@voicenter-team/opensips-js 1.0.22 → 1.0.42

Sign up to get free protection for your applications and to get access to all the features.
Files changed (65) hide show
  1. package/dist/index.d.ts +737 -0
  2. package/dist/opensips-js.cjs.js +155 -0
  3. package/dist/opensips-js.es.js +21363 -0
  4. package/dist/opensips-js.iife.js +155 -0
  5. package/dist/opensips-js.umd.js +155 -0
  6. package/package.json +14 -8
  7. package/src/types/Dialog.d.ts +7 -0
  8. package/src/types/Socket.d.ts +8 -0
  9. package/src/types/UAExtended.d.ts +24 -12
  10. package/src/types/listeners.d.ts +12 -4
  11. package/src/types/msrp.d.ts +15 -9
  12. package/src/types/rtc.d.ts +15 -5
  13. package/src/types/timer.d.ts +7 -0
  14. package/build/enum/call.event.listener.type.d.ts +0 -7
  15. package/build/enum/call.event.listener.type.js +0 -10
  16. package/build/enum/message.event.listener.type.d.ts +0 -5
  17. package/build/enum/message.event.listener.type.js +0 -8
  18. package/build/enum/metric.keys.to.include.d.ts +0 -2
  19. package/build/enum/metric.keys.to.include.js +0 -4
  20. package/build/enum/session.direction.enum.d.ts +0 -2
  21. package/build/enum/session.direction.enum.js +0 -5
  22. package/build/helpers/UA/index.d.ts +0 -41
  23. package/build/helpers/UA/index.js +0 -318
  24. package/build/helpers/audio.helper.d.ts +0 -15
  25. package/build/helpers/audio.helper.js +0 -97
  26. package/build/helpers/filter.helper.d.ts +0 -2
  27. package/build/helpers/filter.helper.js +0 -14
  28. package/build/helpers/jssip.d.ts +0 -5
  29. package/build/helpers/jssip.js +0 -30
  30. package/build/helpers/time.helper.d.ts +0 -16
  31. package/build/helpers/time.helper.js +0 -28
  32. package/build/helpers/volume.helper.d.ts +0 -2
  33. package/build/helpers/volume.helper.js +0 -76
  34. package/build/helpers/webrtcmetrics/collector.d.ts +0 -32
  35. package/build/helpers/webrtcmetrics/collector.js +0 -282
  36. package/build/helpers/webrtcmetrics/engine.d.ts +0 -20
  37. package/build/helpers/webrtcmetrics/engine.js +0 -164
  38. package/build/helpers/webrtcmetrics/exporter.d.ts +0 -116
  39. package/build/helpers/webrtcmetrics/exporter.js +0 -528
  40. package/build/helpers/webrtcmetrics/extractor.d.ts +0 -1
  41. package/build/helpers/webrtcmetrics/extractor.js +0 -976
  42. package/build/helpers/webrtcmetrics/index.d.ts +0 -63
  43. package/build/helpers/webrtcmetrics/index.js +0 -93
  44. package/build/helpers/webrtcmetrics/metrics.d.ts +0 -2
  45. package/build/helpers/webrtcmetrics/metrics.js +0 -8
  46. package/build/helpers/webrtcmetrics/probe.d.ts +0 -76
  47. package/build/helpers/webrtcmetrics/probe.js +0 -153
  48. package/build/helpers/webrtcmetrics/utils/config.d.ts +0 -12
  49. package/build/helpers/webrtcmetrics/utils/config.js +0 -28
  50. package/build/helpers/webrtcmetrics/utils/helper.d.ts +0 -13
  51. package/build/helpers/webrtcmetrics/utils/helper.js +0 -134
  52. package/build/helpers/webrtcmetrics/utils/log.d.ts +0 -7
  53. package/build/helpers/webrtcmetrics/utils/log.js +0 -71
  54. package/build/helpers/webrtcmetrics/utils/models.d.ts +0 -309
  55. package/build/helpers/webrtcmetrics/utils/models.js +0 -298
  56. package/build/helpers/webrtcmetrics/utils/score.d.ts +0 -4
  57. package/build/helpers/webrtcmetrics/utils/score.js +0 -235
  58. package/build/helpers/webrtcmetrics/utils/shortUUId.d.ts +0 -1
  59. package/build/helpers/webrtcmetrics/utils/shortUUId.js +0 -7
  60. package/build/index.d.ts +0 -180
  61. package/build/index.js +0 -1141
  62. package/build/lib/msrp/message.d.ts +0 -12
  63. package/build/lib/msrp/message.js +0 -82
  64. package/build/lib/msrp/session.d.ts +0 -94
  65. package/build/lib/msrp/session.js +0 -621
@@ -0,0 +1,155 @@
1
+ var OpensipsJS=function(){"use strict";var Qf=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function qt(c){return c&&c.__esModule&&Object.prototype.hasOwnProperty.call(c,"default")?c.default:c}const el={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 vu=el,Xe={USER_AGENT:"".concat(vu.title," ").concat(vu.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 tl(c){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?tl=function(n){return typeof n}:tl=function(n){return n&&typeof Symbol=="function"&&n.constructor===Symbol&&n!==Symbol.prototype?"symbol":typeof n},tl(c)}function sl(c,r){if(!(c instanceof r))throw new TypeError("Cannot call a class as a function")}function nl(c,r){if(typeof r!="function"&&r!==null)throw new TypeError("Super expression must either be null or a function");c.prototype=Object.create(r&&r.prototype,{constructor:{value:c,writable:!0,configurable:!0}}),r&&lr(c,r)}function rl(c){var r=Tu();return function(){var o=or(c),a;if(r){var t=or(this).constructor;a=Reflect.construct(o,arguments,t)}else a=o.apply(this,arguments);return Zf(this,a)}}function Zf(c,r){return r&&(tl(r)==="object"||typeof r=="function")?r:e_(c)}function e_(c){if(c===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return c}function pn(c){var r=typeof Map=="function"?new Map:void 0;return pn=function(o){if(o===null||!t_(o))return o;if(typeof o!="function")throw new TypeError("Super expression must either be null or a function");if(typeof r<"u"){if(r.has(o))return r.get(o);r.set(o,a)}function a(){return il(o,arguments,or(this).constructor)}return a.prototype=Object.create(o.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}}),lr(a,o)},pn(c)}function il(c,r,n){return Tu()?il=Reflect.construct:il=function(a,t,s){var p=[null];p.push.apply(p,t);var _=Function.bind.apply(a,p),d=new _;return s&&lr(d,s.prototype),d},il.apply(null,arguments)}function Tu(){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 t_(c){return Function.toString.call(c).indexOf("[native code]")!==-1}function lr(c,r){return lr=Object.setPrototypeOf||function(o,a){return o.__proto__=a,o},lr(c,r)}function or(c){return or=Object.setPrototypeOf?Object.getPrototypeOf:function(n){return n.__proto__||Object.getPrototypeOf(n)},or(c)}var s_=function(c){nl(n,c);var r=rl(n);function n(o,a){var t;return sl(this,n),t=r.call(this),t.code=1,t.name="CONFIGURATION_ERROR",t.parameter=o,t.value=a,t.message=t.value?"Invalid value ".concat(JSON.stringify(t.value),' for parameter "').concat(t.parameter,'"'):"Missing parameter: ".concat(t.parameter),t}return n}(pn(Error)),n_=function(c){nl(n,c);var r=rl(n);function n(o){var a;return sl(this,n),a=r.call(this),a.code=2,a.name="INVALID_STATE_ERROR",a.status=o,a.message="Invalid status: ".concat(o),a}return n}(pn(Error)),r_=function(c){nl(n,c);var r=rl(n);function n(o){var a;return sl(this,n),a=r.call(this),a.code=3,a.name="NOT_SUPPORTED_ERROR",a.message=o,a}return n}(pn(Error)),i_=function(c){nl(n,c);var r=rl(n);function n(o){var a;return sl(this,n),a=r.call(this),a.code=4,a.name="NOT_READY_ERROR",a.message=o,a}return n}(pn(Error)),ps={ConfigurationError:s_,InvalidStateError:n_,NotSupportedError:r_,NotReadyError:i_},Ye={},Io,Eu;function bo(){if(Eu)return Io;Eu=1;function c(t,s){if(!(t instanceof s))throw new TypeError("Cannot call a class as a function")}function r(t,s){for(var p=0;p<s.length;p++){var _=s[p];_.enumerable=_.enumerable||!1,_.configurable=!0,"value"in _&&(_.writable=!0),Object.defineProperty(t,_.key,_)}}function n(t,s,p){return s&&r(t.prototype,s),p&&r(t,p),t}var o=ms(),a=jt();return Io=function(){n(t,null,[{key:"parse",value:function(p){if(p=a.parse(p,"Name_Addr_Header"),p!==-1)return p}}]);function t(s,p,_){if(c(this,t),!s||!(s instanceof o))throw new TypeError('missing or invalid "uri" parameter');this._uri=s,this._parameters={},this.display_name=p;for(var d in _)Object.prototype.hasOwnProperty.call(_,d)&&this.setParam(d,_[d])}return n(t,[{key:"setParam",value:function(p,_){p&&(this._parameters[p.toLowerCase()]=typeof _>"u"||_===null?null:_.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 _=this._parameters[p];return delete this._parameters[p],_}}},{key:"clearParams",value:function(){this._parameters={}}},{key:"clone",value:function(){return new t(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 _ in this._parameters)Object.prototype.hasOwnProperty.call(this._parameters,_)&&(p+=";".concat(_),this._parameters[_]!==null&&(p+="=".concat(this._parameters[_])));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}}]),t}(),Io}var wo,yu;function jt(){return yu||(yu=1,wo=function(){function c(n){return'"'+n.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\x08/g,"\\b").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\f/g,"\\f").replace(/\r/g,"\\r").replace(/[\x00-\x07\x0B\x0E-\x1F\x80-\uFFFF]/g,escape)+'"'}var r={parse:function(o,a){var t={CRLF:g,DIGIT:v,ALPHA:E,HEXDIG:S,WSP:C,OCTET:I,DQUOTE:w,SP:F,HTAB:L,alphanum:ie,reserved:N,unreserved:H,mark:ve,escaped:me,LWS:M,SWS:D,HCOLON:V,TEXT_UTF8_TRIM:j,TEXT_UTF8char:Y,UTF8_NONASCII:$,UTF8_CONT:X,LHEX:U,token:P,token_nodot:Z,separators:et,word:Q,STAR:W,SLASH:B,EQUAL:te,LPAREN:de,RPAREN:Ae,RAQUOT:Ue,LAQUOT:Se,COMMA:ne,SEMI:Te,COLON:tt,LDQUOT:st,RDQUOT:ge,comment:Ee,ctext:Ce,quoted_string:be,quoted_string_clean:_e,qdtext:ce,quoted_pair:fe,SIP_URI_noparams:Re,SIP_URI:Oe,uri_scheme:Je,uri_scheme_sips:Me,uri_scheme_sip:Ut,userinfo:gt,user:wn,user_unreserved:On,password:Ys,hostport:Xt,host:_s,hostname:zs,domainlabel:Dn,toplabel:Nn,IPv6reference:Js,IPv6address:he,h16:re,ls32:nt,IPv4address:Ft,dec_octet:Rs,port:Br,uri_parameters:Un,uri_parameter:Pn,transport_param:Gr,user_param:Kr,method_param:Wr,ttl_param:Yr,maddr_param:zr,lr_param:Jr,other_param:Xr,pname:Qr,pvalue:Is,paramchar:bs,param_unreserved:Zr,headers:Xs,header:Qs,hname:ei,hvalue:ws,hnv_unreserved:Zs,Request_Response:no,Request_Line:ti,Request_URI:kn,absoluteURI:Mn,hier_part:si,net_path:en,abs_path:tn,opaque_part:Os,uric:Ds,uric_no_slash:ni,path_segments:sn,segment:Ns,param:hs,pchar:Us,scheme:ri,authority:ii,srvr:li,reg_name:oi,query:xn,SIP_Version:Ln,INVITEm:ai,ACKm:ui,OPTIONSm:ci,BYEm:fi,CANCELm:_i,REGISTERm:hi,SUBSCRIBEm:di,NOTIFYm:pi,REFERm:nn,Method:rn,Status_Line:mi,Status_Code:gi,extension_code:vi,Reason_Phrase:ro,Allow_Events:tu,Call_ID:su,Contact:$n,contact_param:Pt,name_addr:kt,display_name:Ps,contact_params:Hn,c_p_q:Ti,c_p_expires:Qt,delta_seconds:Zt,qvalue:Ge,generic_param:Ke,gen_value:io,Content_Disposition:lo,disp_type:Fn,disp_param:qn,handling_param:oo,Content_Encoding:nu,Content_Length:ru,Content_Type:ao,media_type:Ei,m_type:yi,discrete_type:Si,composite_type:ln,extension_token:on,x_token:Ci,m_subtype:jn,m_parameter:Vn,m_value:uo,CSeq:co,CSeq_value:fo,Expires:iu,Event:an,event_type:un,From:Ai,from_param:cn,tag_param:Ri,Max_Forwards:lu,Min_Expires:ou,Name_Addr_Header:au,Proxy_Authenticate:Ii,challenge:Bn,other_challenge:ks,auth_param:es,digest_cln:fn,realm:bi,realm_value:wi,domain:_n,URI:hn,nonce:Oi,nonce_value:Di,opaque:Ni,stale:Ui,algorithm:Pi,qop_options:dn,qop_value:Gn,Proxy_Require:uu,Record_Route:Kn,rec_route:Wn,Reason:ki,reason_param:Yn,reason_cause:_o,Require:cu,Route:zn,route_param:Jn,Subscription_State:ho,substate_value:Xn,subexp_params:Qn,event_reason_value:po,Subject:fu,Supported:_u,To:Mi,to_param:xi,Via:Zn,via_param:Ms,via_params:er,via_ttl:Li,via_maddr:$i,via_received:Hi,via_branch:Fi,response_port:qi,rport:ji,sent_protocol:Vi,protocol_name:Bi,transport:Gi,sent_by:Ki,via_host:Wi,via_port:tr,ttl:Yi,WWW_Authenticate:hu,Session_Expires:mo,s_e_expires:sr,s_e_params:nr,s_e_refresher:go,extension_header:vo,header_value:To,message_body:du,uuid_URI:Eo,uuid:Mt,hex4:xt,hex8:zi,hex12:yo,Refer_To:pu,Replaces:So,call_id:rr,replaces_param:ir,to_tag:Ji,from_tag:Xi,early_flag:Co};if(a!==void 0){if(t[a]===void 0)throw new Error("Invalid rule name: "+c(a)+".")}else a="CRLF";var s=0,p=0,_=[];function d(e){s<p||(s>p&&(p=s,_=[]),_.push(e))}function g(){var e;return o.substr(s,2)===`\r
2
+ `?(e=`\r
3
+ `,s+=2):(e=null,d('"\\r\\n"')),e}function v(){var e;return/^[0-9]/.test(o.charAt(s))?(e=o.charAt(s),s++):(e=null,d("[0-9]")),e}function E(){var e;return/^[a-zA-Z]/.test(o.charAt(s))?(e=o.charAt(s),s++):(e=null,d("[a-zA-Z]")),e}function S(){var e;return/^[0-9a-fA-F]/.test(o.charAt(s))?(e=o.charAt(s),s++):(e=null,d("[0-9a-fA-F]")),e}function C(){var e;return e=F(),e===null&&(e=L()),e}function I(){var e;return/^[\0-\xFF]/.test(o.charAt(s))?(e=o.charAt(s),s++):(e=null,d("[\\0-\\xFF]")),e}function w(){var e;return/^["]/.test(o.charAt(s))?(e=o.charAt(s),s++):(e=null,d('["]')),e}function F(){var e;return o.charCodeAt(s)===32?(e=" ",s++):(e=null,d('" "')),e}function L(){var e;return o.charCodeAt(s)===9?(e=" ",s++):(e=null,d('"\\t"')),e}function ie(){var e;return/^[a-zA-Z0-9]/.test(o.charAt(s))?(e=o.charAt(s),s++):(e=null,d("[a-zA-Z0-9]")),e}function N(){var e;return o.charCodeAt(s)===59?(e=";",s++):(e=null,d('";"')),e===null&&(o.charCodeAt(s)===47?(e="/",s++):(e=null,d('"/"')),e===null&&(o.charCodeAt(s)===63?(e="?",s++):(e=null,d('"?"')),e===null&&(o.charCodeAt(s)===58?(e=":",s++):(e=null,d('":"')),e===null&&(o.charCodeAt(s)===64?(e="@",s++):(e=null,d('"@"')),e===null&&(o.charCodeAt(s)===38?(e="&",s++):(e=null,d('"&"')),e===null&&(o.charCodeAt(s)===61?(e="=",s++):(e=null,d('"="')),e===null&&(o.charCodeAt(s)===43?(e="+",s++):(e=null,d('"+"')),e===null&&(o.charCodeAt(s)===36?(e="$",s++):(e=null,d('"$"')),e===null&&(o.charCodeAt(s)===44?(e=",",s++):(e=null,d('","'))))))))))),e}function H(){var e;return e=ie(),e===null&&(e=ve()),e}function ve(){var e;return o.charCodeAt(s)===45?(e="-",s++):(e=null,d('"-"')),e===null&&(o.charCodeAt(s)===95?(e="_",s++):(e=null,d('"_"')),e===null&&(o.charCodeAt(s)===46?(e=".",s++):(e=null,d('"."')),e===null&&(o.charCodeAt(s)===33?(e="!",s++):(e=null,d('"!"')),e===null&&(o.charCodeAt(s)===126?(e="~",s++):(e=null,d('"~"')),e===null&&(o.charCodeAt(s)===42?(e="*",s++):(e=null,d('"*"')),e===null&&(o.charCodeAt(s)===39?(e="'",s++):(e=null,d(`"'"`)),e===null&&(o.charCodeAt(s)===40?(e="(",s++):(e=null,d('"("')),e===null&&(o.charCodeAt(s)===41?(e=")",s++):(e=null,d('")"')))))))))),e}function me(){var e,l,u,f,h;return f=s,h=s,o.charCodeAt(s)===37?(e="%",s++):(e=null,d('"%"')),e!==null?(l=S(),l!==null?(u=S(),u!==null?e=[e,l,u]:(e=null,s=h)):(e=null,s=h)):(e=null,s=h),e!==null&&(e=function(m,T){return T.join("")}(f,e)),e===null&&(s=f),e}function M(){var e,l,u,f,h,m;for(f=s,h=s,m=s,e=[],l=C();l!==null;)e.push(l),l=C();if(e!==null?(l=g(),l!==null?e=[e,l]:(e=null,s=m)):(e=null,s=m),e=e!==null?e:"",e!==null){if(u=C(),u!==null)for(l=[];u!==null;)l.push(u),u=C();else l=null;l!==null?e=[e,l]:(e=null,s=h)}else e=null,s=h;return e!==null&&(e=function(T){return" "}()),e===null&&(s=f),e}function D(){var e;return e=M(),e=e!==null?e:"",e}function V(){var e,l,u,f,h;for(f=s,h=s,e=[],l=F(),l===null&&(l=L());l!==null;)e.push(l),l=F(),l===null&&(l=L());return e!==null?(o.charCodeAt(s)===58?(l=":",s++):(l=null,d('":"')),l!==null?(u=D(),u!==null?e=[e,l,u]:(e=null,s=h)):(e=null,s=h)):(e=null,s=h),e!==null&&(e=function(m){return":"}()),e===null&&(s=f),e}function j(){var e,l,u,f,h,m,T;if(h=s,m=s,l=Y(),l!==null)for(e=[];l!==null;)e.push(l),l=Y();else e=null;if(e!==null){for(l=[],T=s,u=[],f=M();f!==null;)u.push(f),f=M();for(u!==null?(f=Y(),f!==null?u=[u,f]:(u=null,s=T)):(u=null,s=T);u!==null;){for(l.push(u),T=s,u=[],f=M();f!==null;)u.push(f),f=M();u!==null?(f=Y(),f!==null?u=[u,f]:(u=null,s=T)):(u=null,s=T)}l!==null?e=[e,l]:(e=null,s=m)}else e=null,s=m;return e!==null&&(e=function(y){return o.substring(s,y)}(h)),e===null&&(s=h),e}function Y(){var e;return/^[!-~]/.test(o.charAt(s))?(e=o.charAt(s),s++):(e=null,d("[!-~]")),e===null&&(e=$()),e}function $(){var e;return/^[\x80-\uFFFF]/.test(o.charAt(s))?(e=o.charAt(s),s++):(e=null,d("[\\x80-\\uFFFF]")),e}function X(){var e;return/^[\x80-\xBF]/.test(o.charAt(s))?(e=o.charAt(s),s++):(e=null,d("[\\x80-\\xBF]")),e}function U(){var e;return e=v(),e===null&&(/^[a-f]/.test(o.charAt(s))?(e=o.charAt(s),s++):(e=null,d("[a-f]"))),e}function P(){var e,l,u;if(u=s,l=ie(),l===null&&(o.charCodeAt(s)===45?(l="-",s++):(l=null,d('"-"')),l===null&&(o.charCodeAt(s)===46?(l=".",s++):(l=null,d('"."')),l===null&&(o.charCodeAt(s)===33?(l="!",s++):(l=null,d('"!"')),l===null&&(o.charCodeAt(s)===37?(l="%",s++):(l=null,d('"%"')),l===null&&(o.charCodeAt(s)===42?(l="*",s++):(l=null,d('"*"')),l===null&&(o.charCodeAt(s)===95?(l="_",s++):(l=null,d('"_"')),l===null&&(o.charCodeAt(s)===43?(l="+",s++):(l=null,d('"+"')),l===null&&(o.charCodeAt(s)===96?(l="`",s++):(l=null,d('"`"')),l===null&&(o.charCodeAt(s)===39?(l="'",s++):(l=null,d(`"'"`)),l===null&&(o.charCodeAt(s)===126?(l="~",s++):(l=null,d('"~"')))))))))))),l!==null)for(e=[];l!==null;)e.push(l),l=ie(),l===null&&(o.charCodeAt(s)===45?(l="-",s++):(l=null,d('"-"')),l===null&&(o.charCodeAt(s)===46?(l=".",s++):(l=null,d('"."')),l===null&&(o.charCodeAt(s)===33?(l="!",s++):(l=null,d('"!"')),l===null&&(o.charCodeAt(s)===37?(l="%",s++):(l=null,d('"%"')),l===null&&(o.charCodeAt(s)===42?(l="*",s++):(l=null,d('"*"')),l===null&&(o.charCodeAt(s)===95?(l="_",s++):(l=null,d('"_"')),l===null&&(o.charCodeAt(s)===43?(l="+",s++):(l=null,d('"+"')),l===null&&(o.charCodeAt(s)===96?(l="`",s++):(l=null,d('"`"')),l===null&&(o.charCodeAt(s)===39?(l="'",s++):(l=null,d(`"'"`)),l===null&&(o.charCodeAt(s)===126?(l="~",s++):(l=null,d('"~"'))))))))))));else e=null;return e!==null&&(e=function(f){return o.substring(s,f)}(u)),e===null&&(s=u),e}function Z(){var e,l,u;if(u=s,l=ie(),l===null&&(o.charCodeAt(s)===45?(l="-",s++):(l=null,d('"-"')),l===null&&(o.charCodeAt(s)===33?(l="!",s++):(l=null,d('"!"')),l===null&&(o.charCodeAt(s)===37?(l="%",s++):(l=null,d('"%"')),l===null&&(o.charCodeAt(s)===42?(l="*",s++):(l=null,d('"*"')),l===null&&(o.charCodeAt(s)===95?(l="_",s++):(l=null,d('"_"')),l===null&&(o.charCodeAt(s)===43?(l="+",s++):(l=null,d('"+"')),l===null&&(o.charCodeAt(s)===96?(l="`",s++):(l=null,d('"`"')),l===null&&(o.charCodeAt(s)===39?(l="'",s++):(l=null,d(`"'"`)),l===null&&(o.charCodeAt(s)===126?(l="~",s++):(l=null,d('"~"'))))))))))),l!==null)for(e=[];l!==null;)e.push(l),l=ie(),l===null&&(o.charCodeAt(s)===45?(l="-",s++):(l=null,d('"-"')),l===null&&(o.charCodeAt(s)===33?(l="!",s++):(l=null,d('"!"')),l===null&&(o.charCodeAt(s)===37?(l="%",s++):(l=null,d('"%"')),l===null&&(o.charCodeAt(s)===42?(l="*",s++):(l=null,d('"*"')),l===null&&(o.charCodeAt(s)===95?(l="_",s++):(l=null,d('"_"')),l===null&&(o.charCodeAt(s)===43?(l="+",s++):(l=null,d('"+"')),l===null&&(o.charCodeAt(s)===96?(l="`",s++):(l=null,d('"`"')),l===null&&(o.charCodeAt(s)===39?(l="'",s++):(l=null,d(`"'"`)),l===null&&(o.charCodeAt(s)===126?(l="~",s++):(l=null,d('"~"')))))))))));else e=null;return e!==null&&(e=function(f){return o.substring(s,f)}(u)),e===null&&(s=u),e}function et(){var e;return o.charCodeAt(s)===40?(e="(",s++):(e=null,d('"("')),e===null&&(o.charCodeAt(s)===41?(e=")",s++):(e=null,d('")"')),e===null&&(o.charCodeAt(s)===60?(e="<",s++):(e=null,d('"<"')),e===null&&(o.charCodeAt(s)===62?(e=">",s++):(e=null,d('">"')),e===null&&(o.charCodeAt(s)===64?(e="@",s++):(e=null,d('"@"')),e===null&&(o.charCodeAt(s)===44?(e=",",s++):(e=null,d('","')),e===null&&(o.charCodeAt(s)===59?(e=";",s++):(e=null,d('";"')),e===null&&(o.charCodeAt(s)===58?(e=":",s++):(e=null,d('":"')),e===null&&(o.charCodeAt(s)===92?(e="\\",s++):(e=null,d('"\\\\"')),e===null&&(e=w(),e===null&&(o.charCodeAt(s)===47?(e="/",s++):(e=null,d('"/"')),e===null&&(o.charCodeAt(s)===91?(e="[",s++):(e=null,d('"["')),e===null&&(o.charCodeAt(s)===93?(e="]",s++):(e=null,d('"]"')),e===null&&(o.charCodeAt(s)===63?(e="?",s++):(e=null,d('"?"')),e===null&&(o.charCodeAt(s)===61?(e="=",s++):(e=null,d('"="')),e===null&&(o.charCodeAt(s)===123?(e="{",s++):(e=null,d('"{"')),e===null&&(o.charCodeAt(s)===125?(e="}",s++):(e=null,d('"}"')),e===null&&(e=F(),e===null&&(e=L())))))))))))))))))),e}function Q(){var e,l,u;if(u=s,l=ie(),l===null&&(o.charCodeAt(s)===45?(l="-",s++):(l=null,d('"-"')),l===null&&(o.charCodeAt(s)===46?(l=".",s++):(l=null,d('"."')),l===null&&(o.charCodeAt(s)===33?(l="!",s++):(l=null,d('"!"')),l===null&&(o.charCodeAt(s)===37?(l="%",s++):(l=null,d('"%"')),l===null&&(o.charCodeAt(s)===42?(l="*",s++):(l=null,d('"*"')),l===null&&(o.charCodeAt(s)===95?(l="_",s++):(l=null,d('"_"')),l===null&&(o.charCodeAt(s)===43?(l="+",s++):(l=null,d('"+"')),l===null&&(o.charCodeAt(s)===96?(l="`",s++):(l=null,d('"`"')),l===null&&(o.charCodeAt(s)===39?(l="'",s++):(l=null,d(`"'"`)),l===null&&(o.charCodeAt(s)===126?(l="~",s++):(l=null,d('"~"')),l===null&&(o.charCodeAt(s)===40?(l="(",s++):(l=null,d('"("')),l===null&&(o.charCodeAt(s)===41?(l=")",s++):(l=null,d('")"')),l===null&&(o.charCodeAt(s)===60?(l="<",s++):(l=null,d('"<"')),l===null&&(o.charCodeAt(s)===62?(l=">",s++):(l=null,d('">"')),l===null&&(o.charCodeAt(s)===58?(l=":",s++):(l=null,d('":"')),l===null&&(o.charCodeAt(s)===92?(l="\\",s++):(l=null,d('"\\\\"')),l===null&&(l=w(),l===null&&(o.charCodeAt(s)===47?(l="/",s++):(l=null,d('"/"')),l===null&&(o.charCodeAt(s)===91?(l="[",s++):(l=null,d('"["')),l===null&&(o.charCodeAt(s)===93?(l="]",s++):(l=null,d('"]"')),l===null&&(o.charCodeAt(s)===63?(l="?",s++):(l=null,d('"?"')),l===null&&(o.charCodeAt(s)===123?(l="{",s++):(l=null,d('"{"')),l===null&&(o.charCodeAt(s)===125?(l="}",s++):(l=null,d('"}"'))))))))))))))))))))))))),l!==null)for(e=[];l!==null;)e.push(l),l=ie(),l===null&&(o.charCodeAt(s)===45?(l="-",s++):(l=null,d('"-"')),l===null&&(o.charCodeAt(s)===46?(l=".",s++):(l=null,d('"."')),l===null&&(o.charCodeAt(s)===33?(l="!",s++):(l=null,d('"!"')),l===null&&(o.charCodeAt(s)===37?(l="%",s++):(l=null,d('"%"')),l===null&&(o.charCodeAt(s)===42?(l="*",s++):(l=null,d('"*"')),l===null&&(o.charCodeAt(s)===95?(l="_",s++):(l=null,d('"_"')),l===null&&(o.charCodeAt(s)===43?(l="+",s++):(l=null,d('"+"')),l===null&&(o.charCodeAt(s)===96?(l="`",s++):(l=null,d('"`"')),l===null&&(o.charCodeAt(s)===39?(l="'",s++):(l=null,d(`"'"`)),l===null&&(o.charCodeAt(s)===126?(l="~",s++):(l=null,d('"~"')),l===null&&(o.charCodeAt(s)===40?(l="(",s++):(l=null,d('"("')),l===null&&(o.charCodeAt(s)===41?(l=")",s++):(l=null,d('")"')),l===null&&(o.charCodeAt(s)===60?(l="<",s++):(l=null,d('"<"')),l===null&&(o.charCodeAt(s)===62?(l=">",s++):(l=null,d('">"')),l===null&&(o.charCodeAt(s)===58?(l=":",s++):(l=null,d('":"')),l===null&&(o.charCodeAt(s)===92?(l="\\",s++):(l=null,d('"\\\\"')),l===null&&(l=w(),l===null&&(o.charCodeAt(s)===47?(l="/",s++):(l=null,d('"/"')),l===null&&(o.charCodeAt(s)===91?(l="[",s++):(l=null,d('"["')),l===null&&(o.charCodeAt(s)===93?(l="]",s++):(l=null,d('"]"')),l===null&&(o.charCodeAt(s)===63?(l="?",s++):(l=null,d('"?"')),l===null&&(o.charCodeAt(s)===123?(l="{",s++):(l=null,d('"{"')),l===null&&(o.charCodeAt(s)===125?(l="}",s++):(l=null,d('"}"')))))))))))))))))))))))));else e=null;return e!==null&&(e=function(f){return o.substring(s,f)}(u)),e===null&&(s=u),e}function W(){var e,l,u,f,h;return f=s,h=s,e=D(),e!==null?(o.charCodeAt(s)===42?(l="*",s++):(l=null,d('"*"')),l!==null?(u=D(),u!==null?e=[e,l,u]:(e=null,s=h)):(e=null,s=h)):(e=null,s=h),e!==null&&(e=function(m){return"*"}()),e===null&&(s=f),e}function B(){var e,l,u,f,h;return f=s,h=s,e=D(),e!==null?(o.charCodeAt(s)===47?(l="/",s++):(l=null,d('"/"')),l!==null?(u=D(),u!==null?e=[e,l,u]:(e=null,s=h)):(e=null,s=h)):(e=null,s=h),e!==null&&(e=function(m){return"/"}()),e===null&&(s=f),e}function te(){var e,l,u,f,h;return f=s,h=s,e=D(),e!==null?(o.charCodeAt(s)===61?(l="=",s++):(l=null,d('"="')),l!==null?(u=D(),u!==null?e=[e,l,u]:(e=null,s=h)):(e=null,s=h)):(e=null,s=h),e!==null&&(e=function(m){return"="}()),e===null&&(s=f),e}function de(){var e,l,u,f,h;return f=s,h=s,e=D(),e!==null?(o.charCodeAt(s)===40?(l="(",s++):(l=null,d('"("')),l!==null?(u=D(),u!==null?e=[e,l,u]:(e=null,s=h)):(e=null,s=h)):(e=null,s=h),e!==null&&(e=function(m){return"("}()),e===null&&(s=f),e}function Ae(){var e,l,u,f,h;return f=s,h=s,e=D(),e!==null?(o.charCodeAt(s)===41?(l=")",s++):(l=null,d('")"')),l!==null?(u=D(),u!==null?e=[e,l,u]:(e=null,s=h)):(e=null,s=h)):(e=null,s=h),e!==null&&(e=function(m){return")"}()),e===null&&(s=f),e}function Ue(){var e,l,u,f;return u=s,f=s,o.charCodeAt(s)===62?(e=">",s++):(e=null,d('">"')),e!==null?(l=D(),l!==null?e=[e,l]:(e=null,s=f)):(e=null,s=f),e!==null&&(e=function(h){return">"}()),e===null&&(s=u),e}function Se(){var e,l,u,f;return u=s,f=s,e=D(),e!==null?(o.charCodeAt(s)===60?(l="<",s++):(l=null,d('"<"')),l!==null?e=[e,l]:(e=null,s=f)):(e=null,s=f),e!==null&&(e=function(h){return"<"}()),e===null&&(s=u),e}function ne(){var e,l,u,f,h;return f=s,h=s,e=D(),e!==null?(o.charCodeAt(s)===44?(l=",",s++):(l=null,d('","')),l!==null?(u=D(),u!==null?e=[e,l,u]:(e=null,s=h)):(e=null,s=h)):(e=null,s=h),e!==null&&(e=function(m){return","}()),e===null&&(s=f),e}function Te(){var e,l,u,f,h;return f=s,h=s,e=D(),e!==null?(o.charCodeAt(s)===59?(l=";",s++):(l=null,d('";"')),l!==null?(u=D(),u!==null?e=[e,l,u]:(e=null,s=h)):(e=null,s=h)):(e=null,s=h),e!==null&&(e=function(m){return";"}()),e===null&&(s=f),e}function tt(){var e,l,u,f,h;return f=s,h=s,e=D(),e!==null?(o.charCodeAt(s)===58?(l=":",s++):(l=null,d('":"')),l!==null?(u=D(),u!==null?e=[e,l,u]:(e=null,s=h)):(e=null,s=h)):(e=null,s=h),e!==null&&(e=function(m){return":"}()),e===null&&(s=f),e}function st(){var e,l,u,f;return u=s,f=s,e=D(),e!==null?(l=w(),l!==null?e=[e,l]:(e=null,s=f)):(e=null,s=f),e!==null&&(e=function(h){return'"'}()),e===null&&(s=u),e}function ge(){var e,l,u,f;return u=s,f=s,e=w(),e!==null?(l=D(),l!==null?e=[e,l]:(e=null,s=f)):(e=null,s=f),e!==null&&(e=function(h){return'"'}()),e===null&&(s=u),e}function Ee(){var e,l,u,f;if(f=s,e=de(),e!==null){for(l=[],u=Ce(),u===null&&(u=fe(),u===null&&(u=Ee()));u!==null;)l.push(u),u=Ce(),u===null&&(u=fe(),u===null&&(u=Ee()));l!==null?(u=Ae(),u!==null?e=[e,l,u]:(e=null,s=f)):(e=null,s=f)}else e=null,s=f;return e}function Ce(){var e;return/^[!-']/.test(o.charAt(s))?(e=o.charAt(s),s++):(e=null,d("[!-']")),e===null&&(/^[*-[]/.test(o.charAt(s))?(e=o.charAt(s),s++):(e=null,d("[*-[]")),e===null&&(/^[\]-~]/.test(o.charAt(s))?(e=o.charAt(s),s++):(e=null,d("[\\]-~]")),e===null&&(e=$(),e===null&&(e=M())))),e}function be(){var e,l,u,f,h,m;if(h=s,m=s,e=D(),e!==null)if(l=w(),l!==null){for(u=[],f=ce(),f===null&&(f=fe());f!==null;)u.push(f),f=ce(),f===null&&(f=fe());u!==null?(f=w(),f!==null?e=[e,l,u,f]:(e=null,s=m)):(e=null,s=m)}else e=null,s=m;else e=null,s=m;return e!==null&&(e=function(T){return o.substring(s,T)}(h)),e===null&&(s=h),e}function _e(){var e,l,u,f,h,m;if(h=s,m=s,e=D(),e!==null)if(l=w(),l!==null){for(u=[],f=ce(),f===null&&(f=fe());f!==null;)u.push(f),f=ce(),f===null&&(f=fe());u!==null?(f=w(),f!==null?e=[e,l,u,f]:(e=null,s=m)):(e=null,s=m)}else e=null,s=m;else e=null,s=m;return e!==null&&(e=function(T){var y=o.substring(s,T).trim();return y.substring(1,y.length-1).replace(/\\([\x00-\x09\x0b-\x0c\x0e-\x7f])/g,"$1")}(h)),e===null&&(s=h),e}function ce(){var e;return e=M(),e===null&&(o.charCodeAt(s)===33?(e="!",s++):(e=null,d('"!"')),e===null&&(/^[#-[]/.test(o.charAt(s))?(e=o.charAt(s),s++):(e=null,d("[#-[]")),e===null&&(/^[\]-~]/.test(o.charAt(s))?(e=o.charAt(s),s++):(e=null,d("[\\]-~]")),e===null&&(e=$())))),e}function fe(){var e,l,u;return u=s,o.charCodeAt(s)===92?(e="\\",s++):(e=null,d('"\\\\"')),e!==null?(/^[\0-\t]/.test(o.charAt(s))?(l=o.charAt(s),s++):(l=null,d("[\\0-\\t]")),l===null&&(/^[\x0B-\f]/.test(o.charAt(s))?(l=o.charAt(s),s++):(l=null,d("[\\x0B-\\f]")),l===null&&(/^[\x0E-]/.test(o.charAt(s))?(l=o.charAt(s),s++):(l=null,d("[\\x0E-]")))),l!==null?e=[e,l]:(e=null,s=u)):(e=null,s=u),e}function Re(){var e,l,u,f,h,m;return h=s,m=s,e=Je(),e!==null?(o.charCodeAt(s)===58?(l=":",s++):(l=null,d('":"')),l!==null?(u=gt(),u=u!==null?u:"",u!==null?(f=Xt(),f!==null?e=[e,l,u,f]:(e=null,s=m)):(e=null,s=m)):(e=null,s=m)):(e=null,s=m),e!==null&&(e=function(T){try{b.uri=new ds(b.scheme,b.user,b.host,b.port),delete b.scheme,delete b.user,delete b.host,delete b.host_type,delete b.port}catch{b=-1}}()),e===null&&(s=h),e}function Oe(){var e,l,u,f,h,m,T,y;return T=s,y=s,e=Je(),e!==null?(o.charCodeAt(s)===58?(l=":",s++):(l=null,d('":"')),l!==null?(u=gt(),u=u!==null?u:"",u!==null?(f=Xt(),f!==null?(h=Un(),h!==null?(m=Xs(),m=m!==null?m:"",m!==null?e=[e,l,u,f,h,m]:(e=null,s=y)):(e=null,s=y)):(e=null,s=y)):(e=null,s=y)):(e=null,s=y)):(e=null,s=y),e!==null&&(e=function(O){try{b.uri=new ds(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}}()),e===null&&(s=T),e}function Je(){var e;return e=Me(),e===null&&(e=Ut()),e}function Me(){var e,l;return l=s,o.substr(s,4).toLowerCase()==="sips"?(e=o.substr(s,4),s+=4):(e=null,d('"sips"')),e!==null&&(e=function(u,f){b.scheme=f.toLowerCase()}(l,e)),e===null&&(s=l),e}function Ut(){var e,l;return l=s,o.substr(s,3).toLowerCase()==="sip"?(e=o.substr(s,3),s+=3):(e=null,d('"sip"')),e!==null&&(e=function(u,f){b.scheme=f.toLowerCase()}(l,e)),e===null&&(s=l),e}function gt(){var e,l,u,f,h,m;return f=s,h=s,e=wn(),e!==null?(m=s,o.charCodeAt(s)===58?(l=":",s++):(l=null,d('":"')),l!==null?(u=Ys(),u!==null?l=[l,u]:(l=null,s=m)):(l=null,s=m),l=l!==null?l:"",l!==null?(o.charCodeAt(s)===64?(u="@",s++):(u=null,d('"@"')),u!==null?e=[e,l,u]:(e=null,s=h)):(e=null,s=h)):(e=null,s=h),e!==null&&(e=function(T){b.user=decodeURIComponent(o.substring(s-1,T))}(f)),e===null&&(s=f),e}function wn(){var e,l;if(l=H(),l===null&&(l=me(),l===null&&(l=On())),l!==null)for(e=[];l!==null;)e.push(l),l=H(),l===null&&(l=me(),l===null&&(l=On()));else e=null;return e}function On(){var e;return o.charCodeAt(s)===38?(e="&",s++):(e=null,d('"&"')),e===null&&(o.charCodeAt(s)===61?(e="=",s++):(e=null,d('"="')),e===null&&(o.charCodeAt(s)===43?(e="+",s++):(e=null,d('"+"')),e===null&&(o.charCodeAt(s)===36?(e="$",s++):(e=null,d('"$"')),e===null&&(o.charCodeAt(s)===44?(e=",",s++):(e=null,d('","')),e===null&&(o.charCodeAt(s)===59?(e=";",s++):(e=null,d('";"')),e===null&&(o.charCodeAt(s)===63?(e="?",s++):(e=null,d('"?"')),e===null&&(o.charCodeAt(s)===47?(e="/",s++):(e=null,d('"/"'))))))))),e}function Ys(){var e,l,u;for(u=s,e=[],l=H(),l===null&&(l=me(),l===null&&(o.charCodeAt(s)===38?(l="&",s++):(l=null,d('"&"')),l===null&&(o.charCodeAt(s)===61?(l="=",s++):(l=null,d('"="')),l===null&&(o.charCodeAt(s)===43?(l="+",s++):(l=null,d('"+"')),l===null&&(o.charCodeAt(s)===36?(l="$",s++):(l=null,d('"$"')),l===null&&(o.charCodeAt(s)===44?(l=",",s++):(l=null,d('","'))))))));l!==null;)e.push(l),l=H(),l===null&&(l=me(),l===null&&(o.charCodeAt(s)===38?(l="&",s++):(l=null,d('"&"')),l===null&&(o.charCodeAt(s)===61?(l="=",s++):(l=null,d('"="')),l===null&&(o.charCodeAt(s)===43?(l="+",s++):(l=null,d('"+"')),l===null&&(o.charCodeAt(s)===36?(l="$",s++):(l=null,d('"$"')),l===null&&(o.charCodeAt(s)===44?(l=",",s++):(l=null,d('","'))))))));return e!==null&&(e=function(f){b.password=o.substring(s,f)}(u)),e===null&&(s=u),e}function Xt(){var e,l,u,f,h;return f=s,e=_s(),e!==null?(h=s,o.charCodeAt(s)===58?(l=":",s++):(l=null,d('":"')),l!==null?(u=Br(),u!==null?l=[l,u]:(l=null,s=h)):(l=null,s=h),l=l!==null?l:"",l!==null?e=[e,l]:(e=null,s=f)):(e=null,s=f),e}function _s(){var e,l;return l=s,e=zs(),e===null&&(e=Ft(),e===null&&(e=Js())),e!==null&&(e=function(u){return b.host=o.substring(s,u).toLowerCase(),b.host}(l)),e===null&&(s=l),e}function zs(){var e,l,u,f,h,m;for(f=s,h=s,e=[],m=s,l=Dn(),l!==null?(o.charCodeAt(s)===46?(u=".",s++):(u=null,d('"."')),u!==null?l=[l,u]:(l=null,s=m)):(l=null,s=m);l!==null;)e.push(l),m=s,l=Dn(),l!==null?(o.charCodeAt(s)===46?(u=".",s++):(u=null,d('"."')),u!==null?l=[l,u]:(l=null,s=m)):(l=null,s=m);return e!==null?(l=Nn(),l!==null?(o.charCodeAt(s)===46?(u=".",s++):(u=null,d('"."')),u=u!==null?u:"",u!==null?e=[e,l,u]:(e=null,s=h)):(e=null,s=h)):(e=null,s=h),e!==null&&(e=function(T){return b.host_type="domain",o.substring(s,T)}(f)),e===null&&(s=f),e}function Dn(){var e,l,u,f;if(f=s,e=ie(),e!==null){for(l=[],u=ie(),u===null&&(o.charCodeAt(s)===45?(u="-",s++):(u=null,d('"-"')),u===null&&(o.charCodeAt(s)===95?(u="_",s++):(u=null,d('"_"'))));u!==null;)l.push(u),u=ie(),u===null&&(o.charCodeAt(s)===45?(u="-",s++):(u=null,d('"-"')),u===null&&(o.charCodeAt(s)===95?(u="_",s++):(u=null,d('"_"'))));l!==null?e=[e,l]:(e=null,s=f)}else e=null,s=f;return e}function Nn(){var e,l,u,f;if(f=s,e=E(),e!==null){for(l=[],u=ie(),u===null&&(o.charCodeAt(s)===45?(u="-",s++):(u=null,d('"-"')),u===null&&(o.charCodeAt(s)===95?(u="_",s++):(u=null,d('"_"'))));u!==null;)l.push(u),u=ie(),u===null&&(o.charCodeAt(s)===45?(u="-",s++):(u=null,d('"-"')),u===null&&(o.charCodeAt(s)===95?(u="_",s++):(u=null,d('"_"'))));l!==null?e=[e,l]:(e=null,s=f)}else e=null,s=f;return e}function Js(){var e,l,u,f,h;return f=s,h=s,o.charCodeAt(s)===91?(e="[",s++):(e=null,d('"["')),e!==null?(l=he(),l!==null?(o.charCodeAt(s)===93?(u="]",s++):(u=null,d('"]"')),u!==null?e=[e,l,u]:(e=null,s=h)):(e=null,s=h)):(e=null,s=h),e!==null&&(e=function(m){return b.host_type="IPv6",o.substring(s,m)}(f)),e===null&&(s=f),e}function he(){var e,l,u,f,h,m,T,y,O,se,De,Ct,xs,x,A,pe;return x=s,A=s,e=re(),e!==null?(o.charCodeAt(s)===58?(l=":",s++):(l=null,d('":"')),l!==null?(u=re(),u!==null?(o.charCodeAt(s)===58?(f=":",s++):(f=null,d('":"')),f!==null?(h=re(),h!==null?(o.charCodeAt(s)===58?(m=":",s++):(m=null,d('":"')),m!==null?(T=re(),T!==null?(o.charCodeAt(s)===58?(y=":",s++):(y=null,d('":"')),y!==null?(O=re(),O!==null?(o.charCodeAt(s)===58?(se=":",s++):(se=null,d('":"')),se!==null?(De=re(),De!==null?(o.charCodeAt(s)===58?(Ct=":",s++):(Ct=null,d('":"')),Ct!==null?(xs=nt(),xs!==null?e=[e,l,u,f,h,m,T,y,O,se,De,Ct,xs]:(e=null,s=A)):(e=null,s=A)):(e=null,s=A)):(e=null,s=A)):(e=null,s=A)):(e=null,s=A)):(e=null,s=A)):(e=null,s=A)):(e=null,s=A)):(e=null,s=A)):(e=null,s=A)):(e=null,s=A)):(e=null,s=A),e===null&&(A=s,o.substr(s,2)==="::"?(e="::",s+=2):(e=null,d('"::"')),e!==null?(l=re(),l!==null?(o.charCodeAt(s)===58?(u=":",s++):(u=null,d('":"')),u!==null?(f=re(),f!==null?(o.charCodeAt(s)===58?(h=":",s++):(h=null,d('":"')),h!==null?(m=re(),m!==null?(o.charCodeAt(s)===58?(T=":",s++):(T=null,d('":"')),T!==null?(y=re(),y!==null?(o.charCodeAt(s)===58?(O=":",s++):(O=null,d('":"')),O!==null?(se=re(),se!==null?(o.charCodeAt(s)===58?(De=":",s++):(De=null,d('":"')),De!==null?(Ct=nt(),Ct!==null?e=[e,l,u,f,h,m,T,y,O,se,De,Ct]:(e=null,s=A)):(e=null,s=A)):(e=null,s=A)):(e=null,s=A)):(e=null,s=A)):(e=null,s=A)):(e=null,s=A)):(e=null,s=A)):(e=null,s=A)):(e=null,s=A)):(e=null,s=A)):(e=null,s=A),e===null&&(A=s,o.substr(s,2)==="::"?(e="::",s+=2):(e=null,d('"::"')),e!==null?(l=re(),l!==null?(o.charCodeAt(s)===58?(u=":",s++):(u=null,d('":"')),u!==null?(f=re(),f!==null?(o.charCodeAt(s)===58?(h=":",s++):(h=null,d('":"')),h!==null?(m=re(),m!==null?(o.charCodeAt(s)===58?(T=":",s++):(T=null,d('":"')),T!==null?(y=re(),y!==null?(o.charCodeAt(s)===58?(O=":",s++):(O=null,d('":"')),O!==null?(se=nt(),se!==null?e=[e,l,u,f,h,m,T,y,O,se]:(e=null,s=A)):(e=null,s=A)):(e=null,s=A)):(e=null,s=A)):(e=null,s=A)):(e=null,s=A)):(e=null,s=A)):(e=null,s=A)):(e=null,s=A)):(e=null,s=A),e===null&&(A=s,o.substr(s,2)==="::"?(e="::",s+=2):(e=null,d('"::"')),e!==null?(l=re(),l!==null?(o.charCodeAt(s)===58?(u=":",s++):(u=null,d('":"')),u!==null?(f=re(),f!==null?(o.charCodeAt(s)===58?(h=":",s++):(h=null,d('":"')),h!==null?(m=re(),m!==null?(o.charCodeAt(s)===58?(T=":",s++):(T=null,d('":"')),T!==null?(y=nt(),y!==null?e=[e,l,u,f,h,m,T,y]:(e=null,s=A)):(e=null,s=A)):(e=null,s=A)):(e=null,s=A)):(e=null,s=A)):(e=null,s=A)):(e=null,s=A)):(e=null,s=A),e===null&&(A=s,o.substr(s,2)==="::"?(e="::",s+=2):(e=null,d('"::"')),e!==null?(l=re(),l!==null?(o.charCodeAt(s)===58?(u=":",s++):(u=null,d('":"')),u!==null?(f=re(),f!==null?(o.charCodeAt(s)===58?(h=":",s++):(h=null,d('":"')),h!==null?(m=nt(),m!==null?e=[e,l,u,f,h,m]:(e=null,s=A)):(e=null,s=A)):(e=null,s=A)):(e=null,s=A)):(e=null,s=A)):(e=null,s=A),e===null&&(A=s,o.substr(s,2)==="::"?(e="::",s+=2):(e=null,d('"::"')),e!==null?(l=re(),l!==null?(o.charCodeAt(s)===58?(u=":",s++):(u=null,d('":"')),u!==null?(f=nt(),f!==null?e=[e,l,u,f]:(e=null,s=A)):(e=null,s=A)):(e=null,s=A)):(e=null,s=A),e===null&&(A=s,o.substr(s,2)==="::"?(e="::",s+=2):(e=null,d('"::"')),e!==null?(l=nt(),l!==null?e=[e,l]:(e=null,s=A)):(e=null,s=A),e===null&&(A=s,o.substr(s,2)==="::"?(e="::",s+=2):(e=null,d('"::"')),e!==null?(l=re(),l!==null?e=[e,l]:(e=null,s=A)):(e=null,s=A),e===null&&(A=s,e=re(),e!==null?(o.substr(s,2)==="::"?(l="::",s+=2):(l=null,d('"::"')),l!==null?(u=re(),u!==null?(o.charCodeAt(s)===58?(f=":",s++):(f=null,d('":"')),f!==null?(h=re(),h!==null?(o.charCodeAt(s)===58?(m=":",s++):(m=null,d('":"')),m!==null?(T=re(),T!==null?(o.charCodeAt(s)===58?(y=":",s++):(y=null,d('":"')),y!==null?(O=re(),O!==null?(o.charCodeAt(s)===58?(se=":",s++):(se=null,d('":"')),se!==null?(De=nt(),De!==null?e=[e,l,u,f,h,m,T,y,O,se,De]:(e=null,s=A)):(e=null,s=A)):(e=null,s=A)):(e=null,s=A)):(e=null,s=A)):(e=null,s=A)):(e=null,s=A)):(e=null,s=A)):(e=null,s=A)):(e=null,s=A)):(e=null,s=A),e===null&&(A=s,e=re(),e!==null?(pe=s,o.charCodeAt(s)===58?(l=":",s++):(l=null,d('":"')),l!==null?(u=re(),u!==null?l=[l,u]:(l=null,s=pe)):(l=null,s=pe),l=l!==null?l:"",l!==null?(o.substr(s,2)==="::"?(u="::",s+=2):(u=null,d('"::"')),u!==null?(f=re(),f!==null?(o.charCodeAt(s)===58?(h=":",s++):(h=null,d('":"')),h!==null?(m=re(),m!==null?(o.charCodeAt(s)===58?(T=":",s++):(T=null,d('":"')),T!==null?(y=re(),y!==null?(o.charCodeAt(s)===58?(O=":",s++):(O=null,d('":"')),O!==null?(se=nt(),se!==null?e=[e,l,u,f,h,m,T,y,O,se]:(e=null,s=A)):(e=null,s=A)):(e=null,s=A)):(e=null,s=A)):(e=null,s=A)):(e=null,s=A)):(e=null,s=A)):(e=null,s=A)):(e=null,s=A)):(e=null,s=A),e===null&&(A=s,e=re(),e!==null?(pe=s,o.charCodeAt(s)===58?(l=":",s++):(l=null,d('":"')),l!==null?(u=re(),u!==null?l=[l,u]:(l=null,s=pe)):(l=null,s=pe),l=l!==null?l:"",l!==null?(pe=s,o.charCodeAt(s)===58?(u=":",s++):(u=null,d('":"')),u!==null?(f=re(),f!==null?u=[u,f]:(u=null,s=pe)):(u=null,s=pe),u=u!==null?u:"",u!==null?(o.substr(s,2)==="::"?(f="::",s+=2):(f=null,d('"::"')),f!==null?(h=re(),h!==null?(o.charCodeAt(s)===58?(m=":",s++):(m=null,d('":"')),m!==null?(T=re(),T!==null?(o.charCodeAt(s)===58?(y=":",s++):(y=null,d('":"')),y!==null?(O=nt(),O!==null?e=[e,l,u,f,h,m,T,y,O]:(e=null,s=A)):(e=null,s=A)):(e=null,s=A)):(e=null,s=A)):(e=null,s=A)):(e=null,s=A)):(e=null,s=A)):(e=null,s=A)):(e=null,s=A),e===null&&(A=s,e=re(),e!==null?(pe=s,o.charCodeAt(s)===58?(l=":",s++):(l=null,d('":"')),l!==null?(u=re(),u!==null?l=[l,u]:(l=null,s=pe)):(l=null,s=pe),l=l!==null?l:"",l!==null?(pe=s,o.charCodeAt(s)===58?(u=":",s++):(u=null,d('":"')),u!==null?(f=re(),f!==null?u=[u,f]:(u=null,s=pe)):(u=null,s=pe),u=u!==null?u:"",u!==null?(pe=s,o.charCodeAt(s)===58?(f=":",s++):(f=null,d('":"')),f!==null?(h=re(),h!==null?f=[f,h]:(f=null,s=pe)):(f=null,s=pe),f=f!==null?f:"",f!==null?(o.substr(s,2)==="::"?(h="::",s+=2):(h=null,d('"::"')),h!==null?(m=re(),m!==null?(o.charCodeAt(s)===58?(T=":",s++):(T=null,d('":"')),T!==null?(y=nt(),y!==null?e=[e,l,u,f,h,m,T,y]:(e=null,s=A)):(e=null,s=A)):(e=null,s=A)):(e=null,s=A)):(e=null,s=A)):(e=null,s=A)):(e=null,s=A)):(e=null,s=A),e===null&&(A=s,e=re(),e!==null?(pe=s,o.charCodeAt(s)===58?(l=":",s++):(l=null,d('":"')),l!==null?(u=re(),u!==null?l=[l,u]:(l=null,s=pe)):(l=null,s=pe),l=l!==null?l:"",l!==null?(pe=s,o.charCodeAt(s)===58?(u=":",s++):(u=null,d('":"')),u!==null?(f=re(),f!==null?u=[u,f]:(u=null,s=pe)):(u=null,s=pe),u=u!==null?u:"",u!==null?(pe=s,o.charCodeAt(s)===58?(f=":",s++):(f=null,d('":"')),f!==null?(h=re(),h!==null?f=[f,h]:(f=null,s=pe)):(f=null,s=pe),f=f!==null?f:"",f!==null?(pe=s,o.charCodeAt(s)===58?(h=":",s++):(h=null,d('":"')),h!==null?(m=re(),m!==null?h=[h,m]:(h=null,s=pe)):(h=null,s=pe),h=h!==null?h:"",h!==null?(o.substr(s,2)==="::"?(m="::",s+=2):(m=null,d('"::"')),m!==null?(T=nt(),T!==null?e=[e,l,u,f,h,m,T]:(e=null,s=A)):(e=null,s=A)):(e=null,s=A)):(e=null,s=A)):(e=null,s=A)):(e=null,s=A)):(e=null,s=A),e===null&&(A=s,e=re(),e!==null?(pe=s,o.charCodeAt(s)===58?(l=":",s++):(l=null,d('":"')),l!==null?(u=re(),u!==null?l=[l,u]:(l=null,s=pe)):(l=null,s=pe),l=l!==null?l:"",l!==null?(pe=s,o.charCodeAt(s)===58?(u=":",s++):(u=null,d('":"')),u!==null?(f=re(),f!==null?u=[u,f]:(u=null,s=pe)):(u=null,s=pe),u=u!==null?u:"",u!==null?(pe=s,o.charCodeAt(s)===58?(f=":",s++):(f=null,d('":"')),f!==null?(h=re(),h!==null?f=[f,h]:(f=null,s=pe)):(f=null,s=pe),f=f!==null?f:"",f!==null?(pe=s,o.charCodeAt(s)===58?(h=":",s++):(h=null,d('":"')),h!==null?(m=re(),m!==null?h=[h,m]:(h=null,s=pe)):(h=null,s=pe),h=h!==null?h:"",h!==null?(pe=s,o.charCodeAt(s)===58?(m=":",s++):(m=null,d('":"')),m!==null?(T=re(),T!==null?m=[m,T]:(m=null,s=pe)):(m=null,s=pe),m=m!==null?m:"",m!==null?(o.substr(s,2)==="::"?(T="::",s+=2):(T=null,d('"::"')),T!==null?(y=re(),y!==null?e=[e,l,u,f,h,m,T,y]:(e=null,s=A)):(e=null,s=A)):(e=null,s=A)):(e=null,s=A)):(e=null,s=A)):(e=null,s=A)):(e=null,s=A)):(e=null,s=A),e===null&&(A=s,e=re(),e!==null?(pe=s,o.charCodeAt(s)===58?(l=":",s++):(l=null,d('":"')),l!==null?(u=re(),u!==null?l=[l,u]:(l=null,s=pe)):(l=null,s=pe),l=l!==null?l:"",l!==null?(pe=s,o.charCodeAt(s)===58?(u=":",s++):(u=null,d('":"')),u!==null?(f=re(),f!==null?u=[u,f]:(u=null,s=pe)):(u=null,s=pe),u=u!==null?u:"",u!==null?(pe=s,o.charCodeAt(s)===58?(f=":",s++):(f=null,d('":"')),f!==null?(h=re(),h!==null?f=[f,h]:(f=null,s=pe)):(f=null,s=pe),f=f!==null?f:"",f!==null?(pe=s,o.charCodeAt(s)===58?(h=":",s++):(h=null,d('":"')),h!==null?(m=re(),m!==null?h=[h,m]:(h=null,s=pe)):(h=null,s=pe),h=h!==null?h:"",h!==null?(pe=s,o.charCodeAt(s)===58?(m=":",s++):(m=null,d('":"')),m!==null?(T=re(),T!==null?m=[m,T]:(m=null,s=pe)):(m=null,s=pe),m=m!==null?m:"",m!==null?(pe=s,o.charCodeAt(s)===58?(T=":",s++):(T=null,d('":"')),T!==null?(y=re(),y!==null?T=[T,y]:(T=null,s=pe)):(T=null,s=pe),T=T!==null?T:"",T!==null?(o.substr(s,2)==="::"?(y="::",s+=2):(y=null,d('"::"')),y!==null?e=[e,l,u,f,h,m,T,y]:(e=null,s=A)):(e=null,s=A)):(e=null,s=A)):(e=null,s=A)):(e=null,s=A)):(e=null,s=A)):(e=null,s=A)):(e=null,s=A))))))))))))))),e!==null&&(e=function(Bv){return b.host_type="IPv6",o.substring(s,Bv)}(x)),e===null&&(s=x),e}function re(){var e,l,u,f,h;return h=s,e=S(),e!==null?(l=S(),l=l!==null?l:"",l!==null?(u=S(),u=u!==null?u:"",u!==null?(f=S(),f=f!==null?f:"",f!==null?e=[e,l,u,f]:(e=null,s=h)):(e=null,s=h)):(e=null,s=h)):(e=null,s=h),e}function nt(){var e,l,u,f;return f=s,e=re(),e!==null?(o.charCodeAt(s)===58?(l=":",s++):(l=null,d('":"')),l!==null?(u=re(),u!==null?e=[e,l,u]:(e=null,s=f)):(e=null,s=f)):(e=null,s=f),e===null&&(e=Ft()),e}function Ft(){var e,l,u,f,h,m,T,y,O;return y=s,O=s,e=Rs(),e!==null?(o.charCodeAt(s)===46?(l=".",s++):(l=null,d('"."')),l!==null?(u=Rs(),u!==null?(o.charCodeAt(s)===46?(f=".",s++):(f=null,d('"."')),f!==null?(h=Rs(),h!==null?(o.charCodeAt(s)===46?(m=".",s++):(m=null,d('"."')),m!==null?(T=Rs(),T!==null?e=[e,l,u,f,h,m,T]:(e=null,s=O)):(e=null,s=O)):(e=null,s=O)):(e=null,s=O)):(e=null,s=O)):(e=null,s=O)):(e=null,s=O),e!==null&&(e=function(se){return b.host_type="IPv4",o.substring(s,se)}(y)),e===null&&(s=y),e}function Rs(){var e,l,u,f;return f=s,o.substr(s,2)==="25"?(e="25",s+=2):(e=null,d('"25"')),e!==null?(/^[0-5]/.test(o.charAt(s))?(l=o.charAt(s),s++):(l=null,d("[0-5]")),l!==null?e=[e,l]:(e=null,s=f)):(e=null,s=f),e===null&&(f=s,o.charCodeAt(s)===50?(e="2",s++):(e=null,d('"2"')),e!==null?(/^[0-4]/.test(o.charAt(s))?(l=o.charAt(s),s++):(l=null,d("[0-4]")),l!==null?(u=v(),u!==null?e=[e,l,u]:(e=null,s=f)):(e=null,s=f)):(e=null,s=f),e===null&&(f=s,o.charCodeAt(s)===49?(e="1",s++):(e=null,d('"1"')),e!==null?(l=v(),l!==null?(u=v(),u!==null?e=[e,l,u]:(e=null,s=f)):(e=null,s=f)):(e=null,s=f),e===null&&(f=s,/^[1-9]/.test(o.charAt(s))?(e=o.charAt(s),s++):(e=null,d("[1-9]")),e!==null?(l=v(),l!==null?e=[e,l]:(e=null,s=f)):(e=null,s=f),e===null&&(e=v())))),e}function Br(){var e,l,u,f,h,m,T;return m=s,T=s,e=v(),e=e!==null?e:"",e!==null?(l=v(),l=l!==null?l:"",l!==null?(u=v(),u=u!==null?u:"",u!==null?(f=v(),f=f!==null?f:"",f!==null?(h=v(),h=h!==null?h:"",h!==null?e=[e,l,u,f,h]:(e=null,s=T)):(e=null,s=T)):(e=null,s=T)):(e=null,s=T)):(e=null,s=T),e!==null&&(e=function(y,O){return O=parseInt(O.join("")),b.port=O,O}(m,e)),e===null&&(s=m),e}function Un(){var e,l,u,f;for(e=[],f=s,o.charCodeAt(s)===59?(l=";",s++):(l=null,d('";"')),l!==null?(u=Pn(),u!==null?l=[l,u]:(l=null,s=f)):(l=null,s=f);l!==null;)e.push(l),f=s,o.charCodeAt(s)===59?(l=";",s++):(l=null,d('";"')),l!==null?(u=Pn(),u!==null?l=[l,u]:(l=null,s=f)):(l=null,s=f);return e}function Pn(){var e;return e=Gr(),e===null&&(e=Kr(),e===null&&(e=Wr(),e===null&&(e=Yr(),e===null&&(e=zr(),e===null&&(e=Jr(),e===null&&(e=Xr())))))),e}function Gr(){var e,l,u,f;return u=s,f=s,o.substr(s,10).toLowerCase()==="transport="?(e=o.substr(s,10),s+=10):(e=null,d('"transport="')),e!==null?(o.substr(s,3).toLowerCase()==="udp"?(l=o.substr(s,3),s+=3):(l=null,d('"udp"')),l===null&&(o.substr(s,3).toLowerCase()==="tcp"?(l=o.substr(s,3),s+=3):(l=null,d('"tcp"')),l===null&&(o.substr(s,4).toLowerCase()==="sctp"?(l=o.substr(s,4),s+=4):(l=null,d('"sctp"')),l===null&&(o.substr(s,3).toLowerCase()==="tls"?(l=o.substr(s,3),s+=3):(l=null,d('"tls"')),l===null&&(l=P())))),l!==null?e=[e,l]:(e=null,s=f)):(e=null,s=f),e!==null&&(e=function(h,m){b.uri_params||(b.uri_params={}),b.uri_params.transport=m.toLowerCase()}(u,e[1])),e===null&&(s=u),e}function Kr(){var e,l,u,f;return u=s,f=s,o.substr(s,5).toLowerCase()==="user="?(e=o.substr(s,5),s+=5):(e=null,d('"user="')),e!==null?(o.substr(s,5).toLowerCase()==="phone"?(l=o.substr(s,5),s+=5):(l=null,d('"phone"')),l===null&&(o.substr(s,2).toLowerCase()==="ip"?(l=o.substr(s,2),s+=2):(l=null,d('"ip"')),l===null&&(l=P())),l!==null?e=[e,l]:(e=null,s=f)):(e=null,s=f),e!==null&&(e=function(h,m){b.uri_params||(b.uri_params={}),b.uri_params.user=m.toLowerCase()}(u,e[1])),e===null&&(s=u),e}function Wr(){var e,l,u,f;return u=s,f=s,o.substr(s,7).toLowerCase()==="method="?(e=o.substr(s,7),s+=7):(e=null,d('"method="')),e!==null?(l=rn(),l!==null?e=[e,l]:(e=null,s=f)):(e=null,s=f),e!==null&&(e=function(h,m){b.uri_params||(b.uri_params={}),b.uri_params.method=m}(u,e[1])),e===null&&(s=u),e}function Yr(){var e,l,u,f;return u=s,f=s,o.substr(s,4).toLowerCase()==="ttl="?(e=o.substr(s,4),s+=4):(e=null,d('"ttl="')),e!==null?(l=Yi(),l!==null?e=[e,l]:(e=null,s=f)):(e=null,s=f),e!==null&&(e=function(h,m){b.params||(b.params={}),b.params.ttl=m}(u,e[1])),e===null&&(s=u),e}function zr(){var e,l,u,f;return u=s,f=s,o.substr(s,6).toLowerCase()==="maddr="?(e=o.substr(s,6),s+=6):(e=null,d('"maddr="')),e!==null?(l=_s(),l!==null?e=[e,l]:(e=null,s=f)):(e=null,s=f),e!==null&&(e=function(h,m){b.uri_params||(b.uri_params={}),b.uri_params.maddr=m}(u,e[1])),e===null&&(s=u),e}function Jr(){var e,l,u,f,h,m;return f=s,h=s,o.substr(s,2).toLowerCase()==="lr"?(e=o.substr(s,2),s+=2):(e=null,d('"lr"')),e!==null?(m=s,o.charCodeAt(s)===61?(l="=",s++):(l=null,d('"="')),l!==null?(u=P(),u!==null?l=[l,u]:(l=null,s=m)):(l=null,s=m),l=l!==null?l:"",l!==null?e=[e,l]:(e=null,s=h)):(e=null,s=h),e!==null&&(e=function(T){b.uri_params||(b.uri_params={}),b.uri_params.lr=void 0}()),e===null&&(s=f),e}function Xr(){var e,l,u,f,h,m;return f=s,h=s,e=Qr(),e!==null?(m=s,o.charCodeAt(s)===61?(l="=",s++):(l=null,d('"="')),l!==null?(u=Is(),u!==null?l=[l,u]:(l=null,s=m)):(l=null,s=m),l=l!==null?l:"",l!==null?e=[e,l]:(e=null,s=h)):(e=null,s=h),e!==null&&(e=function(T,y,O){b.uri_params||(b.uri_params={}),typeof O>"u"?O=void 0:O=O[1],b.uri_params[y.toLowerCase()]=O}(f,e[0],e[1])),e===null&&(s=f),e}function Qr(){var e,l,u;if(u=s,l=bs(),l!==null)for(e=[];l!==null;)e.push(l),l=bs();else e=null;return e!==null&&(e=function(f,h){return h.join("")}(u,e)),e===null&&(s=u),e}function Is(){var e,l,u;if(u=s,l=bs(),l!==null)for(e=[];l!==null;)e.push(l),l=bs();else e=null;return e!==null&&(e=function(f,h){return h.join("")}(u,e)),e===null&&(s=u),e}function bs(){var e;return e=Zr(),e===null&&(e=H(),e===null&&(e=me())),e}function Zr(){var e;return o.charCodeAt(s)===91?(e="[",s++):(e=null,d('"["')),e===null&&(o.charCodeAt(s)===93?(e="]",s++):(e=null,d('"]"')),e===null&&(o.charCodeAt(s)===47?(e="/",s++):(e=null,d('"/"')),e===null&&(o.charCodeAt(s)===58?(e=":",s++):(e=null,d('":"')),e===null&&(o.charCodeAt(s)===38?(e="&",s++):(e=null,d('"&"')),e===null&&(o.charCodeAt(s)===43?(e="+",s++):(e=null,d('"+"')),e===null&&(o.charCodeAt(s)===36?(e="$",s++):(e=null,d('"$"')))))))),e}function Xs(){var e,l,u,f,h,m,T;if(m=s,o.charCodeAt(s)===63?(e="?",s++):(e=null,d('"?"')),e!==null)if(l=Qs(),l!==null){for(u=[],T=s,o.charCodeAt(s)===38?(f="&",s++):(f=null,d('"&"')),f!==null?(h=Qs(),h!==null?f=[f,h]:(f=null,s=T)):(f=null,s=T);f!==null;)u.push(f),T=s,o.charCodeAt(s)===38?(f="&",s++):(f=null,d('"&"')),f!==null?(h=Qs(),h!==null?f=[f,h]:(f=null,s=T)):(f=null,s=T);u!==null?e=[e,l,u]:(e=null,s=m)}else e=null,s=m;else e=null,s=m;return e}function Qs(){var e,l,u,f,h;return f=s,h=s,e=ei(),e!==null?(o.charCodeAt(s)===61?(l="=",s++):(l=null,d('"="')),l!==null?(u=ws(),u!==null?e=[e,l,u]:(e=null,s=h)):(e=null,s=h)):(e=null,s=h),e!==null&&(e=function(m,T,y){T=T.join("").toLowerCase(),y=y.join(""),b.uri_headers||(b.uri_headers={}),b.uri_headers[T]?b.uri_headers[T].push(y):b.uri_headers[T]=[y]}(f,e[0],e[2])),e===null&&(s=f),e}function ei(){var e,l;if(l=Zs(),l===null&&(l=H(),l===null&&(l=me())),l!==null)for(e=[];l!==null;)e.push(l),l=Zs(),l===null&&(l=H(),l===null&&(l=me()));else e=null;return e}function ws(){var e,l;for(e=[],l=Zs(),l===null&&(l=H(),l===null&&(l=me()));l!==null;)e.push(l),l=Zs(),l===null&&(l=H(),l===null&&(l=me()));return e}function Zs(){var e;return o.charCodeAt(s)===91?(e="[",s++):(e=null,d('"["')),e===null&&(o.charCodeAt(s)===93?(e="]",s++):(e=null,d('"]"')),e===null&&(o.charCodeAt(s)===47?(e="/",s++):(e=null,d('"/"')),e===null&&(o.charCodeAt(s)===63?(e="?",s++):(e=null,d('"?"')),e===null&&(o.charCodeAt(s)===58?(e=":",s++):(e=null,d('":"')),e===null&&(o.charCodeAt(s)===43?(e="+",s++):(e=null,d('"+"')),e===null&&(o.charCodeAt(s)===36?(e="$",s++):(e=null,d('"$"')))))))),e}function no(){var e;return e=mi(),e===null&&(e=ti()),e}function ti(){var e,l,u,f,h,m;return m=s,e=rn(),e!==null?(l=F(),l!==null?(u=kn(),u!==null?(f=F(),f!==null?(h=Ln(),h!==null?e=[e,l,u,f,h]:(e=null,s=m)):(e=null,s=m)):(e=null,s=m)):(e=null,s=m)):(e=null,s=m),e}function kn(){var e;return e=Oe(),e===null&&(e=Mn()),e}function Mn(){var e,l,u,f;return f=s,e=ri(),e!==null?(o.charCodeAt(s)===58?(l=":",s++):(l=null,d('":"')),l!==null?(u=si(),u===null&&(u=Os()),u!==null?e=[e,l,u]:(e=null,s=f)):(e=null,s=f)):(e=null,s=f),e}function si(){var e,l,u,f,h;return f=s,e=en(),e===null&&(e=tn()),e!==null?(h=s,o.charCodeAt(s)===63?(l="?",s++):(l=null,d('"?"')),l!==null?(u=xn(),u!==null?l=[l,u]:(l=null,s=h)):(l=null,s=h),l=l!==null?l:"",l!==null?e=[e,l]:(e=null,s=f)):(e=null,s=f),e}function en(){var e,l,u,f;return f=s,o.substr(s,2)==="//"?(e="//",s+=2):(e=null,d('"//"')),e!==null?(l=ii(),l!==null?(u=tn(),u=u!==null?u:"",u!==null?e=[e,l,u]:(e=null,s=f)):(e=null,s=f)):(e=null,s=f),e}function tn(){var e,l,u;return u=s,o.charCodeAt(s)===47?(e="/",s++):(e=null,d('"/"')),e!==null?(l=sn(),l!==null?e=[e,l]:(e=null,s=u)):(e=null,s=u),e}function Os(){var e,l,u,f;if(f=s,e=ni(),e!==null){for(l=[],u=Ds();u!==null;)l.push(u),u=Ds();l!==null?e=[e,l]:(e=null,s=f)}else e=null,s=f;return e}function Ds(){var e;return e=N(),e===null&&(e=H(),e===null&&(e=me())),e}function ni(){var e;return e=H(),e===null&&(e=me(),e===null&&(o.charCodeAt(s)===59?(e=";",s++):(e=null,d('";"')),e===null&&(o.charCodeAt(s)===63?(e="?",s++):(e=null,d('"?"')),e===null&&(o.charCodeAt(s)===58?(e=":",s++):(e=null,d('":"')),e===null&&(o.charCodeAt(s)===64?(e="@",s++):(e=null,d('"@"')),e===null&&(o.charCodeAt(s)===38?(e="&",s++):(e=null,d('"&"')),e===null&&(o.charCodeAt(s)===61?(e="=",s++):(e=null,d('"="')),e===null&&(o.charCodeAt(s)===43?(e="+",s++):(e=null,d('"+"')),e===null&&(o.charCodeAt(s)===36?(e="$",s++):(e=null,d('"$"')),e===null&&(o.charCodeAt(s)===44?(e=",",s++):(e=null,d('","')))))))))))),e}function sn(){var e,l,u,f,h,m;if(h=s,e=Ns(),e!==null){for(l=[],m=s,o.charCodeAt(s)===47?(u="/",s++):(u=null,d('"/"')),u!==null?(f=Ns(),f!==null?u=[u,f]:(u=null,s=m)):(u=null,s=m);u!==null;)l.push(u),m=s,o.charCodeAt(s)===47?(u="/",s++):(u=null,d('"/"')),u!==null?(f=Ns(),f!==null?u=[u,f]:(u=null,s=m)):(u=null,s=m);l!==null?e=[e,l]:(e=null,s=h)}else e=null,s=h;return e}function Ns(){var e,l,u,f,h,m;for(h=s,e=[],l=Us();l!==null;)e.push(l),l=Us();if(e!==null){for(l=[],m=s,o.charCodeAt(s)===59?(u=";",s++):(u=null,d('";"')),u!==null?(f=hs(),f!==null?u=[u,f]:(u=null,s=m)):(u=null,s=m);u!==null;)l.push(u),m=s,o.charCodeAt(s)===59?(u=";",s++):(u=null,d('";"')),u!==null?(f=hs(),f!==null?u=[u,f]:(u=null,s=m)):(u=null,s=m);l!==null?e=[e,l]:(e=null,s=h)}else e=null,s=h;return e}function hs(){var e,l;for(e=[],l=Us();l!==null;)e.push(l),l=Us();return e}function Us(){var e;return e=H(),e===null&&(e=me(),e===null&&(o.charCodeAt(s)===58?(e=":",s++):(e=null,d('":"')),e===null&&(o.charCodeAt(s)===64?(e="@",s++):(e=null,d('"@"')),e===null&&(o.charCodeAt(s)===38?(e="&",s++):(e=null,d('"&"')),e===null&&(o.charCodeAt(s)===61?(e="=",s++):(e=null,d('"="')),e===null&&(o.charCodeAt(s)===43?(e="+",s++):(e=null,d('"+"')),e===null&&(o.charCodeAt(s)===36?(e="$",s++):(e=null,d('"$"')),e===null&&(o.charCodeAt(s)===44?(e=",",s++):(e=null,d('","')))))))))),e}function ri(){var e,l,u,f,h;if(f=s,h=s,e=E(),e!==null){for(l=[],u=E(),u===null&&(u=v(),u===null&&(o.charCodeAt(s)===43?(u="+",s++):(u=null,d('"+"')),u===null&&(o.charCodeAt(s)===45?(u="-",s++):(u=null,d('"-"')),u===null&&(o.charCodeAt(s)===46?(u=".",s++):(u=null,d('"."'))))));u!==null;)l.push(u),u=E(),u===null&&(u=v(),u===null&&(o.charCodeAt(s)===43?(u="+",s++):(u=null,d('"+"')),u===null&&(o.charCodeAt(s)===45?(u="-",s++):(u=null,d('"-"')),u===null&&(o.charCodeAt(s)===46?(u=".",s++):(u=null,d('"."'))))));l!==null?e=[e,l]:(e=null,s=h)}else e=null,s=h;return e!==null&&(e=function(m){b.scheme=o.substring(s,m)}(f)),e===null&&(s=f),e}function ii(){var e;return e=li(),e===null&&(e=oi()),e}function li(){var e,l,u,f;return u=s,f=s,e=gt(),e!==null?(o.charCodeAt(s)===64?(l="@",s++):(l=null,d('"@"')),l!==null?e=[e,l]:(e=null,s=f)):(e=null,s=f),e=e!==null?e:"",e!==null?(l=Xt(),l!==null?e=[e,l]:(e=null,s=u)):(e=null,s=u),e=e!==null?e:"",e}function oi(){var e,l;if(l=H(),l===null&&(l=me(),l===null&&(o.charCodeAt(s)===36?(l="$",s++):(l=null,d('"$"')),l===null&&(o.charCodeAt(s)===44?(l=",",s++):(l=null,d('","')),l===null&&(o.charCodeAt(s)===59?(l=";",s++):(l=null,d('";"')),l===null&&(o.charCodeAt(s)===58?(l=":",s++):(l=null,d('":"')),l===null&&(o.charCodeAt(s)===64?(l="@",s++):(l=null,d('"@"')),l===null&&(o.charCodeAt(s)===38?(l="&",s++):(l=null,d('"&"')),l===null&&(o.charCodeAt(s)===61?(l="=",s++):(l=null,d('"="')),l===null&&(o.charCodeAt(s)===43?(l="+",s++):(l=null,d('"+"'))))))))))),l!==null)for(e=[];l!==null;)e.push(l),l=H(),l===null&&(l=me(),l===null&&(o.charCodeAt(s)===36?(l="$",s++):(l=null,d('"$"')),l===null&&(o.charCodeAt(s)===44?(l=",",s++):(l=null,d('","')),l===null&&(o.charCodeAt(s)===59?(l=";",s++):(l=null,d('";"')),l===null&&(o.charCodeAt(s)===58?(l=":",s++):(l=null,d('":"')),l===null&&(o.charCodeAt(s)===64?(l="@",s++):(l=null,d('"@"')),l===null&&(o.charCodeAt(s)===38?(l="&",s++):(l=null,d('"&"')),l===null&&(o.charCodeAt(s)===61?(l="=",s++):(l=null,d('"="')),l===null&&(o.charCodeAt(s)===43?(l="+",s++):(l=null,d('"+"')))))))))));else e=null;return e}function xn(){var e,l;for(e=[],l=Ds();l!==null;)e.push(l),l=Ds();return e}function Ln(){var e,l,u,f,h,m,T,y;if(T=s,y=s,o.substr(s,3).toLowerCase()==="sip"?(e=o.substr(s,3),s+=3):(e=null,d('"SIP"')),e!==null)if(o.charCodeAt(s)===47?(l="/",s++):(l=null,d('"/"')),l!==null){if(f=v(),f!==null)for(u=[];f!==null;)u.push(f),f=v();else u=null;if(u!==null)if(o.charCodeAt(s)===46?(f=".",s++):(f=null,d('"."')),f!==null){if(m=v(),m!==null)for(h=[];m!==null;)h.push(m),m=v();else h=null;h!==null?e=[e,l,u,f,h]:(e=null,s=y)}else e=null,s=y;else e=null,s=y}else e=null,s=y;else e=null,s=y;return e!==null&&(e=function(O){b.sip_version=o.substring(s,O)}(T)),e===null&&(s=T),e}function ai(){var e;return o.substr(s,6)==="INVITE"?(e="INVITE",s+=6):(e=null,d('"INVITE"')),e}function ui(){var e;return o.substr(s,3)==="ACK"?(e="ACK",s+=3):(e=null,d('"ACK"')),e}function ci(){var e;return o.substr(s,7)==="OPTIONS"?(e="OPTIONS",s+=7):(e=null,d('"OPTIONS"')),e}function fi(){var e;return o.substr(s,3)==="BYE"?(e="BYE",s+=3):(e=null,d('"BYE"')),e}function _i(){var e;return o.substr(s,6)==="CANCEL"?(e="CANCEL",s+=6):(e=null,d('"CANCEL"')),e}function hi(){var e;return o.substr(s,8)==="REGISTER"?(e="REGISTER",s+=8):(e=null,d('"REGISTER"')),e}function di(){var e;return o.substr(s,9)==="SUBSCRIBE"?(e="SUBSCRIBE",s+=9):(e=null,d('"SUBSCRIBE"')),e}function pi(){var e;return o.substr(s,6)==="NOTIFY"?(e="NOTIFY",s+=6):(e=null,d('"NOTIFY"')),e}function nn(){var e;return o.substr(s,5)==="REFER"?(e="REFER",s+=5):(e=null,d('"REFER"')),e}function rn(){var e,l;return l=s,e=ai(),e===null&&(e=ui(),e===null&&(e=ci(),e===null&&(e=fi(),e===null&&(e=_i(),e===null&&(e=hi(),e===null&&(e=di(),e===null&&(e=pi(),e===null&&(e=nn(),e===null&&(e=P()))))))))),e!==null&&(e=function(u){return b.method=o.substring(s,u),b.method}(l)),e===null&&(s=l),e}function mi(){var e,l,u,f,h,m;return m=s,e=Ln(),e!==null?(l=F(),l!==null?(u=gi(),u!==null?(f=F(),f!==null?(h=ro(),h!==null?e=[e,l,u,f,h]:(e=null,s=m)):(e=null,s=m)):(e=null,s=m)):(e=null,s=m)):(e=null,s=m),e}function gi(){var e,l;return l=s,e=vi(),e!==null&&(e=function(u,f){b.status_code=parseInt(f.join(""))}(l,e)),e===null&&(s=l),e}function vi(){var e,l,u,f;return f=s,e=v(),e!==null?(l=v(),l!==null?(u=v(),u!==null?e=[e,l,u]:(e=null,s=f)):(e=null,s=f)):(e=null,s=f),e}function ro(){var e,l,u;for(u=s,e=[],l=N(),l===null&&(l=H(),l===null&&(l=me(),l===null&&(l=$(),l===null&&(l=X(),l===null&&(l=F(),l===null&&(l=L()))))));l!==null;)e.push(l),l=N(),l===null&&(l=H(),l===null&&(l=me(),l===null&&(l=$(),l===null&&(l=X(),l===null&&(l=F(),l===null&&(l=L()))))));return e!==null&&(e=function(f){b.reason_phrase=o.substring(s,f)}(u)),e===null&&(s=u),e}function tu(){var e,l,u,f,h,m;if(h=s,e=un(),e!==null){for(l=[],m=s,u=ne(),u!==null?(f=un(),f!==null?u=[u,f]:(u=null,s=m)):(u=null,s=m);u!==null;)l.push(u),m=s,u=ne(),u!==null?(f=un(),f!==null?u=[u,f]:(u=null,s=m)):(u=null,s=m);l!==null?e=[e,l]:(e=null,s=h)}else e=null,s=h;return e}function su(){var e,l,u,f,h,m;return f=s,h=s,e=Q(),e!==null?(m=s,o.charCodeAt(s)===64?(l="@",s++):(l=null,d('"@"')),l!==null?(u=Q(),u!==null?l=[l,u]:(l=null,s=m)):(l=null,s=m),l=l!==null?l:"",l!==null?e=[e,l]:(e=null,s=h)):(e=null,s=h),e!==null&&(e=function(T){b=o.substring(s,T)}(f)),e===null&&(s=f),e}function $n(){var e,l,u,f,h,m,T;if(h=s,e=W(),e===null)if(m=s,e=Pt(),e!==null){for(l=[],T=s,u=ne(),u!==null?(f=Pt(),f!==null?u=[u,f]:(u=null,s=T)):(u=null,s=T);u!==null;)l.push(u),T=s,u=ne(),u!==null?(f=Pt(),f!==null?u=[u,f]:(u=null,s=T)):(u=null,s=T);l!==null?e=[e,l]:(e=null,s=m)}else e=null,s=m;return e!==null&&(e=function(y){var O,se;for(se=b.multi_header.length,O=0;O<se;O++)if(b.multi_header[O].parsed===null){b=null;break}b!==null?b=b.multi_header:b=-1}()),e===null&&(s=h),e}function Pt(){var e,l,u,f,h,m,T;if(h=s,m=s,e=Re(),e===null&&(e=kt()),e!==null){for(l=[],T=s,u=Te(),u!==null?(f=Hn(),f!==null?u=[u,f]:(u=null,s=T)):(u=null,s=T);u!==null;)l.push(u),T=s,u=Te(),u!==null?(f=Hn(),f!==null?u=[u,f]:(u=null,s=T)):(u=null,s=T);l!==null?e=[e,l]:(e=null,s=m)}else e=null,s=m;return e!==null&&(e=function(y){var O;b.multi_header||(b.multi_header=[]);try{O=new R(b.uri,b.display_name,b.params),delete b.uri,delete b.display_name,delete b.params}catch{O=null}b.multi_header.push({possition:s,offset:y,parsed:O})}(h)),e===null&&(s=h),e}function kt(){var e,l,u,f,h;return h=s,e=Ps(),e=e!==null?e:"",e!==null?(l=Se(),l!==null?(u=Oe(),u!==null?(f=Ue(),f!==null?e=[e,l,u,f]:(e=null,s=h)):(e=null,s=h)):(e=null,s=h)):(e=null,s=h),e}function Ps(){var e,l,u,f,h,m,T;if(h=s,m=s,e=P(),e!==null){for(l=[],T=s,u=M(),u!==null?(f=P(),f!==null?u=[u,f]:(u=null,s=T)):(u=null,s=T);u!==null;)l.push(u),T=s,u=M(),u!==null?(f=P(),f!==null?u=[u,f]:(u=null,s=T)):(u=null,s=T);l!==null?e=[e,l]:(e=null,s=m)}else e=null,s=m;return e===null&&(e=_e()),e!==null&&(e=function(y,O){typeof O=="string"?b.display_name=O:b.display_name=O[1].reduce(function(se,De){return se+De[0]+De[1]},O[0])}(h,e)),e===null&&(s=h),e}function Hn(){var e;return e=Ti(),e===null&&(e=Qt(),e===null&&(e=Ke())),e}function Ti(){var e,l,u,f,h;return f=s,h=s,o.substr(s,1).toLowerCase()==="q"?(e=o.substr(s,1),s++):(e=null,d('"q"')),e!==null?(l=te(),l!==null?(u=Ge(),u!==null?e=[e,l,u]:(e=null,s=h)):(e=null,s=h)):(e=null,s=h),e!==null&&(e=function(m,T){b.params||(b.params={}),b.params.q=T}(f,e[2])),e===null&&(s=f),e}function Qt(){var e,l,u,f,h;return f=s,h=s,o.substr(s,7).toLowerCase()==="expires"?(e=o.substr(s,7),s+=7):(e=null,d('"expires"')),e!==null?(l=te(),l!==null?(u=Zt(),u!==null?e=[e,l,u]:(e=null,s=h)):(e=null,s=h)):(e=null,s=h),e!==null&&(e=function(m,T){b.params||(b.params={}),b.params.expires=T}(f,e[2])),e===null&&(s=f),e}function Zt(){var e,l,u;if(u=s,l=v(),l!==null)for(e=[];l!==null;)e.push(l),l=v();else e=null;return e!==null&&(e=function(f,h){return parseInt(h.join(""))}(u,e)),e===null&&(s=u),e}function Ge(){var e,l,u,f,h,m,T,y;return m=s,T=s,o.charCodeAt(s)===48?(e="0",s++):(e=null,d('"0"')),e!==null?(y=s,o.charCodeAt(s)===46?(l=".",s++):(l=null,d('"."')),l!==null?(u=v(),u=u!==null?u:"",u!==null?(f=v(),f=f!==null?f:"",f!==null?(h=v(),h=h!==null?h:"",h!==null?l=[l,u,f,h]:(l=null,s=y)):(l=null,s=y)):(l=null,s=y)):(l=null,s=y),l=l!==null?l:"",l!==null?e=[e,l]:(e=null,s=T)):(e=null,s=T),e!==null&&(e=function(O){return parseFloat(o.substring(s,O))}(m)),e===null&&(s=m),e}function Ke(){var e,l,u,f,h,m;return f=s,h=s,e=P(),e!==null?(m=s,l=te(),l!==null?(u=io(),u!==null?l=[l,u]:(l=null,s=m)):(l=null,s=m),l=l!==null?l:"",l!==null?e=[e,l]:(e=null,s=h)):(e=null,s=h),e!==null&&(e=function(T,y,O){b.params||(b.params={}),typeof O>"u"?O=void 0:O=O[1],b.params[y.toLowerCase()]=O}(f,e[0],e[1])),e===null&&(s=f),e}function io(){var e;return e=P(),e===null&&(e=_s(),e===null&&(e=be())),e}function lo(){var e,l,u,f,h,m;if(h=s,e=Fn(),e!==null){for(l=[],m=s,u=Te(),u!==null?(f=qn(),f!==null?u=[u,f]:(u=null,s=m)):(u=null,s=m);u!==null;)l.push(u),m=s,u=Te(),u!==null?(f=qn(),f!==null?u=[u,f]:(u=null,s=m)):(u=null,s=m);l!==null?e=[e,l]:(e=null,s=h)}else e=null,s=h;return e}function Fn(){var e;return o.substr(s,6).toLowerCase()==="render"?(e=o.substr(s,6),s+=6):(e=null,d('"render"')),e===null&&(o.substr(s,7).toLowerCase()==="session"?(e=o.substr(s,7),s+=7):(e=null,d('"session"')),e===null&&(o.substr(s,4).toLowerCase()==="icon"?(e=o.substr(s,4),s+=4):(e=null,d('"icon"')),e===null&&(o.substr(s,5).toLowerCase()==="alert"?(e=o.substr(s,5),s+=5):(e=null,d('"alert"')),e===null&&(e=P())))),e}function qn(){var e;return e=oo(),e===null&&(e=Ke()),e}function oo(){var e,l,u,f;return f=s,o.substr(s,8).toLowerCase()==="handling"?(e=o.substr(s,8),s+=8):(e=null,d('"handling"')),e!==null?(l=te(),l!==null?(o.substr(s,8).toLowerCase()==="optional"?(u=o.substr(s,8),s+=8):(u=null,d('"optional"')),u===null&&(o.substr(s,8).toLowerCase()==="required"?(u=o.substr(s,8),s+=8):(u=null,d('"required"')),u===null&&(u=P())),u!==null?e=[e,l,u]:(e=null,s=f)):(e=null,s=f)):(e=null,s=f),e}function nu(){var e,l,u,f,h,m;if(h=s,e=P(),e!==null){for(l=[],m=s,u=ne(),u!==null?(f=P(),f!==null?u=[u,f]:(u=null,s=m)):(u=null,s=m);u!==null;)l.push(u),m=s,u=ne(),u!==null?(f=P(),f!==null?u=[u,f]:(u=null,s=m)):(u=null,s=m);l!==null?e=[e,l]:(e=null,s=h)}else e=null,s=h;return e}function ru(){var e,l,u;if(u=s,l=v(),l!==null)for(e=[];l!==null;)e.push(l),l=v();else e=null;return e!==null&&(e=function(f,h){b=parseInt(h.join(""))}(u,e)),e===null&&(s=u),e}function ao(){var e,l;return l=s,e=Ei(),e!==null&&(e=function(u){b=o.substring(s,u)}(l)),e===null&&(s=l),e}function Ei(){var e,l,u,f,h,m,T,y;if(T=s,e=yi(),e!==null)if(l=B(),l!==null)if(u=jn(),u!==null){for(f=[],y=s,h=Te(),h!==null?(m=Vn(),m!==null?h=[h,m]:(h=null,s=y)):(h=null,s=y);h!==null;)f.push(h),y=s,h=Te(),h!==null?(m=Vn(),m!==null?h=[h,m]:(h=null,s=y)):(h=null,s=y);f!==null?e=[e,l,u,f]:(e=null,s=T)}else e=null,s=T;else e=null,s=T;else e=null,s=T;return e}function yi(){var e;return e=Si(),e===null&&(e=ln()),e}function Si(){var e;return o.substr(s,4).toLowerCase()==="text"?(e=o.substr(s,4),s+=4):(e=null,d('"text"')),e===null&&(o.substr(s,5).toLowerCase()==="image"?(e=o.substr(s,5),s+=5):(e=null,d('"image"')),e===null&&(o.substr(s,5).toLowerCase()==="audio"?(e=o.substr(s,5),s+=5):(e=null,d('"audio"')),e===null&&(o.substr(s,5).toLowerCase()==="video"?(e=o.substr(s,5),s+=5):(e=null,d('"video"')),e===null&&(o.substr(s,11).toLowerCase()==="application"?(e=o.substr(s,11),s+=11):(e=null,d('"application"')),e===null&&(e=on()))))),e}function ln(){var e;return o.substr(s,7).toLowerCase()==="message"?(e=o.substr(s,7),s+=7):(e=null,d('"message"')),e===null&&(o.substr(s,9).toLowerCase()==="multipart"?(e=o.substr(s,9),s+=9):(e=null,d('"multipart"')),e===null&&(e=on())),e}function on(){var e;return e=P(),e===null&&(e=Ci()),e}function Ci(){var e,l,u;return u=s,o.substr(s,2).toLowerCase()==="x-"?(e=o.substr(s,2),s+=2):(e=null,d('"x-"')),e!==null?(l=P(),l!==null?e=[e,l]:(e=null,s=u)):(e=null,s=u),e}function jn(){var e;return e=on(),e===null&&(e=P()),e}function Vn(){var e,l,u,f;return f=s,e=P(),e!==null?(l=te(),l!==null?(u=uo(),u!==null?e=[e,l,u]:(e=null,s=f)):(e=null,s=f)):(e=null,s=f),e}function uo(){var e;return e=P(),e===null&&(e=be()),e}function co(){var e,l,u,f;return f=s,e=fo(),e!==null?(l=M(),l!==null?(u=rn(),u!==null?e=[e,l,u]:(e=null,s=f)):(e=null,s=f)):(e=null,s=f),e}function fo(){var e,l,u;if(u=s,l=v(),l!==null)for(e=[];l!==null;)e.push(l),l=v();else e=null;return e!==null&&(e=function(f,h){b.value=parseInt(h.join(""))}(u,e)),e===null&&(s=u),e}function iu(){var e,l;return l=s,e=Zt(),e!==null&&(e=function(u,f){b=f}(l,e)),e===null&&(s=l),e}function an(){var e,l,u,f,h,m,T;if(h=s,m=s,e=un(),e!==null){for(l=[],T=s,u=Te(),u!==null?(f=Ke(),f!==null?u=[u,f]:(u=null,s=T)):(u=null,s=T);u!==null;)l.push(u),T=s,u=Te(),u!==null?(f=Ke(),f!==null?u=[u,f]:(u=null,s=T)):(u=null,s=T);l!==null?e=[e,l]:(e=null,s=m)}else e=null,s=m;return e!==null&&(e=function(y,O){b.event=O.join("").toLowerCase()}(h,e[0])),e===null&&(s=h),e}function un(){var e,l,u,f,h,m;if(h=s,e=Z(),e!==null){for(l=[],m=s,o.charCodeAt(s)===46?(u=".",s++):(u=null,d('"."')),u!==null?(f=Z(),f!==null?u=[u,f]:(u=null,s=m)):(u=null,s=m);u!==null;)l.push(u),m=s,o.charCodeAt(s)===46?(u=".",s++):(u=null,d('"."')),u!==null?(f=Z(),f!==null?u=[u,f]:(u=null,s=m)):(u=null,s=m);l!==null?e=[e,l]:(e=null,s=h)}else e=null,s=h;return e}function Ai(){var e,l,u,f,h,m,T;if(h=s,m=s,e=Re(),e===null&&(e=kt()),e!==null){for(l=[],T=s,u=Te(),u!==null?(f=cn(),f!==null?u=[u,f]:(u=null,s=T)):(u=null,s=T);u!==null;)l.push(u),T=s,u=Te(),u!==null?(f=cn(),f!==null?u=[u,f]:(u=null,s=T)):(u=null,s=T);l!==null?e=[e,l]:(e=null,s=m)}else e=null,s=m;return e!==null&&(e=function(y){var O=b.tag;try{b=new R(b.uri,b.display_name,b.params),O&&b.setParam("tag",O)}catch{b=-1}}()),e===null&&(s=h),e}function cn(){var e;return e=Ri(),e===null&&(e=Ke()),e}function Ri(){var e,l,u,f,h;return f=s,h=s,o.substr(s,3).toLowerCase()==="tag"?(e=o.substr(s,3),s+=3):(e=null,d('"tag"')),e!==null?(l=te(),l!==null?(u=P(),u!==null?e=[e,l,u]:(e=null,s=h)):(e=null,s=h)):(e=null,s=h),e!==null&&(e=function(m,T){b.tag=T}(f,e[2])),e===null&&(s=f),e}function lu(){var e,l,u;if(u=s,l=v(),l!==null)for(e=[];l!==null;)e.push(l),l=v();else e=null;return e!==null&&(e=function(f,h){b=parseInt(h.join(""))}(u,e)),e===null&&(s=u),e}function ou(){var e,l;return l=s,e=Zt(),e!==null&&(e=function(u,f){b=f}(l,e)),e===null&&(s=l),e}function au(){var e,l,u,f,h,m,T,y,O,se;for(y=s,O=s,e=[],l=Ps();l!==null;)e.push(l),l=Ps();if(e!==null)if(l=Se(),l!==null)if(u=Oe(),u!==null)if(f=Ue(),f!==null){for(h=[],se=s,m=Te(),m!==null?(T=Ke(),T!==null?m=[m,T]:(m=null,s=se)):(m=null,s=se);m!==null;)h.push(m),se=s,m=Te(),m!==null?(T=Ke(),T!==null?m=[m,T]:(m=null,s=se)):(m=null,s=se);h!==null?e=[e,l,u,f,h]:(e=null,s=O)}else e=null,s=O;else e=null,s=O;else e=null,s=O;else e=null,s=O;return e!==null&&(e=function(De){try{b=new R(b.uri,b.display_name,b.params)}catch{b=-1}}()),e===null&&(s=y),e}function Ii(){var e;return e=Bn(),e}function Bn(){var e,l,u,f,h,m,T,y;if(T=s,o.substr(s,6).toLowerCase()==="digest"?(e=o.substr(s,6),s+=6):(e=null,d('"Digest"')),e!==null)if(l=M(),l!==null)if(u=fn(),u!==null){for(f=[],y=s,h=ne(),h!==null?(m=fn(),m!==null?h=[h,m]:(h=null,s=y)):(h=null,s=y);h!==null;)f.push(h),y=s,h=ne(),h!==null?(m=fn(),m!==null?h=[h,m]:(h=null,s=y)):(h=null,s=y);f!==null?e=[e,l,u,f]:(e=null,s=T)}else e=null,s=T;else e=null,s=T;else e=null,s=T;return e===null&&(e=ks()),e}function ks(){var e,l,u,f,h,m,T,y;if(T=s,e=P(),e!==null)if(l=M(),l!==null)if(u=es(),u!==null){for(f=[],y=s,h=ne(),h!==null?(m=es(),m!==null?h=[h,m]:(h=null,s=y)):(h=null,s=y);h!==null;)f.push(h),y=s,h=ne(),h!==null?(m=es(),m!==null?h=[h,m]:(h=null,s=y)):(h=null,s=y);f!==null?e=[e,l,u,f]:(e=null,s=T)}else e=null,s=T;else e=null,s=T;else e=null,s=T;return e}function es(){var e,l,u,f;return f=s,e=P(),e!==null?(l=te(),l!==null?(u=P(),u===null&&(u=be()),u!==null?e=[e,l,u]:(e=null,s=f)):(e=null,s=f)):(e=null,s=f),e}function fn(){var e;return e=bi(),e===null&&(e=_n(),e===null&&(e=Oi(),e===null&&(e=Ni(),e===null&&(e=Ui(),e===null&&(e=Pi(),e===null&&(e=dn(),e===null&&(e=es()))))))),e}function bi(){var e,l,u,f;return f=s,o.substr(s,5).toLowerCase()==="realm"?(e=o.substr(s,5),s+=5):(e=null,d('"realm"')),e!==null?(l=te(),l!==null?(u=wi(),u!==null?e=[e,l,u]:(e=null,s=f)):(e=null,s=f)):(e=null,s=f),e}function wi(){var e,l;return l=s,e=_e(),e!==null&&(e=function(u,f){b.realm=f}(l,e)),e===null&&(s=l),e}function _n(){var e,l,u,f,h,m,T,y,O;if(y=s,o.substr(s,6).toLowerCase()==="domain"?(e=o.substr(s,6),s+=6):(e=null,d('"domain"')),e!==null)if(l=te(),l!==null)if(u=st(),u!==null)if(f=hn(),f!==null){if(h=[],O=s,T=F(),T!==null)for(m=[];T!==null;)m.push(T),T=F();else m=null;for(m!==null?(T=hn(),T!==null?m=[m,T]:(m=null,s=O)):(m=null,s=O);m!==null;){if(h.push(m),O=s,T=F(),T!==null)for(m=[];T!==null;)m.push(T),T=F();else m=null;m!==null?(T=hn(),T!==null?m=[m,T]:(m=null,s=O)):(m=null,s=O)}h!==null?(m=ge(),m!==null?e=[e,l,u,f,h,m]:(e=null,s=y)):(e=null,s=y)}else e=null,s=y;else e=null,s=y;else e=null,s=y;else e=null,s=y;return e}function hn(){var e;return e=Mn(),e===null&&(e=tn()),e}function Oi(){var e,l,u,f;return f=s,o.substr(s,5).toLowerCase()==="nonce"?(e=o.substr(s,5),s+=5):(e=null,d('"nonce"')),e!==null?(l=te(),l!==null?(u=Di(),u!==null?e=[e,l,u]:(e=null,s=f)):(e=null,s=f)):(e=null,s=f),e}function Di(){var e,l;return l=s,e=_e(),e!==null&&(e=function(u,f){b.nonce=f}(l,e)),e===null&&(s=l),e}function Ni(){var e,l,u,f,h;return f=s,h=s,o.substr(s,6).toLowerCase()==="opaque"?(e=o.substr(s,6),s+=6):(e=null,d('"opaque"')),e!==null?(l=te(),l!==null?(u=_e(),u!==null?e=[e,l,u]:(e=null,s=h)):(e=null,s=h)):(e=null,s=h),e!==null&&(e=function(m,T){b.opaque=T}(f,e[2])),e===null&&(s=f),e}function Ui(){var e,l,u,f,h;return f=s,o.substr(s,5).toLowerCase()==="stale"?(e=o.substr(s,5),s+=5):(e=null,d('"stale"')),e!==null?(l=te(),l!==null?(h=s,o.substr(s,4).toLowerCase()==="true"?(u=o.substr(s,4),s+=4):(u=null,d('"true"')),u!==null&&(u=function(m){b.stale=!0}()),u===null&&(s=h),u===null&&(h=s,o.substr(s,5).toLowerCase()==="false"?(u=o.substr(s,5),s+=5):(u=null,d('"false"')),u!==null&&(u=function(m){b.stale=!1}()),u===null&&(s=h)),u!==null?e=[e,l,u]:(e=null,s=f)):(e=null,s=f)):(e=null,s=f),e}function Pi(){var e,l,u,f,h;return f=s,h=s,o.substr(s,9).toLowerCase()==="algorithm"?(e=o.substr(s,9),s+=9):(e=null,d('"algorithm"')),e!==null?(l=te(),l!==null?(o.substr(s,3).toLowerCase()==="md5"?(u=o.substr(s,3),s+=3):(u=null,d('"MD5"')),u===null&&(o.substr(s,8).toLowerCase()==="md5-sess"?(u=o.substr(s,8),s+=8):(u=null,d('"MD5-sess"')),u===null&&(u=P())),u!==null?e=[e,l,u]:(e=null,s=h)):(e=null,s=h)):(e=null,s=h),e!==null&&(e=function(m,T){b.algorithm=T.toUpperCase()}(f,e[2])),e===null&&(s=f),e}function dn(){var e,l,u,f,h,m,T,y,O,se;if(y=s,o.substr(s,3).toLowerCase()==="qop"?(e=o.substr(s,3),s+=3):(e=null,d('"qop"')),e!==null)if(l=te(),l!==null)if(u=st(),u!==null){if(O=s,f=Gn(),f!==null){for(h=[],se=s,o.charCodeAt(s)===44?(m=",",s++):(m=null,d('","')),m!==null?(T=Gn(),T!==null?m=[m,T]:(m=null,s=se)):(m=null,s=se);m!==null;)h.push(m),se=s,o.charCodeAt(s)===44?(m=",",s++):(m=null,d('","')),m!==null?(T=Gn(),T!==null?m=[m,T]:(m=null,s=se)):(m=null,s=se);h!==null?f=[f,h]:(f=null,s=O)}else f=null,s=O;f!==null?(h=ge(),h!==null?e=[e,l,u,f,h]:(e=null,s=y)):(e=null,s=y)}else e=null,s=y;else e=null,s=y;else e=null,s=y;return e}function Gn(){var e,l;return l=s,o.substr(s,8).toLowerCase()==="auth-int"?(e=o.substr(s,8),s+=8):(e=null,d('"auth-int"')),e===null&&(o.substr(s,4).toLowerCase()==="auth"?(e=o.substr(s,4),s+=4):(e=null,d('"auth"')),e===null&&(e=P())),e!==null&&(e=function(u,f){b.qop||(b.qop=[]),b.qop.push(f.toLowerCase())}(l,e)),e===null&&(s=l),e}function uu(){var e,l,u,f,h,m;if(h=s,e=P(),e!==null){for(l=[],m=s,u=ne(),u!==null?(f=P(),f!==null?u=[u,f]:(u=null,s=m)):(u=null,s=m);u!==null;)l.push(u),m=s,u=ne(),u!==null?(f=P(),f!==null?u=[u,f]:(u=null,s=m)):(u=null,s=m);l!==null?e=[e,l]:(e=null,s=h)}else e=null,s=h;return e}function Kn(){var e,l,u,f,h,m,T;if(h=s,m=s,e=Wn(),e!==null){for(l=[],T=s,u=ne(),u!==null?(f=Wn(),f!==null?u=[u,f]:(u=null,s=T)):(u=null,s=T);u!==null;)l.push(u),T=s,u=ne(),u!==null?(f=Wn(),f!==null?u=[u,f]:(u=null,s=T)):(u=null,s=T);l!==null?e=[e,l]:(e=null,s=m)}else e=null,s=m;return e!==null&&(e=function(y){var O,se;for(se=b.multi_header.length,O=0;O<se;O++)if(b.multi_header[O].parsed===null){b=null;break}b!==null?b=b.multi_header:b=-1}()),e===null&&(s=h),e}function Wn(){var e,l,u,f,h,m,T;if(h=s,m=s,e=kt(),e!==null){for(l=[],T=s,u=Te(),u!==null?(f=Ke(),f!==null?u=[u,f]:(u=null,s=T)):(u=null,s=T);u!==null;)l.push(u),T=s,u=Te(),u!==null?(f=Ke(),f!==null?u=[u,f]:(u=null,s=T)):(u=null,s=T);l!==null?e=[e,l]:(e=null,s=m)}else e=null,s=m;return e!==null&&(e=function(y){var O;b.multi_header||(b.multi_header=[]);try{O=new R(b.uri,b.display_name,b.params),delete b.uri,delete b.display_name,delete b.params}catch{O=null}b.multi_header.push({possition:s,offset:y,parsed:O})}(h)),e===null&&(s=h),e}function ki(){var e,l,u,f,h,m,T;if(h=s,m=s,o.substr(s,3).toLowerCase()==="sip"?(e=o.substr(s,3),s+=3):(e=null,d('"SIP"')),e===null&&(e=P()),e!==null){for(l=[],T=s,u=Te(),u!==null?(f=Yn(),f!==null?u=[u,f]:(u=null,s=T)):(u=null,s=T);u!==null;)l.push(u),T=s,u=Te(),u!==null?(f=Yn(),f!==null?u=[u,f]:(u=null,s=T)):(u=null,s=T);l!==null?e=[e,l]:(e=null,s=m)}else e=null,s=m;return e!==null&&(e=function(y,O){if(b.protocol=O.toLowerCase(),b.params||(b.params={}),b.params.text&&b.params.text[0]==='"'){var se=b.params.text;b.text=se.substring(1,se.length-1),delete b.params.text}}(h,e[0])),e===null&&(s=h),e}function Yn(){var e;return e=_o(),e===null&&(e=Ke()),e}function _o(){var e,l,u,f,h,m;if(h=s,m=s,o.substr(s,5).toLowerCase()==="cause"?(e=o.substr(s,5),s+=5):(e=null,d('"cause"')),e!==null)if(l=te(),l!==null){if(f=v(),f!==null)for(u=[];f!==null;)u.push(f),f=v();else u=null;u!==null?e=[e,l,u]:(e=null,s=m)}else e=null,s=m;else e=null,s=m;return e!==null&&(e=function(T,y){b.cause=parseInt(y.join(""))}(h,e[2])),e===null&&(s=h),e}function cu(){var e,l,u,f,h,m;if(h=s,e=P(),e!==null){for(l=[],m=s,u=ne(),u!==null?(f=P(),f!==null?u=[u,f]:(u=null,s=m)):(u=null,s=m);u!==null;)l.push(u),m=s,u=ne(),u!==null?(f=P(),f!==null?u=[u,f]:(u=null,s=m)):(u=null,s=m);l!==null?e=[e,l]:(e=null,s=h)}else e=null,s=h;return e}function zn(){var e,l,u,f,h,m;if(h=s,e=Jn(),e!==null){for(l=[],m=s,u=ne(),u!==null?(f=Jn(),f!==null?u=[u,f]:(u=null,s=m)):(u=null,s=m);u!==null;)l.push(u),m=s,u=ne(),u!==null?(f=Jn(),f!==null?u=[u,f]:(u=null,s=m)):(u=null,s=m);l!==null?e=[e,l]:(e=null,s=h)}else e=null,s=h;return e}function Jn(){var e,l,u,f,h,m;if(h=s,e=kt(),e!==null){for(l=[],m=s,u=Te(),u!==null?(f=Ke(),f!==null?u=[u,f]:(u=null,s=m)):(u=null,s=m);u!==null;)l.push(u),m=s,u=Te(),u!==null?(f=Ke(),f!==null?u=[u,f]:(u=null,s=m)):(u=null,s=m);l!==null?e=[e,l]:(e=null,s=h)}else e=null,s=h;return e}function ho(){var e,l,u,f,h,m;if(h=s,e=Xn(),e!==null){for(l=[],m=s,u=Te(),u!==null?(f=Qn(),f!==null?u=[u,f]:(u=null,s=m)):(u=null,s=m);u!==null;)l.push(u),m=s,u=Te(),u!==null?(f=Qn(),f!==null?u=[u,f]:(u=null,s=m)):(u=null,s=m);l!==null?e=[e,l]:(e=null,s=h)}else e=null,s=h;return e}function Xn(){var e,l;return l=s,o.substr(s,6).toLowerCase()==="active"?(e=o.substr(s,6),s+=6):(e=null,d('"active"')),e===null&&(o.substr(s,7).toLowerCase()==="pending"?(e=o.substr(s,7),s+=7):(e=null,d('"pending"')),e===null&&(o.substr(s,10).toLowerCase()==="terminated"?(e=o.substr(s,10),s+=10):(e=null,d('"terminated"')),e===null&&(e=P()))),e!==null&&(e=function(u){b.state=o.substring(s,u)}(l)),e===null&&(s=l),e}function Qn(){var e,l,u,f,h;return f=s,h=s,o.substr(s,6).toLowerCase()==="reason"?(e=o.substr(s,6),s+=6):(e=null,d('"reason"')),e!==null?(l=te(),l!==null?(u=po(),u!==null?e=[e,l,u]:(e=null,s=h)):(e=null,s=h)):(e=null,s=h),e!==null&&(e=function(m,T){typeof T<"u"&&(b.reason=T)}(f,e[2])),e===null&&(s=f),e===null&&(f=s,h=s,o.substr(s,7).toLowerCase()==="expires"?(e=o.substr(s,7),s+=7):(e=null,d('"expires"')),e!==null?(l=te(),l!==null?(u=Zt(),u!==null?e=[e,l,u]:(e=null,s=h)):(e=null,s=h)):(e=null,s=h),e!==null&&(e=function(m,T){typeof T<"u"&&(b.expires=T)}(f,e[2])),e===null&&(s=f),e===null&&(f=s,h=s,o.substr(s,11).toLowerCase()==="retry_after"?(e=o.substr(s,11),s+=11):(e=null,d('"retry_after"')),e!==null?(l=te(),l!==null?(u=Zt(),u!==null?e=[e,l,u]:(e=null,s=h)):(e=null,s=h)):(e=null,s=h),e!==null&&(e=function(m,T){typeof T<"u"&&(b.retry_after=T)}(f,e[2])),e===null&&(s=f),e===null&&(e=Ke()))),e}function po(){var e;return o.substr(s,11).toLowerCase()==="deactivated"?(e=o.substr(s,11),s+=11):(e=null,d('"deactivated"')),e===null&&(o.substr(s,9).toLowerCase()==="probation"?(e=o.substr(s,9),s+=9):(e=null,d('"probation"')),e===null&&(o.substr(s,8).toLowerCase()==="rejected"?(e=o.substr(s,8),s+=8):(e=null,d('"rejected"')),e===null&&(o.substr(s,7).toLowerCase()==="timeout"?(e=o.substr(s,7),s+=7):(e=null,d('"timeout"')),e===null&&(o.substr(s,6).toLowerCase()==="giveup"?(e=o.substr(s,6),s+=6):(e=null,d('"giveup"')),e===null&&(o.substr(s,10).toLowerCase()==="noresource"?(e=o.substr(s,10),s+=10):(e=null,d('"noresource"')),e===null&&(o.substr(s,9).toLowerCase()==="invariant"?(e=o.substr(s,9),s+=9):(e=null,d('"invariant"')),e===null&&(e=P()))))))),e}function fu(){var e;return e=j(),e=e!==null?e:"",e}function _u(){var e,l,u,f,h,m;if(h=s,e=P(),e!==null){for(l=[],m=s,u=ne(),u!==null?(f=P(),f!==null?u=[u,f]:(u=null,s=m)):(u=null,s=m);u!==null;)l.push(u),m=s,u=ne(),u!==null?(f=P(),f!==null?u=[u,f]:(u=null,s=m)):(u=null,s=m);l!==null?e=[e,l]:(e=null,s=h)}else e=null,s=h;return e=e!==null?e:"",e}function Mi(){var e,l,u,f,h,m,T;if(h=s,m=s,e=Re(),e===null&&(e=kt()),e!==null){for(l=[],T=s,u=Te(),u!==null?(f=xi(),f!==null?u=[u,f]:(u=null,s=T)):(u=null,s=T);u!==null;)l.push(u),T=s,u=Te(),u!==null?(f=xi(),f!==null?u=[u,f]:(u=null,s=T)):(u=null,s=T);l!==null?e=[e,l]:(e=null,s=m)}else e=null,s=m;return e!==null&&(e=function(y){var O=b.tag;try{b=new R(b.uri,b.display_name,b.params),O&&b.setParam("tag",O)}catch{b=-1}}()),e===null&&(s=h),e}function xi(){var e;return e=Ri(),e===null&&(e=Ke()),e}function Zn(){var e,l,u,f,h,m;if(h=s,e=Ms(),e!==null){for(l=[],m=s,u=ne(),u!==null?(f=Ms(),f!==null?u=[u,f]:(u=null,s=m)):(u=null,s=m);u!==null;)l.push(u),m=s,u=ne(),u!==null?(f=Ms(),f!==null?u=[u,f]:(u=null,s=m)):(u=null,s=m);l!==null?e=[e,l]:(e=null,s=h)}else e=null,s=h;return e}function Ms(){var e,l,u,f,h,m,T,y;if(T=s,e=Vi(),e!==null)if(l=M(),l!==null)if(u=Ki(),u!==null){for(f=[],y=s,h=Te(),h!==null?(m=er(),m!==null?h=[h,m]:(h=null,s=y)):(h=null,s=y);h!==null;)f.push(h),y=s,h=Te(),h!==null?(m=er(),m!==null?h=[h,m]:(h=null,s=y)):(h=null,s=y);f!==null?e=[e,l,u,f]:(e=null,s=T)}else e=null,s=T;else e=null,s=T;else e=null,s=T;return e}function er(){var e;return e=Li(),e===null&&(e=$i(),e===null&&(e=Hi(),e===null&&(e=Fi(),e===null&&(e=qi(),e===null&&(e=Ke()))))),e}function Li(){var e,l,u,f,h;return f=s,h=s,o.substr(s,3).toLowerCase()==="ttl"?(e=o.substr(s,3),s+=3):(e=null,d('"ttl"')),e!==null?(l=te(),l!==null?(u=Yi(),u!==null?e=[e,l,u]:(e=null,s=h)):(e=null,s=h)):(e=null,s=h),e!==null&&(e=function(m,T){b.ttl=T}(f,e[2])),e===null&&(s=f),e}function $i(){var e,l,u,f,h;return f=s,h=s,o.substr(s,5).toLowerCase()==="maddr"?(e=o.substr(s,5),s+=5):(e=null,d('"maddr"')),e!==null?(l=te(),l!==null?(u=_s(),u!==null?e=[e,l,u]:(e=null,s=h)):(e=null,s=h)):(e=null,s=h),e!==null&&(e=function(m,T){b.maddr=T}(f,e[2])),e===null&&(s=f),e}function Hi(){var e,l,u,f,h;return f=s,h=s,o.substr(s,8).toLowerCase()==="received"?(e=o.substr(s,8),s+=8):(e=null,d('"received"')),e!==null?(l=te(),l!==null?(u=Ft(),u===null&&(u=he()),u!==null?e=[e,l,u]:(e=null,s=h)):(e=null,s=h)):(e=null,s=h),e!==null&&(e=function(m,T){b.received=T}(f,e[2])),e===null&&(s=f),e}function Fi(){var e,l,u,f,h;return f=s,h=s,o.substr(s,6).toLowerCase()==="branch"?(e=o.substr(s,6),s+=6):(e=null,d('"branch"')),e!==null?(l=te(),l!==null?(u=P(),u!==null?e=[e,l,u]:(e=null,s=h)):(e=null,s=h)):(e=null,s=h),e!==null&&(e=function(m,T){b.branch=T}(f,e[2])),e===null&&(s=f),e}function qi(){var e,l,u,f,h;return f=s,o.substr(s,5).toLowerCase()==="rport"?(e=o.substr(s,5),s+=5):(e=null,d('"rport"')),e!==null?(h=s,l=te(),l!==null?(u=ji(),u!==null?l=[l,u]:(l=null,s=h)):(l=null,s=h),l=l!==null?l:"",l!==null?e=[e,l]:(e=null,s=f)):(e=null,s=f),e}function ji(){var e,l,u,f,h,m,T;return m=s,T=s,e=v(),e=e!==null?e:"",e!==null?(l=v(),l=l!==null?l:"",l!==null?(u=v(),u=u!==null?u:"",u!==null?(f=v(),f=f!==null?f:"",f!==null?(h=v(),h=h!==null?h:"",h!==null?e=[e,l,u,f,h]:(e=null,s=T)):(e=null,s=T)):(e=null,s=T)):(e=null,s=T)):(e=null,s=T),e!==null&&(e=function(y,O){b.rport=parseInt(O.join(""))}(m,e)),e===null&&(s=m),e}function Vi(){var e,l,u,f,h,m;return m=s,e=Bi(),e!==null?(l=B(),l!==null?(u=P(),u!==null?(f=B(),f!==null?(h=Gi(),h!==null?e=[e,l,u,f,h]:(e=null,s=m)):(e=null,s=m)):(e=null,s=m)):(e=null,s=m)):(e=null,s=m),e}function Bi(){var e,l;return l=s,o.substr(s,3).toLowerCase()==="sip"?(e=o.substr(s,3),s+=3):(e=null,d('"SIP"')),e===null&&(e=P()),e!==null&&(e=function(u,f){b.protocol=f}(l,e)),e===null&&(s=l),e}function Gi(){var e,l;return l=s,o.substr(s,3).toLowerCase()==="udp"?(e=o.substr(s,3),s+=3):(e=null,d('"UDP"')),e===null&&(o.substr(s,3).toLowerCase()==="tcp"?(e=o.substr(s,3),s+=3):(e=null,d('"TCP"')),e===null&&(o.substr(s,3).toLowerCase()==="tls"?(e=o.substr(s,3),s+=3):(e=null,d('"TLS"')),e===null&&(o.substr(s,4).toLowerCase()==="sctp"?(e=o.substr(s,4),s+=4):(e=null,d('"SCTP"')),e===null&&(e=P())))),e!==null&&(e=function(u,f){b.transport=f}(l,e)),e===null&&(s=l),e}function Ki(){var e,l,u,f,h;return f=s,e=Wi(),e!==null?(h=s,l=tt(),l!==null?(u=tr(),u!==null?l=[l,u]:(l=null,s=h)):(l=null,s=h),l=l!==null?l:"",l!==null?e=[e,l]:(e=null,s=f)):(e=null,s=f),e}function Wi(){var e,l;return l=s,e=Ft(),e===null&&(e=Js(),e===null&&(e=zs())),e!==null&&(e=function(u){b.host=o.substring(s,u)}(l)),e===null&&(s=l),e}function tr(){var e,l,u,f,h,m,T;return m=s,T=s,e=v(),e=e!==null?e:"",e!==null?(l=v(),l=l!==null?l:"",l!==null?(u=v(),u=u!==null?u:"",u!==null?(f=v(),f=f!==null?f:"",f!==null?(h=v(),h=h!==null?h:"",h!==null?e=[e,l,u,f,h]:(e=null,s=T)):(e=null,s=T)):(e=null,s=T)):(e=null,s=T)):(e=null,s=T),e!==null&&(e=function(y,O){b.port=parseInt(O.join(""))}(m,e)),e===null&&(s=m),e}function Yi(){var e,l,u,f,h;return f=s,h=s,e=v(),e!==null?(l=v(),l=l!==null?l:"",l!==null?(u=v(),u=u!==null?u:"",u!==null?e=[e,l,u]:(e=null,s=h)):(e=null,s=h)):(e=null,s=h),e!==null&&(e=function(m,T){return parseInt(T.join(""))}(f,e)),e===null&&(s=f),e}function hu(){var e;return e=Bn(),e}function mo(){var e,l,u,f,h,m;if(h=s,e=sr(),e!==null){for(l=[],m=s,u=Te(),u!==null?(f=nr(),f!==null?u=[u,f]:(u=null,s=m)):(u=null,s=m);u!==null;)l.push(u),m=s,u=Te(),u!==null?(f=nr(),f!==null?u=[u,f]:(u=null,s=m)):(u=null,s=m);l!==null?e=[e,l]:(e=null,s=h)}else e=null,s=h;return e}function sr(){var e,l;return l=s,e=Zt(),e!==null&&(e=function(u,f){b.expires=f}(l,e)),e===null&&(s=l),e}function nr(){var e;return e=go(),e===null&&(e=Ke()),e}function go(){var e,l,u,f,h;return f=s,h=s,o.substr(s,9).toLowerCase()==="refresher"?(e=o.substr(s,9),s+=9):(e=null,d('"refresher"')),e!==null?(l=te(),l!==null?(o.substr(s,3).toLowerCase()==="uac"?(u=o.substr(s,3),s+=3):(u=null,d('"uac"')),u===null&&(o.substr(s,3).toLowerCase()==="uas"?(u=o.substr(s,3),s+=3):(u=null,d('"uas"'))),u!==null?e=[e,l,u]:(e=null,s=h)):(e=null,s=h)):(e=null,s=h),e!==null&&(e=function(m,T){b.refresher=T.toLowerCase()}(f,e[2])),e===null&&(s=f),e}function vo(){var e,l,u,f;return f=s,e=P(),e!==null?(l=V(),l!==null?(u=To(),u!==null?e=[e,l,u]:(e=null,s=f)):(e=null,s=f)):(e=null,s=f),e}function To(){var e,l;for(e=[],l=Y(),l===null&&(l=X(),l===null&&(l=M()));l!==null;)e.push(l),l=Y(),l===null&&(l=X(),l===null&&(l=M()));return e}function du(){var e,l;for(e=[],l=I();l!==null;)e.push(l),l=I();return e}function Eo(){var e,l,u;return u=s,o.substr(s,5)==="uuid:"?(e="uuid:",s+=5):(e=null,d('"uuid:"')),e!==null?(l=Mt(),l!==null?e=[e,l]:(e=null,s=u)):(e=null,s=u),e}function Mt(){var e,l,u,f,h,m,T,y,O,se,De;return se=s,De=s,e=zi(),e!==null?(o.charCodeAt(s)===45?(l="-",s++):(l=null,d('"-"')),l!==null?(u=xt(),u!==null?(o.charCodeAt(s)===45?(f="-",s++):(f=null,d('"-"')),f!==null?(h=xt(),h!==null?(o.charCodeAt(s)===45?(m="-",s++):(m=null,d('"-"')),m!==null?(T=xt(),T!==null?(o.charCodeAt(s)===45?(y="-",s++):(y=null,d('"-"')),y!==null?(O=yo(),O!==null?e=[e,l,u,f,h,m,T,y,O]:(e=null,s=De)):(e=null,s=De)):(e=null,s=De)):(e=null,s=De)):(e=null,s=De)):(e=null,s=De)):(e=null,s=De)):(e=null,s=De)):(e=null,s=De),e!==null&&(e=function(Ct,xs){b=o.substring(s+5,Ct)}(se,e[0])),e===null&&(s=se),e}function xt(){var e,l,u,f,h;return h=s,e=S(),e!==null?(l=S(),l!==null?(u=S(),u!==null?(f=S(),f!==null?e=[e,l,u,f]:(e=null,s=h)):(e=null,s=h)):(e=null,s=h)):(e=null,s=h),e}function zi(){var e,l,u;return u=s,e=xt(),e!==null?(l=xt(),l!==null?e=[e,l]:(e=null,s=u)):(e=null,s=u),e}function yo(){var e,l,u,f;return f=s,e=xt(),e!==null?(l=xt(),l!==null?(u=xt(),u!==null?e=[e,l,u]:(e=null,s=f)):(e=null,s=f)):(e=null,s=f),e}function pu(){var e,l,u,f,h,m,T;if(h=s,m=s,e=Re(),e===null&&(e=kt()),e!==null){for(l=[],T=s,u=Te(),u!==null?(f=Ke(),f!==null?u=[u,f]:(u=null,s=T)):(u=null,s=T);u!==null;)l.push(u),T=s,u=Te(),u!==null?(f=Ke(),f!==null?u=[u,f]:(u=null,s=T)):(u=null,s=T);l!==null?e=[e,l]:(e=null,s=m)}else e=null,s=m;return e!==null&&(e=function(y){try{b=new R(b.uri,b.display_name,b.params)}catch{b=-1}}()),e===null&&(s=h),e}function So(){var e,l,u,f,h,m;if(h=s,e=rr(),e!==null){for(l=[],m=s,u=Te(),u!==null?(f=ir(),f!==null?u=[u,f]:(u=null,s=m)):(u=null,s=m);u!==null;)l.push(u),m=s,u=Te(),u!==null?(f=ir(),f!==null?u=[u,f]:(u=null,s=m)):(u=null,s=m);l!==null?e=[e,l]:(e=null,s=h)}else e=null,s=h;return e}function rr(){var e,l,u,f,h,m;return f=s,h=s,e=Q(),e!==null?(m=s,o.charCodeAt(s)===64?(l="@",s++):(l=null,d('"@"')),l!==null?(u=Q(),u!==null?l=[l,u]:(l=null,s=m)):(l=null,s=m),l=l!==null?l:"",l!==null?e=[e,l]:(e=null,s=h)):(e=null,s=h),e!==null&&(e=function(T){b.call_id=o.substring(s,T)}(f)),e===null&&(s=f),e}function ir(){var e;return e=Ji(),e===null&&(e=Xi(),e===null&&(e=Co(),e===null&&(e=Ke()))),e}function Ji(){var e,l,u,f,h;return f=s,h=s,o.substr(s,6)==="to-tag"?(e="to-tag",s+=6):(e=null,d('"to-tag"')),e!==null?(l=te(),l!==null?(u=P(),u!==null?e=[e,l,u]:(e=null,s=h)):(e=null,s=h)):(e=null,s=h),e!==null&&(e=function(m,T){b.to_tag=T}(f,e[2])),e===null&&(s=f),e}function Xi(){var e,l,u,f,h;return f=s,h=s,o.substr(s,8)==="from-tag"?(e="from-tag",s+=8):(e=null,d('"from-tag"')),e!==null?(l=te(),l!==null?(u=P(),u!==null?e=[e,l,u]:(e=null,s=h)):(e=null,s=h)):(e=null,s=h),e!==null&&(e=function(m,T){b.from_tag=T}(f,e[2])),e===null&&(s=f),e}function Co(){var e,l;return l=s,o.substr(s,10)==="early-only"?(e="early-only",s+=10):(e=null,d('"early-only"')),e!==null&&(e=function(u){b.early_only=!0}()),e===null&&(s=l),e}function mu(e){e.sort();for(var l=null,u=[],f=0;f<e.length;f++)e[f]!==l&&(u.push(e[f]),l=e[f]);return u}function Ao(){for(var e=1,l=1,u=!1,f=0;f<Math.max(s,p);f++){var h=o.charAt(f);h===`
4
+ `?(u||e++,l=1,u=!1):h==="\r"||h==="\u2028"||h==="\u2029"?(e++,l=1,u=!0):(l++,u=!1)}return{line:e,column:l}}var ds=ms(),R=bo(),b={},Qi=t[a]();if(Qi===null||s!==o.length){var Zi=Math.max(s,p),Ro=Zi<o.length?o.charAt(Zi):null,i=Ao();return new this.SyntaxError(mu(_),Ro,Zi,i.line,i.column),-1}return b},toSource:function(){return this._source}};return r.SyntaxError=function(n,o,a,t,s){function p(_,d){var g,v;switch(_.length){case 0:g="end of input";break;case 1:g=_[0];break;default:g=_.slice(0,_.length-1).join(", ")+" or "+_[_.length-1]}return v=d?c(d):"end of input","Expected "+g+" but "+v+" found."}this.name="SyntaxError",this.expected=n,this.found=o,this.message=p(n,o),this.offset=a,this.line=t,this.column=s},r.SyntaxError.prototype=Error.prototype,r}()),wo}var Oo,Su;function ms(){if(Su)return Oo;Su=1;function c(d,g){var v;if(typeof Symbol>"u"||d[Symbol.iterator]==null){if(Array.isArray(d)||(v=r(d))||g&&d&&typeof d.length=="number"){v&&(d=v);var E=0,S=function(){};return{s:S,n:function(){return E>=d.length?{done:!0}:{done:!1,value:d[E++]}},e:function(L){throw L},f:S}}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 C=!0,I=!1,w;return{s:function(){v=d[Symbol.iterator]()},n:function(){var L=v.next();return C=L.done,L},e:function(L){I=!0,w=L},f:function(){try{!C&&v.return!=null&&v.return()}finally{if(I)throw w}}}}function r(d,g){if(d){if(typeof d=="string")return n(d,g);var v=Object.prototype.toString.call(d).slice(8,-1);if(v==="Object"&&d.constructor&&(v=d.constructor.name),v==="Map"||v==="Set")return Array.from(d);if(v==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(v))return n(d,g)}}function n(d,g){(g==null||g>d.length)&&(g=d.length);for(var v=0,E=new Array(g);v<g;v++)E[v]=d[v];return E}function o(d,g){if(!(d instanceof g))throw new TypeError("Cannot call a class as a function")}function a(d,g){for(var v=0;v<g.length;v++){var E=g[v];E.enumerable=E.enumerable||!1,E.configurable=!0,"value"in E&&(E.writable=!0),Object.defineProperty(d,E.key,E)}}function t(d,g,v){return g&&a(d.prototype,g),v&&a(d,v),d}var s=Xe,p=vt(),_=jt();return Oo=function(){t(d,null,[{key:"parse",value:function(v){if(v=_.parse(v,"SIP_URI"),v!==-1)return v}}]);function d(g,v,E,S){var C=arguments.length>4&&arguments[4]!==void 0?arguments[4]:{},I=arguments.length>5&&arguments[5]!==void 0?arguments[5]:{};if(o(this,d),!E)throw new TypeError('missing or invalid "host" parameter');this._parameters={},this._headers={},this._scheme=g||s.SIP,this._user=v,this._host=E,this._port=S;for(var w in C)Object.prototype.hasOwnProperty.call(C,w)&&this.setParam(w,C[w]);for(var F in I)Object.prototype.hasOwnProperty.call(I,F)&&this.setHeader(F,I[F])}return t(d,[{key:"setParam",value:function(v,E){v&&(this._parameters[v.toLowerCase()]=typeof E>"u"||E===null?null:E.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 E=this._parameters[v];return delete this._parameters[v],E}}},{key:"clearParams",value:function(){this._parameters={}}},{key:"setHeader",value:function(v,E){this._headers[p.headerize(v)]=Array.isArray(E)?E:[E]}},{key:"getHeader",value:function(v){if(v)return this._headers[p.headerize(v)]}},{key:"hasHeader",value:function(v){if(v)return this._headers.hasOwnProperty(p.headerize(v))&&!0||!1}},{key:"deleteHeader",value:function(v){if(v=p.headerize(v),this._headers.hasOwnProperty(v)){var E=this._headers[v];return delete this._headers[v],E}}},{key:"clearHeaders",value:function(){this._headers={}}},{key:"clone",value:function(){return new d(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 v=[],E="".concat(this._scheme,":");this._user&&(E+="".concat(p.escapeUser(this._user),"@")),E+=this._host,(this._port||this._port===0)&&(E+=":".concat(this._port));for(var S in this._parameters)Object.prototype.hasOwnProperty.call(this._parameters,S)&&(E+=";".concat(S),this._parameters[S]!==null&&(E+="=".concat(this._parameters[S])));for(var C in this._headers)if(Object.prototype.hasOwnProperty.call(this._headers,C)){var I=c(this._headers[C]),w;try{for(I.s();!(w=I.n()).done;){var F=w.value;v.push("".concat(C,"=").concat(F))}}catch(L){I.e(L)}finally{I.f()}}return v.length>0&&(E+="?".concat(v.join("&"))),E}},{key:"toAor",value:function(v){var E="".concat(this._scheme,":");return this._user&&(E+="".concat(p.escapeUser(this._user),"@")),E+=this._host,v&&(this._port||this._port===0)&&(E+=":".concat(this._port)),E}},{key:"scheme",get:function(){return this._scheme},set:function(v){this._scheme=v.toLowerCase()}},{key:"user",get:function(){return this._user},set:function(v){this._user=v}},{key:"host",get:function(){return this._host},set:function(v){this._host=v.toLowerCase()}},{key:"port",get:function(){return this._port},set:function(v){this._port=v===0?v:parseInt(v,10)||null}}]),d}(),Oo}var Cu;function vt(){if(Cu)return Ye;Cu=1;function c(g){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?c=function(E){return typeof E}:c=function(E){return E&&typeof Symbol=="function"&&E.constructor===Symbol&&E!==Symbol.prototype?"symbol":typeof E},c(g)}function r(g,v){var E;if(typeof Symbol>"u"||g[Symbol.iterator]==null){if(Array.isArray(g)||(E=n(g))||v&&g&&typeof g.length=="number"){E&&(g=E);var S=0,C=function(){};return{s:C,n:function(){return S>=g.length?{done:!0}:{done:!1,value:g[S++]}},e:function(ie){throw ie},f:C}}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 I=!0,w=!1,F;return{s:function(){E=g[Symbol.iterator]()},n:function(){var ie=E.next();return I=ie.done,ie},e:function(ie){w=!0,F=ie},f:function(){try{!I&&E.return!=null&&E.return()}finally{if(w)throw F}}}}function n(g,v){if(g){if(typeof g=="string")return o(g,v);var E=Object.prototype.toString.call(g).slice(8,-1);if(E==="Object"&&g.constructor&&(E=g.constructor.name),E==="Map"||E==="Set")return Array.from(g);if(E==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(E))return o(g,v)}}function o(g,v){(v==null||v>g.length)&&(v=g.length);for(var E=0,S=new Array(v);E<v;E++)S[E]=g[E];return S}var a=Xe,t=ms(),s=jt();Ye.str_utf8_length=function(g){return unescape(encodeURIComponent(g)).length};var p=Ye.isFunction=function(g){return g!==void 0?Object.prototype.toString.call(g)==="[object Function]":!1};Ye.isString=function(g){return g!==void 0?Object.prototype.toString.call(g)==="[object String]":!1},Ye.isDecimal=function(g){return!isNaN(g)&&parseFloat(g)===parseInt(g,10)},Ye.isEmpty=function(g){return g===null||g===""||g===void 0||Array.isArray(g)&&g.length===0||typeof g=="number"&&isNaN(g)},Ye.hasMethods=function(g){for(var v=arguments.length,E=new Array(v>1?v-1:0),S=1;S<v;S++)E[S-1]=arguments[S];for(var C=0,I=E;C<I.length;C++){var w=I[C];if(p(g[w]))return!1}return!0};var _=Ye.createRandomToken=function(g){var v=arguments.length>1&&arguments[1]!==void 0?arguments[1]:32,E,S,C="";for(E=0;E<g;E++)S=Math.random()*v|0,C+=S.toString(v);return C};Ye.newTag=function(){return _(10)},Ye.newUUID=function(){var g="xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(v){var E=Math.random()*16|0,S=v==="x"?E:E&3|8;return S.toString(16)});return g},Ye.hostType=function(g){if(g){if(g=s.parse(g,"host"),g!==-1)return g.host_type}else return};var d=Ye.escapeUser=function(g){return encodeURIComponent(decodeURIComponent(g)).replace(/%3A/ig,":").replace(/%2B/ig,"+").replace(/%3F/ig,"?").replace(/%2F/ig,"/")};return Ye.normalizeTarget=function(g,v){if(g){if(g instanceof t)return g;if(typeof g=="string"){var E=g.split("@"),S,C;switch(E.length){case 1:if(!v)return;S=g,C=v;break;case 2:S=E[0],C=E[1];break;default:S=E.slice(0,E.length-1).join("@"),C=E[E.length-1]}S=S.replace(/^(sips?|tel):/i,""),/^[-.()]*\+?[0-9\-.()]+$/.test(S)&&(S=S.replace(/[-.()]/g,"")),g="".concat(a.SIP,":").concat(d(S),"@").concat(C);var I;return(I=t.parse(g))?I:void 0}else return}else return},Ye.headerize=function(g){var v={"Call-Id":"Call-ID",Cseq:"CSeq","Www-Authenticate":"WWW-Authenticate"},E=g.toLowerCase().replace(/_/g,"-").split("-"),S="",C=E.length,I;for(I=0;I<C;I++)I!==0&&(S+="-"),S+=E[I].charAt(0).toUpperCase()+E[I].substring(1);return v[S]&&(S=v[S]),S},Ye.sipErrorCause=function(g){for(var v in a.SIP_ERROR_CAUSES)if(a.SIP_ERROR_CAUSES[v].indexOf(g)!==-1)return a.causes[v];return a.causes.SIP_FAILURE_CODE},Ye.getRandomTestNetIP=function(){function g(v,E){return Math.floor(Math.random()*(E-v+1)+v)}return"192.0.2.".concat(g(1,254))},Ye.calculateMD5=function(g){function v(_e,ce){return _e<<ce|_e>>>32-ce}function E(_e,ce){var fe=_e&2147483648,Re=ce&2147483648,Oe=_e&1073741824,Je=ce&1073741824,Me=(_e&1073741823)+(ce&1073741823);return Oe&Je?Me^2147483648^fe^Re:Oe|Je?Me&1073741824?Me^3221225472^fe^Re:Me^1073741824^fe^Re:Me^fe^Re}function S(_e,ce,fe){return _e&ce|~_e&fe}function C(_e,ce,fe){return _e&fe|ce&~fe}function I(_e,ce,fe){return _e^ce^fe}function w(_e,ce,fe){return ce^(_e|~fe)}function F(_e,ce,fe,Re,Oe,Je,Me){return _e=E(_e,E(E(S(ce,fe,Re),Oe),Me)),E(v(_e,Je),ce)}function L(_e,ce,fe,Re,Oe,Je,Me){return _e=E(_e,E(E(C(ce,fe,Re),Oe),Me)),E(v(_e,Je),ce)}function ie(_e,ce,fe,Re,Oe,Je,Me){return _e=E(_e,E(E(I(ce,fe,Re),Oe),Me)),E(v(_e,Je),ce)}function N(_e,ce,fe,Re,Oe,Je,Me){return _e=E(_e,E(E(w(ce,fe,Re),Oe),Me)),E(v(_e,Je),ce)}function H(_e){for(var ce,fe=_e.length,Re=fe+8,Oe=(Re-Re%64)/64,Je=(Oe+1)*16,Me=new Array(Je-1),Ut=0,gt=0;gt<fe;)ce=(gt-gt%4)/4,Ut=gt%4*8,Me[ce]=Me[ce]|_e.charCodeAt(gt)<<Ut,gt++;return ce=(gt-gt%4)/4,Ut=gt%4*8,Me[ce]=Me[ce]|128<<Ut,Me[Je-2]=fe<<3,Me[Je-1]=fe>>>29,Me}function ve(_e){var ce="",fe="",Re,Oe;for(Oe=0;Oe<=3;Oe++)Re=_e>>>Oe*8&255,fe="0".concat(Re.toString(16)),ce=ce+fe.substr(fe.length-2,2);return ce}function me(_e){for(var ce="",fe=0;fe<_e.length;fe++){var Re=_e.charCodeAt(fe);Re<128?ce+=String.fromCharCode(Re):Re>127&&Re<2048?(ce+=String.fromCharCode(Re>>6|192),ce+=String.fromCharCode(Re&63|128)):(ce+=String.fromCharCode(Re>>12|224),ce+=String.fromCharCode(Re>>6&63|128),ce+=String.fromCharCode(Re&63|128))}return ce}var M=[],D,V,j,Y,$,X,U,P,Z,et=7,Q=12,W=17,B=22,te=5,de=9,Ae=14,Ue=20,Se=4,ne=11,Te=16,tt=23,st=6,ge=10,Ee=15,Ce=21;for(g=me(g),M=H(g),X=1732584193,U=4023233417,P=2562383102,Z=271733878,D=0;D<M.length;D+=16)V=X,j=U,Y=P,$=Z,X=F(X,U,P,Z,M[D+0],et,3614090360),Z=F(Z,X,U,P,M[D+1],Q,3905402710),P=F(P,Z,X,U,M[D+2],W,606105819),U=F(U,P,Z,X,M[D+3],B,3250441966),X=F(X,U,P,Z,M[D+4],et,4118548399),Z=F(Z,X,U,P,M[D+5],Q,1200080426),P=F(P,Z,X,U,M[D+6],W,2821735955),U=F(U,P,Z,X,M[D+7],B,4249261313),X=F(X,U,P,Z,M[D+8],et,1770035416),Z=F(Z,X,U,P,M[D+9],Q,2336552879),P=F(P,Z,X,U,M[D+10],W,4294925233),U=F(U,P,Z,X,M[D+11],B,2304563134),X=F(X,U,P,Z,M[D+12],et,1804603682),Z=F(Z,X,U,P,M[D+13],Q,4254626195),P=F(P,Z,X,U,M[D+14],W,2792965006),U=F(U,P,Z,X,M[D+15],B,1236535329),X=L(X,U,P,Z,M[D+1],te,4129170786),Z=L(Z,X,U,P,M[D+6],de,3225465664),P=L(P,Z,X,U,M[D+11],Ae,643717713),U=L(U,P,Z,X,M[D+0],Ue,3921069994),X=L(X,U,P,Z,M[D+5],te,3593408605),Z=L(Z,X,U,P,M[D+10],de,38016083),P=L(P,Z,X,U,M[D+15],Ae,3634488961),U=L(U,P,Z,X,M[D+4],Ue,3889429448),X=L(X,U,P,Z,M[D+9],te,568446438),Z=L(Z,X,U,P,M[D+14],de,3275163606),P=L(P,Z,X,U,M[D+3],Ae,4107603335),U=L(U,P,Z,X,M[D+8],Ue,1163531501),X=L(X,U,P,Z,M[D+13],te,2850285829),Z=L(Z,X,U,P,M[D+2],de,4243563512),P=L(P,Z,X,U,M[D+7],Ae,1735328473),U=L(U,P,Z,X,M[D+12],Ue,2368359562),X=ie(X,U,P,Z,M[D+5],Se,4294588738),Z=ie(Z,X,U,P,M[D+8],ne,2272392833),P=ie(P,Z,X,U,M[D+11],Te,1839030562),U=ie(U,P,Z,X,M[D+14],tt,4259657740),X=ie(X,U,P,Z,M[D+1],Se,2763975236),Z=ie(Z,X,U,P,M[D+4],ne,1272893353),P=ie(P,Z,X,U,M[D+7],Te,4139469664),U=ie(U,P,Z,X,M[D+10],tt,3200236656),X=ie(X,U,P,Z,M[D+13],Se,681279174),Z=ie(Z,X,U,P,M[D+0],ne,3936430074),P=ie(P,Z,X,U,M[D+3],Te,3572445317),U=ie(U,P,Z,X,M[D+6],tt,76029189),X=ie(X,U,P,Z,M[D+9],Se,3654602809),Z=ie(Z,X,U,P,M[D+12],ne,3873151461),P=ie(P,Z,X,U,M[D+15],Te,530742520),U=ie(U,P,Z,X,M[D+2],tt,3299628645),X=N(X,U,P,Z,M[D+0],st,4096336452),Z=N(Z,X,U,P,M[D+7],ge,1126891415),P=N(P,Z,X,U,M[D+14],Ee,2878612391),U=N(U,P,Z,X,M[D+5],Ce,4237533241),X=N(X,U,P,Z,M[D+12],st,1700485571),Z=N(Z,X,U,P,M[D+3],ge,2399980690),P=N(P,Z,X,U,M[D+10],Ee,4293915773),U=N(U,P,Z,X,M[D+1],Ce,2240044497),X=N(X,U,P,Z,M[D+8],st,1873313359),Z=N(Z,X,U,P,M[D+15],ge,4264355552),P=N(P,Z,X,U,M[D+6],Ee,2734768916),U=N(U,P,Z,X,M[D+13],Ce,1309151649),X=N(X,U,P,Z,M[D+4],st,4149444226),Z=N(Z,X,U,P,M[D+11],ge,3174756917),P=N(P,Z,X,U,M[D+2],Ee,718787259),U=N(U,P,Z,X,M[D+9],Ce,3951481745),X=E(X,V),U=E(U,j),P=E(P,Y),Z=E(Z,$);var be=ve(X)+ve(U)+ve(P)+ve(Z);return be.toLowerCase()},Ye.closeMediaStream=function(g){if(g)try{var v;if(g.getTracks){v=g.getTracks();var E=r(v),S;try{for(E.s();!(S=E.n()).done;){var C=S.value;C.stop()}}catch(H){E.e(H)}finally{E.f()}}else{v=g.getAudioTracks();var I=r(v),w;try{for(I.s();!(w=I.n()).done;){var F=w.value;F.stop()}}catch(H){I.e(H)}finally{I.f()}v=g.getVideoTracks();var L=r(v),ie;try{for(L.s();!(ie=L.n()).done;){var N=ie.value;N.stop()}}catch(H){L.e(H)}finally{L.f()}}}catch{(typeof g.stop=="function"||c(g.stop)==="object")&&g.stop()}},Ye.cloneArray=function(g){return g&&g.slice()||[]},Ye.cloneObject=function(g){var v=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return g&&Object.assign({},g)||v},Ye}var Do={exports:{}},mn=typeof Reflect=="object"?Reflect:null,Au=mn&&typeof mn.apply=="function"?mn.apply:function(r,n,o){return Function.prototype.apply.call(r,n,o)},ll;mn&&typeof mn.ownKeys=="function"?ll=mn.ownKeys:Object.getOwnPropertySymbols?ll=function(r){return Object.getOwnPropertyNames(r).concat(Object.getOwnPropertySymbols(r))}:ll=function(r){return Object.getOwnPropertyNames(r)};function l_(c){console&&console.warn&&console.warn(c)}var Ru=Number.isNaN||function(r){return r!==r};function Pe(){Pe.init.call(this)}Do.exports=Pe,Do.exports.once=c_,Pe.EventEmitter=Pe,Pe.prototype._events=void 0,Pe.prototype._eventsCount=0,Pe.prototype._maxListeners=void 0;var Iu=10;function ol(c){if(typeof c!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof c)}Object.defineProperty(Pe,"defaultMaxListeners",{enumerable:!0,get:function(){return Iu},set:function(c){if(typeof c!="number"||c<0||Ru(c))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+c+".");Iu=c}}),Pe.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},Pe.prototype.setMaxListeners=function(r){if(typeof r!="number"||r<0||Ru(r))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+r+".");return this._maxListeners=r,this};function bu(c){return c._maxListeners===void 0?Pe.defaultMaxListeners:c._maxListeners}Pe.prototype.getMaxListeners=function(){return bu(this)},Pe.prototype.emit=function(r){for(var n=[],o=1;o<arguments.length;o++)n.push(arguments[o]);var a=r==="error",t=this._events;if(t!==void 0)a=a&&t.error===void 0;else if(!a)return!1;if(a){var s;if(n.length>0&&(s=n[0]),s instanceof Error)throw s;var p=new Error("Unhandled error."+(s?" ("+s.message+")":""));throw p.context=s,p}var _=t[r];if(_===void 0)return!1;if(typeof _=="function")Au(_,this,n);else for(var d=_.length,g=Uu(_,d),o=0;o<d;++o)Au(g[o],this,n);return!0};function wu(c,r,n,o){var a,t,s;if(ol(n),t=c._events,t===void 0?(t=c._events=Object.create(null),c._eventsCount=0):(t.newListener!==void 0&&(c.emit("newListener",r,n.listener?n.listener:n),t=c._events),s=t[r]),s===void 0)s=t[r]=n,++c._eventsCount;else if(typeof s=="function"?s=t[r]=o?[n,s]:[s,n]:o?s.unshift(n):s.push(n),a=bu(c),a>0&&s.length>a&&!s.warned){s.warned=!0;var p=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+String(r)+" listeners added. Use emitter.setMaxListeners() to increase limit");p.name="MaxListenersExceededWarning",p.emitter=c,p.type=r,p.count=s.length,l_(p)}return c}Pe.prototype.addListener=function(r,n){return wu(this,r,n,!1)},Pe.prototype.on=Pe.prototype.addListener,Pe.prototype.prependListener=function(r,n){return wu(this,r,n,!0)};function o_(){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 Ou(c,r,n){var o={fired:!1,wrapFn:void 0,target:c,type:r,listener:n},a=o_.bind(o);return a.listener=n,o.wrapFn=a,a}Pe.prototype.once=function(r,n){return ol(n),this.on(r,Ou(this,r,n)),this},Pe.prototype.prependOnceListener=function(r,n){return ol(n),this.prependListener(r,Ou(this,r,n)),this},Pe.prototype.removeListener=function(r,n){var o,a,t,s,p;if(ol(n),a=this._events,a===void 0)return this;if(o=a[r],o===void 0)return this;if(o===n||o.listener===n)--this._eventsCount===0?this._events=Object.create(null):(delete a[r],a.removeListener&&this.emit("removeListener",r,o.listener||n));else if(typeof o!="function"){for(t=-1,s=o.length-1;s>=0;s--)if(o[s]===n||o[s].listener===n){p=o[s].listener,t=s;break}if(t<0)return this;t===0?o.shift():a_(o,t),o.length===1&&(a[r]=o[0]),a.removeListener!==void 0&&this.emit("removeListener",r,p||n)}return this},Pe.prototype.off=Pe.prototype.removeListener,Pe.prototype.removeAllListeners=function(r){var n,o,a;if(o=this._events,o===void 0)return this;if(o.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):o[r]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete o[r]),this;if(arguments.length===0){var t=Object.keys(o),s;for(a=0;a<t.length;++a)s=t[a],s!=="removeListener"&&this.removeAllListeners(s);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(n=o[r],typeof n=="function")this.removeListener(r,n);else if(n!==void 0)for(a=n.length-1;a>=0;a--)this.removeListener(r,n[a]);return this};function Du(c,r,n){var o=c._events;if(o===void 0)return[];var a=o[r];return a===void 0?[]:typeof a=="function"?n?[a.listener||a]:[a]:n?u_(a):Uu(a,a.length)}Pe.prototype.listeners=function(r){return Du(this,r,!0)},Pe.prototype.rawListeners=function(r){return Du(this,r,!1)},Pe.listenerCount=function(c,r){return typeof c.listenerCount=="function"?c.listenerCount(r):Nu.call(c,r)},Pe.prototype.listenerCount=Nu;function Nu(c){var r=this._events;if(r!==void 0){var n=r[c];if(typeof n=="function")return 1;if(n!==void 0)return n.length}return 0}Pe.prototype.eventNames=function(){return this._eventsCount>0?ll(this._events):[]};function Uu(c,r){for(var n=new Array(r),o=0;o<r;++o)n[o]=c[o];return n}function a_(c,r){for(;r+1<c.length;r++)c[r]=c[r+1];c.pop()}function u_(c){for(var r=new Array(c.length),n=0;n<r.length;++n)r[n]=c[n].listener||c[n];return r}function c_(c,r){return new Promise(function(n,o){function a(s){c.removeListener(r,t),o(s)}function t(){typeof c.removeListener=="function"&&c.removeListener("error",a),n([].slice.call(arguments))}Pu(c,r,t,{once:!0}),r!=="error"&&f_(c,a,{once:!0})})}function f_(c,r,n){typeof c.on=="function"&&Pu(c,"error",r,n)}function Pu(c,r,n,o){if(typeof c.on=="function")o.once?c.once(r,n):c.on(r,n);else if(typeof c.addEventListener=="function")c.addEventListener(r,function a(t){o.once&&c.removeEventListener(r,a),n(t)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof c)}var ot=Do.exports,No={exports:{}},Uo,ku;function __(){if(ku)return Uo;ku=1;var c=1e3,r=c*60,n=r*60,o=n*24,a=o*7,t=o*365.25;Uo=function(g,v){v=v||{};var E=typeof g;if(E==="string"&&g.length>0)return s(g);if(E==="number"&&isFinite(g))return v.long?_(g):p(g);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(g))};function s(g){if(g=String(g),!(g.length>100)){var v=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(g);if(v){var E=parseFloat(v[1]),S=(v[2]||"ms").toLowerCase();switch(S){case"years":case"year":case"yrs":case"yr":case"y":return E*t;case"weeks":case"week":case"w":return E*a;case"days":case"day":case"d":return E*o;case"hours":case"hour":case"hrs":case"hr":case"h":return E*n;case"minutes":case"minute":case"mins":case"min":case"m":return E*r;case"seconds":case"second":case"secs":case"sec":case"s":return E*c;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return E;default:return}}}}function p(g){var v=Math.abs(g);return v>=o?Math.round(g/o)+"d":v>=n?Math.round(g/n)+"h":v>=r?Math.round(g/r)+"m":v>=c?Math.round(g/c)+"s":g+"ms"}function _(g){var v=Math.abs(g);return v>=o?d(g,v,o,"day"):v>=n?d(g,v,n,"hour"):v>=r?d(g,v,r,"minute"):v>=c?d(g,v,c,"second"):g+" ms"}function d(g,v,E,S){var C=v>=E*1.5;return Math.round(g/E)+" "+S+(C?"s":"")}return Uo}function h_(c){n.debug=n,n.default=n,n.coerce=_,n.disable=t,n.enable=a,n.enabled=s,n.humanize=__(),n.destroy=d,Object.keys(c).forEach(g=>{n[g]=c[g]}),n.names=[],n.skips=[],n.formatters={};function r(g){let v=0;for(let E=0;E<g.length;E++)v=(v<<5)-v+g.charCodeAt(E),v|=0;return n.colors[Math.abs(v)%n.colors.length]}n.selectColor=r;function n(g){let v,E=null,S,C;function I(...w){if(!I.enabled)return;const F=I,L=Number(new Date),ie=L-(v||L);F.diff=ie,F.prev=v,F.curr=L,v=L,w[0]=n.coerce(w[0]),typeof w[0]!="string"&&w.unshift("%O");let N=0;w[0]=w[0].replace(/%([a-zA-Z%])/g,(ve,me)=>{if(ve==="%%")return"%";N++;const M=n.formatters[me];if(typeof M=="function"){const D=w[N];ve=M.call(F,D),w.splice(N,1),N--}return ve}),n.formatArgs.call(F,w),(F.log||n.log).apply(F,w)}return I.namespace=g,I.useColors=n.useColors(),I.color=n.selectColor(g),I.extend=o,I.destroy=n.destroy,Object.defineProperty(I,"enabled",{enumerable:!0,configurable:!1,get:()=>E!==null?E:(S!==n.namespaces&&(S=n.namespaces,C=n.enabled(g)),C),set:w=>{E=w}}),typeof n.init=="function"&&n.init(I),I}function o(g,v){const E=n(this.namespace+(typeof v>"u"?":":v)+g);return E.log=this.log,E}function a(g){n.save(g),n.namespaces=g,n.names=[],n.skips=[];let v;const E=(typeof g=="string"?g:"").split(/[\s,]+/),S=E.length;for(v=0;v<S;v++)E[v]&&(g=E[v].replace(/\*/g,".*?"),g[0]==="-"?n.skips.push(new RegExp("^"+g.slice(1)+"$")):n.names.push(new RegExp("^"+g+"$")))}function t(){const g=[...n.names.map(p),...n.skips.map(p).map(v=>"-"+v)].join(",");return n.enable(""),g}function s(g){if(g[g.length-1]==="*")return!0;let v,E;for(v=0,E=n.skips.length;v<E;v++)if(n.skips[v].test(g))return!1;for(v=0,E=n.names.length;v<E;v++)if(n.names[v].test(g))return!0;return!1}function p(g){return g.toString().substring(2,g.toString().length-2).replace(/\.\*\?$/,"*")}function _(g){return g instanceof Error?g.stack||g.message:g}function d(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")}return n.enable(n.load()),n}var d_=h_;(function(c,r){r.formatArgs=o,r.save=a,r.load=t,r.useColors=n,r.storage=s(),r.destroy=(()=>{let _=!1;return()=>{_||(_=!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`."))}})(),r.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"];function n(){return typeof window<"u"&&window.process&&(window.process.type==="renderer"||window.process.__nwjs)?!0:typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)?!1:typeof document<"u"&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||typeof window<"u"&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)}function o(_){if(_[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+_[0]+(this.useColors?"%c ":" ")+"+"+c.exports.humanize(this.diff),!this.useColors)return;const d="color: "+this.color;_.splice(1,0,d,"color: inherit");let g=0,v=0;_[0].replace(/%[a-zA-Z%]/g,E=>{E!=="%%"&&(g++,E==="%c"&&(v=g))}),_.splice(v,0,d)}r.log=console.debug||console.log||(()=>{});function a(_){try{_?r.storage.setItem("debug",_):r.storage.removeItem("debug")}catch{}}function t(){let _;try{_=r.storage.getItem("debug")}catch{}return!_&&typeof process<"u"&&"env"in process&&(_=process.env.DEBUG),_}function s(){try{return localStorage}catch{}}c.exports=d_(r);const{formatters:p}=c.exports;p.j=function(_){try{return JSON.stringify(_)}catch(d){return"[UnexpectedJSONParseError]: "+d.message}}})(No,No.exports);var gn=No.exports;function p_(c,r){if(!(c instanceof r))throw new TypeError("Cannot call a class as a function")}function Mu(c,r){for(var n=0;n<r.length;n++){var o=r[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(c,o.key,o)}}function m_(c,r,n){return r&&Mu(c.prototype,r),n&&Mu(c,n),c}var vn=gn,Tn="JsSIP",rt=function(){function c(r){p_(this,c),r?(this._debug=vn.default("".concat(Tn,":").concat(r)),this._warn=vn.default("".concat(Tn,":WARN:").concat(r)),this._error=vn.default("".concat(Tn,":ERROR:").concat(r))):(this._debug=vn.default(Tn),this._warn=vn.default("".concat(Tn,":WARN")),this._error=vn.default("".concat(Tn,":ERROR"))),this._debug.log=console.info.bind(console),this._warn.log=console.warn.bind(console),this._error.log=console.error.bind(console)}return m_(c,[{key:"debug",get:function(){return this._debug}},{key:"warn",get:function(){return this._warn}},{key:"error",get:function(){return this._error}}]),c}(),wt={},xu={},Lu={exports:{}},$u=Lu.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 r="candidate:%s %d %s %d %s %d typ %s";return r+=c.raddr!=null?" raddr %s rport %d":"%v%v",r+=c.tcptype!=null?" tcptype %s":"%v",c.generation!=null&&(r+=" generation %d"),r+=c["network-id"]!=null?" network-id %d":"%v",r+=c["network-cost"]!=null?" network-cost %d":"%v",r}},{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 r="ssrc:%d";return c.attribute!=null&&(r+=" %s",c.value!=null&&(r+=":%s")),r}},{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 r="mediaclk:";return r+=c.id!=null?"id=%s %s":"%v%s",r+=c.mediaClockValue!=null?"=%s":"",r+=c.rateNumerator!=null?" rate=%s":"",r+=c.rateDenominator!=null?"/%s":"",r}},{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($u).forEach(function(c){var r=$u[c];r.forEach(function(n){n.reg||(n.reg=/(.*)/),n.format||(n.format="%s")})});var Hu=Lu.exports;(function(c){var r=function(p){return String(Number(p))===p?Number(p):p},n=function(p,_,d,g){if(g&&!d)_[g]=r(p[1]);else for(var v=0;v<d.length;v+=1)p[v+1]!=null&&(_[d[v]]=r(p[v+1]))},o=function(p,_,d){var g=p.name&&p.names;p.push&&!_[p.push]?_[p.push]=[]:g&&!_[p.name]&&(_[p.name]={});var v=p.push?{}:g?_[p.name]:_;n(d.match(p.reg),v,p.names,p.name),p.push&&_[p.push].push(v)},a=Hu,t=RegExp.prototype.test.bind(/^([a-z])=(.*)/);c.parse=function(p){var _={},d=[],g=_;return p.split(/(\r\n|\r|\n)/).filter(t).forEach(function(v){var E=v[0],S=v.slice(2);E==="m"&&(d.push({rtp:[],fmtp:[]}),g=d[d.length-1]);for(var C=0;C<(a[E]||[]).length;C+=1){var I=a[E][C];if(I.reg.test(S))return o(I,g,S)}}),_.media=d,_};var s=function(p,_){var d=_.split(/=(.+)/,2);return d.length===2?p[d[0]]=r(d[1]):d.length===1&&_.length>1&&(p[d[0]]=void 0),p};c.parseParams=function(p){return p.split(/;\s?/).reduce(s,{})},c.parseFmtpConfig=c.parseParams,c.parsePayloads=function(p){return p.toString().split(" ").map(Number)},c.parseRemoteCandidates=function(p){for(var _=[],d=p.split(" ").map(r),g=0;g<d.length;g+=3)_.push({component:d[g],ip:d[g+1],port:d[g+2]});return _},c.parseImageAttributes=function(p){return p.split(" ").map(function(_){return _.substring(1,_.length-1).split(",").reduce(s,{})})},c.parseSimulcastStreamList=function(p){return p.split(";").map(function(_){return _.split(",").map(function(d){var g,v=!1;return d[0]!=="~"?g=r(d):(g=r(d.substring(1,d.length)),v=!0),{scid:g,paused:v}})})}})(xu);var Po=Hu,g_=/%[sdv%]/g,v_=function(c){var r=1,n=arguments,o=n.length;return c.replace(g_,function(a){if(r>=o)return a;var t=n[r];switch(r+=1,a){case"%%":return"%";case"%s":return String(t);case"%d":return Number(t);case"%v":return""}})},ar=function(c,r,n){var o=r.format instanceof Function?r.format(r.push?n:n[r.name]):r.format,a=[c+"="+o];if(r.names)for(var t=0;t<r.names.length;t+=1){var s=r.names[t];r.name?a.push(n[r.name][s]):a.push(n[r.names[t]])}else a.push(n[r.name]);return v_.apply(null,a)},T_=["v","o","s","i","u","e","p","c","b","t","r","z","a"],E_=["i","c","b","a"],y_=function(c,r){r=r||{},c.version==null&&(c.version=0),c.name==null&&(c.name=" "),c.media.forEach(function(t){t.payloads==null&&(t.payloads="")});var n=r.outerOrder||T_,o=r.innerOrder||E_,a=[];return n.forEach(function(t){Po[t].forEach(function(s){s.name in c&&c[s.name]!=null?a.push(ar(t,s,c)):s.push in c&&c[s.push]!=null&&c[s.push].forEach(function(p){a.push(ar(t,s,p))})})}),c.media.forEach(function(t){a.push(ar("m",Po.m[0],t)),o.forEach(function(s){Po[s].forEach(function(p){p.name in t&&t[p.name]!=null?a.push(ar(s,p,t)):p.push in t&&t[p.push]!=null&&t[p.push].forEach(function(_){a.push(ar(s,p,_))})})})}),a.join(`\r
7
+ `)+`\r
8
+ `},Ls=xu,S_=y_;wt.write=S_,wt.parse=Ls.parse,wt.parseParams=Ls.parseParams,wt.parseFmtpConfig=Ls.parseFmtpConfig,wt.parsePayloads=Ls.parsePayloads,wt.parseRemoteCandidates=Ls.parseRemoteCandidates,wt.parseImageAttributes=Ls.parseImageAttributes,wt.parseSimulcastStreamList=Ls.parseSimulcastStreamList;function al(c){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?al=function(n){return typeof n}:al=function(n){return n&&typeof Symbol=="function"&&n.constructor===Symbol&&n!==Symbol.prototype?"symbol":typeof n},al(c)}function ko(c,r){if(typeof r!="function"&&r!==null)throw new TypeError("Super expression must either be null or a function");c.prototype=Object.create(r&&r.prototype,{constructor:{value:c,writable:!0,configurable:!0}}),r&&Mo(c,r)}function Mo(c,r){return Mo=Object.setPrototypeOf||function(o,a){return o.__proto__=a,o},Mo(c,r)}function xo(c){var r=R_();return function(){var o=ul(c),a;if(r){var t=ul(this).constructor;a=Reflect.construct(o,arguments,t)}else a=o.apply(this,arguments);return C_(this,a)}}function C_(c,r){return r&&(al(r)==="object"||typeof r=="function")?r:A_(c)}function A_(c){if(c===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return c}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 ul(c){return ul=Object.setPrototypeOf?Object.getPrototypeOf:function(n){return n.__proto__||Object.getPrototypeOf(n)},ul(c)}function Ot(c,r){var n;if(typeof Symbol>"u"||c[Symbol.iterator]==null){if(Array.isArray(c)||(n=I_(c))||r&&c&&typeof c.length=="number"){n&&(c=n);var o=0,a=function(){};return{s:a,n:function(){return o>=c.length?{done:!0}:{done:!1,value:c[o++]}},e:function(d){throw d},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 t=!0,s=!1,p;return{s:function(){n=c[Symbol.iterator]()},n:function(){var d=n.next();return t=d.done,d},e:function(d){s=!0,p=d},f:function(){try{!t&&n.return!=null&&n.return()}finally{if(s)throw p}}}}function I_(c,r){if(c){if(typeof c=="string")return Fu(c,r);var n=Object.prototype.toString.call(c).slice(8,-1);if(n==="Object"&&c.constructor&&(n=c.constructor.name),n==="Map"||n==="Set")return Array.from(c);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return Fu(c,r)}}function Fu(c,r){(r==null||r>c.length)&&(r=c.length);for(var n=0,o=new Array(r);n<r;n++)o[n]=c[n];return o}function ur(c,r){if(!(c instanceof r))throw new TypeError("Cannot call a class as a function")}function qu(c,r){for(var n=0;n<r.length;n++){var o=r[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(c,o.key,o)}}function cl(c,r,n){return r&&qu(c.prototype,r),n&&qu(c,n),c}var ju=wt,b_=rt,at=Xe,Qe=vt(),Vu=bo(),w_=jt(),Lo=new b_("SIPMessage"),Bu=function(){function c(r,n,o,a,t,s){if(ur(this,c),!r||!n||!o)return null;a=a||{},this.ua=o,this.headers={},this.method=r,this.ruri=n,this.body=s,this.extraHeaders=Qe.cloneArray(t),this.ua.configuration.extra_headers&&(this.extraHeaders=this.extraHeaders.concat(this.ua.configuration.extra_headers)),a.route_set?this.setHeader("route",a.route_set):o.configuration.use_preloaded_route&&this.setHeader("route","<".concat(o.transport.sip_uri,";lr>")),this.setHeader("via",""),this.setHeader("max-forwards",at.MAX_FORWARDS);var p=a.to_uri||n,_=a.to_tag?{tag:a.to_tag}:null,d=typeof a.to_display_name<"u"?a.to_display_name:null;this.to=new Vu(p,d,_),this.setHeader("to",this.to.toString());var g=a.from_uri||o.configuration.uri,v={tag:a.from_tag||Qe.newTag()},E;typeof a.from_display_name<"u"?E=a.from_display_name:o.configuration.display_name?E=o.configuration.display_name:E=null,this.from=new Vu(g,E,v),this.setHeader("from",this.from.toString());var S=a.call_id||o.configuration.jssip_id+Qe.createRandomToken(15);this.call_id=S,this.setHeader("call-id",S);var C=a.cseq||Math.floor(Math.random()*1e4);this.cseq=C,this.setHeader("cseq","".concat(C," ").concat(r))}return cl(c,[{key:"setHeader",value:function(n,o){for(var a=new RegExp("^\\s*".concat(n,"\\s*:"),"i"),t=0;t<this.extraHeaders.length;t++)a.test(this.extraHeaders[t])&&this.extraHeaders.splice(t,1);this.headers[Qe.headerize(n)]=Array.isArray(o)?o:[o]}},{key:"getHeader",value:function(n){var o=this.headers[Qe.headerize(n)];if(o){if(o[0])return o[0]}else{var a=new RegExp("^\\s*".concat(n,"\\s*:"),"i"),t=Ot(this.extraHeaders),s;try{for(t.s();!(s=t.n()).done;){var p=s.value;if(a.test(p))return p.substring(p.indexOf(":")+1).trim()}}catch(_){t.e(_)}finally{t.f()}}}},{key:"getHeaders",value:function(n){var o=this.headers[Qe.headerize(n)],a=[];if(o){var t=Ot(o),s;try{for(t.s();!(s=t.n()).done;){var p=s.value;a.push(p)}}catch(E){t.e(E)}finally{t.f()}return a}else{var _=new RegExp("^\\s*".concat(n,"\\s*:"),"i"),d=Ot(this.extraHeaders),g;try{for(d.s();!(g=d.n()).done;){var v=g.value;_.test(v)&&a.push(v.substring(v.indexOf(":")+1).trim())}}catch(E){d.e(E)}finally{d.f()}return a}}},{key:"hasHeader",value:function(n){if(this.headers[Qe.headerize(n)])return!0;var o=new RegExp("^\\s*".concat(n,"\\s*:"),"i"),a=Ot(this.extraHeaders),t;try{for(a.s();!(t=a.n()).done;){var s=t.value;if(o.test(s))return!0}}catch(p){a.e(p)}finally{a.f()}return!1}},{key:"parseSDP",value:function(n){return!n&&this.sdp?this.sdp:(this.sdp=ju.parse(this.body||""),this.sdp)}},{key:"toString",value:function(){var n="".concat(this.method," ").concat(this.ruri,` SIP/2.0\r
10
+ `);for(var o in this.headers)if(Object.prototype.hasOwnProperty.call(this.headers,o)){var a=Ot(this.headers[o]),t;try{for(a.s();!(t=a.n()).done;){var s=t.value;n+="".concat(o,": ").concat(s,`\r
11
+ `)}}catch(S){a.e(S)}finally{a.f()}}var p=Ot(this.extraHeaders),_;try{for(p.s();!(_=p.n()).done;){var d=_.value;n+="".concat(d.trim(),`\r
12
+ `)}}catch(S){p.e(S)}finally{p.f()}var g=[];switch(this.method){case at.REGISTER:g.push("path","gruu");break;case at.INVITE:this.ua.configuration.session_timers&&g.push("timer"),(this.ua.contact.pub_gruu||this.ua.contact.temp_gruu)&&g.push("gruu"),g.push("ice","replaces");break;case at.UPDATE:this.ua.configuration.session_timers&&g.push("timer"),g.push("ice");break}g.push("outbound");var v=this.ua.configuration.user_agent||at.USER_AGENT;if(n+="Allow: ".concat(at.ALLOWED_METHODS,`\r
13
+ `),n+="Supported: ".concat(g,`\r
14
+ `),n+="User-Agent: ".concat(v,`\r
15
+ `),this.body){var E=Qe.str_utf8_length(this.body);n+="Content-Length: ".concat(E,`\r
16
+ \r
17
+ `),n+=this.body}else n+=`Content-Length: 0\r
18
+ \r
19
+ `;return n}},{key:"clone",value:function(){var n=new c(this.method,this.ruri,this.ua);return Object.keys(this.headers).forEach(function(o){n.headers[o]=this.headers[o].slice()},this),n.body=this.body,n.extraHeaders=Qe.cloneArray(this.extraHeaders),n.to=this.to,n.from=this.from,n.call_id=this.call_id,n.cseq=this.cseq,n}}]),c}(),O_=function(c){ko(n,c);var r=xo(n);function n(o,a,t,s,p){var _;return ur(this,n),_=r.call(this,at.INVITE,o,a,t,s,p),_.transaction=null,_}return cl(n,[{key:"cancel",value:function(a){this.transaction.cancel(a)}},{key:"clone",value:function(){var a=new n(this.ruri,this.ua);return Object.keys(this.headers).forEach(function(t){a.headers[t]=this.headers[t].slice()},this),a.body=this.body,a.extraHeaders=Qe.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}}]),n}(Bu),Gu=function(){function c(){ur(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 cl(c,[{key:"addHeader",value:function(n,o){var a={raw:o};n=Qe.headerize(n),this.headers[n]?this.headers[n].push(a):this.headers[n]=[a]}},{key:"getHeader",value:function(n){var o=this.headers[Qe.headerize(n)];if(o){if(o[0])return o[0].raw}else return}},{key:"getHeaders",value:function(n){var o=this.headers[Qe.headerize(n)],a=[];if(!o)return[];var t=Ot(o),s;try{for(t.s();!(s=t.n()).done;){var p=s.value;a.push(p.raw)}}catch(_){t.e(_)}finally{t.f()}return a}},{key:"hasHeader",value:function(n){return!!this.headers[Qe.headerize(n)]}},{key:"parseHeader",value:function(n){var o=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;if(n=Qe.headerize(n),this.headers[n]){if(o>=this.headers[n].length){Lo.debug('not so many "'.concat(n,'" headers present'));return}}else{Lo.debug('header "'.concat(n,'" not present'));return}var a=this.headers[n][o],t=a.raw;if(a.parsed)return a.parsed;var s=w_.parse(t,n.replace(/-/g,"_"));if(s===-1){this.headers[n].splice(o,1),Lo.debug('error parsing "'.concat(n,'" header field with value "').concat(t,'"'));return}else return a.parsed=s,s}},{key:"s",value:function(n,o){return this.parseHeader(n,o)}},{key:"setHeader",value:function(n,o){var a={raw:o};this.headers[Qe.headerize(n)]=[a]}},{key:"parseSDP",value:function(n){return!n&&this.sdp?this.sdp:(this.sdp=ju.parse(this.body||""),this.sdp)}},{key:"toString",value:function(){return this.data}}]),c}(),D_=function(c){ko(n,c);var r=xo(n);function n(o){var a;return ur(this,n),a=r.call(this),a.ua=o,a.headers={},a.ruri=null,a.transport=null,a.server_transaction=null,a}return cl(n,[{key:"reply",value:function(a,t,s,p,_,d){var g=[],v=this.getHeader("To");if(a=a||null,t=t||null,!a||a<100||a>699)throw new TypeError("Invalid status_code: ".concat(a));if(t&&typeof t!="string"&&!(t instanceof String))throw new TypeError("Invalid reason_phrase: ".concat(t));t=t||at.REASON_PHRASE[a]||"",s=Qe.cloneArray(s),this.ua.configuration.extra_headers&&(s=s.concat(this.ua.configuration.extra_headers));var E="SIP/2.0 ".concat(a," ").concat(t,`\r
20
+ `);if(this.method===at.INVITE&&a>100&&a<=200){var S=this.getHeaders("record-route"),C=Ot(S),I;try{for(C.s();!(I=C.n()).done;){var w=I.value;E+="Record-Route: ".concat(w,`\r
21
+ `)}}catch(D){C.e(D)}finally{C.f()}}var F=this.getHeaders("via"),L=Ot(F),ie;try{for(L.s();!(ie=L.n()).done;){var N=ie.value;E+="Via: ".concat(N,`\r
22
+ `)}}catch(D){L.e(D)}finally{L.f()}!this.to_tag&&a>100?v+=";tag=".concat(Qe.newTag()):this.to_tag&&!this.s("to").hasParam("tag")&&(v+=";tag=".concat(this.to_tag)),E+="To: ".concat(v,`\r
23
+ `),E+="From: ".concat(this.getHeader("From"),`\r
24
+ `),E+="Call-ID: ".concat(this.call_id,`\r
25
+ `),E+="CSeq: ".concat(this.cseq," ").concat(this.method,`\r
26
+ `);var H=Ot(s),ve;try{for(H.s();!(ve=H.n()).done;){var me=ve.value;E+="".concat(me.trim(),`\r
27
+ `)}}catch(D){H.e(D)}finally{H.f()}switch(this.method){case at.INVITE:this.ua.configuration.session_timers&&g.push("timer"),(this.ua.contact.pub_gruu||this.ua.contact.temp_gruu)&&g.push("gruu"),g.push("ice","replaces");break;case at.UPDATE:this.ua.configuration.session_timers&&g.push("timer"),p&&g.push("ice"),g.push("replaces")}if(g.push("outbound"),this.method===at.OPTIONS?(E+="Allow: ".concat(at.ALLOWED_METHODS,`\r
28
+ `),E+="Accept: ".concat(at.ACCEPTED_BODY_TYPES,`\r
29
+ `)):a===405?E+="Allow: ".concat(at.ALLOWED_METHODS,`\r
30
+ `):a===415&&(E+="Accept: ".concat(at.ACCEPTED_BODY_TYPES,`\r
31
+ `)),E+="Supported: ".concat(g,`\r
32
+ `),p){var M=Qe.str_utf8_length(p);E+=`Content-Type: application/sdp\r
33
+ `,E+="Content-Length: ".concat(M,`\r
34
+ \r
35
+ `),E+=p}else E+="Content-Length: ".concat(0,`\r
36
+ \r
37
+ `);this.server_transaction.receiveResponse(a,E,_,d)}},{key:"reply_sl",value:function(){var a=arguments.length>0&&arguments[0]!==void 0?arguments[0]:null,t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:null,s=this.getHeaders("via");if(!a||a<100||a>699)throw new TypeError("Invalid status_code: ".concat(a));if(t&&typeof t!="string"&&!(t instanceof String))throw new TypeError("Invalid reason_phrase: ".concat(t));t=t||at.REASON_PHRASE[a]||"";var p="SIP/2.0 ".concat(a," ").concat(t,`\r
38
+ `),_=Ot(s),d;try{for(_.s();!(d=_.n()).done;){var g=d.value;p+="Via: ".concat(g,`\r
39
+ `)}}catch(I){_.e(I)}finally{_.f()}var v=this.getHeader("To");if(!this.to_tag&&a>100?v+=";tag=".concat(Qe.newTag()):this.to_tag&&!this.s("to").hasParam("tag")&&(v+=";tag=".concat(this.to_tag)),p+="To: ".concat(v,`\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 E=Ot(this.ua.configuration.extra_headers),S;try{for(E.s();!(S=E.n()).done;){var C=S.value;p+="".concat(C.trim(),`\r
44
+ `)}}catch(I){E.e(I)}finally{E.f()}}p+="Content-Length: ".concat(0,`\r
45
+ \r
46
+ `),this.transport.send(p)}}]),n}(Gu),N_=function(c){ko(n,c);var r=xo(n);function n(){var o;return ur(this,n),o=r.call(this),o.headers={},o.status_code=null,o.reason_phrase=null,o}return n}(Gu),ts={OutgoingRequest:Bu,InitialOutgoingInviteRequest:O_,IncomingRequest:D_,IncomingResponse:N_};function U_(c,r){if(!(c instanceof r))throw new TypeError("Cannot call a class as a function")}function Ku(c,r){for(var n=0;n<r.length;n++){var o=r[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(c,o.key,o)}}function P_(c,r,n){return r&&Ku(c.prototype,r),n&&Ku(c,n),c}var k_=rt,ss=vt(),Lt=new k_("DigestAuthentication"),M_=function(){function c(r){U_(this,c),this._credentials=r,this._cnonce=null,this._nc=0,this._ncHex="00000000",this._algorithm=null,this._realm=null,this._nonce=null,this._opaque=null,this._stale=null,this._qop=null,this._method=null,this._uri=null,this._ha1=null,this._response=null}return P_(c,[{key:"get",value:function(n){switch(n){case"realm":return this._realm;case"ha1":return this._ha1;default:Lt.warn('get() | cannot get "%s" parameter',n);return}}},{key:"authenticate",value:function(n,o){var a=n.method,t=n.ruri,s=n.body,p=arguments.length>2&&arguments[2]!==void 0?arguments[2]: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 Lt.warn('authenticate() | challenge with Digest algorithm different than "MD5", authentication aborted'),!1}else this._algorithm="MD5";if(!this._nonce)return Lt.warn("authenticate() | challenge without Digest nonce, authentication aborted"),!1;if(!this._realm)return Lt.warn("authenticate() | challenge without Digest realm, authentication aborted"),!1;if(!this._credentials.password){if(!this._credentials.ha1)return Lt.warn("authenticate() | no plain SIP password nor ha1 provided, authentication aborted"),!1;if(this._credentials.realm!==this._realm)return Lt.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 Lt.warn('authenticate() | challenge without Digest qop different than "auth" or "auth-int", authentication aborted'),!1;else this._qop=null;this._method=a,this._uri=t,this._cnonce=p||ss.createRandomToken(12),this._nc+=1;var _=Number(this._nc).toString(16);this._ncHex="00000000".substr(0,8-_.length)+_,this._nc===4294967296&&(this._nc=1,this._ncHex="00000001"),this._credentials.password?this._ha1=ss.calculateMD5("".concat(this._credentials.username,":").concat(this._realm,":").concat(this._credentials.password)):this._ha1=this._credentials.ha1;var d,g;return this._qop==="auth"?(d="".concat(this._method,":").concat(this._uri),g=ss.calculateMD5(d),Lt.debug('authenticate() | using qop=auth [a2:"%s"]',d),this._response=ss.calculateMD5("".concat(this._ha1,":").concat(this._nonce,":").concat(this._ncHex,":").concat(this._cnonce,":auth:").concat(g))):this._qop==="auth-int"?(d="".concat(this._method,":").concat(this._uri,":").concat(ss.calculateMD5(s||"")),g=ss.calculateMD5(d),Lt.debug('authenticate() | using qop=auth-int [a2:"%s"]',d),this._response=ss.calculateMD5("".concat(this._ha1,":").concat(this._nonce,":").concat(this._ncHex,":").concat(this._cnonce,":auth-int:").concat(g))):this._qop===null&&(d="".concat(this._method,":").concat(this._uri),g=ss.calculateMD5(d),Lt.debug('authenticate() | using qop=null [a2:"%s"]',d),this._response=ss.calculateMD5("".concat(this._ha1,":").concat(this._nonce,":").concat(g))),Lt.debug("authenticate() | response generated"),!0}},{key:"toString",value:function(){var n=[];if(!this._response)throw new Error("response field does not exist, cannot generate Authorization header");return n.push("algorithm=".concat(this._algorithm)),n.push('username="'.concat(this._credentials.username,'"')),n.push('realm="'.concat(this._realm,'"')),n.push('nonce="'.concat(this._nonce,'"')),n.push('uri="'.concat(this._uri,'"')),n.push('response="'.concat(this._response,'"')),this._opaque&&n.push('opaque="'.concat(this._opaque,'"')),this._qop&&(n.push("qop=".concat(this._qop)),n.push('cnonce="'.concat(this._cnonce,'"')),n.push("nc=".concat(this._ncHex))),"Digest ".concat(n.join(", "))}}]),c}(),ns=500,x_=4e3,Wu=5e3,Yu={T1:ns,T2:x_,T4:Wu,TIMER_B:64*ns,TIMER_D:0*ns,TIMER_F:64*ns,TIMER_H:64*ns,TIMER_I:0*ns,TIMER_J:0*ns,TIMER_K:0*Wu,TIMER_L:64*ns,TIMER_M:64*ns,PROVISIONAL_RESPONSE_INTERVAL:6e4};function fl(c){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?fl=function(n){return typeof n}:fl=function(n){return n&&typeof Symbol=="function"&&n.constructor===Symbol&&n!==Symbol.prototype?"symbol":typeof n},fl(c)}function cr(c,r){if(!(c instanceof r))throw new TypeError("Cannot call a class as a function")}function zu(c,r){for(var n=0;n<r.length;n++){var o=r[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(c,o.key,o)}}function fr(c,r,n){return r&&zu(c.prototype,r),n&&zu(c,n),c}function _r(c,r){if(typeof r!="function"&&r!==null)throw new TypeError("Super expression must either be null or a function");c.prototype=Object.create(r&&r.prototype,{constructor:{value:c,writable:!0,configurable:!0}}),r&&$o(c,r)}function $o(c,r){return $o=Object.setPrototypeOf||function(o,a){return o.__proto__=a,o},$o(c,r)}function hr(c){var r=$_();return function(){var o=_l(c),a;if(r){var t=_l(this).constructor;a=Reflect.construct(o,arguments,t)}else a=o.apply(this,arguments);return L_(this,a)}}function L_(c,r){return r&&(fl(r)==="object"||typeof r=="function")?r:gs(c)}function gs(c){if(c===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return c}function $_(){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 _l(c){return _l=Object.setPrototypeOf?Object.getPrototypeOf:function(n){return n.__proto__||Object.getPrototypeOf(n)},_l(c)}var dr=ot.EventEmitter,pr=rt,mr=Xe,Ju=ts,Vt=Yu,Xu=new pr("NonInviteClientTransaction"),hl=new pr("InviteClientTransaction"),H_=new pr("AckClientTransaction"),Qu=new pr("NonInviteServerTransaction"),dl=new pr("InviteServerTransaction"),le={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"},F_=function(c){_r(n,c);var r=hr(n);function n(o,a,t,s){var p;cr(this,n),p=r.call(this),p.type=le.NON_INVITE_CLIENT,p.id="z9hG4bK".concat(Math.floor(Math.random()*1e7)),p.ua=o,p.transport=a,p.request=t,p.eventHandlers=s;var _="SIP/2.0/".concat(a.via_transport);return _+=" ".concat(o.configuration.via_host,";branch=").concat(p.id),p.request.setHeader("via",_),p.ua.newTransaction(gs(p)),p}return fr(n,[{key:"stateChanged",value:function(a){this.state=a,this.emit("stateChanged")}},{key:"send",value:function(){var a=this;this.stateChanged(le.STATUS_TRYING),this.F=setTimeout(function(){a.timer_F()},Vt.TIMER_F),this.transport.send(this.request)||this.onTransportError()}},{key:"onTransportError",value:function(){Xu.debug("transport error occurred, deleting transaction ".concat(this.id)),clearTimeout(this.F),clearTimeout(this.K),this.stateChanged(le.STATUS_TERMINATED),this.ua.destroyTransaction(this),this.eventHandlers.onTransportError()}},{key:"timer_F",value:function(){Xu.debug("Timer F expired for transaction ".concat(this.id)),this.stateChanged(le.STATUS_TERMINATED),this.ua.destroyTransaction(this),this.eventHandlers.onRequestTimeout()}},{key:"timer_K",value:function(){this.stateChanged(le.STATUS_TERMINATED),this.ua.destroyTransaction(this)}},{key:"receiveResponse",value:function(a){var t=this,s=a.status_code;if(s<200)switch(this.state){case le.STATUS_TRYING:case le.STATUS_PROCEEDING:this.stateChanged(le.STATUS_PROCEEDING),this.eventHandlers.onReceiveResponse(a);break}else switch(this.state){case le.STATUS_TRYING:case le.STATUS_PROCEEDING:this.stateChanged(le.STATUS_COMPLETED),clearTimeout(this.F),s===408?this.eventHandlers.onRequestTimeout():this.eventHandlers.onReceiveResponse(a),this.K=setTimeout(function(){t.timer_K()},Vt.TIMER_K);break;case le.STATUS_COMPLETED:break}}},{key:"C",get:function(){return le}}]),n}(dr),q_=function(c){_r(n,c);var r=hr(n);function n(o,a,t,s){var p;cr(this,n),p=r.call(this),p.type=le.INVITE_CLIENT,p.id="z9hG4bK".concat(Math.floor(Math.random()*1e7)),p.ua=o,p.transport=a,p.request=t,p.eventHandlers=s,t.transaction=gs(p);var _="SIP/2.0/".concat(a.via_transport);return _+=" ".concat(o.configuration.via_host,";branch=").concat(p.id),p.request.setHeader("via",_),p.ua.newTransaction(gs(p)),p}return fr(n,[{key:"stateChanged",value:function(a){this.state=a,this.emit("stateChanged")}},{key:"send",value:function(){var a=this;this.stateChanged(le.STATUS_CALLING),this.B=setTimeout(function(){a.timer_B()},Vt.TIMER_B),this.transport.send(this.request)||this.onTransportError()}},{key:"onTransportError",value:function(){clearTimeout(this.B),clearTimeout(this.D),clearTimeout(this.M),this.state!==le.STATUS_ACCEPTED&&(hl.debug("transport error occurred, deleting transaction ".concat(this.id)),this.eventHandlers.onTransportError()),this.stateChanged(le.STATUS_TERMINATED),this.ua.destroyTransaction(this)}},{key:"timer_M",value:function(){hl.debug("Timer M expired for transaction ".concat(this.id)),this.state===le.STATUS_ACCEPTED&&(clearTimeout(this.B),this.stateChanged(le.STATUS_TERMINATED),this.ua.destroyTransaction(this))}},{key:"timer_B",value:function(){hl.debug("Timer B expired for transaction ".concat(this.id)),this.state===le.STATUS_CALLING&&(this.stateChanged(le.STATUS_TERMINATED),this.ua.destroyTransaction(this),this.eventHandlers.onRequestTimeout())}},{key:"timer_D",value:function(){hl.debug("Timer D expired for transaction ".concat(this.id)),clearTimeout(this.B),this.stateChanged(le.STATUS_TERMINATED),this.ua.destroyTransaction(this)}},{key:"sendACK",value:function(a){var t=this,s=new Ju.OutgoingRequest(mr.ACK,this.request.ruri,this.ua,{route_set:this.request.getHeaders("route"),call_id:this.request.getHeader("call-id"),cseq:this.request.cseq});s.setHeader("from",this.request.getHeader("from")),s.setHeader("via",this.request.getHeader("via")),s.setHeader("to",a.getHeader("to")),this.D=setTimeout(function(){t.timer_D()},Vt.TIMER_D),this.transport.send(s)}},{key:"cancel",value:function(a){if(this.state===le.STATUS_PROCEEDING){var t=new Ju.OutgoingRequest(mr.CANCEL,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",this.request.getHeader("to")),a&&t.setHeader("reason",a),this.transport.send(t)}}},{key:"receiveResponse",value:function(a){var t=this,s=a.status_code;if(s>=100&&s<=199)switch(this.state){case le.STATUS_CALLING:this.stateChanged(le.STATUS_PROCEEDING),this.eventHandlers.onReceiveResponse(a);break;case le.STATUS_PROCEEDING:this.eventHandlers.onReceiveResponse(a);break}else if(s>=200&&s<=299)switch(this.state){case le.STATUS_CALLING:case le.STATUS_PROCEEDING:this.stateChanged(le.STATUS_ACCEPTED),this.M=setTimeout(function(){t.timer_M()},Vt.TIMER_M),this.eventHandlers.onReceiveResponse(a);break;case le.STATUS_ACCEPTED:this.eventHandlers.onReceiveResponse(a);break}else if(s>=300&&s<=699)switch(this.state){case le.STATUS_CALLING:case le.STATUS_PROCEEDING:this.stateChanged(le.STATUS_COMPLETED),this.sendACK(a),this.eventHandlers.onReceiveResponse(a);break;case le.STATUS_COMPLETED:this.sendACK(a);break}}},{key:"C",get:function(){return le}}]),n}(dr),j_=function(c){_r(n,c);var r=hr(n);function n(o,a,t,s){var p;cr(this,n),p=r.call(this),p.id="z9hG4bK".concat(Math.floor(Math.random()*1e7)),p.transport=a,p.request=t,p.eventHandlers=s;var _="SIP/2.0/".concat(a.via_transport);return _+=" ".concat(o.configuration.via_host,";branch=").concat(p.id),p.request.setHeader("via",_),p}return fr(n,[{key:"send",value:function(){this.transport.send(this.request)||this.onTransportError()}},{key:"onTransportError",value:function(){H_.debug("transport error occurred for transaction ".concat(this.id)),this.eventHandlers.onTransportError()}},{key:"C",get:function(){return le}}]),n}(dr),V_=function(c){_r(n,c);var r=hr(n);function n(o,a,t){var s;return cr(this,n),s=r.call(this),s.type=le.NON_INVITE_SERVER,s.id=t.via_branch,s.ua=o,s.transport=a,s.request=t,s.last_response="",t.server_transaction=gs(s),s.state=le.STATUS_TRYING,o.newTransaction(gs(s)),s}return fr(n,[{key:"stateChanged",value:function(a){this.state=a,this.emit("stateChanged")}},{key:"timer_J",value:function(){Qu.debug("Timer J expired for transaction ".concat(this.id)),this.stateChanged(le.STATUS_TERMINATED),this.ua.destroyTransaction(this)}},{key:"onTransportError",value:function(){this.transportError||(this.transportError=!0,Qu.debug("transport error occurred, deleting transaction ".concat(this.id)),clearTimeout(this.J),this.stateChanged(le.STATUS_TERMINATED),this.ua.destroyTransaction(this))}},{key:"receiveResponse",value:function(a,t,s,p){var _=this;if(a===100)switch(this.state){case le.STATUS_TRYING:this.stateChanged(le.STATUS_PROCEEDING),this.transport.send(t)||this.onTransportError();break;case le.STATUS_PROCEEDING:this.last_response=t,this.transport.send(t)?s&&s():(this.onTransportError(),p&&p());break}else if(a>=200&&a<=699)switch(this.state){case le.STATUS_TRYING:case le.STATUS_PROCEEDING:this.stateChanged(le.STATUS_COMPLETED),this.last_response=t,this.J=setTimeout(function(){_.timer_J()},Vt.TIMER_J),this.transport.send(t)?s&&s():(this.onTransportError(),p&&p());break;case le.STATUS_COMPLETED:break}}},{key:"C",get:function(){return le}}]),n}(dr),B_=function(c){_r(n,c);var r=hr(n);function n(o,a,t){var s;return cr(this,n),s=r.call(this),s.type=le.INVITE_SERVER,s.id=t.via_branch,s.ua=o,s.transport=a,s.request=t,s.last_response="",t.server_transaction=gs(s),s.state=le.STATUS_PROCEEDING,o.newTransaction(gs(s)),s.resendProvisionalTimer=null,t.reply(100),s}return fr(n,[{key:"stateChanged",value:function(a){this.state=a,this.emit("stateChanged")}},{key:"timer_H",value:function(){dl.debug("Timer H expired for transaction ".concat(this.id)),this.state===le.STATUS_COMPLETED&&dl.debug("ACK not received, dialog will be terminated"),this.stateChanged(le.STATUS_TERMINATED),this.ua.destroyTransaction(this)}},{key:"timer_I",value:function(){this.stateChanged(le.STATUS_TERMINATED),this.ua.destroyTransaction(this)}},{key:"timer_L",value:function(){dl.debug("Timer L expired for transaction ".concat(this.id)),this.state===le.STATUS_ACCEPTED&&(this.stateChanged(le.STATUS_TERMINATED),this.ua.destroyTransaction(this))}},{key:"onTransportError",value:function(){this.transportError||(this.transportError=!0,dl.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(le.STATUS_TERMINATED),this.ua.destroyTransaction(this))}},{key:"resend_provisional",value:function(){this.transport.send(this.last_response)||this.onTransportError()}},{key:"receiveResponse",value:function(a,t,s,p){var _=this;if(a>=100&&a<=199)switch(this.state){case le.STATUS_PROCEEDING:this.transport.send(t)||this.onTransportError(),this.last_response=t;break}if(a>100&&a<=199&&this.state===le.STATUS_PROCEEDING)this.resendProvisionalTimer===null&&(this.resendProvisionalTimer=setInterval(function(){_.resend_provisional()},Vt.PROVISIONAL_RESPONSE_INTERVAL));else if(a>=200&&a<=299)switch(this.state){case le.STATUS_PROCEEDING:this.stateChanged(le.STATUS_ACCEPTED),this.last_response=t,this.L=setTimeout(function(){_.timer_L()},Vt.TIMER_L),this.resendProvisionalTimer!==null&&(clearInterval(this.resendProvisionalTimer),this.resendProvisionalTimer=null);case le.STATUS_ACCEPTED:this.transport.send(t)?s&&s():(this.onTransportError(),p&&p());break}else if(a>=300&&a<=699)switch(this.state){case le.STATUS_PROCEEDING:this.resendProvisionalTimer!==null&&(clearInterval(this.resendProvisionalTimer),this.resendProvisionalTimer=null),this.transport.send(t)?(this.stateChanged(le.STATUS_COMPLETED),this.H=setTimeout(function(){_.timer_H()},Vt.TIMER_H),s&&s()):(this.onTransportError(),p&&p());break}}},{key:"C",get:function(){return le}}]),n}(dr);function G_(c,r){var n=c._transactions,o;switch(r.method){case mr.INVITE:if(o=n.ist[r.via_branch],o){switch(o.state){case le.STATUS_PROCEEDING:o.transport.send(o.last_response);break;case le.STATUS_ACCEPTED:break}return!0}break;case mr.ACK:if(o=n.ist[r.via_branch],o){if(o.state===le.STATUS_ACCEPTED)return!1;if(o.state===le.STATUS_COMPLETED)return o.state=le.STATUS_CONFIRMED,o.I=setTimeout(function(){o.timer_I()},Vt.TIMER_I),!0}else return!1;break;case mr.CANCEL:return o=n.ist[r.via_branch],o?(r.reply_sl(200),o.state!==le.STATUS_PROCEEDING):(r.reply_sl(481),!0);default:if(o=n.nist[r.via_branch],o){switch(o.state){case le.STATUS_TRYING:break;case le.STATUS_PROCEEDING:case le.STATUS_COMPLETED:o.transport.send(o.last_response);break}return!0}break}}var gr={C:le,NonInviteClientTransaction:F_,InviteClientTransaction:q_,AckClientTransaction:j_,NonInviteServerTransaction:V_,InviteServerTransaction:B_,checkTransaction:G_};function K_(c,r){if(!(c instanceof r))throw new TypeError("Cannot call a class as a function")}function Zu(c,r){for(var n=0;n<r.length;n++){var o=r[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(c,o.key,o)}}function W_(c,r,n){return r&&Zu(c.prototype,r),n&&Zu(c,n),c}var Y_=rt,ec=Xe,z_=M_,Ho=gr,J_=new Y_("RequestSender"),Fo={onRequestTimeout:function(){},onTransportError:function(){},onReceiveResponse:function(){},onAuthenticated:function(){}},vr=function(){function c(r,n,o){K_(this,c),this._ua=r,this._eventHandlers=o,this._method=n.method,this._request=n,this._auth=null,this._challenged=!1,this._staled=!1;for(var a in Fo)Object.prototype.hasOwnProperty.call(Fo,a)&&(this._eventHandlers[a]||(this._eventHandlers[a]=Fo[a]));r.status===r.C.STATUS_USER_CLOSED&&(this._method!==ec.BYE||this._method!==ec.ACK)&&this._eventHandlers.onTransportError()}return W_(c,[{key:"send",value:function(){var n=this,o={onRequestTimeout:function(){n._eventHandlers.onRequestTimeout()},onTransportError:function(){n._eventHandlers.onTransportError()},onReceiveResponse:function(t){n._receiveResponse(t)}};switch(this._method){case"INVITE":this.clientTransaction=new Ho.InviteClientTransaction(this._ua,this._ua.transport,this._request,o);break;case"ACK":this.clientTransaction=new Ho.AckClientTransaction(this._ua,this._ua.transport,this._request,o);break;default:this.clientTransaction=new Ho.NonInviteClientTransaction(this._ua,this._ua.transport,this._request,o)}this._ua._configuration.authorization_jwt&&this._request.setHeader("Authorization",this._ua._configuration.authorization_jwt),this.clientTransaction.send()}},{key:"_receiveResponse",value:function(n){var o,a,t=n.status_code;if((t===401||t===407)&&(this._ua.configuration.password!==null||this._ua.configuration.ha1!==null)){if(n.status_code===401?(o=n.parseHeader("www-authenticate"),a="authorization"):(o=n.parseHeader("proxy-authenticate"),a="proxy-authorization"),!o){J_.debug("".concat(n.status_code," with wrong or missing challenge, cannot authenticate")),this._eventHandlers.onReceiveResponse(n);return}if(!this._challenged||!this._staled&&o.stale===!0){if(this._auth||(this._auth=new z_({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,o)){this._eventHandlers.onReceiveResponse(n);return}this._challenged=!0,this._ua.set("realm",this._auth.get("realm")),this._ua.set("ha1",this._auth.get("ha1")),o.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(n)}else this._eventHandlers.onReceiveResponse(n)}}]),c}();function X_(c,r){if(!(c instanceof r))throw new TypeError("Cannot call a class as a function")}function tc(c,r){for(var n=0;n<r.length;n++){var o=r[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(c,o.key,o)}}function Q_(c,r,n){return r&&tc(c.prototype,r),n&&tc(c,n),c}var Z_=rt,qo=vt(),$s=Xe,sc=ts,nc=vr,Tr=new Z_("Registrator"),pl=10,eh=function(){function c(r,n){X_(this,c),this._reg_id=1,this._ua=r,this._transport=n,this._registrar=r.configuration.registrar_server,this._expires=r.configuration.register_expires,this._call_id=qo.createRandomToken(22),this._cseq=0,this._to_uri=r.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 Q_(c,[{key:"setExtraHeaders",value:function(n){Array.isArray(n)||(n=[]),this._extraHeaders=n.slice()}},{key:"setExtraContactParams",value:function(n){n instanceof Object||(n={}),this._extraContactParams="";for(var o in n)if(Object.prototype.hasOwnProperty.call(n,o)){var a=n[o];this._extraContactParams+=";".concat(o),a&&(this._extraContactParams+="=".concat(a))}}},{key:"register",value:function(){var n=this;if(this._registering){Tr.debug("Register request in progress...");return}var o=this._extraHeaders.slice();o.push("Contact: ".concat(this._contact,";expires=").concat(this._expires).concat(this._extraContactParams)),o.push("Expires: ".concat(this._expires));var a=new sc.OutgoingRequest($s.REGISTER,this._registrar,this._ua,{to_uri:this._to_uri,call_id:this._call_id,cseq:this._cseq+=1},o),t=new nc(this._ua,a,{onRequestTimeout:function(){n._registrationFailure(null,$s.causes.REQUEST_TIMEOUT)},onTransportError:function(){n._registrationFailure(null,$s.causes.CONNECTION_ERROR)},onAuthenticated:function(){n._cseq+=1},onReceiveResponse:function(p){if(p.cseq===n._cseq)switch(n._registrationTimer!==null&&(clearTimeout(n._registrationTimer),n._registrationTimer=null),!0){case/^1[0-9]{2}$/.test(p.status_code):break;case/^2[0-9]{2}$/.test(p.status_code):{if(n._registering=!1,!p.hasHeader("Contact")){Tr.debug("no Contact header in response to REGISTER, response ignored");break}var _=p.headers.Contact.reduce(function(S,C){return S.concat(C.parsed)},[]),d=_.find(function(S){return n._sipInstance===S.getParam("+sip.instance")&&n._reg_id===parseInt(S.getParam("reg-id"))});if(d||(d=_.find(function(S){return S.uri.user===n._ua.contact.uri.user})),!d){Tr.debug("no Contact header pointing to us, response ignored");break}var g=d.getParam("expires");!g&&p.hasHeader("expires")&&(g=p.getHeader("expires")),g||(g=n._expires),g=Number(g),g<pl&&(g=pl);var v=g>64?g*1e3/2+Math.floor((g/2-32)*1e3*Math.random()):g*1e3-5e3;n._registrationTimer=setTimeout(function(){n._registrationTimer=null,n._ua.listeners("registrationExpiring").length===0?n.register():n._ua.emit("registrationExpiring")},v),d.hasParam("temp-gruu")&&(n._ua.contact.temp_gruu=d.getParam("temp-gruu").replace(/"/g,"")),d.hasParam("pub-gruu")&&(n._ua.contact.pub_gruu=d.getParam("pub-gruu").replace(/"/g,"")),n._registered||(n._registered=!0,n._ua.registered({response:p}));break}case/^423$/.test(p.status_code):{p.hasHeader("min-expires")?(n._expires=Number(p.getHeader("min-expires")),n._expires<pl&&(n._expires=pl),n.register()):(Tr.debug("423 response received for REGISTER without Min-Expires"),n._registrationFailure(p,$s.causes.SIP_FAILURE_CODE));break}default:{var E=qo.sipErrorCause(p.status_code);n._registrationFailure(p,E)}}}});this._registering=!0,t.send()}},{key:"unregister",value:function(){var n=this,o=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(!this._registered){Tr.debug("already unregistered");return}this._registered=!1,this._registrationTimer!==null&&(clearTimeout(this._registrationTimer),this._registrationTimer=null);var a=this._extraHeaders.slice();o.all?a.push("Contact: *".concat(this._extraContactParams)):a.push("Contact: ".concat(this._contact,";expires=0").concat(this._extraContactParams)),a.push("Expires: 0");var t=new sc.OutgoingRequest($s.REGISTER,this._registrar,this._ua,{to_uri:this._to_uri,call_id:this._call_id,cseq:this._cseq+=1},a),s=new nc(this._ua,t,{onRequestTimeout:function(){n._unregistered(null,$s.causes.REQUEST_TIMEOUT)},onTransportError:function(){n._unregistered(null,$s.causes.CONNECTION_ERROR)},onAuthenticated:function(){n._cseq+=1},onReceiveResponse:function(_){switch(!0){case/^1[0-9]{2}$/.test(_.status_code):break;case/^2[0-9]{2}$/.test(_.status_code):n._unregistered(_);break;default:{var d=qo.sipErrorCause(_.status_code);n._unregistered(_,d)}}}});s.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(n,o){this._registering=!1,this._ua.registrationFailed({response:n||null,cause:o}),this._registered&&(this._registered=!1,this._ua.unregistered({response:n||null,cause:o}))}},{key:"_unregistered",value:function(n,o){this._registering=!1,this._registered=!1,this._ua.unregistered({response:n||null,cause:o||null})}},{key:"registered",get:function(){return this._registered}}]),c}();function th(c,r){if(!(c instanceof r))throw new TypeError("Cannot call a class as a function")}function rc(c,r){for(var n=0;n<r.length;n++){var o=r[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(c,o.key,o)}}function sh(c,r,n){return r&&rc(c.prototype,r),n&&rc(c,n),c}var jo=Xe,ml=gr,nh=vr,Vo={onRequestTimeout:function(){},onTransportError:function(){},onSuccessResponse:function(){},onErrorResponse:function(){},onAuthenticated:function(){},onDialogError:function(){}},rh=function(){function c(r,n,o){th(this,c),this._dialog=r,this._ua=r._ua,this._request=n,this._eventHandlers=o,this._reattempt=!1,this._reattemptTimer=null;for(var a in Vo)Object.prototype.hasOwnProperty.call(Vo,a)&&(this._eventHandlers[a]||(this._eventHandlers[a]=Vo[a]))}return sh(c,[{key:"send",value:function(){var n=this,o=new nh(this._ua,this._request,{onRequestTimeout:function(){n._eventHandlers.onRequestTimeout()},onTransportError:function(){n._eventHandlers.onTransportError()},onAuthenticated:function(s){n._eventHandlers.onAuthenticated(s)},onReceiveResponse:function(s){n._receiveResponse(s)}});if(o.send(),(this._request.method===jo.INVITE||this._request.method===jo.UPDATE&&this._request.body)&&o.clientTransaction.state!==ml.C.STATUS_TERMINATED){this._dialog.uac_pending_reply=!0;var a=function t(){(o.clientTransaction.state===ml.C.STATUS_ACCEPTED||o.clientTransaction.state===ml.C.STATUS_COMPLETED||o.clientTransaction.state===ml.C.STATUS_TERMINATED)&&(o.clientTransaction.removeListener("stateChanged",t),n._dialog.uac_pending_reply=!1)};o.clientTransaction.on("stateChanged",a)}}},{key:"_receiveResponse",value:function(n){var o=this;n.status_code===408||n.status_code===481?this._eventHandlers.onDialogError(n):n.method===jo.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(function(){o._dialog.isTerminated()||(o._reattempt=!0,o.send())},1e3)):n.status_code>=200&&n.status_code<300?this._eventHandlers.onSuccessResponse(n):n.status_code>=300&&this._eventHandlers.onErrorResponse(n)}},{key:"request",get:function(){return this._request}}]),c}();function ih(c,r){if(!(c instanceof r))throw new TypeError("Cannot call a class as a function")}function ic(c,r){for(var n=0;n<r.length;n++){var o=r[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(c,o.key,o)}}function lc(c,r,n){return r&&ic(c.prototype,r),n&&ic(c,n),c}var lh=rt,oc=ts,vs=Xe,Er=gr,oh=rh,Bo=vt(),Go=new lh("Dialog"),Ts={STATUS_EARLY:1,STATUS_CONFIRMED:2,STATUS_TERMINATED:3},ah=function(){lc(c,null,[{key:"C",get:function(){return Ts}}]);function c(r,n,o){var a=arguments.length>3&&arguments[3]!==void 0?arguments[3]:Ts.STATUS_CONFIRMED;if(ih(this,c),this._owner=r,this._ua=r._ua,this._uac_pending_reply=!1,this._uas_pending_reply=!1,!n.hasHeader("contact"))return{error:"unable to create a Dialog without Contact header field"};n instanceof oc.IncomingResponse&&(a=n.status_code<200?Ts.STATUS_EARLY:Ts.STATUS_CONFIRMED);var t=n.parseHeader("contact");o==="UAS"?(this._id={call_id:n.call_id,local_tag:n.to_tag,remote_tag:n.from_tag,toString:function(){return this.call_id+this.local_tag+this.remote_tag}},this._state=a,this._remote_seqnum=n.cseq,this._local_uri=n.parseHeader("to").uri,this._remote_uri=n.parseHeader("from").uri,this._remote_target=t.uri,this._route_set=n.getHeaders("record-route"),this._ack_seqnum=this._remote_seqnum):o==="UAC"&&(this._id={call_id:n.call_id,local_tag:n.from_tag,remote_tag:n.to_tag,toString:function(){return this.call_id+this.local_tag+this.remote_tag}},this._state=a,this._local_seqnum=n.cseq,this._local_uri=n.parseHeader("from").uri,this._remote_uri=n.parseHeader("to").uri,this._remote_target=t.uri,this._route_set=n.getHeaders("record-route").reverse(),this._ack_seqnum=null),this._ua.newDialog(this),Go.debug("new ".concat(o," dialog created with status ").concat(this._state===Ts.STATUS_EARLY?"EARLY":"CONFIRMED"))}return lc(c,[{key:"isTerminated",value:function(){return this._status===Ts.STATUS_TERMINATED}},{key:"update",value:function(n,o){this._state=Ts.STATUS_CONFIRMED,Go.debug("dialog ".concat(this._id.toString()," changed to CONFIRMED state")),o==="UAC"&&(this._route_set=n.getHeaders("record-route").reverse())}},{key:"terminate",value:function(){Go.debug("dialog ".concat(this._id.toString()," deleted")),this._ua.destroyDialog(this),this._state=Ts.STATUS_TERMINATED}},{key:"sendRequest",value:function(n){var o=this,a=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},t=Bo.cloneArray(a.extraHeaders),s=Bo.cloneObject(a.eventHandlers),p=a.body||null,_=this._createRequest(n,t,p);s.onAuthenticated=function(){o._local_seqnum+=1};var d=new oh(this,_,s);return d.send(),_}},{key:"receiveRequest",value:function(n){this._checkInDialogRequest(n)&&(n.method===vs.ACK&&this._ack_seqnum!==null?this._ack_seqnum=null:n.method===vs.INVITE&&(this._ack_seqnum=n.cseq),this._owner.receiveRequest(n))}},{key:"_createRequest",value:function(n,o,a){o=Bo.cloneArray(o),this._local_seqnum||(this._local_seqnum=Math.floor(Math.random()*1e4));var t=n===vs.CANCEL||n===vs.ACK?this._local_seqnum:this._local_seqnum+=1,s=new oc.OutgoingRequest(n,this._remote_target,this._ua,{cseq:t,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},o,a);return s}},{key:"_checkInDialogRequest",value:function(n){var o=this;if(!this._remote_seqnum)this._remote_seqnum=n.cseq;else if(n.cseq<this._remote_seqnum)if(n.method===vs.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===vs.INVITE||n.method===vs.UPDATE&&n.body){if(this._uac_pending_reply===!0)n.reply(491);else if(this._uas_pending_reply===!0){var a=(Math.random()*10|0)+1;return n.reply(500,null,["Retry-After:".concat(a)]),!1}else{this._uas_pending_reply=!0;var t=function s(){(n.server_transaction.state===Er.C.STATUS_ACCEPTED||n.server_transaction.state===Er.C.STATUS_COMPLETED||n.server_transaction.state===Er.C.STATUS_TERMINATED)&&(n.server_transaction.removeListener("stateChanged",s),o._uas_pending_reply=!1)};n.server_transaction.on("stateChanged",t)}n.hasHeader("contact")&&n.server_transaction.on("stateChanged",function(){n.server_transaction.state===Er.C.STATUS_ACCEPTED&&(o._remote_target=n.parseHeader("contact").uri)})}else n.method===vs.NOTIFY&&n.hasHeader("contact")&&n.server_transaction.on("stateChanged",function(){n.server_transaction.state===Er.C.STATUS_COMPLETED&&(o._remote_target=n.parseHeader("contact").uri)});return!0}},{key:"id",get:function(){return this._id}},{key:"local_seqnum",get:function(){return this._local_seqnum},set:function(n){this._local_seqnum=n}},{key:"owner",get:function(){return this._owner}},{key:"uac_pending_reply",get:function(){return this._uac_pending_reply},set:function(n){this._uac_pending_reply=n}},{key:"uas_pending_reply",get:function(){return this._uas_pending_reply}}]),c}(),Ko={exports:{}};function gl(c){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?gl=function(n){return typeof n}:gl=function(n){return n&&typeof Symbol=="function"&&n.constructor===Symbol&&n!==Symbol.prototype?"symbol":typeof n},gl(c)}function uh(c,r){if(!(c instanceof r))throw new TypeError("Cannot call a class as a function")}function ac(c,r){for(var n=0;n<r.length;n++){var o=r[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(c,o.key,o)}}function ch(c,r,n){return r&&ac(c.prototype,r),n&&ac(c,n),c}function fh(c,r){if(typeof r!="function"&&r!==null)throw new TypeError("Super expression must either be null or a function");c.prototype=Object.create(r&&r.prototype,{constructor:{value:c,writable:!0,configurable:!0}}),r&&Wo(c,r)}function Wo(c,r){return Wo=Object.setPrototypeOf||function(o,a){return o.__proto__=a,o},Wo(c,r)}function _h(c){var r=ph();return function(){var o=vl(c),a;if(r){var t=vl(this).constructor;a=Reflect.construct(o,arguments,t)}else a=o.apply(this,arguments);return hh(this,a)}}function hh(c,r){return r&&(gl(r)==="object"||typeof r=="function")?r:dh(c)}function dh(c){if(c===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return c}function ph(){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(n){return n.__proto__||Object.getPrototypeOf(n)},vl(c)}var mh=ot.EventEmitter,gh=rt,vh=Xe,Th=ps,uc=vt(),Eh=new gh("RTCSession:DTMF"),cc={MIN_DURATION:70,MAX_DURATION:6e3,DEFAULT_DURATION:100,MIN_INTER_TONE_GAP:50,DEFAULT_INTER_TONE_GAP:500};Ko.exports=function(c){fh(n,c);var r=_h(n);function n(o){var a;return uh(this,n),a=r.call(this),a._session=o,a._direction=null,a._tone=null,a._duration=null,a._request=null,a}return ch(n,[{key:"send",value:function(a){var t=this,s=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 Th.InvalidStateError(this._session.status);var p=uc.cloneArray(s.extraHeaders);if(this.eventHandlers=uc.cloneObject(s.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=s.duration,p.push("Content-Type: application/dtmf-relay");var _="Signal=".concat(this._tone,`\r
47
+ `);_+="Duration=".concat(this._duration),this._session.newDTMF({originator:"local",dtmf:this,request:this._request}),this._session.sendRequest(vh.INFO,{extraHeaders:p,eventHandlers:{onSuccessResponse:function(g){t.emit("succeeded",{originator:"remote",response:g})},onErrorResponse:function(g){t.eventHandlers.onFailed&&t.eventHandlers.onFailed(),t.emit("failed",{originator:"remote",response:g})},onRequestTimeout:function(){t._session.onRequestTimeout()},onTransportError:function(){t._session.onTransportError()},onDialogError:function(){t._session.onDialogError()}},body:_})}},{key:"init_incoming",value:function(a){var t=/^(Signal\s*?=\s*?)([0-9A-D#*]{1})(\s)?.*/,s=/^(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&&t.test(p[0])&&(this._tone=p[0].replace(t,"$2")),p.length>=2&&s.test(p[1])&&(this._duration=parseInt(p[1].replace(s,"$2"),10))}this._duration||(this._duration=cc.DEFAULT_DURATION),this._tone?this._session.newDTMF({originator:"remote",dtmf:this,request:a}):Eh.debug("invalid INFO DTMF received, discarded")}},{key:"tone",get:function(){return this._tone}},{key:"duration",get:function(){return this._duration}}]),n}(mh),Ko.exports.C=cc;var yh=Ko.exports;function Tl(c){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?Tl=function(n){return typeof n}:Tl=function(n){return n&&typeof Symbol=="function"&&n.constructor===Symbol&&n!==Symbol.prototype?"symbol":typeof n},Tl(c)}function Sh(c,r){if(!(c instanceof r))throw new TypeError("Cannot call a class as a function")}function fc(c,r){for(var n=0;n<r.length;n++){var o=r[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(c,o.key,o)}}function Ch(c,r,n){return r&&fc(c.prototype,r),n&&fc(c,n),c}function Ah(c,r){if(typeof r!="function"&&r!==null)throw new TypeError("Super expression must either be null or a function");c.prototype=Object.create(r&&r.prototype,{constructor:{value:c,writable:!0,configurable:!0}}),r&&Yo(c,r)}function Yo(c,r){return Yo=Object.setPrototypeOf||function(o,a){return o.__proto__=a,o},Yo(c,r)}function Rh(c){var r=wh();return function(){var o=El(c),a;if(r){var t=El(this).constructor;a=Reflect.construct(o,arguments,t)}else a=o.apply(this,arguments);return Ih(this,a)}}function Ih(c,r){return r&&(Tl(r)==="object"||typeof r=="function")?r:bh(c)}function bh(c){if(c===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return c}function wh(){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 El(c){return El=Object.setPrototypeOf?Object.getPrototypeOf:function(n){return n.__proto__||Object.getPrototypeOf(n)},El(c)}var Oh=ot.EventEmitter,Dh=Xe,Nh=ps,Uh=vt(),Ph=function(c){Ah(n,c);var r=Rh(n);function n(o){var a;return Sh(this,n),a=r.call(this),a._session=o,a._direction=null,a._contentType=null,a._body=null,a}return Ch(n,[{key:"send",value:function(a,t){var s=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 Nh.InvalidStateError(this._session.status);this._contentType=a,this._body=t;var _=Uh.cloneArray(p.extraHeaders);_.push("Content-Type: ".concat(a)),this._session.newInfo({originator:"local",info:this,request:this.request}),this._session.sendRequest(Dh.INFO,{extraHeaders:_,eventHandlers:{onSuccessResponse:function(g){s.emit("succeeded",{originator:"remote",response:g})},onErrorResponse:function(g){s.emit("failed",{originator:"remote",response:g})},onTransportError:function(){s._session.onTransportError()},onRequestTimeout:function(){s._session.onRequestTimeout()},onDialogError:function(){s._session.onDialogError()}},body:t})}},{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}}]),n}(Oh);function kh(c,r){if(!(c instanceof r))throw new TypeError("Cannot call a class as a function")}function _c(c,r){for(var n=0;n<r.length;n++){var o=r[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(c,o.key,o)}}function Mh(c,r,n){return r&&_c(c.prototype,r),n&&_c(c,n),c}var xh=rt,hc=Xe,Lh=new xh("RTCSession:ReferNotifier"),zo={event_type:"refer",body_type:"message/sipfrag;version=2.0",expires:300},$h=function(){function c(r,n,o){kh(this,c),this._session=r,this._id=n,this._expires=o||zo.expires,this._active=!0,this.notify(100)}return Mh(c,[{key:"notify",value:function(n,o){if(Lh.debug("notify()"),this._active!==!1){o=o||hc.REASON_PHRASE[n]||"";var a;n>=200?a="terminated;reason=noresource":a="active;expires=".concat(this._expires),this._session.sendRequest(hc.NOTIFY,{extraHeaders:["Event: ".concat(zo.event_type,";id=").concat(this._id),"Subscription-State: ".concat(a),"Content-Type: ".concat(zo.body_type)],body:"SIP/2.0 ".concat(n," ").concat(o),eventHandlers:{onErrorResponse:function(){this._active=!1}}})}}}]),c}();function yl(c){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?yl=function(n){return typeof n}:yl=function(n){return n&&typeof Symbol=="function"&&n.constructor===Symbol&&n!==Symbol.prototype?"symbol":typeof n},yl(c)}function Hh(c,r){if(!(c instanceof r))throw new TypeError("Cannot call a class as a function")}function dc(c,r){for(var n=0;n<r.length;n++){var o=r[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(c,o.key,o)}}function Fh(c,r,n){return r&&dc(c.prototype,r),n&&dc(c,n),c}function qh(c,r){if(typeof r!="function"&&r!==null)throw new TypeError("Super expression must either be null or a function");c.prototype=Object.create(r&&r.prototype,{constructor:{value:c,writable:!0,configurable:!0}}),r&&Jo(c,r)}function Jo(c,r){return Jo=Object.setPrototypeOf||function(o,a){return o.__proto__=a,o},Jo(c,r)}function jh(c){var r=Gh();return function(){var o=Sl(c),a;if(r){var t=Sl(this).constructor;a=Reflect.construct(o,arguments,t)}else a=o.apply(this,arguments);return Vh(this,a)}}function Vh(c,r){return r&&(yl(r)==="object"||typeof r=="function")?r:Bh(c)}function Bh(c){if(c===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return c}function Gh(){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 Sl(c){return Sl=Object.setPrototypeOf?Object.getPrototypeOf:function(n){return n.__proto__||Object.getPrototypeOf(n)},Sl(c)}var Kh=ot.EventEmitter,Wh=rt,yr=Xe,Yh=jt(),pc=vt(),Hs=new Wh("RTCSession:ReferSubscriber"),zh=function(c){qh(n,c);var r=jh(n);function n(o){var a;return Hh(this,n),a=r.call(this),a._id=null,a._session=o,a}return Fh(n,[{key:"sendRefer",value:function(a){var t=this,s=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};Hs.debug("sendRefer()");var p=pc.cloneArray(s.extraHeaders),_=pc.cloneObject(s.eventHandlers);for(var d in _)Object.prototype.hasOwnProperty.call(_,d)&&this.on(d,_[d]);var g=null;s.replaces&&(g=s.replaces._request.call_id,g+=";to-tag=".concat(s.replaces._to_tag),g+=";from-tag=".concat(s.replaces._from_tag),g=encodeURIComponent(g));var v="Refer-To: <".concat(a).concat(g?"?Replaces=".concat(g):"",">");if(p.push(v),!p.some(function(C){return C.toLowerCase().startsWith("referred-by:")})){var E="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(E)}p.push("Contact: ".concat(this._session.contact));var S=this._session.sendRequest(yr.REFER,{extraHeaders:p,eventHandlers:{onSuccessResponse:function(I){t._requestSucceeded(I)},onErrorResponse:function(I){t._requestFailed(I,yr.causes.REJECTED)},onTransportError:function(){t._requestFailed(null,yr.causes.CONNECTION_ERROR)},onRequestTimeout:function(){t._requestFailed(null,yr.causes.REQUEST_TIMEOUT)},onDialogError:function(){t._requestFailed(null,yr.causes.DIALOG_ERROR)}}});this._id=S.cseq}},{key:"receiveNotify",value:function(a){if(Hs.debug("receiveNotify()"),!!a.body){var t=Yh.parse(a.body.trim().split(`\r
49
+ `,1)[0],"Status_Line");if(t===-1){Hs.debug('receiveNotify() | error parsing NOTIFY body: "'.concat(a.body,'"'));return}switch(!0){case/^100$/.test(t.status_code):this.emit("trying",{request:a,status_line:t});break;case/^1[0-9]{2}$/.test(t.status_code):this.emit("progress",{request:a,status_line:t});break;case/^2[0-9]{2}$/.test(t.status_code):this.emit("accepted",{request:a,status_line:t});break;default:this.emit("failed",{request:a,status_line:t});break}}}},{key:"_requestSucceeded",value:function(a){Hs.debug("REFER succeeded"),Hs.debug('emit "requestSucceeded"'),this.emit("requestSucceeded",{response:a})}},{key:"_requestFailed",value:function(a,t){Hs.debug("REFER failed"),Hs.debug('emit "requestFailed"'),this.emit("requestFailed",{response:a||null,cause:t})}},{key:"id",get:function(){return this._id}}]),n}(Kh);function Cl(c){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?Cl=function(n){return typeof n}:Cl=function(n){return n&&typeof Symbol=="function"&&n.constructor===Symbol&&n!==Symbol.prototype?"symbol":typeof n},Cl(c)}function rs(c,r){var n;if(typeof Symbol>"u"||c[Symbol.iterator]==null){if(Array.isArray(c)||(n=Jh(c))||r&&c&&typeof c.length=="number"){n&&(c=n);var o=0,a=function(){};return{s:a,n:function(){return o>=c.length?{done:!0}:{done:!1,value:c[o++]}},e:function(d){throw d},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 t=!0,s=!1,p;return{s:function(){n=c[Symbol.iterator]()},n:function(){var d=n.next();return t=d.done,d},e:function(d){s=!0,p=d},f:function(){try{!t&&n.return!=null&&n.return()}finally{if(s)throw p}}}}function Jh(c,r){if(c){if(typeof c=="string")return mc(c,r);var n=Object.prototype.toString.call(c).slice(8,-1);if(n==="Object"&&c.constructor&&(n=c.constructor.name),n==="Map"||n==="Set")return Array.from(c);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return mc(c,r)}}function mc(c,r){(r==null||r>c.length)&&(r=c.length);for(var n=0,o=new Array(r);n<r;n++)o[n]=c[n];return o}function Xh(c,r){if(!(c instanceof r))throw new TypeError("Cannot call a class as a function")}function gc(c,r){for(var n=0;n<r.length;n++){var o=r[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(c,o.key,o)}}function vc(c,r,n){return r&&gc(c.prototype,r),n&&gc(c,n),c}function Qh(c,r){if(typeof r!="function"&&r!==null)throw new TypeError("Super expression must either be null or a function");c.prototype=Object.create(r&&r.prototype,{constructor:{value:c,writable:!0,configurable:!0}}),r&&Xo(c,r)}function Xo(c,r){return Xo=Object.setPrototypeOf||function(o,a){return o.__proto__=a,o},Xo(c,r)}function Zh(c){var r=sd();return function(){var o=Al(c),a;if(r){var t=Al(this).constructor;a=Reflect.construct(o,arguments,t)}else a=o.apply(this,arguments);return ed(this,a)}}function ed(c,r){return r&&(Cl(r)==="object"||typeof r=="function")?r:td(c)}function td(c){if(c===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return c}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 Al(c){return Al=Object.setPrototypeOf?Object.getPrototypeOf:function(n){return n.__proto__||Object.getPrototypeOf(n)},Al(c)}var nd=ot.EventEmitter,Tc=wt,rd=rt,oe=Xe,Fs=ps,Ec=gr,Fe=vt(),Sr=Yu,id=ts,Rl=ah,ld=vr,It=yh,yc=Ph,od=$h,ad=zh,Sc=ms(),G=new rd("RTCSession"),z={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},Il=["audio","video"],ud=function(c){Qh(n,c);var r=Zh(n);vc(n,null,[{key:"C",get:function(){return z}}]);function n(o){var a;return Xh(this,n),G.debug("new"),a=r.call(this),a._id=null,a._ua=o,a._status=z.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:oe.SESSION_EXPIRES,currentExpires:null,running:!1,refresher:!1,timer:null},a._referSubscribers={},a._data={},a}return vc(n,[{key:"isInProgress",value:function(){switch(this._status){case z.STATUS_NULL:case z.STATUS_INVITE_SENT:case z.STATUS_1XX_RECEIVED:case z.STATUS_INVITE_RECEIVED:case z.STATUS_WAITING_FOR_ANSWER:return!0;default:return!1}}},{key:"isEstablished",value:function(){switch(this._status){case z.STATUS_ANSWERED:case z.STATUS_WAITING_FOR_ACK:case z.STATUS_CONFIRMED:return!0;default:return!1}}},{key:"isEnded",value:function(){switch(this._status){case z.STATUS_CANCELED:case z.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 t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},s=arguments.length>2?arguments[2]:void 0;G.debug("connect()");var p=a,_=Fe.cloneObject(t.eventHandlers),d=Fe.cloneArray(t.extraHeaders),g=Fe.cloneObject(t.mediaConstraints,{audio:!0,video:!0}),v=t.mediaStream||null,E=Fe.cloneObject(t.pcConfig,{iceServers:[]}),S=t.rtcConstraints||null,C=t.rtcOfferConstraints||null;if(this._rtcOfferConstraints=C,this._rtcAnswerConstraints=t.rtcAnswerConstraints||null,this._data=t.data||this._data,a===void 0)throw new TypeError("Not enough arguments");if(this._status!==z.STATUS_NULL)throw new Fs.InvalidStateError(this._status);if(!window.RTCPeerConnection)throw new Fs.NotSupportedError("WebRTC not supported");if(a=this._ua.normalizeTarget(a),!a)throw new TypeError("Invalid target: ".concat(p));this._sessionTimers.enabled&&Fe.isDecimal(t.sessionTimersExpires)&&(t.sessionTimersExpires>=oe.MIN_SESSION_EXPIRES?this._sessionTimers.defaultExpires=t.sessionTimersExpires:this._sessionTimers.defaultExpires=oe.SESSION_EXPIRES);for(var I in _)Object.prototype.hasOwnProperty.call(_,I)&&this.on(I,_[I]);this._from_tag=Fe.newTag();var w=t.anonymous||!1,F={from_tag:this._from_tag};this._contact=this._ua.contact.toString({anonymous:w,outbound:!0}),w?(F.from_display_name="Anonymous",F.from_uri=new Sc("sip","anonymous","anonymous.invalid"),d.push("P-Preferred-Identity: ".concat(this._ua.configuration.uri.toString())),d.push("Privacy: id")):t.fromUserName&&(F.from_uri=new Sc("sip",t.fromUserName,this._ua.configuration.uri.host),d.push("P-Preferred-Identity: ".concat(this._ua.configuration.uri.toString()))),t.fromDisplayName&&(F.from_display_name=t.fromDisplayName),d.push("Contact: ".concat(this._contact)),d.push("Content-Type: application/sdp"),this._sessionTimers.enabled&&d.push("Session-Expires: ".concat(this._sessionTimers.defaultExpires).concat(this._ua.configuration.session_timers_force_refresher?";refresher=uac":"")),this._request=new id.InitialOutgoingInviteRequest(a,this._ua,F,d),this._id=this._request.call_id+this._from_tag,this._createRTCConnection(E,S),this._direction="outgoing",this._local_identity=this._request.from,this._remote_identity=this._request.to,s&&s(this),this._newRTCSession("local",this._request),this._sendInitialRequest(g,C,v)}},{key:"init_incoming",value:function(a,t){var s=this;G.debug("init_incoming()");var p,_=a.hasHeader("Content-Type")?a.getHeader("Content-Type").toLowerCase():void 0;if(a.body&&_!=="application/sdp"){a.reply(415);return}if(this._status=z.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=Fe.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=z.STATUS_WAITING_FOR_ANSWER,this._timers.userNoAnswerTimer=setTimeout(function(){a.reply(408),s._failed("local",null,oe.causes.NO_ANSWER)},this._ua.configuration.no_answer_timeout),p&&(this._timers.expiresTimer=setTimeout(function(){s._status===z.STATUS_WAITING_FOR_ANSWER&&(a.reply(487),s._failed("system",null,oe.causes.EXPIRES))},p)),this._direction="incoming",this._local_identity=a.to,this._remote_identity=a.from,t&&t(this),this._newRTCSession("remote",a),this._status!==z.STATUS_TERMINATED&&(a.reply(180,null,["Contact: ".concat(this._contact)]),this._progress("local",null))}},{key:"answer",value:function(){var a=this,t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};G.debug("answer()");var s=this._request,p=Fe.cloneArray(t.extraHeaders),_=Fe.cloneObject(t.mediaConstraints),d=t.mediaStream||null,g=Fe.cloneObject(t.pcConfig,{iceServers:[]}),v=t.rtcConstraints||null,E=t.rtcAnswerConstraints||null,S=Fe.cloneObject(t.rtcOfferConstraints),C,I=!1,w=!1,F=!1,L=!1;if(this._rtcAnswerConstraints=E,this._rtcOfferConstraints=t.rtcOfferConstraints||null,this._data=t.data||this._data,this._direction!=="incoming")throw new Fs.NotSupportedError('"answer" not supported for outgoing RTCSession');if(this._status!==z.STATUS_WAITING_FOR_ANSWER)throw new Fs.InvalidStateError(this._status);if(this._sessionTimers.enabled&&Fe.isDecimal(t.sessionTimersExpires)&&(t.sessionTimersExpires>=oe.MIN_SESSION_EXPIRES?this._sessionTimers.defaultExpires=t.sessionTimersExpires:this._sessionTimers.defaultExpires=oe.SESSION_EXPIRES),this._status=z.STATUS_ANSWERED,!this._createDialog(s,"UAS")){s.reply(500,"Error creating dialog");return}clearTimeout(this._timers.userNoAnswerTimer),p.unshift("Contact: ".concat(this._contact));var ie=s.parseSDP();Array.isArray(ie.media)||(ie.media=[ie.media]);var N=rs(ie.media),H;try{for(N.s();!(H=N.n()).done;){var ve=H.value;ve.type==="audio"&&(I=!0,(!ve.direction||ve.direction==="sendrecv")&&(F=!0)),ve.type==="video"&&(w=!0,(!ve.direction||ve.direction==="sendrecv")&&(L=!0))}}catch($){N.e($)}finally{N.f()}if(d&&_.audio===!1){C=d.getAudioTracks();var me=rs(C),M;try{for(me.s();!(M=me.n()).done;){var D=M.value;d.removeTrack(D)}}catch($){me.e($)}finally{me.f()}}if(d&&_.video===!1){C=d.getVideoTracks();var V=rs(C),j;try{for(V.s();!(j=V.n()).done;){var Y=j.value;d.removeTrack(Y)}}catch($){V.e($)}finally{V.f()}}!d&&_.audio===void 0&&(_.audio=F),!d&&_.video===void 0&&(_.video=L),!d&&!I&&!S.offerToReceiveAudio&&(_.audio=!1),!d&&!w&&!S.offerToReceiveVideo&&(_.video=!1),this._createRTCConnection(g,v),Promise.resolve().then(function(){if(d)return d;if(_.audio||_.video)return a._localMediaStreamLocallyGenerated=!0,navigator.mediaDevices.getUserMedia(_).catch(function($){throw a._status===z.STATUS_TERMINATED?new Error("terminated"):(s.reply(480),a._failed("local",null,oe.causes.USER_DENIED_MEDIA_ACCESS),G.warn('emit "getusermediafailed" [error:%o]',$),a.emit("getusermediafailed",$),new Error("getUserMedia() failed"))})}).then(function($){if(a._status===z.STATUS_TERMINATED)throw new Error("terminated");a._localMediaStream=$,$&&$.getTracks().forEach(function(X){a._connection.addTrack(X,$)})}).then(function(){if(!a._late_sdp){var $={originator:"remote",type:"offer",sdp:s.body};G.debug('emit "sdp"'),a.emit("sdp",$);var X=new RTCSessionDescription({type:"offer",sdp:$.sdp});return a._connectionPromiseQueue=a._connectionPromiseQueue.then(function(){return a._connection.setRemoteDescription(X)}).catch(function(U){throw s.reply(488),a._failed("system",null,oe.causes.WEBRTC_ERROR),G.warn('emit "peerconnection:setremotedescriptionfailed" [error:%o]',U),a.emit("peerconnection:setremotedescriptionfailed",U),new Error("peerconnection.setRemoteDescription() failed")}),a._connectionPromiseQueue}}).then(function(){if(a._status===z.STATUS_TERMINATED)throw new Error("terminated");return a._connecting(s),a._late_sdp?a._createLocalDescription("offer",a._rtcOfferConstraints).catch(function(){throw s.reply(500),new Error("_createLocalDescription() failed")}):a._createLocalDescription("answer",E).catch(function(){throw s.reply(500),new Error("_createLocalDescription() failed")})}).then(function($){if(a._status===z.STATUS_TERMINATED)throw new Error("terminated");a._handleSessionTimersInIncomingRequest(s,p),s.reply(200,null,p,$,function(){a._status=z.STATUS_WAITING_FOR_ACK,a._setInvite2xxTimer(s,$),a._setACKTimer(),a._accepted("local")},function(){a._failed("system",null,oe.causes.CONNECTION_ERROR)})}).catch(function($){a._status!==z.STATUS_TERMINATED&&G.warn($)})}},{key:"terminate",value:function(){var a=this,t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};G.debug("terminate()");var s=t.cause||oe.causes.BYE,p=Fe.cloneArray(t.extraHeaders),_=t.body,d,g=t.status_code,v=t.reason_phrase;if(this._status===z.STATUS_TERMINATED)throw new Fs.InvalidStateError(this._status);switch(this._status){case z.STATUS_NULL:case z.STATUS_INVITE_SENT:case z.STATUS_1XX_RECEIVED:if(G.debug("canceling session"),g&&(g<200||g>=700))throw new TypeError("Invalid status_code: ".concat(g));g&&(v=v||oe.REASON_PHRASE[g]||"",d="SIP ;cause=".concat(g,' ;text="').concat(v,'"')),this._status===z.STATUS_NULL||this._status===z.STATUS_INVITE_SENT?(this._is_canceled=!0,this._cancel_reason=d):this._status===z.STATUS_1XX_RECEIVED&&this._request.cancel(d),this._status=z.STATUS_CANCELED,this._failed("local",null,oe.causes.CANCELED);break;case z.STATUS_WAITING_FOR_ANSWER:case z.STATUS_ANSWERED:if(G.debug("rejecting session"),g=g||480,g<300||g>=700)throw new TypeError("Invalid status_code: ".concat(g));this._request.reply(g,v,p,_),this._failed("local",null,oe.causes.REJECTED);break;case z.STATUS_WAITING_FOR_ACK:case z.STATUS_CONFIRMED:if(G.debug("terminating session"),v=t.reason_phrase||oe.REASON_PHRASE[g]||"",g&&(g<200||g>=700))throw new TypeError("Invalid status_code: ".concat(g));if(g&&p.push("Reason: SIP ;cause=".concat(g,'; text="').concat(v,'"')),this._status===z.STATUS_WAITING_FOR_ACK&&this._direction==="incoming"&&this._request.server_transaction.state!==Ec.C.STATUS_TERMINATED){var E=this._dialog;this.receiveRequest=function(S){var C=S.method;C===oe.ACK&&(a.sendRequest(oe.BYE,{extraHeaders:p,body:_}),E.terminate())},this._request.server_transaction.on("stateChanged",function(){a._request.server_transaction.state===Ec.C.STATUS_TERMINATED&&(a.sendRequest(oe.BYE,{extraHeaders:p,body:_}),E.terminate())}),this._ended("local",null,s),this._dialog=E,this._ua.newDialog(E)}else this.sendRequest(oe.BYE,{extraHeaders:p,body:_}),this._ended("local",null,s)}}},{key:"sendDTMF",value:function(a){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};G.debug("sendDTMF() | tones: %s",a);var s=0,p=t.duration||null,_=t.interToneGap||null,d=t.transportType||oe.DTMF_TRANSPORT.INFO;if(a===void 0)throw new TypeError("Not enough arguments");if(this._status!==z.STATUS_CONFIRMED&&this._status!==z.STATUS_WAITING_FOR_ACK&&this._status!==z.STATUS_1XX_RECEIVED)throw new Fs.InvalidStateError(this._status);if(d!==oe.DTMF_TRANSPORT.INFO&&d!==oe.DTMF_TRANSPORT.RFC2833)throw new TypeError("invalid transportType: ".concat(d));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&&!Fe.isDecimal(p))throw new TypeError("Invalid tone duration: ".concat(p));if(p?p<It.C.MIN_DURATION?(G.debug('"duration" value is lower than the minimum allowed, setting it to '.concat(It.C.MIN_DURATION," milliseconds")),p=It.C.MIN_DURATION):p>It.C.MAX_DURATION?(G.debug('"duration" value is greater than the maximum allowed, setting it to '.concat(It.C.MAX_DURATION," milliseconds")),p=It.C.MAX_DURATION):p=Math.abs(p):p=It.C.DEFAULT_DURATION,t.duration=p,_&&!Fe.isDecimal(_))throw new TypeError("Invalid interToneGap: ".concat(_));if(_?_<It.C.MIN_INTER_TONE_GAP?(G.debug('"interToneGap" value is lower than the minimum allowed, setting it to '.concat(It.C.MIN_INTER_TONE_GAP," milliseconds")),_=It.C.MIN_INTER_TONE_GAP):_=Math.abs(_):_=It.C.DEFAULT_INTER_TONE_GAP,d===oe.DTMF_TRANSPORT.RFC2833){var g=this._getDTMFRTPSender();g&&(a=g.toneBuffer+a,g.insertDTMF(a,p,_));return}if(this._tones){this._tones+=a;return}this._tones=a,v.call(this);function v(){var E=this,S;if(this._status===z.STATUS_TERMINATED||!this._tones||s>=this._tones.length){this._tones=null;return}var C=this._tones[s];if(s+=1,C===",")S=2e3;else{var I=new It(this);t.eventHandlers={onFailed:function(){E._tones=null}},I.send(C,t),S=p+_}setTimeout(v.bind(this),S)}}},{key:"sendInfo",value:function(a,t){var s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};if(G.debug("sendInfo()"),this._status!==z.STATUS_CONFIRMED&&this._status!==z.STATUS_WAITING_FOR_ACK&&this._status!==z.STATUS_1XX_RECEIVED)throw new Fs.InvalidStateError(this._status);var p=new yc(this);p.send(a,t,s)}},{key:"mute",value:function(){var a=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{audio:!0,video:!1};G.debug("mute()");var t=!1,s=!1;this._audioMuted===!1&&a.audio&&(t=!0,this._audioMuted=!0,this._toggleMuteAudio(!0)),this._videoMuted===!1&&a.video&&(s=!0,this._videoMuted=!0,this._toggleMuteVideo(!0)),(t===!0||s===!0)&&this._onmute({audio:t,video:s})}},{key:"unmute",value:function(){var a=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{audio:!0,video:!0};G.debug("unmute()");var t=!1,s=!1;this._audioMuted===!0&&a.audio&&(t=!0,this._audioMuted=!1,this._localHold===!1&&this._toggleMuteAudio(!1)),this._videoMuted===!0&&a.video&&(s=!0,this._videoMuted=!1,this._localHold===!1&&this._toggleMuteVideo(!1)),(t===!0||s===!0)&&this._onunmute({audio:t,video:s})}},{key:"hold",value:function(){var a=this,t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},s=arguments.length>1?arguments[1]:void 0;if(G.debug("hold()"),this._status!==z.STATUS_WAITING_FOR_ACK&&this._status!==z.STATUS_CONFIRMED||this._localHold===!0||!this._isReadyToReOffer())return!1;this._localHold=!0,this._onhold("local");var p={succeeded:function(){s&&s()},failed:function(){a.terminate({cause:oe.causes.WEBRTC_ERROR,status_code:500,reason_phrase:"Hold Failed"})}};return t.useUpdate?this._sendUpdate({sdpOffer:!0,eventHandlers:p,extraHeaders:t.extraHeaders}):this._sendReinvite({eventHandlers:p,extraHeaders:t.extraHeaders}),!0}},{key:"unhold",value:function(){var a=this,t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},s=arguments.length>1?arguments[1]:void 0;if(G.debug("unhold()"),this._status!==z.STATUS_WAITING_FOR_ACK&&this._status!==z.STATUS_CONFIRMED||this._localHold===!1||!this._isReadyToReOffer())return!1;this._localHold=!1,this._onunhold("local");var p={succeeded:function(){s&&s()},failed:function(){a.terminate({cause:oe.causes.WEBRTC_ERROR,status_code:500,reason_phrase:"Unhold Failed"})}};return t.useUpdate?this._sendUpdate({sdpOffer:!0,eventHandlers:p,extraHeaders:t.extraHeaders}):this._sendReinvite({eventHandlers:p,extraHeaders:t.extraHeaders}),!0}},{key:"renegotiate",value:function(){var a=this,t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},s=arguments.length>1?arguments[1]:void 0;G.debug("renegotiate()");var p=t.rtcOfferConstraints||null;if(this._status!==z.STATUS_WAITING_FOR_ACK&&this._status!==z.STATUS_CONFIRMED||!this._isReadyToReOffer())return!1;var _={succeeded:function(){s&&s()},failed:function(){a.terminate({cause:oe.causes.WEBRTC_ERROR,status_code:500,reason_phrase:"Media Renegotiation Failed"})}};return this._setLocalMediaStatus(),t.useUpdate?this._sendUpdate({sdpOffer:!0,eventHandlers:_,rtcOfferConstraints:p,extraHeaders:t.extraHeaders}):this._sendReinvite({eventHandlers:_,rtcOfferConstraints:p,extraHeaders:t.extraHeaders}),!0}},{key:"refer",value:function(a,t){var s=this;G.debug("refer()");var p=a;if(this._status!==z.STATUS_WAITING_FOR_ACK&&this._status!==z.STATUS_CONFIRMED)return!1;if(a=this._ua.normalizeTarget(a),!a)throw new TypeError("Invalid target: ".concat(p));var _=new ad(this);_.sendRefer(a,t);var d=_.id;return this._referSubscribers[d]=_,_.on("requestFailed",function(){delete s._referSubscribers[d]}),_.on("accepted",function(){delete s._referSubscribers[d]}),_.on("failed",function(){delete s._referSubscribers[d]}),_}},{key:"sendRequest",value:function(a,t){return G.debug("sendRequest()"),this._dialog.sendRequest(a,t)}},{key:"receiveRequest",value:function(a){var t=this;if(G.debug("receiveRequest()"),a.method===oe.CANCEL)(this._status===z.STATUS_WAITING_FOR_ANSWER||this._status===z.STATUS_ANSWERED)&&(this._status=z.STATUS_CANCELED,this._request.reply(487),this._failed("remote",a,oe.causes.CANCELED));else switch(a.method){case oe.ACK:if(this._status!==z.STATUS_WAITING_FOR_ACK)return;if(this._status=z.STATUS_CONFIRMED,clearTimeout(this._timers.ackTimer),clearTimeout(this._timers.invite2xxTimer),this._late_sdp){if(!a.body){this.terminate({cause:oe.causes.MISSING_SDP,status_code:400});break}var s={originator:"remote",type:"answer",sdp:a.body};G.debug('emit "sdp"'),this.emit("sdp",s);var p=new RTCSessionDescription({type:"answer",sdp:s.sdp});this._connectionPromiseQueue=this._connectionPromiseQueue.then(function(){return t._connection.setRemoteDescription(p)}).then(function(){t._is_confirmed||t._confirmed("remote",a)}).catch(function(d){t.terminate({cause:oe.causes.BAD_MEDIA_DESCRIPTION,status_code:488}),G.warn('emit "peerconnection:setremotedescriptionfailed" [error:%o]',d),t.emit("peerconnection:setremotedescriptionfailed",d)})}else this._is_confirmed||this._confirmed("remote",a);break;case oe.BYE:this._status===z.STATUS_CONFIRMED||this._status===z.STATUS_WAITING_FOR_ACK?(a.reply(200),this._ended("remote",a,oe.causes.BYE)):this._status===z.STATUS_INVITE_RECEIVED||this._status===z.STATUS_WAITING_FOR_ANSWER?(a.reply(200),this._request.reply(487,"BYE Received"),this._ended("remote",a,oe.causes.BYE)):a.reply(403,"Wrong Status");break;case oe.INVITE:this._status===z.STATUS_CONFIRMED?a.hasHeader("replaces")?this._receiveReplaces(a):this._receiveReinvite(a):a.reply(403,"Wrong Status");break;case oe.INFO:if(this._status===z.STATUS_1XX_RECEIVED||this._status===z.STATUS_WAITING_FOR_ANSWER||this._status===z.STATUS_ANSWERED||this._status===z.STATUS_WAITING_FOR_ACK||this._status===z.STATUS_CONFIRMED){var _=a.hasHeader("Content-Type")?a.getHeader("Content-Type").toLowerCase():void 0;_&&_.match(/^application\/dtmf-relay/i)?new It(this).init_incoming(a):_!==void 0?new yc(this).init_incoming(a):a.reply(415)}else a.reply(403,"Wrong Status");break;case oe.UPDATE:this._status===z.STATUS_CONFIRMED?this._receiveUpdate(a):a.reply(403,"Wrong Status");break;case oe.REFER:this._status===z.STATUS_CONFIRMED?this._receiveRefer(a):a.reply(403,"Wrong Status");break;case oe.NOTIFY:this._status===z.STATUS_CONFIRMED?this._receiveNotify(a):a.reply(403,"Wrong Status");break;default:a.reply(501)}}},{key:"onTransportError",value:function(){G.warn("onTransportError()"),this._status!==z.STATUS_TERMINATED&&this.terminate({status_code:500,reason_phrase:oe.causes.CONNECTION_ERROR,cause:oe.causes.CONNECTION_ERROR})}},{key:"onRequestTimeout",value:function(){G.warn("onRequestTimeout()"),this._status!==z.STATUS_TERMINATED&&this.terminate({status_code:408,reason_phrase:oe.causes.REQUEST_TIMEOUT,cause:oe.causes.REQUEST_TIMEOUT})}},{key:"onDialogError",value:function(){G.warn("onDialogError()"),this._status!==z.STATUS_TERMINATED&&this.terminate({status_code:500,reason_phrase:oe.causes.DIALOG_ERROR,cause:oe.causes.DIALOG_ERROR})}},{key:"newDTMF",value:function(a){G.debug("newDTMF()"),this.emit("newDTMF",a)}},{key:"newInfo",value:function(a){G.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?(G.debug("_isReadyToReOffer() | there is another INVITE/UPDATE transaction in progress"),!1):!0:(G.debug("_isReadyToReOffer() | session not established yet"),!1):(G.debug("_isReadyToReOffer() | internal WebRTC status not ready"),!1)}},{key:"_close",value:function(){if(G.debug("close()"),this._localMediaStream&&this._localMediaStreamLocallyGenerated&&(G.debug("close() | closing local MediaStream"),Fe.closeMediaStream(this._localMediaStream)),this._status!==z.STATUS_TERMINATED){if(this._status=z.STATUS_TERMINATED,this._connection)try{this._connection.close()}catch(p){G.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 t in this._earlyDialogs)Object.prototype.hasOwnProperty.call(this._earlyDialogs,t)&&(this._earlyDialogs[t].terminate(),delete this._earlyDialogs[t]);for(var s in this._referSubscribers)Object.prototype.hasOwnProperty.call(this._referSubscribers,s)&&delete this._referSubscribers[s];this._ua.destroyRTCSession(this)}}},{key:"_setInvite2xxTimer",value:function(a,t){var s=Sr.T1;function p(){this._status===z.STATUS_WAITING_FOR_ACK&&(a.reply(200,null,["Contact: ".concat(this._contact)],t),s<Sr.T2&&(s=s*2,s>Sr.T2&&(s=Sr.T2)),this._timers.invite2xxTimer=setTimeout(p.bind(this),s))}this._timers.invite2xxTimer=setTimeout(p.bind(this),s)}},{key:"_setACKTimer",value:function(){var a=this;this._timers.ackTimer=setTimeout(function(){a._status===z.STATUS_WAITING_FOR_ACK&&(G.debug("no ACK received, terminating the session"),clearTimeout(a._timers.invite2xxTimer),a.sendRequest(oe.BYE),a._ended("remote",null,oe.causes.NO_ACK))},Sr.TIMER_H)}},{key:"_createRTCConnection",value:function(a,t){var s=this;this._connection=new RTCPeerConnection(a,t),this._connection.addEventListener("iceconnectionstatechange",function(){var p=s._connection.iceConnectionState;p==="failed"&&s.terminate({cause:oe.causes.RTP_TIMEOUT,status_code:408,reason_phrase:oe.causes.RTP_TIMEOUT})}),G.debug('emit "peerconnection"'),this.emit("peerconnection",{peerconnection:this._connection})}},{key:"_createLocalDescription",value:function(a,t){var s=this;if(G.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(t).catch(function(_){return G.warn('emit "peerconnection:createofferfailed" [error:%o]',_),s.emit("peerconnection:createofferfailed",_),Promise.reject(_)}):p.createAnswer(t).catch(function(_){return G.warn('emit "peerconnection:createanswerfailed" [error:%o]',_),s.emit("peerconnection:createanswerfailed",_),Promise.reject(_)})}).then(function(_){return p.setLocalDescription(_).catch(function(d){return s._rtcReady=!0,G.warn('emit "peerconnection:setlocaldescriptionfailed" [error:%o]',d),s.emit("peerconnection:setlocaldescriptionfailed",d),Promise.reject(d)})}).then(function(){var _=t&&t.iceRestart;if(p.iceGatheringState==="complete"&&!_||p.iceGatheringState==="gathering"&&s._iceReady){s._rtcReady=!0;var d={originator:"local",type:a,sdp:p.localDescription.sdp};return G.debug('emit "sdp"'),s.emit("sdp",d),Promise.resolve(d.sdp)}return new Promise(function(g){var v=!1,E,S;s._iceReady=!1;var C=function(){p.removeEventListener("icecandidate",E),p.removeEventListener("icegatheringstatechange",S),v=!0,s._rtcReady=!0,s._iceReady=!0;var w={originator:"local",type:a,sdp:p.localDescription.sdp};G.debug('emit "sdp"'),s.emit("sdp",w),g(w.sdp)};p.addEventListener("icecandidate",E=function(w){var F=w.candidate;F?s.emit("icecandidate",{candidate:F,ready:C}):v||C()}),p.addEventListener("icegatheringstatechange",S=function(){p.iceGatheringState==="complete"&&!v&&C()})})})}},{key:"_createDialog",value:function(a,t,s){var p=t==="UAS"?a.to_tag:a.from_tag,_=t==="UAS"?a.from_tag:a.to_tag,d=a.call_id+p+_,g=this._earlyDialogs[d];if(s)return g?!0:(g=new Rl(this,a,t,Rl.C.STATUS_EARLY),g.error?(G.debug(g.error),this._failed("remote",a,oe.causes.INTERNAL_ERROR),!1):(this._earlyDialogs[d]=g,!0));if(this._from_tag=a.from_tag,this._to_tag=a.to_tag,g)return g.update(a,t),this._dialog=g,delete this._earlyDialogs[d],!0;var v=new Rl(this,a,t);return v.error?(G.debug(v.error),this._failed("remote",a,oe.causes.INTERNAL_ERROR),!1):(this._dialog=v,!0)}},{key:"_receiveReinvite",value:function(a){var t=this;G.debug("receiveReinvite()");var s=a.hasHeader("Content-Type")?a.getHeader("Content-Type").toLowerCase():void 0,p={request:a,callback:void 0,reject:d.bind(this)},_=!1;function d(){var v=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};_=!0;var E=v.status_code||403,S=v.reason_phrase||"",C=Fe.cloneArray(v.extraHeaders);if(this._status!==z.STATUS_CONFIRMED)return!1;if(E<300||E>=700)throw new TypeError("Invalid status_code: ".concat(E));a.reply(E,S,C)}if(this.emit("reinvite",p),_)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 t._createLocalDescription("offer",t._rtcOfferConstraints)}).then(function(v){g.call(t,v)}).catch(function(){a.reply(500)});return}if(s!=="application/sdp"){G.debug("invalid Content-Type"),a.reply(415);return}this._processInDialogSdpOffer(a).then(function(v){t._status!==z.STATUS_TERMINATED&&g.call(t,v)}).catch(function(v){G.warn(v)});function g(v){var E=this,S=["Contact: ".concat(this._contact)];this._handleSessionTimersInIncomingRequest(a,S),this._late_sdp&&(v=this._mangleOffer(v)),a.reply(200,null,S,v,function(){E._status=z.STATUS_WAITING_FOR_ACK,E._setInvite2xxTimer(a,v),E._setACKTimer()}),typeof p.callback=="function"&&p.callback()}}},{key:"_receiveUpdate",value:function(a){var t=this;G.debug("receiveUpdate()");var s=a.hasHeader("Content-Type")?a.getHeader("Content-Type").toLowerCase():void 0,p={request:a,callback:void 0,reject:d.bind(this)},_=!1;function d(){var v=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};_=!0;var E=v.status_code||403,S=v.reason_phrase||"",C=Fe.cloneArray(v.extraHeaders);if(this._status!==z.STATUS_CONFIRMED)return!1;if(E<300||E>=700)throw new TypeError("Invalid status_code: ".concat(E));a.reply(E,S,C)}if(this.emit("update",p),_)return;if(!a.body){g.call(this,null);return}if(s!=="application/sdp"){G.debug("invalid Content-Type"),a.reply(415);return}this._processInDialogSdpOffer(a).then(function(v){t._status!==z.STATUS_TERMINATED&&g.call(t,v)}).catch(function(v){G.warn(v)});function g(v){var E=["Contact: ".concat(this._contact)];this._handleSessionTimersInIncomingRequest(a,E),a.reply(200,null,E,v),typeof p.callback=="function"&&p.callback()}}},{key:"_processInDialogSdpOffer",value:function(a){var t=this;G.debug("_processInDialogSdpOffer()");var s=a.parseSDP(),p=!1,_=rs(s.media),d;try{for(_.s();!(d=_.n()).done;){var g=d.value;if(Il.indexOf(g.type)!==-1){var v=g.direction||s.direction||"sendrecv";if(v==="sendonly"||v==="inactive")p=!0;else{p=!1;break}}}}catch(C){_.e(C)}finally{_.f()}var E={originator:"remote",type:"offer",sdp:a.body};G.debug('emit "sdp"'),this.emit("sdp",E);var S=new RTCSessionDescription({type:"offer",sdp:E.sdp});return this._connectionPromiseQueue=this._connectionPromiseQueue.then(function(){if(t._status===z.STATUS_TERMINATED)throw new Error("terminated");return t._connection.setRemoteDescription(S).catch(function(C){throw a.reply(488),G.warn('emit "peerconnection:setremotedescriptionfailed" [error:%o]',C),t.emit("peerconnection:setremotedescriptionfailed",C),C})}).then(function(){if(t._status===z.STATUS_TERMINATED)throw new Error("terminated");t._remoteHold===!0&&p===!1?(t._remoteHold=!1,t._onunhold("remote")):t._remoteHold===!1&&p===!0&&(t._remoteHold=!0,t._onhold("remote"))}).then(function(){if(t._status===z.STATUS_TERMINATED)throw new Error("terminated");return t._createLocalDescription("answer",t._rtcAnswerConstraints).catch(function(C){throw a.reply(500),G.warn('emit "peerconnection:createtelocaldescriptionfailed" [error:%o]',C),C})}).catch(function(C){G.warn("_processInDialogSdpOffer() failed [error: %o]",C)}),this._connectionPromiseQueue}},{key:"_receiveRefer",value:function(a){var t=this;if(G.debug("receiveRefer()"),!a.refer_to){G.debug("no Refer-To header field present in REFER"),a.reply(400);return}if(a.refer_to.uri.scheme!==oe.SIP){G.debug("Refer-To header field points to a non-SIP URI scheme"),a.reply(416);return}a.reply(202);var s=new od(this,a.cseq);G.debug('emit "refer"'),this.emit("refer",{request:a,accept:function(g,v){p.call(t,g,v)},reject:function(){_.call(t)}});function p(d){var g=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(d=typeof d=="function"?d:null,this._status!==z.STATUS_WAITING_FOR_ACK&&this._status!==z.STATUS_CONFIRMED)return!1;var v=new n(this._ua);if(v.on("progress",function(S){var C=S.response;s.notify(C.status_code,C.reason_phrase)}),v.on("accepted",function(S){var C=S.response;s.notify(C.status_code,C.reason_phrase)}),v.on("_failed",function(S){var C=S.message,I=S.cause;C?s.notify(C.status_code,C.reason_phrase):s.notify(487,I)}),a.refer_to.uri.hasHeader("replaces")){var E=decodeURIComponent(a.refer_to.uri.getHeader("replaces"));g.extraHeaders=Fe.cloneArray(g.extraHeaders),g.extraHeaders.push("Replaces: ".concat(E))}v.connect(a.refer_to.uri.toAor(),g,d)}function _(){s.notify(603)}}},{key:"_receiveNotify",value:function(a){switch(G.debug("receiveNotify()"),a.event||a.reply(400),a.event.event){case"refer":{var t,s;if(a.event.params&&a.event.params.id)t=a.event.params.id,s=this._referSubscribers[t];else if(Object.keys(this._referSubscribers).length===1)s=this._referSubscribers[Object.keys(this._referSubscribers)[0]];else{a.reply(400,"Missing event id parameter");return}if(!s){a.reply(481,"Subscription does not exist");return}s.receiveNotify(a),a.reply(200);break}default:a.reply(489)}}},{key:"_receiveReplaces",value:function(a){var t=this;G.debug("receiveReplaces()");function s(_){var d=this;if(this._status!==z.STATUS_WAITING_FOR_ACK&&this._status!==z.STATUS_CONFIRMED)return!1;var g=new n(this._ua);g.on("confirmed",function(){d.terminate()}),g.init_incoming(a,_)}function p(){G.debug("Replaced INVITE rejected by the user"),a.reply(486)}this.emit("replaces",{request:a,accept:function(d){s.call(t,d)},reject:function(){p.call(t)}})}},{key:"_sendInitialRequest",value:function(a,t,s){var p=this,_=new ld(this._ua,this._request,{onRequestTimeout:function(){p.onRequestTimeout()},onTransportError:function(){p.onTransportError()},onAuthenticated:function(g){p._request=g},onReceiveResponse:function(g){p._receiveInviteResponse(g)}});Promise.resolve().then(function(){if(s)return s;if(a.audio||a.video)return p._localMediaStreamLocallyGenerated=!0,navigator.mediaDevices.getUserMedia(a).catch(function(d){throw p._status===z.STATUS_TERMINATED?new Error("terminated"):(p._failed("local",null,oe.causes.USER_DENIED_MEDIA_ACCESS),G.warn('emit "getusermediafailed" [error:%o]',d),p.emit("getusermediafailed",d),d)})}).then(function(d){if(p._status===z.STATUS_TERMINATED)throw new Error("terminated");return p._localMediaStream=d,d&&d.getTracks().forEach(function(g){p._connection.addTrack(g,d)}),p._connecting(p._request),p._createLocalDescription("offer",t).catch(function(g){throw p._failed("local",null,oe.causes.WEBRTC_ERROR),g})}).then(function(d){if(p._is_canceled||p._status===z.STATUS_TERMINATED)throw new Error("terminated");p._request.body=d,p._status=z.STATUS_INVITE_SENT,G.debug('emit "sending" [request:%o]',p._request),p.emit("sending",{request:p._request}),_.send()}).catch(function(d){p._status!==z.STATUS_TERMINATED&&G.warn(d)})}},{key:"_getDTMFRTPSender",value:function(){var a=this._connection.getSenders().find(function(t){return t.track&&t.track.kind==="audio"});if(!(a&&a.dtmf)){G.warn("sendDTMF() | no local audio track to send DTMF with");return}return a.dtmf}},{key:"_receiveInviteResponse",value:function(a){var t=this;if(G.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(oe.ACK);return}else{var s=new Rl(this,a,"UAC");if(s.error!==void 0){G.debug(s.error);return}this.sendRequest(oe.ACK),this.sendRequest(oe.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!==z.STATUS_INVITE_SENT&&this._status!==z.STATUS_1XX_RECEIVED))switch(!0){case/^100$/.test(a.status_code):this._status=z.STATUS_1XX_RECEIVED;break;case/^1[0-9]{2}$/.test(a.status_code):{if(!a.to_tag){G.debug("1xx response received without to tag");break}if(a.hasHeader("contact")&&!this._createDialog(a,"UAC",!0))break;if(this._status=z.STATUS_1XX_RECEIVED,!a.body){this._progress("remote",a);break}var p={originator:"remote",type:"answer",sdp:a.body};G.debug('emit "sdp"'),this.emit("sdp",p);var _=new RTCSessionDescription({type:"answer",sdp:p.sdp});this._connectionPromiseQueue=this._connectionPromiseQueue.then(function(){return t._connection.setRemoteDescription(_)}).then(function(){return t._progress("remote",a)}).catch(function(E){G.warn('emit "peerconnection:setremotedescriptionfailed" [error:%o]',E),t.emit("peerconnection:setremotedescriptionfailed",E)});break}case/^2[0-9]{2}$/.test(a.status_code):{if(this._status=z.STATUS_CONFIRMED,!a.body){this._acceptAndTerminate(a,400,oe.causes.MISSING_SDP),this._failed("remote",a,oe.causes.BAD_MEDIA_DESCRIPTION);break}if(!this._createDialog(a,"UAC"))break;var d={originator:"remote",type:"answer",sdp:a.body};G.debug('emit "sdp"'),this.emit("sdp",d);var g=new RTCSessionDescription({type:"answer",sdp:d.sdp});this._connectionPromiseQueue=this._connectionPromiseQueue.then(function(){if(t._connection.signalingState==="stable")return t._connection.createOffer(t._rtcOfferConstraints).then(function(E){return t._connection.setLocalDescription(E)}).catch(function(E){t._acceptAndTerminate(a,500,E.toString()),t._failed("local",a,oe.causes.WEBRTC_ERROR)})}).then(function(){t._connection.setRemoteDescription(g).then(function(){t._handleSessionTimersInIncomingResponse(a),t._accepted("remote",a),t.sendRequest(oe.ACK),t._confirmed("local",null)}).catch(function(E){t._acceptAndTerminate(a,488,"Not Acceptable Here"),t._failed("remote",a,oe.causes.BAD_MEDIA_DESCRIPTION),G.warn('emit "peerconnection:setremotedescriptionfailed" [error:%o]',E),t.emit("peerconnection:setremotedescriptionfailed",E)})});break}default:{var v=Fe.sipErrorCause(a.status_code);this._failed("remote",a,v)}}}},{key:"_sendReinvite",value:function(){var a=this,t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};G.debug("sendReinvite()");var s=Fe.cloneArray(t.extraHeaders),p=Fe.cloneObject(t.eventHandlers),_=t.rtcOfferConstraints||this._rtcOfferConstraints||null,d=!1;s.push("Contact: ".concat(this._contact)),s.push("Content-Type: application/sdp"),this._sessionTimers.running&&s.push("Session-Expires: ".concat(this._sessionTimers.currentExpires,";refresher=").concat(this._sessionTimers.refresher?"uac":"uas")),this._connectionPromiseQueue=this._connectionPromiseQueue.then(function(){return a._createLocalDescription("offer",_)}).then(function(E){E=a._mangleOffer(E);var S={originator:"local",type:"offer",sdp:E};G.debug('emit "sdp"'),a.emit("sdp",S),a.sendRequest(oe.INVITE,{extraHeaders:s,body:E,eventHandlers:{onSuccessResponse:function(I){g.call(a,I),d=!0},onErrorResponse:function(I){v.call(a,I)},onTransportError:function(){a.onTransportError()},onRequestTimeout:function(){a.onRequestTimeout()},onDialogError:function(){a.onDialogError()}}})}).catch(function(){v()});function g(E){var S=this;if(this._status!==z.STATUS_TERMINATED&&(this.sendRequest(oe.ACK),!d)){if(this._handleSessionTimersInIncomingResponse(E),E.body){if(!E.hasHeader("Content-Type")||E.getHeader("Content-Type").toLowerCase()!=="application/sdp"){v.call(this);return}}else{v.call(this);return}var C={originator:"remote",type:"answer",sdp:E.body};G.debug('emit "sdp"'),this.emit("sdp",C);var I=new RTCSessionDescription({type:"answer",sdp:C.sdp});this._connectionPromiseQueue=this._connectionPromiseQueue.then(function(){return S._connection.setRemoteDescription(I)}).then(function(){p.succeeded&&p.succeeded(E)}).catch(function(w){v.call(S),G.warn('emit "peerconnection:setremotedescriptionfailed" [error:%o]',w),S.emit("peerconnection:setremotedescriptionfailed",w)})}}function v(E){p.failed&&p.failed(E)}}},{key:"_sendUpdate",value:function(){var a=this,t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};G.debug("sendUpdate()");var s=Fe.cloneArray(t.extraHeaders),p=Fe.cloneObject(t.eventHandlers),_=t.rtcOfferConstraints||this._rtcOfferConstraints||null,d=t.sdpOffer||!1,g=!1;s.push("Contact: ".concat(this._contact)),this._sessionTimers.running&&s.push("Session-Expires: ".concat(this._sessionTimers.currentExpires,";refresher=").concat(this._sessionTimers.refresher?"uac":"uas")),d?(s.push("Content-Type: application/sdp"),this._connectionPromiseQueue=this._connectionPromiseQueue.then(function(){return a._createLocalDescription("offer",_)}).then(function(S){S=a._mangleOffer(S);var C={originator:"local",type:"offer",sdp:S};G.debug('emit "sdp"'),a.emit("sdp",C),a.sendRequest(oe.UPDATE,{extraHeaders:s,body:S,eventHandlers:{onSuccessResponse:function(w){v.call(a,w),g=!0},onErrorResponse:function(w){E.call(a,w)},onTransportError:function(){a.onTransportError()},onRequestTimeout:function(){a.onRequestTimeout()},onDialogError:function(){a.onDialogError()}}})}).catch(function(){E.call(a)})):this.sendRequest(oe.UPDATE,{extraHeaders:s,eventHandlers:{onSuccessResponse:function(C){v.call(a,C)},onErrorResponse:function(C){E.call(a,C)},onTransportError:function(){a.onTransportError()},onRequestTimeout:function(){a.onRequestTimeout()},onDialogError:function(){a.onDialogError()}}});function v(S){var C=this;if(this._status!==z.STATUS_TERMINATED&&!g)if(this._handleSessionTimersInIncomingResponse(S),d){if(S.body){if(!S.hasHeader("Content-Type")||S.getHeader("Content-Type").toLowerCase()!=="application/sdp"){E.call(this);return}}else{E.call(this);return}var I={originator:"remote",type:"answer",sdp:S.body};G.debug('emit "sdp"'),this.emit("sdp",I);var w=new RTCSessionDescription({type:"answer",sdp:I.sdp});this._connectionPromiseQueue=this._connectionPromiseQueue.then(function(){return C._connection.setRemoteDescription(w)}).then(function(){p.succeeded&&p.succeeded(S)}).catch(function(F){E.call(C),G.warn('emit "peerconnection:setremotedescriptionfailed" [error:%o]',F),C.emit("peerconnection:setremotedescriptionfailed",F)})}else p.succeeded&&p.succeeded(S)}function E(S){p.failed&&p.failed(S)}}},{key:"_acceptAndTerminate",value:function(a,t,s){G.debug("acceptAndTerminate()");var p=[];t&&(s=s||oe.REASON_PHRASE[t]||"",p.push("Reason: SIP ;cause=".concat(t,'; text="').concat(s,'"'))),(this._dialog||this._createDialog(a,"UAC"))&&(this.sendRequest(oe.ACK),this.sendRequest(oe.BYE,{extraHeaders:p})),this._status=z.STATUS_TERMINATED}},{key:"_mangleOffer",value:function(a){if(!this._localHold&&!this._remoteHold)return a;if(a=Tc.parse(a),this._localHold&&!this._remoteHold){G.debug("mangleOffer() | me on hold, mangling offer");var t=rs(a.media),s;try{for(t.s();!(s=t.n()).done;){var p=s.value;Il.indexOf(p.type)!==-1&&(p.direction?p.direction==="sendrecv"?p.direction="sendonly":p.direction==="recvonly"&&(p.direction="inactive"):p.direction="sendonly")}}catch(C){t.e(C)}finally{t.f()}}else if(this._localHold&&this._remoteHold){G.debug("mangleOffer() | both on hold, mangling offer");var _=rs(a.media),d;try{for(_.s();!(d=_.n()).done;){var g=d.value;Il.indexOf(g.type)!==-1&&(g.direction="inactive")}}catch(C){_.e(C)}finally{_.f()}}else if(this._remoteHold){G.debug("mangleOffer() | remote on hold, mangling offer");var v=rs(a.media),E;try{for(v.s();!(E=v.n()).done;){var S=E.value;Il.indexOf(S.type)!==-1&&(S.direction?S.direction==="sendrecv"?S.direction="recvonly":S.direction==="recvonly"&&(S.direction="inactive"):S.direction="recvonly")}}catch(C){v.e(C)}finally{v.f()}}return Tc.write(a)}},{key:"_setLocalMediaStatus",value:function(){var a=!0,t=!0;(this._localHold||this._remoteHold)&&(a=!1,t=!1),this._audioMuted&&(a=!1),this._videoMuted&&(t=!1),this._toggleMuteAudio(!a),this._toggleMuteVideo(!t)}},{key:"_handleSessionTimersInIncomingRequest",value:function(a,t){if(this._sessionTimers.enabled){var s;a.session_expires&&a.session_expires>=oe.MIN_SESSION_EXPIRES?(this._sessionTimers.currentExpires=a.session_expires,s=a.session_expires_refresher||"uas"):(this._sessionTimers.currentExpires=this._sessionTimers.defaultExpires,s="uas"),t.push("Session-Expires: ".concat(this._sessionTimers.currentExpires,";refresher=").concat(s)),this._sessionTimers.refresher=s==="uas",this._runSessionTimer()}}},{key:"_handleSessionTimersInIncomingResponse",value:function(a){if(this._sessionTimers.enabled){var t;a.session_expires&&a.session_expires>=oe.MIN_SESSION_EXPIRES?(this._sessionTimers.currentExpires=a.session_expires,t=a.session_expires_refresher||"uac"):(this._sessionTimers.currentExpires=this._sessionTimers.defaultExpires,t="uac"),this._sessionTimers.refresher=t==="uac",this._runSessionTimer()}}},{key:"_runSessionTimer",value:function(){var a=this,t=this._sessionTimers.currentExpires;this._sessionTimers.running=!0,clearTimeout(this._sessionTimers.timer),this._sessionTimers.refresher?this._sessionTimers.timer=setTimeout(function(){a._status!==z.STATUS_TERMINATED&&a._isReadyToReOffer()&&(G.debug("runSessionTimer() | sending session refresh request"),a._sessionTimers.refreshMethod===oe.UPDATE?a._sendUpdate():a._sendReinvite())},t*500):this._sessionTimers.timer=setTimeout(function(){a._status!==z.STATUS_TERMINATED&&(G.warn("runSessionTimer() | timer expired, terminating the session"),a.terminate({cause:oe.causes.REQUEST_TIMEOUT,status_code:408,reason_phrase:"Session Timer Expired"}))},t*1100)}},{key:"_toggleMuteAudio",value:function(a){var t=this._connection.getSenders().filter(function(d){return d.track&&d.track.kind==="audio"}),s=rs(t),p;try{for(s.s();!(p=s.n()).done;){var _=p.value;_.track.enabled=!a}}catch(d){s.e(d)}finally{s.f()}}},{key:"_toggleMuteVideo",value:function(a){var t=this._connection.getSenders().filter(function(d){return d.track&&d.track.kind==="video"}),s=rs(t),p;try{for(s.s();!(p=s.n()).done;){var _=p.value;_.track.enabled=!a}}catch(d){s.e(d)}finally{s.f()}}},{key:"_newRTCSession",value:function(a,t){G.debug("newRTCSession()"),this._ua.newRTCSession(this,{originator:a,session:this,request:t})}},{key:"_connecting",value:function(a){G.debug("session connecting"),G.debug('emit "connecting"'),this.emit("connecting",{request:a})}},{key:"_progress",value:function(a,t){G.debug("session progress"),G.debug('emit "progress"'),this.emit("progress",{originator:a,response:t||null})}},{key:"_accepted",value:function(a,t){G.debug("session accepted"),this._start_time=new Date,G.debug('emit "accepted"'),this.emit("accepted",{originator:a,response:t||null})}},{key:"_confirmed",value:function(a,t){G.debug("session confirmed"),this._is_confirmed=!0,G.debug('emit "confirmed"'),this.emit("confirmed",{originator:a,ack:t||null})}},{key:"_ended",value:function(a,t,s){G.debug("session ended"),this._end_time=new Date,this._close(),G.debug('emit "ended"'),this.emit("ended",{originator:a,message:t||null,cause:s})}},{key:"_failed",value:function(a,t,s){G.debug("session failed"),G.debug('emit "_failed"'),this.emit("_failed",{originator:a,message:t||null,cause:s}),this._close(),G.debug('emit "failed"'),this.emit("failed",{originator:a,message:t||null,cause:s})}},{key:"_onhold",value:function(a){G.debug("session onhold"),this._setLocalMediaStatus(),G.debug('emit "hold"'),this.emit("hold",{originator:a})}},{key:"_onunhold",value:function(a){G.debug("session onunhold"),this._setLocalMediaStatus(),G.debug('emit "unhold"'),this.emit("unhold",{originator:a})}},{key:"_onmute",value:function(a){var t=a.audio,s=a.video;G.debug("session onmute"),this._setLocalMediaStatus(),G.debug('emit "muted"'),this.emit("muted",{audio:t,video:s})}},{key:"_onunmute",value:function(a){var t=a.audio,s=a.video;G.debug("session onunmute"),this._setLocalMediaStatus(),G.debug('emit "unmuted"'),this.emit("unmuted",{audio:t,video:s})}},{key:"C",get:function(){return z}},{key:"causes",get:function(){return oe.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}}]),n}(nd);function bl(c){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?bl=function(n){return typeof n}:bl=function(n){return n&&typeof Symbol=="function"&&n.constructor===Symbol&&n!==Symbol.prototype?"symbol":typeof n},bl(c)}function cd(c,r){if(!(c instanceof r))throw new TypeError("Cannot call a class as a function")}function Cc(c,r){for(var n=0;n<r.length;n++){var o=r[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(c,o.key,o)}}function fd(c,r,n){return r&&Cc(c.prototype,r),n&&Cc(c,n),c}function _d(c,r){if(typeof r!="function"&&r!==null)throw new TypeError("Super expression must either be null or a function");c.prototype=Object.create(r&&r.prototype,{constructor:{value:c,writable:!0,configurable:!0}}),r&&Qo(c,r)}function Qo(c,r){return Qo=Object.setPrototypeOf||function(o,a){return o.__proto__=a,o},Qo(c,r)}function hd(c){var r=md();return function(){var o=wl(c),a;if(r){var t=wl(this).constructor;a=Reflect.construct(o,arguments,t)}else a=o.apply(this,arguments);return dd(this,a)}}function dd(c,r){return r&&(bl(r)==="object"||typeof r=="function")?r:pd(c)}function pd(c){if(c===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return c}function md(){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(n){return n.__proto__||Object.getPrototypeOf(n)},wl(c)}var gd=ot.EventEmitter,vd=rt,Zo=Xe,Td=ts,Cr=vt(),Ed=vr,Ac=ps,yd=ms(),Ol=new vd("Message"),Sd=function(c){_d(n,c);var r=hd(n);function n(o){var a;return cd(this,n),a=r.call(this),a._ua=o,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 fd(n,[{key:"send",value:function(a,t){var s=this,p=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},_=a;if(a===void 0||t===void 0)throw new TypeError("Not enough arguments");if(a=this._ua.normalizeTarget(a),!a)throw new TypeError("Invalid target: ".concat(_));var d=Cr.cloneArray(p.extraHeaders),g=Cr.cloneObject(p.eventHandlers),v=p.contentType||"text/plain",E={};p.fromUserName&&(E.from_uri=new yd("sip",p.fromUserName,this._ua.configuration.uri.host),d.push("P-Preferred-Identity: ".concat(this._ua.configuration.uri.toString()))),p.fromDisplayName&&(E.from_display_name=p.fromDisplayName);for(var S in g)Object.prototype.hasOwnProperty.call(g,S)&&this.on(S,g[S]);d.push("Content-Type: ".concat(v)),this._request=new Td.OutgoingRequest(Zo.MESSAGE,a,this._ua,E,d),t&&(this._request.body=t);var C=new Ed(this._ua,this._request,{onRequestTimeout:function(){s._onRequestTimeout()},onTransportError:function(){s._onTransportError()},onReceiveResponse:function(w){s._receiveResponse(w)}});this._newMessage("local",this._request),C.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]:{},t=Cr.cloneArray(a.extraHeaders),s=a.body;if(this._direction!=="incoming")throw new Ac.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,t,s)}},{key:"reject",value:function(){var a=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},t=a.status_code||480,s=a.reason_phrase,p=Cr.cloneArray(a.extraHeaders),_=a.body;if(this._direction!=="incoming")throw new Ac.NotSupportedError('"reject" not supported for outgoing Message');if(this._is_replied)throw new Error("incoming Message already replied");if(t<300||t>=700)throw new TypeError("Invalid status_code: ".concat(t));this._is_replied=!0,this._request.reply(t,s,p,_)}},{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 t=Cr.sipErrorCause(a.status_code);this._failed("remote",a,t);break}}}},{key:"_onRequestTimeout",value:function(){this._closed||this._failed("system",null,Zo.causes.REQUEST_TIMEOUT)}},{key:"_onTransportError",value:function(){this._closed||this._failed("system",null,Zo.causes.CONNECTION_ERROR)}},{key:"_close",value:function(){this._closed=!0,this._ua.destroyMessage(this)}},{key:"_newMessage",value:function(a,t){a==="remote"?(this._direction="incoming",this._local_identity=t.to,this._remote_identity=t.from):a==="local"&&(this._direction="outgoing",this._local_identity=t.from,this._remote_identity=t.to),this._ua.newMessage(this,{originator:a,message:this,request:t})}},{key:"_failed",value:function(a,t,s){Ol.debug("MESSAGE failed"),this._close(),Ol.debug('emit "failed"'),this.emit("failed",{originator:a,response:t||null,cause:s})}},{key:"_succeeded",value:function(a,t){Ol.debug("MESSAGE succeeded"),this._close(),Ol.debug('emit "succeeded"'),this.emit("succeeded",{originator:a,response:t})}},{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}}]),n}(gd);function Dl(c){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?Dl=function(n){return typeof n}:Dl=function(n){return n&&typeof Symbol=="function"&&n.constructor===Symbol&&n!==Symbol.prototype?"symbol":typeof n},Dl(c)}function Cd(c,r){if(!(c instanceof r))throw new TypeError("Cannot call a class as a function")}function Rc(c,r){for(var n=0;n<r.length;n++){var o=r[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(c,o.key,o)}}function Ad(c,r,n){return r&&Rc(c.prototype,r),n&&Rc(c,n),c}function Rd(c,r){if(typeof r!="function"&&r!==null)throw new TypeError("Super expression must either be null or a function");c.prototype=Object.create(r&&r.prototype,{constructor:{value:c,writable:!0,configurable:!0}}),r&&ea(c,r)}function ea(c,r){return ea=Object.setPrototypeOf||function(o,a){return o.__proto__=a,o},ea(c,r)}function Id(c){var r=Od();return function(){var o=Nl(c),a;if(r){var t=Nl(this).constructor;a=Reflect.construct(o,arguments,t)}else a=o.apply(this,arguments);return bd(this,a)}}function bd(c,r){return r&&(Dl(r)==="object"||typeof r=="function")?r:wd(c)}function wd(c){if(c===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return c}function Od(){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 Nl(c){return Nl=Object.setPrototypeOf?Object.getPrototypeOf:function(n){return n.__proto__||Object.getPrototypeOf(n)},Nl(c)}var Dd=ot.EventEmitter,Nd=rt,ta=Xe,Ud=ts,Ar=vt(),Pd=vr,Ic=ps,Ul=new Nd("Options"),kd=function(c){Rd(n,c);var r=Id(n);function n(o){var a;return Cd(this,n),a=r.call(this),a._ua=o,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 Ad(n,[{key:"send",value:function(a,t){var s=this,p=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},_=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(_));var d=Ar.cloneArray(p.extraHeaders),g=Ar.cloneObject(p.eventHandlers),v=p.contentType||"application/sdp";for(var E in g)Object.prototype.hasOwnProperty.call(g,E)&&this.on(E,g[E]);d.push("Content-Type: ".concat(v)),this._request=new Ud.OutgoingRequest(ta.OPTIONS,a,this._ua,null,d),t&&(this._request.body=t);var S=new Pd(this._ua,this._request,{onRequestTimeout:function(){s._onRequestTimeout()},onTransportError:function(){s._onTransportError()},onReceiveResponse:function(I){s._receiveResponse(I)}});this._newOptions("local",this._request),S.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]:{},t=Ar.cloneArray(a.extraHeaders),s=a.body;if(this._direction!=="incoming")throw new Ic.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,t,s)}},{key:"reject",value:function(){var a=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},t=a.status_code||480,s=a.reason_phrase,p=Ar.cloneArray(a.extraHeaders),_=a.body;if(this._direction!=="incoming")throw new Ic.NotSupportedError('"reject" not supported for outgoing Options');if(this._is_replied)throw new Error("incoming Options already replied");if(t<300||t>=700)throw new TypeError("Invalid status_code: ".concat(t));this._is_replied=!0,this._request.reply(t,s,p,_)}},{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 t=Ar.sipErrorCause(a.status_code);this._failed("remote",a,t);break}}}},{key:"_onRequestTimeout",value:function(){this._closed||this._failed("system",null,ta.causes.REQUEST_TIMEOUT)}},{key:"_onTransportError",value:function(){this._closed||this._failed("system",null,ta.causes.CONNECTION_ERROR)}},{key:"_close",value:function(){this._closed=!0,this._ua.destroyMessage(this)}},{key:"_newOptions",value:function(a,t){a==="remote"?(this._direction="incoming",this._local_identity=t.to,this._remote_identity=t.from):a==="local"&&(this._direction="outgoing",this._local_identity=t.from,this._remote_identity=t.to),this._ua.newOptions(this,{originator:a,message:this,request:t})}},{key:"_failed",value:function(a,t,s){Ul.debug("OPTIONS failed"),this._close(),Ul.debug('emit "failed"'),this.emit("failed",{originator:a,response:t||null,cause:s})}},{key:"_succeeded",value:function(a,t){Ul.debug("OPTIONS succeeded"),this._close(),Ul.debug('emit "succeeded"'),this.emit("succeeded",{originator:a,response:t})}},{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}}]),n}(Dd),sa={},Md=rt,na=vt(),xd=jt(),Rr=new Md("Socket");sa.isSocket=function(c){if(Array.isArray(c))return!1;if(typeof c>"u")return Rr.warn("undefined JsSIP.Socket instance"),!1;try{if(!na.isString(c.url))throw Rr.warn("missing or invalid JsSIP.Socket url property"),new Error("Missing or invalid JsSIP.Socket url property");if(!na.isString(c.via_transport))throw Rr.warn("missing or invalid JsSIP.Socket via_transport property"),new Error("Missing or invalid JsSIP.Socket via_transport property");if(xd.parse(c.sip_uri,"SIP_URI")===-1)throw Rr.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(r){if(!na.isFunction(c[r]))throw Rr.warn("missing or invalid JsSIP.Socket method: ".concat(r)),new Error("Missing or invalid JsSIP.Socket method: ".concat(r))})}catch{return!1}return!0};function Ld(c,r){if(!(c instanceof r))throw new TypeError("Cannot call a class as a function")}function bc(c,r){for(var n=0;n<r.length;n++){var o=r[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(c,o.key,o)}}function $d(c,r,n){return r&&bc(c.prototype,r),n&&bc(c,n),c}var Hd=rt,Fd=sa,wc=Xe,At=new Hd("Transport"),Dt={STATUS_CONNECTED:0,STATUS_CONNECTING:1,STATUS_DISCONNECTED:2,SOCKET_STATUS_READY:0,SOCKET_STATUS_ERROR:1,recovery_options:{min_interval:wc.CONNECTION_RECOVERY_MIN_INTERVAL,max_interval:wc.CONNECTION_RECOVERY_MAX_INTERVAL}},qd=function(){function c(r){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:Dt.recovery_options;Ld(this,c),At.debug("new()"),this.status=Dt.STATUS_DISCONNECTED,this.socket=null,this.sockets=[],this.recovery_options=n,this.recover_attempts=0,this.recovery_timer=null,this.close_requested=!1;try{this.textDecoder=new TextDecoder("utf8")}catch(o){At.warn("cannot use TextDecoder: ".concat(o))}if(typeof r>"u")throw new TypeError("Invalid argument. undefined 'sockets' argument");r instanceof Array||(r=[r]),r.forEach(function(o){if(!Fd.isSocket(o.socket))throw new TypeError("Invalid argument. invalid 'JsSIP.Socket' instance");if(o.weight&&!Number(o.weight))throw new TypeError("Invalid argument. 'weight' attribute is not a number");this.sockets.push({socket:o.socket,weight:o.weight||0,status:Dt.SOCKET_STATUS_READY})},this),this._getSocket()}return $d(c,[{key:"connect",value:function(){if(At.debug("connect()"),this.isConnected()){At.debug("Transport is already connected");return}else if(this.isConnecting()){At.debug("Transport is connecting");return}this.close_requested=!1,this.status=Dt.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(){At.debug("close()"),this.close_requested=!0,this.recover_attempts=0,this.status=Dt.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(n){if(At.debug("send()"),!this.isConnected())return At.warn("unable to send message, transport is not connected"),!1;var o=n.toString();return At.debug(`sending message:
51
+
52
+ `.concat(o,`
53
+ `)),this.socket.send(o)}},{key:"isConnected",value:function(){return this.status===Dt.STATUS_CONNECTED}},{key:"isConnecting",value:function(){return this.status===Dt.STATUS_CONNECTING}},{key:"_reconnect",value:function(){var n=this;this.recover_attempts+=1;var o=Math.floor(Math.random()*Math.pow(2,this.recover_attempts)+1);o<this.recovery_options.min_interval?o=this.recovery_options.min_interval:o>this.recovery_options.max_interval&&(o=this.recovery_options.max_interval),At.debug("reconnection attempt: ".concat(this.recover_attempts,". next connection attempt in ").concat(o," seconds")),this.recovery_timer=setTimeout(function(){!n.close_requested&&!(n.isConnected()||n.isConnecting())&&(n._getSocket(),n.connect())},o*1e3)}},{key:"_getSocket",value:function(){var n=[];if(this.sockets.forEach(function(a){a.status!==Dt.SOCKET_STATUS_ERROR&&(n.length===0?n.push(a):a.weight>n[0].weight?n=[a]:a.weight===n[0].weight&&n.push(a))}),n.length===0){this.sockets.forEach(function(a){a.status=Dt.SOCKET_STATUS_READY}),this._getSocket();return}var o=Math.floor(Math.random()*n.length);this.socket=n[o].socket}},{key:"_onConnect",value:function(){this.recover_attempts=0,this.status=Dt.STATUS_CONNECTED,this.recovery_timer!==null&&(clearTimeout(this.recovery_timer),this.recovery_timer=null),this.onconnect({socket:this})}},{key:"_onDisconnect",value:function(n,o,a){this.status=Dt.STATUS_DISCONNECTED,this.ondisconnect({socket:this.socket,error:n,code:o,reason:a}),!this.close_requested&&(this.sockets.forEach(function(t){this.socket===t.socket&&(t.status=Dt.SOCKET_STATUS_ERROR)},this),this._reconnect(n))}},{key:"_onData",value:function(n){if(n===`\r
54
+ `){At.debug("received message with CRLF Keep Alive response");return}else if(typeof n!="string"){try{this.textDecoder?n=this.textDecoder.decode(n):n=String.fromCharCode.apply(null,new Uint8Array(n))}catch{At.debug("received binary message failed to be converted into string, message discarded");return}At.debug(`received binary message:
55
+
56
+ `.concat(n,`
57
+ `))}else At.debug(`received text message:
58
+
59
+ `.concat(n,`
60
+ `));this.ondata({transport:this,message:n})}},{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}(),Oc={};function Dc(c,r){var n;if(typeof Symbol>"u"||c[Symbol.iterator]==null){if(Array.isArray(c)||(n=jd(c))||r&&c&&typeof c.length=="number"){n&&(c=n);var o=0,a=function(){};return{s:a,n:function(){return o>=c.length?{done:!0}:{done:!1,value:c[o++]}},e:function(d){throw d},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 t=!0,s=!1,p;return{s:function(){n=c[Symbol.iterator]()},n:function(){var d=n.next();return t=d.done,d},e:function(d){s=!0,p=d},f:function(){try{!t&&n.return!=null&&n.return()}finally{if(s)throw p}}}}function jd(c,r){if(c){if(typeof c=="string")return Nc(c,r);var n=Object.prototype.toString.call(c).slice(8,-1);if(n==="Object"&&c.constructor&&(n=c.constructor.name),n==="Map"||n==="Set")return Array.from(c);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return Nc(c,r)}}function Nc(c,r){(r==null||r>c.length)&&(r=c.length);for(var n=0,o=new Array(r);n<r;n++)o[n]=c[n];return o}var Vd=rt,ra=jt(),ia=ts,Pl=new Vd("Parser");Oc.parseMessage=function(c,r){var n,o,a=c.indexOf(`\r
62
+ `);if(a===-1){Pl.warn("parseMessage() | no CRLF found, not a SIP message");return}var t=c.substring(0,a),s=ra.parse(t,"Request_Response");if(s===-1){Pl.warn('parseMessage() | error parsing first line of SIP message: "'.concat(t,'"'));return}else s.status_code?(n=new ia.IncomingResponse,n.status_code=s.status_code,n.reason_phrase=s.reason_phrase):(n=new ia.IncomingRequest(r),n.method=s.method,n.ruri=s.uri);n.data=c;for(var p=a+2;;){if(a=Bd(c,p),a===-2){o=p+2;break}else if(a===-1){Pl.warn("parseMessage() | malformed message");return}if(s=Gd(n,c,p,a),s!==!0){Pl.warn("parseMessage() |",s.error);return}p=a+2}if(n.hasHeader("content-length")){var _=n.getHeader("content-length");n.body=c.substr(o,_)}else n.body=c.substring(o);return n};function Bd(c,r){var n=r,o=0,a=0;if(c.substring(n,n+2).match(/(^\r\n)/))return-2;for(;o===0;){if(a=c.indexOf(`\r
63
+ `,n),a===-1)return a;!c.substring(a+2,a+4).match(/(^\r\n)/)&&c.charAt(a+2).match(/(^\s+)/)?n=a+2:o=a}return o}function Gd(c,r,n,o){var a,t=r.indexOf(":",n),s=r.substring(n,t).trim(),p=r.substring(t+1,o).trim();switch(s.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=ra.parse(p,"Record_Route"),a===-1)a=void 0;else{var _=Dc(a),d;try{for(_.s();!(d=_.n()).done;){var g=d.value;c.addHeader("record-route",p.substring(g.possition,g.offset)),c.headers["Record-Route"][c.getHeaders("record-route").length-1].parsed=g.parsed}}catch(C){_.e(C)}finally{_.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=ra.parse(p,"Contact"),a===-1)a=void 0;else{var v=Dc(a),E;try{for(v.s();!(E=v.n()).done;){var S=E.value;c.addHeader("contact",p.substring(S.possition,S.offset)),c.headers.Contact[c.getHeaders("contact").length-1].parsed=S.parsed}}catch(C){v.e(C)}finally{v.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 ia.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(s,p),a=0}return a===void 0?{error:'error parsing header "'.concat(s,'"')}:!0}function kl(c,r){var n;if(typeof Symbol>"u"||c[Symbol.iterator]==null){if(Array.isArray(c)||(n=Kd(c))||r&&c&&typeof c.length=="number"){n&&(c=n);var o=0,a=function(){};return{s:a,n:function(){return o>=c.length?{done:!0}:{done:!1,value:c[o++]}},e:function(d){throw d},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 t=!0,s=!1,p;return{s:function(){n=c[Symbol.iterator]()},n:function(){var d=n.next();return t=d.done,d},e:function(d){s=!0,p=d},f:function(){try{!t&&n.return!=null&&n.return()}finally{if(s)throw p}}}}function Kd(c,r){if(c){if(typeof c=="string")return Uc(c,r);var n=Object.prototype.toString.call(c).slice(8,-1);if(n==="Object"&&c.constructor&&(n=c.constructor.name),n==="Map"||n==="Set")return Array.from(c);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return Uc(c,r)}}function Uc(c,r){(r==null||r>c.length)&&(r=c.length);for(var n=0,o=new Array(r);n<r;n++)o[n]=c[n];return o}var Wd=rt,Pc=Xe,kc=ts,la=vt(),oa=new Wd("sanityCheck"),Yd=[rp],zd=[Qd,Zd,ep,tp],Jd=[sp,np],xe,Bt,Mc,Xd=function(c,r,n){xe=c,Bt=r,Mc=n;var o=kl(Yd),a;try{for(o.s();!(a=o.n()).done;){var t=a.value;if(t()===!1)return!1}}catch(E){o.e(E)}finally{o.f()}if(xe instanceof kc.IncomingRequest){var s=kl(zd),p;try{for(s.s();!(p=s.n()).done;){var _=p.value;if(_()===!1)return!1}}catch(E){s.e(E)}finally{s.f()}}else if(xe instanceof kc.IncomingResponse){var d=kl(Jd),g;try{for(d.s();!(g=d.n()).done;){var v=g.value;if(v()===!1)return!1}}catch(E){d.e(E)}finally{d.f()}}return!0};function Qd(){if(xe.s("to").uri.scheme!=="sip")return Ir(416),!1}function Zd(){if(!xe.to_tag&&xe.call_id.substr(0,5)===Bt.configuration.jssip_id)return Ir(482),!1}function ep(){var c=la.str_utf8_length(xe.body),r=xe.getHeader("content-length");if(c<r)return Ir(400),!1}function tp(){var c=xe.from_tag,r=xe.call_id,n=xe.cseq,o;if(!xe.to_tag)if(xe.method===Pc.INVITE){if(Bt._transactions.ist[xe.via_branch])return!1;for(var a in Bt._transactions.ist)if(Object.prototype.hasOwnProperty.call(Bt._transactions.ist,a)&&(o=Bt._transactions.ist[a],o.request.from_tag===c&&o.request.call_id===r&&o.request.cseq===n))return Ir(482),!1}else{if(Bt._transactions.nist[xe.via_branch])return!1;for(var t in Bt._transactions.nist)if(Object.prototype.hasOwnProperty.call(Bt._transactions.nist,t)&&(o=Bt._transactions.nist[t],o.request.from_tag===c&&o.request.call_id===r&&o.request.cseq===n))return Ir(482),!1}}function sp(){if(xe.getHeaders("via").length>1)return oa.debug("more than one Via header field present in the response, dropping the response"),!1}function np(){var c=la.str_utf8_length(xe.body),r=xe.getHeader("content-length");if(c<r)return oa.debug("message body length is lower than the value in Content-Length header field, dropping the response"),!1}function rp(){for(var c=["from","to","call_id","cseq","via"],r=0,n=c;r<n.length;r++){var o=n[r];if(!xe.hasHeader(o))return oa.debug("missing mandatory header field : ".concat(o,", dropping the response")),!1}}function Ir(c){var r=xe.getHeaders("via"),n,o="SIP/2.0 ".concat(c," ").concat(Pc.REASON_PHRASE[c],`\r
65
+ `),a=kl(r),t;try{for(a.s();!(t=a.n()).done;){var s=t.value;o+="Via: ".concat(s,`\r
66
+ `)}}catch(p){a.e(p)}finally{a.f()}n=xe.getHeader("To"),xe.to_tag||(n+=";tag=".concat(la.newTag())),o+="To: ".concat(n,`\r
67
+ `),o+="From: ".concat(xe.getHeader("From"),`\r
68
+ `),o+="Call-ID: ".concat(xe.call_id,`\r
69
+ `),o+="CSeq: ".concat(xe.cseq," ").concat(xe.method,`\r
70
+ `),o+=`\r
71
+ `,Mc.send(o)}var aa={};function xc(c,r){var n;if(typeof Symbol>"u"||c[Symbol.iterator]==null){if(Array.isArray(c)||(n=ip(c))||r&&c&&typeof c.length=="number"){n&&(c=n);var o=0,a=function(){};return{s:a,n:function(){return o>=c.length?{done:!0}:{done:!1,value:c[o++]}},e:function(d){throw d},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 t=!0,s=!1,p;return{s:function(){n=c[Symbol.iterator]()},n:function(){var d=n.next();return t=d.done,d},e:function(d){s=!0,p=d},f:function(){try{!t&&n.return!=null&&n.return()}finally{if(s)throw p}}}}function ip(c,r){if(c){if(typeof c=="string")return Lc(c,r);var n=Object.prototype.toString.call(c).slice(8,-1);if(n==="Object"&&c.constructor&&(n=c.constructor.name),n==="Map"||n==="Set")return Array.from(c);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return Lc(c,r)}}function Lc(c,r){(r==null||r>c.length)&&(r=c.length);for(var n=0,o=new Array(r);n<r;n++)o[n]=c[n];return o}var En=vt(),qs=Xe,ua=jt(),$c=ms(),ca=sa,fa=ps;aa.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:qs.UPDATE,session_timers_force_refresher:!1,no_answer_timeout:60,register:!0,register_expires:600,registrar_server:null,sockets:null,connection_recovery_max_interval:qs.CONNECTION_RECOVERY_MAX_INTERVAL,connection_recovery_min_interval:qs.CONNECTION_RECOVERY_MIN_INTERVAL,extra_headers:null,via_host:"".concat(En.createRandomToken(12),".invalid")};var Ml={mandatory:{sockets:function(r){var n=[];if(ca.isSocket(r))n.push({socket:r});else if(Array.isArray(r)&&r.length){var o=xc(r),a;try{for(o.s();!(a=o.n()).done;){var t=a.value;Object.prototype.hasOwnProperty.call(t,"socket")&&ca.isSocket(t.socket)?n.push(t):ca.isSocket(t)&&n.push({socket:t})}}catch(s){o.e(s)}finally{o.f()}}else return;return n},uri:function(r){/^sip:/i.test(r)||(r="".concat(qs.SIP,":").concat(r));var n=$c.parse(r);if(n)return n.user?n:void 0}},optional:{authorization_user:function(r){if(ua.parse('"'.concat(r,'"'),"quoted_string")!==-1)return r},authorization_jwt:function(r){if(typeof r=="string")return r},user_agent:function(r){if(typeof r=="string")return r},connection_recovery_max_interval:function(r){if(En.isDecimal(r)){var n=Number(r);if(n>0)return n}},connection_recovery_min_interval:function(r){if(En.isDecimal(r)){var n=Number(r);if(n>0)return n}},contact_uri:function(r){if(typeof r=="string"){var n=ua.parse(r,"SIP_URI");if(n!==-1)return n}},display_name:function(r){return r},instance_id:function(r){if(/^uuid:/i.test(r)&&(r=r.substr(5)),ua.parse(r,"uuid")!==-1)return r},no_answer_timeout:function(r){if(En.isDecimal(r)){var n=Number(r);if(n>0)return n}},session_timers:function(r){if(typeof r=="boolean")return r},session_timers_refresh_method:function(r){if(typeof r=="string"&&(r=r.toUpperCase(),r===qs.INVITE||r===qs.UPDATE))return r},session_timers_force_refresher:function(r){if(typeof r=="boolean")return r},password:function(r){return String(r)},realm:function(r){return String(r)},ha1:function(r){return String(r)},register:function(r){if(typeof r=="boolean")return r},register_expires:function(r){if(En.isDecimal(r)){var n=Number(r);if(n>0)return n}},registrar_server:function(r){/^sip:/i.test(r)||(r="".concat(qs.SIP,":").concat(r));var n=$c.parse(r);if(n)return n.user?void 0:n},use_preloaded_route:function(r){if(typeof r=="boolean")return r},extra_headers:function(r){var n=[];if(Array.isArray(r)&&r.length){var o=xc(r),a;try{for(o.s();!(a=o.n()).done;){var t=a.value;typeof t=="string"&&n.push(t)}}catch(s){o.e(s)}finally{o.f()}}else return;return n}}};aa.load=function(c,r){for(var n in Ml.mandatory)if(r.hasOwnProperty(n)){var o=r[n],a=Ml.mandatory[n](o);if(a!==void 0)c[n]=a;else throw new fa.ConfigurationError(n,o)}else throw new fa.ConfigurationError(n);for(var t in Ml.optional)if(r.hasOwnProperty(t)){var s=r[t];if(En.isEmpty(s))continue;var p=Ml.optional[t](s);if(p!==void 0)c[t]=p;else throw new fa.ConfigurationError(t,s)}};function xl(c){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?xl=function(n){return typeof n}:xl=function(n){return n&&typeof Symbol=="function"&&n.constructor===Symbol&&n!==Symbol.prototype?"symbol":typeof n},xl(c)}function lp(c,r){if(!(c instanceof r))throw new TypeError("Cannot call a class as a function")}function Hc(c,r){for(var n=0;n<r.length;n++){var o=r[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(c,o.key,o)}}function Fc(c,r,n){return r&&Hc(c.prototype,r),n&&Hc(c,n),c}function op(c,r){if(typeof r!="function"&&r!==null)throw new TypeError("Super expression must either be null or a function");c.prototype=Object.create(r&&r.prototype,{constructor:{value:c,writable:!0,configurable:!0}}),r&&_a(c,r)}function _a(c,r){return _a=Object.setPrototypeOf||function(o,a){return o.__proto__=a,o},_a(c,r)}function ap(c){var r=cp();return function(){var o=Ll(c),a;if(r){var t=Ll(this).constructor;a=Reflect.construct(o,arguments,t)}else a=o.apply(this,arguments);return up(this,a)}}function up(c,r){return r&&(xl(r)==="object"||typeof r=="function")?r:qc(c)}function qc(c){if(c===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return c}function cp(){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(n){return n.__proto__||Object.getPrototypeOf(n)},Ll(c)}var fp=ot.EventEmitter,_p=rt,ut=Xe,hp=eh,jc=ud,Vc=Sd,Bc=kd,ha=gr,dp=qd,$l=vt(),pp=ps,mp=ms(),gp=Oc,da=ts,vp=Xd,pa=aa,$e=new _p("UA"),ct={STATUS_INIT:0,STATUS_READY:1,STATUS_USER_CLOSED:2,STATUS_NOT_READY:3,CONFIGURATION_ERROR:1,NETWORK_ERROR:2},Tp=function(c){op(n,c);var r=ap(n);Fc(n,null,[{key:"C",get:function(){return ct}}]);function n(o){var a;if(lp(this,n),$e.debug("new() [configuration:%o]",o),a=r.call(this),a._cache={credentials:{}},a._configuration=Object.assign({},pa.settings),a._dynConfiguration={},a._dialogs={},a._applicants={},a._sessions={},a._transport=null,a._contact=null,a._status=ct.STATUS_INIT,a._error=null,a._transactions={nist:{},nict:{},ist:{},ict:{}},a._data={},a._closeTimer=null,o===void 0)throw new TypeError("Not enough arguments");try{a._loadConfig(o)}catch(t){throw a._status=ct.STATUS_NOT_READY,a._error=ct.CONFIGURATION_ERROR,t}return a._registrator=new hp(qc(a)),a}return Fc(n,[{key:"start",value:function(){$e.debug("start()"),this._status===ct.STATUS_INIT?this._transport.connect():this._status===ct.STATUS_USER_CLOSED?($e.debug("restarting UA"),this._closeTimer!==null&&(clearTimeout(this._closeTimer),this._closeTimer=null,this._transport.disconnect()),this._status=ct.STATUS_INIT,this._transport.connect()):this._status===ct.STATUS_READY?$e.debug("UA is in READY status, not restarted"):$e.debug("ERROR: connection is down, Auto-Recovery system is trying to reconnect"),this._dynConfiguration.register=this._configuration.register}},{key:"register",value:function(){$e.debug("register()"),this._dynConfiguration.register=!0,this._registrator.register()}},{key:"unregister",value:function(a){$e.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,t){$e.debug("call()");var s=new jc(this);return s.connect(a,t),s}},{key:"sendMessage",value:function(a,t,s){$e.debug("sendMessage()");var p=new Vc(this);return p.send(a,t,s),p}},{key:"sendOptions",value:function(a,t,s){$e.debug("sendOptions()");var p=new Bc(this);return p.send(a,t,s),p}},{key:"terminateSessions",value:function(a){$e.debug("terminateSessions()");for(var t in this._sessions)this._sessions[t].isEnded()||this._sessions[t].terminate(a)}},{key:"stop",value:function(){var a=this;if($e.debug("stop()"),this._dynConfiguration={},this._status===ct.STATUS_USER_CLOSED){$e.debug("UA already closed");return}this._registrator.close();var t=Object.keys(this._sessions).length;for(var s in this._sessions)if(Object.prototype.hasOwnProperty.call(this._sessions,s)){$e.debug("closing session ".concat(s));try{this._sessions[s].terminate()}catch{}}for(var p in this._applicants)if(Object.prototype.hasOwnProperty.call(this._applicants,p))try{this._applicants[p].close()}catch{}this._status=ct.STATUS_USER_CLOSED;var _=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&&t===0?this._transport.disconnect():this._closeTimer=setTimeout(function(){a._closeTimer=null,a._transport.disconnect()},2e3)}},{key:"normalizeTarget",value:function(a){return $l.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:$e.warn('get() | cannot get "%s" parameter in runtime',a);return}}},{key:"set",value:function(a,t){switch(a){case"authorization_user":{this._configuration.authorization_user=String(t);break}case"password":{this._configuration.password=String(t);break}case"realm":{this._configuration.realm=String(t);break}case"ha1":{this._configuration.ha1=String(t),this._configuration.password=null;break}case"authorization_jwt":{this._configuration.authorization_jwt=String(t);break}case"display_name":{this._configuration.display_name=t;break}default:return $e.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,t){this._applicants[a]=a,this.emit("newMessage",t)}},{key:"newOptions",value:function(a,t){this._applicants[a]=a,this.emit("newOptions",t)}},{key:"destroyMessage",value:function(a){delete this._applicants[a]}},{key:"newRTCSession",value:function(a,t){this._sessions[a.id]=a,this.emit("newRTCSession",t)}},{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 t=a.method;if(a.ruri.user!==this._configuration.uri.user&&a.ruri.user!==this._contact.uri.user){$e.debug("Request-URI does not point to us"),a.method!==ut.ACK&&a.reply_sl(404);return}if(a.ruri.scheme===ut.SIPS){a.reply_sl(416);return}if(!ha.checkTransaction(this,a)){if(t===ut.INVITE?new ha.InviteServerTransaction(this,this._transport,a):t!==ut.ACK&&t!==ut.CANCEL&&new ha.NonInviteServerTransaction(this,this._transport,a),t===ut.OPTIONS){if(this.listeners("newOptions").length===0){a.reply(200);return}var s=new Bc(this);s.init_incoming(a)}else if(t===ut.MESSAGE){if(this.listeners("newMessage").length===0){a.reply(405);return}var p=new Vc(this);p.init_incoming(a)}else if(t===ut.INVITE&&!a.to_tag&&this.listeners("newRTCSession").length===0){a.reply(405);return}var _,d;if(a.to_tag)_=this._findDialog(a.call_id,a.from_tag,a.to_tag),_?_.receiveRequest(a):t===ut.NOTIFY?(d=this._findSession(a),d?d.receiveRequest(a):($e.debug("received NOTIFY request for a non existent subscription"),a.reply(481,"Subscription does not exist"))):t!==ut.ACK&&a.reply(481);else switch(t){case ut.INVITE:if(window.RTCPeerConnection)if(a.hasHeader("replaces")){var g=a.replaces;_=this._findDialog(g.call_id,g.from_tag,g.to_tag),_?(d=_.owner,d.isEnded()?a.reply(603):d.receiveRequest(a)):a.reply(481)}else d=new jc(this),d.init_incoming(a);else $e.warn("INVITE received but WebRTC is not supported"),a.reply(488);break;case ut.BYE:a.reply(481);break;case ut.CANCEL:d=this._findSession(a),d?d.receiveRequest(a):$e.debug("received CANCEL request for a non existent session");break;case ut.ACK:break;case ut.NOTIFY:this.emit("sipEvent",{event:a.event,request:a}),a.reply(200);break;default:a.reply(405);break}}}},{key:"_findSession",value:function(a){var t=a.call_id,s=a.from_tag,p=a.to_tag,_=t+s,d=this._sessions[_],g=t+p,v=this._sessions[g];return d||v||null}},{key:"_findDialog",value:function(a,t,s){var p=a+t+s,_=this._dialogs[p];return _||(p=a+s+t,_=this._dialogs[p],_||null)}},{key:"_loadConfig",value:function(a){try{pa.load(this._configuration,a)}catch(g){throw g}this._configuration.display_name===0&&(this._configuration.display_name="0"),this._configuration.instance_id||(this._configuration.instance_id=$l.newUUID()),this._configuration.jssip_id=$l.createRandomToken(5);var t=this._configuration.uri.clone();t.user=null,this._configuration.hostport_params=t.toString().replace(/^sip:/i,"");try{this._transport=new dp(this._configuration.sockets,{max_interval:this._configuration.connection_recovery_max_interval,min_interval:this._configuration.connection_recovery_min_interval}),this._transport.onconnecting=Ep.bind(this),this._transport.onconnect=yp.bind(this),this._transport.ondisconnect=Sp.bind(this),this._transport.ondata=Cp.bind(this)}catch(g){throw $e.warn(g),new pp.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 s=this._configuration.uri.clone();s.user=null,s.clearParams(),s.clearHeaders(),this._configuration.registrar_server=s}this._configuration.no_answer_timeout*=1e3,this._configuration.contact_uri?this._configuration.via_host=this._configuration.contact_uri.host:this._configuration.contact_uri=new mp("sip",$l.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 v=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},E=v.anonymous||null,S=v.outbound||null,C="<";return E?C+=this.temp_gruu||"sip:anonymous@anonymous.invalid;transport=ws":C+=this.pub_gruu||this.uri.toString(),S&&(E?!this.temp_gruu:!this.pub_gruu)&&(C+=";ob"),C+=">",C}};var p=["authorization_user","password","realm","ha1","authorization_jwt","display_name","register"];for(var _ in this._configuration)Object.prototype.hasOwnProperty.call(this._configuration,_)&&(p.indexOf(_)!==-1?Object.defineProperty(this._configuration,_,{writable:!0,configurable:!1}):Object.defineProperty(this._configuration,_,{writable:!1,configurable:!1}));$e.debug("configuration parameters after validation:");for(var d in this._configuration)if(Object.prototype.hasOwnProperty.call(pa.settings,d))switch(d){case"uri":case"registrar_server":$e.debug("- ".concat(d,": ").concat(this._configuration[d]));break;case"password":case"ha1":case"authorization_jwt":$e.debug("- ".concat(d,": NOT SHOWN"));break;default:$e.debug("- ".concat(d,": ").concat(JSON.stringify(this._configuration[d])))}}},{key:"C",get:function(){return ct}},{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}}]),n}(fp);function Ep(c){this.emit("connecting",c)}function yp(c){this._status!==ct.STATUS_USER_CLOSED&&(this._status=ct.STATUS_READY,this._error=null,this.emit("connected",c),this._dynConfiguration.register&&this._registrator.register())}function Sp(c){for(var r=["nict","ict","nist","ist"],n=0,o=r;n<o.length;n++){var a=o[n];for(var t in this._transactions[a])Object.prototype.hasOwnProperty.call(this._transactions[a],t)&&this._transactions[a][t].onTransportError()}this.emit("disconnected",c),this._registrator.onTransportClosed(),this._status!==ct.STATUS_USER_CLOSED&&(this._status=ct.STATUS_NOT_READY,this._error=ct.NETWORK_ERROR)}function Cp(c){var r=c.transport,n=c.message;if(n=gp.parseMessage(n,this),!!n&&!(this._status===ct.STATUS_USER_CLOSED&&n instanceof da.IncomingRequest)&&vp(n,this,r)){if(n instanceof da.IncomingRequest)n.transport=r,this.receiveRequest(n);else if(n instanceof da.IncomingResponse){var o;switch(n.method){case ut.INVITE:o=this._transactions.ict[n.via_branch],o&&o.receiveResponse(n);break;case ut.ACK:break;default:o=this._transactions.nict[n.via_branch],o&&o.receiveResponse(n);break}}}}function Ap(c,r){if(!(c instanceof r))throw new TypeError("Cannot call a class as a function")}function Gc(c,r){for(var n=0;n<r.length;n++){var o=r[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(c,o.key,o)}}function Rp(c,r,n){return r&&Gc(c.prototype,r),n&&Gc(c,n),c}var Ip=rt,bp=jt(),yt=new Ip("WebSocketInterface"),wp=function(){function c(r){Ap(this,c),yt.debug('new() [url:"%s"]',r),this._url=r,this._sip_uri=null,this._via_transport=null,this._ws=null;var n=bp.parse(r,"absoluteURI");if(n===-1)throw yt.warn("invalid WebSocket URI: ".concat(r)),new TypeError("Invalid argument: ".concat(r));if(n.scheme!=="wss"&&n.scheme!=="ws")throw yt.warn("invalid WebSocket URI scheme: ".concat(n.scheme)),new TypeError("Invalid argument: ".concat(r));this._sip_uri="sip:".concat(n.host).concat(n.port?":".concat(n.port):"",";transport=ws"),this._via_transport=n.scheme.toUpperCase()}return Rp(c,[{key:"connect",value:function(){if(yt.debug("connect()"),this.isConnected()){yt.debug("WebSocket ".concat(this._url," is already connected"));return}else if(this.isConnecting()){yt.debug("WebSocket ".concat(this._url," is connecting"));return}this._ws&&this.disconnect(),yt.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(n){this._onError(n)}}},{key:"disconnect",value:function(){yt.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(n){return yt.debug("send()"),this.isConnected()?(this._ws.send(n),!0):(yt.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(){yt.debug("WebSocket ".concat(this._url," connected")),this.onconnect()}},{key:"_onClose",value:function(n){var o=n.wasClean,a=n.code,t=n.reason;yt.debug("WebSocket ".concat(this._url," closed")),o===!1&&yt.debug("WebSocket abrupt disconnection"),this.ondisconnect(!o,a,t)}},{key:"_onMessage",value:function(n){var o=n.data;yt.debug("received WebSocket message"),this.ondata(o)}},{key:"_onError",value:function(n){yt.warn("WebSocket ".concat(this._url," error: "),n)}},{key:"via_transport",get:function(){return this._via_transport},set:function(n){this._via_transport=n.toUpperCase()}},{key:"sip_uri",get:function(){return this._sip_uri}},{key:"url",get:function(){return this._url}}]),c}(),ma=el,Op=Xe,Dp=ps,Np=vt(),Up=Tp,Pp=ms(),kp=bo(),Mp=jt(),xp=wp,Lp=gn("JsSIP");Lp("version %s",ma.version);var ga={C:Op,Exceptions:Dp,Utils:Np,UA:Up,URI:Pp,NameAddrHeader:kp,WebSocketInterface:xp,Grammar:Mp,debug:gn,get name(){return ma.title},get version(){return ma.version}};const yn=gn,Sn="JsSIP";var it=class{constructor(r){r?(this._debug=yn.default(`${Sn}:${r}`),this._warn=yn.default(`${Sn}:WARN:${r}`),this._error=yn.default(`${Sn}:ERROR:${r}`)):(this._debug=yn.default(Sn),this._warn=yn.default(`${Sn}:WARN`),this._error=yn.default(`${Sn}: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 Kc=el;var we={USER_AGENT:`${Kc.title} ${Kc.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 Ie=qt(we);var ze={},va,Wc;function Ta(){if(Wc)return va;Wc=1;const c=is(),r=Gt();return va=class Jf{static parse(o){if(o=r.parse(o,"Name_Addr_Header"),o!==-1)return o}constructor(o,a,t){if(!o||!(o instanceof c))throw new TypeError('missing or invalid "uri" parameter');this._uri=o,this._parameters={},this.display_name=a;for(const s in t)Object.prototype.hasOwnProperty.call(t,s)&&this.setParam(s,t[s])}get uri(){return this._uri}get display_name(){return this._display_name}set display_name(o){this._display_name=o===0?"0":o}setParam(o,a){o&&(this._parameters[o.toLowerCase()]=typeof a>"u"||a===null?null:a.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 a=this._parameters[o];return delete this._parameters[o],a}}clearParams(){this._parameters={}}clone(){return new Jf(this._uri.clone(),this._display_name,JSON.parse(JSON.stringify(this._parameters)))}_quote(o){return o.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}toString(){let o=this._display_name?`"${this._quote(this._display_name)}" `:"";o+=`<${this._uri.toString()}>`;for(const a in this._parameters)Object.prototype.hasOwnProperty.call(this._parameters,a)&&(o+=`;${a}`,this._parameters[a]!==null&&(o+=`=${this._parameters[a]}`));return o}},va}var Ea,Yc;function Gt(){return Yc||(Yc=1,Ea=function(){function c(n){return'"'+n.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\x08/g,"\\b").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\f/g,"\\f").replace(/\r/g,"\\r").replace(/[\x00-\x07\x0B\x0E-\x1F\x80-\uFFFF]/g,escape)+'"'}var r={parse:function(n,o){var a={CRLF:d,DIGIT:g,ALPHA:v,HEXDIG:E,WSP:S,OCTET:C,DQUOTE:I,SP:w,HTAB:F,alphanum:L,reserved:ie,unreserved:N,mark:H,escaped:ve,LWS:me,SWS:M,HCOLON:D,TEXT_UTF8_TRIM:V,TEXT_UTF8char:j,UTF8_NONASCII:Y,UTF8_CONT:$,LHEX:X,token:U,token_nodot:P,separators:Z,word:et,STAR:Q,SLASH:W,EQUAL:B,LPAREN:te,RPAREN:de,RAQUOT:Ae,LAQUOT:Ue,COMMA:Se,SEMI:ne,COLON:Te,LDQUOT:tt,RDQUOT:st,comment:ge,ctext:Ee,quoted_string:Ce,quoted_string_clean:be,qdtext:_e,quoted_pair:ce,SIP_URI_noparams:fe,SIP_URI:Re,uri_scheme:Oe,uri_scheme_sips:Je,uri_scheme_sip:Me,userinfo:Ut,user:gt,user_unreserved:wn,password:On,hostport:Ys,host:Xt,hostname:_s,domainlabel:zs,toplabel:Dn,IPv6reference:Nn,IPv6address:Js,h16:he,ls32:re,IPv4address:nt,dec_octet:Ft,port:Rs,uri_parameters:Br,uri_parameter:Un,transport_param:Pn,user_param:Gr,method_param:Kr,ttl_param:Wr,maddr_param:Yr,lr_param:zr,other_param:Jr,pname:Xr,pvalue:Qr,paramchar:Is,param_unreserved:bs,headers:Zr,header:Xs,hname:Qs,hvalue:ei,hnv_unreserved:ws,Request_Response:Zs,Request_Line:no,Request_URI:ti,absoluteURI:kn,hier_part:Mn,net_path:si,abs_path:en,opaque_part:tn,uric:Os,uric_no_slash:Ds,path_segments:ni,segment:sn,param:Ns,pchar:hs,scheme:Us,authority:ri,srvr:ii,reg_name:li,query:oi,SIP_Version:xn,INVITEm:Ln,ACKm:ai,OPTIONSm:ui,BYEm:ci,CANCELm:fi,REGISTERm:_i,SUBSCRIBEm:hi,NOTIFYm:di,REFERm:pi,Method:nn,Status_Line:rn,Status_Code:mi,extension_code:gi,Reason_Phrase:vi,Allow_Events:ro,Call_ID:tu,Contact:su,contact_param:$n,name_addr:Pt,display_name:kt,contact_params:Ps,c_p_q:Hn,c_p_expires:Ti,delta_seconds:Qt,qvalue:Zt,generic_param:Ge,gen_value:Ke,Content_Disposition:io,disp_type:lo,disp_param:Fn,handling_param:qn,Content_Encoding:oo,Content_Length:nu,Content_Type:ru,media_type:ao,m_type:Ei,discrete_type:yi,composite_type:Si,extension_token:ln,x_token:on,m_subtype:Ci,m_parameter:jn,m_value:Vn,CSeq:uo,CSeq_value:co,Expires:fo,Event:iu,event_type:an,From:un,from_param:Ai,tag_param:cn,Max_Forwards:Ri,Min_Expires:lu,Name_Addr_Header:ou,Proxy_Authenticate:au,challenge:Ii,other_challenge:Bn,auth_param:ks,digest_cln:es,realm:fn,realm_value:bi,domain:wi,URI:_n,nonce:hn,nonce_value:Oi,opaque:Di,stale:Ni,algorithm:Ui,qop_options:Pi,qop_value:dn,Proxy_Require:Gn,Record_Route:uu,rec_route:Kn,Reason:Wn,reason_param:ki,reason_cause:Yn,Require:_o,Route:cu,route_param:zn,Subscription_State:Jn,substate_value:ho,subexp_params:Xn,event_reason_value:Qn,Subject:po,Supported:fu,To:_u,to_param:Mi,Via:xi,via_param:Zn,via_params:Ms,via_ttl:er,via_maddr:Li,via_received:$i,via_branch:Hi,response_port:Fi,rport:qi,sent_protocol:ji,protocol_name:Vi,transport:Bi,sent_by:Gi,via_host:Ki,via_port:Wi,ttl:tr,WWW_Authenticate:Yi,Session_Expires:hu,s_e_expires:mo,s_e_params:sr,s_e_refresher:nr,extension_header:go,header_value:vo,message_body:To,uuid_URI:du,uuid:Eo,hex4:Mt,hex8:xt,hex12:zi,Refer_To:yo,Replaces:pu,call_id:So,replaces_param:rr,to_tag:ir,from_tag:Ji,early_flag:Xi};if(o!==void 0){if(a[o]===void 0)throw new Error("Invalid rule name: "+c(o)+".")}else o="CRLF";var t=0,s=0,p=[];function _(i){t<s||(t>s&&(s=t,p=[]),p.push(i))}function d(){var i;return n.substr(t,2)===`\r
73
+ `?(i=`\r
74
+ `,t+=2):(i=null,_('"\\r\\n"')),i}function g(){var i;return/^[0-9]/.test(n.charAt(t))?(i=n.charAt(t),t++):(i=null,_("[0-9]")),i}function v(){var i;return/^[a-zA-Z]/.test(n.charAt(t))?(i=n.charAt(t),t++):(i=null,_("[a-zA-Z]")),i}function E(){var i;return/^[0-9a-fA-F]/.test(n.charAt(t))?(i=n.charAt(t),t++):(i=null,_("[0-9a-fA-F]")),i}function S(){var i;return i=w(),i===null&&(i=F()),i}function C(){var i;return/^[\0-\xFF]/.test(n.charAt(t))?(i=n.charAt(t),t++):(i=null,_("[\\0-\\xFF]")),i}function I(){var i;return/^["]/.test(n.charAt(t))?(i=n.charAt(t),t++):(i=null,_('["]')),i}function w(){var i;return n.charCodeAt(t)===32?(i=" ",t++):(i=null,_('" "')),i}function F(){var i;return n.charCodeAt(t)===9?(i=" ",t++):(i=null,_('"\\t"')),i}function L(){var i;return/^[a-zA-Z0-9]/.test(n.charAt(t))?(i=n.charAt(t),t++):(i=null,_("[a-zA-Z0-9]")),i}function ie(){var i;return n.charCodeAt(t)===59?(i=";",t++):(i=null,_('";"')),i===null&&(n.charCodeAt(t)===47?(i="/",t++):(i=null,_('"/"')),i===null&&(n.charCodeAt(t)===63?(i="?",t++):(i=null,_('"?"')),i===null&&(n.charCodeAt(t)===58?(i=":",t++):(i=null,_('":"')),i===null&&(n.charCodeAt(t)===64?(i="@",t++):(i=null,_('"@"')),i===null&&(n.charCodeAt(t)===38?(i="&",t++):(i=null,_('"&"')),i===null&&(n.charCodeAt(t)===61?(i="=",t++):(i=null,_('"="')),i===null&&(n.charCodeAt(t)===43?(i="+",t++):(i=null,_('"+"')),i===null&&(n.charCodeAt(t)===36?(i="$",t++):(i=null,_('"$"')),i===null&&(n.charCodeAt(t)===44?(i=",",t++):(i=null,_('","'))))))))))),i}function N(){var i;return i=L(),i===null&&(i=H()),i}function H(){var i;return n.charCodeAt(t)===45?(i="-",t++):(i=null,_('"-"')),i===null&&(n.charCodeAt(t)===95?(i="_",t++):(i=null,_('"_"')),i===null&&(n.charCodeAt(t)===46?(i=".",t++):(i=null,_('"."')),i===null&&(n.charCodeAt(t)===33?(i="!",t++):(i=null,_('"!"')),i===null&&(n.charCodeAt(t)===126?(i="~",t++):(i=null,_('"~"')),i===null&&(n.charCodeAt(t)===42?(i="*",t++):(i=null,_('"*"')),i===null&&(n.charCodeAt(t)===39?(i="'",t++):(i=null,_(`"'"`)),i===null&&(n.charCodeAt(t)===40?(i="(",t++):(i=null,_('"("')),i===null&&(n.charCodeAt(t)===41?(i=")",t++):(i=null,_('")"')))))))))),i}function ve(){var i,e,l,u,f;return u=t,f=t,n.charCodeAt(t)===37?(i="%",t++):(i=null,_('"%"')),i!==null?(e=E(),e!==null?(l=E(),l!==null?i=[i,e,l]:(i=null,t=f)):(i=null,t=f)):(i=null,t=f),i!==null&&(i=function(h,m){return m.join("")}(u,i)),i===null&&(t=u),i}function me(){var i,e,l,u,f,h;for(u=t,f=t,h=t,i=[],e=S();e!==null;)i.push(e),e=S();if(i!==null?(e=d(),e!==null?i=[i,e]:(i=null,t=h)):(i=null,t=h),i=i!==null?i:"",i!==null){if(l=S(),l!==null)for(e=[];l!==null;)e.push(l),l=S();else e=null;e!==null?i=[i,e]:(i=null,t=f)}else i=null,t=f;return i!==null&&(i=function(m){return" "}()),i===null&&(t=u),i}function M(){var i;return i=me(),i=i!==null?i:"",i}function D(){var i,e,l,u,f;for(u=t,f=t,i=[],e=w(),e===null&&(e=F());e!==null;)i.push(e),e=w(),e===null&&(e=F());return i!==null?(n.charCodeAt(t)===58?(e=":",t++):(e=null,_('":"')),e!==null?(l=M(),l!==null?i=[i,e,l]:(i=null,t=f)):(i=null,t=f)):(i=null,t=f),i!==null&&(i=function(h){return":"}()),i===null&&(t=u),i}function V(){var i,e,l,u,f,h,m;if(f=t,h=t,e=j(),e!==null)for(i=[];e!==null;)i.push(e),e=j();else i=null;if(i!==null){for(e=[],m=t,l=[],u=me();u!==null;)l.push(u),u=me();for(l!==null?(u=j(),u!==null?l=[l,u]:(l=null,t=m)):(l=null,t=m);l!==null;){for(e.push(l),m=t,l=[],u=me();u!==null;)l.push(u),u=me();l!==null?(u=j(),u!==null?l=[l,u]:(l=null,t=m)):(l=null,t=m)}e!==null?i=[i,e]:(i=null,t=h)}else i=null,t=h;return i!==null&&(i=function(T){return n.substring(t,T)}(f)),i===null&&(t=f),i}function j(){var i;return/^[!-~]/.test(n.charAt(t))?(i=n.charAt(t),t++):(i=null,_("[!-~]")),i===null&&(i=Y()),i}function Y(){var i;return/^[\x80-\uFFFF]/.test(n.charAt(t))?(i=n.charAt(t),t++):(i=null,_("[\\x80-\\uFFFF]")),i}function $(){var i;return/^[\x80-\xBF]/.test(n.charAt(t))?(i=n.charAt(t),t++):(i=null,_("[\\x80-\\xBF]")),i}function X(){var i;return i=g(),i===null&&(/^[a-f]/.test(n.charAt(t))?(i=n.charAt(t),t++):(i=null,_("[a-f]"))),i}function U(){var i,e,l;if(l=t,e=L(),e===null&&(n.charCodeAt(t)===45?(e="-",t++):(e=null,_('"-"')),e===null&&(n.charCodeAt(t)===46?(e=".",t++):(e=null,_('"."')),e===null&&(n.charCodeAt(t)===33?(e="!",t++):(e=null,_('"!"')),e===null&&(n.charCodeAt(t)===37?(e="%",t++):(e=null,_('"%"')),e===null&&(n.charCodeAt(t)===42?(e="*",t++):(e=null,_('"*"')),e===null&&(n.charCodeAt(t)===95?(e="_",t++):(e=null,_('"_"')),e===null&&(n.charCodeAt(t)===43?(e="+",t++):(e=null,_('"+"')),e===null&&(n.charCodeAt(t)===96?(e="`",t++):(e=null,_('"`"')),e===null&&(n.charCodeAt(t)===39?(e="'",t++):(e=null,_(`"'"`)),e===null&&(n.charCodeAt(t)===126?(e="~",t++):(e=null,_('"~"')))))))))))),e!==null)for(i=[];e!==null;)i.push(e),e=L(),e===null&&(n.charCodeAt(t)===45?(e="-",t++):(e=null,_('"-"')),e===null&&(n.charCodeAt(t)===46?(e=".",t++):(e=null,_('"."')),e===null&&(n.charCodeAt(t)===33?(e="!",t++):(e=null,_('"!"')),e===null&&(n.charCodeAt(t)===37?(e="%",t++):(e=null,_('"%"')),e===null&&(n.charCodeAt(t)===42?(e="*",t++):(e=null,_('"*"')),e===null&&(n.charCodeAt(t)===95?(e="_",t++):(e=null,_('"_"')),e===null&&(n.charCodeAt(t)===43?(e="+",t++):(e=null,_('"+"')),e===null&&(n.charCodeAt(t)===96?(e="`",t++):(e=null,_('"`"')),e===null&&(n.charCodeAt(t)===39?(e="'",t++):(e=null,_(`"'"`)),e===null&&(n.charCodeAt(t)===126?(e="~",t++):(e=null,_('"~"'))))))))))));else i=null;return i!==null&&(i=function(u){return n.substring(t,u)}(l)),i===null&&(t=l),i}function P(){var i,e,l;if(l=t,e=L(),e===null&&(n.charCodeAt(t)===45?(e="-",t++):(e=null,_('"-"')),e===null&&(n.charCodeAt(t)===33?(e="!",t++):(e=null,_('"!"')),e===null&&(n.charCodeAt(t)===37?(e="%",t++):(e=null,_('"%"')),e===null&&(n.charCodeAt(t)===42?(e="*",t++):(e=null,_('"*"')),e===null&&(n.charCodeAt(t)===95?(e="_",t++):(e=null,_('"_"')),e===null&&(n.charCodeAt(t)===43?(e="+",t++):(e=null,_('"+"')),e===null&&(n.charCodeAt(t)===96?(e="`",t++):(e=null,_('"`"')),e===null&&(n.charCodeAt(t)===39?(e="'",t++):(e=null,_(`"'"`)),e===null&&(n.charCodeAt(t)===126?(e="~",t++):(e=null,_('"~"'))))))))))),e!==null)for(i=[];e!==null;)i.push(e),e=L(),e===null&&(n.charCodeAt(t)===45?(e="-",t++):(e=null,_('"-"')),e===null&&(n.charCodeAt(t)===33?(e="!",t++):(e=null,_('"!"')),e===null&&(n.charCodeAt(t)===37?(e="%",t++):(e=null,_('"%"')),e===null&&(n.charCodeAt(t)===42?(e="*",t++):(e=null,_('"*"')),e===null&&(n.charCodeAt(t)===95?(e="_",t++):(e=null,_('"_"')),e===null&&(n.charCodeAt(t)===43?(e="+",t++):(e=null,_('"+"')),e===null&&(n.charCodeAt(t)===96?(e="`",t++):(e=null,_('"`"')),e===null&&(n.charCodeAt(t)===39?(e="'",t++):(e=null,_(`"'"`)),e===null&&(n.charCodeAt(t)===126?(e="~",t++):(e=null,_('"~"')))))))))));else i=null;return i!==null&&(i=function(u){return n.substring(t,u)}(l)),i===null&&(t=l),i}function Z(){var i;return n.charCodeAt(t)===40?(i="(",t++):(i=null,_('"("')),i===null&&(n.charCodeAt(t)===41?(i=")",t++):(i=null,_('")"')),i===null&&(n.charCodeAt(t)===60?(i="<",t++):(i=null,_('"<"')),i===null&&(n.charCodeAt(t)===62?(i=">",t++):(i=null,_('">"')),i===null&&(n.charCodeAt(t)===64?(i="@",t++):(i=null,_('"@"')),i===null&&(n.charCodeAt(t)===44?(i=",",t++):(i=null,_('","')),i===null&&(n.charCodeAt(t)===59?(i=";",t++):(i=null,_('";"')),i===null&&(n.charCodeAt(t)===58?(i=":",t++):(i=null,_('":"')),i===null&&(n.charCodeAt(t)===92?(i="\\",t++):(i=null,_('"\\\\"')),i===null&&(i=I(),i===null&&(n.charCodeAt(t)===47?(i="/",t++):(i=null,_('"/"')),i===null&&(n.charCodeAt(t)===91?(i="[",t++):(i=null,_('"["')),i===null&&(n.charCodeAt(t)===93?(i="]",t++):(i=null,_('"]"')),i===null&&(n.charCodeAt(t)===63?(i="?",t++):(i=null,_('"?"')),i===null&&(n.charCodeAt(t)===61?(i="=",t++):(i=null,_('"="')),i===null&&(n.charCodeAt(t)===123?(i="{",t++):(i=null,_('"{"')),i===null&&(n.charCodeAt(t)===125?(i="}",t++):(i=null,_('"}"')),i===null&&(i=w(),i===null&&(i=F())))))))))))))))))),i}function et(){var i,e,l;if(l=t,e=L(),e===null&&(n.charCodeAt(t)===45?(e="-",t++):(e=null,_('"-"')),e===null&&(n.charCodeAt(t)===46?(e=".",t++):(e=null,_('"."')),e===null&&(n.charCodeAt(t)===33?(e="!",t++):(e=null,_('"!"')),e===null&&(n.charCodeAt(t)===37?(e="%",t++):(e=null,_('"%"')),e===null&&(n.charCodeAt(t)===42?(e="*",t++):(e=null,_('"*"')),e===null&&(n.charCodeAt(t)===95?(e="_",t++):(e=null,_('"_"')),e===null&&(n.charCodeAt(t)===43?(e="+",t++):(e=null,_('"+"')),e===null&&(n.charCodeAt(t)===96?(e="`",t++):(e=null,_('"`"')),e===null&&(n.charCodeAt(t)===39?(e="'",t++):(e=null,_(`"'"`)),e===null&&(n.charCodeAt(t)===126?(e="~",t++):(e=null,_('"~"')),e===null&&(n.charCodeAt(t)===40?(e="(",t++):(e=null,_('"("')),e===null&&(n.charCodeAt(t)===41?(e=")",t++):(e=null,_('")"')),e===null&&(n.charCodeAt(t)===60?(e="<",t++):(e=null,_('"<"')),e===null&&(n.charCodeAt(t)===62?(e=">",t++):(e=null,_('">"')),e===null&&(n.charCodeAt(t)===58?(e=":",t++):(e=null,_('":"')),e===null&&(n.charCodeAt(t)===92?(e="\\",t++):(e=null,_('"\\\\"')),e===null&&(e=I(),e===null&&(n.charCodeAt(t)===47?(e="/",t++):(e=null,_('"/"')),e===null&&(n.charCodeAt(t)===91?(e="[",t++):(e=null,_('"["')),e===null&&(n.charCodeAt(t)===93?(e="]",t++):(e=null,_('"]"')),e===null&&(n.charCodeAt(t)===63?(e="?",t++):(e=null,_('"?"')),e===null&&(n.charCodeAt(t)===123?(e="{",t++):(e=null,_('"{"')),e===null&&(n.charCodeAt(t)===125?(e="}",t++):(e=null,_('"}"'))))))))))))))))))))))))),e!==null)for(i=[];e!==null;)i.push(e),e=L(),e===null&&(n.charCodeAt(t)===45?(e="-",t++):(e=null,_('"-"')),e===null&&(n.charCodeAt(t)===46?(e=".",t++):(e=null,_('"."')),e===null&&(n.charCodeAt(t)===33?(e="!",t++):(e=null,_('"!"')),e===null&&(n.charCodeAt(t)===37?(e="%",t++):(e=null,_('"%"')),e===null&&(n.charCodeAt(t)===42?(e="*",t++):(e=null,_('"*"')),e===null&&(n.charCodeAt(t)===95?(e="_",t++):(e=null,_('"_"')),e===null&&(n.charCodeAt(t)===43?(e="+",t++):(e=null,_('"+"')),e===null&&(n.charCodeAt(t)===96?(e="`",t++):(e=null,_('"`"')),e===null&&(n.charCodeAt(t)===39?(e="'",t++):(e=null,_(`"'"`)),e===null&&(n.charCodeAt(t)===126?(e="~",t++):(e=null,_('"~"')),e===null&&(n.charCodeAt(t)===40?(e="(",t++):(e=null,_('"("')),e===null&&(n.charCodeAt(t)===41?(e=")",t++):(e=null,_('")"')),e===null&&(n.charCodeAt(t)===60?(e="<",t++):(e=null,_('"<"')),e===null&&(n.charCodeAt(t)===62?(e=">",t++):(e=null,_('">"')),e===null&&(n.charCodeAt(t)===58?(e=":",t++):(e=null,_('":"')),e===null&&(n.charCodeAt(t)===92?(e="\\",t++):(e=null,_('"\\\\"')),e===null&&(e=I(),e===null&&(n.charCodeAt(t)===47?(e="/",t++):(e=null,_('"/"')),e===null&&(n.charCodeAt(t)===91?(e="[",t++):(e=null,_('"["')),e===null&&(n.charCodeAt(t)===93?(e="]",t++):(e=null,_('"]"')),e===null&&(n.charCodeAt(t)===63?(e="?",t++):(e=null,_('"?"')),e===null&&(n.charCodeAt(t)===123?(e="{",t++):(e=null,_('"{"')),e===null&&(n.charCodeAt(t)===125?(e="}",t++):(e=null,_('"}"')))))))))))))))))))))))));else i=null;return i!==null&&(i=function(u){return n.substring(t,u)}(l)),i===null&&(t=l),i}function Q(){var i,e,l,u,f;return u=t,f=t,i=M(),i!==null?(n.charCodeAt(t)===42?(e="*",t++):(e=null,_('"*"')),e!==null?(l=M(),l!==null?i=[i,e,l]:(i=null,t=f)):(i=null,t=f)):(i=null,t=f),i!==null&&(i=function(h){return"*"}()),i===null&&(t=u),i}function W(){var i,e,l,u,f;return u=t,f=t,i=M(),i!==null?(n.charCodeAt(t)===47?(e="/",t++):(e=null,_('"/"')),e!==null?(l=M(),l!==null?i=[i,e,l]:(i=null,t=f)):(i=null,t=f)):(i=null,t=f),i!==null&&(i=function(h){return"/"}()),i===null&&(t=u),i}function B(){var i,e,l,u,f;return u=t,f=t,i=M(),i!==null?(n.charCodeAt(t)===61?(e="=",t++):(e=null,_('"="')),e!==null?(l=M(),l!==null?i=[i,e,l]:(i=null,t=f)):(i=null,t=f)):(i=null,t=f),i!==null&&(i=function(h){return"="}()),i===null&&(t=u),i}function te(){var i,e,l,u,f;return u=t,f=t,i=M(),i!==null?(n.charCodeAt(t)===40?(e="(",t++):(e=null,_('"("')),e!==null?(l=M(),l!==null?i=[i,e,l]:(i=null,t=f)):(i=null,t=f)):(i=null,t=f),i!==null&&(i=function(h){return"("}()),i===null&&(t=u),i}function de(){var i,e,l,u,f;return u=t,f=t,i=M(),i!==null?(n.charCodeAt(t)===41?(e=")",t++):(e=null,_('")"')),e!==null?(l=M(),l!==null?i=[i,e,l]:(i=null,t=f)):(i=null,t=f)):(i=null,t=f),i!==null&&(i=function(h){return")"}()),i===null&&(t=u),i}function Ae(){var i,e,l,u;return l=t,u=t,n.charCodeAt(t)===62?(i=">",t++):(i=null,_('">"')),i!==null?(e=M(),e!==null?i=[i,e]:(i=null,t=u)):(i=null,t=u),i!==null&&(i=function(f){return">"}()),i===null&&(t=l),i}function Ue(){var i,e,l,u;return l=t,u=t,i=M(),i!==null?(n.charCodeAt(t)===60?(e="<",t++):(e=null,_('"<"')),e!==null?i=[i,e]:(i=null,t=u)):(i=null,t=u),i!==null&&(i=function(f){return"<"}()),i===null&&(t=l),i}function Se(){var i,e,l,u,f;return u=t,f=t,i=M(),i!==null?(n.charCodeAt(t)===44?(e=",",t++):(e=null,_('","')),e!==null?(l=M(),l!==null?i=[i,e,l]:(i=null,t=f)):(i=null,t=f)):(i=null,t=f),i!==null&&(i=function(h){return","}()),i===null&&(t=u),i}function ne(){var i,e,l,u,f;return u=t,f=t,i=M(),i!==null?(n.charCodeAt(t)===59?(e=";",t++):(e=null,_('";"')),e!==null?(l=M(),l!==null?i=[i,e,l]:(i=null,t=f)):(i=null,t=f)):(i=null,t=f),i!==null&&(i=function(h){return";"}()),i===null&&(t=u),i}function Te(){var i,e,l,u,f;return u=t,f=t,i=M(),i!==null?(n.charCodeAt(t)===58?(e=":",t++):(e=null,_('":"')),e!==null?(l=M(),l!==null?i=[i,e,l]:(i=null,t=f)):(i=null,t=f)):(i=null,t=f),i!==null&&(i=function(h){return":"}()),i===null&&(t=u),i}function tt(){var i,e,l,u;return l=t,u=t,i=M(),i!==null?(e=I(),e!==null?i=[i,e]:(i=null,t=u)):(i=null,t=u),i!==null&&(i=function(f){return'"'}()),i===null&&(t=l),i}function st(){var i,e,l,u;return l=t,u=t,i=I(),i!==null?(e=M(),e!==null?i=[i,e]:(i=null,t=u)):(i=null,t=u),i!==null&&(i=function(f){return'"'}()),i===null&&(t=l),i}function ge(){var i,e,l,u;if(u=t,i=te(),i!==null){for(e=[],l=Ee(),l===null&&(l=ce(),l===null&&(l=ge()));l!==null;)e.push(l),l=Ee(),l===null&&(l=ce(),l===null&&(l=ge()));e!==null?(l=de(),l!==null?i=[i,e,l]:(i=null,t=u)):(i=null,t=u)}else i=null,t=u;return i}function Ee(){var i;return/^[!-']/.test(n.charAt(t))?(i=n.charAt(t),t++):(i=null,_("[!-']")),i===null&&(/^[*-[]/.test(n.charAt(t))?(i=n.charAt(t),t++):(i=null,_("[*-[]")),i===null&&(/^[\]-~]/.test(n.charAt(t))?(i=n.charAt(t),t++):(i=null,_("[\\]-~]")),i===null&&(i=Y(),i===null&&(i=me())))),i}function Ce(){var i,e,l,u,f,h;if(f=t,h=t,i=M(),i!==null)if(e=I(),e!==null){for(l=[],u=_e(),u===null&&(u=ce());u!==null;)l.push(u),u=_e(),u===null&&(u=ce());l!==null?(u=I(),u!==null?i=[i,e,l,u]:(i=null,t=h)):(i=null,t=h)}else i=null,t=h;else i=null,t=h;return i!==null&&(i=function(m){return n.substring(t,m)}(f)),i===null&&(t=f),i}function be(){var i,e,l,u,f,h;if(f=t,h=t,i=M(),i!==null)if(e=I(),e!==null){for(l=[],u=_e(),u===null&&(u=ce());u!==null;)l.push(u),u=_e(),u===null&&(u=ce());l!==null?(u=I(),u!==null?i=[i,e,l,u]:(i=null,t=h)):(i=null,t=h)}else i=null,t=h;else i=null,t=h;return i!==null&&(i=function(m){var T=n.substring(t,m).trim();return T.substring(1,T.length-1).replace(/\\([\x00-\x09\x0b-\x0c\x0e-\x7f])/g,"$1")}(f)),i===null&&(t=f),i}function _e(){var i;return i=me(),i===null&&(n.charCodeAt(t)===33?(i="!",t++):(i=null,_('"!"')),i===null&&(/^[#-[]/.test(n.charAt(t))?(i=n.charAt(t),t++):(i=null,_("[#-[]")),i===null&&(/^[\]-~]/.test(n.charAt(t))?(i=n.charAt(t),t++):(i=null,_("[\\]-~]")),i===null&&(i=Y())))),i}function ce(){var i,e,l;return l=t,n.charCodeAt(t)===92?(i="\\",t++):(i=null,_('"\\\\"')),i!==null?(/^[\0-\t]/.test(n.charAt(t))?(e=n.charAt(t),t++):(e=null,_("[\\0-\\t]")),e===null&&(/^[\x0B-\f]/.test(n.charAt(t))?(e=n.charAt(t),t++):(e=null,_("[\\x0B-\\f]")),e===null&&(/^[\x0E-]/.test(n.charAt(t))?(e=n.charAt(t),t++):(e=null,_("[\\x0E-]")))),e!==null?i=[i,e]:(i=null,t=l)):(i=null,t=l),i}function fe(){var i,e,l,u,f,h;return f=t,h=t,i=Oe(),i!==null?(n.charCodeAt(t)===58?(e=":",t++):(e=null,_('":"')),e!==null?(l=Ut(),l=l!==null?l:"",l!==null?(u=Ys(),u!==null?i=[i,e,l,u]:(i=null,t=h)):(i=null,t=h)):(i=null,t=h)):(i=null,t=h),i!==null&&(i=function(m){try{R.uri=new Ao(R.scheme,R.user,R.host,R.port),delete R.scheme,delete R.user,delete R.host,delete R.host_type,delete R.port}catch{R=-1}}()),i===null&&(t=f),i}function Re(){var i,e,l,u,f,h,m,T;return m=t,T=t,i=Oe(),i!==null?(n.charCodeAt(t)===58?(e=":",t++):(e=null,_('":"')),e!==null?(l=Ut(),l=l!==null?l:"",l!==null?(u=Ys(),u!==null?(f=Br(),f!==null?(h=Zr(),h=h!==null?h:"",h!==null?i=[i,e,l,u,f,h]:(i=null,t=T)):(i=null,t=T)):(i=null,t=T)):(i=null,t=T)):(i=null,t=T)):(i=null,t=T),i!==null&&(i=function(y){try{R.uri=new Ao(R.scheme,R.user,R.host,R.port,R.uri_params,R.uri_headers),delete R.scheme,delete R.user,delete R.host,delete R.host_type,delete R.port,delete R.uri_params,o==="SIP_URI"&&(R=R.uri)}catch{R=-1}}()),i===null&&(t=m),i}function Oe(){var i;return i=Je(),i===null&&(i=Me()),i}function Je(){var i,e;return e=t,n.substr(t,4).toLowerCase()==="sips"?(i=n.substr(t,4),t+=4):(i=null,_('"sips"')),i!==null&&(i=function(l,u){R.scheme=u.toLowerCase()}(e,i)),i===null&&(t=e),i}function Me(){var i,e;return e=t,n.substr(t,3).toLowerCase()==="sip"?(i=n.substr(t,3),t+=3):(i=null,_('"sip"')),i!==null&&(i=function(l,u){R.scheme=u.toLowerCase()}(e,i)),i===null&&(t=e),i}function Ut(){var i,e,l,u,f,h;return u=t,f=t,i=gt(),i!==null?(h=t,n.charCodeAt(t)===58?(e=":",t++):(e=null,_('":"')),e!==null?(l=On(),l!==null?e=[e,l]:(e=null,t=h)):(e=null,t=h),e=e!==null?e:"",e!==null?(n.charCodeAt(t)===64?(l="@",t++):(l=null,_('"@"')),l!==null?i=[i,e,l]:(i=null,t=f)):(i=null,t=f)):(i=null,t=f),i!==null&&(i=function(m){R.user=decodeURIComponent(n.substring(t-1,m))}(u)),i===null&&(t=u),i}function gt(){var i,e;if(e=N(),e===null&&(e=ve(),e===null&&(e=wn())),e!==null)for(i=[];e!==null;)i.push(e),e=N(),e===null&&(e=ve(),e===null&&(e=wn()));else i=null;return i}function wn(){var i;return n.charCodeAt(t)===38?(i="&",t++):(i=null,_('"&"')),i===null&&(n.charCodeAt(t)===61?(i="=",t++):(i=null,_('"="')),i===null&&(n.charCodeAt(t)===43?(i="+",t++):(i=null,_('"+"')),i===null&&(n.charCodeAt(t)===36?(i="$",t++):(i=null,_('"$"')),i===null&&(n.charCodeAt(t)===44?(i=",",t++):(i=null,_('","')),i===null&&(n.charCodeAt(t)===59?(i=";",t++):(i=null,_('";"')),i===null&&(n.charCodeAt(t)===63?(i="?",t++):(i=null,_('"?"')),i===null&&(n.charCodeAt(t)===47?(i="/",t++):(i=null,_('"/"'))))))))),i}function On(){var i,e,l;for(l=t,i=[],e=N(),e===null&&(e=ve(),e===null&&(n.charCodeAt(t)===38?(e="&",t++):(e=null,_('"&"')),e===null&&(n.charCodeAt(t)===61?(e="=",t++):(e=null,_('"="')),e===null&&(n.charCodeAt(t)===43?(e="+",t++):(e=null,_('"+"')),e===null&&(n.charCodeAt(t)===36?(e="$",t++):(e=null,_('"$"')),e===null&&(n.charCodeAt(t)===44?(e=",",t++):(e=null,_('","'))))))));e!==null;)i.push(e),e=N(),e===null&&(e=ve(),e===null&&(n.charCodeAt(t)===38?(e="&",t++):(e=null,_('"&"')),e===null&&(n.charCodeAt(t)===61?(e="=",t++):(e=null,_('"="')),e===null&&(n.charCodeAt(t)===43?(e="+",t++):(e=null,_('"+"')),e===null&&(n.charCodeAt(t)===36?(e="$",t++):(e=null,_('"$"')),e===null&&(n.charCodeAt(t)===44?(e=",",t++):(e=null,_('","'))))))));return i!==null&&(i=function(u){R.password=n.substring(t,u)}(l)),i===null&&(t=l),i}function Ys(){var i,e,l,u,f;return u=t,i=Xt(),i!==null?(f=t,n.charCodeAt(t)===58?(e=":",t++):(e=null,_('":"')),e!==null?(l=Rs(),l!==null?e=[e,l]:(e=null,t=f)):(e=null,t=f),e=e!==null?e:"",e!==null?i=[i,e]:(i=null,t=u)):(i=null,t=u),i}function Xt(){var i,e;return e=t,i=_s(),i===null&&(i=nt(),i===null&&(i=Nn())),i!==null&&(i=function(l){return R.host=n.substring(t,l).toLowerCase(),R.host}(e)),i===null&&(t=e),i}function _s(){var i,e,l,u,f,h;for(u=t,f=t,i=[],h=t,e=zs(),e!==null?(n.charCodeAt(t)===46?(l=".",t++):(l=null,_('"."')),l!==null?e=[e,l]:(e=null,t=h)):(e=null,t=h);e!==null;)i.push(e),h=t,e=zs(),e!==null?(n.charCodeAt(t)===46?(l=".",t++):(l=null,_('"."')),l!==null?e=[e,l]:(e=null,t=h)):(e=null,t=h);return i!==null?(e=Dn(),e!==null?(n.charCodeAt(t)===46?(l=".",t++):(l=null,_('"."')),l=l!==null?l:"",l!==null?i=[i,e,l]:(i=null,t=f)):(i=null,t=f)):(i=null,t=f),i!==null&&(i=function(m){return R.host_type="domain",n.substring(t,m)}(u)),i===null&&(t=u),i}function zs(){var i,e,l,u;if(u=t,i=L(),i!==null){for(e=[],l=L(),l===null&&(n.charCodeAt(t)===45?(l="-",t++):(l=null,_('"-"')),l===null&&(n.charCodeAt(t)===95?(l="_",t++):(l=null,_('"_"'))));l!==null;)e.push(l),l=L(),l===null&&(n.charCodeAt(t)===45?(l="-",t++):(l=null,_('"-"')),l===null&&(n.charCodeAt(t)===95?(l="_",t++):(l=null,_('"_"'))));e!==null?i=[i,e]:(i=null,t=u)}else i=null,t=u;return i}function Dn(){var i,e,l,u;if(u=t,i=v(),i!==null){for(e=[],l=L(),l===null&&(n.charCodeAt(t)===45?(l="-",t++):(l=null,_('"-"')),l===null&&(n.charCodeAt(t)===95?(l="_",t++):(l=null,_('"_"'))));l!==null;)e.push(l),l=L(),l===null&&(n.charCodeAt(t)===45?(l="-",t++):(l=null,_('"-"')),l===null&&(n.charCodeAt(t)===95?(l="_",t++):(l=null,_('"_"'))));e!==null?i=[i,e]:(i=null,t=u)}else i=null,t=u;return i}function Nn(){var i,e,l,u,f;return u=t,f=t,n.charCodeAt(t)===91?(i="[",t++):(i=null,_('"["')),i!==null?(e=Js(),e!==null?(n.charCodeAt(t)===93?(l="]",t++):(l=null,_('"]"')),l!==null?i=[i,e,l]:(i=null,t=f)):(i=null,t=f)):(i=null,t=f),i!==null&&(i=function(h){return R.host_type="IPv6",n.substring(t,h)}(u)),i===null&&(t=u),i}function Js(){var i,e,l,u,f,h,m,T,y,O,se,De,Ct,xs,x,A;return xs=t,x=t,i=he(),i!==null?(n.charCodeAt(t)===58?(e=":",t++):(e=null,_('":"')),e!==null?(l=he(),l!==null?(n.charCodeAt(t)===58?(u=":",t++):(u=null,_('":"')),u!==null?(f=he(),f!==null?(n.charCodeAt(t)===58?(h=":",t++):(h=null,_('":"')),h!==null?(m=he(),m!==null?(n.charCodeAt(t)===58?(T=":",t++):(T=null,_('":"')),T!==null?(y=he(),y!==null?(n.charCodeAt(t)===58?(O=":",t++):(O=null,_('":"')),O!==null?(se=he(),se!==null?(n.charCodeAt(t)===58?(De=":",t++):(De=null,_('":"')),De!==null?(Ct=re(),Ct!==null?i=[i,e,l,u,f,h,m,T,y,O,se,De,Ct]:(i=null,t=x)):(i=null,t=x)):(i=null,t=x)):(i=null,t=x)):(i=null,t=x)):(i=null,t=x)):(i=null,t=x)):(i=null,t=x)):(i=null,t=x)):(i=null,t=x)):(i=null,t=x)):(i=null,t=x)):(i=null,t=x),i===null&&(x=t,n.substr(t,2)==="::"?(i="::",t+=2):(i=null,_('"::"')),i!==null?(e=he(),e!==null?(n.charCodeAt(t)===58?(l=":",t++):(l=null,_('":"')),l!==null?(u=he(),u!==null?(n.charCodeAt(t)===58?(f=":",t++):(f=null,_('":"')),f!==null?(h=he(),h!==null?(n.charCodeAt(t)===58?(m=":",t++):(m=null,_('":"')),m!==null?(T=he(),T!==null?(n.charCodeAt(t)===58?(y=":",t++):(y=null,_('":"')),y!==null?(O=he(),O!==null?(n.charCodeAt(t)===58?(se=":",t++):(se=null,_('":"')),se!==null?(De=re(),De!==null?i=[i,e,l,u,f,h,m,T,y,O,se,De]:(i=null,t=x)):(i=null,t=x)):(i=null,t=x)):(i=null,t=x)):(i=null,t=x)):(i=null,t=x)):(i=null,t=x)):(i=null,t=x)):(i=null,t=x)):(i=null,t=x)):(i=null,t=x)):(i=null,t=x),i===null&&(x=t,n.substr(t,2)==="::"?(i="::",t+=2):(i=null,_('"::"')),i!==null?(e=he(),e!==null?(n.charCodeAt(t)===58?(l=":",t++):(l=null,_('":"')),l!==null?(u=he(),u!==null?(n.charCodeAt(t)===58?(f=":",t++):(f=null,_('":"')),f!==null?(h=he(),h!==null?(n.charCodeAt(t)===58?(m=":",t++):(m=null,_('":"')),m!==null?(T=he(),T!==null?(n.charCodeAt(t)===58?(y=":",t++):(y=null,_('":"')),y!==null?(O=re(),O!==null?i=[i,e,l,u,f,h,m,T,y,O]:(i=null,t=x)):(i=null,t=x)):(i=null,t=x)):(i=null,t=x)):(i=null,t=x)):(i=null,t=x)):(i=null,t=x)):(i=null,t=x)):(i=null,t=x)):(i=null,t=x),i===null&&(x=t,n.substr(t,2)==="::"?(i="::",t+=2):(i=null,_('"::"')),i!==null?(e=he(),e!==null?(n.charCodeAt(t)===58?(l=":",t++):(l=null,_('":"')),l!==null?(u=he(),u!==null?(n.charCodeAt(t)===58?(f=":",t++):(f=null,_('":"')),f!==null?(h=he(),h!==null?(n.charCodeAt(t)===58?(m=":",t++):(m=null,_('":"')),m!==null?(T=re(),T!==null?i=[i,e,l,u,f,h,m,T]:(i=null,t=x)):(i=null,t=x)):(i=null,t=x)):(i=null,t=x)):(i=null,t=x)):(i=null,t=x)):(i=null,t=x)):(i=null,t=x),i===null&&(x=t,n.substr(t,2)==="::"?(i="::",t+=2):(i=null,_('"::"')),i!==null?(e=he(),e!==null?(n.charCodeAt(t)===58?(l=":",t++):(l=null,_('":"')),l!==null?(u=he(),u!==null?(n.charCodeAt(t)===58?(f=":",t++):(f=null,_('":"')),f!==null?(h=re(),h!==null?i=[i,e,l,u,f,h]:(i=null,t=x)):(i=null,t=x)):(i=null,t=x)):(i=null,t=x)):(i=null,t=x)):(i=null,t=x),i===null&&(x=t,n.substr(t,2)==="::"?(i="::",t+=2):(i=null,_('"::"')),i!==null?(e=he(),e!==null?(n.charCodeAt(t)===58?(l=":",t++):(l=null,_('":"')),l!==null?(u=re(),u!==null?i=[i,e,l,u]:(i=null,t=x)):(i=null,t=x)):(i=null,t=x)):(i=null,t=x),i===null&&(x=t,n.substr(t,2)==="::"?(i="::",t+=2):(i=null,_('"::"')),i!==null?(e=re(),e!==null?i=[i,e]:(i=null,t=x)):(i=null,t=x),i===null&&(x=t,n.substr(t,2)==="::"?(i="::",t+=2):(i=null,_('"::"')),i!==null?(e=he(),e!==null?i=[i,e]:(i=null,t=x)):(i=null,t=x),i===null&&(x=t,i=he(),i!==null?(n.substr(t,2)==="::"?(e="::",t+=2):(e=null,_('"::"')),e!==null?(l=he(),l!==null?(n.charCodeAt(t)===58?(u=":",t++):(u=null,_('":"')),u!==null?(f=he(),f!==null?(n.charCodeAt(t)===58?(h=":",t++):(h=null,_('":"')),h!==null?(m=he(),m!==null?(n.charCodeAt(t)===58?(T=":",t++):(T=null,_('":"')),T!==null?(y=he(),y!==null?(n.charCodeAt(t)===58?(O=":",t++):(O=null,_('":"')),O!==null?(se=re(),se!==null?i=[i,e,l,u,f,h,m,T,y,O,se]:(i=null,t=x)):(i=null,t=x)):(i=null,t=x)):(i=null,t=x)):(i=null,t=x)):(i=null,t=x)):(i=null,t=x)):(i=null,t=x)):(i=null,t=x)):(i=null,t=x)):(i=null,t=x),i===null&&(x=t,i=he(),i!==null?(A=t,n.charCodeAt(t)===58?(e=":",t++):(e=null,_('":"')),e!==null?(l=he(),l!==null?e=[e,l]:(e=null,t=A)):(e=null,t=A),e=e!==null?e:"",e!==null?(n.substr(t,2)==="::"?(l="::",t+=2):(l=null,_('"::"')),l!==null?(u=he(),u!==null?(n.charCodeAt(t)===58?(f=":",t++):(f=null,_('":"')),f!==null?(h=he(),h!==null?(n.charCodeAt(t)===58?(m=":",t++):(m=null,_('":"')),m!==null?(T=he(),T!==null?(n.charCodeAt(t)===58?(y=":",t++):(y=null,_('":"')),y!==null?(O=re(),O!==null?i=[i,e,l,u,f,h,m,T,y,O]:(i=null,t=x)):(i=null,t=x)):(i=null,t=x)):(i=null,t=x)):(i=null,t=x)):(i=null,t=x)):(i=null,t=x)):(i=null,t=x)):(i=null,t=x)):(i=null,t=x),i===null&&(x=t,i=he(),i!==null?(A=t,n.charCodeAt(t)===58?(e=":",t++):(e=null,_('":"')),e!==null?(l=he(),l!==null?e=[e,l]:(e=null,t=A)):(e=null,t=A),e=e!==null?e:"",e!==null?(A=t,n.charCodeAt(t)===58?(l=":",t++):(l=null,_('":"')),l!==null?(u=he(),u!==null?l=[l,u]:(l=null,t=A)):(l=null,t=A),l=l!==null?l:"",l!==null?(n.substr(t,2)==="::"?(u="::",t+=2):(u=null,_('"::"')),u!==null?(f=he(),f!==null?(n.charCodeAt(t)===58?(h=":",t++):(h=null,_('":"')),h!==null?(m=he(),m!==null?(n.charCodeAt(t)===58?(T=":",t++):(T=null,_('":"')),T!==null?(y=re(),y!==null?i=[i,e,l,u,f,h,m,T,y]:(i=null,t=x)):(i=null,t=x)):(i=null,t=x)):(i=null,t=x)):(i=null,t=x)):(i=null,t=x)):(i=null,t=x)):(i=null,t=x)):(i=null,t=x),i===null&&(x=t,i=he(),i!==null?(A=t,n.charCodeAt(t)===58?(e=":",t++):(e=null,_('":"')),e!==null?(l=he(),l!==null?e=[e,l]:(e=null,t=A)):(e=null,t=A),e=e!==null?e:"",e!==null?(A=t,n.charCodeAt(t)===58?(l=":",t++):(l=null,_('":"')),l!==null?(u=he(),u!==null?l=[l,u]:(l=null,t=A)):(l=null,t=A),l=l!==null?l:"",l!==null?(A=t,n.charCodeAt(t)===58?(u=":",t++):(u=null,_('":"')),u!==null?(f=he(),f!==null?u=[u,f]:(u=null,t=A)):(u=null,t=A),u=u!==null?u:"",u!==null?(n.substr(t,2)==="::"?(f="::",t+=2):(f=null,_('"::"')),f!==null?(h=he(),h!==null?(n.charCodeAt(t)===58?(m=":",t++):(m=null,_('":"')),m!==null?(T=re(),T!==null?i=[i,e,l,u,f,h,m,T]:(i=null,t=x)):(i=null,t=x)):(i=null,t=x)):(i=null,t=x)):(i=null,t=x)):(i=null,t=x)):(i=null,t=x)):(i=null,t=x),i===null&&(x=t,i=he(),i!==null?(A=t,n.charCodeAt(t)===58?(e=":",t++):(e=null,_('":"')),e!==null?(l=he(),l!==null?e=[e,l]:(e=null,t=A)):(e=null,t=A),e=e!==null?e:"",e!==null?(A=t,n.charCodeAt(t)===58?(l=":",t++):(l=null,_('":"')),l!==null?(u=he(),u!==null?l=[l,u]:(l=null,t=A)):(l=null,t=A),l=l!==null?l:"",l!==null?(A=t,n.charCodeAt(t)===58?(u=":",t++):(u=null,_('":"')),u!==null?(f=he(),f!==null?u=[u,f]:(u=null,t=A)):(u=null,t=A),u=u!==null?u:"",u!==null?(A=t,n.charCodeAt(t)===58?(f=":",t++):(f=null,_('":"')),f!==null?(h=he(),h!==null?f=[f,h]:(f=null,t=A)):(f=null,t=A),f=f!==null?f:"",f!==null?(n.substr(t,2)==="::"?(h="::",t+=2):(h=null,_('"::"')),h!==null?(m=re(),m!==null?i=[i,e,l,u,f,h,m]:(i=null,t=x)):(i=null,t=x)):(i=null,t=x)):(i=null,t=x)):(i=null,t=x)):(i=null,t=x)):(i=null,t=x),i===null&&(x=t,i=he(),i!==null?(A=t,n.charCodeAt(t)===58?(e=":",t++):(e=null,_('":"')),e!==null?(l=he(),l!==null?e=[e,l]:(e=null,t=A)):(e=null,t=A),e=e!==null?e:"",e!==null?(A=t,n.charCodeAt(t)===58?(l=":",t++):(l=null,_('":"')),l!==null?(u=he(),u!==null?l=[l,u]:(l=null,t=A)):(l=null,t=A),l=l!==null?l:"",l!==null?(A=t,n.charCodeAt(t)===58?(u=":",t++):(u=null,_('":"')),u!==null?(f=he(),f!==null?u=[u,f]:(u=null,t=A)):(u=null,t=A),u=u!==null?u:"",u!==null?(A=t,n.charCodeAt(t)===58?(f=":",t++):(f=null,_('":"')),f!==null?(h=he(),h!==null?f=[f,h]:(f=null,t=A)):(f=null,t=A),f=f!==null?f:"",f!==null?(A=t,n.charCodeAt(t)===58?(h=":",t++):(h=null,_('":"')),h!==null?(m=he(),m!==null?h=[h,m]:(h=null,t=A)):(h=null,t=A),h=h!==null?h:"",h!==null?(n.substr(t,2)==="::"?(m="::",t+=2):(m=null,_('"::"')),m!==null?(T=he(),T!==null?i=[i,e,l,u,f,h,m,T]:(i=null,t=x)):(i=null,t=x)):(i=null,t=x)):(i=null,t=x)):(i=null,t=x)):(i=null,t=x)):(i=null,t=x)):(i=null,t=x),i===null&&(x=t,i=he(),i!==null?(A=t,n.charCodeAt(t)===58?(e=":",t++):(e=null,_('":"')),e!==null?(l=he(),l!==null?e=[e,l]:(e=null,t=A)):(e=null,t=A),e=e!==null?e:"",e!==null?(A=t,n.charCodeAt(t)===58?(l=":",t++):(l=null,_('":"')),l!==null?(u=he(),u!==null?l=[l,u]:(l=null,t=A)):(l=null,t=A),l=l!==null?l:"",l!==null?(A=t,n.charCodeAt(t)===58?(u=":",t++):(u=null,_('":"')),u!==null?(f=he(),f!==null?u=[u,f]:(u=null,t=A)):(u=null,t=A),u=u!==null?u:"",u!==null?(A=t,n.charCodeAt(t)===58?(f=":",t++):(f=null,_('":"')),f!==null?(h=he(),h!==null?f=[f,h]:(f=null,t=A)):(f=null,t=A),f=f!==null?f:"",f!==null?(A=t,n.charCodeAt(t)===58?(h=":",t++):(h=null,_('":"')),h!==null?(m=he(),m!==null?h=[h,m]:(h=null,t=A)):(h=null,t=A),h=h!==null?h:"",h!==null?(A=t,n.charCodeAt(t)===58?(m=":",t++):(m=null,_('":"')),m!==null?(T=he(),T!==null?m=[m,T]:(m=null,t=A)):(m=null,t=A),m=m!==null?m:"",m!==null?(n.substr(t,2)==="::"?(T="::",t+=2):(T=null,_('"::"')),T!==null?i=[i,e,l,u,f,h,m,T]:(i=null,t=x)):(i=null,t=x)):(i=null,t=x)):(i=null,t=x)):(i=null,t=x)):(i=null,t=x)):(i=null,t=x)):(i=null,t=x))))))))))))))),i!==null&&(i=function(pe){return R.host_type="IPv6",n.substring(t,pe)}(xs)),i===null&&(t=xs),i}function he(){var i,e,l,u,f;return f=t,i=E(),i!==null?(e=E(),e=e!==null?e:"",e!==null?(l=E(),l=l!==null?l:"",l!==null?(u=E(),u=u!==null?u:"",u!==null?i=[i,e,l,u]:(i=null,t=f)):(i=null,t=f)):(i=null,t=f)):(i=null,t=f),i}function re(){var i,e,l,u;return u=t,i=he(),i!==null?(n.charCodeAt(t)===58?(e=":",t++):(e=null,_('":"')),e!==null?(l=he(),l!==null?i=[i,e,l]:(i=null,t=u)):(i=null,t=u)):(i=null,t=u),i===null&&(i=nt()),i}function nt(){var i,e,l,u,f,h,m,T,y;return T=t,y=t,i=Ft(),i!==null?(n.charCodeAt(t)===46?(e=".",t++):(e=null,_('"."')),e!==null?(l=Ft(),l!==null?(n.charCodeAt(t)===46?(u=".",t++):(u=null,_('"."')),u!==null?(f=Ft(),f!==null?(n.charCodeAt(t)===46?(h=".",t++):(h=null,_('"."')),h!==null?(m=Ft(),m!==null?i=[i,e,l,u,f,h,m]:(i=null,t=y)):(i=null,t=y)):(i=null,t=y)):(i=null,t=y)):(i=null,t=y)):(i=null,t=y)):(i=null,t=y),i!==null&&(i=function(O){return R.host_type="IPv4",n.substring(t,O)}(T)),i===null&&(t=T),i}function Ft(){var i,e,l,u;return u=t,n.substr(t,2)==="25"?(i="25",t+=2):(i=null,_('"25"')),i!==null?(/^[0-5]/.test(n.charAt(t))?(e=n.charAt(t),t++):(e=null,_("[0-5]")),e!==null?i=[i,e]:(i=null,t=u)):(i=null,t=u),i===null&&(u=t,n.charCodeAt(t)===50?(i="2",t++):(i=null,_('"2"')),i!==null?(/^[0-4]/.test(n.charAt(t))?(e=n.charAt(t),t++):(e=null,_("[0-4]")),e!==null?(l=g(),l!==null?i=[i,e,l]:(i=null,t=u)):(i=null,t=u)):(i=null,t=u),i===null&&(u=t,n.charCodeAt(t)===49?(i="1",t++):(i=null,_('"1"')),i!==null?(e=g(),e!==null?(l=g(),l!==null?i=[i,e,l]:(i=null,t=u)):(i=null,t=u)):(i=null,t=u),i===null&&(u=t,/^[1-9]/.test(n.charAt(t))?(i=n.charAt(t),t++):(i=null,_("[1-9]")),i!==null?(e=g(),e!==null?i=[i,e]:(i=null,t=u)):(i=null,t=u),i===null&&(i=g())))),i}function Rs(){var i,e,l,u,f,h,m;return h=t,m=t,i=g(),i=i!==null?i:"",i!==null?(e=g(),e=e!==null?e:"",e!==null?(l=g(),l=l!==null?l:"",l!==null?(u=g(),u=u!==null?u:"",u!==null?(f=g(),f=f!==null?f:"",f!==null?i=[i,e,l,u,f]:(i=null,t=m)):(i=null,t=m)):(i=null,t=m)):(i=null,t=m)):(i=null,t=m),i!==null&&(i=function(T,y){return y=parseInt(y.join("")),R.port=y,y}(h,i)),i===null&&(t=h),i}function Br(){var i,e,l,u;for(i=[],u=t,n.charCodeAt(t)===59?(e=";",t++):(e=null,_('";"')),e!==null?(l=Un(),l!==null?e=[e,l]:(e=null,t=u)):(e=null,t=u);e!==null;)i.push(e),u=t,n.charCodeAt(t)===59?(e=";",t++):(e=null,_('";"')),e!==null?(l=Un(),l!==null?e=[e,l]:(e=null,t=u)):(e=null,t=u);return i}function Un(){var i;return i=Pn(),i===null&&(i=Gr(),i===null&&(i=Kr(),i===null&&(i=Wr(),i===null&&(i=Yr(),i===null&&(i=zr(),i===null&&(i=Jr())))))),i}function Pn(){var i,e,l,u;return l=t,u=t,n.substr(t,10).toLowerCase()==="transport="?(i=n.substr(t,10),t+=10):(i=null,_('"transport="')),i!==null?(n.substr(t,3).toLowerCase()==="udp"?(e=n.substr(t,3),t+=3):(e=null,_('"udp"')),e===null&&(n.substr(t,3).toLowerCase()==="tcp"?(e=n.substr(t,3),t+=3):(e=null,_('"tcp"')),e===null&&(n.substr(t,4).toLowerCase()==="sctp"?(e=n.substr(t,4),t+=4):(e=null,_('"sctp"')),e===null&&(n.substr(t,3).toLowerCase()==="tls"?(e=n.substr(t,3),t+=3):(e=null,_('"tls"')),e===null&&(e=U())))),e!==null?i=[i,e]:(i=null,t=u)):(i=null,t=u),i!==null&&(i=function(f,h){R.uri_params||(R.uri_params={}),R.uri_params.transport=h.toLowerCase()}(l,i[1])),i===null&&(t=l),i}function Gr(){var i,e,l,u;return l=t,u=t,n.substr(t,5).toLowerCase()==="user="?(i=n.substr(t,5),t+=5):(i=null,_('"user="')),i!==null?(n.substr(t,5).toLowerCase()==="phone"?(e=n.substr(t,5),t+=5):(e=null,_('"phone"')),e===null&&(n.substr(t,2).toLowerCase()==="ip"?(e=n.substr(t,2),t+=2):(e=null,_('"ip"')),e===null&&(e=U())),e!==null?i=[i,e]:(i=null,t=u)):(i=null,t=u),i!==null&&(i=function(f,h){R.uri_params||(R.uri_params={}),R.uri_params.user=h.toLowerCase()}(l,i[1])),i===null&&(t=l),i}function Kr(){var i,e,l,u;return l=t,u=t,n.substr(t,7).toLowerCase()==="method="?(i=n.substr(t,7),t+=7):(i=null,_('"method="')),i!==null?(e=nn(),e!==null?i=[i,e]:(i=null,t=u)):(i=null,t=u),i!==null&&(i=function(f,h){R.uri_params||(R.uri_params={}),R.uri_params.method=h}(l,i[1])),i===null&&(t=l),i}function Wr(){var i,e,l,u;return l=t,u=t,n.substr(t,4).toLowerCase()==="ttl="?(i=n.substr(t,4),t+=4):(i=null,_('"ttl="')),i!==null?(e=tr(),e!==null?i=[i,e]:(i=null,t=u)):(i=null,t=u),i!==null&&(i=function(f,h){R.params||(R.params={}),R.params.ttl=h}(l,i[1])),i===null&&(t=l),i}function Yr(){var i,e,l,u;return l=t,u=t,n.substr(t,6).toLowerCase()==="maddr="?(i=n.substr(t,6),t+=6):(i=null,_('"maddr="')),i!==null?(e=Xt(),e!==null?i=[i,e]:(i=null,t=u)):(i=null,t=u),i!==null&&(i=function(f,h){R.uri_params||(R.uri_params={}),R.uri_params.maddr=h}(l,i[1])),i===null&&(t=l),i}function zr(){var i,e,l,u,f,h;return u=t,f=t,n.substr(t,2).toLowerCase()==="lr"?(i=n.substr(t,2),t+=2):(i=null,_('"lr"')),i!==null?(h=t,n.charCodeAt(t)===61?(e="=",t++):(e=null,_('"="')),e!==null?(l=U(),l!==null?e=[e,l]:(e=null,t=h)):(e=null,t=h),e=e!==null?e:"",e!==null?i=[i,e]:(i=null,t=f)):(i=null,t=f),i!==null&&(i=function(m){R.uri_params||(R.uri_params={}),R.uri_params.lr=void 0}()),i===null&&(t=u),i}function Jr(){var i,e,l,u,f,h;return u=t,f=t,i=Xr(),i!==null?(h=t,n.charCodeAt(t)===61?(e="=",t++):(e=null,_('"="')),e!==null?(l=Qr(),l!==null?e=[e,l]:(e=null,t=h)):(e=null,t=h),e=e!==null?e:"",e!==null?i=[i,e]:(i=null,t=f)):(i=null,t=f),i!==null&&(i=function(m,T,y){R.uri_params||(R.uri_params={}),typeof y>"u"?y=void 0:y=y[1],R.uri_params[T.toLowerCase()]=y}(u,i[0],i[1])),i===null&&(t=u),i}function Xr(){var i,e,l;if(l=t,e=Is(),e!==null)for(i=[];e!==null;)i.push(e),e=Is();else i=null;return i!==null&&(i=function(u,f){return f.join("")}(l,i)),i===null&&(t=l),i}function Qr(){var i,e,l;if(l=t,e=Is(),e!==null)for(i=[];e!==null;)i.push(e),e=Is();else i=null;return i!==null&&(i=function(u,f){return f.join("")}(l,i)),i===null&&(t=l),i}function Is(){var i;return i=bs(),i===null&&(i=N(),i===null&&(i=ve())),i}function bs(){var i;return n.charCodeAt(t)===91?(i="[",t++):(i=null,_('"["')),i===null&&(n.charCodeAt(t)===93?(i="]",t++):(i=null,_('"]"')),i===null&&(n.charCodeAt(t)===47?(i="/",t++):(i=null,_('"/"')),i===null&&(n.charCodeAt(t)===58?(i=":",t++):(i=null,_('":"')),i===null&&(n.charCodeAt(t)===38?(i="&",t++):(i=null,_('"&"')),i===null&&(n.charCodeAt(t)===43?(i="+",t++):(i=null,_('"+"')),i===null&&(n.charCodeAt(t)===36?(i="$",t++):(i=null,_('"$"')))))))),i}function Zr(){var i,e,l,u,f,h,m;if(h=t,n.charCodeAt(t)===63?(i="?",t++):(i=null,_('"?"')),i!==null)if(e=Xs(),e!==null){for(l=[],m=t,n.charCodeAt(t)===38?(u="&",t++):(u=null,_('"&"')),u!==null?(f=Xs(),f!==null?u=[u,f]:(u=null,t=m)):(u=null,t=m);u!==null;)l.push(u),m=t,n.charCodeAt(t)===38?(u="&",t++):(u=null,_('"&"')),u!==null?(f=Xs(),f!==null?u=[u,f]:(u=null,t=m)):(u=null,t=m);l!==null?i=[i,e,l]:(i=null,t=h)}else i=null,t=h;else i=null,t=h;return i}function Xs(){var i,e,l,u,f;return u=t,f=t,i=Qs(),i!==null?(n.charCodeAt(t)===61?(e="=",t++):(e=null,_('"="')),e!==null?(l=ei(),l!==null?i=[i,e,l]:(i=null,t=f)):(i=null,t=f)):(i=null,t=f),i!==null&&(i=function(h,m,T){m=m.join("").toLowerCase(),T=T.join(""),R.uri_headers||(R.uri_headers={}),R.uri_headers[m]?R.uri_headers[m].push(T):R.uri_headers[m]=[T]}(u,i[0],i[2])),i===null&&(t=u),i}function Qs(){var i,e;if(e=ws(),e===null&&(e=N(),e===null&&(e=ve())),e!==null)for(i=[];e!==null;)i.push(e),e=ws(),e===null&&(e=N(),e===null&&(e=ve()));else i=null;return i}function ei(){var i,e;for(i=[],e=ws(),e===null&&(e=N(),e===null&&(e=ve()));e!==null;)i.push(e),e=ws(),e===null&&(e=N(),e===null&&(e=ve()));return i}function ws(){var i;return n.charCodeAt(t)===91?(i="[",t++):(i=null,_('"["')),i===null&&(n.charCodeAt(t)===93?(i="]",t++):(i=null,_('"]"')),i===null&&(n.charCodeAt(t)===47?(i="/",t++):(i=null,_('"/"')),i===null&&(n.charCodeAt(t)===63?(i="?",t++):(i=null,_('"?"')),i===null&&(n.charCodeAt(t)===58?(i=":",t++):(i=null,_('":"')),i===null&&(n.charCodeAt(t)===43?(i="+",t++):(i=null,_('"+"')),i===null&&(n.charCodeAt(t)===36?(i="$",t++):(i=null,_('"$"')))))))),i}function Zs(){var i;return i=rn(),i===null&&(i=no()),i}function no(){var i,e,l,u,f,h;return h=t,i=nn(),i!==null?(e=w(),e!==null?(l=ti(),l!==null?(u=w(),u!==null?(f=xn(),f!==null?i=[i,e,l,u,f]:(i=null,t=h)):(i=null,t=h)):(i=null,t=h)):(i=null,t=h)):(i=null,t=h),i}function ti(){var i;return i=Re(),i===null&&(i=kn()),i}function kn(){var i,e,l,u;return u=t,i=Us(),i!==null?(n.charCodeAt(t)===58?(e=":",t++):(e=null,_('":"')),e!==null?(l=Mn(),l===null&&(l=tn()),l!==null?i=[i,e,l]:(i=null,t=u)):(i=null,t=u)):(i=null,t=u),i}function Mn(){var i,e,l,u,f;return u=t,i=si(),i===null&&(i=en()),i!==null?(f=t,n.charCodeAt(t)===63?(e="?",t++):(e=null,_('"?"')),e!==null?(l=oi(),l!==null?e=[e,l]:(e=null,t=f)):(e=null,t=f),e=e!==null?e:"",e!==null?i=[i,e]:(i=null,t=u)):(i=null,t=u),i}function si(){var i,e,l,u;return u=t,n.substr(t,2)==="//"?(i="//",t+=2):(i=null,_('"//"')),i!==null?(e=ri(),e!==null?(l=en(),l=l!==null?l:"",l!==null?i=[i,e,l]:(i=null,t=u)):(i=null,t=u)):(i=null,t=u),i}function en(){var i,e,l;return l=t,n.charCodeAt(t)===47?(i="/",t++):(i=null,_('"/"')),i!==null?(e=ni(),e!==null?i=[i,e]:(i=null,t=l)):(i=null,t=l),i}function tn(){var i,e,l,u;if(u=t,i=Ds(),i!==null){for(e=[],l=Os();l!==null;)e.push(l),l=Os();e!==null?i=[i,e]:(i=null,t=u)}else i=null,t=u;return i}function Os(){var i;return i=ie(),i===null&&(i=N(),i===null&&(i=ve())),i}function Ds(){var i;return i=N(),i===null&&(i=ve(),i===null&&(n.charCodeAt(t)===59?(i=";",t++):(i=null,_('";"')),i===null&&(n.charCodeAt(t)===63?(i="?",t++):(i=null,_('"?"')),i===null&&(n.charCodeAt(t)===58?(i=":",t++):(i=null,_('":"')),i===null&&(n.charCodeAt(t)===64?(i="@",t++):(i=null,_('"@"')),i===null&&(n.charCodeAt(t)===38?(i="&",t++):(i=null,_('"&"')),i===null&&(n.charCodeAt(t)===61?(i="=",t++):(i=null,_('"="')),i===null&&(n.charCodeAt(t)===43?(i="+",t++):(i=null,_('"+"')),i===null&&(n.charCodeAt(t)===36?(i="$",t++):(i=null,_('"$"')),i===null&&(n.charCodeAt(t)===44?(i=",",t++):(i=null,_('","')))))))))))),i}function ni(){var i,e,l,u,f,h;if(f=t,i=sn(),i!==null){for(e=[],h=t,n.charCodeAt(t)===47?(l="/",t++):(l=null,_('"/"')),l!==null?(u=sn(),u!==null?l=[l,u]:(l=null,t=h)):(l=null,t=h);l!==null;)e.push(l),h=t,n.charCodeAt(t)===47?(l="/",t++):(l=null,_('"/"')),l!==null?(u=sn(),u!==null?l=[l,u]:(l=null,t=h)):(l=null,t=h);e!==null?i=[i,e]:(i=null,t=f)}else i=null,t=f;return i}function sn(){var i,e,l,u,f,h;for(f=t,i=[],e=hs();e!==null;)i.push(e),e=hs();if(i!==null){for(e=[],h=t,n.charCodeAt(t)===59?(l=";",t++):(l=null,_('";"')),l!==null?(u=Ns(),u!==null?l=[l,u]:(l=null,t=h)):(l=null,t=h);l!==null;)e.push(l),h=t,n.charCodeAt(t)===59?(l=";",t++):(l=null,_('";"')),l!==null?(u=Ns(),u!==null?l=[l,u]:(l=null,t=h)):(l=null,t=h);e!==null?i=[i,e]:(i=null,t=f)}else i=null,t=f;return i}function Ns(){var i,e;for(i=[],e=hs();e!==null;)i.push(e),e=hs();return i}function hs(){var i;return i=N(),i===null&&(i=ve(),i===null&&(n.charCodeAt(t)===58?(i=":",t++):(i=null,_('":"')),i===null&&(n.charCodeAt(t)===64?(i="@",t++):(i=null,_('"@"')),i===null&&(n.charCodeAt(t)===38?(i="&",t++):(i=null,_('"&"')),i===null&&(n.charCodeAt(t)===61?(i="=",t++):(i=null,_('"="')),i===null&&(n.charCodeAt(t)===43?(i="+",t++):(i=null,_('"+"')),i===null&&(n.charCodeAt(t)===36?(i="$",t++):(i=null,_('"$"')),i===null&&(n.charCodeAt(t)===44?(i=",",t++):(i=null,_('","')))))))))),i}function Us(){var i,e,l,u,f;if(u=t,f=t,i=v(),i!==null){for(e=[],l=v(),l===null&&(l=g(),l===null&&(n.charCodeAt(t)===43?(l="+",t++):(l=null,_('"+"')),l===null&&(n.charCodeAt(t)===45?(l="-",t++):(l=null,_('"-"')),l===null&&(n.charCodeAt(t)===46?(l=".",t++):(l=null,_('"."'))))));l!==null;)e.push(l),l=v(),l===null&&(l=g(),l===null&&(n.charCodeAt(t)===43?(l="+",t++):(l=null,_('"+"')),l===null&&(n.charCodeAt(t)===45?(l="-",t++):(l=null,_('"-"')),l===null&&(n.charCodeAt(t)===46?(l=".",t++):(l=null,_('"."'))))));e!==null?i=[i,e]:(i=null,t=f)}else i=null,t=f;return i!==null&&(i=function(h){R.scheme=n.substring(t,h)}(u)),i===null&&(t=u),i}function ri(){var i;return i=ii(),i===null&&(i=li()),i}function ii(){var i,e,l,u;return l=t,u=t,i=Ut(),i!==null?(n.charCodeAt(t)===64?(e="@",t++):(e=null,_('"@"')),e!==null?i=[i,e]:(i=null,t=u)):(i=null,t=u),i=i!==null?i:"",i!==null?(e=Ys(),e!==null?i=[i,e]:(i=null,t=l)):(i=null,t=l),i=i!==null?i:"",i}function li(){var i,e;if(e=N(),e===null&&(e=ve(),e===null&&(n.charCodeAt(t)===36?(e="$",t++):(e=null,_('"$"')),e===null&&(n.charCodeAt(t)===44?(e=",",t++):(e=null,_('","')),e===null&&(n.charCodeAt(t)===59?(e=";",t++):(e=null,_('";"')),e===null&&(n.charCodeAt(t)===58?(e=":",t++):(e=null,_('":"')),e===null&&(n.charCodeAt(t)===64?(e="@",t++):(e=null,_('"@"')),e===null&&(n.charCodeAt(t)===38?(e="&",t++):(e=null,_('"&"')),e===null&&(n.charCodeAt(t)===61?(e="=",t++):(e=null,_('"="')),e===null&&(n.charCodeAt(t)===43?(e="+",t++):(e=null,_('"+"'))))))))))),e!==null)for(i=[];e!==null;)i.push(e),e=N(),e===null&&(e=ve(),e===null&&(n.charCodeAt(t)===36?(e="$",t++):(e=null,_('"$"')),e===null&&(n.charCodeAt(t)===44?(e=",",t++):(e=null,_('","')),e===null&&(n.charCodeAt(t)===59?(e=";",t++):(e=null,_('";"')),e===null&&(n.charCodeAt(t)===58?(e=":",t++):(e=null,_('":"')),e===null&&(n.charCodeAt(t)===64?(e="@",t++):(e=null,_('"@"')),e===null&&(n.charCodeAt(t)===38?(e="&",t++):(e=null,_('"&"')),e===null&&(n.charCodeAt(t)===61?(e="=",t++):(e=null,_('"="')),e===null&&(n.charCodeAt(t)===43?(e="+",t++):(e=null,_('"+"')))))))))));else i=null;return i}function oi(){var i,e;for(i=[],e=Os();e!==null;)i.push(e),e=Os();return i}function xn(){var i,e,l,u,f,h,m,T;if(m=t,T=t,n.substr(t,3).toLowerCase()==="sip"?(i=n.substr(t,3),t+=3):(i=null,_('"SIP"')),i!==null)if(n.charCodeAt(t)===47?(e="/",t++):(e=null,_('"/"')),e!==null){if(u=g(),u!==null)for(l=[];u!==null;)l.push(u),u=g();else l=null;if(l!==null)if(n.charCodeAt(t)===46?(u=".",t++):(u=null,_('"."')),u!==null){if(h=g(),h!==null)for(f=[];h!==null;)f.push(h),h=g();else f=null;f!==null?i=[i,e,l,u,f]:(i=null,t=T)}else i=null,t=T;else i=null,t=T}else i=null,t=T;else i=null,t=T;return i!==null&&(i=function(y){R.sip_version=n.substring(t,y)}(m)),i===null&&(t=m),i}function Ln(){var i;return n.substr(t,6)==="INVITE"?(i="INVITE",t+=6):(i=null,_('"INVITE"')),i}function ai(){var i;return n.substr(t,3)==="ACK"?(i="ACK",t+=3):(i=null,_('"ACK"')),i}function ui(){var i;return n.substr(t,7)==="OPTIONS"?(i="OPTIONS",t+=7):(i=null,_('"OPTIONS"')),i}function ci(){var i;return n.substr(t,3)==="BYE"?(i="BYE",t+=3):(i=null,_('"BYE"')),i}function fi(){var i;return n.substr(t,6)==="CANCEL"?(i="CANCEL",t+=6):(i=null,_('"CANCEL"')),i}function _i(){var i;return n.substr(t,8)==="REGISTER"?(i="REGISTER",t+=8):(i=null,_('"REGISTER"')),i}function hi(){var i;return n.substr(t,9)==="SUBSCRIBE"?(i="SUBSCRIBE",t+=9):(i=null,_('"SUBSCRIBE"')),i}function di(){var i;return n.substr(t,6)==="NOTIFY"?(i="NOTIFY",t+=6):(i=null,_('"NOTIFY"')),i}function pi(){var i;return n.substr(t,5)==="REFER"?(i="REFER",t+=5):(i=null,_('"REFER"')),i}function nn(){var i,e;return e=t,i=Ln(),i===null&&(i=ai(),i===null&&(i=ui(),i===null&&(i=ci(),i===null&&(i=fi(),i===null&&(i=_i(),i===null&&(i=hi(),i===null&&(i=di(),i===null&&(i=pi(),i===null&&(i=U()))))))))),i!==null&&(i=function(l){return R.method=n.substring(t,l),R.method}(e)),i===null&&(t=e),i}function rn(){var i,e,l,u,f,h;return h=t,i=xn(),i!==null?(e=w(),e!==null?(l=mi(),l!==null?(u=w(),u!==null?(f=vi(),f!==null?i=[i,e,l,u,f]:(i=null,t=h)):(i=null,t=h)):(i=null,t=h)):(i=null,t=h)):(i=null,t=h),i}function mi(){var i,e;return e=t,i=gi(),i!==null&&(i=function(l,u){R.status_code=parseInt(u.join(""))}(e,i)),i===null&&(t=e),i}function gi(){var i,e,l,u;return u=t,i=g(),i!==null?(e=g(),e!==null?(l=g(),l!==null?i=[i,e,l]:(i=null,t=u)):(i=null,t=u)):(i=null,t=u),i}function vi(){var i,e,l;for(l=t,i=[],e=ie(),e===null&&(e=N(),e===null&&(e=ve(),e===null&&(e=Y(),e===null&&(e=$(),e===null&&(e=w(),e===null&&(e=F()))))));e!==null;)i.push(e),e=ie(),e===null&&(e=N(),e===null&&(e=ve(),e===null&&(e=Y(),e===null&&(e=$(),e===null&&(e=w(),e===null&&(e=F()))))));return i!==null&&(i=function(u){R.reason_phrase=n.substring(t,u)}(l)),i===null&&(t=l),i}function ro(){var i,e,l,u,f,h;if(f=t,i=an(),i!==null){for(e=[],h=t,l=Se(),l!==null?(u=an(),u!==null?l=[l,u]:(l=null,t=h)):(l=null,t=h);l!==null;)e.push(l),h=t,l=Se(),l!==null?(u=an(),u!==null?l=[l,u]:(l=null,t=h)):(l=null,t=h);e!==null?i=[i,e]:(i=null,t=f)}else i=null,t=f;return i}function tu(){var i,e,l,u,f,h;return u=t,f=t,i=et(),i!==null?(h=t,n.charCodeAt(t)===64?(e="@",t++):(e=null,_('"@"')),e!==null?(l=et(),l!==null?e=[e,l]:(e=null,t=h)):(e=null,t=h),e=e!==null?e:"",e!==null?i=[i,e]:(i=null,t=f)):(i=null,t=f),i!==null&&(i=function(m){R=n.substring(t,m)}(u)),i===null&&(t=u),i}function su(){var i,e,l,u,f,h,m;if(f=t,i=Q(),i===null)if(h=t,i=$n(),i!==null){for(e=[],m=t,l=Se(),l!==null?(u=$n(),u!==null?l=[l,u]:(l=null,t=m)):(l=null,t=m);l!==null;)e.push(l),m=t,l=Se(),l!==null?(u=$n(),u!==null?l=[l,u]:(l=null,t=m)):(l=null,t=m);e!==null?i=[i,e]:(i=null,t=h)}else i=null,t=h;return i!==null&&(i=function(T){var y,O;for(O=R.multi_header.length,y=0;y<O;y++)if(R.multi_header[y].parsed===null){R=null;break}R!==null?R=R.multi_header:R=-1}()),i===null&&(t=f),i}function $n(){var i,e,l,u,f,h,m;if(f=t,h=t,i=fe(),i===null&&(i=Pt()),i!==null){for(e=[],m=t,l=ne(),l!==null?(u=Ps(),u!==null?l=[l,u]:(l=null,t=m)):(l=null,t=m);l!==null;)e.push(l),m=t,l=ne(),l!==null?(u=Ps(),u!==null?l=[l,u]:(l=null,t=m)):(l=null,t=m);e!==null?i=[i,e]:(i=null,t=h)}else i=null,t=h;return i!==null&&(i=function(T){var y;R.multi_header||(R.multi_header=[]);try{y=new ds(R.uri,R.display_name,R.params),delete R.uri,delete R.display_name,delete R.params}catch{y=null}R.multi_header.push({possition:t,offset:T,parsed:y})}(f)),i===null&&(t=f),i}function Pt(){var i,e,l,u,f;return f=t,i=kt(),i=i!==null?i:"",i!==null?(e=Ue(),e!==null?(l=Re(),l!==null?(u=Ae(),u!==null?i=[i,e,l,u]:(i=null,t=f)):(i=null,t=f)):(i=null,t=f)):(i=null,t=f),i}function kt(){var i,e,l,u,f,h,m;if(f=t,h=t,i=U(),i!==null){for(e=[],m=t,l=me(),l!==null?(u=U(),u!==null?l=[l,u]:(l=null,t=m)):(l=null,t=m);l!==null;)e.push(l),m=t,l=me(),l!==null?(u=U(),u!==null?l=[l,u]:(l=null,t=m)):(l=null,t=m);e!==null?i=[i,e]:(i=null,t=h)}else i=null,t=h;return i===null&&(i=be()),i!==null&&(i=function(T,y){typeof y=="string"?R.display_name=y:R.display_name=y[1].reduce(function(O,se){return O+se[0]+se[1]},y[0])}(f,i)),i===null&&(t=f),i}function Ps(){var i;return i=Hn(),i===null&&(i=Ti(),i===null&&(i=Ge())),i}function Hn(){var i,e,l,u,f;return u=t,f=t,n.substr(t,1).toLowerCase()==="q"?(i=n.substr(t,1),t++):(i=null,_('"q"')),i!==null?(e=B(),e!==null?(l=Zt(),l!==null?i=[i,e,l]:(i=null,t=f)):(i=null,t=f)):(i=null,t=f),i!==null&&(i=function(h,m){R.params||(R.params={}),R.params.q=m}(u,i[2])),i===null&&(t=u),i}function Ti(){var i,e,l,u,f;return u=t,f=t,n.substr(t,7).toLowerCase()==="expires"?(i=n.substr(t,7),t+=7):(i=null,_('"expires"')),i!==null?(e=B(),e!==null?(l=Qt(),l!==null?i=[i,e,l]:(i=null,t=f)):(i=null,t=f)):(i=null,t=f),i!==null&&(i=function(h,m){R.params||(R.params={}),R.params.expires=m}(u,i[2])),i===null&&(t=u),i}function Qt(){var i,e,l;if(l=t,e=g(),e!==null)for(i=[];e!==null;)i.push(e),e=g();else i=null;return i!==null&&(i=function(u,f){return parseInt(f.join(""))}(l,i)),i===null&&(t=l),i}function Zt(){var i,e,l,u,f,h,m,T;return h=t,m=t,n.charCodeAt(t)===48?(i="0",t++):(i=null,_('"0"')),i!==null?(T=t,n.charCodeAt(t)===46?(e=".",t++):(e=null,_('"."')),e!==null?(l=g(),l=l!==null?l:"",l!==null?(u=g(),u=u!==null?u:"",u!==null?(f=g(),f=f!==null?f:"",f!==null?e=[e,l,u,f]:(e=null,t=T)):(e=null,t=T)):(e=null,t=T)):(e=null,t=T),e=e!==null?e:"",e!==null?i=[i,e]:(i=null,t=m)):(i=null,t=m),i!==null&&(i=function(y){return parseFloat(n.substring(t,y))}(h)),i===null&&(t=h),i}function Ge(){var i,e,l,u,f,h;return u=t,f=t,i=U(),i!==null?(h=t,e=B(),e!==null?(l=Ke(),l!==null?e=[e,l]:(e=null,t=h)):(e=null,t=h),e=e!==null?e:"",e!==null?i=[i,e]:(i=null,t=f)):(i=null,t=f),i!==null&&(i=function(m,T,y){R.params||(R.params={}),typeof y>"u"?y=void 0:y=y[1],R.params[T.toLowerCase()]=y}(u,i[0],i[1])),i===null&&(t=u),i}function Ke(){var i;return i=U(),i===null&&(i=Xt(),i===null&&(i=Ce())),i}function io(){var i,e,l,u,f,h;if(f=t,i=lo(),i!==null){for(e=[],h=t,l=ne(),l!==null?(u=Fn(),u!==null?l=[l,u]:(l=null,t=h)):(l=null,t=h);l!==null;)e.push(l),h=t,l=ne(),l!==null?(u=Fn(),u!==null?l=[l,u]:(l=null,t=h)):(l=null,t=h);e!==null?i=[i,e]:(i=null,t=f)}else i=null,t=f;return i}function lo(){var i;return n.substr(t,6).toLowerCase()==="render"?(i=n.substr(t,6),t+=6):(i=null,_('"render"')),i===null&&(n.substr(t,7).toLowerCase()==="session"?(i=n.substr(t,7),t+=7):(i=null,_('"session"')),i===null&&(n.substr(t,4).toLowerCase()==="icon"?(i=n.substr(t,4),t+=4):(i=null,_('"icon"')),i===null&&(n.substr(t,5).toLowerCase()==="alert"?(i=n.substr(t,5),t+=5):(i=null,_('"alert"')),i===null&&(i=U())))),i}function Fn(){var i;return i=qn(),i===null&&(i=Ge()),i}function qn(){var i,e,l,u;return u=t,n.substr(t,8).toLowerCase()==="handling"?(i=n.substr(t,8),t+=8):(i=null,_('"handling"')),i!==null?(e=B(),e!==null?(n.substr(t,8).toLowerCase()==="optional"?(l=n.substr(t,8),t+=8):(l=null,_('"optional"')),l===null&&(n.substr(t,8).toLowerCase()==="required"?(l=n.substr(t,8),t+=8):(l=null,_('"required"')),l===null&&(l=U())),l!==null?i=[i,e,l]:(i=null,t=u)):(i=null,t=u)):(i=null,t=u),i}function oo(){var i,e,l,u,f,h;if(f=t,i=U(),i!==null){for(e=[],h=t,l=Se(),l!==null?(u=U(),u!==null?l=[l,u]:(l=null,t=h)):(l=null,t=h);l!==null;)e.push(l),h=t,l=Se(),l!==null?(u=U(),u!==null?l=[l,u]:(l=null,t=h)):(l=null,t=h);e!==null?i=[i,e]:(i=null,t=f)}else i=null,t=f;return i}function nu(){var i,e,l;if(l=t,e=g(),e!==null)for(i=[];e!==null;)i.push(e),e=g();else i=null;return i!==null&&(i=function(u,f){R=parseInt(f.join(""))}(l,i)),i===null&&(t=l),i}function ru(){var i,e;return e=t,i=ao(),i!==null&&(i=function(l){R=n.substring(t,l)}(e)),i===null&&(t=e),i}function ao(){var i,e,l,u,f,h,m,T;if(m=t,i=Ei(),i!==null)if(e=W(),e!==null)if(l=Ci(),l!==null){for(u=[],T=t,f=ne(),f!==null?(h=jn(),h!==null?f=[f,h]:(f=null,t=T)):(f=null,t=T);f!==null;)u.push(f),T=t,f=ne(),f!==null?(h=jn(),h!==null?f=[f,h]:(f=null,t=T)):(f=null,t=T);u!==null?i=[i,e,l,u]:(i=null,t=m)}else i=null,t=m;else i=null,t=m;else i=null,t=m;return i}function Ei(){var i;return i=yi(),i===null&&(i=Si()),i}function yi(){var i;return n.substr(t,4).toLowerCase()==="text"?(i=n.substr(t,4),t+=4):(i=null,_('"text"')),i===null&&(n.substr(t,5).toLowerCase()==="image"?(i=n.substr(t,5),t+=5):(i=null,_('"image"')),i===null&&(n.substr(t,5).toLowerCase()==="audio"?(i=n.substr(t,5),t+=5):(i=null,_('"audio"')),i===null&&(n.substr(t,5).toLowerCase()==="video"?(i=n.substr(t,5),t+=5):(i=null,_('"video"')),i===null&&(n.substr(t,11).toLowerCase()==="application"?(i=n.substr(t,11),t+=11):(i=null,_('"application"')),i===null&&(i=ln()))))),i}function Si(){var i;return n.substr(t,7).toLowerCase()==="message"?(i=n.substr(t,7),t+=7):(i=null,_('"message"')),i===null&&(n.substr(t,9).toLowerCase()==="multipart"?(i=n.substr(t,9),t+=9):(i=null,_('"multipart"')),i===null&&(i=ln())),i}function ln(){var i;return i=U(),i===null&&(i=on()),i}function on(){var i,e,l;return l=t,n.substr(t,2).toLowerCase()==="x-"?(i=n.substr(t,2),t+=2):(i=null,_('"x-"')),i!==null?(e=U(),e!==null?i=[i,e]:(i=null,t=l)):(i=null,t=l),i}function Ci(){var i;return i=ln(),i===null&&(i=U()),i}function jn(){var i,e,l,u;return u=t,i=U(),i!==null?(e=B(),e!==null?(l=Vn(),l!==null?i=[i,e,l]:(i=null,t=u)):(i=null,t=u)):(i=null,t=u),i}function Vn(){var i;return i=U(),i===null&&(i=Ce()),i}function uo(){var i,e,l,u;return u=t,i=co(),i!==null?(e=me(),e!==null?(l=nn(),l!==null?i=[i,e,l]:(i=null,t=u)):(i=null,t=u)):(i=null,t=u),i}function co(){var i,e,l;if(l=t,e=g(),e!==null)for(i=[];e!==null;)i.push(e),e=g();else i=null;return i!==null&&(i=function(u,f){R.value=parseInt(f.join(""))}(l,i)),i===null&&(t=l),i}function fo(){var i,e;return e=t,i=Qt(),i!==null&&(i=function(l,u){R=u}(e,i)),i===null&&(t=e),i}function iu(){var i,e,l,u,f,h,m;if(f=t,h=t,i=an(),i!==null){for(e=[],m=t,l=ne(),l!==null?(u=Ge(),u!==null?l=[l,u]:(l=null,t=m)):(l=null,t=m);l!==null;)e.push(l),m=t,l=ne(),l!==null?(u=Ge(),u!==null?l=[l,u]:(l=null,t=m)):(l=null,t=m);e!==null?i=[i,e]:(i=null,t=h)}else i=null,t=h;return i!==null&&(i=function(T,y){R.event=y.join("").toLowerCase()}(f,i[0])),i===null&&(t=f),i}function an(){var i,e,l,u,f,h;if(f=t,i=P(),i!==null){for(e=[],h=t,n.charCodeAt(t)===46?(l=".",t++):(l=null,_('"."')),l!==null?(u=P(),u!==null?l=[l,u]:(l=null,t=h)):(l=null,t=h);l!==null;)e.push(l),h=t,n.charCodeAt(t)===46?(l=".",t++):(l=null,_('"."')),l!==null?(u=P(),u!==null?l=[l,u]:(l=null,t=h)):(l=null,t=h);e!==null?i=[i,e]:(i=null,t=f)}else i=null,t=f;return i}function un(){var i,e,l,u,f,h,m;if(f=t,h=t,i=fe(),i===null&&(i=Pt()),i!==null){for(e=[],m=t,l=ne(),l!==null?(u=Ai(),u!==null?l=[l,u]:(l=null,t=m)):(l=null,t=m);l!==null;)e.push(l),m=t,l=ne(),l!==null?(u=Ai(),u!==null?l=[l,u]:(l=null,t=m)):(l=null,t=m);e!==null?i=[i,e]:(i=null,t=h)}else i=null,t=h;return i!==null&&(i=function(T){var y=R.tag;try{R=new ds(R.uri,R.display_name,R.params),y&&R.setParam("tag",y)}catch{R=-1}}()),i===null&&(t=f),i}function Ai(){var i;return i=cn(),i===null&&(i=Ge()),i}function cn(){var i,e,l,u,f;return u=t,f=t,n.substr(t,3).toLowerCase()==="tag"?(i=n.substr(t,3),t+=3):(i=null,_('"tag"')),i!==null?(e=B(),e!==null?(l=U(),l!==null?i=[i,e,l]:(i=null,t=f)):(i=null,t=f)):(i=null,t=f),i!==null&&(i=function(h,m){R.tag=m}(u,i[2])),i===null&&(t=u),i}function Ri(){var i,e,l;if(l=t,e=g(),e!==null)for(i=[];e!==null;)i.push(e),e=g();else i=null;return i!==null&&(i=function(u,f){R=parseInt(f.join(""))}(l,i)),i===null&&(t=l),i}function lu(){var i,e;return e=t,i=Qt(),i!==null&&(i=function(l,u){R=u}(e,i)),i===null&&(t=e),i}function ou(){var i,e,l,u,f,h,m,T,y,O;for(T=t,y=t,i=[],e=kt();e!==null;)i.push(e),e=kt();if(i!==null)if(e=Ue(),e!==null)if(l=Re(),l!==null)if(u=Ae(),u!==null){for(f=[],O=t,h=ne(),h!==null?(m=Ge(),m!==null?h=[h,m]:(h=null,t=O)):(h=null,t=O);h!==null;)f.push(h),O=t,h=ne(),h!==null?(m=Ge(),m!==null?h=[h,m]:(h=null,t=O)):(h=null,t=O);f!==null?i=[i,e,l,u,f]:(i=null,t=y)}else i=null,t=y;else i=null,t=y;else i=null,t=y;else i=null,t=y;return i!==null&&(i=function(se){try{R=new ds(R.uri,R.display_name,R.params)}catch{R=-1}}()),i===null&&(t=T),i}function au(){var i;return i=Ii(),i}function Ii(){var i,e,l,u,f,h,m,T;if(m=t,n.substr(t,6).toLowerCase()==="digest"?(i=n.substr(t,6),t+=6):(i=null,_('"Digest"')),i!==null)if(e=me(),e!==null)if(l=es(),l!==null){for(u=[],T=t,f=Se(),f!==null?(h=es(),h!==null?f=[f,h]:(f=null,t=T)):(f=null,t=T);f!==null;)u.push(f),T=t,f=Se(),f!==null?(h=es(),h!==null?f=[f,h]:(f=null,t=T)):(f=null,t=T);u!==null?i=[i,e,l,u]:(i=null,t=m)}else i=null,t=m;else i=null,t=m;else i=null,t=m;return i===null&&(i=Bn()),i}function Bn(){var i,e,l,u,f,h,m,T;if(m=t,i=U(),i!==null)if(e=me(),e!==null)if(l=ks(),l!==null){for(u=[],T=t,f=Se(),f!==null?(h=ks(),h!==null?f=[f,h]:(f=null,t=T)):(f=null,t=T);f!==null;)u.push(f),T=t,f=Se(),f!==null?(h=ks(),h!==null?f=[f,h]:(f=null,t=T)):(f=null,t=T);u!==null?i=[i,e,l,u]:(i=null,t=m)}else i=null,t=m;else i=null,t=m;else i=null,t=m;return i}function ks(){var i,e,l,u;return u=t,i=U(),i!==null?(e=B(),e!==null?(l=U(),l===null&&(l=Ce()),l!==null?i=[i,e,l]:(i=null,t=u)):(i=null,t=u)):(i=null,t=u),i}function es(){var i;return i=fn(),i===null&&(i=wi(),i===null&&(i=hn(),i===null&&(i=Di(),i===null&&(i=Ni(),i===null&&(i=Ui(),i===null&&(i=Pi(),i===null&&(i=ks()))))))),i}function fn(){var i,e,l,u;return u=t,n.substr(t,5).toLowerCase()==="realm"?(i=n.substr(t,5),t+=5):(i=null,_('"realm"')),i!==null?(e=B(),e!==null?(l=bi(),l!==null?i=[i,e,l]:(i=null,t=u)):(i=null,t=u)):(i=null,t=u),i}function bi(){var i,e;return e=t,i=be(),i!==null&&(i=function(l,u){R.realm=u}(e,i)),i===null&&(t=e),i}function wi(){var i,e,l,u,f,h,m,T,y;if(T=t,n.substr(t,6).toLowerCase()==="domain"?(i=n.substr(t,6),t+=6):(i=null,_('"domain"')),i!==null)if(e=B(),e!==null)if(l=tt(),l!==null)if(u=_n(),u!==null){if(f=[],y=t,m=w(),m!==null)for(h=[];m!==null;)h.push(m),m=w();else h=null;for(h!==null?(m=_n(),m!==null?h=[h,m]:(h=null,t=y)):(h=null,t=y);h!==null;){if(f.push(h),y=t,m=w(),m!==null)for(h=[];m!==null;)h.push(m),m=w();else h=null;h!==null?(m=_n(),m!==null?h=[h,m]:(h=null,t=y)):(h=null,t=y)}f!==null?(h=st(),h!==null?i=[i,e,l,u,f,h]:(i=null,t=T)):(i=null,t=T)}else i=null,t=T;else i=null,t=T;else i=null,t=T;else i=null,t=T;return i}function _n(){var i;return i=kn(),i===null&&(i=en()),i}function hn(){var i,e,l,u;return u=t,n.substr(t,5).toLowerCase()==="nonce"?(i=n.substr(t,5),t+=5):(i=null,_('"nonce"')),i!==null?(e=B(),e!==null?(l=Oi(),l!==null?i=[i,e,l]:(i=null,t=u)):(i=null,t=u)):(i=null,t=u),i}function Oi(){var i,e;return e=t,i=be(),i!==null&&(i=function(l,u){R.nonce=u}(e,i)),i===null&&(t=e),i}function Di(){var i,e,l,u,f;return u=t,f=t,n.substr(t,6).toLowerCase()==="opaque"?(i=n.substr(t,6),t+=6):(i=null,_('"opaque"')),i!==null?(e=B(),e!==null?(l=be(),l!==null?i=[i,e,l]:(i=null,t=f)):(i=null,t=f)):(i=null,t=f),i!==null&&(i=function(h,m){R.opaque=m}(u,i[2])),i===null&&(t=u),i}function Ni(){var i,e,l,u,f;return u=t,n.substr(t,5).toLowerCase()==="stale"?(i=n.substr(t,5),t+=5):(i=null,_('"stale"')),i!==null?(e=B(),e!==null?(f=t,n.substr(t,4).toLowerCase()==="true"?(l=n.substr(t,4),t+=4):(l=null,_('"true"')),l!==null&&(l=function(h){R.stale=!0}()),l===null&&(t=f),l===null&&(f=t,n.substr(t,5).toLowerCase()==="false"?(l=n.substr(t,5),t+=5):(l=null,_('"false"')),l!==null&&(l=function(h){R.stale=!1}()),l===null&&(t=f)),l!==null?i=[i,e,l]:(i=null,t=u)):(i=null,t=u)):(i=null,t=u),i}function Ui(){var i,e,l,u,f;return u=t,f=t,n.substr(t,9).toLowerCase()==="algorithm"?(i=n.substr(t,9),t+=9):(i=null,_('"algorithm"')),i!==null?(e=B(),e!==null?(n.substr(t,3).toLowerCase()==="md5"?(l=n.substr(t,3),t+=3):(l=null,_('"MD5"')),l===null&&(n.substr(t,8).toLowerCase()==="md5-sess"?(l=n.substr(t,8),t+=8):(l=null,_('"MD5-sess"')),l===null&&(l=U())),l!==null?i=[i,e,l]:(i=null,t=f)):(i=null,t=f)):(i=null,t=f),i!==null&&(i=function(h,m){R.algorithm=m.toUpperCase()}(u,i[2])),i===null&&(t=u),i}function Pi(){var i,e,l,u,f,h,m,T,y,O;if(T=t,n.substr(t,3).toLowerCase()==="qop"?(i=n.substr(t,3),t+=3):(i=null,_('"qop"')),i!==null)if(e=B(),e!==null)if(l=tt(),l!==null){if(y=t,u=dn(),u!==null){for(f=[],O=t,n.charCodeAt(t)===44?(h=",",t++):(h=null,_('","')),h!==null?(m=dn(),m!==null?h=[h,m]:(h=null,t=O)):(h=null,t=O);h!==null;)f.push(h),O=t,n.charCodeAt(t)===44?(h=",",t++):(h=null,_('","')),h!==null?(m=dn(),m!==null?h=[h,m]:(h=null,t=O)):(h=null,t=O);f!==null?u=[u,f]:(u=null,t=y)}else u=null,t=y;u!==null?(f=st(),f!==null?i=[i,e,l,u,f]:(i=null,t=T)):(i=null,t=T)}else i=null,t=T;else i=null,t=T;else i=null,t=T;return i}function dn(){var i,e;return e=t,n.substr(t,8).toLowerCase()==="auth-int"?(i=n.substr(t,8),t+=8):(i=null,_('"auth-int"')),i===null&&(n.substr(t,4).toLowerCase()==="auth"?(i=n.substr(t,4),t+=4):(i=null,_('"auth"')),i===null&&(i=U())),i!==null&&(i=function(l,u){R.qop||(R.qop=[]),R.qop.push(u.toLowerCase())}(e,i)),i===null&&(t=e),i}function Gn(){var i,e,l,u,f,h;if(f=t,i=U(),i!==null){for(e=[],h=t,l=Se(),l!==null?(u=U(),u!==null?l=[l,u]:(l=null,t=h)):(l=null,t=h);l!==null;)e.push(l),h=t,l=Se(),l!==null?(u=U(),u!==null?l=[l,u]:(l=null,t=h)):(l=null,t=h);e!==null?i=[i,e]:(i=null,t=f)}else i=null,t=f;return i}function uu(){var i,e,l,u,f,h,m;if(f=t,h=t,i=Kn(),i!==null){for(e=[],m=t,l=Se(),l!==null?(u=Kn(),u!==null?l=[l,u]:(l=null,t=m)):(l=null,t=m);l!==null;)e.push(l),m=t,l=Se(),l!==null?(u=Kn(),u!==null?l=[l,u]:(l=null,t=m)):(l=null,t=m);e!==null?i=[i,e]:(i=null,t=h)}else i=null,t=h;return i!==null&&(i=function(T){var y,O;for(O=R.multi_header.length,y=0;y<O;y++)if(R.multi_header[y].parsed===null){R=null;break}R!==null?R=R.multi_header:R=-1}()),i===null&&(t=f),i}function Kn(){var i,e,l,u,f,h,m;if(f=t,h=t,i=Pt(),i!==null){for(e=[],m=t,l=ne(),l!==null?(u=Ge(),u!==null?l=[l,u]:(l=null,t=m)):(l=null,t=m);l!==null;)e.push(l),m=t,l=ne(),l!==null?(u=Ge(),u!==null?l=[l,u]:(l=null,t=m)):(l=null,t=m);e!==null?i=[i,e]:(i=null,t=h)}else i=null,t=h;return i!==null&&(i=function(T){var y;R.multi_header||(R.multi_header=[]);try{y=new ds(R.uri,R.display_name,R.params),delete R.uri,delete R.display_name,delete R.params}catch{y=null}R.multi_header.push({possition:t,offset:T,parsed:y})}(f)),i===null&&(t=f),i}function Wn(){var i,e,l,u,f,h,m;if(f=t,h=t,n.substr(t,3).toLowerCase()==="sip"?(i=n.substr(t,3),t+=3):(i=null,_('"SIP"')),i===null&&(i=U()),i!==null){for(e=[],m=t,l=ne(),l!==null?(u=ki(),u!==null?l=[l,u]:(l=null,t=m)):(l=null,t=m);l!==null;)e.push(l),m=t,l=ne(),l!==null?(u=ki(),u!==null?l=[l,u]:(l=null,t=m)):(l=null,t=m);e!==null?i=[i,e]:(i=null,t=h)}else i=null,t=h;return i!==null&&(i=function(T,y){if(R.protocol=y.toLowerCase(),R.params||(R.params={}),R.params.text&&R.params.text[0]==='"'){var O=R.params.text;R.text=O.substring(1,O.length-1),delete R.params.text}}(f,i[0])),i===null&&(t=f),i}function ki(){var i;return i=Yn(),i===null&&(i=Ge()),i}function Yn(){var i,e,l,u,f,h;if(f=t,h=t,n.substr(t,5).toLowerCase()==="cause"?(i=n.substr(t,5),t+=5):(i=null,_('"cause"')),i!==null)if(e=B(),e!==null){if(u=g(),u!==null)for(l=[];u!==null;)l.push(u),u=g();else l=null;l!==null?i=[i,e,l]:(i=null,t=h)}else i=null,t=h;else i=null,t=h;return i!==null&&(i=function(m,T){R.cause=parseInt(T.join(""))}(f,i[2])),i===null&&(t=f),i}function _o(){var i,e,l,u,f,h;if(f=t,i=U(),i!==null){for(e=[],h=t,l=Se(),l!==null?(u=U(),u!==null?l=[l,u]:(l=null,t=h)):(l=null,t=h);l!==null;)e.push(l),h=t,l=Se(),l!==null?(u=U(),u!==null?l=[l,u]:(l=null,t=h)):(l=null,t=h);e!==null?i=[i,e]:(i=null,t=f)}else i=null,t=f;return i}function cu(){var i,e,l,u,f,h;if(f=t,i=zn(),i!==null){for(e=[],h=t,l=Se(),l!==null?(u=zn(),u!==null?l=[l,u]:(l=null,t=h)):(l=null,t=h);l!==null;)e.push(l),h=t,l=Se(),l!==null?(u=zn(),u!==null?l=[l,u]:(l=null,t=h)):(l=null,t=h);e!==null?i=[i,e]:(i=null,t=f)}else i=null,t=f;return i}function zn(){var i,e,l,u,f,h;if(f=t,i=Pt(),i!==null){for(e=[],h=t,l=ne(),l!==null?(u=Ge(),u!==null?l=[l,u]:(l=null,t=h)):(l=null,t=h);l!==null;)e.push(l),h=t,l=ne(),l!==null?(u=Ge(),u!==null?l=[l,u]:(l=null,t=h)):(l=null,t=h);e!==null?i=[i,e]:(i=null,t=f)}else i=null,t=f;return i}function Jn(){var i,e,l,u,f,h;if(f=t,i=ho(),i!==null){for(e=[],h=t,l=ne(),l!==null?(u=Xn(),u!==null?l=[l,u]:(l=null,t=h)):(l=null,t=h);l!==null;)e.push(l),h=t,l=ne(),l!==null?(u=Xn(),u!==null?l=[l,u]:(l=null,t=h)):(l=null,t=h);e!==null?i=[i,e]:(i=null,t=f)}else i=null,t=f;return i}function ho(){var i,e;return e=t,n.substr(t,6).toLowerCase()==="active"?(i=n.substr(t,6),t+=6):(i=null,_('"active"')),i===null&&(n.substr(t,7).toLowerCase()==="pending"?(i=n.substr(t,7),t+=7):(i=null,_('"pending"')),i===null&&(n.substr(t,10).toLowerCase()==="terminated"?(i=n.substr(t,10),t+=10):(i=null,_('"terminated"')),i===null&&(i=U()))),i!==null&&(i=function(l){R.state=n.substring(t,l)}(e)),i===null&&(t=e),i}function Xn(){var i,e,l,u,f;return u=t,f=t,n.substr(t,6).toLowerCase()==="reason"?(i=n.substr(t,6),t+=6):(i=null,_('"reason"')),i!==null?(e=B(),e!==null?(l=Qn(),l!==null?i=[i,e,l]:(i=null,t=f)):(i=null,t=f)):(i=null,t=f),i!==null&&(i=function(h,m){typeof m<"u"&&(R.reason=m)}(u,i[2])),i===null&&(t=u),i===null&&(u=t,f=t,n.substr(t,7).toLowerCase()==="expires"?(i=n.substr(t,7),t+=7):(i=null,_('"expires"')),i!==null?(e=B(),e!==null?(l=Qt(),l!==null?i=[i,e,l]:(i=null,t=f)):(i=null,t=f)):(i=null,t=f),i!==null&&(i=function(h,m){typeof m<"u"&&(R.expires=m)}(u,i[2])),i===null&&(t=u),i===null&&(u=t,f=t,n.substr(t,11).toLowerCase()==="retry_after"?(i=n.substr(t,11),t+=11):(i=null,_('"retry_after"')),i!==null?(e=B(),e!==null?(l=Qt(),l!==null?i=[i,e,l]:(i=null,t=f)):(i=null,t=f)):(i=null,t=f),i!==null&&(i=function(h,m){typeof m<"u"&&(R.retry_after=m)}(u,i[2])),i===null&&(t=u),i===null&&(i=Ge()))),i}function Qn(){var i;return n.substr(t,11).toLowerCase()==="deactivated"?(i=n.substr(t,11),t+=11):(i=null,_('"deactivated"')),i===null&&(n.substr(t,9).toLowerCase()==="probation"?(i=n.substr(t,9),t+=9):(i=null,_('"probation"')),i===null&&(n.substr(t,8).toLowerCase()==="rejected"?(i=n.substr(t,8),t+=8):(i=null,_('"rejected"')),i===null&&(n.substr(t,7).toLowerCase()==="timeout"?(i=n.substr(t,7),t+=7):(i=null,_('"timeout"')),i===null&&(n.substr(t,6).toLowerCase()==="giveup"?(i=n.substr(t,6),t+=6):(i=null,_('"giveup"')),i===null&&(n.substr(t,10).toLowerCase()==="noresource"?(i=n.substr(t,10),t+=10):(i=null,_('"noresource"')),i===null&&(n.substr(t,9).toLowerCase()==="invariant"?(i=n.substr(t,9),t+=9):(i=null,_('"invariant"')),i===null&&(i=U()))))))),i}function po(){var i;return i=V(),i=i!==null?i:"",i}function fu(){var i,e,l,u,f,h;if(f=t,i=U(),i!==null){for(e=[],h=t,l=Se(),l!==null?(u=U(),u!==null?l=[l,u]:(l=null,t=h)):(l=null,t=h);l!==null;)e.push(l),h=t,l=Se(),l!==null?(u=U(),u!==null?l=[l,u]:(l=null,t=h)):(l=null,t=h);e!==null?i=[i,e]:(i=null,t=f)}else i=null,t=f;return i=i!==null?i:"",i}function _u(){var i,e,l,u,f,h,m;if(f=t,h=t,i=fe(),i===null&&(i=Pt()),i!==null){for(e=[],m=t,l=ne(),l!==null?(u=Mi(),u!==null?l=[l,u]:(l=null,t=m)):(l=null,t=m);l!==null;)e.push(l),m=t,l=ne(),l!==null?(u=Mi(),u!==null?l=[l,u]:(l=null,t=m)):(l=null,t=m);e!==null?i=[i,e]:(i=null,t=h)}else i=null,t=h;return i!==null&&(i=function(T){var y=R.tag;try{R=new ds(R.uri,R.display_name,R.params),y&&R.setParam("tag",y)}catch{R=-1}}()),i===null&&(t=f),i}function Mi(){var i;return i=cn(),i===null&&(i=Ge()),i}function xi(){var i,e,l,u,f,h;if(f=t,i=Zn(),i!==null){for(e=[],h=t,l=Se(),l!==null?(u=Zn(),u!==null?l=[l,u]:(l=null,t=h)):(l=null,t=h);l!==null;)e.push(l),h=t,l=Se(),l!==null?(u=Zn(),u!==null?l=[l,u]:(l=null,t=h)):(l=null,t=h);e!==null?i=[i,e]:(i=null,t=f)}else i=null,t=f;return i}function Zn(){var i,e,l,u,f,h,m,T;if(m=t,i=ji(),i!==null)if(e=me(),e!==null)if(l=Gi(),l!==null){for(u=[],T=t,f=ne(),f!==null?(h=Ms(),h!==null?f=[f,h]:(f=null,t=T)):(f=null,t=T);f!==null;)u.push(f),T=t,f=ne(),f!==null?(h=Ms(),h!==null?f=[f,h]:(f=null,t=T)):(f=null,t=T);u!==null?i=[i,e,l,u]:(i=null,t=m)}else i=null,t=m;else i=null,t=m;else i=null,t=m;return i}function Ms(){var i;return i=er(),i===null&&(i=Li(),i===null&&(i=$i(),i===null&&(i=Hi(),i===null&&(i=Fi(),i===null&&(i=Ge()))))),i}function er(){var i,e,l,u,f;return u=t,f=t,n.substr(t,3).toLowerCase()==="ttl"?(i=n.substr(t,3),t+=3):(i=null,_('"ttl"')),i!==null?(e=B(),e!==null?(l=tr(),l!==null?i=[i,e,l]:(i=null,t=f)):(i=null,t=f)):(i=null,t=f),i!==null&&(i=function(h,m){R.ttl=m}(u,i[2])),i===null&&(t=u),i}function Li(){var i,e,l,u,f;return u=t,f=t,n.substr(t,5).toLowerCase()==="maddr"?(i=n.substr(t,5),t+=5):(i=null,_('"maddr"')),i!==null?(e=B(),e!==null?(l=Xt(),l!==null?i=[i,e,l]:(i=null,t=f)):(i=null,t=f)):(i=null,t=f),i!==null&&(i=function(h,m){R.maddr=m}(u,i[2])),i===null&&(t=u),i}function $i(){var i,e,l,u,f;return u=t,f=t,n.substr(t,8).toLowerCase()==="received"?(i=n.substr(t,8),t+=8):(i=null,_('"received"')),i!==null?(e=B(),e!==null?(l=nt(),l===null&&(l=Js()),l!==null?i=[i,e,l]:(i=null,t=f)):(i=null,t=f)):(i=null,t=f),i!==null&&(i=function(h,m){R.received=m}(u,i[2])),i===null&&(t=u),i}function Hi(){var i,e,l,u,f;return u=t,f=t,n.substr(t,6).toLowerCase()==="branch"?(i=n.substr(t,6),t+=6):(i=null,_('"branch"')),i!==null?(e=B(),e!==null?(l=U(),l!==null?i=[i,e,l]:(i=null,t=f)):(i=null,t=f)):(i=null,t=f),i!==null&&(i=function(h,m){R.branch=m}(u,i[2])),i===null&&(t=u),i}function Fi(){var i,e,l,u,f;return u=t,n.substr(t,5).toLowerCase()==="rport"?(i=n.substr(t,5),t+=5):(i=null,_('"rport"')),i!==null?(f=t,e=B(),e!==null?(l=qi(),l!==null?e=[e,l]:(e=null,t=f)):(e=null,t=f),e=e!==null?e:"",e!==null?i=[i,e]:(i=null,t=u)):(i=null,t=u),i}function qi(){var i,e,l,u,f,h,m;return h=t,m=t,i=g(),i=i!==null?i:"",i!==null?(e=g(),e=e!==null?e:"",e!==null?(l=g(),l=l!==null?l:"",l!==null?(u=g(),u=u!==null?u:"",u!==null?(f=g(),f=f!==null?f:"",f!==null?i=[i,e,l,u,f]:(i=null,t=m)):(i=null,t=m)):(i=null,t=m)):(i=null,t=m)):(i=null,t=m),i!==null&&(i=function(T,y){R.rport=parseInt(y.join(""))}(h,i)),i===null&&(t=h),i}function ji(){var i,e,l,u,f,h;return h=t,i=Vi(),i!==null?(e=W(),e!==null?(l=U(),l!==null?(u=W(),u!==null?(f=Bi(),f!==null?i=[i,e,l,u,f]:(i=null,t=h)):(i=null,t=h)):(i=null,t=h)):(i=null,t=h)):(i=null,t=h),i}function Vi(){var i,e;return e=t,n.substr(t,3).toLowerCase()==="sip"?(i=n.substr(t,3),t+=3):(i=null,_('"SIP"')),i===null&&(i=U()),i!==null&&(i=function(l,u){R.protocol=u}(e,i)),i===null&&(t=e),i}function Bi(){var i,e;return e=t,n.substr(t,3).toLowerCase()==="udp"?(i=n.substr(t,3),t+=3):(i=null,_('"UDP"')),i===null&&(n.substr(t,3).toLowerCase()==="tcp"?(i=n.substr(t,3),t+=3):(i=null,_('"TCP"')),i===null&&(n.substr(t,3).toLowerCase()==="tls"?(i=n.substr(t,3),t+=3):(i=null,_('"TLS"')),i===null&&(n.substr(t,4).toLowerCase()==="sctp"?(i=n.substr(t,4),t+=4):(i=null,_('"SCTP"')),i===null&&(i=U())))),i!==null&&(i=function(l,u){R.transport=u}(e,i)),i===null&&(t=e),i}function Gi(){var i,e,l,u,f;return u=t,i=Ki(),i!==null?(f=t,e=Te(),e!==null?(l=Wi(),l!==null?e=[e,l]:(e=null,t=f)):(e=null,t=f),e=e!==null?e:"",e!==null?i=[i,e]:(i=null,t=u)):(i=null,t=u),i}function Ki(){var i,e;return e=t,i=nt(),i===null&&(i=Nn(),i===null&&(i=_s())),i!==null&&(i=function(l){R.host=n.substring(t,l)}(e)),i===null&&(t=e),i}function Wi(){var i,e,l,u,f,h,m;return h=t,m=t,i=g(),i=i!==null?i:"",i!==null?(e=g(),e=e!==null?e:"",e!==null?(l=g(),l=l!==null?l:"",l!==null?(u=g(),u=u!==null?u:"",u!==null?(f=g(),f=f!==null?f:"",f!==null?i=[i,e,l,u,f]:(i=null,t=m)):(i=null,t=m)):(i=null,t=m)):(i=null,t=m)):(i=null,t=m),i!==null&&(i=function(T,y){R.port=parseInt(y.join(""))}(h,i)),i===null&&(t=h),i}function tr(){var i,e,l,u,f;return u=t,f=t,i=g(),i!==null?(e=g(),e=e!==null?e:"",e!==null?(l=g(),l=l!==null?l:"",l!==null?i=[i,e,l]:(i=null,t=f)):(i=null,t=f)):(i=null,t=f),i!==null&&(i=function(h,m){return parseInt(m.join(""))}(u,i)),i===null&&(t=u),i}function Yi(){var i;return i=Ii(),i}function hu(){var i,e,l,u,f,h;if(f=t,i=mo(),i!==null){for(e=[],h=t,l=ne(),l!==null?(u=sr(),u!==null?l=[l,u]:(l=null,t=h)):(l=null,t=h);l!==null;)e.push(l),h=t,l=ne(),l!==null?(u=sr(),u!==null?l=[l,u]:(l=null,t=h)):(l=null,t=h);e!==null?i=[i,e]:(i=null,t=f)}else i=null,t=f;return i}function mo(){var i,e;return e=t,i=Qt(),i!==null&&(i=function(l,u){R.expires=u}(e,i)),i===null&&(t=e),i}function sr(){var i;return i=nr(),i===null&&(i=Ge()),i}function nr(){var i,e,l,u,f;return u=t,f=t,n.substr(t,9).toLowerCase()==="refresher"?(i=n.substr(t,9),t+=9):(i=null,_('"refresher"')),i!==null?(e=B(),e!==null?(n.substr(t,3).toLowerCase()==="uac"?(l=n.substr(t,3),t+=3):(l=null,_('"uac"')),l===null&&(n.substr(t,3).toLowerCase()==="uas"?(l=n.substr(t,3),t+=3):(l=null,_('"uas"'))),l!==null?i=[i,e,l]:(i=null,t=f)):(i=null,t=f)):(i=null,t=f),i!==null&&(i=function(h,m){R.refresher=m.toLowerCase()}(u,i[2])),i===null&&(t=u),i}function go(){var i,e,l,u;return u=t,i=U(),i!==null?(e=D(),e!==null?(l=vo(),l!==null?i=[i,e,l]:(i=null,t=u)):(i=null,t=u)):(i=null,t=u),i}function vo(){var i,e;for(i=[],e=j(),e===null&&(e=$(),e===null&&(e=me()));e!==null;)i.push(e),e=j(),e===null&&(e=$(),e===null&&(e=me()));return i}function To(){var i,e;for(i=[],e=C();e!==null;)i.push(e),e=C();return i}function du(){var i,e,l;return l=t,n.substr(t,5)==="uuid:"?(i="uuid:",t+=5):(i=null,_('"uuid:"')),i!==null?(e=Eo(),e!==null?i=[i,e]:(i=null,t=l)):(i=null,t=l),i}function Eo(){var i,e,l,u,f,h,m,T,y,O,se;return O=t,se=t,i=xt(),i!==null?(n.charCodeAt(t)===45?(e="-",t++):(e=null,_('"-"')),e!==null?(l=Mt(),l!==null?(n.charCodeAt(t)===45?(u="-",t++):(u=null,_('"-"')),u!==null?(f=Mt(),f!==null?(n.charCodeAt(t)===45?(h="-",t++):(h=null,_('"-"')),h!==null?(m=Mt(),m!==null?(n.charCodeAt(t)===45?(T="-",t++):(T=null,_('"-"')),T!==null?(y=zi(),y!==null?i=[i,e,l,u,f,h,m,T,y]:(i=null,t=se)):(i=null,t=se)):(i=null,t=se)):(i=null,t=se)):(i=null,t=se)):(i=null,t=se)):(i=null,t=se)):(i=null,t=se)):(i=null,t=se),i!==null&&(i=function(De,Ct){R=n.substring(t+5,De)}(O,i[0])),i===null&&(t=O),i}function Mt(){var i,e,l,u,f;return f=t,i=E(),i!==null?(e=E(),e!==null?(l=E(),l!==null?(u=E(),u!==null?i=[i,e,l,u]:(i=null,t=f)):(i=null,t=f)):(i=null,t=f)):(i=null,t=f),i}function xt(){var i,e,l;return l=t,i=Mt(),i!==null?(e=Mt(),e!==null?i=[i,e]:(i=null,t=l)):(i=null,t=l),i}function zi(){var i,e,l,u;return u=t,i=Mt(),i!==null?(e=Mt(),e!==null?(l=Mt(),l!==null?i=[i,e,l]:(i=null,t=u)):(i=null,t=u)):(i=null,t=u),i}function yo(){var i,e,l,u,f,h,m;if(f=t,h=t,i=fe(),i===null&&(i=Pt()),i!==null){for(e=[],m=t,l=ne(),l!==null?(u=Ge(),u!==null?l=[l,u]:(l=null,t=m)):(l=null,t=m);l!==null;)e.push(l),m=t,l=ne(),l!==null?(u=Ge(),u!==null?l=[l,u]:(l=null,t=m)):(l=null,t=m);e!==null?i=[i,e]:(i=null,t=h)}else i=null,t=h;return i!==null&&(i=function(T){try{R=new ds(R.uri,R.display_name,R.params)}catch{R=-1}}()),i===null&&(t=f),i}function pu(){var i,e,l,u,f,h;if(f=t,i=So(),i!==null){for(e=[],h=t,l=ne(),l!==null?(u=rr(),u!==null?l=[l,u]:(l=null,t=h)):(l=null,t=h);l!==null;)e.push(l),h=t,l=ne(),l!==null?(u=rr(),u!==null?l=[l,u]:(l=null,t=h)):(l=null,t=h);e!==null?i=[i,e]:(i=null,t=f)}else i=null,t=f;return i}function So(){var i,e,l,u,f,h;return u=t,f=t,i=et(),i!==null?(h=t,n.charCodeAt(t)===64?(e="@",t++):(e=null,_('"@"')),e!==null?(l=et(),l!==null?e=[e,l]:(e=null,t=h)):(e=null,t=h),e=e!==null?e:"",e!==null?i=[i,e]:(i=null,t=f)):(i=null,t=f),i!==null&&(i=function(m){R.call_id=n.substring(t,m)}(u)),i===null&&(t=u),i}function rr(){var i;return i=ir(),i===null&&(i=Ji(),i===null&&(i=Xi(),i===null&&(i=Ge()))),i}function ir(){var i,e,l,u,f;return u=t,f=t,n.substr(t,6)==="to-tag"?(i="to-tag",t+=6):(i=null,_('"to-tag"')),i!==null?(e=B(),e!==null?(l=U(),l!==null?i=[i,e,l]:(i=null,t=f)):(i=null,t=f)):(i=null,t=f),i!==null&&(i=function(h,m){R.to_tag=m}(u,i[2])),i===null&&(t=u),i}function Ji(){var i,e,l,u,f;return u=t,f=t,n.substr(t,8)==="from-tag"?(i="from-tag",t+=8):(i=null,_('"from-tag"')),i!==null?(e=B(),e!==null?(l=U(),l!==null?i=[i,e,l]:(i=null,t=f)):(i=null,t=f)):(i=null,t=f),i!==null&&(i=function(h,m){R.from_tag=m}(u,i[2])),i===null&&(t=u),i}function Xi(){var i,e;return e=t,n.substr(t,10)==="early-only"?(i="early-only",t+=10):(i=null,_('"early-only"')),i!==null&&(i=function(l){R.early_only=!0}()),i===null&&(t=e),i}function Co(i){i.sort();for(var e=null,l=[],u=0;u<i.length;u++)i[u]!==e&&(l.push(i[u]),e=i[u]);return l}function mu(){for(var i=1,e=1,l=!1,u=0;u<Math.max(t,s);u++){var f=n.charAt(u);f===`
75
+ `?(l||i++,e=1,l=!1):f==="\r"||f==="\u2028"||f==="\u2029"?(i++,e=1,l=!0):(e++,l=!1)}return{line:i,column:e}}var Ao=is(),ds=Ta(),R={},b=a[o]();if(b===null||t!==n.length){var Qi=Math.max(t,s),Zi=Qi<n.length?n.charAt(Qi):null,Ro=mu();return new this.SyntaxError(Co(p),Zi,Qi,Ro.line,Ro.column),-1}return R},toSource:function(){return this._source}};return r.SyntaxError=function(n,o,a,t,s){function p(_,d){var g,v;switch(_.length){case 0:g="end of input";break;case 1:g=_[0];break;default:g=_.slice(0,_.length-1).join(", ")+" or "+_[_.length-1]}return v=d?c(d):"end of input","Expected "+g+" but "+v+" found."}this.name="SyntaxError",this.expected=n,this.found=o,this.message=p(n,o),this.offset=a,this.line=t,this.column=s},r.SyntaxError.prototype=Error.prototype,r}()),Ea}var ya,zc;function is(){if(zc)return ya;zc=1;const c=we,r=ft(),n=Gt();return ya=class Xf{static parse(a){if(a=n.parse(a,"SIP_URI"),a!==-1)return a}constructor(a,t,s,p,_={},d={}){if(!s)throw new TypeError('missing or invalid "host" parameter');this._parameters={},this._headers={},this._scheme=a||c.SIP,this._user=t,this._host=s,this._port=p;for(const g in _)Object.prototype.hasOwnProperty.call(_,g)&&this.setParam(g,_[g]);for(const g in d)Object.prototype.hasOwnProperty.call(d,g)&&this.setHeader(g,d[g])}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,t){a&&(this._parameters[a.toLowerCase()]=typeof t>"u"||t===null?null:t.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 t=this._parameters[a];return delete this._parameters[a],t}}clearParams(){this._parameters={}}setHeader(a,t){this._headers[r.headerize(a)]=Array.isArray(t)?t:[t]}getHeader(a){if(a)return this._headers[r.headerize(a)]}hasHeader(a){if(a)return this._headers.hasOwnProperty(r.headerize(a))&&!0||!1}deleteHeader(a){if(a=r.headerize(a),this._headers.hasOwnProperty(a)){const t=this._headers[a];return delete this._headers[a],t}}clearHeaders(){this._headers={}}clone(){return new Xf(this._scheme,this._user,this._host,this._port,JSON.parse(JSON.stringify(this._parameters)),JSON.parse(JSON.stringify(this._headers)))}toString(){const a=[];let t=`${this._scheme}:`;this._user&&(t+=`${r.escapeUser(this._user)}@`),t+=this._host,(this._port||this._port===0)&&(t+=`:${this._port}`);for(const s in this._parameters)Object.prototype.hasOwnProperty.call(this._parameters,s)&&(t+=`;${s}`,this._parameters[s]!==null&&(t+=`=${this._parameters[s]}`));for(const s in this._headers)if(Object.prototype.hasOwnProperty.call(this._headers,s))for(const p of this._headers[s])a.push(`${s}=${p}`);return a.length>0&&(t+=`?${a.join("&")}`),t}toAor(a){let t=`${this._scheme}:`;return this._user&&(t+=`${r.escapeUser(this._user)}@`),t+=this._host,a&&(this._port||this._port===0)&&(t+=`:${this._port}`),t}},ya}var Jc;function ft(){if(Jc)return ze;Jc=1;const c=we,r=is(),n=Gt();ze.str_utf8_length=s=>unescape(encodeURIComponent(s)).length;const o=ze.isFunction=s=>s!==void 0?Object.prototype.toString.call(s)==="[object Function]":!1;ze.isString=s=>s!==void 0?Object.prototype.toString.call(s)==="[object String]":!1,ze.isDecimal=s=>!isNaN(s)&&parseFloat(s)===parseInt(s,10),ze.isEmpty=s=>s===null||s===""||s===void 0||Array.isArray(s)&&s.length===0||typeof s=="number"&&isNaN(s),ze.hasMethods=function(s,...p){for(const _ of p)if(o(s[_]))return!1;return!0};const a=ze.createRandomToken=(s,p=32)=>{let _,d,g="";for(_=0;_<s;_++)d=Math.random()*p|0,g+=d.toString(p);return g};ze.newTag=()=>a(10),ze.newUUID=()=>"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,p=>{const _=Math.random()*16|0;return(p==="x"?_:_&3|8).toString(16)}),ze.hostType=s=>{if(s){if(s=n.parse(s,"host"),s!==-1)return s.host_type}else return};const t=ze.escapeUser=s=>encodeURIComponent(decodeURIComponent(s)).replace(/%3A/ig,":").replace(/%2B/ig,"+").replace(/%3F/ig,"?").replace(/%2F/ig,"/");return ze.normalizeTarget=(s,p)=>{if(s){if(s instanceof r)return s;if(typeof s=="string"){const _=s.split("@");let d,g;switch(_.length){case 1:if(!p)return;d=s,g=p;break;case 2:d=_[0],g=_[1];break;default:d=_.slice(0,_.length-1).join("@"),g=_[_.length-1]}d=d.replace(/^(sips?|tel):/i,""),/^[-.()]*\+?[0-9\-.()]+$/.test(d)&&(d=d.replace(/[-.()]/g,"")),s=`${c.SIP}:${t(d)}@${g}`;let v;return(v=r.parse(s))?v:void 0}else return}else return},ze.headerize=s=>{const p={"Call-Id":"Call-ID",Cseq:"CSeq","Www-Authenticate":"WWW-Authenticate"},_=s.toLowerCase().replace(/_/g,"-").split("-");let d="";const g=_.length;let v;for(v=0;v<g;v++)v!==0&&(d+="-"),d+=_[v].charAt(0).toUpperCase()+_[v].substring(1);return p[d]&&(d=p[d]),d},ze.sipErrorCause=s=>{for(const p in c.SIP_ERROR_CAUSES)if(c.SIP_ERROR_CAUSES[p].indexOf(s)!==-1)return c.causes[p];return c.causes.SIP_FAILURE_CODE},ze.getRandomTestNetIP=()=>{function s(p,_){return Math.floor(Math.random()*(_-p+1)+p)}return`192.0.2.${s(1,254)}`},ze.calculateMD5=s=>{function p(ge,Ee){return ge<<Ee|ge>>>32-Ee}function _(ge,Ee){const Ce=ge&2147483648,be=Ee&2147483648,_e=ge&1073741824,ce=Ee&1073741824,fe=(ge&1073741823)+(Ee&1073741823);return _e&ce?fe^2147483648^Ce^be:_e|ce?fe&1073741824?fe^3221225472^Ce^be:fe^1073741824^Ce^be:fe^Ce^be}function d(ge,Ee,Ce){return ge&Ee|~ge&Ce}function g(ge,Ee,Ce){return ge&Ce|Ee&~Ce}function v(ge,Ee,Ce){return ge^Ee^Ce}function E(ge,Ee,Ce){return Ee^(ge|~Ce)}function S(ge,Ee,Ce,be,_e,ce,fe){return ge=_(ge,_(_(d(Ee,Ce,be),_e),fe)),_(p(ge,ce),Ee)}function C(ge,Ee,Ce,be,_e,ce,fe){return ge=_(ge,_(_(g(Ee,Ce,be),_e),fe)),_(p(ge,ce),Ee)}function I(ge,Ee,Ce,be,_e,ce,fe){return ge=_(ge,_(_(v(Ee,Ce,be),_e),fe)),_(p(ge,ce),Ee)}function w(ge,Ee,Ce,be,_e,ce,fe){return ge=_(ge,_(_(E(Ee,Ce,be),_e),fe)),_(p(ge,ce),Ee)}function F(ge){let Ee;const Ce=ge.length,be=Ce+8,ce=((be-be%64)/64+1)*16,fe=new Array(ce-1);let Re=0,Oe=0;for(;Oe<Ce;)Ee=(Oe-Oe%4)/4,Re=Oe%4*8,fe[Ee]=fe[Ee]|ge.charCodeAt(Oe)<<Re,Oe++;return Ee=(Oe-Oe%4)/4,Re=Oe%4*8,fe[Ee]=fe[Ee]|128<<Re,fe[ce-2]=Ce<<3,fe[ce-1]=Ce>>>29,fe}function L(ge){let Ee="",Ce="",be,_e;for(_e=0;_e<=3;_e++)be=ge>>>_e*8&255,Ce=`0${be.toString(16)}`,Ee=Ee+Ce.substr(Ce.length-2,2);return Ee}function ie(ge){let Ee="";for(let Ce=0;Ce<ge.length;Ce++){const be=ge.charCodeAt(Ce);be<128?Ee+=String.fromCharCode(be):be>127&&be<2048?(Ee+=String.fromCharCode(be>>6|192),Ee+=String.fromCharCode(be&63|128)):(Ee+=String.fromCharCode(be>>12|224),Ee+=String.fromCharCode(be>>6&63|128),Ee+=String.fromCharCode(be&63|128))}return Ee}let N=[],H,ve,me,M,D,V,j,Y,$;const X=7,U=12,P=17,Z=22,et=5,Q=9,W=14,B=20,te=4,de=11,Ae=16,Ue=23,Se=6,ne=10,Te=15,tt=21;for(s=ie(s),N=F(s),V=1732584193,j=4023233417,Y=2562383102,$=271733878,H=0;H<N.length;H+=16)ve=V,me=j,M=Y,D=$,V=S(V,j,Y,$,N[H+0],X,3614090360),$=S($,V,j,Y,N[H+1],U,3905402710),Y=S(Y,$,V,j,N[H+2],P,606105819),j=S(j,Y,$,V,N[H+3],Z,3250441966),V=S(V,j,Y,$,N[H+4],X,4118548399),$=S($,V,j,Y,N[H+5],U,1200080426),Y=S(Y,$,V,j,N[H+6],P,2821735955),j=S(j,Y,$,V,N[H+7],Z,4249261313),V=S(V,j,Y,$,N[H+8],X,1770035416),$=S($,V,j,Y,N[H+9],U,2336552879),Y=S(Y,$,V,j,N[H+10],P,4294925233),j=S(j,Y,$,V,N[H+11],Z,2304563134),V=S(V,j,Y,$,N[H+12],X,1804603682),$=S($,V,j,Y,N[H+13],U,4254626195),Y=S(Y,$,V,j,N[H+14],P,2792965006),j=S(j,Y,$,V,N[H+15],Z,1236535329),V=C(V,j,Y,$,N[H+1],et,4129170786),$=C($,V,j,Y,N[H+6],Q,3225465664),Y=C(Y,$,V,j,N[H+11],W,643717713),j=C(j,Y,$,V,N[H+0],B,3921069994),V=C(V,j,Y,$,N[H+5],et,3593408605),$=C($,V,j,Y,N[H+10],Q,38016083),Y=C(Y,$,V,j,N[H+15],W,3634488961),j=C(j,Y,$,V,N[H+4],B,3889429448),V=C(V,j,Y,$,N[H+9],et,568446438),$=C($,V,j,Y,N[H+14],Q,3275163606),Y=C(Y,$,V,j,N[H+3],W,4107603335),j=C(j,Y,$,V,N[H+8],B,1163531501),V=C(V,j,Y,$,N[H+13],et,2850285829),$=C($,V,j,Y,N[H+2],Q,4243563512),Y=C(Y,$,V,j,N[H+7],W,1735328473),j=C(j,Y,$,V,N[H+12],B,2368359562),V=I(V,j,Y,$,N[H+5],te,4294588738),$=I($,V,j,Y,N[H+8],de,2272392833),Y=I(Y,$,V,j,N[H+11],Ae,1839030562),j=I(j,Y,$,V,N[H+14],Ue,4259657740),V=I(V,j,Y,$,N[H+1],te,2763975236),$=I($,V,j,Y,N[H+4],de,1272893353),Y=I(Y,$,V,j,N[H+7],Ae,4139469664),j=I(j,Y,$,V,N[H+10],Ue,3200236656),V=I(V,j,Y,$,N[H+13],te,681279174),$=I($,V,j,Y,N[H+0],de,3936430074),Y=I(Y,$,V,j,N[H+3],Ae,3572445317),j=I(j,Y,$,V,N[H+6],Ue,76029189),V=I(V,j,Y,$,N[H+9],te,3654602809),$=I($,V,j,Y,N[H+12],de,3873151461),Y=I(Y,$,V,j,N[H+15],Ae,530742520),j=I(j,Y,$,V,N[H+2],Ue,3299628645),V=w(V,j,Y,$,N[H+0],Se,4096336452),$=w($,V,j,Y,N[H+7],ne,1126891415),Y=w(Y,$,V,j,N[H+14],Te,2878612391),j=w(j,Y,$,V,N[H+5],tt,4237533241),V=w(V,j,Y,$,N[H+12],Se,1700485571),$=w($,V,j,Y,N[H+3],ne,2399980690),Y=w(Y,$,V,j,N[H+10],Te,4293915773),j=w(j,Y,$,V,N[H+1],tt,2240044497),V=w(V,j,Y,$,N[H+8],Se,1873313359),$=w($,V,j,Y,N[H+15],ne,4264355552),Y=w(Y,$,V,j,N[H+6],Te,2734768916),j=w(j,Y,$,V,N[H+13],tt,1309151649),V=w(V,j,Y,$,N[H+4],Se,4149444226),$=w($,V,j,Y,N[H+11],ne,3174756917),Y=w(Y,$,V,j,N[H+2],Te,718787259),j=w(j,Y,$,V,N[H+9],tt,3951481745),V=_(V,ve),j=_(j,me),Y=_(Y,M),$=_($,D);return(L(V)+L(j)+L(Y)+L($)).toLowerCase()},ze.closeMediaStream=s=>{if(s)try{let p;if(s.getTracks){p=s.getTracks();for(const _ of p)_.stop()}else{p=s.getAudioTracks();for(const _ of p)_.stop();p=s.getVideoTracks();for(const _ of p)_.stop()}}catch{(typeof s.stop=="function"||typeof s.stop=="object")&&s.stop()}},ze.cloneArray=s=>s&&s.slice()||[],ze.cloneObject=(s,p={})=>s&&Object.assign({},s)||p,ze}const Xc=wt,$p=it,_t=we,Ze=ft(),Qc=Ta(),Hp=Gt(),Sa=new $p("SIPMessage");class Hl{constructor(r,n,o,a,t,s){if(!r||!n||!o)return null;a=a||{},this.ua=o,this.headers={},this.method=r,this.ruri=n,this.body=s,this.extraHeaders=Ze.cloneArray(t),this.ua.configuration.extra_headers&&(this.extraHeaders=this.extraHeaders.concat(this.ua.configuration.extra_headers)),a.route_set?this.setHeader("route",a.route_set):o.configuration.use_preloaded_route&&this.setHeader("route",`<${o.transport.sip_uri};lr>`),this.setHeader("via",""),this.setHeader("max-forwards",_t.MAX_FORWARDS);const p=a.to_uri||n,_=a.to_tag?{tag:a.to_tag}:null,d=typeof a.to_display_name<"u"?a.to_display_name:null;this.to=new Qc(p,d,_),this.setHeader("to",this.to.toString());const g=a.from_uri||o.configuration.uri,v={tag:a.from_tag||Ze.newTag()};let E;typeof a.from_display_name<"u"?E=a.from_display_name:o.configuration.display_name?E=o.configuration.display_name:E=null,this.from=new Qc(g,E,v),this.setHeader("from",this.from.toString());const S=a.call_id||o.configuration.jssip_id+Ze.createRandomToken(15);this.call_id=S,this.setHeader("call-id",S);const C=a.cseq||Math.floor(Math.random()*1e4);this.cseq=C,this.setHeader("cseq",`${C} ${r}`)}setHeader(r,n){const o=new RegExp(`^\\s*${r}\\s*:`,"i");for(let a=0;a<this.extraHeaders.length;a++)o.test(this.extraHeaders[a])&&this.extraHeaders.splice(a,1);this.headers[Ze.headerize(r)]=Array.isArray(n)?n:[n]}getHeader(r){const n=this.headers[Ze.headerize(r)];if(n){if(n[0])return n[0]}else{const o=new RegExp(`^\\s*${r}\\s*:`,"i");for(const a of this.extraHeaders)if(o.test(a))return a.substring(a.indexOf(":")+1).trim()}}getHeaders(r){const n=this.headers[Ze.headerize(r)],o=[];if(n){for(const a of n)o.push(a);return o}else{const a=new RegExp(`^\\s*${r}\\s*:`,"i");for(const t of this.extraHeaders)a.test(t)&&o.push(t.substring(t.indexOf(":")+1).trim());return o}}hasHeader(r){if(this.headers[Ze.headerize(r)])return!0;{const n=new RegExp(`^\\s*${r}\\s*:`,"i");for(const o of this.extraHeaders)if(n.test(o))return!0}return!1}parseSDP(r){return!r&&this.sdp?this.sdp:(this.sdp=Xc.parse(this.body||""),this.sdp)}toString(){let r=`${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 t of this.headers[a])r+=`${a}: ${t}\r
77
+ `;for(const a of this.extraHeaders)r+=`${a.trim()}\r
78
+ `;const n=[];switch(this.method){case _t.REGISTER:n.push("path","gruu");break;case _t.INVITE:this.ua.configuration.session_timers&&n.push("timer"),(this.ua.contact.pub_gruu||this.ua.contact.temp_gruu)&&n.push("gruu"),n.push("ice","replaces");break;case _t.UPDATE:this.ua.configuration.session_timers&&n.push("timer"),n.push("ice");break}n.push("outbound");const o=this.ua.configuration.user_agent||_t.USER_AGENT;if(r+=`Allow: ${_t.ALLOWED_METHODS}\r
79
+ `,r+=`Supported: ${n}\r
80
+ `,r+=`User-Agent: ${o}\r
81
+ `,this.body){const a=Ze.str_utf8_length(this.body);r+=`Content-Length: ${a}\r
82
+ \r
83
+ `,r+=this.body}else r+=`Content-Length: 0\r
84
+ \r
85
+ `;return r}clone(){const r=new Hl(this.method,this.ruri,this.ua);return Object.keys(this.headers).forEach(function(n){r.headers[n]=this.headers[n].slice()},this),r.body=this.body,r.extraHeaders=Ze.cloneArray(this.extraHeaders),r.to=this.to,r.from=this.from,r.call_id=this.call_id,r.cseq=this.cseq,r}}class Ca extends Hl{constructor(r,n,o,a,t){super(_t.INVITE,r,n,o,a,t),this.transaction=null}cancel(r){this.transaction.cancel(r)}clone(){const r=new Ca(this.ruri,this.ua);return Object.keys(this.headers).forEach(function(n){r.headers[n]=this.headers[n].slice()},this),r.body=this.body,r.extraHeaders=Ze.cloneArray(this.extraHeaders),r.to=this.to,r.from=this.from,r.call_id=this.call_id,r.cseq=this.cseq,r.transaction=this.transaction,r}}class Zc{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(r,n){const o={raw:n};r=Ze.headerize(r),this.headers[r]?this.headers[r].push(o):this.headers[r]=[o]}getHeader(r){const n=this.headers[Ze.headerize(r)];if(n){if(n[0])return n[0].raw}else return}getHeaders(r){const n=this.headers[Ze.headerize(r)],o=[];if(!n)return[];for(const a of n)o.push(a.raw);return o}hasHeader(r){return!!this.headers[Ze.headerize(r)]}parseHeader(r,n=0){if(r=Ze.headerize(r),this.headers[r]){if(n>=this.headers[r].length){Sa.debug(`not so many "${r}" headers present`);return}}else{Sa.debug(`header "${r}" not present`);return}const o=this.headers[r][n],a=o.raw;if(o.parsed)return o.parsed;const t=Hp.parse(a,r.replace(/-/g,"_"));if(t===-1){this.headers[r].splice(n,1),Sa.debug(`error parsing "${r}" header field with value "${a}"`);return}else return o.parsed=t,t}s(r,n){return this.parseHeader(r,n)}setHeader(r,n){const o={raw:n};this.headers[Ze.headerize(r)]=[o]}parseSDP(r){return!r&&this.sdp?this.sdp:(this.sdp=Xc.parse(this.body||""),this.sdp)}toString(){return this.data}}class Fp extends Zc{constructor(r){super(),this.ua=r,this.headers={},this.ruri=null,this.transport=null,this.server_transaction=null}reply(r,n,o,a,t,s){const p=[];let _=this.getHeader("To");if(r=r||null,n=n||null,!r||r<100||r>699)throw new TypeError(`Invalid status_code: ${r}`);if(n&&typeof n!="string"&&!(n instanceof String))throw new TypeError(`Invalid reason_phrase: ${n}`);n=n||_t.REASON_PHRASE[r]||"",o=Ze.cloneArray(o),this.ua.configuration.extra_headers&&(o=o.concat(this.ua.configuration.extra_headers));let d=`SIP/2.0 ${r} ${n}\r
86
+ `;if(this.method===_t.INVITE&&r>100&&r<=200){const v=this.getHeaders("record-route");for(const E of v)d+=`Record-Route: ${E}\r
87
+ `}const g=this.getHeaders("via");for(const v of g)d+=`Via: ${v}\r
88
+ `;!this.to_tag&&r>100?_+=`;tag=${Ze.newTag()}`:this.to_tag&&!this.s("to").hasParam("tag")&&(_+=`;tag=${this.to_tag}`),d+=`To: ${_}\r
89
+ `,d+=`From: ${this.getHeader("From")}\r
90
+ `,d+=`Call-ID: ${this.call_id}\r
91
+ `,d+=`CSeq: ${this.cseq} ${this.method}\r
92
+ `;for(const v of o)d+=`${v.trim()}\r
93
+ `;switch(this.method){case _t.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 _t.UPDATE:this.ua.configuration.session_timers&&p.push("timer"),a&&p.push("ice"),p.push("replaces")}if(p.push("outbound"),this.method===_t.OPTIONS?(d+=`Allow: ${_t.ALLOWED_METHODS}\r
94
+ `,d+=`Accept: ${_t.ACCEPTED_BODY_TYPES}\r
95
+ `):r===405?d+=`Allow: ${_t.ALLOWED_METHODS}\r
96
+ `:r===415&&(d+=`Accept: ${_t.ACCEPTED_BODY_TYPES}\r
97
+ `),d+=`Supported: ${p}\r
98
+ `,a){const v=Ze.str_utf8_length(a);d+=`Content-Type: application/sdp\r
99
+ `,d+=`Content-Length: ${v}\r
100
+ \r
101
+ `,d+=a}else d+=`Content-Length: 0\r
102
+ \r
103
+ `;this.server_transaction.receiveResponse(r,d,t,s)}reply_sl(r=null,n=null){const o=this.getHeaders("via");if(!r||r<100||r>699)throw new TypeError(`Invalid status_code: ${r}`);if(n&&typeof n!="string"&&!(n instanceof String))throw new TypeError(`Invalid reason_phrase: ${n}`);n=n||_t.REASON_PHRASE[r]||"";let a=`SIP/2.0 ${r} ${n}\r
104
+ `;for(const s of o)a+=`Via: ${s}\r
105
+ `;let t=this.getHeader("To");if(!this.to_tag&&r>100?t+=`;tag=${Ze.newTag()}`:this.to_tag&&!this.s("to").hasParam("tag")&&(t+=`;tag=${this.to_tag}`),a+=`To: ${t}\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 s of this.ua.configuration.extra_headers)a+=`${s.trim()}\r
110
+ `;a+=`Content-Length: 0\r
111
+ \r
112
+ `,this.transport.send(a)}}class qp extends Zc{constructor(){super(),this.headers={},this.status_code=null,this.reason_phrase=null}}var Kt={OutgoingRequest:Hl,InitialOutgoingInviteRequest:Ca,IncomingRequest:Fp,IncomingResponse:qp};const jp=it,ls=ft(),$t=new jp("DigestAuthentication");var ef=class{constructor(r){this._credentials=r,this._cnonce=null,this._nc=0,this._ncHex="00000000",this._algorithm=null,this._realm=null,this._nonce=null,this._opaque=null,this._stale=null,this._qop=null,this._method=null,this._uri=null,this._ha1=null,this._response=null}get(r){switch(r){case"realm":return this._realm;case"ha1":return this._ha1;default:$t.warn('get() | cannot get "%s" parameter',r);return}}authenticate({method:r,ruri:n,body:o},a,t=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 $t.warn('authenticate() | challenge with Digest algorithm different than "MD5", authentication aborted'),!1}else this._algorithm="MD5";if(!this._nonce)return $t.warn("authenticate() | challenge without Digest nonce, authentication aborted"),!1;if(!this._realm)return $t.warn("authenticate() | challenge without Digest realm, authentication aborted"),!1;if(!this._credentials.password){if(!this._credentials.ha1)return $t.warn("authenticate() | no plain SIP password nor ha1 provided, authentication aborted"),!1;if(this._credentials.realm!==this._realm)return $t.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 $t.warn('authenticate() | challenge without Digest qop different than "auth" or "auth-int", authentication aborted'),!1;else this._qop=null;this._method=r,this._uri=n,this._cnonce=t||ls.createRandomToken(12),this._nc+=1;const s=Number(this._nc).toString(16);this._ncHex="00000000".substr(0,8-s.length)+s,this._nc===4294967296&&(this._nc=1,this._ncHex="00000001"),this._credentials.password?this._ha1=ls.calculateMD5(`${this._credentials.username}:${this._realm}:${this._credentials.password}`):this._ha1=this._credentials.ha1;let p,_;return this._qop==="auth"?(p=`${this._method}:${this._uri}`,_=ls.calculateMD5(p),$t.debug('authenticate() | using qop=auth [a2:"%s"]',p),this._response=ls.calculateMD5(`${this._ha1}:${this._nonce}:${this._ncHex}:${this._cnonce}:auth:${_}`)):this._qop==="auth-int"?(p=`${this._method}:${this._uri}:${ls.calculateMD5(o||"")}`,_=ls.calculateMD5(p),$t.debug('authenticate() | using qop=auth-int [a2:"%s"]',p),this._response=ls.calculateMD5(`${this._ha1}:${this._nonce}:${this._ncHex}:${this._cnonce}:auth-int:${_}`)):this._qop===null&&(p=`${this._method}:${this._uri}`,_=ls.calculateMD5(p),$t.debug('authenticate() | using qop=null [a2:"%s"]',p),this._response=ls.calculateMD5(`${this._ha1}:${this._nonce}:${_}`)),$t.debug("authenticate() | response generated"),!0}toString(){const r=[];if(!this._response)throw new Error("response field does not exist, cannot generate Authorization header");return r.push(`algorithm=${this._algorithm}`),r.push(`username="${this._credentials.username}"`),r.push(`realm="${this._realm}"`),r.push(`nonce="${this._nonce}"`),r.push(`uri="${this._uri}"`),r.push(`response="${this._response}"`),this._opaque&&r.push(`opaque="${this._opaque}"`),this._qop&&(r.push(`qop=${this._qop}`),r.push(`cnonce="${this._cnonce}"`),r.push(`nc=${this._ncHex}`)),`Digest ${r.join(", ")}`}};const Vp=qt(ef),os=500,Bp=4e3,tf=5e3;var sf={T1:os,T2:Bp,T4:tf,TIMER_B:64*os,TIMER_D:0*os,TIMER_F:64*os,TIMER_H:64*os,TIMER_I:0*os,TIMER_J:0*os,TIMER_K:0*tf,TIMER_L:64*os,TIMER_M:64*os,PROVISIONAL_RESPONSE_INTERVAL:6e4};const br=ot.EventEmitter,wr=it,Or=we,nf=Kt,Wt=sf,rf=new wr("NonInviteClientTransaction"),Fl=new wr("InviteClientTransaction"),Gp=new wr("AckClientTransaction"),lf=new wr("NonInviteServerTransaction"),ql=new wr("InviteServerTransaction"),ae={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 Kp extends br{constructor(r,n,o,a){super(),this.type=ae.NON_INVITE_CLIENT,this.id=`z9hG4bK${Math.floor(Math.random()*1e7)}`,this.ua=r,this.transport=n,this.request=o,this.eventHandlers=a;let t=`SIP/2.0/${n.via_transport}`;t+=` ${r.configuration.via_host};branch=${this.id}`,this.request.setHeader("via",t),this.ua.newTransaction(this)}get C(){return ae}stateChanged(r){this.state=r,this.emit("stateChanged")}send(){this.stateChanged(ae.STATUS_TRYING),this.F=setTimeout(()=>{this.timer_F()},Wt.TIMER_F),this.transport.send(this.request)||this.onTransportError()}onTransportError(){rf.debug(`transport error occurred, deleting transaction ${this.id}`),clearTimeout(this.F),clearTimeout(this.K),this.stateChanged(ae.STATUS_TERMINATED),this.ua.destroyTransaction(this),this.eventHandlers.onTransportError()}timer_F(){rf.debug(`Timer F expired for transaction ${this.id}`),this.stateChanged(ae.STATUS_TERMINATED),this.ua.destroyTransaction(this),this.eventHandlers.onRequestTimeout()}timer_K(){this.stateChanged(ae.STATUS_TERMINATED),this.ua.destroyTransaction(this)}receiveResponse(r){const n=r.status_code;if(n<200)switch(this.state){case ae.STATUS_TRYING:case ae.STATUS_PROCEEDING:this.stateChanged(ae.STATUS_PROCEEDING),this.eventHandlers.onReceiveResponse(r);break}else switch(this.state){case ae.STATUS_TRYING:case ae.STATUS_PROCEEDING:this.stateChanged(ae.STATUS_COMPLETED),clearTimeout(this.F),n===408?this.eventHandlers.onRequestTimeout():this.eventHandlers.onReceiveResponse(r),this.K=setTimeout(()=>{this.timer_K()},Wt.TIMER_K);break;case ae.STATUS_COMPLETED:break}}}class Wp extends br{constructor(r,n,o,a){super(),this.type=ae.INVITE_CLIENT,this.id=`z9hG4bK${Math.floor(Math.random()*1e7)}`,this.ua=r,this.transport=n,this.request=o,this.eventHandlers=a,o.transaction=this;let t=`SIP/2.0/${n.via_transport}`;t+=` ${r.configuration.via_host};branch=${this.id}`,this.request.setHeader("via",t),this.ua.newTransaction(this)}get C(){return ae}stateChanged(r){this.state=r,this.emit("stateChanged")}send(){this.stateChanged(ae.STATUS_CALLING),this.B=setTimeout(()=>{this.timer_B()},Wt.TIMER_B),this.transport.send(this.request)||this.onTransportError()}onTransportError(){clearTimeout(this.B),clearTimeout(this.D),clearTimeout(this.M),this.state!==ae.STATUS_ACCEPTED&&(Fl.debug(`transport error occurred, deleting transaction ${this.id}`),this.eventHandlers.onTransportError()),this.stateChanged(ae.STATUS_TERMINATED),this.ua.destroyTransaction(this)}timer_M(){Fl.debug(`Timer M expired for transaction ${this.id}`),this.state===ae.STATUS_ACCEPTED&&(clearTimeout(this.B),this.stateChanged(ae.STATUS_TERMINATED),this.ua.destroyTransaction(this))}timer_B(){Fl.debug(`Timer B expired for transaction ${this.id}`),this.state===ae.STATUS_CALLING&&(this.stateChanged(ae.STATUS_TERMINATED),this.ua.destroyTransaction(this),this.eventHandlers.onRequestTimeout())}timer_D(){Fl.debug(`Timer D expired for transaction ${this.id}`),clearTimeout(this.B),this.stateChanged(ae.STATUS_TERMINATED),this.ua.destroyTransaction(this)}sendACK(r){const n=new nf.OutgoingRequest(Or.ACK,this.request.ruri,this.ua,{route_set:this.request.getHeaders("route"),call_id:this.request.getHeader("call-id"),cseq:this.request.cseq});n.setHeader("from",this.request.getHeader("from")),n.setHeader("via",this.request.getHeader("via")),n.setHeader("to",r.getHeader("to")),this.D=setTimeout(()=>{this.timer_D()},Wt.TIMER_D),this.transport.send(n)}cancel(r){if(this.state!==ae.STATUS_PROCEEDING)return;const n=new nf.OutgoingRequest(Or.CANCEL,this.request.ruri,this.ua,{route_set:this.request.getHeaders("route"),call_id:this.request.getHeader("call-id"),cseq:this.request.cseq});n.setHeader("from",this.request.getHeader("from")),n.setHeader("via",this.request.getHeader("via")),n.setHeader("to",this.request.getHeader("to")),r&&n.setHeader("reason",r),this.transport.send(n)}receiveResponse(r){const n=r.status_code;if(n>=100&&n<=199)switch(this.state){case ae.STATUS_CALLING:this.stateChanged(ae.STATUS_PROCEEDING),this.eventHandlers.onReceiveResponse(r);break;case ae.STATUS_PROCEEDING:this.eventHandlers.onReceiveResponse(r);break}else if(n>=200&&n<=299)switch(this.state){case ae.STATUS_CALLING:case ae.STATUS_PROCEEDING:this.stateChanged(ae.STATUS_ACCEPTED),this.M=setTimeout(()=>{this.timer_M()},Wt.TIMER_M),this.eventHandlers.onReceiveResponse(r);break;case ae.STATUS_ACCEPTED:this.eventHandlers.onReceiveResponse(r);break}else if(n>=300&&n<=699)switch(this.state){case ae.STATUS_CALLING:case ae.STATUS_PROCEEDING:this.stateChanged(ae.STATUS_COMPLETED),this.sendACK(r),this.eventHandlers.onReceiveResponse(r);break;case ae.STATUS_COMPLETED:this.sendACK(r);break}}}class Yp extends br{constructor(r,n,o,a){super(),this.id=`z9hG4bK${Math.floor(Math.random()*1e7)}`,this.transport=n,this.request=o,this.eventHandlers=a;let t=`SIP/2.0/${n.via_transport}`;t+=` ${r.configuration.via_host};branch=${this.id}`,this.request.setHeader("via",t)}get C(){return ae}send(){this.transport.send(this.request)||this.onTransportError()}onTransportError(){Gp.debug(`transport error occurred for transaction ${this.id}`),this.eventHandlers.onTransportError()}}class zp extends br{constructor(r,n,o){super(),this.type=ae.NON_INVITE_SERVER,this.id=o.via_branch,this.ua=r,this.transport=n,this.request=o,this.last_response="",o.server_transaction=this,this.state=ae.STATUS_TRYING,r.newTransaction(this)}get C(){return ae}stateChanged(r){this.state=r,this.emit("stateChanged")}timer_J(){lf.debug(`Timer J expired for transaction ${this.id}`),this.stateChanged(ae.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(ae.STATUS_TERMINATED),this.ua.destroyTransaction(this))}receiveResponse(r,n,o,a){if(r===100)switch(this.state){case ae.STATUS_TRYING:this.stateChanged(ae.STATUS_PROCEEDING),this.transport.send(n)||this.onTransportError();break;case ae.STATUS_PROCEEDING:this.last_response=n,this.transport.send(n)?o&&o():(this.onTransportError(),a&&a());break}else if(r>=200&&r<=699)switch(this.state){case ae.STATUS_TRYING:case ae.STATUS_PROCEEDING:this.stateChanged(ae.STATUS_COMPLETED),this.last_response=n,this.J=setTimeout(()=>{this.timer_J()},Wt.TIMER_J),this.transport.send(n)?o&&o():(this.onTransportError(),a&&a());break;case ae.STATUS_COMPLETED:break}}}class Jp extends br{constructor(r,n,o){super(),this.type=ae.INVITE_SERVER,this.id=o.via_branch,this.ua=r,this.transport=n,this.request=o,this.last_response="",o.server_transaction=this,this.state=ae.STATUS_PROCEEDING,r.newTransaction(this),this.resendProvisionalTimer=null,o.reply(100)}get C(){return ae}stateChanged(r){this.state=r,this.emit("stateChanged")}timer_H(){ql.debug(`Timer H expired for transaction ${this.id}`),this.state===ae.STATUS_COMPLETED&&ql.debug("ACK not received, dialog will be terminated"),this.stateChanged(ae.STATUS_TERMINATED),this.ua.destroyTransaction(this)}timer_I(){this.stateChanged(ae.STATUS_TERMINATED),this.ua.destroyTransaction(this)}timer_L(){ql.debug(`Timer L expired for transaction ${this.id}`),this.state===ae.STATUS_ACCEPTED&&(this.stateChanged(ae.STATUS_TERMINATED),this.ua.destroyTransaction(this))}onTransportError(){this.transportError||(this.transportError=!0,ql.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(ae.STATUS_TERMINATED),this.ua.destroyTransaction(this))}resend_provisional(){this.transport.send(this.last_response)||this.onTransportError()}receiveResponse(r,n,o,a){if(r>=100&&r<=199)switch(this.state){case ae.STATUS_PROCEEDING:this.transport.send(n)||this.onTransportError(),this.last_response=n;break}if(r>100&&r<=199&&this.state===ae.STATUS_PROCEEDING)this.resendProvisionalTimer===null&&(this.resendProvisionalTimer=setInterval(()=>{this.resend_provisional()},Wt.PROVISIONAL_RESPONSE_INTERVAL));else if(r>=200&&r<=299)switch(this.state){case ae.STATUS_PROCEEDING:this.stateChanged(ae.STATUS_ACCEPTED),this.last_response=n,this.L=setTimeout(()=>{this.timer_L()},Wt.TIMER_L),this.resendProvisionalTimer!==null&&(clearInterval(this.resendProvisionalTimer),this.resendProvisionalTimer=null);case ae.STATUS_ACCEPTED:this.transport.send(n)?o&&o():(this.onTransportError(),a&&a());break}else if(r>=300&&r<=699)switch(this.state){case ae.STATUS_PROCEEDING:this.resendProvisionalTimer!==null&&(clearInterval(this.resendProvisionalTimer),this.resendProvisionalTimer=null),this.transport.send(n)?(this.stateChanged(ae.STATUS_COMPLETED),this.H=setTimeout(()=>{this.timer_H()},Wt.TIMER_H),o&&o()):(this.onTransportError(),a&&a());break}}}function Xp({_transactions:c},r){let n;switch(r.method){case Or.INVITE:if(n=c.ist[r.via_branch],n){switch(n.state){case ae.STATUS_PROCEEDING:n.transport.send(n.last_response);break;case ae.STATUS_ACCEPTED:break}return!0}break;case Or.ACK:if(n=c.ist[r.via_branch],n){if(n.state===ae.STATUS_ACCEPTED)return!1;if(n.state===ae.STATUS_COMPLETED)return n.state=ae.STATUS_CONFIRMED,n.I=setTimeout(()=>{n.timer_I()},Wt.TIMER_I),!0}else return!1;break;case Or.CANCEL:return n=c.ist[r.via_branch],n?(r.reply_sl(200),n.state!==ae.STATUS_PROCEEDING):(r.reply_sl(481),!0);default:if(n=c.nist[r.via_branch],n){switch(n.state){case ae.STATUS_TRYING:break;case ae.STATUS_PROCEEDING:case ae.STATUS_COMPLETED:n.transport.send(n.last_response);break}return!0}break}}var Cn={C:ae,NonInviteClientTransaction:Kp,InviteClientTransaction:Wp,AckClientTransaction:Yp,NonInviteServerTransaction:zp,InviteServerTransaction:Jp,checkTransaction:Xp};const Dr=qt(Cn),Qp=it,of=we,Zp=ef,Aa=Cn,em=new Qp("RequestSender"),Ra={onRequestTimeout:()=>{},onTransportError:()=>{},onReceiveResponse:()=>{},onAuthenticated:()=>{}};var An=class{constructor(r,n,o){this._ua=r,this._eventHandlers=o,this._method=n.method,this._request=n,this._auth=null,this._challenged=!1,this._staled=!1;for(const a in Ra)Object.prototype.hasOwnProperty.call(Ra,a)&&(this._eventHandlers[a]||(this._eventHandlers[a]=Ra[a]));r.status===r.C.STATUS_USER_CLOSED&&(this._method!==of.BYE||this._method!==of.ACK)&&this._eventHandlers.onTransportError()}send(){const r={onRequestTimeout:()=>{this._eventHandlers.onRequestTimeout()},onTransportError:()=>{this._eventHandlers.onTransportError()},onReceiveResponse:n=>{this._receiveResponse(n)}};switch(this._method){case"INVITE":this.clientTransaction=new Aa.InviteClientTransaction(this._ua,this._ua.transport,this._request,r);break;case"ACK":this.clientTransaction=new Aa.AckClientTransaction(this._ua,this._ua.transport,this._request,r);break;default:this.clientTransaction=new Aa.NonInviteClientTransaction(this._ua,this._ua.transport,this._request,r)}this._ua._configuration.authorization_jwt&&this._request.setHeader("Authorization",this._ua._configuration.authorization_jwt),this.clientTransaction.send()}_receiveResponse(r){let n,o;const a=r.status_code;if((a===401||a===407)&&(this._ua.configuration.password!==null||this._ua.configuration.ha1!==null)){if(r.status_code===401?(n=r.parseHeader("www-authenticate"),o="authorization"):(n=r.parseHeader("proxy-authenticate"),o="proxy-authorization"),!n){em.debug(`${r.status_code} with wrong or missing challenge, cannot authenticate`),this._eventHandlers.onReceiveResponse(r);return}if(!this._challenged||!this._staled&&n.stale===!0){if(this._auth||(this._auth=new Zp({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,n)){this._eventHandlers.onReceiveResponse(r);return}this._challenged=!0,this._ua.set("realm",this._auth.get("realm")),this._ua.set("ha1",this._auth.get("ha1")),n.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(o,this._auth.toString()),this._eventHandlers.onAuthenticated(this._request),this.send()}else this._eventHandlers.onReceiveResponse(r)}else this._eventHandlers.onReceiveResponse(r)}};const tm=qt(An),sm=it,Ia=ft(),js=we,af=Kt,uf=An,Nr=new sm("Registrator"),jl=10;var nm=class{constructor(r,n){this._reg_id=1,this._ua=r,this._transport=n,this._registrar=r.configuration.registrar_server,this._expires=r.configuration.register_expires,this._call_id=Ia.createRandomToken(22),this._cseq=0,this._to_uri=r.configuration.uri,this._registrationTimer=null,this._registering=!1,this._registered=!1,this._contact=this._ua.contact.toString(),this._contact+=";+sip.ice",this._extraHeaders=[],this._extraContactParams="",this._sipInstance=`"<urn:uuid:${this._ua.configuration.instance_id}>"`,this._contact+=`;reg-id=${this._reg_id}`,this._contact+=`;+sip.instance=${this._sipInstance}`}get registered(){return this._registered}setExtraHeaders(r){Array.isArray(r)||(r=[]),this._extraHeaders=r.slice()}setExtraContactParams(r){r instanceof Object||(r={}),this._extraContactParams="";for(const n in r)if(Object.prototype.hasOwnProperty.call(r,n)){const o=r[n];this._extraContactParams+=`;${n}`,o&&(this._extraContactParams+=`=${o}`)}}register(){if(this._registering){Nr.debug("Register request in progress...");return}const r=this._extraHeaders.slice();r.push(`Contact: ${this._contact};expires=${this._expires}${this._extraContactParams}`),r.push(`Expires: ${this._expires}`);const n=new af.OutgoingRequest(js.REGISTER,this._registrar,this._ua,{to_uri:this._to_uri,call_id:this._call_id,cseq:this._cseq+=1},r),o=new uf(this._ua,n,{onRequestTimeout:()=>{this._registrationFailure(null,js.causes.REQUEST_TIMEOUT)},onTransportError:()=>{this._registrationFailure(null,js.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")){Nr.debug("no Contact header in response to REGISTER, response ignored");break}const t=a.headers.Contact.reduce((d,g)=>d.concat(g.parsed),[]);let s=t.find(d=>this._sipInstance===d.getParam("+sip.instance")&&this._reg_id===parseInt(d.getParam("reg-id")));if(s||(s=t.find(d=>d.uri.user===this._ua.contact.uri.user)),!s){Nr.debug("no Contact header pointing to us, response ignored");break}let p=s.getParam("expires");!p&&a.hasHeader("expires")&&(p=a.getHeader("expires")),p||(p=this._expires),p=Number(p),p<jl&&(p=jl);const _=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")},_),s.hasParam("temp-gruu")&&(this._ua.contact.temp_gruu=s.getParam("temp-gruu").replace(/"/g,"")),s.hasParam("pub-gruu")&&(this._ua.contact.pub_gruu=s.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<jl&&(this._expires=jl),this.register()):(Nr.debug("423 response received for REGISTER without Min-Expires"),this._registrationFailure(a,js.causes.SIP_FAILURE_CODE));break}default:{const t=Ia.sipErrorCause(a.status_code);this._registrationFailure(a,t)}}}});this._registering=!0,o.send()}unregister(r={}){if(!this._registered){Nr.debug("already unregistered");return}this._registered=!1,this._registrationTimer!==null&&(clearTimeout(this._registrationTimer),this._registrationTimer=null);const n=this._extraHeaders.slice();r.all?n.push(`Contact: *${this._extraContactParams}`):n.push(`Contact: ${this._contact};expires=0${this._extraContactParams}`),n.push("Expires: 0");const o=new af.OutgoingRequest(js.REGISTER,this._registrar,this._ua,{to_uri:this._to_uri,call_id:this._call_id,cseq:this._cseq+=1},n);new uf(this._ua,o,{onRequestTimeout:()=>{this._unregistered(null,js.causes.REQUEST_TIMEOUT)},onTransportError:()=>{this._unregistered(null,js.causes.CONNECTION_ERROR)},onAuthenticated:()=>{this._cseq+=1},onReceiveResponse:t=>{switch(!0){case/^1[0-9]{2}$/.test(t.status_code):break;case/^2[0-9]{2}$/.test(t.status_code):this._unregistered(t);break;default:{const s=Ia.sipErrorCause(t.status_code);this._unregistered(t,s)}}}}).send()}close(){this._registered&&this.unregister()}onTransportClosed(){this._registering=!1,this._registrationTimer!==null&&(clearTimeout(this._registrationTimer),this._registrationTimer=null),this._registered&&(this._registered=!1,this._ua.unregistered({}))}_registrationFailure(r,n){this._registering=!1,this._ua.registrationFailed({response:r||null,cause:n}),this._registered&&(this._registered=!1,this._ua.unregistered({response:r||null,cause:n}))}_unregistered(r,n){this._registering=!1,this._registered=!1,this._ua.unregistered({response:r||null,cause:n||null})}};class rm extends Error{constructor(r,n){super(),this.code=1,this.name="CONFIGURATION_ERROR",this.parameter=r,this.value=n,this.message=this.value?`Invalid value ${JSON.stringify(this.value)} for parameter "${this.parameter}"`:`Missing parameter: ${this.parameter}`}}class im extends Error{constructor(r){super(),this.code=2,this.name="INVALID_STATE_ERROR",this.status=r,this.message=`Invalid status: ${r}`}}class lm extends Error{constructor(r){super(),this.code=3,this.name="NOT_SUPPORTED_ERROR",this.message=r}}class om extends Error{constructor(r){super(),this.code=4,this.name="NOT_READY_ERROR",this.message=r}}var as={ConfigurationError:rm,InvalidStateError:im,NotSupportedError:lm,NotReadyError:om};const am=qt(as),ba=we,Vl=Cn,um=An,wa={onRequestTimeout:()=>{},onTransportError:()=>{},onSuccessResponse:()=>{},onErrorResponse:()=>{},onAuthenticated:()=>{},onDialogError:()=>{}};var cm=class{constructor(r,n,o){this._dialog=r,this._ua=r._ua,this._request=n,this._eventHandlers=o,this._reattempt=!1,this._reattemptTimer=null;for(const a in wa)Object.prototype.hasOwnProperty.call(wa,a)&&(this._eventHandlers[a]||(this._eventHandlers[a]=wa[a]))}get request(){return this._request}send(){const r=new um(this._ua,this._request,{onRequestTimeout:()=>{this._eventHandlers.onRequestTimeout()},onTransportError:()=>{this._eventHandlers.onTransportError()},onAuthenticated:n=>{this._eventHandlers.onAuthenticated(n)},onReceiveResponse:n=>{this._receiveResponse(n)}});if(r.send(),(this._request.method===ba.INVITE||this._request.method===ba.UPDATE&&this._request.body)&&r.clientTransaction.state!==Vl.C.STATUS_TERMINATED){this._dialog.uac_pending_reply=!0;const n=()=>{(r.clientTransaction.state===Vl.C.STATUS_ACCEPTED||r.clientTransaction.state===Vl.C.STATUS_COMPLETED||r.clientTransaction.state===Vl.C.STATUS_TERMINATED)&&(r.clientTransaction.removeListener("stateChanged",n),this._dialog.uac_pending_reply=!1)};r.clientTransaction.on("stateChanged",n)}}_receiveResponse(r){r.status_code===408||r.status_code===481?this._eventHandlers.onDialogError(r):r.method===ba.INVITE&&r.status_code===491?this._reattempt?r.status_code>=200&&r.status_code<300?this._eventHandlers.onSuccessResponse(r):r.status_code>=300&&this._eventHandlers.onErrorResponse(r):(this._request.cseq=this._dialog.local_seqnum+=1,this._reattemptTimer=setTimeout(()=>{this._dialog.isTerminated()||(this._reattempt=!0,this.send())},1e3)):r.status_code>=200&&r.status_code<300?this._eventHandlers.onSuccessResponse(r):r.status_code>=300&&this._eventHandlers.onErrorResponse(r)}};const fm=it,cf=Kt,Es=we,Ur=Cn,_m=cm,Oa=ft(),Da=new fm("Dialog"),ys={STATUS_EARLY:1,STATUS_CONFIRMED:2,STATUS_TERMINATED:3};var ff=class{static get C(){return ys}constructor(r,n,o,a=ys.STATUS_CONFIRMED){if(this._owner=r,this._ua=r._ua,this._uac_pending_reply=!1,this._uas_pending_reply=!1,!n.hasHeader("contact"))return{error:"unable to create a Dialog without Contact header field"};n instanceof cf.IncomingResponse&&(a=n.status_code<200?ys.STATUS_EARLY:ys.STATUS_CONFIRMED);const t=n.parseHeader("contact");o==="UAS"?(this._id={call_id:n.call_id,local_tag:n.to_tag,remote_tag:n.from_tag,toString(){return this.call_id+this.local_tag+this.remote_tag}},this._state=a,this._remote_seqnum=n.cseq,this._local_uri=n.parseHeader("to").uri,this._remote_uri=n.parseHeader("from").uri,this._remote_target=t.uri,this._route_set=n.getHeaders("record-route"),this._ack_seqnum=this._remote_seqnum):o==="UAC"&&(this._id={call_id:n.call_id,local_tag:n.from_tag,remote_tag:n.to_tag,toString(){return this.call_id+this.local_tag+this.remote_tag}},this._state=a,this._local_seqnum=n.cseq,this._local_uri=n.parseHeader("from").uri,this._remote_uri=n.parseHeader("to").uri,this._remote_target=t.uri,this._route_set=n.getHeaders("record-route").reverse(),this._ack_seqnum=null),this._ua.newDialog(this),Da.debug(`new ${o} dialog created with status ${this._state===ys.STATUS_EARLY?"EARLY":"CONFIRMED"}`)}get id(){return this._id}get local_seqnum(){return this._local_seqnum}set local_seqnum(r){this._local_seqnum=r}get owner(){return this._owner}get uac_pending_reply(){return this._uac_pending_reply}set uac_pending_reply(r){this._uac_pending_reply=r}get uas_pending_reply(){return this._uas_pending_reply}isTerminated(){return this._status===ys.STATUS_TERMINATED}update(r,n){this._state=ys.STATUS_CONFIRMED,Da.debug(`dialog ${this._id.toString()} changed to CONFIRMED state`),n==="UAC"&&(this._route_set=r.getHeaders("record-route").reverse())}terminate(){Da.debug(`dialog ${this._id.toString()} deleted`),this._ua.destroyDialog(this),this._state=ys.STATUS_TERMINATED}sendRequest(r,n={}){const o=Oa.cloneArray(n.extraHeaders),a=Oa.cloneObject(n.eventHandlers),t=n.body||null,s=this._createRequest(r,o,t);return a.onAuthenticated=()=>{this._local_seqnum+=1},new _m(this,s,a).send(),s}receiveRequest(r){this._checkInDialogRequest(r)&&(r.method===Es.ACK&&this._ack_seqnum!==null?this._ack_seqnum=null:r.method===Es.INVITE&&(this._ack_seqnum=r.cseq),this._owner.receiveRequest(r))}_createRequest(r,n,o){n=Oa.cloneArray(n),this._local_seqnum||(this._local_seqnum=Math.floor(Math.random()*1e4));const a=r===Es.CANCEL||r===Es.ACK?this._local_seqnum:this._local_seqnum+=1;return new cf.OutgoingRequest(r,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},n,o)}_checkInDialogRequest(r){if(!this._remote_seqnum)this._remote_seqnum=r.cseq;else if(r.cseq<this._remote_seqnum)if(r.method===Es.ACK){if(this._ack_seqnum===null||r.cseq!==this._ack_seqnum)return!1}else return r.reply(500),!1;else r.cseq>this._remote_seqnum&&(this._remote_seqnum=r.cseq);if(r.method===Es.INVITE||r.method===Es.UPDATE&&r.body){if(this._uac_pending_reply===!0)r.reply(491);else if(this._uas_pending_reply===!0){const n=(Math.random()*10|0)+1;return r.reply(500,null,[`Retry-After:${n}`]),!1}else{this._uas_pending_reply=!0;const n=()=>{(r.server_transaction.state===Ur.C.STATUS_ACCEPTED||r.server_transaction.state===Ur.C.STATUS_COMPLETED||r.server_transaction.state===Ur.C.STATUS_TERMINATED)&&(r.server_transaction.removeListener("stateChanged",n),this._uas_pending_reply=!1)};r.server_transaction.on("stateChanged",n)}r.hasHeader("contact")&&r.server_transaction.on("stateChanged",()=>{r.server_transaction.state===Ur.C.STATUS_ACCEPTED&&(this._remote_target=r.parseHeader("contact").uri)})}else r.method===Es.NOTIFY&&r.hasHeader("contact")&&r.server_transaction.on("stateChanged",()=>{r.server_transaction.state===Ur.C.STATUS_COMPLETED&&(this._remote_target=r.parseHeader("contact").uri)});return!0}};const Bl=qt(ff);var Na={exports:{}};const hm=ot.EventEmitter,dm=it,pm=we,mm=as,_f=ft(),gm=new dm("RTCSession:DTMF"),hf={MIN_DURATION:70,MAX_DURATION:6e3,DEFAULT_DURATION:100,MIN_INTER_TONE_GAP:50,DEFAULT_INTER_TONE_GAP:500};Na.exports=class extends hm{constructor(r){super(),this._session=r,this._direction=null,this._tone=null,this._duration=null,this._request=null}get tone(){return this._tone}get duration(){return this._duration}send(r,n={}){if(r===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 mm.InvalidStateError(this._session.status);const o=_f.cloneArray(n.extraHeaders);if(this.eventHandlers=_f.cloneObject(n.eventHandlers),typeof r=="string")r=r.toUpperCase();else if(typeof r=="number")r=r.toString();else throw new TypeError(`Invalid tone: ${r}`);if(r.match(/^[0-9A-DR#*]$/))this._tone=r;else throw new TypeError(`Invalid tone: ${r}`);this._duration=n.duration,o.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(pm.INFO,{extraHeaders:o,eventHandlers:{onSuccessResponse:t=>{this.emit("succeeded",{originator:"remote",response:t})},onErrorResponse:t=>{this.eventHandlers.onFailed&&this.eventHandlers.onFailed(),this.emit("failed",{originator:"remote",response:t})},onRequestTimeout:()=>{this._session.onRequestTimeout()},onTransportError:()=>{this._session.onTransportError()},onDialogError:()=>{this._session.onDialogError()}},body:a})}init_incoming(r){const n=/^(Signal\s*?=\s*?)([0-9A-D#*]{1})(\s)?.*/,o=/^(Duration\s?=\s?)([0-9]{1,4})(\s)?.*/;if(this._direction="incoming",this._request=r,r.reply(200),r.body){const a=r.body.split(`
114
+ `);a.length>=1&&n.test(a[0])&&(this._tone=a[0].replace(n,"$2")),a.length>=2&&o.test(a[1])&&(this._duration=parseInt(a[1].replace(o,"$2"),10))}this._duration||(this._duration=hf.DEFAULT_DURATION),this._tone?this._session.newDTMF({originator:"remote",dtmf:this,request:r}):gm.debug("invalid INFO DTMF received, discarded")}},Na.exports.C=hf;var vm=Na.exports;const Tm=ot.EventEmitter,Em=we,ym=as,Sm=ft();var Cm=class extends Tm{constructor(r){super(),this._session=r,this._direction=null,this._contentType=null,this._body=null}get contentType(){return this._contentType}get body(){return this._body}send(r,n,o={}){if(this._direction="outgoing",r===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 ym.InvalidStateError(this._session.status);this._contentType=r,this._body=n;const a=Sm.cloneArray(o.extraHeaders);a.push(`Content-Type: ${r}`),this._session.newInfo({originator:"local",info:this,request:this.request}),this._session.sendRequest(Em.INFO,{extraHeaders:a,eventHandlers:{onSuccessResponse:t=>{this.emit("succeeded",{originator:"remote",response:t})},onErrorResponse:t=>{this.emit("failed",{originator:"remote",response:t})},onTransportError:()=>{this._session.onTransportError()},onRequestTimeout:()=>{this._session.onRequestTimeout()},onDialogError:()=>{this._session.onDialogError()}},body:n})}init_incoming(r){this._direction="incoming",this.request=r,r.reply(200),this._contentType=r.hasHeader("Content-Type")?r.getHeader("Content-Type").toLowerCase():void 0,this._body=r.body,this._session.newInfo({originator:"remote",info:this,request:r})}};const Am=it,df=we,Rm=new Am("RTCSession:ReferNotifier"),Ua={event_type:"refer",body_type:"message/sipfrag;version=2.0",expires:300};var Im=class{constructor(r,n,o){this._session=r,this._id=n,this._expires=o||Ua.expires,this._active=!0,this.notify(100)}notify(r,n){if(Rm.debug("notify()"),this._active===!1)return;n=n||df.REASON_PHRASE[r]||"";let o;r>=200?o="terminated;reason=noresource":o=`active;expires=${this._expires}`,this._session.sendRequest(df.NOTIFY,{extraHeaders:[`Event: ${Ua.event_type};id=${this._id}`,`Subscription-State: ${o}`,`Content-Type: ${Ua.body_type}`],body:`SIP/2.0 ${r} ${n}`,eventHandlers:{onErrorResponse(){this._active=!1}}})}};const bm=ot.EventEmitter,wm=it,Pr=we,Om=Gt(),pf=ft(),Vs=new wm("RTCSession:ReferSubscriber");var Dm=class extends bm{constructor(r){super(),this._id=null,this._session=r}get id(){return this._id}sendRefer(r,n={}){Vs.debug("sendRefer()");const o=pf.cloneArray(n.extraHeaders),a=pf.cloneObject(n.eventHandlers);for(const _ in a)Object.prototype.hasOwnProperty.call(a,_)&&this.on(_,a[_]);let t=null;n.replaces&&(t=n.replaces._request.call_id,t+=`;to-tag=${n.replaces._to_tag}`,t+=`;from-tag=${n.replaces._from_tag}`,t=encodeURIComponent(t));const s=`Refer-To: <${r}${t?`?Replaces=${t}`:""}>`;if(o.push(s),!o.some(_=>_.toLowerCase().startsWith("referred-by:"))){const _=`Referred-By: <${this._session._ua._configuration.uri._scheme}:${this._session._ua._configuration.uri._user}@${this._session._ua._configuration.uri._host}>`;o.push(_)}o.push(`Contact: ${this._session.contact}`);const p=this._session.sendRequest(Pr.REFER,{extraHeaders:o,eventHandlers:{onSuccessResponse:_=>{this._requestSucceeded(_)},onErrorResponse:_=>{this._requestFailed(_,Pr.causes.REJECTED)},onTransportError:()=>{this._requestFailed(null,Pr.causes.CONNECTION_ERROR)},onRequestTimeout:()=>{this._requestFailed(null,Pr.causes.REQUEST_TIMEOUT)},onDialogError:()=>{this._requestFailed(null,Pr.causes.DIALOG_ERROR)}}});this._id=p.cseq}receiveNotify(r){if(Vs.debug("receiveNotify()"),!r.body)return;const n=Om.parse(r.body.trim().split(`\r
115
+ `,1)[0],"Status_Line");if(n===-1){Vs.debug(`receiveNotify() | error parsing NOTIFY body: "${r.body}"`);return}switch(!0){case/^100$/.test(n.status_code):this.emit("trying",{request:r,status_line:n});break;case/^1[0-9]{2}$/.test(n.status_code):this.emit("progress",{request:r,status_line:n});break;case/^2[0-9]{2}$/.test(n.status_code):this.emit("accepted",{request:r,status_line:n});break;default:this.emit("failed",{request:r,status_line:n});break}}_requestSucceeded(r){Vs.debug("REFER succeeded"),Vs.debug('emit "requestSucceeded"'),this.emit("requestSucceeded",{response:r})}_requestFailed(r,n){Vs.debug("REFER failed"),Vs.debug('emit "requestFailed"'),this.emit("requestFailed",{response:r||null,cause:n})}};const Nm=ot.EventEmitter,mf=wt,Um=it,ue=we,Bs=as,gf=Cn,qe=ft(),kr=sf,Pm=Kt,Gl=ff,km=An,bt=vm,vf=Cm,Mm=Im,xm=Dm,Tf=is(),K=new Um("RTCSession"),J={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},Kl=["audio","video"];var Lm=class gu extends Nm{static get C(){return J}constructor(r){K.debug("new"),super(),this._id=null,this._ua=r,this._status=J.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:ue.SESSION_EXPIRES,currentExpires:null,running:!1,refresher:!1,timer:null},this._referSubscribers={},this._data={}}get C(){return J}get causes(){return ue.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(r){this._data=r}get status(){return this._status}isInProgress(){switch(this._status){case J.STATUS_NULL:case J.STATUS_INVITE_SENT:case J.STATUS_1XX_RECEIVED:case J.STATUS_INVITE_RECEIVED:case J.STATUS_WAITING_FOR_ANSWER:return!0;default:return!1}}isEstablished(){switch(this._status){case J.STATUS_ANSWERED:case J.STATUS_WAITING_FOR_ACK:case J.STATUS_CONFIRMED:return!0;default:return!1}}isEnded(){switch(this._status){case J.STATUS_CANCELED:case J.STATUS_TERMINATED:return!0;default:return!1}}isMuted(){return{audio:this._audioMuted,video:this._videoMuted}}isOnHold(){return{local:this._localHold,remote:this._remoteHold}}connect(r,n={},o){K.debug("connect()");const a=r,t=qe.cloneObject(n.eventHandlers),s=qe.cloneArray(n.extraHeaders),p=qe.cloneObject(n.mediaConstraints,{audio:!0,video:!0}),_=n.mediaStream||null,d=qe.cloneObject(n.pcConfig,{iceServers:[]}),g=n.rtcConstraints||null,v=n.rtcOfferConstraints||null;if(this._rtcOfferConstraints=v,this._rtcAnswerConstraints=n.rtcAnswerConstraints||null,this._data=n.data||this._data,r===void 0)throw new TypeError("Not enough arguments");if(this._status!==J.STATUS_NULL)throw new Bs.InvalidStateError(this._status);if(!window.RTCPeerConnection)throw new Bs.NotSupportedError("WebRTC not supported");if(r=this._ua.normalizeTarget(r),!r)throw new TypeError(`Invalid target: ${a}`);this._sessionTimers.enabled&&qe.isDecimal(n.sessionTimersExpires)&&(n.sessionTimersExpires>=ue.MIN_SESSION_EXPIRES?this._sessionTimers.defaultExpires=n.sessionTimersExpires:this._sessionTimers.defaultExpires=ue.SESSION_EXPIRES);for(const C in t)Object.prototype.hasOwnProperty.call(t,C)&&this.on(C,t[C]);this._from_tag=qe.newTag();const E=n.anonymous||!1,S={from_tag:this._from_tag};this._contact=this._ua.contact.toString({anonymous:E,outbound:!0}),E?(S.from_display_name="Anonymous",S.from_uri=new Tf("sip","anonymous","anonymous.invalid"),s.push(`P-Preferred-Identity: ${this._ua.configuration.uri.toString()}`),s.push("Privacy: id")):n.fromUserName&&(S.from_uri=new Tf("sip",n.fromUserName,this._ua.configuration.uri.host),s.push(`P-Preferred-Identity: ${this._ua.configuration.uri.toString()}`)),n.fromDisplayName&&(S.from_display_name=n.fromDisplayName),s.push(`Contact: ${this._contact}`),s.push("Content-Type: application/sdp"),this._sessionTimers.enabled&&s.push(`Session-Expires: ${this._sessionTimers.defaultExpires}${this._ua.configuration.session_timers_force_refresher?";refresher=uac":""}`),this._request=new Pm.InitialOutgoingInviteRequest(r,this._ua,S,s),this._id=this._request.call_id+this._from_tag,this._createRTCConnection(d,g),this._direction="outgoing",this._local_identity=this._request.from,this._remote_identity=this._request.to,o&&o(this),this._newRTCSession("local",this._request),this._sendInitialRequest(p,v,_)}init_incoming(r,n){K.debug("init_incoming()");let o;const a=r.hasHeader("Content-Type")?r.getHeader("Content-Type").toLowerCase():void 0;if(r.body&&a!=="application/sdp"){r.reply(415);return}if(this._status=J.STATUS_INVITE_RECEIVED,this._from_tag=r.from_tag,this._id=r.call_id+this._from_tag,this._request=r,this._contact=this._ua.contact.toString(),r.hasHeader("expires")&&(o=r.getHeader("expires")*1e3),r.to_tag=qe.newTag(),!this._createDialog(r,"UAS",!0)){r.reply(500,"Missing Contact header field");return}r.body?this._late_sdp=!1:this._late_sdp=!0,this._status=J.STATUS_WAITING_FOR_ANSWER,this._timers.userNoAnswerTimer=setTimeout(()=>{r.reply(408),this._failed("local",null,ue.causes.NO_ANSWER)},this._ua.configuration.no_answer_timeout),o&&(this._timers.expiresTimer=setTimeout(()=>{this._status===J.STATUS_WAITING_FOR_ANSWER&&(r.reply(487),this._failed("system",null,ue.causes.EXPIRES))},o)),this._direction="incoming",this._local_identity=r.to,this._remote_identity=r.from,n&&n(this),this._newRTCSession("remote",r),this._status!==J.STATUS_TERMINATED&&(r.reply(180,null,[`Contact: ${this._contact}`]),this._progress("local",null))}answer(r={}){K.debug("answer()");const n=this._request,o=qe.cloneArray(r.extraHeaders),a=qe.cloneObject(r.mediaConstraints),t=r.mediaStream||null,s=qe.cloneObject(r.pcConfig,{iceServers:[]}),p=r.rtcConstraints||null,_=r.rtcAnswerConstraints||null,d=qe.cloneObject(r.rtcOfferConstraints);let g,v=!1,E=!1,S=!1,C=!1;if(this._rtcAnswerConstraints=_,this._rtcOfferConstraints=r.rtcOfferConstraints||null,this._data=r.data||this._data,this._direction!=="incoming")throw new Bs.NotSupportedError('"answer" not supported for outgoing RTCSession');if(this._status!==J.STATUS_WAITING_FOR_ANSWER)throw new Bs.InvalidStateError(this._status);if(this._sessionTimers.enabled&&qe.isDecimal(r.sessionTimersExpires)&&(r.sessionTimersExpires>=ue.MIN_SESSION_EXPIRES?this._sessionTimers.defaultExpires=r.sessionTimersExpires:this._sessionTimers.defaultExpires=ue.SESSION_EXPIRES),this._status=J.STATUS_ANSWERED,!this._createDialog(n,"UAS")){n.reply(500,"Error creating dialog");return}clearTimeout(this._timers.userNoAnswerTimer),o.unshift(`Contact: ${this._contact}`);const I=n.parseSDP();Array.isArray(I.media)||(I.media=[I.media]);for(const w of I.media)w.type==="audio"&&(v=!0,(!w.direction||w.direction==="sendrecv")&&(S=!0)),w.type==="video"&&(E=!0,(!w.direction||w.direction==="sendrecv")&&(C=!0));if(t&&a.audio===!1){g=t.getAudioTracks();for(const w of g)t.removeTrack(w)}if(t&&a.video===!1){g=t.getVideoTracks();for(const w of g)t.removeTrack(w)}!t&&a.audio===void 0&&(a.audio=S),!t&&a.video===void 0&&(a.video=C),!t&&!v&&!d.offerToReceiveAudio&&(a.audio=!1),!t&&!E&&!d.offerToReceiveVideo&&(a.video=!1),this._createRTCConnection(s,p),Promise.resolve().then(()=>{if(t)return t;if(a.audio||a.video)return this._localMediaStreamLocallyGenerated=!0,navigator.mediaDevices.getUserMedia(a).catch(w=>{throw this._status===J.STATUS_TERMINATED?new Error("terminated"):(n.reply(480),this._failed("local",null,ue.causes.USER_DENIED_MEDIA_ACCESS),K.warn('emit "getusermediafailed" [error:%o]',w),this.emit("getusermediafailed",w),new Error("getUserMedia() failed"))})}).then(w=>{if(this._status===J.STATUS_TERMINATED)throw new Error("terminated");this._localMediaStream=w,w&&w.getTracks().forEach(F=>{this._connection.addTrack(F,w)})}).then(()=>{if(this._late_sdp)return;const w={originator:"remote",type:"offer",sdp:n.body};K.debug('emit "sdp"'),this.emit("sdp",w);const F=new RTCSessionDescription({type:"offer",sdp:w.sdp});return this._connectionPromiseQueue=this._connectionPromiseQueue.then(()=>this._connection.setRemoteDescription(F)).catch(L=>{throw n.reply(488),this._failed("system",null,ue.causes.WEBRTC_ERROR),K.warn('emit "peerconnection:setremotedescriptionfailed" [error:%o]',L),this.emit("peerconnection:setremotedescriptionfailed",L),new Error("peerconnection.setRemoteDescription() failed")}),this._connectionPromiseQueue}).then(()=>{if(this._status===J.STATUS_TERMINATED)throw new Error("terminated");return this._connecting(n),this._late_sdp?this._createLocalDescription("offer",this._rtcOfferConstraints).catch(()=>{throw n.reply(500),new Error("_createLocalDescription() failed")}):this._createLocalDescription("answer",_).catch(()=>{throw n.reply(500),new Error("_createLocalDescription() failed")})}).then(w=>{if(this._status===J.STATUS_TERMINATED)throw new Error("terminated");this._handleSessionTimersInIncomingRequest(n,o),n.reply(200,null,o,w,()=>{this._status=J.STATUS_WAITING_FOR_ACK,this._setInvite2xxTimer(n,w),this._setACKTimer(),this._accepted("local")},()=>{this._failed("system",null,ue.causes.CONNECTION_ERROR)})}).catch(w=>{this._status!==J.STATUS_TERMINATED&&K.warn(w)})}terminate(r={}){K.debug("terminate()");const n=r.cause||ue.causes.BYE,o=qe.cloneArray(r.extraHeaders),a=r.body;let t,s=r.status_code,p=r.reason_phrase;if(this._status===J.STATUS_TERMINATED)throw new Bs.InvalidStateError(this._status);switch(this._status){case J.STATUS_NULL:case J.STATUS_INVITE_SENT:case J.STATUS_1XX_RECEIVED:if(K.debug("canceling session"),s&&(s<200||s>=700))throw new TypeError(`Invalid status_code: ${s}`);s&&(p=p||ue.REASON_PHRASE[s]||"",t=`SIP ;cause=${s} ;text="${p}"`),this._status===J.STATUS_NULL||this._status===J.STATUS_INVITE_SENT?(this._is_canceled=!0,this._cancel_reason=t):this._status===J.STATUS_1XX_RECEIVED&&this._request.cancel(t),this._status=J.STATUS_CANCELED,this._failed("local",null,ue.causes.CANCELED);break;case J.STATUS_WAITING_FOR_ANSWER:case J.STATUS_ANSWERED:if(K.debug("rejecting session"),s=s||480,s<300||s>=700)throw new TypeError(`Invalid status_code: ${s}`);this._request.reply(s,p,o,a),this._failed("local",null,ue.causes.REJECTED);break;case J.STATUS_WAITING_FOR_ACK:case J.STATUS_CONFIRMED:if(K.debug("terminating session"),p=r.reason_phrase||ue.REASON_PHRASE[s]||"",s&&(s<200||s>=700))throw new TypeError(`Invalid status_code: ${s}`);if(s&&o.push(`Reason: SIP ;cause=${s}; text="${p}"`),this._status===J.STATUS_WAITING_FOR_ACK&&this._direction==="incoming"&&this._request.server_transaction.state!==gf.C.STATUS_TERMINATED){const _=this._dialog;this.receiveRequest=({method:d})=>{d===ue.ACK&&(this.sendRequest(ue.BYE,{extraHeaders:o,body:a}),_.terminate())},this._request.server_transaction.on("stateChanged",()=>{this._request.server_transaction.state===gf.C.STATUS_TERMINATED&&(this.sendRequest(ue.BYE,{extraHeaders:o,body:a}),_.terminate())}),this._ended("local",null,n),this._dialog=_,this._ua.newDialog(_)}else this.sendRequest(ue.BYE,{extraHeaders:o,body:a}),this._ended("local",null,n)}}sendDTMF(r,n={}){K.debug("sendDTMF() | tones: %s",r);let o=0,a=n.duration||null,t=n.interToneGap||null;const s=n.transportType||ue.DTMF_TRANSPORT.INFO;if(r===void 0)throw new TypeError("Not enough arguments");if(this._status!==J.STATUS_CONFIRMED&&this._status!==J.STATUS_WAITING_FOR_ACK&&this._status!==J.STATUS_1XX_RECEIVED)throw new Bs.InvalidStateError(this._status);if(s!==ue.DTMF_TRANSPORT.INFO&&s!==ue.DTMF_TRANSPORT.RFC2833)throw new TypeError(`invalid transportType: ${s}`);if(typeof r=="number"&&(r=r.toString()),!r||typeof r!="string"||!r.match(/^[0-9A-DR#*,]+$/i))throw new TypeError(`Invalid tones: ${r}`);if(a&&!qe.isDecimal(a))throw new TypeError(`Invalid tone duration: ${a}`);if(a?a<bt.C.MIN_DURATION?(K.debug(`"duration" value is lower than the minimum allowed, setting it to ${bt.C.MIN_DURATION} milliseconds`),a=bt.C.MIN_DURATION):a>bt.C.MAX_DURATION?(K.debug(`"duration" value is greater than the maximum allowed, setting it to ${bt.C.MAX_DURATION} milliseconds`),a=bt.C.MAX_DURATION):a=Math.abs(a):a=bt.C.DEFAULT_DURATION,n.duration=a,t&&!qe.isDecimal(t))throw new TypeError(`Invalid interToneGap: ${t}`);if(t?t<bt.C.MIN_INTER_TONE_GAP?(K.debug(`"interToneGap" value is lower than the minimum allowed, setting it to ${bt.C.MIN_INTER_TONE_GAP} milliseconds`),t=bt.C.MIN_INTER_TONE_GAP):t=Math.abs(t):t=bt.C.DEFAULT_INTER_TONE_GAP,s===ue.DTMF_TRANSPORT.RFC2833){const _=this._getDTMFRTPSender();_&&(r=_.toneBuffer+r,_.insertDTMF(r,a,t));return}if(this._tones){this._tones+=r;return}this._tones=r,p.call(this);function p(){let _;if(this._status===J.STATUS_TERMINATED||!this._tones||o>=this._tones.length){this._tones=null;return}const d=this._tones[o];if(o+=1,d===",")_=2e3;else{const g=new bt(this);n.eventHandlers={onFailed:()=>{this._tones=null}},g.send(d,n),_=a+t}setTimeout(p.bind(this),_)}}sendInfo(r,n,o={}){if(K.debug("sendInfo()"),this._status!==J.STATUS_CONFIRMED&&this._status!==J.STATUS_WAITING_FOR_ACK&&this._status!==J.STATUS_1XX_RECEIVED)throw new Bs.InvalidStateError(this._status);new vf(this).send(r,n,o)}mute(r={audio:!0,video:!1}){K.debug("mute()");let n=!1,o=!1;this._audioMuted===!1&&r.audio&&(n=!0,this._audioMuted=!0,this._toggleMuteAudio(!0)),this._videoMuted===!1&&r.video&&(o=!0,this._videoMuted=!0,this._toggleMuteVideo(!0)),(n===!0||o===!0)&&this._onmute({audio:n,video:o})}unmute(r={audio:!0,video:!0}){K.debug("unmute()");let n=!1,o=!1;this._audioMuted===!0&&r.audio&&(n=!0,this._audioMuted=!1,this._localHold===!1&&this._toggleMuteAudio(!1)),this._videoMuted===!0&&r.video&&(o=!0,this._videoMuted=!1,this._localHold===!1&&this._toggleMuteVideo(!1)),(n===!0||o===!0)&&this._onunmute({audio:n,video:o})}hold(r={},n){if(K.debug("hold()"),this._status!==J.STATUS_WAITING_FOR_ACK&&this._status!==J.STATUS_CONFIRMED||this._localHold===!0||!this._isReadyToReOffer())return!1;this._localHold=!0,this._onhold("local");const o={succeeded:()=>{n&&n()},failed:()=>{this.terminate({cause:ue.causes.WEBRTC_ERROR,status_code:500,reason_phrase:"Hold Failed"})}};return r.useUpdate?this._sendUpdate({sdpOffer:!0,eventHandlers:o,extraHeaders:r.extraHeaders}):this._sendReinvite({eventHandlers:o,extraHeaders:r.extraHeaders}),!0}unhold(r={},n){if(K.debug("unhold()"),this._status!==J.STATUS_WAITING_FOR_ACK&&this._status!==J.STATUS_CONFIRMED||this._localHold===!1||!this._isReadyToReOffer())return!1;this._localHold=!1,this._onunhold("local");const o={succeeded:()=>{n&&n()},failed:()=>{this.terminate({cause:ue.causes.WEBRTC_ERROR,status_code:500,reason_phrase:"Unhold Failed"})}};return r.useUpdate?this._sendUpdate({sdpOffer:!0,eventHandlers:o,extraHeaders:r.extraHeaders}):this._sendReinvite({eventHandlers:o,extraHeaders:r.extraHeaders}),!0}renegotiate(r={},n){K.debug("renegotiate()");const o=r.rtcOfferConstraints||null;if(this._status!==J.STATUS_WAITING_FOR_ACK&&this._status!==J.STATUS_CONFIRMED||!this._isReadyToReOffer())return!1;const a={succeeded:()=>{n&&n()},failed:()=>{this.terminate({cause:ue.causes.WEBRTC_ERROR,status_code:500,reason_phrase:"Media Renegotiation Failed"})}};return this._setLocalMediaStatus(),r.useUpdate?this._sendUpdate({sdpOffer:!0,eventHandlers:a,rtcOfferConstraints:o,extraHeaders:r.extraHeaders}):this._sendReinvite({eventHandlers:a,rtcOfferConstraints:o,extraHeaders:r.extraHeaders}),!0}refer(r,n){K.debug("refer()");const o=r;if(this._status!==J.STATUS_WAITING_FOR_ACK&&this._status!==J.STATUS_CONFIRMED)return!1;if(r=this._ua.normalizeTarget(r),!r)throw new TypeError(`Invalid target: ${o}`);const a=new xm(this);a.sendRefer(r,n);const t=a.id;return this._referSubscribers[t]=a,a.on("requestFailed",()=>{delete this._referSubscribers[t]}),a.on("accepted",()=>{delete this._referSubscribers[t]}),a.on("failed",()=>{delete this._referSubscribers[t]}),a}sendRequest(r,n){return K.debug("sendRequest()"),this._dialog.sendRequest(r,n)}receiveRequest(r){if(K.debug("receiveRequest()"),r.method===ue.CANCEL)(this._status===J.STATUS_WAITING_FOR_ANSWER||this._status===J.STATUS_ANSWERED)&&(this._status=J.STATUS_CANCELED,this._request.reply(487),this._failed("remote",r,ue.causes.CANCELED));else switch(r.method){case ue.ACK:if(this._status!==J.STATUS_WAITING_FOR_ACK)return;if(this._status=J.STATUS_CONFIRMED,clearTimeout(this._timers.ackTimer),clearTimeout(this._timers.invite2xxTimer),this._late_sdp){if(!r.body){this.terminate({cause:ue.causes.MISSING_SDP,status_code:400});break}const n={originator:"remote",type:"answer",sdp:r.body};K.debug('emit "sdp"'),this.emit("sdp",n);const o=new RTCSessionDescription({type:"answer",sdp:n.sdp});this._connectionPromiseQueue=this._connectionPromiseQueue.then(()=>this._connection.setRemoteDescription(o)).then(()=>{this._is_confirmed||this._confirmed("remote",r)}).catch(a=>{this.terminate({cause:ue.causes.BAD_MEDIA_DESCRIPTION,status_code:488}),K.warn('emit "peerconnection:setremotedescriptionfailed" [error:%o]',a),this.emit("peerconnection:setremotedescriptionfailed",a)})}else this._is_confirmed||this._confirmed("remote",r);break;case ue.BYE:this._status===J.STATUS_CONFIRMED||this._status===J.STATUS_WAITING_FOR_ACK?(r.reply(200),this._ended("remote",r,ue.causes.BYE)):this._status===J.STATUS_INVITE_RECEIVED||this._status===J.STATUS_WAITING_FOR_ANSWER?(r.reply(200),this._request.reply(487,"BYE Received"),this._ended("remote",r,ue.causes.BYE)):r.reply(403,"Wrong Status");break;case ue.INVITE:this._status===J.STATUS_CONFIRMED?r.hasHeader("replaces")?this._receiveReplaces(r):this._receiveReinvite(r):r.reply(403,"Wrong Status");break;case ue.INFO:if(this._status===J.STATUS_1XX_RECEIVED||this._status===J.STATUS_WAITING_FOR_ANSWER||this._status===J.STATUS_ANSWERED||this._status===J.STATUS_WAITING_FOR_ACK||this._status===J.STATUS_CONFIRMED){const n=r.hasHeader("Content-Type")?r.getHeader("Content-Type").toLowerCase():void 0;n&&n.match(/^application\/dtmf-relay/i)?new bt(this).init_incoming(r):n!==void 0?new vf(this).init_incoming(r):r.reply(415)}else r.reply(403,"Wrong Status");break;case ue.UPDATE:this._status===J.STATUS_CONFIRMED?this._receiveUpdate(r):r.reply(403,"Wrong Status");break;case ue.REFER:this._status===J.STATUS_CONFIRMED?this._receiveRefer(r):r.reply(403,"Wrong Status");break;case ue.NOTIFY:this._status===J.STATUS_CONFIRMED?this._receiveNotify(r):r.reply(403,"Wrong Status");break;default:r.reply(501)}}onTransportError(){K.warn("onTransportError()"),this._status!==J.STATUS_TERMINATED&&this.terminate({status_code:500,reason_phrase:ue.causes.CONNECTION_ERROR,cause:ue.causes.CONNECTION_ERROR})}onRequestTimeout(){K.warn("onRequestTimeout()"),this._status!==J.STATUS_TERMINATED&&this.terminate({status_code:408,reason_phrase:ue.causes.REQUEST_TIMEOUT,cause:ue.causes.REQUEST_TIMEOUT})}onDialogError(){K.warn("onDialogError()"),this._status!==J.STATUS_TERMINATED&&this.terminate({status_code:500,reason_phrase:ue.causes.DIALOG_ERROR,cause:ue.causes.DIALOG_ERROR})}newDTMF(r){K.debug("newDTMF()"),this.emit("newDTMF",r)}newInfo(r){K.debug("newInfo()"),this.emit("newInfo",r)}_isReadyToReOffer(){return this._rtcReady?this._dialog?this._dialog.uac_pending_reply===!0||this._dialog.uas_pending_reply===!0?(K.debug("_isReadyToReOffer() | there is another INVITE/UPDATE transaction in progress"),!1):!0:(K.debug("_isReadyToReOffer() | session not established yet"),!1):(K.debug("_isReadyToReOffer() | internal WebRTC status not ready"),!1)}_close(){if(K.debug("close()"),this._localMediaStream&&this._localMediaStreamLocallyGenerated&&(K.debug("close() | closing local MediaStream"),qe.closeMediaStream(this._localMediaStream)),this._status!==J.STATUS_TERMINATED){if(this._status=J.STATUS_TERMINATED,this._connection)try{this._connection.close()}catch(r){K.warn("close() | error closing the RTCPeerConnection: %o",r)}for(const r in this._timers)Object.prototype.hasOwnProperty.call(this._timers,r)&&clearTimeout(this._timers[r]);clearTimeout(this._sessionTimers.timer),this._dialog&&(this._dialog.terminate(),delete this._dialog);for(const r in this._earlyDialogs)Object.prototype.hasOwnProperty.call(this._earlyDialogs,r)&&(this._earlyDialogs[r].terminate(),delete this._earlyDialogs[r]);for(const r in this._referSubscribers)Object.prototype.hasOwnProperty.call(this._referSubscribers,r)&&delete this._referSubscribers[r];this._ua.destroyRTCSession(this)}}_setInvite2xxTimer(r,n){let o=kr.T1;function a(){this._status===J.STATUS_WAITING_FOR_ACK&&(r.reply(200,null,[`Contact: ${this._contact}`],n),o<kr.T2&&(o=o*2,o>kr.T2&&(o=kr.T2)),this._timers.invite2xxTimer=setTimeout(a.bind(this),o))}this._timers.invite2xxTimer=setTimeout(a.bind(this),o)}_setACKTimer(){this._timers.ackTimer=setTimeout(()=>{this._status===J.STATUS_WAITING_FOR_ACK&&(K.debug("no ACK received, terminating the session"),clearTimeout(this._timers.invite2xxTimer),this.sendRequest(ue.BYE),this._ended("remote",null,ue.causes.NO_ACK))},kr.TIMER_H)}_createRTCConnection(r,n){this._connection=new RTCPeerConnection(r,n),this._connection.addEventListener("iceconnectionstatechange",()=>{this._connection.iceConnectionState==="failed"&&this.terminate({cause:ue.causes.RTP_TIMEOUT,status_code:408,reason_phrase:ue.causes.RTP_TIMEOUT})}),K.debug('emit "peerconnection"'),this.emit("peerconnection",{peerconnection:this._connection})}_createLocalDescription(r,n){if(K.debug("createLocalDescription()"),r!=="offer"&&r!=="answer")throw new Error(`createLocalDescription() | invalid type "${r}"`);const o=this._connection;return this._rtcReady=!1,Promise.resolve().then(()=>r==="offer"?o.createOffer(n).catch(a=>(K.warn('emit "peerconnection:createofferfailed" [error:%o]',a),this.emit("peerconnection:createofferfailed",a),Promise.reject(a))):o.createAnswer(n).catch(a=>(K.warn('emit "peerconnection:createanswerfailed" [error:%o]',a),this.emit("peerconnection:createanswerfailed",a),Promise.reject(a)))).then(a=>o.setLocalDescription(a).catch(t=>(this._rtcReady=!0,K.warn('emit "peerconnection:setlocaldescriptionfailed" [error:%o]',t),this.emit("peerconnection:setlocaldescriptionfailed",t),Promise.reject(t)))).then(()=>{const a=n&&n.iceRestart;if(o.iceGatheringState==="complete"&&!a||o.iceGatheringState==="gathering"&&this._iceReady){this._rtcReady=!0;const t={originator:"local",type:r,sdp:o.localDescription.sdp};return K.debug('emit "sdp"'),this.emit("sdp",t),Promise.resolve(t.sdp)}return new Promise(t=>{let s=!1,p,_;this._iceReady=!1;const d=()=>{o.removeEventListener("icecandidate",p),o.removeEventListener("icegatheringstatechange",_),s=!0,this._rtcReady=!0,this._iceReady=!0;const g={originator:"local",type:r,sdp:o.localDescription.sdp};K.debug('emit "sdp"'),this.emit("sdp",g),t(g.sdp)};o.addEventListener("icecandidate",p=g=>{const v=g.candidate;v?this.emit("icecandidate",{candidate:v,ready:d}):s||d()}),o.addEventListener("icegatheringstatechange",_=()=>{o.iceGatheringState==="complete"&&!s&&d()})})})}_createDialog(r,n,o){const a=n==="UAS"?r.to_tag:r.from_tag,t=n==="UAS"?r.from_tag:r.to_tag,s=r.call_id+a+t;let p=this._earlyDialogs[s];if(o)return p?!0:(p=new Gl(this,r,n,Gl.C.STATUS_EARLY),p.error?(K.debug(p.error),this._failed("remote",r,ue.causes.INTERNAL_ERROR),!1):(this._earlyDialogs[s]=p,!0));{if(this._from_tag=r.from_tag,this._to_tag=r.to_tag,p)return p.update(r,n),this._dialog=p,delete this._earlyDialogs[s],!0;const _=new Gl(this,r,n);return _.error?(K.debug(_.error),this._failed("remote",r,ue.causes.INTERNAL_ERROR),!1):(this._dialog=_,!0)}}_receiveReinvite(r){K.debug("receiveReinvite()");const n=r.hasHeader("Content-Type")?r.getHeader("Content-Type").toLowerCase():void 0,o={request:r,callback:void 0,reject:t.bind(this)};let a=!1;function t(p={}){a=!0;const _=p.status_code||403,d=p.reason_phrase||"",g=qe.cloneArray(p.extraHeaders);if(this._status!==J.STATUS_CONFIRMED)return!1;if(_<300||_>=700)throw new TypeError(`Invalid status_code: ${_}`);r.reply(_,d,g)}if(this.emit("reinvite",o),a)return;if(this._late_sdp=!1,!r.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=>{s.call(this,p)}).catch(()=>{r.reply(500)});return}if(n!=="application/sdp"){K.debug("invalid Content-Type"),r.reply(415);return}this._processInDialogSdpOffer(r).then(p=>{this._status!==J.STATUS_TERMINATED&&s.call(this,p)}).catch(p=>{K.warn(p)});function s(p){const _=[`Contact: ${this._contact}`];this._handleSessionTimersInIncomingRequest(r,_),this._late_sdp&&(p=this._mangleOffer(p)),r.reply(200,null,_,p,()=>{this._status=J.STATUS_WAITING_FOR_ACK,this._setInvite2xxTimer(r,p),this._setACKTimer()}),typeof o.callback=="function"&&o.callback()}}_receiveUpdate(r){K.debug("receiveUpdate()");const n=r.hasHeader("Content-Type")?r.getHeader("Content-Type").toLowerCase():void 0,o={request:r,callback:void 0,reject:t.bind(this)};let a=!1;function t(p={}){a=!0;const _=p.status_code||403,d=p.reason_phrase||"",g=qe.cloneArray(p.extraHeaders);if(this._status!==J.STATUS_CONFIRMED)return!1;if(_<300||_>=700)throw new TypeError(`Invalid status_code: ${_}`);r.reply(_,d,g)}if(this.emit("update",o),a)return;if(!r.body){s.call(this,null);return}if(n!=="application/sdp"){K.debug("invalid Content-Type"),r.reply(415);return}this._processInDialogSdpOffer(r).then(p=>{this._status!==J.STATUS_TERMINATED&&s.call(this,p)}).catch(p=>{K.warn(p)});function s(p){const _=[`Contact: ${this._contact}`];this._handleSessionTimersInIncomingRequest(r,_),r.reply(200,null,_,p),typeof o.callback=="function"&&o.callback()}}_processInDialogSdpOffer(r){K.debug("_processInDialogSdpOffer()");const n=r.parseSDP();let o=!1;for(const s of n.media){if(Kl.indexOf(s.type)===-1)continue;const p=s.direction||n.direction||"sendrecv";if(p==="sendonly"||p==="inactive")o=!0;else{o=!1;break}}const a={originator:"remote",type:"offer",sdp:r.body};K.debug('emit "sdp"'),this.emit("sdp",a);const t=new RTCSessionDescription({type:"offer",sdp:a.sdp});return this._connectionPromiseQueue=this._connectionPromiseQueue.then(()=>{if(this._status===J.STATUS_TERMINATED)throw new Error("terminated");return this._connection.setRemoteDescription(t).catch(s=>{throw r.reply(488),K.warn('emit "peerconnection:setremotedescriptionfailed" [error:%o]',s),this.emit("peerconnection:setremotedescriptionfailed",s),s})}).then(()=>{if(this._status===J.STATUS_TERMINATED)throw new Error("terminated");this._remoteHold===!0&&o===!1?(this._remoteHold=!1,this._onunhold("remote")):this._remoteHold===!1&&o===!0&&(this._remoteHold=!0,this._onhold("remote"))}).then(()=>{if(this._status===J.STATUS_TERMINATED)throw new Error("terminated");return this._createLocalDescription("answer",this._rtcAnswerConstraints).catch(s=>{throw r.reply(500),K.warn('emit "peerconnection:createtelocaldescriptionfailed" [error:%o]',s),s})}).catch(s=>{K.warn("_processInDialogSdpOffer() failed [error: %o]",s)}),this._connectionPromiseQueue}_receiveRefer(r){if(K.debug("receiveRefer()"),!r.refer_to){K.debug("no Refer-To header field present in REFER"),r.reply(400);return}if(r.refer_to.uri.scheme!==ue.SIP){K.debug("Refer-To header field points to a non-SIP URI scheme"),r.reply(416);return}r.reply(202);const n=new Mm(this,r.cseq);K.debug('emit "refer"'),this.emit("refer",{request:r,accept:(t,s)=>{o.call(this,t,s)},reject:()=>{a.call(this)}});function o(t,s={}){if(t=typeof t=="function"?t:null,this._status!==J.STATUS_WAITING_FOR_ACK&&this._status!==J.STATUS_CONFIRMED)return!1;const p=new gu(this._ua);if(p.on("progress",({response:_})=>{n.notify(_.status_code,_.reason_phrase)}),p.on("accepted",({response:_})=>{n.notify(_.status_code,_.reason_phrase)}),p.on("_failed",({message:_,cause:d})=>{_?n.notify(_.status_code,_.reason_phrase):n.notify(487,d)}),r.refer_to.uri.hasHeader("replaces")){const _=decodeURIComponent(r.refer_to.uri.getHeader("replaces"));s.extraHeaders=qe.cloneArray(s.extraHeaders),s.extraHeaders.push(`Replaces: ${_}`)}p.connect(r.refer_to.uri.toAor(),s,t)}function a(){n.notify(603)}}_receiveNotify(r){switch(K.debug("receiveNotify()"),r.event||r.reply(400),r.event.event){case"refer":{let n,o;if(r.event.params&&r.event.params.id)n=r.event.params.id,o=this._referSubscribers[n];else if(Object.keys(this._referSubscribers).length===1)o=this._referSubscribers[Object.keys(this._referSubscribers)[0]];else{r.reply(400,"Missing event id parameter");return}if(!o){r.reply(481,"Subscription does not exist");return}o.receiveNotify(r),r.reply(200);break}default:r.reply(489)}}_receiveReplaces(r){K.debug("receiveReplaces()");function n(a){if(this._status!==J.STATUS_WAITING_FOR_ACK&&this._status!==J.STATUS_CONFIRMED)return!1;const t=new gu(this._ua);t.on("confirmed",()=>{this.terminate()}),t.init_incoming(r,a)}function o(){K.debug("Replaced INVITE rejected by the user"),r.reply(486)}this.emit("replaces",{request:r,accept:a=>{n.call(this,a)},reject:()=>{o.call(this)}})}_sendInitialRequest(r,n,o){const a=new km(this._ua,this._request,{onRequestTimeout:()=>{this.onRequestTimeout()},onTransportError:()=>{this.onTransportError()},onAuthenticated:t=>{this._request=t},onReceiveResponse:t=>{this._receiveInviteResponse(t)}});Promise.resolve().then(()=>{if(o)return o;if(r.audio||r.video)return this._localMediaStreamLocallyGenerated=!0,navigator.mediaDevices.getUserMedia(r).catch(t=>{throw this._status===J.STATUS_TERMINATED?new Error("terminated"):(this._failed("local",null,ue.causes.USER_DENIED_MEDIA_ACCESS),K.warn('emit "getusermediafailed" [error:%o]',t),this.emit("getusermediafailed",t),t)})}).then(t=>{if(this._status===J.STATUS_TERMINATED)throw new Error("terminated");return this._localMediaStream=t,t&&t.getTracks().forEach(s=>{this._connection.addTrack(s,t)}),this._connecting(this._request),this._createLocalDescription("offer",n).catch(s=>{throw this._failed("local",null,ue.causes.WEBRTC_ERROR),s})}).then(t=>{if(this._is_canceled||this._status===J.STATUS_TERMINATED)throw new Error("terminated");this._request.body=t,this._status=J.STATUS_INVITE_SENT,K.debug('emit "sending" [request:%o]',this._request),this.emit("sending",{request:this._request}),a.send()}).catch(t=>{this._status!==J.STATUS_TERMINATED&&K.warn(t)})}_getDTMFRTPSender(){const r=this._connection.getSenders().find(n=>n.track&&n.track.kind==="audio");if(!(r&&r.dtmf)){K.warn("sendDTMF() | no local audio track to send DTMF with");return}return r.dtmf}_receiveInviteResponse(r){if(K.debug("receiveInviteResponse()"),this._dialog&&r.status_code>=200&&r.status_code<=299)if(this._dialog.id.call_id===r.call_id&&this._dialog.id.local_tag===r.from_tag&&this._dialog.id.remote_tag===r.to_tag){this.sendRequest(ue.ACK);return}else{const n=new Gl(this,r,"UAC");if(n.error!==void 0){K.debug(n.error);return}this.sendRequest(ue.ACK),this.sendRequest(ue.BYE);return}if(this._is_canceled){r.status_code>=100&&r.status_code<200?this._request.cancel(this._cancel_reason):r.status_code>=200&&r.status_code<299&&this._acceptAndTerminate(r);return}if(!(this._status!==J.STATUS_INVITE_SENT&&this._status!==J.STATUS_1XX_RECEIVED))switch(!0){case/^100$/.test(r.status_code):this._status=J.STATUS_1XX_RECEIVED;break;case/^1[0-9]{2}$/.test(r.status_code):{if(!r.to_tag){K.debug("1xx response received without to tag");break}if(r.hasHeader("contact")&&!this._createDialog(r,"UAC",!0))break;if(this._status=J.STATUS_1XX_RECEIVED,!r.body){this._progress("remote",r);break}const n={originator:"remote",type:"answer",sdp:r.body};K.debug('emit "sdp"'),this.emit("sdp",n);const o=new RTCSessionDescription({type:"answer",sdp:n.sdp});this._connectionPromiseQueue=this._connectionPromiseQueue.then(()=>this._connection.setRemoteDescription(o)).then(()=>this._progress("remote",r)).catch(a=>{K.warn('emit "peerconnection:setremotedescriptionfailed" [error:%o]',a),this.emit("peerconnection:setremotedescriptionfailed",a)});break}case/^2[0-9]{2}$/.test(r.status_code):{if(this._status=J.STATUS_CONFIRMED,!r.body){this._acceptAndTerminate(r,400,ue.causes.MISSING_SDP),this._failed("remote",r,ue.causes.BAD_MEDIA_DESCRIPTION);break}if(!this._createDialog(r,"UAC"))break;const n={originator:"remote",type:"answer",sdp:r.body};K.debug('emit "sdp"'),this.emit("sdp",n);const o=new RTCSessionDescription({type:"answer",sdp:n.sdp});this._connectionPromiseQueue=this._connectionPromiseQueue.then(()=>{if(this._connection.signalingState==="stable")return this._connection.createOffer(this._rtcOfferConstraints).then(a=>this._connection.setLocalDescription(a)).catch(a=>{this._acceptAndTerminate(r,500,a.toString()),this._failed("local",r,ue.causes.WEBRTC_ERROR)})}).then(()=>{this._connection.setRemoteDescription(o).then(()=>{this._handleSessionTimersInIncomingResponse(r),this._accepted("remote",r),this.sendRequest(ue.ACK),this._confirmed("local",null)}).catch(a=>{this._acceptAndTerminate(r,488,"Not Acceptable Here"),this._failed("remote",r,ue.causes.BAD_MEDIA_DESCRIPTION),K.warn('emit "peerconnection:setremotedescriptionfailed" [error:%o]',a),this.emit("peerconnection:setremotedescriptionfailed",a)})});break}default:{const n=qe.sipErrorCause(r.status_code);this._failed("remote",r,n)}}}_sendReinvite(r={}){K.debug("sendReinvite()");const n=qe.cloneArray(r.extraHeaders),o=qe.cloneObject(r.eventHandlers),a=r.rtcOfferConstraints||this._rtcOfferConstraints||null;let t=!1;n.push(`Contact: ${this._contact}`),n.push("Content-Type: application/sdp"),this._sessionTimers.running&&n.push(`Session-Expires: ${this._sessionTimers.currentExpires};refresher=${this._sessionTimers.refresher?"uac":"uas"}`),this._connectionPromiseQueue=this._connectionPromiseQueue.then(()=>this._createLocalDescription("offer",a)).then(_=>{_=this._mangleOffer(_);const d={originator:"local",type:"offer",sdp:_};K.debug('emit "sdp"'),this.emit("sdp",d),this.sendRequest(ue.INVITE,{extraHeaders:n,body:_,eventHandlers:{onSuccessResponse:g=>{s.call(this,g),t=!0},onErrorResponse:g=>{p.call(this,g)},onTransportError:()=>{this.onTransportError()},onRequestTimeout:()=>{this.onRequestTimeout()},onDialogError:()=>{this.onDialogError()}}})}).catch(()=>{p()});function s(_){if(this._status===J.STATUS_TERMINATED||(this.sendRequest(ue.ACK),t))return;if(this._handleSessionTimersInIncomingResponse(_),_.body){if(!_.hasHeader("Content-Type")||_.getHeader("Content-Type").toLowerCase()!=="application/sdp"){p.call(this);return}}else{p.call(this);return}const d={originator:"remote",type:"answer",sdp:_.body};K.debug('emit "sdp"'),this.emit("sdp",d);const g=new RTCSessionDescription({type:"answer",sdp:d.sdp});this._connectionPromiseQueue=this._connectionPromiseQueue.then(()=>this._connection.setRemoteDescription(g)).then(()=>{o.succeeded&&o.succeeded(_)}).catch(v=>{p.call(this),K.warn('emit "peerconnection:setremotedescriptionfailed" [error:%o]',v),this.emit("peerconnection:setremotedescriptionfailed",v)})}function p(_){o.failed&&o.failed(_)}}_sendUpdate(r={}){K.debug("sendUpdate()");const n=qe.cloneArray(r.extraHeaders),o=qe.cloneObject(r.eventHandlers),a=r.rtcOfferConstraints||this._rtcOfferConstraints||null,t=r.sdpOffer||!1;let s=!1;n.push(`Contact: ${this._contact}`),this._sessionTimers.running&&n.push(`Session-Expires: ${this._sessionTimers.currentExpires};refresher=${this._sessionTimers.refresher?"uac":"uas"}`),t?(n.push("Content-Type: application/sdp"),this._connectionPromiseQueue=this._connectionPromiseQueue.then(()=>this._createLocalDescription("offer",a)).then(d=>{d=this._mangleOffer(d);const g={originator:"local",type:"offer",sdp:d};K.debug('emit "sdp"'),this.emit("sdp",g),this.sendRequest(ue.UPDATE,{extraHeaders:n,body:d,eventHandlers:{onSuccessResponse:v=>{p.call(this,v),s=!0},onErrorResponse:v=>{_.call(this,v)},onTransportError:()=>{this.onTransportError()},onRequestTimeout:()=>{this.onRequestTimeout()},onDialogError:()=>{this.onDialogError()}}})}).catch(()=>{_.call(this)})):this.sendRequest(ue.UPDATE,{extraHeaders:n,eventHandlers:{onSuccessResponse:d=>{p.call(this,d)},onErrorResponse:d=>{_.call(this,d)},onTransportError:()=>{this.onTransportError()},onRequestTimeout:()=>{this.onRequestTimeout()},onDialogError:()=>{this.onDialogError()}}});function p(d){if(this._status!==J.STATUS_TERMINATED&&!s)if(this._handleSessionTimersInIncomingResponse(d),t){if(d.body){if(!d.hasHeader("Content-Type")||d.getHeader("Content-Type").toLowerCase()!=="application/sdp"){_.call(this);return}}else{_.call(this);return}const g={originator:"remote",type:"answer",sdp:d.body};K.debug('emit "sdp"'),this.emit("sdp",g);const v=new RTCSessionDescription({type:"answer",sdp:g.sdp});this._connectionPromiseQueue=this._connectionPromiseQueue.then(()=>this._connection.setRemoteDescription(v)).then(()=>{o.succeeded&&o.succeeded(d)}).catch(E=>{_.call(this),K.warn('emit "peerconnection:setremotedescriptionfailed" [error:%o]',E),this.emit("peerconnection:setremotedescriptionfailed",E)})}else o.succeeded&&o.succeeded(d)}function _(d){o.failed&&o.failed(d)}}_acceptAndTerminate(r,n,o){K.debug("acceptAndTerminate()");const a=[];n&&(o=o||ue.REASON_PHRASE[n]||"",a.push(`Reason: SIP ;cause=${n}; text="${o}"`)),(this._dialog||this._createDialog(r,"UAC"))&&(this.sendRequest(ue.ACK),this.sendRequest(ue.BYE,{extraHeaders:a})),this._status=J.STATUS_TERMINATED}_mangleOffer(r){if(!this._localHold&&!this._remoteHold)return r;if(r=mf.parse(r),this._localHold&&!this._remoteHold){K.debug("mangleOffer() | me on hold, mangling offer");for(const n of r.media)Kl.indexOf(n.type)!==-1&&(n.direction?n.direction==="sendrecv"?n.direction="sendonly":n.direction==="recvonly"&&(n.direction="inactive"):n.direction="sendonly")}else if(this._localHold&&this._remoteHold){K.debug("mangleOffer() | both on hold, mangling offer");for(const n of r.media)Kl.indexOf(n.type)!==-1&&(n.direction="inactive")}else if(this._remoteHold){K.debug("mangleOffer() | remote on hold, mangling offer");for(const n of r.media)Kl.indexOf(n.type)!==-1&&(n.direction?n.direction==="sendrecv"?n.direction="recvonly":n.direction==="recvonly"&&(n.direction="inactive"):n.direction="recvonly")}return mf.write(r)}_setLocalMediaStatus(){let r=!0,n=!0;(this._localHold||this._remoteHold)&&(r=!1,n=!1),this._audioMuted&&(r=!1),this._videoMuted&&(n=!1),this._toggleMuteAudio(!r),this._toggleMuteVideo(!n)}_handleSessionTimersInIncomingRequest(r,n){if(!this._sessionTimers.enabled)return;let o;r.session_expires&&r.session_expires>=ue.MIN_SESSION_EXPIRES?(this._sessionTimers.currentExpires=r.session_expires,o=r.session_expires_refresher||"uas"):(this._sessionTimers.currentExpires=this._sessionTimers.defaultExpires,o="uas"),n.push(`Session-Expires: ${this._sessionTimers.currentExpires};refresher=${o}`),this._sessionTimers.refresher=o==="uas",this._runSessionTimer()}_handleSessionTimersInIncomingResponse(r){if(!this._sessionTimers.enabled)return;let n;r.session_expires&&r.session_expires>=ue.MIN_SESSION_EXPIRES?(this._sessionTimers.currentExpires=r.session_expires,n=r.session_expires_refresher||"uac"):(this._sessionTimers.currentExpires=this._sessionTimers.defaultExpires,n="uac"),this._sessionTimers.refresher=n==="uac",this._runSessionTimer()}_runSessionTimer(){const r=this._sessionTimers.currentExpires;this._sessionTimers.running=!0,clearTimeout(this._sessionTimers.timer),this._sessionTimers.refresher?this._sessionTimers.timer=setTimeout(()=>{this._status!==J.STATUS_TERMINATED&&this._isReadyToReOffer()&&(K.debug("runSessionTimer() | sending session refresh request"),this._sessionTimers.refreshMethod===ue.UPDATE?this._sendUpdate():this._sendReinvite())},r*500):this._sessionTimers.timer=setTimeout(()=>{this._status!==J.STATUS_TERMINATED&&(K.warn("runSessionTimer() | timer expired, terminating the session"),this.terminate({cause:ue.causes.REQUEST_TIMEOUT,status_code:408,reason_phrase:"Session Timer Expired"}))},r*1100)}_toggleMuteAudio(r){const n=this._connection.getSenders().filter(o=>o.track&&o.track.kind==="audio");for(const o of n)o.track.enabled=!r}_toggleMuteVideo(r){const n=this._connection.getSenders().filter(o=>o.track&&o.track.kind==="video");for(const o of n)o.track.enabled=!r}_newRTCSession(r,n){K.debug("newRTCSession()"),this._ua.newRTCSession(this,{originator:r,session:this,request:n})}_connecting(r){K.debug("session connecting"),K.debug('emit "connecting"'),this.emit("connecting",{request:r})}_progress(r,n){K.debug("session progress"),K.debug('emit "progress"'),this.emit("progress",{originator:r,response:n||null})}_accepted(r,n){K.debug("session accepted"),this._start_time=new Date,K.debug('emit "accepted"'),this.emit("accepted",{originator:r,response:n||null})}_confirmed(r,n){K.debug("session confirmed"),this._is_confirmed=!0,K.debug('emit "confirmed"'),this.emit("confirmed",{originator:r,ack:n||null})}_ended(r,n,o){K.debug("session ended"),this._end_time=new Date,this._close(),K.debug('emit "ended"'),this.emit("ended",{originator:r,message:n||null,cause:o})}_failed(r,n,o){K.debug("session failed"),K.debug('emit "_failed"'),this.emit("_failed",{originator:r,message:n||null,cause:o}),this._close(),K.debug('emit "failed"'),this.emit("failed",{originator:r,message:n||null,cause:o})}_onhold(r){K.debug("session onhold"),this._setLocalMediaStatus(),K.debug('emit "hold"'),this.emit("hold",{originator:r})}_onunhold(r){K.debug("session onunhold"),this._setLocalMediaStatus(),K.debug('emit "unhold"'),this.emit("unhold",{originator:r})}_onmute({audio:r,video:n}){K.debug("session onmute"),this._setLocalMediaStatus(),K.debug('emit "muted"'),this.emit("muted",{audio:r,video:n})}_onunmute({audio:r,video:n}){K.debug("session onunmute"),this._setLocalMediaStatus(),K.debug('emit "unmuted"'),this.emit("unmuted",{audio:r,video:n})}};const $m=ot.EventEmitter,Hm=it,Pa=we,Fm=Kt,Mr=ft(),qm=An,Ef=as,jm=is(),Wl=new Hm("Message");var Vm=class extends $m{constructor(r){super(),this._ua=r,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(r,n,o={}){const a=r;if(r===void 0||n===void 0)throw new TypeError("Not enough arguments");if(r=this._ua.normalizeTarget(r),!r)throw new TypeError(`Invalid target: ${a}`);const t=Mr.cloneArray(o.extraHeaders),s=Mr.cloneObject(o.eventHandlers),p=o.contentType||"text/plain",_={};o.fromUserName&&(_.from_uri=new jm("sip",o.fromUserName,this._ua.configuration.uri.host),t.push(`P-Preferred-Identity: ${this._ua.configuration.uri.toString()}`)),o.fromDisplayName&&(_.from_display_name=o.fromDisplayName);for(const g in s)Object.prototype.hasOwnProperty.call(s,g)&&this.on(g,s[g]);t.push(`Content-Type: ${p}`),this._request=new Fm.OutgoingRequest(Pa.MESSAGE,r,this._ua,_,t),n&&(this._request.body=n);const d=new qm(this._ua,this._request,{onRequestTimeout:()=>{this._onRequestTimeout()},onTransportError:()=>{this._onTransportError()},onReceiveResponse:g=>{this._receiveResponse(g)}});this._newMessage("local",this._request),d.send()}init_incoming(r){this._request=r,this._newMessage("remote",r),this._is_replied||(this._is_replied=!0,r.reply(200)),this._close()}accept(r={}){const n=Mr.cloneArray(r.extraHeaders),o=r.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,n,o)}reject(r={}){const n=r.status_code||480,o=r.reason_phrase,a=Mr.cloneArray(r.extraHeaders),t=r.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(n<300||n>=700)throw new TypeError(`Invalid status_code: ${n}`);this._is_replied=!0,this._request.reply(n,o,a,t)}_receiveResponse(r){if(!this._closed)switch(!0){case/^1[0-9]{2}$/.test(r.status_code):break;case/^2[0-9]{2}$/.test(r.status_code):this._succeeded("remote",r);break;default:{const n=Mr.sipErrorCause(r.status_code);this._failed("remote",r,n);break}}}_onRequestTimeout(){this._closed||this._failed("system",null,Pa.causes.REQUEST_TIMEOUT)}_onTransportError(){this._closed||this._failed("system",null,Pa.causes.CONNECTION_ERROR)}_close(){this._closed=!0,this._ua.destroyMessage(this)}_newMessage(r,n){r==="remote"?(this._direction="incoming",this._local_identity=n.to,this._remote_identity=n.from):r==="local"&&(this._direction="outgoing",this._local_identity=n.from,this._remote_identity=n.to),this._ua.newMessage(this,{originator:r,message:this,request:n})}_failed(r,n,o){Wl.debug("MESSAGE failed"),this._close(),Wl.debug('emit "failed"'),this.emit("failed",{originator:r,response:n||null,cause:o})}_succeeded(r,n){Wl.debug("MESSAGE succeeded"),this._close(),Wl.debug('emit "succeeded"'),this.emit("succeeded",{originator:r,response:n})}};const Bm=ot.EventEmitter,Gm=it,ka=we,Km=Kt,xr=ft(),Wm=An,yf=as,Yl=new Gm("Options");var Ym=class extends Bm{constructor(r){super(),this._ua=r,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(r,n,o={}){const a=r;if(r===void 0)throw new TypeError("A target is required for OPTIONS");if(r=this._ua.normalizeTarget(r),!r)throw new TypeError(`Invalid target: ${a}`);const t=xr.cloneArray(o.extraHeaders),s=xr.cloneObject(o.eventHandlers),p=o.contentType||"application/sdp";for(const d in s)Object.prototype.hasOwnProperty.call(s,d)&&this.on(d,s[d]);t.push(`Content-Type: ${p}`),this._request=new Km.OutgoingRequest(ka.OPTIONS,r,this._ua,null,t),n&&(this._request.body=n);const _=new Wm(this._ua,this._request,{onRequestTimeout:()=>{this._onRequestTimeout()},onTransportError:()=>{this._onTransportError()},onReceiveResponse:d=>{this._receiveResponse(d)}});this._newOptions("local",this._request),_.send()}init_incoming(r){this._request=r,this._newOptions("remote",r),this._is_replied||(this._is_replied=!0,r.reply(200)),this._close()}accept(r={}){const n=xr.cloneArray(r.extraHeaders),o=r.body;if(this._direction!=="incoming")throw new yf.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,n,o)}reject(r={}){const n=r.status_code||480,o=r.reason_phrase,a=xr.cloneArray(r.extraHeaders),t=r.body;if(this._direction!=="incoming")throw new yf.NotSupportedError('"reject" not supported for outgoing Options');if(this._is_replied)throw new Error("incoming Options already replied");if(n<300||n>=700)throw new TypeError(`Invalid status_code: ${n}`);this._is_replied=!0,this._request.reply(n,o,a,t)}_receiveResponse(r){if(!this._closed)switch(!0){case/^1[0-9]{2}$/.test(r.status_code):break;case/^2[0-9]{2}$/.test(r.status_code):this._succeeded("remote",r);break;default:{const n=xr.sipErrorCause(r.status_code);this._failed("remote",r,n);break}}}_onRequestTimeout(){this._closed||this._failed("system",null,ka.causes.REQUEST_TIMEOUT)}_onTransportError(){this._closed||this._failed("system",null,ka.causes.CONNECTION_ERROR)}_close(){this._closed=!0,this._ua.destroyMessage(this)}_newOptions(r,n){r==="remote"?(this._direction="incoming",this._local_identity=n.to,this._remote_identity=n.from):r==="local"&&(this._direction="outgoing",this._local_identity=n.from,this._remote_identity=n.to),this._ua.newOptions(this,{originator:r,message:this,request:n})}_failed(r,n,o){Yl.debug("OPTIONS failed"),this._close(),Yl.debug('emit "failed"'),this.emit("failed",{originator:r,response:n||null,cause:o})}_succeeded(r,n){Yl.debug("OPTIONS succeeded"),this._close(),Yl.debug('emit "succeeded"'),this.emit("succeeded",{originator:r,response:n})}},Ma={};const zm=it,xa=ft(),Jm=Gt(),Lr=new zm("Socket");Ma.isSocket=c=>{if(Array.isArray(c))return!1;if(typeof c>"u")return Lr.warn("undefined JsSIP.Socket instance"),!1;try{if(!xa.isString(c.url))throw Lr.warn("missing or invalid JsSIP.Socket url property"),new Error("Missing or invalid JsSIP.Socket url property");if(!xa.isString(c.via_transport))throw Lr.warn("missing or invalid JsSIP.Socket via_transport property"),new Error("Missing or invalid JsSIP.Socket via_transport property");if(Jm.parse(c.sip_uri,"SIP_URI")===-1)throw Lr.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(r=>{if(!xa.isFunction(c[r]))throw Lr.warn(`missing or invalid JsSIP.Socket method: ${r}`),new Error(`Missing or invalid JsSIP.Socket method: ${r}`)})}catch{return!1}return!0};const Xm=it,Qm=Ma,Sf=we,Rt=new Xm("Transport"),Nt={STATUS_CONNECTED:0,STATUS_CONNECTING:1,STATUS_DISCONNECTED:2,SOCKET_STATUS_READY:0,SOCKET_STATUS_ERROR:1,recovery_options:{min_interval:Sf.CONNECTION_RECOVERY_MIN_INTERVAL,max_interval:Sf.CONNECTION_RECOVERY_MAX_INTERVAL}};var Zm=class{constructor(r,n=Nt.recovery_options){Rt.debug("new()"),this.status=Nt.STATUS_DISCONNECTED,this.socket=null,this.sockets=[],this.recovery_options=n,this.recover_attempts=0,this.recovery_timer=null,this.close_requested=!1;try{this.textDecoder=new TextDecoder("utf8")}catch(o){Rt.warn(`cannot use TextDecoder: ${o}`)}if(typeof r>"u")throw new TypeError("Invalid argument. undefined 'sockets' argument");r instanceof Array||(r=[r]),r.forEach(function(o){if(!Qm.isSocket(o.socket))throw new TypeError("Invalid argument. invalid 'JsSIP.Socket' instance");if(o.weight&&!Number(o.weight))throw new TypeError("Invalid argument. 'weight' attribute is not a number");this.sockets.push({socket:o.socket,weight:o.weight||0,status:Nt.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(Rt.debug("connect()"),this.isConnected()){Rt.debug("Transport is already connected");return}else if(this.isConnecting()){Rt.debug("Transport is connecting");return}this.close_requested=!1,this.status=Nt.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(){Rt.debug("close()"),this.close_requested=!0,this.recover_attempts=0,this.status=Nt.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(r){if(Rt.debug("send()"),!this.isConnected())return Rt.warn("unable to send message, transport is not connected"),!1;const n=r.toString();return Rt.debug(`sending message:
116
+
117
+ ${n}
118
+ `),this.socket.send(n)}isConnected(){return this.status===Nt.STATUS_CONNECTED}isConnecting(){return this.status===Nt.STATUS_CONNECTING}_reconnect(){this.recover_attempts+=1;let r=Math.floor(Math.random()*Math.pow(2,this.recover_attempts)+1);r<this.recovery_options.min_interval?r=this.recovery_options.min_interval:r>this.recovery_options.max_interval&&(r=this.recovery_options.max_interval),Rt.debug(`reconnection attempt: ${this.recover_attempts}. next connection attempt in ${r} seconds`),this.recovery_timer=setTimeout(()=>{!this.close_requested&&!(this.isConnected()||this.isConnecting())&&(this._getSocket(),this.connect())},r*1e3)}_getSocket(){let r=[];if(this.sockets.forEach(o=>{o.status!==Nt.SOCKET_STATUS_ERROR&&(r.length===0?r.push(o):o.weight>r[0].weight?r=[o]:o.weight===r[0].weight&&r.push(o))}),r.length===0){this.sockets.forEach(o=>{o.status=Nt.SOCKET_STATUS_READY}),this._getSocket();return}const n=Math.floor(Math.random()*r.length);this.socket=r[n].socket}_onConnect(){this.recover_attempts=0,this.status=Nt.STATUS_CONNECTED,this.recovery_timer!==null&&(clearTimeout(this.recovery_timer),this.recovery_timer=null),this.onconnect({socket:this})}_onDisconnect(r,n,o){this.status=Nt.STATUS_DISCONNECTED,this.ondisconnect({socket:this.socket,error:r,code:n,reason:o}),!this.close_requested&&(this.sockets.forEach(function(a){this.socket===a.socket&&(a.status=Nt.SOCKET_STATUS_ERROR)},this),this._reconnect(r))}_onData(r){if(r===`\r
119
+ `){Rt.debug("received message with CRLF Keep Alive response");return}else if(typeof r!="string"){try{this.textDecoder?r=this.textDecoder.decode(r):r=String.fromCharCode.apply(null,new Uint8Array(r))}catch{Rt.debug("received binary message failed to be converted into string, message discarded");return}Rt.debug(`received binary message:
120
+
121
+ ${r}
122
+ `)}else Rt.debug(`received text message:
123
+
124
+ ${r}
125
+ `);this.ondata({transport:this,message:r})}},Cf={};const eg=it,La=Gt(),$a=Kt,zl=new eg("Parser");Cf.parseMessage=(c,r)=>{let n,o,a=c.indexOf(`\r
126
+ `);if(a===-1){zl.warn("parseMessage() | no CRLF found, not a SIP message");return}const t=c.substring(0,a);let s=La.parse(t,"Request_Response");if(s===-1){zl.warn(`parseMessage() | error parsing first line of SIP message: "${t}"`);return}else s.status_code?(n=new $a.IncomingResponse,n.status_code=s.status_code,n.reason_phrase=s.reason_phrase):(n=new $a.IncomingRequest(r),n.method=s.method,n.ruri=s.uri);n.data=c;let p=a+2;for(;;){if(a=tg(c,p),a===-2){o=p+2;break}else if(a===-1){zl.warn("parseMessage() | malformed message");return}if(s=sg(n,c,p,a),s!==!0){zl.warn("parseMessage() |",s.error);return}p=a+2}if(n.hasHeader("content-length")){const _=n.getHeader("content-length");n.body=c.substr(o,_)}else n.body=c.substring(o);return n};function tg(c,r){let n=r,o=0,a=0;if(c.substring(n,n+2).match(/(^\r\n)/))return-2;for(;o===0;){if(a=c.indexOf(`\r
127
+ `,n),a===-1)return a;!c.substring(a+2,a+4).match(/(^\r\n)/)&&c.charAt(a+2).match(/(^\s+)/)?n=a+2:o=a}return o}function sg(c,r,n,o){let a;const t=r.indexOf(":",n),s=r.substring(n,t).trim(),p=r.substring(t+1,o).trim();switch(s.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=La.parse(p,"Record_Route"),a===-1)a=void 0;else for(const _ of a)c.addHeader("record-route",p.substring(_.possition,_.offset)),c.headers["Record-Route"][c.getHeaders("record-route").length-1].parsed=_.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=La.parse(p,"Contact"),a===-1)a=void 0;else for(const _ of a)c.addHeader("contact",p.substring(_.possition,_.offset)),c.headers.Contact[c.getHeaders("contact").length-1].parsed=_.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 $a.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(s,p),a=0}return a===void 0?{error:`error parsing header "${s}"`}:!0}const ng=it,Af=we,Rf=Kt,Ha=ft(),Fa=new ng("sanityCheck"),rg=[dg],ig=[ag,ug,cg,fg],lg=[_g,hg];let Le,Yt,If;var og=(c,r,n)=>{Le=c,Yt=r,If=n;for(const o of rg)if(o()===!1)return!1;if(Le instanceof Rf.IncomingRequest){for(const o of ig)if(o()===!1)return!1}else if(Le instanceof Rf.IncomingResponse){for(const o of lg)if(o()===!1)return!1}return!0};function ag(){if(Le.s("to").uri.scheme!=="sip")return $r(416),!1}function ug(){if(!Le.to_tag&&Le.call_id.substr(0,5)===Yt.configuration.jssip_id)return $r(482),!1}function cg(){const c=Ha.str_utf8_length(Le.body),r=Le.getHeader("content-length");if(c<r)return $r(400),!1}function fg(){const c=Le.from_tag,r=Le.call_id,n=Le.cseq;let o;if(!Le.to_tag)if(Le.method===Af.INVITE){if(Yt._transactions.ist[Le.via_branch])return!1;for(const a in Yt._transactions.ist)if(Object.prototype.hasOwnProperty.call(Yt._transactions.ist,a)&&(o=Yt._transactions.ist[a],o.request.from_tag===c&&o.request.call_id===r&&o.request.cseq===n))return $r(482),!1}else{if(Yt._transactions.nist[Le.via_branch])return!1;for(const a in Yt._transactions.nist)if(Object.prototype.hasOwnProperty.call(Yt._transactions.nist,a)&&(o=Yt._transactions.nist[a],o.request.from_tag===c&&o.request.call_id===r&&o.request.cseq===n))return $r(482),!1}}function _g(){if(Le.getHeaders("via").length>1)return Fa.debug("more than one Via header field present in the response, dropping the response"),!1}function hg(){const c=Ha.str_utf8_length(Le.body),r=Le.getHeader("content-length");if(c<r)return Fa.debug("message body length is lower than the value in Content-Length header field, dropping the response"),!1}function dg(){const c=["from","to","call_id","cseq","via"];for(const r of c)if(!Le.hasHeader(r))return Fa.debug(`missing mandatory header field : ${r}, dropping the response`),!1}function $r(c){const r=Le.getHeaders("via");let n,o=`SIP/2.0 ${c} ${Af.REASON_PHRASE[c]}\r
128
+ `;for(const a of r)o+=`Via: ${a}\r
129
+ `;n=Le.getHeader("To"),Le.to_tag||(n+=`;tag=${Ha.newTag()}`),o+=`To: ${n}\r
130
+ `,o+=`From: ${Le.getHeader("From")}\r
131
+ `,o+=`Call-ID: ${Le.call_id}\r
132
+ `,o+=`CSeq: ${Le.cseq} ${Le.method}\r
133
+ `,o+=`\r
134
+ `,If.send(o)}var qa={};const Rn=ft(),Gs=we,ja=Gt(),bf=is(),Va=Ma,Ba=as;qa.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:Gs.UPDATE,session_timers_force_refresher:!1,no_answer_timeout:60,register:!0,register_expires:600,registrar_server:null,sockets:null,connection_recovery_max_interval:Gs.CONNECTION_RECOVERY_MAX_INTERVAL,connection_recovery_min_interval:Gs.CONNECTION_RECOVERY_MIN_INTERVAL,extra_headers:null,via_host:`${Rn.createRandomToken(12)}.invalid`};const Jl={mandatory:{sockets(c){const r=[];if(Va.isSocket(c))r.push({socket:c});else if(Array.isArray(c)&&c.length)for(const n of c)Object.prototype.hasOwnProperty.call(n,"socket")&&Va.isSocket(n.socket)?r.push(n):Va.isSocket(n)&&r.push({socket:n});else return;return r},uri(c){/^sip:/i.test(c)||(c=`${Gs.SIP}:${c}`);const r=bf.parse(c);if(r)return r.user?r:void 0}},optional:{authorization_user(c){if(ja.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(Rn.isDecimal(c)){const r=Number(c);if(r>0)return r}},connection_recovery_min_interval(c){if(Rn.isDecimal(c)){const r=Number(c);if(r>0)return r}},contact_uri(c){if(typeof c=="string"){const r=ja.parse(c,"SIP_URI");if(r!==-1)return r}},display_name(c){return c},instance_id(c){if(/^uuid:/i.test(c)&&(c=c.substr(5)),ja.parse(c,"uuid")!==-1)return c},no_answer_timeout(c){if(Rn.isDecimal(c)){const r=Number(c);if(r>0)return r}},session_timers(c){if(typeof c=="boolean")return c},session_timers_refresh_method(c){if(typeof c=="string"&&(c=c.toUpperCase(),c===Gs.INVITE||c===Gs.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(Rn.isDecimal(c)){const r=Number(c);if(r>0)return r}},registrar_server(c){/^sip:/i.test(c)||(c=`${Gs.SIP}:${c}`);const r=bf.parse(c);if(r)return r.user?void 0:r},use_preloaded_route(c){if(typeof c=="boolean")return c},extra_headers(c){const r=[];if(Array.isArray(c)&&c.length)for(const n of c)typeof n=="string"&&r.push(n);else return;return r}}};qa.load=(c,r)=>{for(const n in Jl.mandatory)if(r.hasOwnProperty(n)){const o=r[n],a=Jl.mandatory[n](o);if(a!==void 0)c[n]=a;else throw new Ba.ConfigurationError(n,o)}else throw new Ba.ConfigurationError(n);for(const n in Jl.optional)if(r.hasOwnProperty(n)){const o=r[n];if(Rn.isEmpty(o))continue;const a=Jl.optional[n](o);if(a!==void 0)c[n]=a;else throw new Ba.ConfigurationError(n,o)}};const pg=ot.EventEmitter,mg=it,ht=we,gg=nm,wf=Lm,Of=Vm,Df=Ym,Ga=Cn,vg=Zm,Xl=ft(),Tg=as,Eg=is(),yg=Cf,Ka=Kt,Sg=og,Wa=qa,He=new mg("UA"),dt={STATUS_INIT:0,STATUS_READY:1,STATUS_USER_CLOSED:2,STATUS_NOT_READY:3,CONFIGURATION_ERROR:1,NETWORK_ERROR:2};var Nf=class extends pg{static get C(){return dt}constructor(r){if(He.debug("new() [configuration:%o]",r),super(),this._cache={credentials:{}},this._configuration=Object.assign({},Wa.settings),this._dynConfiguration={},this._dialogs={},this._applicants={},this._sessions={},this._transport=null,this._contact=null,this._status=dt.STATUS_INIT,this._error=null,this._transactions={nist:{},nict:{},ist:{},ict:{}},this._data={},this._closeTimer=null,r===void 0)throw new TypeError("Not enough arguments");try{this._loadConfig(r)}catch(n){throw this._status=dt.STATUS_NOT_READY,this._error=dt.CONFIGURATION_ERROR,n}this._registrator=new gg(this)}get C(){return dt}get status(){return this._status}get contact(){return this._contact}get configuration(){return this._configuration}get transport(){return this._transport}start(){He.debug("start()"),this._status===dt.STATUS_INIT?this._transport.connect():this._status===dt.STATUS_USER_CLOSED?(He.debug("restarting UA"),this._closeTimer!==null&&(clearTimeout(this._closeTimer),this._closeTimer=null,this._transport.disconnect()),this._status=dt.STATUS_INIT,this._transport.connect()):this._status===dt.STATUS_READY?He.debug("UA is in READY status, not restarted"):He.debug("ERROR: connection is down, Auto-Recovery system is trying to reconnect"),this._dynConfiguration.register=this._configuration.register}register(){He.debug("register()"),this._dynConfiguration.register=!0,this._registrator.register()}unregister(r){He.debug("unregister()"),this._dynConfiguration.register=!1,this._registrator.unregister(r)}registrator(){return this._registrator}isRegistered(){return this._registrator.registered}isConnected(){return this._transport.isConnected()}call(r,n){He.debug("call()");const o=new wf(this);return o.connect(r,n),o}sendMessage(r,n,o){He.debug("sendMessage()");const a=new Of(this);return a.send(r,n,o),a}sendOptions(r,n,o){He.debug("sendOptions()");const a=new Df(this);return a.send(r,n,o),a}terminateSessions(r){He.debug("terminateSessions()");for(const n in this._sessions)this._sessions[n].isEnded()||this._sessions[n].terminate(r)}stop(){if(He.debug("stop()"),this._dynConfiguration={},this._status===dt.STATUS_USER_CLOSED){He.debug("UA already closed");return}this._registrator.close();const r=Object.keys(this._sessions).length;for(const o in this._sessions)if(Object.prototype.hasOwnProperty.call(this._sessions,o)){He.debug(`closing session ${o}`);try{this._sessions[o].terminate()}catch{}}for(const o in this._applicants)if(Object.prototype.hasOwnProperty.call(this._applicants,o))try{this._applicants[o].close()}catch{}this._status=dt.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&&r===0?this._transport.disconnect():this._closeTimer=setTimeout(()=>{this._closeTimer=null,this._transport.disconnect()},2e3)}normalizeTarget(r){return Xl.normalizeTarget(r,this._configuration.hostport_params)}get(r){switch(r){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:He.warn('get() | cannot get "%s" parameter in runtime',r);return}}set(r,n){switch(r){case"authorization_user":{this._configuration.authorization_user=String(n);break}case"password":{this._configuration.password=String(n);break}case"realm":{this._configuration.realm=String(n);break}case"ha1":{this._configuration.ha1=String(n),this._configuration.password=null;break}case"authorization_jwt":{this._configuration.authorization_jwt=String(n);break}case"display_name":{this._configuration.display_name=n;break}default:return He.warn('set() | cannot set "%s" parameter in runtime',r),!1}return!0}newTransaction(r){this._transactions[r.type][r.id]=r,this.emit("newTransaction",{transaction:r})}destroyTransaction(r){delete this._transactions[r.type][r.id],this.emit("transactionDestroyed",{transaction:r})}newDialog(r){this._dialogs[r.id]=r}destroyDialog(r){delete this._dialogs[r.id]}newMessage(r,n){this._applicants[r]=r,this.emit("newMessage",n)}newOptions(r,n){this._applicants[r]=r,this.emit("newOptions",n)}destroyMessage(r){delete this._applicants[r]}newRTCSession(r,n){this._sessions[r.id]=r,this.emit("newRTCSession",n)}destroyRTCSession(r){delete this._sessions[r.id]}registered(r){this.emit("registered",r)}unregistered(r){this.emit("unregistered",r)}registrationFailed(r){this.emit("registrationFailed",r)}receiveRequest(r){const n=r.method;if(r.ruri.user!==this._configuration.uri.user&&r.ruri.user!==this._contact.uri.user){He.debug("Request-URI does not point to us"),r.method!==ht.ACK&&r.reply_sl(404);return}if(r.ruri.scheme===ht.SIPS){r.reply_sl(416);return}if(Ga.checkTransaction(this,r))return;if(n===ht.INVITE?new Ga.InviteServerTransaction(this,this._transport,r):n!==ht.ACK&&n!==ht.CANCEL&&new Ga.NonInviteServerTransaction(this,this._transport,r),n===ht.OPTIONS){if(this.listeners("newOptions").length===0){r.reply(200);return}new Df(this).init_incoming(r)}else if(n===ht.MESSAGE){if(this.listeners("newMessage").length===0){r.reply(405);return}new Of(this).init_incoming(r)}else if(n===ht.INVITE&&!r.to_tag&&this.listeners("newRTCSession").length===0){r.reply(405);return}let o,a;if(r.to_tag)o=this._findDialog(r.call_id,r.from_tag,r.to_tag),o?o.receiveRequest(r):n===ht.NOTIFY?(a=this._findSession(r),a?a.receiveRequest(r):(He.debug("received NOTIFY request for a non existent subscription"),r.reply(481,"Subscription does not exist"))):n!==ht.ACK&&r.reply(481);else switch(n){case ht.INVITE:if(window.RTCPeerConnection)if(r.hasHeader("replaces")){const t=r.replaces;o=this._findDialog(t.call_id,t.from_tag,t.to_tag),o?(a=o.owner,a.isEnded()?r.reply(603):a.receiveRequest(r)):r.reply(481)}else a=new wf(this),a.init_incoming(r);else He.warn("INVITE received but WebRTC is not supported"),r.reply(488);break;case ht.BYE:r.reply(481);break;case ht.CANCEL:a=this._findSession(r),a?a.receiveRequest(r):He.debug("received CANCEL request for a non existent session");break;case ht.ACK:break;case ht.NOTIFY:this.emit("sipEvent",{event:r.event,request:r}),r.reply(200);break;default:r.reply(405);break}}_findSession({call_id:r,from_tag:n,to_tag:o}){const a=r+n,t=this._sessions[a],s=r+o,p=this._sessions[s];return t||p||null}_findDialog(r,n,o){let a=r+n+o,t=this._dialogs[a];return t||(a=r+o+n,t=this._dialogs[a],t||null)}_loadConfig(r){try{Wa.load(this._configuration,r)}catch(a){throw a}this._configuration.display_name===0&&(this._configuration.display_name="0"),this._configuration.instance_id||(this._configuration.instance_id=Xl.newUUID()),this._configuration.jssip_id=Xl.createRandomToken(5);const n=this._configuration.uri.clone();n.user=null,this._configuration.hostport_params=n.toString().replace(/^sip:/i,"");try{this._transport=new vg(this._configuration.sockets,{max_interval:this._configuration.connection_recovery_max_interval,min_interval:this._configuration.connection_recovery_min_interval}),this._transport.onconnecting=Cg.bind(this),this._transport.onconnect=Ag.bind(this),this._transport.ondisconnect=Rg.bind(this),this._transport.ondata=Ig.bind(this)}catch(a){throw He.warn(a),new Tg.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 Eg("sip",Xl.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 t=a.anonymous||null,s=a.outbound||null;let p="<";return t?p+=this.temp_gruu||"sip:anonymous@anonymous.invalid;transport=ws":p+=this.pub_gruu||this.uri.toString(),s&&(t?!this.temp_gruu:!this.pub_gruu)&&(p+=";ob"),p+=">",p}};const o=["authorization_user","password","realm","ha1","authorization_jwt","display_name","register"];for(const a in this._configuration)Object.prototype.hasOwnProperty.call(this._configuration,a)&&(o.indexOf(a)!==-1?Object.defineProperty(this._configuration,a,{writable:!0,configurable:!1}):Object.defineProperty(this._configuration,a,{writable:!1,configurable:!1}));He.debug("configuration parameters after validation:");for(const a in this._configuration)if(Object.prototype.hasOwnProperty.call(Wa.settings,a))switch(a){case"uri":case"registrar_server":He.debug(`- ${a}: ${this._configuration[a]}`);break;case"password":case"ha1":case"authorization_jwt":He.debug(`- ${a}: NOT SHOWN`);break;default:He.debug(`- ${a}: ${JSON.stringify(this._configuration[a])}`)}}};function Cg(c){this.emit("connecting",c)}function Ag(c){this._status!==dt.STATUS_USER_CLOSED&&(this._status=dt.STATUS_READY,this._error=null,this.emit("connected",c),this._dynConfiguration.register&&this._registrator.register())}function Rg(c){const r=["nict","ict","nist","ist"];for(const n of r)for(const o in this._transactions[n])Object.prototype.hasOwnProperty.call(this._transactions[n],o)&&this._transactions[n][o].onTransportError();this.emit("disconnected",c),this._registrator.onTransportClosed(),this._status!==dt.STATUS_USER_CLOSED&&(this._status=dt.STATUS_NOT_READY,this._error=dt.NETWORK_ERROR)}function Ig(c){const r=c.transport;let n=c.message;if(n=yg.parseMessage(n,this),!!n&&!(this._status===dt.STATUS_USER_CLOSED&&n instanceof Ka.IncomingRequest)&&Sg(n,this,r)){if(n instanceof Ka.IncomingRequest)n.transport=r,this.receiveRequest(n);else if(n instanceof Ka.IncomingResponse){let o;switch(n.method){case ht.INVITE:o=this._transactions.ict[n.via_branch],o&&o.receiveResponse(n);break;case ht.ACK:break;default:o=this._transactions.nict[n.via_branch],o&&o.receiveResponse(n);break}}}}const bg=qt(Nf);var Ss=ft();class In{constructor(r){if(this.headers={},r.length>0){let n=!1;const o=r.split(`\r
135
+ `),a=o.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 t of o){if(t==`-------${this.ident}$`)break;if(t===""){n=!0;continue}if(t&&n)this.body+=`${t}\r
136
+ `;else{const s=t.split(": ");this.addHeader(s[0],s[1].trim())}}}else this.ident=Ss.createRandomToken(12),this.protocol="MSRP"}addHeader(r,n){this.headers[r]=n}getHeader(r){return this.headers[r]}toString(){let r=`${this.protocol} ${this.ident} ${this.code} ${this.method}`.replaceAll(/null\s|undefined\s/ig,"")+`\r
137
+ `;for(const n in this.headers)r+=`${n}: ${this.headers[n]}\r
138
+ `;return this.body&&(r+=`\r
139
+ ${this.body}\r
140
+ `),r+=`-------${this.ident}$\r
141
+ `,r}}var wg=is();const Ya=qt(wg),ye={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 Uf extends ot.EventEmitter{constructor(r){super(),this._id=null,this.my_ip="127.0.0.1",this._ua=r,this.auth_id=Ss.createRandomToken(10),this._status=ye.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:r._configuration.authorization_user,ha1:r._configuration.ha1,realm:r._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:Ie.SESSION_EXPIRES,currentExpires:null,running:!1,refresher:!1,timer:null},this._msrpKeepAliveTimer=null}static get C(){return ye}get direction(){return this._direction}get connection(){return this._connection}get id(){return this._id}connect(r=""){r!==""&&(this._direction="outgoing"),this.target=r,this._connection=new WebSocket(`ws://${this._ua._configuration.realm}:2856`,"msrp"),this._connection.binaryType="arraybuffer",this._connection.onopen=n=>{console.log("open"),this.onopen()},this._connection.onclose=n=>{console.log("close",n),this.onclose()},this._connection.onmessage=n=>{console.log("msg",n),this.onmessage(n)},this._connection.onerror=n=>{console.log("error"),this.onerror()}}_sendKeepAlive(){const r=new In("");r.method="SEND",r.addHeader("To-Path",`${this.my_addr[1]}`),r.addHeader("From-Path",`${this.my_addr[0]}`),r.addHeader("Message-ID",Ss.createRandomToken(10)),this._connection.send(r.toString())}answer(){if(!this._createDialog(this._request,"UAS")){this._request.reply(500,"Error creating dialog");return}this._status=ye.STATUS_ANSWERED,clearTimeout(this._timers.userNoAnswerTimer),this.connect()}acceptParty(r){this._request.parseSDP(!0),this._request.reply(200,"OK",[],`v=0
142
+ o=- 4232740119537112802 2 IN IP4 ${this.my_ip}
143
+ c=IN IP4 ${this.my_ip}
144
+ t=0 0
145
+ m=message 2856 TCP/TLS/MSRP *
146
+ a=accept-types:text/plain text/html
147
+ a=path: ${r.getHeader("Use-Path")} msrp://${this._ua._configuration.authorization_user}.${this._ua._configuration.realm}:2856/${this.auth_id};ws
148
+ `)}inviteParty(r){const n={},o=[];n.to_uri=new Ya("sip",this.target,this._ua._configuration.realm),n.from_uri=new Ya("sip",this._ua._configuration.uri.user,this._ua._configuration.uri.host),o.push(`Contact: ${this._ua.contact.toString({outbound:!0})}`),o.push("Content-Type: application/sdp"),this._request=new Kt.InitialOutgoingInviteRequest(new Ya("sip",this.target,this._ua._configuration.realm).clone(),this._ua,n,o,`v=0
149
+ o=- 4232740119537112802 2 IN IP4 ${this.my_ip}
150
+ c=IN IP4 ${this.my_ip}
151
+ t=0 0
152
+ m=message 2856 TCP/TLS/MSRP *
153
+ a=accept-types:text/plain text/html
154
+ a=path:${r.getHeader("Use-Path")} msrp://${this._ua._configuration.authorization_user}.${this._ua._configuration.realm}:2856/${this.auth_id};ws
155
+ `),this._newMSRPSession("local",this._request),this._id=this._request.call_id+this._from_tag,console.log("dialog be",this._dialog),new tm(this._ua,this._request,{onRequestTimeout:()=>{this.onRequestTimeout(),console.log("to")},onTransportError:t=>{this.onTransportError(),console.log(t)},onAuthenticated:t=>{this._request=t},onReceiveResponse:t=>{this._receiveInviteResponse(t),console.log("dialog af",this._dialog),t.status_code===200&&(t.parseSDP(!0),this._status=ye.STATUS_CONFIRMED,this.target_addr=t.sdp.media[0].invalid[1].value.replaceAll("path:","").split(" ").reverse(),this.status="active",this.emit("active"),this.emit("confirmed"))}}).send(),this._status=ye.STATUS_INVITE_SENT}terminate(r={}){console.log("terminate",this);const n=r.cause||Ie.causes.BYE,o=Ss.cloneArray(r.extraHeaders),a=r.body;let t,s=r.status_code,p=r.reason_phrase;if(this._status===ye.STATUS_TERMINATED)throw new am.InvalidStateError(this._status);switch(this.status="terminated",this._status){case ye.STATUS_NULL:case ye.STATUS_INVITE_SENT:case ye.STATUS_1XX_RECEIVED:if(s&&(s<200||s>=700))throw new TypeError(`Invalid status_code: ${s}`);s&&(p=p||Ie.REASON_PHRASE[s]||"",t=`SIP ;cause=${s} ;text="${p}"`),this._status===ye.STATUS_NULL||this._status===ye.STATUS_INVITE_SENT?(this._is_canceled=!0,this._cancel_reason=t):this._status===ye.STATUS_1XX_RECEIVED&&this._request.cancel(t),this._status=ye.STATUS_CANCELED,console.log("failed 1"),this._failed("local",null,Ie.causes.CANCELED);break;case ye.STATUS_WAITING_FOR_ANSWER:case ye.STATUS_ANSWERED:if(s=s||480,console.log("REPLY 480"),s<300||s>=700)throw new TypeError(`Invalid status_code: ${s}`);this._request.reply(s,p,o,a),console.log("failed 2"),this._failed("local",null,Ie.causes.REJECTED);break;case ye.STATUS_WAITING_FOR_ACK:case ye.STATUS_CONFIRMED:if(p=r.reason_phrase||Ie.REASON_PHRASE[s]||"",s&&(s<200||s>=700))throw new TypeError(`Invalid status_code: ${s}`);if(s&&o.push(`Reason: SIP ;cause=${s}; text="${p}"`),this._status===ye.STATUS_WAITING_FOR_ACK&&this._direction==="incoming"&&this._request.server_transaction.state!==Dr.C.STATUS_TERMINATED){const _=this._dialog;this.receiveRequest=({method:d})=>{d===Ie.ACK&&(this.sendRequest(Ie.BYE,{extraHeaders:o,body:a}),_.terminate())},this._request.server_transaction.on("stateChanged",()=>{this._request.server_transaction.state===Dr.C.STATUS_TERMINATED&&(this.sendRequest(Ie.BYE,{extraHeaders:o,body:a}),_.terminate())}),this._ended("local",null,n),this._dialog=_,this._ua.newDialog(_)}else console.log("here it is"),this.sendRequest(Ie.BYE,{extraHeaders:o,body:a}),this._ended("local",null,n)}}sendRequest(r,n){return this._dialog.sendRequest(r,n)}authenticate(r){this.status="auth";let n=new In("");n.method="AUTH",n.addHeader("To-Path",`msrp://${this._ua._configuration.realm}:2856;ws`),n.addHeader("From-Path",`msrp://${this.credentials.username}.${this.credentials.realm}:2856/${this.auth_id};ws`),r&&n.addHeader("Authorization",r.toString());let o=n.toString();console.log(o);let a=[];for(var t=0;t<o.length;t++)a.push(o.charCodeAt(t).toString(16));console.log(a),this._connection.send(n.toString())}onmessage(r){console.log("onmessage",r);const n=new In(r.data);if(this.status==="auth"&&n.code===401){const o=this.parseAuth(n.getHeader("WWW-Authenticate")),a=new Vp(this.credentials);a.authenticate({method:"AUTH",ruri:`msrp://${this._ua._configuration.realm}:2856;ws`,body:null},o,Ss.createRandomToken(12)),this.authenticate(a)}this.status==="auth"&&n.code===200&&this._direction==="outgoing"?(this.my_addr.push(n.getHeader("To-Path")),this.my_addr.push(n.getHeader("Use-Path")),this.status="active",this.inviteParty(n)):this.status==="auth"&&n.code===200&&this._direction==="incoming"?(this.my_addr.push(n.getHeader("To-Path")),this.my_addr.push(n.getHeader("Use-Path")),this.status="active",this.acceptParty(n),this.emit("confirmed")):n.method==="SEND"&&(this._sendOk(n),this._sendReport(n),n.direction="incoming",this.emit("newMessage",n),this._msgHistory.push(n),this.emit("msgHistoryUpdate",this._msgHistory),console.log("======================================================================")),n.code===480&&this._close()}onclose(){console.log("close")}onopen(){const r=new RTCPeerConnection({iceServers:[]});r.createDataChannel(""),r.createOffer().then(r.setLocalDescription.bind(r)),r.onicecandidate=n=>{if(!n||!n.candidate||!n.candidate.candidate)return;const o=/([0-9]{1,3}(\.[0-9]{1,3}){3})/,a=n.candidate.candidate.match(o);this.my_ip=a&&a[1],r.onicecandidate=()=>{},this.authenticate(null)}}onerror(r){console.log(r)}_receiveInviteResponse(r){if(console.log("resp0000000000000",r),this._dialog&&r.status_code>=200&&r.status_code<=299)if(console.log("200000000000000"),this._dialog.id.call_id===r.call_id&&this._dialog.id.local_tag===r.from_tag&&this._dialog.id.remote_tag===r.to_tag){this.sendRequest(Ie.ACK);return}else{const n=new Bl(this,r,"UAC");if(n.error!==void 0){console.log(n.error);return}this.sendRequest(Ie.ACK),this.sendRequest(Ie.BYE);return}if(this._is_canceled){r.status_code>=100&&r.status_code<200?this._request.cancel(this._cancel_reason):r.status_code>=200&&r.status_code<299&&this._acceptAndTerminate(r);return}if(!(this._status!==ye.STATUS_INVITE_SENT&&this._status!==ye.STATUS_1XX_RECEIVED))switch(console.log("start Switch"),!0){case/^100$/.test(r.status_code):this._status=ye.STATUS_1XX_RECEIVED;break;case/^1[0-9]{2}$/.test(r.status_code):{if(!r.to_tag){console.log("1xx response received without to tag");break}if(r.hasHeader("contact")&&!this._createDialog(r,"UAC",!0))break;if(this._status=ye.STATUS_1XX_RECEIVED,!r.body){this._progress("remote",r);break}const n={originator:"remote",type:"answer",sdp:r.body};console.log('emit "sdp"'),this.emit("sdp",n);const o=new RTCSessionDescription({type:"answer",sdp:n.sdp});this._connectionPromiseQueue=this._connectionPromiseQueue.then(()=>this._connection.setRemoteDescription(o)).then(()=>this._progress("remote",r)).catch(a=>{console.log('emit "peerconnection:setremotedescriptionfailed" [error:%o]',a),this.emit("peerconnection:setremotedescriptionfailed",a)});break}case/^2[0-9]{2}$/.test(r.status_code):{if(console.log("maybe here???"),this._status=ye.STATUS_CONFIRMED,!r.body){this._acceptAndTerminate(r,400,Ie.causes.MISSING_SDP),console.log("failed 3"),this._failed("remote",r,Ie.causes.BAD_MEDIA_DESCRIPTION);break}if(!this._createDialog(r,"UAC"))break;const n={originator:"remote",type:"answer",sdp:r.body};console.log('emit "sdp"'),this.emit("sdp",n),new RTCSessionDescription({type:"answer",sdp:n.sdp}),this._connectionPromiseQueue=this._connectionPromiseQueue.then(()=>{if(this._connection.signalingState==="stable")return this._connection.createOffer(this._rtcOfferConstraints).then(o=>this._connection.setLocalDescription(o)).catch(o=>{this._acceptAndTerminate(r,500,o.toString()),console.log("failed 4"),this._failed("local",r,Ie.causes.WEBRTC_ERROR)})}).then(()=>{this._handleSessionTimersInIncomingResponse(r),this._accepted("remote",r),this.sendRequest(Ie.ACK),this._confirmed("local",null)});break}default:{const n=Ss.sipErrorCause(r.status_code);console.log("failed 5"),this._failed("remote",r,n)}}}sendMSRP(r){const n=new In("");n.method="SEND",n.addHeader("To-Path",`${this.my_addr[1]} ${this.target_addr[1]} ${this.target_addr[0]}`),n.addHeader("From-Path",`${this.my_addr[0]}`),n.addHeader("Message-ID",Ss.createRandomToken(10)),n.addHeader("Byte-Range","1-25/25"),n.addHeader("Content-Type","text/plain"),n.addHeader("Success-Report","yes"),n.addHeader("Failure-Report","yes"),n.body=r;let o=n.toString();console.log(o);let a=[];for(var t=0;t<o.length;t++)a.push(o.charCodeAt(t).toString(16));console.log(a),this._connection.send(n.toString()),n.direction="outgoing",this.emit("newMessage",n),this._msgHistory.push(n),this.emit("msgHistoryUpdate",this._msgHistory)}_sendOk(r){let n=r.ident,o=r.getHeader("Message-ID"),a=new In("");a.method="200 OK",a.addHeader("To-Path",`${this.my_addr[1]}`),a.addHeader("From-Path",`${this.my_addr[0]}`),a.addHeader("Message-ID",o),a.ident=n;let t=a.toString();console.log(t);let s=[];for(var p=0;p<t.length;p++)s.push(t.charCodeAt(p).toString(16));console.log(s),this._connection.send(a.toString())}_sendReport(r){let n=r.ident,o=r.getHeader("Message-ID"),a=new In("");a.method="REPORT",a.addHeader("To-Path",`${r.getHeader("From-Path")}`),a.addHeader("From-Path",`${this.my_addr[0]}`),a.addHeader("Message-ID",o),a.addHeader("Byte-Range","1-25/25"),a.addHeader("Status","000 200 OK"),a.ident=n;let t=a.toString();console.log(t);let s=[];for(var p=0;p<t.length;p++)s.push(t.charCodeAt(p).toString(16));console.log(s),this._connection.send(a.toString())}parseAuth(r){const n={},o=r.replace("Digest","").split(",");for(const a of o){const t=a.trim().split("=");n[t[0]]=t[1].match('^"(.+)"$')[1]}return n}init_incoming(r,n){let o;const a=r.hasHeader("Content-Type")?r.getHeader("Content-Type").toLowerCase():void 0;if(r.body&&a!=="application/sdp"){r.reply(415);return}if(this._status=ye.STATUS_INVITE_RECEIVED,this._from_tag=r.from_tag,this._id=r.call_id+this._from_tag,this._request=r,this._contact=this._ua.contact.toString(),r.hasHeader("expires")&&(o=r.getHeader("expires")*1e3),r.to_tag=Ss.newTag(),!this._createDialog(r,"UAS",!0)){r.reply(500,"Missing Contact header field");return}r.body?this._late_sdp=!1:this._late_sdp=!0,this._status=ye.STATUS_WAITING_FOR_ANSWER,this._timers.userNoAnswerTimer=setTimeout(()=>{r.reply(408),console.log("failed 6"),this._failed("local",null,Ie.causes.NO_ANSWER)},this._ua.configuration.no_answer_timeout),o&&(this._timers.expiresTimer=setTimeout(()=>{this._status===ye.STATUS_WAITING_FOR_ANSWER&&(r.reply(487),console.log("failed 7"),this._failed("system",null,Ie.causes.EXPIRES))},o)),this._direction="incoming",this._local_identity=r.to,this._remote_identity=r.from,n&&n(this),r.parseSDP(!0),this.target_addr=r.sdp.media[0].invalid[1].value.replaceAll("path:","").split(" ").reverse(),this._newMSRPSession("remote",r),this._status!==ye.STATUS_TERMINATED&&(r.reply(180,null,[`Contact: ${this._ua._contact}`]),this._progress("local",null))}_failed(r,n,o){this.emit("_failed",{originator:r,message:n||null,cause:o}),this._close(),this.emit("failed",{originator:r,message:n||null,cause:o})}_close(){if(console.log("CLOSE SESSION"),this._status!==ye.STATUS_TERMINATED){if(this._status=ye.STATUS_TERMINATED,this._connection)try{this._connection.close()}catch(r){console.log("close() | error closing the RTCPeerConnection: %o",r)}for(const r in this._timers)Object.prototype.hasOwnProperty.call(this._timers,r)&&clearTimeout(this._timers[r]);clearTimeout(this._sessionTimers.timer),this._dialog&&(this._dialog.terminate(),delete this._dialog);for(const r in this._earlyDialogs)Object.prototype.hasOwnProperty.call(this._earlyDialogs,r)&&(this._earlyDialogs[r].terminate(),delete this._earlyDialogs[r]);for(const r in this._referSubscribers)Object.prototype.hasOwnProperty.call(this._referSubscribers,r)&&delete this._referSubscribers[r];this._ua.destroyMSRPSession(this)}}_createDialog(r,n,o){const a=n==="UAS"?r.to_tag:r.from_tag,t=n==="UAS"?r.from_tag:r.to_tag,s=r.call_id+a+t;let p=this._earlyDialogs[s];if(o)return p?!0:(p=new Bl(this,r,n,Bl.C.STATUS_EARLY),p.error?(console.log("failed 8"),this._failed("remote",r,Ie.causes.INTERNAL_ERROR),!1):(this._earlyDialogs[s]=p,!0));{if(this._from_tag=r.from_tag,this._to_tag=r.to_tag,p)return p.update(r,n),this._dialog=p,delete this._earlyDialogs[s],!0;const _=new Bl(this,r,n);return _.error?(console.log("failed 9"),this._failed("remote",r,Ie.causes.INTERNAL_ERROR),!1):(this._dialog=_,!0)}}_newMSRPSession(r,n){this._ua.newMSRPSession(this,{originator:r,session:this,request:n})}_progress(r,n){this.emit("progress",{originator:r,response:n||null})}isEnded(){switch(this._status){case ye.STATUS_CANCELED:case ye.STATUS_TERMINATED:return!0;default:return!1}}_accepted(r,n){console.log("session accepted"),this._start_time=new Date,console.log('emit "accepted"'),this.emit("accepted",{originator:r,response:n||null})}_confirmed(r,n){console.log("session confirmed"),this._is_confirmed=!0,console.log('emit "confirmed"'),this.emit("confirmed",{originator:r,ack:n||null})}_ended(r,n,o){console.log("session ended"),this._end_time=new Date,this._close(),console.log('emit "ended"'),this.emit("ended",{originator:r,message:n||null,cause:o})}_handleSessionTimersInIncomingResponse(r){if(!this._sessionTimers.enabled)return;let n;r.session_expires&&r.session_expires>=Ie.MIN_SESSION_EXPIRES?(this._sessionTimers.currentExpires=r.session_expires,n=r.session_expires_refresher||"uac"):(this._sessionTimers.currentExpires=this._sessionTimers.defaultExpires,n="uac"),this._sessionTimers.refresher=n==="uac",this._runSessionTimer()}receiveRequest(r){if(console.log("receiveRequest()"),r.method===Ie.CANCEL)(this._status===ye.STATUS_WAITING_FOR_ANSWER||this._status===ye.STATUS_ANSWERED)&&(this._status=ye.STATUS_CANCELED,this._request.reply(487),console.log("failed 10"),this._failed("remote",r,Ie.causes.CANCELED));else switch(r.method){case Ie.ACK:if(this._status!==ye.STATUS_WAITING_FOR_ACK)return;if(this._status=ye.STATUS_CONFIRMED,clearTimeout(this._timers.ackTimer),clearTimeout(this._timers.invite2xxTimer),this._late_sdp){if(!r.body){this.terminate({cause:Ie.causes.MISSING_SDP,status_code:400});break}const n={originator:"remote",type:"answer",sdp:r.body};console.log('emit "sdp"'),this.emit("sdp",n);const o=new RTCSessionDescription({type:"answer",sdp:n.sdp});this._connectionPromiseQueue=this._connectionPromiseQueue.then(()=>this._connection.setRemoteDescription(o)).then(()=>{this._is_confirmed||this._confirmed("remote",r)}).catch(a=>{this.terminate({cause:Ie.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",r);break;case Ie.BYE:this._status===ye.STATUS_CONFIRMED||this._status===ye.STATUS_WAITING_FOR_ACK?(r.reply(200),this._ended("remote",r,Ie.causes.BYE)):this._status===ye.STATUS_INVITE_RECEIVED||this._status===ye.STATUS_WAITING_FOR_ANSWER?(r.reply(200),this._request.reply(487,"BYE Received"),this._ended("remote",r,Ie.causes.BYE)):r.reply(403,"Wrong Status");break;case Ie.INVITE:this._status===ye.STATUS_CONFIRMED?r.hasHeader("replaces")?this._receiveReplaces(r):this._receiveReinvite(r):r.reply(403,"Wrong Status");break;case Ie.INFO:this._status===ye.STATUS_1XX_RECEIVED||this._status===ye.STATUS_WAITING_FOR_ANSWER||this._status===ye.STATUS_ANSWERED||this._status===ye.STATUS_WAITING_FOR_ACK||this._status===ye.STATUS_CONFIRMED?(r.hasHeader("Content-Type")?r.getHeader("Content-Type").toLowerCase():void 0)!==void 0?new RTCSession_Info(this).init_incoming(r):r.reply(415):r.reply(403,"Wrong Status");break;case Ie.UPDATE:this._status===ye.STATUS_CONFIRMED?this._receiveUpdate(r):r.reply(403,"Wrong Status");break;case Ie.REFER:this._status===ye.STATUS_CONFIRMED?this._receiveRefer(r):r.reply(403,"Wrong Status");break;case Ie.NOTIFY:this._status===ye.STATUS_CONFIRMED?this._receiveNotify(r):r.reply(403,"Wrong Status");break;default:r.reply(501)}}onTransportError(){console.log("onTransportError()"),this._status!==ye.STATUS_TERMINATED&&this.terminate({status_code:500,reason_phrase:Ie.causes.CONNECTION_ERROR,cause:Ie.causes.CONNECTION_ERROR})}onRequestTimeout(){console.log("onRequestTimeout()"),this._status!==ye.STATUS_TERMINATED&&this.terminate({status_code:408,reason_phrase:Ie.causes.REQUEST_TIMEOUT,cause:Ie.causes.REQUEST_TIMEOUT})}onDialogError(){console.log("onDialogError()"),this._status!==ye.STATUS_TERMINATED&&this.terminate({status_code:500,reason_phrase:Ie.causes.DIALOG_ERROR,cause:Ie.causes.DIALOG_ERROR})}}const zt=console,Pf={STATUS_INIT:0,STATUS_READY:1,STATUS_USER_CLOSED:2,STATUS_NOT_READY:3,CONFIGURATION_ERROR:1,NETWORK_ERROR:2},Og=bg;class Dg extends Og{constructor(r){console.log(r),super(r),this._msrp_sessions=[],this._transactions={nist:{},nict:{},ist:{},ict:{}}}call(r,n){return super.call(r,n)}newMSRPSession(r,n){r.on("msgHistoryUpdate",o=>{console.log(o)}),this._msrp_sessions[r.id]=r,this.emit("newMSRPSession",n)}destroyMSRPSession(r){delete this._msrp_sessions[r.id]}receiveRequest(r){const n=r.method;if(console.log("-----------"),r.ruri.user!==this._configuration.uri.user&&r.ruri.user!==this._contact.uri.user){zt.debug("Request-URI does not point to us"),r.method!==we.ACK&&r.reply_sl(404);return}if(r.ruri.scheme===we.SIPS){r.reply_sl(416);return}if(Dr.checkTransaction(this,r))return;if(n===we.INVITE?new Dr.InviteServerTransaction(this,this._transport,r):n!==we.ACK&&n!==we.CANCEL&&new Dr.NonInviteServerTransaction(this,this._transport,r),n===we.OPTIONS){if(this.listeners("newOptions").length===0){r.reply(200);return}new ga.Options(this).init_incoming(r)}else if(n===we.MESSAGE){if(this.listeners("newMessage").length===0){r.reply(405);return}new ga.Message(this).init_incoming(r)}else if(n===we.INVITE&&!r.to_tag&&this.listeners("newRTCSession").length===0){r.reply(405);return}let o,a;if(r.to_tag)o=this._findDialog(r.call_id,r.from_tag,r.to_tag),o?o.receiveRequest(r):n===we.NOTIFY?(a=this._findSession(r),a?a.receiveRequest(r):(zt.debug("received NOTIFY request for a non existent subscription"),r.reply(481,"Subscription does not exist"))):n!==we.ACK&&r.reply(481);else switch(n){case we.INVITE:if(window.RTCPeerConnection)if(r.hasHeader("replaces")){const t=r.replaces;o=this._findDialog(t.call_id,t.from_tag,t.to_tag),o?(a=o.owner,a.isEnded()?r.reply(603):a.receiveRequest(r)):r.reply(481)}else r.body.search(/MSRP/ig)?(a=new Uf(this),a.init_incoming(r)):(a=new ga.RTCSessiono(this),a.init_incoming(r));else zt.warn("INVITE received but WebRTC is not supported"),r.reply(488);break;case we.BYE:r.reply(481);break;case we.CANCEL:a=this._findSession(r),a?a.receiveRequest(r):zt.debug("received CANCEL request for a non existent session");break;case we.ACK:break;case we.NOTIFY:this.emit("sipEvent",{event:r.event,request:r}),r.reply(200);break;default:r.reply(405);break}}startMSRP(r,n){zt.debug("startMSRP()",n);const o=new Uf(this);return o.connect(r),o}terminateMSRPSessions(r){zt.debug("terminateSessions()");for(const n in this._msrp_sessions)this._msrp_sessions[n].isEnded()||this._msrp_sessions[n].terminate(r)}stop(){if(zt.debug("stop()"),this._dynConfiguration={},this._status===Pf.STATUS_USER_CLOSED){zt.debug("UA already closed");return}this._registrator.close();const r=Object.keys(this._sessions).length;for(const o in this._sessions)if(Object.prototype.hasOwnProperty.call(this._sessions,o)){zt.debug(`closing session ${o}`);try{this._sessions[o].terminate()}catch(a){console.error(a)}}for(const o in this._msrp_sessions)if(Object.prototype.hasOwnProperty.call(this._msrp_sessions,o)){zt.debug(`closing session ${o}`);try{this._msrp_sessions[o].terminate()}catch(a){console.error(a)}}for(const o in this._applicants)if(Object.prototype.hasOwnProperty.call(this._applicants,o))try{this._applicants[o].close()}catch(a){console.error(a)}this._status=Pf.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&&r===0?this._transport.disconnect():this._closeTimer=setTimeout(()=>{this._closeTimer=null,this._transport.disconnect()},2e3)}}var pt={};pt.forEach=async(c,r,n)=>{const o=[];for(let a=0;a<c.length;a++)if(a in c){const t=Promise.resolve(c[a]).then(s=>r.call(n||globalThis,s,a,c));o.push(t)}await Promise.all(o)},pt.forEachSeries=async(c,r,n)=>{for(let o=0;o<c.length;o++)o in c&&await r.call(n||globalThis,await c[o],o,c)},pt.map=async(c,r,n)=>{const o=[];for(let a=0;a<c.length;a++)a in c&&(o[a]=Promise.resolve(c[a]).then(t=>r.call(n||globalThis,t,a,c)));return Promise.all(o)},pt.mapSeries=async(c,r,n)=>{const o=[];for(let a=0;a<c.length;a++)a in c&&(o[a]=await r.call(n||globalThis,await c[a],a,c));return o},pt.find=(c,r,n)=>new Promise((o,a)=>{if(c.length===0)return o();let t=1;for(let s=0;s<c.length;s++){const p=_=>{_?o(c[s]):t===c.length&&o(),t++};Promise.resolve(c[s]).then(_=>r.call(n||globalThis,_,s,c)).then(p).catch(a)}}),pt.findSeries=async(c,r,n)=>{for(let o=0;o<c.length;o++)if(await r.call(n||globalThis,await c[o],o,c))return c[o]},pt.findIndex=(c,r,n)=>new Promise((o,a)=>{if(c.length===0)return o(-1);let t=1;for(let s=0;s<c.length;s++){const p=_=>{_?o(s):t===c.length&&o(-1),t++};Promise.resolve(c[s]).then(_=>r.call(n||globalThis,_,s,c)).then(p).catch(a)}}),pt.findIndexSeries=async(c,r,n)=>{for(let o=0;o<c.length;o++)if(await r.call(n||globalThis,await c[o],o,c))return o},pt.some=(c,r,n)=>new Promise((o,a)=>{if(c.length===0)return o(!1);let t=1;for(let s=0;s<c.length;s++){if(!(s in c)){t++;continue}const p=_=>{_?o(!0):t===c.length&&o(!1),t++};Promise.resolve(c[s]).then(_=>r.call(n||globalThis,_,s,c)).then(p).catch(a)}}),pt.someSeries=async(c,r,n)=>{for(let o=0;o<c.length;o++)if(o in c&&await r.call(n||globalThis,await c[o],o,c))return!0;return!1},pt.every=(c,r,n)=>new Promise((o,a)=>{if(c.length===0)return o(!0);let t=1;for(let s=0;s<c.length;s++){if(!(s in c)){t++;continue}const p=_=>{_?t===c.length&&o(!0):o(!1),t++};Promise.resolve(c[s]).then(_=>r.call(n||globalThis,_,s,c)).then(p).catch(a)}}),pt.everySeries=async(c,r,n)=>{for(let o=0;o<c.length;o++)if(o in c&&!await r.call(n||globalThis,await c[o],o,c))return!1;return!0},pt.filter=(c,r,n)=>new Promise(async(o,a)=>{const t=[];for(let p=0;p<c.length;p++)p in c&&(t[p]=Promise.resolve(c[p]).then(_=>r.call(n||globalThis,_,p,c)).catch(a));const s=[];for(let p=0;p<t.length;p++)await t[p]&&s.push(await c[p]);o(s)}),pt.filterSeries=async(c,r,n)=>{const o=[];for(let a=0;a<c.length;a++)a in c&&await r.call(n||globalThis,await c[a],a,c)&&o.push(await c[a]);return o},pt.reduce=async(c,r,n)=>{if(c.length===0&&n===void 0)throw TypeError("Reduce of empty array with no initial value");let o,a;for(n!==void 0?(a=n,o=0):(a=c[0],o=1),o;o<c.length;o++)o in c&&(a=await r(await a,await c[o],o,c));return a};var kf={};(function(c){const r=pt;Object.keys(r).forEach(n=>{const o=n.charAt(0).toUpperCase()+n.slice(1);c[`async${o}`]=async function(...a){return r[n](this,...a)}})})(kf);var Ng=Object.assign(pt,{instanceMethods:kf});function za(c){return c<10?`0${c}`:`${c}`}function Ug(c){let r=c.hours||0,n=c.minutes||0,o=c.seconds||0;o++,o===60&&(o=0,n++,n===60&&(n=0,r++));const a=`${za(r)}:${za(n)}:${za(o)}`;return{seconds:o,minutes:n,hours:r,formatted:a}}function Pg(c,r){return Object.keys(c).filter(n=>r.includes(n)).reduce((n,o)=>{const a=o;return{...n,[a]:c[a]}},{})}const kg=["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"],Mg=["_cancel_reason","_contact","direction","_end_time","_eventsCount","_from_tag","_id","_is_canceled","_is_confirmed","_late_sdp","status","start_time","_remote_identity","target_addr"];function Mf(c){const r={};return kg.forEach(n=>{c[n]!==void 0&&(r[n]=c[n])}),r.localHold=c._localHold,r}function xf(c){const r={};return Mg.forEach(n=>{c[n]!==void 0&&(r[n]=c[n])}),r}function Ql(c,r){const n=new AudioContext,o=n.createMediaStreamSource(c),a=n.createMediaStreamDestination(),t=n.createGain();return o.connect(t),t.connect(a),t.gain.value=r,a.stream}function xg(c,r,n,o){const a=document.createElement("audio");a.id=r._id,a.className="audioTag",a.srcObject=c.stream,a.setSinkId(n),a.volume=o,a.play(),r.audioTag=a}function Lg(c){if(c&&typeof c.log=="function"&&typeof c.warn=="function"&&typeof c.error=="function")return!0}var $g={exports:{}};(function(c){var r=function(n){var o=Object.prototype,a=o.hasOwnProperty,t=Object.defineProperty||function(Q,W,B){Q[W]=B.value},s,p=typeof Symbol=="function"?Symbol:{},_=p.iterator||"@@iterator",d=p.asyncIterator||"@@asyncIterator",g=p.toStringTag||"@@toStringTag";function v(Q,W,B){return Object.defineProperty(Q,W,{value:B,enumerable:!0,configurable:!0,writable:!0}),Q[W]}try{v({},"")}catch{v=function(W,B,te){return W[B]=te}}function E(Q,W,B,te){var de=W&&W.prototype instanceof ie?W:ie,Ae=Object.create(de.prototype),Ue=new P(te||[]);return t(Ae,"_invoke",{value:Y(Q,B,Ue)}),Ae}n.wrap=E;function S(Q,W,B){try{return{type:"normal",arg:Q.call(W,B)}}catch(te){return{type:"throw",arg:te}}}var C="suspendedStart",I="suspendedYield",w="executing",F="completed",L={};function ie(){}function N(){}function H(){}var ve={};v(ve,_,function(){return this});var me=Object.getPrototypeOf,M=me&&me(me(Z([])));M&&M!==o&&a.call(M,_)&&(ve=M);var D=H.prototype=ie.prototype=Object.create(ve);N.prototype=H,t(D,"constructor",{value:H,configurable:!0}),t(H,"constructor",{value:N,configurable:!0}),N.displayName=v(H,g,"GeneratorFunction");function V(Q){["next","throw","return"].forEach(function(W){v(Q,W,function(B){return this._invoke(W,B)})})}n.isGeneratorFunction=function(Q){var W=typeof Q=="function"&&Q.constructor;return W?W===N||(W.displayName||W.name)==="GeneratorFunction":!1},n.mark=function(Q){return Object.setPrototypeOf?Object.setPrototypeOf(Q,H):(Q.__proto__=H,v(Q,g,"GeneratorFunction")),Q.prototype=Object.create(D),Q},n.awrap=function(Q){return{__await:Q}};function j(Q,W){function B(Ae,Ue,Se,ne){var Te=S(Q[Ae],Q,Ue);if(Te.type==="throw")ne(Te.arg);else{var tt=Te.arg,st=tt.value;return st&&typeof st=="object"&&a.call(st,"__await")?W.resolve(st.__await).then(function(ge){B("next",ge,Se,ne)},function(ge){B("throw",ge,Se,ne)}):W.resolve(st).then(function(ge){tt.value=ge,Se(tt)},function(ge){return B("throw",ge,Se,ne)})}}var te;function de(Ae,Ue){function Se(){return new W(function(ne,Te){B(Ae,Ue,ne,Te)})}return te=te?te.then(Se,Se):Se()}t(this,"_invoke",{value:de})}V(j.prototype),v(j.prototype,d,function(){return this}),n.AsyncIterator=j,n.async=function(Q,W,B,te,de){de===void 0&&(de=Promise);var Ae=new j(E(Q,W,B,te),de);return n.isGeneratorFunction(W)?Ae:Ae.next().then(function(Ue){return Ue.done?Ue.value:Ae.next()})};function Y(Q,W,B){var te=C;return function(Ae,Ue){if(te===w)throw new Error("Generator is already running");if(te===F){if(Ae==="throw")throw Ue;return et()}for(B.method=Ae,B.arg=Ue;;){var Se=B.delegate;if(Se){var ne=$(Se,B);if(ne){if(ne===L)continue;return ne}}if(B.method==="next")B.sent=B._sent=B.arg;else if(B.method==="throw"){if(te===C)throw te=F,B.arg;B.dispatchException(B.arg)}else B.method==="return"&&B.abrupt("return",B.arg);te=w;var Te=S(Q,W,B);if(Te.type==="normal"){if(te=B.done?F:I,Te.arg===L)continue;return{value:Te.arg,done:B.done}}else Te.type==="throw"&&(te=F,B.method="throw",B.arg=Te.arg)}}}function $(Q,W){var B=W.method,te=Q.iterator[B];if(te===s)return W.delegate=null,B==="throw"&&Q.iterator.return&&(W.method="return",W.arg=s,$(Q,W),W.method==="throw")||B!=="return"&&(W.method="throw",W.arg=new TypeError("The iterator does not provide a '"+B+"' method")),L;var de=S(te,Q.iterator,W.arg);if(de.type==="throw")return W.method="throw",W.arg=de.arg,W.delegate=null,L;var Ae=de.arg;if(!Ae)return W.method="throw",W.arg=new TypeError("iterator result is not an object"),W.delegate=null,L;if(Ae.done)W[Q.resultName]=Ae.value,W.next=Q.nextLoc,W.method!=="return"&&(W.method="next",W.arg=s);else return Ae;return W.delegate=null,L}V(D),v(D,g,"Generator"),v(D,_,function(){return this}),v(D,"toString",function(){return"[object Generator]"});function X(Q){var W={tryLoc:Q[0]};1 in Q&&(W.catchLoc=Q[1]),2 in Q&&(W.finallyLoc=Q[2],W.afterLoc=Q[3]),this.tryEntries.push(W)}function U(Q){var W=Q.completion||{};W.type="normal",delete W.arg,Q.completion=W}function P(Q){this.tryEntries=[{tryLoc:"root"}],Q.forEach(X,this),this.reset(!0)}n.keys=function(Q){var W=Object(Q),B=[];for(var te in W)B.push(te);return B.reverse(),function de(){for(;B.length;){var Ae=B.pop();if(Ae in W)return de.value=Ae,de.done=!1,de}return de.done=!0,de}};function Z(Q){if(Q){var W=Q[_];if(W)return W.call(Q);if(typeof Q.next=="function")return Q;if(!isNaN(Q.length)){var B=-1,te=function de(){for(;++B<Q.length;)if(a.call(Q,B))return de.value=Q[B],de.done=!1,de;return de.value=s,de.done=!0,de};return te.next=te}}return{next:et}}n.values=Z;function et(){return{value:s,done:!0}}return P.prototype={constructor:P,reset:function(Q){if(this.prev=0,this.next=0,this.sent=this._sent=s,this.done=!1,this.delegate=null,this.method="next",this.arg=s,this.tryEntries.forEach(U),!Q)for(var W in this)W.charAt(0)==="t"&&a.call(this,W)&&!isNaN(+W.slice(1))&&(this[W]=s)},stop:function(){this.done=!0;var Q=this.tryEntries[0],W=Q.completion;if(W.type==="throw")throw W.arg;return this.rval},dispatchException:function(Q){if(this.done)throw Q;var W=this;function B(ne,Te){return Ae.type="throw",Ae.arg=Q,W.next=ne,Te&&(W.method="next",W.arg=s),!!Te}for(var te=this.tryEntries.length-1;te>=0;--te){var de=this.tryEntries[te],Ae=de.completion;if(de.tryLoc==="root")return B("end");if(de.tryLoc<=this.prev){var Ue=a.call(de,"catchLoc"),Se=a.call(de,"finallyLoc");if(Ue&&Se){if(this.prev<de.catchLoc)return B(de.catchLoc,!0);if(this.prev<de.finallyLoc)return B(de.finallyLoc)}else if(Ue){if(this.prev<de.catchLoc)return B(de.catchLoc,!0)}else if(Se){if(this.prev<de.finallyLoc)return B(de.finallyLoc)}else throw new Error("try statement without catch or finally")}}},abrupt:function(Q,W){for(var B=this.tryEntries.length-1;B>=0;--B){var te=this.tryEntries[B];if(te.tryLoc<=this.prev&&a.call(te,"finallyLoc")&&this.prev<te.finallyLoc){var de=te;break}}de&&(Q==="break"||Q==="continue")&&de.tryLoc<=W&&W<=de.finallyLoc&&(de=null);var Ae=de?de.completion:{};return Ae.type=Q,Ae.arg=W,de?(this.method="next",this.next=de.finallyLoc,L):this.complete(Ae)},complete:function(Q,W){if(Q.type==="throw")throw Q.arg;return Q.type==="break"||Q.type==="continue"?this.next=Q.arg:Q.type==="return"?(this.rval=this.arg=Q.arg,this.method="return",this.next="end"):Q.type==="normal"&&W&&(this.next=W),L},finish:function(Q){for(var W=this.tryEntries.length-1;W>=0;--W){var B=this.tryEntries[W];if(B.finallyLoc===Q)return this.complete(B.completion,B.afterLoc),U(B),L}},catch:function(Q){for(var W=this.tryEntries.length-1;W>=0;--W){var B=this.tryEntries[W];if(B.tryLoc===Q){var te=B.completion;if(te.type==="throw"){var de=te.arg;U(B)}return de}}throw new Error("illegal catch attempt")},delegateYield:function(Q,W,B){return this.delegate={iterator:Z(Q),resultName:W,nextLoc:B},this.method==="next"&&(this.arg=s),L}},n}(c.exports);try{regeneratorRuntime=r}catch{typeof globalThis=="object"?globalThis.regeneratorRuntime=r:Function("r","regeneratorRuntime = r")(r)}})($g);var Lf={exports:{}};(function(c){(function(r,n){c.exports?c.exports=n():r.log=n()})(Qf,function(){var r=function(){},n="undefined",o=typeof window!==n&&typeof window.navigator!==n&&/Trident\/|MSIE /.test(window.navigator.userAgent),a=["trace","debug","info","warn","error"];function t(I,w){var F=I[w];if(typeof F.bind=="function")return F.bind(I);try{return Function.prototype.bind.call(F,I)}catch{return function(){return Function.prototype.apply.apply(F,[I,arguments])}}}function s(){console.log&&(console.log.apply?console.log.apply(console,arguments):Function.prototype.apply.apply(console.log,[console,arguments])),console.trace&&console.trace()}function p(I){return I==="debug"&&(I="log"),typeof console===n?!1:I==="trace"&&o?s:console[I]!==void 0?t(console,I):console.log!==void 0?t(console,"log"):r}function _(I,w){for(var F=0;F<a.length;F++){var L=a[F];this[L]=F<I?r:this.methodFactory(L,I,w)}this.log=this.debug}function d(I,w,F){return function(){typeof console!==n&&(_.call(this,w,F),this[I].apply(this,arguments))}}function g(I,w,F){return p(I)||d.apply(this,arguments)}function v(I,w,F){var L=this,ie;w=w??"WARN";var N="loglevel";typeof I=="string"?N+=":"+I:typeof I=="symbol"&&(N=void 0);function H(D){var V=(a[D]||"silent").toUpperCase();if(!(typeof window===n||!N)){try{window.localStorage[N]=V;return}catch{}try{window.document.cookie=encodeURIComponent(N)+"="+V+";"}catch{}}}function ve(){var D;if(!(typeof window===n||!N)){try{D=window.localStorage[N]}catch{}if(typeof D===n)try{var V=window.document.cookie,j=V.indexOf(encodeURIComponent(N)+"=");j!==-1&&(D=/^([^;]+)/.exec(V.slice(j))[1])}catch{}return L.levels[D]===void 0&&(D=void 0),D}}function me(){if(!(typeof window===n||!N)){try{window.localStorage.removeItem(N);return}catch{}try{window.document.cookie=encodeURIComponent(N)+"=; expires=Thu, 01 Jan 1970 00:00:00 UTC"}catch{}}}L.name=I,L.levels={TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,SILENT:5},L.methodFactory=F||g,L.getLevel=function(){return ie},L.setLevel=function(D,V){if(typeof D=="string"&&L.levels[D.toUpperCase()]!==void 0&&(D=L.levels[D.toUpperCase()]),typeof D=="number"&&D>=0&&D<=L.levels.SILENT){if(ie=D,V!==!1&&H(D),_.call(L,D,I),typeof console===n&&D<L.levels.SILENT)return"No console available for logging"}else throw"log.setLevel() called with invalid level: "+D},L.setDefaultLevel=function(D){w=D,ve()||L.setLevel(D,!1)},L.resetLevel=function(){L.setLevel(w,!1),me()},L.enableAll=function(D){L.setLevel(L.levels.TRACE,D)},L.disableAll=function(D){L.setLevel(L.levels.SILENT,D)};var M=ve();M==null&&(M=w),L.setLevel(M,!1)}var E=new v,S={};E.getLogger=function(w){if(typeof w!="symbol"&&typeof w!="string"||w==="")throw new TypeError("You must supply a name when creating a logger.");var F=S[w];return F||(F=S[w]=new v(w,E.getLevel(),E.methodFactory)),F};var C=typeof window!==n?window.log:void 0;return E.noConflict=function(){return typeof window!==n&&window.log===E&&(window.log=C),E},E.getLoggers=function(){return S},E.default=E,E})})(Lf);var Tt=Lf.exports;const us=()=>`${new Date().toISOString()} | metrics`,cs=(c,r,n)=>`${c} | ${r} | ${n}`;Tt.setDefaultLevel(Tt.levels.TRACE);const Hg=c=>{Tt.info(cs(us(),"log ",`set log level to ${c?"verbose":"info"}`)),Tt.setLevel(c?Tt.levels.TRACE:Tt.levels.INFO)},Fg=c=>{const r=[...Object.keys(Tt.levels)];r.includes(c)?(Tt.info(cs(us(),"log ",`update log level to ${c.toLowerCase()}`)),Tt.setLevel(c)):Tt.warn(cs(us(),"log ","Incorrect log level please choose one of "),r)},Ne=(c,r,n)=>{n?Tt.debug(cs(us(),c,r),n):Tt.debug(cs(us(),c,r))},Ja=(c,r)=>{Tt.info(cs(us(),c,r))},Ks=(c,r)=>{Tt.info(cs(us(),c,r))},Zl=(c,r)=>{Tt.warn(cs(us(),c,r))},bn=(c,r)=>{Tt.error(cs(us(),c,r))};function qg(c){return Math.floor(Math.random()*c).toString()}function $f(c,r){let n=r;return c.forEach(o=>{n=n.replace(o,"")}),n}function jg(c,r){let n="";for(let o=0;o<r;o+=1)n+=c[qg(c.length)];return n}function Vg({length:c=20,useLetters:r=!0,useNumbers:n=!0,includeSymbols:o=[],excludeSymbols:a=[]}={}){let t="abcdefghijklmnopqrstuvwxyz",s="0123456789",p=[],_=[],d=[];return r&&(a.length&&(t=$f(a,t)),_=t.split("")),n&&(a.length&&(s=$f(a,s)),d=s.split("")),p=[..._,...d,...o],jg(p,c)}var Bg=Vg;const Hr=qt(Bg),Gg=()=>"WebRTCMetrics",Kg=()=>"5.0.3",ke={INBOUND:"inbound",OUTBOUND:"outbound"},fs={IDLE:"idle",RUNNING:"running",MUTED:"muted"},Fr={NEW:"new",CHECKING:"checking",CONNECTED:"connected",COMPLETED:"completed",DISCONNECTED:"disconnected",FAILED:"failed",CLOSED:"closed"},Wg=()=>({...{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:[]}}),Hf={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:ke.INBOUND},Ff={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:ke.OUTBOUND},qf={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:ke.INBOUND},jf={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:ke.OUTBOUND},Yg=c=>{const r={pname:"",call_id:"",user_id:"",timestamp:null,count:0,audio:{},video:{},network:{infrastructure:3,local_candidate_id:"",local_candidate_type:"",local_candidate_protocol:"",local_candidate_relay_protocol:"",remote_candidate_id:"",remote_candidate_type:"",remote_candidate_protocol:""},data:{total_KBytes_in:0,total_KBytes_out:0,delta_KBytes_in:0,delta_KBytes_out:0,delta_kbs_in:0,delta_kbs_out:0,delta_kbs_bandwidth_in:0,delta_kbs_bandwidth_out:0,delta_rtt_connectivity_ms:null,total_rtt_connectivity_ms:0,total_rtt_connectivity_measure:0},experimental:{time_to_measure_ms:0}};if(c){const n={...c,audio:{},video:{},data:{...c.data},network:{...c.network},experimental:{...c.experimental}};return Object.keys(c.audio).forEach(o=>{n.audio[o]={...c.audio[o]}}),Object.keys(c.video).forEach(o=>{n.video[o]={...c.video[o]}}),n}return{...r,audio:{},video:{},data:{...r.data},network:{...r.network},experimental:{...r.experimental}}},zg={refreshEvery:2e3,startAfter:0,stopAfter:-1,verbose:!1,pname:`p-${Hr()}`,cid:`c-${Hr()}`,uid:`u-${Hr()}`,record:!1,ticket:!0},Ht={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"},q={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"},k={SUCCEEDED:"succeeded",AUDIO:"audio",VIDEO:"video"},qr={ETHERNET:0,CELLULAR_5G:2,WIFI:3,CELLULAR_4G:5,CELLULAR:10},Xa={ETHERNET:"ethernet",CELLULAR_4G:"cellular",WIFI:"wifi"},ee={AUDIO:"audio",VIDEO:"video",NETWORK:"network",DATA:"data"},Qa="config ",Jg=(c,r={},n)=>{const o={...n,...r};return r.pname||Zl(Qa,`Argument [String] 'cfg.pname' for the peerConnection name or id is missing - use generated '${n.pname}'`),r.cid||Zl(Qa,`Argument [String] 'cfg.cid' for the call name or id is missing - use generated '${n.cid}'`),r.uid||Zl(Qa,`Argument [String] 'cfg.uid' for the user name or id is missing - use generated '${n.uid}'`),o.pc=c,o},Xg=(c={})=>{const r={...zg,...c};return r.name=Gg(),r.version=Kg(),r},jr=(c,r,n,o=!1,a)=>{let t=c.map(s=>{if(!n)return s[r];if(!a)return s[r][n];const p=s[r][a];return p?p[n]:null});return t=t.filter(s=>o?Number.isFinite(s)&&s>0:Number.isFinite(s)),t.length===0?[]:t},Cs=c=>c.reduce((r,n)=>r+n,0)/c.length,Qg=()=>`probe-${Hr()}`,Zg=()=>`coltr-${Hr()}`,Vf=c=>new Promise(r=>setTimeout(r,c)),Za=(c,r,n)=>{r?c.call(r,n):c(n)},je=(c,r,n,o)=>{const a=jr(c,r,n,!0,o);if(a.length===0)return null;const t=a.reduce((d,g)=>d+g,0)/a.length;return t===0?null:a.map(d=>Math.abs(t-d)).reduce((d,g)=>d+g,0)/a.length*100/t},We=(c,r,n,o=!1,a)=>{const t=jr(c,r,n,o,a);return t.length===0?null:t.reduce((s,p)=>s+p,0)/t.length},Ws=(c,r,n)=>jr(c,r,n).reduce((a,t)=>a+t,0),Ve=(c,r,n,o)=>{const a=jr(c,r,n,!0,o);return a.length===0?null:Math.min(...a)},Be=(c,r,n,o)=>{const a=jr(c,r,n,!1,o);return a.length===0?null:Math.max(...a)},mt=(c,r,n,o)=>{const a=c.slice().pop();if(!a)return null;if(!n)return a[r];if(!o)return a[r][n];const t=a[r][o];return t?t[n]:null},ev=c=>c.slice().pop(),lt=(c,r,n)=>{if(!r)return null;const o={};let a=r[k.AUDIO][c];a||(a=n===ke.INBOUND?{...Hf}:{...Ff}),o[k.AUDIO]=a;let t=r[k.VIDEO][c];return t||(t=n===ke.INBOUND?{...qf}:{...jf}),o[k.VIDEO]=t,o},Vr="exporter ",tv="2.0",Bf=(c,r,n)=>{if(!c||c.length===0)return 0;const o=c[c.length-1];if(!o)return 0;const a=o[r][n];if(a){const t=a.total_rtt_ms_out,s=a.total_rtt_measure_out;return!s||!t?We(c,r,"delta_rtt_ms_out",!1,n):Number(t/s)}return null},sv=(c,r)=>{if(!c||c.length===0)return 0;const n=c[c.length-1];if(!n)return 0;const o=n[r].total_rtt_connectivity_ms,a=n[r].total_rtt_connectivity_measure;return!a||!o?We(c,r,"delta_rtt_connectivity_ms"):Number(o/a)},nv=c=>mt(c,"network","local_candidate_type")!=="relay"?`direct/${mt(c,"network","local_candidate_protocol")}`:`turn/${mt(c,"network","local_candidate_relay_protocol")}`,rv=c=>{const r=mt(c,"network","remote_candidate_type"),n=mt(c,"network","remote_candidate_protocol");return r!=="relay"?`direct/${n}`:`turn/${n}`};class iv{constructor(r){this._start=null,this._end=null,this._cfg=r,this._referenceReport=null,this._reports=[],this._events=[]}start(){Ja(Vr,"start() - start exporter...");const r=new Date;return this._start=r.toJSON(),r}stop(){Ja(Vr,"stop() - stop exporter...");const r=new Date;return this._end=r.toJSON(),r}saveReferenceReport(r){this._referenceReport=r}getReferenceReport(){return this._referenceReport}addReport(r){this._cfg.ticket&&(Ne(Vr,`addReport() - add report to exporter at ${r.timestamp}`),this._reports.push(r))}addCustomEvent(r){this._events.push(r)}reset(){Ja(Vr,"resetReports() - reset reports"),this._reports=[],this._referenceReport=null,this._start=null,this._end=null}get ticket(){Ne(Vr,"ticket() - generate ticket");const r=mt(this._reports,"audio","total_packets_lost_in"),n=mt(this._reports,"audio","total_packets_in"),o=mt(this._reports,"video","total_packets_lost_in"),a=mt(this._reports,"video","total_packets_in"),t={},s=ev(this._reports);return s&&(Object.keys(s[k.AUDIO]).forEach(p=>{const _=s[k.AUDIO][p];if(t[_.ssrc]={type:k.AUDIO,direction:_.direction},_.direction===ke.INBOUND){const d={avg:We(this._reports,k.AUDIO,"delta_jitter_ms_in",!1,p),min:Ve(this._reports,k.AUDIO,"delta_jitter_ms_in",p),max:Be(this._reports,k.AUDIO,"delta_jitter_ms_in",p),volatility:je(this._reports,k.AUDIO,"delta_jitter_ms_in",p),_unit:{avg:"ms",min:"ms",max:"ms",volatility:"percent"}},g={avg:We(this._reports,k.AUDIO,"delta_kbs_in",!1,p),min:Ve(this._reports,k.AUDIO,"delta_kbs_in",p),max:Be(this._reports,k.AUDIO,"delta_kbs_in",p),volatility:je(this._reports,k.AUDIO,"delta_kbs_in",p),_unit:{avg:"kbs",min:"kbs",max:"kbs",volatility:"percent"}},v={avg:We(this._reports,k.AUDIO,"delta_KBytes_in",!1,p),min:Ve(this._reports,k.AUDIO,"delta_KBytes_in",p),max:Be(this._reports,k.AUDIO,"delta_KBytes_in",p),volatility:je(this._reports,k.AUDIO,"delta_KBytes_in",p),_unit:{avg:"KB",min:"KB",max:"KB",volatility:"percent"}},E={emodel:{avg:We(this._reports,k.AUDIO,"mos_emodel_in",!1,p),min:Ve(this._reports,k.AUDIO,"mos_emodel_in",p),max:Be(this._reports,k.AUDIO,"mos_emodel_in",p),volatility:je(this._reports,k.AUDIO,"mos_emodel_in",p)},effective:{avg:We(this._reports,k.AUDIO,"mos_in",!1,p),min:Ve(this._reports,k.AUDIO,"mos_in",p),max:Be(this._reports,k.AUDIO,"mos_in",p),volatility:je(this._reports,k.AUDIO,"mos_in",p)},_unit:{avg:"number (1-5)",min:"number (1-5)",max:"number (1-5)",volatility:"percent"}},S=mt(this._reports,k.AUDIO,"total_packets_lost_in",p),C=mt(this._reports,k.AUDIO,"total_packets_in",p),I={lost:S,avg:Math.round((S/(S+C)*100||0)*100)/100,_unit:{avg:"percent",lost:"number"}};t[p].jitter=d,t[p].mos=E,t[p].traffic=v,t[p].bitrate=g,t[p].loss=I}else{const d={avg:We(this._reports,k.AUDIO,"delta_jitter_ms_out",!1,p),min:Ve(this._reports,k.AUDIO,"delta_jitter_ms_out",p),max:Be(this._reports,k.AUDIO,"delta_jitter_ms_out",p),volatility:je(this._reports,k.AUDIO,"delta_jitter_ms_out",p),_unit:{avg:"ms",min:"ms",max:"ms",volatility:"percent"}},g={avg:We(this._reports,k.AUDIO,"delta_kbs_out",!1,p),min:Ve(this._reports,k.AUDIO,"delta_kbs_out",p),max:Be(this._reports,k.AUDIO,"delta_kbs_out",p),volatility:je(this._reports,k.AUDIO,"delta_kbs_out",p),_unit:{avg:"kbs",min:"kbs",max:"kbs",volatility:"percent"}},v={avg:We(this._reports,k.AUDIO,"delta_KBytes_out",!1,p),min:Ve(this._reports,k.AUDIO,"delta_KBytes_out",p),max:Be(this._reports,k.AUDIO,"delta_KBytes_out",p),volatility:je(this._reports,k.AUDIO,"delta_KBytes_out",p),_unit:{avg:"KB",min:"KB",max:"KB",bitrate:"kbs",volatility:"percent"}},E={avg:Bf(this._reports,k.AUDIO,p),min:Ve(this._reports,k.AUDIO,"delta_rtt_ms_out",p),max:Be(this._reports,k.AUDIO,"delta_rtt_ms_out",p),volatility:je(this._reports,k.AUDIO,"delta_rtt_ms_out",p),_unit:{avg:"ms",min:"ms",max:"ms",volatility:"percent"}},S=mt(this._reports,k.AUDIO,"total_packets_lost_out",p),C=mt(this._reports,k.AUDIO,"total_packets_out",p),I={lost:S,avg:Math.round((S/(S+C)*100||0)*100)/100,_unit:{avg:"percent",lost:"number"}},w={emodel:{avg:We(this._reports,k.AUDIO,"mos_emodel_out",!1,p),min:Ve(this._reports,k.AUDIO,"mos_emodel_out",p),max:Be(this._reports,k.AUDIO,"mos_emodel_out",p),volatility:je(this._reports,k.AUDIO,"mos_emodel_out",p)},effective:{avg:We(this._reports,k.AUDIO,"mos_out",!1,p),min:Ve(this._reports,k.AUDIO,"mos_out",p),max:Be(this._reports,k.AUDIO,"mos_out",p),volatility:je(this._reports,k.AUDIO,"mos_out",p)},_unit:{avg:"number (1-5)",min:"number (1-5)",max:"number (1-5)",volatility:"percent"}};t[p].jitter=d,t[p].rtt=E,t[p].traffic=v,t[p].bitrate=g,t[p].loss=I,t[p].mos=w}}),Object.keys(s[k.VIDEO]).forEach(p=>{const _=s[k.VIDEO][p];if(t[p]={type:k.VIDEO,direction:_.direction},_.direction===ke.INBOUND){const d={avg:We(this._reports,k.VIDEO,"delta_jitter_ms_in",!1,p),min:Ve(this._reports,k.VIDEO,"delta_jitter_ms_in",p),max:Be(this._reports,k.VIDEO,"delta_jitter_ms_in",p),volatility:je(this._reports,k.VIDEO,"delta_jitter_ms_in",p),_unit:{avg:"ms",min:"ms",max:"ms",volatility:"percent"}},g={avg:We(this._reports,k.VIDEO,"delta_kbs_in",!1,p),min:Ve(this._reports,k.VIDEO,"delta_kbs_in",p),max:Be(this._reports,k.VIDEO,"delta_kbs_in",p),volatility:je(this._reports,k.VIDEO,"delta_kbs_in",p),_unit:{avg:"kbs",min:"kbs",max:"kbs",volatility:"percent"}},v={avg:We(this._reports,k.VIDEO,"delta_KBytes_in",!1,p),min:Ve(this._reports,k.VIDEO,"delta_KBytes_in",p),max:Be(this._reports,k.VIDEO,"delta_KBytes_in",p),volatility:je(this._reports,k.VIDEO,"delta_KBytes_in",p),_unit:{avg:"KB",min:"KB",max:"KB",volatility:"percent"}},E=mt(this._reports,k.VIDEO,"total_packets_lost_in",p),S=mt(this._reports,k.VIDEO,"total_packets_in",p),C={lost:E,avg:Math.round((E/(E+S)*100||0)*100)/100,_unit:{avg:"percent",lost:"number"}};t[p].jitter=d,t[p].traffic=v,t[p].bitrate=g,t[p].loss=C}else{const d={avg:We(this._reports,k.VIDEO,"delta_jitter_ms_out",!1,p),min:Ve(this._reports,k.VIDEO,"delta_jitter_ms_out",p),max:Be(this._reports,k.VIDEO,"delta_jitter_ms_out",p),volatility:je(this._reports,k.VIDEO,"delta_jitter_ms_out",p),_unit:{avg:"ms",min:"ms",max:"ms",volatility:"percent"}},g={avg:We(this._reports,k.VIDEO,"delta_kbs_out",!1,p),min:Ve(this._reports,k.VIDEO,"delta_kbs_out",p),max:Be(this._reports,k.VIDEO,"delta_kbs_out",p),volatility:je(this._reports,k.VIDEO,"delta_kbs_out",p),_unit:{avg:"kbs",min:"kbs",max:"kbs",volatility:"percent"}},v={avg:We(this._reports,k.VIDEO,"delta_KBytes_out",!1,p),min:Ve(this._reports,k.VIDEO,"delta_KBytes_out",p),max:Be(this._reports,k.VIDEO,"delta_KBytes_out",p),volatility:je(this._reports,k.VIDEO,"delta_KBytes_out",p),_unit:{avg:"KB",min:"KB",max:"KB",volatility:"percent"}},E={avg:Bf(this._reports,k.VIDEO,p),min:Ve(this._reports,k.VIDEO,"delta_rtt_ms_out",p),max:Be(this._reports,k.VIDEO,"delta_rtt_ms_out",p),volatility:je(this._reports,k.VIDEO,"delta_rtt_ms_out",p),_unit:{avg:"ms",min:"ms",max:"ms",volatility:"percent"}},S=mt(this._reports,k.VIDEO,"total_packets_lost_out",p),C=mt(this._reports,k.VIDEO,"total_packets_out",p),I={lost:S,avg:Math.round((S/(S+C)*100||0)*100)/100,_unit:{avg:"percent",lost:"number"}};t[p].jitter=d,t[p].rtt=E,t[p].traffic=v,t[p].bitrate=g,t[p].loss=I}})),{version:tv,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:t,data:{rtt:{avg:sv(this._reports,"data"),min:Ve(this._reports,"data","delta_rtt_connectivity_ms"),max:Be(this._reports,"data","delta_rtt_connectivity_ms"),volatility:je(this._reports,"data","delta_rtt_connectivity_ms"),_unit:{avg:"ms",min:"ms",max:"ms",volatility:"percent"}},packetsLost:{audio:{in:{avg:Math.round((r/(r+n)*100||0)*100)/100}},video:{in:{avg:Math.round((o/(o+a)*100||0)*100)/100}},unit:{avg:"percent"}},bitrate:{in:{avg:We(this._reports,"data","delta_kbs_in"),min:Ve(this._reports,"data","delta_kbs_in"),max:Be(this._reports,"data","delta_kbs_in"),volatility:je(this._reports,"data","delta_kbs_in")},out:{avg:We(this._reports,"data","delta_kbs_out"),min:Ve(this._reports,"data","delta_kbs_out"),max:Be(this._reports,"data","delta_kbs_out"),volatility:je(this._reports,"data","delta_kbs_out")},unit:{avg:"kbs",min:"kbs",max:"kbs",volatility:"percent"}},traffic:{in:{avg:We(this._reports,"data","delta_KBytes_in"),min:Ve(this._reports,"data","delta_KBytes_in"),max:Be(this._reports,"data","delta_KBytes_in"),volatility:je(this._reports,"data","delta_KBytes_in")},out:{avg:We(this._reports,"data","delta_KBytes_out"),min:Ve(this._reports,"data","delta_KBytes_out"),max:Be(this._reports,"data","delta_KBytes_out"),volatility:je(this._reports,"data","delta_KBytes_out")},unit:{avg:"KBytes",min:"KBytes",max:"KBytes",volatility:"percent"}},network:{localConnection:nv(this._reports),remoteConnection:rv(this._reports)}}}}updateConfig(r){this._cfg=r}getLastReport(){return this._reports.slice().pop()||null}getBeforeLastReport(){const r=this._reports.slice();return r.pop(),r.pop()||null}getReportsNumber(){return this._reports.length}}const As="extractor ",Gf=(c,r,n,o)=>{let a=!1;const t=o[r].total_rtt_ms_out,s=o[r].total_rtt_measure_out,p=n?n[r].total_rtt_ms_out:0,_=n?n[r].total_rtt_measure_out:0,d={rtt:null,totalRTT:t,totalRTTMeasurements:s};if(c[q.TIMESTAMP]===o[r].timestamp_out||!Object.prototype.hasOwnProperty.call(c,q.ROUND_TRIP_TIME)||Object.prototype.hasOwnProperty.call(c,q.TOTAL_ROUND_TRIP_TIME_MEASUREMENTS)&&(a=!0,Number(c[q.TOTAL_ROUND_TRIP_TIME_MEASUREMENTS])===0||Number(c[q.TOTAL_ROUND_TRIP_TIME_MEASUREMENTS])-_===s))return d;const g=1e3*Number(c[q.ROUND_TRIP_TIME]);let v=t+g,E=s+1;return a&&(v=1e3*Number(c[q.TOTAL_ROUND_TRIP_TIME])-p,E=Number(c[q.TOTAL_ROUND_TRIP_TIME_MEASUREMENTS])-_),{rtt:g,totalRTT:v,totalRTTMeasurements:E}},lv=(c,r,n,o)=>{if(!Object.prototype.hasOwnProperty.call(c,q.CURRENT_ROUND_TRIP_TIME))return{rtt:null,totalRTT:o[r].total_rtt_connectivity_ms,totalRTTMeasurements:o[r].total_rtt_connectivity_measure};const a=1e3*Number(c[q.CURRENT_ROUND_TRIP_TIME]);let t=o[r].total_rtt_connectivity_ms+a,s=o[r].total_rtt_connectivity_measure+1;return Object.prototype.hasOwnProperty.call(c,q.TOTAL_ROUND_TRIP_TIME)&&(t=1e3*Number(c[q.TOTAL_ROUND_TRIP_TIME])-(n?n[r].total_rtt_connectivity_ms:0)),Object.prototype.hasOwnProperty.call(c,q.RESPONSES_RECEIVED)&&(s=Number(c[q.RESPONSES_RECEIVED])-(n?n[r].total_rtt_connectivity_measure:0)),{rtt:a,totalRTT:t,totalRTTMeasurements:s}},eo=(c,r,n)=>c[q.TIMESTAMP]===n[r].timestamp_out||!Object.prototype.hasOwnProperty.call(c,q.JITTER)?null:1e3*(Number(c[q.JITTER])||0),ov=(c,r)=>{if(!Object.prototype.hasOwnProperty.call(c,q.FRAMES_DECODED)||!Object.prototype.hasOwnProperty.call(c,q.TOTAL_DECODE_TIME))return{delta_ms_decode_frame:r[k.VIDEO].delta_ms_decode_frame_in,frames_decoded:r[k.VIDEO].total_frames_decoded_in,total_decode_time:r[k.VIDEO].total_time_decoded_in};const n=c[q.FRAMES_DECODED],o=c[q.TOTAL_DECODE_TIME],a=o-r[k.VIDEO].total_time_decoded_in,t=n-r[k.VIDEO].total_frames_decoded_in;return{delta_ms_decode_frame:t>0?a*1e3/t:0,frames_decoded:n,total_decode_time:o}},av=(c,r)=>{if(!Object.prototype.hasOwnProperty.call(c,q.FRAMES_ENCODED)||!Object.prototype.hasOwnProperty.call(c,q.TOTAL_ENCODE_TIME))return{delta_ms_encode_frame:r[k.VIDEO].delta_ms_encode_frame_out,frames_encoded:r[k.VIDEO].total_frames_encoded_out,total_encode_time:r[k.VIDEO].total_time_encoded_out};const n=c[q.FRAMES_ENCODED],o=c[q.TOTAL_ENCODE_TIME],a=o-r[k.VIDEO].total_time_encoded_out,t=n-r[k.VIDEO].total_frames_encoded_out;return{delta_ms_encode_frame:t>0&&a?a*1e3/t:0,frames_encoded:n,total_encode_time:o}},Kf=(c,r,n,o)=>{if(!Object.prototype.hasOwnProperty.call(c,q.PACKETS_SENT)||!Object.prototype.hasOwnProperty.call(c,q.BYTES_SENT))return{packetsSent:n[r].total_packets_out,packetsLost:n[r].total_packets_lost_out,bytesSent:n[r].total_KBytes_out};const a=Number(c[q.PACKETS_SENT])||0-(o?o[r].total_packets_out:0),t=a-n[r].total_packets_out,s=Number(c[q.BYTES_SENT])/1024-(o?o[r].total_KBytes_out:0),p=s-n[r].total_KBytes_out,_=c[q.TIMESTAMP]||Date.now(),d=o?o.timestamp:null;let g=n.timestamp;!g&&d&&(g=d);const v=g?_-g:0,E=v>0?p*.008*1024/v*1e3:0;return{packetsSent:a,deltaPacketsSent:t,KBytesSent:s,deltaKBytesSent:p,kbsSent:E}},Wf=(c,r,n,o)=>{let a=n[r].total_packets_lost_out,t=0,s=0;return Object.prototype.hasOwnProperty.call(c,q.PACKETS_LOST)&&(a=Number(c[q.PACKETS_LOST])||0-(o?o[r].total_packets_lost_out:0),t=a-n[r].total_packets_lost_out),Object.prototype.hasOwnProperty.call(c,q.FRACTION_LOST)&&(s=Number(100*c[q.FRACTION_LOST])),{packetsLost:a,deltaPacketsLost:t,fractionLost:s}},Yf=(c,r,n,o)=>{if(!Object.prototype.hasOwnProperty.call(c,q.PACKETS_RECEIVED)||!Object.prototype.hasOwnProperty.call(c,q.PACKETS_LOST)||!Object.prototype.hasOwnProperty.call(c,q.BYTES_RECEIVED))return{percent_packets_lost:n[r].percent_packets_lost_in,packetsReceived:n[r].total_packets_in,packetsLost:n[r].total_packets_lost_in,bytesReceived:n[r].total_KBytes_in};const a=Number(c[q.PACKETS_RECEIVED])||0-(o?o[r].total_packets_in:0),t=Number(c[q.PACKETS_LOST])||0-(o?o[r].total_packets_lost_in:0),s=t-n[r].total_packets_lost_in,p=a-n[r].total_packets_in,_=a!==n[r].total_packets_in?s*100/(s+p):0,d=Number(c[q.BYTES_RECEIVED])/1024-(o?o[r].total_KBytes_in:0),g=d-n[r].total_KBytes_in,v=c[q.TIMESTAMP]||Date.now(),E=o?o.timestamp:null;let S=n.timestamp;!S&&E&&(S=E);const C=S?v-S:0,I=C>0?g*.008*1024/C*1e3:0;return{percentPacketsLost:_,packetsReceived:a,deltaPacketsReceived:p,packetsLost:t,deltaPacketsLost:s,KBytesReceived:d,deltaKBytesReceived:g,kbsReceived:I}},uv=c=>c[q.CANDIDATE_TYPE]!=="relay"?"":c[q.RELAY_PROTOCOL]||"",cv=c=>{if(!Object.prototype.hasOwnProperty.call(c,q.NETWORK_TYPE))return qr.WIFI;switch(c[q.NETWORK_TYPE]){case Xa.ETHERNET:return qr.ETHERNET;case Xa.CELLULAR_4G:return qr.CELLULAR_4G;case Xa.WIFI:return qr.WIFI;default:return qr.CELLULAR}},zf=c=>!Object.prototype.hasOwnProperty.call(c,q.FRAME_HEIGHT)||!Object.prototype.hasOwnProperty.call(c,q.FRAME_WIDTH)?{width:null,height:null,framerate:null}:{width:c[q.FRAME_WIDTH]||null,height:c[q.FRAME_HEIGHT]||null,framerate:c[q.FRAMES_PER_SECOND]},fv=c=>{const r=Object.prototype.hasOwnProperty.call(c,q.QUALITY_LIMITATION_REASON)?c[q.QUALITY_LIMITATION_REASON]:null,n=Object.prototype.hasOwnProperty.call(c,q.QUALITY_LIMITATION_RESOLUTION_CHANGES)?c[q.QUALITY_LIMITATION_RESOLUTION_CHANGES]:null,o=Object.prototype.hasOwnProperty.call(c,q.QUALITY_LIMITATION_DURATIONS)?c[q.QUALITY_LIMITATION_DURATIONS]:null;return o&&Object.keys(o).forEach(a=>{o[a]>1e3&&(o[a]=Number(o[a]/1e3))}),{reason:r,durations:o,resolutionChanges:n}},_v=(c,r,n)=>{if(!Object.prototype.hasOwnProperty.call(c,q.PLI)||!Object.prototype.hasOwnProperty.call(c,q.NACK))return{pliCount:r.total_pli_sent_in,nackCount:r.total_nack_sent_in,deltaPliCount:0,deltaNackCount:0};const o=(c[q.PLI]||0)-(n?n[k.VIDEO].total_pli_sent_in:0),a=(c[q.NACK]||0)-(n?n[k.VIDEO].total_nack_sent_in:0);return{pliCount:o,nackCount:a,deltaPliCount:o-r[k.VIDEO].total_pli_sent_in,deltaNackCount:a-r[k.VIDEO].total_nack_sent_in}},hv=(c,r,n)=>{if(!Object.prototype.hasOwnProperty.call(c,q.PLI)||!Object.prototype.hasOwnProperty.call(c,q.NACK))return{pliCount:r.total_pli_received_out,nackCount:r.total_nack_received_out,deltaPliCount:0,deltaNackCount:0};const o=(c[q.PLI]||0)-(n?n[k.VIDEO].total_pli_received_out:0),a=(c[q.NACK]||0)-(n?n[k.VIDEO].total_nack_received_out:0);return{pliCount:o,nackCount:a,deltaPliCount:o-r[k.VIDEO].total_pli_received_out,deltaNackCount:a-r[k.VIDEO].total_nack_received_out}},dv=c=>({channels:c[q.CHANNELS]||null,clock_rate:c[q.CLOCK_RATE]||null,mime_type:c[q.MIME_TYPE]||null,sdp_fmtp_line:c[q.SDP_FMTP_LINE]||null}),pv=c=>({clock_rate:c[q.CLOCK_RATE]||null,mime_type:c[q.MIME_TYPE]||null}),mv=(c,r,n)=>{const o=(c[q.BYTES_RECEIVED]||0)/1024-(n?n.data.total_KBytes_in:0),a=(c[q.BYTES_SENT]||0)/1024-(n?n.data.total_KBytes_out:0),t=c[q.TIMESTAMP]||Date.now(),s=o-r.data.total_KBytes_in,p=a-r.data.total_KBytes_out,_=n?n.timestamp:null;let d=r.timestamp;!d&&_&&(d=_);const g=d?t-d:0,v=g>0?s*.008*1024/g*1e3:0,E=g>0?p*.008*1024/g*1e3:0;return{total_KBytes_received:o,total_KBytes_sent:a,delta_KBytes_received:s,delta_KBytes_sent:p,kbs_speed_received:v,kbs_speed_sent:E}},gv=c=>{const r=c[q.AVAILABLE_INCOMING_BITRATE]/1024||0,n=c[q.AVAILABLE_OUTGOING_BITRATE]/1024||0;return{kbs_incoming_bandwidth:r,kbs_outgoing_bandwidth:n}},vv=(c,r,n,o)=>{if(!c)return[];switch(c[q.TYPE]){case Ht.CANDIDATE_PAIR:let a=!1;if(c[q.NOMINATED]&&c[q.STATE]===k.SUCCEEDED&&(a=!0,Ne(As,`analyze() - got stats ${c[q.TYPE]} for ${n}`,c),q.SELECTED in c&&!c[q.SELECTED]&&(a=!1)),a){const s=c[q.LOCAL_CANDIDATE_ID],p=c[q.REMOTE_CANDIDATE_ID],_=mv(c,r,o),d=gv(c),g=lv(c,"data",o,r);return[{type:ee.NETWORK,value:{local_candidate_id:s}},{type:ee.NETWORK,value:{remote_candidate_id:p}},{type:ee.DATA,value:{total_KBytes_in:_.total_KBytes_received}},{type:ee.DATA,value:{total_KBytes_out:_.total_KBytes_sent}},{type:ee.DATA,value:{delta_KBytes_in:_.delta_KBytes_received}},{type:ee.DATA,value:{delta_KBytes_out:_.delta_KBytes_sent}},{type:ee.DATA,value:{delta_kbs_in:_.kbs_speed_received}},{type:ee.DATA,value:{delta_kbs_out:_.kbs_speed_sent}},{type:ee.DATA,value:{delta_kbs_bandwidth_in:d.kbs_incoming_bandwidth}},{type:ee.DATA,value:{delta_kbs_bandwidth_out:d.kbs_outgoing_bandwidth}},{type:ee.DATA,value:{delta_rtt_connectivity_ms:g.rtt}},{type:ee.DATA,value:{total_rtt_connectivity_ms:g.totalRTT}},{type:ee.DATA,value:{total_rtt_connectivity_measure:g.totalRTTMeasurements}}]}break;case Ht.LOCAL_CANDIDATE:if(c[q.ID]===r.network.local_candidate_id)return[{type:ee.NETWORK,value:{infrastructure:cv(c)}},{type:ee.NETWORK,value:{local_candidate_type:c[q.CANDIDATE_TYPE]||""}},{type:ee.NETWORK,value:{local_candidate_protocol:c[q.PROTOCOL]||""}},{type:ee.NETWORK,value:{local_candidate_relay_protocol:uv(c)}}];break;case Ht.REMOTE_CANDIDATE:if(c[q.ID]===r.network.remote_candidate_id)return[{type:ee.NETWORK,value:{remote_candidate_type:c[q.CANDIDATE_TYPE]||""}},{type:ee.NETWORK,value:{remote_candidate_protocol:c[q.PROTOCOL]||""}}];break;case Ht.INBOUND_RTP:{Ne(As,`analyze() - got stats ${c[q.TYPE]} for ${n}`,c);const s=c[q.SSRC],p=lt(s,r,ke.INBOUND);p&&(p.timestamp=r.timestamp);const _=lt(s,o,ke.INBOUND);if(_&&(_.timestamp=o.timestamp),c[q.MEDIA_TYPE]===k.AUDIO){const d=Yf(c,k.AUDIO,p,_),g=eo(c,k.AUDIO,p),v=c[q.CODEC_ID]||"";return[{ssrc:s,type:ee.AUDIO,value:{codec_id_in:v}},{ssrc:s,type:ee.AUDIO,value:{total_packets_in:d.packetsReceived}},{ssrc:s,type:ee.AUDIO,value:{delta_packets_in:d.deltaPacketsReceived}},{ssrc:s,type:ee.AUDIO,value:{total_packets_lost_in:d.packetsLost}},{ssrc:s,type:ee.AUDIO,value:{delta_packets_lost_in:d.deltaPacketsLost}},{ssrc:s,type:ee.AUDIO,value:{percent_packets_lost_in:d.percentPacketsLost}},{ssrc:s,type:ee.AUDIO,value:{total_KBytes_in:d.KBytesReceived}},{ssrc:s,type:ee.AUDIO,value:{delta_KBytes_in:d.deltaKBytesReceived}},{ssrc:s,type:ee.AUDIO,value:{delta_kbs_in:d.kbsReceived}},{ssrc:s,type:ee.AUDIO,value:{delta_jitter_ms_in:g}}]}if(c[q.MEDIA_TYPE]===k.VIDEO){const d=ov(c,p),g=Yf(c,k.VIDEO,p,_),v=eo(c,k.VIDEO,p),E=c[q.DECODER_IMPLEMENTATION]||null,S=c[q.CODEC_ID]||null,C=zf(c),I=_v(c,p,_);return[{ssrc:s,type:ee.VIDEO,value:{codec_id_in:S}},{ssrc:s,type:ee.VIDEO,value:{total_packets_in:g.packetsReceived}},{ssrc:s,type:ee.VIDEO,value:{delta_packets_in:g.deltaPacketsReceived}},{ssrc:s,type:ee.VIDEO,value:{total_packets_lost_in:g.packetsLost}},{ssrc:s,type:ee.VIDEO,value:{delta_packets_lost_in:g.deltaPacketsLost}},{ssrc:s,type:ee.VIDEO,value:{percent_packets_lost_in:g.percentPacketsLost}},{ssrc:s,type:ee.VIDEO,value:{total_KBytes_in:g.KBytesReceived}},{ssrc:s,type:ee.VIDEO,value:{delta_KBytes_in:g.deltaKBytesReceived}},{ssrc:s,type:ee.VIDEO,value:{delta_kbs_in:g.kbsReceived}},{ssrc:s,type:ee.VIDEO,value:{delta_jitter_ms_in:v}},{ssrc:s,type:ee.VIDEO,value:{decoder_in:E}},{ssrc:s,type:ee.VIDEO,value:{delta_ms_decode_frame_in:d.delta_ms_decode_frame}},{ssrc:s,type:ee.VIDEO,value:{total_frames_decoded_in:d.frames_decoded}},{ssrc:s,type:ee.VIDEO,value:{total_time_decoded_in:d.total_decode_time}},{ssrc:s,type:ee.VIDEO,value:{total_nack_sent_in:I.nackCount}},{ssrc:s,type:ee.VIDEO,value:{delta_nack_sent_in:I.deltaNackCount}},{ssrc:s,type:ee.VIDEO,value:{total_pli_sent_in:I.pliCount}},{ssrc:s,type:ee.VIDEO,value:{delta_pli_sent_in:I.deltaPliCount}},{ssrc:s,type:ee.VIDEO,value:{size_in:C}}]}break}case Ht.OUTBOUND_RTP:{Ne(As,`analyze() - got stats ${c[q.TYPE]} for ${n}`,c);const s=c[q.SSRC],p=lt(s,r,ke.OUTBOUND);p&&(p.timestamp=r.timestamp);const _=lt(s,o,ke.OUTBOUND);if(_&&(_.timestamp=o.timestamp),c[q.MEDIA_TYPE]===k.AUDIO){const d=c[q.CODEC_ID]||null,g=Kf(c,k.AUDIO,p,_);return[{ssrc:s,type:ee.AUDIO,value:{codec_id_out:d}},{ssrc:s,type:ee.AUDIO,value:{total_packets_out:g.packetsSent}},{ssrc:s,type:ee.AUDIO,value:{delta_packets_out:g.deltaPacketsSent}},{ssrc:s,type:ee.AUDIO,value:{total_KBytes_out:g.KBytesSent}},{ssrc:s,type:ee.AUDIO,value:{delta_KBytes_out:g.deltaKBytesSent}},{ssrc:s,type:ee.AUDIO,value:{delta_kbs_out:g.kbsSent}}]}if(c[q.MEDIA_TYPE]===k.VIDEO){const d=c[q.ENCODER_IMPLEMENTATION]||null,g=c[q.CODEC_ID]||null,v=av(c,p),E=zf(c),S=fv(c),C=hv(c,p,_),I=Kf(c,k.VIDEO,p,_);return[{ssrc:s,type:ee.VIDEO,value:{codec_id_out:g}},{ssrc:s,type:ee.VIDEO,value:{total_packets_out:I.packetsSent}},{ssrc:s,type:ee.VIDEO,value:{delta_packets_out:I.deltaPacketsSent}},{ssrc:s,type:ee.VIDEO,value:{total_KBytes_out:I.KBytesSent}},{ssrc:s,type:ee.VIDEO,value:{delta_KBytes_out:I.deltaKBytesSent}},{ssrc:s,type:ee.VIDEO,value:{delta_kbs_out:I.kbsSent}},{ssrc:s,type:ee.VIDEO,value:{encoder_out:d}},{ssrc:s,type:ee.VIDEO,value:{delta_ms_encode_frame_out:v.delta_ms_encode_frame}},{ssrc:s,type:ee.VIDEO,value:{total_frames_encoded_out:v.frames_encoded}},{ssrc:s,type:ee.VIDEO,value:{total_time_encoded_out:v.total_encode_time}},{ssrc:s,type:ee.VIDEO,value:{total_nack_received_out:C.nackCount}},{ssrc:s,type:ee.VIDEO,value:{delta_nack_received_out:C.deltaNackCount}},{ssrc:s,type:ee.VIDEO,value:{total_pli_received_out:C.pliCount}},{ssrc:s,type:ee.VIDEO,value:{delta_pli_received_out:C.deltaPliCount}},{ssrc:s,type:ee.VIDEO,value:{size_out:E}},{ssrc:s,type:ee.VIDEO,value:{limitation_out:S}}]}break}case Ht.MEDIA_SOURCE:{Ne(As,`analyze() - got stats ${c[q.TYPE]} for ${n}`,c);break}case Ht.TRACK:{Ne(As,`analyze() - got stats ${c[q.TYPE]} for ${n}`,c);break}case Ht.CODEC:const t=[];return Object.keys(r[k.AUDIO]).forEach(s=>{const p=r[k.AUDIO][s];if(p.codec_id_in===c[q.ID]||p.codec_id_out===c[q.ID]){Ne(As,`analyze() - got stats ${c[q.TYPE]} for ${n}`,c);const _=dv(c);c[q.ID]===p.codec_id_in?t.push({ssrc:p.ssrc,type:ee.AUDIO,value:{codec_in:_}}):t.push({ssrc:p.ssrc,type:ee.AUDIO,value:{codec_out:_}})}}),Object.keys(r[k.VIDEO]).forEach(s=>{const p=r[k.VIDEO][s];if(p.codec_id_in===c[q.ID]||p.codec_id_out===c[q.ID]){Ne(As,`analyze() - got stats ${c[q.TYPE]} for ${n}`,c);const _=pv(c);c[q.ID]===p.codec_id_in?t.push({ssrc:p.ssrc,type:ee.VIDEO,value:{codec_in:_}}):t.push({ssrc:p.ssrc,type:ee.VIDEO,value:{codec_out:_}})}}),t;case Ht.REMOTE_INBOUND_RTP:{Ne(As,`analyze() - got stats ${c[q.TYPE]} for ${n}`,c);const s=c[q.SSRC],p=lt(s,r,ke.OUTBOUND),_=lt(s,o,ke.OUTBOUND);if(c[q.KIND]===k.AUDIO){const d=Gf(c,k.AUDIO,_,p),g=eo(c,k.AUDIO,p),v=Wf(c,k.AUDIO,p,_);return[{ssrc:s,type:ee.AUDIO,value:{delta_rtt_ms_out:d.rtt}},{ssrc:s,type:ee.AUDIO,value:{total_rtt_ms_out:d.totalRTT}},{ssrc:s,type:ee.AUDIO,value:{total_rtt_measure_out:d.totalRTTMeasurements}},{ssrc:s,type:ee.AUDIO,value:{delta_jitter_ms_out:g}},{ssrc:s,type:ee.AUDIO,value:{timestamp_out:c[q.TIMESTAMP]}},{ssrc:s,type:ee.AUDIO,value:{total_packets_lost_out:v.packetsLost}},{ssrc:s,type:ee.AUDIO,value:{delta_packets_lost_out:v.deltaPacketsLost}},{ssrc:s,type:ee.AUDIO,value:{percent_packets_lost_out:v.fractionLost}}]}if(c[q.KIND]===k.VIDEO){const d=Gf(c,k.VIDEO,_,p),g=eo(c,k.VIDEO,p),v=Wf(c,k.VIDEO,p,_);return[{ssrc:s,type:ee.VIDEO,value:{delta_rtt_ms_out:d.rtt}},{ssrc:s,type:ee.VIDEO,value:{total_rtt_ms_out:d.totalRTT}},{ssrc:s,type:ee.VIDEO,value:{total_rtt_measure_out:d.totalRTTMeasurements}},{ssrc:s,type:ee.VIDEO,value:{delta_jitter_ms_out:g}},{ssrc:s,type:ee.VIDEO,value:{timestamp_out:c[q.TIMESTAMP]}},{ssrc:s,type:ee.VIDEO,value:{total_packets_lost_out:v.packetsLost}},{ssrc:s,type:ee.VIDEO,value:{delta_packets_lost_out:v.deltaPacketsLost}},{ssrc:s,type:ee.VIDEO,value:{percent_packets_lost_out:v.fractionLost}}]}break}}return[]},to=c=>c<0?1:c>100?4.5:1+.035*c+7/1e6*c*(c-60)*(100-c),Tv=(c,r=k.AUDIO,n,o,a)=>{const t=lt(a,c,ke.INBOUND),s=lt(a,n,ke.INBOUND),p=lt(a,o,ke.INBOUND),_=[],d=[],g=t[r].percent_packets_lost_in,v=t[r].delta_jitter_ms_in,E=s&&s[r].delta_jitter_ms_in||null,S=p&&p[r].delta_jitter_ms_in||null,C=c.data.delta_rtt_connectivity_ms,I=n&&n.data.delta_rtt_connectivity_ms||null,w=o&&o.data.delta_rtt_connectivity_ms||null;C&&_.push(C),I&&_.push(I),w&&_.push(w),v&&d.push(v),n&&E&&d.push(E),o&&S&&d.push(S);const F=_.length>0?Cs(_):100,L=d.length>0?Cs(d):10,ie=93.2-g,N=.18*ie*ie-27.9*ie+1126.62,H=(F+L)/2,ve=H-177.3<0?0:1,me=.024*H+.11*(H-177.3)*ve,M=N-me;return to(M)},Ev=(c,r=k.AUDIO,n,o,a)=>{const t=lt(a,c,ke.OUTBOUND),s=lt(a,n,ke.OUTBOUND),p=lt(a,o,ke.OUTBOUND),_=[],d=[],g=t[r].percent_packets_lost_out,v=t[r].delta_rtt_ms_out,E=s&&s[r].delta_rtt_ms_out||null,S=p&&p[r].delta_rtt_ms_out||null,C=t[r].delta_jitter_ms_out,I=s&&s[r].delta_jitter_ms_out||null,w=p&&p[r].delta_jitter_ms_out||null,F=c.data.delta_rtt_connectivity_ms,L=n&&n.data.delta_rtt_connectivity_ms||null,ie=o&&o.data.delta_rtt_connectivity_ms||null;v?_.push(v):F&&_.push(F),E?_.push(E):L&&_.push(L),S?_.push(S):ie&&_.push(ie),C&&d.push(C),n&&I&&d.push(I),o&&w&&d.push(w);const N=_.length>0?Cs(_):100,H=d.length>0?Cs(d):10,ve=93.2-g,me=.18*ve*ve-27.9*ve+1126.62,M=(N+H)/2,D=M-177.3<0?0:1,V=.024*M+.11*(M-177.3)*D,j=me-V;return to(j)},yv=(c,r=k.AUDIO,n,o,a)=>{const t=lt(a,c,ke.INBOUND),s=lt(a,n,ke.INBOUND),p=lt(a,o,ke.INBOUND),_=[],d=[],g=t[r].percent_packets_lost_in/100,v=t[r].delta_jitter_ms_in,E=s&&s[r].delta_jitter_ms_in||null,S=p&&p[r].delta_jitter_ms_in||null,C=c.data.delta_rtt_connectivity_ms,I=n&&n.data.delta_rtt_connectivity_ms||null,w=o&&o.data.delta_rtt_connectivity_ms||null;C&&_.push(C),I&&_.push(I),w&&_.push(w),v&&d.push(v),s&&E&&d.push(E),p&&S&&d.push(S);const F=_.length>0?Cs(_):100,L=d.length>0?Cs(d):10,ie=0,N=19.8,H=29.7,ve=30,me=(F+L)/2+ve,M=me-177.3<0?0:1,D=.024*me+.11*(me-177.3)*M,j=93.2-(ie+N*Math.log(1+H*g)+D);return to(j)},Sv=(c,r=k.AUDIO,n,o,a)=>{const t=lt(a,c,ke.OUTBOUND),s=lt(a,n,ke.OUTBOUND),p=lt(a,o,ke.OUTBOUND),_=[],d=[],g=t[r].percent_packets_lost_out/100,v=t[r].delta_rtt_ms_out,E=s&&s[r].delta_rtt_ms_out||null,S=p&&p[r].delta_rtt_ms_out||null,C=t[r].delta_jitter_ms_out,I=s&&s[r].delta_jitter_ms_out||null,w=p&&p[r].delta_jitter_ms_out||null,F=c.data.delta_rtt_connectivity_ms,L=n&&n.data.delta_rtt_connectivity_ms||null,ie=o&&o.data.delta_rtt_connectivity_ms||null;v?_.push(v):F&&_.push(F),E?_.push(E):L&&_.push(L),S?_.push(S):ie&&_.push(ie),C&&d.push(C),s&&I&&d.push(I),p&&w&&d.push(w);const N=_.length>0?Cs(_):100,H=d.length>0?Cs(d):10,ve=0,me=19.8,M=29.7,D=30,V=(N+H)/2+D,j=V-177.3<0?0:1,Y=.024*V+.11*(V-177.3)*j,X=93.2-(ve+me*Math.log(1+M*g)+Y);return to(X)};class Cv{constructor(r,n){this._callbacks={onreport:null,onticket:null},this._id=Zg(),this._moduleName=this._id,this._probeId=n,this._config=r,this._exporter=new iv(r),this._state=fs.IDLE,this.registerToPCEvents(),Ks(this._moduleName,`new collector created for probe ${this._probeId}`)}analyze(r,n,o,a){const t=(_,d)=>_===k.AUDIO?d===Ht.INBOUND_RTP?{...Hf}:{...Ff}:d===Ht.INBOUND_RTP?{...qf}:{...jf},s=Yg(n);s.pname=this._config.pname,s.call_id=this._config.cid,s.user_id=this._config.uid,s.count=n?n.count+1:1;let p=null;return r.forEach(_=>{!p&&_.timestamp&&(p=_.timestamp),vv(_,s,s.pname,a).forEach(g=>{if(g.value&&g.type)if(g.ssrc){let v=s[g.type][g.ssrc];v||(v=t(g.type,_.type),v.ssrc=g.ssrc,s[g.type][g.ssrc]=v),Object.keys(g.value).forEach(E=>{v[E]=g.value[E]})}else Object.keys(g.value).forEach(v=>{s[g.type][v]=g.value[v]})})}),s.timestamp=p,Object.keys(s[k.AUDIO]).forEach(_=>{const d=s[k.AUDIO][_];d.direction===ke.INBOUND?(d.mos_emodel_in=Tv(s,k.AUDIO,n,o,d.ssrc),d.mos_in=yv(s,k.AUDIO,n,o,d.ssrc)):(d.mos_emodel_out=Ev(s,k.AUDIO,n,o,d.ssrc),d.mos_out=Sv(s,k.AUDIO,n,o,d.ssrc))}),s}async takeReferenceStats(){return new Promise((r,n)=>{const o=Date.now();setTimeout(async()=>{try{const a=Date.now()-o,t=Date.now(),s=await this._config.pc.getStats(),p=this.analyze(s,null,null,null),_=Date.now();p.experimental.time_to_measure_ms=_-t,p.experimental.time_to_wait_ms=a,this._exporter.saveReferenceReport(p),Ne(this._moduleName,`got reference report for probe ${this._probeId}`),r()}catch(a){n(a)}},this._config.startAfter)})}async collectStats(){try{if(this._state!==fs.RUNNING||!this._config.pc)return Ne(this._moduleName,`report discarded (too late) for probe ${this._probeId}`),null;const r=Date.now(),n=await this._config.pc.getStats(),o=this.analyze(n,this._exporter.getLastReport(),this._exporter.getBeforeLastReport(),this._exporter.getReferenceReport()),a=Date.now();return o.experimental.time_to_measure_ms=a-r,this._exporter.addReport(o),Ne(this._moduleName,`got report for probe ${this._probeId}#${this._exporter.getReportsNumber()+1}`),this.fireOnReport(o),o}catch(r){return bn(this._moduleName,`got error ${r}`),null}}async start(){Ne(this._moduleName,"starting"),this.state=fs.RUNNING,this._startedTime=this._exporter.start(),Ne(this._moduleName,"started")}async mute(){this.state=fs.MUTED,Ne(this._moduleName,"muted")}async unmute(){this.state=fs.RUNNING,Ne(this._moduleName,"unmuted")}async stop(r){if(Ne(this._moduleName,`stopping${r?" by watchdog":""}...`),this._stoppedTime=this._exporter.stop(),this.state=fs.IDLE,this._config.ticket){const{ticket:n}=this._exporter;this.fireOnTicket(n)}this._exporter.reset(),Ne(this._moduleName,"stopped")}registerCallback(r,n,o){r in this._callbacks?(this._callbacks[r]={callback:n,context:o},Ne(this._moduleName,`registered callback '${r}'`)):bn(this._moduleName,`can't register callback for '${r}' - not found`)}unregisterCallback(r){r in this._callbacks?(this._callbacks[r]=null,delete this._callbacks[r],Ne(this._moduleName,`unregistered callback '${r}'`)):bn(this._moduleName,`can't unregister callback for '${r}' - not found`)}fireOnReport(r){this._callbacks.onreport&&Za(this._callbacks.onreport.callback,this._callbacks.onreport.context,r)}fireOnTicket(r){this._callbacks.onticket&&Za(this._callbacks.onticket.callback,this._callbacks.onticket.context,r)}updateConfig(r){this._config=r,this._exporter.updateConfig(r)}get state(){return this._state}set state(r){this._state=r,Ne(this._moduleName,`state changed to ${r}`)}addCustomEvent(r,n,o,a){this._exporter.addCustomEvent({at:typeof r=="object"?r.toJSON():r,category:n,name:o,description:a})}async registerToPCEvents(){const{pc:r}=this._config;if(navigator.mediaDevices.ondevicechange=async()=>{try{const n=await navigator.mediaDevices.enumerateDevices();this.addCustomEvent(new Date().toJSON(),"device",`${n.length} devices found`,"Media Devices state")}catch{bn(this._moduleName,"can't get devices")}},r){r.oniceconnectionstatechange=()=>{const o=r.iceConnectionState;o===Fr.CONNECTED||o===Fr.COMPLETED?this.addCustomEvent(new Date().toJSON(),"call",o,"ICE connection state"):o===Fr.DISCONNECTED||o===Fr.FAILED?this.addCustomEvent(new Date().toJSON(),"call",o,"ICE connection state"):o===Fr.CLOSED&&this.addCustomEvent(new Date().toJSON(),"call","ended","ICE connection state")},r.onicegatheringstatechange=()=>{const o=r.iceGatheringState;this.addCustomEvent(new Date().toJSON(),"call",o,"ICE gathering state")},r.ontrack=o=>{this.addCustomEvent(new Date().toJSON(),"call",`${o.track.kind}track`,"MediaStreamTrack received")},r.onnegotiationneeded=()=>{this.addCustomEvent(new Date().toJSON(),"call","negotiation","Media changed")};const n=r.getReceivers();if(n&&n.length>0){const o=n[0],{transport:a}=o;if(a){const{iceTransport:t}=a;t&&(t.onselectedcandidatepairchange=()=>{this.addCustomEvent(new Date().toJSON(),"call","transport","Candidates Pair changed")})}}}}}class Av{constructor(r){this._id=r.pname&&r.pname.substr(0,12).padEnd(12," ")||Qg(),this._moduleName=this._id,Ks(this._moduleName,"probe created"),this._config=r,this._collector=new Cv(this._config,this._id)}set onreport(r){r?this._collector.registerCallback("onreport",r):this._collector.unregisterCallback("onreport")}set onticket(r){r?this._collector.registerCallback("onticket",r):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(r){this._collector.state=r}addCustomEvent(r,n,o,a=new Date().toJSON()){this._collector.addCustomEvent(a,n,r,o)}get isRunning(){return this._collector.state===fs.RUNNING}get isIdle(){return this._collector.state===fs.IDLE}updateUserId(r){this._config.uid=r,this._collector.updateConfig(this._config)}updateCallId(r){this._config.cid=r,this._collector.updateConfig(this._config)}start(){if(!this.isIdle){Zl(this._moduleName,"probe is already running");return}this._collector.start()}stop(r=!1){this.isRunning&&this._collector.stop(r)}async takeReferenceStats(){return this._collector.takeReferenceStats()}async collectStats(){return this._collector.collectStats()}}const Et="engine ";class Rv{constructor(r){this._config=r,this._probes=[],this._startedTime=null,this._callbacks={onresult:null},Ks(Et,`configured for probing every ${this._config.refreshEvery}ms`),Ks(Et,`configured for starting after ${this._config.startAfter}ms`),Ks(Et,`${!this._config.stopAfter||this._config.stopAfter!==-1?`configured for stopped after ${this._config.stopAfter}ms`:"configured for never stopped"}`),Ne(Et,"engine initialized")}get probes(){return this._probes}get isRunning(){return this._probes.some(r=>r.isRunning)}get isIdle(){return this._probes.every(r=>r.isIdle)}addNewProbe(r,n){if(!r)throw new Error("undefined peer connection");const o=Jg(r,n,this._config),a=new Av(o);return this._probes.push(a),Ne(Et,`${this._probes.length} probes registered`),a}removeExistingProbe(r){if(!r)throw new Error("undefined probe");r.state===fs.RUNNING&&r.stop(),this._probes=this._probes.filter(n=>r.id!==n.id)}async start(){const r=()=>{this._probes.forEach(t=>t.start())},n=async()=>Promise.all(this._probes.map(t=>t.takeReferenceStats())),o=()=>this.isIdle?!1:!this._config.stopAfter||this._config.stopAfter<0?!0:Date.now()<this._startedTime+this._config.stopAfter,a=async()=>{const t=Wg(),s=this._probes.filter(p=>p.isRunning);for(const p of s){const _=await p.collectStats();_&&t.probes.push(_),Ne(Et,`got probe ${p.id}`),await Vf(0)}return t.delta_time_to_measure_probes_ms=Ws(t.probes,"experimental","time_to_measure_ms"),t.delta_KBytes_in=Ws(t.probes,"data","delta_KBytes_in"),t.delta_KBytes_out=Ws(t.probes,"data","delta_KBytes_out"),t.delta_kbs_in=Ws(t.probes,"data","delta_kbs_in"),t.delta_kbs_out=Ws(t.probes,"data","delta_kbs_out"),t.total_time_decoded_in=Ws(t.probes,"video","total_time_decoded_in"),t.total_time_encoded_out=Ws(t.probes,"video","total_time_encoded_out"),t};for(Ne(Et,"starting to collect"),r(),Ne(Et,"generating reference reports..."),await n(),Ne(Et,"reference reports generated"),this._startedTime=Date.now();o();)if(Ne(Et,`wait ${this._config.refreshEvery}ms before collecting`),await Vf(this._config.refreshEvery),o()){Ne(Et,"collecting...");const t=Date.now(),s=await a(),p=Date.now();s.delta_time_consumed_to_measure_ms=p-t,this.fireOnReports(s),Ne(Et,"collected")}Ne(Et,"reaching end of the collecting period..."),this.isRunning&&setTimeout(()=>{this.stop()},0)}stop(r){const n=o=>{this._probes.forEach(a=>{a.stop(o)})};Ks(Et,"stop collecting"),n(r)}registerCallback(r,n,o){r in this._callbacks?(this._callbacks[r]={callback:n,context:o},Ne(Et,`registered callback '${r}'`)):bn(Et,`can't register callback for '${r}' - not found`)}unregisterCallback(r){r in this._callbacks?(this._callbacks[r]=null,delete this._callbacks[r],Ne(this._moduleName,`unregistered callback '${r}'`)):bn(this._moduleName,`can't unregister callback for '${r}' - not found`)}fireOnReports(r){this._callbacks.onresult&&r.probes.length>0&&Za(this._callbacks.onresult.callback,this._callbacks.onresult.context,r)}}const Iv="interface ";class bv{constructor(r){this._config=Xg(r),Ks(Iv,`welcome to ${this._config.name} version ${this._config.version}`),Hg(this._config.verbose||!1),this._engine=new Rv(this._config)}setupLogLevel(r){Fg(r)}get version(){return this._config.version}get name(){return this._config.name}get probes(){return this._engine.probes}createProbe(r,n){return this._engine.addNewProbe(r,n)}startAllProbes(){this._engine.start()}stopAllProbes(){this._engine.stop()}get running(){return this._engine.isRunning}get idle(){return this._engine.isIdle}removeProbe(r){this._engine.removeExistingProbe(r)}set onresult(r){r?this._engine.registerCallback("onresult",r):this._engine.unregisterCallback("onresult")}}const wv=it,Ov=Gt(),St=new wv("WebSocketInterface");var Dv=class{constructor(r){St.debug('new() [url:"%s"]',r),this._url=r,this._sip_uri=null,this._via_transport=null,this._ws=null;const n=Ov.parse(r,"absoluteURI");if(n===-1)throw St.warn(`invalid WebSocket URI: ${r}`),new TypeError(`Invalid argument: ${r}`);if(n.scheme!=="wss"&&n.scheme!=="ws")throw St.warn(`invalid WebSocket URI scheme: ${n.scheme}`),new TypeError(`Invalid argument: ${r}`);this._sip_uri=`sip:${n.host}${n.port?`:${n.port}`:""};transport=ws`,this._via_transport=n.scheme.toUpperCase()}get via_transport(){return this._via_transport}set via_transport(r){this._via_transport=r.toUpperCase()}get sip_uri(){return this._sip_uri}get url(){return this._url}connect(){if(St.debug("connect()"),this.isConnected()){St.debug(`WebSocket ${this._url} is already connected`);return}else if(this.isConnecting()){St.debug(`WebSocket ${this._url} is connecting`);return}this._ws&&this.disconnect(),St.debug(`connecting to WebSocket ${this._url}`);try{this._ws=new WebSocket(this._url,"sip"),this._ws.binaryType="arraybuffer",this._ws.onopen=this._onOpen.bind(this),this._ws.onclose=this._onClose.bind(this),this._ws.onmessage=this._onMessage.bind(this),this._ws.onerror=this._onError.bind(this)}catch(r){this._onError(r)}}disconnect(){St.debug("disconnect()"),this._ws&&(this._ws.onopen=()=>{},this._ws.onclose=()=>{},this._ws.onmessage=()=>{},this._ws.onerror=()=>{},this._ws.close(),this._ws=null)}send(r){return St.debug("send()"),this.isConnected()?(this._ws.send(r),!0):(St.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(){St.debug(`WebSocket ${this._url} connected`),this.onconnect()}_onClose({wasClean:r,code:n,reason:o}){St.debug(`WebSocket ${this._url} closed`),r===!1&&St.debug("WebSocket abrupt disconnection"),this.ondisconnect(!r,n,o)}_onMessage({data:r}){St.debug("received WebSocket message"),this.ondata(r)}_onError(r){St.warn(`WebSocket ${this._url} error: `,r)}};const eu=el,Nv=we,Uv=as,Pv=ft(),kv=Nf,Mv=is(),xv=Ta(),Lv=Gt(),$v=Dv;gn("JsSIP")("version %s",eu.version);var Hv={C:Nv,Exceptions:Uv,Utils:Pv,UA:kv,URI:Mv,NameAddrHeader:xv,WebSocketInterface:$v,Grammar:Lv,debug:gn,get name(){return eu.title},get version(){return eu.version}};const Fv=qt(Hv),qv=["mos_in","codec_in","delta_KBytes_in","delta_kbs_in","delta_jitter_ms_in","delta_packets_lost_in"],Jt={NEW_CALL:"new_call",CALL_CONFIRMED:"confirmed",CALL_FAILED:"failed",CALL_PROGRESS:"progress",CALL_ENDED:"ended"},jv=0,so={SELECTED_INPUT_DEVICE:"selectedInputDevice",SELECTED_OUTPUT_DEVICE:"selectedOutputDevice"};class Vv extends Dg{constructor(r,n){const o={...r.configuration,sockets:r.socketInterfaces.map(a=>new Fv.WebSocketInterface(a))};super(o),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.muted=!1,this.isAutoAnswer=!1,this.isDNDEnabled=!1,this.muteWhenJoinEnabled=!1,this.activeRooms={},this.activeCalls={},this.extendedCalls={},this.activeMessages={},this.extendedMessages={},this.msrpHistory={},this.microphoneInputLevelValue=2,this.speakerVolumeValue=1,this.availableMediaDevices=[],this.selectedMediaDevices={input:"default",output:"default"},this.callStatus={},this.callTime={},this.callMetrics={},this.timeIntervals={},this.metricConfig={refreshEvery:1e3},this.originalStreamValue=null,this.isReconnecting=!1,this.listenersList={},this.options=r,n&&Lg(n)&&(this.logger=n)}on(r,n){return super.on(r,n)}off(r,n){return super.off(r,n)}emit(r,n){return super.emit(r,n)}get sipDomain(){return this.options.sipDomain}get sipOptions(){return{...this.options.sipOptions,mediaConstraints:this.getUserMediaConstraints}}get currentActiveRoomId(){return this.currentActiveRoomIdValue}set currentActiveRoomId(r){this.currentActiveRoomIdValue=r,this.emit("currentActiveRoomChanged",r)}get autoAnswer(){return this.isAutoAnswer}get callAddingInProgress(){return this.isCallAddingInProgress}set callAddingInProgress(r){this.isCallAddingInProgress=r,this.emit("callAddingInProgressChanged",r)}get isMSRPInitializing(){return this.isMSRPInitializingValue}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 getActiveMessages(){return this.activeMessages}get getActiveRooms(){return this.activeRooms}get isMuted(){return this.muted}get getInputDeviceList(){return this.availableMediaDevices.filter(r=>r.kind==="audioinput")}get getOutputDeviceList(){return this.availableMediaDevices.filter(r=>r.kind==="audiooutput")}get getUserMediaConstraints(){return{audio:{deviceId:{exact:this.selectedMediaDevices.input}},video:!1}}get getInputDefaultDevice(){return this.getInputDeviceList.find(r=>r.deviceId==="default")}get getOutputDefaultDevice(){return this.getOutputDeviceList.find(r=>r.deviceId==="default")}get selectedInputDevice(){return this.selectedMediaDevices.input}get selectedOutputDevice(){return this.selectedMediaDevices.output}get originalStream(){return this.originalStreamValue}setAvailableMediaDevices(r){this.availableMediaDevices=r,this.emit("changeAvailableDeviceList",r)}async updateDeviceList(){await navigator.mediaDevices.getUserMedia(this.getUserMediaConstraints);const r=await navigator.mediaDevices.enumerateDevices();this.setAvailableMediaDevices(r)}async setMediaDevices(r=!1){var t,s;this.selectedMediaDevices.input=localStorage.getItem(so.SELECTED_INPUT_DEVICE)||"default",this.selectedMediaDevices.output=localStorage.getItem(so.SELECTED_OUTPUT_DEVICE)||"default",await navigator.mediaDevices.getUserMedia(this.getUserMediaConstraints);const n=await navigator.mediaDevices.enumerateDevices();this.setAvailableMediaDevices(n);const o=r&&((t=this.getInputDefaultDevice)==null?void 0:t.deviceId)||"",a=r&&((s=this.getOutputDefaultDevice)==null?void 0:s.deviceId)||"";await this.setMicrophone(o),await this.setSpeaker(a)}setCallTime(r){const n={...r};delete n.callId,this.callTime={...this.callTime,[r.callId]:n},this.emit("changeCallTime",this.callTime)}removeCallTime(r){const n={...this.callTime};delete n[r],this.callTime={...n},this.emit("changeCallTime",this.callTime)}setTimeInterval(r,n){this.timeIntervals={...this.timeIntervals,[r]:n}}removeTimeInterval(r){const n={...this.timeIntervals};clearInterval(n[r]),delete n[r],this.timeIntervals={...n}}stopCallTimer(r){this.removeTimeInterval(r),this.removeCallTime(r)}setMetricsConfig(r){this.metricConfig={...this.metricConfig,...r}}sendDTMF(r,n){if(!/^[A-D0-9]+$/g.test(n))throw new Error("Not allowed character in DTMF input");this.extendedCalls[r].sendDTMF(n)}setIsMuted(r){this.muted=r,this.emit("changeIsMuted",r)}doMute(r){const n=this.currentActiveRoomId;this.setIsMuted(r),this.roomReconfigure(n)}doCallHold({callId:r,toHold:n,automatic:o}){const a=this.extendedCalls[r];a._automaticHold=o??!1,n?a.hold():a.unhold()}cancelAllOutgoingUnanswered(){Object.values(this.getActiveCalls).filter(r=>r.direction==="outgoing"&&r.status===jv).forEach(r=>this.callTerminate(r._id))}callAnswer(r){const n=this.extendedCalls[r];this.cancelAllOutgoingUnanswered(),n.answer(this.sipOptions),this.updateCall(n),this.setCurrentActiveRoomId(n.roomId),n.connection.addEventListener("addstream",async o=>{this.triggerAddStream(o,n)})}msrpAnswer(r){const n=this.extendedMessages[r];n.answer(this.sipOptions),this.updateMSRPSession(n)}async callMove(r,n){this.updateCallStatus({callId:r,isMoving:!0}),await this.callChangeRoom({callId:r,roomId:n}),this.updateCallStatus({callId:r,isMoving:!1})}updateCall(r){this.activeCalls[r._id]=Mf(r),this.emit("changeActiveCalls",this.activeCalls)}updateMSRPSession(r){this.activeMessages[r._id]=xf(r),this.emit("changeActiveMessages",this.activeMessages)}updateRoom(r){const o={...this.activeRooms[r.roomId],...r};this.activeRooms={...this.activeRooms,[r.roomId]:{...o}},this.emit("updateRoom",{room:o,roomList:this.activeRooms})}hasAutoAnswerHeaders(r){const n=/answer-after=0/,a=r.request.getHeader("Call-Info");return a&&n.test(a)}_addCall(r,n=!0){this.activeCalls={...this.activeCalls,[r._id]:Mf(r)},this.extendedCalls[r._id]=r,n&&this.emit("changeActiveCalls",this.activeCalls)}addCallStatus(r){this.callStatus={...this.callStatus,[r]:{isMoving:!1,isTransferring:!1,isMerging:!1}},this.emit("changeCallStatus",this.callStatus)}addMMSRPSession(r){this.activeMessages={...this.activeMessages,[r._id]:xf(r)},this.extendedMessages[r._id]=r,this.emit("changeActiveMessages",this.activeMessages)}addMSRPMessage(r,n){const o=this.msrpHistory[n.id]||[];o.push(r),this.msrpHistory={...this.msrpHistory,[n.id]:[...o]},this.emit("newMSRPMessage",{message:r,session:n})}updateCallStatus(r){const o={...{...this.callStatus[r.callId]}};r.isMoving!==void 0&&(o.isMoving=r.isMoving),r.isTransferring!==void 0&&(o.isTransferring=r.isTransferring),r.isMerging!==void 0&&(o.isMerging=r.isMerging),this.callStatus={...this.callStatus,[r.callId]:{...o}},this.emit("changeCallStatus",this.callStatus)}removeCallStatus(r){const n={...this.callStatus};delete n[r],this.callStatus={...n},this.emit("changeCallStatus",this.callStatus)}addRoom(r){this.activeRooms={...this.activeRooms,[r.roomId]:r},this.emit("addRoom",{room:r,roomList:this.activeRooms})}async setMicrophone(r){if(!this.getInputDeviceList.find(({deviceId:a})=>a===r))return;this.setSelectedInputDevice(r);let n;try{n=await navigator.mediaDevices.getUserMedia(this.getUserMediaConstraints)}catch(a){console.error(a)}if(Object.keys(this.getActiveCalls).length===0)return;const o=Object.values(this.extendedCalls).filter(a=>a.roomId===this.currentActiveRoomId);o.length===1?Object.values(o).forEach(a=>{const t=Ql(n,this.microphoneInputLevel);t.getTracks().forEach(s=>s.enabled=!this.isMuted),this.setOriginalStream(t),a.connection.getSenders()[0].replaceTrack(t.getTracks()[0]),this.updateCall(a)}):await this.doConference(o)}setOriginalStream(r){this.originalStreamValue=r,this.emit("changeOriginalStream",r)}async setSpeaker(r){if(!this.getOutputDeviceList.find(({deviceId:a})=>a===r))return;this.setSelectedOutputDevice(r);const n=Object.values(this.extendedCalls);if(n.length===0)return;const o=n.filter(a=>a.roomId===this.currentActiveRoomId);o.length===1?n.forEach(a=>{var t;(t=a.audioTag)==null||t.setSinkId(r),this.updateCall(a)}):await this.doConference(o)}removeRoom(r){const n={...this.activeRooms},o={...n[r]};delete n[r],this.activeRooms={...n},this.emit("removeRoom",{room:o,roomList:this.activeRooms})}deleteRoomIfEmpty(r){r!==void 0&&Object.values(this.extendedCalls).filter(n=>n.roomId===r).length===0&&(this.removeRoom(r),this.currentActiveRoomId===r&&(this.currentActiveRoomId=void 0))}checkInitialized(){if(!this.initialized)throw new Error("[OpenSIPSJS] You must call `start` method first!")}muteReconfigure(r){this.muted?r.mute({audio:!0}):r.unmute({audio:!0})}async roomReconfigure(r){if(r===void 0)return;const n=Object.values(this.extendedCalls).filter(o=>o.roomId===r);if(this.currentActiveRoomId===r?n.forEach(o=>{o.audioTag&&(this.muteReconfigure(o),o.audioTag.muted=!1,this.updateCall(o))}):n.forEach(o=>{o.audioTag&&(o.audioTag.muted=!0,this.updateCall(o))}),n.length===0)this.deleteRoomIfEmpty(r);else if(n.length===1&&this.currentActiveRoomId!==r)n[0].isOnHold().local||this.doCallHold({callId:n[0].id,toHold:!0,automatic:!0});else if(n.length===1&&this.currentActiveRoomId===r){n[0].isOnHold().local&&n[0]._automaticHold&&this.doCallHold({callId:n[0].id,toHold:!1});let o;try{o=await navigator.mediaDevices.getUserMedia(this.getUserMediaConstraints)}catch(a){console.error(a)}if(o&&n[0].connection&&n[0].connection.getSenders()[0]){const a=Ql(o,this.microphoneInputLevel);a.getTracks().forEach(t=>t.enabled=!this.muted),this.setOriginalStream(a),await n[0].connection.getSenders()[0].replaceTrack(a.getTracks()[0]),this.muteReconfigure(n[0])}}else n.length>1&&await this.doConference(n)}async doConference(r){r.forEach(t=>{t._localHold&&this.doCallHold({callId:t._id,toHold:!1})});const n=[];r.forEach(t=>{t!=null&&t.connection.getReceivers().forEach(s=>{n.push(s.track)})});const o=new AudioContext,a=new MediaStream;await Ng.forEach(r,async t=>{if(t==null)return;const s=o.createMediaStreamDestination();if(t.connection.getReceivers().forEach(p=>{n.forEach(_=>{a.addTrack(p.track),p.track.id!==_.id&&o.createMediaStreamSource(new MediaStream([_])).connect(s)})}),r[0].roomId===this.currentActiveRoomId){const p=await navigator.mediaDevices.getUserMedia(this.getUserMediaConstraints),_=Ql(p,this.microphoneInputLevel);_.getTracks().forEach(g=>g.enabled=!this.isMuted),this.setOriginalStream(_),o.createMediaStreamSource(_).connect(s)}t.connection.getSenders()[0]&&(await t.connection.getSenders()[0].replaceTrack(s.stream.getTracks()[0]),this.muteReconfigure(t))})}muteCaller(r,n){const o=this.extendedCalls[r];o&&o.connection.getReceivers().length&&(o.localMuted=n,o.connection.getReceivers().forEach(a=>{a.track.enabled=!n}),this.updateCall(o),this.roomReconfigure(o.roomId))}callTerminate(r){const n=this.extendedCalls[r];n._status!==8&&n.terminate()}messageTerminate(r){const n=this.extendedMessages[r];n._status!==8&&n.terminate()}callTransfer(r,n){if(n.toString().length===0)return console.error("Target must be passed");const o=this.extendedCalls[r];if(!o._is_confirmed&&!o._is_canceled){const a=`sip:${n}@${this.sipDomain}`;o.terminate({status_code:302,reason_phrase:"Moved Temporarily",extraHeaders:[`Contact: ${a}`]});return}this.updateCallStatus({callId:r,isTransferring:!0}),o.refer(`sip:${n}@${this.sipDomain}`),this.updateCall(o)}callMerge(r){const n=Object.values(this.extendedCalls).filter(t=>t.roomId===r);if(n.length!==2)return;const o=n[0],a=n[1];!o||!a||(this.updateCallStatus({callId:o._id,isMerging:!0}),this.updateCallStatus({callId:a._id,isMerging:!0}),o.refer(a.remote_identity.uri.toString(),{replaces:a}),this.updateCall(o))}setDND(r){this.isDNDEnabled=r,this.emit("changeIsDND",r)}startCallTimer(r){const n={callId:r,hours:0,minutes:0,seconds:0,formatted:""};this.setCallTime(n);const o=setInterval(()=>{const a={...this.callTime[r]},t=Ug(a);this.setCallTime({callId:r,...t})},1e3);this.setTimeInterval(r,o)}async setCurrentActiveRoomId(r){const n=this.currentActiveRoomId;r!==n&&(this.currentActiveRoomId=r,await this.roomReconfigure(n),await this.roomReconfigure(r))}getNewRoomId(){const r=Object.keys(this.activeRooms);return r.length===0?1:parseInt(r.sort()[r.length-1])+1}subscribe(r,n){const a=!this.listenersList[r]||!this.listenersList[r].length?[n]:[...this.listenersList[r],n];this.listenersList={...this.listenersList,[r]:a}}removeIListener(r){const n={...this.listenersList};delete n[r],this.listenersList={...n}}async addCall(r){var d,g;const n=r.session;if(this.getActiveCalls[n.id]!==void 0)return;const a=this.getNewRoomId(),t={started:new Date,incomingInProgress:!1,roomId:a};n.direction==="incoming"?(this.logger.log("New incoming call from",(g=(d=n._remote_identity)==null?void 0:d._uri)==null?void 0:g._user),t.incomingInProgress=!0,this.subscribe(Jt.CALL_CONFIRMED,v=>{n.id===v.id&&(this.updateRoom({incomingInProgress:!1,roomId:a}),this.startCallTimer(n.id))}),this.subscribe(Jt.CALL_FAILED,v=>{n.id===v.id&&(this.updateRoom({incomingInProgress:!1,roomId:a}),this.deleteRoomIfEmpty(a))})):n.direction==="outgoing"&&this.startCallTimer(n.id);const s=n,p=this.hasAutoAnswerHeaders(r),_=s.direction==="incoming"&&!this.hasActiveCalls&&(p||this.autoAnswer);s.roomId=a,s.localMuted=!1,s.autoAnswer=_,_?this._addCall(s,!1):this._addCall(s),this.addCallStatus(n.id),this.addRoom(t),_&&this.callAnswer(s._id)}addMessageSession(r){if(!r._id||this.getActiveMessages[r._id]!==void 0)return;const o=r;this.addMMSRPSession(o)}triggerListener({listenerType:r,session:n,event:o}){const a=this.listenersList[r];!a||!a.length||a.forEach(t=>{t(n,o)})}triggerMSRPListener({listenerType:r,session:n,event:o}){const a=this.listenersList[r];!a||!a.length||a.forEach(t=>{t(n,o)})}removeCall(r){const n={...this.activeCalls};delete n[r],this.activeCalls={...n};const o={...this.extendedCalls};delete o[r],this.extendedCalls={...o},this.emit("changeActiveCalls",this.activeCalls)}removeMMSRPSession(r){const n={...this.activeMessages};delete n[r],this.activeMessages={...n};const o={...this.extendedMessages};delete o[r],this.extendedMessages={...o},this.emit("changeActiveMessages",this.activeMessages)}activeCallListRemove(r){const n=this.extendedCalls[r._id].roomId;this.removeCall(r._id),this.roomReconfigure(n)}activeMessageListRemove(r){this.removeMMSRPSession(r._id)}newRTCSessionCallback(r){const n=r.session;if(this.isDND){n.terminate({status_code:486,reason_phrase:"Do Not Disturb"});return}if(n.on("ended",o=>{var t,s;this.logger.log("Session ended for",(s=(t=n._remote_identity)==null?void 0:t._uri)==null?void 0:s._user),this.triggerListener({listenerType:Jt.CALL_ENDED,session:n,event:o});const a=this.getActiveCalls[n.id];a&&this.activeCallListRemove(a),this.stopCallTimer(n.id),this.removeCallStatus(n.id),this.removeCallMetrics(n.id),Object.keys(this.extendedCalls).length||this.setIsMuted(!1)}),n.on("progress",o=>{var a,t;this.logger.log("Session in progress for",(t=(a=n._remote_identity)==null?void 0:a._uri)==null?void 0:t._user),this.triggerListener({listenerType:Jt.CALL_PROGRESS,session:n,event:o})}),n.on("failed",o=>{var t,s;this.logger.log("Session failed for",(s=(t=n._remote_identity)==null?void 0:t._uri)==null?void 0:s._user),this.triggerListener({listenerType:Jt.CALL_FAILED,session:n,event:o}),n.id===this.callAddingInProgress&&(this.callAddingInProgress=void 0);const a=this.getActiveCalls[n.id];a&&this.activeCallListRemove(a),this.stopCallTimer(n.id),this.removeCallStatus(n.id),this.removeCallMetrics(n.id),Object.keys(this.extendedCalls).length||this.setIsMuted(!1)}),n.on("confirmed",o=>{var a,t;this.logger.log("Session confirmed for",(t=(a=n._remote_identity)==null?void 0:a._uri)==null?void 0:t._user),this.triggerListener({listenerType:Jt.CALL_CONFIRMED,session:n,event:o}),this.updateCall(n),n.id===this.callAddingInProgress&&(this.callAddingInProgress=void 0)}),this.addCall(r),n.direction==="outgoing"){const o=this.getActiveCalls[n.id].roomId;this.setCurrentActiveRoomId(o)}}newMSRPSessionCallback(r){const n=r.session;n.on("ended",o=>{this.triggerMSRPListener({listenerType:Jt.CALL_ENDED,session:n,event:o});const a=this.getActiveMessages[n.id];this.activeMessageListRemove(a)}),n.on("failed",o=>{this.triggerMSRPListener({listenerType:Jt.CALL_FAILED,session:n,event:o});const a=this.getActiveMessages[n.id];this.activeMessageListRemove(a)}),n.on("confirmed",o=>{this.triggerMSRPListener({listenerType:Jt.CALL_CONFIRMED,session:n,event:o}),this.updateMSRPSession(n)}),n.on("newMessage",o=>{this.addMSRPMessage(o,n)}),this.addMessageSession(n)}setInitialized(r){this.initialized=r,this.emit("ready",r)}begin(){if(this.isConnected()){console.error("Connection is already established");return}return 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.newRTCSessionEventName,this.newRTCSessionCallback.bind(this)),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.on(this.newMSRPSessionEventName,this.newMSRPSessionCallback.bind(this)),this.logger.log("Connecting to",this.options.socketInterfaces[0]),this.start(),this.setMediaDevices(!0),this}setMuteWhenJoin(r){this.muteWhenJoinEnabled=r,this.emit("changeMuteWhenJoin",r)}setMicrophoneInputLevel(r){this.microphoneInputLevelValue=r,this.roomReconfigure(this.currentActiveRoomId)}setSpeakerVolume(r){this.speakerVolumeValue=r,Object.values(this.extendedCalls).forEach(n=>{n.audioTag&&(n.audioTag.volume=r)})}setAutoAnswer(r){this.isAutoAnswer=r}setSelectedInputDevice(r){localStorage.setItem(so.SELECTED_INPUT_DEVICE,r),this.selectedMediaDevices.input=r,this.emit("changeActiveInputMediaDevice",r)}setSelectedOutputDevice(r){localStorage.setItem(so.SELECTED_OUTPUT_DEVICE,r),this.selectedMediaDevices.output=r,this.emit("changeActiveOutputMediaDevice",r)}setIsMSRPInitializing(r){this.isMSRPInitializingValue=r,this.emit("isMSRPInitializingChanged",r)}setCallMetrics(r){const n={...r};delete n.callId,this.callMetrics={...this.callMetrics,[r.callId]:n},this.emit("changeCallMetrics",this.callMetrics)}removeCallMetrics(r){const n={...this.callMetrics};delete n[r],this.callMetrics={...n},this.emit("changeCallMetrics",this.callMetrics)}getCallQuality(r){const n=new bv(this.metricConfig),o=n.createProbe(r.connection,{cid:r._id}),a=[];let t;o.onreport=s=>{Object.entries(s.audio).forEach(([d,g])=>{g.direction==="inbound"&&!a.includes(d)&&(a.push(d),t=d)});const p=s.audio[t],_=Pg(p,qv);_.callId=r._id,this.setCallMetrics(n)},this.subscribe(Jt.CALL_ENDED,s=>{s._id===r._id&&n.stopAllProbes()}),n.startAllProbes()}async triggerAddStream(r,n){this.setIsMuted(this.muteWhenJoin);const o=await navigator.mediaDevices.getUserMedia(this.getUserMediaConstraints),a=Ql(o,this.microphoneInputLevel),t=this.isMuted||this.muteWhenJoin;a.getTracks().forEach(s=>s.enabled=!t),this.setOriginalStream(a),await n.connection.getSenders()[0].replaceTrack(a.getTracks()[0]),xg(r,n,this.selectedOutputDevice,this.speakerVolume),this.getCallQuality(n),this.updateCall(n)}doCall({target:r,addToCurrentRoom:n}){if(this.checkInitialized(),r.length===0)return console.error("Target must be a valid string");this.logger.log(`Calling sip:${r}@${this.sipDomain}...`);const o=this.call(`sip:${r}@${this.sipDomain}`,this.sipOptions);this.callAddingInProgress=o.id,n&&this.currentActiveRoomId!==void 0&&this.callChangeRoom({callId:o.id,roomId:this.currentActiveRoomId}),o.connection.addEventListener("addstream",a=>{this.triggerAddStream(a,o)})}initMSRP(r,n,o){if(this.checkInitialized(),r.length===0)return console.error("Target must be a valid string");const a=this.startMSRP(r,o);a.on("active",()=>{this.addMessageSession(a),a.sendMSRP(n),this.setIsMSRPInitializing(!1)}),this.setIsMSRPInitializing(!0)}sendMSRP(r,n){const o=this.extendedMessages[r];if(!o)throw new Error(`MSRP session with id ${r} doesn't exist!`);o.sendMSRP(n)}async callChangeRoom({callId:r,roomId:n}){const o=this.extendedCalls[r].roomId;return this.extendedCalls[r].roomId=n,await this.setCurrentActiveRoomId(n),Promise.all([this.roomReconfigure(o),this.roomReconfigure(n)]).then(()=>{this.deleteRoomIfEmpty(o),this.deleteRoomIfEmpty(n)})}}return Vv}();