console
!function(){return function e(t,n,r){function i(a,o){if(!n[a]){if(!t[a]){var l="function"==typeof require&&require;if(!o&&l)return l(a,!0);if(s)return s(a,!0);var u=new Error("Cannot find module '"+a+"'");throw u.code="MODULE_NOT_FOUND",u}var c=n[a]={exports:{}};t[a][0].call(c.exports,function(e){return i(t[a][1][e]||e)},c,c.exports,e,t,n,r)}return n[a].exports}for(var s="function"==typeof require&&require,a=0;a<r.length;a++)i(r[a]);return i}}()({1:[function(e,t,n){function r(){this._events=this._events||{},this._maxListeners=this._maxListeners||void 0}function i(e){return"function"==typeof e}function s(e){return"object"==typeof e&&null!==e}function a(e){return void 0===e}t.exports=r,r.EventEmitter=r,r.prototype._events=void 0,r.prototype._maxListeners=void 0,r.defaultMaxListeners=10,r.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||isNaN(e))throw TypeError("n must be a positive number");return this._maxListeners=e,this},r.prototype.emit=function(e){var t,n,r,o,l,u;if(this._events||(this._events={}),"error"===e&&(!this._events.error||s(this._events.error)&&!this._events.error.length)){if((t=arguments[1])instanceof Error)throw t;var c=new Error('Uncaught, unspecified "error" event. ('+t+")");throw c.context=t,c}if(a(n=this._events[e]))return!1;if(i(n))switch(arguments.length){case 1:n.call(this);break;case 2:n.call(this,arguments[1]);break;case 3:n.call(this,arguments[1],arguments[2]);break;default:o=Array.prototype.slice.call(arguments,1),n.apply(this,o)}else if(s(n))for(o=Array.prototype.slice.call(arguments,1),r=(u=n.slice()).length,l=0;l<r;l++)u[l].apply(this,o);return!0},r.prototype.addListener=function(e,t){var n;if(!i(t))throw TypeError("listener must be a function");return this._events||(this._events={}),this._events.newListener&&this.emit("newListener",e,i(t.listener)?t.listener:t),this._events[e]?s(this._events[e])?this._events[e].push(t):this._events[e]=[this._events[e],t]:this._events[e]=t,s(this._events[e])&&!this._events[e].warned&&(n=a(this._maxListeners)?r.defaultMaxListeners:this._maxListeners)&&n>0&&this._events[e].length>n&&(this._events[e].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[e].length),"function"==typeof console.trace&&console.trace()),this},r.prototype.on=r.prototype.addListener,r.prototype.once=function(e,t){if(!i(t))throw TypeError("listener must be a function");var n=!1;function r(){this.removeListener(e,r),n||(n=!0,t.apply(this,arguments))}return r.listener=t,this.on(e,r),this},r.prototype.removeListener=function(e,t){var n,r,a,o;if(!i(t))throw TypeError("listener must be a function");if(!this._events||!this._events[e])return this;if(a=(n=this._events[e]).length,r=-1,n===t||i(n.listener)&&n.listener===t)delete this._events[e],this._events.removeListener&&this.emit("removeListener",e,t);else if(s(n)){for(o=a;o-- >0;)if(n[o]===t||n[o].listener&&n[o].listener===t){r=o;break}if(r<0)return this;1===n.length?(n.length=0,delete this._events[e]):n.splice(r,1),this._events.removeListener&&this.emit("removeListener",e,t)}return this},r.prototype.removeAllListeners=function(e){var t,n;if(!this._events)return this;if(!this._events.removeListener)return 0===arguments.length?this._events={}:this._events[e]&&delete this._events[e],this;if(0===arguments.length){for(t in this._events)"removeListener"!==t&&this.removeAllListeners(t);return this.removeAllListeners("removeListener"),this._events={},this}if(i(n=this._events[e]))this.removeListener(e,n);else if(n)for(;n.length;)this.removeListener(e,n[n.length-1]);return delete this._events[e],this},r.prototype.listeners=function(e){return this._events&&this._events[e]?i(this._events[e])?[this._events[e]]:this._events[e].slice():[]},r.prototype.listenerCount=function(e){if(this._events){var t=this._events[e];if(i(t))return 1;if(t)return t.length}return 0},r.listenerCount=function(e,t){return e.listenerCount(t)}},{}],2:[function(e,t,n){(function(r){function i(){var e;try{e=n.storage.debug}catch(e){}return!e&&void 0!==r&&"env"in r&&(e=r.env.DEBUG),e}(n=t.exports=e("./debug")).log=function(){return"object"==typeof console&&console.log&&Function.prototype.apply.call(console.log,console,arguments)},n.formatArgs=function(e){var t=this.useColors;if(e[0]=(t?"%c":"")+this.namespace+(t?" %c":" ")+e[0]+(t?"%c ":" ")+"+"+n.humanize(this.diff),!t)return;var r="color: "+this.color;e.splice(1,0,r,"color: inherit");var i=0,s=0;e[0].replace(/%[a-zA-Z%]/g,function(e){"%%"!==e&&(i++,"%c"===e&&(s=i))}),e.splice(s,0,r)},n.save=function(e){try{null==e?n.storage.removeItem("debug"):n.storage.debug=e}catch(e){}},n.load=i,n.useColors=function(){if("undefined"!=typeof window&&window.process&&"renderer"===window.process.type)return!0;if("undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))return!1;return"undefined"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||"undefined"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)},n.storage="undefined"!=typeof chrome&&void 0!==chrome.storage?chrome.storage.local:function(){try{return window.localStorage}catch(e){}}(),n.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"],n.formatters.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}},n.enable(i())}).call(this,e("_process"))},{"./debug":3,_process:34}],3:[function(e,t,n){function r(e){var t;function r(){if(r.enabled){var e=r,i=+new Date,s=i-(t||i);e.diff=s,e.prev=t,e.curr=i,t=i;for(var a=new Array(arguments.length),o=0;o<a.length;o++)a[o]=arguments[o];a[0]=n.coerce(a[0]),"string"!=typeof a[0]&&a.unshift("%O");var l=0;a[0]=a[0].replace(/%([a-zA-Z%])/g,function(t,r){if("%%"===t)return t;l++;var i=n.formatters[r];if("function"==typeof i){var s=a[l];t=i.call(e,s),a.splice(l,1),l--}return t}),n.formatArgs.call(e,a),(r.log||n.log||console.log.bind(console)).apply(e,a)}}return r.namespace=e,r.enabled=n.enabled(e),r.useColors=n.useColors(),r.color=function(e){var t,r=0;for(t in e)r=(r<<5)-r+e.charCodeAt(t),r|=0;return n.colors[Math.abs(r)%n.colors.length]}(e),r.destroy=i,"function"==typeof n.init&&n.init(r),n.instances.push(r),r}function i(){var e=n.instances.indexOf(this);return-1!==e&&(n.instances.splice(e,1),!0)}(n=t.exports=r.debug=r.default=r).coerce=function(e){return e instanceof Error?e.stack||e.message:e},n.disable=function(){n.enable("")},n.enable=function(e){var t;n.save(e),n.names=[],n.skips=[];var r=("string"==typeof e?e:"").split(/[\s,]+/),i=r.length;for(t=0;t<i;t++)r[t]&&("-"===(e=r[t].replace(/\*/g,".*?"))[0]?n.skips.push(new RegExp("^"+e.substr(1)+"$")):n.names.push(new RegExp("^"+e+"$")));for(t=0;t<n.instances.length;t++){var s=n.instances[t];s.enabled=n.enabled(s.namespace)}},n.enabled=function(e){if("*"===e[e.length-1])return!0;var t,r;for(t=0,r=n.skips.length;t<r;t++)if(n.skips[t].test(e))return!1;for(t=0,r=n.names.length;t<r;t++)if(n.names[t].test(e))return!0;return!1},n.humanize=e("ms"),n.instances=[],n.names=[],n.skips=[],n.formatters={}},{ms:33}],4:[function(e,t,n){"use strict";var r=e("./Utils"),i=e("./Constants"),s=e("./Grammar"),a=e("./URI"),o=e("./Socket"),l=e("./Exceptions");n.settings={authorization_user:null,password:null,realm:null,ha1:null,display_name:null,uri:null,contact_uri:null,instance_id:null,use_preloaded_route:!1,session_timers:!0,session_timers_refresh_method:i.UPDATE,no_answer_timeout:60,register:!0,register_expires:600,registrar_server:null,sockets:null,connection_recovery_max_interval:null,connection_recovery_min_interval:null,via_host:r.createRandomToken(12)+".invalid"};var u={mandatory:{sockets:function(e){var t=[];if(o.isSocket(e))t.push({socket:e});else{if(!Array.isArray(e)||!e.length)return;var n=!0,r=!1,i=void 0;try{for(var s,a=e[Symbol.iterator]();!(n=(s=a.next()).done);n=!0){var l=s.value;Object.prototype.hasOwnProperty.call(l,"socket")&&o.isSocket(l.socket)?t.push(l):o.isSocket(l)&&t.push({socket:l})}}catch(e){r=!0,i=e}finally{try{!n&&a.return&&a.return()}finally{if(r)throw i}}}return t},uri:function(e){/^sip:/i.test(e)||(e=i.SIP+":"+e);var t=a.parse(e);return t&&t.user?t:void 0}},optional:{authorization_user:function(e){return-1===s.parse('"'+e+'"',"quoted_string")?void 0:e},user_agent:function(e){if("string"==typeof e)return e},connection_recovery_max_interval:function(e){if(r.isDecimal(e)){var t=Number(e);if(t>0)return t}},connection_recovery_min_interval:function(e){if(r.isDecimal(e)){var t=Number(e);if(t>0)return t}},contact_uri:function(e){if("string"==typeof e){var t=s.parse(e,"SIP_URI");if(-1!==t)return t}},display_name:function(e){return-1===s.parse('"'+e+'"',"display_name")?void 0:e},instance_id:function(e){return/^uuid:/i.test(e)&&(e=e.substr(5)),-1===s.parse(e,"uuid")?void 0:e},no_answer_timeout:function(e){if(r.isDecimal(e)){var t=Number(e);if(t>0)return t}},session_timers:function(e){if("boolean"==typeof e)return e},session_timers_refresh_method:function(e){if("string"==typeof e&&((e=e.toUpperCase())===i.INVITE||e===i.UPDATE))return e},password:function(e){return String(e)},realm:function(e){return String(e)},ha1:function(e){return String(e)},register:function(e){if("boolean"==typeof e)return e},register_expires:function(e){if(r.isDecimal(e)){var t=Number(e);if(t>0)return t}},registrar_server:function(e){/^sip:/i.test(e)||(e=i.SIP+":"+e);var t=a.parse(e);return t?t.user?void 0:t:void 0},use_preloaded_route:function(e){if("boolean"==typeof e)return e}}};n.load=function(e,t){for(var n in u.mandatory){if(!t.hasOwnProperty(n))throw new l.ConfigurationError(n);var i=t[n],s=u.mandatory[n](i);if(void 0===s)throw new l.ConfigurationError(n,i);e[n]=s}for(var a in u.optional)if(t.hasOwnProperty(a)){var o=t[a];if(r.isEmpty(o))continue;var c=u.optional[a](o);if(void 0===c)throw new l.ConfigurationError(a,o);e[a]=c}}},{"./Constants":5,"./Exceptions":9,"./Grammar":10,"./Socket":23,"./URI":28,"./Utils":29}],5:[function(e,t,n){"use strict";var r=e("../package.json");t.exports={USER_AGENT:r.title+" "+r.version,SIP:"sip",SIPS:"sips",causes:{CONNECTION_ERROR:"Connection Error",REQUEST_TIMEOUT:"Request Timeout",SIP_FAILURE_CODE:"SIP Failure Code",INTERNAL_ERROR:"Internal Error",BUSY:"Busy",REJECTED:"Rejected",REDIRECTED:"Redirected",UNAVAILABLE:"Unavailable",NOT_FOUND:"Not Found",ADDRESS_INCOMPLETE:"Address Incomplete",INCOMPATIBLE_SDP:"Incompatible SDP",MISSING_SDP:"Missing SDP",AUTHENTICATION_ERROR:"Authentication Error",BYE:"Terminated",WEBRTC_ERROR:"WebRTC Error",CANCELED:"Canceled",NO_ANSWER:"No Answer",EXPIRES:"Expires",NO_ACK:"No ACK",DIALOG_ERROR:"Dialog Error",USER_DENIED_MEDIA_ACCESS:"User Denied Media Access",BAD_MEDIA_DESCRIPTION:"Bad Media Description",RTP_TIMEOUT:"RTP Timeout"},SIP_ERROR_CAUSES:{REDIRECTED:[300,301,302,305,380],BUSY:[486,600],REJECTED:[403,603],NOT_FOUND:[404,604],UNAVAILABLE:[480,410,408,430],ADDRESS_INCOMPLETE:[484,424],INCOMPATIBLE_SDP:[488,606],AUTHENTICATION_ERROR:[401,407]},ACK:"ACK",BYE:"BYE",CANCEL:"CANCEL",INFO:"INFO",INVITE:"INVITE",MESSAGE:"MESSAGE",NOTIFY:"NOTIFY",OPTIONS:"OPTIONS",REGISTER:"REGISTER",REFER:"REFER",UPDATE:"UPDATE",SUBSCRIBE:"SUBSCRIBE",REASON_PHRASE:{100:"Trying",180:"Ringing",181:"Call Is Being Forwarded",182:"Queued",183:"Session Progress",199:"Early Dialog Terminated",200:"OK",202:"Accepted",204:"No Notification",300:"Multiple Choices",301:"Moved Permanently",302:"Moved Temporarily",305:"Use Proxy",380:"Alternative Service",400:"Bad Request",401:"Unauthorized",402:"Payment Required",403:"Forbidden",404:"Not Found",405:"Method Not Allowed",406:"Not Acceptable",407:"Proxy Authentication Required",408:"Request Timeout",410:"Gone",412:"Conditional Request Failed",413:"Request Entity Too Large",414:"Request-URI Too Long",415:"Unsupported Media Type",416:"Unsupported URI Scheme",417:"Unknown Resource-Priority",420:"Bad Extension",421:"Extension Required",422:"Session Interval Too Small",423:"Interval Too Brief",424:"Bad Location Information",428:"Use Identity Header",429:"Provide Referrer Identity",430:"Flow Failed",433:"Anonymity Disallowed",436:"Bad Identity-Info",437:"Unsupported Certificate",438:"Invalid Identity Header",439:"First Hop Lacks Outbound Support",440:"Max-Breadth Exceeded",469:"Bad Info Package",470:"Consent Needed",478:"Unresolvable Destination",480:"Temporarily Unavailable",481:"Call/Transaction Does Not Exist",482:"Loop Detected",483:"Too Many Hops",484:"Address Incomplete",485:"Ambiguous",486:"Busy Here",487:"Request Terminated",488:"Not Acceptable Here",489:"Bad Event",491:"Request Pending",493:"Undecipherable",494:"Security Agreement Required",500:"JsSIP Internal Error",501:"Not Implemented",502:"Bad Gateway",503:"Service Unavailable",504:"Server Time-out",505:"Version Not Supported",513:"Message Too Large",580:"Precondition Failure",600:"Busy Everywhere",603:"Decline",604:"Does Not Exist Anywhere",606:"Not Acceptable"},ALLOWED_METHODS:"INVITE,ACK,CANCEL,BYE,UPDATE,MESSAGE,OPTIONS,REFER,INFO",ACCEPTED_BODY_TYPES:"application/sdp, application/dtmf-relay",MAX_FORWARDS:69,SESSION_EXPIRES:90,MIN_SESSION_EXPIRES:60}},{"../package.json":32}],6:[function(e,t,n){"use strict";var r=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}();var i=e("./SIPMessage"),s=e("./Constants"),a=e("./Transactions"),o=e("./Dialog/RequestSender"),l=e("./Utils"),u=e("debug")("JsSIP:Dialog"),c={STATUS_EARLY:1,STATUS_CONFIRMED:2};t.exports=function(){function e(t,n,r){var s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:c.STATUS_CONFIRMED;if(function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this._owner=t,this._ua=t._ua,this._uac_pending_reply=!1,this._uas_pending_reply=!1,!n.hasHeader("contact"))return{error:"unable to create a Dialog without Contact header field"};n instanceof i.IncomingResponse&&(s=n.status_code<200?c.STATUS_EARLY:c.STATUS_CONFIRMED);var a=n.parseHeader("contact");"UAS"===r?(this._id={call_id:n.call_id,local_tag:n.to_tag,remote_tag:n.from_tag,toString:function(){return this.call_id+this.local_tag+this.remote_tag}},this._state=s,this._remote_seqnum=n.cseq,this._local_uri=n.parseHeader("to").uri,this._remote_uri=n.parseHeader("from").uri,this._remote_target=a.uri,this._route_set=n.getHeaders("record-route"),this._ack_seqnum=this._remote_seqnum):"UAC"===r&&(this._id={call_id:n.call_id,local_tag:n.from_tag,remote_tag:n.to_tag,toString:function(){return this.call_id+this.local_tag+this.remote_tag}},this._state=s,this._local_seqnum=n.cseq,this._local_uri=n.parseHeader("from").uri,this._remote_uri=n.parseHeader("to").uri,this._remote_target=a.uri,this._route_set=n.getHeaders("record-route").reverse(),this._ack_seqnum=null),this._ua.newDialog(this),u("new "+r+" dialog created with status "+(this._state===c.STATUS_EARLY?"EARLY":"CONFIRMED"))}return r(e,null,[{key:"C",get:function(){return c}}]),r(e,[{key:"update",value:function(e,t){this._state=c.STATUS_CONFIRMED,u("dialog "+this._id.toString()+" changed to CONFIRMED state"),"UAC"===t&&(this._route_set=e.getHeaders("record-route").reverse())}},{key:"terminate",value:function(){u("dialog "+this._id.toString()+" deleted"),this._ua.destroyDialog(this)}},{key:"sendRequest",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=l.cloneArray(n.extraHeaders),i=n.eventHandlers||{},s=n.body||null,a=this._createRequest(e,r,s);return i.onAuthenticated=function(){t._local_seqnum+=1},new o(this,a,i).send(),a}},{key:"receiveRequest",value:function(e){this._checkInDialogRequest(e)&&(e.method===s.ACK&&null!==this._ack_seqnum?this._ack_seqnum=null:e.method===s.INVITE&&(this._ack_seqnum=e.cseq),this._owner.receiveRequest(e))}},{key:"_createRequest",value:function(e,t,n){t=l.cloneArray(t),this._local_seqnum||(this._local_seqnum=Math.floor(1e4*Math.random()));var r=e===s.CANCEL||e===s.ACK?this._local_seqnum:this._local_seqnum+=1;return new i.OutgoingRequest(e,this._remote_target,this._ua,{cseq:r,call_id:this._id.call_id,from_uri:this._local_uri,from_tag:this._id.local_tag,to_uri:this._remote_uri,to_tag:this._id.remote_tag,route_set:this._route_set},t,n)}},{key:"_checkInDialogRequest",value:function(e){var t=this;if(this._remote_seqnum)if(e.cseq<this._remote_seqnum){if(e.method!==s.ACK)return e.reply(500),!1;if(null===this._ack_seqnum||e.cseq!==this._ack_seqnum)return!1}else e.cseq>this._remote_seqnum&&(this._remote_seqnum=e.cseq);else this._remote_seqnum=e.cseq;if(e.method===s.INVITE||e.method===s.UPDATE&&e.body){if(!0===this._uac_pending_reply)e.reply(491);else{if(!0===this._uas_pending_reply){var n=1+(10*Math.random()|0);return e.reply(500,null,["Retry-After:"+n]),!1}this._uas_pending_reply=!0;e.server_transaction.on("stateChanged",function n(){e.server_transaction.state!==a.C.STATUS_ACCEPTED&&e.server_transaction.state!==a.C.STATUS_COMPLETED&&e.server_transaction.state!==a.C.STATUS_TERMINATED||(e.server_transaction.removeListener("stateChanged",n),t._uas_pending_reply=!1)})}e.hasHeader("contact")&&e.server_transaction.on("stateChanged",function(){e.server_transaction.state===a.C.STATUS_ACCEPTED&&(t._remote_target=e.parseHeader("contact").uri)})}else e.method===s.NOTIFY&&e.hasHeader("contact")&&e.server_transaction.on("stateChanged",function(){e.server_transaction.state===a.C.STATUS_COMPLETED&&(t._remote_target=e.parseHeader("contact").uri)});return!0}},{key:"id",get:function(){return this._id}},{key:"local_seqnum",get:function(){return this._local_seqnum},set:function(e){this._local_seqnum=e}},{key:"owner",get:function(){return this._owner}},{key:"uac_pending_reply",get:function(){return this._uac_pending_reply},set:function(e){this._uac_pending_reply=e}},{key:"uas_pending_reply",get:function(){return this._uas_pending_reply}}]),e}()},{"./Constants":5,"./Dialog/RequestSender":7,"./SIPMessage":22,"./Transactions":25,"./Utils":29,debug:2}],7:[function(e,t,n){"use strict";var r=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}();var i=e("../Constants"),s=e("../Transactions"),a=e("../RTCSession"),o=e("../RequestSender"),l={onRequestTimeout:function(){},onTransportError:function(){},onSuccessResponse:function(){},onErrorResponse:function(){},onAuthenticated:function(){},onDialogError:function(){}};t.exports=function(){function e(t,n,r){for(var i in function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this._dialog=t,this._ua=t._ua,this._request=n,this._eventHandlers=r,this._reattempt=!1,this._reattemptTimer=null,l)Object.prototype.hasOwnProperty.call(l,i)&&(this._eventHandlers[i]||(this._eventHandlers[i]=l[i]))}return r(e,[{key:"send",value:function(){var e=this,t=new o(this._ua,this._request,{onRequestTimeout:function(){e._eventHandlers.onRequestTimeout()},onTransportError:function(){e._eventHandlers.onTransportError()},onAuthenticated:function(t){e._eventHandlers.onAuthenticated(t)},onReceiveResponse:function(t){e._receiveResponse(t)}});if(t.send(),(this._request.method===i.INVITE||this._request.method===i.UPDATE&&this._request.body)&&t.clientTransaction.state!==s.C.STATUS_TERMINATED){this._dialog.uac_pending_reply=!0;t.clientTransaction.on("stateChanged",function n(){t.clientTransaction.state!==s.C.STATUS_ACCEPTED&&t.clientTransaction.state!==s.C.STATUS_COMPLETED&&t.clientTransaction.state!==s.C.STATUS_TERMINATED||(t.clientTransaction.removeListener("stateChanged",n),e._dialog.uac_pending_reply=!1)})}}},{key:"_receiveResponse",value:function(e){var t=this;408===e.status_code||481===e.status_code?this._eventHandlers.onDialogError(e):e.method===i.INVITE&&491===e.status_code?this._reattempt?e.status_code>=200&&e.status_code<300?this._eventHandlers.onSuccessResponse(e):e.status_code>=300&&this._eventHandlers.onErrorResponse(e):(this._request.cseq.value=this._dialog.local_seqnum+=1,this._reattemptTimer=setTimeout(function(){t._dialog.owner.status!==a.C.STATUS_TERMINATED&&(t._reattempt=!0,t._request_sender.send())},1e3)):e.status_code>=200&&e.status_code<300?this._eventHandlers.onSuccessResponse(e):e.status_code>=300&&this._eventHandlers.onErrorResponse(e)}},{key:"request",get:function(){return this._request}}]),e}()},{"../Constants":5,"../RTCSession":15,"../RequestSender":21,"../Transactions":25}],8:[function(e,t,n){"use strict";var r=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}();var i=e("./Utils"),s=e("debug")("JsSIP:DigestAuthentication"),a=e("debug")("JsSIP:ERROR:DigestAuthentication");a.log=console.warn.bind(console),t.exports=function(){function e(t){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this._credentials=t,this._cnonce=null,this._nc=0,this._ncHex="00000000",this._algorithm=null,this._realm=null,this._nonce=null,this._opaque=null,this._stale=null,this._qop=null,this._method=null,this._uri=null,this._ha1=null,this._response=null}return r(e,[{key:"get",value:function(e){switch(e){case"realm":return this._realm;case"ha1":return this._ha1;default:return void a('get() | cannot get "%s" parameter',e)}}},{key:"authenticate",value:function(e,t){var n=e.method,r=e.ruri,o=e.body,l=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;if(this._algorithm=t.algorithm,this._realm=t.realm,this._nonce=t.nonce,this._opaque=t.opaque,this._stale=t.stale,this._algorithm){if("MD5"!==this._algorithm)return a('authenticate() | challenge with Digest algorithm different than "MD5", authentication aborted'),!1}else this._algorithm="MD5";if(!this._nonce)return a("authenticate() | challenge without Digest nonce, authentication aborted"),!1;if(!this._realm)return a("authenticate() | challenge without Digest realm, authentication aborted"),!1;if(!this._credentials.password){if(!this._credentials.ha1)return a("authenticate() | no plain SIP password nor ha1 provided, authentication aborted"),!1;if(this._credentials.realm!==this._realm)return a('authenticate() | no plain SIP password, and stored `realm` does not match the given `realm`, cannot authenticate [stored:"%s", given:"%s"]',this._credentials.realm,this._realm),!1}if(t.qop)if(t.qop.indexOf("auth-int")>-1)this._qop="auth-int";else{if(!(t.qop.indexOf("auth")>-1))return a('authenticate() | challenge without Digest qop different than "auth" or "auth-int", authentication aborted'),!1;this._qop="auth"}else this._qop=null;this._method=n,this._uri=r,this._cnonce=l||i.createRandomToken(12),this._nc+=1;var u=Number(this._nc).toString(16);this._ncHex="00000000".substr(0,8-u.length)+u,4294967296===this._nc&&(this._nc=1,this._ncHex="00000001"),this._credentials.password?this._ha1=i.calculateMD5(this._credentials.username+":"+this._realm+":"+this._credentials.password):this._ha1=this._credentials.ha1;var c=void 0;return"auth"===this._qop?(c=i.calculateMD5(this._method+":"+this._uri),this._response=i.calculateMD5(this._ha1+":"+this._nonce+":"+this._ncHex+":"+this._cnonce+":auth:"+c)):"auth-int"===this._qop?(c=i.calculateMD5(this._method+":"+this._uri+":"+i.calculateMD5(o||"")),this._response=i.calculateMD5(this._ha1+":"+this._nonce+":"+this._ncHex+":"+this._cnonce+":auth-int:"+c)):null===this._qop&&(c=i.calculateMD5(this._method+":"+this._uri),this._response=i.calculateMD5(this._ha1+":"+this._nonce+":"+c)),s("authenticate() | response generated"),!0}},{key:"toString",value:function(){var e=[];if(!this._response)throw new Error("response field does not exist, cannot generate Authorization header");return e.push("algorithm="+this._algorithm),e.push('username="'+this._credentials.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}()},{"./Utils":29,debug:2}],9:[function(e,t,n){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function s(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}var a=function(e){function t(e,n){r(this,t);var s=i(this,(t.__proto__||Object.getPrototypeOf(t)).call(this));return s.code=1,s.name="CONFIGURATION_ERROR",s.parameter=e,s.value=n,s.message=s.value?"Invalid value "+JSON.stringify(s.value)+' for parameter "'+s.parameter+'"':"Missing parameter: "+s.parameter,s}return s(t,Error),t}(),o=function(e){function t(e){r(this,t);var n=i(this,(t.__proto__||Object.getPrototypeOf(t)).call(this));return n.code=2,n.name="INVALID_STATE_ERROR",n.status=e,n.message="Invalid status: "+e,n}return s(t,Error),t}(),l=function(e){function t(e){r(this,t);var n=i(this,(t.__proto__||Object.getPrototypeOf(t)).call(this));return n.code=3,n.name="NOT_SUPPORTED_ERROR",n.message=e,n}return s(t,Error),t}(),u=function(e){function t(e){r(this,t);var n=i(this,(t.__proto__||Object.getPrototypeOf(t)).call(this));return n.code=4,n.name="NOT_READY_ERROR",n.message=e,n}return s(t,Error),t}();t.exports={ConfigurationError:a,InvalidStateError:o,NotSupportedError:l,NotReadyError:u}},{}],10:[function(e,t,n){"use strict";t.exports=function(){function t(e){return'"'+e.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\x08/g,"\\b").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\f/g,"\\f").replace(/\r/g,"\\r").replace(/[\x00-\x07\x0B\x0E-\x1F\x80-\uFFFF]/g,escape)+'"'}var n={parse:function(n,r){var i={CRLF:c,DIGIT:d,ALPHA:h,HEXDIG:p,WSP:f,OCTET:m,DQUOTE:_,SP:v,HTAB:g,alphanum:y,reserved:T,unreserved:S,mark:C,escaped:E,LWS:b,SWS:R,HCOLON:w,TEXT_UTF8_TRIM:A,TEXT_UTF8char:I,UTF8_NONASCII:k,UTF8_CONT:P,LHEX:function(){var e;null===(e=d())&&(/^[a-f]/.test(n.charAt(s))?(e=n.charAt(s),s++):(e=null,0===a&&u("[a-f]")));return e},token:O,token_nodot:N,separators:function(){var e;40===n.charCodeAt(s)?(e="(",s++):(e=null,0===a&&u('"("'));null===e&&(41===n.charCodeAt(s)?(e=")",s++):(e=null,0===a&&u('")"')),null===e&&(60===n.charCodeAt(s)?(e="<",s++):(e=null,0===a&&u('"<"')),null===e&&(62===n.charCodeAt(s)?(e=">",s++):(e=null,0===a&&u('">"')),null===e&&(64===n.charCodeAt(s)?(e="@",s++):(e=null,0===a&&u('"@"')),null===e&&(44===n.charCodeAt(s)?(e=",",s++):(e=null,0===a&&u('","')),null===e&&(59===n.charCodeAt(s)?(e=";",s++):(e=null,0===a&&u('";"')),null===e&&(58===n.charCodeAt(s)?(e=":",s++):(e=null,0===a&&u('":"')),null===e&&(92===n.charCodeAt(s)?(e="\\",s++):(e=null,0===a&&u('"\\\\"')),null===e&&null===(e=_())&&(47===n.charCodeAt(s)?(e="/",s++):(e=null,0===a&&u('"/"')),null===e&&(91===n.charCodeAt(s)?(e="[",s++):(e=null,0===a&&u('"["')),null===e&&(93===n.charCodeAt(s)?(e="]",s++):(e=null,0===a&&u('"]"')),null===e&&(63===n.charCodeAt(s)?(e="?",s++):(e=null,0===a&&u('"?"')),null===e&&(61===n.charCodeAt(s)?(e="=",s++):(e=null,0===a&&u('"="')),null===e&&(123===n.charCodeAt(s)?(e="{",s++):(e=null,0===a&&u('"{"')),null===e&&(125===n.charCodeAt(s)?(e="}",s++):(e=null,0===a&&u('"}"')),null===e&&null===(e=v())&&(e=g()))))))))))))))));return e},word:x,STAR:D,SLASH:M,EQUAL:U,LPAREN:L,RPAREN:H,RAQUOT:q,LAQUOT:j,COMMA:F,SEMI:G,COLON:B,LDQUOT:J,RDQUOT:W,comment:function e(){var t,n,r;var i;i=s;t=L();if(null!==t){for(n=[],null===(r=V())&&null===(r=K())&&(r=e());null!==r;)n.push(r),null===(r=V())&&null===(r=K())&&(r=e());null!==n&&null!==(r=H())?t=[t,n,r]:(t=null,s=i)}else t=null,s=i;return t},ctext:V,quoted_string:z,quoted_string_clean:Y,qdtext:$,quoted_pair:K,SIP_URI_noparams:X,SIP_URI:Q,uri_scheme:Z,uri_scheme_sips:ee,uri_scheme_sip:te,userinfo:ne,user:re,user_unreserved:ie,password:se,hostport:ae,host:oe,hostname:le,domainlabel:ue,toplabel:ce,IPv6reference:de,IPv6address:he,h16:pe,ls32:fe,IPv4address:me,dec_octet:_e,port:ve,uri_parameters:ge,uri_parameter:ye,transport_param:Te,user_param:Se,method_param:Ce,ttl_param:Ee,maddr_param:be,lr_param:Re,other_param:we,pname:Ae,pvalue:Ie,paramchar:ke,param_unreserved:Pe,headers:Oe,header:Ne,hname:xe,hvalue:De,hnv_unreserved:Me,Request_Response:function(){var e;null===(e=dt())&&(e=Ue());return e},Request_Line:Ue,Request_URI:Le,absoluteURI:He,hier_part:qe,net_path:je,abs_path:Fe,opaque_part:Ge,uric:Be,uric_no_slash:Je,path_segments:We,segment:Ve,param:ze,pchar:Ye,scheme:$e,authority:Ke,srvr:Xe,reg_name:Qe,query:Ze,SIP_Version:et,INVITEm:tt,ACKm:nt,OPTIONSm:rt,BYEm:it,CANCELm:st,REGISTERm:at,SUBSCRIBEm:ot,NOTIFYm:lt,REFERm:ut,Method:ct,Status_Line:dt,Status_Code:ht,extension_code:pt,Reason_Phrase:ft,Allow_Events:function(){var e,t,n,r,i,a;if(i=s,null!==(e=Ht())){for(t=[],a=s,null!==(n=F())&&null!==(r=Ht())?n=[n,r]:(n=null,s=a);null!==n;)t.push(n),a=s,null!==(n=F())&&null!==(r=Ht())?n=[n,r]:(n=null,s=a);null!==t?e=[e,t]:(e=null,s=i)}else e=null,s=i;return e},Call_ID:function(){var e,t,r,i,o,l;i=s,o=s,null!==(e=x())?(l=s,64===n.charCodeAt(s)?(t="@",s++):(t=null,0===a&&u('"@"')),null!==t&&null!==(r=x())?t=[t,r]:(t=null,s=l),null!==(t=null!==t?t:"")?e=[e,t]:(e=null,s=o)):(e=null,s=o);null!==e&&(c=i,e=void(jn=n.substring(s,c)));var c;null===e&&(s=i);return e},Contact:function(){var e,t,n,r,i,a,o;if(i=s,null===(e=D()))if(a=s,null!==(e=mt())){for(t=[],o=s,null!==(n=F())&&null!==(r=mt())?n=[n,r]:(n=null,s=o);null!==n;)t.push(n),o=s,null!==(n=F())&&null!==(r=mt())?n=[n,r]:(n=null,s=o);null!==t?e=[e,t]:(e=null,s=a)}else e=null,s=a;null!==e&&(e=function(e){var t,n;for(n=jn.multi_header.length,t=0;t<n;t++)if(null===jn.multi_header[t].parsed){jn=null;break}jn=null!==jn?jn.multi_header:-1}());null===e&&(s=i);return e},contact_param:mt,name_addr:_t,display_name:vt,contact_params:gt,c_p_q:yt,c_p_expires:Tt,delta_seconds:St,qvalue:Ct,generic_param:Et,gen_value:bt,Content_Disposition:function(){var e,t,n,r,i,a;if(i=s,null!==(e=Rt())){for(t=[],a=s,null!==(n=G())&&null!==(r=wt())?n=[n,r]:(n=null,s=a);null!==n;)t.push(n),a=s,null!==(n=G())&&null!==(r=wt())?n=[n,r]:(n=null,s=a);null!==t?e=[e,t]:(e=null,s=i)}else e=null,s=i;return e},disp_type:Rt,disp_param:wt,handling_param:At,Content_Encoding:function(){var e,t,n,r,i,a;if(i=s,null!==(e=O())){for(t=[],a=s,null!==(n=F())&&null!==(r=O())?n=[n,r]:(n=null,s=a);null!==n;)t.push(n),a=s,null!==(n=F())&&null!==(r=O())?n=[n,r]:(n=null,s=a);null!==t?e=[e,t]:(e=null,s=i)}else e=null,s=i;return e},Content_Length:function(){var e,t,n;if(n=s,null!==(t=d()))for(e=[];null!==t;)e.push(t),t=d();else e=null;null!==e&&(e=void(jn=parseInt(e.join(""))));null===e&&(s=n);return e},Content_Type:function(){var e,t;t=s,null!==(e=It())&&(r=t,e=void(jn=n.substring(s,r)));var r;null===e&&(s=t);return e},media_type:It,m_type:kt,discrete_type:Pt,composite_type:Ot,extension_token:Nt,x_token:xt,m_subtype:Dt,m_parameter:Mt,m_value:Ut,CSeq:function(){var e,t,n,r;r=s,null!==(e=Lt())&&null!==(t=b())&&null!==(n=ct())?e=[e,t,n]:(e=null,s=r);return e},CSeq_value:Lt,Expires:function(){var e,t;t=s,null!==(e=St())&&(e=void(jn=e));null===e&&(s=t);return e},Event:function(){var e,t,n,r,i,a,o;if(i=s,a=s,null!==(e=Ht())){for(t=[],o=s,null!==(n=G())&&null!==(r=Et())?n=[n,r]:(n=null,s=o);null!==n;)t.push(n),o=s,null!==(n=G())&&null!==(r=Et())?n=[n,r]:(n=null,s=o);null!==t?e=[e,t]:(e=null,s=a)}else e=null,s=a;null!==e&&(l=e[0],e=void(jn.event=l.join("").toLowerCase()));var l;null===e&&(s=i);return e},event_type:Ht,From:function(){var e,t,n,r,i,a,o;i=s,a=s,null===(e=X())&&(e=_t());if(null!==e){for(t=[],o=s,null!==(n=G())&&null!==(r=qt())?n=[n,r]:(n=null,s=o);null!==n;)t.push(n),o=s,null!==(n=G())&&null!==(r=qt())?n=[n,r]:(n=null,s=o);null!==t?e=[e,t]:(e=null,s=a)}else e=null,s=a;null!==e&&(e=function(e){var t=jn.tag;try{jn=new qn(jn.uri,jn.display_name,jn.params),t&&jn.setParam("tag",t)}catch(e){jn=-1}}());null===e&&(s=i);return e},from_param:qt,tag_param:jt,Max_Forwards:function(){var e,t,n;if(n=s,null!==(t=d()))for(e=[];null!==t;)e.push(t),t=d();else e=null;null!==e&&(e=void(jn=parseInt(e.join(""))));null===e&&(s=n);return e},Min_Expires:function(){var e,t;t=s,null!==(e=St())&&(e=void(jn=e));null===e&&(s=t);return e},Name_Addr_Header:function(){var e,t,n,r,i,a,o,l,u,c;l=s,u=s,e=[],t=vt();for(;null!==t;)e.push(t),t=vt();if(null!==e)if(null!==(t=j()))if(null!==(n=Q()))if(null!==(r=q())){for(i=[],c=s,null!==(a=G())&&null!==(o=Et())?a=[a,o]:(a=null,s=c);null!==a;)i.push(a),c=s,null!==(a=G())&&null!==(o=Et())?a=[a,o]:(a=null,s=c);null!==i?e=[e,t,n,r,i]:(e=null,s=u)}else e=null,s=u;else e=null,s=u;else e=null,s=u;else e=null,s=u;null!==e&&(e=function(e){try{jn=new qn(jn.uri,jn.display_name,jn.params)}catch(e){jn=-1}}());null===e&&(s=l);return e},Proxy_Authenticate:function(){return Ft()},challenge:Ft,other_challenge:Gt,auth_param:Bt,digest_cln:Jt,realm:Wt,realm_value:Vt,domain:zt,URI:Yt,nonce:$t,nonce_value:Kt,opaque:Xt,stale:Qt,algorithm:Zt,qop_options:en,qop_value:tn,Proxy_Require:function(){var e,t,n,r,i,a;if(i=s,null!==(e=O())){for(t=[],a=s,null!==(n=F())&&null!==(r=O())?n=[n,r]:(n=null,s=a);null!==n;)t.push(n),a=s,null!==(n=F())&&null!==(r=O())?n=[n,r]:(n=null,s=a);null!==t?e=[e,t]:(e=null,s=i)}else e=null,s=i;return e},Record_Route:function(){var e,t,n,r,i,a,o;if(i=s,a=s,null!==(e=nn())){for(t=[],o=s,null!==(n=F())&&null!==(r=nn())?n=[n,r]:(n=null,s=o);null!==n;)t.push(n),o=s,null!==(n=F())&&null!==(r=nn())?n=[n,r]:(n=null,s=o);null!==t?e=[e,t]:(e=null,s=a)}else e=null,s=a;null!==e&&(e=function(e){var t,n;for(n=jn.multi_header.length,t=0;t<n;t++)if(null===jn.multi_header[t].parsed){jn=null;break}jn=null!==jn?jn.multi_header:-1}());null===e&&(s=i);return e},rec_route:nn,Reason:function(){var e,t,r,i,o,l,c;o=s,l=s,"sip"===n.substr(s,3).toLowerCase()?(e=n.substr(s,3),s+=3):(e=null,0===a&&u('"SIP"'));null===e&&(e=O());if(null!==e){for(t=[],c=s,null!==(r=G())&&null!==(i=rn())?r=[r,i]:(r=null,s=c);null!==r;)t.push(r),c=s,null!==(r=G())&&null!==(i=rn())?r=[r,i]:(r=null,s=c);null!==t?e=[e,t]:(e=null,s=l)}else e=null,s=l;null!==e&&(e=function(e,t){if(jn.protocol=t.toLowerCase(),jn.params||(jn.params={}),jn.params.text&&'"'===jn.params.text[0]){var n=jn.params.text;jn.text=n.substring(1,n.length-1),delete jn.params.text}}(0,e[0]));null===e&&(s=o);return e},reason_param:rn,reason_cause:sn,Require:function(){var e,t,n,r,i,a;if(i=s,null!==(e=O())){for(t=[],a=s,null!==(n=F())&&null!==(r=O())?n=[n,r]:(n=null,s=a);null!==n;)t.push(n),a=s,null!==(n=F())&&null!==(r=O())?n=[n,r]:(n=null,s=a);null!==t?e=[e,t]:(e=null,s=i)}else e=null,s=i;return e},Route:function(){var e,t,n,r,i,a;if(i=s,null!==(e=an())){for(t=[],a=s,null!==(n=F())&&null!==(r=an())?n=[n,r]:(n=null,s=a);null!==n;)t.push(n),a=s,null!==(n=F())&&null!==(r=an())?n=[n,r]:(n=null,s=a);null!==t?e=[e,t]:(e=null,s=i)}else e=null,s=i;return e},route_param:an,Subscription_State:function(){var e,t,n,r,i,a;if(i=s,null!==(e=on())){for(t=[],a=s,null!==(n=G())&&null!==(r=ln())?n=[n,r]:(n=null,s=a);null!==n;)t.push(n),a=s,null!==(n=G())&&null!==(r=ln())?n=[n,r]:(n=null,s=a);null!==t?e=[e,t]:(e=null,s=i)}else e=null,s=i;return e},substate_value:on,subexp_params:ln,event_reason_value:un,Subject:function(){var e;return e=null!==(e=A())?e:""},Supported:function(){var e,t,n,r,i,a;if(i=s,null!==(e=O())){for(t=[],a=s,null!==(n=F())&&null!==(r=O())?n=[n,r]:(n=null,s=a);null!==n;)t.push(n),a=s,null!==(n=F())&&null!==(r=O())?n=[n,r]:(n=null,s=a);null!==t?e=[e,t]:(e=null,s=i)}else e=null,s=i;return e=null!==e?e:""},To:function(){var e,t,n,r,i,a,o;i=s,a=s,null===(e=X())&&(e=_t());if(null!==e){for(t=[],o=s,null!==(n=G())&&null!==(r=cn())?n=[n,r]:(n=null,s=o);null!==n;)t.push(n),o=s,null!==(n=G())&&null!==(r=cn())?n=[n,r]:(n=null,s=o);null!==t?e=[e,t]:(e=null,s=a)}else e=null,s=a;null!==e&&(e=function(e){var t=jn.tag;try{jn=new qn(jn.uri,jn.display_name,jn.params),t&&jn.setParam("tag",t)}catch(e){jn=-1}}());null===e&&(s=i);return e},to_param:cn,Via:function(){var e,t,n,r,i,a;if(i=s,null!==(e=dn())){for(t=[],a=s,null!==(n=F())&&null!==(r=dn())?n=[n,r]:(n=null,s=a);null!==n;)t.push(n),a=s,null!==(n=F())&&null!==(r=dn())?n=[n,r]:(n=null,s=a);null!==t?e=[e,t]:(e=null,s=i)}else e=null,s=i;return e},via_param:dn,via_params:hn,via_ttl:pn,via_maddr:fn,via_received:mn,via_branch:_n,response_port:vn,sent_protocol:gn,protocol_name:yn,transport:Tn,sent_by:Sn,via_host:Cn,via_port:En,ttl:bn,WWW_Authenticate:function(){return Ft()},Session_Expires:function(){var e,t,n,r,i,a;if(i=s,null!==(e=Rn())){for(t=[],a=s,null!==(n=G())&&null!==(r=wn())?n=[n,r]:(n=null,s=a);null!==n;)t.push(n),a=s,null!==(n=G())&&null!==(r=wn())?n=[n,r]:(n=null,s=a);null!==t?e=[e,t]:(e=null,s=i)}else e=null,s=i;return e},s_e_expires:Rn,s_e_params:wn,s_e_refresher:An,extension_header:function(){var e,t,n,r;r=s,null!==(e=O())&&null!==(t=w())&&null!==(n=In())?e=[e,t,n]:(e=null,s=r);return e},header_value:In,message_body:function(){var e,t;e=[],t=m();for(;null!==t;)e.push(t),t=m();return e},uuid_URI:function(){var e,t,r;r=s,"uuid:"===n.substr(s,5)?(e="uuid:",s+=5):(e=null,0===a&&u('"uuid:"'));null!==e&&null!==(t=kn())?e=[e,t]:(e=null,s=r);return e},uuid:kn,hex4:Pn,hex8:On,hex12:Nn,Refer_To:function(){var e,t,n,r,i,a,o;i=s,a=s,null===(e=X())&&(e=_t());if(null!==e){for(t=[],o=s,null!==(n=G())&&null!==(r=Et())?n=[n,r]:(n=null,s=o);null!==n;)t.push(n),o=s,null!==(n=G())&&null!==(r=Et())?n=[n,r]:(n=null,s=o);null!==t?e=[e,t]:(e=null,s=a)}else e=null,s=a;null!==e&&(e=function(e){try{jn=new qn(jn.uri,jn.display_name,jn.params)}catch(e){jn=-1}}());null===e&&(s=i);return e},Replaces:function(){var e,t,n,r,i,a;if(i=s,null!==(e=xn())){for(t=[],a=s,null!==(n=G())&&null!==(r=Dn())?n=[n,r]:(n=null,s=a);null!==n;)t.push(n),a=s,null!==(n=G())&&null!==(r=Dn())?n=[n,r]:(n=null,s=a);null!==t?e=[e,t]:(e=null,s=i)}else e=null,s=i;return e},call_id:xn,replaces_param:Dn,to_tag:Mn,from_tag:Un,early_flag:Ln};if(void 0!==r){if(void 0===i[r])throw new Error("Invalid rule name: "+t(r)+".")}else r="CRLF";var s=0,a=0,o=0,l=[];function u(e){s<o||(s>o&&(o=s,l=[]),l.push(e))}function c(){var e;return"\r\n"===n.substr(s,2)?(e="\r\n",s+=2):(e=null,0===a&&u('"\\r\\n"')),e}function d(){var e;return/^[0-9]/.test(n.charAt(s))?(e=n.charAt(s),s++):(e=null,0===a&&u("[0-9]")),e}function h(){var e;return/^[a-zA-Z]/.test(n.charAt(s))?(e=n.charAt(s),s++):(e=null,0===a&&u("[a-zA-Z]")),e}function p(){var e;return/^[0-9a-fA-F]/.test(n.charAt(s))?(e=n.charAt(s),s++):(e=null,0===a&&u("[0-9a-fA-F]")),e}function f(){var e;return null===(e=v())&&(e=g()),e}function m(){var e;return/^[\0-\xFF]/.test(n.charAt(s))?(e=n.charAt(s),s++):(e=null,0===a&&u("[\\0-\\xFF]")),e}function _(){var e;return/^["]/.test(n.charAt(s))?(e=n.charAt(s),s++):(e=null,0===a&&u('["]')),e}function v(){var e;return 32===n.charCodeAt(s)?(e=" ",s++):(e=null,0===a&&u('" "')),e}function g(){var e;return 9===n.charCodeAt(s)?(e="\t",s++):(e=null,0===a&&u('"\\t"')),e}function y(){var e;return/^[a-zA-Z0-9]/.test(n.charAt(s))?(e=n.charAt(s),s++):(e=null,0===a&&u("[a-zA-Z0-9]")),e}function T(){var e;return 59===n.charCodeAt(s)?(e=";",s++):(e=null,0===a&&u('";"')),null===e&&(47===n.charCodeAt(s)?(e="/",s++):(e=null,0===a&&u('"/"')),null===e&&(63===n.charCodeAt(s)?(e="?",s++):(e=null,0===a&&u('"?"')),null===e&&(58===n.charCodeAt(s)?(e=":",s++):(e=null,0===a&&u('":"')),null===e&&(64===n.charCodeAt(s)?(e="@",s++):(e=null,0===a&&u('"@"')),null===e&&(38===n.charCodeAt(s)?(e="&",s++):(e=null,0===a&&u('"&"')),null===e&&(61===n.charCodeAt(s)?(e="=",s++):(e=null,0===a&&u('"="')),null===e&&(43===n.charCodeAt(s)?(e="+",s++):(e=null,0===a&&u('"+"')),null===e&&(36===n.charCodeAt(s)?(e="$",s++):(e=null,0===a&&u('"$"')),null===e&&(44===n.charCodeAt(s)?(e=",",s++):(e=null,0===a&&u('","'))))))))))),e}function S(){var e;return null===(e=y())&&(e=C()),e}function C(){var e;return 45===n.charCodeAt(s)?(e="-",s++):(e=null,0===a&&u('"-"')),null===e&&(95===n.charCodeAt(s)?(e="_",s++):(e=null,0===a&&u('"_"')),null===e&&(46===n.charCodeAt(s)?(e=".",s++):(e=null,0===a&&u('"."')),null===e&&(33===n.charCodeAt(s)?(e="!",s++):(e=null,0===a&&u('"!"')),null===e&&(126===n.charCodeAt(s)?(e="~",s++):(e=null,0===a&&u('"~"')),null===e&&(42===n.charCodeAt(s)?(e="*",s++):(e=null,0===a&&u('"*"')),null===e&&(39===n.charCodeAt(s)?(e="'",s++):(e=null,0===a&&u('"\'"')),null===e&&(40===n.charCodeAt(s)?(e="(",s++):(e=null,0===a&&u('"("')),null===e&&(41===n.charCodeAt(s)?(e=")",s++):(e=null,0===a&&u('")"')))))))))),e}function E(){var e,t,r,i,o;return i=s,o=s,37===n.charCodeAt(s)?(e="%",s++):(e=null,0===a&&u('"%"')),null!==e&&null!==(t=p())&&null!==(r=p())?e=[e,t,r]:(e=null,s=o),null!==e&&(e=e.join("")),null===e&&(s=i),e}function b(){var e,t,n,r,i,a;for(r=s,i=s,a=s,e=[],t=f();null!==t;)e.push(t),t=f();if(null!==e&&null!==(t=c())?e=[e,t]:(e=null,s=a),null!==(e=null!==e?e:"")){if(null!==(n=f()))for(t=[];null!==n;)t.push(n),n=f();else t=null;null!==t?e=[e,t]:(e=null,s=i)}else e=null,s=i;return null!==e&&(e=" "),null===e&&(s=r),e}function R(){var e;return e=null!==(e=b())?e:""}function w(){var e,t,r,i,o;for(i=s,o=s,e=[],null===(t=v())&&(t=g());null!==t;)e.push(t),null===(t=v())&&(t=g());return null!==e?(58===n.charCodeAt(s)?(t=":",s++):(t=null,0===a&&u('":"')),null!==t&&null!==(r=R())?e=[e,t,r]:(e=null,s=o)):(e=null,s=o),null!==e&&(e=":"),null===e&&(s=i),e}function A(){var e,t,r,i,a,o,l,u;if(a=s,o=s,null!==(t=I()))for(e=[];null!==t;)e.push(t),t=I();else e=null;if(null!==e){for(t=[],l=s,r=[],i=b();null!==i;)r.push(i),i=b();for(null!==r&&null!==(i=I())?r=[r,i]:(r=null,s=l);null!==r;){for(t.push(r),l=s,r=[],i=b();null!==i;)r.push(i),i=b();null!==r&&null!==(i=I())?r=[r,i]:(r=null,s=l)}null!==t?e=[e,t]:(e=null,s=o)}else e=null,s=o;return null!==e&&(u=a,e=n.substring(s,u)),null===e&&(s=a),e}function I(){var e;return/^[!-~]/.test(n.charAt(s))?(e=n.charAt(s),s++):(e=null,0===a&&u("[!-~]")),null===e&&(e=k()),e}function k(){var e;return/^[\x80-\uFFFF]/.test(n.charAt(s))?(e=n.charAt(s),s++):(e=null,0===a&&u("[\\x80-\\uFFFF]")),e}function P(){var e;return/^[\x80-\xBF]/.test(n.charAt(s))?(e=n.charAt(s),s++):(e=null,0===a&&u("[\\x80-\\xBF]")),e}function O(){var e,t,r,i;if(r=s,null===(t=y())&&(45===n.charCodeAt(s)?(t="-",s++):(t=null,0===a&&u('"-"')),null===t&&(46===n.charCodeAt(s)?(t=".",s++):(t=null,0===a&&u('"."')),null===t&&(33===n.charCodeAt(s)?(t="!",s++):(t=null,0===a&&u('"!"')),null===t&&(37===n.charCodeAt(s)?(t="%",s++):(t=null,0===a&&u('"%"')),null===t&&(42===n.charCodeAt(s)?(t="*",s++):(t=null,0===a&&u('"*"')),null===t&&(95===n.charCodeAt(s)?(t="_",s++):(t=null,0===a&&u('"_"')),null===t&&(43===n.charCodeAt(s)?(t="+",s++):(t=null,0===a&&u('"+"')),null===t&&(96===n.charCodeAt(s)?(t="`",s++):(t=null,0===a&&u('"`"')),null===t&&(39===n.charCodeAt(s)?(t="'",s++):(t=null,0===a&&u('"\'"')),null===t&&(126===n.charCodeAt(s)?(t="~",s++):(t=null,0===a&&u('"~"')))))))))))),null!==t)for(e=[];null!==t;)e.push(t),null===(t=y())&&(45===n.charCodeAt(s)?(t="-",s++):(t=null,0===a&&u('"-"')),null===t&&(46===n.charCodeAt(s)?(t=".",s++):(t=null,0===a&&u('"."')),null===t&&(33===n.charCodeAt(s)?(t="!",s++):(t=null,0===a&&u('"!"')),null===t&&(37===n.charCodeAt(s)?(t="%",s++):(t=null,0===a&&u('"%"')),null===t&&(42===n.charCodeAt(s)?(t="*",s++):(t=null,0===a&&u('"*"')),null===t&&(95===n.charCodeAt(s)?(t="_",s++):(t=null,0===a&&u('"_"')),null===t&&(43===n.charCodeAt(s)?(t="+",s++):(t=null,0===a&&u('"+"')),null===t&&(96===n.charCodeAt(s)?(t="`",s++):(t=null,0===a&&u('"`"')),null===t&&(39===n.charCodeAt(s)?(t="'",s++):(t=null,0===a&&u('"\'"')),null===t&&(126===n.charCodeAt(s)?(t="~",s++):(t=null,0===a&&u('"~"'))))))))))));else e=null;return null!==e&&(i=r,e=n.substring(s,i)),null===e&&(s=r),e}function N(){var e,t,r,i;if(r=s,null===(t=y())&&(45===n.charCodeAt(s)?(t="-",s++):(t=null,0===a&&u('"-"')),null===t&&(33===n.charCodeAt(s)?(t="!",s++):(t=null,0===a&&u('"!"')),null===t&&(37===n.charCodeAt(s)?(t="%",s++):(t=null,0===a&&u('"%"')),null===t&&(42===n.charCodeAt(s)?(t="*",s++):(t=null,0===a&&u('"*"')),null===t&&(95===n.charCodeAt(s)?(t="_",s++):(t=null,0===a&&u('"_"')),null===t&&(43===n.charCodeAt(s)?(t="+",s++):(t=null,0===a&&u('"+"')),null===t&&(96===n.charCodeAt(s)?(t="`",s++):(t=null,0===a&&u('"`"')),null===t&&(39===n.charCodeAt(s)?(t="'",s++):(t=null,0===a&&u('"\'"')),null===t&&(126===n.charCodeAt(s)?(t="~",s++):(t=null,0===a&&u('"~"'))))))))))),null!==t)for(e=[];null!==t;)e.push(t),null===(t=y())&&(45===n.charCodeAt(s)?(t="-",s++):(t=null,0===a&&u('"-"')),null===t&&(33===n.charCodeAt(s)?(t="!",s++):(t=null,0===a&&u('"!"')),null===t&&(37===n.charCodeAt(s)?(t="%",s++):(t=null,0===a&&u('"%"')),null===t&&(42===n.charCodeAt(s)?(t="*",s++):(t=null,0===a&&u('"*"')),null===t&&(95===n.charCodeAt(s)?(t="_",s++):(t=null,0===a&&u('"_"')),null===t&&(43===n.charCodeAt(s)?(t="+",s++):(t=null,0===a&&u('"+"')),null===t&&(96===n.charCodeAt(s)?(t="`",s++):(t=null,0===a&&u('"`"')),null===t&&(39===n.charCodeAt(s)?(t="'",s++):(t=null,0===a&&u('"\'"')),null===t&&(126===n.charCodeAt(s)?(t="~",s++):(t=null,0===a&&u('"~"')))))))))));else e=null;return null!==e&&(i=r,e=n.substring(s,i)),null===e&&(s=r),e}function x(){var e,t,r,i;if(r=s,null===(t=y())&&(45===n.charCodeAt(s)?(t="-",s++):(t=null,0===a&&u('"-"')),null===t&&(46===n.charCodeAt(s)?(t=".",s++):(t=null,0===a&&u('"."')),null===t&&(33===n.charCodeAt(s)?(t="!",s++):(t=null,0===a&&u('"!"')),null===t&&(37===n.charCodeAt(s)?(t="%",s++):(t=null,0===a&&u('"%"')),null===t&&(42===n.charCodeAt(s)?(t="*",s++):(t=null,0===a&&u('"*"')),null===t&&(95===n.charCodeAt(s)?(t="_",s++):(t=null,0===a&&u('"_"')),null===t&&(43===n.charCodeAt(s)?(t="+",s++):(t=null,0===a&&u('"+"')),null===t&&(96===n.charCodeAt(s)?(t="`",s++):(t=null,0===a&&u('"`"')),null===t&&(39===n.charCodeAt(s)?(t="'",s++):(t=null,0===a&&u('"\'"')),null===t&&(126===n.charCodeAt(s)?(t="~",s++):(t=null,0===a&&u('"~"')),null===t&&(40===n.charCodeAt(s)?(t="(",s++):(t=null,0===a&&u('"("')),null===t&&(41===n.charCodeAt(s)?(t=")",s++):(t=null,0===a&&u('")"')),null===t&&(60===n.charCodeAt(s)?(t="<",s++):(t=null,0===a&&u('"<"')),null===t&&(62===n.charCodeAt(s)?(t=">",s++):(t=null,0===a&&u('">"')),null===t&&(58===n.charCodeAt(s)?(t=":",s++):(t=null,0===a&&u('":"')),null===t&&(92===n.charCodeAt(s)?(t="\\",s++):(t=null,0===a&&u('"\\\\"')),null===t&&null===(t=_())&&(47===n.charCodeAt(s)?(t="/",s++):(t=null,0===a&&u('"/"')),null===t&&(91===n.charCodeAt(s)?(t="[",s++):(t=null,0===a&&u('"["')),null===t&&(93===n.charCodeAt(s)?(t="]",s++):(t=null,0===a&&u('"]"')),null===t&&(63===n.charCodeAt(s)?(t="?",s++):(t=null,0===a&&u('"?"')),null===t&&(123===n.charCodeAt(s)?(t="{",s++):(t=null,0===a&&u('"{"')),null===t&&(125===n.charCodeAt(s)?(t="}",s++):(t=null,0===a&&u('"}"')))))))))))))))))))))))),null!==t)for(e=[];null!==t;)e.push(t),null===(t=y())&&(45===n.charCodeAt(s)?(t="-",s++):(t=null,0===a&&u('"-"')),null===t&&(46===n.charCodeAt(s)?(t=".",s++):(t=null,0===a&&u('"."')),null===t&&(33===n.charCodeAt(s)?(t="!",s++):(t=null,0===a&&u('"!"')),null===t&&(37===n.charCodeAt(s)?(t="%",s++):(t=null,0===a&&u('"%"')),null===t&&(42===n.charCodeAt(s)?(t="*",s++):(t=null,0===a&&u('"*"')),null===t&&(95===n.charCodeAt(s)?(t="_",s++):(t=null,0===a&&u('"_"')),null===t&&(43===n.charCodeAt(s)?(t="+",s++):(t=null,0===a&&u('"+"')),null===t&&(96===n.charCodeAt(s)?(t="`",s++):(t=null,0===a&&u('"`"')),null===t&&(39===n.charCodeAt(s)?(t="'",s++):(t=null,0===a&&u('"\'"')),null===t&&(126===n.charCodeAt(s)?(t="~",s++):(t=null,0===a&&u('"~"')),null===t&&(40===n.charCodeAt(s)?(t="(",s++):(t=null,0===a&&u('"("')),null===t&&(41===n.charCodeAt(s)?(t=")",s++):(t=null,0===a&&u('")"')),null===t&&(60===n.charCodeAt(s)?(t="<",s++):(t=null,0===a&&u('"<"')),null===t&&(62===n.charCodeAt(s)?(t=">",s++):(t=null,0===a&&u('">"')),null===t&&(58===n.charCodeAt(s)?(t=":",s++):(t=null,0===a&&u('":"')),null===t&&(92===n.charCodeAt(s)?(t="\\",s++):(t=null,0===a&&u('"\\\\"')),null===t&&null===(t=_())&&(47===n.charCodeAt(s)?(t="/",s++):(t=null,0===a&&u('"/"')),null===t&&(91===n.charCodeAt(s)?(t="[",s++):(t=null,0===a&&u('"["')),null===t&&(93===n.charCodeAt(s)?(t="]",s++):(t=null,0===a&&u('"]"')),null===t&&(63===n.charCodeAt(s)?(t="?",s++):(t=null,0===a&&u('"?"')),null===t&&(123===n.charCodeAt(s)?(t="{",s++):(t=null,0===a&&u('"{"')),null===t&&(125===n.charCodeAt(s)?(t="}",s++):(t=null,0===a&&u('"}"'))))))))))))))))))))))));else e=null;return null!==e&&(i=r,e=n.substring(s,i)),null===e&&(s=r),e}function D(){var e,t,r,i,o;return i=s,o=s,null!==(e=R())?(42===n.charCodeAt(s)?(t="*",s++):(t=null,0===a&&u('"*"')),null!==t&&null!==(r=R())?e=[e,t,r]:(e=null,s=o)):(e=null,s=o),null!==e&&(e="*"),null===e&&(s=i),e}function M(){var e,t,r,i,o;return i=s,o=s,null!==(e=R())?(47===n.charCodeAt(s)?(t="/",s++):(t=null,0===a&&u('"/"')),null!==t&&null!==(r=R())?e=[e,t,r]:(e=null,s=o)):(e=null,s=o),null!==e&&(e="/"),null===e&&(s=i),e}function U(){var e,t,r,i,o;return i=s,o=s,null!==(e=R())?(61===n.charCodeAt(s)?(t="=",s++):(t=null,0===a&&u('"="')),null!==t&&null!==(r=R())?e=[e,t,r]:(e=null,s=o)):(e=null,s=o),null!==e&&(e="="),null===e&&(s=i),e}function L(){var e,t,r,i,o;return i=s,o=s,null!==(e=R())?(40===n.charCodeAt(s)?(t="(",s++):(t=null,0===a&&u('"("')),null!==t&&null!==(r=R())?e=[e,t,r]:(e=null,s=o)):(e=null,s=o),null!==e&&(e="("),null===e&&(s=i),e}function H(){var e,t,r,i,o;return i=s,o=s,null!==(e=R())?(41===n.charCodeAt(s)?(t=")",s++):(t=null,0===a&&u('")"')),null!==t&&null!==(r=R())?e=[e,t,r]:(e=null,s=o)):(e=null,s=o),null!==e&&(e=")"),null===e&&(s=i),e}function q(){var e,t,r,i;return r=s,i=s,62===n.charCodeAt(s)?(e=">",s++):(e=null,0===a&&u('">"')),null!==e&&null!==(t=R())?e=[e,t]:(e=null,s=i),null!==e&&(e=">"),null===e&&(s=r),e}function j(){var e,t,r,i;return r=s,i=s,null!==(e=R())?(60===n.charCodeAt(s)?(t="<",s++):(t=null,0===a&&u('"<"')),null!==t?e=[e,t]:(e=null,s=i)):(e=null,s=i),null!==e&&(e="<"),null===e&&(s=r),e}function F(){var e,t,r,i,o;return i=s,o=s,null!==(e=R())?(44===n.charCodeAt(s)?(t=",",s++):(t=null,0===a&&u('","')),null!==t&&null!==(r=R())?e=[e,t,r]:(e=null,s=o)):(e=null,s=o),null!==e&&(e=","),null===e&&(s=i),e}function G(){var e,t,r,i,o;return i=s,o=s,null!==(e=R())?(59===n.charCodeAt(s)?(t=";",s++):(t=null,0===a&&u('";"')),null!==t&&null!==(r=R())?e=[e,t,r]:(e=null,s=o)):(e=null,s=o),null!==e&&(e=";"),null===e&&(s=i),e}function B(){var e,t,r,i,o;return i=s,o=s,null!==(e=R())?(58===n.charCodeAt(s)?(t=":",s++):(t=null,0===a&&u('":"')),null!==t&&null!==(r=R())?e=[e,t,r]:(e=null,s=o)):(e=null,s=o),null!==e&&(e=":"),null===e&&(s=i),e}function J(){var e,t,n,r;return n=s,r=s,null!==(e=R())&&null!==(t=_())?e=[e,t]:(e=null,s=r),null!==e&&(e='"'),null===e&&(s=n),e}function W(){var e,t,n,r;return n=s,r=s,null!==(e=_())&&null!==(t=R())?e=[e,t]:(e=null,s=r),null!==e&&(e='"'),null===e&&(s=n),e}function V(){var e;return/^[!-']/.test(n.charAt(s))?(e=n.charAt(s),s++):(e=null,0===a&&u("[!-']")),null===e&&(/^[*-[]/.test(n.charAt(s))?(e=n.charAt(s),s++):(e=null,0===a&&u("[*-[]")),null===e&&(/^[\]-~]/.test(n.charAt(s))?(e=n.charAt(s),s++):(e=null,0===a&&u("[\\]-~]")),null===e&&null===(e=k())&&(e=b()))),e}function z(){var e,t,r,i,a,o,l;if(a=s,o=s,null!==(e=R()))if(null!==(t=_())){for(r=[],null===(i=$())&&(i=K());null!==i;)r.push(i),null===(i=$())&&(i=K());null!==r&&null!==(i=_())?e=[e,t,r,i]:(e=null,s=o)}else e=null,s=o;else e=null,s=o;return null!==e&&(l=a,e=n.substring(s,l)),null===e&&(s=a),e}function Y(){var e,t,r,i,a,o,l;if(a=s,o=s,null!==(e=R()))if(null!==(t=_())){for(r=[],null===(i=$())&&(i=K());null!==i;)r.push(i),null===(i=$())&&(i=K());null!==r&&null!==(i=_())?e=[e,t,r,i]:(e=null,s=o)}else e=null,s=o;else e=null,s=o;return null!==e&&(l=a,e=n.substring(s-1,l+1)),null===e&&(s=a),e}function $(){var e;return null===(e=b())&&(33===n.charCodeAt(s)?(e="!",s++):(e=null,0===a&&u('"!"')),null===e&&(/^[#-[]/.test(n.charAt(s))?(e=n.charAt(s),s++):(e=null,0===a&&u("[#-[]")),null===e&&(/^[\]-~]/.test(n.charAt(s))?(e=n.charAt(s),s++):(e=null,0===a&&u("[\\]-~]")),null===e&&(e=k())))),e}function K(){var e,t,r;return r=s,92===n.charCodeAt(s)?(e="\\",s++):(e=null,0===a&&u('"\\\\"')),null!==e?(/^[\0-\t]/.test(n.charAt(s))?(t=n.charAt(s),s++):(t=null,0===a&&u("[\\0-\\t]")),null===t&&(/^[\x0B-\f]/.test(n.charAt(s))?(t=n.charAt(s),s++):(t=null,0===a&&u("[\\x0B-\\f]")),null===t&&(/^[\x0E-]/.test(n.charAt(s))?(t=n.charAt(s),s++):(t=null,0===a&&u("[\\x0E-]")))),null!==t?e=[e,t]:(e=null,s=r)):(e=null,s=r),e}function X(){var e,t,r,i,o,l;return o=s,l=s,null!==(e=Z())?(58===n.charCodeAt(s)?(t=":",s++):(t=null,0===a&&u('":"')),null!==t&&null!==(r=null!==(r=ne())?r:"")&&null!==(i=ae())?e=[e,t,r,i]:(e=null,s=l)):(e=null,s=l),null!==e&&(e=function(e){try{jn.uri=new Hn(jn.scheme,jn.user,jn.host,jn.port),delete jn.scheme,delete jn.user,delete jn.host,delete jn.host_type,delete jn.port}catch(e){jn=-1}}()),null===e&&(s=o),e}function Q(){var e,t,i,o,l,c,d,h;return d=s,h=s,null!==(e=Z())?(58===n.charCodeAt(s)?(t=":",s++):(t=null,0===a&&u('":"')),null!==t&&null!==(i=null!==(i=ne())?i:"")&&null!==(o=ae())&&null!==(l=ge())&&null!==(c=null!==(c=Oe())?c:"")?e=[e,t,i,o,l,c]:(e=null,s=h)):(e=null,s=h),null!==e&&(e=function(e){try{jn.uri=new Hn(jn.scheme,jn.user,jn.host,jn.port,jn.uri_params,jn.uri_headers),delete jn.scheme,delete jn.user,delete jn.host,delete jn.host_type,delete jn.port,delete jn.uri_params,"SIP_URI"===r&&(jn=jn.uri)}catch(e){jn=-1}}()),null===e&&(s=d),e}function Z(){var e;return null===(e=ee())&&(e=te()),e}function ee(){var e,t,r;return t=s,"sips"===n.substr(s,4).toLowerCase()?(e=n.substr(s,4),s+=4):(e=null,0===a&&u('"sips"')),null!==e&&(r=e,e=void(jn.scheme=r.toLowerCase())),null===e&&(s=t),e}function te(){var e,t,r;return t=s,"sip"===n.substr(s,3).toLowerCase()?(e=n.substr(s,3),s+=3):(e=null,0===a&&u('"sip"')),null!==e&&(r=e,e=void(jn.scheme=r.toLowerCase())),null===e&&(s=t),e}function ne(){var e,t,r,i,o,l,c;return i=s,o=s,null!==(e=re())?(l=s,58===n.charCodeAt(s)?(t=":",s++):(t=null,0===a&&u('":"')),null!==t&&null!==(r=se())?t=[t,r]:(t=null,s=l),null!==(t=null!==t?t:"")?(64===n.charCodeAt(s)?(r="@",s++):(r=null,0===a&&u('"@"')),null!==r?e=[e,t,r]:(e=null,s=o)):(e=null,s=o)):(e=null,s=o),null!==e&&(c=i,e=void(jn.user=decodeURIComponent(n.substring(s-1,c)))),null===e&&(s=i),e}function re(){var e,t;if(null===(t=S())&&null===(t=E())&&(t=ie()),null!==t)for(e=[];null!==t;)e.push(t),null===(t=S())&&null===(t=E())&&(t=ie());else e=null;return e}function ie(){var e;return 38===n.charCodeAt(s)?(e="&",s++):(e=null,0===a&&u('"&"')),null===e&&(61===n.charCodeAt(s)?(e="=",s++):(e=null,0===a&&u('"="')),null===e&&(43===n.charCodeAt(s)?(e="+",s++):(e=null,0===a&&u('"+"')),null===e&&(36===n.charCodeAt(s)?(e="$",s++):(e=null,0===a&&u('"$"')),null===e&&(44===n.charCodeAt(s)?(e=",",s++):(e=null,0===a&&u('","')),null===e&&(59===n.charCodeAt(s)?(e=";",s++):(e=null,0===a&&u('";"')),null===e&&(63===n.charCodeAt(s)?(e="?",s++):(e=null,0===a&&u('"?"')),null===e&&(47===n.charCodeAt(s)?(e="/",s++):(e=null,0===a&&u('"/"'))))))))),e}function se(){var e,t,r,i;for(r=s,e=[],null===(t=S())&&null===(t=E())&&(38===n.charCodeAt(s)?(t="&",s++):(t=null,0===a&&u('"&"')),null===t&&(61===n.charCodeAt(s)?(t="=",s++):(t=null,0===a&&u('"="')),null===t&&(43===n.charCodeAt(s)?(t="+",s++):(t=null,0===a&&u('"+"')),null===t&&(36===n.charCodeAt(s)?(t="$",s++):(t=null,0===a&&u('"$"')),null===t&&(44===n.charCodeAt(s)?(t=",",s++):(t=null,0===a&&u('","')))))));null!==t;)e.push(t),null===(t=S())&&null===(t=E())&&(38===n.charCodeAt(s)?(t="&",s++):(t=null,0===a&&u('"&"')),null===t&&(61===n.charCodeAt(s)?(t="=",s++):(t=null,0===a&&u('"="')),null===t&&(43===n.charCodeAt(s)?(t="+",s++):(t=null,0===a&&u('"+"')),null===t&&(36===n.charCodeAt(s)?(t="$",s++):(t=null,0===a&&u('"$"')),null===t&&(44===n.charCodeAt(s)?(t=",",s++):(t=null,0===a&&u('","')))))));return null!==e&&(i=r,e=void(jn.password=n.substring(s,i))),null===e&&(s=r),e}function ae(){var e,t,r,i,o;return i=s,null!==(e=oe())?(o=s,58===n.charCodeAt(s)?(t=":",s++):(t=null,0===a&&u('":"')),null!==t&&null!==(r=ve())?t=[t,r]:(t=null,s=o),null!==(t=null!==t?t:"")?e=[e,t]:(e=null,s=i)):(e=null,s=i),e}function oe(){var e,t,r;return t=s,null===(e=le())&&null===(e=me())&&(e=de()),null!==e&&(r=t,jn.host=n.substring(s,r).toLowerCase(),e=jn.host),null===e&&(s=t),e}function le(){var e,t,r,i,o,l,c;for(i=s,o=s,e=[],l=s,null!==(t=ue())?(46===n.charCodeAt(s)?(r=".",s++):(r=null,0===a&&u('"."')),null!==r?t=[t,r]:(t=null,s=l)):(t=null,s=l);null!==t;)e.push(t),l=s,null!==(t=ue())?(46===n.charCodeAt(s)?(r=".",s++):(r=null,0===a&&u('"."')),null!==r?t=[t,r]:(t=null,s=l)):(t=null,s=l);return null!==e&&null!==(t=ce())?(46===n.charCodeAt(s)?(r=".",s++):(r=null,0===a&&u('"."')),null!==(r=null!==r?r:"")?e=[e,t,r]:(e=null,s=o)):(e=null,s=o),null!==e&&(c=i,jn.host_type="domain",e=n.substring(s,c)),null===e&&(s=i),e}function ue(){var e,t,r,i;if(i=s,null!==(e=y())){for(t=[],null===(r=y())&&(45===n.charCodeAt(s)?(r="-",s++):(r=null,0===a&&u('"-"')),null===r&&(95===n.charCodeAt(s)?(r="_",s++):(r=null,0===a&&u('"_"'))));null!==r;)t.push(r),null===(r=y())&&(45===n.charCodeAt(s)?(r="-",s++):(r=null,0===a&&u('"-"')),null===r&&(95===n.charCodeAt(s)?(r="_",s++):(r=null,0===a&&u('"_"'))));null!==t?e=[e,t]:(e=null,s=i)}else e=null,s=i;return e}function ce(){var e,t,r,i;if(i=s,null!==(e=h())){for(t=[],null===(r=y())&&(45===n.charCodeAt(s)?(r="-",s++):(r=null,0===a&&u('"-"')),null===r&&(95===n.charCodeAt(s)?(r="_",s++):(r=null,0===a&&u('"_"'))));null!==r;)t.push(r),null===(r=y())&&(45===n.charCodeAt(s)?(r="-",s++):(r=null,0===a&&u('"-"')),null===r&&(95===n.charCodeAt(s)?(r="_",s++):(r=null,0===a&&u('"_"'))));null!==t?e=[e,t]:(e=null,s=i)}else e=null,s=i;return e}function de(){var e,t,r,i,o,l;return i=s,o=s,91===n.charCodeAt(s)?(e="[",s++):(e=null,0===a&&u('"["')),null!==e&&null!==(t=he())?(93===n.charCodeAt(s)?(r="]",s++):(r=null,0===a&&u('"]"')),null!==r?e=[e,t,r]:(e=null,s=o)):(e=null,s=o),null!==e&&(l=i,jn.host_type="IPv6",e=n.substring(s,l)),null===e&&(s=i),e}function he(){var e,t,r,i,o,l,c,d,h,p,f,m,_,v,g,y,T;return v=s,g=s,null!==(e=pe())?(58===n.charCodeAt(s)?(t=":",s++):(t=null,0===a&&u('":"')),null!==t&&null!==(r=pe())?(58===n.charCodeAt(s)?(i=":",s++):(i=null,0===a&&u('":"')),null!==i&&null!==(o=pe())?(58===n.charCodeAt(s)?(l=":",s++):(l=null,0===a&&u('":"')),null!==l&&null!==(c=pe())?(58===n.charCodeAt(s)?(d=":",s++):(d=null,0===a&&u('":"')),null!==d&&null!==(h=pe())?(58===n.charCodeAt(s)?(p=":",s++):(p=null,0===a&&u('":"')),null!==p&&null!==(f=pe())?(58===n.charCodeAt(s)?(m=":",s++):(m=null,0===a&&u('":"')),null!==m&&null!==(_=fe())?e=[e,t,r,i,o,l,c,d,h,p,f,m,_]:(e=null,s=g)):(e=null,s=g)):(e=null,s=g)):(e=null,s=g)):(e=null,s=g)):(e=null,s=g)):(e=null,s=g),null===e&&(g=s,"::"===n.substr(s,2)?(e="::",s+=2):(e=null,0===a&&u('"::"')),null!==e&&null!==(t=pe())?(58===n.charCodeAt(s)?(r=":",s++):(r=null,0===a&&u('":"')),null!==r&&null!==(i=pe())?(58===n.charCodeAt(s)?(o=":",s++):(o=null,0===a&&u('":"')),null!==o&&null!==(l=pe())?(58===n.charCodeAt(s)?(c=":",s++):(c=null,0===a&&u('":"')),null!==c&&null!==(d=pe())?(58===n.charCodeAt(s)?(h=":",s++):(h=null,0===a&&u('":"')),null!==h&&null!==(p=pe())?(58===n.charCodeAt(s)?(f=":",s++):(f=null,0===a&&u('":"')),null!==f&&null!==(m=fe())?e=[e,t,r,i,o,l,c,d,h,p,f,m]:(e=null,s=g)):(e=null,s=g)):(e=null,s=g)):(e=null,s=g)):(e=null,s=g)):(e=null,s=g),null===e&&(g=s,"::"===n.substr(s,2)?(e="::",s+=2):(e=null,0===a&&u('"::"')),null!==e&&null!==(t=pe())?(58===n.charCodeAt(s)?(r=":",s++):(r=null,0===a&&u('":"')),null!==r&&null!==(i=pe())?(58===n.charCodeAt(s)?(o=":",s++):(o=null,0===a&&u('":"')),null!==o&&null!==(l=pe())?(58===n.charCodeAt(s)?(c=":",s++):(c=null,0===a&&u('":"')),null!==c&&null!==(d=pe())?(58===n.charCodeAt(s)?(h=":",s++):(h=null,0===a&&u('":"')),null!==h&&null!==(p=fe())?e=[e,t,r,i,o,l,c,d,h,p]:(e=null,s=g)):(e=null,s=g)):(e=null,s=g)):(e=null,s=g)):(e=null,s=g),null===e&&(g=s,"::"===n.substr(s,2)?(e="::",s+=2):(e=null,0===a&&u('"::"')),null!==e&&null!==(t=pe())?(58===n.charCodeAt(s)?(r=":",s++):(r=null,0===a&&u('":"')),null!==r&&null!==(i=pe())?(58===n.charCodeAt(s)?(o=":",s++):(o=null,0===a&&u('":"')),null!==o&&null!==(l=pe())?(58===n.charCodeAt(s)?(c=":",s++):(c=null,0===a&&u('":"')),null!==c&&null!==(d=fe())?e=[e,t,r,i,o,l,c,d]:(e=null,s=g)):(e=null,s=g)):(e=null,s=g)):(e=null,s=g),null===e&&(g=s,"::"===n.substr(s,2)?(e="::",s+=2):(e=null,0===a&&u('"::"')),null!==e&&null!==(t=pe())?(58===n.charCodeAt(s)?(r=":",s++):(r=null,0===a&&u('":"')),null!==r&&null!==(i=pe())?(58===n.charCodeAt(s)?(o=":",s++):(o=null,0===a&&u('":"')),null!==o&&null!==(l=fe())?e=[e,t,r,i,o,l]:(e=null,s=g)):(e=null,s=g)):(e=null,s=g),null===e&&(g=s,"::"===n.substr(s,2)?(e="::",s+=2):(e=null,0===a&&u('"::"')),null!==e&&null!==(t=pe())?(58===n.charCodeAt(s)?(r=":",s++):(r=null,0===a&&u('":"')),null!==r&&null!==(i=fe())?e=[e,t,r,i]:(e=null,s=g)):(e=null,s=g),null===e&&(g=s,"::"===n.substr(s,2)?(e="::",s+=2):(e=null,0===a&&u('"::"')),null!==e&&null!==(t=fe())?e=[e,t]:(e=null,s=g),null===e&&(g=s,"::"===n.substr(s,2)?(e="::",s+=2):(e=null,0===a&&u('"::"')),null!==e&&null!==(t=pe())?e=[e,t]:(e=null,s=g),null===e&&(g=s,null!==(e=pe())?("::"===n.substr(s,2)?(t="::",s+=2):(t=null,0===a&&u('"::"')),null!==t&&null!==(r=pe())?(58===n.charCodeAt(s)?(i=":",s++):(i=null,0===a&&u('":"')),null!==i&&null!==(o=pe())?(58===n.charCodeAt(s)?(l=":",s++):(l=null,0===a&&u('":"')),null!==l&&null!==(c=pe())?(58===n.charCodeAt(s)?(d=":",s++):(d=null,0===a&&u('":"')),null!==d&&null!==(h=pe())?(58===n.charCodeAt(s)?(p=":",s++):(p=null,0===a&&u('":"')),null!==p&&null!==(f=fe())?e=[e,t,r,i,o,l,c,d,h,p,f]:(e=null,s=g)):(e=null,s=g)):(e=null,s=g)):(e=null,s=g)):(e=null,s=g)):(e=null,s=g),null===e&&(g=s,null!==(e=pe())?(y=s,58===n.charCodeAt(s)?(t=":",s++):(t=null,0===a&&u('":"')),null!==t&&null!==(r=pe())?t=[t,r]:(t=null,s=y),null!==(t=null!==t?t:"")?("::"===n.substr(s,2)?(r="::",s+=2):(r=null,0===a&&u('"::"')),null!==r&&null!==(i=pe())?(58===n.charCodeAt(s)?(o=":",s++):(o=null,0===a&&u('":"')),null!==o&&null!==(l=pe())?(58===n.charCodeAt(s)?(c=":",s++):(c=null,0===a&&u('":"')),null!==c&&null!==(d=pe())?(58===n.charCodeAt(s)?(h=":",s++):(h=null,0===a&&u('":"')),null!==h&&null!==(p=fe())?e=[e,t,r,i,o,l,c,d,h,p]:(e=null,s=g)):(e=null,s=g)):(e=null,s=g)):(e=null,s=g)):(e=null,s=g)):(e=null,s=g),null===e&&(g=s,null!==(e=pe())?(y=s,58===n.charCodeAt(s)?(t=":",s++):(t=null,0===a&&u('":"')),null!==t&&null!==(r=pe())?t=[t,r]:(t=null,s=y),null!==(t=null!==t?t:"")?(y=s,58===n.charCodeAt(s)?(r=":",s++):(r=null,0===a&&u('":"')),null!==r&&null!==(i=pe())?r=[r,i]:(r=null,s=y),null!==(r=null!==r?r:"")?("::"===n.substr(s,2)?(i="::",s+=2):(i=null,0===a&&u('"::"')),null!==i&&null!==(o=pe())?(58===n.charCodeAt(s)?(l=":",s++):(l=null,0===a&&u('":"')),null!==l&&null!==(c=pe())?(58===n.charCodeAt(s)?(d=":",s++):(d=null,0===a&&u('":"')),null!==d&&null!==(h=fe())?e=[e,t,r,i,o,l,c,d,h]:(e=null,s=g)):(e=null,s=g)):(e=null,s=g)):(e=null,s=g)):(e=null,s=g)):(e=null,s=g),null===e&&(g=s,null!==(e=pe())?(y=s,58===n.charCodeAt(s)?(t=":",s++):(t=null,0===a&&u('":"')),null!==t&&null!==(r=pe())?t=[t,r]:(t=null,s=y),null!==(t=null!==t?t:"")?(y=s,58===n.charCodeAt(s)?(r=":",s++):(r=null,0===a&&u('":"')),null!==r&&null!==(i=pe())?r=[r,i]:(r=null,s=y),null!==(r=null!==r?r:"")?(y=s,58===n.charCodeAt(s)?(i=":",s++):(i=null,0===a&&u('":"')),null!==i&&null!==(o=pe())?i=[i,o]:(i=null,s=y),null!==(i=null!==i?i:"")?("::"===n.substr(s,2)?(o="::",s+=2):(o=null,0===a&&u('"::"')),null!==o&&null!==(l=pe())?(58===n.charCodeAt(s)?(c=":",s++):(c=null,0===a&&u('":"')),null!==c&&null!==(d=fe())?e=[e,t,r,i,o,l,c,d]:(e=null,s=g)):(e=null,s=g)):(e=null,s=g)):(e=null,s=g)):(e=null,s=g)):(e=null,s=g),null===e&&(g=s,null!==(e=pe())?(y=s,58===n.charCodeAt(s)?(t=":",s++):(t=null,0===a&&u('":"')),null!==t&&null!==(r=pe())?t=[t,r]:(t=null,s=y),null!==(t=null!==t?t:"")?(y=s,58===n.charCodeAt(s)?(r=":",s++):(r=null,0===a&&u('":"')),null!==r&&null!==(i=pe())?r=[r,i]:(r=null,s=y),null!==(r=null!==r?r:"")?(y=s,58===n.charCodeAt(s)?(i=":",s++):(i=null,0===a&&u('":"')),null!==i&&null!==(o=pe())?i=[i,o]:(i=null,s=y),null!==(i=null!==i?i:"")?(y=s,58===n.charCodeAt(s)?(o=":",s++):(o=null,0===a&&u('":"')),null!==o&&null!==(l=pe())?o=[o,l]:(o=null,s=y),null!==(o=null!==o?o:"")?("::"===n.substr(s,2)?(l="::",s+=2):(l=null,0===a&&u('"::"')),null!==l&&null!==(c=fe())?e=[e,t,r,i,o,l,c]:(e=null,s=g)):(e=null,s=g)):(e=null,s=g)):(e=null,s=g)):(e=null,s=g)):(e=null,s=g),null===e&&(g=s,null!==(e=pe())?(y=s,58===n.charCodeAt(s)?(t=":",s++):(t=null,0===a&&u('":"')),null!==t&&null!==(r=pe())?t=[t,r]:(t=null,s=y),null!==(t=null!==t?t:"")?(y=s,58===n.charCodeAt(s)?(r=":",s++):(r=null,0===a&&u('":"')),null!==r&&null!==(i=pe())?r=[r,i]:(r=null,s=y),null!==(r=null!==r?r:"")?(y=s,58===n.charCodeAt(s)?(i=":",s++):(i=null,0===a&&u('":"')),null!==i&&null!==(o=pe())?i=[i,o]:(i=null,s=y),null!==(i=null!==i?i:"")?(y=s,58===n.charCodeAt(s)?(o=":",s++):(o=null,0===a&&u('":"')),null!==o&&null!==(l=pe())?o=[o,l]:(o=null,s=y),null!==(o=null!==o?o:"")?(y=s,58===n.charCodeAt(s)?(l=":",s++):(l=null,0===a&&u('":"')),null!==l&&null!==(c=pe())?l=[l,c]:(l=null,s=y),null!==(l=null!==l?l:"")?("::"===n.substr(s,2)?(c="::",s+=2):(c=null,0===a&&u('"::"')),null!==c&&null!==(d=pe())?e=[e,t,r,i,o,l,c,d]:(e=null,s=g)):(e=null,s=g)):(e=null,s=g)):(e=null,s=g)):(e=null,s=g)):(e=null,s=g)):(e=null,s=g),null===e&&(g=s,null!==(e=pe())?(y=s,58===n.charCodeAt(s)?(t=":",s++):(t=null,0===a&&u('":"')),null!==t&&null!==(r=pe())?t=[t,r]:(t=null,s=y),null!==(t=null!==t?t:"")?(y=s,58===n.charCodeAt(s)?(r=":",s++):(r=null,0===a&&u('":"')),null!==r&&null!==(i=pe())?r=[r,i]:(r=null,s=y),null!==(r=null!==r?r:"")?(y=s,58===n.charCodeAt(s)?(i=":",s++):(i=null,0===a&&u('":"')),null!==i&&null!==(o=pe())?i=[i,o]:(i=null,s=y),null!==(i=null!==i?i:"")?(y=s,58===n.charCodeAt(s)?(o=":",s++):(o=null,0===a&&u('":"')),null!==o&&null!==(l=pe())?o=[o,l]:(o=null,s=y),null!==(o=null!==o?o:"")?(y=s,58===n.charCodeAt(s)?(l=":",s++):(l=null,0===a&&u('":"')),null!==l&&null!==(c=pe())?l=[l,c]:(l=null,s=y),null!==(l=null!==l?l:"")?(y=s,58===n.charCodeAt(s)?(c=":",s++):(c=null,0===a&&u('":"')),null!==c&&null!==(d=pe())?c=[c,d]:(c=null,s=y),null!==(c=null!==c?c:"")?("::"===n.substr(s,2)?(d="::",s+=2):(d=null,0===a&&u('"::"')),null!==d?e=[e,t,r,i,o,l,c,d]:(e=null,s=g)):(e=null,s=g)):(e=null,s=g)):(e=null,s=g)):(e=null,s=g)):(e=null,s=g)):(e=null,s=g)):(e=null,s=g))))))))))))))),null!==e&&(T=v,jn.host_type="IPv6",e=n.substring(s,T)),null===e&&(s=v),e}function pe(){var e,t,n,r,i;return i=s,null!==(e=p())&&null!==(t=null!==(t=p())?t:"")&&null!==(n=null!==(n=p())?n:"")&&null!==(r=null!==(r=p())?r:"")?e=[e,t,n,r]:(e=null,s=i),e}function fe(){var e,t,r,i;return i=s,null!==(e=pe())?(58===n.charCodeAt(s)?(t=":",s++):(t=null,0===a&&u('":"')),null!==t&&null!==(r=pe())?e=[e,t,r]:(e=null,s=i)):(e=null,s=i),null===e&&(e=me()),e}function me(){var e,t,r,i,o,l,c,d,h,p;return d=s,h=s,null!==(e=_e())?(46===n.charCodeAt(s)?(t=".",s++):(t=null,0===a&&u('"."')),null!==t&&null!==(r=_e())?(46===n.charCodeAt(s)?(i=".",s++):(i=null,0===a&&u('"."')),null!==i&&null!==(o=_e())?(46===n.charCodeAt(s)?(l=".",s++):(l=null,0===a&&u('"."')),null!==l&&null!==(c=_e())?e=[e,t,r,i,o,l,c]:(e=null,s=h)):(e=null,s=h)):(e=null,s=h)):(e=null,s=h),null!==e&&(p=d,jn.host_type="IPv4",e=n.substring(s,p)),null===e&&(s=d),e}function _e(){var e,t,r,i;return i=s,"25"===n.substr(s,2)?(e="25",s+=2):(e=null,0===a&&u('"25"')),null!==e?(/^[0-5]/.test(n.charAt(s))?(t=n.charAt(s),s++):(t=null,0===a&&u("[0-5]")),null!==t?e=[e,t]:(e=null,s=i)):(e=null,s=i),null===e&&(i=s,50===n.charCodeAt(s)?(e="2",s++):(e=null,0===a&&u('"2"')),null!==e?(/^[0-4]/.test(n.charAt(s))?(t=n.charAt(s),s++):(t=null,0===a&&u("[0-4]")),null!==t&&null!==(r=d())?e=[e,t,r]:(e=null,s=i)):(e=null,s=i),null===e&&(i=s,49===n.charCodeAt(s)?(e="1",s++):(e=null,0===a&&u('"1"')),null!==e&&null!==(t=d())&&null!==(r=d())?e=[e,t,r]:(e=null,s=i),null===e&&(i=s,/^[1-9]/.test(n.charAt(s))?(e=n.charAt(s),s++):(e=null,0===a&&u("[1-9]")),null!==e&&null!==(t=d())?e=[e,t]:(e=null,s=i),null===e&&(e=d())))),e}function ve(){var e,t,n,r,i,a,o,l;return a=s,o=s,null!==(e=null!==(e=d())?e:"")&&null!==(t=null!==(t=d())?t:"")&&null!==(n=null!==(n=d())?n:"")&&null!==(r=null!==(r=d())?r:"")&&null!==(i=null!==(i=d())?i:"")?e=[e,t,n,r,i]:(e=null,s=o),null!==e&&(l=e,l=parseInt(l.join("")),jn.port=l,e=l),null===e&&(s=a),e}function ge(){var e,t,r,i;for(e=[],i=s,59===n.charCodeAt(s)?(t=";",s++):(t=null,0===a&&u('";"')),null!==t&&null!==(r=ye())?t=[t,r]:(t=null,s=i);null!==t;)e.push(t),i=s,59===n.charCodeAt(s)?(t=";",s++):(t=null,0===a&&u('";"')),null!==t&&null!==(r=ye())?t=[t,r]:(t=null,s=i);return e}function ye(){var e;return null===(e=Te())&&null===(e=Se())&&null===(e=Ce())&&null===(e=Ee())&&null===(e=be())&&null===(e=Re())&&(e=we()),e}function Te(){var e,t,r,i,o;return r=s,i=s,"transport="===n.substr(s,10).toLowerCase()?(e=n.substr(s,10),s+=10):(e=null,0===a&&u('"transport="')),null!==e?("udp"===n.substr(s,3).toLowerCase()?(t=n.substr(s,3),s+=3):(t=null,0===a&&u('"udp"')),null===t&&("tcp"===n.substr(s,3).toLowerCase()?(t=n.substr(s,3),s+=3):(t=null,0===a&&u('"tcp"')),null===t&&("sctp"===n.substr(s,4).toLowerCase()?(t=n.substr(s,4),s+=4):(t=null,0===a&&u('"sctp"')),null===t&&("tls"===n.substr(s,3).toLowerCase()?(t=n.substr(s,3),s+=3):(t=null,0===a&&u('"tls"')),null===t&&(t=O())))),null!==t?e=[e,t]:(e=null,s=i)):(e=null,s=i),null!==e&&(o=e[1],jn.uri_params||(jn.uri_params={}),e=void(jn.uri_params.transport=o.toLowerCase())),null===e&&(s=r),e}function Se(){var e,t,r,i,o;return r=s,i=s,"user="===n.substr(s,5).toLowerCase()?(e=n.substr(s,5),s+=5):(e=null,0===a&&u('"user="')),null!==e?("phone"===n.substr(s,5).toLowerCase()?(t=n.substr(s,5),s+=5):(t=null,0===a&&u('"phone"')),null===t&&("ip"===n.substr(s,2).toLowerCase()?(t=n.substr(s,2),s+=2):(t=null,0===a&&u('"ip"')),null===t&&(t=O())),null!==t?e=[e,t]:(e=null,s=i)):(e=null,s=i),null!==e&&(o=e[1],jn.uri_params||(jn.uri_params={}),e=void(jn.uri_params.user=o.toLowerCase())),null===e&&(s=r),e}function Ce(){var e,t,r,i,o;return r=s,i=s,"method="===n.substr(s,7).toLowerCase()?(e=n.substr(s,7),s+=7):(e=null,0===a&&u('"method="')),null!==e&&null!==(t=ct())?e=[e,t]:(e=null,s=i),null!==e&&(o=e[1],jn.uri_params||(jn.uri_params={}),e=void(jn.uri_params.method=o)),null===e&&(s=r),e}function Ee(){var e,t,r,i,o;return r=s,i=s,"ttl="===n.substr(s,4).toLowerCase()?(e=n.substr(s,4),s+=4):(e=null,0===a&&u('"ttl="')),null!==e&&null!==(t=bn())?e=[e,t]:(e=null,s=i),null!==e&&(o=e[1],jn.params||(jn.params={}),e=void(jn.params.ttl=o)),null===e&&(s=r),e}function be(){var e,t,r,i,o;return r=s,i=s,"maddr="===n.substr(s,6).toLowerCase()?(e=n.substr(s,6),s+=6):(e=null,0===a&&u('"maddr="')),null!==e&&null!==(t=oe())?e=[e,t]:(e=null,s=i),null!==e&&(o=e[1],jn.uri_params||(jn.uri_params={}),e=void(jn.uri_params.maddr=o)),null===e&&(s=r),e}function Re(){var e,t,r,i,o,l;return i=s,o=s,"lr"===n.substr(s,2).toLowerCase()?(e=n.substr(s,2),s+=2):(e=null,0===a&&u('"lr"')),null!==e?(l=s,61===n.charCodeAt(s)?(t="=",s++):(t=null,0===a&&u('"="')),null!==t&&null!==(r=O())?t=[t,r]:(t=null,s=l),null!==(t=null!==t?t:"")?e=[e,t]:(e=null,s=o)):(e=null,s=o),null!==e&&(jn.uri_params||(jn.uri_params={}),e=void(jn.uri_params.lr=void 0)),null===e&&(s=i),e}function we(){var e,t,r,i,o,l,c,d;return i=s,o=s,null!==(e=Ae())?(l=s,61===n.charCodeAt(s)?(t="=",s++):(t=null,0===a&&u('"="')),null!==t&&null!==(r=Ie())?t=[t,r]:(t=null,s=l),null!==(t=null!==t?t:"")?e=[e,t]:(e=null,s=o)):(e=null,s=o),null!==e&&(c=e[0],d=e[1],jn.uri_params||(jn.uri_params={}),d=void 0===d?void 0:d[1],e=void(jn.uri_params[c.toLowerCase()]=d)),null===e&&(s=i),e}function Ae(){var e,t,n;if(n=s,null!==(t=ke()))for(e=[];null!==t;)e.push(t),t=ke();else e=null;return null!==e&&(e=e.join("")),null===e&&(s=n),e}function Ie(){var e,t,n;if(n=s,null!==(t=ke()))for(e=[];null!==t;)e.push(t),t=ke();else e=null;return null!==e&&(e=e.join("")),null===e&&(s=n),e}function ke(){var e;return null===(e=Pe())&&null===(e=S())&&(e=E()),e}function Pe(){var e;return 91===n.charCodeAt(s)?(e="[",s++):(e=null,0===a&&u('"["')),null===e&&(93===n.charCodeAt(s)?(e="]",s++):(e=null,0===a&&u('"]"')),null===e&&(47===n.charCodeAt(s)?(e="/",s++):(e=null,0===a&&u('"/"')),null===e&&(58===n.charCodeAt(s)?(e=":",s++):(e=null,0===a&&u('":"')),null===e&&(38===n.charCodeAt(s)?(e="&",s++):(e=null,0===a&&u('"&"')),null===e&&(43===n.charCodeAt(s)?(e="+",s++):(e=null,0===a&&u('"+"')),null===e&&(36===n.charCodeAt(s)?(e="$",s++):(e=null,0===a&&u('"$"')))))))),e}function Oe(){var e,t,r,i,o,l,c;if(l=s,63===n.charCodeAt(s)?(e="?",s++):(e=null,0===a&&u('"?"')),null!==e)if(null!==(t=Ne())){for(r=[],c=s,38===n.charCodeAt(s)?(i="&",s++):(i=null,0===a&&u('"&"')),null!==i&&null!==(o=Ne())?i=[i,o]:(i=null,s=c);null!==i;)r.push(i),c=s,38===n.charCodeAt(s)?(i="&",s++):(i=null,0===a&&u('"&"')),null!==i&&null!==(o=Ne())?i=[i,o]:(i=null,s=c);null!==r?e=[e,t,r]:(e=null,s=l)}else e=null,s=l;else e=null,s=l;return e}function Ne(){var e,t,r,i,o,l,c;return i=s,o=s,null!==(e=xe())?(61===n.charCodeAt(s)?(t="=",s++):(t=null,0===a&&u('"="')),null!==t&&null!==(r=De())?e=[e,t,r]:(e=null,s=o)):(e=null,s=o),null!==e&&(l=e[0],c=e[2],l=l.join("").toLowerCase(),c=c.join(""),jn.uri_headers||(jn.uri_headers={}),e=void(jn.uri_headers[l]?jn.uri_headers[l].push(c):jn.uri_headers[l]=[c])),null===e&&(s=i),e}function xe(){var e,t;if(null===(t=Me())&&null===(t=S())&&(t=E()),null!==t)for(e=[];null!==t;)e.push(t),null===(t=Me())&&null===(t=S())&&(t=E());else e=null;return e}function De(){var e,t;for(e=[],null===(t=Me())&&null===(t=S())&&(t=E());null!==t;)e.push(t),null===(t=Me())&&null===(t=S())&&(t=E());return e}function Me(){var e;return 91===n.charCodeAt(s)?(e="[",s++):(e=null,0===a&&u('"["')),null===e&&(93===n.charCodeAt(s)?(e="]",s++):(e=null,0===a&&u('"]"')),null===e&&(47===n.charCodeAt(s)?(e="/",s++):(e=null,0===a&&u('"/"')),null===e&&(63===n.charCodeAt(s)?(e="?",s++):(e=null,0===a&&u('"?"')),null===e&&(58===n.charCodeAt(s)?(e=":",s++):(e=null,0===a&&u('":"')),null===e&&(43===n.charCodeAt(s)?(e="+",s++):(e=null,0===a&&u('"+"')),null===e&&(36===n.charCodeAt(s)?(e="$",s++):(e=null,0===a&&u('"$"')))))))),e}function Ue(){var e,t,n,r,i,a;return a=s,null!==(e=ct())&&null!==(t=v())&&null!==(n=Le())&&null!==(r=v())&&null!==(i=et())?e=[e,t,n,r,i]:(e=null,s=a),e}function Le(){var e;return null===(e=Q())&&(e=He()),e}function He(){var e,t,r,i;return i=s,null!==(e=$e())?(58===n.charCodeAt(s)?(t=":",s++):(t=null,0===a&&u('":"')),null!==t?(null===(r=qe())&&(r=Ge()),null!==r?e=[e,t,r]:(e=null,s=i)):(e=null,s=i)):(e=null,s=i),e}function qe(){var e,t,r,i,o;return i=s,null===(e=je())&&(e=Fe()),null!==e?(o=s,63===n.charCodeAt(s)?(t="?",s++):(t=null,0===a&&u('"?"')),null!==t&&null!==(r=Ze())?t=[t,r]:(t=null,s=o),null!==(t=null!==t?t:"")?e=[e,t]:(e=null,s=i)):(e=null,s=i),e}function je(){var e,t,r,i;return i=s,"//"===n.substr(s,2)?(e="//",s+=2):(e=null,0===a&&u('"//"')),null!==e&&null!==(t=Ke())&&null!==(r=null!==(r=Fe())?r:"")?e=[e,t,r]:(e=null,s=i),e}function Fe(){var e,t,r;return r=s,47===n.charCodeAt(s)?(e="/",s++):(e=null,0===a&&u('"/"')),null!==e&&null!==(t=We())?e=[e,t]:(e=null,s=r),e}function Ge(){var e,t,n,r;if(r=s,null!==(e=Je())){for(t=[],n=Be();null!==n;)t.push(n),n=Be();null!==t?e=[e,t]:(e=null,s=r)}else e=null,s=r;return e}function Be(){var e;return null===(e=T())&&null===(e=S())&&(e=E()),e}function Je(){var e;return null===(e=S())&&null===(e=E())&&(59===n.charCodeAt(s)?(e=";",s++):(e=null,0===a&&u('";"')),null===e&&(63===n.charCodeAt(s)?(e="?",s++):(e=null,0===a&&u('"?"')),null===e&&(58===n.charCodeAt(s)?(e=":",s++):(e=null,0===a&&u('":"')),null===e&&(64===n.charCodeAt(s)?(e="@",s++):(e=null,0===a&&u('"@"')),null===e&&(38===n.charCodeAt(s)?(e="&",s++):(e=null,0===a&&u('"&"')),null===e&&(61===n.charCodeAt(s)?(e="=",s++):(e=null,0===a&&u('"="')),null===e&&(43===n.charCodeAt(s)?(e="+",s++):(e=null,0===a&&u('"+"')),null===e&&(36===n.charCodeAt(s)?(e="$",s++):(e=null,0===a&&u('"$"')),null===e&&(44===n.charCodeAt(s)?(e=",",s++):(e=null,0===a&&u('","'))))))))))),e}function We(){var e,t,r,i,o,l;if(o=s,null!==(e=Ve())){for(t=[],l=s,47===n.charCodeAt(s)?(r="/",s++):(r=null,0===a&&u('"/"')),null!==r&&null!==(i=Ve())?r=[r,i]:(r=null,s=l);null!==r;)t.push(r),l=s,47===n.charCodeAt(s)?(r="/",s++):(r=null,0===a&&u('"/"')),null!==r&&null!==(i=Ve())?r=[r,i]:(r=null,s=l);null!==t?e=[e,t]:(e=null,s=o)}else e=null,s=o;return e}function Ve(){var e,t,r,i,o,l;for(o=s,e=[],t=Ye();null!==t;)e.push(t),t=Ye();if(null!==e){for(t=[],l=s,59===n.charCodeAt(s)?(r=";",s++):(r=null,0===a&&u('";"')),null!==r&&null!==(i=ze())?r=[r,i]:(r=null,s=l);null!==r;)t.push(r),l=s,59===n.charCodeAt(s)?(r=";",s++):(r=null,0===a&&u('";"')),null!==r&&null!==(i=ze())?r=[r,i]:(r=null,s=l);null!==t?e=[e,t]:(e=null,s=o)}else e=null,s=o;return e}function ze(){var e,t;for(e=[],t=Ye();null!==t;)e.push(t),t=Ye();return e}function Ye(){var e;return null===(e=S())&&null===(e=E())&&(58===n.charCodeAt(s)?(e=":",s++):(e=null,0===a&&u('":"')),null===e&&(64===n.charCodeAt(s)?(e="@",s++):(e=null,0===a&&u('"@"')),null===e&&(38===n.charCodeAt(s)?(e="&",s++):(e=null,0===a&&u('"&"')),null===e&&(61===n.charCodeAt(s)?(e="=",s++):(e=null,0===a&&u('"="')),null===e&&(43===n.charCodeAt(s)?(e="+",s++):(e=null,0===a&&u('"+"')),null===e&&(36===n.charCodeAt(s)?(e="$",s++):(e=null,0===a&&u('"$"')),null===e&&(44===n.charCodeAt(s)?(e=",",s++):(e=null,0===a&&u('","'))))))))),e}function $e(){var e,t,r,i,o,l;if(i=s,o=s,null!==(e=h())){for(t=[],null===(r=h())&&null===(r=d())&&(43===n.charCodeAt(s)?(r="+",s++):(r=null,0===a&&u('"+"')),null===r&&(45===n.charCodeAt(s)?(r="-",s++):(r=null,0===a&&u('"-"')),null===r&&(46===n.charCodeAt(s)?(r=".",s++):(r=null,0===a&&u('"."')))));null!==r;)t.push(r),null===(r=h())&&null===(r=d())&&(43===n.charCodeAt(s)?(r="+",s++):(r=null,0===a&&u('"+"')),null===r&&(45===n.charCodeAt(s)?(r="-",s++):(r=null,0===a&&u('"-"')),null===r&&(46===n.charCodeAt(s)?(r=".",s++):(r=null,0===a&&u('"."')))));null!==t?e=[e,t]:(e=null,s=o)}else e=null,s=o;return null!==e&&(l=i,e=void(jn.scheme=n.substring(s,l))),null===e&&(s=i),e}function Ke(){var e;return null===(e=Xe())&&(e=Qe()),e}function Xe(){var e,t,r,i;return r=s,i=s,null!==(e=ne())?(64===n.charCodeAt(s)?(t="@",s++):(t=null,0===a&&u('"@"')),null!==t?e=[e,t]:(e=null,s=i)):(e=null,s=i),null!==(e=null!==e?e:"")&&null!==(t=ae())?e=[e,t]:(e=null,s=r),e=null!==e?e:""}function Qe(){var e,t;if(null===(t=S())&&null===(t=E())&&(36===n.charCodeAt(s)?(t="$",s++):(t=null,0===a&&u('"$"')),null===t&&(44===n.charCodeAt(s)?(t=",",s++):(t=null,0===a&&u('","')),null===t&&(59===n.charCodeAt(s)?(t=";",s++):(t=null,0===a&&u('";"')),null===t&&(58===n.charCodeAt(s)?(t=":",s++):(t=null,0===a&&u('":"')),null===t&&(64===n.charCodeAt(s)?(t="@",s++):(t=null,0===a&&u('"@"')),null===t&&(38===n.charCodeAt(s)?(t="&",s++):(t=null,0===a&&u('"&"')),null===t&&(61===n.charCodeAt(s)?(t="=",s++):(t=null,0===a&&u('"="')),null===t&&(43===n.charCodeAt(s)?(t="+",s++):(t=null,0===a&&u('"+"')))))))))),null!==t)for(e=[];null!==t;)e.push(t),null===(t=S())&&null===(t=E())&&(36===n.charCodeAt(s)?(t="$",s++):(t=null,0===a&&u('"$"')),null===t&&(44===n.charCodeAt(s)?(t=",",s++):(t=null,0===a&&u('","')),null===t&&(59===n.charCodeAt(s)?(t=";",s++):(t=null,0===a&&u('";"')),null===t&&(58===n.charCodeAt(s)?(t=":",s++):(t=null,0===a&&u('":"')),null===t&&(64===n.charCodeAt(s)?(t="@",s++):(t=null,0===a&&u('"@"')),null===t&&(38===n.charCodeAt(s)?(t="&",s++):(t=null,0===a&&u('"&"')),null===t&&(61===n.charCodeAt(s)?(t="=",s++):(t=null,0===a&&u('"="')),null===t&&(43===n.charCodeAt(s)?(t="+",s++):(t=null,0===a&&u('"+"'))))))))));else e=null;return e}function Ze(){var e,t;for(e=[],t=Be();null!==t;)e.push(t),t=Be();return e}function et(){var e,t,r,i,o,l,c,h,p;if(c=s,h=s,"sip"===n.substr(s,3).toLowerCase()?(e=n.substr(s,3),s+=3):(e=null,0===a&&u('"SIP"')),null!==e)if(47===n.charCodeAt(s)?(t="/",s++):(t=null,0===a&&u('"/"')),null!==t){if(null!==(i=d()))for(r=[];null!==i;)r.push(i),i=d();else r=null;if(null!==r)if(46===n.charCodeAt(s)?(i=".",s++):(i=null,0===a&&u('"."')),null!==i){if(null!==(l=d()))for(o=[];null!==l;)o.push(l),l=d();else o=null;null!==o?e=[e,t,r,i,o]:(e=null,s=h)}else e=null,s=h;else e=null,s=h}else e=null,s=h;else e=null,s=h;return null!==e&&(p=c,e=void(jn.sip_version=n.substring(s,p))),null===e&&(s=c),e}function tt(){var e;return"INVITE"===n.substr(s,6)?(e="INVITE",s+=6):(e=null,0===a&&u('"INVITE"')),e}function nt(){var e;return"ACK"===n.substr(s,3)?(e="ACK",s+=3):(e=null,0===a&&u('"ACK"')),e}function rt(){var e;return"OPTIONS"===n.substr(s,7)?(e="OPTIONS",s+=7):(e=null,0===a&&u('"OPTIONS"')),e}function it(){var e;return"BYE"===n.substr(s,3)?(e="BYE",s+=3):(e=null,0===a&&u('"BYE"')),e}function st(){var e;return"CANCEL"===n.substr(s,6)?(e="CANCEL",s+=6):(e=null,0===a&&u('"CANCEL"')),e}function at(){var e;return"REGISTER"===n.substr(s,8)?(e="REGISTER",s+=8):(e=null,0===a&&u('"REGISTER"')),e}function ot(){var e;return"SUBSCRIBE"===n.substr(s,9)?(e="SUBSCRIBE",s+=9):(e=null,0===a&&u('"SUBSCRIBE"')),e}function lt(){var e;return"NOTIFY"===n.substr(s,6)?(e="NOTIFY",s+=6):(e=null,0===a&&u('"NOTIFY"')),e}function ut(){var e;return"REFER"===n.substr(s,5)?(e="REFER",s+=5):(e=null,0===a&&u('"REFER"')),e}function ct(){var e,t,r;return t=s,null===(e=tt())&&null===(e=nt())&&null===(e=rt())&&null===(e=it())&&null===(e=st())&&null===(e=at())&&null===(e=ot())&&null===(e=lt())&&null===(e=ut())&&(e=O()),null!==e&&(r=t,jn.method=n.substring(s,r),e=jn.method),null===e&&(s=t),e}function dt(){var e,t,n,r,i,a;return a=s,null!==(e=et())&&null!==(t=v())&&null!==(n=ht())&&null!==(r=v())&&null!==(i=ft())?e=[e,t,n,r,i]:(e=null,s=a),e}function ht(){var e,t,n;return t=s,null!==(e=pt())&&(n=e,e=void(jn.status_code=parseInt(n.join("")))),null===e&&(s=t),e}function pt(){var e,t,n,r;return r=s,null!==(e=d())&&null!==(t=d())&&null!==(n=d())?e=[e,t,n]:(e=null,s=r),e}function ft(){var e,t,r,i;for(r=s,e=[],null===(t=T())&&null===(t=S())&&null===(t=E())&&null===(t=k())&&null===(t=P())&&null===(t=v())&&(t=g());null!==t;)e.push(t),null===(t=T())&&null===(t=S())&&null===(t=E())&&null===(t=k())&&null===(t=P())&&null===(t=v())&&(t=g());return null!==e&&(i=r,e=void(jn.reason_phrase=n.substring(s,i))),null===e&&(s=r),e}function mt(){var e,t,n,r,i,a,o;if(i=s,a=s,null===(e=X())&&(e=_t()),null!==e){for(t=[],o=s,null!==(n=G())&&null!==(r=gt())?n=[n,r]:(n=null,s=o);null!==n;)t.push(n),o=s,null!==(n=G())&&null!==(r=gt())?n=[n,r]:(n=null,s=o);null!==t?e=[e,t]:(e=null,s=a)}else e=null,s=a;return null!==e&&(e=function(e){var t;jn.multi_header||(jn.multi_header=[]);try{t=new qn(jn.uri,jn.display_name,jn.params),delete jn.uri,delete jn.display_name,delete jn.params}catch(e){t=null}jn.multi_header.push({possition:s,offset:e,parsed:t})}(i)),null===e&&(s=i),e}function _t(){var e,t,n,r,i;return i=s,null!==(e=null!==(e=vt())?e:"")&&null!==(t=j())&&null!==(n=Q())&&null!==(r=q())?e=[e,t,n,r]:(e=null,s=i),e}function vt(){var e,t,r,i,a,o,l,u,c;if(a=s,o=s,null!==(e=O())){for(t=[],l=s,null!==(r=b())&&null!==(i=O())?r=[r,i]:(r=null,s=l);null!==r;)t.push(r),l=s,null!==(r=b())&&null!==(i=O())?r=[r,i]:(r=null,s=l);null!==t?e=[e,t]:(e=null,s=o)}else e=null,s=o;return null===e&&(e=z()),null!==e&&(u=a,c=e,'"'===(c=n.substring(s,u).trim())[0]&&(c=c.substring(1,c.length-1)),e=void(jn.display_name=c)),null===e&&(s=a),e}function gt(){var e;return null===(e=yt())&&null===(e=Tt())&&(e=Et()),e}function yt(){var e,t,r,i,o,l;return i=s,o=s,"q"===n.substr(s,1).toLowerCase()?(e=n.substr(s,1),s++):(e=null,0===a&&u('"q"')),null!==e&&null!==(t=U())&&null!==(r=Ct())?e=[e,t,r]:(e=null,s=o),null!==e&&(l=e[2],jn.params||(jn.params={}),e=void(jn.params.q=l)),null===e&&(s=i),e}function Tt(){var e,t,r,i,o,l;return i=s,o=s,"expires"===n.substr(s,7).toLowerCase()?(e=n.substr(s,7),s+=7):(e=null,0===a&&u('"expires"')),null!==e&&null!==(t=U())&&null!==(r=St())?e=[e,t,r]:(e=null,s=o),null!==e&&(l=e[2],jn.params||(jn.params={}),e=void(jn.params.expires=l)),null===e&&(s=i),e}function St(){var e,t,n;if(n=s,null!==(t=d()))for(e=[];null!==t;)e.push(t),t=d();else e=null;return null!==e&&(e=parseInt(e.join(""))),null===e&&(s=n),e}function Ct(){var e,t,r,i,o,l,c,h,p;return l=s,c=s,48===n.charCodeAt(s)?(e="0",s++):(e=null,0===a&&u('"0"')),null!==e?(h=s,46===n.charCodeAt(s)?(t=".",s++):(t=null,0===a&&u('"."')),null!==t&&null!==(r=null!==(r=d())?r:"")&&null!==(i=null!==(i=d())?i:"")&&null!==(o=null!==(o=d())?o:"")?t=[t,r,i,o]:(t=null,s=h),null!==(t=null!==t?t:"")?e=[e,t]:(e=null,s=c)):(e=null,s=c),null!==e&&(p=l,e=parseFloat(n.substring(s,p))),null===e&&(s=l),e}function Et(){var e,t,n,r,i,a,o,l;return r=s,i=s,null!==(e=O())?(a=s,null!==(t=U())&&null!==(n=bt())?t=[t,n]:(t=null,s=a),null!==(t=null!==t?t:"")?e=[e,t]:(e=null,s=i)):(e=null,s=i),null!==e&&(o=e[0],l=e[1],jn.params||(jn.params={}),l=void 0===l?void 0:l[1],e=void(jn.params[o.toLowerCase()]=l)),null===e&&(s=r),e}function bt(){var e;return null===(e=O())&&null===(e=oe())&&(e=z()),e}function Rt(){var e;return"render"===n.substr(s,6).toLowerCase()?(e=n.substr(s,6),s+=6):(e=null,0===a&&u('"render"')),null===e&&("session"===n.substr(s,7).toLowerCase()?(e=n.substr(s,7),s+=7):(e=null,0===a&&u('"session"')),null===e&&("icon"===n.substr(s,4).toLowerCase()?(e=n.substr(s,4),s+=4):(e=null,0===a&&u('"icon"')),null===e&&("alert"===n.substr(s,5).toLowerCase()?(e=n.substr(s,5),s+=5):(e=null,0===a&&u('"alert"')),null===e&&(e=O())))),e}function wt(){var e;return null===(e=At())&&(e=Et()),e}function At(){var e,t,r,i;return i=s,"handling"===n.substr(s,8).toLowerCase()?(e=n.substr(s,8),s+=8):(e=null,0===a&&u('"handling"')),null!==e&&null!==(t=U())?("optional"===n.substr(s,8).toLowerCase()?(r=n.substr(s,8),s+=8):(r=null,0===a&&u('"optional"')),null===r&&("required"===n.substr(s,8).toLowerCase()?(r=n.substr(s,8),s+=8):(r=null,0===a&&u('"required"')),null===r&&(r=O())),null!==r?e=[e,t,r]:(e=null,s=i)):(e=null,s=i),e}function It(){var e,t,n,r,i,a,o,l;if(o=s,null!==(e=kt()))if(null!==(t=M()))if(null!==(n=Dt())){for(r=[],l=s,null!==(i=G())&&null!==(a=Mt())?i=[i,a]:(i=null,s=l);null!==i;)r.push(i),l=s,null!==(i=G())&&null!==(a=Mt())?i=[i,a]:(i=null,s=l);null!==r?e=[e,t,n,r]:(e=null,s=o)}else e=null,s=o;else e=null,s=o;else e=null,s=o;return e}function kt(){var e;return null===(e=Pt())&&(e=Ot()),e}function Pt(){var e;return"text"===n.substr(s,4).toLowerCase()?(e=n.substr(s,4),s+=4):(e=null,0===a&&u('"text"')),null===e&&("image"===n.substr(s,5).toLowerCase()?(e=n.substr(s,5),s+=5):(e=null,0===a&&u('"image"')),null===e&&("audio"===n.substr(s,5).toLowerCase()?(e=n.substr(s,5),s+=5):(e=null,0===a&&u('"audio"')),null===e&&("video"===n.substr(s,5).toLowerCase()?(e=n.substr(s,5),s+=5):(e=null,0===a&&u('"video"')),null===e&&("application"===n.substr(s,11).toLowerCase()?(e=n.substr(s,11),s+=11):(e=null,0===a&&u('"application"')),null===e&&(e=Nt()))))),e}function Ot(){var e;return"message"===n.substr(s,7).toLowerCase()?(e=n.substr(s,7),s+=7):(e=null,0===a&&u('"message"')),null===e&&("multipart"===n.substr(s,9).toLowerCase()?(e=n.substr(s,9),s+=9):(e=null,0===a&&u('"multipart"')),null===e&&(e=Nt())),e}function Nt(){var e;return null===(e=O())&&(e=xt()),e}function xt(){var e,t,r;return r=s,"x-"===n.substr(s,2).toLowerCase()?(e=n.substr(s,2),s+=2):(e=null,0===a&&u('"x-"')),null!==e&&null!==(t=O())?e=[e,t]:(e=null,s=r),e}function Dt(){var e;return null===(e=Nt())&&(e=O()),e}function Mt(){var e,t,n,r;return r=s,null!==(e=O())&&null!==(t=U())&&null!==(n=Ut())?e=[e,t,n]:(e=null,s=r),e}function Ut(){var e;return null===(e=O())&&(e=z()),e}function Lt(){var e,t,n,r;if(n=s,null!==(t=d()))for(e=[];null!==t;)e.push(t),t=d();else e=null;return null!==e&&(r=e,e=void(jn.value=parseInt(r.join("")))),null===e&&(s=n),e}function Ht(){var e,t,r,i,o,l;if(o=s,null!==(e=N())){for(t=[],l=s,46===n.charCodeAt(s)?(r=".",s++):(r=null,0===a&&u('"."')),null!==r&&null!==(i=N())?r=[r,i]:(r=null,s=l);null!==r;)t.push(r),l=s,46===n.charCodeAt(s)?(r=".",s++):(r=null,0===a&&u('"."')),null!==r&&null!==(i=N())?r=[r,i]:(r=null,s=l);null!==t?e=[e,t]:(e=null,s=o)}else e=null,s=o;return e}function qt(){var e;return null===(e=jt())&&(e=Et()),e}function jt(){var e,t,r,i,o,l;return i=s,o=s,"tag"===n.substr(s,3).toLowerCase()?(e=n.substr(s,3),s+=3):(e=null,0===a&&u('"tag"')),null!==e&&null!==(t=U())&&null!==(r=O())?e=[e,t,r]:(e=null,s=o),null!==e&&(l=e[2],e=void(jn.tag=l)),null===e&&(s=i),e}function Ft(){var e,t,r,i,o,l,c,d;if(c=s,"digest"===n.substr(s,6).toLowerCase()?(e=n.substr(s,6),s+=6):(e=null,0===a&&u('"Digest"')),null!==e)if(null!==(t=b()))if(null!==(r=Jt())){for(i=[],d=s,null!==(o=F())&&null!==(l=Jt())?o=[o,l]:(o=null,s=d);null!==o;)i.push(o),d=s,null!==(o=F())&&null!==(l=Jt())?o=[o,l]:(o=null,s=d);null!==i?e=[e,t,r,i]:(e=null,s=c)}else e=null,s=c;else e=null,s=c;else e=null,s=c;return null===e&&(e=Gt()),e}function Gt(){var e,t,n,r,i,a,o,l;if(o=s,null!==(e=O()))if(null!==(t=b()))if(null!==(n=Bt())){for(r=[],l=s,null!==(i=F())&&null!==(a=Bt())?i=[i,a]:(i=null,s=l);null!==i;)r.push(i),l=s,null!==(i=F())&&null!==(a=Bt())?i=[i,a]:(i=null,s=l);null!==r?e=[e,t,n,r]:(e=null,s=o)}else e=null,s=o;else e=null,s=o;else e=null,s=o;return e}function Bt(){var e,t,n,r;return r=s,null!==(e=O())&&null!==(t=U())?(null===(n=O())&&(n=z()),null!==n?e=[e,t,n]:(e=null,s=r)):(e=null,s=r),e}function Jt(){var e;return null===(e=Wt())&&null===(e=zt())&&null===(e=$t())&&null===(e=Xt())&&null===(e=Qt())&&null===(e=Zt())&&null===(e=en())&&(e=Bt()),e}function Wt(){var e,t,r,i;return i=s,"realm"===n.substr(s,5).toLowerCase()?(e=n.substr(s,5),s+=5):(e=null,0===a&&u('"realm"')),null!==e&&null!==(t=U())&&null!==(r=Vt())?e=[e,t,r]:(e=null,s=i),e}function Vt(){var e,t,n;return t=s,null!==(e=Y())&&(n=e,e=void(jn.realm=n)),null===e&&(s=t),e}function zt(){var e,t,r,i,o,l,c,d,h;if(d=s,"domain"===n.substr(s,6).toLowerCase()?(e=n.substr(s,6),s+=6):(e=null,0===a&&u('"domain"')),null!==e)if(null!==(t=U()))if(null!==(r=J()))if(null!==(i=Yt())){if(o=[],h=s,null!==(c=v()))for(l=[];null!==c;)l.push(c),c=v();else l=null;for(null!==l&&null!==(c=Yt())?l=[l,c]:(l=null,s=h);null!==l;){if(o.push(l),h=s,null!==(c=v()))for(l=[];null!==c;)l.push(c),c=v();else l=null;null!==l&&null!==(c=Yt())?l=[l,c]:(l=null,s=h)}null!==o&&null!==(l=W())?e=[e,t,r,i,o,l]:(e=null,s=d)}else e=null,s=d;else e=null,s=d;else e=null,s=d;else e=null,s=d;return e}function Yt(){var e;return null===(e=He())&&(e=Fe()),e}function $t(){var e,t,r,i;return i=s,"nonce"===n.substr(s,5).toLowerCase()?(e=n.substr(s,5),s+=5):(e=null,0===a&&u('"nonce"')),null!==e&&null!==(t=U())&&null!==(r=Kt())?e=[e,t,r]:(e=null,s=i),e}function Kt(){var e,t,n;return t=s,null!==(e=Y())&&(n=e,e=void(jn.nonce=n)),null===e&&(s=t),e}function Xt(){var e,t,r,i,o,l;return i=s,o=s,"opaque"===n.substr(s,6).toLowerCase()?(e=n.substr(s,6),s+=6):(e=null,0===a&&u('"opaque"')),null!==e&&null!==(t=U())&&null!==(r=Y())?e=[e,t,r]:(e=null,s=o),null!==e&&(l=e[2],e=void(jn.opaque=l)),null===e&&(s=i),e}function Qt(){var e,t,r,i,o;return i=s,"stale"===n.substr(s,5).toLowerCase()?(e=n.substr(s,5),s+=5):(e=null,0===a&&u('"stale"')),null!==e&&null!==(t=U())?(o=s,"true"===n.substr(s,4).toLowerCase()?(r=n.substr(s,4),s+=4):(r=null,0===a&&u('"true"')),null!==r&&(r=void(jn.stale=!0)),null===r&&(s=o),null===r&&(o=s,"false"===n.substr(s,5).toLowerCase()?(r=n.substr(s,5),s+=5):(r=null,0===a&&u('"false"')),null!==r&&(r=void(jn.stale=!1)),null===r&&(s=o)),null!==r?e=[e,t,r]:(e=null,s=i)):(e=null,s=i),e}function Zt(){var e,t,r,i,o,l;return i=s,o=s,"algorithm"===n.substr(s,9).toLowerCase()?(e=n.substr(s,9),s+=9):(e=null,0===a&&u('"algorithm"')),null!==e&&null!==(t=U())?("md5"===n.substr(s,3).toLowerCase()?(r=n.substr(s,3),s+=3):(r=null,0===a&&u('"MD5"')),null===r&&("md5-sess"===n.substr(s,8).toLowerCase()?(r=n.substr(s,8),s+=8):(r=null,0===a&&u('"MD5-sess"')),null===r&&(r=O())),null!==r?e=[e,t,r]:(e=null,s=o)):(e=null,s=o),null!==e&&(l=e[2],e=void(jn.algorithm=l.toUpperCase())),null===e&&(s=i),e}function en(){var e,t,r,i,o,l,c,d,h,p;if(d=s,"qop"===n.substr(s,3).toLowerCase()?(e=n.substr(s,3),s+=3):(e=null,0===a&&u('"qop"')),null!==e)if(null!==(t=U()))if(null!==(r=J())){if(h=s,null!==(i=tn())){for(o=[],p=s,44===n.charCodeAt(s)?(l=",",s++):(l=null,0===a&&u('","')),null!==l&&null!==(c=tn())?l=[l,c]:(l=null,s=p);null!==l;)o.push(l),p=s,44===n.charCodeAt(s)?(l=",",s++):(l=null,0===a&&u('","')),null!==l&&null!==(c=tn())?l=[l,c]:(l=null,s=p);null!==o?i=[i,o]:(i=null,s=h)}else i=null,s=h;null!==i&&null!==(o=W())?e=[e,t,r,i,o]:(e=null,s=d)}else e=null,s=d;else e=null,s=d;else e=null,s=d;return e}function tn(){var e,t,r;return t=s,"auth-int"===n.substr(s,8).toLowerCase()?(e=n.substr(s,8),s+=8):(e=null,0===a&&u('"auth-int"')),null===e&&("auth"===n.substr(s,4).toLowerCase()?(e=n.substr(s,4),s+=4):(e=null,0===a&&u('"auth"')),null===e&&(e=O())),null!==e&&(r=e,jn.qop||(jn.qop=[]),e=void jn.qop.push(r.toLowerCase())),null===e&&(s=t),e}function nn(){var e,t,n,r,i,a,o;if(i=s,a=s,null!==(e=_t())){for(t=[],o=s,null!==(n=G())&&null!==(r=Et())?n=[n,r]:(n=null,s=o);null!==n;)t.push(n),o=s,null!==(n=G())&&null!==(r=Et())?n=[n,r]:(n=null,s=o);null!==t?e=[e,t]:(e=null,s=a)}else e=null,s=a;return null!==e&&(e=function(e){var t;jn.multi_header||(jn.multi_header=[]);try{t=new qn(jn.uri,jn.display_name,jn.params),delete jn.uri,delete jn.display_name,delete jn.params}catch(e){t=null}jn.multi_header.push({possition:s,offset:e,parsed:t})}(i)),null===e&&(s=i),e}function rn(){var e;return null===(e=sn())&&(e=Et()),e}function sn(){var e,t,r,i,o,l,c;if(o=s,l=s,"cause"===n.substr(s,5).toLowerCase()?(e=n.substr(s,5),s+=5):(e=null,0===a&&u('"cause"')),null!==e)if(null!==(t=U())){if(null!==(i=d()))for(r=[];null!==i;)r.push(i),i=d();else r=null;null!==r?e=[e,t,r]:(e=null,s=l)}else e=null,s=l;else e=null,s=l;return null!==e&&(c=e[2],e=void(jn.cause=parseInt(c.join("")))),null===e&&(s=o),e}function an(){var e,t,n,r,i,a;if(i=s,null!==(e=_t())){for(t=[],a=s,null!==(n=G())&&null!==(r=Et())?n=[n,r]:(n=null,s=a);null!==n;)t.push(n),a=s,null!==(n=G())&&null!==(r=Et())?n=[n,r]:(n=null,s=a);null!==t?e=[e,t]:(e=null,s=i)}else e=null,s=i;return e}function on(){var e,t,r;return t=s,"active"===n.substr(s,6).toLowerCase()?(e=n.substr(s,6),s+=6):(e=null,0===a&&u('"active"')),null===e&&("pending"===n.substr(s,7).toLowerCase()?(e=n.substr(s,7),s+=7):(e=null,0===a&&u('"pending"')),null===e&&("terminated"===n.substr(s,10).toLowerCase()?(e=n.substr(s,10),s+=10):(e=null,0===a&&u('"terminated"')),null===e&&(e=O()))),null!==e&&(r=t,e=void(jn.state=n.substring(s,r))),null===e&&(s=t),e}function ln(){var e,t,r,i,o,l,c,d;return i=s,o=s,"reason"===n.substr(s,6).toLowerCase()?(e=n.substr(s,6),s+=6):(e=null,0===a&&u('"reason"')),null!==e&&null!==(t=U())&&null!==(r=un())?e=[e,t,r]:(e=null,s=o),null!==e&&(e=void(void 0!==(l=e[2])&&(jn.reason=l))),null===e&&(s=i),null===e&&(i=s,o=s,"expires"===n.substr(s,7).toLowerCase()?(e=n.substr(s,7),s+=7):(e=null,0===a&&u('"expires"')),null!==e&&null!==(t=U())&&null!==(r=St())?e=[e,t,r]:(e=null,s=o),null!==e&&(e=void(void 0!==(d=e[2])&&(jn.expires=d))),null===e&&(s=i),null===e&&(i=s,o=s,"retry_after"===n.substr(s,11).toLowerCase()?(e=n.substr(s,11),s+=11):(e=null,0===a&&u('"retry_after"')),null!==e&&null!==(t=U())&&null!==(r=St())?e=[e,t,r]:(e=null,s=o),null!==e&&(e=void(void 0!==(c=e[2])&&(jn.retry_after=c))),null===e&&(s=i),null===e&&(e=Et()))),e}function un(){var e;return"deactivated"===n.substr(s,11).toLowerCase()?(e=n.substr(s,11),s+=11):(e=null,0===a&&u('"deactivated"')),null===e&&("probation"===n.substr(s,9).toLowerCase()?(e=n.substr(s,9),s+=9):(e=null,0===a&&u('"probation"')),null===e&&("rejected"===n.substr(s,8).toLowerCase()?(e=n.substr(s,8),s+=8):(e=null,0===a&&u('"rejected"')),null===e&&("timeout"===n.substr(s,7).toLowerCase()?(e=n.substr(s,7),s+=7):(e=null,0===a&&u('"timeout"')),null===e&&("giveup"===n.substr(s,6).toLowerCase()?(e=n.substr(s,6),s+=6):(e=null,0===a&&u('"giveup"')),null===e&&("noresource"===n.substr(s,10).toLowerCase()?(e=n.substr(s,10),s+=10):(e=null,0===a&&u('"noresource"')),null===e&&("invariant"===n.substr(s,9).toLowerCase()?(e=n.substr(s,9),s+=9):(e=null,0===a&&u('"invariant"')),null===e&&(e=O()))))))),e}function cn(){var e;return null===(e=jt())&&(e=Et()),e}function dn(){var e,t,n,r,i,a,o,l;if(o=s,null!==(e=gn()))if(null!==(t=b()))if(null!==(n=Sn())){for(r=[],l=s,null!==(i=G())&&null!==(a=hn())?i=[i,a]:(i=null,s=l);null!==i;)r.push(i),l=s,null!==(i=G())&&null!==(a=hn())?i=[i,a]:(i=null,s=l);null!==r?e=[e,t,n,r]:(e=null,s=o)}else e=null,s=o;else e=null,s=o;else e=null,s=o;return e}function hn(){var e;return null===(e=pn())&&null===(e=fn())&&null===(e=mn())&&null===(e=_n())&&null===(e=vn())&&(e=Et()),e}function pn(){var e,t,r,i,o,l;return i=s,o=s,"ttl"===n.substr(s,3).toLowerCase()?(e=n.substr(s,3),s+=3):(e=null,0===a&&u('"ttl"')),null!==e&&null!==(t=U())&&null!==(r=bn())?e=[e,t,r]:(e=null,s=o),null!==e&&(l=e[2],e=void(jn.ttl=l)),null===e&&(s=i),e}function fn(){var e,t,r,i,o,l;return i=s,o=s,"maddr"===n.substr(s,5).toLowerCase()?(e=n.substr(s,5),s+=5):(e=null,0===a&&u('"maddr"')),null!==e&&null!==(t=U())&&null!==(r=oe())?e=[e,t,r]:(e=null,s=o),null!==e&&(l=e[2],e=void(jn.maddr=l)),null===e&&(s=i),e}function mn(){var e,t,r,i,o,l;return i=s,o=s,"received"===n.substr(s,8).toLowerCase()?(e=n.substr(s,8),s+=8):(e=null,0===a&&u('"received"')),null!==e&&null!==(t=U())?(null===(r=me())&&(r=he()),null!==r?e=[e,t,r]:(e=null,s=o)):(e=null,s=o),null!==e&&(l=e[2],e=void(jn.received=l)),null===e&&(s=i),e}function _n(){var e,t,r,i,o,l;return i=s,o=s,"branch"===n.substr(s,6).toLowerCase()?(e=n.substr(s,6),s+=6):(e=null,0===a&&u('"branch"')),null!==e&&null!==(t=U())&&null!==(r=O())?e=[e,t,r]:(e=null,s=o),null!==e&&(l=e[2],e=void(jn.branch=l)),null===e&&(s=i),e}function vn(){var e,t,r,i,o,l,c;if(o=s,l=s,"rport"===n.substr(s,5).toLowerCase()?(e=n.substr(s,5),s+=5):(e=null,0===a&&u('"rport"')),null!==e){if(c=s,null!==(t=U())){for(r=[],i=d();null!==i;)r.push(i),i=d();null!==r?t=[t,r]:(t=null,s=c)}else t=null,s=c;null!==(t=null!==t?t:"")?e=[e,t]:(e=null,s=l)}else e=null,s=l;return null!==e&&(e=void("undefined"!=typeof response_port&&(jn.rport=response_port.join("")))),null===e&&(s=o),e}function gn(){var e,t,n,r,i,a;return a=s,null!==(e=yn())&&null!==(t=M())&&null!==(n=O())&&null!==(r=M())&&null!==(i=Tn())?e=[e,t,n,r,i]:(e=null,s=a),e}function yn(){var e,t,r;return t=s,"sip"===n.substr(s,3).toLowerCase()?(e=n.substr(s,3),s+=3):(e=null,0===a&&u('"SIP"')),null===e&&(e=O()),null!==e&&(r=e,e=void(jn.protocol=r)),null===e&&(s=t),e}function Tn(){var e,t,r;return t=s,"udp"===n.substr(s,3).toLowerCase()?(e=n.substr(s,3),s+=3):(e=null,0===a&&u('"UDP"')),null===e&&("tcp"===n.substr(s,3).toLowerCase()?(e=n.substr(s,3),s+=3):(e=null,0===a&&u('"TCP"')),null===e&&("tls"===n.substr(s,3).toLowerCase()?(e=n.substr(s,3),s+=3):(e=null,0===a&&u('"TLS"')),null===e&&("sctp"===n.substr(s,4).toLowerCase()?(e=n.substr(s,4),s+=4):(e=null,0===a&&u('"SCTP"')),null===e&&(e=O())))),null!==e&&(r=e,e=void(jn.transport=r)),null===e&&(s=t),e}function Sn(){var e,t,n,r,i;return r=s,null!==(e=Cn())?(i=s,null!==(t=B())&&null!==(n=En())?t=[t,n]:(t=null,s=i),null!==(t=null!==t?t:"")?e=[e,t]:(e=null,s=r)):(e=null,s=r),e}function Cn(){var e,t,r;return t=s,null===(e=me())&&null===(e=de())&&(e=le()),null!==e&&(r=t,e=void(jn.host=n.substring(s,r))),null===e&&(s=t),e}function En(){var e,t,n,r,i,a,o,l;return a=s,o=s,null!==(e=null!==(e=d())?e:"")&&null!==(t=null!==(t=d())?t:"")&&null!==(n=null!==(n=d())?n:"")&&null!==(r=null!==(r=d())?r:"")&&null!==(i=null!==(i=d())?i:"")?e=[e,t,n,r,i]:(e=null,s=o),null!==e&&(l=e,e=void(jn.port=parseInt(l.join("")))),null===e&&(s=a),e}function bn(){var e,t,n,r,i;return r=s,i=s,null!==(e=d())&&null!==(t=null!==(t=d())?t:"")&&null!==(n=null!==(n=d())?n:"")?e=[e,t,n]:(e=null,s=i),null!==e&&(e=parseInt(e.join(""))),null===e&&(s=r),e}function Rn(){var e,t,n;return t=s,null!==(e=St())&&(n=e,e=void(jn.expires=n)),null===e&&(s=t),e}function wn(){var e;return null===(e=An())&&(e=Et()),e}function An(){var e,t,r,i,o,l;return i=s,o=s,"refresher"===n.substr(s,9).toLowerCase()?(e=n.substr(s,9),s+=9):(e=null,0===a&&u('"refresher"')),null!==e&&null!==(t=U())?("uac"===n.substr(s,3).toLowerCase()?(r=n.substr(s,3),s+=3):(r=null,0===a&&u('"uac"')),null===r&&("uas"===n.substr(s,3).toLowerCase()?(r=n.substr(s,3),s+=3):(r=null,0===a&&u('"uas"'))),null!==r?e=[e,t,r]:(e=null,s=o)):(e=null,s=o),null!==e&&(l=e[2],e=void(jn.refresher=l.toLowerCase())),null===e&&(s=i),e}function In(){var e,t;for(e=[],null===(t=I())&&null===(t=P())&&(t=b());null!==t;)e.push(t),null===(t=I())&&null===(t=P())&&(t=b());return e}function kn(){var e,t,r,i,o,l,c,d,h,p,f,m;return p=s,f=s,null!==(e=On())?(45===n.charCodeAt(s)?(t="-",s++):(t=null,0===a&&u('"-"')),null!==t&&null!==(r=Pn())?(45===n.charCodeAt(s)?(i="-",s++):(i=null,0===a&&u('"-"')),null!==i&&null!==(o=Pn())?(45===n.charCodeAt(s)?(l="-",s++):(l=null,0===a&&u('"-"')),null!==l&&null!==(c=Pn())?(45===n.charCodeAt(s)?(d="-",s++):(d=null,0===a&&u('"-"')),null!==d&&null!==(h=Nn())?e=[e,t,r,i,o,l,c,d,h]:(e=null,s=f)):(e=null,s=f)):(e=null,s=f)):(e=null,s=f)):(e=null,s=f),null!==e&&(m=p,e[0],e=void(jn=n.substring(s+5,m))),null===e&&(s=p),e}function Pn(){var e,t,n,r,i;return i=s,null!==(e=p())&&null!==(t=p())&&null!==(n=p())&&null!==(r=p())?e=[e,t,n,r]:(e=null,s=i),e}function On(){var e,t,n;return n=s,null!==(e=Pn())&&null!==(t=Pn())?e=[e,t]:(e=null,s=n),e}function Nn(){var e,t,n,r;return r=s,null!==(e=Pn())&&null!==(t=Pn())&&null!==(n=Pn())?e=[e,t,n]:(e=null,s=r),e}function xn(){var e,t,r,i,o,l,c;return i=s,o=s,null!==(e=x())?(l=s,64===n.charCodeAt(s)?(t="@",s++):(t=null,0===a&&u('"@"')),null!==t&&null!==(r=x())?t=[t,r]:(t=null,s=l),null!==(t=null!==t?t:"")?e=[e,t]:(e=null,s=o)):(e=null,s=o),null!==e&&(c=i,e=void(jn.call_id=n.substring(s,c))),null===e&&(s=i),e}function Dn(){var e;return null===(e=Mn())&&null===(e=Un())&&null===(e=Ln())&&(e=Et()),e}function Mn(){var e,t,r,i,o,l;return i=s,o=s,"to-tag"===n.substr(s,6)?(e="to-tag",s+=6):(e=null,0===a&&u('"to-tag"')),null!==e&&null!==(t=U())&&null!==(r=O())?e=[e,t,r]:(e=null,s=o),null!==e&&(l=e[2],e=void(jn.to_tag=l)),null===e&&(s=i),e}function Un(){var e,t,r,i,o,l;return i=s,o=s,"from-tag"===n.substr(s,8)?(e="from-tag",s+=8):(e=null,0===a&&u('"from-tag"')),null!==e&&null!==(t=U())&&null!==(r=O())?e=[e,t,r]:(e=null,s=o),null!==e&&(l=e[2],e=void(jn.from_tag=l)),null===e&&(s=i),e}function Ln(){var e,t;return t=s,"early-only"===n.substr(s,10)?(e="early-only",s+=10):(e=null,0===a&&u('"early-only"')),null!==e&&(e=void(jn.early_only=!0)),null===e&&(s=t),e}var Hn=e("./URI"),qn=e("./NameAddrHeader"),jn={};if(null===i[r]()||s!==n.length){var Fn=Math.max(s,o),Gn=Fn<n.length?n.charAt(Fn):null,Bn=function(){for(var e=1,t=1,r=!1,i=0;i<Math.max(s,o);i++){var a=n.charAt(i);"\n"===a?(r||e++,t=1,r=!1):"\r"===a||"\u2028"===a||"\u2029"===a?(e++,t=1,r=!0):(t++,r=!1)}return{line:e,column:t}}();return new this.SyntaxError(function(e){e.sort();for(var t=null,n=[],r=0;r<e.length;r++)e[r]!==t&&(n.push(e[r]),t=e[r]);return n}(l),Gn,Fn,Bn.line,Bn.column),-1}return jn},toSource:function(){return this._source},SyntaxError:function(e,n,r,i,s){this.name="SyntaxError",this.expected=e,this.found=n,this.message=function(e,n){var r;switch(e.length){case 0:r="end of input";break;case 1:r=e[0];break;default:r=e.slice(0,e.length-1).join(", ")+" or "+e[e.length-1]}return"Expected "+r+" but "+(n?t(n):"end of input")+" found."}(e,n),this.offset=r,this.line=i,this.column=s}};return n.SyntaxError.prototype=Error.prototype,n}()},{"./NameAddrHeader":13,"./URI":28}],11:[function(e,t,n){"use strict";var r=e("webrtc-adapter"),i=e("../package.json"),s=e("./Constants"),a=e("./Exceptions"),o=e("./Utils"),l=e("./UA"),u=e("./URI"),c=e("./NameAddrHeader"),d=e("./Grammar"),h=e("./WebSocketInterface");e("debug")("JsSIP")("version %s",i.version),t.exports={C:s,Exceptions:a,Utils:o,UA:l,URI:u,NameAddrHeader:c,WebSocketInterface:h,Grammar:d,debug:e("debug"),adapter:r,get name(){return i.title},get version(){return i.version}}},{"../package.json":32,"./Constants":5,"./Exceptions":9,"./Grammar":10,"./NameAddrHeader":13,"./UA":27,"./URI":28,"./Utils":29,"./WebSocketInterface":30,debug:2,"webrtc-adapter":42}],12:[function(e,t,n){"use strict";var r=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}();var i=e("events").EventEmitter,s=e("./Constants"),a=e("./SIPMessage"),o=e("./Utils"),l=e("./RequestSender"),u=e("./Exceptions"),c=e("debug")("JsSIP:Message");t.exports=function(e){function t(e){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t);var n=function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}(this,(t.__proto__||Object.getPrototypeOf(t)).call(this));return n._ua=e,n._request=null,n._closed=!1,n._direction=null,n._local_identity=null,n._remote_identity=null,n._is_replied=!1,n._data={},n}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}(t,i),r(t,[{key:"send",value:function(e,t){var n=this,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},i=e;if(void 0===e||void 0===t)throw new TypeError("Not enough arguments");if(!(e=this._ua.normalizeTarget(e)))throw new TypeError("Invalid target: "+i);var u=o.cloneArray(r.extraHeaders),c=r.eventHandlers||{},d=r.contentType||"text/plain";for(var h in c)Object.prototype.hasOwnProperty.call(c,h)&&this.on(h,c[h]);u.push("Content-Type: "+d),this._request=new a.OutgoingRequest(s.MESSAGE,e,this._ua,null,u),t&&(this._request.body=t);var p=new l(this._ua,this._request,{onRequestTimeout:function(){n._onRequestTimeout()},onTransportError:function(){n._onTransportError()},onReceiveResponse:function(e){n._receiveResponse(e)}});this._newMessage("local",this._request),p.send()}},{key:"init_incoming",value:function(e){this._request=e,this._newMessage("remote",e),this._is_replied||(this._is_replied=!0,e.reply(200)),this._close()}},{key:"accept",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=o.cloneArray(e.extraHeaders),n=e.body;if("incoming"!==this._direction)throw new u.NotSupportedError('"accept" not supported for outgoing Message');if(this._is_replied)throw new Error("incoming Message already replied");this._is_replied=!0,this._request.reply(200,null,t,n)}},{key:"reject",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.status_code||480,n=e.reason_phrase,r=o.cloneArray(e.extraHeaders),i=e.body;if("incoming"!==this._direction)throw new u.NotSupportedError('"reject" not supported for outgoing Message');if(this._is_replied)throw new Error("incoming Message already replied");if(t<300||t>=700)throw new TypeError("Invalid status_code: "+t);this._is_replied=!0,this._request.reply(t,n,r,i)}},{key:"_receiveResponse",value:function(e){if(!this._closed)switch(!0){case/^1[0-9]{2}$/.test(e.status_code):break;case/^2[0-9]{2}$/.test(e.status_code):this._succeeded("remote",e);break;default:var t=o.sipErrorCause(e.status_code);this._failed("remote",e,t)}}},{key:"_onRequestTimeout",value:function(){this._closed||this._failed("system",null,s.causes.REQUEST_TIMEOUT)}},{key:"_onTransportError",value:function(){this._closed||this._failed("system",null,s.causes.CONNECTION_ERROR)}},{key:"_close",value:function(){this._closed=!0,this._ua.destroyMessage(this)}},{key:"_newMessage",value:function(e,t){"remote"===e?(this._direction="incoming",this._local_identity=t.to,this._remote_identity=t.from):"local"===e&&(this._direction="outgoing",this._local_identity=t.from,this._remote_identity=t.to),this._ua.newMessage(this,{originator:e,message:this,request:t})}},{key:"_failed",value:function(e,t,n){c("MESSAGE failed"),this._close(),c('emit "failed"'),this.emit("failed",{originator:e,response:t||null,cause:n})}},{key:"_succeeded",value:function(e,t){c("MESSAGE succeeded"),this._close(),c('emit "succeeded"'),this.emit("succeeded",{originator:e,response:t})}},{key:"direction",get:function(){return this._direction}},{key:"local_identity",get:function(){return this._local_identity}},{key:"remote_identity",get:function(){return this._remote_identity}}]),t}()},{"./Constants":5,"./Exceptions":9,"./RequestSender":21,"./SIPMessage":22,"./Utils":29,debug:2,events:1}],13:[function(e,t,n){"use strict";var r=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}();var i=e("./URI"),s=e("./Grammar");t.exports=function(){function e(t,n,r){if(function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),!(t&&t instanceof i))throw new TypeError('missing or invalid "uri" parameter');for(var s in this._uri=t,this._parameters={},this._display_name=n,r)Object.prototype.hasOwnProperty.call(r,s)&&this.setParam(s,r[s])}return r(e,null,[{key:"parse",value:function(e){return-1!==(e=s.parse(e,"Name_Addr_Header"))?e:void 0}}]),r(e,[{key:"setParam",value:function(e,t){e&&(this._parameters[e.toLowerCase()]=null==t?null:t.toString())}},{key:"getParam",value:function(e){if(e)return this._parameters[e.toLowerCase()]}},{key:"hasParam",value:function(e){if(e)return!!this._parameters.hasOwnProperty(e.toLowerCase())}},{key:"deleteParam",value:function(e){if(e=e.toLowerCase(),this._parameters.hasOwnProperty(e)){var t=this._parameters[e];return delete this._parameters[e],t}}},{key:"clearParams",value:function(){this._parameters={}}},{key:"clone",value:function(){return new e(this._uri.clone(),this._display_name,JSON.parse(JSON.stringify(this._parameters)))}},{key:"toString",value:function(){var e=this._display_name||0===this._display_name?'"'+this._display_name+'" ':"";for(var t in e+="<"+this._uri.toString()+">",this._parameters)Object.prototype.hasOwnProperty.call(this._parameters,t)&&(e+=";"+t,null!==this._parameters[t]&&(e+="="+this._parameters[t]));return e}},{key:"uri",get:function(){return this._uri}},{key:"display_name",get:function(){return this._display_name},set:function(e){this._display_name=0===e?"0":e}}]),e}()},{"./Grammar":10,"./URI":28}],14:[function(e,t,n){"use strict";var r=e("./Grammar"),i=e("./SIPMessage"),s=e("debug")("JsSIP:ERROR:Parser");function a(e,t){var n=t,r=0,i=0;if(e.substring(n,n+2).match(/(^\r\n)/))return-2;for(;0===r;){if(-1===(i=e.indexOf("\r\n",n)))return i;!e.substring(i+2,i+4).match(/(^\r\n)/)&&e.charAt(i+2).match(/(^\s+)/)?n=i+2:r=i}return r}function o(e,t,n,s){var a=void 0,o=t.indexOf(":",n),l=t.substring(n,o).trim(),u=t.substring(o+1,s).trim();switch(l.toLowerCase()){case"via":case"v":e.addHeader("via",u),1===e.getHeaders("via").length?(a=e.parseHeader("Via"))&&(e.via=a,e.via_branch=a.branch):a=0;break;case"from":case"f":e.setHeader("from",u),(a=e.parseHeader("from"))&&(e.from=a,e.from_tag=a.getParam("tag"));break;case"to":case"t":e.setHeader("to",u),(a=e.parseHeader("to"))&&(e.to=a,e.to_tag=a.getParam("tag"));break;case"record-route":if(-1===(a=r.parse(u,"Record_Route")))a=void 0;else{var c=!0,d=!1,h=void 0;try{for(var p,f=a[Symbol.iterator]();!(c=(p=f.next()).done);c=!0){var m=p.value;e.addHeader("record-route",u.substring(m.possition,m.offset)),e.headers["Record-Route"][e.getHeaders("record-route").length-1].parsed=m.parsed}}catch(e){d=!0,h=e}finally{try{!c&&f.return&&f.return()}finally{if(d)throw h}}}break;case"call-id":case"i":e.setHeader("call-id",u),(a=e.parseHeader("call-id"))&&(e.call_id=u);break;case"contact":case"m":if(-1===(a=r.parse(u,"Contact")))a=void 0;else{var _=!0,v=!1,g=void 0;try{for(var y,T=a[Symbol.iterator]();!(_=(y=T.next()).done);_=!0){var S=y.value;e.addHeader("contact",u.substring(S.possition,S.offset)),e.headers.Contact[e.getHeaders("contact").length-1].parsed=S.parsed}}catch(e){v=!0,g=e}finally{try{!_&&T.return&&T.return()}finally{if(v)throw g}}}break;case"content-length":case"l":e.setHeader("content-length",u),a=e.parseHeader("content-length");break;case"content-type":case"c":e.setHeader("content-type",u),a=e.parseHeader("content-type");break;case"cseq":e.setHeader("cseq",u),(a=e.parseHeader("cseq"))&&(e.cseq=a.value),e instanceof i.IncomingResponse&&(e.method=a.method);break;case"max-forwards":e.setHeader("max-forwards",u),a=e.parseHeader("max-forwards");break;case"www-authenticate":e.setHeader("www-authenticate",u),a=e.parseHeader("www-authenticate");break;case"proxy-authenticate":e.setHeader("proxy-authenticate",u),a=e.parseHeader("proxy-authenticate");break;case"session-expires":case"x":e.setHeader("session-expires",u),(a=e.parseHeader("session-expires"))&&(e.session_expires=a.expires,e.session_expires_refresher=a.refresher);break;case"refer-to":case"r":e.setHeader("refer-to",u),(a=e.parseHeader("refer-to"))&&(e.refer_to=a);break;case"replaces":e.setHeader("replaces",u),(a=e.parseHeader("replaces"))&&(e.replaces=a);break;case"event":case"o":e.setHeader("event",u),(a=e.parseHeader("event"))&&(e.event=a);break;default:e.addHeader(l,u),a=0}return void 0!==a||{error:'error parsing header "'+l+'"'}}s.log=console.warn.bind(console),n.parseMessage=function(e,t){var n=void 0,l=void 0,u=e.indexOf("\r\n");if(-1!==u){var c=e.substring(0,u),d=r.parse(c,"Request_Response");if(-1!==d){d.status_code?((n=new i.IncomingResponse).status_code=d.status_code,n.reason_phrase=d.reason_phrase):((n=new i.IncomingRequest(t)).method=d.method,n.ruri=d.uri),n.data=e;for(var h=u+2;;){if(-2===(u=a(e,h))){l=h+2;break}if(-1===u)return void s("parseMessage() | malformed message");if(!0!==(d=o(n,e,h,u)))return void s("parseMessage() |",d.error);h=u+2}if(n.hasHeader("content-length")){var p=n.getHeader("content-length");n.body=e.substr(l,p)}else n.body=e.substring(l);return n}s('parseMessage() | error parsing first line of SIP message: "'+c+'"')}else s("parseMessage() | no CRLF found, not a SIP message")}},{"./Grammar":10,"./SIPMessage":22,debug:2}],15:[function(e,t,n){"use strict";var r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},i=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}();var s=e("events").EventEmitter,a=e("sdp-transform"),o=e("./Constants"),l=e("./Exceptions"),u=e("./Transactions"),c=e("./Utils"),d=e("./Timers"),h=e("./SIPMessage"),p=e("./Dialog"),f=e("./RequestSender"),m=e("./RTCSession/DTMF"),_=e("./RTCSession/Info"),v=e("./RTCSession/ReferNotifier"),g=e("./RTCSession/ReferSubscriber"),y=e("debug")("JsSIP:RTCSession"),T=e("debug")("JsSIP:ERROR:RTCSession");T.log=console.warn.bind(console);var S={STATUS_NULL:0,STATUS_INVITE_SENT:1,STATUS_1XX_RECEIVED:2,STATUS_INVITE_RECEIVED:3,STATUS_WAITING_FOR_ANSWER:4,STATUS_ANSWERED:5,STATUS_WAITING_FOR_ACK:6,STATUS_CANCELED:7,STATUS_TERMINATED:8,STATUS_CONFIRMED:9},C=["audio","video"];t.exports=function(e){function t(e){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),y("new");var n=function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}(this,(t.__proto__||Object.getPrototypeOf(t)).call(this));return n._id=null,n._ua=e,n._status=S.STATUS_NULL,n._dialog=null,n._earlyDialogs={},n._contact=null,n._from_tag=null,n._to_tag=null,n._connection=null,n._connectionPromiseQueue=Promise.resolve(),n._request=null,n._is_canceled=!1,n._cancel_reason="",n._is_confirmed=!1,n._late_sdp=!1,n._rtcOfferConstraints=null,n._rtcAnswerConstraints=null,n._localMediaStream=null,n._localMediaStreamLocallyGenerated=!1,n._rtcReady=!0,n._timers={ackTimer:null,expiresTimer:null,invite2xxTimer:null,userNoAnswerTimer:null},n._direction=null,n._local_identity=null,n._remote_identity=null,n._start_time=null,n._end_time=null,n._tones=null,n._audioMuted=!1,n._videoMuted=!1,n._localHold=!1,n._remoteHold=!1,n._sessionTimers={enabled:n._ua.configuration.session_timers,refreshMethod:n._ua.configuration.session_timers_refresh_method,defaultExpires:o.SESSION_EXPIRES,currentExpires:null,running:!1,refresher:!1,timer:null},n._referSubscribers={},n._data={},n}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}(t,s),i(t,null,[{key:"C",get:function(){return S}}]),i(t,[{key:"isInProgress",value:function(){switch(this._status){case S.STATUS_NULL:case S.STATUS_INVITE_SENT:case S.STATUS_1XX_RECEIVED:case S.STATUS_INVITE_RECEIVED:case S.STATUS_WAITING_FOR_ANSWER:return!0;default:return!1}}},{key:"isEstablished",value:function(){switch(this._status){case S.STATUS_ANSWERED:case S.STATUS_WAITING_FOR_ACK:case S.STATUS_CONFIRMED:return!0;default:return!1}}},{key:"isEnded",value:function(){switch(this._status){case S.STATUS_CANCELED:case S.STATUS_TERMINATED:return!0;default:return!1}}},{key:"isMuted",value:function(){return{audio:this._audioMuted,video:this._videoMuted}}},{key:"isOnHold",value:function(){return{local:this._localHold,remote:this._remoteHold}}},{key:"connect",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments[2];y("connect()");var r=e,i=t.eventHandlers||{},s=c.cloneArray(t.extraHeaders),a=t.mediaConstraints||{audio:!0,video:!0},u=t.mediaStream||null,d=t.pcConfig||{iceServers:[]},p=t.rtcConstraints||null,f=t.rtcOfferConstraints||null;if(this._rtcOfferConstraints=f,this._rtcAnswerConstraints=t.rtcAnswerConstraints||null,this._data=t.data||this._data,void 0===e)throw new TypeError("Not enough arguments");if(this._status!==S.STATUS_NULL)throw new l.InvalidStateError(this._status);if(!window.RTCPeerConnection)throw new l.NotSupportedError("WebRTC not supported");if(!(e=this._ua.normalizeTarget(e)))throw new TypeError("Invalid target: "+r);for(var m in this._sessionTimers.enabled&&c.isDecimal(t.sessionTimersExpires)&&(t.sessionTimersExpires>=o.MIN_SESSION_EXPIRES?this._sessionTimers.defaultExpires=t.sessionTimersExpires:this._sessionTimers.defaultExpires=o.SESSION_EXPIRES),i)Object.prototype.hasOwnProperty.call(i,m)&&this.on(m,i[m]);this._from_tag=c.newTag();var _=t.anonymous||!1,v={from_tag:this._from_tag};this._contact=this._ua.contact.toString({anonymous:_,outbound:!0}),_&&(v.from_display_name="Anonymous",v.from_uri="sip:anonymous@anonymous.invalid",s.push("P-Preferred-Identity: "+this._ua.configuration.uri.toString()),s.push("Privacy: id")),s.push("Contact: "+this._contact),s.push("Content-Type: application/sdp"),this._sessionTimers.enabled&&s.push("Session-Expires: "+this._sessionTimers.defaultExpires),this._request=new h.InitialOutgoingInviteRequest(e,this._ua,v,s),this._id=this._request.call_id+this._from_tag,this._createRTCConnection(d,p),this._direction="outgoing",this._local_identity=this._request.from,this._remote_identity=this._request.to,n&&n(this),this._newRTCSession("local",this._request),this._sendInitialRequest(a,f,u)}},{key:"init_incoming",value:function(e,t){var n=this;y("init_incoming()");var r=void 0,i=e.getHeader("Content-Type");e.body&&"application/sdp"!==i?e.reply(415):(this._status=S.STATUS_INVITE_RECEIVED,this._from_tag=e.from_tag,this._id=e.call_id+this._from_tag,this._request=e,this._contact=this._ua.contact.toString(),e.hasHeader("expires")&&(r=1e3*e.getHeader("expires")),e.to_tag=c.newTag(),this._createDialog(e,"UAS",!0)?(e.body?this._late_sdp=!1:this._late_sdp=!0,this._status=S.STATUS_WAITING_FOR_ANSWER,this._timers.userNoAnswerTimer=setTimeout(function(){e.reply(408),n._failed("local",null,o.causes.NO_ANSWER)},this._ua.configuration.no_answer_timeout),r&&(this._timers.expiresTimer=setTimeout(function(){n._status===S.STATUS_WAITING_FOR_ANSWER&&(e.reply(487),n._failed("system",null,o.causes.EXPIRES))},r)),this._direction="incoming",this._local_identity=e.to,this._remote_identity=e.from,t&&t(this),this._newRTCSession("remote",e),this._status!==S.STATUS_TERMINATED&&(e.reply(180,null,["Contact: "+this._contact]),this._progress("local",null))):e.reply(500,"Missing Contact header field"))}},{key:"answer",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};y("answer()");var n=this._request,r=c.cloneArray(t.extraHeaders),i=t.mediaConstraints||{},s=t.mediaStream||null,a=t.pcConfig||{iceServers:[]},u=t.rtcConstraints||null,d=t.rtcAnswerConstraints||null,h=void 0,p=!1,f=!1,m=!1,_=!1;if(this._rtcAnswerConstraints=d,this._rtcOfferConstraints=t.rtcOfferConstraints||null,this._data=t.data||this._data,"incoming"!==this._direction)throw new l.NotSupportedError('"answer" not supported for outgoing RTCSession');if(this._status!==S.STATUS_WAITING_FOR_ANSWER)throw new l.InvalidStateError(this._status);if(this._sessionTimers.enabled&&c.isDecimal(t.sessionTimersExpires)&&(t.sessionTimersExpires>=o.MIN_SESSION_EXPIRES?this._sessionTimers.defaultExpires=t.sessionTimersExpires:this._sessionTimers.defaultExpires=o.SESSION_EXPIRES),this._status=S.STATUS_ANSWERED,this._createDialog(n,"UAS")){clearTimeout(this._timers.userNoAnswerTimer),r.unshift("Contact: "+this._contact);var v=n.parseSDP();Array.isArray(v.media)||(v.media=[v.media]);var g=!0,C=!1,E=void 0;try{for(var b,R=v.media[Symbol.iterator]();!(g=(b=R.next()).done);g=!0){var w=b.value;"audio"===w.type&&(p=!0,w.direction&&"sendrecv"!==w.direction||(m=!0)),"video"===w.type&&(f=!0,w.direction&&"sendrecv"!==w.direction||(_=!0))}}catch(e){C=!0,E=e}finally{try{!g&&R.return&&R.return()}finally{if(C)throw E}}if(s&&!1===i.audio){h=s.getAudioTracks();var A=!0,I=!1,k=void 0;try{for(var P,O=h[Symbol.iterator]();!(A=(P=O.next()).done);A=!0){var N=P.value;s.removeTrack(N)}}catch(e){I=!0,k=e}finally{try{!A&&O.return&&O.return()}finally{if(I)throw k}}}if(s&&!1===i.video){h=s.getVideoTracks();var x=!0,D=!1,M=void 0;try{for(var U,L=h[Symbol.iterator]();!(x=(U=L.next()).done);x=!0){var H=U.value;s.removeTrack(H)}}catch(e){D=!0,M=e}finally{try{!x&&L.return&&L.return()}finally{if(D)throw M}}}s||void 0!==i.audio||(i.audio=m),s||void 0!==i.video||(i.video=_),s||p||(i.audio=!1),s||f||(i.video=!1),this._createRTCConnection(a,u),Promise.resolve().then(function(){return s||(i.audio||i.video?(e._localMediaStreamLocallyGenerated=!0,navigator.mediaDevices.getUserMedia(i).catch(function(t){if(e._status===S.STATUS_TERMINATED)throw new Error("terminated");throw n.reply(480),e._failed("local",null,o.causes.USER_DENIED_MEDIA_ACCESS),T('emit "getusermediafailed" [error:%o]',t),e.emit("getusermediafailed",t),new Error("getUserMedia() failed")})):void 0)}).then(function(t){if(e._status===S.STATUS_TERMINATED)throw new Error("terminated");e._localMediaStream=t,t&&e._connection.addStream(t)}).then(function(){if(!e._late_sdp){var t={originator:"remote",type:"offer",sdp:n.body};y('emit "sdp"'),e.emit("sdp",t);var r=new RTCSessionDescription({type:"offer",sdp:t.sdp});return e._connectionPromiseQueue=e._connectionPromiseQueue.then(function(){return e._connection.setRemoteDescription(r)}).catch(function(t){throw n.reply(488),e._failed("system",null,o.causes.WEBRTC_ERROR),T('emit "peerconnection:setremotedescriptionfailed" [error:%o]',t),e.emit("peerconnection:setremotedescriptionfailed",t),new Error("peerconnection.setRemoteDescription() failed")}),e._connectionPromiseQueue}}).then(function(){if(e._status===S.STATUS_TERMINATED)throw new Error("terminated");return e._connecting(n),e._late_sdp?e._createLocalDescription("offer",e._rtcOfferConstraints).catch(function(){throw n.reply(500),new Error("_createLocalDescription() failed")}):e._createLocalDescription("answer",d).catch(function(){throw n.reply(500),new Error("_createLocalDescription() failed")})}).then(function(t){if(e._status===S.STATUS_TERMINATED)throw new Error("terminated");e._handleSessionTimersInIncomingRequest(n,r),n.reply(200,null,r,t,function(){e._status=S.STATUS_WAITING_FOR_ACK,e._setInvite2xxTimer(n,t),e._setACKTimer(),e._accepted("local")},function(){e._failed("system",null,o.causes.CONNECTION_ERROR)})}).catch(function(t){e._status!==S.STATUS_TERMINATED&&T(t)})}else n.reply(500,"Error creating dialog")}},{key:"terminate",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};y("terminate()");var n=t.cause||o.causes.BYE,r=c.cloneArray(t.extraHeaders),i=t.body,s=void 0,a=t.status_code,d=t.reason_phrase;if(this._status===S.STATUS_TERMINATED)throw new l.InvalidStateError(this._status);switch(this._status){case S.STATUS_NULL:case S.STATUS_INVITE_SENT:case S.STATUS_1XX_RECEIVED:if(y("canceling session"),a&&(a<200||a>=700))throw new TypeError("Invalid status_code: "+a);a&&(s="SIP ;cause="+a+' ;text="'+(d=d||o.REASON_PHRASE[a]||"")+'"'),this._status===S.STATUS_NULL||this._status===S.STATUS_INVITE_SENT?(this._is_canceled=!0,this._cancel_reason=s):this._status===S.STATUS_1XX_RECEIVED&&this._request.cancel(s),this._status=S.STATUS_CANCELED,this._failed("local",null,o.causes.CANCELED);break;case S.STATUS_WAITING_FOR_ANSWER:case S.STATUS_ANSWERED:if(y("rejecting session"),(a=a||480)<300||a>=700)throw new TypeError("Invalid status_code: "+a);this._request.reply(a,d,r,i),this._failed("local",null,o.causes.REJECTED);break;case S.STATUS_WAITING_FOR_ACK:case S.STATUS_CONFIRMED:if(y("terminating session"),d=t.reason_phrase||o.REASON_PHRASE[a]||"",a&&(a<200||a>=700))throw new TypeError("Invalid status_code: "+a);if(a&&r.push("Reason: SIP ;cause="+a+'; text="'+d+'"'),this._status===S.STATUS_WAITING_FOR_ACK&&"incoming"===this._direction&&this._request.server_transaction.state!==u.C.STATUS_TERMINATED){var h=this._dialog;this.receiveRequest=function(t){t.method===o.ACK&&(e.sendRequest(o.BYE,{extraHeaders:r,body:i}),h.terminate())},this._request.server_transaction.on("stateChanged",function(){e._request.server_transaction.state===u.C.STATUS_TERMINATED&&(e.sendRequest(o.BYE,{extraHeaders:r,body:i}),h.terminate())}),this._ended("local",null,n),this._dialog=h,this._ua.newDialog(h)}else this.sendRequest(o.BYE,{extraHeaders:r,body:i}),this._ended("local",null,n)}}},{key:"sendDTMF",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};y("sendDTMF() | tones: %s",e);var n=0,r=t.duration||null,i=t.interToneGap||null;if(void 0===e)throw new TypeError("Not enough arguments");if(this._status!==S.STATUS_CONFIRMED&&this._status!==S.STATUS_WAITING_FOR_ACK)throw new l.InvalidStateError(this._status);if("number"==typeof e&&(e=e.toString()),!e||"string"!=typeof e||!e.match(/^[0-9A-DR#*,]+$/i))throw new TypeError("Invalid tones: "+e);if(r&&!c.isDecimal(r))throw new TypeError("Invalid tone duration: "+r);if(r?r<m.C.MIN_DURATION?(y('"duration" value is lower than the minimum allowed, setting it to '+m.C.MIN_DURATION+" milliseconds"),r=m.C.MIN_DURATION):r>m.C.MAX_DURATION?(y('"duration" value is greater than the maximum allowed, setting it to '+m.C.MAX_DURATION+" milliseconds"),r=m.C.MAX_DURATION):r=Math.abs(r):r=m.C.DEFAULT_DURATION,t.duration=r,i&&!c.isDecimal(i))throw new TypeError("Invalid interToneGap: "+i);i?i<m.C.MIN_INTER_TONE_GAP?(y('"interToneGap" value is lower than the minimum allowed, setting it to '+m.C.MIN_INTER_TONE_GAP+" milliseconds"),i=m.C.MIN_INTER_TONE_GAP):i=Math.abs(i):i=m.C.DEFAULT_INTER_TONE_GAP,this._tones?this._tones+=e:(this._tones=e,function e(){var s=this;var a=void 0;if(this._status===S.STATUS_TERMINATED||!this._tones||n>=this._tones.length)return void(this._tones=null);var o=this._tones[n];n+=1;if(","===o)a=2e3;else{var l=new m(this);t.eventHandlers={onFailed:function(){s._tones=null}},l.send(o,t),a=r+i}setTimeout(e.bind(this),a)}.call(this))}},{key:"sendInfo",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(y("sendInfo()"),this._status!==S.STATUS_CONFIRMED&&this._status!==S.STATUS_WAITING_FOR_ACK)throw new l.InvalidStateError(this._status);new _(this).send(e,t,n)}},{key:"mute",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{audio:!0,video:!1};y("mute()");var t=!1,n=!1;!1===this._audioMuted&&e.audio&&(t=!0,this._audioMuted=!0,this._toogleMuteAudio(!0)),!1===this._videoMuted&&e.video&&(n=!0,this._videoMuted=!0,this._toogleMuteVideo(!0)),!0!==t&&!0!==n||this._onmute({audio:t,video:n})}},{key:"unmute",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{audio:!0,video:!0};y("unmute()");var t=!1,n=!1;!0===this._audioMuted&&e.audio&&(t=!0,this._audioMuted=!1,!1===this._localHold&&this._toogleMuteAudio(!1)),!0===this._videoMuted&&e.video&&(n=!0,this._videoMuted=!1,!1===this._localHold&&this._toogleMuteVideo(!1)),!0!==t&&!0!==n||this._onunmute({audio:t,video:n})}},{key:"hold",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=arguments[1];if(y("hold()"),this._status!==S.STATUS_WAITING_FOR_ACK&&this._status!==S.STATUS_CONFIRMED)return!1;if(!0===this._localHold)return!1;if(!this._isReadyToReOffer())return!1;this._localHold=!0,this._onhold("local");var r={succeeded:function(){n&&n()},failed:function(){e.terminate({cause:o.causes.WEBRTC_ERROR,status_code:500,reason_phrase:"Hold Failed"})}};return t.useUpdate?this._sendUpdate({sdpOffer:!0,eventHandlers:r,extraHeaders:t.extraHeaders}):this._sendReinvite({eventHandlers:r,extraHeaders:t.extraHeaders}),!0}},{key:"unhold",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=arguments[1];if(y("unhold()"),this._status!==S.STATUS_WAITING_FOR_ACK&&this._status!==S.STATUS_CONFIRMED)return!1;if(!1===this._localHold)return!1;if(!this._isReadyToReOffer())return!1;this._localHold=!1,this._onunhold("local");var r={succeeded:function(){n&&n()},failed:function(){e.terminate({cause:o.causes.WEBRTC_ERROR,status_code:500,reason_phrase:"Unhold Failed"})}};return t.useUpdate?this._sendUpdate({sdpOffer:!0,eventHandlers:r,extraHeaders:t.extraHeaders}):this._sendReinvite({eventHandlers:r,extraHeaders:t.extraHeaders}),!0}},{key:"renegotiate",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=arguments[1];y("renegotiate()");var r=t.rtcOfferConstraints||null;if(this._status!==S.STATUS_WAITING_FOR_ACK&&this._status!==S.STATUS_CONFIRMED)return!1;if(!this._isReadyToReOffer())return!1;var i={succeeded:function(){n&&n()},failed:function(){e.terminate({cause:o.causes.WEBRTC_ERROR,status_code:500,reason_phrase:"Media Renegotiation Failed"})}};return this._setLocalMediaStatus(),t.useUpdate?this._sendUpdate({sdpOffer:!0,eventHandlers:i,rtcOfferConstraints:r,extraHeaders:t.extraHeaders}):this._sendReinvite({eventHandlers:i,rtcOfferConstraints:r,extraHeaders:t.extraHeaders}),!0}},{key:"refer",value:function(e,t){var n=this;y("refer()");var r=e;if(this._status!==S.STATUS_WAITING_FOR_ACK&&this._status!==S.STATUS_CONFIRMED)return!1;if(!(e=this._ua.normalizeTarget(e)))throw new TypeError("Invalid target: "+r);var i=new g(this);i.sendRefer(e,t);var s=i.id;return this._referSubscribers[s]=i,i.on("requestFailed",function(){delete n._referSubscribers[s]}),i.on("accepted",function(){delete n._referSubscribers[s]}),i.on("failed",function(){delete n._referSubscribers[s]}),i}},{key:"sendRequest",value:function(e,t){return y("sendRequest()"),this._dialog.sendRequest(e,t)}},{key:"receiveRequest",value:function(e){var t=this;if(y("receiveRequest()"),e.method===o.CANCEL)this._status!==S.STATUS_WAITING_FOR_ANSWER&&this._status!==S.STATUS_ANSWERED||(this._status=S.STATUS_CANCELED,this._request.reply(487),this._failed("remote",e,o.causes.CANCELED));else switch(e.method){case o.ACK:if(this._status!==S.STATUS_WAITING_FOR_ACK)return;if(this._status=S.STATUS_CONFIRMED,clearTimeout(this._timers.ackTimer),clearTimeout(this._timers.invite2xxTimer),this._late_sdp){if(!e.body){this.terminate({cause:o.causes.MISSING_SDP,status_code:400});break}var n={originator:"remote",type:"answer",sdp:e.body};y('emit "sdp"'),this.emit("sdp",n);var r=new RTCSessionDescription({type:"answer",sdp:n.sdp});this._connectionPromiseQueue=this._connectionPromiseQueue.then(function(){return t._connection.setRemoteDescription(r)}).then(function(){t._is_confirmed||t._confirmed("remote",e)}).catch(function(e){t.terminate({cause:o.causes.BAD_MEDIA_DESCRIPTION,status_code:488}),T('emit "peerconnection:setremotedescriptionfailed" [error:%o]',e),t.emit("peerconnection:setremotedescriptionfailed",e)})}else this._is_confirmed||this._confirmed("remote",e);break;case o.BYE:this._status===S.STATUS_CONFIRMED?(e.reply(200),this._ended("remote",e,o.causes.BYE)):this._status===S.STATUS_INVITE_RECEIVED?(e.reply(200),this._request.reply(487,"BYE Received"),this._ended("remote",e,o.causes.BYE)):e.reply(403,"Wrong Status");break;case o.INVITE:this._status===S.STATUS_CONFIRMED?e.hasHeader("replaces")?this._receiveReplaces(e):this._receiveReinvite(e):e.reply(403,"Wrong Status");break;case o.INFO:if(this._status===S.STATUS_1XX_RECEIVED||this._status===S.STATUS_WAITING_FOR_ANSWER||this._status===S.STATUS_ANSWERED||this._status===S.STATUS_WAITING_FOR_ACK||this._status===S.STATUS_CONFIRMED){var i=e.getHeader("content-type");i&&i.match(/^application\/dtmf-relay/i)?new m(this).init_incoming(e):void 0!==i?new _(this).init_incoming(e):e.reply(415)}else e.reply(403,"Wrong Status");break;case o.UPDATE:this._status===S.STATUS_CONFIRMED?this._receiveUpdate(e):e.reply(403,"Wrong Status");break;case o.REFER:this._status===S.STATUS_CONFIRMED?this._receiveRefer(e):e.reply(403,"Wrong Status");break;case o.NOTIFY:this._status===S.STATUS_CONFIRMED?this._receiveNotify(e):e.reply(403,"Wrong Status");break;default:e.reply(501)}}},{key:"onTransportError",value:function(){T("onTransportError()"),this._status!==S.STATUS_TERMINATED&&this.terminate({status_code:500,reason_phrase:o.causes.CONNECTION_ERROR,cause:o.causes.CONNECTION_ERROR})}},{key:"onRequestTimeout",value:function(){T("onRequestTimeout()"),this._status!==S.STATUS_TERMINATED&&this.terminate({status_code:408,reason_phrase:o.causes.REQUEST_TIMEOUT,cause:o.causes.REQUEST_TIMEOUT})}},{key:"onDialogError",value:function(){T("onDialogError()"),this._status!==S.STATUS_TERMINATED&&this.terminate({status_code:500,reason_phrase:o.causes.DIALOG_ERROR,cause:o.causes.DIALOG_ERROR})}},{key:"newDTMF",value:function(e){y("newDTMF()"),this.emit("newDTMF",e)}},{key:"newInfo",value:function(e){y("newInfo()"),this.emit("newInfo",e)}},{key:"_isReadyToReOffer",value:function(){return this._rtcReady?this._dialog?!0!==this._dialog.uac_pending_reply&&!0!==this._dialog.uas_pending_reply||(y("_isReadyToReOffer() | there is another INVITE/UPDATE transaction in progress"),!1):(y("_isReadyToReOffer() | session not established yet"),!1):(y("_isReadyToReOffer() | internal WebRTC status not ready"),!1)}},{key:"_close",value:function(){if(y("close()"),this._status!==S.STATUS_TERMINATED){if(this._status=S.STATUS_TERMINATED,this._connection)try{this._connection.close()}catch(e){T("close() | error closing the RTCPeerConnection: %o",e)}for(var e in this._localMediaStream&&this._localMediaStreamLocallyGenerated&&(y("close() | closing local MediaStream"),c.closeMediaStream(this._localMediaStream)),this._timers)Object.prototype.hasOwnProperty.call(this._timers,e)&&clearTimeout(this._timers[e]);for(var t in clearTimeout(this._sessionTimers.timer),this._dialog&&(this._dialog.terminate(),delete this._dialog),this._earlyDialogs)Object.prototype.hasOwnProperty.call(this._earlyDialogs,t)&&(this._earlyDialogs[t].terminate(),delete this._earlyDialogs[t]);for(var n in this._referSubscribers)Object.prototype.hasOwnProperty.call(this._referSubscribers,n)&&delete this._referSubscribers[n];this._ua.destroyRTCSession(this)}}},{key:"_setInvite2xxTimer",value:function(e,t){var n=d.T1;this._timers.invite2xxTimer=setTimeout(function r(){this._status===S.STATUS_WAITING_FOR_ACK&&(e.reply(200,null,["Contact: "+this._contact],t),n<d.T2&&(n*=2)>d.T2&&(n=d.T2),this._timers.invite2xxTimer=setTimeout(r.bind(this),n))}.bind(this),n)}},{key:"_setACKTimer",value:function(){var e=this;this._timers.ackTimer=setTimeout(function(){e._status===S.STATUS_WAITING_FOR_ACK&&(y("no ACK received, terminating the session"),clearTimeout(e._timers.invite2xxTimer),e.sendRequest(o.BYE),e._ended("remote",null,o.causes.NO_ACK))},d.TIMER_H)}},{key:"_createRTCConnection",value:function(e,t){var n=this;this._connection=new RTCPeerConnection(e,t),this._connection.addEventListener("iceconnectionstatechange",function(){"failed"===n._connection.iceConnectionState&&n.terminate({cause:o.causes.RTP_TIMEOUT,status_code:408,reason_phrase:o.causes.RTP_TIMEOUT})}),y('emit "peerconnection"'),this.emit("peerconnection",{peerconnection:this._connection})}},{key:"_createLocalDescription",value:function(e,t){var n=this;if(y("createLocalDescription()"),"offer"!==e&&"answer"!==e)throw new Error('createLocalDescription() | invalid type "'+e+'"');var r=this._connection;return this._rtcReady=!1,Promise.resolve().then(function(){return"offer"===e?r.createOffer(t).catch(function(e){return T('emit "peerconnection:createofferfailed" [error:%o]',e),n.emit("peerconnection:createofferfailed",e),Promise.reject(e)}):r.createAnswer(t).catch(function(e){return T('emit "peerconnection:createanswerfailed" [error:%o]',e),n.emit("peerconnection:createanswerfailed",e),Promise.reject(e)})}).then(function(e){return r.setLocalDescription(e).catch(function(e){return n._rtcReady=!0,T('emit "peerconnection:setlocaldescriptionfailed" [error:%o]',e),n.emit("peerconnection:setlocaldescriptionfailed",e),Promise.reject(e)})}).then(function(){if("complete"===r.iceGatheringState){n._rtcReady=!0;var t={originator:"local",type:e,sdp:r.localDescription.sdp};return y('emit "sdp"'),n.emit("sdp",t),Promise.resolve(t.sdp)}return new Promise(function(t){var i=!1,s=void 0,a=function(){r.removeEventListener("icecandidate",s),i=!0,n._rtcReady=!0;var a={originator:"local",type:e,sdp:r.localDescription.sdp};y('emit "sdp"'),n.emit("sdp",a),t(a.sdp)};r.addEventListener("icecandidate",s=function(e){var t=e.candidate;t?n.emit("icecandidate",{candidate:t,ready:a}):i||a()})})})}},{key:"_createDialog",value:function(e,t,n){var r="UAS"===t?e.to_tag:e.from_tag,i="UAS"===t?e.from_tag:e.to_tag,s=e.call_id+r+i,a=this._earlyDialogs[s];if(n)return!!a||((a=new p(this,e,t,p.C.STATUS_EARLY)).error?(y(a.error),this._failed("remote",e,o.causes.INTERNAL_ERROR),!1):(this._earlyDialogs[s]=a,!0));if(this._from_tag=e.from_tag,this._to_tag=e.to_tag,a)return a.update(e,t),this._dialog=a,delete this._earlyDialogs[s],!0;var l=new p(this,e,t);return l.error?(y(l.error),this._failed("remote",e,o.causes.INTERNAL_ERROR),!1):(this._dialog=l,!0)}},{key:"_receiveReinvite",value:function(e){var t=this;y("receiveReinvite()");var n=e.getHeader("Content-Type"),r={request:e,callback:void 0,reject:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};i=!0;var n=t.status_code||403,r=t.reason_phrase||"",s=c.cloneArray(t.extraHeaders);if(this._status!==S.STATUS_CONFIRMED)return!1;if(n<300||n>=700)throw new TypeError("Invalid status_code: "+n);e.reply(n,r,s)}.bind(this)},i=!1;if(this.emit("reinvite",r),!i){if(this._late_sdp=!1,!e.body)return this._late_sdp=!0,void(this._connectionPromiseQueue=this._connectionPromiseQueue.then(function(){return t._createLocalDescription("offer",t._rtcOfferConstraints)}).then(function(e){s.call(t,e)}).catch(function(){e.reply(500)}));if("application/sdp"!==n)return y("invalid Content-Type"),void e.reply(415);this._processInDialogSdpOffer(e).then(function(e){t._status!==S.STATUS_TERMINATED&&s.call(t,e)}).catch(function(e){T(e)})}function s(t){var n=this,i=["Contact: "+this._contact];this._handleSessionTimersInIncomingRequest(e,i),this._late_sdp&&(t=this._mangleOffer(t)),e.reply(200,null,i,t,function(){n._status=S.STATUS_WAITING_FOR_ACK,n._setInvite2xxTimer(e,t),n._setACKTimer()}),"function"==typeof r.callback&&r.callback()}}},{key:"_receiveUpdate",value:function(e){var t=this;y("receiveUpdate()");var n=e.getHeader("Content-Type"),r={request:e,callback:void 0,reject:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};i=!0;var n=t.status_code||403,r=t.reason_phrase||"",s=c.cloneArray(t.extraHeaders);if(this._status!==S.STATUS_CONFIRMED)return!1;if(n<300||n>=700)throw new TypeError("Invalid status_code: "+n);e.reply(n,r,s)}.bind(this)},i=!1;if(this.emit("update",r),!i)if(e.body){if("application/sdp"!==n)return y("invalid Content-Type"),void e.reply(415);this._processInDialogSdpOffer(e).then(function(e){t._status!==S.STATUS_TERMINATED&&s.call(t,e)}).catch(function(e){T(e)})}else s.call(this,null);function s(t){var n=["Contact: "+this._contact];this._handleSessionTimersInIncomingRequest(e,n),e.reply(200,null,n,t),"function"==typeof r.callback&&r.callback()}}},{key:"_processInDialogSdpOffer",value:function(e){var t=this;y("_processInDialogSdpOffer()");var n=e.parseSDP(),r=!1,i=!0,s=!1,a=void 0;try{for(var o,l=n.media[Symbol.iterator]();!(i=(o=l.next()).done);i=!0){var u=o.value;if(-1!==C.indexOf(u.type)){var c=u.direction||n.direction||"sendrecv";if("sendonly"!==c&&"inactive"!==c){r=!1;break}r=!0}}}catch(e){s=!0,a=e}finally{try{!i&&l.return&&l.return()}finally{if(s)throw a}}var d={originator:"remote",type:"offer",sdp:e.body};y('emit "sdp"'),this.emit("sdp",d);var h=new RTCSessionDescription({type:"offer",sdp:d.sdp});return this._connectionPromiseQueue=this._connectionPromiseQueue.then(function(){if(t._status===S.STATUS_TERMINATED)throw new Error("terminated");return t._connection.setRemoteDescription(h).catch(function(n){throw e.reply(488),T('emit "peerconnection:setremotedescriptionfailed" [error:%o]',n),t.emit("peerconnection:setremotedescriptionfailed",n),new Error("peerconnection.setRemoteDescription() failed")})}).then(function(){if(t._status===S.STATUS_TERMINATED)throw new Error("terminated");!0===t._remoteHold&&!1===r?(t._remoteHold=!1,t._onunhold("remote")):!1===t._remoteHold&&!0===r&&(t._remoteHold=!0,t._onhold("remote"))}).then(function(){if(t._status===S.STATUS_TERMINATED)throw new Error("terminated");return t._createLocalDescription("answer",t._rtcAnswerConstraints).catch(function(){throw e.reply(500),new Error("_createLocalDescription() failed")})}),this._connectionPromiseQueue}},{key:"_receiveRefer",value:function(e){var n=this;if(y("receiveRefer()"),void 0===r(e.refer_to))return y("no Refer-To header field present in REFER"),void e.reply(400);if(e.refer_to.uri.scheme!==o.SIP)return y("Refer-To header field points to a non-SIP URI scheme"),void e.reply(416);e.reply(202);var i=new v(this,e.cseq);y('emit "refer"'),this.emit("refer",{request:e,accept:function(r,s){(function(n){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(n="function"==typeof n?n:null,this._status!==S.STATUS_WAITING_FOR_ACK&&this._status!==S.STATUS_CONFIRMED)return!1;var s=new t(this._ua);if(s.on("progress",function(e){var t=e.response;i.notify(t.status_code,t.reason_phrase)}),s.on("accepted",function(e){var t=e.response;i.notify(t.status_code,t.reason_phrase)}),s.on("failed",function(e){var t=e.message,n=e.cause;t?i.notify(t.status_code,t.reason_phrase):i.notify(487,n)}),e.refer_to.uri.hasHeader("replaces")){var a=decodeURIComponent(e.refer_to.uri.getHeader("replaces"));r.extraHeaders=c.cloneArray(r.extraHeaders),r.extraHeaders.push("Replaces: "+a)}s.connect(e.refer_to.uri.toAor(),r,n)}).call(n,r,s)},reject:function(){(function(){i.notify(603)}).call(n)}})}},{key:"_receiveNotify",value:function(e){switch(y("receiveNotify()"),void 0===r(e.event)&&e.reply(400),e.event.event){case"refer":var t=void 0,n=void 0;if(e.event.params&&e.event.params.id)t=e.event.params.id,n=this._referSubscribers[t];else{if(1!==Object.keys(this._referSubscribers).length)return void e.reply(400,"Missing event id parameter");n=this._referSubscribers[Object.keys(this._referSubscribers)[0]]}if(!n)return void e.reply(481,"Subscription does not exist");n.receiveNotify(e),e.reply(200);break;default:e.reply(489)}}},{key:"_receiveReplaces",value:function(e){var n=this;y("receiveReplaces()"),this.emit("replaces",{request:e,accept:function(r){(function(n){var r=this;if(this._status!==S.STATUS_WAITING_FOR_ACK&&this._status!==S.STATUS_CONFIRMED)return!1;var i=new t(this._ua);i.on("confirmed",function(){r.terminate()}),i.init_incoming(e,n)}).call(n,r)},reject:function(){(function(){y("Replaced INVITE rejected by the user"),e.reply(486)}).call(n)}})}},{key:"_sendInitialRequest",value:function(e,t,n){var r=this,i=new f(this._ua,this._request,{onRequestTimeout:function(){r.onRequestTimeout()},onTransportError:function(){r.onTransportError()},onAuthenticated:function(e){r._request=e},onReceiveResponse:function(e){r._receiveInviteResponse(e)}});Promise.resolve().then(function(){return n||(e.audio||e.video?(r._localMediaStreamLocallyGenerated=!0,navigator.mediaDevices.getUserMedia(e).catch(function(e){if(r._status===S.STATUS_TERMINATED)throw new Error("terminated");throw r._failed("local",null,o.causes.USER_DENIED_MEDIA_ACCESS),T('emit "getusermediafailed" [error:%o]',e),r.emit("getusermediafailed"),e})):void 0)}).then(function(e){if(r._status===S.STATUS_TERMINATED)throw new Error("terminated");return r._localMediaStream=e,e&&r._connection.addStream(e),r._connecting(r._request),r._createLocalDescription("offer",t).catch(function(e){throw r._failed("local",null,o.causes.WEBRTC_ERROR),e})}).then(function(e){if(r._is_canceled||r._status===S.STATUS_TERMINATED)throw new Error("terminated");r._request.body=e,r._status=S.STATUS_INVITE_SENT,y('emit "sending" [request:%o]',r._request),r.emit("sending",{request:r._request}),i.send()}).catch(function(e){r._status!==S.STATUS_TERMINATED&&T(e)})}},{key:"_receiveInviteResponse",value:function(e){var t=this;if(y("receiveInviteResponse()"),this._dialog&&e.status_code>=200&&e.status_code<=299){if(this._dialog.id.call_id===e.call_id&&this._dialog.id.local_tag===e.from_tag&&this._dialog.id.remote_tag===e.to_tag)return void this.sendRequest(o.ACK);var n=new p(this,e,"UAC");return void 0!==n.error?void y(n.error):(this.sendRequest(o.ACK),void this.sendRequest(o.BYE))}if(this._is_canceled)e.status_code>=100&&e.status_code<200?this._request.cancel(this._cancel_reason):e.status_code>=200&&e.status_code<299&&this._acceptAndTerminate(e);else if(this._status===S.STATUS_INVITE_SENT||this._status===S.STATUS_1XX_RECEIVED)switch(!0){case/^100$/.test(e.status_code):this._status=S.STATUS_1XX_RECEIVED;break;case/^1[0-9]{2}$/.test(e.status_code):if(!e.to_tag){y("1xx response received without to tag");break}if(e.hasHeader("contact")&&!this._createDialog(e,"UAC",!0))break;if(this._status=S.STATUS_1XX_RECEIVED,this._progress("remote",e),!e.body)break;var r={originator:"remote",type:"answer",sdp:e.body};y('emit "sdp"'),this.emit("sdp",r);var i=new RTCSessionDescription({type:"answer",sdp:r.sdp});this._connectionPromiseQueue=this._connectionPromiseQueue.then(function(){return t._connection.setRemoteDescription(i)}).catch(function(e){T('emit "peerconnection:setremotedescriptionfailed" [error:%o]',e),t.emit("peerconnection:setremotedescriptionfailed",e)});break;case/^2[0-9]{2}$/.test(e.status_code):if(this._status=S.STATUS_CONFIRMED,!e.body){this._acceptAndTerminate(e,400,o.causes.MISSING_SDP),this._failed("remote",e,o.causes.BAD_MEDIA_DESCRIPTION);break}if(!this._createDialog(e,"UAC"))break;var s={originator:"remote",type:"answer",sdp:e.body};y('emit "sdp"'),this.emit("sdp",s);var a=new RTCSessionDescription({type:"answer",sdp:s.sdp});this._connectionPromiseQueue=this._connectionPromiseQueue.then(function(){if("stable"===t._connection.signalingState)return t._connection.createOffer().then(function(e){return t._connection.setLocalDescription(e)}).catch(function(n){t._acceptAndTerminate(e,500,n.toString()),t._failed("local",e,o.causes.WEBRTC_ERROR)})}).then(function(){t._connection.setRemoteDescription(a).then(function(){t._handleSessionTimersInIncomingResponse(e),t._accepted("remote",e),t.sendRequest(o.ACK),t._confirmed("local",null)}).catch(function(n){t._acceptAndTerminate(e,488,"Not Acceptable Here"),t._failed("remote",e,o.causes.BAD_MEDIA_DESCRIPTION),T('emit "peerconnection:setremotedescriptionfailed" [error:%o]',n),t.emit("peerconnection:setremotedescriptionfailed",n)})});break;default:var l=c.sipErrorCause(e.status_code);this._failed("remote",e,l)}}},{key:"_sendReinvite",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};y("sendReinvite()");var n=c.cloneArray(t.extraHeaders),r=t.eventHandlers||{},i=t.rtcOfferConstraints||this._rtcOfferConstraints||null,s=!1;function a(e){r.failed&&r.failed(e)}n.push("Contact: "+this._contact),n.push("Content-Type: application/sdp"),this._sessionTimers.running&&n.push("Session-Expires: "+this._sessionTimers.currentExpires+";refresher="+(this._sessionTimers.refresher?"uac":"uas")),this._connectionPromiseQueue=this._connectionPromiseQueue.then(function(){return e._createLocalDescription("offer",i)}).then(function(t){t=e._mangleOffer(t),e.sendRequest(o.INVITE,{extraHeaders:n,body:t,eventHandlers:{onSuccessResponse:function(t){(function(e){var t=this;if(this._status===S.STATUS_TERMINATED)return;if(this.sendRequest(o.ACK),s)return;if(this._handleSessionTimersInIncomingResponse(e),!e.body)return void a.call(this);if("application/sdp"!==e.getHeader("Content-Type"))return void a.call(this);var n={originator:"remote",type:"answer",sdp:e.body};y('emit "sdp"'),this.emit("sdp",n);var i=new RTCSessionDescription({type:"answer",sdp:n.sdp});this._connectionPromiseQueue=this._connectionPromiseQueue.then(function(){return t._connection.setRemoteDescription(i)}).then(function(){r.succeeded&&r.succeeded(e)}).catch(function(e){a.call(t),T('emit "peerconnection:setremotedescriptionfailed" [error:%o]',e),t.emit("peerconnection:setremotedescriptionfailed",e)})}).call(e,t),s=!0},onErrorResponse:function(t){a.call(e,t)},onTransportError:function(){e.onTransportError()},onRequestTimeout:function(){e.onRequestTimeout()},onDialogError:function(){e.onDialogError()}}})}).catch(function(){a()})}},{key:"_sendUpdate",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};y("sendUpdate()");var n=c.cloneArray(t.extraHeaders),r=t.eventHandlers||{},i=t.rtcOfferConstraints||this._rtcOfferConstraints||null,s=t.sdpOffer||!1,a=!1;function l(e){var t=this;if(this._status!==S.STATUS_TERMINATED&&!a)if(this._handleSessionTimersInIncomingResponse(e),s){if(!e.body)return void u.call(this);if("application/sdp"!==e.getHeader("Content-Type"))return void u.call(this);var n={originator:"remote",type:"answer",sdp:e.body};y('emit "sdp"'),this.emit("sdp",n);var i=new RTCSessionDescription({type:"answer",sdp:n.sdp});this._connectionPromiseQueue=this._connectionPromiseQueue.then(function(){return t._connection.setRemoteDescription(i)}).then(function(){r.succeeded&&r.succeeded(e)}).catch(function(e){u.call(t),T('emit "peerconnection:setremotedescriptionfailed" [error:%o]',e),t.emit("peerconnection:setremotedescriptionfailed",e)})}else r.succeeded&&r.succeeded(e)}function u(e){r.failed&&r.failed(e)}n.push("Contact: "+this._contact),this._sessionTimers.running&&n.push("Session-Expires: "+this._sessionTimers.currentExpires+";refresher="+(this._sessionTimers.refresher?"uac":"uas")),s?(n.push("Content-Type: application/sdp"),this._connectionPromiseQueue=this._connectionPromiseQueue.then(function(){return e._createLocalDescription("offer",i)}).then(function(t){t=e._mangleOffer(t),e.sendRequest(o.UPDATE,{extraHeaders:n,body:t,eventHandlers:{onSuccessResponse:function(t){l.call(e,t),a=!0},onErrorResponse:function(t){u.call(e,t)},onTransportError:function(){e.onTransportError()},onRequestTimeout:function(){e.onRequestTimeout()},onDialogError:function(){e.onDialogError()}}})}).catch(function(){u.call(e)})):this.sendRequest(o.UPDATE,{extraHeaders:n,eventHandlers:{onSuccessResponse:function(t){l.call(e,t)},onErrorResponse:function(t){u.call(e,t)},onTransportError:function(){e.onTransportError()},onRequestTimeout:function(){e.onRequestTimeout()},onDialogError:function(){e.onDialogError()}}})}},{key:"_acceptAndTerminate",value:function(e,t,n){y("acceptAndTerminate()");var r=[];t&&(n=n||o.REASON_PHRASE[t]||"",r.push("Reason: SIP ;cause="+t+'; text="'+n+'"')),(this._dialog||this._createDialog(e,"UAC"))&&(this.sendRequest(o.ACK),this.sendRequest(o.BYE,{extraHeaders:r})),this._status=S.STATUS_TERMINATED}},{key:"_mangleOffer",value:function(e){if(!this._localHold&&!this._remoteHold)return e;if(e=a.parse(e),this._localHold&&!this._remoteHold){y("mangleOffer() | me on hold, mangling offer");var t=!0,n=!1,r=void 0;try{for(var i,s=e.media[Symbol.iterator]();!(t=(i=s.next()).done);t=!0){var o=i.value;-1!==C.indexOf(o.type)&&(o.direction?"sendrecv"===o.direction?o.direction="sendonly":"recvonly"===o.direction&&(o.direction="inactive"):o.direction="sendonly")}}catch(e){n=!0,r=e}finally{try{!t&&s.return&&s.return()}finally{if(n)throw r}}}else if(this._localHold&&this._remoteHold){y("mangleOffer() | both on hold, mangling offer");var l=!0,u=!1,c=void 0;try{for(var d,h=e.media[Symbol.iterator]();!(l=(d=h.next()).done);l=!0){var p=d.value;-1!==C.indexOf(p.type)&&(p.direction="inactive")}}catch(e){u=!0,c=e}finally{try{!l&&h.return&&h.return()}finally{if(u)throw c}}}else if(this._remoteHold){y("mangleOffer() | remote on hold, mangling offer");var f=!0,m=!1,_=void 0;try{for(var v,g=e.media[Symbol.iterator]();!(f=(v=g.next()).done);f=!0){var T=v.value;-1!==C.indexOf(T.type)&&(T.direction?"sendrecv"===T.direction?T.direction="recvonly":"recvonly"===T.direction&&(T.direction="inactive"):T.direction="recvonly")}}catch(e){m=!0,_=e}finally{try{!f&&g.return&&g.return()}finally{if(m)throw _}}}return a.write(e)}},{key:"_setLocalMediaStatus",value:function(){var e=!0,t=!0;(this._localHold||this._remoteHold)&&(e=!1,t=!1),this._audioMuted&&(e=!1),this._videoMuted&&(t=!1),this._toogleMuteAudio(!e),this._toogleMuteVideo(!t)}},{key:"_handleSessionTimersInIncomingRequest",value:function(e,t){if(this._sessionTimers.enabled){var n=void 0;e.session_expires&&e.session_expires>=o.MIN_SESSION_EXPIRES?(this._sessionTimers.currentExpires=e.session_expires,n=e.session_expires_refresher||"uas"):(this._sessionTimers.currentExpires=this._sessionTimers.defaultExpires,n="uas"),t.push("Session-Expires: "+this._sessionTimers.currentExpires+";refresher="+n),this._sessionTimers.refresher="uas"===n,this._runSessionTimer()}}},{key:"_handleSessionTimersInIncomingResponse",value:function(e){if(this._sessionTimers.enabled){var t=void 0;e.session_expires&&e.session_expires>=o.MIN_SESSION_EXPIRES?(this._sessionTimers.currentExpires=e.session_expires,t=e.session_expires_refresher||"uac"):(this._sessionTimers.currentExpires=this._sessionTimers.defaultExpires,t="uac"),this._sessionTimers.refresher="uac"===t,this._runSessionTimer()}}},{key:"_runSessionTimer",value:function(){var e=this,t=this._sessionTimers.currentExpires;this._sessionTimers.running=!0,clearTimeout(this._sessionTimers.timer),this._sessionTimers.refresher?this._sessionTimers.timer=setTimeout(function(){e._status!==S.STATUS_TERMINATED&&(y("runSessionTimer() | sending session refresh request"),e._sessionTimers.refreshMethod===o.UPDATE?e._sendUpdate():e._sendReinvite())},500*t):this._sessionTimers.timer=setTimeout(function(){e._status!==S.STATUS_TERMINATED&&(T("runSessionTimer() | timer expired, terminating the session"),e.terminate({cause:o.causes.REQUEST_TIMEOUT,status_code:408,reason_phrase:"Session Timer Expired"}))},1100*t)}},{key:"_toogleMuteAudio",value:function(e){var t=this._connection.getLocalStreams(),n=!0,r=!1,i=void 0;try{for(var s,a=t[Symbol.iterator]();!(n=(s=a.next()).done);n=!0){var o=s.value.getAudioTracks(),l=!0,u=!1,c=void 0;try{for(var d,h=o[Symbol.iterator]();!(l=(d=h.next()).done);l=!0){d.value.enabled=!e}}catch(e){u=!0,c=e}finally{try{!l&&h.return&&h.return()}finally{if(u)throw c}}}}catch(e){r=!0,i=e}finally{try{!n&&a.return&&a.return()}finally{if(r)throw i}}}},{key:"_toogleMuteVideo",value:function(e){var t=this._connection.getLocalStreams(),n=!0,r=!1,i=void 0;try{for(var s,a=t[Symbol.iterator]();!(n=(s=a.next()).done);n=!0){var o=s.value.getVideoTracks(),l=!0,u=!1,c=void 0;try{for(var d,h=o[Symbol.iterator]();!(l=(d=h.next()).done);l=!0){d.value.enabled=!e}}catch(e){u=!0,c=e}finally{try{!l&&h.return&&h.return()}finally{if(u)throw c}}}}catch(e){r=!0,i=e}finally{try{!n&&a.return&&a.return()}finally{if(r)throw i}}}},{key:"_newRTCSession",value:function(e,t){y("newRTCSession()"),this._ua.newRTCSession(this,{originator:e,session:this,request:t})}},{key:"_connecting",value:function(e){y("session connecting"),y('emit "connecting"'),this.emit("connecting",{request:e})}},{key:"_progress",value:function(e,t){y("session progress"),y('emit "progress"'),this.emit("progress",{originator:e,response:t||null})}},{key:"_accepted",value:function(e,t){y("session accepted"),this._start_time=new Date,y('emit "accepted"'),this.emit("accepted",{originator:e,response:t||null})}},{key:"_confirmed",value:function(e,t){y("session confirmed"),this._is_confirmed=!0,y('emit "confirmed"'),this.emit("confirmed",{originator:e,ack:t||null})}},{key:"_ended",value:function(e,t,n){y("session ended"),this._end_time=new Date,this._close(),y('emit "ended"'),this.emit("ended",{originator:e,message:t||null,cause:n})}},{key:"_failed",value:function(e,t,n){y("session failed"),this._close(),y('emit "failed"'),this.emit("failed",{originator:e,message:t||null,cause:n})}},{key:"_onhold",value:function(e){y("session onhold"),this._setLocalMediaStatus(),y('emit "hold"'),this.emit("hold",{originator:e})}},{key:"_onunhold",value:function(e){y("session onunhold"),this._setLocalMediaStatus(),y('emit "unhold"'),this.emit("unhold",{originator:e})}},{key:"_onmute",value:function(e){var t=e.audio,n=e.video;y("session onmute"),this._setLocalMediaStatus(),y('emit "muted"'),this.emit("muted",{audio:t,video:n})}},{key:"_onunmute",value:function(e){var t=e.audio,n=e.video;y("session onunmute"),this._setLocalMediaStatus(),y('emit "unmuted"'),this.emit("unmuted",{audio:t,video:n})}},{key:"C",get:function(){return S}},{key:"causes",get:function(){return o.causes}},{key:"id",get:function(){return this._id}},{key:"connection",get:function(){return this._connection}},{key:"contact",get:function(){return this._contact}},{key:"direction",get:function(){return this._direction}},{key:"local_identity",get:function(){return this._local_identity}},{key:"remote_identity",get:function(){return this._remote_identity}},{key:"start_time",get:function(){return this._start_time}},{key:"end_time",get:function(){return this._end_time}},{key:"data",get:function(){return this._data},set:function(e){this._data=e}},{key:"status",get:function(){return this._status}}]),t}()},{"./Constants":5,"./Dialog":6,"./Exceptions":9,"./RTCSession/DTMF":16,"./RTCSession/Info":17,"./RTCSession/ReferNotifier":18,"./RTCSession/ReferSubscriber":19,"./RequestSender":21,"./SIPMessage":22,"./Timers":24,"./Transactions":25,"./Utils":29,debug:2,events:1,"sdp-transform":37}],16:[function(e,t,n){"use strict";var r=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}();var i=e("events").EventEmitter,s=e("../Constants"),a=e("../Exceptions"),o=e("../Utils"),l=e("debug")("JsSIP:RTCSession:DTMF");e("debug")("JsSIP:ERROR:RTCSession:DTMF").log=console.warn.bind(console);var u={MIN_DURATION:70,MAX_DURATION:6e3,DEFAULT_DURATION:100,MIN_INTER_TONE_GAP:50,DEFAULT_INTER_TONE_GAP:500};t.exports=function(e){function t(e){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t);var n=function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}(this,(t.__proto__||Object.getPrototypeOf(t)).call(this));return n._session=e,n._direction=null,n._tone=null,n._duration=null,n._request=null,n}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}(t,i),r(t,[{key:"send",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(void 0===e)throw new TypeError("Not enough arguments");if(this._direction="outgoing",this._session.status!==this._session.C.STATUS_CONFIRMED&&this._session.status!==this._session.C.STATUS_WAITING_FOR_ACK)throw new a.InvalidStateError(this._session.status);var r=o.cloneArray(n.extraHeaders);if(this.eventHandlers=n.eventHandlers||{},"string"==typeof e)e=e.toUpperCase();else{if("number"!=typeof e)throw new TypeError("Invalid tone: "+e);e=e.toString()}if(!e.match(/^[0-9A-DR#*]$/))throw new TypeError("Invalid tone: "+e);this._tone=e,this._duration=n.duration,r.push("Content-Type: application/dtmf-relay");var i="Signal="+this._tone+"\r\n";i+="Duration="+this._duration,this._session.newDTMF({originator:"local",dtmf:this,request:this._request}),this._session.sendRequest(s.INFO,{extraHeaders:r,eventHandlers:{onSuccessResponse:function(e){t.emit("succeeded",{originator:"remote",response:e})},onErrorResponse:function(e){t.eventHandlers.onFailed&&t.eventHandlers.onFailed(),t.emit("failed",{originator:"remote",response:e})},onRequestTimeout:function(){t._session.onRequestTimeout()},onTransportError:function(){t._session.onTransportError()},onDialogError:function(){t._session.onDialogError()}},body:i})}},{key:"init_incoming",value:function(e){var t=/^(Signal\s*?=\s*?)([0-9A-D#*]{1})(\s)?.*/,n=/^(Duration\s?=\s?)([0-9]{1,4})(\s)?.*/;if(this._direction="incoming",this._request=e,e.reply(200),e.body){var r=e.body.split("\n");r.length>=1&&t.test(r[0])&&(this._tone=r[0].replace(t,"$2")),r.length>=2&&n.test(r[1])&&(this._duration=parseInt(r[1].replace(n,"$2"),10))}this._duration||(this._duration=u.DEFAULT_DURATION),this._tone?this._session.newDTMF({originator:"remote",dtmf:this,request:e}):l("invalid INFO DTMF received, discarded")}},{key:"tone",get:function(){return this._tone}},{key:"duration",get:function(){return this._duration}}]),t}(),t.exports.C=u},{"../Constants":5,"../Exceptions":9,"../Utils":29,debug:2,events:1}],17:[function(e,t,n){"use strict";var r=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}();var i=e("events").EventEmitter;e("debug")("JsSIP:ERROR:RTCSession:Info").log=console.warn.bind(console);var s=e("../Constants"),a=e("../Exceptions"),o=e("../Utils");t.exports=function(e){function t(e){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t);var n=function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}(this,(t.__proto__||Object.getPrototypeOf(t)).call(this));return n._session=e,n._direction=null,n._contentType=null,n._body=null,n}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}(t,i),r(t,[{key:"send",value:function(e,t){var n=this,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(this._direction="outgoing",void 0===e)throw new TypeError("Not enough arguments");if(this._session.status!==this._session.C.STATUS_CONFIRMED&&this._session.status!==this._session.C.STATUS_WAITING_FOR_ACK)throw new a.InvalidStateError(this._session.status);this._contentType=e,this._body=t;var i=o.cloneArray(r.extraHeaders);i.push("Content-Type: "+e),this._session.newInfo({originator:"local",info:this,request:this.request}),this._session.sendRequest(s.INFO,{extraHeaders:i,eventHandlers:{onSuccessResponse:function(e){n.emit("succeeded",{originator:"remote",response:e})},onErrorResponse:function(e){n.emit("failed",{originator:"remote",response:e})},onTransportError:function(){n._session.onTransportError()},onRequestTimeout:function(){n._session.onRequestTimeout()},onDialogError:function(){n._session.onDialogError()}},body:t})}},{key:"init_incoming",value:function(e){this._direction="incoming",this.request=e,e.reply(200),this._contentType=e.getHeader("content-type"),this._body=e.body,this._session.newInfo({originator:"remote",info:this,request:e})}},{key:"contentType",get:function(){return this._contentType}},{key:"body",get:function(){return this._body}}]),t}()},{"../Constants":5,"../Exceptions":9,"../Utils":29,debug:2,events:1}],18:[function(e,t,n){"use strict";var r=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}();var i=e("../Constants"),s=e("debug")("JsSIP:RTCSession:ReferNotifier"),a={event_type:"refer",body_type:"message/sipfrag;version=2.0",expires:300};t.exports=function(){function e(t,n,r){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this._session=t,this._id=n,this._expires=r||a.expires,this._active=!0,this.notify(100)}return r(e,[{key:"notify",value:function(e,t){if(s("notify()"),!1!==this._active){t=t||i.REASON_PHRASE[e]||"";var n=void 0;n=e>=200?"terminated;reason=noresource":"active;expires="+this._expires,this._session.sendRequest(i.NOTIFY,{extraHeaders:["Event: "+a.event_type+";id="+this._id,"Subscription-State: "+n,"Content-Type: "+a.body_type],body:"SIP/2.0 "+e+" "+t,eventHandlers:{onErrorResponse:function(){this._active=!1}}})}}}]),e}()},{"../Constants":5,debug:2}],19:[function(e,t,n){"use strict";var r=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}();var i=e("events").EventEmitter,s=e("../Constants"),a=e("../Grammar"),o=e("../Utils"),l=e("debug")("JsSIP:RTCSession:ReferSubscriber");t.exports=function(e){function t(e){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t);var n=function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}(this,(t.__proto__||Object.getPrototypeOf(t)).call(this));return n._id=null,n._session=e,n}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}(t,i),r(t,[{key:"sendRefer",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};l("sendRefer()");var r=o.cloneArray(n.extraHeaders),i=n.eventHandlers||{};for(var a in i)Object.prototype.hasOwnProperty.call(i,a)&&this.on(a,i[a]);var u=null;n.replaces&&(u=n.replaces._request.call_id,u+=";to-tag="+n.replaces._to_tag,u+=";from-tag="+n.replaces._from_tag,u=encodeURIComponent(u));var c="Refer-To: <"+e+(u?"?Replaces="+u:"")+">";r.push(c),r.push("Contact: "+this._session.contact);var d=this._session.sendRequest(s.REFER,{extraHeaders:r,eventHandlers:{onSuccessResponse:function(e){t._requestSucceeded(e)},onErrorResponse:function(e){t._requestFailed(e,s.causes.REJECTED)},onTransportError:function(){t._requestFailed(null,s.causes.CONNECTION_ERROR)},onRequestTimeout:function(){t._requestFailed(null,s.causes.REQUEST_TIMEOUT)},onDialogError:function(){t._requestFailed(null,s.causes.DIALOG_ERROR)}}});this._id=d.cseq}},{key:"receiveNotify",value:function(e){if(l("receiveNotify()"),e.body){var t=a.parse(e.body.trim(),"Status_Line");if(-1!==t)switch(!0){case/^100$/.test(t.status_code):this.emit("trying",{request:e,status_line:t});break;case/^1[0-9]{2}$/.test(t.status_code):this.emit("progress",{request:e,status_line:t});break;case/^2[0-9]{2}$/.test(t.status_code):this.emit("accepted",{request:e,status_line:t});break;default:this.emit("failed",{request:e,status_line:t})}else l('receiveNotify() | error parsing NOTIFY body: "'+e.body+'"')}}},{key:"_requestSucceeded",value:function(e){l("REFER succeeded"),l('emit "requestSucceeded"'),this.emit("requestSucceeded",{response:e})}},{key:"_requestFailed",value:function(e,t){l("REFER failed"),l('emit "requestFailed"'),this.emit("requestFailed",{response:e||null,cause:t})}},{key:"id",get:function(){return this._id}}]),t}()},{"../Constants":5,"../Grammar":10,"../Utils":29,debug:2,events:1}],20:[function(e,t,n){"use strict";var r=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}();var i=e("./Utils"),s=e("./Constants"),a=e("./SIPMessage"),o=e("./RequestSender"),l=e("debug")("JsSIP:Registrator");t.exports=function(){function e(t,n){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e);this._ua=t,this._transport=n,this._registrar=t.configuration.registrar_server,this._expires=t.configuration.register_expires,this._call_id=i.createRandomToken(22),this._cseq=0,this._to_uri=t.configuration.uri,this._registrationTimer=null,this._registering=!1,this._registered=!1,this._contact=this._ua.contact.toString(),this._contact+=";+sip.ice",this._extraHeaders=[],this._extraContactParams="",this._contact+=";reg-id=1",this._contact+=';+sip.instance="<urn:uuid:'+this._ua.configuration.instance_id+'>"'}return r(e,[{key:"setExtraHeaders",value:function(e){Array.isArray(e)||(e=[]),this._extraHeaders=e.slice()}},{key:"setExtraContactParams",value:function(e){for(var t in e instanceof Object||(e={}),this._extraContactParams="",e)if(Object.prototype.hasOwnProperty.call(e,t)){var n=e[t];this._extraContactParams+=";"+t,n&&(this._extraContactParams+="="+n)}}},{key:"register",value:function(){var e=this;if(this._registering)l("Register request in progress...");else{var t=this._extraHeaders.slice();t.push("Contact: "+this._contact+";expires="+this._expires+this._extraContactParams),t.push("Expires: "+this._expires);var n=new a.OutgoingRequest(s.REGISTER,this._registrar,this._ua,{to_uri:this._to_uri,call_id:this._call_id,cseq:this._cseq+=1},t),r=new o(this._ua,n,{onRequestTimeout:function(){e._registrationFailure(null,s.causes.REQUEST_TIMEOUT)},onTransportError:function(){e._registrationFailure(null,s.causes.CONNECTION_ERROR)},onAuthenticated:function(){e._cseq+=1},onReceiveResponse:function(t){var n=void 0,r=void 0,a=t.getHeaders("contact").length;if(t.cseq===e._cseq)switch(null!==e._registrationTimer&&(clearTimeout(e._registrationTimer),e._registrationTimer=null),!0){case/^1[0-9]{2}$/.test(t.status_code):break;case/^2[0-9]{2}$/.test(t.status_code):if(e._registering=!1,!a){l("no Contact header in response to REGISTER, response ignored");break}for(;a--;){if((n=t.parseHeader("contact",a)).uri.user===e._ua.contact.uri.user){r=n.getParam("expires");break}n=null}if(!n){l("no Contact header pointing to us, response ignored");break}!r&&t.hasHeader("expires")&&(r=t.getHeader("expires")),r||(r=e._expires),(r=Number(r))<10&&(r=10),e._registrationTimer=setTimeout(function(){e._registrationTimer=null,0===e._ua.listeners("registrationExpiring").length?e.register():e._ua.emit("registrationExpiring")},1e3*r-5e3),n.hasParam("temp-gruu")&&(e._ua.contact.temp_gruu=n.getParam("temp-gruu").replace(/"/g,"")),n.hasParam("pub-gruu")&&(e._ua.contact.pub_gruu=n.getParam("pub-gruu").replace(/"/g,"")),e._registered||(e._registered=!0,e._ua.registered({response:t}));break;case/^423$/.test(t.status_code):t.hasHeader("min-expires")?(e._expires=Number(t.getHeader("min-expires")),e._expires<10&&(e._expires=10),e.register()):(l("423 response received for REGISTER without Min-Expires"),e._registrationFailure(t,s.causes.SIP_FAILURE_CODE));break;default:var o=i.sipErrorCause(t.status_code);e._registrationFailure(t,o)}}});this._registering=!0,r.send()}}},{key:"unregister",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(this._registered){this._registered=!1,null!==this._registrationTimer&&(clearTimeout(this._registrationTimer),this._registrationTimer=null);var n=this._extraHeaders.slice();t.all?n.push("Contact: *"+this._extraContactParams):n.push("Contact: "+this._contact+";expires=0"+this._extraContactParams),n.push("Expires: 0");var r=new a.OutgoingRequest(s.REGISTER,this._registrar,this._ua,{to_uri:this._to_uri,call_id:this._call_id,cseq:this._cseq+=1},n);new o(this._ua,r,{onRequestTimeout:function(){e._unregistered(null,s.causes.REQUEST_TIMEOUT)},onTransportError:function(){e._unregistered(null,s.causes.CONNECTION_ERROR)},onAuthenticated:function(){e._cseq+=1},onReceiveResponse:function(t){switch(!0){case/^1[0-9]{2}$/.test(t.status_code):break;case/^2[0-9]{2}$/.test(t.status_code):e._unregistered(t);break;default:var n=i.sipErrorCause(t.status_code);e._unregistered(t,n)}}}).send()}else l("already unregistered")}},{key:"close",value:function(){this._registered&&this.unregister()}},{key:"onTransportClosed",value:function(){this._registering=!1,null!==this._registrationTimer&&(clearTimeout(this._registrationTimer),this._registrationTimer=null),this._registered&&(this._registered=!1,this._ua.unregistered({}))}},{key:"_registrationFailure",value:function(e,t){this._registering=!1,this._ua.registrationFailed({response:e||null,cause:t}),this._registered&&(this._registered=!1,this._ua.unregistered({response:e||null,cause:t}))}},{key:"_unregistered",value:function(e,t){this._registering=!1,this._registered=!1,this._ua.unregistered({response:e||null,cause:t||null})}},{key:"registered",get:function(){return this._registered}}]),e}()},{"./Constants":5,"./RequestSender":21,"./SIPMessage":22,"./Utils":29,debug:2}],21:[function(e,t,n){"use strict";var r=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}();var i=e("./Constants"),s=e("./DigestAuthentication"),a=e("./Transactions"),o=e("debug")("JsSIP:RequestSender"),l={onRequestTimeout:function(){},onTransportError:function(){},onReceiveResponse:function(){},onAuthenticated:function(){}};t.exports=function(){function e(t,n,r){for(var s in function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this._ua=t,this._eventHandlers=r,this._method=n.method,this._request=n,this._auth=null,this._challenged=!1,this._staled=!1,l)Object.prototype.hasOwnProperty.call(l,s)&&(this._eventHandlers[s]||(this._eventHandlers[s]=l[s]));t.status!==t.C.STATUS_USER_CLOSED||this._method===i.BYE&&this._method===i.ACK||this._eventHandlers.onTransportError()}return r(e,[{key:"send",value:function(){var e=this,t={onRequestTimeout:function(){e._eventHandlers.onRequestTimeout()},onTransportError:function(){e._eventHandlers.onTransportError()},onReceiveResponse:function(t){e._receiveResponse(t)}};switch(this._method){case"INVITE":this.clientTransaction=new a.InviteClientTransaction(this._ua,this._ua.transport,this._request,t);break;case"ACK":this.clientTransaction=new a.AckClientTransaction(this._ua,this._ua.transport,this._request,t);break;default:this.clientTransaction=new a.NonInviteClientTransaction(this._ua,this._ua.transport,this._request,t)}this.clientTransaction.send()}},{key:"_receiveResponse",value:function(e){var t=void 0,n=void 0,r=e.status_code;if(401!==r&&407!==r||null===this._ua.configuration.password&&null===this._ua.configuration.ha1)this._eventHandlers.onReceiveResponse(e);else{if(401===e.status_code?(t=e.parseHeader("www-authenticate"),n="authorization"):(t=e.parseHeader("proxy-authenticate"),n="proxy-authorization"),!t)return o(e.status_code+" with wrong or missing challenge, cannot authenticate"),void this._eventHandlers.onReceiveResponse(e);if(!this._challenged||!this._staled&&!0===t.stale){if(this._auth||(this._auth=new s({username:this._ua.configuration.authorization_user,password:this._ua.configuration.password,realm:this._ua.configuration.realm,ha1:this._ua.configuration.ha1})),!this._auth.authenticate(this._request,t))return void this._eventHandlers.onReceiveResponse(e);this._challenged=!0,this._ua.set("realm",this._auth.get("realm")),this._ua.set("ha1",this._auth.get("ha1")),t.stale&&(this._staled=!0),this._request=this._request.clone(),this._request.cseq+=1,this._request.setHeader("cseq",this._request.cseq+" "+this._method),this._request.setHeader(n,this._auth.toString()),this._eventHandlers.onAuthenticated(this._request),this.send()}else this._eventHandlers.onReceiveResponse(e)}}}]),e}()},{"./Constants":5,"./DigestAuthentication":8,"./Transactions":25,debug:2}],22:[function(e,t,n){"use strict";var r=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}();function i(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function s(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}function a(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var o=e("sdp-transform"),l=e("./Constants"),u=e("./Utils"),c=e("./NameAddrHeader"),d=e("./Grammar"),h=e("debug")("JsSIP:SIPMessage"),p=function(){function e(t,n,r,i,s,o){if(a(this,e),!t||!n||!r)return null;i=i||{},this.ua=r,this.headers={},this.method=t,this.ruri=n,this.body=o,this.extraHeaders=u.cloneArray(s),i.route_set?this.setHeader("route",i.route_set):r.configuration.use_preloaded_route&&this.setHeader("route","<"+r.transport.sip_uri+";lr>"),this.setHeader("via",""),this.setHeader("max-forwards",l.MAX_FORWARDS);var d=i.to_display_name||0===i.to_display_name?'"'+i.to_display_name+'" ':"";d+="<"+(i.to_uri||n)+">",d+=i.to_tag?";tag="+i.to_tag:"",this.to=c.parse(d),this.setHeader("to",d);var h=void 0;h=i.from_display_name||0===i.from_display_name?'"'+i.from_display_name+'" ':r.configuration.display_name?'"'+r.configuration.display_name+'" ':"",h+="<"+(i.from_uri||r.configuration.uri)+">;tag=",h+=i.from_tag||u.newTag(),this.from=c.parse(h),this.setHeader("from",h);var p=i.call_id||r.configuration.jssip_id+u.createRandomToken(15);this.call_id=p,this.setHeader("call-id",p);var f=i.cseq||Math.floor(1e4*Math.random());this.cseq=f,this.setHeader("cseq",f+" "+t)}return r(e,[{key:"setHeader",value:function(e,t){for(var n=new RegExp("^\\s*"+e+"\\s*:","i"),r=0;r<this.extraHeaders.length;r++)n.test(this.extraHeaders[r])&&this.extraHeaders.splice(r,1);this.headers[u.headerize(e)]=Array.isArray(t)?t:[t]}},{key:"getHeader",value:function(e){var t=this.headers[u.headerize(e)];if(t){if(t[0])return t[0]}else{var n=new RegExp("^\\s*"+e+"\\s*:","i"),r=!0,i=!1,s=void 0;try{for(var a,o=this.extraHeaders[Symbol.iterator]();!(r=(a=o.next()).done);r=!0){var l=a.value;if(n.test(l))return l.substring(l.indexOf(":")+1).trim()}}catch(e){i=!0,s=e}finally{try{!r&&o.return&&o.return()}finally{if(i)throw s}}}}},{key:"getHeaders",value:function(e){var t=this.headers[u.headerize(e)],n=[];if(t){var r=!0,i=!1,s=void 0;try{for(var a,o=t[Symbol.iterator]();!(r=(a=o.next()).done);r=!0){var l=a.value;n.push(l)}}catch(e){i=!0,s=e}finally{try{!r&&o.return&&o.return()}finally{if(i)throw s}}return n}var c=new RegExp("^\\s*"+e+"\\s*:","i"),d=!0,h=!1,p=void 0;try{for(var f,m=this.extraHeaders[Symbol.iterator]();!(d=(f=m.next()).done);d=!0){var _=f.value;c.test(_)&&n.push(_.substring(_.indexOf(":")+1).trim())}}catch(e){h=!0,p=e}finally{try{!d&&m.return&&m.return()}finally{if(h)throw p}}return n}},{key:"hasHeader",value:function(e){if(this.headers[u.headerize(e)])return!0;var t=new RegExp("^\\s*"+e+"\\s*:","i"),n=!0,r=!1,i=void 0;try{for(var s,a=this.extraHeaders[Symbol.iterator]();!(n=(s=a.next()).done);n=!0){var o=s.value;if(t.test(o))return!0}}catch(e){r=!0,i=e}finally{try{!n&&a.return&&a.return()}finally{if(r)throw i}}return!1}},{key:"parseSDP",value:function(e){return!e&&this.sdp?this.sdp:(this.sdp=o.parse(this.body||""),this.sdp)}},{key:"toString",value:function(){var e=this.method+" "+this.ruri+" SIP/2.0\r\n";for(var t in this.headers)if(Object.prototype.hasOwnProperty.call(this.headers,t)){var n=!0,r=!1,i=void 0;try{for(var s,a=this.headers[t][Symbol.iterator]();!(n=(s=a.next()).done);n=!0){e+=t+": "+s.value+"\r\n"}}catch(e){r=!0,i=e}finally{try{!n&&a.return&&a.return()}finally{if(r)throw i}}}var o=!0,c=!1,d=void 0;try{for(var h,p=this.extraHeaders[Symbol.iterator]();!(o=(h=p.next()).done);o=!0){e+=h.value.trim()+"\r\n"}}catch(e){c=!0,d=e}finally{try{!o&&p.return&&p.return()}finally{if(c)throw d}}var f=[];switch(this.method){case l.REGISTER:f.push("path","gruu");break;case l.INVITE:this.ua.configuration.session_timers&&f.push("timer"),(this.ua.contact.pub_gruu||this.ua.contact.temp_gruu)&&f.push("gruu"),f.push("ice","replaces");break;case l.UPDATE:this.ua.configuration.session_timers&&f.push("timer"),f.push("ice")}f.push("outbound");var m=this.ua.configuration.user_agent||l.USER_AGENT;(e+="Allow: "+l.ALLOWED_METHODS+"\r\n",e+="Supported: "+f+"\r\n",e+="User-Agent: "+m+"\r\n",this.body)?(e+="Content-Length: "+u.str_utf8_length(this.body)+"\r\n\r\n",e+=this.body):e+="Content-Length: 0\r\n\r\n";return e}},{key:"clone",value:function(){var t=new e(this.method,this.ruri,this.ua);return Object.keys(this.headers).forEach(function(e){t.headers[e]=this.headers[e].slice()},this),t.body=this.body,t.extraHeaders=u.cloneArray(this.extraHeaders),t.to=this.to,t.from=this.from,t.call_id=this.call_id,t.cseq=this.cseq,t}}]),e}(),f=function(e){function t(e,n,r,s,o){a(this,t);var u=i(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,l.INVITE,e,n,r,s,o));return u.transaction=null,u}return s(t,p),r(t,[{key:"cancel",value:function(e){this.transaction.cancel(e)}},{key:"clone",value:function(){var e=new t(this.ruri,this.ua);return Object.keys(this.headers).forEach(function(t){e.headers[t]=this.headers[t].slice()},this),e.body=this.body,e.extraHeaders=u.cloneArray(this.extraHeaders),e.to=this.to,e.from=this.from,e.call_id=this.call_id,e.cseq=this.cseq,e.transaction=this.transaction,e}}]),t}(),m=function(){function e(){a(this,e),this.data=null,this.headers=null,this.method=null,this.via=null,this.via_branch=null,this.call_id=null,this.cseq=null,this.from=null,this.from_tag=null,this.to=null,this.to_tag=null,this.body=null,this.sdp=null}return r(e,[{key:"addHeader",value:function(e,t){var n={raw:t};e=u.headerize(e),this.headers[e]?this.headers[e].push(n):this.headers[e]=[n]}},{key:"getHeader",value:function(e){var t=this.headers[u.headerize(e)];if(t)return t[0]?t[0].raw:void 0}},{key:"getHeaders",value:function(e){var t=this.headers[u.headerize(e)],n=[];if(!t)return[];var r=!0,i=!1,s=void 0;try{for(var a,o=t[Symbol.iterator]();!(r=(a=o.next()).done);r=!0){var l=a.value;n.push(l.raw)}}catch(e){i=!0,s=e}finally{try{!r&&o.return&&o.return()}finally{if(i)throw s}}return n}},{key:"hasHeader",value:function(e){return!!this.headers[u.headerize(e)]}},{key:"parseHeader",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;if(e=u.headerize(e),this.headers[e]){if(!(t>=this.headers[e].length)){var n=this.headers[e][t],r=n.raw;if(n.parsed)return n.parsed;var i=d.parse(r,e.replace(/-/g,"_"));return-1===i?(this.headers[e].splice(t,1),void h('error parsing "'+e+'" header field with value "'+r+'"')):(n.parsed=i,i)}h('not so many "'+e+'" headers present')}else h('header "'+e+'" not present')}},{key:"s",value:function(e,t){return this.parseHeader(e,t)}},{key:"setHeader",value:function(e,t){var n={raw:t};this.headers[u.headerize(e)]=[n]}},{key:"parseSDP",value:function(e){return!e&&this.sdp?this.sdp:(this.sdp=o.parse(this.body||""),this.sdp)}},{key:"toString",value:function(){return this.data}}]),e}(),_=function(e){function t(e){a(this,t);var n=i(this,(t.__proto__||Object.getPrototypeOf(t)).call(this));return n.ua=e,n.headers={},n.ruri=null,n.transport=null,n.server_transaction=null,n}return s(t,m),r(t,[{key:"reply",value:function(e,t,n,r,i,s){var a=[],o=this.getHeader("To");if(t=t||null,!(e=e||null)||e<100||e>699)throw new TypeError("Invalid status_code: "+e);if(t&&"string"!=typeof t&&!(t instanceof String))throw new TypeError("Invalid reason_phrase: "+t);t=t||l.REASON_PHRASE[e]||"",n=u.cloneArray(n);var c="SIP/2.0 "+e+" "+t+"\r\n";if(this.method===l.INVITE&&e>100&&e<=200){var d=this.getHeaders("record-route"),h=!0,p=!1,f=void 0;try{for(var m,_=d[Symbol.iterator]();!(h=(m=_.next()).done);h=!0){c+="Record-Route: "+m.value+"\r\n"}}catch(e){p=!0,f=e}finally{try{!h&&_.return&&_.return()}finally{if(p)throw f}}}var v=this.getHeaders("via"),g=!0,y=!1,T=void 0;try{for(var S,C=v[Symbol.iterator]();!(g=(S=C.next()).done);g=!0){c+="Via: "+S.value+"\r\n"}}catch(e){y=!0,T=e}finally{try{!g&&C.return&&C.return()}finally{if(y)throw T}}!this.to_tag&&e>100?o+=";tag="+u.newTag():this.to_tag&&!this.s("to").hasParam("tag")&&(o+=";tag="+this.to_tag),c+="To: "+o+"\r\n",c+="From: "+this.getHeader("From")+"\r\n",c+="Call-ID: "+this.call_id+"\r\n",c+="CSeq: "+this.cseq+" "+this.method+"\r\n";var E=!0,b=!1,R=void 0;try{for(var w,A=n[Symbol.iterator]();!(E=(w=A.next()).done);E=!0){c+=w.value.trim()+"\r\n"}}catch(e){b=!0,R=e}finally{try{!E&&A.return&&A.return()}finally{if(b)throw R}}switch(this.method){case l.INVITE:this.ua.configuration.session_timers&&a.push("timer"),(this.ua.contact.pub_gruu||this.ua.contact.temp_gruu)&&a.push("gruu"),a.push("ice","replaces");break;case l.UPDATE:this.ua.configuration.session_timers&&a.push("timer"),r&&a.push("ice"),a.push("replaces")}(a.push("outbound"),this.method===l.OPTIONS?(c+="Allow: "+l.ALLOWED_METHODS+"\r\n",c+="Accept: "+l.ACCEPTED_BODY_TYPES+"\r\n"):405===e?c+="Allow: "+l.ALLOWED_METHODS+"\r\n":415===e&&(c+="Accept: "+l.ACCEPTED_BODY_TYPES+"\r\n"),c+="Supported: "+a+"\r\n",r)?(c+="Content-Type: application/sdp\r\n",c+="Content-Length: "+u.str_utf8_length(r)+"\r\n\r\n",c+=r):c+="Content-Length: 0\r\n\r\n";this.server_transaction.receiveResponse(e,c,i,s)}},{key:"reply_sl",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,n=this.getHeaders("via");if(!e||e<100||e>699)throw new TypeError("Invalid status_code: "+e);if(t&&"string"!=typeof t&&!(t instanceof String))throw new TypeError("Invalid reason_phrase: "+t);var r="SIP/2.0 "+e+" "+(t=t||l.REASON_PHRASE[e]||"")+"\r\n",i=!0,s=!1,a=void 0;try{for(var o,c=n[Symbol.iterator]();!(i=(o=c.next()).done);i=!0){r+="Via: "+o.value+"\r\n"}}catch(e){s=!0,a=e}finally{try{!i&&c.return&&c.return()}finally{if(s)throw a}}var d=this.getHeader("To");!this.to_tag&&e>100?d+=";tag="+u.newTag():this.to_tag&&!this.s("to").hasParam("tag")&&(d+=";tag="+this.to_tag),r+="To: "+d+"\r\n",r+="From: "+this.getHeader("From")+"\r\n",r+="Call-ID: "+this.call_id+"\r\n",r+="CSeq: "+this.cseq+" "+this.method+"\r\n",r+="Content-Length: 0\r\n\r\n",this.transport.send(r)}}]),t}(),v=function(e){function t(){a(this,t);var e=i(this,(t.__proto__||Object.getPrototypeOf(t)).call(this));return e.headers={},e.status_code=null,e.reason_phrase=null,e}return s(t,m),t}();t.exports={OutgoingRequest:p,InitialOutgoingInviteRequest:f,IncomingRequest:_,IncomingResponse:v}},{"./Constants":5,"./Grammar":10,"./NameAddrHeader":13,"./Utils":29,debug:2,"sdp-transform":37}],23:[function(e,t,n){"use strict";var r=e("./Utils"),i=e("./Grammar"),s=e("debug")("JsSIP:ERROR:Socket");s.log=console.warn.bind(console),n.isSocket=function(e){if(Array.isArray(e))return!1;if(void 0===e)return s("undefined JsSIP.Socket instance"),!1;try{if(!r.isString(e.url))throw s("missing or invalid JsSIP.Socket url property"),new Error;if(!r.isString(e.via_transport))throw s("missing or invalid JsSIP.Socket via_transport property"),new Error;if(-1===i.parse(e.sip_uri,"SIP_URI"))throw s("missing or invalid JsSIP.Socket sip_uri property"),new Error}catch(e){return!1}try{["connect","disconnect","send"].forEach(function(t){if(!r.isFunction(e[t]))throw s("missing or invalid JsSIP.Socket method: "+t),new Error})}catch(e){return!1}return!0}},{"./Grammar":10,"./Utils":29,debug:2}],24:[function(e,t,n){"use strict";var r=500;t.exports={T1:r,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,PROVISIONAL_RESPONSE_INTERVAL:6e4}},{}],25:[function(e,t,n){"use strict";var r=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}();function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function s(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function a(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}var o=e("events").EventEmitter,l=e("./Constants"),u=e("./SIPMessage"),c=e("./Timers"),d=e("debug")("JsSIP:NonInviteClientTransaction"),h=e("debug")("JsSIP:InviteClientTransaction"),p=e("debug")("JsSIP:AckClientTransaction"),f=e("debug")("JsSIP:NonInviteServerTransaction"),m=e("debug")("JsSIP:InviteServerTransaction"),_={STATUS_TRYING:1,STATUS_PROCEEDING:2,STATUS_CALLING:3,STATUS_ACCEPTED:4,STATUS_COMPLETED:5,STATUS_TERMINATED:6,STATUS_CONFIRMED:7,NON_INVITE_CLIENT:"nict",NON_INVITE_SERVER:"nist",INVITE_CLIENT:"ict",INVITE_SERVER:"ist"},v=function(e){function t(e,n,r,a){i(this,t);var o=s(this,(t.__proto__||Object.getPrototypeOf(t)).call(this));o.type=_.NON_INVITE_CLIENT,o.id="z9hG4bK"+Math.floor(1e7*Math.random()),o.ua=e,o.transport=n,o.request=r,o.eventHandlers=a;var l="SIP/2.0/"+n.via_transport;return l+=" "+e.configuration.via_host+";branch="+o.id,o.request.setHeader("via",l),o.ua.newTransaction(o),o}return a(t,o),r(t,[{key:"stateChanged",value:function(e){this.state=e,this.emit("stateChanged")}},{key:"send",value:function(){var e=this;this.stateChanged(_.STATUS_TRYING),this.F=setTimeout(function(){e.timer_F()},c.TIMER_F),this.transport.send(this.request)||this.onTransportError()}},{key:"onTransportError",value:function(){d("transport error occurred, deleting transaction "+this.id),clearTimeout(this.F),clearTimeout(this.K),this.stateChanged(_.STATUS_TERMINATED),this.ua.destroyTransaction(this),this.eventHandlers.onTransportError()}},{key:"timer_F",value:function(){d("Timer F expired for transaction "+this.id),this.stateChanged(_.STATUS_TERMINATED),this.ua.destroyTransaction(this),this.eventHandlers.onRequestTimeout()}},{key:"timer_K",value:function(){this.stateChanged(_.STATUS_TERMINATED),this.ua.destroyTransaction(this)}},{key:"receiveResponse",value:function(e){var t=this,n=e.status_code;if(n<200)switch(this.state){case _.STATUS_TRYING:case _.STATUS_PROCEEDING:this.stateChanged(_.STATUS_PROCEEDING),this.eventHandlers.onReceiveResponse(e)}else switch(this.state){case _.STATUS_TRYING:case _.STATUS_PROCEEDING:this.stateChanged(_.STATUS_COMPLETED),clearTimeout(this.F),408===n?this.eventHandlers.onRequestTimeout():this.eventHandlers.onReceiveResponse(e),this.K=setTimeout(function(){t.timer_K()},c.TIMER_K);break;case _.STATUS_COMPLETED:}}},{key:"C",get:function(){return _}}]),t}(),g=function(e){function t(e,n,r,a){i(this,t);var o=s(this,(t.__proto__||Object.getPrototypeOf(t)).call(this));o.type=_.INVITE_CLIENT,o.id="z9hG4bK"+Math.floor(1e7*Math.random()),o.ua=e,o.transport=n,o.request=r,o.eventHandlers=a,r.transaction=o;var l="SIP/2.0/"+n.via_transport;return l+=" "+e.configuration.via_host+";branch="+o.id,o.request.setHeader("via",l),o.ua.newTransaction(o),o}return a(t,o),r(t,[{key:"stateChanged",value:function(e){this.state=e,this.emit("stateChanged")}},{key:"send",value:function(){var e=this;this.stateChanged(_.STATUS_CALLING),this.B=setTimeout(function(){e.timer_B()},c.TIMER_B),this.transport.send(this.request)||this.onTransportError()}},{key:"onTransportError",value:function(){clearTimeout(this.B),clearTimeout(this.D),clearTimeout(this.M),this.state!==_.STATUS_ACCEPTED&&(h("transport error occurred, deleting transaction "+this.id),this.eventHandlers.onTransportError()),this.stateChanged(_.STATUS_TERMINATED),this.ua.destroyTransaction(this)}},{key:"timer_M",value:function(){h("Timer M expired for transaction "+this.id),this.state===_.STATUS_ACCEPTED&&(clearTimeout(this.B),this.stateChanged(_.STATUS_TERMINATED),this.ua.destroyTransaction(this))}},{key:"timer_B",value:function(){h("Timer B expired for transaction "+this.id),this.state===_.STATUS_CALLING&&(this.stateChanged(_.STATUS_TERMINATED),this.ua.destroyTransaction(this),this.eventHandlers.onRequestTimeout())}},{key:"timer_D",value:function(){h("Timer D expired for transaction "+this.id),clearTimeout(this.B),this.stateChanged(_.STATUS_TERMINATED),this.ua.destroyTransaction(this)}},{key:"sendACK",value:function(e){var t=this,n=new u.OutgoingRequest(l.ACK,this.request.ruri,this.ua,{route_set:this.request.getHeader("route"),call_id:this.request.getHeader("call-id"),cseq:this.request.cseq});n.setHeader("from",this.request.getHeader("from")),n.setHeader("via",this.request.getHeader("via")),n.setHeader("to",e.getHeader("to")),this.D=setTimeout(function(){t.timer_D()},c.TIMER_D),this.transport.send(n)}},{key:"cancel",value:function(e){if(this.state===_.STATUS_PROCEEDING){var t=new u.OutgoingRequest(l.CANCEL,this.request.ruri,this.ua,{route_set:this.request.getHeader("route"),call_id:this.request.getHeader("call-id"),cseq:this.request.cseq});t.setHeader("from",this.request.getHeader("from")),t.setHeader("via",this.request.getHeader("via")),t.setHeader("to",this.request.getHeader("to")),e&&t.setHeader("reason",e),this.transport.send(t)}}},{key:"receiveResponse",value:function(e){var t=this,n=e.status_code;if(n>=100&&n<=199)switch(this.state){case _.STATUS_CALLING:this.stateChanged(_.STATUS_PROCEEDING),this.eventHandlers.onReceiveResponse(e);break;case _.STATUS_PROCEEDING:this.eventHandlers.onReceiveResponse(e)}else if(n>=200&&n<=299)switch(this.state){case _.STATUS_CALLING:case _.STATUS_PROCEEDING:this.stateChanged(_.STATUS_ACCEPTED),this.M=setTimeout(function(){t.timer_M()},c.TIMER_M),this.eventHandlers.onReceiveResponse(e);break;case _.STATUS_ACCEPTED:this.eventHandlers.onReceiveResponse(e)}else if(n>=300&&n<=699)switch(this.state){case _.STATUS_CALLING:case _.STATUS_PROCEEDING:this.stateChanged(_.STATUS_COMPLETED),this.sendACK(e),this.eventHandlers.onReceiveResponse(e);break;case _.STATUS_COMPLETED:this.sendACK(e)}}},{key:"C",get:function(){return _}}]),t}(),y=function(e){function t(e,n,r,a){i(this,t);var o=s(this,(t.__proto__||Object.getPrototypeOf(t)).call(this));o.id="z9hG4bK"+Math.floor(1e7*Math.random()),o.transport=n,o.request=r,o.eventHandlers=a;var l="SIP/2.0/"+n.via_transport;return l+=" "+e.configuration.via_host+";branch="+o.id,o.request.setHeader("via",l),o}return a(t,o),r(t,[{key:"send",value:function(){this.transport.send(this.request)||this.onTransportError()}},{key:"onTransportError",value:function(){p("transport error occurred for transaction "+this.id),this.eventHandlers.onTransportError()}},{key:"C",get:function(){return _}}]),t}(),T=function(e){function t(e,n,r){i(this,t);var a=s(this,(t.__proto__||Object.getPrototypeOf(t)).call(this));return a.type=_.NON_INVITE_SERVER,a.id=r.via_branch,a.ua=e,a.transport=n,a.request=r,a.last_response="",r.server_transaction=a,a.state=_.STATUS_TRYING,e.newTransaction(a),a}return a(t,o),r(t,[{key:"stateChanged",value:function(e){this.state=e,this.emit("stateChanged")}},{key:"timer_J",value:function(){f("Timer J expired for transaction "+this.id),this.stateChanged(_.STATUS_TERMINATED),this.ua.destroyTransaction(this)}},{key:"onTransportError",value:function(){this.transportError||(this.transportError=!0,f("transport error occurred, deleting transaction "+this.id),clearTimeout(this.J),this.stateChanged(_.STATUS_TERMINATED),this.ua.destroyTransaction(this))}},{key:"receiveResponse",value:function(e,t,n,r){var i=this;if(100===e)switch(this.state){case _.STATUS_TRYING:this.stateChanged(_.STATUS_PROCEEDING),this.transport.send(t)||this.onTransportError();break;case _.STATUS_PROCEEDING:this.last_response=t,this.transport.send(t)?n&&n():(this.onTransportError(),r&&r())}else if(e>=200&&e<=699)switch(this.state){case _.STATUS_TRYING:case _.STATUS_PROCEEDING:this.stateChanged(_.STATUS_COMPLETED),this.last_response=t,this.J=setTimeout(function(){i.timer_J()},c.TIMER_J),this.transport.send(t)?n&&n():(this.onTransportError(),r&&r());break;case _.STATUS_COMPLETED:}}},{key:"C",get:function(){return _}}]),t}(),S=function(e){function t(e,n,r){i(this,t);var a=s(this,(t.__proto__||Object.getPrototypeOf(t)).call(this));return a.type=_.INVITE_SERVER,a.id=r.via_branch,a.ua=e,a.transport=n,a.request=r,a.last_response="",r.server_transaction=a,a.state=_.STATUS_PROCEEDING,e.newTransaction(a),a.resendProvisionalTimer=null,r.reply(100),a}return a(t,o),r(t,[{key:"stateChanged",value:function(e){this.state=e,this.emit("stateChanged")}},{key:"timer_H",value:function(){m("Timer H expired for transaction "+this.id),this.state===_.STATUS_COMPLETED&&m("ACK not received, dialog will be terminated"),this.stateChanged(_.STATUS_TERMINATED),this.ua.destroyTransaction(this)}},{key:"timer_I",value:function(){this.stateChanged(_.STATUS_TERMINATED)}},{key:"timer_L",value:function(){m("Timer L expired for transaction "+this.id),this.state===_.STATUS_ACCEPTED&&(this.stateChanged(_.STATUS_TERMINATED),this.ua.destroyTransaction(this))}},{key:"onTransportError",value:function(){this.transportError||(this.transportError=!0,m("transport error occurred, deleting transaction "+this.id),null!==this.resendProvisionalTimer&&(clearInterval(this.resendProvisionalTimer),this.resendProvisionalTimer=null),clearTimeout(this.L),clearTimeout(this.H),clearTimeout(this.I),this.stateChanged(_.STATUS_TERMINATED),this.ua.destroyTransaction(this))}},{key:"resend_provisional",value:function(){this.transport.send(this.last_response)||this.onTransportError()}},{key:"receiveResponse",value:function(e,t,n,r){var i=this;if(e>=100&&e<=199)switch(this.state){case _.STATUS_PROCEEDING:this.transport.send(t)||this.onTransportError(),this.last_response=t}if(e>100&&e<=199&&this.state===_.STATUS_PROCEEDING)null===this.resendProvisionalTimer&&(this.resendProvisionalTimer=setInterval(function(){i.resend_provisional()},c.PROVISIONAL_RESPONSE_INTERVAL));else if(e>=200&&e<=299)switch(this.state){case _.STATUS_PROCEEDING:this.stateChanged(_.STATUS_ACCEPTED),this.last_response=t,this.L=setTimeout(function(){i.timer_L()},c.TIMER_L),null!==this.resendProvisionalTimer&&(clearInterval(this.resendProvisionalTimer),this.resendProvisionalTimer=null);case _.STATUS_ACCEPTED:this.transport.send(t)?n&&n():(this.onTransportError(),r&&r())}else if(e>=300&&e<=699)switch(this.state){case _.STATUS_PROCEEDING:null!==this.resendProvisionalTimer&&(clearInterval(this.resendProvisionalTimer),this.resendProvisionalTimer=null),this.transport.send(t)?(this.stateChanged(_.STATUS_COMPLETED),this.H=setTimeout(function(){i.timer_H()},c.TIMER_H),n&&n()):(this.onTransportError(),r&&r())}}},{key:"C",get:function(){return _}}]),t}();t.exports={C:_,NonInviteClientTransaction:v,InviteClientTransaction:g,AckClientTransaction:y,NonInviteServerTransaction:T,InviteServerTransaction:S,checkTransaction:function(e,t){var n=e._transactions,r=void 0;switch(t.method){case l.INVITE:if(r=n.ist[t.via_branch]){switch(r.state){case _.STATUS_PROCEEDING:r.transport.send(r.last_response);break;case _.STATUS_ACCEPTED:}return!0}break;case l.ACK:if(!(r=n.ist[t.via_branch]))return!1;if(r.state===_.STATUS_ACCEPTED)return!1;if(r.state===_.STATUS_COMPLETED)return r.state=_.STATUS_CONFIRMED,r.I=setTimeout(function(){r.timer_I()},c.TIMER_I),!0;break;case l.CANCEL:return(r=n.ist[t.via_branch])?(t.reply_sl(200),r.state!==_.STATUS_PROCEEDING):(t.reply_sl(481),!0);default:if(r=n.nist[t.via_branch]){switch(r.state){case _.STATUS_TRYING:break;case _.STATUS_PROCEEDING:case _.STATUS_COMPLETED:r.transport.send(r.last_response)}return!0}}}}},{"./Constants":5,"./SIPMessage":22,"./Timers":24,debug:2,events:1}],26:[function(e,t,n){"use strict";var r=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}();var i=e("./Socket"),s=e("debug")("JsSIP:Transport"),a=e("debug")("JsSIP:ERROR:Transport");a.log=console.warn.bind(console);var o={STATUS_CONNECTED:0,STATUS_CONNECTING:1,STATUS_DISCONNECTED:2,SOCKET_STATUS_READY:0,SOCKET_STATUS_ERROR:1,recovery_options:{min_interval:2,max_interval:30}};t.exports=function(){function e(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:o.recovery_options;if(function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),s("new()"),this.status=o.STATUS_DISCONNECTED,this.socket=null,this.sockets=[],this.recovery_options=n,this.recover_attempts=0,this.recovery_timer=null,this.close_requested=!1,void 0===t)throw new TypeError("Invalid argument. undefined 'sockets' argument");t instanceof Array||(t=[t]),t.forEach(function(e){if(!i.isSocket(e.socket))throw new TypeError("Invalid argument. invalid 'JsSIP.Socket' instance");if(e.weight&&!Number(e.weight))throw new TypeError("Invalid argument. 'weight' attribute is not a number");this.sockets.push({socket:e.socket,weight:e.weight||0,status:o.SOCKET_STATUS_READY})},this),this._getSocket()}return r(e,[{key:"connect",value:function(){s("connect()"),this.isConnected()?s("Transport is already connected"):this.isConnecting()?s("Transport is connecting"):(this.close_requested=!1,this.status=o.STATUS_CONNECTING,this.onconnecting({socket:this.socket,attempts:this.recover_attempts}),this.close_requested||(this.socket.onconnect=this._onConnect.bind(this),this.socket.ondisconnect=this._onDisconnect.bind(this),this.socket.ondata=this._onData.bind(this),this.socket.connect()))}},{key:"disconnect",value:function(){s("close()"),this.close_requested=!0,this.recover_attempts=0,this.status=o.STATUS_DISCONNECTED,null!==this.recovery_timer&&(clearTimeout(this.recovery_timer),this.recovery_timer=null),this.socket.onconnect=function(){},this.socket.ondisconnect=function(){},this.socket.ondata=function(){},this.socket.disconnect(),this.ondisconnect({socket:this.socket,error:!1})}},{key:"send",value:function(e){if(s("send()"),!this.isConnected())return a("unable to send message, transport is not connected"),!1;var t=e.toString();return s("sending message:\n\n"+t+"\n"),this.socket.send(t)}},{key:"isConnected",value:function(){return this.status===o.STATUS_CONNECTED}},{key:"isConnecting",value:function(){return this.status===o.STATUS_CONNECTING}},{key:"_reconnect",value:function(){var e=this;this.recover_attempts+=1;var t=Math.floor(Math.random()*Math.pow(2,this.recover_attempts)+1);t<this.recovery_options.min_interval?t=this.recovery_options.min_interval:t>this.recovery_options.max_interval&&(t=this.recovery_options.max_interval),s("reconnection attempt: "+this.recover_attempts+". next connection attempt in "+t+" seconds"),this.recovery_timer=setTimeout(function(){e.close_requested||e.isConnected()||e.isConnecting()||(e._getSocket(),e.connect())},1e3*t)}},{key:"_getSocket",value:function(){var e=[];if(this.sockets.forEach(function(t){t.status!==o.SOCKET_STATUS_ERROR&&(0===e.length?e.push(t):t.weight>e[0].weight?e=[t]:t.weight===e[0].weight&&e.push(t))}),0===e.length)return this.sockets.forEach(function(e){e.status=o.SOCKET_STATUS_READY}),void this._getSocket();var t=Math.floor(Math.random()*e.length);this.socket=e[t].socket}},{key:"_onConnect",value:function(){this.recover_attempts=0,this.status=o.STATUS_CONNECTED,null!==this.recovery_timer&&(clearTimeout(this.recovery_timer),this.recovery_timer=null),this.onconnect({socket:this})}},{key:"_onDisconnect",value:function(e,t,n){this.status=o.STATUS_DISCONNECTED,this.ondisconnect({socket:this.socket,error:e,code:t,reason:n}),this.close_requested||(this.sockets.forEach(function(e){this.socket===e.socket&&(e.status=o.SOCKET_STATUS_ERROR)},this),this._reconnect(e))}},{key:"_onData",value:function(e){if("\r\n"!==e){if("string"!=typeof e){try{e=String.fromCharCode.apply(null,new Uint8Array(e))}catch(e){return void s("received binary message failed to be converted into string, message discarded")}s("received binary message:\n\n"+e+"\n")}else s("received text message:\n\n"+e+"\n");this.ondata({transport:this,message:e})}else s("received message with CRLF Keep Alive response")}},{key:"via_transport",get:function(){return this.socket.via_transport}},{key:"url",get:function(){return this.socket.url}},{key:"sip_uri",get:function(){return this.socket.sip_uri}}]),e}()},{"./Socket":23,debug:2}],27:[function(e,t,n){"use strict";var r=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}();var i=e("events").EventEmitter,s=e("./Constants"),a=e("./Registrator"),o=e("./RTCSession"),l=e("./Message"),u=e("./Transactions"),c=e("./Transport"),d=e("./Utils"),h=e("./Exceptions"),p=e("./URI"),f=e("./Grammar"),m=e("./Parser"),_=e("./SIPMessage"),v=e("./sanityCheck"),g=e("./Config"),y=e("debug")("JsSIP:UA"),T=e("debug")("JsSIP:ERROR:UA");T.log=console.warn.bind(console);var S={STATUS_INIT:0,STATUS_READY:1,STATUS_USER_CLOSED:2,STATUS_NOT_READY:3,CONFIGURATION_ERROR:1,NETWORK_ERROR:2};t.exports=function(e){function t(e){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),y("new() [configuration:%o]",e);var n=function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}(this,(t.__proto__||Object.getPrototypeOf(t)).call(this));if(n._cache={credentials:{}},n._configuration=Object.assign({},g.settings),n._dynConfiguration={},n._dialogs={},n._applicants={},n._sessions={},n._transport=null,n._contact=null,n._status=S.STATUS_INIT,n._error=null,n._transactions={nist:{},nict:{},ist:{},ict:{}},n._data={},n._closeTimer=null,void 0===e)throw new TypeError("Not enough arguments");try{n._loadConfig(e)}catch(e){throw n._status=S.STATUS_NOT_READY,n._error=S.CONFIGURATION_ERROR,e}return n._registrator=new a(n),n}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}(t,i),r(t,null,[{key:"C",get:function(){return S}}]),r(t,[{key:"start",value:function(){y("start()"),this._status===S.STATUS_INIT?this._transport.connect():this._status===S.STATUS_USER_CLOSED?(y("restarting UA"),null!==this._closeTimer&&(clearTimeout(this._closeTimer),this._closeTimer=null,this._transport.disconnect()),this._status=S.STATUS_INIT,this._transport.connect()):this._status===S.STATUS_READY?y("UA is in READY status, not restarted"):y("ERROR: connection is down, Auto-Recovery system is trying to reconnect"),this._dynConfiguration.register=this._configuration.register}},{key:"register",value:function(){y("register()"),this._dynConfiguration.register=!0,this._registrator.register()}},{key:"unregister",value:function(e){y("unregister()"),this._dynConfiguration.register=!1,this._registrator.unregister(e)}},{key:"registrator",value:function(){return this._registrator}},{key:"isRegistered",value:function(){return this._registrator.registered}},{key:"isConnected",value:function(){return this._transport.isConnected()}},{key:"call",value:function(e,t){y("call()");var n=new o(this);return n.connect(e,t),n}},{key:"sendMessage",value:function(e,t,n){y("sendMessage()");var r=new l(this);return r.send(e,t,n),r}},{key:"terminateSessions",value:function(e){for(var t in y("terminateSessions()"),this._sessions)this._sessions[t].isEnded()||this._sessions[t].terminate(e)}},{key:"stop",value:function(){var e=this;if(y("stop()"),this._dynConfiguration={},this._status!==S.STATUS_USER_CLOSED){this._registrator.close();var t=Object.keys(this._sessions).length;for(var n in this._sessions)if(Object.prototype.hasOwnProperty.call(this._sessions,n)){y("closing session "+n);try{this._sessions[n].terminate()}catch(e){}}for(var r in this._applicants)if(Object.prototype.hasOwnProperty.call(this._applicants,r))try{this._applicants[r].close()}catch(e){}this._status=S.STATUS_USER_CLOSED,0===Object.keys(this._transactions.nict).length+Object.keys(this._transactions.nist).length+Object.keys(this._transactions.ict).length+Object.keys(this._transactions.ist).length&&0===t?this._transport.disconnect():this._closeTimer=setTimeout(function(){e._closeTimer=null,e._transport.disconnect()},2e3)}else y("UA already closed")}},{key:"normalizeTarget",value:function(e){return d.normalizeTarget(e,this._configuration.hostport_params)}},{key:"get",value:function(e){switch(e){case"realm":return this._configuration.realm;case"ha1":return this._configuration.ha1;default:return void T('get() | cannot get "%s" parameter in runtime',e)}}},{key:"set",value:function(e,t){switch(e){case"password":this._configuration.password=String(t);break;case"realm":this._configuration.realm=String(t);break;case"ha1":this._configuration.ha1=String(t),this._configuration.password=null;break;case"display_name":if(-1===f.parse('"'+t+'"',"display_name"))return T('set() | wrong "display_name"'),!1;this._configuration.display_name=t;break;default:return T('set() | cannot set "%s" parameter in runtime',e),!1}return!0}},{key:"newTransaction",value:function(e){this._transactions[e.type][e.id]=e,this.emit("newTransaction",{transaction:e})}},{key:"destroyTransaction",value:function(e){delete this._transactions[e.type][e.id],this.emit("transactionDestroyed",{transaction:e})}},{key:"newDialog",value:function(e){this._dialogs[e.id]=e}},{key:"destroyDialog",value:function(e){delete this._dialogs[e.id]}},{key:"newMessage",value:function(e,t){this._applicants[e]=e,this.emit("newMessage",t)}},{key:"destroyMessage",value:function(e){delete this._applicants[e]}},{key:"newRTCSession",value:function(e,t){this._sessions[e.id]=e,this.emit("newRTCSession",t)}},{key:"destroyRTCSession",value:function(e){delete this._sessions[e.id]}},{key:"registered",value:function(e){this.emit("registered",e)}},{key:"unregistered",value:function(e){this.emit("unregistered",e)}},{key:"registrationFailed",value:function(e){this.emit("registrationFailed",e)}},{key:"receiveRequest",value:function(e){var t=e.method;if(e.ruri.user!==this._configuration.uri.user&&e.ruri.user!==this._contact.uri.user)return y("Request-URI does not point to us"),void(e.method!==s.ACK&&e.reply_sl(404));if(e.ruri.scheme!==s.SIPS){if(!u.checkTransaction(this,e)){if(t===s.INVITE?new u.InviteServerTransaction(this,this._transport,e):t!==s.ACK&&t!==s.CANCEL&&new u.NonInviteServerTransaction(this,this._transport,e),t===s.OPTIONS)e.reply(200);else if(t===s.MESSAGE){if(0===this.listeners("newMessage").length)return void e.reply(405);new l(this).init_incoming(e)}else if(t===s.INVITE&&!e.to_tag&&0===this.listeners("newRTCSession").length)return void e.reply(405);var n=void 0,r=void 0;if(e.to_tag)(n=this._findDialog(e.call_id,e.from_tag,e.to_tag))?n.receiveRequest(e):t===s.NOTIFY?(r=this._findSession(e))?r.receiveRequest(e):(y("received NOTIFY request for a non existent subscription"),e.reply(481,"Subscription does not exist")):t!==s.ACK&&e.reply(481);else switch(t){case s.INVITE:if(window.RTCPeerConnection)if(e.hasHeader("replaces")){var i=e.replaces;(n=this._findDialog(i.call_id,i.from_tag,i.to_tag))?(r=n.owner).isEnded()?e.reply(603):r.receiveRequest(e):e.reply(481)}else(r=new o(this)).init_incoming(e);else T("INVITE received but WebRTC is not supported"),e.reply(488);break;case s.BYE:e.reply(481);break;case s.CANCEL:(r=this._findSession(e))?r.receiveRequest(e):y("received CANCEL request for a non existent session");break;case s.ACK:break;default:e.reply(405)}}}else e.reply_sl(416)}},{key:"_findSession",value:function(e){var t=e.call_id,n=e.from_tag,r=e.to_tag,i=t+n,s=this._sessions[i],a=t+r,o=this._sessions[a];return s||(o||null)}},{key:"_findDialog",value:function(e,t,n){var r=e+t+n,i=this._dialogs[r];return i||(r=e+n+t,(i=this._dialogs[r])||null)}},{key:"_loadConfig",value:function(e){try{g.load(this._configuration,e)}catch(e){throw e}0===this._configuration.display_name&&(this._configuration.display_name="0"),this._configuration.instance_id||(this._configuration.instance_id=d.newUUID()),this._configuration.jssip_id=d.createRandomToken(5);var t=this._configuration.uri.clone();t.user=null,this._configuration.hostport_params=t.toString().replace(/^sip:/i,"");try{this._transport=new c(this._configuration.sockets,{max_interval:this._configuration.connection_recovery_max_interval,min_interval:this._configuration.connection_recovery_min_interval}),this._transport.onconnecting=function(e){this.emit("connecting",e)}.bind(this),this._transport.onconnect=function(e){if(this._status===S.STATUS_USER_CLOSED)return;this._status=S.STATUS_READY,this._error=null,this.emit("connected",e),this._dynConfiguration.register&&this._registrator.register()}.bind(this),this._transport.ondisconnect=function(e){var t=!0,n=!1,r=void 0;try{for(var i,s=["nict","ict","nist","ist"][Symbol.iterator]();!(t=(i=s.next()).done);t=!0){var a=i.value;for(var o in this._transactions[a])Object.prototype.hasOwnProperty.call(this._transactions[a],o)&&this._transactions[a][o].onTransportError()}}catch(e){n=!0,r=e}finally{try{!t&&s.return&&s.return()}finally{if(n)throw r}}this.emit("disconnected",e),this._registrator.onTransportClosed(),this._status!==S.STATUS_USER_CLOSED&&(this._status=S.STATUS_NOT_READY,this._error=S.NETWORK_ERROR)}.bind(this),this._transport.ondata=function(e){var t=e.transport,n=e.message;if(!(n=m.parseMessage(n,this)))return;if(this._status===S.STATUS_USER_CLOSED&&n instanceof _.IncomingRequest)return;if(!v(n,this,t))return;if(n instanceof _.IncomingRequest)n.transport=t,this.receiveRequest(n);else if(n instanceof _.IncomingResponse){var r=void 0;switch(n.method){case s.INVITE:(r=this._transactions.ict[n.via_branch])&&r.receiveResponse(n);break;case s.ACK:break;default:(r=this._transactions.nict[n.via_branch])&&r.receiveResponse(n)}}}.bind(this)}catch(e){throw T(e),new h.ConfigurationError("sockets",this._configuration.sockets)}if(delete this._configuration.sockets,this._configuration.authorization_user||(this._configuration.authorization_user=this._configuration.uri.user),!this._configuration.registrar_server){var n=this._configuration.uri.clone();n.user=null,n.clearParams(),n.clearHeaders(),this._configuration.registrar_server=n}this._configuration.no_answer_timeout*=1e3,this._configuration.contact_uri?this._configuration.via_host=this._configuration.contact_uri.host:this._configuration.contact_uri=new p("sip",d.createRandomToken(8),this._configuration.via_host,null,{transport:"ws"}),this._contact={pub_gruu:null,temp_gruu:null,uri:this._configuration.contact_uri,toString:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.anonymous||null,n=e.outbound||null,r="<";return r+=t?this.temp_gruu||"sip:anonymous@anonymous.invalid;transport=ws":this.pub_gruu||this.uri.toString(),!n||(t?this.temp_gruu:this.pub_gruu)||(r+=";ob"),r+=">"}};var r=["password","realm","ha1","display_name","register"];for(var i in this._configuration)Object.prototype.hasOwnProperty.call(this._configuration,i)&&(-1!==r.indexOf(i)?Object.defineProperty(this._configuration,i,{writable:!0,configurable:!1}):Object.defineProperty(this._configuration,i,{writable:!1,configurable:!1}));for(var a in y("configuration parameters after validation:"),this._configuration)if(Object.prototype.hasOwnProperty.call(g.settings,a))switch(a){case"uri":case"registrar_server":y("- "+a+": "+this._configuration[a]);break;case"password":case"ha1":y("- "+a+": NOT SHOWN");break;default:y("- "+a+": "+JSON.stringify(this._configuration[a]))}}},{key:"C",get:function(){return S}},{key:"status",get:function(){return this._status}},{key:"contact",get:function(){return this._contact}},{key:"configuration",get:function(){return this._configuration}},{key:"transport",get:function(){return this._transport}}]),t}()},{"./Config":4,"./Constants":5,"./Exceptions":9,"./Grammar":10,"./Message":12,"./Parser":14,"./RTCSession":15,"./Registrator":20,"./SIPMessage":22,"./Transactions":25,"./Transport":26,"./URI":28,"./Utils":29,"./sanityCheck":31,debug:2,events:1}],28:[function(e,t,n){"use strict";var r=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}();var i=e("./Constants"),s=e("./Utils"),a=e("./Grammar");t.exports=function(){function e(t,n,r,s){var a=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{},o=arguments.length>5&&void 0!==arguments[5]?arguments[5]:{};if(function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),!r)throw new TypeError('missing or invalid "host" parameter');for(var l in this._parameters={},this._headers={},this._scheme=t||i.SIP,this._user=n,this._host=r,this._port=s,a)Object.prototype.hasOwnProperty.call(a,l)&&this.setParam(l,a[l]);for(var u in o)Object.prototype.hasOwnProperty.call(o,u)&&this.setHeader(u,o[u])}return r(e,null,[{key:"parse",value:function(e){return-1!==(e=a.parse(e,"SIP_URI"))?e:void 0}}]),r(e,[{key:"setParam",value:function(e,t){e&&(this._parameters[e.toLowerCase()]=null==t?null:t.toString())}},{key:"getParam",value:function(e){if(e)return this._parameters[e.toLowerCase()]}},{key:"hasParam",value:function(e){if(e)return!!this._parameters.hasOwnProperty(e.toLowerCase())}},{key:"deleteParam",value:function(e){if(e=e.toLowerCase(),this._parameters.hasOwnProperty(e)){var t=this._parameters[e];return delete this._parameters[e],t}}},{key:"clearParams",value:function(){this._parameters={}}},{key:"setHeader",value:function(e,t){this._headers[s.headerize(e)]=Array.isArray(t)?t:[t]}},{key:"getHeader",value:function(e){if(e)return this._headers[s.headerize(e)]}},{key:"hasHeader",value:function(e){if(e)return!!this._headers.hasOwnProperty(s.headerize(e))}},{key:"deleteHeader",value:function(e){if(e=s.headerize(e),this._headers.hasOwnProperty(e)){var t=this._headers[e];return delete this._headers[e],t}}},{key:"clearHeaders",value:function(){this._headers={}}},{key:"clone",value:function(){return new e(this._scheme,this._user,this._host,this._port,JSON.parse(JSON.stringify(this._parameters)),JSON.parse(JSON.stringify(this._headers)))}},{key:"toString",value:function(){var e=[],t=this._scheme+":";for(var n in this._user&&(t+=s.escapeUser(this._user)+"@"),t+=this._host,(this._port||0===this._port)&&(t+=":"+this._port),this._parameters)Object.prototype.hasOwnProperty.call(this._parameters,n)&&(t+=";"+n,null!==this._parameters[n]&&(t+="="+this._parameters[n]));for(var r in this._headers)if(Object.prototype.hasOwnProperty.call(this._headers,r)){var i=!0,a=!1,o=void 0;try{for(var l,u=this._headers[r][Symbol.iterator]();!(i=(l=u.next()).done);i=!0){var c=l.value;e.push(r+"="+c)}}catch(e){a=!0,o=e}finally{try{!i&&u.return&&u.return()}finally{if(a)throw o}}}return e.length>0&&(t+="?"+e.join("&")),t}},{key:"toAor",value:function(e){var t=this._scheme+":";return this._user&&(t+=s.escapeUser(this._user)+"@"),t+=this._host,e&&(this._port||0===this._port)&&(t+=":"+this._port),t}},{key:"scheme",get:function(){return this._scheme},set:function(e){this._scheme=e.toLowerCase()}},{key:"user",get:function(){return this._user},set:function(e){this._user=e}},{key:"host",get:function(){return this._host},set:function(e){this._host=e.toLowerCase()}},{key:"port",get:function(){return this._port},set:function(e){this._port=0===e?e:parseInt(e,10)||null}}]),e}()},{"./Constants":5,"./Grammar":10,"./Utils":29}],29:[function(e,t,n){"use strict";var r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},i=e("./Constants"),s=e("./URI"),a=e("./Grammar");n.str_utf8_length=function(e){return unescape(encodeURIComponent(e)).length};var o=n.isFunction=function(e){return void 0!==e&&"[object Function]"===Object.prototype.toString.call(e)};n.isString=function(e){return void 0!==e&&"[object String]"===Object.prototype.toString.call(e)},n.isDecimal=function(e){return!isNaN(e)&&parseFloat(e)===parseInt(e,10)},n.isEmpty=function(e){return null===e||""===e||void 0===e||Array.isArray(e)&&0===e.length||"number"==typeof e&&isNaN(e)},n.hasMethods=function(e){for(var t=arguments.length,n=Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];var i=!0,s=!1,a=void 0;try{for(var l,u=n[Symbol.iterator]();!(i=(l=u.next()).done);i=!0){var c=l.value;if(o(e[c]))return!1}}catch(e){s=!0,a=e}finally{try{!i&&u.return&&u.return()}finally{if(s)throw a}}return!0};var l=n.createRandomToken=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:32,n=void 0,r="";for(n=0;n<e;n++)r+=(Math.random()*t|0).toString(t);return r};n.newTag=function(){return l(10)},n.newUUID=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(e){var t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)})},n.hostType=function(e){if(e)return-1!==(e=a.parse(e,"host"))?e.host_type:void 0};var u=n.escapeUser=function(e){return encodeURIComponent(decodeURIComponent(e)).replace(/%3A/gi,":").replace(/%2B/gi,"+").replace(/%3F/gi,"?").replace(/%2F/gi,"/")};n.normalizeTarget=function(e,t){if(e){if(e instanceof s)return e;if("string"==typeof e){var n=e.split("@"),r=void 0,a=void 0;switch(n.length){case 1:if(!t)return;r=e,a=t;break;case 2:r=n[0],a=n[1];break;default:r=n.slice(0,n.length-1).join("@"),a=n[n.length-1]}r=r.replace(/^(sips?|tel):/i,""),/^[-.()]*\+?[0-9\-.()]+$/.test(r)&&(r=r.replace(/[-.()]/g,"")),e=i.SIP+":"+u(r)+"@"+a;var o;return(o=s.parse(e))?o:void 0}}else;},n.headerize=function(e){var t={"Call-Id":"Call-ID",Cseq:"CSeq","Www-Authenticate":"WWW-Authenticate"},n=e.toLowerCase().replace(/_/g,"-").split("-"),r="",i=n.length,s=void 0;for(s=0;s<i;s++)0!==s&&(r+="-"),r+=n[s].charAt(0).toUpperCase()+n[s].substring(1);return t[r]&&(r=t[r]),r},n.sipErrorCause=function(e){for(var t in i.SIP_ERROR_CAUSES)if(-1!==i.SIP_ERROR_CAUSES[t].indexOf(e))return i.causes[t];return i.causes.SIP_FAILURE_CODE},n.getRandomTestNetIP=function(){return"192.0.2."+(e=1,t=254,Math.floor(Math.random()*(t-e+1)+e));var e,t},n.calculateMD5=function(e){function t(e,t){return e<<t|e>>>32-t}function n(e,t){var n=2147483648&e,r=2147483648&t,i=1073741824&e,s=1073741824&t,a=(1073741823&e)+(1073741823&t);return i&s?2147483648^a^n^r:i|s?1073741824&a?3221225472^a^n^r:1073741824^a^n^r:a^n^r}function r(e,r,i,s,a,o,l){return e=n(e,n(n(function(e,t,n){return e&t|~e&n}(r,i,s),a),l)),n(t(e,o),r)}function i(e,r,i,s,a,o,l){return e=n(e,n(n(function(e,t,n){return e&n|t&~n}(r,i,s),a),l)),n(t(e,o),r)}function s(e,r,i,s,a,o,l){return e=n(e,n(n(function(e,t,n){return e^t^n}(r,i,s),a),l)),n(t(e,o),r)}function a(e,r,i,s,a,o,l){return e=n(e,n(n(function(e,t,n){return t^(e|~n)}(r,i,s),a),l)),n(t(e,o),r)}function o(e){var t="",n="",r=void 0;for(r=0;r<=3;r++)t+=(n="0"+(e>>>8*r&255).toString(16)).substr(n.length-2,2);return t}var l,u=void 0,c=void 0,d=void 0,h=void 0,p=void 0,f=void 0,m=void 0,_=void 0,v=void 0;for(l=function(e){for(var t=void 0,n=e.length,r=n+8,i=16*((r-r%64)/64+1),s=new Array(i-1),a=0,o=0;o<n;)a=o%4*8,s[t=(o-o%4)/4]=s[t]|e.charCodeAt(o)<<a,o++;return a=o%4*8,s[t=(o-o%4)/4]=s[t]|128<<a,s[i-2]=n<<3,s[i-1]=n>>>29,s}(e=function(e){e=e.replace(/\r\n/g,"\n");for(var t="",n=0;n<e.length;n++){var r=e.charCodeAt(n);r<128?t+=String.fromCharCode(r):r>127&&r<2048?(t+=String.fromCharCode(r>>6|192),t+=String.fromCharCode(63&r|128)):(t+=String.fromCharCode(r>>12|224),t+=String.fromCharCode(r>>6&63|128),t+=String.fromCharCode(63&r|128))}return t}(e)),f=1732584193,m=4023233417,_=2562383102,v=271733878,u=0;u<l.length;u+=16)c=f,d=m,h=_,p=v,f=r(f,m,_,v,l[u+0],7,3614090360),v=r(v,f,m,_,l[u+1],12,3905402710),_=r(_,v,f,m,l[u+2],17,606105819),m=r(m,_,v,f,l[u+3],22,3250441966),f=r(f,m,_,v,l[u+4],7,4118548399),v=r(v,f,m,_,l[u+5],12,1200080426),_=r(_,v,f,m,l[u+6],17,2821735955),m=r(m,_,v,f,l[u+7],22,4249261313),f=r(f,m,_,v,l[u+8],7,1770035416),v=r(v,f,m,_,l[u+9],12,2336552879),_=r(_,v,f,m,l[u+10],17,4294925233),m=r(m,_,v,f,l[u+11],22,2304563134),f=r(f,m,_,v,l[u+12],7,1804603682),v=r(v,f,m,_,l[u+13],12,4254626195),_=r(_,v,f,m,l[u+14],17,2792965006),f=i(f,m=r(m,_,v,f,l[u+15],22,1236535329),_,v,l[u+1],5,4129170786),v=i(v,f,m,_,l[u+6],9,3225465664),_=i(_,v,f,m,l[u+11],14,643717713),m=i(m,_,v,f,l[u+0],20,3921069994),f=i(f,m,_,v,l[u+5],5,3593408605),v=i(v,f,m,_,l[u+10],9,38016083),_=i(_,v,f,m,l[u+15],14,3634488961),m=i(m,_,v,f,l[u+4],20,3889429448),f=i(f,m,_,v,l[u+9],5,568446438),v=i(v,f,m,_,l[u+14],9,3275163606),_=i(_,v,f,m,l[u+3],14,4107603335),m=i(m,_,v,f,l[u+8],20,1163531501),f=i(f,m,_,v,l[u+13],5,2850285829),v=i(v,f,m,_,l[u+2],9,4243563512),_=i(_,v,f,m,l[u+7],14,1735328473),f=s(f,m=i(m,_,v,f,l[u+12],20,2368359562),_,v,l[u+5],4,4294588738),v=s(v,f,m,_,l[u+8],11,2272392833),_=s(_,v,f,m,l[u+11],16,1839030562),m=s(m,_,v,f,l[u+14],23,4259657740),f=s(f,m,_,v,l[u+1],4,2763975236),v=s(v,f,m,_,l[u+4],11,1272893353),_=s(_,v,f,m,l[u+7],16,4139469664),m=s(m,_,v,f,l[u+10],23,3200236656),f=s(f,m,_,v,l[u+13],4,681279174),v=s(v,f,m,_,l[u+0],11,3936430074),_=s(_,v,f,m,l[u+3],16,3572445317),m=s(m,_,v,f,l[u+6],23,76029189),f=s(f,m,_,v,l[u+9],4,3654602809),v=s(v,f,m,_,l[u+12],11,3873151461),_=s(_,v,f,m,l[u+15],16,530742520),f=a(f,m=s(m,_,v,f,l[u+2],23,3299628645),_,v,l[u+0],6,4096336452),v=a(v,f,m,_,l[u+7],10,1126891415),_=a(_,v,f,m,l[u+14],15,2878612391),m=a(m,_,v,f,l[u+5],21,4237533241),f=a(f,m,_,v,l[u+12],6,1700485571),v=a(v,f,m,_,l[u+3],10,2399980690),_=a(_,v,f,m,l[u+10],15,4293915773),m=a(m,_,v,f,l[u+1],21,2240044497),f=a(f,m,_,v,l[u+8],6,1873313359),v=a(v,f,m,_,l[u+15],10,4264355552),_=a(_,v,f,m,l[u+6],15,2734768916),m=a(m,_,v,f,l[u+13],21,1309151649),f=a(f,m,_,v,l[u+4],6,4149444226),v=a(v,f,m,_,l[u+11],10,3174756917),_=a(_,v,f,m,l[u+2],15,718787259),m=a(m,_,v,f,l[u+9],21,3951481745),f=n(f,c),m=n(m,d),_=n(_,h),v=n(v,p);return(o(f)+o(m)+o(_)+o(v)).toLowerCase()},n.closeMediaStream=function(e){if(e)try{var t=void 0;if(e.getTracks){t=e.getTracks();var n=!0,i=!1,s=void 0;try{for(var a,o=t[Symbol.iterator]();!(n=(a=o.next()).done);n=!0){a.value.stop()}}catch(e){i=!0,s=e}finally{try{!n&&o.return&&o.return()}finally{if(i)throw s}}}else{t=e.getAudioTracks();var l=!0,u=!1,c=void 0;try{for(var d,h=t[Symbol.iterator]();!(l=(d=h.next()).done);l=!0){d.value.stop()}}catch(e){u=!0,c=e}finally{try{!l&&h.return&&h.return()}finally{if(u)throw c}}t=e.getVideoTracks();var p=!0,f=!1,m=void 0;try{for(var _,v=t[Symbol.iterator]();!(p=(_=v.next()).done);p=!0){_.value.stop()}}catch(e){f=!0,m=e}finally{try{!p&&v.return&&v.return()}finally{if(f)throw m}}}}catch(t){"function"!=typeof e.stop&&"object"!==r(e.stop)||e.stop()}},n.cloneArray=function(e){return e&&e.slice()||[]}},{"./Constants":5,"./Grammar":10,"./URI":28}],30:[function(e,t,n){"use strict";var r=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}();var i=e("./Grammar"),s=e("debug")("JsSIP:WebSocketInterface"),a=e("debug")("JsSIP:ERROR:WebSocketInterface");a.log=console.warn.bind(console),t.exports=function(){function e(t){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),s('new() [url:"%s"]',t),this._url=t,this._sip_uri=null,this._via_transport=null,this._ws=null;var n=i.parse(t,"absoluteURI");if(-1===n)throw a("invalid WebSocket URI: "+t),new TypeError("Invalid argument: "+t);if("wss"!==n.scheme&&"ws"!==n.scheme)throw a("invalid WebSocket URI scheme: "+n.scheme),new TypeError("Invalid argument: "+t);this._sip_uri="sip:"+n.host+(n.port?":"+n.port:"")+";transport=ws",this._via_transport=n.scheme.toUpperCase()}return r(e,[{key:"connect",value:function(){if(s("connect()"),this.isConnected())s("WebSocket "+this._url+" is already connected");else if(this.isConnecting())s("WebSocket "+this._url+" is connecting");else{this._ws&&this.disconnect(),s("connecting to WebSocket "+this._url);try{this._ws=new WebSocket(this._url,"sip"),this._ws.binaryType="arraybuffer",this._ws.onopen=this._onOpen.bind(this),this._ws.onclose=this._onClose.bind(this),this._ws.onmessage=this._onMessage.bind(this),this._ws.onerror=this._onError.bind(this)}catch(e){this._onError(e)}}}},{key:"disconnect",value:function(){s("disconnect()"),this._ws&&(this._ws.onopen=function(){},this._ws.onclose=function(){},this._ws.onmessage=function(){},this._ws.onerror=function(){},this._ws.close(),this._ws=null)}},{key:"send",value:function(e){return s("send()"),this.isConnected()?(this._ws.send(e),!0):(a("unable to send message, WebSocket is not open"),!1)}},{key:"isConnected",value:function(){return this._ws&&this._ws.readyState===this._ws.OPEN}},{key:"isConnecting",value:function(){return this._ws&&this._ws.readyState===this._ws.CONNECTING}},{key:"_onOpen",value:function(){s("WebSocket "+this._url+" connected"),this.onconnect()}},{key:"_onClose",value:function(e){var t=e.wasClean,n=e.code,r=e.reason;s("WebSocket "+this._url+" closed"),!1===t&&s("WebSocket abrupt disconnection");var i={socket:this,error:!t,code:n,reason:r};this.ondisconnect(i)}},{key:"_onMessage",value:function(e){var t=e.data;s("received WebSocket message"),this.ondata(t)}},{key:"_onError",value:function(e){a("WebSocket "+this._url+" error: "+e)}},{key:"via_transport",get:function(){return this._via_transport},set:function(e){this._via_transport=e.toUpperCase()}},{key:"sip_uri",get:function(){return this._sip_uri}},{key:"url",get:function(){return this._url}}]),e}()},{"./Grammar":10,debug:2}],31:[function(e,t,n){"use strict";var r=e("./Constants"),i=e("./SIPMessage"),s=e("./Utils"),a=e("debug")("JsSIP:sanityCheck"),o=[function(){var e=!0,t=!1,n=void 0;try{for(var r,i=["from","to","call_id","cseq","via"][Symbol.iterator]();!(e=(r=i.next()).done);e=!0){var s=r.value;if(!c.hasHeader(s))return a("missing mandatory header field : "+s+", dropping the response"),!1}}catch(e){t=!0,n=e}finally{try{!e&&i.return&&i.return()}finally{if(t)throw n}}}],l=[function(){if("sip"!==c.s("to").uri.scheme)return p(416),!1},function(){if(!c.to_tag&&c.call_id.substr(0,5)===d.configuration.jssip_id)return p(482),!1},function(){var e=s.str_utf8_length(c.body),t=c.getHeader("content-length");if(e<t)return p(400),!1},function(){var e=c.from_tag,t=c.call_id,n=c.cseq,i=void 0;if(c.to_tag)return;if(c.method===r.INVITE){if(d._transactions.ist[c.via_branch])return!1;for(var s in d._transactions.ist)if(Object.prototype.hasOwnProperty.call(d._transactions.ist,s)&&(i=d._transactions.ist[s]).request.from_tag===e&&i.request.call_id===t&&i.request.cseq===n)return p(482),!1}else{if(d._transactions.nist[c.via_branch])return!1;for(var a in d._transactions.nist)if(Object.prototype.hasOwnProperty.call(d._transactions.nist,a)&&(i=d._transactions.nist[a]).request.from_tag===e&&i.request.call_id===t&&i.request.cseq===n)return p(482),!1}}],u=[function(){if(c.getHeaders("via").length>1)return a("more than one Via header field present in the response, dropping the response"),!1},function(){var e=s.str_utf8_length(c.body),t=c.getHeader("content-length");if(e<t)return a("message body length is lower than the value in Content-Length header field, dropping the response"),!1}],c=void 0,d=void 0,h=void 0;function p(e){var t=c.getHeaders("via"),n=void 0,i="SIP/2.0 "+e+" "+r.REASON_PHRASE[e]+"\r\n",a=!0,o=!1,l=void 0;try{for(var u,d=t[Symbol.iterator]();!(a=(u=d.next()).done);a=!0){i+="Via: "+u.value+"\r\n"}}catch(e){o=!0,l=e}finally{try{!a&&d.return&&d.return()}finally{if(o)throw l}}n=c.getHeader("To"),c.to_tag||(n+=";tag="+s.newTag()),i+="To: "+n+"\r\n",i+="From: "+c.getHeader("From")+"\r\n",i+="Call-ID: "+c.call_id+"\r\n",i+="CSeq: "+c.cseq+" "+c.method+"\r\n",i+="\r\n",h.send(i)}t.exports=function(e,t,n){c=e,d=t,h=n;var r=!0,s=!1,a=void 0;try{for(var p,f=o[Symbol.iterator]();!(r=(p=f.next()).done);r=!0){if(!1===(0,p.value)())return!1}}catch(e){s=!0,a=e}finally{try{!r&&f.return&&f.return()}finally{if(s)throw a}}if(c instanceof i.IncomingRequest){var m=!0,_=!1,v=void 0;try{for(var g,y=l[Symbol.iterator]();!(m=(g=y.next()).done);m=!0){if(!1===(0,g.value)())return!1}}catch(e){_=!0,v=e}finally{try{!m&&y.return&&y.return()}finally{if(_)throw v}}}else if(c instanceof i.IncomingResponse){var T=!0,S=!1,C=void 0;try{for(var E,b=u[Symbol.iterator]();!(T=(E=b.next()).done);T=!0){if(!1===(0,E.value)())return!1}}catch(e){S=!0,C=e}finally{try{!T&&b.return&&b.return()}finally{if(S)throw C}}}return!0}},{"./Constants":5,"./SIPMessage":22,"./Utils":29,debug:2}],32:[function(e,t,n){t.exports={_from:"jssip@^3.2.11",_id:"jssip@3.2.11",_inBundle:!1,_integrity:"sha1-5ou6ODFKs4YXQjdE1huMfouSGNg=",_location:"/jssip",_phantomChildren:{},_requested:{type:"range",registry:!0,raw:"jssip@^3.2.11",name:"jssip",escapedName:"jssip",rawSpec:"^3.2.11",saveSpec:null,fetchSpec:"^3.2.11"},_requiredBy:["/"],_resolved:"http://registry.npm.taobao.org/jssip/download/jssip-3.2.11.tgz",_shasum:"e68bba38314ab38617423744d61b8c7e8b9218d8",_spec:"jssip@^3.2.11",_where:"D:\\caoshiyuan\\vocieTack\\jssipWrapper",author:{name:"José Luis Millán",email:"jmillan@aliax.net",url:"https://github.com/jmillan"},bugs:{url:"https://github.com/versatica/JsSIP/issues"},bundleDependencies:!1,contributors:[{name:"Iñaki Baz Castillo",email:"ibc@aliax.net",url:"https://github.com/ibc"},{name:"Saúl Ibarra Corretgé",email:"saghul@gmail.com",url:"https://github.com/saghul"}],dependencies:{debug:"^3.1.0",events:"^2.0.0","sdp-transform":"^2.4.1","webrtc-adapter":"^6.1.5"},deprecated:!1,description:"the Javascript SIP library",devDependencies:{"ansi-colors":"^1.1.0","babel-core":"^6.26.0","babel-preset-env":"^1.6.1",browserify:"^16.2.0",eslint:"^4.19.1","fancy-log":"^1.3.2",gulp:"^4.0.0","gulp-babel":"^7.0.1","gulp-eslint":"^4.0.2","gulp-expect-file":"0.0.7","gulp-header":"^2.0.5","gulp-nodeunit-runner":"^0.2.2","gulp-plumber":"^1.2.0","gulp-rename":"^1.2.2","gulp-uglify":"^3.0.0",pegjs:"^0.7.0","vinyl-buffer":"^1.0.1","vinyl-source-stream":"^2.0.0"},homepage:"http://jssip.net",keywords:["sip","websocket","webrtc","node","browser","library"],license:"MIT",main:"lib-es5/JsSIP.js",name:"jssip",repository:{type:"git",url:"git+https://github.com/versatica/JsSIP.git"},scripts:{prepublishOnly:"gulp babel",test:"gulp test"},title:"JsSIP",version:"3.2.11"}},{}],33:[function(e,t,n){var r=1e3,i=60*r,s=60*i,a=24*s,o=365.25*a;function l(e,t,n){if(!(e<t))return e<1.5*t?Math.floor(e/t)+" "+n:Math.ceil(e/t)+" "+n+"s"}t.exports=function(e,t){t=t||{};var n,u=typeof e;if("string"===u&&e.length>0)return function(e){if((e=String(e)).length>100)return;var t=/^((?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|years?|yrs?|y)?$/i.exec(e);if(!t)return;var n=parseFloat(t[1]);switch((t[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return n*o;case"days":case"day":case"d":return n*a;case"hours":case"hour":case"hrs":case"hr":case"h":return n*s;case"minutes":case"minute":case"mins":case"min":case"m":return n*i;case"seconds":case"second":case"secs":case"sec":case"s":return n*r;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return n;default:return}}(e);if("number"===u&&!1===isNaN(e))return t.long?l(n=e,a,"day")||l(n,s,"hour")||l(n,i,"minute")||l(n,r,"second")||n+" ms":function(e){if(e>=a)return Math.round(e/a)+"d";if(e>=s)return Math.round(e/s)+"h";if(e>=i)return Math.round(e/i)+"m";if(e>=r)return Math.round(e/r)+"s";return e+"ms"}(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))}},{}],34:[function(e,t,n){var r,i,s=t.exports={};function a(){throw new Error("setTimeout has not been defined")}function o(){throw new Error("clearTimeout has not been defined")}function l(e){if(r===setTimeout)return setTimeout(e,0);if((r===a||!r)&&setTimeout)return r=setTimeout,setTimeout(e,0);try{return r(e,0)}catch(t){try{return r.call(null,e,0)}catch(t){return r.call(this,e,0)}}}!function(){try{r="function"==typeof setTimeout?setTimeout:a}catch(e){r=a}try{i="function"==typeof clearTimeout?clearTimeout:o}catch(e){i=o}}();var u,c=[],d=!1,h=-1;function p(){d&&u&&(d=!1,u.length?c=u.concat(c):h=-1,c.length&&f())}function f(){if(!d){var e=l(p);d=!0;for(var t=c.length;t;){for(u=c,c=[];++h<t;)u&&u[h].run();h=-1,t=c.length}u=null,d=!1,function(e){if(i===clearTimeout)return clearTimeout(e);if((i===o||!i)&&clearTimeout)return i=clearTimeout,clearTimeout(e);try{i(e)}catch(t){try{return i.call(null,e)}catch(t){return i.call(this,e)}}}(e)}}function m(e,t){this.fun=e,this.array=t}function _(){}s.nextTick=function(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)t[n-1]=arguments[n];c.push(new m(e,t)),1!==c.length||d||l(f)},m.prototype.run=function(){this.fun.apply(null,this.array)},s.title="browser",s.browser=!0,s.env={},s.argv=[],s.version="",s.versions={},s.on=_,s.addListener=_,s.once=_,s.off=_,s.removeListener=_,s.removeAllListeners=_,s.emit=_,s.prependListener=_,s.prependOnceListener=_,s.listeners=function(e){return[]},s.binding=function(e){throw new Error("process.binding is not supported")},s.cwd=function(){return"/"},s.chdir=function(e){throw new Error("process.chdir is not supported")},s.umask=function(){return 0}},{}],35:[function(e,t,n){"use strict";var r=e("sdp");function i(e,t,n,i,s){var a=r.writeRtpDescription(e.kind,t);if(a+=r.writeIceParameters(e.iceGatherer.getLocalParameters()),a+=r.writeDtlsParameters(e.dtlsTransport.getLocalParameters(),"offer"===n?"actpass":s||"active"),a+="a=mid:"+e.mid+"\r\n",e.rtpSender&&e.rtpReceiver?a+="a=sendrecv\r\n":e.rtpSender?a+="a=sendonly\r\n":e.rtpReceiver?a+="a=recvonly\r\n":a+="a=inactive\r\n",e.rtpSender){var o=e.rtpSender._initialTrackId||e.rtpSender.track.id;e.rtpSender._initialTrackId=o;var l="msid:"+(i?i.id:"-")+" "+o+"\r\n";a+="a="+l,a+="a=ssrc:"+e.sendEncodingParameters[0].ssrc+" "+l,e.sendEncodingParameters[0].rtx&&(a+="a=ssrc:"+e.sendEncodingParameters[0].rtx.ssrc+" "+l,a+="a=ssrc-group:FID "+e.sendEncodingParameters[0].ssrc+" "+e.sendEncodingParameters[0].rtx.ssrc+"\r\n")}return a+="a=ssrc:"+e.sendEncodingParameters[0].ssrc+" cname:"+r.localCName+"\r\n",e.rtpSender&&e.sendEncodingParameters[0].rtx&&(a+="a=ssrc:"+e.sendEncodingParameters[0].rtx.ssrc+" cname:"+r.localCName+"\r\n"),a}function s(e,t){var n={codecs:[],headerExtensions:[],fecMechanisms:[]},r=function(e,t){e=parseInt(e,10);for(var n=0;n<t.length;n++)if(t[n].payloadType===e||t[n].preferredPayloadType===e)return t[n]},i=function(e,t,n,i){var s=r(e.parameters.apt,n),a=r(t.parameters.apt,i);return s&&a&&s.name.toLowerCase()===a.name.toLowerCase()};return e.codecs.forEach(function(r){for(var s=0;s<t.codecs.length;s++){var a=t.codecs[s];if(r.name.toLowerCase()===a.name.toLowerCase()&&r.clockRate===a.clockRate){if("rtx"===r.name.toLowerCase()&&r.parameters&&a.parameters.apt&&!i(r,a,e.codecs,t.codecs))continue;(a=JSON.parse(JSON.stringify(a))).numChannels=Math.min(r.numChannels,a.numChannels),n.codecs.push(a),a.rtcpFeedback=a.rtcpFeedback.filter(function(e){for(var t=0;t<r.rtcpFeedback.length;t++)if(r.rtcpFeedback[t].type===e.type&&r.rtcpFeedback[t].parameter===e.parameter)return!0;return!1});break}}}),e.headerExtensions.forEach(function(e){for(var r=0;r<t.headerExtensions.length;r++){var i=t.headerExtensions[r];if(e.uri===i.uri){n.headerExtensions.push(i);break}}}),n}function a(e,t,n){return-1!=={offer:{setLocalDescription:["stable","have-local-offer"],setRemoteDescription:["stable","have-remote-offer"]},answer:{setLocalDescription:["have-remote-offer","have-local-pranswer"],setRemoteDescription:["have-local-offer","have-remote-pranswer"]}}[t][e].indexOf(n)}function o(e,t){var n=e.getRemoteCandidates().find(function(e){return t.foundation===e.foundation&&t.ip===e.ip&&t.port===e.port&&t.priority===e.priority&&t.protocol===e.protocol&&t.type===e.type});return n||e.addRemoteCandidate(t),!n}function l(e,t){var n=new Error(t);return n.name=e,n.code={NotSupportedError:9,InvalidStateError:11,InvalidAccessError:15,TypeError:void 0,OperationError:void 0}[e],n}t.exports=function(e,t){function n(t,n){n.addTrack(t),n.dispatchEvent(new e.MediaStreamTrackEvent("addtrack",{track:t}))}function u(t,n,r,i){var s=new Event("track");s.track=n,s.receiver=r,s.transceiver={receiver:r},s.streams=i,e.setTimeout(function(){t._dispatchEvent("track",s)})}var c=function(n){var i=this,s=document.createDocumentFragment();if(["addEventListener","removeEventListener","dispatchEvent"].forEach(function(e){i[e]=s[e].bind(s)}),this.canTrickleIceCandidates=null,this.needNegotiation=!1,this.localStreams=[],this.remoteStreams=[],this._localDescription=null,this._remoteDescription=null,this.signalingState="stable",this.iceConnectionState="new",this.connectionState="new",this.iceGatheringState="new",n=JSON.parse(JSON.stringify(n||{})),this.usingBundle="max-bundle"===n.bundlePolicy,"negotiate"===n.rtcpMuxPolicy)throw l("NotSupportedError","rtcpMuxPolicy 'negotiate' is not supported");switch(n.rtcpMuxPolicy||(n.rtcpMuxPolicy="require"),n.iceTransportPolicy){case"all":case"relay":break;default:n.iceTransportPolicy="all"}switch(n.bundlePolicy){case"balanced":case"max-compat":case"max-bundle":break;default:n.bundlePolicy="balanced"}if(n.iceServers=function(e,t){var n=!1;return(e=JSON.parse(JSON.stringify(e))).filter(function(e){if(e&&(e.urls||e.url)){var r=e.urls||e.url;e.url&&!e.urls&&console.warn("RTCIceServer.url is deprecated! Use urls instead.");var i="string"==typeof r;return i&&(r=[r]),r=r.filter(function(e){return 0!==e.indexOf("turn:")||-1===e.indexOf("transport=udp")||-1!==e.indexOf("turn:[")||n?0===e.indexOf("stun:")&&t>=14393&&-1===e.indexOf("?transport=udp"):(n=!0,!0)}),delete e.url,e.urls=i?r[0]:r,!!r.length}})}(n.iceServers||[],t),this._iceGatherers=[],n.iceCandidatePoolSize)for(var a=n.iceCandidatePoolSize;a>0;a--)this._iceGatherers.push(new e.RTCIceGatherer({iceServers:n.iceServers,gatherPolicy:n.iceTransportPolicy}));else n.iceCandidatePoolSize=0;this._config=n,this.transceivers=[],this._sdpSessionId=r.generateSessionId(),this._sdpSessionVersion=0,this._dtlsRole=void 0,this._isClosed=!1};Object.defineProperty(c.prototype,"localDescription",{configurable:!0,get:function(){return this._localDescription}}),Object.defineProperty(c.prototype,"remoteDescription",{configurable:!0,get:function(){return this._remoteDescription}}),c.prototype.onicecandidate=null,c.prototype.onaddstream=null,c.prototype.ontrack=null,c.prototype.onremovestream=null,c.prototype.onsignalingstatechange=null,c.prototype.oniceconnectionstatechange=null,c.prototype.onconnectionstatechange=null,c.prototype.onicegatheringstatechange=null,c.prototype.onnegotiationneeded=null,c.prototype.ondatachannel=null,c.prototype._dispatchEvent=function(e,t){this._isClosed||(this.dispatchEvent(t),"function"==typeof this["on"+e]&&this["on"+e](t))},c.prototype._emitGatheringStateChange=function(){var e=new Event("icegatheringstatechange");this._dispatchEvent("icegatheringstatechange",e)},c.prototype.getConfiguration=function(){return this._config},c.prototype.getLocalStreams=function(){return this.localStreams},c.prototype.getRemoteStreams=function(){return this.remoteStreams},c.prototype._createTransceiver=function(e,t){var n=this.transceivers.length>0,r={track:null,iceGatherer:null,iceTransport:null,dtlsTransport:null,localCapabilities:null,remoteCapabilities:null,rtpSender:null,rtpReceiver:null,kind:e,mid:null,sendEncodingParameters:null,recvEncodingParameters:null,stream:null,associatedRemoteMediaStreams:[],wantReceive:!0};if(this.usingBundle&&n)r.iceTransport=this.transceivers[0].iceTransport,r.dtlsTransport=this.transceivers[0].dtlsTransport;else{var i=this._createIceAndDtlsTransports();r.iceTransport=i.iceTransport,r.dtlsTransport=i.dtlsTransport}return t||this.transceivers.push(r),r},c.prototype.addTrack=function(t,n){if(this._isClosed)throw l("InvalidStateError","Attempted to call addTrack on a closed peerconnection.");var r;if(this.transceivers.find(function(e){return e.track===t}))throw l("InvalidAccessError","Track already exists.");for(var i=0;i<this.transceivers.length;i++)this.transceivers[i].track||this.transceivers[i].kind!==t.kind||(r=this.transceivers[i]);return r||(r=this._createTransceiver(t.kind)),this._maybeFireNegotiationNeeded(),-1===this.localStreams.indexOf(n)&&this.localStreams.push(n),r.track=t,r.stream=n,r.rtpSender=new e.RTCRtpSender(t,r.dtlsTransport),r.rtpSender},c.prototype.addStream=function(e){var n=this;if(t>=15025)e.getTracks().forEach(function(t){n.addTrack(t,e)});else{var r=e.clone();e.getTracks().forEach(function(e,t){var n=r.getTracks()[t];e.addEventListener("enabled",function(e){n.enabled=e.enabled})}),r.getTracks().forEach(function(e){n.addTrack(e,r)})}},c.prototype.removeTrack=function(t){if(this._isClosed)throw l("InvalidStateError","Attempted to call removeTrack on a closed peerconnection.");if(!(t instanceof e.RTCRtpSender))throw new TypeError("Argument 1 of RTCPeerConnection.removeTrack does not implement interface RTCRtpSender.");var n=this.transceivers.find(function(e){return e.rtpSender===t});if(!n)throw l("InvalidAccessError","Sender was not created by this connection.");var r=n.stream;n.rtpSender.stop(),n.rtpSender=null,n.track=null,n.stream=null,-1===this.transceivers.map(function(e){return e.stream}).indexOf(r)&&this.localStreams.indexOf(r)>-1&&this.localStreams.splice(this.localStreams.indexOf(r),1),this._maybeFireNegotiationNeeded()},c.prototype.removeStream=function(e){var t=this;e.getTracks().forEach(function(e){var n=t.getSenders().find(function(t){return t.track===e});n&&t.removeTrack(n)})},c.prototype.getSenders=function(){return this.transceivers.filter(function(e){return!!e.rtpSender}).map(function(e){return e.rtpSender})},c.prototype.getReceivers=function(){return this.transceivers.filter(function(e){return!!e.rtpReceiver}).map(function(e){return e.rtpReceiver})},c.prototype._createIceGatherer=function(t,n){var r=this;if(n&&t>0)return this.transceivers[0].iceGatherer;if(this._iceGatherers.length)return this._iceGatherers.shift();var i=new e.RTCIceGatherer({iceServers:this._config.iceServers,gatherPolicy:this._config.iceTransportPolicy});return Object.defineProperty(i,"state",{value:"new",writable:!0}),this.transceivers[t].bufferedCandidateEvents=[],this.transceivers[t].bufferCandidates=function(e){var n=!e.candidate||0===Object.keys(e.candidate).length;i.state=n?"completed":"gathering",null!==r.transceivers[t].bufferedCandidateEvents&&r.transceivers[t].bufferedCandidateEvents.push(e)},i.addEventListener("localcandidate",this.transceivers[t].bufferCandidates),i},c.prototype._gather=function(t,n){var i=this,s=this.transceivers[n].iceGatherer;if(!s.onlocalcandidate){var a=this.transceivers[n].bufferedCandidateEvents;this.transceivers[n].bufferedCandidateEvents=null,s.removeEventListener("localcandidate",this.transceivers[n].bufferCandidates),s.onlocalcandidate=function(e){if(!(i.usingBundle&&n>0)){var a=new Event("icecandidate");a.candidate={sdpMid:t,sdpMLineIndex:n};var o=e.candidate,l=!o||0===Object.keys(o).length;if(l)"new"!==s.state&&"gathering"!==s.state||(s.state="completed");else{"new"===s.state&&(s.state="gathering"),o.component=1,o.ufrag=s.getLocalParameters().usernameFragment;var u=r.writeCandidate(o);a.candidate=Object.assign(a.candidate,r.parseCandidate(u)),a.candidate.candidate=u,a.candidate.toJSON=function(){return{candidate:a.candidate.candidate,sdpMid:a.candidate.sdpMid,sdpMLineIndex:a.candidate.sdpMLineIndex,usernameFragment:a.candidate.usernameFragment}}}var c=r.getMediaSections(i._localDescription.sdp);c[a.candidate.sdpMLineIndex]+=l?"a=end-of-candidates\r\n":"a="+a.candidate.candidate+"\r\n",i._localDescription.sdp=r.getDescription(i._localDescription.sdp)+c.join("");var d=i.transceivers.every(function(e){return e.iceGatherer&&"completed"===e.iceGatherer.state});"gathering"!==i.iceGatheringState&&(i.iceGatheringState="gathering",i._emitGatheringStateChange()),l||i._dispatchEvent("icecandidate",a),d&&(i._dispatchEvent("icecandidate",new Event("icecandidate")),i.iceGatheringState="complete",i._emitGatheringStateChange())}},e.setTimeout(function(){a.forEach(function(e){s.onlocalcandidate(e)})},0)}},c.prototype._createIceAndDtlsTransports=function(){var t=this,n=new e.RTCIceTransport(null);n.onicestatechange=function(){t._updateIceConnectionState(),t._updateConnectionState()};var r=new e.RTCDtlsTransport(n);return r.ondtlsstatechange=function(){t._updateConnectionState()},r.onerror=function(){Object.defineProperty(r,"state",{value:"failed",writable:!0}),t._updateConnectionState()},{iceTransport:n,dtlsTransport:r}},c.prototype._disposeIceAndDtlsTransports=function(e){var t=this.transceivers[e].iceGatherer;t&&(delete t.onlocalcandidate,delete this.transceivers[e].iceGatherer);var n=this.transceivers[e].iceTransport;n&&(delete n.onicestatechange,delete this.transceivers[e].iceTransport);var r=this.transceivers[e].dtlsTransport;r&&(delete r.ondtlsstatechange,delete r.onerror,delete this.transceivers[e].dtlsTransport)},c.prototype._transceive=function(e,n,i){var a=s(e.localCapabilities,e.remoteCapabilities);n&&e.rtpSender&&(a.encodings=e.sendEncodingParameters,a.rtcp={cname:r.localCName,compound:e.rtcpParameters.compound},e.recvEncodingParameters.length&&(a.rtcp.ssrc=e.recvEncodingParameters[0].ssrc),e.rtpSender.send(a)),i&&e.rtpReceiver&&a.codecs.length>0&&("video"===e.kind&&e.recvEncodingParameters&&t<15019&&e.recvEncodingParameters.forEach(function(e){delete e.rtx}),e.recvEncodingParameters.length?a.encodings=e.recvEncodingParameters:a.encodings=[{}],a.rtcp={compound:e.rtcpParameters.compound},e.rtcpParameters.cname&&(a.rtcp.cname=e.rtcpParameters.cname),e.sendEncodingParameters.length&&(a.rtcp.ssrc=e.sendEncodingParameters[0].ssrc),e.rtpReceiver.receive(a))},c.prototype.setLocalDescription=function(e){var t,n,i=this;if(-1===["offer","answer"].indexOf(e.type))return Promise.reject(l("TypeError",'Unsupported type "'+e.type+'"'));if(!a("setLocalDescription",e.type,i.signalingState)||i._isClosed)return Promise.reject(l("InvalidStateError","Can not set local "+e.type+" in state "+i.signalingState));if("offer"===e.type)t=r.splitSections(e.sdp),n=t.shift(),t.forEach(function(e,t){var n=r.parseRtpParameters(e);i.transceivers[t].localCapabilities=n}),i.transceivers.forEach(function(e,t){i._gather(e.mid,t)});else if("answer"===e.type){t=r.splitSections(i._remoteDescription.sdp),n=t.shift();var o=r.matchPrefix(n,"a=ice-lite").length>0;t.forEach(function(e,t){var a=i.transceivers[t],l=a.iceGatherer,u=a.iceTransport,c=a.dtlsTransport,d=a.localCapabilities,h=a.remoteCapabilities;if(!(r.isRejected(e)&&0===r.matchPrefix(e,"a=bundle-only").length)&&!a.rejected){var p=r.getIceParameters(e,n),f=r.getDtlsParameters(e,n);o&&(f.role="server"),i.usingBundle&&0!==t||(i._gather(a.mid,t),"new"===u.state&&u.start(l,p,o?"controlling":"controlled"),"new"===c.state&&c.start(f));var m=s(d,h);i._transceive(a,m.codecs.length>0,!1)}})}return i._localDescription={type:e.type,sdp:e.sdp},"offer"===e.type?i._updateSignalingState("have-local-offer"):i._updateSignalingState("stable"),Promise.resolve()},c.prototype.setRemoteDescription=function(i){var s=this;if(-1===["offer","answer"].indexOf(i.type))return Promise.reject(l("TypeError",'Unsupported type "'+i.type+'"'));if(!a("setRemoteDescription",i.type,s.signalingState)||s._isClosed)return Promise.reject(l("InvalidStateError","Can not set remote "+i.type+" in state "+s.signalingState));var c={};s.remoteStreams.forEach(function(e){c[e.id]=e});var d=[],h=r.splitSections(i.sdp),p=h.shift(),f=r.matchPrefix(p,"a=ice-lite").length>0,m=r.matchPrefix(p,"a=group:BUNDLE ").length>0;s.usingBundle=m;var _=r.matchPrefix(p,"a=ice-options:")[0];return s.canTrickleIceCandidates=!!_&&_.substr(14).split(" ").indexOf("trickle")>=0,h.forEach(function(a,l){var u=r.splitLines(a),h=r.getKind(a),_=r.isRejected(a)&&0===r.matchPrefix(a,"a=bundle-only").length,v=u[0].substr(2).split(" ")[2],g=r.getDirection(a,p),y=r.parseMsid(a),T=r.getMid(a)||r.generateIdentifier();if(_||"application"===h&&("DTLS/SCTP"===v||"UDP/DTLS/SCTP"===v))s.transceivers[l]={mid:T,kind:h,protocol:v,rejected:!0};else{var S,C,E,b,R,w,A,I,k;!_&&s.transceivers[l]&&s.transceivers[l].rejected&&(s.transceivers[l]=s._createTransceiver(h,!0));var P,O,N=r.parseRtpParameters(a);_||(P=r.getIceParameters(a,p),(O=r.getDtlsParameters(a,p)).role="client"),A=r.parseRtpEncodingParameters(a);var x=r.parseRtcpParameters(a),D=r.matchPrefix(a,"a=end-of-candidates",p).length>0,M=r.matchPrefix(a,"a=candidate:").map(function(e){return r.parseCandidate(e)}).filter(function(e){return 1===e.component});if(("offer"===i.type||"answer"===i.type)&&!_&&m&&l>0&&s.transceivers[l]&&(s._disposeIceAndDtlsTransports(l),s.transceivers[l].iceGatherer=s.transceivers[0].iceGatherer,s.transceivers[l].iceTransport=s.transceivers[0].iceTransport,s.transceivers[l].dtlsTransport=s.transceivers[0].dtlsTransport,s.transceivers[l].rtpSender&&s.transceivers[l].rtpSender.setTransport(s.transceivers[0].dtlsTransport),s.transceivers[l].rtpReceiver&&s.transceivers[l].rtpReceiver.setTransport(s.transceivers[0].dtlsTransport)),"offer"!==i.type||_)"answer"!==i.type||_||(C=(S=s.transceivers[l]).iceGatherer,E=S.iceTransport,b=S.dtlsTransport,R=S.rtpReceiver,w=S.sendEncodingParameters,I=S.localCapabilities,s.transceivers[l].recvEncodingParameters=A,s.transceivers[l].remoteCapabilities=N,s.transceivers[l].rtcpParameters=x,M.length&&"new"===E.state&&(!f&&!D||m&&0!==l?M.forEach(function(e){o(S.iceTransport,e)}):E.setRemoteCandidates(M)),m&&0!==l||("new"===E.state&&E.start(C,P,"controlling"),"new"===b.state&&b.start(O)),s._transceive(S,"sendrecv"===g||"recvonly"===g,"sendrecv"===g||"sendonly"===g),!R||"sendrecv"!==g&&"sendonly"!==g?delete S.rtpReceiver:(k=R.track,y?(c[y.stream]||(c[y.stream]=new e.MediaStream),n(k,c[y.stream]),d.push([k,R,c[y.stream]])):(c.default||(c.default=new e.MediaStream),n(k,c.default),d.push([k,R,c.default]))));else{(S=s.transceivers[l]||s._createTransceiver(h)).mid=T,S.iceGatherer||(S.iceGatherer=s._createIceGatherer(l,m)),M.length&&"new"===S.iceTransport.state&&(!D||m&&0!==l?M.forEach(function(e){o(S.iceTransport,e)}):S.iceTransport.setRemoteCandidates(M)),I=e.RTCRtpReceiver.getCapabilities(h),t<15019&&(I.codecs=I.codecs.filter(function(e){return"rtx"!==e.name})),w=S.sendEncodingParameters||[{ssrc:1001*(2*l+2)}];var U,L=!1;if("sendrecv"===g||"sendonly"===g){if(L=!S.rtpReceiver,R=S.rtpReceiver||new e.RTCRtpReceiver(S.dtlsTransport,h),L)k=R.track,y&&"-"===y.stream||(y?(c[y.stream]||(c[y.stream]=new e.MediaStream,Object.defineProperty(c[y.stream],"id",{get:function(){return y.stream}})),Object.defineProperty(k,"id",{get:function(){return y.track}}),U=c[y.stream]):(c.default||(c.default=new e.MediaStream),U=c.default)),U&&(n(k,U),S.associatedRemoteMediaStreams.push(U)),d.push([k,R,U])}else S.rtpReceiver&&S.rtpReceiver.track&&(S.associatedRemoteMediaStreams.forEach(function(t){var n,r,i=t.getTracks().find(function(e){return e.id===S.rtpReceiver.track.id});i&&(n=i,(r=t).removeTrack(n),r.dispatchEvent(new e.MediaStreamTrackEvent("removetrack",{track:n})))}),S.associatedRemoteMediaStreams=[]);S.localCapabilities=I,S.remoteCapabilities=N,S.rtpReceiver=R,S.rtcpParameters=x,S.sendEncodingParameters=w,S.recvEncodingParameters=A,s._transceive(s.transceivers[l],!1,L)}}}),void 0===s._dtlsRole&&(s._dtlsRole="offer"===i.type?"active":"passive"),s._remoteDescription={type:i.type,sdp:i.sdp},"offer"===i.type?s._updateSignalingState("have-remote-offer"):s._updateSignalingState("stable"),Object.keys(c).forEach(function(t){var n=c[t];if(n.getTracks().length){if(-1===s.remoteStreams.indexOf(n)){s.remoteStreams.push(n);var r=new Event("addstream");r.stream=n,e.setTimeout(function(){s._dispatchEvent("addstream",r)})}d.forEach(function(e){var t=e[0],r=e[1];n.id===e[2].id&&u(s,t,r,[n])})}}),d.forEach(function(e){e[2]||u(s,e[0],e[1],[])}),e.setTimeout(function(){s&&s.transceivers&&s.transceivers.forEach(function(e){e.iceTransport&&"new"===e.iceTransport.state&&e.iceTransport.getRemoteCandidates().length>0&&(console.warn("Timeout for addRemoteCandidate. Consider sending an end-of-candidates notification"),e.iceTransport.addRemoteCandidate({}))})},4e3),Promise.resolve()},c.prototype.close=function(){this.transceivers.forEach(function(e){e.iceTransport&&e.iceTransport.stop(),e.dtlsTransport&&e.dtlsTransport.stop(),e.rtpSender&&e.rtpSender.stop(),e.rtpReceiver&&e.rtpReceiver.stop()}),this._isClosed=!0,this._updateSignalingState("closed")},c.prototype._updateSignalingState=function(e){this.signalingState=e;var t=new Event("signalingstatechange");this._dispatchEvent("signalingstatechange",t)},c.prototype._maybeFireNegotiationNeeded=function(){var t=this;"stable"===this.signalingState&&!0!==this.needNegotiation&&(this.needNegotiation=!0,e.setTimeout(function(){if(t.needNegotiation){t.needNegotiation=!1;var e=new Event("negotiationneeded");t._dispatchEvent("negotiationneeded",e)}},0))},c.prototype._updateIceConnectionState=function(){var e,t={new:0,closed:0,checking:0,connected:0,completed:0,disconnected:0,failed:0};if(this.transceivers.forEach(function(e){t[e.iceTransport.state]++}),e="new",t.failed>0?e="failed":t.checking>0?e="checking":t.disconnected>0?e="disconnected":t.new>0?e="new":t.connected>0?e="connected":t.completed>0&&(e="completed"),e!==this.iceConnectionState){this.iceConnectionState=e;var n=new Event("iceconnectionstatechange");this._dispatchEvent("iceconnectionstatechange",n)}},c.prototype._updateConnectionState=function(){var e,t={new:0,closed:0,connecting:0,connected:0,completed:0,disconnected:0,failed:0};if(this.transceivers.forEach(function(e){t[e.iceTransport.state]++,t[e.dtlsTransport.state]++}),t.connected+=t.completed,e="new",t.failed>0?e="failed":t.connecting>0?e="connecting":t.disconnected>0?e="disconnected":t.new>0?e="new":t.connected>0&&(e="connected"),e!==this.connectionState){this.connectionState=e;var n=new Event("connectionstatechange");this._dispatchEvent("connectionstatechange",n)}},c.prototype.createOffer=function(){var n=this;if(n._isClosed)return Promise.reject(l("InvalidStateError","Can not call createOffer after close"));var s=n.transceivers.filter(function(e){return"audio"===e.kind}).length,a=n.transceivers.filter(function(e){return"video"===e.kind}).length,o=arguments[0];if(o){if(o.mandatory||o.optional)throw new TypeError("Legacy mandatory/optional constraints not supported.");void 0!==o.offerToReceiveAudio&&(s=!0===o.offerToReceiveAudio?1:!1===o.offerToReceiveAudio?0:o.offerToReceiveAudio),void 0!==o.offerToReceiveVideo&&(a=!0===o.offerToReceiveVideo?1:!1===o.offerToReceiveVideo?0:o.offerToReceiveVideo)}for(n.transceivers.forEach(function(e){"audio"===e.kind?--s<0&&(e.wantReceive=!1):"video"===e.kind&&--a<0&&(e.wantReceive=!1)});s>0||a>0;)s>0&&(n._createTransceiver("audio"),s--),a>0&&(n._createTransceiver("video"),a--);var u=r.writeSessionBoilerplate(n._sdpSessionId,n._sdpSessionVersion++);n.transceivers.forEach(function(i,s){var a=i.track,o=i.kind,l=i.mid||r.generateIdentifier();i.mid=l,i.iceGatherer||(i.iceGatherer=n._createIceGatherer(s,n.usingBundle));var u=e.RTCRtpSender.getCapabilities(o);t<15019&&(u.codecs=u.codecs.filter(function(e){return"rtx"!==e.name})),u.codecs.forEach(function(e){"H264"===e.name&&void 0===e.parameters["level-asymmetry-allowed"]&&(e.parameters["level-asymmetry-allowed"]="1"),i.remoteCapabilities&&i.remoteCapabilities.codecs&&i.remoteCapabilities.codecs.forEach(function(t){e.name.toLowerCase()===t.name.toLowerCase()&&e.clockRate===t.clockRate&&(e.preferredPayloadType=t.payloadType)})}),u.headerExtensions.forEach(function(e){(i.remoteCapabilities&&i.remoteCapabilities.headerExtensions||[]).forEach(function(t){e.uri===t.uri&&(e.id=t.id)})});var c=i.sendEncodingParameters||[{ssrc:1001*(2*s+1)}];a&&t>=15019&&"video"===o&&!c[0].rtx&&(c[0].rtx={ssrc:c[0].ssrc+1}),i.wantReceive&&(i.rtpReceiver=new e.RTCRtpReceiver(i.dtlsTransport,o)),i.localCapabilities=u,i.sendEncodingParameters=c}),"max-compat"!==n._config.bundlePolicy&&(u+="a=group:BUNDLE "+n.transceivers.map(function(e){return e.mid}).join(" ")+"\r\n"),u+="a=ice-options:trickle\r\n",n.transceivers.forEach(function(e,t){u+=i(e,e.localCapabilities,"offer",e.stream,n._dtlsRole),u+="a=rtcp-rsize\r\n",!e.iceGatherer||"new"===n.iceGatheringState||0!==t&&n.usingBundle||(e.iceGatherer.getLocalCandidates().forEach(function(e){e.component=1,u+="a="+r.writeCandidate(e)+"\r\n"}),"completed"===e.iceGatherer.state&&(u+="a=end-of-candidates\r\n"))});var c=new e.RTCSessionDescription({type:"offer",sdp:u});return Promise.resolve(c)},c.prototype.createAnswer=function(){var n=this;if(n._isClosed)return Promise.reject(l("InvalidStateError","Can not call createAnswer after close"));if("have-remote-offer"!==n.signalingState&&"have-local-pranswer"!==n.signalingState)return Promise.reject(l("InvalidStateError","Can not call createAnswer in signalingState "+n.signalingState));var a=r.writeSessionBoilerplate(n._sdpSessionId,n._sdpSessionVersion++);n.usingBundle&&(a+="a=group:BUNDLE "+n.transceivers.map(function(e){return e.mid}).join(" ")+"\r\n");var o=r.getMediaSections(n._remoteDescription.sdp).length;n.transceivers.forEach(function(e,r){if(!(r+1>o)){if(e.rejected)return"application"===e.kind?"DTLS/SCTP"===e.protocol?a+="m=application 0 DTLS/SCTP 5000\r\n":a+="m=application 0 "+e.protocol+" webrtc-datachannel\r\n":"audio"===e.kind?a+="m=audio 0 UDP/TLS/RTP/SAVPF 0\r\na=rtpmap:0 PCMU/8000\r\n":"video"===e.kind&&(a+="m=video 0 UDP/TLS/RTP/SAVPF 120\r\na=rtpmap:120 VP8/90000\r\n"),void(a+="c=IN IP4 0.0.0.0\r\na=inactive\r\na=mid:"+e.mid+"\r\n");var l;if(e.stream)"audio"===e.kind?l=e.stream.getAudioTracks()[0]:"video"===e.kind&&(l=e.stream.getVideoTracks()[0]),l&&t>=15019&&"video"===e.kind&&!e.sendEncodingParameters[0].rtx&&(e.sendEncodingParameters[0].rtx={ssrc:e.sendEncodingParameters[0].ssrc+1});var u=s(e.localCapabilities,e.remoteCapabilities);!u.codecs.filter(function(e){return"rtx"===e.name.toLowerCase()}).length&&e.sendEncodingParameters[0].rtx&&delete e.sendEncodingParameters[0].rtx,a+=i(e,u,"answer",e.stream,n._dtlsRole),e.rtcpParameters&&e.rtcpParameters.reducedSize&&(a+="a=rtcp-rsize\r\n")}});var u=new e.RTCSessionDescription({type:"answer",sdp:a});return Promise.resolve(u)},c.prototype.addIceCandidate=function(e){var t,n=this;return e&&void 0===e.sdpMLineIndex&&!e.sdpMid?Promise.reject(new TypeError("sdpMLineIndex or sdpMid required")):new Promise(function(i,s){if(!n._remoteDescription)return s(l("InvalidStateError","Can not add ICE candidate without a remote description"));if(e&&""!==e.candidate){var a=e.sdpMLineIndex;if(e.sdpMid)for(var u=0;u<n.transceivers.length;u++)if(n.transceivers[u].mid===e.sdpMid){a=u;break}var c=n.transceivers[a];if(!c)return s(l("OperationError","Can not add ICE candidate"));if(c.rejected)return i();var d=Object.keys(e.candidate).length>0?r.parseCandidate(e.candidate):{};if("tcp"===d.protocol&&(0===d.port||9===d.port))return i();if(d.component&&1!==d.component)return i();if((0===a||a>0&&c.iceTransport!==n.transceivers[0].iceTransport)&&!o(c.iceTransport,d))return s(l("OperationError","Can not add ICE candidate"));var h=e.candidate.trim();0===h.indexOf("a=")&&(h=h.substr(2)),(t=r.getMediaSections(n._remoteDescription.sdp))[a]+="a="+(d.type?h:"end-of-candidates")+"\r\n",n._remoteDescription.sdp=r.getDescription(n._remoteDescription.sdp)+t.join("")}else for(var p=0;p<n.transceivers.length&&(n.transceivers[p].rejected||(n.transceivers[p].iceTransport.addRemoteCandidate({}),(t=r.getMediaSections(n._remoteDescription.sdp))[p]+="a=end-of-candidates\r\n",n._remoteDescription.sdp=r.getDescription(n._remoteDescription.sdp)+t.join(""),!n.usingBundle));p++);i()})},c.prototype.getStats=function(t){if(t&&t instanceof e.MediaStreamTrack){var n=null;if(this.transceivers.forEach(function(e){e.rtpSender&&e.rtpSender.track===t?n=e.rtpSender:e.rtpReceiver&&e.rtpReceiver.track===t&&(n=e.rtpReceiver)}),!n)throw l("InvalidAccessError","Invalid selector.");return n.getStats()}var r=[];return this.transceivers.forEach(function(e){["rtpSender","rtpReceiver","iceGatherer","iceTransport","dtlsTransport"].forEach(function(t){e[t]&&r.push(e[t].getStats())})}),Promise.all(r).then(function(e){var t=new Map;return e.forEach(function(e){e.forEach(function(e){t.set(e.id,e)})}),t})};["RTCRtpSender","RTCRtpReceiver","RTCIceGatherer","RTCIceTransport","RTCDtlsTransport"].forEach(function(t){var n=e[t];if(n&&n.prototype&&n.prototype.getStats){var r=n.prototype.getStats;n.prototype.getStats=function(){return r.apply(this).then(function(e){var t=new Map;return Object.keys(e).forEach(function(n){var r;e[n].type={inboundrtp:"inbound-rtp",outboundrtp:"outbound-rtp",candidatepair:"candidate-pair",localcandidate:"local-candidate",remotecandidate:"remote-candidate"}[(r=e[n]).type]||r.type,t.set(n,e[n])}),t})}}});var d=["createOffer","createAnswer"];return d.forEach(function(e){var t=c.prototype[e];c.prototype[e]=function(){var e=arguments;return"function"==typeof e[0]||"function"==typeof e[1]?t.apply(this,[arguments[2]]).then(function(t){"function"==typeof e[0]&&e[0].apply(null,[t])},function(t){"function"==typeof e[1]&&e[1].apply(null,[t])}):t.apply(this,arguments)}}),(d=["setLocalDescription","setRemoteDescription","addIceCandidate"]).forEach(function(e){var t=c.prototype[e];c.prototype[e]=function(){var e=arguments;return"function"==typeof e[1]||"function"==typeof e[2]?t.apply(this,arguments).then(function(){"function"==typeof e[1]&&e[1].apply(null)},function(t){"function"==typeof e[2]&&e[2].apply(null,[t])}):t.apply(this,arguments)}}),["getStats"].forEach(function(e){var t=c.prototype[e];c.prototype[e]=function(){var e=arguments;return"function"==typeof e[1]?t.apply(this,arguments).then(function(){"function"==typeof e[1]&&e[1].apply(null)}):t.apply(this,arguments)}}),c}},{sdp:40}],36:[function(e,t,n){var r=t.exports={v:[{name:"version",reg:/^(\d*)$/}],o:[{name:"origin",reg:/^(\S*) (\d*) (\d*) (\S*) IP(\d) (\S*)/,names:["username","sessionId","sessionVersion","netType","ipVer","address"],format:"%s %s %d %s IP%d %s"}],s:[{name:"name"}],i:[{name:"description"}],u:[{name:"uri"}],e:[{name:"email"}],p:[{name:"phone"}],z:[{name:"timezones"}],r:[{name:"repeats"}],t:[{name:"timing",reg:/^(\d*) (\d*)/,names:["start","stop"],format:"%d %d"}],c:[{name:"connection",reg:/^IN IP(\d) (\S*)/,names:["version","ip"],format:"IN IP%d %s"}],b:[{push:"bandwidth",reg:/^(TIAS|AS|CT|RR|RS):(\d*)/,names:["type","limit"],format:"%s:%s"}],m:[{reg:/^(\w*) (\d*) ([\w\/]*)(?: (.*))?/,names:["type","port","protocol","payloads"],format:"%s %d %s %s"}],a:[{push:"rtp",reg:/^rtpmap:(\d*) ([\w\-\.]*)(?:\s*\/(\d*)(?:\s*\/(\S*))?)?/,names:["payload","codec","rate","encoding"],format:function(e){return e.encoding?"rtpmap:%d %s/%s/%s":e.rate?"rtpmap:%d %s/%s":"rtpmap:%d %s"}},{push:"fmtp",reg:/^fmtp:(\d*) ([\S| ]*)/,names:["payload","config"],format:"fmtp:%d %s"},{name:"control",reg:/^control:(.*)/,format:"control:%s"},{name:"rtcp",reg:/^rtcp:(\d*)(?: (\S*) IP(\d) (\S*))?/,names:["port","netType","ipVer","address"],format:function(e){return null!=e.address?"rtcp:%d %s IP%d %s":"rtcp:%d"}},{push:"rtcpFbTrrInt",reg:/^rtcp-fb:(\*|\d*) trr-int (\d*)/,names:["payload","value"],format:"rtcp-fb:%d trr-int %d"},{push:"rtcpFb",reg:/^rtcp-fb:(\*|\d*) ([\w-_]*)(?: ([\w-_]*))?/,names:["payload","type","subtype"],format:function(e){return null!=e.subtype?"rtcp-fb:%s %s %s":"rtcp-fb:%s %s"}},{push:"ext",reg:/^extmap:(\d+)(?:\/(\w+))? (\S*)(?: (\S*))?/,names:["value","direction","uri","config"],format:function(e){return"extmap:%d"+(e.direction?"/%s":"%v")+" %s"+(e.config?" %s":"")}},{push:"crypto",reg:/^crypto:(\d*) ([\w_]*) (\S*)(?: (\S*))?/,names:["id","suite","config","sessionConfig"],format:function(e){return null!=e.sessionConfig?"crypto:%d %s %s %s":"crypto:%d %s %s"}},{name:"setup",reg:/^setup:(\w*)/,format:"setup:%s"},{name:"mid",reg:/^mid:([^\s]*)/,format:"mid:%s"},{name:"msid",reg:/^msid:(.*)/,format:"msid:%s"},{name:"ptime",reg:/^ptime:(\d*)/,format:"ptime:%d"},{name:"maxptime",reg:/^maxptime:(\d*)/,format:"maxptime:%d"},{name:"direction",reg:/^(sendrecv|recvonly|sendonly|inactive)/},{name:"icelite",reg:/^(ice-lite)/},{name:"iceUfrag",reg:/^ice-ufrag:(\S*)/,format:"ice-ufrag:%s"},{name:"icePwd",reg:/^ice-pwd:(\S*)/,format:"ice-pwd:%s"},{name:"fingerprint",reg:/^fingerprint:(\S*) (\S*)/,names:["type","hash"],format:"fingerprint:%s %s"},{push:"candidates",reg:/^candidate:(\S*) (\d*) (\S*) (\d*) (\S*) (\d*) typ (\S*)(?: raddr (\S*) rport (\d*))?(?: tcptype (\S*))?(?: generation (\d*))?(?: network-id (\d*))?(?: network-cost (\d*))?/,names:["foundation","component","transport","priority","ip","port","type","raddr","rport","tcptype","generation","network-id","network-cost"],format:function(e){var t="candidate:%s %d %s %d %s %d typ %s";return t+=null!=e.raddr?" raddr %s rport %d":"%v%v",t+=null!=e.tcptype?" tcptype %s":"%v",null!=e.generation&&(t+=" generation %d"),t+=null!=e["network-id"]?" network-id %d":"%v",t+=null!=e["network-cost"]?" network-cost %d":"%v"}},{name:"endOfCandidates",reg:/^(end-of-candidates)/},{name:"remoteCandidates",reg:/^remote-candidates:(.*)/,format:"remote-candidates:%s"},{name:"iceOptions",reg:/^ice-options:(\S*)/,format:"ice-options:%s"},{push:"ssrcs",reg:/^ssrc:(\d*) ([\w_-]*)(?::(.*))?/,names:["id","attribute","value"],format:function(e){var t="ssrc:%d";return null!=e.attribute&&(t+=" %s",null!=e.value&&(t+=":%s")),t}},{push:"ssrcGroups",reg:/^ssrc-group:([\x21\x23\x24\x25\x26\x27\x2A\x2B\x2D\x2E\w]*) (.*)/,names:["semantics","ssrcs"],format:"ssrc-group:%s %s"},{name:"msidSemantic",reg:/^msid-semantic:\s?(\w*) (\S*)/,names:["semantic","token"],format:"msid-semantic: %s %s"},{push:"groups",reg:/^group:(\w*) (.*)/,names:["type","mids"],format:"group:%s %s"},{name:"rtcpMux",reg:/^(rtcp-mux)/},{name:"rtcpRsize",reg:/^(rtcp-rsize)/},{name:"sctpmap",reg:/^sctpmap:([\w_\/]*) (\S*)(?: (\S*))?/,names:["sctpmapNumber","app","maxMessageSize"],format:function(e){return null!=e.maxMessageSize?"sctpmap:%s %s %s":"sctpmap:%s %s"}},{name:"xGoogleFlag",reg:/^x-google-flag:([^\s]*)/,format:"x-google-flag:%s"},{push:"rids",reg:/^rid:([\d\w]+) (\w+)(?: ([\S| ]*))?/,names:["id","direction","params"],format:function(e){return e.params?"rid:%s %s %s":"rid:%s %s"}},{push:"imageattrs",reg:new RegExp("^imageattr:(\\d+|\\*)[\\s\\t]+(send|recv)[\\s\\t]+(\\*|\\[\\S+\\](?:[\\s\\t]+\\[\\S+\\])*)(?:[\\s\\t]+(recv|send)[\\s\\t]+(\\*|\\[\\S+\\](?:[\\s\\t]+\\[\\S+\\])*))?"),names:["pt","dir1","attrs1","dir2","attrs2"],format:function(e){return"imageattr:%s %s %s"+(e.dir2?" %s %s":"")}},{name:"simulcast",reg:new RegExp("^simulcast:(send|recv) ([a-zA-Z0-9\\-_~;,]+)(?:\\s?(send|recv) ([a-zA-Z0-9\\-_~;,]+))?$"),names:["dir1","list1","dir2","list2"],format:function(e){return"simulcast:%s %s"+(e.dir2?" %s %s":"")}},{name:"simulcast_03",reg:/^simulcast:[\s\t]+([\S+\s\t]+)$/,names:["value"],format:"simulcast: %s"},{name:"framerate",reg:/^framerate:(\d+(?:$|\.\d+))/,format:"framerate:%s"},{name:"sourceFilter",reg:/^source-filter: *(excl|incl) (\S*) (IP4|IP6|\*) (\S*) (.*)/,names:["filterMode","netType","addressTypes","destAddress","srcList"],format:"source-filter: %s %s %s %s %s"},{push:"invalid",names:["value"]}]};Object.keys(r).forEach(function(e){r[e].forEach(function(e){e.reg||(e.reg=/(.*)/),e.format||(e.format="%s")})})},{}],37:[function(e,t,n){var r=e("./parser"),i=e("./writer");n.write=i,n.parse=r.parse,n.parseFmtpConfig=r.parseFmtpConfig,n.parseParams=r.parseParams,n.parsePayloads=r.parsePayloads,n.parseRemoteCandidates=r.parseRemoteCandidates,n.parseImageAttributes=r.parseImageAttributes,n.parseSimulcastStreamList=r.parseSimulcastStreamList},{"./parser":38,"./writer":39}],38:[function(e,t,n){var r=function(e){return String(Number(e))===e?Number(e):e},i=function(e,t,n){var i=e.name&&e.names;e.push&&!t[e.push]?t[e.push]=[]:i&&!t[e.name]&&(t[e.name]={});var s=e.push?{}:i?t[e.name]:t;!function(e,t,n,i){if(i&&!n)t[i]=r(e[1]);else for(var s=0;s<n.length;s+=1)null!=e[s+1]&&(t[n[s]]=r(e[s+1]))}(n.match(e.reg),s,e.names,e.name),e.push&&t[e.push].push(s)},s=e("./grammar"),a=RegExp.prototype.test.bind(/^([a-z])=(.*)/);n.parse=function(e){var t={},n=[],r=t;return e.split(/(\r\n|\r|\n)/).filter(a).forEach(function(e){var t=e[0],a=e.slice(2);"m"===t&&(n.push({rtp:[],fmtp:[]}),r=n[n.length-1]);for(var o=0;o<(s[t]||[]).length;o+=1){var l=s[t][o];if(l.reg.test(a))return i(l,r,a)}}),t.media=n,t};var o=function(e,t){var n=t.split(/=(.+)/,2);return 2===n.length?e[n[0]]=r(n[1]):1===n.length&&t.length>1&&(e[n[0]]=void 0),e};n.parseParams=function(e){return e.split(/\;\s?/).reduce(o,{})},n.parseFmtpConfig=n.parseParams,n.parsePayloads=function(e){return e.split(" ").map(Number)},n.parseRemoteCandidates=function(e){for(var t=[],n=e.split(" ").map(r),i=0;i<n.length;i+=3)t.push({component:n[i],ip:n[i+1],port:n[i+2]});return t},n.parseImageAttributes=function(e){return e.split(" ").map(function(e){return e.substring(1,e.length-1).split(",").reduce(o,{})})},n.parseSimulcastStreamList=function(e){return e.split(";").map(function(e){return e.split(",").map(function(e){var t,n=!1;return"~"!==e[0]?t=r(e):(t=r(e.substring(1,e.length)),n=!0),{scid:t,paused:n}})})}},{"./grammar":36}],39:[function(e,t,n){var r=e("./grammar"),i=/%[sdv%]/g,s=function(e,t,n){var r=[e+"="+(t.format instanceof Function?t.format(t.push?n:n[t.name]):t.format)];if(t.names)for(var s=0;s<t.names.length;s+=1){var a=t.names[s];t.name?r.push(n[t.name][a]):r.push(n[t.names[s]])}else r.push(n[t.name]);return function(e){var t=1,n=arguments,r=n.length;return e.replace(i,function(e){if(t>=r)return e;var i=n[t];switch(t+=1,e){case"%%":return"%";case"%s":return String(i);case"%d":return Number(i);case"%v":return""}})}.apply(null,r)},a=["v","o","s","i","u","e","p","c","b","t","r","z","a"],o=["i","c","b","a"];t.exports=function(e,t){t=t||{},null==e.version&&(e.version=0),null==e.name&&(e.name=" "),e.media.forEach(function(e){null==e.payloads&&(e.payloads="")});var n=t.outerOrder||a,i=t.innerOrder||o,l=[];return n.forEach(function(t){r[t].forEach(function(n){n.name in e&&null!=e[n.name]?l.push(s(t,n,e)):n.push in e&&null!=e[n.push]&&e[n.push].forEach(function(e){l.push(s(t,n,e))})})}),e.media.forEach(function(e){l.push(s("m",r.m[0],e)),i.forEach(function(t){r[t].forEach(function(n){n.name in e&&null!=e[n.name]?l.push(s(t,n,e)):n.push in e&&null!=e[n.push]&&e[n.push].forEach(function(e){l.push(s(t,n,e))})})})}),l.join("\r\n")+"\r\n"}},{"./grammar":36}],40:[function(e,t,n){"use strict";var r={generateIdentifier:function(){return Math.random().toString(36).substr(2,10)}};r.localCName=r.generateIdentifier(),r.splitLines=function(e){return e.trim().split("\n").map(function(e){return e.trim()})},r.splitSections=function(e){return e.split("\nm=").map(function(e,t){return(t>0?"m="+e:e).trim()+"\r\n"})},r.getDescription=function(e){var t=r.splitSections(e);return t&&t[0]},r.getMediaSections=function(e){var t=r.splitSections(e);return t.shift(),t},r.matchPrefix=function(e,t){return r.splitLines(e).filter(function(e){return 0===e.indexOf(t)})},r.parseCandidate=function(e){for(var t,n={foundation:(t=0===e.indexOf("a=candidate:")?e.substring(12).split(" "):e.substring(10).split(" "))[0],component:parseInt(t[1],10),protocol:t[2].toLowerCase(),priority:parseInt(t[3],10),ip:t[4],port:parseInt(t[5],10),type:t[7]},r=8;r<t.length;r+=2)switch(t[r]){case"raddr":n.relatedAddress=t[r+1];break;case"rport":n.relatedPort=parseInt(t[r+1],10);break;case"tcptype":n.tcpType=t[r+1];break;case"ufrag":n.ufrag=t[r+1],n.usernameFragment=t[r+1];break;default:n[t[r]]=t[r+1]}return n},r.writeCandidate=function(e){var t=[];t.push(e.foundation),t.push(e.component),t.push(e.protocol.toUpperCase()),t.push(e.priority),t.push(e.ip),t.push(e.port);var n=e.type;return t.push("typ"),t.push(n),"host"!==n&&e.relatedAddress&&e.relatedPort&&(t.push("raddr"),t.push(e.relatedAddress),t.push("rport"),t.push(e.relatedPort)),e.tcpType&&"tcp"===e.protocol.toLowerCase()&&(t.push("tcptype"),t.push(e.tcpType)),(e.usernameFragment||e.ufrag)&&(t.push("ufrag"),t.push(e.usernameFragment||e.ufrag)),"candidate:"+t.join(" ")},r.parseIceOptions=function(e){return e.substr(14).split(" ")},r.parseRtpMap=function(e){var t=e.substr(9).split(" "),n={payloadType:parseInt(t.shift(),10)};return t=t[0].split("/"),n.name=t[0],n.clockRate=parseInt(t[1],10),n.channels=3===t.length?parseInt(t[2],10):1,n.numChannels=n.channels,n},r.writeRtpMap=function(e){var t=e.payloadType;void 0!==e.preferredPayloadType&&(t=e.preferredPayloadType);var n=e.channels||e.numChannels||1;return"a=rtpmap:"+t+" "+e.name+"/"+e.clockRate+(1!==n?"/"+n:"")+"\r\n"},r.parseExtmap=function(e){var t=e.substr(9).split(" ");return{id:parseInt(t[0],10),direction:t[0].indexOf("/")>0?t[0].split("/")[1]:"sendrecv",uri:t[1]}},r.writeExtmap=function(e){return"a=extmap:"+(e.id||e.preferredId)+(e.direction&&"sendrecv"!==e.direction?"/"+e.direction:"")+" "+e.uri+"\r\n"},r.parseFmtp=function(e){for(var t,n={},r=e.substr(e.indexOf(" ")+1).split(";"),i=0;i<r.length;i++)n[(t=r[i].trim().split("="))[0].trim()]=t[1];return n},r.writeFmtp=function(e){var t="",n=e.payloadType;if(void 0!==e.preferredPayloadType&&(n=e.preferredPayloadType),e.parameters&&Object.keys(e.parameters).length){var r=[];Object.keys(e.parameters).forEach(function(t){e.parameters[t]?r.push(t+"="+e.parameters[t]):r.push(t)}),t+="a=fmtp:"+n+" "+r.join(";")+"\r\n"}return t},r.parseRtcpFb=function(e){var t=e.substr(e.indexOf(" ")+1).split(" ");return{type:t.shift(),parameter:t.join(" ")}},r.writeRtcpFb=function(e){var t="",n=e.payloadType;return void 0!==e.preferredPayloadType&&(n=e.preferredPayloadType),e.rtcpFeedback&&e.rtcpFeedback.length&&e.rtcpFeedback.forEach(function(e){t+="a=rtcp-fb:"+n+" "+e.type+(e.parameter&&e.parameter.length?" "+e.parameter:"")+"\r\n"}),t},r.parseSsrcMedia=function(e){var t=e.indexOf(" "),n={ssrc:parseInt(e.substr(7,t-7),10)},r=e.indexOf(":",t);return r>-1?(n.attribute=e.substr(t+1,r-t-1),n.value=e.substr(r+1)):n.attribute=e.substr(t+1),n},r.parseSsrcGroup=function(e){var t=e.substr(13).split(" ");return{semantics:t.shift(),ssrcs:t.map(function(e){return parseInt(e,10)})}},r.getMid=function(e){var t=r.matchPrefix(e,"a=mid:")[0];if(t)return t.substr(6)},r.parseFingerprint=function(e){var t=e.substr(14).split(" ");return{algorithm:t[0].toLowerCase(),value:t[1]}},r.getDtlsParameters=function(e,t){return{role:"auto",fingerprints:r.matchPrefix(e+t,"a=fingerprint:").map(r.parseFingerprint)}},r.writeDtlsParameters=function(e,t){var n="a=setup:"+t+"\r\n";return e.fingerprints.forEach(function(e){n+="a=fingerprint:"+e.algorithm+" "+e.value+"\r\n"}),n},r.getIceParameters=function(e,t){var n=r.splitLines(e);return{usernameFragment:(n=n.concat(r.splitLines(t))).filter(function(e){return 0===e.indexOf("a=ice-ufrag:")})[0].substr(12),password:n.filter(function(e){return 0===e.indexOf("a=ice-pwd:")})[0].substr(10)}},r.writeIceParameters=function(e){return"a=ice-ufrag:"+e.usernameFragment+"\r\na=ice-pwd:"+e.password+"\r\n"},r.parseRtpParameters=function(e){for(var t={codecs:[],headerExtensions:[],fecMechanisms:[],rtcp:[]},n=r.splitLines(e)[0].split(" "),i=3;i<n.length;i++){var s=n[i],a=r.matchPrefix(e,"a=rtpmap:"+s+" ")[0];if(a){var o=r.parseRtpMap(a),l=r.matchPrefix(e,"a=fmtp:"+s+" ");switch(o.parameters=l.length?r.parseFmtp(l[0]):{},o.rtcpFeedback=r.matchPrefix(e,"a=rtcp-fb:"+s+" ").map(r.parseRtcpFb),t.codecs.push(o),o.name.toUpperCase()){case"RED":case"ULPFEC":t.fecMechanisms.push(o.name.toUpperCase())}}}return r.matchPrefix(e,"a=extmap:").forEach(function(e){t.headerExtensions.push(r.parseExtmap(e))}),t},r.writeRtpDescription=function(e,t){var n="";n+="m="+e+" ",n+=t.codecs.length>0?"9":"0",n+=" UDP/TLS/RTP/SAVPF ",n+=t.codecs.map(function(e){return void 0!==e.preferredPayloadType?e.preferredPayloadType:e.payloadType}).join(" ")+"\r\n",n+="c=IN IP4 0.0.0.0\r\n",n+="a=rtcp:9 IN IP4 0.0.0.0\r\n",t.codecs.forEach(function(e){n+=r.writeRtpMap(e),n+=r.writeFmtp(e),n+=r.writeRtcpFb(e)});var i=0;return t.codecs.forEach(function(e){e.maxptime>i&&(i=e.maxptime)}),i>0&&(n+="a=maxptime:"+i+"\r\n"),n+="a=rtcp-mux\r\n",t.headerExtensions&&t.headerExtensions.forEach(function(e){n+=r.writeExtmap(e)}),n},r.parseRtpEncodingParameters=function(e){var t,n=[],i=r.parseRtpParameters(e),s=-1!==i.fecMechanisms.indexOf("RED"),a=-1!==i.fecMechanisms.indexOf("ULPFEC"),o=r.matchPrefix(e,"a=ssrc:").map(function(e){return r.parseSsrcMedia(e)}).filter(function(e){return"cname"===e.attribute}),l=o.length>0&&o[0].ssrc,u=r.matchPrefix(e,"a=ssrc-group:FID").map(function(e){return e.substr(17).split(" ").map(function(e){return parseInt(e,10)})});u.length>0&&u[0].length>1&&u[0][0]===l&&(t=u[0][1]),i.codecs.forEach(function(e){if("RTX"===e.name.toUpperCase()&&e.parameters.apt){var r={ssrc:l,codecPayloadType:parseInt(e.parameters.apt,10)};l&&t&&(r.rtx={ssrc:t}),n.push(r),s&&((r=JSON.parse(JSON.stringify(r))).fec={ssrc:t,mechanism:a?"red+ulpfec":"red"},n.push(r))}}),0===n.length&&l&&n.push({ssrc:l});var c=r.matchPrefix(e,"b=");return c.length&&(c=0===c[0].indexOf("b=TIAS:")?parseInt(c[0].substr(7),10):0===c[0].indexOf("b=AS:")?1e3*parseInt(c[0].substr(5),10)*.95-16e3:void 0,n.forEach(function(e){e.maxBitrate=c})),n},r.parseRtcpParameters=function(e){var t={},n=r.matchPrefix(e,"a=ssrc:").map(function(e){return r.parseSsrcMedia(e)}).filter(function(e){return"cname"===e.attribute})[0];n&&(t.cname=n.value,t.ssrc=n.ssrc);var i=r.matchPrefix(e,"a=rtcp-rsize");t.reducedSize=i.length>0,t.compound=0===i.length;var s=r.matchPrefix(e,"a=rtcp-mux");return t.mux=s.length>0,t},r.parseMsid=function(e){var t,n=r.matchPrefix(e,"a=msid:");if(1===n.length)return{stream:(t=n[0].substr(7).split(" "))[0],track:t[1]};var i=r.matchPrefix(e,"a=ssrc:").map(function(e){return r.parseSsrcMedia(e)}).filter(function(e){return"msid"===e.attribute});return i.length>0?{stream:(t=i[0].value.split(" "))[0],track:t[1]}:void 0},r.generateSessionId=function(){return Math.random().toString().substr(2,21)},r.writeSessionBoilerplate=function(e,t){var n=void 0!==t?t:2;return"v=0\r\no=thisisadapterortc "+(e||r.generateSessionId())+" "+n+" IN IP4 127.0.0.1\r\ns=-\r\nt=0 0\r\n"},r.writeMediaSection=function(e,t,n,i){var s=r.writeRtpDescription(e.kind,t);if(s+=r.writeIceParameters(e.iceGatherer.getLocalParameters()),s+=r.writeDtlsParameters(e.dtlsTransport.getLocalParameters(),"offer"===n?"actpass":"active"),s+="a=mid:"+e.mid+"\r\n",e.direction?s+="a="+e.direction+"\r\n":e.rtpSender&&e.rtpReceiver?s+="a=sendrecv\r\n":e.rtpSender?s+="a=sendonly\r\n":e.rtpReceiver?s+="a=recvonly\r\n":s+="a=inactive\r\n",e.rtpSender){var a="msid:"+i.id+" "+e.rtpSender.track.id+"\r\n";s+="a="+a,s+="a=ssrc:"+e.sendEncodingParameters[0].ssrc+" "+a,e.sendEncodingParameters[0].rtx&&(s+="a=ssrc:"+e.sendEncodingParameters[0].rtx.ssrc+" "+a,s+="a=ssrc-group:FID "+e.sendEncodingParameters[0].ssrc+" "+e.sendEncodingParameters[0].rtx.ssrc+"\r\n")}return s+="a=ssrc:"+e.sendEncodingParameters[0].ssrc+" cname:"+r.localCName+"\r\n",e.rtpSender&&e.sendEncodingParameters[0].rtx&&(s+="a=ssrc:"+e.sendEncodingParameters[0].rtx.ssrc+" cname:"+r.localCName+"\r\n"),s},r.getDirection=function(e,t){for(var n=r.splitLines(e),i=0;i<n.length;i++)switch(n[i]){case"a=sendrecv":case"a=sendonly":case"a=recvonly":case"a=inactive":return n[i].substr(2)}return t?r.getDirection(t):"sendrecv"},r.getKind=function(e){return r.splitLines(e)[0].split(" ")[0].substr(2)},r.isRejected=function(e){return"0"===e.split(" ",2)[1]},r.parseMLine=function(e){var t=r.splitLines(e)[0].substr(2).split(" ");return{kind:t[0],port:parseInt(t[1],10),protocol:t[2],fmt:t.slice(3).join(" ")}},r.parseOLine=function(e){var t=r.matchPrefix(e,"o=")[0].substr(2).split(" ");return{username:t[0],sessionId:t[1],sessionVersion:parseInt(t[2],10),netType:t[3],addressType:t[4],address:t[5]}},r.isValidSDP=function(e){if("string"!=typeof e||0===e.length)return!1;for(var t=r.splitLines(e),n=0;n<t.length;n++)if(t[n].length<2||"="!==t[n].charAt(1))return!1;return!0},"object"==typeof t&&(t.exports=r)},{}],41:[function(e,t,n){!function(e){if("object"==typeof n)t.exports=e();else if("function"==typeof define&&define.amd)define(e);else{var r;try{r=window}catch(e){r=self}r.SparkMD5=e()}}(function(e){"use strict";var t=["0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f"];function n(e,t){var n=e[0],r=e[1],i=e[2],s=e[3];r=((r+=((i=((i+=((s=((s+=((n=((n+=(r&i|~r&s)+t[0]-680876936|0)<<7|n>>>25)+r|0)&r|~n&i)+t[1]-389564586|0)<<12|s>>>20)+n|0)&n|~s&r)+t[2]+606105819|0)<<17|i>>>15)+s|0)&s|~i&n)+t[3]-1044525330|0)<<22|r>>>10)+i|0,r=((r+=((i=((i+=((s=((s+=((n=((n+=(r&i|~r&s)+t[4]-176418897|0)<<7|n>>>25)+r|0)&r|~n&i)+t[5]+1200080426|0)<<12|s>>>20)+n|0)&n|~s&r)+t[6]-1473231341|0)<<17|i>>>15)+s|0)&s|~i&n)+t[7]-45705983|0)<<22|r>>>10)+i|0,r=((r+=((i=((i+=((s=((s+=((n=((n+=(r&i|~r&s)+t[8]+1770035416|0)<<7|n>>>25)+r|0)&r|~n&i)+t[9]-1958414417|0)<<12|s>>>20)+n|0)&n|~s&r)+t[10]-42063|0)<<17|i>>>15)+s|0)&s|~i&n)+t[11]-1990404162|0)<<22|r>>>10)+i|0,r=((r+=((i=((i+=((s=((s+=((n=((n+=(r&i|~r&s)+t[12]+1804603682|0)<<7|n>>>25)+r|0)&r|~n&i)+t[13]-40341101|0)<<12|s>>>20)+n|0)&n|~s&r)+t[14]-1502002290|0)<<17|i>>>15)+s|0)&s|~i&n)+t[15]+1236535329|0)<<22|r>>>10)+i|0,r=((r+=((i=((i+=((s=((s+=((n=((n+=(r&s|i&~s)+t[1]-165796510|0)<<5|n>>>27)+r|0)&i|r&~i)+t[6]-1069501632|0)<<9|s>>>23)+n|0)&r|n&~r)+t[11]+643717713|0)<<14|i>>>18)+s|0)&n|s&~n)+t[0]-373897302|0)<<20|r>>>12)+i|0,r=((r+=((i=((i+=((s=((s+=((n=((n+=(r&s|i&~s)+t[5]-701558691|0)<<5|n>>>27)+r|0)&i|r&~i)+t[10]+38016083|0)<<9|s>>>23)+n|0)&r|n&~r)+t[15]-660478335|0)<<14|i>>>18)+s|0)&n|s&~n)+t[4]-405537848|0)<<20|r>>>12)+i|0,r=((r+=((i=((i+=((s=((s+=((n=((n+=(r&s|i&~s)+t[9]+568446438|0)<<5|n>>>27)+r|0)&i|r&~i)+t[14]-1019803690|0)<<9|s>>>23)+n|0)&r|n&~r)+t[3]-187363961|0)<<14|i>>>18)+s|0)&n|s&~n)+t[8]+1163531501|0)<<20|r>>>12)+i|0,r=((r+=((i=((i+=((s=((s+=((n=((n+=(r&s|i&~s)+t[13]-1444681467|0)<<5|n>>>27)+r|0)&i|r&~i)+t[2]-51403784|0)<<9|s>>>23)+n|0)&r|n&~r)+t[7]+1735328473|0)<<14|i>>>18)+s|0)&n|s&~n)+t[12]-1926607734|0)<<20|r>>>12)+i|0,r=((r+=((i=((i+=((s=((s+=((n=((n+=(r^i^s)+t[5]-378558|0)<<4|n>>>28)+r|0)^r^i)+t[8]-2022574463|0)<<11|s>>>21)+n|0)^n^r)+t[11]+1839030562|0)<<16|i>>>16)+s|0)^s^n)+t[14]-35309556|0)<<23|r>>>9)+i|0,r=((r+=((i=((i+=((s=((s+=((n=((n+=(r^i^s)+t[1]-1530992060|0)<<4|n>>>28)+r|0)^r^i)+t[4]+1272893353|0)<<11|s>>>21)+n|0)^n^r)+t[7]-155497632|0)<<16|i>>>16)+s|0)^s^n)+t[10]-1094730640|0)<<23|r>>>9)+i|0,r=((r+=((i=((i+=((s=((s+=((n=((n+=(r^i^s)+t[13]+681279174|0)<<4|n>>>28)+r|0)^r^i)+t[0]-358537222|0)<<11|s>>>21)+n|0)^n^r)+t[3]-722521979|0)<<16|i>>>16)+s|0)^s^n)+t[6]+76029189|0)<<23|r>>>9)+i|0,r=((r+=((i=((i+=((s=((s+=((n=((n+=(r^i^s)+t[9]-640364487|0)<<4|n>>>28)+r|0)^r^i)+t[12]-421815835|0)<<11|s>>>21)+n|0)^n^r)+t[15]+530742520|0)<<16|i>>>16)+s|0)^s^n)+t[2]-995338651|0)<<23|r>>>9)+i|0,r=((r+=((s=((s+=(r^((n=((n+=(i^(r|~s))+t[0]-198630844|0)<<6|n>>>26)+r|0)|~i))+t[7]+1126891415|0)<<10|s>>>22)+n|0)^((i=((i+=(n^(s|~r))+t[14]-1416354905|0)<<15|i>>>17)+s|0)|~n))+t[5]-57434055|0)<<21|r>>>11)+i|0,r=((r+=((s=((s+=(r^((n=((n+=(i^(r|~s))+t[12]+1700485571|0)<<6|n>>>26)+r|0)|~i))+t[3]-1894986606|0)<<10|s>>>22)+n|0)^((i=((i+=(n^(s|~r))+t[10]-1051523|0)<<15|i>>>17)+s|0)|~n))+t[1]-2054922799|0)<<21|r>>>11)+i|0,r=((r+=((s=((s+=(r^((n=((n+=(i^(r|~s))+t[8]+1873313359|0)<<6|n>>>26)+r|0)|~i))+t[15]-30611744|0)<<10|s>>>22)+n|0)^((i=((i+=(n^(s|~r))+t[6]-1560198380|0)<<15|i>>>17)+s|0)|~n))+t[13]+1309151649|0)<<21|r>>>11)+i|0,r=((r+=((s=((s+=(r^((n=((n+=(i^(r|~s))+t[4]-145523070|0)<<6|n>>>26)+r|0)|~i))+t[11]-1120210379|0)<<10|s>>>22)+n|0)^((i=((i+=(n^(s|~r))+t[2]+718787259|0)<<15|i>>>17)+s|0)|~n))+t[9]-343485551|0)<<21|r>>>11)+i|0,e[0]=n+e[0]|0,e[1]=r+e[1]|0,e[2]=i+e[2]|0,e[3]=s+e[3]|0}function r(e){var t,n=[];for(t=0;t<64;t+=4)n[t>>2]=e.charCodeAt(t)+(e.charCodeAt(t+1)<<8)+(e.charCodeAt(t+2)<<16)+(e.charCodeAt(t+3)<<24);return n}function i(e){var t,n=[];for(t=0;t<64;t+=4)n[t>>2]=e[t]+(e[t+1]<<8)+(e[t+2]<<16)+(e[t+3]<<24);return n}function s(e){var t,i,s,a,o,l,u=e.length,c=[1732584193,-271733879,-1732584194,271733878];for(t=64;t<=u;t+=64)n(c,r(e.substring(t-64,t)));for(i=(e=e.substring(t-64)).length,s=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],t=0;t<i;t+=1)s[t>>2]|=e.charCodeAt(t)<<(t%4<<3);if(s[t>>2]|=128<<(t%4<<3),t>55)for(n(c,s),t=0;t<16;t+=1)s[t]=0;return a=(a=8*u).toString(16).match(/(.*?)(.{0,8})$/),o=parseInt(a[2],16),l=parseInt(a[1],16)||0,s[14]=o,s[15]=l,n(c,s),c}function a(e){var n,r="";for(n=0;n<4;n+=1)r+=t[e>>8*n+4&15]+t[e>>8*n&15];return r}function o(e){var t;for(t=0;t<e.length;t+=1)e[t]=a(e[t]);return e.join("")}function l(e){return/[\u0080-\uFFFF]/.test(e)&&(e=unescape(encodeURIComponent(e))),e}function u(e){var t,n=[],r=e.length;for(t=0;t<r-1;t+=2)n.push(parseInt(e.substr(t,2),16));return String.fromCharCode.apply(String,n)}function c(){this.reset()}return"5d41402abc4b2a76b9719d911017c592"!==o(s("hello"))&&function(e,t){var n=(65535&e)+(65535&t);return(e>>16)+(t>>16)+(n>>16)<<16|65535&n},"undefined"==typeof ArrayBuffer||ArrayBuffer.prototype.slice||function(){function t(e,t){return(e=0|e||0)<0?Math.max(e+t,0):Math.min(e,t)}ArrayBuffer.prototype.slice=function(n,r){var i,s,a,o,l=this.byteLength,u=t(n,l),c=l;return r!==e&&(c=t(r,l)),u>c?new ArrayBuffer(0):(i=c-u,s=new ArrayBuffer(i),a=new Uint8Array(s),o=new Uint8Array(this,u,i),a.set(o),s)}}(),c.prototype.append=function(e){return this.appendBinary(l(e)),this},c.prototype.appendBinary=function(e){this._buff+=e,this._length+=e.length;var t,i=this._buff.length;for(t=64;t<=i;t+=64)n(this._hash,r(this._buff.substring(t-64,t)));return this._buff=this._buff.substring(t-64),this},c.prototype.end=function(e){var t,n,r=this._buff,i=r.length,s=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];for(t=0;t<i;t+=1)s[t>>2]|=r.charCodeAt(t)<<(t%4<<3);return this._finish(s,i),n=o(this._hash),e&&(n=u(n)),this.reset(),n},c.prototype.reset=function(){return this._buff="",this._length=0,this._hash=[1732584193,-271733879,-1732584194,271733878],this},c.prototype.getState=function(){return{buff:this._buff,length:this._length,hash:this._hash}},c.prototype.setState=function(e){return this._buff=e.buff,this._length=e.length,this._hash=e.hash,this},c.prototype.destroy=function(){delete this._hash,delete this._buff,delete this._length},c.prototype._finish=function(e,t){var r,i,s,a=t;if(e[a>>2]|=128<<(a%4<<3),a>55)for(n(this._hash,e),a=0;a<16;a+=1)e[a]=0;r=(r=8*this._length).toString(16).match(/(.*?)(.{0,8})$/),i=parseInt(r[2],16),s=parseInt(r[1],16)||0,e[14]=i,e[15]=s,n(this._hash,e)},c.hash=function(e,t){return c.hashBinary(l(e),t)},c.hashBinary=function(e,t){var n=o(s(e));return t?u(n):n},c.ArrayBuffer=function(){this.reset()},c.ArrayBuffer.prototype.append=function(e){var t,r,s,a,o,l=(r=this._buff.buffer,s=e,a=!0,(o=new Uint8Array(r.byteLength+s.byteLength)).set(new Uint8Array(r)),o.set(new Uint8Array(s),r.byteLength),a?o:o.buffer),u=l.length;for(this._length+=e.byteLength,t=64;t<=u;t+=64)n(this._hash,i(l.subarray(t-64,t)));return this._buff=t-64<u?new Uint8Array(l.buffer.slice(t-64)):new Uint8Array(0),this},c.ArrayBuffer.prototype.end=function(e){var t,n,r=this._buff,i=r.length,s=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];for(t=0;t<i;t+=1)s[t>>2]|=r[t]<<(t%4<<3);return this._finish(s,i),n=o(this._hash),e&&(n=u(n)),this.reset(),n},c.ArrayBuffer.prototype.reset=function(){return this._buff=new Uint8Array(0),this._length=0,this._hash=[1732584193,-271733879,-1732584194,271733878],this},c.ArrayBuffer.prototype.getState=function(){var e,t=c.prototype.getState.call(this);return t.buff=(e=t.buff,String.fromCharCode.apply(null,new Uint8Array(e))),t},c.ArrayBuffer.prototype.setState=function(e){return e.buff=function(e,t){var n,r=e.length,i=new ArrayBuffer(r),s=new Uint8Array(i);for(n=0;n<r;n+=1)s[n]=e.charCodeAt(n);return t?s:i}(e.buff,!0),c.prototype.setState.call(this,e)},c.ArrayBuffer.prototype.destroy=c.prototype.destroy,c.ArrayBuffer.prototype._finish=c.prototype._finish,c.ArrayBuffer.hash=function(e,t){var r=o(function(e){var t,r,s,a,o,l,u=e.length,c=[1732584193,-271733879,-1732584194,271733878];for(t=64;t<=u;t+=64)n(c,i(e.subarray(t-64,t)));for(r=(e=t-64<u?e.subarray(t-64):new Uint8Array(0)).length,s=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],t=0;t<r;t+=1)s[t>>2]|=e[t]<<(t%4<<3);if(s[t>>2]|=128<<(t%4<<3),t>55)for(n(c,s),t=0;t<16;t+=1)s[t]=0;return a=(a=8*u).toString(16).match(/(.*?)(.{0,8})$/),o=parseInt(a[2],16),l=parseInt(a[1],16)||0,s[14]=o,s[15]=l,n(c,s),c}(new Uint8Array(e)));return t?u(r):r},c})},{}],42:[function(e,t,n){(function(n){"use strict";var r=e("./adapter_factory.js");t.exports=r({window:n.window})}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./adapter_factory.js":43}],43:[function(e,t,n){"use strict";var r=e("./utils");t.exports=function(t,n){var i=t&&t.window,s={shimChrome:!0,shimFirefox:!0,shimEdge:!0,shimSafari:!0};for(var a in n)hasOwnProperty.call(n,a)&&(s[a]=n[a]);var o=r.log,l=r.detectBrowser(i),u=e("./chrome/chrome_shim")||null,c=e("./edge/edge_shim")||null,d=e("./firefox/firefox_shim")||null,h=e("./safari/safari_shim")||null,p=e("./common_shim")||null,f={browserDetails:l,commonShim:p,extractVersion:r.extractVersion,disableLog:r.disableLog,disableWarnings:r.disableWarnings};switch(l.browser){case"chrome":if(!u||!u.shimPeerConnection||!s.shimChrome)return o("Chrome shim is not included in this adapter release."),f;o("adapter.js shimming chrome."),f.browserShim=u,p.shimCreateObjectURL(i),u.shimGetUserMedia(i),u.shimMediaStream(i),u.shimSourceObject(i),u.shimPeerConnection(i),u.shimOnTrack(i),u.shimAddTrackRemoveTrack(i),u.shimGetSendersWithDtmf(i),u.shimSenderReceiverGetStats(i),u.fixNegotiationNeeded(i),p.shimRTCIceCandidate(i),p.shimMaxMessageSize(i),p.shimSendThrowTypeError(i);break;case"firefox":if(!d||!d.shimPeerConnection||!s.shimFirefox)return o("Firefox shim is not included in this adapter release."),f;o("adapter.js shimming firefox."),f.browserShim=d,p.shimCreateObjectURL(i),d.shimGetUserMedia(i),d.shimSourceObject(i),d.shimPeerConnection(i),d.shimOnTrack(i),d.shimRemoveStream(i),d.shimSenderGetStats(i),d.shimReceiverGetStats(i),d.shimRTCDataChannel(i),p.shimRTCIceCandidate(i),p.shimMaxMessageSize(i),p.shimSendThrowTypeError(i);break;case"edge":if(!c||!c.shimPeerConnection||!s.shimEdge)return o("MS edge shim is not included in this adapter release."),f;o("adapter.js shimming edge."),f.browserShim=c,p.shimCreateObjectURL(i),c.shimGetUserMedia(i),c.shimPeerConnection(i),c.shimReplaceTrack(i),p.shimMaxMessageSize(i),p.shimSendThrowTypeError(i);break;case"safari":if(!h||!s.shimSafari)return o("Safari shim is not included in this adapter release."),f;o("adapter.js shimming safari."),f.browserShim=h,p.shimCreateObjectURL(i),h.shimRTCIceServerUrls(i),h.shimCreateOfferLegacy(i),h.shimCallbacksAPI(i),h.shimLocalStreamsAPI(i),h.shimRemoteStreamsAPI(i),h.shimTrackEventTransceiver(i),h.shimGetUserMedia(i),p.shimRTCIceCandidate(i),p.shimMaxMessageSize(i),p.shimSendThrowTypeError(i);break;default:o("Unsupported browser!")}return f}},{"./chrome/chrome_shim":44,"./common_shim":46,"./edge/edge_shim":47,"./firefox/firefox_shim":50,"./safari/safari_shim":52,"./utils":53}],44:[function(e,t,n){"use strict";var r=e("../utils.js"),i=r.log;function s(e,t,n){var r=n?"outbound-rtp":"inbound-rtp",i=new Map;if(null===t)return i;var s=[];return e.forEach(function(e){"track"===e.type&&e.trackIdentifier===t.id&&s.push(e)}),s.forEach(function(t){e.forEach(function(n){n.type===r&&n.trackId===t.id&&function e(t,n,r){n&&!r.has(n.id)&&(r.set(n.id,n),Object.keys(n).forEach(function(i){i.endsWith("Id")?e(t,t.get(n[i]),r):i.endsWith("Ids")&&n[i].forEach(function(n){e(t,t.get(n),r)})}))}(e,n,i)})}),i}t.exports={shimGetUserMedia:e("./getusermedia"),shimMediaStream:function(e){e.MediaStream=e.MediaStream||e.webkitMediaStream},shimOnTrack:function(e){if("object"!=typeof e||!e.RTCPeerConnection||"ontrack"in e.RTCPeerConnection.prototype)"RTCRtpTransceiver"in e||r.wrapPeerConnectionEvent(e,"track",function(e){return e.transceiver||(e.transceiver={receiver:e.receiver}),e});else{Object.defineProperty(e.RTCPeerConnection.prototype,"ontrack",{get:function(){return this._ontrack},set:function(e){this._ontrack&&this.removeEventListener("track",this._ontrack),this.addEventListener("track",this._ontrack=e)},enumerable:!0,configurable:!0});var t=e.RTCPeerConnection.prototype.setRemoteDescription;e.RTCPeerConnection.prototype.setRemoteDescription=function(){var n=this;return n._ontrackpoly||(n._ontrackpoly=function(t){t.stream.addEventListener("addtrack",function(r){var i;i=e.RTCPeerConnection.prototype.getReceivers?n.getReceivers().find(function(e){return e.track&&e.track.id===r.track.id}):{track:r.track};var s=new Event("track");s.track=r.track,s.receiver=i,s.transceiver={receiver:i},s.streams=[t.stream],n.dispatchEvent(s)}),t.stream.getTracks().forEach(function(r){var i;i=e.RTCPeerConnection.prototype.getReceivers?n.getReceivers().find(function(e){return e.track&&e.track.id===r.id}):{track:r};var s=new Event("track");s.track=r,s.receiver=i,s.transceiver={receiver:i},s.streams=[t.stream],n.dispatchEvent(s)})},n.addEventListener("addstream",n._ontrackpoly)),t.apply(n,arguments)}}},shimGetSendersWithDtmf:function(e){if("object"==typeof e&&e.RTCPeerConnection&&!("getSenders"in e.RTCPeerConnection.prototype)&&"createDTMFSender"in e.RTCPeerConnection.prototype){var t=function(e,t){return{track:t,get dtmf(){return void 0===this._dtmf&&("audio"===t.kind?this._dtmf=e.createDTMFSender(t):this._dtmf=null),this._dtmf},_pc:e}};if(!e.RTCPeerConnection.prototype.getSenders){e.RTCPeerConnection.prototype.getSenders=function(){return this._senders=this._senders||[],this._senders.slice()};var n=e.RTCPeerConnection.prototype.addTrack;e.RTCPeerConnection.prototype.addTrack=function(e,r){var i=n.apply(this,arguments);return i||(i=t(this,e),this._senders.push(i)),i};var r=e.RTCPeerConnection.prototype.removeTrack;e.RTCPeerConnection.prototype.removeTrack=function(e){r.apply(this,arguments);var t=this._senders.indexOf(e);-1!==t&&this._senders.splice(t,1)}}var i=e.RTCPeerConnection.prototype.addStream;e.RTCPeerConnection.prototype.addStream=function(e){var n=this;n._senders=n._senders||[],i.apply(n,[e]),e.getTracks().forEach(function(e){n._senders.push(t(n,e))})};var s=e.RTCPeerConnection.prototype.removeStream;e.RTCPeerConnection.prototype.removeStream=function(e){var t=this;t._senders=t._senders||[],s.apply(t,[e]),e.getTracks().forEach(function(e){var n=t._senders.find(function(t){return t.track===e});n&&t._senders.splice(t._senders.indexOf(n),1)})}}else if("object"==typeof e&&e.RTCPeerConnection&&"getSenders"in e.RTCPeerConnection.prototype&&"createDTMFSender"in e.RTCPeerConnection.prototype&&e.RTCRtpSender&&!("dtmf"in e.RTCRtpSender.prototype)){var a=e.RTCPeerConnection.prototype.getSenders;e.RTCPeerConnection.prototype.getSenders=function(){var e=this,t=a.apply(e,[]);return t.forEach(function(t){t._pc=e}),t},Object.defineProperty(e.RTCRtpSender.prototype,"dtmf",{get:function(){return void 0===this._dtmf&&("audio"===this.track.kind?this._dtmf=this._pc.createDTMFSender(this.track):this._dtmf=null),this._dtmf}})}},shimSenderReceiverGetStats:function(e){if("object"==typeof e&&e.RTCPeerConnection&&e.RTCRtpSender&&e.RTCRtpReceiver){if(!("getStats"in e.RTCRtpSender.prototype)){var t=e.RTCPeerConnection.prototype.getSenders;t&&(e.RTCPeerConnection.prototype.getSenders=function(){var e=this,n=t.apply(e,[]);return n.forEach(function(t){t._pc=e}),n});var n=e.RTCPeerConnection.prototype.addTrack;n&&(e.RTCPeerConnection.prototype.addTrack=function(){var e=n.apply(this,arguments);return e._pc=this,e}),e.RTCRtpSender.prototype.getStats=function(){var e=this;return this._pc.getStats().then(function(t){return s(t,e.track,!0)})}}if(!("getStats"in e.RTCRtpReceiver.prototype)){var i=e.RTCPeerConnection.prototype.getReceivers;i&&(e.RTCPeerConnection.prototype.getReceivers=function(){var e=this,t=i.apply(e,[]);return t.forEach(function(t){t._pc=e}),t}),r.wrapPeerConnectionEvent(e,"track",function(e){return e.receiver._pc=e.srcElement,e}),e.RTCRtpReceiver.prototype.getStats=function(){var e=this;return this._pc.getStats().then(function(t){return s(t,e.track,!1)})}}if("getStats"in e.RTCRtpSender.prototype&&"getStats"in e.RTCRtpReceiver.prototype){var a=e.RTCPeerConnection.prototype.getStats;e.RTCPeerConnection.prototype.getStats=function(){if(arguments.length>0&&arguments[0]instanceof e.MediaStreamTrack){var t,n,r,i=arguments[0];return this.getSenders().forEach(function(e){e.track===i&&(t?r=!0:t=e)}),this.getReceivers().forEach(function(e){return e.track===i&&(n?r=!0:n=e),e.track===i}),r||t&&n?Promise.reject(new DOMException("There are more than one sender or receiver for the track.","InvalidAccessError")):t?t.getStats():n?n.getStats():Promise.reject(new DOMException("There is no sender or receiver for the track.","InvalidAccessError"))}return a.apply(this,arguments)}}}},shimSourceObject:function(e){var t=e&&e.URL;"object"==typeof e&&(!e.HTMLMediaElement||"srcObject"in e.HTMLMediaElement.prototype||Object.defineProperty(e.HTMLMediaElement.prototype,"srcObject",{get:function(){return this._srcObject},set:function(e){var n=this;this._srcObject=e,this.src&&t.revokeObjectURL(this.src),e?(this.src=t.createObjectURL(e),e.addEventListener("addtrack",function(){n.src&&t.revokeObjectURL(n.src),n.src=t.createObjectURL(e)}),e.addEventListener("removetrack",function(){n.src&&t.revokeObjectURL(n.src),n.src=t.createObjectURL(e)})):this.src=""}}))},shimAddTrackRemoveTrackWithNative:function(e){e.RTCPeerConnection.prototype.getLocalStreams=function(){var e=this;return this._shimmedLocalStreams=this._shimmedLocalStreams||{},Object.keys(this._shimmedLocalStreams).map(function(t){return e._shimmedLocalStreams[t][0]})};var t=e.RTCPeerConnection.prototype.addTrack;e.RTCPeerConnection.prototype.addTrack=function(e,n){if(!n)return t.apply(this,arguments);this._shimmedLocalStreams=this._shimmedLocalStreams||{};var r=t.apply(this,arguments);return this._shimmedLocalStreams[n.id]?-1===this._shimmedLocalStreams[n.id].indexOf(r)&&this._shimmedLocalStreams[n.id].push(r):this._shimmedLocalStreams[n.id]=[n,r],r};var n=e.RTCPeerConnection.prototype.addStream;e.RTCPeerConnection.prototype.addStream=function(e){var t=this;this._shimmedLocalStreams=this._shimmedLocalStreams||{},e.getTracks().forEach(function(e){if(t.getSenders().find(function(t){return t.track===e}))throw new DOMException("Track already exists.","InvalidAccessError")});var r=t.getSenders();n.apply(this,arguments);var i=t.getSenders().filter(function(e){return-1===r.indexOf(e)});this._shimmedLocalStreams[e.id]=[e].concat(i)};var r=e.RTCPeerConnection.prototype.removeStream;e.RTCPeerConnection.prototype.removeStream=function(e){return this._shimmedLocalStreams=this._shimmedLocalStreams||{},delete this._shimmedLocalStreams[e.id],r.apply(this,arguments)};var i=e.RTCPeerConnection.prototype.removeTrack;e.RTCPeerConnection.prototype.removeTrack=function(e){var t=this;return this._shimmedLocalStreams=this._shimmedLocalStreams||{},e&&Object.keys(this._shimmedLocalStreams).forEach(function(n){var r=t._shimmedLocalStreams[n].indexOf(e);-1!==r&&t._shimmedLocalStreams[n].splice(r,1),1===t._shimmedLocalStreams[n].length&&delete t._shimmedLocalStreams[n]}),i.apply(this,arguments)}},shimAddTrackRemoveTrack:function(e){var t=r.detectBrowser(e);if(e.RTCPeerConnection.prototype.addTrack&&t.version>=65)return this.shimAddTrackRemoveTrackWithNative(e);var n=e.RTCPeerConnection.prototype.getLocalStreams;e.RTCPeerConnection.prototype.getLocalStreams=function(){var e=this,t=n.apply(this);return e._reverseStreams=e._reverseStreams||{},t.map(function(t){return e._reverseStreams[t.id]})};var i=e.RTCPeerConnection.prototype.addStream;e.RTCPeerConnection.prototype.addStream=function(t){var n=this;if(n._streams=n._streams||{},n._reverseStreams=n._reverseStreams||{},t.getTracks().forEach(function(e){if(n.getSenders().find(function(t){return t.track===e}))throw new DOMException("Track already exists.","InvalidAccessError")}),!n._reverseStreams[t.id]){var r=new e.MediaStream(t.getTracks());n._streams[t.id]=r,n._reverseStreams[r.id]=t,t=r}i.apply(n,[t])};var s=e.RTCPeerConnection.prototype.removeStream;function a(e,t){var n=t.sdp;return Object.keys(e._reverseStreams||[]).forEach(function(t){var r=e._reverseStreams[t],i=e._streams[r.id];n=n.replace(new RegExp(i.id,"g"),r.id)}),new RTCSessionDescription({type:t.type,sdp:n})}e.RTCPeerConnection.prototype.removeStream=function(e){var t=this;t._streams=t._streams||{},t._reverseStreams=t._reverseStreams||{},s.apply(t,[t._streams[e.id]||e]),delete t._reverseStreams[t._streams[e.id]?t._streams[e.id].id:e.id],delete t._streams[e.id]},e.RTCPeerConnection.prototype.addTrack=function(t,n){var r=this;if("closed"===r.signalingState)throw new DOMException("The RTCPeerConnection's signalingState is 'closed'.","InvalidStateError");var i=[].slice.call(arguments,1);if(1!==i.length||!i[0].getTracks().find(function(e){return e===t}))throw new DOMException("The adapter.js addTrack polyfill only supports a single stream which is associated with the specified track.","NotSupportedError");if(r.getSenders().find(function(e){return e.track===t}))throw new DOMException("Track already exists.","InvalidAccessError");r._streams=r._streams||{},r._reverseStreams=r._reverseStreams||{};var s=r._streams[n.id];if(s)s.addTrack(t),Promise.resolve().then(function(){r.dispatchEvent(new Event("negotiationneeded"))});else{var a=new e.MediaStream([t]);r._streams[n.id]=a,r._reverseStreams[a.id]=n,r.addStream(a)}return r.getSenders().find(function(e){return e.track===t})},["createOffer","createAnswer"].forEach(function(t){var n=e.RTCPeerConnection.prototype[t];e.RTCPeerConnection.prototype[t]=function(){var e=this,t=arguments;return arguments.length&&"function"==typeof arguments[0]?n.apply(e,[function(n){var r=a(e,n);t[0].apply(null,[r])},function(e){t[1]&&t[1].apply(null,e)},arguments[2]]):n.apply(e,arguments).then(function(t){return a(e,t)})}});var o=e.RTCPeerConnection.prototype.setLocalDescription;e.RTCPeerConnection.prototype.setLocalDescription=function(){return arguments.length&&arguments[0].type?(arguments[0]=function(e,t){var n=t.sdp;return Object.keys(e._reverseStreams||[]).forEach(function(t){var r=e._reverseStreams[t],i=e._streams[r.id];n=n.replace(new RegExp(r.id,"g"),i.id)}),new RTCSessionDescription({type:t.type,sdp:n})}(this,arguments[0]),o.apply(this,arguments)):o.apply(this,arguments)};var l=Object.getOwnPropertyDescriptor(e.RTCPeerConnection.prototype,"localDescription");Object.defineProperty(e.RTCPeerConnection.prototype,"localDescription",{get:function(){var e=l.get.apply(this);return""===e.type?e:a(this,e)}}),e.RTCPeerConnection.prototype.removeTrack=function(e){var t,n=this;if("closed"===n.signalingState)throw new DOMException("The RTCPeerConnection's signalingState is 'closed'.","InvalidStateError");if(!e._pc)throw new DOMException("Argument 1 of RTCPeerConnection.removeTrack does not implement interface RTCRtpSender.","TypeError");if(!(e._pc===n))throw new DOMException("Sender was not created by this connection.","InvalidAccessError");n._streams=n._streams||{},Object.keys(n._streams).forEach(function(r){n._streams[r].getTracks().find(function(t){return e.track===t})&&(t=n._streams[r])}),t&&(1===t.getTracks().length?n.removeStream(n._reverseStreams[t.id]):t.removeTrack(e.track),n.dispatchEvent(new Event("negotiationneeded")))}},shimPeerConnection:function(e){var t=r.detectBrowser(e);if(!e.RTCPeerConnection&&e.webkitRTCPeerConnection)e.RTCPeerConnection=function(t,n){return i("PeerConnection"),t&&t.iceTransportPolicy&&(t.iceTransports=t.iceTransportPolicy),new e.webkitRTCPeerConnection(t,n)},e.RTCPeerConnection.prototype=e.webkitRTCPeerConnection.prototype,e.webkitRTCPeerConnection.generateCertificate&&Object.defineProperty(e.RTCPeerConnection,"generateCertificate",{get:function(){return e.webkitRTCPeerConnection.generateCertificate}});else{var n=e.RTCPeerConnection;e.RTCPeerConnection=function(e,t){if(e&&e.iceServers){for(var i=[],s=0;s<e.iceServers.length;s++){var a=e.iceServers[s];!a.hasOwnProperty("urls")&&a.hasOwnProperty("url")?(r.deprecated("RTCIceServer.url","RTCIceServer.urls"),(a=JSON.parse(JSON.stringify(a))).urls=a.url,i.push(a)):i.push(e.iceServers[s])}e.iceServers=i}return new n(e,t)},e.RTCPeerConnection.prototype=n.prototype,Object.defineProperty(e.RTCPeerConnection,"generateCertificate",{get:function(){return n.generateCertificate}})}var s=e.RTCPeerConnection.prototype.getStats;e.RTCPeerConnection.prototype.getStats=function(e,t,n){var r=this,i=arguments;if(arguments.length>0&&"function"==typeof e)return s.apply(this,arguments);if(0===s.length&&(0===arguments.length||"function"!=typeof arguments[0]))return s.apply(this,[]);var a=function(e){var t={};return e.result().forEach(function(e){var n={id:e.id,timestamp:e.timestamp,type:{localcandidate:"local-candidate",remotecandidate:"remote-candidate"}[e.type]||e.type};e.names().forEach(function(t){n[t]=e.stat(t)}),t[n.id]=n}),t},o=function(e){return new Map(Object.keys(e).map(function(t){return[t,e[t]]}))};if(arguments.length>=2){return s.apply(this,[function(e){i[1](o(a(e)))},arguments[0]])}return new Promise(function(e,t){s.apply(r,[function(t){e(o(a(t)))},t])}).then(t,n)},t.version<51&&["setLocalDescription","setRemoteDescription","addIceCandidate"].forEach(function(t){var n=e.RTCPeerConnection.prototype[t];e.RTCPeerConnection.prototype[t]=function(){var e=arguments,t=this,r=new Promise(function(r,i){n.apply(t,[e[0],r,i])});return e.length<2?r:r.then(function(){e[1].apply(null,[])},function(t){e.length>=3&&e[2].apply(null,[t])})}}),t.version<52&&["createOffer","createAnswer"].forEach(function(t){var n=e.RTCPeerConnection.prototype[t];e.RTCPeerConnection.prototype[t]=function(){var e=this;if(arguments.length<1||1===arguments.length&&"object"==typeof arguments[0]){var t=1===arguments.length?arguments[0]:void 0;return new Promise(function(r,i){n.apply(e,[r,i,t])})}return n.apply(this,arguments)}}),["setLocalDescription","setRemoteDescription","addIceCandidate"].forEach(function(t){var n=e.RTCPeerConnection.prototype[t];e.RTCPeerConnection.prototype[t]=function(){return arguments[0]=new("addIceCandidate"===t?e.RTCIceCandidate:e.RTCSessionDescription)(arguments[0]),n.apply(this,arguments)}});var a=e.RTCPeerConnection.prototype.addIceCandidate;e.RTCPeerConnection.prototype.addIceCandidate=function(){return arguments[0]?a.apply(this,arguments):(arguments[1]&&arguments[1].apply(null),Promise.resolve())}},fixNegotiationNeeded:function(e){r.wrapPeerConnectionEvent(e,"negotiationneeded",function(e){if("stable"===e.target.signalingState)return e})},shimGetDisplayMedia:function(e,t){"getDisplayMedia"in e.navigator||("function"==typeof t?navigator.getDisplayMedia=function(e){return t(e).then(function(t){return e.video={mandatory:{chromeMediaSource:"desktop",chromeMediaSourceId:t,maxFrameRate:e.video.frameRate||3}},navigator.mediaDevices.getUserMedia(e)})}:console.error("shimGetDisplayMedia: getSourceId argument is not a function"))}}},{"../utils.js":53,"./getusermedia":45}],45:[function(e,t,n){"use strict";var r=e("../utils.js"),i=r.log;t.exports=function(e){var t=r.detectBrowser(e),n=e&&e.navigator,s=function(e){if("object"!=typeof e||e.mandatory||e.optional)return e;var t={};return Object.keys(e).forEach(function(n){if("require"!==n&&"advanced"!==n&&"mediaSource"!==n){var r="object"==typeof e[n]?e[n]:{ideal:e[n]};void 0!==r.exact&&"number"==typeof r.exact&&(r.min=r.max=r.exact);var i=function(e,t){return e?e+t.charAt(0).toUpperCase()+t.slice(1):"deviceId"===t?"sourceId":t};if(void 0!==r.ideal){t.optional=t.optional||[];var s={};"number"==typeof r.ideal?(s[i("min",n)]=r.ideal,t.optional.push(s),(s={})[i("max",n)]=r.ideal,t.optional.push(s)):(s[i("",n)]=r.ideal,t.optional.push(s))}void 0!==r.exact&&"number"!=typeof r.exact?(t.mandatory=t.mandatory||{},t.mandatory[i("",n)]=r.exact):["min","max"].forEach(function(e){void 0!==r[e]&&(t.mandatory=t.mandatory||{},t.mandatory[i(e,n)]=r[e])})}}),e.advanced&&(t.optional=(t.optional||[]).concat(e.advanced)),t},a=function(e,r){if(t.version>=61)return r(e);if((e=JSON.parse(JSON.stringify(e)))&&"object"==typeof e.audio){var a=function(e,t,n){t in e&&!(n in e)&&(e[n]=e[t],delete e[t])};a((e=JSON.parse(JSON.stringify(e))).audio,"autoGainControl","googAutoGainControl"),a(e.audio,"noiseSuppression","googNoiseSuppression"),e.audio=s(e.audio)}if(e&&"object"==typeof e.video){var o=e.video.facingMode;o=o&&("object"==typeof o?o:{ideal:o});var l,u=t.version<66;if(o&&("user"===o.exact||"environment"===o.exact||"user"===o.ideal||"environment"===o.ideal)&&(!n.mediaDevices.getSupportedConstraints||!n.mediaDevices.getSupportedConstraints().facingMode||u))if(delete e.video.facingMode,"environment"===o.exact||"environment"===o.ideal?l=["back","rear"]:"user"!==o.exact&&"user"!==o.ideal||(l=["front"]),l)return n.mediaDevices.enumerateDevices().then(function(t){var n=(t=t.filter(function(e){return"videoinput"===e.kind})).find(function(e){return l.some(function(t){return-1!==e.label.toLowerCase().indexOf(t)})});return!n&&t.length&&-1!==l.indexOf("back")&&(n=t[t.length-1]),n&&(e.video.deviceId=o.exact?{exact:n.deviceId}:{ideal:n.deviceId}),e.video=s(e.video),i("chrome: "+JSON.stringify(e)),r(e)});e.video=s(e.video)}return i("chrome: "+JSON.stringify(e)),r(e)},o=function(e){return t.version>=64?e:{name:{PermissionDeniedError:"NotAllowedError",PermissionDismissedError:"NotAllowedError",InvalidStateError:"NotAllowedError",DevicesNotFoundError:"NotFoundError",ConstraintNotSatisfiedError:"OverconstrainedError",TrackStartError:"NotReadableError",MediaDeviceFailedDueToShutdown:"NotAllowedError",MediaDeviceKillSwitchOn:"NotAllowedError",TabCaptureError:"AbortError",ScreenCaptureError:"AbortError",DeviceCaptureError:"AbortError"}[e.name]||e.name,message:e.message,constraint:e.constraint||e.constraintName,toString:function(){return this.name+(this.message&&": ")+this.message}}};n.getUserMedia=function(e,t,r){a(e,function(e){n.webkitGetUserMedia(e,t,function(e){r&&r(o(e))})})};var l=function(e){return new Promise(function(t,r){n.getUserMedia(e,t,r)})};if(n.mediaDevices||(n.mediaDevices={getUserMedia:l,enumerateDevices:function(){return new Promise(function(t){var n={audio:"audioinput",video:"videoinput"};return e.MediaStreamTrack.getSources(function(e){t(e.map(function(e){return{label:e.label,kind:n[e.kind],deviceId:e.id,groupId:""}}))})})},getSupportedConstraints:function(){return{deviceId:!0,echoCancellation:!0,facingMode:!0,frameRate:!0,height:!0,width:!0}}}),n.mediaDevices.getUserMedia){var u=n.mediaDevices.getUserMedia.bind(n.mediaDevices);n.mediaDevices.getUserMedia=function(e){return a(e,function(e){return u(e).then(function(t){if(e.audio&&!t.getAudioTracks().length||e.video&&!t.getVideoTracks().length)throw t.getTracks().forEach(function(e){e.stop()}),new DOMException("","NotFoundError");return t},function(e){return Promise.reject(o(e))})})}}else n.mediaDevices.getUserMedia=function(e){return l(e)};void 0===n.mediaDevices.addEventListener&&(n.mediaDevices.addEventListener=function(){i("Dummy mediaDevices.addEventListener called.")}),void 0===n.mediaDevices.removeEventListener&&(n.mediaDevices.removeEventListener=function(){i("Dummy mediaDevices.removeEventListener called.")})}},{"../utils.js":53}],46:[function(e,t,n){"use strict";var r=e("sdp"),i=e("./utils");t.exports={shimRTCIceCandidate:function(e){if(e.RTCIceCandidate&&!(e.RTCIceCandidate&&"foundation"in e.RTCIceCandidate.prototype)){var t=e.RTCIceCandidate;e.RTCIceCandidate=function(e){if("object"==typeof e&&e.candidate&&0===e.candidate.indexOf("a=")&&((e=JSON.parse(JSON.stringify(e))).candidate=e.candidate.substr(2)),e.candidate&&e.candidate.length){var n=new t(e),i=r.parseCandidate(e.candidate),s=Object.assign(n,i);return s.toJSON=function(){return{candidate:s.candidate,sdpMid:s.sdpMid,sdpMLineIndex:s.sdpMLineIndex,usernameFragment:s.usernameFragment}},s}return new t(e)},e.RTCIceCandidate.prototype=t.prototype,i.wrapPeerConnectionEvent(e,"icecandidate",function(t){return t.candidate&&Object.defineProperty(t,"candidate",{value:new e.RTCIceCandidate(t.candidate),writable:"false"}),t})}},shimCreateObjectURL:function(e){var t=e&&e.URL;if("object"==typeof e&&e.HTMLMediaElement&&"srcObject"in e.HTMLMediaElement.prototype&&t.createObjectURL&&t.revokeObjectURL){var n=t.createObjectURL.bind(t),r=t.revokeObjectURL.bind(t),s=new Map,a=0;t.createObjectURL=function(e){if("getTracks"in e){var t="polyblob:"+ ++a;return s.set(t,e),i.deprecated("URL.createObjectURL(stream)","elem.srcObject = stream"),t}return n(e)},t.revokeObjectURL=function(e){r(e),s.delete(e)};var o=Object.getOwnPropertyDescriptor(e.HTMLMediaElement.prototype,"src");Object.defineProperty(e.HTMLMediaElement.prototype,"src",{get:function(){return o.get.apply(this)},set:function(e){return this.srcObject=s.get(e)||null,o.set.apply(this,[e])}});var l=e.HTMLMediaElement.prototype.setAttribute;e.HTMLMediaElement.prototype.setAttribute=function(){return 2===arguments.length&&"src"===(""+arguments[0]).toLowerCase()&&(this.srcObject=s.get(arguments[1])||null),l.apply(this,arguments)}}},shimMaxMessageSize:function(e){if(!e.RTCSctpTransport&&e.RTCPeerConnection){var t=i.detectBrowser(e);"sctp"in e.RTCPeerConnection.prototype||Object.defineProperty(e.RTCPeerConnection.prototype,"sctp",{get:function(){return void 0===this._sctp?null:this._sctp}});var n=e.RTCPeerConnection.prototype.setRemoteDescription;e.RTCPeerConnection.prototype.setRemoteDescription=function(){var e,i,s,a;if(this._sctp=null,s=arguments[0],(a=r.splitSections(s.sdp)).shift(),a.some(function(e){var t=r.parseMLine(e);return t&&"application"===t.kind&&-1!==t.protocol.indexOf("SCTP")})){var o,l=function(e){var t=e.sdp.match(/mozilla...THIS_IS_SDPARTA-(\d+)/);if(null===t||t.length<2)return-1;var n=parseInt(t[1],10);return n!=n?-1:n}(arguments[0]),u=(e=l,i=65536,"firefox"===t.browser&&(i=t.version<57?-1===e?16384:2147483637:t.version<60?57===t.version?65535:65536:2147483637),i),c=function(e,n){var i=65536;"firefox"===t.browser&&57===t.version&&(i=65535);var s=r.matchPrefix(e.sdp,"a=max-message-size:");return s.length>0?i=parseInt(s[0].substr(19),10):"firefox"===t.browser&&-1!==n&&(i=2147483637),i}(arguments[0],l);o=0===u&&0===c?Number.POSITIVE_INFINITY:0===u||0===c?Math.max(u,c):Math.min(u,c);var d={};Object.defineProperty(d,"maxMessageSize",{get:function(){return o}}),this._sctp=d}return n.apply(this,arguments)}}},shimSendThrowTypeError:function(e){if(e.RTCPeerConnection&&"createDataChannel"in e.RTCPeerConnection.prototype){var t=e.RTCPeerConnection.prototype.createDataChannel;e.RTCPeerConnection.prototype.createDataChannel=function(){var e=t.apply(this,arguments);return n(e,this),e},i.wrapPeerConnectionEvent(e,"datachannel",function(e){return n(e.channel,e.target),e})}function n(e,t){var n=e.send;e.send=function(){var r=arguments[0],i=r.length||r.size||r.byteLength;if("open"===e.readyState&&t.sctp&&i>t.sctp.maxMessageSize)throw new TypeError("Message too large (can send a maximum of "+t.sctp.maxMessageSize+" bytes)");return n.apply(e,arguments)}}}}},{"./utils":53,sdp:40}],47:[function(e,t,n){"use strict";var r=e("../utils"),i=e("./filtericeservers"),s=e("rtcpeerconnection-shim");t.exports={shimGetUserMedia:e("./getusermedia"),shimPeerConnection:function(e){var t=r.detectBrowser(e);if(e.RTCIceGatherer&&(e.RTCIceCandidate||(e.RTCIceCandidate=function(e){return e}),e.RTCSessionDescription||(e.RTCSessionDescription=function(e){return e}),t.version<15025)){var n=Object.getOwnPropertyDescriptor(e.MediaStreamTrack.prototype,"enabled");Object.defineProperty(e.MediaStreamTrack.prototype,"enabled",{set:function(e){n.set.call(this,e);var t=new Event("enabled");t.enabled=e,this.dispatchEvent(t)}})}!e.RTCRtpSender||"dtmf"in e.RTCRtpSender.prototype||Object.defineProperty(e.RTCRtpSender.prototype,"dtmf",{get:function(){return void 0===this._dtmf&&("audio"===this.track.kind?this._dtmf=new e.RTCDtmfSender(this):"video"===this.track.kind&&(this._dtmf=null)),this._dtmf}}),e.RTCDtmfSender&&!e.RTCDTMFSender&&(e.RTCDTMFSender=e.RTCDtmfSender);var a=s(e,t.version);e.RTCPeerConnection=function(e){return e&&e.iceServers&&(e.iceServers=i(e.iceServers)),new a(e)},e.RTCPeerConnection.prototype=a.prototype},shimReplaceTrack:function(e){!e.RTCRtpSender||"replaceTrack"in e.RTCRtpSender.prototype||(e.RTCRtpSender.prototype.replaceTrack=e.RTCRtpSender.prototype.setTrack)}}},{"../utils":53,"./filtericeservers":48,"./getusermedia":49,"rtcpeerconnection-shim":35}],48:[function(e,t,n){"use strict";var r=e("../utils");t.exports=function(e,t){var n=!1;return(e=JSON.parse(JSON.stringify(e))).filter(function(e){if(e&&(e.urls||e.url)){var i=e.urls||e.url;e.url&&!e.urls&&r.deprecated("RTCIceServer.url","RTCIceServer.urls");var s="string"==typeof i;return s&&(i=[i]),i=i.filter(function(e){return 0===e.indexOf("turn:")&&-1!==e.indexOf("transport=udp")&&-1===e.indexOf("turn:[")&&!n?(n=!0,!0):0===e.indexOf("stun:")&&t>=14393&&-1===e.indexOf("?transport=udp")}),delete e.url,e.urls=s?i[0]:i,!!i.length}})}},{"../utils":53}],49:[function(e,t,n){"use strict";t.exports=function(e){var t=e&&e.navigator,n=t.mediaDevices.getUserMedia.bind(t.mediaDevices);t.mediaDevices.getUserMedia=function(e){return n(e).catch(function(e){return Promise.reject(function(e){return{name:{PermissionDeniedError:"NotAllowedError"}[e.name]||e.name,message:e.message,constraint:e.constraint,toString:function(){return this.name}}}(e))})}}},{}],50:[function(e,t,n){"use strict";var r=e("../utils");t.exports={shimGetUserMedia:e("./getusermedia"),shimOnTrack:function(e){"object"!=typeof e||!e.RTCPeerConnection||"ontrack"in e.RTCPeerConnection.prototype||Object.defineProperty(e.RTCPeerConnection.prototype,"ontrack",{get:function(){return this._ontrack},set:function(e){this._ontrack&&(this.removeEventListener("track",this._ontrack),this.removeEventListener("addstream",this._ontrackpoly)),this.addEventListener("track",this._ontrack=e),this.addEventListener("addstream",this._ontrackpoly=function(e){e.stream.getTracks().forEach(function(t){var n=new Event("track");n.track=t,n.receiver={track:t},n.transceiver={receiver:n.receiver},n.streams=[e.stream],this.dispatchEvent(n)}.bind(this))}.bind(this))},enumerable:!0,configurable:!0}),"object"==typeof e&&e.RTCTrackEvent&&"receiver"in e.RTCTrackEvent.prototype&&!("transceiver"in e.RTCTrackEvent.prototype)&&Object.defineProperty(e.RTCTrackEvent.prototype,"transceiver",{get:function(){return{receiver:this.receiver}}})},shimSourceObject:function(e){"object"==typeof e&&(!e.HTMLMediaElement||"srcObject"in e.HTMLMediaElement.prototype||Object.defineProperty(e.HTMLMediaElement.prototype,"srcObject",{get:function(){return this.mozSrcObject},set:function(e){this.mozSrcObject=e}}))},shimPeerConnection:function(e){var t=r.detectBrowser(e);if("object"==typeof e&&(e.RTCPeerConnection||e.mozRTCPeerConnection)){e.RTCPeerConnection||(e.RTCPeerConnection=function(n,r){if(t.version<38&&n&&n.iceServers){for(var i=[],s=0;s<n.iceServers.length;s++){var a=n.iceServers[s];if(a.hasOwnProperty("urls"))for(var o=0;o<a.urls.length;o++){var l={url:a.urls[o]};0===a.urls[o].indexOf("turn")&&(l.username=a.username,l.credential=a.credential),i.push(l)}else i.push(n.iceServers[s])}n.iceServers=i}return new e.mozRTCPeerConnection(n,r)},e.RTCPeerConnection.prototype=e.mozRTCPeerConnection.prototype,e.mozRTCPeerConnection.generateCertificate&&Object.defineProperty(e.RTCPeerConnection,"generateCertificate",{get:function(){return e.mozRTCPeerConnection.generateCertificate}}),e.RTCSessionDescription=e.mozRTCSessionDescription,e.RTCIceCandidate=e.mozRTCIceCandidate),["setLocalDescription","setRemoteDescription","addIceCandidate"].forEach(function(t){var n=e.RTCPeerConnection.prototype[t];e.RTCPeerConnection.prototype[t]=function(){return arguments[0]=new("addIceCandidate"===t?e.RTCIceCandidate:e.RTCSessionDescription)(arguments[0]),n.apply(this,arguments)}});var n=e.RTCPeerConnection.prototype.addIceCandidate;e.RTCPeerConnection.prototype.addIceCandidate=function(){return arguments[0]?n.apply(this,arguments):(arguments[1]&&arguments[1].apply(null),Promise.resolve())};var i={inboundrtp:"inbound-rtp",outboundrtp:"outbound-rtp",candidatepair:"candidate-pair",localcandidate:"local-candidate",remotecandidate:"remote-candidate"},s=e.RTCPeerConnection.prototype.getStats;e.RTCPeerConnection.prototype.getStats=function(e,n,r){return s.apply(this,[e||null]).then(function(e){if(t.version<48&&(e=function(e){var t=new Map;return Object.keys(e).forEach(function(n){t.set(n,e[n]),t[n]=e[n]}),t}(e)),t.version<53&&!n)try{e.forEach(function(e){e.type=i[e.type]||e.type})}catch(t){if("TypeError"!==t.name)throw t;e.forEach(function(t,n){e.set(n,Object.assign({},t,{type:i[t.type]||t.type}))})}return e}).then(n,r)}}},shimSenderGetStats:function(e){if("object"==typeof e&&e.RTCPeerConnection&&e.RTCRtpSender&&!(e.RTCRtpSender&&"getStats"in e.RTCRtpSender.prototype)){var t=e.RTCPeerConnection.prototype.getSenders;t&&(e.RTCPeerConnection.prototype.getSenders=function(){var e=this,n=t.apply(e,[]);return n.forEach(function(t){t._pc=e}),n});var n=e.RTCPeerConnection.prototype.addTrack;n&&(e.RTCPeerConnection.prototype.addTrack=function(){var e=n.apply(this,arguments);return e._pc=this,e}),e.RTCRtpSender.prototype.getStats=function(){return this.track?this._pc.getStats(this.track):Promise.resolve(new Map)}}},shimReceiverGetStats:function(e){if("object"==typeof e&&e.RTCPeerConnection&&e.RTCRtpSender&&!(e.RTCRtpSender&&"getStats"in e.RTCRtpReceiver.prototype)){var t=e.RTCPeerConnection.prototype.getReceivers;t&&(e.RTCPeerConnection.prototype.getReceivers=function(){var e=this,n=t.apply(e,[]);return n.forEach(function(t){t._pc=e}),n}),r.wrapPeerConnectionEvent(e,"track",function(e){return e.receiver._pc=e.srcElement,e}),e.RTCRtpReceiver.prototype.getStats=function(){return this._pc.getStats(this.track)}}},shimRemoveStream:function(e){!e.RTCPeerConnection||"removeStream"in e.RTCPeerConnection.prototype||(e.RTCPeerConnection.prototype.removeStream=function(e){var t=this;r.deprecated("removeStream","removeTrack"),this.getSenders().forEach(function(n){n.track&&-1!==e.getTracks().indexOf(n.track)&&t.removeTrack(n)})})},shimRTCDataChannel:function(e){e.DataChannel&&!e.RTCDataChannel&&(e.RTCDataChannel=e.DataChannel)},shimGetDisplayMedia:function(e,t){"getDisplayMedia"in e.navigator||(navigator.getDisplayMedia=function(e){if(!e||!e.video){var n=new DOMException("getDisplayMedia without video constraints is undefined");return n.name="NotFoundError",n.code=8,Promise.reject(n)}return!0===e.video?e.video={mediaSource:t}:e.video.mediaSource=t,navigator.mediaDevices.getUserMedia(e)})}}},{"../utils":53,"./getusermedia":51}],51:[function(e,t,n){"use strict";var r=e("../utils"),i=r.log;t.exports=function(e){var t=r.detectBrowser(e),n=e&&e.navigator,s=e&&e.MediaStreamTrack,a=function(e){return{name:{InternalError:"NotReadableError",NotSupportedError:"TypeError",PermissionDeniedError:"NotAllowedError",SecurityError:"NotAllowedError"}[e.name]||e.name,message:{"The operation is insecure.":"The request is not allowed by the user agent or the platform in the current context."}[e.message]||e.message,constraint:e.constraint,toString:function(){return this.name+(this.message&&": ")+this.message}}},o=function(e,r,s){var o=function(e){if("object"!=typeof e||e.require)return e;var t=[];return Object.keys(e).forEach(function(n){if("require"!==n&&"advanced"!==n&&"mediaSource"!==n){var r=e[n]="object"==typeof e[n]?e[n]:{ideal:e[n]};if(void 0===r.min&&void 0===r.max&&void 0===r.exact||t.push(n),void 0!==r.exact&&("number"==typeof r.exact?r.min=r.max=r.exact:e[n]=r.exact,delete r.exact),void 0!==r.ideal){e.advanced=e.advanced||[];var i={};"number"==typeof r.ideal?i[n]={min:r.ideal,max:r.ideal}:i[n]=r.ideal,e.advanced.push(i),delete r.ideal,Object.keys(r).length||delete e[n]}}}),t.length&&(e.require=t),e};return e=JSON.parse(JSON.stringify(e)),t.version<38&&(i("spec: "+JSON.stringify(e)),e.audio&&(e.audio=o(e.audio)),e.video&&(e.video=o(e.video)),i("ff37: "+JSON.stringify(e))),n.mozGetUserMedia(e,r,function(e){s(a(e))})};if(n.mediaDevices||(n.mediaDevices={getUserMedia:function(e){return new Promise(function(t,n){o(e,t,n)})},addEventListener:function(){},removeEventListener:function(){}}),n.mediaDevices.enumerateDevices=n.mediaDevices.enumerateDevices||function(){return new Promise(function(e){e([{kind:"audioinput",deviceId:"default",label:"",groupId:""},{kind:"videoinput",deviceId:"default",label:"",groupId:""}])})},t.version<41){var l=n.mediaDevices.enumerateDevices.bind(n.mediaDevices);n.mediaDevices.enumerateDevices=function(){return l().then(void 0,function(e){if("NotFoundError"===e.name)return[];throw e})}}if(t.version<49){var u=n.mediaDevices.getUserMedia.bind(n.mediaDevices);n.mediaDevices.getUserMedia=function(e){return u(e).then(function(t){if(e.audio&&!t.getAudioTracks().length||e.video&&!t.getVideoTracks().length)throw t.getTracks().forEach(function(e){e.stop()}),new DOMException("The object can not be found here.","NotFoundError");return t},function(e){return Promise.reject(a(e))})}}if(!(t.version>55&&"autoGainControl"in n.mediaDevices.getSupportedConstraints())){var c=function(e,t,n){t in e&&!(n in e)&&(e[n]=e[t],delete e[t])},d=n.mediaDevices.getUserMedia.bind(n.mediaDevices);if(n.mediaDevices.getUserMedia=function(e){return"object"==typeof e&&"object"==typeof e.audio&&(e=JSON.parse(JSON.stringify(e)),c(e.audio,"autoGainControl","mozAutoGainControl"),c(e.audio,"noiseSuppression","mozNoiseSuppression")),d(e)},s&&s.prototype.getSettings){var h=s.prototype.getSettings;s.prototype.getSettings=function(){var e=h.apply(this,arguments);return c(e,"mozAutoGainControl","autoGainControl"),c(e,"mozNoiseSuppression","noiseSuppression"),e}}if(s&&s.prototype.applyConstraints){var p=s.prototype.applyConstraints;s.prototype.applyConstraints=function(e){return"audio"===this.kind&&"object"==typeof e&&(e=JSON.parse(JSON.stringify(e)),c(e,"autoGainControl","mozAutoGainControl"),c(e,"noiseSuppression","mozNoiseSuppression")),p.apply(this,[e])}}}n.getUserMedia=function(e,i,s){if(t.version<44)return o(e,i,s);r.deprecated("navigator.getUserMedia","navigator.mediaDevices.getUserMedia"),n.mediaDevices.getUserMedia(e).then(i,s)}}},{"../utils":53}],52:[function(e,t,n){"use strict";var r=e("../utils");t.exports={shimLocalStreamsAPI:function(e){if("object"==typeof e&&e.RTCPeerConnection){if("getLocalStreams"in e.RTCPeerConnection.prototype||(e.RTCPeerConnection.prototype.getLocalStreams=function(){return this._localStreams||(this._localStreams=[]),this._localStreams}),"getStreamById"in e.RTCPeerConnection.prototype||(e.RTCPeerConnection.prototype.getStreamById=function(e){var t=null;return this._localStreams&&this._localStreams.forEach(function(n){n.id===e&&(t=n)}),this._remoteStreams&&this._remoteStreams.forEach(function(n){n.id===e&&(t=n)}),t}),!("addStream"in e.RTCPeerConnection.prototype)){var t=e.RTCPeerConnection.prototype.addTrack;e.RTCPeerConnection.prototype.addStream=function(e){this._localStreams||(this._localStreams=[]),-1===this._localStreams.indexOf(e)&&this._localStreams.push(e);var n=this;e.getTracks().forEach(function(r){t.call(n,r,e)})},e.RTCPeerConnection.prototype.addTrack=function(e,n){return n&&(this._localStreams?-1===this._localStreams.indexOf(n)&&this._localStreams.push(n):this._localStreams=[n]),t.call(this,e,n)}}"removeStream"in e.RTCPeerConnection.prototype||(e.RTCPeerConnection.prototype.removeStream=function(e){this._localStreams||(this._localStreams=[]);var t=this._localStreams.indexOf(e);if(-1!==t){this._localStreams.splice(t,1);var n=this,r=e.getTracks();this.getSenders().forEach(function(e){-1!==r.indexOf(e.track)&&n.removeTrack(e)})}})}},shimRemoteStreamsAPI:function(e){if("object"==typeof e&&e.RTCPeerConnection&&("getRemoteStreams"in e.RTCPeerConnection.prototype||(e.RTCPeerConnection.prototype.getRemoteStreams=function(){return this._remoteStreams?this._remoteStreams:[]}),!("onaddstream"in e.RTCPeerConnection.prototype))){Object.defineProperty(e.RTCPeerConnection.prototype,"onaddstream",{get:function(){return this._onaddstream},set:function(e){this._onaddstream&&this.removeEventListener("addstream",this._onaddstream),this.addEventListener("addstream",this._onaddstream=e)}});var t=e.RTCPeerConnection.prototype.setRemoteDescription;e.RTCPeerConnection.prototype.setRemoteDescription=function(){var e=this;return this._onaddstreampoly||this.addEventListener("track",this._onaddstreampoly=function(t){t.streams.forEach(function(t){if(e._remoteStreams||(e._remoteStreams=[]),!(e._remoteStreams.indexOf(t)>=0)){e._remoteStreams.push(t);var n=new Event("addstream");n.stream=t,e.dispatchEvent(n)}})}),t.apply(e,arguments)}}},shimCallbacksAPI:function(e){if("object"==typeof e&&e.RTCPeerConnection){var t=e.RTCPeerConnection.prototype,n=t.createOffer,r=t.createAnswer,i=t.setLocalDescription,s=t.setRemoteDescription,a=t.addIceCandidate;t.createOffer=function(e,t){var r=arguments.length>=2?arguments[2]:arguments[0],i=n.apply(this,[r]);return t?(i.then(e,t),Promise.resolve()):i},t.createAnswer=function(e,t){var n=arguments.length>=2?arguments[2]:arguments[0],i=r.apply(this,[n]);return t?(i.then(e,t),Promise.resolve()):i};var o=function(e,t,n){var r=i.apply(this,[e]);return n?(r.then(t,n),Promise.resolve()):r};t.setLocalDescription=o,o=function(e,t,n){var r=s.apply(this,[e]);return n?(r.then(t,n),Promise.resolve()):r},t.setRemoteDescription=o,o=function(e,t,n){var r=a.apply(this,[e]);return n?(r.then(t,n),Promise.resolve()):r},t.addIceCandidate=o}},shimGetUserMedia:function(e){var t=e&&e.navigator;t.getUserMedia||(t.webkitGetUserMedia?t.getUserMedia=t.webkitGetUserMedia.bind(t):t.mediaDevices&&t.mediaDevices.getUserMedia&&(t.getUserMedia=function(e,n,r){t.mediaDevices.getUserMedia(e).then(n,r)}.bind(t)))},shimRTCIceServerUrls:function(e){var t=e.RTCPeerConnection;e.RTCPeerConnection=function(e,n){if(e&&e.iceServers){for(var i=[],s=0;s<e.iceServers.length;s++){var a=e.iceServers[s];!a.hasOwnProperty("urls")&&a.hasOwnProperty("url")?(r.deprecated("RTCIceServer.url","RTCIceServer.urls"),(a=JSON.parse(JSON.stringify(a))).urls=a.url,delete a.url,i.push(a)):i.push(e.iceServers[s])}e.iceServers=i}return new t(e,n)},e.RTCPeerConnection.prototype=t.prototype,"generateCertificate"in e.RTCPeerConnection&&Object.defineProperty(e.RTCPeerConnection,"generateCertificate",{get:function(){return t.generateCertificate}})},shimTrackEventTransceiver:function(e){"object"==typeof e&&e.RTCPeerConnection&&"receiver"in e.RTCTrackEvent.prototype&&!e.RTCTransceiver&&Object.defineProperty(e.RTCTrackEvent.prototype,"transceiver",{get:function(){return{receiver:this.receiver}}})},shimCreateOfferLegacy:function(e){var t=e.RTCPeerConnection.prototype.createOffer;e.RTCPeerConnection.prototype.createOffer=function(e){var n=this;if(e){void 0!==e.offerToReceiveAudio&&(e.offerToReceiveAudio=!!e.offerToReceiveAudio);var r=n.getTransceivers().find(function(e){return e.sender.track&&"audio"===e.sender.track.kind});!1===e.offerToReceiveAudio&&r?"sendrecv"===r.direction?r.setDirection?r.setDirection("sendonly"):r.direction="sendonly":"recvonly"===r.direction&&(r.setDirection?r.setDirection("inactive"):r.direction="inactive"):!0!==e.offerToReceiveAudio||r||n.addTransceiver("audio"),void 0!==e.offerToReceiveVideo&&(e.offerToReceiveVideo=!!e.offerToReceiveVideo);var i=n.getTransceivers().find(function(e){return e.sender.track&&"video"===e.sender.track.kind});!1===e.offerToReceiveVideo&&i?"sendrecv"===i.direction?i.setDirection("sendonly"):"recvonly"===i.direction&&i.setDirection("inactive"):!0!==e.offerToReceiveVideo||i||n.addTransceiver("video")}return t.apply(n,arguments)}}}},{"../utils":53}],53:[function(e,t,n){"use strict";var r=!0,i=!0;function s(e,t,n){var r=e.match(t);return r&&r.length>=n&&parseInt(r[n],10)}t.exports={extractVersion:s,wrapPeerConnectionEvent:function(e,t,n){if(e.RTCPeerConnection){var r=e.RTCPeerConnection.prototype,i=r.addEventListener;r.addEventListener=function(e,r){if(e!==t)return i.apply(this,arguments);var s=function(e){var t=n(e);t&&r(t)};return this._eventMap=this._eventMap||{},this._eventMap[r]=s,i.apply(this,[e,s])};var s=r.removeEventListener;r.removeEventListener=function(e,n){if(e!==t||!this._eventMap||!this._eventMap[n])return s.apply(this,arguments);var r=this._eventMap[n];return delete this._eventMap[n],s.apply(this,[e,r])},Object.defineProperty(r,"on"+t,{get:function(){return this["_on"+t]},set:function(e){this["_on"+t]&&(this.removeEventListener(t,this["_on"+t]),delete this["_on"+t]),e&&this.addEventListener(t,this["_on"+t]=e)},enumerable:!0,configurable:!0})}},disableLog:function(e){return"boolean"!=typeof e?new Error("Argument type: "+typeof e+". Please use a boolean."):(r=e,e?"adapter.js logging disabled":"adapter.js logging enabled")},disableWarnings:function(e){return"boolean"!=typeof e?new Error("Argument type: "+typeof e+". Please use a boolean."):(i=!e,"adapter.js deprecation warnings "+(e?"disabled":"enabled"))},log:function(){if("object"==typeof window){if(r)return;"undefined"!=typeof console&&"function"==typeof console.log&&console.log.apply(console,arguments)}},deprecated:function(e,t){i&&console.warn(e+" is deprecated, please use "+t+" instead.")},detectBrowser:function(e){var t=e&&e.navigator,n={browser:null,version:null};if(void 0===e||!e.navigator)return n.browser="Not a browser.",n;if(t.mozGetUserMedia)n.browser="firefox",n.version=s(t.userAgent,/Firefox\/(\d+)\./,1);else if(t.webkitGetUserMedia)n.browser="chrome",n.version=s(t.userAgent,/Chrom(e|ium)\/(\d+)\./,2);else if(t.mediaDevices&&t.userAgent.match(/Edge\/(\d+).(\d+)$/))n.browser="edge",n.version=s(t.userAgent,/Edge\/(\d+).(\d+)$/,2);else{if(!e.RTCPeerConnection||!t.userAgent.match(/AppleWebKit\/(\d+)\./))return n.browser="Not a supported browser.",n;n.browser="safari",n.version=s(t.userAgent,/AppleWebKit\/(\d+)\./,1)}return n}}},{}],54:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var r,i=e("debug"),s=(r=i)&&r.__esModule?r:{default:r};const a="jssip-wrap";n.default=class{constructor(e){e?(this._debug=(0,s.default)(a+":"+e),this._warn=(0,s.default)(a+":WARN:"+e),this._error=(0,s.default)(a+":ERROR:"+e)):(this._debug=(0,s.default)(a),this._warn=(0,s.default)(a+":WARN"),this._error=(0,s.default)(a+":ERROR")),this._debug.log=console.info.bind(console),this._warn.log=console.warn.bind(console),this._error.log=console.error.bind(console)}get debug(){return this._debug}get warn(){return this._warn}get error(){return this._error}}},{debug:2}],55:[function(e,t,n){"use strict";var r=s(e("./Logger")),i=s(e("spark-md5"));function s(e){return e&&e.__esModule?e:{default:e}}const a=new r.default("getLoginInfo");function o(t){for(var n=e("./province.json"),r="",i=n.TestDistricts,s=n.CurDistricts,o=0;o<i.length;o++)if(i[o].switchNumbers&&-1!==i[o].switchNumbers.split(",").indexOf(t))return r=i[o].uniServer;for(o=0;o<s.length;o++){var l=s[o].areaCode.split(",");for(var u of l)if(t.startsWith(u))return r=s[o].uniServer,a.debug(`${t} 运维地址 ${r}`),r}a.warn(`failed to find 运维服务器:${t}`)}async function l(e,t,n,r){try{var s=new URL("https://"+r+":1047/Api/Client/getinfo"),o=JSON.parse(localStorage.getItem("userData"))||{},l={un:e,pwd:o&&null!==o.pwd&&void 0!==o.pwd?o.pwd:i.default.hash(t),switchNumber:n,cFlag:1};s.search=new URLSearchParams(l),a.debug(`await fetch ${s}`);let h=await fetch(s),p=await h.json();if(0!==Number(p.status))return{status:50002,info:p.info,step:"getinfo"};o.server=p.data.real_domain,o.serverIp=p.data.domain,o.eid=p.data.eid,o.sipPort=p.data.port;var u=Number(p.data.eid).toString(16),c="00000000"+u;c=c.substr(u.length,c.length),o.eid16=c,localStorage.setItem("userData",JSON.stringify(o));var d={domain:p.data.domain,sipPort:p.data.port,real_domain:p.data.real_domain,http_port:p.data.http_port,https_port:p.data.http_ports,epName:p.data.epName,eid:p.data.eid};return a.debug("getinfo:"+JSON.stringify(d)),{status:200,info:"获取运维信息成功",data:d}}catch(e){return a.error("getInfo"+e),{status:50001,info:e,step:"getinfo"}}}async function u(e,t){try{var n=JSON.parse(localStorage.getItem("userData")),r="https://"+n.server+"/Talk/Api/";t.pwd=n&&null!==n.pwd&&void 0!==n.pwd?n.pwd:i.default.hash(t.pwd);var s=new URL(r+e);s.search=new URLSearchParams(t),a.debug(`${e} await fetch ${s}`),a.debug(`${e} param ${JSON.stringify(t)}`);let h=await fetch(s),p=await h.json();if(0!==Number(p.status))return{status:50003,info:p.info,step:e};var o={};switch(e){case"getEpProfile":o={dialing_display_set:(l=p.data.epProfile).dialing_display_set,incoming_call_remind:l.incoming_call_remind,outcallenterprisenumber:l.outcallenterprisenumber,switch_number_public_set_mode:l.switch_number_public_set_mode,switch_number_default:l.switch_number_default,allow_customer_manager:l.allow_customer_manager,allow_callcenter:l.allow_callcenter,allow_auto_answer:l.allow_auto_answer,allow_hide_number:l.allow_hide_number,allow_worksheet:l.allow_worksheet,allow_monitor:l.allow_monitor,extension_end:l.extension_end,extension_start:l.extension_start,allow_record_manager:l.allow_record_manager},n.extension_end=l.extension_end,n.extension_start=l.extension_start,localStorage.setItem("userData",JSON.stringify(n));break;case"getGroups":o=u=p.data.map(function(e){return{id:e.id,eid:e.eid,name:e.name}});break;case"getMemberInfo":var l,u=(l=p.data).inGroups.map(function(e){return{id:e.id,eid:e.eid,name:e.name}});n.groupInfo=u;var c={id:l.id,eid:l.eid,uid:l.uid,displayname:l.displayname,number:l.number,work_number:l.work_number,duty:l.duty,mobile:l.mobile,outside_callnumber:l.outside_callnumber,address:l.address,permission:l.permission,call_limit:l.call_limit,time_limit:l.time_limit,cur_limit_time:l.cur_limit_time};n.userInfo=c,localStorage.setItem("userData",JSON.stringify(n)),o={userData:c,inGroups:u};break;case"updateInfo":a.debug(e+JSON.stringify(p)),o=p;break;case"searchEpMembers":var d=p.data.data.map(function(e){return{id:e.eid,eid:e.eid,uid:e.uid,displayname:e.displayname,number:e.number,mobile:e.mobile,telephone:e.telephone,pinyin:e.pinyin,outside_callnumber:e.outside_callnumber,address:e.address,gids:e.gids,gName:e.gName,service_callmode:e.service_callmode,service_control_time:e.service_control_time,service_control:e.service_control}});o={recordsTotal:p.data.recordsTotal,recordsFiltered:p.data.recordsFiltered,data:d};break;case"getMemberCallStates":o=p.data.filter(function(e){return e.uid==t.uid});break;default:return{status:50004,info:"未知请求"}}return a.debug(e+JSON.stringify(o)),{status:200,info:"获取成功",returnData:o}}catch(t){return a.error(e+t),{status:50001,info:t,step:e}}}t.exports={getLoginData:async function(e,t,n,r){try{var s=o(n);if(null==s||0==s.length)throw{status:5e4,info:"获取服务器失败",step:"getESserver"};var c=i.default.hash(t),d=Math.random().toString().split(".")[1].substr(0,8),h=Math.random().toString().split(".")[1].substr(0,6),p={pwd:c,clearPwd:d+t+h,switchNumber:n,callintype:r};localStorage.setItem("userData",JSON.stringify(p));var f=await l(e,t,n,s);if(200!=f.status)throw f;var m={un:e,pwd:t,eid:f.data.eid},_=await u("getEpProfile",m);if(200!=_.status)throw _;var v=await u("getMemberInfo",m);if(200!=v.status)throw v;m.jsonStr=JSON.stringify({data:{callintype:r}});var g=await u("updateInfo",m);if(200!=g.status)throw g;return{status:200,info:"获取成功",serverInfo:f.data,epInfo:_,memberInfo:v.returnData}}catch(e){return a.debug(e),localStorage.removeItem("userData"),e}},webApiHandler:u,_loadServerFromJson:o,_getInfo:l}},{"./Logger":54,"./province.json":57,"spark-md5":41}],56:[function(e,t,n){"use strict";var r=o(e("jssip")),i=o(e("./Logger")),s=e("./xmljs"),a=o(e("./getLoginInfo"));function o(e){return e&&e.__esModule?e:{default:e}}const l=e("events").EventEmitter,u=new i.default("index");t.exports=class extends l{constructor(){super(),this._ua=null}async login(e,t){var n=JSON.parse(localStorage.getItem("userData"));n||this.emit("registrationFailed"),e&&(n.loginGid=e.gid,n.socketUri=e.socketUri,n.status=e.status,n.remoteAudio=e.remoteAudio,localStorage.setItem("userData",JSON.stringify(n))),u.debug("准备sip注册"),this.registerSip(n),this.registerEvents(t),this.receiveNewMsg();var r=e&&e.remoteAudio||n.remoteAudio;this.newSessionEvent(document.getElementById(r))}registerSip(e){let t=`${e.serverIp}:${e.sipPort}`,n=`${e.userInfo.number}_${e.eid16}`,i=new r.default.WebSocketInterface(e.socketUri);this._ua=new r.default.UA({uri:`sip:${n}@${t}`,password:e.clearPwd.slice(8,e.clearPwd.length-6),display_name:e.userInfo.displayname,sockets:[i],registrar_server:t,contact_uri:`sip:${n}@${t}`,authorization_user:n,user_agent:"callcenter_webrtc",use_preloaded_route:!1,session_timers:!0}),this._ua.start()}receiveNewMsg(e){this._ua.on("newMessage",e=>{var t=e.request.body,n=(0,s.xmlToJs)(t);u.debug(`receive message:${JSON.stringify(n)}`);let r=Object.keys(n)[0];var i=JSON.parse(localStorage.getItem("userData"));if("cc"==r&&4!=Number(i.callintype)){let e=n.cc.a;switch(e){case"1":case"2":this.emit("statusChanged",{status:e});break;case"38":this.emit("transferCallSuccess",n.cc);break;case"39":this.emit("transferCallFaild",n.cc);break;case"201":this.emit("calloutResponse",n.cc);break;case"301":this.emit("callinResponse",n.cc);break;case"100":this.emit("newPBXCall",n.cc),this.answerPBXCall(n.cc.c);break;case"104":this.emit("answeredPBXCall",n.cc);break;case"105":this.emit("endPBXCall",n.cc)}}else"o"==r&&n.o.a&&n.o.a.u&&this.emit("kickedOffLine",n.o.a.u[0])})}registerEvents(e){this._ua.on("connecting",t=>{e({code:"connecting",data:t})}),this._ua.on("connected",t=>{e({code:"connected",data:t})}),this._ua.on("disconnected",t=>{e({code:"disconnected",data:t})}),this._ua.on("registered",t=>{let n=JSON.parse(localStorage.getItem("userData"));this.changeStaus(n.status.toString()),n.seatMode||this.setSeatMode(52,!0),this.logonWithGroup(n.loginGid,n.eid),e({code:"registered",data:t})}),this._ua.on("registrationFailed",t=>{u.debug("sip注册失败"),localStorage.removeItem("userData"),e({code:"registrationFailed",data:t})})}newSessionEvent(e){this._ua.on("newRTCSession",t=>{u.debug('UA "newRTCSession" event');let n=t.session;n.answer({mediaConstraints:{audio:!0,video:!1}}),n.connection.addEventListener("addstream",t=>{e.srcObject=t.stream,t.stream.addEventListener("addtrack",t=>{let n=t.track;e.srcObject===t.stream&&(e.srcObject=t.stream,n.addEventListener("ended",()=>{}))}),t.stream.addEventListener("removetrack",()=>{e.srcObject===t.stream&&(e.srcObject=t.stream)})}),this.emit("incomingCall",t),this.setSessionInfo(n)})}setSessionInfo(e){e.on("newInfo",t=>{if(u.debug('UA "newInfo" event'),!e.ccNumber){var n=t.request.body;e.ccNumber=(0,s.xmlToJs)(n).i.n}})}sendMsgHelper(e,t,n){var r=(0,s.jsToXml)(e);n||(n={succeeded:function(e){u.debug(`${t} success!`)},failed:function(e){u.debug(e)}}),this.sendMessage("PBX",r,n)}answerPBXCall(e){var t={a:"102",c:e};this.sendMsgHelper(t,"answerPBXCall")}hangUpPBXCall(e){var t={a:"106",c:e};this.sendMsgHelper(t,"hangUpPBXCall")}call(e,t,n){u.debug('call others [uri:"%s"]',e);var r=JSON.parse(localStorage.getItem("userData")),i=Math.random().toString().split(".")[1].substr(0,3);switch(t){case 1:let a=this._ua.call(e,{mediaConstraints:{audio:!0},rtcOfferConstraints:{offerToReceiveAudio:1},eventHandlers:n});return this.setSessionInfo(a),a;case 2:var s={a:"200",p:r.switchNumber,i:Date.now().toString()+i,t:e};this.sendMsgHelper(s,"call-回拨",n);break;case 3:s={a:"300",p:r.switchNumber,i:Date.now().toString()+i,t:`${e}_${r.eid16}`};this.sendMsgHelper(s,"call-内线互拨",n)}}stop(e){this._ua.stop(),this._ua.once("unregistered",t=>{var n=t.response;"OK"==n.reason_phrase&&200==n.status_code&&"REGISTER"==n.method?(localStorage.removeItem("userData"),e({code:n.status_code,info:n.reason_phrase})):e({code:n.status_code,info:n.reason_phrase})})}sendMessage(e,t,n){u.debug(`send message!!!,content:${t} target:${e}`);let r={eventHandlers:n,contentType:"application/pidf+xml"};return this._ua.sendMessage(e,t,r)}isConnected(){return this._ua.isConnected}changeStaus(e){let t=this;var n={succeeded:function(n){u.debug("changeStaus success!"),t.emit("statusChanged",{status:e})},failed:function(e){u.debug(e),t.emit("changeStausFailed")}};return this.sendMsgHelper({a:e.toString()},"changeStaus",n)}logonWithGroup(e,t){return this.sendMsgHelper({a:"53",g:`${e}_${t}`},"logonWithGroup")}async setSeatMode(e,t){t||52!=e||this.changeStaus("1");var n=JSON.parse(localStorage.getItem("userData")),r=52==e?2:1,i=51==e?4:2,s={un:n.userInfo.number,pwd:n.clearPwd.slice(8,n.clearPwd.length-6),eid:n.eid,jsonStr:JSON.stringify({data:{callintype:i}})};return await a.default.webApiHandler("updateInfo",s),n.callintype=i,n.seatMode=r,localStorage.setItem("userData",JSON.stringify(n)),this.sendMsgHelper({a:e.toString()},"setSeatMode")}transferPBXCall(e,t,n){if(!e||!t||!n){return new Error("缺少参数")}var r=JSON.parse(localStorage.getItem("userData")),i={a:"31",c:e,g:`${t}_${r.eid}`,n:`${n}_${r.eid16}`};return this.sendMsgHelper(i,"transferPBXCall")}}},{"./Logger":54,"./getLoginInfo":55,"./xmljs":58,events:1,jssip:11}],57:[function(e,t,n){t.exports={version:"1.0",TestDistricts:[{name:"开发调试服务器",uniServer:"cses.emic.com.cn",Ip:"112.80.5.131",switchNumbers:"02566699703"},{name:"159分布式云总机-开发调试",uniServer:"kfyw.emic.com.cn",Ip:"112.80.5.155",switchNumbers:"02566699741,02566699794,02566687971,02566687961,02566687313,02566687960,02566687301,02566699792,02566699734,02566687970,02566699746,02566699794,02566687335"}],CurDistricts:[{areaCode:"025,0510,0511,0512,0513,0514,0515,0516,0517,0518,0519,0523,0527",name:"江苏省",uniServer:"yzj.10010js.com"},{areaCode:"010",name:"北京市",uniServer:"bj.emic.com.cn"},{areaCode:"0770,0771,0772,0773,0774,0775,0776,0777,0778,0779",name:"广西自治区",uniServer:"emic.gx10010.com"},{areaCode:"0730,0731,0734,0735,0736,0737,0738,0739,0743,0744,0745,0746",name:"湖南省",uniServer:"hn.emic.com.cn"},{areaCode:"0570,0571,0572,0573,0574,0575,0576,0577,0578,0579,0580",name:"浙江省",uniServer:"zj.emic.com.cn"},{areaCode:"0591,0592,0593,0594,0595,0596,0597,0598,0599",name:"福建省",uniServer:"fj.emic.com.cn"},{areaCode:"0310,0311,0312,0313,0314,0315,0316,0317,0318,0319,0335",name:"河北省",uniServer:"www.woyzj.com"},{areaCode:"0550,0551,0552,0553,0554,0555,0556,0557,0558,0559,0561,0562,0563,0564,0566",name:"安徽省",uniServer:"ah.emic.com.cn"},{areaCode:"021",name:"上海市",uniServer:"sh.emic.com.cn"},{areaCode:"0891,0892,0893,0894,0895,0896,0897",name:"西藏自治区",uniServer:"xz.emic.com.cn"},{areaCode:"029,0911,0912,0913,0914,0915,0916,0917,0919",name:"陕西省",uniServer:"sn.emic.com.cn"},{areaCode:"0701,0790,0791,0792,0793,0794,0795,0796,0797,0798,0799",name:"江西省",uniServer:"jx.emic.com.cn"},{areaCode:"0370,0371,0372,0373,0374,0375,0376,0377,0379,0391,0392,0393,0394,0395,0396,0398",name:"河南省",uniServer:"yzj.online.ha.cn"},{areaCode:"022",name:"天津市",uniServer:"yzj.tjunicom.com"},{areaCode:"0851,0852,0853,0854,0855,0856,0857,0858,0859",name:"贵州省",uniServer:"gz.emic.com.cn"},{areaCode:"020,0660,0662,0663,0668,0750,0751,0752,0753,0754,0755,0756,0757,0758,0759,0760,0762,0763,0766,0768,0769",name:"广东省",uniServer:"gd.emic.com.cn"},{areaCode:"0691,0692,0870,0871,0872,0873,0874,0875,0876,0877,0878,0879,0883,0886,0887,0888",name:"云南省",uniServer:"yn.emic.com.cn"},{areaCode:"023",name:"重庆市",uniServer:"cq.emic.com.cn"},{areaCode:"028,0812,0813,0816,0817,0818,0825,0826,0827,0830,0831,0832,0833,0834,0835,0836,0837,0838,0839",name:"四川省",uniServer:"sc.emic.com.cn"},{areaCode:"0349,0350,0351,0352,0353,0354,0355,0356,0357,0358,0359",name:"山西省",uniServer:"sx.emic.com.cn"},{areaCode:"024,0411,0412,0415,0416,0417,0418,0419,0421,0427,0429",name:"辽宁省",uniServer:"ln.emic.com.cn"},{areaCode:"0930,0931,0932,0933,0934,0935,0936,0937,0938,0939,0941,0943",name:"甘肃省",uniServer:"gs.emic.com.cn"},{areaCode:"0530,0531,0532,0533,0534,0535,0536,0537,0538,0539,0543,0546,0631,0632,0633,0634,0635",name:"山东省",uniServer:"sd.emic.com.cn"},{areaCode:"027,0710,0711,0712,0713,0714,0715,0716,0717,0718,0719,0722,0724",name:"湖北省",uniServer:"hub.emic.com.cn"},{areaCode:"0898",name:"海南省",uniServer:"han.emicloud.com"}]}},{}],58:[function(e,t,n){"use strict";var r,i=e("./Logger");new((r=i)&&r.__esModule?r:{default:r}).default("xml2json");function s(e){var t=null;if(!window.DOMParser&&window.ActiveXObject)for(var n=["MSXML.2.DOMDocument.6.0","MSXML.2.DOMDocument.3.0","Microsoft.XMLDOM"],r=0;r<n.length;r++)try{(t=new ActiveXObject(n[r])).async=!1,t.loadXML(e);break}catch(e){}else{if(!(window.DOMParser&&document.implementation&&document.implementation.createDocument))return null;try{t=(new DOMParser).parseFromString(e,"text/xml")}catch(e){}}return t}t.exports={xmlToJs:function(e){for(var t=["a","b","c","f","g","k","o","i","m","n","p","r","s","t","q","v","z","l","u","nm"],n=t.length,r=["cc","o","mn","i"],i={},a=0;a<r.length;a++)if(s(e).getElementsByTagName(r[a]).length){var o;o=r[a];for(var l=s(e).firstChild,u={},c=0;c<n;c++)l.getAttribute(t[c])&&(u[t[c]]=l.getAttribute(t[c]));if(i[o]=u,s(e).firstChild.childNodes.length>0)for(var d=s(e).firstChild,h=[],p=(c=0,d.children.length);c<p;c++){for(var f={},m=d.children[c],_=0;_<n;_++)m.getAttribute(t[_])&&(f[t[_]]=m.getAttribute(t[_]));if(h.push(f),i[o][s(e).firstChild.children[0].tagName]=h,d.children[0].children.length>0)for(var v=[],g=0;g<d.children[0].children.length;g++){u=d.children[0].children[g];var y={};for(_=0;_<n;_++)u.getAttribute(t[_])&&(y[t[_]]=u.getAttribute(t[_]));v.push(y),i[o][s(e).firstChild.children[0].tagName][d.children[0].children[0].tagName]=v}}}return i},jsToXml:function(e){var t=s("<cc />").getElementsByTagName("cc")[0];for(var n in e)t.setAttribute(n,e[n]);return'<?xml version="1.0" encoding="utf-8"?>'+function(e){let t=document.createElement("div");t.appendChild(e);let n=t.innerHTML;return t=e=null,n}(t)}}},{"./Logger":54}],59:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0}),n.default=function(e){var t=` <div id='PHONE-LEFT-STATUS' style='width:${parseInt(e.width)/2}px'>\n <div data-type='pattern'>\n <div data-hide='0'>\n 当前处于移动模式\n </div>\n </div> \n <div data-type='rect' >\n <div data-hide='0'>\n <span data-type='number'>18330986136</span>\n | \n <span data-type='status'>呼叫中</span>\n <span data-type='times'>00:00:00</span>\n </div>\n </div>\n <div data-type='planePage'>\n <div data-hide='0'>\n \n </div> \n </div> \n <div data-type='incomingStatus'>\n <div data-hide='0'>\n <div data-type='bg'>\n <span data-type='number'>18330986136</span>\n  \n <span data-type='status'>来电</span>\n </div> \n <span data-hide="1" data-type='answer'>接听</span>\n </div> \n </div>\n </div>\n `,n="";["1","2","3","4","5","6","7","8","9","*","0","#"].map((e,t)=>{var r=t%3==0?0:16;n+='<span style="display:inline-block;"><input data-type="num" type="button" value="'+e+'" style="margin-left:'+r+'px"></span>'});var r=`<div id="PHONE-PANEL" data-hide='0' data-toggle='planePage'> \n <span data-type='close'>×</span>\n <div><input data-type='input' id='PANEL-INPUT' type='text' placeholder="请输入拨打的号码" oninput='this.value=this.value.replace(/[^0-9]/g,"")'></div>\n <div>\n ${n}\n </div>\n <div data-type='call' data-hide='0'>拨号</div>\n </div>`,i='<ul class="s-tips" id=\'EphoneBar\'>\n \n <li class="zhuce" id="zhuce" data-phone-key="0" data-phone-type="register">\n \x3c!--  --\x3e\n <em title="注册"></em>\n <span data-type="toggle" data-hide="0"></span>\n <div data-arrow=\'register\' class="arrow arrow-up" data-hide=\'0\'></div>\n \x3c!--状态切换--\x3e\n <div id="PHONE-ENTRY-TOGGLE" data-hide=\'0\' data-toggle=\'statusPage\'> \n <ul>\n <li data-type="leisure" data-hide=\'1\'><em></em><span>空闲</span></li>\n <li data-type="busy" data-hide=\'1\' ><em></em><span>忙碌</span></li>\n <li data-type="logout" data-hide=\'1\'><em></em><span>退出</span></li>\n </ul>\n </div>\n </li>\n\n \x3c!--<li class="logout" id="logout" data-phone-key="0" data-phone-type="logout" data-hide=\'0\'>\n <em title="退出"></em>\n </li>\n <li class="gray shimang" id="shimang" data-phone-key="3" data-phone-type=\'busy\' data-hide=\'1\'>\n <em title="示闲"></em>\n </li>\n <li class="shixian" id="shixian" data-phone-key="3" data-phone-type=\'leisure\' data-hide=\'0\'>\n <em title="示忙"></em>\n </li> --\x3e\n\n <li class="gray hujiao" id="hujiao" data-phone-key="1" data-phone-type=\'open\'>\n <em title="呼叫"></em>\n <div data-arrow=\'open\' class="arrow arrow-up" data-hide=\'0\'></div>\n </li>\n\n <li class="gray guanduan" id="guanduan" data-phone-key="1" data-phone-type=\'terminate\' data-hide=\'0\'>\n <em title="挂断" style=\'color:red\'></em>\n </li> \n <li class="gray zhuanjie" id="zhuanjie" data-phone-key="2" data-phone-type="switch">\n <em title="转接"></em>\n <div data-arrow=\'switch\' class="arrow arrow-up" data-hide=\'0\'></div>\n </li>\n\n \x3c!--<li class="gray sanfang" id="sanfang" data-phone-type=\'three\'>\n <em></em>\n <span>三方通话</span>\n <div data-arrow=\'three\' class="arrow arrow-up" data-hide=\'0\'></div>\n </li> --\x3e\n\n <li class="gray baochi" id="baochi" data-phone-key="1" data-phone-type=\'hold\' data-hide=\'1\'>\n <em title="暂停通话"></em>\n </li>\n <li class="jietong" id="jietong" data-phone-key="1" data-phone-type=\'unhold\' data-hide=\'0\'>\n <em title="恢复通话"></em>\n </li> \n\n <li class="jietong gray" id="jietong" data-phone-key="4" data-phone-type=\'setting\' data-hide=\'1\'>\n <em title="设置"></em>\n <div data-arrow=\'setting\' class="arrow arrow-up" data-hide=\'0\'></div>\n </li>\n </ul>';return`<div id="PHONE-ENTRY-CONTAINER" style="width:${e.width};height:${e.height};">\n <div style="background:${e.background};"width:${e.width};height:${e.height};"> \n <audio autoplay id='peeraideo'></audio>\n \x3c!--控制面板--\x3e\n ${i}\n \x3c!--通话状态--\x3e\n ${t}\n </div> \n \x3c!--登陆--\x3e\n <div id="PHONE-ENTRY-LOGIN" data-hide='0' data-toggle='loginPage'>\n <span data-type='close'>×</span>\n <span data-type='error'></span>\n <ul>\n <li>\n <span>总机号</span>\n <input type="text" data-type="switchnumber" value="02566699734" onkeyup="this.value=this.value.replace(/\\D/g,'')" onpaste="this.value=this.value.replace(/\\D/g,'')">\n </li>\n <li>\n <span>分机号</span>\n <input type="text" data-type='seatnumber' onkeyup="this.value=this.value.replace(/\\D/g,'')" onpaste="this.value=this.value.replace(/\\D/g,'')">\n </li>\n <li>\n <span>密 码</span>\n <input type="password" data-type="password" onkeyup="this.value=this.value.replace(/\\D/g,'')" onpaste="this.value=this.value.replace(/\\D/g,'')">\n </li>\n \x3c!-- <li>\n <span>座机号</span>\n <input type="text" data-type="password" onkeyup="this.value=this.value.replace(/\\D/g,'')" onpaste="this.value=this.value.replace(/\\D/g,'')">\n </li> --\x3e\n <li id="model" style="border:none">\n <label><span><input type="radio" name="callType" value='2' checked> VOIP</span></label>\n <label><span><input type="radio" disabled="true" name="callType" value='4'> SIP话机模式</span></label>\n <span data-type="loginStatus"><em></em> <span>示闲</span></span> \n </li>\n <li id="login">\n <span data-type='login' data-disabled='1'>登录</span>\n </li>\n </ul>\n </div>\n \x3c!--登陆选组--\x3e\n <div id="PHONE-ENTRY-SELECTGROUP" data-hide='0' data-toggle='selectGroup' >\n <span data-type='close'>×</span>\n <div data-type="introduce">请先选择工作所需的技能组:</div>\n <ul data-type="groupList">\n <<li>白浅白浅</li>\n <li>野花野花</li>\n <li class="selected">凤九凤九</li>\n <li>东华东华</li>\n <li>小团子小团子子子</li>\n <li>成玉成玉</li>\n <li>白浅白浅</li>\n <li>野花野花</li>\n </ul>\n <div data-type="confirm" data-disabled='1'>确认</div>\n </div>\n \x3c!--拨号面板--\x3e\n <div id='PHONE-ENTRY-PANEL' data-hide='0' data-toggle='fastPage'>\n <span data-type='close'>×</span>\n <div data-type='inputgroup'>\n <input type="text" data-type='input' placeholder="请输入电话号码" oninput='this.value=this.value.replace(/[^0-9]/g,"").replace(/ /g,"")'>\n </div>\n <button data-type='call'>呼叫</button>\n </div>\n ${r}\n \x3c!--转接--\x3e \n <div id="PHONE-ENTRY-SWITCH" data-hide='0' data-toggle='switchPage'>\n <span data-type="error"></span>\n <div id="SWITCH_PlATE">\n <span data-type="close">×</span>\n <div id="GROUP">\n <div data-type="select">\n <div data-type="select_text">全部技能组</div>\n <div data-type="select_icon">\n <div class="arrow arrow-down"></div>\n </div>\n </div>\n <ul data-type="group" data-hide="0">\n \x3c!-- <li data-eid='65656' data-id='580' data-level='1' data-name='翟岗岗技能组' data-oid='1' data-pid='0'>全部技能组</li>\n <li>售前技能组</li>\n <li>售后技能组</li>\n <li>技术支持</li> --\x3e\n </ul>\n <div data-type="filter"><input type="checkbox" data-type="checkbox" style='vertical-align: middle;'> 仅查可转接坐席</div>\n </div>\n <ul data-type="kefuList">\n \x3c!-- <li class="busy">白浅\n <span></span>\n </li>\n <li>野花\n <span></span>\n </li>\n <li>凤九\n <span></span>\n </li>\n <li>东华\n <span></span>\n </li>\n <li>小团子\n <span></span>\n </li>\n <li>成玉\n <span></span>\n </li> --\x3e\n </ul>\n <div data-type="transfer" data-disabled='1'>确认转接</div>\n </div>\n </div>\n \x3c!--设置--\x3e\n <div id="PHONE-ENTRY-SETTING" data-hide='0' data-toggle='setting'>\n <span data-type='close'>×</span>\n <ul>\n <li>\n <span>坐席模式</span>\n <span>\n <label><input type="radio" name="pattern" checked value="51" data-type="move"> 移动 </label>\n <label><input type="radio" name="pattern" value="52" checked data-type="fix" > 固定 </label>\n </span>\n </li>\n <li>\n <span>wss地址</span>\n <span>\n <select>\n <option value="1" selected>wss://s01.vsbc.com:9060</option>\n <option value="2">wss://10.0.0.165:10443</option>\n </select> \n </span>\n </li>\n <li>\n <span>功能按钮位置</span>\n <span>\n <label><input type="radio" data-type="postionButton" name="postionButton" value="left" checked> 左 </label>\n <label><input type="radio" data-type="postionButton" name="postionButton" value="right"> 右 </label>\n </span>\n </li>\n <li id="confirm">\n <span data-type='confirm'>确定</span>\n </li>\n </ul>\n </div>\n \x3c!--三方通话--\x3e\n <div id="PHONE-TRILATERA-SESSION" data-hide='0' data-toggle='threeSession'>\n <p data-type="status">等待被叫接听...</p>\n <p>\n <span data-type="number">02567893755</span>\n <span data-type="img"></span> \n \x3c!-- <span data-type="cancel">取消</span> --\x3e\n \x3c!-- <span data-type="redial">重新拨号</span> --\x3e\n <span data-type="hangup">挂断</span>\n </p>\n <p>\n <span data-type="number">02567893755</span>\n \x3c!-- <span data-type="img"></span> --\x3e\n <span data-type="cancel">取消</span>\n <span data-type="redial">重新拨号</span>\n \x3c!-- <span data-type="hangup">挂断</span> --\x3e\n </p>\n </div> \n </div>`}},{}],60:[function(e,t,n){"use strict";var r=a(e("./phone")),i=e("../lib/getLoginInfo"),s=a(e("./html"));function a(e){return e&&e.__esModule?e:{default:e}}!function(e,t){e.$E=new class{constructor(){this.options={width:"500px",height:"50px",background:"",callBackground:["#1E59B9","#19C583","#FF6754"],drop:!0},this.closeTimer=null,this.watchTimer=null,this.gid=null,this.recordsTotal=null,this.callintype="2",this.callType=0,this.isOutCall=!1,this.socket_uri="wss://s01.vsbc.com:9060",this.log=r.default.debug("script")}init(e,n){document.getElementsByTagName("head")[0],document.createElement("link");var i,a=!!localStorage.getItem("userData")&&JSON.parse(localStorage.getItem("userData")),o=document.createElement("div");try{i=t.querySelector(e)||t.querySelector("body")}catch(e){e&&(i=t.querySelector("body"))}"object"==typeof n&&n&&(this.options.width=n.width?n.width:this.options.width,this.options.height=n.height?n.height:this.options.height,this.options.background=n.background?n.background:this.options.background,this.options.drop=null!=n.drop?n.drop:this.options.drop,this.options.callBackground=n.callBackground&&Array.isArray(n.callBackground)?n.callBackground:this.options.callBackground),this.options.drop&&this._addDrop(o,i),o.style.width=this.options.width,o.style.boxShadow="0px 1px 15px #c3c3c3",o.style.zIndex=999,o.style.background=this.options.background,o.id="PHONE-DROP",o.innerHTML=(0,s.default)(this.options),i.appendChild(o),this.eventListener(),window.onbeforeunload=function(e){r.default._beforeunload(),e.returnValue="离开取消会话"},a&&a.setting&&this.setTogglePosition(a.setting)}eventListener(){var n,s,a,o=[],l=this,u=null,c=1,d=0;let h=document.querySelectorAll("#EphoneBar li[data-phone-key]"),p=this._Sel("#EphoneBar li[data-phone-type='register']"),f=(this._Sel("#EphoneBar li[data-phone-type='logout']"),this._Sel("#EphoneBar li[data-phone-type='open']"),this._Sel("#PHONE-LEFT-STATUS>div[data-type='planePage']>div")),m=p.querySelector("span[data-type='toggle']"),_=this._Sel("#PHONE-ENTRY-LOGIN[data-hide]"),v=this._Sel("#PHONE-ENTRY-SELECTGROUP[data-hide]"),g=this._Sel("#PHONE-ENTRY-TOGGLE[data-hide]"),y=this._Sel("#PHONE-ENTRY-SETTING[data-hide]"),T=this._Sel("#PHONE-ENTRY-PANEL[data-hide]"),S=this._Sel("#PHONE-ENTRY-SWITCH[data-hide]"),C=t.querySelectorAll("#PHONE-ENTRY-LOGIN[data-hide] input[data-type]"),E=C[0],b=C[1],R=C[2],w=_.querySelector("span[data-type='error']");var A=_.querySelector("[data-type='loginStatus']"),I=A.querySelector("span");this._Sel("#PHONE-ENTRY-SETTING input[data-type='registerServer']"),this._Sel("#PHONE-ENTRY-SETTING input[data-type='websocketUrl']"),t.querySelectorAll("#PHONE-ENTRY-SETTING option");let k=this._Sel("#PHONE-ENTRY-SWITCH[data-hide] [data-type='kefuList']"),P=this._Sel("#PHONE-ENTRY-PANEL[data-hide] input[data-type='input']"),O=this._Sel("#PHONE-ENTRY-SWITCH[data-hide] [data-type='select_text']"),N=S.querySelector("span[data-type='error']");localStorage&&localStorage.getItem("userData")&&this.register(),Array.from(C).forEach(e=>{e.onfocus=(()=>{w.innerText=""})}),Array.from(h).forEach(e=>{o.push(e),e.onclick=function(e){e.stopPropagation();var t=this.getAttribute("data-phone-type"),n=this.getAttribute("data-phone-key");if(!this.classList.contains("gray"))switch(n){case"0":if("register"==t)if(r.default.sipStatus){var i=JSON.parse(localStorage.userData),s=l._Sel("#PHONE-ENTRY-TOGGLE li[data-type='leisure']"),a=l._Sel("#PHONE-ENTRY-TOGGLE li[data-type='busy']");s.dataset.hide=a.dataset.hide=1==i.seatMode?"0":"1",l.setDisplayNone("statusPage")}else l.setDisplayNone("loginPage");break;case"1":"open"==t&&l.setDisplayNone("fastPage"),"terminate"==t&&r.default.terminate(),"hold"==t&&r.default.hold(),"unhold"==t&&r.default.unhold();break;case"2":if(0==l._Sel("#PHONE-ENTRY-SWITCH[data-hide]").dataset.hide){l.getGroup(),i=JSON.parse(localStorage.userData),l.gid=i.loginGid?i.loginGid:-1;var o={un:i.userInfo.number,pwd:i.pwd,eid:i.eid,searchGid:l.gid,length:20};l.getMembers(o)}l.setDisplayNone("switchPage");break;case"4":var u=l._Sel("#PHONE-ENTRY-SETTING input[data-type='move']"),c=l._Sel("#PHONE-ENTRY-SETTING input[data-type='fix']");i=JSON.parse(localStorage.userData),l.setDisplayNone("setting"),i&&("1"==i.seatMode?u.checked=!0:c.checked=!0)}}}),_.onclick=async function(e){e.stopPropagation();var t=e.target||e.srcElement;if("close"==t.dataset.type&&(_.dataset.hide="0",l.setArrowNone()),"loginStatus"!=t.dataset.type&&"loginStatus"!=t.parentNode.dataset.type||(A.classList.contains("busy")?(A.classList.remove("busy"),I.innerText="示闲",r.default._kefuStatus="1"):(A.classList.add("busy"),I.innerText="示忙",r.default._kefuStatus="2")),"login"==t.dataset.type){if(0==E.value.length)return w.innerText="请输入总机号码",!1;if(0==b.value.length)return w.innerText="请输入分机号码",!1;if(b.value.length<4||b.value.length>6)return w.innerText="分机号码错误,请重新输入",!1;if(0==R.value.length)return w.innerText="请输入密码",!1;if("0"==t.dataset.disabled)return;t.dataset.disabled="0",l.callintype=_.querySelector("input[type='radio'][name='callType']:checked").value;var n=await(0,i.getLoginData)(b.value,R.value,E.value,l.callintype);if(l.log("getLoginData",{res:n}),5e4==n.status)return w.innerText="总机号码错误,请重新输入",void(t.dataset.disabled="1");if(50002==n.status)return w.innerText="分机号码或密码错误,请重新输入",void(t.dataset.disabled="1");var s=JSON.parse(localStorage.userData).groupInfo;if(s.length>1){_.dataset.hide="0",v.dataset.hide="1";var a="";return s.map((e,t)=>{a+="<li title='"+e.name+"' data-eid='"+e.eid+"' data-id='"+e.id+"'>"+e.name+"</li>"}),l._Sel("#PHONE-ENTRY-SELECTGROUP ul[data-type='groupList']").innerHTML=a,void(t.dataset.disabled="1")}var o={switchnumber:E.value,seatnumber:b.value,password:R.value,gid:s[0]?s[0].id:0,callintype:l.callintype,socketUri:l.socket_uri,status:r.default._kefuStatus};l.register(o,t)}},g.addEventListener("click",function(e){e.stopPropagation();var t=e.target||e.srcElement,n=JSON.parse(localStorage.userData).seatMode;if("leisure"==t.dataset.type||"leisure"==t.parentNode.dataset.type){if(1==n)return;r.default.changeStaus("1")}if("busy"==t.dataset.type||"busy"==t.parentNode.dataset.type){if(1==n)return;r.default.changeStaus("2")}if("logout"==t.dataset.type||"logout"==t.parentNode.dataset.type){var i=l._Sel("#PHONE-LEFT-STATUS div[data-type='pattern']>div");r.default.stop(function(e){200==e.code?(r.default._kefuStatus="1",m.dataset.hide="0",l.setDisplayNone("all"),l.sethighlight("register",!0),i.dataset.hide="0"):alert(e.info)})}g.dataset.hide="0",l.setArrowNone()}),y.onclick=function(e){e.stopPropagation();var t=e.target||e.srcElement;if("confirm"==t.dataset.type){var n=JSON.parse(localStorage.userData),i=(l._Sel("#EphoneBar"),l._Sel("#PHONE-LEFT-STATUS"),l._Sel("#PHONE-LEFT-STATUS div[data-type='pattern']>div")),s=y.querySelector("input[type='radio'][name='pattern']:checked").getAttribute("value"),a="51"==s?1:2,o={postion:y.querySelector("input[type='radio'][name='postionButton']:checked").getAttribute("value")};if(!n)return;n.setting=o,localStorage.setItem("userData",JSON.stringify(n)),n.seatMode!=a&&(r.default.setSeatMode(s),i.dataset.hide=1==a?"1":"0",1==a?l.sethighlight("register,setting",!0):l.sethighlight("register,open,setting",!0)),l.setTogglePosition(o),l.setArrowNone(),y.dataset.hide=0}"close"==t.dataset.type&&(y.dataset.hide=0,l.setArrowNone())},v.onclick=function(e){e.stopPropagation();var t=e.target||e.srcElement;if("close"==t.dataset.type&&(v.dataset.hide="0",_.dataset.hide="1",localStorage.getItem("userData")&&localStorage.removeItem("userData")),"groupList"==t.parentNode.dataset.type){var r=t.parentNode.children;Array.from(r).forEach(e=>{e.classList.remove("selected")}),t.classList.add("selected"),n=t.dataset.id,l.log("groupList:id",n)}if("confirm"==t.dataset.type){if("0"==t.dataset.disabled)return;if(document.querySelectorAll("#PHONE-ENTRY-SELECTGROUP ul[data-type='groupList']>li.selected").length<1)return;t.dataset.disabled="0";var i=JSON.parse(localStorage.userData),s={switchnumber:i.switchNumber,seatnumber:i.userInfo.number,password:i.pwd,gid:n,callintype:l.callintype,socketUri:l.socket_uri};l.register(s,t)}},T.onclick=function(e){e.stopPropagation();var t=e.target||e.srcElement;if("close"==t.dataset.type&&(l.setArrowNone(),T.dataset.hide="0"),"call"==t.dataset.type){if(0==P.value.length)return;var n=P.value,i=JSON.parse(localStorage.userData),s=parseInt(i.extension_start),a=parseInt(i.extension_end);l.callType=parseInt(n)>=s&&parseInt(n)<=a?3:2;var o={peerID:2==l.callType?"9"+n:n,callType:l.callType};r.default.call(o),l.phoneStatus("outgoingCall",{panelInput:n,callType:o.callType}),P.value="",T.dataset.hide=0}},P.onkeydown=function(e){if("13"==e.keyCode){if(0==P.value.length)return;var t=P.value,n=JSON.parse(localStorage.userData),i=parseInt(n.extension_start),s=parseInt(n.extension_end);l.callType=parseInt(t)>=i&&parseInt(t)<=s?3:2;var a={peerID:2==l.callType?"9"+t:t,callType:l.callType};r.default.call(a),l.phoneStatus("outgoingCall",{panelInput:t,callType:a.callType}),P.value="",T.dataset.hide=0}},S.onclick=async function(t){t.stopPropagation();var n,i=t.target||t.srcElement;if(l.log(i),"select"==i.parentNode.dataset.type){var o=l._Sel('#GROUP ul[data-type="group"]').dataset.hide;l._Sel('#GROUP ul[data-type="group"]').dataset.hide="1"==o?"0":"1"}if("group"==i.parentNode.dataset.type){O.innerText=i.innerText,l._Sel('#GROUP ul[data-type="group"]').dataset.hide=0,l.log(i.dataset.id),l.gid=i.dataset.id?i.dataset.id:-1,c=1;var h={un:(n=JSON.parse(localStorage.userData)).userInfo.number,pwd:n.pwd,eid:n.eid,searchGid:i.dataset.id?i.dataset.id:-1,length:20};d&&(h.searchServiceControl=d),l.getMembers(h)}"checkbox"==i.dataset.type&&(c=1,l.log(i.checked),h={un:(n=JSON.parse(localStorage.userData)).userInfo.number,pwd:n.pwd,eid:n.eid,searchGid:l.gid,length:20},i.checked?(d=1,h.searchServiceControl=d):d=0,l.getMembers(h));if("close"==i.dataset.type&&(l.setDisplayNone("switchPage"),O.innerText="未分组",l.setArrowNone()),"kefuList"==i.parentNode.dataset.type){if("offLine"==i.dataset.status||"busy"==i.dataset.status)return;for(var p=i.parentNode.children.length,f=0;f<p;f++)i.parentNode.children[f].classList.remove("selected");i.classList.add("selected"),s=i.dataset.gids,a=i.dataset.number}"transfer"==i.dataset.type&&"0"!=i.dataset.disabled&&s&&a&&(l.log("正在转接...",s,a),i.dataset.disabled="0",N.style.color="#19C583",N.innerText="正在转接,请稍后...",r.default.transferPBXCall(s,a,function(t){"transferCallFaild"==t.type?(S.dataset.hide="1",N.style.color="#FD3D39",N.innerText="电话转接失败",u&&e.clearTimeout(u),u=e.setTimeout(()=>{N.innerText=""},2e3)):(N.innerText="电话转接成功",u&&e.clearTimeout(u),u=e.setTimeout(()=>{N.innerText="",S.dataset.hide="0"},2e3)),i.dataset.disabled="1"}))},k.onscroll=function(e){var t=e.target||e.srcElement,n=Math.ceil(parseInt(l.recordsTotal)/20);if(t.scrollTop>=t.scrollHeight-t.offsetHeight){if(c==n)return;var r=JSON.parse(localStorage.userData),i={un:r.userInfo.number,pwd:r.pwd,eid:r.eid,searchGid:l.gid,start:20*c,length:20};l.getMembers(i,!0),c++}};var x=this._Sel("#PHONE-PANEL");o.push(_,v,y,T,x,f,S,g),this.options.drop&&this._stopPro(o)}_Sel(e){return t.querySelector(e)}async getGroup(){var e=JSON.parse(localStorage.userData),t={un:e.userInfo.number,pwd:e.pwd,eid:e.eid},n=await(0,i.webApiHandler)("getGroups",t);this.log({getGroups:n});var r,s="<li>未分组</li>";n.returnData.map((t,n)=>{t.id==e.loginGid&&(r=t.name),s+="<li data-eid='"+t.eid+"' data-id='"+t.id+"' data-level='"+t.level+"' data-name='"+t.name+"' data-oid='"+t.oid+"' data-pid='"+t.pid+"'>"+t.name+"</li>"}),this._Sel("#PHONE-ENTRY-SWITCH[data-hide] [data-type='select_text']").innerText=r||"未分组",this._Sel('#PHONE-ENTRY-SWITCH ul[data-type="group"]').innerHTML=s}async getMembers(e,t){var n=await(0,i.webApiHandler)("searchEpMembers",e);this.recordsTotal=n.returnData.recordsTotal,this.log({getMembers:n});var r="";n.returnData.data.length?n.returnData.data.map((e,t)=>{var n;0==e.service_control||2==e.service_control?n="offLine":1==e.service_control?n="":e.service_control>2&&(n="busy"),r+="<li title='"+e.displayname+"' data-status_code='"+e.service_control+"' data-status='"+n+"' data-gids='"+this.gid+"' data-number='"+e.number+"'>"+e.displayname+"<span></span></li>"}):r+="<li data-type='noOne'>暂无坐席</li>";var s=this._Sel("#PHONE-ENTRY-SWITCH>#SWITCH_PlATE>ul");s.innerHTML=t?s.innerHTML+r:r}register(e,t){e&&(e.remoteAudio="peeraideo"),r.default.register(e,e=>{switch(t&&(t.dataset.disabled="1"),e.code){case 200:if(r.default.session)return;var n=this._Sel("#PHONE-LEFT-STATUS div[data-type='pattern']>div"),i=localStorage.userData?JSON.parse(localStorage.userData):void 0;this.setDisplayNone("all"),this.setArrowNone(),i?(1==i.seatMode?this.sethighlight("register,setting",!0):this.sethighlight("register,open,setting",!0),n.dataset.hide=1==i.seatMode?"1":"0"):this.sethighlight("register,open,setting",!0);break;case 100:this.log("eventIncoming__100:"+e.type,e),this.phoneStatus(e.type,e.data);break;case 300:var s=e.data.r;switch(this.log("被踢下线",s),s){case"895":this.setDisplayNone("all"),confirm("其他用户登录您的账号,请重新登录")?(r.default.terminate(),this.register()):r.default.stop(e=>{200==e.code?(r.default.terminate(),r.default._kefuStatus="1",kefuStatus.dataset.hide="0",this.sethighlight("register",!0)):alert(e.info)});break;case"897":alert("注册超时,请重新登录");break;case"898":alert("账号过期/账号被删/账号修改,请重新登录");break;case"899":alert("企业停止")}break;default:alert(e.info)}})}_addDrop(e,t){var n=this;e.onmousedown=function(r){r.stopPropagation(),r.preventDefault(),t.setCapture&&t.setCapture();var i=r||event,s=this,a=i.clientX-this.offsetLeft,o=i.clientY-this.offsetTop;this.style.position="fixed",this.style.cursor="move",document.onmousemove=function(e){var t=e||event,r=t.clientX-a,i=t.clientY-o,l=document.body.clientHeight||document.documentElement.offsetHeight||document.body.scrollHeight||window.screen.height-133,u=document.body.clientWidth||document.documentElement.clientWidth||document.body.clientWidth;r<=20&&(r=0),r>=u-parseInt(s.offsetWidth)-20&&(r=u-parseInt(s.offsetWidth)),i>=l-parseInt(n.options.height)-20&&(i=l-parseInt(n.options.height)),i<=20&&(i=0),s.style.left=r+"px",s.style.top=i+"px"},document.onmouseup=function(){document.onmousemove=null,document.onmouseup=null,s.style.cursor="default",e.setCapture&&t.releaseCapture()}}}_stopPro(e){e.forEach(e=>{e.addEventListener("mousedown",function(e){e.stopPropagation()})})}_hideAllMode(){document.addEventListener("click",e=>{e.stopPropagation(),this.setDisplayNone("all")})}timerWatch(t,n){var r=0,i=0,s=0;t.innerText="00:00:00",n?(e.clearInterval(this.watchTimer),this.watchTimer=e.setInterval(()=>{++r>=60&&(r=0,i++),i>=60&&(i=0,s++),t.innerText=(s<10?"0"+s:s)+":"+(i<10?"0"+i:i)+":"+(r<10?"0"+r:r)},1e3)):e.clearInterval(this.watchTimer)}sethighlight(e,t){document.querySelectorAll("#EphoneBar li[data-phone-key]").forEach(n=>{-1!==e.indexOf(n.dataset.phoneType)?t?n.classList.remove("gray"):n.classList.add("gray"):t?n.classList.add("gray"):n.classList.remove("gray")})}setDisplayNone(e){var t=document.querySelectorAll("#PHONE-ENTRY-CONTAINER div[data-toggle]"),n=document.querySelectorAll("#EphoneBar div[data-arrow]"),r=["loginPage","selectGroup","statusPage","fastPage","switchPage","setting"],i=["register","register","register","open","switch","setting"];Array.from(n).forEach(e=>{e.dataset.hide="0"}),Array.from(t).forEach(t=>{if(-1!==e.indexOf(t.dataset.toggle)){var n=r.indexOf(t.dataset.toggle);t.dataset.hide="1"==t.dataset.hide?"0":"1",n>=0&&(document.querySelector("#EphoneBar div[data-arrow="+i[n]+"]").dataset.hide=t.dataset.hide)}else t.dataset.hide="0"})}setTogglePosition(e){var t=document.querySelectorAll("#PHONE-ENTRY-CONTAINER div[data-toggle]"),n=this._Sel("#EphoneBar"),r=this._Sel("#PHONE-LEFT-STATUS"),i=this._Sel("#PHONE-ENTRY-SETTING[data-hide] input[data-type='postionButton'][value="+e.postion+"]"),s=e.postion&&"left"==e.postion;n.style.float=s?"left":"right",r.style.float=s?"right":"left",i.checked=!0,Array.from(t).forEach(e=>{"statusPage"!=e.dataset.toggle&&(e.style.left=s?"0px":parseInt(this.options.width)-300+"px")})}setArrowNone(){var e=document.querySelectorAll("#EphoneBar>li>div[data-arrow]");Array.from(e).forEach(e=>{e.dataset.hide="0"})}phoneStatus(t,n){var i=this,s=(this._Sel("#PHONE-LEFT-STATUS>div[data-type='circle']>div"),this._Sel("#PHONE-LEFT-STATUS>div[data-type='rect']>div")),a=s.querySelector("span[data-type='number']"),o=s.querySelector("span[data-type='status']"),l=s.querySelector("span[data-type='times']"),u=this.options.callBackground,c=(this._Sel("#PHONE-LEFT-STATUS>div[data-type='planePage']>div"),this._Sel("#PHONE-PANEL"),this._Sel("li[data-phone-type='open']")),d=this._Sel("li[data-phone-type='terminate']"),h=this._Sel("#EphoneBar li[data-phone-type='hold']"),p=this._Sel("#EphoneBar li[data-phone-type='unhold']");switch(t){case"outgoingCall":s.dataset.hide=1,s.style.background=u[0],a.innerText=n.panelInput.length>12?n.panelInput.substring(1,12)+"...":n.panelInput,o.innerText="呼叫中",this.timerWatch(l,!0),this.sethighlight("all",!0),this.setDisplayNone("all"),this.setArrowNone(),setTimeout(()=>{this.isOutCall||(r.default.terminate(),s.style.background=u[2],o.innerText="呼叫超时",e.clearTimeout(i.closeTimer),this.timerWatch(l,!1),this.closeTimer=e.setTimeout(()=>{s.dataset.hide="0",this.sethighlight("register,open,setting",!0),this.setDisplayNone("all")},2e3))},3e4);break;case"newPBXCall":var f=JSON.parse(localStorage.userData),m=parseInt(f.extension_start),_=parseInt(f.extension_end),v=-1!=n.n.indexOf("_")?n.n.split("_")[0]:n.n;this.callType=parseInt(v)>=m&&parseInt(v)<=_?3:2,a.innerText=v;break;case"calloutResponse":case"callinResponse":200!=n.r&&(s.style.background=u[2],o.innerText="呼叫失败",e.clearTimeout(i.closeTimer),this.closeTimer=e.setTimeout(()=>{s.dataset.hide="0",this.sethighlight("register,open,setting",!0),this.setDisplayNone("all")},2e3));break;case"progress":this.isOutCall=!0,c.dataset.hide="0",d.dataset.hide="1",this.sethighlight("terminate",!0),this.setDisplayNone("all"),this.setArrowNone();break;case"accepted":break;case"answeredPBXCall":s.dataset.hide="1",s.style.background=u[1],this.timerWatch(l,!0),o.innerText="通话中",2==this.callType?this.sethighlight("terminate,hold,unhold,switch",!0):this.sethighlight("terminate,hold,unhold",!0);break;case"ended":this.setDisplayNone("all"),this.timerWatch(l,!1),s.dataset.hide="1",s.style.background=u[2],o.innerText="通话结束",this.sethighlight("all",!0),e.clearTimeout(i.closeTimer),this.closeTimer=e.setTimeout(()=>{s.dataset.hide="0",c.dataset.hide="1",d.dataset.hide="0",p.dataset.hide="0",h.dataset.hide="1",this.sethighlight("register,open,setting",!0),this.isOutCall=!1},2e3);break;case"endPBXCall":break;case"failed":this.setDisplayNone("all"),this.timerWatch(l,!1),s.dataset.hide="1",s.style.background=u[2],o.innerText="通话结束",this.sethighlight("all",!0),e.clearTimeout(i.closeTimer),this.closeTimer=e.setTimeout(()=>{s.dataset.hide="0",c.dataset.hide="1",d.dataset.hide="0",p.dataset.hide="0",h.dataset.hide="1",this.sethighlight("register,open,setting",!0),this.isOutCall=!1},2e3);break;case"hold":"local"==n.originator&&(h.dataset.hide="0",p.dataset.hide="1");break;case"unhold":"local"==n.originator&&(h.dataset.hide="1",p.dataset.hide="0")}}}}(window,document)},{"../lib/getLoginInfo":55,"./html":59,"./phone":61}],61:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var r=s(e("debug")),i=s(e("../lib/index"));function s(e){return e&&e.__esModule?e:{default:e}}n.default=new class{constructor(){this._ua=null,this._session=null,this._sipStatus=!1,this._socketStatus=!1,this._kefuStatus="1",this.callType="2",this.debug=r.default,this.log=this.debug("phone")}register(e,t){this._ua=new i.default;var n=e?{un:e.seatnumber,pwd:e.password,switchNumber:e.switchnumber,callintype:e.callintype,socketUri:e.socketUri,gid:e.gid,remoteAudio:e.remoteAudio,status:this._kefuStatus}:void 0;this.log("login param :",n),this._ua.login(n,e=>{this.handlerResult(e,t)}),this.eventStatus(),this.eventIncoming(t),this.log("call register"),this._ua.on("kickedOffLine",e=>{this.log("kickedOffLine, ",{data:e}),t({code:300,data:e})})}handlerResult(e,t){var n=e.code;switch(this.log(`UA ${e.code} event ${JSON.stringify(e.data)}`),n){case"connecting":case"disconnected":this.socketStatus=!1;break;case"connected":this.socketStatus=!0;break;case"registered":this.log("registered: ",e.data.response.status_code,",",e.data.response.reason_phrase,{data:e.data}),200==e.data.response.status_code&&t({code:e.data.response.status_code,info:"登陆成功",data:e.data});break;case"registrationFailed":t({code:301,info:"登录失败",data:e.data})}}eventStatus(){this._ua.on("statusChanged",e=>{var t=document.querySelector("li[data-phone-type='register'] span"),n=["#19C583","rgb(254, 211, 0)"];"0"==e.status&&(this.sipStatus=!1),"1"==e.status&&(this.sipStatus=!0,t.dataset.hide="1",t.style.background=n[0]),"2"==e.status&&(this.sipStatus=!0,t.dataset.hide="1",t.style.background=n[1]),this._kefuStatus=e.status;var r=JSON.parse(localStorage.userData);r.status=e.status,localStorage.setItem("userData",JSON.stringify(r)),this.log("statusChanged:",e)})}eventIncoming(e){this._ua.on("incomingCall",t=>{if(this.log("incomingCall: ",t.originator+":",{data:t}),"local"===t.originator)return;let n=t.session;t.session.on("progress",t=>{this.session=n,e({code:100,type:"progress",data:t})}),t.session.on("connecting",t=>{e({code:100,type:"connecting",data:t})}),t.session.on("accepted",t=>{e({code:100,type:"accepted",data:t})}),t.session.on("failed",t=>{this.session=null,e({code:100,type:"failed",data:t})}),t.session.on("ended",t=>{this.log("ended",{data:t}),this.session=null,e({code:100,type:"ended",data:t})}),t.session.on("hold",t=>{this.log("hold",t),e({code:100,type:"hold",data:t})}),t.session.on("unhold",t=>{this.log("unhold",t),e({code:100,type:"unhold",data:t})}),t.session.on("newDTMF",e=>{this.log("newDTMF",e.originator,e)})}),this._ua.on("newPBXCall",t=>{this.log("newPBXCall",t),e({code:100,type:"newPBXCall",data:t})}),this._ua.on("calloutResponse",t=>{this.log("calloutResponse座席外呼响应201",t),e({code:100,type:"calloutResponse",data:t})}),this._ua.on("callinResponse",t=>{this.log("callinResponse座席外呼响应(内线)301",t),e({code:100,type:"callinResponse",data:t})}),this._ua.on("answeredPBXCall",t=>{this.log("answeredPBXCall",t),e({code:100,type:"answeredPBXCall",data:t})}),this._ua.on("endPBXCall",t=>{this.log("endPBXCall",t),e({code:100,type:"endPBXCall",data:t})})}call(e){this.callType=e.callType,this._ua.call(e.peerID,this.callType,{}),this.log("call to:",{peerID:e.peerID,callType:this.callType})}sendDTMF(e){this.session&&this.session.sendDTMF(e),this.log("sendDTMF",e+"")}terminate(){this.session&&(this._ua.hangUpPBXCall(this.session.ccNumber),this.session.terminate())}stop(e){this._ua._ua.isRegistered()&&this._ua.stop(t=>{200==t.code&&(this.sipStatus=!1),e(t)})}hold(){this.session&&this.session.hold()}unhold(){this.session&&this.session.unhold()}transferPBXCall(e,t,n){this.session&&(this._ua.transferPBXCall(this.session.ccNumber,e,t),this._ua.once("transferCallSuccess",e=>{this.log("transferCallSuccess(电话转接成功)",e),n({type:"transferCallSuccess",data:e})}),this._ua.once("transferCallFaild",e=>{this.log("transferCallFaild(电话转接失败)",e),n({type:"transferCallFaild",data:e})}))}changeStaus(e){this._ua.changeStaus(e),this.log("setchangeStaus:",e)}sendMessage(e,t,n){var r=this,i={eventHandlers:{succeeded:function(e){r.log("send message succeeded",{data:e}),n({type:"success",content:t,data:e})},failed:function(e){console.error("send message error",{data:e}),n({type:"failed",content:t,data:e})}}};this._ua.sendMessage(e+"_00013093",t,i)}setSeatMode(e){this._ua.setSeatMode(e,!1),this.log("setSeatMode:",e)}_beforeunload(e){this.session&&(this._ua.hangUpPBXCall(this.session.ccNumber),this.session.terminate()),!this.sipStatus&&localStorage.getItem("userData")&&localStorage.removeItem("userData")}get socketStatus(){return this._socketStatus}set socketStatus(e){this._ua._ua&&e&&this._ua._ua.isRegistered()?this.sipStatus=!0:this.sipStatus=!1,this._socketStatus=e}get sipStatus(){return this._sipStatus}set sipStatus(e){this.log("setSipStatus",e),this._sipStatus=e}get session(){return this._session}set session(e){this._session=e,this.log("session change:",e)}}},{"../lib/index":56,debug:2}]},{},[60]);
//# sourceMappingURL=../../maps/src/ui/index.js.map
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<script id="emickf_ee549f8c0be21546" src="./bundle.js"></script>
<link rel="stylesheet" href="./main.css">
</head>
<style>
body,
html {
height: 100%
}
#test {
width: 500px;
margin: 0 auto;
border: 1px dotted #00008b;
height: 50px
}
.helper {
position: absolute;
left: 200px;
bottom: 200px
}
.helper a {
color: #337ab7;
text-decoration: none
}
</style>
<body>
<div id="test"></div>
<div class="helper">
<h4>以下链接可以跳转至帮助文档,如有需要可下载css、js</h4>
<ul>
<li>
<a href="https://www.yuque.com/yimi/phone-control/welcome-to-lark" target="_blank">帮助文档</a>
</li>
<li>
<a href="https://sip.emicmh.com:3002/main.css" target="_blank">css地址</a>
</li>
<li>
<a href="https://sip.emicmh.com:3002/bundle.js" target="_blank">js地址</a>
</li>
</ul>
</div>
</body>
<script>if (window.ActiveXObject || "ActiveXObject" in window || -1 < navigator.userAgent.indexOf("Edge")) document.body.innerHTML = "<h1>请使用非IE/Edge浏览器!!!</h1>"; else { var options = { drop: !0 }; $E.init("#test", options) }</script>
</html>
@font-face{font-family:iconfont;src:url(https://at.alicdn.com/t/font_792726_wd5lzuxvvh.eot);src:url(https://at.alicdn.com/t/font_792726_wd5lzuxvvh.eot?#iefix) format('embedded-opentype'),url(https://at.alicdn.com/t/font_792726_wd5lzuxvvh.woff) format('woff'),url(https://at.alicdn.com/t/font_792726_wd5lzuxvvh.ttf) format('truetype'),url(https://at.alicdn.com/t/font_792726_wd5lzuxvvh.svg#iconfont) format('svg')}#PHONE-DROP div,#PHONE-DROP li,#PHONE-DROP span,#PHONE-DROP ul{padding:0;margin:0;list-style:none;box-sizing:border-box}#PHONE-DROP ::-webkit-scrollbar,#PHONE-DROP ::-webkit-scrollbar-track{width:7px;height:7px}#PHONE-DROP ::-webkit-scrollbar-button{display:none}#PHONE-DROP ::-webkit-scrollbar-thumb{border-radius:3px;background:#dddfe0}#PHONE-DROP ::-webkit-scrollbar-track-piece{background:#fff}#PHONE-DROP input:-webkit-autofill{-webkit-box-shadow:0 0 0 1000px #fff inset}#PHONE-DROP input{vertical-align:text-top}#PHONE-DROP em{font-family:iconfont!important;font-style:normal;display:block;overflow:hidden}#PHONE-DROP span[data-type=close]{position:absolute;right:15px;top:6px;cursor:pointer;color:#999;font-size:20px;z-index:2009}#PHONE-DROP span[data-type=error]{position:absolute;top:14px;left:15px;right:50px;text-align:left;font-size:12px;color:#FD3D39;z-index:2009}#PHONE-DROP [data-disabled="0"]{cursor:wait!important;opacity:.5!important}#PHONE-DROP .arrow{width:0;height:0;position:absolute;display:inline-block;z-index:2009}#PHONE-DROP .arrow-up{border-bottom:8px solid #eff1f3;border-left:8px solid transparent;border-right:8px solid transparent;top:43px;left:14px}#PHONE-DROP{border-radius:3px;margin:0 auto}#PHONE-ENTRY-CONTAINER{position:relative}#PHONE-DROP #PHONE-ENTRY-CONTAINER div[data-toggle]{position:absolute;top:51px;left:0}#PHONE-DROP #EphoneBar{height:100%}#PHONE-DROP #EphoneBar>li{float:left;width:45px;height:50px;color:#2ea9df;text-align:center;cursor:pointer;position:relative}#PHONE-DROP #EphoneBar>li.gray{cursor:default}#EphoneBar>li>em{line-height:50px;font-size:24px}#EphoneBar>li.gray em{color:#999}#EphoneBar>li[data-phone-type=register]>span{position:absolute;bottom:10px;right:6px;width:12px;height:12px;border-radius:6px;background:#57df00}#EphoneBar>li[data-phone-type=register]>span.busy{background:#fed300}#PHONE-LEFT-STATUS{float:right;height:50px;font-size:13px;color:rgba(255,255,255,.8);overflow:hidden}#PHONE-LEFT-STATUS>div{float:left;height:inherit;position:relative}#PHONE-LEFT-STATUS div[data-type=pattern]>div{width:250px;text-align:center;height:30px;font-size:13px;margin:10px 0 10px 15px;line-height:30px;color:#999}#PHONE-LEFT-STATUS div[data-type=rect]>div{background:#1E59B9;border-radius:2px;color:#fff;width:230px;height:30px;margin:10px 0 10px 15px;border:none;font-size:13px;opacity:.87;text-align:center;line-height:30px}#PHONE-LEFT-STATUS div[data-type=planePage]>div{position:absolute;left:266px;top:28px;height:32px;width:32px;margin-top:-20px;color:#fff;text-align:center;line-height:40px;border-radius:50%;cursor:pointer;font-family:iconfont!important;font-size:20px;background:#999}#PHONE-LEFT-STATUS>div[data-type=incomingStatus]>div{position:absolute;height:30px;left:20px;margin-top:-15px;top:50%;width:260px}#PHONE-ENTRY-SELECTGROUP[data-hide],#PHONE-PANEL[data-hide]{top:51px;position:absolute;box-shadow:0 0 4px 0 rgba(0,0,0,.15),0 1px 4px 0 rgba(0,0,0,.23)}#PHONE-LEFT-STATUS>div[data-type=incomingStatus]>div>div{display:inline-block;width:180px;border-radius:2px;color:#fff;border:none;font-size:13px;opacity:.87;line-height:30px;background:#1E59B9;text-align:center}#PHONE-LEFT-STATUS>div[data-type=incomingStatus] span[data-type=answer]{margin-left:10px;display:inline-block;height:30px;width:54px;background:#4BD966;border-radius:2px;cursor:pointer;text-align:center;line-height:30px}#PHONE-ENTRY-LOGIN[data-hide]{width:300px;background:#FFF;box-shadow:0 0 4px 0 rgba(0,0,0,.15),0 1px 4px 0 rgba(0,0,0,.23);border-radius:2px;padding:20px 15px}#PHONE-ENTRY-LOGIN[data-hide] li>span{display:inline-block;color:#333}#PHONE-ENTRY-LOGIN[data-hide] li{width:100%;height:40px;border-bottom:1px solid #E7E7E7;border-radius:3px 3px 0 0;font-size:12px;line-height:42px}#PHONE-ENTRY-LOGIN[data-hide] li>input{width:160px;height:20px;display:inline-block;margin-left:10px;border:none;border-left:1px solid #E7E7E7;font-size:12px;padding:0 10px}#PHONE-ENTRY-LOGIN[data-hide] li>input:focus{outline:0}#PHONE-ENTRY-LOGIN[data-hide] li#model{text-align:left;padding-left:12px}#PHONE-ENTRY-LOGIN[data-hide] li#model>span{float:right;margin-right:15px;cursor:pointer}#PHONE-ENTRY-LOGIN[data-hide] li#model em{display:inline-block;width:10px;height:10px;border-radius:5px;background:#19c583}#PHONE-ENTRY-LOGIN[data-hide] li#model>[data-type=loginStatus].busy em{background:#fed300!important}#PHONE-ENTRY-LOGIN[data-hide] li#login{border:none;border-radius:3px}#PHONE-ENTRY-LOGIN[data-hide] li#login span{background:#2ea9df;font-size:16px;color:#FFF;height:100%;width:100%;cursor:pointer;text-align:center}#PHONE-ENTRY-TOGGLE{width:100px;position:absolute;left:-25px;top:50px;background:#fff;box-shadow:#c3c3c3 0 1px 15px;border-radius:3px}#PHONE-ENTRY-TOGGLE ul>li{padding:0 10px;height:30px;list-style:none;font-size:14px;line-height:30px;cursor:pointer}#PHONE-ENTRY-TOGGLE ul>li:hover{background:#ccc}#PHONE-ENTRY-TOGGLE ul>li[data-type=logout]{border-top:1px solid #ccc;text-align:center}#PHONE-ENTRY-TOGGLE ul>li>em{width:10px;height:10px;border-radius:5px;display:inline-block;margin-right:10px}#PHONE-ENTRY-TOGGLE ul>li[data-type=leisure]>em{background:#19C583}#PHONE-ENTRY-TOGGLE ul>li[data-type=busy]>em{background:#fed300}#PHONE-ENTRY-TOGGLE ul>li[data-type=logout]>em{width:20px;height:30px;margin-right:3px;font-size:14px;vertical-align:top}#PHONE-ENTRY-SELECTGROUP[data-hide]{width:300px;background:#FFF;border-radius:2px;padding:20px 0;font-size:14px;right:-65px;color:#333}#PHONE-ENTRY-SELECTGROUP[data-hide] div[data-type=introduce]{padding-left:15px}#PHONE-ENTRY-SELECTGROUP[data-hide] ul{width:100%;max-height:180px;overflow:auto;margin:16px 0;padding:10px 0;border-top:1px solid #EEE}#PHONE-ENTRY-SELECTGROUP[data-hide] ul>li{float:left;width:80px;height:32px;line-height:32px;background:#F2F2F2;color:#666;cursor:pointer;text-align:center;list-style:none;margin:0 0 15px 15px;border-radius:3px;font-size:12px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}#PHONE-ENTRY-SELECTGROUP[data-hide] ul>li.selected,#PHONE-ENTRY-SELECTGROUP[data-hide] ul>li:hover{background:#D7EAFF;border-radius:3px;color:#3D7FEE}#PHONE-ENTRY-SELECTGROUP[data-hide] [data-type=confirm]{margin:0 auto;width:80px;height:32px;line-height:32px;background:#2ea9df;border-radius:3px;color:#FFF;cursor:pointer;text-align:center}#PHONE-PANEL[data-hide]{width:230px;left:254px;padding:32px 24px 20px;text-align:center;background:#FFF;border-radius:2px}#PHONE-PANEL input[type=button]{width:50px;height:50px;border-radius:25px;font-size:28px;color:#333;letter-spacing:0;float:left;background:#E5E5E5;border:none;outline:0;margin-bottom:16px;cursor:pointer}#PHONE-PANEL button{width:48px;height:24px;font-size:13px;color:#fff;background:#2acf81;border:none;margin:10px;cursor:pointer}#PHONE-PANEL input[type=text]{padding:0 5px;width:186px;height:29px;margin-bottom:16px;font-size:16px;color:#333;letter-spacing:0;text-align:left;border:none;border-bottom:1px solid #E7E7E7;outline:0;border-radius:3px;background:#fff}#PHONE-PANEL [data-type=call]{width:50px;height:50px;margin:-6px auto 0;border-radius:25px;background:#19C583;display:inline-block;color:#fff;line-height:50px}#PHONE-ENTRY-SWITCH[data-hide] #SWITCH_PlATE{width:300px;box-shadow:0 0 4px 0 rgba(0,0,0,.15),0 1px 4px 0 rgba(0,0,0,.23);border-radius:2px;background:#fff;position:relative;overflow:hidden;padding:20px 0}#PHONE-ENTRY-SWITCH[data-hide] span[data-type=error]{left:15px}#PHONE-ENTRY-SWITCH[data-hide] #GROUP{margin:12px 0 15px;height:30px;width:100%;font-size:12px;color:#9B9B9B;line-height:24px;position:relative;z-index:2001}#PHONE-ENTRY-SWITCH[data-hide] #GROUP [data-type=filter]{position:absolute;left:145px;top:3px}#PHONE-ENTRY-SWITCH[data-hide='1']>#SWITCH_PlATE>ul{width:100%;min-height:34px;max-height:210px;padding:10px 0;border-top:1px solid #EEE;overflow-y:auto}#PHONE-ENTRY-SWITCH[data-hide='1']>#SWITCH_PlATE>ul>li:not([data-type=noOne]){position:relative;float:left;width:80px;height:32px;line-height:32px;background:#F2F2F2;color:#666;text-align:center;list-style:none;margin:0 0 15px 15px;border-radius:3px;font-size:12px;box-sizing:border-box;padding-left:14px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}#PHONE-ENTRY-SWITCH[data-hide='1']>#SWITCH_PlATE>ul>li[data-type=noOne]{text-align:center;list-style:none;color:#9B9B9B}#PHONE-ENTRY-SWITCH[data-hide='1']>#SWITCH_PlATE>ul>li>span{width:8px;height:8px;border-radius:4px;position:absolute;left:4px;top:13px;background:#19C583}#PHONE-ENTRY-SWITCH[data-hide='1']>#SWITCH_PlATE>ul>li[data-status=busy],#PHONE-ENTRY-SWITCH[data-hide='1']>#SWITCH_PlATE>ul>li[data-status=offLine]{background:rgba(227,227,227,.7)}#PHONE-ENTRY-SWITCH[data-hide='1']>#SWITCH_PlATE>ul>li[data-status_code="1"]:hover{background:rgba(61,127,238,.12);color:#3D7FEE;cursor:pointer}#PHONE-ENTRY-SWITCH[data-hide='1']>#SWITCH_PlATE>ul>li[data-status=busy]>span{background:#FED300}#PHONE-ENTRY-SWITCH[data-hide='1']>#SWITCH_PlATE>ul>li[data-status=offLine]>span{background:#a6a6a6}#PHONE-ENTRY-SWITCH[data-hide='1']>#SWITCH_PlATE>ul>li.selected{background:rgba(61,127,238,.12);color:#3D7FEE}#PHONE-ENTRY-SWITCH[data-hide='1'] div[data-type=transfer]{width:80px;height:32px;line-height:32px;font-size:14px;margin:15px auto 0;background:#2ea9df;border-radius:3px;color:#FFF;text-align:center;cursor:pointer}#PHONE-ENTRY-SETTING[data-hide]{width:300px;right:0;top:51px;background:#FFF;box-shadow:0 0 4px 0 rgba(0,0,0,.15),0 1px 4px 0 rgba(0,0,0,.23);border-radius:2px}#PHONE-ENTRY-SETTING[data-hide]>div.arrow{left:320px}#PHONE-ENTRY-SETTING[data-hide]>ul{border-radius:4px;height:100%;padding:20px 15px;background:#fff}#PHONE-ENTRY-SETTING[data-hide] li{position:relative;list-style:none;text-align:left;width:100%;height:40px;border-bottom:1px solid #E7E7E7;border-radius:3px 3px 0 0;font-size:12px;line-height:42px}#PHONE-ENTRY-SETTING[data-hide] li>span{display:inline-block;color:#333;padding-left:13px}#PHONE-ENTRY-PANEL[data-hide],#PHONE-TRILATERA-SESSION{display:none;box-shadow:0 0 4px 0 rgba(0,0,0,.15),0 1px 4px 0 rgba(0,0,0,.23)}#PHONE-ENTRY-SETTING[data-hide] li#setting{margin-top:22px;border:none;border-radius:3px}#PHONE-ENTRY-SETTING[data-hide] li#confirm{border:none;border-radius:3px;text-align:center}#PHONE-ENTRY-SETTING[data-hide] li#confirm span{background:#2ea9df;font-size:15px;color:#FFF;height:100%;width:100%;cursor:pointer;padding:0}#PHONE-ENTRY-PANEL[data-hide]{z-index:2000;width:300px;padding:20px 15px;text-align:center;background:#fff;border-radius:2px}#PHONE-ENTRY-PANEL>div[data-type=inputgroup]{border-bottom:1px solid #E7E7E7;width:270px;padding:10px 15px 0}#PHONE-ENTRY-PANEL input[data-type=input]{border:none;outline:0;border-radius:3px 3px 0 0;width:100%;height:32px;font-size:12px;color:#323;letter-spacing:0}#PHONE-ENTRY-PANEL button[data-type=call]{color:#FFF;text-align:center;cursor:pointer;padding:0;width:60px;height:32px;background:#2ea9df;border-radius:3px;margin-top:15px;font-size:14px;border:none}#PHONE-TRILATERA-SESSION{width:364px;height:153px;background:#FFF;border-radius:2px;position:absolute;right:16px;top:90px;padding:20px;box-sizing:border-box}#PHONE-ENTRY-CONTAINER [data-hide='1'],#PHONE-TRILATERA-SESSION[data-hide='1']{display:block}#PHONE-TRILATERA-SESSION p{margin:13px 0;font-size:14px;position:relative}#PHONE-TRILATERA-SESSION span{display:inline-block}#PHONE-TRILATERA-SESSION [data-type=status]{color:#333}#PHONE-TRILATERA-SESSION [data-type=number]{color:#333;margin-right:40px}#PHONE-TRILATERA-SESSION [data-type=img]{color:#666;opacity:.6;font-family:iconfont!important;font-size:16px;font-style:normal;-webkit-font-smoothing:antialiased;margin-left:5px;margin-right:46px}#PHONE-TRILATERA-SESSION [data-type=cancel]{color:#666;margin-right:40px}#PHONE-TRILATERA-SESSION [data-type=redial]{color:#3D7FEE;margin-right:23px}#PHONE-TRILATERA-SESSION [data-type=hangup]{color:#666;position:absolute;right:16px}#PHONE-ENTRY-CONTAINER [data-hide='0']{display:none!important}#PHONE-DROP div[data-type=select]{width:100%;width:113px;height:30px;margin:0 16px;background:#f4f4f4;color:#838990;border:none;border-radius:3px;z-index:2001;cursor:pointer}#PHONE-DROP div[data-type=select]>div{height:100%;float:left}#PHONE-DROP div[data-type=select]>div[data-type=select_text]{width:calc(100% - 31px);border-right:1px solid rgba(61,127,238,.13);line-height:30px;text-align:center;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}#PHONE-DROP div[data-type=select]>div[data-type=select_icon]{width:30px;position:relative}#PHONE-DROP div[data-type=select]>div[data-type=select_icon]>.arrow-down{border-top:4px solid #838990;border-left:4px solid transparent;border-right:4px solid transparent;top:13px;left:11px}#PHONE-DROP ul[data-type=group]{width:113px;height:100px;position:absolute;left:16px;top:30px;overflow:auto;z-index:100}#PHONE-DROP ul[data-type=group] li{height:30px;list-style:none;line-height:30px;text-align:center;background:#fff;color:#838990;cursor:pointer}#PHONE-DROP ul[data-type=group] li:hover{background:#f4f4f4}