Fork of FusionPBX but with LDAP kinda working
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

1 lines
320 KiB

!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.SIP=t():e.SIP=t()}(this,(function(){return function(e){var t={};function r(i){if(t[i])return t[i].exports;var n=t[i]={i:i,l:!1,exports:{}};return e[i].call(n.exports,n,n.exports,r),n.l=!0,n.exports}return r.m=e,r.c=t,r.d=function(e,t,i){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:i})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var i=Object.create(null);if(r.r(i),Object.defineProperty(i,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var n in e)r.d(i,n,function(t){return e[t]}.bind(null,n));return i},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=109)}([function(e,t,r){"use strict";r.r(t),r.d(t,"__extends",(function(){return n})),r.d(t,"__assign",(function(){return s})),r.d(t,"__rest",(function(){return o})),r.d(t,"__decorate",(function(){return a})),r.d(t,"__param",(function(){return c})),r.d(t,"__metadata",(function(){return u})),r.d(t,"__awaiter",(function(){return d})),r.d(t,"__generator",(function(){return p})),r.d(t,"__exportStar",(function(){return l})),r.d(t,"__values",(function(){return h})),r.d(t,"__read",(function(){return g})),r.d(t,"__spread",(function(){return f})),r.d(t,"__spreadArrays",(function(){return m})),r.d(t,"__await",(function(){return v})),r.d(t,"__asyncGenerator",(function(){return S})),r.d(t,"__asyncDelegator",(function(){return T})),r.d(t,"__asyncValues",(function(){return y})),r.d(t,"__makeTemplateObject",(function(){return E})),r.d(t,"__importStar",(function(){return b})),r.d(t,"__importDefault",(function(){return C}));var i=function(e,t){return(i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)};function n(e,t){function r(){this.constructor=e}i(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}var s=function(){return(s=Object.assign||function(e){for(var t,r=1,i=arguments.length;r<i;r++)for(var n in t=arguments[r])Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e}).apply(this,arguments)};function o(e,t){var r={};for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&t.indexOf(i)<0&&(r[i]=e[i]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var n=0;for(i=Object.getOwnPropertySymbols(e);n<i.length;n++)t.indexOf(i[n])<0&&Object.prototype.propertyIsEnumerable.call(e,i[n])&&(r[i[n]]=e[i[n]])}return r}function a(e,t,r,i){var n,s=arguments.length,o=s<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,r):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(e,t,r,i);else for(var a=e.length-1;a>=0;a--)(n=e[a])&&(o=(s<3?n(o):s>3?n(t,r,o):n(t,r))||o);return s>3&&o&&Object.defineProperty(t,r,o),o}function c(e,t){return function(r,i){t(r,i,e)}}function u(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)}function d(e,t,r,i){return new(r||(r=Promise))((function(n,s){function o(e){try{c(i.next(e))}catch(e){s(e)}}function a(e){try{c(i.throw(e))}catch(e){s(e)}}function c(e){e.done?n(e.value):new r((function(t){t(e.value)})).then(o,a)}c((i=i.apply(e,t||[])).next())}))}function p(e,t){var r,i,n,s,o={label:0,sent:function(){if(1&n[0])throw n[1];return n[1]},trys:[],ops:[]};return s={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function a(s){return function(a){return function(s){if(r)throw new TypeError("Generator is already executing.");for(;o;)try{if(r=1,i&&(n=2&s[0]?i.return:s[0]?i.throw||((n=i.return)&&n.call(i),0):i.next)&&!(n=n.call(i,s[1])).done)return n;switch(i=0,n&&(s=[2&s[0],n.value]),s[0]){case 0:case 1:n=s;break;case 4:return o.label++,{value:s[1],done:!1};case 5:o.label++,i=s[1],s=[0];continue;case 7:s=o.ops.pop(),o.trys.pop();continue;default:if(!(n=(n=o.trys).length>0&&n[n.length-1])&&(6===s[0]||2===s[0])){o=0;continue}if(3===s[0]&&(!n||s[1]>n[0]&&s[1]<n[3])){o.label=s[1];break}if(6===s[0]&&o.label<n[1]){o.label=n[1],n=s;break}if(n&&o.label<n[2]){o.label=n[2],o.ops.push(s);break}n[2]&&o.ops.pop(),o.trys.pop();continue}s=t.call(e,o)}catch(e){s=[6,e],i=0}finally{r=n=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,a])}}}function l(e,t){for(var r in e)t.hasOwnProperty(r)||(t[r]=e[r])}function h(e){var t="function"==typeof Symbol&&e[Symbol.iterator],r=0;return t?t.call(e):{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}}}function g(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var i,n,s=r.call(e),o=[];try{for(;(void 0===t||t-- >0)&&!(i=s.next()).done;)o.push(i.value)}catch(e){n={error:e}}finally{try{i&&!i.done&&(r=s.return)&&r.call(s)}finally{if(n)throw n.error}}return o}function f(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(g(arguments[t]));return e}function m(){for(var e=0,t=0,r=arguments.length;t<r;t++)e+=arguments[t].length;var i=Array(e),n=0;for(t=0;t<r;t++)for(var s=arguments[t],o=0,a=s.length;o<a;o++,n++)i[n]=s[o];return i}function v(e){return this instanceof v?(this.v=e,this):new v(e)}function S(e,t,r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var i,n=r.apply(e,t||[]),s=[];return i={},o("next"),o("throw"),o("return"),i[Symbol.asyncIterator]=function(){return this},i;function o(e){n[e]&&(i[e]=function(t){return new Promise((function(r,i){s.push([e,t,r,i])>1||a(e,t)}))})}function a(e,t){try{(r=n[e](t)).value instanceof v?Promise.resolve(r.value.v).then(c,u):d(s[0][2],r)}catch(e){d(s[0][3],e)}var r}function c(e){a("next",e)}function u(e){a("throw",e)}function d(e,t){e(t),s.shift(),s.length&&a(s[0][0],s[0][1])}}function T(e){var t,r;return t={},i("next"),i("throw",(function(e){throw e})),i("return"),t[Symbol.iterator]=function(){return this},t;function i(i,n){t[i]=e[i]?function(t){return(r=!r)?{value:v(e[i](t)),done:"return"===i}:n?n(t):t}:n}}function y(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t,r=e[Symbol.asyncIterator];return r?r.call(e):(e=h(e),t={},i("next"),i("throw"),i("return"),t[Symbol.asyncIterator]=function(){return this},t);function i(r){t[r]=e[r]&&function(t){return new Promise((function(i,n){(function(e,t,r,i){Promise.resolve(i).then((function(t){e({value:t,done:r})}),t)})(i,n,(t=e[r](t)).done,t.value)}))}}}function E(e,t){return Object.defineProperty?Object.defineProperty(e,"raw",{value:t}):e.raw=t,e}function b(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t}function C(e){return e&&e.__esModule?e:{default:e}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=r(0);i.__exportStar(r(22),t),i.__exportStar(r(35),t),i.__exportStar(r(67),t),i.__exportStar(r(68),t),i.__exportStar(r(69),t),i.__exportStar(r(35),t),i.__exportStar(r(25),t),i.__exportStar(r(13),t),i.__exportStar(r(23),t)},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=r(0);i.__exportStar(r(55),t),i.__exportStar(r(57),t),i.__exportStar(r(59),t),i.__exportStar(r(29),t),i.__exportStar(r(19),t),i.__exportStar(r(32),t),i.__exportStar(r(33),t),i.__exportStar(r(20),t),i.__exportStar(r(34),t),i.__exportStar(r(62),t),i.__exportStar(r(21),t),i.__exportStar(r(30),t)},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=r(2),n=r(1),s=function(){function e(e,t,r,i){this.transactionConstructor=e,this.core=t,this.message=r,this.delegate=i,this.challenged=!1,this.stale=!1,this.logger=this.loggerFactory.getLogger("sip.user-agent-client"),this.init()}return e.prototype.dispose=function(){this.transaction.dispose()},Object.defineProperty(e.prototype,"loggerFactory",{get:function(){return this.core.loggerFactory},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"transaction",{get:function(){if(!this._transaction)throw new Error("Transaction undefined.");return this._transaction},enumerable:!0,configurable:!0}),e.prototype.cancel=function(t,r){var s=this;if(void 0===r&&(r={}),!this.transaction)throw new Error("Transaction undefined.");if(!this.message.to)throw new Error("To undefined.");if(!this.message.from)throw new Error("From undefined.");var o=this.core.makeOutgoingRequestMessage(i.C.CANCEL,this.message.ruri,this.message.from.uri,this.message.to.uri,{toTag:this.message.toTag,fromTag:this.message.fromTag,callId:this.message.callId,cseq:this.message.cseq},r.extraHeaders);if(o.branch=this.message.branch,this.message.headers.Route&&(o.headers.Route=this.message.headers.Route),t&&o.setHeader("Reason",t),this.transaction.state===n.TransactionState.Proceeding)new e(n.NonInviteClientTransaction,this.core,o);else this.transaction.once("stateChanged",(function(){if(s.transaction&&s.transaction.state===n.TransactionState.Proceeding)new e(n.NonInviteClientTransaction,s.core,o)}));return o},e.prototype.authenticationGuard=function(e){var t,r,i=e.statusCode;if(!i)throw new Error("Response status code undefined.");if(401!==i&&407!==i)return!0;if(401===i?(t=e.parseHeader("www-authenticate"),r="authorization"):(t=e.parseHeader("proxy-authenticate"),r="proxy-authorization"),!t)return this.logger.warn(i+" with wrong or missing challenge, cannot authenticate"),!0;if(this.challenged&&(this.stale||!0!==t.stale))return this.logger.warn(i+" apparently in authentication loop, cannot authenticate"),!0;if(!this.credentials&&(this.credentials=this.core.configuration.authenticationFactory(),!this.credentials))return this.logger.warn("Unable to obtain credentials, cannot authenticate"),!0;if(!this.credentials.authenticate(this.message,t))return!0;this.challenged=!0,t.stale&&(this.stale=!0);var n=this.message.cseq+=1;return this.message.setHeader("cseq",n+" "+this.message.method),this.message.setHeader(r,this.credentials.toString()),this.init(),!1},e.prototype.onRequestTimeout=function(){this.logger.warn("User agent client request timed out. Generating internal 408 Request Timeout.");var e=new i.IncomingResponseMessage;e.statusCode=408,e.reasonPhrase="Request Timeout",this.receiveResponse(e)},e.prototype.onTransportError=function(e){this.logger.error(e.message),this.logger.error("User agent client request transport error. Generating internal 503 Service Unavailable.");var t=new i.IncomingResponseMessage;t.statusCode=503,t.reasonPhrase="Service Unavailable",this.receiveResponse(t)},e.prototype.receiveResponse=function(e){if(this.authenticationGuard(e)){var t=e.statusCode?e.statusCode.toString():"";if(!t)throw new Error("Response status code undefined.");switch(!0){case/^100$/.test(t):this.delegate&&this.delegate.onTrying&&this.delegate.onTrying({message:e});break;case/^1[0-9]{2}$/.test(t):this.delegate&&this.delegate.onProgress&&this.delegate.onProgress({message:e});break;case/^2[0-9]{2}$/.test(t):this.delegate&&this.delegate.onAccept&&this.delegate.onAccept({message:e});break;case/^3[0-9]{2}$/.test(t):this.delegate&&this.delegate.onRedirect&&this.delegate.onRedirect({message:e});break;case/^[4-6][0-9]{2}$/.test(t):this.delegate&&this.delegate.onReject&&this.delegate.onReject({message:e});break;default:throw new Error("Invalid status code "+t)}}},e.prototype.init=function(){var e=this,t={loggerFactory:this.loggerFactory,onRequestTimeout:function(){return e.onRequestTimeout()},onStateChange:function(t){t===n.TransactionState.Terminated&&(e.core.userAgentClients.delete(i),r===e._transaction&&e.dispose())},onTransportError:function(t){return e.onTransportError(t)},receiveResponse:function(t){return e.receiveResponse(t)}},r=new this.transactionConstructor(this.message,this.core.transport,t);this._transaction=r;var i=r.id+r.request.method;this.core.userAgentClients.set(i,this)},e}();t.UserAgentClient=s},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=r(16),n=r(2),s=r(10),o=r(1),a=function(){function e(e,t,r,i){this.transactionConstructor=e,this.core=t,this.message=r,this.delegate=i,this.logger=this.loggerFactory.getLogger("sip.user-agent-server"),this.toTag=r.toTag?r.toTag:s.newTag(),this.init()}return e.prototype.dispose=function(){this.transaction.dispose()},Object.defineProperty(e.prototype,"loggerFactory",{get:function(){return this.core.loggerFactory},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"transaction",{get:function(){if(!this._transaction)throw new Error("Transaction undefined.");return this._transaction},enumerable:!0,configurable:!0}),e.prototype.accept=function(e){if(void 0===e&&(e={statusCode:200}),!this.acceptable)throw new i.TransactionStateError(this.message.method+" not acceptable in state "+this.transaction.state+".");var t=e.statusCode;if(t<200||t>299)throw new TypeError("Invalid statusCode: "+t);return this.reply(e)},e.prototype.progress=function(e){if(void 0===e&&(e={statusCode:180}),!this.progressable)throw new i.TransactionStateError(this.message.method+" not progressable in state "+this.transaction.state+".");var t=e.statusCode;if(t<101||t>199)throw new TypeError("Invalid statusCode: "+t);return this.reply(e)},e.prototype.redirect=function(e,t){if(void 0===t&&(t={statusCode:302}),!this.redirectable)throw new i.TransactionStateError(this.message.method+" not redirectable in state "+this.transaction.state+".");var r=t.statusCode;if(r<300||r>399)throw new TypeError("Invalid statusCode: "+r);var n=new Array;return e.forEach((function(e){return n.push("Contact: "+e.toString())})),t.extraHeaders=(t.extraHeaders||[]).concat(n),this.reply(t)},e.prototype.reject=function(e){if(void 0===e&&(e={statusCode:480}),!this.rejectable)throw new i.TransactionStateError(this.message.method+" not rejectable in state "+this.transaction.state+".");var t=e.statusCode;if(t<400||t>699)throw new TypeError("Invalid statusCode: "+t);return this.reply(e)},e.prototype.trying=function(e){if(!this.tryingable)throw new i.TransactionStateError(this.message.method+" not tryingable in state "+this.transaction.state+".");return this.reply({statusCode:100})},e.prototype.receiveCancel=function(e){this.delegate&&this.delegate.onCancel&&this.delegate.onCancel(e)},Object.defineProperty(e.prototype,"acceptable",{get:function(){if(this.transaction instanceof o.InviteServerTransaction)return this.transaction.state===o.TransactionState.Proceeding||this.transaction.state===o.TransactionState.Accepted;if(this.transaction instanceof o.NonInviteServerTransaction)return this.transaction.state===o.TransactionState.Trying||this.transaction.state===o.TransactionState.Proceeding;throw new Error("Unknown transaction type.")},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"progressable",{get:function(){if(this.transaction instanceof o.InviteServerTransaction)return this.transaction.state===o.TransactionState.Proceeding;if(this.transaction instanceof o.NonInviteServerTransaction)return!1;throw new Error("Unknown transaction type.")},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"redirectable",{get:function(){if(this.transaction instanceof o.InviteServerTransaction)return this.transaction.state===o.TransactionState.Proceeding;if(this.transaction instanceof o.NonInviteServerTransaction)return this.transaction.state===o.TransactionState.Trying||this.transaction.state===o.TransactionState.Proceeding;throw new Error("Unknown transaction type.")},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"rejectable",{get:function(){if(this.transaction instanceof o.InviteServerTransaction)return this.transaction.state===o.TransactionState.Proceeding;if(this.transaction instanceof o.NonInviteServerTransaction)return this.transaction.state===o.TransactionState.Trying||this.transaction.state===o.TransactionState.Proceeding;throw new Error("Unknown transaction type.")},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"tryingable",{get:function(){if(this.transaction instanceof o.InviteServerTransaction)return this.transaction.state===o.TransactionState.Proceeding;if(this.transaction instanceof o.NonInviteServerTransaction)return this.transaction.state===o.TransactionState.Trying;throw new Error("Unknown transaction type.")},enumerable:!0,configurable:!0}),e.prototype.reply=function(e){e.toTag||100===e.statusCode||(e.toTag=this.toTag),e.userAgent=e.userAgent||this.core.configuration.userAgentHeaderFieldValue,e.supported=e.supported||this.core.configuration.supportedOptionTagsResponse;var t=n.constructOutgoingResponse(this.message,e);return this.transaction.receiveResponse(e.statusCode,t.message),t},e.prototype.init=function(){var e=this,t={loggerFactory:this.loggerFactory,onStateChange:function(t){t===o.TransactionState.Terminated&&(e.core.userAgentServers.delete(i),e.dispose())},onTransportError:function(t){e.logger.error(t.message),e.delegate&&e.delegate.onTransportError?e.delegate.onTransportError(t):e.logger.error("User agent server response transport error.")}},r=new this.transactionConstructor(this.message,this.core.transport,t);this._transaction=r;var i=r.id;this.core.userAgentServers.set(r.id,this)},e}();t.UserAgentServer=a},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=r(0);i.__exportStar(r(17),t),i.__exportStar(r(16),t),i.__exportStar(r(71),t),i.__exportStar(r(2),t),i.__exportStar(r(15),t),i.__exportStar(r(27),t),i.__exportStar(r(1),t),i.__exportStar(r(73),t),i.__exportStar(r(50),t),i.__exportStar(r(6),t),i.__exportStar(r(86),t)},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=500;t.Timers={T1:i,T2:4e3,T4:5e3,TIMER_B:32e3,TIMER_D:0,TIMER_F:32e3,TIMER_H:32e3,TIMER_I:0,TIMER_J:0,TIMER_K:0,TIMER_L:32e3,TIMER_M:32e3,TIMER_N:32e3,PROVISIONAL_RESPONSE_INTERVAL:6e4}},function(e,t,r){"use strict";var i,n="object"==typeof Reflect?Reflect:null,s=n&&"function"==typeof n.apply?n.apply:function(e,t,r){return Function.prototype.apply.call(e,t,r)};i=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 a(){a.init.call(this)}e.exports=a,a.EventEmitter=a,a.prototype._events=void 0,a.prototype._eventsCount=0,a.prototype._maxListeners=void 0;var c=10;function u(e){return void 0===e._maxListeners?a.defaultMaxListeners:e._maxListeners}function d(e,t,r,i){var n,s,o,a;if("function"!=typeof r)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof r);if(void 0===(s=e._events)?(s=e._events=Object.create(null),e._eventsCount=0):(void 0!==s.newListener&&(e.emit("newListener",t,r.listener?r.listener:r),s=e._events),o=s[t]),void 0===o)o=s[t]=r,++e._eventsCount;else if("function"==typeof o?o=s[t]=i?[r,o]:[o,r]:i?o.unshift(r):o.push(r),(n=u(e))>0&&o.length>n&&!o.warned){o.warned=!0;var c=new Error("Possible EventEmitter memory leak detected. "+o.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");c.name="MaxListenersExceededWarning",c.emitter=e,c.type=t,c.count=o.length,a=c,console&&console.warn&&console.warn(a)}return e}function p(){for(var e=[],t=0;t<arguments.length;t++)e.push(arguments[t]);this.fired||(this.target.removeListener(this.type,this.wrapFn),this.fired=!0,s(this.listener,this.target,e))}function l(e,t,r){var i={fired:!1,wrapFn:void 0,target:e,type:t,listener:r},n=p.bind(i);return n.listener=r,i.wrapFn=n,n}function h(e,t,r){var i=e._events;if(void 0===i)return[];var n=i[t];return void 0===n?[]:"function"==typeof n?r?[n.listener||n]:[n]:r?function(e){for(var t=new Array(e.length),r=0;r<t.length;++r)t[r]=e[r].listener||e[r];return t}(n):f(n,n.length)}function g(e){var t=this._events;if(void 0!==t){var r=t[e];if("function"==typeof r)return 1;if(void 0!==r)return r.length}return 0}function f(e,t){for(var r=new Array(t),i=0;i<t;++i)r[i]=e[i];return r}Object.defineProperty(a,"defaultMaxListeners",{enumerable:!0,get:function(){return c},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+".");c=e}}),a.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},a.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},a.prototype.getMaxListeners=function(){return u(this)},a.prototype.emit=function(e){for(var t=[],r=1;r<arguments.length;r++)t.push(arguments[r]);var i="error"===e,n=this._events;if(void 0!==n)i=i&&void 0===n.error;else if(!i)return!1;if(i){var o;if(t.length>0&&(o=t[0]),o instanceof Error)throw o;var a=new Error("Unhandled error."+(o?" ("+o.message+")":""));throw a.context=o,a}var c=n[e];if(void 0===c)return!1;if("function"==typeof c)s(c,this,t);else{var u=c.length,d=f(c,u);for(r=0;r<u;++r)s(d[r],this,t)}return!0},a.prototype.addListener=function(e,t){return d(this,e,t,!1)},a.prototype.on=a.prototype.addListener,a.prototype.prependListener=function(e,t){return d(this,e,t,!0)},a.prototype.once=function(e,t){if("function"!=typeof t)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof t);return this.on(e,l(this,e,t)),this},a.prototype.prependOnceListener=function(e,t){if("function"!=typeof t)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof t);return this.prependListener(e,l(this,e,t)),this},a.prototype.removeListener=function(e,t){var r,i,n,s,o;if("function"!=typeof t)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof t);if(void 0===(i=this._events))return this;if(void 0===(r=i[e]))return this;if(r===t||r.listener===t)0==--this._eventsCount?this._events=Object.create(null):(delete i[e],i.removeListener&&this.emit("removeListener",e,r.listener||t));else if("function"!=typeof r){for(n=-1,s=r.length-1;s>=0;s--)if(r[s]===t||r[s].listener===t){o=r[s].listener,n=s;break}if(n<0)return this;0===n?r.shift():function(e,t){for(;t+1<e.length;t++)e[t]=e[t+1];e.pop()}(r,n),1===r.length&&(i[e]=r[0]),void 0!==i.removeListener&&this.emit("removeListener",e,o||t)}return this},a.prototype.off=a.prototype.removeListener,a.prototype.removeAllListeners=function(e){var t,r,i;if(void 0===(r=this._events))return this;if(void 0===r.removeListener)return 0===arguments.length?(this._events=Object.create(null),this._eventsCount=0):void 0!==r[e]&&(0==--this._eventsCount?this._events=Object.create(null):delete r[e]),this;if(0===arguments.length){var n,s=Object.keys(r);for(i=0;i<s.length;++i)"removeListener"!==(n=s[i])&&this.removeAllListeners(n);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if("function"==typeof(t=r[e]))this.removeListener(e,t);else if(void 0!==t)for(i=t.length-1;i>=0;i--)this.removeListener(e,t[i]);return this},a.prototype.listeners=function(e){return h(this,e,!0)},a.prototype.rawListeners=function(e){return h(this,e,!1)},a.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):g.call(e,t)},a.prototype.listenerCount=g,a.prototype.eventNames=function(){return this._eventsCount>0?i(this._events):[]}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),function(e){e[e.STATUS_EARLY=1]="STATUS_EARLY",e[e.STATUS_CONFIRMED=2]="STATUS_CONFIRMED"}(t.DialogStatus||(t.DialogStatus={})),function(e){e[e.STATUS_NULL=0]="STATUS_NULL",e[e.STATUS_INVITE_SENT=1]="STATUS_INVITE_SENT",e[e.STATUS_1XX_RECEIVED=2]="STATUS_1XX_RECEIVED",e[e.STATUS_INVITE_RECEIVED=3]="STATUS_INVITE_RECEIVED",e[e.STATUS_WAITING_FOR_ANSWER=4]="STATUS_WAITING_FOR_ANSWER",e[e.STATUS_ANSWERED=5]="STATUS_ANSWERED",e[e.STATUS_WAITING_FOR_PRACK=6]="STATUS_WAITING_FOR_PRACK",e[e.STATUS_WAITING_FOR_ACK=7]="STATUS_WAITING_FOR_ACK",e[e.STATUS_CANCELED=8]="STATUS_CANCELED",e[e.STATUS_TERMINATED=9]="STATUS_TERMINATED",e[e.STATUS_ANSWERED_WAITING_FOR_PRACK=10]="STATUS_ANSWERED_WAITING_FOR_PRACK",e[e.STATUS_EARLY_MEDIA=11]="STATUS_EARLY_MEDIA",e[e.STATUS_CONFIRMED=12]="STATUS_CONFIRMED"}(t.SessionStatus||(t.SessionStatus={})),function(e){e[e.ClientContext=0]="ClientContext",e[e.ConfigurationError=1]="ConfigurationError",e[e.Dialog=2]="Dialog",e[e.DigestAuthentication=3]="DigestAuthentication",e[e.DTMF=4]="DTMF",e[e.IncomingMessage=5]="IncomingMessage",e[e.IncomingRequest=6]="IncomingRequest",e[e.IncomingResponse=7]="IncomingResponse",e[e.InvalidStateError=8]="InvalidStateError",e[e.InviteClientContext=9]="InviteClientContext",e[e.InviteServerContext=10]="InviteServerContext",e[e.Logger=11]="Logger",e[e.LoggerFactory=12]="LoggerFactory",e[e.MethodParameterError=13]="MethodParameterError",e[e.NameAddrHeader=14]="NameAddrHeader",e[e.NotSupportedError=15]="NotSupportedError",e[e.OutgoingRequest=16]="OutgoingRequest",e[e.Parameters=17]="Parameters",e[e.PublishContext=18]="PublishContext",e[e.ReferClientContext=19]="ReferClientContext",e[e.ReferServerContext=20]="ReferServerContext",e[e.RegisterContext=21]="RegisterContext",e[e.RenegotiationError=22]="RenegotiationError",e[e.RequestSender=23]="RequestSender",e[e.ServerContext=24]="ServerContext",e[e.Session=25]="Session",e[e.SessionDescriptionHandler=26]="SessionDescriptionHandler",e[e.SessionDescriptionHandlerError=27]="SessionDescriptionHandlerError",e[e.SessionDescriptionHandlerObserver=28]="SessionDescriptionHandlerObserver",e[e.Subscription=29]="Subscription",e[e.Transport=30]="Transport",e[e.UA=31]="UA",e[e.URI=32]="URI"}(t.TypeStrings||(t.TypeStrings={})),function(e){e[e.STATUS_INIT=0]="STATUS_INIT",e[e.STATUS_STARTING=1]="STATUS_STARTING",e[e.STATUS_READY=2]="STATUS_READY",e[e.STATUS_USER_CLOSED=3]="STATUS_USER_CLOSED",e[e.STATUS_NOT_READY=4]="STATUS_NOT_READY"}(t.UAStatus||(t.UAStatus={}))},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=r(11),n=r(29),s=r(30);!function(e){e.defer=function(){var e={};return e.promise=new Promise((function(t,r){e.resolve=t,e.reject=r})),e},e.reducePromises=function(e,t){return e.reduce((function(e,t){return e=e.then(t)}),Promise.resolve(t))},e.str_utf8_length=function(e){return encodeURIComponent(e).replace(/%[A-F\d]{2}/g,"U").length},e.generateFakeSDP=function(e){if(e){var t=e.indexOf("o="),r=e.indexOf("\r\n",t);return"v=0\r\n"+e.slice(t,r)+"\r\ns=-\r\nt=0 0\r\nc=IN IP4 0.0.0.0"}},e.isDecimal=function(e){var t=parseInt(e,10);return!isNaN(t)&&parseFloat(e)===t},e.createRandomToken=function(e,t){void 0===t&&(t=32);for(var r="",i=0;i<e;i++){r+=Math.floor(Math.random()*t).toString(t)}return r},e.newTag=function(){return e.createRandomToken(10)},e.newUUID=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(function(e){var t=Math.floor(16*Math.random());return("x"===e?t:t%4+8).toString(16)}))},e.normalizeTarget=function(t,r){if(t){if(t instanceof s.URI)return t;if("string"==typeof t){var o=t.split("@"),a=void 0,c=void 0;switch(o.length){case 1:if(!r)return;a=t,c=r;break;case 2:a=o[0],c=o[1];break;default:a=o.slice(0,o.length-1).join("@"),c=o[o.length-1]}return a=a.replace(/^(sips?|tel):/i,""),/^[\-\.\(\)]*\+?[0-9\-\.\(\)]+$/.test(a)&&(a=a.replace(/[\-\.\(\)]/g,"")),t=i.C.SIP+":"+e.escapeUser(a)+"@"+c,n.Grammar.URIParse(t)}}else;},e.escapeUser=function(e){return encodeURIComponent(decodeURIComponent(e)).replace(/%3A/gi,":").replace(/%2B/gi,"+").replace(/%3F/gi,"?").replace(/%2F/gi,"/")},e.headerize=function(e){for(var t={"Call-Id":"Call-ID",Cseq:"CSeq","Min-Se":"Min-SE",Rack:"RAck",Rseq:"RSeq","Www-Authenticate":"WWW-Authenticate"},r=e.toLowerCase().replace(/_/g,"-").split("-"),i=r.length,n="",s=0;s<i;s++)0!==s&&(n+="-"),n+=r[s].charAt(0).toUpperCase()+r[s].substring(1);return t[n]&&(n=t[n]),n},e.sipErrorCause=function(e){for(var t in i.C.SIP_ERROR_CAUSES)if(-1!==i.C.SIP_ERROR_CAUSES[t].indexOf(e))return i.C.causes[t];return i.C.causes.SIP_FAILURE_CODE},e.getReasonPhrase=function(e,t){return t||i.C.REASON_PHRASE[e]||""},e.getReasonHeaderValue=function(t,r){return"SIP;cause="+t+';text="'+(r=e.getReasonPhrase(t,r))+'"'},e.getCancelReason=function(t,r){if(t&&t<200||t>699)throw new TypeError("Invalid statusCode: "+t);if(t)return e.getReasonHeaderValue(t,r)},e.buildStatusLine=function(t,r){if(!t||t<100||t>699)throw new TypeError("Invalid statusCode: "+t);if(r&&"string"!=typeof r&&!(r instanceof String))throw new TypeError("Invalid reason: "+r);return"SIP/2.0 "+t+" "+(r=e.getReasonPhrase(t,r))+"\r\n"},e.fromBodyObj=function(e){var t=e.body,r=e.contentType;return{contentDisposition:function(e){return"application/sdp"===e?"session":"render"}(r),contentType:r,content:t}},e.toBodyObj=function(e){return{body:e.content,contentType:e.contentType}}}(t.Utils||(t.Utils={}))},function(e,t,r){"use strict";function i(e,t){void 0===t&&(t=32);for(var r="",i=0;i<e;i++){r+=Math.floor(Math.random()*t).toString(t)}return r}Object.defineProperty(t,"__esModule",{value:!0}),t.createRandomToken=i,t.getReasonPhrase=function(e){return n[e]||""},t.newTag=function(){return i(10)},t.headerize=function(e){for(var t={"Call-Id":"Call-ID",Cseq:"CSeq","Min-Se":"Min-SE",Rack:"RAck",Rseq:"RSeq","Www-Authenticate":"WWW-Authenticate"},r=e.toLowerCase().replace(/_/g,"-").split("-"),i=r.length,n="",s=0;s<i;s++)0!==s&&(n+="-"),n+=r[s].charAt(0).toUpperCase()+r[s].substring(1);return t[n]&&(n=t[n]),n},t.str_utf8_length=function(e){return encodeURIComponent(e).replace(/%[A-F\d]{2}/g,"U").length};var n={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",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:"Internal Server 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"}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=r(88);!function(e){e.version=i.LIBRARY_VERSION,e.USER_AGENT="SIP.js/"+i.LIBRARY_VERSION,e.SIP="sip",e.SIPS="sips",function(e){e.CONNECTION_ERROR="Connection Error",e.INTERNAL_ERROR="Internal Error",e.REQUEST_TIMEOUT="Request Timeout",e.SIP_FAILURE_CODE="SIP Failure Code",e.ADDRESS_INCOMPLETE="Address Incomplete",e.AUTHENTICATION_ERROR="Authentication Error",e.BUSY="Busy",e.DIALOG_ERROR="Dialog Error",e.INCOMPATIBLE_SDP="Incompatible SDP",e.NOT_FOUND="Not Found",e.REDIRECTED="Redirected",e.REJECTED="Rejected",e.UNAVAILABLE="Unavailable",e.BAD_MEDIA_DESCRIPTION="Bad Media Description",e.CANCELED="Canceled",e.EXPIRES="Expires",e.NO_ACK="No ACK",e.NO_ANSWER="No Answer",e.NO_PRACK="No PRACK",e.RTP_TIMEOUT="RTP Timeout",e.USER_DENIED_MEDIA_ACCESS="User Denied Media Access",e.WEBRTC_ERROR="WebRTC Error",e.WEBRTC_NOT_SUPPORTED="WebRTC Not Supported"}(e.causes||(e.causes={})),function(e){e.REQUIRED="required",e.SUPPORTED="supported",e.UNSUPPORTED="none"}(e.supported||(e.supported={})),e.SIP_ERROR_CAUSES={ADDRESS_INCOMPLETE:[484],AUTHENTICATION_ERROR:[401,407],BUSY:[486,600],INCOMPATIBLE_SDP:[488,606],NOT_FOUND:[404,604],REDIRECTED:[300,301,302,305,380],REJECTED:[403,603],UNAVAILABLE:[480,410,408,430]},e.ACK="ACK",e.BYE="BYE",e.CANCEL="CANCEL",e.INFO="INFO",e.INVITE="INVITE",e.MESSAGE="MESSAGE",e.NOTIFY="NOTIFY",e.OPTIONS="OPTIONS",e.REGISTER="REGISTER",e.UPDATE="UPDATE",e.SUBSCRIBE="SUBSCRIBE",e.PUBLISH="PUBLISH",e.REFER="REFER",e.PRACK="PRACK",e.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",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:"Internal Server 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"},e.OPTION_TAGS={"100rel":!0,199:!0,answermode:!0,"early-session":!0,eventlist:!0,explicitsub:!0,"from-change":!0,"geolocation-http":!0,"geolocation-sip":!0,gin:!0,gruu:!0,histinfo:!0,ice:!0,join:!0,"multiple-refer":!0,norefersub:!0,nosub:!0,outbound:!0,path:!0,policy:!0,precondition:!0,pref:!0,privacy:!0,"recipient-list-invite":!0,"recipient-list-message":!0,"recipient-list-subscribe":!0,replaces:!0,"resource-priority":!0,"sdp-anat":!0,"sec-agree":!0,tdialog:!0,timer:!0,uui:!0},function(e){e.INFO="info",e.RTP="rtp"}(e.dtmfType||(e.dtmfType={}))}(t.C||(t.C={}))},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=r(0),n=r(5),s=r(8);!function(e){var t=function(e){function t(){return e.call(this,"The session description handler has closed.")||this}return i.__extends(t,e),t}(n.Exception);e.ClosedSessionDescriptionHandlerError=t;var r=function(e){function t(){return e.call(this,"The session has terminated.")||this}return i.__extends(t,e),t}(n.Exception);e.TerminatedSessionError=r;var s=function(e){function t(t){return e.call(this,t||"Unsupported session description content type.")||this}return i.__extends(t,e),t}(n.Exception);e.UnsupportedSessionDescriptionContentTypeError=s}(t.Exceptions||(t.Exceptions={}));var o=function(e){function t(t,r,i){var n=e.call(this,i)||this;return n.code=t,n.name=r,n.message=i,n}return i.__extends(t,e),t}(n.Exception);!function(e){var t=function(e){function t(t,r){var i=e.call(this,1,"CONFIGURATION_ERROR",r?"Invalid value "+JSON.stringify(r)+" for parameter '"+t+"'":"Missing parameter: "+t)||this;return i.type=s.TypeStrings.ConfigurationError,i.parameter=t,i.value=r,i}return i.__extends(t,e),t}(o);e.ConfigurationError=t;var r=function(e){function t(t){var r=e.call(this,2,"INVALID_STATE_ERROR","Invalid status: "+t)||this;return r.type=s.TypeStrings.InvalidStateError,r.status=t,r}return i.__extends(t,e),t}(o);e.InvalidStateError=r;var n=function(e){function t(t){var r=e.call(this,3,"NOT_SUPPORTED_ERROR",t)||this;return r.type=s.TypeStrings.NotSupportedError,r}return i.__extends(t,e),t}(o);e.NotSupportedError=n;var a=function(e){function t(t){var r=e.call(this,5,"RENEGOTIATION_ERROR",t)||this;return r.type=s.TypeStrings.RenegotiationError,r}return i.__extends(t,e),t}(o);e.RenegotiationError=a;var c=function(e){function t(t,r,i){var n=e.call(this,6,"METHOD_PARAMETER_ERROR",i?"Invalid value "+JSON.stringify(i)+" for parameter '"+r+"'":"Missing parameter: "+r)||this;return n.type=s.TypeStrings.MethodParameterError,n.method=t,n.parameter=r,n.value=i,n}return i.__extends(t,e),t}(o);e.MethodParameterError=c;var u=function(e){function t(t,r,i){var n=e.call(this,8,"SESSION_DESCRIPTION_HANDLER_ERROR",i||"Error with Session Description Handler")||this;return n.type=s.TypeStrings.SessionDescriptionHandlerError,n.method=t,n.error=r,n}return i.__extends(t,e),t}(o);e.SessionDescriptionHandlerError=u}(t.Exceptions||(t.Exceptions={}))},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),function(e){e.Accepted="Accepted",e.Calling="Calling",e.Completed="Completed",e.Confirmed="Confirmed",e.Proceeding="Proceeding",e.Terminated="Terminated",e.Trying="Trying"}(t.TransactionState||(t.TransactionState={}))},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=r(2);t.AllowedMethods=[i.C.ACK,i.C.BYE,i.C.CANCEL,i.C.INFO,i.C.INVITE,i.C.MESSAGE,i.C.NOTIFY,i.C.OPTIONS,i.C.PRACK,i.C.REFER,i.C.REGISTER,i.C.SUBSCRIBE]},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),r(0).__exportStar(r(64),t)},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=r(0);i.__exportStar(r(24),t),i.__exportStar(r(65),t),i.__exportStar(r(66),t)},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=r(0);i.__exportStar(r(18),t),i.__exportStar(r(63),t),i.__exportStar(r(47),t)},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=r(2),n=function(){function e(e,t){this.core=e,this.dialogState=t,this.core.dialogs.set(this.id,this)}return e.initialDialogStateForUserAgentClient=function(e,t){var r=t.getHeaders("record-route").reverse(),n=t.parseHeader("contact");if(!n)throw new Error("Contact undefined.");if(!(n instanceof i.NameAddrHeader))throw new Error("Contact not instance of NameAddrHeader.");var s=n.uri,o=e.cseq,a=e.callId,c=e.fromTag,u=t.toTag;if(!a)throw new Error("Call id undefined.");if(!c)throw new Error("From tag undefined.");if(!u)throw new Error("To tag undefined.");if(!e.from)throw new Error("From undefined.");if(!e.to)throw new Error("To undefined.");var d=e.from.uri,p=e.to.uri;if(!t.statusCode)throw new Error("Incoming response status code undefined.");return{id:a+c+u,early:t.statusCode<200,callId:a,localTag:c,remoteTag:u,localSequenceNumber:o,remoteSequenceNumber:void 0,localURI:d,remoteURI:p,remoteTarget:s,routeSet:r,secure:!1}},e.initialDialogStateForUserAgentServer=function(e,t,r){void 0===r&&(r=!1);var n=e.getHeaders("record-route"),s=e.parseHeader("contact");if(!s)throw new Error("Contact undefined.");if(!(s instanceof i.NameAddrHeader))throw new Error("Contact not instance of NameAddrHeader.");var o=s.uri,a=e.cseq,c=e.callId,u=t,d=e.fromTag,p=e.from.uri;return{id:c+u+d,early:r,callId:c,localTag:u,remoteTag:d,localSequenceNumber:void 0,remoteSequenceNumber:a,localURI:e.to.uri,remoteURI:p,remoteTarget:o,routeSet:n,secure:!1}},e.prototype.dispose=function(){this.core.dialogs.delete(this.id)},Object.defineProperty(e.prototype,"id",{get:function(){return this.dialogState.id},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"early",{get:function(){return this.dialogState.early},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"callId",{get:function(){return this.dialogState.callId},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"localTag",{get:function(){return this.dialogState.localTag},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"remoteTag",{get:function(){return this.dialogState.remoteTag},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"localSequenceNumber",{get:function(){return this.dialogState.localSequenceNumber},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"remoteSequenceNumber",{get:function(){return this.dialogState.remoteSequenceNumber},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"localURI",{get:function(){return this.dialogState.localURI},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"remoteURI",{get:function(){return this.dialogState.remoteURI},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"remoteTarget",{get:function(){return this.dialogState.remoteTarget},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"routeSet",{get:function(){return this.dialogState.routeSet},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"secure",{get:function(){return this.dialogState.secure},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"userAgentCore",{get:function(){return this.core},enumerable:!0,configurable:!0}),e.prototype.confirm=function(){this.dialogState.early=!1},e.prototype.receiveRequest=function(e){if(e.method!==i.C.ACK){if(this.remoteSequenceNumber){if(e.cseq<=this.remoteSequenceNumber)throw new Error("Out of sequence in dialog request. Did you forget to call sequenceGuard()?");this.dialogState.remoteSequenceNumber=e.cseq}this.remoteSequenceNumber||(this.dialogState.remoteSequenceNumber=e.cseq)}},e.prototype.recomputeRouteSet=function(e){this.dialogState.routeSet=e.getHeaders("record-route").reverse()},e.prototype.createOutgoingRequestMessage=function(e,t){var r,i=this.remoteURI,n=this.remoteTag,s=this.localURI,o=this.localTag,a=this.callId;r=t&&t.cseq?t.cseq:this.dialogState.localSequenceNumber?this.dialogState.localSequenceNumber+=1:this.dialogState.localSequenceNumber=1;var c=this.remoteTarget,u=this.routeSet,d=t&&t.extraHeaders,p=t&&t.body;return this.userAgentCore.makeOutgoingRequestMessage(e,c,s,i,{callId:a,cseq:r,fromTag:o,toTag:n,routeSet:u},d,p)},e.prototype.sequenceGuard=function(e){return e.method===i.C.ACK||(!(this.remoteSequenceNumber&&e.cseq<=this.remoteSequenceNumber)||(this.core.replyStateless(e,{statusCode:500}),!1))},e}();t.Dialog=n},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=r(29),n=r(10),s=function(){function e(){this.headers={}}return e.prototype.addHeader=function(e,t){var r={raw:t};e=n.headerize(e),this.headers[e]?this.headers[e].push(r):this.headers[e]=[r]},e.prototype.getHeader=function(e){var t=this.headers[n.headerize(e)];if(t)return t[0]?t[0].raw:void 0},e.prototype.getHeaders=function(e){var t=this.headers[n.headerize(e)],r=[];if(!t)return[];for(var i=0,s=t;i<s.length;i++){var o=s[i];r.push(o.raw)}return r},e.prototype.hasHeader=function(e){return!!this.headers[n.headerize(e)]},e.prototype.parseHeader=function(e,t){if(void 0===t&&(t=0),e=n.headerize(e),this.headers[e]&&!(t>=this.headers[e].length)){var r=this.headers[e][t],s=r.raw;if(r.parsed)return r.parsed;var o=i.Grammar.parse(s,e.replace(/-/g,"_"));return-1===o?void this.headers[e].splice(t,1):(r.parsed=o,o)}},e.prototype.s=function(e,t){return void 0===t&&(t=0),this.parseHeader(e,t)},e.prototype.setHeader=function(e,t){this.headers[n.headerize(e)]=[{raw:t}]},e.prototype.toString=function(){return this.data},e}();t.IncomingMessage=s},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=r(0),n=function(e){function t(t,r,i){var n=e.call(this,i)||this;return n.uri=t,n._displayName=r,n}return i.__extends(t,e),Object.defineProperty(t.prototype,"friendlyName",{get:function(){return this.displayName||this.uri.aor},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"displayName",{get:function(){return this._displayName},set:function(e){this._displayName=e},enumerable:!0,configurable:!0}),t.prototype.clone=function(){return new t(this.uri.clone(),this._displayName,JSON.parse(JSON.stringify(this.parameters)))},t.prototype.toString=function(){var e=this.displayName||"0"===this.displayName?'"'+this.displayName+'" ':"";for(var t in e+="<"+this.uri.toString()+">",this.parameters)this.parameters.hasOwnProperty(t)&&(e+=";"+t,null!==this.parameters[t]&&(e+="="+this.parameters[t]));return e},t}(r(21).Parameters);t.NameAddrHeader=n},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=function(){function e(e){for(var t in this.parameters={},e)e.hasOwnProperty(t)&&this.setParam(t,e[t])}return e.prototype.setParam=function(e,t){e&&(this.parameters[e.toLowerCase()]=null==t?null:t.toString())},e.prototype.getParam=function(e){if(e)return this.parameters[e.toLowerCase()]},e.prototype.hasParam=function(e){return!!e&&!!this.parameters.hasOwnProperty(e.toLowerCase())},e.prototype.deleteParam=function(e){if(e=e.toLowerCase(),this.parameters.hasOwnProperty(e)){var t=this.parameters[e];return delete this.parameters[e],t}},e.prototype.clearParams=function(){this.parameters={}},e}();t.Parameters=i},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=r(0),n=function(e){function t(r,i,n,s,o){var a=e.call(this,i,n,t.makeId(r),s,o)||this;a._request=r,a.user=n;var c=i.server&&i.server.scheme?i.server.scheme:void 0;return r.setViaHeader(a.id,c),a}return i.__extends(t,e),t.makeId=function(e){if("CANCEL"===e.method){if(!e.branch)throw new Error("Outgoing CANCEL request without a branch.");return e.branch}return"z9hG4bK"+Math.floor(1e7*Math.random())},Object.defineProperty(t.prototype,"request",{get:function(){return this._request},enumerable:!0,configurable:!0}),t.prototype.onRequestTimeout=function(){this.user.onRequestTimeout&&this.user.onRequestTimeout()},t}(r(23).Transaction);t.ClientTransaction=n},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=r(0),n=r(7),s=r(16),o=function(e){function t(t,r,i,n,s){var o=e.call(this)||this;return o._transport=t,o._user=r,o._id=i,o._state=n,o.logger=r.loggerFactory.getLogger(s,i),o.logger.debug("Constructing "+o.typeToString()+" with id "+o.id+"."),o}return i.__extends(t,e),t.prototype.dispose=function(){this.logger.debug("Destroyed "+this.typeToString()+" with id "+this.id+".")},Object.defineProperty(t.prototype,"id",{get:function(){return this._id},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"kind",{get:function(){throw new Error("Invalid kind.")},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"state",{get:function(){return this._state},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"transport",{get:function(){return this._transport},enumerable:!0,configurable:!0}),t.prototype.on=function(t,r){return e.prototype.on.call(this,t,r)},t.prototype.logTransportError=function(e,t){this.logger.error(e.message),this.logger.error("Transport error occurred in "+this.typeToString()+" with id "+this.id+"."),this.logger.error(t)},t.prototype.send=function(e){var t=this;return this.transport.send(e).catch((function(e){if(e instanceof s.TransportError)throw t.onTransportError(e),e;var r;throw r=e&&"string"==typeof e.message?new s.TransportError(e.message):new s.TransportError,t.onTransportError(r),r}))},t.prototype.setState=function(e){this.logger.debug('State change to "'+e+'" on '+this.typeToString()+" with id "+this.id+"."),this._state=e,this._user.onStateChange&&this._user.onStateChange(e),this.emit("stateChanged")},t.prototype.typeToString=function(){return"UnknownType"},t}(n.EventEmitter);t.Transaction=o},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=r(0),n=function(e){function t(t){var r=this.constructor,i=e.call(this,t)||this;return Object.setPrototypeOf(i,r.prototype),i}return i.__extends(t,e),t}(Error);t.Exception=n},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=r(0),n=function(e){function t(t,r,i,n,s){var o=e.call(this,r,i,t.viaBranch,n,s)||this;return o._request=t,o.user=i,o}return i.__extends(t,e),Object.defineProperty(t.prototype,"request",{get:function(){return this._request},enumerable:!0,configurable:!0}),t}(r(23).Transaction);t.ServerTransaction=n},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=r(0),n=r(1),s=function(e){function t(t,r,i){var s=void 0!==t.userAgentCore?t.userAgentCore:t;return e.call(this,n.NonInviteServerTransaction,s,r,i)||this}return i.__extends(t,e),t}(r(4).UserAgentServer);t.NotifyUserAgentServer=s},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),r(0).__exportStar(r(70),t)},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),function(e){e[e.error=0]="error",e[e.warn=1]="warn",e[e.log=2]="log",e[e.debug=3]="debug"}(t.Levels||(t.Levels={}))},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=r(0).__importStar(r(58));!function(e){e.parse=function(e,t){var r={startRule:t};try{i.parse(e,r)}catch(e){r.data=-1}return r.data},e.nameAddrHeaderParse=function(t){var r=e.parse(t,"Name_Addr_Header");return-1!==r?r:void 0},e.URIParse=function(t){var r=e.parse(t,"SIP_URI");return-1!==r?r:void 0}}(t.Grammar||(t.Grammar={}))},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=r(0),n=function(e){function t(t,r,i,n,s,o){var a=e.call(this,s)||this;if(a.headers={},!i)throw new TypeError('missing or invalid "host" parameter');for(var c in t=t||"sip",o)o.hasOwnProperty(c)&&a.setHeader(c,o[c]);return a.raw={scheme:t,user:r,host:i,port:n},a.normal={scheme:t.toLowerCase(),user:r,host:i.toLowerCase(),port:n},a}return i.__extends(t,e),Object.defineProperty(t.prototype,"scheme",{get:function(){return this.normal.scheme},set:function(e){this.raw.scheme=e,this.normal.scheme=e.toLowerCase()},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"user",{get:function(){return this.normal.user},set:function(e){this.normal.user=this.raw.user=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"host",{get:function(){return this.normal.host},set:function(e){this.raw.host=e,this.normal.host=e.toLowerCase()},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"aor",{get:function(){return this.normal.user+"@"+this.normal.host},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"port",{get:function(){return this.normal.port},set:function(e){this.normal.port=this.raw.port=e},enumerable:!0,configurable:!0}),t.prototype.setHeader=function(e,t){this.headers[this.headerize(e)]=t instanceof Array?t:[t]},t.prototype.getHeader=function(e){if(e)return this.headers[this.headerize(e)]},t.prototype.hasHeader=function(e){return!!e&&!!this.headers.hasOwnProperty(this.headerize(e))},t.prototype.deleteHeader=function(e){if(e=this.headerize(e),this.headers.hasOwnProperty(e)){var t=this.headers[e];return delete this.headers[e],t}},t.prototype.clearHeaders=function(){this.headers={}},t.prototype.clone=function(){return new t(this._raw.scheme,this._raw.user||"",this._raw.host,this._raw.port,JSON.parse(JSON.stringify(this.parameters)),JSON.parse(JSON.stringify(this.headers)))},t.prototype.toRaw=function(){return this._toString(this._raw)},t.prototype.toString=function(){return this._toString(this._normal)},Object.defineProperty(t.prototype,"_normal",{get:function(){return this.normal},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"_raw",{get:function(){return this.raw},enumerable:!0,configurable:!0}),t.prototype._toString=function(e){var t=e.scheme+":";for(var r in e.scheme.toLowerCase().match("^sips?$")||(t+="//"),e.user&&(t+=this.escapeUser(e.user)+"@"),t+=e.host,(e.port||0===e.port)&&(t+=":"+e.port),this.parameters)this.parameters.hasOwnProperty(r)&&(t+=";"+r,null!==this.parameters[r]&&(t+="="+this.parameters[r]));var i=[];for(var n in this.headers)if(this.headers.hasOwnProperty(n))for(var s in this.headers[n])this.headers[n].hasOwnProperty(s)&&i.push(n+"="+this.headers[n][s]);return i.length>0&&(t+="?"+i.join("&")),t},t.prototype.escapeUser=function(e){var t;try{t=decodeURIComponent(e)}catch(e){throw e}return encodeURIComponent(t).replace(/%3A/gi,":").replace(/%2B/gi,"+").replace(/%3F/gi,"?").replace(/%2F/gi,"/")},t.prototype.headerize=function(e){for(var t={"Call-Id":"Call-ID",Cseq:"CSeq","Min-Se":"Min-SE",Rack:"RAck",Rseq:"RSeq","Www-Authenticate":"WWW-Authenticate"},r=e.toLowerCase().replace(/_/g,"-").split("-"),i=r.length,n="",s=0;s<i;s++)0!==s&&(n+="-"),n+=r[s].charAt(0).toUpperCase()+r[s].substring(1);return t[n]&&(n=t[n]),n},t}(r(21).Parameters);t.URI=n},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),function(e){e.Initial="Initial",e.Establishing="Establishing",e.Established="Established",e.Terminating="Terminating",e.Terminated="Terminated"}(t.SessionState||(t.SessionState={}))},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=r(0),n=function(e){function t(){return e.call(this)||this}return i.__extends(t,e),t}(r(19).IncomingMessage);t.IncomingRequestMessage=n},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=r(0),n=function(e){function t(){return e.call(this)||this}return i.__extends(t,e),t}(r(19).IncomingMessage);t.IncomingResponseMessage=n},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=r(0),n=r(20),s=r(10),o=function(){function e(t,r,n,o,a,c,u){this.headers={},this.extraHeaders=[],this.options=e.getDefaultOptions(),a&&(this.options=i.__assign(i.__assign({},this.options),a),this.options.optionTags&&this.options.optionTags.length&&(this.options.optionTags=this.options.optionTags.slice()),this.options.routeSet&&this.options.routeSet.length&&(this.options.routeSet=this.options.routeSet.slice())),c&&c.length&&(this.extraHeaders=c.slice()),u&&(this.body={body:u.content,contentType:u.contentType}),this.method=t,this.ruri=r.clone(),this.fromURI=n.clone(),this.fromTag=this.options.fromTag?this.options.fromTag:s.newTag(),this.from=e.makeNameAddrHeader(this.fromURI,this.options.fromDisplayName,this.fromTag),this.toURI=o.clone(),this.toTag=this.options.toTag,this.to=e.makeNameAddrHeader(this.toURI,this.options.toDisplayName,this.toTag),this.callId=this.options.callId?this.options.callId:this.options.callIdPrefix+s.createRandomToken(15),this.cseq=this.options.cseq,this.setHeader("route",this.options.routeSet),this.setHeader("via",""),this.setHeader("to",this.to.toString()),this.setHeader("from",this.from.toString()),this.setHeader("cseq",this.cseq+" "+this.method),this.setHeader("call-id",this.callId),this.setHeader("max-forwards","70")}return e.getDefaultOptions=function(){return{callId:"",callIdPrefix:"",cseq:1,toDisplayName:"",toTag:"",fromDisplayName:"",fromTag:"",forceRport:!1,hackViaTcp:!1,optionTags:["outbound"],routeSet:[],userAgentString:"sip.js",viaHost:""}},e.makeNameAddrHeader=function(e,t,r){var i={};return r&&(i.tag=r),new n.NameAddrHeader(e,t,i)},e.prototype.getHeader=function(e){var t=this.headers[s.headerize(e)];if(t){if(t[0])return t[0]}else for(var r=new RegExp("^\\s*"+e+"\\s*:","i"),i=0,n=this.extraHeaders;i<n.length;i++){var o=n[i];if(r.test(o))return o.substring(o.indexOf(":")+1).trim()}},e.prototype.getHeaders=function(e){var t=[],r=this.headers[s.headerize(e)];if(r)for(var i=0,n=r;i<n.length;i++){var o=n[i];t.push(o)}else for(var a=new RegExp("^\\s*"+e+"\\s*:","i"),c=0,u=this.extraHeaders;c<u.length;c++){var d=u[c];a.test(d)&&t.push(d.substring(d.indexOf(":")+1).trim())}return t},e.prototype.hasHeader=function(e){if(this.headers[s.headerize(e)])return!0;for(var t=new RegExp("^\\s*"+e+"\\s*:","i"),r=0,i=this.extraHeaders;r<i.length;r++){var n=i[r];if(t.test(n))return!0}return!1},e.prototype.setHeader=function(e,t){this.headers[s.headerize(e)]=t instanceof Array?t:[t]},e.prototype.setViaHeader=function(e,t){void 0===t&&(t="WSS"),this.options.hackViaTcp&&(t="TCP");var r="SIP/2.0/"+t;r+=" "+this.options.viaHost+";branch="+e,this.options.forceRport&&(r+=";rport"),this.setHeader("via",r),this.branch=e},e.prototype.toString=function(){var e="";for(var t in e+=this.method+" "+this.ruri.toRaw()+" SIP/2.0\r\n",this.headers)if(this.headers[t])for(var r=0,i=this.headers[t];r<i.length;r++){e+=t+": "+i[r]+"\r\n"}for(var n=0,o=this.extraHeaders;n<o.length;n++){e+=(t=o[n]).trim()+"\r\n"}return e+="Supported: "+this.options.optionTags.join(", ")+"\r\n",e+="User-Agent: "+this.options.userAgentString+"\r\n",this.body?"string"==typeof this.body?(e+="Content-Length: "+s.str_utf8_length(this.body)+"\r\n\r\n",e+=this.body):this.body.body&&this.body.contentType?(e+="Content-Type: "+this.body.contentType+"\r\n",e+="Content-Length: "+s.str_utf8_length(this.body.body)+"\r\n\r\n",e+=this.body.body):e+="Content-Length: 0\r\n\r\n":e+="Content-Length: 0\r\n\r\n",e},e}();t.OutgoingRequestMessage=o},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=r(0),n=r(6),s=r(22),o=r(13),a=function(e){function t(t,r,i){var s=e.call(this,t,r,i,o.TransactionState.Calling,"sip.transaction.ict")||this;return s.ackRetransmissionCache=new Map,s.B=setTimeout((function(){return s.timer_B()}),n.Timers.TIMER_B),s.send(t.toString()).catch((function(e){s.logTransportError(e,"Failed to send initial outgoing request.")})),s}return i.__extends(t,e),t.prototype.dispose=function(){this.B&&(clearTimeout(this.B),this.B=void 0),this.D&&(clearTimeout(this.D),this.D=void 0),this.M&&(clearTimeout(this.M),this.M=void 0),e.prototype.dispose.call(this)},Object.defineProperty(t.prototype,"kind",{get:function(){return"ict"},enumerable:!0,configurable:!0}),t.prototype.ackResponse=function(e){var t=this,r=e.toTag;if(!r)throw new Error("To tag undefined.");var i="z9hG4bK"+Math.floor(1e7*Math.random()),n=this.transport.server&&this.transport.server.scheme?this.transport.server.scheme:void 0;e.setViaHeader(i,n),this.ackRetransmissionCache.set(r,e),this.send(e.toString()).catch((function(e){t.logTransportError(e,"Failed to send ACK to 2xx response.")}))},t.prototype.receiveResponse=function(e){var t=this,r=e.statusCode;if(!r||r<100||r>699)throw new Error("Invalid status code "+r);switch(this.state){case o.TransactionState.Calling:if(r>=100&&r<=199)return this.stateTransition(o.TransactionState.Proceeding),void(this.user.receiveResponse&&this.user.receiveResponse(e));if(r>=200&&r<=299)return this.ackRetransmissionCache.set(e.toTag,void 0),this.stateTransition(o.TransactionState.Accepted),void(this.user.receiveResponse&&this.user.receiveResponse(e));if(r>=300&&r<=699)return this.stateTransition(o.TransactionState.Completed),this.ack(e),void(this.user.receiveResponse&&this.user.receiveResponse(e));break;case o.TransactionState.Proceeding:if(r>=100&&r<=199)return void(this.user.receiveResponse&&this.user.receiveResponse(e));if(r>=200&&r<=299)return this.ackRetransmissionCache.set(e.toTag,void 0),this.stateTransition(o.TransactionState.Accepted),void(this.user.receiveResponse&&this.user.receiveResponse(e));if(r>=300&&r<=699)return this.stateTransition(o.TransactionState.Completed),this.ack(e),void(this.user.receiveResponse&&this.user.receiveResponse(e));break;case o.TransactionState.Accepted:if(r>=200&&r<=299){if(!this.ackRetransmissionCache.has(e.toTag))return this.ackRetransmissionCache.set(e.toTag,void 0),void(this.user.receiveResponse&&this.user.receiveResponse(e));var i=this.ackRetransmissionCache.get(e.toTag);return i?void this.send(i.toString()).catch((function(e){t.logTransportError(e,"Failed to send retransmission of ACK to 2xx response.")})):void 0}break;case o.TransactionState.Completed:if(r>=300&&r<=699)return void this.ack(e);break;case o.TransactionState.Terminated:break;default:throw new Error("Invalid state "+this.state)}var n="Received unexpected "+r+" response while in state "+this.state+".";this.logger.warn(n)},t.prototype.onTransportError=function(e){this.user.onTransportError&&this.user.onTransportError(e),this.stateTransition(o.TransactionState.Terminated,!0)},t.prototype.typeToString=function(){return"INVITE client transaction"},t.prototype.ack=function(e){var t=this,r=this.request.ruri,i=this.request.callId,n=this.request.cseq,s=this.request.getHeader("from"),o=e.getHeader("to"),a=this.request.getHeader("via"),c=this.request.getHeader("route");if(!s)throw new Error("From undefined.");if(!o)throw new Error("To undefined.");if(!a)throw new Error("Via undefined.");var u="ACK "+r+" SIP/2.0\r\n";c&&(u+="Route: "+c+"\r\n"),u+="Via: "+a+"\r\n",u+="To: "+o+"\r\n",u+="From: "+s+"\r\n",u+="Call-ID: "+i+"\r\n",u+="CSeq: "+n+" ACK\r\n",u+="Max-Forwards: 70\r\n",u+="Content-Length: 0\r\n\r\n",this.send(u).catch((function(e){t.logTransportError(e,"Failed to send ACK to non-2xx response.")}))},t.prototype.stateTransition=function(e,t){var r=this;void 0===t&&(t=!1);var i=function(){throw new Error("Invalid state transition from "+r.state+" to "+e)};switch(e){case o.TransactionState.Calling:i();break;case o.TransactionState.Proceeding:this.state!==o.TransactionState.Calling&&i();break;case o.TransactionState.Accepted:case o.TransactionState.Completed:this.state!==o.TransactionState.Calling&&this.state!==o.TransactionState.Proceeding&&i();break;case o.TransactionState.Terminated:this.state!==o.TransactionState.Calling&&this.state!==o.TransactionState.Accepted&&this.state!==o.TransactionState.Completed&&(t||i());break;default:i()}this.B&&(clearTimeout(this.B),this.B=void 0),o.TransactionState.Proceeding,e===o.TransactionState.Completed&&(this.D=setTimeout((function(){return r.timer_D()}),n.Timers.TIMER_D)),e===o.TransactionState.Accepted&&(this.M=setTimeout((function(){return r.timer_M()}),n.Timers.TIMER_M)),e===o.TransactionState.Terminated&&this.dispose(),this.setState(e)},t.prototype.timer_A=function(){},t.prototype.timer_B=function(){this.logger.debug("Timer B expired for INVITE client transaction "+this.id+"."),this.state===o.TransactionState.Calling&&(this.onRequestTimeout(),this.stateTransition(o.TransactionState.Terminated))},t.prototype.timer_D=function(){this.logger.debug("Timer D expired for INVITE client transaction "+this.id+"."),this.state===o.TransactionState.Completed&&this.stateTransition(o.TransactionState.Terminated)},t.prototype.timer_M=function(){this.logger.debug("Timer M expired for INVITE client transaction "+this.id+"."),this.state===o.TransactionState.Accepted&&this.stateTransition(o.TransactionState.Terminated)},t}(s.ClientTransaction);t.InviteClientTransaction=a},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=r(0),n=r(2),s=r(1),o=function(e){function t(t,r,i){var o,a=t.createOutgoingRequestMessage(n.C.BYE,i);return o=e.call(this,s.NonInviteClientTransaction,t.userAgentCore,a,r)||this,t.dispose(),o}return i.__extends(t,e),t}(r(3).UserAgentClient);t.ByeUserAgentClient=o},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=r(0),n=r(1),s=function(e){function t(t,r,i){return e.call(this,n.NonInviteServerTransaction,t.userAgentCore,r,i)||this}return i.__extends(t,e),t}(r(4).UserAgentServer);t.ByeUserAgentServer=s},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=r(0),n=r(2),s=r(1),o=function(e){function t(t,r,i){var o=t.createOutgoingRequestMessage(n.C.INFO,i);return e.call(this,s.NonInviteClientTransaction,t.userAgentCore,o,r)||this}return i.__extends(t,e),t}(r(3).UserAgentClient);t.InfoUserAgentClient=o},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=r(0),n=r(1),s=function(e){function t(t,r,i){return e.call(this,n.NonInviteServerTransaction,t.userAgentCore,r,i)||this}return i.__extends(t,e),t}(r(4).UserAgentServer);t.InfoUserAgentServer=s},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=r(0),n=r(2),s=r(1),o=function(e){function t(t,r,i){var o=t.createOutgoingRequestMessage(n.C.NOTIFY,i);return e.call(this,s.NonInviteClientTransaction,t.userAgentCore,o,r)||this}return i.__extends(t,e),t}(r(3).UserAgentClient);t.NotifyUserAgentClient=o},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=r(0),n=r(2),s=r(1),o=function(e){function t(t,r,i){var o,a=t.createOutgoingRequestMessage(n.C.PRACK,i);return o=e.call(this,s.NonInviteClientTransaction,t.userAgentCore,a,r)||this,t.signalingStateTransition(a),o}return i.__extends(t,e),t}(r(3).UserAgentClient);t.PrackUserAgentClient=o},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=r(0),n=r(1),s=function(e){function t(t,r,i){var s=e.call(this,n.NonInviteServerTransaction,t.userAgentCore,r,i)||this;return t.signalingStateTransition(r),s.dialog=t,s}return i.__extends(t,e),t.prototype.accept=function(t){return void 0===t&&(t={statusCode:200}),t.body&&this.dialog.signalingStateTransition(t.body),e.prototype.accept.call(this,t)},t}(r(4).UserAgentServer);t.PrackUserAgentServer=s},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=r(0),n=r(2),s=r(1),o=function(e){function t(t,r,i){var o=this,a=t.createOutgoingRequestMessage(n.C.INVITE,i);return(o=e.call(this,s.InviteClientTransaction,t.userAgentCore,a,r)||this).delegate=r,t.signalingStateTransition(a),t.reinviteUserAgentClient=o,o.dialog=t,o}return i.__extends(t,e),t.prototype.receiveResponse=function(e){var t=this,r=e.statusCode?e.statusCode.toString():"";if(!r)throw new Error("Response status code undefined.");switch(!0){case/^100$/.test(r):this.delegate&&this.delegate.onTrying&&this.delegate.onTrying({message:e});break;case/^1[0-9]{2}$/.test(r):this.delegate&&this.delegate.onProgress&&this.delegate.onProgress({message:e,session:this.dialog,prack:function(e){throw new Error("Unimplemented.")}});break;case/^2[0-9]{2}$/.test(r):this.dialog.signalingStateTransition(e),this.delegate&&this.delegate.onAccept&&this.delegate.onAccept({message:e,session:this.dialog,ack:function(e){return t.dialog.ack(e)}});break;case/^3[0-9]{2}$/.test(r):this.dialog.signalingStateRollback(),this.dialog.reinviteUserAgentClient=void 0,this.delegate&&this.delegate.onRedirect&&this.delegate.onRedirect({message:e});break;case/^[4-6][0-9]{2}$/.test(r):this.dialog.signalingStateRollback(),this.dialog.reinviteUserAgentClient=void 0,this.delegate&&this.delegate.onReject&&this.delegate.onReject({message:e});break;default:throw new Error("Invalid status code "+r)}},t}(r(3).UserAgentClient);t.ReInviteUserAgentClient=o},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=r(0),n=r(1),s=function(e){function t(t,r,i){var s=e.call(this,n.InviteServerTransaction,t.userAgentCore,r,i)||this;return t.reinviteUserAgentServer=s,s.dialog=t,s}return i.__extends(t,e),t.prototype.accept=function(t){void 0===t&&(t={statusCode:200}),t.extraHeaders=t.extraHeaders||[],t.extraHeaders=t.extraHeaders.concat(this.dialog.routeSet.map((function(e){return"Record-Route: "+e})));var r=e.prototype.accept.call(this,t),n=this.dialog,s=i.__assign(i.__assign({},r),{session:n});return t.body&&this.dialog.signalingStateTransition(t.body),this.dialog.reConfirm(),s},t.prototype.progress=function(t){void 0===t&&(t={statusCode:180});var r=e.prototype.progress.call(this,t),n=this.dialog,s=i.__assign(i.__assign({},r),{session:n});return t.body&&this.dialog.signalingStateTransition(t.body),s},t.prototype.redirect=function(e,t){throw void 0===t&&(t={statusCode:302}),this.dialog.signalingStateRollback(),this.dialog.reinviteUserAgentServer=void 0,new Error("Unimplemented.")},t.prototype.reject=function(t){return void 0===t&&(t={statusCode:488}),this.dialog.signalingStateRollback(),this.dialog.reinviteUserAgentServer=void 0,e.prototype.reject.call(this,t)},t}(r(4).UserAgentServer);t.ReInviteUserAgentServer=s},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=r(0),n=r(2),s=r(1),o=function(e){function t(t,r,i){var o=t.createOutgoingRequestMessage(n.C.REFER,i);return e.call(this,s.NonInviteClientTransaction,t.userAgentCore,o,r)||this}return i.__extends(t,e),t}(r(3).UserAgentClient);t.ReferUserAgentClient=o},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=r(0),n=r(1),s=function(e){function t(t,r,i){var s=void 0!==t.userAgentCore?t.userAgentCore:t;return e.call(this,n.NonInviteServerTransaction,s,r,i)||this}return i.__extends(t,e),t}(r(4).UserAgentServer);t.ReferUserAgentServer=s},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=r(0),n=r(2),s=r(27),o=r(6),a=r(14),c=r(26),u=r(48),d=function(e){function t(t,r,i,n,s,o){var a=e.call(this,n,s)||this;return a.delegate=o,a._autoRefresh=!1,a._subscriptionEvent=t,a._subscriptionExpires=r,a._subscriptionExpiresInitial=r,a._subscriptionExpiresLastSet=Math.floor(Date.now()/1e3),a._subscriptionRefresh=void 0,a._subscriptionRefreshLastSet=void 0,a._subscriptionState=i,a.logger=n.loggerFactory.getLogger("sip.subscribe-dialog"),a.logger.log("SUBSCRIBE dialog "+a.id+" constructed"),a}return i.__extends(t,e),t.initialDialogStateForSubscription=function(e,t){var r=t.getHeaders("record-route"),i=t.parseHeader("contact");if(!i)throw new Error("Contact undefined.");if(!(i instanceof n.NameAddrHeader))throw new Error("Contact not instance of NameAddrHeader.");var s=i.uri,o=e.cseq,a=e.callId,c=e.fromTag,u=t.fromTag;if(!a)throw new Error("Call id undefined.");if(!c)throw new Error("From tag undefined.");if(!u)throw new Error("To tag undefined.");if(!e.from)throw new Error("From undefined.");if(!e.to)throw new Error("To undefined.");return{id:a+c+u,early:!1,callId:a,localTag:c,remoteTag:u,localSequenceNumber:o,remoteSequenceNumber:void 0,localURI:e.from.uri,remoteURI:e.to.uri,remoteTarget:s,routeSet:r,secure:!1}},t.prototype.dispose=function(){e.prototype.dispose.call(this),this.N&&(clearTimeout(this.N),this.N=void 0),this.refreshTimerClear(),this.logger.log("SUBSCRIBE dialog "+this.id+" destroyed")},Object.defineProperty(t.prototype,"autoRefresh",{get:function(){return this._autoRefresh},set:function(e){this._autoRefresh=!0,this.refreshTimerSet()},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"subscriptionEvent",{get:function(){return this._subscriptionEvent},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"subscriptionExpires",{get:function(){var e=Math.floor(Date.now()/1e3)-this._subscriptionExpiresLastSet,t=this._subscriptionExpires-e;return Math.max(t,0)},set:function(e){if(e<0)throw new Error("Expires must be greater than or equal to zero.");if(this._subscriptionExpires=e,this._subscriptionExpiresLastSet=Math.floor(Date.now()/1e3),this.autoRefresh){var t=this.subscriptionRefresh;(void 0===t||t>=e)&&this.refreshTimerSet()}},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"subscriptionExpiresInitial",{get:function(){return this._subscriptionExpiresInitial},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"subscriptionRefresh",{get:function(){if(void 0!==this._subscriptionRefresh&&void 0!==this._subscriptionRefreshLastSet){var e=Math.floor(Date.now()/1e3)-this._subscriptionRefreshLastSet,t=this._subscriptionRefresh-e;return Math.max(t,0)}},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"subscriptionState",{get:function(){return this._subscriptionState},enumerable:!0,configurable:!0}),t.prototype.receiveRequest=function(t){if(this.logger.log("SUBSCRIBE dialog "+this.id+" received "+t.method+" request"),this.sequenceGuard(t))switch(e.prototype.receiveRequest.call(this,t),t.method){case n.C.NOTIFY:this.onNotify(t);break;default:this.logger.log("SUBSCRIBE dialog "+this.id+" received unimplemented "+t.method+" request"),this.core.replyStateless(t,{statusCode:501})}else this.logger.log("SUBSCRIBE dialog "+this.id+" rejected out of order "+t.method+" request.")},t.prototype.refresh=function(){var e="Allow: "+a.AllowedMethods.toString(),t={};return t.extraHeaders=(t.extraHeaders||[]).slice(),t.extraHeaders.push(e),t.extraHeaders.push("Event: "+this.subscriptionEvent),t.extraHeaders.push("Expires: "+this.subscriptionExpiresInitial),t.extraHeaders.push("Contact: "+this.core.configuration.contact.toString()),this.subscribe(void 0,t)},t.prototype.subscribe=function(e,t){var r=this;if(void 0===t&&(t={}),this.subscriptionState!==s.SubscriptionState.Pending&&this.subscriptionState!==s.SubscriptionState.Active)throw new Error("Invalid state "+this.subscriptionState+'. May only re-subscribe while in state "pending" or "active".');this.logger.log("SUBSCRIBE dialog "+this.id+" sending SUBSCRIBE request");var i=new u.ReSubscribeUserAgentClient(this,e,t);return this.N=setTimeout((function(){return r.timer_N()}),o.Timers.TIMER_N),i},t.prototype.terminate=function(){this.stateTransition(s.SubscriptionState.Terminated),this.onTerminated()},t.prototype.unsubscribe=function(){var e="Allow: "+a.AllowedMethods.toString(),t={};return t.extraHeaders=(t.extraHeaders||[]).slice(),t.extraHeaders.push(e),t.extraHeaders.push("Event: "+this.subscriptionEvent),t.extraHeaders.push("Expires: 0"),t.extraHeaders.push("Contact: "+this.core.configuration.contact.toString()),this.subscribe(void 0,t)},t.prototype.onNotify=function(e){var t=e.parseHeader("Event").event;if(t&&t===this.subscriptionEvent){this.N&&(clearTimeout(this.N),this.N=void 0);var r=e.parseHeader("Subscription-State");if(r&&r.state){var i=r.state,n=r.expires?Math.max(r.expires,0):void 0;switch(i){case"pending":this.stateTransition(s.SubscriptionState.Pending,n);break;case"active":this.stateTransition(s.SubscriptionState.Active,n);break;case"terminated":this.stateTransition(s.SubscriptionState.Terminated,n);break;default:this.logger.warn("Unrecognized subscription state.")}var o=new c.NotifyUserAgentServer(this,e);this.delegate&&this.delegate.onNotify?this.delegate.onNotify(o):o.accept()}else this.core.replyStateless(e,{statusCode:489})}else this.core.replyStateless(e,{statusCode:489})},t.prototype.onRefresh=function(e){this.delegate&&this.delegate.onRefresh&&this.delegate.onRefresh(e)},t.prototype.onTerminated=function(){this.delegate&&this.delegate.onTerminated&&this.delegate.onTerminated()},t.prototype.refreshTimerClear=function(){this.refreshTimer&&(clearTimeout(this.refreshTimer),this.refreshTimer=void 0)},t.prototype.refreshTimerSet=function(){var e=this;if(this.refreshTimerClear(),this.autoRefresh&&this.subscriptionExpires>0){var t=900*this.subscriptionExpires;this._subscriptionRefresh=Math.floor(t/1e3),this._subscriptionRefreshLastSet=Math.floor(Date.now()/1e3),this.refreshTimer=setTimeout((function(){e.refreshTimer=void 0,e._subscriptionRefresh=void 0,e._subscriptionRefreshLastSet=void 0,e.onRefresh(e.refresh())}),t)}},t.prototype.stateTransition=function(e,t){var r=this,i=function(){r.logger.warn("Invalid subscription state transition from "+r.subscriptionState+" to "+e)};switch(e){case s.SubscriptionState.Initial:case s.SubscriptionState.NotifyWait:return void i();case s.SubscriptionState.Pending:if(this.subscriptionState!==s.SubscriptionState.NotifyWait&&this.subscriptionState!==s.SubscriptionState.Pending)return void i();break;case s.SubscriptionState.Active:case s.SubscriptionState.Terminated:if(this.subscriptionState!==s.SubscriptionState.NotifyWait&&this.subscriptionState!==s.SubscriptionState.Pending&&this.subscriptionState!==s.SubscriptionState.Active)return void i();break;default:return void i()}e===s.SubscriptionState.Pending&&t&&(this.subscriptionExpires=t),e===s.SubscriptionState.Active&&t&&(this.subscriptionExpires=t),e===s.SubscriptionState.Terminated&&this.dispose(),this._subscriptionState=e},t.prototype.timer_N=function(){this.subscriptionState!==s.SubscriptionState.Terminated&&(this.stateTransition(s.SubscriptionState.Terminated),this.onTerminated())},t}(r(18).Dialog);t.SubscriptionDialog=d},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=r(0),n=r(2),s=r(1),o=function(e){function t(t,r,i){var o=this,a=t.createOutgoingRequestMessage(n.C.SUBSCRIBE,i);return(o=e.call(this,s.NonInviteClientTransaction,t.userAgentCore,a,r)||this).dialog=t,o}return i.__extends(t,e),t.prototype.waitNotifyStop=function(){},t.prototype.receiveResponse=function(t){if(t.statusCode&&t.statusCode>=200&&t.statusCode<300){var r=t.getHeader("Expires");if(r){var i=Number(r);this.dialog.subscriptionExpires>i&&(this.dialog.subscriptionExpires=i)}else this.logger.warn("Expires header missing in a 200-class response to SUBSCRIBE")}if(t.statusCode&&t.statusCode>=400&&t.statusCode<700){-1!==[404,405,410,416,480,481,482,483,484,485,489,501,604].indexOf(t.statusCode)&&this.dialog.terminate()}e.prototype.receiveResponse.call(this,t)},t}(r(3).UserAgentClient);t.ReSubscribeUserAgentClient=o},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=r(28),n=function(){function e(e,t,r){this.logger=e,this.category=t,this.label=r}return e.prototype.error=function(e){this.genericLog(i.Levels.error,e)},e.prototype.warn=function(e){this.genericLog(i.Levels.warn,e)},e.prototype.log=function(e){this.genericLog(i.Levels.log,e)},e.prototype.debug=function(e){this.genericLog(i.Levels.debug,e)},e.prototype.genericLog=function(e,t){this.logger.genericLog(e,this.category,this.label,t)},e}();t.Logger=n},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=r(0);i.__exportStar(r(36),t),i.__exportStar(r(37),t),i.__exportStar(r(75),t),i.__exportStar(r(38),t),i.__exportStar(r(39),t),i.__exportStar(r(76),t),i.__exportStar(r(77),t),i.__exportStar(r(78),t),i.__exportStar(r(79),t),i.__exportStar(r(40),t),i.__exportStar(r(26),t),i.__exportStar(r(80),t),i.__exportStar(r(41),t),i.__exportStar(r(42),t),i.__exportStar(r(43),t),i.__exportStar(r(44),t),i.__exportStar(r(48),t),i.__exportStar(r(81),t),i.__exportStar(r(45),t),i.__exportStar(r(46),t),i.__exportStar(r(82),t),i.__exportStar(r(83),t),i.__exportStar(r(84),t),i.__exportStar(r(85),t),i.__exportStar(r(3),t),i.__exportStar(r(4),t)},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=r(0),n=r(7),s=r(11),o=r(5),a=r(8),c=r(9),u=function(e){function t(r,i,n,s){var o=e.call(this)||this;return o.data={},t.initializer(o,r,i,n,s),o}return i.__extends(t,e),t.initializer=function(e,t,r,i,n){if(e.type=a.TypeStrings.ClientContext,void 0===i)throw new TypeError("Not enough arguments");e.ua=t,e.logger=t.getLogger("sip.clientcontext"),e.method=r;var s=t.normalizeTarget(i);if(!s)throw new TypeError("Invalid target: "+i);var u=t.userAgentCore.configuration.aor;if(n&&n.params&&n.params.fromUri&&!(u="string"==typeof n.params.fromUri?o.Grammar.URIParse(n.params.fromUri):n.params.fromUri))throw new TypeError("Invalid from URI: "+n.params.fromUri);var d=s;if(n&&n.params&&n.params.toUri&&!(d="string"==typeof n.params.toUri?o.Grammar.URIParse(n.params.toUri):n.params.toUri))throw new TypeError("Invalid to URI: "+n.params.toUri);var p,l,h=((n=(n=Object.create(n||Object.prototype))||{}).extraHeaders||[]).slice(),g=n.params||{};n.body&&(p={body:n.body,contentType:n.contentType?n.contentType:"application/sdp"},e.body=p),p&&(l=c.Utils.fromBodyObj(p)),e.request=t.userAgentCore.makeOutgoingRequestMessage(r,s,u,d,g,h,l),e.request.from&&(e.localIdentity=e.request.from),e.request.to&&(e.remoteIdentity=e.request.to)},t.prototype.send=function(){var e=this;return this.ua.userAgentCore.request(this.request,{onAccept:function(t){return e.receiveResponse(t.message)},onProgress:function(t){return e.receiveResponse(t.message)},onRedirect:function(t){return e.receiveResponse(t.message)},onReject:function(t){return e.receiveResponse(t.message)},onTrying:function(t){return e.receiveResponse(t.message)}}),this},t.prototype.receiveResponse=function(e){var t=e.statusCode||0,r=c.Utils.getReasonPhrase(t);switch(!0){case/^1[0-9]{2}$/.test(t.toString()):this.emit("progress",e,r);break;case/^2[0-9]{2}$/.test(t.toString()):this.ua.applicants[this.toString()]&&delete this.ua.applicants[this.toString()],this.emit("accepted",e,r);break;default:this.ua.applicants[this.toString()]&&delete this.ua.applicants[this.toString()],this.emit("rejected",e,r),this.emit("failed",e,r)}},t.prototype.onRequestTimeout=function(){this.emit("failed",void 0,s.C.causes.REQUEST_TIMEOUT)},t.prototype.onTransportError=function(){this.emit("failed",void 0,s.C.causes.CONNECTION_ERROR)},t}(n.EventEmitter);t.ClientContext=u},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=r(0),n=r(7),s=r(11),o=r(5),a=r(14),c=r(8),u=r(12),d=r(9),p=r(53),l=r(92),h=r(54),g=r(93),f=r(31),m=function(e){function t(t,r){void 0===r&&(r={});var i=e.call(this)||this;return i.type=c.TypeStrings.Session,i.method=s.C.INVITE,i.localHold=!1,i.status=c.SessionStatus.STATUS_NULL,i.isFailed=!1,i.rel100=s.C.supported.UNSUPPORTED,i.expiresTimer=void 0,i.userNoAnswerTimer=void 0,i._state=f.SessionState.Initial,i._stateEventEmitter=new n.EventEmitter,i.pendingReinvite=!1,i.tones=void 0,i.userAgent=t,i.delegate=r.delegate,i.logger=t.getLogger("sip.session"),i}return i.__extends(t,e),t.prototype.close=function(){if(this.logger.log("Session["+this.id+"].close"),this.status!==c.SessionStatus.STATUS_TERMINATED){if(this._sessionDescriptionHandler&&this._sessionDescriptionHandler.close(),this.expiresTimer&&clearTimeout(this.expiresTimer),this.userNoAnswerTimer&&clearTimeout(this.userNoAnswerTimer),this.status=c.SessionStatus.STATUS_TERMINATED,!this.id)throw new Error("Session id undefined.");delete this.userAgent.sessions[this.id]}},t.prototype.on=function(t,r){return e.prototype.on.call(this,t,r)},t.prototype.emit=function(t){for(var r=[],n=1;n<arguments.length;n++)r[n-1]=arguments[n];return e.prototype.emit.apply(this,i.__spreadArrays([t],r))},Object.defineProperty(t.prototype,"sessionDescriptionHandler",{get:function(){return this._sessionDescriptionHandler},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"sessionDescriptionHandlerFactory",{get:function(){return this.userAgent.configuration.sessionDescriptionHandlerFactory},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"state",{get:function(){return this._state},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"stateChange",{get:function(){return p.makeEmitter(this._stateEventEmitter)},enumerable:!0,configurable:!0}),t.prototype.invite=function(e){var t=this;if(void 0===e&&(e={}),this.logger.log("Session.invite"),this.state!==f.SessionState.Established)return Promise.reject(new Error("Invalid session state "+this.state));if(this.pendingReinvite)return Promise.reject(new Error("Reinvite in progress. Please wait until complete, then try again."));if(!this._sessionDescriptionHandler)throw new Error("Session description handler undefined.");this.pendingReinvite=!0;var r={onAccept:function(r){var i=o.getBody(r.message);if(!i)return t.logger.error("Received 2xx response to re-INVITE without a session description"),t.ackAndBye(r,400,"Missing session description"),t.stateTransition(f.SessionState.Terminated),t.isFailed=!0,void(t.pendingReinvite=!1);if(e.withoutSdp){var n={sessionDescriptionHandlerOptions:e.sessionDescriptionHandlerOptions,sessionDescriptionHandlerModifiers:e.sessionDescriptionHandlerModifiers};t.setOfferAndGetAnswer(i,n).then((function(e){r.ack({body:e})})).catch((function(e){t.logger.error("Failed to handle offer in 2xx response to re-INVITE"),t.logger.error(e.message),t.state===f.SessionState.Terminated?r.ack():(t.ackAndBye(r,488,"Bad Media Description"),t.stateTransition(f.SessionState.Terminated),t.isFailed=!0)})).then((function(){t.pendingReinvite=!1,e.requestDelegate&&e.requestDelegate.onAccept&&e.requestDelegate.onAccept(r)}))}else{n={sessionDescriptionHandlerOptions:t.sessionDescriptionHandlerOptions,sessionDescriptionHandlerModifiers:t.sessionDescriptionHandlerModifiers};t.setAnswer(i,n).then((function(){r.ack()})).catch((function(e){t.logger.error("Failed to handle answer in 2xx response to re-INVITE"),t.logger.error(e.message),t.state!==f.SessionState.Terminated?(t.ackAndBye(r,488,"Bad Media Description"),t.stateTransition(f.SessionState.Terminated),t.isFailed=!0):r.ack()})).then((function(){t.pendingReinvite=!1,e.requestDelegate&&e.requestDelegate.onAccept&&e.requestDelegate.onAccept(r)}))}},onProgress:function(e){},onRedirect:function(e){},onReject:function(r){t.logger.warn("Received a non-2xx response to re-INVITE"),t.pendingReinvite=!1,e.withoutSdp?e.requestDelegate&&e.requestDelegate.onReject&&e.requestDelegate.onReject(r):t.rollbackOffer().catch((function(e){if(t.logger.error("Failed to rollback offer on non-2xx response to re-INVITE"),t.logger.error(e.message),t.state!==f.SessionState.Terminated){if(!t.dialog)throw new Error("Dialog undefined.");var r=[];r.push("Reason: "+d.Utils.getReasonHeaderValue(500,"Internal Server Error")),t.dialog.bye(void 0,{extraHeaders:r}),t.stateTransition(f.SessionState.Terminated),t.isFailed=!0}})).then((function(){e.requestDelegate&&e.requestDelegate.onReject&&e.requestDelegate.onReject(r)}))},onTrying:function(e){}},i=e.requestOptions||{};if(i.extraHeaders=(i.extraHeaders||[]).slice(),i.extraHeaders.push("Allow: "+a.AllowedMethods.toString()),i.extraHeaders.push("Contact: "+this.contact),e.withoutSdp)return this.dialog?Promise.resolve(this.dialog.invite(r,i)):(this.pendingReinvite=!1,Promise.reject(new Error("Dialog undefined.")));var n={sessionDescriptionHandlerOptions:e.sessionDescriptionHandlerOptions,sessionDescriptionHandlerModifiers:e.sessionDescriptionHandlerModifiers};return this.getOffer(n).then((function(e){if(!t.dialog)throw t.pendingReinvite=!1,new Error("Dialog undefined.");return i.body=e,t.dialog.invite(r,i)})).catch((function(e){throw t.logger.error(e.message),t.logger.error("Failed to send re-INVITE"),t.pendingReinvite=!1,e}))},t.prototype.bye=function(e,t){var r=this;if(!this.dialog)return Promise.reject(new Error("Session dialog undefined."));var i=this.dialog;switch(i.sessionState){case o.SessionState.Initial:case o.SessionState.Early:throw new Error("Invalid dialog state "+i.sessionState);case o.SessionState.AckWait:return this.stateTransition(f.SessionState.Terminating),new Promise((function(n,s){i.delegate={onAck:function(){var s=i.bye(e,t);r.stateTransition(f.SessionState.Terminated),n(s)},onAckTimeout:function(){var s=i.bye(e,t);r.stateTransition(f.SessionState.Terminated),n(s)}}}));case o.SessionState.Confirmed:var n=i.bye(e,t);return this.stateTransition(f.SessionState.Terminated),Promise.resolve(n);case o.SessionState.Terminated:throw new Error("Invalid dialog state "+i.sessionState);default:throw new Error("Unrecognized state.")}},t.prototype.info=function(e,t){return this.dialog?Promise.resolve(this.dialog.info(e,t)):Promise.reject(new Error("Session dialog undefined."))},t.prototype.refer=function(e,t,r){return this.dialog?(this.referrer=e,Promise.resolve(this.dialog.refer(t,r))):Promise.reject(new Error("Session dialog undefined."))},t.prototype.ackAndBye=function(e,t,r){e.ack();var i=[];t&&i.push("Reason: "+d.Utils.getReasonHeaderValue(t,r)),e.session.bye(void 0,{extraHeaders:i})},t.prototype.onAckRequest=function(e){var t=this;if(this.logger.log("Session.onAckRequest"),this.state===f.SessionState.Initial||this.state===f.SessionState.Establishing||this.state===f.SessionState.Established||this.state===f.SessionState.Terminating){this.state!==f.SessionState.Initial&&this.state!==f.SessionState.Establishing||this.stateTransition(f.SessionState.Established);var r=this.dialog;if(!r)throw new Error("Dialog undefined.");switch(r.signalingState){case o.SignalingState.Initial:this.logger.error("Invalid signaling state "+r.signalingState+"."),this.isFailed=!0;var i=["Reason: "+d.Utils.getReasonHeaderValue(488,"Bad Media Description")];return r.bye(void 0,{extraHeaders:i}),void this.stateTransition(f.SessionState.Terminated);case o.SignalingState.Stable:var n=o.getBody(e.message);if(!n)return void(this.status=c.SessionStatus.STATUS_CONFIRMED);if("render"===n.contentDisposition)return this.renderbody=n.content,this.rendertype=n.contentType,void(this.status=c.SessionStatus.STATUS_CONFIRMED);if("session"!==n.contentDisposition)return void(this.status=c.SessionStatus.STATUS_CONFIRMED);var s={sessionDescriptionHandlerOptions:this.sessionDescriptionHandlerOptions,sessionDescriptionHandlerModifiers:this.sessionDescriptionHandlerModifiers};return void this.setAnswer(n,s).then((function(){t.status=c.SessionStatus.STATUS_CONFIRMED})).catch((function(e){t.logger.error(e.message),t.isFailed=!0;var i=["Reason: "+d.Utils.getReasonHeaderValue(488,"Bad Media Description")];r.bye(void 0,{extraHeaders:i}),t.stateTransition(f.SessionState.Terminated)}));case o.SignalingState.HaveLocalOffer:case o.SignalingState.HaveRemoteOffer:this.logger.error("Invalid signaling state "+r.signalingState+"."),this.isFailed=!0;i=["Reason: "+d.Utils.getReasonHeaderValue(488,"Bad Media Description")];return r.bye(void 0,{extraHeaders:i}),void this.stateTransition(f.SessionState.Terminated);case o.SignalingState.Closed:default:throw new Error("Invalid signaling state "+r.signalingState+".")}}else this.logger.error("ACK received while in state "+this.state+", dropping request")},t.prototype.onByeRequest=function(e){this.logger.log("Session.onByeRequest"),this.state===f.SessionState.Established?(e.accept(),this.stateTransition(f.SessionState.Terminated)):this.logger.error("BYE received while in state "+this.state+", dropping request")},t.prototype.onInfoRequest=function(e){if(this.logger.log("Session.onInfoRequest"),this.state===f.SessionState.Established)if(this.delegate&&this.delegate.onInfo){var t=new l.Info(e);this.delegate.onInfo(t)}else e.accept();else this.logger.error("INFO received while in state "+this.state+", dropping request")},t.prototype.onInviteRequest=function(e){var t=this;if(this.logger.log("Session.onInviteRequest"),this.state===f.SessionState.Established){var r=["Contact: "+this.contact];if(e.message.hasHeader("P-Asserted-Identity")){var i=e.message.getHeader("P-Asserted-Identity");if(!i)throw new Error("Header undefined.");this.assertedIdentity=o.Grammar.nameAddrHeaderParse(i)}var n={sessionDescriptionHandlerOptions:this.sessionDescriptionHandlerOptions,sessionDescriptionHandlerModifiers:this.sessionDescriptionHandlerModifiers};this.generateResponseOfferAnswerInDialog(n).then((function(i){var n=e.accept({statusCode:200,extraHeaders:r,body:i});t.delegate&&t.delegate.onInvite&&t.delegate.onInvite(e.message,n.message,200)})).catch((function(i){if(t.logger.error(i.message),t.logger.error("Failed to handle to re-INVITE request"),!t.dialog)throw new Error("Dialog undefined.");if(t.logger.error(t.dialog.signalingState),t.dialog.signalingState!==o.SignalingState.Stable)t.rollbackOffer().then((function(){var r=e.reject({statusCode:488});t.delegate&&t.delegate.onInvite&&t.delegate.onInvite(e.message,r.message,488)})).catch((function(i){t.logger.error(i.message),t.logger.error("Failed to rollback offer on re-INVITE request");var n=e.reject({statusCode:488});if(t.state!==f.SessionState.Terminated){if(!t.dialog)throw new Error("Dialog undefined.");[].push("Reason: "+d.Utils.getReasonHeaderValue(500,"Internal Server Error")),t.dialog.bye(void 0,{extraHeaders:r}),t.stateTransition(f.SessionState.Terminated),t.isFailed=!0}t.delegate&&t.delegate.onInvite&&t.delegate.onInvite(e.message,n.message,488)}));else{var n=e.reject({statusCode:488});t.delegate&&t.delegate.onInvite&&t.delegate.onInvite(e.message,n.message,488)}}))}else this.logger.error("INVITE received while in state "+this.state+", dropping request")},t.prototype.onNotifyRequest=function(e){if(this.logger.log("Session.onNotifyRequest"),this.state===f.SessionState.Established)if(this.referrer&&this.referrer.delegate&&this.referrer.delegate.onNotify){var t=new h.Notification(e);this.referrer.delegate.onNotify(t)}else if(this.delegate&&this.delegate.onNotify){t=new h.Notification(e);this.delegate.onNotify(t)}else e.accept();else this.logger.error("NOTIFY received while in state "+this.state+", dropping request")},t.prototype.onPrackRequest=function(e){if(this.logger.log("Session.onPrackRequest"),this.state===f.SessionState.Established)throw new Error("Unimplemented.");this.logger.error("PRACK received while in state "+this.state+", dropping request")},t.prototype.onReferRequest=function(e){var t=this;if(this.logger.log("Session.onReferRequest"),this.state===f.SessionState.Established){if(this.status===c.SessionStatus.STATUS_CONFIRMED){if(!e.message.hasHeader("refer-to"))return this.logger.warn("Invalid REFER packet. A refer-to header is required. Rejecting."),void e.reject();var r=new g.Referral(e,this);this.delegate&&this.delegate.onRefer?this.delegate.onRefer(r):(this.logger.log("No delegate available to handle REFER, automatically accepting and following."),r.accept().then((function(){return r.makeInviter(t.passedOptions).invite()})).catch((function(e){t.logger.error(e.message)})))}}else this.logger.error("REFER received while in state "+this.state+", dropping request")},t.prototype.generateResponseOfferAnswer=function(e,t){if(this.dialog)return this.generateResponseOfferAnswerInDialog(t);var r=o.getBody(e.message);return r&&"session"===r.contentDisposition?this.setOfferAndGetAnswer(r,t):this.getOffer(t)},t.prototype.generateResponseOfferAnswerInDialog=function(e){if(!this.dialog)throw new Error("Dialog undefined.");switch(this.dialog.signalingState){case o.SignalingState.Initial:return this.getOffer(e);case o.SignalingState.HaveLocalOffer:return Promise.resolve(void 0);case o.SignalingState.HaveRemoteOffer:if(!this.dialog.offer)throw new Error("Session offer undefined in signaling state "+this.dialog.signalingState+".");return this.setOfferAndGetAnswer(this.dialog.offer,e);case o.SignalingState.Stable:return this.state!==f.SessionState.Established?Promise.resolve(void 0):this.getOffer(e);case o.SignalingState.Closed:default:throw new Error("Invalid signaling state "+this.dialog.signalingState+".")}},t.prototype.getOffer=function(e){var t=this,r=this.setupSessionDescriptionHandler(),i=e.sessionDescriptionHandlerOptions,n=e.sessionDescriptionHandlerModifiers;try{return r.getDescription(i,n).then((function(e){return d.Utils.fromBodyObj(e)})).catch((function(e){t.logger.error("Session.getOffer: SDH getDescription rejected...");var r=e instanceof Error?e:new Error(e);throw t.logger.error(r.message),r}))}catch(e){this.logger.error("Session.getOffer: SDH getDescription threw...");var s=e instanceof Error?e:new Error(e);return this.logger.error(s.message),Promise.reject(s)}},t.prototype.rollbackOffer=function(){var e=this,t=this.setupSessionDescriptionHandler();if(!t.rollbackDescription)return Promise.resolve();try{return t.rollbackDescription().catch((function(t){e.logger.error("Session.rollbackOffer: SDH rollbackDescription rejected...");var r=t instanceof Error?t:new Error(t);throw e.logger.error(r.message),r}))}catch(e){this.logger.error("Session.rollbackOffer: SDH rollbackDescription threw...");var r=e instanceof Error?e:new Error(e);return this.logger.error(r.message),Promise.reject(r)}},t.prototype.setAnswer=function(e,t){var r=this,i=this.setupSessionDescriptionHandler(),n=t.sessionDescriptionHandlerOptions,s=t.sessionDescriptionHandlerModifiers;try{if(!i.hasDescription(e.contentType))return Promise.reject(new u.Exceptions.UnsupportedSessionDescriptionContentTypeError)}catch(e){this.logger.error("Session.setAnswer: SDH hasDescription threw...");var o=e instanceof Error?e:new Error(e);return this.logger.error(o.message),Promise.reject(o)}try{return i.setDescription(e.content,n,s).catch((function(e){r.logger.error("Session.setAnswer: SDH setDescription rejected...");var t=e instanceof Error?e:new Error(e);throw r.logger.error(t.message),t}))}catch(e){this.logger.error("Session.setAnswer: SDH setDescription threw...");o=e instanceof Error?e:new Error(e);return this.logger.error(o.message),Promise.reject(o)}},t.prototype.setOfferAndGetAnswer=function(e,t){var r=this,i=this.setupSessionDescriptionHandler(),n=t.sessionDescriptionHandlerOptions,s=t.sessionDescriptionHandlerModifiers;try{if(!i.hasDescription(e.contentType))return Promise.reject(new u.Exceptions.UnsupportedSessionDescriptionContentTypeError)}catch(e){this.logger.error("Session.setOfferAndGetAnswer: SDH hasDescription threw...");var o=e instanceof Error?e:new Error(e);return this.logger.error(o.message),Promise.reject(o)}try{return i.setDescription(e.content,n,s).then((function(){return i.getDescription(n,s)})).then((function(e){return d.Utils.fromBodyObj(e)})).catch((function(e){r.logger.error("Session.setOfferAndGetAnswer: SDH setDescription or getDescription rejected...");var t=e instanceof Error?e:new Error(e);throw r.logger.error(t.message),t}))}catch(e){this.logger.error("Session.setOfferAndGetAnswer: SDH setDescription or getDescription threw...");o=e instanceof Error?e:new Error(e);return this.logger.error(o.message),Promise.reject(o)}},t.prototype.setSessionDescriptionHandler=function(e){if(this._sessionDescriptionHandler)throw new Error("Sessionn description handler defined.");this._sessionDescriptionHandler=e},t.prototype.setupSessionDescriptionHandler=function(){return this._sessionDescriptionHandler?this._sessionDescriptionHandler:(this._sessionDescriptionHandler=this.sessionDescriptionHandlerFactory(this,this.userAgent.configuration.sessionDescriptionHandlerFactoryOptions),this.emit("SessionDescriptionHandler-created",this._sessionDescriptionHandler),this._sessionDescriptionHandler)},t.prototype.stateTransition=function(e){var t=this,r=function(){throw new Error("Invalid state transition from "+t._state+" to "+e)};switch(this._state){case f.SessionState.Initial:e!==f.SessionState.Establishing&&e!==f.SessionState.Established&&e!==f.SessionState.Terminating&&e!==f.SessionState.Terminated&&r();break;case f.SessionState.Establishing:e!==f.SessionState.Established&&e!==f.SessionState.Terminating&&e!==f.SessionState.Terminated&&r();break;case f.SessionState.Established:e!==f.SessionState.Terminating&&e!==f.SessionState.Terminated&&r();break;case f.SessionState.Terminating:e!==f.SessionState.Terminated&&r();break;case f.SessionState.Terminated:r();break;default:throw new Error("Unrecognized state.")}e===f.SessionState.Established&&(this.startTime=new Date),e===f.SessionState.Terminated&&(this.endTime=new Date,this.close()),this._state=e,this.logger.log("Session "+this.id+" transitioned to state "+this._state),this._stateEventEmitter.emit("event",this._state)},t.C=c.SessionStatus,t}(n.EventEmitter);t.Session=m},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.makeEmitter=function(e,t){return void 0===t&&(t="event"),{on:function(r){e.on(t,r)},off:function(r){e.removeListener(t,r)},once:function(r){e.once(t,r)}}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=function(){function e(e){this.incomingNotifyRequest=e}return Object.defineProperty(e.prototype,"request",{get:function(){return this.incomingNotifyRequest.message},enumerable:!0,configurable:!0}),e.prototype.accept=function(e){return this.incomingNotifyRequest.accept(e),Promise.resolve()},e.prototype.reject=function(e){return this.incomingNotifyRequest.reject(e),Promise.resolve()},e}();t.Notification=i},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),r(0).__exportStar(r(56),t)},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),function(e){e.ACK="ACK",e.BYE="BYE",e.CANCEL="CANCEL",e.INFO="INFO",e.INVITE="INVITE",e.MESSAGE="MESSAGE",e.NOTIFY="NOTIFY",e.OPTIONS="OPTIONS",e.REGISTER="REGISTER",e.UPDATE="UPDATE",e.SUBSCRIBE="SUBSCRIBE",e.PUBLISH="PUBLISH",e.REFER="REFER",e.PRACK="PRACK"}(t.C||(t.C={}))},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=r(32),n=r(33),s=r(34);function o(e){return!(!e||"string"!=typeof e.content||"string"!=typeof e.contentType||void 0!==e.contentDisposition)||"string"==typeof e.contentDisposition}function a(e){return"application/sdp"===e?"session":"render"}t.fromBodyLegacy=function(e){var t="string"==typeof e?e:e.body,r="string"==typeof e?"application/sdp":e.contentType;return{contentDisposition:a(r),contentType:r,content:t}},t.getBody=function(e){var t,r,c,u;if(e instanceof i.IncomingRequestMessage&&e.body&&(t=(u=e.parseHeader("Content-Disposition"))?u.type:void 0,r=e.parseHeader("Content-Type"),c=e.body),e instanceof n.IncomingResponseMessage&&e.body&&(t=(u=e.parseHeader("Content-Disposition"))?u.type:void 0,r=e.parseHeader("Content-Type"),c=e.body),e instanceof s.OutgoingRequestMessage&&e.body)if(t=e.getHeader("Content-Disposition"),r=e.getHeader("Content-Type"),"string"==typeof e.body){if(!r)throw new Error("Header content type header does not equal body content type.");c=e.body}else{if(r&&r!==e.body.contentType)throw new Error("Header content type header does not equal body content type.");r=e.body.contentType,c=e.body.body}if(o(e)&&(t=e.contentDisposition,r=e.contentType,c=e.content),c){if(r&&!t&&(t=a(r)),!t)throw new Error("Content disposition undefined.");if(!r)throw new Error("Content type undefined.");return{contentDisposition:t,contentType:r,content:c}}},t.isBody=o},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=r(0),n=r(20),s=r(30),o=function(e){function t(r,i,n,s){var o=e.call(this)||this;return o.message=r,o.expected=i,o.found=n,o.location=s,o.name="SyntaxError","function"==typeof Error.captureStackTrace&&Error.captureStackTrace(o,t),o}return i.__extends(t,e),t.buildMessage=function(e,t){function r(e){return e.charCodeAt(0).toString(16).toUpperCase()}function i(e){return e.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,(function(e){return"\\x0"+r(e)})).replace(/[\x10-\x1F\x7F-\x9F]/g,(function(e){return"\\x"+r(e)}))}function n(e){return e.replace(/\\/g,"\\\\").replace(/\]/g,"\\]").replace(/\^/g,"\\^").replace(/-/g,"\\-").replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,(function(e){return"\\x0"+r(e)})).replace(/[\x10-\x1F\x7F-\x9F]/g,(function(e){return"\\x"+r(e)}))}function s(e){switch(e.type){case"literal":return'"'+i(e.text)+'"';case"class":var t=e.parts.map((function(e){return Array.isArray(e)?n(e[0])+"-"+n(e[1]):n(e)}));return"["+(e.inverted?"^":"")+t+"]";case"any":return"any character";case"end":return"end of input";case"other":return e.description}}return"Expected "+function(e){var t,r,i=e.map(s);if(i.sort(),i.length>0){for(t=1,r=1;t<i.length;t++)i[t-1]!==i[t]&&(i[r]=i[t],r++);i.length=r}switch(i.length){case 1:return i[0];case 2:return i[0]+" or "+i[1];default:return i.slice(0,-1).join(", ")+", or "+i[i.length-1]}}(e)+" but "+((o=t)?'"'+i(o)+'"':"end of input")+" found.";var o},t}(Error);t.SyntaxError=o,t.parse=function(e,t){t=void 0!==t?t:{};var r,i={},a={Contact:119,Name_Addr_Header:156,Record_Route:176,Request_Response:81,SIP_URI:45,Subscription_State:186,Supported:191,Require:182,Via:194,absoluteURI:84,Call_ID:118,Content_Disposition:130,Content_Length:135,Content_Type:136,CSeq:146,displayName:122,Event:149,From:151,host:52,Max_Forwards:154,Min_SE:213,Proxy_Authenticate:157,quoted_string:40,Refer_To:178,Replaces:179,Session_Expires:210,stun_URI:217,To:192,turn_URI:223,uuid:226,WWW_Authenticate:209,challenge:158,sipfrag:230,Referred_By:231},c=119,u=["\r\n",T("\r\n",!1),/^[0-9]/,y([["0","9"]],!1,!1),/^[a-zA-Z]/,y([["a","z"],["A","Z"]],!1,!1),/^[0-9a-fA-F]/,y([["0","9"],["a","f"],["A","F"]],!1,!1),/^[\0-\xFF]/,y([["\0","\xff"]],!1,!1),/^["]/,y(['"'],!1,!1)," ",T(" ",!1),"\t",T("\t",!1),/^[a-zA-Z0-9]/,y([["a","z"],["A","Z"],["0","9"]],!1,!1),";",T(";",!1),"/",T("/",!1),"?",T("?",!1),":",T(":",!1),"@",T("@",!1),"&",T("&",!1),"=",T("=",!1),"+",T("+",!1),"$",T("$",!1),",",T(",",!1),"-",T("-",!1),"_",T("_",!1),".",T(".",!1),"!",T("!",!1),"~",T("~",!1),"*",T("*",!1),"'",T("'",!1),"(",T("(",!1),")",T(")",!1),"%",T("%",!1),function(){return" "},function(){return":"},/^[!-~]/,y([["!","~"]],!1,!1),/^[\x80-\uFFFF]/,y([["\x80","\uffff"]],!1,!1),/^[\x80-\xBF]/,y([["\x80","\xbf"]],!1,!1),/^[a-f]/,y([["a","f"]],!1,!1),"`",T("`",!1),"<",T("<",!1),">",T(">",!1),"\\",T("\\",!1),"[",T("[",!1),"]",T("]",!1),"{",T("{",!1),"}",T("}",!1),function(){return"*"},function(){return"/"},function(){return"="},function(){return"("},function(){return")"},function(){return">"},function(){return"<"},function(){return","},function(){return";"},function(){return":"},function(){return'"'},/^[!-']/,y([["!","'"]],!1,!1),/^[*-[]/,y([["*","["]],!1,!1),/^[\]-~]/,y([["]","~"]],!1,!1),function(e){return e},/^[#-[]/,y([["#","["]],!1,!1),/^[\0-\t]/,y([["\0","\t"]],!1,!1),/^[\x0B-\f]/,y([["\v","\f"]],!1,!1),/^[\x0E-\x7F]/,y([["\x0e","\x7f"]],!1,!1),function(){(t=t||{data:{}}).data.uri=new s.URI(t.data.scheme,t.data.user,t.data.host,t.data.port),delete t.data.scheme,delete t.data.user,delete t.data.host,delete t.data.host_type,delete t.data.port},function(){(t=t||{data:{}}).data.uri=new s.URI(t.data.scheme,t.data.user,t.data.host,t.data.port,t.data.uri_params,t.data.uri_headers),delete t.data.scheme,delete t.data.user,delete t.data.host,delete t.data.host_type,delete t.data.port,delete t.data.uri_params,"SIP_URI"===t.startRule&&(t.data=t.data.uri)},"sips",T("sips",!0),"sip",T("sip",!0),function(e){(t=t||{data:{}}).data.scheme=e},function(){(t=t||{data:{}}).data.user=decodeURIComponent(v().slice(0,-1))},function(){(t=t||{data:{}}).data.password=v()},function(){return(t=t||{data:{}}).data.host=v(),t.data.host},function(){return(t=t||{data:{}}).data.host_type="domain",v()},/^[a-zA-Z0-9_\-]/,y([["a","z"],["A","Z"],["0","9"],"_","-"],!1,!1),/^[a-zA-Z0-9\-]/,y([["a","z"],["A","Z"],["0","9"],"-"],!1,!1),function(){return(t=t||{data:{}}).data.host_type="IPv6",v()},"::",T("::",!1),function(){return(t=t||{data:{}}).data.host_type="IPv6",v()},function(){return(t=t||{data:{}}).data.host_type="IPv4",v()},"25",T("25",!1),/^[0-5]/,y([["0","5"]],!1,!1),"2",T("2",!1),/^[0-4]/,y([["0","4"]],!1,!1),"1",T("1",!1),/^[1-9]/,y([["1","9"]],!1,!1),function(e){return t=t||{data:{}},e=parseInt(e.join("")),t.data.port=e,e},"transport=",T("transport=",!0),"udp",T("udp",!0),"tcp",T("tcp",!0),"sctp",T("sctp",!0),"tls",T("tls",!0),function(e){(t=t||{data:{}}).data.uri_params||(t.data.uri_params={}),t.data.uri_params.transport=e.toLowerCase()},"user=",T("user=",!0),"phone",T("phone",!0),"ip",T("ip",!0),function(e){(t=t||{data:{}}).data.uri_params||(t.data.uri_params={}),t.data.uri_params.user=e.toLowerCase()},"method=",T("method=",!0),function(e){(t=t||{data:{}}).data.uri_params||(t.data.uri_params={}),t.data.uri_params.method=e},"ttl=",T("ttl=",!0),function(e){(t=t||{data:{}}).data.params||(t.data.params={}),t.data.params.ttl=e},"maddr=",T("maddr=",!0),function(e){(t=t||{data:{}}).data.uri_params||(t.data.uri_params={}),t.data.uri_params.maddr=e},"lr",T("lr",!0),function(){(t=t||{data:{}}).data.uri_params||(t.data.uri_params={}),t.data.uri_params.lr=void 0},function(e,r){(t=t||{data:{}}).data.uri_params||(t.data.uri_params={}),r=null===r?void 0:r[1],t.data.uri_params[e.toLowerCase()]=r},function(e,r){e=e.join("").toLowerCase(),r=r.join(""),(t=t||{data:{}}).data.uri_headers||(t.data.uri_headers={}),t.data.uri_headers[e]?t.data.uri_headers[e].push(r):t.data.uri_headers[e]=[r]},function(){"Refer_To"===(t=t||{data:{}}).startRule&&(t.data.uri=new s.URI(t.data.scheme,t.data.user,t.data.host,t.data.port,t.data.uri_params,t.data.uri_headers),delete t.data.scheme,delete t.data.user,delete t.data.host,delete t.data.host_type,delete t.data.port,delete t.data.uri_params)},"//",T("//",!1),function(){(t=t||{data:{}}).data.scheme=v()},T("SIP",!0),function(){(t=t||{data:{}}).data.sip_version=v()},"INVITE",T("INVITE",!1),"ACK",T("ACK",!1),"VXACH",T("VXACH",!1),"OPTIONS",T("OPTIONS",!1),"BYE",T("BYE",!1),"CANCEL",T("CANCEL",!1),"REGISTER",T("REGISTER",!1),"SUBSCRIBE",T("SUBSCRIBE",!1),"NOTIFY",T("NOTIFY",!1),"REFER",T("REFER",!1),"PUBLISH",T("PUBLISH",!1),function(){return(t=t||{data:{}}).data.method=v(),t.data.method},function(e){(t=t||{data:{}}).data.status_code=parseInt(e.join(""))},function(){(t=t||{data:{}}).data.reason_phrase=v()},function(){(t=t||{data:{}}).data=v()},function(){var e,r;for(r=(t=t||{data:{}}).data.multi_header.length,e=0;e<r;e++)if(null===t.data.multi_header[e].parsed){t.data=null;break}null!==t.data?t.data=t.data.multi_header:t.data=-1},function(){var e;(t=t||{data:{}}).data.multi_header||(t.data.multi_header=[]);try{e=new n.NameAddrHeader(t.data.uri,t.data.displayName,t.data.params),delete t.data.uri,delete t.data.displayName,delete t.data.params}catch(t){e=null}t.data.multi_header.push({position:p,offset:S().start.offset,parsed:e})},function(e){'"'===(e=v().trim())[0]&&(e=e.substring(1,e.length-1)),(t=t||{data:{}}).data.displayName=e},"q",T("q",!0),function(e){(t=t||{data:{}}).data.params||(t.data.params={}),t.data.params.q=e},"expires",T("expires",!0),function(e){(t=t||{data:{}}).data.params||(t.data.params={}),t.data.params.expires=e},function(e){return parseInt(e.join(""))},"0",T("0",!1),function(){return parseFloat(v())},function(e,r){(t=t||{data:{}}).data.params||(t.data.params={}),r=null===r?void 0:r[1],t.data.params[e.toLowerCase()]=r},"render",T("render",!0),"session",T("session",!0),"icon",T("icon",!0),"alert",T("alert",!0),function(){"Content_Disposition"===(t=t||{data:{}}).startRule&&(t.data.type=v().toLowerCase())},"handling",T("handling",!0),"optional",T("optional",!0),"required",T("required",!0),function(e){(t=t||{data:{}}).data=parseInt(e.join(""))},function(){(t=t||{data:{}}).data=v()},"text",T("text",!0),"image",T("image",!0),"audio",T("audio",!0),"video",T("video",!0),"application",T("application",!0),"message",T("message",!0),"multipart",T("multipart",!0),"x-",T("x-",!0),function(e){(t=t||{data:{}}).data.value=parseInt(e.join(""))},function(e){(t=t||{data:{}}).data=e},function(e){(t=t||{data:{}}).data.event=e.toLowerCase()},function(){var e=(t=t||{data:{}}).data.tag;t.data=new n.NameAddrHeader(t.data.uri,t.data.displayName,t.data.params),e&&t.data.setParam("tag",e)},"tag",T("tag",!0),function(e){(t=t||{data:{}}).data.tag=e},function(e){(t=t||{data:{}}).data=parseInt(e.join(""))},function(e){(t=t||{data:{}}).data=e},function(){(t=t||{data:{}}).data=new n.NameAddrHeader(t.data.uri,t.data.displayName,t.data.params)},"digest",T("Digest",!0),"realm",T("realm",!0),function(e){(t=t||{data:{}}).data.realm=e},"domain",T("domain",!0),"nonce",T("nonce",!0),function(e){(t=t||{data:{}}).data.nonce=e},"opaque",T("opaque",!0),function(e){(t=t||{data:{}}).data.opaque=e},"stale",T("stale",!0),"true",T("true",!0),function(){(t=t||{data:{}}).data.stale=!0},"false",T("false",!0),function(){(t=t||{data:{}}).data.stale=!1},"algorithm",T("algorithm",!0),"md5",T("MD5",!0),"md5-sess",T("MD5-sess",!0),function(e){(t=t||{data:{}}).data.algorithm=e.toUpperCase()},"qop",T("qop",!0),"auth-int",T("auth-int",!0),"auth",T("auth",!0),function(e){(t=t||{data:{}}).data.qop||(t.data.qop=[]),t.data.qop.push(e.toLowerCase())},function(e){(t=t||{data:{}}).data.value=parseInt(e.join(""))},function(){var e,r;for(r=(t=t||{data:{}}).data.multi_header.length,e=0;e<r;e++)if(null===t.data.multi_header[e].parsed){t.data=null;break}null!==t.data?t.data=t.data.multi_header:t.data=-1},function(){var e;(t=t||{data:{}}).data.multi_header||(t.data.multi_header=[]);try{e=new n.NameAddrHeader(t.data.uri,t.data.displayName,t.data.params),delete t.data.uri,delete t.data.displayName,delete t.data.params}catch(t){e=null}t.data.multi_header.push({position:p,offset:S().start.offset,parsed:e})},function(){(t=t||{data:{}}).data=new n.NameAddrHeader(t.data.uri,t.data.displayName,t.data.params)},function(){(t=t||{data:{}}).data.replaces_from_tag&&t.data.replaces_to_tag||(t.data=-1)},function(){(t=t||{data:{}}).data={call_id:t.data}},"from-tag",T("from-tag",!0),function(e){(t=t||{data:{}}).data.replaces_from_tag=e},"to-tag",T("to-tag",!0),function(e){(t=t||{data:{}}).data.replaces_to_tag=e},"early-only",T("early-only",!0),function(){(t=t||{data:{}}).data.early_only=!0},function(e,t){return t},function(e,t){return function(e,t){return[e].concat(t)}(e,t)},function(e){"Require"===(t=t||{data:{}}).startRule&&(t.data=e||[])},function(e){(t=t||{data:{}}).data.value=parseInt(e.join(""))},"active",T("active",!0),"pending",T("pending",!0),"terminated",T("terminated",!0),function(){(t=t||{data:{}}).data.state=v()},"reason",T("reason",!0),function(e){t=t||{data:{}},void 0!==e&&(t.data.reason=e)},function(e){t=t||{data:{}},void 0!==e&&(t.data.expires=e)},"retry_after",T("retry_after",!0),function(e){t=t||{data:{}},void 0!==e&&(t.data.retry_after=e)},"deactivated",T("deactivated",!0),"probation",T("probation",!0),"rejected",T("rejected",!0),"timeout",T("timeout",!0),"giveup",T("giveup",!0),"noresource",T("noresource",!0),"invariant",T("invariant",!0),function(e){"Supported"===(t=t||{data:{}}).startRule&&(t.data=e||[])},function(){var e=(t=t||{data:{}}).data.tag;t.data=new n.NameAddrHeader(t.data.uri,t.data.displayName,t.data.params),e&&t.data.setParam("tag",e)},"ttl",T("ttl",!0),function(e){(t=t||{data:{}}).data.ttl=e},"maddr",T("maddr",!0),function(e){(t=t||{data:{}}).data.maddr=e},"received",T("received",!0),function(e){(t=t||{data:{}}).data.received=e},"branch",T("branch",!0),function(e){(t=t||{data:{}}).data.branch=e},"rport",T("rport",!0),function(e){t=t||{data:{}},void 0!==e&&(t.data.rport=e.join(""))},function(e){(t=t||{data:{}}).data.protocol=e},T("UDP",!0),T("TCP",!0),T("TLS",!0),T("SCTP",!0),function(e){(t=t||{data:{}}).data.transport=e},function(){(t=t||{data:{}}).data.host=v()},function(e){(t=t||{data:{}}).data.port=parseInt(e.join(""))},function(e){return parseInt(e.join(""))},function(e){"Session_Expires"===(t=t||{data:{}}).startRule&&(t.data.deltaSeconds=e)},"refresher",T("refresher",!1),"uas",T("uas",!1),"uac",T("uac",!1),function(e){"Session_Expires"===(t=t||{data:{}}).startRule&&(t.data.refresher=e)},function(e){"Min_SE"===(t=t||{data:{}}).startRule&&(t.data=e)},"stuns",T("stuns",!0),"stun",T("stun",!0),function(e){(t=t||{data:{}}).data.scheme=e},function(e){(t=t||{data:{}}).data.host=e},"?transport=",T("?transport=",!1),"turns",T("turns",!0),"turn",T("turn",!0),function(e){(t=t||{data:{}}).data.transport=e},function(){(t=t||{data:{}}).data=v()},"Referred-By",T("Referred-By",!1),"b",T("b",!1),"cid",T("cid",!1)],d=[_('2 ""6 7!'),_('4"""5!7#'),_('4$""5!7%'),_('4&""5!7\''),_(";'.# &;("),_('4(""5!7)'),_('4*""5!7+'),_('2,""6,7-'),_('2.""6.7/'),_('40""5!71'),_('22""6273.\x89 &24""6475.} &26""6677.q &28""6879.e &2:""6:7;.Y &2<""6<7=.M &2>""6>7?.A &2@""6@7A.5 &2B""6B7C.) &2D""6D7E'),_(";).# &;,"),_('2F""6F7G.} &2H""6H7I.q &2J""6J7K.e &2L""6L7M.Y &2N""6N7O.M &2P""6P7Q.A &2R""6R7S.5 &2T""6T7U.) &2V""6V7W'),_('%%2X""6X7Y/5#;#/,$;#/#$+#)(#\'#("\'#&\'#/"!&,)'),_('%%$;$0#*;$&/,#; /#$+")("\'#&\'#." &"/=#$;$/&#0#*;$&&&#/\'$8":Z" )("\'#&\'#'),_(';.." &"'),_("%$;'.# &;(0)*;'.# &;(&/?#28\"\"6879/0$;//'$8#:[# )(#'#(\"'#&'#"),_('%%$;2/&#0#*;2&&&#/g#$%$;.0#*;.&/,#;2/#$+")("\'#&\'#0=*%$;.0#*;.&/,#;2/#$+")("\'#&\'#&/#$+")("\'#&\'#/"!&,)'),_('4\\""5!7].# &;3'),_('4^""5!7_'),_('4`""5!7a'),_(';!.) &4b""5!7c'),_('%$;).\x95 &2F""6F7G.\x89 &2J""6J7K.} &2L""6L7M.q &2X""6X7Y.e &2P""6P7Q.Y &2H""6H7I.M &2@""6@7A.A &2d""6d7e.5 &2R""6R7S.) &2N""6N7O/\x9e#0\x9b*;).\x95 &2F""6F7G.\x89 &2J""6J7K.} &2L""6L7M.q &2X""6X7Y.e &2P""6P7Q.Y &2H""6H7I.M &2@""6@7A.A &2d""6d7e.5 &2R""6R7S.) &2N""6N7O&&&#/"!&,)'),_('%$;).\x89 &2F""6F7G.} &2L""6L7M.q &2X""6X7Y.e &2P""6P7Q.Y &2H""6H7I.M &2@""6@7A.A &2d""6d7e.5 &2R""6R7S.) &2N""6N7O/\x92#0\x8f*;).\x89 &2F""6F7G.} &2L""6L7M.q &2X""6X7Y.e &2P""6P7Q.Y &2H""6H7I.M &2@""6@7A.A &2d""6d7e.5 &2R""6R7S.) &2N""6N7O&&&#/"!&,)'),_('2T""6T7U.\xe3 &2V""6V7W.\xd7 &2f""6f7g.\xcb &2h""6h7i.\xbf &2:""6:7;.\xb3 &2D""6D7E.\xa7 &22""6273.\x9b &28""6879.\x8f &2j""6j7k.\x83 &;&.} &24""6475.q &2l""6l7m.e &2n""6n7o.Y &26""6677.M &2>""6>7?.A &2p""6p7q.5 &2r""6r7s.) &;\'.# &;('),_('%$;).\u012b &2F""6F7G.\u011f &2J""6J7K.\u0113 &2L""6L7M.\u0107 &2X""6X7Y.\xfb &2P""6P7Q.\xef &2H""6H7I.\xe3 &2@""6@7A.\xd7 &2d""6d7e.\xcb &2R""6R7S.\xbf &2N""6N7O.\xb3 &2T""6T7U.\xa7 &2V""6V7W.\x9b &2f""6f7g.\x8f &2h""6h7i.\x83 &28""6879.w &2j""6j7k.k &;&.e &24""6475.Y &2l""6l7m.M &2n""6n7o.A &26""6677.5 &2p""6p7q.) &2r""6r7s/\u0134#0\u0131*;).\u012b &2F""6F7G.\u011f &2J""6J7K.\u0113 &2L""6L7M.\u0107 &2X""6X7Y.\xfb &2P""6P7Q.\xef &2H""6H7I.\xe3 &2@""6@7A.\xd7 &2d""6d7e.\xcb &2R""6R7S.\xbf &2N""6N7O.\xb3 &2T""6T7U.\xa7 &2V""6V7W.\x9b &2f""6f7g.\x8f &2h""6h7i.\x83 &28""6879.w &2j""6j7k.k &;&.e &24""6475.Y &2l""6l7m.M &2n""6n7o.A &26""6677.5 &2p""6p7q.) &2r""6r7s&&&#/"!&,)'),_("%;//?#2P\"\"6P7Q/0$;//'$8#:t# )(#'#(\"'#&'#"),_("%;//?#24\"\"6475/0$;//'$8#:u# )(#'#(\"'#&'#"),_("%;//?#2>\"\"6>7?/0$;//'$8#:v# )(#'#(\"'#&'#"),_("%;//?#2T\"\"6T7U/0$;//'$8#:w# )(#'#(\"'#&'#"),_("%;//?#2V\"\"6V7W/0$;//'$8#:x# )(#'#(\"'#&'#"),_('%2h""6h7i/0#;//\'$8":y" )("\'#&\'#'),_('%;//6#2f""6f7g/\'$8":z" )("\'#&\'#'),_("%;//?#2D\"\"6D7E/0$;//'$8#:{# )(#'#(\"'#&'#"),_("%;//?#22\"\"6273/0$;//'$8#:|# )(#'#(\"'#&'#"),_("%;//?#28\"\"6879/0$;//'$8#:}# )(#'#(\"'#&'#"),_("%;//0#;&/'$8\":~\" )(\"'#&'#"),_("%;&/0#;//'$8\":~\" )(\"'#&'#"),_("%;=/T#$;G.) &;K.# &;F0/*;G.) &;K.# &;F&/,$;>/#$+#)(#'#(\"'#&'#"),_('4\x7f""5!7\x80.A &4\x81""5!7\x82.5 &4\x83""5!7\x84.) &;3.# &;.'),_("%%;//Q#;&/H$$;J.# &;K0)*;J.# &;K&/,$;&/#$+$)($'#(#'#(\"'#&'#/\"!&,)"),_("%;//]#;&/T$%$;J.# &;K0)*;J.# &;K&/\"!&,)/1$;&/($8$:\x85$!!)($'#(#'#(\"'#&'#"),_(';..G &2L""6L7M.; &4\x86""5!7\x87./ &4\x83""5!7\x84.# &;3'),_('%2j""6j7k/J#4\x88""5!7\x89.5 &4\x8a""5!7\x8b.) &4\x8c""5!7\x8d/#$+")("\'#&\'#'),_("%;N/M#28\"\"6879/>$;O.\" &\"/0$;S/'$8$:\x8e$ )($'#(#'#(\"'#&'#"),_("%;N/d#28\"\"6879/U$;O.\" &\"/G$;S/>$;_/5$;l.\" &\"/'$8&:\x8f& )(&'#(%'#($'#(#'#(\"'#&'#"),_('%3\x90""5$7\x91.) &3\x92""5#7\x93/\' 8!:\x94!! )'),_('%;P/]#%28""6879/,#;R/#$+")("\'#&\'#." &"/6$2:""6:7;/\'$8#:\x95# )(#\'#("\'#&\'#'),_("$;+.) &;-.# &;Q/2#0/*;+.) &;-.# &;Q&&&#"),_('2<""6<7=.q &2>""6>7?.e &2@""6@7A.Y &2B""6B7C.M &2D""6D7E.A &22""6273.5 &26""6677.) &24""6475'),_('%$;+._ &;-.Y &2<""6<7=.M &2>""6>7?.A &2@""6@7A.5 &2B""6B7C.) &2D""6D7E0e*;+._ &;-.Y &2<""6<7=.M &2>""6>7?.A &2@""6@7A.5 &2B""6B7C.) &2D""6D7E&/& 8!:\x96! )'),_('%;T/J#%28""6879/,#;^/#$+")("\'#&\'#." &"/#$+")("\'#&\'#'),_("%;U.) &;\\.# &;X/& 8!:\x97! )"),_('%$%;V/2#2J""6J7K/#$+")("\'#&\'#0<*%;V/2#2J""6J7K/#$+")("\'#&\'#&/D#;W/;$2J""6J7K." &"/\'$8#:\x98# )(#\'#("\'#&\'#'),_('$4\x99""5!7\x9a/,#0)*4\x99""5!7\x9a&&&#'),_('%4$""5!7%/?#$4\x9b""5!7\x9c0)*4\x9b""5!7\x9c&/#$+")("\'#&\'#'),_('%2l""6l7m/?#;Y/6$2n""6n7o/\'$8#:\x9d# )(#\'#("\'#&\'#'),_('%%;Z/\xb3#28""6879/\xa4$;Z/\x9b$28""6879/\x8c$;Z/\x83$28""6879/t$;Z/k$28""6879/\\$;Z/S$28""6879/D$;Z/;$28""6879/,$;[/#$+-)(-\'#(,\'#(+\'#(*\'#()\'#((\'#(\'\'#(&\'#(%\'#($\'#(#\'#("\'#&\'#.\u0790 &%2\x9e""6\x9e7\x9f/\xa4#;Z/\x9b$28""6879/\x8c$;Z/\x83$28""6879/t$;Z/k$28""6879/\\$;Z/S$28""6879/D$;Z/;$28""6879/,$;[/#$+,)(,\'#(+\'#(*\'#()\'#((\'#(\'\'#(&\'#(%\'#($\'#(#\'#("\'#&\'#.\u06f9 &%2\x9e""6\x9e7\x9f/\x8c#;Z/\x83$28""6879/t$;Z/k$28""6879/\\$;Z/S$28""6879/D$;Z/;$28""6879/,$;[/#$+*)(*\'#()\'#((\'#(\'\'#(&\'#(%\'#($\'#(#\'#("\'#&\'#.\u067a &%2\x9e""6\x9e7\x9f/t#;Z/k$28""6879/\\$;Z/S$28""6879/D$;Z/;$28""6879/,$;[/#$+()((\'#(\'\'#(&\'#(%\'#($\'#(#\'#("\'#&\'#.\u0613 &%2\x9e""6\x9e7\x9f/\\#;Z/S$28""6879/D$;Z/;$28""6879/,$;[/#$+&)(&\'#(%\'#($\'#(#\'#("\'#&\'#.\u05c4 &%2\x9e""6\x9e7\x9f/D#;Z/;$28""6879/,$;[/#$+$)($\'#(#\'#("\'#&\'#.\u058d &%2\x9e""6\x9e7\x9f/,#;[/#$+")("\'#&\'#.\u056e &%2\x9e""6\x9e7\x9f/,#;Z/#$+")("\'#&\'#.\u054f &%;Z/\x9b#2\x9e""6\x9e7\x9f/\x8c$;Z/\x83$28""6879/t$;Z/k$28""6879/\\$;Z/S$28""6879/D$;Z/;$28""6879/,$;[/#$++)(+\'#(*\'#()\'#((\'#(\'\'#(&\'#(%\'#($\'#(#\'#("\'#&\'#.\u04c7 &%;Z/\xaa#%28""6879/,#;Z/#$+")("\'#&\'#." &"/\x83$2\x9e""6\x9e7\x9f/t$;Z/k$28""6879/\\$;Z/S$28""6879/D$;Z/;$28""6879/,$;[/#$+*)(*\'#()\'#((\'#(\'\'#(&\'#(%\'#($\'#(#\'#("\'#&\'#.\u0430 &%;Z/\xb9#%28""6879/,#;Z/#$+")("\'#&\'#." &"/\x92$%28""6879/,#;Z/#$+")("\'#&\'#." &"/k$2\x9e""6\x9e7\x9f/\\$;Z/S$28""6879/D$;Z/;$28""6879/,$;[/#$+))()\'#((\'#(\'\'#(&\'#(%\'#($\'#(#\'#("\'#&\'#.\u038a &%;Z/\xc8#%28""6879/,#;Z/#$+")("\'#&\'#." &"/\xa1$%28""6879/,#;Z/#$+")("\'#&\'#." &"/z$%28""6879/,#;Z/#$+")("\'#&\'#." &"/S$2\x9e""6\x9e7\x9f/D$;Z/;$28""6879/,$;[/#$+()((\'#(\'\'#(&\'#(%\'#($\'#(#\'#("\'#&\'#.\u02d5 &%;Z/\xd7#%28""6879/,#;Z/#$+")("\'#&\'#." &"/\xb0$%28""6879/,#;Z/#$+")("\'#&\'#." &"/\x89$%28""6879/,#;Z/#$+")("\'#&\'#." &"/b$%28""6879/,#;Z/#$+")("\'#&\'#." &"/;$2\x9e""6\x9e7\x9f/,$;[/#$+\')(\'\'#(&\'#(%\'#($\'#(#\'#("\'#&\'#.\u0211 &%;Z/\xfe#%28""6879/,#;Z/#$+")("\'#&\'#." &"/\xd7$%28""6879/,#;Z/#$+")("\'#&\'#." &"/\xb0$%28""6879/,#;Z/#$+")("\'#&\'#." &"/\x89$%28""6879/,#;Z/#$+")("\'#&\'#." &"/b$%28""6879/,#;Z/#$+")("\'#&\'#." &"/;$2\x9e""6\x9e7\x9f/,$;Z/#$+()((\'#(\'\'#(&\'#(%\'#($\'#(#\'#("\'#&\'#.\u0126 &%;Z/\u011c#%28""6879/,#;Z/#$+")("\'#&\'#." &"/\xf5$%28""6879/,#;Z/#$+")("\'#&\'#." &"/\xce$%28""6879/,#;Z/#$+")("\'#&\'#." &"/\xa7$%28""6879/,#;Z/#$+")("\'#&\'#." &"/\x80$%28""6879/,#;Z/#$+")("\'#&\'#." &"/Y$%28""6879/,#;Z/#$+")("\'#&\'#." &"/2$2\x9e""6\x9e7\x9f/#$+()((\'#(\'\'#(&\'#(%\'#($\'#(#\'#("\'#&\'#/& 8!:\xa0! )'),_('%;#/M#;#." &"/?$;#." &"/1$;#." &"/#$+$)($\'#(#\'#("\'#&\'#'),_("%;Z/;#28\"\"6879/,$;Z/#$+#)(#'#(\"'#&'#.# &;\\"),_("%;]/o#2J\"\"6J7K/`$;]/W$2J\"\"6J7K/H$;]/?$2J\"\"6J7K/0$;]/'$8':\xa1' )(''#(&'#(%'#($'#(#'#(\"'#&'#"),_('%2\xa2""6\xa27\xa3/2#4\xa4""5!7\xa5/#$+")("\'#&\'#.\x98 &%2\xa6""6\xa67\xa7/;#4\xa8""5!7\xa9/,$;!/#$+#)(#\'#("\'#&\'#.j &%2\xaa""6\xaa7\xab/5#;!/,$;!/#$+#)(#\'#("\'#&\'#.B &%4\xac""5!7\xad/,#;!/#$+")("\'#&\'#.# &;!'),_('%%;!." &"/[#;!." &"/M$;!." &"/?$;!." &"/1$;!." &"/#$+%)(%\'#($\'#(#\'#("\'#&\'#/\' 8!:\xae!! )'),_('$%22""6273/,#;`/#$+")("\'#&\'#0<*%22""6273/,#;`/#$+")("\'#&\'#&'),_(";a.A &;b.; &;c.5 &;d./ &;e.) &;f.# &;g"),_('%3\xaf""5*7\xb0/a#3\xb1""5#7\xb2.G &3\xb3""5#7\xb4.; &3\xb5""5$7\xb6./ &3\xb7""5#7\xb8.# &;6/($8":\xb9"! )("\'#&\'#'),_('%3\xba""5%7\xbb/I#3\xbc""5%7\xbd./ &3\xbe""5"7\xbf.# &;6/($8":\xc0"! )("\'#&\'#'),_('%3\xc1""5\'7\xc2/1#;\x90/($8":\xc3"! )("\'#&\'#'),_('%3\xc4""5$7\xc5/1#;\xf0/($8":\xc6"! )("\'#&\'#'),_('%3\xc7""5&7\xc8/1#;T/($8":\xc9"! )("\'#&\'#'),_('%3\xca""5"7\xcb/N#%2>""6>7?/,#;6/#$+")("\'#&\'#." &"/\'$8":\xcc" )("\'#&\'#'),_('%;h/P#%2>""6>7?/,#;i/#$+")("\'#&\'#." &"/)$8":\xcd""! )("\'#&\'#'),_('%$;j/&#0#*;j&&&#/"!&,)'),_('%$;j/&#0#*;j&&&#/"!&,)'),_(";k.) &;+.# &;-"),_('2l""6l7m.e &2n""6n7o.Y &24""6475.M &28""6879.A &2<""6<7=.5 &2@""6@7A.) &2B""6B7C'),_('%26""6677/n#;m/e$$%2<""6<7=/,#;m/#$+")("\'#&\'#0<*%2<""6<7=/,#;m/#$+")("\'#&\'#&/#$+#)(#\'#("\'#&\'#'),_('%;n/A#2>""6>7?/2$;o/)$8#:\xce#"" )(#\'#("\'#&\'#'),_("$;p.) &;+.# &;-/2#0/*;p.) &;+.# &;-&&&#"),_("$;p.) &;+.# &;-0/*;p.) &;+.# &;-&"),_('2l""6l7m.e &2n""6n7o.Y &24""6475.M &26""6677.A &28""6879.5 &2@""6@7A.) &2B""6B7C'),_(";\x91.# &;r"),_("%;\x90/G#;'/>$;s/5$;'/,$;\x84/#$+%)(%'#($'#(#'#(\"'#&'#"),_(";M.# &;t"),_("%;\x7f/E#28\"\"6879/6$;u.# &;x/'$8#:\xcf# )(#'#(\"'#&'#"),_('%;v.# &;w/J#%26""6677/,#;\x83/#$+")("\'#&\'#." &"/#$+")("\'#&\'#'),_('%2\xd0""6\xd07\xd1/:#;\x80/1$;w." &"/#$+#)(#\'#("\'#&\'#'),_('%24""6475/,#;{/#$+")("\'#&\'#'),_("%;z/3#$;y0#*;y&/#$+\")(\"'#&'#"),_(";*.) &;+.# &;-"),_(';+.\x8f &;-.\x89 &22""6273.} &26""6677.q &28""6879.e &2:""6:7;.Y &2<""6<7=.M &2>""6>7?.A &2@""6@7A.5 &2B""6B7C.) &2D""6D7E'),_('%;|/e#$%24""6475/,#;|/#$+")("\'#&\'#0<*%24""6475/,#;|/#$+")("\'#&\'#&/#$+")("\'#&\'#'),_('%$;~0#*;~&/e#$%22""6273/,#;}/#$+")("\'#&\'#0<*%22""6273/,#;}/#$+")("\'#&\'#&/#$+")("\'#&\'#'),_("$;~0#*;~&"),_(';+.w &;-.q &28""6879.e &2:""6:7;.Y &2<""6<7=.M &2>""6>7?.A &2@""6@7A.5 &2B""6B7C.) &2D""6D7E'),_('%%;"/\x87#$;".G &;!.A &2@""6@7A.5 &2F""6F7G.) &2J""6J7K0M*;".G &;!.A &2@""6@7A.5 &2F""6F7G.) &2J""6J7K&/#$+")("\'#&\'#/& 8!:\xd2! )'),_(";\x81.# &;\x82"),_('%%;O/2#2:""6:7;/#$+")("\'#&\'#." &"/,#;S/#$+")("\'#&\'#." &"'),_('$;+.\x83 &;-.} &2B""6B7C.q &2D""6D7E.e &22""6273.Y &28""6879.M &2:""6:7;.A &2<""6<7=.5 &2>""6>7?.) &2@""6@7A/\x8c#0\x89*;+.\x83 &;-.} &2B""6B7C.q &2D""6D7E.e &22""6273.Y &28""6879.M &2:""6:7;.A &2<""6<7=.5 &2>""6>7?.) &2@""6@7A&&&#'),_("$;y0#*;y&"),_('%3\x92""5#7\xd3/q#24""6475/b$$;!/&#0#*;!&&&#/L$2J""6J7K/=$$;!/&#0#*;!&&&#/\'$8%:\xd4% )(%\'#($\'#(#\'#("\'#&\'#'),_('2\xd5""6\xd57\xd6'),_('2\xd7""6\xd77\xd8'),_('2\xd9""6\xd97\xda'),_('2\xdb""6\xdb7\xdc'),_('2\xdd""6\xdd7\xde'),_('2\xdf""6\xdf7\xe0'),_('2\xe1""6\xe17\xe2'),_('2\xe3""6\xe37\xe4'),_('2\xe5""6\xe57\xe6'),_('2\xe7""6\xe77\xe8'),_('2\xe9""6\xe97\xea'),_("%;\x85.Y &;\x86.S &;\x88.M &;\x89.G &;\x8a.A &;\x8b.; &;\x8c.5 &;\x8f./ &;\x8d.) &;\x8e.# &;6/& 8!:\xeb! )"),_("%;\x84/G#;'/>$;\x92/5$;'/,$;\x94/#$+%)(%'#($'#(#'#(\"'#&'#"),_("%;\x93/' 8!:\xec!! )"),_("%;!/5#;!/,$;!/#$+#)(#'#(\"'#&'#"),_("%$;*.A &;+.; &;-.5 &;3./ &;4.) &;'.# &;(0G*;*.A &;+.; &;-.5 &;3./ &;4.) &;'.# &;(&/& 8!:\xed! )"),_("%;\xb6/Y#$%;A/,#;\xb6/#$+\")(\"'#&'#06*%;A/,#;\xb6/#$+\")(\"'#&'#&/#$+\")(\"'#&'#"),_('%;9/N#%2:""6:7;/,#;9/#$+")("\'#&\'#." &"/\'$8":\xee" )("\'#&\'#'),_("%;:.c &%;\x98/Y#$%;A/,#;\x98/#$+\")(\"'#&'#06*%;A/,#;\x98/#$+\")(\"'#&'#&/#$+\")(\"'#&'#/& 8!:\xef! )"),_("%;L.# &;\x99/]#$%;B/,#;\x9b/#$+\")(\"'#&'#06*%;B/,#;\x9b/#$+\")(\"'#&'#&/'$8\":\xf0\" )(\"'#&'#"),_("%;\x9a.\" &\"/>#;@/5$;M/,$;?/#$+$)($'#(#'#(\"'#&'#"),_("%%;6/Y#$%;./,#;6/#$+\")(\"'#&'#06*%;./,#;6/#$+\")(\"'#&'#&/#$+\")(\"'#&'#.# &;H/' 8!:\xf1!! )"),_(";\x9c.) &;\x9d.# &;\xa0"),_("%3\xf2\"\"5!7\xf3/:#;</1$;\x9f/($8#:\xf4#! )(#'#(\"'#&'#"),_("%3\xf5\"\"5'7\xf6/:#;</1$;\x9e/($8#:\xf7#! )(#'#(\"'#&'#"),_("%$;!/&#0#*;!&&&#/' 8!:\xf8!! )"),_('%2\xf9""6\xf97\xfa/o#%2J""6J7K/M#;!." &"/?$;!." &"/1$;!." &"/#$+$)($\'#(#\'#("\'#&\'#." &"/\'$8":\xfb" )("\'#&\'#'),_('%;6/J#%;</,#;\xa1/#$+")("\'#&\'#." &"/)$8":\xfc""! )("\'#&\'#'),_(";6.) &;T.# &;H"),_("%;\xa3/Y#$%;B/,#;\xa4/#$+\")(\"'#&'#06*%;B/,#;\xa4/#$+\")(\"'#&'#&/#$+\")(\"'#&'#"),_('%3\xfd""5&7\xfe.G &3\xff""5\'7\u0100.; &3\u0101""5$7\u0102./ &3\u0103""5%7\u0104.# &;6/& 8!:\u0105! )'),_(";\xa5.# &;\xa0"),_('%3\u0106""5(7\u0107/M#;</D$3\u0108""5(7\u0109./ &3\u010a""5(7\u010b.# &;6/#$+#)(#\'#("\'#&\'#'),_("%;6/Y#$%;A/,#;6/#$+\")(\"'#&'#06*%;A/,#;6/#$+\")(\"'#&'#&/#$+\")(\"'#&'#"),_("%$;!/&#0#*;!&&&#/' 8!:\u010c!! )"),_("%;\xa9/& 8!:\u010d! )"),_("%;\xaa/k#;;/b$;\xaf/Y$$%;B/,#;\xb0/#$+\")(\"'#&'#06*%;B/,#;\xb0/#$+\")(\"'#&'#&/#$+$)($'#(#'#(\"'#&'#"),_(";\xab.# &;\xac"),_('3\u010e""5$7\u010f.S &3\u0110""5%7\u0111.G &3\u0112""5%7\u0113.; &3\u0114""5%7\u0115./ &3\u0116""5+7\u0117.# &;\xad'),_('3\u0118""5\'7\u0119./ &3\u011a""5)7\u011b.# &;\xad'),_(";6.# &;\xae"),_('%3\u011c""5"7\u011d/,#;6/#$+")("\'#&\'#'),_(";\xad.# &;6"),_("%;6/5#;</,$;\xb1/#$+#)(#'#(\"'#&'#"),_(";6.# &;H"),_("%;\xb3/5#;./,$;\x90/#$+#)(#'#(\"'#&'#"),_("%$;!/&#0#*;!&&&#/' 8!:\u011e!! )"),_("%;\x9e/' 8!:\u011f!! )"),_('%;\xb6/^#$%;B/,#;\xa0/#$+")("\'#&\'#06*%;B/,#;\xa0/#$+")("\'#&\'#&/($8":\u0120"!!)("\'#&\'#'),_('%%;7/e#$%2J""6J7K/,#;7/#$+")("\'#&\'#0<*%2J""6J7K/,#;7/#$+")("\'#&\'#&/#$+")("\'#&\'#/"!&,)'),_("%;L.# &;\x99/]#$%;B/,#;\xb8/#$+\")(\"'#&'#06*%;B/,#;\xb8/#$+\")(\"'#&'#&/'$8\":\u0121\" )(\"'#&'#"),_(";\xb9.# &;\xa0"),_("%3\u0122\"\"5#7\u0123/:#;</1$;6/($8#:\u0124#! )(#'#(\"'#&'#"),_("%$;!/&#0#*;!&&&#/' 8!:\u0125!! )"),_("%;\x9e/' 8!:\u0126!! )"),_("%$;\x9a0#*;\x9a&/x#;@/o$;M/f$;?/]$$%;B/,#;\xa0/#$+\")(\"'#&'#06*%;B/,#;\xa0/#$+\")(\"'#&'#&/'$8%:\u0127% )(%'#($'#(#'#(\"'#&'#"),_(";\xbe"),_("%3\u0128\"\"5&7\u0129/k#;./b$;\xc1/Y$$%;A/,#;\xc1/#$+\")(\"'#&'#06*%;A/,#;\xc1/#$+\")(\"'#&'#&/#$+$)($'#(#'#(\"'#&'#.# &;\xbf"),_("%;6/k#;./b$;\xc0/Y$$%;A/,#;\xc0/#$+\")(\"'#&'#06*%;A/,#;\xc0/#$+\")(\"'#&'#&/#$+$)($'#(#'#(\"'#&'#"),_("%;6/;#;</2$;6.# &;H/#$+#)(#'#(\"'#&'#"),_(";\xc2.G &;\xc4.A &;\xc6.; &;\xc8.5 &;\xc9./ &;\xca.) &;\xcb.# &;\xc0"),_("%3\u012a\"\"5%7\u012b/5#;</,$;\xc3/#$+#)(#'#(\"'#&'#"),_("%;I/' 8!:\u012c!! )"),_("%3\u012d\"\"5&7\u012e/\x97#;</\x8e$;D/\x85$;\xc5/|$$%$;'/&#0#*;'&&&#/,#;\xc5/#$+\")(\"'#&'#0C*%$;'/&#0#*;'&&&#/,#;\xc5/#$+\")(\"'#&'#&/,$;E/#$+&)(&'#(%'#($'#(#'#(\"'#&'#"),_(";t.# &;w"),_("%3\u012f\"\"5%7\u0130/5#;</,$;\xc7/#$+#)(#'#(\"'#&'#"),_("%;I/' 8!:\u0131!! )"),_("%3\u0132\"\"5&7\u0133/:#;</1$;I/($8#:\u0134#! )(#'#(\"'#&'#"),_('%3\u0135""5%7\u0136/]#;</T$%3\u0137""5$7\u0138/& 8!:\u0139! ).4 &%3\u013a""5%7\u013b/& 8!:\u013c! )/#$+#)(#\'#("\'#&\'#'),_('%3\u013d""5)7\u013e/R#;</I$3\u013f""5#7\u0140./ &3\u0141""5(7\u0142.# &;6/($8#:\u0143#! )(#\'#("\'#&\'#'),_('%3\u0144""5#7\u0145/\x93#;</\x8a$;D/\x81$%;\xcc/e#$%2D""6D7E/,#;\xcc/#$+")("\'#&\'#0<*%2D""6D7E/,#;\xcc/#$+")("\'#&\'#&/#$+")("\'#&\'#/,$;E/#$+%)(%\'#($\'#(#\'#("\'#&\'#'),_('%3\u0146""5(7\u0147./ &3\u0148""5$7\u0149.# &;6/\' 8!:\u014a!! )'),_("%;6/Y#$%;A/,#;6/#$+\")(\"'#&'#06*%;A/,#;6/#$+\")(\"'#&'#&/#$+\")(\"'#&'#"),_("%;\xcf/G#;./>$;\xcf/5$;./,$;\x90/#$+%)(%'#($'#(#'#(\"'#&'#"),_("%$;!/&#0#*;!&&&#/' 8!:\u014b!! )"),_("%;\xd1/]#$%;A/,#;\xd1/#$+\")(\"'#&'#06*%;A/,#;\xd1/#$+\")(\"'#&'#&/'$8\":\u014c\" )(\"'#&'#"),_("%;\x99/]#$%;B/,#;\xa0/#$+\")(\"'#&'#06*%;B/,#;\xa0/#$+\")(\"'#&'#&/'$8\":\u014d\" )(\"'#&'#"),_('%;L.O &;\x99.I &%;@." &"/:#;t/1$;?." &"/#$+#)(#\'#("\'#&\'#/]#$%;B/,#;\xa0/#$+")("\'#&\'#06*%;B/,#;\xa0/#$+")("\'#&\'#&/\'$8":\u014e" )("\'#&\'#'),_("%;\xd4/]#$%;B/,#;\xd5/#$+\")(\"'#&'#06*%;B/,#;\xd5/#$+\")(\"'#&'#&/'$8\":\u014f\" )(\"'#&'#"),_("%;\x96/& 8!:\u0150! )"),_('%3\u0151""5(7\u0152/:#;</1$;6/($8#:\u0153#! )(#\'#("\'#&\'#.g &%3\u0154""5&7\u0155/:#;</1$;6/($8#:\u0156#! )(#\'#("\'#&\'#.: &%3\u0157""5*7\u0158/& 8!:\u0159! ).# &;\xa0'),_('%%;6/k#$%;A/2#;6/)$8":\u015a""$ )("\'#&\'#0<*%;A/2#;6/)$8":\u015a""$ )("\'#&\'#&/)$8":\u015b""! )("\'#&\'#." &"/\' 8!:\u015c!! )'),_("%;\xd8/Y#$%;A/,#;\xd8/#$+\")(\"'#&'#06*%;A/,#;\xd8/#$+\")(\"'#&'#&/#$+\")(\"'#&'#"),_("%;\x99/Y#$%;B/,#;\xa0/#$+\")(\"'#&'#06*%;B/,#;\xa0/#$+\")(\"'#&'#&/#$+\")(\"'#&'#"),_("%$;!/&#0#*;!&&&#/' 8!:\u015d!! )"),_("%;\xdb/Y#$%;B/,#;\xdc/#$+\")(\"'#&'#06*%;B/,#;\xdc/#$+\")(\"'#&'#&/#$+\")(\"'#&'#"),_('%3\u015e""5&7\u015f.; &3\u0160""5\'7\u0161./ &3\u0162""5*7\u0163.# &;6/& 8!:\u0164! )'),_("%3\u0165\"\"5&7\u0166/:#;</1$;\xdd/($8#:\u0167#! )(#'#(\"'#&'#.} &%3\xf5\"\"5'7\xf6/:#;</1$;\x9e/($8#:\u0168#! )(#'#(\"'#&'#.P &%3\u0169\"\"5+7\u016a/:#;</1$;\x9e/($8#:\u016b#! )(#'#(\"'#&'#.# &;\xa0"),_('3\u016c""5+7\u016d.k &3\u016e""5)7\u016f._ &3\u0170""5(7\u0171.S &3\u0172""5\'7\u0173.G &3\u0174""5&7\u0175.; &3\u0176""5*7\u0177./ &3\u0178""5)7\u0179.# &;6'),_(';1." &"'),_('%%;6/k#$%;A/2#;6/)$8":\u015a""$ )("\'#&\'#0<*%;A/2#;6/)$8":\u015a""$ )("\'#&\'#&/)$8":\u015b""! )("\'#&\'#." &"/\' 8!:\u017a!! )'),_("%;L.# &;\x99/]#$%;B/,#;\xe1/#$+\")(\"'#&'#06*%;B/,#;\xe1/#$+\")(\"'#&'#&/'$8\":\u017b\" )(\"'#&'#"),_(";\xb9.# &;\xa0"),_("%;\xe3/Y#$%;A/,#;\xe3/#$+\")(\"'#&'#06*%;A/,#;\xe3/#$+\")(\"'#&'#&/#$+\")(\"'#&'#"),_("%;\xea/k#;./b$;\xed/Y$$%;B/,#;\xe4/#$+\")(\"'#&'#06*%;B/,#;\xe4/#$+\")(\"'#&'#&/#$+$)($'#(#'#(\"'#&'#"),_(";\xe5.; &;\xe6.5 &;\xe7./ &;\xe8.) &;\xe9.# &;\xa0"),_("%3\u017c\"\"5#7\u017d/:#;</1$;\xf0/($8#:\u017e#! )(#'#(\"'#&'#"),_("%3\u017f\"\"5%7\u0180/:#;</1$;T/($8#:\u0181#! )(#'#(\"'#&'#"),_("%3\u0182\"\"5(7\u0183/F#;</=$;\\.) &;Y.# &;X/($8#:\u0184#! )(#'#(\"'#&'#"),_("%3\u0185\"\"5&7\u0186/:#;</1$;6/($8#:\u0187#! )(#'#(\"'#&'#"),_("%3\u0188\"\"5%7\u0189/A#;</8$$;!0#*;!&/($8#:\u018a#! )(#'#(\"'#&'#"),_("%;\xeb/G#;;/>$;6/5$;;/,$;\xec/#$+%)(%'#($'#(#'#(\"'#&'#"),_('%3\x92""5#7\xd3.# &;6/\' 8!:\u018b!! )'),_('%3\xb1""5#7\u018c.G &3\xb3""5#7\u018d.; &3\xb7""5#7\u018e./ &3\xb5""5$7\u018f.# &;6/\' 8!:\u0190!! )'),_('%;\xee/D#%;C/,#;\xef/#$+")("\'#&\'#." &"/#$+")("\'#&\'#'),_("%;U.) &;\\.# &;X/& 8!:\u0191! )"),_('%%;!." &"/[#;!." &"/M$;!." &"/?$;!." &"/1$;!." &"/#$+%)(%\'#($\'#(#\'#("\'#&\'#/\' 8!:\u0192!! )'),_('%%;!/?#;!." &"/1$;!." &"/#$+#)(#\'#("\'#&\'#/\' 8!:\u0193!! )'),_(";\xbe"),_('%;\x9e/^#$%;B/,#;\xf3/#$+")("\'#&\'#06*%;B/,#;\xf3/#$+")("\'#&\'#&/($8":\u0194"!!)("\'#&\'#'),_(";\xf4.# &;\xa0"),_('%2\u0195""6\u01957\u0196/L#;</C$2\u0197""6\u01977\u0198.) &2\u0199""6\u01997\u019a/($8#:\u019b#! )(#\'#("\'#&\'#'),_('%;\x9e/^#$%;B/,#;\xa0/#$+")("\'#&\'#06*%;B/,#;\xa0/#$+")("\'#&\'#&/($8":\u019c"!!)("\'#&\'#'),_("%;6/5#;0/,$;\xf7/#$+#)(#'#(\"'#&'#"),_("$;2.) &;4.# &;.0/*;2.) &;4.# &;.&"),_("$;%0#*;%&"),_("%;\xfa/;#28\"\"6879/,$;\xfb/#$+#)(#'#(\"'#&'#"),_('%3\u019d""5%7\u019e.) &3\u019f""5$7\u01a0/\' 8!:\u01a1!! )'),_('%;\xfc/J#%28""6879/,#;^/#$+")("\'#&\'#." &"/#$+")("\'#&\'#'),_("%;\\.) &;X.# &;\x82/' 8!:\u01a2!! )"),_(';".S &;!.M &2F""6F7G.A &2J""6J7K.5 &2H""6H7I.) &2N""6N7O'),_('2L""6L7M.\x95 &2B""6B7C.\x89 &2<""6<7=.} &2R""6R7S.q &2T""6T7U.e &2V""6V7W.Y &2P""6P7Q.M &2@""6@7A.A &2D""6D7E.5 &22""6273.) &2>""6>7?'),_('%;\u0100/b#28""6879/S$;\xfb/J$%2\u01a3""6\u01a37\u01a4/,#;\xec/#$+")("\'#&\'#." &"/#$+$)($\'#(#\'#("\'#&\'#'),_('%3\u01a5""5%7\u01a6.) &3\u01a7""5$7\u01a8/\' 8!:\u01a1!! )'),_('%3\xb1""5#7\xb2.6 &3\xb3""5#7\xb4.* &$;+0#*;+&/\' 8!:\u01a9!! )'),_("%;\u0104/\x87#2F\"\"6F7G/x$;\u0103/o$2F\"\"6F7G/`$;\u0103/W$2F\"\"6F7G/H$;\u0103/?$2F\"\"6F7G/0$;\u0105/'$8):\u01aa) )()'#(('#(''#(&'#(%'#($'#(#'#(\"'#&'#"),_("%;#/>#;#/5$;#/,$;#/#$+$)($'#(#'#(\"'#&'#"),_("%;\u0103/,#;\u0103/#$+\")(\"'#&'#"),_("%;\u0103/5#;\u0103/,$;\u0103/#$+#)(#'#(\"'#&'#"),_("%;q/T#$;m0#*;m&/D$%; /,#;\xf8/#$+\")(\"'#&'#.\" &\"/#$+#)(#'#(\"'#&'#"),_('%2\u01ab""6\u01ab7\u01ac.) &2\u01ad""6\u01ad7\u01ae/w#;0/n$;\u0108/e$$%;B/2#;\u0109.# &;\xa0/#$+")("\'#&\'#0<*%;B/2#;\u0109.# &;\xa0/#$+")("\'#&\'#&/#$+$)($\'#(#\'#("\'#&\'#'),_(";\x99.# &;L"),_("%2\u01af\"\"6\u01af7\u01b0/5#;</,$;\u010a/#$+#)(#'#(\"'#&'#"),_("%;D/S#;,/J$2:\"\"6:7;/;$;,.# &;T/,$;E/#$+%)(%'#($'#(#'#(\"'#&'#")],p=0,l=0,h=[{line:1,column:1}],g=0,f=[],m=0;if(void 0!==t.startRule){if(!(t.startRule in a))throw new Error("Can't start parsing from rule \""+t.startRule+'".');c=a[t.startRule]}function v(){return e.substring(l,p)}function S(){return b(l,p)}function T(e,t){return{type:"literal",text:e,ignoreCase:t}}function y(e,t,r){return{type:"class",parts:e,inverted:t,ignoreCase:r}}function E(t){var r,i=h[t];if(i)return i;for(r=t-1;!h[r];)r--;for(i={line:(i=h[r]).line,column:i.column};r<t;)10===e.charCodeAt(r)?(i.line++,i.column=1):i.column++,r++;return h[t]=i,i}function b(e,t){var r=E(e),i=E(t);return{start:{offset:e,line:r.line,column:r.column},end:{offset:t,line:i.line,column:i.column}}}function C(e){p<g||(p>g&&(g=p,f=[]),f.push(e))}function R(e,t,r){return new o(o.buildMessage(e,t),e,t,r)}function _(e){return e.split("").map((function(e){return e.charCodeAt(0)-32}))}if(t.data={},(r=function t(r){for(var n,s=d[r],o=0,a=[],c=s.length,h=[],g=[];;){for(;o<c;)switch(s[o]){case 0:g.push(u[s[o+1]]),o+=2;break;case 1:g.push(void 0),o++;break;case 2:g.push(null),o++;break;case 3:g.push(i),o++;break;case 4:g.push([]),o++;break;case 5:g.push(p),o++;break;case 6:g.pop(),o++;break;case 7:p=g.pop(),o++;break;case 8:g.length-=s[o+1],o+=2;break;case 9:g.splice(-2,1),o++;break;case 10:g[g.length-2].push(g.pop()),o++;break;case 11:g.push(g.splice(g.length-s[o+1],s[o+1])),o+=2;break;case 12:g.push(e.substring(g.pop(),p)),o++;break;case 13:h.push(c),a.push(o+3+s[o+1]+s[o+2]),g[g.length-1]?(c=o+3+s[o+1],o+=3):(c=o+3+s[o+1]+s[o+2],o+=3+s[o+1]);break;case 14:h.push(c),a.push(o+3+s[o+1]+s[o+2]),g[g.length-1]===i?(c=o+3+s[o+1],o+=3):(c=o+3+s[o+1]+s[o+2],o+=3+s[o+1]);break;case 15:h.push(c),a.push(o+3+s[o+1]+s[o+2]),g[g.length-1]!==i?(c=o+3+s[o+1],o+=3):(c=o+3+s[o+1]+s[o+2],o+=3+s[o+1]);break;case 16:g[g.length-1]!==i?(h.push(c),a.push(o),c=o+2+s[o+1],o+=2):o+=2+s[o+1];break;case 17:h.push(c),a.push(o+3+s[o+1]+s[o+2]),e.length>p?(c=o+3+s[o+1],o+=3):(c=o+3+s[o+1]+s[o+2],o+=3+s[o+1]);break;case 18:h.push(c),a.push(o+4+s[o+2]+s[o+3]),e.substr(p,u[s[o+1]].length)===u[s[o+1]]?(c=o+4+s[o+2],o+=4):(c=o+4+s[o+2]+s[o+3],o+=4+s[o+2]);break;case 19:h.push(c),a.push(o+4+s[o+2]+s[o+3]),e.substr(p,u[s[o+1]].length).toLowerCase()===u[s[o+1]]?(c=o+4+s[o+2],o+=4):(c=o+4+s[o+2]+s[o+3],o+=4+s[o+2]);break;case 20:h.push(c),a.push(o+4+s[o+2]+s[o+3]),u[s[o+1]].test(e.charAt(p))?(c=o+4+s[o+2],o+=4):(c=o+4+s[o+2]+s[o+3],o+=4+s[o+2]);break;case 21:g.push(e.substr(p,s[o+1])),p+=s[o+1],o+=2;break;case 22:g.push(u[s[o+1]]),p+=u[s[o+1]].length,o+=2;break;case 23:g.push(i),0===m&&C(u[s[o+1]]),o+=2;break;case 24:l=g[g.length-1-s[o+1]],o+=2;break;case 25:l=p,o++;break;case 26:n=s.slice(o+4,o+4+s[o+3]).map((function(e){return g[g.length-1-e]})),g.splice(g.length-s[o+2],s[o+2],u[s[o+1]].apply(null,n)),o+=4+s[o+3];break;case 27:g.push(t(s[o+1])),o+=2;break;case 28:m++,o++;break;case 29:m--,o++;break;default:throw new Error("Invalid opcode: "+s[o]+".")}if(!(h.length>0))break;c=h.pop(),o=a.pop()}return g[0]}(c))!==i&&p===e.length)return r;throw r!==i&&p<e.length&&C({type:"end"}),R(f,g<e.length?e.charAt(g):null,g<e.length?b(g,g+1):b(g,g))}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=r(0).__importDefault(r(60)),n=r(10),s=function(){function e(e,t,r){this.logger=e.getLogger("sipjs.digestauthentication"),this.username=t,this.password=r,this.nc=0,this.ncHex="00000000"}return e.prototype.authenticate=function(e,t,r){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 this.logger.warn("challenge with Digest algorithm different than 'MD5', authentication aborted"),!1}else this.algorithm="MD5";if(!this.realm)return this.logger.warn("challenge without Digest realm, authentication aborted"),!1;if(!this.nonce)return this.logger.warn("challenge without Digest nonce, authentication aborted"),!1;if(t.qop)if(t.qop.indexOf("auth")>-1)this.qop="auth";else{if(!(t.qop.indexOf("auth-int")>-1))return this.logger.warn("challenge without Digest qop different than 'auth' or 'auth-int', authentication aborted"),!1;this.qop="auth-int"}else this.qop=void 0;return this.method=e.method,this.uri=e.ruri,this.cnonce=n.createRandomToken(12),this.nc+=1,this.updateNcHex(),4294967296===this.nc&&(this.nc=1,this.ncHex="00000001"),this.calculateResponse(r),!0},e.prototype.toString=function(){var e=[];if(!this.response)throw new Error("response field does not exist, cannot generate Authorization header");return e.push("algorithm="+this.algorithm),e.push('username="'+this.username+'"'),e.push('realm="'+this.realm+'"'),e.push('nonce="'+this.nonce+'"'),e.push('uri="'+this.uri+'"'),e.push('response="'+this.response+'"'),this.opaque&&e.push('opaque="'+this.opaque+'"'),this.qop&&(e.push("qop="+this.qop),e.push('cnonce="'+this.cnonce+'"'),e.push("nc="+this.ncHex)),"Digest "+e.join(", ")},e.prototype.updateNcHex=function(){var e=Number(this.nc).toString(16);this.ncHex="00000000".substr(0,8-e.length)+e},e.prototype.calculateResponse=function(e){var t,r=i.default(this.username+":"+this.realm+":"+this.password);"auth"===this.qop?(t=i.default(this.method+":"+this.uri),this.response=i.default(r+":"+this.nonce+":"+this.ncHex+":"+this.cnonce+":auth:"+t)):"auth-int"===this.qop?(t=i.default(this.method+":"+this.uri+":"+i.default(e||"")),this.response=i.default(r+":"+this.nonce+":"+this.ncHex+":"+this.cnonce+":auth-int:"+t)):void 0===this.qop&&(t=i.default(this.method+":"+this.uri),this.response=i.default(r+":"+this.nonce+":"+t))},e}();t.DigestAuthentication=s},function(e,t,r){var i;e.exports=(i=r(61),function(e){var t=i,r=t.lib,n=r.WordArray,s=r.Hasher,o=t.algo,a=[];!function(){for(var t=0;t<64;t++)a[t]=4294967296*e.abs(e.sin(t+1))|0}();var c=o.MD5=s.extend({_doReset:function(){this._hash=new n.init([1732584193,4023233417,2562383102,271733878])},_doProcessBlock:function(e,t){for(var r=0;r<16;r++){var i=t+r,n=e[i];e[i]=16711935&(n<<8|n>>>24)|4278255360&(n<<24|n>>>8)}var s=this._hash.words,o=e[t+0],c=e[t+1],h=e[t+2],g=e[t+3],f=e[t+4],m=e[t+5],v=e[t+6],S=e[t+7],T=e[t+8],y=e[t+9],E=e[t+10],b=e[t+11],C=e[t+12],R=e[t+13],_=e[t+14],w=e[t+15],A=s[0],I=s[1],O=s[2],x=s[3];A=u(A,I,O,x,o,7,a[0]),x=u(x,A,I,O,c,12,a[1]),O=u(O,x,A,I,h,17,a[2]),I=u(I,O,x,A,g,22,a[3]),A=u(A,I,O,x,f,7,a[4]),x=u(x,A,I,O,m,12,a[5]),O=u(O,x,A,I,v,17,a[6]),I=u(I,O,x,A,S,22,a[7]),A=u(A,I,O,x,T,7,a[8]),x=u(x,A,I,O,y,12,a[9]),O=u(O,x,A,I,E,17,a[10]),I=u(I,O,x,A,b,22,a[11]),A=u(A,I,O,x,C,7,a[12]),x=u(x,A,I,O,R,12,a[13]),O=u(O,x,A,I,_,17,a[14]),A=d(A,I=u(I,O,x,A,w,22,a[15]),O,x,c,5,a[16]),x=d(x,A,I,O,v,9,a[17]),O=d(O,x,A,I,b,14,a[18]),I=d(I,O,x,A,o,20,a[19]),A=d(A,I,O,x,m,5,a[20]),x=d(x,A,I,O,E,9,a[21]),O=d(O,x,A,I,w,14,a[22]),I=d(I,O,x,A,f,20,a[23]),A=d(A,I,O,x,y,5,a[24]),x=d(x,A,I,O,_,9,a[25]),O=d(O,x,A,I,g,14,a[26]),I=d(I,O,x,A,T,20,a[27]),A=d(A,I,O,x,R,5,a[28]),x=d(x,A,I,O,h,9,a[29]),O=d(O,x,A,I,S,14,a[30]),A=p(A,I=d(I,O,x,A,C,20,a[31]),O,x,m,4,a[32]),x=p(x,A,I,O,T,11,a[33]),O=p(O,x,A,I,b,16,a[34]),I=p(I,O,x,A,_,23,a[35]),A=p(A,I,O,x,c,4,a[36]),x=p(x,A,I,O,f,11,a[37]),O=p(O,x,A,I,S,16,a[38]),I=p(I,O,x,A,E,23,a[39]),A=p(A,I,O,x,R,4,a[40]),x=p(x,A,I,O,o,11,a[41]),O=p(O,x,A,I,g,16,a[42]),I=p(I,O,x,A,v,23,a[43]),A=p(A,I,O,x,y,4,a[44]),x=p(x,A,I,O,C,11,a[45]),O=p(O,x,A,I,w,16,a[46]),A=l(A,I=p(I,O,x,A,h,23,a[47]),O,x,o,6,a[48]),x=l(x,A,I,O,S,10,a[49]),O=l(O,x,A,I,_,15,a[50]),I=l(I,O,x,A,m,21,a[51]),A=l(A,I,O,x,C,6,a[52]),x=l(x,A,I,O,g,10,a[53]),O=l(O,x,A,I,E,15,a[54]),I=l(I,O,x,A,c,21,a[55]),A=l(A,I,O,x,T,6,a[56]),x=l(x,A,I,O,w,10,a[57]),O=l(O,x,A,I,v,15,a[58]),I=l(I,O,x,A,R,21,a[59]),A=l(A,I,O,x,f,6,a[60]),x=l(x,A,I,O,b,10,a[61]),O=l(O,x,A,I,h,15,a[62]),I=l(I,O,x,A,y,21,a[63]),s[0]=s[0]+A|0,s[1]=s[1]+I|0,s[2]=s[2]+O|0,s[3]=s[3]+x|0},_doFinalize:function(){var t=this._data,r=t.words,i=8*this._nDataBytes,n=8*t.sigBytes;r[n>>>5]|=128<<24-n%32;var s=e.floor(i/4294967296),o=i;r[15+(n+64>>>9<<4)]=16711935&(s<<8|s>>>24)|4278255360&(s<<24|s>>>8),r[14+(n+64>>>9<<4)]=16711935&(o<<8|o>>>24)|4278255360&(o<<24|o>>>8),t.sigBytes=4*(r.length+1),this._process();for(var a=this._hash,c=a.words,u=0;u<4;u++){var d=c[u];c[u]=16711935&(d<<8|d>>>24)|4278255360&(d<<24|d>>>8)}return a},clone:function(){var e=s.clone.call(this);return e._hash=this._hash.clone(),e}});function u(e,t,r,i,n,s,o){var a=e+(t&r|~t&i)+n+o;return(a<<s|a>>>32-s)+t}function d(e,t,r,i,n,s,o){var a=e+(t&i|r&~i)+n+o;return(a<<s|a>>>32-s)+t}function p(e,t,r,i,n,s,o){var a=e+(t^r^i)+n+o;return(a<<s|a>>>32-s)+t}function l(e,t,r,i,n,s,o){var a=e+(r^(t|~i))+n+o;return(a<<s|a>>>32-s)+t}t.MD5=s._createHelper(c),t.HmacMD5=s._createHmacHelper(c)}(Math),i.MD5)},function(e,t,r){var i;e.exports=(i=i||function(e,t){var r=Object.create||function(){function e(){}return function(t){var r;return e.prototype=t,r=new e,e.prototype=null,r}}(),i={},n=i.lib={},s=n.Base={extend:function(e){var t=r(this);return e&&t.mixIn(e),t.hasOwnProperty("init")&&this.init!==t.init||(t.init=function(){t.$super.init.apply(this,arguments)}),t.init.prototype=t,t.$super=this,t},create:function(){var e=this.extend();return e.init.apply(e,arguments),e},init:function(){},mixIn:function(e){for(var t in e)e.hasOwnProperty(t)&&(this[t]=e[t]);e.hasOwnProperty("toString")&&(this.toString=e.toString)},clone:function(){return this.init.prototype.extend(this)}},o=n.WordArray=s.extend({init:function(e,t){e=this.words=e||[],this.sigBytes=null!=t?t:4*e.length},toString:function(e){return(e||c).stringify(this)},concat:function(e){var t=this.words,r=e.words,i=this.sigBytes,n=e.sigBytes;if(this.clamp(),i%4)for(var s=0;s<n;s++){var o=r[s>>>2]>>>24-s%4*8&255;t[i+s>>>2]|=o<<24-(i+s)%4*8}else for(s=0;s<n;s+=4)t[i+s>>>2]=r[s>>>2];return this.sigBytes+=n,this},clamp:function(){var t=this.words,r=this.sigBytes;t[r>>>2]&=4294967295<<32-r%4*8,t.length=e.ceil(r/4)},clone:function(){var e=s.clone.call(this);return e.words=this.words.slice(0),e},random:function(t){for(var r,i=[],n=function(t){t=t;var r=987654321,i=4294967295;return function(){var n=((r=36969*(65535&r)+(r>>16)&i)<<16)+(t=18e3*(65535&t)+(t>>16)&i)&i;return n/=4294967296,(n+=.5)*(e.random()>.5?1:-1)}},s=0;s<t;s+=4){var a=n(4294967296*(r||e.random()));r=987654071*a(),i.push(4294967296*a()|0)}return new o.init(i,t)}}),a=i.enc={},c=a.Hex={stringify:function(e){for(var t=e.words,r=e.sigBytes,i=[],n=0;n<r;n++){var s=t[n>>>2]>>>24-n%4*8&255;i.push((s>>>4).toString(16)),i.push((15&s).toString(16))}return i.join("")},parse:function(e){for(var t=e.length,r=[],i=0;i<t;i+=2)r[i>>>3]|=parseInt(e.substr(i,2),16)<<24-i%8*4;return new o.init(r,t/2)}},u=a.Latin1={stringify:function(e){for(var t=e.words,r=e.sigBytes,i=[],n=0;n<r;n++){var s=t[n>>>2]>>>24-n%4*8&255;i.push(String.fromCharCode(s))}return i.join("")},parse:function(e){for(var t=e.length,r=[],i=0;i<t;i++)r[i>>>2]|=(255&e.charCodeAt(i))<<24-i%4*8;return new o.init(r,t)}},d=a.Utf8={stringify:function(e){try{return decodeURIComponent(escape(u.stringify(e)))}catch(e){throw new Error("Malformed UTF-8 data")}},parse:function(e){return u.parse(unescape(encodeURIComponent(e)))}},p=n.BufferedBlockAlgorithm=s.extend({reset:function(){this._data=new o.init,this._nDataBytes=0},_append:function(e){"string"==typeof e&&(e=d.parse(e)),this._data.concat(e),this._nDataBytes+=e.sigBytes},_process:function(t){var r=this._data,i=r.words,n=r.sigBytes,s=this.blockSize,a=n/(4*s),c=(a=t?e.ceil(a):e.max((0|a)-this._minBufferSize,0))*s,u=e.min(4*c,n);if(c){for(var d=0;d<c;d+=s)this._doProcessBlock(i,d);var p=i.splice(0,c);r.sigBytes-=u}return new o.init(p,u)},clone:function(){var e=s.clone.call(this);return e._data=this._data.clone(),e},_minBufferSize:0}),l=(n.Hasher=p.extend({cfg:s.extend(),init:function(e){this.cfg=this.cfg.extend(e),this.reset()},reset:function(){p.reset.call(this),this._doReset()},update:function(e){return this._append(e),this._process(),this},finalize:function(e){return e&&this._append(e),this._doFinalize()},blockSize:16,_createHelper:function(e){return function(t,r){return new e.init(r).finalize(t)}},_createHmacHelper:function(e){return function(t,r){return new l.HMAC.init(e,r).finalize(t)}}}),i.algo={});return i}(Math),i)},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=r(10);t.constructOutgoingResponse=function(e,t){var r="\r\n";if(t.statusCode<100||t.statusCode>699)throw new TypeError("Invalid statusCode: "+t.statusCode);var n=t.reasonPhrase?t.reasonPhrase:i.getReasonPhrase(t.statusCode),s="SIP/2.0 "+t.statusCode+" "+n+r;t.statusCode>=100&&t.statusCode,t.statusCode;var o="From: "+e.getHeader("From")+r,a="Call-ID: "+e.callId+r,c="CSeq: "+e.cseq+" "+e.method+r,u=e.getHeaders("via").reduce((function(e,t){return e+"Via: "+t+r}),""),d="To: "+e.getHeader("to");if(t.statusCode>100&&!e.parseHeader("to").hasParam("tag")){var p=t.toTag;p||(p=i.newTag()),d+=";tag="+p}d+=r;var l="";t.supported&&(l="Supported: "+t.supported.join(", ")+r);var h="";t.userAgent&&(h="User-Agent: "+t.userAgent+r);var g="";return t.extraHeaders&&(g=t.extraHeaders.reduce((function(e,t){return e+t.trim()+r}),"")),s+=u,s+=o,s+=d,s+=c,s+=a,s+=l,s+=h,s+=g,t.body?(s+="Content-Type: "+t.body.contentType+r,s+="Content-Length: "+i.str_utf8_length(t.body.content)+r+r,s+=t.body.content):s+="Content-Length: 0\r\n\r\n",{message:s}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=r(0),n=r(2),s=r(15),o=r(6),a=r(1),c=r(36),u=r(37),d=r(38),p=r(39),l=r(40),h=r(26),g=r(41),f=r(42),m=r(43),v=r(44),S=r(45),T=r(46),y=function(e){function t(t,r,i,n){var o=e.call(this,r,i)||this;return o.initialTransaction=t,o._signalingState=s.SignalingState.Initial,o.ackWait=!1,o.delegate=n,t instanceof a.InviteServerTransaction&&(o.ackWait=!0),o.early||o.start2xxRetransmissionTimer(),o.signalingStateTransition(t.request),o.logger=r.loggerFactory.getLogger("sip.invite-dialog"),o.logger.log("INVITE dialog "+o.id+" constructed"),o}return i.__extends(t,e),t.prototype.dispose=function(){e.prototype.dispose.call(this),this._signalingState=s.SignalingState.Closed,this._offer=void 0,this._answer=void 0,this.invite2xxTimer&&(clearTimeout(this.invite2xxTimer),this.invite2xxTimer=void 0),this.logger.log("INVITE dialog "+this.id+" destroyed")},Object.defineProperty(t.prototype,"sessionState",{get:function(){return this.early?s.SessionState.Early:this.ackWait?s.SessionState.AckWait:this._signalingState===s.SignalingState.Closed?s.SessionState.Terminated:s.SessionState.Confirmed},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"signalingState",{get:function(){return this._signalingState},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"offer",{get:function(){return this._offer},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"answer",{get:function(){return this._answer},enumerable:!0,configurable:!0}),t.prototype.confirm=function(){this.early&&this.start2xxRetransmissionTimer(),e.prototype.confirm.call(this)},t.prototype.reConfirm=function(){this.reinviteUserAgentServer&&this.startReInvite2xxRetransmissionTimer()},t.prototype.ack=function(e){var t;if(void 0===e&&(e={}),this.logger.log("INVITE dialog "+this.id+" sending ACK request"),this.reinviteUserAgentClient){if(!(this.reinviteUserAgentClient.transaction instanceof a.InviteClientTransaction))throw new Error("Transaction not instance of InviteClientTransaction.");t=this.reinviteUserAgentClient.transaction,this.reinviteUserAgentClient=void 0}else{if(!(this.initialTransaction instanceof a.InviteClientTransaction))throw new Error("Initial transaction not instance of InviteClientTransaction.");t=this.initialTransaction}e.cseq=t.request.cseq;var r=this.createOutgoingRequestMessage(n.C.ACK,e);return t.ackResponse(r),this.signalingStateTransition(r),{message:r}},t.prototype.bye=function(e,t){if(this.logger.log("INVITE dialog "+this.id+" sending BYE request"),this.initialTransaction instanceof a.InviteServerTransaction){if(this.early)throw new Error("UAS MUST NOT send a BYE on early dialogs.");if(this.ackWait&&this.initialTransaction.state!==a.TransactionState.Terminated)throw new Error("UAS MUST NOT send a BYE on a confirmed dialog until it has received an ACK for its 2xx response or until the server transaction times out.")}return new c.ByeUserAgentClient(this,e,t)},t.prototype.info=function(e,t){if(this.logger.log("INVITE dialog "+this.id+" sending INFO request"),this.early)throw new Error("Dialog not confirmed.");return new d.InfoUserAgentClient(this,e,t)},t.prototype.invite=function(e,t){if(this.logger.log("INVITE dialog "+this.id+" sending INVITE request"),this.early)throw new Error("Dialog not confirmed.");if(this.reinviteUserAgentClient)throw new Error("There is an ongoing re-INVITE client transaction.");if(this.reinviteUserAgentServer)throw new Error("There is an ongoing re-INVITE server transaction.");return new m.ReInviteUserAgentClient(this,e,t)},t.prototype.notify=function(e,t){if(this.logger.log("INVITE dialog "+this.id+" sending NOTIFY request"),this.early)throw new Error("Dialog not confirmed.");return new l.NotifyUserAgentClient(this,e,t)},t.prototype.prack=function(e,t){return this.logger.log("INVITE dialog "+this.id+" sending PRACK request"),new g.PrackUserAgentClient(this,e,t)},t.prototype.refer=function(e,t){if(this.logger.log("INVITE dialog "+this.id+" sending REFER request"),this.early)throw new Error("Dialog not confirmed.");return new S.ReferUserAgentClient(this,e,t)},t.prototype.receiveRequest=function(t){if(this.logger.log("INVITE dialog "+this.id+" received "+t.method+" request"),t.method===n.C.ACK){if(this.ackWait){if(this.initialTransaction instanceof a.InviteClientTransaction)return void this.logger.warn("INVITE dialog "+this.id+" received unexpected "+t.method+" request, dropping.");if(this.initialTransaction.request.cseq!==t.cseq)return void this.logger.warn("INVITE dialog "+this.id+" received unexpected "+t.method+" request, dropping.");this.ackWait=!1}else{if(!this.reinviteUserAgentServer)return void this.logger.warn("INVITE dialog "+this.id+" received unexpected "+t.method+" request, dropping.");if(this.reinviteUserAgentServer.transaction.request.cseq!==t.cseq)return void this.logger.warn("INVITE dialog "+this.id+" received unexpected "+t.method+" request, dropping.");this.reinviteUserAgentServer=void 0}return this.signalingStateTransition(t),void(this.delegate&&this.delegate.onAck&&this.delegate.onAck({message:t}))}if(this.sequenceGuard(t)){if(t.method===n.C.INVITE){if(this.reinviteUserAgentServer){var r=["Retry-After: "+(Math.floor(10*Math.random())+1)];return void this.core.replyStateless(t,{statusCode:500,extraHeaders:r})}if(this.reinviteUserAgentClient)return void this.core.replyStateless(t,{statusCode:491})}if(e.prototype.receiveRequest.call(this,t),t.method===n.C.INVITE){var i=t.parseHeader("contact");if(!i)throw new Error("Contact undefined.");if(!(i instanceof n.NameAddrHeader))throw new Error("Contact not instance of NameAddrHeader.");this.dialogState.remoteTarget=i.uri}switch(t.method){case n.C.BYE:var s=new u.ByeUserAgentServer(this,t);this.delegate&&this.delegate.onBye?this.delegate.onBye(s):s.accept(),this.dispose();break;case n.C.INFO:s=new p.InfoUserAgentServer(this,t);this.delegate&&this.delegate.onInfo?this.delegate.onInfo(s):s.reject({statusCode:469,extraHeaders:["Recv-Info :"]});break;case n.C.INVITE:s=new v.ReInviteUserAgentServer(this,t);this.signalingStateTransition(t),this.delegate&&this.delegate.onInvite?this.delegate.onInvite(s):s.reject({statusCode:488});break;case n.C.NOTIFY:s=new h.NotifyUserAgentServer(this,t);this.delegate&&this.delegate.onNotify?this.delegate.onNotify(s):s.accept();break;case n.C.PRACK:s=new f.PrackUserAgentServer(this,t);this.delegate&&this.delegate.onPrack?this.delegate.onPrack(s):s.accept();break;case n.C.REFER:s=new T.ReferUserAgentServer(this,t);this.delegate&&this.delegate.onRefer?this.delegate.onRefer(s):s.reject();break;default:this.logger.log("INVITE dialog "+this.id+" received unimplemented "+t.method+" request"),this.core.replyStateless(t,{statusCode:501})}}else this.logger.log("INVITE dialog "+this.id+" rejected out of order "+t.method+" request.")},t.prototype.reliableSequenceGuard=function(e){var t=e.statusCode;if(!t)throw new Error("Status code undefined");if(t>100&&t<200){var r=e.getHeader("require"),i=e.getHeader("rseq"),n=r&&r.includes("100rel")&&i?Number(i):void 0;if(n){if(this.rseq&&this.rseq+1!==n)return!1;this.rseq||(this.rseq=n)}}return!0},t.prototype.signalingStateRollback=function(){this._signalingState!==s.SignalingState.HaveLocalOffer&&this.signalingState!==s.SignalingState.HaveRemoteOffer||this._rollbackOffer&&this._rollbackAnswer&&(this._signalingState=s.SignalingState.Stable,this._offer=this._rollbackOffer,this._answer=this._rollbackAnswer)},t.prototype.signalingStateTransition=function(e){var t=n.getBody(e);if(t&&"session"===t.contentDisposition){if(this._signalingState===s.SignalingState.Stable&&(this._rollbackOffer=this._offer,this._rollbackAnswer=this._answer),e instanceof n.IncomingRequestMessage)switch(this._signalingState){case s.SignalingState.Initial:case s.SignalingState.Stable:this._signalingState=s.SignalingState.HaveRemoteOffer,this._offer=t,this._answer=void 0;break;case s.SignalingState.HaveLocalOffer:this._signalingState=s.SignalingState.Stable,this._answer=t;break;case s.SignalingState.HaveRemoteOffer:case s.SignalingState.Closed:break;default:throw new Error("Unexpected signaling state.")}if(e instanceof n.IncomingResponseMessage)switch(this._signalingState){case s.SignalingState.Initial:case s.SignalingState.Stable:this._signalingState=s.SignalingState.HaveRemoteOffer,this._offer=t,this._answer=void 0;break;case s.SignalingState.HaveLocalOffer:this._signalingState=s.SignalingState.Stable,this._answer=t;break;case s.SignalingState.HaveRemoteOffer:case s.SignalingState.Closed:break;default:throw new Error("Unexpected signaling state.")}if(e instanceof n.OutgoingRequestMessage)switch(this._signalingState){case s.SignalingState.Initial:case s.SignalingState.Stable:this._signalingState=s.SignalingState.HaveLocalOffer,this._offer=t,this._answer=void 0;break;case s.SignalingState.HaveLocalOffer:break;case s.SignalingState.HaveRemoteOffer:this._signalingState=s.SignalingState.Stable,this._answer=t;break;case s.SignalingState.Closed:break;default:throw new Error("Unexpected signaling state.")}if(n.isBody(e))switch(this._signalingState){case s.SignalingState.Initial:case s.SignalingState.Stable:this._signalingState=s.SignalingState.HaveLocalOffer,this._offer=t,this._answer=void 0;break;case s.SignalingState.HaveLocalOffer:break;case s.SignalingState.HaveRemoteOffer:this._signalingState=s.SignalingState.Stable,this._answer=t;break;case s.SignalingState.Closed:break;default:throw new Error("Unexpected signaling state.")}}},t.prototype.start2xxRetransmissionTimer=function(){var e=this;if(this.initialTransaction instanceof a.InviteServerTransaction){var t=this.initialTransaction,r=o.Timers.T1,i=function(){e.ackWait?(e.logger.log("No ACK for 2xx response received, attempting retransmission"),t.retransmitAcceptedResponse(),r=Math.min(2*r,o.Timers.T2),e.invite2xxTimer=setTimeout(i,r)):e.invite2xxTimer=void 0};this.invite2xxTimer=setTimeout(i,r);var n=function(){t.state===a.TransactionState.Terminated&&(t.removeListener("stateChanged",n),e.invite2xxTimer&&(clearTimeout(e.invite2xxTimer),e.invite2xxTimer=void 0),e.ackWait&&(e.delegate&&e.delegate.onAckTimeout?e.delegate.onAckTimeout():e.bye()))};t.addListener("stateChanged",n)}},t.prototype.startReInvite2xxRetransmissionTimer=function(){var e=this;if(this.reinviteUserAgentServer&&this.reinviteUserAgentServer.transaction instanceof a.InviteServerTransaction){var t=this.reinviteUserAgentServer.transaction,r=o.Timers.T1,i=function(){e.reinviteUserAgentServer?(e.logger.log("No ACK for 2xx response received, attempting retransmission"),t.retransmitAcceptedResponse(),r=Math.min(2*r,o.Timers.T2),e.invite2xxTimer=setTimeout(i,r)):e.invite2xxTimer=void 0};this.invite2xxTimer=setTimeout(i,r);var n=function(){t.state===a.TransactionState.Terminated&&(t.removeListener("stateChanged",n),e.invite2xxTimer&&(clearTimeout(e.invite2xxTimer),e.invite2xxTimer=void 0),e.reinviteUserAgentServer)};t.addListener("stateChanged",n)}},t}(r(18).Dialog);t.SessionDialog=y},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),function(e){e.Initial="Initial",e.Early="Early",e.AckWait="AckWait",e.Confirmed="Confirmed",e.Terminated="Terminated"}(t.SessionState||(t.SessionState={})),function(e){e.Initial="Initial",e.HaveLocalOffer="HaveLocalOffer",e.HaveRemoteOffer="HaveRemoteOffer",e.Stable="Stable",e.Closed="Closed"}(t.SignalingState||(t.SignalingState={}))},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=r(0),n=function(e){function t(t){return e.call(this,t||"Transaction state error.")||this}return i.__extends(t,e),t}(r(24).Exception);t.TransactionStateError=n},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=r(0),n=function(e){function t(t){return e.call(this,t||"Unspecified transport error.")||this}return i.__extends(t,e),t}(r(24).Exception);t.TransportError=n},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=r(0),n=r(2),s=r(6),o=r(25),a=r(13),c=function(e){function t(t,r,i){return e.call(this,t,r,i,a.TransactionState.Proceeding,"sip.transaction.ist")||this}return i.__extends(t,e),t.prototype.dispose=function(){this.stopProgressExtensionTimer(),this.H&&(clearTimeout(this.H),this.H=void 0),this.I&&(clearTimeout(this.I),this.I=void 0),this.L&&(clearTimeout(this.L),this.L=void 0),e.prototype.dispose.call(this)},Object.defineProperty(t.prototype,"kind",{get:function(){return"ist"},enumerable:!0,configurable:!0}),t.prototype.receiveRequest=function(e){var t=this;switch(this.state){case a.TransactionState.Proceeding:if(e.method===n.C.INVITE)return void(this.lastProvisionalResponse&&this.send(this.lastProvisionalResponse).catch((function(e){t.logTransportError(e,"Failed to send retransmission of provisional response.")})));break;case a.TransactionState.Accepted:if(e.method===n.C.INVITE)return;break;case a.TransactionState.Completed:if(e.method===n.C.INVITE){if(!this.lastFinalResponse)throw new Error("Last final response undefined.");return void this.send(this.lastFinalResponse).catch((function(e){t.logTransportError(e,"Failed to send retransmission of final response.")}))}if(e.method===n.C.ACK)return void this.stateTransition(a.TransactionState.Confirmed);break;case a.TransactionState.Confirmed:case a.TransactionState.Terminated:if(e.method===n.C.INVITE||e.method===n.C.ACK)return;break;default:throw new Error("Invalid state "+this.state)}var r="INVITE server transaction received unexpected "+e.method+" request while in state "+this.state+".";this.logger.warn(r)},t.prototype.receiveResponse=function(e,t){var r=this;if(e<100||e>699)throw new Error("Invalid status code "+e);switch(this.state){case a.TransactionState.Proceeding:if(e>=100&&e<=199)return this.lastProvisionalResponse=t,e>100&&this.startProgressExtensionTimer(),void this.send(t).catch((function(e){r.logTransportError(e,"Failed to send 1xx response.")}));if(e>=200&&e<=299)return this.lastFinalResponse=t,this.stateTransition(a.TransactionState.Accepted),void this.send(t).catch((function(e){r.logTransportError(e,"Failed to send 2xx response.")}));if(e>=300&&e<=699)return this.lastFinalResponse=t,this.stateTransition(a.TransactionState.Completed),void this.send(t).catch((function(e){r.logTransportError(e,"Failed to send non-2xx final response.")}));break;case a.TransactionState.Accepted:if(e>=200&&e<=299)return void this.send(t).catch((function(e){r.logTransportError(e,"Failed to send 2xx response.")}));break;case a.TransactionState.Completed:case a.TransactionState.Confirmed:case a.TransactionState.Terminated:break;default:throw new Error("Invalid state "+this.state)}var i="INVITE server transaction received unexpected "+e+" response from TU while in state "+this.state+".";throw this.logger.error(i),new Error(i)},t.prototype.retransmitAcceptedResponse=function(){var e=this;this.state===a.TransactionState.Accepted&&this.lastFinalResponse&&this.send(this.lastFinalResponse).catch((function(t){e.logTransportError(t,"Failed to send 2xx response.")}))},t.prototype.onTransportError=function(e){this.user.onTransportError&&this.user.onTransportError(e)},t.prototype.typeToString=function(){return"INVITE server transaction"},t.prototype.stateTransition=function(e){var t=this,r=function(){throw new Error("Invalid state transition from "+t.state+" to "+e)};switch(e){case a.TransactionState.Proceeding:r();break;case a.TransactionState.Accepted:case a.TransactionState.Completed:this.state!==a.TransactionState.Proceeding&&r();break;case a.TransactionState.Confirmed:this.state!==a.TransactionState.Completed&&r();break;case a.TransactionState.Terminated:this.state!==a.TransactionState.Accepted&&this.state!==a.TransactionState.Completed&&this.state!==a.TransactionState.Confirmed&&r();break;default:r()}this.stopProgressExtensionTimer(),e===a.TransactionState.Accepted&&(this.L=setTimeout((function(){return t.timer_L()}),s.Timers.TIMER_L)),e===a.TransactionState.Completed&&(this.H=setTimeout((function(){return t.timer_H()}),s.Timers.TIMER_H)),e===a.TransactionState.Confirmed&&(this.I=setTimeout((function(){return t.timer_I()}),s.Timers.TIMER_I)),e===a.TransactionState.Terminated&&this.dispose(),this.setState(e)},t.prototype.startProgressExtensionTimer=function(){var e=this;void 0===this.progressExtensionTimer&&(this.progressExtensionTimer=setInterval((function(){if(e.logger.debug("Progress extension timer expired for INVITE server transaction "+e.id+"."),!e.lastProvisionalResponse)throw new Error("Last provisional response undefined.");e.send(e.lastProvisionalResponse).catch((function(t){e.logTransportError(t,"Failed to send retransmission of provisional response.")}))}),s.Timers.PROVISIONAL_RESPONSE_INTERVAL))},t.prototype.stopProgressExtensionTimer=function(){void 0!==this.progressExtensionTimer&&(clearInterval(this.progressExtensionTimer),this.progressExtensionTimer=void 0)},t.prototype.timer_G=function(){},t.prototype.timer_H=function(){this.logger.debug("Timer H expired for INVITE server transaction "+this.id+"."),this.state===a.TransactionState.Completed&&(this.logger.warn("ACK to negative final response was never received, terminating transaction."),this.stateTransition(a.TransactionState.Terminated))},t.prototype.timer_I=function(){this.logger.debug("Timer I expired for INVITE server transaction "+this.id+"."),this.stateTransition(a.TransactionState.Terminated)},t.prototype.timer_L=function(){this.logger.debug("Timer L expired for INVITE server transaction "+this.id+"."),this.state===a.TransactionState.Accepted&&this.stateTransition(a.TransactionState.Terminated)},t}(o.ServerTransaction);t.InviteServerTransaction=c},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=r(0),n=r(6),s=r(22),o=r(13),a=function(e){function t(t,r,i){var s=e.call(this,t,r,i,o.TransactionState.Trying,"sip.transaction.nict")||this;return s.F=setTimeout((function(){return s.timer_F()}),n.Timers.TIMER_F),s.send(t.toString()).catch((function(e){s.logTransportError(e,"Failed to send initial outgoing request.")})),s}return i.__extends(t,e),t.prototype.dispose=function(){this.F&&(clearTimeout(this.F),this.F=void 0),this.K&&(clearTimeout(this.K),this.K=void 0),e.prototype.dispose.call(this)},Object.defineProperty(t.prototype,"kind",{get:function(){return"nict"},enumerable:!0,configurable:!0}),t.prototype.receiveResponse=function(e){var t=e.statusCode;if(!t||t<100||t>699)throw new Error("Invalid status code "+t);switch(this.state){case o.TransactionState.Trying:if(t>=100&&t<=199)return this.stateTransition(o.TransactionState.Proceeding),void(this.user.receiveResponse&&this.user.receiveResponse(e));if(t>=200&&t<=699)return this.stateTransition(o.TransactionState.Completed),408===t?void this.onRequestTimeout():void(this.user.receiveResponse&&this.user.receiveResponse(e));break;case o.TransactionState.Proceeding:if(t>=100&&t<=199&&this.user.receiveResponse)return this.user.receiveResponse(e);if(t>=200&&t<=699)return this.stateTransition(o.TransactionState.Completed),408===t?void this.onRequestTimeout():void(this.user.receiveResponse&&this.user.receiveResponse(e));case o.TransactionState.Completed:case o.TransactionState.Terminated:return;default:throw new Error("Invalid state "+this.state)}var r="Non-INVITE client transaction received unexpected "+t+" response while in state "+this.state+".";this.logger.warn(r)},t.prototype.onTransportError=function(e){this.user.onTransportError&&this.user.onTransportError(e),this.stateTransition(o.TransactionState.Terminated,!0)},t.prototype.typeToString=function(){return"non-INVITE client transaction"},t.prototype.stateTransition=function(e,t){var r=this;void 0===t&&(t=!1);var i=function(){throw new Error("Invalid state transition from "+r.state+" to "+e)};switch(e){case o.TransactionState.Trying:i();break;case o.TransactionState.Proceeding:this.state!==o.TransactionState.Trying&&i();break;case o.TransactionState.Completed:this.state!==o.TransactionState.Trying&&this.state!==o.TransactionState.Proceeding&&i();break;case o.TransactionState.Terminated:this.state!==o.TransactionState.Trying&&this.state!==o.TransactionState.Proceeding&&this.state!==o.TransactionState.Completed&&(t||i());break;default:i()}e===o.TransactionState.Completed&&(this.F&&(clearTimeout(this.F),this.F=void 0),this.K=setTimeout((function(){return r.timer_K()}),n.Timers.TIMER_K)),e===o.TransactionState.Terminated&&this.dispose(),this.setState(e)},t.prototype.timer_F=function(){this.logger.debug("Timer F expired for non-INVITE client transaction "+this.id+"."),this.state!==o.TransactionState.Trying&&this.state!==o.TransactionState.Proceeding||(this.onRequestTimeout(),this.stateTransition(o.TransactionState.Terminated))},t.prototype.timer_K=function(){this.state===o.TransactionState.Completed&&this.stateTransition(o.TransactionState.Terminated)},t}(s.ClientTransaction);t.NonInviteClientTransaction=a},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=r(0),n=r(6),s=r(25),o=r(13),a=function(e){function t(t,r,i){return e.call(this,t,r,i,o.TransactionState.Trying,"sip.transaction.nist")||this}return i.__extends(t,e),t.prototype.dispose=function(){this.J&&(clearTimeout(this.J),this.J=void 0),e.prototype.dispose.call(this)},Object.defineProperty(t.prototype,"kind",{get:function(){return"nist"},enumerable:!0,configurable:!0}),t.prototype.receiveRequest=function(e){var t=this;switch(this.state){case o.TransactionState.Trying:break;case o.TransactionState.Proceeding:if(!this.lastResponse)throw new Error("Last response undefined.");this.send(this.lastResponse).catch((function(e){t.logTransportError(e,"Failed to send retransmission of provisional response.")}));break;case o.TransactionState.Completed:if(!this.lastResponse)throw new Error("Last response undefined.");this.send(this.lastResponse).catch((function(e){t.logTransportError(e,"Failed to send retransmission of final response.")}));break;case o.TransactionState.Terminated:break;default:throw new Error("Invalid state "+this.state)}},t.prototype.receiveResponse=function(e,t){var r=this;if(e<100||e>699)throw new Error("Invalid status code "+e);if(e>100&&e<=199)throw new Error("Provisional response other than 100 not allowed.");switch(this.state){case o.TransactionState.Trying:if(this.lastResponse=t,e>=100&&e<200)return this.stateTransition(o.TransactionState.Proceeding),void this.send(t).catch((function(e){r.logTransportError(e,"Failed to send provisional response.")}));if(e>=200&&e<=699)return this.stateTransition(o.TransactionState.Completed),void this.send(t).catch((function(e){r.logTransportError(e,"Failed to send final response.")}));break;case o.TransactionState.Proceeding:if(this.lastResponse=t,e>=200&&e<=699)return this.stateTransition(o.TransactionState.Completed),void this.send(t).catch((function(e){r.logTransportError(e,"Failed to send final response.")}));break;case o.TransactionState.Completed:return;case o.TransactionState.Terminated:break;default:throw new Error("Invalid state "+this.state)}var i="Non-INVITE server transaction received unexpected "+e+" response from TU while in state "+this.state+".";throw this.logger.error(i),new Error(i)},t.prototype.onTransportError=function(e){this.user.onTransportError&&this.user.onTransportError(e),this.stateTransition(o.TransactionState.Terminated,!0)},t.prototype.typeToString=function(){return"non-INVITE server transaction"},t.prototype.stateTransition=function(e,t){var r=this;void 0===t&&(t=!1);var i=function(){throw new Error("Invalid state transition from "+r.state+" to "+e)};switch(e){case o.TransactionState.Trying:i();break;case o.TransactionState.Proceeding:this.state!==o.TransactionState.Trying&&i();break;case o.TransactionState.Completed:this.state!==o.TransactionState.Trying&&this.state!==o.TransactionState.Proceeding&&i();break;case o.TransactionState.Terminated:this.state!==o.TransactionState.Proceeding&&this.state!==o.TransactionState.Completed&&(t||i());break;default:i()}e===o.TransactionState.Completed&&(this.J=setTimeout((function(){return r.timer_J()}),n.Timers.TIMER_J)),e===o.TransactionState.Terminated&&this.dispose(),this.setState(e)},t.prototype.timer_J=function(){this.logger.debug("Timer J expired for NON-INVITE server transaction "+this.id+"."),this.state===o.TransactionState.Completed&&this.stateTransition(o.TransactionState.Terminated)},t}(s.ServerTransaction);t.NonInviteServerTransaction=a},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),function(e){e.Initial="Initial",e.NotifyWait="NotifyWait",e.Pending="Pending",e.Active="Active",e.Terminated="Terminated"}(t.SubscriptionState||(t.SubscriptionState={}))},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=r(0);i.__exportStar(r(28),t),i.__exportStar(r(72),t),i.__exportStar(r(49),t)},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=r(28),n=r(49),s=function(){function e(){this.builtinEnabled=!0,this._level=i.Levels.log,this.loggers={},this.logger=this.getLogger("sip:loggerfactory")}return Object.defineProperty(e.prototype,"level",{get:function(){return this._level},set:function(e){e>=0&&e<=3?this._level=e:e>3?this._level=3:i.Levels.hasOwnProperty(e)?this._level=e:this.logger.error("invalid 'level' parameter value: "+JSON.stringify(e))},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"connector",{get:function(){return this._connector},set:function(e){e?"function"==typeof e?this._connector=e:this.logger.error("invalid 'connector' parameter value: "+JSON.stringify(e)):this._connector=void 0},enumerable:!0,configurable:!0}),e.prototype.getLogger=function(e,t){if(t&&3===this.level)return new n.Logger(this,e,t);if(this.loggers[e])return this.loggers[e];var r=new n.Logger(this,e);return this.loggers[e]=r,r},e.prototype.genericLog=function(e,t,r,n){this.level>=e&&this.builtinEnabled&&this.print(e,t,r,n),this.connector&&this.connector(i.Levels[e],t,r,n)},e.prototype.print=function(e,t,r,n){if("string"==typeof n){var s=[new Date,t];r&&s.push(r),n=s.concat(n).join(" | ")}switch(e){case i.Levels.error:console.error(n);break;case i.Levels.warn:console.warn(n);break;case i.Levels.log:console.log(n);break;case i.Levels.debug:console.debug(n)}},e}();t.LoggerFactory=s},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),r(0).__exportStar(r(74),t)},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=r(0),n=r(2),s=r(1),o=r(50),a=r(14),c=["application/sdp","application/dtmf-relay"],u=function(){function e(e,t){void 0===t&&(t={}),this.userAgentClients=new Map,this.userAgentServers=new Map,this.configuration=e,this.delegate=t,this.dialogs=new Map,this.subscribers=new Map,this.logger=e.loggerFactory.getLogger("sip.user-agent-core")}return e.prototype.dispose=function(){this.reset()},e.prototype.reset=function(){this.dialogs.forEach((function(e){return e.dispose()})),this.dialogs.clear(),this.subscribers.forEach((function(e){return e.dispose()})),this.subscribers.clear(),this.userAgentClients.forEach((function(e){return e.dispose()})),this.userAgentClients.clear(),this.userAgentServers.forEach((function(e){return e.dispose()})),this.userAgentServers.clear()},Object.defineProperty(e.prototype,"loggerFactory",{get:function(){return this.configuration.loggerFactory},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"transport",{get:function(){var e=this.configuration.transportAccessor();if(!e)throw new Error("Transport undefined.");return e},enumerable:!0,configurable:!0}),e.prototype.invite=function(e,t){return new o.InviteUserAgentClient(this,e,t)},e.prototype.message=function(e,t){return new o.MessageUserAgentClient(this,e,t)},e.prototype.publish=function(e,t){return new o.PublishUserAgentClient(this,e,t)},e.prototype.register=function(e,t){return new o.RegisterUserAgentClient(this,e,t)},e.prototype.subscribe=function(e,t){return new o.SubscribeUserAgentClient(this,e,t)},e.prototype.request=function(e,t){return new o.UserAgentClient(s.NonInviteClientTransaction,this,e,t)},e.prototype.makeOutgoingRequestMessage=function(e,t,r,s,o,a,c){var u=this.configuration.sipjsId,d=this.configuration.displayName,p=this.configuration.viaForceRport,l=this.configuration.hackViaTcp,h=this.configuration.supportedOptionTags.slice();e===n.C.REGISTER&&h.push("path","gruu"),e===n.C.INVITE&&(this.configuration.contact.pubGruu||this.configuration.contact.tempGruu)&&h.push("gruu");var g={callIdPrefix:u,forceRport:p,fromDisplayName:d,hackViaTcp:l,optionTags:h,routeSet:this.configuration.routeSet,userAgentString:this.configuration.userAgentHeaderFieldValue,viaHost:this.configuration.viaHost},f=i.__assign(i.__assign({},g),o);return new n.OutgoingRequestMessage(e,t,r,s,f,a,c)},e.prototype.receiveIncomingRequestFromTransport=function(e){this.receiveRequestFromTransport(e)},e.prototype.receiveIncomingResponseFromTransport=function(e){this.receiveResponseFromTransport(e)},e.prototype.replyStateless=function(e,t){var r=this,s=this.configuration.userAgentHeaderFieldValue,o=this.configuration.supportedOptionTagsResponse;t=i.__assign(i.__assign({},t),{userAgent:s,supported:o});var a=n.constructOutgoingResponse(e,t);return this.transport.send(a.message).catch((function(t){t instanceof Error&&r.logger.error(t.message),r.logger.error("Transport error occurred sending stateless reply to "+e.method+" request.")})),a},e.prototype.receiveRequestFromTransport=function(e){var t=e.viaBranch,r=this.userAgentServers.get(t);e.method===n.C.ACK&&r&&r.transaction.state===s.TransactionState.Accepted&&r instanceof o.InviteUserAgentServer?this.logger.warn("Discarding out of dialog ACK after 2xx response sent on transaction "+t+"."):e.method!==n.C.CANCEL?r?r.transaction.receiveRequest(e):this.receiveRequest(e):r?(this.replyStateless(e,{statusCode:200}),r.transaction instanceof s.InviteServerTransaction&&r.transaction.state===s.TransactionState.Proceeding&&r instanceof o.InviteUserAgentServer&&r.receiveCancel(e)):this.replyStateless(e,{statusCode:481})},e.prototype.receiveRequest=function(e){if(-1!==a.AllowedMethods.indexOf(e.method)){if(!e.ruri)throw new Error("Request-URI undefined.");if("sip"===e.ruri.scheme){var t=e.ruri,r=function(e){return!!e&&e.user===t.user};if(!r(this.configuration.aor)&&!(r(this.configuration.contact.uri)||r(this.configuration.contact.pubGruu)||r(this.configuration.contact.tempGruu)))return this.logger.warn("Request-URI does not point to us."),void(e.method!==n.C.ACK&&this.replyStateless(e,{statusCode:404}));if(e.method!==n.C.INVITE||e.hasHeader("Contact")){if(!e.toTag){var i=e.viaBranch;if(!this.userAgentServers.has(i))if(Array.from(this.userAgentServers.values()).some((function(t){return t.transaction.request.fromTag===e.fromTag&&t.transaction.request.callId===e.callId&&t.transaction.request.cseq===e.cseq})))return void this.replyStateless(e,{statusCode:482})}e.toTag?this.receiveInsideDialogRequest(e):this.receiveOutsideDialogRequest(e)}else this.replyStateless(e,{statusCode:400,reasonPhrase:"Missing Contact Header"})}else this.replyStateless(e,{statusCode:416})}else{var s="Allow: "+a.AllowedMethods.toString();this.replyStateless(e,{statusCode:405,extraHeaders:[s]})}},e.prototype.receiveInsideDialogRequest=function(e){if(e.method===n.C.NOTIFY){var t=e.parseHeader("Event");if(!t||!t.event)return void this.replyStateless(e,{statusCode:489});var r=e.callId+e.toTag+t.event,i=this.subscribers.get(r);if(i){var s=new o.NotifyUserAgentServer(this,e);return void i.onNotify(s)}}var u=e.callId+e.toTag+e.fromTag,d=this.dialogs.get(u);if(d){if(e.method===n.C.OPTIONS){var p="Allow: "+a.AllowedMethods.toString(),l="Accept: "+c.toString();return void this.replyStateless(e,{statusCode:200,extraHeaders:[p,l]})}d.receiveRequest(e)}else e.method!==n.C.ACK&&this.replyStateless(e,{statusCode:481})},e.prototype.receiveOutsideDialogRequest=function(e){switch(e.method){case n.C.ACK:break;case n.C.BYE:this.replyStateless(e,{statusCode:481});break;case n.C.CANCEL:throw new Error("Unexpected out of dialog request method "+e.method+".");case n.C.INFO:this.replyStateless(e,{statusCode:405});break;case n.C.INVITE:var t=new o.InviteUserAgentServer(this,e);this.delegate.onInvite?this.delegate.onInvite(t):t.reject();break;case n.C.MESSAGE:t=new o.MessageUserAgentServer(this,e);this.delegate.onMessage?this.delegate.onMessage(t):t.accept();break;case n.C.NOTIFY:t=new o.NotifyUserAgentServer(this,e);this.delegate.onNotify?this.delegate.onNotify(t):t.reject({statusCode:405});break;case n.C.OPTIONS:var r="Allow: "+a.AllowedMethods.toString(),i="Accept: "+c.toString();this.replyStateless(e,{statusCode:200,extraHeaders:[r,i]});break;case n.C.REFER:t=new o.ReferUserAgentServer(this,e);this.delegate.onRefer?this.delegate.onRefer(t):t.reject({statusCode:405});break;case n.C.REGISTER:t=new o.RegisterUserAgentServer(this,e);this.delegate.onRegister?this.delegate.onRegister(t):t.reject({statusCode:405});break;case n.C.SUBSCRIBE:t=new o.SubscribeUserAgentServer(this,e);this.delegate.onSubscribe?this.delegate.onSubscribe(t):t.reject({statusCode:480});break;default:throw new Error("Unexpected out of dialog request method "+e.method+".")}},e.prototype.receiveResponseFromTransport=function(e){if(e.getHeaders("via").length>1)this.logger.warn("More than one Via header field present in the response, dropping");else{var t=e.viaBranch+e.method,r=this.userAgentClients.get(t);r?r.transaction.receiveResponse(e):this.logger.warn("Discarding unmatched "+e.statusCode+" response to "+e.method+" "+t+".")}},e}();t.UserAgentCore=u},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=r(0),n=r(1),s=function(e){function t(t,r,i){return e.call(this,n.NonInviteClientTransaction,t,r,i)||this}return i.__extends(t,e),t}(r(3).UserAgentClient);t.CancelUserAgentClient=s},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=r(0),n=r(17),s=r(15),o=r(1),a=function(e){function t(t,r,i){var n=e.call(this,o.InviteClientTransaction,t,r,i)||this;return n.confirmedDialogAcks=new Map,n.confirmedDialogs=new Map,n.earlyDialogs=new Map,n.delegate=i,n}return i.__extends(t,e),t.prototype.dispose=function(){this.earlyDialogs.forEach((function(e){return e.dispose()})),this.earlyDialogs.clear(),e.prototype.dispose.call(this)},t.prototype.onTransportError=function(t){if(this.transaction.state===o.TransactionState.Calling)return e.prototype.onTransportError.call(this,t);this.logger.error(t.message),this.logger.error("User agent client request transport error while sending ACK.")},t.prototype.receiveResponse=function(e){var t=this;if(this.authenticationGuard(e)){var r=e.statusCode?e.statusCode.toString():"";if(!r)throw new Error("Response status code undefined.");switch(!0){case/^100$/.test(r):return void(this.delegate&&this.delegate.onTrying&&this.delegate.onTrying({message:e}));case/^1[0-9]{2}$/.test(r):if(!e.toTag)return void this.logger.warn("Non-100 1xx INVITE response received without a to tag, dropping.");var i=n.Dialog.initialDialogStateForUserAgentClient(this.message,e),a=this.earlyDialogs.get(i.id);if(!a){if(!((d=this.transaction)instanceof o.InviteClientTransaction))throw new Error("Transaction not instance of InviteClientTransaction.");a=new n.SessionDialog(d,this.core,i),this.earlyDialogs.set(a.id,a)}if(!a.reliableSequenceGuard(e))return void this.logger.warn("1xx INVITE reliable response received out of order, dropping.");a.signalingState!==s.SignalingState.Initial&&a.signalingState!==s.SignalingState.HaveLocalOffer||a.signalingStateTransition(e);var c=a;return void(this.delegate&&this.delegate.onProgress&&this.delegate.onProgress({message:e,session:c,prack:function(e){return c.prack(void 0,e)}}));case/^2[0-9]{2}$/.test(r):i=n.Dialog.initialDialogStateForUserAgentClient(this.message,e);var u=this.confirmedDialogs.get(i.id);if(u){if(l=this.confirmedDialogAcks.get(i.id)){if(!((d=this.transaction)instanceof o.InviteClientTransaction))throw new Error("Client transaction not instance of InviteClientTransaction.");d.ackResponse(l.message)}return}if(u=this.earlyDialogs.get(i.id))u.confirm(),u.recomputeRouteSet(e),this.earlyDialogs.delete(u.id),this.confirmedDialogs.set(u.id,u);else{var d;if(!((d=this.transaction)instanceof o.InviteClientTransaction))throw new Error("Transaction not instance of InviteClientTransaction.");u=new n.SessionDialog(d,this.core,i),this.confirmedDialogs.set(u.id,u)}u.signalingState!==s.SignalingState.Initial&&u.signalingState!==s.SignalingState.HaveLocalOffer||u.signalingStateTransition(e);var p=u;if(this.delegate&&this.delegate.onAccept)this.delegate.onAccept({message:e,session:p,ack:function(e){var r=p.ack(e);return t.confirmedDialogAcks.set(p.id,r),r}});else{var l=p.ack();this.confirmedDialogAcks.set(p.id,l)}return;case/^3[0-9]{2}$/.test(r):return this.earlyDialogs.forEach((function(e){return e.dispose()})),this.earlyDialogs.clear(),void(this.delegate&&this.delegate.onRedirect&&this.delegate.onRedirect({message:e}));case/^[4-6][0-9]{2}$/.test(r):return this.earlyDialogs.forEach((function(e){return e.dispose()})),this.earlyDialogs.clear(),void(this.delegate&&this.delegate.onReject&&this.delegate.onReject({message:e}));default:throw new Error("Invalid status code "+r)}throw new Error("Executing what should be an unreachable code path receiving "+r+" response.")}},t}(r(3).UserAgentClient);t.InviteUserAgentClient=a},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=r(0),n=r(17),s=r(16),o=r(15),a=r(1),c=r(14),u=function(e){function t(t,r,i){var n=e.call(this,a.InviteServerTransaction,t,r,i)||this;return n.core=t,n}return i.__extends(t,e),t.prototype.dispose=function(){this.earlyDialog&&this.earlyDialog.dispose(),e.prototype.dispose.call(this)},t.prototype.accept=function(t){if(void 0===t&&(t={statusCode:200}),!this.acceptable)throw new s.TransactionStateError(this.message.method+" not acceptable in state "+this.transaction.state+".");if(!this.confirmedDialog)if(this.earlyDialog)this.earlyDialog.confirm(),this.confirmedDialog=this.earlyDialog,this.earlyDialog=void 0;else{var r=this.transaction;if(!(r instanceof a.InviteServerTransaction))throw new Error("Transaction not instance of InviteClientTransaction.");var u=n.Dialog.initialDialogStateForUserAgentServer(this.message,this.toTag);this.confirmedDialog=new n.SessionDialog(r,this.core,u)}var d=this.message.getHeaders("record-route").map((function(e){return"Record-Route: "+e})),p="Contact: "+this.core.configuration.contact.toString(),l="Allow: "+c.AllowedMethods.toString();if(!t.body)if(this.confirmedDialog.signalingState===o.SignalingState.Stable)t.body=this.confirmedDialog.answer;else if(this.confirmedDialog.signalingState===o.SignalingState.Initial||this.confirmedDialog.signalingState===o.SignalingState.HaveRemoteOffer)throw new Error("Response must have a body.");t.statusCode=t.statusCode||200,t.extraHeaders=t.extraHeaders||[],t.extraHeaders=t.extraHeaders.concat(d),t.extraHeaders.push(l),t.extraHeaders.push(p);var h=e.prototype.accept.call(this,t),g=this.confirmedDialog,f=i.__assign(i.__assign({},h),{session:g});return t.body&&this.confirmedDialog.signalingState!==o.SignalingState.Stable&&this.confirmedDialog.signalingStateTransition(t.body),f},t.prototype.progress=function(t){if(void 0===t&&(t={statusCode:180}),!this.progressable)throw new s.TransactionStateError(this.message.method+" not progressable in state "+this.transaction.state+".");if(!this.earlyDialog){var r=this.transaction;if(!(r instanceof a.InviteServerTransaction))throw new Error("Transaction not instance of InviteClientTransaction.");var c=n.Dialog.initialDialogStateForUserAgentServer(this.message,this.toTag,!0);this.earlyDialog=new n.SessionDialog(r,this.core,c)}var u=this.message.getHeaders("record-route").map((function(e){return"Record-Route: "+e})),d="Contact: "+this.core.configuration.contact;t.extraHeaders=t.extraHeaders||[],t.extraHeaders=t.extraHeaders.concat(u),t.extraHeaders.push(d);var p=e.prototype.progress.call(this,t),l=this.earlyDialog,h=i.__assign(i.__assign({},p),{session:l});return t.body&&this.earlyDialog.signalingState!==o.SignalingState.Stable&&this.earlyDialog.signalingStateTransition(t.body),h},t.prototype.redirect=function(t,r){return void 0===r&&(r={statusCode:302}),e.prototype.redirect.call(this,t,r)},t.prototype.reject=function(t){return void 0===t&&(t={statusCode:486}),e.prototype.reject.call(this,t)},t}(r(4).UserAgentServer);t.InviteUserAgentServer=u},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=r(0),n=r(1),s=function(e){function t(t,r,i){return e.call(this,n.NonInviteClientTransaction,t,r,i)||this}return i.__extends(t,e),t}(r(3).UserAgentClient);t.MessageUserAgentClient=s},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=r(0),n=r(1),s=function(e){function t(t,r,i){var s=e.call(this,n.NonInviteServerTransaction,t,r,i)||this;return s.core=t,s}return i.__extends(t,e),t}(r(4).UserAgentServer);t.MessageUserAgentServer=s},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=r(0),n=r(1),s=function(e){function t(t,r,i){return e.call(this,n.NonInviteClientTransaction,t,r,i)||this}return i.__extends(t,e),t}(r(3).UserAgentClient);t.PublishUserAgentClient=s},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=r(0),n=r(1),s=function(e){function t(t,r,i){return e.call(this,n.NonInviteServerTransaction,t.userAgentCore,r,i)||this}return i.__extends(t,e),t}(r(4).UserAgentServer);t.ReSubscribeUserAgentServer=s},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=r(0),n=r(1),s=function(e){function t(t,r,i){return e.call(this,n.NonInviteClientTransaction,t,r,i)||this}return i.__extends(t,e),t}(r(3).UserAgentClient);t.RegisterUserAgentClient=s},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=r(0),n=r(1),s=function(e){function t(t,r,i){var s=e.call(this,n.NonInviteServerTransaction,t,r,i)||this;return s.core=t,s}return i.__extends(t,e),t}(r(4).UserAgentServer);t.RegisterUserAgentServer=s},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=r(0),n=r(47),s=r(27),o=r(6),a=r(1),c=function(e){function t(t,r,i){var n=this,o=r.getHeader("Event");if(!o)throw new Error("Event undefined");var c=r.getHeader("Expires");if(!c)throw new Error("Expires undefined");return(n=e.call(this,a.NonInviteClientTransaction,t,r,i)||this).delegate=i,n.subscriberId=r.callId+r.fromTag+o,n.subscriptionExpiresRequested=n.subscriptionExpires=Number(c),n.subscriptionEvent=o,n.subscriptionState=s.SubscriptionState.NotifyWait,n.waitNotifyStart(),n}return i.__extends(t,e),t.prototype.dispose=function(){e.prototype.dispose.call(this)},t.prototype.onNotify=function(e){var t=e.message.parseHeader("Event").event;if(!t||t!==this.subscriptionEvent)return this.logger.warn("Failed to parse event."),void e.reject({statusCode:489});var r=e.message.parseHeader("Subscription-State");if(!r||!r.state)return this.logger.warn("Failed to parse subscription state."),void e.reject({statusCode:489});var i=r.state;switch(i){case"pending":case"active":case"terminated":break;default:return this.logger.warn("Invalid subscription state "+i),void e.reject({statusCode:489})}if("terminated"!==i&&!e.message.parseHeader("contact"))return this.logger.warn("Failed to parse contact."),void e.reject({statusCode:489});if(this.dialog)throw new Error("Dialog already created. This implementation only supports install of single subscriptions.");switch(this.waitNotifyStop(),this.subscriptionExpires=r.expires?Math.min(this.subscriptionExpires,Math.max(r.expires,0)):this.subscriptionExpires,i){case"pending":this.subscriptionState=s.SubscriptionState.Pending;break;case"active":this.subscriptionState=s.SubscriptionState.Active;break;case"terminated":this.subscriptionState=s.SubscriptionState.Terminated;break;default:throw new Error("Unrecognized state "+i+".")}if(this.subscriptionState!==s.SubscriptionState.Terminated){var o=n.SubscriptionDialog.initialDialogStateForSubscription(this.message,e.message);this.dialog=new n.SubscriptionDialog(this.subscriptionEvent,this.subscriptionExpires,this.subscriptionState,this.core,o)}if(this.delegate&&this.delegate.onNotify){var a=e,c=this.dialog;this.delegate.onNotify({request:a,subscription:c})}else e.accept()},t.prototype.waitNotifyStart=function(){var e=this;this.N||(this.core.subscribers.set(this.subscriberId,this),this.N=setTimeout((function(){return e.timer_N()}),o.Timers.TIMER_N))},t.prototype.waitNotifyStop=function(){this.N&&(this.core.subscribers.delete(this.subscriberId),clearTimeout(this.N),this.N=void 0)},t.prototype.receiveResponse=function(t){if(this.authenticationGuard(t)){if(t.statusCode&&t.statusCode>=200&&t.statusCode<300){var r=t.getHeader("Expires");if(r){var i=Number(r);i>this.subscriptionExpiresRequested&&this.logger.warn("Expires header in a 200-class response to SUBSCRIBE with a higher value than the one in the request"),i<this.subscriptionExpires&&(this.subscriptionExpires=i)}else this.logger.warn("Expires header missing in a 200-class response to SUBSCRIBE");this.dialog&&this.dialog.subscriptionExpires>this.subscriptionExpires&&(this.dialog.subscriptionExpires=this.subscriptionExpires)}t.statusCode&&t.statusCode>=300&&t.statusCode<700&&this.waitNotifyStop(),e.prototype.receiveResponse.call(this,t)}},t.prototype.timer_N=function(){this.logger.warn("Timer N expired for SUBSCRIBE user agent client. Timed out waiting for NOTIFY."),this.waitNotifyStop(),this.delegate&&this.delegate.onNotifyTimeout&&this.delegate.onNotifyTimeout()},t}(r(3).UserAgentClient);t.SubscribeUserAgentClient=c},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=r(0),n=r(1),s=function(e){function t(t,r,i){var s=e.call(this,n.NonInviteServerTransaction,t,r,i)||this;return s.core=t,s}return i.__extends(t,e),t}(r(4).UserAgentServer);t.SubscribeUserAgentServer=s},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=r(0),n=function(e){function t(t,r){var i=e.call(this)||this;return i.logger=t,i}return i.__extends(t,e),t.prototype.connect=function(e){var t=this;return void 0===e&&(e={}),this.connectPromise(e).then((function(e){e.overrideEvent||t.emit("connected")}))},t.prototype.send=function(e,t){var r=this;return void 0===t&&(t={}),this.sendPromise(e).then((function(e){e.overrideEvent||r.emit("messageSent",e.msg)}))},t.prototype.disconnect=function(e){var t=this;return void 0===e&&(e={}),this.disconnectPromise(e).then((function(e){e.overrideEvent||t.emit("disconnected")}))},t.prototype.afterConnected=function(e){this.isConnected()?e():this.once("connected",e)},t.prototype.waitForConnected=function(){var e=this;return console.warn("DEPRECATION WARNING Transport.waitForConnected(): use afterConnected() instead"),new Promise((function(t){e.afterConnected(t)}))},t}(r(7).EventEmitter);t.Transport=n},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=function(e,t){for(var r,i=[],n=e.split(/\r\n/),s=0;s<n.length;){var o=n[s];if(/^m=(?:audio|video)/.test(o))r={index:s,stripped:[]},i.push(r);else if(r){var a=/^a=rtpmap:(\d+) ([^\/]+)\//.exec(o);if(a&&t===a[2]){n.splice(s,1),r.stripped.push(a[1]);continue}}s++}for(var c=0,u=i;c<u.length;c++){for(var d=u[c],p=n[d.index].split(" "),l=3;l<p.length;)-1===d.stripped.indexOf(p[l])?l++:p.splice(l,1);n[d.index]=p.join(" ")}return n.join("\r\n")},n=function(e,t){var r=new RegExp("m="+t+".*$","gm"),i=new RegExp("^a=group:.*$","gm");if(r.test(e)){var n,s=(e=e.split(/^m=/gm).filter((function(e){if(e.substr(0,t.length)===t){if(n=e.match(/^a=mid:.*$/gm)){var r=n[0].match(/:.+$/g);r&&(n=r[0].substr(1))}return!1}return!0})).join("m=")).match(i);if(s&&1===s.length){var o=s[0],a=new RegExp(" *"+n+"[^ ]*","g");o=o.replace(a,""),e=e.split(i).join(o)}}return e};t.stripTcpCandidates=function(e){return e.sdp=(e.sdp||"").replace(/^a=candidate:\d+ \d+ tcp .*?\r\n/gim,""),Promise.resolve(e)},t.stripTelephoneEvent=function(e){return e.sdp=i(e.sdp||"","telephone-event"),Promise.resolve(e)},t.cleanJitsiSdpImageattr=function(e){return e.sdp=(e.sdp||"").replace(/^(a=imageattr:.*?)(x|y)=\[0-/gm,"$1$2=[1:"),Promise.resolve(e)},t.stripG722=function(e){return e.sdp=i(e.sdp||"","G722"),Promise.resolve(e)},t.stripRtpPayload=function(e){return function(t){return t.sdp=i(t.sdp||"",e),Promise.resolve(t)}},t.stripVideo=function(e){return e.sdp=n(e.sdp||"","video"),Promise.resolve(e)},t.addMidLines=function(e){var t=e.sdp||"";if(-1===t.search(/^a=mid.*$/gm)){var r=t.match(/^m=.*$/gm),i=t.split(/^m=.*$/gm);r&&r.forEach((function(e,t){r[t]=e+"\na=mid:"+t})),i.forEach((function(e,t){r&&r[t]&&(i[t]=e+r[t])})),t=i.join(""),e.sdp=t}return Promise.resolve(e)}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.LIBRARY_VERSION="0.15.6"},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=r(5);!function(e){function t(e,t){var r=t,i=0,n=0;if(e.substring(r,r+2).match(/(^\r\n)/))return-2;for(;0===i;){if(-1===(n=e.indexOf("\r\n",r)))return n;!e.substring(n+2,n+4).match(/(^\r\n)/)&&e.charAt(n+2).match(/(^\s+)/)?r=n+2:i=n}return i}function r(e,t,r,n){var s,o=t.indexOf(":",r),a=t.substring(r,o).trim(),c=t.substring(o+1,n).trim();switch(a.toLowerCase()){case"via":case"v":e.addHeader("via",c),1===e.getHeaders("via").length?(s=e.parseHeader("Via"))&&(e.via=s,e.viaBranch=s.branch):s=0;break;case"from":case"f":e.setHeader("from",c),(s=e.parseHeader("from"))&&(e.from=s,e.fromTag=s.getParam("tag"));break;case"to":case"t":e.setHeader("to",c),(s=e.parseHeader("to"))&&(e.to=s,e.toTag=s.getParam("tag"));break;case"record-route":if(-1===(s=i.Grammar.parse(c,"Record_Route"))){s=void 0;break}for(var u in s)s[u]&&(e.addHeader("record-route",c.substring(s[u].position,s[u].offset)),e.headers["Record-Route"][e.getHeaders("record-route").length-1].parsed=s[u].parsed);break;case"call-id":case"i":e.setHeader("call-id",c),(s=e.parseHeader("call-id"))&&(e.callId=c);break;case"contact":case"m":if(-1===(s=i.Grammar.parse(c,"Contact"))){s=void 0;break}if(!(s instanceof Array)){s=void 0;break}s.forEach((function(t){e.addHeader("contact",c.substring(t.position,t.offset)),e.headers.Contact[e.getHeaders("contact").length-1].parsed=t.parsed}));break;case"content-length":case"l":e.setHeader("content-length",c),s=e.parseHeader("content-length");break;case"content-type":case"c":e.setHeader("content-type",c),s=e.parseHeader("content-type");break;case"cseq":e.setHeader("cseq",c),(s=e.parseHeader("cseq"))&&(e.cseq=s.value),e instanceof i.IncomingResponseMessage&&(e.method=s.method);break;case"max-forwards":e.setHeader("max-forwards",c),s=e.parseHeader("max-forwards");break;case"www-authenticate":e.setHeader("www-authenticate",c),s=e.parseHeader("www-authenticate");break;case"proxy-authenticate":e.setHeader("proxy-authenticate",c),s=e.parseHeader("proxy-authenticate");break;case"refer-to":case"r":e.setHeader("refer-to",c),(s=e.parseHeader("refer-to"))&&(e.referTo=s);break;default:e.addHeader(a.toLowerCase(),c),s=0}return void 0!==s||{error:"error parsing header '"+a+"'"}}e.getHeader=t,e.parseHeader=r,e.parseMessage=function(e,n){var s=0,o=e.indexOf("\r\n");if(-1!==o){var a,c=e.substring(0,o),u=i.Grammar.parse(c,"Request_Response");if(-1!==u){var d;for(u.status_code?((a=new i.IncomingResponseMessage).statusCode=u.status_code,a.reasonPhrase=u.reason_phrase):((a=new i.IncomingRequestMessage).method=u.method,a.ruri=u.uri),a.data=e,s=o+2;;){if(-2===(o=t(e,s))){d=s+2;break}if(-1===o)return void n.error("malformed message");if(!0!==r(a,e,s,o))return void n.error(u.error);s=o+2}return a.hasHeader("content-length")?a.body=e.substr(d,Number(a.getHeader("content-length"))):a.body=e.substring(d),a}n.warn('error parsing first line of SIP message: "'+c+'"')}else n.warn("no CRLF found, not a SIP message, discarded")}}(t.Parser||(t.Parser={}))},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=r(0),n=r(7),s=r(11),o=r(5),a=r(8),c=r(9),u=function(e){function t(r,i){var n=e.call(this)||this;return n.incomingRequest=i,n.data={},t.initializer(n,r,i),n}return i.__extends(t,e),t.initializer=function(e,t,r){var i=r.message;if(e.type=a.TypeStrings.ServerContext,e.ua=t,e.logger=t.getLogger("sip.servercontext"),e.request=i,i.body&&(e.body=i.body),i.hasHeader("Content-Type")&&(e.contentType=i.getHeader("Content-Type")),e.method=i.method,e.localIdentity=i.to,e.remoteIdentity=i.from,i.hasHeader("P-Asserted-Identity")){var n=i.getHeader("P-Asserted-Identity");n&&(e.assertedIdentity=o.Grammar.nameAddrHeaderParse(n))}},t.prototype.progress=function(e){return void 0===e&&(e={}),e.statusCode=e.statusCode||180,e.minCode=100,e.maxCode=199,e.events=["progress"],this.reply(e)},t.prototype.accept=function(e){return void 0===e&&(e={}),e.statusCode=e.statusCode||200,e.minCode=200,e.maxCode=299,e.events=["accepted"],this.reply(e)},t.prototype.reject=function(e){return void 0===e&&(e={}),e.statusCode=e.statusCode||480,e.minCode=300,e.maxCode=699,e.events=["rejected","failed"],this.reply(e)},t.prototype.reply=function(e){var t=this;void 0===e&&(e={});var r=e.statusCode||100,i=e.minCode||100,n=e.maxCode||699,s=c.Utils.getReasonPhrase(r,e.reasonPhrase),a=e.extraHeaders||[],u=e.body?o.fromBodyLegacy(e.body):void 0,d=e.events||[];if(r<i||r>n)throw new TypeError("Invalid statusCode: "+r);var p,l={statusCode:r,reasonPhrase:s,extraHeaders:a,body:u},h=r.toString();switch(!0){case/^100$/.test(h):p=this.incomingRequest.trying(l).message;break;case/^1[0-9]{2}$/.test(h):p=this.incomingRequest.progress(l).message;break;case/^2[0-9]{2}$/.test(h):p=this.incomingRequest.accept(l).message;break;case/^3[0-9]{2}$/.test(h):p=this.incomingRequest.redirect([],l).message;break;case/^[4-6][0-9]{2}$/.test(h):p=this.incomingRequest.reject(l).message;break;default:throw new Error("Invalid status code "+r)}return d.forEach((function(e){t.emit(e,p,s)})),this},t.prototype.onRequestTimeout=function(){this.emit("failed",void 0,s.C.causes.REQUEST_TIMEOUT)},t.prototype.onTransportError=function(){this.emit("failed",void 0,s.C.causes.CONNECTION_ERROR)},t}(n.EventEmitter);t.ServerContext=u},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=r(0),n=r(7),s=r(52),o=r(8),a=r(12),c=r(9),u=i.__importStar(r(87)),d=r(97),p=function(e){function t(t,r,i){var n=e.call(this)||this;return n.type=o.TypeStrings.SessionDescriptionHandler,n.options=i||{},n.logger=t,n.observer=r,n.dtmfSender=void 0,n.shouldAcquireMedia=!0,n.CONTENT_TYPE="application/sdp",n.C={DIRECTION:{NULL:null,SENDRECV:"sendrecv",SENDONLY:"sendonly",RECVONLY:"recvonly",INACTIVE:"inactive"}},n.logger.log("SessionDescriptionHandlerOptions: "+JSON.stringify(n.options)),n.direction=n.C.DIRECTION.NULL,n.modifiers=n.options.modifiers||[],Array.isArray(n.modifiers)||(n.modifiers=[n.modifiers]),n.iceGatheringTimeout=!1,n.initPeerConnection(n.options.peerConnectionOptions),n.constraints=n.checkAndDefaultConstraints(n.options.constraints),n}return i.__extends(t,e),t.defaultFactory=function(e,r){return new t(e instanceof s.Session?e.userAgent.getLogger("sip.sessionDescriptionHandler",e.id):e.ua.getLogger("sip.invitecontext.sessionDescriptionHandler",e.id),new d.SessionDescriptionHandlerObserver(e,r),r)},t.prototype.close=function(){this.logger.log("closing PeerConnection"),this.peerConnection&&"closed"!==this.peerConnection.signalingState&&(this.peerConnection.getSenders?this.peerConnection.getSenders().forEach((function(e){e.track&&e.track.stop()})):(this.logger.warn("Using getLocalStreams which is deprecated"),this.peerConnection.getLocalStreams().forEach((function(e){e.getTracks().forEach((function(e){e.stop()}))}))),this.peerConnection.getReceivers?this.peerConnection.getReceivers().forEach((function(e){e.track&&e.track.stop()})):(this.logger.warn("Using getRemoteStreams which is deprecated"),this.peerConnection.getRemoteStreams().forEach((function(e){e.getTracks().forEach((function(e){e.stop()}))}))),this.resetIceGatheringComplete(),this.peerConnection.close())},t.prototype.getDescription=function(e,t){var r=this;void 0===e&&(e={}),void 0===t&&(t=[]),e.peerConnectionOptions&&this.initPeerConnection(e.peerConnectionOptions);var i=Object.assign({},this.constraints,e.constraints);return i=this.checkAndDefaultConstraints(i),JSON.stringify(i)!==JSON.stringify(this.constraints)&&(this.constraints=i,this.shouldAcquireMedia=!0),Array.isArray(t)||(t=[t]),t=t.concat(this.modifiers),Promise.resolve().then((function(){if(r.shouldAcquireMedia)return r.acquire(r.constraints).then((function(){r.shouldAcquireMedia=!1}))})).then((function(){return r.createOfferOrAnswer(e.RTCOfferOptions,t)})).then((function(e){if(void 0===e.sdp)throw new a.Exceptions.SessionDescriptionHandlerError("getDescription",void 0,"SDP undefined");return r.emit("getDescription",e),{body:e.sdp,contentType:r.CONTENT_TYPE}}))},t.prototype.hasDescription=function(e){return e===this.CONTENT_TYPE},t.prototype.holdModifier=function(e){return e.sdp?(/a=(sendrecv|sendonly|recvonly|inactive)/.test(e.sdp)?(e.sdp=e.sdp.replace(/a=sendrecv\r\n/g,"a=sendonly\r\n"),e.sdp=e.sdp.replace(/a=recvonly\r\n/g,"a=inactive\r\n")):e.sdp=e.sdp.replace(/(m=[^\r]*\r\n)/g,"$1a=sendonly\r\n"),Promise.resolve(e)):Promise.resolve(e)},t.prototype.setDescription=function(e,t,r){var i=this;void 0===t&&(t={}),void 0===r&&(r=[]),t.peerConnectionOptions&&this.initPeerConnection(t.peerConnectionOptions),Array.isArray(r)||(r=[r]),r=r.concat(this.modifiers);var n={type:this.hasOffer("local")?"answer":"offer",sdp:e};return Promise.resolve().then((function(){if(i.shouldAcquireMedia&&i.options.alwaysAcquireMediaFirst)return i.acquire(i.constraints).then((function(){i.shouldAcquireMedia=!1}))})).then((function(){return c.Utils.reducePromises(r,n)})).catch((function(e){if(e.type===o.TypeStrings.SessionDescriptionHandlerError)throw e;var t=new a.Exceptions.SessionDescriptionHandlerError("setDescription",e,"The modifiers did not resolve successfully");throw i.logger.error(t.message),i.emit("peerConnection-setRemoteDescriptionFailed",t),t})).then((function(e){return i.emit("setDescription",e),i.peerConnection.setRemoteDescription(e)})).catch((function(n){if(n.type===o.TypeStrings.SessionDescriptionHandlerError)throw n;if(/^m=video.+$/gm.test(e)&&!t.disableAudioFallback)return t.disableAudioFallback=!0,i.setDescription(e,t,[u.stripVideo].concat(r));var s=new a.Exceptions.SessionDescriptionHandlerError("setDescription",n);throw s.error&&i.logger.error(s.error),i.emit("peerConnection-setRemoteDescriptionFailed",s),s})).then((function(){i.peerConnection.getReceivers?i.emit("setRemoteDescription",i.peerConnection.getReceivers()):i.emit("setRemoteDescription",i.peerConnection.getRemoteStreams()),i.emit("confirmed",i)}))},t.prototype.sendDtmf=function(e,t){if(void 0===t&&(t={}),!this.dtmfSender&&this.hasBrowserGetSenderSupport()){var r=this.peerConnection.getSenders();r.length>0&&(this.dtmfSender=r[0].dtmf)}if(!this.dtmfSender&&this.hasBrowserTrackSupport()){var i=this.peerConnection.getLocalStreams();if(i.length>0){var n=i[0].getAudioTracks();n.length>0&&(this.dtmfSender=this.peerConnection.createDTMFSender(n[0]))}}if(!this.dtmfSender)return!1;try{this.dtmfSender.insertDTMF(e,t.duration,t.interToneGap)}catch(e){if("InvalidStateError"===e.type||"InvalidCharacterError"===e.type)return this.logger.error(e),!1;throw e}return this.logger.log("DTMF sent via RTP: "+e.toString()),!0},t.prototype.getDirection=function(){return this.direction},t.prototype.on=function(t,r){return e.prototype.on.call(this,t,r)},t.prototype.getMediaStream=function(e){return navigator.mediaDevices.getUserMedia(e)},t.prototype.createOfferOrAnswer=function(e,t){var r=this;void 0===e&&(e={}),void 0===t&&(t=[]);var i=this.hasOffer("remote")?"createAnswer":"createOffer",n=this.peerConnection;return this.logger.log(i),(this.hasOffer("remote")?n.createAnswer:n.createOffer).apply(n,e).catch((function(e){if(e.type===o.TypeStrings.SessionDescriptionHandlerError)throw e;var t=new a.Exceptions.SessionDescriptionHandlerError("createOfferOrAnswer",e,"peerConnection-"+i+"Failed");throw r.emit("peerConnection-"+i+"Failed",t),t})).then((function(e){return c.Utils.reducePromises(t,r.createRTCSessionDescriptionInit(e))})).then((function(e){return r.resetIceGatheringComplete(),r.logger.log("Setting local sdp."),r.logger.log("sdp is "+e.sdp||!1),n.setLocalDescription(e)})).catch((function(e){if(e.type===o.TypeStrings.SessionDescriptionHandlerError)throw e;var t=new a.Exceptions.SessionDescriptionHandlerError("createOfferOrAnswer",e,"peerConnection-SetLocalDescriptionFailed");throw r.emit("peerConnection-SetLocalDescriptionFailed",t),t})).then((function(){return r.waitForIceGatheringComplete()})).then((function(){if(!r.peerConnection.localDescription)throw new a.Exceptions.SessionDescriptionHandlerError("Missing local description");var e=r.createRTCSessionDescriptionInit(r.peerConnection.localDescription);return c.Utils.reducePromises(t,e)})).then((function(e){return r.setDirection(e.sdp||""),e})).catch((function(e){if(e.type===o.TypeStrings.SessionDescriptionHandlerError)throw e;var t=new a.Exceptions.SessionDescriptionHandlerError("createOfferOrAnswer",e);throw r.logger.error(t.toString()),t}))},t.prototype.createRTCSessionDescriptionInit=function(e){return{type:e.type,sdp:e.sdp}},t.prototype.addDefaultIceCheckingTimeout=function(e){return void 0===e.iceCheckingTimeout&&(e.iceCheckingTimeout=5e3),e},t.prototype.addDefaultIceServers=function(e){return e.iceServers||(e.iceServers=[{urls:"stun:stun.l.google.com:19302"}]),e},t.prototype.checkAndDefaultConstraints=function(e){var t={audio:!0,video:!this.options.alwaysAcquireMediaFirst};return e=e||t,0===Object.keys(e).length&&e.constructor===Object?t:e},t.prototype.hasBrowserTrackSupport=function(){return Boolean(this.peerConnection.addTrack)},t.prototype.hasBrowserGetSenderSupport=function(){return Boolean(this.peerConnection.getSenders)},t.prototype.initPeerConnection=function(e){var t=this;void 0===e&&(e={}),(e=this.addDefaultIceCheckingTimeout(e)).rtcConfiguration=e.rtcConfiguration||{},e.rtcConfiguration=this.addDefaultIceServers(e.rtcConfiguration),this.logger.log("initPeerConnection"),this.peerConnection&&(this.logger.log("Already have a peer connection for this session. Tearing down."),this.resetIceGatheringComplete(),this.peerConnection.close()),this.peerConnection=new RTCPeerConnection(e.rtcConfiguration),this.logger.log("New peer connection created"),"ontrack"in this.peerConnection?this.peerConnection.addEventListener("track",(function(e){t.logger.log("track added"),t.observer.trackAdded(),t.emit("addTrack",e)})):(this.logger.warn("Using onaddstream which is deprecated"),this.peerConnection.onaddstream=function(e){t.logger.log("stream added"),t.emit("addStream",e)}),this.peerConnection.onicecandidate=function(e){t.emit("iceCandidate",e),e.candidate?t.logger.log("ICE candidate received: "+(null===e.candidate.candidate?null:e.candidate.candidate.trim())):null===e.candidate&&(t.logger.log("ICE candidate gathering complete"),t.triggerIceGatheringComplete())},this.peerConnection.onicegatheringstatechange=function(){switch(t.logger.log("RTCIceGatheringState changed: "+t.peerConnection.iceGatheringState),t.peerConnection.iceGatheringState){case"gathering":t.emit("iceGathering",t),!t.iceGatheringTimer&&e.iceCheckingTimeout&&(t.iceGatheringTimeout=!1,t.iceGatheringTimer=setTimeout((function(){t.logger.log("RTCIceChecking Timeout Triggered after "+e.iceCheckingTimeout+" milliseconds"),t.iceGatheringTimeout=!0,t.triggerIceGatheringComplete()}),e.iceCheckingTimeout));break;case"complete":t.triggerIceGatheringComplete()}},this.peerConnection.oniceconnectionstatechange=function(){var e;switch(t.peerConnection.iceConnectionState){case"new":e="iceConnection";break;case"checking":e="iceConnectionChecking";break;case"connected":e="iceConnectionConnected";break;case"completed":e="iceConnectionCompleted";break;case"failed":e="iceConnectionFailed";break;case"disconnected":e="iceConnectionDisconnected";break;case"closed":e="iceConnectionClosed";break;default:return void t.logger.warn("Unknown iceConnection state: "+t.peerConnection.iceConnectionState)}t.logger.log("ICE Connection State changed to "+e),t.emit(e,t)}},t.prototype.acquire=function(e){var t=this;return e=this.checkAndDefaultConstraints(e),new Promise((function(r,i){t.logger.log("acquiring local media"),t.emit("userMediaRequest",e),e.audio||e.video?t.getMediaStream(e).then((function(e){t.observer.trackAdded(),t.emit("userMedia",e),r(e)})).catch((function(e){t.emit("userMediaFailed",e),i(e)})):r([])})).catch((function(e){if(e.type===o.TypeStrings.SessionDescriptionHandlerError)throw e;var r=new a.Exceptions.SessionDescriptionHandlerError("acquire",e,"unable to acquire streams");throw t.logger.error(r.message),r.error&&t.logger.error(r.error),r})).then((function(e){return t.logger.log("acquired local media streams"),t.peerConnection.removeTrack&&t.peerConnection.getSenders().forEach((function(e){t.peerConnection.removeTrack(e)})),e})).catch((function(e){if(e.type===o.TypeStrings.SessionDescriptionHandlerError)throw e;var r=new a.Exceptions.SessionDescriptionHandlerError("acquire",e,"error removing streams");throw t.logger.error(r.message),r.error&&t.logger.error(r.error),r})).then((function(e){return[].concat(e).forEach((function(e){t.peerConnection.addTrack?e.getTracks().forEach((function(r){t.peerConnection.addTrack(r,e)})):t.peerConnection.addStream(e)})),Promise.resolve()})).catch((function(e){if(e.type===o.TypeStrings.SessionDescriptionHandlerError)throw e;var r=new a.Exceptions.SessionDescriptionHandlerError("acquire",e,"error adding stream");throw t.logger.error(r.message),r.error&&t.logger.error(r.error),r}))},t.prototype.hasOffer=function(e){var t="have-"+e+"-offer";return this.peerConnection.signalingState===t},t.prototype.isIceGatheringComplete=function(){return"complete"===this.peerConnection.iceGatheringState||this.iceGatheringTimeout},t.prototype.resetIceGatheringComplete=function(){this.iceGatheringTimeout=!1,this.logger.log("resetIceGatheringComplete"),this.iceGatheringTimer&&(clearTimeout(this.iceGatheringTimer),this.iceGatheringTimer=void 0),this.iceGatheringDeferred&&(this.iceGatheringDeferred.reject(),this.iceGatheringDeferred=void 0)},t.prototype.setDirection=function(e){var t=e.match(/a=(sendrecv|sendonly|recvonly|inactive)/);if(null===t)return this.direction=this.C.DIRECTION.NULL,void this.observer.directionChanged();var r=t[1];switch(r){case this.C.DIRECTION.SENDRECV:case this.C.DIRECTION.SENDONLY:case this.C.DIRECTION.RECVONLY:case this.C.DIRECTION.INACTIVE:this.direction=r;break;default:this.direction=this.C.DIRECTION.NULL}this.observer.directionChanged()},t.prototype.triggerIceGatheringComplete=function(){this.isIceGatheringComplete()&&(this.emit("iceGatheringComplete",this),this.iceGatheringTimer&&(clearTimeout(this.iceGatheringTimer),this.iceGatheringTimer=void 0),this.iceGatheringDeferred&&(this.iceGatheringDeferred.resolve(),this.iceGatheringDeferred=void 0))},t.prototype.waitForIceGatheringComplete=function(){return this.logger.log("waitForIceGatheringComplete"),this.isIceGatheringComplete()?(this.logger.log("ICE is already complete. Return resolved."),Promise.resolve()):(this.iceGatheringDeferred||(this.iceGatheringDeferred=c.Utils.defer()),this.logger.log("ICE is not complete. Returning promise"),this.iceGatheringDeferred?this.iceGatheringDeferred.promise:Promise.resolve())},t}(n.EventEmitter);t.SessionDescriptionHandler=p},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=function(){function e(e){this.incomingInfoRequest=e}return Object.defineProperty(e.prototype,"request",{get:function(){return this.incomingInfoRequest.message},enumerable:!0,configurable:!0}),e.prototype.accept=function(e){return this.incomingInfoRequest.accept(e),Promise.resolve()},e.prototype.reject=function(e){return this.incomingInfoRequest.reject(e),Promise.resolve()},e}();t.Info=i},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=r(5),n=function(){function e(e,t){this.incomingReferRequest=e,this.session=t}return Object.defineProperty(e.prototype,"referTo",{get:function(){var e=this.incomingReferRequest.message.parseHeader("refer-to");if(!(e instanceof i.NameAddrHeader))throw new Error("Failed to parse Refer-To header.");return e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"referredBy",{get:function(){return this.incomingReferRequest.message.getHeader("referred-by")},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"replaces",{get:function(){return this.referTo.uri.getHeader("replaces")},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"request",{get:function(){return this.incomingReferRequest.message},enumerable:!0,configurable:!0}),e.prototype.accept=function(e){return void 0===e&&(e={statusCode:202}),this.incomingReferRequest.accept(e),Promise.resolve()},e.prototype.reject=function(e){return this.incomingReferRequest.reject(e),Promise.resolve()},e.prototype.makeInviter=function(e){if(this.inviter)return this.inviter;var t=this.referTo.uri.clone();t.clearHeaders();var r=((e=e||{}).extraHeaders||[]).slice(),i=this.replaces;i&&r.push("Replaces: "+decodeURIComponent(i));var n=this.referredBy;return n&&r.push("Referred-By: "+n),e.extraHeaders=r,this.inviter=this.session.userAgent.makeInviter(t,e),this.inviter.referred=this.session,this.session.referral=this.inviter,this.inviter},e}();t.Referral=n},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i,n=r(0),s=r(5),o=r(8),a=r(12),c=r(9);!function(e){e[e.STATUS_CONNECTING=0]="STATUS_CONNECTING",e[e.STATUS_OPEN=1]="STATUS_OPEN",e[e.STATUS_CLOSING=2]="STATUS_CLOSING",e[e.STATUS_CLOSED=3]="STATUS_CLOSED"}(i=t.TransportStatus||(t.TransportStatus={}));var u=function(e){function t(t,r){void 0===r&&(r={});var n=e.call(this,t)||this;return n.type=o.TypeStrings.Transport,n.reconnectionAttempts=0,n.status=i.STATUS_CONNECTING,n.configuration=n.loadConfig(r),n.server=n.configuration.wsServers[0],n}return n.__extends(t,e),t.prototype.isConnected=function(){return this.status===i.STATUS_OPEN},t.prototype.sendPromise=function(e,t){if(void 0===t&&(t={}),void 0===this.ws)return this.onError("unable to send message - WebSocket undefined"),Promise.reject(new Error("WebSocket undefined."));if(!this.statusAssert(i.STATUS_OPEN,t.force))return this.onError("unable to send message - WebSocket not open"),Promise.reject(new Error("WebSocket not open."));!0===this.configuration.traceSip&&this.logger.log("sending WebSocket message:\n\n"+e+"\n");try{this.ws.send(e)}catch(e){return e instanceof e&&Promise.reject(e),Promise.reject(new Error("Failed to send message."))}return Promise.resolve({msg:e})},t.prototype.disconnectPromise=function(e){var t=this;return void 0===e&&(e={}),this.disconnectionPromise?this.disconnectionPromise:(e.code=e.code||1e3,this.statusTransition(i.STATUS_CLOSING,e.force)?(this.emit("disconnecting"),this.disconnectionPromise=new Promise((function(r,i){t.disconnectDeferredResolve=r,t.reconnectTimer&&(clearTimeout(t.reconnectTimer),t.reconnectTimer=void 0),t.ws?(t.stopSendingKeepAlives(),t.logger.log("closing WebSocket "+t.server.wsUri),t.ws.close(e.code,e.reason)):i("Attempted to disconnect but the websocket doesn't exist")})),this.disconnectionPromise):this.status===i.STATUS_CLOSED?Promise.resolve({overrideEvent:!0}):this.connectionPromise?this.connectionPromise.then((function(){return Promise.reject("The websocket did not disconnect")})).catch((function(){return Promise.resolve({overrideEvent:!0})})):Promise.reject("The websocket did not disconnect"))},t.prototype.connectPromise=function(e){var t=this;return void 0===e&&(e={}),this.status!==i.STATUS_CLOSING||e.force?this.connectionPromise?this.connectionPromise:(this.server=this.server||this.getNextWsServer(e.force),this.connectionPromise=new Promise((function(r,n){if((t.status===i.STATUS_OPEN||t.status===i.STATUS_CLOSING)&&!e.force)return t.logger.warn("WebSocket "+t.server.wsUri+" is already connected"),void n("Failed status check - attempted to open a connection but already open/closing");t.connectDeferredResolve=r,t.connectDeferredReject=n,t.status=i.STATUS_CONNECTING,t.emit("connecting"),t.logger.log("connecting to WebSocket "+t.server.wsUri),t.disposeWs();try{t.ws=new WebSocket(t.server.wsUri,"sip")}catch(e){return t.ws=void 0,t.statusTransition(i.STATUS_CLOSED,!0),t.onError("error connecting to WebSocket "+t.server.wsUri+":"+e),n("Failed to create a websocket"),t.connectDeferredResolve=void 0,void(t.connectDeferredReject=void 0)}if(!t.ws)return n("Unexpected instance websocket not set"),t.connectDeferredResolve=void 0,void(t.connectDeferredReject=void 0);t.connectionTimeout=setTimeout((function(){t.statusTransition(i.STATUS_CLOSED),t.logger.warn("took too long to connect - exceeded time set in configuration.connectionTimeout: "+t.configuration.connectionTimeout+"s"),t.emit("disconnected",{code:1e3}),t.connectionPromise=void 0,n("Connection timeout"),t.connectDeferredResolve=void 0,t.connectDeferredReject=void 0;var e=t.ws;t.disposeWs(),e&&e.close(1e3)}),1e3*t.configuration.connectionTimeout),t.boundOnOpen=t.onOpen.bind(t),t.boundOnMessage=t.onMessage.bind(t),t.boundOnClose=t.onClose.bind(t),t.boundOnError=t.onWebsocketError.bind(t),t.ws.addEventListener("open",t.boundOnOpen),t.ws.addEventListener("message",t.boundOnMessage),t.ws.addEventListener("close",t.boundOnClose),t.ws.addEventListener("error",t.boundOnError)})),this.connectionPromise):Promise.reject("WebSocket "+this.server.wsUri+" is closing")},t.prototype.onMessage=function(e){var t,r=e.data;if(/^(\r\n)+$/.test(r))return this.clearKeepAliveTimeout(),void(!0===this.configuration.traceSip&&this.logger.log("received WebSocket message with CRLF Keep Alive response"));if(r){if("string"!=typeof r){try{t=String.fromCharCode.apply(null,new Uint8Array(r))}catch(e){return void this.logger.warn("received WebSocket binary message failed to be converted into string, message discarded")}!0===this.configuration.traceSip&&this.logger.log("received WebSocket binary message:\n\n"+r+"\n")}else!0===this.configuration.traceSip&&this.logger.log("received WebSocket text message:\n\n"+r+"\n"),t=r;this.emit("message",t)}else this.logger.warn("received empty message, message discarded")},t.prototype.onOpen=function(){if(this.status===i.STATUS_CLOSED){var e=this.ws;return this.disposeWs(),void(e&&e.close(1e3))}this.statusTransition(i.STATUS_OPEN,!0),this.emit("connected"),this.connectionTimeout&&(clearTimeout(this.connectionTimeout),this.connectionTimeout=void 0),this.logger.log("WebSocket "+this.server.wsUri+" connected"),void 0!==this.reconnectTimer&&(clearTimeout(this.reconnectTimer),this.reconnectTimer=void 0),this.reconnectionAttempts=0,this.disconnectionPromise=void 0,this.disconnectDeferredResolve=void 0,this.startSendingKeepAlives(),this.connectDeferredResolve?(this.connectDeferredResolve({overrideEvent:!0}),this.connectDeferredResolve=void 0,this.connectDeferredReject=void 0):this.logger.warn("Unexpected websocket.onOpen with no connectDeferredResolve")},t.prototype.onClose=function(e){if(this.logger.log("WebSocket disconnected (code: "+e.code+(e.reason?"| reason: "+e.reason:"")+")"),this.status!==i.STATUS_CLOSING&&(this.logger.warn("WebSocket closed without SIP.js requesting it"),this.emit("transportError")),this.stopSendingKeepAlives(),this.connectionTimeout&&clearTimeout(this.connectionTimeout),this.connectDeferredReject&&this.connectDeferredReject("Websocket Closed"),this.connectionTimeout=void 0,this.connectionPromise=void 0,this.connectDeferredResolve=void 0,this.connectDeferredReject=void 0,this.disconnectDeferredResolve)return this.disconnectDeferredResolve({overrideEvent:!0}),this.statusTransition(i.STATUS_CLOSED),void(this.disconnectDeferredResolve=void 0);this.statusTransition(i.STATUS_CLOSED,!0),this.emit("disconnected",{code:e.code,reason:e.reason}),this.disposeWs(),this.reconnect()},t.prototype.disposeWs=function(){this.ws&&(this.ws.removeEventListener("open",this.boundOnOpen),this.ws.removeEventListener("message",this.boundOnMessage),this.ws.removeEventListener("close",this.boundOnClose),this.ws.removeEventListener("error",this.boundOnError),this.ws=void 0)},t.prototype.onError=function(e){this.logger.warn("Transport error: "+e),this.emit("transportError")},t.prototype.onWebsocketError=function(){this.onError("The Websocket had an error")},t.prototype.reconnect=function(){var e=this;if(this.reconnectionAttempts>0&&this.logger.log("Reconnection attempt "+this.reconnectionAttempts+" failed"),this.noAvailableServers())return this.logger.warn("attempted to get next ws server but there are no available ws servers left"),this.logger.warn("no available ws servers left - going to closed state"),this.statusTransition(i.STATUS_CLOSED,!0),this.emit("closed"),void this.resetServerErrorStatus();this.isConnected()&&(this.logger.warn("attempted to reconnect while connected - forcing disconnect"),this.disconnect({force:!0})),this.reconnectionAttempts+=1,this.reconnectionAttempts>this.configuration.maxReconnectionAttempts?(this.logger.warn("maximum reconnection attempts for WebSocket "+this.server.wsUri),this.logger.log("transport "+this.server.wsUri+" failed | connection state set to 'error'"),this.server.isError=!0,this.emit("transportError"),this.noAvailableServers()||(this.server=this.getNextWsServer()),this.reconnectionAttempts=0,this.reconnect()):(this.logger.log("trying to reconnect to WebSocket "+this.server.wsUri+" (reconnection attempt "+this.reconnectionAttempts+")"),this.reconnectTimer=setTimeout((function(){e.connect(),e.reconnectTimer=void 0}),1===this.reconnectionAttempts?0:1e3*this.configuration.reconnectionTimeout))},t.prototype.resetServerErrorStatus=function(){for(var e=0,t=this.configuration.wsServers;e<t.length;e++){t[e].isError=!1}},t.prototype.getNextWsServer=function(e){if(void 0===e&&(e=!1),this.noAvailableServers())throw this.logger.warn("attempted to get next ws server but there are no available ws servers left"),new Error("Attempted to get next ws server, but there are no available ws servers left.");for(var t=[],r=0,i=this.configuration.wsServers;r<i.length;r++){var n=i[r];n.isError&&!e||(0===t.length?t.push(n):n.weight>t[0].weight?t=[n]:n.weight===t[0].weight&&t.push(n))}return t[Math.floor(Math.random()*t.length)]},t.prototype.noAvailableServers=function(){for(var e=0,t=this.configuration.wsServers;e<t.length;e++){if(!t[e].isError)return!1}return!0},t.prototype.sendKeepAlive=function(){var e=this;if(!this.keepAliveDebounceTimeout)return this.keepAliveDebounceTimeout=setTimeout((function(){e.emit("keepAliveDebounceTimeout"),e.clearKeepAliveTimeout()}),1e3*this.configuration.keepAliveDebounce),this.send("\r\n\r\n")},t.prototype.clearKeepAliveTimeout=function(){this.keepAliveDebounceTimeout&&clearTimeout(this.keepAliveDebounceTimeout),this.keepAliveDebounceTimeout=void 0},t.prototype.startSendingKeepAlives=function(){var e,t,r=this;this.configuration.keepAliveInterval&&!this.keepAliveInterval&&(this.keepAliveInterval=setInterval((function(){r.sendKeepAlive(),r.startSendingKeepAlives()}),(e=this.configuration.keepAliveInterval,t=.8*e,1e3*(Math.random()*(e-t)+t))))},t.prototype.stopSendingKeepAlives=function(){this.keepAliveInterval&&clearInterval(this.keepAliveInterval),this.keepAliveDebounceTimeout&&clearTimeout(this.keepAliveDebounceTimeout),this.keepAliveInterval=void 0,this.keepAliveDebounceTimeout=void 0},t.prototype.statusAssert=function(e,t){return e===this.status||(t?(this.logger.warn("Attempted to assert "+Object.keys(i)[this.status]+" as "+Object.keys(i)[e]+"- continuing with option: 'force'"),!0):(this.logger.warn("Tried to assert "+Object.keys(i)[e]+" but is currently "+Object.keys(i)[this.status]),!1))},t.prototype.statusTransition=function(e,t){return void 0===t&&(t=!1),this.logger.log("Attempting to transition status from "+Object.keys(i)[this.status]+" to "+Object.keys(i)[e]),e===i.STATUS_CONNECTING&&this.statusAssert(i.STATUS_CLOSED,t)||e===i.STATUS_OPEN&&this.statusAssert(i.STATUS_CONNECTING,t)||e===i.STATUS_CLOSING&&this.statusAssert(i.STATUS_OPEN,t)||e===i.STATUS_CLOSED?(this.status=e,!0):(this.logger.warn("Status transition failed - result: no-op - reason: either gave an nonexistent status or attempted illegal transition"),!1)},t.prototype.loadConfig=function(e){var t={wsServers:[{scheme:"WSS",sipUri:"<sip:edge.sip.onsip.com;transport=ws;lr>",weight:0,wsUri:"wss://edge.sip.onsip.com",isError:!1}],connectionTimeout:5,maxReconnectionAttempts:3,reconnectionTimeout:4,keepAliveInterval:0,keepAliveDebounce:10,traceSip:!1},r=this.getConfigurationCheck();for(var i in r.mandatory){if(!e.hasOwnProperty(i))throw new a.Exceptions.ConfigurationError(i);var n=e[i];if(void 0===(s=r.mandatory[i](n)))throw new a.Exceptions.ConfigurationError(i,n);t[i]=s}for(var i in r.optional)if(e.hasOwnProperty(i)){var s;if((n=e[i])instanceof Array&&0===n.length||null===n||""===n||void 0===n||"number"==typeof n&&isNaN(n))continue;if(void 0===(s=r.optional[i](n)))throw new a.Exceptions.ConfigurationError(i,n);t[i]=s}var o={};for(var i in t)t.hasOwnProperty(i)&&(o[i]={value:t[i]});var c=Object.defineProperties({},o);for(var i in this.logger.log("configuration parameters after validation:"),t)t.hasOwnProperty(i)&&this.logger.log("\xb7 "+i+": "+JSON.stringify(t[i]));return c},t.prototype.getConfigurationCheck=function(){return{mandatory:{},optional:{wsServers:function(e){if("string"==typeof e)e=[{wsUri:e}];else{if(!(e instanceof Array))return;for(var t=0;t<e.length;t++)"string"==typeof e[t]&&(e[t]={wsUri:e[t]})}if(0===e.length)return!1;for(var r=0,i=e;r<i.length;r++){var n=i[r];if(!n.wsUri)return;if(n.weight&&!Number(n.weight))return;var o=s.Grammar.parse(n.wsUri,"absoluteURI");if(-1===o)return;if(["wss","ws","udp"].indexOf(o.scheme)<0)return;n.sipUri="<sip:"+o.host+(o.port?":"+o.port:"")+";transport="+o.scheme.replace(/^wss$/i,"ws")+";lr>",n.weight||(n.weight=0),n.isError=!1,n.scheme=o.scheme.toUpperCase()}return e},keepAliveInterval:function(e){if(c.Utils.isDecimal(e)){var t=Number(e);if(t>0)return t}},keepAliveDebounce:function(e){if(c.Utils.isDecimal(e)){var t=Number(e);if(t>0)return t}},traceSip:function(e){if("boolean"==typeof e)return e},connectionTimeout:function(e){if(c.Utils.isDecimal(e)){var t=Number(e);if(t>0)return t}},maxReconnectionAttempts:function(e){if(c.Utils.isDecimal(e)){var t=Number(e);if(t>=0)return t}},reconnectionTimeout:function(e){if(c.Utils.isDecimal(e)){var t=Number(e);if(t>0)return t}}}}},t.C=i,t}(s.Transport);t.Transport=u},,function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=r(0),n=r(51),s=r(11),o=r(5),a=r(8),c=r(12),u=r(90),d=function(e){function t(t,r,i,n){void 0===n&&(n={});var o=this;if(void 0===t||void 0===r||void 0===i)throw new TypeError("Not enough arguments");return(o=e.call(this,t,s.C.REFER,r.remoteIdentity.uri.toString(),n)||this).type=a.TypeStrings.ReferClientContext,o.options=n,o.extraHeaders=(o.options.extraHeaders||[]).slice(),o.applicant=r,o.target=o.initReferTo(i),o.ua&&o.extraHeaders.push("Referred-By: <"+o.ua.configuration.uri+">"),o.extraHeaders.push("Contact: "+r.contact),o.extraHeaders.push("Allow: "+["ACK","CANCEL","INVITE","MESSAGE","BYE","OPTIONS","INFO","NOTIFY","REFER"].toString()),o.extraHeaders.push("Refer-To: "+o.target),o.errorListener=o.onTransportError.bind(o),t.transport&&t.transport.on("transportError",o.errorListener),o}return i.__extends(t,e),t.prototype.refer=function(e){var t=this;void 0===e&&(e={});var r=(this.extraHeaders||[]).slice();return e.extraHeaders&&r.concat(e.extraHeaders),this.applicant.sendRequest(s.C.REFER,{extraHeaders:this.extraHeaders,receiveResponse:function(r){var i=r&&r.statusCode?r.statusCode.toString():"";/^1[0-9]{2}$/.test(i)?t.emit("referRequestProgress",t):/^2[0-9]{2}$/.test(i)?t.emit("referRequestAccepted",t):/^[4-6][0-9]{2}$/.test(i)&&t.emit("referRequestRejected",t),e.receiveResponse&&e.receiveResponse(r)}}),this},t.prototype.receiveNotify=function(e){var t=e.message.hasHeader("Content-Type")?e.message.getHeader("Content-Type"):void 0;if(t&&-1!==t.search(/^message\/sipfrag/)){var r=o.Grammar.parse(e.message.body,"sipfrag");if(-1===r)return void e.reject({statusCode:489,reasonPhrase:"Bad Event"});switch(!0){case/^1[0-9]{2}$/.test(r.status_code):this.emit("referProgress",this);break;case/^2[0-9]{2}$/.test(r.status_code):this.emit("referAccepted",this),!this.options.activeAfterTransfer&&this.applicant.terminate&&this.applicant.terminate();break;default:this.emit("referRejected",this)}return e.accept(),void this.emit("notify",e.message)}e.reject({statusCode:489,reasonPhrase:"Bad Event"})},t.prototype.initReferTo=function(e){var t;if("string"==typeof e){var r=o.Grammar.parse(e,"Refer_To");t=r&&r.uri?r.uri:e;var i=this.ua.normalizeTarget(e);if(!i)throw new TypeError("Invalid target: "+e);t=i}else{if(!e.session)throw new Error("Session undefined.");var n=e.remoteIdentity.friendlyName,s=e.session.remoteTarget.toString(),a=e.session.callId,c=e.session.remoteTag,u=e.session.localTag;t='"'+n+'" <'+s+"?Replaces="+encodeURIComponent(a+";to-tag="+c+";from-tag="+u)+">"}return t},t}(n.ClientContext);t.ReferClientContext=d;var p=function(e){function t(t,r,i){var n=e.call(this,t,r)||this;return n.session=i,n.type=a.TypeStrings.ReferServerContext,n.ua=t,n.status=a.SessionStatus.STATUS_INVITE_RECEIVED,n.fromTag=n.request.fromTag,n.id=n.request.callId+n.fromTag,n.contact=n.ua.contact.toString(),n.logger=t.getLogger("sip.referservercontext",n.id),n.cseq=Math.floor(1e4*Math.random()),n.callId=n.request.callId,n.fromUri=n.request.to.uri,n.fromTag=n.request.to.parameters.tag,n.remoteTarget=n.request.headers.Contact[0].parsed.uri,n.toUri=n.request.from.uri,n.toTag=n.request.fromTag,n.routeSet=n.request.getHeaders("record-route"),n.request.hasHeader("refer-to")?(n.referTo=n.request.parseHeader("refer-to"),n.referredSession=n.ua.findSession(n.request),n.request.hasHeader("referred-by")&&(n.referredBy=n.request.getHeader("referred-by")),n.referTo.uri.hasHeader("replaces")&&(n.replaces=n.referTo.uri.getHeader("replaces")),n.errorListener=n.onTransportError.bind(n),t.transport&&t.transport.on("transportError",n.errorListener),n.status=a.SessionStatus.STATUS_WAITING_FOR_ANSWER,n):(n.logger.warn("Invalid REFER packet. A refer-to header is required. Rejecting refer."),n.reject(),n)}return i.__extends(t,e),t.prototype.progress=function(){if(this.status!==a.SessionStatus.STATUS_WAITING_FOR_ANSWER)throw new c.Exceptions.InvalidStateError(this.status);this.incomingRequest.trying()},t.prototype.reject=function(t){if(void 0===t&&(t={}),this.status===a.SessionStatus.STATUS_TERMINATED)throw new c.Exceptions.InvalidStateError(this.status);this.logger.log("Rejecting refer"),this.status=a.SessionStatus.STATUS_TERMINATED,e.prototype.reject.call(this,t),this.emit("referRequestRejected",this)},t.prototype.accept=function(e,t){var r=this;if(void 0===e&&(e={}),this.status!==a.SessionStatus.STATUS_WAITING_FOR_ANSWER)throw new c.Exceptions.InvalidStateError(this.status);if(this.status=a.SessionStatus.STATUS_ANSWERED,this.incomingRequest.accept({statusCode:202,reasonPhrase:"Accepted"}),this.emit("referRequestAccepted",this),e.followRefer){this.logger.log("Accepted refer, attempting to automatically follow it");var i=this.referTo.uri;if(!i.scheme||!i.scheme.match("^sips?$"))return this.logger.error("SIP.js can only automatically follow SIP refer target"),void this.reject();var n=e.inviteOptions||{},s=(n.extraHeaders||[]).slice();if(this.replaces&&s.push("Replaces: "+decodeURIComponent(this.replaces)),this.referredBy&&s.push("Referred-By: "+this.referredBy),n.extraHeaders=s,i.clearHeaders(),this.targetSession=this.ua.invite(i.toString(),n,t),this.emit("referInviteSent",this),this.targetSession){this.targetSession.once("progress",(function(e){var t=e.statusCode||100,i=e.reasonPhrase;r.sendNotify(("SIP/2.0 "+t+" "+i).trim()),r.emit("referProgress",r),r.referredSession&&r.referredSession.emit("referProgress",r)})),this.targetSession.once("accepted",(function(){r.logger.log("Successfully followed the refer"),r.sendNotify("SIP/2.0 200 OK"),r.emit("referAccepted",r),r.referredSession&&r.referredSession.emit("referAccepted",r)}));var o=function(e){if(r.status!==a.SessionStatus.STATUS_TERMINATED){if(r.logger.log("Refer was not successful. Resuming session"),e&&429===e.statusCode)return r.logger.log("Alerting referrer that identity is required."),void r.sendNotify("SIP/2.0 429 Provide Referrer Identity");r.sendNotify("SIP/2.0 603 Declined"),r.status=a.SessionStatus.STATUS_TERMINATED,r.emit("referRejected",r),r.referredSession&&r.referredSession.emit("referRejected")}};this.targetSession.once("rejected",o),this.targetSession.once("failed",o)}}else this.logger.log("Accepted refer, but did not automatically follow it"),this.sendNotify("SIP/2.0 200 OK"),this.emit("referAccepted",this),this.referredSession&&this.referredSession.emit("referAccepted",this)},t.prototype.sendNotify=function(e){if(this.status!==a.SessionStatus.STATUS_ANSWERED)throw new c.Exceptions.InvalidStateError(this.status);if(-1===o.Grammar.parse(e,"sipfrag"))throw new Error("sipfrag body is required to send notify for refer");var t={contentDisposition:"render",contentType:"message/sipfrag",content:e};if(this.session)this.session.notify(void 0,{extraHeaders:["Event: refer","Subscription-State: terminated"],body:t});else{var r=this.ua.userAgentCore.makeOutgoingRequestMessage(s.C.NOTIFY,this.remoteTarget,this.fromUri,this.toUri,{cseq:this.cseq+=1,callId:this.callId,fromTag:this.fromTag,toTag:this.toTag,routeSet:this.routeSet},["Event: refer","Subscription-State: terminated","Content-Type: message/sipfrag"],t),i=this.ua.transport;if(!i)throw new Error("Transport undefined.");var n={loggerFactory:this.ua.getLoggerFactory()};new o.NonInviteClientTransaction(r,i,n)}},t.prototype.on=function(t,r){return e.prototype.on.call(this,t,r)},t}(u.ServerContext);t.ReferServerContext=p},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=r(8),n=function(){function e(e,t){this.type=i.TypeStrings.SessionDescriptionHandlerObserver,this.session=e,this.options=t}return e.prototype.trackAdded=function(){this.session.emit("trackAdded")},e.prototype.directionChanged=function(){this.session.emit("directionChanged")},e}();t.SessionDescriptionHandlerObserver=n},,,function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=r(0),n=r(51),s=r(11),o=r(5),a=r(8),c=r(12),u=r(9),d=function(e){function t(t,r,i,n){void 0===n&&(n={});var o=this;if(n.extraHeaders=(n.extraHeaders||[]).slice(),n.contentType=n.contentType||"text/plain","number"!=typeof n.expires||n.expires%1!=0?n.expires=3600:n.expires=Number(n.expires),"boolean"!=typeof n.unpublishOnClose&&(n.unpublishOnClose=!0),null==r||""===r)throw new c.Exceptions.MethodParameterError("Publish","Target",r);if(void 0===(r=t.normalizeTarget(r)))throw new c.Exceptions.MethodParameterError("Publish","Target",r);if((o=e.call(this,t,s.C.PUBLISH,r,n)||this).type=a.TypeStrings.PublishContext,o.options=n,o.target=r,null==i||""===i)throw new c.Exceptions.MethodParameterError("Publish","Event",i);return o.event=i,o.logger=t.getLogger("sip.publish"),o.pubRequestExpires=o.options.expires,o}return i.__extends(t,e),t.prototype.publish=function(e){this.publishRefreshTimer&&(clearTimeout(this.publishRefreshTimer),this.publishRefreshTimer=void 0),this.options.body=e,this.pubRequestBody=this.options.body,0===this.pubRequestExpires&&(this.pubRequestExpires=this.options.expires,this.pubRequestEtag=void 0),this.ua.publishers[this.target.toString()+":"+this.event]||(this.ua.publishers[this.target.toString()+":"+this.event]=this),this.sendPublishRequest()},t.prototype.unpublish=function(){this.publishRefreshTimer&&(clearTimeout(this.publishRefreshTimer),this.publishRefreshTimer=void 0),this.pubRequestBody=void 0,this.pubRequestExpires=0,void 0!==this.pubRequestEtag&&this.sendPublishRequest()},t.prototype.close=function(){this.options.unpublishOnClose?this.unpublish():(this.publishRefreshTimer&&(clearTimeout(this.publishRefreshTimer),this.publishRefreshTimer=void 0),this.pubRequestBody=void 0,this.pubRequestExpires=0,this.pubRequestEtag=void 0),this.ua.publishers[this.target.toString()+":"+this.event]&&delete this.ua.publishers[this.target.toString()+":"+this.event]},t.prototype.onRequestTimeout=function(){e.prototype.onRequestTimeout.call(this),this.emit("unpublished",void 0,s.C.causes.REQUEST_TIMEOUT)},t.prototype.onTransportError=function(){e.prototype.onTransportError.call(this),this.emit("unpublished",void 0,s.C.causes.CONNECTION_ERROR)},t.prototype.receiveResponse=function(e){var t=this,r=e.statusCode||0,i=u.Utils.getReasonPhrase(r);switch(!0){case/^1[0-9]{2}$/.test(r.toString()):this.emit("progress",e,i);break;case/^2[0-9]{2}$/.test(r.toString()):if(e.hasHeader("SIP-ETag")?this.pubRequestEtag=e.getHeader("SIP-ETag"):this.logger.warn("SIP-ETag header missing in a 200-class response to PUBLISH"),e.hasHeader("Expires")){var n=Number(e.getHeader("Expires"));"number"==typeof n&&n>=0&&n<=this.pubRequestExpires?this.pubRequestExpires=n:this.logger.warn("Bad Expires header in a 200-class response to PUBLISH")}else this.logger.warn("Expires header missing in a 200-class response to PUBLISH");0!==this.pubRequestExpires?(this.publishRefreshTimer=setTimeout((function(){return t.refreshRequest()}),900*this.pubRequestExpires),this.emit("published",e,i)):this.emit("unpublished",e,i);break;case/^412$/.test(r.toString()):void 0!==this.pubRequestEtag&&0!==this.pubRequestExpires?(this.logger.warn("412 response to PUBLISH, recovering"),this.pubRequestEtag=void 0,this.emit("progress",e,i),this.publish(this.options.body)):(this.logger.warn("412 response to PUBLISH, recovery failed"),this.pubRequestExpires=0,this.emit("failed",e,i),this.emit("unpublished",e,i));break;case/^423$/.test(r.toString()):if(0!==this.pubRequestExpires&&e.hasHeader("Min-Expires")){var s=Number(e.getHeader("Min-Expires"));"number"==typeof s||s>this.pubRequestExpires?(this.logger.warn("423 code in response to PUBLISH, adjusting the Expires value and trying to recover"),this.pubRequestExpires=s,this.emit("progress",e,i),this.publish(this.options.body)):(this.logger.warn("Bad 423 response Min-Expires header received for PUBLISH"),this.pubRequestExpires=0,this.emit("failed",e,i),this.emit("unpublished",e,i))}else this.logger.warn("423 response to PUBLISH, recovery failed"),this.pubRequestExpires=0,this.emit("failed",e,i),this.emit("unpublished",e,i);break;default:this.pubRequestExpires=0,this.emit("failed",e,i),this.emit("unpublished",e,i)}0===this.pubRequestExpires&&(this.publishRefreshTimer&&(clearTimeout(this.publishRefreshTimer),this.publishRefreshTimer=void 0),this.pubRequestBody=void 0,this.pubRequestEtag=void 0)},t.prototype.send=function(){var e=this;return this.ua.userAgentCore.publish(this.request,{onAccept:function(t){return e.receiveResponse(t.message)},onProgress:function(t){return e.receiveResponse(t.message)},onRedirect:function(t){return e.receiveResponse(t.message)},onReject:function(t){return e.receiveResponse(t.message)},onTrying:function(t){return e.receiveResponse(t.message)}}),this},t.prototype.refreshRequest=function(){if(this.publishRefreshTimer&&(clearTimeout(this.publishRefreshTimer),this.publishRefreshTimer=void 0),this.pubRequestBody=void 0,void 0===this.pubRequestEtag)throw new c.Exceptions.MethodParameterError("Publish","Body",void 0);if(0===this.pubRequestExpires)throw new c.Exceptions.MethodParameterError("Publish","Expire",this.pubRequestExpires);this.sendPublishRequest()},t.prototype.sendPublishRequest=function(){var e=Object.create(this.options||Object.prototype);e.extraHeaders=(this.options.extraHeaders||[]).slice(),e.extraHeaders.push("Event: "+this.event),e.extraHeaders.push("Expires: "+this.pubRequestExpires),void 0!==this.pubRequestEtag&&e.extraHeaders.push("SIP-If-Match: "+this.pubRequestEtag);var t=this.target instanceof o.URI?this.target:this.ua.normalizeTarget(this.target);if(!t)throw new Error("ruri undefined.");var r,i,n=this.options.params||{};void 0!==this.pubRequestBody&&(r={body:this.pubRequestBody,contentType:this.options.contentType}),r&&(i=u.Utils.fromBodyObj(r)),this.request=this.ua.userAgentCore.makeOutgoingRequestMessage(s.C.PUBLISH,t,n.fromUri?n.fromUri:this.ua.userAgentCore.configuration.aor,n.toUri?n.toUri:this.target,n,e.extraHeaders,i),this.send()},t}(n.ClientContext);t.PublishContext=d},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=r(0),n=r(51),s=r(11),o=r(5),a=r(8),c=r(12),u=r(9);function d(e){var t={expires:600,extraContactHeaderParams:[],instanceId:void 0,params:{},regId:void 0,registrar:void 0},r={mandatory:{},optional:{expires:function(e){if(u.Utils.isDecimal(e)){var t=Number(e);if(t>=0)return t}},extraContactHeaderParams:function(e){if(e instanceof Array)return e.filter((function(e){return"string"==typeof e}))},instanceId:function(e){if("string"==typeof e)return/^uuid:/i.test(e)&&(e=e.substr(5)),-1===o.Grammar.parse(e,"uuid")?void 0:e},params:function(e){if("object"==typeof e)return e},regId:function(e){if(u.Utils.isDecimal(e)){var t=Number(e);if(t>=0)return t}},registrar:function(e){if("string"==typeof e){/^sip:/i.test(e)||(e=s.C.SIP+":"+e);var t=o.Grammar.URIParse(e);return t?t.user?void 0:t:void 0}}}};for(var i in r.mandatory){if(!e.hasOwnProperty(i))throw new c.Exceptions.ConfigurationError(i);var n=e[i];if(void 0===(a=r.mandatory[i](n)))throw new c.Exceptions.ConfigurationError(i,n);t[i]=a}for(var i in r.optional)if(e.hasOwnProperty(i)){var a;if((n=e[i])instanceof Array&&0===n.length)continue;if(null===n||""===n||void 0===n||"number"==typeof n&&isNaN(n))continue;if(void 0===(a=r.optional[i](n)))throw new c.Exceptions.ConfigurationError(i,n);t[i]=a}return t}var p=function(e){function t(t,r){void 0===r&&(r={});var i=this,n=d(r);if(n.regId&&!n.instanceId?n.instanceId=u.Utils.newUUID():!n.regId&&n.instanceId&&(n.regId=1),n.params.toUri=n.params.toUri||t.configuration.uri,n.params.toDisplayName=n.params.toDisplayName||t.configuration.displayName,n.params.callId=n.params.callId||u.Utils.createRandomToken(22),n.params.cseq=n.params.cseq||Math.floor(1e4*Math.random()),!n.registrar){var o={};"object"==typeof t.configuration.uri?(o=t.configuration.uri.clone()).user=void 0:o=t.configuration.uri,n.registrar=o}for(var c in(i=e.call(this,t,s.C.REGISTER,n.registrar,n)||this).type=a.TypeStrings.RegisterContext,i.options=n,i.logger=t.getLogger("sip.registercontext"),i.logger.log("configuration parameters for RegisterContext after validation:"),n)n.hasOwnProperty(c)&&i.logger.log("\xb7 "+c+": "+JSON.stringify(n[c]));return i.expires=n.expires,i.contact=t.contact.toString(),i.registered=!1,t.transport.on("disconnected",(function(){return i.onTransportDisconnected()})),i}return i.__extends(t,e),t.prototype.register=function(e){var t=this;void 0===e&&(e={}),this.options=i.__assign(i.__assign({},this.options),e);var r=(this.options.extraHeaders||[]).slice();r.push("Contact: "+this.generateContactHeader(this.expires)),r.push("Allow: "+["ACK","CANCEL","INVITE","MESSAGE","BYE","OPTIONS","INFO","NOTIFY","REFER"].toString()),this.closeHeaders=this.options.closeWithHeaders?(this.options.extraHeaders||[]).slice():[],this.receiveResponse=function(e){if(e.cseq===t.request.cseq){void 0!==t.registrationTimer&&(clearTimeout(t.registrationTimer),t.registrationTimer=void 0);var r=(e.statusCode||0).toString();switch(!0){case/^1[0-9]{2}$/.test(r):t.emit("progress",e);break;case/^2[0-9]{2}$/.test(r):t.emit("accepted",e);var i=void 0;e.hasHeader("expires")&&(i=Number(e.getHeader("expires"))),void 0!==t.registrationExpiredTimer&&(clearTimeout(t.registrationExpiredTimer),t.registrationExpiredTimer=void 0);var n=e.getHeaders("contact").length;if(!n){t.logger.warn("no Contact header in response to REGISTER, response ignored");break}for(var a=void 0;n--;){if((a=e.parseHeader("contact",n)).uri.user===t.ua.contact.uri.user){i=a.getParam("expires");break}a=void 0}if(!a){t.logger.warn("no Contact header pointing to us, response ignored");break}void 0===i&&(i=t.expires),t.registrationTimer=setTimeout((function(){t.registrationTimer=void 0,t.register(t.options)}),1e3*i-3e3),t.registrationExpiredTimer=setTimeout((function(){t.logger.warn("registration expired"),t.registered&&t.unregistered(void 0,s.C.causes.EXPIRES)}),1e3*i),a.hasParam("temp-gruu")&&(t.ua.contact.tempGruu=o.Grammar.URIParse(a.getParam("temp-gruu").replace(/"/g,""))),a.hasParam("pub-gruu")&&(t.ua.contact.pubGruu=o.Grammar.URIParse(a.getParam("pub-gruu").replace(/"/g,""))),t.registered=!0,t.emit("registered",e||void 0);break;case/^423$/.test(r):e.hasHeader("min-expires")?(t.expires=Number(e.getHeader("min-expires")),t.register(t.options)):(t.logger.warn("423 response received for REGISTER without Min-Expires"),t.registrationFailure(e,s.C.causes.SIP_FAILURE_CODE));break;default:t.registrationFailure(e,u.Utils.sipErrorCause(e.statusCode||0))}}},this.onRequestTimeout=function(){t.registrationFailure(void 0,s.C.causes.REQUEST_TIMEOUT)},this.onTransportError=function(){t.registrationFailure(void 0,s.C.causes.CONNECTION_ERROR)},this.request.cseq++,this.request.setHeader("cseq",this.request.cseq+" REGISTER"),this.request.extraHeaders=r,this.send()},t.prototype.close=function(){var e={all:!1,extraHeaders:this.closeHeaders};this.registeredBefore=this.registered,this.registered&&this.unregister(e)},t.prototype.unregister=function(e){var t=this;void 0===e&&(e={}),this.registered||e.all||this.logger.warn("Already unregistered, but sending an unregister anyways.");var r=(e.extraHeaders||[]).slice();this.registered=!1,void 0!==this.registrationTimer&&(clearTimeout(this.registrationTimer),this.registrationTimer=void 0),e.all?(r.push("Contact: *"),r.push("Expires: 0")):r.push("Contact: "+this.generateContactHeader(0)),this.receiveResponse=function(e){var r=e&&e.statusCode?e.statusCode.toString():"";switch(!0){case/^1[0-9]{2}$/.test(r):t.emit("progress",e);break;case/^2[0-9]{2}$/.test(r):t.emit("accepted",e),void 0!==t.registrationExpiredTimer&&(clearTimeout(t.registrationExpiredTimer),t.registrationExpiredTimer=void 0),t.unregistered(e);break;default:t.unregistered(e,u.Utils.sipErrorCause(e.statusCode||0))}},this.onRequestTimeout=function(){},this.request.cseq++,this.request.setHeader("cseq",this.request.cseq+" REGISTER"),this.request.extraHeaders=r,this.send()},t.prototype.unregistered=function(e,t){this.registered=!1,this.emit("unregistered",e||void 0,t||void 0)},t.prototype.send=function(){var e=this;return this.ua.userAgentCore.register(this.request,{onAccept:function(t){return e.receiveResponse(t.message)},onProgress:function(t){return e.receiveResponse(t.message)},onRedirect:function(t){return e.receiveResponse(t.message)},onReject:function(t){return e.receiveResponse(t.message)},onTrying:function(t){return e.receiveResponse(t.message)}}),this},t.prototype.registrationFailure=function(e,t){this.emit("failed",e||void 0,t||void 0)},t.prototype.onTransportDisconnected=function(){this.registeredBefore=this.registered,void 0!==this.registrationTimer&&(clearTimeout(this.registrationTimer),this.registrationTimer=void 0),void 0!==this.registrationExpiredTimer&&(clearTimeout(this.registrationExpiredTimer),this.registrationExpiredTimer=void 0),this.registered&&this.unregistered(void 0,s.C.causes.CONNECTION_ERROR)},t.prototype.generateContactHeader=function(e){void 0===e&&(e=0);var t=this.contact;return this.options.regId&&this.options.instanceId&&(t+=";reg-id="+this.options.regId,t+=';+sip.instance="<urn:uuid:'+this.options.instanceId+'>"'),this.options.extraContactHeaderParams&&this.options.extraContactHeaderParams.forEach((function(e){t+=";"+e})),t+=";expires="+e},t}(n.ClientContext);t.RegisterContext=p},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=r(0),n=r(7),s=r(51),o=r(11),a=r(5),c=r(8),u=r(12),d=r(96),p=r(90),l=r(110),h=r(9),g=function(e){function t(r){var i=e.call(this)||this;if(i.data={},i.type=c.TypeStrings.Session,!r)throw new u.Exceptions.SessionDescriptionHandlerError("A session description handler is required for the session to function");return i.status=t.C.STATUS_NULL,i.pendingReinvite=!1,i.sessionDescriptionHandlerFactory=r,i.hasOffer=!1,i.hasAnswer=!1,i.timers={ackTimer:void 0,expiresTimer:void 0,invite2xxTimer:void 0,userNoAnswerTimer:void 0,rel1xxTimer:void 0,prackTimer:void 0},i.startTime=void 0,i.endTime=void 0,i.tones=void 0,i.localHold=!1,i.earlySdp=void 0,i.rel100=o.C.supported.UNSUPPORTED,i}return i.__extends(t,e),t.prototype.dtmf=function(e,t){var r=this;if(void 0===t&&(t={}),this.status!==c.SessionStatus.STATUS_CONFIRMED&&this.status!==c.SessionStatus.STATUS_WAITING_FOR_ACK)throw new u.Exceptions.InvalidStateError(this.status);if(!e||!e.toString().match(/^[0-9A-D#*,]+$/i))throw new TypeError("Invalid tones: "+e);var i=function(){if(r.status!==c.SessionStatus.STATUS_TERMINATED&&r.tones&&0!==r.tones.length){var e,n=r.tones.shift();","===n.tone?e=2e3:(n.on("failed",(function(){r.tones=void 0})),n.send(t),e=n.duration+n.interToneGap),setTimeout(i,e)}else r.tones=void 0};e=e.toString();var n=this.ua.configuration.dtmfType;this.sessionDescriptionHandler&&n===o.C.dtmfType.RTP&&(this.sessionDescriptionHandler.sendDtmf(e,t)||(this.logger.warn("Attempt to use dtmfType 'RTP' has failed, falling back to INFO packet method"),n=o.C.dtmfType.INFO));if(n===o.C.dtmfType.INFO){for(var s=[],a=e.split("");a.length>0;)s.push(new l.DTMF(this,a.shift(),t));if(this.tones)return this.tones=this.tones.concat(s),this;this.tones=s,i()}return this},t.prototype.bye=function(e){if(void 0===e&&(e={}),this.status===c.SessionStatus.STATUS_TERMINATED)return this.logger.error("Error: Attempted to send BYE in a terminated session."),this;this.logger.log("terminating Session");var t=e.statusCode;if(t&&(t<200||t>=700))throw new TypeError("Invalid statusCode: "+t);return e.receiveResponse=function(){},this.sendRequest(o.C.BYE,e).terminated()},t.prototype.refer=function(e,t){if(void 0===t&&(t={}),this.status!==c.SessionStatus.STATUS_CONFIRMED)throw new u.Exceptions.InvalidStateError(this.status);return this.referContext=new d.ReferClientContext(this.ua,this,e,t),this.emit("referRequested",this.referContext),this.referContext.refer(t),this.referContext},t.prototype.sendRequest=function(e,t){if(void 0===t&&(t={}),!this.session)throw new Error("Session undefined.");var r;t.body&&(t.body=h.Utils.fromBodyObj(t.body));var i,n=t.receiveResponse;n&&(r={onAccept:function(e){return n(e.message)},onProgress:function(e){return n(e.message)},onRedirect:function(e){return n(e.message)},onReject:function(e){return n(e.message)},onTrying:function(e){return n(e.message)}});var s=t;switch(e){case o.C.BYE:i=this.session.bye(r,s);break;case o.C.INVITE:i=this.session.invite(r,s);break;case o.C.REFER:i=this.session.refer(r,s);break;default:throw new Error("Unexpected "+e+". Method not implemented by user agent core.")}return this.emit(e.toLowerCase(),i.message),this},t.prototype.close=function(){if(this.status===c.SessionStatus.STATUS_TERMINATED)return this;for(var e in this.logger.log("closing INVITE session "+this.id),this.sessionDescriptionHandler&&this.sessionDescriptionHandler.close(),this.timers)this.timers[e]&&clearTimeout(this.timers[e]);return this.status=c.SessionStatus.STATUS_TERMINATED,this.ua.transport&&this.ua.transport.removeListener("transportError",this.errorListener),delete this.ua.sessions[this.id],this},t.prototype.hold=function(e,t){if(void 0===e&&(e={}),void 0===t&&(t=[]),this.status!==c.SessionStatus.STATUS_WAITING_FOR_ACK&&this.status!==c.SessionStatus.STATUS_CONFIRMED)throw new u.Exceptions.InvalidStateError(this.status);this.localHold?this.logger.log("Session is already on hold, cannot put it on hold again"):(e.modifiers=t,this.sessionDescriptionHandler&&e.modifiers.push(this.sessionDescriptionHandler.holdModifier),this.localHold=!0,this.sendReinvite(e))},t.prototype.unhold=function(e,t){if(void 0===e&&(e={}),void 0===t&&(t=[]),this.status!==c.SessionStatus.STATUS_WAITING_FOR_ACK&&this.status!==c.SessionStatus.STATUS_CONFIRMED)throw new u.Exceptions.InvalidStateError(this.status);this.localHold?(e.modifiers=t,this.localHold=!1,this.sendReinvite(e)):this.logger.log("Session is not on hold, cannot unhold it")},t.prototype.reinvite=function(e,t){return void 0===e&&(e={}),void 0===t&&(t=[]),e.modifiers=t,this.sendReinvite(e)},t.prototype.terminate=function(e){return this},t.prototype.onTransportError=function(){this.status!==c.SessionStatus.STATUS_CONFIRMED&&this.status!==c.SessionStatus.STATUS_TERMINATED&&this.failed(void 0,o.C.causes.CONNECTION_ERROR)},t.prototype.onRequestTimeout=function(){this.status===c.SessionStatus.STATUS_CONFIRMED?this.terminated(void 0,o.C.causes.REQUEST_TIMEOUT):this.status!==c.SessionStatus.STATUS_TERMINATED&&(this.failed(void 0,o.C.causes.REQUEST_TIMEOUT),this.terminated(void 0,o.C.causes.REQUEST_TIMEOUT))},t.prototype.onDialogError=function(e){this.status===c.SessionStatus.STATUS_CONFIRMED?this.terminated(e,o.C.causes.DIALOG_ERROR):this.status!==c.SessionStatus.STATUS_TERMINATED&&(this.failed(e,o.C.causes.DIALOG_ERROR),this.terminated(e,o.C.causes.DIALOG_ERROR))},t.prototype.on=function(t,r){return e.prototype.on.call(this,t,r)},t.prototype.onAck=function(e){var t=this,r=function(){clearTimeout(t.timers.ackTimer),clearTimeout(t.timers.invite2xxTimer),t.status=c.SessionStatus.STATUS_CONFIRMED;var r=e.message.getHeader("Content-Disposition");r&&"render"===r.type&&(t.renderbody=e.message.body,t.rendertype=e.message.getHeader("Content-Type")),t.emit("confirmed",e.message)};this.status===c.SessionStatus.STATUS_WAITING_FOR_ACK&&(this.sessionDescriptionHandler&&this.sessionDescriptionHandler.hasDescription(e.message.getHeader("Content-Type")||"")?(this.hasAnswer=!0,this.sessionDescriptionHandler.setDescription(e.message.body,this.sessionDescriptionHandlerOptions,this.modifiers).catch((function(r){throw t.logger.warn(r),t.terminate({statusCode:"488",reasonPhrase:"Bad Media Description"}),t.failed(e.message,o.C.causes.BAD_MEDIA_DESCRIPTION),t.terminated(e.message,o.C.causes.BAD_MEDIA_DESCRIPTION),r})).then((function(){return r()}))):r())},t.prototype.receiveRequest=function(e){switch(e.message.method){case o.C.BYE:e.accept(),this.status===c.SessionStatus.STATUS_CONFIRMED&&(this.emit("bye",e.message),this.terminated(e.message,o.C.BYE));break;case o.C.INVITE:this.status===c.SessionStatus.STATUS_CONFIRMED&&(this.logger.log("re-INVITE received"),this.receiveReinvite(e));break;case o.C.INFO:if(this.status===c.SessionStatus.STATUS_CONFIRMED||this.status===c.SessionStatus.STATUS_WAITING_FOR_ACK){if(this.onInfo)return this.onInfo(e.message);var t=e.message.getHeader("content-type");if(t)if(t.match(/^application\/dtmf-relay/i)){if(e.message.body){var r=e.message.body.split("\r\n",2);if(2===r.length){var i=void 0,n=void 0,s=/^(Signal\s*?=\s*?)([0-9A-D#*]{1})(\s)?.*/;s.test(r[0])&&(i=r[0].replace(s,"$2"));var a=/^(Duration\s?=\s?)([0-9]{1,4})(\s)?.*/;a.test(r[1])&&(n=parseInt(r[1].replace(a,"$2"),10)),i&&n&&new l.DTMF(this,i,{duration:n}).init_incoming(e)}}}else e.reject({statusCode:415,extraHeaders:["Accept: application/dtmf-relay"]})}break;case o.C.REFER:if(this.status===c.SessionStatus.STATUS_CONFIRMED)if(this.logger.log("REFER received"),this.referContext=new d.ReferServerContext(this.ua,e,this.session),this.listeners("referRequested").length)this.emit("referRequested",this.referContext);else{this.logger.log("No referRequested listeners, automatically accepting and following the refer");var u={followRefer:!0};this.passedOptions&&(u.inviteOptions=this.passedOptions),this.referContext.accept(u,this.modifiers)}break;case o.C.NOTIFY:if(this.referContext&&this.referContext.type===c.TypeStrings.ReferClientContext&&e.message.hasHeader("event")&&/^refer(;.*)?$/.test(e.message.getHeader("event")))return void this.referContext.receiveNotify(e);e.accept(),this.emit("notify",e.message)}},t.prototype.receiveReinvite=function(e){var t,r=this;if(this.emit("reinvite",this,e.message),e.message.hasHeader("P-Asserted-Identity")&&(this.assertedIdentity=a.Grammar.nameAddrHeaderParse(e.message.getHeader("P-Asserted-Identity"))),this.sessionDescriptionHandler){if("0"!==e.message.getHeader("Content-Length")||e.message.getHeader("Content-Type")){if(!this.sessionDescriptionHandler.hasDescription(e.message.getHeader("Content-Type")||""))return e.reject({statusCode:415}),void this.emit("reinviteFailed",this);t=this.sessionDescriptionHandler.setDescription(e.message.body,this.sessionDescriptionHandlerOptions,this.modifiers).then(this.sessionDescriptionHandler.getDescription.bind(this.sessionDescriptionHandler,this.sessionDescriptionHandlerOptions,this.modifiers))}else t=this.sessionDescriptionHandler.getDescription(this.sessionDescriptionHandlerOptions,this.modifiers);t.catch((function(t){var i;throw t.type===c.TypeStrings.SessionDescriptionHandlerError?i=500:t.type===c.TypeStrings.RenegotiationError?(r.emit("renegotiationError",t),r.logger.warn(t.toString()),i=488):(r.logger.error(t),i=488),e.reject({statusCode:i}),r.emit("reinviteFailed",r),t})).then((function(t){var i=["Contact: "+r.contact];e.accept({statusCode:200,extraHeaders:i,body:h.Utils.fromBodyObj(t)}),r.status=c.SessionStatus.STATUS_WAITING_FOR_ACK,r.emit("reinviteAccepted",r)}))}else this.logger.warn("No SessionDescriptionHandler to reinvite")},t.prototype.sendReinvite=function(e){var t=this;if(void 0===e&&(e={}),this.pendingReinvite)this.logger.warn("Reinvite in progress. Please wait until complete, then try again.");else if(this.sessionDescriptionHandler){this.pendingReinvite=!0,e.modifiers=e.modifiers||[];var r=(e.extraHeaders||[]).slice();r.push("Contact: "+this.contact),r.push("Allow: "+["ACK","CANCEL","INVITE","MESSAGE","BYE","OPTIONS","INFO","NOTIFY","REFER"].toString()),this.sessionDescriptionHandler.getDescription(e.sessionDescriptionHandlerOptions,e.modifiers).then((function(e){if(!t.session)throw new Error("Session undefined.");var i={onAccept:function(e){if(t.status!==c.SessionStatus.STATUS_TERMINATED)if(t.pendingReinvite){if(t.status=c.SessionStatus.STATUS_CONFIRMED,t.emit("ack",e.ack()),t.pendingReinvite=!1,clearTimeout(t.timers.invite2xxTimer),!t.sessionDescriptionHandler||!t.sessionDescriptionHandler.hasDescription(e.message.getHeader("Content-Type")||""))return t.logger.error("2XX response received to re-invite but did not have a description"),t.emit("reinviteFailed",t),void t.emit("renegotiationError",new u.Exceptions.RenegotiationError("2XX response received to re-invite but did not have a description"));t.sessionDescriptionHandler.setDescription(e.message.body,t.sessionDescriptionHandlerOptions,t.modifiers).catch((function(e){throw t.logger.error("Could not set the description in 2XX response"),t.logger.error(e),t.emit("reinviteFailed",t),t.emit("renegotiationError",e),t.sendRequest(o.C.BYE,{extraHeaders:["Reason: "+h.Utils.getReasonHeaderValue(488,"Not Acceptable Here")]}),t.terminated(void 0,o.C.causes.INCOMPATIBLE_SDP),e})).then((function(){t.emit("reinviteAccepted",t)}))}else t.logger.error("Received reinvite response, but have no pending reinvite");else t.logger.error("Received reinvite response, but in STATUS_TERMINATED")},onProgress:function(e){},onRedirect:function(e){t.pendingReinvite=!1,t.logger.log("Received a non 1XX or 2XX response to a re-invite"),t.emit("reinviteFailed",t),t.emit("renegotiationError",new u.Exceptions.RenegotiationError("Invalid response to a re-invite"))},onReject:function(e){t.pendingReinvite=!1,t.logger.log("Received a non 1XX or 2XX response to a re-invite"),t.emit("reinviteFailed",t),t.emit("renegotiationError",new u.Exceptions.RenegotiationError("Invalid response to a re-invite"))},onTrying:function(e){}},n={extraHeaders:r,body:h.Utils.fromBodyObj(e)};t.session.invite(i,n)})).catch((function(e){if(e.type===c.TypeStrings.RenegotiationError)throw t.pendingReinvite=!1,t.emit("renegotiationError",e),t.logger.warn("Renegotiation Error"),t.logger.warn(e.toString()),e;throw t.logger.error("sessionDescriptionHandler error"),t.logger.error(e),e}))}else this.logger.warn("No SessionDescriptionHandler, can't reinvite..")},t.prototype.failed=function(e,t){return this.status===c.SessionStatus.STATUS_TERMINATED?this:(this.emit("failed",e,t),this)},t.prototype.rejected=function(e,t){return this.emit("rejected",e,t),this},t.prototype.canceled=function(){return this.sessionDescriptionHandler&&this.sessionDescriptionHandler.close(),this.emit("cancel"),this},t.prototype.accepted=function(e,t){return e instanceof String||(t=h.Utils.getReasonPhrase(e&&e.statusCode||0,t)),this.startTime=new Date,this.replacee&&(this.replacee.emit("replaced",this),this.replacee.terminate()),this.emit("accepted",e,t),this},t.prototype.terminated=function(e,t){return this.status===c.SessionStatus.STATUS_TERMINATED?this:(this.endTime=new Date,this.close(),this.emit("terminated",e,t),this)},t.prototype.connecting=function(e){return this.emit("connecting",{request:e}),this},t.C=c.SessionStatus,t}(n.EventEmitter);t.Session=g;var f=function(e){function t(t,r){var i=this;if(!t.configuration.sessionDescriptionHandlerFactory)throw t.logger.warn("Can't build ISC without SDH Factory"),new Error("ISC Constructor Failed");(i=e.call(this,t.configuration.sessionDescriptionHandlerFactory)||this)._canceled=!1,i.rseq=Math.floor(1e4*Math.random()),i.incomingRequest=r;var n=r.message;p.ServerContext.initializer(i,t,r),i.type=c.TypeStrings.InviteServerContext;var s=n.parseHeader("Content-Disposition");s&&"render"===s.type&&(i.renderbody=n.body,i.rendertype=n.getHeader("Content-Type")),i.status=c.SessionStatus.STATUS_INVITE_RECEIVED,i.fromTag=n.fromTag,i.id=n.callId+i.fromTag,i.request=n,i.contact=i.ua.contact.toString(),i.logger=t.getLogger("sip.inviteservercontext",i.id),i.ua.sessions[i.id]=i;var a=function(e,t){n.hasHeader(e)&&n.getHeader(e).toLowerCase().indexOf("100rel")>=0&&(i.rel100=t)};if(a("require",o.C.supported.REQUIRED),a("supported",o.C.supported.SUPPORTED),i.request.toTag=r.toTag,i.status=c.SessionStatus.STATUS_WAITING_FOR_ANSWER,i.timers.userNoAnswerTimer=setTimeout((function(){r.reject({statusCode:408}),i.failed(n,o.C.causes.NO_ANSWER),i.terminated(n,o.C.causes.NO_ANSWER)}),i.ua.configuration.noAnswerTimeout||60),n.hasHeader("expires")){var u=1e3*Number(n.getHeader("expires")||0);i.timers.expiresTimer=setTimeout((function(){i.status===c.SessionStatus.STATUS_WAITING_FOR_ANSWER&&(r.reject({statusCode:487}),i.failed(n,o.C.causes.EXPIRES),i.terminated(n,o.C.causes.EXPIRES))}),u)}return i.errorListener=i.onTransportError.bind(i),t.transport&&t.transport.on("transportError",i.errorListener),i}return i.__extends(t,e),Object.defineProperty(t.prototype,"autoSendAnInitialProvisionalResponse",{get:function(){return this.rel100!==o.C.supported.REQUIRED},enumerable:!0,configurable:!0}),t.prototype.reply=function(e){return void 0===e&&(e={}),this},t.prototype.reject=function(e){var t=this;if(void 0===e&&(e={}),this.status===c.SessionStatus.STATUS_TERMINATED)throw new u.Exceptions.InvalidStateError(this.status);this.logger.log("rejecting RTCSession");var r=e.statusCode||480,i=h.Utils.getReasonPhrase(r,e.reasonPhrase),n=e.extraHeaders||[];if(r<300||r>699)throw new TypeError("Invalid statusCode: "+r);var s=e.body?a.fromBodyLegacy(e.body):void 0,o=r<400?this.incomingRequest.redirect([],{statusCode:r,reasonPhrase:i,extraHeaders:n,body:s}):this.incomingRequest.reject({statusCode:r,reasonPhrase:i,extraHeaders:n,body:s});return["rejected","failed"].forEach((function(e){t.emit(e,o.message,i)})),this.terminated()},t.prototype.accept=function(e){var t=this;return void 0===e&&(e={}),this._accept(e).then((function(e){var r=e.message,i=e.session;i.delegate={onAck:function(e){return t.onAck(e)},onAckTimeout:function(){return t.onAckTimeout()},onBye:function(e){return t.receiveRequest(e)},onInfo:function(e){return t.receiveRequest(e)},onInvite:function(e){return t.receiveRequest(e)},onNotify:function(e){return t.receiveRequest(e)},onPrack:function(e){return t.receiveRequest(e)},onRefer:function(e){return t.receiveRequest(e)}},t.session=i,t.status=c.SessionStatus.STATUS_WAITING_FOR_ACK,t.accepted(r,h.Utils.getReasonPhrase(200))})).catch((function(e){if(t.onContextError(e),!t._canceled)throw e})),this},t.prototype.progress=function(e){var t=this;void 0===e&&(e={});var r=e.statusCode||180;if(r<100||r>199)throw new TypeError("Invalid statusCode: "+r);if(this.status===c.SessionStatus.STATUS_TERMINATED)return this.logger.warn("Unexpected call for progress while terminated, ignoring"),this;if(this.status===c.SessionStatus.STATUS_ANSWERED)return this.logger.warn("Unexpected call for progress while answered, ignoring"),this;if(this.status===c.SessionStatus.STATUS_ANSWERED_WAITING_FOR_PRACK)return this.logger.warn("Unexpected call for progress while answered (waiting for prack), ignoring"),this;if(this.status===c.SessionStatus.STATUS_WAITING_FOR_PRACK)return this.logger.warn("Unexpected call for progress while waiting for prack, ignoring"),this;if(100===e.statusCode){try{this.incomingRequest.trying()}catch(e){if(this.onContextError(e),!this._canceled)throw e}return this}return this.rel100===o.C.supported.REQUIRED||this.rel100===o.C.supported.SUPPORTED&&e.rel100||this.rel100===o.C.supported.SUPPORTED&&this.ua.configuration.rel100===o.C.supported.REQUIRED?(this._reliableProgressWaitForPrack(e).catch((function(e){if(t.onContextError(e),!t._canceled)throw e})),this):(this._progress(e).catch((function(e){if(t.onContextError(e),!t._canceled)throw e})),this)},t.prototype.terminate=function(e){var t=this;if(void 0===e&&(e={}),!this.session)return this.reject(e),this;switch(this.session.sessionState){case a.SessionState.Initial:case a.SessionState.Early:return this.reject(e),this;case a.SessionState.AckWait:return this.session.delegate={onAck:function(){t.sendRequest(o.C.BYE,e)},onAckTimeout:function(){t.sendRequest(o.C.BYE,e)}},this.emit("bye",this.request),this.terminated(),this;case a.SessionState.Confirmed:return this.bye(e),this;case a.SessionState.Terminated:default:return this}},t.prototype.onCancel=function(e){this.status!==c.SessionStatus.STATUS_WAITING_FOR_ANSWER&&this.status!==c.SessionStatus.STATUS_WAITING_FOR_PRACK&&this.status!==c.SessionStatus.STATUS_ANSWERED_WAITING_FOR_PRACK&&this.status!==c.SessionStatus.STATUS_EARLY_MEDIA&&this.status!==c.SessionStatus.STATUS_ANSWERED||(this.status=c.SessionStatus.STATUS_CANCELED,this.incomingRequest.reject({statusCode:487}),this.canceled(),this.rejected(e,o.C.causes.CANCELED),this.failed(e,o.C.causes.CANCELED),this.terminated(e,o.C.causes.CANCELED))},t.prototype.receiveRequest=function(t){var r=this;switch(t.message.method){case o.C.PRACK:this.status===c.SessionStatus.STATUS_WAITING_FOR_PRACK||this.status===c.SessionStatus.STATUS_ANSWERED_WAITING_FOR_PRACK?this.hasAnswer?(clearTimeout(this.timers.rel1xxTimer),clearTimeout(this.timers.prackTimer),t.accept(),this.status===c.SessionStatus.STATUS_ANSWERED_WAITING_FOR_PRACK&&(this.status=c.SessionStatus.STATUS_EARLY_MEDIA,this.accept()),this.status=c.SessionStatus.STATUS_EARLY_MEDIA):(this.sessionDescriptionHandler=this.setupSessionDescriptionHandler(),this.emit("SessionDescriptionHandler-created",this.sessionDescriptionHandler),this.sessionDescriptionHandler.hasDescription(t.message.getHeader("Content-Type")||"")?(this.hasAnswer=!0,this.sessionDescriptionHandler.setDescription(t.message.body,this.sessionDescriptionHandlerOptions,this.modifiers).then((function(){clearTimeout(r.timers.rel1xxTimer),clearTimeout(r.timers.prackTimer),t.accept(),r.status===c.SessionStatus.STATUS_ANSWERED_WAITING_FOR_PRACK&&(r.status=c.SessionStatus.STATUS_EARLY_MEDIA,r.accept()),r.status=c.SessionStatus.STATUS_EARLY_MEDIA}),(function(e){r.logger.warn(e),r.terminate({statusCode:"488",reasonPhrase:"Bad Media Description"}),r.failed(t.message,o.C.causes.BAD_MEDIA_DESCRIPTION),r.terminated(t.message,o.C.causes.BAD_MEDIA_DESCRIPTION)}))):(this.terminate({statusCode:"488",reasonPhrase:"Bad Media Description"}),this.failed(t.message,o.C.causes.BAD_MEDIA_DESCRIPTION),this.terminated(t.message,o.C.causes.BAD_MEDIA_DESCRIPTION))):this.status===c.SessionStatus.STATUS_EARLY_MEDIA&&t.accept();break;default:e.prototype.receiveRequest.call(this,t)}},t.prototype.setupSessionDescriptionHandler=function(){return this.sessionDescriptionHandler?this.sessionDescriptionHandler:this.sessionDescriptionHandlerFactory(this,this.ua.configuration.sessionDescriptionHandlerFactoryOptions)},t.prototype.generateResponseOfferAnswer=function(e){if(!this.session){var t=a.getBody(this.incomingRequest.message);return t&&"session"===t.contentDisposition?this.setOfferAndGetAnswer(t,e):this.getOffer(e)}switch(this.session.signalingState){case a.SignalingState.Initial:return this.getOffer(e);case a.SignalingState.Stable:case a.SignalingState.HaveLocalOffer:return Promise.resolve(void 0);case a.SignalingState.HaveRemoteOffer:if(!this.session.offer)throw new Error("Session offer undefined");return this.setOfferAndGetAnswer(this.session.offer,e);case a.SignalingState.Closed:default:throw new Error("Invalid signaling state "+this.session.signalingState+".")}},t.prototype.handlePrackOfferAnswer=function(e,t){if(!this.session)throw new Error("Session undefined.");var r=a.getBody(e.message);if(!r||"session"!==r.contentDisposition)return Promise.resolve(void 0);switch(this.session.signalingState){case a.SignalingState.Initial:throw new Error("Invalid signaling state "+this.session.signalingState+".");case a.SignalingState.Stable:return this.setAnswer(r,t).then((function(){}));case a.SignalingState.HaveLocalOffer:throw new Error("Invalid signaling state "+this.session.signalingState+".");case a.SignalingState.HaveRemoteOffer:return this.setOfferAndGetAnswer(r,t);case a.SignalingState.Closed:default:throw new Error("Invalid signaling state "+this.session.signalingState+".")}},t.prototype.canceled=function(){return this._canceled=!0,e.prototype.canceled.call(this)},t.prototype.terminated=function(t,r){return this.prackNeverArrived(),e.prototype.terminated.call(this,t,r)},t.prototype._accept=function(e){var t=this;return void 0===e&&(e={}),this.onInfo=e.onInfo,this.status===c.SessionStatus.STATUS_WAITING_FOR_PRACK?(this.status=c.SessionStatus.STATUS_ANSWERED_WAITING_FOR_PRACK,this.waitForArrivalOfPrack().then((function(){t.status=c.SessionStatus.STATUS_ANSWERED,clearTimeout(t.timers.userNoAnswerTimer)})).then((function(){return t.generateResponseOfferAnswer(e)})).then((function(e){return t.incomingRequest.accept({statusCode:200,body:e})}))):this.status!==c.SessionStatus.STATUS_WAITING_FOR_ANSWER?Promise.reject(new u.Exceptions.InvalidStateError(this.status)):(this.status=c.SessionStatus.STATUS_ANSWERED,this.status=c.SessionStatus.STATUS_ANSWERED,clearTimeout(this.timers.userNoAnswerTimer),this.generateResponseOfferAnswer(e).then((function(e){return t.incomingRequest.accept({statusCode:200,body:e})})))},t.prototype._progress=function(e){void 0===e&&(e={});var t=e.statusCode||180,r=e.reasonPhrase,i=(e.extraHeaders||[]).slice(),n=e.body?a.fromBodyLegacy(e.body):void 0;if(183===t&&!n)return this._progressWithSDP(e);try{var s=this.incomingRequest.progress({statusCode:t,reasonPhrase:r,extraHeaders:i,body:n});return this.emit("progress",s.message,r),this.session=s.session,Promise.resolve(s)}catch(e){return Promise.reject(e)}},t.prototype._progressWithSDP=function(e){var t=this;void 0===e&&(e={});var r=e.statusCode||183,i=e.reasonPhrase,n=(e.extraHeaders||[]).slice();return this.generateResponseOfferAnswer(e).then((function(e){return t.incomingRequest.progress({statusCode:r,reasonPhrase:i,extraHeaders:n,body:e})})).then((function(e){return t.emit("progress",e.message,i),t.session=e.session,e}))},t.prototype._reliableProgress=function(e){var t=this;void 0===e&&(e={});var r=e.statusCode||183,i=e.reasonPhrase,n=(e.extraHeaders||[]).slice();return n.push("Require: 100rel"),n.push("RSeq: "+Math.floor(1e4*Math.random())),this.generateResponseOfferAnswer(e).then((function(e){return t.incomingRequest.progress({statusCode:r,reasonPhrase:i,extraHeaders:n,body:e})})).then((function(e){return t.emit("progress",e.message,i),t.session=e.session,e}))},t.prototype._reliableProgressWaitForPrack=function(e){var t=this;void 0===e&&(e={});var r,i=e.statusCode||183,n=e.reasonPhrase,s=(e.extraHeaders||[]).slice();return s.push("Require: 100rel"),s.push("RSeq: "+this.rseq++),this.status=c.SessionStatus.STATUS_WAITING_FOR_PRACK,new Promise((function(d,p){var l=!0;return t.generateResponseOfferAnswer(e).then((function(e){return r=e,t.incomingRequest.progress({statusCode:i,reasonPhrase:n,extraHeaders:s,body:r})})).then((function(h){var g,f;t.emit("progress",h.message,n),t.session=h.session,h.session.delegate={onPrack:function(r){g=r,clearTimeout(m),clearTimeout(T),l&&(l=!1,t.handlePrackOfferAnswer(g,e).then((function(e){try{f=g.accept({statusCode:200,body:e}),t.status===c.SessionStatus.STATUS_WAITING_FOR_PRACK&&(t.status=c.SessionStatus.STATUS_WAITING_FOR_ANSWER),t.prackArrived(),d({prackRequest:g,prackResponse:f,progressResponse:h})}catch(e){p(e)}})))}};var m=setTimeout((function(){if(l){l=!1,t.logger.warn("No PRACK received, rejecting INVITE."),clearTimeout(T);try{t.incomingRequest.reject({statusCode:504}),t.terminated(void 0,o.C.causes.NO_PRACK),p(new u.Exceptions.TerminatedSessionError)}catch(e){p(e)}}}),64*a.Timers.T1),v=function(){try{t.incomingRequest.progress({statusCode:i,reasonPhrase:n,extraHeaders:s,body:r})}catch(e){return l=!1,void p(e)}T=setTimeout(v,S*=2)},S=a.Timers.T1,T=setTimeout(v,S)}))}))},t.prototype.onAckTimeout=function(){if(this.status===c.SessionStatus.STATUS_WAITING_FOR_ACK){if(this.logger.log("no ACK received for an extended period of time, terminating the call"),!this.session)throw new Error("Session undefined.");this.session.bye(),this.terminated(void 0,o.C.causes.NO_ACK)}},t.prototype.onContextError=function(e){var t=480;e instanceof a.Exception?e instanceof u.Exceptions.SessionDescriptionHandlerError?(this.logger.error(e.message),e.error&&this.logger.error(e.error)):e instanceof u.Exceptions.TerminatedSessionError?this.logger.warn("Incoming session terminated while waiting for PRACK."):e instanceof u.Exceptions.UnsupportedSessionDescriptionContentTypeError?t=415:e instanceof a.Exception&&this.logger.error(e.message):e instanceof Error?this.logger.error(e.message):(this.logger.error("An error occurred in the session description handler."),this.logger.error(e));try{this.incomingRequest.reject({statusCode:t}),this.failed(this.incomingRequest.message,e.message),this.terminated(this.incomingRequest.message,e.message)}catch(e){return}},t.prototype.prackArrived=function(){this.waitingForPrackResolve&&this.waitingForPrackResolve(),this.waitingForPrackPromise=void 0,this.waitingForPrackResolve=void 0,this.waitingForPrackReject=void 0},t.prototype.prackNeverArrived=function(){this.waitingForPrackReject&&this.waitingForPrackReject(new u.Exceptions.TerminatedSessionError),this.waitingForPrackPromise=void 0,this.waitingForPrackResolve=void 0,this.waitingForPrackReject=void 0},t.prototype.waitForArrivalOfPrack=function(){var e=this;if(this.waitingForPrackPromise)throw new Error("Already waiting for PRACK");return this.waitingForPrackPromise=new Promise((function(t,r){e.waitingForPrackResolve=t,e.waitingForPrackReject=r})),this.waitingForPrackPromise},t.prototype.getOffer=function(e){return this.hasOffer=!0,this.getSessionDescriptionHandler().getDescription(e.sessionDescriptionHandlerOptions,e.modifiers).then((function(e){return h.Utils.fromBodyObj(e)}))},t.prototype.setAnswer=function(e,t){this.hasAnswer=!0;var r=this.getSessionDescriptionHandler();return r.hasDescription(e.contentType)?r.setDescription(e.content,t.sessionDescriptionHandlerOptions,t.modifiers):Promise.reject(new u.Exceptions.UnsupportedSessionDescriptionContentTypeError)},t.prototype.setOfferAndGetAnswer=function(e,t){this.hasOffer=!0,this.hasAnswer=!0;var r=this.getSessionDescriptionHandler();return r.hasDescription(e.contentType)?r.setDescription(e.content,t.sessionDescriptionHandlerOptions,t.modifiers).then((function(){return r.getDescription(t.sessionDescriptionHandlerOptions,t.modifiers)})).then((function(e){return h.Utils.fromBodyObj(e)})):Promise.reject(new u.Exceptions.UnsupportedSessionDescriptionContentTypeError)},t.prototype.getSessionDescriptionHandler=function(){var e=this.sessionDescriptionHandler=this.setupSessionDescriptionHandler();return this.emit("SessionDescriptionHandler-created",this.sessionDescriptionHandler),e},t}(g);t.InviteServerContext=f;var m=function(e){function t(t,r,i,n){void 0===i&&(i={}),void 0===n&&(n=[]);var a=this;if(!t.configuration.sessionDescriptionHandlerFactory)throw t.logger.warn("Can't build ISC without SDH Factory"),new Error("ICC Constructor Failed");i.params=i.params||{};var d=i.anonymous||!1,p=h.Utils.newTag();i.params.fromTag=p;var l=t.contact.toString({anonymous:d,outbound:d?!t.contact.tempGruu:!t.contact.pubGruu}),g=(i.extraHeaders||[]).slice();if(d&&t.configuration.uri&&(i.params.fromDisplayName="Anonymous",i.params.fromUri="sip:anonymous@anonymous.invalid",g.push("P-Preferred-Identity: "+t.configuration.uri.toString()),g.push("Privacy: id")),g.push("Contact: "+l),g.push("Allow: "+["ACK","CANCEL","INVITE","MESSAGE","BYE","OPTIONS","INFO","NOTIFY","REFER"].toString()),t.configuration.rel100===o.C.supported.REQUIRED&&g.push("Require: 100rel"),t.configuration.replaces===o.C.supported.REQUIRED&&g.push("Require: replaces"),i.extraHeaders=g,a=e.call(this,t.configuration.sessionDescriptionHandlerFactory)||this,s.ClientContext.initializer(a,t,o.C.INVITE,r,i),a.earlyMediaSessionDescriptionHandlers=new Map,a.type=c.TypeStrings.InviteClientContext,a.passedOptions=i,a.sessionDescriptionHandlerOptions=i.sessionDescriptionHandlerOptions||{},a.modifiers=n,a.inviteWithoutSdp=i.inviteWithoutSdp||!1,a.anonymous=i.anonymous||!1,a.renderbody=i.renderbody||void 0,a.rendertype=i.rendertype||"text/plain",a.fromTag=p,a.contact=l,a.status!==c.SessionStatus.STATUS_NULL)throw new u.Exceptions.InvalidStateError(a.status);return a.isCanceled=!1,a.received100=!1,a.method=o.C.INVITE,a.logger=t.getLogger("sip.inviteclientcontext"),t.applicants[a.toString()]=a,a.id=a.request.callId+a.fromTag,a.onInfo=i.onInfo,a.errorListener=a.onTransportError.bind(a),t.transport&&t.transport.on("transportError",a.errorListener),a}return i.__extends(t,e),t.prototype.receiveResponse=function(e){throw new Error("Unimplemented.")},t.prototype.send=function(){return this.sendInvite(),this},t.prototype.invite=function(){var e=this;return this.ua.sessions[this.id]=this,Promise.resolve().then((function(){e.isCanceled||e.status===c.SessionStatus.STATUS_TERMINATED||(e.inviteWithoutSdp?(e.renderbody&&e.rendertype&&(e.request.body={body:e.renderbody,contentType:e.rendertype}),e.status=c.SessionStatus.STATUS_INVITE_SENT,e.send()):(e.sessionDescriptionHandler=e.sessionDescriptionHandlerFactory(e,e.ua.configuration.sessionDescriptionHandlerFactoryOptions||{}),e.emit("SessionDescriptionHandler-created",e.sessionDescriptionHandler),e.sessionDescriptionHandler.getDescription(e.sessionDescriptionHandlerOptions,e.modifiers).then((function(t){e.isCanceled||e.status===c.SessionStatus.STATUS_TERMINATED||(e.hasOffer=!0,e.request.body=t,e.status=c.SessionStatus.STATUS_INVITE_SENT,e.send())}),(function(t){t.type===c.TypeStrings.SessionDescriptionHandlerError&&(e.logger.log(t.message),t.error&&e.logger.log(t.error)),e.status!==c.SessionStatus.STATUS_TERMINATED&&(e.failed(void 0,o.C.causes.WEBRTC_ERROR),e.terminated(void 0,o.C.causes.WEBRTC_ERROR))}))))})),this},t.prototype.cancel=function(e){if(void 0===e&&(e={}),this.status===c.SessionStatus.STATUS_TERMINATED||this.status===c.SessionStatus.STATUS_CONFIRMED)throw new u.Exceptions.InvalidStateError(this.status);if(this.isCanceled)throw new u.Exceptions.InvalidStateError(c.SessionStatus.STATUS_CANCELED);this.isCanceled=!0,this.logger.log("Canceling session");var t=h.Utils.getCancelReason(e.statusCode,e.reasonPhrase);return e.extraHeaders=(e.extraHeaders||[]).slice(),this.outgoingInviteRequest&&(this.logger.warn("Canceling session before it was created"),this.outgoingInviteRequest.cancel(t,e)),this.canceled()},t.prototype.terminate=function(e){return this.status===c.SessionStatus.STATUS_TERMINATED?this:(this.status===c.SessionStatus.STATUS_WAITING_FOR_ACK||this.status===c.SessionStatus.STATUS_CONFIRMED?this.bye(e):this.cancel(e),this)},t.prototype.sendInvite=function(){var e=this;this.outgoingInviteRequest=this.ua.userAgentCore.invite(this.request,{onAccept:function(t){return e.onAccept(t)},onProgress:function(t){return e.onProgress(t)},onRedirect:function(t){return e.onRedirect(t)},onReject:function(t){return e.onReject(t)},onTrying:function(t){return e.onTrying(t)}})},t.prototype.ackAndBye=function(e,t,r,i){if(!this.ua.userAgentCore)throw new Error("Method requires user agent core.");var n=[];r&&n.push("Reason: "+h.Utils.getReasonHeaderValue(r,i));var s=e.ack();this.emit("ack",s.message);var o=t.bye(void 0,{extraHeaders:n});this.emit("bye",o.message)},t.prototype.disposeEarlyMedia=function(){if(!this.earlyMediaSessionDescriptionHandlers)throw new Error("Early media session description handlers undefined.");this.earlyMediaSessionDescriptionHandlers.forEach((function(e){e.close()}))},t.prototype.onAccept=function(e){var t=this;if(!this.earlyMediaSessionDescriptionHandlers)throw new Error("Early media session description handlers undefined.");var r=e.message,i=e.session;if(this.session)this.ackAndBye(e,i);else{if(this.isCanceled)return this.ackAndBye(e,i),void this.emit("bye",this.request);switch(r.hasHeader("P-Asserted-Identity")&&(this.assertedIdentity=a.Grammar.nameAddrHeaderParse(r.getHeader("P-Asserted-Identity"))),this.session=i,this.session.delegate={onAck:function(e){return t.onAck(e)},onBye:function(e){return t.receiveRequest(e)},onInfo:function(e){return t.receiveRequest(e)},onInvite:function(e){return t.receiveRequest(e)},onNotify:function(e){return t.receiveRequest(e)},onPrack:function(e){return t.receiveRequest(e)},onRefer:function(e){return t.receiveRequest(e)}},i.signalingState){case a.SignalingState.Initial:case a.SignalingState.HaveLocalOffer:this.ackAndBye(e,i,400,"Missing session description"),this.failed(r,o.C.causes.BAD_MEDIA_DESCRIPTION);break;case a.SignalingState.HaveRemoteOffer:var n=this.sessionDescriptionHandlerFactory(this,this.ua.configuration.sessionDescriptionHandlerFactoryOptions||{});if(this.sessionDescriptionHandler=n,this.emit("SessionDescriptionHandler-created",this.sessionDescriptionHandler),!n.hasDescription(r.getHeader("Content-Type")||"")){this.ackAndBye(e,i,400,"Missing session description"),this.failed(r,o.C.causes.BAD_MEDIA_DESCRIPTION);break}this.hasOffer=!0,n.setDescription(r.body,this.sessionDescriptionHandlerOptions,this.modifiers).then((function(){return n.getDescription(t.sessionDescriptionHandlerOptions,t.modifiers)})).then((function(i){if(!t.isCanceled&&t.status!==c.SessionStatus.STATUS_TERMINATED){t.status=c.SessionStatus.STATUS_CONFIRMED,t.hasAnswer=!0;var n={contentDisposition:"session",contentType:i.contentType,content:i.body},s=e.ack({body:n});t.emit("ack",s.message),t.accepted(r)}})).catch((function(n){if(n.type!==c.TypeStrings.SessionDescriptionHandlerError)throw n;t.logger.warn("invalid description"),t.logger.warn(n.toString()),t.ackAndBye(e,i,488,"Invalid session description"),t.failed(r,o.C.causes.BAD_MEDIA_DESCRIPTION)}));break;case a.SignalingState.Stable:var s;if(this.renderbody&&this.rendertype&&(s={body:{contentDisposition:"render",contentType:this.rendertype,content:this.renderbody}}),this.hasOffer&&!this.hasAnswer){if(!this.sessionDescriptionHandler)throw new Error("Session description handler undefined.");var u=i.answer;if(!u)throw new Error("Answer is undefined.");this.sessionDescriptionHandler.setDescription(u.content,this.sessionDescriptionHandlerOptions,this.modifiers).then((function(){t.hasAnswer=!0,t.status=c.SessionStatus.STATUS_CONFIRMED;var i=e.ack(s);t.emit("ack",i.message),t.accepted(r)})).catch((function(n){t.logger.error(n),t.ackAndBye(e,i,488,"Not Acceptable Here"),t.failed(r,o.C.causes.BAD_MEDIA_DESCRIPTION)}))}else{if(this.sessionDescriptionHandler=this.earlyMediaSessionDescriptionHandlers.get(i.id),!this.sessionDescriptionHandler)throw new Error("Session description handler undefined.");this.earlyMediaSessionDescriptionHandlers.delete(i.id),this.hasOffer=!0,this.hasAnswer=!0,this.status=c.SessionStatus.STATUS_CONFIRMED;var d=e.ack();this.emit("ack",d.message),this.accepted(r)}break;case a.SignalingState.Closed:break;default:throw new Error("Unknown session signaling state.")}this.disposeEarlyMedia()}},t.prototype.onProgress=function(e){var t=this;if(!this.isCanceled){if(!this.outgoingInviteRequest)throw new Error("Outgoing INVITE request undefined.");if(!this.earlyMediaSessionDescriptionHandlers)throw new Error("Early media session description handlers undefined.");var r=e.message,i=e.session;if(this.status=c.SessionStatus.STATUS_1XX_RECEIVED,r.hasHeader("P-Asserted-Identity")&&(this.assertedIdentity=a.Grammar.nameAddrHeaderParse(r.getHeader("P-Asserted-Identity"))),!i)throw new Error("Session undefined.");var n=r.getHeader("require"),s=r.getHeader("rseq"),u=!!(n&&n.includes("100rel")&&s?Number(s):void 0),d=[];if(u&&d.push("RAck: "+r.getHeader("rseq")+" "+r.getHeader("cseq")),i.signalingState===a.SignalingState.Initial)return u&&(this.logger.warn("First reliable provisional response received MUST contain an offer when INVITE does not contain an offer."),e.prack({extraHeaders:d})),void this.emit("progress",r);if(i.signalingState===a.SignalingState.HaveLocalOffer)return u&&e.prack({extraHeaders:d}),void this.emit("progress",r);if(i.signalingState===a.SignalingState.HaveRemoteOffer){if(!u)return void this.logger.warn("Non-reliable provisional response MUST NOT contain an initial offer, discarding response.");var p=this.sessionDescriptionHandlerFactory(this,this.ua.configuration.sessionDescriptionHandlerFactoryOptions||{});return this.emit("SessionDescriptionHandler-created",p),this.earlyMediaSessionDescriptionHandlers.set(i.id,p),void p.setDescription(r.body,this.sessionDescriptionHandlerOptions,this.modifiers).then((function(){return p.getDescription(t.sessionDescriptionHandlerOptions,t.modifiers)})).then((function(i){var n={contentDisposition:"session",contentType:i.contentType,content:i.body};e.prack({extraHeaders:d,body:n}),t.status=c.SessionStatus.STATUS_EARLY_MEDIA,t.emit("progress",r)})).catch((function(e){t.status!==c.SessionStatus.STATUS_TERMINATED&&(t.failed(void 0,o.C.causes.WEBRTC_ERROR),t.terminated(void 0,o.C.causes.WEBRTC_ERROR))}))}return i.signalingState===a.SignalingState.Stable?(u&&e.prack({extraHeaders:d}),void this.emit("progress",r)):void 0}},t.prototype.onRedirect=function(e){this.disposeEarlyMedia();var t=e.message,r=t.statusCode,i=h.Utils.sipErrorCause(r||0);this.rejected(t,i),this.failed(t,i),this.terminated(t,i)},t.prototype.onReject=function(e){this.disposeEarlyMedia();var t=e.message,r=t.statusCode,i=h.Utils.sipErrorCause(r||0);this.rejected(t,i),this.failed(t,i),this.terminated(t,i)},t.prototype.onTrying=function(e){this.received100=!0,this.emit("progress",e.message)},t}(g);t.InviteClientContext=m},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=r(0),n=r(7),s=r(11),o=r(5),a=r(14),c=r(8),u=r(9),d=function(e){function t(t,r,i,n){void 0===n&&(n={});var o=e.call(this)||this;o.data={},o.method=s.C.SUBSCRIBE,o.body=void 0,o.type=c.TypeStrings.Subscription,o.ua=t,o.logger=t.getLogger("sip.subscription"),n.body&&(o.body={body:n.body,contentType:n.contentType?n.contentType:"application/sdp"});var a=t.normalizeTarget(r);if(!a)throw new TypeError("Invalid target: "+r);if(o.uri=a,o.event=i,void 0===n.expires?o.expires=3600:"number"!=typeof n.expires?(t.logger.warn('Option "expires" must be a number. Using default of 3600.'),o.expires=3600):o.expires=n.expires,o.extraHeaders=(n.extraHeaders||[]).slice(),o.context=o.initContext(),o.disposed=!1,o.request=o.context.message,!o.request.from)throw new Error("From undefined.");if(!o.request.to)throw new Error("From undefined.");return o.localIdentity=o.request.from,o.remoteIdentity=o.request.to,o.id=o.request.callId+o.request.from.parameters.tag+o.event,o.ua.subscriptions[o.id]=o,o}return i.__extends(t,e),t.prototype.dispose=function(){this.disposed||(this.retryAfterTimer&&(clearTimeout(this.retryAfterTimer),this.retryAfterTimer=void 0),this.context.dispose(),this.disposed=!0,delete this.ua.subscriptions[this.id])},t.prototype.on=function(t,r){return e.prototype.on.call(this,t,r)},t.prototype.emit=function(t){for(var r=[],n=1;n<arguments.length;n++)r[n-1]=arguments[n];return e.prototype.emit.apply(this,i.__spreadArrays([t],r))},t.prototype.close=function(){if(!this.disposed)switch(this.dispose(),this.context.state){case o.SubscriptionState.Initial:case o.SubscriptionState.NotifyWait:this.onTerminated();break;case o.SubscriptionState.Pending:case o.SubscriptionState.Active:this.unsubscribe();break;case o.SubscriptionState.Terminated:this.onTerminated()}},t.prototype.refresh=function(){var e=this;switch(this.context.state){case o.SubscriptionState.Initial:case o.SubscriptionState.NotifyWait:case o.SubscriptionState.Pending:break;case o.SubscriptionState.Active:if(this.subscription)this.subscription.refresh().delegate={onAccept:function(t){return e.onAccepted(t)},onRedirect:function(t){return e.onFailed(t)},onReject:function(t){return e.onFailed(t)}};break;case o.SubscriptionState.Terminated:}},t.prototype.subscribe=function(){var e=this;switch(this.context.state){case o.SubscriptionState.Initial:this.context.subscribe().then((function(t){t.success?(t.success.subscription&&(e.subscription=t.success.subscription,e.subscription.delegate={onNotify:function(t){return e.onNotify(t)},onRefresh:function(t){return e.onRefresh(t)},onTerminated:function(){return e.close()}}),e.onNotify(t.success.request)):t.failure&&e.onFailed(t.failure.response)}));break;case o.SubscriptionState.NotifyWait:case o.SubscriptionState.Pending:break;case o.SubscriptionState.Active:this.refresh();break;case o.SubscriptionState.Terminated:}return this},t.prototype.unsubscribe=function(){switch(this.dispose(),this.context.state){case o.SubscriptionState.Initial:case o.SubscriptionState.NotifyWait:break;case o.SubscriptionState.Pending:case o.SubscriptionState.Active:this.subscription&&this.subscription.unsubscribe();break;case o.SubscriptionState.Terminated:}this.onTerminated()},t.prototype.onAccepted=function(e){var t=e.message.statusCode?e.message.statusCode:0,r=u.Utils.getReasonPhrase(t);this.emit("accepted",e.message,r)},t.prototype.onFailed=function(e){if(this.close(),e){var t=e.message.statusCode?e.message.statusCode:0,r=u.Utils.getReasonPhrase(t);this.emit("failed",e.message,r),this.emit("rejected",e.message,r)}},t.prototype.onNotify=function(e){var t=this;if(e.accept(),this.emit("notify",{request:e.message}),!this.disposed){var r=e.message.parseHeader("Subscription-State");if(r&&r.state)switch(r.state){case"terminated":if(r.reason)switch(this.logger.log("Terminated subscription with reason "+r.reason),r.reason){case"deactivated":case"timeout":return this.initContext(),void this.subscribe();case"probation":case"giveup":return this.initContext(),void(r.params&&r.params["retry-after"]?this.retryAfterTimer=setTimeout((function(){return t.subscribe()}),r.params["retry-after"]):this.subscribe())}this.close()}}},t.prototype.onRefresh=function(e){var t=this;e.delegate={onAccept:function(e){return t.onAccepted(e)}}},t.prototype.onTerminated=function(){this.emit("terminated")},t.prototype.initContext=function(){var e=this,t={extraHeaders:this.extraHeaders,body:this.body?u.Utils.fromBodyObj(this.body):void 0};return this.context=new p(this.ua.userAgentCore,this.uri,this.event,this.expires,t),this.context.delegate={onAccept:function(t){return e.onAccepted(t)}},this.context},t}(n.EventEmitter);t.Subscription=d;var p=function(){function e(e,t,r,i,n,o){this.core=e,this.target=t,this.event=r,this.expires=i,this.subscribed=!1,this.logger=e.loggerFactory.getLogger("sip.subscription"),this.delegate=o;var c="Allow: "+a.AllowedMethods.toString(),u=(n&&n.extraHeaders||[]).slice();u.push(c),u.push("Event: "+this.event),u.push("Expires: "+this.expires),u.push("Contact: "+this.core.configuration.contact.toString());var d=n&&n.body;this.message=e.makeOutgoingRequestMessage(s.C.SUBSCRIBE,this.target,this.core.configuration.aor,this.target,{},u,d)}return e.prototype.dispose=function(){this.subscription&&this.subscription.dispose(),this.request&&(this.request.waitNotifyStop(),this.request.dispose())},Object.defineProperty(e.prototype,"state",{get:function(){return this.subscription?this.subscription.subscriptionState:this.subscribed?o.SubscriptionState.NotifyWait:o.SubscriptionState.Initial},enumerable:!0,configurable:!0}),e.prototype.subscribe=function(){var e=this;return this.subscribed?Promise.reject(new Error("Not in initial state. Did you call subscribe more than once?")):(this.subscribed=!0,new Promise((function(t,r){if(!e.message)throw new Error("Message undefined.");e.request=e.core.subscribe(e.message,{onAccept:function(t){e.delegate&&e.delegate.onAccept&&e.delegate.onAccept(t)},onNotify:function(r){e.subscription=r.subscription,e.subscription&&(e.subscription.autoRefresh=!0),t({success:r})},onNotifyTimeout:function(){t({failure:{}})},onRedirect:function(e){t({failure:{response:e}})},onReject:function(e){t({failure:{response:e}})}})})))},e}()},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=r(0),n=r(7),s=r(51),o=r(11),a=r(5),c=r(8),u=r(12),d=r(89),p=r(100),l=r(96),h=r(101),g=r(90),f=r(102),m=r(103),v=r(9),S=r(91),T=r(94),y=function(e){function t(r){var i=e.call(this)||this;if(i.unloadListener=function(){i.stop()},i.type=c.TypeStrings.UA,i.log=new a.LoggerFactory,i.logger=i.getLogger("sip.ua"),i.configuration={},i.applicants={},i.data={},i.sessions={},i.subscriptions={},i.publishers={},i.status=c.UAStatus.STATUS_INIT,void 0===r?r={}:("string"==typeof r||r instanceof String)&&(r={uri:r}),r.log&&(i.log.builtinEnabled=r.log.builtinEnabled,r.log.hasOwnProperty("connector")&&(i.log.connector=r.log.connector),r.log.hasOwnProperty("level"))){var n=r.log.level,s=void 0;if("string"==typeof n)switch(n){case"error":s=a.Levels.error;break;case"warn":s=a.Levels.warn;break;case"log":s=a.Levels.log;break;case"debug":s=a.Levels.debug}else switch(n){case 0:s=a.Levels.error;break;case 1:s=a.Levels.warn;break;case 2:s=a.Levels.log;break;case 3:s=a.Levels.debug}void 0===s?i.logger.error('Invalid "level" parameter value: '+JSON.stringify(n)):i.log.level=s}i.logger.warn("The UA class has been deprecated and will no longer be available starting with SIP.js release 0.16.0. The UA has been replaced by the UserAgent class. Please update accordingly.");try{i.loadConfig(r)}catch(e){throw i.status=c.UAStatus.STATUS_NOT_READY,i.error=t.C.CONFIGURATION_ERROR,e}if(!i.configuration.transportConstructor)throw new a.TransportError("Transport constructor not set");i.transport=new i.configuration.transportConstructor(i.getLogger("sip.transport"),i.configuration.transportOptions);var u=E(i),d={onInvite:function(e){e.trying(),e.delegate={onCancel:function(e){t.onCancel(e)},onTransportError:function(e){t.onTransportError()}};var t=new f.InviteServerContext(i,e);!function(e,t){if(i.configuration.replaces!==o.C.supported.UNSUPPORTED){var r=t.parseHeader("replaces");if(r){var n=i.sessions[r.call_id+r.replaces_from_tag]||i.sessions[r.call_id+r.replaces_to_tag]||void 0;if(!n)return void i.userAgentCore.replyStateless(t,{statusCode:481});if(n.status===c.SessionStatus.STATUS_TERMINATED)return void i.userAgentCore.replyStateless(t,{statusCode:603});var s=r.call_id+r.replaces_to_tag+r.replaces_from_tag,a=i.userAgentCore.dialogs.get(s);if(!a)return void i.userAgentCore.replyStateless(t,{statusCode:481});if(!a.early&&r.early_only)return void i.userAgentCore.replyStateless(t,{statusCode:486});e.replacee=n}}}(t,e.message),t.autoSendAnInitialProvisionalResponse&&t.progress(),i.emit("invite",t)},onMessage:function(e){var t=new g.ServerContext(i,e);t.body=e.message.body,t.contentType=e.message.getHeader("Content-Type")||"text/plain",e.accept(),i.emit("message",t)},onNotify:function(e){i.configuration.allowLegacyNotifications&&i.listeners("notify").length>0?(e.accept(),i.emit("notify",{request:e.message})):e.reject({statusCode:481})},onRefer:function(e){i.logger.log("Received an out of dialog refer"),i.configuration.allowOutOfDialogRefers||e.reject({statusCode:405}),i.logger.log("Allow out of dialog refers is enabled on the UA");var t=new l.ReferServerContext(i,e);i.listeners("outOfDialogReferRequested").length?i.emit("outOfDialogReferRequested",t):(i.logger.log("No outOfDialogReferRequest listeners, automatically accepting and following the out of dialog refer"),t.accept({followRefer:!0}))},onSubscribe:function(e){i.emit("subscribe",e)}};return i.userAgentCore=new a.UserAgentCore(u,d),i.registerContext=new h.RegisterContext(i,r.registerOptions),i.registerContext.on("failed",i.emit.bind(i,"registrationFailed")),i.registerContext.on("registered",i.emit.bind(i,"registered")),i.registerContext.on("unregistered",i.emit.bind(i,"unregistered")),i.configuration.autostart&&i.start(),i}return i.__extends(t,e),t.prototype.register=function(e){return void 0===e&&(e={}),e.register&&(this.configuration.register=!0),this.registerContext.register(e),this},t.prototype.unregister=function(e){var t=this;return this.configuration.register=!1,this.transport.afterConnected((function(){t.registerContext.unregister(e)})),this},t.prototype.isRegistered=function(){return this.registerContext.registered},t.prototype.invite=function(e,t,r){var i=this,n=new f.InviteClientContext(this,e,t,r);return this.transport.afterConnected((function(){n.invite(),i.emit("inviteSent",n)})),n},t.prototype.subscribe=function(e,t,r){var i=new m.Subscription(this,e,t,r);return this.transport.afterConnected((function(){return i.subscribe()})),i},t.prototype.publish=function(e,t,r,i){var n=new p.PublishContext(this,e,t,i);return this.transport.afterConnected((function(){n.publish(r)})),n},t.prototype.message=function(e,t,r){if(void 0===r&&(r={}),void 0===t)throw new TypeError("Not enough arguments");return r.contentType=r.contentType||"text/plain",r.body=t,this.request(o.C.MESSAGE,e,r)},t.prototype.request=function(e,t,r){var i=new s.ClientContext(this,e,t,r);return this.transport.afterConnected((function(){return i.send()})),i},t.prototype.stop=function(){if(this.logger.log("user requested closure..."),this.status===c.UAStatus.STATUS_USER_CLOSED)return this.logger.warn("UA already closed"),this;for(var e in this.logger.log("closing registerContext"),this.registerContext.close(),this.sessions)this.sessions[e]&&(this.logger.log("closing session "+e),this.sessions[e].terminate());for(var t in this.subscriptions)this.subscriptions[t]&&(this.logger.log("unsubscribe "+t),this.subscriptions[t].unsubscribe());for(var r in this.publishers)this.publishers[r]&&(this.logger.log("unpublish "+r),this.publishers[r].close());for(var i in this.applicants)this.applicants[i]&&this.applicants[i].close();if(this.status=c.UAStatus.STATUS_USER_CLOSED,this.transport.disconnect(),this.userAgentCore.reset(),this.configuration.autostop){var n=!("undefined"==typeof chrome||!chrome.app||!chrome.app.runtime);"undefined"==typeof window||"function"!=typeof window.removeEventListener||n||window.removeEventListener("unload",this.unloadListener)}return this},t.prototype.start=function(){if(this.logger.log("user requested startup..."),this.status===c.UAStatus.STATUS_INIT?(this.status=c.UAStatus.STATUS_STARTING,this.setTransportListeners(),this.emit("transportCreated",this.transport),this.transport.connect()):this.status===c.UAStatus.STATUS_USER_CLOSED?(this.logger.log("resuming"),this.status=c.UAStatus.STATUS_READY,this.transport.connect()):this.status===c.UAStatus.STATUS_STARTING?this.logger.log("UA is in STARTING status, not opening new connection"):this.status===c.UAStatus.STATUS_READY?this.logger.log("UA is in READY status, not resuming"):this.logger.error("Connection is down. Auto-Recovery system is trying to connect"),this.configuration.autostop){var e=!("undefined"==typeof chrome||!chrome.app||!chrome.app.runtime);"undefined"==typeof window||"function"!=typeof window.addEventListener||e||window.addEventListener("unload",this.unloadListener)}return this},t.prototype.normalizeTarget=function(e){return v.Utils.normalizeTarget(e,this.configuration.hostportParams)},t.prototype.getLogger=function(e,t){return this.log.getLogger(e,t)},t.prototype.getLoggerFactory=function(){return this.log},t.prototype.getSupportedResponseOptions=function(){var e=[];(this.contact.pubGruu||this.contact.tempGruu)&&e.push("gruu"),this.configuration.rel100===o.C.supported.SUPPORTED&&e.push("100rel"),this.configuration.replaces===o.C.supported.SUPPORTED&&e.push("replaces"),e.push("outbound"),e=e.concat(this.configuration.extraSupported||[]);var t=this.configuration.hackAllowUnregisteredOptionTags||!1,r={};return e=e.filter((function(e){var i=o.C.OPTION_TAGS[e],n=!r[e];return r[e]=!0,(i||t)&&n}))},t.prototype.findSession=function(e){return this.sessions[e.callId+e.fromTag]||this.sessions[e.callId+e.toTag]||void 0},t.prototype.on=function(t,r){return e.prototype.on.call(this,t,r)},t.prototype.onTransportError=function(){this.status!==c.UAStatus.STATUS_USER_CLOSED&&(this.error&&this.error===t.C.NETWORK_ERROR||(this.status=c.UAStatus.STATUS_NOT_READY,this.error=t.C.NETWORK_ERROR))},t.prototype.setTransportListeners=function(){var e=this;this.transport.on("connected",(function(){return e.onTransportConnected()})),this.transport.on("message",(function(t){return e.onTransportReceiveMsg(t)})),this.transport.on("transportError",(function(){return e.onTransportError()}))},t.prototype.onTransportConnected=function(){var e=this;this.configuration.register&&Promise.resolve().then((function(){return e.registerContext.register()}))},t.prototype.onTransportReceiveMsg=function(e){var t=this,r=d.Parser.parseMessage(e,this.getLogger("sip.parser"));if(r)if(this.status===c.UAStatus.STATUS_USER_CLOSED&&r instanceof a.IncomingRequestMessage)this.logger.warn("UA received message when status = USER_CLOSED - aborting");else{var i=function(){for(var e=0,i=["from","to","call_id","cseq","via"];e<i.length;e++){var n=i[e];if(!r.hasHeader(n))return t.logger.warn("Missing mandatory header field : "+n+"."),!1}return!0};if(r instanceof a.IncomingRequestMessage){if(!i())return void this.logger.warn("Request missing mandatory header field. Dropping.");if(!r.toTag&&r.callId.substr(0,5)===this.configuration.sipjsId)return void this.userAgentCore.replyStateless(r,{statusCode:482});var n=v.Utils.str_utf8_length(r.body);if((s=r.getHeader("content-length"))&&n<Number(s))return void this.userAgentCore.replyStateless(r,{statusCode:400})}if(r instanceof a.IncomingResponseMessage){if(!i())return void this.logger.warn("Response missing mandatory header field. Dropping.");if(r.getHeaders("via").length>1)return void this.logger.warn("More than one Via header field present in the response. Dropping.");if(r.via.host!==this.configuration.viaHost||void 0!==r.via.port)return void this.logger.warn("Via sent-by in the response does not match UA Via host value. Dropping.");var s;n=v.Utils.str_utf8_length(r.body);if((s=r.getHeader("content-length"))&&n<Number(s))return void this.logger.warn("Message body length is lower than the value in Content-Length header field. Dropping.")}if(r instanceof a.IncomingRequestMessage)this.userAgentCore.receiveIncomingRequestFromTransport(r);else{if(!(r instanceof a.IncomingResponseMessage))throw new Error("Invalid message type.");this.userAgentCore.receiveIncomingResponseFromTransport(r)}}else this.logger.warn("UA failed to parse incoming SIP message - discarding.")},t.prototype.checkAuthenticationFactory=function(e){if(e instanceof Function)return e.initialize||(e.initialize=function(){return Promise.resolve()}),e},t.prototype.loadConfig=function(e){var t=this,r={viaHost:v.Utils.createRandomToken(12)+".invalid",uri:new a.URI("sip","anonymous."+v.Utils.createRandomToken(6),"anonymous.invalid",void 0,void 0),custom:{},displayName:"",password:void 0,register:!0,registerOptions:{},transportConstructor:T.Transport,transportOptions:{},usePreloadedRoute:!1,userAgentString:o.C.USER_AGENT,noAnswerTimeout:60,hackViaTcp:!1,hackIpInContact:!1,hackWssInTransport:!1,hackAllowUnregisteredOptionTags:!1,sessionDescriptionHandlerFactoryOptions:{constraints:{},peerConnectionOptions:{}},extraSupported:[],contactName:v.Utils.createRandomToken(8),contactTransport:"ws",forceRport:!1,autostart:!0,autostop:!0,rel100:o.C.supported.UNSUPPORTED,dtmfType:o.C.dtmfType.INFO,replaces:o.C.supported.UNSUPPORTED,sessionDescriptionHandlerFactory:S.SessionDescriptionHandler.defaultFactory,authenticationFactory:this.checkAuthenticationFactory((function(e){return new a.DigestAuthentication(e.getLoggerFactory(),t.configuration.authorizationUser,t.configuration.password)})),allowLegacyNotifications:!1,allowOutOfDialogRefers:!1,experimentalFeatures:!1},i=this.getConfigurationCheck();for(var n in i.mandatory){if(!e.hasOwnProperty(n))throw new u.Exceptions.ConfigurationError(n);var s=e[n];if(void 0===(c=i.mandatory[n](s)))throw new u.Exceptions.ConfigurationError(n,s);r[n]=c}for(var n in i.optional)if(e.hasOwnProperty(n)){var c;if((s=e[n])instanceof Array&&0===s.length||null===s||""===s||void 0===s||"number"==typeof s&&isNaN(s))continue;if(void 0===(c=i.optional[n](s)))throw new u.Exceptions.ConfigurationError(n,s);r[n]=c}0===r.displayName&&(r.displayName="0"),r.sipjsId=v.Utils.createRandomToken(5);var d=r.uri.clone();if(d.user=void 0,r.hostportParams=d.toRaw().replace(/^sip:/i,""),r.authorizationUser||(r.authorizationUser=r.uri.user),r.noAnswerTimeout=1e3*r.noAnswerTimeout,r.hackIpInContact)if("boolean"==typeof r.hackIpInContact){var p=Math.floor(254*Math.random()+1);r.viaHost="192.0.2."+p}else"string"==typeof r.hackIpInContact&&(r.viaHost=r.hackIpInContact);r.hackWssInTransport&&(r.contactTransport="wss"),this.contact={pubGruu:void 0,tempGruu:void 0,uri:new a.URI("sip",r.contactName,r.viaHost,void 0,{transport:r.contactTransport}),toString:function(e){void 0===e&&(e={});var i=e.anonymous||!1,n=e.outbound||!1,s="<";return s+=i?(t.contact.tempGruu||"sip:anonymous@anonymous.invalid;transport="+r.contactTransport).toString():(t.contact.pubGruu||t.contact.uri).toString(),n&&(s+=";ob"),s+=">"}};var l={};for(var n in r)r.hasOwnProperty(n)&&(l[n]=r[n]);for(var n in Object.assign(this.configuration,l),this.logger.log("configuration parameters after validation:"),r)if(r.hasOwnProperty(n))switch(n){case"uri":case"sessionDescriptionHandlerFactory":this.logger.log("\xb7 "+n+": "+r[n]);break;case"password":this.logger.log("\xb7 "+n+": NOT SHOWN");break;case"transportConstructor":this.logger.log("\xb7 "+n+": "+r[n].name);break;default:this.logger.log("\xb7 "+n+": "+JSON.stringify(r[n]))}},t.prototype.getConfigurationCheck=function(){return{mandatory:{},optional:{uri:function(e){/^sip:/i.test(e)||(e=o.C.SIP+":"+e);var t=a.Grammar.URIParse(e);return t&&t.user?t:void 0},transportConstructor:function(e){if(e instanceof Function)return e},transportOptions:function(e){if("object"==typeof e)return e},authorizationUser:function(e){return-1===a.Grammar.parse('"'+e+'"',"quoted_string")?void 0:e},displayName:function(e){return-1===a.Grammar.parse('"'+e+'"',"displayName")?void 0:e},dtmfType:function(e){switch(e){case o.C.dtmfType.RTP:return o.C.dtmfType.RTP;case o.C.dtmfType.INFO:default:return o.C.dtmfType.INFO}},hackViaTcp:function(e){if("boolean"==typeof e)return e},hackIpInContact:function(e){return"boolean"==typeof e?e:"string"==typeof e&&-1!==a.Grammar.parse(e,"host")?e:void 0},hackWssInTransport:function(e){if("boolean"==typeof e)return e},hackAllowUnregisteredOptionTags:function(e){if("boolean"==typeof e)return e},contactTransport:function(e){if("string"==typeof e)return e},extraSupported:function(e){if(e instanceof Array){for(var t=0,r=e;t<r.length;t++){if("string"!=typeof r[t])return}return e}},forceRport:function(e){if("boolean"==typeof e)return e},noAnswerTimeout:function(e){if(v.Utils.isDecimal(e)){var t=Number(e);if(t>0)return t}},password:function(e){return String(e)},rel100:function(e){return e===o.C.supported.REQUIRED?o.C.supported.REQUIRED:e===o.C.supported.SUPPORTED?o.C.supported.SUPPORTED:o.C.supported.UNSUPPORTED},replaces:function(e){return e===o.C.supported.REQUIRED?o.C.supported.REQUIRED:e===o.C.supported.SUPPORTED?o.C.supported.SUPPORTED:o.C.supported.UNSUPPORTED},register:function(e){if("boolean"==typeof e)return e},registerOptions:function(e){if("object"==typeof e)return e},usePreloadedRoute:function(e){if("boolean"==typeof e)return e},userAgentString:function(e){if("string"==typeof e)return e},autostart:function(e){if("boolean"==typeof e)return e},autostop:function(e){if("boolean"==typeof e)return e},sessionDescriptionHandlerFactory:function(e){if(e instanceof Function)return e},sessionDescriptionHandlerFactoryOptions:function(e){if("object"==typeof e)return e},authenticationFactory:this.checkAuthenticationFactory,allowLegacyNotifications:function(e){if("boolean"==typeof e)return e},custom:function(e){if("object"==typeof e)return e},contactName:function(e){if("string"==typeof e)return e},experimentalFeatures:function(e){if("boolean"==typeof e)return e}}}},t.C={STATUS_INIT:0,STATUS_STARTING:1,STATUS_READY:2,STATUS_USER_CLOSED:3,STATUS_NOT_READY:4,CONFIGURATION_ERROR:1,NETWORK_ERROR:2,ALLOWED_METHODS:["ACK","CANCEL","INVITE","MESSAGE","BYE","OPTIONS","INFO","NOTIFY","REFER"],ACCEPTED_BODY_TYPES:["application/sdp","application/dtmf-relay"],MAX_FORWARDS:70,TAG_LENGTH:10},t}(n.EventEmitter);function E(e){if(!(e.configuration.uri instanceof a.URI))throw new Error("Configuration URI not instance of URI.");var t=e.configuration.uri,r=e.contact,i=e.configuration.displayName?e.configuration.displayName:"",n=!!e.configuration.hackViaTcp,s=e.configuration.usePreloadedRoute&&e.transport.server&&e.transport.server.sipUri?[e.transport.server.sipUri]:[],c=e.configuration.sipjsId||v.Utils.createRandomToken(5),u=[];u.push("outbound"),e.configuration.rel100===o.C.supported.SUPPORTED&&u.push("100rel"),e.configuration.replaces===o.C.supported.SUPPORTED&&u.push("replaces"),e.configuration.extraSupported&&u.push.apply(u,e.configuration.extraSupported),e.configuration.hackAllowUnregisteredOptionTags||(u=u.filter((function(e){return o.C.OPTION_TAGS[e]}))),u=Array.from(new Set(u));var d=e.getSupportedResponseOptions(),p=e.configuration.userAgentString||"sipjs";if(!e.configuration.viaHost)throw new Error("Configuration via host undefined");var l=!!e.configuration.forceRport,h=e.configuration.viaHost;return{aor:t,contact:r,displayName:i,hackViaTcp:n,loggerFactory:e.getLoggerFactory(),routeSet:s,sipjsId:c,supportedOptionTags:u,supportedOptionTagsResponse:d,userAgentHeaderFieldValue:p,viaForceRport:l,viaHost:h,authenticationFactory:function(){if(e.configuration.authenticationFactory)return e.configuration.authenticationFactory(e)},transportAccessor:function(){return e.transport}}}t.UA=y,function(e){!function(e){e.RTP="rtp",e.INFO="info"}(e.DtmfType||(e.DtmfType={}))}(y=t.UA||(t.UA={})),t.UA=y,t.makeUserAgentCoreConfigurationFromUA=E},,,,,function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=r(0),n=r(5);t.DigestAuthentication=n.DigestAuthentication,t.Grammar=n.Grammar,t.IncomingRequest=n.IncomingRequestMessage,t.IncomingResponse=n.IncomingResponseMessage,t.LoggerFactory=n.LoggerFactory,t.NameAddrHeader=n.NameAddrHeader,t.OutgoingRequest=n.OutgoingRequestMessage,t.Timers=n.Timers,t.Transport=n.Transport,t.URI=n.URI;var s=r(51);t.ClientContext=s.ClientContext;var o=r(11);t.C=o.C;var a=r(8);t.DialogStatus=a.DialogStatus,t.SessionStatus=a.SessionStatus,t.TypeStrings=a.TypeStrings,t.UAStatus=a.UAStatus;var c=r(12);t.Exceptions=c.Exceptions;var u=r(89);t.Parser=u.Parser;var d=r(100);t.PublishContext=d.PublishContext;var p=r(96);t.ReferClientContext=p.ReferClientContext,t.ReferServerContext=p.ReferServerContext;var l=r(101);t.RegisterContext=l.RegisterContext;var h=r(90);t.ServerContext=h.ServerContext;var g=r(102);t.InviteClientContext=g.InviteClientContext,t.InviteServerContext=g.InviteServerContext,t.Session=g.Session;var f=r(103);t.Subscription=f.Subscription;var m=r(1),v={InviteClientTransaction:m.InviteClientTransaction,InviteServerTransaction:m.InviteServerTransaction,NonInviteClientTransaction:m.NonInviteClientTransaction,NonInviteServerTransaction:m.NonInviteServerTransaction};t.Transactions=v;var S=r(104);t.makeUserAgentCoreConfigurationFromUA=S.makeUserAgentCoreConfigurationFromUA,t.UA=S.UA;var T=r(9);t.Utils=T.Utils;var y=i.__importStar(r(111));t.Web=y;var E=o.C.version;t.version=E;t.name="sip.js";var b=i.__importStar(r(5));t.Core=b},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=r(0),n=r(7),s=r(11),o=r(8),a=r(12),c=r(9),u=function(e){function t(t,r,i){void 0===i&&(i={});var n=e.call(this)||this;if(n.C={MIN_DURATION:70,MAX_DURATION:6e3,DEFAULT_DURATION:100,MIN_INTER_TONE_GAP:50,DEFAULT_INTER_TONE_GAP:500},n.type=o.TypeStrings.DTMF,void 0===r)throw new TypeError("Not enough arguments");if(n.logger=t.ua.getLogger("sip.invitecontext.dtmf",t.id),n.owner=t,"string"==typeof r)r=r.toUpperCase();else{if("number"!=typeof r)throw new TypeError("Invalid tone: "+r);r=r.toString()}if(!r.match(/^[0-9A-D#*]$/))throw new TypeError("Invalid tone: "+r);n.tone=r;var s=i.duration,a=i.interToneGap;if(s&&!c.Utils.isDecimal(s))throw new TypeError("Invalid tone duration: "+s);if(s?s<n.C.MIN_DURATION?(n.logger.warn("'duration' value is lower than the minimum allowed, setting it to "+n.C.MIN_DURATION+" milliseconds"),s=n.C.MIN_DURATION):s>n.C.MAX_DURATION?(n.logger.warn("'duration' value is greater than the maximum allowed, setting it to "+n.C.MAX_DURATION+" milliseconds"),s=n.C.MAX_DURATION):s=Math.abs(s):s=n.C.DEFAULT_DURATION,n.duration=s,a&&!c.Utils.isDecimal(a))throw new TypeError("Invalid interToneGap: "+a);return a?a<n.C.MIN_INTER_TONE_GAP?(n.logger.warn("'interToneGap' value is lower than the minimum allowed, setting it to "+n.C.MIN_INTER_TONE_GAP+" milliseconds"),a=n.C.MIN_INTER_TONE_GAP):a=Math.abs(a):a=n.C.DEFAULT_INTER_TONE_GAP,n.interToneGap=a,n}return i.__extends(t,e),t.prototype.send=function(e){if(void 0===e&&(e={}),this.owner.status!==o.SessionStatus.STATUS_CONFIRMED&&this.owner.status!==o.SessionStatus.STATUS_WAITING_FOR_ACK)throw new a.Exceptions.InvalidStateError(this.owner.status);var t=e.extraHeaders?e.extraHeaders.slice():[],r={contentType:"application/dtmf-relay",body:"Signal= "+this.tone+"\r\nDuration= "+this.duration};if(this.owner.session){var i=this.owner.session.info(void 0,{extraHeaders:t,body:c.Utils.fromBodyObj(r)});this.owner.emit("dtmf",i.message,this)}else;},t.prototype.init_incoming=function(e){e.accept(),this.tone&&this.duration?this.owner.emit("dtmf",e.message,this):this.logger.warn("invalid INFO DTMF received, discarded")},t.prototype.receiveResponse=function(e){var t=e&&e.statusCode?e.statusCode:0;switch(!0){case/^1[0-9]{2}$/.test(t.toString()):break;case/^2[0-9]{2}$/.test(t.toString()):this.emit("succeeded",{originator:"remote",response:e});break;default:var r=c.Utils.sipErrorCause(t);this.emit("failed",e,r)}},t.prototype.onRequestTimeout=function(){this.emit("failed",void 0,s.C.causes.REQUEST_TIMEOUT),this.owner.onRequestTimeout()},t.prototype.onTransportError=function(){this.emit("failed",void 0,s.C.causes.CONNECTION_ERROR),this.owner.onTransportError()},t.prototype.onDialogError=function(e){this.emit("failed",e,s.C.causes.DIALOG_ERROR),this.owner.onDialogError(e)},t}(n.EventEmitter);t.DTMF=u},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=r(0).__importStar(r(87));t.Modifiers=i;var n=r(112);t.Simple=n.Simple;var s=r(91);t.SessionDescriptionHandler=s.SessionDescriptionHandler;var o=r(94);t.Transport=o.Transport},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i,n=r(0),s=r(7),o=r(104),a=n.__importStar(r(87));!function(e){e[e.STATUS_NULL=0]="STATUS_NULL",e[e.STATUS_NEW=1]="STATUS_NEW",e[e.STATUS_CONNECTING=2]="STATUS_CONNECTING",e[e.STATUS_CONNECTED=3]="STATUS_CONNECTED",e[e.STATUS_COMPLETED=4]="STATUS_COMPLETED"}(i=t.SimpleStatus||(t.SimpleStatus={}));var c=function(e){function t(t){var r=e.call(this)||this;if(t.media.remote.video?r.video=!0:r.video=!1,t.media.remote.audio?r.audio=!0:r.audio=!1,!r.audio&&!r.video)throw new Error("At least one remote audio or video element is required for Simple.");r.options=t;var n=navigator.userAgent.toLowerCase(),s=!1,c=!1;n.indexOf("safari")>-1&&n.indexOf("chrome")<0?s=!0:n.indexOf("firefox")>-1&&n.indexOf("chrome")<0&&(c=!0);var u={};return s&&(u.modifiers=[a.stripG722]),c&&(u.alwaysAcquireMediaFirst=!0),r.options.ua.uri?r.anonymous=!1:r.anonymous=!0,r.ua=new o.UA({uri:r.options.ua.uri,authorizationUser:r.options.ua.authorizationUser,password:r.options.ua.password,displayName:r.options.ua.displayName,userAgentString:r.options.ua.userAgentString,register:!0,sessionDescriptionHandlerFactoryOptions:u,transportOptions:{traceSip:r.options.ua.traceSip,wsServers:r.options.ua.wsServers}}),r.state=i.STATUS_NULL,r.logger=r.ua.getLogger("sip.simple"),r.ua.on("registered",(function(){r.emit("registered",r.ua)})),r.ua.on("unregistered",(function(){r.emit("unregistered",r.ua)})),r.ua.on("registrationFailed",(function(){r.emit("unregistered",r.ua)})),r.ua.on("invite",(function(e){if(r.state!==i.STATUS_NULL&&r.state!==i.STATUS_COMPLETED)return r.logger.warn("Rejecting incoming call. Simple only supports 1 call at a time"),void e.reject();r.session=e,r.setupSession(),r.emit("ringing",r.session)})),r.ua.on("message",(function(e){r.emit("message",e)})),r}return n.__extends(t,e),t.prototype.call=function(e){if(this.ua&&this.checkRegistration()){if(this.state===i.STATUS_NULL||this.state===i.STATUS_COMPLETED)return this.options.media.remote.audio&&(this.options.media.remote.audio.autoplay=!0),this.options.media.remote.video&&(this.options.media.remote.video.autoplay=!0),this.options.media.local&&this.options.media.local.video&&(this.options.media.local.video.autoplay=!0,this.options.media.local.video.volume=0),this.session=this.ua.invite(e,{sessionDescriptionHandlerOptions:{constraints:{audio:this.audio,video:this.video}}}),this.setupSession(),this.session;this.logger.warn("Cannot make more than a single call with Simple")}else this.logger.warn("A registered UA is required for calling")},t.prototype.answer=function(){if(this.state===i.STATUS_NEW||this.state===i.STATUS_CONNECTING)return this.options.media.remote.audio&&(this.options.media.remote.audio.autoplay=!0),this.options.media.remote.video&&(this.options.media.remote.video.autoplay=!0),this.session.accept({sessionDescriptionHandlerOptions:{constraints:{audio:this.audio,video:this.video}}});this.logger.warn("No call to answer")},t.prototype.reject=function(){if(this.state===i.STATUS_NEW||this.state===i.STATUS_CONNECTING)return this.session.reject();this.logger.warn("Call is already answered")},t.prototype.hangup=function(){if(this.state===i.STATUS_CONNECTED||this.state===i.STATUS_CONNECTING||this.state===i.STATUS_NEW)return this.state!==i.STATUS_CONNECTED?this.session.cancel():this.session?this.session.bye():void 0;this.logger.warn("No active call to hang up on")},t.prototype.hold=function(){if(this.state===i.STATUS_CONNECTED&&this.session&&!this.session.localHold)return this.mute(),this.logger.log("Placing session on hold"),this.session.hold();this.logger.warn("Cannot put call on hold")},t.prototype.unhold=function(){if(this.state===i.STATUS_CONNECTED&&this.session&&this.session.localHold)return this.unmute(),this.logger.log("Placing call off hold"),this.session.unhold();this.logger.warn("Cannot unhold a call that is not on hold")},t.prototype.mute=function(){this.state===i.STATUS_CONNECTED?(this.logger.log("Muting Audio"),this.toggleMute(!0),this.emit("mute",this)):this.logger.warn("An acitve call is required to mute audio")},t.prototype.unmute=function(){this.state===i.STATUS_CONNECTED?(this.logger.log("Unmuting Audio"),this.toggleMute(!1),this.emit("unmute",this)):this.logger.warn("An active call is required to unmute audio")},t.prototype.sendDTMF=function(e){this.state===i.STATUS_CONNECTED&&this.session?(this.logger.log("Sending DTMF tone: "+e),this.session.dtmf(e)):this.logger.warn("An active call is required to send a DTMF tone")},t.prototype.message=function(e,t){this.ua&&this.checkRegistration()?e&&t?this.ua.message(e,t):this.logger.warn("A destination and message are required to send a message"):this.logger.warn("A registered UA is required to send a message")},t.prototype.checkRegistration=function(){return this.anonymous||this.ua&&this.ua.isRegistered()},t.prototype.setupRemoteMedia=function(){var e=this;if(this.session){var t,r=this.session.sessionDescriptionHandler.peerConnection;r.getReceivers?(t=new MediaStream,r.getReceivers().forEach((function(e){var r=e.track;r&&t.addTrack(r)}))):t=r.getRemoteStreams()[0],this.video?(this.options.media.remote.video.srcObject=t,this.options.media.remote.video.play().catch((function(){e.logger.log("play was rejected")}))):this.audio&&(this.options.media.remote.audio.srcObject=t,this.options.media.remote.audio.play().catch((function(){e.logger.log("play was rejected")})))}else this.logger.warn("No session to set remote media on")},t.prototype.setupLocalMedia=function(){if(this.session){if(this.video&&this.options.media.local&&this.options.media.local.video){var e,t=this.session.sessionDescriptionHandler.peerConnection;t.getSenders?(e=new MediaStream,t.getSenders().forEach((function(t){var r=t.track;r&&"video"===r.kind&&e.addTrack(r)}))):e=t.getLocalStreams()[0],this.options.media.local.video.srcObject=e,this.options.media.local.video.volume=0,this.options.media.local.video.play()}}else this.logger.warn("No session to set local media on")},t.prototype.cleanupMedia=function(){this.video&&(this.options.media.remote.video.srcObject=null,this.options.media.remote.video.pause(),this.options.media.local&&this.options.media.local.video&&(this.options.media.local.video.srcObject=null,this.options.media.local.video.pause())),this.audio&&(this.options.media.remote.audio.srcObject=null,this.options.media.remote.audio.pause())},t.prototype.setupSession=function(){var e=this;this.session?(this.state=i.STATUS_NEW,this.emit("new",this.session),this.session.on("progress",(function(){return e.onProgress()})),this.session.on("accepted",(function(){return e.onAccepted()})),this.session.on("rejected",(function(){return e.onEnded()})),this.session.on("failed",(function(){return e.onFailed()})),this.session.on("terminated",(function(){return e.onEnded()}))):this.logger.warn("No session to set up")},t.prototype.destroyMedia=function(){this.session&&this.session.sessionDescriptionHandler&&this.session.sessionDescriptionHandler.close()},t.prototype.toggleMute=function(e){if(this.session){var t=this.session.sessionDescriptionHandler.peerConnection;t.getSenders?t.getSenders().forEach((function(t){t.track&&(t.track.enabled=!e)})):t.getLocalStreams().forEach((function(t){t.getAudioTracks().forEach((function(t){t.enabled=!e})),t.getVideoTracks().forEach((function(t){t.enabled=!e}))}))}else this.logger.warn("No session to toggle mute")},t.prototype.onAccepted=function(){var e=this;this.session?(this.state=i.STATUS_CONNECTED,this.emit("connected",this.session),this.setupLocalMedia(),this.setupRemoteMedia(),this.session.sessionDescriptionHandler&&(this.session.sessionDescriptionHandler.on("addTrack",(function(){e.logger.log("A track has been added, triggering new remoteMedia setup"),e.setupRemoteMedia()})),this.session.sessionDescriptionHandler.on("addStream",(function(){e.logger.log("A stream has been added, trigger new remoteMedia setup"),e.setupRemoteMedia()}))),this.session.on("dtmf",(function(t,r){e.emit("dtmf",r.tone)})),this.session.on("bye",(function(){return e.onEnded()}))):this.logger.warn("No session for accepting")},t.prototype.onProgress=function(){this.state=i.STATUS_CONNECTING,this.emit("connecting",this.session)},t.prototype.onFailed=function(){this.onEnded()},t.prototype.onEnded=function(){this.state=i.STATUS_COMPLETED,this.emit("ended",this.session),this.cleanupMedia()},t.C=i,t}(s.EventEmitter);t.Simple=c}])}));