@zhaokun/cti 1.4.6 → 1.4.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- /*! version: 1.4.6 */
1
+ /*! version: 1.4.7 */
2
2
  !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("zhaokunCTI",[],t):"object"==typeof exports?exports.zhaokunCTI=t():e.zhaokunCTI=t()}("undefined"!=typeof self?self:this,(()=>(()=>{var e={7:e=>{"use strict";var t,n="object"==typeof Reflect?Reflect:null,r=n&&"function"==typeof n.apply?n.apply:function(e,t,n){return Function.prototype.apply.call(e,t,n)};t=n&&"function"==typeof n.ownKeys?n.ownKeys:Object.getOwnPropertySymbols?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:function(e){return Object.getOwnPropertyNames(e)};var o=Number.isNaN||function(e){return e!=e};function i(){i.init.call(this)}e.exports=i,e.exports.once=function(e,t){return new Promise((function(n,r){function o(n){e.removeListener(t,i),r(n)}function i(){"function"==typeof e.removeListener&&e.removeListener("error",o),n([].slice.call(arguments))}_(e,t,i,{once:!0}),"error"!==t&&function(e,t,n){"function"==typeof e.on&&_(e,"error",t,n)}(e,o,{once:!0})}))},i.EventEmitter=i,i.prototype._events=void 0,i.prototype._eventsCount=0,i.prototype._maxListeners=void 0;var s=10;function a(e){if("function"!=typeof e)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof e)}function u(e){return void 0===e._maxListeners?i.defaultMaxListeners:e._maxListeners}function l(e,t,n,r){var o,i,s,l;if(a(n),void 0===(i=e._events)?(i=e._events=Object.create(null),e._eventsCount=0):(void 0!==i.newListener&&(e.emit("newListener",t,n.listener?n.listener:n),i=e._events),s=i[t]),void 0===s)s=i[t]=n,++e._eventsCount;else if("function"==typeof s?s=i[t]=r?[n,s]:[s,n]:r?s.unshift(n):s.push(n),(o=u(e))>0&&s.length>o&&!s.warned){s.warned=!0;var c=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");c.name="MaxListenersExceededWarning",c.emitter=e,c.type=t,c.count=s.length,l=c,console&&console.warn&&console.warn(l)}return e}function c(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function f(e,t,n){var r={fired:!1,wrapFn:void 0,target:e,type:t,listener:n},o=c.bind(r);return o.listener=n,r.wrapFn=o,o}function h(e,t,n){var r=e._events;if(void 0===r)return[];var o=r[t];return void 0===o?[]:"function"==typeof o?n?[o.listener||o]:[o]:n?function(e){for(var t=new Array(e.length),n=0;n<t.length;++n)t[n]=e[n].listener||e[n];return t}(o):p(o,o.length)}function d(e){var t=this._events;if(void 0!==t){var n=t[e];if("function"==typeof n)return 1;if(void 0!==n)return n.length}return 0}function p(e,t){for(var n=new Array(t),r=0;r<t;++r)n[r]=e[r];return n}function _(e,t,n,r){if("function"==typeof e.on)r.once?e.once(t,n):e.on(t,n);else{if("function"!=typeof e.addEventListener)throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof e);e.addEventListener(t,(function o(i){r.once&&e.removeEventListener(t,o),n(i)}))}}Object.defineProperty(i,"defaultMaxListeners",{enumerable:!0,get:function(){return s},set:function(e){if("number"!=typeof e||e<0||o(e))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+e+".");s=e}}),i.init=function(){void 0!==this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},i.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||o(e))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+e+".");return this._maxListeners=e,this},i.prototype.getMaxListeners=function(){return u(this)},i.prototype.emit=function(e){for(var t=[],n=1;n<arguments.length;n++)t.push(arguments[n]);var o="error"===e,i=this._events;if(void 0!==i)o=o&&void 0===i.error;else if(!o)return!1;if(o){var s;if(t.length>0&&(s=t[0]),s instanceof Error)throw s;var a=new Error("Unhandled error."+(s?" ("+s.message+")":""));throw a.context=s,a}var u=i[e];if(void 0===u)return!1;if("function"==typeof u)r(u,this,t);else{var l=u.length,c=p(u,l);for(n=0;n<l;++n)r(c[n],this,t)}return!0},i.prototype.addListener=function(e,t){return l(this,e,t,!1)},i.prototype.on=i.prototype.addListener,i.prototype.prependListener=function(e,t){return l(this,e,t,!0)},i.prototype.once=function(e,t){return a(t),this.on(e,f(this,e,t)),this},i.prototype.prependOnceListener=function(e,t){return a(t),this.prependListener(e,f(this,e,t)),this},i.prototype.removeListener=function(e,t){var n,r,o,i,s;if(a(t),void 0===(r=this._events))return this;if(void 0===(n=r[e]))return this;if(n===t||n.listener===t)0==--this._eventsCount?this._events=Object.create(null):(delete r[e],r.removeListener&&this.emit("removeListener",e,n.listener||t));else if("function"!=typeof n){for(o=-1,i=n.length-1;i>=0;i--)if(n[i]===t||n[i].listener===t){s=n[i].listener,o=i;break}if(o<0)return this;0===o?n.shift():function(e,t){for(;t+1<e.length;t++)e[t]=e[t+1];e.pop()}(n,o),1===n.length&&(r[e]=n[0]),void 0!==r.removeListener&&this.emit("removeListener",e,s||t)}return this},i.prototype.off=i.prototype.removeListener,i.prototype.removeAllListeners=function(e){var t,n,r;if(void 0===(n=this._events))return this;if(void 0===n.removeListener)return 0===arguments.length?(this._events=Object.create(null),this._eventsCount=0):void 0!==n[e]&&(0==--this._eventsCount?this._events=Object.create(null):delete n[e]),this;if(0===arguments.length){var o,i=Object.keys(n);for(r=0;r<i.length;++r)"removeListener"!==(o=i[r])&&this.removeAllListeners(o);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if("function"==typeof(t=n[e]))this.removeListener(e,t);else if(void 0!==t)for(r=t.length-1;r>=0;r--)this.removeListener(e,t[r]);return this},i.prototype.listeners=function(e){return h(this,e,!0)},i.prototype.rawListeners=function(e){return h(this,e,!1)},i.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):d.call(e,t)},i.prototype.listenerCount=d,i.prototype.eventNames=function(){return this._eventsCount>0?t(this._events):[]}},700:(e,t,n)=>{"use strict";function r(e,t){var n;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return o(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return o(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var s,a=!0,u=!1;return{s:function(){n=e[Symbol.iterator]()},n:function(){var e=n.next();return a=e.done,e},e:function(e){u=!0,s=e},f:function(){try{a||null==n.return||n.return()}finally{if(u)throw s}}}}function o(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var i=n(137),s=n(349),a=n(561),u=n(670),l=n(627),c=n(956);t.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:s.UPDATE,session_timers_force_refresher:!1,no_answer_timeout:60,register:!0,register_expires:600,registrar_server:null,sockets:null,connection_recovery_max_interval:s.CONNECTION_RECOVERY_MAX_INTERVAL,connection_recovery_min_interval:s.CONNECTION_RECOVERY_MIN_INTERVAL,extra_headers:null,via_host:"".concat(i.createRandomToken(12),".invalid")};var f={mandatory:{sockets:function(e){var t=[];if(l.isSocket(e))t.push({socket:e});else{if(!Array.isArray(e)||!e.length)return;var n,o=r(e);try{for(o.s();!(n=o.n()).done;){var i=n.value;Object.prototype.hasOwnProperty.call(i,"socket")&&l.isSocket(i.socket)?t.push(i):l.isSocket(i)&&t.push({socket:i})}}catch(e){o.e(e)}finally{o.f()}}return t},uri:function(e){/^sip:/i.test(e)||(e="".concat(s.SIP,":").concat(e));var t=u.parse(e);return t&&t.user?t:void 0}},optional:{authorization_user:function(e){return-1===a.parse('"'.concat(e,'"'),"quoted_string")?void 0:e},authorization_jwt:function(e){if("string"==typeof e)return e},user_agent:function(e){if("string"==typeof e)return e},connection_recovery_max_interval:function(e){if(i.isDecimal(e)){var t=Number(e);if(t>0)return t}},connection_recovery_min_interval:function(e){if(i.isDecimal(e)){var t=Number(e);if(t>0)return t}},contact_uri:function(e){if("string"==typeof e){var t=a.parse(e,"SIP_URI");if(-1!==t)return t}},display_name:function(e){return e},instance_id:function(e){return/^uuid:/i.test(e)&&(e=e.substr(5)),-1===a.parse(e,"uuid")?void 0:e},no_answer_timeout:function(e){if(i.isDecimal(e)){var t=Number(e);if(t>0)return t}},session_timers:function(e){if("boolean"==typeof e)return e},session_timers_refresh_method:function(e){if("string"==typeof e&&((e=e.toUpperCase())===s.INVITE||e===s.UPDATE))return e},session_timers_force_refresher:function(e){if("boolean"==typeof e)return e},password:function(e){return String(e)},realm:function(e){return String(e)},ha1:function(e){return String(e)},register:function(e){if("boolean"==typeof e)return e},register_expires:function(e){if(i.isDecimal(e)){var t=Number(e);if(t>0)return t}},registrar_server:function(e){/^sip:/i.test(e)||(e="".concat(s.SIP,":").concat(e));var t=u.parse(e);return t?t.user?void 0:t:void 0},use_preloaded_route:function(e){if("boolean"==typeof e)return e},extra_headers:function(e){var t=[];if(Array.isArray(e)&&e.length){var n,o=r(e);try{for(o.s();!(n=o.n()).done;){var i=n.value;"string"==typeof i&&t.push(i)}}catch(e){o.e(e)}finally{o.f()}return t}}}};t.load=function(e,t){for(var n in f.mandatory){if(!t.hasOwnProperty(n))throw new c.ConfigurationError(n);var r=t[n],o=f.mandatory[n](r);if(void 0===o)throw new c.ConfigurationError(n,r);e[n]=o}for(var s in f.optional)if(t.hasOwnProperty(s)){var a=t[s];if(i.isEmpty(a))continue;var u=f.optional[s](a);if(void 0===u)throw new c.ConfigurationError(s,a);e[s]=u}}},349:(e,t,n)=>{"use strict";var r=n(633);e.exports={USER_AGENT:"".concat(r.title," ").concat(r.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}},978:(e,t,n)=>{"use strict";function r(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function o(e,t,n){return t&&r(e.prototype,t),n&&r(e,n),e}var i=n(510),s=n(213),a=n(349),u=n(143),l=n(453),c=n(137),f=new i("Dialog"),h={STATUS_EARLY:1,STATUS_CONFIRMED:2,STATUS_TERMINATED:3};e.exports=function(){function e(t,n,r){var o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:h.STATUS_CONFIRMED;if(function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this._owner=t,this._ua=t._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 s.IncomingResponse&&(o=n.status_code<200?h.STATUS_EARLY:h.STATUS_CONFIRMED);var i=n.parseHeader("contact");"UAS"===r?(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=o,this._remote_seqnum=n.cseq,this._local_uri=n.parseHeader("to").uri,this._remote_uri=n.parseHeader("from").uri,this._remote_target=i.uri,this._route_set=n.getHeaders("record-route"),this._ack_seqnum=this._remote_seqnum):"UAC"===r&&(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=o,this._local_seqnum=n.cseq,this._local_uri=n.parseHeader("from").uri,this._remote_uri=n.parseHeader("to").uri,this._remote_target=i.uri,this._route_set=n.getHeaders("record-route").reverse(),this._ack_seqnum=null),this._ua.newDialog(this),f.debug("new ".concat(r," dialog created with status ").concat(this._state===h.STATUS_EARLY?"EARLY":"CONFIRMED"))}return o(e,null,[{key:"C",get:function(){return h}}]),o(e,[{key:"isTerminated",value:function(){return this._status===h.STATUS_TERMINATED}},{key:"update",value:function(e,t){this._state=h.STATUS_CONFIRMED,f.debug("dialog ".concat(this._id.toString()," changed to CONFIRMED state")),"UAC"===t&&(this._route_set=e.getHeaders("record-route").reverse())}},{key:"terminate",value:function(){f.debug("dialog ".concat(this._id.toString()," deleted")),this._ua.destroyDialog(this),this._state=h.STATUS_TERMINATED}},{key:"sendRequest",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=c.cloneArray(n.extraHeaders),o=c.cloneObject(n.eventHandlers),i=n.body||null,s=this._createRequest(e,r,i);return o.onAuthenticated=function(){t._local_seqnum+=1},new l(this,s,o).send(),s}},{key:"receiveRequest",value:function(e){this._checkInDialogRequest(e)&&(e.method===a.ACK&&null!==this._ack_seqnum?this._ack_seqnum=null:e.method===a.INVITE&&(this._ack_seqnum=e.cseq),this._owner.receiveRequest(e))}},{key:"_createRequest",value:function(e,t,n){t=c.cloneArray(t),this._local_seqnum||(this._local_seqnum=Math.floor(1e4*Math.random()));var r=e===a.CANCEL||e===a.ACK?this._local_seqnum:this._local_seqnum+=1;return new s.OutgoingRequest(e,this._remote_target,this._ua,{cseq:r,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},t,n)}},{key:"_checkInDialogRequest",value:function(e){var t=this;if(this._remote_seqnum)if(e.cseq<this._remote_seqnum){if(e.method!==a.ACK)return e.reply(500),!1;if(null===this._ack_seqnum||e.cseq!==this._ack_seqnum)return!1}else e.cseq>this._remote_seqnum&&(this._remote_seqnum=e.cseq);else this._remote_seqnum=e.cseq;if(e.method===a.INVITE||e.method===a.UPDATE&&e.body){if(!0===this._uac_pending_reply)e.reply(491);else{if(!0===this._uas_pending_reply){var n=1+(10*Math.random()|0);return e.reply(500,null,["Retry-After:".concat(n)]),!1}this._uas_pending_reply=!0;e.server_transaction.on("stateChanged",(function n(){e.server_transaction.state!==u.C.STATUS_ACCEPTED&&e.server_transaction.state!==u.C.STATUS_COMPLETED&&e.server_transaction.state!==u.C.STATUS_TERMINATED||(e.server_transaction.removeListener("stateChanged",n),t._uas_pending_reply=!1)}))}e.hasHeader("contact")&&e.server_transaction.on("stateChanged",(function(){e.server_transaction.state===u.C.STATUS_ACCEPTED&&(t._remote_target=e.parseHeader("contact").uri)}))}else e.method===a.NOTIFY&&e.hasHeader("contact")&&e.server_transaction.on("stateChanged",(function(){e.server_transaction.state===u.C.STATUS_COMPLETED&&(t._remote_target=e.parseHeader("contact").uri)}));return!0}},{key:"id",get:function(){return this._id}},{key:"local_seqnum",get:function(){return this._local_seqnum},set:function(e){this._local_seqnum=e}},{key:"owner",get:function(){return this._owner}},{key:"uac_pending_reply",get:function(){return this._uac_pending_reply},set:function(e){this._uac_pending_reply=e}},{key:"uas_pending_reply",get:function(){return this._uas_pending_reply}}]),e}()},453:(e,t,n)=>{"use strict";function r(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}var o=n(349),i=n(143),s=n(396),a={onRequestTimeout:function(){},onTransportError:function(){},onSuccessResponse:function(){},onErrorResponse:function(){},onAuthenticated:function(){},onDialogError:function(){}};e.exports=function(){function e(t,n,r){for(var o in function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this._dialog=t,this._ua=t._ua,this._request=n,this._eventHandlers=r,this._reattempt=!1,this._reattemptTimer=null,a)Object.prototype.hasOwnProperty.call(a,o)&&(this._eventHandlers[o]||(this._eventHandlers[o]=a[o]))}var t,n,u;return t=e,(n=[{key:"send",value:function(){var e=this,t=new s(this._ua,this._request,{onRequestTimeout:function(){e._eventHandlers.onRequestTimeout()},onTransportError:function(){e._eventHandlers.onTransportError()},onAuthenticated:function(t){e._eventHandlers.onAuthenticated(t)},onReceiveResponse:function(t){e._receiveResponse(t)}});t.send(),(this._request.method===o.INVITE||this._request.method===o.UPDATE&&this._request.body)&&t.clientTransaction.state!==i.C.STATUS_TERMINATED&&(this._dialog.uac_pending_reply=!0,t.clientTransaction.on("stateChanged",(function n(){t.clientTransaction.state!==i.C.STATUS_ACCEPTED&&t.clientTransaction.state!==i.C.STATUS_COMPLETED&&t.clientTransaction.state!==i.C.STATUS_TERMINATED||(t.clientTransaction.removeListener("stateChanged",n),e._dialog.uac_pending_reply=!1)})))}},{key:"_receiveResponse",value:function(e){var t=this;408===e.status_code||481===e.status_code?this._eventHandlers.onDialogError(e):e.method===o.INVITE&&491===e.status_code?this._reattempt?e.status_code>=200&&e.status_code<300?this._eventHandlers.onSuccessResponse(e):e.status_code>=300&&this._eventHandlers.onErrorResponse(e):(this._request.cseq=this._dialog.local_seqnum+=1,this._reattemptTimer=setTimeout((function(){t._dialog.isTerminated()||(t._reattempt=!0,t.send())}),1e3)):e.status_code>=200&&e.status_code<300?this._eventHandlers.onSuccessResponse(e):e.status_code>=300&&this._eventHandlers.onErrorResponse(e)}},{key:"request",get:function(){return this._request}}])&&r(t.prototype,n),u&&r(t,u),e}()},554:(e,t,n)=>{"use strict";function r(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}var o=n(510),i=n(137),s=new o("DigestAuthentication");e.exports=function(){function e(t){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this._credentials=t,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}var t,n,o;return t=e,n=[{key:"get",value:function(e){switch(e){case"realm":return this._realm;case"ha1":return this._ha1;default:return void s.warn('get() | cannot get "%s" parameter',e)}}},{key:"authenticate",value:function(e,t){var n=e.method,r=e.ruri,o=e.body,a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;if(this._algorithm=t.algorithm,this._realm=t.realm,this._nonce=t.nonce,this._opaque=t.opaque,this._stale=t.stale,this._algorithm){if("MD5"!==this._algorithm)return s.warn('authenticate() | challenge with Digest algorithm different than "MD5", authentication aborted'),!1}else this._algorithm="MD5";if(!this._nonce)return s.warn("authenticate() | challenge without Digest nonce, authentication aborted"),!1;if(!this._realm)return s.warn("authenticate() | challenge without Digest realm, authentication aborted"),!1;if(!this._credentials.password){if(!this._credentials.ha1)return s.warn("authenticate() | no plain SIP password nor ha1 provided, authentication aborted"),!1;if(this._credentials.realm!==this._realm)return s.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(t.qop)if(t.qop.indexOf("auth-int")>-1)this._qop="auth-int";else{if(!(t.qop.indexOf("auth")>-1))return s.warn('authenticate() | challenge without Digest qop different than "auth" or "auth-int", authentication aborted'),!1;this._qop="auth"}else this._qop=null;this._method=n,this._uri=r,this._cnonce=a||i.createRandomToken(12),this._nc+=1;var u,l,c=Number(this._nc).toString(16);return this._ncHex="00000000".substr(0,8-c.length)+c,4294967296===this._nc&&(this._nc=1,this._ncHex="00000001"),this._credentials.password?this._ha1=i.calculateMD5("".concat(this._credentials.username,":").concat(this._realm,":").concat(this._credentials.password)):this._ha1=this._credentials.ha1,"auth"===this._qop?(u="".concat(this._method,":").concat(this._uri),l=i.calculateMD5(u),s.debug('authenticate() | using qop=auth [a2:"%s"]',u),this._response=i.calculateMD5("".concat(this._ha1,":").concat(this._nonce,":").concat(this._ncHex,":").concat(this._cnonce,":auth:").concat(l))):"auth-int"===this._qop?(u="".concat(this._method,":").concat(this._uri,":").concat(i.calculateMD5(o||"")),l=i.calculateMD5(u),s.debug('authenticate() | using qop=auth-int [a2:"%s"]',u),this._response=i.calculateMD5("".concat(this._ha1,":").concat(this._nonce,":").concat(this._ncHex,":").concat(this._cnonce,":auth-int:").concat(l))):null===this._qop&&(u="".concat(this._method,":").concat(this._uri),l=i.calculateMD5(u),s.debug('authenticate() | using qop=null [a2:"%s"]',u),this._response=i.calculateMD5("".concat(this._ha1,":").concat(this._nonce,":").concat(l))),s.debug("authenticate() | response generated"),!0}},{key:"toString",value:function(){var e=[];if(!this._response)throw new Error("response field does not exist, cannot generate Authorization header");return e.push("algorithm=".concat(this._algorithm)),e.push('username="'.concat(this._credentials.username,'"')),e.push('realm="'.concat(this._realm,'"')),e.push('nonce="'.concat(this._nonce,'"')),e.push('uri="'.concat(this._uri,'"')),e.push('response="'.concat(this._response,'"')),this._opaque&&e.push('opaque="'.concat(this._opaque,'"')),this._qop&&(e.push("qop=".concat(this._qop)),e.push('cnonce="'.concat(this._cnonce,'"')),e.push("nc=".concat(this._ncHex))),"Digest ".concat(e.join(", "))}}],n&&r(t.prototype,n),o&&r(t,o),e}()},956:e=>{"use strict";function t(e){return t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},t(e)}function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function r(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&u(e,t)}function o(e){var n=a();return function(){var r,o=l(e);if(n){var i=l(this).constructor;r=Reflect.construct(o,arguments,i)}else r=o.apply(this,arguments);return function(e,n){if(n&&("object"===t(n)||"function"==typeof n))return n;return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}(this,r)}}function i(e){var t="function"==typeof Map?new Map:void 0;return i=function(e){if(null===e||(n=e,-1===Function.toString.call(n).indexOf("[native code]")))return e;var n;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,r)}function r(){return s(e,arguments,l(this).constructor)}return r.prototype=Object.create(e.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),u(r,e)},i(e)}function s(e,t,n){return s=a()?Reflect.construct:function(e,t,n){var r=[null];r.push.apply(r,t);var o=new(Function.bind.apply(e,r));return n&&u(o,n.prototype),o},s.apply(null,arguments)}function a(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}function u(e,t){return u=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},u(e,t)}function l(e){return l=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},l(e)}var c=function(e){r(i,e);var t=o(i);function i(e,r){var o;return n(this,i),(o=t.call(this)).code=1,o.name="CONFIGURATION_ERROR",o.parameter=e,o.value=r,o.message=o.value?"Invalid value ".concat(JSON.stringify(o.value),' for parameter "').concat(o.parameter,'"'):"Missing parameter: ".concat(o.parameter),o}return i}(i(Error)),f=function(e){r(i,e);var t=o(i);function i(e){var r;return n(this,i),(r=t.call(this)).code=2,r.name="INVALID_STATE_ERROR",r.status=e,r.message="Invalid status: ".concat(e),r}return i}(i(Error)),h=function(e){r(i,e);var t=o(i);function i(e){var r;return n(this,i),(r=t.call(this)).code=3,r.name="NOT_SUPPORTED_ERROR",r.message=e,r}return i}(i(Error)),d=function(e){r(i,e);var t=o(i);function i(e){var r;return n(this,i),(r=t.call(this)).code=4,r.name="NOT_READY_ERROR",r.message=e,r}return i}(i(Error));e.exports={ConfigurationError:c,InvalidStateError:f,NotSupportedError:h,NotReadyError:d}},561:(e,t,n)=>{"use strict";e.exports=function(){function e(e){return'"'+e.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\x08/g,"\\b").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\f/g,"\\f").replace(/\r/g,"\\r").replace(/[\x00-\x07\x0B\x0E-\x1F\x80-\uFFFF]/g,escape)+'"'}var t={parse:function(t,r){var o={CRLF:c,DIGIT:f,ALPHA:h,HEXDIG:d,WSP:p,OCTET:_,DQUOTE:v,SP:m,HTAB:y,alphanum:g,reserved:b,unreserved:T,mark:w,escaped:S,LWS:E,SWS:C,HCOLON:A,TEXT_UTF8_TRIM:R,TEXT_UTF8char:I,UTF8_NONASCII:O,UTF8_CONT:k,LHEX:function(){var e;null===(e=f())&&(/^[a-f]/.test(t.charAt(i))?(e=t.charAt(i),i++):(e=null,0===s&&l("[a-f]")));return e},token:x,token_nodot:N,separators:function(){var e;40===t.charCodeAt(i)?(e="(",i++):(e=null,0===s&&l('"("'));null===e&&(41===t.charCodeAt(i)?(e=")",i++):(e=null,0===s&&l('")"')),null===e&&(60===t.charCodeAt(i)?(e="<",i++):(e=null,0===s&&l('"<"')),null===e&&(62===t.charCodeAt(i)?(e=">",i++):(e=null,0===s&&l('">"')),null===e&&(64===t.charCodeAt(i)?(e="@",i++):(e=null,0===s&&l('"@"')),null===e&&(44===t.charCodeAt(i)?(e=",",i++):(e=null,0===s&&l('","')),null===e&&(59===t.charCodeAt(i)?(e=";",i++):(e=null,0===s&&l('";"')),null===e&&(58===t.charCodeAt(i)?(e=":",i++):(e=null,0===s&&l('":"')),null===e&&(92===t.charCodeAt(i)?(e="\\",i++):(e=null,0===s&&l('"\\\\"')),null===e&&null===(e=v())&&(47===t.charCodeAt(i)?(e="/",i++):(e=null,0===s&&l('"/"')),null===e&&(91===t.charCodeAt(i)?(e="[",i++):(e=null,0===s&&l('"["')),null===e&&(93===t.charCodeAt(i)?(e="]",i++):(e=null,0===s&&l('"]"')),null===e&&(63===t.charCodeAt(i)?(e="?",i++):(e=null,0===s&&l('"?"')),null===e&&(61===t.charCodeAt(i)?(e="=",i++):(e=null,0===s&&l('"="')),null===e&&(123===t.charCodeAt(i)?(e="{",i++):(e=null,0===s&&l('"{"')),null===e&&(125===t.charCodeAt(i)?(e="}",i++):(e=null,0===s&&l('"}"')),null===e&&null===(e=m())&&(e=y()))))))))))))))));return e},word:P,STAR:D,SLASH:L,EQUAL:U,LPAREN:M,RPAREN:j,RAQUOT:q,LAQUOT:F,COMMA:H,SEMI:G,COLON:B,LDQUOT:W,RDQUOT:V,comment:function e(){var t,n,r,o;if(o=i,null!==(t=M())){for(n=[],null===(r=K())&&null===(r=J())&&(r=e());null!==r;)n.push(r),null===(r=K())&&null===(r=J())&&(r=e());null!==n&&null!==(r=j())?t=[t,n,r]:(t=null,i=o)}else t=null,i=o;return t},ctext:K,quoted_string:z,quoted_string_clean:Y,qdtext:$,quoted_pair:J,SIP_URI_noparams:X,SIP_URI:Q,uri_scheme:Z,uri_scheme_sips:ee,uri_scheme_sip:te,userinfo:ne,user:re,user_unreserved:oe,password:ie,hostport:se,host:ae,hostname:ue,domainlabel:le,toplabel:ce,IPv6reference:fe,IPv6address:he,h16:de,ls32:pe,IPv4address:_e,dec_octet:ve,port:me,uri_parameters:ye,uri_parameter:ge,transport_param:be,user_param:Te,method_param:we,ttl_param:Se,maddr_param:Ee,lr_param:Ce,other_param:Ae,pname:Re,pvalue:Ie,paramchar:Oe,param_unreserved:ke,headers:xe,header:Ne,hname:Pe,hvalue:De,hnv_unreserved:Le,Request_Response:function(){var e;null===(e=ft())&&(e=Ue());return e},Request_Line:Ue,Request_URI:Me,absoluteURI:je,hier_part:qe,net_path:Fe,abs_path:He,opaque_part:Ge,uric:Be,uric_no_slash:We,path_segments:Ve,segment:Ke,param:ze,pchar:Ye,scheme:$e,authority:Je,srvr:Xe,reg_name:Qe,query:Ze,SIP_Version:et,INVITEm:tt,ACKm:nt,OPTIONSm:rt,BYEm:ot,CANCELm:it,REGISTERm:st,SUBSCRIBEm:at,NOTIFYm:ut,REFERm:lt,Method:ct,Status_Line:ft,Status_Code:ht,extension_code:dt,Reason_Phrase:pt,Allow_Events:function(){var e,t,n,r,o,s;if(o=i,null!==(e=jt())){for(t=[],s=i,null!==(n=H())&&null!==(r=jt())?n=[n,r]:(n=null,i=s);null!==n;)t.push(n),s=i,null!==(n=H())&&null!==(r=jt())?n=[n,r]:(n=null,i=s);null!==t?e=[e,t]:(e=null,i=o)}else e=null,i=o;return e},Call_ID:function(){var e,n,r,o,a,u;o=i,a=i,null!==(e=P())?(u=i,64===t.charCodeAt(i)?(n="@",i++):(n=null,0===s&&l('"@"')),null!==n&&null!==(r=P())?n=[n,r]:(n=null,i=u),null!==(n=null!==n?n:"")?e=[e,n]:(e=null,i=a)):(e=null,i=a);null!==e&&(e=function(e){Hn=t.substring(i,e)}(o));null===e&&(i=o);return e},Contact:function(){var e,t,n,r,o,s,a;if(o=i,null===(e=D()))if(s=i,null!==(e=_t())){for(t=[],a=i,null!==(n=H())&&null!==(r=_t())?n=[n,r]:(n=null,i=a);null!==n;)t.push(n),a=i,null!==(n=H())&&null!==(r=_t())?n=[n,r]:(n=null,i=a);null!==t?e=[e,t]:(e=null,i=s)}else e=null,i=s;null!==e&&(e=function(){var e,t;for(t=Hn.multi_header.length,e=0;e<t;e++)if(null===Hn.multi_header[e].parsed){Hn=null;break}Hn=null!==Hn?Hn.multi_header:-1}());null===e&&(i=o);return e},contact_param:_t,name_addr:vt,display_name:mt,contact_params:yt,c_p_q:gt,c_p_expires:bt,delta_seconds:Tt,qvalue:wt,generic_param:St,gen_value:Et,Content_Disposition:function(){var e,t,n,r,o,s;if(o=i,null!==(e=Ct())){for(t=[],s=i,null!==(n=G())&&null!==(r=At())?n=[n,r]:(n=null,i=s);null!==n;)t.push(n),s=i,null!==(n=G())&&null!==(r=At())?n=[n,r]:(n=null,i=s);null!==t?e=[e,t]:(e=null,i=o)}else e=null,i=o;return e},disp_type:Ct,disp_param:At,handling_param:Rt,Content_Encoding:function(){var e,t,n,r,o,s;if(o=i,null!==(e=x())){for(t=[],s=i,null!==(n=H())&&null!==(r=x())?n=[n,r]:(n=null,i=s);null!==n;)t.push(n),s=i,null!==(n=H())&&null!==(r=x())?n=[n,r]:(n=null,i=s);null!==t?e=[e,t]:(e=null,i=o)}else e=null,i=o;return e},Content_Length:function(){var e,t,n;if(n=i,null!==(t=f()))for(e=[];null!==t;)e.push(t),t=f();else e=null;null!==e&&(e=void(Hn=parseInt(e.join(""))));null===e&&(i=n);return e},Content_Type:function(){var e,n;n=i,null!==(e=It())&&(e=function(e){Hn=t.substring(i,e)}(n));null===e&&(i=n);return e},media_type:It,m_type:Ot,discrete_type:kt,composite_type:xt,extension_token:Nt,x_token:Pt,m_subtype:Dt,m_parameter:Lt,m_value:Ut,CSeq:function(){var e,t,n,r;r=i,null!==(e=Mt())&&null!==(t=E())&&null!==(n=ct())?e=[e,t,n]:(e=null,i=r);return e},CSeq_value:Mt,Expires:function(){var e,t;t=i,null!==(e=Tt())&&(e=void(Hn=e));null===e&&(i=t);return e},Event:function(){var e,t,n,r,o,s,a;if(o=i,s=i,null!==(e=jt())){for(t=[],a=i,null!==(n=G())&&null!==(r=St())?n=[n,r]:(n=null,i=a);null!==n;)t.push(n),a=i,null!==(n=G())&&null!==(r=St())?n=[n,r]:(n=null,i=a);null!==t?e=[e,t]:(e=null,i=s)}else e=null,i=s;null!==e&&(u=e[0],e=void(Hn.event=u.join("").toLowerCase()));var u;null===e&&(i=o);return e},event_type:jt,From:function(){var e,t,n,r,o,s,a;o=i,s=i,null===(e=X())&&(e=vt());if(null!==e){for(t=[],a=i,null!==(n=G())&&null!==(r=qt())?n=[n,r]:(n=null,i=a);null!==n;)t.push(n),a=i,null!==(n=G())&&null!==(r=qt())?n=[n,r]:(n=null,i=a);null!==t?e=[e,t]:(e=null,i=s)}else e=null,i=s;null!==e&&(e=function(){var e=Hn.tag;try{Hn=new Fn(Hn.uri,Hn.display_name,Hn.params),e&&Hn.setParam("tag",e)}catch(e){Hn=-1}}());null===e&&(i=o);return e},from_param:qt,tag_param:Ft,Max_Forwards:function(){var e,t,n;if(n=i,null!==(t=f()))for(e=[];null!==t;)e.push(t),t=f();else e=null;null!==e&&(e=void(Hn=parseInt(e.join(""))));null===e&&(i=n);return e},Min_Expires:function(){var e,t;t=i,null!==(e=Tt())&&(e=void(Hn=e));null===e&&(i=t);return e},Name_Addr_Header:function(){var e,t,n,r,o,s,a,u,l,c;u=i,l=i,e=[],t=mt();for(;null!==t;)e.push(t),t=mt();if(null!==e)if(null!==(t=F()))if(null!==(n=Q()))if(null!==(r=q())){for(o=[],c=i,null!==(s=G())&&null!==(a=St())?s=[s,a]:(s=null,i=c);null!==s;)o.push(s),c=i,null!==(s=G())&&null!==(a=St())?s=[s,a]:(s=null,i=c);null!==o?e=[e,t,n,r,o]:(e=null,i=l)}else e=null,i=l;else e=null,i=l;else e=null,i=l;else e=null,i=l;null!==e&&(e=function(){try{Hn=new Fn(Hn.uri,Hn.display_name,Hn.params)}catch(e){Hn=-1}}());null===e&&(i=u);return e},Proxy_Authenticate:function(){return Ht()},challenge:Ht,other_challenge:Gt,auth_param:Bt,digest_cln:Wt,realm:Vt,realm_value:Kt,domain:zt,URI:Yt,nonce:$t,nonce_value:Jt,opaque:Xt,stale:Qt,algorithm:Zt,qop_options:en,qop_value:tn,Proxy_Require:function(){var e,t,n,r,o,s;if(o=i,null!==(e=x())){for(t=[],s=i,null!==(n=H())&&null!==(r=x())?n=[n,r]:(n=null,i=s);null!==n;)t.push(n),s=i,null!==(n=H())&&null!==(r=x())?n=[n,r]:(n=null,i=s);null!==t?e=[e,t]:(e=null,i=o)}else e=null,i=o;return e},Record_Route:function(){var e,t,n,r,o,s,a;if(o=i,s=i,null!==(e=nn())){for(t=[],a=i,null!==(n=H())&&null!==(r=nn())?n=[n,r]:(n=null,i=a);null!==n;)t.push(n),a=i,null!==(n=H())&&null!==(r=nn())?n=[n,r]:(n=null,i=a);null!==t?e=[e,t]:(e=null,i=s)}else e=null,i=s;null!==e&&(e=function(){var e,t;for(t=Hn.multi_header.length,e=0;e<t;e++)if(null===Hn.multi_header[e].parsed){Hn=null;break}Hn=null!==Hn?Hn.multi_header:-1}());null===e&&(i=o);return e},rec_route:nn,Reason:function(){var e,n,r,o,a,u,c;a=i,u=i,"sip"===t.substr(i,3).toLowerCase()?(e=t.substr(i,3),i+=3):(e=null,0===s&&l('"SIP"'));null===e&&(e=x());if(null!==e){for(n=[],c=i,null!==(r=G())&&null!==(o=rn())?r=[r,o]:(r=null,i=c);null!==r;)n.push(r),c=i,null!==(r=G())&&null!==(o=rn())?r=[r,o]:(r=null,i=c);null!==n?e=[e,n]:(e=null,i=u)}else e=null,i=u;null!==e&&(e=function(e,t){if(Hn.protocol=t.toLowerCase(),Hn.params||(Hn.params={}),Hn.params.text&&'"'===Hn.params.text[0]){var n=Hn.params.text;Hn.text=n.substring(1,n.length-1),delete Hn.params.text}}(0,e[0]));null===e&&(i=a);return e},reason_param:rn,reason_cause:on,Require:function(){var e,t,n,r,o,s;if(o=i,null!==(e=x())){for(t=[],s=i,null!==(n=H())&&null!==(r=x())?n=[n,r]:(n=null,i=s);null!==n;)t.push(n),s=i,null!==(n=H())&&null!==(r=x())?n=[n,r]:(n=null,i=s);null!==t?e=[e,t]:(e=null,i=o)}else e=null,i=o;return e},Route:function(){var e,t,n,r,o,s;if(o=i,null!==(e=sn())){for(t=[],s=i,null!==(n=H())&&null!==(r=sn())?n=[n,r]:(n=null,i=s);null!==n;)t.push(n),s=i,null!==(n=H())&&null!==(r=sn())?n=[n,r]:(n=null,i=s);null!==t?e=[e,t]:(e=null,i=o)}else e=null,i=o;return e},route_param:sn,Subscription_State:function(){var e,t,n,r,o,s;if(o=i,null!==(e=an())){for(t=[],s=i,null!==(n=G())&&null!==(r=un())?n=[n,r]:(n=null,i=s);null!==n;)t.push(n),s=i,null!==(n=G())&&null!==(r=un())?n=[n,r]:(n=null,i=s);null!==t?e=[e,t]:(e=null,i=o)}else e=null,i=o;return e},substate_value:an,subexp_params:un,event_reason_value:ln,Subject:function(){var e;return e=null!==(e=R())?e:""},Supported:function(){var e,t,n,r,o,s;if(o=i,null!==(e=x())){for(t=[],s=i,null!==(n=H())&&null!==(r=x())?n=[n,r]:(n=null,i=s);null!==n;)t.push(n),s=i,null!==(n=H())&&null!==(r=x())?n=[n,r]:(n=null,i=s);null!==t?e=[e,t]:(e=null,i=o)}else e=null,i=o;return e=null!==e?e:""},To:function(){var e,t,n,r,o,s,a;o=i,s=i,null===(e=X())&&(e=vt());if(null!==e){for(t=[],a=i,null!==(n=G())&&null!==(r=cn())?n=[n,r]:(n=null,i=a);null!==n;)t.push(n),a=i,null!==(n=G())&&null!==(r=cn())?n=[n,r]:(n=null,i=a);null!==t?e=[e,t]:(e=null,i=s)}else e=null,i=s;null!==e&&(e=function(){var e=Hn.tag;try{Hn=new Fn(Hn.uri,Hn.display_name,Hn.params),e&&Hn.setParam("tag",e)}catch(e){Hn=-1}}());null===e&&(i=o);return e},to_param:cn,Via:function(){var e,t,n,r,o,s;if(o=i,null!==(e=fn())){for(t=[],s=i,null!==(n=H())&&null!==(r=fn())?n=[n,r]:(n=null,i=s);null!==n;)t.push(n),s=i,null!==(n=H())&&null!==(r=fn())?n=[n,r]:(n=null,i=s);null!==t?e=[e,t]:(e=null,i=o)}else e=null,i=o;return e},via_param:fn,via_params:hn,via_ttl:dn,via_maddr:pn,via_received:_n,via_branch:vn,response_port:mn,rport:yn,sent_protocol:gn,protocol_name:bn,transport:Tn,sent_by:wn,via_host:Sn,via_port:En,ttl:Cn,WWW_Authenticate:function(){return Ht()},Session_Expires:function(){var e,t,n,r,o,s;if(o=i,null!==(e=An())){for(t=[],s=i,null!==(n=G())&&null!==(r=Rn())?n=[n,r]:(n=null,i=s);null!==n;)t.push(n),s=i,null!==(n=G())&&null!==(r=Rn())?n=[n,r]:(n=null,i=s);null!==t?e=[e,t]:(e=null,i=o)}else e=null,i=o;return e},s_e_expires:An,s_e_params:Rn,s_e_refresher:In,extension_header:function(){var e,t,n,r;r=i,null!==(e=x())&&null!==(t=A())&&null!==(n=On())?e=[e,t,n]:(e=null,i=r);return e},header_value:On,message_body:function(){var e,t;e=[],t=_();for(;null!==t;)e.push(t),t=_();return e},uuid_URI:function(){var e,n,r;r=i,"uuid:"===t.substr(i,5)?(e="uuid:",i+=5):(e=null,0===s&&l('"uuid:"'));null!==e&&null!==(n=kn())?e=[e,n]:(e=null,i=r);return e},uuid:kn,hex4:xn,hex8:Nn,hex12:Pn,Refer_To:function(){var e,t,n,r,o,s,a;o=i,s=i,null===(e=X())&&(e=vt());if(null!==e){for(t=[],a=i,null!==(n=G())&&null!==(r=St())?n=[n,r]:(n=null,i=a);null!==n;)t.push(n),a=i,null!==(n=G())&&null!==(r=St())?n=[n,r]:(n=null,i=a);null!==t?e=[e,t]:(e=null,i=s)}else e=null,i=s;null!==e&&(e=function(){try{Hn=new Fn(Hn.uri,Hn.display_name,Hn.params)}catch(e){Hn=-1}}());null===e&&(i=o);return e},Replaces:function(){var e,t,n,r,o,s;if(o=i,null!==(e=Dn())){for(t=[],s=i,null!==(n=G())&&null!==(r=Ln())?n=[n,r]:(n=null,i=s);null!==n;)t.push(n),s=i,null!==(n=G())&&null!==(r=Ln())?n=[n,r]:(n=null,i=s);null!==t?e=[e,t]:(e=null,i=o)}else e=null,i=o;return e},call_id:Dn,replaces_param:Ln,to_tag:Un,from_tag:Mn,early_flag:jn};if(void 0!==r){if(void 0===o[r])throw new Error("Invalid rule name: "+e(r)+".")}else r="CRLF";var i=0,s=0,a=0,u=[];function l(e){i<a||(i>a&&(a=i,u=[]),u.push(e))}function c(){var e;return"\r\n"===t.substr(i,2)?(e="\r\n",i+=2):(e=null,0===s&&l('"\\r\\n"')),e}function f(){var e;return/^[0-9]/.test(t.charAt(i))?(e=t.charAt(i),i++):(e=null,0===s&&l("[0-9]")),e}function h(){var e;return/^[a-zA-Z]/.test(t.charAt(i))?(e=t.charAt(i),i++):(e=null,0===s&&l("[a-zA-Z]")),e}function d(){var e;return/^[0-9a-fA-F]/.test(t.charAt(i))?(e=t.charAt(i),i++):(e=null,0===s&&l("[0-9a-fA-F]")),e}function p(){var e;return null===(e=m())&&(e=y()),e}function _(){var e;return/^[\0-\xFF]/.test(t.charAt(i))?(e=t.charAt(i),i++):(e=null,0===s&&l("[\\0-\\xFF]")),e}function v(){var e;return/^["]/.test(t.charAt(i))?(e=t.charAt(i),i++):(e=null,0===s&&l('["]')),e}function m(){var e;return 32===t.charCodeAt(i)?(e=" ",i++):(e=null,0===s&&l('" "')),e}function y(){var e;return 9===t.charCodeAt(i)?(e="\t",i++):(e=null,0===s&&l('"\\t"')),e}function g(){var e;return/^[a-zA-Z0-9]/.test(t.charAt(i))?(e=t.charAt(i),i++):(e=null,0===s&&l("[a-zA-Z0-9]")),e}function b(){var e;return 59===t.charCodeAt(i)?(e=";",i++):(e=null,0===s&&l('";"')),null===e&&(47===t.charCodeAt(i)?(e="/",i++):(e=null,0===s&&l('"/"')),null===e&&(63===t.charCodeAt(i)?(e="?",i++):(e=null,0===s&&l('"?"')),null===e&&(58===t.charCodeAt(i)?(e=":",i++):(e=null,0===s&&l('":"')),null===e&&(64===t.charCodeAt(i)?(e="@",i++):(e=null,0===s&&l('"@"')),null===e&&(38===t.charCodeAt(i)?(e="&",i++):(e=null,0===s&&l('"&"')),null===e&&(61===t.charCodeAt(i)?(e="=",i++):(e=null,0===s&&l('"="')),null===e&&(43===t.charCodeAt(i)?(e="+",i++):(e=null,0===s&&l('"+"')),null===e&&(36===t.charCodeAt(i)?(e="$",i++):(e=null,0===s&&l('"$"')),null===e&&(44===t.charCodeAt(i)?(e=",",i++):(e=null,0===s&&l('","'))))))))))),e}function T(){var e;return null===(e=g())&&(e=w()),e}function w(){var e;return 45===t.charCodeAt(i)?(e="-",i++):(e=null,0===s&&l('"-"')),null===e&&(95===t.charCodeAt(i)?(e="_",i++):(e=null,0===s&&l('"_"')),null===e&&(46===t.charCodeAt(i)?(e=".",i++):(e=null,0===s&&l('"."')),null===e&&(33===t.charCodeAt(i)?(e="!",i++):(e=null,0===s&&l('"!"')),null===e&&(126===t.charCodeAt(i)?(e="~",i++):(e=null,0===s&&l('"~"')),null===e&&(42===t.charCodeAt(i)?(e="*",i++):(e=null,0===s&&l('"*"')),null===e&&(39===t.charCodeAt(i)?(e="'",i++):(e=null,0===s&&l('"\'"')),null===e&&(40===t.charCodeAt(i)?(e="(",i++):(e=null,0===s&&l('"("')),null===e&&(41===t.charCodeAt(i)?(e=")",i++):(e=null,0===s&&l('")"')))))))))),e}function S(){var e,n,r,o,a;return o=i,a=i,37===t.charCodeAt(i)?(e="%",i++):(e=null,0===s&&l('"%"')),null!==e&&null!==(n=d())&&null!==(r=d())?e=[e,n,r]:(e=null,i=a),null!==e&&(e=e.join("")),null===e&&(i=o),e}function E(){var e,t,n,r,o,s;for(r=i,o=i,s=i,e=[],t=p();null!==t;)e.push(t),t=p();if(null!==e&&null!==(t=c())?e=[e,t]:(e=null,i=s),null!==(e=null!==e?e:"")){if(null!==(n=p()))for(t=[];null!==n;)t.push(n),n=p();else t=null;null!==t?e=[e,t]:(e=null,i=o)}else e=null,i=o;return null!==e&&(e=" "),null===e&&(i=r),e}function C(){var e;return e=null!==(e=E())?e:""}function A(){var e,n,r,o,a;for(o=i,a=i,e=[],null===(n=m())&&(n=y());null!==n;)e.push(n),null===(n=m())&&(n=y());return null!==e?(58===t.charCodeAt(i)?(n=":",i++):(n=null,0===s&&l('":"')),null!==n&&null!==(r=C())?e=[e,n,r]:(e=null,i=a)):(e=null,i=a),null!==e&&(e=":"),null===e&&(i=o),e}function R(){var e,n,r,o,s,a,u;if(s=i,a=i,null!==(n=I()))for(e=[];null!==n;)e.push(n),n=I();else e=null;if(null!==e){for(n=[],u=i,r=[],o=E();null!==o;)r.push(o),o=E();for(null!==r&&null!==(o=I())?r=[r,o]:(r=null,i=u);null!==r;){for(n.push(r),u=i,r=[],o=E();null!==o;)r.push(o),o=E();null!==r&&null!==(o=I())?r=[r,o]:(r=null,i=u)}null!==n?e=[e,n]:(e=null,i=a)}else e=null,i=a;return null!==e&&(e=function(e){return t.substring(i,e)}(s)),null===e&&(i=s),e}function I(){var e;return/^[!-~]/.test(t.charAt(i))?(e=t.charAt(i),i++):(e=null,0===s&&l("[!-~]")),null===e&&(e=O()),e}function O(){var e;return/^[\x80-\uFFFF]/.test(t.charAt(i))?(e=t.charAt(i),i++):(e=null,0===s&&l("[\\x80-\\uFFFF]")),e}function k(){var e;return/^[\x80-\xBF]/.test(t.charAt(i))?(e=t.charAt(i),i++):(e=null,0===s&&l("[\\x80-\\xBF]")),e}function x(){var e,n,r;if(r=i,null===(n=g())&&(45===t.charCodeAt(i)?(n="-",i++):(n=null,0===s&&l('"-"')),null===n&&(46===t.charCodeAt(i)?(n=".",i++):(n=null,0===s&&l('"."')),null===n&&(33===t.charCodeAt(i)?(n="!",i++):(n=null,0===s&&l('"!"')),null===n&&(37===t.charCodeAt(i)?(n="%",i++):(n=null,0===s&&l('"%"')),null===n&&(42===t.charCodeAt(i)?(n="*",i++):(n=null,0===s&&l('"*"')),null===n&&(95===t.charCodeAt(i)?(n="_",i++):(n=null,0===s&&l('"_"')),null===n&&(43===t.charCodeAt(i)?(n="+",i++):(n=null,0===s&&l('"+"')),null===n&&(96===t.charCodeAt(i)?(n="`",i++):(n=null,0===s&&l('"`"')),null===n&&(39===t.charCodeAt(i)?(n="'",i++):(n=null,0===s&&l('"\'"')),null===n&&(126===t.charCodeAt(i)?(n="~",i++):(n=null,0===s&&l('"~"')))))))))))),null!==n)for(e=[];null!==n;)e.push(n),null===(n=g())&&(45===t.charCodeAt(i)?(n="-",i++):(n=null,0===s&&l('"-"')),null===n&&(46===t.charCodeAt(i)?(n=".",i++):(n=null,0===s&&l('"."')),null===n&&(33===t.charCodeAt(i)?(n="!",i++):(n=null,0===s&&l('"!"')),null===n&&(37===t.charCodeAt(i)?(n="%",i++):(n=null,0===s&&l('"%"')),null===n&&(42===t.charCodeAt(i)?(n="*",i++):(n=null,0===s&&l('"*"')),null===n&&(95===t.charCodeAt(i)?(n="_",i++):(n=null,0===s&&l('"_"')),null===n&&(43===t.charCodeAt(i)?(n="+",i++):(n=null,0===s&&l('"+"')),null===n&&(96===t.charCodeAt(i)?(n="`",i++):(n=null,0===s&&l('"`"')),null===n&&(39===t.charCodeAt(i)?(n="'",i++):(n=null,0===s&&l('"\'"')),null===n&&(126===t.charCodeAt(i)?(n="~",i++):(n=null,0===s&&l('"~"'))))))))))));else e=null;return null!==e&&(e=function(e){return t.substring(i,e)}(r)),null===e&&(i=r),e}function N(){var e,n,r;if(r=i,null===(n=g())&&(45===t.charCodeAt(i)?(n="-",i++):(n=null,0===s&&l('"-"')),null===n&&(33===t.charCodeAt(i)?(n="!",i++):(n=null,0===s&&l('"!"')),null===n&&(37===t.charCodeAt(i)?(n="%",i++):(n=null,0===s&&l('"%"')),null===n&&(42===t.charCodeAt(i)?(n="*",i++):(n=null,0===s&&l('"*"')),null===n&&(95===t.charCodeAt(i)?(n="_",i++):(n=null,0===s&&l('"_"')),null===n&&(43===t.charCodeAt(i)?(n="+",i++):(n=null,0===s&&l('"+"')),null===n&&(96===t.charCodeAt(i)?(n="`",i++):(n=null,0===s&&l('"`"')),null===n&&(39===t.charCodeAt(i)?(n="'",i++):(n=null,0===s&&l('"\'"')),null===n&&(126===t.charCodeAt(i)?(n="~",i++):(n=null,0===s&&l('"~"'))))))))))),null!==n)for(e=[];null!==n;)e.push(n),null===(n=g())&&(45===t.charCodeAt(i)?(n="-",i++):(n=null,0===s&&l('"-"')),null===n&&(33===t.charCodeAt(i)?(n="!",i++):(n=null,0===s&&l('"!"')),null===n&&(37===t.charCodeAt(i)?(n="%",i++):(n=null,0===s&&l('"%"')),null===n&&(42===t.charCodeAt(i)?(n="*",i++):(n=null,0===s&&l('"*"')),null===n&&(95===t.charCodeAt(i)?(n="_",i++):(n=null,0===s&&l('"_"')),null===n&&(43===t.charCodeAt(i)?(n="+",i++):(n=null,0===s&&l('"+"')),null===n&&(96===t.charCodeAt(i)?(n="`",i++):(n=null,0===s&&l('"`"')),null===n&&(39===t.charCodeAt(i)?(n="'",i++):(n=null,0===s&&l('"\'"')),null===n&&(126===t.charCodeAt(i)?(n="~",i++):(n=null,0===s&&l('"~"')))))))))));else e=null;return null!==e&&(e=function(e){return t.substring(i,e)}(r)),null===e&&(i=r),e}function P(){var e,n,r;if(r=i,null===(n=g())&&(45===t.charCodeAt(i)?(n="-",i++):(n=null,0===s&&l('"-"')),null===n&&(46===t.charCodeAt(i)?(n=".",i++):(n=null,0===s&&l('"."')),null===n&&(33===t.charCodeAt(i)?(n="!",i++):(n=null,0===s&&l('"!"')),null===n&&(37===t.charCodeAt(i)?(n="%",i++):(n=null,0===s&&l('"%"')),null===n&&(42===t.charCodeAt(i)?(n="*",i++):(n=null,0===s&&l('"*"')),null===n&&(95===t.charCodeAt(i)?(n="_",i++):(n=null,0===s&&l('"_"')),null===n&&(43===t.charCodeAt(i)?(n="+",i++):(n=null,0===s&&l('"+"')),null===n&&(96===t.charCodeAt(i)?(n="`",i++):(n=null,0===s&&l('"`"')),null===n&&(39===t.charCodeAt(i)?(n="'",i++):(n=null,0===s&&l('"\'"')),null===n&&(126===t.charCodeAt(i)?(n="~",i++):(n=null,0===s&&l('"~"')),null===n&&(40===t.charCodeAt(i)?(n="(",i++):(n=null,0===s&&l('"("')),null===n&&(41===t.charCodeAt(i)?(n=")",i++):(n=null,0===s&&l('")"')),null===n&&(60===t.charCodeAt(i)?(n="<",i++):(n=null,0===s&&l('"<"')),null===n&&(62===t.charCodeAt(i)?(n=">",i++):(n=null,0===s&&l('">"')),null===n&&(58===t.charCodeAt(i)?(n=":",i++):(n=null,0===s&&l('":"')),null===n&&(92===t.charCodeAt(i)?(n="\\",i++):(n=null,0===s&&l('"\\\\"')),null===n&&null===(n=v())&&(47===t.charCodeAt(i)?(n="/",i++):(n=null,0===s&&l('"/"')),null===n&&(91===t.charCodeAt(i)?(n="[",i++):(n=null,0===s&&l('"["')),null===n&&(93===t.charCodeAt(i)?(n="]",i++):(n=null,0===s&&l('"]"')),null===n&&(63===t.charCodeAt(i)?(n="?",i++):(n=null,0===s&&l('"?"')),null===n&&(123===t.charCodeAt(i)?(n="{",i++):(n=null,0===s&&l('"{"')),null===n&&(125===t.charCodeAt(i)?(n="}",i++):(n=null,0===s&&l('"}"')))))))))))))))))))))))),null!==n)for(e=[];null!==n;)e.push(n),null===(n=g())&&(45===t.charCodeAt(i)?(n="-",i++):(n=null,0===s&&l('"-"')),null===n&&(46===t.charCodeAt(i)?(n=".",i++):(n=null,0===s&&l('"."')),null===n&&(33===t.charCodeAt(i)?(n="!",i++):(n=null,0===s&&l('"!"')),null===n&&(37===t.charCodeAt(i)?(n="%",i++):(n=null,0===s&&l('"%"')),null===n&&(42===t.charCodeAt(i)?(n="*",i++):(n=null,0===s&&l('"*"')),null===n&&(95===t.charCodeAt(i)?(n="_",i++):(n=null,0===s&&l('"_"')),null===n&&(43===t.charCodeAt(i)?(n="+",i++):(n=null,0===s&&l('"+"')),null===n&&(96===t.charCodeAt(i)?(n="`",i++):(n=null,0===s&&l('"`"')),null===n&&(39===t.charCodeAt(i)?(n="'",i++):(n=null,0===s&&l('"\'"')),null===n&&(126===t.charCodeAt(i)?(n="~",i++):(n=null,0===s&&l('"~"')),null===n&&(40===t.charCodeAt(i)?(n="(",i++):(n=null,0===s&&l('"("')),null===n&&(41===t.charCodeAt(i)?(n=")",i++):(n=null,0===s&&l('")"')),null===n&&(60===t.charCodeAt(i)?(n="<",i++):(n=null,0===s&&l('"<"')),null===n&&(62===t.charCodeAt(i)?(n=">",i++):(n=null,0===s&&l('">"')),null===n&&(58===t.charCodeAt(i)?(n=":",i++):(n=null,0===s&&l('":"')),null===n&&(92===t.charCodeAt(i)?(n="\\",i++):(n=null,0===s&&l('"\\\\"')),null===n&&null===(n=v())&&(47===t.charCodeAt(i)?(n="/",i++):(n=null,0===s&&l('"/"')),null===n&&(91===t.charCodeAt(i)?(n="[",i++):(n=null,0===s&&l('"["')),null===n&&(93===t.charCodeAt(i)?(n="]",i++):(n=null,0===s&&l('"]"')),null===n&&(63===t.charCodeAt(i)?(n="?",i++):(n=null,0===s&&l('"?"')),null===n&&(123===t.charCodeAt(i)?(n="{",i++):(n=null,0===s&&l('"{"')),null===n&&(125===t.charCodeAt(i)?(n="}",i++):(n=null,0===s&&l('"}"'))))))))))))))))))))))));else e=null;return null!==e&&(e=function(e){return t.substring(i,e)}(r)),null===e&&(i=r),e}function D(){var e,n,r,o,a;return o=i,a=i,null!==(e=C())?(42===t.charCodeAt(i)?(n="*",i++):(n=null,0===s&&l('"*"')),null!==n&&null!==(r=C())?e=[e,n,r]:(e=null,i=a)):(e=null,i=a),null!==e&&(e="*"),null===e&&(i=o),e}function L(){var e,n,r,o,a;return o=i,a=i,null!==(e=C())?(47===t.charCodeAt(i)?(n="/",i++):(n=null,0===s&&l('"/"')),null!==n&&null!==(r=C())?e=[e,n,r]:(e=null,i=a)):(e=null,i=a),null!==e&&(e="/"),null===e&&(i=o),e}function U(){var e,n,r,o,a;return o=i,a=i,null!==(e=C())?(61===t.charCodeAt(i)?(n="=",i++):(n=null,0===s&&l('"="')),null!==n&&null!==(r=C())?e=[e,n,r]:(e=null,i=a)):(e=null,i=a),null!==e&&(e="="),null===e&&(i=o),e}function M(){var e,n,r,o,a;return o=i,a=i,null!==(e=C())?(40===t.charCodeAt(i)?(n="(",i++):(n=null,0===s&&l('"("')),null!==n&&null!==(r=C())?e=[e,n,r]:(e=null,i=a)):(e=null,i=a),null!==e&&(e="("),null===e&&(i=o),e}function j(){var e,n,r,o,a;return o=i,a=i,null!==(e=C())?(41===t.charCodeAt(i)?(n=")",i++):(n=null,0===s&&l('")"')),null!==n&&null!==(r=C())?e=[e,n,r]:(e=null,i=a)):(e=null,i=a),null!==e&&(e=")"),null===e&&(i=o),e}function q(){var e,n,r,o;return r=i,o=i,62===t.charCodeAt(i)?(e=">",i++):(e=null,0===s&&l('">"')),null!==e&&null!==(n=C())?e=[e,n]:(e=null,i=o),null!==e&&(e=">"),null===e&&(i=r),e}function F(){var e,n,r,o;return r=i,o=i,null!==(e=C())?(60===t.charCodeAt(i)?(n="<",i++):(n=null,0===s&&l('"<"')),null!==n?e=[e,n]:(e=null,i=o)):(e=null,i=o),null!==e&&(e="<"),null===e&&(i=r),e}function H(){var e,n,r,o,a;return o=i,a=i,null!==(e=C())?(44===t.charCodeAt(i)?(n=",",i++):(n=null,0===s&&l('","')),null!==n&&null!==(r=C())?e=[e,n,r]:(e=null,i=a)):(e=null,i=a),null!==e&&(e=","),null===e&&(i=o),e}function G(){var e,n,r,o,a;return o=i,a=i,null!==(e=C())?(59===t.charCodeAt(i)?(n=";",i++):(n=null,0===s&&l('";"')),null!==n&&null!==(r=C())?e=[e,n,r]:(e=null,i=a)):(e=null,i=a),null!==e&&(e=";"),null===e&&(i=o),e}function B(){var e,n,r,o,a;return o=i,a=i,null!==(e=C())?(58===t.charCodeAt(i)?(n=":",i++):(n=null,0===s&&l('":"')),null!==n&&null!==(r=C())?e=[e,n,r]:(e=null,i=a)):(e=null,i=a),null!==e&&(e=":"),null===e&&(i=o),e}function W(){var e,t,n,r;return n=i,r=i,null!==(e=C())&&null!==(t=v())?e=[e,t]:(e=null,i=r),null!==e&&(e='"'),null===e&&(i=n),e}function V(){var e,t,n,r;return n=i,r=i,null!==(e=v())&&null!==(t=C())?e=[e,t]:(e=null,i=r),null!==e&&(e='"'),null===e&&(i=n),e}function K(){var e;return/^[!-']/.test(t.charAt(i))?(e=t.charAt(i),i++):(e=null,0===s&&l("[!-']")),null===e&&(/^[*-[]/.test(t.charAt(i))?(e=t.charAt(i),i++):(e=null,0===s&&l("[*-[]")),null===e&&(/^[\]-~]/.test(t.charAt(i))?(e=t.charAt(i),i++):(e=null,0===s&&l("[\\]-~]")),null===e&&null===(e=O())&&(e=E()))),e}function z(){var e,n,r,o,s,a;if(s=i,a=i,null!==(e=C()))if(null!==(n=v())){for(r=[],null===(o=$())&&(o=J());null!==o;)r.push(o),null===(o=$())&&(o=J());null!==r&&null!==(o=v())?e=[e,n,r,o]:(e=null,i=a)}else e=null,i=a;else e=null,i=a;return null!==e&&(e=function(e){return t.substring(i,e)}(s)),null===e&&(i=s),e}function Y(){var e,n,r,o,s,a;if(s=i,a=i,null!==(e=C()))if(null!==(n=v())){for(r=[],null===(o=$())&&(o=J());null!==o;)r.push(o),null===(o=$())&&(o=J());null!==r&&null!==(o=v())?e=[e,n,r,o]:(e=null,i=a)}else e=null,i=a;else e=null,i=a;return null!==e&&(e=function(e){var n=t.substring(i,e).trim();return n.substring(1,n.length-1).replace(/\\([\x00-\x09\x0b-\x0c\x0e-\x7f])/g,"$1")}(s)),null===e&&(i=s),e}function $(){var e;return null===(e=E())&&(33===t.charCodeAt(i)?(e="!",i++):(e=null,0===s&&l('"!"')),null===e&&(/^[#-[]/.test(t.charAt(i))?(e=t.charAt(i),i++):(e=null,0===s&&l("[#-[]")),null===e&&(/^[\]-~]/.test(t.charAt(i))?(e=t.charAt(i),i++):(e=null,0===s&&l("[\\]-~]")),null===e&&(e=O())))),e}function J(){var e,n,r;return r=i,92===t.charCodeAt(i)?(e="\\",i++):(e=null,0===s&&l('"\\\\"')),null!==e?(/^[\0-\t]/.test(t.charAt(i))?(n=t.charAt(i),i++):(n=null,0===s&&l("[\\0-\\t]")),null===n&&(/^[\x0B-\f]/.test(t.charAt(i))?(n=t.charAt(i),i++):(n=null,0===s&&l("[\\x0B-\\f]")),null===n&&(/^[\x0E-]/.test(t.charAt(i))?(n=t.charAt(i),i++):(n=null,0===s&&l("[\\x0E-]")))),null!==n?e=[e,n]:(e=null,i=r)):(e=null,i=r),e}function X(){var e,n,r,o,a,u;return a=i,u=i,null!==(e=Z())?(58===t.charCodeAt(i)?(n=":",i++):(n=null,0===s&&l('":"')),null!==n&&null!==(r=null!==(r=ne())?r:"")&&null!==(o=se())?e=[e,n,r,o]:(e=null,i=u)):(e=null,i=u),null!==e&&(e=function(){try{Hn.uri=new qn(Hn.scheme,Hn.user,Hn.host,Hn.port),delete Hn.scheme,delete Hn.user,delete Hn.host,delete Hn.host_type,delete Hn.port}catch(e){Hn=-1}}()),null===e&&(i=a),e}function Q(){var e,n,o,a,u,c,f,h;return f=i,h=i,null!==(e=Z())?(58===t.charCodeAt(i)?(n=":",i++):(n=null,0===s&&l('":"')),null!==n&&null!==(o=null!==(o=ne())?o:"")&&null!==(a=se())&&null!==(u=ye())&&null!==(c=null!==(c=xe())?c:"")?e=[e,n,o,a,u,c]:(e=null,i=h)):(e=null,i=h),null!==e&&(e=function(){try{Hn.uri=new qn(Hn.scheme,Hn.user,Hn.host,Hn.port,Hn.uri_params,Hn.uri_headers),delete Hn.scheme,delete Hn.user,delete Hn.host,delete Hn.host_type,delete Hn.port,delete Hn.uri_params,"SIP_URI"===r&&(Hn=Hn.uri)}catch(e){Hn=-1}}()),null===e&&(i=f),e}function Z(){var e;return null===(e=ee())&&(e=te()),e}function ee(){var e,n,r;return n=i,"sips"===t.substr(i,4).toLowerCase()?(e=t.substr(i,4),i+=4):(e=null,0===s&&l('"sips"')),null!==e&&(r=e,e=void(Hn.scheme=r.toLowerCase())),null===e&&(i=n),e}function te(){var e,n,r;return n=i,"sip"===t.substr(i,3).toLowerCase()?(e=t.substr(i,3),i+=3):(e=null,0===s&&l('"sip"')),null!==e&&(r=e,e=void(Hn.scheme=r.toLowerCase())),null===e&&(i=n),e}function ne(){var e,n,r,o,a,u;return o=i,a=i,null!==(e=re())?(u=i,58===t.charCodeAt(i)?(n=":",i++):(n=null,0===s&&l('":"')),null!==n&&null!==(r=ie())?n=[n,r]:(n=null,i=u),null!==(n=null!==n?n:"")?(64===t.charCodeAt(i)?(r="@",i++):(r=null,0===s&&l('"@"')),null!==r?e=[e,n,r]:(e=null,i=a)):(e=null,i=a)):(e=null,i=a),null!==e&&(e=function(e){Hn.user=decodeURIComponent(t.substring(i-1,e))}(o)),null===e&&(i=o),e}function re(){var e,t;if(null===(t=T())&&null===(t=S())&&(t=oe()),null!==t)for(e=[];null!==t;)e.push(t),null===(t=T())&&null===(t=S())&&(t=oe());else e=null;return e}function oe(){var e;return 38===t.charCodeAt(i)?(e="&",i++):(e=null,0===s&&l('"&"')),null===e&&(61===t.charCodeAt(i)?(e="=",i++):(e=null,0===s&&l('"="')),null===e&&(43===t.charCodeAt(i)?(e="+",i++):(e=null,0===s&&l('"+"')),null===e&&(36===t.charCodeAt(i)?(e="$",i++):(e=null,0===s&&l('"$"')),null===e&&(44===t.charCodeAt(i)?(e=",",i++):(e=null,0===s&&l('","')),null===e&&(59===t.charCodeAt(i)?(e=";",i++):(e=null,0===s&&l('";"')),null===e&&(63===t.charCodeAt(i)?(e="?",i++):(e=null,0===s&&l('"?"')),null===e&&(47===t.charCodeAt(i)?(e="/",i++):(e=null,0===s&&l('"/"'))))))))),e}function ie(){var e,n,r;for(r=i,e=[],null===(n=T())&&null===(n=S())&&(38===t.charCodeAt(i)?(n="&",i++):(n=null,0===s&&l('"&"')),null===n&&(61===t.charCodeAt(i)?(n="=",i++):(n=null,0===s&&l('"="')),null===n&&(43===t.charCodeAt(i)?(n="+",i++):(n=null,0===s&&l('"+"')),null===n&&(36===t.charCodeAt(i)?(n="$",i++):(n=null,0===s&&l('"$"')),null===n&&(44===t.charCodeAt(i)?(n=",",i++):(n=null,0===s&&l('","')))))));null!==n;)e.push(n),null===(n=T())&&null===(n=S())&&(38===t.charCodeAt(i)?(n="&",i++):(n=null,0===s&&l('"&"')),null===n&&(61===t.charCodeAt(i)?(n="=",i++):(n=null,0===s&&l('"="')),null===n&&(43===t.charCodeAt(i)?(n="+",i++):(n=null,0===s&&l('"+"')),null===n&&(36===t.charCodeAt(i)?(n="$",i++):(n=null,0===s&&l('"$"')),null===n&&(44===t.charCodeAt(i)?(n=",",i++):(n=null,0===s&&l('","')))))));return null!==e&&(e=function(e){Hn.password=t.substring(i,e)}(r)),null===e&&(i=r),e}function se(){var e,n,r,o,a;return o=i,null!==(e=ae())?(a=i,58===t.charCodeAt(i)?(n=":",i++):(n=null,0===s&&l('":"')),null!==n&&null!==(r=me())?n=[n,r]:(n=null,i=a),null!==(n=null!==n?n:"")?e=[e,n]:(e=null,i=o)):(e=null,i=o),e}function ae(){var e,n;return n=i,null===(e=ue())&&null===(e=_e())&&(e=fe()),null!==e&&(e=function(e){return Hn.host=t.substring(i,e).toLowerCase(),Hn.host}(n)),null===e&&(i=n),e}function ue(){var e,n,r,o,a,u;for(o=i,a=i,e=[],u=i,null!==(n=le())?(46===t.charCodeAt(i)?(r=".",i++):(r=null,0===s&&l('"."')),null!==r?n=[n,r]:(n=null,i=u)):(n=null,i=u);null!==n;)e.push(n),u=i,null!==(n=le())?(46===t.charCodeAt(i)?(r=".",i++):(r=null,0===s&&l('"."')),null!==r?n=[n,r]:(n=null,i=u)):(n=null,i=u);return null!==e&&null!==(n=ce())?(46===t.charCodeAt(i)?(r=".",i++):(r=null,0===s&&l('"."')),null!==(r=null!==r?r:"")?e=[e,n,r]:(e=null,i=a)):(e=null,i=a),null!==e&&(e=function(e){return Hn.host_type="domain",t.substring(i,e)}(o)),null===e&&(i=o),e}function le(){var e,n,r,o;if(o=i,null!==(e=g())){for(n=[],null===(r=g())&&(45===t.charCodeAt(i)?(r="-",i++):(r=null,0===s&&l('"-"')),null===r&&(95===t.charCodeAt(i)?(r="_",i++):(r=null,0===s&&l('"_"'))));null!==r;)n.push(r),null===(r=g())&&(45===t.charCodeAt(i)?(r="-",i++):(r=null,0===s&&l('"-"')),null===r&&(95===t.charCodeAt(i)?(r="_",i++):(r=null,0===s&&l('"_"'))));null!==n?e=[e,n]:(e=null,i=o)}else e=null,i=o;return e}function ce(){var e,n,r,o;if(o=i,null!==(e=h())){for(n=[],null===(r=g())&&(45===t.charCodeAt(i)?(r="-",i++):(r=null,0===s&&l('"-"')),null===r&&(95===t.charCodeAt(i)?(r="_",i++):(r=null,0===s&&l('"_"'))));null!==r;)n.push(r),null===(r=g())&&(45===t.charCodeAt(i)?(r="-",i++):(r=null,0===s&&l('"-"')),null===r&&(95===t.charCodeAt(i)?(r="_",i++):(r=null,0===s&&l('"_"'))));null!==n?e=[e,n]:(e=null,i=o)}else e=null,i=o;return e}function fe(){var e,n,r,o,a;return o=i,a=i,91===t.charCodeAt(i)?(e="[",i++):(e=null,0===s&&l('"["')),null!==e&&null!==(n=he())?(93===t.charCodeAt(i)?(r="]",i++):(r=null,0===s&&l('"]"')),null!==r?e=[e,n,r]:(e=null,i=a)):(e=null,i=a),null!==e&&(e=function(e){return Hn.host_type="IPv6",t.substring(i,e)}(o)),null===e&&(i=o),e}function he(){var e,n,r,o,a,u,c,f,h,d,p,_,v,m,y,g;return m=i,y=i,null!==(e=de())?(58===t.charCodeAt(i)?(n=":",i++):(n=null,0===s&&l('":"')),null!==n&&null!==(r=de())?(58===t.charCodeAt(i)?(o=":",i++):(o=null,0===s&&l('":"')),null!==o&&null!==(a=de())?(58===t.charCodeAt(i)?(u=":",i++):(u=null,0===s&&l('":"')),null!==u&&null!==(c=de())?(58===t.charCodeAt(i)?(f=":",i++):(f=null,0===s&&l('":"')),null!==f&&null!==(h=de())?(58===t.charCodeAt(i)?(d=":",i++):(d=null,0===s&&l('":"')),null!==d&&null!==(p=de())?(58===t.charCodeAt(i)?(_=":",i++):(_=null,0===s&&l('":"')),null!==_&&null!==(v=pe())?e=[e,n,r,o,a,u,c,f,h,d,p,_,v]:(e=null,i=y)):(e=null,i=y)):(e=null,i=y)):(e=null,i=y)):(e=null,i=y)):(e=null,i=y)):(e=null,i=y),null===e&&(y=i,"::"===t.substr(i,2)?(e="::",i+=2):(e=null,0===s&&l('"::"')),null!==e&&null!==(n=de())?(58===t.charCodeAt(i)?(r=":",i++):(r=null,0===s&&l('":"')),null!==r&&null!==(o=de())?(58===t.charCodeAt(i)?(a=":",i++):(a=null,0===s&&l('":"')),null!==a&&null!==(u=de())?(58===t.charCodeAt(i)?(c=":",i++):(c=null,0===s&&l('":"')),null!==c&&null!==(f=de())?(58===t.charCodeAt(i)?(h=":",i++):(h=null,0===s&&l('":"')),null!==h&&null!==(d=de())?(58===t.charCodeAt(i)?(p=":",i++):(p=null,0===s&&l('":"')),null!==p&&null!==(_=pe())?e=[e,n,r,o,a,u,c,f,h,d,p,_]:(e=null,i=y)):(e=null,i=y)):(e=null,i=y)):(e=null,i=y)):(e=null,i=y)):(e=null,i=y),null===e&&(y=i,"::"===t.substr(i,2)?(e="::",i+=2):(e=null,0===s&&l('"::"')),null!==e&&null!==(n=de())?(58===t.charCodeAt(i)?(r=":",i++):(r=null,0===s&&l('":"')),null!==r&&null!==(o=de())?(58===t.charCodeAt(i)?(a=":",i++):(a=null,0===s&&l('":"')),null!==a&&null!==(u=de())?(58===t.charCodeAt(i)?(c=":",i++):(c=null,0===s&&l('":"')),null!==c&&null!==(f=de())?(58===t.charCodeAt(i)?(h=":",i++):(h=null,0===s&&l('":"')),null!==h&&null!==(d=pe())?e=[e,n,r,o,a,u,c,f,h,d]:(e=null,i=y)):(e=null,i=y)):(e=null,i=y)):(e=null,i=y)):(e=null,i=y),null===e&&(y=i,"::"===t.substr(i,2)?(e="::",i+=2):(e=null,0===s&&l('"::"')),null!==e&&null!==(n=de())?(58===t.charCodeAt(i)?(r=":",i++):(r=null,0===s&&l('":"')),null!==r&&null!==(o=de())?(58===t.charCodeAt(i)?(a=":",i++):(a=null,0===s&&l('":"')),null!==a&&null!==(u=de())?(58===t.charCodeAt(i)?(c=":",i++):(c=null,0===s&&l('":"')),null!==c&&null!==(f=pe())?e=[e,n,r,o,a,u,c,f]:(e=null,i=y)):(e=null,i=y)):(e=null,i=y)):(e=null,i=y),null===e&&(y=i,"::"===t.substr(i,2)?(e="::",i+=2):(e=null,0===s&&l('"::"')),null!==e&&null!==(n=de())?(58===t.charCodeAt(i)?(r=":",i++):(r=null,0===s&&l('":"')),null!==r&&null!==(o=de())?(58===t.charCodeAt(i)?(a=":",i++):(a=null,0===s&&l('":"')),null!==a&&null!==(u=pe())?e=[e,n,r,o,a,u]:(e=null,i=y)):(e=null,i=y)):(e=null,i=y),null===e&&(y=i,"::"===t.substr(i,2)?(e="::",i+=2):(e=null,0===s&&l('"::"')),null!==e&&null!==(n=de())?(58===t.charCodeAt(i)?(r=":",i++):(r=null,0===s&&l('":"')),null!==r&&null!==(o=pe())?e=[e,n,r,o]:(e=null,i=y)):(e=null,i=y),null===e&&(y=i,"::"===t.substr(i,2)?(e="::",i+=2):(e=null,0===s&&l('"::"')),null!==e&&null!==(n=pe())?e=[e,n]:(e=null,i=y),null===e&&(y=i,"::"===t.substr(i,2)?(e="::",i+=2):(e=null,0===s&&l('"::"')),null!==e&&null!==(n=de())?e=[e,n]:(e=null,i=y),null===e&&(y=i,null!==(e=de())?("::"===t.substr(i,2)?(n="::",i+=2):(n=null,0===s&&l('"::"')),null!==n&&null!==(r=de())?(58===t.charCodeAt(i)?(o=":",i++):(o=null,0===s&&l('":"')),null!==o&&null!==(a=de())?(58===t.charCodeAt(i)?(u=":",i++):(u=null,0===s&&l('":"')),null!==u&&null!==(c=de())?(58===t.charCodeAt(i)?(f=":",i++):(f=null,0===s&&l('":"')),null!==f&&null!==(h=de())?(58===t.charCodeAt(i)?(d=":",i++):(d=null,0===s&&l('":"')),null!==d&&null!==(p=pe())?e=[e,n,r,o,a,u,c,f,h,d,p]:(e=null,i=y)):(e=null,i=y)):(e=null,i=y)):(e=null,i=y)):(e=null,i=y)):(e=null,i=y),null===e&&(y=i,null!==(e=de())?(g=i,58===t.charCodeAt(i)?(n=":",i++):(n=null,0===s&&l('":"')),null!==n&&null!==(r=de())?n=[n,r]:(n=null,i=g),null!==(n=null!==n?n:"")?("::"===t.substr(i,2)?(r="::",i+=2):(r=null,0===s&&l('"::"')),null!==r&&null!==(o=de())?(58===t.charCodeAt(i)?(a=":",i++):(a=null,0===s&&l('":"')),null!==a&&null!==(u=de())?(58===t.charCodeAt(i)?(c=":",i++):(c=null,0===s&&l('":"')),null!==c&&null!==(f=de())?(58===t.charCodeAt(i)?(h=":",i++):(h=null,0===s&&l('":"')),null!==h&&null!==(d=pe())?e=[e,n,r,o,a,u,c,f,h,d]:(e=null,i=y)):(e=null,i=y)):(e=null,i=y)):(e=null,i=y)):(e=null,i=y)):(e=null,i=y),null===e&&(y=i,null!==(e=de())?(g=i,58===t.charCodeAt(i)?(n=":",i++):(n=null,0===s&&l('":"')),null!==n&&null!==(r=de())?n=[n,r]:(n=null,i=g),null!==(n=null!==n?n:"")?(g=i,58===t.charCodeAt(i)?(r=":",i++):(r=null,0===s&&l('":"')),null!==r&&null!==(o=de())?r=[r,o]:(r=null,i=g),null!==(r=null!==r?r:"")?("::"===t.substr(i,2)?(o="::",i+=2):(o=null,0===s&&l('"::"')),null!==o&&null!==(a=de())?(58===t.charCodeAt(i)?(u=":",i++):(u=null,0===s&&l('":"')),null!==u&&null!==(c=de())?(58===t.charCodeAt(i)?(f=":",i++):(f=null,0===s&&l('":"')),null!==f&&null!==(h=pe())?e=[e,n,r,o,a,u,c,f,h]:(e=null,i=y)):(e=null,i=y)):(e=null,i=y)):(e=null,i=y)):(e=null,i=y)):(e=null,i=y),null===e&&(y=i,null!==(e=de())?(g=i,58===t.charCodeAt(i)?(n=":",i++):(n=null,0===s&&l('":"')),null!==n&&null!==(r=de())?n=[n,r]:(n=null,i=g),null!==(n=null!==n?n:"")?(g=i,58===t.charCodeAt(i)?(r=":",i++):(r=null,0===s&&l('":"')),null!==r&&null!==(o=de())?r=[r,o]:(r=null,i=g),null!==(r=null!==r?r:"")?(g=i,58===t.charCodeAt(i)?(o=":",i++):(o=null,0===s&&l('":"')),null!==o&&null!==(a=de())?o=[o,a]:(o=null,i=g),null!==(o=null!==o?o:"")?("::"===t.substr(i,2)?(a="::",i+=2):(a=null,0===s&&l('"::"')),null!==a&&null!==(u=de())?(58===t.charCodeAt(i)?(c=":",i++):(c=null,0===s&&l('":"')),null!==c&&null!==(f=pe())?e=[e,n,r,o,a,u,c,f]:(e=null,i=y)):(e=null,i=y)):(e=null,i=y)):(e=null,i=y)):(e=null,i=y)):(e=null,i=y),null===e&&(y=i,null!==(e=de())?(g=i,58===t.charCodeAt(i)?(n=":",i++):(n=null,0===s&&l('":"')),null!==n&&null!==(r=de())?n=[n,r]:(n=null,i=g),null!==(n=null!==n?n:"")?(g=i,58===t.charCodeAt(i)?(r=":",i++):(r=null,0===s&&l('":"')),null!==r&&null!==(o=de())?r=[r,o]:(r=null,i=g),null!==(r=null!==r?r:"")?(g=i,58===t.charCodeAt(i)?(o=":",i++):(o=null,0===s&&l('":"')),null!==o&&null!==(a=de())?o=[o,a]:(o=null,i=g),null!==(o=null!==o?o:"")?(g=i,58===t.charCodeAt(i)?(a=":",i++):(a=null,0===s&&l('":"')),null!==a&&null!==(u=de())?a=[a,u]:(a=null,i=g),null!==(a=null!==a?a:"")?("::"===t.substr(i,2)?(u="::",i+=2):(u=null,0===s&&l('"::"')),null!==u&&null!==(c=pe())?e=[e,n,r,o,a,u,c]:(e=null,i=y)):(e=null,i=y)):(e=null,i=y)):(e=null,i=y)):(e=null,i=y)):(e=null,i=y),null===e&&(y=i,null!==(e=de())?(g=i,58===t.charCodeAt(i)?(n=":",i++):(n=null,0===s&&l('":"')),null!==n&&null!==(r=de())?n=[n,r]:(n=null,i=g),null!==(n=null!==n?n:"")?(g=i,58===t.charCodeAt(i)?(r=":",i++):(r=null,0===s&&l('":"')),null!==r&&null!==(o=de())?r=[r,o]:(r=null,i=g),null!==(r=null!==r?r:"")?(g=i,58===t.charCodeAt(i)?(o=":",i++):(o=null,0===s&&l('":"')),null!==o&&null!==(a=de())?o=[o,a]:(o=null,i=g),null!==(o=null!==o?o:"")?(g=i,58===t.charCodeAt(i)?(a=":",i++):(a=null,0===s&&l('":"')),null!==a&&null!==(u=de())?a=[a,u]:(a=null,i=g),null!==(a=null!==a?a:"")?(g=i,58===t.charCodeAt(i)?(u=":",i++):(u=null,0===s&&l('":"')),null!==u&&null!==(c=de())?u=[u,c]:(u=null,i=g),null!==(u=null!==u?u:"")?("::"===t.substr(i,2)?(c="::",i+=2):(c=null,0===s&&l('"::"')),null!==c&&null!==(f=de())?e=[e,n,r,o,a,u,c,f]:(e=null,i=y)):(e=null,i=y)):(e=null,i=y)):(e=null,i=y)):(e=null,i=y)):(e=null,i=y)):(e=null,i=y),null===e&&(y=i,null!==(e=de())?(g=i,58===t.charCodeAt(i)?(n=":",i++):(n=null,0===s&&l('":"')),null!==n&&null!==(r=de())?n=[n,r]:(n=null,i=g),null!==(n=null!==n?n:"")?(g=i,58===t.charCodeAt(i)?(r=":",i++):(r=null,0===s&&l('":"')),null!==r&&null!==(o=de())?r=[r,o]:(r=null,i=g),null!==(r=null!==r?r:"")?(g=i,58===t.charCodeAt(i)?(o=":",i++):(o=null,0===s&&l('":"')),null!==o&&null!==(a=de())?o=[o,a]:(o=null,i=g),null!==(o=null!==o?o:"")?(g=i,58===t.charCodeAt(i)?(a=":",i++):(a=null,0===s&&l('":"')),null!==a&&null!==(u=de())?a=[a,u]:(a=null,i=g),null!==(a=null!==a?a:"")?(g=i,58===t.charCodeAt(i)?(u=":",i++):(u=null,0===s&&l('":"')),null!==u&&null!==(c=de())?u=[u,c]:(u=null,i=g),null!==(u=null!==u?u:"")?(g=i,58===t.charCodeAt(i)?(c=":",i++):(c=null,0===s&&l('":"')),null!==c&&null!==(f=de())?c=[c,f]:(c=null,i=g),null!==(c=null!==c?c:"")?("::"===t.substr(i,2)?(f="::",i+=2):(f=null,0===s&&l('"::"')),null!==f?e=[e,n,r,o,a,u,c,f]:(e=null,i=y)):(e=null,i=y)):(e=null,i=y)):(e=null,i=y)):(e=null,i=y)):(e=null,i=y)):(e=null,i=y)):(e=null,i=y))))))))))))))),null!==e&&(e=function(e){return Hn.host_type="IPv6",t.substring(i,e)}(m)),null===e&&(i=m),e}function de(){var e,t,n,r,o;return o=i,null!==(e=d())&&null!==(t=null!==(t=d())?t:"")&&null!==(n=null!==(n=d())?n:"")&&null!==(r=null!==(r=d())?r:"")?e=[e,t,n,r]:(e=null,i=o),e}function pe(){var e,n,r,o;return o=i,null!==(e=de())?(58===t.charCodeAt(i)?(n=":",i++):(n=null,0===s&&l('":"')),null!==n&&null!==(r=de())?e=[e,n,r]:(e=null,i=o)):(e=null,i=o),null===e&&(e=_e()),e}function _e(){var e,n,r,o,a,u,c,f,h;return f=i,h=i,null!==(e=ve())?(46===t.charCodeAt(i)?(n=".",i++):(n=null,0===s&&l('"."')),null!==n&&null!==(r=ve())?(46===t.charCodeAt(i)?(o=".",i++):(o=null,0===s&&l('"."')),null!==o&&null!==(a=ve())?(46===t.charCodeAt(i)?(u=".",i++):(u=null,0===s&&l('"."')),null!==u&&null!==(c=ve())?e=[e,n,r,o,a,u,c]:(e=null,i=h)):(e=null,i=h)):(e=null,i=h)):(e=null,i=h),null!==e&&(e=function(e){return Hn.host_type="IPv4",t.substring(i,e)}(f)),null===e&&(i=f),e}function ve(){var e,n,r,o;return o=i,"25"===t.substr(i,2)?(e="25",i+=2):(e=null,0===s&&l('"25"')),null!==e?(/^[0-5]/.test(t.charAt(i))?(n=t.charAt(i),i++):(n=null,0===s&&l("[0-5]")),null!==n?e=[e,n]:(e=null,i=o)):(e=null,i=o),null===e&&(o=i,50===t.charCodeAt(i)?(e="2",i++):(e=null,0===s&&l('"2"')),null!==e?(/^[0-4]/.test(t.charAt(i))?(n=t.charAt(i),i++):(n=null,0===s&&l("[0-4]")),null!==n&&null!==(r=f())?e=[e,n,r]:(e=null,i=o)):(e=null,i=o),null===e&&(o=i,49===t.charCodeAt(i)?(e="1",i++):(e=null,0===s&&l('"1"')),null!==e&&null!==(n=f())&&null!==(r=f())?e=[e,n,r]:(e=null,i=o),null===e&&(o=i,/^[1-9]/.test(t.charAt(i))?(e=t.charAt(i),i++):(e=null,0===s&&l("[1-9]")),null!==e&&null!==(n=f())?e=[e,n]:(e=null,i=o),null===e&&(e=f())))),e}function me(){var e,t,n,r,o,s,a,u;return s=i,a=i,null!==(e=null!==(e=f())?e:"")&&null!==(t=null!==(t=f())?t:"")&&null!==(n=null!==(n=f())?n:"")&&null!==(r=null!==(r=f())?r:"")&&null!==(o=null!==(o=f())?o:"")?e=[e,t,n,r,o]:(e=null,i=a),null!==e&&(u=e,u=parseInt(u.join("")),Hn.port=u,e=u),null===e&&(i=s),e}function ye(){var e,n,r,o;for(e=[],o=i,59===t.charCodeAt(i)?(n=";",i++):(n=null,0===s&&l('";"')),null!==n&&null!==(r=ge())?n=[n,r]:(n=null,i=o);null!==n;)e.push(n),o=i,59===t.charCodeAt(i)?(n=";",i++):(n=null,0===s&&l('";"')),null!==n&&null!==(r=ge())?n=[n,r]:(n=null,i=o);return e}function ge(){var e;return null===(e=be())&&null===(e=Te())&&null===(e=we())&&null===(e=Se())&&null===(e=Ee())&&null===(e=Ce())&&(e=Ae()),e}function be(){var e,n,r,o,a;return r=i,o=i,"transport="===t.substr(i,10).toLowerCase()?(e=t.substr(i,10),i+=10):(e=null,0===s&&l('"transport="')),null!==e?("udp"===t.substr(i,3).toLowerCase()?(n=t.substr(i,3),i+=3):(n=null,0===s&&l('"udp"')),null===n&&("tcp"===t.substr(i,3).toLowerCase()?(n=t.substr(i,3),i+=3):(n=null,0===s&&l('"tcp"')),null===n&&("sctp"===t.substr(i,4).toLowerCase()?(n=t.substr(i,4),i+=4):(n=null,0===s&&l('"sctp"')),null===n&&("tls"===t.substr(i,3).toLowerCase()?(n=t.substr(i,3),i+=3):(n=null,0===s&&l('"tls"')),null===n&&(n=x())))),null!==n?e=[e,n]:(e=null,i=o)):(e=null,i=o),null!==e&&(a=e[1],Hn.uri_params||(Hn.uri_params={}),e=void(Hn.uri_params.transport=a.toLowerCase())),null===e&&(i=r),e}function Te(){var e,n,r,o,a;return r=i,o=i,"user="===t.substr(i,5).toLowerCase()?(e=t.substr(i,5),i+=5):(e=null,0===s&&l('"user="')),null!==e?("phone"===t.substr(i,5).toLowerCase()?(n=t.substr(i,5),i+=5):(n=null,0===s&&l('"phone"')),null===n&&("ip"===t.substr(i,2).toLowerCase()?(n=t.substr(i,2),i+=2):(n=null,0===s&&l('"ip"')),null===n&&(n=x())),null!==n?e=[e,n]:(e=null,i=o)):(e=null,i=o),null!==e&&(a=e[1],Hn.uri_params||(Hn.uri_params={}),e=void(Hn.uri_params.user=a.toLowerCase())),null===e&&(i=r),e}function we(){var e,n,r,o,a;return r=i,o=i,"method="===t.substr(i,7).toLowerCase()?(e=t.substr(i,7),i+=7):(e=null,0===s&&l('"method="')),null!==e&&null!==(n=ct())?e=[e,n]:(e=null,i=o),null!==e&&(a=e[1],Hn.uri_params||(Hn.uri_params={}),e=void(Hn.uri_params.method=a)),null===e&&(i=r),e}function Se(){var e,n,r,o,a;return r=i,o=i,"ttl="===t.substr(i,4).toLowerCase()?(e=t.substr(i,4),i+=4):(e=null,0===s&&l('"ttl="')),null!==e&&null!==(n=Cn())?e=[e,n]:(e=null,i=o),null!==e&&(a=e[1],Hn.params||(Hn.params={}),e=void(Hn.params.ttl=a)),null===e&&(i=r),e}function Ee(){var e,n,r,o,a;return r=i,o=i,"maddr="===t.substr(i,6).toLowerCase()?(e=t.substr(i,6),i+=6):(e=null,0===s&&l('"maddr="')),null!==e&&null!==(n=ae())?e=[e,n]:(e=null,i=o),null!==e&&(a=e[1],Hn.uri_params||(Hn.uri_params={}),e=void(Hn.uri_params.maddr=a)),null===e&&(i=r),e}function Ce(){var e,n,r,o,a,u;return o=i,a=i,"lr"===t.substr(i,2).toLowerCase()?(e=t.substr(i,2),i+=2):(e=null,0===s&&l('"lr"')),null!==e?(u=i,61===t.charCodeAt(i)?(n="=",i++):(n=null,0===s&&l('"="')),null!==n&&null!==(r=x())?n=[n,r]:(n=null,i=u),null!==(n=null!==n?n:"")?e=[e,n]:(e=null,i=a)):(e=null,i=a),null!==e&&(Hn.uri_params||(Hn.uri_params={}),e=void(Hn.uri_params.lr=void 0)),null===e&&(i=o),e}function Ae(){var e,n,r,o,a,u,c,f;return o=i,a=i,null!==(e=Re())?(u=i,61===t.charCodeAt(i)?(n="=",i++):(n=null,0===s&&l('"="')),null!==n&&null!==(r=Ie())?n=[n,r]:(n=null,i=u),null!==(n=null!==n?n:"")?e=[e,n]:(e=null,i=a)):(e=null,i=a),null!==e&&(c=e[0],f=e[1],Hn.uri_params||(Hn.uri_params={}),f=void 0===f?void 0:f[1],e=void(Hn.uri_params[c.toLowerCase()]=f)),null===e&&(i=o),e}function Re(){var e,t,n;if(n=i,null!==(t=Oe()))for(e=[];null!==t;)e.push(t),t=Oe();else e=null;return null!==e&&(e=e.join("")),null===e&&(i=n),e}function Ie(){var e,t,n;if(n=i,null!==(t=Oe()))for(e=[];null!==t;)e.push(t),t=Oe();else e=null;return null!==e&&(e=e.join("")),null===e&&(i=n),e}function Oe(){var e;return null===(e=ke())&&null===(e=T())&&(e=S()),e}function ke(){var e;return 91===t.charCodeAt(i)?(e="[",i++):(e=null,0===s&&l('"["')),null===e&&(93===t.charCodeAt(i)?(e="]",i++):(e=null,0===s&&l('"]"')),null===e&&(47===t.charCodeAt(i)?(e="/",i++):(e=null,0===s&&l('"/"')),null===e&&(58===t.charCodeAt(i)?(e=":",i++):(e=null,0===s&&l('":"')),null===e&&(38===t.charCodeAt(i)?(e="&",i++):(e=null,0===s&&l('"&"')),null===e&&(43===t.charCodeAt(i)?(e="+",i++):(e=null,0===s&&l('"+"')),null===e&&(36===t.charCodeAt(i)?(e="$",i++):(e=null,0===s&&l('"$"')))))))),e}function xe(){var e,n,r,o,a,u,c;if(u=i,63===t.charCodeAt(i)?(e="?",i++):(e=null,0===s&&l('"?"')),null!==e)if(null!==(n=Ne())){for(r=[],c=i,38===t.charCodeAt(i)?(o="&",i++):(o=null,0===s&&l('"&"')),null!==o&&null!==(a=Ne())?o=[o,a]:(o=null,i=c);null!==o;)r.push(o),c=i,38===t.charCodeAt(i)?(o="&",i++):(o=null,0===s&&l('"&"')),null!==o&&null!==(a=Ne())?o=[o,a]:(o=null,i=c);null!==r?e=[e,n,r]:(e=null,i=u)}else e=null,i=u;else e=null,i=u;return e}function Ne(){var e,n,r,o,a,u,c;return o=i,a=i,null!==(e=Pe())?(61===t.charCodeAt(i)?(n="=",i++):(n=null,0===s&&l('"="')),null!==n&&null!==(r=De())?e=[e,n,r]:(e=null,i=a)):(e=null,i=a),null!==e&&(u=e[0],c=e[2],u=u.join("").toLowerCase(),c=c.join(""),Hn.uri_headers||(Hn.uri_headers={}),e=void(Hn.uri_headers[u]?Hn.uri_headers[u].push(c):Hn.uri_headers[u]=[c])),null===e&&(i=o),e}function Pe(){var e,t;if(null===(t=Le())&&null===(t=T())&&(t=S()),null!==t)for(e=[];null!==t;)e.push(t),null===(t=Le())&&null===(t=T())&&(t=S());else e=null;return e}function De(){var e,t;for(e=[],null===(t=Le())&&null===(t=T())&&(t=S());null!==t;)e.push(t),null===(t=Le())&&null===(t=T())&&(t=S());return e}function Le(){var e;return 91===t.charCodeAt(i)?(e="[",i++):(e=null,0===s&&l('"["')),null===e&&(93===t.charCodeAt(i)?(e="]",i++):(e=null,0===s&&l('"]"')),null===e&&(47===t.charCodeAt(i)?(e="/",i++):(e=null,0===s&&l('"/"')),null===e&&(63===t.charCodeAt(i)?(e="?",i++):(e=null,0===s&&l('"?"')),null===e&&(58===t.charCodeAt(i)?(e=":",i++):(e=null,0===s&&l('":"')),null===e&&(43===t.charCodeAt(i)?(e="+",i++):(e=null,0===s&&l('"+"')),null===e&&(36===t.charCodeAt(i)?(e="$",i++):(e=null,0===s&&l('"$"')))))))),e}function Ue(){var e,t,n,r,o,s;return s=i,null!==(e=ct())&&null!==(t=m())&&null!==(n=Me())&&null!==(r=m())&&null!==(o=et())?e=[e,t,n,r,o]:(e=null,i=s),e}function Me(){var e;return null===(e=Q())&&(e=je()),e}function je(){var e,n,r,o;return o=i,null!==(e=$e())?(58===t.charCodeAt(i)?(n=":",i++):(n=null,0===s&&l('":"')),null!==n?(null===(r=qe())&&(r=Ge()),null!==r?e=[e,n,r]:(e=null,i=o)):(e=null,i=o)):(e=null,i=o),e}function qe(){var e,n,r,o,a;return o=i,null===(e=Fe())&&(e=He()),null!==e?(a=i,63===t.charCodeAt(i)?(n="?",i++):(n=null,0===s&&l('"?"')),null!==n&&null!==(r=Ze())?n=[n,r]:(n=null,i=a),null!==(n=null!==n?n:"")?e=[e,n]:(e=null,i=o)):(e=null,i=o),e}function Fe(){var e,n,r,o;return o=i,"//"===t.substr(i,2)?(e="//",i+=2):(e=null,0===s&&l('"//"')),null!==e&&null!==(n=Je())&&null!==(r=null!==(r=He())?r:"")?e=[e,n,r]:(e=null,i=o),e}function He(){var e,n,r;return r=i,47===t.charCodeAt(i)?(e="/",i++):(e=null,0===s&&l('"/"')),null!==e&&null!==(n=Ve())?e=[e,n]:(e=null,i=r),e}function Ge(){var e,t,n,r;if(r=i,null!==(e=We())){for(t=[],n=Be();null!==n;)t.push(n),n=Be();null!==t?e=[e,t]:(e=null,i=r)}else e=null,i=r;return e}function Be(){var e;return null===(e=b())&&null===(e=T())&&(e=S()),e}function We(){var e;return null===(e=T())&&null===(e=S())&&(59===t.charCodeAt(i)?(e=";",i++):(e=null,0===s&&l('";"')),null===e&&(63===t.charCodeAt(i)?(e="?",i++):(e=null,0===s&&l('"?"')),null===e&&(58===t.charCodeAt(i)?(e=":",i++):(e=null,0===s&&l('":"')),null===e&&(64===t.charCodeAt(i)?(e="@",i++):(e=null,0===s&&l('"@"')),null===e&&(38===t.charCodeAt(i)?(e="&",i++):(e=null,0===s&&l('"&"')),null===e&&(61===t.charCodeAt(i)?(e="=",i++):(e=null,0===s&&l('"="')),null===e&&(43===t.charCodeAt(i)?(e="+",i++):(e=null,0===s&&l('"+"')),null===e&&(36===t.charCodeAt(i)?(e="$",i++):(e=null,0===s&&l('"$"')),null===e&&(44===t.charCodeAt(i)?(e=",",i++):(e=null,0===s&&l('","'))))))))))),e}function Ve(){var e,n,r,o,a,u;if(a=i,null!==(e=Ke())){for(n=[],u=i,47===t.charCodeAt(i)?(r="/",i++):(r=null,0===s&&l('"/"')),null!==r&&null!==(o=Ke())?r=[r,o]:(r=null,i=u);null!==r;)n.push(r),u=i,47===t.charCodeAt(i)?(r="/",i++):(r=null,0===s&&l('"/"')),null!==r&&null!==(o=Ke())?r=[r,o]:(r=null,i=u);null!==n?e=[e,n]:(e=null,i=a)}else e=null,i=a;return e}function Ke(){var e,n,r,o,a,u;for(a=i,e=[],n=Ye();null!==n;)e.push(n),n=Ye();if(null!==e){for(n=[],u=i,59===t.charCodeAt(i)?(r=";",i++):(r=null,0===s&&l('";"')),null!==r&&null!==(o=ze())?r=[r,o]:(r=null,i=u);null!==r;)n.push(r),u=i,59===t.charCodeAt(i)?(r=";",i++):(r=null,0===s&&l('";"')),null!==r&&null!==(o=ze())?r=[r,o]:(r=null,i=u);null!==n?e=[e,n]:(e=null,i=a)}else e=null,i=a;return e}function ze(){var e,t;for(e=[],t=Ye();null!==t;)e.push(t),t=Ye();return e}function Ye(){var e;return null===(e=T())&&null===(e=S())&&(58===t.charCodeAt(i)?(e=":",i++):(e=null,0===s&&l('":"')),null===e&&(64===t.charCodeAt(i)?(e="@",i++):(e=null,0===s&&l('"@"')),null===e&&(38===t.charCodeAt(i)?(e="&",i++):(e=null,0===s&&l('"&"')),null===e&&(61===t.charCodeAt(i)?(e="=",i++):(e=null,0===s&&l('"="')),null===e&&(43===t.charCodeAt(i)?(e="+",i++):(e=null,0===s&&l('"+"')),null===e&&(36===t.charCodeAt(i)?(e="$",i++):(e=null,0===s&&l('"$"')),null===e&&(44===t.charCodeAt(i)?(e=",",i++):(e=null,0===s&&l('","'))))))))),e}function $e(){var e,n,r,o,a;if(o=i,a=i,null!==(e=h())){for(n=[],null===(r=h())&&null===(r=f())&&(43===t.charCodeAt(i)?(r="+",i++):(r=null,0===s&&l('"+"')),null===r&&(45===t.charCodeAt(i)?(r="-",i++):(r=null,0===s&&l('"-"')),null===r&&(46===t.charCodeAt(i)?(r=".",i++):(r=null,0===s&&l('"."')))));null!==r;)n.push(r),null===(r=h())&&null===(r=f())&&(43===t.charCodeAt(i)?(r="+",i++):(r=null,0===s&&l('"+"')),null===r&&(45===t.charCodeAt(i)?(r="-",i++):(r=null,0===s&&l('"-"')),null===r&&(46===t.charCodeAt(i)?(r=".",i++):(r=null,0===s&&l('"."')))));null!==n?e=[e,n]:(e=null,i=a)}else e=null,i=a;return null!==e&&(e=function(e){Hn.scheme=t.substring(i,e)}(o)),null===e&&(i=o),e}function Je(){var e;return null===(e=Xe())&&(e=Qe()),e}function Xe(){var e,n,r,o;return r=i,o=i,null!==(e=ne())?(64===t.charCodeAt(i)?(n="@",i++):(n=null,0===s&&l('"@"')),null!==n?e=[e,n]:(e=null,i=o)):(e=null,i=o),null!==(e=null!==e?e:"")&&null!==(n=se())?e=[e,n]:(e=null,i=r),e=null!==e?e:""}function Qe(){var e,n;if(null===(n=T())&&null===(n=S())&&(36===t.charCodeAt(i)?(n="$",i++):(n=null,0===s&&l('"$"')),null===n&&(44===t.charCodeAt(i)?(n=",",i++):(n=null,0===s&&l('","')),null===n&&(59===t.charCodeAt(i)?(n=";",i++):(n=null,0===s&&l('";"')),null===n&&(58===t.charCodeAt(i)?(n=":",i++):(n=null,0===s&&l('":"')),null===n&&(64===t.charCodeAt(i)?(n="@",i++):(n=null,0===s&&l('"@"')),null===n&&(38===t.charCodeAt(i)?(n="&",i++):(n=null,0===s&&l('"&"')),null===n&&(61===t.charCodeAt(i)?(n="=",i++):(n=null,0===s&&l('"="')),null===n&&(43===t.charCodeAt(i)?(n="+",i++):(n=null,0===s&&l('"+"')))))))))),null!==n)for(e=[];null!==n;)e.push(n),null===(n=T())&&null===(n=S())&&(36===t.charCodeAt(i)?(n="$",i++):(n=null,0===s&&l('"$"')),null===n&&(44===t.charCodeAt(i)?(n=",",i++):(n=null,0===s&&l('","')),null===n&&(59===t.charCodeAt(i)?(n=";",i++):(n=null,0===s&&l('";"')),null===n&&(58===t.charCodeAt(i)?(n=":",i++):(n=null,0===s&&l('":"')),null===n&&(64===t.charCodeAt(i)?(n="@",i++):(n=null,0===s&&l('"@"')),null===n&&(38===t.charCodeAt(i)?(n="&",i++):(n=null,0===s&&l('"&"')),null===n&&(61===t.charCodeAt(i)?(n="=",i++):(n=null,0===s&&l('"="')),null===n&&(43===t.charCodeAt(i)?(n="+",i++):(n=null,0===s&&l('"+"'))))))))));else e=null;return e}function Ze(){var e,t;for(e=[],t=Be();null!==t;)e.push(t),t=Be();return e}function et(){var e,n,r,o,a,u,c,h;if(c=i,h=i,"sip"===t.substr(i,3).toLowerCase()?(e=t.substr(i,3),i+=3):(e=null,0===s&&l('"SIP"')),null!==e)if(47===t.charCodeAt(i)?(n="/",i++):(n=null,0===s&&l('"/"')),null!==n){if(null!==(o=f()))for(r=[];null!==o;)r.push(o),o=f();else r=null;if(null!==r)if(46===t.charCodeAt(i)?(o=".",i++):(o=null,0===s&&l('"."')),null!==o){if(null!==(u=f()))for(a=[];null!==u;)a.push(u),u=f();else a=null;null!==a?e=[e,n,r,o,a]:(e=null,i=h)}else e=null,i=h;else e=null,i=h}else e=null,i=h;else e=null,i=h;return null!==e&&(e=function(e){Hn.sip_version=t.substring(i,e)}(c)),null===e&&(i=c),e}function tt(){var e;return"INVITE"===t.substr(i,6)?(e="INVITE",i+=6):(e=null,0===s&&l('"INVITE"')),e}function nt(){var e;return"ACK"===t.substr(i,3)?(e="ACK",i+=3):(e=null,0===s&&l('"ACK"')),e}function rt(){var e;return"OPTIONS"===t.substr(i,7)?(e="OPTIONS",i+=7):(e=null,0===s&&l('"OPTIONS"')),e}function ot(){var e;return"BYE"===t.substr(i,3)?(e="BYE",i+=3):(e=null,0===s&&l('"BYE"')),e}function it(){var e;return"CANCEL"===t.substr(i,6)?(e="CANCEL",i+=6):(e=null,0===s&&l('"CANCEL"')),e}function st(){var e;return"REGISTER"===t.substr(i,8)?(e="REGISTER",i+=8):(e=null,0===s&&l('"REGISTER"')),e}function at(){var e;return"SUBSCRIBE"===t.substr(i,9)?(e="SUBSCRIBE",i+=9):(e=null,0===s&&l('"SUBSCRIBE"')),e}function ut(){var e;return"NOTIFY"===t.substr(i,6)?(e="NOTIFY",i+=6):(e=null,0===s&&l('"NOTIFY"')),e}function lt(){var e;return"REFER"===t.substr(i,5)?(e="REFER",i+=5):(e=null,0===s&&l('"REFER"')),e}function ct(){var e,n;return n=i,null===(e=tt())&&null===(e=nt())&&null===(e=rt())&&null===(e=ot())&&null===(e=it())&&null===(e=st())&&null===(e=at())&&null===(e=ut())&&null===(e=lt())&&(e=x()),null!==e&&(e=function(e){return Hn.method=t.substring(i,e),Hn.method}(n)),null===e&&(i=n),e}function ft(){var e,t,n,r,o,s;return s=i,null!==(e=et())&&null!==(t=m())&&null!==(n=ht())&&null!==(r=m())&&null!==(o=pt())?e=[e,t,n,r,o]:(e=null,i=s),e}function ht(){var e,t,n;return t=i,null!==(e=dt())&&(n=e,e=void(Hn.status_code=parseInt(n.join("")))),null===e&&(i=t),e}function dt(){var e,t,n,r;return r=i,null!==(e=f())&&null!==(t=f())&&null!==(n=f())?e=[e,t,n]:(e=null,i=r),e}function pt(){var e,n,r;for(r=i,e=[],null===(n=b())&&null===(n=T())&&null===(n=S())&&null===(n=O())&&null===(n=k())&&null===(n=m())&&(n=y());null!==n;)e.push(n),null===(n=b())&&null===(n=T())&&null===(n=S())&&null===(n=O())&&null===(n=k())&&null===(n=m())&&(n=y());return null!==e&&(e=function(e){Hn.reason_phrase=t.substring(i,e)}(r)),null===e&&(i=r),e}function _t(){var e,t,n,r,o,s,a;if(o=i,s=i,null===(e=X())&&(e=vt()),null!==e){for(t=[],a=i,null!==(n=G())&&null!==(r=yt())?n=[n,r]:(n=null,i=a);null!==n;)t.push(n),a=i,null!==(n=G())&&null!==(r=yt())?n=[n,r]:(n=null,i=a);null!==t?e=[e,t]:(e=null,i=s)}else e=null,i=s;return null!==e&&(e=function(e){var t;Hn.multi_header||(Hn.multi_header=[]);try{t=new Fn(Hn.uri,Hn.display_name,Hn.params),delete Hn.uri,delete Hn.display_name,delete Hn.params}catch(e){t=null}Hn.multi_header.push({possition:i,offset:e,parsed:t})}(o)),null===e&&(i=o),e}function vt(){var e,t,n,r,o;return o=i,null!==(e=null!==(e=mt())?e:"")&&null!==(t=F())&&null!==(n=Q())&&null!==(r=q())?e=[e,t,n,r]:(e=null,i=o),e}function mt(){var e,t,n,r,o,s,a,u;if(o=i,s=i,null!==(e=x())){for(t=[],a=i,null!==(n=E())&&null!==(r=x())?n=[n,r]:(n=null,i=a);null!==n;)t.push(n),a=i,null!==(n=E())&&null!==(r=x())?n=[n,r]:(n=null,i=a);null!==t?e=[e,t]:(e=null,i=s)}else e=null,i=s;return null===e&&(e=Y()),null!==e&&(u=e,e=void(Hn.display_name="string"==typeof u?u:u[1].reduce((function(e,t){return e+t[0]+t[1]}),u[0]))),null===e&&(i=o),e}function yt(){var e;return null===(e=gt())&&null===(e=bt())&&(e=St()),e}function gt(){var e,n,r,o,a,u;return o=i,a=i,"q"===t.substr(i,1).toLowerCase()?(e=t.substr(i,1),i++):(e=null,0===s&&l('"q"')),null!==e&&null!==(n=U())&&null!==(r=wt())?e=[e,n,r]:(e=null,i=a),null!==e&&(u=e[2],Hn.params||(Hn.params={}),e=void(Hn.params.q=u)),null===e&&(i=o),e}function bt(){var e,n,r,o,a,u;return o=i,a=i,"expires"===t.substr(i,7).toLowerCase()?(e=t.substr(i,7),i+=7):(e=null,0===s&&l('"expires"')),null!==e&&null!==(n=U())&&null!==(r=Tt())?e=[e,n,r]:(e=null,i=a),null!==e&&(u=e[2],Hn.params||(Hn.params={}),e=void(Hn.params.expires=u)),null===e&&(i=o),e}function Tt(){var e,t,n;if(n=i,null!==(t=f()))for(e=[];null!==t;)e.push(t),t=f();else e=null;return null!==e&&(e=parseInt(e.join(""))),null===e&&(i=n),e}function wt(){var e,n,r,o,a,u,c,h;return u=i,c=i,48===t.charCodeAt(i)?(e="0",i++):(e=null,0===s&&l('"0"')),null!==e?(h=i,46===t.charCodeAt(i)?(n=".",i++):(n=null,0===s&&l('"."')),null!==n&&null!==(r=null!==(r=f())?r:"")&&null!==(o=null!==(o=f())?o:"")&&null!==(a=null!==(a=f())?a:"")?n=[n,r,o,a]:(n=null,i=h),null!==(n=null!==n?n:"")?e=[e,n]:(e=null,i=c)):(e=null,i=c),null!==e&&(e=function(e){return parseFloat(t.substring(i,e))}(u)),null===e&&(i=u),e}function St(){var e,t,n,r,o,s,a,u;return r=i,o=i,null!==(e=x())?(s=i,null!==(t=U())&&null!==(n=Et())?t=[t,n]:(t=null,i=s),null!==(t=null!==t?t:"")?e=[e,t]:(e=null,i=o)):(e=null,i=o),null!==e&&(a=e[0],u=e[1],Hn.params||(Hn.params={}),u=void 0===u?void 0:u[1],e=void(Hn.params[a.toLowerCase()]=u)),null===e&&(i=r),e}function Et(){var e;return null===(e=x())&&null===(e=ae())&&(e=z()),e}function Ct(){var e;return"render"===t.substr(i,6).toLowerCase()?(e=t.substr(i,6),i+=6):(e=null,0===s&&l('"render"')),null===e&&("session"===t.substr(i,7).toLowerCase()?(e=t.substr(i,7),i+=7):(e=null,0===s&&l('"session"')),null===e&&("icon"===t.substr(i,4).toLowerCase()?(e=t.substr(i,4),i+=4):(e=null,0===s&&l('"icon"')),null===e&&("alert"===t.substr(i,5).toLowerCase()?(e=t.substr(i,5),i+=5):(e=null,0===s&&l('"alert"')),null===e&&(e=x())))),e}function At(){var e;return null===(e=Rt())&&(e=St()),e}function Rt(){var e,n,r,o;return o=i,"handling"===t.substr(i,8).toLowerCase()?(e=t.substr(i,8),i+=8):(e=null,0===s&&l('"handling"')),null!==e&&null!==(n=U())?("optional"===t.substr(i,8).toLowerCase()?(r=t.substr(i,8),i+=8):(r=null,0===s&&l('"optional"')),null===r&&("required"===t.substr(i,8).toLowerCase()?(r=t.substr(i,8),i+=8):(r=null,0===s&&l('"required"')),null===r&&(r=x())),null!==r?e=[e,n,r]:(e=null,i=o)):(e=null,i=o),e}function It(){var e,t,n,r,o,s,a,u;if(a=i,null!==(e=Ot()))if(null!==(t=L()))if(null!==(n=Dt())){for(r=[],u=i,null!==(o=G())&&null!==(s=Lt())?o=[o,s]:(o=null,i=u);null!==o;)r.push(o),u=i,null!==(o=G())&&null!==(s=Lt())?o=[o,s]:(o=null,i=u);null!==r?e=[e,t,n,r]:(e=null,i=a)}else e=null,i=a;else e=null,i=a;else e=null,i=a;return e}function Ot(){var e;return null===(e=kt())&&(e=xt()),e}function kt(){var e;return"text"===t.substr(i,4).toLowerCase()?(e=t.substr(i,4),i+=4):(e=null,0===s&&l('"text"')),null===e&&("image"===t.substr(i,5).toLowerCase()?(e=t.substr(i,5),i+=5):(e=null,0===s&&l('"image"')),null===e&&("audio"===t.substr(i,5).toLowerCase()?(e=t.substr(i,5),i+=5):(e=null,0===s&&l('"audio"')),null===e&&("video"===t.substr(i,5).toLowerCase()?(e=t.substr(i,5),i+=5):(e=null,0===s&&l('"video"')),null===e&&("application"===t.substr(i,11).toLowerCase()?(e=t.substr(i,11),i+=11):(e=null,0===s&&l('"application"')),null===e&&(e=Nt()))))),e}function xt(){var e;return"message"===t.substr(i,7).toLowerCase()?(e=t.substr(i,7),i+=7):(e=null,0===s&&l('"message"')),null===e&&("multipart"===t.substr(i,9).toLowerCase()?(e=t.substr(i,9),i+=9):(e=null,0===s&&l('"multipart"')),null===e&&(e=Nt())),e}function Nt(){var e;return null===(e=x())&&(e=Pt()),e}function Pt(){var e,n,r;return r=i,"x-"===t.substr(i,2).toLowerCase()?(e=t.substr(i,2),i+=2):(e=null,0===s&&l('"x-"')),null!==e&&null!==(n=x())?e=[e,n]:(e=null,i=r),e}function Dt(){var e;return null===(e=Nt())&&(e=x()),e}function Lt(){var e,t,n,r;return r=i,null!==(e=x())&&null!==(t=U())&&null!==(n=Ut())?e=[e,t,n]:(e=null,i=r),e}function Ut(){var e;return null===(e=x())&&(e=z()),e}function Mt(){var e,t,n,r;if(n=i,null!==(t=f()))for(e=[];null!==t;)e.push(t),t=f();else e=null;return null!==e&&(r=e,e=void(Hn.value=parseInt(r.join("")))),null===e&&(i=n),e}function jt(){var e,n,r,o,a,u;if(a=i,null!==(e=N())){for(n=[],u=i,46===t.charCodeAt(i)?(r=".",i++):(r=null,0===s&&l('"."')),null!==r&&null!==(o=N())?r=[r,o]:(r=null,i=u);null!==r;)n.push(r),u=i,46===t.charCodeAt(i)?(r=".",i++):(r=null,0===s&&l('"."')),null!==r&&null!==(o=N())?r=[r,o]:(r=null,i=u);null!==n?e=[e,n]:(e=null,i=a)}else e=null,i=a;return e}function qt(){var e;return null===(e=Ft())&&(e=St()),e}function Ft(){var e,n,r,o,a,u;return o=i,a=i,"tag"===t.substr(i,3).toLowerCase()?(e=t.substr(i,3),i+=3):(e=null,0===s&&l('"tag"')),null!==e&&null!==(n=U())&&null!==(r=x())?e=[e,n,r]:(e=null,i=a),null!==e&&(u=e[2],e=void(Hn.tag=u)),null===e&&(i=o),e}function Ht(){var e,n,r,o,a,u,c,f;if(c=i,"digest"===t.substr(i,6).toLowerCase()?(e=t.substr(i,6),i+=6):(e=null,0===s&&l('"Digest"')),null!==e)if(null!==(n=E()))if(null!==(r=Wt())){for(o=[],f=i,null!==(a=H())&&null!==(u=Wt())?a=[a,u]:(a=null,i=f);null!==a;)o.push(a),f=i,null!==(a=H())&&null!==(u=Wt())?a=[a,u]:(a=null,i=f);null!==o?e=[e,n,r,o]:(e=null,i=c)}else e=null,i=c;else e=null,i=c;else e=null,i=c;return null===e&&(e=Gt()),e}function Gt(){var e,t,n,r,o,s,a,u;if(a=i,null!==(e=x()))if(null!==(t=E()))if(null!==(n=Bt())){for(r=[],u=i,null!==(o=H())&&null!==(s=Bt())?o=[o,s]:(o=null,i=u);null!==o;)r.push(o),u=i,null!==(o=H())&&null!==(s=Bt())?o=[o,s]:(o=null,i=u);null!==r?e=[e,t,n,r]:(e=null,i=a)}else e=null,i=a;else e=null,i=a;else e=null,i=a;return e}function Bt(){var e,t,n,r;return r=i,null!==(e=x())&&null!==(t=U())?(null===(n=x())&&(n=z()),null!==n?e=[e,t,n]:(e=null,i=r)):(e=null,i=r),e}function Wt(){var e;return null===(e=Vt())&&null===(e=zt())&&null===(e=$t())&&null===(e=Xt())&&null===(e=Qt())&&null===(e=Zt())&&null===(e=en())&&(e=Bt()),e}function Vt(){var e,n,r,o;return o=i,"realm"===t.substr(i,5).toLowerCase()?(e=t.substr(i,5),i+=5):(e=null,0===s&&l('"realm"')),null!==e&&null!==(n=U())&&null!==(r=Kt())?e=[e,n,r]:(e=null,i=o),e}function Kt(){var e,t,n;return t=i,null!==(e=Y())&&(n=e,e=void(Hn.realm=n)),null===e&&(i=t),e}function zt(){var e,n,r,o,a,u,c,f,h;if(f=i,"domain"===t.substr(i,6).toLowerCase()?(e=t.substr(i,6),i+=6):(e=null,0===s&&l('"domain"')),null!==e)if(null!==(n=U()))if(null!==(r=W()))if(null!==(o=Yt())){if(a=[],h=i,null!==(c=m()))for(u=[];null!==c;)u.push(c),c=m();else u=null;for(null!==u&&null!==(c=Yt())?u=[u,c]:(u=null,i=h);null!==u;){if(a.push(u),h=i,null!==(c=m()))for(u=[];null!==c;)u.push(c),c=m();else u=null;null!==u&&null!==(c=Yt())?u=[u,c]:(u=null,i=h)}null!==a&&null!==(u=V())?e=[e,n,r,o,a,u]:(e=null,i=f)}else e=null,i=f;else e=null,i=f;else e=null,i=f;else e=null,i=f;return e}function Yt(){var e;return null===(e=je())&&(e=He()),e}function $t(){var e,n,r,o;return o=i,"nonce"===t.substr(i,5).toLowerCase()?(e=t.substr(i,5),i+=5):(e=null,0===s&&l('"nonce"')),null!==e&&null!==(n=U())&&null!==(r=Jt())?e=[e,n,r]:(e=null,i=o),e}function Jt(){var e,t,n;return t=i,null!==(e=Y())&&(n=e,e=void(Hn.nonce=n)),null===e&&(i=t),e}function Xt(){var e,n,r,o,a,u;return o=i,a=i,"opaque"===t.substr(i,6).toLowerCase()?(e=t.substr(i,6),i+=6):(e=null,0===s&&l('"opaque"')),null!==e&&null!==(n=U())&&null!==(r=Y())?e=[e,n,r]:(e=null,i=a),null!==e&&(u=e[2],e=void(Hn.opaque=u)),null===e&&(i=o),e}function Qt(){var e,n,r,o,a;return o=i,"stale"===t.substr(i,5).toLowerCase()?(e=t.substr(i,5),i+=5):(e=null,0===s&&l('"stale"')),null!==e&&null!==(n=U())?(a=i,"true"===t.substr(i,4).toLowerCase()?(r=t.substr(i,4),i+=4):(r=null,0===s&&l('"true"')),null!==r&&(r=void(Hn.stale=!0)),null===r&&(i=a),null===r&&(a=i,"false"===t.substr(i,5).toLowerCase()?(r=t.substr(i,5),i+=5):(r=null,0===s&&l('"false"')),null!==r&&(r=void(Hn.stale=!1)),null===r&&(i=a)),null!==r?e=[e,n,r]:(e=null,i=o)):(e=null,i=o),e}function Zt(){var e,n,r,o,a,u;return o=i,a=i,"algorithm"===t.substr(i,9).toLowerCase()?(e=t.substr(i,9),i+=9):(e=null,0===s&&l('"algorithm"')),null!==e&&null!==(n=U())?("md5"===t.substr(i,3).toLowerCase()?(r=t.substr(i,3),i+=3):(r=null,0===s&&l('"MD5"')),null===r&&("md5-sess"===t.substr(i,8).toLowerCase()?(r=t.substr(i,8),i+=8):(r=null,0===s&&l('"MD5-sess"')),null===r&&(r=x())),null!==r?e=[e,n,r]:(e=null,i=a)):(e=null,i=a),null!==e&&(u=e[2],e=void(Hn.algorithm=u.toUpperCase())),null===e&&(i=o),e}function en(){var e,n,r,o,a,u,c,f,h,d;if(f=i,"qop"===t.substr(i,3).toLowerCase()?(e=t.substr(i,3),i+=3):(e=null,0===s&&l('"qop"')),null!==e)if(null!==(n=U()))if(null!==(r=W())){if(h=i,null!==(o=tn())){for(a=[],d=i,44===t.charCodeAt(i)?(u=",",i++):(u=null,0===s&&l('","')),null!==u&&null!==(c=tn())?u=[u,c]:(u=null,i=d);null!==u;)a.push(u),d=i,44===t.charCodeAt(i)?(u=",",i++):(u=null,0===s&&l('","')),null!==u&&null!==(c=tn())?u=[u,c]:(u=null,i=d);null!==a?o=[o,a]:(o=null,i=h)}else o=null,i=h;null!==o&&null!==(a=V())?e=[e,n,r,o,a]:(e=null,i=f)}else e=null,i=f;else e=null,i=f;else e=null,i=f;return e}function tn(){var e,n,r;return n=i,"auth-int"===t.substr(i,8).toLowerCase()?(e=t.substr(i,8),i+=8):(e=null,0===s&&l('"auth-int"')),null===e&&("auth"===t.substr(i,4).toLowerCase()?(e=t.substr(i,4),i+=4):(e=null,0===s&&l('"auth"')),null===e&&(e=x())),null!==e&&(r=e,Hn.qop||(Hn.qop=[]),e=void Hn.qop.push(r.toLowerCase())),null===e&&(i=n),e}function nn(){var e,t,n,r,o,s,a;if(o=i,s=i,null!==(e=vt())){for(t=[],a=i,null!==(n=G())&&null!==(r=St())?n=[n,r]:(n=null,i=a);null!==n;)t.push(n),a=i,null!==(n=G())&&null!==(r=St())?n=[n,r]:(n=null,i=a);null!==t?e=[e,t]:(e=null,i=s)}else e=null,i=s;return null!==e&&(e=function(e){var t;Hn.multi_header||(Hn.multi_header=[]);try{t=new Fn(Hn.uri,Hn.display_name,Hn.params),delete Hn.uri,delete Hn.display_name,delete Hn.params}catch(e){t=null}Hn.multi_header.push({possition:i,offset:e,parsed:t})}(o)),null===e&&(i=o),e}function rn(){var e;return null===(e=on())&&(e=St()),e}function on(){var e,n,r,o,a,u,c;if(a=i,u=i,"cause"===t.substr(i,5).toLowerCase()?(e=t.substr(i,5),i+=5):(e=null,0===s&&l('"cause"')),null!==e)if(null!==(n=U())){if(null!==(o=f()))for(r=[];null!==o;)r.push(o),o=f();else r=null;null!==r?e=[e,n,r]:(e=null,i=u)}else e=null,i=u;else e=null,i=u;return null!==e&&(c=e[2],e=void(Hn.cause=parseInt(c.join("")))),null===e&&(i=a),e}function sn(){var e,t,n,r,o,s;if(o=i,null!==(e=vt())){for(t=[],s=i,null!==(n=G())&&null!==(r=St())?n=[n,r]:(n=null,i=s);null!==n;)t.push(n),s=i,null!==(n=G())&&null!==(r=St())?n=[n,r]:(n=null,i=s);null!==t?e=[e,t]:(e=null,i=o)}else e=null,i=o;return e}function an(){var e,n;return n=i,"active"===t.substr(i,6).toLowerCase()?(e=t.substr(i,6),i+=6):(e=null,0===s&&l('"active"')),null===e&&("pending"===t.substr(i,7).toLowerCase()?(e=t.substr(i,7),i+=7):(e=null,0===s&&l('"pending"')),null===e&&("terminated"===t.substr(i,10).toLowerCase()?(e=t.substr(i,10),i+=10):(e=null,0===s&&l('"terminated"')),null===e&&(e=x()))),null!==e&&(e=function(e){Hn.state=t.substring(i,e)}(n)),null===e&&(i=n),e}function un(){var e,n,r,o,a,u,c,f;return o=i,a=i,"reason"===t.substr(i,6).toLowerCase()?(e=t.substr(i,6),i+=6):(e=null,0===s&&l('"reason"')),null!==e&&null!==(n=U())&&null!==(r=ln())?e=[e,n,r]:(e=null,i=a),null!==e&&(e=void(void 0!==(u=e[2])&&(Hn.reason=u))),null===e&&(i=o),null===e&&(o=i,a=i,"expires"===t.substr(i,7).toLowerCase()?(e=t.substr(i,7),i+=7):(e=null,0===s&&l('"expires"')),null!==e&&null!==(n=U())&&null!==(r=Tt())?e=[e,n,r]:(e=null,i=a),null!==e&&(e=void(void 0!==(f=e[2])&&(Hn.expires=f))),null===e&&(i=o),null===e&&(o=i,a=i,"retry_after"===t.substr(i,11).toLowerCase()?(e=t.substr(i,11),i+=11):(e=null,0===s&&l('"retry_after"')),null!==e&&null!==(n=U())&&null!==(r=Tt())?e=[e,n,r]:(e=null,i=a),null!==e&&(e=void(void 0!==(c=e[2])&&(Hn.retry_after=c))),null===e&&(i=o),null===e&&(e=St()))),e}function ln(){var e;return"deactivated"===t.substr(i,11).toLowerCase()?(e=t.substr(i,11),i+=11):(e=null,0===s&&l('"deactivated"')),null===e&&("probation"===t.substr(i,9).toLowerCase()?(e=t.substr(i,9),i+=9):(e=null,0===s&&l('"probation"')),null===e&&("rejected"===t.substr(i,8).toLowerCase()?(e=t.substr(i,8),i+=8):(e=null,0===s&&l('"rejected"')),null===e&&("timeout"===t.substr(i,7).toLowerCase()?(e=t.substr(i,7),i+=7):(e=null,0===s&&l('"timeout"')),null===e&&("giveup"===t.substr(i,6).toLowerCase()?(e=t.substr(i,6),i+=6):(e=null,0===s&&l('"giveup"')),null===e&&("noresource"===t.substr(i,10).toLowerCase()?(e=t.substr(i,10),i+=10):(e=null,0===s&&l('"noresource"')),null===e&&("invariant"===t.substr(i,9).toLowerCase()?(e=t.substr(i,9),i+=9):(e=null,0===s&&l('"invariant"')),null===e&&(e=x()))))))),e}function cn(){var e;return null===(e=Ft())&&(e=St()),e}function fn(){var e,t,n,r,o,s,a,u;if(a=i,null!==(e=gn()))if(null!==(t=E()))if(null!==(n=wn())){for(r=[],u=i,null!==(o=G())&&null!==(s=hn())?o=[o,s]:(o=null,i=u);null!==o;)r.push(o),u=i,null!==(o=G())&&null!==(s=hn())?o=[o,s]:(o=null,i=u);null!==r?e=[e,t,n,r]:(e=null,i=a)}else e=null,i=a;else e=null,i=a;else e=null,i=a;return e}function hn(){var e;return null===(e=dn())&&null===(e=pn())&&null===(e=_n())&&null===(e=vn())&&null===(e=mn())&&(e=St()),e}function dn(){var e,n,r,o,a,u;return o=i,a=i,"ttl"===t.substr(i,3).toLowerCase()?(e=t.substr(i,3),i+=3):(e=null,0===s&&l('"ttl"')),null!==e&&null!==(n=U())&&null!==(r=Cn())?e=[e,n,r]:(e=null,i=a),null!==e&&(u=e[2],e=void(Hn.ttl=u)),null===e&&(i=o),e}function pn(){var e,n,r,o,a,u;return o=i,a=i,"maddr"===t.substr(i,5).toLowerCase()?(e=t.substr(i,5),i+=5):(e=null,0===s&&l('"maddr"')),null!==e&&null!==(n=U())&&null!==(r=ae())?e=[e,n,r]:(e=null,i=a),null!==e&&(u=e[2],e=void(Hn.maddr=u)),null===e&&(i=o),e}function _n(){var e,n,r,o,a,u;return o=i,a=i,"received"===t.substr(i,8).toLowerCase()?(e=t.substr(i,8),i+=8):(e=null,0===s&&l('"received"')),null!==e&&null!==(n=U())?(null===(r=_e())&&(r=he()),null!==r?e=[e,n,r]:(e=null,i=a)):(e=null,i=a),null!==e&&(u=e[2],e=void(Hn.received=u)),null===e&&(i=o),e}function vn(){var e,n,r,o,a,u;return o=i,a=i,"branch"===t.substr(i,6).toLowerCase()?(e=t.substr(i,6),i+=6):(e=null,0===s&&l('"branch"')),null!==e&&null!==(n=U())&&null!==(r=x())?e=[e,n,r]:(e=null,i=a),null!==e&&(u=e[2],e=void(Hn.branch=u)),null===e&&(i=o),e}function mn(){var e,n,r,o,a;return o=i,"rport"===t.substr(i,5).toLowerCase()?(e=t.substr(i,5),i+=5):(e=null,0===s&&l('"rport"')),null!==e?(a=i,null!==(n=U())&&null!==(r=yn())?n=[n,r]:(n=null,i=a),null!==(n=null!==n?n:"")?e=[e,n]:(e=null,i=o)):(e=null,i=o),e}function yn(){var e,t,n,r,o,s,a,u;return s=i,a=i,null!==(e=null!==(e=f())?e:"")&&null!==(t=null!==(t=f())?t:"")&&null!==(n=null!==(n=f())?n:"")&&null!==(r=null!==(r=f())?r:"")&&null!==(o=null!==(o=f())?o:"")?e=[e,t,n,r,o]:(e=null,i=a),null!==e&&(u=e,e=void(Hn.rport=parseInt(u.join("")))),null===e&&(i=s),e}function gn(){var e,t,n,r,o,s;return s=i,null!==(e=bn())&&null!==(t=L())&&null!==(n=x())&&null!==(r=L())&&null!==(o=Tn())?e=[e,t,n,r,o]:(e=null,i=s),e}function bn(){var e,n,r;return n=i,"sip"===t.substr(i,3).toLowerCase()?(e=t.substr(i,3),i+=3):(e=null,0===s&&l('"SIP"')),null===e&&(e=x()),null!==e&&(r=e,e=void(Hn.protocol=r)),null===e&&(i=n),e}function Tn(){var e,n,r;return n=i,"udp"===t.substr(i,3).toLowerCase()?(e=t.substr(i,3),i+=3):(e=null,0===s&&l('"UDP"')),null===e&&("tcp"===t.substr(i,3).toLowerCase()?(e=t.substr(i,3),i+=3):(e=null,0===s&&l('"TCP"')),null===e&&("tls"===t.substr(i,3).toLowerCase()?(e=t.substr(i,3),i+=3):(e=null,0===s&&l('"TLS"')),null===e&&("sctp"===t.substr(i,4).toLowerCase()?(e=t.substr(i,4),i+=4):(e=null,0===s&&l('"SCTP"')),null===e&&(e=x())))),null!==e&&(r=e,e=void(Hn.transport=r)),null===e&&(i=n),e}function wn(){var e,t,n,r,o;return r=i,null!==(e=Sn())?(o=i,null!==(t=B())&&null!==(n=En())?t=[t,n]:(t=null,i=o),null!==(t=null!==t?t:"")?e=[e,t]:(e=null,i=r)):(e=null,i=r),e}function Sn(){var e,n;return n=i,null===(e=_e())&&null===(e=fe())&&(e=ue()),null!==e&&(e=function(e){Hn.host=t.substring(i,e)}(n)),null===e&&(i=n),e}function En(){var e,t,n,r,o,s,a,u;return s=i,a=i,null!==(e=null!==(e=f())?e:"")&&null!==(t=null!==(t=f())?t:"")&&null!==(n=null!==(n=f())?n:"")&&null!==(r=null!==(r=f())?r:"")&&null!==(o=null!==(o=f())?o:"")?e=[e,t,n,r,o]:(e=null,i=a),null!==e&&(u=e,e=void(Hn.port=parseInt(u.join("")))),null===e&&(i=s),e}function Cn(){var e,t,n,r,o;return r=i,o=i,null!==(e=f())&&null!==(t=null!==(t=f())?t:"")&&null!==(n=null!==(n=f())?n:"")?e=[e,t,n]:(e=null,i=o),null!==e&&(e=parseInt(e.join(""))),null===e&&(i=r),e}function An(){var e,t,n;return t=i,null!==(e=Tt())&&(n=e,e=void(Hn.expires=n)),null===e&&(i=t),e}function Rn(){var e;return null===(e=In())&&(e=St()),e}function In(){var e,n,r,o,a,u;return o=i,a=i,"refresher"===t.substr(i,9).toLowerCase()?(e=t.substr(i,9),i+=9):(e=null,0===s&&l('"refresher"')),null!==e&&null!==(n=U())?("uac"===t.substr(i,3).toLowerCase()?(r=t.substr(i,3),i+=3):(r=null,0===s&&l('"uac"')),null===r&&("uas"===t.substr(i,3).toLowerCase()?(r=t.substr(i,3),i+=3):(r=null,0===s&&l('"uas"'))),null!==r?e=[e,n,r]:(e=null,i=a)):(e=null,i=a),null!==e&&(u=e[2],e=void(Hn.refresher=u.toLowerCase())),null===e&&(i=o),e}function On(){var e,t;for(e=[],null===(t=I())&&null===(t=k())&&(t=E());null!==t;)e.push(t),null===(t=I())&&null===(t=k())&&(t=E());return e}function kn(){var e,n,r,o,a,u,c,f,h,d,p;return d=i,p=i,null!==(e=Nn())?(45===t.charCodeAt(i)?(n="-",i++):(n=null,0===s&&l('"-"')),null!==n&&null!==(r=xn())?(45===t.charCodeAt(i)?(o="-",i++):(o=null,0===s&&l('"-"')),null!==o&&null!==(a=xn())?(45===t.charCodeAt(i)?(u="-",i++):(u=null,0===s&&l('"-"')),null!==u&&null!==(c=xn())?(45===t.charCodeAt(i)?(f="-",i++):(f=null,0===s&&l('"-"')),null!==f&&null!==(h=Pn())?e=[e,n,r,o,a,u,c,f,h]:(e=null,i=p)):(e=null,i=p)):(e=null,i=p)):(e=null,i=p)):(e=null,i=p),null!==e&&(e=function(e){Hn=t.substring(i+5,e)}(d,e[0])),null===e&&(i=d),e}function xn(){var e,t,n,r,o;return o=i,null!==(e=d())&&null!==(t=d())&&null!==(n=d())&&null!==(r=d())?e=[e,t,n,r]:(e=null,i=o),e}function Nn(){var e,t,n;return n=i,null!==(e=xn())&&null!==(t=xn())?e=[e,t]:(e=null,i=n),e}function Pn(){var e,t,n,r;return r=i,null!==(e=xn())&&null!==(t=xn())&&null!==(n=xn())?e=[e,t,n]:(e=null,i=r),e}function Dn(){var e,n,r,o,a,u;return o=i,a=i,null!==(e=P())?(u=i,64===t.charCodeAt(i)?(n="@",i++):(n=null,0===s&&l('"@"')),null!==n&&null!==(r=P())?n=[n,r]:(n=null,i=u),null!==(n=null!==n?n:"")?e=[e,n]:(e=null,i=a)):(e=null,i=a),null!==e&&(e=function(e){Hn.call_id=t.substring(i,e)}(o)),null===e&&(i=o),e}function Ln(){var e;return null===(e=Un())&&null===(e=Mn())&&null===(e=jn())&&(e=St()),e}function Un(){var e,n,r,o,a,u;return o=i,a=i,"to-tag"===t.substr(i,6)?(e="to-tag",i+=6):(e=null,0===s&&l('"to-tag"')),null!==e&&null!==(n=U())&&null!==(r=x())?e=[e,n,r]:(e=null,i=a),null!==e&&(u=e[2],e=void(Hn.to_tag=u)),null===e&&(i=o),e}function Mn(){var e,n,r,o,a,u;return o=i,a=i,"from-tag"===t.substr(i,8)?(e="from-tag",i+=8):(e=null,0===s&&l('"from-tag"')),null!==e&&null!==(n=U())&&null!==(r=x())?e=[e,n,r]:(e=null,i=a),null!==e&&(u=e[2],e=void(Hn.from_tag=u)),null===e&&(i=o),e}function jn(){var e,n;return n=i,"early-only"===t.substr(i,10)?(e="early-only",i+=10):(e=null,0===s&&l('"early-only"')),null!==e&&(e=void(Hn.early_only=!0)),null===e&&(i=n),e}var qn=n(670),Fn=n(47),Hn={};if(null===o[r]()||i!==t.length){var Gn=Math.max(i,a),Bn=Gn<t.length?t.charAt(Gn):null,Wn=function(){for(var e=1,n=1,r=!1,o=0;o<Math.max(i,a);o++){var s=t.charAt(o);"\n"===s?(r||e++,n=1,r=!1):"\r"===s||"\u2028"===s||"\u2029"===s?(e++,n=1,r=!0):(n++,r=!1)}return{line:e,column:n}}();return new this.SyntaxError(function(e){e.sort();for(var t=null,n=[],r=0;r<e.length;r++)e[r]!==t&&(n.push(e[r]),t=e[r]);return n}(u),Bn,Gn,Wn.line,Wn.column),-1}return Hn},toSource:function(){return this._source},SyntaxError:function(t,n,r,o,i){this.name="SyntaxError",this.expected=t,this.found=n,this.message=function(t,n){var r;switch(t.length){case 0:r="end of input";break;case 1:r=t[0];break;default:r=t.slice(0,t.length-1).join(", ")+" or "+t[t.length-1]}return"Expected "+r+" but "+(n?e(n):"end of input")+" found."}(t,n),this.offset=r,this.line=o,this.column=i}};return t.SyntaxError.prototype=Error.prototype,t}()},53:(e,t,n)=>{"use strict";var r=n(633),o=n(349),i=n(956),s=n(137),a=n(544),u=n(670),l=n(47),c=n(561),f=n(32);n(720)("JsSIP")("version %s",r.version),e.exports={C:o,Exceptions:i,Utils:s,UA:a,URI:u,NameAddrHeader:l,WebSocketInterface:f,Grammar:c,debug:n(720),get name(){return r.title},get version(){return r.version}}},510:(e,t,n)=>{"use strict";function r(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}var o=n(720),i="JsSIP";e.exports=function(){function e(t){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),t?(this._debug=o.default("".concat(i,":").concat(t)),this._warn=o.default("".concat(i,":WARN:").concat(t)),this._error=o.default("".concat(i,":ERROR:").concat(t))):(this._debug=o.default(i),this._warn=o.default("".concat(i,":WARN")),this._error=o.default("".concat(i,":ERROR"))),this._debug.log=console.info.bind(console),this._warn.log=console.warn.bind(console),this._error.log=console.error.bind(console)}var t,n,s;return t=e,(n=[{key:"debug",get:function(){return this._debug}},{key:"warn",get:function(){return this._warn}},{key:"error",get:function(){return this._error}}])&&r(t.prototype,n),s&&r(t,s),e}()},603:(e,t,n)=>{"use strict";function r(e){return r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},r(e)}function o(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function i(e,t){return i=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},i(e,t)}function s(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,o=a(e);if(t){var i=a(this).constructor;n=Reflect.construct(o,arguments,i)}else n=o.apply(this,arguments);return function(e,t){if(t&&("object"===r(t)||"function"==typeof t))return t;return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}(this,n)}}function a(e){return a=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},a(e)}var u=n(7).EventEmitter,l=n(510),c=n(349),f=n(213),h=n(137),d=n(396),p=n(956),_=n(670),v=new l("Message");e.exports=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&i(e,t)}(u,e);var t,n,r,a=s(u);function u(e){var t;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,u),(t=a.call(this))._ua=e,t._request=null,t._closed=!1,t._direction=null,t._local_identity=null,t._remote_identity=null,t._is_replied=!1,t._data={},t}return t=u,n=[{key:"send",value:function(e,t){var n=this,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},o=e;if(void 0===e||void 0===t)throw new TypeError("Not enough arguments");if(!(e=this._ua.normalizeTarget(e)))throw new TypeError("Invalid target: ".concat(o));var i=h.cloneArray(r.extraHeaders),s=h.cloneObject(r.eventHandlers),a=r.contentType||"text/plain",u={};for(var l in r.fromUserName&&(u.from_uri=new _("sip",r.fromUserName,this._ua.configuration.uri.host),i.push("P-Preferred-Identity: ".concat(this._ua.configuration.uri.toString()))),r.fromDisplayName&&(u.from_display_name=r.fromDisplayName),s)Object.prototype.hasOwnProperty.call(s,l)&&this.on(l,s[l]);i.push("Content-Type: ".concat(a)),this._request=new f.OutgoingRequest(c.MESSAGE,e,this._ua,u,i),t&&(this._request.body=t);var p=new d(this._ua,this._request,{onRequestTimeout:function(){n._onRequestTimeout()},onTransportError:function(){n._onTransportError()},onReceiveResponse:function(e){n._receiveResponse(e)}});this._newMessage("local",this._request),p.send()}},{key:"init_incoming",value:function(e){this._request=e,this._newMessage("remote",e),this._is_replied||(this._is_replied=!0,e.reply(200)),this._close()}},{key:"accept",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=h.cloneArray(e.extraHeaders),n=e.body;if("incoming"!==this._direction)throw new p.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,n)}},{key:"reject",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.status_code||480,n=e.reason_phrase,r=h.cloneArray(e.extraHeaders),o=e.body;if("incoming"!==this._direction)throw new p.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,n,r,o)}},{key:"_receiveResponse",value:function(e){if(!this._closed)switch(!0){case/^1[0-9]{2}$/.test(e.status_code):break;case/^2[0-9]{2}$/.test(e.status_code):this._succeeded("remote",e);break;default:var t=h.sipErrorCause(e.status_code);this._failed("remote",e,t)}}},{key:"_onRequestTimeout",value:function(){this._closed||this._failed("system",null,c.causes.REQUEST_TIMEOUT)}},{key:"_onTransportError",value:function(){this._closed||this._failed("system",null,c.causes.CONNECTION_ERROR)}},{key:"_close",value:function(){this._closed=!0,this._ua.destroyMessage(this)}},{key:"_newMessage",value:function(e,t){"remote"===e?(this._direction="incoming",this._local_identity=t.to,this._remote_identity=t.from):"local"===e&&(this._direction="outgoing",this._local_identity=t.from,this._remote_identity=t.to),this._ua.newMessage(this,{originator:e,message:this,request:t})}},{key:"_failed",value:function(e,t,n){v.debug("MESSAGE failed"),this._close(),v.debug('emit "failed"'),this.emit("failed",{originator:e,response:t||null,cause:n})}},{key:"_succeeded",value:function(e,t){v.debug("MESSAGE succeeded"),this._close(),v.debug('emit "succeeded"'),this.emit("succeeded",{originator:e,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&&o(t.prototype,n),r&&o(t,r),u}(u)},47:(e,t,n)=>{"use strict";function r(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function o(e,t,n){return t&&r(e.prototype,t),n&&r(e,n),e}var i=n(670),s=n(561);e.exports=function(){function e(t,n,r){if(function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),!(t&&t instanceof i))throw new TypeError('missing or invalid "uri" parameter');for(var o in this._uri=t,this._parameters={},this.display_name=n,r)Object.prototype.hasOwnProperty.call(r,o)&&this.setParam(o,r[o])}return o(e,null,[{key:"parse",value:function(e){return-1!==(e=s.parse(e,"Name_Addr_Header"))?e:void 0}}]),o(e,[{key:"setParam",value:function(e,t){e&&(this._parameters[e.toLowerCase()]=null==t?null:t.toString())}},{key:"getParam",value:function(e){if(e)return this._parameters[e.toLowerCase()]}},{key:"hasParam",value:function(e){if(e)return!!this._parameters.hasOwnProperty(e.toLowerCase())}},{key:"deleteParam",value:function(e){if(e=e.toLowerCase(),this._parameters.hasOwnProperty(e)){var t=this._parameters[e];return delete this._parameters[e],t}}},{key:"clearParams",value:function(){this._parameters={}}},{key:"clone",value:function(){return new e(this._uri.clone(),this._display_name,JSON.parse(JSON.stringify(this._parameters)))}},{key:"_quote",value:function(e){return e.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}},{key:"toString",value:function(){var e=this._display_name?'"'.concat(this._quote(this._display_name),'" '):"";for(var t in e+="<".concat(this._uri.toString(),">"),this._parameters)Object.prototype.hasOwnProperty.call(this._parameters,t)&&(e+=";".concat(t),null!==this._parameters[t]&&(e+="=".concat(this._parameters[t])));return e}},{key:"uri",get:function(){return this._uri}},{key:"display_name",get:function(){return this._display_name},set:function(e){this._display_name=0===e?"0":e}}]),e}()},6:(e,t,n)=>{"use strict";function r(e){return r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},r(e)}function o(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function i(e,t){return i=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},i(e,t)}function s(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,o=a(e);if(t){var i=a(this).constructor;n=Reflect.construct(o,arguments,i)}else n=o.apply(this,arguments);return function(e,t){if(t&&("object"===r(t)||"function"==typeof t))return t;return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}(this,n)}}function a(e){return a=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},a(e)}var u=n(7).EventEmitter,l=n(510),c=n(349),f=n(213),h=n(137),d=n(396),p=n(956),_=new l("Options");e.exports=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&i(e,t)}(u,e);var t,n,r,a=s(u);function u(e){var t;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,u),(t=a.call(this))._ua=e,t._request=null,t._closed=!1,t._direction=null,t._local_identity=null,t._remote_identity=null,t._is_replied=!1,t._data={},t}return t=u,n=[{key:"send",value:function(e,t){var n=this,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},o=e;if(void 0===e)throw new TypeError("A target is required for OPTIONS");if(!(e=this._ua.normalizeTarget(e)))throw new TypeError("Invalid target: ".concat(o));var i=h.cloneArray(r.extraHeaders),s=h.cloneObject(r.eventHandlers),a=r.contentType||"application/sdp";for(var u in s)Object.prototype.hasOwnProperty.call(s,u)&&this.on(u,s[u]);i.push("Content-Type: ".concat(a)),this._request=new f.OutgoingRequest(c.OPTIONS,e,this._ua,null,i),t&&(this._request.body=t);var l=new d(this._ua,this._request,{onRequestTimeout:function(){n._onRequestTimeout()},onTransportError:function(){n._onTransportError()},onReceiveResponse:function(e){n._receiveResponse(e)}});this._newOptions("local",this._request),l.send()}},{key:"init_incoming",value:function(e){this._request=e,this._newOptions("remote",e),this._is_replied||(this._is_replied=!0,e.reply(200)),this._close()}},{key:"accept",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=h.cloneArray(e.extraHeaders),n=e.body;if("incoming"!==this._direction)throw new p.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,n)}},{key:"reject",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.status_code||480,n=e.reason_phrase,r=h.cloneArray(e.extraHeaders),o=e.body;if("incoming"!==this._direction)throw new p.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,n,r,o)}},{key:"_receiveResponse",value:function(e){if(!this._closed)switch(!0){case/^1[0-9]{2}$/.test(e.status_code):break;case/^2[0-9]{2}$/.test(e.status_code):this._succeeded("remote",e);break;default:var t=h.sipErrorCause(e.status_code);this._failed("remote",e,t)}}},{key:"_onRequestTimeout",value:function(){this._closed||this._failed("system",null,c.causes.REQUEST_TIMEOUT)}},{key:"_onTransportError",value:function(){this._closed||this._failed("system",null,c.causes.CONNECTION_ERROR)}},{key:"_close",value:function(){this._closed=!0,this._ua.destroyMessage(this)}},{key:"_newOptions",value:function(e,t){"remote"===e?(this._direction="incoming",this._local_identity=t.to,this._remote_identity=t.from):"local"===e&&(this._direction="outgoing",this._local_identity=t.from,this._remote_identity=t.to),this._ua.newOptions(this,{originator:e,message:this,request:t})}},{key:"_failed",value:function(e,t,n){_.debug("OPTIONS failed"),this._close(),_.debug('emit "failed"'),this.emit("failed",{originator:e,response:t||null,cause:n})}},{key:"_succeeded",value:function(e,t){_.debug("OPTIONS succeeded"),this._close(),_.debug('emit "succeeded"'),this.emit("succeeded",{originator:e,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&&o(t.prototype,n),r&&o(t,r),u}(u)},725:(e,t,n)=>{"use strict";function r(e,t){var n;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return o(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return o(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var s,a=!0,u=!1;return{s:function(){n=e[Symbol.iterator]()},n:function(){var e=n.next();return a=e.done,e},e:function(e){u=!0,s=e},f:function(){try{a||null==n.return||n.return()}finally{if(u)throw s}}}}function o(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var i=n(510),s=n(561),a=n(213),u=new i("Parser");function l(e,t){var n=t,r=0,o=0;if(e.substring(n,n+2).match(/(^\r\n)/))return-2;for(;0===r;){if(-1===(o=e.indexOf("\r\n",n)))return o;!e.substring(o+2,o+4).match(/(^\r\n)/)&&e.charAt(o+2).match(/(^\s+)/)?n=o+2:r=o}return r}function c(e,t,n,o){var i,u=t.indexOf(":",n),l=t.substring(n,u).trim(),c=t.substring(u+1,o).trim();switch(l.toLowerCase()){case"via":case"v":e.addHeader("via",c),1===e.getHeaders("via").length?(i=e.parseHeader("Via"))&&(e.via=i,e.via_branch=i.branch):i=0;break;case"from":case"f":e.setHeader("from",c),(i=e.parseHeader("from"))&&(e.from=i,e.from_tag=i.getParam("tag"));break;case"to":case"t":e.setHeader("to",c),(i=e.parseHeader("to"))&&(e.to=i,e.to_tag=i.getParam("tag"));break;case"record-route":if(-1===(i=s.parse(c,"Record_Route")))i=void 0;else{var f,h=r(i);try{for(h.s();!(f=h.n()).done;){var d=f.value;e.addHeader("record-route",c.substring(d.possition,d.offset)),e.headers["Record-Route"][e.getHeaders("record-route").length-1].parsed=d.parsed}}catch(e){h.e(e)}finally{h.f()}}break;case"call-id":case"i":e.setHeader("call-id",c),(i=e.parseHeader("call-id"))&&(e.call_id=c);break;case"contact":case"m":if(-1===(i=s.parse(c,"Contact")))i=void 0;else{var p,_=r(i);try{for(_.s();!(p=_.n()).done;){var v=p.value;e.addHeader("contact",c.substring(v.possition,v.offset)),e.headers.Contact[e.getHeaders("contact").length-1].parsed=v.parsed}}catch(e){_.e(e)}finally{_.f()}}break;case"content-length":case"l":e.setHeader("content-length",c),i=e.parseHeader("content-length");break;case"content-type":case"c":e.setHeader("content-type",c),i=e.parseHeader("content-type");break;case"cseq":e.setHeader("cseq",c),(i=e.parseHeader("cseq"))&&(e.cseq=i.value),e instanceof a.IncomingResponse&&(e.method=i.method);break;case"max-forwards":e.setHeader("max-forwards",c),i=e.parseHeader("max-forwards");break;case"www-authenticate":e.setHeader("www-authenticate",c),i=e.parseHeader("www-authenticate");break;case"proxy-authenticate":e.setHeader("proxy-authenticate",c),i=e.parseHeader("proxy-authenticate");break;case"session-expires":case"x":e.setHeader("session-expires",c),(i=e.parseHeader("session-expires"))&&(e.session_expires=i.expires,e.session_expires_refresher=i.refresher);break;case"refer-to":case"r":e.setHeader("refer-to",c),(i=e.parseHeader("refer-to"))&&(e.refer_to=i);break;case"replaces":e.setHeader("replaces",c),(i=e.parseHeader("replaces"))&&(e.replaces=i);break;case"event":case"o":e.setHeader("event",c),(i=e.parseHeader("event"))&&(e.event=i);break;default:e.addHeader(l,c),i=0}return void 0!==i||{error:'error parsing header "'.concat(l,'"')}}t.parseMessage=function(e,t){var n,r,o=e.indexOf("\r\n");if(-1!==o){var i=e.substring(0,o),f=s.parse(i,"Request_Response");if(-1!==f){f.status_code?((n=new a.IncomingResponse).status_code=f.status_code,n.reason_phrase=f.reason_phrase):((n=new a.IncomingRequest(t)).method=f.method,n.ruri=f.uri),n.data=e;for(var h=o+2;;){if(-2===(o=l(e,h))){r=h+2;break}if(-1===o)return void u.warn("parseMessage() | malformed message");if(!0!==(f=c(n,e,h,o)))return void u.warn("parseMessage() |",f.error);h=o+2}if(n.hasHeader("content-length")){var d=n.getHeader("content-length");n.body=e.substr(r,d)}else n.body=e.substring(r);return n}u.warn('parseMessage() | error parsing first line of SIP message: "'.concat(i,'"'))}else u.warn("parseMessage() | no CRLF found, not a SIP message")}},395:(e,t,n)=>{"use strict";function r(e){return r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},r(e)}function o(e,t){var n;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return i(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return i(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,o=function(){};return{s:o,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var s,a=!0,u=!1;return{s:function(){n=e[Symbol.iterator]()},n:function(){var e=n.next();return a=e.done,e},e:function(e){u=!0,s=e},f:function(){try{a||null==n.return||n.return()}finally{if(u)throw s}}}}function i(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function s(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function a(e,t,n){return t&&s(e.prototype,t),n&&s(e,n),e}function u(e,t){return u=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},u(e,t)}function l(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,o=c(e);if(t){var i=c(this).constructor;n=Reflect.construct(o,arguments,i)}else n=o.apply(this,arguments);return function(e,t){if(t&&("object"===r(t)||"function"==typeof t))return t;return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}(this,n)}}function c(e){return c=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},c(e)}var f=n(7).EventEmitter,h=n(363),d=n(510),p=n(349),_=n(956),v=n(143),m=n(137),y=n(672),g=n(213),b=n(978),T=n(396),w=n(697),S=n(850),E=n(276),C=n(716),A=n(670),R=new d("RTCSession"),I={STATUS_NULL:0,STATUS_INVITE_SENT:1,STATUS_1XX_RECEIVED:2,STATUS_INVITE_RECEIVED:3,STATUS_WAITING_FOR_ANSWER:4,STATUS_ANSWERED:5,STATUS_WAITING_FOR_ACK:6,STATUS_CANCELED:7,STATUS_TERMINATED:8,STATUS_CONFIRMED:9},O=["audio","video"];e.exports=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&u(e,t)}(n,e);var t=l(n);function n(e){var r;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,n),R.debug("new"),(r=t.call(this))._id=null,r._ua=e,r._status=I.STATUS_NULL,r._dialog=null,r._earlyDialogs={},r._contact=null,r._from_tag=null,r._to_tag=null,r._connection=null,r._connectionPromiseQueue=Promise.resolve(),r._request=null,r._is_canceled=!1,r._cancel_reason="",r._is_confirmed=!1,r._late_sdp=!1,r._rtcOfferConstraints=null,r._rtcAnswerConstraints=null,r._localMediaStream=null,r._localMediaStreamLocallyGenerated=!1,r._rtcReady=!0,r._iceReady=!1,r._timers={ackTimer:null,expiresTimer:null,invite2xxTimer:null,userNoAnswerTimer:null},r._direction=null,r._local_identity=null,r._remote_identity=null,r._start_time=null,r._end_time=null,r._tones=null,r._audioMuted=!1,r._videoMuted=!1,r._localHold=!1,r._remoteHold=!1,r._sessionTimers={enabled:r._ua.configuration.session_timers,refreshMethod:r._ua.configuration.session_timers_refresh_method,defaultExpires:p.SESSION_EXPIRES,currentExpires:null,running:!1,refresher:!1,timer:null},r._referSubscribers={},r._data={},r}return a(n,null,[{key:"C",get:function(){return I}}]),a(n,[{key:"isInProgress",value:function(){switch(this._status){case I.STATUS_NULL:case I.STATUS_INVITE_SENT:case I.STATUS_1XX_RECEIVED:case I.STATUS_INVITE_RECEIVED:case I.STATUS_WAITING_FOR_ANSWER:return!0;default:return!1}}},{key:"isEstablished",value:function(){switch(this._status){case I.STATUS_ANSWERED:case I.STATUS_WAITING_FOR_ACK:case I.STATUS_CONFIRMED:return!0;default:return!1}}},{key:"isEnded",value:function(){switch(this._status){case I.STATUS_CANCELED:case I.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(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2?arguments[2]:void 0;R.debug("connect()");var r=e,o=m.cloneObject(t.eventHandlers),i=m.cloneArray(t.extraHeaders),s=m.cloneObject(t.mediaConstraints,{audio:!0,video:!0}),a=t.mediaStream||null,u=m.cloneObject(t.pcConfig,{iceServers:[]}),l=t.rtcConstraints||null,c=t.rtcOfferConstraints||null;if(this._rtcOfferConstraints=c,this._rtcAnswerConstraints=t.rtcAnswerConstraints||null,this._data=t.data||this._data,void 0===e)throw new TypeError("Not enough arguments");if(this._status!==I.STATUS_NULL)throw new _.InvalidStateError(this._status);if(!window.RTCPeerConnection)throw new _.NotSupportedError("WebRTC not supported");if(!(e=this._ua.normalizeTarget(e)))throw new TypeError("Invalid target: ".concat(r));for(var f in this._sessionTimers.enabled&&m.isDecimal(t.sessionTimersExpires)&&(t.sessionTimersExpires>=p.MIN_SESSION_EXPIRES?this._sessionTimers.defaultExpires=t.sessionTimersExpires:this._sessionTimers.defaultExpires=p.SESSION_EXPIRES),o)Object.prototype.hasOwnProperty.call(o,f)&&this.on(f,o[f]);this._from_tag=m.newTag();var h=t.anonymous||!1,d={from_tag:this._from_tag};this._contact=this._ua.contact.toString({anonymous:h,outbound:!0}),h?(d.from_display_name="Anonymous",d.from_uri=new A("sip","anonymous","anonymous.invalid"),i.push("P-Preferred-Identity: ".concat(this._ua.configuration.uri.toString())),i.push("Privacy: id")):t.fromUserName&&(d.from_uri=new A("sip",t.fromUserName,this._ua.configuration.uri.host),i.push("P-Preferred-Identity: ".concat(this._ua.configuration.uri.toString()))),t.fromDisplayName&&(d.from_display_name=t.fromDisplayName),i.push("Contact: ".concat(this._contact)),i.push("Content-Type: application/sdp"),this._sessionTimers.enabled&&i.push("Session-Expires: ".concat(this._sessionTimers.defaultExpires).concat(this._ua.configuration.session_timers_force_refresher?";refresher=uac":"")),this._request=new g.InitialOutgoingInviteRequest(e,this._ua,d,i),this._id=this._request.call_id+this._from_tag,this._createRTCConnection(u,l),this._direction="outgoing",this._local_identity=this._request.from,this._remote_identity=this._request.to,n&&n(this),this._newRTCSession("local",this._request),this._sendInitialRequest(s,c,a)}},{key:"init_incoming",value:function(e,t){var n,r=this;R.debug("init_incoming()");var o=e.hasHeader("Content-Type")?e.getHeader("Content-Type").toLowerCase():void 0;e.body&&"application/sdp"!==o?e.reply(415):(this._status=I.STATUS_INVITE_RECEIVED,this._from_tag=e.from_tag,this._id=e.call_id+this._from_tag,this._request=e,this._contact=this._ua.contact.toString(),e.hasHeader("expires")&&(n=1e3*e.getHeader("expires")),e.to_tag=m.newTag(),this._createDialog(e,"UAS",!0)?(e.body?this._late_sdp=!1:this._late_sdp=!0,this._status=I.STATUS_WAITING_FOR_ANSWER,this._timers.userNoAnswerTimer=setTimeout((function(){e.reply(408),r._failed("local",null,p.causes.NO_ANSWER)}),this._ua.configuration.no_answer_timeout),n&&(this._timers.expiresTimer=setTimeout((function(){r._status===I.STATUS_WAITING_FOR_ANSWER&&(e.reply(487),r._failed("system",null,p.causes.EXPIRES))}),n)),this._direction="incoming",this._local_identity=e.to,this._remote_identity=e.from,t&&t(this),this._newRTCSession("remote",e),this._status!==I.STATUS_TERMINATED&&(e.reply(180,null,["Contact: ".concat(this._contact)]),this._progress("local",null))):e.reply(500,"Missing Contact header field"))}},{key:"answer",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};R.debug("answer()");var n=this._request,r=m.cloneArray(t.extraHeaders),i=m.cloneObject(t.mediaConstraints),s=t.mediaStream||null,a=m.cloneObject(t.pcConfig,{iceServers:[]}),u=t.rtcConstraints||null,l=t.rtcAnswerConstraints||null,c=m.cloneObject(t.rtcOfferConstraints),f=!1,h=!1,d=!1,v=!1;if(this._rtcAnswerConstraints=l,this._rtcOfferConstraints=t.rtcOfferConstraints||null,this._data=t.data||this._data,"incoming"!==this._direction)throw new _.NotSupportedError('"answer" not supported for outgoing RTCSession');if(this._status!==I.STATUS_WAITING_FOR_ANSWER)throw new _.InvalidStateError(this._status);if(this._sessionTimers.enabled&&m.isDecimal(t.sessionTimersExpires)&&(t.sessionTimersExpires>=p.MIN_SESSION_EXPIRES?this._sessionTimers.defaultExpires=t.sessionTimersExpires:this._sessionTimers.defaultExpires=p.SESSION_EXPIRES),this._status=I.STATUS_ANSWERED,this._createDialog(n,"UAS")){clearTimeout(this._timers.userNoAnswerTimer),r.unshift("Contact: ".concat(this._contact));var y=n.parseSDP();Array.isArray(y.media)||(y.media=[y.media]);var g,b=o(y.media);try{for(b.s();!(g=b.n()).done;){var T=g.value;"audio"===T.type&&(f=!0,T.direction&&"sendrecv"!==T.direction||(d=!0)),"video"===T.type&&(h=!0,T.direction&&"sendrecv"!==T.direction||(v=!0))}}catch(e){b.e(e)}finally{b.f()}if(s&&!1===i.audio){var w,S=o(s.getAudioTracks());try{for(S.s();!(w=S.n()).done;){var E=w.value;s.removeTrack(E)}}catch(e){S.e(e)}finally{S.f()}}if(s&&!1===i.video){var C,A=o(s.getVideoTracks());try{for(A.s();!(C=A.n()).done;){var O=C.value;s.removeTrack(O)}}catch(e){A.e(e)}finally{A.f()}}s||void 0!==i.audio||(i.audio=d),s||void 0!==i.video||(i.video=v),s||f||c.offerToReceiveAudio||(i.audio=!1),s||h||c.offerToReceiveVideo||(i.video=!1),this._createRTCConnection(a,u),Promise.resolve().then((function(){return s||(i.audio||i.video?(e._localMediaStreamLocallyGenerated=!0,navigator.mediaDevices.getUserMedia(i).catch((function(t){if(e._status===I.STATUS_TERMINATED)throw new Error("terminated");throw n.reply(480),e._failed("local",null,p.causes.USER_DENIED_MEDIA_ACCESS),R.warn('emit "getusermediafailed" [error:%o]',t),e.emit("getusermediafailed",t),new Error("getUserMedia() failed")}))):void 0)})).then((function(t){if(e._status===I.STATUS_TERMINATED)throw new Error("terminated");e._localMediaStream=t,t&&t.getTracks().forEach((function(n){e._connection.addTrack(n,t)}))})).then((function(){if(!e._late_sdp){var t={originator:"remote",type:"offer",sdp:n.body};R.debug('emit "sdp"'),e.emit("sdp",t);var r=new RTCSessionDescription({type:"offer",sdp:t.sdp});return e._connectionPromiseQueue=e._connectionPromiseQueue.then((function(){return e._connection.setRemoteDescription(r)})).catch((function(t){throw n.reply(488),e._failed("system",null,p.causes.WEBRTC_ERROR),R.warn('emit "peerconnection:setremotedescriptionfailed" [error:%o]',t),e.emit("peerconnection:setremotedescriptionfailed",t),new Error("peerconnection.setRemoteDescription() failed")})),e._connectionPromiseQueue}})).then((function(){if(e._status===I.STATUS_TERMINATED)throw new Error("terminated");return e._connecting(n),e._late_sdp?e._createLocalDescription("offer",e._rtcOfferConstraints).catch((function(){throw n.reply(500),new Error("_createLocalDescription() failed")})):e._createLocalDescription("answer",l).catch((function(){throw n.reply(500),new Error("_createLocalDescription() failed")}))})).then((function(t){if(e._status===I.STATUS_TERMINATED)throw new Error("terminated");e._handleSessionTimersInIncomingRequest(n,r),n.reply(200,null,r,t,(function(){e._status=I.STATUS_WAITING_FOR_ACK,e._setInvite2xxTimer(n,t),e._setACKTimer(),e._accepted("local")}),(function(){e._failed("system",null,p.causes.CONNECTION_ERROR)}))})).catch((function(t){e._status!==I.STATUS_TERMINATED&&R.warn(t)}))}else n.reply(500,"Error creating dialog")}},{key:"terminate",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};R.debug("terminate()");var n,r=t.cause||p.causes.BYE,o=m.cloneArray(t.extraHeaders),i=t.body,s=t.status_code,a=t.reason_phrase;if(this._status===I.STATUS_TERMINATED)throw new _.InvalidStateError(this._status);switch(this._status){case I.STATUS_NULL:case I.STATUS_INVITE_SENT:case I.STATUS_1XX_RECEIVED:if(R.debug("canceling session"),s&&(s<200||s>=700))throw new TypeError("Invalid status_code: ".concat(s));s&&(a=a||p.REASON_PHRASE[s]||"",n="SIP ;cause=".concat(s,' ;text="').concat(a,'"')),this._status===I.STATUS_NULL||this._status===I.STATUS_INVITE_SENT?(this._is_canceled=!0,this._cancel_reason=n):this._status===I.STATUS_1XX_RECEIVED&&this._request.cancel(n),this._status=I.STATUS_CANCELED,this._failed("local",null,p.causes.CANCELED);break;case I.STATUS_WAITING_FOR_ANSWER:case I.STATUS_ANSWERED:if(R.debug("rejecting session"),(s=s||480)<300||s>=700)throw new TypeError("Invalid status_code: ".concat(s));this._request.reply(s,a,o,i),this._failed("local",null,p.causes.REJECTED);break;case I.STATUS_WAITING_FOR_ACK:case I.STATUS_CONFIRMED:if(R.debug("terminating session"),a=t.reason_phrase||p.REASON_PHRASE[s]||"",s&&(s<200||s>=700))throw new TypeError("Invalid status_code: ".concat(s));if(s&&o.push("Reason: SIP ;cause=".concat(s,'; text="').concat(a,'"')),this._status===I.STATUS_WAITING_FOR_ACK&&"incoming"===this._direction&&this._request.server_transaction.state!==v.C.STATUS_TERMINATED){var u=this._dialog;this.receiveRequest=function(t){t.method===p.ACK&&(e.sendRequest(p.BYE,{extraHeaders:o,body:i}),u.terminate())},this._request.server_transaction.on("stateChanged",(function(){e._request.server_transaction.state===v.C.STATUS_TERMINATED&&(e.sendRequest(p.BYE,{extraHeaders:o,body:i}),u.terminate())})),this._ended("local",null,r),this._dialog=u,this._ua.newDialog(u)}else this.sendRequest(p.BYE,{extraHeaders:o,body:i}),this._ended("local",null,r)}}},{key:"sendDTMF",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};R.debug("sendDTMF() | tones: %s",e);var n=0,r=t.duration||null,o=t.interToneGap||null,i=t.transportType||p.DTMF_TRANSPORT.INFO;if(void 0===e)throw new TypeError("Not enough arguments");if(this._status!==I.STATUS_CONFIRMED&&this._status!==I.STATUS_WAITING_FOR_ACK&&this._status!==I.STATUS_1XX_RECEIVED)throw new _.InvalidStateError(this._status);if(i!==p.DTMF_TRANSPORT.INFO&&i!==p.DTMF_TRANSPORT.RFC2833)throw new TypeError("invalid transportType: ".concat(i));if("number"==typeof e&&(e=e.toString()),!e||"string"!=typeof e||!e.match(/^[0-9A-DR#*,]+$/i))throw new TypeError("Invalid tones: ".concat(e));if(r&&!m.isDecimal(r))throw new TypeError("Invalid tone duration: ".concat(r));if(r?r<w.C.MIN_DURATION?(R.debug('"duration" value is lower than the minimum allowed, setting it to '.concat(w.C.MIN_DURATION," milliseconds")),r=w.C.MIN_DURATION):r>w.C.MAX_DURATION?(R.debug('"duration" value is greater than the maximum allowed, setting it to '.concat(w.C.MAX_DURATION," milliseconds")),r=w.C.MAX_DURATION):r=Math.abs(r):r=w.C.DEFAULT_DURATION,t.duration=r,o&&!m.isDecimal(o))throw new TypeError("Invalid interToneGap: ".concat(o));if(o?o<w.C.MIN_INTER_TONE_GAP?(R.debug('"interToneGap" value is lower than the minimum allowed, setting it to '.concat(w.C.MIN_INTER_TONE_GAP," milliseconds")),o=w.C.MIN_INTER_TONE_GAP):o=Math.abs(o):o=w.C.DEFAULT_INTER_TONE_GAP,i!==p.DTMF_TRANSPORT.RFC2833)this._tones?this._tones+=e:(this._tones=e,function e(){var i,s=this;if(this._status===I.STATUS_TERMINATED||!this._tones||n>=this._tones.length)return void(this._tones=null);var a=this._tones[n];if(n+=1,","===a)i=2e3;else{var u=new w(this);t.eventHandlers={onFailed:function(){s._tones=null}},u.send(a,t),i=r+o}setTimeout(e.bind(this),i)}.call(this));else{var s=this._getDTMFRTPSender();s&&(e=s.toneBuffer+e,s.insertDTMF(e,r,o))}}},{key:"sendInfo",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(R.debug("sendInfo()"),this._status!==I.STATUS_CONFIRMED&&this._status!==I.STATUS_WAITING_FOR_ACK&&this._status!==I.STATUS_1XX_RECEIVED)throw new _.InvalidStateError(this._status);new S(this).send(e,t,n)}},{key:"mute",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{audio:!0,video:!1};R.debug("mute()");var t=!1,n=!1;!1===this._audioMuted&&e.audio&&(t=!0,this._audioMuted=!0,this._toggleMuteAudio(!0)),!1===this._videoMuted&&e.video&&(n=!0,this._videoMuted=!0,this._toggleMuteVideo(!0)),!0!==t&&!0!==n||this._onmute({audio:t,video:n})}},{key:"unmute",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{audio:!0,video:!0};R.debug("unmute()");var t=!1,n=!1;!0===this._audioMuted&&e.audio&&(t=!0,this._audioMuted=!1,!1===this._localHold&&this._toggleMuteAudio(!1)),!0===this._videoMuted&&e.video&&(n=!0,this._videoMuted=!1,!1===this._localHold&&this._toggleMuteVideo(!1)),!0!==t&&!0!==n||this._onunmute({audio:t,video:n})}},{key:"hold",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=arguments.length>1?arguments[1]:void 0;if(R.debug("hold()"),this._status!==I.STATUS_WAITING_FOR_ACK&&this._status!==I.STATUS_CONFIRMED)return!1;if(!0===this._localHold)return!1;if(!this._isReadyToReOffer())return!1;this._localHold=!0,this._onhold("local");var r={succeeded:function(){n&&n()},failed:function(){e.terminate({cause:p.causes.WEBRTC_ERROR,status_code:500,reason_phrase:"Hold Failed"})}};return t.useUpdate?this._sendUpdate({sdpOffer:!0,eventHandlers:r,extraHeaders:t.extraHeaders}):this._sendReinvite({eventHandlers:r,extraHeaders:t.extraHeaders}),!0}},{key:"unhold",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=arguments.length>1?arguments[1]:void 0;if(R.debug("unhold()"),this._status!==I.STATUS_WAITING_FOR_ACK&&this._status!==I.STATUS_CONFIRMED)return!1;if(!1===this._localHold)return!1;if(!this._isReadyToReOffer())return!1;this._localHold=!1,this._onunhold("local");var r={succeeded:function(){n&&n()},failed:function(){e.terminate({cause:p.causes.WEBRTC_ERROR,status_code:500,reason_phrase:"Unhold Failed"})}};return t.useUpdate?this._sendUpdate({sdpOffer:!0,eventHandlers:r,extraHeaders:t.extraHeaders}):this._sendReinvite({eventHandlers:r,extraHeaders:t.extraHeaders}),!0}},{key:"renegotiate",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=arguments.length>1?arguments[1]:void 0;R.debug("renegotiate()");var r=t.rtcOfferConstraints||null;if(this._status!==I.STATUS_WAITING_FOR_ACK&&this._status!==I.STATUS_CONFIRMED)return!1;if(!this._isReadyToReOffer())return!1;var o={succeeded:function(){n&&n()},failed:function(){e.terminate({cause:p.causes.WEBRTC_ERROR,status_code:500,reason_phrase:"Media Renegotiation Failed"})}};return this._setLocalMediaStatus(),t.useUpdate?this._sendUpdate({sdpOffer:!0,eventHandlers:o,rtcOfferConstraints:r,extraHeaders:t.extraHeaders}):this._sendReinvite({eventHandlers:o,rtcOfferConstraints:r,extraHeaders:t.extraHeaders}),!0}},{key:"refer",value:function(e,t){var n=this;R.debug("refer()");var r=e;if(this._status!==I.STATUS_WAITING_FOR_ACK&&this._status!==I.STATUS_CONFIRMED)return!1;if(!(e=this._ua.normalizeTarget(e)))throw new TypeError("Invalid target: ".concat(r));var o=new C(this);o.sendRefer(e,t);var i=o.id;return this._referSubscribers[i]=o,o.on("requestFailed",(function(){delete n._referSubscribers[i]})),o.on("accepted",(function(){delete n._referSubscribers[i]})),o.on("failed",(function(){delete n._referSubscribers[i]})),o}},{key:"sendRequest",value:function(e,t){return R.debug("sendRequest()"),this._dialog.sendRequest(e,t)}},{key:"receiveRequest",value:function(e){var t=this;if(R.debug("receiveRequest()"),e.method===p.CANCEL)this._status!==I.STATUS_WAITING_FOR_ANSWER&&this._status!==I.STATUS_ANSWERED||(this._status=I.STATUS_CANCELED,this._request.reply(487),this._failed("remote",e,p.causes.CANCELED));else switch(e.method){case p.ACK:if(this._status!==I.STATUS_WAITING_FOR_ACK)return;if(this._status=I.STATUS_CONFIRMED,clearTimeout(this._timers.ackTimer),clearTimeout(this._timers.invite2xxTimer),this._late_sdp){if(!e.body){this.terminate({cause:p.causes.MISSING_SDP,status_code:400});break}var n={originator:"remote",type:"answer",sdp:e.body};R.debug('emit "sdp"'),this.emit("sdp",n);var r=new RTCSessionDescription({type:"answer",sdp:n.sdp});this._connectionPromiseQueue=this._connectionPromiseQueue.then((function(){return t._connection.setRemoteDescription(r)})).then((function(){t._is_confirmed||t._confirmed("remote",e)})).catch((function(e){t.terminate({cause:p.causes.BAD_MEDIA_DESCRIPTION,status_code:488}),R.warn('emit "peerconnection:setremotedescriptionfailed" [error:%o]',e),t.emit("peerconnection:setremotedescriptionfailed",e)}))}else this._is_confirmed||this._confirmed("remote",e);break;case p.BYE:this._status===I.STATUS_CONFIRMED||this._status===I.STATUS_WAITING_FOR_ACK?(e.reply(200),this._ended("remote",e,p.causes.BYE)):this._status===I.STATUS_INVITE_RECEIVED||this._status===I.STATUS_WAITING_FOR_ANSWER?(e.reply(200),this._request.reply(487,"BYE Received"),this._ended("remote",e,p.causes.BYE)):e.reply(403,"Wrong Status");break;case p.INVITE:this._status===I.STATUS_CONFIRMED?e.hasHeader("replaces")?this._receiveReplaces(e):this._receiveReinvite(e):e.reply(403,"Wrong Status");break;case p.INFO:if(this._status===I.STATUS_1XX_RECEIVED||this._status===I.STATUS_WAITING_FOR_ANSWER||this._status===I.STATUS_ANSWERED||this._status===I.STATUS_WAITING_FOR_ACK||this._status===I.STATUS_CONFIRMED){var o=e.hasHeader("Content-Type")?e.getHeader("Content-Type").toLowerCase():void 0;o&&o.match(/^application\/dtmf-relay/i)?new w(this).init_incoming(e):void 0!==o?new S(this).init_incoming(e):e.reply(415)}else e.reply(403,"Wrong Status");break;case p.UPDATE:this._status===I.STATUS_CONFIRMED?this._receiveUpdate(e):e.reply(403,"Wrong Status");break;case p.REFER:this._status===I.STATUS_CONFIRMED?this._receiveRefer(e):e.reply(403,"Wrong Status");break;case p.NOTIFY:this._status===I.STATUS_CONFIRMED?this._receiveNotify(e):e.reply(403,"Wrong Status");break;default:e.reply(501)}}},{key:"onTransportError",value:function(){R.warn("onTransportError()"),this._status!==I.STATUS_TERMINATED&&this.terminate({status_code:500,reason_phrase:p.causes.CONNECTION_ERROR,cause:p.causes.CONNECTION_ERROR})}},{key:"onRequestTimeout",value:function(){R.warn("onRequestTimeout()"),this._status!==I.STATUS_TERMINATED&&this.terminate({status_code:408,reason_phrase:p.causes.REQUEST_TIMEOUT,cause:p.causes.REQUEST_TIMEOUT})}},{key:"onDialogError",value:function(){R.warn("onDialogError()"),this._status!==I.STATUS_TERMINATED&&this.terminate({status_code:500,reason_phrase:p.causes.DIALOG_ERROR,cause:p.causes.DIALOG_ERROR})}},{key:"newDTMF",value:function(e){R.debug("newDTMF()"),this.emit("newDTMF",e)}},{key:"newInfo",value:function(e){R.debug("newInfo()"),this.emit("newInfo",e)}},{key:"_isReadyToReOffer",value:function(){return this._rtcReady?this._dialog?!0!==this._dialog.uac_pending_reply&&!0!==this._dialog.uas_pending_reply||(R.debug("_isReadyToReOffer() | there is another INVITE/UPDATE transaction in progress"),!1):(R.debug("_isReadyToReOffer() | session not established yet"),!1):(R.debug("_isReadyToReOffer() | internal WebRTC status not ready"),!1)}},{key:"_close",value:function(){if(R.debug("close()"),this._localMediaStream&&this._localMediaStreamLocallyGenerated&&(R.debug("close() | closing local MediaStream"),m.closeMediaStream(this._localMediaStream)),this._status!==I.STATUS_TERMINATED){if(this._status=I.STATUS_TERMINATED,this._connection)try{this._connection.close()}catch(e){R.warn("close() | error closing the RTCPeerConnection: %o",e)}for(var e in this._timers)Object.prototype.hasOwnProperty.call(this._timers,e)&&clearTimeout(this._timers[e]);for(var t in clearTimeout(this._sessionTimers.timer),this._dialog&&(this._dialog.terminate(),delete this._dialog),this._earlyDialogs)Object.prototype.hasOwnProperty.call(this._earlyDialogs,t)&&(this._earlyDialogs[t].terminate(),delete this._earlyDialogs[t]);for(var n in this._referSubscribers)Object.prototype.hasOwnProperty.call(this._referSubscribers,n)&&delete this._referSubscribers[n];this._ua.destroyRTCSession(this)}}},{key:"_setInvite2xxTimer",value:function(e,t){var n=y.T1;this._timers.invite2xxTimer=setTimeout(function r(){this._status===I.STATUS_WAITING_FOR_ACK&&(e.reply(200,null,["Contact: ".concat(this._contact)],t),n<y.T2&&(n*=2)>y.T2&&(n=y.T2),this._timers.invite2xxTimer=setTimeout(r.bind(this),n))}.bind(this),n)}},{key:"_setACKTimer",value:function(){var e=this;this._timers.ackTimer=setTimeout((function(){e._status===I.STATUS_WAITING_FOR_ACK&&(R.debug("no ACK received, terminating the session"),clearTimeout(e._timers.invite2xxTimer),e.sendRequest(p.BYE),e._ended("remote",null,p.causes.NO_ACK))}),y.TIMER_H)}},{key:"_createRTCConnection",value:function(e,t){var n=this;this._connection=new RTCPeerConnection(e,t),this._connection.addEventListener("iceconnectionstatechange",(function(){"failed"===n._connection.iceConnectionState&&n.terminate({cause:p.causes.RTP_TIMEOUT,status_code:408,reason_phrase:p.causes.RTP_TIMEOUT})})),R.debug('emit "peerconnection"'),this.emit("peerconnection",{peerconnection:this._connection})}},{key:"_createLocalDescription",value:function(e,t){var n=this;if(R.debug("createLocalDescription()"),"offer"!==e&&"answer"!==e)throw new Error('createLocalDescription() | invalid type "'.concat(e,'"'));var r=this._connection;return this._rtcReady=!1,Promise.resolve().then((function(){return"offer"===e?r.createOffer(t).catch((function(e){return R.warn('emit "peerconnection:createofferfailed" [error:%o]',e),n.emit("peerconnection:createofferfailed",e),Promise.reject(e)})):r.createAnswer(t).catch((function(e){return R.warn('emit "peerconnection:createanswerfailed" [error:%o]',e),n.emit("peerconnection:createanswerfailed",e),Promise.reject(e)}))})).then((function(e){return r.setLocalDescription(e).catch((function(e){return n._rtcReady=!0,R.warn('emit "peerconnection:setlocaldescriptionfailed" [error:%o]',e),n.emit("peerconnection:setlocaldescriptionfailed",e),Promise.reject(e)}))})).then((function(){var o=t&&t.iceRestart;if("complete"===r.iceGatheringState&&!o||"gathering"===r.iceGatheringState&&n._iceReady){n._rtcReady=!0;var i={originator:"local",type:e,sdp:r.localDescription.sdp};return R.debug('emit "sdp"'),n.emit("sdp",i),Promise.resolve(i.sdp)}return new Promise((function(t){var o,i,s=!1;n._iceReady=!1;var a=function(){if(!s){r.removeEventListener("icecandidate",o),r.removeEventListener("icegatheringstatechange",i),s=!0,n._rtcReady=!0,n._iceReady=!0;var a={originator:"local",type:e,sdp:r.localDescription.sdp};R.debug('emit "sdp"'),n.emit("sdp",a),t(a.sdp)}};r.addEventListener("icecandidate",o=function(e){var t=e.candidate;t?n.emit("icecandidate",{candidate:t,ready:a}):a()}),r.addEventListener("icegatheringstatechange",i=function(){"complete"===r.iceGatheringState&&a()})}))}))}},{key:"_createDialog",value:function(e,t,n){var r="UAS"===t?e.to_tag:e.from_tag,o="UAS"===t?e.from_tag:e.to_tag,i=e.call_id+r+o,s=this._earlyDialogs[i];if(n)return!!s||((s=new b(this,e,t,b.C.STATUS_EARLY)).error?(R.debug(s.error),this._failed("remote",e,p.causes.INTERNAL_ERROR),!1):(this._earlyDialogs[i]=s,!0));if(this._from_tag=e.from_tag,this._to_tag=e.to_tag,s)return s.update(e,t),this._dialog=s,delete this._earlyDialogs[i],!0;var a=new b(this,e,t);return a.error?(R.debug(a.error),this._failed("remote",e,p.causes.INTERNAL_ERROR),!1):(this._dialog=a,!0)}},{key:"_receiveReinvite",value:function(e){var t=this;R.debug("receiveReinvite()");var n=e.hasHeader("Content-Type")?e.getHeader("Content-Type").toLowerCase():void 0,r={request:e,callback:void 0,reject:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};o=!0;var n=t.status_code||403,r=t.reason_phrase||"",i=m.cloneArray(t.extraHeaders);if(this._status!==I.STATUS_CONFIRMED)return!1;if(n<300||n>=700)throw new TypeError("Invalid status_code: ".concat(n));e.reply(n,r,i)}.bind(this)},o=!1;if(this.emit("reinvite",r),!o){if(this._late_sdp=!1,!e.body)return this._late_sdp=!0,this._remoteHold&&(this._remoteHold=!1,this._onunhold("remote")),void(this._connectionPromiseQueue=this._connectionPromiseQueue.then((function(){return t._createLocalDescription("offer",t._rtcOfferConstraints)})).then((function(e){i.call(t,e)})).catch((function(){e.reply(500)})));if("application/sdp"!==n)return R.debug("invalid Content-Type"),void e.reply(415);this._processInDialogSdpOffer(e).then((function(e){t._status!==I.STATUS_TERMINATED&&i.call(t,e)})).catch((function(e){R.warn(e)}))}function i(t){var n=this,o=["Contact: ".concat(this._contact)];this._handleSessionTimersInIncomingRequest(e,o),this._late_sdp&&(t=this._mangleOffer(t)),e.reply(200,null,o,t,(function(){n._status=I.STATUS_WAITING_FOR_ACK,n._setInvite2xxTimer(e,t),n._setACKTimer()})),"function"==typeof r.callback&&r.callback()}}},{key:"_receiveUpdate",value:function(e){var t=this;R.debug("receiveUpdate()");var n=e.hasHeader("Content-Type")?e.getHeader("Content-Type").toLowerCase():void 0,r={request:e,callback:void 0,reject:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};o=!0;var n=t.status_code||403,r=t.reason_phrase||"",i=m.cloneArray(t.extraHeaders);if(this._status!==I.STATUS_CONFIRMED)return!1;if(n<300||n>=700)throw new TypeError("Invalid status_code: ".concat(n));e.reply(n,r,i)}.bind(this)},o=!1;if(this.emit("update",r),!o)if(e.body){if("application/sdp"!==n)return R.debug("invalid Content-Type"),void e.reply(415);this._processInDialogSdpOffer(e).then((function(e){t._status!==I.STATUS_TERMINATED&&i.call(t,e)})).catch((function(e){R.warn(e)}))}else i.call(this,null);function i(t){var n=["Contact: ".concat(this._contact)];this._handleSessionTimersInIncomingRequest(e,n),e.reply(200,null,n,t),"function"==typeof r.callback&&r.callback()}}},{key:"_processInDialogSdpOffer",value:function(e){var t=this;R.debug("_processInDialogSdpOffer()");var n,r=e.parseSDP(),i=!1,s=o(r.media);try{for(s.s();!(n=s.n()).done;){var a=n.value;if(-1!==O.indexOf(a.type)){var u=a.direction||r.direction||"sendrecv";if("sendonly"!==u&&"inactive"!==u){i=!1;break}i=!0}}}catch(e){s.e(e)}finally{s.f()}var l={originator:"remote",type:"offer",sdp:e.body};R.debug('emit "sdp"'),this.emit("sdp",l);var c=new RTCSessionDescription({type:"offer",sdp:l.sdp});return this._connectionPromiseQueue=this._connectionPromiseQueue.then((function(){if(t._status===I.STATUS_TERMINATED)throw new Error("terminated");return t._connection.setRemoteDescription(c).catch((function(n){throw e.reply(488),R.warn('emit "peerconnection:setremotedescriptionfailed" [error:%o]',n),t.emit("peerconnection:setremotedescriptionfailed",n),n}))})).then((function(){if(t._status===I.STATUS_TERMINATED)throw new Error("terminated");!0===t._remoteHold&&!1===i?(t._remoteHold=!1,t._onunhold("remote")):!1===t._remoteHold&&!0===i&&(t._remoteHold=!0,t._onhold("remote"))})).then((function(){if(t._status===I.STATUS_TERMINATED)throw new Error("terminated");return t._createLocalDescription("answer",t._rtcAnswerConstraints).catch((function(t){throw e.reply(500),R.warn('emit "peerconnection:createtelocaldescriptionfailed" [error:%o]',t),t}))})).catch((function(e){R.warn("_processInDialogSdpOffer() failed [error: %o]",e)})),this._connectionPromiseQueue}},{key:"_receiveRefer",value:function(e){var t=this;if(R.debug("receiveRefer()"),!e.refer_to)return R.debug("no Refer-To header field present in REFER"),void e.reply(400);if(e.refer_to.uri.scheme!==p.SIP)return R.debug("Refer-To header field points to a non-SIP URI scheme"),void e.reply(416);e.reply(202);var r=new E(this,e.cseq);function o(t){var o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(t="function"==typeof t?t:null,this._status!==I.STATUS_WAITING_FOR_ACK&&this._status!==I.STATUS_CONFIRMED)return!1;var i=new n(this._ua);if(i.on("progress",(function(e){var t=e.response;r.notify(t.status_code,t.reason_phrase)})),i.on("accepted",(function(e){var t=e.response;r.notify(t.status_code,t.reason_phrase)})),i.on("_failed",(function(e){var t=e.message,n=e.cause;t?r.notify(t.status_code,t.reason_phrase):r.notify(487,n)})),e.refer_to.uri.hasHeader("replaces")){var s=decodeURIComponent(e.refer_to.uri.getHeader("replaces"));o.extraHeaders=m.cloneArray(o.extraHeaders),o.extraHeaders.push("Replaces: ".concat(s))}i.connect(e.refer_to.uri.toAor(),o,t)}function i(){r.notify(603)}R.debug('emit "refer"'),this.emit("refer",{request:e,accept:function(e,n){o.call(t,e,n)},reject:function(){i.call(t)}})}},{key:"_receiveNotify",value:function(e){if(R.debug("receiveNotify()"),e.event||e.reply(400),"refer"===e.event.event){var t,n;if(e.event.params&&e.event.params.id)t=e.event.params.id,n=this._referSubscribers[t];else{if(1!==Object.keys(this._referSubscribers).length)return void e.reply(400,"Missing event id parameter");n=this._referSubscribers[Object.keys(this._referSubscribers)[0]]}if(!n)return void e.reply(481,"Subscription does not exist");n.receiveNotify(e),e.reply(200)}else e.reply(489)}},{key:"_receiveReplaces",value:function(e){var t=this;function r(t){var r=this;if(this._status!==I.STATUS_WAITING_FOR_ACK&&this._status!==I.STATUS_CONFIRMED)return!1;var o=new n(this._ua);o.on("confirmed",(function(){r.terminate()})),o.init_incoming(e,t)}function o(){R.debug("Replaced INVITE rejected by the user"),e.reply(486)}R.debug("receiveReplaces()"),this.emit("replaces",{request:e,accept:function(e){r.call(t,e)},reject:function(){o.call(t)}})}},{key:"_sendInitialRequest",value:function(e,t,n){var r=this,o=new T(this._ua,this._request,{onRequestTimeout:function(){r.onRequestTimeout()},onTransportError:function(){r.onTransportError()},onAuthenticated:function(e){r._request=e},onReceiveResponse:function(e){r._receiveInviteResponse(e)}});Promise.resolve().then((function(){return n||(e.audio||e.video?(r._localMediaStreamLocallyGenerated=!0,navigator.mediaDevices.getUserMedia(e).catch((function(e){if(r._status===I.STATUS_TERMINATED)throw new Error("terminated");throw r._failed("local",null,p.causes.USER_DENIED_MEDIA_ACCESS),R.warn('emit "getusermediafailed" [error:%o]',e),r.emit("getusermediafailed",e),e}))):void 0)})).then((function(e){if(r._status===I.STATUS_TERMINATED)throw new Error("terminated");return r._localMediaStream=e,e&&e.getTracks().forEach((function(t){r._connection.addTrack(t,e)})),r._connecting(r._request),r._createLocalDescription("offer",t).catch((function(e){throw r._failed("local",null,p.causes.WEBRTC_ERROR),e}))})).then((function(e){if(r._is_canceled||r._status===I.STATUS_TERMINATED)throw new Error("terminated");r._request.body=e,r._status=I.STATUS_INVITE_SENT,R.debug('emit "sending" [request:%o]',r._request),r.emit("sending",{request:r._request}),o.send()})).catch((function(e){r._status!==I.STATUS_TERMINATED&&R.warn(e)}))}},{key:"_getDTMFRTPSender",value:function(){var e=this._connection.getSenders().find((function(e){return e.track&&"audio"===e.track.kind}));if(e&&e.dtmf)return e.dtmf;R.warn("sendDTMF() | no local audio track to send DTMF with")}},{key:"_receiveInviteResponse",value:function(e){var t=this;if(R.debug("receiveInviteResponse()"),this._dialog&&e.status_code>=200&&e.status_code<=299){if(this._dialog.id.call_id===e.call_id&&this._dialog.id.local_tag===e.from_tag&&this._dialog.id.remote_tag===e.to_tag)return void this.sendRequest(p.ACK);var n=new b(this,e,"UAC");return void 0!==n.error?void R.debug(n.error):(this.sendRequest(p.ACK),void this.sendRequest(p.BYE))}if(this._is_canceled)e.status_code>=100&&e.status_code<200?this._request.cancel(this._cancel_reason):e.status_code>=200&&e.status_code<299&&this._acceptAndTerminate(e);else if(this._status===I.STATUS_INVITE_SENT||this._status===I.STATUS_1XX_RECEIVED)switch(!0){case/^100$/.test(e.status_code):this._status=I.STATUS_1XX_RECEIVED;break;case/^1[0-9]{2}$/.test(e.status_code):if(!e.to_tag){R.debug("1xx response received without to tag");break}if(e.hasHeader("contact")&&!this._createDialog(e,"UAC",!0))break;if(this._status=I.STATUS_1XX_RECEIVED,!e.body){this._progress("remote",e);break}var r={originator:"remote",type:"answer",sdp:e.body};R.debug('emit "sdp"'),this.emit("sdp",r);var o=new RTCSessionDescription({type:"answer",sdp:r.sdp});this._connectionPromiseQueue=this._connectionPromiseQueue.then((function(){return t._connection.setRemoteDescription(o)})).then((function(){return t._progress("remote",e)})).catch((function(e){R.warn('emit "peerconnection:setremotedescriptionfailed" [error:%o]',e),t.emit("peerconnection:setremotedescriptionfailed",e)}));break;case/^2[0-9]{2}$/.test(e.status_code):if(this._status=I.STATUS_CONFIRMED,!e.body){this._acceptAndTerminate(e,400,p.causes.MISSING_SDP),this._failed("remote",e,p.causes.BAD_MEDIA_DESCRIPTION);break}if(!this._createDialog(e,"UAC"))break;var i={originator:"remote",type:"answer",sdp:e.body};R.debug('emit "sdp"'),this.emit("sdp",i);var s=new RTCSessionDescription({type:"answer",sdp:i.sdp});this._connectionPromiseQueue=this._connectionPromiseQueue.then((function(){if("stable"===t._connection.signalingState)return t._connection.createOffer(t._rtcOfferConstraints).then((function(e){return t._connection.setLocalDescription(e)})).catch((function(n){t._acceptAndTerminate(e,500,n.toString()),t._failed("local",e,p.causes.WEBRTC_ERROR)}))})).then((function(){t._connection.setRemoteDescription(s).then((function(){t._handleSessionTimersInIncomingResponse(e),t._accepted("remote",e),t.sendRequest(p.ACK),t._confirmed("local",null)})).catch((function(n){t._acceptAndTerminate(e,488,"Not Acceptable Here"),t._failed("remote",e,p.causes.BAD_MEDIA_DESCRIPTION),R.warn('emit "peerconnection:setremotedescriptionfailed" [error:%o]',n),t.emit("peerconnection:setremotedescriptionfailed",n)}))}));break;default:var a=m.sipErrorCause(e.status_code);this._failed("remote",e,a)}}},{key:"_sendReinvite",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};R.debug("sendReinvite()");var n=m.cloneArray(t.extraHeaders),r=m.cloneObject(t.eventHandlers),o=t.rtcOfferConstraints||this._rtcOfferConstraints||null,i=!1;function s(e){var t=this;if(this._status!==I.STATUS_TERMINATED&&(this.sendRequest(p.ACK),!i))if(this._handleSessionTimersInIncomingResponse(e),e.body)if(e.hasHeader("Content-Type")&&"application/sdp"===e.getHeader("Content-Type").toLowerCase()){var n={originator:"remote",type:"answer",sdp:e.body};R.debug('emit "sdp"'),this.emit("sdp",n);var o=new RTCSessionDescription({type:"answer",sdp:n.sdp});this._connectionPromiseQueue=this._connectionPromiseQueue.then((function(){return t._connection.setRemoteDescription(o)})).then((function(){r.succeeded&&r.succeeded(e)})).catch((function(e){a.call(t),R.warn('emit "peerconnection:setremotedescriptionfailed" [error:%o]',e),t.emit("peerconnection:setremotedescriptionfailed",e)}))}else a.call(this);else a.call(this)}function a(e){r.failed&&r.failed(e)}n.push("Contact: ".concat(this._contact)),n.push("Content-Type: application/sdp"),this._sessionTimers.running&&n.push("Session-Expires: ".concat(this._sessionTimers.currentExpires,";refresher=").concat(this._sessionTimers.refresher?"uac":"uas")),this._connectionPromiseQueue=this._connectionPromiseQueue.then((function(){return e._createLocalDescription("offer",o)})).then((function(t){var r={originator:"local",type:"offer",sdp:t=e._mangleOffer(t)};R.debug('emit "sdp"'),e.emit("sdp",r),e.sendRequest(p.INVITE,{extraHeaders:n,body:t,eventHandlers:{onSuccessResponse:function(t){s.call(e,t),i=!0},onErrorResponse:function(t){a.call(e,t)},onTransportError:function(){e.onTransportError()},onRequestTimeout:function(){e.onRequestTimeout()},onDialogError:function(){e.onDialogError()}}})})).catch((function(){a()}))}},{key:"_sendUpdate",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};R.debug("sendUpdate()");var n=m.cloneArray(t.extraHeaders),r=m.cloneObject(t.eventHandlers),o=t.rtcOfferConstraints||this._rtcOfferConstraints||null,i=t.sdpOffer||!1,s=!1;function a(e){var t=this;if(this._status!==I.STATUS_TERMINATED&&!s)if(this._handleSessionTimersInIncomingResponse(e),i){if(!e.body)return void u.call(this);if(!e.hasHeader("Content-Type")||"application/sdp"!==e.getHeader("Content-Type").toLowerCase())return void u.call(this);var n={originator:"remote",type:"answer",sdp:e.body};R.debug('emit "sdp"'),this.emit("sdp",n);var o=new RTCSessionDescription({type:"answer",sdp:n.sdp});this._connectionPromiseQueue=this._connectionPromiseQueue.then((function(){return t._connection.setRemoteDescription(o)})).then((function(){r.succeeded&&r.succeeded(e)})).catch((function(e){u.call(t),R.warn('emit "peerconnection:setremotedescriptionfailed" [error:%o]',e),t.emit("peerconnection:setremotedescriptionfailed",e)}))}else r.succeeded&&r.succeeded(e)}function u(e){r.failed&&r.failed(e)}n.push("Contact: ".concat(this._contact)),this._sessionTimers.running&&n.push("Session-Expires: ".concat(this._sessionTimers.currentExpires,";refresher=").concat(this._sessionTimers.refresher?"uac":"uas")),i?(n.push("Content-Type: application/sdp"),this._connectionPromiseQueue=this._connectionPromiseQueue.then((function(){return e._createLocalDescription("offer",o)})).then((function(t){var r={originator:"local",type:"offer",sdp:t=e._mangleOffer(t)};R.debug('emit "sdp"'),e.emit("sdp",r),e.sendRequest(p.UPDATE,{extraHeaders:n,body:t,eventHandlers:{onSuccessResponse:function(t){a.call(e,t),s=!0},onErrorResponse:function(t){u.call(e,t)},onTransportError:function(){e.onTransportError()},onRequestTimeout:function(){e.onRequestTimeout()},onDialogError:function(){e.onDialogError()}}})})).catch((function(){u.call(e)}))):this.sendRequest(p.UPDATE,{extraHeaders:n,eventHandlers:{onSuccessResponse:function(t){a.call(e,t)},onErrorResponse:function(t){u.call(e,t)},onTransportError:function(){e.onTransportError()},onRequestTimeout:function(){e.onRequestTimeout()},onDialogError:function(){e.onDialogError()}}})}},{key:"_acceptAndTerminate",value:function(e,t,n){R.debug("acceptAndTerminate()");var r=[];t&&(n=n||p.REASON_PHRASE[t]||"",r.push("Reason: SIP ;cause=".concat(t,'; text="').concat(n,'"'))),(this._dialog||this._createDialog(e,"UAC"))&&(this.sendRequest(p.ACK),this.sendRequest(p.BYE,{extraHeaders:r})),this._status=I.STATUS_TERMINATED}},{key:"_mangleOffer",value:function(e){if(!this._localHold&&!this._remoteHold)return e;if(e=h.parse(e),this._localHold&&!this._remoteHold){R.debug("mangleOffer() | me on hold, mangling offer");var t,n=o(e.media);try{for(n.s();!(t=n.n()).done;){var r=t.value;-1!==O.indexOf(r.type)&&(r.direction?"sendrecv"===r.direction?r.direction="sendonly":"recvonly"===r.direction&&(r.direction="inactive"):r.direction="sendonly")}}catch(e){n.e(e)}finally{n.f()}}else if(this._localHold&&this._remoteHold){R.debug("mangleOffer() | both on hold, mangling offer");var i,s=o(e.media);try{for(s.s();!(i=s.n()).done;){var a=i.value;-1!==O.indexOf(a.type)&&(a.direction="inactive")}}catch(e){s.e(e)}finally{s.f()}}else if(this._remoteHold){R.debug("mangleOffer() | remote on hold, mangling offer");var u,l=o(e.media);try{for(l.s();!(u=l.n()).done;){var c=u.value;-1!==O.indexOf(c.type)&&(c.direction?"sendrecv"===c.direction?c.direction="recvonly":"recvonly"===c.direction&&(c.direction="inactive"):c.direction="recvonly")}}catch(e){l.e(e)}finally{l.f()}}return h.write(e)}},{key:"_setLocalMediaStatus",value:function(){var e=!0,t=!0;(this._localHold||this._remoteHold)&&(e=!1,t=!1),this._audioMuted&&(e=!1),this._videoMuted&&(t=!1),this._toggleMuteAudio(!e),this._toggleMuteVideo(!t)}},{key:"_handleSessionTimersInIncomingRequest",value:function(e,t){var n;this._sessionTimers.enabled&&(e.session_expires&&e.session_expires>=p.MIN_SESSION_EXPIRES?(this._sessionTimers.currentExpires=e.session_expires,n=e.session_expires_refresher||"uas"):(this._sessionTimers.currentExpires=this._sessionTimers.defaultExpires,n="uas"),t.push("Session-Expires: ".concat(this._sessionTimers.currentExpires,";refresher=").concat(n)),this._sessionTimers.refresher="uas"===n,this._runSessionTimer())}},{key:"_handleSessionTimersInIncomingResponse",value:function(e){var t;this._sessionTimers.enabled&&(e.session_expires&&e.session_expires>=p.MIN_SESSION_EXPIRES?(this._sessionTimers.currentExpires=e.session_expires,t=e.session_expires_refresher||"uac"):(this._sessionTimers.currentExpires=this._sessionTimers.defaultExpires,t="uac"),this._sessionTimers.refresher="uac"===t,this._runSessionTimer())}},{key:"_runSessionTimer",value:function(){var e=this,t=this._sessionTimers.currentExpires;this._sessionTimers.running=!0,clearTimeout(this._sessionTimers.timer),this._sessionTimers.refresher?this._sessionTimers.timer=setTimeout((function(){e._status!==I.STATUS_TERMINATED&&e._isReadyToReOffer()&&(R.debug("runSessionTimer() | sending session refresh request"),e._sessionTimers.refreshMethod===p.UPDATE?e._sendUpdate():e._sendReinvite())}),500*t):this._sessionTimers.timer=setTimeout((function(){e._status!==I.STATUS_TERMINATED&&(R.warn("runSessionTimer() | timer expired, terminating the session"),e.terminate({cause:p.causes.REQUEST_TIMEOUT,status_code:408,reason_phrase:"Session Timer Expired"}))}),1100*t)}},{key:"_toggleMuteAudio",value:function(e){var t,n=this._connection.getSenders().filter((function(e){return e.track&&"audio"===e.track.kind})),r=o(n);try{for(r.s();!(t=r.n()).done;){t.value.track.enabled=!e}}catch(e){r.e(e)}finally{r.f()}}},{key:"_toggleMuteVideo",value:function(e){var t,n=this._connection.getSenders().filter((function(e){return e.track&&"video"===e.track.kind})),r=o(n);try{for(r.s();!(t=r.n()).done;){t.value.track.enabled=!e}}catch(e){r.e(e)}finally{r.f()}}},{key:"_newRTCSession",value:function(e,t){R.debug("newRTCSession()"),this._ua.newRTCSession(this,{originator:e,session:this,request:t})}},{key:"_connecting",value:function(e){R.debug("session connecting"),R.debug('emit "connecting"'),this.emit("connecting",{request:e})}},{key:"_progress",value:function(e,t){R.debug("session progress"),R.debug('emit "progress"'),this.emit("progress",{originator:e,response:t||null})}},{key:"_accepted",value:function(e,t){R.debug("session accepted"),this._start_time=new Date,R.debug('emit "accepted"'),this.emit("accepted",{originator:e,response:t||null})}},{key:"_confirmed",value:function(e,t){R.debug("session confirmed"),this._is_confirmed=!0,R.debug('emit "confirmed"'),this.emit("confirmed",{originator:e,ack:t||null})}},{key:"_ended",value:function(e,t,n){R.debug("session ended"),this._end_time=new Date,this._close(),R.debug('emit "ended"'),this.emit("ended",{originator:e,message:t||null,cause:n})}},{key:"_failed",value:function(e,t,n){R.debug("session failed"),R.debug('emit "_failed"'),this.emit("_failed",{originator:e,message:t||null,cause:n}),this._close(),R.debug('emit "failed"'),this.emit("failed",{originator:e,message:t||null,cause:n})}},{key:"_onhold",value:function(e){R.debug("session onhold"),this._setLocalMediaStatus(),R.debug('emit "hold"'),this.emit("hold",{originator:e})}},{key:"_onunhold",value:function(e){R.debug("session onunhold"),this._setLocalMediaStatus(),R.debug('emit "unhold"'),this.emit("unhold",{originator:e})}},{key:"_onmute",value:function(e){var t=e.audio,n=e.video;R.debug("session onmute"),this._setLocalMediaStatus(),R.debug('emit "muted"'),this.emit("muted",{audio:t,video:n})}},{key:"_onunmute",value:function(e){var t=e.audio,n=e.video;R.debug("session onunmute"),this._setLocalMediaStatus(),R.debug('emit "unmuted"'),this.emit("unmuted",{audio:t,video:n})}},{key:"C",get:function(){return I}},{key:"causes",get:function(){return p.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(e){this._data=e}},{key:"status",get:function(){return this._status}}]),n}(f)},697:(e,t,n)=>{"use strict";function r(e){return r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},r(e)}function o(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function i(e,t){return i=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},i(e,t)}function s(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,o=a(e);if(t){var i=a(this).constructor;n=Reflect.construct(o,arguments,i)}else n=o.apply(this,arguments);return function(e,t){if(t&&("object"===r(t)||"function"==typeof t))return t;return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}(this,n)}}function a(e){return a=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},a(e)}var u=n(7).EventEmitter,l=n(510),c=n(349),f=n(956),h=n(137),d=new l("RTCSession:DTMF"),p={MIN_DURATION:70,MAX_DURATION:6e3,DEFAULT_DURATION:100,MIN_INTER_TONE_GAP:50,DEFAULT_INTER_TONE_GAP:500};e.exports=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&i(e,t)}(u,e);var t,n,r,a=s(u);function u(e){var t;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,u),(t=a.call(this))._session=e,t._direction=null,t._tone=null,t._duration=null,t._request=null,t}return t=u,n=[{key:"send",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(void 0===e)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 f.InvalidStateError(this._session.status);var r=h.cloneArray(n.extraHeaders);if(this.eventHandlers=h.cloneObject(n.eventHandlers),"string"==typeof e)e=e.toUpperCase();else{if("number"!=typeof e)throw new TypeError("Invalid tone: ".concat(e));e=e.toString()}if(!e.match(/^[0-9A-DR#*]$/))throw new TypeError("Invalid tone: ".concat(e));this._tone=e,this._duration=n.duration,r.push("Content-Type: application/dtmf-relay");var o="Signal=".concat(this._tone,"\r\n");o+="Duration=".concat(this._duration),this._session.newDTMF({originator:"local",dtmf:this,request:this._request}),this._session.sendRequest(c.INFO,{extraHeaders:r,eventHandlers:{onSuccessResponse:function(e){t.emit("succeeded",{originator:"remote",response:e})},onErrorResponse:function(e){t.eventHandlers.onFailed&&t.eventHandlers.onFailed(),t.emit("failed",{originator:"remote",response:e})},onRequestTimeout:function(){t._session.onRequestTimeout()},onTransportError:function(){t._session.onTransportError()},onDialogError:function(){t._session.onDialogError()}},body:o})}},{key:"init_incoming",value:function(e){var t=/^(Signal\s*?=\s*?)([0-9A-D#*]{1})(\s)?.*/,n=/^(Duration\s?=\s?)([0-9]{1,4})(\s)?.*/;if(this._direction="incoming",this._request=e,e.reply(200),e.body){var r=e.body.split("\n");r.length>=1&&t.test(r[0])&&(this._tone=r[0].replace(t,"$2")),r.length>=2&&n.test(r[1])&&(this._duration=parseInt(r[1].replace(n,"$2"),10))}this._duration||(this._duration=p.DEFAULT_DURATION),this._tone?this._session.newDTMF({originator:"remote",dtmf:this,request:e}):d.debug("invalid INFO DTMF received, discarded")}},{key:"tone",get:function(){return this._tone}},{key:"duration",get:function(){return this._duration}}],n&&o(t.prototype,n),r&&o(t,r),u}(u),e.exports.C=p},850:(e,t,n)=>{"use strict";function r(e){return r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},r(e)}function o(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function i(e,t){return i=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},i(e,t)}function s(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,o=a(e);if(t){var i=a(this).constructor;n=Reflect.construct(o,arguments,i)}else n=o.apply(this,arguments);return function(e,t){if(t&&("object"===r(t)||"function"==typeof t))return t;return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}(this,n)}}function a(e){return a=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},a(e)}var u=n(7).EventEmitter,l=n(349),c=n(956),f=n(137);e.exports=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&i(e,t)}(u,e);var t,n,r,a=s(u);function u(e){var t;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,u),(t=a.call(this))._session=e,t._direction=null,t._contentType=null,t._body=null,t}return t=u,n=[{key:"send",value:function(e,t){var n=this,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(this._direction="outgoing",void 0===e)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 c.InvalidStateError(this._session.status);this._contentType=e,this._body=t;var o=f.cloneArray(r.extraHeaders);o.push("Content-Type: ".concat(e)),this._session.newInfo({originator:"local",info:this,request:this.request}),this._session.sendRequest(l.INFO,{extraHeaders:o,eventHandlers:{onSuccessResponse:function(e){n.emit("succeeded",{originator:"remote",response:e})},onErrorResponse:function(e){n.emit("failed",{originator:"remote",response:e})},onTransportError:function(){n._session.onTransportError()},onRequestTimeout:function(){n._session.onRequestTimeout()},onDialogError:function(){n._session.onDialogError()}},body:t})}},{key:"init_incoming",value:function(e){this._direction="incoming",this.request=e,e.reply(200),this._contentType=e.hasHeader("Content-Type")?e.getHeader("Content-Type").toLowerCase():void 0,this._body=e.body,this._session.newInfo({originator:"remote",info:this,request:e})}},{key:"contentType",get:function(){return this._contentType}},{key:"body",get:function(){return this._body}}],n&&o(t.prototype,n),r&&o(t,r),u}(u)},276:(e,t,n)=>{"use strict";function r(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}var o=n(510),i=n(349),s=new o("RTCSession:ReferNotifier"),a="refer",u="message/sipfrag;version=2.0",l=300;e.exports=function(){function e(t,n,r){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this._session=t,this._id=n,this._expires=r||l,this._active=!0,this.notify(100)}var t,n,o;return t=e,(n=[{key:"notify",value:function(e,t){var n;s.debug("notify()"),!1!==this._active&&(t=t||i.REASON_PHRASE[e]||"",n=e>=200?"terminated;reason=noresource":"active;expires=".concat(this._expires),this._session.sendRequest(i.NOTIFY,{extraHeaders:["Event: ".concat(a,";id=").concat(this._id),"Subscription-State: ".concat(n),"Content-Type: ".concat(u)],body:"SIP/2.0 ".concat(e," ").concat(t),eventHandlers:{onErrorResponse:function(){this._active=!1}}}))}}])&&r(t.prototype,n),o&&r(t,o),e}()},716:(e,t,n)=>{"use strict";function r(e){return r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},r(e)}function o(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function i(e,t){return i=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},i(e,t)}function s(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,o=a(e);if(t){var i=a(this).constructor;n=Reflect.construct(o,arguments,i)}else n=o.apply(this,arguments);return function(e,t){if(t&&("object"===r(t)||"function"==typeof t))return t;return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}(this,n)}}function a(e){return a=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},a(e)}var u=n(7).EventEmitter,l=n(510),c=n(349),f=n(561),h=n(137),d=new l("RTCSession:ReferSubscriber");e.exports=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&i(e,t)}(u,e);var t,n,r,a=s(u);function u(e){var t;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,u),(t=a.call(this))._id=null,t._session=e,t}return t=u,n=[{key:"sendRefer",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};d.debug("sendRefer()");var r=h.cloneArray(n.extraHeaders),o=h.cloneObject(n.eventHandlers);for(var i in o)Object.prototype.hasOwnProperty.call(o,i)&&this.on(i,o[i]);var s=null;n.replaces&&(s=n.replaces._request.call_id,s+=";to-tag=".concat(n.replaces._to_tag),s+=";from-tag=".concat(n.replaces._from_tag),s=encodeURIComponent(s));var a="Refer-To: <".concat(e).concat(s?"?Replaces=".concat(s):"",">");if(r.push(a),!r.some((function(e){return e.toLowerCase().startsWith("referred-by:")}))){var u="Referred-By: <".concat(this._session._ua._configuration.uri._scheme,":").concat(this._session._ua._configuration.uri._user,"@").concat(this._session._ua._configuration.uri._host,">");r.push(u)}r.push("Contact: ".concat(this._session.contact));var l=this._session.sendRequest(c.REFER,{extraHeaders:r,eventHandlers:{onSuccessResponse:function(e){t._requestSucceeded(e)},onErrorResponse:function(e){t._requestFailed(e,c.causes.REJECTED)},onTransportError:function(){t._requestFailed(null,c.causes.CONNECTION_ERROR)},onRequestTimeout:function(){t._requestFailed(null,c.causes.REQUEST_TIMEOUT)},onDialogError:function(){t._requestFailed(null,c.causes.DIALOG_ERROR)}}});this._id=l.cseq}},{key:"receiveNotify",value:function(e){if(d.debug("receiveNotify()"),e.body){var t=f.parse(e.body.trim().split("\r\n",1)[0],"Status_Line");if(-1!==t)switch(!0){case/^100$/.test(t.status_code):this.emit("trying",{request:e,status_line:t});break;case/^1[0-9]{2}$/.test(t.status_code):this.emit("progress",{request:e,status_line:t});break;case/^2[0-9]{2}$/.test(t.status_code):this.emit("accepted",{request:e,status_line:t});break;default:this.emit("failed",{request:e,status_line:t})}else d.debug('receiveNotify() | error parsing NOTIFY body: "'.concat(e.body,'"'))}}},{key:"_requestSucceeded",value:function(e){d.debug("REFER succeeded"),d.debug('emit "requestSucceeded"'),this.emit("requestSucceeded",{response:e})}},{key:"_requestFailed",value:function(e,t){d.debug("REFER failed"),d.debug('emit "requestFailed"'),this.emit("requestFailed",{response:e||null,cause:t})}},{key:"id",get:function(){return this._id}}],n&&o(t.prototype,n),r&&o(t,r),u}(u)},680:(e,t,n)=>{"use strict";function r(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}var o=n(510),i=n(137),s=n(349),a=n(213),u=n(396),l=new o("Registrator");e.exports=function(){function e(t,n){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this._reg_id=1,this._ua=t,this._transport=n,this._registrar=t.configuration.registrar_server,this._expires=t.configuration.register_expires,this._call_id=i.createRandomToken(22),this._cseq=0,this._to_uri=t.configuration.uri,this._registrationTimer=null,this._registering=!1,this._registered=!1,this._contact=this._ua.contact.toString(),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)}var t,n,o;return t=e,n=[{key:"setExtraHeaders",value:function(e){Array.isArray(e)||(e=[]),this._extraHeaders=e.slice()}},{key:"setExtraContactParams",value:function(e){for(var t in e instanceof Object||(e={}),this._extraContactParams="",e)if(Object.prototype.hasOwnProperty.call(e,t)){var n=e[t];this._extraContactParams+=";".concat(t),n&&(this._extraContactParams+="=".concat(n))}}},{key:"register",value:function(){var e=this;if(this._registering)l.debug("Register request in progress...");else{var t=this._extraHeaders.slice();t.push("Contact: ".concat(this._contact,";expires=").concat(this._expires).concat(this._extraContactParams)),t.push("Expires: ".concat(this._expires));var n=new a.OutgoingRequest(s.REGISTER,this._registrar,this._ua,{to_uri:this._to_uri,call_id:this._call_id,cseq:this._cseq+=1},t),r=new u(this._ua,n,{onRequestTimeout:function(){e._registrationFailure(null,s.causes.REQUEST_TIMEOUT)},onTransportError:function(){e._registrationFailure(null,s.causes.CONNECTION_ERROR)},onAuthenticated:function(){e._cseq+=1},onReceiveResponse:function(t){if(t.cseq===e._cseq)switch(null!==e._registrationTimer&&(clearTimeout(e._registrationTimer),e._registrationTimer=null),!0){case/^1[0-9]{2}$/.test(t.status_code):break;case/^2[0-9]{2}$/.test(t.status_code):if(e._registering=!1,!t.hasHeader("Contact")){l.debug("no Contact header in response to REGISTER, response ignored");break}var n=t.headers.Contact.reduce((function(e,t){return e.concat(t.parsed)}),[]),r=n.find((function(t){return e._sipInstance===t.getParam("+sip.instance")&&e._reg_id===parseInt(t.getParam("reg-id"))}));if(r||(r=n.find((function(t){return t.uri.user===e._ua.contact.uri.user}))),!r){l.debug("no Contact header pointing to us, response ignored");break}var o=r.getParam("expires");!o&&t.hasHeader("expires")&&(o=t.getHeader("expires")),o||(o=e._expires),(o=Number(o))<10&&(o=10);var a=o>64?1e3*o/2+Math.floor(1e3*(o/2-32)*Math.random()):1e3*o-5e3;e._registrationTimer=setTimeout((function(){e._registrationTimer=null,0===e._ua.listeners("registrationExpiring").length?e.register():e._ua.emit("registrationExpiring")}),a),r.hasParam("temp-gruu")&&(e._ua.contact.temp_gruu=r.getParam("temp-gruu").replace(/"/g,"")),r.hasParam("pub-gruu")&&(e._ua.contact.pub_gruu=r.getParam("pub-gruu").replace(/"/g,"")),e._registered||(e._registered=!0,e._ua.registered({response:t}));break;case/^423$/.test(t.status_code):t.hasHeader("min-expires")?(e._expires=Number(t.getHeader("min-expires")),e._expires<10&&(e._expires=10),e.register()):(l.debug("423 response received for REGISTER without Min-Expires"),e._registrationFailure(t,s.causes.SIP_FAILURE_CODE));break;default:var u=i.sipErrorCause(t.status_code);e._registrationFailure(t,u)}}});this._registering=!0,r.send()}}},{key:"unregister",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(this._registered){this._registered=!1,null!==this._registrationTimer&&(clearTimeout(this._registrationTimer),this._registrationTimer=null);var n=this._extraHeaders.slice();t.all?n.push("Contact: *".concat(this._extraContactParams)):n.push("Contact: ".concat(this._contact,";expires=0").concat(this._extraContactParams)),n.push("Expires: 0");var r=new a.OutgoingRequest(s.REGISTER,this._registrar,this._ua,{to_uri:this._to_uri,call_id:this._call_id,cseq:this._cseq+=1},n);new u(this._ua,r,{onRequestTimeout:function(){e._unregistered(null,s.causes.REQUEST_TIMEOUT)},onTransportError:function(){e._unregistered(null,s.causes.CONNECTION_ERROR)},onAuthenticated:function(){e._cseq+=1},onReceiveResponse:function(t){switch(!0){case/^1[0-9]{2}$/.test(t.status_code):break;case/^2[0-9]{2}$/.test(t.status_code):e._unregistered(t);break;default:var n=i.sipErrorCause(t.status_code);e._unregistered(t,n)}}}).send()}else l.debug("already unregistered")}},{key:"close",value:function(){this._registered&&this.unregister()}},{key:"onTransportClosed",value:function(){this._registering=!1,null!==this._registrationTimer&&(clearTimeout(this._registrationTimer),this._registrationTimer=null),this._registered&&(this._registered=!1,this._ua.unregistered({}))}},{key:"_registrationFailure",value:function(e,t){this._registering=!1,this._ua.registrationFailed({response:e||null,cause:t}),this._registered&&(this._registered=!1,this._ua.unregistered({response:e||null,cause:t}))}},{key:"_unregistered",value:function(e,t){this._registering=!1,this._registered=!1,this._ua.unregistered({response:e||null,cause:t||null})}},{key:"registered",get:function(){return this._registered}}],n&&r(t.prototype,n),o&&r(t,o),e}()},396:(e,t,n)=>{"use strict";function r(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}var o=n(510),i=n(349),s=n(554),a=n(143),u=new o("RequestSender"),l={onRequestTimeout:function(){},onTransportError:function(){},onReceiveResponse:function(){},onAuthenticated:function(){}};e.exports=function(){function e(t,n,r){for(var o in function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this._ua=t,this._eventHandlers=r,this._method=n.method,this._request=n,this._auth=null,this._challenged=!1,this._staled=!1,l)Object.prototype.hasOwnProperty.call(l,o)&&(this._eventHandlers[o]||(this._eventHandlers[o]=l[o]));t.status!==t.C.STATUS_USER_CLOSED||this._method===i.BYE&&this._method===i.ACK||this._eventHandlers.onTransportError()}var t,n,o;return t=e,(n=[{key:"send",value:function(){var e=this,t={onRequestTimeout:function(){e._eventHandlers.onRequestTimeout()},onTransportError:function(){e._eventHandlers.onTransportError()},onReceiveResponse:function(t){e._receiveResponse(t)}};switch(this._method){case"INVITE":this.clientTransaction=new a.InviteClientTransaction(this._ua,this._ua.transport,this._request,t);break;case"ACK":this.clientTransaction=new a.AckClientTransaction(this._ua,this._ua.transport,this._request,t);break;default:this.clientTransaction=new a.NonInviteClientTransaction(this._ua,this._ua.transport,this._request,t)}this._ua._configuration.authorization_jwt&&this._request.setHeader("Authorization",this._ua._configuration.authorization_jwt),this.clientTransaction.send()}},{key:"_receiveResponse",value:function(e){var t,n,r=e.status_code;if(401!==r&&407!==r||null===this._ua.configuration.password&&null===this._ua.configuration.ha1)this._eventHandlers.onReceiveResponse(e);else{if(401===e.status_code?(t=e.parseHeader("www-authenticate"),n="authorization"):(t=e.parseHeader("proxy-authenticate"),n="proxy-authorization"),!t)return u.debug("".concat(e.status_code," with wrong or missing challenge, cannot authenticate")),void this._eventHandlers.onReceiveResponse(e);if(!this._challenged||!this._staled&&!0===t.stale){if(this._auth||(this._auth=new s({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,t))return void this._eventHandlers.onReceiveResponse(e);this._challenged=!0,this._ua.set("realm",this._auth.get("realm")),this._ua.set("ha1",this._auth.get("ha1")),t.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(n,this._auth.toString()),this._eventHandlers.onAuthenticated(this._request),this.send()}else this._eventHandlers.onReceiveResponse(e)}}}])&&r(t.prototype,n),o&&r(t,o),e}()},213:(e,t,n)=>{"use strict";function r(e){return r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},r(e)}function o(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&i(e,t)}function i(e,t){return i=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},i(e,t)}function s(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,o=a(e);if(t){var i=a(this).constructor;n=Reflect.construct(o,arguments,i)}else n=o.apply(this,arguments);return function(e,t){if(t&&("object"===r(t)||"function"==typeof t))return t;return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}(this,n)}}function a(e){return a=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},a(e)}function u(e,t){var n;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return l(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return l(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,o=function(){};return{s:o,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,s=!0,a=!1;return{s:function(){n=e[Symbol.iterator]()},n:function(){var e=n.next();return s=e.done,e},e:function(e){a=!0,i=e},f:function(){try{s||null==n.return||n.return()}finally{if(a)throw i}}}}function l(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function c(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function f(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function h(e,t,n){return t&&f(e.prototype,t),n&&f(e,n),e}var d=n(363),p=n(510),_=n(349),v=n(137),m=n(47),y=n(561),g=new p("SIPMessage"),b=function(){function e(t,n,r,o,i,s){if(c(this,e),!t||!n||!r)return null;o=o||{},this.ua=r,this.headers={},this.method=t,this.ruri=n,this.body=s,this.extraHeaders=v.cloneArray(i),this.ua.configuration.extra_headers&&(this.extraHeaders=this.extraHeaders.concat(this.ua.configuration.extra_headers)),o.route_set?this.setHeader("route",o.route_set):r.configuration.use_preloaded_route&&this.setHeader("route","<".concat(r.transport.sip_uri,";lr>")),this.setHeader("via",""),this.setHeader("max-forwards",_.MAX_FORWARDS);var a=o.to_uri||n,u=o.to_tag?{tag:o.to_tag}:null,l=void 0!==o.to_display_name?o.to_display_name:null;this.to=new m(a,l,u),this.setHeader("to",this.to.toString());var f,h=o.from_uri||r.configuration.uri,d={tag:o.from_tag||v.newTag()};f=void 0!==o.from_display_name?o.from_display_name:r.configuration.display_name?r.configuration.display_name:null,this.from=new m(h,f,d),this.setHeader("from",this.from.toString());var p=o.call_id||r.configuration.jssip_id+v.createRandomToken(15);this.call_id=p,this.setHeader("call-id",p);var y=o.cseq||Math.floor(1e4*Math.random());this.cseq=y,this.setHeader("cseq","".concat(y," ").concat(t))}return h(e,[{key:"setHeader",value:function(e,t){for(var n=new RegExp("^\\s*".concat(e,"\\s*:"),"i"),r=0;r<this.extraHeaders.length;r++)n.test(this.extraHeaders[r])&&this.extraHeaders.splice(r,1);this.headers[v.headerize(e)]=Array.isArray(t)?t:[t]}},{key:"getHeader",value:function(e){var t=this.headers[v.headerize(e)];if(t){if(t[0])return t[0]}else{var n,r=new RegExp("^\\s*".concat(e,"\\s*:"),"i"),o=u(this.extraHeaders);try{for(o.s();!(n=o.n()).done;){var i=n.value;if(r.test(i))return i.substring(i.indexOf(":")+1).trim()}}catch(e){o.e(e)}finally{o.f()}}}},{key:"getHeaders",value:function(e){var t=this.headers[v.headerize(e)],n=[];if(t){var r,o=u(t);try{for(o.s();!(r=o.n()).done;){var i=r.value;n.push(i)}}catch(e){o.e(e)}finally{o.f()}return n}var s,a=new RegExp("^\\s*".concat(e,"\\s*:"),"i"),l=u(this.extraHeaders);try{for(l.s();!(s=l.n()).done;){var c=s.value;a.test(c)&&n.push(c.substring(c.indexOf(":")+1).trim())}}catch(e){l.e(e)}finally{l.f()}return n}},{key:"hasHeader",value:function(e){if(this.headers[v.headerize(e)])return!0;var t,n=new RegExp("^\\s*".concat(e,"\\s*:"),"i"),r=u(this.extraHeaders);try{for(r.s();!(t=r.n()).done;){var o=t.value;if(n.test(o))return!0}}catch(e){r.e(e)}finally{r.f()}return!1}},{key:"parseSDP",value:function(e){return!e&&this.sdp||(this.sdp=d.parse(this.body||"")),this.sdp}},{key:"toString",value:function(){var e="".concat(this.method," ").concat(this.ruri," SIP/2.0\r\n");for(var t in this.headers)if(Object.prototype.hasOwnProperty.call(this.headers,t)){var n,r=u(this.headers[t]);try{for(r.s();!(n=r.n()).done;){var o=n.value;e+="".concat(t,": ").concat(o,"\r\n")}}catch(e){r.e(e)}finally{r.f()}}var i,s=u(this.extraHeaders);try{for(s.s();!(i=s.n()).done;){var a=i.value;e+="".concat(a.trim(),"\r\n")}}catch(e){s.e(e)}finally{s.f()}var l=[];switch(this.method){case _.REGISTER:l.push("path","gruu");break;case _.INVITE:this.ua.configuration.session_timers&&l.push("timer"),(this.ua.contact.pub_gruu||this.ua.contact.temp_gruu)&&l.push("gruu"),l.push("ice","replaces");break;case _.UPDATE:this.ua.configuration.session_timers&&l.push("timer"),l.push("ice")}l.push("outbound");var c=this.ua.configuration.user_agent||_.USER_AGENT;if(e+="Allow: ".concat(_.ALLOWED_METHODS,"\r\n"),e+="Supported: ".concat(l,"\r\n"),e+="User-Agent: ".concat(c,"\r\n"),this.body){var f=v.str_utf8_length(this.body);e+="Content-Length: ".concat(f,"\r\n\r\n"),e+=this.body}else e+="Content-Length: 0\r\n\r\n";return e}},{key:"clone",value:function(){var t=new e(this.method,this.ruri,this.ua);return Object.keys(this.headers).forEach((function(e){t.headers[e]=this.headers[e].slice()}),this),t.body=this.body,t.extraHeaders=v.cloneArray(this.extraHeaders),t.to=this.to,t.from=this.from,t.call_id=this.call_id,t.cseq=this.cseq,t}}]),e}(),T=function(e){o(n,e);var t=s(n);function n(e,r,o,i,s){var a;return c(this,n),(a=t.call(this,_.INVITE,e,r,o,i,s)).transaction=null,a}return h(n,[{key:"cancel",value:function(e){this.transaction.cancel(e)}},{key:"clone",value:function(){var e=new n(this.ruri,this.ua);return Object.keys(this.headers).forEach((function(t){e.headers[t]=this.headers[t].slice()}),this),e.body=this.body,e.extraHeaders=v.cloneArray(this.extraHeaders),e.to=this.to,e.from=this.from,e.call_id=this.call_id,e.cseq=this.cseq,e.transaction=this.transaction,e}}]),n}(b),w=function(){function e(){c(this,e),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 h(e,[{key:"addHeader",value:function(e,t){var n={raw:t};e=v.headerize(e),this.headers[e]?this.headers[e].push(n):this.headers[e]=[n]}},{key:"getHeader",value:function(e){var t=this.headers[v.headerize(e)];if(t)return t[0]?t[0].raw:void 0}},{key:"getHeaders",value:function(e){var t=this.headers[v.headerize(e)],n=[];if(!t)return[];var r,o=u(t);try{for(o.s();!(r=o.n()).done;){var i=r.value;n.push(i.raw)}}catch(e){o.e(e)}finally{o.f()}return n}},{key:"hasHeader",value:function(e){return!!this.headers[v.headerize(e)]}},{key:"parseHeader",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;if(e=v.headerize(e),this.headers[e]){if(!(t>=this.headers[e].length)){var n=this.headers[e][t],r=n.raw;if(n.parsed)return n.parsed;var o=y.parse(r,e.replace(/-/g,"_"));return-1===o?(this.headers[e].splice(t,1),void g.debug('error parsing "'.concat(e,'" header field with value "').concat(r,'"'))):(n.parsed=o,o)}g.debug('not so many "'.concat(e,'" headers present'))}else g.debug('header "'.concat(e,'" not present'))}},{key:"s",value:function(e,t){return this.parseHeader(e,t)}},{key:"setHeader",value:function(e,t){var n={raw:t};this.headers[v.headerize(e)]=[n]}},{key:"parseSDP",value:function(e){return!e&&this.sdp||(this.sdp=d.parse(this.body||"")),this.sdp}},{key:"toString",value:function(){return this.data}}]),e}(),S=function(e){o(n,e);var t=s(n);function n(e){var r;return c(this,n),(r=t.call(this)).ua=e,r.headers={},r.ruri=null,r.transport=null,r.server_transaction=null,r}return h(n,[{key:"reply",value:function(e,t,n,r,o,i){var s=[],a=this.getHeader("To");if(t=t||null,!(e=e||null)||e<100||e>699)throw new TypeError("Invalid status_code: ".concat(e));if(t&&"string"!=typeof t&&!(t instanceof String))throw new TypeError("Invalid reason_phrase: ".concat(t));t=t||_.REASON_PHRASE[e]||"",n=v.cloneArray(n),this.ua.configuration.extra_headers&&(n=n.concat(this.ua.configuration.extra_headers));var l="SIP/2.0 ".concat(e," ").concat(t,"\r\n");if(this.method===_.INVITE&&e>100&&e<=200){var c,f=u(this.getHeaders("record-route"));try{for(f.s();!(c=f.n()).done;){var h=c.value;l+="Record-Route: ".concat(h,"\r\n")}}catch(e){f.e(e)}finally{f.f()}}var d,p=u(this.getHeaders("via"));try{for(p.s();!(d=p.n()).done;){var m=d.value;l+="Via: ".concat(m,"\r\n")}}catch(e){p.e(e)}finally{p.f()}!this.to_tag&&e>100?a+=";tag=".concat(v.newTag()):this.to_tag&&!this.s("to").hasParam("tag")&&(a+=";tag=".concat(this.to_tag)),l+="To: ".concat(a,"\r\n"),l+="From: ".concat(this.getHeader("From"),"\r\n"),l+="Call-ID: ".concat(this.call_id,"\r\n"),l+="CSeq: ".concat(this.cseq," ").concat(this.method,"\r\n");var y,g=u(n);try{for(g.s();!(y=g.n()).done;){var b=y.value;l+="".concat(b.trim(),"\r\n")}}catch(e){g.e(e)}finally{g.f()}switch(this.method){case _.INVITE:this.ua.configuration.session_timers&&s.push("timer"),(this.ua.contact.pub_gruu||this.ua.contact.temp_gruu)&&s.push("gruu"),s.push("ice","replaces");break;case _.UPDATE:this.ua.configuration.session_timers&&s.push("timer"),r&&s.push("ice"),s.push("replaces")}if(s.push("outbound"),this.method===_.OPTIONS?(l+="Allow: ".concat(_.ALLOWED_METHODS,"\r\n"),l+="Accept: ".concat(_.ACCEPTED_BODY_TYPES,"\r\n")):405===e?l+="Allow: ".concat(_.ALLOWED_METHODS,"\r\n"):415===e&&(l+="Accept: ".concat(_.ACCEPTED_BODY_TYPES,"\r\n")),l+="Supported: ".concat(s,"\r\n"),r){var T=v.str_utf8_length(r);l+="Content-Type: application/sdp\r\n",l+="Content-Length: ".concat(T,"\r\n\r\n"),l+=r}else l+="Content-Length: ".concat(0,"\r\n\r\n");this.server_transaction.receiveResponse(e,l,o,i)}},{key:"reply_sl",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,n=this.getHeaders("via");if(!e||e<100||e>699)throw new TypeError("Invalid status_code: ".concat(e));if(t&&"string"!=typeof t&&!(t instanceof String))throw new TypeError("Invalid reason_phrase: ".concat(t));t=t||_.REASON_PHRASE[e]||"";var r,o="SIP/2.0 ".concat(e," ").concat(t,"\r\n"),i=u(n);try{for(i.s();!(r=i.n()).done;){var s=r.value;o+="Via: ".concat(s,"\r\n")}}catch(e){i.e(e)}finally{i.f()}var a=this.getHeader("To");if(!this.to_tag&&e>100?a+=";tag=".concat(v.newTag()):this.to_tag&&!this.s("to").hasParam("tag")&&(a+=";tag=".concat(this.to_tag)),o+="To: ".concat(a,"\r\n"),o+="From: ".concat(this.getHeader("From"),"\r\n"),o+="Call-ID: ".concat(this.call_id,"\r\n"),o+="CSeq: ".concat(this.cseq," ").concat(this.method,"\r\n"),this.ua.configuration.extra_headers){var l,c=u(this.ua.configuration.extra_headers);try{for(c.s();!(l=c.n()).done;){var f=l.value;o+="".concat(f.trim(),"\r\n")}}catch(e){c.e(e)}finally{c.f()}}o+="Content-Length: ".concat(0,"\r\n\r\n"),this.transport.send(o)}}]),n}(w),E=function(e){o(n,e);var t=s(n);function n(){var e;return c(this,n),(e=t.call(this)).headers={},e.status_code=null,e.reason_phrase=null,e}return n}(w);e.exports={OutgoingRequest:b,InitialOutgoingInviteRequest:T,IncomingRequest:S,IncomingResponse:E}},627:(e,t,n)=>{"use strict";var r=n(510),o=n(137),i=n(561),s=new r("Socket");
3
3
  /**
4
4
  * Interface documentation: https://jssip.net/documentation/$last_version/api/socket/
@@ -31,4 +31,4 @@ function(){if("undefined"!=typeof window&&window.process&&("renderer"===window.p
31
31
  // RFC version 26 for SCTP over DTLS
32
32
  name:"sctpPort",reg:/^sctp-port:(\d+)$/,format:"sctp-port:%s"},{
33
33
  // RFC version 26 for SCTP over DTLS
34
- name:"maxMessageSize",reg:/^max-message-size:(\d+)$/,format:"max-message-size:%s"},{push:"tsRefClocks",reg:/^ts-refclk:([^\s=]*)(?:=(\S*))?/,names:["clksrc","clksrcExt"],format:function(e){return"ts-refclk:%s"+(null!=e.clksrcExt?"=%s":"")}},{name:"mediaClk",reg:/^mediaclk:(?:id=(\S*))? *([^\s=]*)(?:=(\S*))?(?: *rate=(\d+)\/(\d+))?/,names:["id","mediaClockName","mediaClockValue","rateNumerator","rateDenominator"],format:function(e){var t="mediaclk:";return t+=null!=e.id?"id=%s %s":"%v%s",t+=null!=e.mediaClockValue?"=%s":"",t+=null!=e.rateNumerator?" rate=%s":"",t+=null!=e.rateDenominator?"/%s":""}},{name:"keywords",reg:/^keywds:(.+)$/,format:"keywds:%s"},{name:"content",reg:/^content:(.+)/,format:"content:%s"},{name:"bfcpFloorCtrl",reg:/^floorctrl:(c-only|s-only|c-s)/,format:"floorctrl:%s"},{name:"bfcpConfId",reg:/^confid:(\d+)/,format:"confid:%s"},{name:"bfcpUserId",reg:/^userid:(\d+)/,format:"userid:%s"},{name:"bfcpFloorId",reg:/^floorid:(.+) (?:m-stream|mstrm):(.+)/,names:["id","mStream"],format:"floorid:%s mstrm:%s"},{push:"invalid",names:["value"]}]};Object.keys(t).forEach((function(e){t[e].forEach((function(e){e.reg||(e.reg=/(.*)/),e.format||(e.format="%s")}))}))},363:(e,t,n)=>{var r=n(20),o=n(804);t.write=o,t.parse=r.parse,t.parseParams=r.parseParams,t.parseFmtpConfig=r.parseFmtpConfig,t.parsePayloads=r.parsePayloads,t.parseRemoteCandidates=r.parseRemoteCandidates,t.parseImageAttributes=r.parseImageAttributes,t.parseSimulcastStreamList=r.parseSimulcastStreamList},20:(e,t,n)=>{var r=function(e){return String(Number(e))===e?Number(e):e},o=function(e,t,n){var o=e.name&&e.names;e.push&&!t[e.push]?t[e.push]=[]:o&&!t[e.name]&&(t[e.name]={});var i=e.push?{}:o?t[e.name]:t;!function(e,t,n,o){if(o&&!n)t[o]=r(e[1]);else for(var i=0;i<n.length;i+=1)null!=e[i+1]&&(t[n[i]]=r(e[i+1]))}(n.match(e.reg),i,e.names,e.name),e.push&&t[e.push].push(i)},i=n(602),s=RegExp.prototype.test.bind(/^([a-z])=(.*)/);t.parse=function(e){var t={},n=[],r=t;return e.split(/(\r\n|\r|\n)/).filter(s).forEach((function(e){var t=e[0],s=e.slice(2);"m"===t&&(n.push({rtp:[],fmtp:[]}),r=n[n.length-1]);for(var a=0;a<(i[t]||[]).length;a+=1){var u=i[t][a];if(u.reg.test(s))return o(u,r,s)}})),t.media=n,t};var a=function(e,t){var n=t.split(/=(.+)/,2);return 2===n.length?e[n[0]]=r(n[1]):1===n.length&&t.length>1&&(e[n[0]]=void 0),e};t.parseParams=function(e){return e.split(/;\s?/).reduce(a,{})},t.parseFmtpConfig=t.parseParams,t.parsePayloads=function(e){return e.toString().split(" ").map(Number)},t.parseRemoteCandidates=function(e){for(var t=[],n=e.split(" ").map(r),o=0;o<n.length;o+=3)t.push({component:n[o],ip:n[o+1],port:n[o+2]});return t},t.parseImageAttributes=function(e){return e.split(" ").map((function(e){return e.substring(1,e.length-1).split(",").reduce(a,{})}))},t.parseSimulcastStreamList=function(e){return e.split(";").map((function(e){return e.split(",").map((function(e){var t,n=!1;return"~"!==e[0]?t=r(e):(t=r(e.substring(1,e.length)),n=!0),{scid:t,paused:n}}))}))}},804:(e,t,n)=>{var r=n(602),o=/%[sdv%]/g,i=function(e){var t=1,n=arguments,r=n.length;return e.replace(o,(function(e){if(t>=r)return e;var o=n[t];switch(t+=1,e){case"%%":return"%";case"%s":return String(o);case"%d":return Number(o);case"%v":return""}}))},s=function(e,t,n){var r=[e+"="+(t.format instanceof Function?t.format(t.push?n:n[t.name]):t.format)];if(t.names)for(var o=0;o<t.names.length;o+=1){var s=t.names[o];t.name?r.push(n[t.name][s]):r.push(n[t.names[o]])}else r.push(n[t.name]);return i.apply(null,r)},a=["v","o","s","i","u","e","p","c","b","t","r","z","a"],u=["i","c","b","a"];e.exports=function(e,t){t=t||{},null==e.version&&(e.version=0),null==e.name&&(e.name=" "),e.media.forEach((function(e){null==e.payloads&&(e.payloads="")}));var n=t.outerOrder||a,o=t.innerOrder||u,i=[];return n.forEach((function(t){r[t].forEach((function(n){n.name in e&&null!=e[n.name]?i.push(s(t,n,e)):n.push in e&&null!=e[n.push]&&e[n.push].forEach((function(e){i.push(s(t,n,e))}))}))})),e.media.forEach((function(e){i.push(s("m",r.m[0],e)),o.forEach((function(t){r[t].forEach((function(n){n.name in e&&null!=e[n.name]?i.push(s(t,n,e)):n.push in e&&null!=e[n.push]&&e[n.push].forEach((function(e){i.push(s(t,n,e))}))}))}))})),i.join("\r\n")+"\r\n"}},633:e=>{"use strict";e.exports=JSON.parse('{"name":"jssip","title":"JsSIP","description":"the Javascript SIP library","version":"3.10.1","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"}}')}},t={};function n(r){var o=t[r];if(void 0!==o)return o.exports;var i=t[r]={exports:{}};return e[r](i,i.exports,n),i.exports}n.d=(e,t)=>{for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);var r={};return(()=>{"use strict";function e(t){return e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},e(t)}function t(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,o(r.key),r)}}function o(t){var n=function(t,n){if("object"!=e(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var o=r.call(t,n||"default");if("object"!=e(o))return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===n?String:Number)(t)}(t,"string");return"symbol"==e(n)?n:n+""}n.d(r,{default:()=>ye});var i,s,a,u=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.allowedEvents=t,this.events={}}return n=e,(r=[{key:"on",value:function(t,n){if("function"!=typeof n)throw new Error("回调必须是函数");if(!t||"string"!=typeof t)throw new Error("事件名必须是非空字符串");this.events[t]||(this.events[t]=[]),e.KEEP_EVENTS.includes(t)?0===this.events[t].length&&this.events[t].push(n):this.events[t].push(n)}},{key:"emit",value:function(e,t){var n=this.events[e];n&&n.forEach((function(n){try{n(t)}catch(t){console.error("事件 ".concat(e," 回调执行错误:"),t)}}))}},{key:"off",value:function(e,t){var n=this.events[e];n&&(this.events[e]=n.filter((function(e){return e!==t})))}},{key:"destroy",value:function(){this.events={}}},{key:"destroyEvents",value:function(){var t=this;Object.keys(this.events).forEach((function(n){e.KEEP_EVENTS.includes(n)||delete t.events[n]}))}}])&&t(n.prototype,r),o&&t(n,o),Object.defineProperty(n,"prototype",{writable:!1}),n;var n,r,o}();function l(e){return l="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},l(e)}function c(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function f(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?c(Object(n),!0).forEach((function(t){d(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):c(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function h(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,p(r.key),r)}}function d(e,t,n){return(t=p(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function p(e){var t=function(e,t){if("object"!=l(e)||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!=l(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==l(t)?t:t+""}i=u,a=[],(s=o(s="KEEP_EVENTS"))in i?Object.defineProperty(i,s,{value:a,enumerable:!0,configurable:!0,writable:!0}):i[s]=a;var _=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e)}return function(e,t,n){return t&&h(e.prototype,t),n&&h(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}(e,[{key:"on",value:function(e,t){this.eventBus.on(e,t)}}],[{key:"getEventBus",value:function(){return e.eventBus}},{key:"getBase",value:function(){return e.base}},{key:"setBase",value:function(t){e.base=f(f({},e.base),t)}}])}();d(_,"base",{webrtc:!1,checkin:!1,token:"",aiDenoise:!1,aiDenoisePath:"",agent:"",account:"",socket:"",sip:{socket:"",account:"",password:"",domain:""},env:""}),d(_,"eventBus",new u);var v=n(53);function m(e){return m="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},m(e)}function y(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,g(r.key),r)}}function g(e){var t=function(e,t){if("object"!=m(e)||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!=m(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==m(t)?t:t+""}var b=function(){return function(e,t,n){return t&&y(e.prototype,t),n&&y(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}((function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.allowedEvents=t,this.events={}}),[{key:"on",value:function(e,t){var n;void 0===(null===(n=this.events[e])||void 0===n?void 0:n.length)&&(this.events[e]||(this.events[e]=[]),this.events[e].push(t))}},{key:"emit",value:function(e,t){var n=this.events[e];n&&n.forEach((function(e){e(t)}))}},{key:"off",value:function(e,t){var n=this.events[e];n&&(this.events[e]=n.filter((function(e){return e!==t})))}},{key:"destroy",value:function(){this.events={}}}])}();function T(e){return T="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},T(e)}function w(){w=function(){return t};var e,t={},n=Object.prototype,r=n.hasOwnProperty,o=Object.defineProperty||function(e,t,n){e[t]=n.value},i="function"==typeof Symbol?Symbol:{},s=i.iterator||"@@iterator",a=i.asyncIterator||"@@asyncIterator",u=i.toStringTag||"@@toStringTag";function l(e,t,n){return Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{l({},"")}catch(e){l=function(e,t,n){return e[t]=n}}function c(e,t,n,r){var i=t&&t.prototype instanceof m?t:m,s=Object.create(i.prototype),a=new N(r||[]);return o(s,"_invoke",{value:I(e,n,a)}),s}function f(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(e){return{type:"throw",arg:e}}}t.wrap=c;var h="suspendedStart",d="suspendedYield",p="executing",_="completed",v={};function m(){}function y(){}function g(){}var b={};l(b,s,(function(){return this}));var S=Object.getPrototypeOf,E=S&&S(S(P([])));E&&E!==n&&r.call(E,s)&&(b=E);var C=g.prototype=m.prototype=Object.create(b);function A(e){["next","throw","return"].forEach((function(t){l(e,t,(function(e){return this._invoke(t,e)}))}))}function R(e,t){function n(o,i,s,a){var u=f(e[o],e,i);if("throw"!==u.type){var l=u.arg,c=l.value;return c&&"object"==T(c)&&r.call(c,"__await")?t.resolve(c.__await).then((function(e){n("next",e,s,a)}),(function(e){n("throw",e,s,a)})):t.resolve(c).then((function(e){l.value=e,s(l)}),(function(e){return n("throw",e,s,a)}))}a(u.arg)}var i;o(this,"_invoke",{value:function(e,r){function o(){return new t((function(t,o){n(e,r,t,o)}))}return i=i?i.then(o,o):o()}})}function I(t,n,r){var o=h;return function(i,s){if(o===p)throw Error("Generator is already running");if(o===_){if("throw"===i)throw s;return{value:e,done:!0}}for(r.method=i,r.arg=s;;){var a=r.delegate;if(a){var u=O(a,r);if(u){if(u===v)continue;return u}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if(o===h)throw o=_,r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);o=p;var l=f(t,n,r);if("normal"===l.type){if(o=r.done?_:d,l.arg===v)continue;return{value:l.arg,done:r.done}}"throw"===l.type&&(o=_,r.method="throw",r.arg=l.arg)}}}function O(t,n){var r=n.method,o=t.iterator[r];if(o===e)return n.delegate=null,"throw"===r&&t.iterator.return&&(n.method="return",n.arg=e,O(t,n),"throw"===n.method)||"return"!==r&&(n.method="throw",n.arg=new TypeError("The iterator does not provide a '"+r+"' method")),v;var i=f(o,t.iterator,n.arg);if("throw"===i.type)return n.method="throw",n.arg=i.arg,n.delegate=null,v;var s=i.arg;return s?s.done?(n[t.resultName]=s.value,n.next=t.nextLoc,"return"!==n.method&&(n.method="next",n.arg=e),n.delegate=null,v):s:(n.method="throw",n.arg=new TypeError("iterator result is not an object"),n.delegate=null,v)}function k(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function x(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function N(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(k,this),this.reset(!0)}function P(t){if(t||""===t){var n=t[s];if(n)return n.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var o=-1,i=function n(){for(;++o<t.length;)if(r.call(t,o))return n.value=t[o],n.done=!1,n;return n.value=e,n.done=!0,n};return i.next=i}}throw new TypeError(T(t)+" is not iterable")}return y.prototype=g,o(C,"constructor",{value:g,configurable:!0}),o(g,"constructor",{value:y,configurable:!0}),y.displayName=l(g,u,"GeneratorFunction"),t.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===y||"GeneratorFunction"===(t.displayName||t.name))},t.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,g):(e.__proto__=g,l(e,u,"GeneratorFunction")),e.prototype=Object.create(C),e},t.awrap=function(e){return{__await:e}},A(R.prototype),l(R.prototype,a,(function(){return this})),t.AsyncIterator=R,t.async=function(e,n,r,o,i){void 0===i&&(i=Promise);var s=new R(c(e,n,r,o),i);return t.isGeneratorFunction(n)?s:s.next().then((function(e){return e.done?e.value:s.next()}))},A(C),l(C,u,"Generator"),l(C,s,(function(){return this})),l(C,"toString",(function(){return"[object Generator]"})),t.keys=function(e){var t=Object(e),n=[];for(var r in t)n.push(r);return n.reverse(),function e(){for(;n.length;){var r=n.pop();if(r in t)return e.value=r,e.done=!1,e}return e.done=!0,e}},t.values=P,N.prototype={constructor:N,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=e,this.done=!1,this.delegate=null,this.method="next",this.arg=e,this.tryEntries.forEach(x),!t)for(var n in this)"t"===n.charAt(0)&&r.call(this,n)&&!isNaN(+n.slice(1))&&(this[n]=e)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var n=this;function o(r,o){return a.type="throw",a.arg=t,n.next=r,o&&(n.method="next",n.arg=e),!!o}for(var i=this.tryEntries.length-1;i>=0;--i){var s=this.tryEntries[i],a=s.completion;if("root"===s.tryLoc)return o("end");if(s.tryLoc<=this.prev){var u=r.call(s,"catchLoc"),l=r.call(s,"finallyLoc");if(u&&l){if(this.prev<s.catchLoc)return o(s.catchLoc,!0);if(this.prev<s.finallyLoc)return o(s.finallyLoc)}else if(u){if(this.prev<s.catchLoc)return o(s.catchLoc,!0)}else{if(!l)throw Error("try statement without catch or finally");if(this.prev<s.finallyLoc)return o(s.finallyLoc)}}}},abrupt:function(e,t){for(var n=this.tryEntries.length-1;n>=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var i=o;break}}i&&("break"===e||"continue"===e)&&i.tryLoc<=t&&t<=i.finallyLoc&&(i=null);var s=i?i.completion:{};return s.type=e,s.arg=t,i?(this.method="next",this.next=i.finallyLoc,v):this.complete(s)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),v},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),x(n),v}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var r=n.completion;if("throw"===r.type){var o=r.arg;x(n)}return o}}throw Error("illegal catch attempt")},delegateYield:function(t,n,r){return this.delegate={iterator:P(t),resultName:n,nextLoc:r},"next"===this.method&&(this.arg=e),v}},t}function S(e,t,n,r,o,i,s){try{var a=e[i](s),u=a.value}catch(e){return void n(e)}a.done?t(u):Promise.resolve(u).then(r,o)}function E(e){return function(){var t=this,n=arguments;return new Promise((function(r,o){var i=e.apply(t,n);function s(e){S(i,r,o,s,a,"next",e)}function a(e){S(i,r,o,s,a,"throw",e)}s(void 0)}))}}function C(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,x(r.key),r)}}function A(e,t,n){return t=I(t),function(e,t){if(t&&("object"==T(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}(e,R()?Reflect.construct(t,n||[],I(e).constructor):t.apply(e,n))}function R(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return(R=function(){return!!e})()}function I(e){return I=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},I(e)}function O(e,t){return O=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},O(e,t)}function k(e,t,n){return(t=x(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function x(e){var t=function(e,t){if("object"!=T(e)||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!=T(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==T(t)?t:t+""}var N=function(e){function t(){return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),A(this,t)}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&O(e,t)}(t,e),function(e,t,n){return t&&C(e.prototype,t),n&&C(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}(t,[{key:"on",value:function(e,n){t.eventBus.on(e,n)}},{key:"init",value:(i=E(w().mark((function e(){var n,r,o,i,s;return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=this,!t.content||!t.content.isConnected()){e.next=6;break}return t.content.start(),e.abrupt("return");case 6:if(!t.content||!t.content.isRegistered()){e.next=10;break}return e.abrupt("return");case 10:if(!t.content){e.next=13;break}return t.content.start(),e.abrupt("return");case 13:(r=_.getBase()).aiDenoise&&t.preloadWasm(),o=new v.WebSocketInterface(r.sip.socket),i="sip:"+r.sip.account+"@"+r.sip.domain,s={sockets:[o],uri:i,password:r.sip.password,mediaConstraints:{audio:{echoCancellation:!0,noiseSuppression:!0,autoGainControl:!0,sampleRate:48e3},video:!1}},t.content=new v.UA(s),t.content.on("newRTCSession",(function(e){t.eventBus.emit("newRTCSession",e);var r=e.session;"remote"===e.originator&&(t.answerSession=e.session),r.on("peerconnection",(function(n){t.eventBus.emit("peerconnection",e),n.peerconnection.onaddstream=function(e){t.audio.srcObject=e.stream,t.audio.play()}})),r.on("progress",(function(r){t.eventBus.emit("progress",r);var o=e.request.headers["Call-Info"];void 0!==o&&o[0].raw.includes("answer-after")&&n.answer()})),r.on("failed",(function(e){t.answerSession=null,t.eventBus.emit("failed",e)})),r.on("ended",(function(e){t.eventBus.emit("ended",e),t.answerSession=null}))})),t.content.on("registrationFailed",(function(e){t.eventBus.emit("registrationFailed",e)})),t.content.on("disconnected",(function(e){t.eventBus.emit("disconnected",e)})),t.content.on("registered",(function(e){t.eventBus.emit("registered",e)})),n.start();case 24:case"end":return e.stop()}}),e,this)}))),function(){return i.apply(this,arguments)})},{key:"answer",value:(o=E(w().mark((function e(){var n;return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!t.answerSession){e.next=11;break}if(!_.getBase().aiDenoise){e.next=4;break}return e.next=4,t.initAiDenoise();case 4:return e.next=6,navigator.mediaDevices.getUserMedia({audio:{noiseSuppression:!0,echoCancellation:!0,autoGainControl:!0,sampleRate:48e3},video:!1});case 6:n=e.sent,_.getBase().aiDenoise&&t.rnnoiseNode&&t.audioContext&&(n=t.applyAiDenoise(n)),t.answerSession.answer({mediaConstraints:{audio:!0,video:!1},mediaStream:n,pcConfig:{iceServers:[]},sessionTimersExpires:180}),e.next=12;break;case 11:t.eventBus.emit("answerSession",{code:401,message:"接听对象不存在",data:""});case 12:case"end":return e.stop()}}),e)}))),function(){return o.apply(this,arguments)})},{key:"start",value:function(){t.content&&(t.content.isRegistered()||t.content.start())}},{key:"stop",value:function(){t.content&&t.content.stop()}},{key:"switchMicrophone",value:function(e){t.answerSession&&navigator.mediaDevices.getUserMedia({audio:{deviceId:{exact:e}},video:!1}).then((function(e){var n=t.answerSession.connection.getSenders().find((function(e){var t;return"audio"===(null===(t=e.track)||void 0===t?void 0:t.kind)}));n&&n.replaceTrack(e.getAudioTracks()[0])})).catch((function(e){console.error("切换麦克风失败:",e)}))}},{key:"switchSpeaker",value:function(e){t.audio.setSinkId?t.audio.setSinkId(e).then((function(){return console.log("已切换到扬声器: ".concat(e))})).catch((function(e){return console.error("切换扬声器失败:",e)})):console.warn("当前浏览器不支持切换扬声器")}}],[{key:"getEventBus",value:function(){return t.eventBus}},{key:"getContent",value:function(){return t.content}},{key:"preloadWasm",value:(r=E(w().mark((function e(){var n,r;return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!t.wasmBytes){e.next=2;break}return e.abrupt("return",!0);case 2:if(n=_.getBase().aiDenoisePath){e.next=5;break}return e.abrupt("return",!1);case 5:return e.prev=5,e.next=8,fetch(n);case 8:if((r=e.sent).ok){e.next=11;break}return e.abrupt("return",!1);case 11:return e.next=13,r.arrayBuffer();case 13:return t.wasmBytes=e.sent,e.abrupt("return",!0);case 17:return e.prev=17,e.t0=e.catch(5),e.abrupt("return",!1);case 20:case"end":return e.stop()}}),e,null,[[5,17]])}))),function(){return r.apply(this,arguments)})},{key:"initAiDenoise",value:(n=E(w().mark((function e(){var n;return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!t.rnnoiseNode){e.next=2;break}return e.abrupt("return");case 2:if(t.wasmBytes){e.next=5;break}return e.next=5,t.preloadWasm();case 5:return t.audioContext=new AudioContext({sampleRate:48e3}),e.next=8,t.audioContext.resume();case 8:return e.next=10,t.audioContext.audioWorklet.addModule(URL.createObjectURL(new Blob(['function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }\nfunction _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator["return"] && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a \'" + n + "\' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, "catch": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }\nfunction asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); }\nfunction _asyncToGenerator(n) { return function () { var t = this, e = arguments; return new Promise(function (r, o) { var a = n.apply(t, e); function _next(n) { asyncGeneratorStep(a, r, o, _next, _throw, "next", n); } function _throw(n) { asyncGeneratorStep(a, r, o, _next, _throw, "throw", n); } _next(void 0); }); }; }\nfunction _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }\nfunction _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }\nfunction _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }\nfunction _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }\nfunction _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }\nfunction _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }\nfunction _possibleConstructorReturn(t, e) { if (e && ("object" == _typeof(e) || "function" == typeof e)) return e; if (void 0 !== e) throw new TypeError("Derived constructors may only return object or undefined"); return _assertThisInitialized(t); }\nfunction _assertThisInitialized(e) { if (void 0 === e) throw new ReferenceError("this hasn\'t been initialised - super() hasn\'t been called"); return e; }\nfunction _inherits(t, e) { if ("function" != typeof e && null !== e) throw new TypeError("Super expression must either be null or a function"); t.prototype = Object.create(e && e.prototype, { constructor: { value: t, writable: !0, configurable: !0 } }), Object.defineProperty(t, "prototype", { writable: !1 }), e && _setPrototypeOf(t, e); }\nfunction _wrapNativeSuper(t) { var r = "function" == typeof Map ? new Map() : void 0; return _wrapNativeSuper = function _wrapNativeSuper(t) { if (null === t || !_isNativeFunction(t)) return t; if ("function" != typeof t) throw new TypeError("Super expression must either be null or a function"); if (void 0 !== r) { if (r.has(t)) return r.get(t); r.set(t, Wrapper); } function Wrapper() { return _construct(t, arguments, _getPrototypeOf(this).constructor); } return Wrapper.prototype = Object.create(t.prototype, { constructor: { value: Wrapper, enumerable: !1, writable: !0, configurable: !0 } }), _setPrototypeOf(Wrapper, t); }, _wrapNativeSuper(t); }\nfunction _construct(t, e, r) { if (_isNativeReflectConstruct()) return Reflect.construct.apply(null, arguments); var o = [null]; o.push.apply(o, e); var p = new (t.bind.apply(t, o))(); return r && _setPrototypeOf(p, r.prototype), p; }\nfunction _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }\nfunction _isNativeFunction(t) { try { return -1 !== Function.toString.call(t).indexOf("[native code]"); } catch (n) { return "function" == typeof t; } }\nfunction _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return t.__proto__ = e, t; }, _setPrototypeOf(t, e); }\nfunction _getPrototypeOf(t) { return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) { return t.__proto__ || Object.getPrototypeOf(t); }, _getPrototypeOf(t); }\nvar RNNoiseProcessor = /*#__PURE__*/function (_AudioWorkletProcesso) {\n function RNNoiseProcessor() {\n var _this;\n _classCallCheck(this, RNNoiseProcessor);\n _this = _callSuper(this, RNNoiseProcessor);\n _this.ready = false;\n _this.enabled = true;\n _this.inBuf = new Float32Array(480);\n _this.inIdx = 0;\n _this.outRing = new Float32Array(4800);\n _this.writePos = 0;\n _this.readPos = 0;\n _this.port.onmessage = function (e) {\n if (e.data.type === "init") _this.initWasm(e.data);\n if (e.data.type === "enable") _this.enabled = true;\n if (e.data.type === "disable") _this.enabled = false;\n };\n return _this;\n }\n _inherits(RNNoiseProcessor, _AudioWorkletProcesso);\n return _createClass(RNNoiseProcessor, [{\n key: "initWasm",\n value: function () {\n var _initWasm = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(data) {\n var wasmBytes, imports, _yield$WebAssembly$in, instance, ex, heap, i;\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n wasmBytes = data.wasmBytes;\n imports = {\n wasi_snapshot_preview1: {\n args_get: function args_get() {\n return 0;\n },\n args_sizes_get: function args_sizes_get() {\n return 0;\n },\n proc_exit: function proc_exit() {}\n }\n };\n _context.next = 4;\n return WebAssembly.instantiate(wasmBytes, imports);\n case 4:\n _yield$WebAssembly$in = _context.sent;\n instance = _yield$WebAssembly$in.instance;\n ex = instance.exports;\n if (ex._initialize) ex._initialize();\n this.memory = ex.memory;\n this.processFrame = ex.rnnoise_process_frame;\n this.statePtr = ex.rnnoise_create(0);\n this.inputPtr = ex.malloc(480 * 4);\n this.outputPtr = ex.malloc(480 * 4);\n heap = new Float32Array(this.memory.buffer);\n for (i = 0; i < 3; i++) {\n heap.fill(0, this.inputPtr >> 2, (this.inputPtr >> 2) + 480);\n this.processFrame(this.statePtr, this.outputPtr, this.inputPtr);\n }\n this.ready = true;\n this.port.postMessage({\n type: "ready"\n });\n case 17:\n case "end":\n return _context.stop();\n }\n }, _callee, this);\n }));\n function initWasm(_x) {\n return _initWasm.apply(this, arguments);\n }\n return initWasm;\n }()\n }, {\n key: "process",\n value: function process(inputs, outputs) {\n var input = inputs[0][0];\n var output = outputs[0][0];\n if (!input) return true;\n if (!this.ready || !this.enabled) {\n output.set(input);\n return true;\n }\n for (var i = 0; i < input.length; i++) {\n this.inBuf[this.inIdx++] = input[i] * 32768;\n if (this.inIdx === 480) {\n var heap = new Float32Array(this.memory.buffer);\n heap.set(this.inBuf, this.inputPtr >> 2);\n this.processFrame(this.statePtr, this.outputPtr, this.inputPtr);\n var out = new Float32Array(this.memory.buffer, this.outputPtr, 480);\n for (var j = 0; j < 480; j++) {\n this.outRing[this.writePos % 4800] = out[j] / 32768;\n this.writePos++;\n }\n this.inIdx = 0;\n }\n }\n for (var _i = 0; _i < output.length; _i++) {\n if (this.readPos < this.writePos) {\n output[_i] = this.outRing[this.readPos % 4800];\n this.readPos++;\n } else {\n output[_i] = 0;\n }\n }\n if (this.readPos > 48000) {\n this.writePos -= this.readPos;\n this.readPos = 0;\n }\n return true;\n }\n }]);\n}(/*#__PURE__*/_wrapNativeSuper(AudioWorkletProcessor));\nregisterProcessor("rnnoise-processor", RNNoiseProcessor);'],{type:"application/javascript"})));case 10:return t.rnnoiseNode=new AudioWorkletNode(t.audioContext,"rnnoise-processor"),n=t.wasmBytes,e.next=14,new Promise((function(e){t.rnnoiseNode.port.onmessage=function(t){"ready"===t.data.type&&e(),"error"===t.data.type&&console.error("Worklet降噪出错:",t.data.message)},t.rnnoiseNode.port.postMessage({type:"init",wasmBytes:n},[n])}));case 14:case"end":return e.stop()}}),e)}))),function(){return n.apply(this,arguments)})},{key:"applyAiDenoise",value:function(e){var n=t.audioContext.createMediaStreamSource(e),r=t.audioContext.createMediaStreamDestination();return n.connect(t.rnnoiseNode),t.rnnoiseNode.connect(r),r.stream}},{key:"destroy",value:function(){t.eventBus.destroy()}}]);var n,r,o,i}(_);function P(e){return P="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},P(e)}function D(e,t){var n=e.toString();return n.length>=t?n:n.padStart(t,"0")}function L(e){return L="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},L(e)}function U(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,M(r.key),r)}}function M(e){var t=function(e,t){if("object"!=L(e)||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!=L(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==L(t)?t:t+""}k(N,"content",null),k(N,"answerSession",null),k(N,"audio",new Audio),k(N,"eventBus",new b);var j=function(){return function(e,t,n){return t&&U(e.prototype,t),n&&U(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}((function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.defaultColor="#909399"}),[{key:"log",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:this.defaultColor,r=_.getBase();if(r.env&&"debug"===r.env){for(var o,i=function(e,t){if(0===arguments.length)return null;var n,r=t||"{y}-{m}-{d} {h}:{i}:{s}";"object"===P(e)?n=e:("string"==typeof e&&/^[0-9]+$/.test(e)&&(e=parseInt(e)),"number"==typeof e&&10===e.toString().length&&(e*=1e3),n=new Date(e));var o={y:n.getFullYear(),m:n.getMonth()+1,d:n.getDate(),h:n.getHours(),i:n.getMinutes(),s:n.getSeconds(),a:n.getDay()};return r.replace(/{([ymdhisa])+}/g,(function(e,t){var n=o[t];return"a"===t?["日","一","二","三","四","五","六"][n]:n.toString().padStart(2,"0")}))}(new Date),s=arguments.length,a=new Array(s>3?s-3:0),u=3;u<s;u++)a[u-3]=arguments[u];(o=console).log.apply(o,["%c ".concat(e," %c ").concat(t," %c"),"background:#35495E; padding: 2px 1px; border-radius: 3px 0 0 3px; color: #fff;","background:".concat(n,"; padding: 2px 1px; border-radius: 0 3px 3px 0; color: #fff;"),"background:transparent"].concat(a,["".concat(i)]))}}},{key:"info",value:function(e,t){for(var n=arguments.length,r=new Array(n>2?n-2:0),o=2;o<n;o++)r[o-2]=arguments[o];this.log.apply(this,[e,t,"#909399"].concat(r))}},{key:"success",value:function(e,t){for(var n=arguments.length,r=new Array(n>2?n-2:0),o=2;o<n;o++)r[o-2]=arguments[o];this.log.apply(this,[e,t,"#67C23A"].concat(r))}},{key:"error",value:function(e,t){for(var n=arguments.length,r=new Array(n>2?n-2:0),o=2;o<n;o++)r[o-2]=arguments[o];this.log.apply(this,[e,t,"#F56C6C"].concat(r))}},{key:"warning",value:function(e,t){for(var n=arguments.length,r=new Array(n>2?n-2:0),o=2;o<n;o++)r[o-2]=arguments[o];this.log.apply(this,[e,t,"#E6A23C"].concat(r))}},{key:"custom",value:function(e,t,n){for(var r=arguments.length,o=new Array(r>3?r-3:0),i=3;i<r;i++)o[i-3]=arguments[i];this.log.apply(this,[e,t,n].concat(o))}}])}();const q=new j;function F(e){return F="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},F(e)}function H(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,G(r.key),r)}}function G(e){var t=function(e,t){if("object"!=F(e)||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!=F(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==F(t)?t:t+""}var B=function(){return function(e,t,n){return t&&H(e.prototype,t),n&&H(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}((function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1e3;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.updateInterval=t,this.worker=null,this.isRunning=!1,this.elapsedSeconds=0,this.onUpdate=null}),[{key:"start",value:function(){var e=this;if(!this.isRunning){this.isRunning=!0,this.elapsedSeconds=0;var t=new Blob(['\nlet elapsedSeconds = 0\nlet intervalId = null\n\nonmessage = function (e) {\n if (e.data.command === "start") {\n const interval = e.data.interval || 1000\n intervalId = setInterval(() => {\n elapsedSeconds++\n postMessage({ command: "tick", elapsedSeconds: elapsedSeconds })\n }, interval)\n } else if (e.data.command === "stop") {\n clearInterval(intervalId)\n intervalId = null\n elapsedSeconds = 0\n }\n}\n'],{type:"application/javascript"}),n=URL.createObjectURL(t);this.worker=new Worker(n),this.worker.postMessage({command:"start",interval:this.updateInterval}),this.worker.onmessage=function(t){"tick"===t.data.command&&(e.elapsedSeconds=t.data.elapsedSeconds,e.onUpdate&&e.onUpdate(e.elapsedSeconds))}}}},{key:"stop",value:function(){this.worker&&(this.worker.postMessage({command:"stop"}),this.worker.terminate(),this.worker=null),this.isRunning=!1}},{key:"setOnUpdate",value:function(e){this.onUpdate=e}}])}();function W(e){return W="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},W(e)}function V(){V=function(){return t};var e,t={},n=Object.prototype,r=n.hasOwnProperty,o=Object.defineProperty||function(e,t,n){e[t]=n.value},i="function"==typeof Symbol?Symbol:{},s=i.iterator||"@@iterator",a=i.asyncIterator||"@@asyncIterator",u=i.toStringTag||"@@toStringTag";function l(e,t,n){return Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{l({},"")}catch(e){l=function(e,t,n){return e[t]=n}}function c(e,t,n,r){var i=t&&t.prototype instanceof m?t:m,s=Object.create(i.prototype),a=new k(r||[]);return o(s,"_invoke",{value:A(e,n,a)}),s}function f(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(e){return{type:"throw",arg:e}}}t.wrap=c;var h="suspendedStart",d="suspendedYield",p="executing",_="completed",v={};function m(){}function y(){}function g(){}var b={};l(b,s,(function(){return this}));var T=Object.getPrototypeOf,w=T&&T(T(x([])));w&&w!==n&&r.call(w,s)&&(b=w);var S=g.prototype=m.prototype=Object.create(b);function E(e){["next","throw","return"].forEach((function(t){l(e,t,(function(e){return this._invoke(t,e)}))}))}function C(e,t){function n(o,i,s,a){var u=f(e[o],e,i);if("throw"!==u.type){var l=u.arg,c=l.value;return c&&"object"==W(c)&&r.call(c,"__await")?t.resolve(c.__await).then((function(e){n("next",e,s,a)}),(function(e){n("throw",e,s,a)})):t.resolve(c).then((function(e){l.value=e,s(l)}),(function(e){return n("throw",e,s,a)}))}a(u.arg)}var i;o(this,"_invoke",{value:function(e,r){function o(){return new t((function(t,o){n(e,r,t,o)}))}return i=i?i.then(o,o):o()}})}function A(t,n,r){var o=h;return function(i,s){if(o===p)throw Error("Generator is already running");if(o===_){if("throw"===i)throw s;return{value:e,done:!0}}for(r.method=i,r.arg=s;;){var a=r.delegate;if(a){var u=R(a,r);if(u){if(u===v)continue;return u}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if(o===h)throw o=_,r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);o=p;var l=f(t,n,r);if("normal"===l.type){if(o=r.done?_:d,l.arg===v)continue;return{value:l.arg,done:r.done}}"throw"===l.type&&(o=_,r.method="throw",r.arg=l.arg)}}}function R(t,n){var r=n.method,o=t.iterator[r];if(o===e)return n.delegate=null,"throw"===r&&t.iterator.return&&(n.method="return",n.arg=e,R(t,n),"throw"===n.method)||"return"!==r&&(n.method="throw",n.arg=new TypeError("The iterator does not provide a '"+r+"' method")),v;var i=f(o,t.iterator,n.arg);if("throw"===i.type)return n.method="throw",n.arg=i.arg,n.delegate=null,v;var s=i.arg;return s?s.done?(n[t.resultName]=s.value,n.next=t.nextLoc,"return"!==n.method&&(n.method="next",n.arg=e),n.delegate=null,v):s:(n.method="throw",n.arg=new TypeError("iterator result is not an object"),n.delegate=null,v)}function I(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function O(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function k(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(I,this),this.reset(!0)}function x(t){if(t||""===t){var n=t[s];if(n)return n.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var o=-1,i=function n(){for(;++o<t.length;)if(r.call(t,o))return n.value=t[o],n.done=!1,n;return n.value=e,n.done=!0,n};return i.next=i}}throw new TypeError(W(t)+" is not iterable")}return y.prototype=g,o(S,"constructor",{value:g,configurable:!0}),o(g,"constructor",{value:y,configurable:!0}),y.displayName=l(g,u,"GeneratorFunction"),t.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===y||"GeneratorFunction"===(t.displayName||t.name))},t.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,g):(e.__proto__=g,l(e,u,"GeneratorFunction")),e.prototype=Object.create(S),e},t.awrap=function(e){return{__await:e}},E(C.prototype),l(C.prototype,a,(function(){return this})),t.AsyncIterator=C,t.async=function(e,n,r,o,i){void 0===i&&(i=Promise);var s=new C(c(e,n,r,o),i);return t.isGeneratorFunction(n)?s:s.next().then((function(e){return e.done?e.value:s.next()}))},E(S),l(S,u,"Generator"),l(S,s,(function(){return this})),l(S,"toString",(function(){return"[object Generator]"})),t.keys=function(e){var t=Object(e),n=[];for(var r in t)n.push(r);return n.reverse(),function e(){for(;n.length;){var r=n.pop();if(r in t)return e.value=r,e.done=!1,e}return e.done=!0,e}},t.values=x,k.prototype={constructor:k,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=e,this.done=!1,this.delegate=null,this.method="next",this.arg=e,this.tryEntries.forEach(O),!t)for(var n in this)"t"===n.charAt(0)&&r.call(this,n)&&!isNaN(+n.slice(1))&&(this[n]=e)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var n=this;function o(r,o){return a.type="throw",a.arg=t,n.next=r,o&&(n.method="next",n.arg=e),!!o}for(var i=this.tryEntries.length-1;i>=0;--i){var s=this.tryEntries[i],a=s.completion;if("root"===s.tryLoc)return o("end");if(s.tryLoc<=this.prev){var u=r.call(s,"catchLoc"),l=r.call(s,"finallyLoc");if(u&&l){if(this.prev<s.catchLoc)return o(s.catchLoc,!0);if(this.prev<s.finallyLoc)return o(s.finallyLoc)}else if(u){if(this.prev<s.catchLoc)return o(s.catchLoc,!0)}else{if(!l)throw Error("try statement without catch or finally");if(this.prev<s.finallyLoc)return o(s.finallyLoc)}}}},abrupt:function(e,t){for(var n=this.tryEntries.length-1;n>=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var i=o;break}}i&&("break"===e||"continue"===e)&&i.tryLoc<=t&&t<=i.finallyLoc&&(i=null);var s=i?i.completion:{};return s.type=e,s.arg=t,i?(this.method="next",this.next=i.finallyLoc,v):this.complete(s)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),v},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),O(n),v}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var r=n.completion;if("throw"===r.type){var o=r.arg;O(n)}return o}}throw Error("illegal catch attempt")},delegateYield:function(t,n,r){return this.delegate={iterator:x(t),resultName:n,nextLoc:r},"next"===this.method&&(this.arg=e),v}},t}function K(e,t,n,r,o,i,s){try{var a=e[i](s),u=a.value}catch(e){return void n(e)}a.done?t(u):Promise.resolve(u).then(r,o)}function z(e){return function(){var t=this,n=arguments;return new Promise((function(r,o){var i=e.apply(t,n);function s(e){K(i,r,o,s,a,"next",e)}function a(e){K(i,r,o,s,a,"throw",e)}s(void 0)}))}}function Y(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,Z(r.key),r)}}function $(e,t,n){return t=X(t),function(e,t){if(t&&("object"==W(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}(e,J()?Reflect.construct(t,n||[],X(e).constructor):t.apply(e,n))}function J(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return(J=function(){return!!e})()}function X(e){return X=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},X(e)}function Q(e,t){return Q=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},Q(e,t)}function Z(e){var t=function(e,t){if("object"!=W(e)||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!=W(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==W(t)?t:t+""}var ee=function(e){function t(){var e;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),(e=$(this,t)).baseInfo=_.getBase(),e.initEvent(),e.initJssip(),e.telephone={type:"",reconnect:!1,clientTime:Math.floor(Date.now()/1e3),serverTime:Math.floor(Date.now()/1e3),statusTime:0,diff:0,statusCode:""},e.timer=null,e.watchTimer=null,e.permissionTimer=null,e}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&Q(e,t)}(t,e),function(e,t,n){return t&&Y(e.prototype,t),n&&Y(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}(t,[{key:"startWatchTimer",value:function(){var e=this;this.watchTimer=new B,this.watchTimer.setOnUpdate((function(){if(e.telephone.clientTime=Math.floor(Date.now()/1e3),0!==e.telephone.statusTime){var t=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"hms",n=Math.floor(e/864e5),r=e%864e5,o=Math.floor(r/36e5),i=r%36e5,s=Math.floor(i/6e4),a=i%6e4,u=Math.round(a/1e3);return"dhms"===t?{day:D(n),hours:D(o,2),minutes:D(s,2),seconds:D(u,2)}:"hms"===t?{hours:D(n>0?24*n+o:o,2),minutes:D(s,2),seconds:D(u,2)}:void 0}(1e3*(e.telephone.clientTime-e.telephone.statusTime+e.telephone.diff),"hms");e.eventBus.emit("onlinetime",t.hours+":"+t.minutes+":"+t.seconds)}})),this.watchTimer.start()}},{key:"stopWatchTimer",value:function(){this.watchTimer&&(this.watchTimer.stop(),this.watchTimer=null)}},{key:"stopPermissionTime",value:function(){this.permissionTimer&&(this.permissionTimer.stop(),this.permissionTimer=null)}},{key:"startTimer",value:function(){var e=this;this.timer=new B(3e4),this.timer.setOnUpdate((function(){e.sendMessage({type:"Time",data:{}})})),this.timer.start()}},{key:"stopTimer",value:function(){this.timer&&(this.timer.stop(),this.timer=null)}},{key:"stop",value:function(){this.eventBus.emit("onlinetime","00:00:00"),this.stopTimer(),this.stopWatchTimer(),this.stopPermissionTime(),this.baseInfo.webrtc&&this.sip&&this.sip.stop(),t.content&&(t.content.close(),t.content=null,this.telephone.reconnect=!1)}},{key:"sipEvent",value:function(){var e=this;this.sipEventBus.on("newRTCSession",(function(e){q.custom("telephone","newRTCSession","#E13164",e)})),this.sipEventBus.on("peerconnection",(function(e){q.custom("telephone","peerconnection","#E13164",e)})),this.sipEventBus.on("progress",(function(e){q.custom("telephone","progress","#E13164",e)})),this.sipEventBus.on("failed",(function(e){q.custom("telephone","failed","#E13164",e)})),this.sipEventBus.on("ended",(function(e){q.custom("telephone","ended","#E13164",e)})),this.sipEventBus.on("registrationFailed",(function(e){q.custom("telephone","registrationFailed","#E13164",e)})),this.sipEventBus.on("disconnected",(function(t){q.custom("telephone","disconnected","#E13164",t),e.onclose()})),this.sipEventBus.on("answerSession",(function(t){q.error("telephone","error",t),e.eventBus.emit("error",t)})),this.sipEventBus.on("registered",(function(t){q.custom("telephone","registered","#E13164",t),e.checkin("jssip"),e.onopen("jssip")}))}},{key:"onopen",value:function(e){var n,r=N.getContent();q.info("telephone","onopen",{source:e,webrtc:this.baseInfo.webrtc,readyState:null==t||null===(n=t.content)||void 0===n?void 0:n.readyState,jssip:r,isRegistered:null==r?void 0:r.isRegistered(),isConnected:null==r?void 0:r.isConnected()});var o=200,i="连接成功";"Logout"===this.telephone.type?o=200:"Login"===this.telephone.type&&(o=201),this.baseInfo.webrtc?t.content.readyState===WebSocket.OPEN&&r&&r.isRegistered()&&r.isConnected()&&this.eventBus.emit("onopen",{code:o,message:i}):this.eventBus.emit("onopen",{code:o,message:i})}},{key:"onclose",value:function(){var e=this;if("Logout"===e.telephone.type)if(this.baseInfo.webrtc){var n=N.getContent();if(n){n.isConnected();t.content||n.isConnected()||r({code:200,message:"连接关闭"})}}else r({code:200,message:"连接关闭"});else r({code:201,message:"连接关闭"});function r(t){e.eventBus.emit("onclose",t),e.eventBus.destroyEvents()}}},{key:"initEvent",value:function(){this.eventBus=_.getEventBus()}},{key:"initJssip",value:function(){this.sip=new N,this.sipEventBus=N.getEventBus(),this.sipEvent()}},{key:"init",value:function(){try{if(t.content&&t.content.readyState===WebSocket.OPEN)return void this.checkin("socket");for(var e=this,n=0,r=["webrtc","token","agent","account","socket"];n<r.length;n++){var o=r[n];if(void 0===e.baseInfo[o])return void console.error("".concat(o," is required"))}t.content=new WebSocket(e.baseInfo.socket+"/v1/cc/socket?access_token="+e.baseInfo.token),t.content.onopen=function(){q.success("telephone","WebSocket连接成功"),e.telephone.clientTime=Math.floor(Date.now()/1e3),e.onopen("socket"),e.eventBus.emit("onlinetime","00:00:00"),e.startTimer(),e.startWatchTimer(),e.baseInfo.webrtc&&e.startPermissionTime(),e.baseInfo.webrtc?e.webrtcInfo():e.checkin("socket"),e.sendMessage({type:"Time",data:{}})},t.content.onclose=function(t){q.warning("telephone","onclose",t),e.onclose(),e.stopTimer(),e.stopWatchTimer(),e.reconnect(),e.eventBus.emit("onlinetime","00:00:00"),e.telephone.type="Logout"},t.content.onerror=function(t){q.error("telephone","onerror",t),e.stopTimer(),e.stopWatchTimer(),e.eventBus.emit("onerror",t)},t.content.onmessage=function(t){if(t.data){var n=JSON.parse(t.data),r=n.type,o=n.code,i=n.data;switch(q.custom("telephone","收到数据","#409EFF",n),e.eventBus.emit("onmessage",n),r){case"WebrtcInfo":_.setBase({sip:{socket:i.url,account:i.account,password:i.password,domain:i.domain}}),e.checkin("socket");break;case"Login":e.telephone.type="Login",e.telephone.reconnect=!0,e.relayList();break;case"Logout":e.telephone.type="Logout",e.telephone.reconnect=!1,e.stop();break;case"Status":e.telephone.statusCode=i.status,e.telephone.statusTime=i.time;break;case"Time":e.telephone.serverTime=i,e.telephone.diff=e.telephone.serverTime-e.telephone.clientTime;break;case"Error":-1!==[902,11e3,11012,11013,11032,11034,11030,11040,11041].indexOf(o)&&(e.telephone.reconnect=!1,e.stop())}}}}catch(e){console.log(e)}}},{key:"reconnect",value:function(){var e=this;e.telephone.reconnect&&setTimeout((function(){try{e.init()}catch(t){e.reconnect()}}),5e3)}},{key:"checkin",value:function(){var e,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",r=N.getContent();q.info("telephone","checkin",{source:n,webrtc:this.baseInfo.webrtc,readyState:null==t||null===(e=t.content)||void 0===e?void 0:e.readyState,jssip:r,isRegistered:null==r?void 0:r.isRegistered(),isConnected:null==r?void 0:r.isConnected()});var o=!1;this.baseInfo.webrtc?r&&r.isRegistered&&r.isRegistered()&&t.content.readyState===WebSocket.OPEN?o=!0:this.sip.init():o=!0,o&&"Login"!==this.telephone.type&&this.login()}},{key:"login",value:function(){var e=_.getBase();this.sendMessage({type:"Login",data:{agent:e.agent,account:e.account}})}},{key:"logout",value:function(){this.sendMessage({type:"Logout",data:{}})}},{key:"hangup",value:function(){this.sendMessage({type:"Hangup",data:{}})}},{key:"relayList",value:function(){this.sendMessage({type:"RelayList",data:{}})}},{key:"call",value:(a=z(V().mark((function e(t){var n,r;return V().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n={customer:t.customer,relayNumber:t.relayNumber,custom:t.custom,subscriber:t.subscriber},!this.baseInfo.webrtc){e.next=8;break}return e.next=4,this.checkMicrophoneStatus();case 4:200===(r=e.sent).code?this.sendMessage({type:"Call",data:n}):(q.error("telephone","error",r),this.eventBus.emit("error",r)),e.next=9;break;case 8:this.sendMessage({type:"Call",data:n});case 9:case"end":return e.stop()}}),e,this)}))),function(e){return a.apply(this,arguments)})},{key:"keyup",value:function(e){this.sendMessage({type:"Keyup",data:{key:e}})}},{key:"status",value:function(e){this.sendMessage({type:"Status",data:{status:e}})}},{key:"regionInfo",value:function(e){this.sendMessage({type:"RegionInfo",data:{mobile:e}})}},{key:"mobileAnswer",value:function(e){this.sendMessage({type:"MobileAnswer",data:{status:e.status,relayNumber:e.relayNumber}})}},{key:"transferQueue",value:function(e){this.sendMessage({type:"Blind",data:{type:1,queueId:e}})}},{key:"transfer",value:function(e){this.sendMessage({type:"Blind",data:{type:0,customer:e.customer,relayNumber:e.relayNumber}})}},{key:"threeWayStart",value:function(e){this.sendMessage({type:"ThreeWayStart",data:{customer:e.customer,relayNumber:e.relayNumber}})}},{key:"threeWayCancel",value:function(){this.sendMessage({type:"ThreeWayCancel",data:{}})}},{key:"consultStart",value:function(e){this.sendMessage({type:"ConsultStart",data:{customer:e.customer,relayNumber:e.relayNumber}})}},{key:"consultCancel",value:function(){this.sendMessage({type:"ConsultCancel",data:{}})}},{key:"consultTransfer",value:function(){this.sendMessage({type:"ConsultTransfer",data:{}})}},{key:"hold",value:function(){this.sendMessage({type:"Hold",data:{status:1}})}},{key:"unhold",value:function(){this.sendMessage({type:"Hold",data:{status:0}})}},{key:"grade",value:function(){this.sendMessage({type:"Grade",data:{}})}},{key:"answer",value:function(){this.baseInfo.webrtc?this.sip.answer():this.sendMessage({type:"Answer",data:{}})}},{key:"webrtcInfo",value:function(){this.sendMessage({type:"WebrtcInfo",data:{agent:this.baseInfo.agent,account:this.baseInfo.account}})}},{key:"queueList",value:function(){this.sendMessage({type:"QueueList",data:{}})}},{key:"flowList",value:function(){this.sendMessage({type:"FlowList",data:{}})}},{key:"flow",value:function(e){this.sendMessage({type:"Flow",data:{flowId:e}})}},{key:"customHandle",value:function(e){this.sendMessage(e)}},{key:"sendMessage",value:function(e){t.content&&t.content.readyState===WebSocket.OPEN?(q.info("telephone","发送数据",e),t.content.send(JSON.stringify(e))):(q.error("telephone","error",{code:456,message:"Websocket未连接",data:""}),this.eventBus.emit("error",{code:456,message:"Websocket未连接",data:""}))}},{key:"getDefaultMedia",value:(s=z(V().mark((function e(){var t,n,r,o,i;return V().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.getMedia();case 2:if(t=e.sent,n=t.code,r=t.data,200!==n){e.next=14;break}if(o=r.audioinput.find((function(e){return"default"===e.deviceId})),i=r.audiooutput.find((function(e){return"default"===e.deviceId})),!o){e.next=11;break}return e.abrupt("return",{type:"DefaultMedia",code:200,data:{input:o,output:i}});case 11:return e.abrupt("return",{type:"DefaultMedia",code:101,data:{input:{deviceId:(null==o?void 0:o.deviceId)||"",label:(null==o?void 0:o.label)||"获取失败,麦克风未开启或未授权",groupId:(null==o?void 0:o.groupId)||"",kind:(null==o?void 0:o.kind)||""},output:{deviceId:(null==i?void 0:i.deviceId)||"",label:(null==i?void 0:i.label)||"获取失败,麦克风未开启或未授权",groupId:(null==i?void 0:i.groupId)||"",kind:(null==i?void 0:i.kind)||""}}});case 12:e.next=15;break;case 14:return e.abrupt("return",t);case 15:case"end":return e.stop()}}),e,this)}))),function(){return s.apply(this,arguments)})},{key:"getMedia",value:(i=z(V().mark((function e(){var t,n,r;return V().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,navigator.mediaDevices.enumerateDevices();case 3:return t=e.sent,n=t.filter((function(e){return"audioinput"===e.kind})),r=t.filter((function(e){return"audiooutput"===e.kind})),e.abrupt("return",{type:"Media",code:200,data:{audioinput:n,audiooutput:r}});case 9:return e.prev=9,e.t0=e.catch(0),e.abrupt("return",{type:"Media",code:105,message:"获取麦克风权限失败",data:{input:{deviceId:"",label:"获取失败,麦克风未开启或未授权",groupId:"",kind:""},output:{deviceId:"",label:"获取失败,麦克风未开启或未授权",groupId:"",kind:""}}});case 12:case"end":return e.stop()}}),e,null,[[0,9]])}))),function(){return i.apply(this,arguments)})},{key:"checkMicrophoneStatus",value:(o=z(V().mark((function e(){var t,n;return V().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,navigator.mediaDevices.enumerateDevices();case 3:if(t=e.sent,0!==(n=t.filter((function(e){return"audioinput"===e.kind}))).length){e.next=7;break}return e.abrupt("return",{type:"CheckMicrophoneStatus",code:101,message:"没有找到麦克风设备"});case 7:if(!n.some((function(e){return""!==e.label}))){e.next=12;break}return e.abrupt("return",{type:"CheckMicrophoneStatus",code:200,message:"麦克风已开启"});case 12:return e.abrupt("return",{type:"CheckMicrophoneStatus",code:101,message:"麦克风未开启或未授权"});case 13:e.next=18;break;case 15:return e.prev=15,e.t0=e.catch(0),e.abrupt("return",{type:"CheckMicrophoneStatus",code:101,message:"获取设备信息时出错"});case 18:case"end":return e.stop()}}),e,null,[[0,15]])}))),function(){return o.apply(this,arguments)})},{key:"getPhoneInfo",value:(r=z(V().mark((function e(){return V().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",{type:this.telephone.type,webrtc:this.baseInfo.webrtc,account:this.baseInfo.account,agent:this.baseInfo.agent,socket:this.baseInfo.socket,token:this.baseInfo.token});case 1:case"end":return e.stop()}}),e,this)}))),function(){return r.apply(this,arguments)})},{key:"getSystemInfo",value:(n=z(V().mark((function e(){var t,n,r,o,i,s,a;return V().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t={name:"",version:""},(n=navigator.userAgent).indexOf("Chrome")>-1?(t.name="Chrome",r=n.match(/Chrome\/(\d+\.\d+)/),t.version=r?r[1]:""):n.indexOf("Firefox")>-1?(t.name="Firefox",o=n.match(/Firefox\/(\d+\.\d+)/),t.version=o?o[1]:""):n.indexOf("Safari")>-1?(t.name="Safari",i=n.match(/Version\/(\d+\.\d+)/),t.version=i?i[1]:""):n.indexOf("Edge")>-1?(t.name="Edge",s=n.match(/Edge\/(\d+\.\d+)/),t.version=s?s[1]:""):n.indexOf("Edg")>-1&&(t.name="Edge",a=n.match(/Edg\/(\d+\.\d+)/),t.version=a?a[1]:""),e.abrupt("return",{type:"SystemInfo",code:200,data:{browser:t,support:{webrtc:!!(window.RTCPeerConnection||window.webkitRTCPeerConnection||window.mozRTCPeerConnection),websocket:"WebSocket"in window}}});case 4:case"end":return e.stop()}}),e)}))),function(){return n.apply(this,arguments)})},{key:"startPermissionTime",value:function(){var e=this;this.permissionTimer=new B,this.permissionTimer.setOnUpdate(z(V().mark((function t(){return V().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,e.checkMicrophoneStatus();case 2:200===t.sent.code?e.eventBus.emit("onpermission",{microphone:!0}):e.eventBus.emit("onpermission",{microphone:!1});case 4:case"end":return t.stop()}}),t)})))),this.permissionTimer.start()}}]);var n,r,o,i,s,a}(_);function te(e){return te="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},te(e)}function ne(e,t,n){return(t=ae(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function re(){re=function(){return t};var e,t={},n=Object.prototype,r=n.hasOwnProperty,o=Object.defineProperty||function(e,t,n){e[t]=n.value},i="function"==typeof Symbol?Symbol:{},s=i.iterator||"@@iterator",a=i.asyncIterator||"@@asyncIterator",u=i.toStringTag||"@@toStringTag";function l(e,t,n){return Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{l({},"")}catch(e){l=function(e,t,n){return e[t]=n}}function c(e,t,n,r){var i=t&&t.prototype instanceof m?t:m,s=Object.create(i.prototype),a=new k(r||[]);return o(s,"_invoke",{value:A(e,n,a)}),s}function f(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(e){return{type:"throw",arg:e}}}t.wrap=c;var h="suspendedStart",d="suspendedYield",p="executing",_="completed",v={};function m(){}function y(){}function g(){}var b={};l(b,s,(function(){return this}));var T=Object.getPrototypeOf,w=T&&T(T(x([])));w&&w!==n&&r.call(w,s)&&(b=w);var S=g.prototype=m.prototype=Object.create(b);function E(e){["next","throw","return"].forEach((function(t){l(e,t,(function(e){return this._invoke(t,e)}))}))}function C(e,t){function n(o,i,s,a){var u=f(e[o],e,i);if("throw"!==u.type){var l=u.arg,c=l.value;return c&&"object"==te(c)&&r.call(c,"__await")?t.resolve(c.__await).then((function(e){n("next",e,s,a)}),(function(e){n("throw",e,s,a)})):t.resolve(c).then((function(e){l.value=e,s(l)}),(function(e){return n("throw",e,s,a)}))}a(u.arg)}var i;o(this,"_invoke",{value:function(e,r){function o(){return new t((function(t,o){n(e,r,t,o)}))}return i=i?i.then(o,o):o()}})}function A(t,n,r){var o=h;return function(i,s){if(o===p)throw Error("Generator is already running");if(o===_){if("throw"===i)throw s;return{value:e,done:!0}}for(r.method=i,r.arg=s;;){var a=r.delegate;if(a){var u=R(a,r);if(u){if(u===v)continue;return u}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if(o===h)throw o=_,r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);o=p;var l=f(t,n,r);if("normal"===l.type){if(o=r.done?_:d,l.arg===v)continue;return{value:l.arg,done:r.done}}"throw"===l.type&&(o=_,r.method="throw",r.arg=l.arg)}}}function R(t,n){var r=n.method,o=t.iterator[r];if(o===e)return n.delegate=null,"throw"===r&&t.iterator.return&&(n.method="return",n.arg=e,R(t,n),"throw"===n.method)||"return"!==r&&(n.method="throw",n.arg=new TypeError("The iterator does not provide a '"+r+"' method")),v;var i=f(o,t.iterator,n.arg);if("throw"===i.type)return n.method="throw",n.arg=i.arg,n.delegate=null,v;var s=i.arg;return s?s.done?(n[t.resultName]=s.value,n.next=t.nextLoc,"return"!==n.method&&(n.method="next",n.arg=e),n.delegate=null,v):s:(n.method="throw",n.arg=new TypeError("iterator result is not an object"),n.delegate=null,v)}function I(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function O(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function k(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(I,this),this.reset(!0)}function x(t){if(t||""===t){var n=t[s];if(n)return n.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var o=-1,i=function n(){for(;++o<t.length;)if(r.call(t,o))return n.value=t[o],n.done=!1,n;return n.value=e,n.done=!0,n};return i.next=i}}throw new TypeError(te(t)+" is not iterable")}return y.prototype=g,o(S,"constructor",{value:g,configurable:!0}),o(g,"constructor",{value:y,configurable:!0}),y.displayName=l(g,u,"GeneratorFunction"),t.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===y||"GeneratorFunction"===(t.displayName||t.name))},t.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,g):(e.__proto__=g,l(e,u,"GeneratorFunction")),e.prototype=Object.create(S),e},t.awrap=function(e){return{__await:e}},E(C.prototype),l(C.prototype,a,(function(){return this})),t.AsyncIterator=C,t.async=function(e,n,r,o,i){void 0===i&&(i=Promise);var s=new C(c(e,n,r,o),i);return t.isGeneratorFunction(n)?s:s.next().then((function(e){return e.done?e.value:s.next()}))},E(S),l(S,u,"Generator"),l(S,s,(function(){return this})),l(S,"toString",(function(){return"[object Generator]"})),t.keys=function(e){var t=Object(e),n=[];for(var r in t)n.push(r);return n.reverse(),function e(){for(;n.length;){var r=n.pop();if(r in t)return e.value=r,e.done=!1,e}return e.done=!0,e}},t.values=x,k.prototype={constructor:k,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=e,this.done=!1,this.delegate=null,this.method="next",this.arg=e,this.tryEntries.forEach(O),!t)for(var n in this)"t"===n.charAt(0)&&r.call(this,n)&&!isNaN(+n.slice(1))&&(this[n]=e)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var n=this;function o(r,o){return a.type="throw",a.arg=t,n.next=r,o&&(n.method="next",n.arg=e),!!o}for(var i=this.tryEntries.length-1;i>=0;--i){var s=this.tryEntries[i],a=s.completion;if("root"===s.tryLoc)return o("end");if(s.tryLoc<=this.prev){var u=r.call(s,"catchLoc"),l=r.call(s,"finallyLoc");if(u&&l){if(this.prev<s.catchLoc)return o(s.catchLoc,!0);if(this.prev<s.finallyLoc)return o(s.finallyLoc)}else if(u){if(this.prev<s.catchLoc)return o(s.catchLoc,!0)}else{if(!l)throw Error("try statement without catch or finally");if(this.prev<s.finallyLoc)return o(s.finallyLoc)}}}},abrupt:function(e,t){for(var n=this.tryEntries.length-1;n>=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var i=o;break}}i&&("break"===e||"continue"===e)&&i.tryLoc<=t&&t<=i.finallyLoc&&(i=null);var s=i?i.completion:{};return s.type=e,s.arg=t,i?(this.method="next",this.next=i.finallyLoc,v):this.complete(s)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),v},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),O(n),v}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var r=n.completion;if("throw"===r.type){var o=r.arg;O(n)}return o}}throw Error("illegal catch attempt")},delegateYield:function(t,n,r){return this.delegate={iterator:x(t),resultName:n,nextLoc:r},"next"===this.method&&(this.arg=e),v}},t}function oe(e,t,n,r,o,i,s){try{var a=e[i](s),u=a.value}catch(e){return void n(e)}a.done?t(u):Promise.resolve(u).then(r,o)}function ie(e){return function(){var t=this,n=arguments;return new Promise((function(r,o){var i=e.apply(t,n);function s(e){oe(i,r,o,s,a,"next",e)}function a(e){oe(i,r,o,s,a,"throw",e)}s(void 0)}))}}function se(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,ae(r.key),r)}}function ae(e){var t=function(e,t){if("object"!=te(e)||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!=te(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==te(t)?t:t+""}function ue(e,t){if(t&&("object"==te(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}function le(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return(le=function(){return!!e})()}function ce(e){return ce=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},ce(e)}function fe(e,t){return fe=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},fe(e,t)}function he(e,t,n){(function(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")})(e,t),t.set(e,n)}function de(e,t,n){return e.set(_e(e,t),n),n}function pe(e,t){return e.get(_e(e,t))}function _e(e,t,n){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:n;throw new TypeError("Private element is not present on this object")}!function(e,t,n){(t=Z(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n}(ee,"content",null);var ve=new WeakMap,me=new WeakMap,ye=function(e){function t(e){var n,r;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),n=function(e,t,n){return t=ce(t),ue(e,le()?Reflect.construct(t,n||[],ce(e).constructor):t.apply(e,n))}(this,t),he(n,ve,void 0),he(n,me,void 0),navigator.permissions.query({name:"microphone"}).then(function(){var e=ie(re().mark((function e(t){return re().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if("prompt"!==t.state){e.next=5;break}return e.next=3,navigator.mediaDevices.getUserMedia({audio:{noiseSuppression:!0,echoCancellation:!0,autoGainControl:!0,sampleRate:48e3},video:!1});case 3:e.sent.getTracks().forEach((function(e){return e.stop()}));case 5:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}()),de(ve,n,_.getEventBus()),_.setBase(e),de(me,n,new ee),n.agent=ne(ne(ne(ne(ne({start:function(){pe(me,n).init()},logout:function(){pe(me,n).logout()},hangup:function(){pe(me,n).hangup()},relayList:function(){pe(me,n).relayList()},answer:function(){pe(me,n).answer()},call:function(e){pe(me,n).call(e)},keyup:function(e){pe(me,n).keyup(e)},status:function(e){pe(me,n).status(e)},regionInfo:function(e){pe(me,n).regionInfo(e)},mobileAnswer:function(e){pe(me,n).mobileAnswer(e)},transferQueue:function(e){pe(me,n).transferQueue(e)},transfer:function(e){pe(me,n).transfer(e)},threeWayStart:function(e){pe(me,n).threeWayStart(e)},threeWayCancel:function(){pe(me,n).threeWayCancel()},consultStart:function(e){pe(me,n).consultStart(e)},consultCancel:function(){pe(me,n).consultCancel()},consultTransfer:function(){pe(me,n).consultTransfer()},hold:function(){pe(me,n).hold()},unhold:function(){pe(me,n).unhold()},grade:function(){pe(me,n).grade()},queueList:function(){pe(me,n).queueList()}},"status",(function(e){pe(me,n).status(e)})),"getPhoneInfo",(function(){return pe(me,n).getPhoneInfo()})),"flowList",(function(){pe(me,n).flowList()})),"flow",(function(e){pe(me,n).flow(e)})),"close",(function(){pe(me,n).stop()})),n.tool={getMedia:function(){return pe(me,n).getMedia()},getDefaultMedia:function(){return pe(me,n).getDefaultMedia()},checkMicrophoneStatus:function(){return pe(me,n).checkMicrophoneStatus()},getSystemInfo:function(){return pe(me,n).getSystemInfo()},setAiDenoise:(r=ie(re().mark((function e(t){var r;return re().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(_.setBase({aiDenoise:!!t}),!(r=!!t)){e.next=6;break}return e.next=5,N.preloadWasm();case 5:r=e.sent;case 6:pe(ve,n).emit("onaidenoise",{status:r});case 7:case"end":return e.stop()}}),e)}))),function(e){return r.apply(this,arguments)})},n.custom={handle:function(e){pe(me,n).customHandle(e)}};for(var o=0,i=["webrtc","token","agent","account","socket"];o<i.length;o++){var s=i[o];if(void 0===e[s])return console.error("".concat(s," is required")),ue(n)}return n}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&fe(e,t)}(t,e),function(e,t,n){return t&&se(e.prototype,t),n&&se(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}(t,[{key:"on",value:function(e,t){pe(ve,this).on(e,t)}},{key:"onopen",value:function(e){pe(ve,this).on("onopen",e)}},{key:"onmessage",value:function(e){pe(ve,this).on("onmessage",e)}},{key:"onclose",value:function(e){pe(ve,this).on("onclose",e)}},{key:"onerror",value:function(e){pe(ve,this).on("onerror",e)}},{key:"onlinetime",value:function(e){pe(ve,this).on("onlinetime",e)}},{key:"onaidenoise",value:function(e){pe(ve,this).on("onaidenoise",e)}},{key:"onpermission",value:function(e){pe(ve,this).on("onpermission",e)}},{key:"error",value:function(e){pe(ve,this).on("error",e)}}])}(_)})(),r=r.default})()));
34
+ name:"maxMessageSize",reg:/^max-message-size:(\d+)$/,format:"max-message-size:%s"},{push:"tsRefClocks",reg:/^ts-refclk:([^\s=]*)(?:=(\S*))?/,names:["clksrc","clksrcExt"],format:function(e){return"ts-refclk:%s"+(null!=e.clksrcExt?"=%s":"")}},{name:"mediaClk",reg:/^mediaclk:(?:id=(\S*))? *([^\s=]*)(?:=(\S*))?(?: *rate=(\d+)\/(\d+))?/,names:["id","mediaClockName","mediaClockValue","rateNumerator","rateDenominator"],format:function(e){var t="mediaclk:";return t+=null!=e.id?"id=%s %s":"%v%s",t+=null!=e.mediaClockValue?"=%s":"",t+=null!=e.rateNumerator?" rate=%s":"",t+=null!=e.rateDenominator?"/%s":""}},{name:"keywords",reg:/^keywds:(.+)$/,format:"keywds:%s"},{name:"content",reg:/^content:(.+)/,format:"content:%s"},{name:"bfcpFloorCtrl",reg:/^floorctrl:(c-only|s-only|c-s)/,format:"floorctrl:%s"},{name:"bfcpConfId",reg:/^confid:(\d+)/,format:"confid:%s"},{name:"bfcpUserId",reg:/^userid:(\d+)/,format:"userid:%s"},{name:"bfcpFloorId",reg:/^floorid:(.+) (?:m-stream|mstrm):(.+)/,names:["id","mStream"],format:"floorid:%s mstrm:%s"},{push:"invalid",names:["value"]}]};Object.keys(t).forEach((function(e){t[e].forEach((function(e){e.reg||(e.reg=/(.*)/),e.format||(e.format="%s")}))}))},363:(e,t,n)=>{var r=n(20),o=n(804);t.write=o,t.parse=r.parse,t.parseParams=r.parseParams,t.parseFmtpConfig=r.parseFmtpConfig,t.parsePayloads=r.parsePayloads,t.parseRemoteCandidates=r.parseRemoteCandidates,t.parseImageAttributes=r.parseImageAttributes,t.parseSimulcastStreamList=r.parseSimulcastStreamList},20:(e,t,n)=>{var r=function(e){return String(Number(e))===e?Number(e):e},o=function(e,t,n){var o=e.name&&e.names;e.push&&!t[e.push]?t[e.push]=[]:o&&!t[e.name]&&(t[e.name]={});var i=e.push?{}:o?t[e.name]:t;!function(e,t,n,o){if(o&&!n)t[o]=r(e[1]);else for(var i=0;i<n.length;i+=1)null!=e[i+1]&&(t[n[i]]=r(e[i+1]))}(n.match(e.reg),i,e.names,e.name),e.push&&t[e.push].push(i)},i=n(602),s=RegExp.prototype.test.bind(/^([a-z])=(.*)/);t.parse=function(e){var t={},n=[],r=t;return e.split(/(\r\n|\r|\n)/).filter(s).forEach((function(e){var t=e[0],s=e.slice(2);"m"===t&&(n.push({rtp:[],fmtp:[]}),r=n[n.length-1]);for(var a=0;a<(i[t]||[]).length;a+=1){var u=i[t][a];if(u.reg.test(s))return o(u,r,s)}})),t.media=n,t};var a=function(e,t){var n=t.split(/=(.+)/,2);return 2===n.length?e[n[0]]=r(n[1]):1===n.length&&t.length>1&&(e[n[0]]=void 0),e};t.parseParams=function(e){return e.split(/;\s?/).reduce(a,{})},t.parseFmtpConfig=t.parseParams,t.parsePayloads=function(e){return e.toString().split(" ").map(Number)},t.parseRemoteCandidates=function(e){for(var t=[],n=e.split(" ").map(r),o=0;o<n.length;o+=3)t.push({component:n[o],ip:n[o+1],port:n[o+2]});return t},t.parseImageAttributes=function(e){return e.split(" ").map((function(e){return e.substring(1,e.length-1).split(",").reduce(a,{})}))},t.parseSimulcastStreamList=function(e){return e.split(";").map((function(e){return e.split(",").map((function(e){var t,n=!1;return"~"!==e[0]?t=r(e):(t=r(e.substring(1,e.length)),n=!0),{scid:t,paused:n}}))}))}},804:(e,t,n)=>{var r=n(602),o=/%[sdv%]/g,i=function(e){var t=1,n=arguments,r=n.length;return e.replace(o,(function(e){if(t>=r)return e;var o=n[t];switch(t+=1,e){case"%%":return"%";case"%s":return String(o);case"%d":return Number(o);case"%v":return""}}))},s=function(e,t,n){var r=[e+"="+(t.format instanceof Function?t.format(t.push?n:n[t.name]):t.format)];if(t.names)for(var o=0;o<t.names.length;o+=1){var s=t.names[o];t.name?r.push(n[t.name][s]):r.push(n[t.names[o]])}else r.push(n[t.name]);return i.apply(null,r)},a=["v","o","s","i","u","e","p","c","b","t","r","z","a"],u=["i","c","b","a"];e.exports=function(e,t){t=t||{},null==e.version&&(e.version=0),null==e.name&&(e.name=" "),e.media.forEach((function(e){null==e.payloads&&(e.payloads="")}));var n=t.outerOrder||a,o=t.innerOrder||u,i=[];return n.forEach((function(t){r[t].forEach((function(n){n.name in e&&null!=e[n.name]?i.push(s(t,n,e)):n.push in e&&null!=e[n.push]&&e[n.push].forEach((function(e){i.push(s(t,n,e))}))}))})),e.media.forEach((function(e){i.push(s("m",r.m[0],e)),o.forEach((function(t){r[t].forEach((function(n){n.name in e&&null!=e[n.name]?i.push(s(t,n,e)):n.push in e&&null!=e[n.push]&&e[n.push].forEach((function(e){i.push(s(t,n,e))}))}))}))})),i.join("\r\n")+"\r\n"}},633:e=>{"use strict";e.exports=JSON.parse('{"name":"jssip","title":"JsSIP","description":"the Javascript SIP library","version":"3.10.1","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"}}')}},t={};function n(r){var o=t[r];if(void 0!==o)return o.exports;var i=t[r]={exports:{}};return e[r](i,i.exports,n),i.exports}n.d=(e,t)=>{for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);var r={};return(()=>{"use strict";function e(t){return e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},e(t)}function t(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,o(r.key),r)}}function o(t){var n=function(t,n){if("object"!=e(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var o=r.call(t,n||"default");if("object"!=e(o))return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===n?String:Number)(t)}(t,"string");return"symbol"==e(n)?n:n+""}n.d(r,{default:()=>ye});var i,s,a,u=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.allowedEvents=t,this.events={}}return n=e,(r=[{key:"on",value:function(t,n){if("function"!=typeof n)throw new Error("回调必须是函数");if(!t||"string"!=typeof t)throw new Error("事件名必须是非空字符串");this.events[t]||(this.events[t]=[]),e.KEEP_EVENTS.includes(t)?0===this.events[t].length&&this.events[t].push(n):this.events[t].push(n)}},{key:"emit",value:function(e,t){var n=this.events[e];n&&n.forEach((function(n){try{n(t)}catch(t){console.error("事件 ".concat(e," 回调执行错误:"),t)}}))}},{key:"off",value:function(e,t){var n=this.events[e];n&&(this.events[e]=n.filter((function(e){return e!==t})))}},{key:"destroy",value:function(){this.events={}}},{key:"destroyEvents",value:function(){var t=this;Object.keys(this.events).forEach((function(n){e.KEEP_EVENTS.includes(n)||delete t.events[n]}))}}])&&t(n.prototype,r),o&&t(n,o),Object.defineProperty(n,"prototype",{writable:!1}),n;var n,r,o}();function l(e){return l="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},l(e)}function c(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function f(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?c(Object(n),!0).forEach((function(t){d(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):c(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function h(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,p(r.key),r)}}function d(e,t,n){return(t=p(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function p(e){var t=function(e,t){if("object"!=l(e)||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!=l(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==l(t)?t:t+""}i=u,a=[],(s=o(s="KEEP_EVENTS"))in i?Object.defineProperty(i,s,{value:a,enumerable:!0,configurable:!0,writable:!0}):i[s]=a;var _=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e)}return function(e,t,n){return t&&h(e.prototype,t),n&&h(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}(e,[{key:"on",value:function(e,t){this.eventBus.on(e,t)}}],[{key:"getEventBus",value:function(){return e.eventBus}},{key:"getBase",value:function(){return e.base}},{key:"setBase",value:function(t){e.base=f(f({},e.base),t)}}])}();d(_,"base",{webrtc:!1,checkin:!1,token:"",aiDenoise:!1,aiDenoisePath:"",agent:"",account:"",socket:"",sip:{socket:"",account:"",password:"",domain:""},env:""}),d(_,"eventBus",new u);var v=n(53);function m(e){return m="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},m(e)}function y(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,g(r.key),r)}}function g(e){var t=function(e,t){if("object"!=m(e)||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!=m(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==m(t)?t:t+""}var b=function(){return function(e,t,n){return t&&y(e.prototype,t),n&&y(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}((function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.allowedEvents=t,this.events={}}),[{key:"on",value:function(e,t){var n;void 0===(null===(n=this.events[e])||void 0===n?void 0:n.length)&&(this.events[e]||(this.events[e]=[]),this.events[e].push(t))}},{key:"emit",value:function(e,t){var n=this.events[e];n&&n.forEach((function(e){e(t)}))}},{key:"off",value:function(e,t){var n=this.events[e];n&&(this.events[e]=n.filter((function(e){return e!==t})))}},{key:"destroy",value:function(){this.events={}}}])}();function T(e){return T="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},T(e)}function w(){w=function(){return t};var e,t={},n=Object.prototype,r=n.hasOwnProperty,o=Object.defineProperty||function(e,t,n){e[t]=n.value},i="function"==typeof Symbol?Symbol:{},s=i.iterator||"@@iterator",a=i.asyncIterator||"@@asyncIterator",u=i.toStringTag||"@@toStringTag";function l(e,t,n){return Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{l({},"")}catch(e){l=function(e,t,n){return e[t]=n}}function c(e,t,n,r){var i=t&&t.prototype instanceof m?t:m,s=Object.create(i.prototype),a=new N(r||[]);return o(s,"_invoke",{value:I(e,n,a)}),s}function f(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(e){return{type:"throw",arg:e}}}t.wrap=c;var h="suspendedStart",d="suspendedYield",p="executing",_="completed",v={};function m(){}function y(){}function g(){}var b={};l(b,s,(function(){return this}));var S=Object.getPrototypeOf,E=S&&S(S(P([])));E&&E!==n&&r.call(E,s)&&(b=E);var C=g.prototype=m.prototype=Object.create(b);function A(e){["next","throw","return"].forEach((function(t){l(e,t,(function(e){return this._invoke(t,e)}))}))}function R(e,t){function n(o,i,s,a){var u=f(e[o],e,i);if("throw"!==u.type){var l=u.arg,c=l.value;return c&&"object"==T(c)&&r.call(c,"__await")?t.resolve(c.__await).then((function(e){n("next",e,s,a)}),(function(e){n("throw",e,s,a)})):t.resolve(c).then((function(e){l.value=e,s(l)}),(function(e){return n("throw",e,s,a)}))}a(u.arg)}var i;o(this,"_invoke",{value:function(e,r){function o(){return new t((function(t,o){n(e,r,t,o)}))}return i=i?i.then(o,o):o()}})}function I(t,n,r){var o=h;return function(i,s){if(o===p)throw Error("Generator is already running");if(o===_){if("throw"===i)throw s;return{value:e,done:!0}}for(r.method=i,r.arg=s;;){var a=r.delegate;if(a){var u=O(a,r);if(u){if(u===v)continue;return u}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if(o===h)throw o=_,r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);o=p;var l=f(t,n,r);if("normal"===l.type){if(o=r.done?_:d,l.arg===v)continue;return{value:l.arg,done:r.done}}"throw"===l.type&&(o=_,r.method="throw",r.arg=l.arg)}}}function O(t,n){var r=n.method,o=t.iterator[r];if(o===e)return n.delegate=null,"throw"===r&&t.iterator.return&&(n.method="return",n.arg=e,O(t,n),"throw"===n.method)||"return"!==r&&(n.method="throw",n.arg=new TypeError("The iterator does not provide a '"+r+"' method")),v;var i=f(o,t.iterator,n.arg);if("throw"===i.type)return n.method="throw",n.arg=i.arg,n.delegate=null,v;var s=i.arg;return s?s.done?(n[t.resultName]=s.value,n.next=t.nextLoc,"return"!==n.method&&(n.method="next",n.arg=e),n.delegate=null,v):s:(n.method="throw",n.arg=new TypeError("iterator result is not an object"),n.delegate=null,v)}function k(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function x(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function N(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(k,this),this.reset(!0)}function P(t){if(t||""===t){var n=t[s];if(n)return n.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var o=-1,i=function n(){for(;++o<t.length;)if(r.call(t,o))return n.value=t[o],n.done=!1,n;return n.value=e,n.done=!0,n};return i.next=i}}throw new TypeError(T(t)+" is not iterable")}return y.prototype=g,o(C,"constructor",{value:g,configurable:!0}),o(g,"constructor",{value:y,configurable:!0}),y.displayName=l(g,u,"GeneratorFunction"),t.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===y||"GeneratorFunction"===(t.displayName||t.name))},t.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,g):(e.__proto__=g,l(e,u,"GeneratorFunction")),e.prototype=Object.create(C),e},t.awrap=function(e){return{__await:e}},A(R.prototype),l(R.prototype,a,(function(){return this})),t.AsyncIterator=R,t.async=function(e,n,r,o,i){void 0===i&&(i=Promise);var s=new R(c(e,n,r,o),i);return t.isGeneratorFunction(n)?s:s.next().then((function(e){return e.done?e.value:s.next()}))},A(C),l(C,u,"Generator"),l(C,s,(function(){return this})),l(C,"toString",(function(){return"[object Generator]"})),t.keys=function(e){var t=Object(e),n=[];for(var r in t)n.push(r);return n.reverse(),function e(){for(;n.length;){var r=n.pop();if(r in t)return e.value=r,e.done=!1,e}return e.done=!0,e}},t.values=P,N.prototype={constructor:N,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=e,this.done=!1,this.delegate=null,this.method="next",this.arg=e,this.tryEntries.forEach(x),!t)for(var n in this)"t"===n.charAt(0)&&r.call(this,n)&&!isNaN(+n.slice(1))&&(this[n]=e)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var n=this;function o(r,o){return a.type="throw",a.arg=t,n.next=r,o&&(n.method="next",n.arg=e),!!o}for(var i=this.tryEntries.length-1;i>=0;--i){var s=this.tryEntries[i],a=s.completion;if("root"===s.tryLoc)return o("end");if(s.tryLoc<=this.prev){var u=r.call(s,"catchLoc"),l=r.call(s,"finallyLoc");if(u&&l){if(this.prev<s.catchLoc)return o(s.catchLoc,!0);if(this.prev<s.finallyLoc)return o(s.finallyLoc)}else if(u){if(this.prev<s.catchLoc)return o(s.catchLoc,!0)}else{if(!l)throw Error("try statement without catch or finally");if(this.prev<s.finallyLoc)return o(s.finallyLoc)}}}},abrupt:function(e,t){for(var n=this.tryEntries.length-1;n>=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var i=o;break}}i&&("break"===e||"continue"===e)&&i.tryLoc<=t&&t<=i.finallyLoc&&(i=null);var s=i?i.completion:{};return s.type=e,s.arg=t,i?(this.method="next",this.next=i.finallyLoc,v):this.complete(s)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),v},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),x(n),v}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var r=n.completion;if("throw"===r.type){var o=r.arg;x(n)}return o}}throw Error("illegal catch attempt")},delegateYield:function(t,n,r){return this.delegate={iterator:P(t),resultName:n,nextLoc:r},"next"===this.method&&(this.arg=e),v}},t}function S(e,t,n,r,o,i,s){try{var a=e[i](s),u=a.value}catch(e){return void n(e)}a.done?t(u):Promise.resolve(u).then(r,o)}function E(e){return function(){var t=this,n=arguments;return new Promise((function(r,o){var i=e.apply(t,n);function s(e){S(i,r,o,s,a,"next",e)}function a(e){S(i,r,o,s,a,"throw",e)}s(void 0)}))}}function C(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,x(r.key),r)}}function A(e,t,n){return t=I(t),function(e,t){if(t&&("object"==T(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}(e,R()?Reflect.construct(t,n||[],I(e).constructor):t.apply(e,n))}function R(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return(R=function(){return!!e})()}function I(e){return I=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},I(e)}function O(e,t){return O=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},O(e,t)}function k(e,t,n){return(t=x(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function x(e){var t=function(e,t){if("object"!=T(e)||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!=T(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==T(t)?t:t+""}var N=function(e){function t(){return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),A(this,t)}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&O(e,t)}(t,e),function(e,t,n){return t&&C(e.prototype,t),n&&C(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}(t,[{key:"on",value:function(e,n){t.eventBus.on(e,n)}},{key:"init",value:(i=E(w().mark((function e(){var n,r,o,i,s;return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=this,!t.content||!t.content.isConnected()){e.next=6;break}return t.content.start(),e.abrupt("return");case 6:if(!t.content||!t.content.isRegistered()){e.next=10;break}return e.abrupt("return");case 10:if(!t.content){e.next=13;break}return t.content.start(),e.abrupt("return");case 13:(r=_.getBase()).aiDenoise&&t.preloadWasm(),o=new v.WebSocketInterface(r.sip.socket),i="sip:"+r.sip.account+"@"+r.sip.domain,s={sockets:[o],uri:i,password:r.sip.password,mediaConstraints:{audio:{echoCancellation:!0,noiseSuppression:!0,autoGainControl:!0,sampleRate:48e3},video:!1}},t.content=new v.UA(s),t.content.on("newRTCSession",(function(e){t.eventBus.emit("newRTCSession",e);var r=e.session;"remote"===e.originator&&(t.answerSession=e.session),r.on("peerconnection",(function(n){t.eventBus.emit("peerconnection",e),n.peerconnection.onaddstream=function(e){t.audio.srcObject=e.stream,t.audio.play()}})),r.on("progress",(function(r){t.eventBus.emit("progress",r);var o=e.request.headers["Call-Info"];void 0!==o&&o[0].raw.includes("answer-after")&&n.answer()})),r.on("failed",(function(e){t.answerSession=null,t.eventBus.emit("failed",e)})),r.on("ended",(function(e){t.eventBus.emit("ended",e),t.answerSession=null}))})),t.content.on("registrationFailed",(function(e){t.eventBus.emit("registrationFailed",e)})),t.content.on("disconnected",(function(e){t.eventBus.emit("disconnected",e)})),t.content.on("registered",(function(e){t.eventBus.emit("registered",e)})),n.start();case 24:case"end":return e.stop()}}),e,this)}))),function(){return i.apply(this,arguments)})},{key:"answer",value:(o=E(w().mark((function e(){var n;return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!t.answerSession){e.next=11;break}if(!_.getBase().aiDenoise){e.next=4;break}return e.next=4,t.initAiDenoise();case 4:return e.next=6,navigator.mediaDevices.getUserMedia({audio:{noiseSuppression:!0,echoCancellation:!0,autoGainControl:!0,sampleRate:48e3},video:!1});case 6:n=e.sent,_.getBase().aiDenoise&&t.rnnoiseNode&&t.audioContext&&(n=t.applyAiDenoise(n)),t.answerSession.answer({mediaConstraints:{audio:!0,video:!1},mediaStream:n,pcConfig:{iceServers:[]},sessionTimersExpires:180}),e.next=12;break;case 11:t.eventBus.emit("answerSession",{code:401,message:"接听对象不存在",data:""});case 12:case"end":return e.stop()}}),e)}))),function(){return o.apply(this,arguments)})},{key:"start",value:function(){t.content&&(t.content.isRegistered()||t.content.start())}},{key:"stop",value:function(){t.content&&t.content.stop()}},{key:"switchMicrophone",value:function(e){t.answerSession&&navigator.mediaDevices.getUserMedia({audio:{deviceId:{exact:e}},video:!1}).then((function(e){var n=t.answerSession.connection.getSenders().find((function(e){var t;return"audio"===(null===(t=e.track)||void 0===t?void 0:t.kind)}));n&&n.replaceTrack(e.getAudioTracks()[0])})).catch((function(e){console.error("切换麦克风失败:",e)}))}},{key:"switchSpeaker",value:function(e){t.audio.setSinkId?t.audio.setSinkId(e).then((function(){return console.log("已切换到扬声器: ".concat(e))})).catch((function(e){return console.error("切换扬声器失败:",e)})):console.warn("当前浏览器不支持切换扬声器")}}],[{key:"getEventBus",value:function(){return t.eventBus}},{key:"getContent",value:function(){return t.content}},{key:"preloadWasm",value:(r=E(w().mark((function e(){var n,r;return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!t.wasmBytes){e.next=2;break}return e.abrupt("return",!0);case 2:if(n=_.getBase().aiDenoisePath){e.next=5;break}return e.abrupt("return",!1);case 5:return e.prev=5,e.next=8,fetch(n);case 8:if((r=e.sent).ok){e.next=11;break}return e.abrupt("return",!1);case 11:return e.next=13,r.arrayBuffer();case 13:return t.wasmBytes=e.sent,e.abrupt("return",!0);case 17:return e.prev=17,e.t0=e.catch(5),e.abrupt("return",!1);case 20:case"end":return e.stop()}}),e,null,[[5,17]])}))),function(){return r.apply(this,arguments)})},{key:"initAiDenoise",value:(n=E(w().mark((function e(){var n;return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!t.rnnoiseNode){e.next=2;break}return e.abrupt("return");case 2:if(t.wasmBytes){e.next=5;break}return e.next=5,t.preloadWasm();case 5:return t.audioContext=new AudioContext({sampleRate:48e3}),e.next=8,t.audioContext.resume();case 8:return e.next=10,t.audioContext.audioWorklet.addModule(URL.createObjectURL(new Blob(['function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }\nfunction _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator["return"] && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a \'" + n + "\' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, "catch": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }\nfunction asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); }\nfunction _asyncToGenerator(n) { return function () { var t = this, e = arguments; return new Promise(function (r, o) { var a = n.apply(t, e); function _next(n) { asyncGeneratorStep(a, r, o, _next, _throw, "next", n); } function _throw(n) { asyncGeneratorStep(a, r, o, _next, _throw, "throw", n); } _next(void 0); }); }; }\nfunction _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }\nfunction _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }\nfunction _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }\nfunction _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }\nfunction _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }\nfunction _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }\nfunction _possibleConstructorReturn(t, e) { if (e && ("object" == _typeof(e) || "function" == typeof e)) return e; if (void 0 !== e) throw new TypeError("Derived constructors may only return object or undefined"); return _assertThisInitialized(t); }\nfunction _assertThisInitialized(e) { if (void 0 === e) throw new ReferenceError("this hasn\'t been initialised - super() hasn\'t been called"); return e; }\nfunction _inherits(t, e) { if ("function" != typeof e && null !== e) throw new TypeError("Super expression must either be null or a function"); t.prototype = Object.create(e && e.prototype, { constructor: { value: t, writable: !0, configurable: !0 } }), Object.defineProperty(t, "prototype", { writable: !1 }), e && _setPrototypeOf(t, e); }\nfunction _wrapNativeSuper(t) { var r = "function" == typeof Map ? new Map() : void 0; return _wrapNativeSuper = function _wrapNativeSuper(t) { if (null === t || !_isNativeFunction(t)) return t; if ("function" != typeof t) throw new TypeError("Super expression must either be null or a function"); if (void 0 !== r) { if (r.has(t)) return r.get(t); r.set(t, Wrapper); } function Wrapper() { return _construct(t, arguments, _getPrototypeOf(this).constructor); } return Wrapper.prototype = Object.create(t.prototype, { constructor: { value: Wrapper, enumerable: !1, writable: !0, configurable: !0 } }), _setPrototypeOf(Wrapper, t); }, _wrapNativeSuper(t); }\nfunction _construct(t, e, r) { if (_isNativeReflectConstruct()) return Reflect.construct.apply(null, arguments); var o = [null]; o.push.apply(o, e); var p = new (t.bind.apply(t, o))(); return r && _setPrototypeOf(p, r.prototype), p; }\nfunction _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }\nfunction _isNativeFunction(t) { try { return -1 !== Function.toString.call(t).indexOf("[native code]"); } catch (n) { return "function" == typeof t; } }\nfunction _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return t.__proto__ = e, t; }, _setPrototypeOf(t, e); }\nfunction _getPrototypeOf(t) { return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) { return t.__proto__ || Object.getPrototypeOf(t); }, _getPrototypeOf(t); }\nvar RNNoiseProcessor = /*#__PURE__*/function (_AudioWorkletProcesso) {\n function RNNoiseProcessor() {\n var _this;\n _classCallCheck(this, RNNoiseProcessor);\n _this = _callSuper(this, RNNoiseProcessor);\n _this.ready = false;\n _this.enabled = true;\n _this.inBuf = new Float32Array(480);\n _this.inIdx = 0;\n _this.outRing = new Float32Array(4800);\n _this.writePos = 0;\n _this.readPos = 0;\n _this.port.onmessage = function (e) {\n if (e.data.type === "init") _this.initWasm(e.data);\n if (e.data.type === "enable") _this.enabled = true;\n if (e.data.type === "disable") _this.enabled = false;\n };\n return _this;\n }\n _inherits(RNNoiseProcessor, _AudioWorkletProcesso);\n return _createClass(RNNoiseProcessor, [{\n key: "initWasm",\n value: function () {\n var _initWasm = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(data) {\n var wasmBytes, imports, _yield$WebAssembly$in, instance, ex, heap, i;\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n wasmBytes = data.wasmBytes;\n imports = {\n wasi_snapshot_preview1: {\n args_get: function args_get() {\n return 0;\n },\n args_sizes_get: function args_sizes_get() {\n return 0;\n },\n proc_exit: function proc_exit() {}\n }\n };\n _context.next = 4;\n return WebAssembly.instantiate(wasmBytes, imports);\n case 4:\n _yield$WebAssembly$in = _context.sent;\n instance = _yield$WebAssembly$in.instance;\n ex = instance.exports;\n if (ex._initialize) ex._initialize();\n this.memory = ex.memory;\n this.processFrame = ex.rnnoise_process_frame;\n this.statePtr = ex.rnnoise_create(0);\n this.inputPtr = ex.malloc(480 * 4);\n this.outputPtr = ex.malloc(480 * 4);\n heap = new Float32Array(this.memory.buffer);\n for (i = 0; i < 3; i++) {\n heap.fill(0, this.inputPtr >> 2, (this.inputPtr >> 2) + 480);\n this.processFrame(this.statePtr, this.outputPtr, this.inputPtr);\n }\n this.ready = true;\n this.port.postMessage({\n type: "ready"\n });\n case 17:\n case "end":\n return _context.stop();\n }\n }, _callee, this);\n }));\n function initWasm(_x) {\n return _initWasm.apply(this, arguments);\n }\n return initWasm;\n }()\n }, {\n key: "process",\n value: function process(inputs, outputs) {\n var input = inputs[0][0];\n var output = outputs[0][0];\n if (!input) return true;\n if (!this.ready || !this.enabled) {\n output.set(input);\n return true;\n }\n for (var i = 0; i < input.length; i++) {\n this.inBuf[this.inIdx++] = input[i] * 32768;\n if (this.inIdx === 480) {\n var heap = new Float32Array(this.memory.buffer);\n heap.set(this.inBuf, this.inputPtr >> 2);\n this.processFrame(this.statePtr, this.outputPtr, this.inputPtr);\n var out = new Float32Array(this.memory.buffer, this.outputPtr, 480);\n for (var j = 0; j < 480; j++) {\n this.outRing[this.writePos % 4800] = out[j] / 32768;\n this.writePos++;\n }\n this.inIdx = 0;\n }\n }\n for (var _i = 0; _i < output.length; _i++) {\n if (this.readPos < this.writePos) {\n output[_i] = this.outRing[this.readPos % 4800];\n this.readPos++;\n } else {\n output[_i] = 0;\n }\n }\n if (this.readPos > 48000) {\n this.writePos -= this.readPos;\n this.readPos = 0;\n }\n return true;\n }\n }]);\n}(/*#__PURE__*/_wrapNativeSuper(AudioWorkletProcessor));\nregisterProcessor("rnnoise-processor", RNNoiseProcessor);'],{type:"application/javascript"})));case 10:return t.rnnoiseNode=new AudioWorkletNode(t.audioContext,"rnnoise-processor"),n=t.wasmBytes,e.next=14,new Promise((function(e){t.rnnoiseNode.port.onmessage=function(t){"ready"===t.data.type&&e(),"error"===t.data.type&&console.error("Worklet降噪出错:",t.data.message)},t.rnnoiseNode.port.postMessage({type:"init",wasmBytes:n},[n])}));case 14:case"end":return e.stop()}}),e)}))),function(){return n.apply(this,arguments)})},{key:"applyAiDenoise",value:function(e){var n=t.audioContext.createMediaStreamSource(e),r=t.audioContext.createMediaStreamDestination();return n.connect(t.rnnoiseNode),t.rnnoiseNode.connect(r),r.stream}},{key:"destroy",value:function(){t.eventBus.destroy()}}]);var n,r,o,i}(_);function P(e){return P="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},P(e)}function D(e,t){var n=e.toString();return n.length>=t?n:n.padStart(t,"0")}function L(e){return L="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},L(e)}function U(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,M(r.key),r)}}function M(e){var t=function(e,t){if("object"!=L(e)||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!=L(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==L(t)?t:t+""}k(N,"content",null),k(N,"answerSession",null),k(N,"audio",new Audio),k(N,"eventBus",new b);var j=function(){return function(e,t,n){return t&&U(e.prototype,t),n&&U(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}((function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.defaultColor="#909399"}),[{key:"log",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:this.defaultColor,r=_.getBase();if(r.env&&"debug"===r.env){for(var o,i=function(e,t){if(0===arguments.length)return null;var n,r=t||"{y}-{m}-{d} {h}:{i}:{s}";"object"===P(e)?n=e:("string"==typeof e&&/^[0-9]+$/.test(e)&&(e=parseInt(e)),"number"==typeof e&&10===e.toString().length&&(e*=1e3),n=new Date(e));var o={y:n.getFullYear(),m:n.getMonth()+1,d:n.getDate(),h:n.getHours(),i:n.getMinutes(),s:n.getSeconds(),a:n.getDay()};return r.replace(/{([ymdhisa])+}/g,(function(e,t){var n=o[t];return"a"===t?["日","一","二","三","四","五","六"][n]:n.toString().padStart(2,"0")}))}(new Date),s=arguments.length,a=new Array(s>3?s-3:0),u=3;u<s;u++)a[u-3]=arguments[u];(o=console).log.apply(o,["%c ".concat(e," %c ").concat(t," %c"),"background:#35495E; padding: 2px 1px; border-radius: 3px 0 0 3px; color: #fff;","background:".concat(n,"; padding: 2px 1px; border-radius: 0 3px 3px 0; color: #fff;"),"background:transparent"].concat(a,["".concat(i)]))}}},{key:"info",value:function(e,t){for(var n=arguments.length,r=new Array(n>2?n-2:0),o=2;o<n;o++)r[o-2]=arguments[o];this.log.apply(this,[e,t,"#909399"].concat(r))}},{key:"success",value:function(e,t){for(var n=arguments.length,r=new Array(n>2?n-2:0),o=2;o<n;o++)r[o-2]=arguments[o];this.log.apply(this,[e,t,"#67C23A"].concat(r))}},{key:"error",value:function(e,t){for(var n=arguments.length,r=new Array(n>2?n-2:0),o=2;o<n;o++)r[o-2]=arguments[o];this.log.apply(this,[e,t,"#F56C6C"].concat(r))}},{key:"warning",value:function(e,t){for(var n=arguments.length,r=new Array(n>2?n-2:0),o=2;o<n;o++)r[o-2]=arguments[o];this.log.apply(this,[e,t,"#E6A23C"].concat(r))}},{key:"custom",value:function(e,t,n){for(var r=arguments.length,o=new Array(r>3?r-3:0),i=3;i<r;i++)o[i-3]=arguments[i];this.log.apply(this,[e,t,n].concat(o))}}])}();const q=new j;function F(e){return F="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},F(e)}function H(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,G(r.key),r)}}function G(e){var t=function(e,t){if("object"!=F(e)||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!=F(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==F(t)?t:t+""}var B=function(){return function(e,t,n){return t&&H(e.prototype,t),n&&H(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}((function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1e3;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.updateInterval=t,this.worker=null,this.isRunning=!1,this.elapsedSeconds=0,this.onUpdate=null}),[{key:"start",value:function(){var e=this;if(!this.isRunning){this.isRunning=!0,this.elapsedSeconds=0;var t=new Blob(['\nlet elapsedSeconds = 0\nlet intervalId = null\n\nonmessage = function (e) {\n if (e.data.command === "start") {\n const interval = e.data.interval || 1000\n intervalId = setInterval(() => {\n elapsedSeconds++\n postMessage({ command: "tick", elapsedSeconds: elapsedSeconds })\n }, interval)\n } else if (e.data.command === "stop") {\n clearInterval(intervalId)\n intervalId = null\n elapsedSeconds = 0\n }\n}\n'],{type:"application/javascript"}),n=URL.createObjectURL(t);this.worker=new Worker(n),this.worker.postMessage({command:"start",interval:this.updateInterval}),this.worker.onmessage=function(t){"tick"===t.data.command&&(e.elapsedSeconds=t.data.elapsedSeconds,e.onUpdate&&e.onUpdate(e.elapsedSeconds))}}}},{key:"stop",value:function(){this.worker&&(this.worker.postMessage({command:"stop"}),this.worker.terminate(),this.worker=null),this.isRunning=!1}},{key:"setOnUpdate",value:function(e){this.onUpdate=e}}])}();function W(e){return W="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},W(e)}function V(){V=function(){return t};var e,t={},n=Object.prototype,r=n.hasOwnProperty,o=Object.defineProperty||function(e,t,n){e[t]=n.value},i="function"==typeof Symbol?Symbol:{},s=i.iterator||"@@iterator",a=i.asyncIterator||"@@asyncIterator",u=i.toStringTag||"@@toStringTag";function l(e,t,n){return Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{l({},"")}catch(e){l=function(e,t,n){return e[t]=n}}function c(e,t,n,r){var i=t&&t.prototype instanceof m?t:m,s=Object.create(i.prototype),a=new k(r||[]);return o(s,"_invoke",{value:A(e,n,a)}),s}function f(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(e){return{type:"throw",arg:e}}}t.wrap=c;var h="suspendedStart",d="suspendedYield",p="executing",_="completed",v={};function m(){}function y(){}function g(){}var b={};l(b,s,(function(){return this}));var T=Object.getPrototypeOf,w=T&&T(T(x([])));w&&w!==n&&r.call(w,s)&&(b=w);var S=g.prototype=m.prototype=Object.create(b);function E(e){["next","throw","return"].forEach((function(t){l(e,t,(function(e){return this._invoke(t,e)}))}))}function C(e,t){function n(o,i,s,a){var u=f(e[o],e,i);if("throw"!==u.type){var l=u.arg,c=l.value;return c&&"object"==W(c)&&r.call(c,"__await")?t.resolve(c.__await).then((function(e){n("next",e,s,a)}),(function(e){n("throw",e,s,a)})):t.resolve(c).then((function(e){l.value=e,s(l)}),(function(e){return n("throw",e,s,a)}))}a(u.arg)}var i;o(this,"_invoke",{value:function(e,r){function o(){return new t((function(t,o){n(e,r,t,o)}))}return i=i?i.then(o,o):o()}})}function A(t,n,r){var o=h;return function(i,s){if(o===p)throw Error("Generator is already running");if(o===_){if("throw"===i)throw s;return{value:e,done:!0}}for(r.method=i,r.arg=s;;){var a=r.delegate;if(a){var u=R(a,r);if(u){if(u===v)continue;return u}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if(o===h)throw o=_,r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);o=p;var l=f(t,n,r);if("normal"===l.type){if(o=r.done?_:d,l.arg===v)continue;return{value:l.arg,done:r.done}}"throw"===l.type&&(o=_,r.method="throw",r.arg=l.arg)}}}function R(t,n){var r=n.method,o=t.iterator[r];if(o===e)return n.delegate=null,"throw"===r&&t.iterator.return&&(n.method="return",n.arg=e,R(t,n),"throw"===n.method)||"return"!==r&&(n.method="throw",n.arg=new TypeError("The iterator does not provide a '"+r+"' method")),v;var i=f(o,t.iterator,n.arg);if("throw"===i.type)return n.method="throw",n.arg=i.arg,n.delegate=null,v;var s=i.arg;return s?s.done?(n[t.resultName]=s.value,n.next=t.nextLoc,"return"!==n.method&&(n.method="next",n.arg=e),n.delegate=null,v):s:(n.method="throw",n.arg=new TypeError("iterator result is not an object"),n.delegate=null,v)}function I(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function O(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function k(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(I,this),this.reset(!0)}function x(t){if(t||""===t){var n=t[s];if(n)return n.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var o=-1,i=function n(){for(;++o<t.length;)if(r.call(t,o))return n.value=t[o],n.done=!1,n;return n.value=e,n.done=!0,n};return i.next=i}}throw new TypeError(W(t)+" is not iterable")}return y.prototype=g,o(S,"constructor",{value:g,configurable:!0}),o(g,"constructor",{value:y,configurable:!0}),y.displayName=l(g,u,"GeneratorFunction"),t.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===y||"GeneratorFunction"===(t.displayName||t.name))},t.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,g):(e.__proto__=g,l(e,u,"GeneratorFunction")),e.prototype=Object.create(S),e},t.awrap=function(e){return{__await:e}},E(C.prototype),l(C.prototype,a,(function(){return this})),t.AsyncIterator=C,t.async=function(e,n,r,o,i){void 0===i&&(i=Promise);var s=new C(c(e,n,r,o),i);return t.isGeneratorFunction(n)?s:s.next().then((function(e){return e.done?e.value:s.next()}))},E(S),l(S,u,"Generator"),l(S,s,(function(){return this})),l(S,"toString",(function(){return"[object Generator]"})),t.keys=function(e){var t=Object(e),n=[];for(var r in t)n.push(r);return n.reverse(),function e(){for(;n.length;){var r=n.pop();if(r in t)return e.value=r,e.done=!1,e}return e.done=!0,e}},t.values=x,k.prototype={constructor:k,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=e,this.done=!1,this.delegate=null,this.method="next",this.arg=e,this.tryEntries.forEach(O),!t)for(var n in this)"t"===n.charAt(0)&&r.call(this,n)&&!isNaN(+n.slice(1))&&(this[n]=e)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var n=this;function o(r,o){return a.type="throw",a.arg=t,n.next=r,o&&(n.method="next",n.arg=e),!!o}for(var i=this.tryEntries.length-1;i>=0;--i){var s=this.tryEntries[i],a=s.completion;if("root"===s.tryLoc)return o("end");if(s.tryLoc<=this.prev){var u=r.call(s,"catchLoc"),l=r.call(s,"finallyLoc");if(u&&l){if(this.prev<s.catchLoc)return o(s.catchLoc,!0);if(this.prev<s.finallyLoc)return o(s.finallyLoc)}else if(u){if(this.prev<s.catchLoc)return o(s.catchLoc,!0)}else{if(!l)throw Error("try statement without catch or finally");if(this.prev<s.finallyLoc)return o(s.finallyLoc)}}}},abrupt:function(e,t){for(var n=this.tryEntries.length-1;n>=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var i=o;break}}i&&("break"===e||"continue"===e)&&i.tryLoc<=t&&t<=i.finallyLoc&&(i=null);var s=i?i.completion:{};return s.type=e,s.arg=t,i?(this.method="next",this.next=i.finallyLoc,v):this.complete(s)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),v},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),O(n),v}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var r=n.completion;if("throw"===r.type){var o=r.arg;O(n)}return o}}throw Error("illegal catch attempt")},delegateYield:function(t,n,r){return this.delegate={iterator:x(t),resultName:n,nextLoc:r},"next"===this.method&&(this.arg=e),v}},t}function K(e,t,n,r,o,i,s){try{var a=e[i](s),u=a.value}catch(e){return void n(e)}a.done?t(u):Promise.resolve(u).then(r,o)}function z(e){return function(){var t=this,n=arguments;return new Promise((function(r,o){var i=e.apply(t,n);function s(e){K(i,r,o,s,a,"next",e)}function a(e){K(i,r,o,s,a,"throw",e)}s(void 0)}))}}function Y(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,Z(r.key),r)}}function $(e,t,n){return t=X(t),function(e,t){if(t&&("object"==W(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}(e,J()?Reflect.construct(t,n||[],X(e).constructor):t.apply(e,n))}function J(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return(J=function(){return!!e})()}function X(e){return X=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},X(e)}function Q(e,t){return Q=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},Q(e,t)}function Z(e){var t=function(e,t){if("object"!=W(e)||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!=W(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==W(t)?t:t+""}var ee=function(e){function t(){var e;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),(e=$(this,t)).baseInfo=_.getBase(),e.initEvent(),e.initJssip(),e.telephone={type:"",reconnect:!1,networkDisconnected:!1,clientTime:Math.floor(Date.now()/1e3),serverTime:Math.floor(Date.now()/1e3),statusTime:0,diff:0,statusCode:""},e.timer=null,e.watchTimer=null,e.permissionTimer=null,e}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&Q(e,t)}(t,e),function(e,t,n){return t&&Y(e.prototype,t),n&&Y(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}(t,[{key:"startWatchTimer",value:function(){var e=this;this.watchTimer=new B,this.watchTimer.setOnUpdate((function(){if(e.telephone.clientTime=Math.floor(Date.now()/1e3),0!==e.telephone.statusTime){var t=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"hms",n=Math.floor(e/864e5),r=e%864e5,o=Math.floor(r/36e5),i=r%36e5,s=Math.floor(i/6e4),a=i%6e4,u=Math.round(a/1e3);return"dhms"===t?{day:D(n),hours:D(o,2),minutes:D(s,2),seconds:D(u,2)}:"hms"===t?{hours:D(n>0?24*n+o:o,2),minutes:D(s,2),seconds:D(u,2)}:void 0}(1e3*(e.telephone.clientTime-e.telephone.statusTime+e.telephone.diff),"hms");e.eventBus.emit("onlinetime",t.hours+":"+t.minutes+":"+t.seconds)}})),this.watchTimer.start()}},{key:"stopWatchTimer",value:function(){this.watchTimer&&(this.watchTimer.stop(),this.watchTimer=null)}},{key:"stopPermissionTime",value:function(){this.permissionTimer&&(this.permissionTimer.stop(),this.permissionTimer=null)}},{key:"startTimer",value:function(){var e=this;this.timer=new B(3e4),this.timer.setOnUpdate((function(){e.sendMessage({type:"Time",data:{}})})),this.timer.start()}},{key:"stopTimer",value:function(){this.timer&&(this.timer.stop(),this.timer=null)}},{key:"stop",value:function(){this.eventBus.emit("onlinetime","00:00:00"),this.stopTimer(),this.stopWatchTimer(),this.stopPermissionTime(),this.baseInfo.webrtc&&this.sip&&this.sip.stop(),t.content&&(t.content.close(),t.content=null,this.telephone.reconnect=!1)}},{key:"sipEvent",value:function(){var e=this;this.sipEventBus.on("newRTCSession",(function(e){q.custom("telephone","newRTCSession","#E13164",e)})),this.sipEventBus.on("peerconnection",(function(e){q.custom("telephone","peerconnection","#E13164",e)})),this.sipEventBus.on("progress",(function(e){q.custom("telephone","progress","#E13164",e)})),this.sipEventBus.on("failed",(function(e){q.custom("telephone","failed","#E13164",e)})),this.sipEventBus.on("ended",(function(e){q.custom("telephone","ended","#E13164",e)})),this.sipEventBus.on("registrationFailed",(function(t){q.custom("telephone","registrationFailed","#E13164",t),"Logout"!==e.telephone.type&&(e.telephone.type="Logout",e.telephone.reconnect=!1,e.onclose({code:203,message:"WebRTC注册失败"}),e.stop())})),this.sipEventBus.on("disconnected",(function(t){q.custom("telephone","disconnected","#E13164",t),"Logout"===e.telephone.type?e.onclose():e.eventBus.emit("onclose",{code:202,message:"WebRTC连接断开,正在重连"})})),this.sipEventBus.on("answerSession",(function(t){q.error("telephone","error",t),e.eventBus.emit("error",t)})),this.sipEventBus.on("registered",(function(t){q.custom("telephone","registered","#E13164",t),"Login"!==e.telephone.type&&e.checkin("jssip"),e.onopen("jssip")}))}},{key:"onopen",value:function(e){var n,r=N.getContent();q.info("telephone","onopen",{source:e,webrtc:this.baseInfo.webrtc,readyState:null==t||null===(n=t.content)||void 0===n?void 0:n.readyState,jssip:r,isRegistered:null==r?void 0:r.isRegistered(),isConnected:null==r?void 0:r.isConnected()});var o=200,i="连接成功";"Login"===this.telephone.type?o=202:this.telephone.networkDisconnected&&(o=201,this.telephone.networkDisconnected=!1),this.baseInfo.webrtc?t.content.readyState===WebSocket.OPEN&&r&&r.isRegistered()&&r.isConnected()&&this.eventBus.emit("onopen",{code:o,message:i}):this.eventBus.emit("onopen",{code:o,message:i})}},{key:"onclose",value:function(e){var n=this;if(e)o(e);else if("Logout"===n.telephone.type)if(this.baseInfo.webrtc){var r=N.getContent();if(r){r.isConnected();t.content||r.isConnected()||o({code:200,message:"连接关闭"})}}else o({code:200,message:"连接关闭"});else o({code:201,message:"连接关闭"});function o(e){n.eventBus.emit("onclose",{code:e.code,message:e.message}),200!==e.code&&203!==e.code||n.eventBus.destroyEvents()}}},{key:"initEvent",value:function(){this.eventBus=_.getEventBus()}},{key:"initJssip",value:function(){this.sip=new N,this.sipEventBus=N.getEventBus(),this.sipEvent()}},{key:"init",value:function(){try{if(t.content&&t.content.readyState===WebSocket.OPEN)return void this.checkin("socket");for(var e=this,n=0,r=["webrtc","token","agent","account","socket"];n<r.length;n++){var o=r[n];if(void 0===e.baseInfo[o])return void console.error("".concat(o," is required"))}t.content=new WebSocket(e.baseInfo.socket+"/v1/cc/socket?access_token="+e.baseInfo.token),t.content.onopen=function(){q.success("telephone","WebSocket连接成功"),e.telephone.clientTime=Math.floor(Date.now()/1e3),e.onopen("socket"),e.eventBus.emit("onlinetime","00:00:00"),e.startTimer(),e.startWatchTimer(),e.baseInfo.webrtc&&e.startPermissionTime(),e.baseInfo.webrtc?e.webrtcInfo():e.checkin("socket"),e.sendMessage({type:"Time",data:{}})},t.content.onclose=function(t){q.warning("telephone","onclose",t),e.onclose(),e.stopTimer(),e.stopWatchTimer(),e.reconnect(),e.eventBus.emit("onlinetime","00:00:00"),e.telephone.networkDisconnected=!0,e.telephone.type="Logout"},t.content.onerror=function(t){q.error("telephone","onerror",t),e.stopTimer(),e.stopWatchTimer(),e.eventBus.emit("onerror",t)},t.content.onmessage=function(t){if(t.data){var n=JSON.parse(t.data),r=n.type,o=n.code,i=n.data;switch(q.custom("telephone","收到数据","#409EFF",n),e.eventBus.emit("onmessage",n),r){case"WebrtcInfo":_.setBase({sip:{socket:i.url,account:i.account,password:i.password,domain:i.domain}}),e.checkin("socket");break;case"Login":e.telephone.type="Login",e.telephone.reconnect=!0,e.relayList();break;case"Logout":e.telephone.type="Logout",e.telephone.reconnect=!1,e.stop();break;case"Status":e.telephone.statusCode=i.status,e.telephone.statusTime=i.time;break;case"Time":e.telephone.serverTime=i,e.telephone.diff=e.telephone.serverTime-e.telephone.clientTime;break;case"Error":-1!==[902,11e3,11013,11032,11034,11030,11040,11041].indexOf(o)&&(e.telephone.type="Logout",e.telephone.reconnect=!1,e.stop())}}}}catch(e){console.log(e)}}},{key:"reconnect",value:function(){var e=this;e.telephone.reconnect&&setTimeout((function(){try{e.init()}catch(t){e.reconnect()}}),5e3)}},{key:"checkin",value:function(){var e,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",r=N.getContent();q.info("telephone","checkin",{source:n,webrtc:this.baseInfo.webrtc,readyState:null==t||null===(e=t.content)||void 0===e?void 0:e.readyState,jssip:r,isRegistered:null==r?void 0:r.isRegistered(),isConnected:null==r?void 0:r.isConnected()});var o=!1;this.baseInfo.webrtc?r&&r.isRegistered&&r.isRegistered()&&t.content.readyState===WebSocket.OPEN?o=!0:this.sip.init():o=!0,o&&"Login"!==this.telephone.type&&this.login()}},{key:"login",value:function(){var e=_.getBase();this.sendMessage({type:"Login",data:{agent:e.agent,account:e.account}})}},{key:"logout",value:function(){this.sendMessage({type:"Logout",data:{}})}},{key:"hangup",value:function(){this.sendMessage({type:"Hangup",data:{}})}},{key:"relayList",value:function(){this.sendMessage({type:"RelayList",data:{}})}},{key:"call",value:(a=z(V().mark((function e(t){var n,r;return V().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n={customer:t.customer,relayNumber:t.relayNumber,custom:t.custom,subscriber:t.subscriber},!this.baseInfo.webrtc){e.next=9;break}return e.next=4,this.checkMicrophoneStatus();case 4:if(200===(r=e.sent).code){e.next=9;break}return q.error("telephone","error",r),this.eventBus.emit("error",r),e.abrupt("return");case 9:this.sendMessage({type:"Call",data:n});case 10:case"end":return e.stop()}}),e,this)}))),function(e){return a.apply(this,arguments)})},{key:"keyup",value:function(e){this.sendMessage({type:"Keyup",data:{key:e}})}},{key:"status",value:function(e){this.sendMessage({type:"Status",data:{status:e}})}},{key:"regionInfo",value:function(e){this.sendMessage({type:"RegionInfo",data:{mobile:e}})}},{key:"mobileAnswer",value:function(e){this.sendMessage({type:"MobileAnswer",data:{status:e.status,relayNumber:e.relayNumber}})}},{key:"transferQueue",value:function(e){this.sendMessage({type:"Blind",data:{type:1,queueId:e}})}},{key:"transfer",value:function(e){this.sendMessage({type:"Blind",data:{type:0,customer:e.customer,relayNumber:e.relayNumber}})}},{key:"threeWayStart",value:function(e){this.sendMessage({type:"ThreeWayStart",data:{customer:e.customer,relayNumber:e.relayNumber}})}},{key:"threeWayCancel",value:function(){this.sendMessage({type:"ThreeWayCancel",data:{}})}},{key:"consultStart",value:function(e){this.sendMessage({type:"ConsultStart",data:{customer:e.customer,relayNumber:e.relayNumber}})}},{key:"consultCancel",value:function(){this.sendMessage({type:"ConsultCancel",data:{}})}},{key:"consultTransfer",value:function(){this.sendMessage({type:"ConsultTransfer",data:{}})}},{key:"hold",value:function(){this.sendMessage({type:"Hold",data:{status:1}})}},{key:"unhold",value:function(){this.sendMessage({type:"Hold",data:{status:0}})}},{key:"grade",value:function(){this.sendMessage({type:"Grade",data:{}})}},{key:"answer",value:function(){this.baseInfo.webrtc?this.sip.answer():this.sendMessage({type:"Answer",data:{}})}},{key:"webrtcInfo",value:function(){this.sendMessage({type:"WebrtcInfo",data:{agent:this.baseInfo.agent,account:this.baseInfo.account}})}},{key:"queueList",value:function(){this.sendMessage({type:"QueueList",data:{}})}},{key:"flowList",value:function(){this.sendMessage({type:"FlowList",data:{}})}},{key:"flow",value:function(e){this.sendMessage({type:"Flow",data:{flowId:e}})}},{key:"customHandle",value:function(e){this.sendMessage(e)}},{key:"sendMessage",value:function(e){t.content&&t.content.readyState===WebSocket.OPEN?(q.info("telephone","发送数据",e),t.content.send(JSON.stringify(e))):(q.error("telephone","error",{code:456,message:"Websocket未连接",data:""}),this.eventBus.emit("error",{code:456,message:"Websocket未连接",data:""}))}},{key:"getDefaultMedia",value:(s=z(V().mark((function e(){var t,n,r,o,i;return V().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.getMedia();case 2:if(t=e.sent,n=t.code,r=t.data,200!==n){e.next=14;break}if(o=r.audioinput.find((function(e){return"default"===e.deviceId})),i=r.audiooutput.find((function(e){return"default"===e.deviceId})),!o){e.next=11;break}return e.abrupt("return",{type:"DefaultMedia",code:200,data:{input:o,output:i}});case 11:return e.abrupt("return",{type:"DefaultMedia",code:101,data:{input:{deviceId:(null==o?void 0:o.deviceId)||"",label:(null==o?void 0:o.label)||"获取失败,麦克风未开启或未授权",groupId:(null==o?void 0:o.groupId)||"",kind:(null==o?void 0:o.kind)||""},output:{deviceId:(null==i?void 0:i.deviceId)||"",label:(null==i?void 0:i.label)||"获取失败,麦克风未开启或未授权",groupId:(null==i?void 0:i.groupId)||"",kind:(null==i?void 0:i.kind)||""}}});case 12:e.next=15;break;case 14:return e.abrupt("return",t);case 15:case"end":return e.stop()}}),e,this)}))),function(){return s.apply(this,arguments)})},{key:"getMedia",value:(i=z(V().mark((function e(){var t,n,r;return V().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,navigator.mediaDevices.enumerateDevices();case 3:return t=e.sent,n=t.filter((function(e){return"audioinput"===e.kind})),r=t.filter((function(e){return"audiooutput"===e.kind})),e.abrupt("return",{type:"Media",code:200,data:{audioinput:n,audiooutput:r}});case 9:return e.prev=9,e.t0=e.catch(0),e.abrupt("return",{type:"Media",code:105,message:"获取麦克风权限失败",data:{input:{deviceId:"",label:"获取失败,麦克风未开启或未授权",groupId:"",kind:""},output:{deviceId:"",label:"获取失败,麦克风未开启或未授权",groupId:"",kind:""}}});case 12:case"end":return e.stop()}}),e,null,[[0,9]])}))),function(){return i.apply(this,arguments)})},{key:"checkMicrophoneStatus",value:(o=z(V().mark((function e(){var t,n;return V().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,navigator.mediaDevices.enumerateDevices();case 3:if(t=e.sent,0!==(n=t.filter((function(e){return"audioinput"===e.kind}))).length){e.next=7;break}return e.abrupt("return",{type:"CheckMicrophoneStatus",code:101,message:"没有找到麦克风设备"});case 7:if(!n.some((function(e){return""!==e.label}))){e.next=12;break}return e.abrupt("return",{type:"CheckMicrophoneStatus",code:200,message:"麦克风已开启"});case 12:return e.abrupt("return",{type:"CheckMicrophoneStatus",code:101,message:"麦克风未开启或未授权"});case 13:e.next=18;break;case 15:return e.prev=15,e.t0=e.catch(0),e.abrupt("return",{type:"CheckMicrophoneStatus",code:101,message:"获取设备信息时出错"});case 18:case"end":return e.stop()}}),e,null,[[0,15]])}))),function(){return o.apply(this,arguments)})},{key:"getPhoneInfo",value:(r=z(V().mark((function e(){return V().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",{type:this.telephone.type,webrtc:this.baseInfo.webrtc,account:this.baseInfo.account,agent:this.baseInfo.agent,socket:this.baseInfo.socket,token:this.baseInfo.token});case 1:case"end":return e.stop()}}),e,this)}))),function(){return r.apply(this,arguments)})},{key:"getSystemInfo",value:(n=z(V().mark((function e(){var t,n,r,o,i,s,a;return V().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t={name:"",version:""},(n=navigator.userAgent).indexOf("Chrome")>-1?(t.name="Chrome",r=n.match(/Chrome\/(\d+\.\d+)/),t.version=r?r[1]:""):n.indexOf("Firefox")>-1?(t.name="Firefox",o=n.match(/Firefox\/(\d+\.\d+)/),t.version=o?o[1]:""):n.indexOf("Safari")>-1?(t.name="Safari",i=n.match(/Version\/(\d+\.\d+)/),t.version=i?i[1]:""):n.indexOf("Edge")>-1?(t.name="Edge",s=n.match(/Edge\/(\d+\.\d+)/),t.version=s?s[1]:""):n.indexOf("Edg")>-1&&(t.name="Edge",a=n.match(/Edg\/(\d+\.\d+)/),t.version=a?a[1]:""),e.abrupt("return",{type:"SystemInfo",code:200,data:{browser:t,support:{webrtc:!!(window.RTCPeerConnection||window.webkitRTCPeerConnection||window.mozRTCPeerConnection),websocket:"WebSocket"in window}}});case 4:case"end":return e.stop()}}),e)}))),function(){return n.apply(this,arguments)})},{key:"startPermissionTime",value:function(){var e=this;this.permissionTimer=new B,this.permissionTimer.setOnUpdate(z(V().mark((function t(){return V().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,e.checkMicrophoneStatus();case 2:200===t.sent.code?e.eventBus.emit("onpermission",{microphone:!0}):e.eventBus.emit("onpermission",{microphone:!1});case 4:case"end":return t.stop()}}),t)})))),this.permissionTimer.start()}}]);var n,r,o,i,s,a}(_);function te(e){return te="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},te(e)}function ne(e,t,n){return(t=ae(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function re(){re=function(){return t};var e,t={},n=Object.prototype,r=n.hasOwnProperty,o=Object.defineProperty||function(e,t,n){e[t]=n.value},i="function"==typeof Symbol?Symbol:{},s=i.iterator||"@@iterator",a=i.asyncIterator||"@@asyncIterator",u=i.toStringTag||"@@toStringTag";function l(e,t,n){return Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{l({},"")}catch(e){l=function(e,t,n){return e[t]=n}}function c(e,t,n,r){var i=t&&t.prototype instanceof m?t:m,s=Object.create(i.prototype),a=new k(r||[]);return o(s,"_invoke",{value:A(e,n,a)}),s}function f(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(e){return{type:"throw",arg:e}}}t.wrap=c;var h="suspendedStart",d="suspendedYield",p="executing",_="completed",v={};function m(){}function y(){}function g(){}var b={};l(b,s,(function(){return this}));var T=Object.getPrototypeOf,w=T&&T(T(x([])));w&&w!==n&&r.call(w,s)&&(b=w);var S=g.prototype=m.prototype=Object.create(b);function E(e){["next","throw","return"].forEach((function(t){l(e,t,(function(e){return this._invoke(t,e)}))}))}function C(e,t){function n(o,i,s,a){var u=f(e[o],e,i);if("throw"!==u.type){var l=u.arg,c=l.value;return c&&"object"==te(c)&&r.call(c,"__await")?t.resolve(c.__await).then((function(e){n("next",e,s,a)}),(function(e){n("throw",e,s,a)})):t.resolve(c).then((function(e){l.value=e,s(l)}),(function(e){return n("throw",e,s,a)}))}a(u.arg)}var i;o(this,"_invoke",{value:function(e,r){function o(){return new t((function(t,o){n(e,r,t,o)}))}return i=i?i.then(o,o):o()}})}function A(t,n,r){var o=h;return function(i,s){if(o===p)throw Error("Generator is already running");if(o===_){if("throw"===i)throw s;return{value:e,done:!0}}for(r.method=i,r.arg=s;;){var a=r.delegate;if(a){var u=R(a,r);if(u){if(u===v)continue;return u}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if(o===h)throw o=_,r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);o=p;var l=f(t,n,r);if("normal"===l.type){if(o=r.done?_:d,l.arg===v)continue;return{value:l.arg,done:r.done}}"throw"===l.type&&(o=_,r.method="throw",r.arg=l.arg)}}}function R(t,n){var r=n.method,o=t.iterator[r];if(o===e)return n.delegate=null,"throw"===r&&t.iterator.return&&(n.method="return",n.arg=e,R(t,n),"throw"===n.method)||"return"!==r&&(n.method="throw",n.arg=new TypeError("The iterator does not provide a '"+r+"' method")),v;var i=f(o,t.iterator,n.arg);if("throw"===i.type)return n.method="throw",n.arg=i.arg,n.delegate=null,v;var s=i.arg;return s?s.done?(n[t.resultName]=s.value,n.next=t.nextLoc,"return"!==n.method&&(n.method="next",n.arg=e),n.delegate=null,v):s:(n.method="throw",n.arg=new TypeError("iterator result is not an object"),n.delegate=null,v)}function I(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function O(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function k(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(I,this),this.reset(!0)}function x(t){if(t||""===t){var n=t[s];if(n)return n.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var o=-1,i=function n(){for(;++o<t.length;)if(r.call(t,o))return n.value=t[o],n.done=!1,n;return n.value=e,n.done=!0,n};return i.next=i}}throw new TypeError(te(t)+" is not iterable")}return y.prototype=g,o(S,"constructor",{value:g,configurable:!0}),o(g,"constructor",{value:y,configurable:!0}),y.displayName=l(g,u,"GeneratorFunction"),t.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===y||"GeneratorFunction"===(t.displayName||t.name))},t.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,g):(e.__proto__=g,l(e,u,"GeneratorFunction")),e.prototype=Object.create(S),e},t.awrap=function(e){return{__await:e}},E(C.prototype),l(C.prototype,a,(function(){return this})),t.AsyncIterator=C,t.async=function(e,n,r,o,i){void 0===i&&(i=Promise);var s=new C(c(e,n,r,o),i);return t.isGeneratorFunction(n)?s:s.next().then((function(e){return e.done?e.value:s.next()}))},E(S),l(S,u,"Generator"),l(S,s,(function(){return this})),l(S,"toString",(function(){return"[object Generator]"})),t.keys=function(e){var t=Object(e),n=[];for(var r in t)n.push(r);return n.reverse(),function e(){for(;n.length;){var r=n.pop();if(r in t)return e.value=r,e.done=!1,e}return e.done=!0,e}},t.values=x,k.prototype={constructor:k,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=e,this.done=!1,this.delegate=null,this.method="next",this.arg=e,this.tryEntries.forEach(O),!t)for(var n in this)"t"===n.charAt(0)&&r.call(this,n)&&!isNaN(+n.slice(1))&&(this[n]=e)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var n=this;function o(r,o){return a.type="throw",a.arg=t,n.next=r,o&&(n.method="next",n.arg=e),!!o}for(var i=this.tryEntries.length-1;i>=0;--i){var s=this.tryEntries[i],a=s.completion;if("root"===s.tryLoc)return o("end");if(s.tryLoc<=this.prev){var u=r.call(s,"catchLoc"),l=r.call(s,"finallyLoc");if(u&&l){if(this.prev<s.catchLoc)return o(s.catchLoc,!0);if(this.prev<s.finallyLoc)return o(s.finallyLoc)}else if(u){if(this.prev<s.catchLoc)return o(s.catchLoc,!0)}else{if(!l)throw Error("try statement without catch or finally");if(this.prev<s.finallyLoc)return o(s.finallyLoc)}}}},abrupt:function(e,t){for(var n=this.tryEntries.length-1;n>=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var i=o;break}}i&&("break"===e||"continue"===e)&&i.tryLoc<=t&&t<=i.finallyLoc&&(i=null);var s=i?i.completion:{};return s.type=e,s.arg=t,i?(this.method="next",this.next=i.finallyLoc,v):this.complete(s)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),v},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),O(n),v}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var r=n.completion;if("throw"===r.type){var o=r.arg;O(n)}return o}}throw Error("illegal catch attempt")},delegateYield:function(t,n,r){return this.delegate={iterator:x(t),resultName:n,nextLoc:r},"next"===this.method&&(this.arg=e),v}},t}function oe(e,t,n,r,o,i,s){try{var a=e[i](s),u=a.value}catch(e){return void n(e)}a.done?t(u):Promise.resolve(u).then(r,o)}function ie(e){return function(){var t=this,n=arguments;return new Promise((function(r,o){var i=e.apply(t,n);function s(e){oe(i,r,o,s,a,"next",e)}function a(e){oe(i,r,o,s,a,"throw",e)}s(void 0)}))}}function se(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,ae(r.key),r)}}function ae(e){var t=function(e,t){if("object"!=te(e)||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!=te(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==te(t)?t:t+""}function ue(e,t){if(t&&("object"==te(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}function le(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return(le=function(){return!!e})()}function ce(e){return ce=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},ce(e)}function fe(e,t){return fe=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},fe(e,t)}function he(e,t,n){(function(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")})(e,t),t.set(e,n)}function de(e,t,n){return e.set(_e(e,t),n),n}function pe(e,t){return e.get(_e(e,t))}function _e(e,t,n){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:n;throw new TypeError("Private element is not present on this object")}!function(e,t,n){(t=Z(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n}(ee,"content",null);var ve=new WeakMap,me=new WeakMap,ye=function(e){function t(e){var n,r;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),n=function(e,t,n){return t=ce(t),ue(e,le()?Reflect.construct(t,n||[],ce(e).constructor):t.apply(e,n))}(this,t),he(n,ve,void 0),he(n,me,void 0),navigator.permissions.query({name:"microphone"}).then(function(){var e=ie(re().mark((function e(t){return re().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if("prompt"!==t.state){e.next=5;break}return e.next=3,navigator.mediaDevices.getUserMedia({audio:{noiseSuppression:!0,echoCancellation:!0,autoGainControl:!0,sampleRate:48e3},video:!1});case 3:e.sent.getTracks().forEach((function(e){return e.stop()}));case 5:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}()),de(ve,n,_.getEventBus()),_.setBase(e),de(me,n,new ee),n.agent=ne(ne(ne(ne(ne({start:function(){pe(me,n).init()},logout:function(){pe(me,n).logout()},hangup:function(){pe(me,n).hangup()},relayList:function(){pe(me,n).relayList()},answer:function(){pe(me,n).answer()},call:function(e){pe(me,n).call(e)},keyup:function(e){pe(me,n).keyup(e)},status:function(e){pe(me,n).status(e)},regionInfo:function(e){pe(me,n).regionInfo(e)},mobileAnswer:function(e){pe(me,n).mobileAnswer(e)},transferQueue:function(e){pe(me,n).transferQueue(e)},transfer:function(e){pe(me,n).transfer(e)},threeWayStart:function(e){pe(me,n).threeWayStart(e)},threeWayCancel:function(){pe(me,n).threeWayCancel()},consultStart:function(e){pe(me,n).consultStart(e)},consultCancel:function(){pe(me,n).consultCancel()},consultTransfer:function(){pe(me,n).consultTransfer()},hold:function(){pe(me,n).hold()},unhold:function(){pe(me,n).unhold()},grade:function(){pe(me,n).grade()},queueList:function(){pe(me,n).queueList()}},"status",(function(e){pe(me,n).status(e)})),"getPhoneInfo",(function(){return pe(me,n).getPhoneInfo()})),"flowList",(function(){pe(me,n).flowList()})),"flow",(function(e){pe(me,n).flow(e)})),"close",(function(){pe(me,n).stop()})),n.tool={getMedia:function(){return pe(me,n).getMedia()},getDefaultMedia:function(){return pe(me,n).getDefaultMedia()},checkMicrophoneStatus:function(){return pe(me,n).checkMicrophoneStatus()},getSystemInfo:function(){return pe(me,n).getSystemInfo()},setAiDenoise:(r=ie(re().mark((function e(t){var r;return re().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(_.setBase({aiDenoise:!!t}),!(r=!!t)){e.next=6;break}return e.next=5,N.preloadWasm();case 5:r=e.sent;case 6:pe(ve,n).emit("onaidenoise",{status:r});case 7:case"end":return e.stop()}}),e)}))),function(e){return r.apply(this,arguments)})},n.custom={handle:function(e){pe(me,n).customHandle(e)}};for(var o=0,i=["webrtc","token","agent","account","socket"];o<i.length;o++){var s=i[o];if(void 0===e[s])return console.error("".concat(s," is required")),ue(n)}return n}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&fe(e,t)}(t,e),function(e,t,n){return t&&se(e.prototype,t),n&&se(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}(t,[{key:"on",value:function(e,t){pe(ve,this).on(e,t)}},{key:"onopen",value:function(e){pe(ve,this).on("onopen",e)}},{key:"onmessage",value:function(e){pe(ve,this).on("onmessage",e)}},{key:"onclose",value:function(e){pe(ve,this).on("onclose",e)}},{key:"onerror",value:function(e){pe(ve,this).on("onerror",e)}},{key:"onlinetime",value:function(e){pe(ve,this).on("onlinetime",e)}},{key:"onaidenoise",value:function(e){pe(ve,this).on("onaidenoise",e)}},{key:"onpermission",value:function(e){pe(ve,this).on("onpermission",e)}},{key:"error",value:function(e){pe(ve,this).on("error",e)}}])}(_)})(),r=r.default})()));