@voicenter-team/opensips-js 1.0.92 → 1.0.94
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/index.d.ts +5 -0
- package/dist/opensips-js.cjs.js +129 -132
- package/dist/opensips-js.es.js +13053 -14985
- package/dist/opensips-js.iife.js +129 -132
- package/dist/opensips-js.umd.js +125 -128
- package/package.json +1 -1
- package/src/types/listeners.d.ts +2 -0
package/dist/opensips-js.iife.js
CHANGED
@@ -1,161 +1,158 @@
|
|
1
|
-
var OpensipsJS=function(){"use strict";var zT=Object.defineProperty;var JT=(er,Be,Hr)=>Be in er?zT(er,Be,{enumerable:!0,configurable:!0,writable:!0,value:Hr}):er[Be]=Hr;var Bs=(er,Be,Hr)=>(JT(er,typeof Be!="symbol"?Be+"":Be,Hr),Hr);var er=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Be(u){return u&&u.__esModule&&Object.prototype.hasOwnProperty.call(u,"default")?u.default:u}const ra={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 Yu=ra,pt={USER_AGENT:"".concat(Yu.title," ").concat(Yu.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 ia(u){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?ia=function(a){return typeof a}:ia=function(a){return a&&typeof Symbol=="function"&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a},ia(u)}function aa(u,n){if(!(u instanceof n))throw new TypeError("Cannot call a class as a function")}function oa(u,n){if(typeof n!="function"&&n!==null)throw new TypeError("Super expression must either be null or a function");u.prototype=Object.create(n&&n.prototype,{constructor:{value:u,writable:!0,configurable:!0}}),n&&_i(u,n)}function ua(u){var n=zu();return function(){var e=di(u),o;if(n){var p=di(this).constructor;o=Reflect.construct(e,arguments,p)}else o=e.apply(this,arguments);return Fh(this,o)}}function Fh(u,n){return n&&(ia(n)==="object"||typeof n=="function")?n:qh(u)}function qh(u){if(u===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return u}function Fr(u){var n=typeof Map=="function"?new Map:void 0;return Fr=function(e){if(e===null||!jh(e))return e;if(typeof e!="function")throw new TypeError("Super expression must either be null or a function");if(typeof n<"u"){if(n.has(e))return n.get(e);n.set(e,o)}function o(){return ca(e,arguments,di(this).constructor)}return o.prototype=Object.create(e.prototype,{constructor:{value:o,enumerable:!1,writable:!0,configurable:!0}}),_i(o,e)},Fr(u)}function ca(u,n,a){return zu()?ca=Reflect.construct:ca=function(o,p,t){var v=[null];v.push.apply(v,p);var C=Function.bind.apply(o,v),l=new C;return t&&_i(l,t.prototype),l},ca.apply(null,arguments)}function zu(){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(u){return Function.toString.call(u).indexOf("[native code]")!==-1}function _i(u,n){return _i=Object.setPrototypeOf||function(e,o){return e.__proto__=o,e},_i(u,n)}function di(u){return di=Object.setPrototypeOf?Object.getPrototypeOf:function(a){return a.__proto__||Object.getPrototypeOf(a)},di(u)}var Vh=function(u){oa(a,u);var n=ua(a);function a(e,o){var p;return aa(this,a),p=n.call(this),p.code=1,p.name="CONFIGURATION_ERROR",p.parameter=e,p.value=o,p.message=p.value?"Invalid value ".concat(JSON.stringify(p.value),' for parameter "').concat(p.parameter,'"'):"Missing parameter: ".concat(p.parameter),p}return a}(Fr(Error)),Bh=function(u){oa(a,u);var n=ua(a);function a(e){var o;return aa(this,a),o=n.call(this),o.code=2,o.name="INVALID_STATE_ERROR",o.status=e,o.message="Invalid status: ".concat(e),o}return a}(Fr(Error)),Gh=function(u){oa(a,u);var n=ua(a);function a(e){var o;return aa(this,a),o=n.call(this),o.code=3,o.name="NOT_SUPPORTED_ERROR",o.message=e,o}return a}(Fr(Error)),Wh=function(u){oa(a,u);var n=ua(a);function a(e){var o;return aa(this,a),o=n.call(this),o.code=4,o.name="NOT_READY_ERROR",o.message=e,o}return a}(Fr(Error)),Wn={ConfigurationError:Vh,InvalidStateError:Bh,NotSupportedError:Gh,NotReadyError:Wh},ct={},go,Ju;function vo(){if(Ju)return go;Ju=1;function u(p,t){if(!(p instanceof t))throw new TypeError("Cannot call a class as a function")}function n(p,t){for(var v=0;v<t.length;v++){var C=t[v];C.enumerable=C.enumerable||!1,C.configurable=!0,"value"in C&&(C.writable=!0),Object.defineProperty(p,C.key,C)}}function a(p,t,v){return t&&n(p.prototype,t),v&&n(p,v),p}var e=Kn(),o=Gs();return go=function(){a(p,null,[{key:"parse",value:function(v){if(v=o.parse(v,"Name_Addr_Header"),v!==-1)return v}}]);function p(t,v,C){if(u(this,p),!t||!(t instanceof e))throw new TypeError('missing or invalid "uri" parameter');this._uri=t,this._parameters={},this.display_name=v;for(var l in C)Object.prototype.hasOwnProperty.call(C,l)&&this.setParam(l,C[l])}return a(p,[{key:"setParam",value:function(v,C){v&&(this._parameters[v.toLowerCase()]=typeof C>"u"||C===null?null:C.toString())}},{key:"getParam",value:function(v){if(v)return this._parameters[v.toLowerCase()]}},{key:"hasParam",value:function(v){if(v)return this._parameters.hasOwnProperty(v.toLowerCase())&&!0||!1}},{key:"deleteParam",value:function(v){if(v=v.toLowerCase(),this._parameters.hasOwnProperty(v)){var C=this._parameters[v];return delete this._parameters[v],C}}},{key:"clearParams",value:function(){this._parameters={}}},{key:"clone",value:function(){return new p(this._uri.clone(),this._display_name,JSON.parse(JSON.stringify(this._parameters)))}},{key:"_quote",value:function(v){return v.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}},{key:"toString",value:function(){var v=this._display_name?'"'.concat(this._quote(this._display_name),'" '):"";v+="<".concat(this._uri.toString(),">");for(var C in this._parameters)Object.prototype.hasOwnProperty.call(this._parameters,C)&&(v+=";".concat(C),this._parameters[C]!==null&&(v+="=".concat(this._parameters[C])));return v}},{key:"uri",get:function(){return this._uri}},{key:"display_name",get:function(){return this._display_name},set:function(v){this._display_name=v===0?"0":v}}]),p}(),go}var To,Xu;function Gs(){return Xu||(Xu=1,To=function(){function u(a){return'"'+a.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\x08/g,"\\b").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\f/g,"\\f").replace(/\r/g,"\\r").replace(/[\x00-\x07\x0B\x0E-\x1F\x80-\uFFFF]/g,escape)+'"'}var n={parse:function(e,o){var p={CRLF:A,DIGIT:b,ALPHA:E,HEXDIG:O,WSP:w,OCTET:N,DQUOTE:U,SP:z,HTAB:j,alphanum:_e,reserved:k,unreserved:H,mark:de,escaped:Ue,LWS:B,SWS:L,HCOLON:V,TEXT_UTF8_TRIM:G,TEXT_UTF8char:K,UTF8_NONASCII:M,UTF8_CONT:te,LHEX:se,token:$,token_nodot:ne,separators:ht,word:P,STAR:Q,SLASH:oe,EQUAL:he,LPAREN:Re,RPAREN:be,RAQUOT:fe,LAQUOT:je,COMMA:xe,SEMI:we,COLON:rt,LDQUOT:$e,RDQUOT:ue,comment:Oe,ctext:Pe,quoted_string:Le,quoted_string_clean:ye,qdtext:pe,quoted_pair:Ce,SIP_URI_noparams:ke,SIP_URI:He,uri_scheme:We,uri_scheme_sips:Ve,uri_scheme_sip:Ht,userinfo:_t,user:Xs,user_unreserved:cs,password:Is,hostport:ws,host:fs,hostname:Qs,domainlabel:hs,toplabel:Se,IPv6reference:dt,IPv6address:Zt,h16:Ae,ls32:vt,IPv4address:_s,dec_octet:Ee,port:Et,uri_parameters:Os,uri_parameter:ds,transport_param:rl,user_param:il,method_param:In,ttl_param:al,maddr_param:ol,lr_param:ul,other_param:Ds,pname:cl,pvalue:fl,paramchar:es,param_unreserved:hl,headers:_l,header:Ft,hname:dr,hvalue:dl,hnv_unreserved:ts,Request_Response:pl,Request_Line:ml,Request_URI:Ns,absoluteURI:Zs,hier_part:gl,net_path:Us,abs_path:xs,opaque_part:vl,uric:ss,uric_no_slash:Ps,path_segments:Ms,segment:ns,param:wn,pchar:ks,scheme:en,authority:On,srvr:ps,reg_name:Tl,query:El,SIP_Version:Dn,INVITEm:Cl,ACKm:Sl,OPTIONSm:Nn,BYEm:Al,CANCELm:yl,REGISTERm:Rl,SUBSCRIBEm:tn,NOTIFYm:bl,REFERm:Il,Method:sn,Status_Line:wl,Status_Code:pr,extension_code:Un,Reason_Phrase:mr,Allow_Events:xn,Call_ID:ms,Contact:Pn,contact_param:nn,name_addr:gs,display_name:Mn,contact_params:qt,c_p_q:ls,c_p_expires:ze,delta_seconds:Yt,qvalue:gr,generic_param:Ze,gen_value:zt,Content_Disposition:vr,disp_type:st,disp_param:Ol,handling_param:ei,Content_Encoding:Tr,Content_Length:Dl,Content_Type:Er,media_type:Cr,m_type:kn,discrete_type:Sr,composite_type:Nl,extension_token:Ls,x_token:Ul,m_subtype:Ar,m_parameter:$s,m_value:yr,CSeq:ti,CSeq_value:vs,Expires:si,Event:Rr,event_type:Ts,From:ea,from_param:br,tag_param:Hs,Max_Forwards:ta,Min_Expires:Ln,Name_Addr_Header:xl,Proxy_Authenticate:$n,challenge:ln,other_challenge:Ir,auth_param:rn,digest_cln:Fs,realm:an,realm_value:qs,domain:on,URI:un,nonce:Pl,nonce_value:Ml,opaque:cn,stale:fn,algorithm:wr,qop_options:Or,qop_value:Es,Proxy_Require:ni,Record_Route:kl,rec_route:Cs,Reason:sa,reason_param:Dr,reason_cause:Ss,Require:na,Route:Ll,route_param:js,Subscription_State:li,substate_value:ri,subexp_params:hn,event_reason_value:ii,Subject:$l,Supported:Nr,To:Hn,to_param:Fn,Via:ai,via_param:qn,via_params:_n,via_ttl:Ur,via_maddr:dn,via_received:jn,via_branch:Hl,response_port:Fl,rport:ql,sent_protocol:jl,protocol_name:Vl,transport:Bl,sent_by:Vn,via_host:xr,via_port:Pr,ttl:Bn,WWW_Authenticate:Gl,Session_Expires:Mr,s_e_expires:Wl,s_e_params:Kl,s_e_refresher:oi,extension_header:ui,header_value:Gn,message_body:Jt,uuid_URI:ci,uuid:Yl,hex4:rs,hex8:fi,hex12:zl,Refer_To:Bt,Replaces:kr,call_id:Jl,replaces_param:Xl,to_tag:hi,from_tag:Lr,early_flag:x};if(o!==void 0){if(p[o]===void 0)throw new Error("Invalid rule name: "+u(o)+".")}else o="CRLF";var t=0,v=0,C=[];function l(r){t<v||(t>v&&(v=t,C=[]),C.push(r))}function A(){var r;return e.substr(t,2)===`\r
|
1
|
+
var OpensipsJS=function(){"use strict";var Kv=Object.defineProperty;var Yv=(sn,Le,kn)=>Le in sn?Kv(sn,Le,{enumerable:!0,configurable:!0,writable:!0,value:kn}):sn[Le]=kn;var Qt=(sn,Le,kn)=>(Yv(sn,typeof Le!="symbol"?Le+"":Le,kn),kn);var sn=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Le(c){return c&&c.__esModule&&Object.prototype.hasOwnProperty.call(c,"default")?c.default:c}const pl={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=pl,it={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 ml(c){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?ml=function(i){return typeof i}:ml=function(i){return i&&typeof Symbol=="function"&&i.constructor===Symbol&&i!==Symbol.prototype?"symbol":typeof i},ml(c)}function gl(c,s){if(!(c instanceof s))throw new TypeError("Cannot call a class as a function")}function Tl(c,s){if(typeof s!="function"&&s!==null)throw new TypeError("Super expression must either be null or a function");c.prototype=Object.create(s&&s.prototype,{constructor:{value:c,writable:!0,configurable:!0}}),s&&dr(c,s)}function vl(c){var s=Yu();return function(){var l=pr(c),a;if(s){var _=pr(this).constructor;a=Reflect.construct(l,arguments,_)}else a=l.apply(this,arguments);return $_(this,a)}}function $_(c,s){return s&&(ml(s)==="object"||typeof s=="function")?s:H_(c)}function H_(c){if(c===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return c}function Ln(c){var s=typeof Map=="function"?new Map:void 0;return Ln=function(l){if(l===null||!F_(l))return l;if(typeof l!="function")throw new TypeError("Super expression must either be null or a function");if(typeof s<"u"){if(s.has(l))return s.get(l);s.set(l,a)}function a(){return El(l,arguments,pr(this).constructor)}return a.prototype=Object.create(l.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}}),dr(a,l)},Ln(c)}function El(c,s,i){return Yu()?El=Reflect.construct:El=function(a,_,e){var p=[null];p.push.apply(p,_);var g=Function.bind.apply(a,p),n=new g;return e&&dr(n,e.prototype),n},El.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 F_(c){return Function.toString.call(c).indexOf("[native code]")!==-1}function dr(c,s){return dr=Object.setPrototypeOf||function(l,a){return l.__proto__=a,l},dr(c,s)}function pr(c){return pr=Object.setPrototypeOf?Object.getPrototypeOf:function(i){return i.__proto__||Object.getPrototypeOf(i)},pr(c)}var j_=function(c){Tl(i,c);var s=vl(i);function i(l,a){var _;return gl(this,i),_=s.call(this),_.code=1,_.name="CONFIGURATION_ERROR",_.parameter=l,_.value=a,_.message=_.value?"Invalid value ".concat(JSON.stringify(_.value),' for parameter "').concat(_.parameter,'"'):"Missing parameter: ".concat(_.parameter),_}return i}(Ln(Error)),q_=function(c){Tl(i,c);var s=vl(i);function i(l){var a;return gl(this,i),a=s.call(this),a.code=2,a.name="INVALID_STATE_ERROR",a.status=l,a.message="Invalid status: ".concat(l),a}return i}(Ln(Error)),V_=function(c){Tl(i,c);var s=vl(i);function i(l){var a;return gl(this,i),a=s.call(this),a.code=3,a.name="NOT_SUPPORTED_ERROR",a.message=l,a}return i}(Ln(Error)),B_=function(c){Tl(i,c);var s=vl(i);function i(l){var a;return gl(this,i),a=s.call(this),a.code=4,a.name="NOT_READY_ERROR",a.message=l,a}return i}(Ln(Error)),ws={ConfigurationError:j_,InvalidStateError:q_,NotSupportedError:V_,NotReadyError:B_},nt={},ro,Ju;function io(){if(Ju)return ro;Ju=1;function c(_,e){if(!(_ instanceof e))throw new TypeError("Cannot call a class as a function")}function s(_,e){for(var p=0;p<e.length;p++){var g=e[p];g.enumerable=g.enumerable||!1,g.configurable=!0,"value"in g&&(g.writable=!0),Object.defineProperty(_,g.key,g)}}function i(_,e,p){return e&&s(_.prototype,e),p&&s(_,p),_}var l=Os(),a=Zt();return ro=function(){i(_,null,[{key:"parse",value:function(p){if(p=a.parse(p,"Name_Addr_Header"),p!==-1)return p}}]);function _(e,p,g){if(c(this,_),!e||!(e instanceof l))throw new TypeError('missing or invalid "uri" parameter');this._uri=e,this._parameters={},this.display_name=p;for(var n in g)Object.prototype.hasOwnProperty.call(g,n)&&this.setParam(n,g[n])}return i(_,[{key:"setParam",value:function(p,g){p&&(this._parameters[p.toLowerCase()]=typeof g>"u"||g===null?null:g.toString())}},{key:"getParam",value:function(p){if(p)return this._parameters[p.toLowerCase()]}},{key:"hasParam",value:function(p){if(p)return this._parameters.hasOwnProperty(p.toLowerCase())&&!0||!1}},{key:"deleteParam",value:function(p){if(p=p.toLowerCase(),this._parameters.hasOwnProperty(p)){var g=this._parameters[p];return delete this._parameters[p],g}}},{key:"clearParams",value:function(){this._parameters={}}},{key:"clone",value:function(){return new _(this._uri.clone(),this._display_name,JSON.parse(JSON.stringify(this._parameters)))}},{key:"_quote",value:function(p){return p.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}},{key:"toString",value:function(){var p=this._display_name?'"'.concat(this._quote(this._display_name),'" '):"";p+="<".concat(this._uri.toString(),">");for(var g in this._parameters)Object.prototype.hasOwnProperty.call(this._parameters,g)&&(p+=";".concat(g),this._parameters[g]!==null&&(p+="=".concat(this._parameters[g])));return p}},{key:"uri",get:function(){return this._uri}},{key:"display_name",get:function(){return this._display_name},set:function(p){this._display_name=p===0?"0":p}}]),_}(),ro}var lo,zu;function Zt(){return zu||(zu=1,lo=function(){function c(i){return'"'+i.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\x08/g,"\\b").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\f/g,"\\f").replace(/\r/g,"\\r").replace(/[\x00-\x07\x0B\x0E-\x1F\x80-\uFFFF]/g,escape)+'"'}var s={parse:function(l,a){var _={CRLF:v,DIGIT:S,ALPHA:m,HEXDIG:C,WSP:A,OCTET:R,DQUOTE:I,SP:V,HTAB:W,alphanum:oe,reserved:x,unreserved:$,mark:Re,escaped:be,LWS:H,SWS:D,HCOLON:L,TEXT_UTF8_TRIM:q,TEXT_UTF8char:j,UTF8_NONASCII:B,UTF8_CONT:Q,LHEX:Z,token:U,token_nodot:se,separators:Dt,word:N,STAR:z,SLASH:re,EQUAL:ae,LPAREN:Te,RPAREN:De,RAQUOT:Ce,LAQUOT:He,COMMA:we,SEMI:Se,COLON:ot,LDQUOT:Ue,RDQUOT:le,comment:Ae,ctext:Oe,quoted_string:Pe,quoted_string_clean:ve,qdtext:he,quoted_pair:pe,SIP_URI_noparams:Ne,SIP_URI:Me,uri_scheme:We,uri_scheme_sips:Fe,uri_scheme_sip:Vt,userinfo:dt,user:ei,user_unreserved:Xn,password:gn,hostport:Tn,host:ys,hostname:Qn,domainlabel:Fs,toplabel:js,IPv6reference:vn,IPv6address:En,h16:ge,ls32:Rt,IPv4address:As,dec_octet:de,port:Nt,uri_parameters:qs,uri_parameter:Cs,transport_param:ti,user_param:si,method_param:Zn,ttl_param:ni,maddr_param:ri,lr_param:ii,other_param:li,pname:ai,pvalue:oi,paramchar:Vs,param_unreserved:ui,headers:ci,header:rs,hname:fi,hvalue:_i,hnv_unreserved:is,Request_Response:Ra,Request_Line:hi,Request_URI:Bs,absoluteURI:di,hier_part:pi,net_path:mi,abs_path:Gs,opaque_part:gi,uric:Ws,uric_no_slash:Sn,path_segments:Ti,segment:ls,param:er,pchar:Ks,scheme:yn,authority:tr,srvr:Ys,reg_name:vi,query:Ei,SIP_Version:sr,INVITEm:Si,ACKm:yi,OPTIONSm:nr,BYEm:Ai,CANCELm:Ci,REGISTERm:Ri,SUBSCRIBEm:Ii,NOTIFYm:bi,REFERm:wi,Method:An,Status_Line:Oi,Status_Code:Di,extension_code:Cn,Reason_Phrase:Ni,Allow_Events:Ia,Call_ID:ba,Contact:wa,contact_param:rr,name_addr:Rs,display_name:ir,contact_params:Js,c_p_q:as,c_p_expires:Rn,delta_seconds:Jt,qvalue:Ui,generic_param:et,gen_value:os,Content_Disposition:Oa,disp_type:tt,disp_param:lr,handling_param:Da,Content_Encoding:Na,Content_Length:Pi,Content_Type:Ua,media_type:Pa,m_type:xa,discrete_type:Ma,composite_type:xi,extension_token:In,x_token:Mi,m_subtype:ki,m_parameter:zs,m_value:Li,CSeq:ka,CSeq_value:ar,Expires:La,Event:Lu,event_type:Xs,From:$u,from_param:$i,tag_param:Is,Max_Forwards:Hu,Min_Expires:Hi,Name_Addr_Header:Fi,Proxy_Authenticate:Fu,challenge:ji,other_challenge:$a,auth_param:bn,digest_cln:Qs,realm:qi,realm_value:Zs,domain:wn,URI:On,nonce:Vi,nonce_value:Bi,opaque:Dn,stale:Gi,algorithm:Wi,qop_options:Ki,qop_value:Nn,Proxy_Require:Ha,Record_Route:Fa,rec_route:bs,Reason:ju,reason_param:Yi,reason_cause:Un,Require:qu,Route:Ji,route_param:Pn,Subscription_State:Vu,substate_value:ja,subexp_params:en,event_reason_value:qa,Subject:Va,Supported:zi,To:Ba,to_param:Xi,Via:Bu,via_param:or,via_params:xn,via_ttl:Ga,via_maddr:Mn,via_received:ur,via_branch:Qi,response_port:Zi,rport:el,sent_protocol:tl,protocol_name:sl,transport:nl,sent_by:rl,via_host:il,via_port:ll,ttl:cr,WWW_Authenticate:Wa,Session_Expires:Ka,s_e_expires:fr,s_e_params:al,s_e_refresher:Ya,extension_header:Ja,header_value:_r,message_body:za,uuid_URI:Gu,uuid:ol,hex4:zt,hex8:Xa,hex12:ul,Refer_To:Xt,Replaces:Qa,call_id:cl,replaces_param:fl,to_tag:Za,from_tag:_l,early_flag:hr};if(a!==void 0){if(_[a]===void 0)throw new Error("Invalid rule name: "+c(a)+".")}else a="CRLF";var e=0,p=0,g=[];function n(r){e<p||(e>p&&(p=e,g=[]),g.push(r))}function v(){var r;return l.substr(e,2)===`\r
|
2
2
|
`?(r=`\r
|
3
|
-
`,t+=2):(r=null,l('"\\r\\n"')),r}function b(){var r;return/^[0-9]/.test(e.charAt(t))?(r=e.charAt(t),t++):(r=null,l("[0-9]")),r}function E(){var r;return/^[a-zA-Z]/.test(e.charAt(t))?(r=e.charAt(t),t++):(r=null,l("[a-zA-Z]")),r}function O(){var r;return/^[0-9a-fA-F]/.test(e.charAt(t))?(r=e.charAt(t),t++):(r=null,l("[0-9a-fA-F]")),r}function w(){var r;return r=z(),r===null&&(r=j()),r}function N(){var r;return/^[\0-\xFF]/.test(e.charAt(t))?(r=e.charAt(t),t++):(r=null,l("[\\0-\\xFF]")),r}function U(){var r;return/^["]/.test(e.charAt(t))?(r=e.charAt(t),t++):(r=null,l('["]')),r}function z(){var r;return e.charCodeAt(t)===32?(r=" ",t++):(r=null,l('" "')),r}function j(){var r;return e.charCodeAt(t)===9?(r=" ",t++):(r=null,l('"\\t"')),r}function _e(){var r;return/^[a-zA-Z0-9]/.test(e.charAt(t))?(r=e.charAt(t),t++):(r=null,l("[a-zA-Z0-9]")),r}function k(){var r;return e.charCodeAt(t)===59?(r=";",t++):(r=null,l('";"')),r===null&&(e.charCodeAt(t)===47?(r="/",t++):(r=null,l('"/"')),r===null&&(e.charCodeAt(t)===63?(r="?",t++):(r=null,l('"?"')),r===null&&(e.charCodeAt(t)===58?(r=":",t++):(r=null,l('":"')),r===null&&(e.charCodeAt(t)===64?(r="@",t++):(r=null,l('"@"')),r===null&&(e.charCodeAt(t)===38?(r="&",t++):(r=null,l('"&"')),r===null&&(e.charCodeAt(t)===61?(r="=",t++):(r=null,l('"="')),r===null&&(e.charCodeAt(t)===43?(r="+",t++):(r=null,l('"+"')),r===null&&(e.charCodeAt(t)===36?(r="$",t++):(r=null,l('"$"')),r===null&&(e.charCodeAt(t)===44?(r=",",t++):(r=null,l('","'))))))))))),r}function H(){var r;return r=_e(),r===null&&(r=de()),r}function de(){var r;return e.charCodeAt(t)===45?(r="-",t++):(r=null,l('"-"')),r===null&&(e.charCodeAt(t)===95?(r="_",t++):(r=null,l('"_"')),r===null&&(e.charCodeAt(t)===46?(r=".",t++):(r=null,l('"."')),r===null&&(e.charCodeAt(t)===33?(r="!",t++):(r=null,l('"!"')),r===null&&(e.charCodeAt(t)===126?(r="~",t++):(r=null,l('"~"')),r===null&&(e.charCodeAt(t)===42?(r="*",t++):(r=null,l('"*"')),r===null&&(e.charCodeAt(t)===39?(r="'",t++):(r=null,l(`"'"`)),r===null&&(e.charCodeAt(t)===40?(r="(",t++):(r=null,l('"("')),r===null&&(e.charCodeAt(t)===41?(r=")",t++):(r=null,l('")"')))))))))),r}function Ue(){var r,f,d,s,c;return s=t,c=t,e.charCodeAt(t)===37?(r="%",t++):(r=null,l('"%"')),r!==null?(f=O(),f!==null?(d=O(),d!==null?r=[r,f,d]:(r=null,t=c)):(r=null,t=c)):(r=null,t=c),r!==null&&(r=function(h,g){return g.join("")}(s,r)),r===null&&(t=s),r}function B(){var r,f,d,s,c,h;for(s=t,c=t,h=t,r=[],f=w();f!==null;)r.push(f),f=w();if(r!==null?(f=A(),f!==null?r=[r,f]:(r=null,t=h)):(r=null,t=h),r=r!==null?r:"",r!==null){if(d=w(),d!==null)for(f=[];d!==null;)f.push(d),d=w();else f=null;f!==null?r=[r,f]:(r=null,t=c)}else r=null,t=c;return r!==null&&(r=function(g){return" "}()),r===null&&(t=s),r}function L(){var r;return r=B(),r=r!==null?r:"",r}function V(){var r,f,d,s,c;for(s=t,c=t,r=[],f=z(),f===null&&(f=j());f!==null;)r.push(f),f=z(),f===null&&(f=j());return r!==null?(e.charCodeAt(t)===58?(f=":",t++):(f=null,l('":"')),f!==null?(d=L(),d!==null?r=[r,f,d]:(r=null,t=c)):(r=null,t=c)):(r=null,t=c),r!==null&&(r=function(h){return":"}()),r===null&&(t=s),r}function G(){var r,f,d,s,c,h,g;if(c=t,h=t,f=K(),f!==null)for(r=[];f!==null;)r.push(f),f=K();else r=null;if(r!==null){for(f=[],g=t,d=[],s=B();s!==null;)d.push(s),s=B();for(d!==null?(s=K(),s!==null?d=[d,s]:(d=null,t=g)):(d=null,t=g);d!==null;){for(f.push(d),g=t,d=[],s=B();s!==null;)d.push(s),s=B();d!==null?(s=K(),s!==null?d=[d,s]:(d=null,t=g)):(d=null,t=g)}f!==null?r=[r,f]:(r=null,t=h)}else r=null,t=h;return r!==null&&(r=function(S){return e.substring(t,S)}(c)),r===null&&(t=c),r}function K(){var r;return/^[!-~]/.test(e.charAt(t))?(r=e.charAt(t),t++):(r=null,l("[!-~]")),r===null&&(r=M()),r}function M(){var r;return/^[\x80-\uFFFF]/.test(e.charAt(t))?(r=e.charAt(t),t++):(r=null,l("[\\x80-\\uFFFF]")),r}function te(){var r;return/^[\x80-\xBF]/.test(e.charAt(t))?(r=e.charAt(t),t++):(r=null,l("[\\x80-\\xBF]")),r}function se(){var r;return r=b(),r===null&&(/^[a-f]/.test(e.charAt(t))?(r=e.charAt(t),t++):(r=null,l("[a-f]"))),r}function $(){var r,f,d;if(d=t,f=_e(),f===null&&(e.charCodeAt(t)===45?(f="-",t++):(f=null,l('"-"')),f===null&&(e.charCodeAt(t)===46?(f=".",t++):(f=null,l('"."')),f===null&&(e.charCodeAt(t)===33?(f="!",t++):(f=null,l('"!"')),f===null&&(e.charCodeAt(t)===37?(f="%",t++):(f=null,l('"%"')),f===null&&(e.charCodeAt(t)===42?(f="*",t++):(f=null,l('"*"')),f===null&&(e.charCodeAt(t)===95?(f="_",t++):(f=null,l('"_"')),f===null&&(e.charCodeAt(t)===43?(f="+",t++):(f=null,l('"+"')),f===null&&(e.charCodeAt(t)===96?(f="`",t++):(f=null,l('"`"')),f===null&&(e.charCodeAt(t)===39?(f="'",t++):(f=null,l(`"'"`)),f===null&&(e.charCodeAt(t)===126?(f="~",t++):(f=null,l('"~"')))))))))))),f!==null)for(r=[];f!==null;)r.push(f),f=_e(),f===null&&(e.charCodeAt(t)===45?(f="-",t++):(f=null,l('"-"')),f===null&&(e.charCodeAt(t)===46?(f=".",t++):(f=null,l('"."')),f===null&&(e.charCodeAt(t)===33?(f="!",t++):(f=null,l('"!"')),f===null&&(e.charCodeAt(t)===37?(f="%",t++):(f=null,l('"%"')),f===null&&(e.charCodeAt(t)===42?(f="*",t++):(f=null,l('"*"')),f===null&&(e.charCodeAt(t)===95?(f="_",t++):(f=null,l('"_"')),f===null&&(e.charCodeAt(t)===43?(f="+",t++):(f=null,l('"+"')),f===null&&(e.charCodeAt(t)===96?(f="`",t++):(f=null,l('"`"')),f===null&&(e.charCodeAt(t)===39?(f="'",t++):(f=null,l(`"'"`)),f===null&&(e.charCodeAt(t)===126?(f="~",t++):(f=null,l('"~"'))))))))))));else r=null;return r!==null&&(r=function(s){return e.substring(t,s)}(d)),r===null&&(t=d),r}function ne(){var r,f,d;if(d=t,f=_e(),f===null&&(e.charCodeAt(t)===45?(f="-",t++):(f=null,l('"-"')),f===null&&(e.charCodeAt(t)===33?(f="!",t++):(f=null,l('"!"')),f===null&&(e.charCodeAt(t)===37?(f="%",t++):(f=null,l('"%"')),f===null&&(e.charCodeAt(t)===42?(f="*",t++):(f=null,l('"*"')),f===null&&(e.charCodeAt(t)===95?(f="_",t++):(f=null,l('"_"')),f===null&&(e.charCodeAt(t)===43?(f="+",t++):(f=null,l('"+"')),f===null&&(e.charCodeAt(t)===96?(f="`",t++):(f=null,l('"`"')),f===null&&(e.charCodeAt(t)===39?(f="'",t++):(f=null,l(`"'"`)),f===null&&(e.charCodeAt(t)===126?(f="~",t++):(f=null,l('"~"'))))))))))),f!==null)for(r=[];f!==null;)r.push(f),f=_e(),f===null&&(e.charCodeAt(t)===45?(f="-",t++):(f=null,l('"-"')),f===null&&(e.charCodeAt(t)===33?(f="!",t++):(f=null,l('"!"')),f===null&&(e.charCodeAt(t)===37?(f="%",t++):(f=null,l('"%"')),f===null&&(e.charCodeAt(t)===42?(f="*",t++):(f=null,l('"*"')),f===null&&(e.charCodeAt(t)===95?(f="_",t++):(f=null,l('"_"')),f===null&&(e.charCodeAt(t)===43?(f="+",t++):(f=null,l('"+"')),f===null&&(e.charCodeAt(t)===96?(f="`",t++):(f=null,l('"`"')),f===null&&(e.charCodeAt(t)===39?(f="'",t++):(f=null,l(`"'"`)),f===null&&(e.charCodeAt(t)===126?(f="~",t++):(f=null,l('"~"')))))))))));else r=null;return r!==null&&(r=function(s){return e.substring(t,s)}(d)),r===null&&(t=d),r}function ht(){var r;return e.charCodeAt(t)===40?(r="(",t++):(r=null,l('"("')),r===null&&(e.charCodeAt(t)===41?(r=")",t++):(r=null,l('")"')),r===null&&(e.charCodeAt(t)===60?(r="<",t++):(r=null,l('"<"')),r===null&&(e.charCodeAt(t)===62?(r=">",t++):(r=null,l('">"')),r===null&&(e.charCodeAt(t)===64?(r="@",t++):(r=null,l('"@"')),r===null&&(e.charCodeAt(t)===44?(r=",",t++):(r=null,l('","')),r===null&&(e.charCodeAt(t)===59?(r=";",t++):(r=null,l('";"')),r===null&&(e.charCodeAt(t)===58?(r=":",t++):(r=null,l('":"')),r===null&&(e.charCodeAt(t)===92?(r="\\",t++):(r=null,l('"\\\\"')),r===null&&(r=U(),r===null&&(e.charCodeAt(t)===47?(r="/",t++):(r=null,l('"/"')),r===null&&(e.charCodeAt(t)===91?(r="[",t++):(r=null,l('"["')),r===null&&(e.charCodeAt(t)===93?(r="]",t++):(r=null,l('"]"')),r===null&&(e.charCodeAt(t)===63?(r="?",t++):(r=null,l('"?"')),r===null&&(e.charCodeAt(t)===61?(r="=",t++):(r=null,l('"="')),r===null&&(e.charCodeAt(t)===123?(r="{",t++):(r=null,l('"{"')),r===null&&(e.charCodeAt(t)===125?(r="}",t++):(r=null,l('"}"')),r===null&&(r=z(),r===null&&(r=j())))))))))))))))))),r}function P(){var r,f,d;if(d=t,f=_e(),f===null&&(e.charCodeAt(t)===45?(f="-",t++):(f=null,l('"-"')),f===null&&(e.charCodeAt(t)===46?(f=".",t++):(f=null,l('"."')),f===null&&(e.charCodeAt(t)===33?(f="!",t++):(f=null,l('"!"')),f===null&&(e.charCodeAt(t)===37?(f="%",t++):(f=null,l('"%"')),f===null&&(e.charCodeAt(t)===42?(f="*",t++):(f=null,l('"*"')),f===null&&(e.charCodeAt(t)===95?(f="_",t++):(f=null,l('"_"')),f===null&&(e.charCodeAt(t)===43?(f="+",t++):(f=null,l('"+"')),f===null&&(e.charCodeAt(t)===96?(f="`",t++):(f=null,l('"`"')),f===null&&(e.charCodeAt(t)===39?(f="'",t++):(f=null,l(`"'"`)),f===null&&(e.charCodeAt(t)===126?(f="~",t++):(f=null,l('"~"')),f===null&&(e.charCodeAt(t)===40?(f="(",t++):(f=null,l('"("')),f===null&&(e.charCodeAt(t)===41?(f=")",t++):(f=null,l('")"')),f===null&&(e.charCodeAt(t)===60?(f="<",t++):(f=null,l('"<"')),f===null&&(e.charCodeAt(t)===62?(f=">",t++):(f=null,l('">"')),f===null&&(e.charCodeAt(t)===58?(f=":",t++):(f=null,l('":"')),f===null&&(e.charCodeAt(t)===92?(f="\\",t++):(f=null,l('"\\\\"')),f===null&&(f=U(),f===null&&(e.charCodeAt(t)===47?(f="/",t++):(f=null,l('"/"')),f===null&&(e.charCodeAt(t)===91?(f="[",t++):(f=null,l('"["')),f===null&&(e.charCodeAt(t)===93?(f="]",t++):(f=null,l('"]"')),f===null&&(e.charCodeAt(t)===63?(f="?",t++):(f=null,l('"?"')),f===null&&(e.charCodeAt(t)===123?(f="{",t++):(f=null,l('"{"')),f===null&&(e.charCodeAt(t)===125?(f="}",t++):(f=null,l('"}"'))))))))))))))))))))))))),f!==null)for(r=[];f!==null;)r.push(f),f=_e(),f===null&&(e.charCodeAt(t)===45?(f="-",t++):(f=null,l('"-"')),f===null&&(e.charCodeAt(t)===46?(f=".",t++):(f=null,l('"."')),f===null&&(e.charCodeAt(t)===33?(f="!",t++):(f=null,l('"!"')),f===null&&(e.charCodeAt(t)===37?(f="%",t++):(f=null,l('"%"')),f===null&&(e.charCodeAt(t)===42?(f="*",t++):(f=null,l('"*"')),f===null&&(e.charCodeAt(t)===95?(f="_",t++):(f=null,l('"_"')),f===null&&(e.charCodeAt(t)===43?(f="+",t++):(f=null,l('"+"')),f===null&&(e.charCodeAt(t)===96?(f="`",t++):(f=null,l('"`"')),f===null&&(e.charCodeAt(t)===39?(f="'",t++):(f=null,l(`"'"`)),f===null&&(e.charCodeAt(t)===126?(f="~",t++):(f=null,l('"~"')),f===null&&(e.charCodeAt(t)===40?(f="(",t++):(f=null,l('"("')),f===null&&(e.charCodeAt(t)===41?(f=")",t++):(f=null,l('")"')),f===null&&(e.charCodeAt(t)===60?(f="<",t++):(f=null,l('"<"')),f===null&&(e.charCodeAt(t)===62?(f=">",t++):(f=null,l('">"')),f===null&&(e.charCodeAt(t)===58?(f=":",t++):(f=null,l('":"')),f===null&&(e.charCodeAt(t)===92?(f="\\",t++):(f=null,l('"\\\\"')),f===null&&(f=U(),f===null&&(e.charCodeAt(t)===47?(f="/",t++):(f=null,l('"/"')),f===null&&(e.charCodeAt(t)===91?(f="[",t++):(f=null,l('"["')),f===null&&(e.charCodeAt(t)===93?(f="]",t++):(f=null,l('"]"')),f===null&&(e.charCodeAt(t)===63?(f="?",t++):(f=null,l('"?"')),f===null&&(e.charCodeAt(t)===123?(f="{",t++):(f=null,l('"{"')),f===null&&(e.charCodeAt(t)===125?(f="}",t++):(f=null,l('"}"')))))))))))))))))))))))));else r=null;return r!==null&&(r=function(s){return e.substring(t,s)}(d)),r===null&&(t=d),r}function Q(){var r,f,d,s,c;return s=t,c=t,r=L(),r!==null?(e.charCodeAt(t)===42?(f="*",t++):(f=null,l('"*"')),f!==null?(d=L(),d!==null?r=[r,f,d]:(r=null,t=c)):(r=null,t=c)):(r=null,t=c),r!==null&&(r=function(h){return"*"}()),r===null&&(t=s),r}function oe(){var r,f,d,s,c;return s=t,c=t,r=L(),r!==null?(e.charCodeAt(t)===47?(f="/",t++):(f=null,l('"/"')),f!==null?(d=L(),d!==null?r=[r,f,d]:(r=null,t=c)):(r=null,t=c)):(r=null,t=c),r!==null&&(r=function(h){return"/"}()),r===null&&(t=s),r}function he(){var r,f,d,s,c;return s=t,c=t,r=L(),r!==null?(e.charCodeAt(t)===61?(f="=",t++):(f=null,l('"="')),f!==null?(d=L(),d!==null?r=[r,f,d]:(r=null,t=c)):(r=null,t=c)):(r=null,t=c),r!==null&&(r=function(h){return"="}()),r===null&&(t=s),r}function Re(){var r,f,d,s,c;return s=t,c=t,r=L(),r!==null?(e.charCodeAt(t)===40?(f="(",t++):(f=null,l('"("')),f!==null?(d=L(),d!==null?r=[r,f,d]:(r=null,t=c)):(r=null,t=c)):(r=null,t=c),r!==null&&(r=function(h){return"("}()),r===null&&(t=s),r}function be(){var r,f,d,s,c;return s=t,c=t,r=L(),r!==null?(e.charCodeAt(t)===41?(f=")",t++):(f=null,l('")"')),f!==null?(d=L(),d!==null?r=[r,f,d]:(r=null,t=c)):(r=null,t=c)):(r=null,t=c),r!==null&&(r=function(h){return")"}()),r===null&&(t=s),r}function fe(){var r,f,d,s;return d=t,s=t,e.charCodeAt(t)===62?(r=">",t++):(r=null,l('">"')),r!==null?(f=L(),f!==null?r=[r,f]:(r=null,t=s)):(r=null,t=s),r!==null&&(r=function(c){return">"}()),r===null&&(t=d),r}function je(){var r,f,d,s;return d=t,s=t,r=L(),r!==null?(e.charCodeAt(t)===60?(f="<",t++):(f=null,l('"<"')),f!==null?r=[r,f]:(r=null,t=s)):(r=null,t=s),r!==null&&(r=function(c){return"<"}()),r===null&&(t=d),r}function xe(){var r,f,d,s,c;return s=t,c=t,r=L(),r!==null?(e.charCodeAt(t)===44?(f=",",t++):(f=null,l('","')),f!==null?(d=L(),d!==null?r=[r,f,d]:(r=null,t=c)):(r=null,t=c)):(r=null,t=c),r!==null&&(r=function(h){return","}()),r===null&&(t=s),r}function we(){var r,f,d,s,c;return s=t,c=t,r=L(),r!==null?(e.charCodeAt(t)===59?(f=";",t++):(f=null,l('";"')),f!==null?(d=L(),d!==null?r=[r,f,d]:(r=null,t=c)):(r=null,t=c)):(r=null,t=c),r!==null&&(r=function(h){return";"}()),r===null&&(t=s),r}function rt(){var r,f,d,s,c;return s=t,c=t,r=L(),r!==null?(e.charCodeAt(t)===58?(f=":",t++):(f=null,l('":"')),f!==null?(d=L(),d!==null?r=[r,f,d]:(r=null,t=c)):(r=null,t=c)):(r=null,t=c),r!==null&&(r=function(h){return":"}()),r===null&&(t=s),r}function $e(){var r,f,d,s;return d=t,s=t,r=L(),r!==null?(f=U(),f!==null?r=[r,f]:(r=null,t=s)):(r=null,t=s),r!==null&&(r=function(c){return'"'}()),r===null&&(t=d),r}function ue(){var r,f,d,s;return d=t,s=t,r=U(),r!==null?(f=L(),f!==null?r=[r,f]:(r=null,t=s)):(r=null,t=s),r!==null&&(r=function(c){return'"'}()),r===null&&(t=d),r}function Oe(){var r,f,d,s;if(s=t,r=Re(),r!==null){for(f=[],d=Pe(),d===null&&(d=Ce(),d===null&&(d=Oe()));d!==null;)f.push(d),d=Pe(),d===null&&(d=Ce(),d===null&&(d=Oe()));f!==null?(d=be(),d!==null?r=[r,f,d]:(r=null,t=s)):(r=null,t=s)}else r=null,t=s;return r}function Pe(){var r;return/^[!-']/.test(e.charAt(t))?(r=e.charAt(t),t++):(r=null,l("[!-']")),r===null&&(/^[*-[]/.test(e.charAt(t))?(r=e.charAt(t),t++):(r=null,l("[*-[]")),r===null&&(/^[\]-~]/.test(e.charAt(t))?(r=e.charAt(t),t++):(r=null,l("[\\]-~]")),r===null&&(r=M(),r===null&&(r=B())))),r}function Le(){var r,f,d,s,c,h;if(c=t,h=t,r=L(),r!==null)if(f=U(),f!==null){for(d=[],s=pe(),s===null&&(s=Ce());s!==null;)d.push(s),s=pe(),s===null&&(s=Ce());d!==null?(s=U(),s!==null?r=[r,f,d,s]:(r=null,t=h)):(r=null,t=h)}else r=null,t=h;else r=null,t=h;return r!==null&&(r=function(g){return e.substring(t,g)}(c)),r===null&&(t=c),r}function ye(){var r,f,d,s,c,h;if(c=t,h=t,r=L(),r!==null)if(f=U(),f!==null){for(d=[],s=pe(),s===null&&(s=Ce());s!==null;)d.push(s),s=pe(),s===null&&(s=Ce());d!==null?(s=U(),s!==null?r=[r,f,d,s]:(r=null,t=h)):(r=null,t=h)}else r=null,t=h;else r=null,t=h;return r!==null&&(r=function(g){var S=e.substring(t,g).trim();return S.substring(1,S.length-1).replace(/\\([\x00-\x09\x0b-\x0c\x0e-\x7f])/g,"$1")}(c)),r===null&&(t=c),r}function pe(){var r;return r=B(),r===null&&(e.charCodeAt(t)===33?(r="!",t++):(r=null,l('"!"')),r===null&&(/^[#-[]/.test(e.charAt(t))?(r=e.charAt(t),t++):(r=null,l("[#-[]")),r===null&&(/^[\]-~]/.test(e.charAt(t))?(r=e.charAt(t),t++):(r=null,l("[\\]-~]")),r===null&&(r=M())))),r}function Ce(){var r,f,d;return d=t,e.charCodeAt(t)===92?(r="\\",t++):(r=null,l('"\\\\"')),r!==null?(/^[\0-\t]/.test(e.charAt(t))?(f=e.charAt(t),t++):(f=null,l("[\\0-\\t]")),f===null&&(/^[\x0B-\f]/.test(e.charAt(t))?(f=e.charAt(t),t++):(f=null,l("[\\x0B-\\f]")),f===null&&(/^[\x0E-]/.test(e.charAt(t))?(f=e.charAt(t),t++):(f=null,l("[\\x0E-]")))),f!==null?r=[r,f]:(r=null,t=d)):(r=null,t=d),r}function ke(){var r,f,d,s,c,h;return c=t,h=t,r=We(),r!==null?(e.charCodeAt(t)===58?(f=":",t++):(f=null,l('":"')),f!==null?(d=_t(),d=d!==null?d:"",d!==null?(s=ws(),s!==null?r=[r,f,d,s]:(r=null,t=h)):(r=null,t=h)):(r=null,t=h)):(r=null,t=h),r!==null&&(r=function(g){try{i.uri=new $r(i.scheme,i.user,i.host,i.port),delete i.scheme,delete i.user,delete i.host,delete i.host_type,delete i.port}catch{i=-1}}()),r===null&&(t=c),r}function He(){var r,f,d,s,c,h,g,S;return g=t,S=t,r=We(),r!==null?(e.charCodeAt(t)===58?(f=":",t++):(f=null,l('":"')),f!==null?(d=_t(),d=d!==null?d:"",d!==null?(s=ws(),s!==null?(c=Os(),c!==null?(h=_l(),h=h!==null?h:"",h!==null?r=[r,f,d,s,c,h]:(r=null,t=S)):(r=null,t=S)):(r=null,t=S)):(r=null,t=S)):(r=null,t=S)):(r=null,t=S),r!==null&&(r=function(R){try{i.uri=new $r(i.scheme,i.user,i.host,i.port,i.uri_params,i.uri_headers),delete i.scheme,delete i.user,delete i.host,delete i.host_type,delete i.port,delete i.uri_params,o==="SIP_URI"&&(i=i.uri)}catch{i=-1}}()),r===null&&(t=g),r}function We(){var r;return r=Ve(),r===null&&(r=Ht()),r}function Ve(){var r,f;return f=t,e.substr(t,4).toLowerCase()==="sips"?(r=e.substr(t,4),t+=4):(r=null,l('"sips"')),r!==null&&(r=function(d,s){i.scheme=s.toLowerCase()}(f,r)),r===null&&(t=f),r}function Ht(){var r,f;return f=t,e.substr(t,3).toLowerCase()==="sip"?(r=e.substr(t,3),t+=3):(r=null,l('"sip"')),r!==null&&(r=function(d,s){i.scheme=s.toLowerCase()}(f,r)),r===null&&(t=f),r}function _t(){var r,f,d,s,c,h;return s=t,c=t,r=Xs(),r!==null?(h=t,e.charCodeAt(t)===58?(f=":",t++):(f=null,l('":"')),f!==null?(d=Is(),d!==null?f=[f,d]:(f=null,t=h)):(f=null,t=h),f=f!==null?f:"",f!==null?(e.charCodeAt(t)===64?(d="@",t++):(d=null,l('"@"')),d!==null?r=[r,f,d]:(r=null,t=c)):(r=null,t=c)):(r=null,t=c),r!==null&&(r=function(g){i.user=decodeURIComponent(e.substring(t-1,g))}(s)),r===null&&(t=s),r}function Xs(){var r,f;if(f=H(),f===null&&(f=Ue(),f===null&&(f=cs())),f!==null)for(r=[];f!==null;)r.push(f),f=H(),f===null&&(f=Ue(),f===null&&(f=cs()));else r=null;return r}function cs(){var r;return e.charCodeAt(t)===38?(r="&",t++):(r=null,l('"&"')),r===null&&(e.charCodeAt(t)===61?(r="=",t++):(r=null,l('"="')),r===null&&(e.charCodeAt(t)===43?(r="+",t++):(r=null,l('"+"')),r===null&&(e.charCodeAt(t)===36?(r="$",t++):(r=null,l('"$"')),r===null&&(e.charCodeAt(t)===44?(r=",",t++):(r=null,l('","')),r===null&&(e.charCodeAt(t)===59?(r=";",t++):(r=null,l('";"')),r===null&&(e.charCodeAt(t)===63?(r="?",t++):(r=null,l('"?"')),r===null&&(e.charCodeAt(t)===47?(r="/",t++):(r=null,l('"/"'))))))))),r}function Is(){var r,f,d;for(d=t,r=[],f=H(),f===null&&(f=Ue(),f===null&&(e.charCodeAt(t)===38?(f="&",t++):(f=null,l('"&"')),f===null&&(e.charCodeAt(t)===61?(f="=",t++):(f=null,l('"="')),f===null&&(e.charCodeAt(t)===43?(f="+",t++):(f=null,l('"+"')),f===null&&(e.charCodeAt(t)===36?(f="$",t++):(f=null,l('"$"')),f===null&&(e.charCodeAt(t)===44?(f=",",t++):(f=null,l('","'))))))));f!==null;)r.push(f),f=H(),f===null&&(f=Ue(),f===null&&(e.charCodeAt(t)===38?(f="&",t++):(f=null,l('"&"')),f===null&&(e.charCodeAt(t)===61?(f="=",t++):(f=null,l('"="')),f===null&&(e.charCodeAt(t)===43?(f="+",t++):(f=null,l('"+"')),f===null&&(e.charCodeAt(t)===36?(f="$",t++):(f=null,l('"$"')),f===null&&(e.charCodeAt(t)===44?(f=",",t++):(f=null,l('","'))))))));return r!==null&&(r=function(s){i.password=e.substring(t,s)}(d)),r===null&&(t=d),r}function ws(){var r,f,d,s,c;return s=t,r=fs(),r!==null?(c=t,e.charCodeAt(t)===58?(f=":",t++):(f=null,l('":"')),f!==null?(d=Et(),d!==null?f=[f,d]:(f=null,t=c)):(f=null,t=c),f=f!==null?f:"",f!==null?r=[r,f]:(r=null,t=s)):(r=null,t=s),r}function fs(){var r,f;return f=t,r=Qs(),r===null&&(r=_s(),r===null&&(r=dt())),r!==null&&(r=function(d){return i.host=e.substring(t,d).toLowerCase(),i.host}(f)),r===null&&(t=f),r}function Qs(){var r,f,d,s,c,h;for(s=t,c=t,r=[],h=t,f=hs(),f!==null?(e.charCodeAt(t)===46?(d=".",t++):(d=null,l('"."')),d!==null?f=[f,d]:(f=null,t=h)):(f=null,t=h);f!==null;)r.push(f),h=t,f=hs(),f!==null?(e.charCodeAt(t)===46?(d=".",t++):(d=null,l('"."')),d!==null?f=[f,d]:(f=null,t=h)):(f=null,t=h);return r!==null?(f=Se(),f!==null?(e.charCodeAt(t)===46?(d=".",t++):(d=null,l('"."')),d=d!==null?d:"",d!==null?r=[r,f,d]:(r=null,t=c)):(r=null,t=c)):(r=null,t=c),r!==null&&(r=function(g){return i.host_type="domain",e.substring(t,g)}(s)),r===null&&(t=s),r}function hs(){var r,f,d,s;if(s=t,r=_e(),r!==null){for(f=[],d=_e(),d===null&&(e.charCodeAt(t)===45?(d="-",t++):(d=null,l('"-"')),d===null&&(e.charCodeAt(t)===95?(d="_",t++):(d=null,l('"_"'))));d!==null;)f.push(d),d=_e(),d===null&&(e.charCodeAt(t)===45?(d="-",t++):(d=null,l('"-"')),d===null&&(e.charCodeAt(t)===95?(d="_",t++):(d=null,l('"_"'))));f!==null?r=[r,f]:(r=null,t=s)}else r=null,t=s;return r}function Se(){var r,f,d,s;if(s=t,r=E(),r!==null){for(f=[],d=_e(),d===null&&(e.charCodeAt(t)===45?(d="-",t++):(d=null,l('"-"')),d===null&&(e.charCodeAt(t)===95?(d="_",t++):(d=null,l('"_"'))));d!==null;)f.push(d),d=_e(),d===null&&(e.charCodeAt(t)===45?(d="-",t++):(d=null,l('"-"')),d===null&&(e.charCodeAt(t)===95?(d="_",t++):(d=null,l('"_"'))));f!==null?r=[r,f]:(r=null,t=s)}else r=null,t=s;return r}function dt(){var r,f,d,s,c;return s=t,c=t,e.charCodeAt(t)===91?(r="[",t++):(r=null,l('"["')),r!==null?(f=Zt(),f!==null?(e.charCodeAt(t)===93?(d="]",t++):(d=null,l('"]"')),d!==null?r=[r,f,d]:(r=null,t=c)):(r=null,t=c)):(r=null,t=c),r!==null&&(r=function(h){return i.host_type="IPv6",e.substring(t,h)}(s)),r===null&&(t=s),r}function Zt(){var r,f,d,s,c,h,g,S,R,I,D,J,Ne,Ke,F,Ie;return Ke=t,F=t,r=Ae(),r!==null?(e.charCodeAt(t)===58?(f=":",t++):(f=null,l('":"')),f!==null?(d=Ae(),d!==null?(e.charCodeAt(t)===58?(s=":",t++):(s=null,l('":"')),s!==null?(c=Ae(),c!==null?(e.charCodeAt(t)===58?(h=":",t++):(h=null,l('":"')),h!==null?(g=Ae(),g!==null?(e.charCodeAt(t)===58?(S=":",t++):(S=null,l('":"')),S!==null?(R=Ae(),R!==null?(e.charCodeAt(t)===58?(I=":",t++):(I=null,l('":"')),I!==null?(D=Ae(),D!==null?(e.charCodeAt(t)===58?(J=":",t++):(J=null,l('":"')),J!==null?(Ne=vt(),Ne!==null?r=[r,f,d,s,c,h,g,S,R,I,D,J,Ne]:(r=null,t=F)):(r=null,t=F)):(r=null,t=F)):(r=null,t=F)):(r=null,t=F)):(r=null,t=F)):(r=null,t=F)):(r=null,t=F)):(r=null,t=F)):(r=null,t=F)):(r=null,t=F)):(r=null,t=F)):(r=null,t=F),r===null&&(F=t,e.substr(t,2)==="::"?(r="::",t+=2):(r=null,l('"::"')),r!==null?(f=Ae(),f!==null?(e.charCodeAt(t)===58?(d=":",t++):(d=null,l('":"')),d!==null?(s=Ae(),s!==null?(e.charCodeAt(t)===58?(c=":",t++):(c=null,l('":"')),c!==null?(h=Ae(),h!==null?(e.charCodeAt(t)===58?(g=":",t++):(g=null,l('":"')),g!==null?(S=Ae(),S!==null?(e.charCodeAt(t)===58?(R=":",t++):(R=null,l('":"')),R!==null?(I=Ae(),I!==null?(e.charCodeAt(t)===58?(D=":",t++):(D=null,l('":"')),D!==null?(J=vt(),J!==null?r=[r,f,d,s,c,h,g,S,R,I,D,J]:(r=null,t=F)):(r=null,t=F)):(r=null,t=F)):(r=null,t=F)):(r=null,t=F)):(r=null,t=F)):(r=null,t=F)):(r=null,t=F)):(r=null,t=F)):(r=null,t=F)):(r=null,t=F)):(r=null,t=F),r===null&&(F=t,e.substr(t,2)==="::"?(r="::",t+=2):(r=null,l('"::"')),r!==null?(f=Ae(),f!==null?(e.charCodeAt(t)===58?(d=":",t++):(d=null,l('":"')),d!==null?(s=Ae(),s!==null?(e.charCodeAt(t)===58?(c=":",t++):(c=null,l('":"')),c!==null?(h=Ae(),h!==null?(e.charCodeAt(t)===58?(g=":",t++):(g=null,l('":"')),g!==null?(S=Ae(),S!==null?(e.charCodeAt(t)===58?(R=":",t++):(R=null,l('":"')),R!==null?(I=vt(),I!==null?r=[r,f,d,s,c,h,g,S,R,I]:(r=null,t=F)):(r=null,t=F)):(r=null,t=F)):(r=null,t=F)):(r=null,t=F)):(r=null,t=F)):(r=null,t=F)):(r=null,t=F)):(r=null,t=F)):(r=null,t=F),r===null&&(F=t,e.substr(t,2)==="::"?(r="::",t+=2):(r=null,l('"::"')),r!==null?(f=Ae(),f!==null?(e.charCodeAt(t)===58?(d=":",t++):(d=null,l('":"')),d!==null?(s=Ae(),s!==null?(e.charCodeAt(t)===58?(c=":",t++):(c=null,l('":"')),c!==null?(h=Ae(),h!==null?(e.charCodeAt(t)===58?(g=":",t++):(g=null,l('":"')),g!==null?(S=vt(),S!==null?r=[r,f,d,s,c,h,g,S]:(r=null,t=F)):(r=null,t=F)):(r=null,t=F)):(r=null,t=F)):(r=null,t=F)):(r=null,t=F)):(r=null,t=F)):(r=null,t=F),r===null&&(F=t,e.substr(t,2)==="::"?(r="::",t+=2):(r=null,l('"::"')),r!==null?(f=Ae(),f!==null?(e.charCodeAt(t)===58?(d=":",t++):(d=null,l('":"')),d!==null?(s=Ae(),s!==null?(e.charCodeAt(t)===58?(c=":",t++):(c=null,l('":"')),c!==null?(h=vt(),h!==null?r=[r,f,d,s,c,h]:(r=null,t=F)):(r=null,t=F)):(r=null,t=F)):(r=null,t=F)):(r=null,t=F)):(r=null,t=F),r===null&&(F=t,e.substr(t,2)==="::"?(r="::",t+=2):(r=null,l('"::"')),r!==null?(f=Ae(),f!==null?(e.charCodeAt(t)===58?(d=":",t++):(d=null,l('":"')),d!==null?(s=vt(),s!==null?r=[r,f,d,s]:(r=null,t=F)):(r=null,t=F)):(r=null,t=F)):(r=null,t=F),r===null&&(F=t,e.substr(t,2)==="::"?(r="::",t+=2):(r=null,l('"::"')),r!==null?(f=vt(),f!==null?r=[r,f]:(r=null,t=F)):(r=null,t=F),r===null&&(F=t,e.substr(t,2)==="::"?(r="::",t+=2):(r=null,l('"::"')),r!==null?(f=Ae(),f!==null?r=[r,f]:(r=null,t=F)):(r=null,t=F),r===null&&(F=t,r=Ae(),r!==null?(e.substr(t,2)==="::"?(f="::",t+=2):(f=null,l('"::"')),f!==null?(d=Ae(),d!==null?(e.charCodeAt(t)===58?(s=":",t++):(s=null,l('":"')),s!==null?(c=Ae(),c!==null?(e.charCodeAt(t)===58?(h=":",t++):(h=null,l('":"')),h!==null?(g=Ae(),g!==null?(e.charCodeAt(t)===58?(S=":",t++):(S=null,l('":"')),S!==null?(R=Ae(),R!==null?(e.charCodeAt(t)===58?(I=":",t++):(I=null,l('":"')),I!==null?(D=vt(),D!==null?r=[r,f,d,s,c,h,g,S,R,I,D]:(r=null,t=F)):(r=null,t=F)):(r=null,t=F)):(r=null,t=F)):(r=null,t=F)):(r=null,t=F)):(r=null,t=F)):(r=null,t=F)):(r=null,t=F)):(r=null,t=F)):(r=null,t=F),r===null&&(F=t,r=Ae(),r!==null?(Ie=t,e.charCodeAt(t)===58?(f=":",t++):(f=null,l('":"')),f!==null?(d=Ae(),d!==null?f=[f,d]:(f=null,t=Ie)):(f=null,t=Ie),f=f!==null?f:"",f!==null?(e.substr(t,2)==="::"?(d="::",t+=2):(d=null,l('"::"')),d!==null?(s=Ae(),s!==null?(e.charCodeAt(t)===58?(c=":",t++):(c=null,l('":"')),c!==null?(h=Ae(),h!==null?(e.charCodeAt(t)===58?(g=":",t++):(g=null,l('":"')),g!==null?(S=Ae(),S!==null?(e.charCodeAt(t)===58?(R=":",t++):(R=null,l('":"')),R!==null?(I=vt(),I!==null?r=[r,f,d,s,c,h,g,S,R,I]:(r=null,t=F)):(r=null,t=F)):(r=null,t=F)):(r=null,t=F)):(r=null,t=F)):(r=null,t=F)):(r=null,t=F)):(r=null,t=F)):(r=null,t=F)):(r=null,t=F),r===null&&(F=t,r=Ae(),r!==null?(Ie=t,e.charCodeAt(t)===58?(f=":",t++):(f=null,l('":"')),f!==null?(d=Ae(),d!==null?f=[f,d]:(f=null,t=Ie)):(f=null,t=Ie),f=f!==null?f:"",f!==null?(Ie=t,e.charCodeAt(t)===58?(d=":",t++):(d=null,l('":"')),d!==null?(s=Ae(),s!==null?d=[d,s]:(d=null,t=Ie)):(d=null,t=Ie),d=d!==null?d:"",d!==null?(e.substr(t,2)==="::"?(s="::",t+=2):(s=null,l('"::"')),s!==null?(c=Ae(),c!==null?(e.charCodeAt(t)===58?(h=":",t++):(h=null,l('":"')),h!==null?(g=Ae(),g!==null?(e.charCodeAt(t)===58?(S=":",t++):(S=null,l('":"')),S!==null?(R=vt(),R!==null?r=[r,f,d,s,c,h,g,S,R]:(r=null,t=F)):(r=null,t=F)):(r=null,t=F)):(r=null,t=F)):(r=null,t=F)):(r=null,t=F)):(r=null,t=F)):(r=null,t=F)):(r=null,t=F),r===null&&(F=t,r=Ae(),r!==null?(Ie=t,e.charCodeAt(t)===58?(f=":",t++):(f=null,l('":"')),f!==null?(d=Ae(),d!==null?f=[f,d]:(f=null,t=Ie)):(f=null,t=Ie),f=f!==null?f:"",f!==null?(Ie=t,e.charCodeAt(t)===58?(d=":",t++):(d=null,l('":"')),d!==null?(s=Ae(),s!==null?d=[d,s]:(d=null,t=Ie)):(d=null,t=Ie),d=d!==null?d:"",d!==null?(Ie=t,e.charCodeAt(t)===58?(s=":",t++):(s=null,l('":"')),s!==null?(c=Ae(),c!==null?s=[s,c]:(s=null,t=Ie)):(s=null,t=Ie),s=s!==null?s:"",s!==null?(e.substr(t,2)==="::"?(c="::",t+=2):(c=null,l('"::"')),c!==null?(h=Ae(),h!==null?(e.charCodeAt(t)===58?(g=":",t++):(g=null,l('":"')),g!==null?(S=vt(),S!==null?r=[r,f,d,s,c,h,g,S]:(r=null,t=F)):(r=null,t=F)):(r=null,t=F)):(r=null,t=F)):(r=null,t=F)):(r=null,t=F)):(r=null,t=F)):(r=null,t=F),r===null&&(F=t,r=Ae(),r!==null?(Ie=t,e.charCodeAt(t)===58?(f=":",t++):(f=null,l('":"')),f!==null?(d=Ae(),d!==null?f=[f,d]:(f=null,t=Ie)):(f=null,t=Ie),f=f!==null?f:"",f!==null?(Ie=t,e.charCodeAt(t)===58?(d=":",t++):(d=null,l('":"')),d!==null?(s=Ae(),s!==null?d=[d,s]:(d=null,t=Ie)):(d=null,t=Ie),d=d!==null?d:"",d!==null?(Ie=t,e.charCodeAt(t)===58?(s=":",t++):(s=null,l('":"')),s!==null?(c=Ae(),c!==null?s=[s,c]:(s=null,t=Ie)):(s=null,t=Ie),s=s!==null?s:"",s!==null?(Ie=t,e.charCodeAt(t)===58?(c=":",t++):(c=null,l('":"')),c!==null?(h=Ae(),h!==null?c=[c,h]:(c=null,t=Ie)):(c=null,t=Ie),c=c!==null?c:"",c!==null?(e.substr(t,2)==="::"?(h="::",t+=2):(h=null,l('"::"')),h!==null?(g=vt(),g!==null?r=[r,f,d,s,c,h,g]:(r=null,t=F)):(r=null,t=F)):(r=null,t=F)):(r=null,t=F)):(r=null,t=F)):(r=null,t=F)):(r=null,t=F),r===null&&(F=t,r=Ae(),r!==null?(Ie=t,e.charCodeAt(t)===58?(f=":",t++):(f=null,l('":"')),f!==null?(d=Ae(),d!==null?f=[f,d]:(f=null,t=Ie)):(f=null,t=Ie),f=f!==null?f:"",f!==null?(Ie=t,e.charCodeAt(t)===58?(d=":",t++):(d=null,l('":"')),d!==null?(s=Ae(),s!==null?d=[d,s]:(d=null,t=Ie)):(d=null,t=Ie),d=d!==null?d:"",d!==null?(Ie=t,e.charCodeAt(t)===58?(s=":",t++):(s=null,l('":"')),s!==null?(c=Ae(),c!==null?s=[s,c]:(s=null,t=Ie)):(s=null,t=Ie),s=s!==null?s:"",s!==null?(Ie=t,e.charCodeAt(t)===58?(c=":",t++):(c=null,l('":"')),c!==null?(h=Ae(),h!==null?c=[c,h]:(c=null,t=Ie)):(c=null,t=Ie),c=c!==null?c:"",c!==null?(Ie=t,e.charCodeAt(t)===58?(h=":",t++):(h=null,l('":"')),h!==null?(g=Ae(),g!==null?h=[h,g]:(h=null,t=Ie)):(h=null,t=Ie),h=h!==null?h:"",h!==null?(e.substr(t,2)==="::"?(g="::",t+=2):(g=null,l('"::"')),g!==null?(S=Ae(),S!==null?r=[r,f,d,s,c,h,g,S]:(r=null,t=F)):(r=null,t=F)):(r=null,t=F)):(r=null,t=F)):(r=null,t=F)):(r=null,t=F)):(r=null,t=F)):(r=null,t=F),r===null&&(F=t,r=Ae(),r!==null?(Ie=t,e.charCodeAt(t)===58?(f=":",t++):(f=null,l('":"')),f!==null?(d=Ae(),d!==null?f=[f,d]:(f=null,t=Ie)):(f=null,t=Ie),f=f!==null?f:"",f!==null?(Ie=t,e.charCodeAt(t)===58?(d=":",t++):(d=null,l('":"')),d!==null?(s=Ae(),s!==null?d=[d,s]:(d=null,t=Ie)):(d=null,t=Ie),d=d!==null?d:"",d!==null?(Ie=t,e.charCodeAt(t)===58?(s=":",t++):(s=null,l('":"')),s!==null?(c=Ae(),c!==null?s=[s,c]:(s=null,t=Ie)):(s=null,t=Ie),s=s!==null?s:"",s!==null?(Ie=t,e.charCodeAt(t)===58?(c=":",t++):(c=null,l('":"')),c!==null?(h=Ae(),h!==null?c=[c,h]:(c=null,t=Ie)):(c=null,t=Ie),c=c!==null?c:"",c!==null?(Ie=t,e.charCodeAt(t)===58?(h=":",t++):(h=null,l('":"')),h!==null?(g=Ae(),g!==null?h=[h,g]:(h=null,t=Ie)):(h=null,t=Ie),h=h!==null?h:"",h!==null?(Ie=t,e.charCodeAt(t)===58?(g=":",t++):(g=null,l('":"')),g!==null?(S=Ae(),S!==null?g=[g,S]:(g=null,t=Ie)):(g=null,t=Ie),g=g!==null?g:"",g!==null?(e.substr(t,2)==="::"?(S="::",t+=2):(S=null,l('"::"')),S!==null?r=[r,f,d,s,c,h,g,S]:(r=null,t=F)):(r=null,t=F)):(r=null,t=F)):(r=null,t=F)):(r=null,t=F)):(r=null,t=F)):(r=null,t=F)):(r=null,t=F))))))))))))))),r!==null&&(r=function(la){return i.host_type="IPv6",e.substring(t,la)}(Ke)),r===null&&(t=Ke),r}function Ae(){var r,f,d,s,c;return c=t,r=O(),r!==null?(f=O(),f=f!==null?f:"",f!==null?(d=O(),d=d!==null?d:"",d!==null?(s=O(),s=s!==null?s:"",s!==null?r=[r,f,d,s]:(r=null,t=c)):(r=null,t=c)):(r=null,t=c)):(r=null,t=c),r}function vt(){var r,f,d,s;return s=t,r=Ae(),r!==null?(e.charCodeAt(t)===58?(f=":",t++):(f=null,l('":"')),f!==null?(d=Ae(),d!==null?r=[r,f,d]:(r=null,t=s)):(r=null,t=s)):(r=null,t=s),r===null&&(r=_s()),r}function _s(){var r,f,d,s,c,h,g,S,R;return S=t,R=t,r=Ee(),r!==null?(e.charCodeAt(t)===46?(f=".",t++):(f=null,l('"."')),f!==null?(d=Ee(),d!==null?(e.charCodeAt(t)===46?(s=".",t++):(s=null,l('"."')),s!==null?(c=Ee(),c!==null?(e.charCodeAt(t)===46?(h=".",t++):(h=null,l('"."')),h!==null?(g=Ee(),g!==null?r=[r,f,d,s,c,h,g]:(r=null,t=R)):(r=null,t=R)):(r=null,t=R)):(r=null,t=R)):(r=null,t=R)):(r=null,t=R)):(r=null,t=R),r!==null&&(r=function(I){return i.host_type="IPv4",e.substring(t,I)}(S)),r===null&&(t=S),r}function Ee(){var r,f,d,s;return s=t,e.substr(t,2)==="25"?(r="25",t+=2):(r=null,l('"25"')),r!==null?(/^[0-5]/.test(e.charAt(t))?(f=e.charAt(t),t++):(f=null,l("[0-5]")),f!==null?r=[r,f]:(r=null,t=s)):(r=null,t=s),r===null&&(s=t,e.charCodeAt(t)===50?(r="2",t++):(r=null,l('"2"')),r!==null?(/^[0-4]/.test(e.charAt(t))?(f=e.charAt(t),t++):(f=null,l("[0-4]")),f!==null?(d=b(),d!==null?r=[r,f,d]:(r=null,t=s)):(r=null,t=s)):(r=null,t=s),r===null&&(s=t,e.charCodeAt(t)===49?(r="1",t++):(r=null,l('"1"')),r!==null?(f=b(),f!==null?(d=b(),d!==null?r=[r,f,d]:(r=null,t=s)):(r=null,t=s)):(r=null,t=s),r===null&&(s=t,/^[1-9]/.test(e.charAt(t))?(r=e.charAt(t),t++):(r=null,l("[1-9]")),r!==null?(f=b(),f!==null?r=[r,f]:(r=null,t=s)):(r=null,t=s),r===null&&(r=b())))),r}function Et(){var r,f,d,s,c,h,g;return h=t,g=t,r=b(),r=r!==null?r:"",r!==null?(f=b(),f=f!==null?f:"",f!==null?(d=b(),d=d!==null?d:"",d!==null?(s=b(),s=s!==null?s:"",s!==null?(c=b(),c=c!==null?c:"",c!==null?r=[r,f,d,s,c]:(r=null,t=g)):(r=null,t=g)):(r=null,t=g)):(r=null,t=g)):(r=null,t=g),r!==null&&(r=function(S,R){return R=parseInt(R.join("")),i.port=R,R}(h,r)),r===null&&(t=h),r}function Os(){var r,f,d,s;for(r=[],s=t,e.charCodeAt(t)===59?(f=";",t++):(f=null,l('";"')),f!==null?(d=ds(),d!==null?f=[f,d]:(f=null,t=s)):(f=null,t=s);f!==null;)r.push(f),s=t,e.charCodeAt(t)===59?(f=";",t++):(f=null,l('";"')),f!==null?(d=ds(),d!==null?f=[f,d]:(f=null,t=s)):(f=null,t=s);return r}function ds(){var r;return r=rl(),r===null&&(r=il(),r===null&&(r=In(),r===null&&(r=al(),r===null&&(r=ol(),r===null&&(r=ul(),r===null&&(r=Ds())))))),r}function rl(){var r,f,d,s;return d=t,s=t,e.substr(t,10).toLowerCase()==="transport="?(r=e.substr(t,10),t+=10):(r=null,l('"transport="')),r!==null?(e.substr(t,3).toLowerCase()==="udp"?(f=e.substr(t,3),t+=3):(f=null,l('"udp"')),f===null&&(e.substr(t,3).toLowerCase()==="tcp"?(f=e.substr(t,3),t+=3):(f=null,l('"tcp"')),f===null&&(e.substr(t,4).toLowerCase()==="sctp"?(f=e.substr(t,4),t+=4):(f=null,l('"sctp"')),f===null&&(e.substr(t,3).toLowerCase()==="tls"?(f=e.substr(t,3),t+=3):(f=null,l('"tls"')),f===null&&(f=$())))),f!==null?r=[r,f]:(r=null,t=s)):(r=null,t=s),r!==null&&(r=function(c,h){i.uri_params||(i.uri_params={}),i.uri_params.transport=h.toLowerCase()}(d,r[1])),r===null&&(t=d),r}function il(){var r,f,d,s;return d=t,s=t,e.substr(t,5).toLowerCase()==="user="?(r=e.substr(t,5),t+=5):(r=null,l('"user="')),r!==null?(e.substr(t,5).toLowerCase()==="phone"?(f=e.substr(t,5),t+=5):(f=null,l('"phone"')),f===null&&(e.substr(t,2).toLowerCase()==="ip"?(f=e.substr(t,2),t+=2):(f=null,l('"ip"')),f===null&&(f=$())),f!==null?r=[r,f]:(r=null,t=s)):(r=null,t=s),r!==null&&(r=function(c,h){i.uri_params||(i.uri_params={}),i.uri_params.user=h.toLowerCase()}(d,r[1])),r===null&&(t=d),r}function In(){var r,f,d,s;return d=t,s=t,e.substr(t,7).toLowerCase()==="method="?(r=e.substr(t,7),t+=7):(r=null,l('"method="')),r!==null?(f=sn(),f!==null?r=[r,f]:(r=null,t=s)):(r=null,t=s),r!==null&&(r=function(c,h){i.uri_params||(i.uri_params={}),i.uri_params.method=h}(d,r[1])),r===null&&(t=d),r}function al(){var r,f,d,s;return d=t,s=t,e.substr(t,4).toLowerCase()==="ttl="?(r=e.substr(t,4),t+=4):(r=null,l('"ttl="')),r!==null?(f=Bn(),f!==null?r=[r,f]:(r=null,t=s)):(r=null,t=s),r!==null&&(r=function(c,h){i.params||(i.params={}),i.params.ttl=h}(d,r[1])),r===null&&(t=d),r}function ol(){var r,f,d,s;return d=t,s=t,e.substr(t,6).toLowerCase()==="maddr="?(r=e.substr(t,6),t+=6):(r=null,l('"maddr="')),r!==null?(f=fs(),f!==null?r=[r,f]:(r=null,t=s)):(r=null,t=s),r!==null&&(r=function(c,h){i.uri_params||(i.uri_params={}),i.uri_params.maddr=h}(d,r[1])),r===null&&(t=d),r}function ul(){var r,f,d,s,c,h;return s=t,c=t,e.substr(t,2).toLowerCase()==="lr"?(r=e.substr(t,2),t+=2):(r=null,l('"lr"')),r!==null?(h=t,e.charCodeAt(t)===61?(f="=",t++):(f=null,l('"="')),f!==null?(d=$(),d!==null?f=[f,d]:(f=null,t=h)):(f=null,t=h),f=f!==null?f:"",f!==null?r=[r,f]:(r=null,t=c)):(r=null,t=c),r!==null&&(r=function(g){i.uri_params||(i.uri_params={}),i.uri_params.lr=void 0}()),r===null&&(t=s),r}function Ds(){var r,f,d,s,c,h;return s=t,c=t,r=cl(),r!==null?(h=t,e.charCodeAt(t)===61?(f="=",t++):(f=null,l('"="')),f!==null?(d=fl(),d!==null?f=[f,d]:(f=null,t=h)):(f=null,t=h),f=f!==null?f:"",f!==null?r=[r,f]:(r=null,t=c)):(r=null,t=c),r!==null&&(r=function(g,S,R){i.uri_params||(i.uri_params={}),typeof R>"u"?R=void 0:R=R[1],i.uri_params[S.toLowerCase()]=R}(s,r[0],r[1])),r===null&&(t=s),r}function cl(){var r,f,d;if(d=t,f=es(),f!==null)for(r=[];f!==null;)r.push(f),f=es();else r=null;return r!==null&&(r=function(s,c){return c.join("")}(d,r)),r===null&&(t=d),r}function fl(){var r,f,d;if(d=t,f=es(),f!==null)for(r=[];f!==null;)r.push(f),f=es();else r=null;return r!==null&&(r=function(s,c){return c.join("")}(d,r)),r===null&&(t=d),r}function es(){var r;return r=hl(),r===null&&(r=H(),r===null&&(r=Ue())),r}function hl(){var r;return e.charCodeAt(t)===91?(r="[",t++):(r=null,l('"["')),r===null&&(e.charCodeAt(t)===93?(r="]",t++):(r=null,l('"]"')),r===null&&(e.charCodeAt(t)===47?(r="/",t++):(r=null,l('"/"')),r===null&&(e.charCodeAt(t)===58?(r=":",t++):(r=null,l('":"')),r===null&&(e.charCodeAt(t)===38?(r="&",t++):(r=null,l('"&"')),r===null&&(e.charCodeAt(t)===43?(r="+",t++):(r=null,l('"+"')),r===null&&(e.charCodeAt(t)===36?(r="$",t++):(r=null,l('"$"')))))))),r}function _l(){var r,f,d,s,c,h,g;if(h=t,e.charCodeAt(t)===63?(r="?",t++):(r=null,l('"?"')),r!==null)if(f=Ft(),f!==null){for(d=[],g=t,e.charCodeAt(t)===38?(s="&",t++):(s=null,l('"&"')),s!==null?(c=Ft(),c!==null?s=[s,c]:(s=null,t=g)):(s=null,t=g);s!==null;)d.push(s),g=t,e.charCodeAt(t)===38?(s="&",t++):(s=null,l('"&"')),s!==null?(c=Ft(),c!==null?s=[s,c]:(s=null,t=g)):(s=null,t=g);d!==null?r=[r,f,d]:(r=null,t=h)}else r=null,t=h;else r=null,t=h;return r}function Ft(){var r,f,d,s,c;return s=t,c=t,r=dr(),r!==null?(e.charCodeAt(t)===61?(f="=",t++):(f=null,l('"="')),f!==null?(d=dl(),d!==null?r=[r,f,d]:(r=null,t=c)):(r=null,t=c)):(r=null,t=c),r!==null&&(r=function(h,g,S){g=g.join("").toLowerCase(),S=S.join(""),i.uri_headers||(i.uri_headers={}),i.uri_headers[g]?i.uri_headers[g].push(S):i.uri_headers[g]=[S]}(s,r[0],r[2])),r===null&&(t=s),r}function dr(){var r,f;if(f=ts(),f===null&&(f=H(),f===null&&(f=Ue())),f!==null)for(r=[];f!==null;)r.push(f),f=ts(),f===null&&(f=H(),f===null&&(f=Ue()));else r=null;return r}function dl(){var r,f;for(r=[],f=ts(),f===null&&(f=H(),f===null&&(f=Ue()));f!==null;)r.push(f),f=ts(),f===null&&(f=H(),f===null&&(f=Ue()));return r}function ts(){var r;return e.charCodeAt(t)===91?(r="[",t++):(r=null,l('"["')),r===null&&(e.charCodeAt(t)===93?(r="]",t++):(r=null,l('"]"')),r===null&&(e.charCodeAt(t)===47?(r="/",t++):(r=null,l('"/"')),r===null&&(e.charCodeAt(t)===63?(r="?",t++):(r=null,l('"?"')),r===null&&(e.charCodeAt(t)===58?(r=":",t++):(r=null,l('":"')),r===null&&(e.charCodeAt(t)===43?(r="+",t++):(r=null,l('"+"')),r===null&&(e.charCodeAt(t)===36?(r="$",t++):(r=null,l('"$"')))))))),r}function pl(){var r;return r=wl(),r===null&&(r=ml()),r}function ml(){var r,f,d,s,c,h;return h=t,r=sn(),r!==null?(f=z(),f!==null?(d=Ns(),d!==null?(s=z(),s!==null?(c=Dn(),c!==null?r=[r,f,d,s,c]:(r=null,t=h)):(r=null,t=h)):(r=null,t=h)):(r=null,t=h)):(r=null,t=h),r}function Ns(){var r;return r=He(),r===null&&(r=Zs()),r}function Zs(){var r,f,d,s;return s=t,r=en(),r!==null?(e.charCodeAt(t)===58?(f=":",t++):(f=null,l('":"')),f!==null?(d=gl(),d===null&&(d=vl()),d!==null?r=[r,f,d]:(r=null,t=s)):(r=null,t=s)):(r=null,t=s),r}function gl(){var r,f,d,s,c;return s=t,r=Us(),r===null&&(r=xs()),r!==null?(c=t,e.charCodeAt(t)===63?(f="?",t++):(f=null,l('"?"')),f!==null?(d=El(),d!==null?f=[f,d]:(f=null,t=c)):(f=null,t=c),f=f!==null?f:"",f!==null?r=[r,f]:(r=null,t=s)):(r=null,t=s),r}function Us(){var r,f,d,s;return s=t,e.substr(t,2)==="//"?(r="//",t+=2):(r=null,l('"//"')),r!==null?(f=On(),f!==null?(d=xs(),d=d!==null?d:"",d!==null?r=[r,f,d]:(r=null,t=s)):(r=null,t=s)):(r=null,t=s),r}function xs(){var r,f,d;return d=t,e.charCodeAt(t)===47?(r="/",t++):(r=null,l('"/"')),r!==null?(f=Ms(),f!==null?r=[r,f]:(r=null,t=d)):(r=null,t=d),r}function vl(){var r,f,d,s;if(s=t,r=Ps(),r!==null){for(f=[],d=ss();d!==null;)f.push(d),d=ss();f!==null?r=[r,f]:(r=null,t=s)}else r=null,t=s;return r}function ss(){var r;return r=k(),r===null&&(r=H(),r===null&&(r=Ue())),r}function Ps(){var r;return r=H(),r===null&&(r=Ue(),r===null&&(e.charCodeAt(t)===59?(r=";",t++):(r=null,l('";"')),r===null&&(e.charCodeAt(t)===63?(r="?",t++):(r=null,l('"?"')),r===null&&(e.charCodeAt(t)===58?(r=":",t++):(r=null,l('":"')),r===null&&(e.charCodeAt(t)===64?(r="@",t++):(r=null,l('"@"')),r===null&&(e.charCodeAt(t)===38?(r="&",t++):(r=null,l('"&"')),r===null&&(e.charCodeAt(t)===61?(r="=",t++):(r=null,l('"="')),r===null&&(e.charCodeAt(t)===43?(r="+",t++):(r=null,l('"+"')),r===null&&(e.charCodeAt(t)===36?(r="$",t++):(r=null,l('"$"')),r===null&&(e.charCodeAt(t)===44?(r=",",t++):(r=null,l('","')))))))))))),r}function Ms(){var r,f,d,s,c,h;if(c=t,r=ns(),r!==null){for(f=[],h=t,e.charCodeAt(t)===47?(d="/",t++):(d=null,l('"/"')),d!==null?(s=ns(),s!==null?d=[d,s]:(d=null,t=h)):(d=null,t=h);d!==null;)f.push(d),h=t,e.charCodeAt(t)===47?(d="/",t++):(d=null,l('"/"')),d!==null?(s=ns(),s!==null?d=[d,s]:(d=null,t=h)):(d=null,t=h);f!==null?r=[r,f]:(r=null,t=c)}else r=null,t=c;return r}function ns(){var r,f,d,s,c,h;for(c=t,r=[],f=ks();f!==null;)r.push(f),f=ks();if(r!==null){for(f=[],h=t,e.charCodeAt(t)===59?(d=";",t++):(d=null,l('";"')),d!==null?(s=wn(),s!==null?d=[d,s]:(d=null,t=h)):(d=null,t=h);d!==null;)f.push(d),h=t,e.charCodeAt(t)===59?(d=";",t++):(d=null,l('";"')),d!==null?(s=wn(),s!==null?d=[d,s]:(d=null,t=h)):(d=null,t=h);f!==null?r=[r,f]:(r=null,t=c)}else r=null,t=c;return r}function wn(){var r,f;for(r=[],f=ks();f!==null;)r.push(f),f=ks();return r}function ks(){var r;return r=H(),r===null&&(r=Ue(),r===null&&(e.charCodeAt(t)===58?(r=":",t++):(r=null,l('":"')),r===null&&(e.charCodeAt(t)===64?(r="@",t++):(r=null,l('"@"')),r===null&&(e.charCodeAt(t)===38?(r="&",t++):(r=null,l('"&"')),r===null&&(e.charCodeAt(t)===61?(r="=",t++):(r=null,l('"="')),r===null&&(e.charCodeAt(t)===43?(r="+",t++):(r=null,l('"+"')),r===null&&(e.charCodeAt(t)===36?(r="$",t++):(r=null,l('"$"')),r===null&&(e.charCodeAt(t)===44?(r=",",t++):(r=null,l('","')))))))))),r}function en(){var r,f,d,s,c;if(s=t,c=t,r=E(),r!==null){for(f=[],d=E(),d===null&&(d=b(),d===null&&(e.charCodeAt(t)===43?(d="+",t++):(d=null,l('"+"')),d===null&&(e.charCodeAt(t)===45?(d="-",t++):(d=null,l('"-"')),d===null&&(e.charCodeAt(t)===46?(d=".",t++):(d=null,l('"."'))))));d!==null;)f.push(d),d=E(),d===null&&(d=b(),d===null&&(e.charCodeAt(t)===43?(d="+",t++):(d=null,l('"+"')),d===null&&(e.charCodeAt(t)===45?(d="-",t++):(d=null,l('"-"')),d===null&&(e.charCodeAt(t)===46?(d=".",t++):(d=null,l('"."'))))));f!==null?r=[r,f]:(r=null,t=c)}else r=null,t=c;return r!==null&&(r=function(h){i.scheme=e.substring(t,h)}(s)),r===null&&(t=s),r}function On(){var r;return r=ps(),r===null&&(r=Tl()),r}function ps(){var r,f,d,s;return d=t,s=t,r=_t(),r!==null?(e.charCodeAt(t)===64?(f="@",t++):(f=null,l('"@"')),f!==null?r=[r,f]:(r=null,t=s)):(r=null,t=s),r=r!==null?r:"",r!==null?(f=ws(),f!==null?r=[r,f]:(r=null,t=d)):(r=null,t=d),r=r!==null?r:"",r}function Tl(){var r,f;if(f=H(),f===null&&(f=Ue(),f===null&&(e.charCodeAt(t)===36?(f="$",t++):(f=null,l('"$"')),f===null&&(e.charCodeAt(t)===44?(f=",",t++):(f=null,l('","')),f===null&&(e.charCodeAt(t)===59?(f=";",t++):(f=null,l('";"')),f===null&&(e.charCodeAt(t)===58?(f=":",t++):(f=null,l('":"')),f===null&&(e.charCodeAt(t)===64?(f="@",t++):(f=null,l('"@"')),f===null&&(e.charCodeAt(t)===38?(f="&",t++):(f=null,l('"&"')),f===null&&(e.charCodeAt(t)===61?(f="=",t++):(f=null,l('"="')),f===null&&(e.charCodeAt(t)===43?(f="+",t++):(f=null,l('"+"'))))))))))),f!==null)for(r=[];f!==null;)r.push(f),f=H(),f===null&&(f=Ue(),f===null&&(e.charCodeAt(t)===36?(f="$",t++):(f=null,l('"$"')),f===null&&(e.charCodeAt(t)===44?(f=",",t++):(f=null,l('","')),f===null&&(e.charCodeAt(t)===59?(f=";",t++):(f=null,l('";"')),f===null&&(e.charCodeAt(t)===58?(f=":",t++):(f=null,l('":"')),f===null&&(e.charCodeAt(t)===64?(f="@",t++):(f=null,l('"@"')),f===null&&(e.charCodeAt(t)===38?(f="&",t++):(f=null,l('"&"')),f===null&&(e.charCodeAt(t)===61?(f="=",t++):(f=null,l('"="')),f===null&&(e.charCodeAt(t)===43?(f="+",t++):(f=null,l('"+"')))))))))));else r=null;return r}function El(){var r,f;for(r=[],f=ss();f!==null;)r.push(f),f=ss();return r}function Dn(){var r,f,d,s,c,h,g,S;if(g=t,S=t,e.substr(t,3).toLowerCase()==="sip"?(r=e.substr(t,3),t+=3):(r=null,l('"SIP"')),r!==null)if(e.charCodeAt(t)===47?(f="/",t++):(f=null,l('"/"')),f!==null){if(s=b(),s!==null)for(d=[];s!==null;)d.push(s),s=b();else d=null;if(d!==null)if(e.charCodeAt(t)===46?(s=".",t++):(s=null,l('"."')),s!==null){if(h=b(),h!==null)for(c=[];h!==null;)c.push(h),h=b();else c=null;c!==null?r=[r,f,d,s,c]:(r=null,t=S)}else r=null,t=S;else r=null,t=S}else r=null,t=S;else r=null,t=S;return r!==null&&(r=function(R){i.sip_version=e.substring(t,R)}(g)),r===null&&(t=g),r}function Cl(){var r;return e.substr(t,6)==="INVITE"?(r="INVITE",t+=6):(r=null,l('"INVITE"')),r}function Sl(){var r;return e.substr(t,3)==="ACK"?(r="ACK",t+=3):(r=null,l('"ACK"')),r}function Nn(){var r;return e.substr(t,7)==="OPTIONS"?(r="OPTIONS",t+=7):(r=null,l('"OPTIONS"')),r}function Al(){var r;return e.substr(t,3)==="BYE"?(r="BYE",t+=3):(r=null,l('"BYE"')),r}function yl(){var r;return e.substr(t,6)==="CANCEL"?(r="CANCEL",t+=6):(r=null,l('"CANCEL"')),r}function Rl(){var r;return e.substr(t,8)==="REGISTER"?(r="REGISTER",t+=8):(r=null,l('"REGISTER"')),r}function tn(){var r;return e.substr(t,9)==="SUBSCRIBE"?(r="SUBSCRIBE",t+=9):(r=null,l('"SUBSCRIBE"')),r}function bl(){var r;return e.substr(t,6)==="NOTIFY"?(r="NOTIFY",t+=6):(r=null,l('"NOTIFY"')),r}function Il(){var r;return e.substr(t,5)==="REFER"?(r="REFER",t+=5):(r=null,l('"REFER"')),r}function sn(){var r,f;return f=t,r=Cl(),r===null&&(r=Sl(),r===null&&(r=Nn(),r===null&&(r=Al(),r===null&&(r=yl(),r===null&&(r=Rl(),r===null&&(r=tn(),r===null&&(r=bl(),r===null&&(r=Il(),r===null&&(r=$()))))))))),r!==null&&(r=function(d){return i.method=e.substring(t,d),i.method}(f)),r===null&&(t=f),r}function wl(){var r,f,d,s,c,h;return h=t,r=Dn(),r!==null?(f=z(),f!==null?(d=pr(),d!==null?(s=z(),s!==null?(c=mr(),c!==null?r=[r,f,d,s,c]:(r=null,t=h)):(r=null,t=h)):(r=null,t=h)):(r=null,t=h)):(r=null,t=h),r}function pr(){var r,f;return f=t,r=Un(),r!==null&&(r=function(d,s){i.status_code=parseInt(s.join(""))}(f,r)),r===null&&(t=f),r}function Un(){var r,f,d,s;return s=t,r=b(),r!==null?(f=b(),f!==null?(d=b(),d!==null?r=[r,f,d]:(r=null,t=s)):(r=null,t=s)):(r=null,t=s),r}function mr(){var r,f,d;for(d=t,r=[],f=k(),f===null&&(f=H(),f===null&&(f=Ue(),f===null&&(f=M(),f===null&&(f=te(),f===null&&(f=z(),f===null&&(f=j()))))));f!==null;)r.push(f),f=k(),f===null&&(f=H(),f===null&&(f=Ue(),f===null&&(f=M(),f===null&&(f=te(),f===null&&(f=z(),f===null&&(f=j()))))));return r!==null&&(r=function(s){i.reason_phrase=e.substring(t,s)}(d)),r===null&&(t=d),r}function xn(){var r,f,d,s,c,h;if(c=t,r=Ts(),r!==null){for(f=[],h=t,d=xe(),d!==null?(s=Ts(),s!==null?d=[d,s]:(d=null,t=h)):(d=null,t=h);d!==null;)f.push(d),h=t,d=xe(),d!==null?(s=Ts(),s!==null?d=[d,s]:(d=null,t=h)):(d=null,t=h);f!==null?r=[r,f]:(r=null,t=c)}else r=null,t=c;return r}function ms(){var r,f,d,s,c,h;return s=t,c=t,r=P(),r!==null?(h=t,e.charCodeAt(t)===64?(f="@",t++):(f=null,l('"@"')),f!==null?(d=P(),d!==null?f=[f,d]:(f=null,t=h)):(f=null,t=h),f=f!==null?f:"",f!==null?r=[r,f]:(r=null,t=c)):(r=null,t=c),r!==null&&(r=function(g){i=e.substring(t,g)}(s)),r===null&&(t=s),r}function Pn(){var r,f,d,s,c,h,g;if(c=t,r=Q(),r===null)if(h=t,r=nn(),r!==null){for(f=[],g=t,d=xe(),d!==null?(s=nn(),s!==null?d=[d,s]:(d=null,t=g)):(d=null,t=g);d!==null;)f.push(d),g=t,d=xe(),d!==null?(s=nn(),s!==null?d=[d,s]:(d=null,t=g)):(d=null,t=g);f!==null?r=[r,f]:(r=null,t=h)}else r=null,t=h;return r!==null&&(r=function(S){var R,I;for(I=i.multi_header.length,R=0;R<I;R++)if(i.multi_header[R].parsed===null){i=null;break}i!==null?i=i.multi_header:i=-1}()),r===null&&(t=c),r}function nn(){var r,f,d,s,c,h,g;if(c=t,h=t,r=ke(),r===null&&(r=gs()),r!==null){for(f=[],g=t,d=we(),d!==null?(s=qt(),s!==null?d=[d,s]:(d=null,t=g)):(d=null,t=g);d!==null;)f.push(d),g=t,d=we(),d!==null?(s=qt(),s!==null?d=[d,s]:(d=null,t=g)):(d=null,t=g);f!==null?r=[r,f]:(r=null,t=h)}else r=null,t=h;return r!==null&&(r=function(S){var R;i.multi_header||(i.multi_header=[]);try{R=new Vs(i.uri,i.display_name,i.params),delete i.uri,delete i.display_name,delete i.params}catch{R=null}i.multi_header.push({possition:t,offset:S,parsed:R})}(c)),r===null&&(t=c),r}function gs(){var r,f,d,s,c;return c=t,r=Mn(),r=r!==null?r:"",r!==null?(f=je(),f!==null?(d=He(),d!==null?(s=fe(),s!==null?r=[r,f,d,s]:(r=null,t=c)):(r=null,t=c)):(r=null,t=c)):(r=null,t=c),r}function Mn(){var r,f,d,s,c,h,g;if(c=t,h=t,r=$(),r!==null){for(f=[],g=t,d=B(),d!==null?(s=$(),s!==null?d=[d,s]:(d=null,t=g)):(d=null,t=g);d!==null;)f.push(d),g=t,d=B(),d!==null?(s=$(),s!==null?d=[d,s]:(d=null,t=g)):(d=null,t=g);f!==null?r=[r,f]:(r=null,t=h)}else r=null,t=h;return r===null&&(r=ye()),r!==null&&(r=function(S,R){typeof R=="string"?i.display_name=R:i.display_name=R[1].reduce(function(I,D){return I+D[0]+D[1]},R[0])}(c,r)),r===null&&(t=c),r}function qt(){var r;return r=ls(),r===null&&(r=ze(),r===null&&(r=Ze())),r}function ls(){var r,f,d,s,c;return s=t,c=t,e.substr(t,1).toLowerCase()==="q"?(r=e.substr(t,1),t++):(r=null,l('"q"')),r!==null?(f=he(),f!==null?(d=gr(),d!==null?r=[r,f,d]:(r=null,t=c)):(r=null,t=c)):(r=null,t=c),r!==null&&(r=function(h,g){i.params||(i.params={}),i.params.q=g}(s,r[2])),r===null&&(t=s),r}function ze(){var r,f,d,s,c;return s=t,c=t,e.substr(t,7).toLowerCase()==="expires"?(r=e.substr(t,7),t+=7):(r=null,l('"expires"')),r!==null?(f=he(),f!==null?(d=Yt(),d!==null?r=[r,f,d]:(r=null,t=c)):(r=null,t=c)):(r=null,t=c),r!==null&&(r=function(h,g){i.params||(i.params={}),i.params.expires=g}(s,r[2])),r===null&&(t=s),r}function Yt(){var r,f,d;if(d=t,f=b(),f!==null)for(r=[];f!==null;)r.push(f),f=b();else r=null;return r!==null&&(r=function(s,c){return parseInt(c.join(""))}(d,r)),r===null&&(t=d),r}function gr(){var r,f,d,s,c,h,g,S;return h=t,g=t,e.charCodeAt(t)===48?(r="0",t++):(r=null,l('"0"')),r!==null?(S=t,e.charCodeAt(t)===46?(f=".",t++):(f=null,l('"."')),f!==null?(d=b(),d=d!==null?d:"",d!==null?(s=b(),s=s!==null?s:"",s!==null?(c=b(),c=c!==null?c:"",c!==null?f=[f,d,s,c]:(f=null,t=S)):(f=null,t=S)):(f=null,t=S)):(f=null,t=S),f=f!==null?f:"",f!==null?r=[r,f]:(r=null,t=g)):(r=null,t=g),r!==null&&(r=function(R){return parseFloat(e.substring(t,R))}(h)),r===null&&(t=h),r}function Ze(){var r,f,d,s,c,h;return s=t,c=t,r=$(),r!==null?(h=t,f=he(),f!==null?(d=zt(),d!==null?f=[f,d]:(f=null,t=h)):(f=null,t=h),f=f!==null?f:"",f!==null?r=[r,f]:(r=null,t=c)):(r=null,t=c),r!==null&&(r=function(g,S,R){i.params||(i.params={}),typeof R>"u"?R=void 0:R=R[1],i.params[S.toLowerCase()]=R}(s,r[0],r[1])),r===null&&(t=s),r}function zt(){var r;return r=$(),r===null&&(r=fs(),r===null&&(r=Le())),r}function vr(){var r,f,d,s,c,h;if(c=t,r=st(),r!==null){for(f=[],h=t,d=we(),d!==null?(s=Ol(),s!==null?d=[d,s]:(d=null,t=h)):(d=null,t=h);d!==null;)f.push(d),h=t,d=we(),d!==null?(s=Ol(),s!==null?d=[d,s]:(d=null,t=h)):(d=null,t=h);f!==null?r=[r,f]:(r=null,t=c)}else r=null,t=c;return r}function st(){var r;return e.substr(t,6).toLowerCase()==="render"?(r=e.substr(t,6),t+=6):(r=null,l('"render"')),r===null&&(e.substr(t,7).toLowerCase()==="session"?(r=e.substr(t,7),t+=7):(r=null,l('"session"')),r===null&&(e.substr(t,4).toLowerCase()==="icon"?(r=e.substr(t,4),t+=4):(r=null,l('"icon"')),r===null&&(e.substr(t,5).toLowerCase()==="alert"?(r=e.substr(t,5),t+=5):(r=null,l('"alert"')),r===null&&(r=$())))),r}function Ol(){var r;return r=ei(),r===null&&(r=Ze()),r}function ei(){var r,f,d,s;return s=t,e.substr(t,8).toLowerCase()==="handling"?(r=e.substr(t,8),t+=8):(r=null,l('"handling"')),r!==null?(f=he(),f!==null?(e.substr(t,8).toLowerCase()==="optional"?(d=e.substr(t,8),t+=8):(d=null,l('"optional"')),d===null&&(e.substr(t,8).toLowerCase()==="required"?(d=e.substr(t,8),t+=8):(d=null,l('"required"')),d===null&&(d=$())),d!==null?r=[r,f,d]:(r=null,t=s)):(r=null,t=s)):(r=null,t=s),r}function Tr(){var r,f,d,s,c,h;if(c=t,r=$(),r!==null){for(f=[],h=t,d=xe(),d!==null?(s=$(),s!==null?d=[d,s]:(d=null,t=h)):(d=null,t=h);d!==null;)f.push(d),h=t,d=xe(),d!==null?(s=$(),s!==null?d=[d,s]:(d=null,t=h)):(d=null,t=h);f!==null?r=[r,f]:(r=null,t=c)}else r=null,t=c;return r}function Dl(){var r,f,d;if(d=t,f=b(),f!==null)for(r=[];f!==null;)r.push(f),f=b();else r=null;return r!==null&&(r=function(s,c){i=parseInt(c.join(""))}(d,r)),r===null&&(t=d),r}function Er(){var r,f;return f=t,r=Cr(),r!==null&&(r=function(d){i=e.substring(t,d)}(f)),r===null&&(t=f),r}function Cr(){var r,f,d,s,c,h,g,S;if(g=t,r=kn(),r!==null)if(f=oe(),f!==null)if(d=Ar(),d!==null){for(s=[],S=t,c=we(),c!==null?(h=$s(),h!==null?c=[c,h]:(c=null,t=S)):(c=null,t=S);c!==null;)s.push(c),S=t,c=we(),c!==null?(h=$s(),h!==null?c=[c,h]:(c=null,t=S)):(c=null,t=S);s!==null?r=[r,f,d,s]:(r=null,t=g)}else r=null,t=g;else r=null,t=g;else r=null,t=g;return r}function kn(){var r;return r=Sr(),r===null&&(r=Nl()),r}function Sr(){var r;return e.substr(t,4).toLowerCase()==="text"?(r=e.substr(t,4),t+=4):(r=null,l('"text"')),r===null&&(e.substr(t,5).toLowerCase()==="image"?(r=e.substr(t,5),t+=5):(r=null,l('"image"')),r===null&&(e.substr(t,5).toLowerCase()==="audio"?(r=e.substr(t,5),t+=5):(r=null,l('"audio"')),r===null&&(e.substr(t,5).toLowerCase()==="video"?(r=e.substr(t,5),t+=5):(r=null,l('"video"')),r===null&&(e.substr(t,11).toLowerCase()==="application"?(r=e.substr(t,11),t+=11):(r=null,l('"application"')),r===null&&(r=Ls()))))),r}function Nl(){var r;return e.substr(t,7).toLowerCase()==="message"?(r=e.substr(t,7),t+=7):(r=null,l('"message"')),r===null&&(e.substr(t,9).toLowerCase()==="multipart"?(r=e.substr(t,9),t+=9):(r=null,l('"multipart"')),r===null&&(r=Ls())),r}function Ls(){var r;return r=$(),r===null&&(r=Ul()),r}function Ul(){var r,f,d;return d=t,e.substr(t,2).toLowerCase()==="x-"?(r=e.substr(t,2),t+=2):(r=null,l('"x-"')),r!==null?(f=$(),f!==null?r=[r,f]:(r=null,t=d)):(r=null,t=d),r}function Ar(){var r;return r=Ls(),r===null&&(r=$()),r}function $s(){var r,f,d,s;return s=t,r=$(),r!==null?(f=he(),f!==null?(d=yr(),d!==null?r=[r,f,d]:(r=null,t=s)):(r=null,t=s)):(r=null,t=s),r}function yr(){var r;return r=$(),r===null&&(r=Le()),r}function ti(){var r,f,d,s;return s=t,r=vs(),r!==null?(f=B(),f!==null?(d=sn(),d!==null?r=[r,f,d]:(r=null,t=s)):(r=null,t=s)):(r=null,t=s),r}function vs(){var r,f,d;if(d=t,f=b(),f!==null)for(r=[];f!==null;)r.push(f),f=b();else r=null;return r!==null&&(r=function(s,c){i.value=parseInt(c.join(""))}(d,r)),r===null&&(t=d),r}function si(){var r,f;return f=t,r=Yt(),r!==null&&(r=function(d,s){i=s}(f,r)),r===null&&(t=f),r}function Rr(){var r,f,d,s,c,h,g;if(c=t,h=t,r=Ts(),r!==null){for(f=[],g=t,d=we(),d!==null?(s=Ze(),s!==null?d=[d,s]:(d=null,t=g)):(d=null,t=g);d!==null;)f.push(d),g=t,d=we(),d!==null?(s=Ze(),s!==null?d=[d,s]:(d=null,t=g)):(d=null,t=g);f!==null?r=[r,f]:(r=null,t=h)}else r=null,t=h;return r!==null&&(r=function(S,R){i.event=R.join("").toLowerCase()}(c,r[0])),r===null&&(t=c),r}function Ts(){var r,f,d,s,c,h;if(c=t,r=ne(),r!==null){for(f=[],h=t,e.charCodeAt(t)===46?(d=".",t++):(d=null,l('"."')),d!==null?(s=ne(),s!==null?d=[d,s]:(d=null,t=h)):(d=null,t=h);d!==null;)f.push(d),h=t,e.charCodeAt(t)===46?(d=".",t++):(d=null,l('"."')),d!==null?(s=ne(),s!==null?d=[d,s]:(d=null,t=h)):(d=null,t=h);f!==null?r=[r,f]:(r=null,t=c)}else r=null,t=c;return r}function ea(){var r,f,d,s,c,h,g;if(c=t,h=t,r=ke(),r===null&&(r=gs()),r!==null){for(f=[],g=t,d=we(),d!==null?(s=br(),s!==null?d=[d,s]:(d=null,t=g)):(d=null,t=g);d!==null;)f.push(d),g=t,d=we(),d!==null?(s=br(),s!==null?d=[d,s]:(d=null,t=g)):(d=null,t=g);f!==null?r=[r,f]:(r=null,t=h)}else r=null,t=h;return r!==null&&(r=function(S){var R=i.tag;try{i=new Vs(i.uri,i.display_name,i.params),R&&i.setParam("tag",R)}catch{i=-1}}()),r===null&&(t=c),r}function br(){var r;return r=Hs(),r===null&&(r=Ze()),r}function Hs(){var r,f,d,s,c;return s=t,c=t,e.substr(t,3).toLowerCase()==="tag"?(r=e.substr(t,3),t+=3):(r=null,l('"tag"')),r!==null?(f=he(),f!==null?(d=$(),d!==null?r=[r,f,d]:(r=null,t=c)):(r=null,t=c)):(r=null,t=c),r!==null&&(r=function(h,g){i.tag=g}(s,r[2])),r===null&&(t=s),r}function ta(){var r,f,d;if(d=t,f=b(),f!==null)for(r=[];f!==null;)r.push(f),f=b();else r=null;return r!==null&&(r=function(s,c){i=parseInt(c.join(""))}(d,r)),r===null&&(t=d),r}function Ln(){var r,f;return f=t,r=Yt(),r!==null&&(r=function(d,s){i=s}(f,r)),r===null&&(t=f),r}function xl(){var r,f,d,s,c,h,g,S,R,I;for(S=t,R=t,r=[],f=Mn();f!==null;)r.push(f),f=Mn();if(r!==null)if(f=je(),f!==null)if(d=He(),d!==null)if(s=fe(),s!==null){for(c=[],I=t,h=we(),h!==null?(g=Ze(),g!==null?h=[h,g]:(h=null,t=I)):(h=null,t=I);h!==null;)c.push(h),I=t,h=we(),h!==null?(g=Ze(),g!==null?h=[h,g]:(h=null,t=I)):(h=null,t=I);c!==null?r=[r,f,d,s,c]:(r=null,t=R)}else r=null,t=R;else r=null,t=R;else r=null,t=R;else r=null,t=R;return r!==null&&(r=function(D){try{i=new Vs(i.uri,i.display_name,i.params)}catch{i=-1}}()),r===null&&(t=S),r}function $n(){var r;return r=ln(),r}function ln(){var r,f,d,s,c,h,g,S;if(g=t,e.substr(t,6).toLowerCase()==="digest"?(r=e.substr(t,6),t+=6):(r=null,l('"Digest"')),r!==null)if(f=B(),f!==null)if(d=Fs(),d!==null){for(s=[],S=t,c=xe(),c!==null?(h=Fs(),h!==null?c=[c,h]:(c=null,t=S)):(c=null,t=S);c!==null;)s.push(c),S=t,c=xe(),c!==null?(h=Fs(),h!==null?c=[c,h]:(c=null,t=S)):(c=null,t=S);s!==null?r=[r,f,d,s]:(r=null,t=g)}else r=null,t=g;else r=null,t=g;else r=null,t=g;return r===null&&(r=Ir()),r}function Ir(){var r,f,d,s,c,h,g,S;if(g=t,r=$(),r!==null)if(f=B(),f!==null)if(d=rn(),d!==null){for(s=[],S=t,c=xe(),c!==null?(h=rn(),h!==null?c=[c,h]:(c=null,t=S)):(c=null,t=S);c!==null;)s.push(c),S=t,c=xe(),c!==null?(h=rn(),h!==null?c=[c,h]:(c=null,t=S)):(c=null,t=S);s!==null?r=[r,f,d,s]:(r=null,t=g)}else r=null,t=g;else r=null,t=g;else r=null,t=g;return r}function rn(){var r,f,d,s;return s=t,r=$(),r!==null?(f=he(),f!==null?(d=$(),d===null&&(d=Le()),d!==null?r=[r,f,d]:(r=null,t=s)):(r=null,t=s)):(r=null,t=s),r}function Fs(){var r;return r=an(),r===null&&(r=on(),r===null&&(r=Pl(),r===null&&(r=cn(),r===null&&(r=fn(),r===null&&(r=wr(),r===null&&(r=Or(),r===null&&(r=rn()))))))),r}function an(){var r,f,d,s;return s=t,e.substr(t,5).toLowerCase()==="realm"?(r=e.substr(t,5),t+=5):(r=null,l('"realm"')),r!==null?(f=he(),f!==null?(d=qs(),d!==null?r=[r,f,d]:(r=null,t=s)):(r=null,t=s)):(r=null,t=s),r}function qs(){var r,f;return f=t,r=ye(),r!==null&&(r=function(d,s){i.realm=s}(f,r)),r===null&&(t=f),r}function on(){var r,f,d,s,c,h,g,S,R;if(S=t,e.substr(t,6).toLowerCase()==="domain"?(r=e.substr(t,6),t+=6):(r=null,l('"domain"')),r!==null)if(f=he(),f!==null)if(d=$e(),d!==null)if(s=un(),s!==null){if(c=[],R=t,g=z(),g!==null)for(h=[];g!==null;)h.push(g),g=z();else h=null;for(h!==null?(g=un(),g!==null?h=[h,g]:(h=null,t=R)):(h=null,t=R);h!==null;){if(c.push(h),R=t,g=z(),g!==null)for(h=[];g!==null;)h.push(g),g=z();else h=null;h!==null?(g=un(),g!==null?h=[h,g]:(h=null,t=R)):(h=null,t=R)}c!==null?(h=ue(),h!==null?r=[r,f,d,s,c,h]:(r=null,t=S)):(r=null,t=S)}else r=null,t=S;else r=null,t=S;else r=null,t=S;else r=null,t=S;return r}function un(){var r;return r=Zs(),r===null&&(r=xs()),r}function Pl(){var r,f,d,s;return s=t,e.substr(t,5).toLowerCase()==="nonce"?(r=e.substr(t,5),t+=5):(r=null,l('"nonce"')),r!==null?(f=he(),f!==null?(d=Ml(),d!==null?r=[r,f,d]:(r=null,t=s)):(r=null,t=s)):(r=null,t=s),r}function Ml(){var r,f;return f=t,r=ye(),r!==null&&(r=function(d,s){i.nonce=s}(f,r)),r===null&&(t=f),r}function cn(){var r,f,d,s,c;return s=t,c=t,e.substr(t,6).toLowerCase()==="opaque"?(r=e.substr(t,6),t+=6):(r=null,l('"opaque"')),r!==null?(f=he(),f!==null?(d=ye(),d!==null?r=[r,f,d]:(r=null,t=c)):(r=null,t=c)):(r=null,t=c),r!==null&&(r=function(h,g){i.opaque=g}(s,r[2])),r===null&&(t=s),r}function fn(){var r,f,d,s,c;return s=t,e.substr(t,5).toLowerCase()==="stale"?(r=e.substr(t,5),t+=5):(r=null,l('"stale"')),r!==null?(f=he(),f!==null?(c=t,e.substr(t,4).toLowerCase()==="true"?(d=e.substr(t,4),t+=4):(d=null,l('"true"')),d!==null&&(d=function(h){i.stale=!0}()),d===null&&(t=c),d===null&&(c=t,e.substr(t,5).toLowerCase()==="false"?(d=e.substr(t,5),t+=5):(d=null,l('"false"')),d!==null&&(d=function(h){i.stale=!1}()),d===null&&(t=c)),d!==null?r=[r,f,d]:(r=null,t=s)):(r=null,t=s)):(r=null,t=s),r}function wr(){var r,f,d,s,c;return s=t,c=t,e.substr(t,9).toLowerCase()==="algorithm"?(r=e.substr(t,9),t+=9):(r=null,l('"algorithm"')),r!==null?(f=he(),f!==null?(e.substr(t,3).toLowerCase()==="md5"?(d=e.substr(t,3),t+=3):(d=null,l('"MD5"')),d===null&&(e.substr(t,8).toLowerCase()==="md5-sess"?(d=e.substr(t,8),t+=8):(d=null,l('"MD5-sess"')),d===null&&(d=$())),d!==null?r=[r,f,d]:(r=null,t=c)):(r=null,t=c)):(r=null,t=c),r!==null&&(r=function(h,g){i.algorithm=g.toUpperCase()}(s,r[2])),r===null&&(t=s),r}function Or(){var r,f,d,s,c,h,g,S,R,I;if(S=t,e.substr(t,3).toLowerCase()==="qop"?(r=e.substr(t,3),t+=3):(r=null,l('"qop"')),r!==null)if(f=he(),f!==null)if(d=$e(),d!==null){if(R=t,s=Es(),s!==null){for(c=[],I=t,e.charCodeAt(t)===44?(h=",",t++):(h=null,l('","')),h!==null?(g=Es(),g!==null?h=[h,g]:(h=null,t=I)):(h=null,t=I);h!==null;)c.push(h),I=t,e.charCodeAt(t)===44?(h=",",t++):(h=null,l('","')),h!==null?(g=Es(),g!==null?h=[h,g]:(h=null,t=I)):(h=null,t=I);c!==null?s=[s,c]:(s=null,t=R)}else s=null,t=R;s!==null?(c=ue(),c!==null?r=[r,f,d,s,c]:(r=null,t=S)):(r=null,t=S)}else r=null,t=S;else r=null,t=S;else r=null,t=S;return r}function Es(){var r,f;return f=t,e.substr(t,8).toLowerCase()==="auth-int"?(r=e.substr(t,8),t+=8):(r=null,l('"auth-int"')),r===null&&(e.substr(t,4).toLowerCase()==="auth"?(r=e.substr(t,4),t+=4):(r=null,l('"auth"')),r===null&&(r=$())),r!==null&&(r=function(d,s){i.qop||(i.qop=[]),i.qop.push(s.toLowerCase())}(f,r)),r===null&&(t=f),r}function ni(){var r,f,d,s,c,h;if(c=t,r=$(),r!==null){for(f=[],h=t,d=xe(),d!==null?(s=$(),s!==null?d=[d,s]:(d=null,t=h)):(d=null,t=h);d!==null;)f.push(d),h=t,d=xe(),d!==null?(s=$(),s!==null?d=[d,s]:(d=null,t=h)):(d=null,t=h);f!==null?r=[r,f]:(r=null,t=c)}else r=null,t=c;return r}function kl(){var r,f,d,s,c,h,g;if(c=t,h=t,r=Cs(),r!==null){for(f=[],g=t,d=xe(),d!==null?(s=Cs(),s!==null?d=[d,s]:(d=null,t=g)):(d=null,t=g);d!==null;)f.push(d),g=t,d=xe(),d!==null?(s=Cs(),s!==null?d=[d,s]:(d=null,t=g)):(d=null,t=g);f!==null?r=[r,f]:(r=null,t=h)}else r=null,t=h;return r!==null&&(r=function(S){var R,I;for(I=i.multi_header.length,R=0;R<I;R++)if(i.multi_header[R].parsed===null){i=null;break}i!==null?i=i.multi_header:i=-1}()),r===null&&(t=c),r}function Cs(){var r,f,d,s,c,h,g;if(c=t,h=t,r=gs(),r!==null){for(f=[],g=t,d=we(),d!==null?(s=Ze(),s!==null?d=[d,s]:(d=null,t=g)):(d=null,t=g);d!==null;)f.push(d),g=t,d=we(),d!==null?(s=Ze(),s!==null?d=[d,s]:(d=null,t=g)):(d=null,t=g);f!==null?r=[r,f]:(r=null,t=h)}else r=null,t=h;return r!==null&&(r=function(S){var R;i.multi_header||(i.multi_header=[]);try{R=new Vs(i.uri,i.display_name,i.params),delete i.uri,delete i.display_name,delete i.params}catch{R=null}i.multi_header.push({possition:t,offset:S,parsed:R})}(c)),r===null&&(t=c),r}function sa(){var r,f,d,s,c,h,g;if(c=t,h=t,e.substr(t,3).toLowerCase()==="sip"?(r=e.substr(t,3),t+=3):(r=null,l('"SIP"')),r===null&&(r=$()),r!==null){for(f=[],g=t,d=we(),d!==null?(s=Dr(),s!==null?d=[d,s]:(d=null,t=g)):(d=null,t=g);d!==null;)f.push(d),g=t,d=we(),d!==null?(s=Dr(),s!==null?d=[d,s]:(d=null,t=g)):(d=null,t=g);f!==null?r=[r,f]:(r=null,t=h)}else r=null,t=h;return r!==null&&(r=function(S,R){if(i.protocol=R.toLowerCase(),i.params||(i.params={}),i.params.text&&i.params.text[0]==='"'){var I=i.params.text;i.text=I.substring(1,I.length-1),delete i.params.text}}(c,r[0])),r===null&&(t=c),r}function Dr(){var r;return r=Ss(),r===null&&(r=Ze()),r}function Ss(){var r,f,d,s,c,h;if(c=t,h=t,e.substr(t,5).toLowerCase()==="cause"?(r=e.substr(t,5),t+=5):(r=null,l('"cause"')),r!==null)if(f=he(),f!==null){if(s=b(),s!==null)for(d=[];s!==null;)d.push(s),s=b();else d=null;d!==null?r=[r,f,d]:(r=null,t=h)}else r=null,t=h;else r=null,t=h;return r!==null&&(r=function(g,S){i.cause=parseInt(S.join(""))}(c,r[2])),r===null&&(t=c),r}function na(){var r,f,d,s,c,h;if(c=t,r=$(),r!==null){for(f=[],h=t,d=xe(),d!==null?(s=$(),s!==null?d=[d,s]:(d=null,t=h)):(d=null,t=h);d!==null;)f.push(d),h=t,d=xe(),d!==null?(s=$(),s!==null?d=[d,s]:(d=null,t=h)):(d=null,t=h);f!==null?r=[r,f]:(r=null,t=c)}else r=null,t=c;return r}function Ll(){var r,f,d,s,c,h;if(c=t,r=js(),r!==null){for(f=[],h=t,d=xe(),d!==null?(s=js(),s!==null?d=[d,s]:(d=null,t=h)):(d=null,t=h);d!==null;)f.push(d),h=t,d=xe(),d!==null?(s=js(),s!==null?d=[d,s]:(d=null,t=h)):(d=null,t=h);f!==null?r=[r,f]:(r=null,t=c)}else r=null,t=c;return r}function js(){var r,f,d,s,c,h;if(c=t,r=gs(),r!==null){for(f=[],h=t,d=we(),d!==null?(s=Ze(),s!==null?d=[d,s]:(d=null,t=h)):(d=null,t=h);d!==null;)f.push(d),h=t,d=we(),d!==null?(s=Ze(),s!==null?d=[d,s]:(d=null,t=h)):(d=null,t=h);f!==null?r=[r,f]:(r=null,t=c)}else r=null,t=c;return r}function li(){var r,f,d,s,c,h;if(c=t,r=ri(),r!==null){for(f=[],h=t,d=we(),d!==null?(s=hn(),s!==null?d=[d,s]:(d=null,t=h)):(d=null,t=h);d!==null;)f.push(d),h=t,d=we(),d!==null?(s=hn(),s!==null?d=[d,s]:(d=null,t=h)):(d=null,t=h);f!==null?r=[r,f]:(r=null,t=c)}else r=null,t=c;return r}function ri(){var r,f;return f=t,e.substr(t,6).toLowerCase()==="active"?(r=e.substr(t,6),t+=6):(r=null,l('"active"')),r===null&&(e.substr(t,7).toLowerCase()==="pending"?(r=e.substr(t,7),t+=7):(r=null,l('"pending"')),r===null&&(e.substr(t,10).toLowerCase()==="terminated"?(r=e.substr(t,10),t+=10):(r=null,l('"terminated"')),r===null&&(r=$()))),r!==null&&(r=function(d){i.state=e.substring(t,d)}(f)),r===null&&(t=f),r}function hn(){var r,f,d,s,c;return s=t,c=t,e.substr(t,6).toLowerCase()==="reason"?(r=e.substr(t,6),t+=6):(r=null,l('"reason"')),r!==null?(f=he(),f!==null?(d=ii(),d!==null?r=[r,f,d]:(r=null,t=c)):(r=null,t=c)):(r=null,t=c),r!==null&&(r=function(h,g){typeof g<"u"&&(i.reason=g)}(s,r[2])),r===null&&(t=s),r===null&&(s=t,c=t,e.substr(t,7).toLowerCase()==="expires"?(r=e.substr(t,7),t+=7):(r=null,l('"expires"')),r!==null?(f=he(),f!==null?(d=Yt(),d!==null?r=[r,f,d]:(r=null,t=c)):(r=null,t=c)):(r=null,t=c),r!==null&&(r=function(h,g){typeof g<"u"&&(i.expires=g)}(s,r[2])),r===null&&(t=s),r===null&&(s=t,c=t,e.substr(t,11).toLowerCase()==="retry_after"?(r=e.substr(t,11),t+=11):(r=null,l('"retry_after"')),r!==null?(f=he(),f!==null?(d=Yt(),d!==null?r=[r,f,d]:(r=null,t=c)):(r=null,t=c)):(r=null,t=c),r!==null&&(r=function(h,g){typeof g<"u"&&(i.retry_after=g)}(s,r[2])),r===null&&(t=s),r===null&&(r=Ze()))),r}function ii(){var r;return e.substr(t,11).toLowerCase()==="deactivated"?(r=e.substr(t,11),t+=11):(r=null,l('"deactivated"')),r===null&&(e.substr(t,9).toLowerCase()==="probation"?(r=e.substr(t,9),t+=9):(r=null,l('"probation"')),r===null&&(e.substr(t,8).toLowerCase()==="rejected"?(r=e.substr(t,8),t+=8):(r=null,l('"rejected"')),r===null&&(e.substr(t,7).toLowerCase()==="timeout"?(r=e.substr(t,7),t+=7):(r=null,l('"timeout"')),r===null&&(e.substr(t,6).toLowerCase()==="giveup"?(r=e.substr(t,6),t+=6):(r=null,l('"giveup"')),r===null&&(e.substr(t,10).toLowerCase()==="noresource"?(r=e.substr(t,10),t+=10):(r=null,l('"noresource"')),r===null&&(e.substr(t,9).toLowerCase()==="invariant"?(r=e.substr(t,9),t+=9):(r=null,l('"invariant"')),r===null&&(r=$()))))))),r}function $l(){var r;return r=G(),r=r!==null?r:"",r}function Nr(){var r,f,d,s,c,h;if(c=t,r=$(),r!==null){for(f=[],h=t,d=xe(),d!==null?(s=$(),s!==null?d=[d,s]:(d=null,t=h)):(d=null,t=h);d!==null;)f.push(d),h=t,d=xe(),d!==null?(s=$(),s!==null?d=[d,s]:(d=null,t=h)):(d=null,t=h);f!==null?r=[r,f]:(r=null,t=c)}else r=null,t=c;return r=r!==null?r:"",r}function Hn(){var r,f,d,s,c,h,g;if(c=t,h=t,r=ke(),r===null&&(r=gs()),r!==null){for(f=[],g=t,d=we(),d!==null?(s=Fn(),s!==null?d=[d,s]:(d=null,t=g)):(d=null,t=g);d!==null;)f.push(d),g=t,d=we(),d!==null?(s=Fn(),s!==null?d=[d,s]:(d=null,t=g)):(d=null,t=g);f!==null?r=[r,f]:(r=null,t=h)}else r=null,t=h;return r!==null&&(r=function(S){var R=i.tag;try{i=new Vs(i.uri,i.display_name,i.params),R&&i.setParam("tag",R)}catch{i=-1}}()),r===null&&(t=c),r}function Fn(){var r;return r=Hs(),r===null&&(r=Ze()),r}function ai(){var r,f,d,s,c,h;if(c=t,r=qn(),r!==null){for(f=[],h=t,d=xe(),d!==null?(s=qn(),s!==null?d=[d,s]:(d=null,t=h)):(d=null,t=h);d!==null;)f.push(d),h=t,d=xe(),d!==null?(s=qn(),s!==null?d=[d,s]:(d=null,t=h)):(d=null,t=h);f!==null?r=[r,f]:(r=null,t=c)}else r=null,t=c;return r}function qn(){var r,f,d,s,c,h,g,S;if(g=t,r=jl(),r!==null)if(f=B(),f!==null)if(d=Vn(),d!==null){for(s=[],S=t,c=we(),c!==null?(h=_n(),h!==null?c=[c,h]:(c=null,t=S)):(c=null,t=S);c!==null;)s.push(c),S=t,c=we(),c!==null?(h=_n(),h!==null?c=[c,h]:(c=null,t=S)):(c=null,t=S);s!==null?r=[r,f,d,s]:(r=null,t=g)}else r=null,t=g;else r=null,t=g;else r=null,t=g;return r}function _n(){var r;return r=Ur(),r===null&&(r=dn(),r===null&&(r=jn(),r===null&&(r=Hl(),r===null&&(r=Fl(),r===null&&(r=Ze()))))),r}function Ur(){var r,f,d,s,c;return s=t,c=t,e.substr(t,3).toLowerCase()==="ttl"?(r=e.substr(t,3),t+=3):(r=null,l('"ttl"')),r!==null?(f=he(),f!==null?(d=Bn(),d!==null?r=[r,f,d]:(r=null,t=c)):(r=null,t=c)):(r=null,t=c),r!==null&&(r=function(h,g){i.ttl=g}(s,r[2])),r===null&&(t=s),r}function dn(){var r,f,d,s,c;return s=t,c=t,e.substr(t,5).toLowerCase()==="maddr"?(r=e.substr(t,5),t+=5):(r=null,l('"maddr"')),r!==null?(f=he(),f!==null?(d=fs(),d!==null?r=[r,f,d]:(r=null,t=c)):(r=null,t=c)):(r=null,t=c),r!==null&&(r=function(h,g){i.maddr=g}(s,r[2])),r===null&&(t=s),r}function jn(){var r,f,d,s,c;return s=t,c=t,e.substr(t,8).toLowerCase()==="received"?(r=e.substr(t,8),t+=8):(r=null,l('"received"')),r!==null?(f=he(),f!==null?(d=_s(),d===null&&(d=Zt()),d!==null?r=[r,f,d]:(r=null,t=c)):(r=null,t=c)):(r=null,t=c),r!==null&&(r=function(h,g){i.received=g}(s,r[2])),r===null&&(t=s),r}function Hl(){var r,f,d,s,c;return s=t,c=t,e.substr(t,6).toLowerCase()==="branch"?(r=e.substr(t,6),t+=6):(r=null,l('"branch"')),r!==null?(f=he(),f!==null?(d=$(),d!==null?r=[r,f,d]:(r=null,t=c)):(r=null,t=c)):(r=null,t=c),r!==null&&(r=function(h,g){i.branch=g}(s,r[2])),r===null&&(t=s),r}function Fl(){var r,f,d,s,c;return s=t,e.substr(t,5).toLowerCase()==="rport"?(r=e.substr(t,5),t+=5):(r=null,l('"rport"')),r!==null?(c=t,f=he(),f!==null?(d=ql(),d!==null?f=[f,d]:(f=null,t=c)):(f=null,t=c),f=f!==null?f:"",f!==null?r=[r,f]:(r=null,t=s)):(r=null,t=s),r}function ql(){var r,f,d,s,c,h,g;return h=t,g=t,r=b(),r=r!==null?r:"",r!==null?(f=b(),f=f!==null?f:"",f!==null?(d=b(),d=d!==null?d:"",d!==null?(s=b(),s=s!==null?s:"",s!==null?(c=b(),c=c!==null?c:"",c!==null?r=[r,f,d,s,c]:(r=null,t=g)):(r=null,t=g)):(r=null,t=g)):(r=null,t=g)):(r=null,t=g),r!==null&&(r=function(S,R){i.rport=parseInt(R.join(""))}(h,r)),r===null&&(t=h),r}function jl(){var r,f,d,s,c,h;return h=t,r=Vl(),r!==null?(f=oe(),f!==null?(d=$(),d!==null?(s=oe(),s!==null?(c=Bl(),c!==null?r=[r,f,d,s,c]:(r=null,t=h)):(r=null,t=h)):(r=null,t=h)):(r=null,t=h)):(r=null,t=h),r}function Vl(){var r,f;return f=t,e.substr(t,3).toLowerCase()==="sip"?(r=e.substr(t,3),t+=3):(r=null,l('"SIP"')),r===null&&(r=$()),r!==null&&(r=function(d,s){i.protocol=s}(f,r)),r===null&&(t=f),r}function Bl(){var r,f;return f=t,e.substr(t,3).toLowerCase()==="udp"?(r=e.substr(t,3),t+=3):(r=null,l('"UDP"')),r===null&&(e.substr(t,3).toLowerCase()==="tcp"?(r=e.substr(t,3),t+=3):(r=null,l('"TCP"')),r===null&&(e.substr(t,3).toLowerCase()==="tls"?(r=e.substr(t,3),t+=3):(r=null,l('"TLS"')),r===null&&(e.substr(t,4).toLowerCase()==="sctp"?(r=e.substr(t,4),t+=4):(r=null,l('"SCTP"')),r===null&&(r=$())))),r!==null&&(r=function(d,s){i.transport=s}(f,r)),r===null&&(t=f),r}function Vn(){var r,f,d,s,c;return s=t,r=xr(),r!==null?(c=t,f=rt(),f!==null?(d=Pr(),d!==null?f=[f,d]:(f=null,t=c)):(f=null,t=c),f=f!==null?f:"",f!==null?r=[r,f]:(r=null,t=s)):(r=null,t=s),r}function xr(){var r,f;return f=t,r=_s(),r===null&&(r=dt(),r===null&&(r=Qs())),r!==null&&(r=function(d){i.host=e.substring(t,d)}(f)),r===null&&(t=f),r}function Pr(){var r,f,d,s,c,h,g;return h=t,g=t,r=b(),r=r!==null?r:"",r!==null?(f=b(),f=f!==null?f:"",f!==null?(d=b(),d=d!==null?d:"",d!==null?(s=b(),s=s!==null?s:"",s!==null?(c=b(),c=c!==null?c:"",c!==null?r=[r,f,d,s,c]:(r=null,t=g)):(r=null,t=g)):(r=null,t=g)):(r=null,t=g)):(r=null,t=g),r!==null&&(r=function(S,R){i.port=parseInt(R.join(""))}(h,r)),r===null&&(t=h),r}function Bn(){var r,f,d,s,c;return s=t,c=t,r=b(),r!==null?(f=b(),f=f!==null?f:"",f!==null?(d=b(),d=d!==null?d:"",d!==null?r=[r,f,d]:(r=null,t=c)):(r=null,t=c)):(r=null,t=c),r!==null&&(r=function(h,g){return parseInt(g.join(""))}(s,r)),r===null&&(t=s),r}function Gl(){var r;return r=ln(),r}function Mr(){var r,f,d,s,c,h;if(c=t,r=Wl(),r!==null){for(f=[],h=t,d=we(),d!==null?(s=Kl(),s!==null?d=[d,s]:(d=null,t=h)):(d=null,t=h);d!==null;)f.push(d),h=t,d=we(),d!==null?(s=Kl(),s!==null?d=[d,s]:(d=null,t=h)):(d=null,t=h);f!==null?r=[r,f]:(r=null,t=c)}else r=null,t=c;return r}function Wl(){var r,f;return f=t,r=Yt(),r!==null&&(r=function(d,s){i.expires=s}(f,r)),r===null&&(t=f),r}function Kl(){var r;return r=oi(),r===null&&(r=Ze()),r}function oi(){var r,f,d,s,c;return s=t,c=t,e.substr(t,9).toLowerCase()==="refresher"?(r=e.substr(t,9),t+=9):(r=null,l('"refresher"')),r!==null?(f=he(),f!==null?(e.substr(t,3).toLowerCase()==="uac"?(d=e.substr(t,3),t+=3):(d=null,l('"uac"')),d===null&&(e.substr(t,3).toLowerCase()==="uas"?(d=e.substr(t,3),t+=3):(d=null,l('"uas"'))),d!==null?r=[r,f,d]:(r=null,t=c)):(r=null,t=c)):(r=null,t=c),r!==null&&(r=function(h,g){i.refresher=g.toLowerCase()}(s,r[2])),r===null&&(t=s),r}function ui(){var r,f,d,s;return s=t,r=$(),r!==null?(f=V(),f!==null?(d=Gn(),d!==null?r=[r,f,d]:(r=null,t=s)):(r=null,t=s)):(r=null,t=s),r}function Gn(){var r,f;for(r=[],f=K(),f===null&&(f=te(),f===null&&(f=B()));f!==null;)r.push(f),f=K(),f===null&&(f=te(),f===null&&(f=B()));return r}function Jt(){var r,f;for(r=[],f=N();f!==null;)r.push(f),f=N();return r}function ci(){var r,f,d;return d=t,e.substr(t,5)==="uuid:"?(r="uuid:",t+=5):(r=null,l('"uuid:"')),r!==null?(f=Yl(),f!==null?r=[r,f]:(r=null,t=d)):(r=null,t=d),r}function Yl(){var r,f,d,s,c,h,g,S,R,I,D;return I=t,D=t,r=fi(),r!==null?(e.charCodeAt(t)===45?(f="-",t++):(f=null,l('"-"')),f!==null?(d=rs(),d!==null?(e.charCodeAt(t)===45?(s="-",t++):(s=null,l('"-"')),s!==null?(c=rs(),c!==null?(e.charCodeAt(t)===45?(h="-",t++):(h=null,l('"-"')),h!==null?(g=rs(),g!==null?(e.charCodeAt(t)===45?(S="-",t++):(S=null,l('"-"')),S!==null?(R=zl(),R!==null?r=[r,f,d,s,c,h,g,S,R]:(r=null,t=D)):(r=null,t=D)):(r=null,t=D)):(r=null,t=D)):(r=null,t=D)):(r=null,t=D)):(r=null,t=D)):(r=null,t=D)):(r=null,t=D),r!==null&&(r=function(J,Ne){i=e.substring(t+5,J)}(I,r[0])),r===null&&(t=I),r}function rs(){var r,f,d,s,c;return c=t,r=O(),r!==null?(f=O(),f!==null?(d=O(),d!==null?(s=O(),s!==null?r=[r,f,d,s]:(r=null,t=c)):(r=null,t=c)):(r=null,t=c)):(r=null,t=c),r}function fi(){var r,f,d;return d=t,r=rs(),r!==null?(f=rs(),f!==null?r=[r,f]:(r=null,t=d)):(r=null,t=d),r}function zl(){var r,f,d,s;return s=t,r=rs(),r!==null?(f=rs(),f!==null?(d=rs(),d!==null?r=[r,f,d]:(r=null,t=s)):(r=null,t=s)):(r=null,t=s),r}function Bt(){var r,f,d,s,c,h,g;if(c=t,h=t,r=ke(),r===null&&(r=gs()),r!==null){for(f=[],g=t,d=we(),d!==null?(s=Ze(),s!==null?d=[d,s]:(d=null,t=g)):(d=null,t=g);d!==null;)f.push(d),g=t,d=we(),d!==null?(s=Ze(),s!==null?d=[d,s]:(d=null,t=g)):(d=null,t=g);f!==null?r=[r,f]:(r=null,t=h)}else r=null,t=h;return r!==null&&(r=function(S){try{i=new Vs(i.uri,i.display_name,i.params)}catch{i=-1}}()),r===null&&(t=c),r}function kr(){var r,f,d,s,c,h;if(c=t,r=Jl(),r!==null){for(f=[],h=t,d=we(),d!==null?(s=Xl(),s!==null?d=[d,s]:(d=null,t=h)):(d=null,t=h);d!==null;)f.push(d),h=t,d=we(),d!==null?(s=Xl(),s!==null?d=[d,s]:(d=null,t=h)):(d=null,t=h);f!==null?r=[r,f]:(r=null,t=c)}else r=null,t=c;return r}function Jl(){var r,f,d,s,c,h;return s=t,c=t,r=P(),r!==null?(h=t,e.charCodeAt(t)===64?(f="@",t++):(f=null,l('"@"')),f!==null?(d=P(),d!==null?f=[f,d]:(f=null,t=h)):(f=null,t=h),f=f!==null?f:"",f!==null?r=[r,f]:(r=null,t=c)):(r=null,t=c),r!==null&&(r=function(g){i.call_id=e.substring(t,g)}(s)),r===null&&(t=s),r}function Xl(){var r;return r=hi(),r===null&&(r=Lr(),r===null&&(r=x(),r===null&&(r=Ze()))),r}function hi(){var r,f,d,s,c;return s=t,c=t,e.substr(t,6)==="to-tag"?(r="to-tag",t+=6):(r=null,l('"to-tag"')),r!==null?(f=he(),f!==null?(d=$(),d!==null?r=[r,f,d]:(r=null,t=c)):(r=null,t=c)):(r=null,t=c),r!==null&&(r=function(h,g){i.to_tag=g}(s,r[2])),r===null&&(t=s),r}function Lr(){var r,f,d,s,c;return s=t,c=t,e.substr(t,8)==="from-tag"?(r="from-tag",t+=8):(r=null,l('"from-tag"')),r!==null?(f=he(),f!==null?(d=$(),d!==null?r=[r,f,d]:(r=null,t=c)):(r=null,t=c)):(r=null,t=c),r!==null&&(r=function(h,g){i.from_tag=g}(s,r[2])),r===null&&(t=s),r}function x(){var r,f;return f=t,e.substr(t,10)==="early-only"?(r="early-only",t+=10):(r=null,l('"early-only"')),r!==null&&(r=function(d){i.early_only=!0}()),r===null&&(t=f),r}function Ql(r){r.sort();for(var f=null,d=[],s=0;s<r.length;s++)r[s]!==f&&(d.push(r[s]),f=r[s]);return d}function Zl(){for(var r=1,f=1,d=!1,s=0;s<Math.max(t,v);s++){var c=e.charAt(s);c===`
|
4
|
-
`?(
|
5
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var
|
6
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var N=!0,U=!1,z;return{s:function(){E=A[Symbol.iterator]()},n:function(){var _e=E.next();return N=_e.done,_e},e:function(_e){U=!0,z=_e},f:function(){try{!N&&E.return!=null&&E.return()}finally{if(U)throw z}}}}function a(A,b){if(A){if(typeof A=="string")return e(A,b);var E=Object.prototype.toString.call(A).slice(8,-1);if(E==="Object"&&A.constructor&&(E=A.constructor.name),E==="Map"||E==="Set")return Array.from(A);if(E==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(E))return e(A,b)}}function e(A,b){(b==null||b>A.length)&&(b=A.length);for(var E=0,O=new Array(b);E<b;E++)O[E]=A[E];return O}var o=pt,p=Kn(),t=Gs();ct.str_utf8_length=function(A){return unescape(encodeURIComponent(A)).length};var v=ct.isFunction=function(A){return A!==void 0?Object.prototype.toString.call(A)==="[object Function]":!1};ct.isString=function(A){return A!==void 0?Object.prototype.toString.call(A)==="[object String]":!1},ct.isDecimal=function(A){return!isNaN(A)&&parseFloat(A)===parseInt(A,10)},ct.isEmpty=function(A){return A===null||A===""||A===void 0||Array.isArray(A)&&A.length===0||typeof A=="number"&&isNaN(A)},ct.hasMethods=function(A){for(var b=arguments.length,E=new Array(b>1?b-1:0),O=1;O<b;O++)E[O-1]=arguments[O];for(var w=0,N=E;w<N.length;w++){var U=N[w];if(v(A[U]))return!1}return!0};var C=ct.createRandomToken=function(A){var b=arguments.length>1&&arguments[1]!==void 0?arguments[1]:32,E,O,w="";for(E=0;E<A;E++)O=Math.random()*b|0,w+=O.toString(b);return w};ct.newTag=function(){return C(10)},ct.newUUID=function(){var A="xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(b){var E=Math.random()*16|0,O=b==="x"?E:E&3|8;return O.toString(16)});return A},ct.hostType=function(A){if(A){if(A=t.parse(A,"host"),A!==-1)return A.host_type}else return};var l=ct.escapeUser=function(A){return encodeURIComponent(decodeURIComponent(A)).replace(/%3A/ig,":").replace(/%2B/ig,"+").replace(/%3F/ig,"?").replace(/%2F/ig,"/")};return ct.normalizeTarget=function(A,b){if(A){if(A instanceof p)return A;if(typeof A=="string"){var E=A.split("@"),O,w;switch(E.length){case 1:if(!b)return;O=A,w=b;break;case 2:O=E[0],w=E[1];break;default:O=E.slice(0,E.length-1).join("@"),w=E[E.length-1]}O=O.replace(/^(sips?|tel):/i,""),/^[-.()]*\+?[0-9\-.()]+$/.test(O)&&(O=O.replace(/[-.()]/g,"")),A="".concat(o.SIP,":").concat(l(O),"@").concat(w);var N;return(N=p.parse(A))?N:void 0}else return}else return},ct.headerize=function(A){var b={"Call-Id":"Call-ID",Cseq:"CSeq","Www-Authenticate":"WWW-Authenticate"},E=A.toLowerCase().replace(/_/g,"-").split("-"),O="",w=E.length,N;for(N=0;N<w;N++)N!==0&&(O+="-"),O+=E[N].charAt(0).toUpperCase()+E[N].substring(1);return b[O]&&(O=b[O]),O},ct.sipErrorCause=function(A){for(var b in o.SIP_ERROR_CAUSES)if(o.SIP_ERROR_CAUSES[b].indexOf(A)!==-1)return o.causes[b];return o.causes.SIP_FAILURE_CODE},ct.getRandomTestNetIP=function(){function A(b,E){return Math.floor(Math.random()*(E-b+1)+b)}return"192.0.2.".concat(A(1,254))},ct.calculateMD5=function(A){function b(ye,pe){return ye<<pe|ye>>>32-pe}function E(ye,pe){var Ce=ye&2147483648,ke=pe&2147483648,He=ye&1073741824,We=pe&1073741824,Ve=(ye&1073741823)+(pe&1073741823);return He&We?Ve^2147483648^Ce^ke:He|We?Ve&1073741824?Ve^3221225472^Ce^ke:Ve^1073741824^Ce^ke:Ve^Ce^ke}function O(ye,pe,Ce){return ye&pe|~ye&Ce}function w(ye,pe,Ce){return ye&Ce|pe&~Ce}function N(ye,pe,Ce){return ye^pe^Ce}function U(ye,pe,Ce){return pe^(ye|~Ce)}function z(ye,pe,Ce,ke,He,We,Ve){return ye=E(ye,E(E(O(pe,Ce,ke),He),Ve)),E(b(ye,We),pe)}function j(ye,pe,Ce,ke,He,We,Ve){return ye=E(ye,E(E(w(pe,Ce,ke),He),Ve)),E(b(ye,We),pe)}function _e(ye,pe,Ce,ke,He,We,Ve){return ye=E(ye,E(E(N(pe,Ce,ke),He),Ve)),E(b(ye,We),pe)}function k(ye,pe,Ce,ke,He,We,Ve){return ye=E(ye,E(E(U(pe,Ce,ke),He),Ve)),E(b(ye,We),pe)}function H(ye){for(var pe,Ce=ye.length,ke=Ce+8,He=(ke-ke%64)/64,We=(He+1)*16,Ve=new Array(We-1),Ht=0,_t=0;_t<Ce;)pe=(_t-_t%4)/4,Ht=_t%4*8,Ve[pe]=Ve[pe]|ye.charCodeAt(_t)<<Ht,_t++;return pe=(_t-_t%4)/4,Ht=_t%4*8,Ve[pe]=Ve[pe]|128<<Ht,Ve[We-2]=Ce<<3,Ve[We-1]=Ce>>>29,Ve}function de(ye){var pe="",Ce="",ke,He;for(He=0;He<=3;He++)ke=ye>>>He*8&255,Ce="0".concat(ke.toString(16)),pe=pe+Ce.substr(Ce.length-2,2);return pe}function Ue(ye){for(var pe="",Ce=0;Ce<ye.length;Ce++){var ke=ye.charCodeAt(Ce);ke<128?pe+=String.fromCharCode(ke):ke>127&&ke<2048?(pe+=String.fromCharCode(ke>>6|192),pe+=String.fromCharCode(ke&63|128)):(pe+=String.fromCharCode(ke>>12|224),pe+=String.fromCharCode(ke>>6&63|128),pe+=String.fromCharCode(ke&63|128))}return pe}var B=[],L,V,G,K,M,te,se,$,ne,ht=7,P=12,Q=17,oe=22,he=5,Re=9,be=14,fe=20,je=4,xe=11,we=16,rt=23,$e=6,ue=10,Oe=15,Pe=21;for(A=Ue(A),B=H(A),te=1732584193,se=4023233417,$=2562383102,ne=271733878,L=0;L<B.length;L+=16)V=te,G=se,K=$,M=ne,te=z(te,se,$,ne,B[L+0],ht,3614090360),ne=z(ne,te,se,$,B[L+1],P,3905402710),$=z($,ne,te,se,B[L+2],Q,606105819),se=z(se,$,ne,te,B[L+3],oe,3250441966),te=z(te,se,$,ne,B[L+4],ht,4118548399),ne=z(ne,te,se,$,B[L+5],P,1200080426),$=z($,ne,te,se,B[L+6],Q,2821735955),se=z(se,$,ne,te,B[L+7],oe,4249261313),te=z(te,se,$,ne,B[L+8],ht,1770035416),ne=z(ne,te,se,$,B[L+9],P,2336552879),$=z($,ne,te,se,B[L+10],Q,4294925233),se=z(se,$,ne,te,B[L+11],oe,2304563134),te=z(te,se,$,ne,B[L+12],ht,1804603682),ne=z(ne,te,se,$,B[L+13],P,4254626195),$=z($,ne,te,se,B[L+14],Q,2792965006),se=z(se,$,ne,te,B[L+15],oe,1236535329),te=j(te,se,$,ne,B[L+1],he,4129170786),ne=j(ne,te,se,$,B[L+6],Re,3225465664),$=j($,ne,te,se,B[L+11],be,643717713),se=j(se,$,ne,te,B[L+0],fe,3921069994),te=j(te,se,$,ne,B[L+5],he,3593408605),ne=j(ne,te,se,$,B[L+10],Re,38016083),$=j($,ne,te,se,B[L+15],be,3634488961),se=j(se,$,ne,te,B[L+4],fe,3889429448),te=j(te,se,$,ne,B[L+9],he,568446438),ne=j(ne,te,se,$,B[L+14],Re,3275163606),$=j($,ne,te,se,B[L+3],be,4107603335),se=j(se,$,ne,te,B[L+8],fe,1163531501),te=j(te,se,$,ne,B[L+13],he,2850285829),ne=j(ne,te,se,$,B[L+2],Re,4243563512),$=j($,ne,te,se,B[L+7],be,1735328473),se=j(se,$,ne,te,B[L+12],fe,2368359562),te=_e(te,se,$,ne,B[L+5],je,4294588738),ne=_e(ne,te,se,$,B[L+8],xe,2272392833),$=_e($,ne,te,se,B[L+11],we,1839030562),se=_e(se,$,ne,te,B[L+14],rt,4259657740),te=_e(te,se,$,ne,B[L+1],je,2763975236),ne=_e(ne,te,se,$,B[L+4],xe,1272893353),$=_e($,ne,te,se,B[L+7],we,4139469664),se=_e(se,$,ne,te,B[L+10],rt,3200236656),te=_e(te,se,$,ne,B[L+13],je,681279174),ne=_e(ne,te,se,$,B[L+0],xe,3936430074),$=_e($,ne,te,se,B[L+3],we,3572445317),se=_e(se,$,ne,te,B[L+6],rt,76029189),te=_e(te,se,$,ne,B[L+9],je,3654602809),ne=_e(ne,te,se,$,B[L+12],xe,3873151461),$=_e($,ne,te,se,B[L+15],we,530742520),se=_e(se,$,ne,te,B[L+2],rt,3299628645),te=k(te,se,$,ne,B[L+0],$e,4096336452),ne=k(ne,te,se,$,B[L+7],ue,1126891415),$=k($,ne,te,se,B[L+14],Oe,2878612391),se=k(se,$,ne,te,B[L+5],Pe,4237533241),te=k(te,se,$,ne,B[L+12],$e,1700485571),ne=k(ne,te,se,$,B[L+3],ue,2399980690),$=k($,ne,te,se,B[L+10],Oe,4293915773),se=k(se,$,ne,te,B[L+1],Pe,2240044497),te=k(te,se,$,ne,B[L+8],$e,1873313359),ne=k(ne,te,se,$,B[L+15],ue,4264355552),$=k($,ne,te,se,B[L+6],Oe,2734768916),se=k(se,$,ne,te,B[L+13],Pe,1309151649),te=k(te,se,$,ne,B[L+4],$e,4149444226),ne=k(ne,te,se,$,B[L+11],ue,3174756917),$=k($,ne,te,se,B[L+2],Oe,718787259),se=k(se,$,ne,te,B[L+9],Pe,3951481745),te=E(te,V),se=E(se,G),$=E($,K),ne=E(ne,M);var Le=de(te)+de(se)+de($)+de(ne);return Le.toLowerCase()},ct.closeMediaStream=function(A){if(A)try{var b;if(A.getTracks){b=A.getTracks();var E=n(b),O;try{for(E.s();!(O=E.n()).done;){var w=O.value;w.stop()}}catch(H){E.e(H)}finally{E.f()}}else{b=A.getAudioTracks();var N=n(b),U;try{for(N.s();!(U=N.n()).done;){var z=U.value;z.stop()}}catch(H){N.e(H)}finally{N.f()}b=A.getVideoTracks();var j=n(b),_e;try{for(j.s();!(_e=j.n()).done;){var k=_e.value;k.stop()}}catch(H){j.e(H)}finally{j.f()}}}catch{(typeof A.stop=="function"||u(A.stop)==="object")&&A.stop()}},ct.cloneArray=function(A){return A&&A.slice()||[]},ct.cloneObject=function(A){var b=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return A&&Object.assign({},A)||b},ct}var Co={exports:{}},qr=typeof Reflect=="object"?Reflect:null,ec=qr&&typeof qr.apply=="function"?qr.apply:function(n,a,e){return Function.prototype.apply.call(n,a,e)},fa;qr&&typeof qr.ownKeys=="function"?fa=qr.ownKeys:Object.getOwnPropertySymbols?fa=function(n){return Object.getOwnPropertyNames(n).concat(Object.getOwnPropertySymbols(n))}:fa=function(n){return Object.getOwnPropertyNames(n)};function Kh(u){console&&console.warn&&console.warn(u)}var tc=Number.isNaN||function(n){return n!==n};function Ye(){Ye.init.call(this)}Co.exports=Ye,Co.exports.once=Xh,Ye.EventEmitter=Ye,Ye.prototype._events=void 0,Ye.prototype._eventsCount=0,Ye.prototype._maxListeners=void 0;var sc=10;function ha(u){if(typeof u!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof u)}Object.defineProperty(Ye,"defaultMaxListeners",{enumerable:!0,get:function(){return sc},set:function(u){if(typeof u!="number"||u<0||tc(u))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+u+".");sc=u}}),Ye.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},Ye.prototype.setMaxListeners=function(n){if(typeof n!="number"||n<0||tc(n))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+n+".");return this._maxListeners=n,this};function nc(u){return u._maxListeners===void 0?Ye.defaultMaxListeners:u._maxListeners}Ye.prototype.getMaxListeners=function(){return nc(this)},Ye.prototype.emit=function(n){for(var a=[],e=1;e<arguments.length;e++)a.push(arguments[e]);var o=n==="error",p=this._events;if(p!==void 0)o=o&&p.error===void 0;else if(!o)return!1;if(o){var t;if(a.length>0&&(t=a[0]),t instanceof Error)throw t;var v=new Error("Unhandled error."+(t?" ("+t.message+")":""));throw v.context=t,v}var C=p[n];if(C===void 0)return!1;if(typeof C=="function")ec(C,this,a);else for(var l=C.length,A=oc(C,l),e=0;e<l;++e)ec(A[e],this,a);return!0};function lc(u,n,a,e){var o,p,t;if(ha(a),p=u._events,p===void 0?(p=u._events=Object.create(null),u._eventsCount=0):(p.newListener!==void 0&&(u.emit("newListener",n,a.listener?a.listener:a),p=u._events),t=p[n]),t===void 0)t=p[n]=a,++u._eventsCount;else if(typeof t=="function"?t=p[n]=e?[a,t]:[t,a]:e?t.unshift(a):t.push(a),o=nc(u),o>0&&t.length>o&&!t.warned){t.warned=!0;var v=new Error("Possible EventEmitter memory leak detected. "+t.length+" "+String(n)+" listeners added. Use emitter.setMaxListeners() to increase limit");v.name="MaxListenersExceededWarning",v.emitter=u,v.type=n,v.count=t.length,Kh(v)}return u}Ye.prototype.addListener=function(n,a){return lc(this,n,a,!1)},Ye.prototype.on=Ye.prototype.addListener,Ye.prototype.prependListener=function(n,a){return lc(this,n,a,!0)};function Yh(){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(u,n,a){var e={fired:!1,wrapFn:void 0,target:u,type:n,listener:a},o=Yh.bind(e);return o.listener=a,e.wrapFn=o,o}Ye.prototype.once=function(n,a){return ha(a),this.on(n,rc(this,n,a)),this},Ye.prototype.prependOnceListener=function(n,a){return ha(a),this.prependListener(n,rc(this,n,a)),this},Ye.prototype.removeListener=function(n,a){var e,o,p,t,v;if(ha(a),o=this._events,o===void 0)return this;if(e=o[n],e===void 0)return this;if(e===a||e.listener===a)--this._eventsCount===0?this._events=Object.create(null):(delete o[n],o.removeListener&&this.emit("removeListener",n,e.listener||a));else if(typeof e!="function"){for(p=-1,t=e.length-1;t>=0;t--)if(e[t]===a||e[t].listener===a){v=e[t].listener,p=t;break}if(p<0)return this;p===0?e.shift():zh(e,p),e.length===1&&(o[n]=e[0]),o.removeListener!==void 0&&this.emit("removeListener",n,v||a)}return this},Ye.prototype.off=Ye.prototype.removeListener,Ye.prototype.removeAllListeners=function(n){var a,e,o;if(e=this._events,e===void 0)return this;if(e.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):e[n]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete e[n]),this;if(arguments.length===0){var p=Object.keys(e),t;for(o=0;o<p.length;++o)t=p[o],t!=="removeListener"&&this.removeAllListeners(t);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(a=e[n],typeof a=="function")this.removeListener(n,a);else if(a!==void 0)for(o=a.length-1;o>=0;o--)this.removeListener(n,a[o]);return this};function ic(u,n,a){var e=u._events;if(e===void 0)return[];var o=e[n];return o===void 0?[]:typeof o=="function"?a?[o.listener||o]:[o]:a?Jh(o):oc(o,o.length)}Ye.prototype.listeners=function(n){return ic(this,n,!0)},Ye.prototype.rawListeners=function(n){return ic(this,n,!1)},Ye.listenerCount=function(u,n){return typeof u.listenerCount=="function"?u.listenerCount(n):ac.call(u,n)},Ye.prototype.listenerCount=ac;function ac(u){var n=this._events;if(n!==void 0){var a=n[u];if(typeof a=="function")return 1;if(a!==void 0)return a.length}return 0}Ye.prototype.eventNames=function(){return this._eventsCount>0?fa(this._events):[]};function oc(u,n){for(var a=new Array(n),e=0;e<n;++e)a[e]=u[e];return a}function zh(u,n){for(;n+1<u.length;n++)u[n]=u[n+1];u.pop()}function Jh(u){for(var n=new Array(u.length),a=0;a<n.length;++a)n[a]=u[a].listener||u[a];return n}function Xh(u,n){return new Promise(function(a,e){function o(t){u.removeListener(n,p),e(t)}function p(){typeof u.removeListener=="function"&&u.removeListener("error",o),a([].slice.call(arguments))}uc(u,n,p,{once:!0}),n!=="error"&&Qh(u,o,{once:!0})})}function Qh(u,n,a){typeof u.on=="function"&&uc(u,"error",n,a)}function uc(u,n,a,e){if(typeof u.on=="function")e.once?u.once(n,a):u.on(n,a);else if(typeof u.addEventListener=="function")u.addEventListener(n,function o(p){e.once&&u.removeEventListener(n,o),a(p)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof u)}var Ct=Co.exports,So={exports:{}},Ao,cc;function Zh(){if(cc)return Ao;cc=1;var u=1e3,n=u*60,a=n*60,e=a*24,o=e*7,p=e*365.25;Ao=function(A,b){b=b||{};var E=typeof A;if(E==="string"&&A.length>0)return t(A);if(E==="number"&&isFinite(A))return b.long?C(A):v(A);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(A))};function t(A){if(A=String(A),!(A.length>100)){var b=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(A);if(b){var E=parseFloat(b[1]),O=(b[2]||"ms").toLowerCase();switch(O){case"years":case"year":case"yrs":case"yr":case"y":return E*p;case"weeks":case"week":case"w":return E*o;case"days":case"day":case"d":return E*e;case"hours":case"hour":case"hrs":case"hr":case"h":return E*a;case"minutes":case"minute":case"mins":case"min":case"m":return E*n;case"seconds":case"second":case"secs":case"sec":case"s":return E*u;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return E;default:return}}}}function v(A){var b=Math.abs(A);return b>=e?Math.round(A/e)+"d":b>=a?Math.round(A/a)+"h":b>=n?Math.round(A/n)+"m":b>=u?Math.round(A/u)+"s":A+"ms"}function C(A){var b=Math.abs(A);return b>=e?l(A,b,e,"day"):b>=a?l(A,b,a,"hour"):b>=n?l(A,b,n,"minute"):b>=u?l(A,b,u,"second"):A+" ms"}function l(A,b,E,O){var w=b>=E*1.5;return Math.round(A/E)+" "+O+(w?"s":"")}return Ao}function e_(u){a.debug=a,a.default=a,a.coerce=C,a.disable=p,a.enable=o,a.enabled=t,a.humanize=Zh(),a.destroy=l,Object.keys(u).forEach(A=>{a[A]=u[A]}),a.names=[],a.skips=[],a.formatters={};function n(A){let b=0;for(let E=0;E<A.length;E++)b=(b<<5)-b+A.charCodeAt(E),b|=0;return a.colors[Math.abs(b)%a.colors.length]}a.selectColor=n;function a(A){let b,E=null,O,w;function N(...U){if(!N.enabled)return;const z=N,j=Number(new Date),_e=j-(b||j);z.diff=_e,z.prev=b,z.curr=j,b=j,U[0]=a.coerce(U[0]),typeof U[0]!="string"&&U.unshift("%O");let k=0;U[0]=U[0].replace(/%([a-zA-Z%])/g,(de,Ue)=>{if(de==="%%")return"%";k++;const B=a.formatters[Ue];if(typeof B=="function"){const L=U[k];de=B.call(z,L),U.splice(k,1),k--}return de}),a.formatArgs.call(z,U),(z.log||a.log).apply(z,U)}return N.namespace=A,N.useColors=a.useColors(),N.color=a.selectColor(A),N.extend=e,N.destroy=a.destroy,Object.defineProperty(N,"enabled",{enumerable:!0,configurable:!1,get:()=>E!==null?E:(O!==a.namespaces&&(O=a.namespaces,w=a.enabled(A)),w),set:U=>{E=U}}),typeof a.init=="function"&&a.init(N),N}function e(A,b){const E=a(this.namespace+(typeof b>"u"?":":b)+A);return E.log=this.log,E}function o(A){a.save(A),a.namespaces=A,a.names=[],a.skips=[];let b;const E=(typeof A=="string"?A:"").split(/[\s,]+/),O=E.length;for(b=0;b<O;b++)E[b]&&(A=E[b].replace(/\*/g,".*?"),A[0]==="-"?a.skips.push(new RegExp("^"+A.slice(1)+"$")):a.names.push(new RegExp("^"+A+"$")))}function p(){const A=[...a.names.map(v),...a.skips.map(v).map(b=>"-"+b)].join(",");return a.enable(""),A}function t(A){if(A[A.length-1]==="*")return!0;let b,E;for(b=0,E=a.skips.length;b<E;b++)if(a.skips[b].test(A))return!1;for(b=0,E=a.names.length;b<E;b++)if(a.names[b].test(A))return!0;return!1}function v(A){return A.toString().substring(2,A.toString().length-2).replace(/\.\*\?$/,"*")}function C(A){return A instanceof Error?A.stack||A.message:A}function l(){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 a.enable(a.load()),a}var t_=e_;(function(u,n){n.formatArgs=e,n.save=o,n.load=p,n.useColors=a,n.storage=t(),n.destroy=(()=>{let C=!1;return()=>{C||(C=!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`."))}})(),n.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 a(){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 e(C){if(C[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+C[0]+(this.useColors?"%c ":" ")+"+"+u.exports.humanize(this.diff),!this.useColors)return;const l="color: "+this.color;C.splice(1,0,l,"color: inherit");let A=0,b=0;C[0].replace(/%[a-zA-Z%]/g,E=>{E!=="%%"&&(A++,E==="%c"&&(b=A))}),C.splice(b,0,l)}n.log=console.debug||console.log||(()=>{});function o(C){try{C?n.storage.setItem("debug",C):n.storage.removeItem("debug")}catch{}}function p(){let C;try{C=n.storage.getItem("debug")}catch{}return!C&&typeof process<"u"&&"env"in process&&(C=process.env.DEBUG),C}function t(){try{return localStorage}catch{}}u.exports=t_(n);const{formatters:v}=u.exports;v.j=function(C){try{return JSON.stringify(C)}catch(l){return"[UnexpectedJSONParseError]: "+l.message}}})(So,So.exports);var jr=So.exports;function s_(u,n){if(!(u instanceof n))throw new TypeError("Cannot call a class as a function")}function fc(u,n){for(var a=0;a<n.length;a++){var e=n[a];e.enumerable=e.enumerable||!1,e.configurable=!0,"value"in e&&(e.writable=!0),Object.defineProperty(u,e.key,e)}}function n_(u,n,a){return n&&fc(u.prototype,n),a&&fc(u,a),u}var Vr=jr,Br="JsSIP",St=function(){function u(n){s_(this,u),n?(this._debug=Vr.default("".concat(Br,":").concat(n)),this._warn=Vr.default("".concat(Br,":WARN:").concat(n)),this._error=Vr.default("".concat(Br,":ERROR:").concat(n))):(this._debug=Vr.default(Br),this._warn=Vr.default("".concat(Br,":WARN")),this._error=Vr.default("".concat(Br,":ERROR"))),this._debug.log=console.info.bind(console),this._warn.log=console.warn.bind(console),this._error.log=console.error.bind(console)}return n_(u,[{key:"debug",get:function(){return this._debug}},{key:"warn",get:function(){return this._warn}},{key:"error",get:function(){return this._error}}]),u}(),Gt={},hc={},_c={exports:{}},dc=_c.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(u){return u.encoding?"rtpmap:%d %s/%s/%s":u.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(u){return u.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(u){return u.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(u){return"extmap:%d"+(u.direction?"/%s":"%v")+(u["encrypt-uri"]?" %s":"%v")+" %s"+(u.config?" %s":"")}},{name:"extmapAllowMixed",reg:/^(extmap-allow-mixed)/},{push:"crypto",reg:/^crypto:(\d*) ([\w_]*) (\S*)(?: (\S*))?/,names:["id","suite","config","sessionConfig"],format:function(u){return u.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(u){var n="candidate:%s %d %s %d %s %d typ %s";return n+=u.raddr!=null?" raddr %s rport %d":"%v%v",n+=u.tcptype!=null?" tcptype %s":"%v",u.generation!=null&&(n+=" generation %d"),n+=u["network-id"]!=null?" network-id %d":"%v",n+=u["network-cost"]!=null?" network-cost %d":"%v",n}},{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(u){var n="ssrc:%d";return u.attribute!=null&&(n+=" %s",u.value!=null&&(n+=":%s")),n}},{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(u){return u.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(u){return u.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(u){return"imageattr:%s %s %s"+(u.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(u){return"simulcast:%s %s"+(u.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(u){return"ts-refclk:%s"+(u.clksrcExt!=null?"=%s":"")}},{name:"mediaClk",reg:/^mediaclk:(?:id=(\S*))? *([^\s=]*)(?:=(\S*))?(?: *rate=(\d+)\/(\d+))?/,names:["id","mediaClockName","mediaClockValue","rateNumerator","rateDenominator"],format:function(u){var n="mediaclk:";return n+=u.id!=null?"id=%s %s":"%v%s",n+=u.mediaClockValue!=null?"=%s":"",n+=u.rateNumerator!=null?" rate=%s":"",n+=u.rateDenominator!=null?"/%s":"",n}},{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(u){var n=dc[u];n.forEach(function(a){a.reg||(a.reg=/(.*)/),a.format||(a.format="%s")})});var pc=_c.exports;(function(u){var n=function(v){return String(Number(v))===v?Number(v):v},a=function(v,C,l,A){if(A&&!l)C[A]=n(v[1]);else for(var b=0;b<l.length;b+=1)v[b+1]!=null&&(C[l[b]]=n(v[b+1]))},e=function(v,C,l){var A=v.name&&v.names;v.push&&!C[v.push]?C[v.push]=[]:A&&!C[v.name]&&(C[v.name]={});var b=v.push?{}:A?C[v.name]:C;a(l.match(v.reg),b,v.names,v.name),v.push&&C[v.push].push(b)},o=pc,p=RegExp.prototype.test.bind(/^([a-z])=(.*)/);u.parse=function(v){var C={},l=[],A=C;return v.split(/(\r\n|\r|\n)/).filter(p).forEach(function(b){var E=b[0],O=b.slice(2);E==="m"&&(l.push({rtp:[],fmtp:[]}),A=l[l.length-1]);for(var w=0;w<(o[E]||[]).length;w+=1){var N=o[E][w];if(N.reg.test(O))return e(N,A,O)}}),C.media=l,C};var t=function(v,C){var l=C.split(/=(.+)/,2);return l.length===2?v[l[0]]=n(l[1]):l.length===1&&C.length>1&&(v[l[0]]=void 0),v};u.parseParams=function(v){return v.split(/;\s?/).reduce(t,{})},u.parseFmtpConfig=u.parseParams,u.parsePayloads=function(v){return v.toString().split(" ").map(Number)},u.parseRemoteCandidates=function(v){for(var C=[],l=v.split(" ").map(n),A=0;A<l.length;A+=3)C.push({component:l[A],ip:l[A+1],port:l[A+2]});return C},u.parseImageAttributes=function(v){return v.split(" ").map(function(C){return C.substring(1,C.length-1).split(",").reduce(t,{})})},u.parseSimulcastStreamList=function(v){return v.split(";").map(function(C){return C.split(",").map(function(l){var A,b=!1;return l[0]!=="~"?A=n(l):(A=n(l.substring(1,l.length)),b=!0),{scid:A,paused:b}})})}})(hc);var yo=pc,l_=/%[sdv%]/g,r_=function(u){var n=1,a=arguments,e=a.length;return u.replace(l_,function(o){if(n>=e)return o;var p=a[n];switch(n+=1,o){case"%%":return"%";case"%s":return String(p);case"%d":return Number(p);case"%v":return""}})},pi=function(u,n,a){var e=n.format instanceof Function?n.format(n.push?a:a[n.name]):n.format,o=[u+"="+e];if(n.names)for(var p=0;p<n.names.length;p+=1){var t=n.names[p];n.name?o.push(a[n.name][t]):o.push(a[n.names[p]])}else o.push(a[n.name]);return r_.apply(null,o)},i_=["v","o","s","i","u","e","p","c","b","t","r","z","a"],a_=["i","c","b","a"],o_=function(u,n){n=n||{},u.version==null&&(u.version=0),u.name==null&&(u.name=" "),u.media.forEach(function(p){p.payloads==null&&(p.payloads="")});var a=n.outerOrder||i_,e=n.innerOrder||a_,o=[];return a.forEach(function(p){yo[p].forEach(function(t){t.name in u&&u[t.name]!=null?o.push(pi(p,t,u)):t.push in u&&u[t.push]!=null&&u[t.push].forEach(function(v){o.push(pi(p,t,v))})})}),u.media.forEach(function(p){o.push(pi("m",yo.m[0],p)),e.forEach(function(t){yo[t].forEach(function(v){v.name in p&&p[v.name]!=null?o.push(pi(t,v,p)):v.push in p&&p[v.push]!=null&&p[v.push].forEach(function(C){o.push(pi(t,v,C))})})})}),o.join(`\r
|
3
|
+
`,e+=2):(r=null,n('"\\r\\n"')),r}function S(){var r;return/^[0-9]/.test(l.charAt(e))?(r=l.charAt(e),e++):(r=null,n("[0-9]")),r}function m(){var r;return/^[a-zA-Z]/.test(l.charAt(e))?(r=l.charAt(e),e++):(r=null,n("[a-zA-Z]")),r}function C(){var r;return/^[0-9a-fA-F]/.test(l.charAt(e))?(r=l.charAt(e),e++):(r=null,n("[0-9a-fA-F]")),r}function A(){var r;return r=V(),r===null&&(r=W()),r}function R(){var r;return/^[\0-\xFF]/.test(l.charAt(e))?(r=l.charAt(e),e++):(r=null,n("[\\0-\\xFF]")),r}function I(){var r;return/^["]/.test(l.charAt(e))?(r=l.charAt(e),e++):(r=null,n('["]')),r}function V(){var r;return l.charCodeAt(e)===32?(r=" ",e++):(r=null,n('" "')),r}function W(){var r;return l.charCodeAt(e)===9?(r=" ",e++):(r=null,n('"\\t"')),r}function oe(){var r;return/^[a-zA-Z0-9]/.test(l.charAt(e))?(r=l.charAt(e),e++):(r=null,n("[a-zA-Z0-9]")),r}function x(){var r;return l.charCodeAt(e)===59?(r=";",e++):(r=null,n('";"')),r===null&&(l.charCodeAt(e)===47?(r="/",e++):(r=null,n('"/"')),r===null&&(l.charCodeAt(e)===63?(r="?",e++):(r=null,n('"?"')),r===null&&(l.charCodeAt(e)===58?(r=":",e++):(r=null,n('":"')),r===null&&(l.charCodeAt(e)===64?(r="@",e++):(r=null,n('"@"')),r===null&&(l.charCodeAt(e)===38?(r="&",e++):(r=null,n('"&"')),r===null&&(l.charCodeAt(e)===61?(r="=",e++):(r=null,n('"="')),r===null&&(l.charCodeAt(e)===43?(r="+",e++):(r=null,n('"+"')),r===null&&(l.charCodeAt(e)===36?(r="$",e++):(r=null,n('"$"')),r===null&&(l.charCodeAt(e)===44?(r=",",e++):(r=null,n('","'))))))))))),r}function $(){var r;return r=oe(),r===null&&(r=Re()),r}function Re(){var r;return l.charCodeAt(e)===45?(r="-",e++):(r=null,n('"-"')),r===null&&(l.charCodeAt(e)===95?(r="_",e++):(r=null,n('"_"')),r===null&&(l.charCodeAt(e)===46?(r=".",e++):(r=null,n('"."')),r===null&&(l.charCodeAt(e)===33?(r="!",e++):(r=null,n('"!"')),r===null&&(l.charCodeAt(e)===126?(r="~",e++):(r=null,n('"~"')),r===null&&(l.charCodeAt(e)===42?(r="*",e++):(r=null,n('"*"')),r===null&&(l.charCodeAt(e)===39?(r="'",e++):(r=null,n(`"'"`)),r===null&&(l.charCodeAt(e)===40?(r="(",e++):(r=null,n('"("')),r===null&&(l.charCodeAt(e)===41?(r=")",e++):(r=null,n('")"')))))))))),r}function be(){var r,f,h,t,o;return t=e,o=e,l.charCodeAt(e)===37?(r="%",e++):(r=null,n('"%"')),r!==null?(f=C(),f!==null?(h=C(),h!==null?r=[r,f,h]:(r=null,e=o)):(r=null,e=o)):(r=null,e=o),r!==null&&(r=function(u,d){return d.join("")}(t,r)),r===null&&(e=t),r}function H(){var r,f,h,t,o,u;for(t=e,o=e,u=e,r=[],f=A();f!==null;)r.push(f),f=A();if(r!==null?(f=v(),f!==null?r=[r,f]:(r=null,e=u)):(r=null,e=u),r=r!==null?r:"",r!==null){if(h=A(),h!==null)for(f=[];h!==null;)f.push(h),h=A();else f=null;f!==null?r=[r,f]:(r=null,e=o)}else r=null,e=o;return r!==null&&(r=function(d){return" "}()),r===null&&(e=t),r}function D(){var r;return r=H(),r=r!==null?r:"",r}function L(){var r,f,h,t,o;for(t=e,o=e,r=[],f=V(),f===null&&(f=W());f!==null;)r.push(f),f=V(),f===null&&(f=W());return r!==null?(l.charCodeAt(e)===58?(f=":",e++):(f=null,n('":"')),f!==null?(h=D(),h!==null?r=[r,f,h]:(r=null,e=o)):(r=null,e=o)):(r=null,e=o),r!==null&&(r=function(u){return":"}()),r===null&&(e=t),r}function q(){var r,f,h,t,o,u,d;if(o=e,u=e,f=j(),f!==null)for(r=[];f!==null;)r.push(f),f=j();else r=null;if(r!==null){for(f=[],d=e,h=[],t=H();t!==null;)h.push(t),t=H();for(h!==null?(t=j(),t!==null?h=[h,t]:(h=null,e=d)):(h=null,e=d);h!==null;){for(f.push(h),d=e,h=[],t=H();t!==null;)h.push(t),t=H();h!==null?(t=j(),t!==null?h=[h,t]:(h=null,e=d)):(h=null,e=d)}f!==null?r=[r,f]:(r=null,e=u)}else r=null,e=u;return r!==null&&(r=function(T){return l.substring(e,T)}(o)),r===null&&(e=o),r}function j(){var r;return/^[!-~]/.test(l.charAt(e))?(r=l.charAt(e),e++):(r=null,n("[!-~]")),r===null&&(r=B()),r}function B(){var r;return/^[\x80-\uFFFF]/.test(l.charAt(e))?(r=l.charAt(e),e++):(r=null,n("[\\x80-\\uFFFF]")),r}function Q(){var r;return/^[\x80-\xBF]/.test(l.charAt(e))?(r=l.charAt(e),e++):(r=null,n("[\\x80-\\xBF]")),r}function Z(){var r;return r=S(),r===null&&(/^[a-f]/.test(l.charAt(e))?(r=l.charAt(e),e++):(r=null,n("[a-f]"))),r}function U(){var r,f,h;if(h=e,f=oe(),f===null&&(l.charCodeAt(e)===45?(f="-",e++):(f=null,n('"-"')),f===null&&(l.charCodeAt(e)===46?(f=".",e++):(f=null,n('"."')),f===null&&(l.charCodeAt(e)===33?(f="!",e++):(f=null,n('"!"')),f===null&&(l.charCodeAt(e)===37?(f="%",e++):(f=null,n('"%"')),f===null&&(l.charCodeAt(e)===42?(f="*",e++):(f=null,n('"*"')),f===null&&(l.charCodeAt(e)===95?(f="_",e++):(f=null,n('"_"')),f===null&&(l.charCodeAt(e)===43?(f="+",e++):(f=null,n('"+"')),f===null&&(l.charCodeAt(e)===96?(f="`",e++):(f=null,n('"`"')),f===null&&(l.charCodeAt(e)===39?(f="'",e++):(f=null,n(`"'"`)),f===null&&(l.charCodeAt(e)===126?(f="~",e++):(f=null,n('"~"')))))))))))),f!==null)for(r=[];f!==null;)r.push(f),f=oe(),f===null&&(l.charCodeAt(e)===45?(f="-",e++):(f=null,n('"-"')),f===null&&(l.charCodeAt(e)===46?(f=".",e++):(f=null,n('"."')),f===null&&(l.charCodeAt(e)===33?(f="!",e++):(f=null,n('"!"')),f===null&&(l.charCodeAt(e)===37?(f="%",e++):(f=null,n('"%"')),f===null&&(l.charCodeAt(e)===42?(f="*",e++):(f=null,n('"*"')),f===null&&(l.charCodeAt(e)===95?(f="_",e++):(f=null,n('"_"')),f===null&&(l.charCodeAt(e)===43?(f="+",e++):(f=null,n('"+"')),f===null&&(l.charCodeAt(e)===96?(f="`",e++):(f=null,n('"`"')),f===null&&(l.charCodeAt(e)===39?(f="'",e++):(f=null,n(`"'"`)),f===null&&(l.charCodeAt(e)===126?(f="~",e++):(f=null,n('"~"'))))))))))));else r=null;return r!==null&&(r=function(t){return l.substring(e,t)}(h)),r===null&&(e=h),r}function se(){var r,f,h;if(h=e,f=oe(),f===null&&(l.charCodeAt(e)===45?(f="-",e++):(f=null,n('"-"')),f===null&&(l.charCodeAt(e)===33?(f="!",e++):(f=null,n('"!"')),f===null&&(l.charCodeAt(e)===37?(f="%",e++):(f=null,n('"%"')),f===null&&(l.charCodeAt(e)===42?(f="*",e++):(f=null,n('"*"')),f===null&&(l.charCodeAt(e)===95?(f="_",e++):(f=null,n('"_"')),f===null&&(l.charCodeAt(e)===43?(f="+",e++):(f=null,n('"+"')),f===null&&(l.charCodeAt(e)===96?(f="`",e++):(f=null,n('"`"')),f===null&&(l.charCodeAt(e)===39?(f="'",e++):(f=null,n(`"'"`)),f===null&&(l.charCodeAt(e)===126?(f="~",e++):(f=null,n('"~"'))))))))))),f!==null)for(r=[];f!==null;)r.push(f),f=oe(),f===null&&(l.charCodeAt(e)===45?(f="-",e++):(f=null,n('"-"')),f===null&&(l.charCodeAt(e)===33?(f="!",e++):(f=null,n('"!"')),f===null&&(l.charCodeAt(e)===37?(f="%",e++):(f=null,n('"%"')),f===null&&(l.charCodeAt(e)===42?(f="*",e++):(f=null,n('"*"')),f===null&&(l.charCodeAt(e)===95?(f="_",e++):(f=null,n('"_"')),f===null&&(l.charCodeAt(e)===43?(f="+",e++):(f=null,n('"+"')),f===null&&(l.charCodeAt(e)===96?(f="`",e++):(f=null,n('"`"')),f===null&&(l.charCodeAt(e)===39?(f="'",e++):(f=null,n(`"'"`)),f===null&&(l.charCodeAt(e)===126?(f="~",e++):(f=null,n('"~"')))))))))));else r=null;return r!==null&&(r=function(t){return l.substring(e,t)}(h)),r===null&&(e=h),r}function Dt(){var r;return l.charCodeAt(e)===40?(r="(",e++):(r=null,n('"("')),r===null&&(l.charCodeAt(e)===41?(r=")",e++):(r=null,n('")"')),r===null&&(l.charCodeAt(e)===60?(r="<",e++):(r=null,n('"<"')),r===null&&(l.charCodeAt(e)===62?(r=">",e++):(r=null,n('">"')),r===null&&(l.charCodeAt(e)===64?(r="@",e++):(r=null,n('"@"')),r===null&&(l.charCodeAt(e)===44?(r=",",e++):(r=null,n('","')),r===null&&(l.charCodeAt(e)===59?(r=";",e++):(r=null,n('";"')),r===null&&(l.charCodeAt(e)===58?(r=":",e++):(r=null,n('":"')),r===null&&(l.charCodeAt(e)===92?(r="\\",e++):(r=null,n('"\\\\"')),r===null&&(r=I(),r===null&&(l.charCodeAt(e)===47?(r="/",e++):(r=null,n('"/"')),r===null&&(l.charCodeAt(e)===91?(r="[",e++):(r=null,n('"["')),r===null&&(l.charCodeAt(e)===93?(r="]",e++):(r=null,n('"]"')),r===null&&(l.charCodeAt(e)===63?(r="?",e++):(r=null,n('"?"')),r===null&&(l.charCodeAt(e)===61?(r="=",e++):(r=null,n('"="')),r===null&&(l.charCodeAt(e)===123?(r="{",e++):(r=null,n('"{"')),r===null&&(l.charCodeAt(e)===125?(r="}",e++):(r=null,n('"}"')),r===null&&(r=V(),r===null&&(r=W())))))))))))))))))),r}function N(){var r,f,h;if(h=e,f=oe(),f===null&&(l.charCodeAt(e)===45?(f="-",e++):(f=null,n('"-"')),f===null&&(l.charCodeAt(e)===46?(f=".",e++):(f=null,n('"."')),f===null&&(l.charCodeAt(e)===33?(f="!",e++):(f=null,n('"!"')),f===null&&(l.charCodeAt(e)===37?(f="%",e++):(f=null,n('"%"')),f===null&&(l.charCodeAt(e)===42?(f="*",e++):(f=null,n('"*"')),f===null&&(l.charCodeAt(e)===95?(f="_",e++):(f=null,n('"_"')),f===null&&(l.charCodeAt(e)===43?(f="+",e++):(f=null,n('"+"')),f===null&&(l.charCodeAt(e)===96?(f="`",e++):(f=null,n('"`"')),f===null&&(l.charCodeAt(e)===39?(f="'",e++):(f=null,n(`"'"`)),f===null&&(l.charCodeAt(e)===126?(f="~",e++):(f=null,n('"~"')),f===null&&(l.charCodeAt(e)===40?(f="(",e++):(f=null,n('"("')),f===null&&(l.charCodeAt(e)===41?(f=")",e++):(f=null,n('")"')),f===null&&(l.charCodeAt(e)===60?(f="<",e++):(f=null,n('"<"')),f===null&&(l.charCodeAt(e)===62?(f=">",e++):(f=null,n('">"')),f===null&&(l.charCodeAt(e)===58?(f=":",e++):(f=null,n('":"')),f===null&&(l.charCodeAt(e)===92?(f="\\",e++):(f=null,n('"\\\\"')),f===null&&(f=I(),f===null&&(l.charCodeAt(e)===47?(f="/",e++):(f=null,n('"/"')),f===null&&(l.charCodeAt(e)===91?(f="[",e++):(f=null,n('"["')),f===null&&(l.charCodeAt(e)===93?(f="]",e++):(f=null,n('"]"')),f===null&&(l.charCodeAt(e)===63?(f="?",e++):(f=null,n('"?"')),f===null&&(l.charCodeAt(e)===123?(f="{",e++):(f=null,n('"{"')),f===null&&(l.charCodeAt(e)===125?(f="}",e++):(f=null,n('"}"'))))))))))))))))))))))))),f!==null)for(r=[];f!==null;)r.push(f),f=oe(),f===null&&(l.charCodeAt(e)===45?(f="-",e++):(f=null,n('"-"')),f===null&&(l.charCodeAt(e)===46?(f=".",e++):(f=null,n('"."')),f===null&&(l.charCodeAt(e)===33?(f="!",e++):(f=null,n('"!"')),f===null&&(l.charCodeAt(e)===37?(f="%",e++):(f=null,n('"%"')),f===null&&(l.charCodeAt(e)===42?(f="*",e++):(f=null,n('"*"')),f===null&&(l.charCodeAt(e)===95?(f="_",e++):(f=null,n('"_"')),f===null&&(l.charCodeAt(e)===43?(f="+",e++):(f=null,n('"+"')),f===null&&(l.charCodeAt(e)===96?(f="`",e++):(f=null,n('"`"')),f===null&&(l.charCodeAt(e)===39?(f="'",e++):(f=null,n(`"'"`)),f===null&&(l.charCodeAt(e)===126?(f="~",e++):(f=null,n('"~"')),f===null&&(l.charCodeAt(e)===40?(f="(",e++):(f=null,n('"("')),f===null&&(l.charCodeAt(e)===41?(f=")",e++):(f=null,n('")"')),f===null&&(l.charCodeAt(e)===60?(f="<",e++):(f=null,n('"<"')),f===null&&(l.charCodeAt(e)===62?(f=">",e++):(f=null,n('">"')),f===null&&(l.charCodeAt(e)===58?(f=":",e++):(f=null,n('":"')),f===null&&(l.charCodeAt(e)===92?(f="\\",e++):(f=null,n('"\\\\"')),f===null&&(f=I(),f===null&&(l.charCodeAt(e)===47?(f="/",e++):(f=null,n('"/"')),f===null&&(l.charCodeAt(e)===91?(f="[",e++):(f=null,n('"["')),f===null&&(l.charCodeAt(e)===93?(f="]",e++):(f=null,n('"]"')),f===null&&(l.charCodeAt(e)===63?(f="?",e++):(f=null,n('"?"')),f===null&&(l.charCodeAt(e)===123?(f="{",e++):(f=null,n('"{"')),f===null&&(l.charCodeAt(e)===125?(f="}",e++):(f=null,n('"}"')))))))))))))))))))))))));else r=null;return r!==null&&(r=function(t){return l.substring(e,t)}(h)),r===null&&(e=h),r}function z(){var r,f,h,t,o;return t=e,o=e,r=D(),r!==null?(l.charCodeAt(e)===42?(f="*",e++):(f=null,n('"*"')),f!==null?(h=D(),h!==null?r=[r,f,h]:(r=null,e=o)):(r=null,e=o)):(r=null,e=o),r!==null&&(r=function(u){return"*"}()),r===null&&(e=t),r}function re(){var r,f,h,t,o;return t=e,o=e,r=D(),r!==null?(l.charCodeAt(e)===47?(f="/",e++):(f=null,n('"/"')),f!==null?(h=D(),h!==null?r=[r,f,h]:(r=null,e=o)):(r=null,e=o)):(r=null,e=o),r!==null&&(r=function(u){return"/"}()),r===null&&(e=t),r}function ae(){var r,f,h,t,o;return t=e,o=e,r=D(),r!==null?(l.charCodeAt(e)===61?(f="=",e++):(f=null,n('"="')),f!==null?(h=D(),h!==null?r=[r,f,h]:(r=null,e=o)):(r=null,e=o)):(r=null,e=o),r!==null&&(r=function(u){return"="}()),r===null&&(e=t),r}function Te(){var r,f,h,t,o;return t=e,o=e,r=D(),r!==null?(l.charCodeAt(e)===40?(f="(",e++):(f=null,n('"("')),f!==null?(h=D(),h!==null?r=[r,f,h]:(r=null,e=o)):(r=null,e=o)):(r=null,e=o),r!==null&&(r=function(u){return"("}()),r===null&&(e=t),r}function De(){var r,f,h,t,o;return t=e,o=e,r=D(),r!==null?(l.charCodeAt(e)===41?(f=")",e++):(f=null,n('")"')),f!==null?(h=D(),h!==null?r=[r,f,h]:(r=null,e=o)):(r=null,e=o)):(r=null,e=o),r!==null&&(r=function(u){return")"}()),r===null&&(e=t),r}function Ce(){var r,f,h,t;return h=e,t=e,l.charCodeAt(e)===62?(r=">",e++):(r=null,n('">"')),r!==null?(f=D(),f!==null?r=[r,f]:(r=null,e=t)):(r=null,e=t),r!==null&&(r=function(o){return">"}()),r===null&&(e=h),r}function He(){var r,f,h,t;return h=e,t=e,r=D(),r!==null?(l.charCodeAt(e)===60?(f="<",e++):(f=null,n('"<"')),f!==null?r=[r,f]:(r=null,e=t)):(r=null,e=t),r!==null&&(r=function(o){return"<"}()),r===null&&(e=h),r}function we(){var r,f,h,t,o;return t=e,o=e,r=D(),r!==null?(l.charCodeAt(e)===44?(f=",",e++):(f=null,n('","')),f!==null?(h=D(),h!==null?r=[r,f,h]:(r=null,e=o)):(r=null,e=o)):(r=null,e=o),r!==null&&(r=function(u){return","}()),r===null&&(e=t),r}function Se(){var r,f,h,t,o;return t=e,o=e,r=D(),r!==null?(l.charCodeAt(e)===59?(f=";",e++):(f=null,n('";"')),f!==null?(h=D(),h!==null?r=[r,f,h]:(r=null,e=o)):(r=null,e=o)):(r=null,e=o),r!==null&&(r=function(u){return";"}()),r===null&&(e=t),r}function ot(){var r,f,h,t,o;return t=e,o=e,r=D(),r!==null?(l.charCodeAt(e)===58?(f=":",e++):(f=null,n('":"')),f!==null?(h=D(),h!==null?r=[r,f,h]:(r=null,e=o)):(r=null,e=o)):(r=null,e=o),r!==null&&(r=function(u){return":"}()),r===null&&(e=t),r}function Ue(){var r,f,h,t;return h=e,t=e,r=D(),r!==null?(f=I(),f!==null?r=[r,f]:(r=null,e=t)):(r=null,e=t),r!==null&&(r=function(o){return'"'}()),r===null&&(e=h),r}function le(){var r,f,h,t;return h=e,t=e,r=I(),r!==null?(f=D(),f!==null?r=[r,f]:(r=null,e=t)):(r=null,e=t),r!==null&&(r=function(o){return'"'}()),r===null&&(e=h),r}function Ae(){var r,f,h,t;if(t=e,r=Te(),r!==null){for(f=[],h=Oe(),h===null&&(h=pe(),h===null&&(h=Ae()));h!==null;)f.push(h),h=Oe(),h===null&&(h=pe(),h===null&&(h=Ae()));f!==null?(h=De(),h!==null?r=[r,f,h]:(r=null,e=t)):(r=null,e=t)}else r=null,e=t;return r}function Oe(){var r;return/^[!-']/.test(l.charAt(e))?(r=l.charAt(e),e++):(r=null,n("[!-']")),r===null&&(/^[*-[]/.test(l.charAt(e))?(r=l.charAt(e),e++):(r=null,n("[*-[]")),r===null&&(/^[\]-~]/.test(l.charAt(e))?(r=l.charAt(e),e++):(r=null,n("[\\]-~]")),r===null&&(r=B(),r===null&&(r=H())))),r}function Pe(){var r,f,h,t,o,u;if(o=e,u=e,r=D(),r!==null)if(f=I(),f!==null){for(h=[],t=he(),t===null&&(t=pe());t!==null;)h.push(t),t=he(),t===null&&(t=pe());h!==null?(t=I(),t!==null?r=[r,f,h,t]:(r=null,e=u)):(r=null,e=u)}else r=null,e=u;else r=null,e=u;return r!==null&&(r=function(d){return l.substring(e,d)}(o)),r===null&&(e=o),r}function ve(){var r,f,h,t,o,u;if(o=e,u=e,r=D(),r!==null)if(f=I(),f!==null){for(h=[],t=he(),t===null&&(t=pe());t!==null;)h.push(t),t=he(),t===null&&(t=pe());h!==null?(t=I(),t!==null?r=[r,f,h,t]:(r=null,e=u)):(r=null,e=u)}else r=null,e=u;else r=null,e=u;return r!==null&&(r=function(d){var T=l.substring(e,d).trim();return T.substring(1,T.length-1).replace(/\\([\x00-\x09\x0b-\x0c\x0e-\x7f])/g,"$1")}(o)),r===null&&(e=o),r}function he(){var r;return r=H(),r===null&&(l.charCodeAt(e)===33?(r="!",e++):(r=null,n('"!"')),r===null&&(/^[#-[]/.test(l.charAt(e))?(r=l.charAt(e),e++):(r=null,n("[#-[]")),r===null&&(/^[\]-~]/.test(l.charAt(e))?(r=l.charAt(e),e++):(r=null,n("[\\]-~]")),r===null&&(r=B())))),r}function pe(){var r,f,h;return h=e,l.charCodeAt(e)===92?(r="\\",e++):(r=null,n('"\\\\"')),r!==null?(/^[\0-\t]/.test(l.charAt(e))?(f=l.charAt(e),e++):(f=null,n("[\\0-\\t]")),f===null&&(/^[\x0B-\f]/.test(l.charAt(e))?(f=l.charAt(e),e++):(f=null,n("[\\x0B-\\f]")),f===null&&(/^[\x0E-]/.test(l.charAt(e))?(f=l.charAt(e),e++):(f=null,n("[\\x0E-]")))),f!==null?r=[r,f]:(r=null,e=h)):(r=null,e=h),r}function Ne(){var r,f,h,t,o,u;return o=e,u=e,r=We(),r!==null?(l.charCodeAt(e)===58?(f=":",e++):(f=null,n('":"')),f!==null?(h=dt(),h=h!==null?h:"",h!==null?(t=Tn(),t!==null?r=[r,f,h,t]:(r=null,e=u)):(r=null,e=u)):(r=null,e=u)):(r=null,e=u),r!==null&&(r=function(d){try{b.uri=new hl(b.scheme,b.user,b.host,b.port),delete b.scheme,delete b.user,delete b.host,delete b.host_type,delete b.port}catch{b=-1}}()),r===null&&(e=o),r}function Me(){var r,f,h,t,o,u,d,T;return d=e,T=e,r=We(),r!==null?(l.charCodeAt(e)===58?(f=":",e++):(f=null,n('":"')),f!==null?(h=dt(),h=h!==null?h:"",h!==null?(t=Tn(),t!==null?(o=qs(),o!==null?(u=ci(),u=u!==null?u:"",u!==null?r=[r,f,h,t,o,u]:(r=null,e=T)):(r=null,e=T)):(r=null,e=T)):(r=null,e=T)):(r=null,e=T)):(r=null,e=T),r!==null&&(r=function(E){try{b.uri=new hl(b.scheme,b.user,b.host,b.port,b.uri_params,b.uri_headers),delete b.scheme,delete b.user,delete b.host,delete b.host_type,delete b.port,delete b.uri_params,a==="SIP_URI"&&(b=b.uri)}catch{b=-1}}()),r===null&&(e=d),r}function We(){var r;return r=Fe(),r===null&&(r=Vt()),r}function Fe(){var r,f;return f=e,l.substr(e,4).toLowerCase()==="sips"?(r=l.substr(e,4),e+=4):(r=null,n('"sips"')),r!==null&&(r=function(h,t){b.scheme=t.toLowerCase()}(f,r)),r===null&&(e=f),r}function Vt(){var r,f;return f=e,l.substr(e,3).toLowerCase()==="sip"?(r=l.substr(e,3),e+=3):(r=null,n('"sip"')),r!==null&&(r=function(h,t){b.scheme=t.toLowerCase()}(f,r)),r===null&&(e=f),r}function dt(){var r,f,h,t,o,u;return t=e,o=e,r=ei(),r!==null?(u=e,l.charCodeAt(e)===58?(f=":",e++):(f=null,n('":"')),f!==null?(h=gn(),h!==null?f=[f,h]:(f=null,e=u)):(f=null,e=u),f=f!==null?f:"",f!==null?(l.charCodeAt(e)===64?(h="@",e++):(h=null,n('"@"')),h!==null?r=[r,f,h]:(r=null,e=o)):(r=null,e=o)):(r=null,e=o),r!==null&&(r=function(d){b.user=decodeURIComponent(l.substring(e-1,d))}(t)),r===null&&(e=t),r}function ei(){var r,f;if(f=$(),f===null&&(f=be(),f===null&&(f=Xn())),f!==null)for(r=[];f!==null;)r.push(f),f=$(),f===null&&(f=be(),f===null&&(f=Xn()));else r=null;return r}function Xn(){var r;return l.charCodeAt(e)===38?(r="&",e++):(r=null,n('"&"')),r===null&&(l.charCodeAt(e)===61?(r="=",e++):(r=null,n('"="')),r===null&&(l.charCodeAt(e)===43?(r="+",e++):(r=null,n('"+"')),r===null&&(l.charCodeAt(e)===36?(r="$",e++):(r=null,n('"$"')),r===null&&(l.charCodeAt(e)===44?(r=",",e++):(r=null,n('","')),r===null&&(l.charCodeAt(e)===59?(r=";",e++):(r=null,n('";"')),r===null&&(l.charCodeAt(e)===63?(r="?",e++):(r=null,n('"?"')),r===null&&(l.charCodeAt(e)===47?(r="/",e++):(r=null,n('"/"'))))))))),r}function gn(){var r,f,h;for(h=e,r=[],f=$(),f===null&&(f=be(),f===null&&(l.charCodeAt(e)===38?(f="&",e++):(f=null,n('"&"')),f===null&&(l.charCodeAt(e)===61?(f="=",e++):(f=null,n('"="')),f===null&&(l.charCodeAt(e)===43?(f="+",e++):(f=null,n('"+"')),f===null&&(l.charCodeAt(e)===36?(f="$",e++):(f=null,n('"$"')),f===null&&(l.charCodeAt(e)===44?(f=",",e++):(f=null,n('","'))))))));f!==null;)r.push(f),f=$(),f===null&&(f=be(),f===null&&(l.charCodeAt(e)===38?(f="&",e++):(f=null,n('"&"')),f===null&&(l.charCodeAt(e)===61?(f="=",e++):(f=null,n('"="')),f===null&&(l.charCodeAt(e)===43?(f="+",e++):(f=null,n('"+"')),f===null&&(l.charCodeAt(e)===36?(f="$",e++):(f=null,n('"$"')),f===null&&(l.charCodeAt(e)===44?(f=",",e++):(f=null,n('","'))))))));return r!==null&&(r=function(t){b.password=l.substring(e,t)}(h)),r===null&&(e=h),r}function Tn(){var r,f,h,t,o;return t=e,r=ys(),r!==null?(o=e,l.charCodeAt(e)===58?(f=":",e++):(f=null,n('":"')),f!==null?(h=Nt(),h!==null?f=[f,h]:(f=null,e=o)):(f=null,e=o),f=f!==null?f:"",f!==null?r=[r,f]:(r=null,e=t)):(r=null,e=t),r}function ys(){var r,f;return f=e,r=Qn(),r===null&&(r=As(),r===null&&(r=vn())),r!==null&&(r=function(h){return b.host=l.substring(e,h).toLowerCase(),b.host}(f)),r===null&&(e=f),r}function Qn(){var r,f,h,t,o,u;for(t=e,o=e,r=[],u=e,f=Fs(),f!==null?(l.charCodeAt(e)===46?(h=".",e++):(h=null,n('"."')),h!==null?f=[f,h]:(f=null,e=u)):(f=null,e=u);f!==null;)r.push(f),u=e,f=Fs(),f!==null?(l.charCodeAt(e)===46?(h=".",e++):(h=null,n('"."')),h!==null?f=[f,h]:(f=null,e=u)):(f=null,e=u);return r!==null?(f=js(),f!==null?(l.charCodeAt(e)===46?(h=".",e++):(h=null,n('"."')),h=h!==null?h:"",h!==null?r=[r,f,h]:(r=null,e=o)):(r=null,e=o)):(r=null,e=o),r!==null&&(r=function(d){return b.host_type="domain",l.substring(e,d)}(t)),r===null&&(e=t),r}function Fs(){var r,f,h,t;if(t=e,r=oe(),r!==null){for(f=[],h=oe(),h===null&&(l.charCodeAt(e)===45?(h="-",e++):(h=null,n('"-"')),h===null&&(l.charCodeAt(e)===95?(h="_",e++):(h=null,n('"_"'))));h!==null;)f.push(h),h=oe(),h===null&&(l.charCodeAt(e)===45?(h="-",e++):(h=null,n('"-"')),h===null&&(l.charCodeAt(e)===95?(h="_",e++):(h=null,n('"_"'))));f!==null?r=[r,f]:(r=null,e=t)}else r=null,e=t;return r}function js(){var r,f,h,t;if(t=e,r=m(),r!==null){for(f=[],h=oe(),h===null&&(l.charCodeAt(e)===45?(h="-",e++):(h=null,n('"-"')),h===null&&(l.charCodeAt(e)===95?(h="_",e++):(h=null,n('"_"'))));h!==null;)f.push(h),h=oe(),h===null&&(l.charCodeAt(e)===45?(h="-",e++):(h=null,n('"-"')),h===null&&(l.charCodeAt(e)===95?(h="_",e++):(h=null,n('"_"'))));f!==null?r=[r,f]:(r=null,e=t)}else r=null,e=t;return r}function vn(){var r,f,h,t,o;return t=e,o=e,l.charCodeAt(e)===91?(r="[",e++):(r=null,n('"["')),r!==null?(f=En(),f!==null?(l.charCodeAt(e)===93?(h="]",e++):(h=null,n('"]"')),h!==null?r=[r,f,h]:(r=null,e=o)):(r=null,e=o)):(r=null,e=o),r!==null&&(r=function(u){return b.host_type="IPv6",l.substring(e,u)}(t)),r===null&&(e=t),r}function En(){var r,f,h,t,o,u,d,T,E,y,O,G,ye,je,P,me;return je=e,P=e,r=ge(),r!==null?(l.charCodeAt(e)===58?(f=":",e++):(f=null,n('":"')),f!==null?(h=ge(),h!==null?(l.charCodeAt(e)===58?(t=":",e++):(t=null,n('":"')),t!==null?(o=ge(),o!==null?(l.charCodeAt(e)===58?(u=":",e++):(u=null,n('":"')),u!==null?(d=ge(),d!==null?(l.charCodeAt(e)===58?(T=":",e++):(T=null,n('":"')),T!==null?(E=ge(),E!==null?(l.charCodeAt(e)===58?(y=":",e++):(y=null,n('":"')),y!==null?(O=ge(),O!==null?(l.charCodeAt(e)===58?(G=":",e++):(G=null,n('":"')),G!==null?(ye=Rt(),ye!==null?r=[r,f,h,t,o,u,d,T,E,y,O,G,ye]:(r=null,e=P)):(r=null,e=P)):(r=null,e=P)):(r=null,e=P)):(r=null,e=P)):(r=null,e=P)):(r=null,e=P)):(r=null,e=P)):(r=null,e=P)):(r=null,e=P)):(r=null,e=P)):(r=null,e=P)):(r=null,e=P),r===null&&(P=e,l.substr(e,2)==="::"?(r="::",e+=2):(r=null,n('"::"')),r!==null?(f=ge(),f!==null?(l.charCodeAt(e)===58?(h=":",e++):(h=null,n('":"')),h!==null?(t=ge(),t!==null?(l.charCodeAt(e)===58?(o=":",e++):(o=null,n('":"')),o!==null?(u=ge(),u!==null?(l.charCodeAt(e)===58?(d=":",e++):(d=null,n('":"')),d!==null?(T=ge(),T!==null?(l.charCodeAt(e)===58?(E=":",e++):(E=null,n('":"')),E!==null?(y=ge(),y!==null?(l.charCodeAt(e)===58?(O=":",e++):(O=null,n('":"')),O!==null?(G=Rt(),G!==null?r=[r,f,h,t,o,u,d,T,E,y,O,G]:(r=null,e=P)):(r=null,e=P)):(r=null,e=P)):(r=null,e=P)):(r=null,e=P)):(r=null,e=P)):(r=null,e=P)):(r=null,e=P)):(r=null,e=P)):(r=null,e=P)):(r=null,e=P)):(r=null,e=P),r===null&&(P=e,l.substr(e,2)==="::"?(r="::",e+=2):(r=null,n('"::"')),r!==null?(f=ge(),f!==null?(l.charCodeAt(e)===58?(h=":",e++):(h=null,n('":"')),h!==null?(t=ge(),t!==null?(l.charCodeAt(e)===58?(o=":",e++):(o=null,n('":"')),o!==null?(u=ge(),u!==null?(l.charCodeAt(e)===58?(d=":",e++):(d=null,n('":"')),d!==null?(T=ge(),T!==null?(l.charCodeAt(e)===58?(E=":",e++):(E=null,n('":"')),E!==null?(y=Rt(),y!==null?r=[r,f,h,t,o,u,d,T,E,y]:(r=null,e=P)):(r=null,e=P)):(r=null,e=P)):(r=null,e=P)):(r=null,e=P)):(r=null,e=P)):(r=null,e=P)):(r=null,e=P)):(r=null,e=P)):(r=null,e=P),r===null&&(P=e,l.substr(e,2)==="::"?(r="::",e+=2):(r=null,n('"::"')),r!==null?(f=ge(),f!==null?(l.charCodeAt(e)===58?(h=":",e++):(h=null,n('":"')),h!==null?(t=ge(),t!==null?(l.charCodeAt(e)===58?(o=":",e++):(o=null,n('":"')),o!==null?(u=ge(),u!==null?(l.charCodeAt(e)===58?(d=":",e++):(d=null,n('":"')),d!==null?(T=Rt(),T!==null?r=[r,f,h,t,o,u,d,T]:(r=null,e=P)):(r=null,e=P)):(r=null,e=P)):(r=null,e=P)):(r=null,e=P)):(r=null,e=P)):(r=null,e=P)):(r=null,e=P),r===null&&(P=e,l.substr(e,2)==="::"?(r="::",e+=2):(r=null,n('"::"')),r!==null?(f=ge(),f!==null?(l.charCodeAt(e)===58?(h=":",e++):(h=null,n('":"')),h!==null?(t=ge(),t!==null?(l.charCodeAt(e)===58?(o=":",e++):(o=null,n('":"')),o!==null?(u=Rt(),u!==null?r=[r,f,h,t,o,u]:(r=null,e=P)):(r=null,e=P)):(r=null,e=P)):(r=null,e=P)):(r=null,e=P)):(r=null,e=P),r===null&&(P=e,l.substr(e,2)==="::"?(r="::",e+=2):(r=null,n('"::"')),r!==null?(f=ge(),f!==null?(l.charCodeAt(e)===58?(h=":",e++):(h=null,n('":"')),h!==null?(t=Rt(),t!==null?r=[r,f,h,t]:(r=null,e=P)):(r=null,e=P)):(r=null,e=P)):(r=null,e=P),r===null&&(P=e,l.substr(e,2)==="::"?(r="::",e+=2):(r=null,n('"::"')),r!==null?(f=Rt(),f!==null?r=[r,f]:(r=null,e=P)):(r=null,e=P),r===null&&(P=e,l.substr(e,2)==="::"?(r="::",e+=2):(r=null,n('"::"')),r!==null?(f=ge(),f!==null?r=[r,f]:(r=null,e=P)):(r=null,e=P),r===null&&(P=e,r=ge(),r!==null?(l.substr(e,2)==="::"?(f="::",e+=2):(f=null,n('"::"')),f!==null?(h=ge(),h!==null?(l.charCodeAt(e)===58?(t=":",e++):(t=null,n('":"')),t!==null?(o=ge(),o!==null?(l.charCodeAt(e)===58?(u=":",e++):(u=null,n('":"')),u!==null?(d=ge(),d!==null?(l.charCodeAt(e)===58?(T=":",e++):(T=null,n('":"')),T!==null?(E=ge(),E!==null?(l.charCodeAt(e)===58?(y=":",e++):(y=null,n('":"')),y!==null?(O=Rt(),O!==null?r=[r,f,h,t,o,u,d,T,E,y,O]:(r=null,e=P)):(r=null,e=P)):(r=null,e=P)):(r=null,e=P)):(r=null,e=P)):(r=null,e=P)):(r=null,e=P)):(r=null,e=P)):(r=null,e=P)):(r=null,e=P)):(r=null,e=P),r===null&&(P=e,r=ge(),r!==null?(me=e,l.charCodeAt(e)===58?(f=":",e++):(f=null,n('":"')),f!==null?(h=ge(),h!==null?f=[f,h]:(f=null,e=me)):(f=null,e=me),f=f!==null?f:"",f!==null?(l.substr(e,2)==="::"?(h="::",e+=2):(h=null,n('"::"')),h!==null?(t=ge(),t!==null?(l.charCodeAt(e)===58?(o=":",e++):(o=null,n('":"')),o!==null?(u=ge(),u!==null?(l.charCodeAt(e)===58?(d=":",e++):(d=null,n('":"')),d!==null?(T=ge(),T!==null?(l.charCodeAt(e)===58?(E=":",e++):(E=null,n('":"')),E!==null?(y=Rt(),y!==null?r=[r,f,h,t,o,u,d,T,E,y]:(r=null,e=P)):(r=null,e=P)):(r=null,e=P)):(r=null,e=P)):(r=null,e=P)):(r=null,e=P)):(r=null,e=P)):(r=null,e=P)):(r=null,e=P)):(r=null,e=P),r===null&&(P=e,r=ge(),r!==null?(me=e,l.charCodeAt(e)===58?(f=":",e++):(f=null,n('":"')),f!==null?(h=ge(),h!==null?f=[f,h]:(f=null,e=me)):(f=null,e=me),f=f!==null?f:"",f!==null?(me=e,l.charCodeAt(e)===58?(h=":",e++):(h=null,n('":"')),h!==null?(t=ge(),t!==null?h=[h,t]:(h=null,e=me)):(h=null,e=me),h=h!==null?h:"",h!==null?(l.substr(e,2)==="::"?(t="::",e+=2):(t=null,n('"::"')),t!==null?(o=ge(),o!==null?(l.charCodeAt(e)===58?(u=":",e++):(u=null,n('":"')),u!==null?(d=ge(),d!==null?(l.charCodeAt(e)===58?(T=":",e++):(T=null,n('":"')),T!==null?(E=Rt(),E!==null?r=[r,f,h,t,o,u,d,T,E]:(r=null,e=P)):(r=null,e=P)):(r=null,e=P)):(r=null,e=P)):(r=null,e=P)):(r=null,e=P)):(r=null,e=P)):(r=null,e=P)):(r=null,e=P),r===null&&(P=e,r=ge(),r!==null?(me=e,l.charCodeAt(e)===58?(f=":",e++):(f=null,n('":"')),f!==null?(h=ge(),h!==null?f=[f,h]:(f=null,e=me)):(f=null,e=me),f=f!==null?f:"",f!==null?(me=e,l.charCodeAt(e)===58?(h=":",e++):(h=null,n('":"')),h!==null?(t=ge(),t!==null?h=[h,t]:(h=null,e=me)):(h=null,e=me),h=h!==null?h:"",h!==null?(me=e,l.charCodeAt(e)===58?(t=":",e++):(t=null,n('":"')),t!==null?(o=ge(),o!==null?t=[t,o]:(t=null,e=me)):(t=null,e=me),t=t!==null?t:"",t!==null?(l.substr(e,2)==="::"?(o="::",e+=2):(o=null,n('"::"')),o!==null?(u=ge(),u!==null?(l.charCodeAt(e)===58?(d=":",e++):(d=null,n('":"')),d!==null?(T=Rt(),T!==null?r=[r,f,h,t,o,u,d,T]:(r=null,e=P)):(r=null,e=P)):(r=null,e=P)):(r=null,e=P)):(r=null,e=P)):(r=null,e=P)):(r=null,e=P)):(r=null,e=P),r===null&&(P=e,r=ge(),r!==null?(me=e,l.charCodeAt(e)===58?(f=":",e++):(f=null,n('":"')),f!==null?(h=ge(),h!==null?f=[f,h]:(f=null,e=me)):(f=null,e=me),f=f!==null?f:"",f!==null?(me=e,l.charCodeAt(e)===58?(h=":",e++):(h=null,n('":"')),h!==null?(t=ge(),t!==null?h=[h,t]:(h=null,e=me)):(h=null,e=me),h=h!==null?h:"",h!==null?(me=e,l.charCodeAt(e)===58?(t=":",e++):(t=null,n('":"')),t!==null?(o=ge(),o!==null?t=[t,o]:(t=null,e=me)):(t=null,e=me),t=t!==null?t:"",t!==null?(me=e,l.charCodeAt(e)===58?(o=":",e++):(o=null,n('":"')),o!==null?(u=ge(),u!==null?o=[o,u]:(o=null,e=me)):(o=null,e=me),o=o!==null?o:"",o!==null?(l.substr(e,2)==="::"?(u="::",e+=2):(u=null,n('"::"')),u!==null?(d=Rt(),d!==null?r=[r,f,h,t,o,u,d]:(r=null,e=P)):(r=null,e=P)):(r=null,e=P)):(r=null,e=P)):(r=null,e=P)):(r=null,e=P)):(r=null,e=P),r===null&&(P=e,r=ge(),r!==null?(me=e,l.charCodeAt(e)===58?(f=":",e++):(f=null,n('":"')),f!==null?(h=ge(),h!==null?f=[f,h]:(f=null,e=me)):(f=null,e=me),f=f!==null?f:"",f!==null?(me=e,l.charCodeAt(e)===58?(h=":",e++):(h=null,n('":"')),h!==null?(t=ge(),t!==null?h=[h,t]:(h=null,e=me)):(h=null,e=me),h=h!==null?h:"",h!==null?(me=e,l.charCodeAt(e)===58?(t=":",e++):(t=null,n('":"')),t!==null?(o=ge(),o!==null?t=[t,o]:(t=null,e=me)):(t=null,e=me),t=t!==null?t:"",t!==null?(me=e,l.charCodeAt(e)===58?(o=":",e++):(o=null,n('":"')),o!==null?(u=ge(),u!==null?o=[o,u]:(o=null,e=me)):(o=null,e=me),o=o!==null?o:"",o!==null?(me=e,l.charCodeAt(e)===58?(u=":",e++):(u=null,n('":"')),u!==null?(d=ge(),d!==null?u=[u,d]:(u=null,e=me)):(u=null,e=me),u=u!==null?u:"",u!==null?(l.substr(e,2)==="::"?(d="::",e+=2):(d=null,n('"::"')),d!==null?(T=ge(),T!==null?r=[r,f,h,t,o,u,d,T]:(r=null,e=P)):(r=null,e=P)):(r=null,e=P)):(r=null,e=P)):(r=null,e=P)):(r=null,e=P)):(r=null,e=P)):(r=null,e=P),r===null&&(P=e,r=ge(),r!==null?(me=e,l.charCodeAt(e)===58?(f=":",e++):(f=null,n('":"')),f!==null?(h=ge(),h!==null?f=[f,h]:(f=null,e=me)):(f=null,e=me),f=f!==null?f:"",f!==null?(me=e,l.charCodeAt(e)===58?(h=":",e++):(h=null,n('":"')),h!==null?(t=ge(),t!==null?h=[h,t]:(h=null,e=me)):(h=null,e=me),h=h!==null?h:"",h!==null?(me=e,l.charCodeAt(e)===58?(t=":",e++):(t=null,n('":"')),t!==null?(o=ge(),o!==null?t=[t,o]:(t=null,e=me)):(t=null,e=me),t=t!==null?t:"",t!==null?(me=e,l.charCodeAt(e)===58?(o=":",e++):(o=null,n('":"')),o!==null?(u=ge(),u!==null?o=[o,u]:(o=null,e=me)):(o=null,e=me),o=o!==null?o:"",o!==null?(me=e,l.charCodeAt(e)===58?(u=":",e++):(u=null,n('":"')),u!==null?(d=ge(),d!==null?u=[u,d]:(u=null,e=me)):(u=null,e=me),u=u!==null?u:"",u!==null?(me=e,l.charCodeAt(e)===58?(d=":",e++):(d=null,n('":"')),d!==null?(T=ge(),T!==null?d=[d,T]:(d=null,e=me)):(d=null,e=me),d=d!==null?d:"",d!==null?(l.substr(e,2)==="::"?(T="::",e+=2):(T=null,n('"::"')),T!==null?r=[r,f,h,t,o,u,d,T]:(r=null,e=P)):(r=null,e=P)):(r=null,e=P)):(r=null,e=P)):(r=null,e=P)):(r=null,e=P)):(r=null,e=P)):(r=null,e=P))))))))))))))),r!==null&&(r=function(dl){return b.host_type="IPv6",l.substring(e,dl)}(je)),r===null&&(e=je),r}function ge(){var r,f,h,t,o;return o=e,r=C(),r!==null?(f=C(),f=f!==null?f:"",f!==null?(h=C(),h=h!==null?h:"",h!==null?(t=C(),t=t!==null?t:"",t!==null?r=[r,f,h,t]:(r=null,e=o)):(r=null,e=o)):(r=null,e=o)):(r=null,e=o),r}function Rt(){var r,f,h,t;return t=e,r=ge(),r!==null?(l.charCodeAt(e)===58?(f=":",e++):(f=null,n('":"')),f!==null?(h=ge(),h!==null?r=[r,f,h]:(r=null,e=t)):(r=null,e=t)):(r=null,e=t),r===null&&(r=As()),r}function As(){var r,f,h,t,o,u,d,T,E;return T=e,E=e,r=de(),r!==null?(l.charCodeAt(e)===46?(f=".",e++):(f=null,n('"."')),f!==null?(h=de(),h!==null?(l.charCodeAt(e)===46?(t=".",e++):(t=null,n('"."')),t!==null?(o=de(),o!==null?(l.charCodeAt(e)===46?(u=".",e++):(u=null,n('"."')),u!==null?(d=de(),d!==null?r=[r,f,h,t,o,u,d]:(r=null,e=E)):(r=null,e=E)):(r=null,e=E)):(r=null,e=E)):(r=null,e=E)):(r=null,e=E)):(r=null,e=E),r!==null&&(r=function(y){return b.host_type="IPv4",l.substring(e,y)}(T)),r===null&&(e=T),r}function de(){var r,f,h,t;return t=e,l.substr(e,2)==="25"?(r="25",e+=2):(r=null,n('"25"')),r!==null?(/^[0-5]/.test(l.charAt(e))?(f=l.charAt(e),e++):(f=null,n("[0-5]")),f!==null?r=[r,f]:(r=null,e=t)):(r=null,e=t),r===null&&(t=e,l.charCodeAt(e)===50?(r="2",e++):(r=null,n('"2"')),r!==null?(/^[0-4]/.test(l.charAt(e))?(f=l.charAt(e),e++):(f=null,n("[0-4]")),f!==null?(h=S(),h!==null?r=[r,f,h]:(r=null,e=t)):(r=null,e=t)):(r=null,e=t),r===null&&(t=e,l.charCodeAt(e)===49?(r="1",e++):(r=null,n('"1"')),r!==null?(f=S(),f!==null?(h=S(),h!==null?r=[r,f,h]:(r=null,e=t)):(r=null,e=t)):(r=null,e=t),r===null&&(t=e,/^[1-9]/.test(l.charAt(e))?(r=l.charAt(e),e++):(r=null,n("[1-9]")),r!==null?(f=S(),f!==null?r=[r,f]:(r=null,e=t)):(r=null,e=t),r===null&&(r=S())))),r}function Nt(){var r,f,h,t,o,u,d;return u=e,d=e,r=S(),r=r!==null?r:"",r!==null?(f=S(),f=f!==null?f:"",f!==null?(h=S(),h=h!==null?h:"",h!==null?(t=S(),t=t!==null?t:"",t!==null?(o=S(),o=o!==null?o:"",o!==null?r=[r,f,h,t,o]:(r=null,e=d)):(r=null,e=d)):(r=null,e=d)):(r=null,e=d)):(r=null,e=d),r!==null&&(r=function(T,E){return E=parseInt(E.join("")),b.port=E,E}(u,r)),r===null&&(e=u),r}function qs(){var r,f,h,t;for(r=[],t=e,l.charCodeAt(e)===59?(f=";",e++):(f=null,n('";"')),f!==null?(h=Cs(),h!==null?f=[f,h]:(f=null,e=t)):(f=null,e=t);f!==null;)r.push(f),t=e,l.charCodeAt(e)===59?(f=";",e++):(f=null,n('";"')),f!==null?(h=Cs(),h!==null?f=[f,h]:(f=null,e=t)):(f=null,e=t);return r}function Cs(){var r;return r=ti(),r===null&&(r=si(),r===null&&(r=Zn(),r===null&&(r=ni(),r===null&&(r=ri(),r===null&&(r=ii(),r===null&&(r=li())))))),r}function ti(){var r,f,h,t;return h=e,t=e,l.substr(e,10).toLowerCase()==="transport="?(r=l.substr(e,10),e+=10):(r=null,n('"transport="')),r!==null?(l.substr(e,3).toLowerCase()==="udp"?(f=l.substr(e,3),e+=3):(f=null,n('"udp"')),f===null&&(l.substr(e,3).toLowerCase()==="tcp"?(f=l.substr(e,3),e+=3):(f=null,n('"tcp"')),f===null&&(l.substr(e,4).toLowerCase()==="sctp"?(f=l.substr(e,4),e+=4):(f=null,n('"sctp"')),f===null&&(l.substr(e,3).toLowerCase()==="tls"?(f=l.substr(e,3),e+=3):(f=null,n('"tls"')),f===null&&(f=U())))),f!==null?r=[r,f]:(r=null,e=t)):(r=null,e=t),r!==null&&(r=function(o,u){b.uri_params||(b.uri_params={}),b.uri_params.transport=u.toLowerCase()}(h,r[1])),r===null&&(e=h),r}function si(){var r,f,h,t;return h=e,t=e,l.substr(e,5).toLowerCase()==="user="?(r=l.substr(e,5),e+=5):(r=null,n('"user="')),r!==null?(l.substr(e,5).toLowerCase()==="phone"?(f=l.substr(e,5),e+=5):(f=null,n('"phone"')),f===null&&(l.substr(e,2).toLowerCase()==="ip"?(f=l.substr(e,2),e+=2):(f=null,n('"ip"')),f===null&&(f=U())),f!==null?r=[r,f]:(r=null,e=t)):(r=null,e=t),r!==null&&(r=function(o,u){b.uri_params||(b.uri_params={}),b.uri_params.user=u.toLowerCase()}(h,r[1])),r===null&&(e=h),r}function Zn(){var r,f,h,t;return h=e,t=e,l.substr(e,7).toLowerCase()==="method="?(r=l.substr(e,7),e+=7):(r=null,n('"method="')),r!==null?(f=An(),f!==null?r=[r,f]:(r=null,e=t)):(r=null,e=t),r!==null&&(r=function(o,u){b.uri_params||(b.uri_params={}),b.uri_params.method=u}(h,r[1])),r===null&&(e=h),r}function ni(){var r,f,h,t;return h=e,t=e,l.substr(e,4).toLowerCase()==="ttl="?(r=l.substr(e,4),e+=4):(r=null,n('"ttl="')),r!==null?(f=cr(),f!==null?r=[r,f]:(r=null,e=t)):(r=null,e=t),r!==null&&(r=function(o,u){b.params||(b.params={}),b.params.ttl=u}(h,r[1])),r===null&&(e=h),r}function ri(){var r,f,h,t;return h=e,t=e,l.substr(e,6).toLowerCase()==="maddr="?(r=l.substr(e,6),e+=6):(r=null,n('"maddr="')),r!==null?(f=ys(),f!==null?r=[r,f]:(r=null,e=t)):(r=null,e=t),r!==null&&(r=function(o,u){b.uri_params||(b.uri_params={}),b.uri_params.maddr=u}(h,r[1])),r===null&&(e=h),r}function ii(){var r,f,h,t,o,u;return t=e,o=e,l.substr(e,2).toLowerCase()==="lr"?(r=l.substr(e,2),e+=2):(r=null,n('"lr"')),r!==null?(u=e,l.charCodeAt(e)===61?(f="=",e++):(f=null,n('"="')),f!==null?(h=U(),h!==null?f=[f,h]:(f=null,e=u)):(f=null,e=u),f=f!==null?f:"",f!==null?r=[r,f]:(r=null,e=o)):(r=null,e=o),r!==null&&(r=function(d){b.uri_params||(b.uri_params={}),b.uri_params.lr=void 0}()),r===null&&(e=t),r}function li(){var r,f,h,t,o,u;return t=e,o=e,r=ai(),r!==null?(u=e,l.charCodeAt(e)===61?(f="=",e++):(f=null,n('"="')),f!==null?(h=oi(),h!==null?f=[f,h]:(f=null,e=u)):(f=null,e=u),f=f!==null?f:"",f!==null?r=[r,f]:(r=null,e=o)):(r=null,e=o),r!==null&&(r=function(d,T,E){b.uri_params||(b.uri_params={}),typeof E>"u"?E=void 0:E=E[1],b.uri_params[T.toLowerCase()]=E}(t,r[0],r[1])),r===null&&(e=t),r}function ai(){var r,f,h;if(h=e,f=Vs(),f!==null)for(r=[];f!==null;)r.push(f),f=Vs();else r=null;return r!==null&&(r=function(t,o){return o.join("")}(h,r)),r===null&&(e=h),r}function oi(){var r,f,h;if(h=e,f=Vs(),f!==null)for(r=[];f!==null;)r.push(f),f=Vs();else r=null;return r!==null&&(r=function(t,o){return o.join("")}(h,r)),r===null&&(e=h),r}function Vs(){var r;return r=ui(),r===null&&(r=$(),r===null&&(r=be())),r}function ui(){var r;return l.charCodeAt(e)===91?(r="[",e++):(r=null,n('"["')),r===null&&(l.charCodeAt(e)===93?(r="]",e++):(r=null,n('"]"')),r===null&&(l.charCodeAt(e)===47?(r="/",e++):(r=null,n('"/"')),r===null&&(l.charCodeAt(e)===58?(r=":",e++):(r=null,n('":"')),r===null&&(l.charCodeAt(e)===38?(r="&",e++):(r=null,n('"&"')),r===null&&(l.charCodeAt(e)===43?(r="+",e++):(r=null,n('"+"')),r===null&&(l.charCodeAt(e)===36?(r="$",e++):(r=null,n('"$"')))))))),r}function ci(){var r,f,h,t,o,u,d;if(u=e,l.charCodeAt(e)===63?(r="?",e++):(r=null,n('"?"')),r!==null)if(f=rs(),f!==null){for(h=[],d=e,l.charCodeAt(e)===38?(t="&",e++):(t=null,n('"&"')),t!==null?(o=rs(),o!==null?t=[t,o]:(t=null,e=d)):(t=null,e=d);t!==null;)h.push(t),d=e,l.charCodeAt(e)===38?(t="&",e++):(t=null,n('"&"')),t!==null?(o=rs(),o!==null?t=[t,o]:(t=null,e=d)):(t=null,e=d);h!==null?r=[r,f,h]:(r=null,e=u)}else r=null,e=u;else r=null,e=u;return r}function rs(){var r,f,h,t,o;return t=e,o=e,r=fi(),r!==null?(l.charCodeAt(e)===61?(f="=",e++):(f=null,n('"="')),f!==null?(h=_i(),h!==null?r=[r,f,h]:(r=null,e=o)):(r=null,e=o)):(r=null,e=o),r!==null&&(r=function(u,d,T){d=d.join("").toLowerCase(),T=T.join(""),b.uri_headers||(b.uri_headers={}),b.uri_headers[d]?b.uri_headers[d].push(T):b.uri_headers[d]=[T]}(t,r[0],r[2])),r===null&&(e=t),r}function fi(){var r,f;if(f=is(),f===null&&(f=$(),f===null&&(f=be())),f!==null)for(r=[];f!==null;)r.push(f),f=is(),f===null&&(f=$(),f===null&&(f=be()));else r=null;return r}function _i(){var r,f;for(r=[],f=is(),f===null&&(f=$(),f===null&&(f=be()));f!==null;)r.push(f),f=is(),f===null&&(f=$(),f===null&&(f=be()));return r}function is(){var r;return l.charCodeAt(e)===91?(r="[",e++):(r=null,n('"["')),r===null&&(l.charCodeAt(e)===93?(r="]",e++):(r=null,n('"]"')),r===null&&(l.charCodeAt(e)===47?(r="/",e++):(r=null,n('"/"')),r===null&&(l.charCodeAt(e)===63?(r="?",e++):(r=null,n('"?"')),r===null&&(l.charCodeAt(e)===58?(r=":",e++):(r=null,n('":"')),r===null&&(l.charCodeAt(e)===43?(r="+",e++):(r=null,n('"+"')),r===null&&(l.charCodeAt(e)===36?(r="$",e++):(r=null,n('"$"')))))))),r}function Ra(){var r;return r=Oi(),r===null&&(r=hi()),r}function hi(){var r,f,h,t,o,u;return u=e,r=An(),r!==null?(f=V(),f!==null?(h=Bs(),h!==null?(t=V(),t!==null?(o=sr(),o!==null?r=[r,f,h,t,o]:(r=null,e=u)):(r=null,e=u)):(r=null,e=u)):(r=null,e=u)):(r=null,e=u),r}function Bs(){var r;return r=Me(),r===null&&(r=di()),r}function di(){var r,f,h,t;return t=e,r=yn(),r!==null?(l.charCodeAt(e)===58?(f=":",e++):(f=null,n('":"')),f!==null?(h=pi(),h===null&&(h=gi()),h!==null?r=[r,f,h]:(r=null,e=t)):(r=null,e=t)):(r=null,e=t),r}function pi(){var r,f,h,t,o;return t=e,r=mi(),r===null&&(r=Gs()),r!==null?(o=e,l.charCodeAt(e)===63?(f="?",e++):(f=null,n('"?"')),f!==null?(h=Ei(),h!==null?f=[f,h]:(f=null,e=o)):(f=null,e=o),f=f!==null?f:"",f!==null?r=[r,f]:(r=null,e=t)):(r=null,e=t),r}function mi(){var r,f,h,t;return t=e,l.substr(e,2)==="//"?(r="//",e+=2):(r=null,n('"//"')),r!==null?(f=tr(),f!==null?(h=Gs(),h=h!==null?h:"",h!==null?r=[r,f,h]:(r=null,e=t)):(r=null,e=t)):(r=null,e=t),r}function Gs(){var r,f,h;return h=e,l.charCodeAt(e)===47?(r="/",e++):(r=null,n('"/"')),r!==null?(f=Ti(),f!==null?r=[r,f]:(r=null,e=h)):(r=null,e=h),r}function gi(){var r,f,h,t;if(t=e,r=Sn(),r!==null){for(f=[],h=Ws();h!==null;)f.push(h),h=Ws();f!==null?r=[r,f]:(r=null,e=t)}else r=null,e=t;return r}function Ws(){var r;return r=x(),r===null&&(r=$(),r===null&&(r=be())),r}function Sn(){var r;return r=$(),r===null&&(r=be(),r===null&&(l.charCodeAt(e)===59?(r=";",e++):(r=null,n('";"')),r===null&&(l.charCodeAt(e)===63?(r="?",e++):(r=null,n('"?"')),r===null&&(l.charCodeAt(e)===58?(r=":",e++):(r=null,n('":"')),r===null&&(l.charCodeAt(e)===64?(r="@",e++):(r=null,n('"@"')),r===null&&(l.charCodeAt(e)===38?(r="&",e++):(r=null,n('"&"')),r===null&&(l.charCodeAt(e)===61?(r="=",e++):(r=null,n('"="')),r===null&&(l.charCodeAt(e)===43?(r="+",e++):(r=null,n('"+"')),r===null&&(l.charCodeAt(e)===36?(r="$",e++):(r=null,n('"$"')),r===null&&(l.charCodeAt(e)===44?(r=",",e++):(r=null,n('","')))))))))))),r}function Ti(){var r,f,h,t,o,u;if(o=e,r=ls(),r!==null){for(f=[],u=e,l.charCodeAt(e)===47?(h="/",e++):(h=null,n('"/"')),h!==null?(t=ls(),t!==null?h=[h,t]:(h=null,e=u)):(h=null,e=u);h!==null;)f.push(h),u=e,l.charCodeAt(e)===47?(h="/",e++):(h=null,n('"/"')),h!==null?(t=ls(),t!==null?h=[h,t]:(h=null,e=u)):(h=null,e=u);f!==null?r=[r,f]:(r=null,e=o)}else r=null,e=o;return r}function ls(){var r,f,h,t,o,u;for(o=e,r=[],f=Ks();f!==null;)r.push(f),f=Ks();if(r!==null){for(f=[],u=e,l.charCodeAt(e)===59?(h=";",e++):(h=null,n('";"')),h!==null?(t=er(),t!==null?h=[h,t]:(h=null,e=u)):(h=null,e=u);h!==null;)f.push(h),u=e,l.charCodeAt(e)===59?(h=";",e++):(h=null,n('";"')),h!==null?(t=er(),t!==null?h=[h,t]:(h=null,e=u)):(h=null,e=u);f!==null?r=[r,f]:(r=null,e=o)}else r=null,e=o;return r}function er(){var r,f;for(r=[],f=Ks();f!==null;)r.push(f),f=Ks();return r}function Ks(){var r;return r=$(),r===null&&(r=be(),r===null&&(l.charCodeAt(e)===58?(r=":",e++):(r=null,n('":"')),r===null&&(l.charCodeAt(e)===64?(r="@",e++):(r=null,n('"@"')),r===null&&(l.charCodeAt(e)===38?(r="&",e++):(r=null,n('"&"')),r===null&&(l.charCodeAt(e)===61?(r="=",e++):(r=null,n('"="')),r===null&&(l.charCodeAt(e)===43?(r="+",e++):(r=null,n('"+"')),r===null&&(l.charCodeAt(e)===36?(r="$",e++):(r=null,n('"$"')),r===null&&(l.charCodeAt(e)===44?(r=",",e++):(r=null,n('","')))))))))),r}function yn(){var r,f,h,t,o;if(t=e,o=e,r=m(),r!==null){for(f=[],h=m(),h===null&&(h=S(),h===null&&(l.charCodeAt(e)===43?(h="+",e++):(h=null,n('"+"')),h===null&&(l.charCodeAt(e)===45?(h="-",e++):(h=null,n('"-"')),h===null&&(l.charCodeAt(e)===46?(h=".",e++):(h=null,n('"."'))))));h!==null;)f.push(h),h=m(),h===null&&(h=S(),h===null&&(l.charCodeAt(e)===43?(h="+",e++):(h=null,n('"+"')),h===null&&(l.charCodeAt(e)===45?(h="-",e++):(h=null,n('"-"')),h===null&&(l.charCodeAt(e)===46?(h=".",e++):(h=null,n('"."'))))));f!==null?r=[r,f]:(r=null,e=o)}else r=null,e=o;return r!==null&&(r=function(u){b.scheme=l.substring(e,u)}(t)),r===null&&(e=t),r}function tr(){var r;return r=Ys(),r===null&&(r=vi()),r}function Ys(){var r,f,h,t;return h=e,t=e,r=dt(),r!==null?(l.charCodeAt(e)===64?(f="@",e++):(f=null,n('"@"')),f!==null?r=[r,f]:(r=null,e=t)):(r=null,e=t),r=r!==null?r:"",r!==null?(f=Tn(),f!==null?r=[r,f]:(r=null,e=h)):(r=null,e=h),r=r!==null?r:"",r}function vi(){var r,f;if(f=$(),f===null&&(f=be(),f===null&&(l.charCodeAt(e)===36?(f="$",e++):(f=null,n('"$"')),f===null&&(l.charCodeAt(e)===44?(f=",",e++):(f=null,n('","')),f===null&&(l.charCodeAt(e)===59?(f=";",e++):(f=null,n('";"')),f===null&&(l.charCodeAt(e)===58?(f=":",e++):(f=null,n('":"')),f===null&&(l.charCodeAt(e)===64?(f="@",e++):(f=null,n('"@"')),f===null&&(l.charCodeAt(e)===38?(f="&",e++):(f=null,n('"&"')),f===null&&(l.charCodeAt(e)===61?(f="=",e++):(f=null,n('"="')),f===null&&(l.charCodeAt(e)===43?(f="+",e++):(f=null,n('"+"'))))))))))),f!==null)for(r=[];f!==null;)r.push(f),f=$(),f===null&&(f=be(),f===null&&(l.charCodeAt(e)===36?(f="$",e++):(f=null,n('"$"')),f===null&&(l.charCodeAt(e)===44?(f=",",e++):(f=null,n('","')),f===null&&(l.charCodeAt(e)===59?(f=";",e++):(f=null,n('";"')),f===null&&(l.charCodeAt(e)===58?(f=":",e++):(f=null,n('":"')),f===null&&(l.charCodeAt(e)===64?(f="@",e++):(f=null,n('"@"')),f===null&&(l.charCodeAt(e)===38?(f="&",e++):(f=null,n('"&"')),f===null&&(l.charCodeAt(e)===61?(f="=",e++):(f=null,n('"="')),f===null&&(l.charCodeAt(e)===43?(f="+",e++):(f=null,n('"+"')))))))))));else r=null;return r}function Ei(){var r,f;for(r=[],f=Ws();f!==null;)r.push(f),f=Ws();return r}function sr(){var r,f,h,t,o,u,d,T;if(d=e,T=e,l.substr(e,3).toLowerCase()==="sip"?(r=l.substr(e,3),e+=3):(r=null,n('"SIP"')),r!==null)if(l.charCodeAt(e)===47?(f="/",e++):(f=null,n('"/"')),f!==null){if(t=S(),t!==null)for(h=[];t!==null;)h.push(t),t=S();else h=null;if(h!==null)if(l.charCodeAt(e)===46?(t=".",e++):(t=null,n('"."')),t!==null){if(u=S(),u!==null)for(o=[];u!==null;)o.push(u),u=S();else o=null;o!==null?r=[r,f,h,t,o]:(r=null,e=T)}else r=null,e=T;else r=null,e=T}else r=null,e=T;else r=null,e=T;return r!==null&&(r=function(E){b.sip_version=l.substring(e,E)}(d)),r===null&&(e=d),r}function Si(){var r;return l.substr(e,6)==="INVITE"?(r="INVITE",e+=6):(r=null,n('"INVITE"')),r}function yi(){var r;return l.substr(e,3)==="ACK"?(r="ACK",e+=3):(r=null,n('"ACK"')),r}function nr(){var r;return l.substr(e,7)==="OPTIONS"?(r="OPTIONS",e+=7):(r=null,n('"OPTIONS"')),r}function Ai(){var r;return l.substr(e,3)==="BYE"?(r="BYE",e+=3):(r=null,n('"BYE"')),r}function Ci(){var r;return l.substr(e,6)==="CANCEL"?(r="CANCEL",e+=6):(r=null,n('"CANCEL"')),r}function Ri(){var r;return l.substr(e,8)==="REGISTER"?(r="REGISTER",e+=8):(r=null,n('"REGISTER"')),r}function Ii(){var r;return l.substr(e,9)==="SUBSCRIBE"?(r="SUBSCRIBE",e+=9):(r=null,n('"SUBSCRIBE"')),r}function bi(){var r;return l.substr(e,6)==="NOTIFY"?(r="NOTIFY",e+=6):(r=null,n('"NOTIFY"')),r}function wi(){var r;return l.substr(e,5)==="REFER"?(r="REFER",e+=5):(r=null,n('"REFER"')),r}function An(){var r,f;return f=e,r=Si(),r===null&&(r=yi(),r===null&&(r=nr(),r===null&&(r=Ai(),r===null&&(r=Ci(),r===null&&(r=Ri(),r===null&&(r=Ii(),r===null&&(r=bi(),r===null&&(r=wi(),r===null&&(r=U()))))))))),r!==null&&(r=function(h){return b.method=l.substring(e,h),b.method}(f)),r===null&&(e=f),r}function Oi(){var r,f,h,t,o,u;return u=e,r=sr(),r!==null?(f=V(),f!==null?(h=Di(),h!==null?(t=V(),t!==null?(o=Ni(),o!==null?r=[r,f,h,t,o]:(r=null,e=u)):(r=null,e=u)):(r=null,e=u)):(r=null,e=u)):(r=null,e=u),r}function Di(){var r,f;return f=e,r=Cn(),r!==null&&(r=function(h,t){b.status_code=parseInt(t.join(""))}(f,r)),r===null&&(e=f),r}function Cn(){var r,f,h,t;return t=e,r=S(),r!==null?(f=S(),f!==null?(h=S(),h!==null?r=[r,f,h]:(r=null,e=t)):(r=null,e=t)):(r=null,e=t),r}function Ni(){var r,f,h;for(h=e,r=[],f=x(),f===null&&(f=$(),f===null&&(f=be(),f===null&&(f=B(),f===null&&(f=Q(),f===null&&(f=V(),f===null&&(f=W()))))));f!==null;)r.push(f),f=x(),f===null&&(f=$(),f===null&&(f=be(),f===null&&(f=B(),f===null&&(f=Q(),f===null&&(f=V(),f===null&&(f=W()))))));return r!==null&&(r=function(t){b.reason_phrase=l.substring(e,t)}(h)),r===null&&(e=h),r}function Ia(){var r,f,h,t,o,u;if(o=e,r=Xs(),r!==null){for(f=[],u=e,h=we(),h!==null?(t=Xs(),t!==null?h=[h,t]:(h=null,e=u)):(h=null,e=u);h!==null;)f.push(h),u=e,h=we(),h!==null?(t=Xs(),t!==null?h=[h,t]:(h=null,e=u)):(h=null,e=u);f!==null?r=[r,f]:(r=null,e=o)}else r=null,e=o;return r}function ba(){var r,f,h,t,o,u;return t=e,o=e,r=N(),r!==null?(u=e,l.charCodeAt(e)===64?(f="@",e++):(f=null,n('"@"')),f!==null?(h=N(),h!==null?f=[f,h]:(f=null,e=u)):(f=null,e=u),f=f!==null?f:"",f!==null?r=[r,f]:(r=null,e=o)):(r=null,e=o),r!==null&&(r=function(d){b=l.substring(e,d)}(t)),r===null&&(e=t),r}function wa(){var r,f,h,t,o,u,d;if(o=e,r=z(),r===null)if(u=e,r=rr(),r!==null){for(f=[],d=e,h=we(),h!==null?(t=rr(),t!==null?h=[h,t]:(h=null,e=d)):(h=null,e=d);h!==null;)f.push(h),d=e,h=we(),h!==null?(t=rr(),t!==null?h=[h,t]:(h=null,e=d)):(h=null,e=d);f!==null?r=[r,f]:(r=null,e=u)}else r=null,e=u;return r!==null&&(r=function(T){var E,y;for(y=b.multi_header.length,E=0;E<y;E++)if(b.multi_header[E].parsed===null){b=null;break}b!==null?b=b.multi_header:b=-1}()),r===null&&(e=o),r}function rr(){var r,f,h,t,o,u,d;if(o=e,u=e,r=Ne(),r===null&&(r=Rs()),r!==null){for(f=[],d=e,h=Se(),h!==null?(t=Js(),t!==null?h=[h,t]:(h=null,e=d)):(h=null,e=d);h!==null;)f.push(h),d=e,h=Se(),h!==null?(t=Js(),t!==null?h=[h,t]:(h=null,e=d)):(h=null,e=d);f!==null?r=[r,f]:(r=null,e=u)}else r=null,e=u;return r!==null&&(r=function(T){var E;b.multi_header||(b.multi_header=[]);try{E=new tn(b.uri,b.display_name,b.params),delete b.uri,delete b.display_name,delete b.params}catch{E=null}b.multi_header.push({possition:e,offset:T,parsed:E})}(o)),r===null&&(e=o),r}function Rs(){var r,f,h,t,o;return o=e,r=ir(),r=r!==null?r:"",r!==null?(f=He(),f!==null?(h=Me(),h!==null?(t=Ce(),t!==null?r=[r,f,h,t]:(r=null,e=o)):(r=null,e=o)):(r=null,e=o)):(r=null,e=o),r}function ir(){var r,f,h,t,o,u,d;if(o=e,u=e,r=U(),r!==null){for(f=[],d=e,h=H(),h!==null?(t=U(),t!==null?h=[h,t]:(h=null,e=d)):(h=null,e=d);h!==null;)f.push(h),d=e,h=H(),h!==null?(t=U(),t!==null?h=[h,t]:(h=null,e=d)):(h=null,e=d);f!==null?r=[r,f]:(r=null,e=u)}else r=null,e=u;return r===null&&(r=ve()),r!==null&&(r=function(T,E){typeof E=="string"?b.display_name=E:b.display_name=E[1].reduce(function(y,O){return y+O[0]+O[1]},E[0])}(o,r)),r===null&&(e=o),r}function Js(){var r;return r=as(),r===null&&(r=Rn(),r===null&&(r=et())),r}function as(){var r,f,h,t,o;return t=e,o=e,l.substr(e,1).toLowerCase()==="q"?(r=l.substr(e,1),e++):(r=null,n('"q"')),r!==null?(f=ae(),f!==null?(h=Ui(),h!==null?r=[r,f,h]:(r=null,e=o)):(r=null,e=o)):(r=null,e=o),r!==null&&(r=function(u,d){b.params||(b.params={}),b.params.q=d}(t,r[2])),r===null&&(e=t),r}function Rn(){var r,f,h,t,o;return t=e,o=e,l.substr(e,7).toLowerCase()==="expires"?(r=l.substr(e,7),e+=7):(r=null,n('"expires"')),r!==null?(f=ae(),f!==null?(h=Jt(),h!==null?r=[r,f,h]:(r=null,e=o)):(r=null,e=o)):(r=null,e=o),r!==null&&(r=function(u,d){b.params||(b.params={}),b.params.expires=d}(t,r[2])),r===null&&(e=t),r}function Jt(){var r,f,h;if(h=e,f=S(),f!==null)for(r=[];f!==null;)r.push(f),f=S();else r=null;return r!==null&&(r=function(t,o){return parseInt(o.join(""))}(h,r)),r===null&&(e=h),r}function Ui(){var r,f,h,t,o,u,d,T;return u=e,d=e,l.charCodeAt(e)===48?(r="0",e++):(r=null,n('"0"')),r!==null?(T=e,l.charCodeAt(e)===46?(f=".",e++):(f=null,n('"."')),f!==null?(h=S(),h=h!==null?h:"",h!==null?(t=S(),t=t!==null?t:"",t!==null?(o=S(),o=o!==null?o:"",o!==null?f=[f,h,t,o]:(f=null,e=T)):(f=null,e=T)):(f=null,e=T)):(f=null,e=T),f=f!==null?f:"",f!==null?r=[r,f]:(r=null,e=d)):(r=null,e=d),r!==null&&(r=function(E){return parseFloat(l.substring(e,E))}(u)),r===null&&(e=u),r}function et(){var r,f,h,t,o,u;return t=e,o=e,r=U(),r!==null?(u=e,f=ae(),f!==null?(h=os(),h!==null?f=[f,h]:(f=null,e=u)):(f=null,e=u),f=f!==null?f:"",f!==null?r=[r,f]:(r=null,e=o)):(r=null,e=o),r!==null&&(r=function(d,T,E){b.params||(b.params={}),typeof E>"u"?E=void 0:E=E[1],b.params[T.toLowerCase()]=E}(t,r[0],r[1])),r===null&&(e=t),r}function os(){var r;return r=U(),r===null&&(r=ys(),r===null&&(r=Pe())),r}function Oa(){var r,f,h,t,o,u;if(o=e,r=tt(),r!==null){for(f=[],u=e,h=Se(),h!==null?(t=lr(),t!==null?h=[h,t]:(h=null,e=u)):(h=null,e=u);h!==null;)f.push(h),u=e,h=Se(),h!==null?(t=lr(),t!==null?h=[h,t]:(h=null,e=u)):(h=null,e=u);f!==null?r=[r,f]:(r=null,e=o)}else r=null,e=o;return r}function tt(){var r;return l.substr(e,6).toLowerCase()==="render"?(r=l.substr(e,6),e+=6):(r=null,n('"render"')),r===null&&(l.substr(e,7).toLowerCase()==="session"?(r=l.substr(e,7),e+=7):(r=null,n('"session"')),r===null&&(l.substr(e,4).toLowerCase()==="icon"?(r=l.substr(e,4),e+=4):(r=null,n('"icon"')),r===null&&(l.substr(e,5).toLowerCase()==="alert"?(r=l.substr(e,5),e+=5):(r=null,n('"alert"')),r===null&&(r=U())))),r}function lr(){var r;return r=Da(),r===null&&(r=et()),r}function Da(){var r,f,h,t;return t=e,l.substr(e,8).toLowerCase()==="handling"?(r=l.substr(e,8),e+=8):(r=null,n('"handling"')),r!==null?(f=ae(),f!==null?(l.substr(e,8).toLowerCase()==="optional"?(h=l.substr(e,8),e+=8):(h=null,n('"optional"')),h===null&&(l.substr(e,8).toLowerCase()==="required"?(h=l.substr(e,8),e+=8):(h=null,n('"required"')),h===null&&(h=U())),h!==null?r=[r,f,h]:(r=null,e=t)):(r=null,e=t)):(r=null,e=t),r}function Na(){var r,f,h,t,o,u;if(o=e,r=U(),r!==null){for(f=[],u=e,h=we(),h!==null?(t=U(),t!==null?h=[h,t]:(h=null,e=u)):(h=null,e=u);h!==null;)f.push(h),u=e,h=we(),h!==null?(t=U(),t!==null?h=[h,t]:(h=null,e=u)):(h=null,e=u);f!==null?r=[r,f]:(r=null,e=o)}else r=null,e=o;return r}function Pi(){var r,f,h;if(h=e,f=S(),f!==null)for(r=[];f!==null;)r.push(f),f=S();else r=null;return r!==null&&(r=function(t,o){b=parseInt(o.join(""))}(h,r)),r===null&&(e=h),r}function Ua(){var r,f;return f=e,r=Pa(),r!==null&&(r=function(h){b=l.substring(e,h)}(f)),r===null&&(e=f),r}function Pa(){var r,f,h,t,o,u,d,T;if(d=e,r=xa(),r!==null)if(f=re(),f!==null)if(h=ki(),h!==null){for(t=[],T=e,o=Se(),o!==null?(u=zs(),u!==null?o=[o,u]:(o=null,e=T)):(o=null,e=T);o!==null;)t.push(o),T=e,o=Se(),o!==null?(u=zs(),u!==null?o=[o,u]:(o=null,e=T)):(o=null,e=T);t!==null?r=[r,f,h,t]:(r=null,e=d)}else r=null,e=d;else r=null,e=d;else r=null,e=d;return r}function xa(){var r;return r=Ma(),r===null&&(r=xi()),r}function Ma(){var r;return l.substr(e,4).toLowerCase()==="text"?(r=l.substr(e,4),e+=4):(r=null,n('"text"')),r===null&&(l.substr(e,5).toLowerCase()==="image"?(r=l.substr(e,5),e+=5):(r=null,n('"image"')),r===null&&(l.substr(e,5).toLowerCase()==="audio"?(r=l.substr(e,5),e+=5):(r=null,n('"audio"')),r===null&&(l.substr(e,5).toLowerCase()==="video"?(r=l.substr(e,5),e+=5):(r=null,n('"video"')),r===null&&(l.substr(e,11).toLowerCase()==="application"?(r=l.substr(e,11),e+=11):(r=null,n('"application"')),r===null&&(r=In()))))),r}function xi(){var r;return l.substr(e,7).toLowerCase()==="message"?(r=l.substr(e,7),e+=7):(r=null,n('"message"')),r===null&&(l.substr(e,9).toLowerCase()==="multipart"?(r=l.substr(e,9),e+=9):(r=null,n('"multipart"')),r===null&&(r=In())),r}function In(){var r;return r=U(),r===null&&(r=Mi()),r}function Mi(){var r,f,h;return h=e,l.substr(e,2).toLowerCase()==="x-"?(r=l.substr(e,2),e+=2):(r=null,n('"x-"')),r!==null?(f=U(),f!==null?r=[r,f]:(r=null,e=h)):(r=null,e=h),r}function ki(){var r;return r=In(),r===null&&(r=U()),r}function zs(){var r,f,h,t;return t=e,r=U(),r!==null?(f=ae(),f!==null?(h=Li(),h!==null?r=[r,f,h]:(r=null,e=t)):(r=null,e=t)):(r=null,e=t),r}function Li(){var r;return r=U(),r===null&&(r=Pe()),r}function ka(){var r,f,h,t;return t=e,r=ar(),r!==null?(f=H(),f!==null?(h=An(),h!==null?r=[r,f,h]:(r=null,e=t)):(r=null,e=t)):(r=null,e=t),r}function ar(){var r,f,h;if(h=e,f=S(),f!==null)for(r=[];f!==null;)r.push(f),f=S();else r=null;return r!==null&&(r=function(t,o){b.value=parseInt(o.join(""))}(h,r)),r===null&&(e=h),r}function La(){var r,f;return f=e,r=Jt(),r!==null&&(r=function(h,t){b=t}(f,r)),r===null&&(e=f),r}function Lu(){var r,f,h,t,o,u,d;if(o=e,u=e,r=Xs(),r!==null){for(f=[],d=e,h=Se(),h!==null?(t=et(),t!==null?h=[h,t]:(h=null,e=d)):(h=null,e=d);h!==null;)f.push(h),d=e,h=Se(),h!==null?(t=et(),t!==null?h=[h,t]:(h=null,e=d)):(h=null,e=d);f!==null?r=[r,f]:(r=null,e=u)}else r=null,e=u;return r!==null&&(r=function(T,E){b.event=E.join("").toLowerCase()}(o,r[0])),r===null&&(e=o),r}function Xs(){var r,f,h,t,o,u;if(o=e,r=se(),r!==null){for(f=[],u=e,l.charCodeAt(e)===46?(h=".",e++):(h=null,n('"."')),h!==null?(t=se(),t!==null?h=[h,t]:(h=null,e=u)):(h=null,e=u);h!==null;)f.push(h),u=e,l.charCodeAt(e)===46?(h=".",e++):(h=null,n('"."')),h!==null?(t=se(),t!==null?h=[h,t]:(h=null,e=u)):(h=null,e=u);f!==null?r=[r,f]:(r=null,e=o)}else r=null,e=o;return r}function $u(){var r,f,h,t,o,u,d;if(o=e,u=e,r=Ne(),r===null&&(r=Rs()),r!==null){for(f=[],d=e,h=Se(),h!==null?(t=$i(),t!==null?h=[h,t]:(h=null,e=d)):(h=null,e=d);h!==null;)f.push(h),d=e,h=Se(),h!==null?(t=$i(),t!==null?h=[h,t]:(h=null,e=d)):(h=null,e=d);f!==null?r=[r,f]:(r=null,e=u)}else r=null,e=u;return r!==null&&(r=function(T){var E=b.tag;try{b=new tn(b.uri,b.display_name,b.params),E&&b.setParam("tag",E)}catch{b=-1}}()),r===null&&(e=o),r}function $i(){var r;return r=Is(),r===null&&(r=et()),r}function Is(){var r,f,h,t,o;return t=e,o=e,l.substr(e,3).toLowerCase()==="tag"?(r=l.substr(e,3),e+=3):(r=null,n('"tag"')),r!==null?(f=ae(),f!==null?(h=U(),h!==null?r=[r,f,h]:(r=null,e=o)):(r=null,e=o)):(r=null,e=o),r!==null&&(r=function(u,d){b.tag=d}(t,r[2])),r===null&&(e=t),r}function Hu(){var r,f,h;if(h=e,f=S(),f!==null)for(r=[];f!==null;)r.push(f),f=S();else r=null;return r!==null&&(r=function(t,o){b=parseInt(o.join(""))}(h,r)),r===null&&(e=h),r}function Hi(){var r,f;return f=e,r=Jt(),r!==null&&(r=function(h,t){b=t}(f,r)),r===null&&(e=f),r}function Fi(){var r,f,h,t,o,u,d,T,E,y;for(T=e,E=e,r=[],f=ir();f!==null;)r.push(f),f=ir();if(r!==null)if(f=He(),f!==null)if(h=Me(),h!==null)if(t=Ce(),t!==null){for(o=[],y=e,u=Se(),u!==null?(d=et(),d!==null?u=[u,d]:(u=null,e=y)):(u=null,e=y);u!==null;)o.push(u),y=e,u=Se(),u!==null?(d=et(),d!==null?u=[u,d]:(u=null,e=y)):(u=null,e=y);o!==null?r=[r,f,h,t,o]:(r=null,e=E)}else r=null,e=E;else r=null,e=E;else r=null,e=E;else r=null,e=E;return r!==null&&(r=function(O){try{b=new tn(b.uri,b.display_name,b.params)}catch{b=-1}}()),r===null&&(e=T),r}function Fu(){var r;return r=ji(),r}function ji(){var r,f,h,t,o,u,d,T;if(d=e,l.substr(e,6).toLowerCase()==="digest"?(r=l.substr(e,6),e+=6):(r=null,n('"Digest"')),r!==null)if(f=H(),f!==null)if(h=Qs(),h!==null){for(t=[],T=e,o=we(),o!==null?(u=Qs(),u!==null?o=[o,u]:(o=null,e=T)):(o=null,e=T);o!==null;)t.push(o),T=e,o=we(),o!==null?(u=Qs(),u!==null?o=[o,u]:(o=null,e=T)):(o=null,e=T);t!==null?r=[r,f,h,t]:(r=null,e=d)}else r=null,e=d;else r=null,e=d;else r=null,e=d;return r===null&&(r=$a()),r}function $a(){var r,f,h,t,o,u,d,T;if(d=e,r=U(),r!==null)if(f=H(),f!==null)if(h=bn(),h!==null){for(t=[],T=e,o=we(),o!==null?(u=bn(),u!==null?o=[o,u]:(o=null,e=T)):(o=null,e=T);o!==null;)t.push(o),T=e,o=we(),o!==null?(u=bn(),u!==null?o=[o,u]:(o=null,e=T)):(o=null,e=T);t!==null?r=[r,f,h,t]:(r=null,e=d)}else r=null,e=d;else r=null,e=d;else r=null,e=d;return r}function bn(){var r,f,h,t;return t=e,r=U(),r!==null?(f=ae(),f!==null?(h=U(),h===null&&(h=Pe()),h!==null?r=[r,f,h]:(r=null,e=t)):(r=null,e=t)):(r=null,e=t),r}function Qs(){var r;return r=qi(),r===null&&(r=wn(),r===null&&(r=Vi(),r===null&&(r=Dn(),r===null&&(r=Gi(),r===null&&(r=Wi(),r===null&&(r=Ki(),r===null&&(r=bn()))))))),r}function qi(){var r,f,h,t;return t=e,l.substr(e,5).toLowerCase()==="realm"?(r=l.substr(e,5),e+=5):(r=null,n('"realm"')),r!==null?(f=ae(),f!==null?(h=Zs(),h!==null?r=[r,f,h]:(r=null,e=t)):(r=null,e=t)):(r=null,e=t),r}function Zs(){var r,f;return f=e,r=ve(),r!==null&&(r=function(h,t){b.realm=t}(f,r)),r===null&&(e=f),r}function wn(){var r,f,h,t,o,u,d,T,E;if(T=e,l.substr(e,6).toLowerCase()==="domain"?(r=l.substr(e,6),e+=6):(r=null,n('"domain"')),r!==null)if(f=ae(),f!==null)if(h=Ue(),h!==null)if(t=On(),t!==null){if(o=[],E=e,d=V(),d!==null)for(u=[];d!==null;)u.push(d),d=V();else u=null;for(u!==null?(d=On(),d!==null?u=[u,d]:(u=null,e=E)):(u=null,e=E);u!==null;){if(o.push(u),E=e,d=V(),d!==null)for(u=[];d!==null;)u.push(d),d=V();else u=null;u!==null?(d=On(),d!==null?u=[u,d]:(u=null,e=E)):(u=null,e=E)}o!==null?(u=le(),u!==null?r=[r,f,h,t,o,u]:(r=null,e=T)):(r=null,e=T)}else r=null,e=T;else r=null,e=T;else r=null,e=T;else r=null,e=T;return r}function On(){var r;return r=di(),r===null&&(r=Gs()),r}function Vi(){var r,f,h,t;return t=e,l.substr(e,5).toLowerCase()==="nonce"?(r=l.substr(e,5),e+=5):(r=null,n('"nonce"')),r!==null?(f=ae(),f!==null?(h=Bi(),h!==null?r=[r,f,h]:(r=null,e=t)):(r=null,e=t)):(r=null,e=t),r}function Bi(){var r,f;return f=e,r=ve(),r!==null&&(r=function(h,t){b.nonce=t}(f,r)),r===null&&(e=f),r}function Dn(){var r,f,h,t,o;return t=e,o=e,l.substr(e,6).toLowerCase()==="opaque"?(r=l.substr(e,6),e+=6):(r=null,n('"opaque"')),r!==null?(f=ae(),f!==null?(h=ve(),h!==null?r=[r,f,h]:(r=null,e=o)):(r=null,e=o)):(r=null,e=o),r!==null&&(r=function(u,d){b.opaque=d}(t,r[2])),r===null&&(e=t),r}function Gi(){var r,f,h,t,o;return t=e,l.substr(e,5).toLowerCase()==="stale"?(r=l.substr(e,5),e+=5):(r=null,n('"stale"')),r!==null?(f=ae(),f!==null?(o=e,l.substr(e,4).toLowerCase()==="true"?(h=l.substr(e,4),e+=4):(h=null,n('"true"')),h!==null&&(h=function(u){b.stale=!0}()),h===null&&(e=o),h===null&&(o=e,l.substr(e,5).toLowerCase()==="false"?(h=l.substr(e,5),e+=5):(h=null,n('"false"')),h!==null&&(h=function(u){b.stale=!1}()),h===null&&(e=o)),h!==null?r=[r,f,h]:(r=null,e=t)):(r=null,e=t)):(r=null,e=t),r}function Wi(){var r,f,h,t,o;return t=e,o=e,l.substr(e,9).toLowerCase()==="algorithm"?(r=l.substr(e,9),e+=9):(r=null,n('"algorithm"')),r!==null?(f=ae(),f!==null?(l.substr(e,3).toLowerCase()==="md5"?(h=l.substr(e,3),e+=3):(h=null,n('"MD5"')),h===null&&(l.substr(e,8).toLowerCase()==="md5-sess"?(h=l.substr(e,8),e+=8):(h=null,n('"MD5-sess"')),h===null&&(h=U())),h!==null?r=[r,f,h]:(r=null,e=o)):(r=null,e=o)):(r=null,e=o),r!==null&&(r=function(u,d){b.algorithm=d.toUpperCase()}(t,r[2])),r===null&&(e=t),r}function Ki(){var r,f,h,t,o,u,d,T,E,y;if(T=e,l.substr(e,3).toLowerCase()==="qop"?(r=l.substr(e,3),e+=3):(r=null,n('"qop"')),r!==null)if(f=ae(),f!==null)if(h=Ue(),h!==null){if(E=e,t=Nn(),t!==null){for(o=[],y=e,l.charCodeAt(e)===44?(u=",",e++):(u=null,n('","')),u!==null?(d=Nn(),d!==null?u=[u,d]:(u=null,e=y)):(u=null,e=y);u!==null;)o.push(u),y=e,l.charCodeAt(e)===44?(u=",",e++):(u=null,n('","')),u!==null?(d=Nn(),d!==null?u=[u,d]:(u=null,e=y)):(u=null,e=y);o!==null?t=[t,o]:(t=null,e=E)}else t=null,e=E;t!==null?(o=le(),o!==null?r=[r,f,h,t,o]:(r=null,e=T)):(r=null,e=T)}else r=null,e=T;else r=null,e=T;else r=null,e=T;return r}function Nn(){var r,f;return f=e,l.substr(e,8).toLowerCase()==="auth-int"?(r=l.substr(e,8),e+=8):(r=null,n('"auth-int"')),r===null&&(l.substr(e,4).toLowerCase()==="auth"?(r=l.substr(e,4),e+=4):(r=null,n('"auth"')),r===null&&(r=U())),r!==null&&(r=function(h,t){b.qop||(b.qop=[]),b.qop.push(t.toLowerCase())}(f,r)),r===null&&(e=f),r}function Ha(){var r,f,h,t,o,u;if(o=e,r=U(),r!==null){for(f=[],u=e,h=we(),h!==null?(t=U(),t!==null?h=[h,t]:(h=null,e=u)):(h=null,e=u);h!==null;)f.push(h),u=e,h=we(),h!==null?(t=U(),t!==null?h=[h,t]:(h=null,e=u)):(h=null,e=u);f!==null?r=[r,f]:(r=null,e=o)}else r=null,e=o;return r}function Fa(){var r,f,h,t,o,u,d;if(o=e,u=e,r=bs(),r!==null){for(f=[],d=e,h=we(),h!==null?(t=bs(),t!==null?h=[h,t]:(h=null,e=d)):(h=null,e=d);h!==null;)f.push(h),d=e,h=we(),h!==null?(t=bs(),t!==null?h=[h,t]:(h=null,e=d)):(h=null,e=d);f!==null?r=[r,f]:(r=null,e=u)}else r=null,e=u;return r!==null&&(r=function(T){var E,y;for(y=b.multi_header.length,E=0;E<y;E++)if(b.multi_header[E].parsed===null){b=null;break}b!==null?b=b.multi_header:b=-1}()),r===null&&(e=o),r}function bs(){var r,f,h,t,o,u,d;if(o=e,u=e,r=Rs(),r!==null){for(f=[],d=e,h=Se(),h!==null?(t=et(),t!==null?h=[h,t]:(h=null,e=d)):(h=null,e=d);h!==null;)f.push(h),d=e,h=Se(),h!==null?(t=et(),t!==null?h=[h,t]:(h=null,e=d)):(h=null,e=d);f!==null?r=[r,f]:(r=null,e=u)}else r=null,e=u;return r!==null&&(r=function(T){var E;b.multi_header||(b.multi_header=[]);try{E=new tn(b.uri,b.display_name,b.params),delete b.uri,delete b.display_name,delete b.params}catch{E=null}b.multi_header.push({possition:e,offset:T,parsed:E})}(o)),r===null&&(e=o),r}function ju(){var r,f,h,t,o,u,d;if(o=e,u=e,l.substr(e,3).toLowerCase()==="sip"?(r=l.substr(e,3),e+=3):(r=null,n('"SIP"')),r===null&&(r=U()),r!==null){for(f=[],d=e,h=Se(),h!==null?(t=Yi(),t!==null?h=[h,t]:(h=null,e=d)):(h=null,e=d);h!==null;)f.push(h),d=e,h=Se(),h!==null?(t=Yi(),t!==null?h=[h,t]:(h=null,e=d)):(h=null,e=d);f!==null?r=[r,f]:(r=null,e=u)}else r=null,e=u;return r!==null&&(r=function(T,E){if(b.protocol=E.toLowerCase(),b.params||(b.params={}),b.params.text&&b.params.text[0]==='"'){var y=b.params.text;b.text=y.substring(1,y.length-1),delete b.params.text}}(o,r[0])),r===null&&(e=o),r}function Yi(){var r;return r=Un(),r===null&&(r=et()),r}function Un(){var r,f,h,t,o,u;if(o=e,u=e,l.substr(e,5).toLowerCase()==="cause"?(r=l.substr(e,5),e+=5):(r=null,n('"cause"')),r!==null)if(f=ae(),f!==null){if(t=S(),t!==null)for(h=[];t!==null;)h.push(t),t=S();else h=null;h!==null?r=[r,f,h]:(r=null,e=u)}else r=null,e=u;else r=null,e=u;return r!==null&&(r=function(d,T){b.cause=parseInt(T.join(""))}(o,r[2])),r===null&&(e=o),r}function qu(){var r,f,h,t,o,u;if(o=e,r=U(),r!==null){for(f=[],u=e,h=we(),h!==null?(t=U(),t!==null?h=[h,t]:(h=null,e=u)):(h=null,e=u);h!==null;)f.push(h),u=e,h=we(),h!==null?(t=U(),t!==null?h=[h,t]:(h=null,e=u)):(h=null,e=u);f!==null?r=[r,f]:(r=null,e=o)}else r=null,e=o;return r}function Ji(){var r,f,h,t,o,u;if(o=e,r=Pn(),r!==null){for(f=[],u=e,h=we(),h!==null?(t=Pn(),t!==null?h=[h,t]:(h=null,e=u)):(h=null,e=u);h!==null;)f.push(h),u=e,h=we(),h!==null?(t=Pn(),t!==null?h=[h,t]:(h=null,e=u)):(h=null,e=u);f!==null?r=[r,f]:(r=null,e=o)}else r=null,e=o;return r}function Pn(){var r,f,h,t,o,u;if(o=e,r=Rs(),r!==null){for(f=[],u=e,h=Se(),h!==null?(t=et(),t!==null?h=[h,t]:(h=null,e=u)):(h=null,e=u);h!==null;)f.push(h),u=e,h=Se(),h!==null?(t=et(),t!==null?h=[h,t]:(h=null,e=u)):(h=null,e=u);f!==null?r=[r,f]:(r=null,e=o)}else r=null,e=o;return r}function Vu(){var r,f,h,t,o,u;if(o=e,r=ja(),r!==null){for(f=[],u=e,h=Se(),h!==null?(t=en(),t!==null?h=[h,t]:(h=null,e=u)):(h=null,e=u);h!==null;)f.push(h),u=e,h=Se(),h!==null?(t=en(),t!==null?h=[h,t]:(h=null,e=u)):(h=null,e=u);f!==null?r=[r,f]:(r=null,e=o)}else r=null,e=o;return r}function ja(){var r,f;return f=e,l.substr(e,6).toLowerCase()==="active"?(r=l.substr(e,6),e+=6):(r=null,n('"active"')),r===null&&(l.substr(e,7).toLowerCase()==="pending"?(r=l.substr(e,7),e+=7):(r=null,n('"pending"')),r===null&&(l.substr(e,10).toLowerCase()==="terminated"?(r=l.substr(e,10),e+=10):(r=null,n('"terminated"')),r===null&&(r=U()))),r!==null&&(r=function(h){b.state=l.substring(e,h)}(f)),r===null&&(e=f),r}function en(){var r,f,h,t,o;return t=e,o=e,l.substr(e,6).toLowerCase()==="reason"?(r=l.substr(e,6),e+=6):(r=null,n('"reason"')),r!==null?(f=ae(),f!==null?(h=qa(),h!==null?r=[r,f,h]:(r=null,e=o)):(r=null,e=o)):(r=null,e=o),r!==null&&(r=function(u,d){typeof d<"u"&&(b.reason=d)}(t,r[2])),r===null&&(e=t),r===null&&(t=e,o=e,l.substr(e,7).toLowerCase()==="expires"?(r=l.substr(e,7),e+=7):(r=null,n('"expires"')),r!==null?(f=ae(),f!==null?(h=Jt(),h!==null?r=[r,f,h]:(r=null,e=o)):(r=null,e=o)):(r=null,e=o),r!==null&&(r=function(u,d){typeof d<"u"&&(b.expires=d)}(t,r[2])),r===null&&(e=t),r===null&&(t=e,o=e,l.substr(e,11).toLowerCase()==="retry_after"?(r=l.substr(e,11),e+=11):(r=null,n('"retry_after"')),r!==null?(f=ae(),f!==null?(h=Jt(),h!==null?r=[r,f,h]:(r=null,e=o)):(r=null,e=o)):(r=null,e=o),r!==null&&(r=function(u,d){typeof d<"u"&&(b.retry_after=d)}(t,r[2])),r===null&&(e=t),r===null&&(r=et()))),r}function qa(){var r;return l.substr(e,11).toLowerCase()==="deactivated"?(r=l.substr(e,11),e+=11):(r=null,n('"deactivated"')),r===null&&(l.substr(e,9).toLowerCase()==="probation"?(r=l.substr(e,9),e+=9):(r=null,n('"probation"')),r===null&&(l.substr(e,8).toLowerCase()==="rejected"?(r=l.substr(e,8),e+=8):(r=null,n('"rejected"')),r===null&&(l.substr(e,7).toLowerCase()==="timeout"?(r=l.substr(e,7),e+=7):(r=null,n('"timeout"')),r===null&&(l.substr(e,6).toLowerCase()==="giveup"?(r=l.substr(e,6),e+=6):(r=null,n('"giveup"')),r===null&&(l.substr(e,10).toLowerCase()==="noresource"?(r=l.substr(e,10),e+=10):(r=null,n('"noresource"')),r===null&&(l.substr(e,9).toLowerCase()==="invariant"?(r=l.substr(e,9),e+=9):(r=null,n('"invariant"')),r===null&&(r=U()))))))),r}function Va(){var r;return r=q(),r=r!==null?r:"",r}function zi(){var r,f,h,t,o,u;if(o=e,r=U(),r!==null){for(f=[],u=e,h=we(),h!==null?(t=U(),t!==null?h=[h,t]:(h=null,e=u)):(h=null,e=u);h!==null;)f.push(h),u=e,h=we(),h!==null?(t=U(),t!==null?h=[h,t]:(h=null,e=u)):(h=null,e=u);f!==null?r=[r,f]:(r=null,e=o)}else r=null,e=o;return r=r!==null?r:"",r}function Ba(){var r,f,h,t,o,u,d;if(o=e,u=e,r=Ne(),r===null&&(r=Rs()),r!==null){for(f=[],d=e,h=Se(),h!==null?(t=Xi(),t!==null?h=[h,t]:(h=null,e=d)):(h=null,e=d);h!==null;)f.push(h),d=e,h=Se(),h!==null?(t=Xi(),t!==null?h=[h,t]:(h=null,e=d)):(h=null,e=d);f!==null?r=[r,f]:(r=null,e=u)}else r=null,e=u;return r!==null&&(r=function(T){var E=b.tag;try{b=new tn(b.uri,b.display_name,b.params),E&&b.setParam("tag",E)}catch{b=-1}}()),r===null&&(e=o),r}function Xi(){var r;return r=Is(),r===null&&(r=et()),r}function Bu(){var r,f,h,t,o,u;if(o=e,r=or(),r!==null){for(f=[],u=e,h=we(),h!==null?(t=or(),t!==null?h=[h,t]:(h=null,e=u)):(h=null,e=u);h!==null;)f.push(h),u=e,h=we(),h!==null?(t=or(),t!==null?h=[h,t]:(h=null,e=u)):(h=null,e=u);f!==null?r=[r,f]:(r=null,e=o)}else r=null,e=o;return r}function or(){var r,f,h,t,o,u,d,T;if(d=e,r=tl(),r!==null)if(f=H(),f!==null)if(h=rl(),h!==null){for(t=[],T=e,o=Se(),o!==null?(u=xn(),u!==null?o=[o,u]:(o=null,e=T)):(o=null,e=T);o!==null;)t.push(o),T=e,o=Se(),o!==null?(u=xn(),u!==null?o=[o,u]:(o=null,e=T)):(o=null,e=T);t!==null?r=[r,f,h,t]:(r=null,e=d)}else r=null,e=d;else r=null,e=d;else r=null,e=d;return r}function xn(){var r;return r=Ga(),r===null&&(r=Mn(),r===null&&(r=ur(),r===null&&(r=Qi(),r===null&&(r=Zi(),r===null&&(r=et()))))),r}function Ga(){var r,f,h,t,o;return t=e,o=e,l.substr(e,3).toLowerCase()==="ttl"?(r=l.substr(e,3),e+=3):(r=null,n('"ttl"')),r!==null?(f=ae(),f!==null?(h=cr(),h!==null?r=[r,f,h]:(r=null,e=o)):(r=null,e=o)):(r=null,e=o),r!==null&&(r=function(u,d){b.ttl=d}(t,r[2])),r===null&&(e=t),r}function Mn(){var r,f,h,t,o;return t=e,o=e,l.substr(e,5).toLowerCase()==="maddr"?(r=l.substr(e,5),e+=5):(r=null,n('"maddr"')),r!==null?(f=ae(),f!==null?(h=ys(),h!==null?r=[r,f,h]:(r=null,e=o)):(r=null,e=o)):(r=null,e=o),r!==null&&(r=function(u,d){b.maddr=d}(t,r[2])),r===null&&(e=t),r}function ur(){var r,f,h,t,o;return t=e,o=e,l.substr(e,8).toLowerCase()==="received"?(r=l.substr(e,8),e+=8):(r=null,n('"received"')),r!==null?(f=ae(),f!==null?(h=As(),h===null&&(h=En()),h!==null?r=[r,f,h]:(r=null,e=o)):(r=null,e=o)):(r=null,e=o),r!==null&&(r=function(u,d){b.received=d}(t,r[2])),r===null&&(e=t),r}function Qi(){var r,f,h,t,o;return t=e,o=e,l.substr(e,6).toLowerCase()==="branch"?(r=l.substr(e,6),e+=6):(r=null,n('"branch"')),r!==null?(f=ae(),f!==null?(h=U(),h!==null?r=[r,f,h]:(r=null,e=o)):(r=null,e=o)):(r=null,e=o),r!==null&&(r=function(u,d){b.branch=d}(t,r[2])),r===null&&(e=t),r}function Zi(){var r,f,h,t,o;return t=e,l.substr(e,5).toLowerCase()==="rport"?(r=l.substr(e,5),e+=5):(r=null,n('"rport"')),r!==null?(o=e,f=ae(),f!==null?(h=el(),h!==null?f=[f,h]:(f=null,e=o)):(f=null,e=o),f=f!==null?f:"",f!==null?r=[r,f]:(r=null,e=t)):(r=null,e=t),r}function el(){var r,f,h,t,o,u,d;return u=e,d=e,r=S(),r=r!==null?r:"",r!==null?(f=S(),f=f!==null?f:"",f!==null?(h=S(),h=h!==null?h:"",h!==null?(t=S(),t=t!==null?t:"",t!==null?(o=S(),o=o!==null?o:"",o!==null?r=[r,f,h,t,o]:(r=null,e=d)):(r=null,e=d)):(r=null,e=d)):(r=null,e=d)):(r=null,e=d),r!==null&&(r=function(T,E){b.rport=parseInt(E.join(""))}(u,r)),r===null&&(e=u),r}function tl(){var r,f,h,t,o,u;return u=e,r=sl(),r!==null?(f=re(),f!==null?(h=U(),h!==null?(t=re(),t!==null?(o=nl(),o!==null?r=[r,f,h,t,o]:(r=null,e=u)):(r=null,e=u)):(r=null,e=u)):(r=null,e=u)):(r=null,e=u),r}function sl(){var r,f;return f=e,l.substr(e,3).toLowerCase()==="sip"?(r=l.substr(e,3),e+=3):(r=null,n('"SIP"')),r===null&&(r=U()),r!==null&&(r=function(h,t){b.protocol=t}(f,r)),r===null&&(e=f),r}function nl(){var r,f;return f=e,l.substr(e,3).toLowerCase()==="udp"?(r=l.substr(e,3),e+=3):(r=null,n('"UDP"')),r===null&&(l.substr(e,3).toLowerCase()==="tcp"?(r=l.substr(e,3),e+=3):(r=null,n('"TCP"')),r===null&&(l.substr(e,3).toLowerCase()==="tls"?(r=l.substr(e,3),e+=3):(r=null,n('"TLS"')),r===null&&(l.substr(e,4).toLowerCase()==="sctp"?(r=l.substr(e,4),e+=4):(r=null,n('"SCTP"')),r===null&&(r=U())))),r!==null&&(r=function(h,t){b.transport=t}(f,r)),r===null&&(e=f),r}function rl(){var r,f,h,t,o;return t=e,r=il(),r!==null?(o=e,f=ot(),f!==null?(h=ll(),h!==null?f=[f,h]:(f=null,e=o)):(f=null,e=o),f=f!==null?f:"",f!==null?r=[r,f]:(r=null,e=t)):(r=null,e=t),r}function il(){var r,f;return f=e,r=As(),r===null&&(r=vn(),r===null&&(r=Qn())),r!==null&&(r=function(h){b.host=l.substring(e,h)}(f)),r===null&&(e=f),r}function ll(){var r,f,h,t,o,u,d;return u=e,d=e,r=S(),r=r!==null?r:"",r!==null?(f=S(),f=f!==null?f:"",f!==null?(h=S(),h=h!==null?h:"",h!==null?(t=S(),t=t!==null?t:"",t!==null?(o=S(),o=o!==null?o:"",o!==null?r=[r,f,h,t,o]:(r=null,e=d)):(r=null,e=d)):(r=null,e=d)):(r=null,e=d)):(r=null,e=d),r!==null&&(r=function(T,E){b.port=parseInt(E.join(""))}(u,r)),r===null&&(e=u),r}function cr(){var r,f,h,t,o;return t=e,o=e,r=S(),r!==null?(f=S(),f=f!==null?f:"",f!==null?(h=S(),h=h!==null?h:"",h!==null?r=[r,f,h]:(r=null,e=o)):(r=null,e=o)):(r=null,e=o),r!==null&&(r=function(u,d){return parseInt(d.join(""))}(t,r)),r===null&&(e=t),r}function Wa(){var r;return r=ji(),r}function Ka(){var r,f,h,t,o,u;if(o=e,r=fr(),r!==null){for(f=[],u=e,h=Se(),h!==null?(t=al(),t!==null?h=[h,t]:(h=null,e=u)):(h=null,e=u);h!==null;)f.push(h),u=e,h=Se(),h!==null?(t=al(),t!==null?h=[h,t]:(h=null,e=u)):(h=null,e=u);f!==null?r=[r,f]:(r=null,e=o)}else r=null,e=o;return r}function fr(){var r,f;return f=e,r=Jt(),r!==null&&(r=function(h,t){b.expires=t}(f,r)),r===null&&(e=f),r}function al(){var r;return r=Ya(),r===null&&(r=et()),r}function Ya(){var r,f,h,t,o;return t=e,o=e,l.substr(e,9).toLowerCase()==="refresher"?(r=l.substr(e,9),e+=9):(r=null,n('"refresher"')),r!==null?(f=ae(),f!==null?(l.substr(e,3).toLowerCase()==="uac"?(h=l.substr(e,3),e+=3):(h=null,n('"uac"')),h===null&&(l.substr(e,3).toLowerCase()==="uas"?(h=l.substr(e,3),e+=3):(h=null,n('"uas"'))),h!==null?r=[r,f,h]:(r=null,e=o)):(r=null,e=o)):(r=null,e=o),r!==null&&(r=function(u,d){b.refresher=d.toLowerCase()}(t,r[2])),r===null&&(e=t),r}function Ja(){var r,f,h,t;return t=e,r=U(),r!==null?(f=L(),f!==null?(h=_r(),h!==null?r=[r,f,h]:(r=null,e=t)):(r=null,e=t)):(r=null,e=t),r}function _r(){var r,f;for(r=[],f=j(),f===null&&(f=Q(),f===null&&(f=H()));f!==null;)r.push(f),f=j(),f===null&&(f=Q(),f===null&&(f=H()));return r}function za(){var r,f;for(r=[],f=R();f!==null;)r.push(f),f=R();return r}function Gu(){var r,f,h;return h=e,l.substr(e,5)==="uuid:"?(r="uuid:",e+=5):(r=null,n('"uuid:"')),r!==null?(f=ol(),f!==null?r=[r,f]:(r=null,e=h)):(r=null,e=h),r}function ol(){var r,f,h,t,o,u,d,T,E,y,O;return y=e,O=e,r=Xa(),r!==null?(l.charCodeAt(e)===45?(f="-",e++):(f=null,n('"-"')),f!==null?(h=zt(),h!==null?(l.charCodeAt(e)===45?(t="-",e++):(t=null,n('"-"')),t!==null?(o=zt(),o!==null?(l.charCodeAt(e)===45?(u="-",e++):(u=null,n('"-"')),u!==null?(d=zt(),d!==null?(l.charCodeAt(e)===45?(T="-",e++):(T=null,n('"-"')),T!==null?(E=ul(),E!==null?r=[r,f,h,t,o,u,d,T,E]:(r=null,e=O)):(r=null,e=O)):(r=null,e=O)):(r=null,e=O)):(r=null,e=O)):(r=null,e=O)):(r=null,e=O)):(r=null,e=O)):(r=null,e=O),r!==null&&(r=function(G,ye){b=l.substring(e+5,G)}(y,r[0])),r===null&&(e=y),r}function zt(){var r,f,h,t,o;return o=e,r=C(),r!==null?(f=C(),f!==null?(h=C(),h!==null?(t=C(),t!==null?r=[r,f,h,t]:(r=null,e=o)):(r=null,e=o)):(r=null,e=o)):(r=null,e=o),r}function Xa(){var r,f,h;return h=e,r=zt(),r!==null?(f=zt(),f!==null?r=[r,f]:(r=null,e=h)):(r=null,e=h),r}function ul(){var r,f,h,t;return t=e,r=zt(),r!==null?(f=zt(),f!==null?(h=zt(),h!==null?r=[r,f,h]:(r=null,e=t)):(r=null,e=t)):(r=null,e=t),r}function Xt(){var r,f,h,t,o,u,d;if(o=e,u=e,r=Ne(),r===null&&(r=Rs()),r!==null){for(f=[],d=e,h=Se(),h!==null?(t=et(),t!==null?h=[h,t]:(h=null,e=d)):(h=null,e=d);h!==null;)f.push(h),d=e,h=Se(),h!==null?(t=et(),t!==null?h=[h,t]:(h=null,e=d)):(h=null,e=d);f!==null?r=[r,f]:(r=null,e=u)}else r=null,e=u;return r!==null&&(r=function(T){try{b=new tn(b.uri,b.display_name,b.params)}catch{b=-1}}()),r===null&&(e=o),r}function Qa(){var r,f,h,t,o,u;if(o=e,r=cl(),r!==null){for(f=[],u=e,h=Se(),h!==null?(t=fl(),t!==null?h=[h,t]:(h=null,e=u)):(h=null,e=u);h!==null;)f.push(h),u=e,h=Se(),h!==null?(t=fl(),t!==null?h=[h,t]:(h=null,e=u)):(h=null,e=u);f!==null?r=[r,f]:(r=null,e=o)}else r=null,e=o;return r}function cl(){var r,f,h,t,o,u;return t=e,o=e,r=N(),r!==null?(u=e,l.charCodeAt(e)===64?(f="@",e++):(f=null,n('"@"')),f!==null?(h=N(),h!==null?f=[f,h]:(f=null,e=u)):(f=null,e=u),f=f!==null?f:"",f!==null?r=[r,f]:(r=null,e=o)):(r=null,e=o),r!==null&&(r=function(d){b.call_id=l.substring(e,d)}(t)),r===null&&(e=t),r}function fl(){var r;return r=Za(),r===null&&(r=_l(),r===null&&(r=hr(),r===null&&(r=et()))),r}function Za(){var r,f,h,t,o;return t=e,o=e,l.substr(e,6)==="to-tag"?(r="to-tag",e+=6):(r=null,n('"to-tag"')),r!==null?(f=ae(),f!==null?(h=U(),h!==null?r=[r,f,h]:(r=null,e=o)):(r=null,e=o)):(r=null,e=o),r!==null&&(r=function(u,d){b.to_tag=d}(t,r[2])),r===null&&(e=t),r}function _l(){var r,f,h,t,o;return t=e,o=e,l.substr(e,8)==="from-tag"?(r="from-tag",e+=8):(r=null,n('"from-tag"')),r!==null?(f=ae(),f!==null?(h=U(),h!==null?r=[r,f,h]:(r=null,e=o)):(r=null,e=o)):(r=null,e=o),r!==null&&(r=function(u,d){b.from_tag=d}(t,r[2])),r===null&&(e=t),r}function hr(){var r,f;return f=e,l.substr(e,10)==="early-only"?(r="early-only",e+=10):(r=null,n('"early-only"')),r!==null&&(r=function(h){b.early_only=!0}()),r===null&&(e=f),r}function eo(r){r.sort();for(var f=null,h=[],t=0;t<r.length;t++)r[t]!==f&&(h.push(r[t]),f=r[t]);return h}function to(){for(var r=1,f=1,h=!1,t=0;t<Math.max(e,p);t++){var o=l.charAt(t);o===`
|
4
|
+
`?(h||r++,f=1,h=!1):o==="\r"||o==="\u2028"||o==="\u2029"?(r++,f=1,h=!0):(f++,h=!1)}return{line:r,column:f}}var hl=Os(),tn=io(),b={},so=_[a]();if(so===null||e!==l.length){var us=Math.max(e,p),w=us<l.length?l.charAt(us):null,no=to();return new this.SyntaxError(eo(g),w,us,no.line,no.column),-1}return b},toSource:function(){return this._source}};return s.SyntaxError=function(i,l,a,_,e){function p(g,n){var v,S;switch(g.length){case 0:v="end of input";break;case 1:v=g[0];break;default:v=g.slice(0,g.length-1).join(", ")+" or "+g[g.length-1]}return S=n?c(n):"end of input","Expected "+v+" but "+S+" found."}this.name="SyntaxError",this.expected=i,this.found=l,this.message=p(i,l),this.offset=a,this.line=_,this.column=e},s.SyntaxError.prototype=Error.prototype,s}()),lo}var ao,Xu;function Os(){if(Xu)return ao;Xu=1;function c(n,v){var S;if(typeof Symbol>"u"||n[Symbol.iterator]==null){if(Array.isArray(n)||(S=s(n))||v&&n&&typeof n.length=="number"){S&&(n=S);var m=0,C=function(){};return{s:C,n:function(){return m>=n.length?{done:!0}:{done:!1,value:n[m++]}},e:function(W){throw W},f:C}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
|
5
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var A=!0,R=!1,I;return{s:function(){S=n[Symbol.iterator]()},n:function(){var W=S.next();return A=W.done,W},e:function(W){R=!0,I=W},f:function(){try{!A&&S.return!=null&&S.return()}finally{if(R)throw I}}}}function s(n,v){if(n){if(typeof n=="string")return i(n,v);var S=Object.prototype.toString.call(n).slice(8,-1);if(S==="Object"&&n.constructor&&(S=n.constructor.name),S==="Map"||S==="Set")return Array.from(n);if(S==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(S))return i(n,v)}}function i(n,v){(v==null||v>n.length)&&(v=n.length);for(var S=0,m=new Array(v);S<v;S++)m[S]=n[S];return m}function l(n,v){if(!(n instanceof v))throw new TypeError("Cannot call a class as a function")}function a(n,v){for(var S=0;S<v.length;S++){var m=v[S];m.enumerable=m.enumerable||!1,m.configurable=!0,"value"in m&&(m.writable=!0),Object.defineProperty(n,m.key,m)}}function _(n,v,S){return v&&a(n.prototype,v),S&&a(n,S),n}var e=it,p=It(),g=Zt();return ao=function(){_(n,null,[{key:"parse",value:function(S){if(S=g.parse(S,"SIP_URI"),S!==-1)return S}}]);function n(v,S,m,C){var A=arguments.length>4&&arguments[4]!==void 0?arguments[4]:{},R=arguments.length>5&&arguments[5]!==void 0?arguments[5]:{};if(l(this,n),!m)throw new TypeError('missing or invalid "host" parameter');this._parameters={},this._headers={},this._scheme=v||e.SIP,this._user=S,this._host=m,this._port=C;for(var I in A)Object.prototype.hasOwnProperty.call(A,I)&&this.setParam(I,A[I]);for(var V in R)Object.prototype.hasOwnProperty.call(R,V)&&this.setHeader(V,R[V])}return _(n,[{key:"setParam",value:function(S,m){S&&(this._parameters[S.toLowerCase()]=typeof m>"u"||m===null?null:m.toString())}},{key:"getParam",value:function(S){if(S)return this._parameters[S.toLowerCase()]}},{key:"hasParam",value:function(S){if(S)return this._parameters.hasOwnProperty(S.toLowerCase())&&!0||!1}},{key:"deleteParam",value:function(S){if(S=S.toLowerCase(),this._parameters.hasOwnProperty(S)){var m=this._parameters[S];return delete this._parameters[S],m}}},{key:"clearParams",value:function(){this._parameters={}}},{key:"setHeader",value:function(S,m){this._headers[p.headerize(S)]=Array.isArray(m)?m:[m]}},{key:"getHeader",value:function(S){if(S)return this._headers[p.headerize(S)]}},{key:"hasHeader",value:function(S){if(S)return this._headers.hasOwnProperty(p.headerize(S))&&!0||!1}},{key:"deleteHeader",value:function(S){if(S=p.headerize(S),this._headers.hasOwnProperty(S)){var m=this._headers[S];return delete this._headers[S],m}}},{key:"clearHeaders",value:function(){this._headers={}}},{key:"clone",value:function(){return new n(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 S=[],m="".concat(this._scheme,":");this._user&&(m+="".concat(p.escapeUser(this._user),"@")),m+=this._host,(this._port||this._port===0)&&(m+=":".concat(this._port));for(var C in this._parameters)Object.prototype.hasOwnProperty.call(this._parameters,C)&&(m+=";".concat(C),this._parameters[C]!==null&&(m+="=".concat(this._parameters[C])));for(var A in this._headers)if(Object.prototype.hasOwnProperty.call(this._headers,A)){var R=c(this._headers[A]),I;try{for(R.s();!(I=R.n()).done;){var V=I.value;S.push("".concat(A,"=").concat(V))}}catch(W){R.e(W)}finally{R.f()}}return S.length>0&&(m+="?".concat(S.join("&"))),m}},{key:"toAor",value:function(S){var m="".concat(this._scheme,":");return this._user&&(m+="".concat(p.escapeUser(this._user),"@")),m+=this._host,S&&(this._port||this._port===0)&&(m+=":".concat(this._port)),m}},{key:"scheme",get:function(){return this._scheme},set:function(S){this._scheme=S.toLowerCase()}},{key:"user",get:function(){return this._user},set:function(S){this._user=S}},{key:"host",get:function(){return this._host},set:function(S){this._host=S.toLowerCase()}},{key:"port",get:function(){return this._port},set:function(S){this._port=S===0?S:parseInt(S,10)||null}}]),n}(),ao}var Qu;function It(){if(Qu)return nt;Qu=1;function c(v){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?c=function(m){return typeof m}:c=function(m){return m&&typeof Symbol=="function"&&m.constructor===Symbol&&m!==Symbol.prototype?"symbol":typeof m},c(v)}function s(v,S){var m;if(typeof Symbol>"u"||v[Symbol.iterator]==null){if(Array.isArray(v)||(m=i(v))||S&&v&&typeof v.length=="number"){m&&(v=m);var C=0,A=function(){};return{s:A,n:function(){return C>=v.length?{done:!0}:{done:!1,value:v[C++]}},e:function(oe){throw oe},f:A}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
|
6
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var R=!0,I=!1,V;return{s:function(){m=v[Symbol.iterator]()},n:function(){var oe=m.next();return R=oe.done,oe},e:function(oe){I=!0,V=oe},f:function(){try{!R&&m.return!=null&&m.return()}finally{if(I)throw V}}}}function i(v,S){if(v){if(typeof v=="string")return l(v,S);var m=Object.prototype.toString.call(v).slice(8,-1);if(m==="Object"&&v.constructor&&(m=v.constructor.name),m==="Map"||m==="Set")return Array.from(v);if(m==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(m))return l(v,S)}}function l(v,S){(S==null||S>v.length)&&(S=v.length);for(var m=0,C=new Array(S);m<S;m++)C[m]=v[m];return C}var a=it,_=Os(),e=Zt();nt.str_utf8_length=function(v){return unescape(encodeURIComponent(v)).length};var p=nt.isFunction=function(v){return v!==void 0?Object.prototype.toString.call(v)==="[object Function]":!1};nt.isString=function(v){return v!==void 0?Object.prototype.toString.call(v)==="[object String]":!1},nt.isDecimal=function(v){return!isNaN(v)&&parseFloat(v)===parseInt(v,10)},nt.isEmpty=function(v){return v===null||v===""||v===void 0||Array.isArray(v)&&v.length===0||typeof v=="number"&&isNaN(v)},nt.hasMethods=function(v){for(var S=arguments.length,m=new Array(S>1?S-1:0),C=1;C<S;C++)m[C-1]=arguments[C];for(var A=0,R=m;A<R.length;A++){var I=R[A];if(p(v[I]))return!1}return!0};var g=nt.createRandomToken=function(v){var S=arguments.length>1&&arguments[1]!==void 0?arguments[1]:32,m,C,A="";for(m=0;m<v;m++)C=Math.random()*S|0,A+=C.toString(S);return A};nt.newTag=function(){return g(10)},nt.newUUID=function(){var v="xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(S){var m=Math.random()*16|0,C=S==="x"?m:m&3|8;return C.toString(16)});return v},nt.hostType=function(v){if(v){if(v=e.parse(v,"host"),v!==-1)return v.host_type}else return};var n=nt.escapeUser=function(v){return encodeURIComponent(decodeURIComponent(v)).replace(/%3A/ig,":").replace(/%2B/ig,"+").replace(/%3F/ig,"?").replace(/%2F/ig,"/")};return nt.normalizeTarget=function(v,S){if(v){if(v instanceof _)return v;if(typeof v=="string"){var m=v.split("@"),C,A;switch(m.length){case 1:if(!S)return;C=v,A=S;break;case 2:C=m[0],A=m[1];break;default:C=m.slice(0,m.length-1).join("@"),A=m[m.length-1]}C=C.replace(/^(sips?|tel):/i,""),/^[-.()]*\+?[0-9\-.()]+$/.test(C)&&(C=C.replace(/[-.()]/g,"")),v="".concat(a.SIP,":").concat(n(C),"@").concat(A);var R;return(R=_.parse(v))?R:void 0}else return}else return},nt.headerize=function(v){var S={"Call-Id":"Call-ID",Cseq:"CSeq","Www-Authenticate":"WWW-Authenticate"},m=v.toLowerCase().replace(/_/g,"-").split("-"),C="",A=m.length,R;for(R=0;R<A;R++)R!==0&&(C+="-"),C+=m[R].charAt(0).toUpperCase()+m[R].substring(1);return S[C]&&(C=S[C]),C},nt.sipErrorCause=function(v){for(var S in a.SIP_ERROR_CAUSES)if(a.SIP_ERROR_CAUSES[S].indexOf(v)!==-1)return a.causes[S];return a.causes.SIP_FAILURE_CODE},nt.getRandomTestNetIP=function(){function v(S,m){return Math.floor(Math.random()*(m-S+1)+S)}return"192.0.2.".concat(v(1,254))},nt.calculateMD5=function(v){function S(ve,he){return ve<<he|ve>>>32-he}function m(ve,he){var pe=ve&2147483648,Ne=he&2147483648,Me=ve&1073741824,We=he&1073741824,Fe=(ve&1073741823)+(he&1073741823);return Me&We?Fe^2147483648^pe^Ne:Me|We?Fe&1073741824?Fe^3221225472^pe^Ne:Fe^1073741824^pe^Ne:Fe^pe^Ne}function C(ve,he,pe){return ve&he|~ve&pe}function A(ve,he,pe){return ve&pe|he&~pe}function R(ve,he,pe){return ve^he^pe}function I(ve,he,pe){return he^(ve|~pe)}function V(ve,he,pe,Ne,Me,We,Fe){return ve=m(ve,m(m(C(he,pe,Ne),Me),Fe)),m(S(ve,We),he)}function W(ve,he,pe,Ne,Me,We,Fe){return ve=m(ve,m(m(A(he,pe,Ne),Me),Fe)),m(S(ve,We),he)}function oe(ve,he,pe,Ne,Me,We,Fe){return ve=m(ve,m(m(R(he,pe,Ne),Me),Fe)),m(S(ve,We),he)}function x(ve,he,pe,Ne,Me,We,Fe){return ve=m(ve,m(m(I(he,pe,Ne),Me),Fe)),m(S(ve,We),he)}function $(ve){for(var he,pe=ve.length,Ne=pe+8,Me=(Ne-Ne%64)/64,We=(Me+1)*16,Fe=new Array(We-1),Vt=0,dt=0;dt<pe;)he=(dt-dt%4)/4,Vt=dt%4*8,Fe[he]=Fe[he]|ve.charCodeAt(dt)<<Vt,dt++;return he=(dt-dt%4)/4,Vt=dt%4*8,Fe[he]=Fe[he]|128<<Vt,Fe[We-2]=pe<<3,Fe[We-1]=pe>>>29,Fe}function Re(ve){var he="",pe="",Ne,Me;for(Me=0;Me<=3;Me++)Ne=ve>>>Me*8&255,pe="0".concat(Ne.toString(16)),he=he+pe.substr(pe.length-2,2);return he}function be(ve){for(var he="",pe=0;pe<ve.length;pe++){var Ne=ve.charCodeAt(pe);Ne<128?he+=String.fromCharCode(Ne):Ne>127&&Ne<2048?(he+=String.fromCharCode(Ne>>6|192),he+=String.fromCharCode(Ne&63|128)):(he+=String.fromCharCode(Ne>>12|224),he+=String.fromCharCode(Ne>>6&63|128),he+=String.fromCharCode(Ne&63|128))}return he}var H=[],D,L,q,j,B,Q,Z,U,se,Dt=7,N=12,z=17,re=22,ae=5,Te=9,De=14,Ce=20,He=4,we=11,Se=16,ot=23,Ue=6,le=10,Ae=15,Oe=21;for(v=be(v),H=$(v),Q=1732584193,Z=4023233417,U=2562383102,se=271733878,D=0;D<H.length;D+=16)L=Q,q=Z,j=U,B=se,Q=V(Q,Z,U,se,H[D+0],Dt,3614090360),se=V(se,Q,Z,U,H[D+1],N,3905402710),U=V(U,se,Q,Z,H[D+2],z,606105819),Z=V(Z,U,se,Q,H[D+3],re,3250441966),Q=V(Q,Z,U,se,H[D+4],Dt,4118548399),se=V(se,Q,Z,U,H[D+5],N,1200080426),U=V(U,se,Q,Z,H[D+6],z,2821735955),Z=V(Z,U,se,Q,H[D+7],re,4249261313),Q=V(Q,Z,U,se,H[D+8],Dt,1770035416),se=V(se,Q,Z,U,H[D+9],N,2336552879),U=V(U,se,Q,Z,H[D+10],z,4294925233),Z=V(Z,U,se,Q,H[D+11],re,2304563134),Q=V(Q,Z,U,se,H[D+12],Dt,1804603682),se=V(se,Q,Z,U,H[D+13],N,4254626195),U=V(U,se,Q,Z,H[D+14],z,2792965006),Z=V(Z,U,se,Q,H[D+15],re,1236535329),Q=W(Q,Z,U,se,H[D+1],ae,4129170786),se=W(se,Q,Z,U,H[D+6],Te,3225465664),U=W(U,se,Q,Z,H[D+11],De,643717713),Z=W(Z,U,se,Q,H[D+0],Ce,3921069994),Q=W(Q,Z,U,se,H[D+5],ae,3593408605),se=W(se,Q,Z,U,H[D+10],Te,38016083),U=W(U,se,Q,Z,H[D+15],De,3634488961),Z=W(Z,U,se,Q,H[D+4],Ce,3889429448),Q=W(Q,Z,U,se,H[D+9],ae,568446438),se=W(se,Q,Z,U,H[D+14],Te,3275163606),U=W(U,se,Q,Z,H[D+3],De,4107603335),Z=W(Z,U,se,Q,H[D+8],Ce,1163531501),Q=W(Q,Z,U,se,H[D+13],ae,2850285829),se=W(se,Q,Z,U,H[D+2],Te,4243563512),U=W(U,se,Q,Z,H[D+7],De,1735328473),Z=W(Z,U,se,Q,H[D+12],Ce,2368359562),Q=oe(Q,Z,U,se,H[D+5],He,4294588738),se=oe(se,Q,Z,U,H[D+8],we,2272392833),U=oe(U,se,Q,Z,H[D+11],Se,1839030562),Z=oe(Z,U,se,Q,H[D+14],ot,4259657740),Q=oe(Q,Z,U,se,H[D+1],He,2763975236),se=oe(se,Q,Z,U,H[D+4],we,1272893353),U=oe(U,se,Q,Z,H[D+7],Se,4139469664),Z=oe(Z,U,se,Q,H[D+10],ot,3200236656),Q=oe(Q,Z,U,se,H[D+13],He,681279174),se=oe(se,Q,Z,U,H[D+0],we,3936430074),U=oe(U,se,Q,Z,H[D+3],Se,3572445317),Z=oe(Z,U,se,Q,H[D+6],ot,76029189),Q=oe(Q,Z,U,se,H[D+9],He,3654602809),se=oe(se,Q,Z,U,H[D+12],we,3873151461),U=oe(U,se,Q,Z,H[D+15],Se,530742520),Z=oe(Z,U,se,Q,H[D+2],ot,3299628645),Q=x(Q,Z,U,se,H[D+0],Ue,4096336452),se=x(se,Q,Z,U,H[D+7],le,1126891415),U=x(U,se,Q,Z,H[D+14],Ae,2878612391),Z=x(Z,U,se,Q,H[D+5],Oe,4237533241),Q=x(Q,Z,U,se,H[D+12],Ue,1700485571),se=x(se,Q,Z,U,H[D+3],le,2399980690),U=x(U,se,Q,Z,H[D+10],Ae,4293915773),Z=x(Z,U,se,Q,H[D+1],Oe,2240044497),Q=x(Q,Z,U,se,H[D+8],Ue,1873313359),se=x(se,Q,Z,U,H[D+15],le,4264355552),U=x(U,se,Q,Z,H[D+6],Ae,2734768916),Z=x(Z,U,se,Q,H[D+13],Oe,1309151649),Q=x(Q,Z,U,se,H[D+4],Ue,4149444226),se=x(se,Q,Z,U,H[D+11],le,3174756917),U=x(U,se,Q,Z,H[D+2],Ae,718787259),Z=x(Z,U,se,Q,H[D+9],Oe,3951481745),Q=m(Q,L),Z=m(Z,q),U=m(U,j),se=m(se,B);var Pe=Re(Q)+Re(Z)+Re(U)+Re(se);return Pe.toLowerCase()},nt.closeMediaStream=function(v){if(v)try{var S;if(v.getTracks){S=v.getTracks();var m=s(S),C;try{for(m.s();!(C=m.n()).done;){var A=C.value;A.stop()}}catch($){m.e($)}finally{m.f()}}else{S=v.getAudioTracks();var R=s(S),I;try{for(R.s();!(I=R.n()).done;){var V=I.value;V.stop()}}catch($){R.e($)}finally{R.f()}S=v.getVideoTracks();var W=s(S),oe;try{for(W.s();!(oe=W.n()).done;){var x=oe.value;x.stop()}}catch($){W.e($)}finally{W.f()}}}catch{(typeof v.stop=="function"||c(v.stop)==="object")&&v.stop()}},nt.cloneArray=function(v){return v&&v.slice()||[]},nt.cloneObject=function(v){var S=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return v&&Object.assign({},v)||S},nt}var oo={exports:{}},$n=typeof Reflect=="object"?Reflect:null,Zu=$n&&typeof $n.apply=="function"?$n.apply:function(s,i,l){return Function.prototype.apply.call(s,i,l)},Sl;$n&&typeof $n.ownKeys=="function"?Sl=$n.ownKeys:Object.getOwnPropertySymbols?Sl=function(s){return Object.getOwnPropertyNames(s).concat(Object.getOwnPropertySymbols(s))}:Sl=function(s){return Object.getOwnPropertyNames(s)};function G_(c){console&&console.warn&&console.warn(c)}var ec=Number.isNaN||function(s){return s!==s};function qe(){qe.init.call(this)}oo.exports=qe,oo.exports.once=J_,qe.EventEmitter=qe,qe.prototype._events=void 0,qe.prototype._eventsCount=0,qe.prototype._maxListeners=void 0;var tc=10;function yl(c){if(typeof c!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof c)}Object.defineProperty(qe,"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}}),qe.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},qe.prototype.setMaxListeners=function(s){if(typeof s!="number"||s<0||ec(s))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+s+".");return this._maxListeners=s,this};function sc(c){return c._maxListeners===void 0?qe.defaultMaxListeners:c._maxListeners}qe.prototype.getMaxListeners=function(){return sc(this)},qe.prototype.emit=function(s){for(var i=[],l=1;l<arguments.length;l++)i.push(arguments[l]);var a=s==="error",_=this._events;if(_!==void 0)a=a&&_.error===void 0;else if(!a)return!1;if(a){var e;if(i.length>0&&(e=i[0]),e instanceof Error)throw e;var p=new Error("Unhandled error."+(e?" ("+e.message+")":""));throw p.context=e,p}var g=_[s];if(g===void 0)return!1;if(typeof g=="function")Zu(g,this,i);else for(var n=g.length,v=ac(g,n),l=0;l<n;++l)Zu(v[l],this,i);return!0};function nc(c,s,i,l){var a,_,e;if(yl(i),_=c._events,_===void 0?(_=c._events=Object.create(null),c._eventsCount=0):(_.newListener!==void 0&&(c.emit("newListener",s,i.listener?i.listener:i),_=c._events),e=_[s]),e===void 0)e=_[s]=i,++c._eventsCount;else if(typeof e=="function"?e=_[s]=l?[i,e]:[e,i]:l?e.unshift(i):e.push(i),a=sc(c),a>0&&e.length>a&&!e.warned){e.warned=!0;var p=new Error("Possible EventEmitter memory leak detected. "+e.length+" "+String(s)+" listeners added. Use emitter.setMaxListeners() to increase limit");p.name="MaxListenersExceededWarning",p.emitter=c,p.type=s,p.count=e.length,G_(p)}return c}qe.prototype.addListener=function(s,i){return nc(this,s,i,!1)},qe.prototype.on=qe.prototype.addListener,qe.prototype.prependListener=function(s,i){return nc(this,s,i,!0)};function W_(){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,s,i){var l={fired:!1,wrapFn:void 0,target:c,type:s,listener:i},a=W_.bind(l);return a.listener=i,l.wrapFn=a,a}qe.prototype.once=function(s,i){return yl(i),this.on(s,rc(this,s,i)),this},qe.prototype.prependOnceListener=function(s,i){return yl(i),this.prependListener(s,rc(this,s,i)),this},qe.prototype.removeListener=function(s,i){var l,a,_,e,p;if(yl(i),a=this._events,a===void 0)return this;if(l=a[s],l===void 0)return this;if(l===i||l.listener===i)--this._eventsCount===0?this._events=Object.create(null):(delete a[s],a.removeListener&&this.emit("removeListener",s,l.listener||i));else if(typeof l!="function"){for(_=-1,e=l.length-1;e>=0;e--)if(l[e]===i||l[e].listener===i){p=l[e].listener,_=e;break}if(_<0)return this;_===0?l.shift():K_(l,_),l.length===1&&(a[s]=l[0]),a.removeListener!==void 0&&this.emit("removeListener",s,p||i)}return this},qe.prototype.off=qe.prototype.removeListener,qe.prototype.removeAllListeners=function(s){var i,l,a;if(l=this._events,l===void 0)return this;if(l.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):l[s]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete l[s]),this;if(arguments.length===0){var _=Object.keys(l),e;for(a=0;a<_.length;++a)e=_[a],e!=="removeListener"&&this.removeAllListeners(e);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(i=l[s],typeof i=="function")this.removeListener(s,i);else if(i!==void 0)for(a=i.length-1;a>=0;a--)this.removeListener(s,i[a]);return this};function ic(c,s,i){var l=c._events;if(l===void 0)return[];var a=l[s];return a===void 0?[]:typeof a=="function"?i?[a.listener||a]:[a]:i?Y_(a):ac(a,a.length)}qe.prototype.listeners=function(s){return ic(this,s,!0)},qe.prototype.rawListeners=function(s){return ic(this,s,!1)},qe.listenerCount=function(c,s){return typeof c.listenerCount=="function"?c.listenerCount(s):lc.call(c,s)},qe.prototype.listenerCount=lc;function lc(c){var s=this._events;if(s!==void 0){var i=s[c];if(typeof i=="function")return 1;if(i!==void 0)return i.length}return 0}qe.prototype.eventNames=function(){return this._eventsCount>0?Sl(this._events):[]};function ac(c,s){for(var i=new Array(s),l=0;l<s;++l)i[l]=c[l];return i}function K_(c,s){for(;s+1<c.length;s++)c[s]=c[s+1];c.pop()}function Y_(c){for(var s=new Array(c.length),i=0;i<s.length;++i)s[i]=c[i].listener||c[i];return s}function J_(c,s){return new Promise(function(i,l){function a(e){c.removeListener(s,_),l(e)}function _(){typeof c.removeListener=="function"&&c.removeListener("error",a),i([].slice.call(arguments))}oc(c,s,_,{once:!0}),s!=="error"&&z_(c,a,{once:!0})})}function z_(c,s,i){typeof c.on=="function"&&oc(c,"error",s,i)}function oc(c,s,i,l){if(typeof c.on=="function")l.once?c.once(s,i):c.on(s,i);else if(typeof c.addEventListener=="function")c.addEventListener(s,function a(_){l.once&&c.removeEventListener(s,a),i(_)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof c)}var ct=oo.exports,uo={exports:{}},co,uc;function X_(){if(uc)return co;uc=1;var c=1e3,s=c*60,i=s*60,l=i*24,a=l*7,_=l*365.25;co=function(v,S){S=S||{};var m=typeof v;if(m==="string"&&v.length>0)return e(v);if(m==="number"&&isFinite(v))return S.long?g(v):p(v);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(v))};function e(v){if(v=String(v),!(v.length>100)){var S=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(v);if(S){var m=parseFloat(S[1]),C=(S[2]||"ms").toLowerCase();switch(C){case"years":case"year":case"yrs":case"yr":case"y":return m*_;case"weeks":case"week":case"w":return m*a;case"days":case"day":case"d":return m*l;case"hours":case"hour":case"hrs":case"hr":case"h":return m*i;case"minutes":case"minute":case"mins":case"min":case"m":return m*s;case"seconds":case"second":case"secs":case"sec":case"s":return m*c;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return m;default:return}}}}function p(v){var S=Math.abs(v);return S>=l?Math.round(v/l)+"d":S>=i?Math.round(v/i)+"h":S>=s?Math.round(v/s)+"m":S>=c?Math.round(v/c)+"s":v+"ms"}function g(v){var S=Math.abs(v);return S>=l?n(v,S,l,"day"):S>=i?n(v,S,i,"hour"):S>=s?n(v,S,s,"minute"):S>=c?n(v,S,c,"second"):v+" ms"}function n(v,S,m,C){var A=S>=m*1.5;return Math.round(v/m)+" "+C+(A?"s":"")}return co}function Q_(c){i.debug=i,i.default=i,i.coerce=g,i.disable=_,i.enable=a,i.enabled=e,i.humanize=X_(),i.destroy=n,Object.keys(c).forEach(v=>{i[v]=c[v]}),i.names=[],i.skips=[],i.formatters={};function s(v){let S=0;for(let m=0;m<v.length;m++)S=(S<<5)-S+v.charCodeAt(m),S|=0;return i.colors[Math.abs(S)%i.colors.length]}i.selectColor=s;function i(v){let S,m=null,C,A;function R(...I){if(!R.enabled)return;const V=R,W=Number(new Date),oe=W-(S||W);V.diff=oe,V.prev=S,V.curr=W,S=W,I[0]=i.coerce(I[0]),typeof I[0]!="string"&&I.unshift("%O");let x=0;I[0]=I[0].replace(/%([a-zA-Z%])/g,(Re,be)=>{if(Re==="%%")return"%";x++;const H=i.formatters[be];if(typeof H=="function"){const D=I[x];Re=H.call(V,D),I.splice(x,1),x--}return Re}),i.formatArgs.call(V,I),(V.log||i.log).apply(V,I)}return R.namespace=v,R.useColors=i.useColors(),R.color=i.selectColor(v),R.extend=l,R.destroy=i.destroy,Object.defineProperty(R,"enabled",{enumerable:!0,configurable:!1,get:()=>m!==null?m:(C!==i.namespaces&&(C=i.namespaces,A=i.enabled(v)),A),set:I=>{m=I}}),typeof i.init=="function"&&i.init(R),R}function l(v,S){const m=i(this.namespace+(typeof S>"u"?":":S)+v);return m.log=this.log,m}function a(v){i.save(v),i.namespaces=v,i.names=[],i.skips=[];let S;const m=(typeof v=="string"?v:"").split(/[\s,]+/),C=m.length;for(S=0;S<C;S++)m[S]&&(v=m[S].replace(/\*/g,".*?"),v[0]==="-"?i.skips.push(new RegExp("^"+v.slice(1)+"$")):i.names.push(new RegExp("^"+v+"$")))}function _(){const v=[...i.names.map(p),...i.skips.map(p).map(S=>"-"+S)].join(",");return i.enable(""),v}function e(v){if(v[v.length-1]==="*")return!0;let S,m;for(S=0,m=i.skips.length;S<m;S++)if(i.skips[S].test(v))return!1;for(S=0,m=i.names.length;S<m;S++)if(i.names[S].test(v))return!0;return!1}function p(v){return v.toString().substring(2,v.toString().length-2).replace(/\.\*\?$/,"*")}function g(v){return v instanceof Error?v.stack||v.message:v}function n(){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 i.enable(i.load()),i}var Z_=Q_;(function(c,s){s.formatArgs=l,s.save=a,s.load=_,s.useColors=i,s.storage=e(),s.destroy=(()=>{let g=!1;return()=>{g||(g=!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`."))}})(),s.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"];function i(){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 l(g){if(g[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+g[0]+(this.useColors?"%c ":" ")+"+"+c.exports.humanize(this.diff),!this.useColors)return;const n="color: "+this.color;g.splice(1,0,n,"color: inherit");let v=0,S=0;g[0].replace(/%[a-zA-Z%]/g,m=>{m!=="%%"&&(v++,m==="%c"&&(S=v))}),g.splice(S,0,n)}s.log=console.debug||console.log||(()=>{});function a(g){try{g?s.storage.setItem("debug",g):s.storage.removeItem("debug")}catch{}}function _(){let g;try{g=s.storage.getItem("debug")}catch{}return!g&&typeof process<"u"&&"env"in process&&(g=process.env.DEBUG),g}function e(){try{return localStorage}catch{}}c.exports=Z_(s);const{formatters:p}=c.exports;p.j=function(g){try{return JSON.stringify(g)}catch(n){return"[UnexpectedJSONParseError]: "+n.message}}})(uo,uo.exports);var Hn=uo.exports;function eh(c,s){if(!(c instanceof s))throw new TypeError("Cannot call a class as a function")}function cc(c,s){for(var i=0;i<s.length;i++){var l=s[i];l.enumerable=l.enumerable||!1,l.configurable=!0,"value"in l&&(l.writable=!0),Object.defineProperty(c,l.key,l)}}function th(c,s,i){return s&&cc(c.prototype,s),i&&cc(c,i),c}var Fn=Hn,jn="JsSIP",ft=function(){function c(s){eh(this,c),s?(this._debug=Fn.default("".concat(jn,":").concat(s)),this._warn=Fn.default("".concat(jn,":WARN:").concat(s)),this._error=Fn.default("".concat(jn,":ERROR:").concat(s))):(this._debug=Fn.default(jn),this._warn=Fn.default("".concat(jn,":WARN")),this._error=Fn.default("".concat(jn,":ERROR"))),this._debug.log=console.info.bind(console),this._warn.log=console.warn.bind(console),this._error.log=console.error.bind(console)}return th(c,[{key:"debug",get:function(){return this._debug}},{key:"warn",get:function(){return this._warn}},{key:"error",get:function(){return this._error}}]),c}(),xt={},fc={},_c={exports:{}},hc=_c.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 s="candidate:%s %d %s %d %s %d typ %s";return s+=c.raddr!=null?" raddr %s rport %d":"%v%v",s+=c.tcptype!=null?" tcptype %s":"%v",c.generation!=null&&(s+=" generation %d"),s+=c["network-id"]!=null?" network-id %d":"%v",s+=c["network-cost"]!=null?" network-cost %d":"%v",s}},{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 s="ssrc:%d";return c.attribute!=null&&(s+=" %s",c.value!=null&&(s+=":%s")),s}},{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 s="mediaclk:";return s+=c.id!=null?"id=%s %s":"%v%s",s+=c.mediaClockValue!=null?"=%s":"",s+=c.rateNumerator!=null?" rate=%s":"",s+=c.rateDenominator!=null?"/%s":"",s}},{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(hc).forEach(function(c){var s=hc[c];s.forEach(function(i){i.reg||(i.reg=/(.*)/),i.format||(i.format="%s")})});var dc=_c.exports;(function(c){var s=function(p){return String(Number(p))===p?Number(p):p},i=function(p,g,n,v){if(v&&!n)g[v]=s(p[1]);else for(var S=0;S<n.length;S+=1)p[S+1]!=null&&(g[n[S]]=s(p[S+1]))},l=function(p,g,n){var v=p.name&&p.names;p.push&&!g[p.push]?g[p.push]=[]:v&&!g[p.name]&&(g[p.name]={});var S=p.push?{}:v?g[p.name]:g;i(n.match(p.reg),S,p.names,p.name),p.push&&g[p.push].push(S)},a=dc,_=RegExp.prototype.test.bind(/^([a-z])=(.*)/);c.parse=function(p){var g={},n=[],v=g;return p.split(/(\r\n|\r|\n)/).filter(_).forEach(function(S){var m=S[0],C=S.slice(2);m==="m"&&(n.push({rtp:[],fmtp:[]}),v=n[n.length-1]);for(var A=0;A<(a[m]||[]).length;A+=1){var R=a[m][A];if(R.reg.test(C))return l(R,v,C)}}),g.media=n,g};var e=function(p,g){var n=g.split(/=(.+)/,2);return n.length===2?p[n[0]]=s(n[1]):n.length===1&&g.length>1&&(p[n[0]]=void 0),p};c.parseParams=function(p){return p.split(/;\s?/).reduce(e,{})},c.parseFmtpConfig=c.parseParams,c.parsePayloads=function(p){return p.toString().split(" ").map(Number)},c.parseRemoteCandidates=function(p){for(var g=[],n=p.split(" ").map(s),v=0;v<n.length;v+=3)g.push({component:n[v],ip:n[v+1],port:n[v+2]});return g},c.parseImageAttributes=function(p){return p.split(" ").map(function(g){return g.substring(1,g.length-1).split(",").reduce(e,{})})},c.parseSimulcastStreamList=function(p){return p.split(";").map(function(g){return g.split(",").map(function(n){var v,S=!1;return n[0]!=="~"?v=s(n):(v=s(n.substring(1,n.length)),S=!0),{scid:v,paused:S}})})}})(fc);var fo=dc,sh=/%[sdv%]/g,nh=function(c){var s=1,i=arguments,l=i.length;return c.replace(sh,function(a){if(s>=l)return a;var _=i[s];switch(s+=1,a){case"%%":return"%";case"%s":return String(_);case"%d":return Number(_);case"%v":return""}})},mr=function(c,s,i){var l=s.format instanceof Function?s.format(s.push?i:i[s.name]):s.format,a=[c+"="+l];if(s.names)for(var _=0;_<s.names.length;_+=1){var e=s.names[_];s.name?a.push(i[s.name][e]):a.push(i[s.names[_]])}else a.push(i[s.name]);return nh.apply(null,a)},rh=["v","o","s","i","u","e","p","c","b","t","r","z","a"],ih=["i","c","b","a"],lh=function(c,s){s=s||{},c.version==null&&(c.version=0),c.name==null&&(c.name=" "),c.media.forEach(function(_){_.payloads==null&&(_.payloads="")});var i=s.outerOrder||rh,l=s.innerOrder||ih,a=[];return i.forEach(function(_){fo[_].forEach(function(e){e.name in c&&c[e.name]!=null?a.push(mr(_,e,c)):e.push in c&&c[e.push]!=null&&c[e.push].forEach(function(p){a.push(mr(_,e,p))})})}),c.media.forEach(function(_){a.push(mr("m",fo.m[0],_)),l.forEach(function(e){fo[e].forEach(function(p){p.name in _&&_[p.name]!=null?a.push(mr(e,p,_)):p.push in _&&_[p.push]!=null&&_[p.push].forEach(function(g){a.push(mr(e,p,g))})})})}),a.join(`\r
|
7
7
|
`)+`\r
|
8
|
-
`},
|
9
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var
|
10
|
-
`);for(var
|
11
|
-
`)}}catch(
|
12
|
-
`)}}catch(
|
13
|
-
`),
|
14
|
-
`),
|
15
|
-
`),this.body){var
|
8
|
+
`},nn=fc,ah=lh;xt.write=ah,xt.parse=nn.parse,xt.parseParams=nn.parseParams,xt.parseFmtpConfig=nn.parseFmtpConfig,xt.parsePayloads=nn.parsePayloads,xt.parseRemoteCandidates=nn.parseRemoteCandidates,xt.parseImageAttributes=nn.parseImageAttributes,xt.parseSimulcastStreamList=nn.parseSimulcastStreamList;function Al(c){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?Al=function(i){return typeof i}:Al=function(i){return i&&typeof Symbol=="function"&&i.constructor===Symbol&&i!==Symbol.prototype?"symbol":typeof i},Al(c)}function _o(c,s){if(typeof s!="function"&&s!==null)throw new TypeError("Super expression must either be null or a function");c.prototype=Object.create(s&&s.prototype,{constructor:{value:c,writable:!0,configurable:!0}}),s&&ho(c,s)}function ho(c,s){return ho=Object.setPrototypeOf||function(l,a){return l.__proto__=a,l},ho(c,s)}function po(c){var s=ch();return function(){var l=Cl(c),a;if(s){var _=Cl(this).constructor;a=Reflect.construct(l,arguments,_)}else a=l.apply(this,arguments);return oh(this,a)}}function oh(c,s){return s&&(Al(s)==="object"||typeof s=="function")?s:uh(c)}function uh(c){if(c===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return c}function ch(){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 Cl(c){return Cl=Object.setPrototypeOf?Object.getPrototypeOf:function(i){return i.__proto__||Object.getPrototypeOf(i)},Cl(c)}function Ht(c,s){var i;if(typeof Symbol>"u"||c[Symbol.iterator]==null){if(Array.isArray(c)||(i=fh(c))||s&&c&&typeof c.length=="number"){i&&(c=i);var l=0,a=function(){};return{s:a,n:function(){return l>=c.length?{done:!0}:{done:!1,value:c[l++]}},e:function(n){throw n},f:a}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
|
9
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var _=!0,e=!1,p;return{s:function(){i=c[Symbol.iterator]()},n:function(){var n=i.next();return _=n.done,n},e:function(n){e=!0,p=n},f:function(){try{!_&&i.return!=null&&i.return()}finally{if(e)throw p}}}}function fh(c,s){if(c){if(typeof c=="string")return pc(c,s);var i=Object.prototype.toString.call(c).slice(8,-1);if(i==="Object"&&c.constructor&&(i=c.constructor.name),i==="Map"||i==="Set")return Array.from(c);if(i==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i))return pc(c,s)}}function pc(c,s){(s==null||s>c.length)&&(s=c.length);for(var i=0,l=new Array(s);i<s;i++)l[i]=c[i];return l}function gr(c,s){if(!(c instanceof s))throw new TypeError("Cannot call a class as a function")}function mc(c,s){for(var i=0;i<s.length;i++){var l=s[i];l.enumerable=l.enumerable||!1,l.configurable=!0,"value"in l&&(l.writable=!0),Object.defineProperty(c,l.key,l)}}function Rl(c,s,i){return s&&mc(c.prototype,s),i&&mc(c,i),c}var gc=xt,_h=ft,pt=it,lt=It(),Tc=io(),hh=Zt(),mo=new _h("SIPMessage"),vc=function(){function c(s,i,l,a,_,e){if(gr(this,c),!s||!i||!l)return null;a=a||{},this.ua=l,this.headers={},this.method=s,this.ruri=i,this.body=e,this.extraHeaders=lt.cloneArray(_),this.ua.configuration.extra_headers&&(this.extraHeaders=this.extraHeaders.concat(this.ua.configuration.extra_headers)),a.route_set?this.setHeader("route",a.route_set):l.configuration.use_preloaded_route&&this.setHeader("route","<".concat(l.transport.sip_uri,";lr>")),this.setHeader("via",""),this.setHeader("max-forwards",pt.MAX_FORWARDS);var p=a.to_uri||i,g=a.to_tag?{tag:a.to_tag}:null,n=typeof a.to_display_name<"u"?a.to_display_name:null;this.to=new Tc(p,n,g),this.setHeader("to",this.to.toString());var v=a.from_uri||l.configuration.uri,S={tag:a.from_tag||lt.newTag()},m;typeof a.from_display_name<"u"?m=a.from_display_name:l.configuration.display_name?m=l.configuration.display_name:m=null,this.from=new Tc(v,m,S),this.setHeader("from",this.from.toString());var C=a.call_id||l.configuration.jssip_id+lt.createRandomToken(15);this.call_id=C,this.setHeader("call-id",C);var A=a.cseq||Math.floor(Math.random()*1e4);this.cseq=A,this.setHeader("cseq","".concat(A," ").concat(s))}return Rl(c,[{key:"setHeader",value:function(i,l){for(var a=new RegExp("^\\s*".concat(i,"\\s*:"),"i"),_=0;_<this.extraHeaders.length;_++)a.test(this.extraHeaders[_])&&this.extraHeaders.splice(_,1);this.headers[lt.headerize(i)]=Array.isArray(l)?l:[l]}},{key:"getHeader",value:function(i){var l=this.headers[lt.headerize(i)];if(l){if(l[0])return l[0]}else{var a=new RegExp("^\\s*".concat(i,"\\s*:"),"i"),_=Ht(this.extraHeaders),e;try{for(_.s();!(e=_.n()).done;){var p=e.value;if(a.test(p))return p.substring(p.indexOf(":")+1).trim()}}catch(g){_.e(g)}finally{_.f()}}}},{key:"getHeaders",value:function(i){var l=this.headers[lt.headerize(i)],a=[];if(l){var _=Ht(l),e;try{for(_.s();!(e=_.n()).done;){var p=e.value;a.push(p)}}catch(m){_.e(m)}finally{_.f()}return a}else{var g=new RegExp("^\\s*".concat(i,"\\s*:"),"i"),n=Ht(this.extraHeaders),v;try{for(n.s();!(v=n.n()).done;){var S=v.value;g.test(S)&&a.push(S.substring(S.indexOf(":")+1).trim())}}catch(m){n.e(m)}finally{n.f()}return a}}},{key:"hasHeader",value:function(i){if(this.headers[lt.headerize(i)])return!0;var l=new RegExp("^\\s*".concat(i,"\\s*:"),"i"),a=Ht(this.extraHeaders),_;try{for(a.s();!(_=a.n()).done;){var e=_.value;if(l.test(e))return!0}}catch(p){a.e(p)}finally{a.f()}return!1}},{key:"parseSDP",value:function(i){return!i&&this.sdp?this.sdp:(this.sdp=gc.parse(this.body||""),this.sdp)}},{key:"toString",value:function(){var i="".concat(this.method," ").concat(this.ruri,` SIP/2.0\r
|
10
|
+
`);for(var l in this.headers)if(Object.prototype.hasOwnProperty.call(this.headers,l)){var a=Ht(this.headers[l]),_;try{for(a.s();!(_=a.n()).done;){var e=_.value;i+="".concat(l,": ").concat(e,`\r
|
11
|
+
`)}}catch(C){a.e(C)}finally{a.f()}}var p=Ht(this.extraHeaders),g;try{for(p.s();!(g=p.n()).done;){var n=g.value;i+="".concat(n.trim(),`\r
|
12
|
+
`)}}catch(C){p.e(C)}finally{p.f()}var v=[];switch(this.method){case pt.REGISTER:v.push("path","gruu");break;case pt.INVITE:this.ua.configuration.session_timers&&v.push("timer"),(this.ua.contact.pub_gruu||this.ua.contact.temp_gruu)&&v.push("gruu"),v.push("ice","replaces");break;case pt.UPDATE:this.ua.configuration.session_timers&&v.push("timer"),v.push("ice");break}v.push("outbound");var S=this.ua.configuration.user_agent||pt.USER_AGENT;if(i+="Allow: ".concat(pt.ALLOWED_METHODS,`\r
|
13
|
+
`),i+="Supported: ".concat(v,`\r
|
14
|
+
`),i+="User-Agent: ".concat(S,`\r
|
15
|
+
`),this.body){var m=lt.str_utf8_length(this.body);i+="Content-Length: ".concat(m,`\r
|
16
16
|
\r
|
17
|
-
`),
|
17
|
+
`),i+=this.body}else i+=`Content-Length: 0\r
|
18
18
|
\r
|
19
|
-
`;return
|
20
|
-
`);if(this.method===
|
21
|
-
`)}}catch(
|
22
|
-
`)}}catch(
|
23
|
-
`),
|
24
|
-
`),
|
25
|
-
`),
|
26
|
-
`);var
|
27
|
-
`)}}catch(
|
28
|
-
`),
|
29
|
-
`)):
|
30
|
-
`):
|
31
|
-
`)),
|
32
|
-
`),
|
33
|
-
`,
|
19
|
+
`;return i}},{key:"clone",value:function(){var i=new c(this.method,this.ruri,this.ua);return Object.keys(this.headers).forEach(function(l){i.headers[l]=this.headers[l].slice()},this),i.body=this.body,i.extraHeaders=lt.cloneArray(this.extraHeaders),i.to=this.to,i.from=this.from,i.call_id=this.call_id,i.cseq=this.cseq,i}}]),c}(),dh=function(c){_o(i,c);var s=po(i);function i(l,a,_,e,p){var g;return gr(this,i),g=s.call(this,pt.INVITE,l,a,_,e,p),g.transaction=null,g}return Rl(i,[{key:"cancel",value:function(a){this.transaction.cancel(a)}},{key:"clone",value:function(){var a=new i(this.ruri,this.ua);return Object.keys(this.headers).forEach(function(_){a.headers[_]=this.headers[_].slice()},this),a.body=this.body,a.extraHeaders=lt.cloneArray(this.extraHeaders),a.to=this.to,a.from=this.from,a.call_id=this.call_id,a.cseq=this.cseq,a.transaction=this.transaction,a}}]),i}(vc),Ec=function(){function c(){gr(this,c),this.data=null,this.headers=null,this.method=null,this.via=null,this.via_branch=null,this.call_id=null,this.cseq=null,this.from=null,this.from_tag=null,this.to=null,this.to_tag=null,this.body=null,this.sdp=null}return Rl(c,[{key:"addHeader",value:function(i,l){var a={raw:l};i=lt.headerize(i),this.headers[i]?this.headers[i].push(a):this.headers[i]=[a]}},{key:"getHeader",value:function(i){var l=this.headers[lt.headerize(i)];if(l){if(l[0])return l[0].raw}else return}},{key:"getHeaders",value:function(i){var l=this.headers[lt.headerize(i)],a=[];if(!l)return[];var _=Ht(l),e;try{for(_.s();!(e=_.n()).done;){var p=e.value;a.push(p.raw)}}catch(g){_.e(g)}finally{_.f()}return a}},{key:"hasHeader",value:function(i){return!!this.headers[lt.headerize(i)]}},{key:"parseHeader",value:function(i){var l=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;if(i=lt.headerize(i),this.headers[i]){if(l>=this.headers[i].length){mo.debug('not so many "'.concat(i,'" headers present'));return}}else{mo.debug('header "'.concat(i,'" not present'));return}var a=this.headers[i][l],_=a.raw;if(a.parsed)return a.parsed;var e=hh.parse(_,i.replace(/-/g,"_"));if(e===-1){this.headers[i].splice(l,1),mo.debug('error parsing "'.concat(i,'" header field with value "').concat(_,'"'));return}else return a.parsed=e,e}},{key:"s",value:function(i,l){return this.parseHeader(i,l)}},{key:"setHeader",value:function(i,l){var a={raw:l};this.headers[lt.headerize(i)]=[a]}},{key:"parseSDP",value:function(i){return!i&&this.sdp?this.sdp:(this.sdp=gc.parse(this.body||""),this.sdp)}},{key:"toString",value:function(){return this.data}}]),c}(),ph=function(c){_o(i,c);var s=po(i);function i(l){var a;return gr(this,i),a=s.call(this),a.ua=l,a.headers={},a.ruri=null,a.transport=null,a.server_transaction=null,a}return Rl(i,[{key:"reply",value:function(a,_,e,p,g,n){var v=[],S=this.getHeader("To");if(a=a||null,_=_||null,!a||a<100||a>699)throw new TypeError("Invalid status_code: ".concat(a));if(_&&typeof _!="string"&&!(_ instanceof String))throw new TypeError("Invalid reason_phrase: ".concat(_));_=_||pt.REASON_PHRASE[a]||"",e=lt.cloneArray(e),this.ua.configuration.extra_headers&&(e=e.concat(this.ua.configuration.extra_headers));var m="SIP/2.0 ".concat(a," ").concat(_,`\r
|
20
|
+
`);if(this.method===pt.INVITE&&a>100&&a<=200){var C=this.getHeaders("record-route"),A=Ht(C),R;try{for(A.s();!(R=A.n()).done;){var I=R.value;m+="Record-Route: ".concat(I,`\r
|
21
|
+
`)}}catch(D){A.e(D)}finally{A.f()}}var V=this.getHeaders("via"),W=Ht(V),oe;try{for(W.s();!(oe=W.n()).done;){var x=oe.value;m+="Via: ".concat(x,`\r
|
22
|
+
`)}}catch(D){W.e(D)}finally{W.f()}!this.to_tag&&a>100?S+=";tag=".concat(lt.newTag()):this.to_tag&&!this.s("to").hasParam("tag")&&(S+=";tag=".concat(this.to_tag)),m+="To: ".concat(S,`\r
|
23
|
+
`),m+="From: ".concat(this.getHeader("From"),`\r
|
24
|
+
`),m+="Call-ID: ".concat(this.call_id,`\r
|
25
|
+
`),m+="CSeq: ".concat(this.cseq," ").concat(this.method,`\r
|
26
|
+
`);var $=Ht(e),Re;try{for($.s();!(Re=$.n()).done;){var be=Re.value;m+="".concat(be.trim(),`\r
|
27
|
+
`)}}catch(D){$.e(D)}finally{$.f()}switch(this.method){case pt.INVITE:this.ua.configuration.session_timers&&v.push("timer"),(this.ua.contact.pub_gruu||this.ua.contact.temp_gruu)&&v.push("gruu"),v.push("ice","replaces");break;case pt.UPDATE:this.ua.configuration.session_timers&&v.push("timer"),p&&v.push("ice"),v.push("replaces")}if(v.push("outbound"),this.method===pt.OPTIONS?(m+="Allow: ".concat(pt.ALLOWED_METHODS,`\r
|
28
|
+
`),m+="Accept: ".concat(pt.ACCEPTED_BODY_TYPES,`\r
|
29
|
+
`)):a===405?m+="Allow: ".concat(pt.ALLOWED_METHODS,`\r
|
30
|
+
`):a===415&&(m+="Accept: ".concat(pt.ACCEPTED_BODY_TYPES,`\r
|
31
|
+
`)),m+="Supported: ".concat(v,`\r
|
32
|
+
`),p){var H=lt.str_utf8_length(p);m+=`Content-Type: application/sdp\r
|
33
|
+
`,m+="Content-Length: ".concat(H,`\r
|
34
34
|
\r
|
35
|
-
`),
|
35
|
+
`),m+=p}else m+="Content-Length: ".concat(0,`\r
|
36
36
|
\r
|
37
|
-
`);this.server_transaction.receiveResponse(
|
38
|
-
`),
|
39
|
-
`)}}catch(
|
40
|
-
`),
|
41
|
-
`),
|
42
|
-
`),
|
43
|
-
`),this.ua.configuration.extra_headers){var
|
44
|
-
`)}}catch(
|
37
|
+
`);this.server_transaction.receiveResponse(a,m,g,n)}},{key:"reply_sl",value:function(){var a=arguments.length>0&&arguments[0]!==void 0?arguments[0]:null,_=arguments.length>1&&arguments[1]!==void 0?arguments[1]:null,e=this.getHeaders("via");if(!a||a<100||a>699)throw new TypeError("Invalid status_code: ".concat(a));if(_&&typeof _!="string"&&!(_ instanceof String))throw new TypeError("Invalid reason_phrase: ".concat(_));_=_||pt.REASON_PHRASE[a]||"";var p="SIP/2.0 ".concat(a," ").concat(_,`\r
|
38
|
+
`),g=Ht(e),n;try{for(g.s();!(n=g.n()).done;){var v=n.value;p+="Via: ".concat(v,`\r
|
39
|
+
`)}}catch(R){g.e(R)}finally{g.f()}var S=this.getHeader("To");if(!this.to_tag&&a>100?S+=";tag=".concat(lt.newTag()):this.to_tag&&!this.s("to").hasParam("tag")&&(S+=";tag=".concat(this.to_tag)),p+="To: ".concat(S,`\r
|
40
|
+
`),p+="From: ".concat(this.getHeader("From"),`\r
|
41
|
+
`),p+="Call-ID: ".concat(this.call_id,`\r
|
42
|
+
`),p+="CSeq: ".concat(this.cseq," ").concat(this.method,`\r
|
43
|
+
`),this.ua.configuration.extra_headers){var m=Ht(this.ua.configuration.extra_headers),C;try{for(m.s();!(C=m.n()).done;){var A=C.value;p+="".concat(A.trim(),`\r
|
44
|
+
`)}}catch(R){m.e(R)}finally{m.f()}}p+="Content-Length: ".concat(0,`\r
|
45
45
|
\r
|
46
|
-
`),this.transport.send(v)}}]),a}(Cc),v_=function(u){Ro(a,u);var n=Io(a);function a(){var e;return mi(this,a),e=n.call(this),e.headers={},e.status_code=null,e.reason_phrase=null,e}return a}(Cc),pn={OutgoingRequest:Ec,InitialOutgoingInviteRequest:m_,IncomingRequest:g_,IncomingResponse:v_};function T_(u,n){if(!(u instanceof n))throw new TypeError("Cannot call a class as a function")}function Sc(u,n){for(var a=0;a<n.length;a++){var e=n[a];e.enumerable=e.enumerable||!1,e.configurable=!0,"value"in e&&(e.writable=!0),Object.defineProperty(u,e.key,e)}}function E_(u,n,a){return n&&Sc(u.prototype,n),a&&Sc(u,a),u}var C_=St,mn=Mt(),As=new C_("DigestAuthentication"),S_=function(){function u(n){T_(this,u),this._credentials=n,this._cnonce=null,this._nc=0,this._ncHex="00000000",this._algorithm=null,this._realm=null,this._nonce=null,this._opaque=null,this._stale=null,this._qop=null,this._method=null,this._uri=null,this._ha1=null,this._response=null}return E_(u,[{key:"get",value:function(a){switch(a){case"realm":return this._realm;case"ha1":return this._ha1;default:As.warn('get() | cannot get "%s" parameter',a);return}}},{key:"authenticate",value:function(a,e){var o=a.method,p=a.ruri,t=a.body,v=arguments.length>2&&arguments[2]!==void 0?arguments[2]:null;if(this._algorithm=e.algorithm,this._realm=e.realm,this._nonce=e.nonce,this._opaque=e.opaque,this._stale=e.stale,this._algorithm){if(this._algorithm!=="MD5")return As.warn('authenticate() | challenge with Digest algorithm different than "MD5", authentication aborted'),!1}else this._algorithm="MD5";if(!this._nonce)return As.warn("authenticate() | challenge without Digest nonce, authentication aborted"),!1;if(!this._realm)return As.warn("authenticate() | challenge without Digest realm, authentication aborted"),!1;if(!this._credentials.password){if(!this._credentials.ha1)return As.warn("authenticate() | no plain SIP password nor ha1 provided, authentication aborted"),!1;if(this._credentials.realm!==this._realm)return As.warn('authenticate() | no plain SIP password, and stored `realm` does not match the given `realm`, cannot authenticate [stored:"%s", given:"%s"]',this._credentials.realm,this._realm),!1}if(e.qop)if(e.qop.indexOf("auth-int")>-1)this._qop="auth-int";else if(e.qop.indexOf("auth")>-1)this._qop="auth";else return As.warn('authenticate() | challenge without Digest qop different than "auth" or "auth-int", authentication aborted'),!1;else this._qop=null;this._method=o,this._uri=p,this._cnonce=v||mn.createRandomToken(12),this._nc+=1;var C=Number(this._nc).toString(16);this._ncHex="00000000".substr(0,8-C.length)+C,this._nc===4294967296&&(this._nc=1,this._ncHex="00000001"),this._credentials.password?this._ha1=mn.calculateMD5("".concat(this._credentials.username,":").concat(this._realm,":").concat(this._credentials.password)):this._ha1=this._credentials.ha1;var l,A;return this._qop==="auth"?(l="".concat(this._method,":").concat(this._uri),A=mn.calculateMD5(l),As.debug('authenticate() | using qop=auth [a2:"%s"]',l),this._response=mn.calculateMD5("".concat(this._ha1,":").concat(this._nonce,":").concat(this._ncHex,":").concat(this._cnonce,":auth:").concat(A))):this._qop==="auth-int"?(l="".concat(this._method,":").concat(this._uri,":").concat(mn.calculateMD5(t||"")),A=mn.calculateMD5(l),As.debug('authenticate() | using qop=auth-int [a2:"%s"]',l),this._response=mn.calculateMD5("".concat(this._ha1,":").concat(this._nonce,":").concat(this._ncHex,":").concat(this._cnonce,":auth-int:").concat(A))):this._qop===null&&(l="".concat(this._method,":").concat(this._uri),A=mn.calculateMD5(l),As.debug('authenticate() | using qop=null [a2:"%s"]',l),this._response=mn.calculateMD5("".concat(this._ha1,":").concat(this._nonce,":").concat(A))),As.debug("authenticate() | response generated"),!0}},{key:"toString",value:function(){var a=[];if(!this._response)throw new Error("response field does not exist, cannot generate Authorization header");return a.push("algorithm=".concat(this._algorithm)),a.push('username="'.concat(this._credentials.username,'"')),a.push('realm="'.concat(this._realm,'"')),a.push('nonce="'.concat(this._nonce,'"')),a.push('uri="'.concat(this._uri,'"')),a.push('response="'.concat(this._response,'"')),this._opaque&&a.push('opaque="'.concat(this._opaque,'"')),this._qop&&(a.push("qop=".concat(this._qop)),a.push('cnonce="'.concat(this._cnonce,'"')),a.push("nc=".concat(this._ncHex))),"Digest ".concat(a.join(", "))}}]),u}(),gn=500,A_=4e3,Ac=5e3,yc={T1:gn,T2:A_,T4:Ac,TIMER_B:64*gn,TIMER_D:0*gn,TIMER_F:64*gn,TIMER_H:64*gn,TIMER_I:0*gn,TIMER_J:0*gn,TIMER_K:0*Ac,TIMER_L:64*gn,TIMER_M:64*gn,PROVISIONAL_RESPONSE_INTERVAL:6e4};function ma(u){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?ma=function(a){return typeof a}:ma=function(a){return a&&typeof Symbol=="function"&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a},ma(u)}function gi(u,n){if(!(u instanceof n))throw new TypeError("Cannot call a class as a function")}function Rc(u,n){for(var a=0;a<n.length;a++){var e=n[a];e.enumerable=e.enumerable||!1,e.configurable=!0,"value"in e&&(e.writable=!0),Object.defineProperty(u,e.key,e)}}function vi(u,n,a){return n&&Rc(u.prototype,n),a&&Rc(u,a),u}function Ti(u,n){if(typeof n!="function"&&n!==null)throw new TypeError("Super expression must either be null or a function");u.prototype=Object.create(n&&n.prototype,{constructor:{value:u,writable:!0,configurable:!0}}),n&&Oo(u,n)}function Oo(u,n){return Oo=Object.setPrototypeOf||function(e,o){return e.__proto__=o,e},Oo(u,n)}function Ei(u){var n=R_();return function(){var e=ga(u),o;if(n){var p=ga(this).constructor;o=Reflect.construct(e,arguments,p)}else o=e.apply(this,arguments);return y_(this,o)}}function y_(u,n){return n&&(ma(n)==="object"||typeof n=="function")?n:Yn(u)}function Yn(u){if(u===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return u}function R_(){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 ga(u){return ga=Object.setPrototypeOf?Object.getPrototypeOf:function(a){return a.__proto__||Object.getPrototypeOf(a)},ga(u)}var Ci=Ct.EventEmitter,Si=St,Ai=pt,bc=pn,Ws=yc,Ic=new Si("NonInviteClientTransaction"),va=new Si("InviteClientTransaction"),b_=new Si("AckClientTransaction"),wc=new Si("NonInviteServerTransaction"),Ta=new Si("InviteServerTransaction"),me={STATUS_TRYING:1,STATUS_PROCEEDING:2,STATUS_CALLING:3,STATUS_ACCEPTED:4,STATUS_COMPLETED:5,STATUS_TERMINATED:6,STATUS_CONFIRMED:7,NON_INVITE_CLIENT:"nict",NON_INVITE_SERVER:"nist",INVITE_CLIENT:"ict",INVITE_SERVER:"ist"},I_=function(u){Ti(a,u);var n=Ei(a);function a(e,o,p,t){var v;gi(this,a),v=n.call(this),v.type=me.NON_INVITE_CLIENT,v.id="z9hG4bK".concat(Math.floor(Math.random()*1e7)),v.ua=e,v.transport=o,v.request=p,v.eventHandlers=t;var C="SIP/2.0/".concat(o.via_transport);return C+=" ".concat(e.configuration.via_host,";branch=").concat(v.id),v.request.setHeader("via",C),v.ua.newTransaction(Yn(v)),v}return vi(a,[{key:"stateChanged",value:function(o){this.state=o,this.emit("stateChanged")}},{key:"send",value:function(){var o=this;this.stateChanged(me.STATUS_TRYING),this.F=setTimeout(function(){o.timer_F()},Ws.TIMER_F),this.transport.send(this.request)||this.onTransportError()}},{key:"onTransportError",value:function(){Ic.debug("transport error occurred, deleting transaction ".concat(this.id)),clearTimeout(this.F),clearTimeout(this.K),this.stateChanged(me.STATUS_TERMINATED),this.ua.destroyTransaction(this),this.eventHandlers.onTransportError()}},{key:"timer_F",value:function(){Ic.debug("Timer F expired for transaction ".concat(this.id)),this.stateChanged(me.STATUS_TERMINATED),this.ua.destroyTransaction(this),this.eventHandlers.onRequestTimeout()}},{key:"timer_K",value:function(){this.stateChanged(me.STATUS_TERMINATED),this.ua.destroyTransaction(this)}},{key:"receiveResponse",value:function(o){var p=this,t=o.status_code;if(t<200)switch(this.state){case me.STATUS_TRYING:case me.STATUS_PROCEEDING:this.stateChanged(me.STATUS_PROCEEDING),this.eventHandlers.onReceiveResponse(o);break}else switch(this.state){case me.STATUS_TRYING:case me.STATUS_PROCEEDING:this.stateChanged(me.STATUS_COMPLETED),clearTimeout(this.F),t===408?this.eventHandlers.onRequestTimeout():this.eventHandlers.onReceiveResponse(o),this.K=setTimeout(function(){p.timer_K()},Ws.TIMER_K);break;case me.STATUS_COMPLETED:break}}},{key:"C",get:function(){return me}}]),a}(Ci),w_=function(u){Ti(a,u);var n=Ei(a);function a(e,o,p,t){var v;gi(this,a),v=n.call(this),v.type=me.INVITE_CLIENT,v.id="z9hG4bK".concat(Math.floor(Math.random()*1e7)),v.ua=e,v.transport=o,v.request=p,v.eventHandlers=t,p.transaction=Yn(v);var C="SIP/2.0/".concat(o.via_transport);return C+=" ".concat(e.configuration.via_host,";branch=").concat(v.id),v.request.setHeader("via",C),v.ua.newTransaction(Yn(v)),v}return vi(a,[{key:"stateChanged",value:function(o){this.state=o,this.emit("stateChanged")}},{key:"send",value:function(){var o=this;this.stateChanged(me.STATUS_CALLING),this.B=setTimeout(function(){o.timer_B()},Ws.TIMER_B),this.transport.send(this.request)||this.onTransportError()}},{key:"onTransportError",value:function(){clearTimeout(this.B),clearTimeout(this.D),clearTimeout(this.M),this.state!==me.STATUS_ACCEPTED&&(va.debug("transport error occurred, deleting transaction ".concat(this.id)),this.eventHandlers.onTransportError()),this.stateChanged(me.STATUS_TERMINATED),this.ua.destroyTransaction(this)}},{key:"timer_M",value:function(){va.debug("Timer M expired for transaction ".concat(this.id)),this.state===me.STATUS_ACCEPTED&&(clearTimeout(this.B),this.stateChanged(me.STATUS_TERMINATED),this.ua.destroyTransaction(this))}},{key:"timer_B",value:function(){va.debug("Timer B expired for transaction ".concat(this.id)),this.state===me.STATUS_CALLING&&(this.stateChanged(me.STATUS_TERMINATED),this.ua.destroyTransaction(this),this.eventHandlers.onRequestTimeout())}},{key:"timer_D",value:function(){va.debug("Timer D expired for transaction ".concat(this.id)),clearTimeout(this.B),this.stateChanged(me.STATUS_TERMINATED),this.ua.destroyTransaction(this)}},{key:"sendACK",value:function(o){var p=this,t=new bc.OutgoingRequest(Ai.ACK,this.request.ruri,this.ua,{route_set:this.request.getHeaders("route"),call_id:this.request.getHeader("call-id"),cseq:this.request.cseq});t.setHeader("from",this.request.getHeader("from")),t.setHeader("via",this.request.getHeader("via")),t.setHeader("to",o.getHeader("to")),this.D=setTimeout(function(){p.timer_D()},Ws.TIMER_D),this.transport.send(t)}},{key:"cancel",value:function(o){if(this.state===me.STATUS_PROCEEDING){var p=new bc.OutgoingRequest(Ai.CANCEL,this.request.ruri,this.ua,{route_set:this.request.getHeaders("route"),call_id:this.request.getHeader("call-id"),cseq:this.request.cseq});p.setHeader("from",this.request.getHeader("from")),p.setHeader("via",this.request.getHeader("via")),p.setHeader("to",this.request.getHeader("to")),o&&p.setHeader("reason",o),this.transport.send(p)}}},{key:"receiveResponse",value:function(o){var p=this,t=o.status_code;if(t>=100&&t<=199)switch(this.state){case me.STATUS_CALLING:this.stateChanged(me.STATUS_PROCEEDING),this.eventHandlers.onReceiveResponse(o);break;case me.STATUS_PROCEEDING:this.eventHandlers.onReceiveResponse(o);break}else if(t>=200&&t<=299)switch(this.state){case me.STATUS_CALLING:case me.STATUS_PROCEEDING:this.stateChanged(me.STATUS_ACCEPTED),this.M=setTimeout(function(){p.timer_M()},Ws.TIMER_M),this.eventHandlers.onReceiveResponse(o);break;case me.STATUS_ACCEPTED:this.eventHandlers.onReceiveResponse(o);break}else if(t>=300&&t<=699)switch(this.state){case me.STATUS_CALLING:case me.STATUS_PROCEEDING:this.stateChanged(me.STATUS_COMPLETED),this.sendACK(o),this.eventHandlers.onReceiveResponse(o);break;case me.STATUS_COMPLETED:this.sendACK(o);break}}},{key:"C",get:function(){return me}}]),a}(Ci),O_=function(u){Ti(a,u);var n=Ei(a);function a(e,o,p,t){var v;gi(this,a),v=n.call(this),v.id="z9hG4bK".concat(Math.floor(Math.random()*1e7)),v.transport=o,v.request=p,v.eventHandlers=t;var C="SIP/2.0/".concat(o.via_transport);return C+=" ".concat(e.configuration.via_host,";branch=").concat(v.id),v.request.setHeader("via",C),v}return vi(a,[{key:"send",value:function(){this.transport.send(this.request)||this.onTransportError()}},{key:"onTransportError",value:function(){b_.debug("transport error occurred for transaction ".concat(this.id)),this.eventHandlers.onTransportError()}},{key:"C",get:function(){return me}}]),a}(Ci),D_=function(u){Ti(a,u);var n=Ei(a);function a(e,o,p){var t;return gi(this,a),t=n.call(this),t.type=me.NON_INVITE_SERVER,t.id=p.via_branch,t.ua=e,t.transport=o,t.request=p,t.last_response="",p.server_transaction=Yn(t),t.state=me.STATUS_TRYING,e.newTransaction(Yn(t)),t}return vi(a,[{key:"stateChanged",value:function(o){this.state=o,this.emit("stateChanged")}},{key:"timer_J",value:function(){wc.debug("Timer J expired for transaction ".concat(this.id)),this.stateChanged(me.STATUS_TERMINATED),this.ua.destroyTransaction(this)}},{key:"onTransportError",value:function(){this.transportError||(this.transportError=!0,wc.debug("transport error occurred, deleting transaction ".concat(this.id)),clearTimeout(this.J),this.stateChanged(me.STATUS_TERMINATED),this.ua.destroyTransaction(this))}},{key:"receiveResponse",value:function(o,p,t,v){var C=this;if(o===100)switch(this.state){case me.STATUS_TRYING:this.stateChanged(me.STATUS_PROCEEDING),this.transport.send(p)||this.onTransportError();break;case me.STATUS_PROCEEDING:this.last_response=p,this.transport.send(p)?t&&t():(this.onTransportError(),v&&v());break}else if(o>=200&&o<=699)switch(this.state){case me.STATUS_TRYING:case me.STATUS_PROCEEDING:this.stateChanged(me.STATUS_COMPLETED),this.last_response=p,this.J=setTimeout(function(){C.timer_J()},Ws.TIMER_J),this.transport.send(p)?t&&t():(this.onTransportError(),v&&v());break;case me.STATUS_COMPLETED:break}}},{key:"C",get:function(){return me}}]),a}(Ci),N_=function(u){Ti(a,u);var n=Ei(a);function a(e,o,p){var t;return gi(this,a),t=n.call(this),t.type=me.INVITE_SERVER,t.id=p.via_branch,t.ua=e,t.transport=o,t.request=p,t.last_response="",p.server_transaction=Yn(t),t.state=me.STATUS_PROCEEDING,e.newTransaction(Yn(t)),t.resendProvisionalTimer=null,p.reply(100),t}return vi(a,[{key:"stateChanged",value:function(o){this.state=o,this.emit("stateChanged")}},{key:"timer_H",value:function(){Ta.debug("Timer H expired for transaction ".concat(this.id)),this.state===me.STATUS_COMPLETED&&Ta.debug("ACK not received, dialog will be terminated"),this.stateChanged(me.STATUS_TERMINATED),this.ua.destroyTransaction(this)}},{key:"timer_I",value:function(){this.stateChanged(me.STATUS_TERMINATED),this.ua.destroyTransaction(this)}},{key:"timer_L",value:function(){Ta.debug("Timer L expired for transaction ".concat(this.id)),this.state===me.STATUS_ACCEPTED&&(this.stateChanged(me.STATUS_TERMINATED),this.ua.destroyTransaction(this))}},{key:"onTransportError",value:function(){this.transportError||(this.transportError=!0,Ta.debug("transport error occurred, deleting transaction ".concat(this.id)),this.resendProvisionalTimer!==null&&(clearInterval(this.resendProvisionalTimer),this.resendProvisionalTimer=null),clearTimeout(this.L),clearTimeout(this.H),clearTimeout(this.I),this.stateChanged(me.STATUS_TERMINATED),this.ua.destroyTransaction(this))}},{key:"resend_provisional",value:function(){this.transport.send(this.last_response)||this.onTransportError()}},{key:"receiveResponse",value:function(o,p,t,v){var C=this;if(o>=100&&o<=199)switch(this.state){case me.STATUS_PROCEEDING:this.transport.send(p)||this.onTransportError(),this.last_response=p;break}if(o>100&&o<=199&&this.state===me.STATUS_PROCEEDING)this.resendProvisionalTimer===null&&(this.resendProvisionalTimer=setInterval(function(){C.resend_provisional()},Ws.PROVISIONAL_RESPONSE_INTERVAL));else if(o>=200&&o<=299)switch(this.state){case me.STATUS_PROCEEDING:this.stateChanged(me.STATUS_ACCEPTED),this.last_response=p,this.L=setTimeout(function(){C.timer_L()},Ws.TIMER_L),this.resendProvisionalTimer!==null&&(clearInterval(this.resendProvisionalTimer),this.resendProvisionalTimer=null);case me.STATUS_ACCEPTED:this.transport.send(p)?t&&t():(this.onTransportError(),v&&v());break}else if(o>=300&&o<=699)switch(this.state){case me.STATUS_PROCEEDING:this.resendProvisionalTimer!==null&&(clearInterval(this.resendProvisionalTimer),this.resendProvisionalTimer=null),this.transport.send(p)?(this.stateChanged(me.STATUS_COMPLETED),this.H=setTimeout(function(){C.timer_H()},Ws.TIMER_H),t&&t()):(this.onTransportError(),v&&v());break}}},{key:"C",get:function(){return me}}]),a}(Ci);function U_(u,n){var a=u._transactions,e;switch(n.method){case Ai.INVITE:if(e=a.ist[n.via_branch],e){switch(e.state){case me.STATUS_PROCEEDING:e.transport.send(e.last_response);break;case me.STATUS_ACCEPTED:break}return!0}break;case Ai.ACK:if(e=a.ist[n.via_branch],e){if(e.state===me.STATUS_ACCEPTED)return!1;if(e.state===me.STATUS_COMPLETED)return e.state=me.STATUS_CONFIRMED,e.I=setTimeout(function(){e.timer_I()},Ws.TIMER_I),!0}else return!1;break;case Ai.CANCEL:return e=a.ist[n.via_branch],e?(n.reply_sl(200),e.state!==me.STATUS_PROCEEDING):(n.reply_sl(481),!0);default:if(e=a.nist[n.via_branch],e){switch(e.state){case me.STATUS_TRYING:break;case me.STATUS_PROCEEDING:case me.STATUS_COMPLETED:e.transport.send(e.last_response);break}return!0}break}}var yi={C:me,NonInviteClientTransaction:I_,InviteClientTransaction:w_,AckClientTransaction:O_,NonInviteServerTransaction:D_,InviteServerTransaction:N_,checkTransaction:U_};function x_(u,n){if(!(u instanceof n))throw new TypeError("Cannot call a class as a function")}function Oc(u,n){for(var a=0;a<n.length;a++){var e=n[a];e.enumerable=e.enumerable||!1,e.configurable=!0,"value"in e&&(e.writable=!0),Object.defineProperty(u,e.key,e)}}function P_(u,n,a){return n&&Oc(u.prototype,n),a&&Oc(u,a),u}var M_=St,Dc=pt,k_=S_,Do=yi,L_=new M_("RequestSender"),No={onRequestTimeout:function(){},onTransportError:function(){},onReceiveResponse:function(){},onAuthenticated:function(){}},Ri=function(){function u(n,a,e){x_(this,u),this._ua=n,this._eventHandlers=e,this._method=a.method,this._request=a,this._auth=null,this._challenged=!1,this._staled=!1;for(var o in No)Object.prototype.hasOwnProperty.call(No,o)&&(this._eventHandlers[o]||(this._eventHandlers[o]=No[o]));n.status===n.C.STATUS_USER_CLOSED&&(this._method!==Dc.BYE||this._method!==Dc.ACK)&&this._eventHandlers.onTransportError()}return P_(u,[{key:"send",value:function(){var a=this,e={onRequestTimeout:function(){a._eventHandlers.onRequestTimeout()},onTransportError:function(){a._eventHandlers.onTransportError()},onReceiveResponse:function(p){a._receiveResponse(p)}};switch(this._method){case"INVITE":this.clientTransaction=new Do.InviteClientTransaction(this._ua,this._ua.transport,this._request,e);break;case"ACK":this.clientTransaction=new Do.AckClientTransaction(this._ua,this._ua.transport,this._request,e);break;default:this.clientTransaction=new Do.NonInviteClientTransaction(this._ua,this._ua.transport,this._request,e)}this._ua._configuration.authorization_jwt&&this._request.setHeader("Authorization",this._ua._configuration.authorization_jwt),this.clientTransaction.send()}},{key:"_receiveResponse",value:function(a){var e,o,p=a.status_code;if((p===401||p===407)&&(this._ua.configuration.password!==null||this._ua.configuration.ha1!==null)){if(a.status_code===401?(e=a.parseHeader("www-authenticate"),o="authorization"):(e=a.parseHeader("proxy-authenticate"),o="proxy-authorization"),!e){L_.debug("".concat(a.status_code," with wrong or missing challenge, cannot authenticate")),this._eventHandlers.onReceiveResponse(a);return}if(!this._challenged||!this._staled&&e.stale===!0){if(this._auth||(this._auth=new k_({username:this._ua.configuration.authorization_user,password:this._ua.configuration.password,realm:this._ua.configuration.realm,ha1:this._ua.configuration.ha1})),!this._auth.authenticate(this._request,e)){this._eventHandlers.onReceiveResponse(a);return}this._challenged=!0,this._ua.set("realm",this._auth.get("realm")),this._ua.set("ha1",this._auth.get("ha1")),e.stale&&(this._staled=!0),this._request=this._request.clone(),this._request.cseq+=1,this._request.setHeader("cseq","".concat(this._request.cseq," ").concat(this._method)),this._request.setHeader(o,this._auth.toString()),this._eventHandlers.onAuthenticated(this._request),this.send()}else this._eventHandlers.onReceiveResponse(a)}else this._eventHandlers.onReceiveResponse(a)}}]),u}();function $_(u,n){if(!(u instanceof n))throw new TypeError("Cannot call a class as a function")}function Nc(u,n){for(var a=0;a<n.length;a++){var e=n[a];e.enumerable=e.enumerable||!1,e.configurable=!0,"value"in e&&(e.writable=!0),Object.defineProperty(u,e.key,e)}}function H_(u,n,a){return n&&Nc(u.prototype,n),a&&Nc(u,a),u}var F_=St,Uo=Mt(),sr=pt,Uc=pn,xc=Ri,bi=new F_("Registrator"),Ea=10,q_=function(){function u(n,a){$_(this,u),this._reg_id=1,this._ua=n,this._transport=a,this._registrar=n.configuration.registrar_server,this._expires=n.configuration.register_expires,this._call_id=Uo.createRandomToken(22),this._cseq=0,this._to_uri=n.configuration.uri,this._registrationTimer=null,this._registering=!1,this._registered=!1,this._contact=this._ua.contact.toString(),this._contact+=";+sip.ice",this._extraHeaders=[],this._extraContactParams="",this._sipInstance='"<urn:uuid:'.concat(this._ua.configuration.instance_id,'>"'),this._contact+=";reg-id=".concat(this._reg_id),this._contact+=";+sip.instance=".concat(this._sipInstance)}return H_(u,[{key:"setExtraHeaders",value:function(a){Array.isArray(a)||(a=[]),this._extraHeaders=a.slice()}},{key:"setExtraContactParams",value:function(a){a instanceof Object||(a={}),this._extraContactParams="";for(var e in a)if(Object.prototype.hasOwnProperty.call(a,e)){var o=a[e];this._extraContactParams+=";".concat(e),o&&(this._extraContactParams+="=".concat(o))}}},{key:"register",value:function(){var a=this;if(this._registering){bi.debug("Register request in progress...");return}var e=this._extraHeaders.slice();e.push("Contact: ".concat(this._contact,";expires=").concat(this._expires).concat(this._extraContactParams)),e.push("Expires: ".concat(this._expires));var o=new Uc.OutgoingRequest(sr.REGISTER,this._registrar,this._ua,{to_uri:this._to_uri,call_id:this._call_id,cseq:this._cseq+=1},e),p=new xc(this._ua,o,{onRequestTimeout:function(){a._registrationFailure(null,sr.causes.REQUEST_TIMEOUT)},onTransportError:function(){a._registrationFailure(null,sr.causes.CONNECTION_ERROR)},onAuthenticated:function(){a._cseq+=1},onReceiveResponse:function(v){if(v.cseq===a._cseq)switch(a._registrationTimer!==null&&(clearTimeout(a._registrationTimer),a._registrationTimer=null),!0){case/^1[0-9]{2}$/.test(v.status_code):break;case/^2[0-9]{2}$/.test(v.status_code):{if(a._registering=!1,!v.hasHeader("Contact")){bi.debug("no Contact header in response to REGISTER, response ignored");break}var C=v.headers.Contact.reduce(function(O,w){return O.concat(w.parsed)},[]),l=C.find(function(O){return a._sipInstance===O.getParam("+sip.instance")&&a._reg_id===parseInt(O.getParam("reg-id"))});if(l||(l=C.find(function(O){return O.uri.user===a._ua.contact.uri.user})),!l){bi.debug("no Contact header pointing to us, response ignored");break}var A=l.getParam("expires");!A&&v.hasHeader("expires")&&(A=v.getHeader("expires")),A||(A=a._expires),A=Number(A),A<Ea&&(A=Ea);var b=A>64?A*1e3/2+Math.floor((A/2-32)*1e3*Math.random()):A*1e3-5e3;a._registrationTimer=setTimeout(function(){a._registrationTimer=null,a._ua.listeners("registrationExpiring").length===0?a.register():a._ua.emit("registrationExpiring")},b),l.hasParam("temp-gruu")&&(a._ua.contact.temp_gruu=l.getParam("temp-gruu").replace(/"/g,"")),l.hasParam("pub-gruu")&&(a._ua.contact.pub_gruu=l.getParam("pub-gruu").replace(/"/g,"")),a._registered||(a._registered=!0,a._ua.registered({response:v}));break}case/^423$/.test(v.status_code):{v.hasHeader("min-expires")?(a._expires=Number(v.getHeader("min-expires")),a._expires<Ea&&(a._expires=Ea),a.register()):(bi.debug("423 response received for REGISTER without Min-Expires"),a._registrationFailure(v,sr.causes.SIP_FAILURE_CODE));break}default:{var E=Uo.sipErrorCause(v.status_code);a._registrationFailure(v,E)}}}});this._registering=!0,p.send()}},{key:"unregister",value:function(){var a=this,e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(!this._registered){bi.debug("already unregistered");return}this._registered=!1,this._registrationTimer!==null&&(clearTimeout(this._registrationTimer),this._registrationTimer=null);var o=this._extraHeaders.slice();e.all?o.push("Contact: *".concat(this._extraContactParams)):o.push("Contact: ".concat(this._contact,";expires=0").concat(this._extraContactParams)),o.push("Expires: 0");var p=new Uc.OutgoingRequest(sr.REGISTER,this._registrar,this._ua,{to_uri:this._to_uri,call_id:this._call_id,cseq:this._cseq+=1},o),t=new xc(this._ua,p,{onRequestTimeout:function(){a._unregistered(null,sr.causes.REQUEST_TIMEOUT)},onTransportError:function(){a._unregistered(null,sr.causes.CONNECTION_ERROR)},onAuthenticated:function(){a._cseq+=1},onReceiveResponse:function(C){switch(!0){case/^1[0-9]{2}$/.test(C.status_code):break;case/^2[0-9]{2}$/.test(C.status_code):a._unregistered(C);break;default:{var l=Uo.sipErrorCause(C.status_code);a._unregistered(C,l)}}}});t.send()}},{key:"close",value:function(){this._registered&&this.unregister()}},{key:"onTransportClosed",value:function(){this._registering=!1,this._registrationTimer!==null&&(clearTimeout(this._registrationTimer),this._registrationTimer=null),this._registered&&(this._registered=!1,this._ua.unregistered({}))}},{key:"_registrationFailure",value:function(a,e){this._registering=!1,this._ua.registrationFailed({response:a||null,cause:e}),this._registered&&(this._registered=!1,this._ua.unregistered({response:a||null,cause:e}))}},{key:"_unregistered",value:function(a,e){this._registering=!1,this._registered=!1,this._ua.unregistered({response:a||null,cause:e||null})}},{key:"registered",get:function(){return this._registered}}]),u}();function j_(u,n){if(!(u instanceof n))throw new TypeError("Cannot call a class as a function")}function Pc(u,n){for(var a=0;a<n.length;a++){var e=n[a];e.enumerable=e.enumerable||!1,e.configurable=!0,"value"in e&&(e.writable=!0),Object.defineProperty(u,e.key,e)}}function V_(u,n,a){return n&&Pc(u.prototype,n),a&&Pc(u,a),u}var xo=pt,Ca=yi,B_=Ri,Po={onRequestTimeout:function(){},onTransportError:function(){},onSuccessResponse:function(){},onErrorResponse:function(){},onAuthenticated:function(){},onDialogError:function(){}},G_=function(){function u(n,a,e){j_(this,u),this._dialog=n,this._ua=n._ua,this._request=a,this._eventHandlers=e,this._reattempt=!1,this._reattemptTimer=null;for(var o in Po)Object.prototype.hasOwnProperty.call(Po,o)&&(this._eventHandlers[o]||(this._eventHandlers[o]=Po[o]))}return V_(u,[{key:"send",value:function(){var a=this,e=new B_(this._ua,this._request,{onRequestTimeout:function(){a._eventHandlers.onRequestTimeout()},onTransportError:function(){a._eventHandlers.onTransportError()},onAuthenticated:function(t){a._eventHandlers.onAuthenticated(t)},onReceiveResponse:function(t){a._receiveResponse(t)}});if(e.send(),(this._request.method===xo.INVITE||this._request.method===xo.UPDATE&&this._request.body)&&e.clientTransaction.state!==Ca.C.STATUS_TERMINATED){this._dialog.uac_pending_reply=!0;var o=function p(){(e.clientTransaction.state===Ca.C.STATUS_ACCEPTED||e.clientTransaction.state===Ca.C.STATUS_COMPLETED||e.clientTransaction.state===Ca.C.STATUS_TERMINATED)&&(e.clientTransaction.removeListener("stateChanged",p),a._dialog.uac_pending_reply=!1)};e.clientTransaction.on("stateChanged",o)}}},{key:"_receiveResponse",value:function(a){var e=this;a.status_code===408||a.status_code===481?this._eventHandlers.onDialogError(a):a.method===xo.INVITE&&a.status_code===491?this._reattempt?a.status_code>=200&&a.status_code<300?this._eventHandlers.onSuccessResponse(a):a.status_code>=300&&this._eventHandlers.onErrorResponse(a):(this._request.cseq=this._dialog.local_seqnum+=1,this._reattemptTimer=setTimeout(function(){e._dialog.isTerminated()||(e._reattempt=!0,e.send())},1e3)):a.status_code>=200&&a.status_code<300?this._eventHandlers.onSuccessResponse(a):a.status_code>=300&&this._eventHandlers.onErrorResponse(a)}},{key:"request",get:function(){return this._request}}]),u}();function W_(u,n){if(!(u instanceof n))throw new TypeError("Cannot call a class as a function")}function Mc(u,n){for(var a=0;a<n.length;a++){var e=n[a];e.enumerable=e.enumerable||!1,e.configurable=!0,"value"in e&&(e.writable=!0),Object.defineProperty(u,e.key,e)}}function kc(u,n,a){return n&&Mc(u.prototype,n),a&&Mc(u,a),u}var K_=St,Lc=pn,zn=pt,Ii=yi,Y_=G_,Mo=Mt(),ko=new K_("Dialog"),Jn={STATUS_EARLY:1,STATUS_CONFIRMED:2,STATUS_TERMINATED:3},z_=function(){kc(u,null,[{key:"C",get:function(){return Jn}}]);function u(n,a,e){var o=arguments.length>3&&arguments[3]!==void 0?arguments[3]:Jn.STATUS_CONFIRMED;if(W_(this,u),this._owner=n,this._ua=n._ua,this._uac_pending_reply=!1,this._uas_pending_reply=!1,!a.hasHeader("contact"))return{error:"unable to create a Dialog without Contact header field"};a instanceof Lc.IncomingResponse&&(o=a.status_code<200?Jn.STATUS_EARLY:Jn.STATUS_CONFIRMED);var p=a.parseHeader("contact");e==="UAS"?(this._id={call_id:a.call_id,local_tag:a.to_tag,remote_tag:a.from_tag,toString:function(){return this.call_id+this.local_tag+this.remote_tag}},this._state=o,this._remote_seqnum=a.cseq,this._local_uri=a.parseHeader("to").uri,this._remote_uri=a.parseHeader("from").uri,this._remote_target=p.uri,this._route_set=a.getHeaders("record-route"),this._ack_seqnum=this._remote_seqnum):e==="UAC"&&(this._id={call_id:a.call_id,local_tag:a.from_tag,remote_tag:a.to_tag,toString:function(){return this.call_id+this.local_tag+this.remote_tag}},this._state=o,this._local_seqnum=a.cseq,this._local_uri=a.parseHeader("from").uri,this._remote_uri=a.parseHeader("to").uri,this._remote_target=p.uri,this._route_set=a.getHeaders("record-route").reverse(),this._ack_seqnum=null),this._ua.newDialog(this),ko.debug("new ".concat(e," dialog created with status ").concat(this._state===Jn.STATUS_EARLY?"EARLY":"CONFIRMED"))}return kc(u,[{key:"isTerminated",value:function(){return this._status===Jn.STATUS_TERMINATED}},{key:"update",value:function(a,e){this._state=Jn.STATUS_CONFIRMED,ko.debug("dialog ".concat(this._id.toString()," changed to CONFIRMED state")),e==="UAC"&&(this._route_set=a.getHeaders("record-route").reverse())}},{key:"terminate",value:function(){ko.debug("dialog ".concat(this._id.toString()," deleted")),this._ua.destroyDialog(this),this._state=Jn.STATUS_TERMINATED}},{key:"sendRequest",value:function(a){var e=this,o=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},p=Mo.cloneArray(o.extraHeaders),t=Mo.cloneObject(o.eventHandlers),v=o.body||null,C=this._createRequest(a,p,v);t.onAuthenticated=function(){e._local_seqnum+=1};var l=new Y_(this,C,t);return l.send(),C}},{key:"receiveRequest",value:function(a){this._checkInDialogRequest(a)&&(a.method===zn.ACK&&this._ack_seqnum!==null?this._ack_seqnum=null:a.method===zn.INVITE&&(this._ack_seqnum=a.cseq),this._owner.receiveRequest(a))}},{key:"_createRequest",value:function(a,e,o){e=Mo.cloneArray(e),this._local_seqnum||(this._local_seqnum=Math.floor(Math.random()*1e4));var p=a===zn.CANCEL||a===zn.ACK?this._local_seqnum:this._local_seqnum+=1,t=new Lc.OutgoingRequest(a,this._remote_target,this._ua,{cseq:p,call_id:this._id.call_id,from_uri:this._local_uri,from_tag:this._id.local_tag,to_uri:this._remote_uri,to_tag:this._id.remote_tag,route_set:this._route_set},e,o);return t}},{key:"_checkInDialogRequest",value:function(a){var e=this;if(!this._remote_seqnum)this._remote_seqnum=a.cseq;else if(a.cseq<this._remote_seqnum)if(a.method===zn.ACK){if(this._ack_seqnum===null||a.cseq!==this._ack_seqnum)return!1}else return a.reply(500),!1;else a.cseq>this._remote_seqnum&&(this._remote_seqnum=a.cseq);if(a.method===zn.INVITE||a.method===zn.UPDATE&&a.body){if(this._uac_pending_reply===!0)a.reply(491);else if(this._uas_pending_reply===!0){var o=(Math.random()*10|0)+1;return a.reply(500,null,["Retry-After:".concat(o)]),!1}else{this._uas_pending_reply=!0;var p=function t(){(a.server_transaction.state===Ii.C.STATUS_ACCEPTED||a.server_transaction.state===Ii.C.STATUS_COMPLETED||a.server_transaction.state===Ii.C.STATUS_TERMINATED)&&(a.server_transaction.removeListener("stateChanged",t),e._uas_pending_reply=!1)};a.server_transaction.on("stateChanged",p)}a.hasHeader("contact")&&a.server_transaction.on("stateChanged",function(){a.server_transaction.state===Ii.C.STATUS_ACCEPTED&&(e._remote_target=a.parseHeader("contact").uri)})}else a.method===zn.NOTIFY&&a.hasHeader("contact")&&a.server_transaction.on("stateChanged",function(){a.server_transaction.state===Ii.C.STATUS_COMPLETED&&(e._remote_target=a.parseHeader("contact").uri)});return!0}},{key:"id",get:function(){return this._id}},{key:"local_seqnum",get:function(){return this._local_seqnum},set:function(a){this._local_seqnum=a}},{key:"owner",get:function(){return this._owner}},{key:"uac_pending_reply",get:function(){return this._uac_pending_reply},set:function(a){this._uac_pending_reply=a}},{key:"uas_pending_reply",get:function(){return this._uas_pending_reply}}]),u}(),Lo={exports:{}};function Sa(u){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?Sa=function(a){return typeof a}:Sa=function(a){return a&&typeof Symbol=="function"&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a},Sa(u)}function J_(u,n){if(!(u instanceof n))throw new TypeError("Cannot call a class as a function")}function $c(u,n){for(var a=0;a<n.length;a++){var e=n[a];e.enumerable=e.enumerable||!1,e.configurable=!0,"value"in e&&(e.writable=!0),Object.defineProperty(u,e.key,e)}}function X_(u,n,a){return n&&$c(u.prototype,n),a&&$c(u,a),u}function Q_(u,n){if(typeof n!="function"&&n!==null)throw new TypeError("Super expression must either be null or a function");u.prototype=Object.create(n&&n.prototype,{constructor:{value:u,writable:!0,configurable:!0}}),n&&$o(u,n)}function $o(u,n){return $o=Object.setPrototypeOf||function(e,o){return e.__proto__=o,e},$o(u,n)}function Z_(u){var n=sd();return function(){var e=Aa(u),o;if(n){var p=Aa(this).constructor;o=Reflect.construct(e,arguments,p)}else o=e.apply(this,arguments);return ed(this,o)}}function ed(u,n){return n&&(Sa(n)==="object"||typeof n=="function")?n:td(u)}function td(u){if(u===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return u}function sd(){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 Aa(u){return Aa=Object.setPrototypeOf?Object.getPrototypeOf:function(a){return a.__proto__||Object.getPrototypeOf(a)},Aa(u)}var nd=Ct.EventEmitter,ld=St,rd=pt,id=Wn,Hc=Mt(),ad=new ld("RTCSession:DTMF"),Fc={MIN_DURATION:70,MAX_DURATION:6e3,DEFAULT_DURATION:100,MIN_INTER_TONE_GAP:50,DEFAULT_INTER_TONE_GAP:500};Lo.exports=function(u){Q_(a,u);var n=Z_(a);function a(e){var o;return J_(this,a),o=n.call(this),o._session=e,o._direction=null,o._tone=null,o._duration=null,o._request=null,o}return X_(a,[{key:"send",value:function(o){var p=this,t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(o===void 0)throw new TypeError("Not enough arguments");if(this._direction="outgoing",this._session.status!==this._session.C.STATUS_CONFIRMED&&this._session.status!==this._session.C.STATUS_WAITING_FOR_ACK)throw new id.InvalidStateError(this._session.status);var v=Hc.cloneArray(t.extraHeaders);if(this.eventHandlers=Hc.cloneObject(t.eventHandlers),typeof o=="string")o=o.toUpperCase();else if(typeof o=="number")o=o.toString();else throw new TypeError("Invalid tone: ".concat(o));if(o.match(/^[0-9A-DR#*]$/))this._tone=o;else throw new TypeError("Invalid tone: ".concat(o));this._duration=t.duration,v.push("Content-Type: application/dtmf-relay");var C="Signal=".concat(this._tone,`\r
|
47
|
-
`);
|
48
|
-
`);
|
49
|
-
`,1)[0],"Status_Line");if(
|
50
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var p=!0,t=!1,v;return{s:function(){a=u[Symbol.iterator]()},n:function(){var l=a.next();return p=l.done,l},e:function(l){t=!0,v=l},f:function(){try{!p&&a.return!=null&&a.return()}finally{if(t)throw v}}}}function Ld(u,n){if(u){if(typeof u=="string")return Wc(u,n);var a=Object.prototype.toString.call(u).slice(8,-1);if(a==="Object"&&u.constructor&&(a=u.constructor.name),a==="Map"||a==="Set")return Array.from(u);if(a==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(a))return Wc(u,n)}}function Wc(u,n){(n==null||n>u.length)&&(n=u.length);for(var a=0,e=new Array(n);a<n;a++)e[a]=u[a];return e}function $d(u,n){if(!(u instanceof n))throw new TypeError("Cannot call a class as a function")}function Kc(u,n){for(var a=0;a<n.length;a++){var e=n[a];e.enumerable=e.enumerable||!1,e.configurable=!0,"value"in e&&(e.writable=!0),Object.defineProperty(u,e.key,e)}}function Yc(u,n,a){return n&&Kc(u.prototype,n),a&&Kc(u,a),u}function Hd(u,n){if(typeof n!="function"&&n!==null)throw new TypeError("Super expression must either be null or a function");u.prototype=Object.create(n&&n.prototype,{constructor:{value:u,writable:!0,configurable:!0}}),n&&jo(u,n)}function jo(u,n){return jo=Object.setPrototypeOf||function(e,o){return e.__proto__=o,e},jo(u,n)}function Fd(u){var n=Vd();return function(){var e=Oa(u),o;if(n){var p=Oa(this).constructor;o=Reflect.construct(e,arguments,p)}else o=e.apply(this,arguments);return qd(this,o)}}function qd(u,n){return n&&(wa(n)==="object"||typeof n=="function")?n:jd(u)}function jd(u){if(u===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return u}function Vd(){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 Oa(u){return Oa=Object.setPrototypeOf?Object.getPrototypeOf:function(a){return a.__proto__||Object.getPrototypeOf(a)},Oa(u)}var Bd=Ct.EventEmitter,zc=Gt,Gd=St,ge=pt,lr=Wn,Jc=yi,nt=Mt(),Oi=yc,Wd=pn,Da=z_,Kd=Ri,Xt=od,Xc=Ed,Yd=Rd,zd=kd,Qc=Kn(),Z=new Gd("RTCSession"),re={STATUS_NULL:0,STATUS_INVITE_SENT:1,STATUS_1XX_RECEIVED:2,STATUS_INVITE_RECEIVED:3,STATUS_WAITING_FOR_ANSWER:4,STATUS_ANSWERED:5,STATUS_WAITING_FOR_ACK:6,STATUS_CANCELED:7,STATUS_TERMINATED:8,STATUS_CONFIRMED:9},Na=["audio","video"],Jd=function(u){Hd(a,u);var n=Fd(a);Yc(a,null,[{key:"C",get:function(){return re}}]);function a(e){var o;return $d(this,a),Z.debug("new"),o=n.call(this),o._id=null,o._ua=e,o._status=re.STATUS_NULL,o._dialog=null,o._earlyDialogs={},o._contact=null,o._from_tag=null,o._to_tag=null,o._connection=null,o._connectionPromiseQueue=Promise.resolve(),o._request=null,o._is_canceled=!1,o._cancel_reason="",o._is_confirmed=!1,o._late_sdp=!1,o._rtcOfferConstraints=null,o._rtcAnswerConstraints=null,o._localMediaStream=null,o._localMediaStreamLocallyGenerated=!1,o._rtcReady=!0,o._iceReady=!1,o._timers={ackTimer:null,expiresTimer:null,invite2xxTimer:null,userNoAnswerTimer:null},o._direction=null,o._local_identity=null,o._remote_identity=null,o._start_time=null,o._end_time=null,o._tones=null,o._audioMuted=!1,o._videoMuted=!1,o._localHold=!1,o._remoteHold=!1,o._sessionTimers={enabled:o._ua.configuration.session_timers,refreshMethod:o._ua.configuration.session_timers_refresh_method,defaultExpires:ge.SESSION_EXPIRES,currentExpires:null,running:!1,refresher:!1,timer:null},o._referSubscribers={},o._data={},o}return Yc(a,[{key:"isInProgress",value:function(){switch(this._status){case re.STATUS_NULL:case re.STATUS_INVITE_SENT:case re.STATUS_1XX_RECEIVED:case re.STATUS_INVITE_RECEIVED:case re.STATUS_WAITING_FOR_ANSWER:return!0;default:return!1}}},{key:"isEstablished",value:function(){switch(this._status){case re.STATUS_ANSWERED:case re.STATUS_WAITING_FOR_ACK:case re.STATUS_CONFIRMED:return!0;default:return!1}}},{key:"isEnded",value:function(){switch(this._status){case re.STATUS_CANCELED:case re.STATUS_TERMINATED:return!0;default:return!1}}},{key:"isMuted",value:function(){return{audio:this._audioMuted,video:this._videoMuted}}},{key:"isOnHold",value:function(){return{local:this._localHold,remote:this._remoteHold}}},{key:"connect",value:function(o){var p=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},t=arguments.length>2?arguments[2]:void 0;Z.debug("connect()");var v=o,C=nt.cloneObject(p.eventHandlers),l=nt.cloneArray(p.extraHeaders),A=nt.cloneObject(p.mediaConstraints,{audio:!0,video:!0}),b=p.mediaStream||null,E=nt.cloneObject(p.pcConfig,{iceServers:[]}),O=p.rtcConstraints||null,w=p.rtcOfferConstraints||null;if(this._rtcOfferConstraints=w,this._rtcAnswerConstraints=p.rtcAnswerConstraints||null,this._data=p.data||this._data,o===void 0)throw new TypeError("Not enough arguments");if(this._status!==re.STATUS_NULL)throw new lr.InvalidStateError(this._status);if(!window.RTCPeerConnection)throw new lr.NotSupportedError("WebRTC not supported");if(o=this._ua.normalizeTarget(o),!o)throw new TypeError("Invalid target: ".concat(v));this._sessionTimers.enabled&&nt.isDecimal(p.sessionTimersExpires)&&(p.sessionTimersExpires>=ge.MIN_SESSION_EXPIRES?this._sessionTimers.defaultExpires=p.sessionTimersExpires:this._sessionTimers.defaultExpires=ge.SESSION_EXPIRES);for(var N in C)Object.prototype.hasOwnProperty.call(C,N)&&this.on(N,C[N]);this._from_tag=nt.newTag();var U=p.anonymous||!1,z={from_tag:this._from_tag};this._contact=this._ua.contact.toString({anonymous:U,outbound:!0}),U?(z.from_display_name="Anonymous",z.from_uri=new Qc("sip","anonymous","anonymous.invalid"),l.push("P-Preferred-Identity: ".concat(this._ua.configuration.uri.toString())),l.push("Privacy: id")):p.fromUserName&&(z.from_uri=new Qc("sip",p.fromUserName,this._ua.configuration.uri.host),l.push("P-Preferred-Identity: ".concat(this._ua.configuration.uri.toString()))),p.fromDisplayName&&(z.from_display_name=p.fromDisplayName),l.push("Contact: ".concat(this._contact)),l.push("Content-Type: application/sdp"),this._sessionTimers.enabled&&l.push("Session-Expires: ".concat(this._sessionTimers.defaultExpires).concat(this._ua.configuration.session_timers_force_refresher?";refresher=uac":"")),this._request=new Wd.InitialOutgoingInviteRequest(o,this._ua,z,l),this._id=this._request.call_id+this._from_tag,this._createRTCConnection(E,O),this._direction="outgoing",this._local_identity=this._request.from,this._remote_identity=this._request.to,t&&t(this),this._newRTCSession("local",this._request),this._sendInitialRequest(A,w,b)}},{key:"init_incoming",value:function(o,p){var t=this;Z.debug("init_incoming()");var v,C=o.hasHeader("Content-Type")?o.getHeader("Content-Type").toLowerCase():void 0;if(o.body&&C!=="application/sdp"){o.reply(415);return}if(this._status=re.STATUS_INVITE_RECEIVED,this._from_tag=o.from_tag,this._id=o.call_id+this._from_tag,this._request=o,this._contact=this._ua.contact.toString(),o.hasHeader("expires")&&(v=o.getHeader("expires")*1e3),o.to_tag=nt.newTag(),!this._createDialog(o,"UAS",!0)){o.reply(500,"Missing Contact header field");return}o.body?this._late_sdp=!1:this._late_sdp=!0,this._status=re.STATUS_WAITING_FOR_ANSWER,this._timers.userNoAnswerTimer=setTimeout(function(){o.reply(408),t._failed("local",null,ge.causes.NO_ANSWER)},this._ua.configuration.no_answer_timeout),v&&(this._timers.expiresTimer=setTimeout(function(){t._status===re.STATUS_WAITING_FOR_ANSWER&&(o.reply(487),t._failed("system",null,ge.causes.EXPIRES))},v)),this._direction="incoming",this._local_identity=o.to,this._remote_identity=o.from,p&&p(this),this._newRTCSession("remote",o),this._status!==re.STATUS_TERMINATED&&(o.reply(180,null,["Contact: ".concat(this._contact)]),this._progress("local",null))}},{key:"answer",value:function(){var o=this,p=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};Z.debug("answer()");var t=this._request,v=nt.cloneArray(p.extraHeaders),C=nt.cloneObject(p.mediaConstraints),l=p.mediaStream||null,A=nt.cloneObject(p.pcConfig,{iceServers:[]}),b=p.rtcConstraints||null,E=p.rtcAnswerConstraints||null,O=nt.cloneObject(p.rtcOfferConstraints),w,N=!1,U=!1,z=!1,j=!1;if(this._rtcAnswerConstraints=E,this._rtcOfferConstraints=p.rtcOfferConstraints||null,this._data=p.data||this._data,this._direction!=="incoming")throw new lr.NotSupportedError('"answer" not supported for outgoing RTCSession');if(this._status!==re.STATUS_WAITING_FOR_ANSWER)throw new lr.InvalidStateError(this._status);if(this._sessionTimers.enabled&&nt.isDecimal(p.sessionTimersExpires)&&(p.sessionTimersExpires>=ge.MIN_SESSION_EXPIRES?this._sessionTimers.defaultExpires=p.sessionTimersExpires:this._sessionTimers.defaultExpires=ge.SESSION_EXPIRES),this._status=re.STATUS_ANSWERED,!this._createDialog(t,"UAS")){t.reply(500,"Error creating dialog");return}clearTimeout(this._timers.userNoAnswerTimer),v.unshift("Contact: ".concat(this._contact));var _e=t.parseSDP();Array.isArray(_e.media)||(_e.media=[_e.media]);var k=vn(_e.media),H;try{for(k.s();!(H=k.n()).done;){var de=H.value;de.type==="audio"&&(N=!0,(!de.direction||de.direction==="sendrecv")&&(z=!0)),de.type==="video"&&(U=!0,(!de.direction||de.direction==="sendrecv")&&(j=!0))}}catch(M){k.e(M)}finally{k.f()}if(l&&C.audio===!1){w=l.getAudioTracks();var Ue=vn(w),B;try{for(Ue.s();!(B=Ue.n()).done;){var L=B.value;l.removeTrack(L)}}catch(M){Ue.e(M)}finally{Ue.f()}}if(l&&C.video===!1){w=l.getVideoTracks();var V=vn(w),G;try{for(V.s();!(G=V.n()).done;){var K=G.value;l.removeTrack(K)}}catch(M){V.e(M)}finally{V.f()}}!l&&C.audio===void 0&&(C.audio=z),!l&&C.video===void 0&&(C.video=j),!l&&!N&&!O.offerToReceiveAudio&&(C.audio=!1),!l&&!U&&!O.offerToReceiveVideo&&(C.video=!1),this._createRTCConnection(A,b),Promise.resolve().then(function(){if(l)return l;if(C.audio||C.video)return o._localMediaStreamLocallyGenerated=!0,navigator.mediaDevices.getUserMedia(C).catch(function(M){throw o._status===re.STATUS_TERMINATED?new Error("terminated"):(t.reply(480),o._failed("local",null,ge.causes.USER_DENIED_MEDIA_ACCESS),Z.warn('emit "getusermediafailed" [error:%o]',M),o.emit("getusermediafailed",M),new Error("getUserMedia() failed"))})}).then(function(M){if(o._status===re.STATUS_TERMINATED)throw new Error("terminated");o._localMediaStream=M,M&&M.getTracks().forEach(function(te){o._connection.addTrack(te,M)})}).then(function(){if(!o._late_sdp){var M={originator:"remote",type:"offer",sdp:t.body};Z.debug('emit "sdp"'),o.emit("sdp",M);var te=new RTCSessionDescription({type:"offer",sdp:M.sdp});return o._connectionPromiseQueue=o._connectionPromiseQueue.then(function(){return o._connection.setRemoteDescription(te)}).catch(function(se){throw t.reply(488),o._failed("system",null,ge.causes.WEBRTC_ERROR),Z.warn('emit "peerconnection:setremotedescriptionfailed" [error:%o]',se),o.emit("peerconnection:setremotedescriptionfailed",se),new Error("peerconnection.setRemoteDescription() failed")}),o._connectionPromiseQueue}}).then(function(){if(o._status===re.STATUS_TERMINATED)throw new Error("terminated");return o._connecting(t),o._late_sdp?o._createLocalDescription("offer",o._rtcOfferConstraints).catch(function(){throw t.reply(500),new Error("_createLocalDescription() failed")}):o._createLocalDescription("answer",E).catch(function(){throw t.reply(500),new Error("_createLocalDescription() failed")})}).then(function(M){if(o._status===re.STATUS_TERMINATED)throw new Error("terminated");o._handleSessionTimersInIncomingRequest(t,v),t.reply(200,null,v,M,function(){o._status=re.STATUS_WAITING_FOR_ACK,o._setInvite2xxTimer(t,M),o._setACKTimer(),o._accepted("local")},function(){o._failed("system",null,ge.causes.CONNECTION_ERROR)})}).catch(function(M){o._status!==re.STATUS_TERMINATED&&Z.warn(M)})}},{key:"terminate",value:function(){var o=this,p=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};Z.debug("terminate()");var t=p.cause||ge.causes.BYE,v=nt.cloneArray(p.extraHeaders),C=p.body,l,A=p.status_code,b=p.reason_phrase;if(this._status===re.STATUS_TERMINATED)throw new lr.InvalidStateError(this._status);switch(this._status){case re.STATUS_NULL:case re.STATUS_INVITE_SENT:case re.STATUS_1XX_RECEIVED:if(Z.debug("canceling session"),A&&(A<200||A>=700))throw new TypeError("Invalid status_code: ".concat(A));A&&(b=b||ge.REASON_PHRASE[A]||"",l="SIP ;cause=".concat(A,' ;text="').concat(b,'"')),this._status===re.STATUS_NULL||this._status===re.STATUS_INVITE_SENT?(this._is_canceled=!0,this._cancel_reason=l):this._status===re.STATUS_1XX_RECEIVED&&this._request.cancel(l),this._status=re.STATUS_CANCELED,this._failed("local",null,ge.causes.CANCELED);break;case re.STATUS_WAITING_FOR_ANSWER:case re.STATUS_ANSWERED:if(Z.debug("rejecting session"),A=A||480,A<300||A>=700)throw new TypeError("Invalid status_code: ".concat(A));this._request.reply(A,b,v,C),this._failed("local",null,ge.causes.REJECTED);break;case re.STATUS_WAITING_FOR_ACK:case re.STATUS_CONFIRMED:if(Z.debug("terminating session"),b=p.reason_phrase||ge.REASON_PHRASE[A]||"",A&&(A<200||A>=700))throw new TypeError("Invalid status_code: ".concat(A));if(A&&v.push("Reason: SIP ;cause=".concat(A,'; text="').concat(b,'"')),this._status===re.STATUS_WAITING_FOR_ACK&&this._direction==="incoming"&&this._request.server_transaction.state!==Jc.C.STATUS_TERMINATED){var E=this._dialog;this.receiveRequest=function(O){var w=O.method;w===ge.ACK&&(o.sendRequest(ge.BYE,{extraHeaders:v,body:C}),E.terminate())},this._request.server_transaction.on("stateChanged",function(){o._request.server_transaction.state===Jc.C.STATUS_TERMINATED&&(o.sendRequest(ge.BYE,{extraHeaders:v,body:C}),E.terminate())}),this._ended("local",null,t),this._dialog=E,this._ua.newDialog(E)}else this.sendRequest(ge.BYE,{extraHeaders:v,body:C}),this._ended("local",null,t)}}},{key:"sendDTMF",value:function(o){var p=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};Z.debug("sendDTMF() | tones: %s",o);var t=0,v=p.duration||null,C=p.interToneGap||null,l=p.transportType||ge.DTMF_TRANSPORT.INFO;if(o===void 0)throw new TypeError("Not enough arguments");if(this._status!==re.STATUS_CONFIRMED&&this._status!==re.STATUS_WAITING_FOR_ACK&&this._status!==re.STATUS_1XX_RECEIVED)throw new lr.InvalidStateError(this._status);if(l!==ge.DTMF_TRANSPORT.INFO&&l!==ge.DTMF_TRANSPORT.RFC2833)throw new TypeError("invalid transportType: ".concat(l));if(typeof o=="number"&&(o=o.toString()),!o||typeof o!="string"||!o.match(/^[0-9A-DR#*,]+$/i))throw new TypeError("Invalid tones: ".concat(o));if(v&&!nt.isDecimal(v))throw new TypeError("Invalid tone duration: ".concat(v));if(v?v<Xt.C.MIN_DURATION?(Z.debug('"duration" value is lower than the minimum allowed, setting it to '.concat(Xt.C.MIN_DURATION," milliseconds")),v=Xt.C.MIN_DURATION):v>Xt.C.MAX_DURATION?(Z.debug('"duration" value is greater than the maximum allowed, setting it to '.concat(Xt.C.MAX_DURATION," milliseconds")),v=Xt.C.MAX_DURATION):v=Math.abs(v):v=Xt.C.DEFAULT_DURATION,p.duration=v,C&&!nt.isDecimal(C))throw new TypeError("Invalid interToneGap: ".concat(C));if(C?C<Xt.C.MIN_INTER_TONE_GAP?(Z.debug('"interToneGap" value is lower than the minimum allowed, setting it to '.concat(Xt.C.MIN_INTER_TONE_GAP," milliseconds")),C=Xt.C.MIN_INTER_TONE_GAP):C=Math.abs(C):C=Xt.C.DEFAULT_INTER_TONE_GAP,l===ge.DTMF_TRANSPORT.RFC2833){var A=this._getDTMFRTPSender();A&&(o=A.toneBuffer+o,A.insertDTMF(o,v,C));return}if(this._tones){this._tones+=o;return}this._tones=o,b.call(this);function b(){var E=this,O;if(this._status===re.STATUS_TERMINATED||!this._tones||t>=this._tones.length){this._tones=null;return}var w=this._tones[t];if(t+=1,w===",")O=2e3;else{var N=new Xt(this);p.eventHandlers={onFailed:function(){E._tones=null}},N.send(w,p),O=v+C}setTimeout(b.bind(this),O)}}},{key:"sendInfo",value:function(o,p){var t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};if(Z.debug("sendInfo()"),this._status!==re.STATUS_CONFIRMED&&this._status!==re.STATUS_WAITING_FOR_ACK&&this._status!==re.STATUS_1XX_RECEIVED)throw new lr.InvalidStateError(this._status);var v=new Xc(this);v.send(o,p,t)}},{key:"mute",value:function(){var o=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{audio:!0,video:!1};Z.debug("mute()");var p=!1,t=!1;this._audioMuted===!1&&o.audio&&(p=!0,this._audioMuted=!0,this._toggleMuteAudio(!0)),this._videoMuted===!1&&o.video&&(t=!0,this._videoMuted=!0,this._toggleMuteVideo(!0)),(p===!0||t===!0)&&this._onmute({audio:p,video:t})}},{key:"unmute",value:function(){var o=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{audio:!0,video:!0};Z.debug("unmute()");var p=!1,t=!1;this._audioMuted===!0&&o.audio&&(p=!0,this._audioMuted=!1,this._localHold===!1&&this._toggleMuteAudio(!1)),this._videoMuted===!0&&o.video&&(t=!0,this._videoMuted=!1,this._localHold===!1&&this._toggleMuteVideo(!1)),(p===!0||t===!0)&&this._onunmute({audio:p,video:t})}},{key:"hold",value:function(){var o=this,p=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},t=arguments.length>1?arguments[1]:void 0;if(Z.debug("hold()"),this._status!==re.STATUS_WAITING_FOR_ACK&&this._status!==re.STATUS_CONFIRMED||this._localHold===!0||!this._isReadyToReOffer())return!1;this._localHold=!0,this._onhold("local");var v={succeeded:function(){t&&t()},failed:function(){o.terminate({cause:ge.causes.WEBRTC_ERROR,status_code:500,reason_phrase:"Hold Failed"})}};return p.useUpdate?this._sendUpdate({sdpOffer:!0,eventHandlers:v,extraHeaders:p.extraHeaders}):this._sendReinvite({eventHandlers:v,extraHeaders:p.extraHeaders}),!0}},{key:"unhold",value:function(){var o=this,p=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},t=arguments.length>1?arguments[1]:void 0;if(Z.debug("unhold()"),this._status!==re.STATUS_WAITING_FOR_ACK&&this._status!==re.STATUS_CONFIRMED||this._localHold===!1||!this._isReadyToReOffer())return!1;this._localHold=!1,this._onunhold("local");var v={succeeded:function(){t&&t()},failed:function(){o.terminate({cause:ge.causes.WEBRTC_ERROR,status_code:500,reason_phrase:"Unhold Failed"})}};return p.useUpdate?this._sendUpdate({sdpOffer:!0,eventHandlers:v,extraHeaders:p.extraHeaders}):this._sendReinvite({eventHandlers:v,extraHeaders:p.extraHeaders}),!0}},{key:"renegotiate",value:function(){var o=this,p=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},t=arguments.length>1?arguments[1]:void 0;Z.debug("renegotiate()");var v=p.rtcOfferConstraints||null;if(this._status!==re.STATUS_WAITING_FOR_ACK&&this._status!==re.STATUS_CONFIRMED||!this._isReadyToReOffer())return!1;var C={succeeded:function(){t&&t()},failed:function(){o.terminate({cause:ge.causes.WEBRTC_ERROR,status_code:500,reason_phrase:"Media Renegotiation Failed"})}};return this._setLocalMediaStatus(),p.useUpdate?this._sendUpdate({sdpOffer:!0,eventHandlers:C,rtcOfferConstraints:v,extraHeaders:p.extraHeaders}):this._sendReinvite({eventHandlers:C,rtcOfferConstraints:v,extraHeaders:p.extraHeaders}),!0}},{key:"refer",value:function(o,p){var t=this;Z.debug("refer()");var v=o;if(this._status!==re.STATUS_WAITING_FOR_ACK&&this._status!==re.STATUS_CONFIRMED)return!1;if(o=this._ua.normalizeTarget(o),!o)throw new TypeError("Invalid target: ".concat(v));var C=new zd(this);C.sendRefer(o,p);var l=C.id;return this._referSubscribers[l]=C,C.on("requestFailed",function(){delete t._referSubscribers[l]}),C.on("accepted",function(){delete t._referSubscribers[l]}),C.on("failed",function(){delete t._referSubscribers[l]}),C}},{key:"sendRequest",value:function(o,p){return Z.debug("sendRequest()"),this._dialog.sendRequest(o,p)}},{key:"receiveRequest",value:function(o){var p=this;if(Z.debug("receiveRequest()"),o.method===ge.CANCEL)(this._status===re.STATUS_WAITING_FOR_ANSWER||this._status===re.STATUS_ANSWERED)&&(this._status=re.STATUS_CANCELED,this._request.reply(487),this._failed("remote",o,ge.causes.CANCELED));else switch(o.method){case ge.ACK:if(this._status!==re.STATUS_WAITING_FOR_ACK)return;if(this._status=re.STATUS_CONFIRMED,clearTimeout(this._timers.ackTimer),clearTimeout(this._timers.invite2xxTimer),this._late_sdp){if(!o.body){this.terminate({cause:ge.causes.MISSING_SDP,status_code:400});break}var t={originator:"remote",type:"answer",sdp:o.body};Z.debug('emit "sdp"'),this.emit("sdp",t);var v=new RTCSessionDescription({type:"answer",sdp:t.sdp});this._connectionPromiseQueue=this._connectionPromiseQueue.then(function(){return p._connection.setRemoteDescription(v)}).then(function(){p._is_confirmed||p._confirmed("remote",o)}).catch(function(l){p.terminate({cause:ge.causes.BAD_MEDIA_DESCRIPTION,status_code:488}),Z.warn('emit "peerconnection:setremotedescriptionfailed" [error:%o]',l),p.emit("peerconnection:setremotedescriptionfailed",l)})}else this._is_confirmed||this._confirmed("remote",o);break;case ge.BYE:this._status===re.STATUS_CONFIRMED||this._status===re.STATUS_WAITING_FOR_ACK?(o.reply(200),this._ended("remote",o,ge.causes.BYE)):this._status===re.STATUS_INVITE_RECEIVED||this._status===re.STATUS_WAITING_FOR_ANSWER?(o.reply(200),this._request.reply(487,"BYE Received"),this._ended("remote",o,ge.causes.BYE)):o.reply(403,"Wrong Status");break;case ge.INVITE:this._status===re.STATUS_CONFIRMED?o.hasHeader("replaces")?this._receiveReplaces(o):this._receiveReinvite(o):o.reply(403,"Wrong Status");break;case ge.INFO:if(this._status===re.STATUS_1XX_RECEIVED||this._status===re.STATUS_WAITING_FOR_ANSWER||this._status===re.STATUS_ANSWERED||this._status===re.STATUS_WAITING_FOR_ACK||this._status===re.STATUS_CONFIRMED){var C=o.hasHeader("Content-Type")?o.getHeader("Content-Type").toLowerCase():void 0;C&&C.match(/^application\/dtmf-relay/i)?new Xt(this).init_incoming(o):C!==void 0?new Xc(this).init_incoming(o):o.reply(415)}else o.reply(403,"Wrong Status");break;case ge.UPDATE:this._status===re.STATUS_CONFIRMED?this._receiveUpdate(o):o.reply(403,"Wrong Status");break;case ge.REFER:this._status===re.STATUS_CONFIRMED?this._receiveRefer(o):o.reply(403,"Wrong Status");break;case ge.NOTIFY:this._status===re.STATUS_CONFIRMED?this._receiveNotify(o):o.reply(403,"Wrong Status");break;default:o.reply(501)}}},{key:"onTransportError",value:function(){Z.warn("onTransportError()"),this._status!==re.STATUS_TERMINATED&&this.terminate({status_code:500,reason_phrase:ge.causes.CONNECTION_ERROR,cause:ge.causes.CONNECTION_ERROR})}},{key:"onRequestTimeout",value:function(){Z.warn("onRequestTimeout()"),this._status!==re.STATUS_TERMINATED&&this.terminate({status_code:408,reason_phrase:ge.causes.REQUEST_TIMEOUT,cause:ge.causes.REQUEST_TIMEOUT})}},{key:"onDialogError",value:function(){Z.warn("onDialogError()"),this._status!==re.STATUS_TERMINATED&&this.terminate({status_code:500,reason_phrase:ge.causes.DIALOG_ERROR,cause:ge.causes.DIALOG_ERROR})}},{key:"newDTMF",value:function(o){Z.debug("newDTMF()"),this.emit("newDTMF",o)}},{key:"newInfo",value:function(o){Z.debug("newInfo()"),this.emit("newInfo",o)}},{key:"_isReadyToReOffer",value:function(){return this._rtcReady?this._dialog?this._dialog.uac_pending_reply===!0||this._dialog.uas_pending_reply===!0?(Z.debug("_isReadyToReOffer() | there is another INVITE/UPDATE transaction in progress"),!1):!0:(Z.debug("_isReadyToReOffer() | session not established yet"),!1):(Z.debug("_isReadyToReOffer() | internal WebRTC status not ready"),!1)}},{key:"_close",value:function(){if(Z.debug("close()"),this._localMediaStream&&this._localMediaStreamLocallyGenerated&&(Z.debug("close() | closing local MediaStream"),nt.closeMediaStream(this._localMediaStream)),this._status!==re.STATUS_TERMINATED){if(this._status=re.STATUS_TERMINATED,this._connection)try{this._connection.close()}catch(v){Z.warn("close() | error closing the RTCPeerConnection: %o",v)}for(var o in this._timers)Object.prototype.hasOwnProperty.call(this._timers,o)&&clearTimeout(this._timers[o]);clearTimeout(this._sessionTimers.timer),this._dialog&&(this._dialog.terminate(),delete this._dialog);for(var p in this._earlyDialogs)Object.prototype.hasOwnProperty.call(this._earlyDialogs,p)&&(this._earlyDialogs[p].terminate(),delete this._earlyDialogs[p]);for(var t in this._referSubscribers)Object.prototype.hasOwnProperty.call(this._referSubscribers,t)&&delete this._referSubscribers[t];this._ua.destroyRTCSession(this)}}},{key:"_setInvite2xxTimer",value:function(o,p){var t=Oi.T1;function v(){this._status===re.STATUS_WAITING_FOR_ACK&&(o.reply(200,null,["Contact: ".concat(this._contact)],p),t<Oi.T2&&(t=t*2,t>Oi.T2&&(t=Oi.T2)),this._timers.invite2xxTimer=setTimeout(v.bind(this),t))}this._timers.invite2xxTimer=setTimeout(v.bind(this),t)}},{key:"_setACKTimer",value:function(){var o=this;this._timers.ackTimer=setTimeout(function(){o._status===re.STATUS_WAITING_FOR_ACK&&(Z.debug("no ACK received, terminating the session"),clearTimeout(o._timers.invite2xxTimer),o.sendRequest(ge.BYE),o._ended("remote",null,ge.causes.NO_ACK))},Oi.TIMER_H)}},{key:"_createRTCConnection",value:function(o,p){var t=this;this._connection=new RTCPeerConnection(o,p),this._connection.addEventListener("iceconnectionstatechange",function(){var v=t._connection.iceConnectionState;v==="failed"&&t.terminate({cause:ge.causes.RTP_TIMEOUT,status_code:408,reason_phrase:ge.causes.RTP_TIMEOUT})}),Z.debug('emit "peerconnection"'),this.emit("peerconnection",{peerconnection:this._connection})}},{key:"_createLocalDescription",value:function(o,p){var t=this;if(Z.debug("createLocalDescription()"),o!=="offer"&&o!=="answer")throw new Error('createLocalDescription() | invalid type "'.concat(o,'"'));var v=this._connection;return this._rtcReady=!1,Promise.resolve().then(function(){return o==="offer"?v.createOffer(p).catch(function(C){return Z.warn('emit "peerconnection:createofferfailed" [error:%o]',C),t.emit("peerconnection:createofferfailed",C),Promise.reject(C)}):v.createAnswer(p).catch(function(C){return Z.warn('emit "peerconnection:createanswerfailed" [error:%o]',C),t.emit("peerconnection:createanswerfailed",C),Promise.reject(C)})}).then(function(C){return v.setLocalDescription(C).catch(function(l){return t._rtcReady=!0,Z.warn('emit "peerconnection:setlocaldescriptionfailed" [error:%o]',l),t.emit("peerconnection:setlocaldescriptionfailed",l),Promise.reject(l)})}).then(function(){var C=p&&p.iceRestart;if(v.iceGatheringState==="complete"&&!C||v.iceGatheringState==="gathering"&&t._iceReady){t._rtcReady=!0;var l={originator:"local",type:o,sdp:v.localDescription.sdp};return Z.debug('emit "sdp"'),t.emit("sdp",l),Promise.resolve(l.sdp)}return new Promise(function(A){var b=!1,E,O;t._iceReady=!1;var w=function(){v.removeEventListener("icecandidate",E),v.removeEventListener("icegatheringstatechange",O),b=!0,t._rtcReady=!0,t._iceReady=!0;var U={originator:"local",type:o,sdp:v.localDescription.sdp};Z.debug('emit "sdp"'),t.emit("sdp",U),A(U.sdp)};v.addEventListener("icecandidate",E=function(U){var z=U.candidate;z?t.emit("icecandidate",{candidate:z,ready:w}):b||w()}),v.addEventListener("icegatheringstatechange",O=function(){v.iceGatheringState==="complete"&&!b&&w()})})})}},{key:"_createDialog",value:function(o,p,t){var v=p==="UAS"?o.to_tag:o.from_tag,C=p==="UAS"?o.from_tag:o.to_tag,l=o.call_id+v+C,A=this._earlyDialogs[l];if(t)return A?!0:(A=new Da(this,o,p,Da.C.STATUS_EARLY),A.error?(Z.debug(A.error),this._failed("remote",o,ge.causes.INTERNAL_ERROR),!1):(this._earlyDialogs[l]=A,!0));if(this._from_tag=o.from_tag,this._to_tag=o.to_tag,A)return A.update(o,p),this._dialog=A,delete this._earlyDialogs[l],!0;var b=new Da(this,o,p);return b.error?(Z.debug(b.error),this._failed("remote",o,ge.causes.INTERNAL_ERROR),!1):(this._dialog=b,!0)}},{key:"_receiveReinvite",value:function(o){var p=this;Z.debug("receiveReinvite()");var t=o.hasHeader("Content-Type")?o.getHeader("Content-Type").toLowerCase():void 0,v={request:o,callback:void 0,reject:l.bind(this)},C=!1;function l(){var b=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};C=!0;var E=b.status_code||403,O=b.reason_phrase||"",w=nt.cloneArray(b.extraHeaders);if(this._status!==re.STATUS_CONFIRMED)return!1;if(E<300||E>=700)throw new TypeError("Invalid status_code: ".concat(E));o.reply(E,O,w)}if(this.emit("reinvite",v),C)return;if(this._late_sdp=!1,!o.body){this._late_sdp=!0,this._remoteHold&&(this._remoteHold=!1,this._onunhold("remote")),this._connectionPromiseQueue=this._connectionPromiseQueue.then(function(){return p._createLocalDescription("offer",p._rtcOfferConstraints)}).then(function(b){A.call(p,b)}).catch(function(){o.reply(500)});return}if(t!=="application/sdp"){Z.debug("invalid Content-Type"),o.reply(415);return}this._processInDialogSdpOffer(o).then(function(b){p._status!==re.STATUS_TERMINATED&&A.call(p,b)}).catch(function(b){Z.warn(b)});function A(b){var E=this,O=["Contact: ".concat(this._contact)];this._handleSessionTimersInIncomingRequest(o,O),this._late_sdp&&(b=this._mangleOffer(b)),o.reply(200,null,O,b,function(){E._status=re.STATUS_WAITING_FOR_ACK,E._setInvite2xxTimer(o,b),E._setACKTimer()}),typeof v.callback=="function"&&v.callback()}}},{key:"_receiveUpdate",value:function(o){var p=this;Z.debug("receiveUpdate()");var t=o.hasHeader("Content-Type")?o.getHeader("Content-Type").toLowerCase():void 0,v={request:o,callback:void 0,reject:l.bind(this)},C=!1;function l(){var b=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};C=!0;var E=b.status_code||403,O=b.reason_phrase||"",w=nt.cloneArray(b.extraHeaders);if(this._status!==re.STATUS_CONFIRMED)return!1;if(E<300||E>=700)throw new TypeError("Invalid status_code: ".concat(E));o.reply(E,O,w)}if(this.emit("update",v),C)return;if(!o.body){A.call(this,null);return}if(t!=="application/sdp"){Z.debug("invalid Content-Type"),o.reply(415);return}this._processInDialogSdpOffer(o).then(function(b){p._status!==re.STATUS_TERMINATED&&A.call(p,b)}).catch(function(b){Z.warn(b)});function A(b){var E=["Contact: ".concat(this._contact)];this._handleSessionTimersInIncomingRequest(o,E),o.reply(200,null,E,b),typeof v.callback=="function"&&v.callback()}}},{key:"_processInDialogSdpOffer",value:function(o){var p=this;Z.debug("_processInDialogSdpOffer()");var t=o.parseSDP(),v=!1,C=vn(t.media),l;try{for(C.s();!(l=C.n()).done;){var A=l.value;if(Na.indexOf(A.type)!==-1){var b=A.direction||t.direction||"sendrecv";if(b==="sendonly"||b==="inactive")v=!0;else{v=!1;break}}}}catch(w){C.e(w)}finally{C.f()}var E={originator:"remote",type:"offer",sdp:o.body};Z.debug('emit "sdp"'),this.emit("sdp",E);var O=new RTCSessionDescription({type:"offer",sdp:E.sdp});return this._connectionPromiseQueue=this._connectionPromiseQueue.then(function(){if(p._status===re.STATUS_TERMINATED)throw new Error("terminated");return p._connection.setRemoteDescription(O).catch(function(w){throw o.reply(488),Z.warn('emit "peerconnection:setremotedescriptionfailed" [error:%o]',w),p.emit("peerconnection:setremotedescriptionfailed",w),w})}).then(function(){if(p._status===re.STATUS_TERMINATED)throw new Error("terminated");p._remoteHold===!0&&v===!1?(p._remoteHold=!1,p._onunhold("remote")):p._remoteHold===!1&&v===!0&&(p._remoteHold=!0,p._onhold("remote"))}).then(function(){if(p._status===re.STATUS_TERMINATED)throw new Error("terminated");return p._createLocalDescription("answer",p._rtcAnswerConstraints).catch(function(w){throw o.reply(500),Z.warn('emit "peerconnection:createtelocaldescriptionfailed" [error:%o]',w),w})}).catch(function(w){Z.warn("_processInDialogSdpOffer() failed [error: %o]",w)}),this._connectionPromiseQueue}},{key:"_receiveRefer",value:function(o){var p=this;if(Z.debug("receiveRefer()"),!o.refer_to){Z.debug("no Refer-To header field present in REFER"),o.reply(400);return}if(o.refer_to.uri.scheme!==ge.SIP){Z.debug("Refer-To header field points to a non-SIP URI scheme"),o.reply(416);return}o.reply(202);var t=new Yd(this,o.cseq);Z.debug('emit "refer"'),this.emit("refer",{request:o,accept:function(A,b){v.call(p,A,b)},reject:function(){C.call(p)}});function v(l){var A=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(l=typeof l=="function"?l:null,this._status!==re.STATUS_WAITING_FOR_ACK&&this._status!==re.STATUS_CONFIRMED)return!1;var b=new a(this._ua);if(b.on("progress",function(O){var w=O.response;t.notify(w.status_code,w.reason_phrase)}),b.on("accepted",function(O){var w=O.response;t.notify(w.status_code,w.reason_phrase)}),b.on("_failed",function(O){var w=O.message,N=O.cause;w?t.notify(w.status_code,w.reason_phrase):t.notify(487,N)}),o.refer_to.uri.hasHeader("replaces")){var E=decodeURIComponent(o.refer_to.uri.getHeader("replaces"));A.extraHeaders=nt.cloneArray(A.extraHeaders),A.extraHeaders.push("Replaces: ".concat(E))}b.connect(o.refer_to.uri.toAor(),A,l)}function C(){t.notify(603)}}},{key:"_receiveNotify",value:function(o){switch(Z.debug("receiveNotify()"),o.event||o.reply(400),o.event.event){case"refer":{var p,t;if(o.event.params&&o.event.params.id)p=o.event.params.id,t=this._referSubscribers[p];else if(Object.keys(this._referSubscribers).length===1)t=this._referSubscribers[Object.keys(this._referSubscribers)[0]];else{o.reply(400,"Missing event id parameter");return}if(!t){o.reply(481,"Subscription does not exist");return}t.receiveNotify(o),o.reply(200);break}default:o.reply(489)}}},{key:"_receiveReplaces",value:function(o){var p=this;Z.debug("receiveReplaces()");function t(C){var l=this;if(this._status!==re.STATUS_WAITING_FOR_ACK&&this._status!==re.STATUS_CONFIRMED)return!1;var A=new a(this._ua);A.on("confirmed",function(){l.terminate()}),A.init_incoming(o,C)}function v(){Z.debug("Replaced INVITE rejected by the user"),o.reply(486)}this.emit("replaces",{request:o,accept:function(l){t.call(p,l)},reject:function(){v.call(p)}})}},{key:"_sendInitialRequest",value:function(o,p,t){var v=this,C=new Kd(this._ua,this._request,{onRequestTimeout:function(){v.onRequestTimeout()},onTransportError:function(){v.onTransportError()},onAuthenticated:function(A){v._request=A},onReceiveResponse:function(A){v._receiveInviteResponse(A)}});Promise.resolve().then(function(){if(t)return t;if(o.audio||o.video)return v._localMediaStreamLocallyGenerated=!0,navigator.mediaDevices.getUserMedia(o).catch(function(l){throw v._status===re.STATUS_TERMINATED?new Error("terminated"):(v._failed("local",null,ge.causes.USER_DENIED_MEDIA_ACCESS),Z.warn('emit "getusermediafailed" [error:%o]',l),v.emit("getusermediafailed",l),l)})}).then(function(l){if(v._status===re.STATUS_TERMINATED)throw new Error("terminated");return v._localMediaStream=l,l&&l.getTracks().forEach(function(A){v._connection.addTrack(A,l)}),v._connecting(v._request),v._createLocalDescription("offer",p).catch(function(A){throw v._failed("local",null,ge.causes.WEBRTC_ERROR),A})}).then(function(l){if(v._is_canceled||v._status===re.STATUS_TERMINATED)throw new Error("terminated");v._request.body=l,v._status=re.STATUS_INVITE_SENT,Z.debug('emit "sending" [request:%o]',v._request),v.emit("sending",{request:v._request}),C.send()}).catch(function(l){v._status!==re.STATUS_TERMINATED&&Z.warn(l)})}},{key:"_getDTMFRTPSender",value:function(){var o=this._connection.getSenders().find(function(p){return p.track&&p.track.kind==="audio"});if(!(o&&o.dtmf)){Z.warn("sendDTMF() | no local audio track to send DTMF with");return}return o.dtmf}},{key:"_receiveInviteResponse",value:function(o){var p=this;if(Z.debug("receiveInviteResponse()"),this._dialog&&o.status_code>=200&&o.status_code<=299)if(this._dialog.id.call_id===o.call_id&&this._dialog.id.local_tag===o.from_tag&&this._dialog.id.remote_tag===o.to_tag){this.sendRequest(ge.ACK);return}else{var t=new Da(this,o,"UAC");if(t.error!==void 0){Z.debug(t.error);return}this.sendRequest(ge.ACK),this.sendRequest(ge.BYE);return}if(this._is_canceled){o.status_code>=100&&o.status_code<200?this._request.cancel(this._cancel_reason):o.status_code>=200&&o.status_code<299&&this._acceptAndTerminate(o);return}if(!(this._status!==re.STATUS_INVITE_SENT&&this._status!==re.STATUS_1XX_RECEIVED))switch(!0){case/^100$/.test(o.status_code):this._status=re.STATUS_1XX_RECEIVED;break;case/^1[0-9]{2}$/.test(o.status_code):{if(!o.to_tag){Z.debug("1xx response received without to tag");break}if(o.hasHeader("contact")&&!this._createDialog(o,"UAC",!0))break;if(this._status=re.STATUS_1XX_RECEIVED,!o.body){this._progress("remote",o);break}var v={originator:"remote",type:"answer",sdp:o.body};Z.debug('emit "sdp"'),this.emit("sdp",v);var C=new RTCSessionDescription({type:"answer",sdp:v.sdp});this._connectionPromiseQueue=this._connectionPromiseQueue.then(function(){return p._connection.setRemoteDescription(C)}).then(function(){return p._progress("remote",o)}).catch(function(E){Z.warn('emit "peerconnection:setremotedescriptionfailed" [error:%o]',E),p.emit("peerconnection:setremotedescriptionfailed",E)});break}case/^2[0-9]{2}$/.test(o.status_code):{if(this._status=re.STATUS_CONFIRMED,!o.body){this._acceptAndTerminate(o,400,ge.causes.MISSING_SDP),this._failed("remote",o,ge.causes.BAD_MEDIA_DESCRIPTION);break}if(!this._createDialog(o,"UAC"))break;var l={originator:"remote",type:"answer",sdp:o.body};Z.debug('emit "sdp"'),this.emit("sdp",l);var A=new RTCSessionDescription({type:"answer",sdp:l.sdp});this._connectionPromiseQueue=this._connectionPromiseQueue.then(function(){if(p._connection.signalingState==="stable")return p._connection.createOffer(p._rtcOfferConstraints).then(function(E){return p._connection.setLocalDescription(E)}).catch(function(E){p._acceptAndTerminate(o,500,E.toString()),p._failed("local",o,ge.causes.WEBRTC_ERROR)})}).then(function(){p._connection.setRemoteDescription(A).then(function(){p._handleSessionTimersInIncomingResponse(o),p._accepted("remote",o),p.sendRequest(ge.ACK),p._confirmed("local",null)}).catch(function(E){p._acceptAndTerminate(o,488,"Not Acceptable Here"),p._failed("remote",o,ge.causes.BAD_MEDIA_DESCRIPTION),Z.warn('emit "peerconnection:setremotedescriptionfailed" [error:%o]',E),p.emit("peerconnection:setremotedescriptionfailed",E)})});break}default:{var b=nt.sipErrorCause(o.status_code);this._failed("remote",o,b)}}}},{key:"_sendReinvite",value:function(){var o=this,p=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};Z.debug("sendReinvite()");var t=nt.cloneArray(p.extraHeaders),v=nt.cloneObject(p.eventHandlers),C=p.rtcOfferConstraints||this._rtcOfferConstraints||null,l=!1;t.push("Contact: ".concat(this._contact)),t.push("Content-Type: application/sdp"),this._sessionTimers.running&&t.push("Session-Expires: ".concat(this._sessionTimers.currentExpires,";refresher=").concat(this._sessionTimers.refresher?"uac":"uas")),this._connectionPromiseQueue=this._connectionPromiseQueue.then(function(){return o._createLocalDescription("offer",C)}).then(function(E){E=o._mangleOffer(E);var O={originator:"local",type:"offer",sdp:E};Z.debug('emit "sdp"'),o.emit("sdp",O),o.sendRequest(ge.INVITE,{extraHeaders:t,body:E,eventHandlers:{onSuccessResponse:function(N){A.call(o,N),l=!0},onErrorResponse:function(N){b.call(o,N)},onTransportError:function(){o.onTransportError()},onRequestTimeout:function(){o.onRequestTimeout()},onDialogError:function(){o.onDialogError()}}})}).catch(function(){b()});function A(E){var O=this;if(this._status!==re.STATUS_TERMINATED&&(this.sendRequest(ge.ACK),!l)){if(this._handleSessionTimersInIncomingResponse(E),E.body){if(!E.hasHeader("Content-Type")||E.getHeader("Content-Type").toLowerCase()!=="application/sdp"){b.call(this);return}}else{b.call(this);return}var w={originator:"remote",type:"answer",sdp:E.body};Z.debug('emit "sdp"'),this.emit("sdp",w);var N=new RTCSessionDescription({type:"answer",sdp:w.sdp});this._connectionPromiseQueue=this._connectionPromiseQueue.then(function(){return O._connection.setRemoteDescription(N)}).then(function(){v.succeeded&&v.succeeded(E)}).catch(function(U){b.call(O),Z.warn('emit "peerconnection:setremotedescriptionfailed" [error:%o]',U),O.emit("peerconnection:setremotedescriptionfailed",U)})}}function b(E){v.failed&&v.failed(E)}}},{key:"_sendUpdate",value:function(){var o=this,p=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};Z.debug("sendUpdate()");var t=nt.cloneArray(p.extraHeaders),v=nt.cloneObject(p.eventHandlers),C=p.rtcOfferConstraints||this._rtcOfferConstraints||null,l=p.sdpOffer||!1,A=!1;t.push("Contact: ".concat(this._contact)),this._sessionTimers.running&&t.push("Session-Expires: ".concat(this._sessionTimers.currentExpires,";refresher=").concat(this._sessionTimers.refresher?"uac":"uas")),l?(t.push("Content-Type: application/sdp"),this._connectionPromiseQueue=this._connectionPromiseQueue.then(function(){return o._createLocalDescription("offer",C)}).then(function(O){O=o._mangleOffer(O);var w={originator:"local",type:"offer",sdp:O};Z.debug('emit "sdp"'),o.emit("sdp",w),o.sendRequest(ge.UPDATE,{extraHeaders:t,body:O,eventHandlers:{onSuccessResponse:function(U){b.call(o,U),A=!0},onErrorResponse:function(U){E.call(o,U)},onTransportError:function(){o.onTransportError()},onRequestTimeout:function(){o.onRequestTimeout()},onDialogError:function(){o.onDialogError()}}})}).catch(function(){E.call(o)})):this.sendRequest(ge.UPDATE,{extraHeaders:t,eventHandlers:{onSuccessResponse:function(w){b.call(o,w)},onErrorResponse:function(w){E.call(o,w)},onTransportError:function(){o.onTransportError()},onRequestTimeout:function(){o.onRequestTimeout()},onDialogError:function(){o.onDialogError()}}});function b(O){var w=this;if(this._status!==re.STATUS_TERMINATED&&!A)if(this._handleSessionTimersInIncomingResponse(O),l){if(O.body){if(!O.hasHeader("Content-Type")||O.getHeader("Content-Type").toLowerCase()!=="application/sdp"){E.call(this);return}}else{E.call(this);return}var N={originator:"remote",type:"answer",sdp:O.body};Z.debug('emit "sdp"'),this.emit("sdp",N);var U=new RTCSessionDescription({type:"answer",sdp:N.sdp});this._connectionPromiseQueue=this._connectionPromiseQueue.then(function(){return w._connection.setRemoteDescription(U)}).then(function(){v.succeeded&&v.succeeded(O)}).catch(function(z){E.call(w),Z.warn('emit "peerconnection:setremotedescriptionfailed" [error:%o]',z),w.emit("peerconnection:setremotedescriptionfailed",z)})}else v.succeeded&&v.succeeded(O)}function E(O){v.failed&&v.failed(O)}}},{key:"_acceptAndTerminate",value:function(o,p,t){Z.debug("acceptAndTerminate()");var v=[];p&&(t=t||ge.REASON_PHRASE[p]||"",v.push("Reason: SIP ;cause=".concat(p,'; text="').concat(t,'"'))),(this._dialog||this._createDialog(o,"UAC"))&&(this.sendRequest(ge.ACK),this.sendRequest(ge.BYE,{extraHeaders:v})),this._status=re.STATUS_TERMINATED}},{key:"_mangleOffer",value:function(o){if(!this._localHold&&!this._remoteHold)return o;if(o=zc.parse(o),this._localHold&&!this._remoteHold){Z.debug("mangleOffer() | me on hold, mangling offer");var p=vn(o.media),t;try{for(p.s();!(t=p.n()).done;){var v=t.value;Na.indexOf(v.type)!==-1&&(v.direction?v.direction==="sendrecv"?v.direction="sendonly":v.direction==="recvonly"&&(v.direction="inactive"):v.direction="sendonly")}}catch(w){p.e(w)}finally{p.f()}}else if(this._localHold&&this._remoteHold){Z.debug("mangleOffer() | both on hold, mangling offer");var C=vn(o.media),l;try{for(C.s();!(l=C.n()).done;){var A=l.value;Na.indexOf(A.type)!==-1&&(A.direction="inactive")}}catch(w){C.e(w)}finally{C.f()}}else if(this._remoteHold){Z.debug("mangleOffer() | remote on hold, mangling offer");var b=vn(o.media),E;try{for(b.s();!(E=b.n()).done;){var O=E.value;Na.indexOf(O.type)!==-1&&(O.direction?O.direction==="sendrecv"?O.direction="recvonly":O.direction==="recvonly"&&(O.direction="inactive"):O.direction="recvonly")}}catch(w){b.e(w)}finally{b.f()}}return zc.write(o)}},{key:"_setLocalMediaStatus",value:function(){var o=!0,p=!0;(this._localHold||this._remoteHold)&&(o=!1,p=!1),this._audioMuted&&(o=!1),this._videoMuted&&(p=!1),this._toggleMuteAudio(!o),this._toggleMuteVideo(!p)}},{key:"_handleSessionTimersInIncomingRequest",value:function(o,p){if(this._sessionTimers.enabled){var t;o.session_expires&&o.session_expires>=ge.MIN_SESSION_EXPIRES?(this._sessionTimers.currentExpires=o.session_expires,t=o.session_expires_refresher||"uas"):(this._sessionTimers.currentExpires=this._sessionTimers.defaultExpires,t="uas"),p.push("Session-Expires: ".concat(this._sessionTimers.currentExpires,";refresher=").concat(t)),this._sessionTimers.refresher=t==="uas",this._runSessionTimer()}}},{key:"_handleSessionTimersInIncomingResponse",value:function(o){if(this._sessionTimers.enabled){var p;o.session_expires&&o.session_expires>=ge.MIN_SESSION_EXPIRES?(this._sessionTimers.currentExpires=o.session_expires,p=o.session_expires_refresher||"uac"):(this._sessionTimers.currentExpires=this._sessionTimers.defaultExpires,p="uac"),this._sessionTimers.refresher=p==="uac",this._runSessionTimer()}}},{key:"_runSessionTimer",value:function(){var o=this,p=this._sessionTimers.currentExpires;this._sessionTimers.running=!0,clearTimeout(this._sessionTimers.timer),this._sessionTimers.refresher?this._sessionTimers.timer=setTimeout(function(){o._status!==re.STATUS_TERMINATED&&o._isReadyToReOffer()&&(Z.debug("runSessionTimer() | sending session refresh request"),o._sessionTimers.refreshMethod===ge.UPDATE?o._sendUpdate():o._sendReinvite())},p*500):this._sessionTimers.timer=setTimeout(function(){o._status!==re.STATUS_TERMINATED&&(Z.warn("runSessionTimer() | timer expired, terminating the session"),o.terminate({cause:ge.causes.REQUEST_TIMEOUT,status_code:408,reason_phrase:"Session Timer Expired"}))},p*1100)}},{key:"_toggleMuteAudio",value:function(o){var p=this._connection.getSenders().filter(function(l){return l.track&&l.track.kind==="audio"}),t=vn(p),v;try{for(t.s();!(v=t.n()).done;){var C=v.value;C.track.enabled=!o}}catch(l){t.e(l)}finally{t.f()}}},{key:"_toggleMuteVideo",value:function(o){var p=this._connection.getSenders().filter(function(l){return l.track&&l.track.kind==="video"}),t=vn(p),v;try{for(t.s();!(v=t.n()).done;){var C=v.value;C.track.enabled=!o}}catch(l){t.e(l)}finally{t.f()}}},{key:"_newRTCSession",value:function(o,p){Z.debug("newRTCSession()"),this._ua.newRTCSession(this,{originator:o,session:this,request:p})}},{key:"_connecting",value:function(o){Z.debug("session connecting"),Z.debug('emit "connecting"'),this.emit("connecting",{request:o})}},{key:"_progress",value:function(o,p){Z.debug("session progress"),Z.debug('emit "progress"'),this.emit("progress",{originator:o,response:p||null})}},{key:"_accepted",value:function(o,p){Z.debug("session accepted"),this._start_time=new Date,Z.debug('emit "accepted"'),this.emit("accepted",{originator:o,response:p||null})}},{key:"_confirmed",value:function(o,p){Z.debug("session confirmed"),this._is_confirmed=!0,Z.debug('emit "confirmed"'),this.emit("confirmed",{originator:o,ack:p||null})}},{key:"_ended",value:function(o,p,t){Z.debug("session ended"),this._end_time=new Date,this._close(),Z.debug('emit "ended"'),this.emit("ended",{originator:o,message:p||null,cause:t})}},{key:"_failed",value:function(o,p,t){Z.debug("session failed"),Z.debug('emit "_failed"'),this.emit("_failed",{originator:o,message:p||null,cause:t}),this._close(),Z.debug('emit "failed"'),this.emit("failed",{originator:o,message:p||null,cause:t})}},{key:"_onhold",value:function(o){Z.debug("session onhold"),this._setLocalMediaStatus(),Z.debug('emit "hold"'),this.emit("hold",{originator:o})}},{key:"_onunhold",value:function(o){Z.debug("session onunhold"),this._setLocalMediaStatus(),Z.debug('emit "unhold"'),this.emit("unhold",{originator:o})}},{key:"_onmute",value:function(o){var p=o.audio,t=o.video;Z.debug("session onmute"),this._setLocalMediaStatus(),Z.debug('emit "muted"'),this.emit("muted",{audio:p,video:t})}},{key:"_onunmute",value:function(o){var p=o.audio,t=o.video;Z.debug("session onunmute"),this._setLocalMediaStatus(),Z.debug('emit "unmuted"'),this.emit("unmuted",{audio:p,video:t})}},{key:"C",get:function(){return re}},{key:"causes",get:function(){return ge.causes}},{key:"id",get:function(){return this._id}},{key:"connection",get:function(){return this._connection}},{key:"contact",get:function(){return this._contact}},{key:"direction",get:function(){return this._direction}},{key:"local_identity",get:function(){return this._local_identity}},{key:"remote_identity",get:function(){return this._remote_identity}},{key:"start_time",get:function(){return this._start_time}},{key:"end_time",get:function(){return this._end_time}},{key:"data",get:function(){return this._data},set:function(o){this._data=o}},{key:"status",get:function(){return this._status}}]),a}(Bd);function Ua(u){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?Ua=function(a){return typeof a}:Ua=function(a){return a&&typeof Symbol=="function"&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a},Ua(u)}function Xd(u,n){if(!(u instanceof n))throw new TypeError("Cannot call a class as a function")}function Zc(u,n){for(var a=0;a<n.length;a++){var e=n[a];e.enumerable=e.enumerable||!1,e.configurable=!0,"value"in e&&(e.writable=!0),Object.defineProperty(u,e.key,e)}}function Qd(u,n,a){return n&&Zc(u.prototype,n),a&&Zc(u,a),u}function Zd(u,n){if(typeof n!="function"&&n!==null)throw new TypeError("Super expression must either be null or a function");u.prototype=Object.create(n&&n.prototype,{constructor:{value:u,writable:!0,configurable:!0}}),n&&Vo(u,n)}function Vo(u,n){return Vo=Object.setPrototypeOf||function(e,o){return e.__proto__=o,e},Vo(u,n)}function ep(u){var n=np();return function(){var e=xa(u),o;if(n){var p=xa(this).constructor;o=Reflect.construct(e,arguments,p)}else o=e.apply(this,arguments);return tp(this,o)}}function tp(u,n){return n&&(Ua(n)==="object"||typeof n=="function")?n:sp(u)}function sp(u){if(u===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return u}function np(){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 xa(u){return xa=Object.setPrototypeOf?Object.getPrototypeOf:function(a){return a.__proto__||Object.getPrototypeOf(a)},xa(u)}var lp=Ct.EventEmitter,rp=St,Bo=pt,ip=pn,Di=Mt(),ap=Ri,ef=Wn,op=Kn(),Pa=new rp("Message"),up=function(u){Zd(a,u);var n=ep(a);function a(e){var o;return Xd(this,a),o=n.call(this),o._ua=e,o._request=null,o._closed=!1,o._direction=null,o._local_identity=null,o._remote_identity=null,o._is_replied=!1,o._data={},o}return Qd(a,[{key:"send",value:function(o,p){var t=this,v=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},C=o;if(o===void 0||p===void 0)throw new TypeError("Not enough arguments");if(o=this._ua.normalizeTarget(o),!o)throw new TypeError("Invalid target: ".concat(C));var l=Di.cloneArray(v.extraHeaders),A=Di.cloneObject(v.eventHandlers),b=v.contentType||"text/plain",E={};v.fromUserName&&(E.from_uri=new op("sip",v.fromUserName,this._ua.configuration.uri.host),l.push("P-Preferred-Identity: ".concat(this._ua.configuration.uri.toString()))),v.fromDisplayName&&(E.from_display_name=v.fromDisplayName);for(var O in A)Object.prototype.hasOwnProperty.call(A,O)&&this.on(O,A[O]);l.push("Content-Type: ".concat(b)),this._request=new ip.OutgoingRequest(Bo.MESSAGE,o,this._ua,E,l),p&&(this._request.body=p);var w=new ap(this._ua,this._request,{onRequestTimeout:function(){t._onRequestTimeout()},onTransportError:function(){t._onTransportError()},onReceiveResponse:function(U){t._receiveResponse(U)}});this._newMessage("local",this._request),w.send()}},{key:"init_incoming",value:function(o){this._request=o,this._newMessage("remote",o),this._is_replied||(this._is_replied=!0,o.reply(200)),this._close()}},{key:"accept",value:function(){var o=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},p=Di.cloneArray(o.extraHeaders),t=o.body;if(this._direction!=="incoming")throw new ef.NotSupportedError('"accept" not supported for outgoing Message');if(this._is_replied)throw new Error("incoming Message already replied");this._is_replied=!0,this._request.reply(200,null,p,t)}},{key:"reject",value:function(){var o=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},p=o.status_code||480,t=o.reason_phrase,v=Di.cloneArray(o.extraHeaders),C=o.body;if(this._direction!=="incoming")throw new ef.NotSupportedError('"reject" not supported for outgoing Message');if(this._is_replied)throw new Error("incoming Message already replied");if(p<300||p>=700)throw new TypeError("Invalid status_code: ".concat(p));this._is_replied=!0,this._request.reply(p,t,v,C)}},{key:"_receiveResponse",value:function(o){if(!this._closed)switch(!0){case/^1[0-9]{2}$/.test(o.status_code):break;case/^2[0-9]{2}$/.test(o.status_code):this._succeeded("remote",o);break;default:{var p=Di.sipErrorCause(o.status_code);this._failed("remote",o,p);break}}}},{key:"_onRequestTimeout",value:function(){this._closed||this._failed("system",null,Bo.causes.REQUEST_TIMEOUT)}},{key:"_onTransportError",value:function(){this._closed||this._failed("system",null,Bo.causes.CONNECTION_ERROR)}},{key:"_close",value:function(){this._closed=!0,this._ua.destroyMessage(this)}},{key:"_newMessage",value:function(o,p){o==="remote"?(this._direction="incoming",this._local_identity=p.to,this._remote_identity=p.from):o==="local"&&(this._direction="outgoing",this._local_identity=p.from,this._remote_identity=p.to),this._ua.newMessage(this,{originator:o,message:this,request:p})}},{key:"_failed",value:function(o,p,t){Pa.debug("MESSAGE failed"),this._close(),Pa.debug('emit "failed"'),this.emit("failed",{originator:o,response:p||null,cause:t})}},{key:"_succeeded",value:function(o,p){Pa.debug("MESSAGE succeeded"),this._close(),Pa.debug('emit "succeeded"'),this.emit("succeeded",{originator:o,response:p})}},{key:"direction",get:function(){return this._direction}},{key:"local_identity",get:function(){return this._local_identity}},{key:"remote_identity",get:function(){return this._remote_identity}}]),a}(lp);function Ma(u){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?Ma=function(a){return typeof a}:Ma=function(a){return a&&typeof Symbol=="function"&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a},Ma(u)}function cp(u,n){if(!(u instanceof n))throw new TypeError("Cannot call a class as a function")}function tf(u,n){for(var a=0;a<n.length;a++){var e=n[a];e.enumerable=e.enumerable||!1,e.configurable=!0,"value"in e&&(e.writable=!0),Object.defineProperty(u,e.key,e)}}function fp(u,n,a){return n&&tf(u.prototype,n),a&&tf(u,a),u}function hp(u,n){if(typeof n!="function"&&n!==null)throw new TypeError("Super expression must either be null or a function");u.prototype=Object.create(n&&n.prototype,{constructor:{value:u,writable:!0,configurable:!0}}),n&&Go(u,n)}function Go(u,n){return Go=Object.setPrototypeOf||function(e,o){return e.__proto__=o,e},Go(u,n)}function _p(u){var n=mp();return function(){var e=ka(u),o;if(n){var p=ka(this).constructor;o=Reflect.construct(e,arguments,p)}else o=e.apply(this,arguments);return dp(this,o)}}function dp(u,n){return n&&(Ma(n)==="object"||typeof n=="function")?n:pp(u)}function pp(u){if(u===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return u}function mp(){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 ka(u){return ka=Object.setPrototypeOf?Object.getPrototypeOf:function(a){return a.__proto__||Object.getPrototypeOf(a)},ka(u)}var gp=Ct.EventEmitter,vp=St,Wo=pt,Tp=pn,Ni=Mt(),Ep=Ri,sf=Wn,La=new vp("Options"),Cp=function(u){hp(a,u);var n=_p(a);function a(e){var o;return cp(this,a),o=n.call(this),o._ua=e,o._request=null,o._closed=!1,o._direction=null,o._local_identity=null,o._remote_identity=null,o._is_replied=!1,o._data={},o}return fp(a,[{key:"send",value:function(o,p){var t=this,v=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},C=o;if(o===void 0)throw new TypeError("A target is required for OPTIONS");if(o=this._ua.normalizeTarget(o),!o)throw new TypeError("Invalid target: ".concat(C));var l=Ni.cloneArray(v.extraHeaders),A=Ni.cloneObject(v.eventHandlers),b=v.contentType||"application/sdp";for(var E in A)Object.prototype.hasOwnProperty.call(A,E)&&this.on(E,A[E]);l.push("Content-Type: ".concat(b)),this._request=new Tp.OutgoingRequest(Wo.OPTIONS,o,this._ua,null,l),p&&(this._request.body=p);var O=new Ep(this._ua,this._request,{onRequestTimeout:function(){t._onRequestTimeout()},onTransportError:function(){t._onTransportError()},onReceiveResponse:function(N){t._receiveResponse(N)}});this._newOptions("local",this._request),O.send()}},{key:"init_incoming",value:function(o){this._request=o,this._newOptions("remote",o),this._is_replied||(this._is_replied=!0,o.reply(200)),this._close()}},{key:"accept",value:function(){var o=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},p=Ni.cloneArray(o.extraHeaders),t=o.body;if(this._direction!=="incoming")throw new sf.NotSupportedError('"accept" not supported for outgoing Options');if(this._is_replied)throw new Error("incoming Options already replied");this._is_replied=!0,this._request.reply(200,null,p,t)}},{key:"reject",value:function(){var o=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},p=o.status_code||480,t=o.reason_phrase,v=Ni.cloneArray(o.extraHeaders),C=o.body;if(this._direction!=="incoming")throw new sf.NotSupportedError('"reject" not supported for outgoing Options');if(this._is_replied)throw new Error("incoming Options already replied");if(p<300||p>=700)throw new TypeError("Invalid status_code: ".concat(p));this._is_replied=!0,this._request.reply(p,t,v,C)}},{key:"_receiveResponse",value:function(o){if(!this._closed)switch(!0){case/^1[0-9]{2}$/.test(o.status_code):break;case/^2[0-9]{2}$/.test(o.status_code):this._succeeded("remote",o);break;default:{var p=Ni.sipErrorCause(o.status_code);this._failed("remote",o,p);break}}}},{key:"_onRequestTimeout",value:function(){this._closed||this._failed("system",null,Wo.causes.REQUEST_TIMEOUT)}},{key:"_onTransportError",value:function(){this._closed||this._failed("system",null,Wo.causes.CONNECTION_ERROR)}},{key:"_close",value:function(){this._closed=!0,this._ua.destroyMessage(this)}},{key:"_newOptions",value:function(o,p){o==="remote"?(this._direction="incoming",this._local_identity=p.to,this._remote_identity=p.from):o==="local"&&(this._direction="outgoing",this._local_identity=p.from,this._remote_identity=p.to),this._ua.newOptions(this,{originator:o,message:this,request:p})}},{key:"_failed",value:function(o,p,t){La.debug("OPTIONS failed"),this._close(),La.debug('emit "failed"'),this.emit("failed",{originator:o,response:p||null,cause:t})}},{key:"_succeeded",value:function(o,p){La.debug("OPTIONS succeeded"),this._close(),La.debug('emit "succeeded"'),this.emit("succeeded",{originator:o,response:p})}},{key:"direction",get:function(){return this._direction}},{key:"local_identity",get:function(){return this._local_identity}},{key:"remote_identity",get:function(){return this._remote_identity}}]),a}(gp),Ko={},Sp=St,Yo=Mt(),Ap=Gs(),Ui=new Sp("Socket");Ko.isSocket=function(u){if(Array.isArray(u))return!1;if(typeof u>"u")return Ui.warn("undefined JsSIP.Socket instance"),!1;try{if(!Yo.isString(u.url))throw Ui.warn("missing or invalid JsSIP.Socket url property"),new Error("Missing or invalid JsSIP.Socket url property");if(!Yo.isString(u.via_transport))throw Ui.warn("missing or invalid JsSIP.Socket via_transport property"),new Error("Missing or invalid JsSIP.Socket via_transport property");if(Ap.parse(u.sip_uri,"SIP_URI")===-1)throw Ui.warn("missing or invalid JsSIP.Socket sip_uri property"),new Error("missing or invalid JsSIP.Socket sip_uri property")}catch{return!1}try{["connect","disconnect","send"].forEach(function(n){if(!Yo.isFunction(u[n]))throw Ui.warn("missing or invalid JsSIP.Socket method: ".concat(n)),new Error("Missing or invalid JsSIP.Socket method: ".concat(n))})}catch{return!1}return!0};function yp(u,n){if(!(u instanceof n))throw new TypeError("Cannot call a class as a function")}function nf(u,n){for(var a=0;a<n.length;a++){var e=n[a];e.enumerable=e.enumerable||!1,e.configurable=!0,"value"in e&&(e.writable=!0),Object.defineProperty(u,e.key,e)}}function Rp(u,n,a){return n&&nf(u.prototype,n),a&&nf(u,a),u}var bp=St,Ip=Ko,lf=pt,Wt=new bp("Transport"),as={STATUS_CONNECTED:0,STATUS_CONNECTING:1,STATUS_DISCONNECTED:2,SOCKET_STATUS_READY:0,SOCKET_STATUS_ERROR:1,recovery_options:{min_interval:lf.CONNECTION_RECOVERY_MIN_INTERVAL,max_interval:lf.CONNECTION_RECOVERY_MAX_INTERVAL}},wp=function(){function u(n){var a=arguments.length>1&&arguments[1]!==void 0?arguments[1]:as.recovery_options;yp(this,u),Wt.debug("new()"),this.status=as.STATUS_DISCONNECTED,this.socket=null,this.sockets=[],this.recovery_options=a,this.recover_attempts=0,this.recovery_timer=null,this.close_requested=!1;try{this.textDecoder=new TextDecoder("utf8")}catch(e){Wt.warn("cannot use TextDecoder: ".concat(e))}if(typeof n>"u")throw new TypeError("Invalid argument. undefined 'sockets' argument");n instanceof Array||(n=[n]),n.forEach(function(e){if(!Ip.isSocket(e.socket))throw new TypeError("Invalid argument. invalid 'JsSIP.Socket' instance");if(e.weight&&!Number(e.weight))throw new TypeError("Invalid argument. 'weight' attribute is not a number");this.sockets.push({socket:e.socket,weight:e.weight||0,status:as.SOCKET_STATUS_READY})},this),this._getSocket()}return Rp(u,[{key:"connect",value:function(){if(Wt.debug("connect()"),this.isConnected()){Wt.debug("Transport is already connected");return}else if(this.isConnecting()){Wt.debug("Transport is connecting");return}this.close_requested=!1,this.status=as.STATUS_CONNECTING,this.onconnecting({socket:this.socket,attempts:this.recover_attempts}),this.close_requested||(this.socket.onconnect=this._onConnect.bind(this),this.socket.ondisconnect=this._onDisconnect.bind(this),this.socket.ondata=this._onData.bind(this),this.socket.connect())}},{key:"disconnect",value:function(){Wt.debug("close()"),this.close_requested=!0,this.recover_attempts=0,this.status=as.STATUS_DISCONNECTED,this.recovery_timer!==null&&(clearTimeout(this.recovery_timer),this.recovery_timer=null),this.socket.onconnect=function(){},this.socket.ondisconnect=function(){},this.socket.ondata=function(){},this.socket.disconnect(),this.ondisconnect({socket:this.socket,error:!1})}},{key:"send",value:function(a){if(Wt.debug("send()"),!this.isConnected())return Wt.warn("unable to send message, transport is not connected"),!1;var e=a.toString();return Wt.debug(`sending message:
|
46
|
+
`),this.transport.send(p)}}]),i}(Ec),mh=function(c){_o(i,c);var s=po(i);function i(){var l;return gr(this,i),l=s.call(this),l.headers={},l.status_code=null,l.reason_phrase=null,l}return i}(Ec),cs={OutgoingRequest:vc,InitialOutgoingInviteRequest:dh,IncomingRequest:ph,IncomingResponse:mh};function gh(c,s){if(!(c instanceof s))throw new TypeError("Cannot call a class as a function")}function Sc(c,s){for(var i=0;i<s.length;i++){var l=s[i];l.enumerable=l.enumerable||!1,l.configurable=!0,"value"in l&&(l.writable=!0),Object.defineProperty(c,l.key,l)}}function Th(c,s,i){return s&&Sc(c.prototype,s),i&&Sc(c,i),c}var vh=ft,fs=It(),Bt=new vh("DigestAuthentication"),Eh=function(){function c(s){gh(this,c),this._credentials=s,this._cnonce=null,this._nc=0,this._ncHex="00000000",this._algorithm=null,this._realm=null,this._nonce=null,this._opaque=null,this._stale=null,this._qop=null,this._method=null,this._uri=null,this._ha1=null,this._response=null}return Th(c,[{key:"get",value:function(i){switch(i){case"realm":return this._realm;case"ha1":return this._ha1;default:Bt.warn('get() | cannot get "%s" parameter',i);return}}},{key:"authenticate",value:function(i,l){var a=i.method,_=i.ruri,e=i.body,p=arguments.length>2&&arguments[2]!==void 0?arguments[2]:null;if(this._algorithm=l.algorithm,this._realm=l.realm,this._nonce=l.nonce,this._opaque=l.opaque,this._stale=l.stale,this._algorithm){if(this._algorithm!=="MD5")return Bt.warn('authenticate() | challenge with Digest algorithm different than "MD5", authentication aborted'),!1}else this._algorithm="MD5";if(!this._nonce)return Bt.warn("authenticate() | challenge without Digest nonce, authentication aborted"),!1;if(!this._realm)return Bt.warn("authenticate() | challenge without Digest realm, authentication aborted"),!1;if(!this._credentials.password){if(!this._credentials.ha1)return Bt.warn("authenticate() | no plain SIP password nor ha1 provided, authentication aborted"),!1;if(this._credentials.realm!==this._realm)return Bt.warn('authenticate() | no plain SIP password, and stored `realm` does not match the given `realm`, cannot authenticate [stored:"%s", given:"%s"]',this._credentials.realm,this._realm),!1}if(l.qop)if(l.qop.indexOf("auth-int")>-1)this._qop="auth-int";else if(l.qop.indexOf("auth")>-1)this._qop="auth";else return Bt.warn('authenticate() | challenge without Digest qop different than "auth" or "auth-int", authentication aborted'),!1;else this._qop=null;this._method=a,this._uri=_,this._cnonce=p||fs.createRandomToken(12),this._nc+=1;var g=Number(this._nc).toString(16);this._ncHex="00000000".substr(0,8-g.length)+g,this._nc===4294967296&&(this._nc=1,this._ncHex="00000001"),this._credentials.password?this._ha1=fs.calculateMD5("".concat(this._credentials.username,":").concat(this._realm,":").concat(this._credentials.password)):this._ha1=this._credentials.ha1;var n,v;return this._qop==="auth"?(n="".concat(this._method,":").concat(this._uri),v=fs.calculateMD5(n),Bt.debug('authenticate() | using qop=auth [a2:"%s"]',n),this._response=fs.calculateMD5("".concat(this._ha1,":").concat(this._nonce,":").concat(this._ncHex,":").concat(this._cnonce,":auth:").concat(v))):this._qop==="auth-int"?(n="".concat(this._method,":").concat(this._uri,":").concat(fs.calculateMD5(e||"")),v=fs.calculateMD5(n),Bt.debug('authenticate() | using qop=auth-int [a2:"%s"]',n),this._response=fs.calculateMD5("".concat(this._ha1,":").concat(this._nonce,":").concat(this._ncHex,":").concat(this._cnonce,":auth-int:").concat(v))):this._qop===null&&(n="".concat(this._method,":").concat(this._uri),v=fs.calculateMD5(n),Bt.debug('authenticate() | using qop=null [a2:"%s"]',n),this._response=fs.calculateMD5("".concat(this._ha1,":").concat(this._nonce,":").concat(v))),Bt.debug("authenticate() | response generated"),!0}},{key:"toString",value:function(){var i=[];if(!this._response)throw new Error("response field does not exist, cannot generate Authorization header");return i.push("algorithm=".concat(this._algorithm)),i.push('username="'.concat(this._credentials.username,'"')),i.push('realm="'.concat(this._realm,'"')),i.push('nonce="'.concat(this._nonce,'"')),i.push('uri="'.concat(this._uri,'"')),i.push('response="'.concat(this._response,'"')),this._opaque&&i.push('opaque="'.concat(this._opaque,'"')),this._qop&&(i.push("qop=".concat(this._qop)),i.push('cnonce="'.concat(this._cnonce,'"')),i.push("nc=".concat(this._ncHex))),"Digest ".concat(i.join(", "))}}]),c}(),_s=500,Sh=4e3,yc=5e3,Ac={T1:_s,T2:Sh,T4:yc,TIMER_B:64*_s,TIMER_D:0*_s,TIMER_F:64*_s,TIMER_H:64*_s,TIMER_I:0*_s,TIMER_J:0*_s,TIMER_K:0*yc,TIMER_L:64*_s,TIMER_M:64*_s,PROVISIONAL_RESPONSE_INTERVAL:6e4};function Il(c){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?Il=function(i){return typeof i}:Il=function(i){return i&&typeof Symbol=="function"&&i.constructor===Symbol&&i!==Symbol.prototype?"symbol":typeof i},Il(c)}function Tr(c,s){if(!(c instanceof s))throw new TypeError("Cannot call a class as a function")}function Cc(c,s){for(var i=0;i<s.length;i++){var l=s[i];l.enumerable=l.enumerable||!1,l.configurable=!0,"value"in l&&(l.writable=!0),Object.defineProperty(c,l.key,l)}}function vr(c,s,i){return s&&Cc(c.prototype,s),i&&Cc(c,i),c}function Er(c,s){if(typeof s!="function"&&s!==null)throw new TypeError("Super expression must either be null or a function");c.prototype=Object.create(s&&s.prototype,{constructor:{value:c,writable:!0,configurable:!0}}),s&&go(c,s)}function go(c,s){return go=Object.setPrototypeOf||function(l,a){return l.__proto__=a,l},go(c,s)}function Sr(c){var s=Ah();return function(){var l=bl(c),a;if(s){var _=bl(this).constructor;a=Reflect.construct(l,arguments,_)}else a=l.apply(this,arguments);return yh(this,a)}}function yh(c,s){return s&&(Il(s)==="object"||typeof s=="function")?s:Ds(c)}function Ds(c){if(c===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return c}function Ah(){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 bl(c){return bl=Object.setPrototypeOf?Object.getPrototypeOf:function(i){return i.__proto__||Object.getPrototypeOf(i)},bl(c)}var yr=ct.EventEmitter,Ar=ft,Cr=it,Rc=cs,es=Ac,Ic=new Ar("NonInviteClientTransaction"),wl=new Ar("InviteClientTransaction"),Ch=new Ar("AckClientTransaction"),bc=new Ar("NonInviteServerTransaction"),Ol=new Ar("InviteServerTransaction"),ue={STATUS_TRYING:1,STATUS_PROCEEDING:2,STATUS_CALLING:3,STATUS_ACCEPTED:4,STATUS_COMPLETED:5,STATUS_TERMINATED:6,STATUS_CONFIRMED:7,NON_INVITE_CLIENT:"nict",NON_INVITE_SERVER:"nist",INVITE_CLIENT:"ict",INVITE_SERVER:"ist"},Rh=function(c){Er(i,c);var s=Sr(i);function i(l,a,_,e){var p;Tr(this,i),p=s.call(this),p.type=ue.NON_INVITE_CLIENT,p.id="z9hG4bK".concat(Math.floor(Math.random()*1e7)),p.ua=l,p.transport=a,p.request=_,p.eventHandlers=e;var g="SIP/2.0/".concat(a.via_transport);return g+=" ".concat(l.configuration.via_host,";branch=").concat(p.id),p.request.setHeader("via",g),p.ua.newTransaction(Ds(p)),p}return vr(i,[{key:"stateChanged",value:function(a){this.state=a,this.emit("stateChanged")}},{key:"send",value:function(){var a=this;this.stateChanged(ue.STATUS_TRYING),this.F=setTimeout(function(){a.timer_F()},es.TIMER_F),this.transport.send(this.request)||this.onTransportError()}},{key:"onTransportError",value:function(){Ic.debug("transport error occurred, deleting transaction ".concat(this.id)),clearTimeout(this.F),clearTimeout(this.K),this.stateChanged(ue.STATUS_TERMINATED),this.ua.destroyTransaction(this),this.eventHandlers.onTransportError()}},{key:"timer_F",value:function(){Ic.debug("Timer F expired for transaction ".concat(this.id)),this.stateChanged(ue.STATUS_TERMINATED),this.ua.destroyTransaction(this),this.eventHandlers.onRequestTimeout()}},{key:"timer_K",value:function(){this.stateChanged(ue.STATUS_TERMINATED),this.ua.destroyTransaction(this)}},{key:"receiveResponse",value:function(a){var _=this,e=a.status_code;if(e<200)switch(this.state){case ue.STATUS_TRYING:case ue.STATUS_PROCEEDING:this.stateChanged(ue.STATUS_PROCEEDING),this.eventHandlers.onReceiveResponse(a);break}else switch(this.state){case ue.STATUS_TRYING:case ue.STATUS_PROCEEDING:this.stateChanged(ue.STATUS_COMPLETED),clearTimeout(this.F),e===408?this.eventHandlers.onRequestTimeout():this.eventHandlers.onReceiveResponse(a),this.K=setTimeout(function(){_.timer_K()},es.TIMER_K);break;case ue.STATUS_COMPLETED:break}}},{key:"C",get:function(){return ue}}]),i}(yr),Ih=function(c){Er(i,c);var s=Sr(i);function i(l,a,_,e){var p;Tr(this,i),p=s.call(this),p.type=ue.INVITE_CLIENT,p.id="z9hG4bK".concat(Math.floor(Math.random()*1e7)),p.ua=l,p.transport=a,p.request=_,p.eventHandlers=e,_.transaction=Ds(p);var g="SIP/2.0/".concat(a.via_transport);return g+=" ".concat(l.configuration.via_host,";branch=").concat(p.id),p.request.setHeader("via",g),p.ua.newTransaction(Ds(p)),p}return vr(i,[{key:"stateChanged",value:function(a){this.state=a,this.emit("stateChanged")}},{key:"send",value:function(){var a=this;this.stateChanged(ue.STATUS_CALLING),this.B=setTimeout(function(){a.timer_B()},es.TIMER_B),this.transport.send(this.request)||this.onTransportError()}},{key:"onTransportError",value:function(){clearTimeout(this.B),clearTimeout(this.D),clearTimeout(this.M),this.state!==ue.STATUS_ACCEPTED&&(wl.debug("transport error occurred, deleting transaction ".concat(this.id)),this.eventHandlers.onTransportError()),this.stateChanged(ue.STATUS_TERMINATED),this.ua.destroyTransaction(this)}},{key:"timer_M",value:function(){wl.debug("Timer M expired for transaction ".concat(this.id)),this.state===ue.STATUS_ACCEPTED&&(clearTimeout(this.B),this.stateChanged(ue.STATUS_TERMINATED),this.ua.destroyTransaction(this))}},{key:"timer_B",value:function(){wl.debug("Timer B expired for transaction ".concat(this.id)),this.state===ue.STATUS_CALLING&&(this.stateChanged(ue.STATUS_TERMINATED),this.ua.destroyTransaction(this),this.eventHandlers.onRequestTimeout())}},{key:"timer_D",value:function(){wl.debug("Timer D expired for transaction ".concat(this.id)),clearTimeout(this.B),this.stateChanged(ue.STATUS_TERMINATED),this.ua.destroyTransaction(this)}},{key:"sendACK",value:function(a){var _=this,e=new Rc.OutgoingRequest(Cr.ACK,this.request.ruri,this.ua,{route_set:this.request.getHeaders("route"),call_id:this.request.getHeader("call-id"),cseq:this.request.cseq});e.setHeader("from",this.request.getHeader("from")),e.setHeader("via",this.request.getHeader("via")),e.setHeader("to",a.getHeader("to")),this.D=setTimeout(function(){_.timer_D()},es.TIMER_D),this.transport.send(e)}},{key:"cancel",value:function(a){if(this.state===ue.STATUS_PROCEEDING){var _=new Rc.OutgoingRequest(Cr.CANCEL,this.request.ruri,this.ua,{route_set:this.request.getHeaders("route"),call_id:this.request.getHeader("call-id"),cseq:this.request.cseq});_.setHeader("from",this.request.getHeader("from")),_.setHeader("via",this.request.getHeader("via")),_.setHeader("to",this.request.getHeader("to")),a&&_.setHeader("reason",a),this.transport.send(_)}}},{key:"receiveResponse",value:function(a){var _=this,e=a.status_code;if(e>=100&&e<=199)switch(this.state){case ue.STATUS_CALLING:this.stateChanged(ue.STATUS_PROCEEDING),this.eventHandlers.onReceiveResponse(a);break;case ue.STATUS_PROCEEDING:this.eventHandlers.onReceiveResponse(a);break}else if(e>=200&&e<=299)switch(this.state){case ue.STATUS_CALLING:case ue.STATUS_PROCEEDING:this.stateChanged(ue.STATUS_ACCEPTED),this.M=setTimeout(function(){_.timer_M()},es.TIMER_M),this.eventHandlers.onReceiveResponse(a);break;case ue.STATUS_ACCEPTED:this.eventHandlers.onReceiveResponse(a);break}else if(e>=300&&e<=699)switch(this.state){case ue.STATUS_CALLING:case ue.STATUS_PROCEEDING:this.stateChanged(ue.STATUS_COMPLETED),this.sendACK(a),this.eventHandlers.onReceiveResponse(a);break;case ue.STATUS_COMPLETED:this.sendACK(a);break}}},{key:"C",get:function(){return ue}}]),i}(yr),bh=function(c){Er(i,c);var s=Sr(i);function i(l,a,_,e){var p;Tr(this,i),p=s.call(this),p.id="z9hG4bK".concat(Math.floor(Math.random()*1e7)),p.transport=a,p.request=_,p.eventHandlers=e;var g="SIP/2.0/".concat(a.via_transport);return g+=" ".concat(l.configuration.via_host,";branch=").concat(p.id),p.request.setHeader("via",g),p}return vr(i,[{key:"send",value:function(){this.transport.send(this.request)||this.onTransportError()}},{key:"onTransportError",value:function(){Ch.debug("transport error occurred for transaction ".concat(this.id)),this.eventHandlers.onTransportError()}},{key:"C",get:function(){return ue}}]),i}(yr),wh=function(c){Er(i,c);var s=Sr(i);function i(l,a,_){var e;return Tr(this,i),e=s.call(this),e.type=ue.NON_INVITE_SERVER,e.id=_.via_branch,e.ua=l,e.transport=a,e.request=_,e.last_response="",_.server_transaction=Ds(e),e.state=ue.STATUS_TRYING,l.newTransaction(Ds(e)),e}return vr(i,[{key:"stateChanged",value:function(a){this.state=a,this.emit("stateChanged")}},{key:"timer_J",value:function(){bc.debug("Timer J expired for transaction ".concat(this.id)),this.stateChanged(ue.STATUS_TERMINATED),this.ua.destroyTransaction(this)}},{key:"onTransportError",value:function(){this.transportError||(this.transportError=!0,bc.debug("transport error occurred, deleting transaction ".concat(this.id)),clearTimeout(this.J),this.stateChanged(ue.STATUS_TERMINATED),this.ua.destroyTransaction(this))}},{key:"receiveResponse",value:function(a,_,e,p){var g=this;if(a===100)switch(this.state){case ue.STATUS_TRYING:this.stateChanged(ue.STATUS_PROCEEDING),this.transport.send(_)||this.onTransportError();break;case ue.STATUS_PROCEEDING:this.last_response=_,this.transport.send(_)?e&&e():(this.onTransportError(),p&&p());break}else if(a>=200&&a<=699)switch(this.state){case ue.STATUS_TRYING:case ue.STATUS_PROCEEDING:this.stateChanged(ue.STATUS_COMPLETED),this.last_response=_,this.J=setTimeout(function(){g.timer_J()},es.TIMER_J),this.transport.send(_)?e&&e():(this.onTransportError(),p&&p());break;case ue.STATUS_COMPLETED:break}}},{key:"C",get:function(){return ue}}]),i}(yr),Oh=function(c){Er(i,c);var s=Sr(i);function i(l,a,_){var e;return Tr(this,i),e=s.call(this),e.type=ue.INVITE_SERVER,e.id=_.via_branch,e.ua=l,e.transport=a,e.request=_,e.last_response="",_.server_transaction=Ds(e),e.state=ue.STATUS_PROCEEDING,l.newTransaction(Ds(e)),e.resendProvisionalTimer=null,_.reply(100),e}return vr(i,[{key:"stateChanged",value:function(a){this.state=a,this.emit("stateChanged")}},{key:"timer_H",value:function(){Ol.debug("Timer H expired for transaction ".concat(this.id)),this.state===ue.STATUS_COMPLETED&&Ol.debug("ACK not received, dialog will be terminated"),this.stateChanged(ue.STATUS_TERMINATED),this.ua.destroyTransaction(this)}},{key:"timer_I",value:function(){this.stateChanged(ue.STATUS_TERMINATED),this.ua.destroyTransaction(this)}},{key:"timer_L",value:function(){Ol.debug("Timer L expired for transaction ".concat(this.id)),this.state===ue.STATUS_ACCEPTED&&(this.stateChanged(ue.STATUS_TERMINATED),this.ua.destroyTransaction(this))}},{key:"onTransportError",value:function(){this.transportError||(this.transportError=!0,Ol.debug("transport error occurred, deleting transaction ".concat(this.id)),this.resendProvisionalTimer!==null&&(clearInterval(this.resendProvisionalTimer),this.resendProvisionalTimer=null),clearTimeout(this.L),clearTimeout(this.H),clearTimeout(this.I),this.stateChanged(ue.STATUS_TERMINATED),this.ua.destroyTransaction(this))}},{key:"resend_provisional",value:function(){this.transport.send(this.last_response)||this.onTransportError()}},{key:"receiveResponse",value:function(a,_,e,p){var g=this;if(a>=100&&a<=199)switch(this.state){case ue.STATUS_PROCEEDING:this.transport.send(_)||this.onTransportError(),this.last_response=_;break}if(a>100&&a<=199&&this.state===ue.STATUS_PROCEEDING)this.resendProvisionalTimer===null&&(this.resendProvisionalTimer=setInterval(function(){g.resend_provisional()},es.PROVISIONAL_RESPONSE_INTERVAL));else if(a>=200&&a<=299)switch(this.state){case ue.STATUS_PROCEEDING:this.stateChanged(ue.STATUS_ACCEPTED),this.last_response=_,this.L=setTimeout(function(){g.timer_L()},es.TIMER_L),this.resendProvisionalTimer!==null&&(clearInterval(this.resendProvisionalTimer),this.resendProvisionalTimer=null);case ue.STATUS_ACCEPTED:this.transport.send(_)?e&&e():(this.onTransportError(),p&&p());break}else if(a>=300&&a<=699)switch(this.state){case ue.STATUS_PROCEEDING:this.resendProvisionalTimer!==null&&(clearInterval(this.resendProvisionalTimer),this.resendProvisionalTimer=null),this.transport.send(_)?(this.stateChanged(ue.STATUS_COMPLETED),this.H=setTimeout(function(){g.timer_H()},es.TIMER_H),e&&e()):(this.onTransportError(),p&&p());break}}},{key:"C",get:function(){return ue}}]),i}(yr);function Dh(c,s){var i=c._transactions,l;switch(s.method){case Cr.INVITE:if(l=i.ist[s.via_branch],l){switch(l.state){case ue.STATUS_PROCEEDING:l.transport.send(l.last_response);break;case ue.STATUS_ACCEPTED:break}return!0}break;case Cr.ACK:if(l=i.ist[s.via_branch],l){if(l.state===ue.STATUS_ACCEPTED)return!1;if(l.state===ue.STATUS_COMPLETED)return l.state=ue.STATUS_CONFIRMED,l.I=setTimeout(function(){l.timer_I()},es.TIMER_I),!0}else return!1;break;case Cr.CANCEL:return l=i.ist[s.via_branch],l?(s.reply_sl(200),l.state!==ue.STATUS_PROCEEDING):(s.reply_sl(481),!0);default:if(l=i.nist[s.via_branch],l){switch(l.state){case ue.STATUS_TRYING:break;case ue.STATUS_PROCEEDING:case ue.STATUS_COMPLETED:l.transport.send(l.last_response);break}return!0}break}}var Rr={C:ue,NonInviteClientTransaction:Rh,InviteClientTransaction:Ih,AckClientTransaction:bh,NonInviteServerTransaction:wh,InviteServerTransaction:Oh,checkTransaction:Dh};function Nh(c,s){if(!(c instanceof s))throw new TypeError("Cannot call a class as a function")}function wc(c,s){for(var i=0;i<s.length;i++){var l=s[i];l.enumerable=l.enumerable||!1,l.configurable=!0,"value"in l&&(l.writable=!0),Object.defineProperty(c,l.key,l)}}function Uh(c,s,i){return s&&wc(c.prototype,s),i&&wc(c,i),c}var Ph=ft,Oc=it,xh=Eh,To=Rr,Mh=new Ph("RequestSender"),vo={onRequestTimeout:function(){},onTransportError:function(){},onReceiveResponse:function(){},onAuthenticated:function(){}},Ir=function(){function c(s,i,l){Nh(this,c),this._ua=s,this._eventHandlers=l,this._method=i.method,this._request=i,this._auth=null,this._challenged=!1,this._staled=!1;for(var a in vo)Object.prototype.hasOwnProperty.call(vo,a)&&(this._eventHandlers[a]||(this._eventHandlers[a]=vo[a]));s.status===s.C.STATUS_USER_CLOSED&&(this._method!==Oc.BYE||this._method!==Oc.ACK)&&this._eventHandlers.onTransportError()}return Uh(c,[{key:"send",value:function(){var i=this,l={onRequestTimeout:function(){i._eventHandlers.onRequestTimeout()},onTransportError:function(){i._eventHandlers.onTransportError()},onReceiveResponse:function(_){i._receiveResponse(_)}};switch(this._method){case"INVITE":this.clientTransaction=new To.InviteClientTransaction(this._ua,this._ua.transport,this._request,l);break;case"ACK":this.clientTransaction=new To.AckClientTransaction(this._ua,this._ua.transport,this._request,l);break;default:this.clientTransaction=new To.NonInviteClientTransaction(this._ua,this._ua.transport,this._request,l)}this._ua._configuration.authorization_jwt&&this._request.setHeader("Authorization",this._ua._configuration.authorization_jwt),this.clientTransaction.send()}},{key:"_receiveResponse",value:function(i){var l,a,_=i.status_code;if((_===401||_===407)&&(this._ua.configuration.password!==null||this._ua.configuration.ha1!==null)){if(i.status_code===401?(l=i.parseHeader("www-authenticate"),a="authorization"):(l=i.parseHeader("proxy-authenticate"),a="proxy-authorization"),!l){Mh.debug("".concat(i.status_code," with wrong or missing challenge, cannot authenticate")),this._eventHandlers.onReceiveResponse(i);return}if(!this._challenged||!this._staled&&l.stale===!0){if(this._auth||(this._auth=new xh({username:this._ua.configuration.authorization_user,password:this._ua.configuration.password,realm:this._ua.configuration.realm,ha1:this._ua.configuration.ha1})),!this._auth.authenticate(this._request,l)){this._eventHandlers.onReceiveResponse(i);return}this._challenged=!0,this._ua.set("realm",this._auth.get("realm")),this._ua.set("ha1",this._auth.get("ha1")),l.stale&&(this._staled=!0),this._request=this._request.clone(),this._request.cseq+=1,this._request.setHeader("cseq","".concat(this._request.cseq," ").concat(this._method)),this._request.setHeader(a,this._auth.toString()),this._eventHandlers.onAuthenticated(this._request),this.send()}else this._eventHandlers.onReceiveResponse(i)}else this._eventHandlers.onReceiveResponse(i)}}]),c}();function kh(c,s){if(!(c instanceof s))throw new TypeError("Cannot call a class as a function")}function Dc(c,s){for(var i=0;i<s.length;i++){var l=s[i];l.enumerable=l.enumerable||!1,l.configurable=!0,"value"in l&&(l.writable=!0),Object.defineProperty(c,l.key,l)}}function Lh(c,s,i){return s&&Dc(c.prototype,s),i&&Dc(c,i),c}var $h=ft,Eo=It(),rn=it,Nc=cs,Uc=Ir,br=new $h("Registrator"),Dl=10,Hh=function(){function c(s,i){kh(this,c),this._reg_id=1,this._ua=s,this._transport=i,this._registrar=s.configuration.registrar_server,this._expires=s.configuration.register_expires,this._call_id=Eo.createRandomToken(22),this._cseq=0,this._to_uri=s.configuration.uri,this._registrationTimer=null,this._registering=!1,this._registered=!1,this._contact=this._ua.contact.toString(),this._contact+=";+sip.ice",this._extraHeaders=[],this._extraContactParams="",this._sipInstance='"<urn:uuid:'.concat(this._ua.configuration.instance_id,'>"'),this._contact+=";reg-id=".concat(this._reg_id),this._contact+=";+sip.instance=".concat(this._sipInstance)}return Lh(c,[{key:"setExtraHeaders",value:function(i){Array.isArray(i)||(i=[]),this._extraHeaders=i.slice()}},{key:"setExtraContactParams",value:function(i){i instanceof Object||(i={}),this._extraContactParams="";for(var l in i)if(Object.prototype.hasOwnProperty.call(i,l)){var a=i[l];this._extraContactParams+=";".concat(l),a&&(this._extraContactParams+="=".concat(a))}}},{key:"register",value:function(){var i=this;if(this._registering){br.debug("Register request in progress...");return}var l=this._extraHeaders.slice();l.push("Contact: ".concat(this._contact,";expires=").concat(this._expires).concat(this._extraContactParams)),l.push("Expires: ".concat(this._expires));var a=new Nc.OutgoingRequest(rn.REGISTER,this._registrar,this._ua,{to_uri:this._to_uri,call_id:this._call_id,cseq:this._cseq+=1},l),_=new Uc(this._ua,a,{onRequestTimeout:function(){i._registrationFailure(null,rn.causes.REQUEST_TIMEOUT)},onTransportError:function(){i._registrationFailure(null,rn.causes.CONNECTION_ERROR)},onAuthenticated:function(){i._cseq+=1},onReceiveResponse:function(p){if(p.cseq===i._cseq)switch(i._registrationTimer!==null&&(clearTimeout(i._registrationTimer),i._registrationTimer=null),!0){case/^1[0-9]{2}$/.test(p.status_code):break;case/^2[0-9]{2}$/.test(p.status_code):{if(i._registering=!1,!p.hasHeader("Contact")){br.debug("no Contact header in response to REGISTER, response ignored");break}var g=p.headers.Contact.reduce(function(C,A){return C.concat(A.parsed)},[]),n=g.find(function(C){return i._sipInstance===C.getParam("+sip.instance")&&i._reg_id===parseInt(C.getParam("reg-id"))});if(n||(n=g.find(function(C){return C.uri.user===i._ua.contact.uri.user})),!n){br.debug("no Contact header pointing to us, response ignored");break}var v=n.getParam("expires");!v&&p.hasHeader("expires")&&(v=p.getHeader("expires")),v||(v=i._expires),v=Number(v),v<Dl&&(v=Dl);var S=v>64?v*1e3/2+Math.floor((v/2-32)*1e3*Math.random()):v*1e3-5e3;i._registrationTimer=setTimeout(function(){i._registrationTimer=null,i._ua.listeners("registrationExpiring").length===0?i.register():i._ua.emit("registrationExpiring")},S),n.hasParam("temp-gruu")&&(i._ua.contact.temp_gruu=n.getParam("temp-gruu").replace(/"/g,"")),n.hasParam("pub-gruu")&&(i._ua.contact.pub_gruu=n.getParam("pub-gruu").replace(/"/g,"")),i._registered||(i._registered=!0,i._ua.registered({response:p}));break}case/^423$/.test(p.status_code):{p.hasHeader("min-expires")?(i._expires=Number(p.getHeader("min-expires")),i._expires<Dl&&(i._expires=Dl),i.register()):(br.debug("423 response received for REGISTER without Min-Expires"),i._registrationFailure(p,rn.causes.SIP_FAILURE_CODE));break}default:{var m=Eo.sipErrorCause(p.status_code);i._registrationFailure(p,m)}}}});this._registering=!0,_.send()}},{key:"unregister",value:function(){var i=this,l=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(!this._registered){br.debug("already unregistered");return}this._registered=!1,this._registrationTimer!==null&&(clearTimeout(this._registrationTimer),this._registrationTimer=null);var a=this._extraHeaders.slice();l.all?a.push("Contact: *".concat(this._extraContactParams)):a.push("Contact: ".concat(this._contact,";expires=0").concat(this._extraContactParams)),a.push("Expires: 0");var _=new Nc.OutgoingRequest(rn.REGISTER,this._registrar,this._ua,{to_uri:this._to_uri,call_id:this._call_id,cseq:this._cseq+=1},a),e=new Uc(this._ua,_,{onRequestTimeout:function(){i._unregistered(null,rn.causes.REQUEST_TIMEOUT)},onTransportError:function(){i._unregistered(null,rn.causes.CONNECTION_ERROR)},onAuthenticated:function(){i._cseq+=1},onReceiveResponse:function(g){switch(!0){case/^1[0-9]{2}$/.test(g.status_code):break;case/^2[0-9]{2}$/.test(g.status_code):i._unregistered(g);break;default:{var n=Eo.sipErrorCause(g.status_code);i._unregistered(g,n)}}}});e.send()}},{key:"close",value:function(){this._registered&&this.unregister()}},{key:"onTransportClosed",value:function(){this._registering=!1,this._registrationTimer!==null&&(clearTimeout(this._registrationTimer),this._registrationTimer=null),this._registered&&(this._registered=!1,this._ua.unregistered({}))}},{key:"_registrationFailure",value:function(i,l){this._registering=!1,this._ua.registrationFailed({response:i||null,cause:l}),this._registered&&(this._registered=!1,this._ua.unregistered({response:i||null,cause:l}))}},{key:"_unregistered",value:function(i,l){this._registering=!1,this._registered=!1,this._ua.unregistered({response:i||null,cause:l||null})}},{key:"registered",get:function(){return this._registered}}]),c}();function Fh(c,s){if(!(c instanceof s))throw new TypeError("Cannot call a class as a function")}function Pc(c,s){for(var i=0;i<s.length;i++){var l=s[i];l.enumerable=l.enumerable||!1,l.configurable=!0,"value"in l&&(l.writable=!0),Object.defineProperty(c,l.key,l)}}function jh(c,s,i){return s&&Pc(c.prototype,s),i&&Pc(c,i),c}var So=it,Nl=Rr,qh=Ir,yo={onRequestTimeout:function(){},onTransportError:function(){},onSuccessResponse:function(){},onErrorResponse:function(){},onAuthenticated:function(){},onDialogError:function(){}},Vh=function(){function c(s,i,l){Fh(this,c),this._dialog=s,this._ua=s._ua,this._request=i,this._eventHandlers=l,this._reattempt=!1,this._reattemptTimer=null;for(var a in yo)Object.prototype.hasOwnProperty.call(yo,a)&&(this._eventHandlers[a]||(this._eventHandlers[a]=yo[a]))}return jh(c,[{key:"send",value:function(){var i=this,l=new qh(this._ua,this._request,{onRequestTimeout:function(){i._eventHandlers.onRequestTimeout()},onTransportError:function(){i._eventHandlers.onTransportError()},onAuthenticated:function(e){i._eventHandlers.onAuthenticated(e)},onReceiveResponse:function(e){i._receiveResponse(e)}});if(l.send(),(this._request.method===So.INVITE||this._request.method===So.UPDATE&&this._request.body)&&l.clientTransaction.state!==Nl.C.STATUS_TERMINATED){this._dialog.uac_pending_reply=!0;var a=function _(){(l.clientTransaction.state===Nl.C.STATUS_ACCEPTED||l.clientTransaction.state===Nl.C.STATUS_COMPLETED||l.clientTransaction.state===Nl.C.STATUS_TERMINATED)&&(l.clientTransaction.removeListener("stateChanged",_),i._dialog.uac_pending_reply=!1)};l.clientTransaction.on("stateChanged",a)}}},{key:"_receiveResponse",value:function(i){var l=this;i.status_code===408||i.status_code===481?this._eventHandlers.onDialogError(i):i.method===So.INVITE&&i.status_code===491?this._reattempt?i.status_code>=200&&i.status_code<300?this._eventHandlers.onSuccessResponse(i):i.status_code>=300&&this._eventHandlers.onErrorResponse(i):(this._request.cseq=this._dialog.local_seqnum+=1,this._reattemptTimer=setTimeout(function(){l._dialog.isTerminated()||(l._reattempt=!0,l.send())},1e3)):i.status_code>=200&&i.status_code<300?this._eventHandlers.onSuccessResponse(i):i.status_code>=300&&this._eventHandlers.onErrorResponse(i)}},{key:"request",get:function(){return this._request}}]),c}();function Bh(c,s){if(!(c instanceof s))throw new TypeError("Cannot call a class as a function")}function xc(c,s){for(var i=0;i<s.length;i++){var l=s[i];l.enumerable=l.enumerable||!1,l.configurable=!0,"value"in l&&(l.writable=!0),Object.defineProperty(c,l.key,l)}}function Mc(c,s,i){return s&&xc(c.prototype,s),i&&xc(c,i),c}var Gh=ft,kc=cs,Ns=it,wr=Rr,Wh=Vh,Ao=It(),Co=new Gh("Dialog"),Us={STATUS_EARLY:1,STATUS_CONFIRMED:2,STATUS_TERMINATED:3},Kh=function(){Mc(c,null,[{key:"C",get:function(){return Us}}]);function c(s,i,l){var a=arguments.length>3&&arguments[3]!==void 0?arguments[3]:Us.STATUS_CONFIRMED;if(Bh(this,c),this._owner=s,this._ua=s._ua,this._uac_pending_reply=!1,this._uas_pending_reply=!1,!i.hasHeader("contact"))return{error:"unable to create a Dialog without Contact header field"};i instanceof kc.IncomingResponse&&(a=i.status_code<200?Us.STATUS_EARLY:Us.STATUS_CONFIRMED);var _=i.parseHeader("contact");l==="UAS"?(this._id={call_id:i.call_id,local_tag:i.to_tag,remote_tag:i.from_tag,toString:function(){return this.call_id+this.local_tag+this.remote_tag}},this._state=a,this._remote_seqnum=i.cseq,this._local_uri=i.parseHeader("to").uri,this._remote_uri=i.parseHeader("from").uri,this._remote_target=_.uri,this._route_set=i.getHeaders("record-route"),this._ack_seqnum=this._remote_seqnum):l==="UAC"&&(this._id={call_id:i.call_id,local_tag:i.from_tag,remote_tag:i.to_tag,toString:function(){return this.call_id+this.local_tag+this.remote_tag}},this._state=a,this._local_seqnum=i.cseq,this._local_uri=i.parseHeader("from").uri,this._remote_uri=i.parseHeader("to").uri,this._remote_target=_.uri,this._route_set=i.getHeaders("record-route").reverse(),this._ack_seqnum=null),this._ua.newDialog(this),Co.debug("new ".concat(l," dialog created with status ").concat(this._state===Us.STATUS_EARLY?"EARLY":"CONFIRMED"))}return Mc(c,[{key:"isTerminated",value:function(){return this._status===Us.STATUS_TERMINATED}},{key:"update",value:function(i,l){this._state=Us.STATUS_CONFIRMED,Co.debug("dialog ".concat(this._id.toString()," changed to CONFIRMED state")),l==="UAC"&&(this._route_set=i.getHeaders("record-route").reverse())}},{key:"terminate",value:function(){Co.debug("dialog ".concat(this._id.toString()," deleted")),this._ua.destroyDialog(this),this._state=Us.STATUS_TERMINATED}},{key:"sendRequest",value:function(i){var l=this,a=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},_=Ao.cloneArray(a.extraHeaders),e=Ao.cloneObject(a.eventHandlers),p=a.body||null,g=this._createRequest(i,_,p);e.onAuthenticated=function(){l._local_seqnum+=1};var n=new Wh(this,g,e);return n.send(),g}},{key:"receiveRequest",value:function(i){this._checkInDialogRequest(i)&&(i.method===Ns.ACK&&this._ack_seqnum!==null?this._ack_seqnum=null:i.method===Ns.INVITE&&(this._ack_seqnum=i.cseq),this._owner.receiveRequest(i))}},{key:"_createRequest",value:function(i,l,a){l=Ao.cloneArray(l),this._local_seqnum||(this._local_seqnum=Math.floor(Math.random()*1e4));var _=i===Ns.CANCEL||i===Ns.ACK?this._local_seqnum:this._local_seqnum+=1,e=new kc.OutgoingRequest(i,this._remote_target,this._ua,{cseq:_,call_id:this._id.call_id,from_uri:this._local_uri,from_tag:this._id.local_tag,to_uri:this._remote_uri,to_tag:this._id.remote_tag,route_set:this._route_set},l,a);return e}},{key:"_checkInDialogRequest",value:function(i){var l=this;if(!this._remote_seqnum)this._remote_seqnum=i.cseq;else if(i.cseq<this._remote_seqnum)if(i.method===Ns.ACK){if(this._ack_seqnum===null||i.cseq!==this._ack_seqnum)return!1}else return i.reply(500),!1;else i.cseq>this._remote_seqnum&&(this._remote_seqnum=i.cseq);if(i.method===Ns.INVITE||i.method===Ns.UPDATE&&i.body){if(this._uac_pending_reply===!0)i.reply(491);else if(this._uas_pending_reply===!0){var a=(Math.random()*10|0)+1;return i.reply(500,null,["Retry-After:".concat(a)]),!1}else{this._uas_pending_reply=!0;var _=function e(){(i.server_transaction.state===wr.C.STATUS_ACCEPTED||i.server_transaction.state===wr.C.STATUS_COMPLETED||i.server_transaction.state===wr.C.STATUS_TERMINATED)&&(i.server_transaction.removeListener("stateChanged",e),l._uas_pending_reply=!1)};i.server_transaction.on("stateChanged",_)}i.hasHeader("contact")&&i.server_transaction.on("stateChanged",function(){i.server_transaction.state===wr.C.STATUS_ACCEPTED&&(l._remote_target=i.parseHeader("contact").uri)})}else i.method===Ns.NOTIFY&&i.hasHeader("contact")&&i.server_transaction.on("stateChanged",function(){i.server_transaction.state===wr.C.STATUS_COMPLETED&&(l._remote_target=i.parseHeader("contact").uri)});return!0}},{key:"id",get:function(){return this._id}},{key:"local_seqnum",get:function(){return this._local_seqnum},set:function(i){this._local_seqnum=i}},{key:"owner",get:function(){return this._owner}},{key:"uac_pending_reply",get:function(){return this._uac_pending_reply},set:function(i){this._uac_pending_reply=i}},{key:"uas_pending_reply",get:function(){return this._uas_pending_reply}}]),c}(),Ro={exports:{}};function Ul(c){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?Ul=function(i){return typeof i}:Ul=function(i){return i&&typeof Symbol=="function"&&i.constructor===Symbol&&i!==Symbol.prototype?"symbol":typeof i},Ul(c)}function Yh(c,s){if(!(c instanceof s))throw new TypeError("Cannot call a class as a function")}function Lc(c,s){for(var i=0;i<s.length;i++){var l=s[i];l.enumerable=l.enumerable||!1,l.configurable=!0,"value"in l&&(l.writable=!0),Object.defineProperty(c,l.key,l)}}function Jh(c,s,i){return s&&Lc(c.prototype,s),i&&Lc(c,i),c}function zh(c,s){if(typeof s!="function"&&s!==null)throw new TypeError("Super expression must either be null or a function");c.prototype=Object.create(s&&s.prototype,{constructor:{value:c,writable:!0,configurable:!0}}),s&&Io(c,s)}function Io(c,s){return Io=Object.setPrototypeOf||function(l,a){return l.__proto__=a,l},Io(c,s)}function Xh(c){var s=ed();return function(){var l=Pl(c),a;if(s){var _=Pl(this).constructor;a=Reflect.construct(l,arguments,_)}else a=l.apply(this,arguments);return Qh(this,a)}}function Qh(c,s){return s&&(Ul(s)==="object"||typeof s=="function")?s:Zh(c)}function Zh(c){if(c===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return c}function ed(){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 Pl(c){return Pl=Object.setPrototypeOf?Object.getPrototypeOf:function(i){return i.__proto__||Object.getPrototypeOf(i)},Pl(c)}var td=ct.EventEmitter,sd=ft,nd=it,rd=ws,$c=It(),id=new sd("RTCSession:DTMF"),Hc={MIN_DURATION:70,MAX_DURATION:6e3,DEFAULT_DURATION:100,MIN_INTER_TONE_GAP:50,DEFAULT_INTER_TONE_GAP:500};Ro.exports=function(c){zh(i,c);var s=Xh(i);function i(l){var a;return Yh(this,i),a=s.call(this),a._session=l,a._direction=null,a._tone=null,a._duration=null,a._request=null,a}return Jh(i,[{key:"send",value:function(a){var _=this,e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(a===void 0)throw new TypeError("Not enough arguments");if(this._direction="outgoing",this._session.status!==this._session.C.STATUS_CONFIRMED&&this._session.status!==this._session.C.STATUS_WAITING_FOR_ACK)throw new rd.InvalidStateError(this._session.status);var p=$c.cloneArray(e.extraHeaders);if(this.eventHandlers=$c.cloneObject(e.eventHandlers),typeof a=="string")a=a.toUpperCase();else if(typeof a=="number")a=a.toString();else throw new TypeError("Invalid tone: ".concat(a));if(a.match(/^[0-9A-DR#*]$/))this._tone=a;else throw new TypeError("Invalid tone: ".concat(a));this._duration=e.duration,p.push("Content-Type: application/dtmf-relay");var g="Signal=".concat(this._tone,`\r
|
47
|
+
`);g+="Duration=".concat(this._duration),this._session.newDTMF({originator:"local",dtmf:this,request:this._request}),this._session.sendRequest(nd.INFO,{extraHeaders:p,eventHandlers:{onSuccessResponse:function(v){_.emit("succeeded",{originator:"remote",response:v})},onErrorResponse:function(v){_.eventHandlers.onFailed&&_.eventHandlers.onFailed(),_.emit("failed",{originator:"remote",response:v})},onRequestTimeout:function(){_._session.onRequestTimeout()},onTransportError:function(){_._session.onTransportError()},onDialogError:function(){_._session.onDialogError()}},body:g})}},{key:"init_incoming",value:function(a){var _=/^(Signal\s*?=\s*?)([0-9A-D#*]{1})(\s)?.*/,e=/^(Duration\s?=\s?)([0-9]{1,4})(\s)?.*/;if(this._direction="incoming",this._request=a,a.reply(200),a.body){var p=a.body.split(`
|
48
|
+
`);p.length>=1&&_.test(p[0])&&(this._tone=p[0].replace(_,"$2")),p.length>=2&&e.test(p[1])&&(this._duration=parseInt(p[1].replace(e,"$2"),10))}this._duration||(this._duration=Hc.DEFAULT_DURATION),this._tone?this._session.newDTMF({originator:"remote",dtmf:this,request:a}):id.debug("invalid INFO DTMF received, discarded")}},{key:"tone",get:function(){return this._tone}},{key:"duration",get:function(){return this._duration}}]),i}(td),Ro.exports.C=Hc;var ld=Ro.exports;function xl(c){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?xl=function(i){return typeof i}:xl=function(i){return i&&typeof Symbol=="function"&&i.constructor===Symbol&&i!==Symbol.prototype?"symbol":typeof i},xl(c)}function ad(c,s){if(!(c instanceof s))throw new TypeError("Cannot call a class as a function")}function Fc(c,s){for(var i=0;i<s.length;i++){var l=s[i];l.enumerable=l.enumerable||!1,l.configurable=!0,"value"in l&&(l.writable=!0),Object.defineProperty(c,l.key,l)}}function od(c,s,i){return s&&Fc(c.prototype,s),i&&Fc(c,i),c}function ud(c,s){if(typeof s!="function"&&s!==null)throw new TypeError("Super expression must either be null or a function");c.prototype=Object.create(s&&s.prototype,{constructor:{value:c,writable:!0,configurable:!0}}),s&&bo(c,s)}function bo(c,s){return bo=Object.setPrototypeOf||function(l,a){return l.__proto__=a,l},bo(c,s)}function cd(c){var s=hd();return function(){var l=Ml(c),a;if(s){var _=Ml(this).constructor;a=Reflect.construct(l,arguments,_)}else a=l.apply(this,arguments);return fd(this,a)}}function fd(c,s){return s&&(xl(s)==="object"||typeof s=="function")?s:_d(c)}function _d(c){if(c===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return c}function hd(){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 Ml(c){return Ml=Object.setPrototypeOf?Object.getPrototypeOf:function(i){return i.__proto__||Object.getPrototypeOf(i)},Ml(c)}var dd=ct.EventEmitter,pd=it,md=ws,gd=It(),Td=function(c){ud(i,c);var s=cd(i);function i(l){var a;return ad(this,i),a=s.call(this),a._session=l,a._direction=null,a._contentType=null,a._body=null,a}return od(i,[{key:"send",value:function(a,_){var e=this,p=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};if(this._direction="outgoing",a===void 0)throw new TypeError("Not enough arguments");if(this._session.status!==this._session.C.STATUS_CONFIRMED&&this._session.status!==this._session.C.STATUS_WAITING_FOR_ACK)throw new md.InvalidStateError(this._session.status);this._contentType=a,this._body=_;var g=gd.cloneArray(p.extraHeaders);g.push("Content-Type: ".concat(a)),this._session.newInfo({originator:"local",info:this,request:this.request}),this._session.sendRequest(pd.INFO,{extraHeaders:g,eventHandlers:{onSuccessResponse:function(v){e.emit("succeeded",{originator:"remote",response:v})},onErrorResponse:function(v){e.emit("failed",{originator:"remote",response:v})},onTransportError:function(){e._session.onTransportError()},onRequestTimeout:function(){e._session.onRequestTimeout()},onDialogError:function(){e._session.onDialogError()}},body:_})}},{key:"init_incoming",value:function(a){this._direction="incoming",this.request=a,a.reply(200),this._contentType=a.hasHeader("Content-Type")?a.getHeader("Content-Type").toLowerCase():void 0,this._body=a.body,this._session.newInfo({originator:"remote",info:this,request:a})}},{key:"contentType",get:function(){return this._contentType}},{key:"body",get:function(){return this._body}}]),i}(dd);function vd(c,s){if(!(c instanceof s))throw new TypeError("Cannot call a class as a function")}function jc(c,s){for(var i=0;i<s.length;i++){var l=s[i];l.enumerable=l.enumerable||!1,l.configurable=!0,"value"in l&&(l.writable=!0),Object.defineProperty(c,l.key,l)}}function Ed(c,s,i){return s&&jc(c.prototype,s),i&&jc(c,i),c}var Sd=ft,qc=it,yd=new Sd("RTCSession:ReferNotifier"),wo={event_type:"refer",body_type:"message/sipfrag;version=2.0",expires:300},Ad=function(){function c(s,i,l){vd(this,c),this._session=s,this._id=i,this._expires=l||wo.expires,this._active=!0,this.notify(100)}return Ed(c,[{key:"notify",value:function(i,l){if(yd.debug("notify()"),this._active!==!1){l=l||qc.REASON_PHRASE[i]||"";var a;i>=200?a="terminated;reason=noresource":a="active;expires=".concat(this._expires),this._session.sendRequest(qc.NOTIFY,{extraHeaders:["Event: ".concat(wo.event_type,";id=").concat(this._id),"Subscription-State: ".concat(a),"Content-Type: ".concat(wo.body_type)],body:"SIP/2.0 ".concat(i," ").concat(l),eventHandlers:{onErrorResponse:function(){this._active=!1}}})}}}]),c}();function kl(c){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?kl=function(i){return typeof i}:kl=function(i){return i&&typeof Symbol=="function"&&i.constructor===Symbol&&i!==Symbol.prototype?"symbol":typeof i},kl(c)}function Cd(c,s){if(!(c instanceof s))throw new TypeError("Cannot call a class as a function")}function Vc(c,s){for(var i=0;i<s.length;i++){var l=s[i];l.enumerable=l.enumerable||!1,l.configurable=!0,"value"in l&&(l.writable=!0),Object.defineProperty(c,l.key,l)}}function Rd(c,s,i){return s&&Vc(c.prototype,s),i&&Vc(c,i),c}function Id(c,s){if(typeof s!="function"&&s!==null)throw new TypeError("Super expression must either be null or a function");c.prototype=Object.create(s&&s.prototype,{constructor:{value:c,writable:!0,configurable:!0}}),s&&Oo(c,s)}function Oo(c,s){return Oo=Object.setPrototypeOf||function(l,a){return l.__proto__=a,l},Oo(c,s)}function bd(c){var s=Dd();return function(){var l=Ll(c),a;if(s){var _=Ll(this).constructor;a=Reflect.construct(l,arguments,_)}else a=l.apply(this,arguments);return wd(this,a)}}function wd(c,s){return s&&(kl(s)==="object"||typeof s=="function")?s:Od(c)}function Od(c){if(c===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return c}function Dd(){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 Ll(c){return Ll=Object.setPrototypeOf?Object.getPrototypeOf:function(i){return i.__proto__||Object.getPrototypeOf(i)},Ll(c)}var Nd=ct.EventEmitter,Ud=ft,Or=it,Pd=Zt(),Bc=It(),ln=new Ud("RTCSession:ReferSubscriber"),xd=function(c){Id(i,c);var s=bd(i);function i(l){var a;return Cd(this,i),a=s.call(this),a._id=null,a._session=l,a}return Rd(i,[{key:"sendRefer",value:function(a){var _=this,e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};ln.debug("sendRefer()");var p=Bc.cloneArray(e.extraHeaders),g=Bc.cloneObject(e.eventHandlers);for(var n in g)Object.prototype.hasOwnProperty.call(g,n)&&this.on(n,g[n]);var v=null;e.replaces&&(v=e.replaces._request.call_id,v+=";to-tag=".concat(e.replaces._to_tag),v+=";from-tag=".concat(e.replaces._from_tag),v=encodeURIComponent(v));var S="Refer-To: <".concat(a).concat(v?"?Replaces=".concat(v):"",">");if(p.push(S),!p.some(function(A){return A.toLowerCase().startsWith("referred-by:")})){var m="Referred-By: <".concat(this._session._ua._configuration.uri._scheme,":").concat(this._session._ua._configuration.uri._user,"@").concat(this._session._ua._configuration.uri._host,">");p.push(m)}p.push("Contact: ".concat(this._session.contact));var C=this._session.sendRequest(Or.REFER,{extraHeaders:p,eventHandlers:{onSuccessResponse:function(R){_._requestSucceeded(R)},onErrorResponse:function(R){_._requestFailed(R,Or.causes.REJECTED)},onTransportError:function(){_._requestFailed(null,Or.causes.CONNECTION_ERROR)},onRequestTimeout:function(){_._requestFailed(null,Or.causes.REQUEST_TIMEOUT)},onDialogError:function(){_._requestFailed(null,Or.causes.DIALOG_ERROR)}}});this._id=C.cseq}},{key:"receiveNotify",value:function(a){if(ln.debug("receiveNotify()"),!!a.body){var _=Pd.parse(a.body.trim().split(`\r
|
49
|
+
`,1)[0],"Status_Line");if(_===-1){ln.debug('receiveNotify() | error parsing NOTIFY body: "'.concat(a.body,'"'));return}switch(!0){case/^100$/.test(_.status_code):this.emit("trying",{request:a,status_line:_});break;case/^1[0-9]{2}$/.test(_.status_code):this.emit("progress",{request:a,status_line:_});break;case/^2[0-9]{2}$/.test(_.status_code):this.emit("accepted",{request:a,status_line:_});break;default:this.emit("failed",{request:a,status_line:_});break}}}},{key:"_requestSucceeded",value:function(a){ln.debug("REFER succeeded"),ln.debug('emit "requestSucceeded"'),this.emit("requestSucceeded",{response:a})}},{key:"_requestFailed",value:function(a,_){ln.debug("REFER failed"),ln.debug('emit "requestFailed"'),this.emit("requestFailed",{response:a||null,cause:_})}},{key:"id",get:function(){return this._id}}]),i}(Nd);function $l(c){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?$l=function(i){return typeof i}:$l=function(i){return i&&typeof Symbol=="function"&&i.constructor===Symbol&&i!==Symbol.prototype?"symbol":typeof i},$l(c)}function hs(c,s){var i;if(typeof Symbol>"u"||c[Symbol.iterator]==null){if(Array.isArray(c)||(i=Md(c))||s&&c&&typeof c.length=="number"){i&&(c=i);var l=0,a=function(){};return{s:a,n:function(){return l>=c.length?{done:!0}:{done:!1,value:c[l++]}},e:function(n){throw n},f:a}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
|
50
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var _=!0,e=!1,p;return{s:function(){i=c[Symbol.iterator]()},n:function(){var n=i.next();return _=n.done,n},e:function(n){e=!0,p=n},f:function(){try{!_&&i.return!=null&&i.return()}finally{if(e)throw p}}}}function Md(c,s){if(c){if(typeof c=="string")return Gc(c,s);var i=Object.prototype.toString.call(c).slice(8,-1);if(i==="Object"&&c.constructor&&(i=c.constructor.name),i==="Map"||i==="Set")return Array.from(c);if(i==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i))return Gc(c,s)}}function Gc(c,s){(s==null||s>c.length)&&(s=c.length);for(var i=0,l=new Array(s);i<s;i++)l[i]=c[i];return l}function kd(c,s){if(!(c instanceof s))throw new TypeError("Cannot call a class as a function")}function Wc(c,s){for(var i=0;i<s.length;i++){var l=s[i];l.enumerable=l.enumerable||!1,l.configurable=!0,"value"in l&&(l.writable=!0),Object.defineProperty(c,l.key,l)}}function Kc(c,s,i){return s&&Wc(c.prototype,s),i&&Wc(c,i),c}function Ld(c,s){if(typeof s!="function"&&s!==null)throw new TypeError("Super expression must either be null or a function");c.prototype=Object.create(s&&s.prototype,{constructor:{value:c,writable:!0,configurable:!0}}),s&&Do(c,s)}function Do(c,s){return Do=Object.setPrototypeOf||function(l,a){return l.__proto__=a,l},Do(c,s)}function $d(c){var s=jd();return function(){var l=Hl(c),a;if(s){var _=Hl(this).constructor;a=Reflect.construct(l,arguments,_)}else a=l.apply(this,arguments);return Hd(this,a)}}function Hd(c,s){return s&&($l(s)==="object"||typeof s=="function")?s:Fd(c)}function Fd(c){if(c===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return c}function jd(){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 Hl(c){return Hl=Object.setPrototypeOf?Object.getPrototypeOf:function(i){return i.__proto__||Object.getPrototypeOf(i)},Hl(c)}var qd=ct.EventEmitter,Yc=xt,Vd=ft,ce=it,an=ws,Jc=Rr,Je=It(),Dr=Ac,Bd=cs,Fl=Kh,Gd=Ir,Lt=ld,zc=Td,Wd=Ad,Kd=xd,Xc=Os(),Y=new Vd("RTCSession"),ee={STATUS_NULL:0,STATUS_INVITE_SENT:1,STATUS_1XX_RECEIVED:2,STATUS_INVITE_RECEIVED:3,STATUS_WAITING_FOR_ANSWER:4,STATUS_ANSWERED:5,STATUS_WAITING_FOR_ACK:6,STATUS_CANCELED:7,STATUS_TERMINATED:8,STATUS_CONFIRMED:9},jl=["audio","video"],Yd=function(c){Ld(i,c);var s=$d(i);Kc(i,null,[{key:"C",get:function(){return ee}}]);function i(l){var a;return kd(this,i),Y.debug("new"),a=s.call(this),a._id=null,a._ua=l,a._status=ee.STATUS_NULL,a._dialog=null,a._earlyDialogs={},a._contact=null,a._from_tag=null,a._to_tag=null,a._connection=null,a._connectionPromiseQueue=Promise.resolve(),a._request=null,a._is_canceled=!1,a._cancel_reason="",a._is_confirmed=!1,a._late_sdp=!1,a._rtcOfferConstraints=null,a._rtcAnswerConstraints=null,a._localMediaStream=null,a._localMediaStreamLocallyGenerated=!1,a._rtcReady=!0,a._iceReady=!1,a._timers={ackTimer:null,expiresTimer:null,invite2xxTimer:null,userNoAnswerTimer:null},a._direction=null,a._local_identity=null,a._remote_identity=null,a._start_time=null,a._end_time=null,a._tones=null,a._audioMuted=!1,a._videoMuted=!1,a._localHold=!1,a._remoteHold=!1,a._sessionTimers={enabled:a._ua.configuration.session_timers,refreshMethod:a._ua.configuration.session_timers_refresh_method,defaultExpires:ce.SESSION_EXPIRES,currentExpires:null,running:!1,refresher:!1,timer:null},a._referSubscribers={},a._data={},a}return Kc(i,[{key:"isInProgress",value:function(){switch(this._status){case ee.STATUS_NULL:case ee.STATUS_INVITE_SENT:case ee.STATUS_1XX_RECEIVED:case ee.STATUS_INVITE_RECEIVED:case ee.STATUS_WAITING_FOR_ANSWER:return!0;default:return!1}}},{key:"isEstablished",value:function(){switch(this._status){case ee.STATUS_ANSWERED:case ee.STATUS_WAITING_FOR_ACK:case ee.STATUS_CONFIRMED:return!0;default:return!1}}},{key:"isEnded",value:function(){switch(this._status){case ee.STATUS_CANCELED:case ee.STATUS_TERMINATED:return!0;default:return!1}}},{key:"isMuted",value:function(){return{audio:this._audioMuted,video:this._videoMuted}}},{key:"isOnHold",value:function(){return{local:this._localHold,remote:this._remoteHold}}},{key:"connect",value:function(a){var _=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},e=arguments.length>2?arguments[2]:void 0;Y.debug("connect()");var p=a,g=Je.cloneObject(_.eventHandlers),n=Je.cloneArray(_.extraHeaders),v=Je.cloneObject(_.mediaConstraints,{audio:!0,video:!0}),S=_.mediaStream||null,m=Je.cloneObject(_.pcConfig,{iceServers:[]}),C=_.rtcConstraints||null,A=_.rtcOfferConstraints||null;if(this._rtcOfferConstraints=A,this._rtcAnswerConstraints=_.rtcAnswerConstraints||null,this._data=_.data||this._data,a===void 0)throw new TypeError("Not enough arguments");if(this._status!==ee.STATUS_NULL)throw new an.InvalidStateError(this._status);if(!window.RTCPeerConnection)throw new an.NotSupportedError("WebRTC not supported");if(a=this._ua.normalizeTarget(a),!a)throw new TypeError("Invalid target: ".concat(p));this._sessionTimers.enabled&&Je.isDecimal(_.sessionTimersExpires)&&(_.sessionTimersExpires>=ce.MIN_SESSION_EXPIRES?this._sessionTimers.defaultExpires=_.sessionTimersExpires:this._sessionTimers.defaultExpires=ce.SESSION_EXPIRES);for(var R in g)Object.prototype.hasOwnProperty.call(g,R)&&this.on(R,g[R]);this._from_tag=Je.newTag();var I=_.anonymous||!1,V={from_tag:this._from_tag};this._contact=this._ua.contact.toString({anonymous:I,outbound:!0}),I?(V.from_display_name="Anonymous",V.from_uri=new Xc("sip","anonymous","anonymous.invalid"),n.push("P-Preferred-Identity: ".concat(this._ua.configuration.uri.toString())),n.push("Privacy: id")):_.fromUserName&&(V.from_uri=new Xc("sip",_.fromUserName,this._ua.configuration.uri.host),n.push("P-Preferred-Identity: ".concat(this._ua.configuration.uri.toString()))),_.fromDisplayName&&(V.from_display_name=_.fromDisplayName),n.push("Contact: ".concat(this._contact)),n.push("Content-Type: application/sdp"),this._sessionTimers.enabled&&n.push("Session-Expires: ".concat(this._sessionTimers.defaultExpires).concat(this._ua.configuration.session_timers_force_refresher?";refresher=uac":"")),this._request=new Bd.InitialOutgoingInviteRequest(a,this._ua,V,n),this._id=this._request.call_id+this._from_tag,this._createRTCConnection(m,C),this._direction="outgoing",this._local_identity=this._request.from,this._remote_identity=this._request.to,e&&e(this),this._newRTCSession("local",this._request),this._sendInitialRequest(v,A,S)}},{key:"init_incoming",value:function(a,_){var e=this;Y.debug("init_incoming()");var p,g=a.hasHeader("Content-Type")?a.getHeader("Content-Type").toLowerCase():void 0;if(a.body&&g!=="application/sdp"){a.reply(415);return}if(this._status=ee.STATUS_INVITE_RECEIVED,this._from_tag=a.from_tag,this._id=a.call_id+this._from_tag,this._request=a,this._contact=this._ua.contact.toString(),a.hasHeader("expires")&&(p=a.getHeader("expires")*1e3),a.to_tag=Je.newTag(),!this._createDialog(a,"UAS",!0)){a.reply(500,"Missing Contact header field");return}a.body?this._late_sdp=!1:this._late_sdp=!0,this._status=ee.STATUS_WAITING_FOR_ANSWER,this._timers.userNoAnswerTimer=setTimeout(function(){a.reply(408),e._failed("local",null,ce.causes.NO_ANSWER)},this._ua.configuration.no_answer_timeout),p&&(this._timers.expiresTimer=setTimeout(function(){e._status===ee.STATUS_WAITING_FOR_ANSWER&&(a.reply(487),e._failed("system",null,ce.causes.EXPIRES))},p)),this._direction="incoming",this._local_identity=a.to,this._remote_identity=a.from,_&&_(this),this._newRTCSession("remote",a),this._status!==ee.STATUS_TERMINATED&&(a.reply(180,null,["Contact: ".concat(this._contact)]),this._progress("local",null))}},{key:"answer",value:function(){var a=this,_=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};Y.debug("answer()");var e=this._request,p=Je.cloneArray(_.extraHeaders),g=Je.cloneObject(_.mediaConstraints),n=_.mediaStream||null,v=Je.cloneObject(_.pcConfig,{iceServers:[]}),S=_.rtcConstraints||null,m=_.rtcAnswerConstraints||null,C=Je.cloneObject(_.rtcOfferConstraints),A,R=!1,I=!1,V=!1,W=!1;if(this._rtcAnswerConstraints=m,this._rtcOfferConstraints=_.rtcOfferConstraints||null,this._data=_.data||this._data,this._direction!=="incoming")throw new an.NotSupportedError('"answer" not supported for outgoing RTCSession');if(this._status!==ee.STATUS_WAITING_FOR_ANSWER)throw new an.InvalidStateError(this._status);if(this._sessionTimers.enabled&&Je.isDecimal(_.sessionTimersExpires)&&(_.sessionTimersExpires>=ce.MIN_SESSION_EXPIRES?this._sessionTimers.defaultExpires=_.sessionTimersExpires:this._sessionTimers.defaultExpires=ce.SESSION_EXPIRES),this._status=ee.STATUS_ANSWERED,!this._createDialog(e,"UAS")){e.reply(500,"Error creating dialog");return}clearTimeout(this._timers.userNoAnswerTimer),p.unshift("Contact: ".concat(this._contact));var oe=e.parseSDP();Array.isArray(oe.media)||(oe.media=[oe.media]);var x=hs(oe.media),$;try{for(x.s();!($=x.n()).done;){var Re=$.value;Re.type==="audio"&&(R=!0,(!Re.direction||Re.direction==="sendrecv")&&(V=!0)),Re.type==="video"&&(I=!0,(!Re.direction||Re.direction==="sendrecv")&&(W=!0))}}catch(B){x.e(B)}finally{x.f()}if(n&&g.audio===!1){A=n.getAudioTracks();var be=hs(A),H;try{for(be.s();!(H=be.n()).done;){var D=H.value;n.removeTrack(D)}}catch(B){be.e(B)}finally{be.f()}}if(n&&g.video===!1){A=n.getVideoTracks();var L=hs(A),q;try{for(L.s();!(q=L.n()).done;){var j=q.value;n.removeTrack(j)}}catch(B){L.e(B)}finally{L.f()}}!n&&g.audio===void 0&&(g.audio=V),!n&&g.video===void 0&&(g.video=W),!n&&!R&&!C.offerToReceiveAudio&&(g.audio=!1),!n&&!I&&!C.offerToReceiveVideo&&(g.video=!1),this._createRTCConnection(v,S),Promise.resolve().then(function(){if(n)return n;if(g.audio||g.video)return a._localMediaStreamLocallyGenerated=!0,navigator.mediaDevices.getUserMedia(g).catch(function(B){throw a._status===ee.STATUS_TERMINATED?new Error("terminated"):(e.reply(480),a._failed("local",null,ce.causes.USER_DENIED_MEDIA_ACCESS),Y.warn('emit "getusermediafailed" [error:%o]',B),a.emit("getusermediafailed",B),new Error("getUserMedia() failed"))})}).then(function(B){if(a._status===ee.STATUS_TERMINATED)throw new Error("terminated");a._localMediaStream=B,B&&B.getTracks().forEach(function(Q){a._connection.addTrack(Q,B)})}).then(function(){if(!a._late_sdp){var B={originator:"remote",type:"offer",sdp:e.body};Y.debug('emit "sdp"'),a.emit("sdp",B);var Q=new RTCSessionDescription({type:"offer",sdp:B.sdp});return a._connectionPromiseQueue=a._connectionPromiseQueue.then(function(){return a._connection.setRemoteDescription(Q)}).catch(function(Z){throw e.reply(488),a._failed("system",null,ce.causes.WEBRTC_ERROR),Y.warn('emit "peerconnection:setremotedescriptionfailed" [error:%o]',Z),a.emit("peerconnection:setremotedescriptionfailed",Z),new Error("peerconnection.setRemoteDescription() failed")}),a._connectionPromiseQueue}}).then(function(){if(a._status===ee.STATUS_TERMINATED)throw new Error("terminated");return a._connecting(e),a._late_sdp?a._createLocalDescription("offer",a._rtcOfferConstraints).catch(function(){throw e.reply(500),new Error("_createLocalDescription() failed")}):a._createLocalDescription("answer",m).catch(function(){throw e.reply(500),new Error("_createLocalDescription() failed")})}).then(function(B){if(a._status===ee.STATUS_TERMINATED)throw new Error("terminated");a._handleSessionTimersInIncomingRequest(e,p),e.reply(200,null,p,B,function(){a._status=ee.STATUS_WAITING_FOR_ACK,a._setInvite2xxTimer(e,B),a._setACKTimer(),a._accepted("local")},function(){a._failed("system",null,ce.causes.CONNECTION_ERROR)})}).catch(function(B){a._status!==ee.STATUS_TERMINATED&&Y.warn(B)})}},{key:"terminate",value:function(){var a=this,_=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};Y.debug("terminate()");var e=_.cause||ce.causes.BYE,p=Je.cloneArray(_.extraHeaders),g=_.body,n,v=_.status_code,S=_.reason_phrase;if(this._status===ee.STATUS_TERMINATED)throw new an.InvalidStateError(this._status);switch(this._status){case ee.STATUS_NULL:case ee.STATUS_INVITE_SENT:case ee.STATUS_1XX_RECEIVED:if(Y.debug("canceling session"),v&&(v<200||v>=700))throw new TypeError("Invalid status_code: ".concat(v));v&&(S=S||ce.REASON_PHRASE[v]||"",n="SIP ;cause=".concat(v,' ;text="').concat(S,'"')),this._status===ee.STATUS_NULL||this._status===ee.STATUS_INVITE_SENT?(this._is_canceled=!0,this._cancel_reason=n):this._status===ee.STATUS_1XX_RECEIVED&&this._request.cancel(n),this._status=ee.STATUS_CANCELED,this._failed("local",null,ce.causes.CANCELED);break;case ee.STATUS_WAITING_FOR_ANSWER:case ee.STATUS_ANSWERED:if(Y.debug("rejecting session"),v=v||480,v<300||v>=700)throw new TypeError("Invalid status_code: ".concat(v));this._request.reply(v,S,p,g),this._failed("local",null,ce.causes.REJECTED);break;case ee.STATUS_WAITING_FOR_ACK:case ee.STATUS_CONFIRMED:if(Y.debug("terminating session"),S=_.reason_phrase||ce.REASON_PHRASE[v]||"",v&&(v<200||v>=700))throw new TypeError("Invalid status_code: ".concat(v));if(v&&p.push("Reason: SIP ;cause=".concat(v,'; text="').concat(S,'"')),this._status===ee.STATUS_WAITING_FOR_ACK&&this._direction==="incoming"&&this._request.server_transaction.state!==Jc.C.STATUS_TERMINATED){var m=this._dialog;this.receiveRequest=function(C){var A=C.method;A===ce.ACK&&(a.sendRequest(ce.BYE,{extraHeaders:p,body:g}),m.terminate())},this._request.server_transaction.on("stateChanged",function(){a._request.server_transaction.state===Jc.C.STATUS_TERMINATED&&(a.sendRequest(ce.BYE,{extraHeaders:p,body:g}),m.terminate())}),this._ended("local",null,e),this._dialog=m,this._ua.newDialog(m)}else this.sendRequest(ce.BYE,{extraHeaders:p,body:g}),this._ended("local",null,e)}}},{key:"sendDTMF",value:function(a){var _=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};Y.debug("sendDTMF() | tones: %s",a);var e=0,p=_.duration||null,g=_.interToneGap||null,n=_.transportType||ce.DTMF_TRANSPORT.INFO;if(a===void 0)throw new TypeError("Not enough arguments");if(this._status!==ee.STATUS_CONFIRMED&&this._status!==ee.STATUS_WAITING_FOR_ACK&&this._status!==ee.STATUS_1XX_RECEIVED)throw new an.InvalidStateError(this._status);if(n!==ce.DTMF_TRANSPORT.INFO&&n!==ce.DTMF_TRANSPORT.RFC2833)throw new TypeError("invalid transportType: ".concat(n));if(typeof a=="number"&&(a=a.toString()),!a||typeof a!="string"||!a.match(/^[0-9A-DR#*,]+$/i))throw new TypeError("Invalid tones: ".concat(a));if(p&&!Je.isDecimal(p))throw new TypeError("Invalid tone duration: ".concat(p));if(p?p<Lt.C.MIN_DURATION?(Y.debug('"duration" value is lower than the minimum allowed, setting it to '.concat(Lt.C.MIN_DURATION," milliseconds")),p=Lt.C.MIN_DURATION):p>Lt.C.MAX_DURATION?(Y.debug('"duration" value is greater than the maximum allowed, setting it to '.concat(Lt.C.MAX_DURATION," milliseconds")),p=Lt.C.MAX_DURATION):p=Math.abs(p):p=Lt.C.DEFAULT_DURATION,_.duration=p,g&&!Je.isDecimal(g))throw new TypeError("Invalid interToneGap: ".concat(g));if(g?g<Lt.C.MIN_INTER_TONE_GAP?(Y.debug('"interToneGap" value is lower than the minimum allowed, setting it to '.concat(Lt.C.MIN_INTER_TONE_GAP," milliseconds")),g=Lt.C.MIN_INTER_TONE_GAP):g=Math.abs(g):g=Lt.C.DEFAULT_INTER_TONE_GAP,n===ce.DTMF_TRANSPORT.RFC2833){var v=this._getDTMFRTPSender();v&&(a=v.toneBuffer+a,v.insertDTMF(a,p,g));return}if(this._tones){this._tones+=a;return}this._tones=a,S.call(this);function S(){var m=this,C;if(this._status===ee.STATUS_TERMINATED||!this._tones||e>=this._tones.length){this._tones=null;return}var A=this._tones[e];if(e+=1,A===",")C=2e3;else{var R=new Lt(this);_.eventHandlers={onFailed:function(){m._tones=null}},R.send(A,_),C=p+g}setTimeout(S.bind(this),C)}}},{key:"sendInfo",value:function(a,_){var e=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};if(Y.debug("sendInfo()"),this._status!==ee.STATUS_CONFIRMED&&this._status!==ee.STATUS_WAITING_FOR_ACK&&this._status!==ee.STATUS_1XX_RECEIVED)throw new an.InvalidStateError(this._status);var p=new zc(this);p.send(a,_,e)}},{key:"mute",value:function(){var a=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{audio:!0,video:!1};Y.debug("mute()");var _=!1,e=!1;this._audioMuted===!1&&a.audio&&(_=!0,this._audioMuted=!0,this._toggleMuteAudio(!0)),this._videoMuted===!1&&a.video&&(e=!0,this._videoMuted=!0,this._toggleMuteVideo(!0)),(_===!0||e===!0)&&this._onmute({audio:_,video:e})}},{key:"unmute",value:function(){var a=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{audio:!0,video:!0};Y.debug("unmute()");var _=!1,e=!1;this._audioMuted===!0&&a.audio&&(_=!0,this._audioMuted=!1,this._localHold===!1&&this._toggleMuteAudio(!1)),this._videoMuted===!0&&a.video&&(e=!0,this._videoMuted=!1,this._localHold===!1&&this._toggleMuteVideo(!1)),(_===!0||e===!0)&&this._onunmute({audio:_,video:e})}},{key:"hold",value:function(){var a=this,_=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},e=arguments.length>1?arguments[1]:void 0;if(Y.debug("hold()"),this._status!==ee.STATUS_WAITING_FOR_ACK&&this._status!==ee.STATUS_CONFIRMED||this._localHold===!0||!this._isReadyToReOffer())return!1;this._localHold=!0,this._onhold("local");var p={succeeded:function(){e&&e()},failed:function(){a.terminate({cause:ce.causes.WEBRTC_ERROR,status_code:500,reason_phrase:"Hold Failed"})}};return _.useUpdate?this._sendUpdate({sdpOffer:!0,eventHandlers:p,extraHeaders:_.extraHeaders}):this._sendReinvite({eventHandlers:p,extraHeaders:_.extraHeaders}),!0}},{key:"unhold",value:function(){var a=this,_=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},e=arguments.length>1?arguments[1]:void 0;if(Y.debug("unhold()"),this._status!==ee.STATUS_WAITING_FOR_ACK&&this._status!==ee.STATUS_CONFIRMED||this._localHold===!1||!this._isReadyToReOffer())return!1;this._localHold=!1,this._onunhold("local");var p={succeeded:function(){e&&e()},failed:function(){a.terminate({cause:ce.causes.WEBRTC_ERROR,status_code:500,reason_phrase:"Unhold Failed"})}};return _.useUpdate?this._sendUpdate({sdpOffer:!0,eventHandlers:p,extraHeaders:_.extraHeaders}):this._sendReinvite({eventHandlers:p,extraHeaders:_.extraHeaders}),!0}},{key:"renegotiate",value:function(){var a=this,_=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},e=arguments.length>1?arguments[1]:void 0;Y.debug("renegotiate()");var p=_.rtcOfferConstraints||null;if(this._status!==ee.STATUS_WAITING_FOR_ACK&&this._status!==ee.STATUS_CONFIRMED||!this._isReadyToReOffer())return!1;var g={succeeded:function(){e&&e()},failed:function(){a.terminate({cause:ce.causes.WEBRTC_ERROR,status_code:500,reason_phrase:"Media Renegotiation Failed"})}};return this._setLocalMediaStatus(),_.useUpdate?this._sendUpdate({sdpOffer:!0,eventHandlers:g,rtcOfferConstraints:p,extraHeaders:_.extraHeaders}):this._sendReinvite({eventHandlers:g,rtcOfferConstraints:p,extraHeaders:_.extraHeaders}),!0}},{key:"refer",value:function(a,_){var e=this;Y.debug("refer()");var p=a;if(this._status!==ee.STATUS_WAITING_FOR_ACK&&this._status!==ee.STATUS_CONFIRMED)return!1;if(a=this._ua.normalizeTarget(a),!a)throw new TypeError("Invalid target: ".concat(p));var g=new Kd(this);g.sendRefer(a,_);var n=g.id;return this._referSubscribers[n]=g,g.on("requestFailed",function(){delete e._referSubscribers[n]}),g.on("accepted",function(){delete e._referSubscribers[n]}),g.on("failed",function(){delete e._referSubscribers[n]}),g}},{key:"sendRequest",value:function(a,_){return Y.debug("sendRequest()"),this._dialog.sendRequest(a,_)}},{key:"receiveRequest",value:function(a){var _=this;if(Y.debug("receiveRequest()"),a.method===ce.CANCEL)(this._status===ee.STATUS_WAITING_FOR_ANSWER||this._status===ee.STATUS_ANSWERED)&&(this._status=ee.STATUS_CANCELED,this._request.reply(487),this._failed("remote",a,ce.causes.CANCELED));else switch(a.method){case ce.ACK:if(this._status!==ee.STATUS_WAITING_FOR_ACK)return;if(this._status=ee.STATUS_CONFIRMED,clearTimeout(this._timers.ackTimer),clearTimeout(this._timers.invite2xxTimer),this._late_sdp){if(!a.body){this.terminate({cause:ce.causes.MISSING_SDP,status_code:400});break}var e={originator:"remote",type:"answer",sdp:a.body};Y.debug('emit "sdp"'),this.emit("sdp",e);var p=new RTCSessionDescription({type:"answer",sdp:e.sdp});this._connectionPromiseQueue=this._connectionPromiseQueue.then(function(){return _._connection.setRemoteDescription(p)}).then(function(){_._is_confirmed||_._confirmed("remote",a)}).catch(function(n){_.terminate({cause:ce.causes.BAD_MEDIA_DESCRIPTION,status_code:488}),Y.warn('emit "peerconnection:setremotedescriptionfailed" [error:%o]',n),_.emit("peerconnection:setremotedescriptionfailed",n)})}else this._is_confirmed||this._confirmed("remote",a);break;case ce.BYE:this._status===ee.STATUS_CONFIRMED||this._status===ee.STATUS_WAITING_FOR_ACK?(a.reply(200),this._ended("remote",a,ce.causes.BYE)):this._status===ee.STATUS_INVITE_RECEIVED||this._status===ee.STATUS_WAITING_FOR_ANSWER?(a.reply(200),this._request.reply(487,"BYE Received"),this._ended("remote",a,ce.causes.BYE)):a.reply(403,"Wrong Status");break;case ce.INVITE:this._status===ee.STATUS_CONFIRMED?a.hasHeader("replaces")?this._receiveReplaces(a):this._receiveReinvite(a):a.reply(403,"Wrong Status");break;case ce.INFO:if(this._status===ee.STATUS_1XX_RECEIVED||this._status===ee.STATUS_WAITING_FOR_ANSWER||this._status===ee.STATUS_ANSWERED||this._status===ee.STATUS_WAITING_FOR_ACK||this._status===ee.STATUS_CONFIRMED){var g=a.hasHeader("Content-Type")?a.getHeader("Content-Type").toLowerCase():void 0;g&&g.match(/^application\/dtmf-relay/i)?new Lt(this).init_incoming(a):g!==void 0?new zc(this).init_incoming(a):a.reply(415)}else a.reply(403,"Wrong Status");break;case ce.UPDATE:this._status===ee.STATUS_CONFIRMED?this._receiveUpdate(a):a.reply(403,"Wrong Status");break;case ce.REFER:this._status===ee.STATUS_CONFIRMED?this._receiveRefer(a):a.reply(403,"Wrong Status");break;case ce.NOTIFY:this._status===ee.STATUS_CONFIRMED?this._receiveNotify(a):a.reply(403,"Wrong Status");break;default:a.reply(501)}}},{key:"onTransportError",value:function(){Y.warn("onTransportError()"),this._status!==ee.STATUS_TERMINATED&&this.terminate({status_code:500,reason_phrase:ce.causes.CONNECTION_ERROR,cause:ce.causes.CONNECTION_ERROR})}},{key:"onRequestTimeout",value:function(){Y.warn("onRequestTimeout()"),this._status!==ee.STATUS_TERMINATED&&this.terminate({status_code:408,reason_phrase:ce.causes.REQUEST_TIMEOUT,cause:ce.causes.REQUEST_TIMEOUT})}},{key:"onDialogError",value:function(){Y.warn("onDialogError()"),this._status!==ee.STATUS_TERMINATED&&this.terminate({status_code:500,reason_phrase:ce.causes.DIALOG_ERROR,cause:ce.causes.DIALOG_ERROR})}},{key:"newDTMF",value:function(a){Y.debug("newDTMF()"),this.emit("newDTMF",a)}},{key:"newInfo",value:function(a){Y.debug("newInfo()"),this.emit("newInfo",a)}},{key:"_isReadyToReOffer",value:function(){return this._rtcReady?this._dialog?this._dialog.uac_pending_reply===!0||this._dialog.uas_pending_reply===!0?(Y.debug("_isReadyToReOffer() | there is another INVITE/UPDATE transaction in progress"),!1):!0:(Y.debug("_isReadyToReOffer() | session not established yet"),!1):(Y.debug("_isReadyToReOffer() | internal WebRTC status not ready"),!1)}},{key:"_close",value:function(){if(Y.debug("close()"),this._localMediaStream&&this._localMediaStreamLocallyGenerated&&(Y.debug("close() | closing local MediaStream"),Je.closeMediaStream(this._localMediaStream)),this._status!==ee.STATUS_TERMINATED){if(this._status=ee.STATUS_TERMINATED,this._connection)try{this._connection.close()}catch(p){Y.warn("close() | error closing the RTCPeerConnection: %o",p)}for(var a in this._timers)Object.prototype.hasOwnProperty.call(this._timers,a)&&clearTimeout(this._timers[a]);clearTimeout(this._sessionTimers.timer),this._dialog&&(this._dialog.terminate(),delete this._dialog);for(var _ in this._earlyDialogs)Object.prototype.hasOwnProperty.call(this._earlyDialogs,_)&&(this._earlyDialogs[_].terminate(),delete this._earlyDialogs[_]);for(var e in this._referSubscribers)Object.prototype.hasOwnProperty.call(this._referSubscribers,e)&&delete this._referSubscribers[e];this._ua.destroyRTCSession(this)}}},{key:"_setInvite2xxTimer",value:function(a,_){var e=Dr.T1;function p(){this._status===ee.STATUS_WAITING_FOR_ACK&&(a.reply(200,null,["Contact: ".concat(this._contact)],_),e<Dr.T2&&(e=e*2,e>Dr.T2&&(e=Dr.T2)),this._timers.invite2xxTimer=setTimeout(p.bind(this),e))}this._timers.invite2xxTimer=setTimeout(p.bind(this),e)}},{key:"_setACKTimer",value:function(){var a=this;this._timers.ackTimer=setTimeout(function(){a._status===ee.STATUS_WAITING_FOR_ACK&&(Y.debug("no ACK received, terminating the session"),clearTimeout(a._timers.invite2xxTimer),a.sendRequest(ce.BYE),a._ended("remote",null,ce.causes.NO_ACK))},Dr.TIMER_H)}},{key:"_createRTCConnection",value:function(a,_){var e=this;this._connection=new RTCPeerConnection(a,_),this._connection.addEventListener("iceconnectionstatechange",function(){var p=e._connection.iceConnectionState;p==="failed"&&e.terminate({cause:ce.causes.RTP_TIMEOUT,status_code:408,reason_phrase:ce.causes.RTP_TIMEOUT})}),Y.debug('emit "peerconnection"'),this.emit("peerconnection",{peerconnection:this._connection})}},{key:"_createLocalDescription",value:function(a,_){var e=this;if(Y.debug("createLocalDescription()"),a!=="offer"&&a!=="answer")throw new Error('createLocalDescription() | invalid type "'.concat(a,'"'));var p=this._connection;return this._rtcReady=!1,Promise.resolve().then(function(){return a==="offer"?p.createOffer(_).catch(function(g){return Y.warn('emit "peerconnection:createofferfailed" [error:%o]',g),e.emit("peerconnection:createofferfailed",g),Promise.reject(g)}):p.createAnswer(_).catch(function(g){return Y.warn('emit "peerconnection:createanswerfailed" [error:%o]',g),e.emit("peerconnection:createanswerfailed",g),Promise.reject(g)})}).then(function(g){return p.setLocalDescription(g).catch(function(n){return e._rtcReady=!0,Y.warn('emit "peerconnection:setlocaldescriptionfailed" [error:%o]',n),e.emit("peerconnection:setlocaldescriptionfailed",n),Promise.reject(n)})}).then(function(){var g=_&&_.iceRestart;if(p.iceGatheringState==="complete"&&!g||p.iceGatheringState==="gathering"&&e._iceReady){e._rtcReady=!0;var n={originator:"local",type:a,sdp:p.localDescription.sdp};return Y.debug('emit "sdp"'),e.emit("sdp",n),Promise.resolve(n.sdp)}return new Promise(function(v){var S=!1,m,C;e._iceReady=!1;var A=function(){p.removeEventListener("icecandidate",m),p.removeEventListener("icegatheringstatechange",C),S=!0,e._rtcReady=!0,e._iceReady=!0;var I={originator:"local",type:a,sdp:p.localDescription.sdp};Y.debug('emit "sdp"'),e.emit("sdp",I),v(I.sdp)};p.addEventListener("icecandidate",m=function(I){var V=I.candidate;V?e.emit("icecandidate",{candidate:V,ready:A}):S||A()}),p.addEventListener("icegatheringstatechange",C=function(){p.iceGatheringState==="complete"&&!S&&A()})})})}},{key:"_createDialog",value:function(a,_,e){var p=_==="UAS"?a.to_tag:a.from_tag,g=_==="UAS"?a.from_tag:a.to_tag,n=a.call_id+p+g,v=this._earlyDialogs[n];if(e)return v?!0:(v=new Fl(this,a,_,Fl.C.STATUS_EARLY),v.error?(Y.debug(v.error),this._failed("remote",a,ce.causes.INTERNAL_ERROR),!1):(this._earlyDialogs[n]=v,!0));if(this._from_tag=a.from_tag,this._to_tag=a.to_tag,v)return v.update(a,_),this._dialog=v,delete this._earlyDialogs[n],!0;var S=new Fl(this,a,_);return S.error?(Y.debug(S.error),this._failed("remote",a,ce.causes.INTERNAL_ERROR),!1):(this._dialog=S,!0)}},{key:"_receiveReinvite",value:function(a){var _=this;Y.debug("receiveReinvite()");var e=a.hasHeader("Content-Type")?a.getHeader("Content-Type").toLowerCase():void 0,p={request:a,callback:void 0,reject:n.bind(this)},g=!1;function n(){var S=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};g=!0;var m=S.status_code||403,C=S.reason_phrase||"",A=Je.cloneArray(S.extraHeaders);if(this._status!==ee.STATUS_CONFIRMED)return!1;if(m<300||m>=700)throw new TypeError("Invalid status_code: ".concat(m));a.reply(m,C,A)}if(this.emit("reinvite",p),g)return;if(this._late_sdp=!1,!a.body){this._late_sdp=!0,this._remoteHold&&(this._remoteHold=!1,this._onunhold("remote")),this._connectionPromiseQueue=this._connectionPromiseQueue.then(function(){return _._createLocalDescription("offer",_._rtcOfferConstraints)}).then(function(S){v.call(_,S)}).catch(function(){a.reply(500)});return}if(e!=="application/sdp"){Y.debug("invalid Content-Type"),a.reply(415);return}this._processInDialogSdpOffer(a).then(function(S){_._status!==ee.STATUS_TERMINATED&&v.call(_,S)}).catch(function(S){Y.warn(S)});function v(S){var m=this,C=["Contact: ".concat(this._contact)];this._handleSessionTimersInIncomingRequest(a,C),this._late_sdp&&(S=this._mangleOffer(S)),a.reply(200,null,C,S,function(){m._status=ee.STATUS_WAITING_FOR_ACK,m._setInvite2xxTimer(a,S),m._setACKTimer()}),typeof p.callback=="function"&&p.callback()}}},{key:"_receiveUpdate",value:function(a){var _=this;Y.debug("receiveUpdate()");var e=a.hasHeader("Content-Type")?a.getHeader("Content-Type").toLowerCase():void 0,p={request:a,callback:void 0,reject:n.bind(this)},g=!1;function n(){var S=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};g=!0;var m=S.status_code||403,C=S.reason_phrase||"",A=Je.cloneArray(S.extraHeaders);if(this._status!==ee.STATUS_CONFIRMED)return!1;if(m<300||m>=700)throw new TypeError("Invalid status_code: ".concat(m));a.reply(m,C,A)}if(this.emit("update",p),g)return;if(!a.body){v.call(this,null);return}if(e!=="application/sdp"){Y.debug("invalid Content-Type"),a.reply(415);return}this._processInDialogSdpOffer(a).then(function(S){_._status!==ee.STATUS_TERMINATED&&v.call(_,S)}).catch(function(S){Y.warn(S)});function v(S){var m=["Contact: ".concat(this._contact)];this._handleSessionTimersInIncomingRequest(a,m),a.reply(200,null,m,S),typeof p.callback=="function"&&p.callback()}}},{key:"_processInDialogSdpOffer",value:function(a){var _=this;Y.debug("_processInDialogSdpOffer()");var e=a.parseSDP(),p=!1,g=hs(e.media),n;try{for(g.s();!(n=g.n()).done;){var v=n.value;if(jl.indexOf(v.type)!==-1){var S=v.direction||e.direction||"sendrecv";if(S==="sendonly"||S==="inactive")p=!0;else{p=!1;break}}}}catch(A){g.e(A)}finally{g.f()}var m={originator:"remote",type:"offer",sdp:a.body};Y.debug('emit "sdp"'),this.emit("sdp",m);var C=new RTCSessionDescription({type:"offer",sdp:m.sdp});return this._connectionPromiseQueue=this._connectionPromiseQueue.then(function(){if(_._status===ee.STATUS_TERMINATED)throw new Error("terminated");return _._connection.setRemoteDescription(C).catch(function(A){throw a.reply(488),Y.warn('emit "peerconnection:setremotedescriptionfailed" [error:%o]',A),_.emit("peerconnection:setremotedescriptionfailed",A),A})}).then(function(){if(_._status===ee.STATUS_TERMINATED)throw new Error("terminated");_._remoteHold===!0&&p===!1?(_._remoteHold=!1,_._onunhold("remote")):_._remoteHold===!1&&p===!0&&(_._remoteHold=!0,_._onhold("remote"))}).then(function(){if(_._status===ee.STATUS_TERMINATED)throw new Error("terminated");return _._createLocalDescription("answer",_._rtcAnswerConstraints).catch(function(A){throw a.reply(500),Y.warn('emit "peerconnection:createtelocaldescriptionfailed" [error:%o]',A),A})}).catch(function(A){Y.warn("_processInDialogSdpOffer() failed [error: %o]",A)}),this._connectionPromiseQueue}},{key:"_receiveRefer",value:function(a){var _=this;if(Y.debug("receiveRefer()"),!a.refer_to){Y.debug("no Refer-To header field present in REFER"),a.reply(400);return}if(a.refer_to.uri.scheme!==ce.SIP){Y.debug("Refer-To header field points to a non-SIP URI scheme"),a.reply(416);return}a.reply(202);var e=new Wd(this,a.cseq);Y.debug('emit "refer"'),this.emit("refer",{request:a,accept:function(v,S){p.call(_,v,S)},reject:function(){g.call(_)}});function p(n){var v=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(n=typeof n=="function"?n:null,this._status!==ee.STATUS_WAITING_FOR_ACK&&this._status!==ee.STATUS_CONFIRMED)return!1;var S=new i(this._ua);if(S.on("progress",function(C){var A=C.response;e.notify(A.status_code,A.reason_phrase)}),S.on("accepted",function(C){var A=C.response;e.notify(A.status_code,A.reason_phrase)}),S.on("_failed",function(C){var A=C.message,R=C.cause;A?e.notify(A.status_code,A.reason_phrase):e.notify(487,R)}),a.refer_to.uri.hasHeader("replaces")){var m=decodeURIComponent(a.refer_to.uri.getHeader("replaces"));v.extraHeaders=Je.cloneArray(v.extraHeaders),v.extraHeaders.push("Replaces: ".concat(m))}S.connect(a.refer_to.uri.toAor(),v,n)}function g(){e.notify(603)}}},{key:"_receiveNotify",value:function(a){switch(Y.debug("receiveNotify()"),a.event||a.reply(400),a.event.event){case"refer":{var _,e;if(a.event.params&&a.event.params.id)_=a.event.params.id,e=this._referSubscribers[_];else if(Object.keys(this._referSubscribers).length===1)e=this._referSubscribers[Object.keys(this._referSubscribers)[0]];else{a.reply(400,"Missing event id parameter");return}if(!e){a.reply(481,"Subscription does not exist");return}e.receiveNotify(a),a.reply(200);break}default:a.reply(489)}}},{key:"_receiveReplaces",value:function(a){var _=this;Y.debug("receiveReplaces()");function e(g){var n=this;if(this._status!==ee.STATUS_WAITING_FOR_ACK&&this._status!==ee.STATUS_CONFIRMED)return!1;var v=new i(this._ua);v.on("confirmed",function(){n.terminate()}),v.init_incoming(a,g)}function p(){Y.debug("Replaced INVITE rejected by the user"),a.reply(486)}this.emit("replaces",{request:a,accept:function(n){e.call(_,n)},reject:function(){p.call(_)}})}},{key:"_sendInitialRequest",value:function(a,_,e){var p=this,g=new Gd(this._ua,this._request,{onRequestTimeout:function(){p.onRequestTimeout()},onTransportError:function(){p.onTransportError()},onAuthenticated:function(v){p._request=v},onReceiveResponse:function(v){p._receiveInviteResponse(v)}});Promise.resolve().then(function(){if(e)return e;if(a.audio||a.video)return p._localMediaStreamLocallyGenerated=!0,navigator.mediaDevices.getUserMedia(a).catch(function(n){throw p._status===ee.STATUS_TERMINATED?new Error("terminated"):(p._failed("local",null,ce.causes.USER_DENIED_MEDIA_ACCESS),Y.warn('emit "getusermediafailed" [error:%o]',n),p.emit("getusermediafailed",n),n)})}).then(function(n){if(p._status===ee.STATUS_TERMINATED)throw new Error("terminated");return p._localMediaStream=n,n&&n.getTracks().forEach(function(v){p._connection.addTrack(v,n)}),p._connecting(p._request),p._createLocalDescription("offer",_).catch(function(v){throw p._failed("local",null,ce.causes.WEBRTC_ERROR),v})}).then(function(n){if(p._is_canceled||p._status===ee.STATUS_TERMINATED)throw new Error("terminated");p._request.body=n,p._status=ee.STATUS_INVITE_SENT,Y.debug('emit "sending" [request:%o]',p._request),p.emit("sending",{request:p._request}),g.send()}).catch(function(n){p._status!==ee.STATUS_TERMINATED&&Y.warn(n)})}},{key:"_getDTMFRTPSender",value:function(){var a=this._connection.getSenders().find(function(_){return _.track&&_.track.kind==="audio"});if(!(a&&a.dtmf)){Y.warn("sendDTMF() | no local audio track to send DTMF with");return}return a.dtmf}},{key:"_receiveInviteResponse",value:function(a){var _=this;if(Y.debug("receiveInviteResponse()"),this._dialog&&a.status_code>=200&&a.status_code<=299)if(this._dialog.id.call_id===a.call_id&&this._dialog.id.local_tag===a.from_tag&&this._dialog.id.remote_tag===a.to_tag){this.sendRequest(ce.ACK);return}else{var e=new Fl(this,a,"UAC");if(e.error!==void 0){Y.debug(e.error);return}this.sendRequest(ce.ACK),this.sendRequest(ce.BYE);return}if(this._is_canceled){a.status_code>=100&&a.status_code<200?this._request.cancel(this._cancel_reason):a.status_code>=200&&a.status_code<299&&this._acceptAndTerminate(a);return}if(!(this._status!==ee.STATUS_INVITE_SENT&&this._status!==ee.STATUS_1XX_RECEIVED))switch(!0){case/^100$/.test(a.status_code):this._status=ee.STATUS_1XX_RECEIVED;break;case/^1[0-9]{2}$/.test(a.status_code):{if(!a.to_tag){Y.debug("1xx response received without to tag");break}if(a.hasHeader("contact")&&!this._createDialog(a,"UAC",!0))break;if(this._status=ee.STATUS_1XX_RECEIVED,!a.body){this._progress("remote",a);break}var p={originator:"remote",type:"answer",sdp:a.body};Y.debug('emit "sdp"'),this.emit("sdp",p);var g=new RTCSessionDescription({type:"answer",sdp:p.sdp});this._connectionPromiseQueue=this._connectionPromiseQueue.then(function(){return _._connection.setRemoteDescription(g)}).then(function(){return _._progress("remote",a)}).catch(function(m){Y.warn('emit "peerconnection:setremotedescriptionfailed" [error:%o]',m),_.emit("peerconnection:setremotedescriptionfailed",m)});break}case/^2[0-9]{2}$/.test(a.status_code):{if(this._status=ee.STATUS_CONFIRMED,!a.body){this._acceptAndTerminate(a,400,ce.causes.MISSING_SDP),this._failed("remote",a,ce.causes.BAD_MEDIA_DESCRIPTION);break}if(!this._createDialog(a,"UAC"))break;var n={originator:"remote",type:"answer",sdp:a.body};Y.debug('emit "sdp"'),this.emit("sdp",n);var v=new RTCSessionDescription({type:"answer",sdp:n.sdp});this._connectionPromiseQueue=this._connectionPromiseQueue.then(function(){if(_._connection.signalingState==="stable")return _._connection.createOffer(_._rtcOfferConstraints).then(function(m){return _._connection.setLocalDescription(m)}).catch(function(m){_._acceptAndTerminate(a,500,m.toString()),_._failed("local",a,ce.causes.WEBRTC_ERROR)})}).then(function(){_._connection.setRemoteDescription(v).then(function(){_._handleSessionTimersInIncomingResponse(a),_._accepted("remote",a),_.sendRequest(ce.ACK),_._confirmed("local",null)}).catch(function(m){_._acceptAndTerminate(a,488,"Not Acceptable Here"),_._failed("remote",a,ce.causes.BAD_MEDIA_DESCRIPTION),Y.warn('emit "peerconnection:setremotedescriptionfailed" [error:%o]',m),_.emit("peerconnection:setremotedescriptionfailed",m)})});break}default:{var S=Je.sipErrorCause(a.status_code);this._failed("remote",a,S)}}}},{key:"_sendReinvite",value:function(){var a=this,_=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};Y.debug("sendReinvite()");var e=Je.cloneArray(_.extraHeaders),p=Je.cloneObject(_.eventHandlers),g=_.rtcOfferConstraints||this._rtcOfferConstraints||null,n=!1;e.push("Contact: ".concat(this._contact)),e.push("Content-Type: application/sdp"),this._sessionTimers.running&&e.push("Session-Expires: ".concat(this._sessionTimers.currentExpires,";refresher=").concat(this._sessionTimers.refresher?"uac":"uas")),this._connectionPromiseQueue=this._connectionPromiseQueue.then(function(){return a._createLocalDescription("offer",g)}).then(function(m){m=a._mangleOffer(m);var C={originator:"local",type:"offer",sdp:m};Y.debug('emit "sdp"'),a.emit("sdp",C),a.sendRequest(ce.INVITE,{extraHeaders:e,body:m,eventHandlers:{onSuccessResponse:function(R){v.call(a,R),n=!0},onErrorResponse:function(R){S.call(a,R)},onTransportError:function(){a.onTransportError()},onRequestTimeout:function(){a.onRequestTimeout()},onDialogError:function(){a.onDialogError()}}})}).catch(function(){S()});function v(m){var C=this;if(this._status!==ee.STATUS_TERMINATED&&(this.sendRequest(ce.ACK),!n)){if(this._handleSessionTimersInIncomingResponse(m),m.body){if(!m.hasHeader("Content-Type")||m.getHeader("Content-Type").toLowerCase()!=="application/sdp"){S.call(this);return}}else{S.call(this);return}var A={originator:"remote",type:"answer",sdp:m.body};Y.debug('emit "sdp"'),this.emit("sdp",A);var R=new RTCSessionDescription({type:"answer",sdp:A.sdp});this._connectionPromiseQueue=this._connectionPromiseQueue.then(function(){return C._connection.setRemoteDescription(R)}).then(function(){p.succeeded&&p.succeeded(m)}).catch(function(I){S.call(C),Y.warn('emit "peerconnection:setremotedescriptionfailed" [error:%o]',I),C.emit("peerconnection:setremotedescriptionfailed",I)})}}function S(m){p.failed&&p.failed(m)}}},{key:"_sendUpdate",value:function(){var a=this,_=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};Y.debug("sendUpdate()");var e=Je.cloneArray(_.extraHeaders),p=Je.cloneObject(_.eventHandlers),g=_.rtcOfferConstraints||this._rtcOfferConstraints||null,n=_.sdpOffer||!1,v=!1;e.push("Contact: ".concat(this._contact)),this._sessionTimers.running&&e.push("Session-Expires: ".concat(this._sessionTimers.currentExpires,";refresher=").concat(this._sessionTimers.refresher?"uac":"uas")),n?(e.push("Content-Type: application/sdp"),this._connectionPromiseQueue=this._connectionPromiseQueue.then(function(){return a._createLocalDescription("offer",g)}).then(function(C){C=a._mangleOffer(C);var A={originator:"local",type:"offer",sdp:C};Y.debug('emit "sdp"'),a.emit("sdp",A),a.sendRequest(ce.UPDATE,{extraHeaders:e,body:C,eventHandlers:{onSuccessResponse:function(I){S.call(a,I),v=!0},onErrorResponse:function(I){m.call(a,I)},onTransportError:function(){a.onTransportError()},onRequestTimeout:function(){a.onRequestTimeout()},onDialogError:function(){a.onDialogError()}}})}).catch(function(){m.call(a)})):this.sendRequest(ce.UPDATE,{extraHeaders:e,eventHandlers:{onSuccessResponse:function(A){S.call(a,A)},onErrorResponse:function(A){m.call(a,A)},onTransportError:function(){a.onTransportError()},onRequestTimeout:function(){a.onRequestTimeout()},onDialogError:function(){a.onDialogError()}}});function S(C){var A=this;if(this._status!==ee.STATUS_TERMINATED&&!v)if(this._handleSessionTimersInIncomingResponse(C),n){if(C.body){if(!C.hasHeader("Content-Type")||C.getHeader("Content-Type").toLowerCase()!=="application/sdp"){m.call(this);return}}else{m.call(this);return}var R={originator:"remote",type:"answer",sdp:C.body};Y.debug('emit "sdp"'),this.emit("sdp",R);var I=new RTCSessionDescription({type:"answer",sdp:R.sdp});this._connectionPromiseQueue=this._connectionPromiseQueue.then(function(){return A._connection.setRemoteDescription(I)}).then(function(){p.succeeded&&p.succeeded(C)}).catch(function(V){m.call(A),Y.warn('emit "peerconnection:setremotedescriptionfailed" [error:%o]',V),A.emit("peerconnection:setremotedescriptionfailed",V)})}else p.succeeded&&p.succeeded(C)}function m(C){p.failed&&p.failed(C)}}},{key:"_acceptAndTerminate",value:function(a,_,e){Y.debug("acceptAndTerminate()");var p=[];_&&(e=e||ce.REASON_PHRASE[_]||"",p.push("Reason: SIP ;cause=".concat(_,'; text="').concat(e,'"'))),(this._dialog||this._createDialog(a,"UAC"))&&(this.sendRequest(ce.ACK),this.sendRequest(ce.BYE,{extraHeaders:p})),this._status=ee.STATUS_TERMINATED}},{key:"_mangleOffer",value:function(a){if(!this._localHold&&!this._remoteHold)return a;if(a=Yc.parse(a),this._localHold&&!this._remoteHold){Y.debug("mangleOffer() | me on hold, mangling offer");var _=hs(a.media),e;try{for(_.s();!(e=_.n()).done;){var p=e.value;jl.indexOf(p.type)!==-1&&(p.direction?p.direction==="sendrecv"?p.direction="sendonly":p.direction==="recvonly"&&(p.direction="inactive"):p.direction="sendonly")}}catch(A){_.e(A)}finally{_.f()}}else if(this._localHold&&this._remoteHold){Y.debug("mangleOffer() | both on hold, mangling offer");var g=hs(a.media),n;try{for(g.s();!(n=g.n()).done;){var v=n.value;jl.indexOf(v.type)!==-1&&(v.direction="inactive")}}catch(A){g.e(A)}finally{g.f()}}else if(this._remoteHold){Y.debug("mangleOffer() | remote on hold, mangling offer");var S=hs(a.media),m;try{for(S.s();!(m=S.n()).done;){var C=m.value;jl.indexOf(C.type)!==-1&&(C.direction?C.direction==="sendrecv"?C.direction="recvonly":C.direction==="recvonly"&&(C.direction="inactive"):C.direction="recvonly")}}catch(A){S.e(A)}finally{S.f()}}return Yc.write(a)}},{key:"_setLocalMediaStatus",value:function(){var a=!0,_=!0;(this._localHold||this._remoteHold)&&(a=!1,_=!1),this._audioMuted&&(a=!1),this._videoMuted&&(_=!1),this._toggleMuteAudio(!a),this._toggleMuteVideo(!_)}},{key:"_handleSessionTimersInIncomingRequest",value:function(a,_){if(this._sessionTimers.enabled){var e;a.session_expires&&a.session_expires>=ce.MIN_SESSION_EXPIRES?(this._sessionTimers.currentExpires=a.session_expires,e=a.session_expires_refresher||"uas"):(this._sessionTimers.currentExpires=this._sessionTimers.defaultExpires,e="uas"),_.push("Session-Expires: ".concat(this._sessionTimers.currentExpires,";refresher=").concat(e)),this._sessionTimers.refresher=e==="uas",this._runSessionTimer()}}},{key:"_handleSessionTimersInIncomingResponse",value:function(a){if(this._sessionTimers.enabled){var _;a.session_expires&&a.session_expires>=ce.MIN_SESSION_EXPIRES?(this._sessionTimers.currentExpires=a.session_expires,_=a.session_expires_refresher||"uac"):(this._sessionTimers.currentExpires=this._sessionTimers.defaultExpires,_="uac"),this._sessionTimers.refresher=_==="uac",this._runSessionTimer()}}},{key:"_runSessionTimer",value:function(){var a=this,_=this._sessionTimers.currentExpires;this._sessionTimers.running=!0,clearTimeout(this._sessionTimers.timer),this._sessionTimers.refresher?this._sessionTimers.timer=setTimeout(function(){a._status!==ee.STATUS_TERMINATED&&a._isReadyToReOffer()&&(Y.debug("runSessionTimer() | sending session refresh request"),a._sessionTimers.refreshMethod===ce.UPDATE?a._sendUpdate():a._sendReinvite())},_*500):this._sessionTimers.timer=setTimeout(function(){a._status!==ee.STATUS_TERMINATED&&(Y.warn("runSessionTimer() | timer expired, terminating the session"),a.terminate({cause:ce.causes.REQUEST_TIMEOUT,status_code:408,reason_phrase:"Session Timer Expired"}))},_*1100)}},{key:"_toggleMuteAudio",value:function(a){var _=this._connection.getSenders().filter(function(n){return n.track&&n.track.kind==="audio"}),e=hs(_),p;try{for(e.s();!(p=e.n()).done;){var g=p.value;g.track.enabled=!a}}catch(n){e.e(n)}finally{e.f()}}},{key:"_toggleMuteVideo",value:function(a){var _=this._connection.getSenders().filter(function(n){return n.track&&n.track.kind==="video"}),e=hs(_),p;try{for(e.s();!(p=e.n()).done;){var g=p.value;g.track.enabled=!a}}catch(n){e.e(n)}finally{e.f()}}},{key:"_newRTCSession",value:function(a,_){Y.debug("newRTCSession()"),this._ua.newRTCSession(this,{originator:a,session:this,request:_})}},{key:"_connecting",value:function(a){Y.debug("session connecting"),Y.debug('emit "connecting"'),this.emit("connecting",{request:a})}},{key:"_progress",value:function(a,_){Y.debug("session progress"),Y.debug('emit "progress"'),this.emit("progress",{originator:a,response:_||null})}},{key:"_accepted",value:function(a,_){Y.debug("session accepted"),this._start_time=new Date,Y.debug('emit "accepted"'),this.emit("accepted",{originator:a,response:_||null})}},{key:"_confirmed",value:function(a,_){Y.debug("session confirmed"),this._is_confirmed=!0,Y.debug('emit "confirmed"'),this.emit("confirmed",{originator:a,ack:_||null})}},{key:"_ended",value:function(a,_,e){Y.debug("session ended"),this._end_time=new Date,this._close(),Y.debug('emit "ended"'),this.emit("ended",{originator:a,message:_||null,cause:e})}},{key:"_failed",value:function(a,_,e){Y.debug("session failed"),Y.debug('emit "_failed"'),this.emit("_failed",{originator:a,message:_||null,cause:e}),this._close(),Y.debug('emit "failed"'),this.emit("failed",{originator:a,message:_||null,cause:e})}},{key:"_onhold",value:function(a){Y.debug("session onhold"),this._setLocalMediaStatus(),Y.debug('emit "hold"'),this.emit("hold",{originator:a})}},{key:"_onunhold",value:function(a){Y.debug("session onunhold"),this._setLocalMediaStatus(),Y.debug('emit "unhold"'),this.emit("unhold",{originator:a})}},{key:"_onmute",value:function(a){var _=a.audio,e=a.video;Y.debug("session onmute"),this._setLocalMediaStatus(),Y.debug('emit "muted"'),this.emit("muted",{audio:_,video:e})}},{key:"_onunmute",value:function(a){var _=a.audio,e=a.video;Y.debug("session onunmute"),this._setLocalMediaStatus(),Y.debug('emit "unmuted"'),this.emit("unmuted",{audio:_,video:e})}},{key:"C",get:function(){return ee}},{key:"causes",get:function(){return ce.causes}},{key:"id",get:function(){return this._id}},{key:"connection",get:function(){return this._connection}},{key:"contact",get:function(){return this._contact}},{key:"direction",get:function(){return this._direction}},{key:"local_identity",get:function(){return this._local_identity}},{key:"remote_identity",get:function(){return this._remote_identity}},{key:"start_time",get:function(){return this._start_time}},{key:"end_time",get:function(){return this._end_time}},{key:"data",get:function(){return this._data},set:function(a){this._data=a}},{key:"status",get:function(){return this._status}}]),i}(qd);function ql(c){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?ql=function(i){return typeof i}:ql=function(i){return i&&typeof Symbol=="function"&&i.constructor===Symbol&&i!==Symbol.prototype?"symbol":typeof i},ql(c)}function Jd(c,s){if(!(c instanceof s))throw new TypeError("Cannot call a class as a function")}function Qc(c,s){for(var i=0;i<s.length;i++){var l=s[i];l.enumerable=l.enumerable||!1,l.configurable=!0,"value"in l&&(l.writable=!0),Object.defineProperty(c,l.key,l)}}function zd(c,s,i){return s&&Qc(c.prototype,s),i&&Qc(c,i),c}function Xd(c,s){if(typeof s!="function"&&s!==null)throw new TypeError("Super expression must either be null or a function");c.prototype=Object.create(s&&s.prototype,{constructor:{value:c,writable:!0,configurable:!0}}),s&&No(c,s)}function No(c,s){return No=Object.setPrototypeOf||function(l,a){return l.__proto__=a,l},No(c,s)}function Qd(c){var s=tp();return function(){var l=Vl(c),a;if(s){var _=Vl(this).constructor;a=Reflect.construct(l,arguments,_)}else a=l.apply(this,arguments);return Zd(this,a)}}function Zd(c,s){return s&&(ql(s)==="object"||typeof s=="function")?s:ep(c)}function ep(c){if(c===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return c}function tp(){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 Vl(c){return Vl=Object.setPrototypeOf?Object.getPrototypeOf:function(i){return i.__proto__||Object.getPrototypeOf(i)},Vl(c)}var sp=ct.EventEmitter,np=ft,Uo=it,rp=cs,Nr=It(),ip=Ir,Zc=ws,lp=Os(),Bl=new np("Message"),ap=function(c){Xd(i,c);var s=Qd(i);function i(l){var a;return Jd(this,i),a=s.call(this),a._ua=l,a._request=null,a._closed=!1,a._direction=null,a._local_identity=null,a._remote_identity=null,a._is_replied=!1,a._data={},a}return zd(i,[{key:"send",value:function(a,_){var e=this,p=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},g=a;if(a===void 0||_===void 0)throw new TypeError("Not enough arguments");if(a=this._ua.normalizeTarget(a),!a)throw new TypeError("Invalid target: ".concat(g));var n=Nr.cloneArray(p.extraHeaders),v=Nr.cloneObject(p.eventHandlers),S=p.contentType||"text/plain",m={};p.fromUserName&&(m.from_uri=new lp("sip",p.fromUserName,this._ua.configuration.uri.host),n.push("P-Preferred-Identity: ".concat(this._ua.configuration.uri.toString()))),p.fromDisplayName&&(m.from_display_name=p.fromDisplayName);for(var C in v)Object.prototype.hasOwnProperty.call(v,C)&&this.on(C,v[C]);n.push("Content-Type: ".concat(S)),this._request=new rp.OutgoingRequest(Uo.MESSAGE,a,this._ua,m,n),_&&(this._request.body=_);var A=new ip(this._ua,this._request,{onRequestTimeout:function(){e._onRequestTimeout()},onTransportError:function(){e._onTransportError()},onReceiveResponse:function(I){e._receiveResponse(I)}});this._newMessage("local",this._request),A.send()}},{key:"init_incoming",value:function(a){this._request=a,this._newMessage("remote",a),this._is_replied||(this._is_replied=!0,a.reply(200)),this._close()}},{key:"accept",value:function(){var a=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},_=Nr.cloneArray(a.extraHeaders),e=a.body;if(this._direction!=="incoming")throw new Zc.NotSupportedError('"accept" not supported for outgoing Message');if(this._is_replied)throw new Error("incoming Message already replied");this._is_replied=!0,this._request.reply(200,null,_,e)}},{key:"reject",value:function(){var a=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},_=a.status_code||480,e=a.reason_phrase,p=Nr.cloneArray(a.extraHeaders),g=a.body;if(this._direction!=="incoming")throw new Zc.NotSupportedError('"reject" not supported for outgoing Message');if(this._is_replied)throw new Error("incoming Message already replied");if(_<300||_>=700)throw new TypeError("Invalid status_code: ".concat(_));this._is_replied=!0,this._request.reply(_,e,p,g)}},{key:"_receiveResponse",value:function(a){if(!this._closed)switch(!0){case/^1[0-9]{2}$/.test(a.status_code):break;case/^2[0-9]{2}$/.test(a.status_code):this._succeeded("remote",a);break;default:{var _=Nr.sipErrorCause(a.status_code);this._failed("remote",a,_);break}}}},{key:"_onRequestTimeout",value:function(){this._closed||this._failed("system",null,Uo.causes.REQUEST_TIMEOUT)}},{key:"_onTransportError",value:function(){this._closed||this._failed("system",null,Uo.causes.CONNECTION_ERROR)}},{key:"_close",value:function(){this._closed=!0,this._ua.destroyMessage(this)}},{key:"_newMessage",value:function(a,_){a==="remote"?(this._direction="incoming",this._local_identity=_.to,this._remote_identity=_.from):a==="local"&&(this._direction="outgoing",this._local_identity=_.from,this._remote_identity=_.to),this._ua.newMessage(this,{originator:a,message:this,request:_})}},{key:"_failed",value:function(a,_,e){Bl.debug("MESSAGE failed"),this._close(),Bl.debug('emit "failed"'),this.emit("failed",{originator:a,response:_||null,cause:e})}},{key:"_succeeded",value:function(a,_){Bl.debug("MESSAGE succeeded"),this._close(),Bl.debug('emit "succeeded"'),this.emit("succeeded",{originator:a,response:_})}},{key:"direction",get:function(){return this._direction}},{key:"local_identity",get:function(){return this._local_identity}},{key:"remote_identity",get:function(){return this._remote_identity}}]),i}(sp);function Gl(c){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?Gl=function(i){return typeof i}:Gl=function(i){return i&&typeof Symbol=="function"&&i.constructor===Symbol&&i!==Symbol.prototype?"symbol":typeof i},Gl(c)}function op(c,s){if(!(c instanceof s))throw new TypeError("Cannot call a class as a function")}function ef(c,s){for(var i=0;i<s.length;i++){var l=s[i];l.enumerable=l.enumerable||!1,l.configurable=!0,"value"in l&&(l.writable=!0),Object.defineProperty(c,l.key,l)}}function up(c,s,i){return s&&ef(c.prototype,s),i&&ef(c,i),c}function cp(c,s){if(typeof s!="function"&&s!==null)throw new TypeError("Super expression must either be null or a function");c.prototype=Object.create(s&&s.prototype,{constructor:{value:c,writable:!0,configurable:!0}}),s&&Po(c,s)}function Po(c,s){return Po=Object.setPrototypeOf||function(l,a){return l.__proto__=a,l},Po(c,s)}function fp(c){var s=dp();return function(){var l=Wl(c),a;if(s){var _=Wl(this).constructor;a=Reflect.construct(l,arguments,_)}else a=l.apply(this,arguments);return _p(this,a)}}function _p(c,s){return s&&(Gl(s)==="object"||typeof s=="function")?s:hp(c)}function hp(c){if(c===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return c}function dp(){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 Wl(c){return Wl=Object.setPrototypeOf?Object.getPrototypeOf:function(i){return i.__proto__||Object.getPrototypeOf(i)},Wl(c)}var pp=ct.EventEmitter,mp=ft,xo=it,gp=cs,Ur=It(),Tp=Ir,tf=ws,Kl=new mp("Options"),vp=function(c){cp(i,c);var s=fp(i);function i(l){var a;return op(this,i),a=s.call(this),a._ua=l,a._request=null,a._closed=!1,a._direction=null,a._local_identity=null,a._remote_identity=null,a._is_replied=!1,a._data={},a}return up(i,[{key:"send",value:function(a,_){var e=this,p=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},g=a;if(a===void 0)throw new TypeError("A target is required for OPTIONS");if(a=this._ua.normalizeTarget(a),!a)throw new TypeError("Invalid target: ".concat(g));var n=Ur.cloneArray(p.extraHeaders),v=Ur.cloneObject(p.eventHandlers),S=p.contentType||"application/sdp";for(var m in v)Object.prototype.hasOwnProperty.call(v,m)&&this.on(m,v[m]);n.push("Content-Type: ".concat(S)),this._request=new gp.OutgoingRequest(xo.OPTIONS,a,this._ua,null,n),_&&(this._request.body=_);var C=new Tp(this._ua,this._request,{onRequestTimeout:function(){e._onRequestTimeout()},onTransportError:function(){e._onTransportError()},onReceiveResponse:function(R){e._receiveResponse(R)}});this._newOptions("local",this._request),C.send()}},{key:"init_incoming",value:function(a){this._request=a,this._newOptions("remote",a),this._is_replied||(this._is_replied=!0,a.reply(200)),this._close()}},{key:"accept",value:function(){var a=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},_=Ur.cloneArray(a.extraHeaders),e=a.body;if(this._direction!=="incoming")throw new tf.NotSupportedError('"accept" not supported for outgoing Options');if(this._is_replied)throw new Error("incoming Options already replied");this._is_replied=!0,this._request.reply(200,null,_,e)}},{key:"reject",value:function(){var a=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},_=a.status_code||480,e=a.reason_phrase,p=Ur.cloneArray(a.extraHeaders),g=a.body;if(this._direction!=="incoming")throw new tf.NotSupportedError('"reject" not supported for outgoing Options');if(this._is_replied)throw new Error("incoming Options already replied");if(_<300||_>=700)throw new TypeError("Invalid status_code: ".concat(_));this._is_replied=!0,this._request.reply(_,e,p,g)}},{key:"_receiveResponse",value:function(a){if(!this._closed)switch(!0){case/^1[0-9]{2}$/.test(a.status_code):break;case/^2[0-9]{2}$/.test(a.status_code):this._succeeded("remote",a);break;default:{var _=Ur.sipErrorCause(a.status_code);this._failed("remote",a,_);break}}}},{key:"_onRequestTimeout",value:function(){this._closed||this._failed("system",null,xo.causes.REQUEST_TIMEOUT)}},{key:"_onTransportError",value:function(){this._closed||this._failed("system",null,xo.causes.CONNECTION_ERROR)}},{key:"_close",value:function(){this._closed=!0,this._ua.destroyMessage(this)}},{key:"_newOptions",value:function(a,_){a==="remote"?(this._direction="incoming",this._local_identity=_.to,this._remote_identity=_.from):a==="local"&&(this._direction="outgoing",this._local_identity=_.from,this._remote_identity=_.to),this._ua.newOptions(this,{originator:a,message:this,request:_})}},{key:"_failed",value:function(a,_,e){Kl.debug("OPTIONS failed"),this._close(),Kl.debug('emit "failed"'),this.emit("failed",{originator:a,response:_||null,cause:e})}},{key:"_succeeded",value:function(a,_){Kl.debug("OPTIONS succeeded"),this._close(),Kl.debug('emit "succeeded"'),this.emit("succeeded",{originator:a,response:_})}},{key:"direction",get:function(){return this._direction}},{key:"local_identity",get:function(){return this._local_identity}},{key:"remote_identity",get:function(){return this._remote_identity}}]),i}(pp),Mo={},Ep=ft,ko=It(),Sp=Zt(),Pr=new Ep("Socket");Mo.isSocket=function(c){if(Array.isArray(c))return!1;if(typeof c>"u")return Pr.warn("undefined JsSIP.Socket instance"),!1;try{if(!ko.isString(c.url))throw Pr.warn("missing or invalid JsSIP.Socket url property"),new Error("Missing or invalid JsSIP.Socket url property");if(!ko.isString(c.via_transport))throw Pr.warn("missing or invalid JsSIP.Socket via_transport property"),new Error("Missing or invalid JsSIP.Socket via_transport property");if(Sp.parse(c.sip_uri,"SIP_URI")===-1)throw Pr.warn("missing or invalid JsSIP.Socket sip_uri property"),new Error("missing or invalid JsSIP.Socket sip_uri property")}catch{return!1}try{["connect","disconnect","send"].forEach(function(s){if(!ko.isFunction(c[s]))throw Pr.warn("missing or invalid JsSIP.Socket method: ".concat(s)),new Error("Missing or invalid JsSIP.Socket method: ".concat(s))})}catch{return!1}return!0};function yp(c,s){if(!(c instanceof s))throw new TypeError("Cannot call a class as a function")}function sf(c,s){for(var i=0;i<s.length;i++){var l=s[i];l.enumerable=l.enumerable||!1,l.configurable=!0,"value"in l&&(l.writable=!0),Object.defineProperty(c,l.key,l)}}function Ap(c,s,i){return s&&sf(c.prototype,s),i&&sf(c,i),c}var Cp=ft,Rp=Mo,nf=it,Mt=new Cp("Transport"),Ft={STATUS_CONNECTED:0,STATUS_CONNECTING:1,STATUS_DISCONNECTED:2,SOCKET_STATUS_READY:0,SOCKET_STATUS_ERROR:1,recovery_options:{min_interval:nf.CONNECTION_RECOVERY_MIN_INTERVAL,max_interval:nf.CONNECTION_RECOVERY_MAX_INTERVAL}},Ip=function(){function c(s){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:Ft.recovery_options;yp(this,c),Mt.debug("new()"),this.status=Ft.STATUS_DISCONNECTED,this.socket=null,this.sockets=[],this.recovery_options=i,this.recover_attempts=0,this.recovery_timer=null,this.close_requested=!1;try{this.textDecoder=new TextDecoder("utf8")}catch(l){Mt.warn("cannot use TextDecoder: ".concat(l))}if(typeof s>"u")throw new TypeError("Invalid argument. undefined 'sockets' argument");s instanceof Array||(s=[s]),s.forEach(function(l){if(!Rp.isSocket(l.socket))throw new TypeError("Invalid argument. invalid 'JsSIP.Socket' instance");if(l.weight&&!Number(l.weight))throw new TypeError("Invalid argument. 'weight' attribute is not a number");this.sockets.push({socket:l.socket,weight:l.weight||0,status:Ft.SOCKET_STATUS_READY})},this),this._getSocket()}return Ap(c,[{key:"connect",value:function(){if(Mt.debug("connect()"),this.isConnected()){Mt.debug("Transport is already connected");return}else if(this.isConnecting()){Mt.debug("Transport is connecting");return}this.close_requested=!1,this.status=Ft.STATUS_CONNECTING,this.onconnecting({socket:this.socket,attempts:this.recover_attempts}),this.close_requested||(this.socket.onconnect=this._onConnect.bind(this),this.socket.ondisconnect=this._onDisconnect.bind(this),this.socket.ondata=this._onData.bind(this),this.socket.connect())}},{key:"disconnect",value:function(){Mt.debug("close()"),this.close_requested=!0,this.recover_attempts=0,this.status=Ft.STATUS_DISCONNECTED,this.recovery_timer!==null&&(clearTimeout(this.recovery_timer),this.recovery_timer=null),this.socket.onconnect=function(){},this.socket.ondisconnect=function(){},this.socket.ondata=function(){},this.socket.disconnect(),this.ondisconnect({socket:this.socket,error:!1})}},{key:"send",value:function(i){if(Mt.debug("send()"),!this.isConnected())return Mt.warn("unable to send message, transport is not connected"),!1;var l=i.toString();return Mt.debug(`sending message:
|
51
51
|
|
52
|
-
`.concat(
|
53
|
-
`)),this.socket.send(
|
54
|
-
`){
|
52
|
+
`.concat(l,`
|
53
|
+
`)),this.socket.send(l)}},{key:"isConnected",value:function(){return this.status===Ft.STATUS_CONNECTED}},{key:"isConnecting",value:function(){return this.status===Ft.STATUS_CONNECTING}},{key:"_reconnect",value:function(){var i=this;this.recover_attempts+=1;var l=Math.floor(Math.random()*Math.pow(2,this.recover_attempts)+1);l<this.recovery_options.min_interval?l=this.recovery_options.min_interval:l>this.recovery_options.max_interval&&(l=this.recovery_options.max_interval),Mt.debug("reconnection attempt: ".concat(this.recover_attempts,". next connection attempt in ").concat(l," seconds")),this.recovery_timer=setTimeout(function(){!i.close_requested&&!(i.isConnected()||i.isConnecting())&&(i._getSocket(),i.connect())},l*1e3)}},{key:"_getSocket",value:function(){var i=[];if(this.sockets.forEach(function(a){a.status!==Ft.SOCKET_STATUS_ERROR&&(i.length===0?i.push(a):a.weight>i[0].weight?i=[a]:a.weight===i[0].weight&&i.push(a))}),i.length===0){this.sockets.forEach(function(a){a.status=Ft.SOCKET_STATUS_READY}),this._getSocket();return}var l=Math.floor(Math.random()*i.length);this.socket=i[l].socket}},{key:"_onConnect",value:function(){this.recover_attempts=0,this.status=Ft.STATUS_CONNECTED,this.recovery_timer!==null&&(clearTimeout(this.recovery_timer),this.recovery_timer=null),this.onconnect({socket:this})}},{key:"_onDisconnect",value:function(i,l,a){this.status=Ft.STATUS_DISCONNECTED,this.ondisconnect({socket:this.socket,error:i,code:l,reason:a}),!this.close_requested&&(this.sockets.forEach(function(_){this.socket===_.socket&&(_.status=Ft.SOCKET_STATUS_ERROR)},this),this._reconnect(i))}},{key:"_onData",value:function(i){if(i===`\r
|
54
|
+
`){Mt.debug("received message with CRLF Keep Alive response");return}else if(typeof i!="string"){try{this.textDecoder?i=this.textDecoder.decode(i):i=String.fromCharCode.apply(null,new Uint8Array(i))}catch{Mt.debug("received binary message failed to be converted into string, message discarded");return}Mt.debug(`received binary message:
|
55
55
|
|
56
|
-
`.concat(
|
57
|
-
`))}else
|
56
|
+
`.concat(i,`
|
57
|
+
`))}else Mt.debug(`received text message:
|
58
58
|
|
59
|
-
`.concat(
|
60
|
-
`));this.ondata({transport:this,message:
|
61
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var
|
62
|
-
`);if(
|
63
|
-
`,
|
64
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var
|
65
|
-
`),
|
66
|
-
`)}}catch(
|
67
|
-
`),
|
68
|
-
`),
|
69
|
-
`),
|
70
|
-
`),
|
71
|
-
`,
|
72
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var p=!0,t=!1,v;return{s:function(){a=u[Symbol.iterator]()},n:function(){var l=a.next();return p=l.done,l},e:function(l){t=!0,v=l},f:function(){try{!p&&a.return!=null&&a.return()}finally{if(t)throw v}}}}function Wp(u,n){if(u){if(typeof u=="string")return df(u,n);var a=Object.prototype.toString.call(u).slice(8,-1);if(a==="Object"&&u.constructor&&(a=u.constructor.name),a==="Map"||a==="Set")return Array.from(u);if(a==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(a))return df(u,n)}}function df(u,n){(n==null||n>u.length)&&(n=u.length);for(var a=0,e=new Array(n);a<n;a++)e[a]=u[a];return e}var Gr=Mt(),rr=pt,eu=Gs(),pf=Kn(),tu=Ko,su=Wn;Zo.settings={authorization_user:null,password:null,realm:null,ha1:null,authorization_jwt:null,display_name:null,uri:null,contact_uri:null,instance_id:null,use_preloaded_route:!1,session_timers:!0,session_timers_refresh_method:rr.UPDATE,session_timers_force_refresher:!1,no_answer_timeout:60,register:!0,register_expires:600,registrar_server:null,sockets:null,connection_recovery_max_interval:rr.CONNECTION_RECOVERY_MAX_INTERVAL,connection_recovery_min_interval:rr.CONNECTION_RECOVERY_MIN_INTERVAL,extra_headers:null,via_host:"".concat(Gr.createRandomToken(12),".invalid")};var Fa={mandatory:{sockets:function(n){var a=[];if(tu.isSocket(n))a.push({socket:n});else if(Array.isArray(n)&&n.length){var e=_f(n),o;try{for(e.s();!(o=e.n()).done;){var p=o.value;Object.prototype.hasOwnProperty.call(p,"socket")&&tu.isSocket(p.socket)?a.push(p):tu.isSocket(p)&&a.push({socket:p})}}catch(t){e.e(t)}finally{e.f()}}else return;return a},uri:function(n){/^sip:/i.test(n)||(n="".concat(rr.SIP,":").concat(n));var a=pf.parse(n);if(a)return a.user?a:void 0}},optional:{authorization_user:function(n){if(eu.parse('"'.concat(n,'"'),"quoted_string")!==-1)return n},authorization_jwt:function(n){if(typeof n=="string")return n},user_agent:function(n){if(typeof n=="string")return n},connection_recovery_max_interval:function(n){if(Gr.isDecimal(n)){var a=Number(n);if(a>0)return a}},connection_recovery_min_interval:function(n){if(Gr.isDecimal(n)){var a=Number(n);if(a>0)return a}},contact_uri:function(n){if(typeof n=="string"){var a=eu.parse(n,"SIP_URI");if(a!==-1)return a}},display_name:function(n){return n},instance_id:function(n){if(/^uuid:/i.test(n)&&(n=n.substr(5)),eu.parse(n,"uuid")!==-1)return n},no_answer_timeout:function(n){if(Gr.isDecimal(n)){var a=Number(n);if(a>0)return a}},session_timers:function(n){if(typeof n=="boolean")return n},session_timers_refresh_method:function(n){if(typeof n=="string"&&(n=n.toUpperCase(),n===rr.INVITE||n===rr.UPDATE))return n},session_timers_force_refresher:function(n){if(typeof n=="boolean")return n},password:function(n){return String(n)},realm:function(n){return String(n)},ha1:function(n){return String(n)},register:function(n){if(typeof n=="boolean")return n},register_expires:function(n){if(Gr.isDecimal(n)){var a=Number(n);if(a>0)return a}},registrar_server:function(n){/^sip:/i.test(n)||(n="".concat(rr.SIP,":").concat(n));var a=pf.parse(n);if(a)return a.user?void 0:a},use_preloaded_route:function(n){if(typeof n=="boolean")return n},extra_headers:function(n){var a=[];if(Array.isArray(n)&&n.length){var e=_f(n),o;try{for(e.s();!(o=e.n()).done;){var p=o.value;typeof p=="string"&&a.push(p)}}catch(t){e.e(t)}finally{e.f()}}else return;return a}}};Zo.load=function(u,n){for(var a in Fa.mandatory)if(n.hasOwnProperty(a)){var e=n[a],o=Fa.mandatory[a](e);if(o!==void 0)u[a]=o;else throw new su.ConfigurationError(a,e)}else throw new su.ConfigurationError(a);for(var p in Fa.optional)if(n.hasOwnProperty(p)){var t=n[p];if(Gr.isEmpty(t))continue;var v=Fa.optional[p](t);if(v!==void 0)u[p]=v;else throw new su.ConfigurationError(p,t)}};function qa(u){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?qa=function(a){return typeof a}:qa=function(a){return a&&typeof Symbol=="function"&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a},qa(u)}function Kp(u,n){if(!(u instanceof n))throw new TypeError("Cannot call a class as a function")}function mf(u,n){for(var a=0;a<n.length;a++){var e=n[a];e.enumerable=e.enumerable||!1,e.configurable=!0,"value"in e&&(e.writable=!0),Object.defineProperty(u,e.key,e)}}function gf(u,n,a){return n&&mf(u.prototype,n),a&&mf(u,a),u}function Yp(u,n){if(typeof n!="function"&&n!==null)throw new TypeError("Super expression must either be null or a function");u.prototype=Object.create(n&&n.prototype,{constructor:{value:u,writable:!0,configurable:!0}}),n&&nu(u,n)}function nu(u,n){return nu=Object.setPrototypeOf||function(e,o){return e.__proto__=o,e},nu(u,n)}function zp(u){var n=Xp();return function(){var e=ja(u),o;if(n){var p=ja(this).constructor;o=Reflect.construct(e,arguments,p)}else o=e.apply(this,arguments);return Jp(this,o)}}function Jp(u,n){return n&&(qa(n)==="object"||typeof n=="function")?n:vf(u)}function vf(u){if(u===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return u}function Xp(){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 ja(u){return ja=Object.setPrototypeOf?Object.getPrototypeOf:function(a){return a.__proto__||Object.getPrototypeOf(a)},ja(u)}var Qp=Ct.EventEmitter,Zp=St,bt=pt,em=q_,Tf=Jd,Ef=up,Cf=Cp,lu=yi,tm=wp,Va=Mt(),sm=Wn,nm=Kn(),lm=rf,ru=pn,rm=$p,iu=Zo,et=new Zp("UA"),It={STATUS_INIT:0,STATUS_READY:1,STATUS_USER_CLOSED:2,STATUS_NOT_READY:3,CONFIGURATION_ERROR:1,NETWORK_ERROR:2},im=function(u){Yp(a,u);var n=zp(a);gf(a,null,[{key:"C",get:function(){return It}}]);function a(e){var o;if(Kp(this,a),et.debug("new() [configuration:%o]",e),o=n.call(this),o._cache={credentials:{}},o._configuration=Object.assign({},iu.settings),o._dynConfiguration={},o._dialogs={},o._applicants={},o._sessions={},o._transport=null,o._contact=null,o._status=It.STATUS_INIT,o._error=null,o._transactions={nist:{},nict:{},ist:{},ict:{}},o._data={},o._closeTimer=null,e===void 0)throw new TypeError("Not enough arguments");try{o._loadConfig(e)}catch(p){throw o._status=It.STATUS_NOT_READY,o._error=It.CONFIGURATION_ERROR,p}return o._registrator=new em(vf(o)),o}return gf(a,[{key:"start",value:function(){et.debug("start()"),this._status===It.STATUS_INIT?this._transport.connect():this._status===It.STATUS_USER_CLOSED?(et.debug("restarting UA"),this._closeTimer!==null&&(clearTimeout(this._closeTimer),this._closeTimer=null,this._transport.disconnect()),this._status=It.STATUS_INIT,this._transport.connect()):this._status===It.STATUS_READY?et.debug("UA is in READY status, not restarted"):et.debug("ERROR: connection is down, Auto-Recovery system is trying to reconnect"),this._dynConfiguration.register=this._configuration.register}},{key:"register",value:function(){et.debug("register()"),this._dynConfiguration.register=!0,this._registrator.register()}},{key:"unregister",value:function(o){et.debug("unregister()"),this._dynConfiguration.register=!1,this._registrator.unregister(o)}},{key:"registrator",value:function(){return this._registrator}},{key:"isRegistered",value:function(){return this._registrator.registered}},{key:"isConnected",value:function(){return this._transport.isConnected()}},{key:"call",value:function(o,p){et.debug("call()");var t=new Tf(this);return t.connect(o,p),t}},{key:"sendMessage",value:function(o,p,t){et.debug("sendMessage()");var v=new Ef(this);return v.send(o,p,t),v}},{key:"sendOptions",value:function(o,p,t){et.debug("sendOptions()");var v=new Cf(this);return v.send(o,p,t),v}},{key:"terminateSessions",value:function(o){et.debug("terminateSessions()");for(var p in this._sessions)this._sessions[p].isEnded()||this._sessions[p].terminate(o)}},{key:"stop",value:function(){var o=this;if(et.debug("stop()"),this._dynConfiguration={},this._status===It.STATUS_USER_CLOSED){et.debug("UA already closed");return}this._registrator.close();var p=Object.keys(this._sessions).length;for(var t in this._sessions)if(Object.prototype.hasOwnProperty.call(this._sessions,t)){et.debug("closing session ".concat(t));try{this._sessions[t].terminate()}catch{}}for(var v in this._applicants)if(Object.prototype.hasOwnProperty.call(this._applicants,v))try{this._applicants[v].close()}catch{}this._status=It.STATUS_USER_CLOSED;var C=Object.keys(this._transactions.nict).length+Object.keys(this._transactions.nist).length+Object.keys(this._transactions.ict).length+Object.keys(this._transactions.ist).length;C===0&&p===0?this._transport.disconnect():this._closeTimer=setTimeout(function(){o._closeTimer=null,o._transport.disconnect()},2e3)}},{key:"normalizeTarget",value:function(o){return Va.normalizeTarget(o,this._configuration.hostport_params)}},{key:"get",value:function(o){switch(o){case"authorization_user":return this._configuration.authorization_user;case"realm":return this._configuration.realm;case"ha1":return this._configuration.ha1;case"authorization_jwt":return this._configuration.authorization_jwt;default:et.warn('get() | cannot get "%s" parameter in runtime',o);return}}},{key:"set",value:function(o,p){switch(o){case"authorization_user":{this._configuration.authorization_user=String(p);break}case"password":{this._configuration.password=String(p);break}case"realm":{this._configuration.realm=String(p);break}case"ha1":{this._configuration.ha1=String(p),this._configuration.password=null;break}case"authorization_jwt":{this._configuration.authorization_jwt=String(p);break}case"display_name":{this._configuration.display_name=p;break}default:return et.warn('set() | cannot set "%s" parameter in runtime',o),!1}return!0}},{key:"newTransaction",value:function(o){this._transactions[o.type][o.id]=o,this.emit("newTransaction",{transaction:o})}},{key:"destroyTransaction",value:function(o){delete this._transactions[o.type][o.id],this.emit("transactionDestroyed",{transaction:o})}},{key:"newDialog",value:function(o){this._dialogs[o.id]=o}},{key:"destroyDialog",value:function(o){delete this._dialogs[o.id]}},{key:"newMessage",value:function(o,p){this._applicants[o]=o,this.emit("newMessage",p)}},{key:"newOptions",value:function(o,p){this._applicants[o]=o,this.emit("newOptions",p)}},{key:"destroyMessage",value:function(o){delete this._applicants[o]}},{key:"newRTCSession",value:function(o,p){this._sessions[o.id]=o,this.emit("newRTCSession",p)}},{key:"destroyRTCSession",value:function(o){delete this._sessions[o.id]}},{key:"registered",value:function(o){this.emit("registered",o)}},{key:"unregistered",value:function(o){this.emit("unregistered",o)}},{key:"registrationFailed",value:function(o){this.emit("registrationFailed",o)}},{key:"receiveRequest",value:function(o){var p=o.method;if(o.ruri.user!==this._configuration.uri.user&&o.ruri.user!==this._contact.uri.user){et.debug("Request-URI does not point to us"),o.method!==bt.ACK&&o.reply_sl(404);return}if(o.ruri.scheme===bt.SIPS){o.reply_sl(416);return}if(!lu.checkTransaction(this,o)){if(p===bt.INVITE?new lu.InviteServerTransaction(this,this._transport,o):p!==bt.ACK&&p!==bt.CANCEL&&new lu.NonInviteServerTransaction(this,this._transport,o),p===bt.OPTIONS){if(this.listeners("newOptions").length===0){o.reply(200);return}var t=new Cf(this);t.init_incoming(o)}else if(p===bt.MESSAGE){if(this.listeners("newMessage").length===0){o.reply(405);return}var v=new Ef(this);v.init_incoming(o)}else if(p===bt.INVITE&&!o.to_tag&&this.listeners("newRTCSession").length===0){o.reply(405);return}var C,l;if(o.to_tag)C=this._findDialog(o.call_id,o.from_tag,o.to_tag),C?C.receiveRequest(o):p===bt.NOTIFY?(l=this._findSession(o),l?l.receiveRequest(o):(et.debug("received NOTIFY request for a non existent subscription"),o.reply(481,"Subscription does not exist"))):p!==bt.ACK&&o.reply(481);else switch(p){case bt.INVITE:if(window.RTCPeerConnection)if(o.hasHeader("replaces")){var A=o.replaces;C=this._findDialog(A.call_id,A.from_tag,A.to_tag),C?(l=C.owner,l.isEnded()?o.reply(603):l.receiveRequest(o)):o.reply(481)}else l=new Tf(this),l.init_incoming(o);else et.warn("INVITE received but WebRTC is not supported"),o.reply(488);break;case bt.BYE:o.reply(481);break;case bt.CANCEL:l=this._findSession(o),l?l.receiveRequest(o):et.debug("received CANCEL request for a non existent session");break;case bt.ACK:break;case bt.NOTIFY:this.emit("sipEvent",{event:o.event,request:o}),o.reply(200);break;default:o.reply(405);break}}}},{key:"_findSession",value:function(o){var p=o.call_id,t=o.from_tag,v=o.to_tag,C=p+t,l=this._sessions[C],A=p+v,b=this._sessions[A];return l||b||null}},{key:"_findDialog",value:function(o,p,t){var v=o+p+t,C=this._dialogs[v];return C||(v=o+t+p,C=this._dialogs[v],C||null)}},{key:"_loadConfig",value:function(o){try{iu.load(this._configuration,o)}catch(A){throw A}this._configuration.display_name===0&&(this._configuration.display_name="0"),this._configuration.instance_id||(this._configuration.instance_id=Va.newUUID()),this._configuration.jssip_id=Va.createRandomToken(5);var p=this._configuration.uri.clone();p.user=null,this._configuration.hostport_params=p.toString().replace(/^sip:/i,"");try{this._transport=new tm(this._configuration.sockets,{max_interval:this._configuration.connection_recovery_max_interval,min_interval:this._configuration.connection_recovery_min_interval}),this._transport.onconnecting=am.bind(this),this._transport.onconnect=om.bind(this),this._transport.ondisconnect=um.bind(this),this._transport.ondata=cm.bind(this)}catch(A){throw et.warn(A),new sm.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){var t=this._configuration.uri.clone();t.user=null,t.clearParams(),t.clearHeaders(),this._configuration.registrar_server=t}this._configuration.no_answer_timeout*=1e3,this._configuration.contact_uri?this._configuration.via_host=this._configuration.contact_uri.host:this._configuration.contact_uri=new nm("sip",Va.createRandomToken(8),this._configuration.via_host,null,{transport:"ws"}),this._contact={pub_gruu:null,temp_gruu:null,uri:this._configuration.contact_uri,toString:function(){var b=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},E=b.anonymous||null,O=b.outbound||null,w="<";return E?w+=this.temp_gruu||"sip:anonymous@anonymous.invalid;transport=ws":w+=this.pub_gruu||this.uri.toString(),O&&(E?!this.temp_gruu:!this.pub_gruu)&&(w+=";ob"),w+=">",w}};var v=["authorization_user","password","realm","ha1","authorization_jwt","display_name","register"];for(var C in this._configuration)Object.prototype.hasOwnProperty.call(this._configuration,C)&&(v.indexOf(C)!==-1?Object.defineProperty(this._configuration,C,{writable:!0,configurable:!1}):Object.defineProperty(this._configuration,C,{writable:!1,configurable:!1}));et.debug("configuration parameters after validation:");for(var l in this._configuration)if(Object.prototype.hasOwnProperty.call(iu.settings,l))switch(l){case"uri":case"registrar_server":et.debug("- ".concat(l,": ").concat(this._configuration[l]));break;case"password":case"ha1":case"authorization_jwt":et.debug("- ".concat(l,": NOT SHOWN"));break;default:et.debug("- ".concat(l,": ").concat(JSON.stringify(this._configuration[l])))}}},{key:"C",get:function(){return It}},{key:"status",get:function(){return this._status}},{key:"contact",get:function(){return this._contact}},{key:"configuration",get:function(){return this._configuration}},{key:"transport",get:function(){return this._transport}}]),a}(Qp);function am(u){this.emit("connecting",u)}function om(u){this._status!==It.STATUS_USER_CLOSED&&(this._status=It.STATUS_READY,this._error=null,this.emit("connected",u),this._dynConfiguration.register&&this._registrator.register())}function um(u){for(var n=["nict","ict","nist","ist"],a=0,e=n;a<e.length;a++){var o=e[a];for(var p in this._transactions[o])Object.prototype.hasOwnProperty.call(this._transactions[o],p)&&this._transactions[o][p].onTransportError()}this.emit("disconnected",u),this._registrator.onTransportClosed(),this._status!==It.STATUS_USER_CLOSED&&(this._status=It.STATUS_NOT_READY,this._error=It.NETWORK_ERROR)}function cm(u){var n=u.transport,a=u.message;if(a=lm.parseMessage(a,this),!!a&&!(this._status===It.STATUS_USER_CLOSED&&a instanceof ru.IncomingRequest)&&rm(a,this,n)){if(a instanceof ru.IncomingRequest)a.transport=n,this.receiveRequest(a);else if(a instanceof ru.IncomingResponse){var e;switch(a.method){case bt.INVITE:e=this._transactions.ict[a.via_branch],e&&e.receiveResponse(a);break;case bt.ACK:break;default:e=this._transactions.nict[a.via_branch],e&&e.receiveResponse(a);break}}}}function fm(u,n){if(!(u instanceof n))throw new TypeError("Cannot call a class as a function")}function Sf(u,n){for(var a=0;a<n.length;a++){var e=n[a];e.enumerable=e.enumerable||!1,e.configurable=!0,"value"in e&&(e.writable=!0),Object.defineProperty(u,e.key,e)}}function hm(u,n,a){return n&&Sf(u.prototype,n),a&&Sf(u,a),u}var _m=St,dm=Gs(),jt=new _m("WebSocketInterface"),pm=function(){function u(n){fm(this,u),jt.debug('new() [url:"%s"]',n),this._url=n,this._sip_uri=null,this._via_transport=null,this._ws=null;var a=dm.parse(n,"absoluteURI");if(a===-1)throw jt.warn("invalid WebSocket URI: ".concat(n)),new TypeError("Invalid argument: ".concat(n));if(a.scheme!=="wss"&&a.scheme!=="ws")throw jt.warn("invalid WebSocket URI scheme: ".concat(a.scheme)),new TypeError("Invalid argument: ".concat(n));this._sip_uri="sip:".concat(a.host).concat(a.port?":".concat(a.port):"",";transport=ws"),this._via_transport=a.scheme.toUpperCase()}return hm(u,[{key:"connect",value:function(){if(jt.debug("connect()"),this.isConnected()){jt.debug("WebSocket ".concat(this._url," is already connected"));return}else if(this.isConnecting()){jt.debug("WebSocket ".concat(this._url," is connecting"));return}this._ws&&this.disconnect(),jt.debug("connecting to WebSocket ".concat(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(a){this._onError(a)}}},{key:"disconnect",value:function(){jt.debug("disconnect()"),this._ws&&(this._ws.onopen=function(){},this._ws.onclose=function(){},this._ws.onmessage=function(){},this._ws.onerror=function(){},this._ws.close(),this._ws=null)}},{key:"send",value:function(a){return jt.debug("send()"),this.isConnected()?(this._ws.send(a),!0):(jt.warn("unable to send message, WebSocket is not open"),!1)}},{key:"isConnected",value:function(){return this._ws&&this._ws.readyState===this._ws.OPEN}},{key:"isConnecting",value:function(){return this._ws&&this._ws.readyState===this._ws.CONNECTING}},{key:"_onOpen",value:function(){jt.debug("WebSocket ".concat(this._url," connected")),this.onconnect()}},{key:"_onClose",value:function(a){var e=a.wasClean,o=a.code,p=a.reason;jt.debug("WebSocket ".concat(this._url," closed")),e===!1&&jt.debug("WebSocket abrupt disconnection"),this.ondisconnect(!e,o,p)}},{key:"_onMessage",value:function(a){var e=a.data;jt.debug("received WebSocket message"),this.ondata(e)}},{key:"_onError",value:function(a){jt.warn("WebSocket ".concat(this._url," error: "),a)}},{key:"via_transport",get:function(){return this._via_transport},set:function(a){this._via_transport=a.toUpperCase()}},{key:"sip_uri",get:function(){return this._sip_uri}},{key:"url",get:function(){return this._url}}]),u}(),au=ra,mm=pt,gm=Wn,vm=Mt(),Tm=im,Em=Kn(),Cm=vo(),Sm=Gs(),Am=pm,ym=jr("JsSIP");ym("version %s",au.version);var Af={C:mm,Exceptions:gm,Utils:vm,UA:Tm,URI:Em,NameAddrHeader:Cm,WebSocketInterface:Am,Grammar:Sm,debug:jr,get name(){return au.title},get version(){return au.version}};const Wr=jr,Kr="JsSIP";var Tt=class{constructor(n){n?(this._debug=Wr.default(`${Kr}:${n}`),this._warn=Wr.default(`${Kr}:WARN:${n}`),this._error=Wr.default(`${Kr}:ERROR:${n}`)):(this._debug=Wr.default(Kr),this._warn=Wr.default(`${Kr}:WARN`),this._error=Wr.default(`${Kr}:ERROR`)),this._debug.log=console.info.bind(console),this._warn.log=console.warn.bind(console),this._error.log=console.error.bind(console)}get debug(){return this._debug}get warn(){return this._warn}get error(){return this._error}};const Ba=Be(Tt),yf=ra;var Fe={USER_AGENT:`${yf.title} ${yf.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};const Y=Be(Fe);var ft={},Rf={},ou,bf;function Ga(){if(bf)return ou;bf=1;const u=Tn(),n=Ys();return ou=class $h{static parse(e){if(e=n.parse(e,"Name_Addr_Header"),e!==-1)return e}constructor(e,o,p){if(!e||!(e instanceof u))throw new TypeError('missing or invalid "uri" parameter');this._uri=e,this._parameters={},this.display_name=o;for(const t in p)Object.prototype.hasOwnProperty.call(p,t)&&this.setParam(t,p[t])}get uri(){return this._uri}get display_name(){return this._display_name}set display_name(e){this._display_name=e===0?"0":e}setParam(e,o){e&&(this._parameters[e.toLowerCase()]=typeof o>"u"||o===null?null:o.toString())}getParam(e){if(e)return this._parameters[e.toLowerCase()]}hasParam(e){if(e)return this._parameters.hasOwnProperty(e.toLowerCase())&&!0||!1}deleteParam(e){if(e=e.toLowerCase(),this._parameters.hasOwnProperty(e)){const o=this._parameters[e];return delete this._parameters[e],o}}clearParams(){this._parameters={}}clone(){return new $h(this._uri.clone(),this._display_name,JSON.parse(JSON.stringify(this._parameters)))}_quote(e){return e.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}toString(){let e=this._display_name?`"${this._quote(this._display_name)}" `:"";e+=`<${this._uri.toString()}>`;for(const o in this._parameters)Object.prototype.hasOwnProperty.call(this._parameters,o)&&(e+=`;${o}`,this._parameters[o]!==null&&(e+=`=${this._parameters[o]}`));return e}},ou}var If;function Ys(){if(If)return Rf;If=1;function u(t){return'"'+t.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\x08/g,"\\b").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\f/g,"\\f").replace(/\r/g,"\\r").replace(/[\x00-\x07\x0B\x0E-\x1F\x80-\uFFFF]/g,escape)+'"'}var n={parse:function(t,v){var C={CRLF:O,DIGIT:w,ALPHA:N,HEXDIG:U,WSP:z,OCTET:j,DQUOTE:_e,SP:k,HTAB:H,alphanum:de,reserved:Ue,unreserved:B,mark:L,escaped:V,LWS:G,SWS:K,HCOLON:M,TEXT_UTF8_TRIM:te,TEXT_UTF8char:se,UTF8_NONASCII:$,UTF8_CONT:ne,LHEX:ht,token:P,token_nodot:Q,separators:oe,word:he,STAR:Re,SLASH:be,EQUAL:fe,LPAREN:je,RPAREN:xe,RAQUOT:we,LAQUOT:rt,COMMA:$e,SEMI:ue,COLON:Oe,LDQUOT:Pe,RDQUOT:Le,comment:ye,ctext:pe,quoted_string:Ce,quoted_string_clean:ke,qdtext:He,quoted_pair:We,SIP_URI_noparams:Ve,SIP_URI:Ht,uri_scheme:_t,uri_scheme_sips:Xs,uri_scheme_sip:cs,userinfo:Is,user:ws,user_unreserved:fs,password:Qs,hostport:hs,host:Se,hostname:dt,domainlabel:Zt,toplabel:Ae,IPv6reference:vt,IPv6address:_s,h16:Ee,ls32:Et,IPv4address:Os,dec_octet:ds,port:rl,uri_parameters:il,uri_parameter:In,transport_param:al,user_param:ol,method_param:ul,ttl_param:Ds,maddr_param:cl,lr_param:fl,other_param:es,pname:hl,pvalue:_l,paramchar:Ft,param_unreserved:dr,headers:dl,header:ts,hname:pl,hvalue:ml,hnv_unreserved:Ns,Request_Response:Zs,Request_Line:gl,Request_URI:Us,absoluteURI:xs,hier_part:vl,net_path:ss,abs_path:Ps,opaque_part:Ms,uric:ns,uric_no_slash:wn,path_segments:ks,segment:en,param:On,pchar:ps,scheme:Tl,authority:El,srvr:Dn,reg_name:Cl,query:Sl,SIP_Version:Nn,INVITEm:Al,ACKm:yl,OPTIONSm:Rl,BYEm:tn,CANCELm:bl,REGISTERm:Il,SUBSCRIBEm:sn,NOTIFYm:wl,REFERm:pr,Method:Un,Status_Line:mr,Status_Code:xn,extension_code:ms,Reason_Phrase:Pn,Allow_Events:nn,Call_ID:gs,Contact:Mn,contact_param:qt,name_addr:ls,display_name:ze,contact_params:Yt,c_p_q:gr,c_p_expires:Ze,delta_seconds:zt,qvalue:vr,generic_param:st,gen_value:Ol,Content_Disposition:ei,disp_type:Tr,disp_param:Dl,handling_param:Er,Content_Encoding:Cr,Content_Length:kn,Content_Type:Sr,media_type:Nl,m_type:Ls,discrete_type:Ul,composite_type:Ar,extension_token:$s,x_token:yr,m_subtype:ti,m_parameter:vs,m_value:si,CSeq:Rr,CSeq_value:Ts,Expires:ea,Event:br,event_type:Hs,From:ta,from_param:Ln,tag_param:xl,Max_Forwards:$n,Min_Expires:ln,Name_Addr_Header:Ir,Proxy_Authenticate:rn,challenge:Fs,other_challenge:an,auth_param:qs,digest_cln:on,realm:un,realm_value:Pl,domain:Ml,URI:cn,nonce:fn,nonce_value:wr,opaque:Or,stale:Es,algorithm:ni,qop_options:kl,qop_value:Cs,Proxy_Require:sa,Record_Route:Dr,rec_route:Ss,Reason:na,reason_param:Ll,reason_cause:js,Require:li,Route:ri,route_param:hn,Subscription_State:ii,substate_value:$l,subexp_params:Nr,event_reason_value:Hn,Subject:Fn,Supported:ai,To:qn,to_param:_n,Via:Ur,via_param:dn,via_params:jn,via_ttl:Hl,via_maddr:Fl,via_received:ql,via_branch:jl,response_port:Vl,rport:Bl,sent_protocol:Vn,protocol_name:xr,transport:Pr,sent_by:Bn,via_host:Gl,via_port:Mr,ttl:Wl,WWW_Authenticate:Kl,Session_Expires:oi,s_e_expires:ui,s_e_params:Gn,s_e_refresher:Jt,extension_header:ci,header_value:Yl,message_body:rs,uuid_URI:fi,uuid:zl,hex4:Bt,hex8:kr,hex12:Jl,Refer_To:Xl,Replaces:hi,call_id:Lr,replaces_param:x,to_tag:Ql,from_tag:Zl,early_flag:$r};if(v!==void 0){if(C[v]===void 0)throw new Error("Invalid rule name: "+u(v)+".")}else v="CRLF";var l=0,A=0,b=[];function E(s){l<A||(l>A&&(A=l,b=[]),b.push(s))}function O(){var s;return t.substr(l,2)===`\r
|
73
|
-
`?(
|
74
|
-
`,l+=2):(s=null,E('"\\r\\n"')),s}function w(){var s;return/^[0-9]/.test(t.charAt(l))?(s=t.charAt(l),l++):(s=null,E("[0-9]")),s}function N(){var s;return/^[a-zA-Z]/.test(t.charAt(l))?(s=t.charAt(l),l++):(s=null,E("[a-zA-Z]")),s}function U(){var s;return/^[0-9a-fA-F]/.test(t.charAt(l))?(s=t.charAt(l),l++):(s=null,E("[0-9a-fA-F]")),s}function z(){var s;return s=k(),s===null&&(s=H()),s}function j(){var s;return/^[\0-\xFF]/.test(t.charAt(l))?(s=t.charAt(l),l++):(s=null,E("[\\0-\\xFF]")),s}function _e(){var s;return/^["]/.test(t.charAt(l))?(s=t.charAt(l),l++):(s=null,E('["]')),s}function k(){var s;return console.log("pos",l),console.log("input.charCodeAt(pos)",t.charAt(l)),t.charCodeAt(l)===32?(s=" ",l++):(s=null,E('" "')),s}function H(){var s;return t.charCodeAt(l)===9?(s=" ",l++):(s=null,E('"\\t"')),s}function de(){var s;return/^[a-zA-Z0-9]/.test(t.charAt(l))?(s=t.charAt(l),l++):(s=null,E("[a-zA-Z0-9]")),s}function Ue(){var s;return t.charCodeAt(l)===59?(s=";",l++):(s=null,E('";"')),s===null&&(t.charCodeAt(l)===47?(s="/",l++):(s=null,E('"/"')),s===null&&(t.charCodeAt(l)===63?(s="?",l++):(s=null,E('"?"')),s===null&&(t.charCodeAt(l)===58?(s=":",l++):(s=null,E('":"')),s===null&&(t.charCodeAt(l)===64?(s="@",l++):(s=null,E('"@"')),s===null&&(t.charCodeAt(l)===38?(s="&",l++):(s=null,E('"&"')),s===null&&(t.charCodeAt(l)===61?(s="=",l++):(s=null,E('"="')),s===null&&(t.charCodeAt(l)===43?(s="+",l++):(s=null,E('"+"')),s===null&&(t.charCodeAt(l)===36?(s="$",l++):(s=null,E('"$"')),s===null&&(t.charCodeAt(l)===44?(s=",",l++):(s=null,E('","'))))))))))),s}function B(){var s;return s=de(),s===null&&(s=L()),s}function L(){var s;return t.charCodeAt(l)===45?(s="-",l++):(s=null,E('"-"')),s===null&&(t.charCodeAt(l)===95?(s="_",l++):(s=null,E('"_"')),s===null&&(t.charCodeAt(l)===46?(s=".",l++):(s=null,E('"."')),s===null&&(t.charCodeAt(l)===33?(s="!",l++):(s=null,E('"!"')),s===null&&(t.charCodeAt(l)===126?(s="~",l++):(s=null,E('"~"')),s===null&&(t.charCodeAt(l)===42?(s="*",l++):(s=null,E('"*"')),s===null&&(t.charCodeAt(l)===39?(s="'",l++):(s=null,E(`"'"`)),s===null&&(t.charCodeAt(l)===40?(s="(",l++):(s=null,E('"("')),s===null&&(t.charCodeAt(l)===41?(s=")",l++):(s=null,E('")"')))))))))),s}function V(){var s,c,h,g,S;return g=l,S=l,t.charCodeAt(l)===37?(s="%",l++):(s=null,E('"%"')),s!==null?(c=U(),c!==null?(h=U(),h!==null?s=[s,c,h]:(s=null,l=S)):(s=null,l=S)):(s=null,l=S),s!==null&&(s=function(R,I){return I.join("")}(g,s)),s===null&&(l=g),s}function G(){var s,c,h,g,S,R;for(g=l,S=l,R=l,s=[],c=z();c!==null;)s.push(c),c=z();if(s!==null?(c=O(),c!==null?s=[s,c]:(s=null,l=R)):(s=null,l=R),s=s!==null?s:"",s!==null){if(h=z(),h!==null)for(c=[];h!==null;)c.push(h),h=z();else c=null;c!==null?s=[s,c]:(s=null,l=S)}else s=null,l=S;return s!==null&&(s=function(I){return" "}()),s===null&&(l=g),s}function K(){var s;return s=G(),s=s!==null?s:"",s}function M(){var s,c,h,g,S;for(g=l,S=l,s=[],c=k(),c===null&&(c=H());c!==null;)s.push(c),c=k(),c===null&&(c=H());return s!==null?(t.charCodeAt(l)===58?(c=":",l++):(c=null,E('":"')),c!==null?(h=K(),h!==null?s=[s,c,h]:(s=null,l=S)):(s=null,l=S)):(s=null,l=S),s!==null&&(s=function(R){return":"}()),s===null&&(l=g),s}function te(){var s,c,h,g,S,R,I;if(S=l,R=l,c=se(),c!==null)for(s=[];c!==null;)s.push(c),c=se();else s=null;if(s!==null){for(c=[],I=l,h=[],g=G();g!==null;)h.push(g),g=G();for(h!==null?(g=se(),g!==null?h=[h,g]:(h=null,l=I)):(h=null,l=I);h!==null;){for(c.push(h),I=l,h=[],g=G();g!==null;)h.push(g),g=G();h!==null?(g=se(),g!==null?h=[h,g]:(h=null,l=I)):(h=null,l=I)}c!==null?s=[s,c]:(s=null,l=R)}else s=null,l=R;return s!==null&&(s=function(D){return t.substring(l,D)}(S)),s===null&&(l=S),s}function se(){var s;return/^[!-~]/.test(t.charAt(l))?(s=t.charAt(l),l++):(s=null,E("[!-~]")),s===null&&(s=$()),s}function $(){var s;return/^[\x80-\uFFFF]/.test(t.charAt(l))?(s=t.charAt(l),l++):(s=null,E("[\\x80-\\uFFFF]")),s}function ne(){var s;return/^[\x80-\xBF]/.test(t.charAt(l))?(s=t.charAt(l),l++):(s=null,E("[\\x80-\\xBF]")),s}function ht(){var s;return s=w(),s===null&&(/^[a-f]/.test(t.charAt(l))?(s=t.charAt(l),l++):(s=null,E("[a-f]"))),s}function P(){var s,c,h;if(h=l,c=de(),c===null&&(t.charCodeAt(l)===45?(c="-",l++):(c=null,E('"-"')),c===null&&(t.charCodeAt(l)===46?(c=".",l++):(c=null,E('"."')),c===null&&(t.charCodeAt(l)===33?(c="!",l++):(c=null,E('"!"')),c===null&&(t.charCodeAt(l)===37?(c="%",l++):(c=null,E('"%"')),c===null&&(t.charCodeAt(l)===42?(c="*",l++):(c=null,E('"*"')),c===null&&(t.charCodeAt(l)===95?(c="_",l++):(c=null,E('"_"')),c===null&&(t.charCodeAt(l)===43?(c="+",l++):(c=null,E('"+"')),c===null&&(t.charCodeAt(l)===96?(c="`",l++):(c=null,E('"`"')),c===null&&(t.charCodeAt(l)===39?(c="'",l++):(c=null,E(`"'"`)),c===null&&(t.charCodeAt(l)===126?(c="~",l++):(c=null,E('"~"')))))))))))),c!==null)for(s=[];c!==null;)s.push(c),c=de(),c===null&&(t.charCodeAt(l)===45?(c="-",l++):(c=null,E('"-"')),c===null&&(t.charCodeAt(l)===46?(c=".",l++):(c=null,E('"."')),c===null&&(t.charCodeAt(l)===33?(c="!",l++):(c=null,E('"!"')),c===null&&(t.charCodeAt(l)===37?(c="%",l++):(c=null,E('"%"')),c===null&&(t.charCodeAt(l)===42?(c="*",l++):(c=null,E('"*"')),c===null&&(t.charCodeAt(l)===95?(c="_",l++):(c=null,E('"_"')),c===null&&(t.charCodeAt(l)===43?(c="+",l++):(c=null,E('"+"')),c===null&&(t.charCodeAt(l)===96?(c="`",l++):(c=null,E('"`"')),c===null&&(t.charCodeAt(l)===39?(c="'",l++):(c=null,E(`"'"`)),c===null&&(t.charCodeAt(l)===126?(c="~",l++):(c=null,E('"~"'))))))))))));else s=null;return s!==null&&(s=function(g){return t.substring(l,g)}(h)),s===null&&(l=h),s}function Q(){var s,c,h;if(h=l,c=de(),c===null&&(t.charCodeAt(l)===45?(c="-",l++):(c=null,E('"-"')),c===null&&(t.charCodeAt(l)===33?(c="!",l++):(c=null,E('"!"')),c===null&&(t.charCodeAt(l)===37?(c="%",l++):(c=null,E('"%"')),c===null&&(t.charCodeAt(l)===42?(c="*",l++):(c=null,E('"*"')),c===null&&(t.charCodeAt(l)===95?(c="_",l++):(c=null,E('"_"')),c===null&&(t.charCodeAt(l)===43?(c="+",l++):(c=null,E('"+"')),c===null&&(t.charCodeAt(l)===96?(c="`",l++):(c=null,E('"`"')),c===null&&(t.charCodeAt(l)===39?(c="'",l++):(c=null,E(`"'"`)),c===null&&(t.charCodeAt(l)===126?(c="~",l++):(c=null,E('"~"'))))))))))),c!==null)for(s=[];c!==null;)s.push(c),c=de(),c===null&&(t.charCodeAt(l)===45?(c="-",l++):(c=null,E('"-"')),c===null&&(t.charCodeAt(l)===33?(c="!",l++):(c=null,E('"!"')),c===null&&(t.charCodeAt(l)===37?(c="%",l++):(c=null,E('"%"')),c===null&&(t.charCodeAt(l)===42?(c="*",l++):(c=null,E('"*"')),c===null&&(t.charCodeAt(l)===95?(c="_",l++):(c=null,E('"_"')),c===null&&(t.charCodeAt(l)===43?(c="+",l++):(c=null,E('"+"')),c===null&&(t.charCodeAt(l)===96?(c="`",l++):(c=null,E('"`"')),c===null&&(t.charCodeAt(l)===39?(c="'",l++):(c=null,E(`"'"`)),c===null&&(t.charCodeAt(l)===126?(c="~",l++):(c=null,E('"~"')))))))))));else s=null;return s!==null&&(s=function(g){return t.substring(l,g)}(h)),s===null&&(l=h),s}function oe(){var s;return t.charCodeAt(l)===40?(s="(",l++):(s=null,E('"("')),s===null&&(t.charCodeAt(l)===41?(s=")",l++):(s=null,E('")"')),s===null&&(t.charCodeAt(l)===60?(s="<",l++):(s=null,E('"<"')),s===null&&(t.charCodeAt(l)===62?(s=">",l++):(s=null,E('">"')),s===null&&(t.charCodeAt(l)===64?(s="@",l++):(s=null,E('"@"')),s===null&&(t.charCodeAt(l)===44?(s=",",l++):(s=null,E('","')),s===null&&(t.charCodeAt(l)===59?(s=";",l++):(s=null,E('";"')),s===null&&(t.charCodeAt(l)===58?(s=":",l++):(s=null,E('":"')),s===null&&(t.charCodeAt(l)===92?(s="\\",l++):(s=null,E('"\\\\"')),s===null&&(s=_e(),s===null&&(t.charCodeAt(l)===47?(s="/",l++):(s=null,E('"/"')),s===null&&(t.charCodeAt(l)===91?(s="[",l++):(s=null,E('"["')),s===null&&(t.charCodeAt(l)===93?(s="]",l++):(s=null,E('"]"')),s===null&&(t.charCodeAt(l)===63?(s="?",l++):(s=null,E('"?"')),s===null&&(t.charCodeAt(l)===61?(s="=",l++):(s=null,E('"="')),s===null&&(t.charCodeAt(l)===123?(s="{",l++):(s=null,E('"{"')),s===null&&(t.charCodeAt(l)===125?(s="}",l++):(s=null,E('"}"')),s===null&&(s=k(),s===null&&(s=H())))))))))))))))))),s}function he(){var s,c,h;if(h=l,c=de(),c===null&&(t.charCodeAt(l)===45?(c="-",l++):(c=null,E('"-"')),c===null&&(t.charCodeAt(l)===46?(c=".",l++):(c=null,E('"."')),c===null&&(t.charCodeAt(l)===33?(c="!",l++):(c=null,E('"!"')),c===null&&(t.charCodeAt(l)===37?(c="%",l++):(c=null,E('"%"')),c===null&&(t.charCodeAt(l)===42?(c="*",l++):(c=null,E('"*"')),c===null&&(t.charCodeAt(l)===95?(c="_",l++):(c=null,E('"_"')),c===null&&(t.charCodeAt(l)===43?(c="+",l++):(c=null,E('"+"')),c===null&&(t.charCodeAt(l)===96?(c="`",l++):(c=null,E('"`"')),c===null&&(t.charCodeAt(l)===39?(c="'",l++):(c=null,E(`"'"`)),c===null&&(t.charCodeAt(l)===126?(c="~",l++):(c=null,E('"~"')),c===null&&(t.charCodeAt(l)===40?(c="(",l++):(c=null,E('"("')),c===null&&(t.charCodeAt(l)===41?(c=")",l++):(c=null,E('")"')),c===null&&(t.charCodeAt(l)===60?(c="<",l++):(c=null,E('"<"')),c===null&&(t.charCodeAt(l)===62?(c=">",l++):(c=null,E('">"')),c===null&&(t.charCodeAt(l)===58?(c=":",l++):(c=null,E('":"')),c===null&&(t.charCodeAt(l)===92?(c="\\",l++):(c=null,E('"\\\\"')),c===null&&(c=_e(),c===null&&(t.charCodeAt(l)===47?(c="/",l++):(c=null,E('"/"')),c===null&&(t.charCodeAt(l)===91?(c="[",l++):(c=null,E('"["')),c===null&&(t.charCodeAt(l)===93?(c="]",l++):(c=null,E('"]"')),c===null&&(t.charCodeAt(l)===63?(c="?",l++):(c=null,E('"?"')),c===null&&(t.charCodeAt(l)===123?(c="{",l++):(c=null,E('"{"')),c===null&&(t.charCodeAt(l)===125?(c="}",l++):(c=null,E('"}"'))))))))))))))))))))))))),c!==null)for(s=[];c!==null;)s.push(c),c=de(),c===null&&(t.charCodeAt(l)===45?(c="-",l++):(c=null,E('"-"')),c===null&&(t.charCodeAt(l)===46?(c=".",l++):(c=null,E('"."')),c===null&&(t.charCodeAt(l)===33?(c="!",l++):(c=null,E('"!"')),c===null&&(t.charCodeAt(l)===37?(c="%",l++):(c=null,E('"%"')),c===null&&(t.charCodeAt(l)===42?(c="*",l++):(c=null,E('"*"')),c===null&&(t.charCodeAt(l)===95?(c="_",l++):(c=null,E('"_"')),c===null&&(t.charCodeAt(l)===43?(c="+",l++):(c=null,E('"+"')),c===null&&(t.charCodeAt(l)===96?(c="`",l++):(c=null,E('"`"')),c===null&&(t.charCodeAt(l)===39?(c="'",l++):(c=null,E(`"'"`)),c===null&&(t.charCodeAt(l)===126?(c="~",l++):(c=null,E('"~"')),c===null&&(t.charCodeAt(l)===40?(c="(",l++):(c=null,E('"("')),c===null&&(t.charCodeAt(l)===41?(c=")",l++):(c=null,E('")"')),c===null&&(t.charCodeAt(l)===60?(c="<",l++):(c=null,E('"<"')),c===null&&(t.charCodeAt(l)===62?(c=">",l++):(c=null,E('">"')),c===null&&(t.charCodeAt(l)===58?(c=":",l++):(c=null,E('":"')),c===null&&(t.charCodeAt(l)===92?(c="\\",l++):(c=null,E('"\\\\"')),c===null&&(c=_e(),c===null&&(t.charCodeAt(l)===47?(c="/",l++):(c=null,E('"/"')),c===null&&(t.charCodeAt(l)===91?(c="[",l++):(c=null,E('"["')),c===null&&(t.charCodeAt(l)===93?(c="]",l++):(c=null,E('"]"')),c===null&&(t.charCodeAt(l)===63?(c="?",l++):(c=null,E('"?"')),c===null&&(t.charCodeAt(l)===123?(c="{",l++):(c=null,E('"{"')),c===null&&(t.charCodeAt(l)===125?(c="}",l++):(c=null,E('"}"')))))))))))))))))))))))));else s=null;return s!==null&&(s=function(g){return t.substring(l,g)}(h)),s===null&&(l=h),s}function Re(){var s,c,h,g,S;return g=l,S=l,s=K(),s!==null?(t.charCodeAt(l)===42?(c="*",l++):(c=null,E('"*"')),c!==null?(h=K(),h!==null?s=[s,c,h]:(s=null,l=S)):(s=null,l=S)):(s=null,l=S),s!==null&&(s=function(R){return"*"}()),s===null&&(l=g),s}function be(){var s,c,h,g,S;return g=l,S=l,s=K(),s!==null?(t.charCodeAt(l)===47?(c="/",l++):(c=null,E('"/"')),c!==null?(h=K(),h!==null?s=[s,c,h]:(s=null,l=S)):(s=null,l=S)):(s=null,l=S),s!==null&&(s=function(R){return"/"}()),s===null&&(l=g),s}function fe(){var s,c,h,g,S;return g=l,S=l,s=K(),s!==null?(t.charCodeAt(l)===61?(c="=",l++):(c=null,E('"="')),c!==null?(h=K(),h!==null?s=[s,c,h]:(s=null,l=S)):(s=null,l=S)):(s=null,l=S),s!==null&&(s=function(R){return"="}()),s===null&&(l=g),s}function je(){var s,c,h,g,S;return g=l,S=l,s=K(),s!==null?(t.charCodeAt(l)===40?(c="(",l++):(c=null,E('"("')),c!==null?(h=K(),h!==null?s=[s,c,h]:(s=null,l=S)):(s=null,l=S)):(s=null,l=S),s!==null&&(s=function(R){return"("}()),s===null&&(l=g),s}function xe(){var s,c,h,g,S;return g=l,S=l,s=K(),s!==null?(t.charCodeAt(l)===41?(c=")",l++):(c=null,E('")"')),c!==null?(h=K(),h!==null?s=[s,c,h]:(s=null,l=S)):(s=null,l=S)):(s=null,l=S),s!==null&&(s=function(R){return")"}()),s===null&&(l=g),s}function we(){var s,c,h,g;return h=l,g=l,t.charCodeAt(l)===62?(s=">",l++):(s=null,E('">"')),s!==null?(c=K(),c!==null?s=[s,c]:(s=null,l=g)):(s=null,l=g),s!==null&&(s=function(S){return">"}()),s===null&&(l=h),s}function rt(){var s,c,h,g;return h=l,g=l,s=K(),s!==null?(t.charCodeAt(l)===60?(c="<",l++):(c=null,E('"<"')),c!==null?s=[s,c]:(s=null,l=g)):(s=null,l=g),s!==null&&(s=function(S){return"<"}()),s===null&&(l=h),s}function $e(){var s,c,h,g,S;return g=l,S=l,s=K(),s!==null?(t.charCodeAt(l)===44?(c=",",l++):(c=null,E('","')),c!==null?(h=K(),h!==null?s=[s,c,h]:(s=null,l=S)):(s=null,l=S)):(s=null,l=S),s!==null&&(s=function(R){return","}()),s===null&&(l=g),s}function ue(){var s,c,h,g,S;return g=l,S=l,s=K(),s!==null?(t.charCodeAt(l)===59?(c=";",l++):(c=null,E('";"')),c!==null?(h=K(),h!==null?s=[s,c,h]:(s=null,l=S)):(s=null,l=S)):(s=null,l=S),s!==null&&(s=function(R){return";"}()),s===null&&(l=g),s}function Oe(){var s,c,h,g,S;return g=l,S=l,s=K(),s!==null?(t.charCodeAt(l)===58?(c=":",l++):(c=null,E('":"')),c!==null?(h=K(),h!==null?s=[s,c,h]:(s=null,l=S)):(s=null,l=S)):(s=null,l=S),s!==null&&(s=function(R){return":"}()),s===null&&(l=g),s}function Pe(){var s,c,h,g;return h=l,g=l,s=K(),s!==null?(c=_e(),c!==null?s=[s,c]:(s=null,l=g)):(s=null,l=g),s!==null&&(s=function(S){return'"'}()),s===null&&(l=h),s}function Le(){var s,c,h,g;return h=l,g=l,s=_e(),s!==null?(c=K(),c!==null?s=[s,c]:(s=null,l=g)):(s=null,l=g),s!==null&&(s=function(S){return'"'}()),s===null&&(l=h),s}function ye(){var s,c,h,g;if(g=l,s=je(),s!==null){for(c=[],h=pe(),h===null&&(h=We(),h===null&&(h=ye()));h!==null;)c.push(h),h=pe(),h===null&&(h=We(),h===null&&(h=ye()));c!==null?(h=xe(),h!==null?s=[s,c,h]:(s=null,l=g)):(s=null,l=g)}else s=null,l=g;return s}function pe(){var s;return/^[!-']/.test(t.charAt(l))?(s=t.charAt(l),l++):(s=null,E("[!-']")),s===null&&(/^[*-[]/.test(t.charAt(l))?(s=t.charAt(l),l++):(s=null,E("[*-[]")),s===null&&(/^[\]-~]/.test(t.charAt(l))?(s=t.charAt(l),l++):(s=null,E("[\\]-~]")),s===null&&(s=$(),s===null&&(s=G())))),s}function Ce(){var s,c,h,g,S,R;if(S=l,R=l,s=K(),s!==null)if(c=_e(),c!==null){for(h=[],g=He(),g===null&&(g=We());g!==null;)h.push(g),g=He(),g===null&&(g=We());h!==null?(g=_e(),g!==null?s=[s,c,h,g]:(s=null,l=R)):(s=null,l=R)}else s=null,l=R;else s=null,l=R;return s!==null&&(s=function(I){return t.substring(l,I)}(S)),s===null&&(l=S),s}function ke(){var s,c,h,g,S,R;if(S=l,R=l,s=K(),s!==null)if(c=_e(),c!==null){for(h=[],g=He(),g===null&&(g=We());g!==null;)h.push(g),g=He(),g===null&&(g=We());h!==null?(g=_e(),g!==null?s=[s,c,h,g]:(s=null,l=R)):(s=null,l=R)}else s=null,l=R;else s=null,l=R;return s!==null&&(s=function(I){var D=t.substring(l,I).trim();return D.substring(1,D.length-1).replace(/\\([\x00-\x09\x0b-\x0c\x0e-\x7f])/g,"$1")}(S)),s===null&&(l=S),s}function He(){var s;return s=G(),s===null&&(t.charCodeAt(l)===33?(s="!",l++):(s=null,E('"!"')),s===null&&(/^[#-[]/.test(t.charAt(l))?(s=t.charAt(l),l++):(s=null,E("[#-[]")),s===null&&(/^[\]-~]/.test(t.charAt(l))?(s=t.charAt(l),l++):(s=null,E("[\\]-~]")),s===null&&(s=$())))),s}function We(){var s,c,h;return h=l,t.charCodeAt(l)===92?(s="\\",l++):(s=null,E('"\\\\"')),s!==null?(/^[\0-\t]/.test(t.charAt(l))?(c=t.charAt(l),l++):(c=null,E("[\\0-\\t]")),c===null&&(/^[\x0B-\f]/.test(t.charAt(l))?(c=t.charAt(l),l++):(c=null,E("[\\x0B-\\f]")),c===null&&(/^[\x0E-]/.test(t.charAt(l))?(c=t.charAt(l),l++):(c=null,E("[\\x0E-]")))),c!==null?s=[s,c]:(s=null,l=h)):(s=null,l=h),s}function Ve(){var s,c,h,g,S,R;return S=l,R=l,s=_t(),s!==null?(t.charCodeAt(l)===58?(c=":",l++):(c=null,E('":"')),c!==null?(h=Is(),h=h!==null?h:"",h!==null?(g=hs(),g!==null?s=[s,c,h,g]:(s=null,l=R)):(s=null,l=R)):(s=null,l=R)):(s=null,l=R),s!==null&&(s=function(I){try{T.uri=new _(T.scheme,T.user,T.host,T.port),delete T.scheme,delete T.user,delete T.host,delete T.host_type,delete T.port}catch{T=-1}}()),s===null&&(l=S),s}function Ht(){var s,c,h,g,S,R,I,D;return I=l,D=l,s=_t(),s!==null?(t.charCodeAt(l)===58?(c=":",l++):(c=null,E('":"')),c!==null?(h=Is(),h=h!==null?h:"",h!==null?(g=hs(),g!==null?(S=il(),S!==null?(R=dl(),R=R!==null?R:"",R!==null?s=[s,c,h,g,S,R]:(s=null,l=D)):(s=null,l=D)):(s=null,l=D)):(s=null,l=D)):(s=null,l=D)):(s=null,l=D),s!==null&&(s=function(J){try{T.uri=new _(T.scheme,T.user,T.host,T.port,T.uri_params,T.uri_headers),delete T.scheme,delete T.user,delete T.host,delete T.host_type,delete T.port,delete T.uri_params,v==="SIP_URI"&&(T=T.uri)}catch{T=-1}}()),s===null&&(l=I),s}function _t(){var s;return s=Xs(),s===null&&(s=cs()),s}function Xs(){var s,c;return c=l,t.substr(l,4).toLowerCase()==="sips"?(s=t.substr(l,4),l+=4):(s=null,E('"sips"')),s!==null&&(s=function(h,g){T.scheme=g.toLowerCase()}(c,s)),s===null&&(l=c),s}function cs(){var s,c;return c=l,t.substr(l,3).toLowerCase()==="sip"?(s=t.substr(l,3),l+=3):(s=null,E('"sip"')),s!==null&&(s=function(h,g){T.scheme=g.toLowerCase()}(c,s)),s===null&&(l=c),s}function Is(){var s,c,h,g,S,R;return g=l,S=l,s=ws(),s!==null?(R=l,t.charCodeAt(l)===58?(c=":",l++):(c=null,E('":"')),c!==null?(h=Qs(),h!==null?c=[c,h]:(c=null,l=R)):(c=null,l=R),c=c!==null?c:"",c!==null?(t.charCodeAt(l)===64?(h="@",l++):(h=null,E('"@"')),h!==null?s=[s,c,h]:(s=null,l=S)):(s=null,l=S)):(s=null,l=S),s!==null&&(s=function(I){T.user=decodeURIComponent(t.substring(l-1,I))}(g)),s===null&&(l=g),s}function ws(){var s,c;if(c=B(),c===null&&(c=V(),c===null&&(c=fs())),c!==null)for(s=[];c!==null;)s.push(c),c=B(),c===null&&(c=V(),c===null&&(c=fs()));else s=null;return s}function fs(){var s;return t.charCodeAt(l)===38?(s="&",l++):(s=null,E('"&"')),s===null&&(t.charCodeAt(l)===61?(s="=",l++):(s=null,E('"="')),s===null&&(t.charCodeAt(l)===43?(s="+",l++):(s=null,E('"+"')),s===null&&(t.charCodeAt(l)===36?(s="$",l++):(s=null,E('"$"')),s===null&&(t.charCodeAt(l)===44?(s=",",l++):(s=null,E('","')),s===null&&(t.charCodeAt(l)===59?(s=";",l++):(s=null,E('";"')),s===null&&(t.charCodeAt(l)===63?(s="?",l++):(s=null,E('"?"')),s===null&&(t.charCodeAt(l)===47?(s="/",l++):(s=null,E('"/"'))))))))),s}function Qs(){var s,c,h;for(h=l,s=[],c=B(),c===null&&(c=V(),c===null&&(t.charCodeAt(l)===38?(c="&",l++):(c=null,E('"&"')),c===null&&(t.charCodeAt(l)===61?(c="=",l++):(c=null,E('"="')),c===null&&(t.charCodeAt(l)===43?(c="+",l++):(c=null,E('"+"')),c===null&&(t.charCodeAt(l)===36?(c="$",l++):(c=null,E('"$"')),c===null&&(t.charCodeAt(l)===44?(c=",",l++):(c=null,E('","'))))))));c!==null;)s.push(c),c=B(),c===null&&(c=V(),c===null&&(t.charCodeAt(l)===38?(c="&",l++):(c=null,E('"&"')),c===null&&(t.charCodeAt(l)===61?(c="=",l++):(c=null,E('"="')),c===null&&(t.charCodeAt(l)===43?(c="+",l++):(c=null,E('"+"')),c===null&&(t.charCodeAt(l)===36?(c="$",l++):(c=null,E('"$"')),c===null&&(t.charCodeAt(l)===44?(c=",",l++):(c=null,E('","'))))))));return s!==null&&(s=function(g){T.password=t.substring(l,g)}(h)),s===null&&(l=h),s}function hs(){var s,c,h,g,S;return g=l,s=Se(),s!==null?(S=l,t.charCodeAt(l)===58?(c=":",l++):(c=null,E('":"')),c!==null?(h=rl(),h!==null?c=[c,h]:(c=null,l=S)):(c=null,l=S),c=c!==null?c:"",c!==null?s=[s,c]:(s=null,l=g)):(s=null,l=g),s}function Se(){var s,c;return c=l,s=dt(),s===null&&(s=Os(),s===null&&(s=vt())),s!==null&&(s=function(h){return T.host=t.substring(l,h).toLowerCase(),T.host}(c)),s===null&&(l=c),s}function dt(){var s,c,h,g,S,R;for(g=l,S=l,s=[],R=l,c=Zt(),c!==null?(t.charCodeAt(l)===46?(h=".",l++):(h=null,E('"."')),h!==null?c=[c,h]:(c=null,l=R)):(c=null,l=R);c!==null;)s.push(c),R=l,c=Zt(),c!==null?(t.charCodeAt(l)===46?(h=".",l++):(h=null,E('"."')),h!==null?c=[c,h]:(c=null,l=R)):(c=null,l=R);return s!==null?(c=Ae(),c!==null?(t.charCodeAt(l)===46?(h=".",l++):(h=null,E('"."')),h=h!==null?h:"",h!==null?s=[s,c,h]:(s=null,l=S)):(s=null,l=S)):(s=null,l=S),s!==null&&(s=function(I){return T.host_type="domain",t.substring(l,I)}(g)),s===null&&(l=g),s}function Zt(){var s,c,h,g;if(g=l,s=de(),s!==null){for(c=[],h=de(),h===null&&(t.charCodeAt(l)===45?(h="-",l++):(h=null,E('"-"')),h===null&&(t.charCodeAt(l)===95?(h="_",l++):(h=null,E('"_"'))));h!==null;)c.push(h),h=de(),h===null&&(t.charCodeAt(l)===45?(h="-",l++):(h=null,E('"-"')),h===null&&(t.charCodeAt(l)===95?(h="_",l++):(h=null,E('"_"'))));c!==null?s=[s,c]:(s=null,l=g)}else s=null,l=g;return s}function Ae(){var s,c,h,g;if(g=l,s=N(),s!==null){for(c=[],h=de(),h===null&&(t.charCodeAt(l)===45?(h="-",l++):(h=null,E('"-"')),h===null&&(t.charCodeAt(l)===95?(h="_",l++):(h=null,E('"_"'))));h!==null;)c.push(h),h=de(),h===null&&(t.charCodeAt(l)===45?(h="-",l++):(h=null,E('"-"')),h===null&&(t.charCodeAt(l)===95?(h="_",l++):(h=null,E('"_"'))));c!==null?s=[s,c]:(s=null,l=g)}else s=null,l=g;return s}function vt(){var s,c,h,g,S;return g=l,S=l,t.charCodeAt(l)===91?(s="[",l++):(s=null,E('"["')),s!==null?(c=_s(),c!==null?(t.charCodeAt(l)===93?(h="]",l++):(h=null,E('"]"')),h!==null?s=[s,c,h]:(s=null,l=S)):(s=null,l=S)):(s=null,l=S),s!==null&&(s=function(R){return T.host_type="IPv6",t.substring(l,R)}(g)),s===null&&(l=g),s}function _s(){var s,c,h,g,S,R,I,D,J,Ne,Ke,F,Ie,la,W,De;return la=l,W=l,s=Ee(),s!==null?(t.charCodeAt(l)===58?(c=":",l++):(c=null,E('":"')),c!==null?(h=Ee(),h!==null?(t.charCodeAt(l)===58?(g=":",l++):(g=null,E('":"')),g!==null?(S=Ee(),S!==null?(t.charCodeAt(l)===58?(R=":",l++):(R=null,E('":"')),R!==null?(I=Ee(),I!==null?(t.charCodeAt(l)===58?(D=":",l++):(D=null,E('":"')),D!==null?(J=Ee(),J!==null?(t.charCodeAt(l)===58?(Ne=":",l++):(Ne=null,E('":"')),Ne!==null?(Ke=Ee(),Ke!==null?(t.charCodeAt(l)===58?(F=":",l++):(F=null,E('":"')),F!==null?(Ie=Et(),Ie!==null?s=[s,c,h,g,S,R,I,D,J,Ne,Ke,F,Ie]:(s=null,l=W)):(s=null,l=W)):(s=null,l=W)):(s=null,l=W)):(s=null,l=W)):(s=null,l=W)):(s=null,l=W)):(s=null,l=W)):(s=null,l=W)):(s=null,l=W)):(s=null,l=W)):(s=null,l=W)):(s=null,l=W),s===null&&(W=l,t.substr(l,2)==="::"?(s="::",l+=2):(s=null,E('"::"')),s!==null?(c=Ee(),c!==null?(t.charCodeAt(l)===58?(h=":",l++):(h=null,E('":"')),h!==null?(g=Ee(),g!==null?(t.charCodeAt(l)===58?(S=":",l++):(S=null,E('":"')),S!==null?(R=Ee(),R!==null?(t.charCodeAt(l)===58?(I=":",l++):(I=null,E('":"')),I!==null?(D=Ee(),D!==null?(t.charCodeAt(l)===58?(J=":",l++):(J=null,E('":"')),J!==null?(Ne=Ee(),Ne!==null?(t.charCodeAt(l)===58?(Ke=":",l++):(Ke=null,E('":"')),Ke!==null?(F=Et(),F!==null?s=[s,c,h,g,S,R,I,D,J,Ne,Ke,F]:(s=null,l=W)):(s=null,l=W)):(s=null,l=W)):(s=null,l=W)):(s=null,l=W)):(s=null,l=W)):(s=null,l=W)):(s=null,l=W)):(s=null,l=W)):(s=null,l=W)):(s=null,l=W)):(s=null,l=W),s===null&&(W=l,t.substr(l,2)==="::"?(s="::",l+=2):(s=null,E('"::"')),s!==null?(c=Ee(),c!==null?(t.charCodeAt(l)===58?(h=":",l++):(h=null,E('":"')),h!==null?(g=Ee(),g!==null?(t.charCodeAt(l)===58?(S=":",l++):(S=null,E('":"')),S!==null?(R=Ee(),R!==null?(t.charCodeAt(l)===58?(I=":",l++):(I=null,E('":"')),I!==null?(D=Ee(),D!==null?(t.charCodeAt(l)===58?(J=":",l++):(J=null,E('":"')),J!==null?(Ne=Et(),Ne!==null?s=[s,c,h,g,S,R,I,D,J,Ne]:(s=null,l=W)):(s=null,l=W)):(s=null,l=W)):(s=null,l=W)):(s=null,l=W)):(s=null,l=W)):(s=null,l=W)):(s=null,l=W)):(s=null,l=W)):(s=null,l=W),s===null&&(W=l,t.substr(l,2)==="::"?(s="::",l+=2):(s=null,E('"::"')),s!==null?(c=Ee(),c!==null?(t.charCodeAt(l)===58?(h=":",l++):(h=null,E('":"')),h!==null?(g=Ee(),g!==null?(t.charCodeAt(l)===58?(S=":",l++):(S=null,E('":"')),S!==null?(R=Ee(),R!==null?(t.charCodeAt(l)===58?(I=":",l++):(I=null,E('":"')),I!==null?(D=Et(),D!==null?s=[s,c,h,g,S,R,I,D]:(s=null,l=W)):(s=null,l=W)):(s=null,l=W)):(s=null,l=W)):(s=null,l=W)):(s=null,l=W)):(s=null,l=W)):(s=null,l=W),s===null&&(W=l,t.substr(l,2)==="::"?(s="::",l+=2):(s=null,E('"::"')),s!==null?(c=Ee(),c!==null?(t.charCodeAt(l)===58?(h=":",l++):(h=null,E('":"')),h!==null?(g=Ee(),g!==null?(t.charCodeAt(l)===58?(S=":",l++):(S=null,E('":"')),S!==null?(R=Et(),R!==null?s=[s,c,h,g,S,R]:(s=null,l=W)):(s=null,l=W)):(s=null,l=W)):(s=null,l=W)):(s=null,l=W)):(s=null,l=W),s===null&&(W=l,t.substr(l,2)==="::"?(s="::",l+=2):(s=null,E('"::"')),s!==null?(c=Ee(),c!==null?(t.charCodeAt(l)===58?(h=":",l++):(h=null,E('":"')),h!==null?(g=Et(),g!==null?s=[s,c,h,g]:(s=null,l=W)):(s=null,l=W)):(s=null,l=W)):(s=null,l=W),s===null&&(W=l,t.substr(l,2)==="::"?(s="::",l+=2):(s=null,E('"::"')),s!==null?(c=Et(),c!==null?s=[s,c]:(s=null,l=W)):(s=null,l=W),s===null&&(W=l,t.substr(l,2)==="::"?(s="::",l+=2):(s=null,E('"::"')),s!==null?(c=Ee(),c!==null?s=[s,c]:(s=null,l=W)):(s=null,l=W),s===null&&(W=l,s=Ee(),s!==null?(t.substr(l,2)==="::"?(c="::",l+=2):(c=null,E('"::"')),c!==null?(h=Ee(),h!==null?(t.charCodeAt(l)===58?(g=":",l++):(g=null,E('":"')),g!==null?(S=Ee(),S!==null?(t.charCodeAt(l)===58?(R=":",l++):(R=null,E('":"')),R!==null?(I=Ee(),I!==null?(t.charCodeAt(l)===58?(D=":",l++):(D=null,E('":"')),D!==null?(J=Ee(),J!==null?(t.charCodeAt(l)===58?(Ne=":",l++):(Ne=null,E('":"')),Ne!==null?(Ke=Et(),Ke!==null?s=[s,c,h,g,S,R,I,D,J,Ne,Ke]:(s=null,l=W)):(s=null,l=W)):(s=null,l=W)):(s=null,l=W)):(s=null,l=W)):(s=null,l=W)):(s=null,l=W)):(s=null,l=W)):(s=null,l=W)):(s=null,l=W)):(s=null,l=W),s===null&&(W=l,s=Ee(),s!==null?(De=l,t.charCodeAt(l)===58?(c=":",l++):(c=null,E('":"')),c!==null?(h=Ee(),h!==null?c=[c,h]:(c=null,l=De)):(c=null,l=De),c=c!==null?c:"",c!==null?(t.substr(l,2)==="::"?(h="::",l+=2):(h=null,E('"::"')),h!==null?(g=Ee(),g!==null?(t.charCodeAt(l)===58?(S=":",l++):(S=null,E('":"')),S!==null?(R=Ee(),R!==null?(t.charCodeAt(l)===58?(I=":",l++):(I=null,E('":"')),I!==null?(D=Ee(),D!==null?(t.charCodeAt(l)===58?(J=":",l++):(J=null,E('":"')),J!==null?(Ne=Et(),Ne!==null?s=[s,c,h,g,S,R,I,D,J,Ne]:(s=null,l=W)):(s=null,l=W)):(s=null,l=W)):(s=null,l=W)):(s=null,l=W)):(s=null,l=W)):(s=null,l=W)):(s=null,l=W)):(s=null,l=W)):(s=null,l=W),s===null&&(W=l,s=Ee(),s!==null?(De=l,t.charCodeAt(l)===58?(c=":",l++):(c=null,E('":"')),c!==null?(h=Ee(),h!==null?c=[c,h]:(c=null,l=De)):(c=null,l=De),c=c!==null?c:"",c!==null?(De=l,t.charCodeAt(l)===58?(h=":",l++):(h=null,E('":"')),h!==null?(g=Ee(),g!==null?h=[h,g]:(h=null,l=De)):(h=null,l=De),h=h!==null?h:"",h!==null?(t.substr(l,2)==="::"?(g="::",l+=2):(g=null,E('"::"')),g!==null?(S=Ee(),S!==null?(t.charCodeAt(l)===58?(R=":",l++):(R=null,E('":"')),R!==null?(I=Ee(),I!==null?(t.charCodeAt(l)===58?(D=":",l++):(D=null,E('":"')),D!==null?(J=Et(),J!==null?s=[s,c,h,g,S,R,I,D,J]:(s=null,l=W)):(s=null,l=W)):(s=null,l=W)):(s=null,l=W)):(s=null,l=W)):(s=null,l=W)):(s=null,l=W)):(s=null,l=W)):(s=null,l=W),s===null&&(W=l,s=Ee(),s!==null?(De=l,t.charCodeAt(l)===58?(c=":",l++):(c=null,E('":"')),c!==null?(h=Ee(),h!==null?c=[c,h]:(c=null,l=De)):(c=null,l=De),c=c!==null?c:"",c!==null?(De=l,t.charCodeAt(l)===58?(h=":",l++):(h=null,E('":"')),h!==null?(g=Ee(),g!==null?h=[h,g]:(h=null,l=De)):(h=null,l=De),h=h!==null?h:"",h!==null?(De=l,t.charCodeAt(l)===58?(g=":",l++):(g=null,E('":"')),g!==null?(S=Ee(),S!==null?g=[g,S]:(g=null,l=De)):(g=null,l=De),g=g!==null?g:"",g!==null?(t.substr(l,2)==="::"?(S="::",l+=2):(S=null,E('"::"')),S!==null?(R=Ee(),R!==null?(t.charCodeAt(l)===58?(I=":",l++):(I=null,E('":"')),I!==null?(D=Et(),D!==null?s=[s,c,h,g,S,R,I,D]:(s=null,l=W)):(s=null,l=W)):(s=null,l=W)):(s=null,l=W)):(s=null,l=W)):(s=null,l=W)):(s=null,l=W)):(s=null,l=W),s===null&&(W=l,s=Ee(),s!==null?(De=l,t.charCodeAt(l)===58?(c=":",l++):(c=null,E('":"')),c!==null?(h=Ee(),h!==null?c=[c,h]:(c=null,l=De)):(c=null,l=De),c=c!==null?c:"",c!==null?(De=l,t.charCodeAt(l)===58?(h=":",l++):(h=null,E('":"')),h!==null?(g=Ee(),g!==null?h=[h,g]:(h=null,l=De)):(h=null,l=De),h=h!==null?h:"",h!==null?(De=l,t.charCodeAt(l)===58?(g=":",l++):(g=null,E('":"')),g!==null?(S=Ee(),S!==null?g=[g,S]:(g=null,l=De)):(g=null,l=De),g=g!==null?g:"",g!==null?(De=l,t.charCodeAt(l)===58?(S=":",l++):(S=null,E('":"')),S!==null?(R=Ee(),R!==null?S=[S,R]:(S=null,l=De)):(S=null,l=De),S=S!==null?S:"",S!==null?(t.substr(l,2)==="::"?(R="::",l+=2):(R=null,E('"::"')),R!==null?(I=Et(),I!==null?s=[s,c,h,g,S,R,I]:(s=null,l=W)):(s=null,l=W)):(s=null,l=W)):(s=null,l=W)):(s=null,l=W)):(s=null,l=W)):(s=null,l=W),s===null&&(W=l,s=Ee(),s!==null?(De=l,t.charCodeAt(l)===58?(c=":",l++):(c=null,E('":"')),c!==null?(h=Ee(),h!==null?c=[c,h]:(c=null,l=De)):(c=null,l=De),c=c!==null?c:"",c!==null?(De=l,t.charCodeAt(l)===58?(h=":",l++):(h=null,E('":"')),h!==null?(g=Ee(),g!==null?h=[h,g]:(h=null,l=De)):(h=null,l=De),h=h!==null?h:"",h!==null?(De=l,t.charCodeAt(l)===58?(g=":",l++):(g=null,E('":"')),g!==null?(S=Ee(),S!==null?g=[g,S]:(g=null,l=De)):(g=null,l=De),g=g!==null?g:"",g!==null?(De=l,t.charCodeAt(l)===58?(S=":",l++):(S=null,E('":"')),S!==null?(R=Ee(),R!==null?S=[S,R]:(S=null,l=De)):(S=null,l=De),S=S!==null?S:"",S!==null?(De=l,t.charCodeAt(l)===58?(R=":",l++):(R=null,E('":"')),R!==null?(I=Ee(),I!==null?R=[R,I]:(R=null,l=De)):(R=null,l=De),R=R!==null?R:"",R!==null?(t.substr(l,2)==="::"?(I="::",l+=2):(I=null,E('"::"')),I!==null?(D=Ee(),D!==null?s=[s,c,h,g,S,R,I,D]:(s=null,l=W)):(s=null,l=W)):(s=null,l=W)):(s=null,l=W)):(s=null,l=W)):(s=null,l=W)):(s=null,l=W)):(s=null,l=W),s===null&&(W=l,s=Ee(),s!==null?(De=l,t.charCodeAt(l)===58?(c=":",l++):(c=null,E('":"')),c!==null?(h=Ee(),h!==null?c=[c,h]:(c=null,l=De)):(c=null,l=De),c=c!==null?c:"",c!==null?(De=l,t.charCodeAt(l)===58?(h=":",l++):(h=null,E('":"')),h!==null?(g=Ee(),g!==null?h=[h,g]:(h=null,l=De)):(h=null,l=De),h=h!==null?h:"",h!==null?(De=l,t.charCodeAt(l)===58?(g=":",l++):(g=null,E('":"')),g!==null?(S=Ee(),S!==null?g=[g,S]:(g=null,l=De)):(g=null,l=De),g=g!==null?g:"",g!==null?(De=l,t.charCodeAt(l)===58?(S=":",l++):(S=null,E('":"')),S!==null?(R=Ee(),R!==null?S=[S,R]:(S=null,l=De)):(S=null,l=De),S=S!==null?S:"",S!==null?(De=l,t.charCodeAt(l)===58?(R=":",l++):(R=null,E('":"')),R!==null?(I=Ee(),I!==null?R=[R,I]:(R=null,l=De)):(R=null,l=De),R=R!==null?R:"",R!==null?(De=l,t.charCodeAt(l)===58?(I=":",l++):(I=null,E('":"')),I!==null?(D=Ee(),D!==null?I=[I,D]:(I=null,l=De)):(I=null,l=De),I=I!==null?I:"",I!==null?(t.substr(l,2)==="::"?(D="::",l+=2):(D=null,E('"::"')),D!==null?s=[s,c,h,g,S,R,I,D]:(s=null,l=W)):(s=null,l=W)):(s=null,l=W)):(s=null,l=W)):(s=null,l=W)):(s=null,l=W)):(s=null,l=W)):(s=null,l=W))))))))))))))),s!==null&&(s=function(YT){return T.host_type="IPv6",t.substring(l,YT)}(la)),s===null&&(l=la),s}function Ee(){var s,c,h,g,S;return S=l,s=U(),s!==null?(c=U(),c=c!==null?c:"",c!==null?(h=U(),h=h!==null?h:"",h!==null?(g=U(),g=g!==null?g:"",g!==null?s=[s,c,h,g]:(s=null,l=S)):(s=null,l=S)):(s=null,l=S)):(s=null,l=S),s}function Et(){var s,c,h,g;return g=l,s=Ee(),s!==null?(t.charCodeAt(l)===58?(c=":",l++):(c=null,E('":"')),c!==null?(h=Ee(),h!==null?s=[s,c,h]:(s=null,l=g)):(s=null,l=g)):(s=null,l=g),s===null&&(s=Os()),s}function Os(){var s,c,h,g,S,R,I,D,J;return D=l,J=l,s=ds(),s!==null?(t.charCodeAt(l)===46?(c=".",l++):(c=null,E('"."')),c!==null?(h=ds(),h!==null?(t.charCodeAt(l)===46?(g=".",l++):(g=null,E('"."')),g!==null?(S=ds(),S!==null?(t.charCodeAt(l)===46?(R=".",l++):(R=null,E('"."')),R!==null?(I=ds(),I!==null?s=[s,c,h,g,S,R,I]:(s=null,l=J)):(s=null,l=J)):(s=null,l=J)):(s=null,l=J)):(s=null,l=J)):(s=null,l=J)):(s=null,l=J),s!==null&&(s=function(Ne){return T.host_type="IPv4",t.substring(l,Ne)}(D)),s===null&&(l=D),s}function ds(){var s,c,h,g;return g=l,t.substr(l,2)==="25"?(s="25",l+=2):(s=null,E('"25"')),s!==null?(/^[0-5]/.test(t.charAt(l))?(c=t.charAt(l),l++):(c=null,E("[0-5]")),c!==null?s=[s,c]:(s=null,l=g)):(s=null,l=g),s===null&&(g=l,t.charCodeAt(l)===50?(s="2",l++):(s=null,E('"2"')),s!==null?(/^[0-4]/.test(t.charAt(l))?(c=t.charAt(l),l++):(c=null,E("[0-4]")),c!==null?(h=w(),h!==null?s=[s,c,h]:(s=null,l=g)):(s=null,l=g)):(s=null,l=g),s===null&&(g=l,t.charCodeAt(l)===49?(s="1",l++):(s=null,E('"1"')),s!==null?(c=w(),c!==null?(h=w(),h!==null?s=[s,c,h]:(s=null,l=g)):(s=null,l=g)):(s=null,l=g),s===null&&(g=l,/^[1-9]/.test(t.charAt(l))?(s=t.charAt(l),l++):(s=null,E("[1-9]")),s!==null?(c=w(),c!==null?s=[s,c]:(s=null,l=g)):(s=null,l=g),s===null&&(s=w())))),s}function rl(){var s,c,h,g,S,R,I;return R=l,I=l,s=w(),s=s!==null?s:"",s!==null?(c=w(),c=c!==null?c:"",c!==null?(h=w(),h=h!==null?h:"",h!==null?(g=w(),g=g!==null?g:"",g!==null?(S=w(),S=S!==null?S:"",S!==null?s=[s,c,h,g,S]:(s=null,l=I)):(s=null,l=I)):(s=null,l=I)):(s=null,l=I)):(s=null,l=I),s!==null&&(s=function(D,J){return J=parseInt(J.join("")),T.port=J,J}(R,s)),s===null&&(l=R),s}function il(){var s,c,h,g;for(s=[],g=l,t.charCodeAt(l)===59?(c=";",l++):(c=null,E('";"')),c!==null?(h=In(),h!==null?c=[c,h]:(c=null,l=g)):(c=null,l=g);c!==null;)s.push(c),g=l,t.charCodeAt(l)===59?(c=";",l++):(c=null,E('";"')),c!==null?(h=In(),h!==null?c=[c,h]:(c=null,l=g)):(c=null,l=g);return s}function In(){var s;return s=al(),s===null&&(s=ol(),s===null&&(s=ul(),s===null&&(s=Ds(),s===null&&(s=cl(),s===null&&(s=fl(),s===null&&(s=es())))))),s}function al(){var s,c,h,g;return h=l,g=l,t.substr(l,10).toLowerCase()==="transport="?(s=t.substr(l,10),l+=10):(s=null,E('"transport="')),s!==null?(t.substr(l,3).toLowerCase()==="udp"?(c=t.substr(l,3),l+=3):(c=null,E('"udp"')),c===null&&(t.substr(l,3).toLowerCase()==="tcp"?(c=t.substr(l,3),l+=3):(c=null,E('"tcp"')),c===null&&(t.substr(l,4).toLowerCase()==="sctp"?(c=t.substr(l,4),l+=4):(c=null,E('"sctp"')),c===null&&(t.substr(l,3).toLowerCase()==="tls"?(c=t.substr(l,3),l+=3):(c=null,E('"tls"')),c===null&&(c=P())))),c!==null?s=[s,c]:(s=null,l=g)):(s=null,l=g),s!==null&&(s=function(S,R){T.uri_params||(T.uri_params={}),T.uri_params.transport=R.toLowerCase()}(h,s[1])),s===null&&(l=h),s}function ol(){var s,c,h,g;return h=l,g=l,t.substr(l,5).toLowerCase()==="user="?(s=t.substr(l,5),l+=5):(s=null,E('"user="')),s!==null?(t.substr(l,5).toLowerCase()==="phone"?(c=t.substr(l,5),l+=5):(c=null,E('"phone"')),c===null&&(t.substr(l,2).toLowerCase()==="ip"?(c=t.substr(l,2),l+=2):(c=null,E('"ip"')),c===null&&(c=P())),c!==null?s=[s,c]:(s=null,l=g)):(s=null,l=g),s!==null&&(s=function(S,R){T.uri_params||(T.uri_params={}),T.uri_params.user=R.toLowerCase()}(h,s[1])),s===null&&(l=h),s}function ul(){var s,c,h,g;return h=l,g=l,t.substr(l,7).toLowerCase()==="method="?(s=t.substr(l,7),l+=7):(s=null,E('"method="')),s!==null?(c=Un(),c!==null?s=[s,c]:(s=null,l=g)):(s=null,l=g),s!==null&&(s=function(S,R){T.uri_params||(T.uri_params={}),T.uri_params.method=R}(h,s[1])),s===null&&(l=h),s}function Ds(){var s,c,h,g;return h=l,g=l,t.substr(l,4).toLowerCase()==="ttl="?(s=t.substr(l,4),l+=4):(s=null,E('"ttl="')),s!==null?(c=Wl(),c!==null?s=[s,c]:(s=null,l=g)):(s=null,l=g),s!==null&&(s=function(S,R){T.params||(T.params={}),T.params.ttl=R}(h,s[1])),s===null&&(l=h),s}function cl(){var s,c,h,g;return h=l,g=l,t.substr(l,6).toLowerCase()==="maddr="?(s=t.substr(l,6),l+=6):(s=null,E('"maddr="')),s!==null?(c=Se(),c!==null?s=[s,c]:(s=null,l=g)):(s=null,l=g),s!==null&&(s=function(S,R){T.uri_params||(T.uri_params={}),T.uri_params.maddr=R}(h,s[1])),s===null&&(l=h),s}function fl(){var s,c,h,g,S,R;return g=l,S=l,t.substr(l,2).toLowerCase()==="lr"?(s=t.substr(l,2),l+=2):(s=null,E('"lr"')),s!==null?(R=l,t.charCodeAt(l)===61?(c="=",l++):(c=null,E('"="')),c!==null?(h=P(),h!==null?c=[c,h]:(c=null,l=R)):(c=null,l=R),c=c!==null?c:"",c!==null?s=[s,c]:(s=null,l=S)):(s=null,l=S),s!==null&&(s=function(I){T.uri_params||(T.uri_params={}),T.uri_params.lr=void 0}()),s===null&&(l=g),s}function es(){var s,c,h,g,S,R;return g=l,S=l,s=hl(),s!==null?(R=l,t.charCodeAt(l)===61?(c="=",l++):(c=null,E('"="')),c!==null?(h=_l(),h!==null?c=[c,h]:(c=null,l=R)):(c=null,l=R),c=c!==null?c:"",c!==null?s=[s,c]:(s=null,l=S)):(s=null,l=S),s!==null&&(s=function(I,D,J){T.uri_params||(T.uri_params={}),typeof J>"u"?J=void 0:J=J[1],T.uri_params[D.toLowerCase()]=J}(g,s[0],s[1])),s===null&&(l=g),s}function hl(){var s,c,h;if(h=l,c=Ft(),c!==null)for(s=[];c!==null;)s.push(c),c=Ft();else s=null;return s!==null&&(s=function(g,S){return S.join("")}(h,s)),s===null&&(l=h),s}function _l(){var s,c,h;if(h=l,c=Ft(),c!==null)for(s=[];c!==null;)s.push(c),c=Ft();else s=null;return s!==null&&(s=function(g,S){return S.join("")}(h,s)),s===null&&(l=h),s}function Ft(){var s;return s=dr(),s===null&&(s=B(),s===null&&(s=V())),s}function dr(){var s;return t.charCodeAt(l)===91?(s="[",l++):(s=null,E('"["')),s===null&&(t.charCodeAt(l)===93?(s="]",l++):(s=null,E('"]"')),s===null&&(t.charCodeAt(l)===47?(s="/",l++):(s=null,E('"/"')),s===null&&(t.charCodeAt(l)===58?(s=":",l++):(s=null,E('":"')),s===null&&(t.charCodeAt(l)===38?(s="&",l++):(s=null,E('"&"')),s===null&&(t.charCodeAt(l)===43?(s="+",l++):(s=null,E('"+"')),s===null&&(t.charCodeAt(l)===36?(s="$",l++):(s=null,E('"$"')))))))),s}function dl(){var s,c,h,g,S,R,I;if(R=l,t.charCodeAt(l)===63?(s="?",l++):(s=null,E('"?"')),s!==null)if(c=ts(),c!==null){for(h=[],I=l,t.charCodeAt(l)===38?(g="&",l++):(g=null,E('"&"')),g!==null?(S=ts(),S!==null?g=[g,S]:(g=null,l=I)):(g=null,l=I);g!==null;)h.push(g),I=l,t.charCodeAt(l)===38?(g="&",l++):(g=null,E('"&"')),g!==null?(S=ts(),S!==null?g=[g,S]:(g=null,l=I)):(g=null,l=I);h!==null?s=[s,c,h]:(s=null,l=R)}else s=null,l=R;else s=null,l=R;return s}function ts(){var s,c,h,g,S;return g=l,S=l,s=pl(),s!==null?(t.charCodeAt(l)===61?(c="=",l++):(c=null,E('"="')),c!==null?(h=ml(),h!==null?s=[s,c,h]:(s=null,l=S)):(s=null,l=S)):(s=null,l=S),s!==null&&(s=function(R,I,D){I=I.join("").toLowerCase(),D=D.join(""),T.uri_headers||(T.uri_headers={}),T.uri_headers[I]?T.uri_headers[I].push(D):T.uri_headers[I]=[D]}(g,s[0],s[2])),s===null&&(l=g),s}function pl(){var s,c;if(c=Ns(),c===null&&(c=B(),c===null&&(c=V())),c!==null)for(s=[];c!==null;)s.push(c),c=Ns(),c===null&&(c=B(),c===null&&(c=V()));else s=null;return s}function ml(){var s,c;for(s=[],c=Ns(),c===null&&(c=B(),c===null&&(c=V()));c!==null;)s.push(c),c=Ns(),c===null&&(c=B(),c===null&&(c=V()));return s}function Ns(){var s;return t.charCodeAt(l)===91?(s="[",l++):(s=null,E('"["')),s===null&&(t.charCodeAt(l)===93?(s="]",l++):(s=null,E('"]"')),s===null&&(t.charCodeAt(l)===47?(s="/",l++):(s=null,E('"/"')),s===null&&(t.charCodeAt(l)===63?(s="?",l++):(s=null,E('"?"')),s===null&&(t.charCodeAt(l)===58?(s=":",l++):(s=null,E('":"')),s===null&&(t.charCodeAt(l)===43?(s="+",l++):(s=null,E('"+"')),s===null&&(t.charCodeAt(l)===36?(s="$",l++):(s=null,E('"$"')))))))),s}function Zs(){var s;return s=mr(),console.log("result0",s),s===null&&(s=gl(),console.log("result0 2",s)),s}function gl(){var s,c,h,g,S,R;return R=l,s=Un(),s!==null?(c=k(),console.log("parse_SP",c),c!==null?(h=Us(),console.log("parse_Request_URI",h),h!==null?(g=k(),console.log("parse_SP 2",g),g!==null?(S=Nn(),S!==null?s=[s,c,h,g,S]:(s=null,l=R)):(s=null,l=R)):(s=null,l=R)):(s=null,l=R)):(s=null,l=R),s}function Us(){var s;return s=Ht(),s===null&&(s=xs()),s}function xs(){var s,c,h,g;return g=l,s=Tl(),s!==null?(t.charCodeAt(l)===58?(c=":",l++):(c=null,E('":"')),c!==null?(h=vl(),h===null&&(h=Ms()),h!==null?s=[s,c,h]:(s=null,l=g)):(s=null,l=g)):(s=null,l=g),s}function vl(){var s,c,h,g,S;return g=l,s=ss(),s===null&&(s=Ps()),s!==null?(S=l,t.charCodeAt(l)===63?(c="?",l++):(c=null,E('"?"')),c!==null?(h=Sl(),h!==null?c=[c,h]:(c=null,l=S)):(c=null,l=S),c=c!==null?c:"",c!==null?s=[s,c]:(s=null,l=g)):(s=null,l=g),s}function ss(){var s,c,h,g;return g=l,t.substr(l,2)==="//"?(s="//",l+=2):(s=null,E('"//"')),s!==null?(c=El(),c!==null?(h=Ps(),h=h!==null?h:"",h!==null?s=[s,c,h]:(s=null,l=g)):(s=null,l=g)):(s=null,l=g),s}function Ps(){var s,c,h;return h=l,t.charCodeAt(l)===47?(s="/",l++):(s=null,E('"/"')),s!==null?(c=ks(),c!==null?s=[s,c]:(s=null,l=h)):(s=null,l=h),s}function Ms(){var s,c,h,g;if(g=l,s=wn(),s!==null){for(c=[],h=ns();h!==null;)c.push(h),h=ns();c!==null?s=[s,c]:(s=null,l=g)}else s=null,l=g;return s}function ns(){var s;return s=Ue(),s===null&&(s=B(),s===null&&(s=V())),s}function wn(){var s;return s=B(),s===null&&(s=V(),s===null&&(t.charCodeAt(l)===59?(s=";",l++):(s=null,E('";"')),s===null&&(t.charCodeAt(l)===63?(s="?",l++):(s=null,E('"?"')),s===null&&(t.charCodeAt(l)===58?(s=":",l++):(s=null,E('":"')),s===null&&(t.charCodeAt(l)===64?(s="@",l++):(s=null,E('"@"')),s===null&&(t.charCodeAt(l)===38?(s="&",l++):(s=null,E('"&"')),s===null&&(t.charCodeAt(l)===61?(s="=",l++):(s=null,E('"="')),s===null&&(t.charCodeAt(l)===43?(s="+",l++):(s=null,E('"+"')),s===null&&(t.charCodeAt(l)===36?(s="$",l++):(s=null,E('"$"')),s===null&&(t.charCodeAt(l)===44?(s=",",l++):(s=null,E('","')))))))))))),s}function ks(){var s,c,h,g,S,R;if(S=l,s=en(),s!==null){for(c=[],R=l,t.charCodeAt(l)===47?(h="/",l++):(h=null,E('"/"')),h!==null?(g=en(),g!==null?h=[h,g]:(h=null,l=R)):(h=null,l=R);h!==null;)c.push(h),R=l,t.charCodeAt(l)===47?(h="/",l++):(h=null,E('"/"')),h!==null?(g=en(),g!==null?h=[h,g]:(h=null,l=R)):(h=null,l=R);c!==null?s=[s,c]:(s=null,l=S)}else s=null,l=S;return s}function en(){var s,c,h,g,S,R;for(S=l,s=[],c=ps();c!==null;)s.push(c),c=ps();if(s!==null){for(c=[],R=l,t.charCodeAt(l)===59?(h=";",l++):(h=null,E('";"')),h!==null?(g=On(),g!==null?h=[h,g]:(h=null,l=R)):(h=null,l=R);h!==null;)c.push(h),R=l,t.charCodeAt(l)===59?(h=";",l++):(h=null,E('";"')),h!==null?(g=On(),g!==null?h=[h,g]:(h=null,l=R)):(h=null,l=R);c!==null?s=[s,c]:(s=null,l=S)}else s=null,l=S;return s}function On(){var s,c;for(s=[],c=ps();c!==null;)s.push(c),c=ps();return s}function ps(){var s;return s=B(),s===null&&(s=V(),s===null&&(t.charCodeAt(l)===58?(s=":",l++):(s=null,E('":"')),s===null&&(t.charCodeAt(l)===64?(s="@",l++):(s=null,E('"@"')),s===null&&(t.charCodeAt(l)===38?(s="&",l++):(s=null,E('"&"')),s===null&&(t.charCodeAt(l)===61?(s="=",l++):(s=null,E('"="')),s===null&&(t.charCodeAt(l)===43?(s="+",l++):(s=null,E('"+"')),s===null&&(t.charCodeAt(l)===36?(s="$",l++):(s=null,E('"$"')),s===null&&(t.charCodeAt(l)===44?(s=",",l++):(s=null,E('","')))))))))),s}function Tl(){var s,c,h,g,S;if(g=l,S=l,s=N(),s!==null){for(c=[],h=N(),h===null&&(h=w(),h===null&&(t.charCodeAt(l)===43?(h="+",l++):(h=null,E('"+"')),h===null&&(t.charCodeAt(l)===45?(h="-",l++):(h=null,E('"-"')),h===null&&(t.charCodeAt(l)===46?(h=".",l++):(h=null,E('"."'))))));h!==null;)c.push(h),h=N(),h===null&&(h=w(),h===null&&(t.charCodeAt(l)===43?(h="+",l++):(h=null,E('"+"')),h===null&&(t.charCodeAt(l)===45?(h="-",l++):(h=null,E('"-"')),h===null&&(t.charCodeAt(l)===46?(h=".",l++):(h=null,E('"."'))))));c!==null?s=[s,c]:(s=null,l=S)}else s=null,l=S;return s!==null&&(s=function(R){T.scheme=t.substring(l,R)}(g)),s===null&&(l=g),s}function El(){var s;return s=Dn(),s===null&&(s=Cl()),s}function Dn(){var s,c,h,g;return h=l,g=l,s=Is(),s!==null?(t.charCodeAt(l)===64?(c="@",l++):(c=null,E('"@"')),c!==null?s=[s,c]:(s=null,l=g)):(s=null,l=g),s=s!==null?s:"",s!==null?(c=hs(),c!==null?s=[s,c]:(s=null,l=h)):(s=null,l=h),s=s!==null?s:"",s}function Cl(){var s,c;if(c=B(),c===null&&(c=V(),c===null&&(t.charCodeAt(l)===36?(c="$",l++):(c=null,E('"$"')),c===null&&(t.charCodeAt(l)===44?(c=",",l++):(c=null,E('","')),c===null&&(t.charCodeAt(l)===59?(c=";",l++):(c=null,E('";"')),c===null&&(t.charCodeAt(l)===58?(c=":",l++):(c=null,E('":"')),c===null&&(t.charCodeAt(l)===64?(c="@",l++):(c=null,E('"@"')),c===null&&(t.charCodeAt(l)===38?(c="&",l++):(c=null,E('"&"')),c===null&&(t.charCodeAt(l)===61?(c="=",l++):(c=null,E('"="')),c===null&&(t.charCodeAt(l)===43?(c="+",l++):(c=null,E('"+"'))))))))))),c!==null)for(s=[];c!==null;)s.push(c),c=B(),c===null&&(c=V(),c===null&&(t.charCodeAt(l)===36?(c="$",l++):(c=null,E('"$"')),c===null&&(t.charCodeAt(l)===44?(c=",",l++):(c=null,E('","')),c===null&&(t.charCodeAt(l)===59?(c=";",l++):(c=null,E('";"')),c===null&&(t.charCodeAt(l)===58?(c=":",l++):(c=null,E('":"')),c===null&&(t.charCodeAt(l)===64?(c="@",l++):(c=null,E('"@"')),c===null&&(t.charCodeAt(l)===38?(c="&",l++):(c=null,E('"&"')),c===null&&(t.charCodeAt(l)===61?(c="=",l++):(c=null,E('"="')),c===null&&(t.charCodeAt(l)===43?(c="+",l++):(c=null,E('"+"')))))))))));else s=null;return s}function Sl(){var s,c;for(s=[],c=ns();c!==null;)s.push(c),c=ns();return s}function Nn(){var s,c,h,g,S,R,I,D;if(I=l,D=l,t.substr(l,3).toLowerCase()==="sip"?(s=t.substr(l,3),l+=3):(s=null,E('"SIP"')),s!==null)if(t.charCodeAt(l)===47?(c="/",l++):(c=null,E('"/"')),c!==null){if(g=w(),g!==null)for(h=[];g!==null;)h.push(g),g=w();else h=null;if(h!==null)if(t.charCodeAt(l)===46?(g=".",l++):(g=null,E('"."')),g!==null){if(R=w(),R!==null)for(S=[];R!==null;)S.push(R),R=w();else S=null;S!==null?s=[s,c,h,g,S]:(s=null,l=D)}else s=null,l=D;else s=null,l=D}else s=null,l=D;else s=null,l=D;return s!==null&&(s=function(J){T.sip_version=t.substring(l,J)}(I)),s===null&&(l=I),s}function Al(){var s;return t.substr(l,6)==="INVITE"?(s="INVITE",l+=6):(s=null,E('"INVITE"')),s}function yl(){var s;return t.substr(l,3)==="ACK"?(s="ACK",l+=3):(s=null,E('"ACK"')),s}function Rl(){var s;return t.substr(l,7)==="OPTIONS"?(s="OPTIONS",l+=7):(s=null,E('"OPTIONS"')),s}function tn(){var s;return t.substr(l,3)==="BYE"?(s="BYE",l+=3):(s=null,E('"BYE"')),s}function bl(){var s;return t.substr(l,6)==="CANCEL"?(s="CANCEL",l+=6):(s=null,E('"CANCEL"')),s}function Il(){var s;return t.substr(l,8)==="REGISTER"?(s="REGISTER",l+=8):(s=null,E('"REGISTER"')),s}function sn(){var s;return t.substr(l,9)==="SUBSCRIBE"?(s="SUBSCRIBE",l+=9):(s=null,E('"SUBSCRIBE"')),s}function wl(){var s;return t.substr(l,6)==="NOTIFY"?(s="NOTIFY",l+=6):(s=null,E('"NOTIFY"')),s}function pr(){var s;return t.substr(l,5)==="REFER"?(s="REFER",l+=5):(s=null,E('"REFER"')),s}function Un(){var s,c;return c=l,s=Al(),s===null&&(s=yl(),s===null&&(s=Rl(),s===null&&(s=tn(),s===null&&(s=bl(),s===null&&(s=Il(),s===null&&(s=sn(),s===null&&(s=wl(),s===null&&(s=pr(),s===null&&(s=P()))))))))),s!==null&&(s=function(h){return T.method=t.substring(l,h),T.method}(c)),s===null&&(l=c),s}function mr(){var s,c,h,g,S,R;return R=l,s=Nn(),s!==null?(c=k(),c!==null?(h=xn(),h!==null?(g=k(),g!==null?(S=Pn(),S!==null?s=[s,c,h,g,S]:(s=null,l=R)):(s=null,l=R)):(s=null,l=R)):(s=null,l=R)):(s=null,l=R),s}function xn(){var s,c;return c=l,s=ms(),s!==null&&(s=function(h,g){T.status_code=parseInt(g.join(""))}(c,s)),s===null&&(l=c),s}function ms(){var s,c,h,g;return g=l,s=w(),s!==null?(c=w(),c!==null?(h=w(),h!==null?s=[s,c,h]:(s=null,l=g)):(s=null,l=g)):(s=null,l=g),s}function Pn(){var s,c,h;for(h=l,s=[],c=Ue(),c===null&&(c=B(),c===null&&(c=V(),c===null&&(c=$(),c===null&&(c=ne(),c===null&&(c=k(),c===null&&(c=H()))))));c!==null;)s.push(c),c=Ue(),c===null&&(c=B(),c===null&&(c=V(),c===null&&(c=$(),c===null&&(c=ne(),c===null&&(c=k(),c===null&&(c=H()))))));return s!==null&&(s=function(g){T.reason_phrase=t.substring(l,g)}(h)),s===null&&(l=h),s}function nn(){var s,c,h,g,S,R;if(S=l,s=Hs(),s!==null){for(c=[],R=l,h=$e(),h!==null?(g=Hs(),g!==null?h=[h,g]:(h=null,l=R)):(h=null,l=R);h!==null;)c.push(h),R=l,h=$e(),h!==null?(g=Hs(),g!==null?h=[h,g]:(h=null,l=R)):(h=null,l=R);c!==null?s=[s,c]:(s=null,l=S)}else s=null,l=S;return s}function gs(){var s,c,h,g,S,R;return g=l,S=l,s=he(),s!==null?(R=l,t.charCodeAt(l)===64?(c="@",l++):(c=null,E('"@"')),c!==null?(h=he(),h!==null?c=[c,h]:(c=null,l=R)):(c=null,l=R),c=c!==null?c:"",c!==null?s=[s,c]:(s=null,l=S)):(s=null,l=S),s!==null&&(s=function(I){T=t.substring(l,I)}(g)),s===null&&(l=g),s}function Mn(){var s,c,h,g,S,R,I;if(S=l,s=Re(),s===null)if(R=l,s=qt(),s!==null){for(c=[],I=l,h=$e(),h!==null?(g=qt(),g!==null?h=[h,g]:(h=null,l=I)):(h=null,l=I);h!==null;)c.push(h),I=l,h=$e(),h!==null?(g=qt(),g!==null?h=[h,g]:(h=null,l=I)):(h=null,l=I);c!==null?s=[s,c]:(s=null,l=R)}else s=null,l=R;return s!==null&&(s=function(D){var J,Ne;for(Ne=T.multi_header.length,J=0;J<Ne;J++)if(T.multi_header[J].parsed===null){T=null;break}T!==null?T=T.multi_header:T=-1}()),s===null&&(l=S),s}function qt(){var s,c,h,g,S,R,I;if(S=l,R=l,s=Ve(),s===null&&(s=ls()),s!==null){for(c=[],I=l,h=ue(),h!==null?(g=Yt(),g!==null?h=[h,g]:(h=null,l=I)):(h=null,l=I);h!==null;)c.push(h),I=l,h=ue(),h!==null?(g=Yt(),g!==null?h=[h,g]:(h=null,l=I)):(h=null,l=I);c!==null?s=[s,c]:(s=null,l=R)}else s=null,l=R;return s!==null&&(s=function(D){var J;T.multi_header||(T.multi_header=[]);try{J=new m(T.uri,T.display_name,T.params),delete T.uri,delete T.display_name,delete T.params}catch{J=null}T.multi_header.push({possition:l,offset:D,parsed:J})}(S)),s===null&&(l=S),s}function ls(){var s,c,h,g,S;return S=l,s=ze(),s=s!==null?s:"",s!==null?(c=rt(),c!==null?(h=Ht(),h!==null?(g=we(),g!==null?s=[s,c,h,g]:(s=null,l=S)):(s=null,l=S)):(s=null,l=S)):(s=null,l=S),s}function ze(){var s,c,h,g,S,R,I;if(S=l,R=l,s=P(),s!==null){for(c=[],I=l,h=G(),h!==null?(g=P(),g!==null?h=[h,g]:(h=null,l=I)):(h=null,l=I);h!==null;)c.push(h),I=l,h=G(),h!==null?(g=P(),g!==null?h=[h,g]:(h=null,l=I)):(h=null,l=I);c!==null?s=[s,c]:(s=null,l=R)}else s=null,l=R;return s===null&&(s=ke()),s!==null&&(s=function(D,J){typeof J=="string"?T.display_name=J:T.display_name=J[1].reduce(function(Ne,Ke){return Ne+Ke[0]+Ke[1]},J[0])}(S,s)),s===null&&(l=S),s}function Yt(){var s;return s=gr(),s===null&&(s=Ze(),s===null&&(s=st())),s}function gr(){var s,c,h,g,S;return g=l,S=l,t.substr(l,1).toLowerCase()==="q"?(s=t.substr(l,1),l++):(s=null,E('"q"')),s!==null?(c=fe(),c!==null?(h=vr(),h!==null?s=[s,c,h]:(s=null,l=S)):(s=null,l=S)):(s=null,l=S),s!==null&&(s=function(R,I){T.params||(T.params={}),T.params.q=I}(g,s[2])),s===null&&(l=g),s}function Ze(){var s,c,h,g,S;return g=l,S=l,t.substr(l,7).toLowerCase()==="expires"?(s=t.substr(l,7),l+=7):(s=null,E('"expires"')),s!==null?(c=fe(),c!==null?(h=zt(),h!==null?s=[s,c,h]:(s=null,l=S)):(s=null,l=S)):(s=null,l=S),s!==null&&(s=function(R,I){T.params||(T.params={}),T.params.expires=I}(g,s[2])),s===null&&(l=g),s}function zt(){var s,c,h;if(h=l,c=w(),c!==null)for(s=[];c!==null;)s.push(c),c=w();else s=null;return s!==null&&(s=function(g,S){return parseInt(S.join(""))}(h,s)),s===null&&(l=h),s}function vr(){var s,c,h,g,S,R,I,D;return R=l,I=l,t.charCodeAt(l)===48?(s="0",l++):(s=null,E('"0"')),s!==null?(D=l,t.charCodeAt(l)===46?(c=".",l++):(c=null,E('"."')),c!==null?(h=w(),h=h!==null?h:"",h!==null?(g=w(),g=g!==null?g:"",g!==null?(S=w(),S=S!==null?S:"",S!==null?c=[c,h,g,S]:(c=null,l=D)):(c=null,l=D)):(c=null,l=D)):(c=null,l=D),c=c!==null?c:"",c!==null?s=[s,c]:(s=null,l=I)):(s=null,l=I),s!==null&&(s=function(J){return parseFloat(t.substring(l,J))}(R)),s===null&&(l=R),s}function st(){var s,c,h,g,S,R;return g=l,S=l,s=P(),s!==null?(R=l,c=fe(),c!==null?(h=Ol(),h!==null?c=[c,h]:(c=null,l=R)):(c=null,l=R),c=c!==null?c:"",c!==null?s=[s,c]:(s=null,l=S)):(s=null,l=S),s!==null&&(s=function(I,D,J){T.params||(T.params={}),typeof J>"u"?J=void 0:J=J[1],T.params[D.toLowerCase()]=J}(g,s[0],s[1])),s===null&&(l=g),s}function Ol(){var s;return s=P(),s===null&&(s=Se(),s===null&&(s=Ce())),s}function ei(){var s,c,h,g,S,R;if(S=l,s=Tr(),s!==null){for(c=[],R=l,h=ue(),h!==null?(g=Dl(),g!==null?h=[h,g]:(h=null,l=R)):(h=null,l=R);h!==null;)c.push(h),R=l,h=ue(),h!==null?(g=Dl(),g!==null?h=[h,g]:(h=null,l=R)):(h=null,l=R);c!==null?s=[s,c]:(s=null,l=S)}else s=null,l=S;return s}function Tr(){var s;return t.substr(l,6).toLowerCase()==="render"?(s=t.substr(l,6),l+=6):(s=null,E('"render"')),s===null&&(t.substr(l,7).toLowerCase()==="session"?(s=t.substr(l,7),l+=7):(s=null,E('"session"')),s===null&&(t.substr(l,4).toLowerCase()==="icon"?(s=t.substr(l,4),l+=4):(s=null,E('"icon"')),s===null&&(t.substr(l,5).toLowerCase()==="alert"?(s=t.substr(l,5),l+=5):(s=null,E('"alert"')),s===null&&(s=P())))),s}function Dl(){var s;return s=Er(),s===null&&(s=st()),s}function Er(){var s,c,h,g;return g=l,t.substr(l,8).toLowerCase()==="handling"?(s=t.substr(l,8),l+=8):(s=null,E('"handling"')),s!==null?(c=fe(),c!==null?(t.substr(l,8).toLowerCase()==="optional"?(h=t.substr(l,8),l+=8):(h=null,E('"optional"')),h===null&&(t.substr(l,8).toLowerCase()==="required"?(h=t.substr(l,8),l+=8):(h=null,E('"required"')),h===null&&(h=P())),h!==null?s=[s,c,h]:(s=null,l=g)):(s=null,l=g)):(s=null,l=g),s}function Cr(){var s,c,h,g,S,R;if(S=l,s=P(),s!==null){for(c=[],R=l,h=$e(),h!==null?(g=P(),g!==null?h=[h,g]:(h=null,l=R)):(h=null,l=R);h!==null;)c.push(h),R=l,h=$e(),h!==null?(g=P(),g!==null?h=[h,g]:(h=null,l=R)):(h=null,l=R);c!==null?s=[s,c]:(s=null,l=S)}else s=null,l=S;return s}function kn(){var s,c,h;if(h=l,c=w(),c!==null)for(s=[];c!==null;)s.push(c),c=w();else s=null;return s!==null&&(s=function(g,S){T=parseInt(S.join(""))}(h,s)),s===null&&(l=h),s}function Sr(){var s,c;return c=l,s=Nl(),s!==null&&(s=function(h){T=t.substring(l,h)}(c)),s===null&&(l=c),s}function Nl(){var s,c,h,g,S,R,I,D;if(I=l,s=Ls(),s!==null)if(c=be(),c!==null)if(h=ti(),h!==null){for(g=[],D=l,S=ue(),S!==null?(R=vs(),R!==null?S=[S,R]:(S=null,l=D)):(S=null,l=D);S!==null;)g.push(S),D=l,S=ue(),S!==null?(R=vs(),R!==null?S=[S,R]:(S=null,l=D)):(S=null,l=D);g!==null?s=[s,c,h,g]:(s=null,l=I)}else s=null,l=I;else s=null,l=I;else s=null,l=I;return s}function Ls(){var s;return s=Ul(),s===null&&(s=Ar()),s}function Ul(){var s;return t.substr(l,4).toLowerCase()==="text"?(s=t.substr(l,4),l+=4):(s=null,E('"text"')),s===null&&(t.substr(l,5).toLowerCase()==="image"?(s=t.substr(l,5),l+=5):(s=null,E('"image"')),s===null&&(t.substr(l,5).toLowerCase()==="audio"?(s=t.substr(l,5),l+=5):(s=null,E('"audio"')),s===null&&(t.substr(l,5).toLowerCase()==="video"?(s=t.substr(l,5),l+=5):(s=null,E('"video"')),s===null&&(t.substr(l,11).toLowerCase()==="application"?(s=t.substr(l,11),l+=11):(s=null,E('"application"')),s===null&&(s=$s()))))),s}function Ar(){var s;return t.substr(l,7).toLowerCase()==="message"?(s=t.substr(l,7),l+=7):(s=null,E('"message"')),s===null&&(t.substr(l,9).toLowerCase()==="multipart"?(s=t.substr(l,9),l+=9):(s=null,E('"multipart"')),s===null&&(s=$s())),s}function $s(){var s;return s=P(),s===null&&(s=yr()),s}function yr(){var s,c,h;return h=l,t.substr(l,2).toLowerCase()==="x-"?(s=t.substr(l,2),l+=2):(s=null,E('"x-"')),s!==null?(c=P(),c!==null?s=[s,c]:(s=null,l=h)):(s=null,l=h),s}function ti(){var s;return s=$s(),s===null&&(s=P()),s}function vs(){var s,c,h,g;return g=l,s=P(),s!==null?(c=fe(),c!==null?(h=si(),h!==null?s=[s,c,h]:(s=null,l=g)):(s=null,l=g)):(s=null,l=g),s}function si(){var s;return s=P(),s===null&&(s=Ce()),s}function Rr(){var s,c,h,g;return g=l,s=Ts(),s!==null?(c=G(),c!==null?(h=Un(),h!==null?s=[s,c,h]:(s=null,l=g)):(s=null,l=g)):(s=null,l=g),s}function Ts(){var s,c,h;if(h=l,c=w(),c!==null)for(s=[];c!==null;)s.push(c),c=w();else s=null;return s!==null&&(s=function(g,S){T.value=parseInt(S.join(""))}(h,s)),s===null&&(l=h),s}function ea(){var s,c;return c=l,s=zt(),s!==null&&(s=function(h,g){T=g}(c,s)),s===null&&(l=c),s}function br(){var s,c,h,g,S,R,I;if(S=l,R=l,s=Hs(),s!==null){for(c=[],I=l,h=ue(),h!==null?(g=st(),g!==null?h=[h,g]:(h=null,l=I)):(h=null,l=I);h!==null;)c.push(h),I=l,h=ue(),h!==null?(g=st(),g!==null?h=[h,g]:(h=null,l=I)):(h=null,l=I);c!==null?s=[s,c]:(s=null,l=R)}else s=null,l=R;return s!==null&&(s=function(D,J){T.event=J.join("").toLowerCase()}(S,s[0])),s===null&&(l=S),s}function Hs(){var s,c,h,g,S,R;if(S=l,s=Q(),s!==null){for(c=[],R=l,t.charCodeAt(l)===46?(h=".",l++):(h=null,E('"."')),h!==null?(g=Q(),g!==null?h=[h,g]:(h=null,l=R)):(h=null,l=R);h!==null;)c.push(h),R=l,t.charCodeAt(l)===46?(h=".",l++):(h=null,E('"."')),h!==null?(g=Q(),g!==null?h=[h,g]:(h=null,l=R)):(h=null,l=R);c!==null?s=[s,c]:(s=null,l=S)}else s=null,l=S;return s}function ta(){var s,c,h,g,S,R,I;if(S=l,R=l,s=Ve(),s===null&&(s=ls()),s!==null){for(c=[],I=l,h=ue(),h!==null?(g=Ln(),g!==null?h=[h,g]:(h=null,l=I)):(h=null,l=I);h!==null;)c.push(h),I=l,h=ue(),h!==null?(g=Ln(),g!==null?h=[h,g]:(h=null,l=I)):(h=null,l=I);c!==null?s=[s,c]:(s=null,l=R)}else s=null,l=R;return s!==null&&(s=function(D){var J=T.tag;try{T=new m(T.uri,T.display_name,T.params),J&&T.setParam("tag",J)}catch{T=-1}}()),s===null&&(l=S),s}function Ln(){var s;return s=xl(),s===null&&(s=st()),s}function xl(){var s,c,h,g,S;return g=l,S=l,t.substr(l,3).toLowerCase()==="tag"?(s=t.substr(l,3),l+=3):(s=null,E('"tag"')),s!==null?(c=fe(),c!==null?(h=P(),h!==null?s=[s,c,h]:(s=null,l=S)):(s=null,l=S)):(s=null,l=S),s!==null&&(s=function(R,I){T.tag=I}(g,s[2])),s===null&&(l=g),s}function $n(){var s,c,h;if(h=l,c=w(),c!==null)for(s=[];c!==null;)s.push(c),c=w();else s=null;return s!==null&&(s=function(g,S){T=parseInt(S.join(""))}(h,s)),s===null&&(l=h),s}function ln(){var s,c;return c=l,s=zt(),s!==null&&(s=function(h,g){T=g}(c,s)),s===null&&(l=c),s}function Ir(){var s,c,h,g,S,R,I,D,J,Ne;for(D=l,J=l,s=[],c=ze();c!==null;)s.push(c),c=ze();if(s!==null)if(c=rt(),c!==null)if(h=Ht(),h!==null)if(g=we(),g!==null){for(S=[],Ne=l,R=ue(),R!==null?(I=st(),I!==null?R=[R,I]:(R=null,l=Ne)):(R=null,l=Ne);R!==null;)S.push(R),Ne=l,R=ue(),R!==null?(I=st(),I!==null?R=[R,I]:(R=null,l=Ne)):(R=null,l=Ne);S!==null?s=[s,c,h,g,S]:(s=null,l=J)}else s=null,l=J;else s=null,l=J;else s=null,l=J;else s=null,l=J;return s!==null&&(s=function(Ke){try{T=new m(T.uri,T.display_name,T.params)}catch{T=-1}}()),s===null&&(l=D),s}function rn(){var s;return s=Fs(),s}function Fs(){var s,c,h,g,S,R,I,D;if(I=l,t.substr(l,6).toLowerCase()==="digest"?(s=t.substr(l,6),l+=6):(s=null,E('"Digest"')),s!==null)if(c=G(),c!==null)if(h=on(),h!==null){for(g=[],D=l,S=$e(),S!==null?(R=on(),R!==null?S=[S,R]:(S=null,l=D)):(S=null,l=D);S!==null;)g.push(S),D=l,S=$e(),S!==null?(R=on(),R!==null?S=[S,R]:(S=null,l=D)):(S=null,l=D);g!==null?s=[s,c,h,g]:(s=null,l=I)}else s=null,l=I;else s=null,l=I;else s=null,l=I;return s===null&&(s=an()),s}function an(){var s,c,h,g,S,R,I,D;if(I=l,s=P(),s!==null)if(c=G(),c!==null)if(h=qs(),h!==null){for(g=[],D=l,S=$e(),S!==null?(R=qs(),R!==null?S=[S,R]:(S=null,l=D)):(S=null,l=D);S!==null;)g.push(S),D=l,S=$e(),S!==null?(R=qs(),R!==null?S=[S,R]:(S=null,l=D)):(S=null,l=D);g!==null?s=[s,c,h,g]:(s=null,l=I)}else s=null,l=I;else s=null,l=I;else s=null,l=I;return s}function qs(){var s,c,h,g;return g=l,s=P(),s!==null?(c=fe(),c!==null?(h=P(),h===null&&(h=Ce()),h!==null?s=[s,c,h]:(s=null,l=g)):(s=null,l=g)):(s=null,l=g),s}function on(){var s;return s=un(),s===null&&(s=Ml(),s===null&&(s=fn(),s===null&&(s=Or(),s===null&&(s=Es(),s===null&&(s=ni(),s===null&&(s=kl(),s===null&&(s=qs()))))))),s}function un(){var s,c,h,g;return g=l,t.substr(l,5).toLowerCase()==="realm"?(s=t.substr(l,5),l+=5):(s=null,E('"realm"')),s!==null?(c=fe(),c!==null?(h=Pl(),h!==null?s=[s,c,h]:(s=null,l=g)):(s=null,l=g)):(s=null,l=g),s}function Pl(){var s,c;return c=l,s=ke(),s!==null&&(s=function(h,g){T.realm=g}(c,s)),s===null&&(l=c),s}function Ml(){var s,c,h,g,S,R,I,D,J;if(D=l,t.substr(l,6).toLowerCase()==="domain"?(s=t.substr(l,6),l+=6):(s=null,E('"domain"')),s!==null)if(c=fe(),c!==null)if(h=Pe(),h!==null)if(g=cn(),g!==null){if(S=[],J=l,I=k(),I!==null)for(R=[];I!==null;)R.push(I),I=k();else R=null;for(R!==null?(I=cn(),I!==null?R=[R,I]:(R=null,l=J)):(R=null,l=J);R!==null;){if(S.push(R),J=l,I=k(),I!==null)for(R=[];I!==null;)R.push(I),I=k();else R=null;R!==null?(I=cn(),I!==null?R=[R,I]:(R=null,l=J)):(R=null,l=J)}S!==null?(R=Le(),R!==null?s=[s,c,h,g,S,R]:(s=null,l=D)):(s=null,l=D)}else s=null,l=D;else s=null,l=D;else s=null,l=D;else s=null,l=D;return s}function cn(){var s;return s=xs(),s===null&&(s=Ps()),s}function fn(){var s,c,h,g;return g=l,t.substr(l,5).toLowerCase()==="nonce"?(s=t.substr(l,5),l+=5):(s=null,E('"nonce"')),s!==null?(c=fe(),c!==null?(h=wr(),h!==null?s=[s,c,h]:(s=null,l=g)):(s=null,l=g)):(s=null,l=g),s}function wr(){var s,c;return c=l,s=ke(),s!==null&&(s=function(h,g){T.nonce=g}(c,s)),s===null&&(l=c),s}function Or(){var s,c,h,g,S;return g=l,S=l,t.substr(l,6).toLowerCase()==="opaque"?(s=t.substr(l,6),l+=6):(s=null,E('"opaque"')),s!==null?(c=fe(),c!==null?(h=ke(),h!==null?s=[s,c,h]:(s=null,l=S)):(s=null,l=S)):(s=null,l=S),s!==null&&(s=function(R,I){T.opaque=I}(g,s[2])),s===null&&(l=g),s}function Es(){var s,c,h,g,S;return g=l,t.substr(l,5).toLowerCase()==="stale"?(s=t.substr(l,5),l+=5):(s=null,E('"stale"')),s!==null?(c=fe(),c!==null?(S=l,t.substr(l,4).toLowerCase()==="true"?(h=t.substr(l,4),l+=4):(h=null,E('"true"')),h!==null&&(h=function(R){T.stale=!0}()),h===null&&(l=S),h===null&&(S=l,t.substr(l,5).toLowerCase()==="false"?(h=t.substr(l,5),l+=5):(h=null,E('"false"')),h!==null&&(h=function(R){T.stale=!1}()),h===null&&(l=S)),h!==null?s=[s,c,h]:(s=null,l=g)):(s=null,l=g)):(s=null,l=g),s}function ni(){var s,c,h,g,S;return g=l,S=l,t.substr(l,9).toLowerCase()==="algorithm"?(s=t.substr(l,9),l+=9):(s=null,E('"algorithm"')),s!==null?(c=fe(),c!==null?(t.substr(l,3).toLowerCase()==="md5"?(h=t.substr(l,3),l+=3):(h=null,E('"MD5"')),h===null&&(t.substr(l,8).toLowerCase()==="md5-sess"?(h=t.substr(l,8),l+=8):(h=null,E('"MD5-sess"')),h===null&&(h=P())),h!==null?s=[s,c,h]:(s=null,l=S)):(s=null,l=S)):(s=null,l=S),s!==null&&(s=function(R,I){T.algorithm=I.toUpperCase()}(g,s[2])),s===null&&(l=g),s}function kl(){var s,c,h,g,S,R,I,D,J,Ne;if(D=l,t.substr(l,3).toLowerCase()==="qop"?(s=t.substr(l,3),l+=3):(s=null,E('"qop"')),s!==null)if(c=fe(),c!==null)if(h=Pe(),h!==null){if(J=l,g=Cs(),g!==null){for(S=[],Ne=l,t.charCodeAt(l)===44?(R=",",l++):(R=null,E('","')),R!==null?(I=Cs(),I!==null?R=[R,I]:(R=null,l=Ne)):(R=null,l=Ne);R!==null;)S.push(R),Ne=l,t.charCodeAt(l)===44?(R=",",l++):(R=null,E('","')),R!==null?(I=Cs(),I!==null?R=[R,I]:(R=null,l=Ne)):(R=null,l=Ne);S!==null?g=[g,S]:(g=null,l=J)}else g=null,l=J;g!==null?(S=Le(),S!==null?s=[s,c,h,g,S]:(s=null,l=D)):(s=null,l=D)}else s=null,l=D;else s=null,l=D;else s=null,l=D;return s}function Cs(){var s,c;return c=l,t.substr(l,8).toLowerCase()==="auth-int"?(s=t.substr(l,8),l+=8):(s=null,E('"auth-int"')),s===null&&(t.substr(l,4).toLowerCase()==="auth"?(s=t.substr(l,4),l+=4):(s=null,E('"auth"')),s===null&&(s=P())),s!==null&&(s=function(h,g){T.qop||(T.qop=[]),T.qop.push(g.toLowerCase())}(c,s)),s===null&&(l=c),s}function sa(){var s,c,h,g,S,R;if(S=l,s=P(),s!==null){for(c=[],R=l,h=$e(),h!==null?(g=P(),g!==null?h=[h,g]:(h=null,l=R)):(h=null,l=R);h!==null;)c.push(h),R=l,h=$e(),h!==null?(g=P(),g!==null?h=[h,g]:(h=null,l=R)):(h=null,l=R);c!==null?s=[s,c]:(s=null,l=S)}else s=null,l=S;return s}function Dr(){var s,c,h,g,S,R,I;if(S=l,R=l,s=Ss(),s!==null){for(c=[],I=l,h=$e(),h!==null?(g=Ss(),g!==null?h=[h,g]:(h=null,l=I)):(h=null,l=I);h!==null;)c.push(h),I=l,h=$e(),h!==null?(g=Ss(),g!==null?h=[h,g]:(h=null,l=I)):(h=null,l=I);c!==null?s=[s,c]:(s=null,l=R)}else s=null,l=R;return s!==null&&(s=function(D){var J,Ne;for(Ne=T.multi_header.length,J=0;J<Ne;J++)if(T.multi_header[J].parsed===null){T=null;break}T!==null?T=T.multi_header:T=-1}()),s===null&&(l=S),s}function Ss(){var s,c,h,g,S,R,I;if(S=l,R=l,s=ls(),s!==null){for(c=[],I=l,h=ue(),h!==null?(g=st(),g!==null?h=[h,g]:(h=null,l=I)):(h=null,l=I);h!==null;)c.push(h),I=l,h=ue(),h!==null?(g=st(),g!==null?h=[h,g]:(h=null,l=I)):(h=null,l=I);c!==null?s=[s,c]:(s=null,l=R)}else s=null,l=R;return s!==null&&(s=function(D){var J;T.multi_header||(T.multi_header=[]);try{J=new m(T.uri,T.display_name,T.params),delete T.uri,delete T.display_name,delete T.params}catch{J=null}T.multi_header.push({possition:l,offset:D,parsed:J})}(S)),s===null&&(l=S),s}function na(){var s,c,h,g,S,R,I;if(S=l,R=l,t.substr(l,3).toLowerCase()==="sip"?(s=t.substr(l,3),l+=3):(s=null,E('"SIP"')),s===null&&(s=P()),s!==null){for(c=[],I=l,h=ue(),h!==null?(g=Ll(),g!==null?h=[h,g]:(h=null,l=I)):(h=null,l=I);h!==null;)c.push(h),I=l,h=ue(),h!==null?(g=Ll(),g!==null?h=[h,g]:(h=null,l=I)):(h=null,l=I);c!==null?s=[s,c]:(s=null,l=R)}else s=null,l=R;return s!==null&&(s=function(D,J){if(T.protocol=J.toLowerCase(),T.params||(T.params={}),T.params.text&&T.params.text[0]==='"'){var Ne=T.params.text;T.text=Ne.substring(1,Ne.length-1),delete T.params.text}}(S,s[0])),s===null&&(l=S),s}function Ll(){var s;return s=js(),s===null&&(s=st()),s}function js(){var s,c,h,g,S,R;if(S=l,R=l,t.substr(l,5).toLowerCase()==="cause"?(s=t.substr(l,5),l+=5):(s=null,E('"cause"')),s!==null)if(c=fe(),c!==null){if(g=w(),g!==null)for(h=[];g!==null;)h.push(g),g=w();else h=null;h!==null?s=[s,c,h]:(s=null,l=R)}else s=null,l=R;else s=null,l=R;return s!==null&&(s=function(I,D){T.cause=parseInt(D.join(""))}(S,s[2])),s===null&&(l=S),s}function li(){var s,c,h,g,S,R;if(S=l,s=P(),s!==null){for(c=[],R=l,h=$e(),h!==null?(g=P(),g!==null?h=[h,g]:(h=null,l=R)):(h=null,l=R);h!==null;)c.push(h),R=l,h=$e(),h!==null?(g=P(),g!==null?h=[h,g]:(h=null,l=R)):(h=null,l=R);c!==null?s=[s,c]:(s=null,l=S)}else s=null,l=S;return s}function ri(){var s,c,h,g,S,R;if(S=l,s=hn(),s!==null){for(c=[],R=l,h=$e(),h!==null?(g=hn(),g!==null?h=[h,g]:(h=null,l=R)):(h=null,l=R);h!==null;)c.push(h),R=l,h=$e(),h!==null?(g=hn(),g!==null?h=[h,g]:(h=null,l=R)):(h=null,l=R);c!==null?s=[s,c]:(s=null,l=S)}else s=null,l=S;return s}function hn(){var s,c,h,g,S,R;if(S=l,s=ls(),s!==null){for(c=[],R=l,h=ue(),h!==null?(g=st(),g!==null?h=[h,g]:(h=null,l=R)):(h=null,l=R);h!==null;)c.push(h),R=l,h=ue(),h!==null?(g=st(),g!==null?h=[h,g]:(h=null,l=R)):(h=null,l=R);c!==null?s=[s,c]:(s=null,l=S)}else s=null,l=S;return s}function ii(){var s,c,h,g,S,R;if(S=l,s=$l(),s!==null){for(c=[],R=l,h=ue(),h!==null?(g=Nr(),g!==null?h=[h,g]:(h=null,l=R)):(h=null,l=R);h!==null;)c.push(h),R=l,h=ue(),h!==null?(g=Nr(),g!==null?h=[h,g]:(h=null,l=R)):(h=null,l=R);c!==null?s=[s,c]:(s=null,l=S)}else s=null,l=S;return s}function $l(){var s,c;return c=l,t.substr(l,6).toLowerCase()==="active"?(s=t.substr(l,6),l+=6):(s=null,E('"active"')),s===null&&(t.substr(l,7).toLowerCase()==="pending"?(s=t.substr(l,7),l+=7):(s=null,E('"pending"')),s===null&&(t.substr(l,10).toLowerCase()==="terminated"?(s=t.substr(l,10),l+=10):(s=null,E('"terminated"')),s===null&&(s=P()))),s!==null&&(s=function(h){T.state=t.substring(l,h)}(c)),s===null&&(l=c),s}function Nr(){var s,c,h,g,S;return g=l,S=l,t.substr(l,6).toLowerCase()==="reason"?(s=t.substr(l,6),l+=6):(s=null,E('"reason"')),s!==null?(c=fe(),c!==null?(h=Hn(),h!==null?s=[s,c,h]:(s=null,l=S)):(s=null,l=S)):(s=null,l=S),s!==null&&(s=function(R,I){typeof I<"u"&&(T.reason=I)}(g,s[2])),s===null&&(l=g),s===null&&(g=l,S=l,t.substr(l,7).toLowerCase()==="expires"?(s=t.substr(l,7),l+=7):(s=null,E('"expires"')),s!==null?(c=fe(),c!==null?(h=zt(),h!==null?s=[s,c,h]:(s=null,l=S)):(s=null,l=S)):(s=null,l=S),s!==null&&(s=function(R,I){typeof I<"u"&&(T.expires=I)}(g,s[2])),s===null&&(l=g),s===null&&(g=l,S=l,t.substr(l,11).toLowerCase()==="retry_after"?(s=t.substr(l,11),l+=11):(s=null,E('"retry_after"')),s!==null?(c=fe(),c!==null?(h=zt(),h!==null?s=[s,c,h]:(s=null,l=S)):(s=null,l=S)):(s=null,l=S),s!==null&&(s=function(R,I){typeof I<"u"&&(T.retry_after=I)}(g,s[2])),s===null&&(l=g),s===null&&(s=st()))),s}function Hn(){var s;return t.substr(l,11).toLowerCase()==="deactivated"?(s=t.substr(l,11),l+=11):(s=null,E('"deactivated"')),s===null&&(t.substr(l,9).toLowerCase()==="probation"?(s=t.substr(l,9),l+=9):(s=null,E('"probation"')),s===null&&(t.substr(l,8).toLowerCase()==="rejected"?(s=t.substr(l,8),l+=8):(s=null,E('"rejected"')),s===null&&(t.substr(l,7).toLowerCase()==="timeout"?(s=t.substr(l,7),l+=7):(s=null,E('"timeout"')),s===null&&(t.substr(l,6).toLowerCase()==="giveup"?(s=t.substr(l,6),l+=6):(s=null,E('"giveup"')),s===null&&(t.substr(l,10).toLowerCase()==="noresource"?(s=t.substr(l,10),l+=10):(s=null,E('"noresource"')),s===null&&(t.substr(l,9).toLowerCase()==="invariant"?(s=t.substr(l,9),l+=9):(s=null,E('"invariant"')),s===null&&(s=P()))))))),s}function Fn(){var s;return s=te(),s=s!==null?s:"",s}function ai(){var s,c,h,g,S,R;if(S=l,s=P(),s!==null){for(c=[],R=l,h=$e(),h!==null?(g=P(),g!==null?h=[h,g]:(h=null,l=R)):(h=null,l=R);h!==null;)c.push(h),R=l,h=$e(),h!==null?(g=P(),g!==null?h=[h,g]:(h=null,l=R)):(h=null,l=R);c!==null?s=[s,c]:(s=null,l=S)}else s=null,l=S;return s=s!==null?s:"",s}function qn(){var s,c,h,g,S,R,I;if(S=l,R=l,s=Ve(),s===null&&(s=ls()),s!==null){for(c=[],I=l,h=ue(),h!==null?(g=_n(),g!==null?h=[h,g]:(h=null,l=I)):(h=null,l=I);h!==null;)c.push(h),I=l,h=ue(),h!==null?(g=_n(),g!==null?h=[h,g]:(h=null,l=I)):(h=null,l=I);c!==null?s=[s,c]:(s=null,l=R)}else s=null,l=R;return s!==null&&(s=function(D){var J=T.tag;try{T=new m(T.uri,T.display_name,T.params),J&&T.setParam("tag",J)}catch{T=-1}}()),s===null&&(l=S),s}function _n(){var s;return s=xl(),s===null&&(s=st()),s}function Ur(){var s,c,h,g,S,R;if(S=l,s=dn(),s!==null){for(c=[],R=l,h=$e(),h!==null?(g=dn(),g!==null?h=[h,g]:(h=null,l=R)):(h=null,l=R);h!==null;)c.push(h),R=l,h=$e(),h!==null?(g=dn(),g!==null?h=[h,g]:(h=null,l=R)):(h=null,l=R);c!==null?s=[s,c]:(s=null,l=S)}else s=null,l=S;return s}function dn(){var s,c,h,g,S,R,I,D;if(I=l,s=Vn(),s!==null)if(c=G(),c!==null)if(h=Bn(),h!==null){for(g=[],D=l,S=ue(),S!==null?(R=jn(),R!==null?S=[S,R]:(S=null,l=D)):(S=null,l=D);S!==null;)g.push(S),D=l,S=ue(),S!==null?(R=jn(),R!==null?S=[S,R]:(S=null,l=D)):(S=null,l=D);g!==null?s=[s,c,h,g]:(s=null,l=I)}else s=null,l=I;else s=null,l=I;else s=null,l=I;return s}function jn(){var s;return s=Hl(),s===null&&(s=Fl(),s===null&&(s=ql(),s===null&&(s=jl(),s===null&&(s=Vl(),s===null&&(s=st()))))),s}function Hl(){var s,c,h,g,S;return g=l,S=l,t.substr(l,3).toLowerCase()==="ttl"?(s=t.substr(l,3),l+=3):(s=null,E('"ttl"')),s!==null?(c=fe(),c!==null?(h=Wl(),h!==null?s=[s,c,h]:(s=null,l=S)):(s=null,l=S)):(s=null,l=S),s!==null&&(s=function(R,I){T.ttl=I}(g,s[2])),s===null&&(l=g),s}function Fl(){var s,c,h,g,S;return g=l,S=l,t.substr(l,5).toLowerCase()==="maddr"?(s=t.substr(l,5),l+=5):(s=null,E('"maddr"')),s!==null?(c=fe(),c!==null?(h=Se(),h!==null?s=[s,c,h]:(s=null,l=S)):(s=null,l=S)):(s=null,l=S),s!==null&&(s=function(R,I){T.maddr=I}(g,s[2])),s===null&&(l=g),s}function ql(){var s,c,h,g,S;return g=l,S=l,t.substr(l,8).toLowerCase()==="received"?(s=t.substr(l,8),l+=8):(s=null,E('"received"')),s!==null?(c=fe(),c!==null?(h=Os(),h===null&&(h=_s()),h!==null?s=[s,c,h]:(s=null,l=S)):(s=null,l=S)):(s=null,l=S),s!==null&&(s=function(R,I){T.received=I}(g,s[2])),s===null&&(l=g),s}function jl(){var s,c,h,g,S;return g=l,S=l,t.substr(l,6).toLowerCase()==="branch"?(s=t.substr(l,6),l+=6):(s=null,E('"branch"')),s!==null?(c=fe(),c!==null?(h=P(),h!==null?s=[s,c,h]:(s=null,l=S)):(s=null,l=S)):(s=null,l=S),s!==null&&(s=function(R,I){T.branch=I}(g,s[2])),s===null&&(l=g),s}function Vl(){var s,c,h,g,S;return g=l,t.substr(l,5).toLowerCase()==="rport"?(s=t.substr(l,5),l+=5):(s=null,E('"rport"')),s!==null?(S=l,c=fe(),c!==null?(h=Bl(),h!==null?c=[c,h]:(c=null,l=S)):(c=null,l=S),c=c!==null?c:"",c!==null?s=[s,c]:(s=null,l=g)):(s=null,l=g),s}function Bl(){var s,c,h,g,S,R,I;return R=l,I=l,s=w(),s=s!==null?s:"",s!==null?(c=w(),c=c!==null?c:"",c!==null?(h=w(),h=h!==null?h:"",h!==null?(g=w(),g=g!==null?g:"",g!==null?(S=w(),S=S!==null?S:"",S!==null?s=[s,c,h,g,S]:(s=null,l=I)):(s=null,l=I)):(s=null,l=I)):(s=null,l=I)):(s=null,l=I),s!==null&&(s=function(D,J){T.rport=parseInt(J.join(""))}(R,s)),s===null&&(l=R),s}function Vn(){var s,c,h,g,S,R;return R=l,s=xr(),s!==null?(c=be(),c!==null?(h=P(),h!==null?(g=be(),g!==null?(S=Pr(),S!==null?s=[s,c,h,g,S]:(s=null,l=R)):(s=null,l=R)):(s=null,l=R)):(s=null,l=R)):(s=null,l=R),s}function xr(){var s,c;return c=l,t.substr(l,3).toLowerCase()==="sip"?(s=t.substr(l,3),l+=3):(s=null,E('"SIP"')),s===null&&(s=P()),s!==null&&(s=function(h,g){T.protocol=g}(c,s)),s===null&&(l=c),s}function Pr(){var s,c;return c=l,t.substr(l,3).toLowerCase()==="udp"?(s=t.substr(l,3),l+=3):(s=null,E('"UDP"')),s===null&&(t.substr(l,3).toLowerCase()==="tcp"?(s=t.substr(l,3),l+=3):(s=null,E('"TCP"')),s===null&&(t.substr(l,3).toLowerCase()==="tls"?(s=t.substr(l,3),l+=3):(s=null,E('"TLS"')),s===null&&(t.substr(l,4).toLowerCase()==="sctp"?(s=t.substr(l,4),l+=4):(s=null,E('"SCTP"')),s===null&&(s=P())))),s!==null&&(s=function(h,g){T.transport=g}(c,s)),s===null&&(l=c),s}function Bn(){var s,c,h,g,S;return g=l,s=Gl(),s!==null?(S=l,c=Oe(),c!==null?(h=Mr(),h!==null?c=[c,h]:(c=null,l=S)):(c=null,l=S),c=c!==null?c:"",c!==null?s=[s,c]:(s=null,l=g)):(s=null,l=g),s}function Gl(){var s,c;return c=l,s=Os(),s===null&&(s=vt(),s===null&&(s=dt())),s!==null&&(s=function(h){T.host=t.substring(l,h)}(c)),s===null&&(l=c),s}function Mr(){var s,c,h,g,S,R,I;return R=l,I=l,s=w(),s=s!==null?s:"",s!==null?(c=w(),c=c!==null?c:"",c!==null?(h=w(),h=h!==null?h:"",h!==null?(g=w(),g=g!==null?g:"",g!==null?(S=w(),S=S!==null?S:"",S!==null?s=[s,c,h,g,S]:(s=null,l=I)):(s=null,l=I)):(s=null,l=I)):(s=null,l=I)):(s=null,l=I),s!==null&&(s=function(D,J){T.port=parseInt(J.join(""))}(R,s)),s===null&&(l=R),s}function Wl(){var s,c,h,g,S;return g=l,S=l,s=w(),s!==null?(c=w(),c=c!==null?c:"",c!==null?(h=w(),h=h!==null?h:"",h!==null?s=[s,c,h]:(s=null,l=S)):(s=null,l=S)):(s=null,l=S),s!==null&&(s=function(R,I){return parseInt(I.join(""))}(g,s)),s===null&&(l=g),s}function Kl(){var s;return s=Fs(),s}function oi(){var s,c,h,g,S,R;if(S=l,s=ui(),s!==null){for(c=[],R=l,h=ue(),h!==null?(g=Gn(),g!==null?h=[h,g]:(h=null,l=R)):(h=null,l=R);h!==null;)c.push(h),R=l,h=ue(),h!==null?(g=Gn(),g!==null?h=[h,g]:(h=null,l=R)):(h=null,l=R);c!==null?s=[s,c]:(s=null,l=S)}else s=null,l=S;return s}function ui(){var s,c;return c=l,s=zt(),s!==null&&(s=function(h,g){T.expires=g}(c,s)),s===null&&(l=c),s}function Gn(){var s;return s=Jt(),s===null&&(s=st()),s}function Jt(){var s,c,h,g,S;return g=l,S=l,t.substr(l,9).toLowerCase()==="refresher"?(s=t.substr(l,9),l+=9):(s=null,E('"refresher"')),s!==null?(c=fe(),c!==null?(t.substr(l,3).toLowerCase()==="uac"?(h=t.substr(l,3),l+=3):(h=null,E('"uac"')),h===null&&(t.substr(l,3).toLowerCase()==="uas"?(h=t.substr(l,3),l+=3):(h=null,E('"uas"'))),h!==null?s=[s,c,h]:(s=null,l=S)):(s=null,l=S)):(s=null,l=S),s!==null&&(s=function(R,I){T.refresher=I.toLowerCase()}(g,s[2])),s===null&&(l=g),s}function ci(){var s,c,h,g;return g=l,s=P(),s!==null?(c=M(),c!==null?(h=Yl(),h!==null?s=[s,c,h]:(s=null,l=g)):(s=null,l=g)):(s=null,l=g),s}function Yl(){var s,c;for(s=[],c=se(),c===null&&(c=ne(),c===null&&(c=G()));c!==null;)s.push(c),c=se(),c===null&&(c=ne(),c===null&&(c=G()));return s}function rs(){var s,c;for(s=[],c=j();c!==null;)s.push(c),c=j();return s}function fi(){var s,c,h;return h=l,t.substr(l,5)==="uuid:"?(s="uuid:",l+=5):(s=null,E('"uuid:"')),s!==null?(c=zl(),c!==null?s=[s,c]:(s=null,l=h)):(s=null,l=h),s}function zl(){var s,c,h,g,S,R,I,D,J,Ne,Ke;return Ne=l,Ke=l,s=kr(),s!==null?(t.charCodeAt(l)===45?(c="-",l++):(c=null,E('"-"')),c!==null?(h=Bt(),h!==null?(t.charCodeAt(l)===45?(g="-",l++):(g=null,E('"-"')),g!==null?(S=Bt(),S!==null?(t.charCodeAt(l)===45?(R="-",l++):(R=null,E('"-"')),R!==null?(I=Bt(),I!==null?(t.charCodeAt(l)===45?(D="-",l++):(D=null,E('"-"')),D!==null?(J=Jl(),J!==null?s=[s,c,h,g,S,R,I,D,J]:(s=null,l=Ke)):(s=null,l=Ke)):(s=null,l=Ke)):(s=null,l=Ke)):(s=null,l=Ke)):(s=null,l=Ke)):(s=null,l=Ke)):(s=null,l=Ke)):(s=null,l=Ke),s!==null&&(s=function(F,Ie){T=t.substring(l+5,F)}(Ne,s[0])),s===null&&(l=Ne),s}function Bt(){var s,c,h,g,S;return S=l,s=U(),s!==null?(c=U(),c!==null?(h=U(),h!==null?(g=U(),g!==null?s=[s,c,h,g]:(s=null,l=S)):(s=null,l=S)):(s=null,l=S)):(s=null,l=S),s}function kr(){var s,c,h;return h=l,s=Bt(),s!==null?(c=Bt(),c!==null?s=[s,c]:(s=null,l=h)):(s=null,l=h),s}function Jl(){var s,c,h,g;return g=l,s=Bt(),s!==null?(c=Bt(),c!==null?(h=Bt(),h!==null?s=[s,c,h]:(s=null,l=g)):(s=null,l=g)):(s=null,l=g),s}function Xl(){var s,c,h,g,S,R,I;if(S=l,R=l,s=Ve(),s===null&&(s=ls()),s!==null){for(c=[],I=l,h=ue(),h!==null?(g=st(),g!==null?h=[h,g]:(h=null,l=I)):(h=null,l=I);h!==null;)c.push(h),I=l,h=ue(),h!==null?(g=st(),g!==null?h=[h,g]:(h=null,l=I)):(h=null,l=I);c!==null?s=[s,c]:(s=null,l=R)}else s=null,l=R;return s!==null&&(s=function(D){try{T=new m(T.uri,T.display_name,T.params)}catch{T=-1}}()),s===null&&(l=S),s}function hi(){var s,c,h,g,S,R;if(S=l,s=Lr(),s!==null){for(c=[],R=l,h=ue(),h!==null?(g=x(),g!==null?h=[h,g]:(h=null,l=R)):(h=null,l=R);h!==null;)c.push(h),R=l,h=ue(),h!==null?(g=x(),g!==null?h=[h,g]:(h=null,l=R)):(h=null,l=R);c!==null?s=[s,c]:(s=null,l=S)}else s=null,l=S;return s}function Lr(){var s,c,h,g,S,R;return g=l,S=l,s=he(),s!==null?(R=l,t.charCodeAt(l)===64?(c="@",l++):(c=null,E('"@"')),c!==null?(h=he(),h!==null?c=[c,h]:(c=null,l=R)):(c=null,l=R),c=c!==null?c:"",c!==null?s=[s,c]:(s=null,l=S)):(s=null,l=S),s!==null&&(s=function(I){T.call_id=t.substring(l,I)}(g)),s===null&&(l=g),s}function x(){var s;return s=Ql(),s===null&&(s=Zl(),s===null&&(s=$r(),s===null&&(s=st()))),s}function Ql(){var s,c,h,g,S;return g=l,S=l,t.substr(l,6)==="to-tag"?(s="to-tag",l+=6):(s=null,E('"to-tag"')),s!==null?(c=fe(),c!==null?(h=P(),h!==null?s=[s,c,h]:(s=null,l=S)):(s=null,l=S)):(s=null,l=S),s!==null&&(s=function(R,I){T.to_tag=I}(g,s[2])),s===null&&(l=g),s}function Zl(){var s,c,h,g,S;return g=l,S=l,t.substr(l,8)==="from-tag"?(s="from-tag",l+=8):(s=null,E('"from-tag"')),s!==null?(c=fe(),c!==null?(h=P(),h!==null?s=[s,c,h]:(s=null,l=S)):(s=null,l=S)):(s=null,l=S),s!==null&&(s=function(R,I){T.from_tag=I}(g,s[2])),s===null&&(l=g),s}function $r(){var s,c;return c=l,t.substr(l,10)==="early-only"?(s="early-only",l+=10):(s=null,E('"early-only"')),s!==null&&(s=function(h){T.early_only=!0}()),s===null&&(l=c),s}function Vs(s){s.sort();for(var c=null,h=[],g=0;g<s.length;g++)s[g]!==c&&(h.push(s[g]),c=s[g]);return h}function i(){for(var s=1,c=1,h=!1,g=0;g<Math.max(l,A);g++){var S=t.charAt(g);S===`
|
75
|
-
`?(h||s++,c=1,h=!1):S==="\r"||S==="\u2028"||S==="\u2029"?(s++,c=1,h=!0):(c++,h=!1)}return{line:s,column:c}}var _=Tn(),m=Ga(),T={},y=C[v]();if(y===null||l!==t.length){var r=Math.max(l,A),f=r<t.length?t.charAt(r):null,d=i();return new this.SyntaxError(Vs(b),f,r,d.line,d.column),-1}return T},toSource:function(){return this._source}};n.SyntaxError=function(t,v,C,l,A){function b(E,O){var w,N;switch(E.length){case 0:w="end of input";break;case 1:w=E[0];break;default:w=E.slice(0,E.length-1).join(", ")+" or "+E[E.length-1]}return N=O?u(O):"end of input","Expected "+w+" but "+N+" found."}this.name="SyntaxError",this.expected=t,this.found=v,this.message=b(t,v),this.offset=C,this.line=l,this.column=A},n.SyntaxError.prototype=Error.prototype;const a='INVITE sip:ds881ehp@6ke7klp2hppe.invalid;transport=ws;+sip.ice;reg-id=1;+sip.instance="<urn:uuid:378e5fc1-d7b5-42a9-8bf3-2b796aa0c67e>" SIP/2.0',e="INVITE sip:gsfjq6nt@6itebkeio2hf.invalid;transport=ws SIP/2.0",o=n.parse(a,"Request_Response");console.log("newRes",o),console.log("#############################################");const p=n.parse(e,"Request_Response");return console.log("oldRes",p),Rf}var uu,wf;function Tn(){if(wf)return uu;wf=1;const u=Fe,n=wt(),a=Ys();return uu=class Hh{static parse(o){if(o=a.parse(o,"SIP_URI"),o!==-1)return o}constructor(o,p,t,v,C={},l={}){if(!t)throw new TypeError('missing or invalid "host" parameter');this._parameters={},this._headers={},this._scheme=o||u.SIP,this._user=p,this._host=t,this._port=v;for(const A in C)Object.prototype.hasOwnProperty.call(C,A)&&this.setParam(A,C[A]);for(const A in l)Object.prototype.hasOwnProperty.call(l,A)&&this.setHeader(A,l[A])}get scheme(){return this._scheme}set scheme(o){this._scheme=o.toLowerCase()}get user(){return this._user}set user(o){this._user=o}get host(){return this._host}set host(o){this._host=o.toLowerCase()}get port(){return this._port}set port(o){this._port=o===0?o:parseInt(o,10)||null}setParam(o,p){o&&(this._parameters[o.toLowerCase()]=typeof p>"u"||p===null?null:p.toString())}getParam(o){if(o)return this._parameters[o.toLowerCase()]}hasParam(o){if(o)return this._parameters.hasOwnProperty(o.toLowerCase())&&!0||!1}deleteParam(o){if(o=o.toLowerCase(),this._parameters.hasOwnProperty(o)){const p=this._parameters[o];return delete this._parameters[o],p}}clearParams(){this._parameters={}}setHeader(o,p){this._headers[n.headerize(o)]=Array.isArray(p)?p:[p]}getHeader(o){if(o)return this._headers[n.headerize(o)]}hasHeader(o){if(o)return this._headers.hasOwnProperty(n.headerize(o))&&!0||!1}deleteHeader(o){if(o=n.headerize(o),this._headers.hasOwnProperty(o)){const p=this._headers[o];return delete this._headers[o],p}}clearHeaders(){this._headers={}}clone(){return new Hh(this._scheme,this._user,this._host,this._port,JSON.parse(JSON.stringify(this._parameters)),JSON.parse(JSON.stringify(this._headers)))}toString(){const o=[];let p=`${this._scheme}:`;this._user&&(p+=`${n.escapeUser(this._user)}@`),p+=this._host,(this._port||this._port===0)&&(p+=`:${this._port}`);for(const t in this._parameters)Object.prototype.hasOwnProperty.call(this._parameters,t)&&(p+=`;${t}`,this._parameters[t]!==null&&(p+=`=${this._parameters[t]}`));for(const t in this._headers)if(Object.prototype.hasOwnProperty.call(this._headers,t))for(const v of this._headers[t])o.push(`${t}=${v}`);return o.length>0&&(p+=`?${o.join("&")}`),p}toAor(o){let p=`${this._scheme}:`;return this._user&&(p+=`${n.escapeUser(this._user)}@`),p+=this._host,o&&(this._port||this._port===0)&&(p+=`:${this._port}`),p}},uu}var Of;function wt(){if(Of)return ft;Of=1;const u=Fe,n=Tn(),a=Ys();ft.str_utf8_length=t=>unescape(encodeURIComponent(t)).length;const e=ft.isFunction=t=>t!==void 0?Object.prototype.toString.call(t)==="[object Function]":!1;ft.isString=t=>t!==void 0?Object.prototype.toString.call(t)==="[object String]":!1,ft.isDecimal=t=>!isNaN(t)&&parseFloat(t)===parseInt(t,10),ft.isEmpty=t=>t===null||t===""||t===void 0||Array.isArray(t)&&t.length===0||typeof t=="number"&&isNaN(t),ft.hasMethods=function(t,...v){for(const C of v)if(e(t[C]))return!1;return!0};const o=ft.createRandomToken=(t,v=32)=>{let C,l,A="";for(C=0;C<t;C++)l=Math.random()*v|0,A+=l.toString(v);return A};ft.newTag=()=>o(10),ft.newUUID=()=>"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,v=>{const C=Math.random()*16|0;return(v==="x"?C:C&3|8).toString(16)}),ft.hostType=t=>{if(t){if(t=a.parse(t,"host"),t!==-1)return t.host_type}else return};const p=ft.escapeUser=t=>encodeURIComponent(decodeURIComponent(t)).replace(/%3A/ig,":").replace(/%2B/ig,"+").replace(/%3F/ig,"?").replace(/%2F/ig,"/");return ft.normalizeTarget=(t,v)=>{if(t){if(t instanceof n)return t;if(typeof t=="string"){const C=t.split("@");let l,A;switch(C.length){case 1:if(!v)return;l=t,A=v;break;case 2:l=C[0],A=C[1];break;default:l=C.slice(0,C.length-1).join("@"),A=C[C.length-1]}l=l.replace(/^(sips?|tel):/i,""),/^[-.()]*\+?[0-9\-.()]+$/.test(l)&&(l=l.replace(/[-.()]/g,"")),t=`${u.SIP}:${p(l)}@${A}`;let b;return(b=n.parse(t))?b:void 0}else return}else return},ft.headerize=t=>{const v={"Call-Id":"Call-ID",Cseq:"CSeq","Www-Authenticate":"WWW-Authenticate"},C=t.toLowerCase().replace(/_/g,"-").split("-");let l="";const A=C.length;let b;for(b=0;b<A;b++)b!==0&&(l+="-"),l+=C[b].charAt(0).toUpperCase()+C[b].substring(1);return v[l]&&(l=v[l]),l},ft.sipErrorCause=t=>{for(const v in u.SIP_ERROR_CAUSES)if(u.SIP_ERROR_CAUSES[v].indexOf(t)!==-1)return u.causes[v];return u.causes.SIP_FAILURE_CODE},ft.getRandomTestNetIP=()=>{function t(v,C){return Math.floor(Math.random()*(C-v+1)+v)}return`192.0.2.${t(1,254)}`},ft.calculateMD5=t=>{function v(ue,Oe){return ue<<Oe|ue>>>32-Oe}function C(ue,Oe){const Pe=ue&2147483648,Le=Oe&2147483648,ye=ue&1073741824,pe=Oe&1073741824,Ce=(ue&1073741823)+(Oe&1073741823);return ye&pe?Ce^2147483648^Pe^Le:ye|pe?Ce&1073741824?Ce^3221225472^Pe^Le:Ce^1073741824^Pe^Le:Ce^Pe^Le}function l(ue,Oe,Pe){return ue&Oe|~ue&Pe}function A(ue,Oe,Pe){return ue&Pe|Oe&~Pe}function b(ue,Oe,Pe){return ue^Oe^Pe}function E(ue,Oe,Pe){return Oe^(ue|~Pe)}function O(ue,Oe,Pe,Le,ye,pe,Ce){return ue=C(ue,C(C(l(Oe,Pe,Le),ye),Ce)),C(v(ue,pe),Oe)}function w(ue,Oe,Pe,Le,ye,pe,Ce){return ue=C(ue,C(C(A(Oe,Pe,Le),ye),Ce)),C(v(ue,pe),Oe)}function N(ue,Oe,Pe,Le,ye,pe,Ce){return ue=C(ue,C(C(b(Oe,Pe,Le),ye),Ce)),C(v(ue,pe),Oe)}function U(ue,Oe,Pe,Le,ye,pe,Ce){return ue=C(ue,C(C(E(Oe,Pe,Le),ye),Ce)),C(v(ue,pe),Oe)}function z(ue){let Oe;const Pe=ue.length,Le=Pe+8,pe=((Le-Le%64)/64+1)*16,Ce=new Array(pe-1);let ke=0,He=0;for(;He<Pe;)Oe=(He-He%4)/4,ke=He%4*8,Ce[Oe]=Ce[Oe]|ue.charCodeAt(He)<<ke,He++;return Oe=(He-He%4)/4,ke=He%4*8,Ce[Oe]=Ce[Oe]|128<<ke,Ce[pe-2]=Pe<<3,Ce[pe-1]=Pe>>>29,Ce}function j(ue){let Oe="",Pe="",Le,ye;for(ye=0;ye<=3;ye++)Le=ue>>>ye*8&255,Pe=`0${Le.toString(16)}`,Oe=Oe+Pe.substr(Pe.length-2,2);return Oe}function _e(ue){let Oe="";for(let Pe=0;Pe<ue.length;Pe++){const Le=ue.charCodeAt(Pe);Le<128?Oe+=String.fromCharCode(Le):Le>127&&Le<2048?(Oe+=String.fromCharCode(Le>>6|192),Oe+=String.fromCharCode(Le&63|128)):(Oe+=String.fromCharCode(Le>>12|224),Oe+=String.fromCharCode(Le>>6&63|128),Oe+=String.fromCharCode(Le&63|128))}return Oe}let k=[],H,de,Ue,B,L,V,G,K,M;const te=7,se=12,$=17,ne=22,ht=5,P=9,Q=14,oe=20,he=4,Re=11,be=16,fe=23,je=6,xe=10,we=15,rt=21;for(t=_e(t),k=z(t),V=1732584193,G=4023233417,K=2562383102,M=271733878,H=0;H<k.length;H+=16)de=V,Ue=G,B=K,L=M,V=O(V,G,K,M,k[H+0],te,3614090360),M=O(M,V,G,K,k[H+1],se,3905402710),K=O(K,M,V,G,k[H+2],$,606105819),G=O(G,K,M,V,k[H+3],ne,3250441966),V=O(V,G,K,M,k[H+4],te,4118548399),M=O(M,V,G,K,k[H+5],se,1200080426),K=O(K,M,V,G,k[H+6],$,2821735955),G=O(G,K,M,V,k[H+7],ne,4249261313),V=O(V,G,K,M,k[H+8],te,1770035416),M=O(M,V,G,K,k[H+9],se,2336552879),K=O(K,M,V,G,k[H+10],$,4294925233),G=O(G,K,M,V,k[H+11],ne,2304563134),V=O(V,G,K,M,k[H+12],te,1804603682),M=O(M,V,G,K,k[H+13],se,4254626195),K=O(K,M,V,G,k[H+14],$,2792965006),G=O(G,K,M,V,k[H+15],ne,1236535329),V=w(V,G,K,M,k[H+1],ht,4129170786),M=w(M,V,G,K,k[H+6],P,3225465664),K=w(K,M,V,G,k[H+11],Q,643717713),G=w(G,K,M,V,k[H+0],oe,3921069994),V=w(V,G,K,M,k[H+5],ht,3593408605),M=w(M,V,G,K,k[H+10],P,38016083),K=w(K,M,V,G,k[H+15],Q,3634488961),G=w(G,K,M,V,k[H+4],oe,3889429448),V=w(V,G,K,M,k[H+9],ht,568446438),M=w(M,V,G,K,k[H+14],P,3275163606),K=w(K,M,V,G,k[H+3],Q,4107603335),G=w(G,K,M,V,k[H+8],oe,1163531501),V=w(V,G,K,M,k[H+13],ht,2850285829),M=w(M,V,G,K,k[H+2],P,4243563512),K=w(K,M,V,G,k[H+7],Q,1735328473),G=w(G,K,M,V,k[H+12],oe,2368359562),V=N(V,G,K,M,k[H+5],he,4294588738),M=N(M,V,G,K,k[H+8],Re,2272392833),K=N(K,M,V,G,k[H+11],be,1839030562),G=N(G,K,M,V,k[H+14],fe,4259657740),V=N(V,G,K,M,k[H+1],he,2763975236),M=N(M,V,G,K,k[H+4],Re,1272893353),K=N(K,M,V,G,k[H+7],be,4139469664),G=N(G,K,M,V,k[H+10],fe,3200236656),V=N(V,G,K,M,k[H+13],he,681279174),M=N(M,V,G,K,k[H+0],Re,3936430074),K=N(K,M,V,G,k[H+3],be,3572445317),G=N(G,K,M,V,k[H+6],fe,76029189),V=N(V,G,K,M,k[H+9],he,3654602809),M=N(M,V,G,K,k[H+12],Re,3873151461),K=N(K,M,V,G,k[H+15],be,530742520),G=N(G,K,M,V,k[H+2],fe,3299628645),V=U(V,G,K,M,k[H+0],je,4096336452),M=U(M,V,G,K,k[H+7],xe,1126891415),K=U(K,M,V,G,k[H+14],we,2878612391),G=U(G,K,M,V,k[H+5],rt,4237533241),V=U(V,G,K,M,k[H+12],je,1700485571),M=U(M,V,G,K,k[H+3],xe,2399980690),K=U(K,M,V,G,k[H+10],we,4293915773),G=U(G,K,M,V,k[H+1],rt,2240044497),V=U(V,G,K,M,k[H+8],je,1873313359),M=U(M,V,G,K,k[H+15],xe,4264355552),K=U(K,M,V,G,k[H+6],we,2734768916),G=U(G,K,M,V,k[H+13],rt,1309151649),V=U(V,G,K,M,k[H+4],je,4149444226),M=U(M,V,G,K,k[H+11],xe,3174756917),K=U(K,M,V,G,k[H+2],we,718787259),G=U(G,K,M,V,k[H+9],rt,3951481745),V=C(V,de),G=C(G,Ue),K=C(K,B),M=C(M,L);return(j(V)+j(G)+j(K)+j(M)).toLowerCase()},ft.closeMediaStream=t=>{if(t)try{let v;if(t.getTracks){v=t.getTracks();for(const C of v)C.stop()}else{v=t.getAudioTracks();for(const C of v)C.stop();v=t.getVideoTracks();for(const C of v)C.stop()}}catch{(typeof t.stop=="function"||typeof t.stop=="object")&&t.stop()}},ft.cloneArray=t=>t&&t.slice()||[],ft.cloneObject=(t,v={})=>t&&Object.assign({},t)||v,ft}const Df=Gt,Rm=Tt,Ot=Fe,gt=wt(),Nf=Ga(),bm=Ys(),cu=new Rm("SIPMessage");class Wa{constructor(n,a,e,o,p,t){if(!n||!a||!e)return null;o=o||{},this.ua=e,this.headers={},this.method=n,this.ruri=a,this.body=t,this.extraHeaders=gt.cloneArray(p),this.ua.configuration.extra_headers&&(this.extraHeaders=this.extraHeaders.concat(this.ua.configuration.extra_headers)),o.route_set?this.setHeader("route",o.route_set):e.configuration.use_preloaded_route&&this.setHeader("route",`<${e.transport.sip_uri};lr>`),this.setHeader("via",""),this.setHeader("max-forwards",Ot.MAX_FORWARDS);const v=o.to_uri||a,C=o.to_tag?{tag:o.to_tag}:null,l=typeof o.to_display_name<"u"?o.to_display_name:null;this.to=new Nf(v,l,C),this.setHeader("to",this.to.toString());const A=o.from_uri||e.configuration.uri,b={tag:o.from_tag||gt.newTag()};let E;typeof o.from_display_name<"u"?E=o.from_display_name:e.configuration.display_name?E=e.configuration.display_name:E=null,this.from=new Nf(A,E,b),this.setHeader("from",this.from.toString());const O=o.call_id||e.configuration.jssip_id+gt.createRandomToken(15);this.call_id=O,this.setHeader("call-id",O);const w=o.cseq||Math.floor(Math.random()*1e4);this.cseq=w,this.setHeader("cseq",`${w} ${n}`)}setHeader(n,a){const e=new RegExp(`^\\s*${n}\\s*:`,"i");for(let o=0;o<this.extraHeaders.length;o++)e.test(this.extraHeaders[o])&&this.extraHeaders.splice(o,1);this.headers[gt.headerize(n)]=Array.isArray(a)?a:[a]}getHeader(n){const a=this.headers[gt.headerize(n)];if(a){if(a[0])return a[0]}else{const e=new RegExp(`^\\s*${n}\\s*:`,"i");for(const o of this.extraHeaders)if(e.test(o))return o.substring(o.indexOf(":")+1).trim()}}getHeaders(n){const a=this.headers[gt.headerize(n)],e=[];if(a){for(const o of a)e.push(o);return e}else{const o=new RegExp(`^\\s*${n}\\s*:`,"i");for(const p of this.extraHeaders)o.test(p)&&e.push(p.substring(p.indexOf(":")+1).trim());return e}}hasHeader(n){if(this.headers[gt.headerize(n)])return!0;{const a=new RegExp(`^\\s*${n}\\s*:`,"i");for(const e of this.extraHeaders)if(a.test(e))return!0}return!1}parseSDP(n){return!n&&this.sdp?this.sdp:(this.sdp=Df.parse(this.body||""),this.sdp)}toString(){let n=`${this.method} ${this.ruri} SIP/2.0\r
|
76
|
-
`;for(const
|
77
|
-
`;for(const
|
78
|
-
`;const
|
79
|
-
`,
|
80
|
-
`,
|
81
|
-
`,this.body){const
|
59
|
+
`.concat(i,`
|
60
|
+
`));this.ondata({transport:this,message:i})}},{key:"via_transport",get:function(){return this.socket.via_transport}},{key:"url",get:function(){return this.socket.url}},{key:"sip_uri",get:function(){return this.socket.sip_uri}}]),c}(),rf={};function lf(c,s){var i;if(typeof Symbol>"u"||c[Symbol.iterator]==null){if(Array.isArray(c)||(i=bp(c))||s&&c&&typeof c.length=="number"){i&&(c=i);var l=0,a=function(){};return{s:a,n:function(){return l>=c.length?{done:!0}:{done:!1,value:c[l++]}},e:function(n){throw n},f:a}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
|
61
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var _=!0,e=!1,p;return{s:function(){i=c[Symbol.iterator]()},n:function(){var n=i.next();return _=n.done,n},e:function(n){e=!0,p=n},f:function(){try{!_&&i.return!=null&&i.return()}finally{if(e)throw p}}}}function bp(c,s){if(c){if(typeof c=="string")return af(c,s);var i=Object.prototype.toString.call(c).slice(8,-1);if(i==="Object"&&c.constructor&&(i=c.constructor.name),i==="Map"||i==="Set")return Array.from(c);if(i==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i))return af(c,s)}}function af(c,s){(s==null||s>c.length)&&(s=c.length);for(var i=0,l=new Array(s);i<s;i++)l[i]=c[i];return l}var wp=ft,Lo=Zt(),$o=cs,Yl=new wp("Parser");rf.parseMessage=function(c,s){var i,l,a=c.indexOf(`\r
|
62
|
+
`);if(a===-1){Yl.warn("parseMessage() | no CRLF found, not a SIP message");return}var _=c.substring(0,a),e=Lo.parse(_,"Request_Response");if(e===-1){Yl.warn('parseMessage() | error parsing first line of SIP message: "'.concat(_,'"'));return}else e.status_code?(i=new $o.IncomingResponse,i.status_code=e.status_code,i.reason_phrase=e.reason_phrase):(i=new $o.IncomingRequest(s),i.method=e.method,i.ruri=e.uri);i.data=c;for(var p=a+2;;){if(a=Op(c,p),a===-2){l=p+2;break}else if(a===-1){Yl.warn("parseMessage() | malformed message");return}if(e=Dp(i,c,p,a),e!==!0){Yl.warn("parseMessage() |",e.error);return}p=a+2}if(i.hasHeader("content-length")){var g=i.getHeader("content-length");i.body=c.substr(l,g)}else i.body=c.substring(l);return i};function Op(c,s){var i=s,l=0,a=0;if(c.substring(i,i+2).match(/(^\r\n)/))return-2;for(;l===0;){if(a=c.indexOf(`\r
|
63
|
+
`,i),a===-1)return a;!c.substring(a+2,a+4).match(/(^\r\n)/)&&c.charAt(a+2).match(/(^\s+)/)?i=a+2:l=a}return l}function Dp(c,s,i,l){var a,_=s.indexOf(":",i),e=s.substring(i,_).trim(),p=s.substring(_+1,l).trim();switch(e.toLowerCase()){case"via":case"v":c.addHeader("via",p),c.getHeaders("via").length===1?(a=c.parseHeader("Via"),a&&(c.via=a,c.via_branch=a.branch)):a=0;break;case"from":case"f":c.setHeader("from",p),a=c.parseHeader("from"),a&&(c.from=a,c.from_tag=a.getParam("tag"));break;case"to":case"t":c.setHeader("to",p),a=c.parseHeader("to"),a&&(c.to=a,c.to_tag=a.getParam("tag"));break;case"record-route":if(a=Lo.parse(p,"Record_Route"),a===-1)a=void 0;else{var g=lf(a),n;try{for(g.s();!(n=g.n()).done;){var v=n.value;c.addHeader("record-route",p.substring(v.possition,v.offset)),c.headers["Record-Route"][c.getHeaders("record-route").length-1].parsed=v.parsed}}catch(A){g.e(A)}finally{g.f()}}break;case"call-id":case"i":c.setHeader("call-id",p),a=c.parseHeader("call-id"),a&&(c.call_id=p);break;case"contact":case"m":if(a=Lo.parse(p,"Contact"),a===-1)a=void 0;else{var S=lf(a),m;try{for(S.s();!(m=S.n()).done;){var C=m.value;c.addHeader("contact",p.substring(C.possition,C.offset)),c.headers.Contact[c.getHeaders("contact").length-1].parsed=C.parsed}}catch(A){S.e(A)}finally{S.f()}}break;case"content-length":case"l":c.setHeader("content-length",p),a=c.parseHeader("content-length");break;case"content-type":case"c":c.setHeader("content-type",p),a=c.parseHeader("content-type");break;case"cseq":c.setHeader("cseq",p),a=c.parseHeader("cseq"),a&&(c.cseq=a.value),c instanceof $o.IncomingResponse&&(c.method=a.method);break;case"max-forwards":c.setHeader("max-forwards",p),a=c.parseHeader("max-forwards");break;case"www-authenticate":c.setHeader("www-authenticate",p),a=c.parseHeader("www-authenticate");break;case"proxy-authenticate":c.setHeader("proxy-authenticate",p),a=c.parseHeader("proxy-authenticate");break;case"session-expires":case"x":c.setHeader("session-expires",p),a=c.parseHeader("session-expires"),a&&(c.session_expires=a.expires,c.session_expires_refresher=a.refresher);break;case"refer-to":case"r":c.setHeader("refer-to",p),a=c.parseHeader("refer-to"),a&&(c.refer_to=a);break;case"replaces":c.setHeader("replaces",p),a=c.parseHeader("replaces"),a&&(c.replaces=a);break;case"event":case"o":c.setHeader("event",p),a=c.parseHeader("event"),a&&(c.event=a);break;default:c.addHeader(e,p),a=0}return a===void 0?{error:'error parsing header "'.concat(e,'"')}:!0}function Jl(c,s){var i;if(typeof Symbol>"u"||c[Symbol.iterator]==null){if(Array.isArray(c)||(i=Np(c))||s&&c&&typeof c.length=="number"){i&&(c=i);var l=0,a=function(){};return{s:a,n:function(){return l>=c.length?{done:!0}:{done:!1,value:c[l++]}},e:function(n){throw n},f:a}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
|
64
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var _=!0,e=!1,p;return{s:function(){i=c[Symbol.iterator]()},n:function(){var n=i.next();return _=n.done,n},e:function(n){e=!0,p=n},f:function(){try{!_&&i.return!=null&&i.return()}finally{if(e)throw p}}}}function Np(c,s){if(c){if(typeof c=="string")return of(c,s);var i=Object.prototype.toString.call(c).slice(8,-1);if(i==="Object"&&c.constructor&&(i=c.constructor.name),i==="Map"||i==="Set")return Array.from(c);if(i==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i))return of(c,s)}}function of(c,s){(s==null||s>c.length)&&(s=c.length);for(var i=0,l=new Array(s);i<s;i++)l[i]=c[i];return l}var Up=ft,uf=it,cf=cs,Ho=It(),Fo=new Up("sanityCheck"),Pp=[Vp],xp=[Lp,$p,Hp,Fp],Mp=[jp,qp],Be,ts,ff,kp=function(c,s,i){Be=c,ts=s,ff=i;var l=Jl(Pp),a;try{for(l.s();!(a=l.n()).done;){var _=a.value;if(_()===!1)return!1}}catch(m){l.e(m)}finally{l.f()}if(Be instanceof cf.IncomingRequest){var e=Jl(xp),p;try{for(e.s();!(p=e.n()).done;){var g=p.value;if(g()===!1)return!1}}catch(m){e.e(m)}finally{e.f()}}else if(Be instanceof cf.IncomingResponse){var n=Jl(Mp),v;try{for(n.s();!(v=n.n()).done;){var S=v.value;if(S()===!1)return!1}}catch(m){n.e(m)}finally{n.f()}}return!0};function Lp(){if(Be.s("to").uri.scheme!=="sip")return xr(416),!1}function $p(){if(!Be.to_tag&&Be.call_id.substr(0,5)===ts.configuration.jssip_id)return xr(482),!1}function Hp(){var c=Ho.str_utf8_length(Be.body),s=Be.getHeader("content-length");if(c<s)return xr(400),!1}function Fp(){var c=Be.from_tag,s=Be.call_id,i=Be.cseq,l;if(!Be.to_tag)if(Be.method===uf.INVITE){if(ts._transactions.ist[Be.via_branch])return!1;for(var a in ts._transactions.ist)if(Object.prototype.hasOwnProperty.call(ts._transactions.ist,a)&&(l=ts._transactions.ist[a],l.request.from_tag===c&&l.request.call_id===s&&l.request.cseq===i))return xr(482),!1}else{if(ts._transactions.nist[Be.via_branch])return!1;for(var _ in ts._transactions.nist)if(Object.prototype.hasOwnProperty.call(ts._transactions.nist,_)&&(l=ts._transactions.nist[_],l.request.from_tag===c&&l.request.call_id===s&&l.request.cseq===i))return xr(482),!1}}function jp(){if(Be.getHeaders("via").length>1)return Fo.debug("more than one Via header field present in the response, dropping the response"),!1}function qp(){var c=Ho.str_utf8_length(Be.body),s=Be.getHeader("content-length");if(c<s)return Fo.debug("message body length is lower than the value in Content-Length header field, dropping the response"),!1}function Vp(){for(var c=["from","to","call_id","cseq","via"],s=0,i=c;s<i.length;s++){var l=i[s];if(!Be.hasHeader(l))return Fo.debug("missing mandatory header field : ".concat(l,", dropping the response")),!1}}function xr(c){var s=Be.getHeaders("via"),i,l="SIP/2.0 ".concat(c," ").concat(uf.REASON_PHRASE[c],`\r
|
65
|
+
`),a=Jl(s),_;try{for(a.s();!(_=a.n()).done;){var e=_.value;l+="Via: ".concat(e,`\r
|
66
|
+
`)}}catch(p){a.e(p)}finally{a.f()}i=Be.getHeader("To"),Be.to_tag||(i+=";tag=".concat(Ho.newTag())),l+="To: ".concat(i,`\r
|
67
|
+
`),l+="From: ".concat(Be.getHeader("From"),`\r
|
68
|
+
`),l+="Call-ID: ".concat(Be.call_id,`\r
|
69
|
+
`),l+="CSeq: ".concat(Be.cseq," ").concat(Be.method,`\r
|
70
|
+
`),l+=`\r
|
71
|
+
`,ff.send(l)}var jo={};function _f(c,s){var i;if(typeof Symbol>"u"||c[Symbol.iterator]==null){if(Array.isArray(c)||(i=Bp(c))||s&&c&&typeof c.length=="number"){i&&(c=i);var l=0,a=function(){};return{s:a,n:function(){return l>=c.length?{done:!0}:{done:!1,value:c[l++]}},e:function(n){throw n},f:a}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
|
72
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var _=!0,e=!1,p;return{s:function(){i=c[Symbol.iterator]()},n:function(){var n=i.next();return _=n.done,n},e:function(n){e=!0,p=n},f:function(){try{!_&&i.return!=null&&i.return()}finally{if(e)throw p}}}}function Bp(c,s){if(c){if(typeof c=="string")return hf(c,s);var i=Object.prototype.toString.call(c).slice(8,-1);if(i==="Object"&&c.constructor&&(i=c.constructor.name),i==="Map"||i==="Set")return Array.from(c);if(i==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i))return hf(c,s)}}function hf(c,s){(s==null||s>c.length)&&(s=c.length);for(var i=0,l=new Array(s);i<s;i++)l[i]=c[i];return l}var qn=It(),on=it,qo=Zt(),df=Os(),Vo=Mo,Bo=ws;jo.settings={authorization_user:null,password:null,realm:null,ha1:null,authorization_jwt:null,display_name:null,uri:null,contact_uri:null,instance_id:null,use_preloaded_route:!1,session_timers:!0,session_timers_refresh_method:on.UPDATE,session_timers_force_refresher:!1,no_answer_timeout:60,register:!0,register_expires:600,registrar_server:null,sockets:null,connection_recovery_max_interval:on.CONNECTION_RECOVERY_MAX_INTERVAL,connection_recovery_min_interval:on.CONNECTION_RECOVERY_MIN_INTERVAL,extra_headers:null,via_host:"".concat(qn.createRandomToken(12),".invalid")};var zl={mandatory:{sockets:function(s){var i=[];if(Vo.isSocket(s))i.push({socket:s});else if(Array.isArray(s)&&s.length){var l=_f(s),a;try{for(l.s();!(a=l.n()).done;){var _=a.value;Object.prototype.hasOwnProperty.call(_,"socket")&&Vo.isSocket(_.socket)?i.push(_):Vo.isSocket(_)&&i.push({socket:_})}}catch(e){l.e(e)}finally{l.f()}}else return;return i},uri:function(s){/^sip:/i.test(s)||(s="".concat(on.SIP,":").concat(s));var i=df.parse(s);if(i)return i.user?i:void 0}},optional:{authorization_user:function(s){if(qo.parse('"'.concat(s,'"'),"quoted_string")!==-1)return s},authorization_jwt:function(s){if(typeof s=="string")return s},user_agent:function(s){if(typeof s=="string")return s},connection_recovery_max_interval:function(s){if(qn.isDecimal(s)){var i=Number(s);if(i>0)return i}},connection_recovery_min_interval:function(s){if(qn.isDecimal(s)){var i=Number(s);if(i>0)return i}},contact_uri:function(s){if(typeof s=="string"){var i=qo.parse(s,"SIP_URI");if(i!==-1)return i}},display_name:function(s){return s},instance_id:function(s){if(/^uuid:/i.test(s)&&(s=s.substr(5)),qo.parse(s,"uuid")!==-1)return s},no_answer_timeout:function(s){if(qn.isDecimal(s)){var i=Number(s);if(i>0)return i}},session_timers:function(s){if(typeof s=="boolean")return s},session_timers_refresh_method:function(s){if(typeof s=="string"&&(s=s.toUpperCase(),s===on.INVITE||s===on.UPDATE))return s},session_timers_force_refresher:function(s){if(typeof s=="boolean")return s},password:function(s){return String(s)},realm:function(s){return String(s)},ha1:function(s){return String(s)},register:function(s){if(typeof s=="boolean")return s},register_expires:function(s){if(qn.isDecimal(s)){var i=Number(s);if(i>0)return i}},registrar_server:function(s){/^sip:/i.test(s)||(s="".concat(on.SIP,":").concat(s));var i=df.parse(s);if(i)return i.user?void 0:i},use_preloaded_route:function(s){if(typeof s=="boolean")return s},extra_headers:function(s){var i=[];if(Array.isArray(s)&&s.length){var l=_f(s),a;try{for(l.s();!(a=l.n()).done;){var _=a.value;typeof _=="string"&&i.push(_)}}catch(e){l.e(e)}finally{l.f()}}else return;return i}}};jo.load=function(c,s){for(var i in zl.mandatory)if(s.hasOwnProperty(i)){var l=s[i],a=zl.mandatory[i](l);if(a!==void 0)c[i]=a;else throw new Bo.ConfigurationError(i,l)}else throw new Bo.ConfigurationError(i);for(var _ in zl.optional)if(s.hasOwnProperty(_)){var e=s[_];if(qn.isEmpty(e))continue;var p=zl.optional[_](e);if(p!==void 0)c[_]=p;else throw new Bo.ConfigurationError(_,e)}};function Xl(c){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?Xl=function(i){return typeof i}:Xl=function(i){return i&&typeof Symbol=="function"&&i.constructor===Symbol&&i!==Symbol.prototype?"symbol":typeof i},Xl(c)}function Gp(c,s){if(!(c instanceof s))throw new TypeError("Cannot call a class as a function")}function pf(c,s){for(var i=0;i<s.length;i++){var l=s[i];l.enumerable=l.enumerable||!1,l.configurable=!0,"value"in l&&(l.writable=!0),Object.defineProperty(c,l.key,l)}}function mf(c,s,i){return s&&pf(c.prototype,s),i&&pf(c,i),c}function Wp(c,s){if(typeof s!="function"&&s!==null)throw new TypeError("Super expression must either be null or a function");c.prototype=Object.create(s&&s.prototype,{constructor:{value:c,writable:!0,configurable:!0}}),s&&Go(c,s)}function Go(c,s){return Go=Object.setPrototypeOf||function(l,a){return l.__proto__=a,l},Go(c,s)}function Kp(c){var s=Jp();return function(){var l=Ql(c),a;if(s){var _=Ql(this).constructor;a=Reflect.construct(l,arguments,_)}else a=l.apply(this,arguments);return Yp(this,a)}}function Yp(c,s){return s&&(Xl(s)==="object"||typeof s=="function")?s:gf(c)}function gf(c){if(c===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return c}function Jp(){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 Ql(c){return Ql=Object.setPrototypeOf?Object.getPrototypeOf:function(i){return i.__proto__||Object.getPrototypeOf(i)},Ql(c)}var zp=ct.EventEmitter,Xp=ft,mt=it,Qp=Hh,Tf=Yd,vf=ap,Ef=vp,Wo=Rr,Zp=Ip,Zl=It(),em=ws,tm=Os(),sm=rf,Ko=cs,nm=kp,Yo=jo,Ke=new Xp("UA"),gt={STATUS_INIT:0,STATUS_READY:1,STATUS_USER_CLOSED:2,STATUS_NOT_READY:3,CONFIGURATION_ERROR:1,NETWORK_ERROR:2},rm=function(c){Wp(i,c);var s=Kp(i);mf(i,null,[{key:"C",get:function(){return gt}}]);function i(l){var a;if(Gp(this,i),Ke.debug("new() [configuration:%o]",l),a=s.call(this),a._cache={credentials:{}},a._configuration=Object.assign({},Yo.settings),a._dynConfiguration={},a._dialogs={},a._applicants={},a._sessions={},a._transport=null,a._contact=null,a._status=gt.STATUS_INIT,a._error=null,a._transactions={nist:{},nict:{},ist:{},ict:{}},a._data={},a._closeTimer=null,l===void 0)throw new TypeError("Not enough arguments");try{a._loadConfig(l)}catch(_){throw a._status=gt.STATUS_NOT_READY,a._error=gt.CONFIGURATION_ERROR,_}return a._registrator=new Qp(gf(a)),a}return mf(i,[{key:"start",value:function(){Ke.debug("start()"),this._status===gt.STATUS_INIT?this._transport.connect():this._status===gt.STATUS_USER_CLOSED?(Ke.debug("restarting UA"),this._closeTimer!==null&&(clearTimeout(this._closeTimer),this._closeTimer=null,this._transport.disconnect()),this._status=gt.STATUS_INIT,this._transport.connect()):this._status===gt.STATUS_READY?Ke.debug("UA is in READY status, not restarted"):Ke.debug("ERROR: connection is down, Auto-Recovery system is trying to reconnect"),this._dynConfiguration.register=this._configuration.register}},{key:"register",value:function(){Ke.debug("register()"),this._dynConfiguration.register=!0,this._registrator.register()}},{key:"unregister",value:function(a){Ke.debug("unregister()"),this._dynConfiguration.register=!1,this._registrator.unregister(a)}},{key:"registrator",value:function(){return this._registrator}},{key:"isRegistered",value:function(){return this._registrator.registered}},{key:"isConnected",value:function(){return this._transport.isConnected()}},{key:"call",value:function(a,_){Ke.debug("call()");var e=new Tf(this);return e.connect(a,_),e}},{key:"sendMessage",value:function(a,_,e){Ke.debug("sendMessage()");var p=new vf(this);return p.send(a,_,e),p}},{key:"sendOptions",value:function(a,_,e){Ke.debug("sendOptions()");var p=new Ef(this);return p.send(a,_,e),p}},{key:"terminateSessions",value:function(a){Ke.debug("terminateSessions()");for(var _ in this._sessions)this._sessions[_].isEnded()||this._sessions[_].terminate(a)}},{key:"stop",value:function(){var a=this;if(Ke.debug("stop()"),this._dynConfiguration={},this._status===gt.STATUS_USER_CLOSED){Ke.debug("UA already closed");return}this._registrator.close();var _=Object.keys(this._sessions).length;for(var e in this._sessions)if(Object.prototype.hasOwnProperty.call(this._sessions,e)){Ke.debug("closing session ".concat(e));try{this._sessions[e].terminate()}catch{}}for(var p in this._applicants)if(Object.prototype.hasOwnProperty.call(this._applicants,p))try{this._applicants[p].close()}catch{}this._status=gt.STATUS_USER_CLOSED;var g=Object.keys(this._transactions.nict).length+Object.keys(this._transactions.nist).length+Object.keys(this._transactions.ict).length+Object.keys(this._transactions.ist).length;g===0&&_===0?this._transport.disconnect():this._closeTimer=setTimeout(function(){a._closeTimer=null,a._transport.disconnect()},2e3)}},{key:"normalizeTarget",value:function(a){return Zl.normalizeTarget(a,this._configuration.hostport_params)}},{key:"get",value:function(a){switch(a){case"authorization_user":return this._configuration.authorization_user;case"realm":return this._configuration.realm;case"ha1":return this._configuration.ha1;case"authorization_jwt":return this._configuration.authorization_jwt;default:Ke.warn('get() | cannot get "%s" parameter in runtime',a);return}}},{key:"set",value:function(a,_){switch(a){case"authorization_user":{this._configuration.authorization_user=String(_);break}case"password":{this._configuration.password=String(_);break}case"realm":{this._configuration.realm=String(_);break}case"ha1":{this._configuration.ha1=String(_),this._configuration.password=null;break}case"authorization_jwt":{this._configuration.authorization_jwt=String(_);break}case"display_name":{this._configuration.display_name=_;break}default:return Ke.warn('set() | cannot set "%s" parameter in runtime',a),!1}return!0}},{key:"newTransaction",value:function(a){this._transactions[a.type][a.id]=a,this.emit("newTransaction",{transaction:a})}},{key:"destroyTransaction",value:function(a){delete this._transactions[a.type][a.id],this.emit("transactionDestroyed",{transaction:a})}},{key:"newDialog",value:function(a){this._dialogs[a.id]=a}},{key:"destroyDialog",value:function(a){delete this._dialogs[a.id]}},{key:"newMessage",value:function(a,_){this._applicants[a]=a,this.emit("newMessage",_)}},{key:"newOptions",value:function(a,_){this._applicants[a]=a,this.emit("newOptions",_)}},{key:"destroyMessage",value:function(a){delete this._applicants[a]}},{key:"newRTCSession",value:function(a,_){this._sessions[a.id]=a,this.emit("newRTCSession",_)}},{key:"destroyRTCSession",value:function(a){delete this._sessions[a.id]}},{key:"registered",value:function(a){this.emit("registered",a)}},{key:"unregistered",value:function(a){this.emit("unregistered",a)}},{key:"registrationFailed",value:function(a){this.emit("registrationFailed",a)}},{key:"receiveRequest",value:function(a){var _=a.method;if(a.ruri.user!==this._configuration.uri.user&&a.ruri.user!==this._contact.uri.user){Ke.debug("Request-URI does not point to us"),a.method!==mt.ACK&&a.reply_sl(404);return}if(a.ruri.scheme===mt.SIPS){a.reply_sl(416);return}if(!Wo.checkTransaction(this,a)){if(_===mt.INVITE?new Wo.InviteServerTransaction(this,this._transport,a):_!==mt.ACK&&_!==mt.CANCEL&&new Wo.NonInviteServerTransaction(this,this._transport,a),_===mt.OPTIONS){if(this.listeners("newOptions").length===0){a.reply(200);return}var e=new Ef(this);e.init_incoming(a)}else if(_===mt.MESSAGE){if(this.listeners("newMessage").length===0){a.reply(405);return}var p=new vf(this);p.init_incoming(a)}else if(_===mt.INVITE&&!a.to_tag&&this.listeners("newRTCSession").length===0){a.reply(405);return}var g,n;if(a.to_tag)g=this._findDialog(a.call_id,a.from_tag,a.to_tag),g?g.receiveRequest(a):_===mt.NOTIFY?(n=this._findSession(a),n?n.receiveRequest(a):(Ke.debug("received NOTIFY request for a non existent subscription"),a.reply(481,"Subscription does not exist"))):_!==mt.ACK&&a.reply(481);else switch(_){case mt.INVITE:if(window.RTCPeerConnection)if(a.hasHeader("replaces")){var v=a.replaces;g=this._findDialog(v.call_id,v.from_tag,v.to_tag),g?(n=g.owner,n.isEnded()?a.reply(603):n.receiveRequest(a)):a.reply(481)}else n=new Tf(this),n.init_incoming(a);else Ke.warn("INVITE received but WebRTC is not supported"),a.reply(488);break;case mt.BYE:a.reply(481);break;case mt.CANCEL:n=this._findSession(a),n?n.receiveRequest(a):Ke.debug("received CANCEL request for a non existent session");break;case mt.ACK:break;case mt.NOTIFY:this.emit("sipEvent",{event:a.event,request:a}),a.reply(200);break;default:a.reply(405);break}}}},{key:"_findSession",value:function(a){var _=a.call_id,e=a.from_tag,p=a.to_tag,g=_+e,n=this._sessions[g],v=_+p,S=this._sessions[v];return n||S||null}},{key:"_findDialog",value:function(a,_,e){var p=a+_+e,g=this._dialogs[p];return g||(p=a+e+_,g=this._dialogs[p],g||null)}},{key:"_loadConfig",value:function(a){try{Yo.load(this._configuration,a)}catch(v){throw v}this._configuration.display_name===0&&(this._configuration.display_name="0"),this._configuration.instance_id||(this._configuration.instance_id=Zl.newUUID()),this._configuration.jssip_id=Zl.createRandomToken(5);var _=this._configuration.uri.clone();_.user=null,this._configuration.hostport_params=_.toString().replace(/^sip:/i,"");try{this._transport=new Zp(this._configuration.sockets,{max_interval:this._configuration.connection_recovery_max_interval,min_interval:this._configuration.connection_recovery_min_interval}),this._transport.onconnecting=im.bind(this),this._transport.onconnect=lm.bind(this),this._transport.ondisconnect=am.bind(this),this._transport.ondata=om.bind(this)}catch(v){throw Ke.warn(v),new em.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){var e=this._configuration.uri.clone();e.user=null,e.clearParams(),e.clearHeaders(),this._configuration.registrar_server=e}this._configuration.no_answer_timeout*=1e3,this._configuration.contact_uri?this._configuration.via_host=this._configuration.contact_uri.host:this._configuration.contact_uri=new tm("sip",Zl.createRandomToken(8),this._configuration.via_host,null,{transport:"ws"}),this._contact={pub_gruu:null,temp_gruu:null,uri:this._configuration.contact_uri,toString:function(){var S=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},m=S.anonymous||null,C=S.outbound||null,A="<";return m?A+=this.temp_gruu||"sip:anonymous@anonymous.invalid;transport=ws":A+=this.pub_gruu||this.uri.toString(),C&&(m?!this.temp_gruu:!this.pub_gruu)&&(A+=";ob"),A+=">",A}};var p=["authorization_user","password","realm","ha1","authorization_jwt","display_name","register"];for(var g in this._configuration)Object.prototype.hasOwnProperty.call(this._configuration,g)&&(p.indexOf(g)!==-1?Object.defineProperty(this._configuration,g,{writable:!0,configurable:!1}):Object.defineProperty(this._configuration,g,{writable:!1,configurable:!1}));Ke.debug("configuration parameters after validation:");for(var n in this._configuration)if(Object.prototype.hasOwnProperty.call(Yo.settings,n))switch(n){case"uri":case"registrar_server":Ke.debug("- ".concat(n,": ").concat(this._configuration[n]));break;case"password":case"ha1":case"authorization_jwt":Ke.debug("- ".concat(n,": NOT SHOWN"));break;default:Ke.debug("- ".concat(n,": ").concat(JSON.stringify(this._configuration[n])))}}},{key:"C",get:function(){return gt}},{key:"status",get:function(){return this._status}},{key:"contact",get:function(){return this._contact}},{key:"configuration",get:function(){return this._configuration}},{key:"transport",get:function(){return this._transport}}]),i}(zp);function im(c){this.emit("connecting",c)}function lm(c){this._status!==gt.STATUS_USER_CLOSED&&(this._status=gt.STATUS_READY,this._error=null,this.emit("connected",c),this._dynConfiguration.register&&this._registrator.register())}function am(c){for(var s=["nict","ict","nist","ist"],i=0,l=s;i<l.length;i++){var a=l[i];for(var _ in this._transactions[a])Object.prototype.hasOwnProperty.call(this._transactions[a],_)&&this._transactions[a][_].onTransportError()}this.emit("disconnected",c),this._registrator.onTransportClosed(),this._status!==gt.STATUS_USER_CLOSED&&(this._status=gt.STATUS_NOT_READY,this._error=gt.NETWORK_ERROR)}function om(c){var s=c.transport,i=c.message;if(i=sm.parseMessage(i,this),!!i&&!(this._status===gt.STATUS_USER_CLOSED&&i instanceof Ko.IncomingRequest)&&nm(i,this,s)){if(i instanceof Ko.IncomingRequest)i.transport=s,this.receiveRequest(i);else if(i instanceof Ko.IncomingResponse){var l;switch(i.method){case mt.INVITE:l=this._transactions.ict[i.via_branch],l&&l.receiveResponse(i);break;case mt.ACK:break;default:l=this._transactions.nict[i.via_branch],l&&l.receiveResponse(i);break}}}}function um(c,s){if(!(c instanceof s))throw new TypeError("Cannot call a class as a function")}function Sf(c,s){for(var i=0;i<s.length;i++){var l=s[i];l.enumerable=l.enumerable||!1,l.configurable=!0,"value"in l&&(l.writable=!0),Object.defineProperty(c,l.key,l)}}function cm(c,s,i){return s&&Sf(c.prototype,s),i&&Sf(c,i),c}var fm=ft,_m=Zt(),Ut=new fm("WebSocketInterface"),hm=function(){function c(s){um(this,c),Ut.debug('new() [url:"%s"]',s),this._url=s,this._sip_uri=null,this._via_transport=null,this._ws=null;var i=_m.parse(s,"absoluteURI");if(i===-1)throw Ut.warn("invalid WebSocket URI: ".concat(s)),new TypeError("Invalid argument: ".concat(s));if(i.scheme!=="wss"&&i.scheme!=="ws")throw Ut.warn("invalid WebSocket URI scheme: ".concat(i.scheme)),new TypeError("Invalid argument: ".concat(s));this._sip_uri="sip:".concat(i.host).concat(i.port?":".concat(i.port):"",";transport=ws"),this._via_transport=i.scheme.toUpperCase()}return cm(c,[{key:"connect",value:function(){if(Ut.debug("connect()"),this.isConnected()){Ut.debug("WebSocket ".concat(this._url," is already connected"));return}else if(this.isConnecting()){Ut.debug("WebSocket ".concat(this._url," is connecting"));return}this._ws&&this.disconnect(),Ut.debug("connecting to WebSocket ".concat(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(i){this._onError(i)}}},{key:"disconnect",value:function(){Ut.debug("disconnect()"),this._ws&&(this._ws.onopen=function(){},this._ws.onclose=function(){},this._ws.onmessage=function(){},this._ws.onerror=function(){},this._ws.close(),this._ws=null)}},{key:"send",value:function(i){return Ut.debug("send()"),this.isConnected()?(this._ws.send(i),!0):(Ut.warn("unable to send message, WebSocket is not open"),!1)}},{key:"isConnected",value:function(){return this._ws&&this._ws.readyState===this._ws.OPEN}},{key:"isConnecting",value:function(){return this._ws&&this._ws.readyState===this._ws.CONNECTING}},{key:"_onOpen",value:function(){Ut.debug("WebSocket ".concat(this._url," connected")),this.onconnect()}},{key:"_onClose",value:function(i){var l=i.wasClean,a=i.code,_=i.reason;Ut.debug("WebSocket ".concat(this._url," closed")),l===!1&&Ut.debug("WebSocket abrupt disconnection"),this.ondisconnect(!l,a,_)}},{key:"_onMessage",value:function(i){var l=i.data;Ut.debug("received WebSocket message"),this.ondata(l)}},{key:"_onError",value:function(i){Ut.warn("WebSocket ".concat(this._url," error: "),i)}},{key:"via_transport",get:function(){return this._via_transport},set:function(i){this._via_transport=i.toUpperCase()}},{key:"sip_uri",get:function(){return this._sip_uri}},{key:"url",get:function(){return this._url}}]),c}(),Jo=pl,dm=it,pm=ws,mm=It(),gm=rm,Tm=Os(),vm=io(),Em=Zt(),Sm=hm,ym=Hn("JsSIP");ym("version %s",Jo.version);var yf={C:dm,Exceptions:pm,Utils:mm,UA:gm,URI:Tm,NameAddrHeader:vm,WebSocketInterface:Sm,Grammar:Em,debug:Hn,get name(){return Jo.title},get version(){return Jo.version}};const Vn=Hn,Bn="JsSIP";var ut=class{constructor(s){s?(this._debug=Vn.default(`${Bn}:${s}`),this._warn=Vn.default(`${Bn}:WARN:${s}`),this._error=Vn.default(`${Bn}:ERROR:${s}`)):(this._debug=Vn.default(Bn),this._warn=Vn.default(`${Bn}:WARN`),this._error=Vn.default(`${Bn}:ERROR`)),this._debug.log=console.info.bind(console),this._warn.log=console.warn.bind(console),this._error.log=console.error.bind(console)}get debug(){return this._debug}get warn(){return this._warn}get error(){return this._error}};const ea=Le(ut),Af=pl;var xe={USER_AGENT:`${Af.title} ${Af.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};const F=Le(xe);var rt={},Cf={},zo,Rf;function Xo(){if(Rf)return zo;Rf=1;const c=ds(),s=Gt();return zo=class k_{static parse(l){if(l=s.parse(l,"Name_Addr_Header"),l!==-1)return l}constructor(l,a,_){if(!l||!(l instanceof c))throw new TypeError('missing or invalid "uri" parameter');this._uri=l,this._parameters={},this.display_name=a;for(const e in _)Object.prototype.hasOwnProperty.call(_,e)&&this.setParam(e,_[e])}get uri(){return this._uri}get display_name(){return this._display_name}set display_name(l){this._display_name=l===0?"0":l}setParam(l,a){l&&(this._parameters[l.toLowerCase()]=typeof a>"u"||a===null?null:a.toString())}getParam(l){if(l)return this._parameters[l.toLowerCase()]}hasParam(l){if(l)return this._parameters.hasOwnProperty(l.toLowerCase())&&!0||!1}deleteParam(l){if(l=l.toLowerCase(),this._parameters.hasOwnProperty(l)){const a=this._parameters[l];return delete this._parameters[l],a}}clearParams(){this._parameters={}}clone(){return new k_(this._uri.clone(),this._display_name,JSON.parse(JSON.stringify(this._parameters)))}_quote(l){return l.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}toString(){let l=this._display_name?`"${this._quote(this._display_name)}" `:"";l+=`<${this._uri.toString()}>`;for(const a in this._parameters)Object.prototype.hasOwnProperty.call(this._parameters,a)&&(l+=`;${a}`,this._parameters[a]!==null&&(l+=`=${this._parameters[a]}`));return l}},zo}var If;function Gt(){if(If)return Cf;If=1;function c(e){return'"'+e.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 s={parse:function(e,p){var g={CRLF:C,DIGIT:A,ALPHA:R,HEXDIG:I,WSP:V,OCTET:W,DQUOTE:oe,SP:x,HTAB:$,alphanum:Re,reserved:be,unreserved:H,mark:D,escaped:L,LWS:q,SWS:j,HCOLON:B,TEXT_UTF8_TRIM:Q,TEXT_UTF8char:Z,UTF8_NONASCII:U,UTF8_CONT:se,LHEX:Dt,token:N,token_nodot:z,separators:re,word:ae,STAR:Te,SLASH:De,EQUAL:Ce,LPAREN:He,RPAREN:we,RAQUOT:Se,LAQUOT:ot,COMMA:Ue,SEMI:le,COLON:Ae,LDQUOT:Oe,RDQUOT:Pe,comment:ve,ctext:he,quoted_string:pe,quoted_string_clean:Ne,qdtext:Me,quoted_pair:We,SIP_URI_noparams:Fe,SIP_URI:Vt,uri_scheme:dt,uri_scheme_sips:ei,uri_scheme_sip:Xn,userinfo:gn,user:Tn,user_unreserved:ys,password:Qn,hostport:Fs,host:js,hostname:vn,domainlabel:En,toplabel:ge,IPv6reference:Rt,IPv6address:As,h16:de,ls32:Nt,IPv4address:qs,dec_octet:Cs,port:ti,uri_parameters:si,uri_parameter:Zn,transport_param:ni,user_param:ri,method_param:ii,ttl_param:li,maddr_param:ai,lr_param:oi,other_param:Vs,pname:ui,pvalue:ci,paramchar:rs,param_unreserved:fi,headers:_i,header:is,hname:Ra,hvalue:hi,hnv_unreserved:Bs,Request_Response:di,Request_Line:pi,Request_URI:mi,absoluteURI:Gs,hier_part:gi,net_path:Ws,abs_path:Sn,opaque_part:Ti,uric:ls,uric_no_slash:er,path_segments:Ks,segment:yn,param:tr,pchar:Ys,scheme:vi,authority:Ei,srvr:sr,reg_name:Si,query:yi,SIP_Version:nr,INVITEm:Ai,ACKm:Ci,OPTIONSm:Ri,BYEm:Ii,CANCELm:bi,REGISTERm:wi,SUBSCRIBEm:An,NOTIFYm:Oi,REFERm:Di,Method:Cn,Status_Line:Ni,Status_Code:Ia,extension_code:ba,Reason_Phrase:wa,Allow_Events:rr,Call_ID:Rs,Contact:ir,contact_param:Js,name_addr:as,display_name:Rn,contact_params:Jt,c_p_q:Ui,c_p_expires:et,delta_seconds:os,qvalue:Oa,generic_param:tt,gen_value:lr,Content_Disposition:Da,disp_type:Na,disp_param:Pi,handling_param:Ua,Content_Encoding:Pa,Content_Length:xa,Content_Type:Ma,media_type:xi,m_type:In,discrete_type:Mi,composite_type:ki,extension_token:zs,x_token:Li,m_subtype:ka,m_parameter:ar,m_value:La,CSeq:Lu,CSeq_value:Xs,Expires:$u,Event:$i,event_type:Is,From:Hu,from_param:Hi,tag_param:Fi,Max_Forwards:Fu,Min_Expires:ji,Name_Addr_Header:$a,Proxy_Authenticate:bn,challenge:Qs,other_challenge:qi,auth_param:Zs,digest_cln:wn,realm:On,realm_value:Vi,domain:Bi,URI:Dn,nonce:Gi,nonce_value:Wi,opaque:Ki,stale:Nn,algorithm:Ha,qop_options:Fa,qop_value:bs,Proxy_Require:ju,Record_Route:Yi,rec_route:Un,Reason:qu,reason_param:Ji,reason_cause:Pn,Require:Vu,Route:ja,route_param:en,Subscription_State:qa,substate_value:Va,subexp_params:zi,event_reason_value:Ba,Subject:Xi,Supported:Bu,To:or,to_param:xn,Via:Ga,via_param:Mn,via_params:ur,via_ttl:Qi,via_maddr:Zi,via_received:el,via_branch:tl,response_port:sl,rport:nl,sent_protocol:rl,protocol_name:il,transport:ll,sent_by:cr,via_host:Wa,via_port:Ka,ttl:fr,WWW_Authenticate:al,Session_Expires:Ya,s_e_expires:Ja,s_e_params:_r,s_e_refresher:za,extension_header:Gu,header_value:ol,message_body:zt,uuid_URI:Xa,uuid:ul,hex4:Xt,hex8:Qa,hex12:cl,Refer_To:fl,Replaces:Za,call_id:_l,replaces_param:hr,to_tag:eo,from_tag:to,early_flag:hl};if(p!==void 0){if(g[p]===void 0)throw new Error("Invalid rule name: "+c(p)+".")}else p="CRLF";var n=0,v=0,S=[];function m(t){n<v||(n>v&&(v=n,S=[]),S.push(t))}function C(){var t;return e.substr(n,2)===`\r
|
73
|
+
`?(t=`\r
|
74
|
+
`,n+=2):(t=null,m('"\\r\\n"')),t}function A(){var t;return/^[0-9]/.test(e.charAt(n))?(t=e.charAt(n),n++):(t=null,m("[0-9]")),t}function R(){var t;return/^[a-zA-Z]/.test(e.charAt(n))?(t=e.charAt(n),n++):(t=null,m("[a-zA-Z]")),t}function I(){var t;return/^[0-9a-fA-F]/.test(e.charAt(n))?(t=e.charAt(n),n++):(t=null,m("[0-9a-fA-F]")),t}function V(){var t;return t=x(),t===null&&(t=$()),t}function W(){var t;return/^[\0-\xFF]/.test(e.charAt(n))?(t=e.charAt(n),n++):(t=null,m("[\\0-\\xFF]")),t}function oe(){var t;return/^["]/.test(e.charAt(n))?(t=e.charAt(n),n++):(t=null,m('["]')),t}function x(){var t;return console.log("pos",n),console.log("input.charCodeAt(pos)",e.charAt(n)),e.charCodeAt(n)===32?(t=" ",n++):(t=null,m('" "')),t}function $(){var t;return e.charCodeAt(n)===9?(t=" ",n++):(t=null,m('"\\t"')),t}function Re(){var t;return/^[a-zA-Z0-9]/.test(e.charAt(n))?(t=e.charAt(n),n++):(t=null,m("[a-zA-Z0-9]")),t}function be(){var t;return e.charCodeAt(n)===59?(t=";",n++):(t=null,m('";"')),t===null&&(e.charCodeAt(n)===47?(t="/",n++):(t=null,m('"/"')),t===null&&(e.charCodeAt(n)===63?(t="?",n++):(t=null,m('"?"')),t===null&&(e.charCodeAt(n)===58?(t=":",n++):(t=null,m('":"')),t===null&&(e.charCodeAt(n)===64?(t="@",n++):(t=null,m('"@"')),t===null&&(e.charCodeAt(n)===38?(t="&",n++):(t=null,m('"&"')),t===null&&(e.charCodeAt(n)===61?(t="=",n++):(t=null,m('"="')),t===null&&(e.charCodeAt(n)===43?(t="+",n++):(t=null,m('"+"')),t===null&&(e.charCodeAt(n)===36?(t="$",n++):(t=null,m('"$"')),t===null&&(e.charCodeAt(n)===44?(t=",",n++):(t=null,m('","'))))))))))),t}function H(){var t;return t=Re(),t===null&&(t=D()),t}function D(){var t;return e.charCodeAt(n)===45?(t="-",n++):(t=null,m('"-"')),t===null&&(e.charCodeAt(n)===95?(t="_",n++):(t=null,m('"_"')),t===null&&(e.charCodeAt(n)===46?(t=".",n++):(t=null,m('"."')),t===null&&(e.charCodeAt(n)===33?(t="!",n++):(t=null,m('"!"')),t===null&&(e.charCodeAt(n)===126?(t="~",n++):(t=null,m('"~"')),t===null&&(e.charCodeAt(n)===42?(t="*",n++):(t=null,m('"*"')),t===null&&(e.charCodeAt(n)===39?(t="'",n++):(t=null,m(`"'"`)),t===null&&(e.charCodeAt(n)===40?(t="(",n++):(t=null,m('"("')),t===null&&(e.charCodeAt(n)===41?(t=")",n++):(t=null,m('")"')))))))))),t}function L(){var t,o,u,d,T;return d=n,T=n,e.charCodeAt(n)===37?(t="%",n++):(t=null,m('"%"')),t!==null?(o=I(),o!==null?(u=I(),u!==null?t=[t,o,u]:(t=null,n=T)):(t=null,n=T)):(t=null,n=T),t!==null&&(t=function(E,y){return y.join("")}(d,t)),t===null&&(n=d),t}function q(){var t,o,u,d,T,E;for(d=n,T=n,E=n,t=[],o=V();o!==null;)t.push(o),o=V();if(t!==null?(o=C(),o!==null?t=[t,o]:(t=null,n=E)):(t=null,n=E),t=t!==null?t:"",t!==null){if(u=V(),u!==null)for(o=[];u!==null;)o.push(u),u=V();else o=null;o!==null?t=[t,o]:(t=null,n=T)}else t=null,n=T;return t!==null&&(t=function(y){return" "}()),t===null&&(n=d),t}function j(){var t;return t=q(),t=t!==null?t:"",t}function B(){var t,o,u,d,T;for(d=n,T=n,t=[],o=x(),o===null&&(o=$());o!==null;)t.push(o),o=x(),o===null&&(o=$());return t!==null?(e.charCodeAt(n)===58?(o=":",n++):(o=null,m('":"')),o!==null?(u=j(),u!==null?t=[t,o,u]:(t=null,n=T)):(t=null,n=T)):(t=null,n=T),t!==null&&(t=function(E){return":"}()),t===null&&(n=d),t}function Q(){var t,o,u,d,T,E,y;if(T=n,E=n,o=Z(),o!==null)for(t=[];o!==null;)t.push(o),o=Z();else t=null;if(t!==null){for(o=[],y=n,u=[],d=q();d!==null;)u.push(d),d=q();for(u!==null?(d=Z(),d!==null?u=[u,d]:(u=null,n=y)):(u=null,n=y);u!==null;){for(o.push(u),y=n,u=[],d=q();d!==null;)u.push(d),d=q();u!==null?(d=Z(),d!==null?u=[u,d]:(u=null,n=y)):(u=null,n=y)}o!==null?t=[t,o]:(t=null,n=E)}else t=null,n=E;return t!==null&&(t=function(O){return e.substring(n,O)}(T)),t===null&&(n=T),t}function Z(){var t;return/^[!-~]/.test(e.charAt(n))?(t=e.charAt(n),n++):(t=null,m("[!-~]")),t===null&&(t=U()),t}function U(){var t;return/^[\x80-\uFFFF]/.test(e.charAt(n))?(t=e.charAt(n),n++):(t=null,m("[\\x80-\\uFFFF]")),t}function se(){var t;return/^[\x80-\xBF]/.test(e.charAt(n))?(t=e.charAt(n),n++):(t=null,m("[\\x80-\\xBF]")),t}function Dt(){var t;return t=A(),t===null&&(/^[a-f]/.test(e.charAt(n))?(t=e.charAt(n),n++):(t=null,m("[a-f]"))),t}function N(){var t,o,u;if(u=n,o=Re(),o===null&&(e.charCodeAt(n)===45?(o="-",n++):(o=null,m('"-"')),o===null&&(e.charCodeAt(n)===46?(o=".",n++):(o=null,m('"."')),o===null&&(e.charCodeAt(n)===33?(o="!",n++):(o=null,m('"!"')),o===null&&(e.charCodeAt(n)===37?(o="%",n++):(o=null,m('"%"')),o===null&&(e.charCodeAt(n)===42?(o="*",n++):(o=null,m('"*"')),o===null&&(e.charCodeAt(n)===95?(o="_",n++):(o=null,m('"_"')),o===null&&(e.charCodeAt(n)===43?(o="+",n++):(o=null,m('"+"')),o===null&&(e.charCodeAt(n)===96?(o="`",n++):(o=null,m('"`"')),o===null&&(e.charCodeAt(n)===39?(o="'",n++):(o=null,m(`"'"`)),o===null&&(e.charCodeAt(n)===126?(o="~",n++):(o=null,m('"~"')))))))))))),o!==null)for(t=[];o!==null;)t.push(o),o=Re(),o===null&&(e.charCodeAt(n)===45?(o="-",n++):(o=null,m('"-"')),o===null&&(e.charCodeAt(n)===46?(o=".",n++):(o=null,m('"."')),o===null&&(e.charCodeAt(n)===33?(o="!",n++):(o=null,m('"!"')),o===null&&(e.charCodeAt(n)===37?(o="%",n++):(o=null,m('"%"')),o===null&&(e.charCodeAt(n)===42?(o="*",n++):(o=null,m('"*"')),o===null&&(e.charCodeAt(n)===95?(o="_",n++):(o=null,m('"_"')),o===null&&(e.charCodeAt(n)===43?(o="+",n++):(o=null,m('"+"')),o===null&&(e.charCodeAt(n)===96?(o="`",n++):(o=null,m('"`"')),o===null&&(e.charCodeAt(n)===39?(o="'",n++):(o=null,m(`"'"`)),o===null&&(e.charCodeAt(n)===126?(o="~",n++):(o=null,m('"~"'))))))))))));else t=null;return t!==null&&(t=function(d){return e.substring(n,d)}(u)),t===null&&(n=u),t}function z(){var t,o,u;if(u=n,o=Re(),o===null&&(e.charCodeAt(n)===45?(o="-",n++):(o=null,m('"-"')),o===null&&(e.charCodeAt(n)===33?(o="!",n++):(o=null,m('"!"')),o===null&&(e.charCodeAt(n)===37?(o="%",n++):(o=null,m('"%"')),o===null&&(e.charCodeAt(n)===42?(o="*",n++):(o=null,m('"*"')),o===null&&(e.charCodeAt(n)===95?(o="_",n++):(o=null,m('"_"')),o===null&&(e.charCodeAt(n)===43?(o="+",n++):(o=null,m('"+"')),o===null&&(e.charCodeAt(n)===96?(o="`",n++):(o=null,m('"`"')),o===null&&(e.charCodeAt(n)===39?(o="'",n++):(o=null,m(`"'"`)),o===null&&(e.charCodeAt(n)===126?(o="~",n++):(o=null,m('"~"'))))))))))),o!==null)for(t=[];o!==null;)t.push(o),o=Re(),o===null&&(e.charCodeAt(n)===45?(o="-",n++):(o=null,m('"-"')),o===null&&(e.charCodeAt(n)===33?(o="!",n++):(o=null,m('"!"')),o===null&&(e.charCodeAt(n)===37?(o="%",n++):(o=null,m('"%"')),o===null&&(e.charCodeAt(n)===42?(o="*",n++):(o=null,m('"*"')),o===null&&(e.charCodeAt(n)===95?(o="_",n++):(o=null,m('"_"')),o===null&&(e.charCodeAt(n)===43?(o="+",n++):(o=null,m('"+"')),o===null&&(e.charCodeAt(n)===96?(o="`",n++):(o=null,m('"`"')),o===null&&(e.charCodeAt(n)===39?(o="'",n++):(o=null,m(`"'"`)),o===null&&(e.charCodeAt(n)===126?(o="~",n++):(o=null,m('"~"')))))))))));else t=null;return t!==null&&(t=function(d){return e.substring(n,d)}(u)),t===null&&(n=u),t}function re(){var t;return e.charCodeAt(n)===40?(t="(",n++):(t=null,m('"("')),t===null&&(e.charCodeAt(n)===41?(t=")",n++):(t=null,m('")"')),t===null&&(e.charCodeAt(n)===60?(t="<",n++):(t=null,m('"<"')),t===null&&(e.charCodeAt(n)===62?(t=">",n++):(t=null,m('">"')),t===null&&(e.charCodeAt(n)===64?(t="@",n++):(t=null,m('"@"')),t===null&&(e.charCodeAt(n)===44?(t=",",n++):(t=null,m('","')),t===null&&(e.charCodeAt(n)===59?(t=";",n++):(t=null,m('";"')),t===null&&(e.charCodeAt(n)===58?(t=":",n++):(t=null,m('":"')),t===null&&(e.charCodeAt(n)===92?(t="\\",n++):(t=null,m('"\\\\"')),t===null&&(t=oe(),t===null&&(e.charCodeAt(n)===47?(t="/",n++):(t=null,m('"/"')),t===null&&(e.charCodeAt(n)===91?(t="[",n++):(t=null,m('"["')),t===null&&(e.charCodeAt(n)===93?(t="]",n++):(t=null,m('"]"')),t===null&&(e.charCodeAt(n)===63?(t="?",n++):(t=null,m('"?"')),t===null&&(e.charCodeAt(n)===61?(t="=",n++):(t=null,m('"="')),t===null&&(e.charCodeAt(n)===123?(t="{",n++):(t=null,m('"{"')),t===null&&(e.charCodeAt(n)===125?(t="}",n++):(t=null,m('"}"')),t===null&&(t=x(),t===null&&(t=$())))))))))))))))))),t}function ae(){var t,o,u;if(u=n,o=Re(),o===null&&(e.charCodeAt(n)===45?(o="-",n++):(o=null,m('"-"')),o===null&&(e.charCodeAt(n)===46?(o=".",n++):(o=null,m('"."')),o===null&&(e.charCodeAt(n)===33?(o="!",n++):(o=null,m('"!"')),o===null&&(e.charCodeAt(n)===37?(o="%",n++):(o=null,m('"%"')),o===null&&(e.charCodeAt(n)===42?(o="*",n++):(o=null,m('"*"')),o===null&&(e.charCodeAt(n)===95?(o="_",n++):(o=null,m('"_"')),o===null&&(e.charCodeAt(n)===43?(o="+",n++):(o=null,m('"+"')),o===null&&(e.charCodeAt(n)===96?(o="`",n++):(o=null,m('"`"')),o===null&&(e.charCodeAt(n)===39?(o="'",n++):(o=null,m(`"'"`)),o===null&&(e.charCodeAt(n)===126?(o="~",n++):(o=null,m('"~"')),o===null&&(e.charCodeAt(n)===40?(o="(",n++):(o=null,m('"("')),o===null&&(e.charCodeAt(n)===41?(o=")",n++):(o=null,m('")"')),o===null&&(e.charCodeAt(n)===60?(o="<",n++):(o=null,m('"<"')),o===null&&(e.charCodeAt(n)===62?(o=">",n++):(o=null,m('">"')),o===null&&(e.charCodeAt(n)===58?(o=":",n++):(o=null,m('":"')),o===null&&(e.charCodeAt(n)===92?(o="\\",n++):(o=null,m('"\\\\"')),o===null&&(o=oe(),o===null&&(e.charCodeAt(n)===47?(o="/",n++):(o=null,m('"/"')),o===null&&(e.charCodeAt(n)===91?(o="[",n++):(o=null,m('"["')),o===null&&(e.charCodeAt(n)===93?(o="]",n++):(o=null,m('"]"')),o===null&&(e.charCodeAt(n)===63?(o="?",n++):(o=null,m('"?"')),o===null&&(e.charCodeAt(n)===123?(o="{",n++):(o=null,m('"{"')),o===null&&(e.charCodeAt(n)===125?(o="}",n++):(o=null,m('"}"'))))))))))))))))))))))))),o!==null)for(t=[];o!==null;)t.push(o),o=Re(),o===null&&(e.charCodeAt(n)===45?(o="-",n++):(o=null,m('"-"')),o===null&&(e.charCodeAt(n)===46?(o=".",n++):(o=null,m('"."')),o===null&&(e.charCodeAt(n)===33?(o="!",n++):(o=null,m('"!"')),o===null&&(e.charCodeAt(n)===37?(o="%",n++):(o=null,m('"%"')),o===null&&(e.charCodeAt(n)===42?(o="*",n++):(o=null,m('"*"')),o===null&&(e.charCodeAt(n)===95?(o="_",n++):(o=null,m('"_"')),o===null&&(e.charCodeAt(n)===43?(o="+",n++):(o=null,m('"+"')),o===null&&(e.charCodeAt(n)===96?(o="`",n++):(o=null,m('"`"')),o===null&&(e.charCodeAt(n)===39?(o="'",n++):(o=null,m(`"'"`)),o===null&&(e.charCodeAt(n)===126?(o="~",n++):(o=null,m('"~"')),o===null&&(e.charCodeAt(n)===40?(o="(",n++):(o=null,m('"("')),o===null&&(e.charCodeAt(n)===41?(o=")",n++):(o=null,m('")"')),o===null&&(e.charCodeAt(n)===60?(o="<",n++):(o=null,m('"<"')),o===null&&(e.charCodeAt(n)===62?(o=">",n++):(o=null,m('">"')),o===null&&(e.charCodeAt(n)===58?(o=":",n++):(o=null,m('":"')),o===null&&(e.charCodeAt(n)===92?(o="\\",n++):(o=null,m('"\\\\"')),o===null&&(o=oe(),o===null&&(e.charCodeAt(n)===47?(o="/",n++):(o=null,m('"/"')),o===null&&(e.charCodeAt(n)===91?(o="[",n++):(o=null,m('"["')),o===null&&(e.charCodeAt(n)===93?(o="]",n++):(o=null,m('"]"')),o===null&&(e.charCodeAt(n)===63?(o="?",n++):(o=null,m('"?"')),o===null&&(e.charCodeAt(n)===123?(o="{",n++):(o=null,m('"{"')),o===null&&(e.charCodeAt(n)===125?(o="}",n++):(o=null,m('"}"')))))))))))))))))))))))));else t=null;return t!==null&&(t=function(d){return e.substring(n,d)}(u)),t===null&&(n=u),t}function Te(){var t,o,u,d,T;return d=n,T=n,t=j(),t!==null?(e.charCodeAt(n)===42?(o="*",n++):(o=null,m('"*"')),o!==null?(u=j(),u!==null?t=[t,o,u]:(t=null,n=T)):(t=null,n=T)):(t=null,n=T),t!==null&&(t=function(E){return"*"}()),t===null&&(n=d),t}function De(){var t,o,u,d,T;return d=n,T=n,t=j(),t!==null?(e.charCodeAt(n)===47?(o="/",n++):(o=null,m('"/"')),o!==null?(u=j(),u!==null?t=[t,o,u]:(t=null,n=T)):(t=null,n=T)):(t=null,n=T),t!==null&&(t=function(E){return"/"}()),t===null&&(n=d),t}function Ce(){var t,o,u,d,T;return d=n,T=n,t=j(),t!==null?(e.charCodeAt(n)===61?(o="=",n++):(o=null,m('"="')),o!==null?(u=j(),u!==null?t=[t,o,u]:(t=null,n=T)):(t=null,n=T)):(t=null,n=T),t!==null&&(t=function(E){return"="}()),t===null&&(n=d),t}function He(){var t,o,u,d,T;return d=n,T=n,t=j(),t!==null?(e.charCodeAt(n)===40?(o="(",n++):(o=null,m('"("')),o!==null?(u=j(),u!==null?t=[t,o,u]:(t=null,n=T)):(t=null,n=T)):(t=null,n=T),t!==null&&(t=function(E){return"("}()),t===null&&(n=d),t}function we(){var t,o,u,d,T;return d=n,T=n,t=j(),t!==null?(e.charCodeAt(n)===41?(o=")",n++):(o=null,m('")"')),o!==null?(u=j(),u!==null?t=[t,o,u]:(t=null,n=T)):(t=null,n=T)):(t=null,n=T),t!==null&&(t=function(E){return")"}()),t===null&&(n=d),t}function Se(){var t,o,u,d;return u=n,d=n,e.charCodeAt(n)===62?(t=">",n++):(t=null,m('">"')),t!==null?(o=j(),o!==null?t=[t,o]:(t=null,n=d)):(t=null,n=d),t!==null&&(t=function(T){return">"}()),t===null&&(n=u),t}function ot(){var t,o,u,d;return u=n,d=n,t=j(),t!==null?(e.charCodeAt(n)===60?(o="<",n++):(o=null,m('"<"')),o!==null?t=[t,o]:(t=null,n=d)):(t=null,n=d),t!==null&&(t=function(T){return"<"}()),t===null&&(n=u),t}function Ue(){var t,o,u,d,T;return d=n,T=n,t=j(),t!==null?(e.charCodeAt(n)===44?(o=",",n++):(o=null,m('","')),o!==null?(u=j(),u!==null?t=[t,o,u]:(t=null,n=T)):(t=null,n=T)):(t=null,n=T),t!==null&&(t=function(E){return","}()),t===null&&(n=d),t}function le(){var t,o,u,d,T;return d=n,T=n,t=j(),t!==null?(e.charCodeAt(n)===59?(o=";",n++):(o=null,m('";"')),o!==null?(u=j(),u!==null?t=[t,o,u]:(t=null,n=T)):(t=null,n=T)):(t=null,n=T),t!==null&&(t=function(E){return";"}()),t===null&&(n=d),t}function Ae(){var t,o,u,d,T;return d=n,T=n,t=j(),t!==null?(e.charCodeAt(n)===58?(o=":",n++):(o=null,m('":"')),o!==null?(u=j(),u!==null?t=[t,o,u]:(t=null,n=T)):(t=null,n=T)):(t=null,n=T),t!==null&&(t=function(E){return":"}()),t===null&&(n=d),t}function Oe(){var t,o,u,d;return u=n,d=n,t=j(),t!==null?(o=oe(),o!==null?t=[t,o]:(t=null,n=d)):(t=null,n=d),t!==null&&(t=function(T){return'"'}()),t===null&&(n=u),t}function Pe(){var t,o,u,d;return u=n,d=n,t=oe(),t!==null?(o=j(),o!==null?t=[t,o]:(t=null,n=d)):(t=null,n=d),t!==null&&(t=function(T){return'"'}()),t===null&&(n=u),t}function ve(){var t,o,u,d;if(d=n,t=He(),t!==null){for(o=[],u=he(),u===null&&(u=We(),u===null&&(u=ve()));u!==null;)o.push(u),u=he(),u===null&&(u=We(),u===null&&(u=ve()));o!==null?(u=we(),u!==null?t=[t,o,u]:(t=null,n=d)):(t=null,n=d)}else t=null,n=d;return t}function he(){var t;return/^[!-']/.test(e.charAt(n))?(t=e.charAt(n),n++):(t=null,m("[!-']")),t===null&&(/^[*-[]/.test(e.charAt(n))?(t=e.charAt(n),n++):(t=null,m("[*-[]")),t===null&&(/^[\]-~]/.test(e.charAt(n))?(t=e.charAt(n),n++):(t=null,m("[\\]-~]")),t===null&&(t=U(),t===null&&(t=q())))),t}function pe(){var t,o,u,d,T,E;if(T=n,E=n,t=j(),t!==null)if(o=oe(),o!==null){for(u=[],d=Me(),d===null&&(d=We());d!==null;)u.push(d),d=Me(),d===null&&(d=We());u!==null?(d=oe(),d!==null?t=[t,o,u,d]:(t=null,n=E)):(t=null,n=E)}else t=null,n=E;else t=null,n=E;return t!==null&&(t=function(y){return e.substring(n,y)}(T)),t===null&&(n=T),t}function Ne(){var t,o,u,d,T,E;if(T=n,E=n,t=j(),t!==null)if(o=oe(),o!==null){for(u=[],d=Me(),d===null&&(d=We());d!==null;)u.push(d),d=Me(),d===null&&(d=We());u!==null?(d=oe(),d!==null?t=[t,o,u,d]:(t=null,n=E)):(t=null,n=E)}else t=null,n=E;else t=null,n=E;return t!==null&&(t=function(y){var O=e.substring(n,y).trim();return O.substring(1,O.length-1).replace(/\\([\x00-\x09\x0b-\x0c\x0e-\x7f])/g,"$1")}(T)),t===null&&(n=T),t}function Me(){var t;return t=q(),t===null&&(e.charCodeAt(n)===33?(t="!",n++):(t=null,m('"!"')),t===null&&(/^[#-[]/.test(e.charAt(n))?(t=e.charAt(n),n++):(t=null,m("[#-[]")),t===null&&(/^[\]-~]/.test(e.charAt(n))?(t=e.charAt(n),n++):(t=null,m("[\\]-~]")),t===null&&(t=U())))),t}function We(){var t,o,u;return u=n,e.charCodeAt(n)===92?(t="\\",n++):(t=null,m('"\\\\"')),t!==null?(/^[\0-\t]/.test(e.charAt(n))?(o=e.charAt(n),n++):(o=null,m("[\\0-\\t]")),o===null&&(/^[\x0B-\f]/.test(e.charAt(n))?(o=e.charAt(n),n++):(o=null,m("[\\x0B-\\f]")),o===null&&(/^[\x0E-]/.test(e.charAt(n))?(o=e.charAt(n),n++):(o=null,m("[\\x0E-]")))),o!==null?t=[t,o]:(t=null,n=u)):(t=null,n=u),t}function Fe(){var t,o,u,d,T,E;return T=n,E=n,t=dt(),t!==null?(e.charCodeAt(n)===58?(o=":",n++):(o=null,m('":"')),o!==null?(u=gn(),u=u!==null?u:"",u!==null?(d=Fs(),d!==null?t=[t,o,u,d]:(t=null,n=E)):(t=null,n=E)):(t=null,n=E)):(t=null,n=E),t!==null&&(t=function(y){try{w.uri=new so(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}}()),t===null&&(n=T),t}function Vt(){var t,o,u,d,T,E,y,O;return y=n,O=n,t=dt(),t!==null?(e.charCodeAt(n)===58?(o=":",n++):(o=null,m('":"')),o!==null?(u=gn(),u=u!==null?u:"",u!==null?(d=Fs(),d!==null?(T=si(),T!==null?(E=_i(),E=E!==null?E:"",E!==null?t=[t,o,u,d,T,E]:(t=null,n=O)):(t=null,n=O)):(t=null,n=O)):(t=null,n=O)):(t=null,n=O)):(t=null,n=O),t!==null&&(t=function(G){try{w.uri=new so(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,p==="SIP_URI"&&(w=w.uri)}catch{w=-1}}()),t===null&&(n=y),t}function dt(){var t;return t=ei(),t===null&&(t=Xn()),t}function ei(){var t,o;return o=n,e.substr(n,4).toLowerCase()==="sips"?(t=e.substr(n,4),n+=4):(t=null,m('"sips"')),t!==null&&(t=function(u,d){w.scheme=d.toLowerCase()}(o,t)),t===null&&(n=o),t}function Xn(){var t,o;return o=n,e.substr(n,3).toLowerCase()==="sip"?(t=e.substr(n,3),n+=3):(t=null,m('"sip"')),t!==null&&(t=function(u,d){w.scheme=d.toLowerCase()}(o,t)),t===null&&(n=o),t}function gn(){var t,o,u,d,T,E;return d=n,T=n,t=Tn(),t!==null?(E=n,e.charCodeAt(n)===58?(o=":",n++):(o=null,m('":"')),o!==null?(u=Qn(),u!==null?o=[o,u]:(o=null,n=E)):(o=null,n=E),o=o!==null?o:"",o!==null?(e.charCodeAt(n)===64?(u="@",n++):(u=null,m('"@"')),u!==null?t=[t,o,u]:(t=null,n=T)):(t=null,n=T)):(t=null,n=T),t!==null&&(t=function(y){w.user=decodeURIComponent(e.substring(n-1,y))}(d)),t===null&&(n=d),t}function Tn(){var t,o;if(o=H(),o===null&&(o=L(),o===null&&(o=ys())),o!==null)for(t=[];o!==null;)t.push(o),o=H(),o===null&&(o=L(),o===null&&(o=ys()));else t=null;return t}function ys(){var t;return e.charCodeAt(n)===38?(t="&",n++):(t=null,m('"&"')),t===null&&(e.charCodeAt(n)===61?(t="=",n++):(t=null,m('"="')),t===null&&(e.charCodeAt(n)===43?(t="+",n++):(t=null,m('"+"')),t===null&&(e.charCodeAt(n)===36?(t="$",n++):(t=null,m('"$"')),t===null&&(e.charCodeAt(n)===44?(t=",",n++):(t=null,m('","')),t===null&&(e.charCodeAt(n)===59?(t=";",n++):(t=null,m('";"')),t===null&&(e.charCodeAt(n)===63?(t="?",n++):(t=null,m('"?"')),t===null&&(e.charCodeAt(n)===47?(t="/",n++):(t=null,m('"/"'))))))))),t}function Qn(){var t,o,u;for(u=n,t=[],o=H(),o===null&&(o=L(),o===null&&(e.charCodeAt(n)===38?(o="&",n++):(o=null,m('"&"')),o===null&&(e.charCodeAt(n)===61?(o="=",n++):(o=null,m('"="')),o===null&&(e.charCodeAt(n)===43?(o="+",n++):(o=null,m('"+"')),o===null&&(e.charCodeAt(n)===36?(o="$",n++):(o=null,m('"$"')),o===null&&(e.charCodeAt(n)===44?(o=",",n++):(o=null,m('","'))))))));o!==null;)t.push(o),o=H(),o===null&&(o=L(),o===null&&(e.charCodeAt(n)===38?(o="&",n++):(o=null,m('"&"')),o===null&&(e.charCodeAt(n)===61?(o="=",n++):(o=null,m('"="')),o===null&&(e.charCodeAt(n)===43?(o="+",n++):(o=null,m('"+"')),o===null&&(e.charCodeAt(n)===36?(o="$",n++):(o=null,m('"$"')),o===null&&(e.charCodeAt(n)===44?(o=",",n++):(o=null,m('","'))))))));return t!==null&&(t=function(d){w.password=e.substring(n,d)}(u)),t===null&&(n=u),t}function Fs(){var t,o,u,d,T;return d=n,t=js(),t!==null?(T=n,e.charCodeAt(n)===58?(o=":",n++):(o=null,m('":"')),o!==null?(u=ti(),u!==null?o=[o,u]:(o=null,n=T)):(o=null,n=T),o=o!==null?o:"",o!==null?t=[t,o]:(t=null,n=d)):(t=null,n=d),t}function js(){var t,o;return o=n,t=vn(),t===null&&(t=qs(),t===null&&(t=Rt())),t!==null&&(t=function(u){return w.host=e.substring(n,u).toLowerCase(),w.host}(o)),t===null&&(n=o),t}function vn(){var t,o,u,d,T,E;for(d=n,T=n,t=[],E=n,o=En(),o!==null?(e.charCodeAt(n)===46?(u=".",n++):(u=null,m('"."')),u!==null?o=[o,u]:(o=null,n=E)):(o=null,n=E);o!==null;)t.push(o),E=n,o=En(),o!==null?(e.charCodeAt(n)===46?(u=".",n++):(u=null,m('"."')),u!==null?o=[o,u]:(o=null,n=E)):(o=null,n=E);return t!==null?(o=ge(),o!==null?(e.charCodeAt(n)===46?(u=".",n++):(u=null,m('"."')),u=u!==null?u:"",u!==null?t=[t,o,u]:(t=null,n=T)):(t=null,n=T)):(t=null,n=T),t!==null&&(t=function(y){return w.host_type="domain",e.substring(n,y)}(d)),t===null&&(n=d),t}function En(){var t,o,u,d;if(d=n,t=Re(),t!==null){for(o=[],u=Re(),u===null&&(e.charCodeAt(n)===45?(u="-",n++):(u=null,m('"-"')),u===null&&(e.charCodeAt(n)===95?(u="_",n++):(u=null,m('"_"'))));u!==null;)o.push(u),u=Re(),u===null&&(e.charCodeAt(n)===45?(u="-",n++):(u=null,m('"-"')),u===null&&(e.charCodeAt(n)===95?(u="_",n++):(u=null,m('"_"'))));o!==null?t=[t,o]:(t=null,n=d)}else t=null,n=d;return t}function ge(){var t,o,u,d;if(d=n,t=R(),t!==null){for(o=[],u=Re(),u===null&&(e.charCodeAt(n)===45?(u="-",n++):(u=null,m('"-"')),u===null&&(e.charCodeAt(n)===95?(u="_",n++):(u=null,m('"_"'))));u!==null;)o.push(u),u=Re(),u===null&&(e.charCodeAt(n)===45?(u="-",n++):(u=null,m('"-"')),u===null&&(e.charCodeAt(n)===95?(u="_",n++):(u=null,m('"_"'))));o!==null?t=[t,o]:(t=null,n=d)}else t=null,n=d;return t}function Rt(){var t,o,u,d,T;return d=n,T=n,e.charCodeAt(n)===91?(t="[",n++):(t=null,m('"["')),t!==null?(o=As(),o!==null?(e.charCodeAt(n)===93?(u="]",n++):(u=null,m('"]"')),u!==null?t=[t,o,u]:(t=null,n=T)):(t=null,n=T)):(t=null,n=T),t!==null&&(t=function(E){return w.host_type="IPv6",e.substring(n,E)}(d)),t===null&&(n=d),t}function As(){var t,o,u,d,T,E,y,O,G,ye,je,P,me,dl,k,Ee;return dl=n,k=n,t=de(),t!==null?(e.charCodeAt(n)===58?(o=":",n++):(o=null,m('":"')),o!==null?(u=de(),u!==null?(e.charCodeAt(n)===58?(d=":",n++):(d=null,m('":"')),d!==null?(T=de(),T!==null?(e.charCodeAt(n)===58?(E=":",n++):(E=null,m('":"')),E!==null?(y=de(),y!==null?(e.charCodeAt(n)===58?(O=":",n++):(O=null,m('":"')),O!==null?(G=de(),G!==null?(e.charCodeAt(n)===58?(ye=":",n++):(ye=null,m('":"')),ye!==null?(je=de(),je!==null?(e.charCodeAt(n)===58?(P=":",n++):(P=null,m('":"')),P!==null?(me=Nt(),me!==null?t=[t,o,u,d,T,E,y,O,G,ye,je,P,me]:(t=null,n=k)):(t=null,n=k)):(t=null,n=k)):(t=null,n=k)):(t=null,n=k)):(t=null,n=k)):(t=null,n=k)):(t=null,n=k)):(t=null,n=k)):(t=null,n=k)):(t=null,n=k)):(t=null,n=k)):(t=null,n=k),t===null&&(k=n,e.substr(n,2)==="::"?(t="::",n+=2):(t=null,m('"::"')),t!==null?(o=de(),o!==null?(e.charCodeAt(n)===58?(u=":",n++):(u=null,m('":"')),u!==null?(d=de(),d!==null?(e.charCodeAt(n)===58?(T=":",n++):(T=null,m('":"')),T!==null?(E=de(),E!==null?(e.charCodeAt(n)===58?(y=":",n++):(y=null,m('":"')),y!==null?(O=de(),O!==null?(e.charCodeAt(n)===58?(G=":",n++):(G=null,m('":"')),G!==null?(ye=de(),ye!==null?(e.charCodeAt(n)===58?(je=":",n++):(je=null,m('":"')),je!==null?(P=Nt(),P!==null?t=[t,o,u,d,T,E,y,O,G,ye,je,P]:(t=null,n=k)):(t=null,n=k)):(t=null,n=k)):(t=null,n=k)):(t=null,n=k)):(t=null,n=k)):(t=null,n=k)):(t=null,n=k)):(t=null,n=k)):(t=null,n=k)):(t=null,n=k)):(t=null,n=k),t===null&&(k=n,e.substr(n,2)==="::"?(t="::",n+=2):(t=null,m('"::"')),t!==null?(o=de(),o!==null?(e.charCodeAt(n)===58?(u=":",n++):(u=null,m('":"')),u!==null?(d=de(),d!==null?(e.charCodeAt(n)===58?(T=":",n++):(T=null,m('":"')),T!==null?(E=de(),E!==null?(e.charCodeAt(n)===58?(y=":",n++):(y=null,m('":"')),y!==null?(O=de(),O!==null?(e.charCodeAt(n)===58?(G=":",n++):(G=null,m('":"')),G!==null?(ye=Nt(),ye!==null?t=[t,o,u,d,T,E,y,O,G,ye]:(t=null,n=k)):(t=null,n=k)):(t=null,n=k)):(t=null,n=k)):(t=null,n=k)):(t=null,n=k)):(t=null,n=k)):(t=null,n=k)):(t=null,n=k)):(t=null,n=k),t===null&&(k=n,e.substr(n,2)==="::"?(t="::",n+=2):(t=null,m('"::"')),t!==null?(o=de(),o!==null?(e.charCodeAt(n)===58?(u=":",n++):(u=null,m('":"')),u!==null?(d=de(),d!==null?(e.charCodeAt(n)===58?(T=":",n++):(T=null,m('":"')),T!==null?(E=de(),E!==null?(e.charCodeAt(n)===58?(y=":",n++):(y=null,m('":"')),y!==null?(O=Nt(),O!==null?t=[t,o,u,d,T,E,y,O]:(t=null,n=k)):(t=null,n=k)):(t=null,n=k)):(t=null,n=k)):(t=null,n=k)):(t=null,n=k)):(t=null,n=k)):(t=null,n=k),t===null&&(k=n,e.substr(n,2)==="::"?(t="::",n+=2):(t=null,m('"::"')),t!==null?(o=de(),o!==null?(e.charCodeAt(n)===58?(u=":",n++):(u=null,m('":"')),u!==null?(d=de(),d!==null?(e.charCodeAt(n)===58?(T=":",n++):(T=null,m('":"')),T!==null?(E=Nt(),E!==null?t=[t,o,u,d,T,E]:(t=null,n=k)):(t=null,n=k)):(t=null,n=k)):(t=null,n=k)):(t=null,n=k)):(t=null,n=k),t===null&&(k=n,e.substr(n,2)==="::"?(t="::",n+=2):(t=null,m('"::"')),t!==null?(o=de(),o!==null?(e.charCodeAt(n)===58?(u=":",n++):(u=null,m('":"')),u!==null?(d=Nt(),d!==null?t=[t,o,u,d]:(t=null,n=k)):(t=null,n=k)):(t=null,n=k)):(t=null,n=k),t===null&&(k=n,e.substr(n,2)==="::"?(t="::",n+=2):(t=null,m('"::"')),t!==null?(o=Nt(),o!==null?t=[t,o]:(t=null,n=k)):(t=null,n=k),t===null&&(k=n,e.substr(n,2)==="::"?(t="::",n+=2):(t=null,m('"::"')),t!==null?(o=de(),o!==null?t=[t,o]:(t=null,n=k)):(t=null,n=k),t===null&&(k=n,t=de(),t!==null?(e.substr(n,2)==="::"?(o="::",n+=2):(o=null,m('"::"')),o!==null?(u=de(),u!==null?(e.charCodeAt(n)===58?(d=":",n++):(d=null,m('":"')),d!==null?(T=de(),T!==null?(e.charCodeAt(n)===58?(E=":",n++):(E=null,m('":"')),E!==null?(y=de(),y!==null?(e.charCodeAt(n)===58?(O=":",n++):(O=null,m('":"')),O!==null?(G=de(),G!==null?(e.charCodeAt(n)===58?(ye=":",n++):(ye=null,m('":"')),ye!==null?(je=Nt(),je!==null?t=[t,o,u,d,T,E,y,O,G,ye,je]:(t=null,n=k)):(t=null,n=k)):(t=null,n=k)):(t=null,n=k)):(t=null,n=k)):(t=null,n=k)):(t=null,n=k)):(t=null,n=k)):(t=null,n=k)):(t=null,n=k)):(t=null,n=k),t===null&&(k=n,t=de(),t!==null?(Ee=n,e.charCodeAt(n)===58?(o=":",n++):(o=null,m('":"')),o!==null?(u=de(),u!==null?o=[o,u]:(o=null,n=Ee)):(o=null,n=Ee),o=o!==null?o:"",o!==null?(e.substr(n,2)==="::"?(u="::",n+=2):(u=null,m('"::"')),u!==null?(d=de(),d!==null?(e.charCodeAt(n)===58?(T=":",n++):(T=null,m('":"')),T!==null?(E=de(),E!==null?(e.charCodeAt(n)===58?(y=":",n++):(y=null,m('":"')),y!==null?(O=de(),O!==null?(e.charCodeAt(n)===58?(G=":",n++):(G=null,m('":"')),G!==null?(ye=Nt(),ye!==null?t=[t,o,u,d,T,E,y,O,G,ye]:(t=null,n=k)):(t=null,n=k)):(t=null,n=k)):(t=null,n=k)):(t=null,n=k)):(t=null,n=k)):(t=null,n=k)):(t=null,n=k)):(t=null,n=k)):(t=null,n=k),t===null&&(k=n,t=de(),t!==null?(Ee=n,e.charCodeAt(n)===58?(o=":",n++):(o=null,m('":"')),o!==null?(u=de(),u!==null?o=[o,u]:(o=null,n=Ee)):(o=null,n=Ee),o=o!==null?o:"",o!==null?(Ee=n,e.charCodeAt(n)===58?(u=":",n++):(u=null,m('":"')),u!==null?(d=de(),d!==null?u=[u,d]:(u=null,n=Ee)):(u=null,n=Ee),u=u!==null?u:"",u!==null?(e.substr(n,2)==="::"?(d="::",n+=2):(d=null,m('"::"')),d!==null?(T=de(),T!==null?(e.charCodeAt(n)===58?(E=":",n++):(E=null,m('":"')),E!==null?(y=de(),y!==null?(e.charCodeAt(n)===58?(O=":",n++):(O=null,m('":"')),O!==null?(G=Nt(),G!==null?t=[t,o,u,d,T,E,y,O,G]:(t=null,n=k)):(t=null,n=k)):(t=null,n=k)):(t=null,n=k)):(t=null,n=k)):(t=null,n=k)):(t=null,n=k)):(t=null,n=k)):(t=null,n=k),t===null&&(k=n,t=de(),t!==null?(Ee=n,e.charCodeAt(n)===58?(o=":",n++):(o=null,m('":"')),o!==null?(u=de(),u!==null?o=[o,u]:(o=null,n=Ee)):(o=null,n=Ee),o=o!==null?o:"",o!==null?(Ee=n,e.charCodeAt(n)===58?(u=":",n++):(u=null,m('":"')),u!==null?(d=de(),d!==null?u=[u,d]:(u=null,n=Ee)):(u=null,n=Ee),u=u!==null?u:"",u!==null?(Ee=n,e.charCodeAt(n)===58?(d=":",n++):(d=null,m('":"')),d!==null?(T=de(),T!==null?d=[d,T]:(d=null,n=Ee)):(d=null,n=Ee),d=d!==null?d:"",d!==null?(e.substr(n,2)==="::"?(T="::",n+=2):(T=null,m('"::"')),T!==null?(E=de(),E!==null?(e.charCodeAt(n)===58?(y=":",n++):(y=null,m('":"')),y!==null?(O=Nt(),O!==null?t=[t,o,u,d,T,E,y,O]:(t=null,n=k)):(t=null,n=k)):(t=null,n=k)):(t=null,n=k)):(t=null,n=k)):(t=null,n=k)):(t=null,n=k)):(t=null,n=k),t===null&&(k=n,t=de(),t!==null?(Ee=n,e.charCodeAt(n)===58?(o=":",n++):(o=null,m('":"')),o!==null?(u=de(),u!==null?o=[o,u]:(o=null,n=Ee)):(o=null,n=Ee),o=o!==null?o:"",o!==null?(Ee=n,e.charCodeAt(n)===58?(u=":",n++):(u=null,m('":"')),u!==null?(d=de(),d!==null?u=[u,d]:(u=null,n=Ee)):(u=null,n=Ee),u=u!==null?u:"",u!==null?(Ee=n,e.charCodeAt(n)===58?(d=":",n++):(d=null,m('":"')),d!==null?(T=de(),T!==null?d=[d,T]:(d=null,n=Ee)):(d=null,n=Ee),d=d!==null?d:"",d!==null?(Ee=n,e.charCodeAt(n)===58?(T=":",n++):(T=null,m('":"')),T!==null?(E=de(),E!==null?T=[T,E]:(T=null,n=Ee)):(T=null,n=Ee),T=T!==null?T:"",T!==null?(e.substr(n,2)==="::"?(E="::",n+=2):(E=null,m('"::"')),E!==null?(y=Nt(),y!==null?t=[t,o,u,d,T,E,y]:(t=null,n=k)):(t=null,n=k)):(t=null,n=k)):(t=null,n=k)):(t=null,n=k)):(t=null,n=k)):(t=null,n=k),t===null&&(k=n,t=de(),t!==null?(Ee=n,e.charCodeAt(n)===58?(o=":",n++):(o=null,m('":"')),o!==null?(u=de(),u!==null?o=[o,u]:(o=null,n=Ee)):(o=null,n=Ee),o=o!==null?o:"",o!==null?(Ee=n,e.charCodeAt(n)===58?(u=":",n++):(u=null,m('":"')),u!==null?(d=de(),d!==null?u=[u,d]:(u=null,n=Ee)):(u=null,n=Ee),u=u!==null?u:"",u!==null?(Ee=n,e.charCodeAt(n)===58?(d=":",n++):(d=null,m('":"')),d!==null?(T=de(),T!==null?d=[d,T]:(d=null,n=Ee)):(d=null,n=Ee),d=d!==null?d:"",d!==null?(Ee=n,e.charCodeAt(n)===58?(T=":",n++):(T=null,m('":"')),T!==null?(E=de(),E!==null?T=[T,E]:(T=null,n=Ee)):(T=null,n=Ee),T=T!==null?T:"",T!==null?(Ee=n,e.charCodeAt(n)===58?(E=":",n++):(E=null,m('":"')),E!==null?(y=de(),y!==null?E=[E,y]:(E=null,n=Ee)):(E=null,n=Ee),E=E!==null?E:"",E!==null?(e.substr(n,2)==="::"?(y="::",n+=2):(y=null,m('"::"')),y!==null?(O=de(),O!==null?t=[t,o,u,d,T,E,y,O]:(t=null,n=k)):(t=null,n=k)):(t=null,n=k)):(t=null,n=k)):(t=null,n=k)):(t=null,n=k)):(t=null,n=k)):(t=null,n=k),t===null&&(k=n,t=de(),t!==null?(Ee=n,e.charCodeAt(n)===58?(o=":",n++):(o=null,m('":"')),o!==null?(u=de(),u!==null?o=[o,u]:(o=null,n=Ee)):(o=null,n=Ee),o=o!==null?o:"",o!==null?(Ee=n,e.charCodeAt(n)===58?(u=":",n++):(u=null,m('":"')),u!==null?(d=de(),d!==null?u=[u,d]:(u=null,n=Ee)):(u=null,n=Ee),u=u!==null?u:"",u!==null?(Ee=n,e.charCodeAt(n)===58?(d=":",n++):(d=null,m('":"')),d!==null?(T=de(),T!==null?d=[d,T]:(d=null,n=Ee)):(d=null,n=Ee),d=d!==null?d:"",d!==null?(Ee=n,e.charCodeAt(n)===58?(T=":",n++):(T=null,m('":"')),T!==null?(E=de(),E!==null?T=[T,E]:(T=null,n=Ee)):(T=null,n=Ee),T=T!==null?T:"",T!==null?(Ee=n,e.charCodeAt(n)===58?(E=":",n++):(E=null,m('":"')),E!==null?(y=de(),y!==null?E=[E,y]:(E=null,n=Ee)):(E=null,n=Ee),E=E!==null?E:"",E!==null?(Ee=n,e.charCodeAt(n)===58?(y=":",n++):(y=null,m('":"')),y!==null?(O=de(),O!==null?y=[y,O]:(y=null,n=Ee)):(y=null,n=Ee),y=y!==null?y:"",y!==null?(e.substr(n,2)==="::"?(O="::",n+=2):(O=null,m('"::"')),O!==null?t=[t,o,u,d,T,E,y,O]:(t=null,n=k)):(t=null,n=k)):(t=null,n=k)):(t=null,n=k)):(t=null,n=k)):(t=null,n=k)):(t=null,n=k)):(t=null,n=k))))))))))))))),t!==null&&(t=function(Wv){return w.host_type="IPv6",e.substring(n,Wv)}(dl)),t===null&&(n=dl),t}function de(){var t,o,u,d,T;return T=n,t=I(),t!==null?(o=I(),o=o!==null?o:"",o!==null?(u=I(),u=u!==null?u:"",u!==null?(d=I(),d=d!==null?d:"",d!==null?t=[t,o,u,d]:(t=null,n=T)):(t=null,n=T)):(t=null,n=T)):(t=null,n=T),t}function Nt(){var t,o,u,d;return d=n,t=de(),t!==null?(e.charCodeAt(n)===58?(o=":",n++):(o=null,m('":"')),o!==null?(u=de(),u!==null?t=[t,o,u]:(t=null,n=d)):(t=null,n=d)):(t=null,n=d),t===null&&(t=qs()),t}function qs(){var t,o,u,d,T,E,y,O,G;return O=n,G=n,t=Cs(),t!==null?(e.charCodeAt(n)===46?(o=".",n++):(o=null,m('"."')),o!==null?(u=Cs(),u!==null?(e.charCodeAt(n)===46?(d=".",n++):(d=null,m('"."')),d!==null?(T=Cs(),T!==null?(e.charCodeAt(n)===46?(E=".",n++):(E=null,m('"."')),E!==null?(y=Cs(),y!==null?t=[t,o,u,d,T,E,y]:(t=null,n=G)):(t=null,n=G)):(t=null,n=G)):(t=null,n=G)):(t=null,n=G)):(t=null,n=G)):(t=null,n=G),t!==null&&(t=function(ye){return w.host_type="IPv4",e.substring(n,ye)}(O)),t===null&&(n=O),t}function Cs(){var t,o,u,d;return d=n,e.substr(n,2)==="25"?(t="25",n+=2):(t=null,m('"25"')),t!==null?(/^[0-5]/.test(e.charAt(n))?(o=e.charAt(n),n++):(o=null,m("[0-5]")),o!==null?t=[t,o]:(t=null,n=d)):(t=null,n=d),t===null&&(d=n,e.charCodeAt(n)===50?(t="2",n++):(t=null,m('"2"')),t!==null?(/^[0-4]/.test(e.charAt(n))?(o=e.charAt(n),n++):(o=null,m("[0-4]")),o!==null?(u=A(),u!==null?t=[t,o,u]:(t=null,n=d)):(t=null,n=d)):(t=null,n=d),t===null&&(d=n,e.charCodeAt(n)===49?(t="1",n++):(t=null,m('"1"')),t!==null?(o=A(),o!==null?(u=A(),u!==null?t=[t,o,u]:(t=null,n=d)):(t=null,n=d)):(t=null,n=d),t===null&&(d=n,/^[1-9]/.test(e.charAt(n))?(t=e.charAt(n),n++):(t=null,m("[1-9]")),t!==null?(o=A(),o!==null?t=[t,o]:(t=null,n=d)):(t=null,n=d),t===null&&(t=A())))),t}function ti(){var t,o,u,d,T,E,y;return E=n,y=n,t=A(),t=t!==null?t:"",t!==null?(o=A(),o=o!==null?o:"",o!==null?(u=A(),u=u!==null?u:"",u!==null?(d=A(),d=d!==null?d:"",d!==null?(T=A(),T=T!==null?T:"",T!==null?t=[t,o,u,d,T]:(t=null,n=y)):(t=null,n=y)):(t=null,n=y)):(t=null,n=y)):(t=null,n=y),t!==null&&(t=function(O,G){return G=parseInt(G.join("")),w.port=G,G}(E,t)),t===null&&(n=E),t}function si(){var t,o,u,d;for(t=[],d=n,e.charCodeAt(n)===59?(o=";",n++):(o=null,m('";"')),o!==null?(u=Zn(),u!==null?o=[o,u]:(o=null,n=d)):(o=null,n=d);o!==null;)t.push(o),d=n,e.charCodeAt(n)===59?(o=";",n++):(o=null,m('";"')),o!==null?(u=Zn(),u!==null?o=[o,u]:(o=null,n=d)):(o=null,n=d);return t}function Zn(){var t;return t=ni(),t===null&&(t=ri(),t===null&&(t=ii(),t===null&&(t=li(),t===null&&(t=ai(),t===null&&(t=oi(),t===null&&(t=Vs())))))),t}function ni(){var t,o,u,d;return u=n,d=n,e.substr(n,10).toLowerCase()==="transport="?(t=e.substr(n,10),n+=10):(t=null,m('"transport="')),t!==null?(e.substr(n,3).toLowerCase()==="udp"?(o=e.substr(n,3),n+=3):(o=null,m('"udp"')),o===null&&(e.substr(n,3).toLowerCase()==="tcp"?(o=e.substr(n,3),n+=3):(o=null,m('"tcp"')),o===null&&(e.substr(n,4).toLowerCase()==="sctp"?(o=e.substr(n,4),n+=4):(o=null,m('"sctp"')),o===null&&(e.substr(n,3).toLowerCase()==="tls"?(o=e.substr(n,3),n+=3):(o=null,m('"tls"')),o===null&&(o=N())))),o!==null?t=[t,o]:(t=null,n=d)):(t=null,n=d),t!==null&&(t=function(T,E){w.uri_params||(w.uri_params={}),w.uri_params.transport=E.toLowerCase()}(u,t[1])),t===null&&(n=u),t}function ri(){var t,o,u,d;return u=n,d=n,e.substr(n,5).toLowerCase()==="user="?(t=e.substr(n,5),n+=5):(t=null,m('"user="')),t!==null?(e.substr(n,5).toLowerCase()==="phone"?(o=e.substr(n,5),n+=5):(o=null,m('"phone"')),o===null&&(e.substr(n,2).toLowerCase()==="ip"?(o=e.substr(n,2),n+=2):(o=null,m('"ip"')),o===null&&(o=N())),o!==null?t=[t,o]:(t=null,n=d)):(t=null,n=d),t!==null&&(t=function(T,E){w.uri_params||(w.uri_params={}),w.uri_params.user=E.toLowerCase()}(u,t[1])),t===null&&(n=u),t}function ii(){var t,o,u,d;return u=n,d=n,e.substr(n,7).toLowerCase()==="method="?(t=e.substr(n,7),n+=7):(t=null,m('"method="')),t!==null?(o=Cn(),o!==null?t=[t,o]:(t=null,n=d)):(t=null,n=d),t!==null&&(t=function(T,E){w.uri_params||(w.uri_params={}),w.uri_params.method=E}(u,t[1])),t===null&&(n=u),t}function li(){var t,o,u,d;return u=n,d=n,e.substr(n,4).toLowerCase()==="ttl="?(t=e.substr(n,4),n+=4):(t=null,m('"ttl="')),t!==null?(o=fr(),o!==null?t=[t,o]:(t=null,n=d)):(t=null,n=d),t!==null&&(t=function(T,E){w.params||(w.params={}),w.params.ttl=E}(u,t[1])),t===null&&(n=u),t}function ai(){var t,o,u,d;return u=n,d=n,e.substr(n,6).toLowerCase()==="maddr="?(t=e.substr(n,6),n+=6):(t=null,m('"maddr="')),t!==null?(o=js(),o!==null?t=[t,o]:(t=null,n=d)):(t=null,n=d),t!==null&&(t=function(T,E){w.uri_params||(w.uri_params={}),w.uri_params.maddr=E}(u,t[1])),t===null&&(n=u),t}function oi(){var t,o,u,d,T,E;return d=n,T=n,e.substr(n,2).toLowerCase()==="lr"?(t=e.substr(n,2),n+=2):(t=null,m('"lr"')),t!==null?(E=n,e.charCodeAt(n)===61?(o="=",n++):(o=null,m('"="')),o!==null?(u=N(),u!==null?o=[o,u]:(o=null,n=E)):(o=null,n=E),o=o!==null?o:"",o!==null?t=[t,o]:(t=null,n=T)):(t=null,n=T),t!==null&&(t=function(y){w.uri_params||(w.uri_params={}),w.uri_params.lr=void 0}()),t===null&&(n=d),t}function Vs(){var t,o,u,d,T,E;return d=n,T=n,t=ui(),t!==null?(E=n,e.charCodeAt(n)===61?(o="=",n++):(o=null,m('"="')),o!==null?(u=ci(),u!==null?o=[o,u]:(o=null,n=E)):(o=null,n=E),o=o!==null?o:"",o!==null?t=[t,o]:(t=null,n=T)):(t=null,n=T),t!==null&&(t=function(y,O,G){w.uri_params||(w.uri_params={}),typeof G>"u"?G=void 0:G=G[1],w.uri_params[O.toLowerCase()]=G}(d,t[0],t[1])),t===null&&(n=d),t}function ui(){var t,o,u;if(u=n,o=rs(),o!==null)for(t=[];o!==null;)t.push(o),o=rs();else t=null;return t!==null&&(t=function(d,T){return T.join("")}(u,t)),t===null&&(n=u),t}function ci(){var t,o,u;if(u=n,o=rs(),o!==null)for(t=[];o!==null;)t.push(o),o=rs();else t=null;return t!==null&&(t=function(d,T){return T.join("")}(u,t)),t===null&&(n=u),t}function rs(){var t;return t=fi(),t===null&&(t=H(),t===null&&(t=L())),t}function fi(){var t;return e.charCodeAt(n)===91?(t="[",n++):(t=null,m('"["')),t===null&&(e.charCodeAt(n)===93?(t="]",n++):(t=null,m('"]"')),t===null&&(e.charCodeAt(n)===47?(t="/",n++):(t=null,m('"/"')),t===null&&(e.charCodeAt(n)===58?(t=":",n++):(t=null,m('":"')),t===null&&(e.charCodeAt(n)===38?(t="&",n++):(t=null,m('"&"')),t===null&&(e.charCodeAt(n)===43?(t="+",n++):(t=null,m('"+"')),t===null&&(e.charCodeAt(n)===36?(t="$",n++):(t=null,m('"$"')))))))),t}function _i(){var t,o,u,d,T,E,y;if(E=n,e.charCodeAt(n)===63?(t="?",n++):(t=null,m('"?"')),t!==null)if(o=is(),o!==null){for(u=[],y=n,e.charCodeAt(n)===38?(d="&",n++):(d=null,m('"&"')),d!==null?(T=is(),T!==null?d=[d,T]:(d=null,n=y)):(d=null,n=y);d!==null;)u.push(d),y=n,e.charCodeAt(n)===38?(d="&",n++):(d=null,m('"&"')),d!==null?(T=is(),T!==null?d=[d,T]:(d=null,n=y)):(d=null,n=y);u!==null?t=[t,o,u]:(t=null,n=E)}else t=null,n=E;else t=null,n=E;return t}function is(){var t,o,u,d,T;return d=n,T=n,t=Ra(),t!==null?(e.charCodeAt(n)===61?(o="=",n++):(o=null,m('"="')),o!==null?(u=hi(),u!==null?t=[t,o,u]:(t=null,n=T)):(t=null,n=T)):(t=null,n=T),t!==null&&(t=function(E,y,O){y=y.join("").toLowerCase(),O=O.join(""),w.uri_headers||(w.uri_headers={}),w.uri_headers[y]?w.uri_headers[y].push(O):w.uri_headers[y]=[O]}(d,t[0],t[2])),t===null&&(n=d),t}function Ra(){var t,o;if(o=Bs(),o===null&&(o=H(),o===null&&(o=L())),o!==null)for(t=[];o!==null;)t.push(o),o=Bs(),o===null&&(o=H(),o===null&&(o=L()));else t=null;return t}function hi(){var t,o;for(t=[],o=Bs(),o===null&&(o=H(),o===null&&(o=L()));o!==null;)t.push(o),o=Bs(),o===null&&(o=H(),o===null&&(o=L()));return t}function Bs(){var t;return e.charCodeAt(n)===91?(t="[",n++):(t=null,m('"["')),t===null&&(e.charCodeAt(n)===93?(t="]",n++):(t=null,m('"]"')),t===null&&(e.charCodeAt(n)===47?(t="/",n++):(t=null,m('"/"')),t===null&&(e.charCodeAt(n)===63?(t="?",n++):(t=null,m('"?"')),t===null&&(e.charCodeAt(n)===58?(t=":",n++):(t=null,m('":"')),t===null&&(e.charCodeAt(n)===43?(t="+",n++):(t=null,m('"+"')),t===null&&(e.charCodeAt(n)===36?(t="$",n++):(t=null,m('"$"')))))))),t}function di(){var t;return t=Ni(),console.log("result0",t),t===null&&(t=pi(),console.log("result0 2",t)),t}function pi(){var t,o,u,d,T,E;return E=n,t=Cn(),t!==null?(o=x(),console.log("parse_SP",o),o!==null?(u=mi(),console.log("parse_Request_URI",u),u!==null?(d=x(),console.log("parse_SP 2",d),d!==null?(T=nr(),T!==null?t=[t,o,u,d,T]:(t=null,n=E)):(t=null,n=E)):(t=null,n=E)):(t=null,n=E)):(t=null,n=E),t}function mi(){var t;return t=Vt(),t===null&&(t=Gs()),t}function Gs(){var t,o,u,d;return d=n,t=vi(),t!==null?(e.charCodeAt(n)===58?(o=":",n++):(o=null,m('":"')),o!==null?(u=gi(),u===null&&(u=Ti()),u!==null?t=[t,o,u]:(t=null,n=d)):(t=null,n=d)):(t=null,n=d),t}function gi(){var t,o,u,d,T;return d=n,t=Ws(),t===null&&(t=Sn()),t!==null?(T=n,e.charCodeAt(n)===63?(o="?",n++):(o=null,m('"?"')),o!==null?(u=yi(),u!==null?o=[o,u]:(o=null,n=T)):(o=null,n=T),o=o!==null?o:"",o!==null?t=[t,o]:(t=null,n=d)):(t=null,n=d),t}function Ws(){var t,o,u,d;return d=n,e.substr(n,2)==="//"?(t="//",n+=2):(t=null,m('"//"')),t!==null?(o=Ei(),o!==null?(u=Sn(),u=u!==null?u:"",u!==null?t=[t,o,u]:(t=null,n=d)):(t=null,n=d)):(t=null,n=d),t}function Sn(){var t,o,u;return u=n,e.charCodeAt(n)===47?(t="/",n++):(t=null,m('"/"')),t!==null?(o=Ks(),o!==null?t=[t,o]:(t=null,n=u)):(t=null,n=u),t}function Ti(){var t,o,u,d;if(d=n,t=er(),t!==null){for(o=[],u=ls();u!==null;)o.push(u),u=ls();o!==null?t=[t,o]:(t=null,n=d)}else t=null,n=d;return t}function ls(){var t;return t=be(),t===null&&(t=H(),t===null&&(t=L())),t}function er(){var t;return t=H(),t===null&&(t=L(),t===null&&(e.charCodeAt(n)===59?(t=";",n++):(t=null,m('";"')),t===null&&(e.charCodeAt(n)===63?(t="?",n++):(t=null,m('"?"')),t===null&&(e.charCodeAt(n)===58?(t=":",n++):(t=null,m('":"')),t===null&&(e.charCodeAt(n)===64?(t="@",n++):(t=null,m('"@"')),t===null&&(e.charCodeAt(n)===38?(t="&",n++):(t=null,m('"&"')),t===null&&(e.charCodeAt(n)===61?(t="=",n++):(t=null,m('"="')),t===null&&(e.charCodeAt(n)===43?(t="+",n++):(t=null,m('"+"')),t===null&&(e.charCodeAt(n)===36?(t="$",n++):(t=null,m('"$"')),t===null&&(e.charCodeAt(n)===44?(t=",",n++):(t=null,m('","')))))))))))),t}function Ks(){var t,o,u,d,T,E;if(T=n,t=yn(),t!==null){for(o=[],E=n,e.charCodeAt(n)===47?(u="/",n++):(u=null,m('"/"')),u!==null?(d=yn(),d!==null?u=[u,d]:(u=null,n=E)):(u=null,n=E);u!==null;)o.push(u),E=n,e.charCodeAt(n)===47?(u="/",n++):(u=null,m('"/"')),u!==null?(d=yn(),d!==null?u=[u,d]:(u=null,n=E)):(u=null,n=E);o!==null?t=[t,o]:(t=null,n=T)}else t=null,n=T;return t}function yn(){var t,o,u,d,T,E;for(T=n,t=[],o=Ys();o!==null;)t.push(o),o=Ys();if(t!==null){for(o=[],E=n,e.charCodeAt(n)===59?(u=";",n++):(u=null,m('";"')),u!==null?(d=tr(),d!==null?u=[u,d]:(u=null,n=E)):(u=null,n=E);u!==null;)o.push(u),E=n,e.charCodeAt(n)===59?(u=";",n++):(u=null,m('";"')),u!==null?(d=tr(),d!==null?u=[u,d]:(u=null,n=E)):(u=null,n=E);o!==null?t=[t,o]:(t=null,n=T)}else t=null,n=T;return t}function tr(){var t,o;for(t=[],o=Ys();o!==null;)t.push(o),o=Ys();return t}function Ys(){var t;return t=H(),t===null&&(t=L(),t===null&&(e.charCodeAt(n)===58?(t=":",n++):(t=null,m('":"')),t===null&&(e.charCodeAt(n)===64?(t="@",n++):(t=null,m('"@"')),t===null&&(e.charCodeAt(n)===38?(t="&",n++):(t=null,m('"&"')),t===null&&(e.charCodeAt(n)===61?(t="=",n++):(t=null,m('"="')),t===null&&(e.charCodeAt(n)===43?(t="+",n++):(t=null,m('"+"')),t===null&&(e.charCodeAt(n)===36?(t="$",n++):(t=null,m('"$"')),t===null&&(e.charCodeAt(n)===44?(t=",",n++):(t=null,m('","')))))))))),t}function vi(){var t,o,u,d,T;if(d=n,T=n,t=R(),t!==null){for(o=[],u=R(),u===null&&(u=A(),u===null&&(e.charCodeAt(n)===43?(u="+",n++):(u=null,m('"+"')),u===null&&(e.charCodeAt(n)===45?(u="-",n++):(u=null,m('"-"')),u===null&&(e.charCodeAt(n)===46?(u=".",n++):(u=null,m('"."'))))));u!==null;)o.push(u),u=R(),u===null&&(u=A(),u===null&&(e.charCodeAt(n)===43?(u="+",n++):(u=null,m('"+"')),u===null&&(e.charCodeAt(n)===45?(u="-",n++):(u=null,m('"-"')),u===null&&(e.charCodeAt(n)===46?(u=".",n++):(u=null,m('"."'))))));o!==null?t=[t,o]:(t=null,n=T)}else t=null,n=T;return t!==null&&(t=function(E){w.scheme=e.substring(n,E)}(d)),t===null&&(n=d),t}function Ei(){var t;return t=sr(),t===null&&(t=Si()),t}function sr(){var t,o,u,d;return u=n,d=n,t=gn(),t!==null?(e.charCodeAt(n)===64?(o="@",n++):(o=null,m('"@"')),o!==null?t=[t,o]:(t=null,n=d)):(t=null,n=d),t=t!==null?t:"",t!==null?(o=Fs(),o!==null?t=[t,o]:(t=null,n=u)):(t=null,n=u),t=t!==null?t:"",t}function Si(){var t,o;if(o=H(),o===null&&(o=L(),o===null&&(e.charCodeAt(n)===36?(o="$",n++):(o=null,m('"$"')),o===null&&(e.charCodeAt(n)===44?(o=",",n++):(o=null,m('","')),o===null&&(e.charCodeAt(n)===59?(o=";",n++):(o=null,m('";"')),o===null&&(e.charCodeAt(n)===58?(o=":",n++):(o=null,m('":"')),o===null&&(e.charCodeAt(n)===64?(o="@",n++):(o=null,m('"@"')),o===null&&(e.charCodeAt(n)===38?(o="&",n++):(o=null,m('"&"')),o===null&&(e.charCodeAt(n)===61?(o="=",n++):(o=null,m('"="')),o===null&&(e.charCodeAt(n)===43?(o="+",n++):(o=null,m('"+"'))))))))))),o!==null)for(t=[];o!==null;)t.push(o),o=H(),o===null&&(o=L(),o===null&&(e.charCodeAt(n)===36?(o="$",n++):(o=null,m('"$"')),o===null&&(e.charCodeAt(n)===44?(o=",",n++):(o=null,m('","')),o===null&&(e.charCodeAt(n)===59?(o=";",n++):(o=null,m('";"')),o===null&&(e.charCodeAt(n)===58?(o=":",n++):(o=null,m('":"')),o===null&&(e.charCodeAt(n)===64?(o="@",n++):(o=null,m('"@"')),o===null&&(e.charCodeAt(n)===38?(o="&",n++):(o=null,m('"&"')),o===null&&(e.charCodeAt(n)===61?(o="=",n++):(o=null,m('"="')),o===null&&(e.charCodeAt(n)===43?(o="+",n++):(o=null,m('"+"')))))))))));else t=null;return t}function yi(){var t,o;for(t=[],o=ls();o!==null;)t.push(o),o=ls();return t}function nr(){var t,o,u,d,T,E,y,O;if(y=n,O=n,e.substr(n,3).toLowerCase()==="sip"?(t=e.substr(n,3),n+=3):(t=null,m('"SIP"')),t!==null)if(e.charCodeAt(n)===47?(o="/",n++):(o=null,m('"/"')),o!==null){if(d=A(),d!==null)for(u=[];d!==null;)u.push(d),d=A();else u=null;if(u!==null)if(e.charCodeAt(n)===46?(d=".",n++):(d=null,m('"."')),d!==null){if(E=A(),E!==null)for(T=[];E!==null;)T.push(E),E=A();else T=null;T!==null?t=[t,o,u,d,T]:(t=null,n=O)}else t=null,n=O;else t=null,n=O}else t=null,n=O;else t=null,n=O;return t!==null&&(t=function(G){w.sip_version=e.substring(n,G)}(y)),t===null&&(n=y),t}function Ai(){var t;return e.substr(n,6)==="INVITE"?(t="INVITE",n+=6):(t=null,m('"INVITE"')),t}function Ci(){var t;return e.substr(n,3)==="ACK"?(t="ACK",n+=3):(t=null,m('"ACK"')),t}function Ri(){var t;return e.substr(n,7)==="OPTIONS"?(t="OPTIONS",n+=7):(t=null,m('"OPTIONS"')),t}function Ii(){var t;return e.substr(n,3)==="BYE"?(t="BYE",n+=3):(t=null,m('"BYE"')),t}function bi(){var t;return e.substr(n,6)==="CANCEL"?(t="CANCEL",n+=6):(t=null,m('"CANCEL"')),t}function wi(){var t;return e.substr(n,8)==="REGISTER"?(t="REGISTER",n+=8):(t=null,m('"REGISTER"')),t}function An(){var t;return e.substr(n,9)==="SUBSCRIBE"?(t="SUBSCRIBE",n+=9):(t=null,m('"SUBSCRIBE"')),t}function Oi(){var t;return e.substr(n,6)==="NOTIFY"?(t="NOTIFY",n+=6):(t=null,m('"NOTIFY"')),t}function Di(){var t;return e.substr(n,5)==="REFER"?(t="REFER",n+=5):(t=null,m('"REFER"')),t}function Cn(){var t,o;return o=n,t=Ai(),t===null&&(t=Ci(),t===null&&(t=Ri(),t===null&&(t=Ii(),t===null&&(t=bi(),t===null&&(t=wi(),t===null&&(t=An(),t===null&&(t=Oi(),t===null&&(t=Di(),t===null&&(t=N()))))))))),t!==null&&(t=function(u){return w.method=e.substring(n,u),w.method}(o)),t===null&&(n=o),t}function Ni(){var t,o,u,d,T,E;return E=n,t=nr(),t!==null?(o=x(),o!==null?(u=Ia(),u!==null?(d=x(),d!==null?(T=wa(),T!==null?t=[t,o,u,d,T]:(t=null,n=E)):(t=null,n=E)):(t=null,n=E)):(t=null,n=E)):(t=null,n=E),t}function Ia(){var t,o;return o=n,t=ba(),t!==null&&(t=function(u,d){w.status_code=parseInt(d.join(""))}(o,t)),t===null&&(n=o),t}function ba(){var t,o,u,d;return d=n,t=A(),t!==null?(o=A(),o!==null?(u=A(),u!==null?t=[t,o,u]:(t=null,n=d)):(t=null,n=d)):(t=null,n=d),t}function wa(){var t,o,u;for(u=n,t=[],o=be(),o===null&&(o=H(),o===null&&(o=L(),o===null&&(o=U(),o===null&&(o=se(),o===null&&(o=x(),o===null&&(o=$()))))));o!==null;)t.push(o),o=be(),o===null&&(o=H(),o===null&&(o=L(),o===null&&(o=U(),o===null&&(o=se(),o===null&&(o=x(),o===null&&(o=$()))))));return t!==null&&(t=function(d){w.reason_phrase=e.substring(n,d)}(u)),t===null&&(n=u),t}function rr(){var t,o,u,d,T,E;if(T=n,t=Is(),t!==null){for(o=[],E=n,u=Ue(),u!==null?(d=Is(),d!==null?u=[u,d]:(u=null,n=E)):(u=null,n=E);u!==null;)o.push(u),E=n,u=Ue(),u!==null?(d=Is(),d!==null?u=[u,d]:(u=null,n=E)):(u=null,n=E);o!==null?t=[t,o]:(t=null,n=T)}else t=null,n=T;return t}function Rs(){var t,o,u,d,T,E;return d=n,T=n,t=ae(),t!==null?(E=n,e.charCodeAt(n)===64?(o="@",n++):(o=null,m('"@"')),o!==null?(u=ae(),u!==null?o=[o,u]:(o=null,n=E)):(o=null,n=E),o=o!==null?o:"",o!==null?t=[t,o]:(t=null,n=T)):(t=null,n=T),t!==null&&(t=function(y){w=e.substring(n,y)}(d)),t===null&&(n=d),t}function ir(){var t,o,u,d,T,E,y;if(T=n,t=Te(),t===null)if(E=n,t=Js(),t!==null){for(o=[],y=n,u=Ue(),u!==null?(d=Js(),d!==null?u=[u,d]:(u=null,n=y)):(u=null,n=y);u!==null;)o.push(u),y=n,u=Ue(),u!==null?(d=Js(),d!==null?u=[u,d]:(u=null,n=y)):(u=null,n=y);o!==null?t=[t,o]:(t=null,n=E)}else t=null,n=E;return t!==null&&(t=function(O){var G,ye;for(ye=w.multi_header.length,G=0;G<ye;G++)if(w.multi_header[G].parsed===null){w=null;break}w!==null?w=w.multi_header:w=-1}()),t===null&&(n=T),t}function Js(){var t,o,u,d,T,E,y;if(T=n,E=n,t=Fe(),t===null&&(t=as()),t!==null){for(o=[],y=n,u=le(),u!==null?(d=Jt(),d!==null?u=[u,d]:(u=null,n=y)):(u=null,n=y);u!==null;)o.push(u),y=n,u=le(),u!==null?(d=Jt(),d!==null?u=[u,d]:(u=null,n=y)):(u=null,n=y);o!==null?t=[t,o]:(t=null,n=E)}else t=null,n=E;return t!==null&&(t=function(O){var G;w.multi_header||(w.multi_header=[]);try{G=new us(w.uri,w.display_name,w.params),delete w.uri,delete w.display_name,delete w.params}catch{G=null}w.multi_header.push({possition:n,offset:O,parsed:G})}(T)),t===null&&(n=T),t}function as(){var t,o,u,d,T;return T=n,t=Rn(),t=t!==null?t:"",t!==null?(o=ot(),o!==null?(u=Vt(),u!==null?(d=Se(),d!==null?t=[t,o,u,d]:(t=null,n=T)):(t=null,n=T)):(t=null,n=T)):(t=null,n=T),t}function Rn(){var t,o,u,d,T,E,y;if(T=n,E=n,t=N(),t!==null){for(o=[],y=n,u=q(),u!==null?(d=N(),d!==null?u=[u,d]:(u=null,n=y)):(u=null,n=y);u!==null;)o.push(u),y=n,u=q(),u!==null?(d=N(),d!==null?u=[u,d]:(u=null,n=y)):(u=null,n=y);o!==null?t=[t,o]:(t=null,n=E)}else t=null,n=E;return t===null&&(t=Ne()),t!==null&&(t=function(O,G){typeof G=="string"?w.display_name=G:w.display_name=G[1].reduce(function(ye,je){return ye+je[0]+je[1]},G[0])}(T,t)),t===null&&(n=T),t}function Jt(){var t;return t=Ui(),t===null&&(t=et(),t===null&&(t=tt())),t}function Ui(){var t,o,u,d,T;return d=n,T=n,e.substr(n,1).toLowerCase()==="q"?(t=e.substr(n,1),n++):(t=null,m('"q"')),t!==null?(o=Ce(),o!==null?(u=Oa(),u!==null?t=[t,o,u]:(t=null,n=T)):(t=null,n=T)):(t=null,n=T),t!==null&&(t=function(E,y){w.params||(w.params={}),w.params.q=y}(d,t[2])),t===null&&(n=d),t}function et(){var t,o,u,d,T;return d=n,T=n,e.substr(n,7).toLowerCase()==="expires"?(t=e.substr(n,7),n+=7):(t=null,m('"expires"')),t!==null?(o=Ce(),o!==null?(u=os(),u!==null?t=[t,o,u]:(t=null,n=T)):(t=null,n=T)):(t=null,n=T),t!==null&&(t=function(E,y){w.params||(w.params={}),w.params.expires=y}(d,t[2])),t===null&&(n=d),t}function os(){var t,o,u;if(u=n,o=A(),o!==null)for(t=[];o!==null;)t.push(o),o=A();else t=null;return t!==null&&(t=function(d,T){return parseInt(T.join(""))}(u,t)),t===null&&(n=u),t}function Oa(){var t,o,u,d,T,E,y,O;return E=n,y=n,e.charCodeAt(n)===48?(t="0",n++):(t=null,m('"0"')),t!==null?(O=n,e.charCodeAt(n)===46?(o=".",n++):(o=null,m('"."')),o!==null?(u=A(),u=u!==null?u:"",u!==null?(d=A(),d=d!==null?d:"",d!==null?(T=A(),T=T!==null?T:"",T!==null?o=[o,u,d,T]:(o=null,n=O)):(o=null,n=O)):(o=null,n=O)):(o=null,n=O),o=o!==null?o:"",o!==null?t=[t,o]:(t=null,n=y)):(t=null,n=y),t!==null&&(t=function(G){return parseFloat(e.substring(n,G))}(E)),t===null&&(n=E),t}function tt(){var t,o,u,d,T,E;return d=n,T=n,t=N(),t!==null?(E=n,o=Ce(),o!==null?(u=lr(),u!==null?o=[o,u]:(o=null,n=E)):(o=null,n=E),o=o!==null?o:"",o!==null?t=[t,o]:(t=null,n=T)):(t=null,n=T),t!==null&&(t=function(y,O,G){w.params||(w.params={}),typeof G>"u"?G=void 0:G=G[1],w.params[O.toLowerCase()]=G}(d,t[0],t[1])),t===null&&(n=d),t}function lr(){var t;return t=N(),t===null&&(t=js(),t===null&&(t=pe())),t}function Da(){var t,o,u,d,T,E;if(T=n,t=Na(),t!==null){for(o=[],E=n,u=le(),u!==null?(d=Pi(),d!==null?u=[u,d]:(u=null,n=E)):(u=null,n=E);u!==null;)o.push(u),E=n,u=le(),u!==null?(d=Pi(),d!==null?u=[u,d]:(u=null,n=E)):(u=null,n=E);o!==null?t=[t,o]:(t=null,n=T)}else t=null,n=T;return t}function Na(){var t;return e.substr(n,6).toLowerCase()==="render"?(t=e.substr(n,6),n+=6):(t=null,m('"render"')),t===null&&(e.substr(n,7).toLowerCase()==="session"?(t=e.substr(n,7),n+=7):(t=null,m('"session"')),t===null&&(e.substr(n,4).toLowerCase()==="icon"?(t=e.substr(n,4),n+=4):(t=null,m('"icon"')),t===null&&(e.substr(n,5).toLowerCase()==="alert"?(t=e.substr(n,5),n+=5):(t=null,m('"alert"')),t===null&&(t=N())))),t}function Pi(){var t;return t=Ua(),t===null&&(t=tt()),t}function Ua(){var t,o,u,d;return d=n,e.substr(n,8).toLowerCase()==="handling"?(t=e.substr(n,8),n+=8):(t=null,m('"handling"')),t!==null?(o=Ce(),o!==null?(e.substr(n,8).toLowerCase()==="optional"?(u=e.substr(n,8),n+=8):(u=null,m('"optional"')),u===null&&(e.substr(n,8).toLowerCase()==="required"?(u=e.substr(n,8),n+=8):(u=null,m('"required"')),u===null&&(u=N())),u!==null?t=[t,o,u]:(t=null,n=d)):(t=null,n=d)):(t=null,n=d),t}function Pa(){var t,o,u,d,T,E;if(T=n,t=N(),t!==null){for(o=[],E=n,u=Ue(),u!==null?(d=N(),d!==null?u=[u,d]:(u=null,n=E)):(u=null,n=E);u!==null;)o.push(u),E=n,u=Ue(),u!==null?(d=N(),d!==null?u=[u,d]:(u=null,n=E)):(u=null,n=E);o!==null?t=[t,o]:(t=null,n=T)}else t=null,n=T;return t}function xa(){var t,o,u;if(u=n,o=A(),o!==null)for(t=[];o!==null;)t.push(o),o=A();else t=null;return t!==null&&(t=function(d,T){w=parseInt(T.join(""))}(u,t)),t===null&&(n=u),t}function Ma(){var t,o;return o=n,t=xi(),t!==null&&(t=function(u){w=e.substring(n,u)}(o)),t===null&&(n=o),t}function xi(){var t,o,u,d,T,E,y,O;if(y=n,t=In(),t!==null)if(o=De(),o!==null)if(u=ka(),u!==null){for(d=[],O=n,T=le(),T!==null?(E=ar(),E!==null?T=[T,E]:(T=null,n=O)):(T=null,n=O);T!==null;)d.push(T),O=n,T=le(),T!==null?(E=ar(),E!==null?T=[T,E]:(T=null,n=O)):(T=null,n=O);d!==null?t=[t,o,u,d]:(t=null,n=y)}else t=null,n=y;else t=null,n=y;else t=null,n=y;return t}function In(){var t;return t=Mi(),t===null&&(t=ki()),t}function Mi(){var t;return e.substr(n,4).toLowerCase()==="text"?(t=e.substr(n,4),n+=4):(t=null,m('"text"')),t===null&&(e.substr(n,5).toLowerCase()==="image"?(t=e.substr(n,5),n+=5):(t=null,m('"image"')),t===null&&(e.substr(n,5).toLowerCase()==="audio"?(t=e.substr(n,5),n+=5):(t=null,m('"audio"')),t===null&&(e.substr(n,5).toLowerCase()==="video"?(t=e.substr(n,5),n+=5):(t=null,m('"video"')),t===null&&(e.substr(n,11).toLowerCase()==="application"?(t=e.substr(n,11),n+=11):(t=null,m('"application"')),t===null&&(t=zs()))))),t}function ki(){var t;return e.substr(n,7).toLowerCase()==="message"?(t=e.substr(n,7),n+=7):(t=null,m('"message"')),t===null&&(e.substr(n,9).toLowerCase()==="multipart"?(t=e.substr(n,9),n+=9):(t=null,m('"multipart"')),t===null&&(t=zs())),t}function zs(){var t;return t=N(),t===null&&(t=Li()),t}function Li(){var t,o,u;return u=n,e.substr(n,2).toLowerCase()==="x-"?(t=e.substr(n,2),n+=2):(t=null,m('"x-"')),t!==null?(o=N(),o!==null?t=[t,o]:(t=null,n=u)):(t=null,n=u),t}function ka(){var t;return t=zs(),t===null&&(t=N()),t}function ar(){var t,o,u,d;return d=n,t=N(),t!==null?(o=Ce(),o!==null?(u=La(),u!==null?t=[t,o,u]:(t=null,n=d)):(t=null,n=d)):(t=null,n=d),t}function La(){var t;return t=N(),t===null&&(t=pe()),t}function Lu(){var t,o,u,d;return d=n,t=Xs(),t!==null?(o=q(),o!==null?(u=Cn(),u!==null?t=[t,o,u]:(t=null,n=d)):(t=null,n=d)):(t=null,n=d),t}function Xs(){var t,o,u;if(u=n,o=A(),o!==null)for(t=[];o!==null;)t.push(o),o=A();else t=null;return t!==null&&(t=function(d,T){w.value=parseInt(T.join(""))}(u,t)),t===null&&(n=u),t}function $u(){var t,o;return o=n,t=os(),t!==null&&(t=function(u,d){w=d}(o,t)),t===null&&(n=o),t}function $i(){var t,o,u,d,T,E,y;if(T=n,E=n,t=Is(),t!==null){for(o=[],y=n,u=le(),u!==null?(d=tt(),d!==null?u=[u,d]:(u=null,n=y)):(u=null,n=y);u!==null;)o.push(u),y=n,u=le(),u!==null?(d=tt(),d!==null?u=[u,d]:(u=null,n=y)):(u=null,n=y);o!==null?t=[t,o]:(t=null,n=E)}else t=null,n=E;return t!==null&&(t=function(O,G){w.event=G.join("").toLowerCase()}(T,t[0])),t===null&&(n=T),t}function Is(){var t,o,u,d,T,E;if(T=n,t=z(),t!==null){for(o=[],E=n,e.charCodeAt(n)===46?(u=".",n++):(u=null,m('"."')),u!==null?(d=z(),d!==null?u=[u,d]:(u=null,n=E)):(u=null,n=E);u!==null;)o.push(u),E=n,e.charCodeAt(n)===46?(u=".",n++):(u=null,m('"."')),u!==null?(d=z(),d!==null?u=[u,d]:(u=null,n=E)):(u=null,n=E);o!==null?t=[t,o]:(t=null,n=T)}else t=null,n=T;return t}function Hu(){var t,o,u,d,T,E,y;if(T=n,E=n,t=Fe(),t===null&&(t=as()),t!==null){for(o=[],y=n,u=le(),u!==null?(d=Hi(),d!==null?u=[u,d]:(u=null,n=y)):(u=null,n=y);u!==null;)o.push(u),y=n,u=le(),u!==null?(d=Hi(),d!==null?u=[u,d]:(u=null,n=y)):(u=null,n=y);o!==null?t=[t,o]:(t=null,n=E)}else t=null,n=E;return t!==null&&(t=function(O){var G=w.tag;try{w=new us(w.uri,w.display_name,w.params),G&&w.setParam("tag",G)}catch{w=-1}}()),t===null&&(n=T),t}function Hi(){var t;return t=Fi(),t===null&&(t=tt()),t}function Fi(){var t,o,u,d,T;return d=n,T=n,e.substr(n,3).toLowerCase()==="tag"?(t=e.substr(n,3),n+=3):(t=null,m('"tag"')),t!==null?(o=Ce(),o!==null?(u=N(),u!==null?t=[t,o,u]:(t=null,n=T)):(t=null,n=T)):(t=null,n=T),t!==null&&(t=function(E,y){w.tag=y}(d,t[2])),t===null&&(n=d),t}function Fu(){var t,o,u;if(u=n,o=A(),o!==null)for(t=[];o!==null;)t.push(o),o=A();else t=null;return t!==null&&(t=function(d,T){w=parseInt(T.join(""))}(u,t)),t===null&&(n=u),t}function ji(){var t,o;return o=n,t=os(),t!==null&&(t=function(u,d){w=d}(o,t)),t===null&&(n=o),t}function $a(){var t,o,u,d,T,E,y,O,G,ye;for(O=n,G=n,t=[],o=Rn();o!==null;)t.push(o),o=Rn();if(t!==null)if(o=ot(),o!==null)if(u=Vt(),u!==null)if(d=Se(),d!==null){for(T=[],ye=n,E=le(),E!==null?(y=tt(),y!==null?E=[E,y]:(E=null,n=ye)):(E=null,n=ye);E!==null;)T.push(E),ye=n,E=le(),E!==null?(y=tt(),y!==null?E=[E,y]:(E=null,n=ye)):(E=null,n=ye);T!==null?t=[t,o,u,d,T]:(t=null,n=G)}else t=null,n=G;else t=null,n=G;else t=null,n=G;else t=null,n=G;return t!==null&&(t=function(je){try{w=new us(w.uri,w.display_name,w.params)}catch{w=-1}}()),t===null&&(n=O),t}function bn(){var t;return t=Qs(),t}function Qs(){var t,o,u,d,T,E,y,O;if(y=n,e.substr(n,6).toLowerCase()==="digest"?(t=e.substr(n,6),n+=6):(t=null,m('"Digest"')),t!==null)if(o=q(),o!==null)if(u=wn(),u!==null){for(d=[],O=n,T=Ue(),T!==null?(E=wn(),E!==null?T=[T,E]:(T=null,n=O)):(T=null,n=O);T!==null;)d.push(T),O=n,T=Ue(),T!==null?(E=wn(),E!==null?T=[T,E]:(T=null,n=O)):(T=null,n=O);d!==null?t=[t,o,u,d]:(t=null,n=y)}else t=null,n=y;else t=null,n=y;else t=null,n=y;return t===null&&(t=qi()),t}function qi(){var t,o,u,d,T,E,y,O;if(y=n,t=N(),t!==null)if(o=q(),o!==null)if(u=Zs(),u!==null){for(d=[],O=n,T=Ue(),T!==null?(E=Zs(),E!==null?T=[T,E]:(T=null,n=O)):(T=null,n=O);T!==null;)d.push(T),O=n,T=Ue(),T!==null?(E=Zs(),E!==null?T=[T,E]:(T=null,n=O)):(T=null,n=O);d!==null?t=[t,o,u,d]:(t=null,n=y)}else t=null,n=y;else t=null,n=y;else t=null,n=y;return t}function Zs(){var t,o,u,d;return d=n,t=N(),t!==null?(o=Ce(),o!==null?(u=N(),u===null&&(u=pe()),u!==null?t=[t,o,u]:(t=null,n=d)):(t=null,n=d)):(t=null,n=d),t}function wn(){var t;return t=On(),t===null&&(t=Bi(),t===null&&(t=Gi(),t===null&&(t=Ki(),t===null&&(t=Nn(),t===null&&(t=Ha(),t===null&&(t=Fa(),t===null&&(t=Zs()))))))),t}function On(){var t,o,u,d;return d=n,e.substr(n,5).toLowerCase()==="realm"?(t=e.substr(n,5),n+=5):(t=null,m('"realm"')),t!==null?(o=Ce(),o!==null?(u=Vi(),u!==null?t=[t,o,u]:(t=null,n=d)):(t=null,n=d)):(t=null,n=d),t}function Vi(){var t,o;return o=n,t=Ne(),t!==null&&(t=function(u,d){w.realm=d}(o,t)),t===null&&(n=o),t}function Bi(){var t,o,u,d,T,E,y,O,G;if(O=n,e.substr(n,6).toLowerCase()==="domain"?(t=e.substr(n,6),n+=6):(t=null,m('"domain"')),t!==null)if(o=Ce(),o!==null)if(u=Oe(),u!==null)if(d=Dn(),d!==null){if(T=[],G=n,y=x(),y!==null)for(E=[];y!==null;)E.push(y),y=x();else E=null;for(E!==null?(y=Dn(),y!==null?E=[E,y]:(E=null,n=G)):(E=null,n=G);E!==null;){if(T.push(E),G=n,y=x(),y!==null)for(E=[];y!==null;)E.push(y),y=x();else E=null;E!==null?(y=Dn(),y!==null?E=[E,y]:(E=null,n=G)):(E=null,n=G)}T!==null?(E=Pe(),E!==null?t=[t,o,u,d,T,E]:(t=null,n=O)):(t=null,n=O)}else t=null,n=O;else t=null,n=O;else t=null,n=O;else t=null,n=O;return t}function Dn(){var t;return t=Gs(),t===null&&(t=Sn()),t}function Gi(){var t,o,u,d;return d=n,e.substr(n,5).toLowerCase()==="nonce"?(t=e.substr(n,5),n+=5):(t=null,m('"nonce"')),t!==null?(o=Ce(),o!==null?(u=Wi(),u!==null?t=[t,o,u]:(t=null,n=d)):(t=null,n=d)):(t=null,n=d),t}function Wi(){var t,o;return o=n,t=Ne(),t!==null&&(t=function(u,d){w.nonce=d}(o,t)),t===null&&(n=o),t}function Ki(){var t,o,u,d,T;return d=n,T=n,e.substr(n,6).toLowerCase()==="opaque"?(t=e.substr(n,6),n+=6):(t=null,m('"opaque"')),t!==null?(o=Ce(),o!==null?(u=Ne(),u!==null?t=[t,o,u]:(t=null,n=T)):(t=null,n=T)):(t=null,n=T),t!==null&&(t=function(E,y){w.opaque=y}(d,t[2])),t===null&&(n=d),t}function Nn(){var t,o,u,d,T;return d=n,e.substr(n,5).toLowerCase()==="stale"?(t=e.substr(n,5),n+=5):(t=null,m('"stale"')),t!==null?(o=Ce(),o!==null?(T=n,e.substr(n,4).toLowerCase()==="true"?(u=e.substr(n,4),n+=4):(u=null,m('"true"')),u!==null&&(u=function(E){w.stale=!0}()),u===null&&(n=T),u===null&&(T=n,e.substr(n,5).toLowerCase()==="false"?(u=e.substr(n,5),n+=5):(u=null,m('"false"')),u!==null&&(u=function(E){w.stale=!1}()),u===null&&(n=T)),u!==null?t=[t,o,u]:(t=null,n=d)):(t=null,n=d)):(t=null,n=d),t}function Ha(){var t,o,u,d,T;return d=n,T=n,e.substr(n,9).toLowerCase()==="algorithm"?(t=e.substr(n,9),n+=9):(t=null,m('"algorithm"')),t!==null?(o=Ce(),o!==null?(e.substr(n,3).toLowerCase()==="md5"?(u=e.substr(n,3),n+=3):(u=null,m('"MD5"')),u===null&&(e.substr(n,8).toLowerCase()==="md5-sess"?(u=e.substr(n,8),n+=8):(u=null,m('"MD5-sess"')),u===null&&(u=N())),u!==null?t=[t,o,u]:(t=null,n=T)):(t=null,n=T)):(t=null,n=T),t!==null&&(t=function(E,y){w.algorithm=y.toUpperCase()}(d,t[2])),t===null&&(n=d),t}function Fa(){var t,o,u,d,T,E,y,O,G,ye;if(O=n,e.substr(n,3).toLowerCase()==="qop"?(t=e.substr(n,3),n+=3):(t=null,m('"qop"')),t!==null)if(o=Ce(),o!==null)if(u=Oe(),u!==null){if(G=n,d=bs(),d!==null){for(T=[],ye=n,e.charCodeAt(n)===44?(E=",",n++):(E=null,m('","')),E!==null?(y=bs(),y!==null?E=[E,y]:(E=null,n=ye)):(E=null,n=ye);E!==null;)T.push(E),ye=n,e.charCodeAt(n)===44?(E=",",n++):(E=null,m('","')),E!==null?(y=bs(),y!==null?E=[E,y]:(E=null,n=ye)):(E=null,n=ye);T!==null?d=[d,T]:(d=null,n=G)}else d=null,n=G;d!==null?(T=Pe(),T!==null?t=[t,o,u,d,T]:(t=null,n=O)):(t=null,n=O)}else t=null,n=O;else t=null,n=O;else t=null,n=O;return t}function bs(){var t,o;return o=n,e.substr(n,8).toLowerCase()==="auth-int"?(t=e.substr(n,8),n+=8):(t=null,m('"auth-int"')),t===null&&(e.substr(n,4).toLowerCase()==="auth"?(t=e.substr(n,4),n+=4):(t=null,m('"auth"')),t===null&&(t=N())),t!==null&&(t=function(u,d){w.qop||(w.qop=[]),w.qop.push(d.toLowerCase())}(o,t)),t===null&&(n=o),t}function ju(){var t,o,u,d,T,E;if(T=n,t=N(),t!==null){for(o=[],E=n,u=Ue(),u!==null?(d=N(),d!==null?u=[u,d]:(u=null,n=E)):(u=null,n=E);u!==null;)o.push(u),E=n,u=Ue(),u!==null?(d=N(),d!==null?u=[u,d]:(u=null,n=E)):(u=null,n=E);o!==null?t=[t,o]:(t=null,n=T)}else t=null,n=T;return t}function Yi(){var t,o,u,d,T,E,y;if(T=n,E=n,t=Un(),t!==null){for(o=[],y=n,u=Ue(),u!==null?(d=Un(),d!==null?u=[u,d]:(u=null,n=y)):(u=null,n=y);u!==null;)o.push(u),y=n,u=Ue(),u!==null?(d=Un(),d!==null?u=[u,d]:(u=null,n=y)):(u=null,n=y);o!==null?t=[t,o]:(t=null,n=E)}else t=null,n=E;return t!==null&&(t=function(O){var G,ye;for(ye=w.multi_header.length,G=0;G<ye;G++)if(w.multi_header[G].parsed===null){w=null;break}w!==null?w=w.multi_header:w=-1}()),t===null&&(n=T),t}function Un(){var t,o,u,d,T,E,y;if(T=n,E=n,t=as(),t!==null){for(o=[],y=n,u=le(),u!==null?(d=tt(),d!==null?u=[u,d]:(u=null,n=y)):(u=null,n=y);u!==null;)o.push(u),y=n,u=le(),u!==null?(d=tt(),d!==null?u=[u,d]:(u=null,n=y)):(u=null,n=y);o!==null?t=[t,o]:(t=null,n=E)}else t=null,n=E;return t!==null&&(t=function(O){var G;w.multi_header||(w.multi_header=[]);try{G=new us(w.uri,w.display_name,w.params),delete w.uri,delete w.display_name,delete w.params}catch{G=null}w.multi_header.push({possition:n,offset:O,parsed:G})}(T)),t===null&&(n=T),t}function qu(){var t,o,u,d,T,E,y;if(T=n,E=n,e.substr(n,3).toLowerCase()==="sip"?(t=e.substr(n,3),n+=3):(t=null,m('"SIP"')),t===null&&(t=N()),t!==null){for(o=[],y=n,u=le(),u!==null?(d=Ji(),d!==null?u=[u,d]:(u=null,n=y)):(u=null,n=y);u!==null;)o.push(u),y=n,u=le(),u!==null?(d=Ji(),d!==null?u=[u,d]:(u=null,n=y)):(u=null,n=y);o!==null?t=[t,o]:(t=null,n=E)}else t=null,n=E;return t!==null&&(t=function(O,G){if(w.protocol=G.toLowerCase(),w.params||(w.params={}),w.params.text&&w.params.text[0]==='"'){var ye=w.params.text;w.text=ye.substring(1,ye.length-1),delete w.params.text}}(T,t[0])),t===null&&(n=T),t}function Ji(){var t;return t=Pn(),t===null&&(t=tt()),t}function Pn(){var t,o,u,d,T,E;if(T=n,E=n,e.substr(n,5).toLowerCase()==="cause"?(t=e.substr(n,5),n+=5):(t=null,m('"cause"')),t!==null)if(o=Ce(),o!==null){if(d=A(),d!==null)for(u=[];d!==null;)u.push(d),d=A();else u=null;u!==null?t=[t,o,u]:(t=null,n=E)}else t=null,n=E;else t=null,n=E;return t!==null&&(t=function(y,O){w.cause=parseInt(O.join(""))}(T,t[2])),t===null&&(n=T),t}function Vu(){var t,o,u,d,T,E;if(T=n,t=N(),t!==null){for(o=[],E=n,u=Ue(),u!==null?(d=N(),d!==null?u=[u,d]:(u=null,n=E)):(u=null,n=E);u!==null;)o.push(u),E=n,u=Ue(),u!==null?(d=N(),d!==null?u=[u,d]:(u=null,n=E)):(u=null,n=E);o!==null?t=[t,o]:(t=null,n=T)}else t=null,n=T;return t}function ja(){var t,o,u,d,T,E;if(T=n,t=en(),t!==null){for(o=[],E=n,u=Ue(),u!==null?(d=en(),d!==null?u=[u,d]:(u=null,n=E)):(u=null,n=E);u!==null;)o.push(u),E=n,u=Ue(),u!==null?(d=en(),d!==null?u=[u,d]:(u=null,n=E)):(u=null,n=E);o!==null?t=[t,o]:(t=null,n=T)}else t=null,n=T;return t}function en(){var t,o,u,d,T,E;if(T=n,t=as(),t!==null){for(o=[],E=n,u=le(),u!==null?(d=tt(),d!==null?u=[u,d]:(u=null,n=E)):(u=null,n=E);u!==null;)o.push(u),E=n,u=le(),u!==null?(d=tt(),d!==null?u=[u,d]:(u=null,n=E)):(u=null,n=E);o!==null?t=[t,o]:(t=null,n=T)}else t=null,n=T;return t}function qa(){var t,o,u,d,T,E;if(T=n,t=Va(),t!==null){for(o=[],E=n,u=le(),u!==null?(d=zi(),d!==null?u=[u,d]:(u=null,n=E)):(u=null,n=E);u!==null;)o.push(u),E=n,u=le(),u!==null?(d=zi(),d!==null?u=[u,d]:(u=null,n=E)):(u=null,n=E);o!==null?t=[t,o]:(t=null,n=T)}else t=null,n=T;return t}function Va(){var t,o;return o=n,e.substr(n,6).toLowerCase()==="active"?(t=e.substr(n,6),n+=6):(t=null,m('"active"')),t===null&&(e.substr(n,7).toLowerCase()==="pending"?(t=e.substr(n,7),n+=7):(t=null,m('"pending"')),t===null&&(e.substr(n,10).toLowerCase()==="terminated"?(t=e.substr(n,10),n+=10):(t=null,m('"terminated"')),t===null&&(t=N()))),t!==null&&(t=function(u){w.state=e.substring(n,u)}(o)),t===null&&(n=o),t}function zi(){var t,o,u,d,T;return d=n,T=n,e.substr(n,6).toLowerCase()==="reason"?(t=e.substr(n,6),n+=6):(t=null,m('"reason"')),t!==null?(o=Ce(),o!==null?(u=Ba(),u!==null?t=[t,o,u]:(t=null,n=T)):(t=null,n=T)):(t=null,n=T),t!==null&&(t=function(E,y){typeof y<"u"&&(w.reason=y)}(d,t[2])),t===null&&(n=d),t===null&&(d=n,T=n,e.substr(n,7).toLowerCase()==="expires"?(t=e.substr(n,7),n+=7):(t=null,m('"expires"')),t!==null?(o=Ce(),o!==null?(u=os(),u!==null?t=[t,o,u]:(t=null,n=T)):(t=null,n=T)):(t=null,n=T),t!==null&&(t=function(E,y){typeof y<"u"&&(w.expires=y)}(d,t[2])),t===null&&(n=d),t===null&&(d=n,T=n,e.substr(n,11).toLowerCase()==="retry_after"?(t=e.substr(n,11),n+=11):(t=null,m('"retry_after"')),t!==null?(o=Ce(),o!==null?(u=os(),u!==null?t=[t,o,u]:(t=null,n=T)):(t=null,n=T)):(t=null,n=T),t!==null&&(t=function(E,y){typeof y<"u"&&(w.retry_after=y)}(d,t[2])),t===null&&(n=d),t===null&&(t=tt()))),t}function Ba(){var t;return e.substr(n,11).toLowerCase()==="deactivated"?(t=e.substr(n,11),n+=11):(t=null,m('"deactivated"')),t===null&&(e.substr(n,9).toLowerCase()==="probation"?(t=e.substr(n,9),n+=9):(t=null,m('"probation"')),t===null&&(e.substr(n,8).toLowerCase()==="rejected"?(t=e.substr(n,8),n+=8):(t=null,m('"rejected"')),t===null&&(e.substr(n,7).toLowerCase()==="timeout"?(t=e.substr(n,7),n+=7):(t=null,m('"timeout"')),t===null&&(e.substr(n,6).toLowerCase()==="giveup"?(t=e.substr(n,6),n+=6):(t=null,m('"giveup"')),t===null&&(e.substr(n,10).toLowerCase()==="noresource"?(t=e.substr(n,10),n+=10):(t=null,m('"noresource"')),t===null&&(e.substr(n,9).toLowerCase()==="invariant"?(t=e.substr(n,9),n+=9):(t=null,m('"invariant"')),t===null&&(t=N()))))))),t}function Xi(){var t;return t=Q(),t=t!==null?t:"",t}function Bu(){var t,o,u,d,T,E;if(T=n,t=N(),t!==null){for(o=[],E=n,u=Ue(),u!==null?(d=N(),d!==null?u=[u,d]:(u=null,n=E)):(u=null,n=E);u!==null;)o.push(u),E=n,u=Ue(),u!==null?(d=N(),d!==null?u=[u,d]:(u=null,n=E)):(u=null,n=E);o!==null?t=[t,o]:(t=null,n=T)}else t=null,n=T;return t=t!==null?t:"",t}function or(){var t,o,u,d,T,E,y;if(T=n,E=n,t=Fe(),t===null&&(t=as()),t!==null){for(o=[],y=n,u=le(),u!==null?(d=xn(),d!==null?u=[u,d]:(u=null,n=y)):(u=null,n=y);u!==null;)o.push(u),y=n,u=le(),u!==null?(d=xn(),d!==null?u=[u,d]:(u=null,n=y)):(u=null,n=y);o!==null?t=[t,o]:(t=null,n=E)}else t=null,n=E;return t!==null&&(t=function(O){var G=w.tag;try{w=new us(w.uri,w.display_name,w.params),G&&w.setParam("tag",G)}catch{w=-1}}()),t===null&&(n=T),t}function xn(){var t;return t=Fi(),t===null&&(t=tt()),t}function Ga(){var t,o,u,d,T,E;if(T=n,t=Mn(),t!==null){for(o=[],E=n,u=Ue(),u!==null?(d=Mn(),d!==null?u=[u,d]:(u=null,n=E)):(u=null,n=E);u!==null;)o.push(u),E=n,u=Ue(),u!==null?(d=Mn(),d!==null?u=[u,d]:(u=null,n=E)):(u=null,n=E);o!==null?t=[t,o]:(t=null,n=T)}else t=null,n=T;return t}function Mn(){var t,o,u,d,T,E,y,O;if(y=n,t=rl(),t!==null)if(o=q(),o!==null)if(u=cr(),u!==null){for(d=[],O=n,T=le(),T!==null?(E=ur(),E!==null?T=[T,E]:(T=null,n=O)):(T=null,n=O);T!==null;)d.push(T),O=n,T=le(),T!==null?(E=ur(),E!==null?T=[T,E]:(T=null,n=O)):(T=null,n=O);d!==null?t=[t,o,u,d]:(t=null,n=y)}else t=null,n=y;else t=null,n=y;else t=null,n=y;return t}function ur(){var t;return t=Qi(),t===null&&(t=Zi(),t===null&&(t=el(),t===null&&(t=tl(),t===null&&(t=sl(),t===null&&(t=tt()))))),t}function Qi(){var t,o,u,d,T;return d=n,T=n,e.substr(n,3).toLowerCase()==="ttl"?(t=e.substr(n,3),n+=3):(t=null,m('"ttl"')),t!==null?(o=Ce(),o!==null?(u=fr(),u!==null?t=[t,o,u]:(t=null,n=T)):(t=null,n=T)):(t=null,n=T),t!==null&&(t=function(E,y){w.ttl=y}(d,t[2])),t===null&&(n=d),t}function Zi(){var t,o,u,d,T;return d=n,T=n,e.substr(n,5).toLowerCase()==="maddr"?(t=e.substr(n,5),n+=5):(t=null,m('"maddr"')),t!==null?(o=Ce(),o!==null?(u=js(),u!==null?t=[t,o,u]:(t=null,n=T)):(t=null,n=T)):(t=null,n=T),t!==null&&(t=function(E,y){w.maddr=y}(d,t[2])),t===null&&(n=d),t}function el(){var t,o,u,d,T;return d=n,T=n,e.substr(n,8).toLowerCase()==="received"?(t=e.substr(n,8),n+=8):(t=null,m('"received"')),t!==null?(o=Ce(),o!==null?(u=qs(),u===null&&(u=As()),u!==null?t=[t,o,u]:(t=null,n=T)):(t=null,n=T)):(t=null,n=T),t!==null&&(t=function(E,y){w.received=y}(d,t[2])),t===null&&(n=d),t}function tl(){var t,o,u,d,T;return d=n,T=n,e.substr(n,6).toLowerCase()==="branch"?(t=e.substr(n,6),n+=6):(t=null,m('"branch"')),t!==null?(o=Ce(),o!==null?(u=N(),u!==null?t=[t,o,u]:(t=null,n=T)):(t=null,n=T)):(t=null,n=T),t!==null&&(t=function(E,y){w.branch=y}(d,t[2])),t===null&&(n=d),t}function sl(){var t,o,u,d,T;return d=n,e.substr(n,5).toLowerCase()==="rport"?(t=e.substr(n,5),n+=5):(t=null,m('"rport"')),t!==null?(T=n,o=Ce(),o!==null?(u=nl(),u!==null?o=[o,u]:(o=null,n=T)):(o=null,n=T),o=o!==null?o:"",o!==null?t=[t,o]:(t=null,n=d)):(t=null,n=d),t}function nl(){var t,o,u,d,T,E,y;return E=n,y=n,t=A(),t=t!==null?t:"",t!==null?(o=A(),o=o!==null?o:"",o!==null?(u=A(),u=u!==null?u:"",u!==null?(d=A(),d=d!==null?d:"",d!==null?(T=A(),T=T!==null?T:"",T!==null?t=[t,o,u,d,T]:(t=null,n=y)):(t=null,n=y)):(t=null,n=y)):(t=null,n=y)):(t=null,n=y),t!==null&&(t=function(O,G){w.rport=parseInt(G.join(""))}(E,t)),t===null&&(n=E),t}function rl(){var t,o,u,d,T,E;return E=n,t=il(),t!==null?(o=De(),o!==null?(u=N(),u!==null?(d=De(),d!==null?(T=ll(),T!==null?t=[t,o,u,d,T]:(t=null,n=E)):(t=null,n=E)):(t=null,n=E)):(t=null,n=E)):(t=null,n=E),t}function il(){var t,o;return o=n,e.substr(n,3).toLowerCase()==="sip"?(t=e.substr(n,3),n+=3):(t=null,m('"SIP"')),t===null&&(t=N()),t!==null&&(t=function(u,d){w.protocol=d}(o,t)),t===null&&(n=o),t}function ll(){var t,o;return o=n,e.substr(n,3).toLowerCase()==="udp"?(t=e.substr(n,3),n+=3):(t=null,m('"UDP"')),t===null&&(e.substr(n,3).toLowerCase()==="tcp"?(t=e.substr(n,3),n+=3):(t=null,m('"TCP"')),t===null&&(e.substr(n,3).toLowerCase()==="tls"?(t=e.substr(n,3),n+=3):(t=null,m('"TLS"')),t===null&&(e.substr(n,4).toLowerCase()==="sctp"?(t=e.substr(n,4),n+=4):(t=null,m('"SCTP"')),t===null&&(t=N())))),t!==null&&(t=function(u,d){w.transport=d}(o,t)),t===null&&(n=o),t}function cr(){var t,o,u,d,T;return d=n,t=Wa(),t!==null?(T=n,o=Ae(),o!==null?(u=Ka(),u!==null?o=[o,u]:(o=null,n=T)):(o=null,n=T),o=o!==null?o:"",o!==null?t=[t,o]:(t=null,n=d)):(t=null,n=d),t}function Wa(){var t,o;return o=n,t=qs(),t===null&&(t=Rt(),t===null&&(t=vn())),t!==null&&(t=function(u){w.host=e.substring(n,u)}(o)),t===null&&(n=o),t}function Ka(){var t,o,u,d,T,E,y;return E=n,y=n,t=A(),t=t!==null?t:"",t!==null?(o=A(),o=o!==null?o:"",o!==null?(u=A(),u=u!==null?u:"",u!==null?(d=A(),d=d!==null?d:"",d!==null?(T=A(),T=T!==null?T:"",T!==null?t=[t,o,u,d,T]:(t=null,n=y)):(t=null,n=y)):(t=null,n=y)):(t=null,n=y)):(t=null,n=y),t!==null&&(t=function(O,G){w.port=parseInt(G.join(""))}(E,t)),t===null&&(n=E),t}function fr(){var t,o,u,d,T;return d=n,T=n,t=A(),t!==null?(o=A(),o=o!==null?o:"",o!==null?(u=A(),u=u!==null?u:"",u!==null?t=[t,o,u]:(t=null,n=T)):(t=null,n=T)):(t=null,n=T),t!==null&&(t=function(E,y){return parseInt(y.join(""))}(d,t)),t===null&&(n=d),t}function al(){var t;return t=Qs(),t}function Ya(){var t,o,u,d,T,E;if(T=n,t=Ja(),t!==null){for(o=[],E=n,u=le(),u!==null?(d=_r(),d!==null?u=[u,d]:(u=null,n=E)):(u=null,n=E);u!==null;)o.push(u),E=n,u=le(),u!==null?(d=_r(),d!==null?u=[u,d]:(u=null,n=E)):(u=null,n=E);o!==null?t=[t,o]:(t=null,n=T)}else t=null,n=T;return t}function Ja(){var t,o;return o=n,t=os(),t!==null&&(t=function(u,d){w.expires=d}(o,t)),t===null&&(n=o),t}function _r(){var t;return t=za(),t===null&&(t=tt()),t}function za(){var t,o,u,d,T;return d=n,T=n,e.substr(n,9).toLowerCase()==="refresher"?(t=e.substr(n,9),n+=9):(t=null,m('"refresher"')),t!==null?(o=Ce(),o!==null?(e.substr(n,3).toLowerCase()==="uac"?(u=e.substr(n,3),n+=3):(u=null,m('"uac"')),u===null&&(e.substr(n,3).toLowerCase()==="uas"?(u=e.substr(n,3),n+=3):(u=null,m('"uas"'))),u!==null?t=[t,o,u]:(t=null,n=T)):(t=null,n=T)):(t=null,n=T),t!==null&&(t=function(E,y){w.refresher=y.toLowerCase()}(d,t[2])),t===null&&(n=d),t}function Gu(){var t,o,u,d;return d=n,t=N(),t!==null?(o=B(),o!==null?(u=ol(),u!==null?t=[t,o,u]:(t=null,n=d)):(t=null,n=d)):(t=null,n=d),t}function ol(){var t,o;for(t=[],o=Z(),o===null&&(o=se(),o===null&&(o=q()));o!==null;)t.push(o),o=Z(),o===null&&(o=se(),o===null&&(o=q()));return t}function zt(){var t,o;for(t=[],o=W();o!==null;)t.push(o),o=W();return t}function Xa(){var t,o,u;return u=n,e.substr(n,5)==="uuid:"?(t="uuid:",n+=5):(t=null,m('"uuid:"')),t!==null?(o=ul(),o!==null?t=[t,o]:(t=null,n=u)):(t=null,n=u),t}function ul(){var t,o,u,d,T,E,y,O,G,ye,je;return ye=n,je=n,t=Qa(),t!==null?(e.charCodeAt(n)===45?(o="-",n++):(o=null,m('"-"')),o!==null?(u=Xt(),u!==null?(e.charCodeAt(n)===45?(d="-",n++):(d=null,m('"-"')),d!==null?(T=Xt(),T!==null?(e.charCodeAt(n)===45?(E="-",n++):(E=null,m('"-"')),E!==null?(y=Xt(),y!==null?(e.charCodeAt(n)===45?(O="-",n++):(O=null,m('"-"')),O!==null?(G=cl(),G!==null?t=[t,o,u,d,T,E,y,O,G]:(t=null,n=je)):(t=null,n=je)):(t=null,n=je)):(t=null,n=je)):(t=null,n=je)):(t=null,n=je)):(t=null,n=je)):(t=null,n=je)):(t=null,n=je),t!==null&&(t=function(P,me){w=e.substring(n+5,P)}(ye,t[0])),t===null&&(n=ye),t}function Xt(){var t,o,u,d,T;return T=n,t=I(),t!==null?(o=I(),o!==null?(u=I(),u!==null?(d=I(),d!==null?t=[t,o,u,d]:(t=null,n=T)):(t=null,n=T)):(t=null,n=T)):(t=null,n=T),t}function Qa(){var t,o,u;return u=n,t=Xt(),t!==null?(o=Xt(),o!==null?t=[t,o]:(t=null,n=u)):(t=null,n=u),t}function cl(){var t,o,u,d;return d=n,t=Xt(),t!==null?(o=Xt(),o!==null?(u=Xt(),u!==null?t=[t,o,u]:(t=null,n=d)):(t=null,n=d)):(t=null,n=d),t}function fl(){var t,o,u,d,T,E,y;if(T=n,E=n,t=Fe(),t===null&&(t=as()),t!==null){for(o=[],y=n,u=le(),u!==null?(d=tt(),d!==null?u=[u,d]:(u=null,n=y)):(u=null,n=y);u!==null;)o.push(u),y=n,u=le(),u!==null?(d=tt(),d!==null?u=[u,d]:(u=null,n=y)):(u=null,n=y);o!==null?t=[t,o]:(t=null,n=E)}else t=null,n=E;return t!==null&&(t=function(O){try{w=new us(w.uri,w.display_name,w.params)}catch{w=-1}}()),t===null&&(n=T),t}function Za(){var t,o,u,d,T,E;if(T=n,t=_l(),t!==null){for(o=[],E=n,u=le(),u!==null?(d=hr(),d!==null?u=[u,d]:(u=null,n=E)):(u=null,n=E);u!==null;)o.push(u),E=n,u=le(),u!==null?(d=hr(),d!==null?u=[u,d]:(u=null,n=E)):(u=null,n=E);o!==null?t=[t,o]:(t=null,n=T)}else t=null,n=T;return t}function _l(){var t,o,u,d,T,E;return d=n,T=n,t=ae(),t!==null?(E=n,e.charCodeAt(n)===64?(o="@",n++):(o=null,m('"@"')),o!==null?(u=ae(),u!==null?o=[o,u]:(o=null,n=E)):(o=null,n=E),o=o!==null?o:"",o!==null?t=[t,o]:(t=null,n=T)):(t=null,n=T),t!==null&&(t=function(y){w.call_id=e.substring(n,y)}(d)),t===null&&(n=d),t}function hr(){var t;return t=eo(),t===null&&(t=to(),t===null&&(t=hl(),t===null&&(t=tt()))),t}function eo(){var t,o,u,d,T;return d=n,T=n,e.substr(n,6)==="to-tag"?(t="to-tag",n+=6):(t=null,m('"to-tag"')),t!==null?(o=Ce(),o!==null?(u=N(),u!==null?t=[t,o,u]:(t=null,n=T)):(t=null,n=T)):(t=null,n=T),t!==null&&(t=function(E,y){w.to_tag=y}(d,t[2])),t===null&&(n=d),t}function to(){var t,o,u,d,T;return d=n,T=n,e.substr(n,8)==="from-tag"?(t="from-tag",n+=8):(t=null,m('"from-tag"')),t!==null?(o=Ce(),o!==null?(u=N(),u!==null?t=[t,o,u]:(t=null,n=T)):(t=null,n=T)):(t=null,n=T),t!==null&&(t=function(E,y){w.from_tag=y}(d,t[2])),t===null&&(n=d),t}function hl(){var t,o;return o=n,e.substr(n,10)==="early-only"?(t="early-only",n+=10):(t=null,m('"early-only"')),t!==null&&(t=function(u){w.early_only=!0}()),t===null&&(n=o),t}function tn(t){t.sort();for(var o=null,u=[],d=0;d<t.length;d++)t[d]!==o&&(u.push(t[d]),o=t[d]);return u}function b(){for(var t=1,o=1,u=!1,d=0;d<Math.max(n,v);d++){var T=e.charAt(d);T===`
|
75
|
+
`?(u||t++,o=1,u=!1):T==="\r"||T==="\u2028"||T==="\u2029"?(t++,o=1,u=!0):(o++,u=!1)}return{line:t,column:o}}var so=ds(),us=Xo(),w={},no=g[p]();if(no===null||n!==e.length){var r=Math.max(n,v),f=r<e.length?e.charAt(r):null,h=b();return new this.SyntaxError(tn(S),f,r,h.line,h.column),-1}return w},toSource:function(){return this._source}};s.SyntaxError=function(e,p,g,n,v){function S(m,C){var A,R;switch(m.length){case 0:A="end of input";break;case 1:A=m[0];break;default:A=m.slice(0,m.length-1).join(", ")+" or "+m[m.length-1]}return R=C?c(C):"end of input","Expected "+A+" but "+R+" found."}this.name="SyntaxError",this.expected=e,this.found=p,this.message=S(e,p),this.offset=g,this.line=n,this.column=v},s.SyntaxError.prototype=Error.prototype;const i='INVITE sip:ds881ehp@6ke7klp2hppe.invalid;transport=ws;+sip.ice;reg-id=1;+sip.instance="<urn:uuid:378e5fc1-d7b5-42a9-8bf3-2b796aa0c67e>" SIP/2.0',l="INVITE sip:gsfjq6nt@6itebkeio2hf.invalid;transport=ws SIP/2.0",a=s.parse(i,"Request_Response");console.log("newRes",a),console.log("#############################################");const _=s.parse(l,"Request_Response");return console.log("oldRes",_),Cf}var Qo,bf;function ds(){if(bf)return Qo;bf=1;const c=xe,s=Tt(),i=Gt();return Qo=class L_{static parse(a){if(a=i.parse(a,"SIP_URI"),a!==-1)return a}constructor(a,_,e,p,g={},n={}){if(!e)throw new TypeError('missing or invalid "host" parameter');this._parameters={},this._headers={},this._scheme=a||c.SIP,this._user=_,this._host=e,this._port=p;for(const v in g)Object.prototype.hasOwnProperty.call(g,v)&&this.setParam(v,g[v]);for(const v in n)Object.prototype.hasOwnProperty.call(n,v)&&this.setHeader(v,n[v])}get scheme(){return this._scheme}set scheme(a){this._scheme=a.toLowerCase()}get user(){return this._user}set user(a){this._user=a}get host(){return this._host}set host(a){this._host=a.toLowerCase()}get port(){return this._port}set port(a){this._port=a===0?a:parseInt(a,10)||null}setParam(a,_){a&&(this._parameters[a.toLowerCase()]=typeof _>"u"||_===null?null:_.toString())}getParam(a){if(a)return this._parameters[a.toLowerCase()]}hasParam(a){if(a)return this._parameters.hasOwnProperty(a.toLowerCase())&&!0||!1}deleteParam(a){if(a=a.toLowerCase(),this._parameters.hasOwnProperty(a)){const _=this._parameters[a];return delete this._parameters[a],_}}clearParams(){this._parameters={}}setHeader(a,_){this._headers[s.headerize(a)]=Array.isArray(_)?_:[_]}getHeader(a){if(a)return this._headers[s.headerize(a)]}hasHeader(a){if(a)return this._headers.hasOwnProperty(s.headerize(a))&&!0||!1}deleteHeader(a){if(a=s.headerize(a),this._headers.hasOwnProperty(a)){const _=this._headers[a];return delete this._headers[a],_}}clearHeaders(){this._headers={}}clone(){return new L_(this._scheme,this._user,this._host,this._port,JSON.parse(JSON.stringify(this._parameters)),JSON.parse(JSON.stringify(this._headers)))}toString(){const a=[];let _=`${this._scheme}:`;this._user&&(_+=`${s.escapeUser(this._user)}@`),_+=this._host,(this._port||this._port===0)&&(_+=`:${this._port}`);for(const e in this._parameters)Object.prototype.hasOwnProperty.call(this._parameters,e)&&(_+=`;${e}`,this._parameters[e]!==null&&(_+=`=${this._parameters[e]}`));for(const e in this._headers)if(Object.prototype.hasOwnProperty.call(this._headers,e))for(const p of this._headers[e])a.push(`${e}=${p}`);return a.length>0&&(_+=`?${a.join("&")}`),_}toAor(a){let _=`${this._scheme}:`;return this._user&&(_+=`${s.escapeUser(this._user)}@`),_+=this._host,a&&(this._port||this._port===0)&&(_+=`:${this._port}`),_}},Qo}var wf;function Tt(){if(wf)return rt;wf=1;const c=xe,s=ds(),i=Gt();rt.str_utf8_length=e=>unescape(encodeURIComponent(e)).length;const l=rt.isFunction=e=>e!==void 0?Object.prototype.toString.call(e)==="[object Function]":!1;rt.isString=e=>e!==void 0?Object.prototype.toString.call(e)==="[object String]":!1,rt.isDecimal=e=>!isNaN(e)&&parseFloat(e)===parseInt(e,10),rt.isEmpty=e=>e===null||e===""||e===void 0||Array.isArray(e)&&e.length===0||typeof e=="number"&&isNaN(e),rt.hasMethods=function(e,...p){for(const g of p)if(l(e[g]))return!1;return!0};const a=rt.createRandomToken=(e,p=32)=>{let g,n,v="";for(g=0;g<e;g++)n=Math.random()*p|0,v+=n.toString(p);return v};rt.newTag=()=>a(10),rt.newUUID=()=>"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,p=>{const g=Math.random()*16|0;return(p==="x"?g:g&3|8).toString(16)}),rt.hostType=e=>{if(e){if(e=i.parse(e,"host"),e!==-1)return e.host_type}else return};const _=rt.escapeUser=e=>encodeURIComponent(decodeURIComponent(e)).replace(/%3A/ig,":").replace(/%2B/ig,"+").replace(/%3F/ig,"?").replace(/%2F/ig,"/");return rt.normalizeTarget=(e,p)=>{if(e){if(e instanceof s)return e;if(typeof e=="string"){const g=e.split("@");let n,v;switch(g.length){case 1:if(!p)return;n=e,v=p;break;case 2:n=g[0],v=g[1];break;default:n=g.slice(0,g.length-1).join("@"),v=g[g.length-1]}n=n.replace(/^(sips?|tel):/i,""),/^[-.()]*\+?[0-9\-.()]+$/.test(n)&&(n=n.replace(/[-.()]/g,"")),e=`${c.SIP}:${_(n)}@${v}`;let S;return(S=s.parse(e))?S:void 0}else return}else return},rt.headerize=e=>{const p={"Call-Id":"Call-ID",Cseq:"CSeq","Www-Authenticate":"WWW-Authenticate"},g=e.toLowerCase().replace(/_/g,"-").split("-");let n="";const v=g.length;let S;for(S=0;S<v;S++)S!==0&&(n+="-"),n+=g[S].charAt(0).toUpperCase()+g[S].substring(1);return p[n]&&(n=p[n]),n},rt.sipErrorCause=e=>{for(const p in c.SIP_ERROR_CAUSES)if(c.SIP_ERROR_CAUSES[p].indexOf(e)!==-1)return c.causes[p];return c.causes.SIP_FAILURE_CODE},rt.getRandomTestNetIP=()=>{function e(p,g){return Math.floor(Math.random()*(g-p+1)+p)}return`192.0.2.${e(1,254)}`},rt.calculateMD5=e=>{function p(le,Ae){return le<<Ae|le>>>32-Ae}function g(le,Ae){const Oe=le&2147483648,Pe=Ae&2147483648,ve=le&1073741824,he=Ae&1073741824,pe=(le&1073741823)+(Ae&1073741823);return ve&he?pe^2147483648^Oe^Pe:ve|he?pe&1073741824?pe^3221225472^Oe^Pe:pe^1073741824^Oe^Pe:pe^Oe^Pe}function n(le,Ae,Oe){return le&Ae|~le&Oe}function v(le,Ae,Oe){return le&Oe|Ae&~Oe}function S(le,Ae,Oe){return le^Ae^Oe}function m(le,Ae,Oe){return Ae^(le|~Oe)}function C(le,Ae,Oe,Pe,ve,he,pe){return le=g(le,g(g(n(Ae,Oe,Pe),ve),pe)),g(p(le,he),Ae)}function A(le,Ae,Oe,Pe,ve,he,pe){return le=g(le,g(g(v(Ae,Oe,Pe),ve),pe)),g(p(le,he),Ae)}function R(le,Ae,Oe,Pe,ve,he,pe){return le=g(le,g(g(S(Ae,Oe,Pe),ve),pe)),g(p(le,he),Ae)}function I(le,Ae,Oe,Pe,ve,he,pe){return le=g(le,g(g(m(Ae,Oe,Pe),ve),pe)),g(p(le,he),Ae)}function V(le){let Ae;const Oe=le.length,Pe=Oe+8,he=((Pe-Pe%64)/64+1)*16,pe=new Array(he-1);let Ne=0,Me=0;for(;Me<Oe;)Ae=(Me-Me%4)/4,Ne=Me%4*8,pe[Ae]=pe[Ae]|le.charCodeAt(Me)<<Ne,Me++;return Ae=(Me-Me%4)/4,Ne=Me%4*8,pe[Ae]=pe[Ae]|128<<Ne,pe[he-2]=Oe<<3,pe[he-1]=Oe>>>29,pe}function W(le){let Ae="",Oe="",Pe,ve;for(ve=0;ve<=3;ve++)Pe=le>>>ve*8&255,Oe=`0${Pe.toString(16)}`,Ae=Ae+Oe.substr(Oe.length-2,2);return Ae}function oe(le){let Ae="";for(let Oe=0;Oe<le.length;Oe++){const Pe=le.charCodeAt(Oe);Pe<128?Ae+=String.fromCharCode(Pe):Pe>127&&Pe<2048?(Ae+=String.fromCharCode(Pe>>6|192),Ae+=String.fromCharCode(Pe&63|128)):(Ae+=String.fromCharCode(Pe>>12|224),Ae+=String.fromCharCode(Pe>>6&63|128),Ae+=String.fromCharCode(Pe&63|128))}return Ae}let x=[],$,Re,be,H,D,L,q,j,B;const Q=7,Z=12,U=17,se=22,Dt=5,N=9,z=14,re=20,ae=4,Te=11,De=16,Ce=23,He=6,we=10,Se=15,ot=21;for(e=oe(e),x=V(e),L=1732584193,q=4023233417,j=2562383102,B=271733878,$=0;$<x.length;$+=16)Re=L,be=q,H=j,D=B,L=C(L,q,j,B,x[$+0],Q,3614090360),B=C(B,L,q,j,x[$+1],Z,3905402710),j=C(j,B,L,q,x[$+2],U,606105819),q=C(q,j,B,L,x[$+3],se,3250441966),L=C(L,q,j,B,x[$+4],Q,4118548399),B=C(B,L,q,j,x[$+5],Z,1200080426),j=C(j,B,L,q,x[$+6],U,2821735955),q=C(q,j,B,L,x[$+7],se,4249261313),L=C(L,q,j,B,x[$+8],Q,1770035416),B=C(B,L,q,j,x[$+9],Z,2336552879),j=C(j,B,L,q,x[$+10],U,4294925233),q=C(q,j,B,L,x[$+11],se,2304563134),L=C(L,q,j,B,x[$+12],Q,1804603682),B=C(B,L,q,j,x[$+13],Z,4254626195),j=C(j,B,L,q,x[$+14],U,2792965006),q=C(q,j,B,L,x[$+15],se,1236535329),L=A(L,q,j,B,x[$+1],Dt,4129170786),B=A(B,L,q,j,x[$+6],N,3225465664),j=A(j,B,L,q,x[$+11],z,643717713),q=A(q,j,B,L,x[$+0],re,3921069994),L=A(L,q,j,B,x[$+5],Dt,3593408605),B=A(B,L,q,j,x[$+10],N,38016083),j=A(j,B,L,q,x[$+15],z,3634488961),q=A(q,j,B,L,x[$+4],re,3889429448),L=A(L,q,j,B,x[$+9],Dt,568446438),B=A(B,L,q,j,x[$+14],N,3275163606),j=A(j,B,L,q,x[$+3],z,4107603335),q=A(q,j,B,L,x[$+8],re,1163531501),L=A(L,q,j,B,x[$+13],Dt,2850285829),B=A(B,L,q,j,x[$+2],N,4243563512),j=A(j,B,L,q,x[$+7],z,1735328473),q=A(q,j,B,L,x[$+12],re,2368359562),L=R(L,q,j,B,x[$+5],ae,4294588738),B=R(B,L,q,j,x[$+8],Te,2272392833),j=R(j,B,L,q,x[$+11],De,1839030562),q=R(q,j,B,L,x[$+14],Ce,4259657740),L=R(L,q,j,B,x[$+1],ae,2763975236),B=R(B,L,q,j,x[$+4],Te,1272893353),j=R(j,B,L,q,x[$+7],De,4139469664),q=R(q,j,B,L,x[$+10],Ce,3200236656),L=R(L,q,j,B,x[$+13],ae,681279174),B=R(B,L,q,j,x[$+0],Te,3936430074),j=R(j,B,L,q,x[$+3],De,3572445317),q=R(q,j,B,L,x[$+6],Ce,76029189),L=R(L,q,j,B,x[$+9],ae,3654602809),B=R(B,L,q,j,x[$+12],Te,3873151461),j=R(j,B,L,q,x[$+15],De,530742520),q=R(q,j,B,L,x[$+2],Ce,3299628645),L=I(L,q,j,B,x[$+0],He,4096336452),B=I(B,L,q,j,x[$+7],we,1126891415),j=I(j,B,L,q,x[$+14],Se,2878612391),q=I(q,j,B,L,x[$+5],ot,4237533241),L=I(L,q,j,B,x[$+12],He,1700485571),B=I(B,L,q,j,x[$+3],we,2399980690),j=I(j,B,L,q,x[$+10],Se,4293915773),q=I(q,j,B,L,x[$+1],ot,2240044497),L=I(L,q,j,B,x[$+8],He,1873313359),B=I(B,L,q,j,x[$+15],we,4264355552),j=I(j,B,L,q,x[$+6],Se,2734768916),q=I(q,j,B,L,x[$+13],ot,1309151649),L=I(L,q,j,B,x[$+4],He,4149444226),B=I(B,L,q,j,x[$+11],we,3174756917),j=I(j,B,L,q,x[$+2],Se,718787259),q=I(q,j,B,L,x[$+9],ot,3951481745),L=g(L,Re),q=g(q,be),j=g(j,H),B=g(B,D);return(W(L)+W(q)+W(j)+W(B)).toLowerCase()},rt.closeMediaStream=e=>{if(e)try{let p;if(e.getTracks){p=e.getTracks();for(const g of p)g.stop()}else{p=e.getAudioTracks();for(const g of p)g.stop();p=e.getVideoTracks();for(const g of p)g.stop()}}catch{(typeof e.stop=="function"||typeof e.stop=="object")&&e.stop()}},rt.cloneArray=e=>e&&e.slice()||[],rt.cloneObject=(e,p={})=>e&&Object.assign({},e)||p,rt}const Of=xt,Am=ut,vt=xe,at=Tt(),Df=Xo(),Cm=Gt(),Zo=new Am("SIPMessage");class ta{constructor(s,i,l,a,_,e){if(!s||!i||!l)return null;a=a||{},this.ua=l,this.headers={},this.method=s,this.ruri=i,this.body=e,this.extraHeaders=at.cloneArray(_),this.ua.configuration.extra_headers&&(this.extraHeaders=this.extraHeaders.concat(this.ua.configuration.extra_headers)),a.route_set?this.setHeader("route",a.route_set):l.configuration.use_preloaded_route&&this.setHeader("route",`<${l.transport.sip_uri};lr>`),this.setHeader("via",""),this.setHeader("max-forwards",vt.MAX_FORWARDS);const p=a.to_uri||i,g=a.to_tag?{tag:a.to_tag}:null,n=typeof a.to_display_name<"u"?a.to_display_name:null;this.to=new Df(p,n,g),this.setHeader("to",this.to.toString());const v=a.from_uri||l.configuration.uri,S={tag:a.from_tag||at.newTag()};let m;typeof a.from_display_name<"u"?m=a.from_display_name:l.configuration.display_name?m=l.configuration.display_name:m=null,this.from=new Df(v,m,S),this.setHeader("from",this.from.toString());const C=a.call_id||l.configuration.jssip_id+at.createRandomToken(15);this.call_id=C,this.setHeader("call-id",C);const A=a.cseq||Math.floor(Math.random()*1e4);this.cseq=A,this.setHeader("cseq",`${A} ${s}`)}setHeader(s,i){const l=new RegExp(`^\\s*${s}\\s*:`,"i");for(let a=0;a<this.extraHeaders.length;a++)l.test(this.extraHeaders[a])&&this.extraHeaders.splice(a,1);this.headers[at.headerize(s)]=Array.isArray(i)?i:[i]}getHeader(s){const i=this.headers[at.headerize(s)];if(i){if(i[0])return i[0]}else{const l=new RegExp(`^\\s*${s}\\s*:`,"i");for(const a of this.extraHeaders)if(l.test(a))return a.substring(a.indexOf(":")+1).trim()}}getHeaders(s){const i=this.headers[at.headerize(s)],l=[];if(i){for(const a of i)l.push(a);return l}else{const a=new RegExp(`^\\s*${s}\\s*:`,"i");for(const _ of this.extraHeaders)a.test(_)&&l.push(_.substring(_.indexOf(":")+1).trim());return l}}hasHeader(s){if(this.headers[at.headerize(s)])return!0;{const i=new RegExp(`^\\s*${s}\\s*:`,"i");for(const l of this.extraHeaders)if(i.test(l))return!0}return!1}parseSDP(s){return!s&&this.sdp?this.sdp:(this.sdp=Of.parse(this.body||""),this.sdp)}toString(){let s=`${this.method} ${this.ruri} SIP/2.0\r
|
76
|
+
`;for(const a in this.headers)if(Object.prototype.hasOwnProperty.call(this.headers,a))for(const _ of this.headers[a])s+=`${a}: ${_}\r
|
77
|
+
`;for(const a of this.extraHeaders)s+=`${a.trim()}\r
|
78
|
+
`;const i=[];switch(this.method){case vt.REGISTER:i.push("path","gruu");break;case vt.INVITE:this.ua.configuration.session_timers&&i.push("timer"),(this.ua.contact.pub_gruu||this.ua.contact.temp_gruu)&&i.push("gruu"),i.push("ice","replaces");break;case vt.UPDATE:this.ua.configuration.session_timers&&i.push("timer"),i.push("ice");break}i.push("outbound");const l=this.ua.configuration.user_agent||vt.USER_AGENT;if(s+=`Allow: ${vt.ALLOWED_METHODS}\r
|
79
|
+
`,s+=`Supported: ${i}\r
|
80
|
+
`,s+=`User-Agent: ${l}\r
|
81
|
+
`,this.body){const a=at.str_utf8_length(this.body);s+=`Content-Length: ${a}\r
|
82
82
|
\r
|
83
|
-
`,
|
83
|
+
`,s+=this.body}else s+=`Content-Length: 0\r
|
84
84
|
\r
|
85
|
-
`;return
|
86
|
-
`;if(this.method===
|
87
|
-
`}const
|
88
|
-
`;!this.to_tag&&
|
89
|
-
`,
|
90
|
-
`,
|
91
|
-
`,
|
92
|
-
`;for(const
|
93
|
-
`;switch(this.method){case
|
94
|
-
`,
|
95
|
-
`):
|
96
|
-
`:
|
97
|
-
`),
|
98
|
-
`,
|
99
|
-
`,
|
85
|
+
`;return s}clone(){const s=new ta(this.method,this.ruri,this.ua);return Object.keys(this.headers).forEach(function(i){s.headers[i]=this.headers[i].slice()},this),s.body=this.body,s.extraHeaders=at.cloneArray(this.extraHeaders),s.to=this.to,s.from=this.from,s.call_id=this.call_id,s.cseq=this.cseq,s}}class eu extends ta{constructor(s,i,l,a,_){super(vt.INVITE,s,i,l,a,_),this.transaction=null}cancel(s){this.transaction.cancel(s)}clone(){const s=new eu(this.ruri,this.ua);return Object.keys(this.headers).forEach(function(i){s.headers[i]=this.headers[i].slice()},this),s.body=this.body,s.extraHeaders=at.cloneArray(this.extraHeaders),s.to=this.to,s.from=this.from,s.call_id=this.call_id,s.cseq=this.cseq,s.transaction=this.transaction,s}}class Nf{constructor(){this.data=null,this.headers=null,this.method=null,this.via=null,this.via_branch=null,this.call_id=null,this.cseq=null,this.from=null,this.from_tag=null,this.to=null,this.to_tag=null,this.body=null,this.sdp=null}addHeader(s,i){const l={raw:i};s=at.headerize(s),this.headers[s]?this.headers[s].push(l):this.headers[s]=[l]}getHeader(s){const i=this.headers[at.headerize(s)];if(i){if(i[0])return i[0].raw}else return}getHeaders(s){const i=this.headers[at.headerize(s)],l=[];if(!i)return[];for(const a of i)l.push(a.raw);return l}hasHeader(s){return!!this.headers[at.headerize(s)]}parseHeader(s,i=0){if(s=at.headerize(s),this.headers[s]){if(i>=this.headers[s].length){Zo.debug(`not so many "${s}" headers present`);return}}else{Zo.debug(`header "${s}" not present`);return}const l=this.headers[s][i],a=l.raw;if(l.parsed)return l.parsed;const _=Cm.parse(a,s.replace(/-/g,"_"));if(_===-1){this.headers[s].splice(i,1),Zo.debug(`error parsing "${s}" header field with value "${a}"`);return}else return l.parsed=_,_}s(s,i){return this.parseHeader(s,i)}setHeader(s,i){const l={raw:i};this.headers[at.headerize(s)]=[l]}parseSDP(s){return!s&&this.sdp?this.sdp:(this.sdp=Of.parse(this.body||""),this.sdp)}toString(){return this.data}}class Rm extends Nf{constructor(s){super(),this.ua=s,this.headers={},this.ruri=null,this.transport=null,this.server_transaction=null}reply(s,i,l,a,_,e){const p=[];let g=this.getHeader("To");if(s=s||null,i=i||null,!s||s<100||s>699)throw new TypeError(`Invalid status_code: ${s}`);if(i&&typeof i!="string"&&!(i instanceof String))throw new TypeError(`Invalid reason_phrase: ${i}`);i=i||vt.REASON_PHRASE[s]||"",l=at.cloneArray(l),this.ua.configuration.extra_headers&&(l=l.concat(this.ua.configuration.extra_headers));let n=`SIP/2.0 ${s} ${i}\r
|
86
|
+
`;if(this.method===vt.INVITE&&s>100&&s<=200){const S=this.getHeaders("record-route");for(const m of S)n+=`Record-Route: ${m}\r
|
87
|
+
`}const v=this.getHeaders("via");for(const S of v)n+=`Via: ${S}\r
|
88
|
+
`;!this.to_tag&&s>100?g+=`;tag=${at.newTag()}`:this.to_tag&&!this.s("to").hasParam("tag")&&(g+=`;tag=${this.to_tag}`),n+=`To: ${g}\r
|
89
|
+
`,n+=`From: ${this.getHeader("From")}\r
|
90
|
+
`,n+=`Call-ID: ${this.call_id}\r
|
91
|
+
`,n+=`CSeq: ${this.cseq} ${this.method}\r
|
92
|
+
`;for(const S of l)n+=`${S.trim()}\r
|
93
|
+
`;switch(this.method){case vt.INVITE:this.ua.configuration.session_timers&&p.push("timer"),(this.ua.contact.pub_gruu||this.ua.contact.temp_gruu)&&p.push("gruu"),p.push("ice","replaces");break;case vt.UPDATE:this.ua.configuration.session_timers&&p.push("timer"),a&&p.push("ice"),p.push("replaces")}if(p.push("outbound"),this.method===vt.OPTIONS?(n+=`Allow: ${vt.ALLOWED_METHODS}\r
|
94
|
+
`,n+=`Accept: ${vt.ACCEPTED_BODY_TYPES}\r
|
95
|
+
`):s===405?n+=`Allow: ${vt.ALLOWED_METHODS}\r
|
96
|
+
`:s===415&&(n+=`Accept: ${vt.ACCEPTED_BODY_TYPES}\r
|
97
|
+
`),n+=`Supported: ${p}\r
|
98
|
+
`,a){const S=at.str_utf8_length(a);n+=`Content-Type: application/sdp\r
|
99
|
+
`,n+=`Content-Length: ${S}\r
|
100
100
|
\r
|
101
|
-
`,
|
101
|
+
`,n+=a}else n+=`Content-Length: 0\r
|
102
102
|
\r
|
103
|
-
`;this.server_transaction.receiveResponse(n,
|
104
|
-
`;for(const
|
105
|
-
`;let
|
106
|
-
`,
|
107
|
-
`,
|
108
|
-
`,
|
109
|
-
`,this.ua.configuration.extra_headers)for(const
|
110
|
-
`;
|
103
|
+
`;this.server_transaction.receiveResponse(s,n,_,e)}reply_sl(s=null,i=null){const l=this.getHeaders("via");if(!s||s<100||s>699)throw new TypeError(`Invalid status_code: ${s}`);if(i&&typeof i!="string"&&!(i instanceof String))throw new TypeError(`Invalid reason_phrase: ${i}`);i=i||vt.REASON_PHRASE[s]||"";let a=`SIP/2.0 ${s} ${i}\r
|
104
|
+
`;for(const e of l)a+=`Via: ${e}\r
|
105
|
+
`;let _=this.getHeader("To");if(!this.to_tag&&s>100?_+=`;tag=${at.newTag()}`:this.to_tag&&!this.s("to").hasParam("tag")&&(_+=`;tag=${this.to_tag}`),a+=`To: ${_}\r
|
106
|
+
`,a+=`From: ${this.getHeader("From")}\r
|
107
|
+
`,a+=`Call-ID: ${this.call_id}\r
|
108
|
+
`,a+=`CSeq: ${this.cseq} ${this.method}\r
|
109
|
+
`,this.ua.configuration.extra_headers)for(const e of this.ua.configuration.extra_headers)a+=`${e.trim()}\r
|
110
|
+
`;a+=`Content-Length: 0\r
|
111
111
|
\r
|
112
|
-
`,this.transport.send(o)}}class wm extends Uf{constructor(){super(),this.headers={},this.status_code=null,this.reason_phrase=null}}var kt={OutgoingRequest:Wa,InitialOutgoingInviteRequest:fu,IncomingRequest:Im,IncomingResponse:wm};const ir=Be(kt),Om=Tt,En=wt(),ys=new Om("DigestAuthentication");var xf=class{constructor(n){this._credentials=n,this._cnonce=null,this._nc=0,this._ncHex="00000000",this._algorithm=null,this._realm=null,this._nonce=null,this._opaque=null,this._stale=null,this._qop=null,this._method=null,this._uri=null,this._ha1=null,this._response=null}get(n){switch(n){case"realm":return this._realm;case"ha1":return this._ha1;default:ys.warn('get() | cannot get "%s" parameter',n);return}}authenticate({method:n,ruri:a,body:e},o,p=null){if(this._algorithm=o.algorithm,this._realm=o.realm,this._nonce=o.nonce,this._opaque=o.opaque,this._stale=o.stale,this._algorithm){if(this._algorithm!=="MD5")return ys.warn('authenticate() | challenge with Digest algorithm different than "MD5", authentication aborted'),!1}else this._algorithm="MD5";if(!this._nonce)return ys.warn("authenticate() | challenge without Digest nonce, authentication aborted"),!1;if(!this._realm)return ys.warn("authenticate() | challenge without Digest realm, authentication aborted"),!1;if(!this._credentials.password){if(!this._credentials.ha1)return ys.warn("authenticate() | no plain SIP password nor ha1 provided, authentication aborted"),!1;if(this._credentials.realm!==this._realm)return ys.warn('authenticate() | no plain SIP password, and stored `realm` does not match the given `realm`, cannot authenticate [stored:"%s", given:"%s"]',this._credentials.realm,this._realm),!1}if(o.qop)if(o.qop.indexOf("auth-int")>-1)this._qop="auth-int";else if(o.qop.indexOf("auth")>-1)this._qop="auth";else return ys.warn('authenticate() | challenge without Digest qop different than "auth" or "auth-int", authentication aborted'),!1;else this._qop=null;this._method=n,this._uri=a,this._cnonce=p||En.createRandomToken(12),this._nc+=1;const t=Number(this._nc).toString(16);this._ncHex="00000000".substr(0,8-t.length)+t,this._nc===4294967296&&(this._nc=1,this._ncHex="00000001"),this._credentials.password?this._ha1=En.calculateMD5(`${this._credentials.username}:${this._realm}:${this._credentials.password}`):this._ha1=this._credentials.ha1;let v,C;return this._qop==="auth"?(v=`${this._method}:${this._uri}`,C=En.calculateMD5(v),ys.debug('authenticate() | using qop=auth [a2:"%s"]',v),this._response=En.calculateMD5(`${this._ha1}:${this._nonce}:${this._ncHex}:${this._cnonce}:auth:${C}`)):this._qop==="auth-int"?(v=`${this._method}:${this._uri}:${En.calculateMD5(e||"")}`,C=En.calculateMD5(v),ys.debug('authenticate() | using qop=auth-int [a2:"%s"]',v),this._response=En.calculateMD5(`${this._ha1}:${this._nonce}:${this._ncHex}:${this._cnonce}:auth-int:${C}`)):this._qop===null&&(v=`${this._method}:${this._uri}`,C=En.calculateMD5(v),ys.debug('authenticate() | using qop=null [a2:"%s"]',v),this._response=En.calculateMD5(`${this._ha1}:${this._nonce}:${C}`)),ys.debug("authenticate() | response generated"),!0}toString(){const n=[];if(!this._response)throw new Error("response field does not exist, cannot generate Authorization header");return n.push(`algorithm=${this._algorithm}`),n.push(`username="${this._credentials.username}"`),n.push(`realm="${this._realm}"`),n.push(`nonce="${this._nonce}"`),n.push(`uri="${this._uri}"`),n.push(`response="${this._response}"`),this._opaque&&n.push(`opaque="${this._opaque}"`),this._qop&&(n.push(`qop=${this._qop}`),n.push(`cnonce="${this._cnonce}"`),n.push(`nc=${this._ncHex}`)),`Digest ${n.join(", ")}`}};const Dm=Be(xf),Cn=500,Nm=4e3,Pf=5e3;var hu={T1:Cn,T2:Nm,T4:Pf,TIMER_B:64*Cn,TIMER_D:0*Cn,TIMER_F:64*Cn,TIMER_H:64*Cn,TIMER_I:0*Cn,TIMER_J:0*Cn,TIMER_K:0*Pf,TIMER_L:64*Cn,TIMER_M:64*Cn,PROVISIONAL_RESPONSE_INTERVAL:6e4};const Pi=Be(hu),Mi=Ct.EventEmitter,ki=Tt,Li=Fe,Mf=kt,zs=hu,kf=new ki("NonInviteClientTransaction"),Ka=new ki("InviteClientTransaction"),Um=new ki("AckClientTransaction"),Lf=new ki("NonInviteServerTransaction"),Ya=new ki("InviteServerTransaction"),ve={STATUS_TRYING:1,STATUS_PROCEEDING:2,STATUS_CALLING:3,STATUS_ACCEPTED:4,STATUS_COMPLETED:5,STATUS_TERMINATED:6,STATUS_CONFIRMED:7,NON_INVITE_CLIENT:"nict",NON_INVITE_SERVER:"nist",INVITE_CLIENT:"ict",INVITE_SERVER:"ist"};class xm extends Mi{constructor(n,a,e,o){super(),this.type=ve.NON_INVITE_CLIENT,this.id=`z9hG4bK${Math.floor(Math.random()*1e7)}`,this.ua=n,this.transport=a,this.request=e,this.eventHandlers=o;let p=`SIP/2.0/${a.via_transport}`;p+=` ${n.configuration.via_host};branch=${this.id}`,this.request.setHeader("via",p),this.ua.newTransaction(this)}get C(){return ve}stateChanged(n){this.state=n,this.emit("stateChanged")}send(){this.stateChanged(ve.STATUS_TRYING),this.F=setTimeout(()=>{this.timer_F()},zs.TIMER_F),this.transport.send(this.request)||this.onTransportError()}onTransportError(){kf.debug(`transport error occurred, deleting transaction ${this.id}`),clearTimeout(this.F),clearTimeout(this.K),this.stateChanged(ve.STATUS_TERMINATED),this.ua.destroyTransaction(this),this.eventHandlers.onTransportError()}timer_F(){kf.debug(`Timer F expired for transaction ${this.id}`),this.stateChanged(ve.STATUS_TERMINATED),this.ua.destroyTransaction(this),this.eventHandlers.onRequestTimeout()}timer_K(){this.stateChanged(ve.STATUS_TERMINATED),this.ua.destroyTransaction(this)}receiveResponse(n){const a=n.status_code;if(a<200)switch(this.state){case ve.STATUS_TRYING:case ve.STATUS_PROCEEDING:this.stateChanged(ve.STATUS_PROCEEDING),this.eventHandlers.onReceiveResponse(n);break}else switch(this.state){case ve.STATUS_TRYING:case ve.STATUS_PROCEEDING:this.stateChanged(ve.STATUS_COMPLETED),clearTimeout(this.F),a===408?this.eventHandlers.onRequestTimeout():this.eventHandlers.onReceiveResponse(n),this.K=setTimeout(()=>{this.timer_K()},zs.TIMER_K);break;case ve.STATUS_COMPLETED:break}}}class Pm extends Mi{constructor(n,a,e,o){super(),this.type=ve.INVITE_CLIENT,this.id=`z9hG4bK${Math.floor(Math.random()*1e7)}`,this.ua=n,this.transport=a,this.request=e,this.eventHandlers=o,e.transaction=this;let p=`SIP/2.0/${a.via_transport}`;p+=` ${n.configuration.via_host};branch=${this.id}`,this.request.setHeader("via",p),this.ua.newTransaction(this)}get C(){return ve}stateChanged(n){this.state=n,this.emit("stateChanged")}send(){this.stateChanged(ve.STATUS_CALLING),this.B=setTimeout(()=>{this.timer_B()},zs.TIMER_B),this.transport.send(this.request)||this.onTransportError()}onTransportError(){clearTimeout(this.B),clearTimeout(this.D),clearTimeout(this.M),this.state!==ve.STATUS_ACCEPTED&&(Ka.debug(`transport error occurred, deleting transaction ${this.id}`),this.eventHandlers.onTransportError()),this.stateChanged(ve.STATUS_TERMINATED),this.ua.destroyTransaction(this)}timer_M(){Ka.debug(`Timer M expired for transaction ${this.id}`),this.state===ve.STATUS_ACCEPTED&&(clearTimeout(this.B),this.stateChanged(ve.STATUS_TERMINATED),this.ua.destroyTransaction(this))}timer_B(){Ka.debug(`Timer B expired for transaction ${this.id}`),this.state===ve.STATUS_CALLING&&(this.stateChanged(ve.STATUS_TERMINATED),this.ua.destroyTransaction(this),this.eventHandlers.onRequestTimeout())}timer_D(){Ka.debug(`Timer D expired for transaction ${this.id}`),clearTimeout(this.B),this.stateChanged(ve.STATUS_TERMINATED),this.ua.destroyTransaction(this)}sendACK(n){const a=new Mf.OutgoingRequest(Li.ACK,this.request.ruri,this.ua,{route_set:this.request.getHeaders("route"),call_id:this.request.getHeader("call-id"),cseq:this.request.cseq});a.setHeader("from",this.request.getHeader("from")),a.setHeader("via",this.request.getHeader("via")),a.setHeader("to",n.getHeader("to")),this.D=setTimeout(()=>{this.timer_D()},zs.TIMER_D),this.transport.send(a)}cancel(n){if(this.state!==ve.STATUS_PROCEEDING)return;const a=new Mf.OutgoingRequest(Li.CANCEL,this.request.ruri,this.ua,{route_set:this.request.getHeaders("route"),call_id:this.request.getHeader("call-id"),cseq:this.request.cseq});a.setHeader("from",this.request.getHeader("from")),a.setHeader("via",this.request.getHeader("via")),a.setHeader("to",this.request.getHeader("to")),n&&a.setHeader("reason",n),this.transport.send(a)}receiveResponse(n){const a=n.status_code;if(a>=100&&a<=199)switch(this.state){case ve.STATUS_CALLING:this.stateChanged(ve.STATUS_PROCEEDING),this.eventHandlers.onReceiveResponse(n);break;case ve.STATUS_PROCEEDING:this.eventHandlers.onReceiveResponse(n);break}else if(a>=200&&a<=299)switch(this.state){case ve.STATUS_CALLING:case ve.STATUS_PROCEEDING:this.stateChanged(ve.STATUS_ACCEPTED),this.M=setTimeout(()=>{this.timer_M()},zs.TIMER_M),this.eventHandlers.onReceiveResponse(n);break;case ve.STATUS_ACCEPTED:this.eventHandlers.onReceiveResponse(n);break}else if(a>=300&&a<=699)switch(this.state){case ve.STATUS_CALLING:case ve.STATUS_PROCEEDING:this.stateChanged(ve.STATUS_COMPLETED),this.sendACK(n),this.eventHandlers.onReceiveResponse(n);break;case ve.STATUS_COMPLETED:this.sendACK(n);break}}}class Mm extends Mi{constructor(n,a,e,o){super(),this.id=`z9hG4bK${Math.floor(Math.random()*1e7)}`,this.transport=a,this.request=e,this.eventHandlers=o;let p=`SIP/2.0/${a.via_transport}`;p+=` ${n.configuration.via_host};branch=${this.id}`,this.request.setHeader("via",p)}get C(){return ve}send(){this.transport.send(this.request)||this.onTransportError()}onTransportError(){Um.debug(`transport error occurred for transaction ${this.id}`),this.eventHandlers.onTransportError()}}class km extends Mi{constructor(n,a,e){super(),this.type=ve.NON_INVITE_SERVER,this.id=e.via_branch,this.ua=n,this.transport=a,this.request=e,this.last_response="",e.server_transaction=this,this.state=ve.STATUS_TRYING,n.newTransaction(this)}get C(){return ve}stateChanged(n){this.state=n,this.emit("stateChanged")}timer_J(){Lf.debug(`Timer J expired for transaction ${this.id}`),this.stateChanged(ve.STATUS_TERMINATED),this.ua.destroyTransaction(this)}onTransportError(){this.transportError||(this.transportError=!0,Lf.debug(`transport error occurred, deleting transaction ${this.id}`),clearTimeout(this.J),this.stateChanged(ve.STATUS_TERMINATED),this.ua.destroyTransaction(this))}receiveResponse(n,a,e,o){if(n===100)switch(this.state){case ve.STATUS_TRYING:this.stateChanged(ve.STATUS_PROCEEDING),this.transport.send(a)||this.onTransportError();break;case ve.STATUS_PROCEEDING:this.last_response=a,this.transport.send(a)?e&&e():(this.onTransportError(),o&&o());break}else if(n>=200&&n<=699)switch(this.state){case ve.STATUS_TRYING:case ve.STATUS_PROCEEDING:this.stateChanged(ve.STATUS_COMPLETED),this.last_response=a,this.J=setTimeout(()=>{this.timer_J()},zs.TIMER_J),this.transport.send(a)?e&&e():(this.onTransportError(),o&&o());break;case ve.STATUS_COMPLETED:break}}}class Lm extends Mi{constructor(n,a,e){super(),this.type=ve.INVITE_SERVER,this.id=e.via_branch,this.ua=n,this.transport=a,this.request=e,this.last_response="",e.server_transaction=this,this.state=ve.STATUS_PROCEEDING,n.newTransaction(this),this.resendProvisionalTimer=null,e.reply(100)}get C(){return ve}stateChanged(n){this.state=n,this.emit("stateChanged")}timer_H(){Ya.debug(`Timer H expired for transaction ${this.id}`),this.state===ve.STATUS_COMPLETED&&Ya.debug("ACK not received, dialog will be terminated"),this.stateChanged(ve.STATUS_TERMINATED),this.ua.destroyTransaction(this)}timer_I(){this.stateChanged(ve.STATUS_TERMINATED),this.ua.destroyTransaction(this)}timer_L(){Ya.debug(`Timer L expired for transaction ${this.id}`),this.state===ve.STATUS_ACCEPTED&&(this.stateChanged(ve.STATUS_TERMINATED),this.ua.destroyTransaction(this))}onTransportError(){this.transportError||(this.transportError=!0,Ya.debug(`transport error occurred, deleting transaction ${this.id}`),this.resendProvisionalTimer!==null&&(clearInterval(this.resendProvisionalTimer),this.resendProvisionalTimer=null),clearTimeout(this.L),clearTimeout(this.H),clearTimeout(this.I),this.stateChanged(ve.STATUS_TERMINATED),this.ua.destroyTransaction(this))}resend_provisional(){this.transport.send(this.last_response)||this.onTransportError()}receiveResponse(n,a,e,o){if(n>=100&&n<=199)switch(this.state){case ve.STATUS_PROCEEDING:this.transport.send(a)||this.onTransportError(),this.last_response=a;break}if(n>100&&n<=199&&this.state===ve.STATUS_PROCEEDING)this.resendProvisionalTimer===null&&(this.resendProvisionalTimer=setInterval(()=>{this.resend_provisional()},zs.PROVISIONAL_RESPONSE_INTERVAL));else if(n>=200&&n<=299)switch(this.state){case ve.STATUS_PROCEEDING:this.stateChanged(ve.STATUS_ACCEPTED),this.last_response=a,this.L=setTimeout(()=>{this.timer_L()},zs.TIMER_L),this.resendProvisionalTimer!==null&&(clearInterval(this.resendProvisionalTimer),this.resendProvisionalTimer=null);case ve.STATUS_ACCEPTED:this.transport.send(a)?e&&e():(this.onTransportError(),o&&o());break}else if(n>=300&&n<=699)switch(this.state){case ve.STATUS_PROCEEDING:this.resendProvisionalTimer!==null&&(clearInterval(this.resendProvisionalTimer),this.resendProvisionalTimer=null),this.transport.send(a)?(this.stateChanged(ve.STATUS_COMPLETED),this.H=setTimeout(()=>{this.timer_H()},zs.TIMER_H),e&&e()):(this.onTransportError(),o&&o());break}}}function $m({_transactions:u},n){let a;switch(n.method){case Li.INVITE:if(a=u.ist[n.via_branch],a){switch(a.state){case ve.STATUS_PROCEEDING:a.transport.send(a.last_response);break;case ve.STATUS_ACCEPTED:break}return!0}break;case Li.ACK:if(a=u.ist[n.via_branch],a){if(a.state===ve.STATUS_ACCEPTED)return!1;if(a.state===ve.STATUS_COMPLETED)return a.state=ve.STATUS_CONFIRMED,a.I=setTimeout(()=>{a.timer_I()},zs.TIMER_I),!0}else return!1;break;case Li.CANCEL:return a=u.ist[n.via_branch],a?(n.reply_sl(200),a.state!==ve.STATUS_PROCEEDING):(n.reply_sl(481),!0);default:if(a=u.nist[n.via_branch],a){switch(a.state){case ve.STATUS_TRYING:break;case ve.STATUS_PROCEEDING:case ve.STATUS_COMPLETED:a.transport.send(a.last_response);break}return!0}break}}var Yr={C:ve,NonInviteClientTransaction:xm,InviteClientTransaction:Pm,AckClientTransaction:Mm,NonInviteServerTransaction:km,InviteServerTransaction:Lm,checkTransaction:$m};const os=Be(Yr),Hm=Tt,$f=Fe,Fm=xf,_u=Yr,qm=new Hm("RequestSender"),du={onRequestTimeout:()=>{},onTransportError:()=>{},onReceiveResponse:()=>{},onAuthenticated:()=>{}};var zr=class{constructor(n,a,e){this._ua=n,this._eventHandlers=e,this._method=a.method,this._request=a,this._auth=null,this._challenged=!1,this._staled=!1;for(const o in du)Object.prototype.hasOwnProperty.call(du,o)&&(this._eventHandlers[o]||(this._eventHandlers[o]=du[o]));n.status===n.C.STATUS_USER_CLOSED&&(this._method!==$f.BYE||this._method!==$f.ACK)&&this._eventHandlers.onTransportError()}send(){const n={onRequestTimeout:()=>{this._eventHandlers.onRequestTimeout()},onTransportError:()=>{this._eventHandlers.onTransportError()},onReceiveResponse:a=>{this._receiveResponse(a)}};switch(this._method){case"INVITE":this.clientTransaction=new _u.InviteClientTransaction(this._ua,this._ua.transport,this._request,n);break;case"ACK":this.clientTransaction=new _u.AckClientTransaction(this._ua,this._ua.transport,this._request,n);break;default:this.clientTransaction=new _u.NonInviteClientTransaction(this._ua,this._ua.transport,this._request,n)}this._ua._configuration.authorization_jwt&&this._request.setHeader("Authorization",this._ua._configuration.authorization_jwt),this.clientTransaction.send()}_receiveResponse(n){let a,e;const o=n.status_code;if((o===401||o===407)&&(this._ua.configuration.password!==null||this._ua.configuration.ha1!==null)){if(n.status_code===401?(a=n.parseHeader("www-authenticate"),e="authorization"):(a=n.parseHeader("proxy-authenticate"),e="proxy-authorization"),!a){qm.debug(`${n.status_code} with wrong or missing challenge, cannot authenticate`),this._eventHandlers.onReceiveResponse(n);return}if(!this._challenged||!this._staled&&a.stale===!0){if(this._auth||(this._auth=new Fm({username:this._ua.configuration.authorization_user,password:this._ua.configuration.password,realm:this._ua.configuration.realm,ha1:this._ua.configuration.ha1})),!this._auth.authenticate(this._request,a)){this._eventHandlers.onReceiveResponse(n);return}this._challenged=!0,this._ua.set("realm",this._auth.get("realm")),this._ua.set("ha1",this._auth.get("ha1")),a.stale&&(this._staled=!0),this._request=this._request.clone(),this._request.cseq+=1,this._request.setHeader("cseq",`${this._request.cseq} ${this._method}`),this._request.setHeader(e,this._auth.toString()),this._eventHandlers.onAuthenticated(this._request),this.send()}else this._eventHandlers.onReceiveResponse(n)}else this._eventHandlers.onReceiveResponse(n)}};const za=Be(zr),jm=Tt,pu=wt(),ar=Fe,Hf=kt,Ff=zr,$i=new jm("Registrator"),Ja=10;var Vm=class{constructor(n,a){this._reg_id=1,this._ua=n,this._transport=a,this._registrar=n.configuration.registrar_server,this._expires=n.configuration.register_expires,this._call_id=pu.createRandomToken(22),this._cseq=0,this._to_uri=n.configuration.uri,this._registrationTimer=null,this._registering=!1,this._registered=!1,this._contact=this._ua.contact.toString(),this._extraContactParams+=";+sip.ice",this._extraHeaders=[],this._sipInstance=`"<urn:uuid:${this._ua.configuration.instance_id}>"`,this._extraContactParams+=`;reg-id=${this._reg_id}`,this._extraContactParams+=`;+sip.instance=${this._sipInstance}`}get registered(){return this._registered}setExtraHeaders(n){Array.isArray(n)||(n=[]),this._extraHeaders=n.slice()}setExtraContactParams(n){n instanceof Object||(n={}),this._extraContactParams="";for(const a in n)if(Object.prototype.hasOwnProperty.call(n,a)){const e=n[a];this._extraContactParams+=`;${a}`,e&&(this._extraContactParams+=`=${e}`)}}register(){if(this._registering){$i.debug("Register request in progress...");return}const n=this._extraHeaders.slice();n.push(`Contact: ${this._contact};expires=${this._expires}${this._extraContactParams}`),n.push(`Expires: ${this._expires}`);const a=new Hf.OutgoingRequest(ar.REGISTER,this._registrar,this._ua,{to_uri:this._to_uri,call_id:this._call_id,cseq:this._cseq+=1},n),e=new Ff(this._ua,a,{onRequestTimeout:()=>{this._registrationFailure(null,ar.causes.REQUEST_TIMEOUT)},onTransportError:()=>{this._registrationFailure(null,ar.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")){$i.debug("no Contact header in response to REGISTER, response ignored");break}const p=o.headers.Contact.reduce((l,A)=>l.concat(A.parsed),[]);let t=p.find(l=>this._sipInstance===l.getParam("+sip.instance")&&this._reg_id===parseInt(l.getParam("reg-id")));if(t||(t=p.find(l=>l.uri.user===this._ua.contact.uri.user)),!t){$i.debug("no Contact header pointing to us, response ignored");break}let v=t.getParam("expires");!v&&o.hasHeader("expires")&&(v=o.getHeader("expires")),v||(v=this._expires),v=Number(v),v<Ja&&(v=Ja);const C=v>64?v*1e3/2+Math.floor((v/2-32)*1e3*Math.random()):v*1e3-5e3;this._registrationTimer=setTimeout(()=>{this._registrationTimer=null,this._ua.listeners("registrationExpiring").length===0?this.register():this._ua.emit("registrationExpiring")},C),t.hasParam("temp-gruu")&&(this._ua.contact.temp_gruu=t.getParam("temp-gruu").replace(/"/g,"")),t.hasParam("pub-gruu")&&(this._ua.contact.pub_gruu=t.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<Ja&&(this._expires=Ja),this.register()):($i.debug("423 response received for REGISTER without Min-Expires"),this._registrationFailure(o,ar.causes.SIP_FAILURE_CODE));break}default:{const p=pu.sipErrorCause(o.status_code);this._registrationFailure(o,p)}}}});this._registering=!0,e.send()}unregister(n={}){if(!this._registered){$i.debug("already unregistered");return}this._registered=!1,this._registrationTimer!==null&&(clearTimeout(this._registrationTimer),this._registrationTimer=null);const a=this._extraHeaders.slice();n.all?a.push(`Contact: *${this._extraContactParams}`):a.push(`Contact: ${this._contact};expires=0${this._extraContactParams}`),a.push("Expires: 0");const e=new Hf.OutgoingRequest(ar.REGISTER,this._registrar,this._ua,{to_uri:this._to_uri,call_id:this._call_id,cseq:this._cseq+=1},a);new Ff(this._ua,e,{onRequestTimeout:()=>{this._unregistered(null,ar.causes.REQUEST_TIMEOUT)},onTransportError:()=>{this._unregistered(null,ar.causes.CONNECTION_ERROR)},onAuthenticated:()=>{this._cseq+=1},onReceiveResponse:p=>{switch(!0){case/^1[0-9]{2}$/.test(p.status_code):break;case/^2[0-9]{2}$/.test(p.status_code):this._unregistered(p);break;default:{const t=pu.sipErrorCause(p.status_code);this._unregistered(p,t)}}}}).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(n,a){this._registering=!1,this._ua.registrationFailed({response:n||null,cause:a}),this._registered&&(this._registered=!1,this._ua.unregistered({response:n||null,cause:a}))}_unregistered(n,a){this._registering=!1,this._registered=!1,this._ua.unregistered({response:n||null,cause:a||null})}};class Bm extends Error{constructor(n,a){super(),this.code=1,this.name="CONFIGURATION_ERROR",this.parameter=n,this.value=a,this.message=this.value?`Invalid value ${JSON.stringify(this.value)} for parameter "${this.parameter}"`:`Missing parameter: ${this.parameter}`}}class Gm extends Error{constructor(n){super(),this.code=2,this.name="INVALID_STATE_ERROR",this.status=n,this.message=`Invalid status: ${n}`}}class Wm extends Error{constructor(n){super(),this.code=3,this.name="NOT_SUPPORTED_ERROR",this.message=n}}class Km extends Error{constructor(n){super(),this.code=4,this.name="NOT_READY_ERROR",this.message=n}}var Sn={ConfigurationError:Bm,InvalidStateError:Gm,NotSupportedError:Wm,NotReadyError:Km};const Xn=Be(Sn),mu=Fe,Xa=Yr,Ym=zr,gu={onRequestTimeout:()=>{},onTransportError:()=>{},onSuccessResponse:()=>{},onErrorResponse:()=>{},onAuthenticated:()=>{},onDialogError:()=>{}};var qf=class{constructor(n,a,e){this._dialog=n,this._ua=n._ua,this._request=a,this._eventHandlers=e,this._reattempt=!1,this._reattemptTimer=null;for(const o in gu)Object.prototype.hasOwnProperty.call(gu,o)&&(this._eventHandlers[o]||(this._eventHandlers[o]=gu[o]))}get request(){return this._request}send(){const n=new Ym(this._ua,this._request,{onRequestTimeout:()=>{this._eventHandlers.onRequestTimeout()},onTransportError:()=>{this._eventHandlers.onTransportError()},onAuthenticated:a=>{this._eventHandlers.onAuthenticated(a)},onReceiveResponse:a=>{this._receiveResponse(a)}});if(n.send(),(this._request.method===mu.INVITE||this._request.method===mu.UPDATE&&this._request.body)&&n.clientTransaction.state!==Xa.C.STATUS_TERMINATED){this._dialog.uac_pending_reply=!0;const a=()=>{(n.clientTransaction.state===Xa.C.STATUS_ACCEPTED||n.clientTransaction.state===Xa.C.STATUS_COMPLETED||n.clientTransaction.state===Xa.C.STATUS_TERMINATED)&&(n.clientTransaction.removeListener("stateChanged",a),this._dialog.uac_pending_reply=!1)};n.clientTransaction.on("stateChanged",a)}}_receiveResponse(n){n.status_code===408||n.status_code===481?this._eventHandlers.onDialogError(n):n.method===mu.INVITE&&n.status_code===491?this._reattempt?n.status_code>=200&&n.status_code<300?this._eventHandlers.onSuccessResponse(n):n.status_code>=300&&this._eventHandlers.onErrorResponse(n):(this._request.cseq=this._dialog.local_seqnum+=1,this._reattemptTimer=setTimeout(()=>{this._dialog.isTerminated()||(this._reattempt=!0,this.send())},1e3)):n.status_code>=200&&n.status_code<300?this._eventHandlers.onSuccessResponse(n):n.status_code>=300&&this._eventHandlers.onErrorResponse(n)}};const zm=Be(qf),Jm=Tt,jf=kt,Qn=Fe,Hi=Yr,Xm=qf,vu=wt(),Tu=new Jm("Dialog"),Zn={STATUS_EARLY:1,STATUS_CONFIRMED:2,STATUS_TERMINATED:3};var Vf=class{static get C(){return Zn}constructor(n,a,e,o=Zn.STATUS_CONFIRMED){if(this._owner=n,this._ua=n._ua,this._uac_pending_reply=!1,this._uas_pending_reply=!1,!a.hasHeader("contact"))return{error:"unable to create a Dialog without Contact header field"};a instanceof jf.IncomingResponse&&(o=a.status_code<200?Zn.STATUS_EARLY:Zn.STATUS_CONFIRMED);const p=a.parseHeader("contact");e==="UAS"?(this._id={call_id:a.call_id,local_tag:a.to_tag,remote_tag:a.from_tag,toString(){return this.call_id+this.local_tag+this.remote_tag}},this._state=o,this._remote_seqnum=a.cseq,this._local_uri=a.parseHeader("to").uri,this._remote_uri=a.parseHeader("from").uri,this._remote_target=p.uri,this._route_set=a.getHeaders("record-route"),this._ack_seqnum=this._remote_seqnum):e==="UAC"&&(this._id={call_id:a.call_id,local_tag:a.from_tag,remote_tag:a.to_tag,toString(){return this.call_id+this.local_tag+this.remote_tag}},this._state=o,this._local_seqnum=a.cseq,this._local_uri=a.parseHeader("from").uri,this._remote_uri=a.parseHeader("to").uri,this._remote_target=p.uri,this._route_set=a.getHeaders("record-route").reverse(),this._ack_seqnum=null),this._ua.newDialog(this),Tu.debug(`new ${e} dialog created with status ${this._state===Zn.STATUS_EARLY?"EARLY":"CONFIRMED"}`)}get id(){return this._id}get local_seqnum(){return this._local_seqnum}set local_seqnum(n){this._local_seqnum=n}get owner(){return this._owner}get uac_pending_reply(){return this._uac_pending_reply}set uac_pending_reply(n){this._uac_pending_reply=n}get uas_pending_reply(){return this._uas_pending_reply}isTerminated(){return this._status===Zn.STATUS_TERMINATED}update(n,a){this._state=Zn.STATUS_CONFIRMED,Tu.debug(`dialog ${this._id.toString()} changed to CONFIRMED state`),a==="UAC"&&(this._route_set=n.getHeaders("record-route").reverse())}terminate(){Tu.debug(`dialog ${this._id.toString()} deleted`),this._ua.destroyDialog(this),this._state=Zn.STATUS_TERMINATED}sendRequest(n,a={}){const e=vu.cloneArray(a.extraHeaders),o=vu.cloneObject(a.eventHandlers),p=a.body||null,t=this._createRequest(n,e,p);return o.onAuthenticated=()=>{this._local_seqnum+=1},new Xm(this,t,o).send(),t}receiveRequest(n){this._checkInDialogRequest(n)&&(n.method===Qn.ACK&&this._ack_seqnum!==null?this._ack_seqnum=null:n.method===Qn.INVITE&&(this._ack_seqnum=n.cseq),this._owner.receiveRequest(n))}_createRequest(n,a,e){a=vu.cloneArray(a),this._local_seqnum||(this._local_seqnum=Math.floor(Math.random()*1e4));const o=n===Qn.CANCEL||n===Qn.ACK?this._local_seqnum:this._local_seqnum+=1;return new jf.OutgoingRequest(n,this._remote_target,this._ua,{cseq:o,call_id:this._id.call_id,from_uri:this._local_uri,from_tag:this._id.local_tag,to_uri:this._remote_uri,to_tag:this._id.remote_tag,route_set:this._route_set},a,e)}_checkInDialogRequest(n){if(!this._remote_seqnum)this._remote_seqnum=n.cseq;else if(n.cseq<this._remote_seqnum)if(n.method===Qn.ACK){if(this._ack_seqnum===null||n.cseq!==this._ack_seqnum)return!1}else return n.reply(500),!1;else n.cseq>this._remote_seqnum&&(this._remote_seqnum=n.cseq);if(n.method===Qn.INVITE||n.method===Qn.UPDATE&&n.body){if(this._uac_pending_reply===!0)n.reply(491);else if(this._uas_pending_reply===!0){const a=(Math.random()*10|0)+1;return n.reply(500,null,[`Retry-After:${a}`]),!1}else{this._uas_pending_reply=!0;const a=()=>{(n.server_transaction.state===Hi.C.STATUS_ACCEPTED||n.server_transaction.state===Hi.C.STATUS_COMPLETED||n.server_transaction.state===Hi.C.STATUS_TERMINATED)&&(n.server_transaction.removeListener("stateChanged",a),this._uas_pending_reply=!1)};n.server_transaction.on("stateChanged",a)}n.hasHeader("contact")&&n.server_transaction.on("stateChanged",()=>{n.server_transaction.state===Hi.C.STATUS_ACCEPTED&&(this._remote_target=n.parseHeader("contact").uri)})}else n.method===Qn.NOTIFY&&n.hasHeader("contact")&&n.server_transaction.on("stateChanged",()=>{n.server_transaction.state===Hi.C.STATUS_COMPLETED&&(this._remote_target=n.parseHeader("contact").uri)});return!0}};const Qa=Be(Vf);var Eu={exports:{}};const Qm=Ct.EventEmitter,Zm=Tt,eg=Fe,tg=Sn,Bf=wt(),sg=new Zm("RTCSession:DTMF"),Gf={MIN_DURATION:70,MAX_DURATION:6e3,DEFAULT_DURATION:100,MIN_INTER_TONE_GAP:50,DEFAULT_INTER_TONE_GAP:500};Eu.exports=class extends Qm{constructor(n){super(),this._session=n,this._direction=null,this._tone=null,this._duration=null,this._request=null}get tone(){return this._tone}get duration(){return this._duration}send(n,a={}){if(n===void 0)throw new TypeError("Not enough arguments");if(this._direction="outgoing",this._session.status!==this._session.C.STATUS_CONFIRMED&&this._session.status!==this._session.C.STATUS_WAITING_FOR_ACK)throw new tg.InvalidStateError(this._session.status);const e=Bf.cloneArray(a.extraHeaders);if(this.eventHandlers=Bf.cloneObject(a.eventHandlers),typeof n=="string")n=n.toUpperCase();else if(typeof n=="number")n=n.toString();else throw new TypeError(`Invalid tone: ${n}`);if(n.match(/^[0-9A-DR#*]$/))this._tone=n;else throw new TypeError(`Invalid tone: ${n}`);this._duration=a.duration,e.push("Content-Type: application/dtmf-relay");let o=`Signal=${this._tone}\r
|
113
|
-
`;
|
114
|
-
`);
|
115
|
-
`,1)[0],"Status_Line");if(a===-1){or.debug(`receiveNotify() | error parsing NOTIFY body: "${n.body}"`);return}switch(!0){case/^100$/.test(a.status_code):this.emit("trying",{request:n,status_line:a});break;case/^1[0-9]{2}$/.test(a.status_code):this.emit("progress",{request:n,status_line:a});break;case/^2[0-9]{2}$/.test(a.status_code):this.emit("accepted",{request:n,status_line:a});break;default:this.emit("failed",{request:n,status_line:a});break}}_requestSucceeded(n){or.debug("REFER succeeded"),or.debug('emit "requestSucceeded"'),this.emit("requestSucceeded",{response:n})}_requestFailed(n,a){or.debug("REFER failed"),or.debug('emit "requestFailed"'),this.emit("requestFailed",{response:n||null,cause:a})}};const dg=Be(Xf),pg=Ct.EventEmitter,Qf=Gt,mg=Tt,Te=Fe,ur=Sn,Zf=Yr,lt=wt(),qi=hu,gg=kt,Za=Vf,vg=zr,Qt=Wf,eh=Kf,Tg=zf,Eg=Xf,th=Tn(),ee=new mg("RTCSession"),ie={STATUS_NULL:0,STATUS_INVITE_SENT:1,STATUS_1XX_RECEIVED:2,STATUS_INVITE_RECEIVED:3,STATUS_WAITING_FOR_ANSWER:4,STATUS_ANSWERED:5,STATUS_WAITING_FOR_ACK:6,STATUS_CANCELED:7,STATUS_TERMINATED:8,STATUS_CONFIRMED:9},eo=["audio","video"];var sh=class Ku extends pg{static get C(){return ie}constructor(n){ee.debug("new"),super(),this._id=null,this._ua=n,this._status=ie.STATUS_NULL,this._dialog=null,this._earlyDialogs={},this._contact=null,this._from_tag=null,this._to_tag=null,this._connection=null,this._connectionPromiseQueue=Promise.resolve(),this._request=null,this._is_canceled=!1,this._cancel_reason="",this._is_confirmed=!1,this._late_sdp=!1,this._rtcOfferConstraints=null,this._rtcAnswerConstraints=null,this._localMediaStream=null,this._localMediaStreamLocallyGenerated=!1,this._rtcReady=!0,this._iceReady=!1,this._timers={ackTimer:null,expiresTimer:null,invite2xxTimer:null,userNoAnswerTimer:null},this._direction=null,this._local_identity=null,this._remote_identity=null,this._start_time=null,this._end_time=null,this._tones=null,this._audioMuted=!1,this._videoMuted=!1,this._localHold=!1,this._remoteHold=!1,this._sessionTimers={enabled:this._ua.configuration.session_timers,refreshMethod:this._ua.configuration.session_timers_refresh_method,defaultExpires:Te.SESSION_EXPIRES,currentExpires:null,running:!1,refresher:!1,timer:null},this._referSubscribers={},this._data={}}get C(){return ie}get causes(){return Te.causes}get id(){return this._id}get connection(){return this._connection}get contact(){return this._contact}get direction(){return this._direction}get local_identity(){return this._local_identity}get remote_identity(){return this._remote_identity}get start_time(){return this._start_time}get end_time(){return this._end_time}get data(){return this._data}set data(n){this._data=n}get status(){return this._status}isInProgress(){switch(this._status){case ie.STATUS_NULL:case ie.STATUS_INVITE_SENT:case ie.STATUS_1XX_RECEIVED:case ie.STATUS_INVITE_RECEIVED:case ie.STATUS_WAITING_FOR_ANSWER:return!0;default:return!1}}isEstablished(){switch(this._status){case ie.STATUS_ANSWERED:case ie.STATUS_WAITING_FOR_ACK:case ie.STATUS_CONFIRMED:return!0;default:return!1}}isEnded(){switch(this._status){case ie.STATUS_CANCELED:case ie.STATUS_TERMINATED:return!0;default:return!1}}isMuted(){return{audio:this._audioMuted,video:this._videoMuted}}isOnHold(){return{local:this._localHold,remote:this._remoteHold}}connect(n,a={},e){ee.debug("connect()");const o=n,p=lt.cloneObject(a.eventHandlers),t=lt.cloneArray(a.extraHeaders),v=lt.cloneObject(a.mediaConstraints,{audio:!0,video:!0}),C=a.mediaStream||null,l=lt.cloneObject(a.pcConfig,{iceServers:[]}),A=a.rtcConstraints||null,b=a.rtcOfferConstraints||null;if(this._rtcOfferConstraints=b,this._rtcAnswerConstraints=a.rtcAnswerConstraints||null,this._data=a.data||this._data,n===void 0)throw new TypeError("Not enough arguments");if(this._status!==ie.STATUS_NULL)throw new ur.InvalidStateError(this._status);if(!window.RTCPeerConnection)throw new ur.NotSupportedError("WebRTC not supported");if(n=this._ua.normalizeTarget(n),!n)throw new TypeError(`Invalid target: ${o}`);this._sessionTimers.enabled&<.isDecimal(a.sessionTimersExpires)&&(a.sessionTimersExpires>=Te.MIN_SESSION_EXPIRES?this._sessionTimers.defaultExpires=a.sessionTimersExpires:this._sessionTimers.defaultExpires=Te.SESSION_EXPIRES);for(const w in p)Object.prototype.hasOwnProperty.call(p,w)&&this.on(w,p[w]);this._from_tag=lt.newTag();const E=a.anonymous||!1,O={from_tag:this._from_tag};this._contact=this._ua.contact.toString({anonymous:E,outbound:!0}),E?(O.from_display_name="Anonymous",O.from_uri=new th("sip","anonymous","anonymous.invalid"),t.push(`P-Preferred-Identity: ${this._ua.configuration.uri.toString()}`),t.push("Privacy: id")):a.fromUserName&&(O.from_uri=new th("sip",a.fromUserName,this._ua.configuration.uri.host),t.push(`P-Preferred-Identity: ${this._ua.configuration.uri.toString()}`)),a.fromDisplayName&&(O.from_display_name=a.fromDisplayName),t.push(`Contact: ${this._contact}`),t.push("Content-Type: application/sdp"),this._sessionTimers.enabled&&t.push(`Session-Expires: ${this._sessionTimers.defaultExpires}${this._ua.configuration.session_timers_force_refresher?";refresher=uac":""}`),this._request=new gg.InitialOutgoingInviteRequest(n,this._ua,O,t),this._id=this._request.call_id+this._from_tag,this._createRTCConnection(l,A),this._direction="outgoing",this._local_identity=this._request.from,this._remote_identity=this._request.to,e&&e(this),this._newRTCSession("local",this._request),this._sendInitialRequest(v,b,C)}init_incoming(n,a){ee.debug("init_incoming()");let e;const o=n.hasHeader("Content-Type")?n.getHeader("Content-Type").toLowerCase():void 0;if(n.body&&o!=="application/sdp"){n.reply(415);return}if(this._status=ie.STATUS_INVITE_RECEIVED,this._from_tag=n.from_tag,this._id=n.call_id+this._from_tag,this._request=n,this._contact=this._ua.contact.toString(),n.hasHeader("expires")&&(e=n.getHeader("expires")*1e3),n.to_tag=lt.newTag(),!this._createDialog(n,"UAS",!0)){n.reply(500,"Missing Contact header field");return}n.body?this._late_sdp=!1:this._late_sdp=!0,this._status=ie.STATUS_WAITING_FOR_ANSWER,this._timers.userNoAnswerTimer=setTimeout(()=>{n.reply(408),this._failed("local",null,Te.causes.NO_ANSWER)},this._ua.configuration.no_answer_timeout),e&&(this._timers.expiresTimer=setTimeout(()=>{this._status===ie.STATUS_WAITING_FOR_ANSWER&&(n.reply(487),this._failed("system",null,Te.causes.EXPIRES))},e)),this._direction="incoming",this._local_identity=n.to,this._remote_identity=n.from,a&&a(this),this._newRTCSession("remote",n),this._status!==ie.STATUS_TERMINATED&&(n.reply(180,null,[`Contact: ${this._contact}`]),this._progress("local",null))}answer(n={}){ee.debug("answer()");const a=this._request,e=lt.cloneArray(n.extraHeaders),o=lt.cloneObject(n.mediaConstraints),p=n.mediaStream||null,t=lt.cloneObject(n.pcConfig,{iceServers:[]}),v=n.rtcConstraints||null,C=n.rtcAnswerConstraints||null,l=lt.cloneObject(n.rtcOfferConstraints);let A,b=!1,E=!1,O=!1,w=!1;if(this._rtcAnswerConstraints=C,this._rtcOfferConstraints=n.rtcOfferConstraints||null,this._data=n.data||this._data,this._direction!=="incoming")throw new ur.NotSupportedError('"answer" not supported for outgoing RTCSession');if(this._status!==ie.STATUS_WAITING_FOR_ANSWER)throw new ur.InvalidStateError(this._status);if(this._sessionTimers.enabled&<.isDecimal(n.sessionTimersExpires)&&(n.sessionTimersExpires>=Te.MIN_SESSION_EXPIRES?this._sessionTimers.defaultExpires=n.sessionTimersExpires:this._sessionTimers.defaultExpires=Te.SESSION_EXPIRES),this._status=ie.STATUS_ANSWERED,!this._createDialog(a,"UAS")){a.reply(500,"Error creating dialog");return}clearTimeout(this._timers.userNoAnswerTimer),e.unshift(`Contact: ${this._contact}`);const N=a.parseSDP();Array.isArray(N.media)||(N.media=[N.media]);for(const U of N.media)U.type==="audio"&&(b=!0,(!U.direction||U.direction==="sendrecv")&&(O=!0)),U.type==="video"&&(E=!0,(!U.direction||U.direction==="sendrecv")&&(w=!0));if(p&&o.audio===!1){A=p.getAudioTracks();for(const U of A)p.removeTrack(U)}if(p&&o.video===!1){A=p.getVideoTracks();for(const U of A)p.removeTrack(U)}!p&&o.audio===void 0&&(o.audio=O),!p&&o.video===void 0&&(o.video=w),!p&&!b&&!l.offerToReceiveAudio&&(o.audio=!1),!p&&!E&&!l.offerToReceiveVideo&&(o.video=!1),this._createRTCConnection(t,v),Promise.resolve().then(()=>{if(p)return p;if(o.audio||o.video)return this._localMediaStreamLocallyGenerated=!0,navigator.mediaDevices.getUserMedia(o).catch(U=>{throw this._status===ie.STATUS_TERMINATED?new Error("terminated"):(a.reply(480),this._failed("local",null,Te.causes.USER_DENIED_MEDIA_ACCESS),ee.warn('emit "getusermediafailed" [error:%o]',U),this.emit("getusermediafailed",U),new Error("getUserMedia() failed"))})}).then(U=>{if(this._status===ie.STATUS_TERMINATED)throw new Error("terminated");this._localMediaStream=U,U&&U.getTracks().forEach(z=>{this._connection.addTrack(z,U)})}).then(()=>{if(this._late_sdp)return;const U={originator:"remote",type:"offer",sdp:a.body};ee.debug('emit "sdp"'),this.emit("sdp",U);const z=new RTCSessionDescription({type:"offer",sdp:U.sdp});return this._connectionPromiseQueue=this._connectionPromiseQueue.then(()=>this._connection.setRemoteDescription(z)).catch(j=>{throw a.reply(488),this._failed("system",null,Te.causes.WEBRTC_ERROR),ee.warn('emit "peerconnection:setremotedescriptionfailed" [error:%o]',j),this.emit("peerconnection:setremotedescriptionfailed",j),new Error("peerconnection.setRemoteDescription() failed")}),this._connectionPromiseQueue}).then(()=>{if(this._status===ie.STATUS_TERMINATED)throw new Error("terminated");return this._connecting(a),this._late_sdp?this._createLocalDescription("offer",this._rtcOfferConstraints).catch(()=>{throw a.reply(500),new Error("_createLocalDescription() failed")}):this._createLocalDescription("answer",C).catch(()=>{throw a.reply(500),new Error("_createLocalDescription() failed")})}).then(U=>{if(this._status===ie.STATUS_TERMINATED)throw new Error("terminated");this._handleSessionTimersInIncomingRequest(a,e),a.reply(200,null,e,U,()=>{this._status=ie.STATUS_WAITING_FOR_ACK,this._setInvite2xxTimer(a,U),this._setACKTimer(),this._accepted("local")},()=>{this._failed("system",null,Te.causes.CONNECTION_ERROR)})}).catch(U=>{this._status!==ie.STATUS_TERMINATED&&ee.warn(U)})}terminate(n={}){ee.debug("terminate()");const a=n.cause||Te.causes.BYE,e=lt.cloneArray(n.extraHeaders),o=n.body;let p,t=n.status_code,v=n.reason_phrase;if(this._status===ie.STATUS_TERMINATED)throw new ur.InvalidStateError(this._status);switch(this._status){case ie.STATUS_NULL:case ie.STATUS_INVITE_SENT:case ie.STATUS_1XX_RECEIVED:if(ee.debug("canceling session"),t&&(t<200||t>=700))throw new TypeError(`Invalid status_code: ${t}`);t&&(v=v||Te.REASON_PHRASE[t]||"",p=`SIP ;cause=${t} ;text="${v}"`),this._status===ie.STATUS_NULL||this._status===ie.STATUS_INVITE_SENT?(this._is_canceled=!0,this._cancel_reason=p):this._status===ie.STATUS_1XX_RECEIVED&&this._request.cancel(p),this._status=ie.STATUS_CANCELED,this._failed("local",null,Te.causes.CANCELED);break;case ie.STATUS_WAITING_FOR_ANSWER:case ie.STATUS_ANSWERED:if(ee.debug("rejecting session"),t=t||480,t<300||t>=700)throw new TypeError(`Invalid status_code: ${t}`);this._request.reply(t,v,e,o),this._failed("local",null,Te.causes.REJECTED);break;case ie.STATUS_WAITING_FOR_ACK:case ie.STATUS_CONFIRMED:if(ee.debug("terminating session"),v=n.reason_phrase||Te.REASON_PHRASE[t]||"",t&&(t<200||t>=700))throw new TypeError(`Invalid status_code: ${t}`);if(t&&e.push(`Reason: SIP ;cause=${t}; text="${v}"`),this._status===ie.STATUS_WAITING_FOR_ACK&&this._direction==="incoming"&&this._request.server_transaction.state!==Zf.C.STATUS_TERMINATED){const C=this._dialog;this.receiveRequest=({method:l})=>{l===Te.ACK&&(this.sendRequest(Te.BYE,{extraHeaders:e,body:o}),C.terminate())},this._request.server_transaction.on("stateChanged",()=>{this._request.server_transaction.state===Zf.C.STATUS_TERMINATED&&(this.sendRequest(Te.BYE,{extraHeaders:e,body:o}),C.terminate())}),this._ended("local",null,a),this._dialog=C,this._ua.newDialog(C)}else this.sendRequest(Te.BYE,{extraHeaders:e,body:o}),this._ended("local",null,a)}}sendDTMF(n,a={}){ee.debug("sendDTMF() | tones: %s",n);let e=0,o=a.duration||null,p=a.interToneGap||null;const t=a.transportType||Te.DTMF_TRANSPORT.INFO;if(n===void 0)throw new TypeError("Not enough arguments");if(this._status!==ie.STATUS_CONFIRMED&&this._status!==ie.STATUS_WAITING_FOR_ACK&&this._status!==ie.STATUS_1XX_RECEIVED)throw new ur.InvalidStateError(this._status);if(t!==Te.DTMF_TRANSPORT.INFO&&t!==Te.DTMF_TRANSPORT.RFC2833)throw new TypeError(`invalid transportType: ${t}`);if(typeof n=="number"&&(n=n.toString()),!n||typeof n!="string"||!n.match(/^[0-9A-DR#*,]+$/i))throw new TypeError(`Invalid tones: ${n}`);if(o&&!lt.isDecimal(o))throw new TypeError(`Invalid tone duration: ${o}`);if(o?o<Qt.C.MIN_DURATION?(ee.debug(`"duration" value is lower than the minimum allowed, setting it to ${Qt.C.MIN_DURATION} milliseconds`),o=Qt.C.MIN_DURATION):o>Qt.C.MAX_DURATION?(ee.debug(`"duration" value is greater than the maximum allowed, setting it to ${Qt.C.MAX_DURATION} milliseconds`),o=Qt.C.MAX_DURATION):o=Math.abs(o):o=Qt.C.DEFAULT_DURATION,a.duration=o,p&&!lt.isDecimal(p))throw new TypeError(`Invalid interToneGap: ${p}`);if(p?p<Qt.C.MIN_INTER_TONE_GAP?(ee.debug(`"interToneGap" value is lower than the minimum allowed, setting it to ${Qt.C.MIN_INTER_TONE_GAP} milliseconds`),p=Qt.C.MIN_INTER_TONE_GAP):p=Math.abs(p):p=Qt.C.DEFAULT_INTER_TONE_GAP,t===Te.DTMF_TRANSPORT.RFC2833){const C=this._getDTMFRTPSender();C&&(n=C.toneBuffer+n,C.insertDTMF(n,o,p));return}if(this._tones){this._tones+=n;return}this._tones=n,v.call(this);function v(){let C;if(this._status===ie.STATUS_TERMINATED||!this._tones||e>=this._tones.length){this._tones=null;return}const l=this._tones[e];if(e+=1,l===",")C=2e3;else{const A=new Qt(this);a.eventHandlers={onFailed:()=>{this._tones=null}},A.send(l,a),C=o+p}setTimeout(v.bind(this),C)}}sendInfo(n,a,e={}){if(ee.debug("sendInfo()"),this._status!==ie.STATUS_CONFIRMED&&this._status!==ie.STATUS_WAITING_FOR_ACK&&this._status!==ie.STATUS_1XX_RECEIVED)throw new ur.InvalidStateError(this._status);new eh(this).send(n,a,e)}mute(n={audio:!0,video:!1}){ee.debug("mute()");let a=!1,e=!1;this._audioMuted===!1&&n.audio&&(a=!0,this._audioMuted=!0,this._toggleMuteAudio(!0)),this._videoMuted===!1&&n.video&&(e=!0,this._videoMuted=!0,this._toggleMuteVideo(!0)),(a===!0||e===!0)&&this._onmute({audio:a,video:e})}unmute(n={audio:!0,video:!0}){ee.debug("unmute()");let a=!1,e=!1;this._audioMuted===!0&&n.audio&&(a=!0,this._audioMuted=!1,this._localHold===!1&&this._toggleMuteAudio(!1)),this._videoMuted===!0&&n.video&&(e=!0,this._videoMuted=!1,this._localHold===!1&&this._toggleMuteVideo(!1)),(a===!0||e===!0)&&this._onunmute({audio:a,video:e})}hold(n={},a){if(ee.debug("hold()"),this._status!==ie.STATUS_WAITING_FOR_ACK&&this._status!==ie.STATUS_CONFIRMED||this._localHold===!0||!this._isReadyToReOffer())return!1;this._localHold=!0,this._onhold("local");const e={succeeded:()=>{a&&a()},failed:()=>{this.terminate({cause:Te.causes.WEBRTC_ERROR,status_code:500,reason_phrase:"Hold Failed"})}};return n.useUpdate?this._sendUpdate({sdpOffer:!0,eventHandlers:e,extraHeaders:n.extraHeaders}):this._sendReinvite({eventHandlers:e,extraHeaders:n.extraHeaders}),!0}unhold(n={},a){if(ee.debug("unhold()"),this._status!==ie.STATUS_WAITING_FOR_ACK&&this._status!==ie.STATUS_CONFIRMED||this._localHold===!1||!this._isReadyToReOffer())return!1;this._localHold=!1,this._onunhold("local");const e={succeeded:()=>{a&&a()},failed:()=>{this.terminate({cause:Te.causes.WEBRTC_ERROR,status_code:500,reason_phrase:"Unhold Failed"})}};return n.useUpdate?this._sendUpdate({sdpOffer:!0,eventHandlers:e,extraHeaders:n.extraHeaders}):this._sendReinvite({eventHandlers:e,extraHeaders:n.extraHeaders}),!0}renegotiate(n={},a){ee.debug("renegotiate()");const e=n.rtcOfferConstraints||null;if(this._status!==ie.STATUS_WAITING_FOR_ACK&&this._status!==ie.STATUS_CONFIRMED||!this._isReadyToReOffer())return!1;const o={succeeded:()=>{a&&a()},failed:()=>{this.terminate({cause:Te.causes.WEBRTC_ERROR,status_code:500,reason_phrase:"Media Renegotiation Failed"})}};return this._setLocalMediaStatus(),n.useUpdate?this._sendUpdate({sdpOffer:!0,eventHandlers:o,rtcOfferConstraints:e,extraHeaders:n.extraHeaders}):this._sendReinvite({eventHandlers:o,rtcOfferConstraints:e,extraHeaders:n.extraHeaders}),!0}refer(n,a){ee.debug("refer()");const e=n;if(this._status!==ie.STATUS_WAITING_FOR_ACK&&this._status!==ie.STATUS_CONFIRMED)return!1;if(n=this._ua.normalizeTarget(n),!n)throw new TypeError(`Invalid target: ${e}`);const o=new Eg(this);o.sendRefer(n,a);const p=o.id;return this._referSubscribers[p]=o,o.on("requestFailed",()=>{delete this._referSubscribers[p]}),o.on("accepted",()=>{delete this._referSubscribers[p]}),o.on("failed",()=>{delete this._referSubscribers[p]}),o}sendRequest(n,a){return ee.debug("sendRequest()"),this._dialog.sendRequest(n,a)}receiveRequest(n){if(ee.debug("receiveRequest()"),n.method===Te.CANCEL)(this._status===ie.STATUS_WAITING_FOR_ANSWER||this._status===ie.STATUS_ANSWERED)&&(this._status=ie.STATUS_CANCELED,this._request.reply(487),this._failed("remote",n,Te.causes.CANCELED));else switch(n.method){case Te.ACK:if(this._status!==ie.STATUS_WAITING_FOR_ACK)return;if(this._status=ie.STATUS_CONFIRMED,clearTimeout(this._timers.ackTimer),clearTimeout(this._timers.invite2xxTimer),this._late_sdp){if(!n.body){this.terminate({cause:Te.causes.MISSING_SDP,status_code:400});break}const a={originator:"remote",type:"answer",sdp:n.body};ee.debug('emit "sdp"'),this.emit("sdp",a);const e=new RTCSessionDescription({type:"answer",sdp:a.sdp});this._connectionPromiseQueue=this._connectionPromiseQueue.then(()=>this._connection.setRemoteDescription(e)).then(()=>{this._is_confirmed||this._confirmed("remote",n)}).catch(o=>{this.terminate({cause:Te.causes.BAD_MEDIA_DESCRIPTION,status_code:488}),ee.warn('emit "peerconnection:setremotedescriptionfailed" [error:%o]',o),this.emit("peerconnection:setremotedescriptionfailed",o)})}else this._is_confirmed||this._confirmed("remote",n);break;case Te.BYE:this._status===ie.STATUS_CONFIRMED||this._status===ie.STATUS_WAITING_FOR_ACK?(n.reply(200),this._ended("remote",n,Te.causes.BYE)):this._status===ie.STATUS_INVITE_RECEIVED||this._status===ie.STATUS_WAITING_FOR_ANSWER?(n.reply(200),this._request.reply(487,"BYE Received"),this._ended("remote",n,Te.causes.BYE)):n.reply(403,"Wrong Status");break;case Te.INVITE:this._status===ie.STATUS_CONFIRMED?n.hasHeader("replaces")?this._receiveReplaces(n):this._receiveReinvite(n):n.reply(403,"Wrong Status");break;case Te.INFO:if(this._status===ie.STATUS_1XX_RECEIVED||this._status===ie.STATUS_WAITING_FOR_ANSWER||this._status===ie.STATUS_ANSWERED||this._status===ie.STATUS_WAITING_FOR_ACK||this._status===ie.STATUS_CONFIRMED){const a=n.hasHeader("Content-Type")?n.getHeader("Content-Type").toLowerCase():void 0;a&&a.match(/^application\/dtmf-relay/i)?new Qt(this).init_incoming(n):a!==void 0?new eh(this).init_incoming(n):n.reply(415)}else n.reply(403,"Wrong Status");break;case Te.UPDATE:this._status===ie.STATUS_CONFIRMED?this._receiveUpdate(n):n.reply(403,"Wrong Status");break;case Te.REFER:this._status===ie.STATUS_CONFIRMED?this._receiveRefer(n):n.reply(403,"Wrong Status");break;case Te.NOTIFY:this._status===ie.STATUS_CONFIRMED?this._receiveNotify(n):n.reply(403,"Wrong Status");break;default:n.reply(501)}}onTransportError(){ee.warn("onTransportError()"),this._status!==ie.STATUS_TERMINATED&&this.terminate({status_code:500,reason_phrase:Te.causes.CONNECTION_ERROR,cause:Te.causes.CONNECTION_ERROR})}onRequestTimeout(){ee.warn("onRequestTimeout()"),this._status!==ie.STATUS_TERMINATED&&this.terminate({status_code:408,reason_phrase:Te.causes.REQUEST_TIMEOUT,cause:Te.causes.REQUEST_TIMEOUT})}onDialogError(){ee.warn("onDialogError()"),this._status!==ie.STATUS_TERMINATED&&this.terminate({status_code:500,reason_phrase:Te.causes.DIALOG_ERROR,cause:Te.causes.DIALOG_ERROR})}newDTMF(n){ee.debug("newDTMF()"),this.emit("newDTMF",n)}newInfo(n){ee.debug("newInfo()"),this.emit("newInfo",n)}_isReadyToReOffer(){return this._rtcReady?this._dialog?this._dialog.uac_pending_reply===!0||this._dialog.uas_pending_reply===!0?(ee.debug("_isReadyToReOffer() | there is another INVITE/UPDATE transaction in progress"),!1):!0:(ee.debug("_isReadyToReOffer() | session not established yet"),!1):(ee.debug("_isReadyToReOffer() | internal WebRTC status not ready"),!1)}_close(){if(ee.debug("close()"),this._localMediaStream&&this._localMediaStreamLocallyGenerated&&(ee.debug("close() | closing local MediaStream"),lt.closeMediaStream(this._localMediaStream)),this._status!==ie.STATUS_TERMINATED){if(this._status=ie.STATUS_TERMINATED,this._connection)try{this._connection.close()}catch(n){ee.warn("close() | error closing the RTCPeerConnection: %o",n)}for(const n in this._timers)Object.prototype.hasOwnProperty.call(this._timers,n)&&clearTimeout(this._timers[n]);clearTimeout(this._sessionTimers.timer),this._dialog&&(this._dialog.terminate(),delete this._dialog);for(const n in this._earlyDialogs)Object.prototype.hasOwnProperty.call(this._earlyDialogs,n)&&(this._earlyDialogs[n].terminate(),delete this._earlyDialogs[n]);for(const n in this._referSubscribers)Object.prototype.hasOwnProperty.call(this._referSubscribers,n)&&delete this._referSubscribers[n];this._ua.destroyRTCSession(this)}}_setInvite2xxTimer(n,a){let e=qi.T1;function o(){this._status===ie.STATUS_WAITING_FOR_ACK&&(n.reply(200,null,[`Contact: ${this._contact}`],a),e<qi.T2&&(e=e*2,e>qi.T2&&(e=qi.T2)),this._timers.invite2xxTimer=setTimeout(o.bind(this),e))}this._timers.invite2xxTimer=setTimeout(o.bind(this),e)}_setACKTimer(){this._timers.ackTimer=setTimeout(()=>{this._status===ie.STATUS_WAITING_FOR_ACK&&(ee.debug("no ACK received, terminating the session"),clearTimeout(this._timers.invite2xxTimer),this.sendRequest(Te.BYE),this._ended("remote",null,Te.causes.NO_ACK))},qi.TIMER_H)}_createRTCConnection(n,a){this._connection=new RTCPeerConnection(n,a),this._connection.addEventListener("iceconnectionstatechange",()=>{this._connection.iceConnectionState==="failed"&&this.terminate({cause:Te.causes.RTP_TIMEOUT,status_code:408,reason_phrase:Te.causes.RTP_TIMEOUT})}),ee.debug('emit "peerconnection"'),this.emit("peerconnection",{peerconnection:this._connection})}_createLocalDescription(n,a){if(ee.debug("createLocalDescription()"),n!=="offer"&&n!=="answer")throw new Error(`createLocalDescription() | invalid type "${n}"`);const e=this._connection;return this._rtcReady=!1,Promise.resolve().then(()=>n==="offer"?e.createOffer(a).catch(o=>(ee.warn('emit "peerconnection:createofferfailed" [error:%o]',o),this.emit("peerconnection:createofferfailed",o),Promise.reject(o))):e.createAnswer(a).catch(o=>(ee.warn('emit "peerconnection:createanswerfailed" [error:%o]',o),this.emit("peerconnection:createanswerfailed",o),Promise.reject(o)))).then(o=>e.setLocalDescription(o).catch(p=>(this._rtcReady=!0,ee.warn('emit "peerconnection:setlocaldescriptionfailed" [error:%o]',p),this.emit("peerconnection:setlocaldescriptionfailed",p),Promise.reject(p)))).then(()=>{const o=a&&a.iceRestart;if(e.iceGatheringState==="complete"&&!o||e.iceGatheringState==="gathering"&&this._iceReady){this._rtcReady=!0;const p={originator:"local",type:n,sdp:e.localDescription.sdp};return ee.debug('emit "sdp"'),this.emit("sdp",p),Promise.resolve(p.sdp)}return new Promise(p=>{let t=!1,v,C;this._iceReady=!1;const l=()=>{e.removeEventListener("icecandidate",v),e.removeEventListener("icegatheringstatechange",C),t=!0,this._rtcReady=!0,this._iceReady=!0;const A={originator:"local",type:n,sdp:e.localDescription.sdp};ee.debug('emit "sdp"'),this.emit("sdp",A),p(A.sdp)};e.addEventListener("icecandidate",v=A=>{const b=A.candidate;b?this.emit("icecandidate",{candidate:b,ready:l}):t||l()}),e.addEventListener("icegatheringstatechange",C=()=>{e.iceGatheringState==="complete"&&!t&&l()})})})}_createDialog(n,a,e){const o=a==="UAS"?n.to_tag:n.from_tag,p=a==="UAS"?n.from_tag:n.to_tag,t=n.call_id+o+p;let v=this._earlyDialogs[t];if(e)return v?!0:(v=new Za(this,n,a,Za.C.STATUS_EARLY),v.error?(ee.debug(v.error),this._failed("remote",n,Te.causes.INTERNAL_ERROR),!1):(this._earlyDialogs[t]=v,!0));{if(this._from_tag=n.from_tag,this._to_tag=n.to_tag,v)return v.update(n,a),this._dialog=v,delete this._earlyDialogs[t],!0;const C=new Za(this,n,a);return C.error?(ee.debug(C.error),this._failed("remote",n,Te.causes.INTERNAL_ERROR),!1):(this._dialog=C,!0)}}_receiveReinvite(n){ee.debug("receiveReinvite()");const a=n.hasHeader("Content-Type")?n.getHeader("Content-Type").toLowerCase():void 0,e={request:n,callback:void 0,reject:p.bind(this)};let o=!1;function p(v={}){o=!0;const C=v.status_code||403,l=v.reason_phrase||"",A=lt.cloneArray(v.extraHeaders);if(this._status!==ie.STATUS_CONFIRMED)return!1;if(C<300||C>=700)throw new TypeError(`Invalid status_code: ${C}`);n.reply(C,l,A)}if(this.emit("reinvite",e),o)return;if(this._late_sdp=!1,!n.body){this._late_sdp=!0,this._remoteHold&&(this._remoteHold=!1,this._onunhold("remote")),this._connectionPromiseQueue=this._connectionPromiseQueue.then(()=>this._createLocalDescription("offer",this._rtcOfferConstraints)).then(v=>{t.call(this,v)}).catch(()=>{n.reply(500)});return}if(a!=="application/sdp"){ee.debug("invalid Content-Type"),n.reply(415);return}this._processInDialogSdpOffer(n).then(v=>{this._status!==ie.STATUS_TERMINATED&&t.call(this,v)}).catch(v=>{ee.warn(v)});function t(v){const C=[`Contact: ${this._contact}`];this._handleSessionTimersInIncomingRequest(n,C),this._late_sdp&&(v=this._mangleOffer(v)),n.reply(200,null,C,v,()=>{this._status=ie.STATUS_WAITING_FOR_ACK,this._setInvite2xxTimer(n,v),this._setACKTimer()}),typeof e.callback=="function"&&e.callback()}}_receiveUpdate(n){ee.debug("receiveUpdate()");const a=n.hasHeader("Content-Type")?n.getHeader("Content-Type").toLowerCase():void 0,e={request:n,callback:void 0,reject:p.bind(this)};let o=!1;function p(v={}){o=!0;const C=v.status_code||403,l=v.reason_phrase||"",A=lt.cloneArray(v.extraHeaders);if(this._status!==ie.STATUS_CONFIRMED)return!1;if(C<300||C>=700)throw new TypeError(`Invalid status_code: ${C}`);n.reply(C,l,A)}if(this.emit("update",e),o)return;if(!n.body){t.call(this,null);return}if(a!=="application/sdp"){ee.debug("invalid Content-Type"),n.reply(415);return}this._processInDialogSdpOffer(n).then(v=>{this._status!==ie.STATUS_TERMINATED&&t.call(this,v)}).catch(v=>{ee.warn(v)});function t(v){const C=[`Contact: ${this._contact}`];this._handleSessionTimersInIncomingRequest(n,C),n.reply(200,null,C,v),typeof e.callback=="function"&&e.callback()}}_processInDialogSdpOffer(n){ee.debug("_processInDialogSdpOffer()");const a=n.parseSDP();let e=!1;for(const t of a.media){if(eo.indexOf(t.type)===-1)continue;const v=t.direction||a.direction||"sendrecv";if(v==="sendonly"||v==="inactive")e=!0;else{e=!1;break}}const o={originator:"remote",type:"offer",sdp:n.body};ee.debug('emit "sdp"'),this.emit("sdp",o);const p=new RTCSessionDescription({type:"offer",sdp:o.sdp});return this._connectionPromiseQueue=this._connectionPromiseQueue.then(()=>{if(this._status===ie.STATUS_TERMINATED)throw new Error("terminated");return this._connection.setRemoteDescription(p).catch(t=>{throw n.reply(488),ee.warn('emit "peerconnection:setremotedescriptionfailed" [error:%o]',t),this.emit("peerconnection:setremotedescriptionfailed",t),t})}).then(()=>{if(this._status===ie.STATUS_TERMINATED)throw new Error("terminated");this._remoteHold===!0&&e===!1?(this._remoteHold=!1,this._onunhold("remote")):this._remoteHold===!1&&e===!0&&(this._remoteHold=!0,this._onhold("remote"))}).then(()=>{if(this._status===ie.STATUS_TERMINATED)throw new Error("terminated");return this._createLocalDescription("answer",this._rtcAnswerConstraints).catch(t=>{throw n.reply(500),ee.warn('emit "peerconnection:createtelocaldescriptionfailed" [error:%o]',t),t})}).catch(t=>{ee.warn("_processInDialogSdpOffer() failed [error: %o]",t)}),this._connectionPromiseQueue}_receiveRefer(n){if(ee.debug("receiveRefer()"),!n.refer_to){ee.debug("no Refer-To header field present in REFER"),n.reply(400);return}if(n.refer_to.uri.scheme!==Te.SIP){ee.debug("Refer-To header field points to a non-SIP URI scheme"),n.reply(416);return}n.reply(202);const a=new Tg(this,n.cseq);ee.debug('emit "refer"'),this.emit("refer",{request:n,accept:(p,t)=>{e.call(this,p,t)},reject:()=>{o.call(this)}});function e(p,t={}){if(p=typeof p=="function"?p:null,this._status!==ie.STATUS_WAITING_FOR_ACK&&this._status!==ie.STATUS_CONFIRMED)return!1;const v=new Ku(this._ua);if(v.on("progress",({response:C})=>{a.notify(C.status_code,C.reason_phrase)}),v.on("accepted",({response:C})=>{a.notify(C.status_code,C.reason_phrase)}),v.on("_failed",({message:C,cause:l})=>{C?a.notify(C.status_code,C.reason_phrase):a.notify(487,l)}),n.refer_to.uri.hasHeader("replaces")){const C=decodeURIComponent(n.refer_to.uri.getHeader("replaces"));t.extraHeaders=lt.cloneArray(t.extraHeaders),t.extraHeaders.push(`Replaces: ${C}`)}v.connect(n.refer_to.uri.toAor(),t,p)}function o(){a.notify(603)}}_receiveNotify(n){switch(ee.debug("receiveNotify()"),n.event||n.reply(400),n.event.event){case"refer":{let a,e;if(n.event.params&&n.event.params.id)a=n.event.params.id,e=this._referSubscribers[a];else if(Object.keys(this._referSubscribers).length===1)e=this._referSubscribers[Object.keys(this._referSubscribers)[0]];else{n.reply(400,"Missing event id parameter");return}if(!e){n.reply(481,"Subscription does not exist");return}e.receiveNotify(n),n.reply(200);break}default:n.reply(489)}}_receiveReplaces(n){ee.debug("receiveReplaces()");function a(o){if(this._status!==ie.STATUS_WAITING_FOR_ACK&&this._status!==ie.STATUS_CONFIRMED)return!1;const p=new Ku(this._ua);p.on("confirmed",()=>{this.terminate()}),p.init_incoming(n,o)}function e(){ee.debug("Replaced INVITE rejected by the user"),n.reply(486)}this.emit("replaces",{request:n,accept:o=>{a.call(this,o)},reject:()=>{e.call(this)}})}_sendInitialRequest(n,a,e){const o=new vg(this._ua,this._request,{onRequestTimeout:()=>{this.onRequestTimeout()},onTransportError:()=>{this.onTransportError()},onAuthenticated:p=>{this._request=p},onReceiveResponse:p=>{this._receiveInviteResponse(p)}});Promise.resolve().then(()=>{if(e)return e;if(n.audio||n.video)return this._localMediaStreamLocallyGenerated=!0,navigator.mediaDevices.getUserMedia(n).catch(p=>{throw this._status===ie.STATUS_TERMINATED?new Error("terminated"):(this._failed("local",null,Te.causes.USER_DENIED_MEDIA_ACCESS),ee.warn('emit "getusermediafailed" [error:%o]',p),this.emit("getusermediafailed",p),p)})}).then(p=>{if(this._status===ie.STATUS_TERMINATED)throw new Error("terminated");return this._localMediaStream=p,p&&p.getTracks().forEach(t=>{this._connection.addTrack(t,p)}),this._connecting(this._request),this._createLocalDescription("offer",a).catch(t=>{throw this._failed("local",null,Te.causes.WEBRTC_ERROR),t})}).then(p=>{if(this._is_canceled||this._status===ie.STATUS_TERMINATED)throw new Error("terminated");this._request.body=p,this._status=ie.STATUS_INVITE_SENT,ee.debug('emit "sending" [request:%o]',this._request),this.emit("sending",{request:this._request}),o.send()}).catch(p=>{this._status!==ie.STATUS_TERMINATED&&ee.warn(p)})}_getDTMFRTPSender(){const n=this._connection.getSenders().find(a=>a.track&&a.track.kind==="audio");if(!(n&&n.dtmf)){ee.warn("sendDTMF() | no local audio track to send DTMF with");return}return n.dtmf}_receiveInviteResponse(n){if(ee.debug("receiveInviteResponse()"),this._dialog&&n.status_code>=200&&n.status_code<=299)if(this._dialog.id.call_id===n.call_id&&this._dialog.id.local_tag===n.from_tag&&this._dialog.id.remote_tag===n.to_tag){this.sendRequest(Te.ACK);return}else{const a=new Za(this,n,"UAC");if(a.error!==void 0){ee.debug(a.error);return}this.sendRequest(Te.ACK),this.sendRequest(Te.BYE);return}if(this._is_canceled){n.status_code>=100&&n.status_code<200?this._request.cancel(this._cancel_reason):n.status_code>=200&&n.status_code<299&&this._acceptAndTerminate(n);return}if(!(this._status!==ie.STATUS_INVITE_SENT&&this._status!==ie.STATUS_1XX_RECEIVED))switch(!0){case/^100$/.test(n.status_code):this._status=ie.STATUS_1XX_RECEIVED;break;case/^1[0-9]{2}$/.test(n.status_code):{if(!n.to_tag){ee.debug("1xx response received without to tag");break}if(n.hasHeader("contact")&&!this._createDialog(n,"UAC",!0))break;if(this._status=ie.STATUS_1XX_RECEIVED,!n.body){this._progress("remote",n);break}const a={originator:"remote",type:"answer",sdp:n.body};ee.debug('emit "sdp"'),this.emit("sdp",a);const e=new RTCSessionDescription({type:"answer",sdp:a.sdp});this._connectionPromiseQueue=this._connectionPromiseQueue.then(()=>this._connection.setRemoteDescription(e)).then(()=>this._progress("remote",n)).catch(o=>{ee.warn('emit "peerconnection:setremotedescriptionfailed" [error:%o]',o),this.emit("peerconnection:setremotedescriptionfailed",o)});break}case/^2[0-9]{2}$/.test(n.status_code):{if(this._status=ie.STATUS_CONFIRMED,!n.body){this._acceptAndTerminate(n,400,Te.causes.MISSING_SDP),this._failed("remote",n,Te.causes.BAD_MEDIA_DESCRIPTION);break}if(!this._createDialog(n,"UAC"))break;const a={originator:"remote",type:"answer",sdp:n.body};ee.debug('emit "sdp"'),this.emit("sdp",a);const e=new RTCSessionDescription({type:"answer",sdp:a.sdp});this._connectionPromiseQueue=this._connectionPromiseQueue.then(()=>{if(this._connection.signalingState==="stable")return this._connection.createOffer(this._rtcOfferConstraints).then(o=>this._connection.setLocalDescription(o)).catch(o=>{this._acceptAndTerminate(n,500,o.toString()),this._failed("local",n,Te.causes.WEBRTC_ERROR)})}).then(()=>{this._connection.setRemoteDescription(e).then(()=>{this._handleSessionTimersInIncomingResponse(n),this._accepted("remote",n),this.sendRequest(Te.ACK),this._confirmed("local",null)}).catch(o=>{this._acceptAndTerminate(n,488,"Not Acceptable Here"),this._failed("remote",n,Te.causes.BAD_MEDIA_DESCRIPTION),ee.warn('emit "peerconnection:setremotedescriptionfailed" [error:%o]',o),this.emit("peerconnection:setremotedescriptionfailed",o)})});break}default:{const a=lt.sipErrorCause(n.status_code);this._failed("remote",n,a)}}}_sendReinvite(n={}){ee.debug("sendReinvite()");const a=lt.cloneArray(n.extraHeaders),e=lt.cloneObject(n.eventHandlers),o=n.rtcOfferConstraints||this._rtcOfferConstraints||null;let p=!1;a.push(`Contact: ${this._contact}`),a.push("Content-Type: application/sdp"),this._sessionTimers.running&&a.push(`Session-Expires: ${this._sessionTimers.currentExpires};refresher=${this._sessionTimers.refresher?"uac":"uas"}`),this._connectionPromiseQueue=this._connectionPromiseQueue.then(()=>this._createLocalDescription("offer",o)).then(C=>{C=this._mangleOffer(C);const l={originator:"local",type:"offer",sdp:C};ee.debug('emit "sdp"'),this.emit("sdp",l),this.sendRequest(Te.INVITE,{extraHeaders:a,body:C,eventHandlers:{onSuccessResponse:A=>{t.call(this,A),p=!0},onErrorResponse:A=>{v.call(this,A)},onTransportError:()=>{this.onTransportError()},onRequestTimeout:()=>{this.onRequestTimeout()},onDialogError:()=>{this.onDialogError()}}})}).catch(()=>{v()});function t(C){if(this._status===ie.STATUS_TERMINATED||(this.sendRequest(Te.ACK),p))return;if(this._handleSessionTimersInIncomingResponse(C),C.body){if(!C.hasHeader("Content-Type")||C.getHeader("Content-Type").toLowerCase()!=="application/sdp"){v.call(this);return}}else{v.call(this);return}const l={originator:"remote",type:"answer",sdp:C.body};ee.debug('emit "sdp"'),this.emit("sdp",l);const A=new RTCSessionDescription({type:"answer",sdp:l.sdp});this._connectionPromiseQueue=this._connectionPromiseQueue.then(()=>this._connection.setRemoteDescription(A)).then(()=>{e.succeeded&&e.succeeded(C)}).catch(b=>{v.call(this),ee.warn('emit "peerconnection:setremotedescriptionfailed" [error:%o]',b),this.emit("peerconnection:setremotedescriptionfailed",b)})}function v(C){e.failed&&e.failed(C)}}_sendUpdate(n={}){ee.debug("sendUpdate()");const a=lt.cloneArray(n.extraHeaders),e=lt.cloneObject(n.eventHandlers),o=n.rtcOfferConstraints||this._rtcOfferConstraints||null,p=n.sdpOffer||!1;let t=!1;a.push(`Contact: ${this._contact}`),this._sessionTimers.running&&a.push(`Session-Expires: ${this._sessionTimers.currentExpires};refresher=${this._sessionTimers.refresher?"uac":"uas"}`),p?(a.push("Content-Type: application/sdp"),this._connectionPromiseQueue=this._connectionPromiseQueue.then(()=>this._createLocalDescription("offer",o)).then(l=>{l=this._mangleOffer(l);const A={originator:"local",type:"offer",sdp:l};ee.debug('emit "sdp"'),this.emit("sdp",A),this.sendRequest(Te.UPDATE,{extraHeaders:a,body:l,eventHandlers:{onSuccessResponse:b=>{v.call(this,b),t=!0},onErrorResponse:b=>{C.call(this,b)},onTransportError:()=>{this.onTransportError()},onRequestTimeout:()=>{this.onRequestTimeout()},onDialogError:()=>{this.onDialogError()}}})}).catch(()=>{C.call(this)})):this.sendRequest(Te.UPDATE,{extraHeaders:a,eventHandlers:{onSuccessResponse:l=>{v.call(this,l)},onErrorResponse:l=>{C.call(this,l)},onTransportError:()=>{this.onTransportError()},onRequestTimeout:()=>{this.onRequestTimeout()},onDialogError:()=>{this.onDialogError()}}});function v(l){if(this._status!==ie.STATUS_TERMINATED&&!t)if(this._handleSessionTimersInIncomingResponse(l),p){if(l.body){if(!l.hasHeader("Content-Type")||l.getHeader("Content-Type").toLowerCase()!=="application/sdp"){C.call(this);return}}else{C.call(this);return}const A={originator:"remote",type:"answer",sdp:l.body};ee.debug('emit "sdp"'),this.emit("sdp",A);const b=new RTCSessionDescription({type:"answer",sdp:A.sdp});this._connectionPromiseQueue=this._connectionPromiseQueue.then(()=>this._connection.setRemoteDescription(b)).then(()=>{e.succeeded&&e.succeeded(l)}).catch(E=>{C.call(this),ee.warn('emit "peerconnection:setremotedescriptionfailed" [error:%o]',E),this.emit("peerconnection:setremotedescriptionfailed",E)})}else e.succeeded&&e.succeeded(l)}function C(l){e.failed&&e.failed(l)}}_acceptAndTerminate(n,a,e){ee.debug("acceptAndTerminate()");const o=[];a&&(e=e||Te.REASON_PHRASE[a]||"",o.push(`Reason: SIP ;cause=${a}; text="${e}"`)),(this._dialog||this._createDialog(n,"UAC"))&&(this.sendRequest(Te.ACK),this.sendRequest(Te.BYE,{extraHeaders:o})),this._status=ie.STATUS_TERMINATED}_mangleOffer(n){if(!this._localHold&&!this._remoteHold)return n;if(n=Qf.parse(n),this._localHold&&!this._remoteHold){ee.debug("mangleOffer() | me on hold, mangling offer");for(const a of n.media)eo.indexOf(a.type)!==-1&&(a.direction?a.direction==="sendrecv"?a.direction="sendonly":a.direction==="recvonly"&&(a.direction="inactive"):a.direction="sendonly")}else if(this._localHold&&this._remoteHold){ee.debug("mangleOffer() | both on hold, mangling offer");for(const a of n.media)eo.indexOf(a.type)!==-1&&(a.direction="inactive")}else if(this._remoteHold){ee.debug("mangleOffer() | remote on hold, mangling offer");for(const a of n.media)eo.indexOf(a.type)!==-1&&(a.direction?a.direction==="sendrecv"?a.direction="recvonly":a.direction==="recvonly"&&(a.direction="inactive"):a.direction="recvonly")}return Qf.write(n)}_setLocalMediaStatus(){let n=!0,a=!0;(this._localHold||this._remoteHold)&&(n=!1,a=!1),this._audioMuted&&(n=!1),this._videoMuted&&(a=!1),this._toggleMuteAudio(!n),this._toggleMuteVideo(!a)}_handleSessionTimersInIncomingRequest(n,a){if(!this._sessionTimers.enabled)return;let e;n.session_expires&&n.session_expires>=Te.MIN_SESSION_EXPIRES?(this._sessionTimers.currentExpires=n.session_expires,e=n.session_expires_refresher||"uas"):(this._sessionTimers.currentExpires=this._sessionTimers.defaultExpires,e="uas"),a.push(`Session-Expires: ${this._sessionTimers.currentExpires};refresher=${e}`),this._sessionTimers.refresher=e==="uas",this._runSessionTimer()}_handleSessionTimersInIncomingResponse(n){if(!this._sessionTimers.enabled)return;let a;n.session_expires&&n.session_expires>=Te.MIN_SESSION_EXPIRES?(this._sessionTimers.currentExpires=n.session_expires,a=n.session_expires_refresher||"uac"):(this._sessionTimers.currentExpires=this._sessionTimers.defaultExpires,a="uac"),this._sessionTimers.refresher=a==="uac",this._runSessionTimer()}_runSessionTimer(){const n=this._sessionTimers.currentExpires;this._sessionTimers.running=!0,clearTimeout(this._sessionTimers.timer),this._sessionTimers.refresher?this._sessionTimers.timer=setTimeout(()=>{this._status!==ie.STATUS_TERMINATED&&this._isReadyToReOffer()&&(ee.debug("runSessionTimer() | sending session refresh request"),this._sessionTimers.refreshMethod===Te.UPDATE?this._sendUpdate():this._sendReinvite())},n*500):this._sessionTimers.timer=setTimeout(()=>{this._status!==ie.STATUS_TERMINATED&&(ee.warn("runSessionTimer() | timer expired, terminating the session"),this.terminate({cause:Te.causes.REQUEST_TIMEOUT,status_code:408,reason_phrase:"Session Timer Expired"}))},n*1100)}_toggleMuteAudio(n){const a=this._connection.getSenders().filter(e=>e.track&&e.track.kind==="audio");for(const e of a)e.track.enabled=!n}_toggleMuteVideo(n){const a=this._connection.getSenders().filter(e=>e.track&&e.track.kind==="video");for(const e of a)e.track.enabled=!n}_newRTCSession(n,a){ee.debug("newRTCSession()"),this._ua.newRTCSession(this,{originator:n,session:this,request:a})}_connecting(n){ee.debug("session connecting"),ee.debug('emit "connecting"'),this.emit("connecting",{request:n})}_progress(n,a){ee.debug("session progress"),ee.debug('emit "progress"'),this.emit("progress",{originator:n,response:a||null})}_accepted(n,a){ee.debug("session accepted"),this._start_time=new Date,ee.debug('emit "accepted"'),this.emit("accepted",{originator:n,response:a||null})}_confirmed(n,a){ee.debug("session confirmed"),this._is_confirmed=!0,ee.debug('emit "confirmed"'),this.emit("confirmed",{originator:n,ack:a||null})}_ended(n,a,e){ee.debug("session ended"),this._end_time=new Date,this._close(),ee.debug('emit "ended"'),this.emit("ended",{originator:n,message:a||null,cause:e})}_failed(n,a,e){ee.debug("session failed"),ee.debug('emit "_failed"'),this.emit("_failed",{originator:n,message:a||null,cause:e}),this._close(),ee.debug('emit "failed"'),this.emit("failed",{originator:n,message:a||null,cause:e})}_onhold(n){ee.debug("session onhold"),this._setLocalMediaStatus(),ee.debug('emit "hold"'),this.emit("hold",{originator:n})}_onunhold(n){ee.debug("session onunhold"),this._setLocalMediaStatus(),ee.debug('emit "unhold"'),this.emit("unhold",{originator:n})}_onmute({audio:n,video:a}){ee.debug("session onmute"),this._setLocalMediaStatus(),ee.debug('emit "muted"'),this.emit("muted",{audio:n,video:a})}_onunmute({audio:n,video:a}){ee.debug("session onunmute"),this._setLocalMediaStatus(),ee.debug('emit "unmuted"'),this.emit("unmuted",{audio:n,video:a})}};const Cg=Be(sh),Sg=Ct.EventEmitter,Ag=Tt,Au=Fe,yg=kt,ji=wt(),Rg=zr,nh=Sn,bg=Tn(),to=new Ag("Message");var Ig=class extends Sg{constructor(n){super(),this._ua=n,this._request=null,this._closed=!1,this._direction=null,this._local_identity=null,this._remote_identity=null,this._is_replied=!1,this._data={}}get direction(){return this._direction}get local_identity(){return this._local_identity}get remote_identity(){return this._remote_identity}send(n,a,e={}){const o=n;if(n===void 0||a===void 0)throw new TypeError("Not enough arguments");if(n=this._ua.normalizeTarget(n),!n)throw new TypeError(`Invalid target: ${o}`);const p=ji.cloneArray(e.extraHeaders),t=ji.cloneObject(e.eventHandlers),v=e.contentType||"text/plain",C={};e.fromUserName&&(C.from_uri=new bg("sip",e.fromUserName,this._ua.configuration.uri.host),p.push(`P-Preferred-Identity: ${this._ua.configuration.uri.toString()}`)),e.fromDisplayName&&(C.from_display_name=e.fromDisplayName);for(const A in t)Object.prototype.hasOwnProperty.call(t,A)&&this.on(A,t[A]);p.push(`Content-Type: ${v}`),this._request=new yg.OutgoingRequest(Au.MESSAGE,n,this._ua,C,p),a&&(this._request.body=a);const l=new Rg(this._ua,this._request,{onRequestTimeout:()=>{this._onRequestTimeout()},onTransportError:()=>{this._onTransportError()},onReceiveResponse:A=>{this._receiveResponse(A)}});this._newMessage("local",this._request),l.send()}init_incoming(n){this._request=n,this._newMessage("remote",n),this._is_replied||(this._is_replied=!0,n.reply(200)),this._close()}accept(n={}){const a=ji.cloneArray(n.extraHeaders),e=n.body;if(this._direction!=="incoming")throw new nh.NotSupportedError('"accept" not supported for outgoing Message');if(this._is_replied)throw new Error("incoming Message already replied");this._is_replied=!0,this._request.reply(200,null,a,e)}reject(n={}){const a=n.status_code||480,e=n.reason_phrase,o=ji.cloneArray(n.extraHeaders),p=n.body;if(this._direction!=="incoming")throw new nh.NotSupportedError('"reject" not supported for outgoing Message');if(this._is_replied)throw new Error("incoming Message already replied");if(a<300||a>=700)throw new TypeError(`Invalid status_code: ${a}`);this._is_replied=!0,this._request.reply(a,e,o,p)}_receiveResponse(n){if(!this._closed)switch(!0){case/^1[0-9]{2}$/.test(n.status_code):break;case/^2[0-9]{2}$/.test(n.status_code):this._succeeded("remote",n);break;default:{const a=ji.sipErrorCause(n.status_code);this._failed("remote",n,a);break}}}_onRequestTimeout(){this._closed||this._failed("system",null,Au.causes.REQUEST_TIMEOUT)}_onTransportError(){this._closed||this._failed("system",null,Au.causes.CONNECTION_ERROR)}_close(){this._closed=!0,this._ua.destroyMessage(this)}_newMessage(n,a){n==="remote"?(this._direction="incoming",this._local_identity=a.to,this._remote_identity=a.from):n==="local"&&(this._direction="outgoing",this._local_identity=a.from,this._remote_identity=a.to),this._ua.newMessage(this,{originator:n,message:this,request:a})}_failed(n,a,e){to.debug("MESSAGE failed"),this._close(),to.debug('emit "failed"'),this.emit("failed",{originator:n,response:a||null,cause:e})}_succeeded(n,a){to.debug("MESSAGE succeeded"),this._close(),to.debug('emit "succeeded"'),this.emit("succeeded",{originator:n,response:a})}};const wg=Ct.EventEmitter,Og=Tt,yu=Fe,Dg=kt,Vi=wt(),Ng=zr,lh=Sn,so=new Og("Options");var Ug=class extends wg{constructor(n){super(),this._ua=n,this._request=null,this._closed=!1,this._direction=null,this._local_identity=null,this._remote_identity=null,this._is_replied=!1,this._data={}}get direction(){return this._direction}get local_identity(){return this._local_identity}get remote_identity(){return this._remote_identity}send(n,a,e={}){const o=n;if(n===void 0)throw new TypeError("A target is required for OPTIONS");if(n=this._ua.normalizeTarget(n),!n)throw new TypeError(`Invalid target: ${o}`);const p=Vi.cloneArray(e.extraHeaders),t=Vi.cloneObject(e.eventHandlers),v=e.contentType||"application/sdp";for(const l in t)Object.prototype.hasOwnProperty.call(t,l)&&this.on(l,t[l]);p.push(`Content-Type: ${v}`),this._request=new Dg.OutgoingRequest(yu.OPTIONS,n,this._ua,null,p),a&&(this._request.body=a);const C=new Ng(this._ua,this._request,{onRequestTimeout:()=>{this._onRequestTimeout()},onTransportError:()=>{this._onTransportError()},onReceiveResponse:l=>{this._receiveResponse(l)}});this._newOptions("local",this._request),C.send()}init_incoming(n){this._request=n,this._newOptions("remote",n),this._is_replied||(this._is_replied=!0,n.reply(200)),this._close()}accept(n={}){const a=Vi.cloneArray(n.extraHeaders),e=n.body;if(this._direction!=="incoming")throw new lh.NotSupportedError('"accept" not supported for outgoing Options');if(this._is_replied)throw new Error("incoming Options already replied");this._is_replied=!0,this._request.reply(200,null,a,e)}reject(n={}){const a=n.status_code||480,e=n.reason_phrase,o=Vi.cloneArray(n.extraHeaders),p=n.body;if(this._direction!=="incoming")throw new lh.NotSupportedError('"reject" not supported for outgoing Options');if(this._is_replied)throw new Error("incoming Options already replied");if(a<300||a>=700)throw new TypeError(`Invalid status_code: ${a}`);this._is_replied=!0,this._request.reply(a,e,o,p)}_receiveResponse(n){if(!this._closed)switch(!0){case/^1[0-9]{2}$/.test(n.status_code):break;case/^2[0-9]{2}$/.test(n.status_code):this._succeeded("remote",n);break;default:{const a=Vi.sipErrorCause(n.status_code);this._failed("remote",n,a);break}}}_onRequestTimeout(){this._closed||this._failed("system",null,yu.causes.REQUEST_TIMEOUT)}_onTransportError(){this._closed||this._failed("system",null,yu.causes.CONNECTION_ERROR)}_close(){this._closed=!0,this._ua.destroyMessage(this)}_newOptions(n,a){n==="remote"?(this._direction="incoming",this._local_identity=a.to,this._remote_identity=a.from):n==="local"&&(this._direction="outgoing",this._local_identity=a.from,this._remote_identity=a.to),this._ua.newOptions(this,{originator:n,message:this,request:a})}_failed(n,a,e){so.debug("OPTIONS failed"),this._close(),so.debug('emit "failed"'),this.emit("failed",{originator:n,response:a||null,cause:e})}_succeeded(n,a){so.debug("OPTIONS succeeded"),this._close(),so.debug('emit "succeeded"'),this.emit("succeeded",{originator:n,response:a})}},Ru={};const xg=Tt,bu=wt(),Pg=Ys(),Bi=new xg("Socket");Ru.isSocket=u=>{if(Array.isArray(u))return!1;if(typeof u>"u")return Bi.warn("undefined JsSIP.Socket instance"),!1;try{if(!bu.isString(u.url))throw Bi.warn("missing or invalid JsSIP.Socket url property"),new Error("Missing or invalid JsSIP.Socket url property");if(!bu.isString(u.via_transport))throw Bi.warn("missing or invalid JsSIP.Socket via_transport property"),new Error("Missing or invalid JsSIP.Socket via_transport property");if(Pg.parse(u.sip_uri,"SIP_URI")===-1)throw Bi.warn("missing or invalid JsSIP.Socket sip_uri property"),new Error("missing or invalid JsSIP.Socket sip_uri property")}catch{return!1}try{["connect","disconnect","send"].forEach(n=>{if(!bu.isFunction(u[n]))throw Bi.warn(`missing or invalid JsSIP.Socket method: ${n}`),new Error(`Missing or invalid JsSIP.Socket method: ${n}`)})}catch{return!1}return!0};const Mg=Tt,kg=Ru,rh=Fe,Kt=new Mg("Transport"),us={STATUS_CONNECTED:0,STATUS_CONNECTING:1,STATUS_DISCONNECTED:2,SOCKET_STATUS_READY:0,SOCKET_STATUS_ERROR:1,recovery_options:{min_interval:rh.CONNECTION_RECOVERY_MIN_INTERVAL,max_interval:rh.CONNECTION_RECOVERY_MAX_INTERVAL}};var ih=class{constructor(n,a=us.recovery_options){Kt.debug("new()"),this.status=us.STATUS_DISCONNECTED,this.socket=null,this.sockets=[],this.recovery_options=a,this.recover_attempts=0,this.recovery_timer=null,this.close_requested=!1;try{this.textDecoder=new TextDecoder("utf8")}catch(e){Kt.warn(`cannot use TextDecoder: ${e}`)}if(typeof n>"u")throw new TypeError("Invalid argument. undefined 'sockets' argument");n instanceof Array||(n=[n]),n.forEach(function(e){if(!kg.isSocket(e.socket))throw new TypeError("Invalid argument. invalid 'JsSIP.Socket' instance");if(e.weight&&!Number(e.weight))throw new TypeError("Invalid argument. 'weight' attribute is not a number");this.sockets.push({socket:e.socket,weight:e.weight||0,status:us.SOCKET_STATUS_READY})},this),this._getSocket()}get via_transport(){return this.socket.via_transport}get url(){return this.socket.url}get sip_uri(){return this.socket.sip_uri}connect(){if(Kt.debug("connect()"),this.isConnected()){Kt.debug("Transport is already connected");return}else if(this.isConnecting()){Kt.debug("Transport is connecting");return}this.close_requested=!1,this.status=us.STATUS_CONNECTING,this.onconnecting({socket:this.socket,attempts:this.recover_attempts}),this.close_requested||(this.socket.onconnect=this._onConnect.bind(this),this.socket.ondisconnect=this._onDisconnect.bind(this),this.socket.ondata=this._onData.bind(this),this.socket.connect())}disconnect(){Kt.debug("close()"),this.close_requested=!0,this.recover_attempts=0,this.status=us.STATUS_DISCONNECTED,this.recovery_timer!==null&&(clearTimeout(this.recovery_timer),this.recovery_timer=null),this.socket.onconnect=()=>{},this.socket.ondisconnect=()=>{},this.socket.ondata=()=>{},this.socket.disconnect(),this.ondisconnect({socket:this.socket,error:!1})}send(n){if(Kt.debug("send()"),!this.isConnected())return Kt.warn("unable to send message, transport is not connected"),!1;const a=n.toString();return Kt.debug(`sending message:
|
112
|
+
`,this.transport.send(a)}}class Im extends Nf{constructor(){super(),this.headers={},this.status_code=null,this.reason_phrase=null}}var bt={OutgoingRequest:ta,InitialOutgoingInviteRequest:eu,IncomingRequest:Rm,IncomingResponse:Im};const un=Le(bt),bm=ut,ps=Tt(),Wt=new bm("DigestAuthentication");var Uf=class{constructor(s){this._credentials=s,this._cnonce=null,this._nc=0,this._ncHex="00000000",this._algorithm=null,this._realm=null,this._nonce=null,this._opaque=null,this._stale=null,this._qop=null,this._method=null,this._uri=null,this._ha1=null,this._response=null}get(s){switch(s){case"realm":return this._realm;case"ha1":return this._ha1;default:Wt.warn('get() | cannot get "%s" parameter',s);return}}authenticate({method:s,ruri:i,body:l},a,_=null){if(this._algorithm=a.algorithm,this._realm=a.realm,this._nonce=a.nonce,this._opaque=a.opaque,this._stale=a.stale,this._algorithm){if(this._algorithm!=="MD5")return Wt.warn('authenticate() | challenge with Digest algorithm different than "MD5", authentication aborted'),!1}else this._algorithm="MD5";if(!this._nonce)return Wt.warn("authenticate() | challenge without Digest nonce, authentication aborted"),!1;if(!this._realm)return Wt.warn("authenticate() | challenge without Digest realm, authentication aborted"),!1;if(!this._credentials.password){if(!this._credentials.ha1)return Wt.warn("authenticate() | no plain SIP password nor ha1 provided, authentication aborted"),!1;if(this._credentials.realm!==this._realm)return Wt.warn('authenticate() | no plain SIP password, and stored `realm` does not match the given `realm`, cannot authenticate [stored:"%s", given:"%s"]',this._credentials.realm,this._realm),!1}if(a.qop)if(a.qop.indexOf("auth-int")>-1)this._qop="auth-int";else if(a.qop.indexOf("auth")>-1)this._qop="auth";else return Wt.warn('authenticate() | challenge without Digest qop different than "auth" or "auth-int", authentication aborted'),!1;else this._qop=null;this._method=s,this._uri=i,this._cnonce=_||ps.createRandomToken(12),this._nc+=1;const e=Number(this._nc).toString(16);this._ncHex="00000000".substr(0,8-e.length)+e,this._nc===4294967296&&(this._nc=1,this._ncHex="00000001"),this._credentials.password?this._ha1=ps.calculateMD5(`${this._credentials.username}:${this._realm}:${this._credentials.password}`):this._ha1=this._credentials.ha1;let p,g;return this._qop==="auth"?(p=`${this._method}:${this._uri}`,g=ps.calculateMD5(p),Wt.debug('authenticate() | using qop=auth [a2:"%s"]',p),this._response=ps.calculateMD5(`${this._ha1}:${this._nonce}:${this._ncHex}:${this._cnonce}:auth:${g}`)):this._qop==="auth-int"?(p=`${this._method}:${this._uri}:${ps.calculateMD5(l||"")}`,g=ps.calculateMD5(p),Wt.debug('authenticate() | using qop=auth-int [a2:"%s"]',p),this._response=ps.calculateMD5(`${this._ha1}:${this._nonce}:${this._ncHex}:${this._cnonce}:auth-int:${g}`)):this._qop===null&&(p=`${this._method}:${this._uri}`,g=ps.calculateMD5(p),Wt.debug('authenticate() | using qop=null [a2:"%s"]',p),this._response=ps.calculateMD5(`${this._ha1}:${this._nonce}:${g}`)),Wt.debug("authenticate() | response generated"),!0}toString(){const s=[];if(!this._response)throw new Error("response field does not exist, cannot generate Authorization header");return s.push(`algorithm=${this._algorithm}`),s.push(`username="${this._credentials.username}"`),s.push(`realm="${this._realm}"`),s.push(`nonce="${this._nonce}"`),s.push(`uri="${this._uri}"`),s.push(`response="${this._response}"`),this._opaque&&s.push(`opaque="${this._opaque}"`),this._qop&&(s.push(`qop=${this._qop}`),s.push(`cnonce="${this._cnonce}"`),s.push(`nc=${this._ncHex}`)),`Digest ${s.join(", ")}`}};const wm=Le(Uf),ms=500,Om=4e3,Pf=5e3;var tu={T1:ms,T2:Om,T4:Pf,TIMER_B:64*ms,TIMER_D:0*ms,TIMER_F:64*ms,TIMER_H:64*ms,TIMER_I:0*ms,TIMER_J:0*ms,TIMER_K:0*Pf,TIMER_L:64*ms,TIMER_M:64*ms,PROVISIONAL_RESPONSE_INTERVAL:6e4};const Mr=Le(tu),kr=ct.EventEmitter,Lr=ut,$r=xe,xf=bt,ss=tu,Mf=new Lr("NonInviteClientTransaction"),sa=new Lr("InviteClientTransaction"),Dm=new Lr("AckClientTransaction"),kf=new Lr("NonInviteServerTransaction"),na=new Lr("InviteServerTransaction"),fe={STATUS_TRYING:1,STATUS_PROCEEDING:2,STATUS_CALLING:3,STATUS_ACCEPTED:4,STATUS_COMPLETED:5,STATUS_TERMINATED:6,STATUS_CONFIRMED:7,NON_INVITE_CLIENT:"nict",NON_INVITE_SERVER:"nist",INVITE_CLIENT:"ict",INVITE_SERVER:"ist"};class Nm extends kr{constructor(s,i,l,a){super(),this.type=fe.NON_INVITE_CLIENT,this.id=`z9hG4bK${Math.floor(Math.random()*1e7)}`,this.ua=s,this.transport=i,this.request=l,this.eventHandlers=a;let _=`SIP/2.0/${i.via_transport}`;_+=` ${s.configuration.via_host};branch=${this.id}`,this.request.setHeader("via",_),this.ua.newTransaction(this)}get C(){return fe}stateChanged(s){this.state=s,this.emit("stateChanged")}send(){this.stateChanged(fe.STATUS_TRYING),this.F=setTimeout(()=>{this.timer_F()},ss.TIMER_F),this.transport.send(this.request)||this.onTransportError()}onTransportError(){Mf.debug(`transport error occurred, deleting transaction ${this.id}`),clearTimeout(this.F),clearTimeout(this.K),this.stateChanged(fe.STATUS_TERMINATED),this.ua.destroyTransaction(this),this.eventHandlers.onTransportError()}timer_F(){Mf.debug(`Timer F expired for transaction ${this.id}`),this.stateChanged(fe.STATUS_TERMINATED),this.ua.destroyTransaction(this),this.eventHandlers.onRequestTimeout()}timer_K(){this.stateChanged(fe.STATUS_TERMINATED),this.ua.destroyTransaction(this)}receiveResponse(s){const i=s.status_code;if(i<200)switch(this.state){case fe.STATUS_TRYING:case fe.STATUS_PROCEEDING:this.stateChanged(fe.STATUS_PROCEEDING),this.eventHandlers.onReceiveResponse(s);break}else switch(this.state){case fe.STATUS_TRYING:case fe.STATUS_PROCEEDING:this.stateChanged(fe.STATUS_COMPLETED),clearTimeout(this.F),i===408?this.eventHandlers.onRequestTimeout():this.eventHandlers.onReceiveResponse(s),this.K=setTimeout(()=>{this.timer_K()},ss.TIMER_K);break;case fe.STATUS_COMPLETED:break}}}class Um extends kr{constructor(s,i,l,a){super(),this.type=fe.INVITE_CLIENT,this.id=`z9hG4bK${Math.floor(Math.random()*1e7)}`,this.ua=s,this.transport=i,this.request=l,this.eventHandlers=a,l.transaction=this;let _=`SIP/2.0/${i.via_transport}`;_+=` ${s.configuration.via_host};branch=${this.id}`,this.request.setHeader("via",_),this.ua.newTransaction(this)}get C(){return fe}stateChanged(s){this.state=s,this.emit("stateChanged")}send(){this.stateChanged(fe.STATUS_CALLING),this.B=setTimeout(()=>{this.timer_B()},ss.TIMER_B),this.transport.send(this.request)||this.onTransportError()}onTransportError(){clearTimeout(this.B),clearTimeout(this.D),clearTimeout(this.M),this.state!==fe.STATUS_ACCEPTED&&(sa.debug(`transport error occurred, deleting transaction ${this.id}`),this.eventHandlers.onTransportError()),this.stateChanged(fe.STATUS_TERMINATED),this.ua.destroyTransaction(this)}timer_M(){sa.debug(`Timer M expired for transaction ${this.id}`),this.state===fe.STATUS_ACCEPTED&&(clearTimeout(this.B),this.stateChanged(fe.STATUS_TERMINATED),this.ua.destroyTransaction(this))}timer_B(){sa.debug(`Timer B expired for transaction ${this.id}`),this.state===fe.STATUS_CALLING&&(this.stateChanged(fe.STATUS_TERMINATED),this.ua.destroyTransaction(this),this.eventHandlers.onRequestTimeout())}timer_D(){sa.debug(`Timer D expired for transaction ${this.id}`),clearTimeout(this.B),this.stateChanged(fe.STATUS_TERMINATED),this.ua.destroyTransaction(this)}sendACK(s){const i=new xf.OutgoingRequest($r.ACK,this.request.ruri,this.ua,{route_set:this.request.getHeaders("route"),call_id:this.request.getHeader("call-id"),cseq:this.request.cseq});i.setHeader("from",this.request.getHeader("from")),i.setHeader("via",this.request.getHeader("via")),i.setHeader("to",s.getHeader("to")),this.D=setTimeout(()=>{this.timer_D()},ss.TIMER_D),this.transport.send(i)}cancel(s){if(this.state!==fe.STATUS_PROCEEDING)return;const i=new xf.OutgoingRequest($r.CANCEL,this.request.ruri,this.ua,{route_set:this.request.getHeaders("route"),call_id:this.request.getHeader("call-id"),cseq:this.request.cseq});i.setHeader("from",this.request.getHeader("from")),i.setHeader("via",this.request.getHeader("via")),i.setHeader("to",this.request.getHeader("to")),s&&i.setHeader("reason",s),this.transport.send(i)}receiveResponse(s){const i=s.status_code;if(i>=100&&i<=199)switch(this.state){case fe.STATUS_CALLING:this.stateChanged(fe.STATUS_PROCEEDING),this.eventHandlers.onReceiveResponse(s);break;case fe.STATUS_PROCEEDING:this.eventHandlers.onReceiveResponse(s);break}else if(i>=200&&i<=299)switch(this.state){case fe.STATUS_CALLING:case fe.STATUS_PROCEEDING:this.stateChanged(fe.STATUS_ACCEPTED),this.M=setTimeout(()=>{this.timer_M()},ss.TIMER_M),this.eventHandlers.onReceiveResponse(s);break;case fe.STATUS_ACCEPTED:this.eventHandlers.onReceiveResponse(s);break}else if(i>=300&&i<=699)switch(this.state){case fe.STATUS_CALLING:case fe.STATUS_PROCEEDING:this.stateChanged(fe.STATUS_COMPLETED),this.sendACK(s),this.eventHandlers.onReceiveResponse(s);break;case fe.STATUS_COMPLETED:this.sendACK(s);break}}}class Pm extends kr{constructor(s,i,l,a){super(),this.id=`z9hG4bK${Math.floor(Math.random()*1e7)}`,this.transport=i,this.request=l,this.eventHandlers=a;let _=`SIP/2.0/${i.via_transport}`;_+=` ${s.configuration.via_host};branch=${this.id}`,this.request.setHeader("via",_)}get C(){return fe}send(){this.transport.send(this.request)||this.onTransportError()}onTransportError(){Dm.debug(`transport error occurred for transaction ${this.id}`),this.eventHandlers.onTransportError()}}class xm extends kr{constructor(s,i,l){super(),this.type=fe.NON_INVITE_SERVER,this.id=l.via_branch,this.ua=s,this.transport=i,this.request=l,this.last_response="",l.server_transaction=this,this.state=fe.STATUS_TRYING,s.newTransaction(this)}get C(){return fe}stateChanged(s){this.state=s,this.emit("stateChanged")}timer_J(){kf.debug(`Timer J expired for transaction ${this.id}`),this.stateChanged(fe.STATUS_TERMINATED),this.ua.destroyTransaction(this)}onTransportError(){this.transportError||(this.transportError=!0,kf.debug(`transport error occurred, deleting transaction ${this.id}`),clearTimeout(this.J),this.stateChanged(fe.STATUS_TERMINATED),this.ua.destroyTransaction(this))}receiveResponse(s,i,l,a){if(s===100)switch(this.state){case fe.STATUS_TRYING:this.stateChanged(fe.STATUS_PROCEEDING),this.transport.send(i)||this.onTransportError();break;case fe.STATUS_PROCEEDING:this.last_response=i,this.transport.send(i)?l&&l():(this.onTransportError(),a&&a());break}else if(s>=200&&s<=699)switch(this.state){case fe.STATUS_TRYING:case fe.STATUS_PROCEEDING:this.stateChanged(fe.STATUS_COMPLETED),this.last_response=i,this.J=setTimeout(()=>{this.timer_J()},ss.TIMER_J),this.transport.send(i)?l&&l():(this.onTransportError(),a&&a());break;case fe.STATUS_COMPLETED:break}}}class Mm extends kr{constructor(s,i,l){super(),this.type=fe.INVITE_SERVER,this.id=l.via_branch,this.ua=s,this.transport=i,this.request=l,this.last_response="",l.server_transaction=this,this.state=fe.STATUS_PROCEEDING,s.newTransaction(this),this.resendProvisionalTimer=null,l.reply(100)}get C(){return fe}stateChanged(s){this.state=s,this.emit("stateChanged")}timer_H(){na.debug(`Timer H expired for transaction ${this.id}`),this.state===fe.STATUS_COMPLETED&&na.debug("ACK not received, dialog will be terminated"),this.stateChanged(fe.STATUS_TERMINATED),this.ua.destroyTransaction(this)}timer_I(){this.stateChanged(fe.STATUS_TERMINATED),this.ua.destroyTransaction(this)}timer_L(){na.debug(`Timer L expired for transaction ${this.id}`),this.state===fe.STATUS_ACCEPTED&&(this.stateChanged(fe.STATUS_TERMINATED),this.ua.destroyTransaction(this))}onTransportError(){this.transportError||(this.transportError=!0,na.debug(`transport error occurred, deleting transaction ${this.id}`),this.resendProvisionalTimer!==null&&(clearInterval(this.resendProvisionalTimer),this.resendProvisionalTimer=null),clearTimeout(this.L),clearTimeout(this.H),clearTimeout(this.I),this.stateChanged(fe.STATUS_TERMINATED),this.ua.destroyTransaction(this))}resend_provisional(){this.transport.send(this.last_response)||this.onTransportError()}receiveResponse(s,i,l,a){if(s>=100&&s<=199)switch(this.state){case fe.STATUS_PROCEEDING:this.transport.send(i)||this.onTransportError(),this.last_response=i;break}if(s>100&&s<=199&&this.state===fe.STATUS_PROCEEDING)this.resendProvisionalTimer===null&&(this.resendProvisionalTimer=setInterval(()=>{this.resend_provisional()},ss.PROVISIONAL_RESPONSE_INTERVAL));else if(s>=200&&s<=299)switch(this.state){case fe.STATUS_PROCEEDING:this.stateChanged(fe.STATUS_ACCEPTED),this.last_response=i,this.L=setTimeout(()=>{this.timer_L()},ss.TIMER_L),this.resendProvisionalTimer!==null&&(clearInterval(this.resendProvisionalTimer),this.resendProvisionalTimer=null);case fe.STATUS_ACCEPTED:this.transport.send(i)?l&&l():(this.onTransportError(),a&&a());break}else if(s>=300&&s<=699)switch(this.state){case fe.STATUS_PROCEEDING:this.resendProvisionalTimer!==null&&(clearInterval(this.resendProvisionalTimer),this.resendProvisionalTimer=null),this.transport.send(i)?(this.stateChanged(fe.STATUS_COMPLETED),this.H=setTimeout(()=>{this.timer_H()},ss.TIMER_H),l&&l()):(this.onTransportError(),a&&a());break}}}function km({_transactions:c},s){let i;switch(s.method){case $r.INVITE:if(i=c.ist[s.via_branch],i){switch(i.state){case fe.STATUS_PROCEEDING:i.transport.send(i.last_response);break;case fe.STATUS_ACCEPTED:break}return!0}break;case $r.ACK:if(i=c.ist[s.via_branch],i){if(i.state===fe.STATUS_ACCEPTED)return!1;if(i.state===fe.STATUS_COMPLETED)return i.state=fe.STATUS_CONFIRMED,i.I=setTimeout(()=>{i.timer_I()},ss.TIMER_I),!0}else return!1;break;case $r.CANCEL:return i=c.ist[s.via_branch],i?(s.reply_sl(200),i.state!==fe.STATUS_PROCEEDING):(s.reply_sl(481),!0);default:if(i=c.nist[s.via_branch],i){switch(i.state){case fe.STATUS_TRYING:break;case fe.STATUS_PROCEEDING:case fe.STATUS_COMPLETED:i.transport.send(i.last_response);break}return!0}break}}var Gn={C:fe,NonInviteClientTransaction:Nm,InviteClientTransaction:Um,AckClientTransaction:Pm,NonInviteServerTransaction:xm,InviteServerTransaction:Mm,checkTransaction:km};const jt=Le(Gn),Lm=ut,Lf=xe,$m=Uf,su=Gn,Hm=new Lm("RequestSender"),nu={onRequestTimeout:()=>{},onTransportError:()=>{},onReceiveResponse:()=>{},onAuthenticated:()=>{}};var Wn=class{constructor(s,i,l){this._ua=s,this._eventHandlers=l,this._method=i.method,this._request=i,this._auth=null,this._challenged=!1,this._staled=!1;for(const a in nu)Object.prototype.hasOwnProperty.call(nu,a)&&(this._eventHandlers[a]||(this._eventHandlers[a]=nu[a]));s.status===s.C.STATUS_USER_CLOSED&&(this._method!==Lf.BYE||this._method!==Lf.ACK)&&this._eventHandlers.onTransportError()}send(){const s={onRequestTimeout:()=>{this._eventHandlers.onRequestTimeout()},onTransportError:()=>{this._eventHandlers.onTransportError()},onReceiveResponse:i=>{this._receiveResponse(i)}};switch(this._method){case"INVITE":this.clientTransaction=new su.InviteClientTransaction(this._ua,this._ua.transport,this._request,s);break;case"ACK":this.clientTransaction=new su.AckClientTransaction(this._ua,this._ua.transport,this._request,s);break;default:this.clientTransaction=new su.NonInviteClientTransaction(this._ua,this._ua.transport,this._request,s)}this._ua._configuration.authorization_jwt&&this._request.setHeader("Authorization",this._ua._configuration.authorization_jwt),this.clientTransaction.send()}_receiveResponse(s){let i,l;const a=s.status_code;if((a===401||a===407)&&(this._ua.configuration.password!==null||this._ua.configuration.ha1!==null)){if(s.status_code===401?(i=s.parseHeader("www-authenticate"),l="authorization"):(i=s.parseHeader("proxy-authenticate"),l="proxy-authorization"),!i){Hm.debug(`${s.status_code} with wrong or missing challenge, cannot authenticate`),this._eventHandlers.onReceiveResponse(s);return}if(!this._challenged||!this._staled&&i.stale===!0){if(this._auth||(this._auth=new $m({username:this._ua.configuration.authorization_user,password:this._ua.configuration.password,realm:this._ua.configuration.realm,ha1:this._ua.configuration.ha1})),!this._auth.authenticate(this._request,i)){this._eventHandlers.onReceiveResponse(s);return}this._challenged=!0,this._ua.set("realm",this._auth.get("realm")),this._ua.set("ha1",this._auth.get("ha1")),i.stale&&(this._staled=!0),this._request=this._request.clone(),this._request.cseq+=1,this._request.setHeader("cseq",`${this._request.cseq} ${this._method}`),this._request.setHeader(l,this._auth.toString()),this._eventHandlers.onAuthenticated(this._request),this.send()}else this._eventHandlers.onReceiveResponse(s)}else this._eventHandlers.onReceiveResponse(s)}};const ra=Le(Wn),Fm=ut,ru=Tt(),cn=xe,$f=bt,Hf=Wn,Hr=new Fm("Registrator"),ia=10;var jm=class{constructor(s,i){this._reg_id=1,this._ua=s,this._transport=i,this._registrar=s.configuration.registrar_server,this._expires=s.configuration.register_expires,this._call_id=ru.createRandomToken(22),this._cseq=0,this._to_uri=s.configuration.uri,this._registrationTimer=null,this._registering=!1,this._registered=!1,this._contact=this._ua.contact.toString(),this._extraContactParams+=";+sip.ice",this._extraHeaders=[],this._sipInstance=`"<urn:uuid:${this._ua.configuration.instance_id}>"`,this._extraContactParams+=`;reg-id=${this._reg_id}`,this._extraContactParams+=`;+sip.instance=${this._sipInstance}`}get registered(){return this._registered}setExtraHeaders(s){Array.isArray(s)||(s=[]),this._extraHeaders=s.slice()}setExtraContactParams(s){s instanceof Object||(s={}),this._extraContactParams="";for(const i in s)if(Object.prototype.hasOwnProperty.call(s,i)){const l=s[i];this._extraContactParams+=`;${i}`,l&&(this._extraContactParams+=`=${l}`)}}register(){if(this._registering){Hr.debug("Register request in progress...");return}const s=this._extraHeaders.slice();s.push(`Contact: ${this._contact};expires=${this._expires}${this._extraContactParams}`),s.push(`Expires: ${this._expires}`);const i=new $f.OutgoingRequest(cn.REGISTER,this._registrar,this._ua,{to_uri:this._to_uri,call_id:this._call_id,cseq:this._cseq+=1},s),l=new Hf(this._ua,i,{onRequestTimeout:()=>{this._registrationFailure(null,cn.causes.REQUEST_TIMEOUT)},onTransportError:()=>{this._registrationFailure(null,cn.causes.CONNECTION_ERROR)},onAuthenticated:()=>{this._cseq+=1},onReceiveResponse:a=>{if(a.cseq===this._cseq)switch(this._registrationTimer!==null&&(clearTimeout(this._registrationTimer),this._registrationTimer=null),!0){case/^1[0-9]{2}$/.test(a.status_code):break;case/^2[0-9]{2}$/.test(a.status_code):{if(this._registering=!1,!a.hasHeader("Contact")){Hr.debug("no Contact header in response to REGISTER, response ignored");break}const _=a.headers.Contact.reduce((n,v)=>n.concat(v.parsed),[]);let e=_.find(n=>this._sipInstance===n.getParam("+sip.instance")&&this._reg_id===parseInt(n.getParam("reg-id")));if(e||(e=_.find(n=>n.uri.user===this._ua.contact.uri.user)),!e){Hr.debug("no Contact header pointing to us, response ignored");break}let p=e.getParam("expires");!p&&a.hasHeader("expires")&&(p=a.getHeader("expires")),p||(p=this._expires),p=Number(p),p<ia&&(p=ia);const g=p>64?p*1e3/2+Math.floor((p/2-32)*1e3*Math.random()):p*1e3-5e3;this._registrationTimer=setTimeout(()=>{this._registrationTimer=null,this._ua.listeners("registrationExpiring").length===0?this.register():this._ua.emit("registrationExpiring")},g),e.hasParam("temp-gruu")&&(this._ua.contact.temp_gruu=e.getParam("temp-gruu").replace(/"/g,"")),e.hasParam("pub-gruu")&&(this._ua.contact.pub_gruu=e.getParam("pub-gruu").replace(/"/g,"")),this._registered||(this._registered=!0,this._ua.registered({response:a}));break}case/^423$/.test(a.status_code):{a.hasHeader("min-expires")?(this._expires=Number(a.getHeader("min-expires")),this._expires<ia&&(this._expires=ia),this.register()):(Hr.debug("423 response received for REGISTER without Min-Expires"),this._registrationFailure(a,cn.causes.SIP_FAILURE_CODE));break}default:{const _=ru.sipErrorCause(a.status_code);this._registrationFailure(a,_)}}}});this._registering=!0,l.send()}unregister(s={}){if(!this._registered){Hr.debug("already unregistered");return}this._registered=!1,this._registrationTimer!==null&&(clearTimeout(this._registrationTimer),this._registrationTimer=null);const i=this._extraHeaders.slice();s.all?i.push(`Contact: *${this._extraContactParams}`):i.push(`Contact: ${this._contact};expires=0${this._extraContactParams}`),i.push("Expires: 0");const l=new $f.OutgoingRequest(cn.REGISTER,this._registrar,this._ua,{to_uri:this._to_uri,call_id:this._call_id,cseq:this._cseq+=1},i);new Hf(this._ua,l,{onRequestTimeout:()=>{this._unregistered(null,cn.causes.REQUEST_TIMEOUT)},onTransportError:()=>{this._unregistered(null,cn.causes.CONNECTION_ERROR)},onAuthenticated:()=>{this._cseq+=1},onReceiveResponse:_=>{switch(!0){case/^1[0-9]{2}$/.test(_.status_code):break;case/^2[0-9]{2}$/.test(_.status_code):this._unregistered(_);break;default:{const e=ru.sipErrorCause(_.status_code);this._unregistered(_,e)}}}}).send()}close(){this._registered&&this.unregister()}onTransportClosed(){this._registering=!1,this._registrationTimer!==null&&(clearTimeout(this._registrationTimer),this._registrationTimer=null),this._registered&&(this._registered=!1,this._ua.unregistered({}))}_registrationFailure(s,i){this._registering=!1,this._ua.registrationFailed({response:s||null,cause:i}),this._registered&&(this._registered=!1,this._ua.unregistered({response:s||null,cause:i}))}_unregistered(s,i){this._registering=!1,this._registered=!1,this._ua.unregistered({response:s||null,cause:i||null})}};class qm extends Error{constructor(s,i){super(),this.code=1,this.name="CONFIGURATION_ERROR",this.parameter=s,this.value=i,this.message=this.value?`Invalid value ${JSON.stringify(this.value)} for parameter "${this.parameter}"`:`Missing parameter: ${this.parameter}`}}class Vm extends Error{constructor(s){super(),this.code=2,this.name="INVALID_STATE_ERROR",this.status=s,this.message=`Invalid status: ${s}`}}class Bm extends Error{constructor(s){super(),this.code=3,this.name="NOT_SUPPORTED_ERROR",this.message=s}}class Gm extends Error{constructor(s){super(),this.code=4,this.name="NOT_READY_ERROR",this.message=s}}var gs={ConfigurationError:qm,InvalidStateError:Vm,NotSupportedError:Bm,NotReadyError:Gm};const Ps=Le(gs),iu=xe,la=Gn,Wm=Wn,lu={onRequestTimeout:()=>{},onTransportError:()=>{},onSuccessResponse:()=>{},onErrorResponse:()=>{},onAuthenticated:()=>{},onDialogError:()=>{}};var Ff=class{constructor(s,i,l){this._dialog=s,this._ua=s._ua,this._request=i,this._eventHandlers=l,this._reattempt=!1,this._reattemptTimer=null;for(const a in lu)Object.prototype.hasOwnProperty.call(lu,a)&&(this._eventHandlers[a]||(this._eventHandlers[a]=lu[a]))}get request(){return this._request}send(){const s=new Wm(this._ua,this._request,{onRequestTimeout:()=>{this._eventHandlers.onRequestTimeout()},onTransportError:()=>{this._eventHandlers.onTransportError()},onAuthenticated:i=>{this._eventHandlers.onAuthenticated(i)},onReceiveResponse:i=>{this._receiveResponse(i)}});if(s.send(),(this._request.method===iu.INVITE||this._request.method===iu.UPDATE&&this._request.body)&&s.clientTransaction.state!==la.C.STATUS_TERMINATED){this._dialog.uac_pending_reply=!0;const i=()=>{(s.clientTransaction.state===la.C.STATUS_ACCEPTED||s.clientTransaction.state===la.C.STATUS_COMPLETED||s.clientTransaction.state===la.C.STATUS_TERMINATED)&&(s.clientTransaction.removeListener("stateChanged",i),this._dialog.uac_pending_reply=!1)};s.clientTransaction.on("stateChanged",i)}}_receiveResponse(s){s.status_code===408||s.status_code===481?this._eventHandlers.onDialogError(s):s.method===iu.INVITE&&s.status_code===491?this._reattempt?s.status_code>=200&&s.status_code<300?this._eventHandlers.onSuccessResponse(s):s.status_code>=300&&this._eventHandlers.onErrorResponse(s):(this._request.cseq=this._dialog.local_seqnum+=1,this._reattemptTimer=setTimeout(()=>{this._dialog.isTerminated()||(this._reattempt=!0,this.send())},1e3)):s.status_code>=200&&s.status_code<300?this._eventHandlers.onSuccessResponse(s):s.status_code>=300&&this._eventHandlers.onErrorResponse(s)}};const Km=Le(Ff),Ym=ut,jf=bt,xs=xe,Fr=Gn,Jm=Ff,au=Tt(),ou=new Ym("Dialog"),Ms={STATUS_EARLY:1,STATUS_CONFIRMED:2,STATUS_TERMINATED:3};var qf=class{static get C(){return Ms}constructor(s,i,l,a=Ms.STATUS_CONFIRMED){if(this._owner=s,this._ua=s._ua,this._uac_pending_reply=!1,this._uas_pending_reply=!1,!i.hasHeader("contact"))return{error:"unable to create a Dialog without Contact header field"};i instanceof jf.IncomingResponse&&(a=i.status_code<200?Ms.STATUS_EARLY:Ms.STATUS_CONFIRMED);const _=i.parseHeader("contact");l==="UAS"?(this._id={call_id:i.call_id,local_tag:i.to_tag,remote_tag:i.from_tag,toString(){return this.call_id+this.local_tag+this.remote_tag}},this._state=a,this._remote_seqnum=i.cseq,this._local_uri=i.parseHeader("to").uri,this._remote_uri=i.parseHeader("from").uri,this._remote_target=_.uri,this._route_set=i.getHeaders("record-route"),this._ack_seqnum=this._remote_seqnum):l==="UAC"&&(this._id={call_id:i.call_id,local_tag:i.from_tag,remote_tag:i.to_tag,toString(){return this.call_id+this.local_tag+this.remote_tag}},this._state=a,this._local_seqnum=i.cseq,this._local_uri=i.parseHeader("from").uri,this._remote_uri=i.parseHeader("to").uri,this._remote_target=_.uri,this._route_set=i.getHeaders("record-route").reverse(),this._ack_seqnum=null),this._ua.newDialog(this),ou.debug(`new ${l} dialog created with status ${this._state===Ms.STATUS_EARLY?"EARLY":"CONFIRMED"}`)}get id(){return this._id}get local_seqnum(){return this._local_seqnum}set local_seqnum(s){this._local_seqnum=s}get owner(){return this._owner}get uac_pending_reply(){return this._uac_pending_reply}set uac_pending_reply(s){this._uac_pending_reply=s}get uas_pending_reply(){return this._uas_pending_reply}isTerminated(){return this._status===Ms.STATUS_TERMINATED}update(s,i){this._state=Ms.STATUS_CONFIRMED,ou.debug(`dialog ${this._id.toString()} changed to CONFIRMED state`),i==="UAC"&&(this._route_set=s.getHeaders("record-route").reverse())}terminate(){ou.debug(`dialog ${this._id.toString()} deleted`),this._ua.destroyDialog(this),this._state=Ms.STATUS_TERMINATED}sendRequest(s,i={}){const l=au.cloneArray(i.extraHeaders),a=au.cloneObject(i.eventHandlers),_=i.body||null,e=this._createRequest(s,l,_);return a.onAuthenticated=()=>{this._local_seqnum+=1},new Jm(this,e,a).send(),e}receiveRequest(s){this._checkInDialogRequest(s)&&(s.method===xs.ACK&&this._ack_seqnum!==null?this._ack_seqnum=null:s.method===xs.INVITE&&(this._ack_seqnum=s.cseq),this._owner.receiveRequest(s))}_createRequest(s,i,l){i=au.cloneArray(i),this._local_seqnum||(this._local_seqnum=Math.floor(Math.random()*1e4));const a=s===xs.CANCEL||s===xs.ACK?this._local_seqnum:this._local_seqnum+=1;return new jf.OutgoingRequest(s,this._remote_target,this._ua,{cseq:a,call_id:this._id.call_id,from_uri:this._local_uri,from_tag:this._id.local_tag,to_uri:this._remote_uri,to_tag:this._id.remote_tag,route_set:this._route_set},i,l)}_checkInDialogRequest(s){if(!this._remote_seqnum)this._remote_seqnum=s.cseq;else if(s.cseq<this._remote_seqnum)if(s.method===xs.ACK){if(this._ack_seqnum===null||s.cseq!==this._ack_seqnum)return!1}else return s.reply(500),!1;else s.cseq>this._remote_seqnum&&(this._remote_seqnum=s.cseq);if(s.method===xs.INVITE||s.method===xs.UPDATE&&s.body){if(this._uac_pending_reply===!0)s.reply(491);else if(this._uas_pending_reply===!0){const i=(Math.random()*10|0)+1;return s.reply(500,null,[`Retry-After:${i}`]),!1}else{this._uas_pending_reply=!0;const i=()=>{(s.server_transaction.state===Fr.C.STATUS_ACCEPTED||s.server_transaction.state===Fr.C.STATUS_COMPLETED||s.server_transaction.state===Fr.C.STATUS_TERMINATED)&&(s.server_transaction.removeListener("stateChanged",i),this._uas_pending_reply=!1)};s.server_transaction.on("stateChanged",i)}s.hasHeader("contact")&&s.server_transaction.on("stateChanged",()=>{s.server_transaction.state===Fr.C.STATUS_ACCEPTED&&(this._remote_target=s.parseHeader("contact").uri)})}else s.method===xs.NOTIFY&&s.hasHeader("contact")&&s.server_transaction.on("stateChanged",()=>{s.server_transaction.state===Fr.C.STATUS_COMPLETED&&(this._remote_target=s.parseHeader("contact").uri)});return!0}};const aa=Le(qf);var uu={exports:{}};const zm=ct.EventEmitter,Xm=ut,Qm=xe,Zm=gs,Vf=Tt(),eg=new Xm("RTCSession:DTMF"),Bf={MIN_DURATION:70,MAX_DURATION:6e3,DEFAULT_DURATION:100,MIN_INTER_TONE_GAP:50,DEFAULT_INTER_TONE_GAP:500};uu.exports=class extends zm{constructor(s){super(),this._session=s,this._direction=null,this._tone=null,this._duration=null,this._request=null}get tone(){return this._tone}get duration(){return this._duration}send(s,i={}){if(s===void 0)throw new TypeError("Not enough arguments");if(this._direction="outgoing",this._session.status!==this._session.C.STATUS_CONFIRMED&&this._session.status!==this._session.C.STATUS_WAITING_FOR_ACK)throw new Zm.InvalidStateError(this._session.status);const l=Vf.cloneArray(i.extraHeaders);if(this.eventHandlers=Vf.cloneObject(i.eventHandlers),typeof s=="string")s=s.toUpperCase();else if(typeof s=="number")s=s.toString();else throw new TypeError(`Invalid tone: ${s}`);if(s.match(/^[0-9A-DR#*]$/))this._tone=s;else throw new TypeError(`Invalid tone: ${s}`);this._duration=i.duration,l.push("Content-Type: application/dtmf-relay");let a=`Signal=${this._tone}\r
|
113
|
+
`;a+=`Duration=${this._duration}`,this._session.newDTMF({originator:"local",dtmf:this,request:this._request}),this._session.sendRequest(Qm.INFO,{extraHeaders:l,eventHandlers:{onSuccessResponse:_=>{this.emit("succeeded",{originator:"remote",response:_})},onErrorResponse:_=>{this.eventHandlers.onFailed&&this.eventHandlers.onFailed(),this.emit("failed",{originator:"remote",response:_})},onRequestTimeout:()=>{this._session.onRequestTimeout()},onTransportError:()=>{this._session.onTransportError()},onDialogError:()=>{this._session.onDialogError()}},body:a})}init_incoming(s){const i=/^(Signal\s*?=\s*?)([0-9A-D#*]{1})(\s)?.*/,l=/^(Duration\s?=\s?)([0-9]{1,4})(\s)?.*/;if(this._direction="incoming",this._request=s,s.reply(200),s.body){const a=s.body.split(`
|
114
|
+
`);a.length>=1&&i.test(a[0])&&(this._tone=a[0].replace(i,"$2")),a.length>=2&&l.test(a[1])&&(this._duration=parseInt(a[1].replace(l,"$2"),10))}this._duration||(this._duration=Bf.DEFAULT_DURATION),this._tone?this._session.newDTMF({originator:"remote",dtmf:this,request:s}):eg.debug("invalid INFO DTMF received, discarded")}},uu.exports.C=Bf;var Gf=uu.exports;const tg=Le(Gf),sg=ct.EventEmitter,ng=xe,rg=gs,ig=Tt();var Wf=class extends sg{constructor(s){super(),this._session=s,this._direction=null,this._contentType=null,this._body=null}get contentType(){return this._contentType}get body(){return this._body}send(s,i,l={}){if(this._direction="outgoing",s===void 0)throw new TypeError("Not enough arguments");if(this._session.status!==this._session.C.STATUS_CONFIRMED&&this._session.status!==this._session.C.STATUS_WAITING_FOR_ACK)throw new rg.InvalidStateError(this._session.status);this._contentType=s,this._body=i;const a=ig.cloneArray(l.extraHeaders);a.push(`Content-Type: ${s}`),this._session.newInfo({originator:"local",info:this,request:this.request}),this._session.sendRequest(ng.INFO,{extraHeaders:a,eventHandlers:{onSuccessResponse:_=>{this.emit("succeeded",{originator:"remote",response:_})},onErrorResponse:_=>{this.emit("failed",{originator:"remote",response:_})},onTransportError:()=>{this._session.onTransportError()},onRequestTimeout:()=>{this._session.onRequestTimeout()},onDialogError:()=>{this._session.onDialogError()}},body:i})}init_incoming(s){this._direction="incoming",this.request=s,s.reply(200),this._contentType=s.hasHeader("Content-Type")?s.getHeader("Content-Type").toLowerCase():void 0,this._body=s.body,this._session.newInfo({originator:"remote",info:this,request:s})}};const cu=Le(Wf),lg=ut,Kf=xe,ag=new lg("RTCSession:ReferNotifier"),fu={event_type:"refer",body_type:"message/sipfrag;version=2.0",expires:300};var Yf=class{constructor(s,i,l){this._session=s,this._id=i,this._expires=l||fu.expires,this._active=!0,this.notify(100)}notify(s,i){if(ag.debug("notify()"),this._active===!1)return;i=i||Kf.REASON_PHRASE[s]||"";let l;s>=200?l="terminated;reason=noresource":l=`active;expires=${this._expires}`,this._session.sendRequest(Kf.NOTIFY,{extraHeaders:[`Event: ${fu.event_type};id=${this._id}`,`Subscription-State: ${l}`,`Content-Type: ${fu.body_type}`],body:`SIP/2.0 ${s} ${i}`,eventHandlers:{onErrorResponse(){this._active=!1}}})}};const og=Le(Yf),ug=ct.EventEmitter,cg=ut,jr=xe,fg=Gt(),Jf=Tt(),fn=new cg("RTCSession:ReferSubscriber");var zf=class extends ug{constructor(s){super(),this._id=null,this._session=s}get id(){return this._id}sendRefer(s,i={}){fn.debug("sendRefer()");const l=Jf.cloneArray(i.extraHeaders),a=Jf.cloneObject(i.eventHandlers);for(const g in a)Object.prototype.hasOwnProperty.call(a,g)&&this.on(g,a[g]);let _=null;i.replaces&&(_=i.replaces._request.call_id,_+=`;to-tag=${i.replaces._to_tag}`,_+=`;from-tag=${i.replaces._from_tag}`,_=encodeURIComponent(_));const e=`Refer-To: <${s}${_?`?Replaces=${_}`:""}>`;if(l.push(e),!l.some(g=>g.toLowerCase().startsWith("referred-by:"))){const g=`Referred-By: <${this._session._ua._configuration.uri._scheme}:${this._session._ua._configuration.uri._user}@${this._session._ua._configuration.uri._host}>`;l.push(g)}l.push(`Contact: ${this._session.contact}`);const p=this._session.sendRequest(jr.REFER,{extraHeaders:l,eventHandlers:{onSuccessResponse:g=>{this._requestSucceeded(g)},onErrorResponse:g=>{this._requestFailed(g,jr.causes.REJECTED)},onTransportError:()=>{this._requestFailed(null,jr.causes.CONNECTION_ERROR)},onRequestTimeout:()=>{this._requestFailed(null,jr.causes.REQUEST_TIMEOUT)},onDialogError:()=>{this._requestFailed(null,jr.causes.DIALOG_ERROR)}}});this._id=p.cseq}receiveNotify(s){if(fn.debug("receiveNotify()"),!s.body)return;const i=fg.parse(s.body.trim().split(`\r
|
115
|
+
`,1)[0],"Status_Line");if(i===-1){fn.debug(`receiveNotify() | error parsing NOTIFY body: "${s.body}"`);return}switch(!0){case/^100$/.test(i.status_code):this.emit("trying",{request:s,status_line:i});break;case/^1[0-9]{2}$/.test(i.status_code):this.emit("progress",{request:s,status_line:i});break;case/^2[0-9]{2}$/.test(i.status_code):this.emit("accepted",{request:s,status_line:i});break;default:this.emit("failed",{request:s,status_line:i});break}}_requestSucceeded(s){fn.debug("REFER succeeded"),fn.debug('emit "requestSucceeded"'),this.emit("requestSucceeded",{response:s})}_requestFailed(s,i){fn.debug("REFER failed"),fn.debug('emit "requestFailed"'),this.emit("requestFailed",{response:s||null,cause:i})}};const _g=Le(zf),hg=ct.EventEmitter,Xf=xt,dg=ut,_e=xe,_n=gs,Qf=Gn,ze=Tt(),qr=tu,pg=bt,oa=qf,mg=Wn,$t=Gf,Zf=Wf,gg=Yf,Tg=zf,e_=ds(),J=new dg("RTCSession"),te={STATUS_NULL:0,STATUS_INVITE_SENT:1,STATUS_1XX_RECEIVED:2,STATUS_INVITE_RECEIVED:3,STATUS_WAITING_FOR_ANSWER:4,STATUS_ANSWERED:5,STATUS_WAITING_FOR_ACK:6,STATUS_CANCELED:7,STATUS_TERMINATED:8,STATUS_CONFIRMED:9},ua=["audio","video"];var t_=class Wu extends hg{static get C(){return te}constructor(s){J.debug("new"),super(),this._id=null,this._ua=s,this._status=te.STATUS_NULL,this._dialog=null,this._earlyDialogs={},this._contact=null,this._from_tag=null,this._to_tag=null,this._connection=null,this._connectionPromiseQueue=Promise.resolve(),this._request=null,this._is_canceled=!1,this._cancel_reason="",this._is_confirmed=!1,this._late_sdp=!1,this._rtcOfferConstraints=null,this._rtcAnswerConstraints=null,this._localMediaStream=null,this._localMediaStreamLocallyGenerated=!1,this._rtcReady=!0,this._iceReady=!1,this._timers={ackTimer:null,expiresTimer:null,invite2xxTimer:null,userNoAnswerTimer:null},this._direction=null,this._local_identity=null,this._remote_identity=null,this._start_time=null,this._end_time=null,this._tones=null,this._audioMuted=!1,this._videoMuted=!1,this._localHold=!1,this._remoteHold=!1,this._sessionTimers={enabled:this._ua.configuration.session_timers,refreshMethod:this._ua.configuration.session_timers_refresh_method,defaultExpires:_e.SESSION_EXPIRES,currentExpires:null,running:!1,refresher:!1,timer:null},this._referSubscribers={},this._data={}}get C(){return te}get causes(){return _e.causes}get id(){return this._id}get connection(){return this._connection}get contact(){return this._contact}get direction(){return this._direction}get local_identity(){return this._local_identity}get remote_identity(){return this._remote_identity}get start_time(){return this._start_time}get end_time(){return this._end_time}get data(){return this._data}set data(s){this._data=s}get status(){return this._status}isInProgress(){switch(this._status){case te.STATUS_NULL:case te.STATUS_INVITE_SENT:case te.STATUS_1XX_RECEIVED:case te.STATUS_INVITE_RECEIVED:case te.STATUS_WAITING_FOR_ANSWER:return!0;default:return!1}}isEstablished(){switch(this._status){case te.STATUS_ANSWERED:case te.STATUS_WAITING_FOR_ACK:case te.STATUS_CONFIRMED:return!0;default:return!1}}isEnded(){switch(this._status){case te.STATUS_CANCELED:case te.STATUS_TERMINATED:return!0;default:return!1}}isMuted(){return{audio:this._audioMuted,video:this._videoMuted}}isOnHold(){return{local:this._localHold,remote:this._remoteHold}}connect(s,i={},l){J.debug("connect()");const a=s,_=ze.cloneObject(i.eventHandlers),e=ze.cloneArray(i.extraHeaders),p=ze.cloneObject(i.mediaConstraints,{audio:!0,video:!0}),g=i.mediaStream||null,n=ze.cloneObject(i.pcConfig,{iceServers:[]}),v=i.rtcConstraints||null,S=i.rtcOfferConstraints||null;if(this._rtcOfferConstraints=S,this._rtcAnswerConstraints=i.rtcAnswerConstraints||null,this._data=i.data||this._data,s===void 0)throw new TypeError("Not enough arguments");if(this._status!==te.STATUS_NULL)throw new _n.InvalidStateError(this._status);if(!window.RTCPeerConnection)throw new _n.NotSupportedError("WebRTC not supported");if(s=this._ua.normalizeTarget(s),!s)throw new TypeError(`Invalid target: ${a}`);this._sessionTimers.enabled&&ze.isDecimal(i.sessionTimersExpires)&&(i.sessionTimersExpires>=_e.MIN_SESSION_EXPIRES?this._sessionTimers.defaultExpires=i.sessionTimersExpires:this._sessionTimers.defaultExpires=_e.SESSION_EXPIRES);for(const A in _)Object.prototype.hasOwnProperty.call(_,A)&&this.on(A,_[A]);this._from_tag=ze.newTag();const m=i.anonymous||!1,C={from_tag:this._from_tag};this._contact=this._ua.contact.toString({anonymous:m,outbound:!0}),m?(C.from_display_name="Anonymous",C.from_uri=new e_("sip","anonymous","anonymous.invalid"),e.push(`P-Preferred-Identity: ${this._ua.configuration.uri.toString()}`),e.push("Privacy: id")):i.fromUserName&&(C.from_uri=new e_("sip",i.fromUserName,this._ua.configuration.uri.host),e.push(`P-Preferred-Identity: ${this._ua.configuration.uri.toString()}`)),i.fromDisplayName&&(C.from_display_name=i.fromDisplayName),e.push(`Contact: ${this._contact}`),e.push("Content-Type: application/sdp"),this._sessionTimers.enabled&&e.push(`Session-Expires: ${this._sessionTimers.defaultExpires}${this._ua.configuration.session_timers_force_refresher?";refresher=uac":""}`),this._request=new pg.InitialOutgoingInviteRequest(s,this._ua,C,e),this._id=this._request.call_id+this._from_tag,this._createRTCConnection(n,v),this._direction="outgoing",this._local_identity=this._request.from,this._remote_identity=this._request.to,l&&l(this),this._newRTCSession("local",this._request),this._sendInitialRequest(p,S,g)}init_incoming(s,i){J.debug("init_incoming()");let l;const a=s.hasHeader("Content-Type")?s.getHeader("Content-Type").toLowerCase():void 0;if(s.body&&a!=="application/sdp"){s.reply(415);return}if(this._status=te.STATUS_INVITE_RECEIVED,this._from_tag=s.from_tag,this._id=s.call_id+this._from_tag,this._request=s,this._contact=this._ua.contact.toString(),s.hasHeader("expires")&&(l=s.getHeader("expires")*1e3),s.to_tag=ze.newTag(),!this._createDialog(s,"UAS",!0)){s.reply(500,"Missing Contact header field");return}s.body?this._late_sdp=!1:this._late_sdp=!0,this._status=te.STATUS_WAITING_FOR_ANSWER,this._timers.userNoAnswerTimer=setTimeout(()=>{s.reply(408),this._failed("local",null,_e.causes.NO_ANSWER)},this._ua.configuration.no_answer_timeout),l&&(this._timers.expiresTimer=setTimeout(()=>{this._status===te.STATUS_WAITING_FOR_ANSWER&&(s.reply(487),this._failed("system",null,_e.causes.EXPIRES))},l)),this._direction="incoming",this._local_identity=s.to,this._remote_identity=s.from,i&&i(this),this._newRTCSession("remote",s),this._status!==te.STATUS_TERMINATED&&(s.reply(180,null,[`Contact: ${this._contact}`]),this._progress("local",null))}answer(s={}){J.debug("answer()");const i=this._request,l=ze.cloneArray(s.extraHeaders),a=ze.cloneObject(s.mediaConstraints),_=s.mediaStream||null,e=ze.cloneObject(s.pcConfig,{iceServers:[]}),p=s.rtcConstraints||null,g=s.rtcAnswerConstraints||null,n=ze.cloneObject(s.rtcOfferConstraints);let v,S=!1,m=!1,C=!1,A=!1;if(this._rtcAnswerConstraints=g,this._rtcOfferConstraints=s.rtcOfferConstraints||null,this._data=s.data||this._data,this._direction!=="incoming")throw new _n.NotSupportedError('"answer" not supported for outgoing RTCSession');if(this._status!==te.STATUS_WAITING_FOR_ANSWER)throw new _n.InvalidStateError(this._status);if(this._sessionTimers.enabled&&ze.isDecimal(s.sessionTimersExpires)&&(s.sessionTimersExpires>=_e.MIN_SESSION_EXPIRES?this._sessionTimers.defaultExpires=s.sessionTimersExpires:this._sessionTimers.defaultExpires=_e.SESSION_EXPIRES),this._status=te.STATUS_ANSWERED,!this._createDialog(i,"UAS")){i.reply(500,"Error creating dialog");return}clearTimeout(this._timers.userNoAnswerTimer),l.unshift(`Contact: ${this._contact}`);const R=i.parseSDP();Array.isArray(R.media)||(R.media=[R.media]);for(const I of R.media)I.type==="audio"&&(S=!0,(!I.direction||I.direction==="sendrecv")&&(C=!0)),I.type==="video"&&(m=!0,(!I.direction||I.direction==="sendrecv")&&(A=!0));if(_&&a.audio===!1){v=_.getAudioTracks();for(const I of v)_.removeTrack(I)}if(_&&a.video===!1){v=_.getVideoTracks();for(const I of v)_.removeTrack(I)}!_&&a.audio===void 0&&(a.audio=C),!_&&a.video===void 0&&(a.video=A),!_&&!S&&!n.offerToReceiveAudio&&(a.audio=!1),!_&&!m&&!n.offerToReceiveVideo&&(a.video=!1),this._createRTCConnection(e,p),Promise.resolve().then(()=>{if(_)return _;if(a.audio||a.video)return this._localMediaStreamLocallyGenerated=!0,navigator.mediaDevices.getUserMedia(a).catch(I=>{throw this._status===te.STATUS_TERMINATED?new Error("terminated"):(i.reply(480),this._failed("local",null,_e.causes.USER_DENIED_MEDIA_ACCESS),J.warn('emit "getusermediafailed" [error:%o]',I),this.emit("getusermediafailed",I),new Error("getUserMedia() failed"))})}).then(I=>{if(this._status===te.STATUS_TERMINATED)throw new Error("terminated");this._localMediaStream=I,I&&I.getTracks().forEach(V=>{this._connection.addTrack(V,I)})}).then(()=>{if(this._late_sdp)return;const I={originator:"remote",type:"offer",sdp:i.body};J.debug('emit "sdp"'),this.emit("sdp",I);const V=new RTCSessionDescription({type:"offer",sdp:I.sdp});return this._connectionPromiseQueue=this._connectionPromiseQueue.then(()=>this._connection.setRemoteDescription(V)).catch(W=>{throw i.reply(488),this._failed("system",null,_e.causes.WEBRTC_ERROR),J.warn('emit "peerconnection:setremotedescriptionfailed" [error:%o]',W),this.emit("peerconnection:setremotedescriptionfailed",W),new Error("peerconnection.setRemoteDescription() failed")}),this._connectionPromiseQueue}).then(()=>{if(this._status===te.STATUS_TERMINATED)throw new Error("terminated");return this._connecting(i),this._late_sdp?this._createLocalDescription("offer",this._rtcOfferConstraints).catch(()=>{throw i.reply(500),new Error("_createLocalDescription() failed")}):this._createLocalDescription("answer",g).catch(()=>{throw i.reply(500),new Error("_createLocalDescription() failed")})}).then(I=>{if(this._status===te.STATUS_TERMINATED)throw new Error("terminated");this._handleSessionTimersInIncomingRequest(i,l),i.reply(200,null,l,I,()=>{this._status=te.STATUS_WAITING_FOR_ACK,this._setInvite2xxTimer(i,I),this._setACKTimer(),this._accepted("local")},()=>{this._failed("system",null,_e.causes.CONNECTION_ERROR)})}).catch(I=>{this._status!==te.STATUS_TERMINATED&&J.warn(I)})}terminate(s={}){J.debug("terminate()");const i=s.cause||_e.causes.BYE,l=ze.cloneArray(s.extraHeaders),a=s.body;let _,e=s.status_code,p=s.reason_phrase;if(this._status===te.STATUS_TERMINATED)throw new _n.InvalidStateError(this._status);switch(this._status){case te.STATUS_NULL:case te.STATUS_INVITE_SENT:case te.STATUS_1XX_RECEIVED:if(J.debug("canceling session"),e&&(e<200||e>=700))throw new TypeError(`Invalid status_code: ${e}`);e&&(p=p||_e.REASON_PHRASE[e]||"",_=`SIP ;cause=${e} ;text="${p}"`),this._status===te.STATUS_NULL||this._status===te.STATUS_INVITE_SENT?(this._is_canceled=!0,this._cancel_reason=_):this._status===te.STATUS_1XX_RECEIVED&&this._request.cancel(_),this._status=te.STATUS_CANCELED,this._failed("local",null,_e.causes.CANCELED);break;case te.STATUS_WAITING_FOR_ANSWER:case te.STATUS_ANSWERED:if(J.debug("rejecting session"),e=e||480,e<300||e>=700)throw new TypeError(`Invalid status_code: ${e}`);this._request.reply(e,p,l,a),this._failed("local",null,_e.causes.REJECTED);break;case te.STATUS_WAITING_FOR_ACK:case te.STATUS_CONFIRMED:if(J.debug("terminating session"),p=s.reason_phrase||_e.REASON_PHRASE[e]||"",e&&(e<200||e>=700))throw new TypeError(`Invalid status_code: ${e}`);if(e&&l.push(`Reason: SIP ;cause=${e}; text="${p}"`),this._status===te.STATUS_WAITING_FOR_ACK&&this._direction==="incoming"&&this._request.server_transaction.state!==Qf.C.STATUS_TERMINATED){const g=this._dialog;this.receiveRequest=({method:n})=>{n===_e.ACK&&(this.sendRequest(_e.BYE,{extraHeaders:l,body:a}),g.terminate())},this._request.server_transaction.on("stateChanged",()=>{this._request.server_transaction.state===Qf.C.STATUS_TERMINATED&&(this.sendRequest(_e.BYE,{extraHeaders:l,body:a}),g.terminate())}),this._ended("local",null,i),this._dialog=g,this._ua.newDialog(g)}else this.sendRequest(_e.BYE,{extraHeaders:l,body:a}),this._ended("local",null,i)}}sendDTMF(s,i={}){J.debug("sendDTMF() | tones: %s",s);let l=0,a=i.duration||null,_=i.interToneGap||null;const e=i.transportType||_e.DTMF_TRANSPORT.INFO;if(s===void 0)throw new TypeError("Not enough arguments");if(this._status!==te.STATUS_CONFIRMED&&this._status!==te.STATUS_WAITING_FOR_ACK&&this._status!==te.STATUS_1XX_RECEIVED)throw new _n.InvalidStateError(this._status);if(e!==_e.DTMF_TRANSPORT.INFO&&e!==_e.DTMF_TRANSPORT.RFC2833)throw new TypeError(`invalid transportType: ${e}`);if(typeof s=="number"&&(s=s.toString()),!s||typeof s!="string"||!s.match(/^[0-9A-DR#*,]+$/i))throw new TypeError(`Invalid tones: ${s}`);if(a&&!ze.isDecimal(a))throw new TypeError(`Invalid tone duration: ${a}`);if(a?a<$t.C.MIN_DURATION?(J.debug(`"duration" value is lower than the minimum allowed, setting it to ${$t.C.MIN_DURATION} milliseconds`),a=$t.C.MIN_DURATION):a>$t.C.MAX_DURATION?(J.debug(`"duration" value is greater than the maximum allowed, setting it to ${$t.C.MAX_DURATION} milliseconds`),a=$t.C.MAX_DURATION):a=Math.abs(a):a=$t.C.DEFAULT_DURATION,i.duration=a,_&&!ze.isDecimal(_))throw new TypeError(`Invalid interToneGap: ${_}`);if(_?_<$t.C.MIN_INTER_TONE_GAP?(J.debug(`"interToneGap" value is lower than the minimum allowed, setting it to ${$t.C.MIN_INTER_TONE_GAP} milliseconds`),_=$t.C.MIN_INTER_TONE_GAP):_=Math.abs(_):_=$t.C.DEFAULT_INTER_TONE_GAP,e===_e.DTMF_TRANSPORT.RFC2833){const g=this._getDTMFRTPSender();g&&(s=g.toneBuffer+s,g.insertDTMF(s,a,_));return}if(this._tones){this._tones+=s;return}this._tones=s,p.call(this);function p(){let g;if(this._status===te.STATUS_TERMINATED||!this._tones||l>=this._tones.length){this._tones=null;return}const n=this._tones[l];if(l+=1,n===",")g=2e3;else{const v=new $t(this);i.eventHandlers={onFailed:()=>{this._tones=null}},v.send(n,i),g=a+_}setTimeout(p.bind(this),g)}}sendInfo(s,i,l={}){if(J.debug("sendInfo()"),this._status!==te.STATUS_CONFIRMED&&this._status!==te.STATUS_WAITING_FOR_ACK&&this._status!==te.STATUS_1XX_RECEIVED)throw new _n.InvalidStateError(this._status);new Zf(this).send(s,i,l)}mute(s={audio:!0,video:!1}){J.debug("mute()");let i=!1,l=!1;this._audioMuted===!1&&s.audio&&(i=!0,this._audioMuted=!0,this._toggleMuteAudio(!0)),this._videoMuted===!1&&s.video&&(l=!0,this._videoMuted=!0,this._toggleMuteVideo(!0)),(i===!0||l===!0)&&this._onmute({audio:i,video:l})}unmute(s={audio:!0,video:!0}){J.debug("unmute()");let i=!1,l=!1;this._audioMuted===!0&&s.audio&&(i=!0,this._audioMuted=!1,this._localHold===!1&&this._toggleMuteAudio(!1)),this._videoMuted===!0&&s.video&&(l=!0,this._videoMuted=!1,this._localHold===!1&&this._toggleMuteVideo(!1)),(i===!0||l===!0)&&this._onunmute({audio:i,video:l})}hold(s={},i){if(J.debug("hold()"),this._status!==te.STATUS_WAITING_FOR_ACK&&this._status!==te.STATUS_CONFIRMED||this._localHold===!0||!this._isReadyToReOffer())return!1;this._localHold=!0,this._onhold("local");const l={succeeded:()=>{i&&i()},failed:()=>{this.terminate({cause:_e.causes.WEBRTC_ERROR,status_code:500,reason_phrase:"Hold Failed"})}};return s.useUpdate?this._sendUpdate({sdpOffer:!0,eventHandlers:l,extraHeaders:s.extraHeaders}):this._sendReinvite({eventHandlers:l,extraHeaders:s.extraHeaders}),!0}unhold(s={},i){if(J.debug("unhold()"),this._status!==te.STATUS_WAITING_FOR_ACK&&this._status!==te.STATUS_CONFIRMED||this._localHold===!1||!this._isReadyToReOffer())return!1;this._localHold=!1,this._onunhold("local");const l={succeeded:()=>{i&&i()},failed:()=>{this.terminate({cause:_e.causes.WEBRTC_ERROR,status_code:500,reason_phrase:"Unhold Failed"})}};return s.useUpdate?this._sendUpdate({sdpOffer:!0,eventHandlers:l,extraHeaders:s.extraHeaders}):this._sendReinvite({eventHandlers:l,extraHeaders:s.extraHeaders}),!0}renegotiate(s={},i){J.debug("renegotiate()");const l=s.rtcOfferConstraints||null;if(this._status!==te.STATUS_WAITING_FOR_ACK&&this._status!==te.STATUS_CONFIRMED||!this._isReadyToReOffer())return!1;const a={succeeded:()=>{i&&i()},failed:()=>{this.terminate({cause:_e.causes.WEBRTC_ERROR,status_code:500,reason_phrase:"Media Renegotiation Failed"})}};return this._setLocalMediaStatus(),s.useUpdate?this._sendUpdate({sdpOffer:!0,eventHandlers:a,rtcOfferConstraints:l,extraHeaders:s.extraHeaders}):this._sendReinvite({eventHandlers:a,rtcOfferConstraints:l,extraHeaders:s.extraHeaders}),!0}refer(s,i){J.debug("refer()");const l=s;if(this._status!==te.STATUS_WAITING_FOR_ACK&&this._status!==te.STATUS_CONFIRMED)return!1;if(s=this._ua.normalizeTarget(s),!s)throw new TypeError(`Invalid target: ${l}`);const a=new Tg(this);a.sendRefer(s,i);const _=a.id;return this._referSubscribers[_]=a,a.on("requestFailed",()=>{delete this._referSubscribers[_]}),a.on("accepted",()=>{delete this._referSubscribers[_]}),a.on("failed",()=>{delete this._referSubscribers[_]}),a}sendRequest(s,i){return J.debug("sendRequest()"),this._dialog.sendRequest(s,i)}receiveRequest(s){if(J.debug("receiveRequest()"),s.method===_e.CANCEL)(this._status===te.STATUS_WAITING_FOR_ANSWER||this._status===te.STATUS_ANSWERED)&&(this._status=te.STATUS_CANCELED,this._request.reply(487),this._failed("remote",s,_e.causes.CANCELED));else switch(s.method){case _e.ACK:if(this._status!==te.STATUS_WAITING_FOR_ACK)return;if(this._status=te.STATUS_CONFIRMED,clearTimeout(this._timers.ackTimer),clearTimeout(this._timers.invite2xxTimer),this._late_sdp){if(!s.body){this.terminate({cause:_e.causes.MISSING_SDP,status_code:400});break}const i={originator:"remote",type:"answer",sdp:s.body};J.debug('emit "sdp"'),this.emit("sdp",i);const l=new RTCSessionDescription({type:"answer",sdp:i.sdp});this._connectionPromiseQueue=this._connectionPromiseQueue.then(()=>this._connection.setRemoteDescription(l)).then(()=>{this._is_confirmed||this._confirmed("remote",s)}).catch(a=>{this.terminate({cause:_e.causes.BAD_MEDIA_DESCRIPTION,status_code:488}),J.warn('emit "peerconnection:setremotedescriptionfailed" [error:%o]',a),this.emit("peerconnection:setremotedescriptionfailed",a)})}else this._is_confirmed||this._confirmed("remote",s);break;case _e.BYE:this._status===te.STATUS_CONFIRMED||this._status===te.STATUS_WAITING_FOR_ACK?(s.reply(200),this._ended("remote",s,_e.causes.BYE)):this._status===te.STATUS_INVITE_RECEIVED||this._status===te.STATUS_WAITING_FOR_ANSWER?(s.reply(200),this._request.reply(487,"BYE Received"),this._ended("remote",s,_e.causes.BYE)):s.reply(403,"Wrong Status");break;case _e.INVITE:this._status===te.STATUS_CONFIRMED?s.hasHeader("replaces")?this._receiveReplaces(s):this._receiveReinvite(s):s.reply(403,"Wrong Status");break;case _e.INFO:if(this._status===te.STATUS_1XX_RECEIVED||this._status===te.STATUS_WAITING_FOR_ANSWER||this._status===te.STATUS_ANSWERED||this._status===te.STATUS_WAITING_FOR_ACK||this._status===te.STATUS_CONFIRMED){const i=s.hasHeader("Content-Type")?s.getHeader("Content-Type").toLowerCase():void 0;i&&i.match(/^application\/dtmf-relay/i)?new $t(this).init_incoming(s):i!==void 0?new Zf(this).init_incoming(s):s.reply(415)}else s.reply(403,"Wrong Status");break;case _e.UPDATE:this._status===te.STATUS_CONFIRMED?this._receiveUpdate(s):s.reply(403,"Wrong Status");break;case _e.REFER:this._status===te.STATUS_CONFIRMED?this._receiveRefer(s):s.reply(403,"Wrong Status");break;case _e.NOTIFY:this._status===te.STATUS_CONFIRMED?this._receiveNotify(s):s.reply(403,"Wrong Status");break;default:s.reply(501)}}onTransportError(){J.warn("onTransportError()"),this._status!==te.STATUS_TERMINATED&&this.terminate({status_code:500,reason_phrase:_e.causes.CONNECTION_ERROR,cause:_e.causes.CONNECTION_ERROR})}onRequestTimeout(){J.warn("onRequestTimeout()"),this._status!==te.STATUS_TERMINATED&&this.terminate({status_code:408,reason_phrase:_e.causes.REQUEST_TIMEOUT,cause:_e.causes.REQUEST_TIMEOUT})}onDialogError(){J.warn("onDialogError()"),this._status!==te.STATUS_TERMINATED&&this.terminate({status_code:500,reason_phrase:_e.causes.DIALOG_ERROR,cause:_e.causes.DIALOG_ERROR})}newDTMF(s){J.debug("newDTMF()"),this.emit("newDTMF",s)}newInfo(s){J.debug("newInfo()"),this.emit("newInfo",s)}_isReadyToReOffer(){return this._rtcReady?this._dialog?this._dialog.uac_pending_reply===!0||this._dialog.uas_pending_reply===!0?(J.debug("_isReadyToReOffer() | there is another INVITE/UPDATE transaction in progress"),!1):!0:(J.debug("_isReadyToReOffer() | session not established yet"),!1):(J.debug("_isReadyToReOffer() | internal WebRTC status not ready"),!1)}_close(){if(J.debug("close()"),this._localMediaStream&&this._localMediaStreamLocallyGenerated&&(J.debug("close() | closing local MediaStream"),ze.closeMediaStream(this._localMediaStream)),this._status!==te.STATUS_TERMINATED){if(this._status=te.STATUS_TERMINATED,this._connection)try{this._connection.close()}catch(s){J.warn("close() | error closing the RTCPeerConnection: %o",s)}for(const s in this._timers)Object.prototype.hasOwnProperty.call(this._timers,s)&&clearTimeout(this._timers[s]);clearTimeout(this._sessionTimers.timer),this._dialog&&(this._dialog.terminate(),delete this._dialog);for(const s in this._earlyDialogs)Object.prototype.hasOwnProperty.call(this._earlyDialogs,s)&&(this._earlyDialogs[s].terminate(),delete this._earlyDialogs[s]);for(const s in this._referSubscribers)Object.prototype.hasOwnProperty.call(this._referSubscribers,s)&&delete this._referSubscribers[s];this._ua.destroyRTCSession(this)}}_setInvite2xxTimer(s,i){let l=qr.T1;function a(){this._status===te.STATUS_WAITING_FOR_ACK&&(s.reply(200,null,[`Contact: ${this._contact}`],i),l<qr.T2&&(l=l*2,l>qr.T2&&(l=qr.T2)),this._timers.invite2xxTimer=setTimeout(a.bind(this),l))}this._timers.invite2xxTimer=setTimeout(a.bind(this),l)}_setACKTimer(){this._timers.ackTimer=setTimeout(()=>{this._status===te.STATUS_WAITING_FOR_ACK&&(J.debug("no ACK received, terminating the session"),clearTimeout(this._timers.invite2xxTimer),this.sendRequest(_e.BYE),this._ended("remote",null,_e.causes.NO_ACK))},qr.TIMER_H)}_createRTCConnection(s,i){this._connection=new RTCPeerConnection(s,i),this._connection.addEventListener("iceconnectionstatechange",()=>{this._connection.iceConnectionState==="failed"&&this.terminate({cause:_e.causes.RTP_TIMEOUT,status_code:408,reason_phrase:_e.causes.RTP_TIMEOUT})}),J.debug('emit "peerconnection"'),this.emit("peerconnection",{peerconnection:this._connection})}_createLocalDescription(s,i){if(J.debug("createLocalDescription()"),s!=="offer"&&s!=="answer")throw new Error(`createLocalDescription() | invalid type "${s}"`);const l=this._connection;return this._rtcReady=!1,Promise.resolve().then(()=>s==="offer"?l.createOffer(i).catch(a=>(J.warn('emit "peerconnection:createofferfailed" [error:%o]',a),this.emit("peerconnection:createofferfailed",a),Promise.reject(a))):l.createAnswer(i).catch(a=>(J.warn('emit "peerconnection:createanswerfailed" [error:%o]',a),this.emit("peerconnection:createanswerfailed",a),Promise.reject(a)))).then(a=>l.setLocalDescription(a).catch(_=>(this._rtcReady=!0,J.warn('emit "peerconnection:setlocaldescriptionfailed" [error:%o]',_),this.emit("peerconnection:setlocaldescriptionfailed",_),Promise.reject(_)))).then(()=>{const a=i&&i.iceRestart;if(l.iceGatheringState==="complete"&&!a||l.iceGatheringState==="gathering"&&this._iceReady){this._rtcReady=!0;const _={originator:"local",type:s,sdp:l.localDescription.sdp};return J.debug('emit "sdp"'),this.emit("sdp",_),Promise.resolve(_.sdp)}return new Promise(_=>{let e=!1,p,g;this._iceReady=!1;const n=()=>{l.removeEventListener("icecandidate",p),l.removeEventListener("icegatheringstatechange",g),e=!0,this._rtcReady=!0,this._iceReady=!0;const v={originator:"local",type:s,sdp:l.localDescription.sdp};J.debug('emit "sdp"'),this.emit("sdp",v),_(v.sdp)};l.addEventListener("icecandidate",p=v=>{const S=v.candidate;S?this.emit("icecandidate",{candidate:S,ready:n}):e||n()}),l.addEventListener("icegatheringstatechange",g=()=>{l.iceGatheringState==="complete"&&!e&&n()})})})}_createDialog(s,i,l){const a=i==="UAS"?s.to_tag:s.from_tag,_=i==="UAS"?s.from_tag:s.to_tag,e=s.call_id+a+_;let p=this._earlyDialogs[e];if(l)return p?!0:(p=new oa(this,s,i,oa.C.STATUS_EARLY),p.error?(J.debug(p.error),this._failed("remote",s,_e.causes.INTERNAL_ERROR),!1):(this._earlyDialogs[e]=p,!0));{if(this._from_tag=s.from_tag,this._to_tag=s.to_tag,p)return p.update(s,i),this._dialog=p,delete this._earlyDialogs[e],!0;const g=new oa(this,s,i);return g.error?(J.debug(g.error),this._failed("remote",s,_e.causes.INTERNAL_ERROR),!1):(this._dialog=g,!0)}}_receiveReinvite(s){J.debug("receiveReinvite()");const i=s.hasHeader("Content-Type")?s.getHeader("Content-Type").toLowerCase():void 0,l={request:s,callback:void 0,reject:_.bind(this)};let a=!1;function _(p={}){a=!0;const g=p.status_code||403,n=p.reason_phrase||"",v=ze.cloneArray(p.extraHeaders);if(this._status!==te.STATUS_CONFIRMED)return!1;if(g<300||g>=700)throw new TypeError(`Invalid status_code: ${g}`);s.reply(g,n,v)}if(this.emit("reinvite",l),a)return;if(this._late_sdp=!1,!s.body){this._late_sdp=!0,this._remoteHold&&(this._remoteHold=!1,this._onunhold("remote")),this._connectionPromiseQueue=this._connectionPromiseQueue.then(()=>this._createLocalDescription("offer",this._rtcOfferConstraints)).then(p=>{e.call(this,p)}).catch(()=>{s.reply(500)});return}if(i!=="application/sdp"){J.debug("invalid Content-Type"),s.reply(415);return}this._processInDialogSdpOffer(s).then(p=>{this._status!==te.STATUS_TERMINATED&&e.call(this,p)}).catch(p=>{J.warn(p)});function e(p){const g=[`Contact: ${this._contact}`];this._handleSessionTimersInIncomingRequest(s,g),this._late_sdp&&(p=this._mangleOffer(p)),s.reply(200,null,g,p,()=>{this._status=te.STATUS_WAITING_FOR_ACK,this._setInvite2xxTimer(s,p),this._setACKTimer()}),typeof l.callback=="function"&&l.callback()}}_receiveUpdate(s){J.debug("receiveUpdate()");const i=s.hasHeader("Content-Type")?s.getHeader("Content-Type").toLowerCase():void 0,l={request:s,callback:void 0,reject:_.bind(this)};let a=!1;function _(p={}){a=!0;const g=p.status_code||403,n=p.reason_phrase||"",v=ze.cloneArray(p.extraHeaders);if(this._status!==te.STATUS_CONFIRMED)return!1;if(g<300||g>=700)throw new TypeError(`Invalid status_code: ${g}`);s.reply(g,n,v)}if(this.emit("update",l),a)return;if(!s.body){e.call(this,null);return}if(i!=="application/sdp"){J.debug("invalid Content-Type"),s.reply(415);return}this._processInDialogSdpOffer(s).then(p=>{this._status!==te.STATUS_TERMINATED&&e.call(this,p)}).catch(p=>{J.warn(p)});function e(p){const g=[`Contact: ${this._contact}`];this._handleSessionTimersInIncomingRequest(s,g),s.reply(200,null,g,p),typeof l.callback=="function"&&l.callback()}}_processInDialogSdpOffer(s){J.debug("_processInDialogSdpOffer()");const i=s.parseSDP();let l=!1;for(const e of i.media){if(ua.indexOf(e.type)===-1)continue;const p=e.direction||i.direction||"sendrecv";if(p==="sendonly"||p==="inactive")l=!0;else{l=!1;break}}const a={originator:"remote",type:"offer",sdp:s.body};J.debug('emit "sdp"'),this.emit("sdp",a);const _=new RTCSessionDescription({type:"offer",sdp:a.sdp});return this._connectionPromiseQueue=this._connectionPromiseQueue.then(()=>{if(this._status===te.STATUS_TERMINATED)throw new Error("terminated");return this._connection.setRemoteDescription(_).catch(e=>{throw s.reply(488),J.warn('emit "peerconnection:setremotedescriptionfailed" [error:%o]',e),this.emit("peerconnection:setremotedescriptionfailed",e),e})}).then(()=>{if(this._status===te.STATUS_TERMINATED)throw new Error("terminated");this._remoteHold===!0&&l===!1?(this._remoteHold=!1,this._onunhold("remote")):this._remoteHold===!1&&l===!0&&(this._remoteHold=!0,this._onhold("remote"))}).then(()=>{if(this._status===te.STATUS_TERMINATED)throw new Error("terminated");return this._createLocalDescription("answer",this._rtcAnswerConstraints).catch(e=>{throw s.reply(500),J.warn('emit "peerconnection:createtelocaldescriptionfailed" [error:%o]',e),e})}).catch(e=>{J.warn("_processInDialogSdpOffer() failed [error: %o]",e)}),this._connectionPromiseQueue}_receiveRefer(s){if(J.debug("receiveRefer()"),!s.refer_to){J.debug("no Refer-To header field present in REFER"),s.reply(400);return}if(s.refer_to.uri.scheme!==_e.SIP){J.debug("Refer-To header field points to a non-SIP URI scheme"),s.reply(416);return}s.reply(202);const i=new gg(this,s.cseq);J.debug('emit "refer"'),this.emit("refer",{request:s,accept:(_,e)=>{l.call(this,_,e)},reject:()=>{a.call(this)}});function l(_,e={}){if(_=typeof _=="function"?_:null,this._status!==te.STATUS_WAITING_FOR_ACK&&this._status!==te.STATUS_CONFIRMED)return!1;const p=new Wu(this._ua);if(p.on("progress",({response:g})=>{i.notify(g.status_code,g.reason_phrase)}),p.on("accepted",({response:g})=>{i.notify(g.status_code,g.reason_phrase)}),p.on("_failed",({message:g,cause:n})=>{g?i.notify(g.status_code,g.reason_phrase):i.notify(487,n)}),s.refer_to.uri.hasHeader("replaces")){const g=decodeURIComponent(s.refer_to.uri.getHeader("replaces"));e.extraHeaders=ze.cloneArray(e.extraHeaders),e.extraHeaders.push(`Replaces: ${g}`)}p.connect(s.refer_to.uri.toAor(),e,_)}function a(){i.notify(603)}}_receiveNotify(s){switch(J.debug("receiveNotify()"),s.event||s.reply(400),s.event.event){case"refer":{let i,l;if(s.event.params&&s.event.params.id)i=s.event.params.id,l=this._referSubscribers[i];else if(Object.keys(this._referSubscribers).length===1)l=this._referSubscribers[Object.keys(this._referSubscribers)[0]];else{s.reply(400,"Missing event id parameter");return}if(!l){s.reply(481,"Subscription does not exist");return}l.receiveNotify(s),s.reply(200);break}default:s.reply(489)}}_receiveReplaces(s){J.debug("receiveReplaces()");function i(a){if(this._status!==te.STATUS_WAITING_FOR_ACK&&this._status!==te.STATUS_CONFIRMED)return!1;const _=new Wu(this._ua);_.on("confirmed",()=>{this.terminate()}),_.init_incoming(s,a)}function l(){J.debug("Replaced INVITE rejected by the user"),s.reply(486)}this.emit("replaces",{request:s,accept:a=>{i.call(this,a)},reject:()=>{l.call(this)}})}_sendInitialRequest(s,i,l){const a=new mg(this._ua,this._request,{onRequestTimeout:()=>{this.onRequestTimeout()},onTransportError:()=>{this.onTransportError()},onAuthenticated:_=>{this._request=_},onReceiveResponse:_=>{this._receiveInviteResponse(_)}});Promise.resolve().then(()=>{if(l)return l;if(s.audio||s.video)return this._localMediaStreamLocallyGenerated=!0,navigator.mediaDevices.getUserMedia(s).catch(_=>{throw this._status===te.STATUS_TERMINATED?new Error("terminated"):(this._failed("local",null,_e.causes.USER_DENIED_MEDIA_ACCESS),J.warn('emit "getusermediafailed" [error:%o]',_),this.emit("getusermediafailed",_),_)})}).then(_=>{if(this._status===te.STATUS_TERMINATED)throw new Error("terminated");return this._localMediaStream=_,_&&_.getTracks().forEach(e=>{this._connection.addTrack(e,_)}),this._connecting(this._request),this._createLocalDescription("offer",i).catch(e=>{throw this._failed("local",null,_e.causes.WEBRTC_ERROR),e})}).then(_=>{if(this._is_canceled||this._status===te.STATUS_TERMINATED)throw new Error("terminated");this._request.body=_,this._status=te.STATUS_INVITE_SENT,J.debug('emit "sending" [request:%o]',this._request),this.emit("sending",{request:this._request}),a.send()}).catch(_=>{this._status!==te.STATUS_TERMINATED&&J.warn(_)})}_getDTMFRTPSender(){const s=this._connection.getSenders().find(i=>i.track&&i.track.kind==="audio");if(!(s&&s.dtmf)){J.warn("sendDTMF() | no local audio track to send DTMF with");return}return s.dtmf}_receiveInviteResponse(s){if(J.debug("receiveInviteResponse()"),this._dialog&&s.status_code>=200&&s.status_code<=299)if(this._dialog.id.call_id===s.call_id&&this._dialog.id.local_tag===s.from_tag&&this._dialog.id.remote_tag===s.to_tag){this.sendRequest(_e.ACK);return}else{const i=new oa(this,s,"UAC");if(i.error!==void 0){J.debug(i.error);return}this.sendRequest(_e.ACK),this.sendRequest(_e.BYE);return}if(this._is_canceled){s.status_code>=100&&s.status_code<200?this._request.cancel(this._cancel_reason):s.status_code>=200&&s.status_code<299&&this._acceptAndTerminate(s);return}if(!(this._status!==te.STATUS_INVITE_SENT&&this._status!==te.STATUS_1XX_RECEIVED))switch(!0){case/^100$/.test(s.status_code):this._status=te.STATUS_1XX_RECEIVED;break;case/^1[0-9]{2}$/.test(s.status_code):{if(!s.to_tag){J.debug("1xx response received without to tag");break}if(s.hasHeader("contact")&&!this._createDialog(s,"UAC",!0))break;if(this._status=te.STATUS_1XX_RECEIVED,!s.body){this._progress("remote",s);break}const i={originator:"remote",type:"answer",sdp:s.body};J.debug('emit "sdp"'),this.emit("sdp",i);const l=new RTCSessionDescription({type:"answer",sdp:i.sdp});this._connectionPromiseQueue=this._connectionPromiseQueue.then(()=>this._connection.setRemoteDescription(l)).then(()=>this._progress("remote",s)).catch(a=>{J.warn('emit "peerconnection:setremotedescriptionfailed" [error:%o]',a),this.emit("peerconnection:setremotedescriptionfailed",a)});break}case/^2[0-9]{2}$/.test(s.status_code):{if(this._status=te.STATUS_CONFIRMED,!s.body){this._acceptAndTerminate(s,400,_e.causes.MISSING_SDP),this._failed("remote",s,_e.causes.BAD_MEDIA_DESCRIPTION);break}if(!this._createDialog(s,"UAC"))break;const i={originator:"remote",type:"answer",sdp:s.body};J.debug('emit "sdp"'),this.emit("sdp",i);const l=new RTCSessionDescription({type:"answer",sdp:i.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(s,500,a.toString()),this._failed("local",s,_e.causes.WEBRTC_ERROR)})}).then(()=>{this._connection.setRemoteDescription(l).then(()=>{this._handleSessionTimersInIncomingResponse(s),this._accepted("remote",s),this.sendRequest(_e.ACK),this._confirmed("local",null)}).catch(a=>{this._acceptAndTerminate(s,488,"Not Acceptable Here"),this._failed("remote",s,_e.causes.BAD_MEDIA_DESCRIPTION),J.warn('emit "peerconnection:setremotedescriptionfailed" [error:%o]',a),this.emit("peerconnection:setremotedescriptionfailed",a)})});break}default:{const i=ze.sipErrorCause(s.status_code);this._failed("remote",s,i)}}}_sendReinvite(s={}){J.debug("sendReinvite()");const i=ze.cloneArray(s.extraHeaders),l=ze.cloneObject(s.eventHandlers),a=s.rtcOfferConstraints||this._rtcOfferConstraints||null;let _=!1;i.push(`Contact: ${this._contact}`),i.push("Content-Type: application/sdp"),this._sessionTimers.running&&i.push(`Session-Expires: ${this._sessionTimers.currentExpires};refresher=${this._sessionTimers.refresher?"uac":"uas"}`),this._connectionPromiseQueue=this._connectionPromiseQueue.then(()=>this._createLocalDescription("offer",a)).then(g=>{g=this._mangleOffer(g);const n={originator:"local",type:"offer",sdp:g};J.debug('emit "sdp"'),this.emit("sdp",n),this.sendRequest(_e.INVITE,{extraHeaders:i,body:g,eventHandlers:{onSuccessResponse:v=>{e.call(this,v),_=!0},onErrorResponse:v=>{p.call(this,v)},onTransportError:()=>{this.onTransportError()},onRequestTimeout:()=>{this.onRequestTimeout()},onDialogError:()=>{this.onDialogError()}}})}).catch(()=>{p()});function e(g){if(this._status===te.STATUS_TERMINATED||(this.sendRequest(_e.ACK),_))return;if(this._handleSessionTimersInIncomingResponse(g),g.body){if(!g.hasHeader("Content-Type")||g.getHeader("Content-Type").toLowerCase()!=="application/sdp"){p.call(this);return}}else{p.call(this);return}const n={originator:"remote",type:"answer",sdp:g.body};J.debug('emit "sdp"'),this.emit("sdp",n);const v=new RTCSessionDescription({type:"answer",sdp:n.sdp});this._connectionPromiseQueue=this._connectionPromiseQueue.then(()=>this._connection.setRemoteDescription(v)).then(()=>{l.succeeded&&l.succeeded(g)}).catch(S=>{p.call(this),J.warn('emit "peerconnection:setremotedescriptionfailed" [error:%o]',S),this.emit("peerconnection:setremotedescriptionfailed",S)})}function p(g){l.failed&&l.failed(g)}}_sendUpdate(s={}){J.debug("sendUpdate()");const i=ze.cloneArray(s.extraHeaders),l=ze.cloneObject(s.eventHandlers),a=s.rtcOfferConstraints||this._rtcOfferConstraints||null,_=s.sdpOffer||!1;let e=!1;i.push(`Contact: ${this._contact}`),this._sessionTimers.running&&i.push(`Session-Expires: ${this._sessionTimers.currentExpires};refresher=${this._sessionTimers.refresher?"uac":"uas"}`),_?(i.push("Content-Type: application/sdp"),this._connectionPromiseQueue=this._connectionPromiseQueue.then(()=>this._createLocalDescription("offer",a)).then(n=>{n=this._mangleOffer(n);const v={originator:"local",type:"offer",sdp:n};J.debug('emit "sdp"'),this.emit("sdp",v),this.sendRequest(_e.UPDATE,{extraHeaders:i,body:n,eventHandlers:{onSuccessResponse:S=>{p.call(this,S),e=!0},onErrorResponse:S=>{g.call(this,S)},onTransportError:()=>{this.onTransportError()},onRequestTimeout:()=>{this.onRequestTimeout()},onDialogError:()=>{this.onDialogError()}}})}).catch(()=>{g.call(this)})):this.sendRequest(_e.UPDATE,{extraHeaders:i,eventHandlers:{onSuccessResponse:n=>{p.call(this,n)},onErrorResponse:n=>{g.call(this,n)},onTransportError:()=>{this.onTransportError()},onRequestTimeout:()=>{this.onRequestTimeout()},onDialogError:()=>{this.onDialogError()}}});function p(n){if(this._status!==te.STATUS_TERMINATED&&!e)if(this._handleSessionTimersInIncomingResponse(n),_){if(n.body){if(!n.hasHeader("Content-Type")||n.getHeader("Content-Type").toLowerCase()!=="application/sdp"){g.call(this);return}}else{g.call(this);return}const v={originator:"remote",type:"answer",sdp:n.body};J.debug('emit "sdp"'),this.emit("sdp",v);const S=new RTCSessionDescription({type:"answer",sdp:v.sdp});this._connectionPromiseQueue=this._connectionPromiseQueue.then(()=>this._connection.setRemoteDescription(S)).then(()=>{l.succeeded&&l.succeeded(n)}).catch(m=>{g.call(this),J.warn('emit "peerconnection:setremotedescriptionfailed" [error:%o]',m),this.emit("peerconnection:setremotedescriptionfailed",m)})}else l.succeeded&&l.succeeded(n)}function g(n){l.failed&&l.failed(n)}}_acceptAndTerminate(s,i,l){J.debug("acceptAndTerminate()");const a=[];i&&(l=l||_e.REASON_PHRASE[i]||"",a.push(`Reason: SIP ;cause=${i}; text="${l}"`)),(this._dialog||this._createDialog(s,"UAC"))&&(this.sendRequest(_e.ACK),this.sendRequest(_e.BYE,{extraHeaders:a})),this._status=te.STATUS_TERMINATED}_mangleOffer(s){if(!this._localHold&&!this._remoteHold)return s;if(s=Xf.parse(s),this._localHold&&!this._remoteHold){J.debug("mangleOffer() | me on hold, mangling offer");for(const i of s.media)ua.indexOf(i.type)!==-1&&(i.direction?i.direction==="sendrecv"?i.direction="sendonly":i.direction==="recvonly"&&(i.direction="inactive"):i.direction="sendonly")}else if(this._localHold&&this._remoteHold){J.debug("mangleOffer() | both on hold, mangling offer");for(const i of s.media)ua.indexOf(i.type)!==-1&&(i.direction="inactive")}else if(this._remoteHold){J.debug("mangleOffer() | remote on hold, mangling offer");for(const i of s.media)ua.indexOf(i.type)!==-1&&(i.direction?i.direction==="sendrecv"?i.direction="recvonly":i.direction==="recvonly"&&(i.direction="inactive"):i.direction="recvonly")}return Xf.write(s)}_setLocalMediaStatus(){let s=!0,i=!0;(this._localHold||this._remoteHold)&&(s=!1,i=!1),this._audioMuted&&(s=!1),this._videoMuted&&(i=!1),this._toggleMuteAudio(!s),this._toggleMuteVideo(!i)}_handleSessionTimersInIncomingRequest(s,i){if(!this._sessionTimers.enabled)return;let l;s.session_expires&&s.session_expires>=_e.MIN_SESSION_EXPIRES?(this._sessionTimers.currentExpires=s.session_expires,l=s.session_expires_refresher||"uas"):(this._sessionTimers.currentExpires=this._sessionTimers.defaultExpires,l="uas"),i.push(`Session-Expires: ${this._sessionTimers.currentExpires};refresher=${l}`),this._sessionTimers.refresher=l==="uas",this._runSessionTimer()}_handleSessionTimersInIncomingResponse(s){if(!this._sessionTimers.enabled)return;let i;s.session_expires&&s.session_expires>=_e.MIN_SESSION_EXPIRES?(this._sessionTimers.currentExpires=s.session_expires,i=s.session_expires_refresher||"uac"):(this._sessionTimers.currentExpires=this._sessionTimers.defaultExpires,i="uac"),this._sessionTimers.refresher=i==="uac",this._runSessionTimer()}_runSessionTimer(){const s=this._sessionTimers.currentExpires;this._sessionTimers.running=!0,clearTimeout(this._sessionTimers.timer),this._sessionTimers.refresher?this._sessionTimers.timer=setTimeout(()=>{this._status!==te.STATUS_TERMINATED&&this._isReadyToReOffer()&&(J.debug("runSessionTimer() | sending session refresh request"),this._sessionTimers.refreshMethod===_e.UPDATE?this._sendUpdate():this._sendReinvite())},s*500):this._sessionTimers.timer=setTimeout(()=>{this._status!==te.STATUS_TERMINATED&&(J.warn("runSessionTimer() | timer expired, terminating the session"),this.terminate({cause:_e.causes.REQUEST_TIMEOUT,status_code:408,reason_phrase:"Session Timer Expired"}))},s*1100)}_toggleMuteAudio(s){const i=this._connection.getSenders().filter(l=>l.track&&l.track.kind==="audio");for(const l of i)l.track.enabled=!s}_toggleMuteVideo(s){const i=this._connection.getSenders().filter(l=>l.track&&l.track.kind==="video");for(const l of i)l.track.enabled=!s}_newRTCSession(s,i){J.debug("newRTCSession()"),this._ua.newRTCSession(this,{originator:s,session:this,request:i})}_connecting(s){J.debug("session connecting"),J.debug('emit "connecting"'),this.emit("connecting",{request:s})}_progress(s,i){J.debug("session progress"),J.debug('emit "progress"'),this.emit("progress",{originator:s,response:i||null})}_accepted(s,i){J.debug("session accepted"),this._start_time=new Date,J.debug('emit "accepted"'),this.emit("accepted",{originator:s,response:i||null})}_confirmed(s,i){J.debug("session confirmed"),this._is_confirmed=!0,J.debug('emit "confirmed"'),this.emit("confirmed",{originator:s,ack:i||null})}_ended(s,i,l){J.debug("session ended"),this._end_time=new Date,this._close(),J.debug('emit "ended"'),this.emit("ended",{originator:s,message:i||null,cause:l})}_failed(s,i,l){J.debug("session failed"),J.debug('emit "_failed"'),this.emit("_failed",{originator:s,message:i||null,cause:l}),this._close(),J.debug('emit "failed"'),this.emit("failed",{originator:s,message:i||null,cause:l})}_onhold(s){J.debug("session onhold"),this._setLocalMediaStatus(),J.debug('emit "hold"'),this.emit("hold",{originator:s})}_onunhold(s){J.debug("session onunhold"),this._setLocalMediaStatus(),J.debug('emit "unhold"'),this.emit("unhold",{originator:s})}_onmute({audio:s,video:i}){J.debug("session onmute"),this._setLocalMediaStatus(),J.debug('emit "muted"'),this.emit("muted",{audio:s,video:i})}_onunmute({audio:s,video:i}){J.debug("session onunmute"),this._setLocalMediaStatus(),J.debug('emit "unmuted"'),this.emit("unmuted",{audio:s,video:i})}};const vg=Le(t_),Eg=ct.EventEmitter,Sg=ut,_u=xe,yg=bt,Vr=Tt(),Ag=Wn,s_=gs,Cg=ds(),ca=new Sg("Message");var Rg=class extends Eg{constructor(s){super(),this._ua=s,this._request=null,this._closed=!1,this._direction=null,this._local_identity=null,this._remote_identity=null,this._is_replied=!1,this._data={}}get direction(){return this._direction}get local_identity(){return this._local_identity}get remote_identity(){return this._remote_identity}send(s,i,l={}){const a=s;if(s===void 0||i===void 0)throw new TypeError("Not enough arguments");if(s=this._ua.normalizeTarget(s),!s)throw new TypeError(`Invalid target: ${a}`);const _=Vr.cloneArray(l.extraHeaders),e=Vr.cloneObject(l.eventHandlers),p=l.contentType||"text/plain",g={};l.fromUserName&&(g.from_uri=new Cg("sip",l.fromUserName,this._ua.configuration.uri.host),_.push(`P-Preferred-Identity: ${this._ua.configuration.uri.toString()}`)),l.fromDisplayName&&(g.from_display_name=l.fromDisplayName);for(const v in e)Object.prototype.hasOwnProperty.call(e,v)&&this.on(v,e[v]);_.push(`Content-Type: ${p}`),this._request=new yg.OutgoingRequest(_u.MESSAGE,s,this._ua,g,_),i&&(this._request.body=i);const n=new Ag(this._ua,this._request,{onRequestTimeout:()=>{this._onRequestTimeout()},onTransportError:()=>{this._onTransportError()},onReceiveResponse:v=>{this._receiveResponse(v)}});this._newMessage("local",this._request),n.send()}init_incoming(s){this._request=s,this._newMessage("remote",s),this._is_replied||(this._is_replied=!0,s.reply(200)),this._close()}accept(s={}){const i=Vr.cloneArray(s.extraHeaders),l=s.body;if(this._direction!=="incoming")throw new s_.NotSupportedError('"accept" not supported for outgoing Message');if(this._is_replied)throw new Error("incoming Message already replied");this._is_replied=!0,this._request.reply(200,null,i,l)}reject(s={}){const i=s.status_code||480,l=s.reason_phrase,a=Vr.cloneArray(s.extraHeaders),_=s.body;if(this._direction!=="incoming")throw new s_.NotSupportedError('"reject" not supported for outgoing Message');if(this._is_replied)throw new Error("incoming Message already replied");if(i<300||i>=700)throw new TypeError(`Invalid status_code: ${i}`);this._is_replied=!0,this._request.reply(i,l,a,_)}_receiveResponse(s){if(!this._closed)switch(!0){case/^1[0-9]{2}$/.test(s.status_code):break;case/^2[0-9]{2}$/.test(s.status_code):this._succeeded("remote",s);break;default:{const i=Vr.sipErrorCause(s.status_code);this._failed("remote",s,i);break}}}_onRequestTimeout(){this._closed||this._failed("system",null,_u.causes.REQUEST_TIMEOUT)}_onTransportError(){this._closed||this._failed("system",null,_u.causes.CONNECTION_ERROR)}_close(){this._closed=!0,this._ua.destroyMessage(this)}_newMessage(s,i){s==="remote"?(this._direction="incoming",this._local_identity=i.to,this._remote_identity=i.from):s==="local"&&(this._direction="outgoing",this._local_identity=i.from,this._remote_identity=i.to),this._ua.newMessage(this,{originator:s,message:this,request:i})}_failed(s,i,l){ca.debug("MESSAGE failed"),this._close(),ca.debug('emit "failed"'),this.emit("failed",{originator:s,response:i||null,cause:l})}_succeeded(s,i){ca.debug("MESSAGE succeeded"),this._close(),ca.debug('emit "succeeded"'),this.emit("succeeded",{originator:s,response:i})}};const Ig=ct.EventEmitter,bg=ut,hu=xe,wg=bt,Br=Tt(),Og=Wn,n_=gs,fa=new bg("Options");var Dg=class extends Ig{constructor(s){super(),this._ua=s,this._request=null,this._closed=!1,this._direction=null,this._local_identity=null,this._remote_identity=null,this._is_replied=!1,this._data={}}get direction(){return this._direction}get local_identity(){return this._local_identity}get remote_identity(){return this._remote_identity}send(s,i,l={}){const a=s;if(s===void 0)throw new TypeError("A target is required for OPTIONS");if(s=this._ua.normalizeTarget(s),!s)throw new TypeError(`Invalid target: ${a}`);const _=Br.cloneArray(l.extraHeaders),e=Br.cloneObject(l.eventHandlers),p=l.contentType||"application/sdp";for(const n in e)Object.prototype.hasOwnProperty.call(e,n)&&this.on(n,e[n]);_.push(`Content-Type: ${p}`),this._request=new wg.OutgoingRequest(hu.OPTIONS,s,this._ua,null,_),i&&(this._request.body=i);const g=new Og(this._ua,this._request,{onRequestTimeout:()=>{this._onRequestTimeout()},onTransportError:()=>{this._onTransportError()},onReceiveResponse:n=>{this._receiveResponse(n)}});this._newOptions("local",this._request),g.send()}init_incoming(s){this._request=s,this._newOptions("remote",s),this._is_replied||(this._is_replied=!0,s.reply(200)),this._close()}accept(s={}){const i=Br.cloneArray(s.extraHeaders),l=s.body;if(this._direction!=="incoming")throw new n_.NotSupportedError('"accept" not supported for outgoing Options');if(this._is_replied)throw new Error("incoming Options already replied");this._is_replied=!0,this._request.reply(200,null,i,l)}reject(s={}){const i=s.status_code||480,l=s.reason_phrase,a=Br.cloneArray(s.extraHeaders),_=s.body;if(this._direction!=="incoming")throw new n_.NotSupportedError('"reject" not supported for outgoing Options');if(this._is_replied)throw new Error("incoming Options already replied");if(i<300||i>=700)throw new TypeError(`Invalid status_code: ${i}`);this._is_replied=!0,this._request.reply(i,l,a,_)}_receiveResponse(s){if(!this._closed)switch(!0){case/^1[0-9]{2}$/.test(s.status_code):break;case/^2[0-9]{2}$/.test(s.status_code):this._succeeded("remote",s);break;default:{const i=Br.sipErrorCause(s.status_code);this._failed("remote",s,i);break}}}_onRequestTimeout(){this._closed||this._failed("system",null,hu.causes.REQUEST_TIMEOUT)}_onTransportError(){this._closed||this._failed("system",null,hu.causes.CONNECTION_ERROR)}_close(){this._closed=!0,this._ua.destroyMessage(this)}_newOptions(s,i){s==="remote"?(this._direction="incoming",this._local_identity=i.to,this._remote_identity=i.from):s==="local"&&(this._direction="outgoing",this._local_identity=i.from,this._remote_identity=i.to),this._ua.newOptions(this,{originator:s,message:this,request:i})}_failed(s,i,l){fa.debug("OPTIONS failed"),this._close(),fa.debug('emit "failed"'),this.emit("failed",{originator:s,response:i||null,cause:l})}_succeeded(s,i){fa.debug("OPTIONS succeeded"),this._close(),fa.debug('emit "succeeded"'),this.emit("succeeded",{originator:s,response:i})}},du={};const Ng=ut,pu=Tt(),Ug=Gt(),Gr=new Ng("Socket");du.isSocket=c=>{if(Array.isArray(c))return!1;if(typeof c>"u")return Gr.warn("undefined JsSIP.Socket instance"),!1;try{if(!pu.isString(c.url))throw Gr.warn("missing or invalid JsSIP.Socket url property"),new Error("Missing or invalid JsSIP.Socket url property");if(!pu.isString(c.via_transport))throw Gr.warn("missing or invalid JsSIP.Socket via_transport property"),new Error("Missing or invalid JsSIP.Socket via_transport property");if(Ug.parse(c.sip_uri,"SIP_URI")===-1)throw Gr.warn("missing or invalid JsSIP.Socket sip_uri property"),new Error("missing or invalid JsSIP.Socket sip_uri property")}catch{return!1}try{["connect","disconnect","send"].forEach(s=>{if(!pu.isFunction(c[s]))throw Gr.warn(`missing or invalid JsSIP.Socket method: ${s}`),new Error(`Missing or invalid JsSIP.Socket method: ${s}`)})}catch{return!1}return!0};const Pg=ut,xg=du,r_=xe,kt=new Pg("Transport"),qt={STATUS_CONNECTED:0,STATUS_CONNECTING:1,STATUS_DISCONNECTED:2,SOCKET_STATUS_READY:0,SOCKET_STATUS_ERROR:1,recovery_options:{min_interval:r_.CONNECTION_RECOVERY_MIN_INTERVAL,max_interval:r_.CONNECTION_RECOVERY_MAX_INTERVAL}};var i_=class{constructor(s,i=qt.recovery_options){kt.debug("new()"),this.status=qt.STATUS_DISCONNECTED,this.socket=null,this.sockets=[],this.recovery_options=i,this.recover_attempts=0,this.recovery_timer=null,this.close_requested=!1;try{this.textDecoder=new TextDecoder("utf8")}catch(l){kt.warn(`cannot use TextDecoder: ${l}`)}if(typeof s>"u")throw new TypeError("Invalid argument. undefined 'sockets' argument");s instanceof Array||(s=[s]),s.forEach(function(l){if(!xg.isSocket(l.socket))throw new TypeError("Invalid argument. invalid 'JsSIP.Socket' instance");if(l.weight&&!Number(l.weight))throw new TypeError("Invalid argument. 'weight' attribute is not a number");this.sockets.push({socket:l.socket,weight:l.weight||0,status:qt.SOCKET_STATUS_READY})},this),this._getSocket()}get via_transport(){return this.socket.via_transport}get url(){return this.socket.url}get sip_uri(){return this.socket.sip_uri}connect(){if(kt.debug("connect()"),this.isConnected()){kt.debug("Transport is already connected");return}else if(this.isConnecting()){kt.debug("Transport is connecting");return}this.close_requested=!1,this.status=qt.STATUS_CONNECTING,this.onconnecting({socket:this.socket,attempts:this.recover_attempts}),this.close_requested||(this.socket.onconnect=this._onConnect.bind(this),this.socket.ondisconnect=this._onDisconnect.bind(this),this.socket.ondata=this._onData.bind(this),this.socket.connect())}disconnect(){kt.debug("close()"),this.close_requested=!0,this.recover_attempts=0,this.status=qt.STATUS_DISCONNECTED,this.recovery_timer!==null&&(clearTimeout(this.recovery_timer),this.recovery_timer=null),this.socket.onconnect=()=>{},this.socket.ondisconnect=()=>{},this.socket.ondata=()=>{},this.socket.disconnect(),this.ondisconnect({socket:this.socket,error:!1})}send(s){if(kt.debug("send()"),!this.isConnected())return kt.warn("unable to send message, transport is not connected"),!1;const i=s.toString();return kt.debug(`sending message:
|
116
116
|
|
117
|
-
${
|
118
|
-
`),this.socket.send(
|
119
|
-
`){
|
117
|
+
${i}
|
118
|
+
`),this.socket.send(i)}isConnected(){return this.status===qt.STATUS_CONNECTED}isConnecting(){return this.status===qt.STATUS_CONNECTING}_reconnect(){this.recover_attempts+=1;let s=Math.floor(Math.random()*Math.pow(2,this.recover_attempts)+1);s<this.recovery_options.min_interval?s=this.recovery_options.min_interval:s>this.recovery_options.max_interval&&(s=this.recovery_options.max_interval),kt.debug(`reconnection attempt: ${this.recover_attempts}. next connection attempt in ${s} seconds`),this.recovery_timer=setTimeout(()=>{!this.close_requested&&!(this.isConnected()||this.isConnecting())&&(this._getSocket(),this.connect())},s*1e3)}_getSocket(){let s=[];if(this.sockets.forEach(l=>{l.status!==qt.SOCKET_STATUS_ERROR&&(s.length===0?s.push(l):l.weight>s[0].weight?s=[l]:l.weight===s[0].weight&&s.push(l))}),s.length===0){this.sockets.forEach(l=>{l.status=qt.SOCKET_STATUS_READY}),this._getSocket();return}const i=Math.floor(Math.random()*s.length);this.socket=s[i].socket}_onConnect(){this.recover_attempts=0,this.status=qt.STATUS_CONNECTED,this.recovery_timer!==null&&(clearTimeout(this.recovery_timer),this.recovery_timer=null),this.onconnect({socket:this})}_onDisconnect(s,i,l){this.status=qt.STATUS_DISCONNECTED,this.ondisconnect({socket:this.socket,error:s,code:i,reason:l}),!this.close_requested&&(this.sockets.forEach(function(a){this.socket===a.socket&&(a.status=qt.SOCKET_STATUS_ERROR)},this),this._reconnect(s))}_onData(s){if(s===`\r
|
119
|
+
`){kt.debug("received message with CRLF Keep Alive response");return}else if(typeof s!="string"){try{this.textDecoder?s=this.textDecoder.decode(s):s=String.fromCharCode.apply(null,new Uint8Array(s))}catch{kt.debug("received binary message failed to be converted into string, message discarded");return}kt.debug(`received binary message:
|
120
120
|
|
121
|
-
${
|
122
|
-
`)}else
|
121
|
+
${s}
|
122
|
+
`)}else kt.debug(`received text message:
|
123
123
|
|
124
|
-
${
|
125
|
-
`);this.ondata({transport:this,message:
|
126
|
-
`);if(
|
127
|
-
`,
|
128
|
-
`;for(const
|
129
|
-
`;
|
130
|
-
`,
|
131
|
-
`,
|
132
|
-
`,
|
133
|
-
`,
|
134
|
-
`,ch.send(e)}const Qg=Be(fh);var Wi={};const Jr=wt(),cr=Fe,Nu=Ys(),hh=Tn(),Uu=Ru,xu=Sn;Wi.settings={authorization_user:null,password:null,realm:null,ha1:null,authorization_jwt:null,display_name:null,uri:null,contact_uri:null,instance_id:null,use_preloaded_route:!1,session_timers:!0,session_timers_refresh_method:cr.UPDATE,session_timers_force_refresher:!1,no_answer_timeout:60,register:!0,register_expires:600,registrar_server:null,sockets:null,connection_recovery_max_interval:cr.CONNECTION_RECOVERY_MAX_INTERVAL,connection_recovery_min_interval:cr.CONNECTION_RECOVERY_MIN_INTERVAL,extra_headers:null,via_host:`${Jr.createRandomToken(12)}.invalid`};const lo={mandatory:{sockets(u){const n=[];if(Uu.isSocket(u))n.push({socket:u});else if(Array.isArray(u)&&u.length)for(const a of u)Object.prototype.hasOwnProperty.call(a,"socket")&&Uu.isSocket(a.socket)?n.push(a):Uu.isSocket(a)&&n.push({socket:a});else return;return n},uri(u){/^sip:/i.test(u)||(u=`${cr.SIP}:${u}`);const n=hh.parse(u);if(n)return n.user?n:void 0}},optional:{authorization_user(u){if(Nu.parse(`"${u}"`,"quoted_string")!==-1)return u},authorization_jwt(u){if(typeof u=="string")return u},user_agent(u){if(typeof u=="string")return u},connection_recovery_max_interval(u){if(Jr.isDecimal(u)){const n=Number(u);if(n>0)return n}},connection_recovery_min_interval(u){if(Jr.isDecimal(u)){const n=Number(u);if(n>0)return n}},contact_uri(u){if(typeof u=="string"){const n=Nu.parse(u,"SIP_URI");if(n!==-1)return n}},display_name(u){return u},instance_id(u){if(/^uuid:/i.test(u)&&(u=u.substr(5)),Nu.parse(u,"uuid")!==-1)return u},no_answer_timeout(u){if(Jr.isDecimal(u)){const n=Number(u);if(n>0)return n}},session_timers(u){if(typeof u=="boolean")return u},session_timers_refresh_method(u){if(typeof u=="string"&&(u=u.toUpperCase(),u===cr.INVITE||u===cr.UPDATE))return u},session_timers_force_refresher(u){if(typeof u=="boolean")return u},password(u){return String(u)},realm(u){return String(u)},ha1(u){return String(u)},register(u){if(typeof u=="boolean")return u},register_expires(u){if(Jr.isDecimal(u)){const n=Number(u);if(n>0)return n}},registrar_server(u){/^sip:/i.test(u)||(u=`${cr.SIP}:${u}`);const n=hh.parse(u);if(n)return n.user?void 0:n},use_preloaded_route(u){if(typeof u=="boolean")return u},extra_headers(u){const n=[];if(Array.isArray(u)&&u.length)for(const a of u)typeof a=="string"&&n.push(a);else return;return n}}};Wi.load=(u,n)=>{for(const a in lo.mandatory)if(n.hasOwnProperty(a)){const e=n[a],o=lo.mandatory[a](e);if(o!==void 0)u[a]=o;else throw new xu.ConfigurationError(a,e)}else throw new xu.ConfigurationError(a);for(const a in lo.optional)if(n.hasOwnProperty(a)){const e=n[a];if(Jr.isEmpty(e))continue;const o=lo.optional[a](e);if(o!==void 0)u[a]=o;else throw new xu.ConfigurationError(a,e)}};const Zg=Ct.EventEmitter,ev=Tt,Dt=Fe,tv=Vm,_h=sh,dh=Ig,ph=Ug,Pu=Yr,sv=ih,ro=wt(),nv=Sn,lv=Tn(),rv=ah,Mu=kt,iv=fh,ku=Wi,tt=new ev("UA"),Nt={STATUS_INIT:0,STATUS_READY:1,STATUS_USER_CLOSED:2,STATUS_NOT_READY:3,CONFIGURATION_ERROR:1,NETWORK_ERROR:2};var mh=class extends Zg{static get C(){return Nt}constructor(n){if(tt.debug("new() [configuration:%o]",n),super(),this._cache={credentials:{}},this._configuration=Object.assign({},ku.settings),this._dynConfiguration={},this._dialogs={},this._applicants={},this._sessions={},this._transport=null,this._contact=null,this._status=Nt.STATUS_INIT,this._error=null,this._transactions={nist:{},nict:{},ist:{},ict:{}},this._data={},this._closeTimer=null,n===void 0)throw new TypeError("Not enough arguments");try{this._loadConfig(n)}catch(a){throw this._status=Nt.STATUS_NOT_READY,this._error=Nt.CONFIGURATION_ERROR,a}this._registrator=new tv(this)}get C(){return Nt}get status(){return this._status}get contact(){return this._contact}get configuration(){return this._configuration}get transport(){return this._transport}start(){tt.debug("start()"),this._status===Nt.STATUS_INIT?this._transport.connect():this._status===Nt.STATUS_USER_CLOSED?(tt.debug("restarting UA"),this._closeTimer!==null&&(clearTimeout(this._closeTimer),this._closeTimer=null,this._transport.disconnect()),this._status=Nt.STATUS_INIT,this._transport.connect()):this._status===Nt.STATUS_READY?tt.debug("UA is in READY status, not restarted"):tt.debug("ERROR: connection is down, Auto-Recovery system is trying to reconnect"),this._dynConfiguration.register=this._configuration.register}register(){tt.debug("register()"),this._dynConfiguration.register=!0,this._registrator.register()}unregister(n){tt.debug("unregister()"),this._dynConfiguration.register=!1,this._registrator.unregister(n)}registrator(){return this._registrator}isRegistered(){return this._registrator.registered}isConnected(){return this._transport.isConnected()}call(n,a){tt.debug("call()");const e=new _h(this);return e.connect(n,a),e}sendMessage(n,a,e){tt.debug("sendMessage()");const o=new dh(this);return o.send(n,a,e),o}sendOptions(n,a,e){tt.debug("sendOptions()");const o=new ph(this);return o.send(n,a,e),o}terminateSessions(n){tt.debug("terminateSessions()");for(const a in this._sessions)this._sessions[a].isEnded()||this._sessions[a].terminate(n)}stop(){if(tt.debug("stop()"),this._dynConfiguration={},this._status===Nt.STATUS_USER_CLOSED){tt.debug("UA already closed");return}this._registrator.close();const n=Object.keys(this._sessions).length;for(const e in this._sessions)if(Object.prototype.hasOwnProperty.call(this._sessions,e)){tt.debug(`closing session ${e}`);try{this._sessions[e].terminate()}catch{}}for(const e in this._applicants)if(Object.prototype.hasOwnProperty.call(this._applicants,e))try{this._applicants[e].close()}catch{}this._status=Nt.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)}normalizeTarget(n){return ro.normalizeTarget(n,this._configuration.hostport_params)}get(n){switch(n){case"authorization_user":return this._configuration.authorization_user;case"realm":return this._configuration.realm;case"ha1":return this._configuration.ha1;case"authorization_jwt":return this._configuration.authorization_jwt;default:tt.warn('get() | cannot get "%s" parameter in runtime',n);return}}set(n,a){switch(n){case"authorization_user":{this._configuration.authorization_user=String(a);break}case"password":{this._configuration.password=String(a);break}case"realm":{this._configuration.realm=String(a);break}case"ha1":{this._configuration.ha1=String(a),this._configuration.password=null;break}case"authorization_jwt":{this._configuration.authorization_jwt=String(a);break}case"display_name":{this._configuration.display_name=a;break}default:return tt.warn('set() | cannot set "%s" parameter in runtime',n),!1}return!0}newTransaction(n){this._transactions[n.type][n.id]=n,this.emit("newTransaction",{transaction:n})}destroyTransaction(n){delete this._transactions[n.type][n.id],this.emit("transactionDestroyed",{transaction:n})}newDialog(n){this._dialogs[n.id]=n}destroyDialog(n){delete this._dialogs[n.id]}newMessage(n,a){this._applicants[n]=n,this.emit("newMessage",a)}newOptions(n,a){this._applicants[n]=n,this.emit("newOptions",a)}destroyMessage(n){delete this._applicants[n]}newRTCSession(n,a){this._sessions[n.id]=n,this.emit("newRTCSession",a)}destroyRTCSession(n){delete this._sessions[n.id]}registered(n){this.emit("registered",n)}unregistered(n){this.emit("unregistered",n)}registrationFailed(n){this.emit("registrationFailed",n)}receiveRequest(n){const a=n.method;if(n.ruri.user!==this._configuration.uri.user&&n.ruri.user!==this._contact.uri.user){tt.debug("Request-URI does not point to us"),n.method!==Dt.ACK&&n.reply_sl(404);return}if(n.ruri.scheme===Dt.SIPS){n.reply_sl(416);return}if(Pu.checkTransaction(this,n))return;if(a===Dt.INVITE?new Pu.InviteServerTransaction(this,this._transport,n):a!==Dt.ACK&&a!==Dt.CANCEL&&new Pu.NonInviteServerTransaction(this,this._transport,n),a===Dt.OPTIONS){if(this.listeners("newOptions").length===0){n.reply(200);return}new ph(this).init_incoming(n)}else if(a===Dt.MESSAGE){if(this.listeners("newMessage").length===0){n.reply(405);return}new dh(this).init_incoming(n)}else if(a===Dt.INVITE&&!n.to_tag&&this.listeners("newRTCSession").length===0){n.reply(405);return}let e,o;if(n.to_tag)e=this._findDialog(n.call_id,n.from_tag,n.to_tag),e?e.receiveRequest(n):a===Dt.NOTIFY?(o=this._findSession(n),o?o.receiveRequest(n):(tt.debug("received NOTIFY request for a non existent subscription"),n.reply(481,"Subscription does not exist"))):a!==Dt.ACK&&n.reply(481);else switch(a){case Dt.INVITE:if(window.RTCPeerConnection)if(n.hasHeader("replaces")){const p=n.replaces;e=this._findDialog(p.call_id,p.from_tag,p.to_tag),e?(o=e.owner,o.isEnded()?n.reply(603):o.receiveRequest(n)):n.reply(481)}else o=new _h(this),o.init_incoming(n);else tt.warn("INVITE received but WebRTC is not supported"),n.reply(488);break;case Dt.BYE:n.reply(481);break;case Dt.CANCEL:o=this._findSession(n),o?o.receiveRequest(n):tt.debug("received CANCEL request for a non existent session");break;case Dt.ACK:break;case Dt.NOTIFY:this.emit("sipEvent",{event:n.event,request:n}),n.reply(200);break;default:n.reply(405);break}}_findSession({call_id:n,from_tag:a,to_tag:e}){const o=n+a,p=this._sessions[o],t=n+e,v=this._sessions[t];return p||v||null}_findDialog(n,a,e){let o=n+a+e,p=this._dialogs[o];return p||(o=n+e+a,p=this._dialogs[o],p||null)}_loadConfig(n){try{ku.load(this._configuration,n)}catch(o){throw o}this._configuration.display_name===0&&(this._configuration.display_name="0"),this._configuration.instance_id||(this._configuration.instance_id=ro.newUUID()),this._configuration.jssip_id=ro.createRandomToken(5);const a=this._configuration.uri.clone();a.user=null,this._configuration.hostport_params=a.toString().replace(/^sip:/i,"");try{this._transport=new sv(this._configuration.sockets,{max_interval:this._configuration.connection_recovery_max_interval,min_interval:this._configuration.connection_recovery_min_interval}),this._transport.onconnecting=av.bind(this),this._transport.onconnect=ov.bind(this),this._transport.ondisconnect=uv.bind(this),this._transport.ondata=cv.bind(this)}catch(o){throw tt.warn(o),new nv.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 o=this._configuration.uri.clone();o.user=null,o.clearParams(),o.clearHeaders(),this._configuration.registrar_server=o}this._configuration.no_answer_timeout*=1e3,this._configuration.contact_uri?this._configuration.via_host=this._configuration.contact_uri.host:this._configuration.contact_uri=new lv("sip",ro.createRandomToken(8),this._configuration.via_host,null,{transport:"ws"}),this._contact={pub_gruu:null,temp_gruu:null,uri:this._configuration.contact_uri,toString(o={}){const p=o.anonymous||null,t=o.outbound||null;let v="<";return p?v+=this.temp_gruu||"sip:anonymous@anonymous.invalid;transport=ws":v+=this.pub_gruu||this.uri.toString(),t&&(p?!this.temp_gruu:!this.pub_gruu)&&(v+=";ob"),v+=">",v}};const e=["authorization_user","password","realm","ha1","authorization_jwt","display_name","register"];for(const o in this._configuration)Object.prototype.hasOwnProperty.call(this._configuration,o)&&(e.indexOf(o)!==-1?Object.defineProperty(this._configuration,o,{writable:!0,configurable:!1}):Object.defineProperty(this._configuration,o,{writable:!1,configurable:!1}));tt.debug("configuration parameters after validation:");for(const o in this._configuration)if(Object.prototype.hasOwnProperty.call(ku.settings,o))switch(o){case"uri":case"registrar_server":tt.debug(`- ${o}: ${this._configuration[o]}`);break;case"password":case"ha1":case"authorization_jwt":tt.debug(`- ${o}: NOT SHOWN`);break;default:tt.debug(`- ${o}: ${JSON.stringify(this._configuration[o])}`)}}};function av(u){this.emit("connecting",u)}function ov(u){this._status!==Nt.STATUS_USER_CLOSED&&(this._status=Nt.STATUS_READY,this._error=null,this.emit("connected",u),this._dynConfiguration.register&&this._registrator.register())}function uv(u){const n=["nict","ict","nist","ist"];for(const a of n)for(const e in this._transactions[a])Object.prototype.hasOwnProperty.call(this._transactions[a],e)&&this._transactions[a][e].onTransportError();this.emit("disconnected",u),this._registrator.onTransportClosed(),this._status!==Nt.STATUS_USER_CLOSED&&(this._status=Nt.STATUS_NOT_READY,this._error=Nt.NETWORK_ERROR)}function cv(u){console.log("onTransportData",u);const n=u.transport;let a=u.message;if(a=rv.parseMessage(a,this),!!a&&!(this._status===Nt.STATUS_USER_CLOSED&&a instanceof Mu.IncomingRequest)&&iv(a,this,n)){if(a instanceof Mu.IncomingRequest)a.transport=n,this.receiveRequest(a);else if(a instanceof Mu.IncomingResponse){let e;switch(a.method){case Dt.INVITE:e=this._transactions.ict[a.via_branch],e&&e.receiveResponse(a);break;case Dt.ACK:break;default:e=this._transactions.nict[a.via_branch],e&&e.receiveResponse(a);break}}}}const fv=Be(mh);for(var Ut=[],Lu=0;Lu<256;++Lu)Ut.push((Lu+256).toString(16).slice(1));function hv(u,n=0){return(Ut[u[n+0]]+Ut[u[n+1]]+Ut[u[n+2]]+Ut[u[n+3]]+"-"+Ut[u[n+4]]+Ut[u[n+5]]+"-"+Ut[u[n+6]]+Ut[u[n+7]]+"-"+Ut[u[n+8]]+Ut[u[n+9]]+"-"+Ut[u[n+10]]+Ut[u[n+11]]+Ut[u[n+12]]+Ut[u[n+13]]+Ut[u[n+14]]+Ut[u[n+15]]).toLowerCase()}var io,_v=new Uint8Array(16);function dv(){if(!io&&(io=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!io))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return io(_v)}var pv=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto);const gh={randomUUID:pv};function vh(u,n,a){if(gh.randomUUID&&!n&&!u)return gh.randomUUID();u=u||{};var e=u.random||(u.rng||dv)();if(e[6]=e[6]&15|64,e[8]=e[8]&63|128,n){a=a||0;for(var o=0;o<16;++o)n[a+o]=e[o];return n}return hv(e)}var Ge=wt();const An=Be(Ge),$u=new Ba("Dialog"),el={STATUS_EARLY:1,STATUS_CONFIRMED:2,STATUS_TERMINATED:3};class ao{static get C(){return el}constructor(n,a,e,o=el.STATUS_CONFIRMED){if(this._owner=n,this._ua=n._ua,this._uac_pending_reply=!1,this._uas_pending_reply=!1,a instanceof kt.IncomingResponse&&(o=a.status_code<200?el.STATUS_EARLY:el.STATUS_CONFIRMED),e==="UAS"){this._id={call_id:a.call_id,local_tag:a.to_tag,remote_tag:a.from_tag,toString(){return this.call_id+this.local_tag+this.remote_tag}},this._state=o,this._remote_seqnum=a.cseq,this._local_uri=a.parseHeader("to").uri,this._remote_uri=a.parseHeader("from").uri;let p=a.getHeaders("to")[0].split(";")[0];p=p.match(/<([^>]*)>/)[1],this._remote_target=p,this._route_set=a.getHeaders("record-route"),this._ack_seqnum=this._remote_seqnum}else if(e==="UAC"){this._id={call_id:a.call_id,local_tag:a.from_tag,remote_tag:a.to_tag,toString(){return this.call_id+this.local_tag+this.remote_tag}},this._state=o,this._local_seqnum=a.cseq,this._local_uri=a.parseHeader("from").uri,this._remote_uri=a.parseHeader("to").uri;let p=a.getHeaders("to")[0].split(";")[0];p=p.match(/<([^>]*)>/)[1],this._remote_target=p,this._route_set=a.getHeaders("record-route").reverse(),this._ack_seqnum=null}this._ua.newDialog(this),$u.debug(`new ${e} dialog created with status ${this._state===el.STATUS_EARLY?"EARLY":"CONFIRMED"}`)}get id(){return this._id}get local_seqnum(){return this._local_seqnum}set local_seqnum(n){this._local_seqnum=n}get owner(){return this._owner}get uac_pending_reply(){return this._uac_pending_reply}set uac_pending_reply(n){this._uac_pending_reply=n}get uas_pending_reply(){return this._uas_pending_reply}isTerminated(){return this._status===el.STATUS_TERMINATED}update(n,a){this._state=el.STATUS_CONFIRMED,$u.debug(`dialog ${this._id.toString()} changed to CONFIRMED state`),a==="UAC"&&(this._route_set=n.getHeaders("record-route").reverse())}terminate(){$u.debug(`dialog ${this._id.toString()} deleted`),this._ua.destroyDialog(this),this._state=el.STATUS_TERMINATED}sendRequest(n,a={}){const e=An.cloneArray(a.extraHeaders),o=An.cloneObject(a.eventHandlers),p=a.body||null,t=this._createRequest(n,e,p);return o.onAuthenticated=()=>{this._local_seqnum+=1},new zm(this,t,o).send(),t}receiveRequest(n){this._checkInDialogRequest(n)&&(n.method===Y.ACK&&this._ack_seqnum!==null?this._ack_seqnum=null:n.method===Y.INVITE&&(this._ack_seqnum=n.cseq),this._owner.receiveRequest(n))}_createRequest(n,a,e){a=An.cloneArray(a),this._local_seqnum||(this._local_seqnum=Math.floor(Math.random()*1e4));const o=n===Y.CANCEL||n===Y.ACK?this._local_seqnum:this._local_seqnum+=1;return new kt.OutgoingRequest(n,this._remote_target,this._ua,{cseq:o,call_id:this._id.call_id,from_uri:this._local_uri,from_tag:this._id.local_tag,to_uri:this._remote_uri,to_tag:this._id.remote_tag,route_set:this._route_set},a,e)}_checkInDialogRequest(n){if(!this._remote_seqnum)this._remote_seqnum=n.cseq;else if(n.cseq<this._remote_seqnum)if(n.method===Y.ACK){if(this._ack_seqnum===null||n.cseq!==this._ack_seqnum)return!1}else return n.reply(500),!1;else n.cseq>this._remote_seqnum&&(this._remote_seqnum=n.cseq);if(n.method===Y.INVITE||n.method===Y.UPDATE&&n.body){if(this._uac_pending_reply===!0)n.reply(491);else if(this._uas_pending_reply===!0){const a=(Math.random()*10|0)+1;return n.reply(500,null,[`Retry-After:${a}`]),!1}else{this._uas_pending_reply=!0;const a=()=>{(n.server_transaction.state===os.C.STATUS_ACCEPTED||n.server_transaction.state===os.C.STATUS_COMPLETED||n.server_transaction.state===os.C.STATUS_TERMINATED)&&(n.server_transaction.removeListener("stateChanged",a),this._uas_pending_reply=!1)};n.server_transaction.on("stateChanged",a)}n.hasHeader("contact")&&n.server_transaction.on("stateChanged",()=>{n.server_transaction.state===os.C.STATUS_ACCEPTED&&(this._remote_target=n.parseHeader("contact").uri)})}else n.method===Y.NOTIFY&&n.hasHeader("contact")&&n.server_transaction.on("stateChanged",()=>{n.server_transaction.state===os.C.STATUS_COMPLETED&&(this._remote_target=n.parseHeader("contact").uri)});return!0}}class mv{constructor(n,a){Bs(this,"plugin",null);Bs(this,"rtcpPeer",null);Bs(this,"handleId",0);Bs(this,"info",null);Bs(this,"joinResult",null);Bs(this,"state",{});Bs(this,"stream",null);Bs(this,"loaded",!1);Bs(this,"aTracks",[]);Bs(this,"vTracks",[]);this.info=n,this.plugin=a,this.rtcpPeer=new RTCPeerConnection({iceServers:[]})}get memberInfo(){return{stream:this.stream,joinResult:this.joinResult,sender:this.handleId,type:"subscriber",name:this.info.display,state:this.state,id:this.handleId}}updateMemberState(n){var a;this.state={...this.state,...n||{}},(a=this.plugin)==null||a.session.emit("member:update",this.memberInfo)}updateMemberStateFromMessage(n){var p,t,v,C;const a=(t=(p=n==null?void 0:n.plugindata)==null?void 0:p.data)==null?void 0:t.newStatePublisher,o=((C=(v=n==null?void 0:n.plugindata)==null?void 0:v.data)==null?void 0:C.publisher_state).find(l=>l.id===a);this.updateMemberState(o==null?void 0:o.state)}hangup(){this.rtcpPeer&&(this.rtcpPeer.close(),this.rtcpPeer=null),this.stream&&this.stream.getTracks().forEach(n=>{n.stop()})}}var gv=Tn();const tl=Be(gv),le=new Ba("JanusSession"),vv="/opt/recordings/",ae={STATUS_NULL:0,STATUS_INVITE_SENT:1,STATUS_1XX_RECEIVED:2,STATUS_INVITE_RECEIVED:3,STATUS_WAITING_FOR_ANSWER:4,STATUS_ANSWERED:5,STATUS_WAITING_FOR_ACK:6,STATUS_CANCELED:7,STATUS_TERMINATED:8,STATUS_CONFIRMED:9},oo=["audio","video"];class uo extends Ct.EventEmitter{static get C(){return ae}constructor(n){le.debug("new"),super(),console.log("constructor call"),this._id=null,this._ua=n,this._status=ae.STATUS_NULL,this._dialog=null,this._earlyDialogs={},this._contact=null,this._from_tag=null,this._to_tag=null,this.lastTransaction=0,this._connection=null,this._connectionPromiseQueue=Promise.resolve(),this._request=null,this._is_canceled=!1,this._cancel_reason="",this._is_confirmed=!1,this._late_sdp=!1,this._rtcOfferConstraints=null,this._rtcAnswerConstraints=null,this._localMediaStream=null,this._localMediaStreamLocallyGenerated=!1,this._rtcReady=!0,this._iceReady=!1,this._timers={ackTimer:null,expiresTimer:null,invite2xxTimer:null,userNoAnswerTimer:null},this._direction=null,this._local_identity=null,this._remote_identity=null,this._start_time=null,this._end_time=null,this._audioMuted=!1,this._videoMuted=!1,this._localHold=!1,this._remoteHold=!1,this._sessionTimers={enabled:this._ua.configuration.session_timers,refreshMethod:this._ua.configuration.session_timers_refresh_method,defaultExpires:Y.SESSION_EXPIRES,currentExpires:null,running:!1,refresher:!1,timer:null},this._referSubscribers={},this._candidates=[],this.publishers=[],this.private_id=null,this.memberList={},this.myFeedList=[],this.display_name="",this.stunServers=[{urls:"stun:turn.voicenter.co",credential:"kxsjahnsdjns3eds23esd",username:"turn2es21e"}];const a=vh().replace(/-/g,"").slice(0,12);this.opaque_id=`videoroomtest-${a}`,this._data={}}get C(){return ae}get causes(){return Y.causes}get id(){return this._id}get connection(){return this._connection}get contact(){return this._contact}get direction(){return this._direction}get local_identity(){return this._local_identity}get remote_identity(){return this._remote_identity}get start_time(){return this._start_time}get end_time(){return this._end_time}get data(){return this._data}set data(n){this._data=n}get status(){return this._status}isInProgress(){switch(this._status){case ae.STATUS_NULL:case ae.STATUS_INVITE_SENT:case ae.STATUS_1XX_RECEIVED:case ae.STATUS_INVITE_RECEIVED:case ae.STATUS_WAITING_FOR_ANSWER:return!0;default:return!1}}isEstablished(){switch(this._status){case ae.STATUS_ANSWERED:case ae.STATUS_WAITING_FOR_ACK:case ae.STATUS_CONFIRMED:return!0;default:return!1}}isEnded(){switch(this._status){case ae.STATUS_CANCELED:case ae.STATUS_TERMINATED:return!0;default:return!1}}isMuted(){return{audio:this._audioMuted,video:this._videoMuted}}isOnHold(){return{local:this._localHold,remote:this._remoteHold}}connect(n,a,e={},o){le.debug("connect()"),this.display_name=a;const p=n,t=Ge.cloneObject(e.eventHandlers),v=Ge.cloneArray(e.extraHeaders),C=Ge.cloneObject(e.mediaConstraints,{audio:!0,video:!0}),l=e.mediaStream||null,A=Ge.cloneObject(e.pcConfig,{iceServers:[]}),b=e.rtcConstraints||null,E=e.rtcOfferConstraints||null;if(this._rtcOfferConstraints=E,this._rtcAnswerConstraints=e.rtcAnswerConstraints||null,this._data=e.data||this._data,n===void 0)throw new TypeError("Not enough arguments");if(this._status!==ae.STATUS_NULL)throw new Xn.InvalidStateError(this._status);if(!window.RTCPeerConnection)throw new Xn.NotSupportedError("WebRTC not supported");if(console.log("target",n),n=this._ua.normalizeTarget(n),console.log("normalizeTarget target",n),this.room_id=n.user,!n)throw new TypeError(`Invalid target: ${p}`);this._sessionTimers.enabled&&Ge.isDecimal(e.sessionTimersExpires)&&(e.sessionTimersExpires>=Y.MIN_SESSION_EXPIRES?this._sessionTimers.defaultExpires=e.sessionTimersExpires:this._sessionTimers.defaultExpires=Y.SESSION_EXPIRES);for(const N in t)Object.prototype.hasOwnProperty.call(t,N)&&this.on(N,t[N]);this._from_tag=Ge.newTag();const O=e.anonymous||!1,w={from_tag:this._from_tag};this._contact=this._ua.contact.toString({anonymous:O,outbound:!0}),O?(w.from_display_name="Anonymous",w.from_uri=new tl("sip","anonymous","anonymous.invalid"),v.push(`P-Preferred-Identity: ${this._ua.configuration.uri.toString()}`),v.push("Privacy: id")):e.fromUserName&&(w.from_uri=new tl("sip",e.fromUserName,this._ua.configuration.uri.host),v.push(`P-Preferred-Identity: ${this._ua.configuration.uri.toString()}`)),e.fromDisplayName&&(w.from_display_name=e.fromDisplayName),v.push(`Contact: ${this._contact}`),v.push("Content-Type: application/json"),this._sessionTimers.enabled&&v.push(`Session-Expires: ${this._sessionTimers.defaultExpires}${this._ua.configuration.session_timers_force_refresher?";refresher=uac":""}`),this._request=new kt.InitialOutgoingInviteRequest(n,this._ua,w,v),this._id=this._request.call_id+this._from_tag,this._createRTCConnection(A,b),this._direction="outgoing",this._local_identity=this._request.from,this._remote_identity=this._request.to,console.log("this._remote_identity",this._remote_identity),o&&o(this),this._newJanusSession("local",this._request),this._sendInitialRequest(C,E,l)}init_incoming(n,a){le.debug("init_incoming()");let e;const o=n.hasHeader("Content-Type")?n.getHeader("Content-Type").toLowerCase():void 0;if(n.body&&o!=="application/sdp"){n.reply(415);return}if(this._status=ae.STATUS_INVITE_RECEIVED,this._from_tag=n.from_tag,this._id=n.call_id+this._from_tag,this._request=n,this._contact=this._ua.contact.toString(),n.hasHeader("expires")&&(e=n.getHeader("expires")*1e3),n.to_tag=Ge.newTag(),!this._createDialog(n,"UAS",!0)){n.reply(500,"Missing Contact header field");return}n.body?this._late_sdp=!1:this._late_sdp=!0,this._status=ae.STATUS_WAITING_FOR_ANSWER,this._timers.userNoAnswerTimer=setTimeout(()=>{n.reply(408),this._failed("local",null,Y.causes.NO_ANSWER)},this._ua.configuration.no_answer_timeout),e&&(this._timers.expiresTimer=setTimeout(()=>{this._status===ae.STATUS_WAITING_FOR_ANSWER&&(n.reply(487),this._failed("system",null,Y.causes.EXPIRES))},e)),this._direction="incoming",this._local_identity=n.to,this._remote_identity=n.from,a&&a(this),this._newJanusSession("remote",n),this._status!==ae.STATUS_TERMINATED&&(n.reply(180,null,[`Contact: ${this._contact}`]),this._progress("local",null))}answer(n={}){le.debug("answer()");const a=this._request,e=Ge.cloneArray(n.extraHeaders),o=Ge.cloneObject(n.mediaConstraints),p=n.mediaStream||null,t=Ge.cloneObject(n.pcConfig,{iceServers:[]}),v=n.rtcConstraints||null,C=n.rtcAnswerConstraints||null,l=Ge.cloneObject(n.rtcOfferConstraints);let A,b=!1,E=!1,O=!1,w=!1;if(this._rtcAnswerConstraints=C,this._rtcOfferConstraints=n.rtcOfferConstraints||null,this._data=n.data||this._data,this._direction!=="incoming")throw new Xn.NotSupportedError('"answer" not supported for outgoing RTCSession');if(this._status!==ae.STATUS_WAITING_FOR_ANSWER)throw new Xn.InvalidStateError(this._status);if(this._sessionTimers.enabled&&Ge.isDecimal(n.sessionTimersExpires)&&(n.sessionTimersExpires>=Y.MIN_SESSION_EXPIRES?this._sessionTimers.defaultExpires=n.sessionTimersExpires:this._sessionTimers.defaultExpires=Y.SESSION_EXPIRES),this._status=ae.STATUS_ANSWERED,!this._createDialog(a,"UAS")){a.reply(500,"Error creating dialog");return}clearTimeout(this._timers.userNoAnswerTimer),e.unshift(`Contact: ${this._contact}`);const N=a.parseSDP();Array.isArray(N.media)||(N.media=[N.media]);for(const U of N.media)U.type==="audio"&&(b=!0,(!U.direction||U.direction==="sendrecv")&&(O=!0)),U.type==="video"&&(E=!0,(!U.direction||U.direction==="sendrecv")&&(w=!0));if(p&&o.audio===!1){A=p.getAudioTracks();for(const U of A)p.removeTrack(U)}if(p&&o.video===!1){A=p.getVideoTracks();for(const U of A)p.removeTrack(U)}!p&&o.audio===void 0&&(o.audio=O),!p&&o.video===void 0&&(o.video=w),!p&&!b&&!l.offerToReceiveAudio&&(o.audio=!1),!p&&!E&&!l.offerToReceiveVideo&&(o.video=!1),this._createRTCConnection(t,v),Promise.resolve().then(()=>{if(p)return p;if(o.audio||o.video)return this._localMediaStreamLocallyGenerated=!0,navigator.mediaDevices.getUserMedia(o).catch(U=>{throw this._status===ae.STATUS_TERMINATED?new Error("terminated"):(a.reply(480),this._failed("local",null,Y.causes.USER_DENIED_MEDIA_ACCESS),le.warn('emit "getusermediafailed" [error:%o]',U),this.emit("getusermediafailed",U),new Error("getUserMedia() failed"))})}).then(U=>{if(this._status===ae.STATUS_TERMINATED)throw new Error("terminated");this._localMediaStream=U,U&&U.getTracks().forEach(z=>{this._connection.addTrack(z,U)})}).then(()=>{if(this._late_sdp)return;const U={originator:"remote",type:"offer",sdp:a.body};le.debug('emit "sdp"'),this.emit("sdp",U);const z=new RTCSessionDescription({type:"offer",sdp:U.sdp});return this._connectionPromiseQueue=this._connectionPromiseQueue.then(()=>this._connection.setRemoteDescription(z)).catch(j=>{throw a.reply(488),this._failed("system",null,Y.causes.WEBRTC_ERROR),le.warn('emit "peerconnection:setremotedescriptionfailed" [error:%o]',j),this.emit("peerconnection:setremotedescriptionfailed",j),new Error("peerconnection.setRemoteDescription() failed")}),this._connectionPromiseQueue}).then(()=>{if(this._status===ae.STATUS_TERMINATED)throw new Error("terminated");return this._connecting(a),this._late_sdp?this._createLocalDescription("offer",this._rtcOfferConstraints).catch(()=>{throw a.reply(500),new Error("_createLocalDescription() failed")}):this._createLocalDescription("answer",C).catch(()=>{throw a.reply(500),new Error("_createLocalDescription() failed")})}).then(U=>{if(this._status===ae.STATUS_TERMINATED)throw new Error("terminated");this._handleSessionTimersInIncomingRequest(a,e),a.reply(200,null,e,U,()=>{this._status=ae.STATUS_WAITING_FOR_ACK,this._setInvite2xxTimer(a,U),this._setACKTimer(),this._accepted("local")},()=>{this._failed("system",null,Y.causes.CONNECTION_ERROR)})}).catch(U=>{this._status!==ae.STATUS_TERMINATED&&le.warn(U)})}terminate(n={}){le.debug("terminate()");const a=n.cause||Y.causes.BYE,e=Ge.cloneArray(n.extraHeaders),o=n.body;let p,t=n.status_code,v=n.reason_phrase;if(this._status===ae.STATUS_TERMINATED)throw new Xn.InvalidStateError(this._status);switch(this._status){case ae.STATUS_NULL:case ae.STATUS_INVITE_SENT:case ae.STATUS_1XX_RECEIVED:if(le.debug("canceling session"),t&&(t<200||t>=700))throw new TypeError(`Invalid status_code: ${t}`);t&&(v=v||Y.REASON_PHRASE[t]||"",p=`SIP ;cause=${t} ;text="${v}"`),this._status===ae.STATUS_NULL||this._status===ae.STATUS_INVITE_SENT?(this._is_canceled=!0,this._cancel_reason=p):this._status===ae.STATUS_1XX_RECEIVED&&this._request.cancel(p),this._status=ae.STATUS_CANCELED,this._failed("local",null,Y.causes.CANCELED);break;case ae.STATUS_WAITING_FOR_ANSWER:case ae.STATUS_ANSWERED:if(le.debug("rejecting session"),t=t||480,t<300||t>=700)throw new TypeError(`Invalid status_code: ${t}`);this._request.reply(t,v,e,o),this._failed("local",null,Y.causes.REJECTED);break;case ae.STATUS_WAITING_FOR_ACK:case ae.STATUS_CONFIRMED:if(le.debug("terminating session"),v=n.reason_phrase||Y.REASON_PHRASE[t]||"",t&&(t<200||t>=700))throw new TypeError(`Invalid status_code: ${t}`);if(t&&e.push(`Reason: SIP ;cause=${t}; text="${v}"`),this._status===ae.STATUS_WAITING_FOR_ACK&&this._direction==="incoming"&&this._request.server_transaction.state!==os.C.STATUS_TERMINATED){const C=this._dialog;this.receiveRequest=({method:l})=>{l===Y.ACK&&(this.sendRequest(Y.BYE,{extraHeaders:e,body:o}),C.terminate(),this.closeSession())},this._request.server_transaction.on("stateChanged",()=>{this._request.server_transaction.state===os.C.STATUS_TERMINATED&&(this.sendRequest(Y.BYE,{extraHeaders:e,body:o}),C.terminate(),this.closeSession())}),this._ended("local",null,a),this._dialog=C,console.log("SET DIALOG terminate"),this._ua.newDialog(C)}else{const C={janus:"leave"},l=["Content-Type: application/json","PTYPE: Leave"];this.sendRequest(Y.BYE,{extraHeaders:l,body:JSON.stringify(C)}),this.closeSession(),this._ended("local",null,a)}}}sendInfo(n,a,e={}){if(le.debug("sendInfo()"),this._status!==ae.STATUS_CONFIRMED&&this._status!==ae.STATUS_WAITING_FOR_ACK&&this._status!==ae.STATUS_1XX_RECEIVED)throw new Xn.InvalidStateError(this._status);new Cu(this).send(n,a,e)}mute(n={audio:!0,video:!1}){le.debug("mute()");let a=!1,e=!1;this._audioMuted===!1&&n.audio&&(a=!0,this._audioMuted=!0,this._toggleMuteAudio(!0)),this._videoMuted===!1&&n.video&&(e=!0,this._videoMuted=!0,this._toggleMuteVideo(!0)),(a===!0||e===!0)&&this._onmute({audio:a,video:e})}unmute(n={audio:!0,video:!0}){le.debug("unmute()");let a=!1,e=!1;this._audioMuted===!0&&n.audio&&(a=!0,this._audioMuted=!1,this._localHold===!1&&this._toggleMuteAudio(!1)),this._videoMuted===!0&&n.video&&(e=!0,this._videoMuted=!1,this._localHold===!1&&this._toggleMuteVideo(!1)),(a===!0||e===!0)&&this._onunmute({audio:a,video:e})}hold(n={},a){if(le.debug("hold()"),this._status!==ae.STATUS_WAITING_FOR_ACK&&this._status!==ae.STATUS_CONFIRMED||this._localHold===!0||!this._isReadyToReOffer())return!1;this._localHold=!0,this._onhold("local");const e={succeeded:()=>{a&&a()},failed:()=>{this.terminate({cause:Y.causes.WEBRTC_ERROR,status_code:500,reason_phrase:"Hold Failed"})}};return n.useUpdate?this._sendUpdate({sdpOffer:!0,eventHandlers:e,extraHeaders:n.extraHeaders}):this._sendReinvite({eventHandlers:e,extraHeaders:n.extraHeaders}),!0}unhold(n={},a){if(le.debug("unhold()"),this._status!==ae.STATUS_WAITING_FOR_ACK&&this._status!==ae.STATUS_CONFIRMED||this._localHold===!1||!this._isReadyToReOffer())return!1;this._localHold=!1,this._onunhold("local");const e={succeeded:()=>{a&&a()},failed:()=>{this.terminate({cause:Y.causes.WEBRTC_ERROR,status_code:500,reason_phrase:"Unhold Failed"})}};return n.useUpdate?this._sendUpdate({sdpOffer:!0,eventHandlers:e,extraHeaders:n.extraHeaders}):this._sendReinvite({eventHandlers:e,extraHeaders:n.extraHeaders}),!0}renegotiate(n={},a){le.debug("renegotiate()");const e=n.rtcOfferConstraints||null;if(this._status!==ae.STATUS_WAITING_FOR_ACK&&this._status!==ae.STATUS_CONFIRMED||!this._isReadyToReOffer())return!1;const o={succeeded:()=>{a&&a()},failed:()=>{this.terminate({cause:Y.causes.WEBRTC_ERROR,status_code:500,reason_phrase:"Media Renegotiation Failed"})}};return this._setLocalMediaStatus(),n.useUpdate?this._sendUpdate({sdpOffer:!0,eventHandlers:o,rtcOfferConstraints:e,extraHeaders:n.extraHeaders}):this._sendReinvite({eventHandlers:o,rtcOfferConstraints:e,extraHeaders:n.extraHeaders}),!0}refer(n,a){le.debug("refer()");const e=n;if(this._status!==ae.STATUS_WAITING_FOR_ACK&&this._status!==ae.STATUS_CONFIRMED)return!1;if(n=this._ua.normalizeTarget(n),!n)throw new TypeError(`Invalid target: ${e}`);const o=new dg(this);o.sendRefer(n,a);const p=o.id;return this._referSubscribers[p]=o,o.on("requestFailed",()=>{delete this._referSubscribers[p]}),o.on("accepted",()=>{delete this._referSubscribers[p]}),o.on("failed",()=>{delete this._referSubscribers[p]}),o}sendRequest(n,a){return le.debug("sendRequest()"),this._dialog.sendRequest(n,a)}receiveNotify(n){le.debug("receiveRequest()")}receiveRequest(n){if(le.debug("receiveRequest()"),n.method===Y.CANCEL)(this._status===ae.STATUS_WAITING_FOR_ANSWER||this._status===ae.STATUS_ANSWERED)&&(this._status=ae.STATUS_CANCELED,this._request.reply(487),this._failed("remote",n,Y.causes.CANCELED));else switch(n.method){case Y.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(!n.body){this.terminate({cause:Y.causes.MISSING_SDP,status_code:400});break}const a={originator:"remote",type:"answer",sdp:n.body};le.debug('emit "sdp"'),this.emit("sdp",a);const e=new RTCSessionDescription({type:"answer",sdp:a.sdp});this._connectionPromiseQueue=this._connectionPromiseQueue.then(()=>this._connection.setRemoteDescription(e)).then(()=>{this._is_confirmed||this._confirmed("remote",n)}).catch(o=>{this.terminate({cause:Y.causes.BAD_MEDIA_DESCRIPTION,status_code:488}),le.warn('emit "peerconnection:setremotedescriptionfailed" [error:%o]',o),this.emit("peerconnection:setremotedescriptionfailed",o)})}else this._is_confirmed||this._confirmed("remote",n);break;case Y.BYE:this._status===ae.STATUS_CONFIRMED||this._status===ae.STATUS_WAITING_FOR_ACK?(n.reply(200),this._ended("remote",n,Y.causes.BYE)):this._status===ae.STATUS_INVITE_RECEIVED||this._status===ae.STATUS_WAITING_FOR_ANSWER?(n.reply(200),this._request.reply(487,"BYE Received"),this._ended("remote",n,Y.causes.BYE)):n.reply(403,"Wrong Status");break;case Y.INVITE:this._status===ae.STATUS_CONFIRMED?n.hasHeader("replaces")?this._receiveReplaces(n):this._receiveReinvite(n):n.reply(403,"Wrong Status");break;case Y.INFO:if(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){const a=n.hasHeader("Content-Type")?n.getHeader("Content-Type").toLowerCase():void 0;a&&a.match(/^application\/dtmf-relay/i)?new ng(this).init_incoming(n):a!==void 0?new Cu(this).init_incoming(n):n.reply(415)}else n.reply(403,"Wrong Status");break;case Y.UPDATE:this._status===ae.STATUS_CONFIRMED?this._receiveUpdate(n):n.reply(403,"Wrong Status");break;case Y.REFER:this._status===ae.STATUS_CONFIRMED?this._receiveRefer(n):n.reply(403,"Wrong Status");break;case Y.NOTIFY:this._status===ae.STATUS_CONFIRMED?this._receiveNotify(n):n.reply(403,"Wrong Status");break;default:n.reply(501)}}onTransportError(){le.warn("onTransportError()"),this._status!==ae.STATUS_TERMINATED&&this.terminate({status_code:500,reason_phrase:Y.causes.CONNECTION_ERROR,cause:Y.causes.CONNECTION_ERROR})}onRequestTimeout(){le.warn("onRequestTimeout()"),this._status!==ae.STATUS_TERMINATED&&this.terminate({status_code:408,reason_phrase:Y.causes.REQUEST_TIMEOUT,cause:Y.causes.REQUEST_TIMEOUT})}onDialogError(){le.warn("onDialogError()"),this._status!==ae.STATUS_TERMINATED&&this.terminate({status_code:500,reason_phrase:Y.causes.DIALOG_ERROR,cause:Y.causes.DIALOG_ERROR})}newDTMF(n){le.debug("newDTMF()"),this.emit("newDTMF",n)}newInfo(n){le.debug("newInfo()"),this.emit("newInfo",n)}_isReadyToReOffer(){return this._rtcReady?this._dialog?this._dialog.uac_pending_reply===!0||this._dialog.uas_pending_reply===!0?(le.debug("_isReadyToReOffer() | there is another INVITE/UPDATE transaction in progress"),!1):!0:(le.debug("_isReadyToReOffer() | session not established yet"),!1):(le.debug("_isReadyToReOffer() | internal WebRTC status not ready"),!1)}_close(){if(le.debug("close()"),this._localMediaStream&&this._localMediaStreamLocallyGenerated&&(le.debug("close() | closing local MediaStream"),Ge.closeMediaStream(this._localMediaStream)),this._status!==ae.STATUS_TERMINATED){if(this._status=ae.STATUS_TERMINATED,this._connection)try{this._connection.close()}catch(n){le.warn("close() | error closing the RTCPeerConnection: %o",n)}for(const n in this._timers)Object.prototype.hasOwnProperty.call(this._timers,n)&&clearTimeout(this._timers[n]);clearTimeout(this._sessionTimers.timer),this._dialog&&(this._dialog.terminate(),delete this._dialog);for(const n in this._earlyDialogs)Object.prototype.hasOwnProperty.call(this._earlyDialogs,n)&&(this._earlyDialogs[n].terminate(),delete this._earlyDialogs[n]);for(const n in this._referSubscribers)Object.prototype.hasOwnProperty.call(this._referSubscribers,n)&&delete this._referSubscribers[n];this._ua.destroyRTCSession(this)}}_setInvite2xxTimer(n,a){let e=Pi.T1;function o(){this._status===ae.STATUS_WAITING_FOR_ACK&&(n.reply(200,null,[`Contact: ${this._contact}`],a),e<Pi.T2&&(e=e*2,e>Pi.T2&&(e=Pi.T2)),this._timers.invite2xxTimer=setTimeout(o.bind(this),e))}this._timers.invite2xxTimer=setTimeout(o.bind(this),e)}_setACKTimer(){this._timers.ackTimer=setTimeout(()=>{this._status===ae.STATUS_WAITING_FOR_ACK&&(le.debug("no ACK received, terminating the session"),clearTimeout(this._timers.invite2xxTimer),this.sendRequest(Y.BYE),this._ended("remote",null,Y.causes.NO_ACK))},Pi.TIMER_H)}_createRTCConnection(n,a){this.stunServers,this._connection=new RTCPeerConnection(n,a),this._connection.addEventListener("iceconnectionstatechange",()=>{this._connection.iceConnectionState==="failed"&&this.terminate({cause:Y.causes.RTP_TIMEOUT,status_code:408,reason_phrase:Y.causes.RTP_TIMEOUT})});let e;const o=p=>{this._connection.signalingState!=="stable"&&this._connection.signalingState!=="have-local-offer"||p.candidate&&(this._candidates.push(p.candidate),clearTimeout(e),e=setTimeout(()=>{this.lastTrickleReceived=!0,this.subscribeSent&&!this.isConfigureSent&&(this.addTracks(this.stream.getTracks()),this._ua.emit("changeMainVideoStream",{name:this.display_name,stream:this.stream}),this._sendConfigureMessage({audio:!0,video:!0}).then(()=>{}))},500))};this._connection.onicecandidate=o,le.debug('emit "peerconnection"'),this.emit("peerconnection",{peerconnection:this._connection})}_createLocalDescription(n,a){if(le.debug("createLocalDescription()"),n!=="offer"&&n!=="answer")throw new Error(`createLocalDescription() | invalid type "${n}"`);const e=this._connection;return this._rtcReady=!1,Promise.resolve().then(()=>n==="offer"?e.createOffer(a).catch(o=>(le.warn('emit "peerconnection:createofferfailed" [error:%o]',o),this.emit("peerconnection:createofferfailed",o),Promise.reject(o))):e.createAnswer(a).catch(o=>(le.warn('emit "peerconnection:createanswerfailed" [error:%o]',o),this.emit("peerconnection:createanswerfailed",o),Promise.reject(o)))).then(o=>e.setLocalDescription(o).catch(p=>(this._rtcReady=!0,le.warn('emit "peerconnection:setlocaldescriptionfailed" [error:%o]',p),this.emit("peerconnection:setlocaldescriptionfailed",p),Promise.reject(p)))).then(()=>{const o=a&&a.iceRestart;if(e.iceGatheringState==="complete"&&!o||e.iceGatheringState==="gathering"&&this._iceReady){this._rtcReady=!0;const p={originator:"local",type:n,sdp:e.localDescription.sdp};return le.debug('emit "sdp"'),this.emit("sdp",p),Promise.resolve(p.sdp)}return new Promise(p=>{let t=!1,v,C;this._iceReady=!1;const l=()=>{e.removeEventListener("icecandidate",v),e.removeEventListener("icegatheringstatechange",C),t=!0,this._rtcReady=!0,this._iceReady=!0;const A={originator:"local",type:n,sdp:e.localDescription.sdp};le.debug('emit "sdp"'),this.emit("sdp",A),p(A.sdp)};e.addEventListener("icecandidate",v=A=>{const b=A.candidate;b?this.emit("icecandidate",{candidate:b,ready:l}):t||l()}),e.addEventListener("icegatheringstatechange",C=()=>{e.iceGatheringState==="complete"&&!t&&l()})})})}_createDialog(n,a,e){console.log("_createDialog",n);const o=a==="UAS"?n.to_tag:n.from_tag,p=a==="UAS"?n.from_tag:n.to_tag,t=n.call_id+o+p;console.log("remote_tag",p);let v=this._earlyDialogs[t];if(e)return v?!0:(v=new ao(this,n,a,ao.C.STATUS_EARLY),console.log("SET DIALOG early"),v.error?(console.log("early_dialog error",v.error),le.debug(v.error),this._failed("remote",n,Y.causes.INTERNAL_ERROR),!1):(this._earlyDialogs[t]=v,!0));{if(this._from_tag=n.from_tag,this._to_tag=n.to_tag,v)return v.update(n,a),console.log("SET DIALOG 1"),this._dialog=v,delete this._earlyDialogs[t],!0;const C=new ao(this,n,a);return C.error?(console.log("dialog.error",C.error),le.debug(C.error),this._failed("remote",n,Y.causes.INTERNAL_ERROR),!1):(console.log("AAA SET DIALOG 2"),this._dialog=C,!0)}}_receiveReinvite(n){le.debug("receiveReinvite()");const a=n.hasHeader("Content-Type")?n.getHeader("Content-Type").toLowerCase():void 0,e={request:n,callback:void 0,reject:p.bind(this)};let o=!1;function p(v={}){o=!0;const C=v.status_code||403,l=v.reason_phrase||"",A=Ge.cloneArray(v.extraHeaders);if(this._status!==ae.STATUS_CONFIRMED)return!1;if(C<300||C>=700)throw new TypeError(`Invalid status_code: ${C}`);n.reply(C,l,A)}if(this.emit("reinvite",e),o)return;if(this._late_sdp=!1,!n.body){this._late_sdp=!0,this._remoteHold&&(this._remoteHold=!1,this._onunhold("remote")),this._connectionPromiseQueue=this._connectionPromiseQueue.then(()=>this._createLocalDescription("offer",this._rtcOfferConstraints)).then(v=>{t.call(this,v)}).catch(()=>{n.reply(500)});return}if(a!=="application/sdp"){le.debug("invalid Content-Type"),n.reply(415);return}this._processInDialogSdpOffer(n).then(v=>{this._status!==ae.STATUS_TERMINATED&&t.call(this,v)}).catch(v=>{le.warn(v)});function t(v){const C=[`Contact: ${this._contact}`];this._handleSessionTimersInIncomingRequest(n,C),this._late_sdp&&(v=this._mangleOffer(v)),n.reply(200,null,C,v,()=>{this._status=ae.STATUS_WAITING_FOR_ACK,this._setInvite2xxTimer(n,v),this._setACKTimer()}),typeof e.callback=="function"&&e.callback()}}_receiveUpdate(n){le.debug("receiveUpdate()");const a=n.hasHeader("Content-Type")?n.getHeader("Content-Type").toLowerCase():void 0,e={request:n,callback:void 0,reject:p.bind(this)};let o=!1;function p(v={}){o=!0;const C=v.status_code||403,l=v.reason_phrase||"",A=Ge.cloneArray(v.extraHeaders);if(this._status!==ae.STATUS_CONFIRMED)return!1;if(C<300||C>=700)throw new TypeError(`Invalid status_code: ${C}`);n.reply(C,l,A)}if(this.emit("update",e),o)return;if(!n.body){t.call(this,null);return}if(a!=="application/sdp"){le.debug("invalid Content-Type"),n.reply(415);return}this._processInDialogSdpOffer(n).then(v=>{this._status!==ae.STATUS_TERMINATED&&t.call(this,v)}).catch(v=>{le.warn(v)});function t(v){const C=[`Contact: ${this._contact}`];this._handleSessionTimersInIncomingRequest(n,C),n.reply(200,null,C,v),typeof e.callback=="function"&&e.callback()}}_processInDialogSdpOffer(n){le.debug("_processInDialogSdpOffer()");const a=n.parseSDP();let e=!1;for(const t of a.media){if(oo.indexOf(t.type)===-1)continue;const v=t.direction||a.direction||"sendrecv";if(v==="sendonly"||v==="inactive")e=!0;else{e=!1;break}}const o={originator:"remote",type:"offer",sdp:n.body};le.debug('emit "sdp"'),this.emit("sdp",o);const p=new RTCSessionDescription({type:"offer",sdp:o.sdp});return this._connectionPromiseQueue=this._connectionPromiseQueue.then(()=>{if(this._status===ae.STATUS_TERMINATED)throw new Error("terminated");return this._connection.setRemoteDescription(p).catch(t=>{throw n.reply(488),le.warn('emit "peerconnection:setremotedescriptionfailed" [error:%o]',t),this.emit("peerconnection:setremotedescriptionfailed",t),t})}).then(()=>{if(this._status===ae.STATUS_TERMINATED)throw new Error("terminated");this._remoteHold===!0&&e===!1?(this._remoteHold=!1,this._onunhold("remote")):this._remoteHold===!1&&e===!0&&(this._remoteHold=!0,this._onhold("remote"))}).then(()=>{if(this._status===ae.STATUS_TERMINATED)throw new Error("terminated");return this._createLocalDescription("answer",this._rtcAnswerConstraints).catch(t=>{throw n.reply(500),le.warn('emit "peerconnection:createtelocaldescriptionfailed" [error:%o]',t),t})}).catch(t=>{le.warn("_processInDialogSdpOffer() failed [error: %o]",t)}),this._connectionPromiseQueue}_receiveRefer(n){if(le.debug("receiveRefer()"),!n.refer_to){le.debug("no Refer-To header field present in REFER"),n.reply(400);return}if(n.refer_to.uri.scheme!==Y.SIP){le.debug("Refer-To header field points to a non-SIP URI scheme"),n.reply(416);return}n.reply(202);const a=new cg(this,n.cseq);le.debug('emit "refer"'),this.emit("refer",{request:n,accept:(p,t)=>{e.call(this,p,t)},reject:()=>{o.call(this)}});function e(p,t={}){if(p=typeof p=="function"?p:null,this._status!==ae.STATUS_WAITING_FOR_ACK&&this._status!==ae.STATUS_CONFIRMED)return!1;const v=new uo(this._ua);if(v.on("progress",({response:C})=>{a.notify(C.status_code,C.reason_phrase)}),v.on("accepted",({response:C})=>{a.notify(C.status_code,C.reason_phrase)}),v.on("_failed",({message:C,cause:l})=>{C?a.notify(C.status_code,C.reason_phrase):a.notify(487,l)}),n.refer_to.uri.hasHeader("replaces")){const C=decodeURIComponent(n.refer_to.uri.getHeader("replaces"));t.extraHeaders=Ge.cloneArray(t.extraHeaders),t.extraHeaders.push(`Replaces: ${C}`)}v.connect(n.refer_to.uri.toAor(),t,p)}function o(){a.notify(603)}}_receiveNotify(n){switch(le.debug("receiveNotify()"),n.event||n.reply(400),n.event.event){case"refer":{let a,e;if(n.event.params&&n.event.params.id)a=n.event.params.id,e=this._referSubscribers[a];else if(Object.keys(this._referSubscribers).length===1)e=this._referSubscribers[Object.keys(this._referSubscribers)[0]];else{n.reply(400,"Missing event id parameter");return}if(!e){n.reply(481,"Subscription does not exist");return}e.receiveNotify(n),n.reply(200);break}default:n.reply(489)}}_receiveReplaces(n){le.debug("receiveReplaces()");function a(o){if(this._status!==ae.STATUS_WAITING_FOR_ACK&&this._status!==ae.STATUS_CONFIRMED)return!1;const p=new uo(this._ua);p.on("confirmed",()=>{this.terminate()}),p.init_incoming(n,o)}function e(){le.debug("Replaced INVITE rejected by the user"),n.reply(486)}this.emit("replaces",{request:n,accept:o=>{a.call(this,o)},reject:()=>{e.call(this)}})}_getNextTransactionId(){return(this.lastTransaction+1).toString()}_sendInitialRequest(n,a,e){this.ackSent=!1,this.publisherSubscribeSent=!1;const o=new za(this._ua,this._request,{onRequestTimeout:()=>{this.onRequestTimeout()},onTransportError:()=>{this.onTransportError()},onAuthenticated:p=>{this._request=p},onReceiveResponse:p=>{this._receiveInviteResponse(p)}});Promise.resolve().then(()=>{if(e)return e;if(n.audio||n.video)return this._localMediaStreamLocallyGenerated=!0,navigator.mediaDevices.getUserMedia(n).catch(p=>{throw this._status===ae.STATUS_TERMINATED?new Error("terminated"):(this._failed("local",null,Y.causes.USER_DENIED_MEDIA_ACCESS),le.warn('emit "getusermediafailed" [error:%o]',p),this.emit("getusermediafailed",p),p)})}).then(p=>{if(this._status===ae.STATUS_TERMINATED)throw new Error("terminated");return this._localMediaStream=p,p&&p.getTracks().forEach(t=>{this._connection.addTrack(t,p)}),this._connecting(this._request),this._createLocalDescription("offer",a).catch(t=>{throw this._failed("local",null,Y.causes.WEBRTC_ERROR),t})}).then(p=>{if(this._is_canceled||this._status===ae.STATUS_TERMINATED)throw new Error("terminated");const t={janus:"attach",plugin:"janus.plugin.videoroom",opaque_id:this.opaque_id},v=JSON.stringify(t);this._request.body=v,this._status=ae.STATUS_INVITE_SENT,le.debug('emit "sending" [request:%o]',this._request),this.emit("sending",{request:this._request}),o.send()}).catch(p=>{this._status!==ae.STATUS_TERMINATED&&le.warn(p)})}requestAudioAndVideoPermissions(){return this.loadStream()}async loadStream(){const n={audio:!0,video:!0};try{this.stream=await navigator.mediaDevices.getUserMedia(n)}catch{try{n.video=!1,this.stream=await navigator.mediaDevices.getUserMedia(n)}catch{n.audio=!1,n.video=!1,this.stream=await navigator.mediaDevices.getUserMedia(n)}}return{stream:this.stream,options:n}}addTracks(n){n.forEach(a=>{this._connection.addTrack(a)})}getRecordFileName(){return vv+this.room_id+btoa(unescape(encodeURIComponent(this.displayName)))+Date.now()}async processIceCandidates(){for(let n=0;n<this.iceCandidates.length;n++)await this._connection.addIceCandidate(this.iceCandidates[n]);this.iceCandidates=[]}async _sendConfigureMessage(n){const a={offerToReceiveAudio:!1,offerToReceiveVideo:!1},e=await this._connection.createOffer(a);await this._connection.setLocalDescription(e);const o=this._candidates.map(C=>({janus:"trickle",candidate:C,handle_id:this.handle_id,session_id:this.session_id})),t={configure:{janus:"message",body:{request:"configure",record:!0,filename:this.getRecordFileName(),...n},jsep:e,handle_id:this.handle_id,session_id:this.session_id},trickles:[...o]},v=["Content-Type: application/json","PTYPE: Ice"];this.sendRequest(Y.INFO,{extraHeaders:v,body:JSON.stringify(t),eventHandlers:{onSuccessResponse:async C=>{this.isConfigureSent=!0;const A=C.data.split(`\r
|
135
|
-
`),b=A[A.length-1],E=JSON.parse(b);await this._connection.setRemoteDescription(E.jsep),this._candidates=[]}}})}_sendMemberStartMessage(n,a){const e={janus:"message",body:{request:"start",room:this.room_id},handle_id:n.handleId,session_id:this.session_id,jsep:a},o=["Content-Type: application/json","PTYPE: Configure"];this.sendRequest(Y.INFO,{extraHeaders:o,body:JSON.stringify(e),eventHandlers:{onSuccessResponse:async p=>{p.status_code===200&&await n.rtcpPeer.setLocalDescription(a)}}})}_sendTrickleMessage(n){const e={trickles:[...n.map(p=>({janus:"trickle",candidate:p,handle_id:this.handle_id,session_id:this.session_id}))]},o=["PTYPE: Trickle"];this.sendRequest(Y.INFO,{extraHeaders:o,body:JSON.stringify(e),eventHandlers:{onSuccessResponse:async p=>{console.log("_sendTrickleMessage",p)}}})}async _answerAttachedStream(n,a){let e=null;const o=async C=>{if(!n.rtcpPeer||n.loaded)return;{n.loaded=!0;const O={audio:!0,video:!0};await new Promise(w=>{setTimeout(w,100)}),e=await n.rtcpPeer.createAnswer(O),this._sendMemberStartMessage(n,e)}const l=C.streams[0].getAudioTracks(),A=C.streams[0].getVideoTracks(),b=[];l[0]&&b.push(l[0]),A[0]&&b.push(A[0]);const E=new MediaStream(b);n.stream=E,this._ua.emit("memberJoin",n.memberInfo)};let p,t=[];const v=C=>{n.rtcpPeer.signalingState!=="stable"&&n.rtcpPeer.signalingState!=="have-local-offer"||(t.push(C.candidate||null),clearTimeout(p),p=setTimeout(()=>{this._sendTrickleMessage(t)},500))};n.rtcpPeer=new RTCPeerConnection,n.rtcpPeer.ontrack=o,n.rtcpPeer.onicecandidate=v,n.rtcpPeer.sender=a.sender,await n.rtcpPeer.setRemoteDescription(a.jsep)}_sendJoinMemberRequest(n){const a={janus:"message",body:{request:"join",room:this.room_id,feed:n.info.id,ptype:"subscriber"},handle_id:n.handleId,session_id:this.session_id},e=["PTYPE: Subscriber"];this.sendRequest(Y.SUBSCRIBE,{extraHeaders:e,body:JSON.stringify(a),eventHandlers:{onSuccessResponse:async o=>{var p,t;if(o.status_code===200){const v=JSON.parse(o.body);(t=(p=v==null?void 0:v.plugindata)==null?void 0:p.data)!=null&&t.id&&await this._answerAttachedStream(n,v)}}}})}_attachMember(n){const a={janus:"attach",opaque_id:this.opaque_id,plugin:"janus.plugin.videoroom",session_id:this.session_id},e=["PTYPE: Subscriber"];this.sendRequest(Y.INFO,{extraHeaders:e,body:JSON.stringify(a),eventHandlers:{onSuccessResponse:async o=>{if(o.status_code===200){const t=JSON.parse(o.body).data.id;n.handleId=t,this._sendJoinMemberRequest(n)}}}})}_detachMember(n){const a={janus:"detach",handle_id:n.handleId,session_id:this.session_id},e=["PTYPE: Subscriber"];this.sendRequest(Y.INFO,{extraHeaders:e,body:JSON.stringify(a)}),this._ua.emit("memberHangup",n.memberInfo)}receivePublishers(n){var e,o,p,t,v,C,l,A;const a={...this.memberList};(o=(e=n==null?void 0:n.plugindata)==null?void 0:e.data)==null||o.publishers.forEach(b=>{delete a[b.id],!this.memberList[b.id]&&!this.myFeedList.includes(b.id)&&b.clientID!==this.client_id&&(this.memberList[b.id]=new mv(b,this),this._attachMember(this.memberList[b.id]))}),((t=(p=n==null?void 0:n.plugindata)==null?void 0:p.data)==null?void 0:t.videoroom)==="synced"&&Object.keys(a).forEach(b=>{a[b].hangup(),delete this.memberList[b]}),this.publishers=(C=(v=n==null?void 0:n.plugindata)==null?void 0:v.data)==null?void 0:C.publishers,this.private_id=(A=(l=n==null?void 0:n.plugindata)==null?void 0:l.data)==null?void 0:A.private_id}receiveUnpublished(n){const a=this.memberList[n];a&&(a.hangup(),this._detachMember(a),delete this.memberList[n])}closeSession(){this.stream&&this.stream.getTracks().forEach(a=>{a.stop()}),Object.values(this.memberList).forEach(a=>{a.hangup(),this._detachMember(a)})}_receiveInviteResponse(n){if(le.debug("receiveInviteResponse()"),console.log("_receiveInviteResponse response",n),console.log("dialog",this._dialog),this._dialog&&n.status_code>=200&&n.status_code<=299&&!this.ackSent)if(console.log("IF 1 dialog"),this._dialog.id.call_id===n.call_id&&this._dialog.id.local_tag===n.from_tag&&this._dialog.id.remote_tag===n.to_tag){this.ackSent=!0,this.sendRequest(Y.ACK);return}else{const a=new ao(this,n,"UAC");if(a.error!==void 0){le.debug(a.error);return}this.sendRequest(Y.ACK),this.sendRequest(Y.BYE);return}if(this.ackSent&&!this.publisherSubscribeSent){const a=JSON.parse(n.body);this.requestAudioAndVideoPermissions().then(()=>{this.session_id=a.session_id,this.handle_id=a.data.id,this.client_id=vh();const e={janus:"message",body:{request:"join",room:this.room_id,ptype:"publisher",display:this.display_name,clientID:this.client_id,opaque_id:this.opaque_id},handle_id:this.handle_id},o=["PTYPE: Publisher"];this.sendRequest(Y.SUBSCRIBE,{extraHeaders:o,body:JSON.stringify(e),eventHandlers:{onSuccessResponse:async p=>{var t,v;if(p.status_code===200){if(this.subscribeSent=!0,p.body)try{const C=JSON.parse(p.body)||{};(v=(t=C.plugindata)==null?void 0:t.data)!=null&&v.publishers&&this.receivePublishers(C)}catch(C){console.error(C)}this.lastTrickleReceived&&!this.isConfigureSent&&(this.addTracks(this.stream.getTracks()),this._ua.emit("changeMainVideoStream",{name:this.display_name,stream:this.stream}),this._sendConfigureMessage({audio:!0,video:!0}).then(()=>{}))}}}}),this.publisherSubscribeSent=!0})}if(this._is_canceled){n.status_code>=100&&n.status_code<200?this._request.cancel(this._cancel_reason):n.status_code>=200&&n.status_code<299&&this._acceptAndTerminate(n);return}if(!(this._status!==ae.STATUS_INVITE_SENT&&this._status!==ae.STATUS_1XX_RECEIVED))switch(!0){case/^100$/.test(n.status_code):this._status=ae.STATUS_1XX_RECEIVED;break;case/^1[0-9]{2}$/.test(n.status_code):{if(!n.to_tag){le.debug("1xx response received without to tag");break}if(n.hasHeader("contact")&&!this._createDialog(n,"UAC",!0))break;if(this._status=ae.STATUS_1XX_RECEIVED,!n.body){this._progress("remote",n);break}const a={originator:"remote",type:"answer",sdp:n.body};le.debug('emit "sdp"'),this.emit("sdp",a);const e=new RTCSessionDescription({type:"answer",sdp:a.sdp});this._connectionPromiseQueue=this._connectionPromiseQueue.then(()=>this._connection.setRemoteDescription(e)).then(()=>this._progress("remote",n)).catch(o=>{le.warn('emit "peerconnection:setremotedescriptionfailed" [error:%o]',o),this.emit("peerconnection:setremotedescriptionfailed",o)});break}case/^2[0-9]{2}$/.test(n.status_code):{if(this._status=ae.STATUS_CONFIRMED,!n.body){this._acceptAndTerminate(n,400,Y.causes.MISSING_SDP),this._failed("remote",n,Y.causes.BAD_MEDIA_DESCRIPTION);break}if(!this._createDialog(n,"UAC"))break;break}default:{const a=Ge.sipErrorCause(n.status_code);this._failed("remote",n,a)}}}_sendReinvite(n={}){le.debug("sendReinvite()");const a=Ge.cloneArray(n.extraHeaders),e=Ge.cloneObject(n.eventHandlers),o=n.rtcOfferConstraints||this._rtcOfferConstraints||null;let p=!1;a.push(`Contact: ${this._contact}`),a.push("Content-Type: application/sdp"),this._sessionTimers.running&&a.push(`Session-Expires: ${this._sessionTimers.currentExpires};refresher=${this._sessionTimers.refresher?"uac":"uas"}`),this._connectionPromiseQueue=this._connectionPromiseQueue.then(()=>this._createLocalDescription("offer",o)).then(C=>{C=this._mangleOffer(C);const l={originator:"local",type:"offer",sdp:C};le.debug('emit "sdp"'),this.emit("sdp",l),this.sendRequest(Y.INVITE,{extraHeaders:a,body:C,eventHandlers:{onSuccessResponse:A=>{t.call(this,A),p=!0},onErrorResponse:A=>{v.call(this,A)},onTransportError:()=>{this.onTransportError()},onRequestTimeout:()=>{this.onRequestTimeout()},onDialogError:()=>{this.onDialogError()}}})}).catch(()=>{v()});function t(C){if(this._status===ae.STATUS_TERMINATED||(this.sendRequest(Y.ACK),p))return;if(this._handleSessionTimersInIncomingResponse(C),C.body){if(!C.hasHeader("Content-Type")||C.getHeader("Content-Type").toLowerCase()!=="application/sdp"){v.call(this);return}}else{v.call(this);return}const l={originator:"remote",type:"answer",sdp:C.body};le.debug('emit "sdp"'),this.emit("sdp",l);const A=new RTCSessionDescription({type:"answer",sdp:l.sdp});this._connectionPromiseQueue=this._connectionPromiseQueue.then(()=>this._connection.setRemoteDescription(A)).then(()=>{e.succeeded&&e.succeeded(C)}).catch(b=>{v.call(this),le.warn('emit "peerconnection:setremotedescriptionfailed" [error:%o]',b),this.emit("peerconnection:setremotedescriptionfailed",b)})}function v(C){e.failed&&e.failed(C)}}_sendUpdate(n={}){le.debug("sendUpdate()");const a=Ge.cloneArray(n.extraHeaders),e=Ge.cloneObject(n.eventHandlers),o=n.rtcOfferConstraints||this._rtcOfferConstraints||null,p=n.sdpOffer||!1;let t=!1;a.push(`Contact: ${this._contact}`),this._sessionTimers.running&&a.push(`Session-Expires: ${this._sessionTimers.currentExpires};refresher=${this._sessionTimers.refresher?"uac":"uas"}`),p?(a.push("Content-Type: application/sdp"),this._connectionPromiseQueue=this._connectionPromiseQueue.then(()=>this._createLocalDescription("offer",o)).then(l=>{l=this._mangleOffer(l);const A={originator:"local",type:"offer",sdp:l};le.debug('emit "sdp"'),this.emit("sdp",A),this.sendRequest(Y.UPDATE,{extraHeaders:a,body:l,eventHandlers:{onSuccessResponse:b=>{v.call(this,b),t=!0},onErrorResponse:b=>{C.call(this,b)},onTransportError:()=>{this.onTransportError()},onRequestTimeout:()=>{this.onRequestTimeout()},onDialogError:()=>{this.onDialogError()}}})}).catch(()=>{C.call(this)})):this.sendRequest(Y.UPDATE,{extraHeaders:a,eventHandlers:{onSuccessResponse:l=>{v.call(this,l)},onErrorResponse:l=>{C.call(this,l)},onTransportError:()=>{this.onTransportError()},onRequestTimeout:()=>{this.onRequestTimeout()},onDialogError:()=>{this.onDialogError()}}});function v(l){if(this._status!==ae.STATUS_TERMINATED&&!t)if(this._handleSessionTimersInIncomingResponse(l),p){if(l.body){if(!l.hasHeader("Content-Type")||l.getHeader("Content-Type").toLowerCase()!=="application/sdp"){C.call(this);return}}else{C.call(this);return}const A={originator:"remote",type:"answer",sdp:l.body};le.debug('emit "sdp"'),this.emit("sdp",A);const b=new RTCSessionDescription({type:"answer",sdp:A.sdp});this._connectionPromiseQueue=this._connectionPromiseQueue.then(()=>this._connection.setRemoteDescription(b)).then(()=>{e.succeeded&&e.succeeded(l)}).catch(E=>{C.call(this),le.warn('emit "peerconnection:setremotedescriptionfailed" [error:%o]',E),this.emit("peerconnection:setremotedescriptionfailed",E)})}else e.succeeded&&e.succeeded(l)}function C(l){e.failed&&e.failed(l)}}_acceptAndTerminate(n,a,e){le.debug("acceptAndTerminate()");const o=[];a&&(e=e||Y.REASON_PHRASE[a]||"",o.push(`Reason: SIP ;cause=${a}; text="${e}"`)),(this._dialog||this._createDialog(n,"UAC"))&&(this.sendRequest(Y.ACK),this.sendRequest(Y.BYE,{extraHeaders:o})),this._status=ae.STATUS_TERMINATED}_mangleOffer(n){if(!this._localHold&&!this._remoteHold)return n;if(n=Gt.parse(n),this._localHold&&!this._remoteHold){le.debug("mangleOffer() | me on hold, mangling offer");for(const a of n.media)oo.indexOf(a.type)!==-1&&(a.direction?a.direction==="sendrecv"?a.direction="sendonly":a.direction==="recvonly"&&(a.direction="inactive"):a.direction="sendonly")}else if(this._localHold&&this._remoteHold){le.debug("mangleOffer() | both on hold, mangling offer");for(const a of n.media)oo.indexOf(a.type)!==-1&&(a.direction="inactive")}else if(this._remoteHold){le.debug("mangleOffer() | remote on hold, mangling offer");for(const a of n.media)oo.indexOf(a.type)!==-1&&(a.direction?a.direction==="sendrecv"?a.direction="recvonly":a.direction==="recvonly"&&(a.direction="inactive"):a.direction="recvonly")}return Gt.write(n)}_setLocalMediaStatus(){let n=!0,a=!0;(this._localHold||this._remoteHold)&&(n=!1,a=!1),this._audioMuted&&(n=!1),this._videoMuted&&(a=!1),this._toggleMuteAudio(!n),this._toggleMuteVideo(!a)}_handleSessionTimersInIncomingRequest(n,a){if(!this._sessionTimers.enabled)return;let e;n.session_expires&&n.session_expires>=Y.MIN_SESSION_EXPIRES?(this._sessionTimers.currentExpires=n.session_expires,e=n.session_expires_refresher||"uas"):(this._sessionTimers.currentExpires=this._sessionTimers.defaultExpires,e="uas"),a.push(`Session-Expires: ${this._sessionTimers.currentExpires};refresher=${e}`),this._sessionTimers.refresher=e==="uas",this._runSessionTimer()}_handleSessionTimersInIncomingResponse(n){if(!this._sessionTimers.enabled)return;let a;n.session_expires&&n.session_expires>=Y.MIN_SESSION_EXPIRES?(this._sessionTimers.currentExpires=n.session_expires,a=n.session_expires_refresher||"uac"):(this._sessionTimers.currentExpires=this._sessionTimers.defaultExpires,a="uac"),this._sessionTimers.refresher=a==="uac",this._runSessionTimer()}_runSessionTimer(){const n=this._sessionTimers.currentExpires;this._sessionTimers.running=!0,clearTimeout(this._sessionTimers.timer),this._sessionTimers.refresher?this._sessionTimers.timer=setTimeout(()=>{this._status!==ae.STATUS_TERMINATED&&this._isReadyToReOffer()&&(le.debug("runSessionTimer() | sending session refresh request"),this._sessionTimers.refreshMethod===Y.UPDATE?this._sendUpdate():this._sendReinvite())},n*500):this._sessionTimers.timer=setTimeout(()=>{this._status!==ae.STATUS_TERMINATED&&(le.warn("runSessionTimer() | timer expired, terminating the session"),this.terminate({cause:Y.causes.REQUEST_TIMEOUT,status_code:408,reason_phrase:"Session Timer Expired"}))},n*1100)}_toggleMuteAudio(n){const a=this._connection.getSenders().filter(e=>e.track&&e.track.kind==="audio");for(const e of a)e.track.enabled=!n}_toggleMuteVideo(n){const a=this._connection.getSenders().filter(e=>e.track&&e.track.kind==="video");for(const e of a)e.track.enabled=!n}_newJanusSession(n,a){le.debug("newRTCSession()"),this._ua.newJanusSession(this,{originator:n,session:this,request:a})}_connecting(n){le.debug("session connecting"),le.debug('emit "connecting"'),this.emit("connecting",{request:n})}_progress(n,a){le.debug("session progress"),le.debug('emit "progress"'),this.emit("progress",{originator:n,response:a||null})}_accepted(n,a){le.debug("session accepted"),this._start_time=new Date,le.debug('emit "accepted"'),this.emit("accepted",{originator:n,response:a||null})}_confirmed(n,a){le.debug("session confirmed"),this._is_confirmed=!0,le.debug('emit "confirmed"'),this.emit("confirmed",{originator:n,ack:a||null})}_ended(n,a,e){le.debug("session ended"),this._end_time=new Date,this._close(),le.debug('emit "ended"'),this.emit("ended",{originator:n,message:a||null,cause:e})}_failed(n,a,e){le.debug("session failed"),le.debug('emit "_failed"'),this.emit("_failed",{originator:n,message:a||null,cause:e}),this._close(),le.debug('emit "failed"'),this.emit("failed",{originator:n,message:a||null,cause:e})}_onhold(n){le.debug("session onhold"),this._setLocalMediaStatus(),le.debug('emit "hold"'),this.emit("hold",{originator:n})}_onunhold(n){le.debug("session onunhold"),this._setLocalMediaStatus(),le.debug('emit "unhold"'),this.emit("unhold",{originator:n})}_onmute({audio:n,video:a}){le.debug("session onmute"),this._setLocalMediaStatus(),le.debug('emit "muted"'),this.emit("muted",{audio:n,video:a})}_onunmute({audio:n,video:a}){le.debug("session onunmute"),this._setLocalMediaStatus(),le.debug('emit "unmuted"'),this.emit("unmuted",{audio:n,video:a})}}class Xr{constructor(n){if(this.headers={},n.length>0){let a=!1;const e=n.split(`\r
|
136
|
-
`),
|
137
|
-
`;else{const
|
138
|
-
`;for(const
|
139
|
-
`;return this.body&&(
|
124
|
+
${s}
|
125
|
+
`);this.ondata({transport:this,message:s})}};const Mg=Le(i_);var l_={};const kg=ut,mu=Gt(),gu=bt,_a=new kg("Parser");l_.parseMessage=(c,s)=>{let i,l,a=c.indexOf(`\r
|
126
|
+
`);if(a===-1){_a.warn("parseMessage() | no CRLF found, not a SIP message");return}const _=c.substring(0,a);let e=mu.parse(_,"Request_Response");if(e===-1){_a.warn(`parseMessage() | error parsing first line of SIP message: "${_}"`);return}else e.status_code?(i=new gu.IncomingResponse,i.status_code=e.status_code,i.reason_phrase=e.reason_phrase):(i=new gu.IncomingRequest(s),i.method=e.method,i.ruri=e.uri);i.data=c;let p=a+2;for(;;){if(a=Lg(c,p),a===-2){l=p+2;break}else if(a===-1){_a.warn("parseMessage() | malformed message");return}if(e=$g(i,c,p,a),e!==!0){_a.warn("parseMessage() |",e.error);return}p=a+2}if(i.hasHeader("content-length")){const g=i.getHeader("content-length");i.body=c.substr(l,g)}else i.body=c.substring(l);return i};function Lg(c,s){let i=s,l=0,a=0;if(c.substring(i,i+2).match(/(^\r\n)/))return-2;for(;l===0;){if(a=c.indexOf(`\r
|
127
|
+
`,i),a===-1)return a;!c.substring(a+2,a+4).match(/(^\r\n)/)&&c.charAt(a+2).match(/(^\s+)/)?i=a+2:l=a}return l}function $g(c,s,i,l){let a;const _=s.indexOf(":",i),e=s.substring(i,_).trim(),p=s.substring(_+1,l).trim();switch(e.toLowerCase()){case"via":case"v":c.addHeader("via",p),c.getHeaders("via").length===1?(a=c.parseHeader("Via"),a&&(c.via=a,c.via_branch=a.branch)):a=0;break;case"from":case"f":c.setHeader("from",p),a=c.parseHeader("from"),a&&(c.from=a,c.from_tag=a.getParam("tag"));break;case"to":case"t":c.setHeader("to",p),a=c.parseHeader("to"),a&&(c.to=a,c.to_tag=a.getParam("tag"));break;case"record-route":if(a=mu.parse(p,"Record_Route"),a===-1)a=void 0;else for(const g of a)c.addHeader("record-route",p.substring(g.possition,g.offset)),c.headers["Record-Route"][c.getHeaders("record-route").length-1].parsed=g.parsed;break;case"call-id":case"i":c.setHeader("call-id",p),a=c.parseHeader("call-id"),a&&(c.call_id=p);break;case"contact":case"m":if(a=mu.parse(p,"Contact"),a===-1)a=void 0;else for(const g of a)c.addHeader("contact",p.substring(g.possition,g.offset)),c.headers.Contact[c.getHeaders("contact").length-1].parsed=g.parsed;break;case"content-length":case"l":c.setHeader("content-length",p),a=c.parseHeader("content-length");break;case"content-type":case"c":c.setHeader("content-type",p),a=c.parseHeader("content-type");break;case"cseq":c.setHeader("cseq",p),a=c.parseHeader("cseq"),a&&(c.cseq=a.value),c instanceof gu.IncomingResponse&&(c.method=a.method);break;case"max-forwards":c.setHeader("max-forwards",p),a=c.parseHeader("max-forwards");break;case"www-authenticate":c.setHeader("www-authenticate",p),a=c.parseHeader("www-authenticate");break;case"proxy-authenticate":c.setHeader("proxy-authenticate",p),a=c.parseHeader("proxy-authenticate");break;case"session-expires":case"x":c.setHeader("session-expires",p),a=c.parseHeader("session-expires"),a&&(c.session_expires=a.expires,c.session_expires_refresher=a.refresher);break;case"refer-to":case"r":c.setHeader("refer-to",p),a=c.parseHeader("refer-to"),a&&(c.refer_to=a);break;case"replaces":c.setHeader("replaces",p),a=c.parseHeader("replaces"),a&&(c.replaces=a);break;case"event":case"o":c.setHeader("event",p),a=c.parseHeader("event"),a&&(c.event=a);break;default:c.addHeader(e,p),a=0}return a===void 0?{error:`error parsing header "${e}"`}:!0}const Hg=ut,a_=xe,o_=bt,Tu=Tt(),vu=new Hg("sanityCheck"),Fg=[Jg],jg=[Vg,Bg,Gg,Wg],qg=[Kg,Yg];let Ge,ns,u_;var c_=(c,s,i)=>{Ge=c,ns=s,u_=i;for(const l of Fg)if(l()===!1)return!1;if(Ge instanceof o_.IncomingRequest){for(const l of jg)if(l()===!1)return!1}else if(Ge instanceof o_.IncomingResponse){for(const l of qg)if(l()===!1)return!1}return!0};function Vg(){if(Ge.s("to").uri.scheme!=="sip")return Wr(416),!1}function Bg(){if(!Ge.to_tag&&Ge.call_id.substr(0,5)===ns.configuration.jssip_id)return Wr(482),!1}function Gg(){const c=Tu.str_utf8_length(Ge.body),s=Ge.getHeader("content-length");if(c<s)return Wr(400),!1}function Wg(){const c=Ge.from_tag,s=Ge.call_id,i=Ge.cseq;let l;if(!Ge.to_tag)if(Ge.method===a_.INVITE){if(ns._transactions.ist[Ge.via_branch])return!1;for(const a in ns._transactions.ist)if(Object.prototype.hasOwnProperty.call(ns._transactions.ist,a)&&(l=ns._transactions.ist[a],l.request.from_tag===c&&l.request.call_id===s&&l.request.cseq===i))return Wr(482),!1}else{if(ns._transactions.nist[Ge.via_branch])return!1;for(const a in ns._transactions.nist)if(Object.prototype.hasOwnProperty.call(ns._transactions.nist,a)&&(l=ns._transactions.nist[a],l.request.from_tag===c&&l.request.call_id===s&&l.request.cseq===i))return Wr(482),!1}}function Kg(){if(Ge.getHeaders("via").length>1)return vu.debug("more than one Via header field present in the response, dropping the response"),!1}function Yg(){const c=Tu.str_utf8_length(Ge.body),s=Ge.getHeader("content-length");if(c<s)return vu.debug("message body length is lower than the value in Content-Length header field, dropping the response"),!1}function Jg(){const c=["from","to","call_id","cseq","via"];for(const s of c)if(!Ge.hasHeader(s))return vu.debug(`missing mandatory header field : ${s}, dropping the response`),!1}function Wr(c){const s=Ge.getHeaders("via");let i,l=`SIP/2.0 ${c} ${a_.REASON_PHRASE[c]}\r
|
128
|
+
`;for(const a of s)l+=`Via: ${a}\r
|
129
|
+
`;i=Ge.getHeader("To"),Ge.to_tag||(i+=`;tag=${Tu.newTag()}`),l+=`To: ${i}\r
|
130
|
+
`,l+=`From: ${Ge.getHeader("From")}\r
|
131
|
+
`,l+=`Call-ID: ${Ge.call_id}\r
|
132
|
+
`,l+=`CSeq: ${Ge.cseq} ${Ge.method}\r
|
133
|
+
`,l+=`\r
|
134
|
+
`,u_.send(l)}const zg=Le(c_);var Kr={};const Kn=Tt(),hn=xe,Eu=Gt(),f_=ds(),Su=du,yu=gs;Kr.settings={authorization_user:null,password:null,realm:null,ha1:null,authorization_jwt:null,display_name:null,uri:null,contact_uri:null,instance_id:null,use_preloaded_route:!1,session_timers:!0,session_timers_refresh_method:hn.UPDATE,session_timers_force_refresher:!1,no_answer_timeout:60,register:!0,register_expires:600,registrar_server:null,sockets:null,connection_recovery_max_interval:hn.CONNECTION_RECOVERY_MAX_INTERVAL,connection_recovery_min_interval:hn.CONNECTION_RECOVERY_MIN_INTERVAL,extra_headers:null,via_host:`${Kn.createRandomToken(12)}.invalid`};const ha={mandatory:{sockets(c){const s=[];if(Su.isSocket(c))s.push({socket:c});else if(Array.isArray(c)&&c.length)for(const i of c)Object.prototype.hasOwnProperty.call(i,"socket")&&Su.isSocket(i.socket)?s.push(i):Su.isSocket(i)&&s.push({socket:i});else return;return s},uri(c){/^sip:/i.test(c)||(c=`${hn.SIP}:${c}`);const s=f_.parse(c);if(s)return s.user?s:void 0}},optional:{authorization_user(c){if(Eu.parse(`"${c}"`,"quoted_string")!==-1)return c},authorization_jwt(c){if(typeof c=="string")return c},user_agent(c){if(typeof c=="string")return c},connection_recovery_max_interval(c){if(Kn.isDecimal(c)){const s=Number(c);if(s>0)return s}},connection_recovery_min_interval(c){if(Kn.isDecimal(c)){const s=Number(c);if(s>0)return s}},contact_uri(c){if(typeof c=="string"){const s=Eu.parse(c,"SIP_URI");if(s!==-1)return s}},display_name(c){return c},instance_id(c){if(/^uuid:/i.test(c)&&(c=c.substr(5)),Eu.parse(c,"uuid")!==-1)return c},no_answer_timeout(c){if(Kn.isDecimal(c)){const s=Number(c);if(s>0)return s}},session_timers(c){if(typeof c=="boolean")return c},session_timers_refresh_method(c){if(typeof c=="string"&&(c=c.toUpperCase(),c===hn.INVITE||c===hn.UPDATE))return c},session_timers_force_refresher(c){if(typeof c=="boolean")return c},password(c){return String(c)},realm(c){return String(c)},ha1(c){return String(c)},register(c){if(typeof c=="boolean")return c},register_expires(c){if(Kn.isDecimal(c)){const s=Number(c);if(s>0)return s}},registrar_server(c){/^sip:/i.test(c)||(c=`${hn.SIP}:${c}`);const s=f_.parse(c);if(s)return s.user?void 0:s},use_preloaded_route(c){if(typeof c=="boolean")return c},extra_headers(c){const s=[];if(Array.isArray(c)&&c.length)for(const i of c)typeof i=="string"&&s.push(i);else return;return s}}};Kr.load=(c,s)=>{for(const i in ha.mandatory)if(s.hasOwnProperty(i)){const l=s[i],a=ha.mandatory[i](l);if(a!==void 0)c[i]=a;else throw new yu.ConfigurationError(i,l)}else throw new yu.ConfigurationError(i);for(const i in ha.optional)if(s.hasOwnProperty(i)){const l=s[i];if(Kn.isEmpty(l))continue;const a=ha.optional[i](l);if(a!==void 0)c[i]=a;else throw new yu.ConfigurationError(i,l)}};const Xg=ct.EventEmitter,Qg=ut,Et=xe,Zg=jm,__=t_,h_=Rg,d_=Dg,Au=Gn,eT=i_,da=Tt(),tT=gs,sT=ds(),nT=l_,Cu=bt,rT=c_,Ru=Kr,Ye=new Qg("UA"),St={STATUS_INIT:0,STATUS_READY:1,STATUS_USER_CLOSED:2,STATUS_NOT_READY:3,CONFIGURATION_ERROR:1,NETWORK_ERROR:2};var p_=class extends Xg{static get C(){return St}constructor(s){if(Ye.debug("new() [configuration:%o]",s),super(),this._cache={credentials:{}},this._configuration=Object.assign({},Ru.settings),this._dynConfiguration={},this._dialogs={},this._applicants={},this._sessions={},this._transport=null,this._contact=null,this._status=St.STATUS_INIT,this._error=null,this._transactions={nist:{},nict:{},ist:{},ict:{}},this._data={},this._closeTimer=null,s===void 0)throw new TypeError("Not enough arguments");try{this._loadConfig(s)}catch(i){throw this._status=St.STATUS_NOT_READY,this._error=St.CONFIGURATION_ERROR,i}this._registrator=new Zg(this)}get C(){return St}get status(){return this._status}get contact(){return this._contact}get configuration(){return this._configuration}get transport(){return this._transport}start(){Ye.debug("start()"),this._status===St.STATUS_INIT?this._transport.connect():this._status===St.STATUS_USER_CLOSED?(Ye.debug("restarting UA"),this._closeTimer!==null&&(clearTimeout(this._closeTimer),this._closeTimer=null,this._transport.disconnect()),this._status=St.STATUS_INIT,this._transport.connect()):this._status===St.STATUS_READY?Ye.debug("UA is in READY status, not restarted"):Ye.debug("ERROR: connection is down, Auto-Recovery system is trying to reconnect"),this._dynConfiguration.register=this._configuration.register}register(){Ye.debug("register()"),this._dynConfiguration.register=!0,this._registrator.register()}unregister(s){Ye.debug("unregister()"),this._dynConfiguration.register=!1,this._registrator.unregister(s)}registrator(){return this._registrator}isRegistered(){return this._registrator.registered}isConnected(){return this._transport.isConnected()}call(s,i){Ye.debug("call()");const l=new __(this);return l.connect(s,i),l}sendMessage(s,i,l){Ye.debug("sendMessage()");const a=new h_(this);return a.send(s,i,l),a}sendOptions(s,i,l){Ye.debug("sendOptions()");const a=new d_(this);return a.send(s,i,l),a}terminateSessions(s){Ye.debug("terminateSessions()");for(const i in this._sessions)this._sessions[i].isEnded()||this._sessions[i].terminate(s)}stop(){if(Ye.debug("stop()"),this._dynConfiguration={},this._status===St.STATUS_USER_CLOSED){Ye.debug("UA already closed");return}this._registrator.close();const s=Object.keys(this._sessions).length;for(const l in this._sessions)if(Object.prototype.hasOwnProperty.call(this._sessions,l)){Ye.debug(`closing session ${l}`);try{this._sessions[l].terminate()}catch{}}for(const l in this._applicants)if(Object.prototype.hasOwnProperty.call(this._applicants,l))try{this._applicants[l].close()}catch{}this._status=St.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&&s===0?this._transport.disconnect():this._closeTimer=setTimeout(()=>{this._closeTimer=null,this._transport.disconnect()},2e3)}normalizeTarget(s){return da.normalizeTarget(s,this._configuration.hostport_params)}get(s){switch(s){case"authorization_user":return this._configuration.authorization_user;case"realm":return this._configuration.realm;case"ha1":return this._configuration.ha1;case"authorization_jwt":return this._configuration.authorization_jwt;default:Ye.warn('get() | cannot get "%s" parameter in runtime',s);return}}set(s,i){switch(s){case"authorization_user":{this._configuration.authorization_user=String(i);break}case"password":{this._configuration.password=String(i);break}case"realm":{this._configuration.realm=String(i);break}case"ha1":{this._configuration.ha1=String(i),this._configuration.password=null;break}case"authorization_jwt":{this._configuration.authorization_jwt=String(i);break}case"display_name":{this._configuration.display_name=i;break}default:return Ye.warn('set() | cannot set "%s" parameter in runtime',s),!1}return!0}newTransaction(s){this._transactions[s.type][s.id]=s,this.emit("newTransaction",{transaction:s})}destroyTransaction(s){delete this._transactions[s.type][s.id],this.emit("transactionDestroyed",{transaction:s})}newDialog(s){this._dialogs[s.id]=s}destroyDialog(s){delete this._dialogs[s.id]}newMessage(s,i){this._applicants[s]=s,this.emit("newMessage",i)}newOptions(s,i){this._applicants[s]=s,this.emit("newOptions",i)}destroyMessage(s){delete this._applicants[s]}newRTCSession(s,i){this._sessions[s.id]=s,this.emit("newRTCSession",i)}destroyRTCSession(s){delete this._sessions[s.id]}registered(s){this.emit("registered",s)}unregistered(s){this.emit("unregistered",s)}registrationFailed(s){this.emit("registrationFailed",s)}receiveRequest(s){const i=s.method;if(s.ruri.user!==this._configuration.uri.user&&s.ruri.user!==this._contact.uri.user){Ye.debug("Request-URI does not point to us"),s.method!==Et.ACK&&s.reply_sl(404);return}if(s.ruri.scheme===Et.SIPS){s.reply_sl(416);return}if(Au.checkTransaction(this,s))return;if(i===Et.INVITE?new Au.InviteServerTransaction(this,this._transport,s):i!==Et.ACK&&i!==Et.CANCEL&&new Au.NonInviteServerTransaction(this,this._transport,s),i===Et.OPTIONS){if(this.listeners("newOptions").length===0){s.reply(200);return}new d_(this).init_incoming(s)}else if(i===Et.MESSAGE){if(this.listeners("newMessage").length===0){s.reply(405);return}new h_(this).init_incoming(s)}else if(i===Et.INVITE&&!s.to_tag&&this.listeners("newRTCSession").length===0){s.reply(405);return}let l,a;if(s.to_tag)l=this._findDialog(s.call_id,s.from_tag,s.to_tag),l?l.receiveRequest(s):i===Et.NOTIFY?(a=this._findSession(s),a?a.receiveRequest(s):(Ye.debug("received NOTIFY request for a non existent subscription"),s.reply(481,"Subscription does not exist"))):i!==Et.ACK&&s.reply(481);else switch(i){case Et.INVITE:if(window.RTCPeerConnection)if(s.hasHeader("replaces")){const _=s.replaces;l=this._findDialog(_.call_id,_.from_tag,_.to_tag),l?(a=l.owner,a.isEnded()?s.reply(603):a.receiveRequest(s)):s.reply(481)}else a=new __(this),a.init_incoming(s);else Ye.warn("INVITE received but WebRTC is not supported"),s.reply(488);break;case Et.BYE:s.reply(481);break;case Et.CANCEL:a=this._findSession(s),a?a.receiveRequest(s):Ye.debug("received CANCEL request for a non existent session");break;case Et.ACK:break;case Et.NOTIFY:this.emit("sipEvent",{event:s.event,request:s}),s.reply(200);break;default:s.reply(405);break}}_findSession({call_id:s,from_tag:i,to_tag:l}){const a=s+i,_=this._sessions[a],e=s+l,p=this._sessions[e];return _||p||null}_findDialog(s,i,l){let a=s+i+l,_=this._dialogs[a];return _||(a=s+l+i,_=this._dialogs[a],_||null)}_loadConfig(s){try{Ru.load(this._configuration,s)}catch(a){throw a}this._configuration.display_name===0&&(this._configuration.display_name="0"),this._configuration.instance_id||(this._configuration.instance_id=da.newUUID()),this._configuration.jssip_id=da.createRandomToken(5);const i=this._configuration.uri.clone();i.user=null,this._configuration.hostport_params=i.toString().replace(/^sip:/i,"");try{this._transport=new eT(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=lT.bind(this),this._transport.ondisconnect=aT.bind(this),this._transport.ondata=oT.bind(this)}catch(a){throw Ye.warn(a),new tT.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 a=this._configuration.uri.clone();a.user=null,a.clearParams(),a.clearHeaders(),this._configuration.registrar_server=a}this._configuration.no_answer_timeout*=1e3,this._configuration.contact_uri?this._configuration.via_host=this._configuration.contact_uri.host:this._configuration.contact_uri=new sT("sip",da.createRandomToken(8),this._configuration.via_host,null,{transport:"ws"}),this._contact={pub_gruu:null,temp_gruu:null,uri:this._configuration.contact_uri,toString(a={}){const _=a.anonymous||null,e=a.outbound||null;let p="<";return _?p+=this.temp_gruu||"sip:anonymous@anonymous.invalid;transport=ws":p+=this.pub_gruu||this.uri.toString(),e&&(_?!this.temp_gruu:!this.pub_gruu)&&(p+=";ob"),p+=">",p}};const l=["authorization_user","password","realm","ha1","authorization_jwt","display_name","register"];for(const a in this._configuration)Object.prototype.hasOwnProperty.call(this._configuration,a)&&(l.indexOf(a)!==-1?Object.defineProperty(this._configuration,a,{writable:!0,configurable:!1}):Object.defineProperty(this._configuration,a,{writable:!1,configurable:!1}));Ye.debug("configuration parameters after validation:");for(const a in this._configuration)if(Object.prototype.hasOwnProperty.call(Ru.settings,a))switch(a){case"uri":case"registrar_server":Ye.debug(`- ${a}: ${this._configuration[a]}`);break;case"password":case"ha1":case"authorization_jwt":Ye.debug(`- ${a}: NOT SHOWN`);break;default:Ye.debug(`- ${a}: ${JSON.stringify(this._configuration[a])}`)}}};function iT(c){this.emit("connecting",c)}function lT(c){this._status!==St.STATUS_USER_CLOSED&&(this._status=St.STATUS_READY,this._error=null,this.emit("connected",c),this._dynConfiguration.register&&this._registrator.register())}function aT(c){const s=["nict","ict","nist","ist"];for(const i of s)for(const l in this._transactions[i])Object.prototype.hasOwnProperty.call(this._transactions[i],l)&&this._transactions[i][l].onTransportError();this.emit("disconnected",c),this._registrator.onTransportClosed(),this._status!==St.STATUS_USER_CLOSED&&(this._status=St.STATUS_NOT_READY,this._error=St.NETWORK_ERROR)}function oT(c){console.log("onTransportData",c);const s=c.transport;let i=c.message;if(i=nT.parseMessage(i,this),!!i&&!(this._status===St.STATUS_USER_CLOSED&&i instanceof Cu.IncomingRequest)&&rT(i,this,s)){if(i instanceof Cu.IncomingRequest)i.transport=s,this.receiveRequest(i);else if(i instanceof Cu.IncomingResponse){let l;switch(i.method){case Et.INVITE:l=this._transactions.ict[i.via_branch],l&&l.receiveResponse(i);break;case Et.ACK:break;default:l=this._transactions.nict[i.via_branch],l&&l.receiveResponse(i);break}}}}const uT=Le(p_);for(var yt=[],Iu=0;Iu<256;++Iu)yt.push((Iu+256).toString(16).slice(1));function cT(c,s=0){return(yt[c[s+0]]+yt[c[s+1]]+yt[c[s+2]]+yt[c[s+3]]+"-"+yt[c[s+4]]+yt[c[s+5]]+"-"+yt[c[s+6]]+yt[c[s+7]]+"-"+yt[c[s+8]]+yt[c[s+9]]+"-"+yt[c[s+10]]+yt[c[s+11]]+yt[c[s+12]]+yt[c[s+13]]+yt[c[s+14]]+yt[c[s+15]]).toLowerCase()}var pa,fT=new Uint8Array(16);function _T(){if(!pa&&(pa=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!pa))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return pa(fT)}var hT=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto);const m_={randomUUID:hT};function g_(c,s,i){if(m_.randomUUID&&!s&&!c)return m_.randomUUID();c=c||{};var l=c.random||(c.rng||_T)();if(l[6]=l[6]&15|64,l[8]=l[8]&63|128,s){i=i||0;for(var a=0;a<16;++a)s[i+a]=l[a];return s}return cT(l)}var $e=Tt();const Ts=Le($e),bu=new ea("Dialog"),ks={STATUS_EARLY:1,STATUS_CONFIRMED:2,STATUS_TERMINATED:3};class ma{static get C(){return ks}constructor(s,i,l,a=ks.STATUS_CONFIRMED){if(this._owner=s,this._ua=s._ua,this._uac_pending_reply=!1,this._uas_pending_reply=!1,i instanceof bt.IncomingResponse&&(a=i.status_code<200?ks.STATUS_EARLY:ks.STATUS_CONFIRMED),l==="UAS"){this._id={call_id:i.call_id,local_tag:i.to_tag,remote_tag:i.from_tag,toString(){return this.call_id+this.local_tag+this.remote_tag}},this._state=a,this._remote_seqnum=i.cseq,this._local_uri=i.parseHeader("to").uri,this._remote_uri=i.parseHeader("from").uri;let _=i.getHeaders("to")[0].split(";")[0];_=_.match(/<([^>]*)>/)[1],this._remote_target=_,this._route_set=i.getHeaders("record-route"),this._ack_seqnum=this._remote_seqnum}else if(l==="UAC"){this._id={call_id:i.call_id,local_tag:i.from_tag,remote_tag:i.to_tag,toString(){return this.call_id+this.local_tag+this.remote_tag}},this._state=a,this._local_seqnum=i.cseq,this._local_uri=i.parseHeader("from").uri,this._remote_uri=i.parseHeader("to").uri;let _=i.getHeaders("to")[0].split(";")[0];_=_.match(/<([^>]*)>/)[1],this._remote_target=_,this._route_set=i.getHeaders("record-route").reverse(),this._ack_seqnum=null}this._ua.newDialog(this),bu.debug(`new ${l} dialog created with status ${this._state===ks.STATUS_EARLY?"EARLY":"CONFIRMED"}`)}get id(){return this._id}get local_seqnum(){return this._local_seqnum}set local_seqnum(s){this._local_seqnum=s}get owner(){return this._owner}get uac_pending_reply(){return this._uac_pending_reply}set uac_pending_reply(s){this._uac_pending_reply=s}get uas_pending_reply(){return this._uas_pending_reply}isTerminated(){return this._status===ks.STATUS_TERMINATED}update(s,i){this._state=ks.STATUS_CONFIRMED,bu.debug(`dialog ${this._id.toString()} changed to CONFIRMED state`),i==="UAC"&&(this._route_set=s.getHeaders("record-route").reverse())}terminate(){bu.debug(`dialog ${this._id.toString()} deleted`),this._ua.destroyDialog(this),this._state=ks.STATUS_TERMINATED}sendRequest(s,i={}){const l=Ts.cloneArray(i.extraHeaders),a=Ts.cloneObject(i.eventHandlers),_=i.body||null,e=this._createRequest(s,l,_);return a.onAuthenticated=()=>{this._local_seqnum+=1},new Km(this,e,a).send(),e}receiveRequest(s){this._checkInDialogRequest(s)&&(s.method===F.ACK&&this._ack_seqnum!==null?this._ack_seqnum=null:s.method===F.INVITE&&(this._ack_seqnum=s.cseq),this._owner.receiveRequest(s))}_createRequest(s,i,l){i=Ts.cloneArray(i),this._local_seqnum||(this._local_seqnum=Math.floor(Math.random()*1e4));const a=s===F.CANCEL||s===F.ACK?this._local_seqnum:this._local_seqnum+=1;return new bt.OutgoingRequest(s,this._remote_target,this._ua,{cseq:a,call_id:this._id.call_id,from_uri:this._local_uri,from_tag:this._id.local_tag,to_uri:this._remote_uri,to_tag:this._id.remote_tag,route_set:this._route_set},i,l)}_checkInDialogRequest(s){if(!this._remote_seqnum)this._remote_seqnum=s.cseq;else if(s.cseq<this._remote_seqnum)if(s.method===F.ACK){if(this._ack_seqnum===null||s.cseq!==this._ack_seqnum)return!1}else return s.reply(500),!1;else s.cseq>this._remote_seqnum&&(this._remote_seqnum=s.cseq);if(s.method===F.INVITE||s.method===F.UPDATE&&s.body){if(this._uac_pending_reply===!0)s.reply(491);else if(this._uas_pending_reply===!0){const i=(Math.random()*10|0)+1;return s.reply(500,null,[`Retry-After:${i}`]),!1}else{this._uas_pending_reply=!0;const i=()=>{(s.server_transaction.state===jt.C.STATUS_ACCEPTED||s.server_transaction.state===jt.C.STATUS_COMPLETED||s.server_transaction.state===jt.C.STATUS_TERMINATED)&&(s.server_transaction.removeListener("stateChanged",i),this._uas_pending_reply=!1)};s.server_transaction.on("stateChanged",i)}s.hasHeader("contact")&&s.server_transaction.on("stateChanged",()=>{s.server_transaction.state===jt.C.STATUS_ACCEPTED&&(this._remote_target=s.parseHeader("contact").uri)})}else s.method===F.NOTIFY&&s.hasHeader("contact")&&s.server_transaction.on("stateChanged",()=>{s.server_transaction.state===jt.C.STATUS_COMPLETED&&(this._remote_target=s.parseHeader("contact").uri)});return!0}}class dT{constructor(s,i){Qt(this,"plugin",null);Qt(this,"rtcpPeer",null);Qt(this,"handleId",0);Qt(this,"info",null);Qt(this,"joinResult",null);Qt(this,"state",{});Qt(this,"stream",null);Qt(this,"loaded",!1);Qt(this,"aTracks",[]);Qt(this,"vTracks",[]);this.info=s,this.plugin=i,this.rtcpPeer=new RTCPeerConnection({iceServers:[]})}get memberInfo(){return{stream:this.stream,joinResult:this.joinResult,sender:this.handleId,type:"subscriber",name:this.info.display,state:this.state,id:this.handleId}}updateMemberState(s){var i;this.state={...this.state,...s||{}},(i=this.plugin)==null||i.session.emit("member:update",this.memberInfo)}updateMemberStateFromMessage(s){var _,e,p,g;const i=(e=(_=s==null?void 0:s.plugindata)==null?void 0:_.data)==null?void 0:e.newStatePublisher,a=((g=(p=s==null?void 0:s.plugindata)==null?void 0:p.data)==null?void 0:g.publisher_state).find(n=>n.id===i);this.updateMemberState(a==null?void 0:a.state)}hangup(){this.rtcpPeer&&(this.rtcpPeer.close(),this.rtcpPeer=null),this.stream&&this.stream.getTracks().forEach(s=>{s.stop()})}}var pT=ds();const Yn=Le(pT),X=new ea("JanusSession"),mT="/opt/recordings/",ne={STATUS_NULL:0,STATUS_INVITE_SENT:1,STATUS_1XX_RECEIVED:2,STATUS_INVITE_RECEIVED:3,STATUS_WAITING_FOR_ANSWER:4,STATUS_ANSWERED:5,STATUS_WAITING_FOR_ACK:6,STATUS_CANCELED:7,STATUS_TERMINATED:8,STATUS_CONFIRMED:9},ga=["audio","video"];class Ta extends ct.EventEmitter{static get C(){return ne}constructor(s){X.debug("new"),super(),console.log("constructor call"),this._id=null,this._ua=s,this._status=ne.STATUS_NULL,this._dialog=null,this._earlyDialogs={},this._contact=null,this._from_tag=null,this._to_tag=null,this.lastTransaction=0,this._connection=null,this._connectionPromiseQueue=Promise.resolve(),this._request=null,this._is_canceled=!1,this._cancel_reason="",this._is_confirmed=!1,this._late_sdp=!1,this._rtcOfferConstraints=null,this._rtcAnswerConstraints=null,this._localMediaStream=null,this._localMediaStreamLocallyGenerated=!1,this._rtcReady=!0,this._iceReady=!1,this._timers={ackTimer:null,expiresTimer:null,invite2xxTimer:null,userNoAnswerTimer:null},this._direction=null,this._local_identity=null,this._remote_identity=null,this._start_time=null,this._end_time=null,this._audioMuted=!1,this._videoMuted=!1,this._localHold=!1,this._remoteHold=!1,this._sessionTimers={enabled:this._ua.configuration.session_timers,refreshMethod:this._ua.configuration.session_timers_refresh_method,defaultExpires:F.SESSION_EXPIRES,currentExpires:null,running:!1,refresher:!1,timer:null},this._referSubscribers={},this._candidates=[],this.publishers=[],this.private_id=null,this.memberList={},this.myFeedList=[],this.display_name="",this.stunServers=[{urls:"stun:turn.voicenter.co",credential:"kxsjahnsdjns3eds23esd",username:"turn2es21e"}];const i=g_().replace(/-/g,"").slice(0,12);this.opaque_id=`videoroomtest-${i}`,this._data={}}get C(){return ne}get causes(){return F.causes}get id(){return this._id}get connection(){return this._connection}get contact(){return this._contact}get direction(){return this._direction}get local_identity(){return this._local_identity}get remote_identity(){return this._remote_identity}get start_time(){return this._start_time}get end_time(){return this._end_time}get data(){return this._data}set data(s){this._data=s}get status(){return this._status}isInProgress(){switch(this._status){case ne.STATUS_NULL:case ne.STATUS_INVITE_SENT:case ne.STATUS_1XX_RECEIVED:case ne.STATUS_INVITE_RECEIVED:case ne.STATUS_WAITING_FOR_ANSWER:return!0;default:return!1}}isEstablished(){switch(this._status){case ne.STATUS_ANSWERED:case ne.STATUS_WAITING_FOR_ACK:case ne.STATUS_CONFIRMED:return!0;default:return!1}}isEnded(){switch(this._status){case ne.STATUS_CANCELED:case ne.STATUS_TERMINATED:return!0;default:return!1}}isMuted(){return{audio:this._audioMuted,video:this._videoMuted}}isOnHold(){return{local:this._localHold,remote:this._remoteHold}}connect(s,i,l={},a){X.debug("connect()"),this.display_name=i;const _=s,e=$e.cloneObject(l.eventHandlers),p=$e.cloneArray(l.extraHeaders),g=$e.cloneObject(l.mediaConstraints,{audio:!0,video:!0}),n=l.mediaStream||null,v=$e.cloneObject(l.pcConfig,{iceServers:[]}),S=l.rtcConstraints||null,m=l.rtcOfferConstraints||null;if(this._rtcOfferConstraints=m,this._rtcAnswerConstraints=l.rtcAnswerConstraints||null,this._data=l.data||this._data,s===void 0)throw new TypeError("Not enough arguments");if(this._status!==ne.STATUS_NULL)throw new Ps.InvalidStateError(this._status);if(!window.RTCPeerConnection)throw new Ps.NotSupportedError("WebRTC not supported");if(console.log("target",s),s=this._ua.normalizeTarget(s),console.log("normalizeTarget target",s),this.room_id=s.user,!s)throw new TypeError(`Invalid target: ${_}`);this._sessionTimers.enabled&&$e.isDecimal(l.sessionTimersExpires)&&(l.sessionTimersExpires>=F.MIN_SESSION_EXPIRES?this._sessionTimers.defaultExpires=l.sessionTimersExpires:this._sessionTimers.defaultExpires=F.SESSION_EXPIRES);for(const R in e)Object.prototype.hasOwnProperty.call(e,R)&&this.on(R,e[R]);this._from_tag=$e.newTag();const C=l.anonymous||!1,A={from_tag:this._from_tag};this._contact=this._ua.contact.toString({anonymous:C,outbound:!0}),C?(A.from_display_name="Anonymous",A.from_uri=new Yn("sip","anonymous","anonymous.invalid"),p.push(`P-Preferred-Identity: ${this._ua.configuration.uri.toString()}`),p.push("Privacy: id")):l.fromUserName&&(A.from_uri=new Yn("sip",l.fromUserName,this._ua.configuration.uri.host),p.push(`P-Preferred-Identity: ${this._ua.configuration.uri.toString()}`)),l.fromDisplayName&&(A.from_display_name=l.fromDisplayName),p.push(`Contact: ${this._contact}`),p.push("Content-Type: application/json"),this._sessionTimers.enabled&&p.push(`Session-Expires: ${this._sessionTimers.defaultExpires}${this._ua.configuration.session_timers_force_refresher?";refresher=uac":""}`),this._request=new bt.InitialOutgoingInviteRequest(s,this._ua,A,p),this._id=this._request.call_id+this._from_tag,this._createRTCConnection(v,S),this._direction="outgoing",this._local_identity=this._request.from,this._remote_identity=this._request.to,console.log("this._remote_identity",this._remote_identity),a&&a(this),this._newJanusSession("local",this._request),this._sendInitialRequest(g,m,n)}init_incoming(s,i){X.debug("init_incoming()");let l;const a=s.hasHeader("Content-Type")?s.getHeader("Content-Type").toLowerCase():void 0;if(s.body&&a!=="application/sdp"){s.reply(415);return}if(this._status=ne.STATUS_INVITE_RECEIVED,this._from_tag=s.from_tag,this._id=s.call_id+this._from_tag,this._request=s,this._contact=this._ua.contact.toString(),s.hasHeader("expires")&&(l=s.getHeader("expires")*1e3),s.to_tag=$e.newTag(),!this._createDialog(s,"UAS",!0)){s.reply(500,"Missing Contact header field");return}s.body?this._late_sdp=!1:this._late_sdp=!0,this._status=ne.STATUS_WAITING_FOR_ANSWER,this._timers.userNoAnswerTimer=setTimeout(()=>{s.reply(408),this._failed("local",null,F.causes.NO_ANSWER)},this._ua.configuration.no_answer_timeout),l&&(this._timers.expiresTimer=setTimeout(()=>{this._status===ne.STATUS_WAITING_FOR_ANSWER&&(s.reply(487),this._failed("system",null,F.causes.EXPIRES))},l)),this._direction="incoming",this._local_identity=s.to,this._remote_identity=s.from,i&&i(this),this._newJanusSession("remote",s),this._status!==ne.STATUS_TERMINATED&&(s.reply(180,null,[`Contact: ${this._contact}`]),this._progress("local",null))}answer(s={}){X.debug("answer()");const i=this._request,l=$e.cloneArray(s.extraHeaders),a=$e.cloneObject(s.mediaConstraints),_=s.mediaStream||null,e=$e.cloneObject(s.pcConfig,{iceServers:[]}),p=s.rtcConstraints||null,g=s.rtcAnswerConstraints||null,n=$e.cloneObject(s.rtcOfferConstraints);let v,S=!1,m=!1,C=!1,A=!1;if(this._rtcAnswerConstraints=g,this._rtcOfferConstraints=s.rtcOfferConstraints||null,this._data=s.data||this._data,this._direction!=="incoming")throw new Ps.NotSupportedError('"answer" not supported for outgoing RTCSession');if(this._status!==ne.STATUS_WAITING_FOR_ANSWER)throw new Ps.InvalidStateError(this._status);if(this._sessionTimers.enabled&&$e.isDecimal(s.sessionTimersExpires)&&(s.sessionTimersExpires>=F.MIN_SESSION_EXPIRES?this._sessionTimers.defaultExpires=s.sessionTimersExpires:this._sessionTimers.defaultExpires=F.SESSION_EXPIRES),this._status=ne.STATUS_ANSWERED,!this._createDialog(i,"UAS")){i.reply(500,"Error creating dialog");return}clearTimeout(this._timers.userNoAnswerTimer),l.unshift(`Contact: ${this._contact}`);const R=i.parseSDP();Array.isArray(R.media)||(R.media=[R.media]);for(const I of R.media)I.type==="audio"&&(S=!0,(!I.direction||I.direction==="sendrecv")&&(C=!0)),I.type==="video"&&(m=!0,(!I.direction||I.direction==="sendrecv")&&(A=!0));if(_&&a.audio===!1){v=_.getAudioTracks();for(const I of v)_.removeTrack(I)}if(_&&a.video===!1){v=_.getVideoTracks();for(const I of v)_.removeTrack(I)}!_&&a.audio===void 0&&(a.audio=C),!_&&a.video===void 0&&(a.video=A),!_&&!S&&!n.offerToReceiveAudio&&(a.audio=!1),!_&&!m&&!n.offerToReceiveVideo&&(a.video=!1),this._createRTCConnection(e,p),Promise.resolve().then(()=>{if(_)return _;if(a.audio||a.video)return this._localMediaStreamLocallyGenerated=!0,navigator.mediaDevices.getUserMedia(a).catch(I=>{throw this._status===ne.STATUS_TERMINATED?new Error("terminated"):(i.reply(480),this._failed("local",null,F.causes.USER_DENIED_MEDIA_ACCESS),X.warn('emit "getusermediafailed" [error:%o]',I),this.emit("getusermediafailed",I),new Error("getUserMedia() failed"))})}).then(I=>{if(this._status===ne.STATUS_TERMINATED)throw new Error("terminated");this._localMediaStream=I,I&&I.getTracks().forEach(V=>{this._connection.addTrack(V,I)})}).then(()=>{if(this._late_sdp)return;const I={originator:"remote",type:"offer",sdp:i.body};X.debug('emit "sdp"'),this.emit("sdp",I);const V=new RTCSessionDescription({type:"offer",sdp:I.sdp});return this._connectionPromiseQueue=this._connectionPromiseQueue.then(()=>this._connection.setRemoteDescription(V)).catch(W=>{throw i.reply(488),this._failed("system",null,F.causes.WEBRTC_ERROR),X.warn('emit "peerconnection:setremotedescriptionfailed" [error:%o]',W),this.emit("peerconnection:setremotedescriptionfailed",W),new Error("peerconnection.setRemoteDescription() failed")}),this._connectionPromiseQueue}).then(()=>{if(this._status===ne.STATUS_TERMINATED)throw new Error("terminated");return this._connecting(i),this._late_sdp?this._createLocalDescription("offer",this._rtcOfferConstraints).catch(()=>{throw i.reply(500),new Error("_createLocalDescription() failed")}):this._createLocalDescription("answer",g).catch(()=>{throw i.reply(500),new Error("_createLocalDescription() failed")})}).then(I=>{if(this._status===ne.STATUS_TERMINATED)throw new Error("terminated");this._handleSessionTimersInIncomingRequest(i,l),i.reply(200,null,l,I,()=>{this._status=ne.STATUS_WAITING_FOR_ACK,this._setInvite2xxTimer(i,I),this._setACKTimer(),this._accepted("local")},()=>{this._failed("system",null,F.causes.CONNECTION_ERROR)})}).catch(I=>{this._status!==ne.STATUS_TERMINATED&&X.warn(I)})}terminate(s={}){X.debug("terminate()");const i=s.cause||F.causes.BYE,l=$e.cloneArray(s.extraHeaders),a=s.body;let _,e=s.status_code,p=s.reason_phrase;if(this._status===ne.STATUS_TERMINATED)throw new Ps.InvalidStateError(this._status);switch(this._status){case ne.STATUS_NULL:case ne.STATUS_INVITE_SENT:case ne.STATUS_1XX_RECEIVED:if(X.debug("canceling session"),e&&(e<200||e>=700))throw new TypeError(`Invalid status_code: ${e}`);e&&(p=p||F.REASON_PHRASE[e]||"",_=`SIP ;cause=${e} ;text="${p}"`),this._status===ne.STATUS_NULL||this._status===ne.STATUS_INVITE_SENT?(this._is_canceled=!0,this._cancel_reason=_):this._status===ne.STATUS_1XX_RECEIVED&&this._request.cancel(_),this._status=ne.STATUS_CANCELED,this._failed("local",null,F.causes.CANCELED);break;case ne.STATUS_WAITING_FOR_ANSWER:case ne.STATUS_ANSWERED:if(X.debug("rejecting session"),e=e||480,e<300||e>=700)throw new TypeError(`Invalid status_code: ${e}`);this._request.reply(e,p,l,a),this._failed("local",null,F.causes.REJECTED);break;case ne.STATUS_WAITING_FOR_ACK:case ne.STATUS_CONFIRMED:if(X.debug("terminating session"),p=s.reason_phrase||F.REASON_PHRASE[e]||"",e&&(e<200||e>=700))throw new TypeError(`Invalid status_code: ${e}`);if(e&&l.push(`Reason: SIP ;cause=${e}; text="${p}"`),this._status===ne.STATUS_WAITING_FOR_ACK&&this._direction==="incoming"&&this._request.server_transaction.state!==jt.C.STATUS_TERMINATED){const g=this._dialog;this.receiveRequest=({method:n})=>{n===F.ACK&&(this.sendRequest(F.BYE,{extraHeaders:l,body:a}),g.terminate(),this.closeSession())},this._request.server_transaction.on("stateChanged",()=>{this._request.server_transaction.state===jt.C.STATUS_TERMINATED&&(this.sendRequest(F.BYE,{extraHeaders:l,body:a}),g.terminate(),this.closeSession())}),this._ended("local",null,i),this._dialog=g,console.log("SET DIALOG terminate"),this._ua.newDialog(g)}else{const g={janus:"leave"},n=["Content-Type: application/json","PTYPE: Leave"];this.sendRequest(F.BYE,{extraHeaders:n,body:JSON.stringify(g)}),this.closeSession(),this._ended("local",null,i)}}}sendInfo(s,i,l={}){if(X.debug("sendInfo()"),this._status!==ne.STATUS_CONFIRMED&&this._status!==ne.STATUS_WAITING_FOR_ACK&&this._status!==ne.STATUS_1XX_RECEIVED)throw new Ps.InvalidStateError(this._status);new cu(this).send(s,i,l)}mute(s={audio:!0,video:!1}){X.debug("mute()");let i=!1,l=!1;this._audioMuted===!1&&s.audio&&(i=!0,this._audioMuted=!0,this._toggleMuteAudio(!0)),this._videoMuted===!1&&s.video&&(l=!0,this._videoMuted=!0,this._toggleMuteVideo(!0)),(i===!0||l===!0)&&this._onmute({audio:i,video:l})}unmute(s={audio:!0,video:!0}){X.debug("unmute()");let i=!1,l=!1;this._audioMuted===!0&&s.audio&&(i=!0,this._audioMuted=!1,this._localHold===!1&&this._toggleMuteAudio(!1)),this._videoMuted===!0&&s.video&&(l=!0,this._videoMuted=!1,this._localHold===!1&&this._toggleMuteVideo(!1)),(i===!0||l===!0)&&this._onunmute({audio:i,video:l})}hold(s={},i){if(X.debug("hold()"),this._status!==ne.STATUS_WAITING_FOR_ACK&&this._status!==ne.STATUS_CONFIRMED||this._localHold===!0||!this._isReadyToReOffer())return!1;this._localHold=!0,this._onhold("local");const l={succeeded:()=>{i&&i()},failed:()=>{this.terminate({cause:F.causes.WEBRTC_ERROR,status_code:500,reason_phrase:"Hold Failed"})}};return s.useUpdate?this._sendUpdate({sdpOffer:!0,eventHandlers:l,extraHeaders:s.extraHeaders}):this._sendReinvite({eventHandlers:l,extraHeaders:s.extraHeaders}),!0}unhold(s={},i){if(X.debug("unhold()"),this._status!==ne.STATUS_WAITING_FOR_ACK&&this._status!==ne.STATUS_CONFIRMED||this._localHold===!1||!this._isReadyToReOffer())return!1;this._localHold=!1,this._onunhold("local");const l={succeeded:()=>{i&&i()},failed:()=>{this.terminate({cause:F.causes.WEBRTC_ERROR,status_code:500,reason_phrase:"Unhold Failed"})}};return s.useUpdate?this._sendUpdate({sdpOffer:!0,eventHandlers:l,extraHeaders:s.extraHeaders}):this._sendReinvite({eventHandlers:l,extraHeaders:s.extraHeaders}),!0}renegotiate(s={},i){X.debug("renegotiate()");const l=s.rtcOfferConstraints||null;if(this._status!==ne.STATUS_WAITING_FOR_ACK&&this._status!==ne.STATUS_CONFIRMED||!this._isReadyToReOffer())return!1;const a={succeeded:()=>{i&&i()},failed:()=>{this.terminate({cause:F.causes.WEBRTC_ERROR,status_code:500,reason_phrase:"Media Renegotiation Failed"})}};return this._setLocalMediaStatus(),s.useUpdate?this._sendUpdate({sdpOffer:!0,eventHandlers:a,rtcOfferConstraints:l,extraHeaders:s.extraHeaders}):this._sendReinvite({eventHandlers:a,rtcOfferConstraints:l,extraHeaders:s.extraHeaders}),!0}refer(s,i){X.debug("refer()");const l=s;if(this._status!==ne.STATUS_WAITING_FOR_ACK&&this._status!==ne.STATUS_CONFIRMED)return!1;if(s=this._ua.normalizeTarget(s),!s)throw new TypeError(`Invalid target: ${l}`);const a=new _g(this);a.sendRefer(s,i);const _=a.id;return this._referSubscribers[_]=a,a.on("requestFailed",()=>{delete this._referSubscribers[_]}),a.on("accepted",()=>{delete this._referSubscribers[_]}),a.on("failed",()=>{delete this._referSubscribers[_]}),a}sendRequest(s,i){return X.debug("sendRequest()"),this._dialog.sendRequest(s,i)}receiveNotify(s){X.debug("receiveRequest()")}receiveRequest(s){if(X.debug("receiveRequest()"),s.method===F.CANCEL)(this._status===ne.STATUS_WAITING_FOR_ANSWER||this._status===ne.STATUS_ANSWERED)&&(this._status=ne.STATUS_CANCELED,this._request.reply(487),this._failed("remote",s,F.causes.CANCELED));else switch(s.method){case F.ACK:if(this._status!==ne.STATUS_WAITING_FOR_ACK)return;if(this._status=ne.STATUS_CONFIRMED,clearTimeout(this._timers.ackTimer),clearTimeout(this._timers.invite2xxTimer),this._late_sdp){if(!s.body){this.terminate({cause:F.causes.MISSING_SDP,status_code:400});break}const i={originator:"remote",type:"answer",sdp:s.body};X.debug('emit "sdp"'),this.emit("sdp",i);const l=new RTCSessionDescription({type:"answer",sdp:i.sdp});this._connectionPromiseQueue=this._connectionPromiseQueue.then(()=>this._connection.setRemoteDescription(l)).then(()=>{this._is_confirmed||this._confirmed("remote",s)}).catch(a=>{this.terminate({cause:F.causes.BAD_MEDIA_DESCRIPTION,status_code:488}),X.warn('emit "peerconnection:setremotedescriptionfailed" [error:%o]',a),this.emit("peerconnection:setremotedescriptionfailed",a)})}else this._is_confirmed||this._confirmed("remote",s);break;case F.BYE:this._status===ne.STATUS_CONFIRMED||this._status===ne.STATUS_WAITING_FOR_ACK?(s.reply(200),this._ended("remote",s,F.causes.BYE)):this._status===ne.STATUS_INVITE_RECEIVED||this._status===ne.STATUS_WAITING_FOR_ANSWER?(s.reply(200),this._request.reply(487,"BYE Received"),this._ended("remote",s,F.causes.BYE)):s.reply(403,"Wrong Status");break;case F.INVITE:this._status===ne.STATUS_CONFIRMED?s.hasHeader("replaces")?this._receiveReplaces(s):this._receiveReinvite(s):s.reply(403,"Wrong Status");break;case F.INFO:if(this._status===ne.STATUS_1XX_RECEIVED||this._status===ne.STATUS_WAITING_FOR_ANSWER||this._status===ne.STATUS_ANSWERED||this._status===ne.STATUS_WAITING_FOR_ACK||this._status===ne.STATUS_CONFIRMED){const i=s.hasHeader("Content-Type")?s.getHeader("Content-Type").toLowerCase():void 0;i&&i.match(/^application\/dtmf-relay/i)?new tg(this).init_incoming(s):i!==void 0?new cu(this).init_incoming(s):s.reply(415)}else s.reply(403,"Wrong Status");break;case F.UPDATE:this._status===ne.STATUS_CONFIRMED?this._receiveUpdate(s):s.reply(403,"Wrong Status");break;case F.REFER:this._status===ne.STATUS_CONFIRMED?this._receiveRefer(s):s.reply(403,"Wrong Status");break;case F.NOTIFY:this._status===ne.STATUS_CONFIRMED?this._receiveNotify(s):s.reply(403,"Wrong Status");break;default:s.reply(501)}}onTransportError(){X.warn("onTransportError()"),this._status!==ne.STATUS_TERMINATED&&this.terminate({status_code:500,reason_phrase:F.causes.CONNECTION_ERROR,cause:F.causes.CONNECTION_ERROR})}onRequestTimeout(){X.warn("onRequestTimeout()"),this._status!==ne.STATUS_TERMINATED&&this.terminate({status_code:408,reason_phrase:F.causes.REQUEST_TIMEOUT,cause:F.causes.REQUEST_TIMEOUT})}onDialogError(){X.warn("onDialogError()"),this._status!==ne.STATUS_TERMINATED&&this.terminate({status_code:500,reason_phrase:F.causes.DIALOG_ERROR,cause:F.causes.DIALOG_ERROR})}newDTMF(s){X.debug("newDTMF()"),this.emit("newDTMF",s)}newInfo(s){X.debug("newInfo()"),this.emit("newInfo",s)}_isReadyToReOffer(){return this._rtcReady?this._dialog?this._dialog.uac_pending_reply===!0||this._dialog.uas_pending_reply===!0?(X.debug("_isReadyToReOffer() | there is another INVITE/UPDATE transaction in progress"),!1):!0:(X.debug("_isReadyToReOffer() | session not established yet"),!1):(X.debug("_isReadyToReOffer() | internal WebRTC status not ready"),!1)}_close(){if(X.debug("close()"),this._localMediaStream&&this._localMediaStreamLocallyGenerated&&(X.debug("close() | closing local MediaStream"),$e.closeMediaStream(this._localMediaStream)),this._status!==ne.STATUS_TERMINATED){if(this._status=ne.STATUS_TERMINATED,this._connection)try{this._connection.close()}catch(s){X.warn("close() | error closing the RTCPeerConnection: %o",s)}for(const s in this._timers)Object.prototype.hasOwnProperty.call(this._timers,s)&&clearTimeout(this._timers[s]);clearTimeout(this._sessionTimers.timer),this._dialog&&(this._dialog.terminate(),delete this._dialog);for(const s in this._earlyDialogs)Object.prototype.hasOwnProperty.call(this._earlyDialogs,s)&&(this._earlyDialogs[s].terminate(),delete this._earlyDialogs[s]);for(const s in this._referSubscribers)Object.prototype.hasOwnProperty.call(this._referSubscribers,s)&&delete this._referSubscribers[s];this._ua.destroyRTCSession(this)}}_setInvite2xxTimer(s,i){let l=Mr.T1;function a(){this._status===ne.STATUS_WAITING_FOR_ACK&&(s.reply(200,null,[`Contact: ${this._contact}`],i),l<Mr.T2&&(l=l*2,l>Mr.T2&&(l=Mr.T2)),this._timers.invite2xxTimer=setTimeout(a.bind(this),l))}this._timers.invite2xxTimer=setTimeout(a.bind(this),l)}_setACKTimer(){this._timers.ackTimer=setTimeout(()=>{this._status===ne.STATUS_WAITING_FOR_ACK&&(X.debug("no ACK received, terminating the session"),clearTimeout(this._timers.invite2xxTimer),this.sendRequest(F.BYE),this._ended("remote",null,F.causes.NO_ACK))},Mr.TIMER_H)}_createRTCConnection(s,i){this.stunServers,this._connection=new RTCPeerConnection(s,i),this._connection.addEventListener("iceconnectionstatechange",()=>{this._connection.iceConnectionState==="failed"&&this.terminate({cause:F.causes.RTP_TIMEOUT,status_code:408,reason_phrase:F.causes.RTP_TIMEOUT})});let l;const a=_=>{this._connection.signalingState!=="stable"&&this._connection.signalingState!=="have-local-offer"||_.candidate&&(this._candidates.push(_.candidate),clearTimeout(l),l=setTimeout(()=>{this.lastTrickleReceived=!0,this.subscribeSent&&!this.isConfigureSent&&(this.addTracks(this.stream.getTracks()),this._ua.emit("changeMainVideoStream",{name:this.display_name,stream:this.stream}),this._sendConfigureMessage({audio:!0,video:!0}).then(()=>{}))},500))};this._connection.onicecandidate=a,X.debug('emit "peerconnection"'),this.emit("peerconnection",{peerconnection:this._connection})}_createLocalDescription(s,i){if(X.debug("createLocalDescription()"),s!=="offer"&&s!=="answer")throw new Error(`createLocalDescription() | invalid type "${s}"`);const l=this._connection;return this._rtcReady=!1,Promise.resolve().then(()=>s==="offer"?l.createOffer(i).catch(a=>(X.warn('emit "peerconnection:createofferfailed" [error:%o]',a),this.emit("peerconnection:createofferfailed",a),Promise.reject(a))):l.createAnswer(i).catch(a=>(X.warn('emit "peerconnection:createanswerfailed" [error:%o]',a),this.emit("peerconnection:createanswerfailed",a),Promise.reject(a)))).then(a=>l.setLocalDescription(a).catch(_=>(this._rtcReady=!0,X.warn('emit "peerconnection:setlocaldescriptionfailed" [error:%o]',_),this.emit("peerconnection:setlocaldescriptionfailed",_),Promise.reject(_)))).then(()=>{const a=i&&i.iceRestart;if(l.iceGatheringState==="complete"&&!a||l.iceGatheringState==="gathering"&&this._iceReady){this._rtcReady=!0;const _={originator:"local",type:s,sdp:l.localDescription.sdp};return X.debug('emit "sdp"'),this.emit("sdp",_),Promise.resolve(_.sdp)}return new Promise(_=>{let e=!1,p,g;this._iceReady=!1;const n=()=>{l.removeEventListener("icecandidate",p),l.removeEventListener("icegatheringstatechange",g),e=!0,this._rtcReady=!0,this._iceReady=!0;const v={originator:"local",type:s,sdp:l.localDescription.sdp};X.debug('emit "sdp"'),this.emit("sdp",v),_(v.sdp)};l.addEventListener("icecandidate",p=v=>{const S=v.candidate;S?this.emit("icecandidate",{candidate:S,ready:n}):e||n()}),l.addEventListener("icegatheringstatechange",g=()=>{l.iceGatheringState==="complete"&&!e&&n()})})})}_createDialog(s,i,l){console.log("_createDialog",s);const a=i==="UAS"?s.to_tag:s.from_tag,_=i==="UAS"?s.from_tag:s.to_tag,e=s.call_id+a+_;console.log("remote_tag",_);let p=this._earlyDialogs[e];if(l)return p?!0:(p=new ma(this,s,i,ma.C.STATUS_EARLY),console.log("SET DIALOG early"),p.error?(console.log("early_dialog error",p.error),X.debug(p.error),this._failed("remote",s,F.causes.INTERNAL_ERROR),!1):(this._earlyDialogs[e]=p,!0));{if(this._from_tag=s.from_tag,this._to_tag=s.to_tag,p)return p.update(s,i),console.log("SET DIALOG 1"),this._dialog=p,delete this._earlyDialogs[e],!0;const g=new ma(this,s,i);return g.error?(console.log("dialog.error",g.error),X.debug(g.error),this._failed("remote",s,F.causes.INTERNAL_ERROR),!1):(console.log("AAA SET DIALOG 2"),this._dialog=g,!0)}}_receiveReinvite(s){X.debug("receiveReinvite()");const i=s.hasHeader("Content-Type")?s.getHeader("Content-Type").toLowerCase():void 0,l={request:s,callback:void 0,reject:_.bind(this)};let a=!1;function _(p={}){a=!0;const g=p.status_code||403,n=p.reason_phrase||"",v=$e.cloneArray(p.extraHeaders);if(this._status!==ne.STATUS_CONFIRMED)return!1;if(g<300||g>=700)throw new TypeError(`Invalid status_code: ${g}`);s.reply(g,n,v)}if(this.emit("reinvite",l),a)return;if(this._late_sdp=!1,!s.body){this._late_sdp=!0,this._remoteHold&&(this._remoteHold=!1,this._onunhold("remote")),this._connectionPromiseQueue=this._connectionPromiseQueue.then(()=>this._createLocalDescription("offer",this._rtcOfferConstraints)).then(p=>{e.call(this,p)}).catch(()=>{s.reply(500)});return}if(i!=="application/sdp"){X.debug("invalid Content-Type"),s.reply(415);return}this._processInDialogSdpOffer(s).then(p=>{this._status!==ne.STATUS_TERMINATED&&e.call(this,p)}).catch(p=>{X.warn(p)});function e(p){const g=[`Contact: ${this._contact}`];this._handleSessionTimersInIncomingRequest(s,g),this._late_sdp&&(p=this._mangleOffer(p)),s.reply(200,null,g,p,()=>{this._status=ne.STATUS_WAITING_FOR_ACK,this._setInvite2xxTimer(s,p),this._setACKTimer()}),typeof l.callback=="function"&&l.callback()}}_receiveUpdate(s){X.debug("receiveUpdate()");const i=s.hasHeader("Content-Type")?s.getHeader("Content-Type").toLowerCase():void 0,l={request:s,callback:void 0,reject:_.bind(this)};let a=!1;function _(p={}){a=!0;const g=p.status_code||403,n=p.reason_phrase||"",v=$e.cloneArray(p.extraHeaders);if(this._status!==ne.STATUS_CONFIRMED)return!1;if(g<300||g>=700)throw new TypeError(`Invalid status_code: ${g}`);s.reply(g,n,v)}if(this.emit("update",l),a)return;if(!s.body){e.call(this,null);return}if(i!=="application/sdp"){X.debug("invalid Content-Type"),s.reply(415);return}this._processInDialogSdpOffer(s).then(p=>{this._status!==ne.STATUS_TERMINATED&&e.call(this,p)}).catch(p=>{X.warn(p)});function e(p){const g=[`Contact: ${this._contact}`];this._handleSessionTimersInIncomingRequest(s,g),s.reply(200,null,g,p),typeof l.callback=="function"&&l.callback()}}_processInDialogSdpOffer(s){X.debug("_processInDialogSdpOffer()");const i=s.parseSDP();let l=!1;for(const e of i.media){if(ga.indexOf(e.type)===-1)continue;const p=e.direction||i.direction||"sendrecv";if(p==="sendonly"||p==="inactive")l=!0;else{l=!1;break}}const a={originator:"remote",type:"offer",sdp:s.body};X.debug('emit "sdp"'),this.emit("sdp",a);const _=new RTCSessionDescription({type:"offer",sdp:a.sdp});return this._connectionPromiseQueue=this._connectionPromiseQueue.then(()=>{if(this._status===ne.STATUS_TERMINATED)throw new Error("terminated");return this._connection.setRemoteDescription(_).catch(e=>{throw s.reply(488),X.warn('emit "peerconnection:setremotedescriptionfailed" [error:%o]',e),this.emit("peerconnection:setremotedescriptionfailed",e),e})}).then(()=>{if(this._status===ne.STATUS_TERMINATED)throw new Error("terminated");this._remoteHold===!0&&l===!1?(this._remoteHold=!1,this._onunhold("remote")):this._remoteHold===!1&&l===!0&&(this._remoteHold=!0,this._onhold("remote"))}).then(()=>{if(this._status===ne.STATUS_TERMINATED)throw new Error("terminated");return this._createLocalDescription("answer",this._rtcAnswerConstraints).catch(e=>{throw s.reply(500),X.warn('emit "peerconnection:createtelocaldescriptionfailed" [error:%o]',e),e})}).catch(e=>{X.warn("_processInDialogSdpOffer() failed [error: %o]",e)}),this._connectionPromiseQueue}_receiveRefer(s){if(X.debug("receiveRefer()"),!s.refer_to){X.debug("no Refer-To header field present in REFER"),s.reply(400);return}if(s.refer_to.uri.scheme!==F.SIP){X.debug("Refer-To header field points to a non-SIP URI scheme"),s.reply(416);return}s.reply(202);const i=new og(this,s.cseq);X.debug('emit "refer"'),this.emit("refer",{request:s,accept:(_,e)=>{l.call(this,_,e)},reject:()=>{a.call(this)}});function l(_,e={}){if(_=typeof _=="function"?_:null,this._status!==ne.STATUS_WAITING_FOR_ACK&&this._status!==ne.STATUS_CONFIRMED)return!1;const p=new Ta(this._ua);if(p.on("progress",({response:g})=>{i.notify(g.status_code,g.reason_phrase)}),p.on("accepted",({response:g})=>{i.notify(g.status_code,g.reason_phrase)}),p.on("_failed",({message:g,cause:n})=>{g?i.notify(g.status_code,g.reason_phrase):i.notify(487,n)}),s.refer_to.uri.hasHeader("replaces")){const g=decodeURIComponent(s.refer_to.uri.getHeader("replaces"));e.extraHeaders=$e.cloneArray(e.extraHeaders),e.extraHeaders.push(`Replaces: ${g}`)}p.connect(s.refer_to.uri.toAor(),e,_)}function a(){i.notify(603)}}_receiveNotify(s){switch(X.debug("receiveNotify()"),s.event||s.reply(400),s.event.event){case"refer":{let i,l;if(s.event.params&&s.event.params.id)i=s.event.params.id,l=this._referSubscribers[i];else if(Object.keys(this._referSubscribers).length===1)l=this._referSubscribers[Object.keys(this._referSubscribers)[0]];else{s.reply(400,"Missing event id parameter");return}if(!l){s.reply(481,"Subscription does not exist");return}l.receiveNotify(s),s.reply(200);break}default:s.reply(489)}}_receiveReplaces(s){X.debug("receiveReplaces()");function i(a){if(this._status!==ne.STATUS_WAITING_FOR_ACK&&this._status!==ne.STATUS_CONFIRMED)return!1;const _=new Ta(this._ua);_.on("confirmed",()=>{this.terminate()}),_.init_incoming(s,a)}function l(){X.debug("Replaced INVITE rejected by the user"),s.reply(486)}this.emit("replaces",{request:s,accept:a=>{i.call(this,a)},reject:()=>{l.call(this)}})}_getNextTransactionId(){return(this.lastTransaction+1).toString()}_sendInitialRequest(s,i,l){this.ackSent=!1,this.publisherSubscribeSent=!1;const a=new ra(this._ua,this._request,{onRequestTimeout:()=>{this.onRequestTimeout()},onTransportError:()=>{this.onTransportError()},onAuthenticated:_=>{this._request=_},onReceiveResponse:_=>{this._receiveInviteResponse(_)}});Promise.resolve().then(()=>{if(l)return l;if(s.audio||s.video)return this._localMediaStreamLocallyGenerated=!0,navigator.mediaDevices.getUserMedia(s).catch(_=>{throw this._status===ne.STATUS_TERMINATED?new Error("terminated"):(this._failed("local",null,F.causes.USER_DENIED_MEDIA_ACCESS),X.warn('emit "getusermediafailed" [error:%o]',_),this.emit("getusermediafailed",_),_)})}).then(_=>{if(this._status===ne.STATUS_TERMINATED)throw new Error("terminated");return this._localMediaStream=_,_&&_.getTracks().forEach(e=>{this._connection.addTrack(e,_)}),this._connecting(this._request),this._createLocalDescription("offer",i).catch(e=>{throw this._failed("local",null,F.causes.WEBRTC_ERROR),e})}).then(_=>{if(this._is_canceled||this._status===ne.STATUS_TERMINATED)throw new Error("terminated");const e={janus:"attach",plugin:"janus.plugin.videoroom",opaque_id:this.opaque_id},p=JSON.stringify(e);this._request.body=p,this._status=ne.STATUS_INVITE_SENT,X.debug('emit "sending" [request:%o]',this._request),this.emit("sending",{request:this._request}),a.send()}).catch(_=>{this._status!==ne.STATUS_TERMINATED&&X.warn(_)})}requestAudioAndVideoPermissions(){return this.loadStream()}async loadStream(){const s={audio:!0,video:!0};try{this.stream=await navigator.mediaDevices.getUserMedia(s)}catch{try{s.video=!1,this.stream=await navigator.mediaDevices.getUserMedia(s)}catch{s.audio=!1,s.video=!1,this.stream=await navigator.mediaDevices.getUserMedia(s)}}return{stream:this.stream,options:s}}addTracks(s){s.forEach(i=>{this._connection.addTrack(i)})}getRecordFileName(){return mT+this.room_id+btoa(unescape(encodeURIComponent(this.displayName)))+Date.now()}async processIceCandidates(){for(let s=0;s<this.iceCandidates.length;s++)await this._connection.addIceCandidate(this.iceCandidates[s]);this.iceCandidates=[]}async _sendConfigureMessage(s){const i={offerToReceiveAudio:!1,offerToReceiveVideo:!1},l=await this._connection.createOffer(i);await this._connection.setLocalDescription(l);const a=this._candidates.map(g=>({janus:"trickle",candidate:g,handle_id:this.handle_id,session_id:this.session_id})),e={configure:{janus:"message",body:{request:"configure",record:!0,filename:this.getRecordFileName(),...s},jsep:l,handle_id:this.handle_id,session_id:this.session_id},trickles:[...a]},p=["Content-Type: application/json","PTYPE: Ice"];this.sendRequest(F.INFO,{extraHeaders:p,body:JSON.stringify(e),eventHandlers:{onSuccessResponse:async g=>{this.isConfigureSent=!0;const v=g.data.split(`\r
|
135
|
+
`),S=v[v.length-1],m=JSON.parse(S);await this._connection.setRemoteDescription(m.jsep),this._candidates=[]}}})}_sendMemberStartMessage(s,i){const l={janus:"message",body:{request:"start",room:this.room_id},handle_id:s.handleId,session_id:this.session_id,jsep:i},a=["Content-Type: application/json","PTYPE: Configure"];this.sendRequest(F.INFO,{extraHeaders:a,body:JSON.stringify(l),eventHandlers:{onSuccessResponse:async _=>{_.status_code===200&&await s.rtcpPeer.setLocalDescription(i)}}})}_sendTrickleMessage(s){const l={trickles:[...s.map(_=>({janus:"trickle",candidate:_,handle_id:this.handle_id,session_id:this.session_id}))]},a=["PTYPE: Trickle"];this.sendRequest(F.INFO,{extraHeaders:a,body:JSON.stringify(l),eventHandlers:{onSuccessResponse:async _=>{console.log("_sendTrickleMessage",_)}}})}async _answerAttachedStream(s,i){let l=null;const a=async g=>{if(!s.rtcpPeer||s.loaded)return;{s.loaded=!0;const C={audio:!0,video:!0};await new Promise(A=>{setTimeout(A,100)}),l=await s.rtcpPeer.createAnswer(C),this._sendMemberStartMessage(s,l)}const n=g.streams[0].getAudioTracks(),v=g.streams[0].getVideoTracks(),S=[];n[0]&&S.push(n[0]),v[0]&&S.push(v[0]);const m=new MediaStream(S);s.stream=m,this._ua.emit("memberJoin",s.memberInfo)};let _,e=[];const p=g=>{s.rtcpPeer.signalingState!=="stable"&&s.rtcpPeer.signalingState!=="have-local-offer"||(e.push(g.candidate||null),clearTimeout(_),_=setTimeout(()=>{this._sendTrickleMessage(e)},500))};s.rtcpPeer=new RTCPeerConnection,s.rtcpPeer.ontrack=a,s.rtcpPeer.onicecandidate=p,s.rtcpPeer.sender=i.sender,await s.rtcpPeer.setRemoteDescription(i.jsep)}_sendJoinMemberRequest(s){const i={janus:"message",body:{request:"join",room:this.room_id,feed:s.info.id,ptype:"subscriber"},handle_id:s.handleId,session_id:this.session_id},l=["PTYPE: Subscriber"];this.sendRequest(F.SUBSCRIBE,{extraHeaders:l,body:JSON.stringify(i),eventHandlers:{onSuccessResponse:async a=>{var _,e;if(a.status_code===200){const p=JSON.parse(a.body);(e=(_=p==null?void 0:p.plugindata)==null?void 0:_.data)!=null&&e.id&&await this._answerAttachedStream(s,p)}}}})}_attachMember(s){const i={janus:"attach",opaque_id:this.opaque_id,plugin:"janus.plugin.videoroom",session_id:this.session_id},l=["PTYPE: Subscriber"];this.sendRequest(F.INFO,{extraHeaders:l,body:JSON.stringify(i),eventHandlers:{onSuccessResponse:async a=>{if(a.status_code===200){const e=JSON.parse(a.body).data.id;s.handleId=e,this._sendJoinMemberRequest(s)}}}})}_detachMember(s){const i={janus:"detach",handle_id:s.handleId,session_id:this.session_id},l=["PTYPE: Subscriber"];this.sendRequest(F.INFO,{extraHeaders:l,body:JSON.stringify(i)}),this._ua.emit("memberHangup",s.memberInfo)}receivePublishers(s){var l,a,_,e,p,g,n,v;const i={...this.memberList};(a=(l=s==null?void 0:s.plugindata)==null?void 0:l.data)==null||a.publishers.forEach(S=>{delete i[S.id],!this.memberList[S.id]&&!this.myFeedList.includes(S.id)&&S.clientID!==this.client_id&&(this.memberList[S.id]=new dT(S,this),this._attachMember(this.memberList[S.id]))}),((e=(_=s==null?void 0:s.plugindata)==null?void 0:_.data)==null?void 0:e.videoroom)==="synced"&&Object.keys(i).forEach(S=>{i[S].hangup(),delete this.memberList[S]}),this.publishers=(g=(p=s==null?void 0:s.plugindata)==null?void 0:p.data)==null?void 0:g.publishers,this.private_id=(v=(n=s==null?void 0:s.plugindata)==null?void 0:n.data)==null?void 0:v.private_id}receiveUnpublished(s){const i=this.memberList[s];i&&(i.hangup(),this._detachMember(i),delete this.memberList[s])}closeSession(){this.stream&&this.stream.getTracks().forEach(i=>{i.stop()}),Object.values(this.memberList).forEach(i=>{i.hangup(),this._detachMember(i)})}_receiveInviteResponse(s){if(X.debug("receiveInviteResponse()"),console.log("_receiveInviteResponse response",s),console.log("dialog",this._dialog),this._dialog&&s.status_code>=200&&s.status_code<=299&&!this.ackSent)if(console.log("IF 1 dialog"),this._dialog.id.call_id===s.call_id&&this._dialog.id.local_tag===s.from_tag&&this._dialog.id.remote_tag===s.to_tag){this.ackSent=!0,this.sendRequest(F.ACK);return}else{const i=new ma(this,s,"UAC");if(i.error!==void 0){X.debug(i.error);return}this.sendRequest(F.ACK),this.sendRequest(F.BYE);return}if(this.ackSent&&!this.publisherSubscribeSent){const i=JSON.parse(s.body);this.requestAudioAndVideoPermissions().then(()=>{this.session_id=i.session_id,this.handle_id=i.data.id,this.client_id=g_();const l={janus:"message",body:{request:"join",room:this.room_id,ptype:"publisher",display:this.display_name,clientID:this.client_id,opaque_id:this.opaque_id},handle_id:this.handle_id},a=["PTYPE: Publisher"];this.sendRequest(F.SUBSCRIBE,{extraHeaders:a,body:JSON.stringify(l),eventHandlers:{onSuccessResponse:async _=>{var e,p;if(_.status_code===200){if(this.subscribeSent=!0,_.body)try{const g=JSON.parse(_.body)||{};(p=(e=g.plugindata)==null?void 0:e.data)!=null&&p.publishers&&this.receivePublishers(g)}catch(g){console.error(g)}this.lastTrickleReceived&&!this.isConfigureSent&&(this.addTracks(this.stream.getTracks()),this._ua.emit("changeMainVideoStream",{name:this.display_name,stream:this.stream}),this._sendConfigureMessage({audio:!0,video:!0}).then(()=>{}))}}}}),this.publisherSubscribeSent=!0})}if(this._is_canceled){s.status_code>=100&&s.status_code<200?this._request.cancel(this._cancel_reason):s.status_code>=200&&s.status_code<299&&this._acceptAndTerminate(s);return}if(!(this._status!==ne.STATUS_INVITE_SENT&&this._status!==ne.STATUS_1XX_RECEIVED))switch(!0){case/^100$/.test(s.status_code):this._status=ne.STATUS_1XX_RECEIVED;break;case/^1[0-9]{2}$/.test(s.status_code):{if(!s.to_tag){X.debug("1xx response received without to tag");break}if(s.hasHeader("contact")&&!this._createDialog(s,"UAC",!0))break;if(this._status=ne.STATUS_1XX_RECEIVED,!s.body){this._progress("remote",s);break}const i={originator:"remote",type:"answer",sdp:s.body};X.debug('emit "sdp"'),this.emit("sdp",i);const l=new RTCSessionDescription({type:"answer",sdp:i.sdp});this._connectionPromiseQueue=this._connectionPromiseQueue.then(()=>this._connection.setRemoteDescription(l)).then(()=>this._progress("remote",s)).catch(a=>{X.warn('emit "peerconnection:setremotedescriptionfailed" [error:%o]',a),this.emit("peerconnection:setremotedescriptionfailed",a)});break}case/^2[0-9]{2}$/.test(s.status_code):{if(this._status=ne.STATUS_CONFIRMED,!s.body){this._acceptAndTerminate(s,400,F.causes.MISSING_SDP),this._failed("remote",s,F.causes.BAD_MEDIA_DESCRIPTION);break}if(!this._createDialog(s,"UAC"))break;break}default:{const i=$e.sipErrorCause(s.status_code);this._failed("remote",s,i)}}}_sendReinvite(s={}){X.debug("sendReinvite()");const i=$e.cloneArray(s.extraHeaders),l=$e.cloneObject(s.eventHandlers),a=s.rtcOfferConstraints||this._rtcOfferConstraints||null;let _=!1;i.push(`Contact: ${this._contact}`),i.push("Content-Type: application/sdp"),this._sessionTimers.running&&i.push(`Session-Expires: ${this._sessionTimers.currentExpires};refresher=${this._sessionTimers.refresher?"uac":"uas"}`),this._connectionPromiseQueue=this._connectionPromiseQueue.then(()=>this._createLocalDescription("offer",a)).then(g=>{g=this._mangleOffer(g);const n={originator:"local",type:"offer",sdp:g};X.debug('emit "sdp"'),this.emit("sdp",n),this.sendRequest(F.INVITE,{extraHeaders:i,body:g,eventHandlers:{onSuccessResponse:v=>{e.call(this,v),_=!0},onErrorResponse:v=>{p.call(this,v)},onTransportError:()=>{this.onTransportError()},onRequestTimeout:()=>{this.onRequestTimeout()},onDialogError:()=>{this.onDialogError()}}})}).catch(()=>{p()});function e(g){if(this._status===ne.STATUS_TERMINATED||(this.sendRequest(F.ACK),_))return;if(this._handleSessionTimersInIncomingResponse(g),g.body){if(!g.hasHeader("Content-Type")||g.getHeader("Content-Type").toLowerCase()!=="application/sdp"){p.call(this);return}}else{p.call(this);return}const n={originator:"remote",type:"answer",sdp:g.body};X.debug('emit "sdp"'),this.emit("sdp",n);const v=new RTCSessionDescription({type:"answer",sdp:n.sdp});this._connectionPromiseQueue=this._connectionPromiseQueue.then(()=>this._connection.setRemoteDescription(v)).then(()=>{l.succeeded&&l.succeeded(g)}).catch(S=>{p.call(this),X.warn('emit "peerconnection:setremotedescriptionfailed" [error:%o]',S),this.emit("peerconnection:setremotedescriptionfailed",S)})}function p(g){l.failed&&l.failed(g)}}_sendUpdate(s={}){X.debug("sendUpdate()");const i=$e.cloneArray(s.extraHeaders),l=$e.cloneObject(s.eventHandlers),a=s.rtcOfferConstraints||this._rtcOfferConstraints||null,_=s.sdpOffer||!1;let e=!1;i.push(`Contact: ${this._contact}`),this._sessionTimers.running&&i.push(`Session-Expires: ${this._sessionTimers.currentExpires};refresher=${this._sessionTimers.refresher?"uac":"uas"}`),_?(i.push("Content-Type: application/sdp"),this._connectionPromiseQueue=this._connectionPromiseQueue.then(()=>this._createLocalDescription("offer",a)).then(n=>{n=this._mangleOffer(n);const v={originator:"local",type:"offer",sdp:n};X.debug('emit "sdp"'),this.emit("sdp",v),this.sendRequest(F.UPDATE,{extraHeaders:i,body:n,eventHandlers:{onSuccessResponse:S=>{p.call(this,S),e=!0},onErrorResponse:S=>{g.call(this,S)},onTransportError:()=>{this.onTransportError()},onRequestTimeout:()=>{this.onRequestTimeout()},onDialogError:()=>{this.onDialogError()}}})}).catch(()=>{g.call(this)})):this.sendRequest(F.UPDATE,{extraHeaders:i,eventHandlers:{onSuccessResponse:n=>{p.call(this,n)},onErrorResponse:n=>{g.call(this,n)},onTransportError:()=>{this.onTransportError()},onRequestTimeout:()=>{this.onRequestTimeout()},onDialogError:()=>{this.onDialogError()}}});function p(n){if(this._status!==ne.STATUS_TERMINATED&&!e)if(this._handleSessionTimersInIncomingResponse(n),_){if(n.body){if(!n.hasHeader("Content-Type")||n.getHeader("Content-Type").toLowerCase()!=="application/sdp"){g.call(this);return}}else{g.call(this);return}const v={originator:"remote",type:"answer",sdp:n.body};X.debug('emit "sdp"'),this.emit("sdp",v);const S=new RTCSessionDescription({type:"answer",sdp:v.sdp});this._connectionPromiseQueue=this._connectionPromiseQueue.then(()=>this._connection.setRemoteDescription(S)).then(()=>{l.succeeded&&l.succeeded(n)}).catch(m=>{g.call(this),X.warn('emit "peerconnection:setremotedescriptionfailed" [error:%o]',m),this.emit("peerconnection:setremotedescriptionfailed",m)})}else l.succeeded&&l.succeeded(n)}function g(n){l.failed&&l.failed(n)}}_acceptAndTerminate(s,i,l){X.debug("acceptAndTerminate()");const a=[];i&&(l=l||F.REASON_PHRASE[i]||"",a.push(`Reason: SIP ;cause=${i}; text="${l}"`)),(this._dialog||this._createDialog(s,"UAC"))&&(this.sendRequest(F.ACK),this.sendRequest(F.BYE,{extraHeaders:a})),this._status=ne.STATUS_TERMINATED}_mangleOffer(s){if(!this._localHold&&!this._remoteHold)return s;if(s=xt.parse(s),this._localHold&&!this._remoteHold){X.debug("mangleOffer() | me on hold, mangling offer");for(const i of s.media)ga.indexOf(i.type)!==-1&&(i.direction?i.direction==="sendrecv"?i.direction="sendonly":i.direction==="recvonly"&&(i.direction="inactive"):i.direction="sendonly")}else if(this._localHold&&this._remoteHold){X.debug("mangleOffer() | both on hold, mangling offer");for(const i of s.media)ga.indexOf(i.type)!==-1&&(i.direction="inactive")}else if(this._remoteHold){X.debug("mangleOffer() | remote on hold, mangling offer");for(const i of s.media)ga.indexOf(i.type)!==-1&&(i.direction?i.direction==="sendrecv"?i.direction="recvonly":i.direction==="recvonly"&&(i.direction="inactive"):i.direction="recvonly")}return xt.write(s)}_setLocalMediaStatus(){let s=!0,i=!0;(this._localHold||this._remoteHold)&&(s=!1,i=!1),this._audioMuted&&(s=!1),this._videoMuted&&(i=!1),this._toggleMuteAudio(!s),this._toggleMuteVideo(!i)}_handleSessionTimersInIncomingRequest(s,i){if(!this._sessionTimers.enabled)return;let l;s.session_expires&&s.session_expires>=F.MIN_SESSION_EXPIRES?(this._sessionTimers.currentExpires=s.session_expires,l=s.session_expires_refresher||"uas"):(this._sessionTimers.currentExpires=this._sessionTimers.defaultExpires,l="uas"),i.push(`Session-Expires: ${this._sessionTimers.currentExpires};refresher=${l}`),this._sessionTimers.refresher=l==="uas",this._runSessionTimer()}_handleSessionTimersInIncomingResponse(s){if(!this._sessionTimers.enabled)return;let i;s.session_expires&&s.session_expires>=F.MIN_SESSION_EXPIRES?(this._sessionTimers.currentExpires=s.session_expires,i=s.session_expires_refresher||"uac"):(this._sessionTimers.currentExpires=this._sessionTimers.defaultExpires,i="uac"),this._sessionTimers.refresher=i==="uac",this._runSessionTimer()}_runSessionTimer(){const s=this._sessionTimers.currentExpires;this._sessionTimers.running=!0,clearTimeout(this._sessionTimers.timer),this._sessionTimers.refresher?this._sessionTimers.timer=setTimeout(()=>{this._status!==ne.STATUS_TERMINATED&&this._isReadyToReOffer()&&(X.debug("runSessionTimer() | sending session refresh request"),this._sessionTimers.refreshMethod===F.UPDATE?this._sendUpdate():this._sendReinvite())},s*500):this._sessionTimers.timer=setTimeout(()=>{this._status!==ne.STATUS_TERMINATED&&(X.warn("runSessionTimer() | timer expired, terminating the session"),this.terminate({cause:F.causes.REQUEST_TIMEOUT,status_code:408,reason_phrase:"Session Timer Expired"}))},s*1100)}_toggleMuteAudio(s){const i=this._connection.getSenders().filter(l=>l.track&&l.track.kind==="audio");for(const l of i)l.track.enabled=!s}_toggleMuteVideo(s){const i=this._connection.getSenders().filter(l=>l.track&&l.track.kind==="video");for(const l of i)l.track.enabled=!s}_newJanusSession(s,i){X.debug("newRTCSession()"),this._ua.newJanusSession(this,{originator:s,session:this,request:i})}_connecting(s){X.debug("session connecting"),X.debug('emit "connecting"'),this.emit("connecting",{request:s})}_progress(s,i){X.debug("session progress"),X.debug('emit "progress"'),this.emit("progress",{originator:s,response:i||null})}_accepted(s,i){X.debug("session accepted"),this._start_time=new Date,X.debug('emit "accepted"'),this.emit("accepted",{originator:s,response:i||null})}_confirmed(s,i){X.debug("session confirmed"),this._is_confirmed=!0,X.debug('emit "confirmed"'),this.emit("confirmed",{originator:s,ack:i||null})}_ended(s,i,l){X.debug("session ended"),this._end_time=new Date,this._close(),X.debug('emit "ended"'),this.emit("ended",{originator:s,message:i||null,cause:l})}_failed(s,i,l){X.debug("session failed"),X.debug('emit "_failed"'),this.emit("_failed",{originator:s,message:i||null,cause:l}),this._close(),X.debug('emit "failed"'),this.emit("failed",{originator:s,message:i||null,cause:l})}_onhold(s){X.debug("session onhold"),this._setLocalMediaStatus(),X.debug('emit "hold"'),this.emit("hold",{originator:s})}_onunhold(s){X.debug("session onunhold"),this._setLocalMediaStatus(),X.debug('emit "unhold"'),this.emit("unhold",{originator:s})}_onmute({audio:s,video:i}){X.debug("session onmute"),this._setLocalMediaStatus(),X.debug('emit "muted"'),this.emit("muted",{audio:s,video:i})}_onunmute({audio:s,video:i}){X.debug("session onunmute"),this._setLocalMediaStatus(),X.debug('emit "unmuted"'),this.emit("unmuted",{audio:s,video:i})}}class Jn{constructor(s){if(this.headers={},s.length>0){let i=!1;const l=s.split(`\r
|
136
|
+
`),a=l.shift().split(/\s/);this.protocol=a[0],this.ident=a[1],this.code=a.length>3?parseInt(a[2]):0,this.method=a.length>3?a[3]:a[2],this.body="";for(const _ of l){if(_==`-------${this.ident}$`)break;if(_===""){i=!0;continue}if(_&&i)this.body+=`${_}\r
|
137
|
+
`;else{const e=_.split(": ");this.addHeader(e[0],e[1].trim())}}}else this.ident=$e.createRandomToken(12),this.protocol="MSRP"}addHeader(s,i){this.headers[s]=i}getHeader(s){return this.headers[s]}toString(){let s=`${this.protocol} ${this.ident} ${this.code} ${this.method}`.replaceAll(/null\s|undefined\s/ig,"")+`\r
|
138
|
+
`;for(const i in this.headers)s+=`${i}: ${this.headers[i]}\r
|
139
|
+
`;return this.body&&(s+=`\r
|
140
140
|
${this.body}\r
|
141
|
-
`),
|
142
|
-
`,
|
141
|
+
`),s+=`-------${this.ident}$\r
|
142
|
+
`,s}}const Ie={STATUS_NULL:0,STATUS_INVITE_SENT:1,STATUS_1XX_RECEIVED:2,STATUS_INVITE_RECEIVED:3,STATUS_WAITING_FOR_ANSWER:4,STATUS_ANSWERED:5,STATUS_WAITING_FOR_ACK:6,STATUS_CANCELED:7,STATUS_TERMINATED:8,STATUS_CONFIRMED:9};class wu extends ct.EventEmitter{constructor(s){super(),this._id=null,this.my_ip="127.0.0.1",this._ua=s,this.auth_id=$e.createRandomToken(10),this._status=Ie.STATUS_NULL,this._dialog=null,this._earlyDialogs={},this._contact=null,this._from_tag=null,this._to_tag=null,this._msgHistory=[],this.target_addr=[],this.my_addr=[],this.credentials={username:s._configuration.authorization_user,ha1:s._configuration.ha1,realm:s._configuration.realm},this._request=null,this.status="new",this.target="",this.message="",this._connectionPromiseQueue=Promise.resolve(),this._timers={ackTimer:null,expiresTimer:null,invite2xxTimer:null,userNoAnswerTimer:null},this._direction=null,this._local_identity=null,this._remote_identity=null,this._start_time=null,this._end_time=null,this._tones=null,this._sessionTimers={enabled:this._ua.configuration.session_timers,refreshMethod:this._ua.configuration.session_timers_refresh_method,defaultExpires:F.SESSION_EXPIRES,currentExpires:null,running:!1,refresher:!1,timer:null},this._msrpKeepAliveTimer=null}static get C(){return Ie}get direction(){return this._direction}get connection(){return this._connection}get id(){return this._id}connect(s=""){s!==""&&(this._direction="outgoing"),this.target=s,this._connection=new WebSocket(`wss://${this._ua._configuration.realm}`,"msrp"),this._connection.binaryType="arraybuffer",this._connection.onopen=i=>{console.log("open",i),this.onopen()},this._connection.onclose=i=>{console.log("close",i),this.onclose()},this._connection.onmessage=i=>{console.log("msg",i),this.onmessage(i)},this._connection.onerror=i=>{console.log("error",i),this.onerror()}}_sendKeepAlive(){const s=new Jn("");s.method="SEND",s.addHeader("To-Path",`${this.my_addr[1]}`),s.addHeader("From-Path",`${this.my_addr[0]}`),s.addHeader("Message-ID",$e.createRandomToken(10)),this._connection.send(s.toString())}answer(){if(!this._createDialog(this._request,"UAS")){this._request.reply(500,"Error creating dialog");return}this._status=Ie.STATUS_ANSWERED,clearTimeout(this._timers.userNoAnswerTimer),this.connect()}acceptParty(s){this._request.parseSDP(!0),this._request.reply(200,"OK",[],`v=0
|
143
143
|
o=- 4232740119537112802 2 IN IP4 ${this.my_ip}
|
144
144
|
c=IN IP4 ${this.my_ip}
|
145
145
|
t=0 0
|
146
146
|
m=message 2856 TCP/TLS/MSRP *
|
147
147
|
a=accept-types:text/plain text/html
|
148
|
-
a=path: ${
|
149
|
-
`)}inviteParty(
|
148
|
+
a=path: ${s.getHeader("Use-Path")} msrp://${this._ua._configuration.authorization_user}.${this._ua._configuration.realm}:2856/${this.auth_id};ws
|
149
|
+
`)}inviteParty(s){const i={},l=[];i.to_uri=new Yn("sip",this.target,this._ua._configuration.realm),i.from_uri=new Yn("sip",this._ua._configuration.uri.user,this._ua._configuration.uri.host),l.push(`Contact: ${this._ua.contact.toString({outbound:!0})}`),l.push("Content-Type: application/sdp"),this._request=new bt.InitialOutgoingInviteRequest(new Yn("sip",this.target,this._ua._configuration.realm).clone(),this._ua,i,l,`v=0
|
150
150
|
o=- 4232740119537112802 2 IN IP4 ${this.my_ip}
|
151
151
|
c=IN IP4 ${this.my_ip}
|
152
152
|
t=0 0
|
153
153
|
m=message 2856 TCP/TLS/MSRP *
|
154
154
|
a=accept-types:text/plain text/html
|
155
|
-
a=path:${
|
156
|
-
`),this._newMSRPSession("local",this._request),this._id=this._request.call_id+this._from_tag,console.log("dialog be",this._dialog),new za(this._ua,this._request,{onRequestTimeout:()=>{this.onRequestTimeout(),console.log("to")},onTransportError:p=>{this.onTransportError(),console.log(p)},onAuthenticated:p=>{this._request=p},onReceiveResponse:p=>{this._receiveInviteResponse(p),console.log("dialog af",this._dialog),p.status_code===200&&(p.parseSDP(!0),this._status=Me.STATUS_CONFIRMED,this.target_addr=p.sdp.media[0].invalid[1].value.replaceAll("path:","").split(" ").reverse(),this.status="active",this.emit("active"),this.emit("confirmed"))}}).send(),this._status=Me.STATUS_INVITE_SENT}terminate(n={}){console.log("terminate",this);const a=n.cause||Y.causes.BYE,e=Ge.cloneArray(n.extraHeaders),o=n.body;let p,t=n.status_code,v=n.reason_phrase;if(this._status===Me.STATUS_TERMINATED)throw new Xn.InvalidStateError(this._status);switch(this.status="terminated",this._status){case Me.STATUS_NULL:case Me.STATUS_INVITE_SENT:case Me.STATUS_1XX_RECEIVED:if(t&&(t<200||t>=700))throw new TypeError(`Invalid status_code: ${t}`);t&&(v=v||Y.REASON_PHRASE[t]||"",p=`SIP ;cause=${t} ;text="${v}"`),this._status===Me.STATUS_NULL||this._status===Me.STATUS_INVITE_SENT?(this._is_canceled=!0,this._cancel_reason=p):this._status===Me.STATUS_1XX_RECEIVED&&this._request.cancel(p),this._status=Me.STATUS_CANCELED,console.log("failed 1"),this._failed("local",null,Y.causes.CANCELED);break;case Me.STATUS_WAITING_FOR_ANSWER:case Me.STATUS_ANSWERED:if(t=t||480,console.log("REPLY 480"),t<300||t>=700)throw new TypeError(`Invalid status_code: ${t}`);this._request.reply(t,v,e,o),console.log("failed 2"),this._failed("local",null,Y.causes.REJECTED);break;case Me.STATUS_WAITING_FOR_ACK:case Me.STATUS_CONFIRMED:if(v=n.reason_phrase||Y.REASON_PHRASE[t]||"",t&&(t<200||t>=700))throw new TypeError(`Invalid status_code: ${t}`);if(t&&e.push(`Reason: SIP ;cause=${t}; text="${v}"`),this._status===Me.STATUS_WAITING_FOR_ACK&&this._direction==="incoming"&&this._request.server_transaction.state!==os.C.STATUS_TERMINATED){const C=this._dialog;this.receiveRequest=({method:l})=>{l===Y.ACK&&(this.sendRequest(Y.BYE,{extraHeaders:e,body:o}),C.terminate())},this._request.server_transaction.on("stateChanged",()=>{this._request.server_transaction.state===os.C.STATUS_TERMINATED&&(this.sendRequest(Y.BYE,{extraHeaders:e,body:o}),C.terminate())}),this._ended("local",null,a),this._dialog=C,this._ua.newDialog(C)}else console.log("here it is"),this.sendRequest(Y.BYE,{extraHeaders:e,body:o}),this._ended("local",null,a)}}sendRequest(n,a){return this._dialog.sendRequest(n,a)}authenticate(n){this.status="auth";let a=new Xr("");a.method="AUTH",a.addHeader("To-Path",`msrp://${this._ua._configuration.realm}:2856;ws`),a.addHeader("From-Path",`msrp://${this.credentials.username}.${this.credentials.realm}:2856/${this.auth_id};ws`),n&&a.addHeader("Authorization",n.toString());let e=a.toString();console.log(e);let o=[];for(var p=0;p<e.length;p++)o.push(e.charCodeAt(p).toString(16));console.log(o),this._connection.send(a.toString())}onmessage(n){console.log("onmessage",n);const a=new Xr(n.data);if(this.status==="auth"&&a.code===401){const e=this.parseAuth(a.getHeader("WWW-Authenticate")),o=new Dm(this.credentials);o.authenticate({method:"AUTH",ruri:`msrp://${this._ua._configuration.realm}:2856;ws`,body:null},e,Ge.createRandomToken(12)),this.authenticate(o)}this.status==="auth"&&a.code===200&&this._direction==="outgoing"?(this.my_addr.push(a.getHeader("To-Path")),this.my_addr.push(a.getHeader("Use-Path")),this.status="active",this.inviteParty(a)):this.status==="auth"&&a.code===200&&this._direction==="incoming"?(this.my_addr.push(a.getHeader("To-Path")),this.my_addr.push(a.getHeader("Use-Path")),this.status="active",this.acceptParty(a),this.emit("confirmed")):a.method==="SEND"&&(this._sendOk(a),this._sendReport(a),a.direction="incoming",this.emit("newMessage",a),this._msgHistory.push(a),this.emit("msgHistoryUpdate",this._msgHistory),console.log("======================================================================")),a.code===480&&this._close()}onclose(){console.log("close")}onopen(){const n=new RTCPeerConnection({iceServers:[]});n.createDataChannel(""),n.createOffer().then(n.setLocalDescription.bind(n)),n.onicecandidate=a=>{if(!a||!a.candidate||!a.candidate.candidate)return;const e=/([0-9]{1,3}(\.[0-9]{1,3}){3})/,o=a.candidate.candidate.match(e);this.my_ip=o&&o[1],n.onicecandidate=()=>{},this.authenticate(null)}}onerror(n){console.log(n)}_receiveInviteResponse(n){if(console.log("resp0000000000000",n),this._dialog&&n.status_code>=200&&n.status_code<=299)if(console.log("200000000000000"),this._dialog.id.call_id===n.call_id&&this._dialog.id.local_tag===n.from_tag&&this._dialog.id.remote_tag===n.to_tag){this.sendRequest(Y.ACK);return}else{const a=new Qa(this,n,"UAC");if(a.error!==void 0){console.log(a.error);return}this.sendRequest(Y.ACK),this.sendRequest(Y.BYE);return}if(this._is_canceled){n.status_code>=100&&n.status_code<200?this._request.cancel(this._cancel_reason):n.status_code>=200&&n.status_code<299&&this._acceptAndTerminate(n);return}if(!(this._status!==Me.STATUS_INVITE_SENT&&this._status!==Me.STATUS_1XX_RECEIVED))switch(console.log("start Switch"),!0){case/^100$/.test(n.status_code):this._status=Me.STATUS_1XX_RECEIVED;break;case/^1[0-9]{2}$/.test(n.status_code):{if(!n.to_tag){console.log("1xx response received without to tag");break}if(n.hasHeader("contact")&&!this._createDialog(n,"UAC",!0))break;if(this._status=Me.STATUS_1XX_RECEIVED,!n.body){this._progress("remote",n);break}const a={originator:"remote",type:"answer",sdp:n.body};console.log('emit "sdp"'),this.emit("sdp",a);const e=new RTCSessionDescription({type:"answer",sdp:a.sdp});this._connectionPromiseQueue=this._connectionPromiseQueue.then(()=>this._connection.setRemoteDescription(e)).then(()=>this._progress("remote",n)).catch(o=>{console.log('emit "peerconnection:setremotedescriptionfailed" [error:%o]',o),this.emit("peerconnection:setremotedescriptionfailed",o)});break}case/^2[0-9]{2}$/.test(n.status_code):{if(console.log("maybe here???"),this._status=Me.STATUS_CONFIRMED,!n.body){this._acceptAndTerminate(n,400,Y.causes.MISSING_SDP),console.log("failed 3"),this._failed("remote",n,Y.causes.BAD_MEDIA_DESCRIPTION);break}if(!this._createDialog(n,"UAC"))break;const a={originator:"remote",type:"answer",sdp:n.body};console.log('emit "sdp"'),this.emit("sdp",a),new RTCSessionDescription({type:"answer",sdp:a.sdp}),this._connectionPromiseQueue=this._connectionPromiseQueue.then(()=>{if(this._connection.signalingState==="stable")return this._connection.createOffer(this._rtcOfferConstraints).then(e=>this._connection.setLocalDescription(e)).catch(e=>{this._acceptAndTerminate(n,500,e.toString()),console.log("failed 4"),this._failed("local",n,Y.causes.WEBRTC_ERROR)})}).then(()=>{this._handleSessionTimersInIncomingResponse(n),this._accepted("remote",n),this.sendRequest(Y.ACK),this._confirmed("local",null)});break}default:{const a=Ge.sipErrorCause(n.status_code);console.log("failed 5"),this._failed("remote",n,a)}}}sendMSRP(n){const a=new Xr("");a.method="SEND",a.addHeader("To-Path",`${this.my_addr[1]} ${this.target_addr[1]} ${this.target_addr[0]}`),a.addHeader("From-Path",`${this.my_addr[0]}`),a.addHeader("Message-ID",Ge.createRandomToken(10)),a.addHeader("Byte-Range","1-25/25"),a.addHeader("Content-Type","text/plain"),a.addHeader("Success-Report","yes"),a.addHeader("Failure-Report","yes"),a.body=n;let e=a.toString();console.log(e);let o=[];for(var p=0;p<e.length;p++)o.push(e.charCodeAt(p).toString(16));console.log(o),this._connection.send(a.toString()),a.direction="outgoing",this.emit("newMessage",a),this._msgHistory.push(a),this.emit("msgHistoryUpdate",this._msgHistory)}_sendOk(n){let a=n.ident,e=n.getHeader("Message-ID"),o=new Xr("");o.method="200 OK",o.addHeader("To-Path",`${this.my_addr[1]}`),o.addHeader("From-Path",`${this.my_addr[0]}`),o.addHeader("Message-ID",e),o.ident=a;let p=o.toString();console.log(p);let t=[];for(var v=0;v<p.length;v++)t.push(p.charCodeAt(v).toString(16));console.log(t),this._connection.send(o.toString())}_sendReport(n){let a=n.ident,e=n.getHeader("Message-ID"),o=new Xr("");o.method="REPORT",o.addHeader("To-Path",`${n.getHeader("From-Path")}`),o.addHeader("From-Path",`${this.my_addr[0]}`),o.addHeader("Message-ID",e),o.addHeader("Byte-Range","1-25/25"),o.addHeader("Status","000 200 OK"),o.ident=a;let p=o.toString();console.log(p);let t=[];for(var v=0;v<p.length;v++)t.push(p.charCodeAt(v).toString(16));console.log(t),this._connection.send(o.toString())}parseAuth(n){const a={},e=n.replace("Digest","").split(",");for(const o of e){const p=o.trim().split("=");a[p[0]]=p[1].match('^"(.+)"$')[1]}return a}init_incoming(n,a){let e;const o=n.hasHeader("Content-Type")?n.getHeader("Content-Type").toLowerCase():void 0;if(n.body&&o!=="application/sdp"){n.reply(415);return}if(this._status=Me.STATUS_INVITE_RECEIVED,this._from_tag=n.from_tag,this._id=n.call_id+this._from_tag,this._request=n,this._contact=this._ua.contact.toString(),n.hasHeader("expires")&&(e=n.getHeader("expires")*1e3),n.to_tag=Ge.newTag(),!this._createDialog(n,"UAS",!0)){n.reply(500,"Missing Contact header field");return}n.body?this._late_sdp=!1:this._late_sdp=!0,this._status=Me.STATUS_WAITING_FOR_ANSWER,this._timers.userNoAnswerTimer=setTimeout(()=>{n.reply(408),console.log("failed 6"),this._failed("local",null,Y.causes.NO_ANSWER)},this._ua.configuration.no_answer_timeout),e&&(this._timers.expiresTimer=setTimeout(()=>{this._status===Me.STATUS_WAITING_FOR_ANSWER&&(n.reply(487),console.log("failed 7"),this._failed("system",null,Y.causes.EXPIRES))},e)),this._direction="incoming",this._local_identity=n.to,this._remote_identity=n.from,a&&a(this),n.parseSDP(!0),this.target_addr=n.sdp.media[0].invalid[1].value.replaceAll("path:","").split(" ").reverse(),this._newMSRPSession("remote",n),this._status!==Me.STATUS_TERMINATED&&(n.reply(180,null,[`Contact: ${this._ua._contact}`]),this._progress("local",null))}_failed(n,a,e){this.emit("_failed",{originator:n,message:a||null,cause:e}),this._close(),this.emit("failed",{originator:n,message:a||null,cause:e})}_close(){if(console.log("CLOSE SESSION"),this._status!==Me.STATUS_TERMINATED){if(this._status=Me.STATUS_TERMINATED,this._connection)try{this._connection.close()}catch(n){console.log("close() | error closing the RTCPeerConnection: %o",n)}for(const n in this._timers)Object.prototype.hasOwnProperty.call(this._timers,n)&&clearTimeout(this._timers[n]);clearTimeout(this._sessionTimers.timer),this._dialog&&(this._dialog.terminate(),delete this._dialog);for(const n in this._earlyDialogs)Object.prototype.hasOwnProperty.call(this._earlyDialogs,n)&&(this._earlyDialogs[n].terminate(),delete this._earlyDialogs[n]);for(const n in this._referSubscribers)Object.prototype.hasOwnProperty.call(this._referSubscribers,n)&&delete this._referSubscribers[n];this._ua.destroyMSRPSession(this)}}_createDialog(n,a,e){const o=a==="UAS"?n.to_tag:n.from_tag,p=a==="UAS"?n.from_tag:n.to_tag,t=n.call_id+o+p;let v=this._earlyDialogs[t];if(e)return v?!0:(v=new Qa(this,n,a,Qa.C.STATUS_EARLY),v.error?(console.log("failed 8"),this._failed("remote",n,Y.causes.INTERNAL_ERROR),!1):(this._earlyDialogs[t]=v,!0));{if(this._from_tag=n.from_tag,this._to_tag=n.to_tag,v)return v.update(n,a),this._dialog=v,delete this._earlyDialogs[t],!0;const C=new Qa(this,n,a);return C.error?(console.log("failed 9"),this._failed("remote",n,Y.causes.INTERNAL_ERROR),!1):(this._dialog=C,!0)}}_newMSRPSession(n,a){this._ua.newMSRPSession(this,{originator:n,session:this,request:a})}_progress(n,a){this.emit("progress",{originator:n,response:a||null})}isEnded(){switch(this._status){case Me.STATUS_CANCELED:case Me.STATUS_TERMINATED:return!0;default:return!1}}_accepted(n,a){console.log("session accepted"),this._start_time=new Date,console.log('emit "accepted"'),this.emit("accepted",{originator:n,response:a||null})}_confirmed(n,a){console.log("session confirmed"),this._is_confirmed=!0,console.log('emit "confirmed"'),this.emit("confirmed",{originator:n,ack:a||null})}_ended(n,a,e){console.log("session ended"),this._end_time=new Date,this._close(),console.log('emit "ended"'),this.emit("ended",{originator:n,message:a||null,cause:e})}_handleSessionTimersInIncomingResponse(n){if(!this._sessionTimers.enabled)return;let a;n.session_expires&&n.session_expires>=Y.MIN_SESSION_EXPIRES?(this._sessionTimers.currentExpires=n.session_expires,a=n.session_expires_refresher||"uac"):(this._sessionTimers.currentExpires=this._sessionTimers.defaultExpires,a="uac"),this._sessionTimers.refresher=a==="uac",this._runSessionTimer()}receiveRequest(n){if(console.log("receiveRequest()"),n.method===Y.CANCEL)(this._status===Me.STATUS_WAITING_FOR_ANSWER||this._status===Me.STATUS_ANSWERED)&&(this._status=Me.STATUS_CANCELED,this._request.reply(487),console.log("failed 10"),this._failed("remote",n,Y.causes.CANCELED));else switch(n.method){case Y.ACK:if(this._status!==Me.STATUS_WAITING_FOR_ACK)return;if(this._status=Me.STATUS_CONFIRMED,clearTimeout(this._timers.ackTimer),clearTimeout(this._timers.invite2xxTimer),this._late_sdp){if(!n.body){this.terminate({cause:Y.causes.MISSING_SDP,status_code:400});break}const a={originator:"remote",type:"answer",sdp:n.body};console.log('emit "sdp"'),this.emit("sdp",a);const e=new RTCSessionDescription({type:"answer",sdp:a.sdp});this._connectionPromiseQueue=this._connectionPromiseQueue.then(()=>this._connection.setRemoteDescription(e)).then(()=>{this._is_confirmed||this._confirmed("remote",n)}).catch(o=>{this.terminate({cause:Y.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",n);break;case Y.BYE:this._status===Me.STATUS_CONFIRMED||this._status===Me.STATUS_WAITING_FOR_ACK?(n.reply(200),this._ended("remote",n,Y.causes.BYE)):this._status===Me.STATUS_INVITE_RECEIVED||this._status===Me.STATUS_WAITING_FOR_ANSWER?(n.reply(200),this._request.reply(487,"BYE Received"),this._ended("remote",n,Y.causes.BYE)):n.reply(403,"Wrong Status");break;case Y.INVITE:this._status===Me.STATUS_CONFIRMED?n.hasHeader("replaces")?this._receiveReplaces(n):this._receiveReinvite(n):n.reply(403,"Wrong Status");break;case Y.INFO:this._status===Me.STATUS_1XX_RECEIVED||this._status===Me.STATUS_WAITING_FOR_ANSWER||this._status===Me.STATUS_ANSWERED||this._status===Me.STATUS_WAITING_FOR_ACK||this._status===Me.STATUS_CONFIRMED?(n.hasHeader("Content-Type")?n.getHeader("Content-Type").toLowerCase():void 0)!==void 0?new Cu(this).init_incoming(n):n.reply(415):n.reply(403,"Wrong Status");break;case Y.UPDATE:this._status===Me.STATUS_CONFIRMED?this._receiveUpdate(n):n.reply(403,"Wrong Status");break;case Y.REFER:this._status===Me.STATUS_CONFIRMED?this._receiveRefer(n):n.reply(403,"Wrong Status");break;case Y.NOTIFY:this._status===Me.STATUS_CONFIRMED?this._receiveNotify(n):n.reply(403,"Wrong Status");break;default:n.reply(501)}}onTransportError(){console.log("onTransportError()"),this._status!==Me.STATUS_TERMINATED&&this.terminate({status_code:500,reason_phrase:Y.causes.CONNECTION_ERROR,cause:Y.causes.CONNECTION_ERROR})}onRequestTimeout(){console.log("onRequestTimeout()"),this._status!==Me.STATUS_TERMINATED&&this.terminate({status_code:408,reason_phrase:Y.causes.REQUEST_TIMEOUT,cause:Y.causes.REQUEST_TIMEOUT})}onDialogError(){console.log("onDialogError()"),this._status!==Me.STATUS_TERMINATED&&this.terminate({status_code:500,reason_phrase:Y.causes.DIALOG_ERROR,cause:Y.causes.DIALOG_ERROR})}}var Tv=Ga();const Qr=Be(Tv);function Th(u){return'"'+u.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 Ki={parse:function(u,n){var a={CRLF:v,DIGIT:C,ALPHA:l,HEXDIG:A,WSP:b,OCTET:E,DQUOTE:O,SP:w,HTAB:N,alphanum:U,reserved:z,unreserved:j,mark:_e,escaped:k,LWS:H,SWS:de,HCOLON:Ue,TEXT_UTF8_TRIM:B,TEXT_UTF8char:L,UTF8_NONASCII:V,UTF8_CONT:G,LHEX:K,token:M,token_nodot:te,separators:se,word:$,STAR:ne,SLASH:ht,EQUAL:P,LPAREN:Q,RPAREN:oe,RAQUOT:he,LAQUOT:Re,COMMA:be,SEMI:fe,COLON:je,LDQUOT:xe,RDQUOT:we,comment:rt,ctext:$e,quoted_string:ue,quoted_string_clean:Oe,qdtext:Pe,quoted_pair:Le,SIP_URI_noparams:ye,SIP_URI:pe,uri_scheme:Ce,uri_scheme_sips:ke,uri_scheme_sip:He,userinfo:We,user:Ve,user_unreserved:Ht,password:_t,hostport:Xs,host:cs,hostname:Is,domainlabel:ws,toplabel:fs,IPv6reference:Qs,IPv6address:hs,h16:Se,ls32:dt,IPv4address:Zt,dec_octet:Ae,port:vt,uri_parameters:_s,uri_parameter:Ee,transport_param:Et,user_param:Os,method_param:ds,ttl_param:rl,maddr_param:il,lr_param:In,other_param:al,pname:ol,pvalue:ul,paramchar:Ds,param_unreserved:cl,headers:fl,header:es,hname:hl,hvalue:_l,hnv_unreserved:Ft,Request_Response:dr,Request_Line:dl,Request_URI:ts,absoluteURI:pl,hier_part:ml,net_path:Ns,abs_path:Zs,opaque_part:gl,uric:Us,uric_no_slash:xs,path_segments:vl,segment:ss,param:Ps,pchar:Ms,scheme:ns,authority:wn,srvr:ks,reg_name:en,query:On,SIP_Version:ps,INVITEm:Tl,ACKm:El,OPTIONSm:Dn,BYEm:Cl,CANCELm:Sl,REGISTERm:Nn,SUBSCRIBEm:Al,NOTIFYm:yl,REFERm:Rl,Method:tn,Status_Line:bl,Status_Code:Il,extension_code:sn,Reason_Phrase:wl,Allow_Events:pr,Call_ID:Un,Contact:mr,contact_param:xn,name_addr:ms,display_name:Pn,contact_params:nn,c_p_q:gs,c_p_expires:Mn,delta_seconds:qt,qvalue:ls,generic_param:ze,gen_value:Yt,Content_Disposition:gr,disp_type:Ze,disp_param:zt,handling_param:vr,Content_Encoding:st,Content_Length:Ol,Content_Type:ei,media_type:Tr,m_type:Dl,discrete_type:Er,composite_type:Cr,extension_token:kn,x_token:Sr,m_subtype:Nl,m_parameter:Ls,m_value:Ul,CSeq:Ar,CSeq_value:$s,Expires:yr,Event:ti,event_type:vs,From:si,from_param:Rr,tag_param:Ts,Max_Forwards:ea,Min_Expires:br,Name_Addr_Header:Hs,Proxy_Authenticate:ta,challenge:Ln,other_challenge:xl,auth_param:$n,digest_cln:ln,realm:Ir,realm_value:rn,domain:Fs,URI:an,nonce:qs,nonce_value:on,opaque:un,stale:Pl,algorithm:Ml,qop_options:cn,qop_value:fn,Proxy_Require:wr,Record_Route:Or,rec_route:Es,Reason:ni,reason_param:kl,reason_cause:Cs,Require:sa,Route:Dr,route_param:Ss,Subscription_State:na,substate_value:Ll,subexp_params:js,event_reason_value:li,Subject:ri,Supported:hn,To:ii,to_param:$l,Via:Nr,via_param:Hn,via_params:Fn,via_ttl:ai,via_maddr:qn,via_received:_n,via_branch:Ur,response_port:dn,rport:jn,sent_protocol:Hl,protocol_name:Fl,transport:ql,sent_by:jl,via_host:Vl,via_port:Bl,ttl:Vn,WWW_Authenticate:xr,Session_Expires:Pr,s_e_expires:Bn,s_e_params:Gl,s_e_refresher:Mr,extension_header:Wl,header_value:Kl,message_body:oi,uuid_URI:ui,uuid:Gn,hex4:Jt,hex8:ci,hex12:Yl,Refer_To:rs,Replaces:fi,call_id:zl,replaces_param:Bt,to_tag:kr,from_tag:Jl,early_flag:Xl};if(n!==void 0){if(a[n]===void 0)throw new Error("Invalid rule name: "+Th(n)+".")}else n="CRLF";var e=0,o=0,p=[];function t(i){e<o||(e>o&&(o=e,p=[]),p.push(i))}function v(){var i;return u.substr(e,2)===`\r
|
157
|
-
|
158
|
-
`,e+=2):(i=null,t('"\\r\\n"')),i}function C(){var i;return/^[0-9]/.test(u.charAt(e))?(i=u.charAt(e),e++):(i=null,t("[0-9]")),i}function l(){var i;return/^[a-zA-Z]/.test(u.charAt(e))?(i=u.charAt(e),e++):(i=null,t("[a-zA-Z]")),i}function A(){var i;return/^[0-9a-fA-F]/.test(u.charAt(e))?(i=u.charAt(e),e++):(i=null,t("[0-9a-fA-F]")),i}function b(){var i;return i=w(),i===null&&(i=N()),i}function E(){var i;return/^[\0-\xFF]/.test(u.charAt(e))?(i=u.charAt(e),e++):(i=null,t("[\\0-\\xFF]")),i}function O(){var i;return/^["]/.test(u.charAt(e))?(i=u.charAt(e),e++):(i=null,t('["]')),i}function w(){var i;return u.charCodeAt(e)===32?(i=" ",e++):(i=null,t('" "')),i}function N(){var i;return u.charCodeAt(e)===9?(i=" ",e++):(i=null,t('"\\t"')),i}function U(){var i;return/^[a-zA-Z0-9]/.test(u.charAt(e))?(i=u.charAt(e),e++):(i=null,t("[a-zA-Z0-9]")),i}function z(){var i;return u.charCodeAt(e)===59?(i=";",e++):(i=null,t('";"')),i===null&&(u.charCodeAt(e)===47?(i="/",e++):(i=null,t('"/"')),i===null&&(u.charCodeAt(e)===63?(i="?",e++):(i=null,t('"?"')),i===null&&(u.charCodeAt(e)===58?(i=":",e++):(i=null,t('":"')),i===null&&(u.charCodeAt(e)===64?(i="@",e++):(i=null,t('"@"')),i===null&&(u.charCodeAt(e)===38?(i="&",e++):(i=null,t('"&"')),i===null&&(u.charCodeAt(e)===61?(i="=",e++):(i=null,t('"="')),i===null&&(u.charCodeAt(e)===43?(i="+",e++):(i=null,t('"+"')),i===null&&(u.charCodeAt(e)===36?(i="$",e++):(i=null,t('"$"')),i===null&&(u.charCodeAt(e)===44?(i=",",e++):(i=null,t('","'))))))))))),i}function j(){var i;return i=U(),i===null&&(i=_e()),i}function _e(){var i;return u.charCodeAt(e)===45?(i="-",e++):(i=null,t('"-"')),i===null&&(u.charCodeAt(e)===95?(i="_",e++):(i=null,t('"_"')),i===null&&(u.charCodeAt(e)===46?(i=".",e++):(i=null,t('"."')),i===null&&(u.charCodeAt(e)===33?(i="!",e++):(i=null,t('"!"')),i===null&&(u.charCodeAt(e)===126?(i="~",e++):(i=null,t('"~"')),i===null&&(u.charCodeAt(e)===42?(i="*",e++):(i=null,t('"*"')),i===null&&(u.charCodeAt(e)===39?(i="'",e++):(i=null,t(`"'"`)),i===null&&(u.charCodeAt(e)===40?(i="(",e++):(i=null,t('"("')),i===null&&(u.charCodeAt(e)===41?(i=")",e++):(i=null,t('")"')))))))))),i}function k(){var i,_,m,T,y;return T=e,y=e,u.charCodeAt(e)===37?(i="%",e++):(i=null,t('"%"')),i!==null?(_=A(),_!==null?(m=A(),m!==null?i=[i,_,m]:(i=null,e=y)):(i=null,e=y)):(i=null,e=y),i!==null&&(i=function(r,f){return f.join("")}(T,i)),i===null&&(e=T),i}function H(){var i,_,m,T,y,r;for(T=e,y=e,r=e,i=[],_=b();_!==null;)i.push(_),_=b();if(i!==null?(_=v(),_!==null?i=[i,_]:(i=null,e=r)):(i=null,e=r),i=i!==null?i:"",i!==null){if(m=b(),m!==null)for(_=[];m!==null;)_.push(m),m=b();else _=null;_!==null?i=[i,_]:(i=null,e=y)}else i=null,e=y;return i!==null&&(i=function(f){return" "}()),i===null&&(e=T),i}function de(){var i;return i=H(),i=i!==null?i:"",i}function Ue(){var i,_,m,T,y;for(T=e,y=e,i=[],_=w(),_===null&&(_=N());_!==null;)i.push(_),_=w(),_===null&&(_=N());return i!==null?(u.charCodeAt(e)===58?(_=":",e++):(_=null,t('":"')),_!==null?(m=de(),m!==null?i=[i,_,m]:(i=null,e=y)):(i=null,e=y)):(i=null,e=y),i!==null&&(i=function(r){return":"}()),i===null&&(e=T),i}function B(){var i,_,m,T,y,r,f;if(y=e,r=e,_=L(),_!==null)for(i=[];_!==null;)i.push(_),_=L();else i=null;if(i!==null){for(_=[],f=e,m=[],T=H();T!==null;)m.push(T),T=H();for(m!==null?(T=L(),T!==null?m=[m,T]:(m=null,e=f)):(m=null,e=f);m!==null;){for(_.push(m),f=e,m=[],T=H();T!==null;)m.push(T),T=H();m!==null?(T=L(),T!==null?m=[m,T]:(m=null,e=f)):(m=null,e=f)}_!==null?i=[i,_]:(i=null,e=r)}else i=null,e=r;return i!==null&&(i=function(d){return u.substring(e,d)}(y)),i===null&&(e=y),i}function L(){var i;return/^[!-~]/.test(u.charAt(e))?(i=u.charAt(e),e++):(i=null,t("[!-~]")),i===null&&(i=V()),i}function V(){var i;return/^[\x80-\uFFFF]/.test(u.charAt(e))?(i=u.charAt(e),e++):(i=null,t("[\\x80-\\uFFFF]")),i}function G(){var i;return/^[\x80-\xBF]/.test(u.charAt(e))?(i=u.charAt(e),e++):(i=null,t("[\\x80-\\xBF]")),i}function K(){var i;return i=C(),i===null&&(/^[a-f]/.test(u.charAt(e))?(i=u.charAt(e),e++):(i=null,t("[a-f]"))),i}function M(){var i,_,m;if(m=e,_=U(),_===null&&(u.charCodeAt(e)===45?(_="-",e++):(_=null,t('"-"')),_===null&&(u.charCodeAt(e)===46?(_=".",e++):(_=null,t('"."')),_===null&&(u.charCodeAt(e)===33?(_="!",e++):(_=null,t('"!"')),_===null&&(u.charCodeAt(e)===37?(_="%",e++):(_=null,t('"%"')),_===null&&(u.charCodeAt(e)===42?(_="*",e++):(_=null,t('"*"')),_===null&&(u.charCodeAt(e)===95?(_="_",e++):(_=null,t('"_"')),_===null&&(u.charCodeAt(e)===43?(_="+",e++):(_=null,t('"+"')),_===null&&(u.charCodeAt(e)===96?(_="`",e++):(_=null,t('"`"')),_===null&&(u.charCodeAt(e)===39?(_="'",e++):(_=null,t(`"'"`)),_===null&&(u.charCodeAt(e)===126?(_="~",e++):(_=null,t('"~"')))))))))))),_!==null)for(i=[];_!==null;)i.push(_),_=U(),_===null&&(u.charCodeAt(e)===45?(_="-",e++):(_=null,t('"-"')),_===null&&(u.charCodeAt(e)===46?(_=".",e++):(_=null,t('"."')),_===null&&(u.charCodeAt(e)===33?(_="!",e++):(_=null,t('"!"')),_===null&&(u.charCodeAt(e)===37?(_="%",e++):(_=null,t('"%"')),_===null&&(u.charCodeAt(e)===42?(_="*",e++):(_=null,t('"*"')),_===null&&(u.charCodeAt(e)===95?(_="_",e++):(_=null,t('"_"')),_===null&&(u.charCodeAt(e)===43?(_="+",e++):(_=null,t('"+"')),_===null&&(u.charCodeAt(e)===96?(_="`",e++):(_=null,t('"`"')),_===null&&(u.charCodeAt(e)===39?(_="'",e++):(_=null,t(`"'"`)),_===null&&(u.charCodeAt(e)===126?(_="~",e++):(_=null,t('"~"'))))))))))));else i=null;return i!==null&&(i=function(T){return u.substring(e,T)}(m)),i===null&&(e=m),i}function te(){var i,_,m;if(m=e,_=U(),_===null&&(u.charCodeAt(e)===45?(_="-",e++):(_=null,t('"-"')),_===null&&(u.charCodeAt(e)===33?(_="!",e++):(_=null,t('"!"')),_===null&&(u.charCodeAt(e)===37?(_="%",e++):(_=null,t('"%"')),_===null&&(u.charCodeAt(e)===42?(_="*",e++):(_=null,t('"*"')),_===null&&(u.charCodeAt(e)===95?(_="_",e++):(_=null,t('"_"')),_===null&&(u.charCodeAt(e)===43?(_="+",e++):(_=null,t('"+"')),_===null&&(u.charCodeAt(e)===96?(_="`",e++):(_=null,t('"`"')),_===null&&(u.charCodeAt(e)===39?(_="'",e++):(_=null,t(`"'"`)),_===null&&(u.charCodeAt(e)===126?(_="~",e++):(_=null,t('"~"'))))))))))),_!==null)for(i=[];_!==null;)i.push(_),_=U(),_===null&&(u.charCodeAt(e)===45?(_="-",e++):(_=null,t('"-"')),_===null&&(u.charCodeAt(e)===33?(_="!",e++):(_=null,t('"!"')),_===null&&(u.charCodeAt(e)===37?(_="%",e++):(_=null,t('"%"')),_===null&&(u.charCodeAt(e)===42?(_="*",e++):(_=null,t('"*"')),_===null&&(u.charCodeAt(e)===95?(_="_",e++):(_=null,t('"_"')),_===null&&(u.charCodeAt(e)===43?(_="+",e++):(_=null,t('"+"')),_===null&&(u.charCodeAt(e)===96?(_="`",e++):(_=null,t('"`"')),_===null&&(u.charCodeAt(e)===39?(_="'",e++):(_=null,t(`"'"`)),_===null&&(u.charCodeAt(e)===126?(_="~",e++):(_=null,t('"~"')))))))))));else i=null;return i!==null&&(i=function(T){return u.substring(e,T)}(m)),i===null&&(e=m),i}function se(){var i;return u.charCodeAt(e)===40?(i="(",e++):(i=null,t('"("')),i===null&&(u.charCodeAt(e)===41?(i=")",e++):(i=null,t('")"')),i===null&&(u.charCodeAt(e)===60?(i="<",e++):(i=null,t('"<"')),i===null&&(u.charCodeAt(e)===62?(i=">",e++):(i=null,t('">"')),i===null&&(u.charCodeAt(e)===64?(i="@",e++):(i=null,t('"@"')),i===null&&(u.charCodeAt(e)===44?(i=",",e++):(i=null,t('","')),i===null&&(u.charCodeAt(e)===59?(i=";",e++):(i=null,t('";"')),i===null&&(u.charCodeAt(e)===58?(i=":",e++):(i=null,t('":"')),i===null&&(u.charCodeAt(e)===92?(i="\\",e++):(i=null,t('"\\\\"')),i===null&&(i=O(),i===null&&(u.charCodeAt(e)===47?(i="/",e++):(i=null,t('"/"')),i===null&&(u.charCodeAt(e)===91?(i="[",e++):(i=null,t('"["')),i===null&&(u.charCodeAt(e)===93?(i="]",e++):(i=null,t('"]"')),i===null&&(u.charCodeAt(e)===63?(i="?",e++):(i=null,t('"?"')),i===null&&(u.charCodeAt(e)===61?(i="=",e++):(i=null,t('"="')),i===null&&(u.charCodeAt(e)===123?(i="{",e++):(i=null,t('"{"')),i===null&&(u.charCodeAt(e)===125?(i="}",e++):(i=null,t('"}"')),i===null&&(i=w(),i===null&&(i=N())))))))))))))))))),i}function $(){var i,_,m;if(m=e,_=U(),_===null&&(u.charCodeAt(e)===45?(_="-",e++):(_=null,t('"-"')),_===null&&(u.charCodeAt(e)===46?(_=".",e++):(_=null,t('"."')),_===null&&(u.charCodeAt(e)===33?(_="!",e++):(_=null,t('"!"')),_===null&&(u.charCodeAt(e)===37?(_="%",e++):(_=null,t('"%"')),_===null&&(u.charCodeAt(e)===42?(_="*",e++):(_=null,t('"*"')),_===null&&(u.charCodeAt(e)===95?(_="_",e++):(_=null,t('"_"')),_===null&&(u.charCodeAt(e)===43?(_="+",e++):(_=null,t('"+"')),_===null&&(u.charCodeAt(e)===96?(_="`",e++):(_=null,t('"`"')),_===null&&(u.charCodeAt(e)===39?(_="'",e++):(_=null,t(`"'"`)),_===null&&(u.charCodeAt(e)===126?(_="~",e++):(_=null,t('"~"')),_===null&&(u.charCodeAt(e)===40?(_="(",e++):(_=null,t('"("')),_===null&&(u.charCodeAt(e)===41?(_=")",e++):(_=null,t('")"')),_===null&&(u.charCodeAt(e)===60?(_="<",e++):(_=null,t('"<"')),_===null&&(u.charCodeAt(e)===62?(_=">",e++):(_=null,t('">"')),_===null&&(u.charCodeAt(e)===58?(_=":",e++):(_=null,t('":"')),_===null&&(u.charCodeAt(e)===92?(_="\\",e++):(_=null,t('"\\\\"')),_===null&&(_=O(),_===null&&(u.charCodeAt(e)===47?(_="/",e++):(_=null,t('"/"')),_===null&&(u.charCodeAt(e)===91?(_="[",e++):(_=null,t('"["')),_===null&&(u.charCodeAt(e)===93?(_="]",e++):(_=null,t('"]"')),_===null&&(u.charCodeAt(e)===63?(_="?",e++):(_=null,t('"?"')),_===null&&(u.charCodeAt(e)===123?(_="{",e++):(_=null,t('"{"')),_===null&&(u.charCodeAt(e)===125?(_="}",e++):(_=null,t('"}"'))))))))))))))))))))))))),_!==null)for(i=[];_!==null;)i.push(_),_=U(),_===null&&(u.charCodeAt(e)===45?(_="-",e++):(_=null,t('"-"')),_===null&&(u.charCodeAt(e)===46?(_=".",e++):(_=null,t('"."')),_===null&&(u.charCodeAt(e)===33?(_="!",e++):(_=null,t('"!"')),_===null&&(u.charCodeAt(e)===37?(_="%",e++):(_=null,t('"%"')),_===null&&(u.charCodeAt(e)===42?(_="*",e++):(_=null,t('"*"')),_===null&&(u.charCodeAt(e)===95?(_="_",e++):(_=null,t('"_"')),_===null&&(u.charCodeAt(e)===43?(_="+",e++):(_=null,t('"+"')),_===null&&(u.charCodeAt(e)===96?(_="`",e++):(_=null,t('"`"')),_===null&&(u.charCodeAt(e)===39?(_="'",e++):(_=null,t(`"'"`)),_===null&&(u.charCodeAt(e)===126?(_="~",e++):(_=null,t('"~"')),_===null&&(u.charCodeAt(e)===40?(_="(",e++):(_=null,t('"("')),_===null&&(u.charCodeAt(e)===41?(_=")",e++):(_=null,t('")"')),_===null&&(u.charCodeAt(e)===60?(_="<",e++):(_=null,t('"<"')),_===null&&(u.charCodeAt(e)===62?(_=">",e++):(_=null,t('">"')),_===null&&(u.charCodeAt(e)===58?(_=":",e++):(_=null,t('":"')),_===null&&(u.charCodeAt(e)===92?(_="\\",e++):(_=null,t('"\\\\"')),_===null&&(_=O(),_===null&&(u.charCodeAt(e)===47?(_="/",e++):(_=null,t('"/"')),_===null&&(u.charCodeAt(e)===91?(_="[",e++):(_=null,t('"["')),_===null&&(u.charCodeAt(e)===93?(_="]",e++):(_=null,t('"]"')),_===null&&(u.charCodeAt(e)===63?(_="?",e++):(_=null,t('"?"')),_===null&&(u.charCodeAt(e)===123?(_="{",e++):(_=null,t('"{"')),_===null&&(u.charCodeAt(e)===125?(_="}",e++):(_=null,t('"}"')))))))))))))))))))))))));else i=null;return i!==null&&(i=function(T){return u.substring(e,T)}(m)),i===null&&(e=m),i}function ne(){var i,_,m,T,y;return T=e,y=e,i=de(),i!==null?(u.charCodeAt(e)===42?(_="*",e++):(_=null,t('"*"')),_!==null?(m=de(),m!==null?i=[i,_,m]:(i=null,e=y)):(i=null,e=y)):(i=null,e=y),i!==null&&(i=function(r){return"*"}()),i===null&&(e=T),i}function ht(){var i,_,m,T,y;return T=e,y=e,i=de(),i!==null?(u.charCodeAt(e)===47?(_="/",e++):(_=null,t('"/"')),_!==null?(m=de(),m!==null?i=[i,_,m]:(i=null,e=y)):(i=null,e=y)):(i=null,e=y),i!==null&&(i=function(r){return"/"}()),i===null&&(e=T),i}function P(){var i,_,m,T,y;return T=e,y=e,i=de(),i!==null?(u.charCodeAt(e)===61?(_="=",e++):(_=null,t('"="')),_!==null?(m=de(),m!==null?i=[i,_,m]:(i=null,e=y)):(i=null,e=y)):(i=null,e=y),i!==null&&(i=function(r){return"="}()),i===null&&(e=T),i}function Q(){var i,_,m,T,y;return T=e,y=e,i=de(),i!==null?(u.charCodeAt(e)===40?(_="(",e++):(_=null,t('"("')),_!==null?(m=de(),m!==null?i=[i,_,m]:(i=null,e=y)):(i=null,e=y)):(i=null,e=y),i!==null&&(i=function(r){return"("}()),i===null&&(e=T),i}function oe(){var i,_,m,T,y;return T=e,y=e,i=de(),i!==null?(u.charCodeAt(e)===41?(_=")",e++):(_=null,t('")"')),_!==null?(m=de(),m!==null?i=[i,_,m]:(i=null,e=y)):(i=null,e=y)):(i=null,e=y),i!==null&&(i=function(r){return")"}()),i===null&&(e=T),i}function he(){var i,_,m,T;return m=e,T=e,u.charCodeAt(e)===62?(i=">",e++):(i=null,t('">"')),i!==null?(_=de(),_!==null?i=[i,_]:(i=null,e=T)):(i=null,e=T),i!==null&&(i=function(y){return">"}()),i===null&&(e=m),i}function Re(){var i,_,m,T;return m=e,T=e,i=de(),i!==null?(u.charCodeAt(e)===60?(_="<",e++):(_=null,t('"<"')),_!==null?i=[i,_]:(i=null,e=T)):(i=null,e=T),i!==null&&(i=function(y){return"<"}()),i===null&&(e=m),i}function be(){var i,_,m,T,y;return T=e,y=e,i=de(),i!==null?(u.charCodeAt(e)===44?(_=",",e++):(_=null,t('","')),_!==null?(m=de(),m!==null?i=[i,_,m]:(i=null,e=y)):(i=null,e=y)):(i=null,e=y),i!==null&&(i=function(r){return","}()),i===null&&(e=T),i}function fe(){var i,_,m,T,y;return T=e,y=e,i=de(),i!==null?(u.charCodeAt(e)===59?(_=";",e++):(_=null,t('";"')),_!==null?(m=de(),m!==null?i=[i,_,m]:(i=null,e=y)):(i=null,e=y)):(i=null,e=y),i!==null&&(i=function(r){return";"}()),i===null&&(e=T),i}function je(){var i,_,m,T,y;return T=e,y=e,i=de(),i!==null?(u.charCodeAt(e)===58?(_=":",e++):(_=null,t('":"')),_!==null?(m=de(),m!==null?i=[i,_,m]:(i=null,e=y)):(i=null,e=y)):(i=null,e=y),i!==null&&(i=function(r){return":"}()),i===null&&(e=T),i}function xe(){var i,_,m,T;return m=e,T=e,i=de(),i!==null?(_=O(),_!==null?i=[i,_]:(i=null,e=T)):(i=null,e=T),i!==null&&(i=function(y){return'"'}()),i===null&&(e=m),i}function we(){var i,_,m,T;return m=e,T=e,i=O(),i!==null?(_=de(),_!==null?i=[i,_]:(i=null,e=T)):(i=null,e=T),i!==null&&(i=function(y){return'"'}()),i===null&&(e=m),i}function rt(){var i,_,m,T;if(T=e,i=Q(),i!==null){for(_=[],m=$e(),m===null&&(m=Le(),m===null&&(m=rt()));m!==null;)_.push(m),m=$e(),m===null&&(m=Le(),m===null&&(m=rt()));_!==null?(m=oe(),m!==null?i=[i,_,m]:(i=null,e=T)):(i=null,e=T)}else i=null,e=T;return i}function $e(){var i;return/^[!-']/.test(u.charAt(e))?(i=u.charAt(e),e++):(i=null,t("[!-']")),i===null&&(/^[*-[]/.test(u.charAt(e))?(i=u.charAt(e),e++):(i=null,t("[*-[]")),i===null&&(/^[\]-~]/.test(u.charAt(e))?(i=u.charAt(e),e++):(i=null,t("[\\]-~]")),i===null&&(i=V(),i===null&&(i=H())))),i}function ue(){var i,_,m,T,y,r;if(y=e,r=e,i=de(),i!==null)if(_=O(),_!==null){for(m=[],T=Pe(),T===null&&(T=Le());T!==null;)m.push(T),T=Pe(),T===null&&(T=Le());m!==null?(T=O(),T!==null?i=[i,_,m,T]:(i=null,e=r)):(i=null,e=r)}else i=null,e=r;else i=null,e=r;return i!==null&&(i=function(f){return u.substring(e,f)}(y)),i===null&&(e=y),i}function Oe(){var i,_,m,T,y,r;if(y=e,r=e,i=de(),i!==null)if(_=O(),_!==null){for(m=[],T=Pe(),T===null&&(T=Le());T!==null;)m.push(T),T=Pe(),T===null&&(T=Le());m!==null?(T=O(),T!==null?i=[i,_,m,T]:(i=null,e=r)):(i=null,e=r)}else i=null,e=r;else i=null,e=r;return i!==null&&(i=function(f){var d=u.substring(e,f).trim();return d.substring(1,d.length-1).replace(/\\([\x00-\x09\x0b-\x0c\x0e-\x7f])/g,"$1")}(y)),i===null&&(e=y),i}function Pe(){var i;return i=H(),i===null&&(u.charCodeAt(e)===33?(i="!",e++):(i=null,t('"!"')),i===null&&(/^[#-[]/.test(u.charAt(e))?(i=u.charAt(e),e++):(i=null,t("[#-[]")),i===null&&(/^[\]-~]/.test(u.charAt(e))?(i=u.charAt(e),e++):(i=null,t("[\\]-~]")),i===null&&(i=V())))),i}function Le(){var i,_,m;return m=e,u.charCodeAt(e)===92?(i="\\",e++):(i=null,t('"\\\\"')),i!==null?(/^[\0-\t]/.test(u.charAt(e))?(_=u.charAt(e),e++):(_=null,t("[\\0-\\t]")),_===null&&(/^[\x0B-\f]/.test(u.charAt(e))?(_=u.charAt(e),e++):(_=null,t("[\\x0B-\\f]")),_===null&&(/^[\x0E-]/.test(u.charAt(e))?(_=u.charAt(e),e++):(_=null,t("[\\x0E-]")))),_!==null?i=[i,_]:(i=null,e=m)):(i=null,e=m),i}function ye(){var i,_,m,T,y,r;return y=e,r=e,i=Ce(),i!==null?(u.charCodeAt(e)===58?(_=":",e++):(_=null,t('":"')),_!==null?(m=We(),m=m!==null?m:"",m!==null?(T=Xs(),T!==null?i=[i,_,m,T]:(i=null,e=r)):(i=null,e=r)):(i=null,e=r)):(i=null,e=r),i!==null&&(i=function(f){try{x.uri=new tl(x.scheme,x.user,x.host,x.port),delete x.scheme,delete x.user,delete x.host,delete x.host_type,delete x.port}catch{x=-1}}()),i===null&&(e=y),i}function pe(){var i,_,m,T,y,r,f,d;return f=e,d=e,i=Ce(),i!==null?(u.charCodeAt(e)===58?(_=":",e++):(_=null,t('":"')),_!==null?(m=We(),m=m!==null?m:"",m!==null?(T=Xs(),T!==null?(y=_s(),y!==null?(r=fl(),r=r!==null?r:"",r!==null?i=[i,_,m,T,y,r]:(i=null,e=d)):(i=null,e=d)):(i=null,e=d)):(i=null,e=d)):(i=null,e=d)):(i=null,e=d),i!==null&&(i=function(c){try{x.uri=new tl(x.scheme,x.user,x.host,x.port,x.uri_params,x.uri_headers),delete x.scheme,delete x.user,delete x.host,delete x.host_type,delete x.port,delete x.uri_params,n==="SIP_URI"&&(x=x.uri)}catch{x=-1}}()),i===null&&(e=f),i}function Ce(){var i;return i=ke(),i===null&&(i=He()),i}function ke(){var i,_;return _=e,u.substr(e,4).toLowerCase()==="sips"?(i=u.substr(e,4),e+=4):(i=null,t('"sips"')),i!==null&&(i=function(m,T){x.scheme=T.toLowerCase()}(_,i)),i===null&&(e=_),i}function He(){var i,_;return _=e,u.substr(e,3).toLowerCase()==="sip"?(i=u.substr(e,3),e+=3):(i=null,t('"sip"')),i!==null&&(i=function(T,y){x.scheme=y.toLowerCase()}(_,i)),i===null&&(e=_),i}function We(){var i,_,m,T,y,r;return T=e,y=e,i=Ve(),i!==null?(r=e,u.charCodeAt(e)===58?(_=":",e++):(_=null,t('":"')),_!==null?(m=_t(),m!==null?_=[_,m]:(_=null,e=r)):(_=null,e=r),_=_!==null?_:"",_!==null?(u.charCodeAt(e)===64?(m="@",e++):(m=null,t('"@"')),m!==null?i=[i,_,m]:(i=null,e=y)):(i=null,e=y)):(i=null,e=y),i!==null&&(i=function(f){x.user=decodeURIComponent(u.substring(e-1,f))}(T)),i===null&&(e=T),i}function Ve(){var i,_;if(_=j(),_===null&&(_=k(),_===null&&(_=Ht())),_!==null)for(i=[];_!==null;)i.push(_),_=j(),_===null&&(_=k(),_===null&&(_=Ht()));else i=null;return i}function Ht(){var i;return u.charCodeAt(e)===38?(i="&",e++):(i=null,t('"&"')),i===null&&(u.charCodeAt(e)===61?(i="=",e++):(i=null,t('"="')),i===null&&(u.charCodeAt(e)===43?(i="+",e++):(i=null,t('"+"')),i===null&&(u.charCodeAt(e)===36?(i="$",e++):(i=null,t('"$"')),i===null&&(u.charCodeAt(e)===44?(i=",",e++):(i=null,t('","')),i===null&&(u.charCodeAt(e)===59?(i=";",e++):(i=null,t('";"')),i===null&&(u.charCodeAt(e)===63?(i="?",e++):(i=null,t('"?"')),i===null&&(u.charCodeAt(e)===47?(i="/",e++):(i=null,t('"/"'))))))))),i}function _t(){var i,_,m;for(m=e,i=[],_=j(),_===null&&(_=k(),_===null&&(u.charCodeAt(e)===38?(_="&",e++):(_=null,t('"&"')),_===null&&(u.charCodeAt(e)===61?(_="=",e++):(_=null,t('"="')),_===null&&(u.charCodeAt(e)===43?(_="+",e++):(_=null,t('"+"')),_===null&&(u.charCodeAt(e)===36?(_="$",e++):(_=null,t('"$"')),_===null&&(u.charCodeAt(e)===44?(_=",",e++):(_=null,t('","'))))))));_!==null;)i.push(_),_=j(),_===null&&(_=k(),_===null&&(u.charCodeAt(e)===38?(_="&",e++):(_=null,t('"&"')),_===null&&(u.charCodeAt(e)===61?(_="=",e++):(_=null,t('"="')),_===null&&(u.charCodeAt(e)===43?(_="+",e++):(_=null,t('"+"')),_===null&&(u.charCodeAt(e)===36?(_="$",e++):(_=null,t('"$"')),_===null&&(u.charCodeAt(e)===44?(_=",",e++):(_=null,t('","'))))))));return i!==null&&(i=function(T){x.password=u.substring(e,T)}(m)),i===null&&(e=m),i}function Xs(){var i,_,m,T,y;return T=e,i=cs(),i!==null?(y=e,u.charCodeAt(e)===58?(_=":",e++):(_=null,t('":"')),_!==null?(m=vt(),m!==null?_=[_,m]:(_=null,e=y)):(_=null,e=y),_=_!==null?_:"",_!==null?i=[i,_]:(i=null,e=T)):(i=null,e=T),i}function cs(){var i,_;return _=e,i=Is(),i===null&&(i=Zt(),i===null&&(i=Qs())),i!==null&&(i=function(m){return x.host=u.substring(e,m).toLowerCase(),x.host}(_)),i===null&&(e=_),i}function Is(){var i,_,m,T,y,r;for(T=e,y=e,i=[],r=e,_=ws(),_!==null?(u.charCodeAt(e)===46?(m=".",e++):(m=null,t('"."')),m!==null?_=[_,m]:(_=null,e=r)):(_=null,e=r);_!==null;)i.push(_),r=e,_=ws(),_!==null?(u.charCodeAt(e)===46?(m=".",e++):(m=null,t('"."')),m!==null?_=[_,m]:(_=null,e=r)):(_=null,e=r);return i!==null?(_=fs(),_!==null?(u.charCodeAt(e)===46?(m=".",e++):(m=null,t('"."')),m=m!==null?m:"",m!==null?i=[i,_,m]:(i=null,e=y)):(i=null,e=y)):(i=null,e=y),i!==null&&(i=function(f){return x.host_type="domain",u.substring(e,f)}(T)),i===null&&(e=T),i}function ws(){var i,_,m,T;if(T=e,i=U(),i!==null){for(_=[],m=U(),m===null&&(u.charCodeAt(e)===45?(m="-",e++):(m=null,t('"-"')),m===null&&(u.charCodeAt(e)===95?(m="_",e++):(m=null,t('"_"'))));m!==null;)_.push(m),m=U(),m===null&&(u.charCodeAt(e)===45?(m="-",e++):(m=null,t('"-"')),m===null&&(u.charCodeAt(e)===95?(m="_",e++):(m=null,t('"_"'))));_!==null?i=[i,_]:(i=null,e=T)}else i=null,e=T;return i}function fs(){var i,_,m,T;if(T=e,i=l(),i!==null){for(_=[],m=U(),m===null&&(u.charCodeAt(e)===45?(m="-",e++):(m=null,t('"-"')),m===null&&(u.charCodeAt(e)===95?(m="_",e++):(m=null,t('"_"'))));m!==null;)_.push(m),m=U(),m===null&&(u.charCodeAt(e)===45?(m="-",e++):(m=null,t('"-"')),m===null&&(u.charCodeAt(e)===95?(m="_",e++):(m=null,t('"_"'))));_!==null?i=[i,_]:(i=null,e=T)}else i=null,e=T;return i}function Qs(){var i,_,m,T,y;return T=e,y=e,u.charCodeAt(e)===91?(i="[",e++):(i=null,t('"["')),i!==null?(_=hs(),_!==null?(u.charCodeAt(e)===93?(m="]",e++):(m=null,t('"]"')),m!==null?i=[i,_,m]:(i=null,e=y)):(i=null,e=y)):(i=null,e=y),i!==null&&(i=function(r){return x.host_type="IPv6",u.substring(e,r)}(T)),i===null&&(e=T),i}function hs(){var i,_,m,T,y,r,f,d,s,c,h,g,S,R,I,D;return R=e,I=e,i=Se(),i!==null?(u.charCodeAt(e)===58?(_=":",e++):(_=null,t('":"')),_!==null?(m=Se(),m!==null?(u.charCodeAt(e)===58?(T=":",e++):(T=null,t('":"')),T!==null?(y=Se(),y!==null?(u.charCodeAt(e)===58?(r=":",e++):(r=null,t('":"')),r!==null?(f=Se(),f!==null?(u.charCodeAt(e)===58?(d=":",e++):(d=null,t('":"')),d!==null?(s=Se(),s!==null?(u.charCodeAt(e)===58?(c=":",e++):(c=null,t('":"')),c!==null?(h=Se(),h!==null?(u.charCodeAt(e)===58?(g=":",e++):(g=null,t('":"')),g!==null?(S=dt(),S!==null?i=[i,_,m,T,y,r,f,d,s,c,h,g,S]:(i=null,e=I)):(i=null,e=I)):(i=null,e=I)):(i=null,e=I)):(i=null,e=I)):(i=null,e=I)):(i=null,e=I)):(i=null,e=I)):(i=null,e=I)):(i=null,e=I)):(i=null,e=I)):(i=null,e=I)):(i=null,e=I),i===null&&(I=e,u.substr(e,2)==="::"?(i="::",e+=2):(i=null,t('"::"')),i!==null?(_=Se(),_!==null?(u.charCodeAt(e)===58?(m=":",e++):(m=null,t('":"')),m!==null?(T=Se(),T!==null?(u.charCodeAt(e)===58?(y=":",e++):(y=null,t('":"')),y!==null?(r=Se(),r!==null?(u.charCodeAt(e)===58?(f=":",e++):(f=null,t('":"')),f!==null?(d=Se(),d!==null?(u.charCodeAt(e)===58?(s=":",e++):(s=null,t('":"')),s!==null?(c=Se(),c!==null?(u.charCodeAt(e)===58?(h=":",e++):(h=null,t('":"')),h!==null?(g=dt(),g!==null?i=[i,_,m,T,y,r,f,d,s,c,h,g]:(i=null,e=I)):(i=null,e=I)):(i=null,e=I)):(i=null,e=I)):(i=null,e=I)):(i=null,e=I)):(i=null,e=I)):(i=null,e=I)):(i=null,e=I)):(i=null,e=I)):(i=null,e=I)):(i=null,e=I),i===null&&(I=e,u.substr(e,2)==="::"?(i="::",e+=2):(i=null,t('"::"')),i!==null?(_=Se(),_!==null?(u.charCodeAt(e)===58?(m=":",e++):(m=null,t('":"')),m!==null?(T=Se(),T!==null?(u.charCodeAt(e)===58?(y=":",e++):(y=null,t('":"')),y!==null?(r=Se(),r!==null?(u.charCodeAt(e)===58?(f=":",e++):(f=null,t('":"')),f!==null?(d=Se(),d!==null?(u.charCodeAt(e)===58?(s=":",e++):(s=null,t('":"')),s!==null?(c=dt(),c!==null?i=[i,_,m,T,y,r,f,d,s,c]:(i=null,e=I)):(i=null,e=I)):(i=null,e=I)):(i=null,e=I)):(i=null,e=I)):(i=null,e=I)):(i=null,e=I)):(i=null,e=I)):(i=null,e=I)):(i=null,e=I),i===null&&(I=e,u.substr(e,2)==="::"?(i="::",e+=2):(i=null,t('"::"')),i!==null?(_=Se(),_!==null?(u.charCodeAt(e)===58?(m=":",e++):(m=null,t('":"')),m!==null?(T=Se(),T!==null?(u.charCodeAt(e)===58?(y=":",e++):(y=null,t('":"')),y!==null?(r=Se(),r!==null?(u.charCodeAt(e)===58?(f=":",e++):(f=null,t('":"')),f!==null?(d=dt(),d!==null?i=[i,_,m,T,y,r,f,d]:(i=null,e=I)):(i=null,e=I)):(i=null,e=I)):(i=null,e=I)):(i=null,e=I)):(i=null,e=I)):(i=null,e=I)):(i=null,e=I),i===null&&(I=e,u.substr(e,2)==="::"?(i="::",e+=2):(i=null,t('"::"')),i!==null?(_=Se(),_!==null?(u.charCodeAt(e)===58?(m=":",e++):(m=null,t('":"')),m!==null?(T=Se(),T!==null?(u.charCodeAt(e)===58?(y=":",e++):(y=null,t('":"')),y!==null?(r=dt(),r!==null?i=[i,_,m,T,y,r]:(i=null,e=I)):(i=null,e=I)):(i=null,e=I)):(i=null,e=I)):(i=null,e=I)):(i=null,e=I),i===null&&(I=e,u.substr(e,2)==="::"?(i="::",e+=2):(i=null,t('"::"')),i!==null?(_=Se(),_!==null?(u.charCodeAt(e)===58?(m=":",e++):(m=null,t('":"')),m!==null?(T=dt(),T!==null?i=[i,_,m,T]:(i=null,e=I)):(i=null,e=I)):(i=null,e=I)):(i=null,e=I),i===null&&(I=e,u.substr(e,2)==="::"?(i="::",e+=2):(i=null,t('"::"')),i!==null?(_=dt(),_!==null?i=[i,_]:(i=null,e=I)):(i=null,e=I),i===null&&(I=e,u.substr(e,2)==="::"?(i="::",e+=2):(i=null,t('"::"')),i!==null?(_=Se(),_!==null?i=[i,_]:(i=null,e=I)):(i=null,e=I),i===null&&(I=e,i=Se(),i!==null?(u.substr(e,2)==="::"?(_="::",e+=2):(_=null,t('"::"')),_!==null?(m=Se(),m!==null?(u.charCodeAt(e)===58?(T=":",e++):(T=null,t('":"')),T!==null?(y=Se(),y!==null?(u.charCodeAt(e)===58?(r=":",e++):(r=null,t('":"')),r!==null?(f=Se(),f!==null?(u.charCodeAt(e)===58?(d=":",e++):(d=null,t('":"')),d!==null?(s=Se(),s!==null?(u.charCodeAt(e)===58?(c=":",e++):(c=null,t('":"')),c!==null?(h=dt(),h!==null?i=[i,_,m,T,y,r,f,d,s,c,h]:(i=null,e=I)):(i=null,e=I)):(i=null,e=I)):(i=null,e=I)):(i=null,e=I)):(i=null,e=I)):(i=null,e=I)):(i=null,e=I)):(i=null,e=I)):(i=null,e=I)):(i=null,e=I),i===null&&(I=e,i=Se(),i!==null?(D=e,u.charCodeAt(e)===58?(_=":",e++):(_=null,t('":"')),_!==null?(m=Se(),m!==null?_=[_,m]:(_=null,e=D)):(_=null,e=D),_=_!==null?_:"",_!==null?(u.substr(e,2)==="::"?(m="::",e+=2):(m=null,t('"::"')),m!==null?(T=Se(),T!==null?(u.charCodeAt(e)===58?(y=":",e++):(y=null,t('":"')),y!==null?(r=Se(),r!==null?(u.charCodeAt(e)===58?(f=":",e++):(f=null,t('":"')),f!==null?(d=Se(),d!==null?(u.charCodeAt(e)===58?(s=":",e++):(s=null,t('":"')),s!==null?(c=dt(),c!==null?i=[i,_,m,T,y,r,f,d,s,c]:(i=null,e=I)):(i=null,e=I)):(i=null,e=I)):(i=null,e=I)):(i=null,e=I)):(i=null,e=I)):(i=null,e=I)):(i=null,e=I)):(i=null,e=I)):(i=null,e=I),i===null&&(I=e,i=Se(),i!==null?(D=e,u.charCodeAt(e)===58?(_=":",e++):(_=null,t('":"')),_!==null?(m=Se(),m!==null?_=[_,m]:(_=null,e=D)):(_=null,e=D),_=_!==null?_:"",_!==null?(D=e,u.charCodeAt(e)===58?(m=":",e++):(m=null,t('":"')),m!==null?(T=Se(),T!==null?m=[m,T]:(m=null,e=D)):(m=null,e=D),m=m!==null?m:"",m!==null?(u.substr(e,2)==="::"?(T="::",e+=2):(T=null,t('"::"')),T!==null?(y=Se(),y!==null?(u.charCodeAt(e)===58?(r=":",e++):(r=null,t('":"')),r!==null?(f=Se(),f!==null?(u.charCodeAt(e)===58?(d=":",e++):(d=null,t('":"')),d!==null?(s=dt(),s!==null?i=[i,_,m,T,y,r,f,d,s]:(i=null,e=I)):(i=null,e=I)):(i=null,e=I)):(i=null,e=I)):(i=null,e=I)):(i=null,e=I)):(i=null,e=I)):(i=null,e=I)):(i=null,e=I),i===null&&(I=e,i=Se(),i!==null?(D=e,u.charCodeAt(e)===58?(_=":",e++):(_=null,t('":"')),_!==null?(m=Se(),m!==null?_=[_,m]:(_=null,e=D)):(_=null,e=D),_=_!==null?_:"",_!==null?(D=e,u.charCodeAt(e)===58?(m=":",e++):(m=null,t('":"')),m!==null?(T=Se(),T!==null?m=[m,T]:(m=null,e=D)):(m=null,e=D),m=m!==null?m:"",m!==null?(D=e,u.charCodeAt(e)===58?(T=":",e++):(T=null,t('":"')),T!==null?(y=Se(),y!==null?T=[T,y]:(T=null,e=D)):(T=null,e=D),T=T!==null?T:"",T!==null?(u.substr(e,2)==="::"?(y="::",e+=2):(y=null,t('"::"')),y!==null?(r=Se(),r!==null?(u.charCodeAt(e)===58?(f=":",e++):(f=null,t('":"')),f!==null?(d=dt(),d!==null?i=[i,_,m,T,y,r,f,d]:(i=null,e=I)):(i=null,e=I)):(i=null,e=I)):(i=null,e=I)):(i=null,e=I)):(i=null,e=I)):(i=null,e=I)):(i=null,e=I),i===null&&(I=e,i=Se(),i!==null?(D=e,u.charCodeAt(e)===58?(_=":",e++):(_=null,t('":"')),_!==null?(m=Se(),m!==null?_=[_,m]:(_=null,e=D)):(_=null,e=D),_=_!==null?_:"",_!==null?(D=e,u.charCodeAt(e)===58?(m=":",e++):(m=null,t('":"')),m!==null?(T=Se(),T!==null?m=[m,T]:(m=null,e=D)):(m=null,e=D),m=m!==null?m:"",m!==null?(D=e,u.charCodeAt(e)===58?(T=":",e++):(T=null,t('":"')),T!==null?(y=Se(),y!==null?T=[T,y]:(T=null,e=D)):(T=null,e=D),T=T!==null?T:"",T!==null?(D=e,u.charCodeAt(e)===58?(y=":",e++):(y=null,t('":"')),y!==null?(r=Se(),r!==null?y=[y,r]:(y=null,e=D)):(y=null,e=D),y=y!==null?y:"",y!==null?(u.substr(e,2)==="::"?(r="::",e+=2):(r=null,t('"::"')),r!==null?(f=dt(),f!==null?i=[i,_,m,T,y,r,f]:(i=null,e=I)):(i=null,e=I)):(i=null,e=I)):(i=null,e=I)):(i=null,e=I)):(i=null,e=I)):(i=null,e=I),i===null&&(I=e,i=Se(),i!==null?(D=e,u.charCodeAt(e)===58?(_=":",e++):(_=null,t('":"')),_!==null?(m=Se(),m!==null?_=[_,m]:(_=null,e=D)):(_=null,e=D),_=_!==null?_:"",_!==null?(D=e,u.charCodeAt(e)===58?(m=":",e++):(m=null,t('":"')),m!==null?(T=Se(),T!==null?m=[m,T]:(m=null,e=D)):(m=null,e=D),m=m!==null?m:"",m!==null?(D=e,u.charCodeAt(e)===58?(T=":",e++):(T=null,t('":"')),T!==null?(y=Se(),y!==null?T=[T,y]:(T=null,e=D)):(T=null,e=D),T=T!==null?T:"",T!==null?(D=e,u.charCodeAt(e)===58?(y=":",e++):(y=null,t('":"')),y!==null?(r=Se(),r!==null?y=[y,r]:(y=null,e=D)):(y=null,e=D),y=y!==null?y:"",y!==null?(D=e,u.charCodeAt(e)===58?(r=":",e++):(r=null,t('":"')),r!==null?(f=Se(),f!==null?r=[r,f]:(r=null,e=D)):(r=null,e=D),r=r!==null?r:"",r!==null?(u.substr(e,2)==="::"?(f="::",e+=2):(f=null,t('"::"')),f!==null?(d=Se(),d!==null?i=[i,_,m,T,y,r,f,d]:(i=null,e=I)):(i=null,e=I)):(i=null,e=I)):(i=null,e=I)):(i=null,e=I)):(i=null,e=I)):(i=null,e=I)):(i=null,e=I),i===null&&(I=e,i=Se(),i!==null?(D=e,u.charCodeAt(e)===58?(_=":",e++):(_=null,t('":"')),_!==null?(m=Se(),m!==null?_=[_,m]:(_=null,e=D)):(_=null,e=D),_=_!==null?_:"",_!==null?(D=e,u.charCodeAt(e)===58?(m=":",e++):(m=null,t('":"')),m!==null?(T=Se(),T!==null?m=[m,T]:(m=null,e=D)):(m=null,e=D),m=m!==null?m:"",m!==null?(D=e,u.charCodeAt(e)===58?(T=":",e++):(T=null,t('":"')),T!==null?(y=Se(),y!==null?T=[T,y]:(T=null,e=D)):(T=null,e=D),T=T!==null?T:"",T!==null?(D=e,u.charCodeAt(e)===58?(y=":",e++):(y=null,t('":"')),y!==null?(r=Se(),r!==null?y=[y,r]:(y=null,e=D)):(y=null,e=D),y=y!==null?y:"",y!==null?(D=e,u.charCodeAt(e)===58?(r=":",e++):(r=null,t('":"')),r!==null?(f=Se(),f!==null?r=[r,f]:(r=null,e=D)):(r=null,e=D),r=r!==null?r:"",r!==null?(D=e,u.charCodeAt(e)===58?(f=":",e++):(f=null,t('":"')),f!==null?(d=Se(),d!==null?f=[f,d]:(f=null,e=D)):(f=null,e=D),f=f!==null?f:"",f!==null?(u.substr(e,2)==="::"?(d="::",e+=2):(d=null,t('"::"')),d!==null?i=[i,_,m,T,y,r,f,d]:(i=null,e=I)):(i=null,e=I)):(i=null,e=I)):(i=null,e=I)):(i=null,e=I)):(i=null,e=I)):(i=null,e=I)):(i=null,e=I))))))))))))))),i!==null&&(i=function(J){return x.host_type="IPv6",u.substring(e,J)}(R)),i===null&&(e=R),i}function Se(){var i,_,m,T,y;return y=e,i=A(),i!==null?(_=A(),_=_!==null?_:"",_!==null?(m=A(),m=m!==null?m:"",m!==null?(T=A(),T=T!==null?T:"",T!==null?i=[i,_,m,T]:(i=null,e=y)):(i=null,e=y)):(i=null,e=y)):(i=null,e=y),i}function dt(){var i,_,m,T;return T=e,i=Se(),i!==null?(u.charCodeAt(e)===58?(_=":",e++):(_=null,t('":"')),_!==null?(m=Se(),m!==null?i=[i,_,m]:(i=null,e=T)):(i=null,e=T)):(i=null,e=T),i===null&&(i=Zt()),i}function Zt(){var i,_,m,T,y,r,f,d,s;return d=e,s=e,i=Ae(),i!==null?(u.charCodeAt(e)===46?(_=".",e++):(_=null,t('"."')),_!==null?(m=Ae(),m!==null?(u.charCodeAt(e)===46?(T=".",e++):(T=null,t('"."')),T!==null?(y=Ae(),y!==null?(u.charCodeAt(e)===46?(r=".",e++):(r=null,t('"."')),r!==null?(f=Ae(),f!==null?i=[i,_,m,T,y,r,f]:(i=null,e=s)):(i=null,e=s)):(i=null,e=s)):(i=null,e=s)):(i=null,e=s)):(i=null,e=s)):(i=null,e=s),i!==null&&(i=function(c){return x.host_type="IPv4",u.substring(e,c)}(d)),i===null&&(e=d),i}function Ae(){var i,_,m,T;return T=e,u.substr(e,2)==="25"?(i="25",e+=2):(i=null,t('"25"')),i!==null?(/^[0-5]/.test(u.charAt(e))?(_=u.charAt(e),e++):(_=null,t("[0-5]")),_!==null?i=[i,_]:(i=null,e=T)):(i=null,e=T),i===null&&(T=e,u.charCodeAt(e)===50?(i="2",e++):(i=null,t('"2"')),i!==null?(/^[0-4]/.test(u.charAt(e))?(_=u.charAt(e),e++):(_=null,t("[0-4]")),_!==null?(m=C(),m!==null?i=[i,_,m]:(i=null,e=T)):(i=null,e=T)):(i=null,e=T),i===null&&(T=e,u.charCodeAt(e)===49?(i="1",e++):(i=null,t('"1"')),i!==null?(_=C(),_!==null?(m=C(),m!==null?i=[i,_,m]:(i=null,e=T)):(i=null,e=T)):(i=null,e=T),i===null&&(T=e,/^[1-9]/.test(u.charAt(e))?(i=u.charAt(e),e++):(i=null,t("[1-9]")),i!==null?(_=C(),_!==null?i=[i,_]:(i=null,e=T)):(i=null,e=T),i===null&&(i=C())))),i}function vt(){var i,_,m,T,y,r,f;return r=e,f=e,i=C(),i=i!==null?i:"",i!==null?(_=C(),_=_!==null?_:"",_!==null?(m=C(),m=m!==null?m:"",m!==null?(T=C(),T=T!==null?T:"",T!==null?(y=C(),y=y!==null?y:"",y!==null?i=[i,_,m,T,y]:(i=null,e=f)):(i=null,e=f)):(i=null,e=f)):(i=null,e=f)):(i=null,e=f),i!==null&&(i=function(d,s){return s=parseInt(s.join("")),x.port=s,s}(r,i)),i===null&&(e=r),i}function _s(){var i,_,m,T;for(i=[],T=e,u.charCodeAt(e)===59?(_=";",e++):(_=null,t('";"')),_!==null?(m=Ee(),m!==null?_=[_,m]:(_=null,e=T)):(_=null,e=T);_!==null;)i.push(_),T=e,u.charCodeAt(e)===59?(_=";",e++):(_=null,t('";"')),_!==null?(m=Ee(),m!==null?_=[_,m]:(_=null,e=T)):(_=null,e=T);return i}function Ee(){var i;return i=Et(),i===null&&(i=Os(),i===null&&(i=ds(),i===null&&(i=rl(),i===null&&(i=il(),i===null&&(i=In(),i===null&&(i=al())))))),i}function Et(){var i,_,m,T;return m=e,T=e,u.substr(e,10).toLowerCase()==="transport="?(i=u.substr(e,10),e+=10):(i=null,t('"transport="')),i!==null?(u.substr(e,3).toLowerCase()==="udp"?(_=u.substr(e,3),e+=3):(_=null,t('"udp"')),_===null&&(u.substr(e,3).toLowerCase()==="tcp"?(_=u.substr(e,3),e+=3):(_=null,t('"tcp"')),_===null&&(u.substr(e,4).toLowerCase()==="sctp"?(_=u.substr(e,4),e+=4):(_=null,t('"sctp"')),_===null&&(u.substr(e,3).toLowerCase()==="tls"?(_=u.substr(e,3),e+=3):(_=null,t('"tls"')),_===null&&(_=M())))),_!==null?i=[i,_]:(i=null,e=T)):(i=null,e=T),i!==null&&(i=function(y,r){x.uri_params||(x.uri_params={}),x.uri_params.transport=r.toLowerCase()}(m,i[1])),i===null&&(e=m),i}function Os(){var i,_,m,T;return m=e,T=e,u.substr(e,5).toLowerCase()==="user="?(i=u.substr(e,5),e+=5):(i=null,t('"user="')),i!==null?(u.substr(e,5).toLowerCase()==="phone"?(_=u.substr(e,5),e+=5):(_=null,t('"phone"')),_===null&&(u.substr(e,2).toLowerCase()==="ip"?(_=u.substr(e,2),e+=2):(_=null,t('"ip"')),_===null&&(_=M())),_!==null?i=[i,_]:(i=null,e=T)):(i=null,e=T),i!==null&&(i=function(y,r){x.uri_params||(x.uri_params={}),x.uri_params.user=r.toLowerCase()}(m,i[1])),i===null&&(e=m),i}function ds(){var i,_,m,T;return m=e,T=e,u.substr(e,7).toLowerCase()==="method="?(i=u.substr(e,7),e+=7):(i=null,t('"method="')),i!==null?(_=tn(),_!==null?i=[i,_]:(i=null,e=T)):(i=null,e=T),i!==null&&(i=function(y,r){x.uri_params||(x.uri_params={}),x.uri_params.method=r}(m,i[1])),i===null&&(e=m),i}function rl(){var i,_,m,T;return m=e,T=e,u.substr(e,4).toLowerCase()==="ttl="?(i=u.substr(e,4),e+=4):(i=null,t('"ttl="')),i!==null?(_=Vn(),_!==null?i=[i,_]:(i=null,e=T)):(i=null,e=T),i!==null&&(i=function(y,r){x.params||(x.params={}),x.params.ttl=r}(m,i[1])),i===null&&(e=m),i}function il(){var i,_,m,T;return m=e,T=e,u.substr(e,6).toLowerCase()==="maddr="?(i=u.substr(e,6),e+=6):(i=null,t('"maddr="')),i!==null?(_=cs(),_!==null?i=[i,_]:(i=null,e=T)):(i=null,e=T),i!==null&&(i=function(y,r){x.uri_params||(x.uri_params={}),x.uri_params.maddr=r}(m,i[1])),i===null&&(e=m),i}function In(){var i,_,m,T,y,r;return T=e,y=e,u.substr(e,2).toLowerCase()==="lr"?(i=u.substr(e,2),e+=2):(i=null,t('"lr"')),i!==null?(r=e,u.charCodeAt(e)===61?(_="=",e++):(_=null,t('"="')),_!==null?(m=M(),m!==null?_=[_,m]:(_=null,e=r)):(_=null,e=r),_=_!==null?_:"",_!==null?i=[i,_]:(i=null,e=y)):(i=null,e=y),i!==null&&(i=function(f){x.uri_params||(x.uri_params={}),x.uri_params.lr=void 0}()),i===null&&(e=T),i}function al(){var i,_,m,T,y,r;return T=e,y=e,i=ol(),i!==null?(r=e,u.charCodeAt(e)===61?(_="=",e++):(_=null,t('"="')),_!==null?(m=ul(),m!==null?_=[_,m]:(_=null,e=r)):(_=null,e=r),_=_!==null?_:"",_!==null?i=[i,_]:(i=null,e=y)):(i=null,e=y),i!==null&&(i=function(f,d,s){x.uri_params||(x.uri_params={}),typeof s>"u"?s=void 0:s=s[1],x.uri_params[d.toLowerCase()]=s}(T,i[0],i[1])),i===null&&(e=T),i}function ol(){var i,_,m;if(m=e,_=Ds(),_!==null)for(i=[];_!==null;)i.push(_),_=Ds();else i=null;return i!==null&&(i=function(T,y){return y.join("")}(m,i)),i===null&&(e=m),i}function ul(){var i,_,m;if(m=e,_=Ds(),_!==null)for(i=[];_!==null;)i.push(_),_=Ds();else i=null;return i!==null&&(i=function(T,y){return y.join("")}(m,i)),i===null&&(e=m),i}function Ds(){var i;return i=cl(),i===null&&(i=j(),i===null&&(i=k())),i}function cl(){var i;return u.charCodeAt(e)===91?(i="[",e++):(i=null,t('"["')),i===null&&(u.charCodeAt(e)===93?(i="]",e++):(i=null,t('"]"')),i===null&&(u.charCodeAt(e)===47?(i="/",e++):(i=null,t('"/"')),i===null&&(u.charCodeAt(e)===58?(i=":",e++):(i=null,t('":"')),i===null&&(u.charCodeAt(e)===38?(i="&",e++):(i=null,t('"&"')),i===null&&(u.charCodeAt(e)===43?(i="+",e++):(i=null,t('"+"')),i===null&&(u.charCodeAt(e)===36?(i="$",e++):(i=null,t('"$"')))))))),i}function fl(){var i,_,m,T,y,r,f;if(r=e,u.charCodeAt(e)===63?(i="?",e++):(i=null,t('"?"')),i!==null)if(_=es(),_!==null){for(m=[],f=e,u.charCodeAt(e)===38?(T="&",e++):(T=null,t('"&"')),T!==null?(y=es(),y!==null?T=[T,y]:(T=null,e=f)):(T=null,e=f);T!==null;)m.push(T),f=e,u.charCodeAt(e)===38?(T="&",e++):(T=null,t('"&"')),T!==null?(y=es(),y!==null?T=[T,y]:(T=null,e=f)):(T=null,e=f);m!==null?i=[i,_,m]:(i=null,e=r)}else i=null,e=r;else i=null,e=r;return i}function es(){var i,_,m,T,y;return T=e,y=e,i=hl(),i!==null?(u.charCodeAt(e)===61?(_="=",e++):(_=null,t('"="')),_!==null?(m=_l(),m!==null?i=[i,_,m]:(i=null,e=y)):(i=null,e=y)):(i=null,e=y),i!==null&&(i=function(r,f,d){f=f.join("").toLowerCase(),d=d.join(""),x.uri_headers||(x.uri_headers={}),x.uri_headers[f]?x.uri_headers[f].push(d):x.uri_headers[f]=[d]}(T,i[0],i[2])),i===null&&(e=T),i}function hl(){var i,_;if(_=Ft(),_===null&&(_=j(),_===null&&(_=k())),_!==null)for(i=[];_!==null;)i.push(_),_=Ft(),_===null&&(_=j(),_===null&&(_=k()));else i=null;return i}function _l(){var i,_;for(i=[],_=Ft(),_===null&&(_=j(),_===null&&(_=k()));_!==null;)i.push(_),_=Ft(),_===null&&(_=j(),_===null&&(_=k()));return i}function Ft(){var i;return u.charCodeAt(e)===91?(i="[",e++):(i=null,t('"["')),i===null&&(u.charCodeAt(e)===93?(i="]",e++):(i=null,t('"]"')),i===null&&(u.charCodeAt(e)===47?(i="/",e++):(i=null,t('"/"')),i===null&&(u.charCodeAt(e)===63?(i="?",e++):(i=null,t('"?"')),i===null&&(u.charCodeAt(e)===58?(i=":",e++):(i=null,t('":"')),i===null&&(u.charCodeAt(e)===43?(i="+",e++):(i=null,t('"+"')),i===null&&(u.charCodeAt(e)===36?(i="$",e++):(i=null,t('"$"')))))))),i}function dr(){var i;return i=bl(),i===null&&(i=dl()),i}function dl(){var i,_,m,T,y,r;return r=e,i=tn(),i!==null?(_=w(),_!==null?(m=ts(),m!==null?(T=w(),T!==null?(y=ps(),y!==null?i=[i,_,m,T,y]:(i=null,e=r)):(i=null,e=r)):(i=null,e=r)):(i=null,e=r)):(i=null,e=r),i}function ts(){var i;return i=pe(),i===null&&(i=pl()),i}function pl(){var i,_,m,T;return T=e,i=ns(),i!==null?(u.charCodeAt(e)===58?(_=":",e++):(_=null,t('":"')),_!==null?(m=ml(),m===null&&(m=gl()),m!==null?i=[i,_,m]:(i=null,e=T)):(i=null,e=T)):(i=null,e=T),i}function ml(){var i,_,m,T,y;return T=e,i=Ns(),i===null&&(i=Zs()),i!==null?(y=e,u.charCodeAt(e)===63?(_="?",e++):(_=null,t('"?"')),_!==null?(m=On(),m!==null?_=[_,m]:(_=null,e=y)):(_=null,e=y),_=_!==null?_:"",_!==null?i=[i,_]:(i=null,e=T)):(i=null,e=T),i}function Ns(){var i,_,m,T;return T=e,u.substr(e,2)==="//"?(i="//",e+=2):(i=null,t('"//"')),i!==null?(_=wn(),_!==null?(m=Zs(),m=m!==null?m:"",m!==null?i=[i,_,m]:(i=null,e=T)):(i=null,e=T)):(i=null,e=T),i}function Zs(){var i,_,m;return m=e,u.charCodeAt(e)===47?(i="/",e++):(i=null,t('"/"')),i!==null?(_=vl(),_!==null?i=[i,_]:(i=null,e=m)):(i=null,e=m),i}function gl(){var i,_,m,T;if(T=e,i=xs(),i!==null){for(_=[],m=Us();m!==null;)_.push(m),m=Us();_!==null?i=[i,_]:(i=null,e=T)}else i=null,e=T;return i}function Us(){var i;return i=z(),i===null&&(i=j(),i===null&&(i=k())),i}function xs(){var i;return i=j(),i===null&&(i=k(),i===null&&(u.charCodeAt(e)===59?(i=";",e++):(i=null,t('";"')),i===null&&(u.charCodeAt(e)===63?(i="?",e++):(i=null,t('"?"')),i===null&&(u.charCodeAt(e)===58?(i=":",e++):(i=null,t('":"')),i===null&&(u.charCodeAt(e)===64?(i="@",e++):(i=null,t('"@"')),i===null&&(u.charCodeAt(e)===38?(i="&",e++):(i=null,t('"&"')),i===null&&(u.charCodeAt(e)===61?(i="=",e++):(i=null,t('"="')),i===null&&(u.charCodeAt(e)===43?(i="+",e++):(i=null,t('"+"')),i===null&&(u.charCodeAt(e)===36?(i="$",e++):(i=null,t('"$"')),i===null&&(u.charCodeAt(e)===44?(i=",",e++):(i=null,t('","')))))))))))),i}function vl(){var i,_,m,T,y,r;if(y=e,i=ss(),i!==null){for(_=[],r=e,u.charCodeAt(e)===47?(m="/",e++):(m=null,t('"/"')),m!==null?(T=ss(),T!==null?m=[m,T]:(m=null,e=r)):(m=null,e=r);m!==null;)_.push(m),r=e,u.charCodeAt(e)===47?(m="/",e++):(m=null,t('"/"')),m!==null?(T=ss(),T!==null?m=[m,T]:(m=null,e=r)):(m=null,e=r);_!==null?i=[i,_]:(i=null,e=y)}else i=null,e=y;return i}function ss(){var i,_,m,T,y,r;for(y=e,i=[],_=Ms();_!==null;)i.push(_),_=Ms();if(i!==null){for(_=[],r=e,u.charCodeAt(e)===59?(m=";",e++):(m=null,t('";"')),m!==null?(T=Ps(),T!==null?m=[m,T]:(m=null,e=r)):(m=null,e=r);m!==null;)_.push(m),r=e,u.charCodeAt(e)===59?(m=";",e++):(m=null,t('";"')),m!==null?(T=Ps(),T!==null?m=[m,T]:(m=null,e=r)):(m=null,e=r);_!==null?i=[i,_]:(i=null,e=y)}else i=null,e=y;return i}function Ps(){var i,_;for(i=[],_=Ms();_!==null;)i.push(_),_=Ms();return i}function Ms(){var i;return i=j(),i===null&&(i=k(),i===null&&(u.charCodeAt(e)===58?(i=":",e++):(i=null,t('":"')),i===null&&(u.charCodeAt(e)===64?(i="@",e++):(i=null,t('"@"')),i===null&&(u.charCodeAt(e)===38?(i="&",e++):(i=null,t('"&"')),i===null&&(u.charCodeAt(e)===61?(i="=",e++):(i=null,t('"="')),i===null&&(u.charCodeAt(e)===43?(i="+",e++):(i=null,t('"+"')),i===null&&(u.charCodeAt(e)===36?(i="$",e++):(i=null,t('"$"')),i===null&&(u.charCodeAt(e)===44?(i=",",e++):(i=null,t('","')))))))))),i}function ns(){var i,_,m,T,y;if(T=e,y=e,i=l(),i!==null){for(_=[],m=l(),m===null&&(m=C(),m===null&&(u.charCodeAt(e)===43?(m="+",e++):(m=null,t('"+"')),m===null&&(u.charCodeAt(e)===45?(m="-",e++):(m=null,t('"-"')),m===null&&(u.charCodeAt(e)===46?(m=".",e++):(m=null,t('"."'))))));m!==null;)_.push(m),m=l(),m===null&&(m=C(),m===null&&(u.charCodeAt(e)===43?(m="+",e++):(m=null,t('"+"')),m===null&&(u.charCodeAt(e)===45?(m="-",e++):(m=null,t('"-"')),m===null&&(u.charCodeAt(e)===46?(m=".",e++):(m=null,t('"."'))))));_!==null?i=[i,_]:(i=null,e=y)}else i=null,e=y;return i!==null&&(i=function(r){x.scheme=u.substring(e,r)}(T)),i===null&&(e=T),i}function wn(){var i;return i=ks(),i===null&&(i=en()),i}function ks(){var i,_,m,T;return m=e,T=e,i=We(),i!==null?(u.charCodeAt(e)===64?(_="@",e++):(_=null,t('"@"')),_!==null?i=[i,_]:(i=null,e=T)):(i=null,e=T),i=i!==null?i:"",i!==null?(_=Xs(),_!==null?i=[i,_]:(i=null,e=m)):(i=null,e=m),i=i!==null?i:"",i}function en(){var i,_;if(_=j(),_===null&&(_=k(),_===null&&(u.charCodeAt(e)===36?(_="$",e++):(_=null,t('"$"')),_===null&&(u.charCodeAt(e)===44?(_=",",e++):(_=null,t('","')),_===null&&(u.charCodeAt(e)===59?(_=";",e++):(_=null,t('";"')),_===null&&(u.charCodeAt(e)===58?(_=":",e++):(_=null,t('":"')),_===null&&(u.charCodeAt(e)===64?(_="@",e++):(_=null,t('"@"')),_===null&&(u.charCodeAt(e)===38?(_="&",e++):(_=null,t('"&"')),_===null&&(u.charCodeAt(e)===61?(_="=",e++):(_=null,t('"="')),_===null&&(u.charCodeAt(e)===43?(_="+",e++):(_=null,t('"+"'))))))))))),_!==null)for(i=[];_!==null;)i.push(_),_=j(),_===null&&(_=k(),_===null&&(u.charCodeAt(e)===36?(_="$",e++):(_=null,t('"$"')),_===null&&(u.charCodeAt(e)===44?(_=",",e++):(_=null,t('","')),_===null&&(u.charCodeAt(e)===59?(_=";",e++):(_=null,t('";"')),_===null&&(u.charCodeAt(e)===58?(_=":",e++):(_=null,t('":"')),_===null&&(u.charCodeAt(e)===64?(_="@",e++):(_=null,t('"@"')),_===null&&(u.charCodeAt(e)===38?(_="&",e++):(_=null,t('"&"')),_===null&&(u.charCodeAt(e)===61?(_="=",e++):(_=null,t('"="')),_===null&&(u.charCodeAt(e)===43?(_="+",e++):(_=null,t('"+"')))))))))));else i=null;return i}function On(){var i,_;for(i=[],_=Us();_!==null;)i.push(_),_=Us();return i}function ps(){var i,_,m,T,y,r,f,d;if(f=e,d=e,u.substr(e,3).toLowerCase()==="sip"?(i=u.substr(e,3),e+=3):(i=null,t('"SIP"')),i!==null)if(u.charCodeAt(e)===47?(_="/",e++):(_=null,t('"/"')),_!==null){if(T=C(),T!==null)for(m=[];T!==null;)m.push(T),T=C();else m=null;if(m!==null)if(u.charCodeAt(e)===46?(T=".",e++):(T=null,t('"."')),T!==null){if(r=C(),r!==null)for(y=[];r!==null;)y.push(r),r=C();else y=null;y!==null?i=[i,_,m,T,y]:(i=null,e=d)}else i=null,e=d;else i=null,e=d}else i=null,e=d;else i=null,e=d;return i!==null&&(i=function(s){x.sip_version=u.substring(e,s)}(f)),i===null&&(e=f),i}function Tl(){var i;return u.substr(e,6)==="INVITE"?(i="INVITE",e+=6):(i=null,t('"INVITE"')),i}function El(){var i;return u.substr(e,3)==="ACK"?(i="ACK",e+=3):(i=null,t('"ACK"')),i}function Dn(){var i;return u.substr(e,7)==="OPTIONS"?(i="OPTIONS",e+=7):(i=null,t('"OPTIONS"')),i}function Cl(){var i;return u.substr(e,3)==="BYE"?(i="BYE",e+=3):(i=null,t('"BYE"')),i}function Sl(){var i;return u.substr(e,6)==="CANCEL"?(i="CANCEL",e+=6):(i=null,t('"CANCEL"')),i}function Nn(){var i;return u.substr(e,8)==="REGISTER"?(i="REGISTER",e+=8):(i=null,t('"REGISTER"')),i}function Al(){var i;return u.substr(e,9)==="SUBSCRIBE"?(i="SUBSCRIBE",e+=9):(i=null,t('"SUBSCRIBE"')),i}function yl(){var i;return u.substr(e,6)==="NOTIFY"?(i="NOTIFY",e+=6):(i=null,t('"NOTIFY"')),i}function Rl(){var i;return u.substr(e,5)==="REFER"?(i="REFER",e+=5):(i=null,t('"REFER"')),i}function tn(){var i,_;return _=e,i=Tl(),i===null&&(i=El(),i===null&&(i=Dn(),i===null&&(i=Cl(),i===null&&(i=Sl(),i===null&&(i=Nn(),i===null&&(i=Al(),i===null&&(i=yl(),i===null&&(i=Rl(),i===null&&(i=M()))))))))),i!==null&&(i=function(m){return x.method=u.substring(e,m),x.method}(_)),i===null&&(e=_),i}function bl(){var i,_,m,T,y,r;return r=e,i=ps(),i!==null?(_=w(),_!==null?(m=Il(),m!==null?(T=w(),T!==null?(y=wl(),y!==null?i=[i,_,m,T,y]:(i=null,e=r)):(i=null,e=r)):(i=null,e=r)):(i=null,e=r)):(i=null,e=r),i}function Il(){var i,_;return _=e,i=sn(),i!==null&&(i=function(m,T){x.status_code=parseInt(T.join(""))}(_,i)),i===null&&(e=_),i}function sn(){var i,_,m,T;return T=e,i=C(),i!==null?(_=C(),_!==null?(m=C(),m!==null?i=[i,_,m]:(i=null,e=T)):(i=null,e=T)):(i=null,e=T),i}function wl(){var i,_,m;for(m=e,i=[],_=z(),_===null&&(_=j(),_===null&&(_=k(),_===null&&(_=V(),_===null&&(_=G(),_===null&&(_=w(),_===null&&(_=N()))))));_!==null;)i.push(_),_=z(),_===null&&(_=j(),_===null&&(_=k(),_===null&&(_=V(),_===null&&(_=G(),_===null&&(_=w(),_===null&&(_=N()))))));return i!==null&&(i=function(T){x.reason_phrase=u.substring(e,T)}(m)),i===null&&(e=m),i}function pr(){var i,_,m,T,y,r;if(y=e,i=vs(),i!==null){for(_=[],r=e,m=be(),m!==null?(T=vs(),T!==null?m=[m,T]:(m=null,e=r)):(m=null,e=r);m!==null;)_.push(m),r=e,m=be(),m!==null?(T=vs(),T!==null?m=[m,T]:(m=null,e=r)):(m=null,e=r);_!==null?i=[i,_]:(i=null,e=y)}else i=null,e=y;return i}function Un(){var i,_,m,T,y,r;return T=e,y=e,i=$(),i!==null?(r=e,u.charCodeAt(e)===64?(_="@",e++):(_=null,t('"@"')),_!==null?(m=$(),m!==null?_=[_,m]:(_=null,e=r)):(_=null,e=r),_=_!==null?_:"",_!==null?i=[i,_]:(i=null,e=y)):(i=null,e=y),i!==null&&(i=function(f){x=u.substring(e,f)}(T)),i===null&&(e=T),i}function mr(){var i,_,m,T,y,r,f;if(y=e,i=ne(),i===null)if(r=e,i=xn(),i!==null){for(_=[],f=e,m=be(),m!==null?(T=xn(),T!==null?m=[m,T]:(m=null,e=f)):(m=null,e=f);m!==null;)_.push(m),f=e,m=be(),m!==null?(T=xn(),T!==null?m=[m,T]:(m=null,e=f)):(m=null,e=f);_!==null?i=[i,_]:(i=null,e=r)}else i=null,e=r;return i!==null&&(i=function(d){var s,c;for(c=x.multi_header.length,s=0;s<c;s++)if(x.multi_header[s].parsed===null){x=null;break}x!==null?x=x.multi_header:x=-1}()),i===null&&(e=y),i}function xn(){var i,_,m,T,y,r,f;if(y=e,r=e,i=ye(),i===null&&(i=ms()),i!==null){for(_=[],f=e,m=fe(),m!==null?(T=nn(),T!==null?m=[m,T]:(m=null,e=f)):(m=null,e=f);m!==null;)_.push(m),f=e,m=fe(),m!==null?(T=nn(),T!==null?m=[m,T]:(m=null,e=f)):(m=null,e=f);_!==null?i=[i,_]:(i=null,e=r)}else i=null,e=r;return i!==null&&(i=function(d){var s;x.multi_header||(x.multi_header=[]);try{s=new Qr(x.uri,x.display_name,x.params),delete x.uri,delete x.display_name,delete x.params}catch{s=null}x.multi_header.push({possition:e,offset:d,parsed:s})}(y)),i===null&&(e=y),i}function ms(){var i,_,m,T,y;return y=e,i=Pn(),i=i!==null?i:"",i!==null?(_=Re(),_!==null?(m=pe(),m!==null?(T=he(),T!==null?i=[i,_,m,T]:(i=null,e=y)):(i=null,e=y)):(i=null,e=y)):(i=null,e=y),i}function Pn(){var i,_,m,T,y,r,f;if(y=e,r=e,i=M(),i!==null){for(_=[],f=e,m=H(),m!==null?(T=M(),T!==null?m=[m,T]:(m=null,e=f)):(m=null,e=f);m!==null;)_.push(m),f=e,m=H(),m!==null?(T=M(),T!==null?m=[m,T]:(m=null,e=f)):(m=null,e=f);_!==null?i=[i,_]:(i=null,e=r)}else i=null,e=r;return i===null&&(i=Oe()),i!==null&&(i=function(d,s){typeof s=="string"?x.display_name=s:x.display_name=s[1].reduce(function(c,h){return c+h[0]+h[1]},s[0])}(y,i)),i===null&&(e=y),i}function nn(){var i;return i=gs(),i===null&&(i=Mn(),i===null&&(i=ze())),i}function gs(){var i,_,m,T,y;return T=e,y=e,u.substr(e,1).toLowerCase()==="q"?(i=u.substr(e,1),e++):(i=null,t('"q"')),i!==null?(_=P(),_!==null?(m=ls(),m!==null?i=[i,_,m]:(i=null,e=y)):(i=null,e=y)):(i=null,e=y),i!==null&&(i=function(r,f){x.params||(x.params={}),x.params.q=f}(T,i[2])),i===null&&(e=T),i}function Mn(){var i,_,m,T,y;return T=e,y=e,u.substr(e,7).toLowerCase()==="expires"?(i=u.substr(e,7),e+=7):(i=null,t('"expires"')),i!==null?(_=P(),_!==null?(m=qt(),m!==null?i=[i,_,m]:(i=null,e=y)):(i=null,e=y)):(i=null,e=y),i!==null&&(i=function(r,f){x.params||(x.params={}),x.params.expires=f}(T,i[2])),i===null&&(e=T),i}function qt(){var i,_,m;if(m=e,_=C(),_!==null)for(i=[];_!==null;)i.push(_),_=C();else i=null;return i!==null&&(i=function(T,y){return parseInt(y.join(""))}(m,i)),i===null&&(e=m),i}function ls(){var i,_,m,T,y,r,f,d;return r=e,f=e,u.charCodeAt(e)===48?(i="0",e++):(i=null,t('"0"')),i!==null?(d=e,u.charCodeAt(e)===46?(_=".",e++):(_=null,t('"."')),_!==null?(m=C(),m=m!==null?m:"",m!==null?(T=C(),T=T!==null?T:"",T!==null?(y=C(),y=y!==null?y:"",y!==null?_=[_,m,T,y]:(_=null,e=d)):(_=null,e=d)):(_=null,e=d)):(_=null,e=d),_=_!==null?_:"",_!==null?i=[i,_]:(i=null,e=f)):(i=null,e=f),i!==null&&(i=function(s){return parseFloat(u.substring(e,s))}(r)),i===null&&(e=r),i}function ze(){var i,_,m,T,y,r;return T=e,y=e,i=M(),i!==null?(r=e,_=P(),_!==null?(m=Yt(),m!==null?_=[_,m]:(_=null,e=r)):(_=null,e=r),_=_!==null?_:"",_!==null?i=[i,_]:(i=null,e=y)):(i=null,e=y),i!==null&&(i=function(f,d,s){x.params||(x.params={}),typeof s>"u"?s=void 0:s=s[1],x.params[d.toLowerCase()]=s}(T,i[0],i[1])),i===null&&(e=T),i}function Yt(){var i;return i=M(),i===null&&(i=cs(),i===null&&(i=ue())),i}function gr(){var i,_,m,T,y,r;if(y=e,i=Ze(),i!==null){for(_=[],r=e,m=fe(),m!==null?(T=zt(),T!==null?m=[m,T]:(m=null,e=r)):(m=null,e=r);m!==null;)_.push(m),r=e,m=fe(),m!==null?(T=zt(),T!==null?m=[m,T]:(m=null,e=r)):(m=null,e=r);_!==null?i=[i,_]:(i=null,e=y)}else i=null,e=y;return i}function Ze(){var i;return u.substr(e,6).toLowerCase()==="render"?(i=u.substr(e,6),e+=6):(i=null,t('"render"')),i===null&&(u.substr(e,7).toLowerCase()==="session"?(i=u.substr(e,7),e+=7):(i=null,t('"session"')),i===null&&(u.substr(e,4).toLowerCase()==="icon"?(i=u.substr(e,4),e+=4):(i=null,t('"icon"')),i===null&&(u.substr(e,5).toLowerCase()==="alert"?(i=u.substr(e,5),e+=5):(i=null,t('"alert"')),i===null&&(i=M())))),i}function zt(){var i;return i=vr(),i===null&&(i=ze()),i}function vr(){var i,_,m,T;return T=e,u.substr(e,8).toLowerCase()==="handling"?(i=u.substr(e,8),e+=8):(i=null,t('"handling"')),i!==null?(_=P(),_!==null?(u.substr(e,8).toLowerCase()==="optional"?(m=u.substr(e,8),e+=8):(m=null,t('"optional"')),m===null&&(u.substr(e,8).toLowerCase()==="required"?(m=u.substr(e,8),e+=8):(m=null,t('"required"')),m===null&&(m=M())),m!==null?i=[i,_,m]:(i=null,e=T)):(i=null,e=T)):(i=null,e=T),i}function st(){var i,_,m,T,y,r;if(y=e,i=M(),i!==null){for(_=[],r=e,m=be(),m!==null?(T=M(),T!==null?m=[m,T]:(m=null,e=r)):(m=null,e=r);m!==null;)_.push(m),r=e,m=be(),m!==null?(T=M(),T!==null?m=[m,T]:(m=null,e=r)):(m=null,e=r);_!==null?i=[i,_]:(i=null,e=y)}else i=null,e=y;return i}function Ol(){var i,_,m;if(m=e,_=C(),_!==null)for(i=[];_!==null;)i.push(_),_=C();else i=null;return i!==null&&(i=function(T,y){x=parseInt(y.join(""))}(m,i)),i===null&&(e=m),i}function ei(){var i,_;return _=e,i=Tr(),i!==null&&(i=function(m){x=u.substring(e,m)}(_)),i===null&&(e=_),i}function Tr(){var i,_,m,T,y,r,f,d;if(f=e,i=Dl(),i!==null)if(_=ht(),_!==null)if(m=Nl(),m!==null){for(T=[],d=e,y=fe(),y!==null?(r=Ls(),r!==null?y=[y,r]:(y=null,e=d)):(y=null,e=d);y!==null;)T.push(y),d=e,y=fe(),y!==null?(r=Ls(),r!==null?y=[y,r]:(y=null,e=d)):(y=null,e=d);T!==null?i=[i,_,m,T]:(i=null,e=f)}else i=null,e=f;else i=null,e=f;else i=null,e=f;return i}function Dl(){var i;return i=Er(),i===null&&(i=Cr()),i}function Er(){var i;return u.substr(e,4).toLowerCase()==="text"?(i=u.substr(e,4),e+=4):(i=null,t('"text"')),i===null&&(u.substr(e,5).toLowerCase()==="image"?(i=u.substr(e,5),e+=5):(i=null,t('"image"')),i===null&&(u.substr(e,5).toLowerCase()==="audio"?(i=u.substr(e,5),e+=5):(i=null,t('"audio"')),i===null&&(u.substr(e,5).toLowerCase()==="video"?(i=u.substr(e,5),e+=5):(i=null,t('"video"')),i===null&&(u.substr(e,11).toLowerCase()==="application"?(i=u.substr(e,11),e+=11):(i=null,t('"application"')),i===null&&(i=kn()))))),i}function Cr(){var i;return u.substr(e,7).toLowerCase()==="message"?(i=u.substr(e,7),e+=7):(i=null,t('"message"')),i===null&&(u.substr(e,9).toLowerCase()==="multipart"?(i=u.substr(e,9),e+=9):(i=null,t('"multipart"')),i===null&&(i=kn())),i}function kn(){var i;return i=M(),i===null&&(i=Sr()),i}function Sr(){var i,_,m;return m=e,u.substr(e,2).toLowerCase()==="x-"?(i=u.substr(e,2),e+=2):(i=null,t('"x-"')),i!==null?(_=M(),_!==null?i=[i,_]:(i=null,e=m)):(i=null,e=m),i}function Nl(){var i;return i=kn(),i===null&&(i=M()),i}function Ls(){var i,_,m,T;return T=e,i=M(),i!==null?(_=P(),_!==null?(m=Ul(),m!==null?i=[i,_,m]:(i=null,e=T)):(i=null,e=T)):(i=null,e=T),i}function Ul(){var i;return i=M(),i===null&&(i=ue()),i}function Ar(){var i,_,m,T;return T=e,i=$s(),i!==null?(_=H(),_!==null?(m=tn(),m!==null?i=[i,_,m]:(i=null,e=T)):(i=null,e=T)):(i=null,e=T),i}function $s(){var i,_,m;if(m=e,_=C(),_!==null)for(i=[];_!==null;)i.push(_),_=C();else i=null;return i!==null&&(i=function(T,y){x.value=parseInt(y.join(""))}(m,i)),i===null&&(e=m),i}function yr(){var i,_;return _=e,i=qt(),i!==null&&(i=function(m,T){x=T}(_,i)),i===null&&(e=_),i}function ti(){var i,_,m,T,y,r,f;if(y=e,r=e,i=vs(),i!==null){for(_=[],f=e,m=fe(),m!==null?(T=ze(),T!==null?m=[m,T]:(m=null,e=f)):(m=null,e=f);m!==null;)_.push(m),f=e,m=fe(),m!==null?(T=ze(),T!==null?m=[m,T]:(m=null,e=f)):(m=null,e=f);_!==null?i=[i,_]:(i=null,e=r)}else i=null,e=r;return i!==null&&(i=function(d,s){x.event=s.join("").toLowerCase()}(y,i[0])),i===null&&(e=y),i}function vs(){var i,_,m,T,y,r;if(y=e,i=te(),i!==null){for(_=[],r=e,u.charCodeAt(e)===46?(m=".",e++):(m=null,t('"."')),m!==null?(T=te(),T!==null?m=[m,T]:(m=null,e=r)):(m=null,e=r);m!==null;)_.push(m),r=e,u.charCodeAt(e)===46?(m=".",e++):(m=null,t('"."')),m!==null?(T=te(),T!==null?m=[m,T]:(m=null,e=r)):(m=null,e=r);_!==null?i=[i,_]:(i=null,e=y)}else i=null,e=y;return i}function si(){var i,_,m,T,y,r,f;if(y=e,r=e,i=ye(),i===null&&(i=ms()),i!==null){for(_=[],f=e,m=fe(),m!==null?(T=Rr(),T!==null?m=[m,T]:(m=null,e=f)):(m=null,e=f);m!==null;)_.push(m),f=e,m=fe(),m!==null?(T=Rr(),T!==null?m=[m,T]:(m=null,e=f)):(m=null,e=f);_!==null?i=[i,_]:(i=null,e=r)}else i=null,e=r;return i!==null&&(i=function(d){var s=x.tag;try{x=new Qr(x.uri,x.display_name,x.params),s&&x.setParam("tag",s)}catch{x=-1}}()),i===null&&(e=y),i}function Rr(){var i;return i=Ts(),i===null&&(i=ze()),i}function Ts(){var i,_,m,T,y;return T=e,y=e,u.substr(e,3).toLowerCase()==="tag"?(i=u.substr(e,3),e+=3):(i=null,t('"tag"')),i!==null?(_=P(),_!==null?(m=M(),m!==null?i=[i,_,m]:(i=null,e=y)):(i=null,e=y)):(i=null,e=y),i!==null&&(i=function(r,f){x.tag=f}(T,i[2])),i===null&&(e=T),i}function ea(){var i,_,m;if(m=e,_=C(),_!==null)for(i=[];_!==null;)i.push(_),_=C();else i=null;return i!==null&&(i=function(T,y){x=parseInt(y.join(""))}(m,i)),i===null&&(e=m),i}function br(){var i,_;return _=e,i=qt(),i!==null&&(i=function(m,T){x=T}(_,i)),i===null&&(e=_),i}function Hs(){var i,_,m,T,y,r,f,d,s,c;for(d=e,s=e,i=[],_=Pn();_!==null;)i.push(_),_=Pn();if(i!==null)if(_=Re(),_!==null)if(m=pe(),m!==null)if(T=he(),T!==null){for(y=[],c=e,r=fe(),r!==null?(f=ze(),f!==null?r=[r,f]:(r=null,e=c)):(r=null,e=c);r!==null;)y.push(r),c=e,r=fe(),r!==null?(f=ze(),f!==null?r=[r,f]:(r=null,e=c)):(r=null,e=c);y!==null?i=[i,_,m,T,y]:(i=null,e=s)}else i=null,e=s;else i=null,e=s;else i=null,e=s;else i=null,e=s;return i!==null&&(i=function(h){try{x=new Qr(x.uri,x.display_name,x.params)}catch{x=-1}}()),i===null&&(e=d),i}function ta(){var i;return i=Ln(),i}function Ln(){var i,_,m,T,y,r,f,d;if(f=e,u.substr(e,6).toLowerCase()==="digest"?(i=u.substr(e,6),e+=6):(i=null,t('"Digest"')),i!==null)if(_=H(),_!==null)if(m=ln(),m!==null){for(T=[],d=e,y=be(),y!==null?(r=ln(),r!==null?y=[y,r]:(y=null,e=d)):(y=null,e=d);y!==null;)T.push(y),d=e,y=be(),y!==null?(r=ln(),r!==null?y=[y,r]:(y=null,e=d)):(y=null,e=d);T!==null?i=[i,_,m,T]:(i=null,e=f)}else i=null,e=f;else i=null,e=f;else i=null,e=f;return i===null&&(i=xl()),i}function xl(){var i,_,m,T,y,r,f,d;if(f=e,i=M(),i!==null)if(_=H(),_!==null)if(m=$n(),m!==null){for(T=[],d=e,y=be(),y!==null?(r=$n(),r!==null?y=[y,r]:(y=null,e=d)):(y=null,e=d);y!==null;)T.push(y),d=e,y=be(),y!==null?(r=$n(),r!==null?y=[y,r]:(y=null,e=d)):(y=null,e=d);T!==null?i=[i,_,m,T]:(i=null,e=f)}else i=null,e=f;else i=null,e=f;else i=null,e=f;return i}function $n(){var i,_,m,T;return T=e,i=M(),i!==null?(_=P(),_!==null?(m=M(),m===null&&(m=ue()),m!==null?i=[i,_,m]:(i=null,e=T)):(i=null,e=T)):(i=null,e=T),i}function ln(){var i;return i=Ir(),i===null&&(i=Fs(),i===null&&(i=qs(),i===null&&(i=un(),i===null&&(i=Pl(),i===null&&(i=Ml(),i===null&&(i=cn(),i===null&&(i=$n()))))))),i}function Ir(){var i,_,m,T;return T=e,u.substr(e,5).toLowerCase()==="realm"?(i=u.substr(e,5),e+=5):(i=null,t('"realm"')),i!==null?(_=P(),_!==null?(m=rn(),m!==null?i=[i,_,m]:(i=null,e=T)):(i=null,e=T)):(i=null,e=T),i}function rn(){var i,_;return _=e,i=Oe(),i!==null&&(i=function(m,T){x.realm=T}(_,i)),i===null&&(e=_),i}function Fs(){var i,_,m,T,y,r,f,d,s;if(d=e,u.substr(e,6).toLowerCase()==="domain"?(i=u.substr(e,6),e+=6):(i=null,t('"domain"')),i!==null)if(_=P(),_!==null)if(m=xe(),m!==null)if(T=an(),T!==null){if(y=[],s=e,f=w(),f!==null)for(r=[];f!==null;)r.push(f),f=w();else r=null;for(r!==null?(f=an(),f!==null?r=[r,f]:(r=null,e=s)):(r=null,e=s);r!==null;){if(y.push(r),s=e,f=w(),f!==null)for(r=[];f!==null;)r.push(f),f=w();else r=null;r!==null?(f=an(),f!==null?r=[r,f]:(r=null,e=s)):(r=null,e=s)}y!==null?(r=we(),r!==null?i=[i,_,m,T,y,r]:(i=null,e=d)):(i=null,e=d)}else i=null,e=d;else i=null,e=d;else i=null,e=d;else i=null,e=d;return i}function an(){var i;return i=pl(),i===null&&(i=Zs()),i}function qs(){var i,_,m,T;return T=e,u.substr(e,5).toLowerCase()==="nonce"?(i=u.substr(e,5),e+=5):(i=null,t('"nonce"')),i!==null?(_=P(),_!==null?(m=on(),m!==null?i=[i,_,m]:(i=null,e=T)):(i=null,e=T)):(i=null,e=T),i}function on(){var i,_;return _=e,i=Oe(),i!==null&&(i=function(m,T){x.nonce=T}(_,i)),i===null&&(e=_),i}function un(){var i,_,m,T,y;return T=e,y=e,u.substr(e,6).toLowerCase()==="opaque"?(i=u.substr(e,6),e+=6):(i=null,t('"opaque"')),i!==null?(_=P(),_!==null?(m=Oe(),m!==null?i=[i,_,m]:(i=null,e=y)):(i=null,e=y)):(i=null,e=y),i!==null&&(i=function(r,f){x.opaque=f}(T,i[2])),i===null&&(e=T),i}function Pl(){var i,_,m,T,y;return T=e,u.substr(e,5).toLowerCase()==="stale"?(i=u.substr(e,5),e+=5):(i=null,t('"stale"')),i!==null?(_=P(),_!==null?(y=e,u.substr(e,4).toLowerCase()==="true"?(m=u.substr(e,4),e+=4):(m=null,t('"true"')),m!==null&&(m=function(r){x.stale=!0}()),m===null&&(e=y),m===null&&(y=e,u.substr(e,5).toLowerCase()==="false"?(m=u.substr(e,5),e+=5):(m=null,t('"false"')),m!==null&&(m=function(r){x.stale=!1}()),m===null&&(e=y)),m!==null?i=[i,_,m]:(i=null,e=T)):(i=null,e=T)):(i=null,e=T),i}function Ml(){var i,_,m,T,y;return T=e,y=e,u.substr(e,9).toLowerCase()==="algorithm"?(i=u.substr(e,9),e+=9):(i=null,t('"algorithm"')),i!==null?(_=P(),_!==null?(u.substr(e,3).toLowerCase()==="md5"?(m=u.substr(e,3),e+=3):(m=null,t('"MD5"')),m===null&&(u.substr(e,8).toLowerCase()==="md5-sess"?(m=u.substr(e,8),e+=8):(m=null,t('"MD5-sess"')),m===null&&(m=M())),m!==null?i=[i,_,m]:(i=null,e=y)):(i=null,e=y)):(i=null,e=y),i!==null&&(i=function(r,f){x.algorithm=f.toUpperCase()}(T,i[2])),i===null&&(e=T),i}function cn(){var i,_,m,T,y,r,f,d,s,c;if(d=e,u.substr(e,3).toLowerCase()==="qop"?(i=u.substr(e,3),e+=3):(i=null,t('"qop"')),i!==null)if(_=P(),_!==null)if(m=xe(),m!==null){if(s=e,T=fn(),T!==null){for(y=[],c=e,u.charCodeAt(e)===44?(r=",",e++):(r=null,t('","')),r!==null?(f=fn(),f!==null?r=[r,f]:(r=null,e=c)):(r=null,e=c);r!==null;)y.push(r),c=e,u.charCodeAt(e)===44?(r=",",e++):(r=null,t('","')),r!==null?(f=fn(),f!==null?r=[r,f]:(r=null,e=c)):(r=null,e=c);y!==null?T=[T,y]:(T=null,e=s)}else T=null,e=s;T!==null?(y=we(),y!==null?i=[i,_,m,T,y]:(i=null,e=d)):(i=null,e=d)}else i=null,e=d;else i=null,e=d;else i=null,e=d;return i}function fn(){var i,_;return _=e,u.substr(e,8).toLowerCase()==="auth-int"?(i=u.substr(e,8),e+=8):(i=null,t('"auth-int"')),i===null&&(u.substr(e,4).toLowerCase()==="auth"?(i=u.substr(e,4),e+=4):(i=null,t('"auth"')),i===null&&(i=M())),i!==null&&(i=function(m,T){x.qop||(x.qop=[]),x.qop.push(T.toLowerCase())}(_,i)),i===null&&(e=_),i}function wr(){var i,_,m,T,y,r;if(y=e,i=M(),i!==null){for(_=[],r=e,m=be(),m!==null?(T=M(),T!==null?m=[m,T]:(m=null,e=r)):(m=null,e=r);m!==null;)_.push(m),r=e,m=be(),m!==null?(T=M(),T!==null?m=[m,T]:(m=null,e=r)):(m=null,e=r);_!==null?i=[i,_]:(i=null,e=y)}else i=null,e=y;return i}function Or(){var i,_,m,T,y,r,f;if(y=e,r=e,i=Es(),i!==null){for(_=[],f=e,m=be(),m!==null?(T=Es(),T!==null?m=[m,T]:(m=null,e=f)):(m=null,e=f);m!==null;)_.push(m),f=e,m=be(),m!==null?(T=Es(),T!==null?m=[m,T]:(m=null,e=f)):(m=null,e=f);_!==null?i=[i,_]:(i=null,e=r)}else i=null,e=r;return i!==null&&(i=function(d){var s,c;for(c=x.multi_header.length,s=0;s<c;s++)if(x.multi_header[s].parsed===null){x=null;break}x!==null?x=x.multi_header:x=-1}()),i===null&&(e=y),i}function Es(){var i,_,m,T,y,r,f;if(y=e,r=e,i=ms(),i!==null){for(_=[],f=e,m=fe(),m!==null?(T=ze(),T!==null?m=[m,T]:(m=null,e=f)):(m=null,e=f);m!==null;)_.push(m),f=e,m=fe(),m!==null?(T=ze(),T!==null?m=[m,T]:(m=null,e=f)):(m=null,e=f);_!==null?i=[i,_]:(i=null,e=r)}else i=null,e=r;return i!==null&&(i=function(d){var s;x.multi_header||(x.multi_header=[]);try{s=new Qr(x.uri,x.display_name,x.params),delete x.uri,delete x.display_name,delete x.params}catch{s=null}x.multi_header.push({possition:e,offset:d,parsed:s})}(y)),i===null&&(e=y),i}function ni(){var i,_,m,T,y,r,f;if(y=e,r=e,u.substr(e,3).toLowerCase()==="sip"?(i=u.substr(e,3),e+=3):(i=null,t('"SIP"')),i===null&&(i=M()),i!==null){for(_=[],f=e,m=fe(),m!==null?(T=kl(),T!==null?m=[m,T]:(m=null,e=f)):(m=null,e=f);m!==null;)_.push(m),f=e,m=fe(),m!==null?(T=kl(),T!==null?m=[m,T]:(m=null,e=f)):(m=null,e=f);_!==null?i=[i,_]:(i=null,e=r)}else i=null,e=r;return i!==null&&(i=function(d,s){if(x.protocol=s.toLowerCase(),x.params||(x.params={}),x.params.text&&x.params.text[0]==='"'){var c=x.params.text;x.text=c.substring(1,c.length-1),delete x.params.text}}(y,i[0])),i===null&&(e=y),i}function kl(){var i;return i=Cs(),i===null&&(i=ze()),i}function Cs(){var i,_,m,T,y,r;if(y=e,r=e,u.substr(e,5).toLowerCase()==="cause"?(i=u.substr(e,5),e+=5):(i=null,t('"cause"')),i!==null)if(_=P(),_!==null){if(T=C(),T!==null)for(m=[];T!==null;)m.push(T),T=C();else m=null;m!==null?i=[i,_,m]:(i=null,e=r)}else i=null,e=r;else i=null,e=r;return i!==null&&(i=function(f,d){x.cause=parseInt(d.join(""))}(y,i[2])),i===null&&(e=y),i}function sa(){var i,_,m,T,y,r;if(y=e,i=M(),i!==null){for(_=[],r=e,m=be(),m!==null?(T=M(),T!==null?m=[m,T]:(m=null,e=r)):(m=null,e=r);m!==null;)_.push(m),r=e,m=be(),m!==null?(T=M(),T!==null?m=[m,T]:(m=null,e=r)):(m=null,e=r);_!==null?i=[i,_]:(i=null,e=y)}else i=null,e=y;return i}function Dr(){var i,_,m,T,y,r;if(y=e,i=Ss(),i!==null){for(_=[],r=e,m=be(),m!==null?(T=Ss(),T!==null?m=[m,T]:(m=null,e=r)):(m=null,e=r);m!==null;)_.push(m),r=e,m=be(),m!==null?(T=Ss(),T!==null?m=[m,T]:(m=null,e=r)):(m=null,e=r);_!==null?i=[i,_]:(i=null,e=y)}else i=null,e=y;return i}function Ss(){var i,_,m,T,y,r;if(y=e,i=ms(),i!==null){for(_=[],r=e,m=fe(),m!==null?(T=ze(),T!==null?m=[m,T]:(m=null,e=r)):(m=null,e=r);m!==null;)_.push(m),r=e,m=fe(),m!==null?(T=ze(),T!==null?m=[m,T]:(m=null,e=r)):(m=null,e=r);_!==null?i=[i,_]:(i=null,e=y)}else i=null,e=y;return i}function na(){var i,_,m,T,y,r;if(y=e,i=Ll(),i!==null){for(_=[],r=e,m=fe(),m!==null?(T=js(),T!==null?m=[m,T]:(m=null,e=r)):(m=null,e=r);m!==null;)_.push(m),r=e,m=fe(),m!==null?(T=js(),T!==null?m=[m,T]:(m=null,e=r)):(m=null,e=r);_!==null?i=[i,_]:(i=null,e=y)}else i=null,e=y;return i}function Ll(){var i,_;return _=e,u.substr(e,6).toLowerCase()==="active"?(i=u.substr(e,6),e+=6):(i=null,t('"active"')),i===null&&(u.substr(e,7).toLowerCase()==="pending"?(i=u.substr(e,7),e+=7):(i=null,t('"pending"')),i===null&&(u.substr(e,10).toLowerCase()==="terminated"?(i=u.substr(e,10),e+=10):(i=null,t('"terminated"')),i===null&&(i=M()))),i!==null&&(i=function(m){x.state=u.substring(e,m)}(_)),i===null&&(e=_),i}function js(){var i,_,m,T,y;return T=e,y=e,u.substr(e,6).toLowerCase()==="reason"?(i=u.substr(e,6),e+=6):(i=null,t('"reason"')),i!==null?(_=P(),_!==null?(m=li(),m!==null?i=[i,_,m]:(i=null,e=y)):(i=null,e=y)):(i=null,e=y),i!==null&&(i=function(r,f){typeof f<"u"&&(x.reason=f)}(T,i[2])),i===null&&(e=T),i===null&&(T=e,y=e,u.substr(e,7).toLowerCase()==="expires"?(i=u.substr(e,7),e+=7):(i=null,t('"expires"')),i!==null?(_=P(),_!==null?(m=qt(),m!==null?i=[i,_,m]:(i=null,e=y)):(i=null,e=y)):(i=null,e=y),i!==null&&(i=function(r,f){typeof f<"u"&&(x.expires=f)}(T,i[2])),i===null&&(e=T),i===null&&(T=e,y=e,u.substr(e,11).toLowerCase()==="retry_after"?(i=u.substr(e,11),e+=11):(i=null,t('"retry_after"')),i!==null?(_=P(),_!==null?(m=qt(),m!==null?i=[i,_,m]:(i=null,e=y)):(i=null,e=y)):(i=null,e=y),i!==null&&(i=function(r,f){typeof f<"u"&&(x.retry_after=f)}(T,i[2])),i===null&&(e=T),i===null&&(i=ze()))),i}function li(){var i;return u.substr(e,11).toLowerCase()==="deactivated"?(i=u.substr(e,11),e+=11):(i=null,t('"deactivated"')),i===null&&(u.substr(e,9).toLowerCase()==="probation"?(i=u.substr(e,9),e+=9):(i=null,t('"probation"')),i===null&&(u.substr(e,8).toLowerCase()==="rejected"?(i=u.substr(e,8),e+=8):(i=null,t('"rejected"')),i===null&&(u.substr(e,7).toLowerCase()==="timeout"?(i=u.substr(e,7),e+=7):(i=null,t('"timeout"')),i===null&&(u.substr(e,6).toLowerCase()==="giveup"?(i=u.substr(e,6),e+=6):(i=null,t('"giveup"')),i===null&&(u.substr(e,10).toLowerCase()==="noresource"?(i=u.substr(e,10),e+=10):(i=null,t('"noresource"')),i===null&&(u.substr(e,9).toLowerCase()==="invariant"?(i=u.substr(e,9),e+=9):(i=null,t('"invariant"')),i===null&&(i=M()))))))),i}function ri(){var i;return i=B(),i=i!==null?i:"",i}function hn(){var i,_,m,T,y,r;if(y=e,i=M(),i!==null){for(_=[],r=e,m=be(),m!==null?(T=M(),T!==null?m=[m,T]:(m=null,e=r)):(m=null,e=r);m!==null;)_.push(m),r=e,m=be(),m!==null?(T=M(),T!==null?m=[m,T]:(m=null,e=r)):(m=null,e=r);_!==null?i=[i,_]:(i=null,e=y)}else i=null,e=y;return i=i!==null?i:"",i}function ii(){var i,_,m,T,y,r,f;if(y=e,r=e,i=ye(),i===null&&(i=ms()),i!==null){for(_=[],f=e,m=fe(),m!==null?(T=$l(),T!==null?m=[m,T]:(m=null,e=f)):(m=null,e=f);m!==null;)_.push(m),f=e,m=fe(),m!==null?(T=$l(),T!==null?m=[m,T]:(m=null,e=f)):(m=null,e=f);_!==null?i=[i,_]:(i=null,e=r)}else i=null,e=r;return i!==null&&(i=function(d){var s=x.tag;try{x=new Qr(x.uri,x.display_name,x.params),s&&x.setParam("tag",s)}catch{x=-1}}()),i===null&&(e=y),i}function $l(){var i;return i=Ts(),i===null&&(i=ze()),i}function Nr(){var i,_,m,T,y,r;if(y=e,i=Hn(),i!==null){for(_=[],r=e,m=be(),m!==null?(T=Hn(),T!==null?m=[m,T]:(m=null,e=r)):(m=null,e=r);m!==null;)_.push(m),r=e,m=be(),m!==null?(T=Hn(),T!==null?m=[m,T]:(m=null,e=r)):(m=null,e=r);_!==null?i=[i,_]:(i=null,e=y)}else i=null,e=y;return i}function Hn(){var i,_,m,T,y,r,f,d;if(f=e,i=Hl(),i!==null)if(_=H(),_!==null)if(m=jl(),m!==null){for(T=[],d=e,y=fe(),y!==null?(r=Fn(),r!==null?y=[y,r]:(y=null,e=d)):(y=null,e=d);y!==null;)T.push(y),d=e,y=fe(),y!==null?(r=Fn(),r!==null?y=[y,r]:(y=null,e=d)):(y=null,e=d);T!==null?i=[i,_,m,T]:(i=null,e=f)}else i=null,e=f;else i=null,e=f;else i=null,e=f;return i}function Fn(){var i;return i=ai(),i===null&&(i=qn(),i===null&&(i=_n(),i===null&&(i=Ur(),i===null&&(i=dn(),i===null&&(i=ze()))))),i}function ai(){var i,_,m,T,y;return T=e,y=e,u.substr(e,3).toLowerCase()==="ttl"?(i=u.substr(e,3),e+=3):(i=null,t('"ttl"')),i!==null?(_=P(),_!==null?(m=Vn(),m!==null?i=[i,_,m]:(i=null,e=y)):(i=null,e=y)):(i=null,e=y),i!==null&&(i=function(r,f){x.ttl=f}(T,i[2])),i===null&&(e=T),i}function qn(){var i,_,m,T,y;return T=e,y=e,u.substr(e,5).toLowerCase()==="maddr"?(i=u.substr(e,5),e+=5):(i=null,t('"maddr"')),i!==null?(_=P(),_!==null?(m=cs(),m!==null?i=[i,_,m]:(i=null,e=y)):(i=null,e=y)):(i=null,e=y),i!==null&&(i=function(r,f){x.maddr=f}(T,i[2])),i===null&&(e=T),i}function _n(){var i,_,m,T,y;return T=e,y=e,u.substr(e,8).toLowerCase()==="received"?(i=u.substr(e,8),e+=8):(i=null,t('"received"')),i!==null?(_=P(),_!==null?(m=Zt(),m===null&&(m=hs()),m!==null?i=[i,_,m]:(i=null,e=y)):(i=null,e=y)):(i=null,e=y),i!==null&&(i=function(r,f){x.received=f}(T,i[2])),i===null&&(e=T),i}function Ur(){var i,_,m,T,y;return T=e,y=e,u.substr(e,6).toLowerCase()==="branch"?(i=u.substr(e,6),e+=6):(i=null,t('"branch"')),i!==null?(_=P(),_!==null?(m=M(),m!==null?i=[i,_,m]:(i=null,e=y)):(i=null,e=y)):(i=null,e=y),i!==null&&(i=function(r,f){x.branch=f}(T,i[2])),i===null&&(e=T),i}function dn(){var i,_,m,T,y;return T=e,u.substr(e,5).toLowerCase()==="rport"?(i=u.substr(e,5),e+=5):(i=null,t('"rport"')),i!==null?(y=e,_=P(),_!==null?(m=jn(),m!==null?_=[_,m]:(_=null,e=y)):(_=null,e=y),_=_!==null?_:"",_!==null?i=[i,_]:(i=null,e=T)):(i=null,e=T),i}function jn(){var i,_,m,T,y,r,f;return r=e,f=e,i=C(),i=i!==null?i:"",i!==null?(_=C(),_=_!==null?_:"",_!==null?(m=C(),m=m!==null?m:"",m!==null?(T=C(),T=T!==null?T:"",T!==null?(y=C(),y=y!==null?y:"",y!==null?i=[i,_,m,T,y]:(i=null,e=f)):(i=null,e=f)):(i=null,e=f)):(i=null,e=f)):(i=null,e=f),i!==null&&(i=function(d,s){x.rport=parseInt(s.join(""))}(r,i)),i===null&&(e=r),i}function Hl(){var i,_,m,T,y,r;return r=e,i=Fl(),i!==null?(_=ht(),_!==null?(m=M(),m!==null?(T=ht(),T!==null?(y=ql(),y!==null?i=[i,_,m,T,y]:(i=null,e=r)):(i=null,e=r)):(i=null,e=r)):(i=null,e=r)):(i=null,e=r),i}function Fl(){var i,_;return _=e,u.substr(e,3).toLowerCase()==="sip"?(i=u.substr(e,3),e+=3):(i=null,t('"SIP"')),i===null&&(i=M()),i!==null&&(i=function(m,T){x.protocol=T}(_,i)),i===null&&(e=_),i}function ql(){var i,_;return _=e,u.substr(e,3).toLowerCase()==="udp"?(i=u.substr(e,3),e+=3):(i=null,t('"UDP"')),i===null&&(u.substr(e,3).toLowerCase()==="tcp"?(i=u.substr(e,3),e+=3):(i=null,t('"TCP"')),i===null&&(u.substr(e,3).toLowerCase()==="tls"?(i=u.substr(e,3),e+=3):(i=null,t('"TLS"')),i===null&&(u.substr(e,4).toLowerCase()==="sctp"?(i=u.substr(e,4),e+=4):(i=null,t('"SCTP"')),i===null&&(i=M())))),i!==null&&(i=function(m,T){x.transport=T}(_,i)),i===null&&(e=_),i}function jl(){var i,_,m,T,y;return T=e,i=Vl(),i!==null?(y=e,_=je(),_!==null?(m=Bl(),m!==null?_=[_,m]:(_=null,e=y)):(_=null,e=y),_=_!==null?_:"",_!==null?i=[i,_]:(i=null,e=T)):(i=null,e=T),i}function Vl(){var i,_;return _=e,i=Zt(),i===null&&(i=Qs(),i===null&&(i=Is())),i!==null&&(i=function(m){x.host=u.substring(e,m)}(_)),i===null&&(e=_),i}function Bl(){var i,_,m,T,y,r,f;return r=e,f=e,i=C(),i=i!==null?i:"",i!==null?(_=C(),_=_!==null?_:"",_!==null?(m=C(),m=m!==null?m:"",m!==null?(T=C(),T=T!==null?T:"",T!==null?(y=C(),y=y!==null?y:"",y!==null?i=[i,_,m,T,y]:(i=null,e=f)):(i=null,e=f)):(i=null,e=f)):(i=null,e=f)):(i=null,e=f),i!==null&&(i=function(d,s){x.port=parseInt(s.join(""))}(r,i)),i===null&&(e=r),i}function Vn(){var i,_,m,T,y;return T=e,y=e,i=C(),i!==null?(_=C(),_=_!==null?_:"",_!==null?(m=C(),m=m!==null?m:"",m!==null?i=[i,_,m]:(i=null,e=y)):(i=null,e=y)):(i=null,e=y),i!==null&&(i=function(r,f){return parseInt(f.join(""))}(T,i)),i===null&&(e=T),i}function xr(){var i;return i=Ln(),i}function Pr(){var i,_,m,T,y,r;if(y=e,i=Bn(),i!==null){for(_=[],r=e,m=fe(),m!==null?(T=Gl(),T!==null?m=[m,T]:(m=null,e=r)):(m=null,e=r);m!==null;)_.push(m),r=e,m=fe(),m!==null?(T=Gl(),T!==null?m=[m,T]:(m=null,e=r)):(m=null,e=r);_!==null?i=[i,_]:(i=null,e=y)}else i=null,e=y;return i}function Bn(){var i,_;return _=e,i=qt(),i!==null&&(i=function(m,T){x.expires=T}(_,i)),i===null&&(e=_),i}function Gl(){var i;return i=Mr(),i===null&&(i=ze()),i}function Mr(){var i,_,m,T,y;return T=e,y=e,u.substr(e,9).toLowerCase()==="refresher"?(i=u.substr(e,9),e+=9):(i=null,t('"refresher"')),i!==null?(_=P(),_!==null?(u.substr(e,3).toLowerCase()==="uac"?(m=u.substr(e,3),e+=3):(m=null,t('"uac"')),m===null&&(u.substr(e,3).toLowerCase()==="uas"?(m=u.substr(e,3),e+=3):(m=null,t('"uas"'))),m!==null?i=[i,_,m]:(i=null,e=y)):(i=null,e=y)):(i=null,e=y),i!==null&&(i=function(r,f){x.refresher=f.toLowerCase()}(T,i[2])),i===null&&(e=T),i}function Wl(){var i,_,m,T;return T=e,i=M(),i!==null?(_=Ue(),_!==null?(m=Kl(),m!==null?i=[i,_,m]:(i=null,e=T)):(i=null,e=T)):(i=null,e=T),i}function Kl(){var i,_;for(i=[],_=L(),_===null&&(_=G(),_===null&&(_=H()));_!==null;)i.push(_),_=L(),_===null&&(_=G(),_===null&&(_=H()));return i}function oi(){var i,_;for(i=[],_=E();_!==null;)i.push(_),_=E();return i}function ui(){var i,_,m;return m=e,u.substr(e,5)==="uuid:"?(i="uuid:",e+=5):(i=null,t('"uuid:"')),i!==null?(_=Gn(),_!==null?i=[i,_]:(i=null,e=m)):(i=null,e=m),i}function Gn(){var i,_,m,T,y,r,f,d,s,c,h;return c=e,h=e,i=ci(),i!==null?(u.charCodeAt(e)===45?(_="-",e++):(_=null,t('"-"')),_!==null?(m=Jt(),m!==null?(u.charCodeAt(e)===45?(T="-",e++):(T=null,t('"-"')),T!==null?(y=Jt(),y!==null?(u.charCodeAt(e)===45?(r="-",e++):(r=null,t('"-"')),r!==null?(f=Jt(),f!==null?(u.charCodeAt(e)===45?(d="-",e++):(d=null,t('"-"')),d!==null?(s=Yl(),s!==null?i=[i,_,m,T,y,r,f,d,s]:(i=null,e=h)):(i=null,e=h)):(i=null,e=h)):(i=null,e=h)):(i=null,e=h)):(i=null,e=h)):(i=null,e=h)):(i=null,e=h)):(i=null,e=h),i!==null&&(i=function(g,S){x=u.substring(e+5,g)}(c,i[0])),i===null&&(e=c),i}function Jt(){var i,_,m,T,y;return y=e,i=A(),i!==null?(_=A(),_!==null?(m=A(),m!==null?(T=A(),T!==null?i=[i,_,m,T]:(i=null,e=y)):(i=null,e=y)):(i=null,e=y)):(i=null,e=y),i}function ci(){var i,_,m;return m=e,i=Jt(),i!==null?(_=Jt(),_!==null?i=[i,_]:(i=null,e=m)):(i=null,e=m),i}function Yl(){var i,_,m,T;return T=e,i=Jt(),i!==null?(_=Jt(),_!==null?(m=Jt(),m!==null?i=[i,_,m]:(i=null,e=T)):(i=null,e=T)):(i=null,e=T),i}function rs(){var i,_,m,T,y,r,f;if(y=e,r=e,i=ye(),i===null&&(i=ms()),i!==null){for(_=[],f=e,m=fe(),m!==null?(T=ze(),T!==null?m=[m,T]:(m=null,e=f)):(m=null,e=f);m!==null;)_.push(m),f=e,m=fe(),m!==null?(T=ze(),T!==null?m=[m,T]:(m=null,e=f)):(m=null,e=f);_!==null?i=[i,_]:(i=null,e=r)}else i=null,e=r;return i!==null&&(i=function(d){try{x=new Qr(x.uri,x.display_name,x.params)}catch{x=-1}}()),i===null&&(e=y),i}function fi(){var i,_,m,T,y,r;if(y=e,i=zl(),i!==null){for(_=[],r=e,m=fe(),m!==null?(T=Bt(),T!==null?m=[m,T]:(m=null,e=r)):(m=null,e=r);m!==null;)_.push(m),r=e,m=fe(),m!==null?(T=Bt(),T!==null?m=[m,T]:(m=null,e=r)):(m=null,e=r);_!==null?i=[i,_]:(i=null,e=y)}else i=null,e=y;return i}function zl(){var i,_,m,T,y,r;return T=e,y=e,i=$(),i!==null?(r=e,u.charCodeAt(e)===64?(_="@",e++):(_=null,t('"@"')),_!==null?(m=$(),m!==null?_=[_,m]:(_=null,e=r)):(_=null,e=r),_=_!==null?_:"",_!==null?i=[i,_]:(i=null,e=y)):(i=null,e=y),i!==null&&(i=function(f){x.call_id=u.substring(e,f)}(T)),i===null&&(e=T),i}function Bt(){var i;return i=kr(),i===null&&(i=Jl(),i===null&&(i=Xl(),i===null&&(i=ze()))),i}function kr(){var i,_,m,T,y;return T=e,y=e,u.substr(e,6)==="to-tag"?(i="to-tag",e+=6):(i=null,t('"to-tag"')),i!==null?(_=P(),_!==null?(m=M(),m!==null?i=[i,_,m]:(i=null,e=y)):(i=null,e=y)):(i=null,e=y),i!==null&&(i=function(r,f){x.to_tag=f}(T,i[2])),i===null&&(e=T),i}function Jl(){var i,_,m,T,y;return T=e,y=e,u.substr(e,8)==="from-tag"?(i="from-tag",e+=8):(i=null,t('"from-tag"')),i!==null?(_=P(),_!==null?(m=M(),m!==null?i=[i,_,m]:(i=null,e=y)):(i=null,e=y)):(i=null,e=y),i!==null&&(i=function(r,f){x.from_tag=f}(T,i[2])),i===null&&(e=T),i}function Xl(){var i,_;return _=e,u.substr(e,10)==="early-only"?(i="early-only",e+=10):(i=null,t('"early-only"')),i!==null&&(i=function(m){x.early_only=!0}()),i===null&&(e=_),i}function hi(i){i.sort();for(var _=null,m=[],T=0;T<i.length;T++)i[T]!==_&&(m.push(i[T]),_=i[T]);return m}function Lr(){for(var i=1,_=1,m=!1,T=0;T<Math.max(e,o);T++){var y=u.charAt(T);y===`
|
159
|
-
`?(m||i++,_=1,m=!1):y==="\r"||y==="\u2028"||y==="\u2029"?(i++,_=1,m=!0):(_++,m=!1)}return{line:i,column:_}}var x={},Ql=a[n]();if(console.log("Grammar result",n,Ql),console.log("Grammar return",Ql),Ql===null||e!==u.length){var Zl=Math.max(e,o),$r=Zl<u.length?u.charAt(Zl):null,Vs=Lr();return new this.SyntaxError(hi(p),$r,Zl,Vs.line,Vs.column),console.log("Grammar return -1"),-1}return x},toSource:function(){return this._source}};Ki.SyntaxError=function(u,n,a,e,o){function p(t,v){var C,l;switch(t.length){case 0:C="end of input";break;case 1:C=t[0];break;default:C=t.slice(0,t.length-1).join(", ")+" or "+t[t.length-1]}return l=v?Th(v):"end of input","Expected "+C+" but "+l+" found."}this.name="SyntaxError",this.expected=u,this.found=n,this.message=p(u,n),this.offset=a,this.line=e,this.column=o},Ki.SyntaxError.prototype=Error.prototype;const co=new Ba("Parser"),Ev=(u,n)=>{let a,e,o=u.indexOf(`\r
|
160
|
-
`);if(o===-1){co.warn("parseMessage() | no CRLF found, not a SIP message");return}const p=u.substring(0,o);let t=Ki.parse(p,"Request_Response");if(t===-1){co.warn(`parseMessage() | error parsing first line of SIP message: "${p}"`);return}else t.status_code?(a=new ir.IncomingResponse,a.status_code=t.status_code,a.reason_phrase=t.reason_phrase):(a=new ir.IncomingRequest(n),a.method=t.method,a.ruri=t.uri);a.data=u;let v=o+2;for(;;){if(o=Cv(u,v),o===-2){e=v+2;break}else if(o===-1){co.warn("parseMessage() | malformed message");return}if(t=Sv(a,u,v,o),t!==!0){co.warn("parseMessage() |",t.error);return}v=o+2}if(a.hasHeader("content-length")){const C=a.getHeader("content-length");a.body=u.substr(e,C)}else a.body=u.substring(e);return a};function Cv(u,n){let a=n,e=0,o=0;if(u.substring(a,a+2).match(/(^\r\n)/))return-2;for(;e===0;){if(o=u.indexOf(`\r
|
161
|
-
`,a),o===-1)return o;!u.substring(o+2,o+4).match(/(^\r\n)/)&&u.charAt(o+2).match(/(^\s+)/)?a=o+2:e=o}return e}function Sv(u,n,a,e){let o;const p=n.indexOf(":",a),t=n.substring(a,p).trim(),v=n.substring(p+1,e).trim();switch(t.toLowerCase()){case"via":case"v":u.addHeader("via",v),u.getHeaders("via").length===1?(o=u.parseHeader("Via"),o&&(u.via=o,u.via_branch=o.branch)):o=0;break;case"from":case"f":u.setHeader("from",v),o=u.parseHeader("from"),o&&(u.from=o,u.from_tag=o.getParam("tag"));break;case"to":case"t":u.setHeader("to",v),o=u.parseHeader("to"),o&&(u.to=o,u.to_tag=o.getParam("tag"));break;case"record-route":if(o=Ki.parse(v,"Record_Route"),o===-1)o=void 0;else for(const C of o)u.addHeader("record-route",v.substring(C.possition,C.offset)),u.headers["Record-Route"][u.getHeaders("record-route").length-1].parsed=C.parsed;break;case"call-id":case"i":u.setHeader("call-id",v),o=u.parseHeader("call-id"),o&&(u.call_id=v);break;case"contact":case"m":if(o=Ki.parse(v,"Contact"),o===-1)o=void 0;else for(const C of o)u.addHeader("contact",v.substring(C.possition,C.offset)),u.headers.Contact[u.getHeaders("contact").length-1].parsed=C.parsed;break;case"content-length":case"l":u.setHeader("content-length",v),o=u.parseHeader("content-length");break;case"content-type":case"c":u.setHeader("content-type",v),o=u.parseHeader("content-type");break;case"cseq":u.setHeader("cseq",v),o=u.parseHeader("cseq"),o&&(u.cseq=o.value),u instanceof ir.IncomingResponse&&(u.method=o.method);break;case"max-forwards":u.setHeader("max-forwards",v),o=u.parseHeader("max-forwards");break;case"www-authenticate":u.setHeader("www-authenticate",v),o=u.parseHeader("www-authenticate");break;case"proxy-authenticate":u.setHeader("proxy-authenticate",v),o=u.parseHeader("proxy-authenticate");break;case"session-expires":case"x":u.setHeader("session-expires",v),o=u.parseHeader("session-expires"),o&&(u.session_expires=o.expires,u.session_expires_refresher=o.refresher);break;case"refer-to":case"r":u.setHeader("refer-to",v),o=u.parseHeader("refer-to"),o&&(u.refer_to=o);break;case"replaces":u.setHeader("replaces",v),o=u.parseHeader("replaces"),o&&(u.replaces=o);break;case"event":case"o":u.setHeader("event",v),o=u.parseHeader("event"),o&&(u.event=o);break;default:u.addHeader(t,v),o=0}return o===void 0?{error:`error parsing header "${t}"`}:!0}const Av={parseMessage:Ev},Yi=new Ba("Registrator"),fo=10;class yv{constructor(n,a){this._reg_id=1,this._ua=n,this._transport=a,this._registrar=n.configuration.registrar_server,this._expires=n.configuration.register_expires,this._call_id=An.createRandomToken(22),this._cseq=0,this._to_uri=n.configuration.uri,this._registrationTimer=null,this._registering=!1,this._registered=!1,this._contact=this._ua.contact.toString();const e=this._contact.indexOf(">");if(e!==-1){const o=this._contact.slice(0,e)+this._contact.slice(e+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(n){Array.isArray(n)||(n=[]),this._extraHeaders=n.slice()}setExtraContactParams(n){n instanceof Object||(n={}),this._extraContactParams="";for(const a in n)if(Object.prototype.hasOwnProperty.call(n,a)){const e=n[a];this._extraContactParams+=`;${a}`,e&&(this._extraContactParams+=`=${e}`)}}setExtraContactUriParams(n){n instanceof Object||(n={}),this._extraContactParams="";for(const a in n)if(Object.prototype.hasOwnProperty.call(n,a)){const e=n[a];this._extraContactParams+=`;${a}`,e&&(this._extraContactParams+=`=${e}`)}}register(){if(this._registering){Yi.debug("Register request in progress...");return}const n=this._extraHeaders.slice();n.push(`Contact: ${this._contact}${this._extraContactParams}>${this._extra_contact};expires=${this._expires}`),n.push(`Expires: ${this._expires}`);const a=new kt.OutgoingRequest(Y.REGISTER,this._registrar,this._ua,{to_uri:this._to_uri,call_id:this._call_id,cseq:this._cseq+=1},n),e=new za(this._ua,a,{onRequestTimeout:()=>{this._registrationFailure(null,Y.causes.REQUEST_TIMEOUT)},onTransportError:()=>{this._registrationFailure(null,Y.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")){Yi.debug("no Contact header in response to REGISTER, response ignored");break}const p=o.headers.Contact.reduce((l,A)=>l.concat(A.parsed),[]);let t=p.find(l=>this._sipInstance===l.getParam("+sip.instance")&&this._reg_id===parseInt(l.getParam("reg-id")));if(t||(t=p.find(l=>l.uri.user===this._ua.contact.uri.user)),!t){Yi.debug("no Contact header pointing to us, response ignored");break}let v=t.getParam("expires");!v&&o.hasHeader("expires")&&(v=o.getHeader("expires")),v||(v=this._expires),v=Number(v),v<fo&&(v=fo);const C=v>64?v*1e3/2+Math.floor((v/2-32)*1e3*Math.random()):v*1e3-5e3;this._registrationTimer=setTimeout(()=>{this._registrationTimer=null,this._ua.listeners("registrationExpiring").length===0?this.register():this._ua.emit("registrationExpiring")},C),t.hasParam("temp-gruu")&&(this._ua.contact.temp_gruu=t.getParam("temp-gruu").replace(/"/g,"")),t.hasParam("pub-gruu")&&(this._ua.contact.pub_gruu=t.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<fo&&(this._expires=fo),this.register()):(Yi.debug("423 response received for REGISTER without Min-Expires"),this._registrationFailure(o,Y.causes.SIP_FAILURE_CODE));break}default:{const p=An.sipErrorCause(o.status_code);this._registrationFailure(o,p)}}}});this._registering=!0,e.send()}unregister(n={}){if(!this._registered){Yi.debug("already unregistered");return}this._registered=!1,this._registrationTimer!==null&&(clearTimeout(this._registrationTimer),this._registrationTimer=null);const a=this._extraHeaders.slice();n.all?a.push(`Contact: *${this._extraContactParams}`):a.push(`Contact: ${this._contact}${this._extraContactParams}>;expires=0`),a.push("Expires: 0");const e=new kt.OutgoingRequest(Y.REGISTER,this._registrar,this._ua,{to_uri:this._to_uri,call_id:this._call_id,cseq:this._cseq+=1},a);new za(this._ua,e,{onRequestTimeout:()=>{this._unregistered(null,Y.causes.REQUEST_TIMEOUT)},onTransportError:()=>{this._unregistered(null,Y.causes.CONNECTION_ERROR)},onAuthenticated:()=>{this._cseq+=1},onReceiveResponse:p=>{switch(!0){case/^1[0-9]{2}$/.test(p.status_code):break;case/^2[0-9]{2}$/.test(p.status_code):this._unregistered(p);break;default:{const t=An.sipErrorCause(p.status_code);this._unregistered(p,t)}}}}).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(n,a){this._registering=!1,this._ua.registrationFailed({response:n||null,cause:a}),this._registered&&(this._registered=!1,this._ua.unregistered({response:n||null,cause:a}))}_unregistered(n,a){this._registering=!1,this._registered=!1,this._ua.unregistered({response:n||null,cause:a||null})}}const At=console,sl={STATUS_INIT:0,STATUS_READY:1,STATUS_USER_CLOSED:2,STATUS_NOT_READY:3,CONFIGURATION_ERROR:1,NETWORK_ERROR:2},Rv=fv;class bv extends Rv{constructor(n){super(n),this._msrp_sessions=[],this._transactions={nist:{},nict:{},ist:{},ict:{}},this._janus_sessions=[],this._registrator=new yv(this)}call(n,a){return super.call(n,a)}joinVideoCall(n,a,e){At.debug("call()");const o=new uo(this);return o.connect(n,a,e),o}_loadConfig(n){try{Wi.load(this._configuration,n)}catch(o){throw o}this._configuration.display_name===0&&(this._configuration.display_name="0"),this._configuration.instance_id||(this._configuration.instance_id=An.newUUID()),this._configuration.jssip_id=An.createRandomToken(5);const a=this._configuration.uri.clone();a.user=null,this._configuration.hostport_params=a.toString().replace(/^sip:/i,"");try{this._transport=new Lg(this._configuration.sockets,{max_interval:this._configuration.connection_recovery_max_interval,min_interval:this._configuration.connection_recovery_min_interval}),this._transport.onconnecting=Iv.bind(this),this._transport.onconnect=wv.bind(this),this._transport.ondisconnect=Ov.bind(this),this._transport.ondata=Dv.bind(this)}catch(o){throw At.warn(o),new Xn.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 o=this._configuration.uri.clone();o.user=null,o.clearParams(),o.clearHeaders(),this._configuration.registrar_server=o}this._configuration.no_answer_timeout*=1e3,this._configuration.contact_uri?this._configuration.via_host=this._configuration.contact_uri.host:this._configuration.contact_uri=new tl("sip",An.createRandomToken(8),this._configuration.via_host,null,{transport:"ws"}),this._contact={pub_gruu:null,temp_gruu:null,uri:this._configuration.contact_uri,toString(o={}){const p=o.anonymous||null,t=o.outbound||null;let v="<";return p?v+=this.temp_gruu||"sip:anonymous@anonymous.invalid;transport=ws":v+=this.pub_gruu||this.uri.toString(),t&&(p?!this.temp_gruu:!this.pub_gruu)&&(v+=";ob"),v+=">",v}};const e=["authorization_user","password","realm","ha1","authorization_jwt","display_name","register"];for(const o in this._configuration)Object.prototype.hasOwnProperty.call(this._configuration,o)&&(e.indexOf(o)!==-1?Object.defineProperty(this._configuration,o,{writable:!0,configurable:!1}):Object.defineProperty(this._configuration,o,{writable:!1,configurable:!1}));At.debug("configuration parameters after validation:");for(const o in this._configuration)if(Object.prototype.hasOwnProperty.call(Wi.settings,o))switch(o){case"uri":case"registrar_server":At.debug(`- ${o}: ${this._configuration[o]}`);break;case"password":case"ha1":case"authorization_jwt":At.debug(`- ${o}: NOT SHOWN`);break;default:At.debug(`- ${o}: ${JSON.stringify(this._configuration[o])}`)}}newMSRPSession(n,a){n.on("msgHistoryUpdate",e=>{console.log(e)}),this._msrp_sessions[n.id]=n,this.emit("newMSRPSession",a)}newJanusSession(n,a){this._janus_sessions[n.id]=n,this.emit("newJanusSession",a)}destroyMSRPSession(n){delete this._msrp_sessions[n.id]}destroyJanusSession(n){delete this._janus_sessions[n.id]}receiveRequest(n){var p,t,v,C;const a=n.method;if(console.log("-----------"),n.ruri.user!==this._configuration.uri.user&&n.ruri.user!==this._contact.uri.user){At.debug("Request-URI does not point to us"),n.method!==Fe.ACK&&n.reply_sl(404);return}if(n.ruri.scheme===Fe.SIPS){n.reply_sl(416);return}if(os.checkTransaction(this,n))return;if(a===Fe.INVITE?new os.InviteServerTransaction(this,this._transport,n):a!==Fe.ACK&&a!==Fe.CANCEL&&new os.NonInviteServerTransaction(this,this._transport,n),a===Fe.OPTIONS){if(this.listeners("newOptions").length===0){n.reply(200);return}new Af.Options(this).init_incoming(n)}else if(a===Fe.MESSAGE){if(this.listeners("newMessage").length===0){n.reply(405);return}new Af.Message(this).init_incoming(n)}else if(a===Fe.INVITE&&!n.to_tag&&this.listeners("newRTCSession").length===0){n.reply(405);return}let e,o;if(n.to_tag)if(e=this._findDialog(n.call_id,n.from_tag,n.to_tag),e)e.receiveRequest(n);else if(a===Fe.NOTIFY)if(o=this._findSession(n),o)o.receiveRequest(n);else{if(n.body)try{const l=JSON.parse(n.body)||{};(t=(p=l.plugindata)==null?void 0:p.data)!=null&&t.publishers&&Object.values(this._janus_sessions)[0].receivePublishers(l),(C=(v=l.plugindata)==null?void 0:v.data)!=null&&C.unpublished&&Object.values(this._janus_sessions)[0].receiveUnpublished(l.plugindata.data.unpublished)}catch(l){console.error(l)}n.reply(200)}else a!==Fe.ACK&&n.reply(481);else switch(a){case Fe.INVITE:if(window.RTCPeerConnection)if(n.hasHeader("replaces")){const l=n.replaces;e=this._findDialog(l.call_id,l.from_tag,l.to_tag),e?(o=e.owner,o.isEnded()?n.reply(603):o.receiveRequest(n)):n.reply(481)}else n.body.search(/MSRP/ig)>-1?(o=new Hu(this),o.init_incoming(n)):n.body.search(/JANUS/ig)>-1||(o=new Cg(this),o.init_incoming(n));else At.warn("INVITE received but WebRTC is not supported"),n.reply(488);break;case Fe.BYE:n.reply(481);break;case Fe.CANCEL:o=this._findSession(n),o?o.receiveRequest(n):At.debug("received CANCEL request for a non existent session");break;case Fe.ACK:break;case Fe.NOTIFY:this.emit("sipEvent",{event:n.event,request:n}),n.reply(200);break;default:n.reply(405);break}}startMSRP(n,a){At.debug("startMSRP()",a);const e=new Hu(this);return e.connect(n),e}startJanus(n,a){At.debug("startJanus()",a);const e=new Hu(this);return e.connect(n),e}terminateMSRPSessions(n){At.debug("terminateSessions()");for(const a in this._msrp_sessions)this._msrp_sessions[a].isEnded()||this._msrp_sessions[a].terminate(n)}terminateJanusSessions(n){At.debug("terminateSessions()");for(const a in this._janus_sessions)this._janus_sessions[a].isEnded()||this._janus_sessions[a].terminate(n)}stop(){if(At.debug("stop()"),this._dynConfiguration={},this._status===sl.STATUS_USER_CLOSED){At.debug("UA already closed");return}this._registrator.close();const n=Object.keys(this._sessions).length;for(const e in this._sessions)if(Object.prototype.hasOwnProperty.call(this._sessions,e)){At.debug(`closing session ${e}`);try{this._sessions[e].terminate()}catch(o){console.error(o)}}for(const e in this._msrp_sessions)if(Object.prototype.hasOwnProperty.call(this._msrp_sessions,e)){At.debug(`closing session ${e}`);try{this._msrp_sessions[e].terminate()}catch(o){console.error(o)}}for(const e in this._janus_sessions)if(Object.prototype.hasOwnProperty.call(this._janus_sessions,e)){At.debug(`closing session ${e}`);try{this._janus_sessions[e].terminate()}catch(o){console.error(o)}}for(const e in this._applicants)if(Object.prototype.hasOwnProperty.call(this._applicants,e))try{this._applicants[e].close()}catch(o){console.error(o)}this._status=sl.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 Iv(u){this.emit("connecting",u)}function wv(u){this._status!==sl.STATUS_USER_CLOSED&&(this._status=sl.STATUS_READY,this._error=null,this.emit("connected",u),this._dynConfiguration.register&&this._registrator.register())}function Ov(u){const n=["nict","ict","nist","ist"];for(const a of n)for(const e in this._transactions[a])Object.prototype.hasOwnProperty.call(this._transactions[a],e)&&this._transactions[a][e].onTransportError();this.emit("disconnected",u),this._registrator.onTransportClosed(),this._status!==sl.STATUS_USER_CLOSED&&(this._status=sl.STATUS_NOT_READY,this._error=sl.NETWORK_ERROR)}function Dv(u){console.log("onTransportData",u);const n=u.transport;let a=u.message;if(a=Av.parseMessage(a,this),!a){console.log("if 1 return");return}if(this._status===sl.STATUS_USER_CLOSED&&a instanceof ir.IncomingRequest){console.log("if 2 return");return}if(!Qg(a,this,n)){console.log("if 3 return");return}if(console.log("onTransportData message",a),console.log("onTransportData instanceof",a instanceof ir.IncomingRequest),a instanceof ir.IncomingRequest)a.transport=n,console.log("onTransportData receiveRequest"),this.receiveRequest(a);else if(a instanceof ir.IncomingResponse){let e;switch(a.method){case Fe.INVITE:e=this._transactions.ict[a.via_branch],e&&e.receiveResponse(a);break;case Fe.ACK:break;default:e=this._transactions.nict[a.via_branch],e&&e.receiveResponse(a);break}}}const Nv=["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"],Uv=["_cancel_reason","_contact","direction","_end_time","_eventsCount","_from_tag","_id","_is_canceled","_is_confirmed","_late_sdp","status","start_time","_remote_identity","target_addr"];function Eh(u){const n={};return Nv.forEach(a=>{u[a]!==void 0&&(n[a]=u[a])}),n.localHold=u._localHold,n}function Ch(u){const n={};return Uv.forEach(a=>{u[a]!==void 0&&(n[a]=u[a])}),n}function Sh(u,n){const a=new AudioContext,e=a.createMediaStreamSource(u),o=a.createMediaStreamDestination(),p=a.createGain();return e.connect(p),p.connect(o),p.gain.value=n,o.stream}function xv(u,n,a,e){const o=document.createElement("audio");o.id=n._id,o.className="audioTag",o.srcObject=u,Ah()||(o.setSinkId(a),o.volume=e),o.play(),n.audioTag=o}function Pv(u){if(u&&typeof u.log=="function"&&typeof u.warn=="function"&&typeof u.error=="function")return!0}function Ah(){return/Mobi|Android|iPhone/i.test(navigator.userAgent)}const Mv=Tt,kv=Ys(),Vt=new Mv("WebSocketInterface");var Lv=class{constructor(n){Vt.debug('new() [url:"%s"]',n),this._url=n,this._sip_uri=null,this._via_transport=null,this._ws=null;const a=kv.parse(n,"absoluteURI");if(a===-1)throw Vt.warn(`invalid WebSocket URI: ${n}`),new TypeError(`Invalid argument: ${n}`);if(a.scheme!=="wss"&&a.scheme!=="ws")throw Vt.warn(`invalid WebSocket URI scheme: ${a.scheme}`),new TypeError(`Invalid argument: ${n}`);this._sip_uri=`sip:${a.host}${a.port?`:${a.port}`:""};transport=ws`,this._via_transport=a.scheme.toUpperCase()}get via_transport(){return this._via_transport}set via_transport(n){this._via_transport=n.toUpperCase()}get sip_uri(){return this._sip_uri}get url(){return this._url}connect(){if(Vt.debug("connect()"),this.isConnected()){Vt.debug(`WebSocket ${this._url} is already connected`);return}else if(this.isConnecting()){Vt.debug(`WebSocket ${this._url} is connecting`);return}this._ws&&this.disconnect(),Vt.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(n){this._onError(n)}}disconnect(){Vt.debug("disconnect()"),this._ws&&(this._ws.onopen=()=>{},this._ws.onclose=()=>{},this._ws.onmessage=()=>{},this._ws.onerror=()=>{},this._ws.close(),this._ws=null)}send(n){return Vt.debug("send()"),this.isConnected()?(this._ws.send(n),!0):(Vt.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(){Vt.debug(`WebSocket ${this._url} connected`),this.onconnect()}_onClose({wasClean:n,code:a,reason:e}){Vt.debug(`WebSocket ${this._url} closed`),n===!1&&Vt.debug("WebSocket abrupt disconnection"),this.ondisconnect(!n,a,e)}_onMessage({data:n}){Vt.debug("received WebSocket message"),this.ondata(n)}_onError(n){Vt.warn(`WebSocket ${this._url} error: `,n)}};const Fu=ra,$v=Fe,Hv=Sn,Fv=wt(),qv=mh,jv=Tn(),Vv=Ga(),Bv=Ys(),Gv=Lv;jr("JsSIP")("version %s",Fu.version);var Wv={C:$v,Exceptions:Hv,Utils:Fv,UA:qv,URI:jv,NameAddrHeader:Vv,WebSocketInterface:Gv,Grammar:Bv,debug:jr,get name(){return Fu.title},get version(){return Fu.version}};const Kv=Be(Wv);function qu(u){return u<10?`0${u}`:`${u}`}function Yv(u){let n=u.hours||0,a=u.minutes||0,e=u.seconds||0;e++,e===60&&(e=0,a++,a===60&&(a=0,n++));const o=`${qu(n)}:${qu(a)}:${qu(e)}`;return{seconds:e,minutes:a,hours:n,formatted:o}}var xt={};xt.forEach=async(u,n,a)=>{const e=[];for(let o=0;o<u.length;o++)if(o in u){const p=Promise.resolve(u[o]).then(t=>n.call(a||globalThis,t,o,u));e.push(p)}await Promise.all(e)},xt.forEachSeries=async(u,n,a)=>{for(let e=0;e<u.length;e++)e in u&&await n.call(a||globalThis,await u[e],e,u)},xt.map=async(u,n,a)=>{const e=[];for(let o=0;o<u.length;o++)o in u&&(e[o]=Promise.resolve(u[o]).then(p=>n.call(a||globalThis,p,o,u)));return Promise.all(e)},xt.mapSeries=async(u,n,a)=>{const e=[];for(let o=0;o<u.length;o++)o in u&&(e[o]=await n.call(a||globalThis,await u[o],o,u));return e},xt.find=(u,n,a)=>new Promise((e,o)=>{if(u.length===0)return e();let p=1;for(let t=0;t<u.length;t++){const v=C=>{C?e(u[t]):p===u.length&&e(),p++};Promise.resolve(u[t]).then(C=>n.call(a||globalThis,C,t,u)).then(v).catch(o)}}),xt.findSeries=async(u,n,a)=>{for(let e=0;e<u.length;e++)if(await n.call(a||globalThis,await u[e],e,u))return u[e]},xt.findIndex=(u,n,a)=>new Promise((e,o)=>{if(u.length===0)return e(-1);let p=1;for(let t=0;t<u.length;t++){const v=C=>{C?e(t):p===u.length&&e(-1),p++};Promise.resolve(u[t]).then(C=>n.call(a||globalThis,C,t,u)).then(v).catch(o)}}),xt.findIndexSeries=async(u,n,a)=>{for(let e=0;e<u.length;e++)if(await n.call(a||globalThis,await u[e],e,u))return e},xt.some=(u,n,a)=>new Promise((e,o)=>{if(u.length===0)return e(!1);let p=1;for(let t=0;t<u.length;t++){if(!(t in u)){p++;continue}const v=C=>{C?e(!0):p===u.length&&e(!1),p++};Promise.resolve(u[t]).then(C=>n.call(a||globalThis,C,t,u)).then(v).catch(o)}}),xt.someSeries=async(u,n,a)=>{for(let e=0;e<u.length;e++)if(e in u&&await n.call(a||globalThis,await u[e],e,u))return!0;return!1},xt.every=(u,n,a)=>new Promise((e,o)=>{if(u.length===0)return e(!0);let p=1;for(let t=0;t<u.length;t++){if(!(t in u)){p++;continue}const v=C=>{C?p===u.length&&e(!0):e(!1),p++};Promise.resolve(u[t]).then(C=>n.call(a||globalThis,C,t,u)).then(v).catch(o)}}),xt.everySeries=async(u,n,a)=>{for(let e=0;e<u.length;e++)if(e in u&&!await n.call(a||globalThis,await u[e],e,u))return!1;return!0},xt.filter=(u,n,a)=>new Promise(async(e,o)=>{const p=[];for(let v=0;v<u.length;v++)v in u&&(p[v]=Promise.resolve(u[v]).then(C=>n.call(a||globalThis,C,v,u)).catch(o));const t=[];for(let v=0;v<p.length;v++)await p[v]&&t.push(await u[v]);e(t)}),xt.filterSeries=async(u,n,a)=>{const e=[];for(let o=0;o<u.length;o++)o in u&&await n.call(a||globalThis,await u[o],o,u)&&e.push(await u[o]);return e},xt.reduce=async(u,n,a)=>{if(u.length===0&&a===void 0)throw TypeError("Reduce of empty array with no initial value");let e,o;for(a!==void 0?(o=a,e=0):(o=u[0],e=1),e;e<u.length;e++)e in u&&(o=await n(await o,await u[e],e,u));return o};var yh={};(function(u){const n=xt;Object.keys(n).forEach(a=>{const e=a.charAt(0).toUpperCase()+a.slice(1);u[`async${e}`]=async function(...o){return n[a](this,...o)}})})(yh);var zv=Object.assign(xt,{instanceMethods:yh});const fr=new AudioContext,Rs={NEW_CALL:"new_call",CALL_CONFIRMED:"confirmed",CALL_FAILED:"failed",CALL_PROGRESS:"progress",CALL_ENDED:"ended"};var Jv={exports:{}};(function(u){var n=function(a){var e=Object.prototype,o=e.hasOwnProperty,p=Object.defineProperty||function(P,Q,oe){P[Q]=oe.value},t,v=typeof Symbol=="function"?Symbol:{},C=v.iterator||"@@iterator",l=v.asyncIterator||"@@asyncIterator",A=v.toStringTag||"@@toStringTag";function b(P,Q,oe){return Object.defineProperty(P,Q,{value:oe,enumerable:!0,configurable:!0,writable:!0}),P[Q]}try{b({},"")}catch{b=function(Q,oe,he){return Q[oe]=he}}function E(P,Q,oe,he){var Re=Q&&Q.prototype instanceof _e?Q:_e,be=Object.create(Re.prototype),fe=new $(he||[]);return p(be,"_invoke",{value:K(P,oe,fe)}),be}a.wrap=E;function O(P,Q,oe){try{return{type:"normal",arg:P.call(Q,oe)}}catch(he){return{type:"throw",arg:he}}}var w="suspendedStart",N="suspendedYield",U="executing",z="completed",j={};function _e(){}function k(){}function H(){}var de={};b(de,C,function(){return this});var Ue=Object.getPrototypeOf,B=Ue&&Ue(Ue(ne([])));B&&B!==e&&o.call(B,C)&&(de=B);var L=H.prototype=_e.prototype=Object.create(de);k.prototype=H,p(L,"constructor",{value:H,configurable:!0}),p(H,"constructor",{value:k,configurable:!0}),k.displayName=b(H,A,"GeneratorFunction");function V(P){["next","throw","return"].forEach(function(Q){b(P,Q,function(oe){return this._invoke(Q,oe)})})}a.isGeneratorFunction=function(P){var Q=typeof P=="function"&&P.constructor;return Q?Q===k||(Q.displayName||Q.name)==="GeneratorFunction":!1},a.mark=function(P){return Object.setPrototypeOf?Object.setPrototypeOf(P,H):(P.__proto__=H,b(P,A,"GeneratorFunction")),P.prototype=Object.create(L),P},a.awrap=function(P){return{__await:P}};function G(P,Q){function oe(be,fe,je,xe){var we=O(P[be],P,fe);if(we.type==="throw")xe(we.arg);else{var rt=we.arg,$e=rt.value;return $e&&typeof $e=="object"&&o.call($e,"__await")?Q.resolve($e.__await).then(function(ue){oe("next",ue,je,xe)},function(ue){oe("throw",ue,je,xe)}):Q.resolve($e).then(function(ue){rt.value=ue,je(rt)},function(ue){return oe("throw",ue,je,xe)})}}var he;function Re(be,fe){function je(){return new Q(function(xe,we){oe(be,fe,xe,we)})}return he=he?he.then(je,je):je()}p(this,"_invoke",{value:Re})}V(G.prototype),b(G.prototype,l,function(){return this}),a.AsyncIterator=G,a.async=function(P,Q,oe,he,Re){Re===void 0&&(Re=Promise);var be=new G(E(P,Q,oe,he),Re);return a.isGeneratorFunction(Q)?be:be.next().then(function(fe){return fe.done?fe.value:be.next()})};function K(P,Q,oe){var he=w;return function(be,fe){if(he===U)throw new Error("Generator is already running");if(he===z){if(be==="throw")throw fe;return ht()}for(oe.method=be,oe.arg=fe;;){var je=oe.delegate;if(je){var xe=M(je,oe);if(xe){if(xe===j)continue;return xe}}if(oe.method==="next")oe.sent=oe._sent=oe.arg;else if(oe.method==="throw"){if(he===w)throw he=z,oe.arg;oe.dispatchException(oe.arg)}else oe.method==="return"&&oe.abrupt("return",oe.arg);he=U;var we=O(P,Q,oe);if(we.type==="normal"){if(he=oe.done?z:N,we.arg===j)continue;return{value:we.arg,done:oe.done}}else we.type==="throw"&&(he=z,oe.method="throw",oe.arg=we.arg)}}}function M(P,Q){var oe=Q.method,he=P.iterator[oe];if(he===t)return Q.delegate=null,oe==="throw"&&P.iterator.return&&(Q.method="return",Q.arg=t,M(P,Q),Q.method==="throw")||oe!=="return"&&(Q.method="throw",Q.arg=new TypeError("The iterator does not provide a '"+oe+"' method")),j;var Re=O(he,P.iterator,Q.arg);if(Re.type==="throw")return Q.method="throw",Q.arg=Re.arg,Q.delegate=null,j;var be=Re.arg;if(!be)return Q.method="throw",Q.arg=new TypeError("iterator result is not an object"),Q.delegate=null,j;if(be.done)Q[P.resultName]=be.value,Q.next=P.nextLoc,Q.method!=="return"&&(Q.method="next",Q.arg=t);else return be;return Q.delegate=null,j}V(L),b(L,A,"Generator"),b(L,C,function(){return this}),b(L,"toString",function(){return"[object Generator]"});function te(P){var Q={tryLoc:P[0]};1 in P&&(Q.catchLoc=P[1]),2 in P&&(Q.finallyLoc=P[2],Q.afterLoc=P[3]),this.tryEntries.push(Q)}function se(P){var Q=P.completion||{};Q.type="normal",delete Q.arg,P.completion=Q}function $(P){this.tryEntries=[{tryLoc:"root"}],P.forEach(te,this),this.reset(!0)}a.keys=function(P){var Q=Object(P),oe=[];for(var he in Q)oe.push(he);return oe.reverse(),function Re(){for(;oe.length;){var be=oe.pop();if(be in Q)return Re.value=be,Re.done=!1,Re}return Re.done=!0,Re}};function ne(P){if(P){var Q=P[C];if(Q)return Q.call(P);if(typeof P.next=="function")return P;if(!isNaN(P.length)){var oe=-1,he=function Re(){for(;++oe<P.length;)if(o.call(P,oe))return Re.value=P[oe],Re.done=!1,Re;return Re.value=t,Re.done=!0,Re};return he.next=he}}return{next:ht}}a.values=ne;function ht(){return{value:t,done:!0}}return $.prototype={constructor:$,reset:function(P){if(this.prev=0,this.next=0,this.sent=this._sent=t,this.done=!1,this.delegate=null,this.method="next",this.arg=t,this.tryEntries.forEach(se),!P)for(var Q in this)Q.charAt(0)==="t"&&o.call(this,Q)&&!isNaN(+Q.slice(1))&&(this[Q]=t)},stop:function(){this.done=!0;var P=this.tryEntries[0],Q=P.completion;if(Q.type==="throw")throw Q.arg;return this.rval},dispatchException:function(P){if(this.done)throw P;var Q=this;function oe(xe,we){return be.type="throw",be.arg=P,Q.next=xe,we&&(Q.method="next",Q.arg=t),!!we}for(var he=this.tryEntries.length-1;he>=0;--he){var Re=this.tryEntries[he],be=Re.completion;if(Re.tryLoc==="root")return oe("end");if(Re.tryLoc<=this.prev){var fe=o.call(Re,"catchLoc"),je=o.call(Re,"finallyLoc");if(fe&&je){if(this.prev<Re.catchLoc)return oe(Re.catchLoc,!0);if(this.prev<Re.finallyLoc)return oe(Re.finallyLoc)}else if(fe){if(this.prev<Re.catchLoc)return oe(Re.catchLoc,!0)}else if(je){if(this.prev<Re.finallyLoc)return oe(Re.finallyLoc)}else throw new Error("try statement without catch or finally")}}},abrupt:function(P,Q){for(var oe=this.tryEntries.length-1;oe>=0;--oe){var he=this.tryEntries[oe];if(he.tryLoc<=this.prev&&o.call(he,"finallyLoc")&&this.prev<he.finallyLoc){var Re=he;break}}Re&&(P==="break"||P==="continue")&&Re.tryLoc<=Q&&Q<=Re.finallyLoc&&(Re=null);var be=Re?Re.completion:{};return be.type=P,be.arg=Q,Re?(this.method="next",this.next=Re.finallyLoc,j):this.complete(be)},complete:function(P,Q){if(P.type==="throw")throw P.arg;return P.type==="break"||P.type==="continue"?this.next=P.arg:P.type==="return"?(this.rval=this.arg=P.arg,this.method="return",this.next="end"):P.type==="normal"&&Q&&(this.next=Q),j},finish:function(P){for(var Q=this.tryEntries.length-1;Q>=0;--Q){var oe=this.tryEntries[Q];if(oe.finallyLoc===P)return this.complete(oe.completion,oe.afterLoc),se(oe),j}},catch:function(P){for(var Q=this.tryEntries.length-1;Q>=0;--Q){var oe=this.tryEntries[Q];if(oe.tryLoc===P){var he=oe.completion;if(he.type==="throw"){var Re=he.arg;se(oe)}return Re}}throw new Error("illegal catch attempt")},delegateYield:function(P,Q,oe){return this.delegate={iterator:ne(P),resultName:Q,nextLoc:oe},this.method==="next"&&(this.arg=t),j}},a}(u.exports);try{regeneratorRuntime=n}catch{typeof globalThis=="object"?globalThis.regeneratorRuntime=n:Function("r","regeneratorRuntime = r")(n)}})(Jv);var Rh={exports:{}};(function(u){(function(n,a){u.exports?u.exports=a():n.log=a()})(er,function(){var n=function(){},a="undefined",e=typeof window!==a&&typeof window.navigator!==a&&/Trident\/|MSIE /.test(window.navigator.userAgent),o=["trace","debug","info","warn","error"];function p(N,U){var z=N[U];if(typeof z.bind=="function")return z.bind(N);try{return Function.prototype.bind.call(z,N)}catch{return function(){return Function.prototype.apply.apply(z,[N,arguments])}}}function t(){console.log&&(console.log.apply?console.log.apply(console,arguments):Function.prototype.apply.apply(console.log,[console,arguments])),console.trace&&console.trace()}function v(N){return N==="debug"&&(N="log"),typeof console===a?!1:N==="trace"&&e?t:console[N]!==void 0?p(console,N):console.log!==void 0?p(console,"log"):n}function C(N,U){for(var z=0;z<o.length;z++){var j=o[z];this[j]=z<N?n:this.methodFactory(j,N,U)}this.log=this.debug}function l(N,U,z){return function(){typeof console!==a&&(C.call(this,U,z),this[N].apply(this,arguments))}}function A(N,U,z){return v(N)||l.apply(this,arguments)}function b(N,U,z){var j=this,_e;U=U??"WARN";var k="loglevel";typeof N=="string"?k+=":"+N:typeof N=="symbol"&&(k=void 0);function H(L){var V=(o[L]||"silent").toUpperCase();if(!(typeof window===a||!k)){try{window.localStorage[k]=V;return}catch{}try{window.document.cookie=encodeURIComponent(k)+"="+V+";"}catch{}}}function de(){var L;if(!(typeof window===a||!k)){try{L=window.localStorage[k]}catch{}if(typeof L===a)try{var V=window.document.cookie,G=V.indexOf(encodeURIComponent(k)+"=");G!==-1&&(L=/^([^;]+)/.exec(V.slice(G))[1])}catch{}return j.levels[L]===void 0&&(L=void 0),L}}function Ue(){if(!(typeof window===a||!k)){try{window.localStorage.removeItem(k);return}catch{}try{window.document.cookie=encodeURIComponent(k)+"=; expires=Thu, 01 Jan 1970 00:00:00 UTC"}catch{}}}j.name=N,j.levels={TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,SILENT:5},j.methodFactory=z||A,j.getLevel=function(){return _e},j.setLevel=function(L,V){if(typeof L=="string"&&j.levels[L.toUpperCase()]!==void 0&&(L=j.levels[L.toUpperCase()]),typeof L=="number"&&L>=0&&L<=j.levels.SILENT){if(_e=L,V!==!1&&H(L),C.call(j,L,N),typeof console===a&&L<j.levels.SILENT)return"No console available for logging"}else throw"log.setLevel() called with invalid level: "+L},j.setDefaultLevel=function(L){U=L,de()||j.setLevel(L,!1)},j.resetLevel=function(){j.setLevel(U,!1),Ue()},j.enableAll=function(L){j.setLevel(j.levels.TRACE,L)},j.disableAll=function(L){j.setLevel(j.levels.SILENT,L)};var B=de();B==null&&(B=U),j.setLevel(B,!1)}var E=new b,O={};E.getLogger=function(U){if(typeof U!="symbol"&&typeof U!="string"||U==="")throw new TypeError("You must supply a name when creating a logger.");var z=O[U];return z||(z=O[U]=new b(U,E.getLevel(),E.methodFactory)),z};var w=typeof window!==a?window.log:void 0;return E.noConflict=function(){return typeof window!==a&&window.log===E&&(window.log=w),E},E.getLoggers=function(){return O},E.default=E,E})})(Rh);var Lt=Rh.exports;const yn=()=>`${new Date().toISOString()} | metrics`,Rn=(u,n,a)=>`${u} | ${n} | ${a}`;Lt.setDefaultLevel(Lt.levels.TRACE);const Xv=u=>{Lt.info(Rn(yn(),"log ",`set log level to ${u?"verbose":"info"}`)),Lt.setLevel(u?Lt.levels.TRACE:Lt.levels.INFO)},Qv=u=>{const n=[...Object.keys(Lt.levels)];n.includes(u)?(Lt.info(Rn(yn(),"log ",`update log level to ${u.toLowerCase()}`)),Lt.setLevel(u)):Lt.warn(Rn(yn(),"log ","Incorrect log level please choose one of "),n)},qe=(u,n,a)=>{a?Lt.debug(Rn(yn(),u,n),a):Lt.debug(Rn(yn(),u,n))},ju=(u,n)=>{Lt.info(Rn(yn(),u,n))},hr=(u,n)=>{Lt.info(Rn(yn(),u,n))},ho=(u,n)=>{Lt.warn(Rn(yn(),u,n))},Zr=(u,n)=>{Lt.error(Rn(yn(),u,n))};function Zv(u){return Math.floor(Math.random()*u).toString()}function bh(u,n){let a=n;return u.forEach(e=>{a=a.replace(e,"")}),a}function eT(u,n){let a="";for(let e=0;e<n;e+=1)a+=u[Zv(u.length)];return a}function tT({length:u=20,useLetters:n=!0,useNumbers:a=!0,includeSymbols:e=[],excludeSymbols:o=[]}={}){let p="abcdefghijklmnopqrstuvwxyz",t="0123456789",v=[],C=[],l=[];return n&&(o.length&&(p=bh(o,p)),C=p.split("")),a&&(o.length&&(t=bh(o,t)),l=t.split("")),v=[...C,...l,...e],eT(v,u)}var sT=tT;const zi=Be(sT),nT=()=>"WebRTCMetrics",lT=()=>"5.0.3",Je={INBOUND:"inbound",OUTBOUND:"outbound"},bn={IDLE:"idle",RUNNING:"running",MUTED:"muted"},Ji={NEW:"new",CHECKING:"checking",CONNECTED:"connected",COMPLETED:"completed",DISCONNECTED:"disconnected",FAILED:"failed",CLOSED:"closed"},rT=()=>({...{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:[]}}),Ih={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:Je.INBOUND},wh={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:Je.OUTBOUND},Oh={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:Je.INBOUND},Dh={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:Je.OUTBOUND},iT=u=>{const n={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(u){const a={...u,audio:{},video:{},data:{...u.data},network:{...u.network},experimental:{...u.experimental}};return Object.keys(u.audio).forEach(e=>{a.audio[e]={...u.audio[e]}}),Object.keys(u.video).forEach(e=>{a.video[e]={...u.video[e]}}),a}return{...n,audio:{},video:{},data:{...n.data},network:{...n.network},experimental:{...n.experimental}}},aT={refreshEvery:2e3,startAfter:0,stopAfter:-1,verbose:!1,pname:`p-${zi()}`,cid:`c-${zi()}`,uid:`u-${zi()}`,record:!1,ticket:!0},bs={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"},X={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"},q={SUCCEEDED:"succeeded",AUDIO:"audio",VIDEO:"video"},Xi={ETHERNET:0,CELLULAR_5G:2,WIFI:3,CELLULAR_4G:5,CELLULAR:10},Vu={ETHERNET:"ethernet",CELLULAR_4G:"cellular",WIFI:"wifi"},ce={AUDIO:"audio",VIDEO:"video",NETWORK:"network",DATA:"data"},Bu="config ",oT=(u,n={},a)=>{const e={...a,...n};return n.pname||ho(Bu,`Argument [String] 'cfg.pname' for the peerConnection name or id is missing - use generated '${a.pname}'`),n.cid||ho(Bu,`Argument [String] 'cfg.cid' for the call name or id is missing - use generated '${a.cid}'`),n.uid||ho(Bu,`Argument [String] 'cfg.uid' for the user name or id is missing - use generated '${a.uid}'`),e.pc=u,e},uT=(u={})=>{const n={...aT,...u};return n.name=nT(),n.version=lT(),n},Qi=(u,n,a,e=!1,o)=>{let p=u.map(t=>{if(!a)return t[n];if(!o)return t[n][a];const v=t[n][o];return v?v[a]:null});return p=p.filter(t=>e?Number.isFinite(t)&&t>0:Number.isFinite(t)),p.length===0?[]:p},nl=u=>u.reduce((n,a)=>n+a,0)/u.length,cT=()=>`probe-${zi()}`,fT=()=>`coltr-${zi()}`,Nh=u=>new Promise(n=>setTimeout(n,u)),Gu=(u,n,a)=>{n?u.call(n,a):u(a)},it=(u,n,a,e)=>{const o=Qi(u,n,a,!0,e);if(o.length===0)return null;const p=o.reduce((l,A)=>l+A,0)/o.length;return p===0?null:o.map(l=>Math.abs(p-l)).reduce((l,A)=>l+A,0)/o.length*100/p},ut=(u,n,a,e=!1,o)=>{const p=Qi(u,n,a,e,o);return p.length===0?null:p.reduce((t,v)=>t+v,0)/p.length},_r=(u,n,a)=>Qi(u,n,a).reduce((o,p)=>o+p,0),at=(u,n,a,e)=>{const o=Qi(u,n,a,!0,e);return o.length===0?null:Math.min(...o)},ot=(u,n,a,e)=>{const o=Qi(u,n,a,!1,e);return o.length===0?null:Math.max(...o)},Pt=(u,n,a,e)=>{const o=u.slice().pop();if(!o)return null;if(!a)return o[n];if(!e)return o[n][a];const p=o[n][e];return p?p[a]:null},hT=u=>u.slice().pop(),yt=(u,n,a)=>{if(!n)return null;const e={};let o=n[q.AUDIO][u];o||(o=a===Je.INBOUND?{...Ih}:{...wh}),e[q.AUDIO]=o;let p=n[q.VIDEO][u];return p||(p=a===Je.INBOUND?{...Oh}:{...Dh}),e[q.VIDEO]=p,e},Zi="exporter ",_T="2.0",Uh=(u,n,a)=>{if(!u||u.length===0)return 0;const e=u[u.length-1];if(!e)return 0;const o=e[n][a];if(o){const p=o.total_rtt_ms_out,t=o.total_rtt_measure_out;return!t||!p?ut(u,n,"delta_rtt_ms_out",!1,a):Number(p/t)}return null},dT=(u,n)=>{if(!u||u.length===0)return 0;const a=u[u.length-1];if(!a)return 0;const e=a[n].total_rtt_connectivity_ms,o=a[n].total_rtt_connectivity_measure;return!o||!e?ut(u,n,"delta_rtt_connectivity_ms"):Number(e/o)},pT=u=>Pt(u,"network","local_candidate_type")!=="relay"?`direct/${Pt(u,"network","local_candidate_protocol")}`:`turn/${Pt(u,"network","local_candidate_relay_protocol")}`,mT=u=>{const n=Pt(u,"network","remote_candidate_type"),a=Pt(u,"network","remote_candidate_protocol");return n!=="relay"?`direct/${a}`:`turn/${a}`};class gT{constructor(n){this._start=null,this._end=null,this._cfg=n,this._referenceReport=null,this._reports=[],this._events=[]}start(){ju(Zi,"start() - start exporter...");const n=new Date;return this._start=n.toJSON(),n}stop(){ju(Zi,"stop() - stop exporter...");const n=new Date;return this._end=n.toJSON(),n}saveReferenceReport(n){this._referenceReport=n}getReferenceReport(){return this._referenceReport}addReport(n){this._cfg.ticket&&(qe(Zi,`addReport() - add report to exporter at ${n.timestamp}`),this._reports.push(n))}addCustomEvent(n){this._events.push(n)}reset(){ju(Zi,"resetReports() - reset reports"),this._reports=[],this._referenceReport=null,this._start=null,this._end=null}get ticket(){qe(Zi,"ticket() - generate ticket");const n=Pt(this._reports,"audio","total_packets_lost_in"),a=Pt(this._reports,"audio","total_packets_in"),e=Pt(this._reports,"video","total_packets_lost_in"),o=Pt(this._reports,"video","total_packets_in"),p={},t=hT(this._reports);return t&&(Object.keys(t[q.AUDIO]).forEach(v=>{const C=t[q.AUDIO][v];if(p[C.ssrc]={type:q.AUDIO,direction:C.direction},C.direction===Je.INBOUND){const l={avg:ut(this._reports,q.AUDIO,"delta_jitter_ms_in",!1,v),min:at(this._reports,q.AUDIO,"delta_jitter_ms_in",v),max:ot(this._reports,q.AUDIO,"delta_jitter_ms_in",v),volatility:it(this._reports,q.AUDIO,"delta_jitter_ms_in",v),_unit:{avg:"ms",min:"ms",max:"ms",volatility:"percent"}},A={avg:ut(this._reports,q.AUDIO,"delta_kbs_in",!1,v),min:at(this._reports,q.AUDIO,"delta_kbs_in",v),max:ot(this._reports,q.AUDIO,"delta_kbs_in",v),volatility:it(this._reports,q.AUDIO,"delta_kbs_in",v),_unit:{avg:"kbs",min:"kbs",max:"kbs",volatility:"percent"}},b={avg:ut(this._reports,q.AUDIO,"delta_KBytes_in",!1,v),min:at(this._reports,q.AUDIO,"delta_KBytes_in",v),max:ot(this._reports,q.AUDIO,"delta_KBytes_in",v),volatility:it(this._reports,q.AUDIO,"delta_KBytes_in",v),_unit:{avg:"KB",min:"KB",max:"KB",volatility:"percent"}},E={emodel:{avg:ut(this._reports,q.AUDIO,"mos_emodel_in",!1,v),min:at(this._reports,q.AUDIO,"mos_emodel_in",v),max:ot(this._reports,q.AUDIO,"mos_emodel_in",v),volatility:it(this._reports,q.AUDIO,"mos_emodel_in",v)},effective:{avg:ut(this._reports,q.AUDIO,"mos_in",!1,v),min:at(this._reports,q.AUDIO,"mos_in",v),max:ot(this._reports,q.AUDIO,"mos_in",v),volatility:it(this._reports,q.AUDIO,"mos_in",v)},_unit:{avg:"number (1-5)",min:"number (1-5)",max:"number (1-5)",volatility:"percent"}},O=Pt(this._reports,q.AUDIO,"total_packets_lost_in",v),w=Pt(this._reports,q.AUDIO,"total_packets_in",v),N={lost:O,avg:Math.round((O/(O+w)*100||0)*100)/100,_unit:{avg:"percent",lost:"number"}};p[v].jitter=l,p[v].mos=E,p[v].traffic=b,p[v].bitrate=A,p[v].loss=N}else{const l={avg:ut(this._reports,q.AUDIO,"delta_jitter_ms_out",!1,v),min:at(this._reports,q.AUDIO,"delta_jitter_ms_out",v),max:ot(this._reports,q.AUDIO,"delta_jitter_ms_out",v),volatility:it(this._reports,q.AUDIO,"delta_jitter_ms_out",v),_unit:{avg:"ms",min:"ms",max:"ms",volatility:"percent"}},A={avg:ut(this._reports,q.AUDIO,"delta_kbs_out",!1,v),min:at(this._reports,q.AUDIO,"delta_kbs_out",v),max:ot(this._reports,q.AUDIO,"delta_kbs_out",v),volatility:it(this._reports,q.AUDIO,"delta_kbs_out",v),_unit:{avg:"kbs",min:"kbs",max:"kbs",volatility:"percent"}},b={avg:ut(this._reports,q.AUDIO,"delta_KBytes_out",!1,v),min:at(this._reports,q.AUDIO,"delta_KBytes_out",v),max:ot(this._reports,q.AUDIO,"delta_KBytes_out",v),volatility:it(this._reports,q.AUDIO,"delta_KBytes_out",v),_unit:{avg:"KB",min:"KB",max:"KB",bitrate:"kbs",volatility:"percent"}},E={avg:Uh(this._reports,q.AUDIO,v),min:at(this._reports,q.AUDIO,"delta_rtt_ms_out",v),max:ot(this._reports,q.AUDIO,"delta_rtt_ms_out",v),volatility:it(this._reports,q.AUDIO,"delta_rtt_ms_out",v),_unit:{avg:"ms",min:"ms",max:"ms",volatility:"percent"}},O=Pt(this._reports,q.AUDIO,"total_packets_lost_out",v),w=Pt(this._reports,q.AUDIO,"total_packets_out",v),N={lost:O,avg:Math.round((O/(O+w)*100||0)*100)/100,_unit:{avg:"percent",lost:"number"}},U={emodel:{avg:ut(this._reports,q.AUDIO,"mos_emodel_out",!1,v),min:at(this._reports,q.AUDIO,"mos_emodel_out",v),max:ot(this._reports,q.AUDIO,"mos_emodel_out",v),volatility:it(this._reports,q.AUDIO,"mos_emodel_out",v)},effective:{avg:ut(this._reports,q.AUDIO,"mos_out",!1,v),min:at(this._reports,q.AUDIO,"mos_out",v),max:ot(this._reports,q.AUDIO,"mos_out",v),volatility:it(this._reports,q.AUDIO,"mos_out",v)},_unit:{avg:"number (1-5)",min:"number (1-5)",max:"number (1-5)",volatility:"percent"}};p[v].jitter=l,p[v].rtt=E,p[v].traffic=b,p[v].bitrate=A,p[v].loss=N,p[v].mos=U}}),Object.keys(t[q.VIDEO]).forEach(v=>{const C=t[q.VIDEO][v];if(p[v]={type:q.VIDEO,direction:C.direction},C.direction===Je.INBOUND){const l={avg:ut(this._reports,q.VIDEO,"delta_jitter_ms_in",!1,v),min:at(this._reports,q.VIDEO,"delta_jitter_ms_in",v),max:ot(this._reports,q.VIDEO,"delta_jitter_ms_in",v),volatility:it(this._reports,q.VIDEO,"delta_jitter_ms_in",v),_unit:{avg:"ms",min:"ms",max:"ms",volatility:"percent"}},A={avg:ut(this._reports,q.VIDEO,"delta_kbs_in",!1,v),min:at(this._reports,q.VIDEO,"delta_kbs_in",v),max:ot(this._reports,q.VIDEO,"delta_kbs_in",v),volatility:it(this._reports,q.VIDEO,"delta_kbs_in",v),_unit:{avg:"kbs",min:"kbs",max:"kbs",volatility:"percent"}},b={avg:ut(this._reports,q.VIDEO,"delta_KBytes_in",!1,v),min:at(this._reports,q.VIDEO,"delta_KBytes_in",v),max:ot(this._reports,q.VIDEO,"delta_KBytes_in",v),volatility:it(this._reports,q.VIDEO,"delta_KBytes_in",v),_unit:{avg:"KB",min:"KB",max:"KB",volatility:"percent"}},E=Pt(this._reports,q.VIDEO,"total_packets_lost_in",v),O=Pt(this._reports,q.VIDEO,"total_packets_in",v),w={lost:E,avg:Math.round((E/(E+O)*100||0)*100)/100,_unit:{avg:"percent",lost:"number"}};p[v].jitter=l,p[v].traffic=b,p[v].bitrate=A,p[v].loss=w}else{const l={avg:ut(this._reports,q.VIDEO,"delta_jitter_ms_out",!1,v),min:at(this._reports,q.VIDEO,"delta_jitter_ms_out",v),max:ot(this._reports,q.VIDEO,"delta_jitter_ms_out",v),volatility:it(this._reports,q.VIDEO,"delta_jitter_ms_out",v),_unit:{avg:"ms",min:"ms",max:"ms",volatility:"percent"}},A={avg:ut(this._reports,q.VIDEO,"delta_kbs_out",!1,v),min:at(this._reports,q.VIDEO,"delta_kbs_out",v),max:ot(this._reports,q.VIDEO,"delta_kbs_out",v),volatility:it(this._reports,q.VIDEO,"delta_kbs_out",v),_unit:{avg:"kbs",min:"kbs",max:"kbs",volatility:"percent"}},b={avg:ut(this._reports,q.VIDEO,"delta_KBytes_out",!1,v),min:at(this._reports,q.VIDEO,"delta_KBytes_out",v),max:ot(this._reports,q.VIDEO,"delta_KBytes_out",v),volatility:it(this._reports,q.VIDEO,"delta_KBytes_out",v),_unit:{avg:"KB",min:"KB",max:"KB",volatility:"percent"}},E={avg:Uh(this._reports,q.VIDEO,v),min:at(this._reports,q.VIDEO,"delta_rtt_ms_out",v),max:ot(this._reports,q.VIDEO,"delta_rtt_ms_out",v),volatility:it(this._reports,q.VIDEO,"delta_rtt_ms_out",v),_unit:{avg:"ms",min:"ms",max:"ms",volatility:"percent"}},O=Pt(this._reports,q.VIDEO,"total_packets_lost_out",v),w=Pt(this._reports,q.VIDEO,"total_packets_out",v),N={lost:O,avg:Math.round((O/(O+w)*100||0)*100)/100,_unit:{avg:"percent",lost:"number"}};p[v].jitter=l,p[v].rtt=E,p[v].traffic=b,p[v].bitrate=A,p[v].loss=N}})),{version:_T,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:p,data:{rtt:{avg:dT(this._reports,"data"),min:at(this._reports,"data","delta_rtt_connectivity_ms"),max:ot(this._reports,"data","delta_rtt_connectivity_ms"),volatility:it(this._reports,"data","delta_rtt_connectivity_ms"),_unit:{avg:"ms",min:"ms",max:"ms",volatility:"percent"}},packetsLost:{audio:{in:{avg:Math.round((n/(n+a)*100||0)*100)/100}},video:{in:{avg:Math.round((e/(e+o)*100||0)*100)/100}},unit:{avg:"percent"}},bitrate:{in:{avg:ut(this._reports,"data","delta_kbs_in"),min:at(this._reports,"data","delta_kbs_in"),max:ot(this._reports,"data","delta_kbs_in"),volatility:it(this._reports,"data","delta_kbs_in")},out:{avg:ut(this._reports,"data","delta_kbs_out"),min:at(this._reports,"data","delta_kbs_out"),max:ot(this._reports,"data","delta_kbs_out"),volatility:it(this._reports,"data","delta_kbs_out")},unit:{avg:"kbs",min:"kbs",max:"kbs",volatility:"percent"}},traffic:{in:{avg:ut(this._reports,"data","delta_KBytes_in"),min:at(this._reports,"data","delta_KBytes_in"),max:ot(this._reports,"data","delta_KBytes_in"),volatility:it(this._reports,"data","delta_KBytes_in")},out:{avg:ut(this._reports,"data","delta_KBytes_out"),min:at(this._reports,"data","delta_KBytes_out"),max:ot(this._reports,"data","delta_KBytes_out"),volatility:it(this._reports,"data","delta_KBytes_out")},unit:{avg:"KBytes",min:"KBytes",max:"KBytes",volatility:"percent"}},network:{localConnection:pT(this._reports),remoteConnection:mT(this._reports)}}}}updateConfig(n){this._cfg=n}getLastReport(){return this._reports.slice().pop()||null}getBeforeLastReport(){const n=this._reports.slice();return n.pop(),n.pop()||null}getReportsNumber(){return this._reports.length}}const ll="extractor ",xh=(u,n,a,e)=>{let o=!1;const p=e[n].total_rtt_ms_out,t=e[n].total_rtt_measure_out,v=a?a[n].total_rtt_ms_out:0,C=a?a[n].total_rtt_measure_out:0,l={rtt:null,totalRTT:p,totalRTTMeasurements:t};if(u[X.TIMESTAMP]===e[n].timestamp_out||!Object.prototype.hasOwnProperty.call(u,X.ROUND_TRIP_TIME)||Object.prototype.hasOwnProperty.call(u,X.TOTAL_ROUND_TRIP_TIME_MEASUREMENTS)&&(o=!0,Number(u[X.TOTAL_ROUND_TRIP_TIME_MEASUREMENTS])===0||Number(u[X.TOTAL_ROUND_TRIP_TIME_MEASUREMENTS])-C===t))return l;const A=1e3*Number(u[X.ROUND_TRIP_TIME]);let b=p+A,E=t+1;return o&&(b=1e3*Number(u[X.TOTAL_ROUND_TRIP_TIME])-v,E=Number(u[X.TOTAL_ROUND_TRIP_TIME_MEASUREMENTS])-C),{rtt:A,totalRTT:b,totalRTTMeasurements:E}},vT=(u,n,a,e)=>{if(!Object.prototype.hasOwnProperty.call(u,X.CURRENT_ROUND_TRIP_TIME))return{rtt:null,totalRTT:e[n].total_rtt_connectivity_ms,totalRTTMeasurements:e[n].total_rtt_connectivity_measure};const o=1e3*Number(u[X.CURRENT_ROUND_TRIP_TIME]);let p=e[n].total_rtt_connectivity_ms+o,t=e[n].total_rtt_connectivity_measure+1;return Object.prototype.hasOwnProperty.call(u,X.TOTAL_ROUND_TRIP_TIME)&&(p=1e3*Number(u[X.TOTAL_ROUND_TRIP_TIME])-(a?a[n].total_rtt_connectivity_ms:0)),Object.prototype.hasOwnProperty.call(u,X.RESPONSES_RECEIVED)&&(t=Number(u[X.RESPONSES_RECEIVED])-(a?a[n].total_rtt_connectivity_measure:0)),{rtt:o,totalRTT:p,totalRTTMeasurements:t}},_o=(u,n,a)=>u[X.TIMESTAMP]===a[n].timestamp_out||!Object.prototype.hasOwnProperty.call(u,X.JITTER)?null:1e3*(Number(u[X.JITTER])||0),TT=(u,n)=>{if(!Object.prototype.hasOwnProperty.call(u,X.FRAMES_DECODED)||!Object.prototype.hasOwnProperty.call(u,X.TOTAL_DECODE_TIME))return{delta_ms_decode_frame:n[q.VIDEO].delta_ms_decode_frame_in,frames_decoded:n[q.VIDEO].total_frames_decoded_in,total_decode_time:n[q.VIDEO].total_time_decoded_in};const a=u[X.FRAMES_DECODED],e=u[X.TOTAL_DECODE_TIME],o=e-n[q.VIDEO].total_time_decoded_in,p=a-n[q.VIDEO].total_frames_decoded_in;return{delta_ms_decode_frame:p>0?o*1e3/p:0,frames_decoded:a,total_decode_time:e}},ET=(u,n)=>{if(!Object.prototype.hasOwnProperty.call(u,X.FRAMES_ENCODED)||!Object.prototype.hasOwnProperty.call(u,X.TOTAL_ENCODE_TIME))return{delta_ms_encode_frame:n[q.VIDEO].delta_ms_encode_frame_out,frames_encoded:n[q.VIDEO].total_frames_encoded_out,total_encode_time:n[q.VIDEO].total_time_encoded_out};const a=u[X.FRAMES_ENCODED],e=u[X.TOTAL_ENCODE_TIME],o=e-n[q.VIDEO].total_time_encoded_out,p=a-n[q.VIDEO].total_frames_encoded_out;return{delta_ms_encode_frame:p>0&&o?o*1e3/p:0,frames_encoded:a,total_encode_time:e}},Ph=(u,n,a,e)=>{if(!Object.prototype.hasOwnProperty.call(u,X.PACKETS_SENT)||!Object.prototype.hasOwnProperty.call(u,X.BYTES_SENT))return{packetsSent:a[n].total_packets_out,packetsLost:a[n].total_packets_lost_out,bytesSent:a[n].total_KBytes_out};const o=Number(u[X.PACKETS_SENT])||0-(e?e[n].total_packets_out:0),p=o-a[n].total_packets_out,t=Number(u[X.BYTES_SENT])/1024-(e?e[n].total_KBytes_out:0),v=t-a[n].total_KBytes_out,C=u[X.TIMESTAMP]||Date.now(),l=e?e.timestamp:null;let A=a.timestamp;!A&&l&&(A=l);const b=A?C-A:0,E=b>0?v*.008*1024/b*1e3:0;return{packetsSent:o,deltaPacketsSent:p,KBytesSent:t,deltaKBytesSent:v,kbsSent:E}},Mh=(u,n,a,e)=>{let o=a[n].total_packets_lost_out,p=0,t=0;return Object.prototype.hasOwnProperty.call(u,X.PACKETS_LOST)&&(o=Number(u[X.PACKETS_LOST])||0-(e?e[n].total_packets_lost_out:0),p=o-a[n].total_packets_lost_out),Object.prototype.hasOwnProperty.call(u,X.FRACTION_LOST)&&(t=Number(100*u[X.FRACTION_LOST])),{packetsLost:o,deltaPacketsLost:p,fractionLost:t}},kh=(u,n,a,e)=>{if(!Object.prototype.hasOwnProperty.call(u,X.PACKETS_RECEIVED)||!Object.prototype.hasOwnProperty.call(u,X.PACKETS_LOST)||!Object.prototype.hasOwnProperty.call(u,X.BYTES_RECEIVED))return{percent_packets_lost:a[n].percent_packets_lost_in,packetsReceived:a[n].total_packets_in,packetsLost:a[n].total_packets_lost_in,bytesReceived:a[n].total_KBytes_in};const o=Number(u[X.PACKETS_RECEIVED])||0-(e?e[n].total_packets_in:0),p=Number(u[X.PACKETS_LOST])||0-(e?e[n].total_packets_lost_in:0),t=p-a[n].total_packets_lost_in,v=o-a[n].total_packets_in,C=o!==a[n].total_packets_in?t*100/(t+v):0,l=Number(u[X.BYTES_RECEIVED])/1024-(e?e[n].total_KBytes_in:0),A=l-a[n].total_KBytes_in,b=u[X.TIMESTAMP]||Date.now(),E=e?e.timestamp:null;let O=a.timestamp;!O&&E&&(O=E);const w=O?b-O:0,N=w>0?A*.008*1024/w*1e3:0;return{percentPacketsLost:C,packetsReceived:o,deltaPacketsReceived:v,packetsLost:p,deltaPacketsLost:t,KBytesReceived:l,deltaKBytesReceived:A,kbsReceived:N}},CT=u=>u[X.CANDIDATE_TYPE]!=="relay"?"":u[X.RELAY_PROTOCOL]||"",ST=u=>{if(!Object.prototype.hasOwnProperty.call(u,X.NETWORK_TYPE))return Xi.WIFI;switch(u[X.NETWORK_TYPE]){case Vu.ETHERNET:return Xi.ETHERNET;case Vu.CELLULAR_4G:return Xi.CELLULAR_4G;case Vu.WIFI:return Xi.WIFI;default:return Xi.CELLULAR}},Lh=u=>!Object.prototype.hasOwnProperty.call(u,X.FRAME_HEIGHT)||!Object.prototype.hasOwnProperty.call(u,X.FRAME_WIDTH)?{width:null,height:null,framerate:null}:{width:u[X.FRAME_WIDTH]||null,height:u[X.FRAME_HEIGHT]||null,framerate:u[X.FRAMES_PER_SECOND]},AT=u=>{const n=Object.prototype.hasOwnProperty.call(u,X.QUALITY_LIMITATION_REASON)?u[X.QUALITY_LIMITATION_REASON]:null,a=Object.prototype.hasOwnProperty.call(u,X.QUALITY_LIMITATION_RESOLUTION_CHANGES)?u[X.QUALITY_LIMITATION_RESOLUTION_CHANGES]:null,e=Object.prototype.hasOwnProperty.call(u,X.QUALITY_LIMITATION_DURATIONS)?u[X.QUALITY_LIMITATION_DURATIONS]:null;return e&&Object.keys(e).forEach(o=>{e[o]>1e3&&(e[o]=Number(e[o]/1e3))}),{reason:n,durations:e,resolutionChanges:a}},yT=(u,n,a)=>{if(!Object.prototype.hasOwnProperty.call(u,X.PLI)||!Object.prototype.hasOwnProperty.call(u,X.NACK))return{pliCount:n.total_pli_sent_in,nackCount:n.total_nack_sent_in,deltaPliCount:0,deltaNackCount:0};const e=(u[X.PLI]||0)-(a?a[q.VIDEO].total_pli_sent_in:0),o=(u[X.NACK]||0)-(a?a[q.VIDEO].total_nack_sent_in:0);return{pliCount:e,nackCount:o,deltaPliCount:e-n[q.VIDEO].total_pli_sent_in,deltaNackCount:o-n[q.VIDEO].total_nack_sent_in}},RT=(u,n,a)=>{if(!Object.prototype.hasOwnProperty.call(u,X.PLI)||!Object.prototype.hasOwnProperty.call(u,X.NACK))return{pliCount:n.total_pli_received_out,nackCount:n.total_nack_received_out,deltaPliCount:0,deltaNackCount:0};const e=(u[X.PLI]||0)-(a?a[q.VIDEO].total_pli_received_out:0),o=(u[X.NACK]||0)-(a?a[q.VIDEO].total_nack_received_out:0);return{pliCount:e,nackCount:o,deltaPliCount:e-n[q.VIDEO].total_pli_received_out,deltaNackCount:o-n[q.VIDEO].total_nack_received_out}},bT=u=>({channels:u[X.CHANNELS]||null,clock_rate:u[X.CLOCK_RATE]||null,mime_type:u[X.MIME_TYPE]||null,sdp_fmtp_line:u[X.SDP_FMTP_LINE]||null}),IT=u=>({clock_rate:u[X.CLOCK_RATE]||null,mime_type:u[X.MIME_TYPE]||null}),wT=(u,n,a)=>{const e=(u[X.BYTES_RECEIVED]||0)/1024-(a?a.data.total_KBytes_in:0),o=(u[X.BYTES_SENT]||0)/1024-(a?a.data.total_KBytes_out:0),p=u[X.TIMESTAMP]||Date.now(),t=e-n.data.total_KBytes_in,v=o-n.data.total_KBytes_out,C=a?a.timestamp:null;let l=n.timestamp;!l&&C&&(l=C);const A=l?p-l:0,b=A>0?t*.008*1024/A*1e3:0,E=A>0?v*.008*1024/A*1e3:0;return{total_KBytes_received:e,total_KBytes_sent:o,delta_KBytes_received:t,delta_KBytes_sent:v,kbs_speed_received:b,kbs_speed_sent:E}},OT=u=>{const n=u[X.AVAILABLE_INCOMING_BITRATE]/1024||0,a=u[X.AVAILABLE_OUTGOING_BITRATE]/1024||0;return{kbs_incoming_bandwidth:n,kbs_outgoing_bandwidth:a}},DT=(u,n,a,e)=>{if(!u)return[];switch(u[X.TYPE]){case bs.CANDIDATE_PAIR:let o=!1;if(u[X.NOMINATED]&&u[X.STATE]===q.SUCCEEDED&&(o=!0,qe(ll,`analyze() - got stats ${u[X.TYPE]} for ${a}`,u),X.SELECTED in u&&!u[X.SELECTED]&&(o=!1)),o){const t=u[X.LOCAL_CANDIDATE_ID],v=u[X.REMOTE_CANDIDATE_ID],C=wT(u,n,e),l=OT(u),A=vT(u,"data",e,n);return[{type:ce.NETWORK,value:{local_candidate_id:t}},{type:ce.NETWORK,value:{remote_candidate_id:v}},{type:ce.DATA,value:{total_KBytes_in:C.total_KBytes_received}},{type:ce.DATA,value:{total_KBytes_out:C.total_KBytes_sent}},{type:ce.DATA,value:{delta_KBytes_in:C.delta_KBytes_received}},{type:ce.DATA,value:{delta_KBytes_out:C.delta_KBytes_sent}},{type:ce.DATA,value:{delta_kbs_in:C.kbs_speed_received}},{type:ce.DATA,value:{delta_kbs_out:C.kbs_speed_sent}},{type:ce.DATA,value:{delta_kbs_bandwidth_in:l.kbs_incoming_bandwidth}},{type:ce.DATA,value:{delta_kbs_bandwidth_out:l.kbs_outgoing_bandwidth}},{type:ce.DATA,value:{delta_rtt_connectivity_ms:A.rtt}},{type:ce.DATA,value:{total_rtt_connectivity_ms:A.totalRTT}},{type:ce.DATA,value:{total_rtt_connectivity_measure:A.totalRTTMeasurements}}]}break;case bs.LOCAL_CANDIDATE:if(u[X.ID]===n.network.local_candidate_id)return[{type:ce.NETWORK,value:{infrastructure:ST(u)}},{type:ce.NETWORK,value:{local_candidate_type:u[X.CANDIDATE_TYPE]||""}},{type:ce.NETWORK,value:{local_candidate_protocol:u[X.PROTOCOL]||""}},{type:ce.NETWORK,value:{local_candidate_relay_protocol:CT(u)}}];break;case bs.REMOTE_CANDIDATE:if(u[X.ID]===n.network.remote_candidate_id)return[{type:ce.NETWORK,value:{remote_candidate_type:u[X.CANDIDATE_TYPE]||""}},{type:ce.NETWORK,value:{remote_candidate_protocol:u[X.PROTOCOL]||""}}];break;case bs.INBOUND_RTP:{qe(ll,`analyze() - got stats ${u[X.TYPE]} for ${a}`,u);const t=u[X.SSRC],v=yt(t,n,Je.INBOUND);v&&(v.timestamp=n.timestamp);const C=yt(t,e,Je.INBOUND);if(C&&(C.timestamp=e.timestamp),u[X.MEDIA_TYPE]===q.AUDIO){const l=kh(u,q.AUDIO,v,C),A=_o(u,q.AUDIO,v),b=u[X.CODEC_ID]||"";return[{ssrc:t,type:ce.AUDIO,value:{codec_id_in:b}},{ssrc:t,type:ce.AUDIO,value:{total_packets_in:l.packetsReceived}},{ssrc:t,type:ce.AUDIO,value:{delta_packets_in:l.deltaPacketsReceived}},{ssrc:t,type:ce.AUDIO,value:{total_packets_lost_in:l.packetsLost}},{ssrc:t,type:ce.AUDIO,value:{delta_packets_lost_in:l.deltaPacketsLost}},{ssrc:t,type:ce.AUDIO,value:{percent_packets_lost_in:l.percentPacketsLost}},{ssrc:t,type:ce.AUDIO,value:{total_KBytes_in:l.KBytesReceived}},{ssrc:t,type:ce.AUDIO,value:{delta_KBytes_in:l.deltaKBytesReceived}},{ssrc:t,type:ce.AUDIO,value:{delta_kbs_in:l.kbsReceived}},{ssrc:t,type:ce.AUDIO,value:{delta_jitter_ms_in:A}}]}if(u[X.MEDIA_TYPE]===q.VIDEO){const l=TT(u,v),A=kh(u,q.VIDEO,v,C),b=_o(u,q.VIDEO,v),E=u[X.DECODER_IMPLEMENTATION]||null,O=u[X.CODEC_ID]||null,w=Lh(u),N=yT(u,v,C);return[{ssrc:t,type:ce.VIDEO,value:{codec_id_in:O}},{ssrc:t,type:ce.VIDEO,value:{total_packets_in:A.packetsReceived}},{ssrc:t,type:ce.VIDEO,value:{delta_packets_in:A.deltaPacketsReceived}},{ssrc:t,type:ce.VIDEO,value:{total_packets_lost_in:A.packetsLost}},{ssrc:t,type:ce.VIDEO,value:{delta_packets_lost_in:A.deltaPacketsLost}},{ssrc:t,type:ce.VIDEO,value:{percent_packets_lost_in:A.percentPacketsLost}},{ssrc:t,type:ce.VIDEO,value:{total_KBytes_in:A.KBytesReceived}},{ssrc:t,type:ce.VIDEO,value:{delta_KBytes_in:A.deltaKBytesReceived}},{ssrc:t,type:ce.VIDEO,value:{delta_kbs_in:A.kbsReceived}},{ssrc:t,type:ce.VIDEO,value:{delta_jitter_ms_in:b}},{ssrc:t,type:ce.VIDEO,value:{decoder_in:E}},{ssrc:t,type:ce.VIDEO,value:{delta_ms_decode_frame_in:l.delta_ms_decode_frame}},{ssrc:t,type:ce.VIDEO,value:{total_frames_decoded_in:l.frames_decoded}},{ssrc:t,type:ce.VIDEO,value:{total_time_decoded_in:l.total_decode_time}},{ssrc:t,type:ce.VIDEO,value:{total_nack_sent_in:N.nackCount}},{ssrc:t,type:ce.VIDEO,value:{delta_nack_sent_in:N.deltaNackCount}},{ssrc:t,type:ce.VIDEO,value:{total_pli_sent_in:N.pliCount}},{ssrc:t,type:ce.VIDEO,value:{delta_pli_sent_in:N.deltaPliCount}},{ssrc:t,type:ce.VIDEO,value:{size_in:w}}]}break}case bs.OUTBOUND_RTP:{qe(ll,`analyze() - got stats ${u[X.TYPE]} for ${a}`,u);const t=u[X.SSRC],v=yt(t,n,Je.OUTBOUND);v&&(v.timestamp=n.timestamp);const C=yt(t,e,Je.OUTBOUND);if(C&&(C.timestamp=e.timestamp),u[X.MEDIA_TYPE]===q.AUDIO){const l=u[X.CODEC_ID]||null,A=Ph(u,q.AUDIO,v,C);return[{ssrc:t,type:ce.AUDIO,value:{codec_id_out:l}},{ssrc:t,type:ce.AUDIO,value:{total_packets_out:A.packetsSent}},{ssrc:t,type:ce.AUDIO,value:{delta_packets_out:A.deltaPacketsSent}},{ssrc:t,type:ce.AUDIO,value:{total_KBytes_out:A.KBytesSent}},{ssrc:t,type:ce.AUDIO,value:{delta_KBytes_out:A.deltaKBytesSent}},{ssrc:t,type:ce.AUDIO,value:{delta_kbs_out:A.kbsSent}}]}if(u[X.MEDIA_TYPE]===q.VIDEO){const l=u[X.ENCODER_IMPLEMENTATION]||null,A=u[X.CODEC_ID]||null,b=ET(u,v),E=Lh(u),O=AT(u),w=RT(u,v,C),N=Ph(u,q.VIDEO,v,C);return[{ssrc:t,type:ce.VIDEO,value:{codec_id_out:A}},{ssrc:t,type:ce.VIDEO,value:{total_packets_out:N.packetsSent}},{ssrc:t,type:ce.VIDEO,value:{delta_packets_out:N.deltaPacketsSent}},{ssrc:t,type:ce.VIDEO,value:{total_KBytes_out:N.KBytesSent}},{ssrc:t,type:ce.VIDEO,value:{delta_KBytes_out:N.deltaKBytesSent}},{ssrc:t,type:ce.VIDEO,value:{delta_kbs_out:N.kbsSent}},{ssrc:t,type:ce.VIDEO,value:{encoder_out:l}},{ssrc:t,type:ce.VIDEO,value:{delta_ms_encode_frame_out:b.delta_ms_encode_frame}},{ssrc:t,type:ce.VIDEO,value:{total_frames_encoded_out:b.frames_encoded}},{ssrc:t,type:ce.VIDEO,value:{total_time_encoded_out:b.total_encode_time}},{ssrc:t,type:ce.VIDEO,value:{total_nack_received_out:w.nackCount}},{ssrc:t,type:ce.VIDEO,value:{delta_nack_received_out:w.deltaNackCount}},{ssrc:t,type:ce.VIDEO,value:{total_pli_received_out:w.pliCount}},{ssrc:t,type:ce.VIDEO,value:{delta_pli_received_out:w.deltaPliCount}},{ssrc:t,type:ce.VIDEO,value:{size_out:E}},{ssrc:t,type:ce.VIDEO,value:{limitation_out:O}}]}break}case bs.MEDIA_SOURCE:{qe(ll,`analyze() - got stats ${u[X.TYPE]} for ${a}`,u);break}case bs.TRACK:{qe(ll,`analyze() - got stats ${u[X.TYPE]} for ${a}`,u);break}case bs.CODEC:const p=[];return Object.keys(n[q.AUDIO]).forEach(t=>{const v=n[q.AUDIO][t];if(v.codec_id_in===u[X.ID]||v.codec_id_out===u[X.ID]){qe(ll,`analyze() - got stats ${u[X.TYPE]} for ${a}`,u);const C=bT(u);u[X.ID]===v.codec_id_in?p.push({ssrc:v.ssrc,type:ce.AUDIO,value:{codec_in:C}}):p.push({ssrc:v.ssrc,type:ce.AUDIO,value:{codec_out:C}})}}),Object.keys(n[q.VIDEO]).forEach(t=>{const v=n[q.VIDEO][t];if(v.codec_id_in===u[X.ID]||v.codec_id_out===u[X.ID]){qe(ll,`analyze() - got stats ${u[X.TYPE]} for ${a}`,u);const C=IT(u);u[X.ID]===v.codec_id_in?p.push({ssrc:v.ssrc,type:ce.VIDEO,value:{codec_in:C}}):p.push({ssrc:v.ssrc,type:ce.VIDEO,value:{codec_out:C}})}}),p;case bs.REMOTE_INBOUND_RTP:{qe(ll,`analyze() - got stats ${u[X.TYPE]} for ${a}`,u);const t=u[X.SSRC],v=yt(t,n,Je.OUTBOUND),C=yt(t,e,Je.OUTBOUND);if(u[X.KIND]===q.AUDIO){const l=xh(u,q.AUDIO,C,v),A=_o(u,q.AUDIO,v),b=Mh(u,q.AUDIO,v,C);return[{ssrc:t,type:ce.AUDIO,value:{delta_rtt_ms_out:l.rtt}},{ssrc:t,type:ce.AUDIO,value:{total_rtt_ms_out:l.totalRTT}},{ssrc:t,type:ce.AUDIO,value:{total_rtt_measure_out:l.totalRTTMeasurements}},{ssrc:t,type:ce.AUDIO,value:{delta_jitter_ms_out:A}},{ssrc:t,type:ce.AUDIO,value:{timestamp_out:u[X.TIMESTAMP]}},{ssrc:t,type:ce.AUDIO,value:{total_packets_lost_out:b.packetsLost}},{ssrc:t,type:ce.AUDIO,value:{delta_packets_lost_out:b.deltaPacketsLost}},{ssrc:t,type:ce.AUDIO,value:{percent_packets_lost_out:b.fractionLost}}]}if(u[X.KIND]===q.VIDEO){const l=xh(u,q.VIDEO,C,v),A=_o(u,q.VIDEO,v),b=Mh(u,q.VIDEO,v,C);return[{ssrc:t,type:ce.VIDEO,value:{delta_rtt_ms_out:l.rtt}},{ssrc:t,type:ce.VIDEO,value:{total_rtt_ms_out:l.totalRTT}},{ssrc:t,type:ce.VIDEO,value:{total_rtt_measure_out:l.totalRTTMeasurements}},{ssrc:t,type:ce.VIDEO,value:{delta_jitter_ms_out:A}},{ssrc:t,type:ce.VIDEO,value:{timestamp_out:u[X.TIMESTAMP]}},{ssrc:t,type:ce.VIDEO,value:{total_packets_lost_out:b.packetsLost}},{ssrc:t,type:ce.VIDEO,value:{delta_packets_lost_out:b.deltaPacketsLost}},{ssrc:t,type:ce.VIDEO,value:{percent_packets_lost_out:b.fractionLost}}]}break}}return[]},po=u=>u<0?1:u>100?4.5:1+.035*u+7/1e6*u*(u-60)*(100-u),NT=(u,n=q.AUDIO,a,e,o)=>{const p=yt(o,u,Je.INBOUND),t=yt(o,a,Je.INBOUND),v=yt(o,e,Je.INBOUND),C=[],l=[],A=p[n].percent_packets_lost_in,b=p[n].delta_jitter_ms_in,E=t&&t[n].delta_jitter_ms_in||null,O=v&&v[n].delta_jitter_ms_in||null,w=u.data.delta_rtt_connectivity_ms,N=a&&a.data.delta_rtt_connectivity_ms||null,U=e&&e.data.delta_rtt_connectivity_ms||null;w&&C.push(w),N&&C.push(N),U&&C.push(U),b&&l.push(b),a&&E&&l.push(E),e&&O&&l.push(O);const z=C.length>0?nl(C):100,j=l.length>0?nl(l):10,_e=93.2-A,k=.18*_e*_e-27.9*_e+1126.62,H=(z+j)/2,de=H-177.3<0?0:1,Ue=.024*H+.11*(H-177.3)*de,B=k-Ue;return po(B)},UT=(u,n=q.AUDIO,a,e,o)=>{const p=yt(o,u,Je.OUTBOUND),t=yt(o,a,Je.OUTBOUND),v=yt(o,e,Je.OUTBOUND),C=[],l=[],A=p[n].percent_packets_lost_out,b=p[n].delta_rtt_ms_out,E=t&&t[n].delta_rtt_ms_out||null,O=v&&v[n].delta_rtt_ms_out||null,w=p[n].delta_jitter_ms_out,N=t&&t[n].delta_jitter_ms_out||null,U=v&&v[n].delta_jitter_ms_out||null,z=u.data.delta_rtt_connectivity_ms,j=a&&a.data.delta_rtt_connectivity_ms||null,_e=e&&e.data.delta_rtt_connectivity_ms||null;b?C.push(b):z&&C.push(z),E?C.push(E):j&&C.push(j),O?C.push(O):_e&&C.push(_e),w&&l.push(w),a&&N&&l.push(N),e&&U&&l.push(U);const k=C.length>0?nl(C):100,H=l.length>0?nl(l):10,de=93.2-A,Ue=.18*de*de-27.9*de+1126.62,B=(k+H)/2,L=B-177.3<0?0:1,V=.024*B+.11*(B-177.3)*L,G=Ue-V;return po(G)},xT=(u,n=q.AUDIO,a,e,o)=>{const p=yt(o,u,Je.INBOUND),t=yt(o,a,Je.INBOUND),v=yt(o,e,Je.INBOUND),C=[],l=[],A=p[n].percent_packets_lost_in/100,b=p[n].delta_jitter_ms_in,E=t&&t[n].delta_jitter_ms_in||null,O=v&&v[n].delta_jitter_ms_in||null,w=u.data.delta_rtt_connectivity_ms,N=a&&a.data.delta_rtt_connectivity_ms||null,U=e&&e.data.delta_rtt_connectivity_ms||null;w&&C.push(w),N&&C.push(N),U&&C.push(U),b&&l.push(b),t&&E&&l.push(E),v&&O&&l.push(O);const z=C.length>0?nl(C):100,j=l.length>0?nl(l):10,_e=0,k=19.8,H=29.7,de=30,Ue=(z+j)/2+de,B=Ue-177.3<0?0:1,L=.024*Ue+.11*(Ue-177.3)*B,G=93.2-(_e+k*Math.log(1+H*A)+L);return po(G)},PT=(u,n=q.AUDIO,a,e,o)=>{const p=yt(o,u,Je.OUTBOUND),t=yt(o,a,Je.OUTBOUND),v=yt(o,e,Je.OUTBOUND),C=[],l=[],A=p[n].percent_packets_lost_out/100,b=p[n].delta_rtt_ms_out,E=t&&t[n].delta_rtt_ms_out||null,O=v&&v[n].delta_rtt_ms_out||null,w=p[n].delta_jitter_ms_out,N=t&&t[n].delta_jitter_ms_out||null,U=v&&v[n].delta_jitter_ms_out||null,z=u.data.delta_rtt_connectivity_ms,j=a&&a.data.delta_rtt_connectivity_ms||null,_e=e&&e.data.delta_rtt_connectivity_ms||null;b?C.push(b):z&&C.push(z),E?C.push(E):j&&C.push(j),O?C.push(O):_e&&C.push(_e),w&&l.push(w),t&&N&&l.push(N),v&&U&&l.push(U);const k=C.length>0?nl(C):100,H=l.length>0?nl(l):10,de=0,Ue=19.8,B=29.7,L=30,V=(k+H)/2+L,G=V-177.3<0?0:1,K=.024*V+.11*(V-177.3)*G,te=93.2-(de+Ue*Math.log(1+B*A)+K);return po(te)};class MT{constructor(n,a){this._callbacks={onreport:null,onticket:null},this._id=fT(),this._moduleName=this._id,this._probeId=a,this._config=n,this._exporter=new gT(n),this._state=bn.IDLE,this.registerToPCEvents(),hr(this._moduleName,`new collector created for probe ${this._probeId}`)}analyze(n,a,e,o){const p=(C,l)=>C===q.AUDIO?l===bs.INBOUND_RTP?{...Ih}:{...wh}:l===bs.INBOUND_RTP?{...Oh}:{...Dh},t=iT(a);t.pname=this._config.pname,t.call_id=this._config.cid,t.user_id=this._config.uid,t.count=a?a.count+1:1;let v=null;return n.forEach(C=>{!v&&C.timestamp&&(v=C.timestamp),DT(C,t,t.pname,o).forEach(A=>{if(A.value&&A.type)if(A.ssrc){let b=t[A.type][A.ssrc];b||(b=p(A.type,C.type),b.ssrc=A.ssrc,t[A.type][A.ssrc]=b),Object.keys(A.value).forEach(E=>{b[E]=A.value[E]})}else Object.keys(A.value).forEach(b=>{t[A.type][b]=A.value[b]})})}),t.timestamp=v,Object.keys(t[q.AUDIO]).forEach(C=>{const l=t[q.AUDIO][C];l.direction===Je.INBOUND?(l.mos_emodel_in=NT(t,q.AUDIO,a,e,l.ssrc),l.mos_in=xT(t,q.AUDIO,a,e,l.ssrc)):(l.mos_emodel_out=UT(t,q.AUDIO,a,e,l.ssrc),l.mos_out=PT(t,q.AUDIO,a,e,l.ssrc))}),t}async takeReferenceStats(){return new Promise((n,a)=>{const e=Date.now();setTimeout(async()=>{try{const o=Date.now()-e,p=Date.now(),t=await this._config.pc.getStats(),v=this.analyze(t,null,null,null),C=Date.now();v.experimental.time_to_measure_ms=C-p,v.experimental.time_to_wait_ms=o,this._exporter.saveReferenceReport(v),qe(this._moduleName,`got reference report for probe ${this._probeId}`),n()}catch(o){a(o)}},this._config.startAfter)})}async collectStats(){try{if(this._state!==bn.RUNNING||!this._config.pc)return qe(this._moduleName,`report discarded (too late) for probe ${this._probeId}`),null;const n=Date.now(),a=await this._config.pc.getStats(),e=this.analyze(a,this._exporter.getLastReport(),this._exporter.getBeforeLastReport(),this._exporter.getReferenceReport()),o=Date.now();return e.experimental.time_to_measure_ms=o-n,this._exporter.addReport(e),qe(this._moduleName,`got report for probe ${this._probeId}#${this._exporter.getReportsNumber()+1}`),this.fireOnReport(e),e}catch(n){return Zr(this._moduleName,`got error ${n}`),null}}async start(){qe(this._moduleName,"starting"),this.state=bn.RUNNING,this._startedTime=this._exporter.start(),qe(this._moduleName,"started")}async mute(){this.state=bn.MUTED,qe(this._moduleName,"muted")}async unmute(){this.state=bn.RUNNING,qe(this._moduleName,"unmuted")}async stop(n){if(qe(this._moduleName,`stopping${n?" by watchdog":""}...`),this._stoppedTime=this._exporter.stop(),this.state=bn.IDLE,this._config.ticket){const{ticket:a}=this._exporter;this.fireOnTicket(a)}this._exporter.reset(),qe(this._moduleName,"stopped")}registerCallback(n,a,e){n in this._callbacks?(this._callbacks[n]={callback:a,context:e},qe(this._moduleName,`registered callback '${n}'`)):Zr(this._moduleName,`can't register callback for '${n}' - not found`)}unregisterCallback(n){n in this._callbacks?(this._callbacks[n]=null,delete this._callbacks[n],qe(this._moduleName,`unregistered callback '${n}'`)):Zr(this._moduleName,`can't unregister callback for '${n}' - not found`)}fireOnReport(n){this._callbacks.onreport&&Gu(this._callbacks.onreport.callback,this._callbacks.onreport.context,n)}fireOnTicket(n){this._callbacks.onticket&&Gu(this._callbacks.onticket.callback,this._callbacks.onticket.context,n)}updateConfig(n){this._config=n,this._exporter.updateConfig(n)}get state(){return this._state}set state(n){this._state=n,qe(this._moduleName,`state changed to ${n}`)}addCustomEvent(n,a,e,o){this._exporter.addCustomEvent({at:typeof n=="object"?n.toJSON():n,category:a,name:e,description:o})}async registerToPCEvents(){const{pc:n}=this._config;if(navigator.mediaDevices.ondevicechange=async()=>{try{const a=await navigator.mediaDevices.enumerateDevices();this.addCustomEvent(new Date().toJSON(),"device",`${a.length} devices found`,"Media Devices state")}catch{Zr(this._moduleName,"can't get devices")}},n){n.oniceconnectionstatechange=()=>{const e=n.iceConnectionState;e===Ji.CONNECTED||e===Ji.COMPLETED?this.addCustomEvent(new Date().toJSON(),"call",e,"ICE connection state"):e===Ji.DISCONNECTED||e===Ji.FAILED?this.addCustomEvent(new Date().toJSON(),"call",e,"ICE connection state"):e===Ji.CLOSED&&this.addCustomEvent(new Date().toJSON(),"call","ended","ICE connection state")},n.onicegatheringstatechange=()=>{const e=n.iceGatheringState;this.addCustomEvent(new Date().toJSON(),"call",e,"ICE gathering state")},n.ontrack=e=>{this.addCustomEvent(new Date().toJSON(),"call",`${e.track.kind}track`,"MediaStreamTrack received")},n.onnegotiationneeded=()=>{this.addCustomEvent(new Date().toJSON(),"call","negotiation","Media changed")};const a=n.getReceivers();if(a&&a.length>0){const e=a[0],{transport:o}=e;if(o){const{iceTransport:p}=o;p&&(p.onselectedcandidatepairchange=()=>{this.addCustomEvent(new Date().toJSON(),"call","transport","Candidates Pair changed")})}}}}}class kT{constructor(n){this._id=n.pname&&n.pname.substr(0,12).padEnd(12," ")||cT(),this._moduleName=this._id,hr(this._moduleName,"probe created"),this._config=n,this._collector=new MT(this._config,this._id)}set onreport(n){n?this._collector.registerCallback("onreport",n):this._collector.unregisterCallback("onreport")}set onticket(n){n?this._collector.registerCallback("onticket",n):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(n){this._collector.state=n}addCustomEvent(n,a,e,o=new Date().toJSON()){this._collector.addCustomEvent(o,a,n,e)}get isRunning(){return this._collector.state===bn.RUNNING}get isIdle(){return this._collector.state===bn.IDLE}updateUserId(n){this._config.uid=n,this._collector.updateConfig(this._config)}updateCallId(n){this._config.cid=n,this._collector.updateConfig(this._config)}start(){if(!this.isIdle){ho(this._moduleName,"probe is already running");return}this._collector.start()}stop(n=!1){this.isRunning&&this._collector.stop(n)}async takeReferenceStats(){return this._collector.takeReferenceStats()}async collectStats(){return this._collector.collectStats()}}const $t="engine ";class LT{constructor(n){this._config=n,this._probes=[],this._startedTime=null,this._callbacks={onresult:null},hr($t,`configured for probing every ${this._config.refreshEvery}ms`),hr($t,`configured for starting after ${this._config.startAfter}ms`),hr($t,`${!this._config.stopAfter||this._config.stopAfter!==-1?`configured for stopped after ${this._config.stopAfter}ms`:"configured for never stopped"}`),qe($t,"engine initialized")}get probes(){return this._probes}get isRunning(){return this._probes.some(n=>n.isRunning)}get isIdle(){return this._probes.every(n=>n.isIdle)}addNewProbe(n,a){if(!n)throw new Error("undefined peer connection");const e=oT(n,a,this._config),o=new kT(e);return this._probes.push(o),qe($t,`${this._probes.length} probes registered`),o}removeExistingProbe(n){if(!n)throw new Error("undefined probe");n.state===bn.RUNNING&&n.stop(),this._probes=this._probes.filter(a=>n.id!==a.id)}async start(){const n=()=>{this._probes.forEach(p=>p.start())},a=async()=>Promise.all(this._probes.map(p=>p.takeReferenceStats())),e=()=>this.isIdle?!1:!this._config.stopAfter||this._config.stopAfter<0?!0:Date.now()<this._startedTime+this._config.stopAfter,o=async()=>{const p=rT(),t=this._probes.filter(v=>v.isRunning);for(const v of t){const C=await v.collectStats();C&&p.probes.push(C),qe($t,`got probe ${v.id}`),await Nh(0)}return p.delta_time_to_measure_probes_ms=_r(p.probes,"experimental","time_to_measure_ms"),p.delta_KBytes_in=_r(p.probes,"data","delta_KBytes_in"),p.delta_KBytes_out=_r(p.probes,"data","delta_KBytes_out"),p.delta_kbs_in=_r(p.probes,"data","delta_kbs_in"),p.delta_kbs_out=_r(p.probes,"data","delta_kbs_out"),p.total_time_decoded_in=_r(p.probes,"video","total_time_decoded_in"),p.total_time_encoded_out=_r(p.probes,"video","total_time_encoded_out"),p};for(qe($t,"starting to collect"),n(),qe($t,"generating reference reports..."),await a(),qe($t,"reference reports generated"),this._startedTime=Date.now();e();)if(qe($t,`wait ${this._config.refreshEvery}ms before collecting`),await Nh(this._config.refreshEvery),e()){qe($t,"collecting...");const p=Date.now(),t=await o(),v=Date.now();t.delta_time_consumed_to_measure_ms=v-p,this.fireOnReports(t),qe($t,"collected")}qe($t,"reaching end of the collecting period..."),this.isRunning&&setTimeout(()=>{this.stop()},0)}stop(n){const a=e=>{this._probes.forEach(o=>{o.stop(e)})};hr($t,"stop collecting"),a(n)}registerCallback(n,a,e){n in this._callbacks?(this._callbacks[n]={callback:a,context:e},qe($t,`registered callback '${n}'`)):Zr($t,`can't register callback for '${n}' - not found`)}unregisterCallback(n){n in this._callbacks?(this._callbacks[n]=null,delete this._callbacks[n],qe(this._moduleName,`unregistered callback '${n}'`)):Zr(this._moduleName,`can't unregister callback for '${n}' - not found`)}fireOnReports(n){this._callbacks.onresult&&n.probes.length>0&&Gu(this._callbacks.onresult.callback,this._callbacks.onresult.context,n)}}const $T="interface ";class HT{constructor(n){this._config=uT(n),hr($T,`welcome to ${this._config.name} version ${this._config.version}`),Xv(this._config.verbose||!1),this._engine=new LT(this._config)}setupLogLevel(n){Qv(n)}get version(){return this._config.version}get name(){return this._config.name}get probes(){return this._engine.probes}createProbe(n,a){return this._engine.addNewProbe(n,a)}startAllProbes(){this._engine.start()}stopAllProbes(){this._engine.stop()}get running(){return this._engine.isRunning}get idle(){return this._engine.isIdle}removeProbe(n){this._engine.removeExistingProbe(n)}set onresult(n){n?this._engine.registerCallback("onresult",n):this._engine.unregisterCallback("onresult")}}function FT(u,n){return Object.keys(u).filter(a=>n.includes(a)).reduce((a,e)=>{const o=e;return{...a,[o]:u[o]}},{})}const qT=["mos_in","codec_in","delta_KBytes_in","delta_kbs_in","delta_jitter_ms_in","delta_packets_lost_in"];class jT{constructor(n){this.intervals={},this.emitInterval=n.emitInterval||200,this.onChangeFunction=n.onChangeFunction}start(n,a){n&&n.getTracks().length&&requestAnimationFrame(()=>this.beginCalculation(n,a))}stop(n){this.clearVolumeInterval(n)}clearVolumeInterval(n){console.log("clearVolumeInterval",n),clearInterval(this.intervals[n]),delete this.intervals[n]}clearAllIntervals(){Object.keys(this.intervals).forEach(n=>{clearInterval(this.intervals[n])}),this.intervals={}}beginCalculation(n,a){this.clearVolumeInterval(a);const e=fr.createAnalyser(),o=fr.createMediaStreamSource(n),p=fr.createScriptProcessor(2048,1,1);e.smoothingTimeConstant=.8,e.fftSize=1024,o.connect(e),e.connect(p),p.connect(fr.destination),this.intervals[a]=setInterval(()=>{const t=new Uint8Array(e.frequencyBinCount);e.getByteFrequencyData(t);let v=0;const C=t.length;for(let A=0;A<C;A++)v+=t[A];const l=v/C;this.onChangeFunction(a,l)},this.emitInterval)}}const mo={SELECTED_INPUT_DEVICE:"OpensipsJSInputDevice",SELECTED_OUTPUT_DEVICE:"OpensipsJSOutputDevice"},VT=0;class BT{constructor(n){this.isAutoAnswer=!1,this.muteWhenJoinEnabled=!1,this.isDNDEnabled=!1,this.muted=!1,this.microphoneInputLevelValue=1,this.speakerVolumeValue=1,this.activeRooms={},this.activeCalls={},this.extendedCalls={},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.context=n,this.context.on(this.context.newRTCSessionEventName,this.newRTCSessionCallback.bind(this)),this.VUMeter=new jT({onChangeFunction:this.emitVolumeChange.bind(this)}),this.initializeMediaDevices()}get sipOptions(){return{...this.context.options.sipOptions,mediaConstraints:this.getUserMediaConstraints}}get currentActiveRoomId(){return this.currentActiveRoomIdValue}set currentActiveRoomId(n){this.currentActiveRoomIdValue=n,this.context.emit("currentActiveRoomChanged",n)}get autoAnswer(){return this.isAutoAnswer}get callAddingInProgress(){return this.isCallAddingInProgress}set callAddingInProgress(n){this.isCallAddingInProgress=n,this.context.emit("callAddingInProgressChanged",n)}get muteWhenJoin(){return this.muteWhenJoinEnabled}get isDND(){return this.isDNDEnabled}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 getActiveRooms(){return this.activeRooms}get isMuted(){return this.muted}get getInputDeviceList(){return this.availableMediaDevices.filter(n=>n.kind==="audioinput")}get getOutputDeviceList(){return this.availableMediaDevices.filter(n=>n.kind==="audiooutput")}get getUserMediaConstraints(){return Ah()?{video:!1,audio:!0}:{audio:{deviceId:{exact:this.selectedMediaDevices.input}},video:!1}}get selectedInputDevice(){return this.selectedMediaDevices.input}get selectedOutputDevice(){return this.selectedMediaDevices.output}get activeStream(){return this.activeStreamValue}setAvailableMediaDevices(n){this.availableMediaDevices=n,this.context.emit("changeAvailableDeviceList",n)}async updateDeviceList(){await navigator.mediaDevices.getUserMedia(this.getUserMediaConstraints);const n=await navigator.mediaDevices.enumerateDevices();this.setAvailableMediaDevices(n)}async initializeMediaDevices(){const n=localStorage.getItem(mo.SELECTED_INPUT_DEVICE)||"default",a=localStorage.getItem(mo.SELECTED_OUTPUT_DEVICE)||"default";try{const e=await navigator.mediaDevices.getUserMedia(this.getUserMediaConstraints),o=await navigator.mediaDevices.enumerateDevices();this.setAvailableMediaDevices(o),await this.setMicrophone(n),await this.setSpeaker(a),navigator.mediaDevices.addEventListener("devicechange",async()=>{const p=await navigator.mediaDevices.enumerateDevices();this.setAvailableMediaDevices(p)}),e.getTracks().forEach(p=>p.stop())}catch(e){console.error(e)}}setCallTime(n){const a={...n};delete a.callId,this.callTime={...this.callTime,[n.callId]:a},this.context.emit("changeCallTime",this.callTime)}removeCallTime(n){const a={...this.callTime};delete a[n],this.callTime={...a},this.context.emit("changeCallTime",this.callTime)}setTimeInterval(n,a){this.timeIntervals={...this.timeIntervals,[n]:a}}removeTimeInterval(n){const a={...this.timeIntervals};a[n]&&(clearInterval(a[n]),delete a[n],this.timeIntervals={...a})}stopCallTimer(n){this.removeTimeInterval(n),this.removeCallTime(n)}emitVolumeChange(n,a){this.context.emit("changeCallVolume",{callId:n,volume:a})}setMetricsConfig(n){this.metricConfig={...this.metricConfig,...n}}sendDTMF(n,a){if(!/^[A-D0-9]+$/g.test(a))throw new Error("Not allowed character in DTMF input");this.extendedCalls[n].sendDTMF(a)}setIsMuted(n){this.muted=n,this.context.emit("changeIsMuted",n)}processMute(n){const a=this.currentActiveRoomId;this.setIsMuted(n),this.initialStreamValue.getTracks().forEach(e=>e.enabled=!n),this.roomReconfigure(a)}mute(){this.processMute(!0)}unmute(){this.processMute(!1)}async processHold({callId:n,toHold:a,automatic:e}){const o=this.extendedCalls[n];o._automaticHold=e??!1,await new Promise(v=>{const C=()=>{v()};a?o.hold({},C):o.unhold({},C)}),this.updateCall(o);const t=Object.values(this.extendedCalls).filter(v=>v.roomId===this.currentActiveRoomId&&(a?n!==v._id:!0));t.length>1&&await this.doConference(t)}holdCall(n,a=!1){return this.processHold({callId:n,automatic:a,toHold:!0})}unholdCall(n){return this.processHold({callId:n,toHold:!1})}cancelAllOutgoingUnanswered(){Object.values(this.getActiveCalls).filter(n=>n.direction==="outgoing"&&n.status===VT).forEach(n=>this.terminateCall(n._id))}answerCall(n){const a=this.extendedCalls[n];this.cancelAllOutgoingUnanswered(),a.answer(this.sipOptions),this.updateCall(a),this.setActiveRoom(a.roomId),a.connection.addEventListener("track",e=>{this.triggerAddStream(e,a)})}async moveCall(n,a){this.updateCallStatus({callId:n,isMoving:!0}),await this.processRoomChange({callId:n,roomId:a}),this.updateCallStatus({callId:n,isMoving:!1})}updateCall(n){this.activeCalls[n._id]=Eh(n),this.context.emit("changeActiveCalls",this.activeCalls)}updateRoom(n){const e={...this.activeRooms[n.roomId],...n};this.activeRooms={...this.activeRooms,[n.roomId]:{...e}},this.context.emit("updateRoom",{room:e,roomList:this.activeRooms})}hasAutoAnswerHeaders(n){const a=/answer-after=0/,o=n.request.getHeader("Call-Info");return o&&a.test(o)}addCall(n,a=!0){this.activeCalls={...this.activeCalls,[n._id]:Eh(n)},this.extendedCalls[n._id]=n,a&&this.context.emit("changeActiveCalls",this.activeCalls)}addCallStatus(n){this.callStatus={...this.callStatus,[n]:{isMoving:!1,isTransferring:!1,isMerging:!1}},this.context.emit("changeCallStatus",this.callStatus)}updateCallStatus(n){const e={...{...this.callStatus[n.callId]}};n.isMoving!==void 0&&(e.isMoving=n.isMoving),n.isTransferring!==void 0&&(e.isTransferring=n.isTransferring),n.isMerging!==void 0&&(e.isMerging=n.isMerging),this.callStatus={...this.callStatus,[n.callId]:{...e}},this.context.emit("changeCallStatus",this.callStatus)}removeCallStatus(n){const a={...this.callStatus};delete a[n],this.callStatus={...a},this.context.emit("changeCallStatus",this.callStatus)}addRoom(n){this.activeRooms={...this.activeRooms,[n.roomId]:n},this.context.emit("addRoom",{room:n,roomList:this.activeRooms})}getActiveStream(){const n=Sh(this.initialStreamValue,this.microphoneInputLevel*2);return n.getTracks().forEach(a=>a.enabled=!this.isMuted),this.setActiveStream(n),n}async setMicrophone(n){if(!this.getInputDeviceList.find(({deviceId:e})=>e===n)||(this.setSelectedInputDevice(n),Object.keys(this.getActiveCalls).length===0))return;await this.setupStream();const a=Object.values(this.extendedCalls).filter(e=>e.roomId===this.currentActiveRoomId);a.length===1?Object.values(a).forEach(async e=>{const o=this.getActiveStream();e.connection.getSenders()[0].replaceTrack(o.getTracks()[0]),this.updateCall(e)}):await this.doConference(a)}setActiveStream(n){this.activeStream&&this.stopVUMeter("origin"),this.setupVUMeter(n,"origin"),this.activeStreamValue=n,this.context.emit("changeActiveStream",n)}async setSpeaker(n){if(!this.getOutputDeviceList.find(({deviceId:o})=>o===n))return;this.setSelectedOutputDevice(n);const a=Object.values(this.extendedCalls);if(a.length===0)return;const e=a.filter(o=>o.roomId===this.currentActiveRoomId);e.length===1?a.forEach(o=>{var p;(p=o.audioTag)==null||p.setSinkId(n),this.updateCall(o)}):await this.doConference(e)}removeRoom(n){const a={...this.activeRooms},e={...a[n]};delete a[n],this.activeRooms={...a},this.context.emit("removeRoom",{room:e,roomList:this.activeRooms})}deleteRoomIfEmpty(n){n!==void 0&&Object.values(this.extendedCalls).filter(a=>a.roomId===n).length===0&&(this.removeRoom(n),this.currentActiveRoomId===n&&(this.currentActiveRoomId=void 0))}checkInitialized(){if(!this.context.initialized)throw new Error("[OpenSIPSJS] You must call `start` method first!")}muteReconfigure(n){this.muted?n.mute({audio:!0}):n.unmute({audio:!0})}async roomReconfigure(n){var e;if(n===void 0)return;const a=Object.values(this.extendedCalls).filter(o=>o.roomId===n);if(this.currentActiveRoomId===n?a.forEach(o=>{o.audioTag&&(this.muteReconfigure(o),o.audioTag.muted=!1,this.updateCall(o))}):a.forEach(o=>{o.audioTag&&(o.audioTag.muted=!0,this.updateCall(o))}),a.length===0)this.deleteRoomIfEmpty(n);else if(a.length===1&&this.currentActiveRoomId!==n)a[0].isOnHold().local||await this.holdCall(a[0].id,!0);else if(a.length===1&&this.currentActiveRoomId===n){if(a[0].isOnHold().local&&a[0]._automaticHold&&await this.unholdCall(a[0].id),a[0].connection&&((e=a[0].connection)!=null&&e.getSenders()[0])){const o=this.getActiveStream();await a[0].connection.getSenders()[0].replaceTrack(o.getTracks()[0]),this.muteReconfigure(a[0])}}else a.length>1&&await this.doConference(a)}async doConference(n){const a=[];n.forEach(e=>{e!=null&&e.connection.getReceivers().forEach(o=>{a.push(o.track)})}),await zv.forEach(n,async e=>{var t;if(e==null)return;const o=new MediaStream,p=fr.createMediaStreamDestination();if(e.connection.getReceivers().forEach(v=>{a.forEach(C=>{o.addTrack(v.track),v.track.id!==C.id&&fr.createMediaStreamSource(new MediaStream([C])).connect(p)})}),n[0].roomId===this.currentActiveRoomId){const v=this.getActiveStream();fr.createMediaStreamSource(v).connect(p)}(t=e.connection)!=null&&t.getSenders()[0]&&(await e.connection.getSenders()[0].replaceTrack(p.stream.getTracks()[0]),this.muteReconfigure(e))})}processCallerMute(n,a){const e=this.extendedCalls[n];e&&e.connection.getReceivers().length&&(e.localMuted=a,e.connection.getReceivers().forEach(o=>{o.track.enabled=!a}),this.updateCall(e))}muteCaller(n){this.processCallerMute(n,!0)}unmuteCaller(n){this.processCallerMute(n,!1)}terminateCall(n){const a=this.extendedCalls[n];a._status!==8&&a.terminate()}transferCall(n,a){if(a.toString().length===0)return new Error("Target must be passed");const e=this.extendedCalls[n];if(!e._is_confirmed&&!e._is_canceled){const o=`sip:${a}@${this.context.sipDomain}`;e.terminate({status_code:302,reason_phrase:"Moved Temporarily",extraHeaders:[`Contact: ${o}`]});return}this.updateCallStatus({callId:n,isTransferring:!0}),e.refer(`sip:${a}@${this.context.sipDomain}`),this.updateCall(e)}mergeCall(n){const a=Object.values(this.extendedCalls).filter(p=>p.roomId===n);if(a.length!==2)return;const e=a[0],o=a[1];!e||!o||(this.updateCallStatus({callId:e._id,isMerging:!0}),this.updateCallStatus({callId:o._id,isMerging:!0}),e.refer(o.remote_identity.uri.toString(),{replaces:o}),this.updateCall(e))}mergeCallByIds(n,a){const e=Object.values(this.extendedCalls).find(p=>p._id===n),o=Object.values(this.extendedCalls).find(p=>p._id===a);if(!e||!o)throw new Error("Call ID is not provided");this.updateCallStatus({callId:n,isMerging:!0}),this.updateCallStatus({callId:a,isMerging:!0}),e.refer(o.remote_identity.uri.toString(),{replaces:o}),this.updateCall(e)}setDND(n){this.isDNDEnabled=n,this.context.emit("changeIsDND",n)}startCallTimer(n){this.removeTimeInterval(n);const a={callId:n,hours:0,minutes:0,seconds:0,formatted:""};this.setCallTime(a);const e=setInterval(()=>{const o={...this.callTime[n]},p=Yv(o);this.setCallTime({callId:n,...p})},1e3);this.setTimeInterval(n,e)}async setActiveRoom(n){const a=this.currentActiveRoomId;n!==a&&(this.currentActiveRoomId=n,await this.roomReconfigure(a),await this.roomReconfigure(n))}getNewRoomId(){const n=Object.keys(this.activeRooms);return n.length===0?1:parseInt(n.sort()[n.length-1])+1}async setupCall(n){var l,A;const a=n.session;if(this.getActiveCalls[a.id]!==void 0)return;const o=this.getNewRoomId(),p={started:new Date,incomingInProgress:!1,roomId:o};a.direction==="incoming"?(this.context.logger.log("New incoming call from",(A=(l=a._remote_identity)==null?void 0:l._uri)==null?void 0:A._user),p.incomingInProgress=!0,this.context.subscribe(Rs.CALL_CONFIRMED,b=>{a.id===b.id&&(this.updateRoom({incomingInProgress:!1,roomId:o}),this.startCallTimer(a.id))}),this.context.subscribe(Rs.CALL_FAILED,b=>{a.id===b.id&&(this.updateRoom({incomingInProgress:!1,roomId:o}),this.deleteRoomIfEmpty(o))})):a.direction==="outgoing"&&(a.once("confirmed",()=>{this.startCallTimer(a.id)}),this.startCallTimer(a.id));const t=a,v=this.hasAutoAnswerHeaders(n),C=t.direction==="incoming"&&!this.hasActiveCalls&&(v||this.autoAnswer);t.roomId=o,t.localMuted=!1,t.autoAnswer=C,C?this.addCall(t,!1):this.addCall(t),this.addCallStatus(a.id),this.addRoom(p),C&&this.answerCall(t._id)}removeCall(n){const a={...this.activeCalls};delete a[n],this.activeCalls={...a};const e={...this.extendedCalls};delete e[n],this.extendedCalls={...e},this.context.emit("changeActiveCalls",this.activeCalls)}activeCallListRemove(n){var o;const a=this.extendedCalls[n._id];this.stopVUMeter("origin"),(o=a.connection)==null||o.getSenders().forEach(p=>{p.track.stop()});const e=a.roomId;this.removeCall(n._id),this.roomReconfigure(e)}async newRTCSessionCallback(n){const a=n.session;if(this.isDND){a.terminate({status_code:486,reason_phrase:"Do Not Disturb"});return}if(this.context.triggerListener({listenerType:Rs.NEW_CALL,session:a,event:n}),a.on("ended",e=>{var p,t,v;this.stopVUMeter(a.id),this.context.logger.log("Session ended for",(t=(p=a._remote_identity)==null?void 0:p._uri)==null?void 0:t._user),this.context.triggerListener({listenerType:Rs.CALL_ENDED,session:a,event:e});const o=this.getActiveCalls[a.id];o&&this.activeCallListRemove(o),this.stopCallTimer(a.id),this.removeCallStatus(a.id),this.removeCallMetrics(a.id),Object.keys(this.extendedCalls).length||(this.setIsMuted(!1),(v=this.initialStreamValue)==null||v.getTracks().forEach(C=>C.stop()),this.initialStreamValue=null)}),a.on("progress",e=>{var o,p;this.context.logger.log("Session in progress for",(p=(o=a._remote_identity)==null?void 0:o._uri)==null?void 0:p._user),this.context.triggerListener({listenerType:Rs.CALL_PROGRESS,session:a,event:e})}),a.on("failed",e=>{var p,t,v;this.stopVUMeter(a.id),this.context.logger.log("Session failed for",(t=(p=a._remote_identity)==null?void 0:p._uri)==null?void 0:t._user),this.context.triggerListener({listenerType:Rs.CALL_FAILED,session:a,event:e}),a.id===this.callAddingInProgress&&(this.callAddingInProgress=void 0);const o=this.getActiveCalls[a.id];o&&this.activeCallListRemove(o),this.stopCallTimer(a.id),this.removeCallStatus(a.id),this.removeCallMetrics(a.id),Object.keys(this.extendedCalls).length||(this.setIsMuted(!1),(v=this.initialStreamValue)==null||v.getTracks().forEach(C=>C.stop()),this.initialStreamValue=null)}),a.on("confirmed",e=>{var o,p;this.context.logger.log("Session confirmed for",(p=(o=a._remote_identity)==null?void 0:o._uri)==null?void 0:p._user),this.context.triggerListener({listenerType:Rs.CALL_CONFIRMED,session:a,event:e}),this.updateCall(a),a.id===this.callAddingInProgress&&(this.callAddingInProgress=void 0)}),await this.setupCall(n),a.direction==="outgoing"){const e=this.getActiveCalls[a.id].roomId;this.setActiveRoom(e)}}setMuteWhenJoin(n){this.muteWhenJoinEnabled=n,this.context.emit("changeMuteWhenJoin",n)}setMicrophoneSensitivity(n){if(n<0||n>1)throw new Error("Value should be in range from 0 to 1!");this.microphoneInputLevelValue=n,this.roomReconfigure(this.currentActiveRoomId)}setSpeakerVolume(n){this.speakerVolumeValue=n,Object.values(this.extendedCalls).forEach(a=>{a.audioTag&&(a.audioTag.volume=n,this.updateCall(a))})}setAutoAnswer(n){this.isAutoAnswer=n}setSelectedInputDevice(n){localStorage.setItem(mo.SELECTED_INPUT_DEVICE,n),this.selectedMediaDevices.input=n,this.context.emit("changeActiveInputMediaDevice",n)}setSelectedOutputDevice(n){localStorage.setItem(mo.SELECTED_OUTPUT_DEVICE,n),this.selectedMediaDevices.output=n,this.context.emit("changeActiveOutputMediaDevice",n)}setCallMetrics(n){const a={...n};delete a.callId,this.callMetrics={...this.callMetrics,[n.callId]:a},this.context.emit("changeCallMetrics",this.callMetrics)}removeCallMetrics(n){const a={...this.callMetrics};delete a[n],this.callMetrics={...a},this.context.emit("changeCallMetrics",this.callMetrics)}getCallQuality(n){const a=new HT(this.metricConfig),e=a.createProbe(n.connection,{cid:n._id}),o=[];let p;e.onreport=t=>{Object.entries(t.audio).forEach(([l,A])=>{A.direction==="inbound"&&!o.includes(l)&&(o.push(l),p=l)});const v=t.audio[p];if(!v)return;const C=FT(v,qT);C.callId=n._id,this.setCallMetrics(C)},this.context.subscribe(Rs.CALL_ENDED,t=>{t._id===n._id&&a.stopAllProbes()}),a.startAllProbes()}setupVUMeter(n,a){this.VUMeter.start(n,a)}stopVUMeter(n){this.VUMeter.stop(n)}async setupStream(){const n=await navigator.mediaDevices.getUserMedia(this.getUserMediaConstraints);this.initialStreamValue&&(this.initialStreamValue.getTracks().forEach(a=>a.stop()),this.initialStreamValue=null),this.initialStreamValue=n}async triggerAddStream(n,a){this.setIsMuted(this.muteWhenJoin||this.isMuted),this.initialStreamValue||await this.setupStream();const e=Sh(this.initialStreamValue,this.microphoneInputLevel*2),o=this.isMuted||this.muteWhenJoin;e.getTracks().forEach(t=>t.enabled=!o),this.setActiveStream(e),await a.connection.getSenders()[0].replaceTrack(e.getTracks()[0]);const p=new MediaStream([n.track]);xv(p,a,this.selectedOutputDevice,this.speakerVolume),this.setupVUMeter(p,a._id),this.getCallQuality(a),this.updateCall(a)}initCall(n,a){if(n.length===0)return console.error("Target must be a valid string");this.context.logger.log(`Calling sip:${n}@${this.context.sipDomain}...`);const e=this.context.call(`sip:${n}@${this.context.sipDomain}`,this.sipOptions);this.callAddingInProgress=e.id,a&&this.currentActiveRoomId!==void 0&&this.processRoomChange({callId:e.id,roomId:this.currentActiveRoomId}),e.connection.addEventListener("track",o=>{this.triggerAddStream(o,e)})}async processRoomChange({callId:n,roomId:a}){const e=this.extendedCalls[n].roomId;this.extendedCalls[n].roomId=a;const o=this.extendedCalls[n];return this.updateCall(o),await this.setActiveRoom(a),Promise.all([this.roomReconfigure(e),this.roomReconfigure(a)]).then(()=>{this.deleteRoomIfEmpty(e),this.deleteRoomIfEmpty(a)})}}class GT{constructor(n){this.context=n}get sipOptions(){return{...this.context.options.sipOptions}}initCall(n,a){if(n.length===0)return console.error("Target must be a valid string");this.context.logger.log(`Calling sip:${n}@${this.context.sipDomain}...`),this.context.joinVideoCall(`sip:${n}@${this.context.sipDomain}`,a,this.sipOptions)}stop(n={}){this.context.terminateJanusSessions(n)}}class WT{constructor(n){this.activeMessages={},this.extendedMessages={},this.msrpHistory={},this.context=n,this.context.on(this.context.newMSRPSessionEventName,this.newMSRPSessionCallback.bind(this.context))}get isMSRPInitializing(){return this.isMSRPInitializingValue}get getActiveMessages(){return this.activeMessages}msrpAnswer(n){const a=this.extendedMessages[n];this.updateMSRPSession(a)}updateMSRPSession(n){this.activeMessages[n._id]=Ch(n),this.context.emit("changeActiveMessages",this.activeMessages)}addMMSRPSession(n){this.activeMessages={...this.activeMessages,[n._id]:Ch(n)},this.extendedMessages[n._id]=n,this.context.emit("changeActiveMessages",this.activeMessages)}addMSRPMessage(n,a){const e=this.msrpHistory[a.id]||[];e.push(n),this.msrpHistory={...this.msrpHistory,[a.id]:[...e]},this.context.emit("newMSRPMessage",{message:n,session:a})}messageTerminate(n){const a=this.extendedMessages[n];a._status!==8&&a.terminate()}addMessageSession(n){if(!n._id||this.getActiveMessages[n._id]!==void 0)return;const e=n;this.addMMSRPSession(e)}triggerMSRPListener({listenerType:n,session:a,event:e}){const o=this.context.listenersList[n];!o||!o.length||o.forEach(p=>{p(a,e)})}removeMMSRPSession(n){const a={...this.activeMessages};delete a[n],this.activeMessages={...a};const e={...this.extendedMessages};delete e[n],this.extendedMessages={...e},this.context.emit("changeActiveMessages",this.activeMessages)}activeMessageListRemove(n){this.removeMMSRPSession(n._id)}newMSRPSessionCallback(n){const a=n.session;a.on("ended",e=>{this.triggerMSRPListener({listenerType:Rs.CALL_ENDED,session:a,event:e});const o=this.getActiveMessages[a.id];this.activeMessageListRemove(o)}),a.on("failed",e=>{this.triggerMSRPListener({listenerType:Rs.CALL_FAILED,session:a,event:e});const o=this.getActiveMessages[a.id];this.activeMessageListRemove(o)}),a.on("confirmed",e=>{this.triggerMSRPListener({listenerType:Rs.CALL_CONFIRMED,session:a,event:e}),this.updateMSRPSession(a)}),a.on("newMessage",e=>{this.addMSRPMessage(e,a)}),this.addMessageSession(a)}setIsMSRPInitializing(n){this.isMSRPInitializingValue=n,this.context.emit("isMSRPInitializingChanged",n)}initMSRP(n,a,e){if(n.length===0)return console.error("Target must be a valid string");const o=this.context.startMSRP(n,e);o.on("active",()=>{this.addMessageSession(o),o.sendMSRP(a),this.setIsMSRPInitializing(!1)}),this.setIsMSRPInitializing(!0)}sendMSRP(n,a){const e=this.extendedMessages[n];if(!e)throw new Error(`MSRP session with id ${n} doesn't exist!`);e.sendMSRP(a)}}const Wu={AUDIO:"audio",VIDEO:"video",MSRP:"msrp"};class KT extends bv{constructor(n,a){if(!n.modules.length)throw new Error("options.modules should include at least 1 module");const e={...n.configuration,sockets:n.socketInterfaces.map(o=>new Kv.WebSocketInterface(o))};super(e),this.initialized=!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.audio=null,this.msrp=null,this.video=null,this.listenersList={},this.modules=[],n.pnExtraHeaders&&Object.keys(n.pnExtraHeaders).length&&this.registrator().setExtraContactUriParams(n.pnExtraHeaders),this.options=n,this.modules=n.modules,a&&Pv(a)&&(this.logger=a)}on(n,a){return super.on(n,a)}off(n,a){return super.off(n,a)}emit(n,a){return super.emit(n,a)}get sipDomain(){return this.options.sipDomain}begin(){if(this.isConnected()){console.error("Connection is already established");return}return this.modules.includes(Wu.AUDIO)&&(this.audio=new BT(this)),this.modules.includes(Wu.MSRP)&&(this.msrp=new WT(this)),this.modules.includes(Wu.VIDEO)&&(this.video=new GT(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.isReconnecting=!1}),this.on(this.disconnectedEventName,()=>{this.isReconnecting||(this.logger.log("Disconnected from",this.options.socketInterfaces[0]),this.logger.log("Reconnecting to",this.options.socketInterfaces[0]),this.isReconnecting=!0,this.stop(),this.setInitialized(!1),setTimeout(this.start.bind(this),5e3))}),this.logger.log("Connecting to",this.options.socketInterfaces[0]),this.start(),this}subscribe(n,a){const o=!this.listenersList[n]||!this.listenersList[n].length?[a]:[...this.listenersList[n],a];this.listenersList={...this.listenersList,[n]:o}}removeIListener(n){const a={...this.listenersList};delete a[n],this.listenersList={...a}}triggerListener({listenerType:n,session:a,event:e}){const o=this.listenersList[n];!o||!o.length||o.forEach(p=>{p(a,e)})}setInitialized(n){this.initialized=n,this.emit("ready",n)}}return KT}();
|
155
|
+
a=path:${s.getHeader("Use-Path")} msrp://${this._ua._configuration.authorization_user}.${this._ua._configuration.realm}:2856/${this.auth_id};ws
|
156
|
+
`),this._newMSRPSession("local",this._request),this._id=this._request.call_id+this._from_tag,console.log("dialog be",this._dialog),new ra(this._ua,this._request,{onRequestTimeout:()=>{this.onRequestTimeout(),console.log("to")},onTransportError:_=>{this.onTransportError(),console.log(_)},onAuthenticated:_=>{this._request=_},onReceiveResponse:_=>{this._receiveInviteResponse(_),console.log("dialog af",this._dialog),_.status_code===200&&(_.parseSDP(!0),this._status=Ie.STATUS_CONFIRMED,this.target_addr=_.sdp.media[0].invalid[1].value.replaceAll("path:","").split(" ").reverse(),this.status="active",this.emit("active"),this.emit("confirmed"))}}).send(),this._status=Ie.STATUS_INVITE_SENT}terminate(s={}){console.log("terminate",this);const i=s.cause||F.causes.BYE,l=$e.cloneArray(s.extraHeaders),a=s.body;let _,e=s.status_code,p=s.reason_phrase;if(this._status===Ie.STATUS_TERMINATED)throw new Ps.InvalidStateError(this._status);switch(this.status="terminated",this._status){case Ie.STATUS_NULL:case Ie.STATUS_INVITE_SENT:case Ie.STATUS_1XX_RECEIVED:if(e&&(e<200||e>=700))throw new TypeError(`Invalid status_code: ${e}`);e&&(p=p||F.REASON_PHRASE[e]||"",_=`SIP ;cause=${e} ;text="${p}"`),this._status===Ie.STATUS_NULL||this._status===Ie.STATUS_INVITE_SENT?(this._is_canceled=!0,this._cancel_reason=_):this._status===Ie.STATUS_1XX_RECEIVED&&this._request.cancel(_),this._status=Ie.STATUS_CANCELED,console.log("failed 1"),this._failed("local",null,F.causes.CANCELED);break;case Ie.STATUS_WAITING_FOR_ANSWER:case Ie.STATUS_ANSWERED:if(e=e||480,console.log("REPLY 480"),e<300||e>=700)throw new TypeError(`Invalid status_code: ${e}`);this._request.reply(e,p,l,a),console.log("failed 2"),this._failed("local",null,F.causes.REJECTED);break;case Ie.STATUS_WAITING_FOR_ACK:case Ie.STATUS_CONFIRMED:if(p=s.reason_phrase||F.REASON_PHRASE[e]||"",e&&(e<200||e>=700))throw new TypeError(`Invalid status_code: ${e}`);if(e&&l.push(`Reason: SIP ;cause=${e}; text="${p}"`),this._status===Ie.STATUS_WAITING_FOR_ACK&&this._direction==="incoming"&&this._request.server_transaction.state!==jt.C.STATUS_TERMINATED){const g=this._dialog;this.receiveRequest=({method:n})=>{n===F.ACK&&(this.sendRequest(F.BYE,{extraHeaders:l,body:a}),g.terminate())},this._request.server_transaction.on("stateChanged",()=>{this._request.server_transaction.state===jt.C.STATUS_TERMINATED&&(this.sendRequest(F.BYE,{extraHeaders:l,body:a}),g.terminate())}),this._ended("local",null,i),this._dialog=g,this._ua.newDialog(g)}else console.log("here it is"),this.sendRequest(F.BYE,{extraHeaders:l,body:a}),this._ended("local",null,i)}}sendRequest(s,i){return this._dialog.sendRequest(s,i)}authenticate(s){this.status="auth";let i=new Jn("");i.method="AUTH",i.addHeader("To-Path",`msrp://${this._ua._configuration.realm}:2856;ws`),i.addHeader("From-Path",`msrp://${this.credentials.username}.${this.credentials.realm}:2856/${this.auth_id};ws`),s&&i.addHeader("Authorization",s.toString());let l=i.toString();console.log(l);let a=[];for(var _=0;_<l.length;_++)a.push(l.charCodeAt(_).toString(16));console.log(a),this._connection.send(i.toString())}onmessage(s){console.log("onmessage",s);const i=new Jn(s.data);if(this.status==="auth"&&i.code===401){const l=this.parseAuth(i.getHeader("WWW-Authenticate")),a=new wm(this.credentials);a.authenticate({method:"AUTH",ruri:`msrp://${this._ua._configuration.realm}:2856;ws`,body:null},l,$e.createRandomToken(12)),this.authenticate(a)}this.status==="auth"&&i.code===200&&this._direction==="outgoing"?(this.my_addr.push(i.getHeader("To-Path")),this.my_addr.push(i.getHeader("Use-Path")),this.status="active",this.inviteParty(i)):this.status==="auth"&&i.code===200&&this._direction==="incoming"?(this.my_addr.push(i.getHeader("To-Path")),this.my_addr.push(i.getHeader("Use-Path")),this.status="active",this.acceptParty(i),this.emit("confirmed")):i.method==="SEND"&&(this._sendOk(i),this._sendReport(i),i.direction="incoming",this.emit("newMessage",i),this._msgHistory.push(i),this.emit("msgHistoryUpdate",this._msgHistory),console.log("======================================================================")),i.code===480&&this._close()}onclose(){console.log("close")}onopen(){const s=new RTCPeerConnection({iceServers:[]});s.createDataChannel(""),s.createOffer().then(s.setLocalDescription.bind(s)),s.onicecandidate=i=>{if(!i||!i.candidate||!i.candidate.candidate)return;const l=/([0-9]{1,3}(\.[0-9]{1,3}){3})/,a=i.candidate.candidate.match(l);this.my_ip=a&&a[1],s.onicecandidate=()=>{},this.authenticate(null)}}onerror(s){console.log(s)}_receiveInviteResponse(s){if(console.log("resp0000000000000",s),this._dialog&&s.status_code>=200&&s.status_code<=299)if(console.log("200000000000000"),this._dialog.id.call_id===s.call_id&&this._dialog.id.local_tag===s.from_tag&&this._dialog.id.remote_tag===s.to_tag){this.sendRequest(F.ACK);return}else{const i=new aa(this,s,"UAC");if(i.error!==void 0){console.log(i.error);return}this.sendRequest(F.ACK),this.sendRequest(F.BYE);return}if(this._is_canceled){s.status_code>=100&&s.status_code<200?this._request.cancel(this._cancel_reason):s.status_code>=200&&s.status_code<299&&this._acceptAndTerminate(s);return}if(!(this._status!==Ie.STATUS_INVITE_SENT&&this._status!==Ie.STATUS_1XX_RECEIVED))switch(console.log("start Switch"),!0){case/^100$/.test(s.status_code):this._status=Ie.STATUS_1XX_RECEIVED;break;case/^1[0-9]{2}$/.test(s.status_code):{if(!s.to_tag){console.log("1xx response received without to tag");break}if(s.hasHeader("contact")&&!this._createDialog(s,"UAC",!0))break;if(this._status=Ie.STATUS_1XX_RECEIVED,!s.body){this._progress("remote",s);break}const i={originator:"remote",type:"answer",sdp:s.body};console.log('emit "sdp"'),this.emit("sdp",i);const l=new RTCSessionDescription({type:"answer",sdp:i.sdp});this._connectionPromiseQueue=this._connectionPromiseQueue.then(()=>this._connection.setRemoteDescription(l)).then(()=>this._progress("remote",s)).catch(a=>{console.log('emit "peerconnection:setremotedescriptionfailed" [error:%o]',a),this.emit("peerconnection:setremotedescriptionfailed",a)});break}case/^2[0-9]{2}$/.test(s.status_code):{if(console.log("maybe here???"),this._status=Ie.STATUS_CONFIRMED,!s.body){this._acceptAndTerminate(s,400,F.causes.MISSING_SDP),console.log("failed 3"),this._failed("remote",s,F.causes.BAD_MEDIA_DESCRIPTION);break}if(!this._createDialog(s,"UAC"))break;const i={originator:"remote",type:"answer",sdp:s.body};console.log('emit "sdp"'),this.emit("sdp",i),new RTCSessionDescription({type:"answer",sdp:i.sdp}),this._connectionPromiseQueue=this._connectionPromiseQueue.then(()=>{if(this._connection.signalingState==="stable")return this._connection.createOffer(this._rtcOfferConstraints).then(l=>this._connection.setLocalDescription(l)).catch(l=>{this._acceptAndTerminate(s,500,l.toString()),console.log("failed 4"),this._failed("local",s,F.causes.WEBRTC_ERROR)})}).then(()=>{this._handleSessionTimersInIncomingResponse(s),this._accepted("remote",s),this.sendRequest(F.ACK),this._confirmed("local",null)});break}default:{const i=$e.sipErrorCause(s.status_code);console.log("failed 5"),this._failed("remote",s,i)}}}sendMSRP(s){const i=new Jn("");i.method="SEND",i.addHeader("To-Path",`${this.my_addr[1]} ${this.target_addr[1]} ${this.target_addr[0]}`),i.addHeader("From-Path",`${this.my_addr[0]}`),i.addHeader("Message-ID",$e.createRandomToken(10)),i.addHeader("Byte-Range","1-25/25"),i.addHeader("Content-Type","text/plain"),i.addHeader("Success-Report","yes"),i.addHeader("Failure-Report","yes"),i.body=s;let l=i.toString();console.log(l);let a=[];for(var _=0;_<l.length;_++)a.push(l.charCodeAt(_).toString(16));console.log(a),this._connection.send(i.toString()),i.direction="outgoing",this.emit("newMessage",i),this._msgHistory.push(i),this.emit("msgHistoryUpdate",this._msgHistory)}_sendOk(s){let i=s.ident,l=s.getHeader("Message-ID"),a=new Jn("");a.method="200 OK",a.addHeader("To-Path",`${this.my_addr[1]}`),a.addHeader("From-Path",`${this.my_addr[0]}`),a.addHeader("Message-ID",l),a.ident=i;let _=a.toString();console.log(_);let e=[];for(var p=0;p<_.length;p++)e.push(_.charCodeAt(p).toString(16));console.log(e),this._connection.send(a.toString())}_sendReport(s){let i=s.ident,l=s.getHeader("Message-ID"),a=new Jn("");a.method="REPORT",a.addHeader("To-Path",`${s.getHeader("From-Path")}`),a.addHeader("From-Path",`${this.my_addr[0]}`),a.addHeader("Message-ID",l),a.addHeader("Byte-Range","1-25/25"),a.addHeader("Status","000 200 OK"),a.ident=i;let _=a.toString();console.log(_);let e=[];for(var p=0;p<_.length;p++)e.push(_.charCodeAt(p).toString(16));console.log(e),this._connection.send(a.toString())}parseAuth(s){const i={},l=s.replace("Digest","").split(",");for(const a of l){const _=a.trim().split("=");i[_[0]]=_[1].match('^"(.+)"$')[1]}return i}init_incoming(s,i){let l;const a=s.hasHeader("Content-Type")?s.getHeader("Content-Type").toLowerCase():void 0;if(s.body&&a!=="application/sdp"){s.reply(415);return}if(this._status=Ie.STATUS_INVITE_RECEIVED,this._from_tag=s.from_tag,this._id=s.call_id+this._from_tag,this._request=s,this._contact=this._ua.contact.toString(),s.hasHeader("expires")&&(l=s.getHeader("expires")*1e3),s.to_tag=$e.newTag(),!this._createDialog(s,"UAS",!0)){s.reply(500,"Missing Contact header field");return}s.body?this._late_sdp=!1:this._late_sdp=!0,this._status=Ie.STATUS_WAITING_FOR_ANSWER,this._timers.userNoAnswerTimer=setTimeout(()=>{s.reply(408),console.log("failed 6"),this._failed("local",null,F.causes.NO_ANSWER)},this._ua.configuration.no_answer_timeout),l&&(this._timers.expiresTimer=setTimeout(()=>{this._status===Ie.STATUS_WAITING_FOR_ANSWER&&(s.reply(487),console.log("failed 7"),this._failed("system",null,F.causes.EXPIRES))},l)),this._direction="incoming",this._local_identity=s.to,this._remote_identity=s.from,i&&i(this),s.parseSDP(!0),this.target_addr=s.sdp.media[0].invalid[1].value.replaceAll("path:","").split(" ").reverse(),this._newMSRPSession("remote",s),this._status!==Ie.STATUS_TERMINATED&&(s.reply(180,null,[`Contact: ${this._ua._contact}`]),this._progress("local",null))}_failed(s,i,l){this.emit("_failed",{originator:s,message:i||null,cause:l}),this._close(),this.emit("failed",{originator:s,message:i||null,cause:l})}_close(){if(console.log("CLOSE SESSION"),this._status!==Ie.STATUS_TERMINATED){if(this._status=Ie.STATUS_TERMINATED,this._connection)try{this._connection.close()}catch(s){console.log("close() | error closing the RTCPeerConnection: %o",s)}for(const s in this._timers)Object.prototype.hasOwnProperty.call(this._timers,s)&&clearTimeout(this._timers[s]);clearTimeout(this._sessionTimers.timer),this._dialog&&(this._dialog.terminate(),delete this._dialog);for(const s in this._earlyDialogs)Object.prototype.hasOwnProperty.call(this._earlyDialogs,s)&&(this._earlyDialogs[s].terminate(),delete this._earlyDialogs[s]);for(const s in this._referSubscribers)Object.prototype.hasOwnProperty.call(this._referSubscribers,s)&&delete this._referSubscribers[s];this._ua.destroyMSRPSession(this)}}_createDialog(s,i,l){const a=i==="UAS"?s.to_tag:s.from_tag,_=i==="UAS"?s.from_tag:s.to_tag,e=s.call_id+a+_;let p=this._earlyDialogs[e];if(l)return p?!0:(p=new aa(this,s,i,aa.C.STATUS_EARLY),p.error?(console.log("failed 8"),this._failed("remote",s,F.causes.INTERNAL_ERROR),!1):(this._earlyDialogs[e]=p,!0));{if(this._from_tag=s.from_tag,this._to_tag=s.to_tag,p)return p.update(s,i),this._dialog=p,delete this._earlyDialogs[e],!0;const g=new aa(this,s,i);return g.error?(console.log("failed 9"),this._failed("remote",s,F.causes.INTERNAL_ERROR),!1):(this._dialog=g,!0)}}_newMSRPSession(s,i){this._ua.newMSRPSession(this,{originator:s,session:this,request:i})}_progress(s,i){this.emit("progress",{originator:s,response:i||null})}isEnded(){switch(this._status){case Ie.STATUS_CANCELED:case Ie.STATUS_TERMINATED:return!0;default:return!1}}_accepted(s,i){console.log("session accepted"),this._start_time=new Date,console.log('emit "accepted"'),this.emit("accepted",{originator:s,response:i||null})}_confirmed(s,i){console.log("session confirmed"),this._is_confirmed=!0,console.log('emit "confirmed"'),this.emit("confirmed",{originator:s,ack:i||null})}_ended(s,i,l){console.log("session ended"),this._end_time=new Date,this._close(),console.log('emit "ended"'),this.emit("ended",{originator:s,message:i||null,cause:l})}_handleSessionTimersInIncomingResponse(s){if(!this._sessionTimers.enabled)return;let i;s.session_expires&&s.session_expires>=F.MIN_SESSION_EXPIRES?(this._sessionTimers.currentExpires=s.session_expires,i=s.session_expires_refresher||"uac"):(this._sessionTimers.currentExpires=this._sessionTimers.defaultExpires,i="uac"),this._sessionTimers.refresher=i==="uac",this._runSessionTimer()}receiveRequest(s){if(console.log("receiveRequest()"),s.method===F.CANCEL)(this._status===Ie.STATUS_WAITING_FOR_ANSWER||this._status===Ie.STATUS_ANSWERED)&&(this._status=Ie.STATUS_CANCELED,this._request.reply(487),console.log("failed 10"),this._failed("remote",s,F.causes.CANCELED));else switch(s.method){case F.ACK:if(this._status!==Ie.STATUS_WAITING_FOR_ACK)return;if(this._status=Ie.STATUS_CONFIRMED,clearTimeout(this._timers.ackTimer),clearTimeout(this._timers.invite2xxTimer),this._late_sdp){if(!s.body){this.terminate({cause:F.causes.MISSING_SDP,status_code:400});break}const i={originator:"remote",type:"answer",sdp:s.body};console.log('emit "sdp"'),this.emit("sdp",i);const l=new RTCSessionDescription({type:"answer",sdp:i.sdp});this._connectionPromiseQueue=this._connectionPromiseQueue.then(()=>this._connection.setRemoteDescription(l)).then(()=>{this._is_confirmed||this._confirmed("remote",s)}).catch(a=>{this.terminate({cause:F.causes.BAD_MEDIA_DESCRIPTION,status_code:488}),console.log('emit "peerconnection:setremotedescriptionfailed" [error:%o]',a),this.emit("peerconnection:setremotedescriptionfailed",a)})}else this._is_confirmed||this._confirmed("remote",s);break;case F.BYE:this._status===Ie.STATUS_CONFIRMED||this._status===Ie.STATUS_WAITING_FOR_ACK?(s.reply(200),this._ended("remote",s,F.causes.BYE)):this._status===Ie.STATUS_INVITE_RECEIVED||this._status===Ie.STATUS_WAITING_FOR_ANSWER?(s.reply(200),this._request.reply(487,"BYE Received"),this._ended("remote",s,F.causes.BYE)):s.reply(403,"Wrong Status");break;case F.INVITE:this._status===Ie.STATUS_CONFIRMED?s.hasHeader("replaces")?this._receiveReplaces(s):this._receiveReinvite(s):s.reply(403,"Wrong Status");break;case F.INFO:this._status===Ie.STATUS_1XX_RECEIVED||this._status===Ie.STATUS_WAITING_FOR_ANSWER||this._status===Ie.STATUS_ANSWERED||this._status===Ie.STATUS_WAITING_FOR_ACK||this._status===Ie.STATUS_CONFIRMED?(s.hasHeader("Content-Type")?s.getHeader("Content-Type").toLowerCase():void 0)!==void 0?new cu(this).init_incoming(s):s.reply(415):s.reply(403,"Wrong Status");break;case F.UPDATE:this._status===Ie.STATUS_CONFIRMED?this._receiveUpdate(s):s.reply(403,"Wrong Status");break;case F.REFER:this._status===Ie.STATUS_CONFIRMED?this._receiveRefer(s):s.reply(403,"Wrong Status");break;case F.NOTIFY:this._status===Ie.STATUS_CONFIRMED?this._receiveNotify(s):s.reply(403,"Wrong Status");break;default:s.reply(501)}}onTransportError(){console.log("onTransportError()"),this._status!==Ie.STATUS_TERMINATED&&this.terminate({status_code:500,reason_phrase:F.causes.CONNECTION_ERROR,cause:F.causes.CONNECTION_ERROR})}onRequestTimeout(){console.log("onRequestTimeout()"),this._status!==Ie.STATUS_TERMINATED&&this.terminate({status_code:408,reason_phrase:F.causes.REQUEST_TIMEOUT,cause:F.causes.REQUEST_TIMEOUT})}onDialogError(){console.log("onDialogError()"),this._status!==Ie.STATUS_TERMINATED&&this.terminate({status_code:500,reason_phrase:F.causes.DIALOG_ERROR,cause:F.causes.DIALOG_ERROR})}}var gT=Gt();const Ou=Le(gT),va=new ea("Parser"),TT=(c,s)=>{let i,l,a=c.indexOf(`\r
|
157
|
+
`);if(a===-1){va.warn("parseMessage() | no CRLF found, not a SIP message");return}const _=c.substring(0,a);let e=Ou.parse(_,"Request_Response");if(e===-1){va.warn(`parseMessage() | error parsing first line of SIP message: "${_}"`);return}else e.status_code?(i=new un.IncomingResponse,i.status_code=e.status_code,i.reason_phrase=e.reason_phrase):(i=new un.IncomingRequest(s),i.method=e.method,i.ruri=e.uri);i.data=c;let p=a+2;for(;;){if(a=vT(c,p),a===-2){l=p+2;break}else if(a===-1){va.warn("parseMessage() | malformed message");return}if(e=ET(i,c,p,a),e!==!0){va.warn("parseMessage() |",e.error);return}p=a+2}if(i.hasHeader("content-length")){const g=i.getHeader("content-length");i.body=c.substr(l,g)}else i.body=c.substring(l);return i};function vT(c,s){let i=s,l=0,a=0;if(c.substring(i,i+2).match(/(^\r\n)/))return-2;for(;l===0;){if(a=c.indexOf(`\r
|
158
|
+
`,i),a===-1)return a;!c.substring(a+2,a+4).match(/(^\r\n)/)&&c.charAt(a+2).match(/(^\s+)/)?i=a+2:l=a}return l}function ET(c,s,i,l){let a;const _=s.indexOf(":",i),e=s.substring(i,_).trim(),p=s.substring(_+1,l).trim();switch(e.toLowerCase()){case"via":case"v":c.addHeader("via",p),c.getHeaders("via").length===1?(a=c.parseHeader("Via"),a&&(c.via=a,c.via_branch=a.branch)):a=0;break;case"from":case"f":c.setHeader("from",p),a=c.parseHeader("from"),a&&(c.from=a,c.from_tag=a.getParam("tag"));break;case"to":case"t":c.setHeader("to",p),a=c.parseHeader("to"),a&&(c.to=a,c.to_tag=a.getParam("tag"));break;case"record-route":if(a=Ou.parse(p,"Record_Route"),a===-1)a=void 0;else for(const g of a)c.addHeader("record-route",p.substring(g.possition,g.offset)),c.headers["Record-Route"][c.getHeaders("record-route").length-1].parsed=g.parsed;break;case"call-id":case"i":c.setHeader("call-id",p),a=c.parseHeader("call-id"),a&&(c.call_id=p);break;case"contact":case"m":if(a=Ou.parse(p,"Contact"),a===-1)a=void 0;else for(const g of a)c.addHeader("contact",p.substring(g.possition,g.offset)),c.headers.Contact[c.getHeaders("contact").length-1].parsed=g.parsed;break;case"content-length":case"l":c.setHeader("content-length",p),a=c.parseHeader("content-length");break;case"content-type":case"c":c.setHeader("content-type",p),a=c.parseHeader("content-type");break;case"cseq":c.setHeader("cseq",p),a=c.parseHeader("cseq"),a&&(c.cseq=a.value),c instanceof un.IncomingResponse&&(c.method=a.method);break;case"max-forwards":c.setHeader("max-forwards",p),a=c.parseHeader("max-forwards");break;case"www-authenticate":c.setHeader("www-authenticate",p),a=c.parseHeader("www-authenticate");break;case"proxy-authenticate":c.setHeader("proxy-authenticate",p),a=c.parseHeader("proxy-authenticate");break;case"session-expires":case"x":c.setHeader("session-expires",p),a=c.parseHeader("session-expires"),a&&(c.session_expires=a.expires,c.session_expires_refresher=a.refresher);break;case"refer-to":case"r":c.setHeader("refer-to",p),a=c.parseHeader("refer-to"),a&&(c.refer_to=a);break;case"replaces":c.setHeader("replaces",p),a=c.parseHeader("replaces"),a&&(c.replaces=a);break;case"event":case"o":c.setHeader("event",p),a=c.parseHeader("event"),a&&(c.event=a);break;default:c.addHeader(e,p),a=0}return a===void 0?{error:`error parsing header "${e}"`}:!0}const ST={parseMessage:TT},Yr=new ea("Registrator"),Ea=10;class yT{constructor(s,i){this._reg_id=1,this._ua=s,this._transport=i,this._registrar=s.configuration.registrar_server,this._expires=s.configuration.register_expires,this._call_id=Ts.createRandomToken(22),this._cseq=0,this._to_uri=s.configuration.uri,this._registrationTimer=null,this._registering=!1,this._registered=!1,this._contact=this._ua.contact.toString();const l=this._contact.indexOf(">");if(l!==-1){const a=this._contact.slice(0,l)+this._contact.slice(l+1,this._contact.length);this._contact=a}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(s){Array.isArray(s)||(s=[]),this._extraHeaders=s.slice()}setExtraContactParams(s){s instanceof Object||(s={}),this._extraContactParams="";for(const i in s)if(Object.prototype.hasOwnProperty.call(s,i)){const l=s[i];this._extraContactParams+=`;${i}`,l&&(this._extraContactParams+=`=${l}`)}}setExtraContactUriParams(s){s instanceof Object||(s={}),this._extraContactParams="";for(const i in s)if(Object.prototype.hasOwnProperty.call(s,i)){const l=s[i];this._extraContactParams+=`;${i}`,l&&(this._extraContactParams+=`=${l}`)}}register(){if(this._registering){Yr.debug("Register request in progress...");return}const s=this._extraHeaders.slice();s.push(`Contact: ${this._contact}${this._extraContactParams}>${this._extra_contact};expires=${this._expires}`),s.push(`Expires: ${this._expires}`);const i=new bt.OutgoingRequest(F.REGISTER,this._registrar,this._ua,{to_uri:this._to_uri,call_id:this._call_id,cseq:this._cseq+=1},s),l=new ra(this._ua,i,{onRequestTimeout:()=>{this._registrationFailure(null,F.causes.REQUEST_TIMEOUT)},onTransportError:()=>{this._registrationFailure(null,F.causes.CONNECTION_ERROR)},onAuthenticated:()=>{this._cseq+=1},onReceiveResponse:a=>{if(a.cseq===this._cseq)switch(this._registrationTimer!==null&&(clearTimeout(this._registrationTimer),this._registrationTimer=null),!0){case/^1[0-9]{2}$/.test(a.status_code):break;case/^2[0-9]{2}$/.test(a.status_code):{if(this._registering=!1,!a.hasHeader("Contact")){Yr.debug("no Contact header in response to REGISTER, response ignored");break}const _=a.headers.Contact.reduce((n,v)=>n.concat(v.parsed),[]);let e=_.find(n=>this._sipInstance===n.getParam("+sip.instance")&&this._reg_id===parseInt(n.getParam("reg-id")));if(e||(e=_.find(n=>n.uri.user===this._ua.contact.uri.user)),!e){Yr.debug("no Contact header pointing to us, response ignored");break}let p=e.getParam("expires");!p&&a.hasHeader("expires")&&(p=a.getHeader("expires")),p||(p=this._expires),p=Number(p),p<Ea&&(p=Ea);const g=p>64?p*1e3/2+Math.floor((p/2-32)*1e3*Math.random()):p*1e3-5e3;this._registrationTimer=setTimeout(()=>{this._registrationTimer=null,this._ua.listeners("registrationExpiring").length===0?this.register():this._ua.emit("registrationExpiring")},g),e.hasParam("temp-gruu")&&(this._ua.contact.temp_gruu=e.getParam("temp-gruu").replace(/"/g,"")),e.hasParam("pub-gruu")&&(this._ua.contact.pub_gruu=e.getParam("pub-gruu").replace(/"/g,"")),this._registered||(this._registered=!0,this._ua.registered({response:a}));break}case/^423$/.test(a.status_code):{a.hasHeader("min-expires")?(this._expires=Number(a.getHeader("min-expires")),this._expires<Ea&&(this._expires=Ea),this.register()):(Yr.debug("423 response received for REGISTER without Min-Expires"),this._registrationFailure(a,F.causes.SIP_FAILURE_CODE));break}default:{const _=Ts.sipErrorCause(a.status_code);this._registrationFailure(a,_)}}}});this._registering=!0,l.send()}unregister(s={}){if(!this._registered){Yr.debug("already unregistered");return}this._registered=!1,this._registrationTimer!==null&&(clearTimeout(this._registrationTimer),this._registrationTimer=null);const i=this._extraHeaders.slice();s.all?i.push(`Contact: *${this._extraContactParams}`):i.push(`Contact: ${this._contact}${this._extraContactParams}>${this._extra_contact};expires=0`),i.push("Expires: 0");const l=new bt.OutgoingRequest(F.REGISTER,this._registrar,this._ua,{to_uri:this._to_uri,call_id:this._call_id,cseq:this._cseq+=1},i);new ra(this._ua,l,{onRequestTimeout:()=>{this._unregistered(null,F.causes.REQUEST_TIMEOUT)},onTransportError:()=>{this._unregistered(null,F.causes.CONNECTION_ERROR)},onAuthenticated:()=>{this._cseq+=1},onReceiveResponse:_=>{switch(!0){case/^1[0-9]{2}$/.test(_.status_code):break;case/^2[0-9]{2}$/.test(_.status_code):this._unregistered(_);break;default:{const e=Ts.sipErrorCause(_.status_code);this._unregistered(_,e)}}}}).send()}close(){this._registered&&this.unregister()}onTransportClosed(){this._registering=!1,this._registrationTimer!==null&&(clearTimeout(this._registrationTimer),this._registrationTimer=null),this._registered&&(this._registered=!1,this._ua.unregistered({}))}_registrationFailure(s,i){this._registering=!1,this._ua.registrationFailed({response:s||null,cause:i}),this._registered&&(this._registered=!1,this._ua.unregistered({response:s||null,cause:i}))}_unregistered(s,i){this._registering=!1,this._registered=!1,this._ua.unregistered({response:s||null,cause:i||null})}}const _t=console,Ls={STATUS_INIT:0,STATUS_READY:1,STATUS_USER_CLOSED:2,STATUS_NOT_READY:3,CONFIGURATION_ERROR:1,NETWORK_ERROR:2},AT=uT;class CT extends AT{constructor(s){super(s),this._msrp_sessions=[],this._transactions={nist:{},nict:{},ist:{},ict:{}},this._janus_sessions=[],this._registrator=new yT(this)}call(s,i){return super.call(s,i)}joinVideoCall(s,i,l){_t.debug("call()");const a=new Ta(this);return a.connect(s,i,l),a}_loadConfig(s){try{Kr.load(this._configuration,s)}catch(a){throw a}this._configuration.display_name===0&&(this._configuration.display_name="0"),this._configuration.instance_id||(this._configuration.instance_id=Ts.newUUID()),this._configuration.jssip_id=Ts.createRandomToken(5);const i=this._configuration.uri.clone();i.user=null,this._configuration.hostport_params=i.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=RT.bind(this),this._transport.onconnect=IT.bind(this),this._transport.ondisconnect=bT.bind(this),this._transport.ondata=wT.bind(this)}catch(a){throw _t.warn(a),new Ps.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 a=this._configuration.uri.clone();a.user=null,a.clearParams(),a.clearHeaders(),this._configuration.registrar_server=a}this._configuration.no_answer_timeout*=1e3,this._configuration.contact_uri?this._configuration.via_host=this._configuration.contact_uri.host:this._configuration.contact_uri=new Yn("sip",Ts.createRandomToken(8),this._configuration.via_host,null,{transport:"ws"}),this._contact={pub_gruu:null,temp_gruu:null,uri:this._configuration.contact_uri,toString(a={}){const _=a.anonymous||null,e=a.outbound||null;let p="<";return _?p+=this.temp_gruu||"sip:anonymous@anonymous.invalid;transport=ws":p+=this.pub_gruu||this.uri.toString(),e&&(_?!this.temp_gruu:!this.pub_gruu)&&(p+=";ob"),p+=">",p}};const l=["authorization_user","password","realm","ha1","authorization_jwt","display_name","register"];for(const a in this._configuration)Object.prototype.hasOwnProperty.call(this._configuration,a)&&(l.indexOf(a)!==-1?Object.defineProperty(this._configuration,a,{writable:!0,configurable:!1}):Object.defineProperty(this._configuration,a,{writable:!1,configurable:!1}));_t.debug("configuration parameters after validation:");for(const a in this._configuration)if(Object.prototype.hasOwnProperty.call(Kr.settings,a))switch(a){case"uri":case"registrar_server":_t.debug(`- ${a}: ${this._configuration[a]}`);break;case"password":case"ha1":case"authorization_jwt":_t.debug(`- ${a}: NOT SHOWN`);break;default:_t.debug(`- ${a}: ${JSON.stringify(this._configuration[a])}`)}}newMSRPSession(s,i){s.on("msgHistoryUpdate",l=>{console.log(l)}),this._msrp_sessions[s.id]=s,this.emit("newMSRPSession",i)}newJanusSession(s,i){this._janus_sessions[s.id]=s,this.emit("newJanusSession",i)}destroyMSRPSession(s){delete this._msrp_sessions[s.id]}destroyJanusSession(s){delete this._janus_sessions[s.id]}receiveRequest(s){var _,e,p,g;const i=s.method;if(console.log("-----------"),s.ruri.user!==this._configuration.uri.user&&s.ruri.user!==this._contact.uri.user){_t.debug("Request-URI does not point to us"),s.method!==xe.ACK&&s.reply_sl(404);return}if(s.ruri.scheme===xe.SIPS){s.reply_sl(416);return}if(jt.checkTransaction(this,s))return;if(i===xe.INVITE?new jt.InviteServerTransaction(this,this._transport,s):i!==xe.ACK&&i!==xe.CANCEL&&new jt.NonInviteServerTransaction(this,this._transport,s),i===xe.OPTIONS){if(this.listeners("newOptions").length===0){s.reply(200);return}new yf.Options(this).init_incoming(s)}else if(i===xe.MESSAGE){if(this.listeners("newMessage").length===0){s.reply(405);return}new yf.Message(this).init_incoming(s)}else if(i===xe.INVITE&&!s.to_tag&&this.listeners("newRTCSession").length===0){s.reply(405);return}let l,a;if(s.to_tag)if(l=this._findDialog(s.call_id,s.from_tag,s.to_tag),l)l.receiveRequest(s);else if(i===xe.NOTIFY)if(a=this._findSession(s),a)a.receiveRequest(s);else{if(s.body)try{const n=JSON.parse(s.body)||{};(e=(_=n.plugindata)==null?void 0:_.data)!=null&&e.publishers&&Object.values(this._janus_sessions)[0].receivePublishers(n),(g=(p=n.plugindata)==null?void 0:p.data)!=null&&g.unpublished&&Object.values(this._janus_sessions)[0].receiveUnpublished(n.plugindata.data.unpublished)}catch(n){console.error(n)}s.reply(200)}else i!==xe.ACK&&s.reply(481);else switch(i){case xe.INVITE:if(window.RTCPeerConnection)if(s.hasHeader("replaces")){const n=s.replaces;l=this._findDialog(n.call_id,n.from_tag,n.to_tag),l?(a=l.owner,a.isEnded()?s.reply(603):a.receiveRequest(s)):s.reply(481)}else s.body.search(/MSRP/ig)>-1?(a=new wu(this),a.init_incoming(s)):s.body.search(/JANUS/ig)>-1||(a=new vg(this),a.init_incoming(s));else _t.warn("INVITE received but WebRTC is not supported"),s.reply(488);break;case xe.BYE:s.reply(481);break;case xe.CANCEL:a=this._findSession(s),a?a.receiveRequest(s):_t.debug("received CANCEL request for a non existent session");break;case xe.ACK:break;case xe.NOTIFY:this.emit("sipEvent",{event:s.event,request:s}),s.reply(200);break;default:s.reply(405);break}}startMSRP(s,i){_t.debug("startMSRP()",i);const l=new wu(this);return l.connect(s),l}startJanus(s,i){_t.debug("startJanus()",i);const l=new wu(this);return l.connect(s),l}terminateMSRPSessions(s){_t.debug("terminateSessions()");for(const i in this._msrp_sessions)this._msrp_sessions[i].isEnded()||this._msrp_sessions[i].terminate(s)}terminateJanusSessions(s){_t.debug("terminateSessions()");for(const i in this._janus_sessions)this._janus_sessions[i].isEnded()||this._janus_sessions[i].terminate(s)}stop(){if(_t.debug("stop()"),this._dynConfiguration={},this._status===Ls.STATUS_USER_CLOSED){_t.debug("UA already closed");return}this._registrator.close();const s=Object.keys(this._sessions).length;for(const l in this._sessions)if(Object.prototype.hasOwnProperty.call(this._sessions,l)){_t.debug(`closing session ${l}`);try{this._sessions[l].terminate()}catch(a){console.error(a)}}for(const l in this._msrp_sessions)if(Object.prototype.hasOwnProperty.call(this._msrp_sessions,l)){_t.debug(`closing session ${l}`);try{this._msrp_sessions[l].terminate()}catch(a){console.error(a)}}for(const l in this._janus_sessions)if(Object.prototype.hasOwnProperty.call(this._janus_sessions,l)){_t.debug(`closing session ${l}`);try{this._janus_sessions[l].terminate()}catch(a){console.error(a)}}for(const l in this._applicants)if(Object.prototype.hasOwnProperty.call(this._applicants,l))try{this._applicants[l].close()}catch(a){console.error(a)}this._status=Ls.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&&s===0?this._transport.disconnect():this._closeTimer=setTimeout(()=>{this._closeTimer=null,this._transport.disconnect()},2e3)}}function RT(c){this.emit("connecting",c)}function IT(c){this._status!==Ls.STATUS_USER_CLOSED&&(this._status=Ls.STATUS_READY,this._error=null,this.emit("connected",c),this._dynConfiguration.register&&this._registrator.register())}function bT(c){const s=["nict","ict","nist","ist"];for(const i of s)for(const l in this._transactions[i])Object.prototype.hasOwnProperty.call(this._transactions[i],l)&&this._transactions[i][l].onTransportError();this.emit("disconnected",c),this._registrator.onTransportClosed(),this._status!==Ls.STATUS_USER_CLOSED&&(this._status=Ls.STATUS_NOT_READY,this._error=Ls.NETWORK_ERROR)}function wT(c){console.log("onTransportData",c);const s=c.transport;let i=c.message;if(i=ST.parseMessage(i,this),!i){console.log("if 1 return");return}if(this._status===Ls.STATUS_USER_CLOSED&&i instanceof un.IncomingRequest){console.log("if 2 return");return}if(!zg(i,this,s)){console.log("if 3 return");return}if(console.log("onTransportData message",i),console.log("onTransportData instanceof",i instanceof un.IncomingRequest),i instanceof un.IncomingRequest)i.transport=s,console.log("onTransportData receiveRequest"),this.receiveRequest(i);else if(i instanceof un.IncomingResponse){let l;switch(i.method){case xe.INVITE:l=this._transactions.ict[i.via_branch],l&&l.receiveResponse(i);break;case xe.ACK:break;default:l=this._transactions.nict[i.via_branch],l&&l.receiveResponse(i);break}}}const OT=["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"],DT=["_cancel_reason","_contact","direction","_end_time","_eventsCount","_from_tag","_id","_is_canceled","_is_confirmed","_late_sdp","status","start_time","_remote_identity","target_addr"];function T_(c){const s={};return OT.forEach(i=>{c[i]!==void 0&&(s[i]=c[i])}),s.localHold=c._localHold,s}function v_(c){const s={};return DT.forEach(i=>{c[i]!==void 0&&(s[i]=c[i])}),s}function E_(c,s){const i=new AudioContext,l=i.createMediaStreamSource(c),a=i.createMediaStreamDestination(),_=i.createGain();return l.connect(_),_.connect(a),_.gain.value=s,a.stream}function NT(c,s,i,l){const a=document.createElement("audio");a.id=s._id,a.className="audioTag",a.srcObject=c,S_()||(a.setSinkId(i),a.volume=l),a.play(),s.audioTag=a}function UT(c){if(c&&typeof c.log=="function"&&typeof c.warn=="function"&&typeof c.error=="function")return!0}function S_(){return/Mobi|Android|iPhone/i.test(navigator.userAgent)}const PT=ut,xT=Gt(),Pt=new PT("WebSocketInterface");var MT=class{constructor(s){Pt.debug('new() [url:"%s"]',s),this._url=s,this._sip_uri=null,this._via_transport=null,this._ws=null;const i=xT.parse(s,"absoluteURI");if(i===-1)throw Pt.warn(`invalid WebSocket URI: ${s}`),new TypeError(`Invalid argument: ${s}`);if(i.scheme!=="wss"&&i.scheme!=="ws")throw Pt.warn(`invalid WebSocket URI scheme: ${i.scheme}`),new TypeError(`Invalid argument: ${s}`);this._sip_uri=`sip:${i.host}${i.port?`:${i.port}`:""};transport=ws`,this._via_transport=i.scheme.toUpperCase()}get via_transport(){return this._via_transport}set via_transport(s){this._via_transport=s.toUpperCase()}get sip_uri(){return this._sip_uri}get url(){return this._url}connect(){if(Pt.debug("connect()"),this.isConnected()){Pt.debug(`WebSocket ${this._url} is already connected`);return}else if(this.isConnecting()){Pt.debug(`WebSocket ${this._url} is connecting`);return}this._ws&&this.disconnect(),Pt.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(s){this._onError(s)}}disconnect(){Pt.debug("disconnect()"),this._ws&&(this._ws.onopen=()=>{},this._ws.onclose=()=>{},this._ws.onmessage=()=>{},this._ws.onerror=()=>{},this._ws.close(),this._ws=null)}send(s){return Pt.debug("send()"),this.isConnected()?(this._ws.send(s),!0):(Pt.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(){Pt.debug(`WebSocket ${this._url} connected`),this.onconnect()}_onClose({wasClean:s,code:i,reason:l}){Pt.debug(`WebSocket ${this._url} closed`),s===!1&&Pt.debug("WebSocket abrupt disconnection"),this.ondisconnect(!s,i,l)}_onMessage({data:s}){Pt.debug("received WebSocket message"),this.ondata(s)}_onError(s){Pt.warn(`WebSocket ${this._url} error: `,s)}};const Du=pl,kT=xe,LT=gs,$T=Tt(),HT=p_,FT=ds(),jT=Xo(),qT=Gt(),VT=MT;Hn("JsSIP")("version %s",Du.version);var BT={C:kT,Exceptions:LT,Utils:$T,UA:HT,URI:FT,NameAddrHeader:jT,WebSocketInterface:VT,Grammar:qT,debug:Hn,get name(){return Du.title},get version(){return Du.version}};const GT=Le(BT);function Nu(c){return c<10?`0${c}`:`${c}`}function WT(c){let s=c.hours||0,i=c.minutes||0,l=c.seconds||0;l++,l===60&&(l=0,i++,i===60&&(i=0,s++));const a=`${Nu(s)}:${Nu(i)}:${Nu(l)}`;return{seconds:l,minutes:i,hours:s,formatted:a}}var At={};At.forEach=async(c,s,i)=>{const l=[];for(let a=0;a<c.length;a++)if(a in c){const _=Promise.resolve(c[a]).then(e=>s.call(i||globalThis,e,a,c));l.push(_)}await Promise.all(l)},At.forEachSeries=async(c,s,i)=>{for(let l=0;l<c.length;l++)l in c&&await s.call(i||globalThis,await c[l],l,c)},At.map=async(c,s,i)=>{const l=[];for(let a=0;a<c.length;a++)a in c&&(l[a]=Promise.resolve(c[a]).then(_=>s.call(i||globalThis,_,a,c)));return Promise.all(l)},At.mapSeries=async(c,s,i)=>{const l=[];for(let a=0;a<c.length;a++)a in c&&(l[a]=await s.call(i||globalThis,await c[a],a,c));return l},At.find=(c,s,i)=>new Promise((l,a)=>{if(c.length===0)return l();let _=1;for(let e=0;e<c.length;e++){const p=g=>{g?l(c[e]):_===c.length&&l(),_++};Promise.resolve(c[e]).then(g=>s.call(i||globalThis,g,e,c)).then(p).catch(a)}}),At.findSeries=async(c,s,i)=>{for(let l=0;l<c.length;l++)if(await s.call(i||globalThis,await c[l],l,c))return c[l]},At.findIndex=(c,s,i)=>new Promise((l,a)=>{if(c.length===0)return l(-1);let _=1;for(let e=0;e<c.length;e++){const p=g=>{g?l(e):_===c.length&&l(-1),_++};Promise.resolve(c[e]).then(g=>s.call(i||globalThis,g,e,c)).then(p).catch(a)}}),At.findIndexSeries=async(c,s,i)=>{for(let l=0;l<c.length;l++)if(await s.call(i||globalThis,await c[l],l,c))return l},At.some=(c,s,i)=>new Promise((l,a)=>{if(c.length===0)return l(!1);let _=1;for(let e=0;e<c.length;e++){if(!(e in c)){_++;continue}const p=g=>{g?l(!0):_===c.length&&l(!1),_++};Promise.resolve(c[e]).then(g=>s.call(i||globalThis,g,e,c)).then(p).catch(a)}}),At.someSeries=async(c,s,i)=>{for(let l=0;l<c.length;l++)if(l in c&&await s.call(i||globalThis,await c[l],l,c))return!0;return!1},At.every=(c,s,i)=>new Promise((l,a)=>{if(c.length===0)return l(!0);let _=1;for(let e=0;e<c.length;e++){if(!(e in c)){_++;continue}const p=g=>{g?_===c.length&&l(!0):l(!1),_++};Promise.resolve(c[e]).then(g=>s.call(i||globalThis,g,e,c)).then(p).catch(a)}}),At.everySeries=async(c,s,i)=>{for(let l=0;l<c.length;l++)if(l in c&&!await s.call(i||globalThis,await c[l],l,c))return!1;return!0},At.filter=(c,s,i)=>new Promise(async(l,a)=>{const _=[];for(let p=0;p<c.length;p++)p in c&&(_[p]=Promise.resolve(c[p]).then(g=>s.call(i||globalThis,g,p,c)).catch(a));const e=[];for(let p=0;p<_.length;p++)await _[p]&&e.push(await c[p]);l(e)}),At.filterSeries=async(c,s,i)=>{const l=[];for(let a=0;a<c.length;a++)a in c&&await s.call(i||globalThis,await c[a],a,c)&&l.push(await c[a]);return l},At.reduce=async(c,s,i)=>{if(c.length===0&&i===void 0)throw TypeError("Reduce of empty array with no initial value");let l,a;for(i!==void 0?(a=i,l=0):(a=c[0],l=1),l;l<c.length;l++)l in c&&(a=await s(await a,await c[l],l,c));return a};var y_={};(function(c){const s=At;Object.keys(s).forEach(i=>{const l=i.charAt(0).toUpperCase()+i.slice(1);c[`async${l}`]=async function(...a){return s[i](this,...a)}})})(y_);var KT=Object.assign(At,{instanceMethods:y_});const dn=new AudioContext,Kt={NEW_CALL:"new_call",CALL_CONFIRMED:"confirmed",CALL_FAILED:"failed",CALL_PROGRESS:"progress",CALL_ENDED:"ended"};var YT={exports:{}};(function(c){var s=function(i){var l=Object.prototype,a=l.hasOwnProperty,_=Object.defineProperty||function(N,z,re){N[z]=re.value},e,p=typeof Symbol=="function"?Symbol:{},g=p.iterator||"@@iterator",n=p.asyncIterator||"@@asyncIterator",v=p.toStringTag||"@@toStringTag";function S(N,z,re){return Object.defineProperty(N,z,{value:re,enumerable:!0,configurable:!0,writable:!0}),N[z]}try{S({},"")}catch{S=function(z,re,ae){return z[re]=ae}}function m(N,z,re,ae){var Te=z&&z.prototype instanceof oe?z:oe,De=Object.create(Te.prototype),Ce=new U(ae||[]);return _(De,"_invoke",{value:j(N,re,Ce)}),De}i.wrap=m;function C(N,z,re){try{return{type:"normal",arg:N.call(z,re)}}catch(ae){return{type:"throw",arg:ae}}}var A="suspendedStart",R="suspendedYield",I="executing",V="completed",W={};function oe(){}function x(){}function $(){}var Re={};S(Re,g,function(){return this});var be=Object.getPrototypeOf,H=be&&be(be(se([])));H&&H!==l&&a.call(H,g)&&(Re=H);var D=$.prototype=oe.prototype=Object.create(Re);x.prototype=$,_(D,"constructor",{value:$,configurable:!0}),_($,"constructor",{value:x,configurable:!0}),x.displayName=S($,v,"GeneratorFunction");function L(N){["next","throw","return"].forEach(function(z){S(N,z,function(re){return this._invoke(z,re)})})}i.isGeneratorFunction=function(N){var z=typeof N=="function"&&N.constructor;return z?z===x||(z.displayName||z.name)==="GeneratorFunction":!1},i.mark=function(N){return Object.setPrototypeOf?Object.setPrototypeOf(N,$):(N.__proto__=$,S(N,v,"GeneratorFunction")),N.prototype=Object.create(D),N},i.awrap=function(N){return{__await:N}};function q(N,z){function re(De,Ce,He,we){var Se=C(N[De],N,Ce);if(Se.type==="throw")we(Se.arg);else{var ot=Se.arg,Ue=ot.value;return Ue&&typeof Ue=="object"&&a.call(Ue,"__await")?z.resolve(Ue.__await).then(function(le){re("next",le,He,we)},function(le){re("throw",le,He,we)}):z.resolve(Ue).then(function(le){ot.value=le,He(ot)},function(le){return re("throw",le,He,we)})}}var ae;function Te(De,Ce){function He(){return new z(function(we,Se){re(De,Ce,we,Se)})}return ae=ae?ae.then(He,He):He()}_(this,"_invoke",{value:Te})}L(q.prototype),S(q.prototype,n,function(){return this}),i.AsyncIterator=q,i.async=function(N,z,re,ae,Te){Te===void 0&&(Te=Promise);var De=new q(m(N,z,re,ae),Te);return i.isGeneratorFunction(z)?De:De.next().then(function(Ce){return Ce.done?Ce.value:De.next()})};function j(N,z,re){var ae=A;return function(De,Ce){if(ae===I)throw new Error("Generator is already running");if(ae===V){if(De==="throw")throw Ce;return Dt()}for(re.method=De,re.arg=Ce;;){var He=re.delegate;if(He){var we=B(He,re);if(we){if(we===W)continue;return we}}if(re.method==="next")re.sent=re._sent=re.arg;else if(re.method==="throw"){if(ae===A)throw ae=V,re.arg;re.dispatchException(re.arg)}else re.method==="return"&&re.abrupt("return",re.arg);ae=I;var Se=C(N,z,re);if(Se.type==="normal"){if(ae=re.done?V:R,Se.arg===W)continue;return{value:Se.arg,done:re.done}}else Se.type==="throw"&&(ae=V,re.method="throw",re.arg=Se.arg)}}}function B(N,z){var re=z.method,ae=N.iterator[re];if(ae===e)return z.delegate=null,re==="throw"&&N.iterator.return&&(z.method="return",z.arg=e,B(N,z),z.method==="throw")||re!=="return"&&(z.method="throw",z.arg=new TypeError("The iterator does not provide a '"+re+"' method")),W;var Te=C(ae,N.iterator,z.arg);if(Te.type==="throw")return z.method="throw",z.arg=Te.arg,z.delegate=null,W;var De=Te.arg;if(!De)return z.method="throw",z.arg=new TypeError("iterator result is not an object"),z.delegate=null,W;if(De.done)z[N.resultName]=De.value,z.next=N.nextLoc,z.method!=="return"&&(z.method="next",z.arg=e);else return De;return z.delegate=null,W}L(D),S(D,v,"Generator"),S(D,g,function(){return this}),S(D,"toString",function(){return"[object Generator]"});function Q(N){var z={tryLoc:N[0]};1 in N&&(z.catchLoc=N[1]),2 in N&&(z.finallyLoc=N[2],z.afterLoc=N[3]),this.tryEntries.push(z)}function Z(N){var z=N.completion||{};z.type="normal",delete z.arg,N.completion=z}function U(N){this.tryEntries=[{tryLoc:"root"}],N.forEach(Q,this),this.reset(!0)}i.keys=function(N){var z=Object(N),re=[];for(var ae in z)re.push(ae);return re.reverse(),function Te(){for(;re.length;){var De=re.pop();if(De in z)return Te.value=De,Te.done=!1,Te}return Te.done=!0,Te}};function se(N){if(N){var z=N[g];if(z)return z.call(N);if(typeof N.next=="function")return N;if(!isNaN(N.length)){var re=-1,ae=function Te(){for(;++re<N.length;)if(a.call(N,re))return Te.value=N[re],Te.done=!1,Te;return Te.value=e,Te.done=!0,Te};return ae.next=ae}}return{next:Dt}}i.values=se;function Dt(){return{value:e,done:!0}}return U.prototype={constructor:U,reset:function(N){if(this.prev=0,this.next=0,this.sent=this._sent=e,this.done=!1,this.delegate=null,this.method="next",this.arg=e,this.tryEntries.forEach(Z),!N)for(var z in this)z.charAt(0)==="t"&&a.call(this,z)&&!isNaN(+z.slice(1))&&(this[z]=e)},stop:function(){this.done=!0;var N=this.tryEntries[0],z=N.completion;if(z.type==="throw")throw z.arg;return this.rval},dispatchException:function(N){if(this.done)throw N;var z=this;function re(we,Se){return De.type="throw",De.arg=N,z.next=we,Se&&(z.method="next",z.arg=e),!!Se}for(var ae=this.tryEntries.length-1;ae>=0;--ae){var Te=this.tryEntries[ae],De=Te.completion;if(Te.tryLoc==="root")return re("end");if(Te.tryLoc<=this.prev){var Ce=a.call(Te,"catchLoc"),He=a.call(Te,"finallyLoc");if(Ce&&He){if(this.prev<Te.catchLoc)return re(Te.catchLoc,!0);if(this.prev<Te.finallyLoc)return re(Te.finallyLoc)}else if(Ce){if(this.prev<Te.catchLoc)return re(Te.catchLoc,!0)}else if(He){if(this.prev<Te.finallyLoc)return re(Te.finallyLoc)}else throw new Error("try statement without catch or finally")}}},abrupt:function(N,z){for(var re=this.tryEntries.length-1;re>=0;--re){var ae=this.tryEntries[re];if(ae.tryLoc<=this.prev&&a.call(ae,"finallyLoc")&&this.prev<ae.finallyLoc){var Te=ae;break}}Te&&(N==="break"||N==="continue")&&Te.tryLoc<=z&&z<=Te.finallyLoc&&(Te=null);var De=Te?Te.completion:{};return De.type=N,De.arg=z,Te?(this.method="next",this.next=Te.finallyLoc,W):this.complete(De)},complete:function(N,z){if(N.type==="throw")throw N.arg;return N.type==="break"||N.type==="continue"?this.next=N.arg:N.type==="return"?(this.rval=this.arg=N.arg,this.method="return",this.next="end"):N.type==="normal"&&z&&(this.next=z),W},finish:function(N){for(var z=this.tryEntries.length-1;z>=0;--z){var re=this.tryEntries[z];if(re.finallyLoc===N)return this.complete(re.completion,re.afterLoc),Z(re),W}},catch:function(N){for(var z=this.tryEntries.length-1;z>=0;--z){var re=this.tryEntries[z];if(re.tryLoc===N){var ae=re.completion;if(ae.type==="throw"){var Te=ae.arg;Z(re)}return Te}}throw new Error("illegal catch attempt")},delegateYield:function(N,z,re){return this.delegate={iterator:se(N),resultName:z,nextLoc:re},this.method==="next"&&(this.arg=e),W}},i}(c.exports);try{regeneratorRuntime=s}catch{typeof globalThis=="object"?globalThis.regeneratorRuntime=s:Function("r","regeneratorRuntime = r")(s)}})(YT);var A_={exports:{}};(function(c){(function(s,i){c.exports?c.exports=i():s.log=i()})(sn,function(){var s=function(){},i="undefined",l=typeof window!==i&&typeof window.navigator!==i&&/Trident\/|MSIE /.test(window.navigator.userAgent),a=["trace","debug","info","warn","error"];function _(R,I){var V=R[I];if(typeof V.bind=="function")return V.bind(R);try{return Function.prototype.bind.call(V,R)}catch{return function(){return Function.prototype.apply.apply(V,[R,arguments])}}}function e(){console.log&&(console.log.apply?console.log.apply(console,arguments):Function.prototype.apply.apply(console.log,[console,arguments])),console.trace&&console.trace()}function p(R){return R==="debug"&&(R="log"),typeof console===i?!1:R==="trace"&&l?e:console[R]!==void 0?_(console,R):console.log!==void 0?_(console,"log"):s}function g(R,I){for(var V=0;V<a.length;V++){var W=a[V];this[W]=V<R?s:this.methodFactory(W,R,I)}this.log=this.debug}function n(R,I,V){return function(){typeof console!==i&&(g.call(this,I,V),this[R].apply(this,arguments))}}function v(R,I,V){return p(R)||n.apply(this,arguments)}function S(R,I,V){var W=this,oe;I=I??"WARN";var x="loglevel";typeof R=="string"?x+=":"+R:typeof R=="symbol"&&(x=void 0);function $(D){var L=(a[D]||"silent").toUpperCase();if(!(typeof window===i||!x)){try{window.localStorage[x]=L;return}catch{}try{window.document.cookie=encodeURIComponent(x)+"="+L+";"}catch{}}}function Re(){var D;if(!(typeof window===i||!x)){try{D=window.localStorage[x]}catch{}if(typeof D===i)try{var L=window.document.cookie,q=L.indexOf(encodeURIComponent(x)+"=");q!==-1&&(D=/^([^;]+)/.exec(L.slice(q))[1])}catch{}return W.levels[D]===void 0&&(D=void 0),D}}function be(){if(!(typeof window===i||!x)){try{window.localStorage.removeItem(x);return}catch{}try{window.document.cookie=encodeURIComponent(x)+"=; expires=Thu, 01 Jan 1970 00:00:00 UTC"}catch{}}}W.name=R,W.levels={TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,SILENT:5},W.methodFactory=V||v,W.getLevel=function(){return oe},W.setLevel=function(D,L){if(typeof D=="string"&&W.levels[D.toUpperCase()]!==void 0&&(D=W.levels[D.toUpperCase()]),typeof D=="number"&&D>=0&&D<=W.levels.SILENT){if(oe=D,L!==!1&&$(D),g.call(W,D,R),typeof console===i&&D<W.levels.SILENT)return"No console available for logging"}else throw"log.setLevel() called with invalid level: "+D},W.setDefaultLevel=function(D){I=D,Re()||W.setLevel(D,!1)},W.resetLevel=function(){W.setLevel(I,!1),be()},W.enableAll=function(D){W.setLevel(W.levels.TRACE,D)},W.disableAll=function(D){W.setLevel(W.levels.SILENT,D)};var H=Re();H==null&&(H=I),W.setLevel(H,!1)}var m=new S,C={};m.getLogger=function(I){if(typeof I!="symbol"&&typeof I!="string"||I==="")throw new TypeError("You must supply a name when creating a logger.");var V=C[I];return V||(V=C[I]=new S(I,m.getLevel(),m.methodFactory)),V};var A=typeof window!==i?window.log:void 0;return m.noConflict=function(){return typeof window!==i&&window.log===m&&(window.log=A),m},m.getLoggers=function(){return C},m.default=m,m})})(A_);var wt=A_.exports;const vs=()=>`${new Date().toISOString()} | metrics`,Es=(c,s,i)=>`${c} | ${s} | ${i}`;wt.setDefaultLevel(wt.levels.TRACE);const JT=c=>{wt.info(Es(vs(),"log ",`set log level to ${c?"verbose":"info"}`)),wt.setLevel(c?wt.levels.TRACE:wt.levels.INFO)},zT=c=>{const s=[...Object.keys(wt.levels)];s.includes(c)?(wt.info(Es(vs(),"log ",`update log level to ${c.toLowerCase()}`)),wt.setLevel(c)):wt.warn(Es(vs(),"log ","Incorrect log level please choose one of "),s)},ke=(c,s,i)=>{i?wt.debug(Es(vs(),c,s),i):wt.debug(Es(vs(),c,s))},Uu=(c,s)=>{wt.info(Es(vs(),c,s))},pn=(c,s)=>{wt.info(Es(vs(),c,s))},Sa=(c,s)=>{wt.warn(Es(vs(),c,s))},zn=(c,s)=>{wt.error(Es(vs(),c,s))};function XT(c){return Math.floor(Math.random()*c).toString()}function C_(c,s){let i=s;return c.forEach(l=>{i=i.replace(l,"")}),i}function QT(c,s){let i="";for(let l=0;l<s;l+=1)i+=c[XT(c.length)];return i}function ZT({length:c=20,useLetters:s=!0,useNumbers:i=!0,includeSymbols:l=[],excludeSymbols:a=[]}={}){let _="abcdefghijklmnopqrstuvwxyz",e="0123456789",p=[],g=[],n=[];return s&&(a.length&&(_=C_(a,_)),g=_.split("")),i&&(a.length&&(e=C_(a,e)),n=e.split("")),p=[...g,...n,...l],QT(p,c)}var ev=ZT;const Jr=Le(ev),tv=()=>"WebRTCMetrics",sv=()=>"5.0.3",Ve={INBOUND:"inbound",OUTBOUND:"outbound"},Ss={IDLE:"idle",RUNNING:"running",MUTED:"muted"},zr={NEW:"new",CHECKING:"checking",CONNECTED:"connected",COMPLETED:"completed",DISCONNECTED:"disconnected",FAILED:"failed",CLOSED:"closed"},nv=()=>({...{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:[]}}),R_={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:Ve.INBOUND},I_={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:Ve.OUTBOUND},b_={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:Ve.INBOUND},w_={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:Ve.OUTBOUND},rv=c=>{const s={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 i={...c,audio:{},video:{},data:{...c.data},network:{...c.network},experimental:{...c.experimental}};return Object.keys(c.audio).forEach(l=>{i.audio[l]={...c.audio[l]}}),Object.keys(c.video).forEach(l=>{i.video[l]={...c.video[l]}}),i}return{...s,audio:{},video:{},data:{...s.data},network:{...s.network},experimental:{...s.experimental}}},iv={refreshEvery:2e3,startAfter:0,stopAfter:-1,verbose:!1,pname:`p-${Jr()}`,cid:`c-${Jr()}`,uid:`u-${Jr()}`,record:!1,ticket:!0},Yt={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"},K={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"},M={SUCCEEDED:"succeeded",AUDIO:"audio",VIDEO:"video"},Xr={ETHERNET:0,CELLULAR_5G:2,WIFI:3,CELLULAR_4G:5,CELLULAR:10},Pu={ETHERNET:"ethernet",CELLULAR_4G:"cellular",WIFI:"wifi"},ie={AUDIO:"audio",VIDEO:"video",NETWORK:"network",DATA:"data"},xu="config ",lv=(c,s={},i)=>{const l={...i,...s};return s.pname||Sa(xu,`Argument [String] 'cfg.pname' for the peerConnection name or id is missing - use generated '${i.pname}'`),s.cid||Sa(xu,`Argument [String] 'cfg.cid' for the call name or id is missing - use generated '${i.cid}'`),s.uid||Sa(xu,`Argument [String] 'cfg.uid' for the user name or id is missing - use generated '${i.uid}'`),l.pc=c,l},av=(c={})=>{const s={...iv,...c};return s.name=tv(),s.version=sv(),s},Qr=(c,s,i,l=!1,a)=>{let _=c.map(e=>{if(!i)return e[s];if(!a)return e[s][i];const p=e[s][a];return p?p[i]:null});return _=_.filter(e=>l?Number.isFinite(e)&&e>0:Number.isFinite(e)),_.length===0?[]:_},$s=c=>c.reduce((s,i)=>s+i,0)/c.length,ov=()=>`probe-${Jr()}`,uv=()=>`coltr-${Jr()}`,O_=c=>new Promise(s=>setTimeout(s,c)),Mu=(c,s,i)=>{s?c.call(s,i):c(i)},Xe=(c,s,i,l)=>{const a=Qr(c,s,i,!0,l);if(a.length===0)return null;const _=a.reduce((n,v)=>n+v,0)/a.length;return _===0?null:a.map(n=>Math.abs(_-n)).reduce((n,v)=>n+v,0)/a.length*100/_},st=(c,s,i,l=!1,a)=>{const _=Qr(c,s,i,l,a);return _.length===0?null:_.reduce((e,p)=>e+p,0)/_.length},mn=(c,s,i)=>Qr(c,s,i).reduce((a,_)=>a+_,0),Qe=(c,s,i,l)=>{const a=Qr(c,s,i,!0,l);return a.length===0?null:Math.min(...a)},Ze=(c,s,i,l)=>{const a=Qr(c,s,i,!1,l);return a.length===0?null:Math.max(...a)},Ct=(c,s,i,l)=>{const a=c.slice().pop();if(!a)return null;if(!i)return a[s];if(!l)return a[s][i];const _=a[s][l];return _?_[i]:null},cv=c=>c.slice().pop(),ht=(c,s,i)=>{if(!s)return null;const l={};let a=s[M.AUDIO][c];a||(a=i===Ve.INBOUND?{...R_}:{...I_}),l[M.AUDIO]=a;let _=s[M.VIDEO][c];return _||(_=i===Ve.INBOUND?{...b_}:{...w_}),l[M.VIDEO]=_,l},Zr="exporter ",fv="2.0",D_=(c,s,i)=>{if(!c||c.length===0)return 0;const l=c[c.length-1];if(!l)return 0;const a=l[s][i];if(a){const _=a.total_rtt_ms_out,e=a.total_rtt_measure_out;return!e||!_?st(c,s,"delta_rtt_ms_out",!1,i):Number(_/e)}return null},_v=(c,s)=>{if(!c||c.length===0)return 0;const i=c[c.length-1];if(!i)return 0;const l=i[s].total_rtt_connectivity_ms,a=i[s].total_rtt_connectivity_measure;return!a||!l?st(c,s,"delta_rtt_connectivity_ms"):Number(l/a)},hv=c=>Ct(c,"network","local_candidate_type")!=="relay"?`direct/${Ct(c,"network","local_candidate_protocol")}`:`turn/${Ct(c,"network","local_candidate_relay_protocol")}`,dv=c=>{const s=Ct(c,"network","remote_candidate_type"),i=Ct(c,"network","remote_candidate_protocol");return s!=="relay"?`direct/${i}`:`turn/${i}`};class pv{constructor(s){this._start=null,this._end=null,this._cfg=s,this._referenceReport=null,this._reports=[],this._events=[]}start(){Uu(Zr,"start() - start exporter...");const s=new Date;return this._start=s.toJSON(),s}stop(){Uu(Zr,"stop() - stop exporter...");const s=new Date;return this._end=s.toJSON(),s}saveReferenceReport(s){this._referenceReport=s}getReferenceReport(){return this._referenceReport}addReport(s){this._cfg.ticket&&(ke(Zr,`addReport() - add report to exporter at ${s.timestamp}`),this._reports.push(s))}addCustomEvent(s){this._events.push(s)}reset(){Uu(Zr,"resetReports() - reset reports"),this._reports=[],this._referenceReport=null,this._start=null,this._end=null}get ticket(){ke(Zr,"ticket() - generate ticket");const s=Ct(this._reports,"audio","total_packets_lost_in"),i=Ct(this._reports,"audio","total_packets_in"),l=Ct(this._reports,"video","total_packets_lost_in"),a=Ct(this._reports,"video","total_packets_in"),_={},e=cv(this._reports);return e&&(Object.keys(e[M.AUDIO]).forEach(p=>{const g=e[M.AUDIO][p];if(_[g.ssrc]={type:M.AUDIO,direction:g.direction},g.direction===Ve.INBOUND){const n={avg:st(this._reports,M.AUDIO,"delta_jitter_ms_in",!1,p),min:Qe(this._reports,M.AUDIO,"delta_jitter_ms_in",p),max:Ze(this._reports,M.AUDIO,"delta_jitter_ms_in",p),volatility:Xe(this._reports,M.AUDIO,"delta_jitter_ms_in",p),_unit:{avg:"ms",min:"ms",max:"ms",volatility:"percent"}},v={avg:st(this._reports,M.AUDIO,"delta_kbs_in",!1,p),min:Qe(this._reports,M.AUDIO,"delta_kbs_in",p),max:Ze(this._reports,M.AUDIO,"delta_kbs_in",p),volatility:Xe(this._reports,M.AUDIO,"delta_kbs_in",p),_unit:{avg:"kbs",min:"kbs",max:"kbs",volatility:"percent"}},S={avg:st(this._reports,M.AUDIO,"delta_KBytes_in",!1,p),min:Qe(this._reports,M.AUDIO,"delta_KBytes_in",p),max:Ze(this._reports,M.AUDIO,"delta_KBytes_in",p),volatility:Xe(this._reports,M.AUDIO,"delta_KBytes_in",p),_unit:{avg:"KB",min:"KB",max:"KB",volatility:"percent"}},m={emodel:{avg:st(this._reports,M.AUDIO,"mos_emodel_in",!1,p),min:Qe(this._reports,M.AUDIO,"mos_emodel_in",p),max:Ze(this._reports,M.AUDIO,"mos_emodel_in",p),volatility:Xe(this._reports,M.AUDIO,"mos_emodel_in",p)},effective:{avg:st(this._reports,M.AUDIO,"mos_in",!1,p),min:Qe(this._reports,M.AUDIO,"mos_in",p),max:Ze(this._reports,M.AUDIO,"mos_in",p),volatility:Xe(this._reports,M.AUDIO,"mos_in",p)},_unit:{avg:"number (1-5)",min:"number (1-5)",max:"number (1-5)",volatility:"percent"}},C=Ct(this._reports,M.AUDIO,"total_packets_lost_in",p),A=Ct(this._reports,M.AUDIO,"total_packets_in",p),R={lost:C,avg:Math.round((C/(C+A)*100||0)*100)/100,_unit:{avg:"percent",lost:"number"}};_[p].jitter=n,_[p].mos=m,_[p].traffic=S,_[p].bitrate=v,_[p].loss=R}else{const n={avg:st(this._reports,M.AUDIO,"delta_jitter_ms_out",!1,p),min:Qe(this._reports,M.AUDIO,"delta_jitter_ms_out",p),max:Ze(this._reports,M.AUDIO,"delta_jitter_ms_out",p),volatility:Xe(this._reports,M.AUDIO,"delta_jitter_ms_out",p),_unit:{avg:"ms",min:"ms",max:"ms",volatility:"percent"}},v={avg:st(this._reports,M.AUDIO,"delta_kbs_out",!1,p),min:Qe(this._reports,M.AUDIO,"delta_kbs_out",p),max:Ze(this._reports,M.AUDIO,"delta_kbs_out",p),volatility:Xe(this._reports,M.AUDIO,"delta_kbs_out",p),_unit:{avg:"kbs",min:"kbs",max:"kbs",volatility:"percent"}},S={avg:st(this._reports,M.AUDIO,"delta_KBytes_out",!1,p),min:Qe(this._reports,M.AUDIO,"delta_KBytes_out",p),max:Ze(this._reports,M.AUDIO,"delta_KBytes_out",p),volatility:Xe(this._reports,M.AUDIO,"delta_KBytes_out",p),_unit:{avg:"KB",min:"KB",max:"KB",bitrate:"kbs",volatility:"percent"}},m={avg:D_(this._reports,M.AUDIO,p),min:Qe(this._reports,M.AUDIO,"delta_rtt_ms_out",p),max:Ze(this._reports,M.AUDIO,"delta_rtt_ms_out",p),volatility:Xe(this._reports,M.AUDIO,"delta_rtt_ms_out",p),_unit:{avg:"ms",min:"ms",max:"ms",volatility:"percent"}},C=Ct(this._reports,M.AUDIO,"total_packets_lost_out",p),A=Ct(this._reports,M.AUDIO,"total_packets_out",p),R={lost:C,avg:Math.round((C/(C+A)*100||0)*100)/100,_unit:{avg:"percent",lost:"number"}},I={emodel:{avg:st(this._reports,M.AUDIO,"mos_emodel_out",!1,p),min:Qe(this._reports,M.AUDIO,"mos_emodel_out",p),max:Ze(this._reports,M.AUDIO,"mos_emodel_out",p),volatility:Xe(this._reports,M.AUDIO,"mos_emodel_out",p)},effective:{avg:st(this._reports,M.AUDIO,"mos_out",!1,p),min:Qe(this._reports,M.AUDIO,"mos_out",p),max:Ze(this._reports,M.AUDIO,"mos_out",p),volatility:Xe(this._reports,M.AUDIO,"mos_out",p)},_unit:{avg:"number (1-5)",min:"number (1-5)",max:"number (1-5)",volatility:"percent"}};_[p].jitter=n,_[p].rtt=m,_[p].traffic=S,_[p].bitrate=v,_[p].loss=R,_[p].mos=I}}),Object.keys(e[M.VIDEO]).forEach(p=>{const g=e[M.VIDEO][p];if(_[p]={type:M.VIDEO,direction:g.direction},g.direction===Ve.INBOUND){const n={avg:st(this._reports,M.VIDEO,"delta_jitter_ms_in",!1,p),min:Qe(this._reports,M.VIDEO,"delta_jitter_ms_in",p),max:Ze(this._reports,M.VIDEO,"delta_jitter_ms_in",p),volatility:Xe(this._reports,M.VIDEO,"delta_jitter_ms_in",p),_unit:{avg:"ms",min:"ms",max:"ms",volatility:"percent"}},v={avg:st(this._reports,M.VIDEO,"delta_kbs_in",!1,p),min:Qe(this._reports,M.VIDEO,"delta_kbs_in",p),max:Ze(this._reports,M.VIDEO,"delta_kbs_in",p),volatility:Xe(this._reports,M.VIDEO,"delta_kbs_in",p),_unit:{avg:"kbs",min:"kbs",max:"kbs",volatility:"percent"}},S={avg:st(this._reports,M.VIDEO,"delta_KBytes_in",!1,p),min:Qe(this._reports,M.VIDEO,"delta_KBytes_in",p),max:Ze(this._reports,M.VIDEO,"delta_KBytes_in",p),volatility:Xe(this._reports,M.VIDEO,"delta_KBytes_in",p),_unit:{avg:"KB",min:"KB",max:"KB",volatility:"percent"}},m=Ct(this._reports,M.VIDEO,"total_packets_lost_in",p),C=Ct(this._reports,M.VIDEO,"total_packets_in",p),A={lost:m,avg:Math.round((m/(m+C)*100||0)*100)/100,_unit:{avg:"percent",lost:"number"}};_[p].jitter=n,_[p].traffic=S,_[p].bitrate=v,_[p].loss=A}else{const n={avg:st(this._reports,M.VIDEO,"delta_jitter_ms_out",!1,p),min:Qe(this._reports,M.VIDEO,"delta_jitter_ms_out",p),max:Ze(this._reports,M.VIDEO,"delta_jitter_ms_out",p),volatility:Xe(this._reports,M.VIDEO,"delta_jitter_ms_out",p),_unit:{avg:"ms",min:"ms",max:"ms",volatility:"percent"}},v={avg:st(this._reports,M.VIDEO,"delta_kbs_out",!1,p),min:Qe(this._reports,M.VIDEO,"delta_kbs_out",p),max:Ze(this._reports,M.VIDEO,"delta_kbs_out",p),volatility:Xe(this._reports,M.VIDEO,"delta_kbs_out",p),_unit:{avg:"kbs",min:"kbs",max:"kbs",volatility:"percent"}},S={avg:st(this._reports,M.VIDEO,"delta_KBytes_out",!1,p),min:Qe(this._reports,M.VIDEO,"delta_KBytes_out",p),max:Ze(this._reports,M.VIDEO,"delta_KBytes_out",p),volatility:Xe(this._reports,M.VIDEO,"delta_KBytes_out",p),_unit:{avg:"KB",min:"KB",max:"KB",volatility:"percent"}},m={avg:D_(this._reports,M.VIDEO,p),min:Qe(this._reports,M.VIDEO,"delta_rtt_ms_out",p),max:Ze(this._reports,M.VIDEO,"delta_rtt_ms_out",p),volatility:Xe(this._reports,M.VIDEO,"delta_rtt_ms_out",p),_unit:{avg:"ms",min:"ms",max:"ms",volatility:"percent"}},C=Ct(this._reports,M.VIDEO,"total_packets_lost_out",p),A=Ct(this._reports,M.VIDEO,"total_packets_out",p),R={lost:C,avg:Math.round((C/(C+A)*100||0)*100)/100,_unit:{avg:"percent",lost:"number"}};_[p].jitter=n,_[p].rtt=m,_[p].traffic=S,_[p].bitrate=v,_[p].loss=R}})),{version:fv,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:_,data:{rtt:{avg:_v(this._reports,"data"),min:Qe(this._reports,"data","delta_rtt_connectivity_ms"),max:Ze(this._reports,"data","delta_rtt_connectivity_ms"),volatility:Xe(this._reports,"data","delta_rtt_connectivity_ms"),_unit:{avg:"ms",min:"ms",max:"ms",volatility:"percent"}},packetsLost:{audio:{in:{avg:Math.round((s/(s+i)*100||0)*100)/100}},video:{in:{avg:Math.round((l/(l+a)*100||0)*100)/100}},unit:{avg:"percent"}},bitrate:{in:{avg:st(this._reports,"data","delta_kbs_in"),min:Qe(this._reports,"data","delta_kbs_in"),max:Ze(this._reports,"data","delta_kbs_in"),volatility:Xe(this._reports,"data","delta_kbs_in")},out:{avg:st(this._reports,"data","delta_kbs_out"),min:Qe(this._reports,"data","delta_kbs_out"),max:Ze(this._reports,"data","delta_kbs_out"),volatility:Xe(this._reports,"data","delta_kbs_out")},unit:{avg:"kbs",min:"kbs",max:"kbs",volatility:"percent"}},traffic:{in:{avg:st(this._reports,"data","delta_KBytes_in"),min:Qe(this._reports,"data","delta_KBytes_in"),max:Ze(this._reports,"data","delta_KBytes_in"),volatility:Xe(this._reports,"data","delta_KBytes_in")},out:{avg:st(this._reports,"data","delta_KBytes_out"),min:Qe(this._reports,"data","delta_KBytes_out"),max:Ze(this._reports,"data","delta_KBytes_out"),volatility:Xe(this._reports,"data","delta_KBytes_out")},unit:{avg:"KBytes",min:"KBytes",max:"KBytes",volatility:"percent"}},network:{localConnection:hv(this._reports),remoteConnection:dv(this._reports)}}}}updateConfig(s){this._cfg=s}getLastReport(){return this._reports.slice().pop()||null}getBeforeLastReport(){const s=this._reports.slice();return s.pop(),s.pop()||null}getReportsNumber(){return this._reports.length}}const Hs="extractor ",N_=(c,s,i,l)=>{let a=!1;const _=l[s].total_rtt_ms_out,e=l[s].total_rtt_measure_out,p=i?i[s].total_rtt_ms_out:0,g=i?i[s].total_rtt_measure_out:0,n={rtt:null,totalRTT:_,totalRTTMeasurements:e};if(c[K.TIMESTAMP]===l[s].timestamp_out||!Object.prototype.hasOwnProperty.call(c,K.ROUND_TRIP_TIME)||Object.prototype.hasOwnProperty.call(c,K.TOTAL_ROUND_TRIP_TIME_MEASUREMENTS)&&(a=!0,Number(c[K.TOTAL_ROUND_TRIP_TIME_MEASUREMENTS])===0||Number(c[K.TOTAL_ROUND_TRIP_TIME_MEASUREMENTS])-g===e))return n;const v=1e3*Number(c[K.ROUND_TRIP_TIME]);let S=_+v,m=e+1;return a&&(S=1e3*Number(c[K.TOTAL_ROUND_TRIP_TIME])-p,m=Number(c[K.TOTAL_ROUND_TRIP_TIME_MEASUREMENTS])-g),{rtt:v,totalRTT:S,totalRTTMeasurements:m}},mv=(c,s,i,l)=>{if(!Object.prototype.hasOwnProperty.call(c,K.CURRENT_ROUND_TRIP_TIME))return{rtt:null,totalRTT:l[s].total_rtt_connectivity_ms,totalRTTMeasurements:l[s].total_rtt_connectivity_measure};const a=1e3*Number(c[K.CURRENT_ROUND_TRIP_TIME]);let _=l[s].total_rtt_connectivity_ms+a,e=l[s].total_rtt_connectivity_measure+1;return Object.prototype.hasOwnProperty.call(c,K.TOTAL_ROUND_TRIP_TIME)&&(_=1e3*Number(c[K.TOTAL_ROUND_TRIP_TIME])-(i?i[s].total_rtt_connectivity_ms:0)),Object.prototype.hasOwnProperty.call(c,K.RESPONSES_RECEIVED)&&(e=Number(c[K.RESPONSES_RECEIVED])-(i?i[s].total_rtt_connectivity_measure:0)),{rtt:a,totalRTT:_,totalRTTMeasurements:e}},ya=(c,s,i)=>c[K.TIMESTAMP]===i[s].timestamp_out||!Object.prototype.hasOwnProperty.call(c,K.JITTER)?null:1e3*(Number(c[K.JITTER])||0),gv=(c,s)=>{if(!Object.prototype.hasOwnProperty.call(c,K.FRAMES_DECODED)||!Object.prototype.hasOwnProperty.call(c,K.TOTAL_DECODE_TIME))return{delta_ms_decode_frame:s[M.VIDEO].delta_ms_decode_frame_in,frames_decoded:s[M.VIDEO].total_frames_decoded_in,total_decode_time:s[M.VIDEO].total_time_decoded_in};const i=c[K.FRAMES_DECODED],l=c[K.TOTAL_DECODE_TIME],a=l-s[M.VIDEO].total_time_decoded_in,_=i-s[M.VIDEO].total_frames_decoded_in;return{delta_ms_decode_frame:_>0?a*1e3/_:0,frames_decoded:i,total_decode_time:l}},Tv=(c,s)=>{if(!Object.prototype.hasOwnProperty.call(c,K.FRAMES_ENCODED)||!Object.prototype.hasOwnProperty.call(c,K.TOTAL_ENCODE_TIME))return{delta_ms_encode_frame:s[M.VIDEO].delta_ms_encode_frame_out,frames_encoded:s[M.VIDEO].total_frames_encoded_out,total_encode_time:s[M.VIDEO].total_time_encoded_out};const i=c[K.FRAMES_ENCODED],l=c[K.TOTAL_ENCODE_TIME],a=l-s[M.VIDEO].total_time_encoded_out,_=i-s[M.VIDEO].total_frames_encoded_out;return{delta_ms_encode_frame:_>0&&a?a*1e3/_:0,frames_encoded:i,total_encode_time:l}},U_=(c,s,i,l)=>{if(!Object.prototype.hasOwnProperty.call(c,K.PACKETS_SENT)||!Object.prototype.hasOwnProperty.call(c,K.BYTES_SENT))return{packetsSent:i[s].total_packets_out,packetsLost:i[s].total_packets_lost_out,bytesSent:i[s].total_KBytes_out};const a=Number(c[K.PACKETS_SENT])||0-(l?l[s].total_packets_out:0),_=a-i[s].total_packets_out,e=Number(c[K.BYTES_SENT])/1024-(l?l[s].total_KBytes_out:0),p=e-i[s].total_KBytes_out,g=c[K.TIMESTAMP]||Date.now(),n=l?l.timestamp:null;let v=i.timestamp;!v&&n&&(v=n);const S=v?g-v:0,m=S>0?p*.008*1024/S*1e3:0;return{packetsSent:a,deltaPacketsSent:_,KBytesSent:e,deltaKBytesSent:p,kbsSent:m}},P_=(c,s,i,l)=>{let a=i[s].total_packets_lost_out,_=0,e=0;return Object.prototype.hasOwnProperty.call(c,K.PACKETS_LOST)&&(a=Number(c[K.PACKETS_LOST])||0-(l?l[s].total_packets_lost_out:0),_=a-i[s].total_packets_lost_out),Object.prototype.hasOwnProperty.call(c,K.FRACTION_LOST)&&(e=Number(100*c[K.FRACTION_LOST])),{packetsLost:a,deltaPacketsLost:_,fractionLost:e}},x_=(c,s,i,l)=>{if(!Object.prototype.hasOwnProperty.call(c,K.PACKETS_RECEIVED)||!Object.prototype.hasOwnProperty.call(c,K.PACKETS_LOST)||!Object.prototype.hasOwnProperty.call(c,K.BYTES_RECEIVED))return{percent_packets_lost:i[s].percent_packets_lost_in,packetsReceived:i[s].total_packets_in,packetsLost:i[s].total_packets_lost_in,bytesReceived:i[s].total_KBytes_in};const a=Number(c[K.PACKETS_RECEIVED])||0-(l?l[s].total_packets_in:0),_=Number(c[K.PACKETS_LOST])||0-(l?l[s].total_packets_lost_in:0),e=_-i[s].total_packets_lost_in,p=a-i[s].total_packets_in,g=a!==i[s].total_packets_in?e*100/(e+p):0,n=Number(c[K.BYTES_RECEIVED])/1024-(l?l[s].total_KBytes_in:0),v=n-i[s].total_KBytes_in,S=c[K.TIMESTAMP]||Date.now(),m=l?l.timestamp:null;let C=i.timestamp;!C&&m&&(C=m);const A=C?S-C:0,R=A>0?v*.008*1024/A*1e3:0;return{percentPacketsLost:g,packetsReceived:a,deltaPacketsReceived:p,packetsLost:_,deltaPacketsLost:e,KBytesReceived:n,deltaKBytesReceived:v,kbsReceived:R}},vv=c=>c[K.CANDIDATE_TYPE]!=="relay"?"":c[K.RELAY_PROTOCOL]||"",Ev=c=>{if(!Object.prototype.hasOwnProperty.call(c,K.NETWORK_TYPE))return Xr.WIFI;switch(c[K.NETWORK_TYPE]){case Pu.ETHERNET:return Xr.ETHERNET;case Pu.CELLULAR_4G:return Xr.CELLULAR_4G;case Pu.WIFI:return Xr.WIFI;default:return Xr.CELLULAR}},M_=c=>!Object.prototype.hasOwnProperty.call(c,K.FRAME_HEIGHT)||!Object.prototype.hasOwnProperty.call(c,K.FRAME_WIDTH)?{width:null,height:null,framerate:null}:{width:c[K.FRAME_WIDTH]||null,height:c[K.FRAME_HEIGHT]||null,framerate:c[K.FRAMES_PER_SECOND]},Sv=c=>{const s=Object.prototype.hasOwnProperty.call(c,K.QUALITY_LIMITATION_REASON)?c[K.QUALITY_LIMITATION_REASON]:null,i=Object.prototype.hasOwnProperty.call(c,K.QUALITY_LIMITATION_RESOLUTION_CHANGES)?c[K.QUALITY_LIMITATION_RESOLUTION_CHANGES]:null,l=Object.prototype.hasOwnProperty.call(c,K.QUALITY_LIMITATION_DURATIONS)?c[K.QUALITY_LIMITATION_DURATIONS]:null;return l&&Object.keys(l).forEach(a=>{l[a]>1e3&&(l[a]=Number(l[a]/1e3))}),{reason:s,durations:l,resolutionChanges:i}},yv=(c,s,i)=>{if(!Object.prototype.hasOwnProperty.call(c,K.PLI)||!Object.prototype.hasOwnProperty.call(c,K.NACK))return{pliCount:s.total_pli_sent_in,nackCount:s.total_nack_sent_in,deltaPliCount:0,deltaNackCount:0};const l=(c[K.PLI]||0)-(i?i[M.VIDEO].total_pli_sent_in:0),a=(c[K.NACK]||0)-(i?i[M.VIDEO].total_nack_sent_in:0);return{pliCount:l,nackCount:a,deltaPliCount:l-s[M.VIDEO].total_pli_sent_in,deltaNackCount:a-s[M.VIDEO].total_nack_sent_in}},Av=(c,s,i)=>{if(!Object.prototype.hasOwnProperty.call(c,K.PLI)||!Object.prototype.hasOwnProperty.call(c,K.NACK))return{pliCount:s.total_pli_received_out,nackCount:s.total_nack_received_out,deltaPliCount:0,deltaNackCount:0};const l=(c[K.PLI]||0)-(i?i[M.VIDEO].total_pli_received_out:0),a=(c[K.NACK]||0)-(i?i[M.VIDEO].total_nack_received_out:0);return{pliCount:l,nackCount:a,deltaPliCount:l-s[M.VIDEO].total_pli_received_out,deltaNackCount:a-s[M.VIDEO].total_nack_received_out}},Cv=c=>({channels:c[K.CHANNELS]||null,clock_rate:c[K.CLOCK_RATE]||null,mime_type:c[K.MIME_TYPE]||null,sdp_fmtp_line:c[K.SDP_FMTP_LINE]||null}),Rv=c=>({clock_rate:c[K.CLOCK_RATE]||null,mime_type:c[K.MIME_TYPE]||null}),Iv=(c,s,i)=>{const l=(c[K.BYTES_RECEIVED]||0)/1024-(i?i.data.total_KBytes_in:0),a=(c[K.BYTES_SENT]||0)/1024-(i?i.data.total_KBytes_out:0),_=c[K.TIMESTAMP]||Date.now(),e=l-s.data.total_KBytes_in,p=a-s.data.total_KBytes_out,g=i?i.timestamp:null;let n=s.timestamp;!n&&g&&(n=g);const v=n?_-n:0,S=v>0?e*.008*1024/v*1e3:0,m=v>0?p*.008*1024/v*1e3:0;return{total_KBytes_received:l,total_KBytes_sent:a,delta_KBytes_received:e,delta_KBytes_sent:p,kbs_speed_received:S,kbs_speed_sent:m}},bv=c=>{const s=c[K.AVAILABLE_INCOMING_BITRATE]/1024||0,i=c[K.AVAILABLE_OUTGOING_BITRATE]/1024||0;return{kbs_incoming_bandwidth:s,kbs_outgoing_bandwidth:i}},wv=(c,s,i,l)=>{if(!c)return[];switch(c[K.TYPE]){case Yt.CANDIDATE_PAIR:let a=!1;if(c[K.NOMINATED]&&c[K.STATE]===M.SUCCEEDED&&(a=!0,ke(Hs,`analyze() - got stats ${c[K.TYPE]} for ${i}`,c),K.SELECTED in c&&!c[K.SELECTED]&&(a=!1)),a){const e=c[K.LOCAL_CANDIDATE_ID],p=c[K.REMOTE_CANDIDATE_ID],g=Iv(c,s,l),n=bv(c),v=mv(c,"data",l,s);return[{type:ie.NETWORK,value:{local_candidate_id:e}},{type:ie.NETWORK,value:{remote_candidate_id:p}},{type:ie.DATA,value:{total_KBytes_in:g.total_KBytes_received}},{type:ie.DATA,value:{total_KBytes_out:g.total_KBytes_sent}},{type:ie.DATA,value:{delta_KBytes_in:g.delta_KBytes_received}},{type:ie.DATA,value:{delta_KBytes_out:g.delta_KBytes_sent}},{type:ie.DATA,value:{delta_kbs_in:g.kbs_speed_received}},{type:ie.DATA,value:{delta_kbs_out:g.kbs_speed_sent}},{type:ie.DATA,value:{delta_kbs_bandwidth_in:n.kbs_incoming_bandwidth}},{type:ie.DATA,value:{delta_kbs_bandwidth_out:n.kbs_outgoing_bandwidth}},{type:ie.DATA,value:{delta_rtt_connectivity_ms:v.rtt}},{type:ie.DATA,value:{total_rtt_connectivity_ms:v.totalRTT}},{type:ie.DATA,value:{total_rtt_connectivity_measure:v.totalRTTMeasurements}}]}break;case Yt.LOCAL_CANDIDATE:if(c[K.ID]===s.network.local_candidate_id)return[{type:ie.NETWORK,value:{infrastructure:Ev(c)}},{type:ie.NETWORK,value:{local_candidate_type:c[K.CANDIDATE_TYPE]||""}},{type:ie.NETWORK,value:{local_candidate_protocol:c[K.PROTOCOL]||""}},{type:ie.NETWORK,value:{local_candidate_relay_protocol:vv(c)}}];break;case Yt.REMOTE_CANDIDATE:if(c[K.ID]===s.network.remote_candidate_id)return[{type:ie.NETWORK,value:{remote_candidate_type:c[K.CANDIDATE_TYPE]||""}},{type:ie.NETWORK,value:{remote_candidate_protocol:c[K.PROTOCOL]||""}}];break;case Yt.INBOUND_RTP:{ke(Hs,`analyze() - got stats ${c[K.TYPE]} for ${i}`,c);const e=c[K.SSRC],p=ht(e,s,Ve.INBOUND);p&&(p.timestamp=s.timestamp);const g=ht(e,l,Ve.INBOUND);if(g&&(g.timestamp=l.timestamp),c[K.MEDIA_TYPE]===M.AUDIO){const n=x_(c,M.AUDIO,p,g),v=ya(c,M.AUDIO,p),S=c[K.CODEC_ID]||"";return[{ssrc:e,type:ie.AUDIO,value:{codec_id_in:S}},{ssrc:e,type:ie.AUDIO,value:{total_packets_in:n.packetsReceived}},{ssrc:e,type:ie.AUDIO,value:{delta_packets_in:n.deltaPacketsReceived}},{ssrc:e,type:ie.AUDIO,value:{total_packets_lost_in:n.packetsLost}},{ssrc:e,type:ie.AUDIO,value:{delta_packets_lost_in:n.deltaPacketsLost}},{ssrc:e,type:ie.AUDIO,value:{percent_packets_lost_in:n.percentPacketsLost}},{ssrc:e,type:ie.AUDIO,value:{total_KBytes_in:n.KBytesReceived}},{ssrc:e,type:ie.AUDIO,value:{delta_KBytes_in:n.deltaKBytesReceived}},{ssrc:e,type:ie.AUDIO,value:{delta_kbs_in:n.kbsReceived}},{ssrc:e,type:ie.AUDIO,value:{delta_jitter_ms_in:v}}]}if(c[K.MEDIA_TYPE]===M.VIDEO){const n=gv(c,p),v=x_(c,M.VIDEO,p,g),S=ya(c,M.VIDEO,p),m=c[K.DECODER_IMPLEMENTATION]||null,C=c[K.CODEC_ID]||null,A=M_(c),R=yv(c,p,g);return[{ssrc:e,type:ie.VIDEO,value:{codec_id_in:C}},{ssrc:e,type:ie.VIDEO,value:{total_packets_in:v.packetsReceived}},{ssrc:e,type:ie.VIDEO,value:{delta_packets_in:v.deltaPacketsReceived}},{ssrc:e,type:ie.VIDEO,value:{total_packets_lost_in:v.packetsLost}},{ssrc:e,type:ie.VIDEO,value:{delta_packets_lost_in:v.deltaPacketsLost}},{ssrc:e,type:ie.VIDEO,value:{percent_packets_lost_in:v.percentPacketsLost}},{ssrc:e,type:ie.VIDEO,value:{total_KBytes_in:v.KBytesReceived}},{ssrc:e,type:ie.VIDEO,value:{delta_KBytes_in:v.deltaKBytesReceived}},{ssrc:e,type:ie.VIDEO,value:{delta_kbs_in:v.kbsReceived}},{ssrc:e,type:ie.VIDEO,value:{delta_jitter_ms_in:S}},{ssrc:e,type:ie.VIDEO,value:{decoder_in:m}},{ssrc:e,type:ie.VIDEO,value:{delta_ms_decode_frame_in:n.delta_ms_decode_frame}},{ssrc:e,type:ie.VIDEO,value:{total_frames_decoded_in:n.frames_decoded}},{ssrc:e,type:ie.VIDEO,value:{total_time_decoded_in:n.total_decode_time}},{ssrc:e,type:ie.VIDEO,value:{total_nack_sent_in:R.nackCount}},{ssrc:e,type:ie.VIDEO,value:{delta_nack_sent_in:R.deltaNackCount}},{ssrc:e,type:ie.VIDEO,value:{total_pli_sent_in:R.pliCount}},{ssrc:e,type:ie.VIDEO,value:{delta_pli_sent_in:R.deltaPliCount}},{ssrc:e,type:ie.VIDEO,value:{size_in:A}}]}break}case Yt.OUTBOUND_RTP:{ke(Hs,`analyze() - got stats ${c[K.TYPE]} for ${i}`,c);const e=c[K.SSRC],p=ht(e,s,Ve.OUTBOUND);p&&(p.timestamp=s.timestamp);const g=ht(e,l,Ve.OUTBOUND);if(g&&(g.timestamp=l.timestamp),c[K.MEDIA_TYPE]===M.AUDIO){const n=c[K.CODEC_ID]||null,v=U_(c,M.AUDIO,p,g);return[{ssrc:e,type:ie.AUDIO,value:{codec_id_out:n}},{ssrc:e,type:ie.AUDIO,value:{total_packets_out:v.packetsSent}},{ssrc:e,type:ie.AUDIO,value:{delta_packets_out:v.deltaPacketsSent}},{ssrc:e,type:ie.AUDIO,value:{total_KBytes_out:v.KBytesSent}},{ssrc:e,type:ie.AUDIO,value:{delta_KBytes_out:v.deltaKBytesSent}},{ssrc:e,type:ie.AUDIO,value:{delta_kbs_out:v.kbsSent}}]}if(c[K.MEDIA_TYPE]===M.VIDEO){const n=c[K.ENCODER_IMPLEMENTATION]||null,v=c[K.CODEC_ID]||null,S=Tv(c,p),m=M_(c),C=Sv(c),A=Av(c,p,g),R=U_(c,M.VIDEO,p,g);return[{ssrc:e,type:ie.VIDEO,value:{codec_id_out:v}},{ssrc:e,type:ie.VIDEO,value:{total_packets_out:R.packetsSent}},{ssrc:e,type:ie.VIDEO,value:{delta_packets_out:R.deltaPacketsSent}},{ssrc:e,type:ie.VIDEO,value:{total_KBytes_out:R.KBytesSent}},{ssrc:e,type:ie.VIDEO,value:{delta_KBytes_out:R.deltaKBytesSent}},{ssrc:e,type:ie.VIDEO,value:{delta_kbs_out:R.kbsSent}},{ssrc:e,type:ie.VIDEO,value:{encoder_out:n}},{ssrc:e,type:ie.VIDEO,value:{delta_ms_encode_frame_out:S.delta_ms_encode_frame}},{ssrc:e,type:ie.VIDEO,value:{total_frames_encoded_out:S.frames_encoded}},{ssrc:e,type:ie.VIDEO,value:{total_time_encoded_out:S.total_encode_time}},{ssrc:e,type:ie.VIDEO,value:{total_nack_received_out:A.nackCount}},{ssrc:e,type:ie.VIDEO,value:{delta_nack_received_out:A.deltaNackCount}},{ssrc:e,type:ie.VIDEO,value:{total_pli_received_out:A.pliCount}},{ssrc:e,type:ie.VIDEO,value:{delta_pli_received_out:A.deltaPliCount}},{ssrc:e,type:ie.VIDEO,value:{size_out:m}},{ssrc:e,type:ie.VIDEO,value:{limitation_out:C}}]}break}case Yt.MEDIA_SOURCE:{ke(Hs,`analyze() - got stats ${c[K.TYPE]} for ${i}`,c);break}case Yt.TRACK:{ke(Hs,`analyze() - got stats ${c[K.TYPE]} for ${i}`,c);break}case Yt.CODEC:const _=[];return Object.keys(s[M.AUDIO]).forEach(e=>{const p=s[M.AUDIO][e];if(p.codec_id_in===c[K.ID]||p.codec_id_out===c[K.ID]){ke(Hs,`analyze() - got stats ${c[K.TYPE]} for ${i}`,c);const g=Cv(c);c[K.ID]===p.codec_id_in?_.push({ssrc:p.ssrc,type:ie.AUDIO,value:{codec_in:g}}):_.push({ssrc:p.ssrc,type:ie.AUDIO,value:{codec_out:g}})}}),Object.keys(s[M.VIDEO]).forEach(e=>{const p=s[M.VIDEO][e];if(p.codec_id_in===c[K.ID]||p.codec_id_out===c[K.ID]){ke(Hs,`analyze() - got stats ${c[K.TYPE]} for ${i}`,c);const g=Rv(c);c[K.ID]===p.codec_id_in?_.push({ssrc:p.ssrc,type:ie.VIDEO,value:{codec_in:g}}):_.push({ssrc:p.ssrc,type:ie.VIDEO,value:{codec_out:g}})}}),_;case Yt.REMOTE_INBOUND_RTP:{ke(Hs,`analyze() - got stats ${c[K.TYPE]} for ${i}`,c);const e=c[K.SSRC],p=ht(e,s,Ve.OUTBOUND),g=ht(e,l,Ve.OUTBOUND);if(c[K.KIND]===M.AUDIO){const n=N_(c,M.AUDIO,g,p),v=ya(c,M.AUDIO,p),S=P_(c,M.AUDIO,p,g);return[{ssrc:e,type:ie.AUDIO,value:{delta_rtt_ms_out:n.rtt}},{ssrc:e,type:ie.AUDIO,value:{total_rtt_ms_out:n.totalRTT}},{ssrc:e,type:ie.AUDIO,value:{total_rtt_measure_out:n.totalRTTMeasurements}},{ssrc:e,type:ie.AUDIO,value:{delta_jitter_ms_out:v}},{ssrc:e,type:ie.AUDIO,value:{timestamp_out:c[K.TIMESTAMP]}},{ssrc:e,type:ie.AUDIO,value:{total_packets_lost_out:S.packetsLost}},{ssrc:e,type:ie.AUDIO,value:{delta_packets_lost_out:S.deltaPacketsLost}},{ssrc:e,type:ie.AUDIO,value:{percent_packets_lost_out:S.fractionLost}}]}if(c[K.KIND]===M.VIDEO){const n=N_(c,M.VIDEO,g,p),v=ya(c,M.VIDEO,p),S=P_(c,M.VIDEO,p,g);return[{ssrc:e,type:ie.VIDEO,value:{delta_rtt_ms_out:n.rtt}},{ssrc:e,type:ie.VIDEO,value:{total_rtt_ms_out:n.totalRTT}},{ssrc:e,type:ie.VIDEO,value:{total_rtt_measure_out:n.totalRTTMeasurements}},{ssrc:e,type:ie.VIDEO,value:{delta_jitter_ms_out:v}},{ssrc:e,type:ie.VIDEO,value:{timestamp_out:c[K.TIMESTAMP]}},{ssrc:e,type:ie.VIDEO,value:{total_packets_lost_out:S.packetsLost}},{ssrc:e,type:ie.VIDEO,value:{delta_packets_lost_out:S.deltaPacketsLost}},{ssrc:e,type:ie.VIDEO,value:{percent_packets_lost_out:S.fractionLost}}]}break}}return[]},Aa=c=>c<0?1:c>100?4.5:1+.035*c+7/1e6*c*(c-60)*(100-c),Ov=(c,s=M.AUDIO,i,l,a)=>{const _=ht(a,c,Ve.INBOUND),e=ht(a,i,Ve.INBOUND),p=ht(a,l,Ve.INBOUND),g=[],n=[],v=_[s].percent_packets_lost_in,S=_[s].delta_jitter_ms_in,m=e&&e[s].delta_jitter_ms_in||null,C=p&&p[s].delta_jitter_ms_in||null,A=c.data.delta_rtt_connectivity_ms,R=i&&i.data.delta_rtt_connectivity_ms||null,I=l&&l.data.delta_rtt_connectivity_ms||null;A&&g.push(A),R&&g.push(R),I&&g.push(I),S&&n.push(S),i&&m&&n.push(m),l&&C&&n.push(C);const V=g.length>0?$s(g):100,W=n.length>0?$s(n):10,oe=93.2-v,x=.18*oe*oe-27.9*oe+1126.62,$=(V+W)/2,Re=$-177.3<0?0:1,be=.024*$+.11*($-177.3)*Re,H=x-be;return Aa(H)},Dv=(c,s=M.AUDIO,i,l,a)=>{const _=ht(a,c,Ve.OUTBOUND),e=ht(a,i,Ve.OUTBOUND),p=ht(a,l,Ve.OUTBOUND),g=[],n=[],v=_[s].percent_packets_lost_out,S=_[s].delta_rtt_ms_out,m=e&&e[s].delta_rtt_ms_out||null,C=p&&p[s].delta_rtt_ms_out||null,A=_[s].delta_jitter_ms_out,R=e&&e[s].delta_jitter_ms_out||null,I=p&&p[s].delta_jitter_ms_out||null,V=c.data.delta_rtt_connectivity_ms,W=i&&i.data.delta_rtt_connectivity_ms||null,oe=l&&l.data.delta_rtt_connectivity_ms||null;S?g.push(S):V&&g.push(V),m?g.push(m):W&&g.push(W),C?g.push(C):oe&&g.push(oe),A&&n.push(A),i&&R&&n.push(R),l&&I&&n.push(I);const x=g.length>0?$s(g):100,$=n.length>0?$s(n):10,Re=93.2-v,be=.18*Re*Re-27.9*Re+1126.62,H=(x+$)/2,D=H-177.3<0?0:1,L=.024*H+.11*(H-177.3)*D,q=be-L;return Aa(q)},Nv=(c,s=M.AUDIO,i,l,a)=>{const _=ht(a,c,Ve.INBOUND),e=ht(a,i,Ve.INBOUND),p=ht(a,l,Ve.INBOUND),g=[],n=[],v=_[s].percent_packets_lost_in/100,S=_[s].delta_jitter_ms_in,m=e&&e[s].delta_jitter_ms_in||null,C=p&&p[s].delta_jitter_ms_in||null,A=c.data.delta_rtt_connectivity_ms,R=i&&i.data.delta_rtt_connectivity_ms||null,I=l&&l.data.delta_rtt_connectivity_ms||null;A&&g.push(A),R&&g.push(R),I&&g.push(I),S&&n.push(S),e&&m&&n.push(m),p&&C&&n.push(C);const V=g.length>0?$s(g):100,W=n.length>0?$s(n):10,oe=0,x=19.8,$=29.7,Re=30,be=(V+W)/2+Re,H=be-177.3<0?0:1,D=.024*be+.11*(be-177.3)*H,q=93.2-(oe+x*Math.log(1+$*v)+D);return Aa(q)},Uv=(c,s=M.AUDIO,i,l,a)=>{const _=ht(a,c,Ve.OUTBOUND),e=ht(a,i,Ve.OUTBOUND),p=ht(a,l,Ve.OUTBOUND),g=[],n=[],v=_[s].percent_packets_lost_out/100,S=_[s].delta_rtt_ms_out,m=e&&e[s].delta_rtt_ms_out||null,C=p&&p[s].delta_rtt_ms_out||null,A=_[s].delta_jitter_ms_out,R=e&&e[s].delta_jitter_ms_out||null,I=p&&p[s].delta_jitter_ms_out||null,V=c.data.delta_rtt_connectivity_ms,W=i&&i.data.delta_rtt_connectivity_ms||null,oe=l&&l.data.delta_rtt_connectivity_ms||null;S?g.push(S):V&&g.push(V),m?g.push(m):W&&g.push(W),C?g.push(C):oe&&g.push(oe),A&&n.push(A),e&&R&&n.push(R),p&&I&&n.push(I);const x=g.length>0?$s(g):100,$=n.length>0?$s(n):10,Re=0,be=19.8,H=29.7,D=30,L=(x+$)/2+D,q=L-177.3<0?0:1,j=.024*L+.11*(L-177.3)*q,Q=93.2-(Re+be*Math.log(1+H*v)+j);return Aa(Q)};class Pv{constructor(s,i){this._callbacks={onreport:null,onticket:null},this._id=uv(),this._moduleName=this._id,this._probeId=i,this._config=s,this._exporter=new pv(s),this._state=Ss.IDLE,this.registerToPCEvents(),pn(this._moduleName,`new collector created for probe ${this._probeId}`)}analyze(s,i,l,a){const _=(g,n)=>g===M.AUDIO?n===Yt.INBOUND_RTP?{...R_}:{...I_}:n===Yt.INBOUND_RTP?{...b_}:{...w_},e=rv(i);e.pname=this._config.pname,e.call_id=this._config.cid,e.user_id=this._config.uid,e.count=i?i.count+1:1;let p=null;return s.forEach(g=>{!p&&g.timestamp&&(p=g.timestamp),wv(g,e,e.pname,a).forEach(v=>{if(v.value&&v.type)if(v.ssrc){let S=e[v.type][v.ssrc];S||(S=_(v.type,g.type),S.ssrc=v.ssrc,e[v.type][v.ssrc]=S),Object.keys(v.value).forEach(m=>{S[m]=v.value[m]})}else Object.keys(v.value).forEach(S=>{e[v.type][S]=v.value[S]})})}),e.timestamp=p,Object.keys(e[M.AUDIO]).forEach(g=>{const n=e[M.AUDIO][g];n.direction===Ve.INBOUND?(n.mos_emodel_in=Ov(e,M.AUDIO,i,l,n.ssrc),n.mos_in=Nv(e,M.AUDIO,i,l,n.ssrc)):(n.mos_emodel_out=Dv(e,M.AUDIO,i,l,n.ssrc),n.mos_out=Uv(e,M.AUDIO,i,l,n.ssrc))}),e}async takeReferenceStats(){return new Promise((s,i)=>{const l=Date.now();setTimeout(async()=>{try{const a=Date.now()-l,_=Date.now(),e=await this._config.pc.getStats(),p=this.analyze(e,null,null,null),g=Date.now();p.experimental.time_to_measure_ms=g-_,p.experimental.time_to_wait_ms=a,this._exporter.saveReferenceReport(p),ke(this._moduleName,`got reference report for probe ${this._probeId}`),s()}catch(a){i(a)}},this._config.startAfter)})}async collectStats(){try{if(this._state!==Ss.RUNNING||!this._config.pc)return ke(this._moduleName,`report discarded (too late) for probe ${this._probeId}`),null;const s=Date.now(),i=await this._config.pc.getStats(),l=this.analyze(i,this._exporter.getLastReport(),this._exporter.getBeforeLastReport(),this._exporter.getReferenceReport()),a=Date.now();return l.experimental.time_to_measure_ms=a-s,this._exporter.addReport(l),ke(this._moduleName,`got report for probe ${this._probeId}#${this._exporter.getReportsNumber()+1}`),this.fireOnReport(l),l}catch(s){return zn(this._moduleName,`got error ${s}`),null}}async start(){ke(this._moduleName,"starting"),this.state=Ss.RUNNING,this._startedTime=this._exporter.start(),ke(this._moduleName,"started")}async mute(){this.state=Ss.MUTED,ke(this._moduleName,"muted")}async unmute(){this.state=Ss.RUNNING,ke(this._moduleName,"unmuted")}async stop(s){if(ke(this._moduleName,`stopping${s?" by watchdog":""}...`),this._stoppedTime=this._exporter.stop(),this.state=Ss.IDLE,this._config.ticket){const{ticket:i}=this._exporter;this.fireOnTicket(i)}this._exporter.reset(),ke(this._moduleName,"stopped")}registerCallback(s,i,l){s in this._callbacks?(this._callbacks[s]={callback:i,context:l},ke(this._moduleName,`registered callback '${s}'`)):zn(this._moduleName,`can't register callback for '${s}' - not found`)}unregisterCallback(s){s in this._callbacks?(this._callbacks[s]=null,delete this._callbacks[s],ke(this._moduleName,`unregistered callback '${s}'`)):zn(this._moduleName,`can't unregister callback for '${s}' - not found`)}fireOnReport(s){this._callbacks.onreport&&Mu(this._callbacks.onreport.callback,this._callbacks.onreport.context,s)}fireOnTicket(s){this._callbacks.onticket&&Mu(this._callbacks.onticket.callback,this._callbacks.onticket.context,s)}updateConfig(s){this._config=s,this._exporter.updateConfig(s)}get state(){return this._state}set state(s){this._state=s,ke(this._moduleName,`state changed to ${s}`)}addCustomEvent(s,i,l,a){this._exporter.addCustomEvent({at:typeof s=="object"?s.toJSON():s,category:i,name:l,description:a})}async registerToPCEvents(){const{pc:s}=this._config;if(navigator.mediaDevices.ondevicechange=async()=>{try{const i=await navigator.mediaDevices.enumerateDevices();this.addCustomEvent(new Date().toJSON(),"device",`${i.length} devices found`,"Media Devices state")}catch{zn(this._moduleName,"can't get devices")}},s){s.oniceconnectionstatechange=()=>{const l=s.iceConnectionState;l===zr.CONNECTED||l===zr.COMPLETED?this.addCustomEvent(new Date().toJSON(),"call",l,"ICE connection state"):l===zr.DISCONNECTED||l===zr.FAILED?this.addCustomEvent(new Date().toJSON(),"call",l,"ICE connection state"):l===zr.CLOSED&&this.addCustomEvent(new Date().toJSON(),"call","ended","ICE connection state")},s.onicegatheringstatechange=()=>{const l=s.iceGatheringState;this.addCustomEvent(new Date().toJSON(),"call",l,"ICE gathering state")},s.ontrack=l=>{this.addCustomEvent(new Date().toJSON(),"call",`${l.track.kind}track`,"MediaStreamTrack received")},s.onnegotiationneeded=()=>{this.addCustomEvent(new Date().toJSON(),"call","negotiation","Media changed")};const i=s.getReceivers();if(i&&i.length>0){const l=i[0],{transport:a}=l;if(a){const{iceTransport:_}=a;_&&(_.onselectedcandidatepairchange=()=>{this.addCustomEvent(new Date().toJSON(),"call","transport","Candidates Pair changed")})}}}}}class xv{constructor(s){this._id=s.pname&&s.pname.substr(0,12).padEnd(12," ")||ov(),this._moduleName=this._id,pn(this._moduleName,"probe created"),this._config=s,this._collector=new Pv(this._config,this._id)}set onreport(s){s?this._collector.registerCallback("onreport",s):this._collector.unregisterCallback("onreport")}set onticket(s){s?this._collector.registerCallback("onticket",s):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(s){this._collector.state=s}addCustomEvent(s,i,l,a=new Date().toJSON()){this._collector.addCustomEvent(a,i,s,l)}get isRunning(){return this._collector.state===Ss.RUNNING}get isIdle(){return this._collector.state===Ss.IDLE}updateUserId(s){this._config.uid=s,this._collector.updateConfig(this._config)}updateCallId(s){this._config.cid=s,this._collector.updateConfig(this._config)}start(){if(!this.isIdle){Sa(this._moduleName,"probe is already running");return}this._collector.start()}stop(s=!1){this.isRunning&&this._collector.stop(s)}async takeReferenceStats(){return this._collector.takeReferenceStats()}async collectStats(){return this._collector.collectStats()}}const Ot="engine ";class Mv{constructor(s){this._config=s,this._probes=[],this._startedTime=null,this._callbacks={onresult:null},pn(Ot,`configured for probing every ${this._config.refreshEvery}ms`),pn(Ot,`configured for starting after ${this._config.startAfter}ms`),pn(Ot,`${!this._config.stopAfter||this._config.stopAfter!==-1?`configured for stopped after ${this._config.stopAfter}ms`:"configured for never stopped"}`),ke(Ot,"engine initialized")}get probes(){return this._probes}get isRunning(){return this._probes.some(s=>s.isRunning)}get isIdle(){return this._probes.every(s=>s.isIdle)}addNewProbe(s,i){if(!s)throw new Error("undefined peer connection");const l=lv(s,i,this._config),a=new xv(l);return this._probes.push(a),ke(Ot,`${this._probes.length} probes registered`),a}removeExistingProbe(s){if(!s)throw new Error("undefined probe");s.state===Ss.RUNNING&&s.stop(),this._probes=this._probes.filter(i=>s.id!==i.id)}async start(){const s=()=>{this._probes.forEach(_=>_.start())},i=async()=>Promise.all(this._probes.map(_=>_.takeReferenceStats())),l=()=>this.isIdle?!1:!this._config.stopAfter||this._config.stopAfter<0?!0:Date.now()<this._startedTime+this._config.stopAfter,a=async()=>{const _=nv(),e=this._probes.filter(p=>p.isRunning);for(const p of e){const g=await p.collectStats();g&&_.probes.push(g),ke(Ot,`got probe ${p.id}`),await O_(0)}return _.delta_time_to_measure_probes_ms=mn(_.probes,"experimental","time_to_measure_ms"),_.delta_KBytes_in=mn(_.probes,"data","delta_KBytes_in"),_.delta_KBytes_out=mn(_.probes,"data","delta_KBytes_out"),_.delta_kbs_in=mn(_.probes,"data","delta_kbs_in"),_.delta_kbs_out=mn(_.probes,"data","delta_kbs_out"),_.total_time_decoded_in=mn(_.probes,"video","total_time_decoded_in"),_.total_time_encoded_out=mn(_.probes,"video","total_time_encoded_out"),_};for(ke(Ot,"starting to collect"),s(),ke(Ot,"generating reference reports..."),await i(),ke(Ot,"reference reports generated"),this._startedTime=Date.now();l();)if(ke(Ot,`wait ${this._config.refreshEvery}ms before collecting`),await O_(this._config.refreshEvery),l()){ke(Ot,"collecting...");const _=Date.now(),e=await a(),p=Date.now();e.delta_time_consumed_to_measure_ms=p-_,this.fireOnReports(e),ke(Ot,"collected")}ke(Ot,"reaching end of the collecting period..."),this.isRunning&&setTimeout(()=>{this.stop()},0)}stop(s){const i=l=>{this._probes.forEach(a=>{a.stop(l)})};pn(Ot,"stop collecting"),i(s)}registerCallback(s,i,l){s in this._callbacks?(this._callbacks[s]={callback:i,context:l},ke(Ot,`registered callback '${s}'`)):zn(Ot,`can't register callback for '${s}' - not found`)}unregisterCallback(s){s in this._callbacks?(this._callbacks[s]=null,delete this._callbacks[s],ke(this._moduleName,`unregistered callback '${s}'`)):zn(this._moduleName,`can't unregister callback for '${s}' - not found`)}fireOnReports(s){this._callbacks.onresult&&s.probes.length>0&&Mu(this._callbacks.onresult.callback,this._callbacks.onresult.context,s)}}const kv="interface ";class Lv{constructor(s){this._config=av(s),pn(kv,`welcome to ${this._config.name} version ${this._config.version}`),JT(this._config.verbose||!1),this._engine=new Mv(this._config)}setupLogLevel(s){zT(s)}get version(){return this._config.version}get name(){return this._config.name}get probes(){return this._engine.probes}createProbe(s,i){return this._engine.addNewProbe(s,i)}startAllProbes(){this._engine.start()}stopAllProbes(){this._engine.stop()}get running(){return this._engine.isRunning}get idle(){return this._engine.isIdle}removeProbe(s){this._engine.removeExistingProbe(s)}set onresult(s){s?this._engine.registerCallback("onresult",s):this._engine.unregisterCallback("onresult")}}function $v(c,s){return Object.keys(c).filter(i=>s.includes(i)).reduce((i,l)=>{const a=l;return{...i,[a]:c[a]}},{})}const Hv=["mos_in","codec_in","delta_KBytes_in","delta_kbs_in","delta_jitter_ms_in","delta_packets_lost_in"];class Fv{constructor(s){this.intervals={},this.emitInterval=s.emitInterval||200,this.onChangeFunction=s.onChangeFunction}start(s,i){s&&s.getTracks().length&&requestAnimationFrame(()=>this.beginCalculation(s,i))}stop(s){this.clearVolumeInterval(s)}clearVolumeInterval(s){console.log("clearVolumeInterval",s),clearInterval(this.intervals[s]),delete this.intervals[s]}clearAllIntervals(){Object.keys(this.intervals).forEach(s=>{clearInterval(this.intervals[s])}),this.intervals={}}beginCalculation(s,i){this.clearVolumeInterval(i);const l=dn.createAnalyser(),a=dn.createMediaStreamSource(s),_=dn.createScriptProcessor(2048,1,1);l.smoothingTimeConstant=.8,l.fftSize=1024,a.connect(l),l.connect(_),_.connect(dn.destination),this.intervals[i]=setInterval(()=>{const e=new Uint8Array(l.frequencyBinCount);l.getByteFrequencyData(e);let p=0;const g=e.length;for(let v=0;v<g;v++)p+=e[v];const n=p/g;this.onChangeFunction(i,n)},this.emitInterval)}}const Ca={SELECTED_INPUT_DEVICE:"OpensipsJSInputDevice",SELECTED_OUTPUT_DEVICE:"OpensipsJSOutputDevice"},jv=0;class qv{constructor(s){this.isAutoAnswer=!1,this.muteWhenJoinEnabled=!1,this.isDNDEnabled=!1,this.muted=!1,this.microphoneInputLevelValue=1,this.speakerVolumeValue=1,this.activeRooms={},this.activeCalls={},this.extendedCalls={},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.context=s,this.context.on(this.context.newRTCSessionEventName,this.newRTCSessionCallback.bind(this)),this.VUMeter=new Fv({onChangeFunction:this.emitVolumeChange.bind(this)}),this.initializeMediaDevices()}get sipOptions(){return{...this.context.options.sipOptions,mediaConstraints:this.getUserMediaConstraints}}get currentActiveRoomId(){return this.currentActiveRoomIdValue}set currentActiveRoomId(s){this.currentActiveRoomIdValue=s,this.context.emit("currentActiveRoomChanged",s)}get autoAnswer(){return this.isAutoAnswer}get callAddingInProgress(){return this.isCallAddingInProgress}set callAddingInProgress(s){this.isCallAddingInProgress=s,this.context.emit("callAddingInProgressChanged",s)}get muteWhenJoin(){return this.muteWhenJoinEnabled}get isDND(){return this.isDNDEnabled}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 getActiveRooms(){return this.activeRooms}get isMuted(){return this.muted}get getInputDeviceList(){return this.availableMediaDevices.filter(s=>s.kind==="audioinput")}get getOutputDeviceList(){return this.availableMediaDevices.filter(s=>s.kind==="audiooutput")}get getUserMediaConstraints(){return S_()?{video:!1,audio:!0}:{audio:{deviceId:{exact:this.selectedMediaDevices.input}},video:!1}}get selectedInputDevice(){return this.selectedMediaDevices.input}get selectedOutputDevice(){return this.selectedMediaDevices.output}get activeStream(){return this.activeStreamValue}setAvailableMediaDevices(s){this.availableMediaDevices=s,this.context.emit("changeAvailableDeviceList",s)}async updateDeviceList(){await navigator.mediaDevices.getUserMedia(this.getUserMediaConstraints);const s=await navigator.mediaDevices.enumerateDevices();this.setAvailableMediaDevices(s)}async initializeMediaDevices(){const s=localStorage.getItem(Ca.SELECTED_INPUT_DEVICE)||"default",i=localStorage.getItem(Ca.SELECTED_OUTPUT_DEVICE)||"default";try{const l=await navigator.mediaDevices.getUserMedia(this.getUserMediaConstraints),a=await navigator.mediaDevices.enumerateDevices();this.setAvailableMediaDevices(a),await this.setMicrophone(s),await this.setSpeaker(i),navigator.mediaDevices.addEventListener("devicechange",async()=>{const _=await navigator.mediaDevices.enumerateDevices();this.setAvailableMediaDevices(_)}),l.getTracks().forEach(_=>_.stop())}catch(l){console.error(l)}}setCallTime(s){const i={...s};delete i.callId,this.callTime={...this.callTime,[s.callId]:i},this.context.emit("changeCallTime",this.callTime)}removeCallTime(s){const i={...this.callTime};delete i[s],this.callTime={...i},this.context.emit("changeCallTime",this.callTime)}setTimeInterval(s,i){this.timeIntervals={...this.timeIntervals,[s]:i}}removeTimeInterval(s){const i={...this.timeIntervals};i[s]&&(clearInterval(i[s]),delete i[s],this.timeIntervals={...i})}stopCallTimer(s){this.removeTimeInterval(s),this.removeCallTime(s)}emitVolumeChange(s,i){this.context.emit("changeCallVolume",{callId:s,volume:i})}setMetricsConfig(s){this.metricConfig={...this.metricConfig,...s}}sendDTMF(s,i){if(!/^[A-D0-9]+$/g.test(i))throw new Error("Not allowed character in DTMF input");this.extendedCalls[s].sendDTMF(i)}setIsMuted(s){this.muted=s,this.context.emit("changeIsMuted",s)}processMute(s){const i=this.currentActiveRoomId;this.setIsMuted(s),this.initialStreamValue.getTracks().forEach(l=>l.enabled=!s),this.roomReconfigure(i)}mute(){this.processMute(!0)}unmute(){this.processMute(!1)}async processHold({callId:s,toHold:i,automatic:l}){const a=this.extendedCalls[s];a._automaticHold=l??!1,await new Promise(p=>{const g=()=>{p()};i?a.hold({},g):a.unhold({},g)}),this.updateCall(a);const e=Object.values(this.extendedCalls).filter(p=>p.roomId===this.currentActiveRoomId&&(i?s!==p._id:!0));e.length>1&&await this.doConference(e)}holdCall(s,i=!1){return this.processHold({callId:s,automatic:i,toHold:!0})}unholdCall(s){return this.processHold({callId:s,toHold:!1})}cancelAllOutgoingUnanswered(){Object.values(this.getActiveCalls).filter(s=>s.direction==="outgoing"&&s.status===jv).forEach(s=>this.terminateCall(s._id))}answerCall(s){const i=this.extendedCalls[s];this.cancelAllOutgoingUnanswered(),i.answer(this.sipOptions),this.updateCall(i),this.setActiveRoom(i.roomId),i.connection.addEventListener("track",l=>{this.triggerAddStream(l,i)})}async moveCall(s,i){this.updateCallStatus({callId:s,isMoving:!0}),await this.processRoomChange({callId:s,roomId:i}),this.updateCallStatus({callId:s,isMoving:!1})}updateCall(s){this.activeCalls[s._id]=T_(s),this.context.emit("changeActiveCalls",this.activeCalls)}updateRoom(s){const l={...this.activeRooms[s.roomId],...s};this.activeRooms={...this.activeRooms,[s.roomId]:{...l}},this.context.emit("updateRoom",{room:l,roomList:this.activeRooms})}hasAutoAnswerHeaders(s){const i=/answer-after=0/,a=s.request.getHeader("Call-Info");return a&&i.test(a)}addCall(s,i=!0){this.activeCalls={...this.activeCalls,[s._id]:T_(s)},this.extendedCalls[s._id]=s,i&&this.context.emit("changeActiveCalls",this.activeCalls)}addCallStatus(s){this.callStatus={...this.callStatus,[s]:{isMoving:!1,isTransferring:!1,isMerging:!1}},this.context.emit("changeCallStatus",this.callStatus)}updateCallStatus(s){const l={...{...this.callStatus[s.callId]}};s.isMoving!==void 0&&(l.isMoving=s.isMoving),s.isTransferring!==void 0&&(l.isTransferring=s.isTransferring),s.isMerging!==void 0&&(l.isMerging=s.isMerging),this.callStatus={...this.callStatus,[s.callId]:{...l}},this.context.emit("changeCallStatus",this.callStatus)}removeCallStatus(s){const i={...this.callStatus};delete i[s],this.callStatus={...i},this.context.emit("changeCallStatus",this.callStatus)}addRoom(s){this.activeRooms={...this.activeRooms,[s.roomId]:s},this.context.emit("addRoom",{room:s,roomList:this.activeRooms})}getActiveStream(){const s=E_(this.initialStreamValue,this.microphoneInputLevel*2);return s.getTracks().forEach(i=>i.enabled=!this.isMuted),this.setActiveStream(s),s}async setMicrophone(s){if(!this.getInputDeviceList.find(({deviceId:l})=>l===s)||(this.setSelectedInputDevice(s),Object.keys(this.getActiveCalls).length===0))return;await this.setupStream();const i=Object.values(this.extendedCalls).filter(l=>l.roomId===this.currentActiveRoomId);i.length===1?Object.values(i).forEach(async l=>{const a=this.getActiveStream();l.connection.getSenders()[0].replaceTrack(a.getTracks()[0]),this.updateCall(l)}):await this.doConference(i)}setActiveStream(s){this.activeStream&&this.stopVUMeter("origin"),this.setupVUMeter(s,"origin"),this.activeStreamValue=s,this.context.emit("changeActiveStream",s)}async setSpeaker(s){if(!this.getOutputDeviceList.find(({deviceId:a})=>a===s))return;this.setSelectedOutputDevice(s);const i=Object.values(this.extendedCalls);if(i.length===0)return;const l=i.filter(a=>a.roomId===this.currentActiveRoomId);l.length===1?i.forEach(a=>{var _;(_=a.audioTag)==null||_.setSinkId(s),this.updateCall(a)}):await this.doConference(l)}removeRoom(s){const i={...this.activeRooms},l={...i[s]};delete i[s],this.activeRooms={...i},this.context.emit("removeRoom",{room:l,roomList:this.activeRooms})}deleteRoomIfEmpty(s){s!==void 0&&Object.values(this.extendedCalls).filter(i=>i.roomId===s).length===0&&(this.removeRoom(s),this.currentActiveRoomId===s&&(this.currentActiveRoomId=void 0))}checkInitialized(){if(!this.context.initialized)throw new Error("[OpenSIPSJS] You must call `start` method first!")}muteReconfigure(s){this.muted?s.mute({audio:!0}):s.unmute({audio:!0})}async roomReconfigure(s){var l;if(s===void 0)return;const i=Object.values(this.extendedCalls).filter(a=>a.roomId===s);if(this.currentActiveRoomId===s?i.forEach(a=>{a.audioTag&&(this.muteReconfigure(a),a.audioTag.muted=!1,this.updateCall(a))}):i.forEach(a=>{a.audioTag&&(a.audioTag.muted=!0,this.updateCall(a))}),i.length===0)this.deleteRoomIfEmpty(s);else if(i.length===1&&this.currentActiveRoomId!==s)i[0].isOnHold().local||await this.holdCall(i[0].id,!0);else if(i.length===1&&this.currentActiveRoomId===s){if(i[0].isOnHold().local&&i[0]._automaticHold&&await this.unholdCall(i[0].id),i[0].connection&&((l=i[0].connection)!=null&&l.getSenders()[0])){const a=this.getActiveStream();await i[0].connection.getSenders()[0].replaceTrack(a.getTracks()[0]),this.muteReconfigure(i[0])}}else i.length>1&&await this.doConference(i)}async doConference(s){const i=[];s.forEach(l=>{l!=null&&l.connection.getReceivers().forEach(a=>{i.push(a.track)})}),await KT.forEach(s,async l=>{var e;if(l==null)return;const a=new MediaStream,_=dn.createMediaStreamDestination();if(l.connection.getReceivers().forEach(p=>{i.forEach(g=>{a.addTrack(p.track),p.track.id!==g.id&&dn.createMediaStreamSource(new MediaStream([g])).connect(_)})}),s[0].roomId===this.currentActiveRoomId){const p=this.getActiveStream();dn.createMediaStreamSource(p).connect(_)}(e=l.connection)!=null&&e.getSenders()[0]&&(await l.connection.getSenders()[0].replaceTrack(_.stream.getTracks()[0]),this.muteReconfigure(l))})}processCallerMute(s,i){const l=this.extendedCalls[s];l&&l.connection.getReceivers().length&&(l.localMuted=i,l.connection.getReceivers().forEach(a=>{a.track.enabled=!i}),this.updateCall(l))}muteCaller(s){this.processCallerMute(s,!0)}unmuteCaller(s){this.processCallerMute(s,!1)}terminateCall(s){const i=this.extendedCalls[s];i._status!==8&&i.terminate()}transferCall(s,i){if(i.toString().length===0)return new Error("Target must be passed");const l=this.extendedCalls[s];if(!l._is_confirmed&&!l._is_canceled){const a=`sip:${i}@${this.context.sipDomain}`;l.terminate({status_code:302,reason_phrase:"Moved Temporarily",extraHeaders:[`Contact: ${a}`]});return}this.updateCallStatus({callId:s,isTransferring:!0}),l.refer(`sip:${i}@${this.context.sipDomain}`),this.updateCall(l)}mergeCall(s){const i=Object.values(this.extendedCalls).filter(_=>_.roomId===s);if(i.length!==2)return;const l=i[0],a=i[1];!l||!a||(this.updateCallStatus({callId:l._id,isMerging:!0}),this.updateCallStatus({callId:a._id,isMerging:!0}),l.refer(a.remote_identity.uri.toString(),{replaces:a}),this.updateCall(l))}mergeCallByIds(s,i){const l=Object.values(this.extendedCalls).find(_=>_._id===s),a=Object.values(this.extendedCalls).find(_=>_._id===i);if(!l||!a)throw new Error("Call ID is not provided");this.updateCallStatus({callId:s,isMerging:!0}),this.updateCallStatus({callId:i,isMerging:!0}),l.refer(a.remote_identity.uri.toString(),{replaces:a}),this.updateCall(l)}setDND(s){this.isDNDEnabled=s,this.context.emit("changeIsDND",s)}startCallTimer(s){this.removeTimeInterval(s);const i={callId:s,hours:0,minutes:0,seconds:0,formatted:""};this.setCallTime(i);const l=setInterval(()=>{const a={...this.callTime[s]},_=WT(a);this.setCallTime({callId:s,..._})},1e3);this.setTimeInterval(s,l)}async setActiveRoom(s){const i=this.currentActiveRoomId;s!==i&&(this.currentActiveRoomId=s,await this.roomReconfigure(i),await this.roomReconfigure(s))}getNewRoomId(){const s=Object.keys(this.activeRooms);return s.length===0?1:parseInt(s.sort()[s.length-1])+1}async setupCall(s){var n,v;const i=s.session;if(this.getActiveCalls[i.id]!==void 0)return;const a=this.getNewRoomId(),_={started:new Date,incomingInProgress:!1,roomId:a};i.direction==="incoming"?(this.context.logger.log("New incoming call from",(v=(n=i._remote_identity)==null?void 0:n._uri)==null?void 0:v._user),_.incomingInProgress=!0,this.context.subscribe(Kt.CALL_CONFIRMED,S=>{i.id===S.id&&(this.updateRoom({incomingInProgress:!1,roomId:a}),this.startCallTimer(i.id))}),this.context.subscribe(Kt.CALL_FAILED,S=>{i.id===S.id&&(this.updateRoom({incomingInProgress:!1,roomId:a}),this.deleteRoomIfEmpty(a))})):i.direction==="outgoing"&&(i.once("confirmed",()=>{this.startCallTimer(i.id)}),this.startCallTimer(i.id));const e=i,p=this.hasAutoAnswerHeaders(s),g=e.direction==="incoming"&&!this.hasActiveCalls&&(p||this.autoAnswer);e.roomId=a,e.localMuted=!1,e.autoAnswer=g,g?this.addCall(e,!1):this.addCall(e),this.addCallStatus(i.id),this.addRoom(_),g&&this.answerCall(e._id)}removeCall(s){const i={...this.activeCalls};delete i[s],this.activeCalls={...i};const l={...this.extendedCalls};delete l[s],this.extendedCalls={...l},this.context.emit("changeActiveCalls",this.activeCalls)}activeCallListRemove(s){var a;const i=this.extendedCalls[s._id];this.stopVUMeter("origin"),(a=i.connection)==null||a.getSenders().forEach(_=>{_.track.stop()});const l=i.roomId;this.removeCall(s._id),this.roomReconfigure(l)}async newRTCSessionCallback(s){const i=s.session;if(this.isDND){i.terminate({status_code:486,reason_phrase:"Do Not Disturb"});return}if(this.context.triggerListener({listenerType:Kt.NEW_CALL,session:i,event:s}),i.on("ended",l=>{var _,e,p;this.stopVUMeter(i.id),this.context.logger.log("Session ended for",(e=(_=i._remote_identity)==null?void 0:_._uri)==null?void 0:e._user),this.context.triggerListener({listenerType:Kt.CALL_ENDED,session:i,event:l});const a=this.getActiveCalls[i.id];a&&this.activeCallListRemove(a),this.stopCallTimer(i.id),this.removeCallStatus(i.id),this.removeCallMetrics(i.id),Object.keys(this.extendedCalls).length||(this.setIsMuted(!1),(p=this.initialStreamValue)==null||p.getTracks().forEach(g=>g.stop()),this.initialStreamValue=null)}),i.on("progress",l=>{var a,_;this.context.logger.log("Session in progress for",(_=(a=i._remote_identity)==null?void 0:a._uri)==null?void 0:_._user),this.context.triggerListener({listenerType:Kt.CALL_PROGRESS,session:i,event:l})}),i.on("failed",l=>{var _,e,p;this.stopVUMeter(i.id),this.context.logger.log("Session failed for",(e=(_=i._remote_identity)==null?void 0:_._uri)==null?void 0:e._user),this.context.triggerListener({listenerType:Kt.CALL_FAILED,session:i,event:l}),i.id===this.callAddingInProgress&&(this.callAddingInProgress=void 0);const a=this.getActiveCalls[i.id];a&&this.activeCallListRemove(a),this.stopCallTimer(i.id),this.removeCallStatus(i.id),this.removeCallMetrics(i.id),Object.keys(this.extendedCalls).length||(this.setIsMuted(!1),(p=this.initialStreamValue)==null||p.getTracks().forEach(g=>g.stop()),this.initialStreamValue=null)}),i.on("confirmed",l=>{var a,_;this.context.logger.log("Session confirmed for",(_=(a=i._remote_identity)==null?void 0:a._uri)==null?void 0:_._user),this.context.triggerListener({listenerType:Kt.CALL_CONFIRMED,session:i,event:l}),this.updateCall(i),i.id===this.callAddingInProgress&&(this.callAddingInProgress=void 0)}),await this.setupCall(s),i.direction==="outgoing"){const l=this.getActiveCalls[i.id].roomId;this.setActiveRoom(l)}}setMuteWhenJoin(s){this.muteWhenJoinEnabled=s,this.context.emit("changeMuteWhenJoin",s)}setMicrophoneSensitivity(s){if(s<0||s>1)throw new Error("Value should be in range from 0 to 1!");this.microphoneInputLevelValue=s,this.roomReconfigure(this.currentActiveRoomId)}setSpeakerVolume(s){this.speakerVolumeValue=s,Object.values(this.extendedCalls).forEach(i=>{i.audioTag&&(i.audioTag.volume=s,this.updateCall(i))})}setAutoAnswer(s){this.isAutoAnswer=s}setSelectedInputDevice(s){localStorage.setItem(Ca.SELECTED_INPUT_DEVICE,s),this.selectedMediaDevices.input=s,this.context.emit("changeActiveInputMediaDevice",s)}setSelectedOutputDevice(s){localStorage.setItem(Ca.SELECTED_OUTPUT_DEVICE,s),this.selectedMediaDevices.output=s,this.context.emit("changeActiveOutputMediaDevice",s)}setCallMetrics(s){const i={...s};delete i.callId,this.callMetrics={...this.callMetrics,[s.callId]:i},this.context.emit("changeCallMetrics",this.callMetrics)}removeCallMetrics(s){const i={...this.callMetrics};delete i[s],this.callMetrics={...i},this.context.emit("changeCallMetrics",this.callMetrics)}getCallQuality(s){const i=new Lv(this.metricConfig),l=i.createProbe(s.connection,{cid:s._id}),a=[];let _;l.onreport=e=>{Object.entries(e.audio).forEach(([n,v])=>{v.direction==="inbound"&&!a.includes(n)&&(a.push(n),_=n)});const p=e.audio[_];if(!p)return;const g=$v(p,Hv);g.callId=s._id,this.setCallMetrics(g)},this.context.subscribe(Kt.CALL_ENDED,e=>{e._id===s._id&&i.stopAllProbes()}),i.startAllProbes()}setupVUMeter(s,i){this.VUMeter.start(s,i)}stopVUMeter(s){this.VUMeter.stop(s)}async setupStream(){const s=await navigator.mediaDevices.getUserMedia(this.getUserMediaConstraints);this.initialStreamValue&&(this.initialStreamValue.getTracks().forEach(i=>i.stop()),this.initialStreamValue=null),this.initialStreamValue=s}async triggerAddStream(s,i){this.setIsMuted(this.muteWhenJoin||this.isMuted),this.initialStreamValue||await this.setupStream();const l=E_(this.initialStreamValue,this.microphoneInputLevel*2),a=this.isMuted||this.muteWhenJoin;l.getTracks().forEach(e=>e.enabled=!a),this.setActiveStream(l),await i.connection.getSenders()[0].replaceTrack(l.getTracks()[0]);const _=new MediaStream([s.track]);NT(_,i,this.selectedOutputDevice,this.speakerVolume),this.setupVUMeter(_,i._id),this.getCallQuality(i),this.updateCall(i)}initCall(s,i){if(s.length===0)return console.error("Target must be a valid string");this.context.logger.log(`Calling sip:${s}@${this.context.sipDomain}...`);const l=this.context.call(`sip:${s}@${this.context.sipDomain}`,this.sipOptions);this.callAddingInProgress=l.id,i&&this.currentActiveRoomId!==void 0&&this.processRoomChange({callId:l.id,roomId:this.currentActiveRoomId}),l.connection.addEventListener("track",a=>{this.triggerAddStream(a,l)})}async processRoomChange({callId:s,roomId:i}){const l=this.extendedCalls[s].roomId;this.extendedCalls[s].roomId=i;const a=this.extendedCalls[s];return this.updateCall(a),await this.setActiveRoom(i),Promise.all([this.roomReconfigure(l),this.roomReconfigure(i)]).then(()=>{this.deleteRoomIfEmpty(l),this.deleteRoomIfEmpty(i)})}}class Vv{constructor(s){this.context=s}get sipOptions(){return{...this.context.options.sipOptions}}initCall(s,i){if(s.length===0)return console.error("Target must be a valid string");this.context.logger.log(`Calling sip:${s}@${this.context.sipDomain}...`),this.context.joinVideoCall(`sip:${s}@${this.context.sipDomain}`,i,this.sipOptions)}stop(s={}){this.context.terminateJanusSessions(s)}}class Bv{constructor(s){this.activeMessages={},this.extendedMessages={},this.msrpHistory={},this.context=s,this.context.on(this.context.newMSRPSessionEventName,this.newMSRPSessionCallback.bind(this.context))}get isMSRPInitializing(){return this.isMSRPInitializingValue}get getActiveMessages(){return this.activeMessages}msrpAnswer(s){const i=this.extendedMessages[s];this.updateMSRPSession(i)}updateMSRPSession(s){this.activeMessages[s._id]=v_(s),this.context.emit("changeActiveMessages",this.activeMessages)}addMMSRPSession(s){this.activeMessages={...this.activeMessages,[s._id]:v_(s)},this.extendedMessages[s._id]=s,this.context.emit("changeActiveMessages",this.activeMessages)}addMSRPMessage(s,i){const l=this.msrpHistory[i.id]||[];l.push(s),this.msrpHistory={...this.msrpHistory,[i.id]:[...l]},this.context.emit("newMSRPMessage",{message:s,session:i})}messageTerminate(s){const i=this.extendedMessages[s];i._status!==8&&i.terminate()}addMessageSession(s){if(!s._id||this.getActiveMessages[s._id]!==void 0)return;const l=s;this.addMMSRPSession(l)}triggerMSRPListener({listenerType:s,session:i,event:l}){const a=this.context.listenersList[s];!a||!a.length||a.forEach(_=>{_(i,l)})}removeMMSRPSession(s){const i={...this.activeMessages};delete i[s],this.activeMessages={...i};const l={...this.extendedMessages};delete l[s],this.extendedMessages={...l},this.context.emit("changeActiveMessages",this.activeMessages)}activeMessageListRemove(s){this.removeMMSRPSession(s._id)}newMSRPSessionCallback(s){const i=s.session;i.on("ended",l=>{this.triggerMSRPListener({listenerType:Kt.CALL_ENDED,session:i,event:l});const a=this.getActiveMessages[i.id];this.activeMessageListRemove(a)}),i.on("failed",l=>{this.triggerMSRPListener({listenerType:Kt.CALL_FAILED,session:i,event:l});const a=this.getActiveMessages[i.id];this.activeMessageListRemove(a)}),i.on("confirmed",l=>{this.triggerMSRPListener({listenerType:Kt.CALL_CONFIRMED,session:i,event:l}),this.updateMSRPSession(i)}),i.on("newMessage",l=>{this.addMSRPMessage(l,i)}),this.addMessageSession(i)}setIsMSRPInitializing(s){this.isMSRPInitializingValue=s,this.context.emit("isMSRPInitializingChanged",s)}initMSRP(s,i,l){if(s.length===0)return console.error("Target must be a valid string");const a=this.context.startMSRP(s,l);a.on("active",()=>{this.addMessageSession(a),a.sendMSRP(i),this.setIsMSRPInitializing(!1)}),this.setIsMSRPInitializing(!0)}sendMSRP(s,i){const l=this.extendedMessages[s];if(!l)throw new Error(`MSRP session with id ${s} doesn't exist!`);l.sendMSRP(i)}}const ku={AUDIO:"audio",VIDEO:"video",MSRP:"msrp"};class Gv extends CT{constructor(s,i){if(!s.modules.length)throw new Error("options.modules should include at least 1 module");const l={...s.configuration,sockets:s.socketInterfaces.map(a=>new GT.WebSocketInterface(a))};super(l),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.audio=null,this.msrp=null,this.video=null,this.listenersList={},this.modules=[],s.pnExtraHeaders&&Object.keys(s.pnExtraHeaders).length&&this.registrator().setExtraContactUriParams(s.pnExtraHeaders),this.options=s,this.modules=s.modules,i&&UT(i)&&(this.logger=i)}on(s,i){return super.on(s,i)}off(s,i){return super.off(s,i)}emit(s,i){return super.emit(s,i)}get sipDomain(){return this.options.sipDomain}begin(){if(this.isConnected()){console.error("Connection is already established");return}return this.modules.includes(ku.AUDIO)&&(this.audio=new qv(this)),this.modules.includes(ku.MSRP)&&(this.msrp=new Bv(this)),this.modules.includes(ku.VIDEO)&&(this.video=new Vv(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.isReconnecting=!1}),this.on(this.disconnectedEventName,()=>{this.isReconnecting||(this.logger.log("Disconnected from",this.options.socketInterfaces[0]),this.logger.log("Reconnecting to",this.options.socketInterfaces[0]),this.isReconnecting=!0,this.stop(),this.setInitialized(!1),this.setConnected(!1),setTimeout(this.start.bind(this),5e3))}),this.logger.log("Connecting to",this.options.socketInterfaces[0]),this.start(),this}subscribe(s,i){const a=!this.listenersList[s]||!this.listenersList[s].length?[i]:[...this.listenersList[s],i];this.listenersList={...this.listenersList,[s]:a}}removeIListener(s){const i={...this.listenersList};delete i[s],this.listenersList={...i}}triggerListener({listenerType:s,session:i,event:l}){const a=this.listenersList[s];!a||!a.length||a.forEach(_=>{_(i,l)})}setInitialized(s){this.initialized=s,this.emit("ready",s)}setConnected(s){this.connected=s,this.emit("connection",s)}}return Gv}();
|