| 123456789101112131415161718192021222324252627282930313233343536373839404142434445 |
- !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.UCloudRTC=t():e.UCloudRTC=t()}(window,(function(){return function(e){var t={};function r(n){if(t[n])return t[n].exports;var o=t[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)r.d(n,o,function(t){return e[t]}.bind(null,o));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=44)}([function(e,t,r){"use strict";(function(e){var r;Object.defineProperty(t,"__esModule",{value:!0}),function(e){e[e.debug=0]="debug",e[e.info=1]="info",e[e.warn=2]="warn",e[e.error=3]="error"}(r=t.ENUM_LOG_LEVEL||(t.ENUM_LOG_LEVEL={}));var n=r.warn,o=function(){function t(e){this.level=n,null!=e&&(this.level=e)}return t.prototype.setLogLevel=function(e){switch(e){case"debug":this.level=r.debug;break;case"info":this.level=r.info;break;case"warn":this.level=r.warn;break;case"error":default:this.level=r.error}},t.prototype.debug=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this.level<=r.debug&&console.info.apply(console,[new Date+" [DEBUG]: "].concat(e))},t.prototype.info=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this.level<=r.info&&console.info.apply(console,[new Date+" [INFO]: "].concat(e))},t.prototype.warn=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this.level<=r.warn&&console.warn.apply(console,[new Date+" [WARN]: "].concat(e))},t.prototype.error=function(){for(var t=this,n=[],o=0;o<arguments.length;o++)n[o]=arguments[o];this.level<=r.error&&(console.error.apply(console,[new Date+" [ERROR]: "].concat(n)),e((function(){t.onError(n)})))},t.prototype.onLog=function(e){},t.prototype.onWarn=function(e){},t.prototype.onError=function(e){},t}();t.Logger=o,t.default=new o}).call(this,r(19).setImmediate)},function(e,t,r){"use strict";var n=r(22),o=r(50),i=Object.prototype.toString;function a(e){return"[object Array]"===i.call(e)}function s(e){return null!==e&&"object"==typeof e}function c(e){return"[object Function]"===i.call(e)}function u(e,t){if(null!=e)if("object"!=typeof e&&(e=[e]),a(e))for(var r=0,n=e.length;r<n;r++)t.call(null,e[r],r,e);else for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&t.call(null,e[o],o,e)}e.exports={isArray:a,isArrayBuffer:function(e){return"[object ArrayBuffer]"===i.call(e)},isBuffer:o,isFormData:function(e){return"undefined"!=typeof FormData&&e instanceof FormData},isArrayBufferView:function(e){return"undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer.isView(e):e&&e.buffer&&e.buffer instanceof ArrayBuffer},isString:function(e){return"string"==typeof e},isNumber:function(e){return"number"==typeof e},isObject:s,isUndefined:function(e){return void 0===e},isDate:function(e){return"[object Date]"===i.call(e)},isFile:function(e){return"[object File]"===i.call(e)},isBlob:function(e){return"[object Blob]"===i.call(e)},isFunction:c,isStream:function(e){return s(e)&&c(e.pipe)},isURLSearchParams:function(e){return"undefined"!=typeof URLSearchParams&&e instanceof URLSearchParams},isStandardBrowserEnv:function(){return("undefined"==typeof navigator||"ReactNative"!==navigator.product&&"NativeScript"!==navigator.product&&"NS"!==navigator.product)&&("undefined"!=typeof window&&"undefined"!=typeof document)},forEach:u,merge:function e(){var t={};function r(r,n){"object"==typeof t[n]&&"object"==typeof r?t[n]=e(t[n],r):t[n]=r}for(var n=0,o=arguments.length;n<o;n++)u(arguments[n],r);return t},deepMerge:function e(){var t={};function r(r,n){"object"==typeof t[n]&&"object"==typeof r?t[n]=e(t[n],r):t[n]="object"==typeof r?e({},r):r}for(var n=0,o=arguments.length;n<o;n++)u(arguments[n],r);return t},extend:function(e,t,r){return u(t,(function(t,o){e[o]=r&&"function"==typeof t?n(t,r):t})),e},trim:function(e){return e.replace(/^\s*/,"").replace(/\s*$/,"")}}},function(e,t,r){"use strict";r.r(t),r.d(t,"__extends",(function(){return o})),r.d(t,"__assign",(function(){return i})),r.d(t,"__rest",(function(){return a})),r.d(t,"__decorate",(function(){return s})),r.d(t,"__param",(function(){return c})),r.d(t,"__metadata",(function(){return u})),r.d(t,"__awaiter",(function(){return d})),r.d(t,"__generator",(function(){return p})),r.d(t,"__exportStar",(function(){return f})),r.d(t,"__values",(function(){return l})),r.d(t,"__read",(function(){return m})),r.d(t,"__spread",(function(){return h})),r.d(t,"__spreadArrays",(function(){return v})),r.d(t,"__await",(function(){return g})),r.d(t,"__asyncGenerator",(function(){return y})),r.d(t,"__asyncDelegator",(function(){return b})),r.d(t,"__asyncValues",(function(){return E})),r.d(t,"__makeTemplateObject",(function(){return _})),r.d(t,"__importStar",(function(){return S})),r.d(t,"__importDefault",(function(){return T}));
- /*! *****************************************************************************
- Copyright (c) Microsoft Corporation. All rights reserved.
- Licensed under the Apache License, Version 2.0 (the "License"); you may not use
- this file except in compliance with the License. You may obtain a copy of the
- License at http://www.apache.org/licenses/LICENSE-2.0
- THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
- WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
- MERCHANTABLITY OR NON-INFRINGEMENT.
- See the Apache Version 2.0 License for specific language governing permissions
- and limitations under the License.
- ***************************************************************************** */
- var n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)};function o(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}var i=function(){return(i=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)};function a(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(e);o<n.length;o++)t.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(e,n[o])&&(r[n[o]]=e[n[o]])}return r}function s(e,t,r,n){var o,i=arguments.length,a=i<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,r,n);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,r,a):o(t,r))||a);return i>3&&a&&Object.defineProperty(t,r,a),a}function c(e,t){return function(r,n){t(r,n,e)}}function u(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)}function d(e,t,r,n){return new(r||(r=Promise))((function(o,i){function a(e){try{c(n.next(e))}catch(e){i(e)}}function s(e){try{c(n.throw(e))}catch(e){i(e)}}function c(e){e.done?o(e.value):new r((function(t){t(e.value)})).then(a,s)}c((n=n.apply(e,t||[])).next())}))}function p(e,t){var r,n,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(i){return function(s){return function(i){if(r)throw new TypeError("Generator is already executing.");for(;a;)try{if(r=1,n&&(o=2&i[0]?n.return:i[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,i[1])).done)return o;switch(n=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,n=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===i[0]||2===i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){a.label=i[1];break}if(6===i[0]&&a.label<o[1]){a.label=o[1],o=i;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(i);break}o[2]&&a.ops.pop(),a.trys.pop();continue}i=t.call(e,a)}catch(e){i=[6,e],n=0}finally{r=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,s])}}}function f(e,t){for(var r in e)t.hasOwnProperty(r)||(t[r]=e[r])}function l(e){var t="function"==typeof Symbol&&e[Symbol.iterator],r=0;return t?t.call(e):{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}}}function m(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,o,i=r.call(e),a=[];try{for(;(void 0===t||t-- >0)&&!(n=i.next()).done;)a.push(n.value)}catch(e){o={error:e}}finally{try{n&&!n.done&&(r=i.return)&&r.call(i)}finally{if(o)throw o.error}}return a}function h(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(m(arguments[t]));return e}function v(){for(var e=0,t=0,r=arguments.length;t<r;t++)e+=arguments[t].length;var n=Array(e),o=0;for(t=0;t<r;t++)for(var i=arguments[t],a=0,s=i.length;a<s;a++,o++)n[o]=i[a];return n}function g(e){return this instanceof g?(this.v=e,this):new g(e)}function y(e,t,r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var n,o=r.apply(e,t||[]),i=[];return n={},a("next"),a("throw"),a("return"),n[Symbol.asyncIterator]=function(){return this},n;function a(e){o[e]&&(n[e]=function(t){return new Promise((function(r,n){i.push([e,t,r,n])>1||s(e,t)}))})}function s(e,t){try{(r=o[e](t)).value instanceof g?Promise.resolve(r.value.v).then(c,u):d(i[0][2],r)}catch(e){d(i[0][3],e)}var r}function c(e){s("next",e)}function u(e){s("throw",e)}function d(e,t){e(t),i.shift(),i.length&&s(i[0][0],i[0][1])}}function b(e){var t,r;return t={},n("next"),n("throw",(function(e){throw e})),n("return"),t[Symbol.iterator]=function(){return this},t;function n(n,o){t[n]=e[n]?function(t){return(r=!r)?{value:g(e[n](t)),done:"return"===n}:o?o(t):t}:o}}function E(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t,r=e[Symbol.asyncIterator];return r?r.call(e):(e=l(e),t={},n("next"),n("throw"),n("return"),t[Symbol.asyncIterator]=function(){return this},t);function n(r){t[r]=e[r]&&function(t){return new Promise((function(n,o){(function(e,t,r,n){Promise.resolve(n).then((function(t){e({value:t,done:r})}),t)})(n,o,(t=e[r](t)).done,t.value)}))}}}function _(e,t){return Object.defineProperty?Object.defineProperty(e,"raw",{value:t}):e.raw=t,e}function S(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t}function T(e){return e&&e.__esModule?e:{default:e}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(75);t.ErrorCodes=n.ErrorCodes,t.createError=function(e,t){var r,n=e;t&&"[object Error]"===Object.prototype.toString.call(t)?(r=t.message,n="Error"===t.name?e:t.name):r="string"==typeof t?t:"null";var o=new Error(r);return o.name=n,o}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),function(e){e[e.pushStream=0]="pushStream",e[e.pullStream=1]="pullStream",e[e.allStream=2]="allStream"}(t.ENUM_ROLE_TYPE||(t.ENUM_ROLE_TYPE={})),function(e){e[e.rtc=0]="rtc",e[e.live=1]="live"}(t.ENUM_ROOM_TYPE||(t.ENUM_ROOM_TYPE={})),function(e){e[e.publish=1]="publish",e[e.subscribe=2]="subscribe"}(t.ENUM_STREAM_TYPE||(t.ENUM_STREAM_TYPE={})),function(e){e[e.none=0]="none",e[e.sd=1]="sd",e[e.hd=2]="hd",e[e.hdp=3]="hdp"}(t.ENUM_VP_LEVEL||(t.ENUM_VP_LEVEL={})),function(e){e[e.camera=1]="camera",e[e.desktop=2]="desktop"}(t.ENUM_MEDIA_TYPE||(t.ENUM_MEDIA_TYPE={})),function(e){e[e.userJoin=1]="userJoin",e[e.userLeave=2]="userLeave"}(t.ENUM_USER_CMD_TYPE||(t.ENUM_USER_CMD_TYPE={})),function(e){e[e.add=1]="add",e[e.remove=2]="remove"}(t.ENUM_STREAM_CMD_TYPE||(t.ENUM_STREAM_CMD_TYPE={})),function(e){e[e.audio=1]="audio",e[e.video=2]="video",e[e.data=3]="data"}(t.ENUM_TRACK_TYPE||(t.ENUM_TRACK_TYPE={})),function(e){e[e.audio=1]="audio",e[e.video=2]="video",e[e.audioVideo=3]="audioVideo"}(t.ENUM_RECORD_MIME||(t.ENUM_RECORD_MIME={})),function(e){e[e.lt=1]="lt",e[e.lb=2]="lb",e[e.rt=3]="rt",e[e.rb=4]="rb"}(t.ENUM_WATER_MARK_POS||(t.ENUM_WATER_MARK_POS={})),function(e){e[e.none=0]="none",e[e.time=1]="time",e[e.image=2]="image",e[e.text=3]="text"}(t.ENUM_WATER_MARK_TYPE||(t.ENUM_WATER_MARK_TYPE={})),function(e){e[e.unjoin=1]="unjoin",e[e.joining=2]="joining",e[e.leaving=3]="leaving",e[e.joined=4]="joined",e[e.rejoining=5]="rejoining"}(t.ENUM_ROOM_STATUS||(t.ENUM_ROOM_STATUS={})),function(e){e[e.unpublish=1]="unpublish",e[e.publishing=2]="publishing",e[e.unpublishing=3]="unpublishing",e[e.published=4]="published"}(t.ENUM_PUBLISH_STATUS||(t.ENUM_PUBLISH_STATUS={})),function(e){e[e.unsubscribe=1]="unsubscribe",e[e.subscribing=2]="subscribing",e[e.unsubscribing=3]="unsubscribing",e[e.subscribed=4]="subscribed"}(t.ENUM_SUBSCRIBE_STATUS||(t.ENUM_SUBSCRIBE_STATUS={})),function(e){e[e.unrecord=1]="unrecord",e[e.starting=2]="starting",e[e.stopping=3]="stopping",e[e.recording=4]="recording"}(t.ENUM_RECORD_STATUS||(t.ENUM_RECORD_STATUS={})),function(e){e[e.relay=1]="relay",e[e.record=2]="record",e[e.relayRecord=3]="relayRecord",e[e.update=4]="update"}(t.ENUM_MIX_TYPE||(t.ENUM_MIX_TYPE={})),function(e){e[e.flow=1]="flow",e[e.main=2]="main",e[e.custom=3]="custom",e[e.customMain=4]="customMain",e[e.customFlow=5]="customFlow",e[e.single=6]="single"}(t.ENUM_MIX_LAYOUT||(t.ENUM_MIX_LAYOUT={})),function(e){e[e.audioVideo=0]="audioVideo",e[e.audio=1]="audio"}(t.ENUM_MIX_OUTPUT_MODE||(t.ENUM_MIX_OUTPUT_MODE={})),function(e){e[e.auto=1]="auto",e[e.manual=2]="manual"}(t.ENUM_MIX_STREAM_ADD_MODE||(t.ENUM_MIX_STREAM_ADD_MODE={}))},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(76).getParser(window.navigator.userAgent);function o(){var e=n.getBrowser(),t=n.getPlatform();return{name:e.name||"unknown",version:e.version||"unknown",isMobile:"mobile"===t.type}}function i(){var e=n.getOS();return{name:e.name||"unknown",version:e.version||"unknown",versionName:e.versionName||"unknown"}}t.isMobile=function(){return"mobile"===n.getPlatformType()},t.getBrowserInfo=o,t.getSystemInfo=i,t.getDeviceInfo=function(){var e=n.getOS(),t=n.getBrowser();return{vendor:e.name||"unknown",brand:t.name||"unknown",model:t.version||"unknown"}},t.getNetworkInfo=function(){return{network:""}},t.getCPUInfo=function(){return{brand:"",model:"",core:null!=window.navigator.hardwareConcurrency?window.navigator.hardwareConcurrency:0}},t.getMemInfo=function(){return{capacity:0}};var a={isSafari:function(){return"safari"===o().name.toLowerCase()},isChrome:function(){return"chrome"===o().name.toLowerCase()},isFirefox:function(){return"firefox"===o().name.toLowerCase()},isEdge:function(){return"microsoft edge"===o().name.toLowerCase()},isIOS:function(){return"ios"===i().name.toLowerCase()}};t.default=a},function(e,t,r){"use strict";var n,o="object"==typeof Reflect?Reflect:null,i=o&&"function"==typeof o.apply?o.apply:function(e,t,r){return Function.prototype.apply.call(e,t,r)};n=o&&"function"==typeof o.ownKeys?o.ownKeys:Object.getOwnPropertySymbols?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:function(e){return Object.getOwnPropertyNames(e)};var a=Number.isNaN||function(e){return e!=e};function s(){s.init.call(this)}e.exports=s,s.EventEmitter=s,s.prototype._events=void 0,s.prototype._eventsCount=0,s.prototype._maxListeners=void 0;var c=10;function u(e){return void 0===e._maxListeners?s.defaultMaxListeners:e._maxListeners}function d(e,t,r,n){var o,i,a,s;if("function"!=typeof r)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof r);if(void 0===(i=e._events)?(i=e._events=Object.create(null),e._eventsCount=0):(void 0!==i.newListener&&(e.emit("newListener",t,r.listener?r.listener:r),i=e._events),a=i[t]),void 0===a)a=i[t]=r,++e._eventsCount;else if("function"==typeof a?a=i[t]=n?[r,a]:[a,r]:n?a.unshift(r):a.push(r),(o=u(e))>0&&a.length>o&&!a.warned){a.warned=!0;var c=new Error("Possible EventEmitter memory leak detected. "+a.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");c.name="MaxListenersExceededWarning",c.emitter=e,c.type=t,c.count=a.length,s=c,console&&console.warn&&console.warn(s)}return e}function p(){for(var e=[],t=0;t<arguments.length;t++)e.push(arguments[t]);this.fired||(this.target.removeListener(this.type,this.wrapFn),this.fired=!0,i(this.listener,this.target,e))}function f(e,t,r){var n={fired:!1,wrapFn:void 0,target:e,type:t,listener:r},o=p.bind(n);return o.listener=r,n.wrapFn=o,o}function l(e,t,r){var n=e._events;if(void 0===n)return[];var o=n[t];return void 0===o?[]:"function"==typeof o?r?[o.listener||o]:[o]:r?function(e){for(var t=new Array(e.length),r=0;r<t.length;++r)t[r]=e[r].listener||e[r];return t}(o):h(o,o.length)}function m(e){var t=this._events;if(void 0!==t){var r=t[e];if("function"==typeof r)return 1;if(void 0!==r)return r.length}return 0}function h(e,t){for(var r=new Array(t),n=0;n<t;++n)r[n]=e[n];return r}Object.defineProperty(s,"defaultMaxListeners",{enumerable:!0,get:function(){return c},set:function(e){if("number"!=typeof e||e<0||a(e))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+e+".");c=e}}),s.init=function(){void 0!==this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},s.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||a(e))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+e+".");return this._maxListeners=e,this},s.prototype.getMaxListeners=function(){return u(this)},s.prototype.emit=function(e){for(var t=[],r=1;r<arguments.length;r++)t.push(arguments[r]);var n="error"===e,o=this._events;if(void 0!==o)n=n&&void 0===o.error;else if(!n)return!1;if(n){var a;if(t.length>0&&(a=t[0]),a instanceof Error)throw a;var s=new Error("Unhandled error."+(a?" ("+a.message+")":""));throw s.context=a,s}var c=o[e];if(void 0===c)return!1;if("function"==typeof c)i(c,this,t);else{var u=c.length,d=h(c,u);for(r=0;r<u;++r)i(d[r],this,t)}return!0},s.prototype.addListener=function(e,t){return d(this,e,t,!1)},s.prototype.on=s.prototype.addListener,s.prototype.prependListener=function(e,t){return d(this,e,t,!0)},s.prototype.once=function(e,t){if("function"!=typeof t)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof t);return this.on(e,f(this,e,t)),this},s.prototype.prependOnceListener=function(e,t){if("function"!=typeof t)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof t);return this.prependListener(e,f(this,e,t)),this},s.prototype.removeListener=function(e,t){var r,n,o,i,a;if("function"!=typeof t)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof t);if(void 0===(n=this._events))return this;if(void 0===(r=n[e]))return this;if(r===t||r.listener===t)0==--this._eventsCount?this._events=Object.create(null):(delete n[e],n.removeListener&&this.emit("removeListener",e,r.listener||t));else if("function"!=typeof r){for(o=-1,i=r.length-1;i>=0;i--)if(r[i]===t||r[i].listener===t){a=r[i].listener,o=i;break}if(o<0)return this;0===o?r.shift():function(e,t){for(;t+1<e.length;t++)e[t]=e[t+1];e.pop()}(r,o),1===r.length&&(n[e]=r[0]),void 0!==n.removeListener&&this.emit("removeListener",e,a||t)}return this},s.prototype.off=s.prototype.removeListener,s.prototype.removeAllListeners=function(e){var t,r,n;if(void 0===(r=this._events))return this;if(void 0===r.removeListener)return 0===arguments.length?(this._events=Object.create(null),this._eventsCount=0):void 0!==r[e]&&(0==--this._eventsCount?this._events=Object.create(null):delete r[e]),this;if(0===arguments.length){var o,i=Object.keys(r);for(n=0;n<i.length;++n)"removeListener"!==(o=i[n])&&this.removeAllListeners(o);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if("function"==typeof(t=r[e]))this.removeListener(e,t);else if(void 0!==t)for(n=t.length-1;n>=0;n--)this.removeListener(e,t[n]);return this},s.prototype.listeners=function(e){return l(this,e,!0)},s.prototype.rawListeners=function(e){return l(this,e,!1)},s.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):m.call(e,t)},s.prototype.listenerCount=m,s.prototype.eventNames=function(){return this._eventsCount>0?n(this._events):[]}},function(e,t,r){"use strict";var n={generateIdentifier:function(){return Math.random().toString(36).substr(2,10)}};n.localCName=n.generateIdentifier(),n.splitLines=function(e){return e.trim().split("\n").map((function(e){return e.trim()}))},n.splitSections=function(e){return e.split("\nm=").map((function(e,t){return(t>0?"m="+e:e).trim()+"\r\n"}))},n.getDescription=function(e){var t=n.splitSections(e);return t&&t[0]},n.getMediaSections=function(e){var t=n.splitSections(e);return t.shift(),t},n.matchPrefix=function(e,t){return n.splitLines(e).filter((function(e){return 0===e.indexOf(t)}))},n.parseCandidate=function(e){for(var t,r={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],address:t[4],port:parseInt(t[5],10),type:t[7]},n=8;n<t.length;n+=2)switch(t[n]){case"raddr":r.relatedAddress=t[n+1];break;case"rport":r.relatedPort=parseInt(t[n+1],10);break;case"tcptype":r.tcpType=t[n+1];break;case"ufrag":r.ufrag=t[n+1],r.usernameFragment=t[n+1];break;default:r[t[n]]=t[n+1]}return r},n.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.address||e.ip),t.push(e.port);var r=e.type;return t.push("typ"),t.push(r),"host"!==r&&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(" ")},n.parseIceOptions=function(e){return e.substr(14).split(" ")},n.parseRtpMap=function(e){var t=e.substr(9).split(" "),r={payloadType:parseInt(t.shift(),10)};return t=t[0].split("/"),r.name=t[0],r.clockRate=parseInt(t[1],10),r.channels=3===t.length?parseInt(t[2],10):1,r.numChannels=r.channels,r},n.writeRtpMap=function(e){var t=e.payloadType;void 0!==e.preferredPayloadType&&(t=e.preferredPayloadType);var r=e.channels||e.numChannels||1;return"a=rtpmap:"+t+" "+e.name+"/"+e.clockRate+(1!==r?"/"+r:"")+"\r\n"},n.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]}},n.writeExtmap=function(e){return"a=extmap:"+(e.id||e.preferredId)+(e.direction&&"sendrecv"!==e.direction?"/"+e.direction:"")+" "+e.uri+"\r\n"},n.parseFmtp=function(e){for(var t,r={},n=e.substr(e.indexOf(" ")+1).split(";"),o=0;o<n.length;o++)r[(t=n[o].trim().split("="))[0].trim()]=t[1];return r},n.writeFmtp=function(e){var t="",r=e.payloadType;if(void 0!==e.preferredPayloadType&&(r=e.preferredPayloadType),e.parameters&&Object.keys(e.parameters).length){var n=[];Object.keys(e.parameters).forEach((function(t){e.parameters[t]?n.push(t+"="+e.parameters[t]):n.push(t)})),t+="a=fmtp:"+r+" "+n.join(";")+"\r\n"}return t},n.parseRtcpFb=function(e){var t=e.substr(e.indexOf(" ")+1).split(" ");return{type:t.shift(),parameter:t.join(" ")}},n.writeRtcpFb=function(e){var t="",r=e.payloadType;return void 0!==e.preferredPayloadType&&(r=e.preferredPayloadType),e.rtcpFeedback&&e.rtcpFeedback.length&&e.rtcpFeedback.forEach((function(e){t+="a=rtcp-fb:"+r+" "+e.type+(e.parameter&&e.parameter.length?" "+e.parameter:"")+"\r\n"})),t},n.parseSsrcMedia=function(e){var t=e.indexOf(" "),r={ssrc:parseInt(e.substr(7,t-7),10)},n=e.indexOf(":",t);return n>-1?(r.attribute=e.substr(t+1,n-t-1),r.value=e.substr(n+1)):r.attribute=e.substr(t+1),r},n.parseSsrcGroup=function(e){var t=e.substr(13).split(" ");return{semantics:t.shift(),ssrcs:t.map((function(e){return parseInt(e,10)}))}},n.getMid=function(e){var t=n.matchPrefix(e,"a=mid:")[0];if(t)return t.substr(6)},n.parseFingerprint=function(e){var t=e.substr(14).split(" ");return{algorithm:t[0].toLowerCase(),value:t[1]}},n.getDtlsParameters=function(e,t){return{role:"auto",fingerprints:n.matchPrefix(e+t,"a=fingerprint:").map(n.parseFingerprint)}},n.writeDtlsParameters=function(e,t){var r="a=setup:"+t+"\r\n";return e.fingerprints.forEach((function(e){r+="a=fingerprint:"+e.algorithm+" "+e.value+"\r\n"})),r},n.getIceParameters=function(e,t){var r=n.splitLines(e);return{usernameFragment:(r=r.concat(n.splitLines(t))).filter((function(e){return 0===e.indexOf("a=ice-ufrag:")}))[0].substr(12),password:r.filter((function(e){return 0===e.indexOf("a=ice-pwd:")}))[0].substr(10)}},n.writeIceParameters=function(e){return"a=ice-ufrag:"+e.usernameFragment+"\r\na=ice-pwd:"+e.password+"\r\n"},n.parseRtpParameters=function(e){for(var t={codecs:[],headerExtensions:[],fecMechanisms:[],rtcp:[]},r=n.splitLines(e)[0].split(" "),o=3;o<r.length;o++){var i=r[o],a=n.matchPrefix(e,"a=rtpmap:"+i+" ")[0];if(a){var s=n.parseRtpMap(a),c=n.matchPrefix(e,"a=fmtp:"+i+" ");switch(s.parameters=c.length?n.parseFmtp(c[0]):{},s.rtcpFeedback=n.matchPrefix(e,"a=rtcp-fb:"+i+" ").map(n.parseRtcpFb),t.codecs.push(s),s.name.toUpperCase()){case"RED":case"ULPFEC":t.fecMechanisms.push(s.name.toUpperCase())}}}return n.matchPrefix(e,"a=extmap:").forEach((function(e){t.headerExtensions.push(n.parseExtmap(e))})),t},n.writeRtpDescription=function(e,t){var r="";r+="m="+e+" ",r+=t.codecs.length>0?"9":"0",r+=" UDP/TLS/RTP/SAVPF ",r+=t.codecs.map((function(e){return void 0!==e.preferredPayloadType?e.preferredPayloadType:e.payloadType})).join(" ")+"\r\n",r+="c=IN IP4 0.0.0.0\r\n",r+="a=rtcp:9 IN IP4 0.0.0.0\r\n",t.codecs.forEach((function(e){r+=n.writeRtpMap(e),r+=n.writeFmtp(e),r+=n.writeRtcpFb(e)}));var o=0;return t.codecs.forEach((function(e){e.maxptime>o&&(o=e.maxptime)})),o>0&&(r+="a=maxptime:"+o+"\r\n"),r+="a=rtcp-mux\r\n",t.headerExtensions&&t.headerExtensions.forEach((function(e){r+=n.writeExtmap(e)})),r},n.parseRtpEncodingParameters=function(e){var t,r=[],o=n.parseRtpParameters(e),i=-1!==o.fecMechanisms.indexOf("RED"),a=-1!==o.fecMechanisms.indexOf("ULPFEC"),s=n.matchPrefix(e,"a=ssrc:").map((function(e){return n.parseSsrcMedia(e)})).filter((function(e){return"cname"===e.attribute})),c=s.length>0&&s[0].ssrc,u=n.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]===c&&(t=u[0][1]),o.codecs.forEach((function(e){if("RTX"===e.name.toUpperCase()&&e.parameters.apt){var n={ssrc:c,codecPayloadType:parseInt(e.parameters.apt,10)};c&&t&&(n.rtx={ssrc:t}),r.push(n),i&&((n=JSON.parse(JSON.stringify(n))).fec={ssrc:c,mechanism:a?"red+ulpfec":"red"},r.push(n))}})),0===r.length&&c&&r.push({ssrc:c});var d=n.matchPrefix(e,"b=");return d.length&&(d=0===d[0].indexOf("b=TIAS:")?parseInt(d[0].substr(7),10):0===d[0].indexOf("b=AS:")?1e3*parseInt(d[0].substr(5),10)*.95-16e3:void 0,r.forEach((function(e){e.maxBitrate=d}))),r},n.parseRtcpParameters=function(e){var t={},r=n.matchPrefix(e,"a=ssrc:").map((function(e){return n.parseSsrcMedia(e)})).filter((function(e){return"cname"===e.attribute}))[0];r&&(t.cname=r.value,t.ssrc=r.ssrc);var o=n.matchPrefix(e,"a=rtcp-rsize");t.reducedSize=o.length>0,t.compound=0===o.length;var i=n.matchPrefix(e,"a=rtcp-mux");return t.mux=i.length>0,t},n.parseMsid=function(e){var t,r=n.matchPrefix(e,"a=msid:");if(1===r.length)return{stream:(t=r[0].substr(7).split(" "))[0],track:t[1]};var o=n.matchPrefix(e,"a=ssrc:").map((function(e){return n.parseSsrcMedia(e)})).filter((function(e){return"msid"===e.attribute}));return o.length>0?{stream:(t=o[0].value.split(" "))[0],track:t[1]}:void 0},n.parseSctpDescription=function(e){var t,r=n.parseMLine(e),o=n.matchPrefix(e,"a=max-message-size:");o.length>0&&(t=parseInt(o[0].substr(19),10)),isNaN(t)&&(t=65536);var i=n.matchPrefix(e,"a=sctp-port:");if(i.length>0)return{port:parseInt(i[0].substr(12),10),protocol:r.fmt,maxMessageSize:t};if(n.matchPrefix(e,"a=sctpmap:").length>0){var a=n.matchPrefix(e,"a=sctpmap:")[0].substr(10).split(" ");return{port:parseInt(a[0],10),protocol:a[1],maxMessageSize:t}}},n.writeSctpDescription=function(e,t){var r=[];return r="DTLS/SCTP"!==e.protocol?["m="+e.kind+" 9 "+e.protocol+" "+t.protocol+"\r\n","c=IN IP4 0.0.0.0\r\n","a=sctp-port:"+t.port+"\r\n"]:["m="+e.kind+" 9 "+e.protocol+" "+t.port+"\r\n","c=IN IP4 0.0.0.0\r\n","a=sctpmap:"+t.port+" "+t.protocol+" 65535\r\n"],void 0!==t.maxMessageSize&&r.push("a=max-message-size:"+t.maxMessageSize+"\r\n"),r.join("")},n.generateSessionId=function(){return Math.random().toString().substr(2,21)},n.writeSessionBoilerplate=function(e,t,r){var o=void 0!==t?t:2;return"v=0\r\no="+(r||"thisisadapterortc")+" "+(e||n.generateSessionId())+" "+o+" IN IP4 127.0.0.1\r\ns=-\r\nt=0 0\r\n"},n.writeMediaSection=function(e,t,r,o){var i=n.writeRtpDescription(e.kind,t);if(i+=n.writeIceParameters(e.iceGatherer.getLocalParameters()),i+=n.writeDtlsParameters(e.dtlsTransport.getLocalParameters(),"offer"===r?"actpass":"active"),i+="a=mid:"+e.mid+"\r\n",e.direction?i+="a="+e.direction+"\r\n":e.rtpSender&&e.rtpReceiver?i+="a=sendrecv\r\n":e.rtpSender?i+="a=sendonly\r\n":e.rtpReceiver?i+="a=recvonly\r\n":i+="a=inactive\r\n",e.rtpSender){var a="msid:"+o.id+" "+e.rtpSender.track.id+"\r\n";i+="a="+a,i+="a=ssrc:"+e.sendEncodingParameters[0].ssrc+" "+a,e.sendEncodingParameters[0].rtx&&(i+="a=ssrc:"+e.sendEncodingParameters[0].rtx.ssrc+" "+a,i+="a=ssrc-group:FID "+e.sendEncodingParameters[0].ssrc+" "+e.sendEncodingParameters[0].rtx.ssrc+"\r\n")}return i+="a=ssrc:"+e.sendEncodingParameters[0].ssrc+" cname:"+n.localCName+"\r\n",e.rtpSender&&e.sendEncodingParameters[0].rtx&&(i+="a=ssrc:"+e.sendEncodingParameters[0].rtx.ssrc+" cname:"+n.localCName+"\r\n"),i},n.getDirection=function(e,t){for(var r=n.splitLines(e),o=0;o<r.length;o++)switch(r[o]){case"a=sendrecv":case"a=sendonly":case"a=recvonly":case"a=inactive":return r[o].substr(2)}return t?n.getDirection(t):"sendrecv"},n.getKind=function(e){return n.splitLines(e)[0].split(" ")[0].substr(2)},n.isRejected=function(e){return"0"===e.split(" ",2)[1]},n.parseMLine=function(e){var t=n.splitLines(e)[0].substr(2).split(" ");return{kind:t[0],port:parseInt(t[1],10),protocol:t[2],fmt:t.slice(3).join(" ")}},n.parseOLine=function(e){var t=n.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]}},n.isValidSDP=function(e){if("string"!=typeof e||0===e.length)return!1;for(var t=n.splitLines(e),r=0;r<t.length;r++)if(t[r].length<2||"="!==t[r].charAt(1))return!1;return!0},e.exports=n},function(e,t){var r;r=function(){return this}();try{r=r||new Function("return this")()}catch(e){"object"==typeof window&&(r=window)}e.exports=r},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SUPPORT_RESOLUTIONS={"240*180":{width:240,height:180,minFrameRate:20,maxFrameRate:20,minVideoBW:100,maxVideoBW:200},"320*180":{width:320,height:180,minFrameRate:20,maxFrameRate:20,minVideoBW:100,maxVideoBW:300},"320*240":{width:320,height:240,minFrameRate:20,maxFrameRate:20,minVideoBW:100,maxVideoBW:400},"480*360":{width:480,height:360,minFrameRate:20,maxFrameRate:20,minVideoBW:100,maxVideoBW:400},"640*360":{width:640,height:360,minFrameRate:20,maxFrameRate:20,minVideoBW:100,maxVideoBW:500},"640*480":{width:640,height:480,minFrameRate:20,maxFrameRate:20,minVideoBW:100,maxVideoBW:600},"640*480_1":{width:640,height:480,minFrameRate:1,maxFrameRate:5,minVideoBW:100,maxVideoBW:600},"1280*720":{width:1280,height:720,minFrameRate:10,maxFrameRate:15,minVideoBW:120,maxVideoBW:1e3},"1280*720_1":{width:1280,height:720,minFrameRate:10,maxFrameRate:15,minVideoBW:120,maxVideoBW:1500},"1280*720_2":{width:1280,height:720,minFrameRate:25,maxFrameRate:30,minVideoBW:120,maxVideoBW:2e3},"1280*720_3":{width:1280,height:720,minFrameRate:1,maxFrameRate:5,minVideoBW:120,maxVideoBW:1e3},"1920*1080":{width:1920,height:1080,minFrameRate:10,maxFrameRate:15,minVideoBW:120,maxVideoBW:1500},"1920*1080_1":{width:1920,height:1080,minFrameRate:10,maxFrameRate:15,minVideoBW:120,maxVideoBW:2e3},"1920*1080_2":{width:1920,height:1080,minFrameRate:25,maxFrameRate:30,minVideoBW:120,maxVideoBW:2500},"1920*1080_3":{width:1920,height:1080,minFrameRate:1,maxFrameRate:5,minVideoBW:120,maxVideoBW:1500}},t.INTERNAL_SUPPORT_RESOLUTIONS={},t.DEFAULT_PROFILE="640*480",t.getSupportProfileNames=function(){return Object.keys(t.SUPPORT_RESOLUTIONS)},t.getInternalSupportProfileNames=function(){return Object.keys(t.INTERNAL_SUPPORT_RESOLUTIONS)},t.getResolution=function(e){var r=t.SUPPORT_RESOLUTIONS[e];return r||(r=t.INTERNAL_SUPPORT_RESOLUTIONS[e]),r||(e=t.DEFAULT_PROFILE,r=t.SUPPORT_RESOLUTIONS[e]),{profileName:e,video:{width:{ideal:r.width},height:{ideal:r.height},frameRate:{ideal:r.maxFrameRate}},attributes:{videoWidth:r.width,videoHeight:r.height,minFrameRate:r.minFrameRate,maxFrameRate:r.maxFrameRate,minVideoBW:r.minVideoBW,maxVideoBW:r.maxVideoBW}}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SERVER_CONFIG={api:"https://urtc.com.cn",log:"https://log.urtc.com.cn",signal:""},t.setServers=function(e){for(var r in t.SERVER_CONFIG)"string"==typeof e[r]?t.SERVER_CONFIG[r]=e[r]:t.SERVER_CONFIG[r]=""}},function(e,t){var r,n,o=e.exports={};function i(){throw new Error("setTimeout has not been defined")}function a(){throw new Error("clearTimeout has not been defined")}function s(e){if(r===setTimeout)return setTimeout(e,0);if((r===i||!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:i}catch(e){r=i}try{n="function"==typeof clearTimeout?clearTimeout:a}catch(e){n=a}}();var c,u=[],d=!1,p=-1;function f(){d&&c&&(d=!1,c.length?u=c.concat(u):p=-1,u.length&&l())}function l(){if(!d){var e=s(f);d=!0;for(var t=u.length;t;){for(c=u,u=[];++p<t;)c&&c[p].run();p=-1,t=u.length}c=null,d=!1,function(e){if(n===clearTimeout)return clearTimeout(e);if((n===a||!n)&&clearTimeout)return n=clearTimeout,clearTimeout(e);try{n(e)}catch(t){try{return n.call(null,e)}catch(t){return n.call(this,e)}}}(e)}}function m(e,t){this.fun=e,this.array=t}function h(){}o.nextTick=function(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var r=1;r<arguments.length;r++)t[r-1]=arguments[r];u.push(new m(e,t)),1!==u.length||d||s(l)},m.prototype.run=function(){this.fun.apply(null,this.array)},o.title="browser",o.browser=!0,o.env={},o.argv=[],o.version="",o.versions={},o.on=h,o.addListener=h,o.once=h,o.off=h,o.removeListener=h,o.removeAllListeners=h,o.emit=h,o.prependListener=h,o.prependOnceListener=h,o.listeners=function(e){return[]},o.binding=function(e){throw new Error("process.binding is not supported")},o.cwd=function(){return"/"},o.chdir=function(e){throw new Error("process.chdir is not supported")},o.umask=function(){return 0}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(13);t.RTCStream=n.RTCStream;var o=r(16);t.LocalStream=o.LocalStream;var i=r(38);t.RemoteStream=i.RemoteStream;var a=r(39);t.StreamManager=a.StreamManager;var s=r(32);t.StatsReports=s.StatsReports,t.StatsReports2=s.StatsReports2;var c=r(78);t.PreviewStreamManager=c.PreviewStreamManager},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(2);r(85);var o=r(9),i=r(0),a=r(5),s=r(32),c=r(14),u=r(15),d=r(3),p=r(33),f=function(){function e(e){this.resolution=o.getResolution(""),this.isSubscriber=!1,this.isEmitted=!1,this.firstEmitTime=Date.now(),this._connectionState=c.ENUM_STREAM_CONNECTION_STATE.closed,this.reconnectTimes=0,this.times=0,this.muteaudio=!1,this.mutevideo=!1,this.currentStatsReports=new s.StatsReports,this.currentStatsReports2=new s.StatsReports2([]),this.emitter=e,this.mediaStream=new MediaStream}return Object.defineProperty(e.prototype,"minVideoBitRate",{get:function(){return this.resolution.attributes.minVideoBW},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"maxVideoBitRate",{get:function(){return this.resolution.attributes.maxVideoBW},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"connectionState",{get:function(){return this._connectionState},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"peerConnectionState",{get:function(){return this.peerConnection?this.peerConnection.connectionState:"closed"},enumerable:!0,configurable:!0}),e.prototype.resumeAudio=function(){return this.audioHelper?this.audioHelper.resume():Promise.resolve()},e.prototype.initConnection=function(){if(this._connectionState=c.ENUM_STREAM_CONNECTION_STATE.connecting,a.default.isChrome()||a.default.isSafari()){var e={sdpSemantics:"plan-b"};this.peerConnection=new RTCPeerConnection(e)}else if(a.default.isEdge()){e={sdpSemantics:"plan-b",bundlePolicy:"max-bundle"};this.peerConnection=new RTCPeerConnection(e)}else this.peerConnection=new RTCPeerConnection;var t=this;this.peerConnection.addEventListener("iceconnectionstatechange",(function(e){var r,n;switch(i.default.debug("iceconnectionstatechange event ",this.iceConnectionState,e,null===(r=t.peerConnection)||void 0===r?void 0:r.iceConnectionState),this.iceConnectionState||(null===(n=t.peerConnection)||void 0===n?void 0:n.iceConnectionState)){case"new":case"connecting":case"checking":case"connected":case"completed":break;case"disconnected":i.default.warn("peerconnection ice disconnected");break;case"failed":i.default.warn("peerconnection ice failed")}})),this.peerConnection.addEventListener("connectionstatechange",(function(e){var r,n;switch(i.default.debug("connectionstatechange event",this.connectionState,e,null===(r=t.peerConnection)||void 0===r?void 0:r.connectionState),this.connectionState||(null===(n=t.peerConnection)||void 0===n?void 0:n.connectionState)){case"new":case"connecting":break;case"connected":t.isEmitted?t.emitter&&t.emitter.emit("stream-reconnected",t):(t.isEmitted=!0,t.firstEmitTime=Date.now(),t.setStatusAsDone(),t.emitter&&t.emitter.emit("stream-connected",t)),t._connectionState=c.ENUM_STREAM_CONNECTION_STATE.connected,t.reconnectTimes=0,t.startUploadStats();break;case"disconnected":i.default.warn("peerconnection disconnected"),t.emitter&&t.emitter.emit("stream-disconnected",t),t.stopUploadStats();break;case"failed":i.default.warn("peerconnection failed"),t.isEmitted||(t.isEmitted=!0,t.firstEmitTime=Date.now(),t.setStatusAsDone(),t.emitter&&t.emitter.emit("stream-connected",t)),t._connectionState=c.ENUM_STREAM_CONNECTION_STATE.disconnected,t.emitter&&t.emitter.emit("stream-failed",t),i.default.debug("peerconnection failed ",t.reconnectTimes,3);break;case"closed":t.stopUploadStats()}}))},e.prototype.destroyConnection=function(){if(this.stopUploadStats(),this.peerConnection){var e=this.peerConnection;this.peerConnection=void 0,e.close()}},e.prototype.setResolution=function(e){this.resolution=e},Object.defineProperty(e.prototype,"videoTrackSettings",{get:function(){var e=this.getVideoTrack();if(e)return e.getSettings();var t=this.resolution.attributes;return{width:t.videoWidth,height:t.videoHeight}},enumerable:!0,configurable:!0}),e.prototype.restart=function(){return n.__awaiter(this,void 0,void 0,(function(){var e,t;return n.__generator(this,(function(r){switch(r.label){case 0:return this.peerConnection?[4,this.peerConnection.createOffer({iceRestart:!0,offerToReceiveAudio:this.audio,offerToReceiveVideo:this.video})]:[2];case 1:return e=r.sent(),this.isSubscriber||(t=this.resolution.attributes,e.sdp&&this.video&&this.videoCodec&&(e.sdp=u.replaceSDPVideoBW(e.sdp,this.videoCodec,t),e.sdp=u.replaceSDPH264Part(e.sdp,this.videoCodec))),e.sdp&&this.video&&this.videoCodec&&(e.sdp=u.handleSDPVideoCodec(e.sdp,this.videoCodec)),e.sdp&&this.audio&&(e.sdp=u.handleSDPAudioCodec(e.sdp)),[4,this.peerConnection.setLocalDescription(e)];case 2:return r.sent(),[2]}}))}))},e.prototype.answer=function(e){return n.__awaiter(this,void 0,void 0,(function(){var t,r;return n.__generator(this,(function(n){return i.default.debug("stream manager answer: ",e),t=u.handleAnswerSDP(e.sdpcontent),r=new RTCSessionDescription({type:e.type,sdp:t}),this.peerConnection?[2,this.peerConnection.setRemoteDescription(r)]:[2,Promise.reject(d.createError(d.ErrorCodes.OTHERS,"no peerconnection"))]}))}))},e.prototype.getAudioTrack=function(){return this.isSubscriber?this.audioHelper&&this.audioHelper.srcAudioTrack:this.audioHelper&&this.audioHelper.dstAudioTrack},e.prototype.getVideoTrack=function(){return this.mediaStream.getVideoTracks()[0]},e.prototype.muteVideo=function(){var e=this;this.mutevideo=!0;var t=this.getVideoTrack();if(t){var r=function(){t.enabled=!1,e.emitter&&e.emitter.emit("video-muted",e)},n=300-(Date.now()-this.firstEmitTime);return!this.isSubscriber&&n>0?setTimeout(r,n):r(),!0}return!1},e.prototype.unmuteVideo=function(){this.mutevideo=!1;var e=this.getVideoTrack();return!!e&&(e.enabled=!0,this.emitter&&this.emitter.emit("video-unmuted",this),!0)},e.prototype.muteAudio=function(){this.muteaudio=!0;var e=this.getAudioTrack();return!!e&&(e.enabled=!1,!0)},e.prototype.unmuteAudio=function(){this.muteaudio=!1;var e=this.getAudioTrack();return!!e&&(e.enabled=!0,!0)},e.prototype.getAudioVolume=function(){return this.audioHelper?this.audioHelper.getVolume():(i.default.warn("No audio track or cannot get volume"),0)},e.prototype.setAudioVolume=function(e){if(this.audioHelper)return this.audioHelper.setVolume(e);return Promise.reject(d.createError(d.ErrorCodes.NOT_SUPPORT,"the stream doesnot contain audio or cannot set volume"))},e.prototype.getMediaStream=function(){return this.mediaStream},e.prototype.destroyMediaStream=function(e){var t=this;this.mediaStream.getTracks().forEach((function(e){t.mediaStream.removeTrack(e)})),this.audioHelper&&(e||this.audioHelper.destroy(),this.audioHelper=void 0),this.videoHelper&&(e||this.videoHelper.destroy(),this.videoHelper=void 0)},e.prototype._close=function(e){this.emitter&&this.emitter.emit("stream-close",this),this.destroyMediaStream(e),this.isEmitted=!1,this.reconnectTimes=0,this._connectionState=c.ENUM_STREAM_CONNECTION_STATE.closed,this.destroyConnection()},e.prototype.updateStatsReports=function(){var e=this;return new Promise((function(t,r){var n=e.lastStatsReports,o=e.currentStatsReports,a=new s.StatsReports;if(a.timestamp-o.timestamp<500){if(n)return void t({last:n,current:o});var c="invoke function too frequently";return i.default.warn(c),void r(d.createError(d.ErrorCodes.OTHERS,c))}if(e.peerConnection)e.peerConnection.getStats().then((function(r){r.forEach((function(e){a.original.push(e),"inbound-rtp"===e.type&&"audio"===e.mediaType&&(a.inAudioReport.bytesReceived=e.bytesReceived||a.inAudioReport.bytesReceived,a.inAudioReport.jitter=e.jitter||a.inAudioReport.jitter,a.inAudioReport.packetsLost=e.packetsLost||a.inAudioReport.packetsLost,a.inAudioReport.packetsReceived=e.packetsReceived||a.inAudioReport.packetsReceived),"inbound-rtp"===e.type&&"video"===e.mediaType&&(a.inVideoReport.bytesReceived=e.bytesReceived||a.inVideoReport.bytesReceived,a.inVideoReport.packetsLost=e.packetsLost||a.inVideoReport.packetsLost,a.inVideoReport.packetsReceived=e.packetsReceived||a.inVideoReport.packetsReceived,a.inVideoReport.firCount=e.firCount||a.inVideoReport.firCount,a.inVideoReport.nackCount=e.nackCount||a.inVideoReport.nackCount,a.inVideoReport.pliCount=e.pliCount||a.inVideoReport.pliCount,a.inVideoReport.framesDecoded=e.framesDecoded||a.inVideoReport.framesDecoded),"outbound-rtp"===e.type&&"audio"===e.mediaType&&(a.outAudioReport.bytesSent=e.bytesSent||a.outAudioReport.bytesSent,a.outAudioReport.packetsSent=e.packetsSent||a.outAudioReport.packetsSent),"outbound-rtp"===e.type&&"video"===e.mediaType&&(a.outVideoReport.bytesSent=e.bytesSent||a.outVideoReport.bytesSent,a.outVideoReport.packetsSent=e.packetsSent||a.outVideoReport.packetsSent,a.outVideoReport.firCount=e.firCount||a.outVideoReport.firCount,a.outVideoReport.nackCount=e.nackCount||a.outVideoReport.nackCount,a.outVideoReport.pliCount=e.pliCount||a.outVideoReport.pliCount,a.outVideoReport.framesEncoded=e.framesEncoded||a.outVideoReport.framesEncoded),"track"===e.type&&(a.inAudioReport.audioLevel=e.audioLevel||a.inAudioReport.audioLevel,a.inVideoReport.frameHeight=e.frameHeight||a.inVideoReport.frameHeight,a.inVideoReport.frameWidth=e.frameWidth||a.inVideoReport.frameWidth,a.inVideoReport.framesDecoded=e.framesDecoded||a.inVideoReport.framesDecoded,a.inVideoReport.framesDropped=e.framesDropped||a.inVideoReport.framesDropped,a.inVideoReport.framesReceived=e.framesReceived||a.inVideoReport.framesReceived,a.outVideoReport.frameHeight=e.frameHeight||a.outVideoReport.frameHeight,a.outVideoReport.frameWidth=e.frameWidth||a.outVideoReport.frameWidth,a.outVideoReport.framesSent=e.framesSent||a.outVideoReport.framesSent),"track"===e.type&&(a.outAudioReport.audioLevel=e.audioLevel||a.outAudioReport.audioLevel),"media-source"===e.type&&"audio"===e.kind&&(a.outAudioReport.audioLevel=e.audioLevel||a.outAudioReport.audioLevel),"outbound-rtp"===e.type&&"audio"===e.mediaType&&(a.outAudioReport.retransmittedBytesSent=e.retransmittedBytesSent||a.outAudioReport.retransmittedBytesSent,a.outAudioReport.retransmittedPacketsSent=e.retransmittedPacketsSent||a.outAudioReport.retransmittedPacketsSent),"remote-inbound-rtp"===e.type&&"audio"===e.kind&&(a.outAudioReport.jitter=e.jitter||a.outAudioReport.jitter,a.outAudioReport.roundTripTime=e.roundTripTime||a.outAudioReport.roundTripTime,a.outAudioReport.packetsLost=e.packetsLost||a.outAudioReport.packetsLost),"media-source"===e.type&&"video"===e.kind&&(a.outVideoReport.height=e.height||a.outVideoReport.height,a.outVideoReport.width=e.width||a.outVideoReport.width,a.outVideoReport.framesPerSecond=e.framesPerSecond||a.outVideoReport.framesPerSecond),"remote-inbound-rtp"===e.type&&"video"===e.kind&&(a.outVideoReport.jitter=e.jitter||a.outVideoReport.jitter,a.outVideoReport.roundTripTime=e.roundTripTime||a.outVideoReport.roundTripTime,a.outVideoReport.packetsLost=e.packetsLost||a.outVideoReport.packetsLost),"candidate-pair"===e.type&&(a.candidatePairReport.availableIncomingBitrate=e.availableIncomingBitrate||a.candidatePairReport.availableIncomingBitrate,a.candidatePairReport.availableOutgoingBitrate=e.availableOutgoingBitrate||a.candidatePairReport.availableOutgoingBitrate,a.candidatePairReport.bytesReceived=e.bytesReceived||a.candidatePairReport.bytesReceived,a.candidatePairReport.bytesSent=e.bytesSent||a.candidatePairReport.bytesSent,a.candidatePairReport.currentRoundTripTime=e.currentRoundTripTime||a.candidatePairReport.currentRoundTripTime,a.candidatePairReport.totalRoundTripTime=e.totalRoundTripTime||a.candidatePairReport.totalRoundTripTime),"local-candidate"===e.type&&(a.localCandidateReport.ip=e.ip||e.address||a.localCandidateReport.ip,a.localCandidateReport.networkType=e.networkType||a.localCandidateReport.networkType,a.localCandidateReport.port=e.port||a.localCandidateReport.port,a.localCandidateReport.protocol=e.protocol||a.localCandidateReport.protocol),"remote-candidate"===e.type&&(a.remoteCandidateReport.ip=e.ip||e.address||a.remoteCandidateReport.ip,a.remoteCandidateReport.port=e.port||a.remoteCandidateReport.port,a.remoteCandidateReport.protocol=e.protocol||a.remoteCandidateReport.protocol),"transport"===e.type&&(a.transportReport.bytesReceived=e.bytesReceived||a.transportReport.bytesReceived,a.transportReport.bytesSent=e.bytesSent||a.transportReport.bytesSent,a.transportReport.dtlsState=e.dtlsState||a.transportReport.dtlsState)})),a.timestamp=Date.now(),e.lastStatsReports=o,e.currentStatsReports=a,t({last:o,current:a})})).catch((function(e){i.default.error("update stats reports - "+e),r(e)}));else{c="no peerconnection";i.default.warn(c),r(d.createError(d.ErrorCodes.OTHERS,c))}}))},e.prototype.updateStatsReports2=function(){var e=this;return new Promise((function(t,r){return n.__awaiter(e,void 0,void 0,(function(){var e,o,a,c,u;return n.__generator(this,(function(n){switch(n.label){case 0:if(e=this.lastStatsReports2,o=this.currentStatsReports2,Date.now()-o.timestamp<500)return e?(t({last:e,current:o}),[2]):(u="invoke function too frequently",i.default.warn(u),r(d.createError(d.ErrorCodes.OTHERS,u)),[2]);if(!this.peerConnection)return[3,5];n.label=1;case 1:return n.trys.push([1,3,,4]),[4,p.getStats(this.peerConnection)];case 2:return a=n.sent(),this.lastStatsReports2=this.currentStatsReports2,this.currentStatsReports2=new s.StatsReports2(a),[3,4];case 3:return c=n.sent(),i.default.error("update stats reports - "+c),r(c),[2];case 4:return t({last:this.lastStatsReports2,current:this.currentStatsReports2}),[3,6];case 5:u="no peerconnection",i.default.warn(u),r(d.createError(d.ErrorCodes.OTHERS,u)),n.label=6;case 6:return[2]}}))}))}))},e.prototype.getStats=function(e,t){var r=this;this.updateStatsReports().then((function(n){var o=n.last,i=n.current,a=Math.round((i.timestamp-o.timestamp)/1e3);if(r.audioCodec)if(r.videoCodec){var s={br:-1,lostpre:-1,vol:-1,mime:r.audioCodec};if(r.isSubscriber){if(i.inAudioReport&&o.inAudioReport){var c=i.inAudioReport.bytesReceived-o.inAudioReport.bytesReceived,u=i.inAudioReport.packetsReceived-o.inAudioReport.packetsReceived,d=i.inAudioReport.packetsLost-o.inAudioReport.packetsLost;s.br=c>=0?Math.round(8*c/a):0,s.lostpre=d>=0&&u>0?Math.round(d/(u+d)*100):0,s.vol=Math.round(100*(i.inAudioReport.audioLevel||0))||0}}else if(i.outAudioReport&&o.outAudioReport){var p=i.outAudioReport.bytesSent-o.outAudioReport.bytesSent,f=i.outAudioReport.packetsSent-o.outAudioReport.packetsSent;d=i.outAudioReport.packetsLost-o.outAudioReport.packetsLost;s.br=p>=0?Math.round(8*p/a):0,s.lostpre=d>=0&&f>0?Math.round(d/(f+d)*100):0,s.vol=Math.round(100*(i.outAudioReport.audioLevel||0))||0}var l={br:-1,lostpre:-1,frt:-1,w:-1,h:-1,mime:r.videoCodec};if(r.isSubscriber){if(i.inVideoReport&&o.inVideoReport){c=i.inVideoReport.bytesReceived-o.inVideoReport.bytesReceived,u=i.inVideoReport.packetsReceived-o.inVideoReport.packetsReceived,d=i.inVideoReport.packetsLost-o.inVideoReport.packetsLost;var m=i.inVideoReport.framesReceived-o.inVideoReport.framesReceived;l.br=c>=0?Math.round(8*c/a):0,l.lostpre=d>=0&&u>0?Math.round(d/(u+d)*100):0,l.frt=m>=0?Math.round(m/a):0,l.w=i.inVideoReport.frameWidth||-1,l.h=i.inVideoReport.frameHeight||-1}}else if(i.outVideoReport&&o.outVideoReport){p=i.outVideoReport.bytesSent-o.outVideoReport.bytesSent,f=i.outVideoReport.packetsSent-o.outVideoReport.packetsSent,d=i.outVideoReport.packetsLost-o.outVideoReport.packetsLost;var h=i.outVideoReport.framesSent-o.outVideoReport.framesSent;l.br=p>=0?Math.round(8*p/a):0,l.lostpre=d>=0&&f>0?Math.round(d/(f+d)*100):0,l.frt=h>=0?Math.round(h/a):0,l.w=i.outVideoReport.frameWidth||i.outVideoReport.width||-1,l.h=i.outVideoReport.frameHeight||i.outVideoReport.height||-1}var v={rtt:-1,delay:-1};r.isSubscriber?i.candidatePairReport&&(v.delay=Math.round(1e3*i.candidatePairReport.currentRoundTripTime)||0):i.candidatePairReport&&(v.rtt=Math.round(1e3*i.candidatePairReport.currentRoundTripTime)||0),e({audio:s,video:l,connection:v})}else{t("no video codec settings")}else t("no audio codec settings")})).catch(t)},e.prototype.getStats2=function(){return n.__awaiter(this,void 0,void 0,(function(){var e,t,r,o,i,a,s,c,u,p,f,l,m,h,v;return n.__generator(this,(function(n){switch(n.label){case 0:return[4,this.updateStatsReports2()];case 1:if(e=n.sent(),t=e.last,r=e.current,o=Math.round((r.timestamp-t.timestamp)/1e3),!this.audioCodec)throw i="no audio codec settings",d.createError(d.ErrorCodes.OTHERS,i);if(!this.videoCodec)throw i="no video codec settings",d.createError(d.ErrorCodes.OTHERS,i);return a={br:-1,lostpre:-1,vol:-1,mime:this.audioCodec},this.isSubscriber?(c=r.audioInputReports.bytesReceived-t.audioInputReports.bytesReceived,u=r.audioInputReports.packetsReceived-t.audioInputReports.packetsReceived,m=r.audioInputReports.packetsLost-t.audioInputReports.packetsLost,a.br=c>=0?Math.round(8*c/o):0,a.lostpre=m>=0&&u>0?Math.round(m/(u+m)*100):0,a.vol=r.audioInputReports.audioLevel>=0?Math.round(100*r.audioInputReports.audioLevel):0):(f=r.audioOutputReports.bytesSent-t.audioOutputReports.bytesSent,l=r.audioOutputReports.packetsSent-t.audioOutputReports.packetsSent,m=r.audioOutputReports.packetsLost-t.audioOutputReports.packetsLost,a.br=f>=0?Math.round(8*f/o):0,a.lostpre=m>=0&&l>0?Math.round(m/(l+m)*100):0,a.vol=r.audioOutputReports.audioLevel>=0?Math.round(100*r.audioOutputReports.audioLevel):0),s={br:-1,lostpre:-1,frt:-1,w:-1,h:-1,mime:this.videoCodec},this.isSubscriber?(c=r.videoInputReports.bytesReceived-t.videoInputReports.bytesReceived,u=r.videoInputReports.packetsReceived-t.videoInputReports.packetsReceived,m=r.videoInputReports.packetsLost-t.videoInputReports.packetsLost,p=r.videoInputReports.framesReceived-t.videoInputReports.framesReceived,s.br=c>=0?Math.round(8*c/o):0,s.lostpre=m>=0&&u>0?Math.round(m/(u+m)*100):0,s.frt=p>=0?Math.round(p/o):0,s.w=r.videoInputReports.frameWidth,s.h=r.videoInputReports.frameHeight):(f=r.videoOutputReports.bytesSent-t.videoOutputReports.bytesSent,l=r.videoOutputReports.packetsSent-t.videoOutputReports.packetsSent,m=r.videoOutputReports.packetsLost-t.videoOutputReports.packetsLost,h=r.videoOutputReports.framesSent-t.videoOutputReports.framesSent,s.br=f>=0?Math.round(8*f/o):0,s.lostpre=m>=0&&l>0?Math.round(m/(l+m)*100):0,s.frt=h>=0?Math.round(h/o):0,s.w=r.videoOutputReports.frameWidth,s.h=r.videoOutputReports.frameHeight),v={rtt:-1,delay:-1},this.isSubscriber?v.delay=Math.round(1e3*r.candidatePairReports.currentRoundTripTime)||0:v.rtt=Math.round(1e3*r.candidatePairReports.currentRoundTripTime)||0,[2,{audio:a,video:s,connection:v}]}}))}))},e.prototype.getLastPeerConnectionStats=function(){return this.lastStatsReports2},e.prototype.getCurrentPeerConnectionStats=function(){return this.currentStatsReports2},e.prototype.startUploadStats=function(){var e=this;this.timer||(this.timer=window.setInterval((function(){e.getStats2().then((function(t){if(e.isSubscriber){if(!e.streamSubId)return;1e3*e.times>=3e3?(e.logReporter&&e.logReporter.reportSubscribeStatusLog(e.streamSubId,e.streamId,e.userId,e.mediaType,{delay:t.connection.delay,rtt:-1,audio:t.audio,video:t.video,cpu:0,memory:0}),e.times=0):e.times+=1}else 1e3*e.times>=3e3?(e.logReporter&&e.logReporter.reportPublishStatusLog(e.streamId,e.mediaType,{delay:-1,rtt:t.connection.rtt,audio:t.audio,video:t.video,cpu:0,memory:0}),e.times=0):e.times+=1})).catch((function(e){i.default.warn("upload stats ",e)}))}),1e3))},e.prototype.stopUploadStats=function(){this.timer&&(window.clearInterval(this.timer),this.timer=0)},e.prototype.playEffect=function(e,t,r){if(this.audioHelper)this.audioHelper.createAudioBufferSource(e,t).then((function(){r()})).catch((function(e){r(e)}));else{r("the stream cannot play audio")}},e.prototype.pauseEffect=function(e,t){if(this.audioHelper)this.audioHelper.pauseEffect(e).then((function(){t()})).catch((function(e){t(e)}));else{t("the stream cannot play audio")}},e.prototype.resumeEffect=function(e,t,r){if(this.audioHelper)this.audioHelper.resumeEffect(e,t).then((function(){r()})).catch((function(e){r(e)}));else{r("the stream cannot play audio")}},e.prototype.stopEffect=function(e,t){if(this.audioHelper)this.audioHelper.removeAudioBufferSource(e).then((function(){t()})).catch((function(e){t(e)}));else{t("the stream cannot play audio")}},e.prototype.setEffectVolume=function(e,t,r){if(this.audioHelper)this.audioHelper.setGainNodeVolume(e,t).then((function(){r()})).catch((function(e){r(e)}));else{r("the stream cannot play audio")}},e.prototype.snapshot=function(e){return this.videoHelper?this.videoHelper.snapshot(e):Promise.reject("stream has no video")},e}();t.RTCStream=f},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),function(e){e[e.none=0]="none",e[e.microphone=1]="microphone",e[e.screen=2]="screen",e[e.custom=3]="custom"}(t.ENUM_AUDIO_TYPE||(t.ENUM_AUDIO_TYPE={})),function(e){e[e.none=0]="none",e[e.camera=1]="camera",e[e.screen=2]="screen",e[e.custom=3]="custom",e[e.image=4]="image"}(t.ENUM_VIDEO_TYPE||(t.ENUM_VIDEO_TYPE={})),function(e){e[e.closed=0]="closed",e[e.connecting=1]="connecting",e[e.connected=2]="connected",e[e.reconnecting=3]="reconnecting",e[e.disconnected=4]="disconnected"}(t.ENUM_STREAM_CONNECTION_STATE||(t.ENUM_STREAM_CONNECTION_STATE={}))},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(5);t.replaceSDPVideoBW=function(e,t,r){var n,o=e.match(/m=video.*\r\n/);if(o){n=o[0]+"b=AS:"+r.maxVideoBW+"\r\n";var i=void 0,a=void 0;"h264"===t?(i=e.search(/a=rtpmap:(\d+) H264\/90000\r\n/),a=e.search(/H264\/90000\r\n/)):"vp8"===t&&(i=e.search(/a=rtpmap:(\d+) VP8\/90000\r\n/),a=e.search(/VP8\/90000\r\n/)),i&&a&&a-i>10&&(n=n+"a=fmtp:"+e.slice(i+9,a-1)+" x-google-min-bitrate="+r.minVideoBW+"\r\n"),e=e.replace(o[0],n)}return e},t.handleSDPVideoCodec=function(e,t){var r,n,o=/m=video \d+ .*\r\n/.exec(e);if("h264"===t)r=/a=rtpmap:\d+ H264\/90000\r\n/,n=/H264\/90000\r\n/;else{if("vp8"!==t)return e;r=/a=rtpmap:\d+ VP8\/90000\r\n/,n=/VP8\/90000\r\n/}if(o){var i=void 0,a=e.search(r),s=e.search(n);if(a&&s&&s-a>10&&(i=e.slice(a+9,s-1)),!i)return e;var c=o[0],u=/(\d+ *)+\r\n$/.exec(c);if(u){var d=u[0],p=d.split(" "),f=p.indexOf(i);f>0&&(p.splice(f,1),p.unshift(i));var l=c.replace(d,p.join(" "));e=e.replace(c,l)}}return e},t.handleSDPAudioCodec=function(e){var t=/m=audio \d+ .*\r\n/.exec(e);if(t){var r=void 0,n=e.search(/a=rtpmap:\d+ opus\/48000\/2\r\n/),o=e.search(/opus\/48000\/2\r\n/);if(n&&o&&o-n>10&&(r=e.slice(n+9,o-1)),!r)return e;var i=t[0],a=/(\d+ *)+\r\n$/.exec(i);if(a){var s=a[0],c=s.split(" "),u=c.indexOf(r);u>0&&(c.splice(u,1),c.unshift(r));var d=i.replace(s,c.join(" "));e=e.replace(i,d)}}return e},t.replaceSDPH264Part=function(e,t){return"h264"===t&&n.default.isSafari(),e},t.handleAnswerSDP=function(e){var t=e.match(/a=x-google-flag:conference\r\n/);return t&&(e=e.replace(t[0],"")),e}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(2),o=r(13),i=r(0),a=r(17),s=r(34),c=r(35),u=r(4),d=r(5),p=r(14),f=r(15),l=r(3),m=function(e){function t(t,r,n){var o=e.call(this,n)||this;return o.status=u.ENUM_PUBLISH_STATUS.unpublish,o.audioType=p.ENUM_AUDIO_TYPE.none,o.videoType=p.ENUM_VIDEO_TYPE.none,o.vp=u.ENUM_VP_LEVEL.none,o.userId=t,o.streamType=u.ENUM_STREAM_TYPE.publish,o.mediaType=r.mediaType,o.muteaudio=!1,o.mutevideo=!1,o.config=r,r.audio&&(o.audioType=p.ENUM_AUDIO_TYPE.microphone),r.video&&(o.videoType=p.ENUM_VIDEO_TYPE.camera),r.screen&&!r.audio&&r.screenAudio&&(o.audioType=p.ENUM_AUDIO_TYPE.screen),r.screen&&!r.video&&(o.videoType=p.ENUM_VIDEO_TYPE.screen),o}return n.__extends(t,e),Object.defineProperty(t.prototype,"audio",{get:function(){return this.config.audio||this.audioType!==p.ENUM_AUDIO_TYPE.none},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"video",{get:function(){return this.config.video||this.videoType!==p.ENUM_VIDEO_TYPE.none},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"isPreview",{get:function(){return!!this.previewId&&this.previewId===this.streamId},enumerable:!0,configurable:!0}),t.prototype.updateVP=function(){var e=this.videoTrackSettings,t=e.width*e.height;this.vp=t>921600?u.ENUM_VP_LEVEL.hdp:t>230400?u.ENUM_VP_LEVEL.hd:u.ENUM_VP_LEVEL.sd},Object.defineProperty(t.prototype,"canUnPublish",{get:function(){var e=!0;switch(this.status){case u.ENUM_PUBLISH_STATUS.unpublish:case u.ENUM_PUBLISH_STATUS.publishing:case u.ENUM_PUBLISH_STATUS.unpublishing:e=!1;break;case u.ENUM_PUBLISH_STATUS.published:default:e=!0}return e},enumerable:!0,configurable:!0}),t.prototype.applyResolution=function(e){var t=this.getVideoTrack();return t?t.applyConstraints(e.video):Promise.reject(l.createError(l.ErrorCodes.OTHERS,"no video track found"))},t.prototype.getScreenMediaStream=function(e){return n.__awaiter(this,void 0,void 0,(function(){var t,r,o,a,s,c,u,p,f,m;return n.__generator(this,(function(n){switch(n.label){case 0:if(t=e.width,r=e.height,o=e.frameRate,a=this.config,!d.default.isChrome()||!a.extensionId)return[3,5];n.label=1;case 1:return n.trys.push([1,3,,4]),[4,new Promise((function(e,n){window.chrome.runtime.sendMessage(a.extensionId,{},(function(a){if(i.default.debug("local stream (chrome extension) response ",a),!a){var s=l.createError(l.ErrorCodes.OTHERS,"chrome extension - no response");return n(s)}if("success"!==a.type){s=l.createError(l.ErrorCodes.OTHERS,"chrome extension - response error");return n(s)}var c=a.options,u={audio:!!(void 0===c?{canRequestAudioTrack:!1}:c).canRequestAudioTrack&&{mandatory:{chromeMediaSource:"desktop",chromeMediaSourceId:a.streamId}},video:{mandatory:{chromeMediaSource:"desktop",chromeMediaSourceId:a.streamId,maxWidth:t,maxHeight:r,maxFrameRate:o}}};if(navigator.mediaDevices.getUserMedia)navigator.mediaDevices.getUserMedia(u).then(e).catch(n);else if(navigator.webkitGetUserMedia)navigator.webkitGetUserMedia(u,e,n);else{s=l.createError(l.ErrorCodes.NOT_SUPPORT,"browser no support screen share");n(s)}}))}))];case 2:return s=n.sent(),i.default.debug("local stream (chrome extension) - ",s),[3,4];case 3:throw c=n.sent(),i.default.warn("chrome extend stream - get screen "+c),c;case 4:return[3,17];case 5:if(!navigator.mediaDevices.getDisplayMedia)return[3,16];n.label=6;case 6:return n.trys.push([6,8,,15]),p={video:{width:{ideal:t},height:{ideal:r},frameRate:o}},this.config.screenAudio&&(p.audio=!0),[4,navigator.mediaDevices.getDisplayMedia(p)];case 7:return s=n.sent(),i.default.debug("local stream - ",s),[3,15];case 8:if(u=n.sent(),i.default.warn("local stream - get screen with video constraints "+u),!(u.message.indexOf("Audio only requests are not supported")>=0))return[3,13];n.label=9;case 9:return n.trys.push([9,11,,12]),p={video:!0},this.config.screenAudio&&(p.audio=!0),[4,navigator.mediaDevices.getDisplayMedia(p)];case 10:return s=n.sent(),[3,12];case 11:throw f=n.sent(),i.default.warn("local stream - get screen without video constraints "+f),u;case 12:return[3,14];case 13:throw u;case 14:return[3,15];case 15:return[3,17];case 16:throw m=l.createError(l.ErrorCodes.NOT_SUPPORT,"browser no support screen share"),i.default.warn("local stream - get screen "+m),m;case 17:return[2,s]}}))}))},t.prototype.addTracks2MediaStream=function(){return n.__awaiter(this,void 0,void 0,(function(){var e,t,r,o,u,d,f,l=this;return n.__generator(this,(function(n){switch(n.label){case 0:if(e=this.config,t={audio:!1,video:!1},e.audio&&e.microphoneId?t.audio={deviceId:{exact:e.microphoneId}}:e.audio&&(t.audio=!0),r=this.resolution,o=r.video,u=r.attributes,e.video&&e.cameraId?(t.video={deviceId:e.cameraId,width:o.width,height:o.height,frameRate:o.frameRate},e.facingMode&&(t.video.facingMode={exact:e.facingMode})):e.video&&(t.video={width:o.width,height:o.height,frameRate:o.frameRate},e.facingMode&&(t.video.facingMode={exact:e.facingMode})),!t.audio&&!t.video)return[3,4];n.label=1;case 1:return n.trys.push([1,3,,4]),[4,navigator.mediaDevices.getUserMedia(t)];case 2:return n.sent().getTracks().forEach((function(e){if(i.default.debug("local stream - add track ",e),"audio"===e.kind){l.audioHelper=new a.AudioHelper(e);var t=l.getAudioTrack();t&&l.mediaStream.addTrack(t),l.audioType=p.ENUM_AUDIO_TYPE.microphone}"video"===e.kind&&(l.videoHelper=new s.VideoHelper(e,l.resolution.attributes),l.mediaStream.addTrack(e),l.videoType=p.ENUM_VIDEO_TYPE.camera)})),[3,4];case 3:throw d=n.sent(),t.audio&&this.logReporter&&this.logReporter.reportExceptionLog(c.ENUM_LOG_EXCEPTION_TYPE.getMicrophones,{msg:""+d}),t.video&&this.logReporter&&this.logReporter.reportExceptionLog(c.ENUM_LOG_EXCEPTION_TYPE.getCameras,{msg:""+d}),i.default.warn("local stream - get user media "+d),d;case 4:if(t.audio&&t.video||!e.screen)return[3,8];n.label=5;case 5:return n.trys.push([5,7,,8]),[4,this.getScreenMediaStream({width:u.videoWidth,height:u.videoHeight,frameRate:u.maxFrameRate})];case 6:return n.sent().getTracks().forEach((function(t){i.default.debug("local stream - add screen track ",t);var r=l;if(t.onended=function(e){i.default.debug("screen track ended ",this.readyState,e),"video"===this.kind&&r.getVideoTrack()===this&&r.emitter&&r.emitter.emit("screen-track-ended",r)},"audio"===t.kind&&!e.audio){l.audioHelper=new a.AudioHelper(t);var n=l.getAudioTrack();n&&l.mediaStream.addTrack(n),l.audioType=p.ENUM_AUDIO_TYPE.screen}"video"!==t.kind||e.video||(l.videoHelper=new s.VideoHelper(t,l.resolution.attributes),l.mediaStream.addTrack(t),l.videoType=p.ENUM_VIDEO_TYPE.screen)})),[3,8];case 7:throw f=n.sent(),i.default.error("local stream - get screen "+f),f;case 8:return[2]}}))}))},t.prototype.addTracks2MediaStream2=function(e){var t=this;return new Promise((function(r){e.getTracks().forEach((function(e){if(i.default.debug("local stream - add track ",e),"audio"===e.kind){t.audioHelper=new a.AudioHelper(e);var r=t.getAudioTrack();r&&t.mediaStream.addTrack(r),t.audioType=p.ENUM_AUDIO_TYPE.custom}"video"===e.kind&&(t.videoHelper=new s.VideoHelper(e,t.resolution.attributes),t.mediaStream.addTrack(e),t.videoType=p.ENUM_VIDEO_TYPE.custom)})),r()}))},t.prototype.addTracks2MediaStream3=function(e){return n.__awaiter(this,void 0,void 0,(function(){var t,r,o,u,d,f,m,h,v,g,y=this;return n.__generator(this,(function(n){switch(n.label){case 0:if(t=this.config,r={audio:!1,video:!1},t.audio&&t.microphoneId?r.audio={deviceId:{exact:t.microphoneId}}:t.audio&&(r.audio=!0),!r.audio)return[3,4];n.label=1;case 1:return n.trys.push([1,3,,4]),[4,navigator.mediaDevices.getUserMedia(r)];case 2:return(v=n.sent()).getTracks().forEach((function(e){if(i.default.debug("local stream - add track ",e),"audio"===e.kind){y.audioHelper=new a.AudioHelper(e);var t=y.getAudioTrack();t&&y.mediaStream.addTrack(t),y.audioType=p.ENUM_AUDIO_TYPE.microphone}})),[3,4];case 3:throw o=n.sent(),r.audio&&this.logReporter&&this.logReporter.reportExceptionLog(c.ENUM_LOG_EXCEPTION_TYPE.getMicrophones,{msg:""+o}),i.default.warn("local stream - get image stream "+o),o;case 4:return n.trys.push([4,6,,7]),u=this.resolution.attributes,d=u.videoWidth,f=u.videoHeight,m=u.maxFrameRate,h=this,[4,s.VideoHelper.createImageStream(e,d,f,m)];case 5:if(h.imageStream=n.sent(),!(v=this.imageStream.mediaStream)||!v.getVideoTracks()[0])throw this.destroyImageStream(),l.createError(l.ErrorCodes.CREATE_STREAM,"cannot create media stream by image");return this.videoHelper=new s.VideoHelper(v.getVideoTracks()[0],this.resolution.attributes),this.mediaStream.addTrack(v.getVideoTracks()[0]),this.videoType=p.ENUM_VIDEO_TYPE.image,[3,7];case 6:throw g=n.sent(),i.default.error("local stream - get image stream "+g),g;case 7:return[2]}}))}))},t.prototype.addTracks2MediaStream4=function(e){var t=this;return new Promise((function(r){e.audioHelper&&(t.audioHelper=e.audioHelper,(n=e.getAudioTrack())&&t.mediaStream.addTrack(n),t.audioType=e.audioType);if(e.videoHelper){var n;if(t.videoHelper=e.videoHelper,n=e.getVideoTrack()){if(e.videoType===p.ENUM_VIDEO_TYPE.screen){var o=t;n.onended=function(e){i.default.debug("screen track ended ",this.readyState,e),"video"===this.kind&&o.getVideoTrack()===this&&o.emitter&&o.emitter.emit("screen-track-ended",o)}}t.mediaStream.addTrack(n)}t.videoType=e.videoType}e.imageStream&&(t.imageStream=e.imageStream),t.resolution=e.resolution,r()}))},t.prototype.init=function(e,t){var r=this;return new Promise((function(o,i){return n.__awaiter(r,void 0,void 0,(function(){var r;return n.__generator(this,(function(n){switch(n.label){case 0:this.isPreview||this.initConnection(),this.initMediaStream(),n.label=1;case 1:return n.trys.push([1,10,,11]),t?(this.previewId=t.previewId,this.muteaudio=t.muteaudio,this.mutevideo=t.mutevideo,[4,this.addTracks2MediaStream4(t)]):[3,3];case 2:return n.sent(),[3,9];case 3:return e.mediaStream?[4,this.addTracks2MediaStream2(e.mediaStream)]:[3,5];case 4:return n.sent(),[3,9];case 5:return e.file||e.filePath?[4,this.addTracks2MediaStream3(e.file||e.filePath)]:[3,7];case 6:return n.sent(),[3,9];case 7:return[4,this.addTracks2MediaStream()];case 8:n.sent(),n.label=9;case 9:return[3,11];case 10:return r=n.sent(),[2,i(r)];case 11:return this.isPreview||this.addTracks2PeerConnection(),o(this.mediaStream),[2]}}))}))}))},t.prototype.initMediaStream=function(){var e,t=new MediaStream;this.audioHelper&&((e=this.getAudioTrack())&&t.addTrack(e));this.videoHelper&&((e=this.videoHelper.dstVideoTrack)&&t.addTrack(e));this.mediaStream=t},t.prototype.addTracks2PeerConnection=function(){var e,t=new MediaStream;this.audioHelper&&((e=this.getAudioTrack())&&(t.addTrack(e),this.peerConnection&&this.peerConnection.addTrack(e,t)));this.videoHelper&&((e=this.videoHelper.dstVideoTrack)&&(t.addTrack(e),this.peerConnection&&this.peerConnection.addTrack(e,t)))},t.prototype.connect=function(e){return n.__awaiter(this,void 0,void 0,(function(){var t,r,o;return n.__generator(this,(function(n){switch(n.label){case 0:this.streamId=e,n.label=1;case 1:if(n.trys.push([1,4,,5]),!this.peerConnection)throw l.createError(l.ErrorCodes.OTHERS,"no peerconnection");if(!this.videoCodec)throw l.createError(l.ErrorCodes.OTHERS,"no video codec settings");return[4,this.peerConnection.createOffer({offerToReceiveAudio:this.audio,offerToReceiveVideo:this.video})];case 2:return t=n.sent(),r=this.resolution.attributes,t.sdp&&this.video&&(t.sdp=f.replaceSDPVideoBW(t.sdp,this.videoCodec,r),t.sdp=f.replaceSDPH264Part(t.sdp,this.videoCodec)),t.sdp&&this.video&&this.videoCodec&&(t.sdp=f.handleSDPVideoCodec(t.sdp,this.videoCodec)),t.sdp&&this.audio&&(t.sdp=f.handleSDPAudioCodec(t.sdp)),[4,this.peerConnection.setLocalDescription(t)];case 3:return n.sent(),[2,t];case 4:throw o=n.sent(),i.default.error("peerconnection create offer error "+o),o;case 5:return[2]}}))}))},t.prototype.setStatusAsDone=function(){this.status=u.ENUM_PUBLISH_STATUS.published},t.prototype.close=function(e){this.destroyImageStream(e),this._close(e),this.status=u.ENUM_PUBLISH_STATUS.unpublish},t.prototype.destroyImageStream=function(e){this.imageStream&&!e&&this.imageStream.destroy(),this.imageStream=void 0},t.prototype.switchMicrophone=function(e){return n.__awaiter(this,void 0,void 0,(function(){var t,r,o,a,s;return n.__generator(this,(function(n){switch(n.label){case 0:if(!this.audio)throw o="stream does not include audio track, cannot switch microphone",i.default.warn("switch microphone - ",o),l.createError(l.ErrorCodes.OTHERS,o);n.label=1;case 1:return n.trys.push([1,3,,4]),[4,navigator.mediaDevices.getUserMedia({audio:{deviceId:{exact:e}}})];case 2:if(t=n.sent(),!(r=t.getAudioTracks()[0]))throw o="no audio track, cannot switch microphone",i.default.warn("switch microphone - ",o),l.createError(l.ErrorCodes.OTHERS,o);return(a=this.audioHelper&&this.audioHelper.updateAudioSourceTrack(r))&&a.stop(),this.config.microphoneId=e,this.audioType=p.ENUM_AUDIO_TYPE.microphone,[3,4];case 3:throw s=n.sent(),i.default.error("switch microphone - "+s),s;case 4:return[2]}}))}))},t.prototype.switchCamera=function(e){var t;return n.__awaiter(this,void 0,void 0,(function(){var r,o,a,s,c,d;return n.__generator(this,(function(n){switch(n.label){case 0:if(!this.video)throw r="stream does not include video track, cannot switch camera",i.default.warn("switch camera - ",r),l.createError(l.ErrorCodes.OTHERS,r);if(this.mediaType!==u.ENUM_MEDIA_TYPE.camera)throw r="the mediaType of current stream isnot camera, cannot switch",i.default.warn("switch camera - ",r),l.createError(l.ErrorCodes.OTHERS,r);n.label=1;case 1:return n.trys.push([1,3,,4]),o=this.resolution.video,a={video:{deviceId:e,width:o.width,height:o.height,frameRate:o.frameRate}},[4,navigator.mediaDevices.getUserMedia(a)];case 2:s=n.sent(),c=s.getVideoTracks()[0],this.destroyImageStream();try{this.replaceVideoTrack(c)}catch(e){throw null===(t=c)||void 0===t||t.stop(),e}return this.config.cameraId=e,this.videoType=p.ENUM_VIDEO_TYPE.camera,[3,4];case 3:throw d=n.sent(),i.default.error("switch camera - "+d),d;case 4:return[2]}}))}))},t.prototype.switchScreen=function(){return n.__awaiter(this,void 0,void 0,(function(){var e,t,r,o=this;return n.__generator(this,(function(n){switch(n.label){case 0:if(!this.video)throw e="stream does not include video track, cannot switch screen",i.default.warn("switch screen - ",e),l.createError(l.ErrorCodes.OTHERS,e);if(this.mediaType!==u.ENUM_MEDIA_TYPE.desktop)throw e="the mediaType of current stream isnot screen, cannot switch",i.default.warn("switch screen - ",e),l.createError(l.ErrorCodes.OTHERS,e);t=this.resolution.attributes,n.label=1;case 1:return n.trys.push([1,3,,4]),[4,this.getScreenMediaStream({width:t.videoWidth,height:t.videoHeight,frameRate:t.maxFrameRate})];case 2:return n.sent().getTracks().forEach((function(e){var t;i.default.debug("local stream - add screen track ",e);var r=o;if(e.onended=function(e){i.default.debug("screen track ended ",this.readyState,e),"video"===this.kind&&r.getVideoTrack()===this&&r.emitter&&r.emitter.emit("screen-track-ended",r)},"audio"===e.kind&&o.audio&&o.audioHelper){var n=o.audioHelper.updateAudioSourceTrack(e);n&&n.stop(),o.audioType=p.ENUM_AUDIO_TYPE.screen}if("video"===e.kind&&o.video){o.destroyImageStream();try{o.replaceVideoTrack(e)}catch(r){throw null===(t=e)||void 0===t||t.stop(),i.default.warn("switch screen - "+r),l.createError(l.ErrorCodes.STREAM_NOT_EXISTS,"stream may not exists")}o.videoType=p.ENUM_VIDEO_TYPE.screen}})),[3,4];case 3:throw r=n.sent(),i.default.error("switch screen - "+r),r;case 4:return[2]}}))}))},t.prototype.switchImage=function(e){var t;return n.__awaiter(this,void 0,void 0,(function(){var r,o,a,s,c;return n.__generator(this,(function(n){switch(n.label){case 0:if(!this.video)throw a="stream does not include video track, cannot switch image",i.default.warn("switch image - ",a),l.createError(l.ErrorCodes.OTHERS,a);n.label=1;case 1:if(n.trys.push([1,3,,4]),!this.videoHelper)throw a="the stream has no video",i.default.warn("switch image - ",a),l.createError(l.ErrorCodes.OTHERS,a);return r=this,[4,this.videoHelper.createImageStream(e)];case 2:if(r.imageStream=n.sent(),!(o=this.imageStream.mediaStream)||!o.getVideoTracks()[0])throw a=l.createError(l.ErrorCodes.CREATE_STREAM,"cannot create media stream by image");s=o.getVideoTracks()[0];try{this.replaceVideoTrack(s)}catch(e){throw null===(t=s)||void 0===t||t.stop(),e}return this.videoType=p.ENUM_VIDEO_TYPE.image,[3,4];case 3:throw c=n.sent(),i.default.error("switch image - "+c),c;case 4:return[2]}}))}))},t.prototype.replaceAudioTrack=function(e,t){var r=this.audioHelper&&this.audioHelper.srcAudioTrack;if(!r)throw l.createError(l.ErrorCodes.AUDIO_TRACK_NOT_EXISTS,"cannot find audio track to be replaced");return this.audioHelper&&this.audioHelper.updateAudioSourceTrack(e),t||r.stop(),r},t.prototype.replaceVideoTrack=function(e,t){var r=this,n=this.getVideoTrack();if(!n)throw l.createError(l.ErrorCodes.VIDEO_TRACK_NOT_EXISTS,"cannot find video track to be replaced");return this.peerConnection?this.peerConnection.getSenders().forEach((function(o){o.track&&"video"===o.track.kind&&(o.replaceTrack(e),r.mediaStream.removeTrack(n),r.mediaStream.addTrack(e),r.videoHelper&&r.videoHelper.updateVideoSourceTrack(e),t||n.stop())})):(this.mediaStream.removeTrack(n),this.mediaStream.addTrack(e),this.videoHelper&&this.videoHelper.updateVideoSourceTrack(e),t||n.stop()),n},t.prototype.replaceTrack=function(e,t){try{var r=void 0;if(e&&"audio"===e.kind)r=this.replaceAudioTrack(e,t);else{if(!e||"video"!==e.kind)throw l.createError(l.ErrorCodes.INVALID_PARAMETER,"unsupported track");r=this.replaceVideoTrack(e,t)}return r}catch(e){throw e}},t.prototype.convertToOuterStream=function(){var e;switch(this.mediaType){case u.ENUM_MEDIA_TYPE.desktop:e="screen";break;case u.ENUM_MEDIA_TYPE.camera:default:e="camera"}var t=this.isPreview||this.status===u.ENUM_PUBLISH_STATUS.published,r={sid:this.streamId,uid:this.userId,type:"publish",mediaType:e,audio:this.audio,video:this.video,muteAudio:this.muteaudio,muteVideo:this.mutevideo,mediaStream:t?this.mediaStream:void 0};return this.previewId&&(r.previewId=this.previewId,r.mediaStream=this.mediaStream),r},t}(o.RTCStream);t.LocalStream=m},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n,o=r(2),i=r(21),a=r(0),s=r(5),c=i.default.create({responseType:"arraybuffer"}),u=window.AudioContext||window.webkitAudioContext||window.mozAudioContext||window.msAudioContext||window.oAudioContext;!function(e){e[e.init=1]="init",e[e.play=2]="play",e[e.pause=3]="pause"}(n||(n={}));var d=function(e){this.state=n.init,this.startedAt=-1,this.pausedAt=-1,this.config=e},p=function(){};t.CachedAudioBuffer=p;var f=function(){function e(e){var t=this;if(this.effects=new Map,this.mediaStream=new MediaStream,this.mediaStream.addTrack(e),this.audioContext=new u,this.audioContext){var r;s.default.isSafari()&&(this.audioContext.onstatechange=function(){"interrupted"===t.audioContext.state&&t.audioContext.resume()}),this.sourceNode=this.audioContext.createMediaStreamSource(this.mediaStream),"function"==typeof this.audioContext.createMediaStreamDestination?(this.gainNode=this.audioContext.createGain(),this.destinationNode=this.audioContext.createMediaStreamDestination(),this.sourceNode.connect(this.gainNode),this.gainNode.connect(this.destinationNode),r=this.destinationNode.stream):r=this.mediaStream;var n=this.audioContext.createMediaStreamSource(r);this.analyser=this.audioContext.createAnalyser(),this.timeDomainData=new Uint8Array(this.analyser.frequencyBinCount),n.connect(this.analyser)}else a.default.error("cannot create audioContext")}return Object.defineProperty(e.prototype,"srcAudioTrack",{get:function(){return this.mediaStream.getAudioTracks()[0]},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"dstAudioTrack",{get:function(){return this.destinationNode?this.destinationNode.stream.getAudioTracks()[0]:this.mediaStream.getAudioTracks()[0]},enumerable:!0,configurable:!0}),e.prototype.resume=function(){return this.audioContext?this.audioContext.resume():Promise.resolve()},e.prototype.destroy=function(){this.effects.forEach((function(e){e.bufferSourceNode.stop()})),this.mediaStream.getAudioTracks().forEach((function(e){e.stop()})),this.audioContext&&this.audioContext.close()},e.prototype.updateAudioSourceTrack=function(e){var t=this.srcAudioTrack;t&&e?(this.mediaStream.removeTrack(t),this.mediaStream.addTrack(e)):e&&this.mediaStream.addTrack(e);var r=this.audioContext.createMediaStreamSource(this.mediaStream);return this.gainNode?(this.sourceNode.disconnect(this.gainNode),this.sourceNode=r,this.sourceNode.connect(this.gainNode)):this.sourceNode=r,t},e.prototype.getVolume=function(){var e=0;return this.analyser&&(this.analyser.getByteTimeDomainData(this.timeDomainData),this.timeDomainData.forEach((function(t){e=Math.max(e,Math.abs(t-128))}))),e/128},e.prototype.setVolume=function(e){return this.gainNode?(this.gainNode.gain.value=e/100,Promise.resolve()):Promise.reject("cannot find gain node")},e.loadAudioBuffer=function(e,t,r){var n=new u;return new Promise((function(o,i){if(!n){var s="cannot create audioContext";return a.default.error("loadAudioBuffer - ",s),void i(s)}if(e[t]){s="the effect Id already exists";return a.default.error("loadAudioBuffer - ",s),void i(s)}c.get(r).then((function(i){n.decodeAudioData(i.data).then((function(n){e[t]={filePath:r,audioBuffer:n},o(n)}))})).catch((function(e){i(e)}))}))},e.unloadAudioBuffer=function(e,t){delete e[t]},e.prototype.createAudioBufferSource=function(t,r){var i=this;return new Promise((function(s,c){return o.__awaiter(i,void 0,void 0,(function(){var i,u,p,f,l,m,h=this;return o.__generator(this,(function(o){switch(o.label){case 0:if(!this.destinationNode)return[2,c(m="this browser not support the API")];if(i=this.effects[r.effectId])switch(m=void 0,i.state){case n.pause:break;case n.play:return[2,c(m="the effect is playing")];case n.init:default:return[2,c(m="the effect is initing")]}return t[r.effectId]?(f=t[r.effectId],r.filePath&&r.filePath!==f.filePath?(m="wrong effectId or filepath, the effect "+r.effectId+" cached filepath is "+f.filePath,[2,c(m)]):(u=f.audioBuffer,i=new d(Object.assign({loop:!1,playTime:0},r,{filePath:f.filePath})),[3,7])):[3,1];case 1:if(!r.filePath)return[3,6];o.label=2;case 2:return o.trys.push([2,4,,5]),[4,e.loadAudioBuffer(t,r.effectId,r.filePath)];case 3:return u=o.sent(),i=new d(Object.assign({loop:!1,playTime:0},r,{filePath:r.filePath})),[3,5];case 4:return l=o.sent(),a.default.error("createAudioBufferSource - ",l),[2,c(l)];case 5:return[3,7];case 6:return m="cannot find effect and no filepath in options to create new one",a.default.error("createAudioBufferSource - ",m),[2,c(m)];case 7:try{i.bufferSourceNode=p=this.audioContext.createBufferSource(),i.bufferSourceNode.buffer=u,i.gainNode=this.audioContext.createGain(),i.bufferSourceNode.connect(i.gainNode),i.gainNode.connect(this.destinationNode),i.bufferSourceNode.loop=i.config.loop,this.effects[i.config.effectId]=i,i.bufferSourceNode.addEventListener("ended",(function(){i.state!==n.pause&&delete h.effects[i.config.effectId]}),{once:!0}),i.config.replace&&this.gainNode&&this.sourceNode.disconnect(this.gainNode),i.bufferSourceNode.start(0,i.config.playTime%u.duration),i.startedAt=Date.now(),i.state=n.play}catch(e){return a.default.error("createAudioBufferSource - ",e),[2,c(e)]}return s(p),[2]}}))}))}))},e.prototype.removeAudioBufferSource=function(e){var t=this;return new Promise((function(r,o){var i=t.effects[e];if(i){switch(i.state){case n.pause:delete t.effects[e];break;case n.play:i.bufferSourceNode.stop();break;case n.init:default:return o("the effect is initing")}r()}else{o("cannot find effect "+e)}}))},e.prototype.setGainNodeVolume=function(e,t){var r=this;return new Promise((function(o,i){var a=r.effects[e];if(a){switch(a.state){case n.play:return a.gainNode.gain.value=t/100,o();case n.pause:return i("the effect is paused");case n.init:default:return i("the effect is initing")}}else{i("cannot find effect "+e)}}))},e.prototype.pauseEffect=function(e){var t=this;return new Promise((function(r,o){var i=t.effects[e];if(!i)return o("cannot find effect "+e);switch(i.state){case n.play:return i.state=n.pause,i.bufferSourceNode.stop(),i.pausedAt=Date.now(),r();case n.pause:return o("the effect is paused");case n.init:default:return o("the effect is initing")}}))},e.prototype.resumeEffect=function(e,t){var r=this;return new Promise((function(o,i){var a=r.effects[t];if(!a)return i("cannot find effect "+t);switch(a.state){case n.play:return i("the effect is playing");case n.pause:var s=Object.assign({},a.config,{playTime:a.config.playTime+(a.pausedAt-a.startedAt)/1e3});r.createAudioBufferSource(e,s).then(o).catch(i);break;case n.init:default:return i("the effect is initing")}}))},e}();t.AudioHelper=f},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.version="1.5.20"},function(e,t,r){(function(e){var n=void 0!==e&&e||"undefined"!=typeof self&&self||window,o=Function.prototype.apply;function i(e,t){this._id=e,this._clearFn=t}t.setTimeout=function(){return new i(o.call(setTimeout,n,arguments),clearTimeout)},t.setInterval=function(){return new i(o.call(setInterval,n,arguments),clearInterval)},t.clearTimeout=t.clearInterval=function(e){e&&e.close()},i.prototype.unref=i.prototype.ref=function(){},i.prototype.close=function(){this._clearFn.call(n,this._id)},t.enroll=function(e,t){clearTimeout(e._idleTimeoutId),e._idleTimeout=t},t.unenroll=function(e){clearTimeout(e._idleTimeoutId),e._idleTimeout=-1},t._unrefActive=t.active=function(e){clearTimeout(e._idleTimeoutId);var t=e._idleTimeout;t>=0&&(e._idleTimeoutId=setTimeout((function(){e._onTimeout&&e._onTimeout()}),t))},r(45),t.setImmediate="undefined"!=typeof self&&self.setImmediate||void 0!==e&&e.setImmediate||this&&this.setImmediate,t.clearImmediate="undefined"!=typeof self&&self.clearImmediate||void 0!==e&&e.clearImmediate||this&&this.clearImmediate}).call(this,r(8))},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(21),o=r(65),i=r(30),a=r(10),s=function(e){return new i(e).origin!==window.location.origin};function c(e){var t=e.url,r=void 0===t?a.SERVER_CONFIG.api+"/uteach":t,c=e.method,u=void 0===c?"GET":c,d=e.responseType,p=void 0===d?"json":d,f=e.data,l=void 0===f?{}:f,m=e.crossOrigin,h=void 0!==m&&m,v=e.needVerifyResponse,g=void 0===v||v;return new Promise((function(e,t){!h&&s(r)?o(r,{param:i.qs.stringify(l)+"&callback"},(function(r,n){return r?t(r):g&&0!==n.err?t(n.msg):void e(n)})):n.default.request({url:r,method:u,responseType:p,data:l}).then((function(r){var n=r.data;if(g&&0!==n.err)return t(n.msg);e(n)})).catch((function(e){t(e)}))}))}t.query=c,t.get=function(e){return c(Object.assign(e,{method:"GET"}))},t.post=function(e){return c(Object.assign(e,{method:"POST"}))}},function(e,t,r){e.exports=r(49)},function(e,t,r){"use strict";e.exports=function(e,t){return function(){for(var r=new Array(arguments.length),n=0;n<r.length;n++)r[n]=arguments[n];return e.apply(t,r)}}},function(e,t,r){"use strict";var n=r(1);function o(e){return encodeURIComponent(e).replace(/%40/gi,"@").replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}e.exports=function(e,t,r){if(!t)return e;var i;if(r)i=r(t);else if(n.isURLSearchParams(t))i=t.toString();else{var a=[];n.forEach(t,(function(e,t){null!=e&&(n.isArray(e)?t+="[]":e=[e],n.forEach(e,(function(e){n.isDate(e)?e=e.toISOString():n.isObject(e)&&(e=JSON.stringify(e)),a.push(o(t)+"="+o(e))})))})),i=a.join("&")}if(i){var s=e.indexOf("#");-1!==s&&(e=e.slice(0,s)),e+=(-1===e.indexOf("?")?"?":"&")+i}return e}},function(e,t,r){"use strict";e.exports=function(e){return!(!e||!e.__CANCEL__)}},function(e,t,r){"use strict";(function(t){var n=r(1),o=r(55),i={"Content-Type":"application/x-www-form-urlencoded"};function a(e,t){!n.isUndefined(e)&&n.isUndefined(e["Content-Type"])&&(e["Content-Type"]=t)}var s,c={adapter:(void 0!==t&&"[object process]"===Object.prototype.toString.call(t)?s=r(26):"undefined"!=typeof XMLHttpRequest&&(s=r(26)),s),transformRequest:[function(e,t){return o(t,"Accept"),o(t,"Content-Type"),n.isFormData(e)||n.isArrayBuffer(e)||n.isBuffer(e)||n.isStream(e)||n.isFile(e)||n.isBlob(e)?e:n.isArrayBufferView(e)?e.buffer:n.isURLSearchParams(e)?(a(t,"application/x-www-form-urlencoded;charset=utf-8"),e.toString()):n.isObject(e)?(a(t,"application/json;charset=utf-8"),JSON.stringify(e)):e}],transformResponse:[function(e){if("string"==typeof e)try{e=JSON.parse(e)}catch(e){}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,validateStatus:function(e){return e>=200&&e<300}};c.headers={common:{Accept:"application/json, text/plain, */*"}},n.forEach(["delete","get","head"],(function(e){c.headers[e]={}})),n.forEach(["post","put","patch"],(function(e){c.headers[e]=n.merge(i)})),e.exports=c}).call(this,r(11))},function(e,t,r){"use strict";var n=r(1),o=r(56),i=r(23),a=r(58),s=r(59),c=r(27);e.exports=function(e){return new Promise((function(t,u){var d=e.data,p=e.headers;n.isFormData(d)&&delete p["Content-Type"];var f=new XMLHttpRequest;if(e.auth){var l=e.auth.username||"",m=e.auth.password||"";p.Authorization="Basic "+btoa(l+":"+m)}if(f.open(e.method.toUpperCase(),i(e.url,e.params,e.paramsSerializer),!0),f.timeout=e.timeout,f.onreadystatechange=function(){if(f&&4===f.readyState&&(0!==f.status||f.responseURL&&0===f.responseURL.indexOf("file:"))){var r="getAllResponseHeaders"in f?a(f.getAllResponseHeaders()):null,n={data:e.responseType&&"text"!==e.responseType?f.response:f.responseText,status:f.status,statusText:f.statusText,headers:r,config:e,request:f};o(t,u,n),f=null}},f.onabort=function(){f&&(u(c("Request aborted",e,"ECONNABORTED",f)),f=null)},f.onerror=function(){u(c("Network Error",e,null,f)),f=null},f.ontimeout=function(){u(c("timeout of "+e.timeout+"ms exceeded",e,"ECONNABORTED",f)),f=null},n.isStandardBrowserEnv()){var h=r(60),v=(e.withCredentials||s(e.url))&&e.xsrfCookieName?h.read(e.xsrfCookieName):void 0;v&&(p[e.xsrfHeaderName]=v)}if("setRequestHeader"in f&&n.forEach(p,(function(e,t){void 0===d&&"content-type"===t.toLowerCase()?delete p[t]:f.setRequestHeader(t,e)})),e.withCredentials&&(f.withCredentials=!0),e.responseType)try{f.responseType=e.responseType}catch(t){if("json"!==e.responseType)throw t}"function"==typeof e.onDownloadProgress&&f.addEventListener("progress",e.onDownloadProgress),"function"==typeof e.onUploadProgress&&f.upload&&f.upload.addEventListener("progress",e.onUploadProgress),e.cancelToken&&e.cancelToken.promise.then((function(e){f&&(f.abort(),u(e),f=null)})),void 0===d&&(d=null),f.send(d)}))}},function(e,t,r){"use strict";var n=r(57);e.exports=function(e,t,r,o,i){var a=new Error(e);return n(a,t,r,o,i)}},function(e,t,r){"use strict";var n=r(1);e.exports=function(e,t){t=t||{};var r={};return n.forEach(["url","method","params","data"],(function(e){void 0!==t[e]&&(r[e]=t[e])})),n.forEach(["headers","auth","proxy"],(function(o){n.isObject(t[o])?r[o]=n.deepMerge(e[o],t[o]):void 0!==t[o]?r[o]=t[o]:n.isObject(e[o])?r[o]=n.deepMerge(e[o]):void 0!==e[o]&&(r[o]=e[o])})),n.forEach(["baseURL","transformRequest","transformResponse","paramsSerializer","timeout","withCredentials","adapter","responseType","xsrfCookieName","xsrfHeaderName","onUploadProgress","onDownloadProgress","maxContentLength","validateStatus","maxRedirects","httpAgent","httpsAgent","cancelToken","socketPath"],(function(n){void 0!==t[n]?r[n]=t[n]:void 0!==e[n]&&(r[n]=e[n])})),r}},function(e,t,r){"use strict";function n(e){this.message=e}n.prototype.toString=function(){return"Cancel"+(this.message?": "+this.message:"")},n.prototype.__CANCEL__=!0,e.exports=n},function(e,t,r){"use strict";(function(t){var n=r(69),o=r(70),i=/^[A-Za-z][A-Za-z0-9+-.]*:\/\//,a=/^([a-z][a-z0-9.+-]*:)?(\/\/)?([\S\s]*)/i,s=new RegExp("^[\\x09\\x0A\\x0B\\x0C\\x0D\\x20\\xA0\\u1680\\u180E\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200A\\u202F\\u205F\\u3000\\u2028\\u2029\\uFEFF]+");function c(e){return(e||"").toString().replace(s,"")}var u=[["#","hash"],["?","query"],function(e){return e.replace("\\","/")},["/","pathname"],["@","auth",1],[NaN,"host",void 0,1,1],[/:(\d+)$/,"port",void 0,1],[NaN,"hostname",void 0,1,1]],d={hash:1,query:1};function p(e){var r,n=("undefined"!=typeof window?window:void 0!==t?t:"undefined"!=typeof self?self:{}).location||{},o={},a=typeof(e=e||n);if("blob:"===e.protocol)o=new l(unescape(e.pathname),{});else if("string"===a)for(r in o=new l(e,{}),d)delete o[r];else if("object"===a){for(r in e)r in d||(o[r]=e[r]);void 0===o.slashes&&(o.slashes=i.test(e.href))}return o}function f(e){e=c(e);var t=a.exec(e);return{protocol:t[1]?t[1].toLowerCase():"",slashes:!!t[2],rest:t[3]}}function l(e,t,r){if(e=c(e),!(this instanceof l))return new l(e,t,r);var i,a,s,d,m,h,v=u.slice(),g=typeof t,y=this,b=0;for("object"!==g&&"string"!==g&&(r=t,t=null),r&&"function"!=typeof r&&(r=o.parse),t=p(t),i=!(a=f(e||"")).protocol&&!a.slashes,y.slashes=a.slashes||i&&t.slashes,y.protocol=a.protocol||t.protocol||"",e=a.rest,a.slashes||(v[3]=[/(.*)/,"pathname"]);b<v.length;b++)"function"!=typeof(d=v[b])?(s=d[0],h=d[1],s!=s?y[h]=e:"string"==typeof s?~(m=e.indexOf(s))&&("number"==typeof d[2]?(y[h]=e.slice(0,m),e=e.slice(m+d[2])):(y[h]=e.slice(m),e=e.slice(0,m))):(m=s.exec(e))&&(y[h]=m[1],e=e.slice(0,m.index)),y[h]=y[h]||i&&d[3]&&t[h]||"",d[4]&&(y[h]=y[h].toLowerCase())):e=d(e);r&&(y.query=r(y.query)),i&&t.slashes&&"/"!==y.pathname.charAt(0)&&(""!==y.pathname||""!==t.pathname)&&(y.pathname=function(e,t){if(""===e)return t;for(var r=(t||"/").split("/").slice(0,-1).concat(e.split("/")),n=r.length,o=r[n-1],i=!1,a=0;n--;)"."===r[n]?r.splice(n,1):".."===r[n]?(r.splice(n,1),a++):a&&(0===n&&(i=!0),r.splice(n,1),a--);return i&&r.unshift(""),"."!==o&&".."!==o||r.push(""),r.join("/")}(y.pathname,t.pathname)),n(y.port,y.protocol)||(y.host=y.hostname,y.port=""),y.username=y.password="",y.auth&&(d=y.auth.split(":"),y.username=d[0]||"",y.password=d[1]||""),y.origin=y.protocol&&y.host&&"file:"!==y.protocol?y.protocol+"//"+y.host:"null",y.href=y.toString()}l.prototype={set:function(e,t,r){var i=this;switch(e){case"query":"string"==typeof t&&t.length&&(t=(r||o.parse)(t)),i[e]=t;break;case"port":i[e]=t,n(t,i.protocol)?t&&(i.host=i.hostname+":"+t):(i.host=i.hostname,i[e]="");break;case"hostname":i[e]=t,i.port&&(t+=":"+i.port),i.host=t;break;case"host":i[e]=t,/:\d+$/.test(t)?(t=t.split(":"),i.port=t.pop(),i.hostname=t.join(":")):(i.hostname=t,i.port="");break;case"protocol":i.protocol=t.toLowerCase(),i.slashes=!r;break;case"pathname":case"hash":if(t){var a="pathname"===e?"/":"#";i[e]=t.charAt(0)!==a?a+t:t}else i[e]=t;break;default:i[e]=t}for(var s=0;s<u.length;s++){var c=u[s];c[4]&&(i[c[1]]=i[c[1]].toLowerCase())}return i.origin=i.protocol&&i.host&&"file:"!==i.protocol?i.protocol+"//"+i.host:"null",i.href=i.toString(),i},toString:function(e){e&&"function"==typeof e||(e=o.stringify);var t,r=this,n=r.protocol;n&&":"!==n.charAt(n.length-1)&&(n+=":");var i=n+(r.slashes?"//":"");return r.username&&(i+=r.username,r.password&&(i+=":"+r.password),i+="@"),i+=r.host+r.pathname,(t="object"==typeof r.query?e(r.query):r.query)&&(i+="?"!==t.charAt(0)?"?"+t:t),r.hash&&(i+=r.hash),i}},l.extractProtocol=f,l.location=p,l.trimLeft=c,l.qs=o,e.exports=l}).call(this,r(8))},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n,o=r(2),i=r(6),a=r(0);!function(e){e[e.unconnected=0]="unconnected",e[e.connecting=1]="connecting",e[e.connected=2]="connected"}(n=t.SignalStatus||(t.SignalStatus={}));var s,c=function(){function e(e,t,r){this.status=n.unconnected,this.grade=100,this.url=e,this.port=t,this.ssl=r}return Object.defineProperty(e.prototype,"wss",{get:function(){return"wss://"+this.url+":"+this.port+"/ws"},enumerable:!0,configurable:!0}),e}();t.Signal=c,function(e){e[e.G1=1]="G1",e[e.G2=2]="G2",e[e.G3=3]="G3",e[e.G4=4]="G4"}(s||(s={}));var u=function(e){function t(){var t=e.call(this)||this;return t.signals=[],t}return o.__extends(t,e),Object.defineProperty(t.prototype,"current",{get:function(){return this._signal},enumerable:!0,configurable:!0}),t.prototype.getLevel=function(e){return e>90&&e<=100?s.G1:e>70&&e<=90?s.G2:e>40&&e<=70?s.G3:s.G4},t.prototype.judge=function(e,t){var r=this,n=this.getLevel(e),o=this.getLevel(t);if(n!==o&&n<o){var i=this.signals.find((function(e){return e!==r._signal&&r.getLevel(e.grade)<o}));if(a.default.debug("judge signal "+(i&&i.wss)+"}"),i){a.default.debug("judge signal "+(i&&this.signals.indexOf(i))+"}");var s=this._signal;this._signal=i,this.emit("change-signal",s,this._signal)}}},t.prototype.award=function(){var e;if(this._signal&&this._signal.status===n.connected&&this._signal.grade<100){var t=this._signal.grade;this._signal.grade=(10*this._signal.grade+2)/10;var r=this._signal.grade;a.default.debug("signal "+(null===(e=this._signal)||void 0===e?void 0:e.url)+" "+t+" -> "+r)}},t.prototype.punish=function(){var e;if(this._signal&&this._signal.status===n.connected&&this._signal.grade>0){var t=this._signal.grade,r=(10*this._signal.grade-10)/10;this._signal.grade=r>=0?r:0;var o=this._signal.grade;a.default.debug("signal "+(null===(e=this._signal)||void 0===e?void 0:e.url)+" "+t+" -> "+o),this.judge(t,o)}},t.prototype.add=function(e){this.signals.push(e),this._signal||(this._signal=e)},t.prototype.remove=function(e){var t=this.signals.findIndex((function(t){return t===e}));t>=0&&this.signals.splice(t,1)},t.prototype.destroy=function(){this.signals=[],this._signal=void 0},t}(i.EventEmitter);t.SignalManager=u},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(33),o=function(){this.bytesReceived=0,this.jitter=0,this.packetsLost=0,this.packetsReceived=0,this.audioLevel=0},i=function(){this.bytesReceived=0,this.packetsLost=0,this.packetsReceived=0,this.firCount=0,this.nackCount=0,this.pliCount=0,this.framesDecoded=0,this.frameHeight=0,this.frameWidth=0,this.framesDropped=0,this.framesReceived=0},a=function(){this.bytesSent=0,this.packetsSent=0,this.retransmittedBytesSent=0,this.retransmittedPacketsSent=0,this.audioLevel=0,this.jitter=0,this.roundTripTime=0,this.packetsLost=0},s=function(){this.bytesSent=0,this.packetsSent=0,this.firCount=0,this.nackCount=0,this.pliCount=0,this.framesEncoded=0,this.frameHeight=0,this.frameWidth=0,this.framesSent=0,this.height=0,this.width=0,this.framesPerSecond=0,this.jitter=0,this.roundTripTime=0,this.packetsLost=0},c=function(){this.availableIncomingBitrate=0,this.availableOutgoingBitrate=0,this.bytesReceived=0,this.bytesSent=0,this.currentRoundTripTime=0,this.totalRoundTripTime=0},u=function(){this.ip="",this.port=0,this.networkType="",this.protocol="udp"},d=function(){this.ip="",this.port=0,this.protocol="udp"},p=function(){this.bytesReceived=0,this.bytesSent=0,this.dtlsState=""},f=function(){this.inAudioReport=new o,this.inVideoReport=new i,this.outAudioReport=new a,this.outVideoReport=new s,this.candidatePairReport=new c,this.localCandidateReport=new u,this.remoteCandidateReport=new d,this.transportReport=new p,this.timestamp=Date.now(),this.original=[]};t.StatsReports=f;var l=function(e){this.timestamp=Date.now(),this.reports=new n.Reports(e),this.audioInputReports=new n.AudioInputReports(e),this.audioOutputReports=new n.AudioOutputReports(e),this.videoInputReports=new n.VideoInputReports(e),this.videoOutputReports=new n.VideoOutputReports(e),this.candidatePairReports=new n.CandidatePairReports(e)};t.StatsReports2=l},function(e,t,r){
- /*!
- * A getStats API of peerconnection with 'Standardized' and 'Legacy Non-Standard' reports.
- *
- * @author poplark <https://github.com/poplark>
- * @license MIT
- */
- window,e.exports=function(e){var t={};function r(n){if(t[n])return t[n].exports;var o=t[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)r.d(n,o,function(t){return e[t]}.bind(null,o));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=3)}([function(e,t,r){"use strict";function n(e,t,r){var n=e.match(t);return n&&n.length>=r&&parseInt(n[r],10)}function o(e){var t=e.navigator,r={browser:null,version:null};if(void 0===e||!e.navigator)return r.browser="Not a browser.",r;if(t.mozGetUserMedia)r.browser="firefox",r.version=n(t.userAgent,/Firefox\/(\d+)\./,1);else if(t.webkitGetUserMedia||!1===e.isSecureContext&&e.webkitRTCPeerConnection&&!e.RTCIceGatherer)r.browser="chrome",r.version=n(t.userAgent,/Chrom(e|ium)\/(\d+)\./,2);else if(t.mediaDevices&&t.userAgent.match(/Edge\/(\d+).(\d+)$/))r.browser="edge",r.version=n(t.userAgent,/Edge\/(\d+).(\d+)$/,2);else{if(!e.RTCPeerConnection||!t.userAgent.match(/AppleWebKit\/(\d+)\./))return r.browser="Not a supported browser.",r;r.browser="safari",r.version=n(t.userAgent,/AppleWebKit\/(\d+)\./,1)}return r}Object.defineProperty(t,"__esModule",{value:!0}),t.detectBrowser=void 0,t.detectBrowser=o;var i=o(window);t.default=i},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Reports=void 0;var n=r(4),o=r(5),i=function(){function e(e){this.originalReports=e}return e.prototype.find=function(e,t){var r=[];return this.originalReports.forEach((function(o){var i=!0;if(t)for(var a in t)if(!(i=n.isUndefined(t[a])?o.has(a):t[a]===o.get(a)))break;i&&o.has(e)&&r.push({key:e,value:o.get(e),origin:o})})),r},e.prototype._find=function(e,t){var r=this.find(e,t);return r[0]?o.parse(""+r[0].value):-1},e}();t.Reports=i},function(e,t,r){"use strict";r.r(t),r.d(t,"__extends",(function(){return o})),r.d(t,"__assign",(function(){return i})),r.d(t,"__rest",(function(){return a})),r.d(t,"__decorate",(function(){return s})),r.d(t,"__param",(function(){return c})),r.d(t,"__metadata",(function(){return u})),r.d(t,"__awaiter",(function(){return d})),r.d(t,"__generator",(function(){return p})),r.d(t,"__createBinding",(function(){return f})),r.d(t,"__exportStar",(function(){return l})),r.d(t,"__values",(function(){return m})),r.d(t,"__read",(function(){return h})),r.d(t,"__spread",(function(){return v})),r.d(t,"__spreadArrays",(function(){return g})),r.d(t,"__await",(function(){return y})),r.d(t,"__asyncGenerator",(function(){return b})),r.d(t,"__asyncDelegator",(function(){return E})),r.d(t,"__asyncValues",(function(){return _})),r.d(t,"__makeTemplateObject",(function(){return S})),r.d(t,"__importStar",(function(){return T})),r.d(t,"__importDefault",(function(){return R})),r.d(t,"__classPrivateFieldGet",(function(){return w})),r.d(t,"__classPrivateFieldSet",(function(){return M}));
- /*! *****************************************************************************
- Copyright (c) Microsoft Corporation.
- Permission to use, copy, modify, and/or distribute this software for any
- purpose with or without fee is hereby granted.
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- PERFORMANCE OF THIS SOFTWARE.
- ***************************************************************************** */
- var n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)};function o(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}var i=function(){return(i=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)};function a(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(e);o<n.length;o++)t.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(e,n[o])&&(r[n[o]]=e[n[o]])}return r}function s(e,t,r,n){var o,i=arguments.length,a=i<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,r,n);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,r,a):o(t,r))||a);return i>3&&a&&Object.defineProperty(t,r,a),a}function c(e,t){return function(r,n){t(r,n,e)}}function u(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)}function d(e,t,r,n){return new(r||(r=Promise))((function(o,i){function a(e){try{c(n.next(e))}catch(e){i(e)}}function s(e){try{c(n.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(a,s)}c((n=n.apply(e,t||[])).next())}))}function p(e,t){var r,n,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(i){return function(s){return function(i){if(r)throw new TypeError("Generator is already executing.");for(;a;)try{if(r=1,n&&(o=2&i[0]?n.return:i[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,i[1])).done)return o;switch(n=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,n=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!((o=(o=a.trys).length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){a.label=i[1];break}if(6===i[0]&&a.label<o[1]){a.label=o[1],o=i;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(i);break}o[2]&&a.ops.pop(),a.trys.pop();continue}i=t.call(e,a)}catch(e){i=[6,e],n=0}finally{r=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,s])}}}function f(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}function l(e,t){for(var r in e)"default"===r||t.hasOwnProperty(r)||(t[r]=e[r])}function m(e){var t="function"==typeof Symbol&&Symbol.iterator,r=t&&e[t],n=0;if(r)return r.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function h(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,o,i=r.call(e),a=[];try{for(;(void 0===t||t-- >0)&&!(n=i.next()).done;)a.push(n.value)}catch(e){o={error:e}}finally{try{n&&!n.done&&(r=i.return)&&r.call(i)}finally{if(o)throw o.error}}return a}function v(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(h(arguments[t]));return e}function g(){for(var e=0,t=0,r=arguments.length;t<r;t++)e+=arguments[t].length;var n=Array(e),o=0;for(t=0;t<r;t++)for(var i=arguments[t],a=0,s=i.length;a<s;a++,o++)n[o]=i[a];return n}function y(e){return this instanceof y?(this.v=e,this):new y(e)}function b(e,t,r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var n,o=r.apply(e,t||[]),i=[];return n={},a("next"),a("throw"),a("return"),n[Symbol.asyncIterator]=function(){return this},n;function a(e){o[e]&&(n[e]=function(t){return new Promise((function(r,n){i.push([e,t,r,n])>1||s(e,t)}))})}function s(e,t){try{(r=o[e](t)).value instanceof y?Promise.resolve(r.value.v).then(c,u):d(i[0][2],r)}catch(e){d(i[0][3],e)}var r}function c(e){s("next",e)}function u(e){s("throw",e)}function d(e,t){e(t),i.shift(),i.length&&s(i[0][0],i[0][1])}}function E(e){var t,r;return t={},n("next"),n("throw",(function(e){throw e})),n("return"),t[Symbol.iterator]=function(){return this},t;function n(n,o){t[n]=e[n]?function(t){return(r=!r)?{value:y(e[n](t)),done:"return"===n}:o?o(t):t}:o}}function _(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t,r=e[Symbol.asyncIterator];return r?r.call(e):(e=m(e),t={},n("next"),n("throw"),n("return"),t[Symbol.asyncIterator]=function(){return this},t);function n(r){t[r]=e[r]&&function(t){return new Promise((function(n,o){!function(e,t,r,n){Promise.resolve(n).then((function(t){e({value:t,done:r})}),t)}(n,o,(t=e[r](t)).done,t.value)}))}}}function S(e,t){return Object.defineProperty?Object.defineProperty(e,"raw",{value:t}):e.raw=t,e}function T(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t}function R(e){return e&&e.__esModule?e:{default:e}}function w(e,t){if(!t.has(e))throw new TypeError("attempted to get private field on non-instance");return t.get(e)}function M(e,t,r){if(!t.has(e))throw new TypeError("attempted to set private field on non-instance");return t.set(e,r),r}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getLegacyStats=t.getStats=t.CandidatePairLegacyReports=t.CandidatePairReports=t.VideoOutputLegacyReports=t.VideoInputLegacyReports=t.VideoOutputReports=t.VideoInputReports=t.AudioOutputLegacyReports=t.AudioInputLegacyReports=t.AudioOutputReports=t.AudioInputReports=t.Reports=void 0;var n=r(0),o=r(1);Object.defineProperty(t,"Reports",{enumerable:!0,get:function(){return o.Reports}});var i=r(8);Object.defineProperty(t,"AudioInputReports",{enumerable:!0,get:function(){return i.AudioInputReports}}),Object.defineProperty(t,"AudioOutputReports",{enumerable:!0,get:function(){return i.AudioOutputReports}}),Object.defineProperty(t,"AudioInputLegacyReports",{enumerable:!0,get:function(){return i.AudioInputLegacyReports}}),Object.defineProperty(t,"AudioOutputLegacyReports",{enumerable:!0,get:function(){return i.AudioOutputLegacyReports}});var a=r(9);Object.defineProperty(t,"VideoInputReports",{enumerable:!0,get:function(){return a.VideoInputReports}}),Object.defineProperty(t,"VideoOutputReports",{enumerable:!0,get:function(){return a.VideoOutputReports}}),Object.defineProperty(t,"VideoInputLegacyReports",{enumerable:!0,get:function(){return a.VideoInputLegacyReports}}),Object.defineProperty(t,"VideoOutputLegacyReports",{enumerable:!0,get:function(){return a.VideoOutputLegacyReports}});var s=r(10);function c(e){return e.getStats().then((function(e){var t=[];return e.forEach((function(e){var r=new Map;for(var n in e)r.set(n,e[n]);t.push(r)})),t}))}Object.defineProperty(t,"CandidatePairReports",{enumerable:!0,get:function(){return s.CandidatePairReports}}),Object.defineProperty(t,"CandidatePairLegacyReports",{enumerable:!0,get:function(){return s.CandidatePairLegacyReports}}),t.getStats=c,t.getLegacyStats=function(e){return"chrome"!==n.default.browser?Promise.reject(new Error("Only chrome/chromium style browsers can use this function")):new Promise((function(t,r){var n=[];e.getStats((function(e){e.result().forEach((function(e){var t=new Map;t.set("id",e.id),t.set("type",e.type),e.names().forEach((function(r){t.set(r,e.stat(r))})),n.push(t)})),t(n)})).catch(r)}))},t.default=c},function(e,t,r){"use strict";function n(e){return Object.prototype.toString.call(e)}Object.defineProperty(t,"__esModule",{value:!0}),t.isNull=t.isUndefined=void 0,t.isUndefined=function(e){return"[object Undefined]"===n(e)},t.isNull=function(e){return"[object Null]"===n(e)}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.parse=void 0;var n=r(6),o=r(7);t.parse=function(e){return e+="",o.isBoolean(e)?o.parseBoolean(e):n.isNumber(e)?n.parseNumber(e):e}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.parseNumber=t.isNumber=t.isFloat=t.isInt=void 0;var n=/^-?(?:0|[1-9][0-9]*)$/,o=/^-?(?:0|[1-9][0-9]*)(?:\.[0-9]*)?(?:[eE][-+]?[0-9]+)?$/;function i(e){return e+="",n.test(e)}function a(e){return e+="",o.test(e)}t.isInt=i,t.isFloat=a,t.isNumber=function(e){return i(e+="")||a(e)},t.parseNumber=function(e){var t;if(i(e+=""))t=parseInt(e,10);else{if(!a(e))throw new Error("parameter invalid");t=parseFloat(e)}return t}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.parseBoolean=t.isBoolean=void 0;var n=/^true|false$/;function o(e){return e+="",n.test(e)}t.isBoolean=o,t.parseBoolean=function(e){if(!o(e+=""))throw new Error("parameter invalid");return"true"===e}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.AudioOutputLegacyReports=t.AudioInputLegacyReports=t.AudioOutputReports=t.AudioInputReports=void 0;var n=r(2),o=r(0),i=r(1),a=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return n.__extends(t,e),Object.defineProperty(t.prototype,"bytesReceived",{get:function(){return this._find("bytesReceived",{type:"inbound-rtp",mediaType:"audio"})},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"packetsReceived",{get:function(){return this._find("packetsReceived",{type:"inbound-rtp",mediaType:"audio"})},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"jitter",{get:function(){return this._find("jitter",{type:"inbound-rtp",mediaType:"audio"})},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"packetsLost",{get:function(){return this._find("packetsLost",{type:"inbound-rtp",mediaType:"audio"})},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"audioLevel",{get:function(){switch(o.default.browser){case"chrome":return this._find("audioLevel",{type:"track",kind:"audio"});case"safari":return this._find("audioLevel",{type:"track"});default:return this._find("audioLevel")}},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"totalAudioEnergy",{get:function(){switch(o.default.browser){case"chrome":return this._find("totalAudioEnergy",{type:"track",kind:"audio"});default:return this._find("totalAudioEnergy")}},enumerable:!1,configurable:!0}),t}(i.Reports);t.AudioInputReports=a;var s=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return n.__extends(t,e),Object.defineProperty(t.prototype,"bytesSent",{get:function(){return this._find("bytesSent",{type:"outbound-rtp",mediaType:"audio"})},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"packetsSent",{get:function(){return this._find("packetsSent",{type:"outbound-rtp",mediaType:"audio"})},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"jitter",{get:function(){switch(o.default.browser){case"chrome":case"firefox":return this._find("jitter",{type:"remote-inbound-rtp",kind:"audio"});default:return this._find("jitter",{mediaType:"audio"})}},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"packetsLost",{get:function(){switch(o.default.browser){case"chrome":case"firefox":return this._find("packetsLost",{type:"remote-inbound-rtp",kind:"audio"});default:return this._find("packetsLost",{mediaType:"audio"})}},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"roundTripTime",{get:function(){switch(o.default.browser){case"chrome":case"firefox":return this._find("roundTripTime",{type:"remote-inbound-rtp",kind:"audio"});default:return this._find("roundTripTime",{mediaType:"audio"})}},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"audioLevel",{get:function(){switch(o.default.browser){case"chrome":return this._find("audioLevel",{type:"media-source",kind:"audio"});default:return this._find("audioLevel")}},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"totalAudioEnergy",{get:function(){switch(o.default.browser){case"chrome":return this._find("totalAudioEnergy",{type:"media-source",kind:"audio"});default:return this._find("totalAudioEnergy")}},enumerable:!1,configurable:!0}),t}(i.Reports);t.AudioOutputReports=s;var c=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return n.__extends(t,e),Object.defineProperty(t.prototype,"bytesReceived",{get:function(){return this._find("bytesReceived",{type:"ssrc",mediaType:"audio"})},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"packetsReceived",{get:function(){return this._find("packetsReceived",{type:"ssrc",mediaType:"audio"})},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"packetsLost",{get:function(){return this._find("packetsLost",{type:"ssrc",mediaType:"audio"})},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"audioLevel",{get:function(){return this._find("audioOutputLevel",{type:"ssrc",mediaType:"audio"})},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"totalAudioEnergy",{get:function(){return this._find("totalAudioEnergy",{type:"ssrc",mediaType:"audio"})},enumerable:!1,configurable:!0}),t}(i.Reports);t.AudioInputLegacyReports=c;var u=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return n.__extends(t,e),Object.defineProperty(t.prototype,"bytesSent",{get:function(){return this._find("bytesSent",{type:"ssrc",mediaType:"audio"})},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"packetsSent",{get:function(){return this._find("packetsSent",{type:"ssrc",mediaType:"audio"})},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"packetsLost",{get:function(){return this._find("packetsLost",{type:"ssrc",mediaType:"audio"})},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"roundTripTime",{get:function(){return this._find("googRtt",{type:"ssrc",mediaType:"audio"})},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"audioLevel",{get:function(){return this._find("audioInputLevel",{type:"ssrc",mediaType:"audio"})},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"totalAudioEnergy",{get:function(){return this._find("totalAudioEnergy",{type:"ssrc",mediaType:"audio"})},enumerable:!1,configurable:!0}),t}(i.Reports);t.AudioOutputLegacyReports=u},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.VideoOutputLegacyReports=t.VideoInputLegacyReports=t.VideoOutputReports=t.VideoInputReports=void 0;var n=r(2),o=r(0),i=r(1),a=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return n.__extends(t,e),Object.defineProperty(t.prototype,"frameWidth",{get:function(){switch(o.default.browser){case"chrome":return this._find("frameWidth",{type:"track",kind:"video"});case"safari":return this._find("frameWidth",{type:"track"});default:return this._find("frameWidth")}},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"frameHeight",{get:function(){switch(o.default.browser){case"chrome":return this._find("frameHeight",{type:"track",kind:"video"});case"safari":return this._find("frameHeight",{type:"track"});default:return this._find("frameHeight")}},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"framesReceived",{get:function(){switch(o.default.browser){case"chrome":return this._find("framesReceived",{type:"track",kind:"video"});case"safari":return this._find("framesReceived",{type:"track"});default:return this._find("framesReceived")}},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"framesDropped",{get:function(){switch(o.default.browser){case"chrome":return this._find("framesDropped",{type:"track",kind:"video"});case"safari":return this._find("framesDropped",{type:"track"});default:return this._find("framesDropped")}},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"bytesReceived",{get:function(){return this._find("bytesReceived",{type:"inbound-rtp",mediaType:"video"})},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"packetsReceived",{get:function(){return this._find("packetsReceived",{type:"inbound-rtp",mediaType:"video"})},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"packetsLost",{get:function(){return this._find("packetsLost",{type:"inbound-rtp",mediaType:"video"})},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"nackCount",{get:function(){return this._find("nackCount",{type:"inbound-rtp",mediaType:"video"})},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"pliCount",{get:function(){return this._find("pliCount",{type:"inbound-rtp",mediaType:"video"})},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"firCount",{get:function(){return this._find("firCount",{type:"inbound-rtp",mediaType:"video"})},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"framesDecoded",{get:function(){switch(o.default.browser){case"chrome":return this._find("framesDecoded",{type:"track",kind:"video"});case"firefox":return this._find("framesDecoded",{type:"inbound-rtp",kind:"video"});case"safari":return this._find("framesDecoded",{type:"track"});default:return this._find("framesDecoded")}},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"jitter",{get:function(){switch(o.default.browser){case"firefox":return this._find("jitter",{type:"inbound-rtp",kind:"video"});default:return this._find("jitter",{mediaType:"video"})}},enumerable:!1,configurable:!0}),t}(i.Reports);t.VideoInputReports=a;var s=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return n.__extends(t,e),Object.defineProperty(t.prototype,"frameWidth",{get:function(){switch(o.default.browser){case"chrome":return this._find("frameWidth",{type:"track",kind:"video"});case"safari":return this._find("frameWidth",{type:"track"});default:return this._find("frameWidth")}},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"frameHeight",{get:function(){switch(o.default.browser){case"chrome":return this._find("frameHeight",{type:"track",kind:"video"});case"safari":return this._find("frameHeight",{type:"track"});default:return this._find("frameHeight")}},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"bytesSent",{get:function(){return this._find("bytesSent",{type:"outbound-rtp",mediaType:"video"})},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"packetsSent",{get:function(){return this._find("packetsSent",{type:"outbound-rtp",mediaType:"video"})},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"nackCount",{get:function(){return this._find("nackCount",{type:"outbound-rtp",mediaType:"video"})},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"pliCount",{get:function(){return this._find("pliCount",{type:"outbound-rtp",mediaType:"video"})},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"firCount",{get:function(){return this._find("firCount",{type:"outbound-rtp",mediaType:"video"})},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"framesEncoded",{get:function(){return this._find("framesEncoded",{type:"outbound-rtp",mediaType:"video"})},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"packetsLost",{get:function(){switch(o.default.browser){case"chrome":case"firefox":return this._find("packetsLost",{type:"remote-inbound-rtp",kind:"video"});default:return this._find("packetsLost",{mediaType:"video"})}},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"jitter",{get:function(){switch(o.default.browser){case"chrome":case"firefox":return this._find("jitter",{type:"remote-inbound-rtp",kind:"video"});default:return this._find("jitter",{mediaType:"video"})}},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"roundTripTime",{get:function(){switch(o.default.browser){case"chrome":case"firefox":return this._find("roundTripTime",{type:"remote-inbound-rtp",kind:"video"});default:return this._find("roundTripTime",{mediaType:"video"})}},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"framesSent",{get:function(){switch(o.default.browser){case"chrome":return this._find("framesSent",{type:"track",kind:"video"});case"safari":return this._find("framesSent",{type:"track"});default:return this._find("framesSent")}},enumerable:!1,configurable:!0}),t}(i.Reports);t.VideoOutputReports=s;var c=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return n.__extends(t,e),Object.defineProperty(t.prototype,"frameWidth",{get:function(){return this._find("googFrameWidthReceived",{type:"ssrc",mediaType:"video"})},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"frameHeight",{get:function(){return this._find("googFrameHeightReceived",{type:"ssrc",mediaType:"video"})},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"bytesReceived",{get:function(){return this._find("bytesReceived",{type:"ssrc",mediaType:"video"})},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"packetsReceived",{get:function(){return this._find("packetsReceived",{type:"ssrc",mediaType:"video"})},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"packetsLost",{get:function(){return this._find("packetsLost",{type:"ssrc",mediaType:"video"})},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"nackCount",{get:function(){return this._find("googNacksSent",{type:"ssrc",mediaType:"video"})},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"pliCount",{get:function(){return this._find("googPlisSent",{type:"ssrc",mediaType:"video"})},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"firCount",{get:function(){return this._find("googFirsSent",{type:"ssrc",mediaType:"video"})},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"framesDecoded",{get:function(){return this._find("framesDecoded",{type:"ssrc",mediaType:"video"})},enumerable:!1,configurable:!0}),t}(i.Reports);t.VideoInputLegacyReports=c;var u=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return n.__extends(t,e),Object.defineProperty(t.prototype,"frameWidth",{get:function(){return this._find("googFrameWidthSent",{type:"ssrc",mediaType:"video"})},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"frameHeight",{get:function(){return this._find("googFrameHeightSent",{type:"ssrc",mediaType:"video"})},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"bytesSent",{get:function(){return this._find("bytesSent",{type:"ssrc",mediaType:"video"})},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"packetsSent",{get:function(){return this._find("packetsSent",{type:"ssrc",mediaType:"video"})},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"nackCount",{get:function(){return this._find("googNacksReceived",{type:"ssrc",mediaType:"video"})},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"pliCount",{get:function(){return this._find("googPlisReceived",{type:"ssrc",mediaType:"video"})},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"firCount",{get:function(){return this._find("googFirsReceived",{type:"ssrc",mediaType:"video"})},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"framesEncoded",{get:function(){return this._find("framesEncoded",{type:"ssrc",mediaType:"video"})},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"packetsLost",{get:function(){return this._find("packetsLost",{type:"ssrc",mediaType:"video"})},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"roundTripTime",{get:function(){return this._find("googRtt",{type:"ssrc",mediaType:"video"})},enumerable:!1,configurable:!0}),t}(i.Reports);t.VideoOutputLegacyReports=u},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.CandidatePairLegacyReports=t.CandidatePairReports=void 0;var n=r(2),o=r(0),i=r(1),a=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return n.__extends(t,e),Object.defineProperty(t.prototype,"bytesSent",{get:function(){switch(o.default.browser){case"chrome":case"safari":return this._find("bytesSent",{type:"candidate-pair"});case"firefox":return this._find("bytesSent",{type:"candidate-pair",selected:!0});default:return this._find("bytesSent",{type:"candidate-pair"})}},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"bytesReceived",{get:function(){switch(o.default.browser){case"chrome":case"safari":return this._find("bytesReceived",{type:"candidate-pair"});case"firefox":return this._find("bytesReceived",{type:"candidate-pair",selected:!0});default:return this._find("bytesReceived",{type:"candidate-pair"})}},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"currentRoundTripTime",{get:function(){switch(o.default.browser){case"chrome":case"safari":default:return this._find("currentRoundTripTime",{type:"candidate-pair"})}},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"totalRoundTripTime",{get:function(){switch(o.default.browser){case"chrome":case"safari":default:return this._find("totalRoundTripTime",{type:"candidate-pair"})}},enumerable:!1,configurable:!0}),t}(i.Reports);t.CandidatePairReports=a;var s=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return n.__extends(t,e),Object.defineProperty(t.prototype,"bytesReceived",{get:function(){return this._find("bytesReceived",{type:"googCandidatePair"})},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"bytesSent",{get:function(){return this._find("bytesSent",{type:"googCandidatePair"})},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"packetsSent",{get:function(){return this._find("packetsSent",{type:"googCandidatePair"})},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"currentRoundTripTime",{get:function(){return this._find("googRtt",{type:"googCandidatePair"})},enumerable:!1,configurable:!0}),t}(i.Reports);t.CandidatePairLegacyReports=s}])},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(0),o=r(3),i=function(){function e(e,t,r,i){var a=this;void 0===t&&(t=640),void 0===r&&(r=480),void 0===i&&(i=20),this.width=640,this.height=480,this.frameRate=20,this.image=e,this.width=t,this.height=r,this.frameRate=i;var s=document.createElement("canvas");s.width=this.width,s.height=this.height;var c=s.getContext("2d");if(!c){var u=o.createError(o.ErrorCodes.CREATE_STREAM,"cannot create canvas context");throw n.default.error(u),u}var d=function(){c.drawImage(a.image,0,0,a.width,a.height),a.drawTimer=window.requestAnimationFrame(d)};return this.drawTimer=window.requestAnimationFrame(d),this.mediaStream=s.captureStream(this.frameRate),document.addEventListener("visibilitychange",(function(){document.hidden?(a.interval&&window.clearInterval(a.interval),a.interval=window.setInterval((function(){c.drawImage(a.image,0,0,a.width,a.height)}),200)):a.interval&&(window.clearInterval(a.interval),a.interval=0)})),this}return e.prototype.destroy=function(){this.drawTimer&&window.cancelAnimationFrame(this.drawTimer),this.interval&&window.clearInterval(this.interval)},e}();t.ImageStream=i;var a=function(){function e(e,t){this.mediaStream=new MediaStream,this.mediaStream.addTrack(e),this.resolutionAttributes=t}return Object.defineProperty(e.prototype,"srcVideoTrack",{get:function(){return this.mediaStream.getVideoTracks()[0]},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"dstVideoTrack",{get:function(){return this.mediaStream.getVideoTracks()[0]},enumerable:!0,configurable:!0}),e.prototype.destroy=function(){this.mediaStream.getTracks().forEach((function(e){e.stop()}))},e.prototype.updateVideoSourceTrack=function(e){var t=this.srcVideoTrack;return t&&e?(this.mediaStream.removeTrack(t),this.mediaStream.addTrack(e)):e&&this.mediaStream.addTrack(e),t},e.prototype.createMediaStreamByImage=function(t){var r=this.srcVideoTrack;if(!r){var i=o.createError(o.ErrorCodes.OTHERS,"no video track");return n.default.error(i),Promise.reject(i)}var a=r.getSettings(),s=a.width||this.resolutionAttributes.videoWidth||640,c=a.height||this.resolutionAttributes.videoHeight||480;return e.createMediaStreamByImage(t,s,c)},e.prototype.createImageStream=function(t){var r=this.srcVideoTrack;if(!r){var n=o.createError(o.ErrorCodes.OTHERS,"no video track");return Promise.reject(n)}var i=r.getSettings(),a=i.width||this.resolutionAttributes.videoWidth||640,s=i.height||this.resolutionAttributes.videoHeight||480,c=i.frameRate||this.resolutionAttributes.maxFrameRate||20;return e.createImageStream(t,a,s,c)},e.getImageByFile=function(t){return new Promise((function(r,i){var a=new FileReader;a.addEventListener("load",(function(t){n.default.debug("file reader loaded ",t),e.getImageByURL(this.result).then(r).catch(i)})),a.addEventListener("error",(function(e){n.default.debug("file reader load error ",e);var t=o.createError(o.ErrorCodes.OTHERS,"file reader load error");i(t)})),a.readAsDataURL(t)}))},e.getImageByURL=function(e){return new Promise((function(t,r){var i=new Image;i.addEventListener("load",(function(e){n.default.debug("image loaded ",e),t(this)})),i.addEventListener("error",(function(e){n.default.debug("image load error ",e);var t=o.createError(o.ErrorCodes.OTHERS,"image load error");r(t)})),i.addEventListener("invalid",(function(e){n.default.debug("image load invalid ",e);var t=o.createError(o.ErrorCodes.OTHERS,"image invalid");r(t)})),i.src=e}))},e.createMediaStreamByImage=function(t,r,i){return void 0===r&&(r=640),void 0===i&&(i=480),new Promise((function(a,s){var c=document.createElement("canvas");c.width=r,c.height=i;var u=c.getContext("2d");if(!u){var d=o.createError(o.ErrorCodes.CREATE_STREAM,"cannot create canvas context");return n.default.error(d),void s(d)}if("string"==typeof t)e.getImageByURL(t).then((function(e){u.drawImage(e,0,0,c.width,c.height),a(c.captureStream())})).catch((function(e){s(e)}));else if(t instanceof File)e.getImageByFile(t).then((function(e){u.drawImage(e,0,0,c.width,c.height),a(c.captureStream())})).catch((function(e){s(e)}));else{d=o.createError(o.ErrorCodes.CREATE_STREAM,"file is invalid");s(d)}}))},e.createImageStream=function(t,r,n,a){if(void 0===r&&(r=640),void 0===n&&(n=480),void 0===a&&(a=20),"string"==typeof t)return e.getImageByURL(t).then((function(e){return new i(e,r,n,a)}));if(t instanceof File)return e.getImageByFile(t).then((function(e){return new i(e,r,n,a)}));var s=o.createError(o.ErrorCodes.CREATE_STREAM,"file is invalid");return Promise.reject(s)},e.prototype.snapshot=function(e){var t=this;return new Promise((function(r,i){var a=document.createElement("video");a.autoplay=!0,a.srcObject=t.mediaStream,a.onplay=function(){var t=document.createElement("canvas");t.width=a.videoWidth,t.height=a.videoHeight;var s=t.getContext("2d");if(!s){var c=o.createError(o.ErrorCodes.OTHERS,"cannot create canvas context");return n.default.warn(c),void i(c)}s.drawImage(a,0,0);var u=t.toDataURL("image");if(a.srcObject=null,a.onplay=null,""!==e){var d=document.createElement("a");d.download=e,d.href=u,d.click()}r(u)}}))},e}();t.VideoHelper=a},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n,o,i,a=r(30),s=r(10),c=r(20),u=r(0),d=r(4),p=r(18),f=r(36),l=r(5),m=r(77);!function(e){e[e.join=10]="join",e[e.stats=2]="stats",e[e.leave=3]="leave",e[e.exception=4]="exception",e[e.operation=5]="operation"}(n||(n={})),function(e){e[e.publish=1]="publish",e[e.subscribe=2]="subscribe",e[e.getCameras=3]="getCameras",e[e.getMicrophones=4]="getMicrophones",e[e.getLoudspeakers=5]="getLoudspeakers",e[e.highCPU=6]="highCPU",e[e.highLoss=7]="highLoss",e[e.highDelay=8]="highDelay",e[e.record=9]="record",e[e.storage=10]="storage",e[e.im=11]="im",e[e.whiteboard=12]="whiteboard",e[e.others=13]="others",e[e.joinRoom=14]="joinRoom",e[e.relay=15]="relay"}(o=t.ENUM_LOG_EXCEPTION_TYPE||(t.ENUM_LOG_EXCEPTION_TYPE={})),function(e){e[e.joinRoom=1]="joinRoom",e[e.leaveRoom=2]="leaveRoom",e[e.publish=3]="publish",e[e.unpublish=4]="unpublish",e[e.subscribe=5]="subscribe",e[e.unsubscribe=6]="unsubscribe",e[e.unmuteVideo=7]="unmuteVideo",e[e.muteVideo=8]="muteVideo",e[e.unmuteAudio=9]="unmuteAudio",e[e.muteAudio=10]="muteAudio",e[e.startRecord=11]="startRecord",e[e.stopRecord=12]="stopRecord",e[e.startRelay=13]="startRelay",e[e.stopRelay=14]="stopRelay"}(i=t.ENUM_LOG_OPERATION_TYPE||(t.ENUM_LOG_OPERATION_TYPE={}));var h=function(){function e(){}return e.prototype.init=function(e,t,r){var n=this;if(this.app_id=e,this.room_id=t,this.user_id=r,u.default.onError=function(e){n.reportExceptionLog(o.others,{msg:""+e})},l.default.isFirefox()||l.default.isEdge())try{this.reportWorker=new m.InlineWorker((function(){var e=this;this.onmessage=function(t){var r=t.data;!function(t,r){var n=new XMLHttpRequest;n.open("post",t,!0),n.setRequestHeader("Content-Type","application/json;charset=utf-8"),n.setRequestHeader("Accept","application/json, text/plain, */*"),n.responseType="json",n.send(JSON.stringify(r)),n.onreadystatechange=function(){4===n.readyState&&200===n.status&&e.postMessage({response:n.response})}}(r.url,r.content)}})),this.reportWorker.onmessage=function(e){u.default.debug("report worker recive data ",e.data)}}catch(e){u.default.warn("browser not support web worker")}},e.prototype.destroy=function(){var e;this.app_id="",this.room_id="",this.user_id="",null===(e=this.reportWorker)||void 0===e||e.terminate(),u.default.onError=function(){}},Object.defineProperty(e.prototype,"isValid",{get:function(){return!!s.SERVER_CONFIG.log&&!!(this.app_id&&this.room_id&&this.user_id)},enumerable:!0,configurable:!0}),e.prototype.getCommonHeader=function(e,t){return{version:"1.0",method:"logup",rpc_id:f.getId(),type:e,ts:Math.round(Date.now()/1e3),aid:this.app_id,rid:this.room_id,sid:t&&t.sid||"",uid:this.user_id,streamid:t&&t.streamId||"",stype:t&&t.stype||0,mtype:t&&t.mtype||0}},e.prototype.reportJoinRoomLog=function(){if(this.isValid){var e=this.getCommonHeader(n.join),t=l.getDeviceInfo(),r=l.getSystemInfo(),o=l.getCPUInfo(),i={sdkv:p.version,agent:f.getAgent(),device:t.vendor+"_"+t.brand+"_"+t.model,system:""+r.name+r.version+"_"+r.versionName,network:""+l.getNetworkInfo().network,cpu:o.brand+"_"+o.model+"_"+o.core,mem:l.getMemInfo().capacity,micphone:1,speaker:1,video:1},c=new a(s.SERVER_CONFIG.log).set("pathname","api/rtcJoinLeaveClientLog"),u=Object.assign({},e,{data:i});this.report(c,u)}},e.prototype.reportLeaveRoomLog=function(){if(this.isValid){var e=this.getCommonHeader(n.leave),t=new a(s.SERVER_CONFIG.log).set("pathname","api/rtcJoinLeaveClientLog"),r=Object.assign({},e,{data:{sdkv:"",agent:"",device:"",system:"",network:"",cpu:"",mem:0,micphone:0,speaker:0,video:0}});this.report(t,r)}},e.prototype.reportPublishStatusLog=function(e,t,r){if(this.isValid){var o=this.getCommonHeader(n.stats,{streamId:e,stype:d.ENUM_STREAM_TYPE.publish,mtype:t}),i=new a(s.SERVER_CONFIG.log).set("pathname","api/rtcClinetLog"),c=Object.assign({userid:"",streamid:""},r),u=Object.assign({},o,{data:c});this.report(i,u)}},e.prototype.reportSubscribeStatusLog=function(e,t,r,o,i){if(this.isValid){var c=this.getCommonHeader(n.stats,{streamId:e,stype:d.ENUM_STREAM_TYPE.subscribe,mtype:o}),u=new a(s.SERVER_CONFIG.log).set("pathname","api/rtcClinetLog"),p=Object.assign({userid:r||"",streamid:t||""},i),f=Object.assign({},c,{data:p});this.report(u,f)}},e.prototype.reportExceptionLog=function(e,t){if(this.isValid){var r=this.getCommonHeader(n.exception,t),i=new a(s.SERVER_CONFIG.log).set("pathname","api/exceptionLog"),c=Object.assign({},r,{data:{errorType:e,userid:e===o.subscribe&&t&&t.userId||"",streamid:e===o.subscribe&&t&&t.streamId||"",msg:t&&t.msg||""}});this.report(i,c)}},e.prototype.reportOperationLog=function(e,t){if(this.isValid){var r=i,o=[r.subscribe,r.unsubscribe,r.unmuteVideo,r.muteVideo,r.unmuteAudio,r.muteAudio],c=[r.subscribe,r.unsubscribe,r.unmuteVideo,r.muteVideo,r.unmuteAudio,r.muteAudio],u=[r.startRecord,r.stopRecord],d=this.getCommonHeader(n.operation,t),p=new a(s.SERVER_CONFIG.log).set("pathname","api/opertionLog"),f=Object.assign({},d,{data:{opertionType:e,userid:o.includes(e)&&t&&t.userId||"",streamid:c.includes(e)&&t&&t.streamId||"",recordid:u.includes(e)&&t&&t.recordId||""}});this.report(p,f)}},e.prototype.report=function(e,t){var r;this.reportWorker?null===(r=this.reportWorker)||void 0===r||r.postMessage({url:e.href,content:t}):c.post({url:e.href,data:t,crossOrigin:!0,needVerifyResponse:!1}).catch((function(e){u.default.warn("report log "+e)}))},e}();t.LogReporter=h},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(5),o=r(37),i=1e7,a="web_"+n.getBrowserInfo().name+n.getBrowserInfo().version,s=i,c=a;t.getAgent=function(){return c},t.setAgent=function(e){c=e},t.resetSeq=function(){s=i},t.getId=function(){return c+"_"+o.formatTime(new Date,"YYYYMMDDHHmmss")+"_"+s++}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.formatTime=function(e,t){void 0===t&&(t="YYYY/MM/DD HH:mm:ss");var r={"M+":e.getMonth()+1,"D+":e.getDate(),"H+":e.getHours(),"m+":e.getMinutes(),"s+":e.getSeconds(),"q+":Math.floor((e.getMonth()+3)/3),S:e.getMilliseconds()};for(var n in/(y+)/i.test(t)&&(t=t.replace(RegExp.$1,(e.getFullYear()+"").substr(4-RegExp.$1.length))),r)new RegExp("("+n+")").test(t)&&(t=t.replace(RegExp.$1,1==RegExp.$1.length?r[n]:("00"+r[n]).substr((""+r[n]).length)));return t}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(2),o=r(0),i=r(13),a=r(17),s=r(34),c=r(4),u=r(15),d=function(e){function t(t,r){var n=e.call(this,r)||this;return n.status=c.ENUM_SUBSCRIBE_STATUS.unsubscribe,n.isSubscriber=!0,n.userId=t.uid,n.streamId=t.sid,n.streamType=c.ENUM_STREAM_TYPE.subscribe,n.mediaType=t.media_type,n.audio=t.audio,n.video=t.video,n.data=t.data,n.muteaudio=t.muteaudio,n.mutevideo=t.mutevideo,n}return n.__extends(t,e),Object.defineProperty(t.prototype,"canSubscribe",{get:function(){var e=!0;switch(this.status){case c.ENUM_SUBSCRIBE_STATUS.subscribing:case c.ENUM_SUBSCRIBE_STATUS.unsubscribing:case c.ENUM_SUBSCRIBE_STATUS.subscribed:e=!1;break;case c.ENUM_SUBSCRIBE_STATUS.unsubscribe:default:e=!0}return e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"canUnSubscribe",{get:function(){var e=!0;switch(this.status){case c.ENUM_SUBSCRIBE_STATUS.subscribing:case c.ENUM_SUBSCRIBE_STATUS.unsubscribing:case c.ENUM_SUBSCRIBE_STATUS.unsubscribe:e=!1;break;case c.ENUM_SUBSCRIBE_STATUS.subscribed:default:e=!0}return e},enumerable:!0,configurable:!0}),t.prototype.initMediaStream=function(){this.mediaStream=new MediaStream},t.prototype.handlePeerConnectionTrackEvent=function(){var e=this;this.peerConnection&&this.peerConnection.addEventListener("track",(function(t){if(o.default.debug("remote - track event ",t),"audio"===t.track.kind){e.audioHelper=new a.AudioHelper(t.track);var r=e.getAudioTrack();r&&e.mediaStream.addTrack(r)}"video"===t.track.kind&&(e.videoHelper=new s.VideoHelper(t.track,e.resolution.attributes),e.mediaStream.addTrack(t.track))}))},t.prototype.connect=function(e){return n.__awaiter(this,void 0,void 0,(function(){var t,r;return n.__generator(this,(function(n){switch(n.label){case 0:this.streamSubId=e,n.label=1;case 1:if(n.trys.push([1,4,,5]),!this.peerConnection)throw new Error("no peerconnection");return[4,this.peerConnection.createOffer({offerToReceiveAudio:this.audio,offerToReceiveVideo:this.video})];case 2:return(t=n.sent()).sdp&&this.video&&this.videoCodec&&(t.sdp=u.handleSDPVideoCodec(t.sdp,this.videoCodec)),t.sdp&&this.audio&&(t.sdp=u.handleSDPAudioCodec(t.sdp)),[4,this.peerConnection.setLocalDescription(t)];case 3:return n.sent(),[2,t];case 4:throw r=n.sent(),o.default.error("peerconnection create offer error "+r),r;case 5:return[2]}}))}))},t.prototype.setStatusAsDone=function(){this.status=c.ENUM_SUBSCRIBE_STATUS.subscribed},t.prototype.close=function(){this._close(),this.status=c.ENUM_SUBSCRIBE_STATUS.unsubscribe},t.prototype.convertToOuterStream=function(){var e;switch(this.mediaType){case c.ENUM_MEDIA_TYPE.desktop:e="screen";break;case c.ENUM_MEDIA_TYPE.camera:default:e="camera"}return{sid:this.streamId,uid:this.userId,type:"subscribe",mediaType:e,audio:this.audio,video:this.video,muteAudio:this.muteaudio,muteVideo:this.mutevideo,mediaStream:this.status===c.ENUM_SUBSCRIBE_STATUS.subscribed?this.mediaStream:void 0}},t.prototype.convertToInnerStream=function(){return{uid:this.userId,sid:this.streamId,streamsub_id:this.streamSubId,stream_type:this.streamType,media_type:this.mediaType,audio:this.audio,video:this.video,data:this.data,muteaudio:this.muteaudio,mutevideo:this.mutevideo}},t.prototype.setAudioVolume=function(e){o.default.debug("setAudioVolume",e);return Promise.reject("remote stream does not support setAudioVolume")},t.prototype.playEffect=function(e,t,r){o.default.debug("playEffect",e,t);var n="remote stream does not support playEffect";o.default.error(n),r(n)},t.prototype.pauseEffect=function(e,t){o.default.debug("pauseEffect",e);var r="remote stream does not support pauseEffect";o.default.error(r),t(r)},t.prototype.resumeEffect=function(e,t,r){o.default.debug("resumeEffect",e,t);var n="remote stream does not support resumeEffect";o.default.error(n),r(n)},t.prototype.stopEffect=function(e,t){o.default.debug("stopEffect",e);var r="remote stream does not support stopEffect";o.default.error(r),t(r)},t.prototype.setEffectVolume=function(e,t,r){o.default.debug("setEffectVolume",e,t);var n="remote stream does not support setEffectVolume";o.default.error(n),r(n)},t}(i.RTCStream);t.RemoteStream=d},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(2),o=r(6),i=r(9),a=r(0),s=r(17),c=r(16),u=r(38),d=r(4),p=r(5),f=r(37),l=r(40),m=r(3),h=function(){function e(e,t){var r=this;this.localStreams=[],this.remoteStreams=[],this.players=[],this.cachedAudioBuffers=new Map,this.innerEmitter=new o.EventEmitter,this.currentResolution=i.getResolution(""),this.audioCodec=e,this.videoCodec=t,this.innerEmitter.on("stream-connected",(function(e){a.default.debug("stream-connected ",e),e.isSubscriber?r._emitter.emit("mediaStreamSubscribed",e):r._emitter.emit("mediaStreamPublished",e)})),this.innerEmitter.on("stream-disconnected",(function(e){a.default.debug("stream-disconnected ",e),r._emitter.emit("streamConnectionDisconnected",e)})),this.innerEmitter.on("stream-reconnected",(function(e){a.default.debug("stream-reconnected ",e),r._emitter.emit("streamConnectionReconnected",e)})),this.innerEmitter.on("stream-failed",(function(e){a.default.debug("stream-failed ",e),r._emitter.emit("streamConnectionClosed",e)})),this.innerEmitter.on("stream-reconnecting",(function(e){a.default.debug("stream-reconnecting ",e),r._emitter.emit("streamConnectionReconnecting",e)})),this.innerEmitter.on("screen-track-ended",(function(e){a.default.debug("screen-track-ended",e),r._emitter.emit("screenMediaStreamEnded",e)})),this.innerEmitter.on("stream-close",(function(e){r.destroyPlayer(e)})),this.innerEmitter.on("video-muted",(function(e){a.default.debug("video track muted ",e)})),this.innerEmitter.on("video-unmuted",(function(e){var t;null===(t=r.players.find((function(t){return t.stream===e})))||void 0===t||t.switch2Video().catch((function(e){a.default.warn("instead audio to video of player",e)}))}))}return Object.defineProperty(e.prototype,"emitter",{set:function(e){this._emitter=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"logReporter",{set:function(e){this._logReporter=e},enumerable:!0,configurable:!0}),e.generatePublishConfig=function(e){var t=e.audio,r=e.video,n=e.facingMode,o=e.screenAudio,i=e.screen,a=e.microphoneId,s=e.cameraId,c=e.extensionId,u={audio:!0,video:!0,screenAudio:!1,screen:!1,mediaType:d.ENUM_MEDIA_TYPE.camera,data:!1};return u.audio=t,u.video=r,n&&(u.facingMode=n),"boolean"==typeof o&&(u.screenAudio=o),u.screen=i,a&&(u.microphoneId=a),s&&(u.cameraId=s),i&&(u.mediaType=d.ENUM_MEDIA_TYPE.desktop),r&&(u.mediaType=d.ENUM_MEDIA_TYPE.camera),c&&(u.extensionId=c),u},e.prototype.getResolution=function(){return this.currentResolution},e.prototype.getLocalStream=function(e){return this.localStreams.find((function(t){return t.streamId===e}))},e.prototype.getLocalStreamByPreviewId=function(e){return this.localStreams.find((function(t){return t.previewId===e}))},e.prototype.getAllLocalStreams=function(){return this.localStreams},e.prototype.getRemoteStream=function(e){return this.remoteStreams.find((function(t){return t.streamId===e||t.streamSubId===e}))},e.prototype.getAllRemoteStreams=function(){return this.remoteStreams},e.prototype.getRemoteStreamsByUserId=function(e){return this.remoteStreams.filter((function(t){return t.userId===e}))},e.prototype.getStream=function(e){return this.getLocalStream(e)||this.getRemoteStream(e)},e.prototype.createLocalStream=function(e,t){a.default.debug("create local stream ",e,t);var r=new c.LocalStream(e,t,this.innerEmitter);return r.audioCodec=this.audioCodec,r.videoCodec=this.videoCodec,r.logReporter=this._logReporter,r.setResolution(this.currentResolution),this.localStreams.push(r),r},e.prototype.removeLocalStream=function(e,t){try{var r=this.localStreams.indexOf(e);r>=0&&(this.localStreams.splice(r,1),e.close(t))}catch(e){a.default.error("remove LocalStream failed "+e)}},e.prototype.removeAllLocalStreams=function(){try{this.localStreams.forEach((function(e){e.close()})),this.localStreams=[]}catch(e){a.default.error("clean local streams "+e)}},e.prototype.createRemoteStream=function(e){a.default.debug("create remote stream ",e);var t=this.getRemoteStream(e.sid);if(!t){(t=new u.RemoteStream(e,this.innerEmitter)).audioCodec=this.audioCodec;return/VP8/.test(e.sid)?t.videoCodec="vp8":/H264/.test(e.sid)?t.videoCodec="h264":t.videoCodec=this.videoCodec,t.logReporter=this._logReporter,t.setResolution(this.currentResolution),this.remoteStreams.push(t),t}a.default.error("create remote stream - ","remote stream exists")},e.prototype.removeRemoteStream=function(e){try{var t=this.remoteStreams.indexOf(e);t>=0&&(this.remoteStreams.splice(t,1),e.close())}catch(e){a.default.error("remove RemoteStream failed "+e)}},e.prototype.removeAllRemoteStreams=function(){try{this.remoteStreams.forEach((function(e){e.close()})),this.localStreams=[]}catch(e){a.default.error("clean remote streams "+e)}},e.prototype.setVideoProfile=function(e){return this.currentResolution=i.getResolution(e),Promise.resolve()},e.prototype.preloadEffect=function(e,t,r){s.AudioHelper.loadAudioBuffer(this.cachedAudioBuffers,e,t).then((function(){r()})).catch((function(e){a.default.error("preloadEffect - "+e),r(e)}))},e.prototype.unloadEffect=function(e){s.AudioHelper.unloadAudioBuffer(this.cachedAudioBuffers,e)},e.prototype.removeAllEffect=function(){this.cachedAudioBuffers=new Map},e.prototype.playEffect=function(e,t,r){var n=this.getLocalStream(e)||this.getRemoteStream(e);if(n)n.playEffect(this.cachedAudioBuffers,t,r);else{r("cannot find stream")}},e.prototype.pauseEffect=function(e,t,r){var n=this.getLocalStream(e)||this.getRemoteStream(e);if(n)n.pauseEffect(t,r);else{r("cannot find stream")}},e.prototype.resumeEffect=function(e,t,r){var n=this.getLocalStream(e)||this.getRemoteStream(e);if(n)n.resumeEffect(this.cachedAudioBuffers,t,r);else{r("cannot find stream")}},e.prototype.stopEffect=function(e,t,r){var n=this.getLocalStream(e)||this.getRemoteStream(e);if(n)n.stopEffect(t,r);else{r("cannot find stream")}},e.prototype.setEffectVolume=function(e,t,r,n){var o=this.getLocalStream(e)||this.getRemoteStream(e);if(o)o.setEffectVolume(t,r,n);else{n("cannot find stream")}},e.enumerateDevices=function(e,t,r){var o=this;new Promise((function(t,r){return n.__awaiter(o,void 0,void 0,(function(){var o,i,s,c,u,d;return n.__generator(this,(function(n){switch(n.label){case 0:o=!0,n.label=1;case 1:return n.trys.push([1,3,,4]),[4,navigator.mediaDevices.enumerateDevices()];case 2:return 0===(u=n.sent()).length?(t(u),[2]):(u.forEach((function(e){""===e.label&&(o=!1)})),o?(t(u),[2]):[3,4]);case 3:return i=n.sent(),r(i),[2];case 4:return n.trys.push([4,6,,7]),s={},e.includes("audio")&&(s.audio=!0),e.includes("video")&&(s.video=!0),[4,navigator.mediaDevices.getUserMedia(s)];case 5:return n.sent().getTracks().forEach((function(e){e.stop()})),[3,7];case 6:return c=n.sent(),a.default.warn("EnumerateDevices ",c),[3,7];case 7:return n.trys.push([7,9,,10]),[4,navigator.mediaDevices.enumerateDevices()];case 8:return u=n.sent(),t(u),[3,10];case 9:return d=n.sent(),r(d),[3,10];case 10:return[2]}}))}))})).then(t).catch(r)},e.prototype.snapshot=function(e,t){var r="";"string"==typeof t?r=t:t&&(r="urtc-snapshot-"+f.formatTime(new Date,"YYYY-MM-DD_HHmmss"));var n=this.getStream(e);if(n)return n.snapshot(r);var o="stream is not found";return a.default.warn(o),Promise.reject(new Error(o))},e.deviceDetection=function(e){var t,r,o=this;if(e.audio){var i={audio:!0,video:!1,screen:!1,data:!1,mediaType:d.ENUM_MEDIA_TYPE.camera,microphoneId:e.microphoneId};t=new c.LocalStream("audioDetection",i)}if(e.video){i={audio:!1,video:!0,screen:!1,data:!1,mediaType:d.ENUM_MEDIA_TYPE.camera,cameraId:e.cameraId};r=new c.LocalStream("videoDetection",i)}return new Promise((function(e){return n.__awaiter(o,void 0,void 0,(function(){var o,i,s;return n.__generator(this,(function(n){switch(n.label){case 0:if(o={audio:!1,video:!1},!t)return[3,6];n.label=1;case 1:return n.trys.push([1,4,,5]),[4,t.initMediaStream()];case 2:return n.sent(),[4,t.addTracks2MediaStream()];case 3:return n.sent(),o.audio=!0,[3,5];case 4:return i=n.sent(),a.default.warn("audio input device invalid ",i),o.audioError=i.message,[3,5];case 5:try{t.close()}catch(e){a.default.warn("audio input device invalid ",e),o.audioError=e.message}n.label=6;case 6:if(!r)return[3,12];n.label=7;case 7:return n.trys.push([7,10,,11]),[4,r.initMediaStream()];case 8:return n.sent(),[4,r.addTracks2MediaStream()];case 9:return n.sent(),o.video=!0,[3,11];case 10:return s=n.sent(),a.default.warn("video input device invalid ",s),o.videoError=s.message,[3,11];case 11:try{r.close()}catch(e){a.default.warn("video input device invalid ",e),o.videoError=e.message}n.label=12;case 12:return e(o),[2]}}))}))}))},e.getSupportedCodec=function(){return n.__awaiter(this,void 0,void 0,(function(){var e,t,r;return n.__generator(this,(function(n){switch(n.label){case 0:t={video:[],audio:[]};try{e=p.default.isChrome()||p.default.isSafari()?new RTCPeerConnection({sdpSemantics:"plan-b"}):new RTCPeerConnection}catch(e){return a.default.error("get supported codec "+e),[2,t]}return[4,e.createOffer({offerToReceiveAudio:!0,offerToReceiveVideo:!0})];case 1:return(r=n.sent()).sdp&&(r.sdp.match(/ vp8/i)&&t.video.push("vp8"),r.sdp.match(/ h264/i)&&t.video.push("h264"),r.sdp.match(/ opus/i)&&t.audio.push("opus")),[2,t]}}))}))},e.isSupportWebRTC=function(){var e=window.RTCPeerConnection||window.mozRTCPeerConnection||window.webkitRTCPeerConnection,t=navigator&&(navigator.getUserMedia||navigator.webkitGetUserMedia||navigator.msGetUserMedia||navigator.mozGetUserMedia||navigator.mediaDevices&&navigator.mediaDevices.getUserMedia),r=window.WebSocket;return!!e&&!!t&&!!r},e.prototype.play=function(e,t,r){var n=this.players.find((function(t){return t.stream===e}));return n?Promise.reject(m.createError(m.ErrorCodes.OTHERS,"the play function has already been invoked, you can invoke the resume function to play")):(n=new l.Player(e,t,r),this.players.push(n),n.play())},e.prototype.resume=function(e){e.resumeAudio().catch((function(e){a.default.warn("resume audio faild "+e)}));var t=this.players.find((function(t){return t.stream===e}));return t?t.resume():Promise.reject(m.createError(m.ErrorCodes.OTHERS,"stream isn't playing"))},e.prototype.stop=function(e){var t=this.players.find((function(t){return t.stream===e}));return t?(t.stop(),Promise.resolve()):Promise.reject(m.createError(m.ErrorCodes.OTHERS,"stream isn't playing"))},e.prototype.destroyPlayer=function(e){var t=this.players.findIndex((function(t){return t.stream===e}));t>=0&&(this.players[t].destroy(),this.players.splice(t,1))},e.prototype.setAudioVolume=function(e,t){var r=this.players.find((function(t){return t.stream===e}));return r?(r.setAudioVolume(t),Promise.resolve()):Promise.reject(m.createError(m.ErrorCodes.OTHERS,"stream isn't playing"))},e}();t.StreamManager=h},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n,o=r(2),i=r(4),a=r(3),s=r(0);!function(e){e[e.initing=0]="initing",e[e.inited=1]="inited",e[e.paused=2]="paused",e[e.playing=3]="playing"}(n||(n={}));var c=function(){function e(e,t,r){this._status=n.initing,this.countdown=0,this.container=t,this.stream=e;var o=r.mute,i=void 0!==o&&o,a=r.mirror,s=void 0!==a&&a,c=r.fit,u=r.controls;u&&(this.controls=u),this.initWrapper(),this.initVideoElement(i,s,c),this.wrapper.appendChild(this.video),this.initAudioElement(i),this.wrapper.appendChild(this.audio)}return Object.defineProperty(e.prototype,"status",{get:function(){return this._status},enumerable:!0,configurable:!0}),e.prototype.init=function(){var e,t,r,o,i=this,a=this.stream.getMediaStream();a&&(this.audioTrack=a.getAudioTracks()[0],null===(e=this.audioTrack)||void 0===e||e.addEventListener("mute",(function(){})),null===(t=this.audioTrack)||void 0===t||t.addEventListener("unmute",(function(){})),this.videoTrack=a.getVideoTracks()[0],null===(r=this.videoTrack)||void 0===r||r.addEventListener("mute",(function(){s.default.debug("player - video muted",i.stream.streamId)})),null===(o=this.videoTrack)||void 0===o||o.addEventListener("unmute",(function(){s.default.debug("player - video unmuted",i.stream.streamId),i.switch2Video().catch((function(e){s.default.warn("player - instead audio to video of player",e)}))})),this._status=n.inited),this.audio.addEventListener("play",(function(){i.updateControls(i.audio,!0),i._status=n.playing})),this.audio.addEventListener("pause",(function(){i.updateControls(i.audio,!1),i._status=n.paused})),this.video.addEventListener("play",(function(){i.updateControls(i.video,!0),i._status=n.playing})),this.video.addEventListener("pause",(function(){i.updateControls(i.video,!1),i._status=n.paused}))},e.prototype.updateControls=function(e,t){switch(this.controls){case"hide":e.controls=!1;break;case"show":e.controls=!0;break;case"auto":default:e.controls=!t}},e.prototype.switch2Video=function(){var e=this;return new Promise((function(t,r){if(e.playingElement!==e.video){var n=e.playingElement,o=e.stream.getMediaStream();o?e.playVideo(o).then((function(){n&&(n.pause(),n.srcObject=null),t()})).catch((function(e){n&&(n.pause(),n.srcObject=null),r(e)})):t()}else t()}))},e.prototype.playAudio=function(e){var t=this,r=e.getAudioTracks()[0],o=new MediaStream;return o.addTrack(r),this.audio.style.display="inline-block",this.video.style.display="none",this.audio.srcObject=o,this.playingElement=this.audio,new Promise((function(e){t.countdown=window.setTimeout(e,0)})).then((function(){return t.audio.play().catch((function(e){throw t.updateControls(t.audio,!1),t._status=n.paused,e}))}))},e.prototype.playVideo=function(e){var t=this;return this.audio.style.display="none",this.video.style.display="inline-block",this.video.srcObject=e,this.playingElement=this.video,new Promise((function(e){t.countdown=window.setTimeout(e,0)})).then((function(){return t.video.play().catch((function(e){throw t.updateControls(t.video,!1),t._status=n.paused,e}))}))},e.prototype.resume=function(){return o.__awaiter(this,void 0,void 0,(function(){var e,t=this;return o.__generator(this,(function(r){return this.playingElement?(e=this.playingElement,this.stream.isSubscriber&&(e.muted=!1),[2,e.play().catch((function(r){throw t.updateControls(e,!1),t._status=n.paused,r}))]):[2,Promise.reject(a.createError(a.ErrorCodes.OTHERS,"not playing"))]}))}))},e.prototype.play=function(){return o.__awaiter(this,void 0,void 0,(function(){var e;return o.__generator(this,(function(t){return(e=this.stream.getMediaStream())?(this.status===n.initing&&this.init(),this.container.appendChild(this.wrapper),this.stream.video?this.stream.mutevideo?[2,this.playAudio(e)]:[2,this.playVideo(e)]:this.stream.audio?this.stream.isSubscriber?[2,this.playAudio(e)]:[2,Promise.resolve()]:[2,Promise.reject(a.createError(a.ErrorCodes.OTHERS,"no audio and video"))]):[2,Promise.reject(a.createError(a.ErrorCodes.INVALID_MEDIASTREAM,"no media stream can play"))]}))}))},e.prototype.stop=function(){this.playingElement&&this.playingElement.pause(),this.countdown&&(window.clearTimeout(this.countdown),this.countdown=0)},e.prototype.destroy=function(){try{this.stop()}catch(e){s.default.warn(e.name+": "+e.message)}try{this.container.removeChild(this.wrapper)}catch(e){s.default.warn(e.name+": "+e.message)}},e.prototype.initWrapper=function(){this.wrapper=document.createElement("div"),this.stream.video?this.wrapper.setAttribute("style","width: 100%; height: 100%; position: relative; background-color: black; overflow: hidden;"):this.wrapper.setAttribute("style","width: 100%; height: 100%; position: relative; overflow: hidden;")},e.prototype.initAudioElement=function(e){void 0===e&&(e=!1),this.audio=document.createElement("audio"),this.audio.setAttribute("id","audio-"+this.stream.streamId),this.audio.muted=e,this.stream.isSubscriber||(this.audio.muted=!0),this.audio.setAttribute("autoplay",""),this.audio.setAttribute("playsinline",""),this.audio.setAttribute("webkit-playsinline","true")},e.prototype.initVideoElement=function(e,t,r){void 0===e&&(e=!1),void 0===t&&(t=!1),this.video=document.createElement("video"),this.video.setAttribute("id","video-"+this.stream.streamId),this.video.muted=e,this.stream.isSubscriber||(this.video.muted=!0,"user"===this.stream.config.facingMode&&(t=!0)),r||(r="cover",this.stream.mediaType===i.ENUM_MEDIA_TYPE.desktop&&(r="contain"));var n="width: 100%; height: 100%; position: absolute;";t&&(n+="transform: rotateY(180deg);"),n+="object-fit: "+r,this.video.setAttribute("style",n),this.video.setAttribute("autoplay",""),this.video.setAttribute("playsinline",""),this.video.setAttribute("webkit-playsinline","true")},e.prototype.setAudioVolume=function(e){e/=100,this.audio.volume=e,this.video.volume=e},e}();t.Player=c},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(79),o=r(80),i=r(81);function a(e,t,r,a){var s=e,c=t,u=r,d=a,p=n.Base64.encode(JSON.stringify({user_id:d,room_id:u,app_id:s})),f=Math.round(Date.now()/1e3),l=i.randNum(8),m=d+s+f+l+u,h=new o("SHA-1","TEXT");return h.setHMACKey(c,"TEXT"),h.update(m),p+"."+h.getHMAC("HEX")+f+l}function s(e){return JSON.parse(n.Base64.decode(e))}function c(e){return n.Base64.encode(JSON.stringify(e))}t.genToken=a,t.decode=s,t.encode=c;var u={genToken:a,decode:s,encode:c};t.default=u},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.convertToOuterUser=function(e){return{uid:e.user_id}}},function(e,t,r){"use strict";var n=r(7);function o(e,t,r,o,i){var a=n.writeRtpDescription(e.kind,t);if(a+=n.writeIceParameters(e.iceGatherer.getLocalParameters()),a+=n.writeDtlsParameters(e.dtlsTransport.getLocalParameters(),"offer"===r?"actpass":i||"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 s=e.rtpSender._initialTrackId||e.rtpSender.track.id;e.rtpSender._initialTrackId=s;var c="msid:"+(o?o.id:"-")+" "+s+"\r\n";a+="a="+c,a+="a=ssrc:"+e.sendEncodingParameters[0].ssrc+" "+c,e.sendEncodingParameters[0].rtx&&(a+="a=ssrc:"+e.sendEncodingParameters[0].rtx.ssrc+" "+c,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:"+n.localCName+"\r\n",e.rtpSender&&e.sendEncodingParameters[0].rtx&&(a+="a=ssrc:"+e.sendEncodingParameters[0].rtx.ssrc+" cname:"+n.localCName+"\r\n"),a}function i(e,t){var r={codecs:[],headerExtensions:[],fecMechanisms:[]},n=function(e,t){e=parseInt(e,10);for(var r=0;r<t.length;r++)if(t[r].payloadType===e||t[r].preferredPayloadType===e)return t[r]},o=function(e,t,r,o){var i=n(e.parameters.apt,r),a=n(t.parameters.apt,o);return i&&a&&i.name.toLowerCase()===a.name.toLowerCase()};return e.codecs.forEach((function(n){for(var i=0;i<t.codecs.length;i++){var a=t.codecs[i];if(n.name.toLowerCase()===a.name.toLowerCase()&&n.clockRate===a.clockRate){if("rtx"===n.name.toLowerCase()&&n.parameters&&a.parameters.apt&&!o(n,a,e.codecs,t.codecs))continue;(a=JSON.parse(JSON.stringify(a))).numChannels=Math.min(n.numChannels,a.numChannels),r.codecs.push(a),a.rtcpFeedback=a.rtcpFeedback.filter((function(e){for(var t=0;t<n.rtcpFeedback.length;t++)if(n.rtcpFeedback[t].type===e.type&&n.rtcpFeedback[t].parameter===e.parameter)return!0;return!1}));break}}})),e.headerExtensions.forEach((function(e){for(var n=0;n<t.headerExtensions.length;n++){var o=t.headerExtensions[n];if(e.uri===o.uri){r.headerExtensions.push(o);break}}})),r}function a(e,t,r){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(r)}function s(e,t){var r=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 r||e.addRemoteCandidate(t),!r}function c(e,t){var r=new Error(t);return r.name=e,r.code={NotSupportedError:9,InvalidStateError:11,InvalidAccessError:15,TypeError:void 0,OperationError:void 0}[e],r}e.exports=function(e,t){function r(t,r){r.addTrack(t),r.dispatchEvent(new e.MediaStreamTrackEvent("addtrack",{track:t}))}function u(t,r,n,o){var i=new Event("track");i.track=r,i.receiver=n,i.transceiver={receiver:n},i.streams=o,e.setTimeout((function(){t._dispatchEvent("track",i)}))}var d=function(r){var o=this,i=document.createDocumentFragment();if(["addEventListener","removeEventListener","dispatchEvent"].forEach((function(e){o[e]=i[e].bind(i)})),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",r=JSON.parse(JSON.stringify(r||{})),this.usingBundle="max-bundle"===r.bundlePolicy,"negotiate"===r.rtcpMuxPolicy)throw c("NotSupportedError","rtcpMuxPolicy 'negotiate' is not supported");switch(r.rtcpMuxPolicy||(r.rtcpMuxPolicy="require"),r.iceTransportPolicy){case"all":case"relay":break;default:r.iceTransportPolicy="all"}switch(r.bundlePolicy){case"balanced":case"max-compat":case"max-bundle":break;default:r.bundlePolicy="balanced"}if(r.iceServers=function(e,t){var r=!1;return(e=JSON.parse(JSON.stringify(e))).filter((function(e){if(e&&(e.urls||e.url)){var n=e.urls||e.url;e.url&&!e.urls&&console.warn("RTCIceServer.url is deprecated! Use urls instead.");var o="string"==typeof n;return o&&(n=[n]),n=n.filter((function(e){return 0===e.indexOf("turn:")&&-1!==e.indexOf("transport=udp")&&-1===e.indexOf("turn:[")&&!r?(r=!0,!0):0===e.indexOf("stun:")&&t>=14393&&-1===e.indexOf("?transport=udp")})),delete e.url,e.urls=o?n[0]:n,!!n.length}}))}(r.iceServers||[],t),this._iceGatherers=[],r.iceCandidatePoolSize)for(var a=r.iceCandidatePoolSize;a>0;a--)this._iceGatherers.push(new e.RTCIceGatherer({iceServers:r.iceServers,gatherPolicy:r.iceTransportPolicy}));else r.iceCandidatePoolSize=0;this._config=r,this.transceivers=[],this._sdpSessionId=n.generateSessionId(),this._sdpSessionVersion=0,this._dtlsRole=void 0,this._isClosed=!1};Object.defineProperty(d.prototype,"localDescription",{configurable:!0,get:function(){return this._localDescription}}),Object.defineProperty(d.prototype,"remoteDescription",{configurable:!0,get:function(){return this._remoteDescription}}),d.prototype.onicecandidate=null,d.prototype.onaddstream=null,d.prototype.ontrack=null,d.prototype.onremovestream=null,d.prototype.onsignalingstatechange=null,d.prototype.oniceconnectionstatechange=null,d.prototype.onconnectionstatechange=null,d.prototype.onicegatheringstatechange=null,d.prototype.onnegotiationneeded=null,d.prototype.ondatachannel=null,d.prototype._dispatchEvent=function(e,t){this._isClosed||(this.dispatchEvent(t),"function"==typeof this["on"+e]&&this["on"+e](t))},d.prototype._emitGatheringStateChange=function(){var e=new Event("icegatheringstatechange");this._dispatchEvent("icegatheringstatechange",e)},d.prototype.getConfiguration=function(){return this._config},d.prototype.getLocalStreams=function(){return this.localStreams},d.prototype.getRemoteStreams=function(){return this.remoteStreams},d.prototype._createTransceiver=function(e,t){var r=this.transceivers.length>0,n={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&&r)n.iceTransport=this.transceivers[0].iceTransport,n.dtlsTransport=this.transceivers[0].dtlsTransport;else{var o=this._createIceAndDtlsTransports();n.iceTransport=o.iceTransport,n.dtlsTransport=o.dtlsTransport}return t||this.transceivers.push(n),n},d.prototype.addTrack=function(t,r){if(this._isClosed)throw c("InvalidStateError","Attempted to call addTrack on a closed peerconnection.");var n;if(this.transceivers.find((function(e){return e.track===t})))throw c("InvalidAccessError","Track already exists.");for(var o=0;o<this.transceivers.length;o++)this.transceivers[o].track||this.transceivers[o].kind!==t.kind||(n=this.transceivers[o]);return n||(n=this._createTransceiver(t.kind)),this._maybeFireNegotiationNeeded(),-1===this.localStreams.indexOf(r)&&this.localStreams.push(r),n.track=t,n.stream=r,n.rtpSender=new e.RTCRtpSender(t,n.dtlsTransport),n.rtpSender},d.prototype.addStream=function(e){var r=this;if(t>=15025)e.getTracks().forEach((function(t){r.addTrack(t,e)}));else{var n=e.clone();e.getTracks().forEach((function(e,t){var r=n.getTracks()[t];e.addEventListener("enabled",(function(e){r.enabled=e.enabled}))})),n.getTracks().forEach((function(e){r.addTrack(e,n)}))}},d.prototype.removeTrack=function(t){if(this._isClosed)throw c("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 r=this.transceivers.find((function(e){return e.rtpSender===t}));if(!r)throw c("InvalidAccessError","Sender was not created by this connection.");var n=r.stream;r.rtpSender.stop(),r.rtpSender=null,r.track=null,r.stream=null,-1===this.transceivers.map((function(e){return e.stream})).indexOf(n)&&this.localStreams.indexOf(n)>-1&&this.localStreams.splice(this.localStreams.indexOf(n),1),this._maybeFireNegotiationNeeded()},d.prototype.removeStream=function(e){var t=this;e.getTracks().forEach((function(e){var r=t.getSenders().find((function(t){return t.track===e}));r&&t.removeTrack(r)}))},d.prototype.getSenders=function(){return this.transceivers.filter((function(e){return!!e.rtpSender})).map((function(e){return e.rtpSender}))},d.prototype.getReceivers=function(){return this.transceivers.filter((function(e){return!!e.rtpReceiver})).map((function(e){return e.rtpReceiver}))},d.prototype._createIceGatherer=function(t,r){var n=this;if(r&&t>0)return this.transceivers[0].iceGatherer;if(this._iceGatherers.length)return this._iceGatherers.shift();var o=new e.RTCIceGatherer({iceServers:this._config.iceServers,gatherPolicy:this._config.iceTransportPolicy});return Object.defineProperty(o,"state",{value:"new",writable:!0}),this.transceivers[t].bufferedCandidateEvents=[],this.transceivers[t].bufferCandidates=function(e){var r=!e.candidate||0===Object.keys(e.candidate).length;o.state=r?"completed":"gathering",null!==n.transceivers[t].bufferedCandidateEvents&&n.transceivers[t].bufferedCandidateEvents.push(e)},o.addEventListener("localcandidate",this.transceivers[t].bufferCandidates),o},d.prototype._gather=function(t,r){var o=this,i=this.transceivers[r].iceGatherer;if(!i.onlocalcandidate){var a=this.transceivers[r].bufferedCandidateEvents;this.transceivers[r].bufferedCandidateEvents=null,i.removeEventListener("localcandidate",this.transceivers[r].bufferCandidates),i.onlocalcandidate=function(e){if(!(o.usingBundle&&r>0)){var a=new Event("icecandidate");a.candidate={sdpMid:t,sdpMLineIndex:r};var s=e.candidate,c=!s||0===Object.keys(s).length;if(c)"new"!==i.state&&"gathering"!==i.state||(i.state="completed");else{"new"===i.state&&(i.state="gathering"),s.component=1,s.ufrag=i.getLocalParameters().usernameFragment;var u=n.writeCandidate(s);a.candidate=Object.assign(a.candidate,n.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 d=n.getMediaSections(o._localDescription.sdp);d[a.candidate.sdpMLineIndex]+=c?"a=end-of-candidates\r\n":"a="+a.candidate.candidate+"\r\n",o._localDescription.sdp=n.getDescription(o._localDescription.sdp)+d.join("");var p=o.transceivers.every((function(e){return e.iceGatherer&&"completed"===e.iceGatherer.state}));"gathering"!==o.iceGatheringState&&(o.iceGatheringState="gathering",o._emitGatheringStateChange()),c||o._dispatchEvent("icecandidate",a),p&&(o._dispatchEvent("icecandidate",new Event("icecandidate")),o.iceGatheringState="complete",o._emitGatheringStateChange())}},e.setTimeout((function(){a.forEach((function(e){i.onlocalcandidate(e)}))}),0)}},d.prototype._createIceAndDtlsTransports=function(){var t=this,r=new e.RTCIceTransport(null);r.onicestatechange=function(){t._updateIceConnectionState(),t._updateConnectionState()};var n=new e.RTCDtlsTransport(r);return n.ondtlsstatechange=function(){t._updateConnectionState()},n.onerror=function(){Object.defineProperty(n,"state",{value:"failed",writable:!0}),t._updateConnectionState()},{iceTransport:r,dtlsTransport:n}},d.prototype._disposeIceAndDtlsTransports=function(e){var t=this.transceivers[e].iceGatherer;t&&(delete t.onlocalcandidate,delete this.transceivers[e].iceGatherer);var r=this.transceivers[e].iceTransport;r&&(delete r.onicestatechange,delete this.transceivers[e].iceTransport);var n=this.transceivers[e].dtlsTransport;n&&(delete n.ondtlsstatechange,delete n.onerror,delete this.transceivers[e].dtlsTransport)},d.prototype._transceive=function(e,r,o){var a=i(e.localCapabilities,e.remoteCapabilities);r&&e.rtpSender&&(a.encodings=e.sendEncodingParameters,a.rtcp={cname:n.localCName,compound:e.rtcpParameters.compound},e.recvEncodingParameters.length&&(a.rtcp.ssrc=e.recvEncodingParameters[0].ssrc),e.rtpSender.send(a)),o&&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))},d.prototype.setLocalDescription=function(e){var t,r,o=this;if(-1===["offer","answer"].indexOf(e.type))return Promise.reject(c("TypeError",'Unsupported type "'+e.type+'"'));if(!a("setLocalDescription",e.type,o.signalingState)||o._isClosed)return Promise.reject(c("InvalidStateError","Can not set local "+e.type+" in state "+o.signalingState));if("offer"===e.type)t=n.splitSections(e.sdp),r=t.shift(),t.forEach((function(e,t){var r=n.parseRtpParameters(e);o.transceivers[t].localCapabilities=r})),o.transceivers.forEach((function(e,t){o._gather(e.mid,t)}));else if("answer"===e.type){t=n.splitSections(o._remoteDescription.sdp),r=t.shift();var s=n.matchPrefix(r,"a=ice-lite").length>0;t.forEach((function(e,t){var a=o.transceivers[t],c=a.iceGatherer,u=a.iceTransport,d=a.dtlsTransport,p=a.localCapabilities,f=a.remoteCapabilities;if(!(n.isRejected(e)&&0===n.matchPrefix(e,"a=bundle-only").length)&&!a.rejected){var l=n.getIceParameters(e,r),m=n.getDtlsParameters(e,r);s&&(m.role="server"),o.usingBundle&&0!==t||(o._gather(a.mid,t),"new"===u.state&&u.start(c,l,s?"controlling":"controlled"),"new"===d.state&&d.start(m));var h=i(p,f);o._transceive(a,h.codecs.length>0,!1)}}))}return o._localDescription={type:e.type,sdp:e.sdp},"offer"===e.type?o._updateSignalingState("have-local-offer"):o._updateSignalingState("stable"),Promise.resolve()},d.prototype.setRemoteDescription=function(o){var d=this;if(-1===["offer","answer"].indexOf(o.type))return Promise.reject(c("TypeError",'Unsupported type "'+o.type+'"'));if(!a("setRemoteDescription",o.type,d.signalingState)||d._isClosed)return Promise.reject(c("InvalidStateError","Can not set remote "+o.type+" in state "+d.signalingState));var p={};d.remoteStreams.forEach((function(e){p[e.id]=e}));var f=[],l=n.splitSections(o.sdp),m=l.shift(),h=n.matchPrefix(m,"a=ice-lite").length>0,v=n.matchPrefix(m,"a=group:BUNDLE ").length>0;d.usingBundle=v;var g=n.matchPrefix(m,"a=ice-options:")[0];return d.canTrickleIceCandidates=!!g&&g.substr(14).split(" ").indexOf("trickle")>=0,l.forEach((function(a,c){var u=n.splitLines(a),l=n.getKind(a),g=n.isRejected(a)&&0===n.matchPrefix(a,"a=bundle-only").length,y=u[0].substr(2).split(" ")[2],b=n.getDirection(a,m),E=n.parseMsid(a),_=n.getMid(a)||n.generateIdentifier();if(g||"application"===l&&("DTLS/SCTP"===y||"UDP/DTLS/SCTP"===y))d.transceivers[c]={mid:_,kind:l,protocol:y,rejected:!0};else{var S,T,R,w,M,C,P,O,A;!g&&d.transceivers[c]&&d.transceivers[c].rejected&&(d.transceivers[c]=d._createTransceiver(l,!0));var I,k,N=n.parseRtpParameters(a);g||(I=n.getIceParameters(a,m),(k=n.getDtlsParameters(a,m)).role="client"),P=n.parseRtpEncodingParameters(a);var x=n.parseRtcpParameters(a),U=n.matchPrefix(a,"a=end-of-candidates",m).length>0,L=n.matchPrefix(a,"a=candidate:").map((function(e){return n.parseCandidate(e)})).filter((function(e){return 1===e.component}));if(("offer"===o.type||"answer"===o.type)&&!g&&v&&c>0&&d.transceivers[c]&&(d._disposeIceAndDtlsTransports(c),d.transceivers[c].iceGatherer=d.transceivers[0].iceGatherer,d.transceivers[c].iceTransport=d.transceivers[0].iceTransport,d.transceivers[c].dtlsTransport=d.transceivers[0].dtlsTransport,d.transceivers[c].rtpSender&&d.transceivers[c].rtpSender.setTransport(d.transceivers[0].dtlsTransport),d.transceivers[c].rtpReceiver&&d.transceivers[c].rtpReceiver.setTransport(d.transceivers[0].dtlsTransport)),"offer"!==o.type||g){if("answer"===o.type&&!g){T=(S=d.transceivers[c]).iceGatherer,R=S.iceTransport,w=S.dtlsTransport,M=S.rtpReceiver,C=S.sendEncodingParameters,O=S.localCapabilities,d.transceivers[c].recvEncodingParameters=P,d.transceivers[c].remoteCapabilities=N,d.transceivers[c].rtcpParameters=x,L.length&&"new"===R.state&&(!h&&!U||v&&0!==c?L.forEach((function(e){s(S.iceTransport,e)})):R.setRemoteCandidates(L)),v&&0!==c||("new"===R.state&&R.start(T,I,"controlling"),"new"===w.state&&w.start(k)),!i(S.localCapabilities,S.remoteCapabilities).codecs.filter((function(e){return"rtx"===e.name.toLowerCase()})).length&&S.sendEncodingParameters[0].rtx&&delete S.sendEncodingParameters[0].rtx,d._transceive(S,"sendrecv"===b||"recvonly"===b,"sendrecv"===b||"sendonly"===b),!M||"sendrecv"!==b&&"sendonly"!==b?delete S.rtpReceiver:(A=M.track,E?(p[E.stream]||(p[E.stream]=new e.MediaStream),r(A,p[E.stream]),f.push([A,M,p[E.stream]])):(p.default||(p.default=new e.MediaStream),r(A,p.default),f.push([A,M,p.default])))}}else{(S=d.transceivers[c]||d._createTransceiver(l)).mid=_,S.iceGatherer||(S.iceGatherer=d._createIceGatherer(c,v)),L.length&&"new"===S.iceTransport.state&&(!U||v&&0!==c?L.forEach((function(e){s(S.iceTransport,e)})):S.iceTransport.setRemoteCandidates(L)),O=e.RTCRtpReceiver.getCapabilities(l),t<15019&&(O.codecs=O.codecs.filter((function(e){return"rtx"!==e.name}))),C=S.sendEncodingParameters||[{ssrc:1001*(2*c+2)}];var j,D=!1;if("sendrecv"===b||"sendonly"===b){if(D=!S.rtpReceiver,M=S.rtpReceiver||new e.RTCRtpReceiver(S.dtlsTransport,l),D)A=M.track,E&&"-"===E.stream||(E?(p[E.stream]||(p[E.stream]=new e.MediaStream,Object.defineProperty(p[E.stream],"id",{get:function(){return E.stream}})),Object.defineProperty(A,"id",{get:function(){return E.track}}),j=p[E.stream]):(p.default||(p.default=new e.MediaStream),j=p.default)),j&&(r(A,j),S.associatedRemoteMediaStreams.push(j)),f.push([A,M,j])}else S.rtpReceiver&&S.rtpReceiver.track&&(S.associatedRemoteMediaStreams.forEach((function(t){var r=t.getTracks().find((function(e){return e.id===S.rtpReceiver.track.id}));r&&function(t,r){r.removeTrack(t),r.dispatchEvent(new e.MediaStreamTrackEvent("removetrack",{track:t}))}(r,t)})),S.associatedRemoteMediaStreams=[]);S.localCapabilities=O,S.remoteCapabilities=N,S.rtpReceiver=M,S.rtcpParameters=x,S.sendEncodingParameters=C,S.recvEncodingParameters=P,d._transceive(d.transceivers[c],!1,D)}}})),void 0===d._dtlsRole&&(d._dtlsRole="offer"===o.type?"active":"passive"),d._remoteDescription={type:o.type,sdp:o.sdp},"offer"===o.type?d._updateSignalingState("have-remote-offer"):d._updateSignalingState("stable"),Object.keys(p).forEach((function(t){var r=p[t];if(r.getTracks().length){if(-1===d.remoteStreams.indexOf(r)){d.remoteStreams.push(r);var n=new Event("addstream");n.stream=r,e.setTimeout((function(){d._dispatchEvent("addstream",n)}))}f.forEach((function(e){var t=e[0],n=e[1];r.id===e[2].id&&u(d,t,n,[r])}))}})),f.forEach((function(e){e[2]||u(d,e[0],e[1],[])})),e.setTimeout((function(){d&&d.transceivers&&d.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()},d.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")},d.prototype._updateSignalingState=function(e){this.signalingState=e;var t=new Event("signalingstatechange");this._dispatchEvent("signalingstatechange",t)},d.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))},d.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){e.iceTransport&&!e.rejected&&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 r=new Event("iceconnectionstatechange");this._dispatchEvent("iceconnectionstatechange",r)}},d.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){e.iceTransport&&e.dtlsTransport&&!e.rejected&&(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 r=new Event("connectionstatechange");this._dispatchEvent("connectionstatechange",r)}},d.prototype.createOffer=function(){var r=this;if(r._isClosed)return Promise.reject(c("InvalidStateError","Can not call createOffer after close"));var i=r.transceivers.filter((function(e){return"audio"===e.kind})).length,a=r.transceivers.filter((function(e){return"video"===e.kind})).length,s=arguments[0];if(s){if(s.mandatory||s.optional)throw new TypeError("Legacy mandatory/optional constraints not supported.");void 0!==s.offerToReceiveAudio&&(i=!0===s.offerToReceiveAudio?1:!1===s.offerToReceiveAudio?0:s.offerToReceiveAudio),void 0!==s.offerToReceiveVideo&&(a=!0===s.offerToReceiveVideo?1:!1===s.offerToReceiveVideo?0:s.offerToReceiveVideo)}for(r.transceivers.forEach((function(e){"audio"===e.kind?--i<0&&(e.wantReceive=!1):"video"===e.kind&&--a<0&&(e.wantReceive=!1)}));i>0||a>0;)i>0&&(r._createTransceiver("audio"),i--),a>0&&(r._createTransceiver("video"),a--);var u=n.writeSessionBoilerplate(r._sdpSessionId,r._sdpSessionVersion++);r.transceivers.forEach((function(o,i){var a=o.track,s=o.kind,c=o.mid||n.generateIdentifier();o.mid=c,o.iceGatherer||(o.iceGatherer=r._createIceGatherer(i,r.usingBundle));var u=e.RTCRtpSender.getCapabilities(s);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"),o.remoteCapabilities&&o.remoteCapabilities.codecs&&o.remoteCapabilities.codecs.forEach((function(t){e.name.toLowerCase()===t.name.toLowerCase()&&e.clockRate===t.clockRate&&(e.preferredPayloadType=t.payloadType)}))})),u.headerExtensions.forEach((function(e){(o.remoteCapabilities&&o.remoteCapabilities.headerExtensions||[]).forEach((function(t){e.uri===t.uri&&(e.id=t.id)}))}));var d=o.sendEncodingParameters||[{ssrc:1001*(2*i+1)}];a&&t>=15019&&"video"===s&&!d[0].rtx&&(d[0].rtx={ssrc:d[0].ssrc+1}),o.wantReceive&&(o.rtpReceiver=new e.RTCRtpReceiver(o.dtlsTransport,s)),o.localCapabilities=u,o.sendEncodingParameters=d})),"max-compat"!==r._config.bundlePolicy&&(u+="a=group:BUNDLE "+r.transceivers.map((function(e){return e.mid})).join(" ")+"\r\n"),u+="a=ice-options:trickle\r\n",r.transceivers.forEach((function(e,t){u+=o(e,e.localCapabilities,"offer",e.stream,r._dtlsRole),u+="a=rtcp-rsize\r\n",!e.iceGatherer||"new"===r.iceGatheringState||0!==t&&r.usingBundle||(e.iceGatherer.getLocalCandidates().forEach((function(e){e.component=1,u+="a="+n.writeCandidate(e)+"\r\n"})),"completed"===e.iceGatherer.state&&(u+="a=end-of-candidates\r\n"))}));var d=new e.RTCSessionDescription({type:"offer",sdp:u});return Promise.resolve(d)},d.prototype.createAnswer=function(){var r=this;if(r._isClosed)return Promise.reject(c("InvalidStateError","Can not call createAnswer after close"));if("have-remote-offer"!==r.signalingState&&"have-local-pranswer"!==r.signalingState)return Promise.reject(c("InvalidStateError","Can not call createAnswer in signalingState "+r.signalingState));var a=n.writeSessionBoilerplate(r._sdpSessionId,r._sdpSessionVersion++);r.usingBundle&&(a+="a=group:BUNDLE "+r.transceivers.map((function(e){return e.mid})).join(" ")+"\r\n"),a+="a=ice-options:trickle\r\n";var s=n.getMediaSections(r._remoteDescription.sdp).length;r.transceivers.forEach((function(e,n){if(!(n+1>s)){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 c;if(e.stream)"audio"===e.kind?c=e.stream.getAudioTracks()[0]:"video"===e.kind&&(c=e.stream.getVideoTracks()[0]),c&&t>=15019&&"video"===e.kind&&!e.sendEncodingParameters[0].rtx&&(e.sendEncodingParameters[0].rtx={ssrc:e.sendEncodingParameters[0].ssrc+1});var u=i(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+=o(e,u,"answer",e.stream,r._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)},d.prototype.addIceCandidate=function(e){var t,r=this;return e&&void 0===e.sdpMLineIndex&&!e.sdpMid?Promise.reject(new TypeError("sdpMLineIndex or sdpMid required")):new Promise((function(o,i){if(!r._remoteDescription)return i(c("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<r.transceivers.length;u++)if(r.transceivers[u].mid===e.sdpMid){a=u;break}var d=r.transceivers[a];if(!d)return i(c("OperationError","Can not add ICE candidate"));if(d.rejected)return o();var p=Object.keys(e.candidate).length>0?n.parseCandidate(e.candidate):{};if("tcp"===p.protocol&&(0===p.port||9===p.port))return o();if(p.component&&1!==p.component)return o();if((0===a||a>0&&d.iceTransport!==r.transceivers[0].iceTransport)&&!s(d.iceTransport,p))return i(c("OperationError","Can not add ICE candidate"));var f=e.candidate.trim();0===f.indexOf("a=")&&(f=f.substr(2)),(t=n.getMediaSections(r._remoteDescription.sdp))[a]+="a="+(p.type?f:"end-of-candidates")+"\r\n",r._remoteDescription.sdp=n.getDescription(r._remoteDescription.sdp)+t.join("")}else for(var l=0;l<r.transceivers.length&&(r.transceivers[l].rejected||(r.transceivers[l].iceTransport.addRemoteCandidate({}),(t=n.getMediaSections(r._remoteDescription.sdp))[l]+="a=end-of-candidates\r\n",r._remoteDescription.sdp=n.getDescription(r._remoteDescription.sdp)+t.join(""),!r.usingBundle));l++);o()}))},d.prototype.getStats=function(t){if(t&&t instanceof e.MediaStreamTrack){var r=null;if(this.transceivers.forEach((function(e){e.rtpSender&&e.rtpSender.track===t?r=e.rtpSender:e.rtpReceiver&&e.rtpReceiver.track===t&&(r=e.rtpReceiver)})),!r)throw c("InvalidAccessError","Invalid selector.");return r.getStats()}var n=[];return this.transceivers.forEach((function(e){["rtpSender","rtpReceiver","iceGatherer","iceTransport","dtlsTransport"].forEach((function(t){e[t]&&n.push(e[t].getStats())}))})),Promise.all(n).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 r=e[t];if(r&&r.prototype&&r.prototype.getStats){var n=r.prototype.getStats;r.prototype.getStats=function(){return n.apply(this).then((function(e){var t=new Map;return Object.keys(e).forEach((function(r){var n;e[r].type={inboundrtp:"inbound-rtp",outboundrtp:"outbound-rtp",candidatepair:"candidate-pair",localcandidate:"local-candidate",remotecandidate:"remote-candidate"}[(n=e[r]).type]||n.type,t.set(r,e[r])})),t}))}}}));var p=["createOffer","createAnswer"];return p.forEach((function(e){var t=d.prototype[e];d.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)}})),(p=["setLocalDescription","setRemoteDescription","addIceCandidate"]).forEach((function(e){var t=d.prototype[e];d.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=d.prototype[e];d.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)}})),d}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(0),o=r(46);t.Client=o.default;var i=r(10);t.setServers=i.setServers;var a=r(12),s=r(9);t.getSupportProfileNames=s.getSupportProfileNames;var c=r(18);t.version=c.version;var u=r(41),d=n.default;function p(e,t){"function"!=typeof e&&(e=function(){}),"function"!=typeof t&&(t=function(){}),a.StreamManager.enumerateDevices(["audio","video"],e,t)}t.Logger=d,t.getDevices=p;var f=u.genToken;function l(e){"function"!=typeof e&&(e=function(){}),a.StreamManager.getSupportedCodec().then((function(t){if(0===t.video.length){n.default.warn("your browser may not support webrtc")}e&&e(t)}))}function m(){return a.StreamManager.isSupportWebRTC()}function h(e,t){"function"==typeof e&&(t=e,e={audio:!0,video:!0});var r={audio:!0,video:!0};if("object"==typeof e&&(r.audio=e.audio,r.video=e.video,r.microphoneId=e.microphoneId,r.cameraId=e.cameraId),r.audio||r.video)if(r.microphoneId&&"string"!=typeof r.microphoneId){o="microphoneId is invalid";n.default.warn(o)}else if(r.cameraId&&"string"!=typeof r.cameraId){o="cameraId is invalid";n.default.warn(o)}else a.StreamManager.deviceDetection(r).then((function(e){"function"==typeof t&&t(e)})).catch((function(e){n.default.warn("device detection ",e)}));else{var o="audio or video must be true";n.default.warn(o)}}t.generateToken=f,t.getSupportedCodec=l,t.isSupportWebRTC=m,t.deviceDetection=h;var v={Client:o.default,Logger:d,setServers:i.setServers,getDevices:p,getSupportProfileNames:s.getSupportProfileNames,version:c.version,generateToken:f,getSupportedCodec:l,isSupportWebRTC:m,deviceDetection:h};t.default=v},function(e,t,r){(function(e,t){!function(e,r){"use strict";if(!e.setImmediate){var n,o,i,a,s,c=1,u={},d=!1,p=e.document,f=Object.getPrototypeOf&&Object.getPrototypeOf(e);f=f&&f.setTimeout?f:e,"[object process]"==={}.toString.call(e.process)?n=function(e){t.nextTick((function(){m(e)}))}:!function(){if(e.postMessage&&!e.importScripts){var t=!0,r=e.onmessage;return e.onmessage=function(){t=!1},e.postMessage("","*"),e.onmessage=r,t}}()?e.MessageChannel?((i=new MessageChannel).port1.onmessage=function(e){m(e.data)},n=function(e){i.port2.postMessage(e)}):p&&"onreadystatechange"in p.createElement("script")?(o=p.documentElement,n=function(e){var t=p.createElement("script");t.onreadystatechange=function(){m(e),t.onreadystatechange=null,o.removeChild(t),t=null},o.appendChild(t)}):n=function(e){setTimeout(m,0,e)}:(a="setImmediate$"+Math.random()+"$",s=function(t){t.source===e&&"string"==typeof t.data&&0===t.data.indexOf(a)&&m(+t.data.slice(a.length))},e.addEventListener?e.addEventListener("message",s,!1):e.attachEvent("onmessage",s),n=function(t){e.postMessage(a+t,"*")}),f.setImmediate=function(e){"function"!=typeof e&&(e=new Function(""+e));for(var t=new Array(arguments.length-1),r=0;r<t.length;r++)t[r]=arguments[r+1];var o={callback:e,args:t};return u[c]=o,n(c),c++},f.clearImmediate=l}function l(e){delete u[e]}function m(e){if(d)setTimeout(m,0,e);else{var t=u[e];if(t){d=!0;try{!function(e){var t=e.callback,n=e.args;switch(n.length){case 0:t();break;case 1:t(n[0]);break;case 2:t(n[0],n[1]);break;case 3:t(n[0],n[1],n[2]);break;default:t.apply(r,n)}}(t)}finally{l(e),d=!1}}}}}("undefined"==typeof self?void 0===e?this:e:self)}).call(this,r(8),r(11))},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(2),o=r(0),i=r(47),a=r(48),s=r(4),c=r(12),u=r(42),d=r(84),p=r(9),f=r(3),l=["pull","push","push-and-pull"],m=["user-added","user-removed","stream-added","stream-removed","stream-published","stream-subscribed","mute-video","unmute-video","mute-audio","unmute-audio","screenshare-stopped","connection-state-change","kick-off","network-quality","stream-reconnected","record-notify","relay-notify","volume-indicator"],h=["user","environment","left","right"],v=[6,12,15,24,30,48,60],g=["add","remove","replace"],y=["add","remove","replace"],b=function(){function e(e,t,r){this.eventManager=new i.EventManager,this.roomType=s.ENUM_ROOM_TYPE.rtc,this.roleType=s.ENUM_ROLE_TYPE.allStream,this.audioCodec="opus",this.videoCodec="h264",this.profileName=p.DEFAULT_PROFILE,this.audioVolumeIndicatorInterval=0;var n=(r=r||{}).type,a=r.role,u=r.codec;switch(o.default.debug("New Client ",e,t,n,a,u),this.appId=e,this.token=t,n){case"live":this.roomType=s.ENUM_ROOM_TYPE.live;break;case"rtc":default:this.roomType=s.ENUM_ROOM_TYPE.rtc}switch(a){case"push":this.roleType=s.ENUM_ROLE_TYPE.pushStream;break;case"pull":this.roleType=s.ENUM_ROLE_TYPE.pullStream;break;case"push-and-pull":default:this.roleType=s.ENUM_ROLE_TYPE.allStream}if(this.roomType===s.ENUM_ROOM_TYPE.rtc&&(this.roleType=s.ENUM_ROLE_TYPE.allStream),u)switch(u){case"h264":this.videoCodec="h264";break;case"vp8":default:this.videoCodec="vp8"}else this.videoCodec="vp8";this.previewStreamManager=new c.PreviewStreamManager,this.eventManager.bind(this.previewStreamManager)}return e.prototype.setRole=function(e){if(!l.includes(e)){var t="role must be one of "+l;return o.default.warn(t),!1}if(this.roomType===s.ENUM_ROOM_TYPE.rtc&&"push-and-pull"!==e){t="role must be 'push-and-pull' in rtc mode";return o.default.warn(t),!1}switch(e){case"push":this.roleType=s.ENUM_ROLE_TYPE.pushStream;break;case"pull":this.roleType=s.ENUM_ROLE_TYPE.pullStream;break;case"push-and-pull":default:this.roleType=s.ENUM_ROLE_TYPE.allStream}return this.sessionManager&&this.sessionManager.setRole(this.roleType),!0},e.prototype.joinRoom=function(e,t,r,n){var i=this;if("function"!=typeof r&&(r=function(){}),"function"!=typeof n&&(n=function(){}),"string"!=typeof e){var s="roomId is incorrect";return o.default.warn(s),void n(f.createError(f.ErrorCodes.INVALID_PARAMETER,s))}if("string"!=typeof t){s="userId is incorrect";return o.default.warn(s),void n(f.createError(f.ErrorCodes.INVALID_PARAMETER,s))}if(this.sessionManager){s="you have already joined the room";return o.default.warn(s),void n(f.createError(f.ErrorCodes.DUPLICATED_JOIN,s))}c.StreamManager.getSupportedCodec().then((function(s){if(n=n||function(){},0===s.video.length){var c="your browser may not support webrtc";return o.default.warn(c),void n(f.createError(f.ErrorCodes.OTHERS,c))}if(i.supportedVideoCodecs=s.video,s.video.includes(i.videoCodec))o.default.debug("your browser supported audio codec are ["+s.audio+"], and supported video codec are ["+s.video+"]");else{var d="your browser supported video codec are ["+s.video+"], sdk will use "+s.video[0]+" instead of "+i.videoCodec;o.default.warn(d),i.videoCodec=s.video[0]}i.sessionManager=new a.SessionManager(i.appId,i.token,i.roomType,i.roleType,i.audioCodec,i.videoCodec),i.eventManager.bind(i.sessionManager),i.sessionManager.streamManager.setVideoProfile(i.profileName),i.sessionManager.joinRoom(e,t,(function(){var e=[],t=[];i.sessionManager&&(e=i.sessionManager.users.map((function(e){return u.convertToOuterUser(e)})),t=i.sessionManager.streamManager.getAllRemoteStreams().map((function(e){return e.convertToOuterStream()})),"number"==typeof i.audioVolumeIndicatorInterval&&i.audioVolumeIndicatorInterval>=200&&i.enableAudioVolumeIndicator(i.audioVolumeIndicatorInterval)),r&&r(e,t)}),(function(e){n&&n(f.createError(f.ErrorCodes.OTHERS,e))}))}))},e.prototype.leaveRoom=function(e,t,r){var n,i=this;if("function"==typeof e?(r=t,t=e,n={keepRecording:!1}):n=e?{keepRecording:!!e.keepRecording}:{keepRecording:!1},"function"!=typeof t&&(t=function(){}),"function"!=typeof r&&(r=function(){}),!this.sessionManager){var a="please join room first";return o.default.warn(a),void r(f.createError(f.ErrorCodes.NOT_JOIN,a))}if(this.sessionManager.isDestroyed)return this.sessionManager=void 0,void t();this.sessionManager.leaveRoom(n,(function(e){o.default.debug(e," leave room"),i.sessionManager=void 0,t&&t()}),r)},e.prototype.publish=function(e,t){var r=this;if("function"!=typeof t&&(t=function(){}),!this.sessionManager){var n="please join room first";return o.default.warn(n),void t(f.createError(f.ErrorCodes.NOT_JOIN,n))}if(e&&d.streamValidator.isValidStreamId(e.previewId)){var i=e.previewId,a=this.previewStreamManager.getStream(i);if(!a){n="stream isnot found, maybe it has already been published or destroyed";return o.default.warn(n),void t(f.createError(f.ErrorCodes.STREAM_NOT_EXISTS,n))}this.sessionManager.publishStream(a,(function(){r.previewStreamManager.removeStream(i,!0).catch((function(e){o.default.error("publish stream failure when remove it "+e)}))}),t)}else{var s;if("function"==typeof e)t=e,s={audio:!0,video:!0,screen:!1};else if(e){if(e.screen&&e.video&&o.default.warn("both video and screen are true, only camera's video will be published"),e.screen&&e.audio&&o.default.warn("both audio and screen are true, only microphone's audio will be published"),e.audio&&e.video&&e.screen){n="audio, video and screen cannot be true at the same time";return o.default.warn(n),void("function"==typeof t&&t(f.createError(f.ErrorCodes.INVALID_PARAMETER,n)))}if(!(e.audio||e.video||e.screen||e.mediaStream)){n="audio, video and screen cannot be false at the same time";return o.default.warn(n),void("function"==typeof t&&t(f.createError(f.ErrorCodes.INVALID_PARAMETER,n)))}s={audio:!!e.audio,video:!!e.video,screen:!!e.screen,microphoneId:e.microphoneId,cameraId:e.cameraId,extensionId:e.extensionId,mediaStream:e.mediaStream,file:e.file,filePath:e.filePath},"boolean"==typeof e.screenAudio&&(s.screenAudio=e.screenAudio),e.facingMode&&h.includes(e.facingMode)&&(s.facingMode=e.facingMode)}else s={audio:!0,video:!0,screen:!1};if("function"!=typeof t&&(t=function(){}),!d.isValidString(s.microphoneId)){n="type error, the microphoneId is not blank or a valid string";return o.default.warn(n),void t(f.createError(f.ErrorCodes.INVALID_PARAMETER,n))}if(!d.isValidString(s.cameraId)){n="type error, the cameraId is not blank or a valid string";return o.default.warn(n),void t(f.createError(f.ErrorCodes.INVALID_PARAMETER,n))}if(s.mediaStream&&!(s.mediaStream instanceof MediaStream)){n="type error, the mediaStream is not a valid MediaStream";return o.default.warn(n),void t(f.createError(f.ErrorCodes.INVALID_PARAMETER,n))}if(!this.sessionManager){n="please join room first";return o.default.warn(n),void t(f.createError(f.ErrorCodes.NOT_JOIN,n))}this.sessionManager.publish(s,(function(){}),t)}},e.prototype.unpublish=function(e,t,r){var n;if("function"==typeof e){if(r=t,t=e,!(a=this.getStream())){var i="stream is not found";return o.default.warn(i),void(r&&r(f.createError(f.ErrorCodes.STREAM_NOT_EXISTS,i)))}n=a.sid}else{if(!d.isValidString(e)){i="the arguments are invalid";return o.default.warn(i),void(r&&r(f.createError(f.ErrorCodes.INVALID_PARAMETER,i)))}var a;if(!(a=this.getStream(e))){var i="stream is not found";return o.default.warn(i),void(r&&r(f.createError(f.ErrorCodes.STREAM_NOT_EXISTS,i)))}n=a.sid}if("function"!=typeof t&&(t=function(){}),"function"!=typeof r&&(r=function(){}),!this.sessionManager){i="please join room first";return o.default.warn(i),void r(f.createError(f.ErrorCodes.NOT_JOIN,i))}this.sessionManager.unpublish(n,t,r)},e.prototype.subscribe=function(e,t){if("function"!=typeof t&&(t=function(){}),!d.streamValidator.isValidStreamId(e)){var r="stream Id is invalid";return o.default.warn(r),void t(f.createError(f.ErrorCodes.INVALID_PARAMETER,r))}var n="vp8";if(n=/VP8/.exec(e)?"vp8":/H264/.exec(e)?"h264":"vp8",!this.supportedVideoCodecs.includes(n)){r="your browser can't decode the video of "+e+" stream";return o.default.warn(r),void t(f.createError(f.ErrorCodes.OTHERS,r))}if(!this.sessionManager){r="please join room first";return o.default.warn(r),void t(f.createError(f.ErrorCodes.NOT_JOIN,r))}this.sessionManager.subscribe(e,(function(){}),t)},e.prototype.unsubscribe=function(e,t,r){if("function"!=typeof t&&(t=function(){}),"function"!=typeof r&&(r=function(){}),!d.streamValidator.isValidStreamId(e)){var n="stream Id is invalid";return o.default.warn(n),void r(f.createError(f.ErrorCodes.INVALID_PARAMETER,n))}if(!this.sessionManager){n="please join room first";return o.default.warn(n),void r(f.createError(f.ErrorCodes.NOT_JOIN,n))}this.sessionManager.unsubscribe(e,t,r)},e.prototype.on=function(e,t){if(o.default.debug("Client on ",e),m.includes(e))this.eventManager.on(e,t);else{if("string"!=typeof e)throw f.createError(f.ErrorCodes.INVALID_PARAMETER,"not supported event type");o.default.warn(e+" is an invalid event type")}},e.prototype.off=function(e,t){if(o.default.debug("Client off ",e),m.includes(e))this.eventManager.off(e,t);else{if("string"!=typeof e)throw f.createError(f.ErrorCodes.INVALID_PARAMETER,"not supported event type");o.default.warn(e+" is an invalid event type")}},e.prototype.muteAudio=function(e){if(d.streamValidator.isValidStreamId(e)){var t=this.previewStreamManager.getStream(e);if(t)return t.muteAudio()}var r=this.getStream(e);return r?!!this.sessionManager&&this.sessionManager.muteAudio(r.sid):(o.default.warn("stream is not found"),!1)},e.prototype.unmuteAudio=function(e){if(d.streamValidator.isValidStreamId(e)){var t=this.previewStreamManager.getStream(e);if(t)return t.unmuteAudio()}var r=this.getStream(e);return r?!!this.sessionManager&&this.sessionManager.unmuteAudio(r.sid):(o.default.warn("stream is not found"),!1)},e.prototype.muteVideo=function(e){if(d.streamValidator.isValidStreamId(e)){var t=this.previewStreamManager.getStream(e);if(t)return t.muteVideo()}var r=this.getStream(e);return r?!!this.sessionManager&&this.sessionManager.muteVideo(r.sid):(o.default.warn("stream is not found"),!1)},e.prototype.unmuteVideo=function(e){if(d.streamValidator.isValidStreamId(e)){var t=this.previewStreamManager.getStream(e);if(t)return t.unmuteVideo()}var r=this.getStream(e);return r?!!this.sessionManager&&this.sessionManager.unmuteVideo(r.sid):(o.default.warn("stream is not found"),!1)},e.prototype.startRecording=function(e,t,r){e=e||{bucket:"",region:""};var n=this.getUser(),i=n&&n.uid||"",a=s.ENUM_MEDIA_TYPE.camera,c=1280,u=720,d=1,p=!0;if(e.mixStream&&"object"==typeof e.mixStream){switch(e.mixStream.uid&&"string"==typeof e.mixStream.uid&&(i=e.mixStream.uid),e.mixStream.type){case"desktop":case"screen":a=s.ENUM_MEDIA_TYPE.desktop;break;case"camera":default:a=s.ENUM_MEDIA_TYPE.camera}switch("number"==typeof e.mixStream.width&&e.mixStream.width>0&&(c=e.mixStream.width),"number"==typeof e.mixStream.height&&e.mixStream.height>0&&(u=e.mixStream.height),e.mixStream.template){case 1:case 2:case 3:case 4:case 5:case 6:case 7:case 8:case 9:d=e.mixStream.template;break;default:d=1}"boolean"==typeof e.mixStream.isAverage&&(p=e.mixStream.isAverage)}if(e.uid&&"string"==typeof e.uid&&(i=e.uid),e.mainViewType&&"string"==typeof e.mainViewType)switch(e.mainViewType){case"desktop":case"screen":a=s.ENUM_MEDIA_TYPE.desktop;break;case"camera":default:a=s.ENUM_MEDIA_TYPE.camera}var l=s.ENUM_WATER_MARK_POS.lt,m=s.ENUM_WATER_MARK_TYPE.none,h="";if(e.waterMark&&"object"==typeof e.waterMark){switch(e.waterMark.position){case"left-top":l=s.ENUM_WATER_MARK_POS.lt;break;case"left-bottom":l=s.ENUM_WATER_MARK_POS.lb;break;case"right-top":l=s.ENUM_WATER_MARK_POS.rt;break;case"right-bottom":l=s.ENUM_WATER_MARK_POS.rb;break;default:l=s.ENUM_WATER_MARK_POS.lt}switch(e.waterMark.type){case"image":m=s.ENUM_WATER_MARK_TYPE.image,"string"==typeof e.waterMark.remarks&&(h=e.waterMark.remarks);break;case"text":m=s.ENUM_WATER_MARK_TYPE.text,"string"==typeof e.waterMark.remarks&&(h=e.waterMark.remarks);break;case"time":default:m=s.ENUM_WATER_MARK_TYPE.time,h=""}}var v=!1,g=parseInt((+new Date/1e3).toString()),y=60;e.relay&&"object"==typeof e.relay&&(v=!0,"number"==typeof e.relay.time&&e.relay.time>0&&(g=e.relay.time),"number"==typeof e.relay.fragment&&e.relay.fragment>0&&(y=e.relay.fragment));var b={waterMarkPos:l,waterMarkType:m,waterMarkRemarks:h,mixStreamUId:i,mixStreamType:a,mixStreamWidth:c,mixStreamHeight:u,mixStreamTemplate:d,isAverage:p,bucket:e.bucket,region:e.region,isRelay:v,relayTime:g,relayFragment:y};if("function"!=typeof t&&(t=function(){}),"function"!=typeof r&&(r=function(){}),!this.sessionManager){var E="please join room first";return o.default.warn(E),void r(f.createError(f.ErrorCodes.NOT_JOIN,E))}this.sessionManager.startRecording(b,t,r)},e.prototype.stopRecording=function(e,t){if("function"!=typeof e&&(e=function(){}),"function"!=typeof t&&(t=function(){}),!this.sessionManager){var r="please join room first";return o.default.warn(r),void t(f.createError(f.ErrorCodes.NOT_JOIN,r))}this.sessionManager.stopRecording(e,t)},e.prototype.getUser=function(){if(this.sessionManager)return u.convertToOuterUser(this.sessionManager.user)},e.prototype.getUsers=function(){return this.sessionManager?this.sessionManager.users.map((function(e){return u.convertToOuterUser(e)})):[]},e.prototype.getStream=function(e){if(d.streamValidator.isValidStreamId(e)){var t=this.previewStreamManager.getStream(e);if(t)return t.convertToOuterStream()}var r;if(this.sessionManager)return d.streamValidator.isValidStreamId(e)?(r=this.sessionManager.streamManager.getStream(e))&&r.convertToOuterStream():(r=this.sessionManager.streamManager.getAllLocalStreams()[0])&&r.convertToOuterStream()},e.prototype.getLocalStreams=function(){var e=[];return this.sessionManager&&this.sessionManager.streamManager.getAllLocalStreams().forEach((function(t){e.push(t.convertToOuterStream())})),this.previewStreamManager.getAllStreams().forEach((function(t){e.push(t.convertToOuterStream())})),e},e.prototype.getRemoteStreams=function(){return this.sessionManager?this.sessionManager.streamManager.getAllRemoteStreams().map((function(e){return e.convertToOuterStream()})):[]},e.prototype.getStreams=function(){return o.default.warn("getStreams is deprecated, please use getRemoteStreams"),this.getRemoteStreams()},e.prototype.getMediaStream=function(e){var t=this.getStream(e);return t&&t.mediaStream},e.prototype.getLocalMediaStream=function(e){return o.default.warn("getLocalMediaStream is deprecated, please use getMediaStream"),this.getMediaStream(e)},e.prototype.getRemoteMediaStream=function(e){return o.default.warn("getLocalMediaStream is deprecated, please use getMediaStream"),this.getMediaStream(e)},e.prototype.play=function(e,t){var r,n,i=(e=e||{}).streamId,a=e.container,s=e.mute,c=void 0!==s&&s,u=e.mirror,p=void 0!==u&&u,l=e.fit,m=e.controls;if(!d.streamValidator.isValidStreamId(i)){var h="stream Id is invalid";return o.default.warn(h),void(t&&t(f.createError(f.ErrorCodes.INVALID_PARAMETER,h)))}var v=null;if("string"==typeof a&&(v=document.getElementById(a)),a instanceof HTMLElement&&(v=a),!v){h="container is invalid";return o.default.warn(h),void(t&&t(f.createError(f.ErrorCodes.INVALID_PARAMETER,h)))}var g={mute:!!c,mirror:!!p,controls:m};if(l)switch(l){case"contain":case"cover":g.fit=l;break;default:g.fit="cover"}if(m)switch(m){case"show":case"hide":case"auto":g.controls=m;break;default:g.controls="auto"}var y=this.previewStreamManager.getStream(i);if(y)this.previewStreamManager.play(y,v,Object.assign({},g,{mute:!0})).then((function(){t&&t()})).catch((function(e){t&&t(e)}));else{var b=null===(r=this.sessionManager)||void 0===r?void 0:r.streamManager.getStream(i);b?null===(n=this.sessionManager)||void 0===n||n.streamManager.play(b,v,g).then((function(){t&&t()})).catch((function(e){t&&t(e)})):t&&t(f.createError(f.ErrorCodes.STREAM_NOT_EXISTS,"stream is not exist"))}},e.prototype.resume=function(e,t){var r,n,o=this.previewStreamManager.getStream(e);if(o)this.previewStreamManager.resume(o).then((function(){t&&t()})).catch((function(e){t&&t(e)}));else{var i=null===(r=this.sessionManager)||void 0===r?void 0:r.streamManager.getStream(e);i?null===(n=this.sessionManager)||void 0===n||n.streamManager.resume(i).then((function(){t&&t()})).catch((function(e){t&&t(e)})):t&&t(f.createError(f.ErrorCodes.STREAM_NOT_EXISTS,"stream is not exist"))}},e.prototype.pause=function(e,t){var r,n,o=this.previewStreamManager.getStream(e);if(o)this.previewStreamManager.stop(o).then((function(){t&&t()})).catch((function(e){t&&t(e)}));else{var i=null===(r=this.sessionManager)||void 0===r?void 0:r.streamManager.getStream(e);i?null===(n=this.sessionManager)||void 0===n||n.streamManager.stop(i).then((function(){t&&t()})).catch((function(e){t&&t(e)})):t&&t(f.createError(f.ErrorCodes.STREAM_NOT_EXISTS,"stream is not exist"))}},e.prototype.stop=function(e,t){var r,n,o=this.previewStreamManager.getStream(e);if(o)return this.previewStreamManager.destroyPlayer(o),void(t&&t());var i=null===(r=this.sessionManager)||void 0===r?void 0:r.streamManager.getStream(e);i?(null===(n=this.sessionManager)||void 0===n||n.streamManager.destroyPlayer(i),t&&t()):t&&t(f.createError(f.ErrorCodes.STREAM_NOT_EXISTS,"stream is not exist"))},e.prototype.getMicrophones=function(e,t){"function"!=typeof e&&(e=function(){}),"function"!=typeof t&&(t=function(){}),c.StreamManager.enumerateDevices(["audio"],(function(t){e&&e(t.filter((function(e){return"audioinput"===e.kind})))}),t)},e.prototype.getCameras=function(e,t){"function"!=typeof e&&(e=function(){}),"function"!=typeof t&&(t=function(){}),c.StreamManager.enumerateDevices(["video"],(function(t){e&&e(t.filter((function(e){return"videoinput"===e.kind})))}),t)},e.prototype.getLoudspeakers=function(e,t){"function"!=typeof e&&(e=function(){}),"function"!=typeof t&&(t=function(){}),c.StreamManager.enumerateDevices(["audio"],(function(t){e&&e(t.filter((function(e){return"audiooutput"===e.kind})))}),t)},e.prototype.setVideoProfile=function(e,t,r){var n,i;if("object"==typeof e)n=e.previewId,i=e.profile;else{var a=Array.prototype.slice.call(arguments),s=a[0],c=a[1],u=a[2];i=s,t=c,r=u}"function"!=typeof t&&(t=function(){}),"function"!=typeof r&&(r=function(){});var l=p.getSupportProfileNames(),m=p.getInternalSupportProfileNames(),h=l.concat(m);if(h.includes(i))if(d.streamValidator.isValidStreamId(n)){var v=this.previewStreamManager.getStream(n);if(v)this.previewStreamManager.setVideoProfile(v.streamId,i).then((function(){t&&t()})).catch((function(e){r&&r(e)}));else{var g="stream is not found";o.default.warn(g),r(f.createError(f.ErrorCodes.STREAM_NOT_EXISTS,g))}}else this.profileName=i,this.sessionManager&&this.sessionManager.streamManager.setVideoProfile(i).catch((function(e){return o.default.warn("set video profile ",e)})),t();else{g=i+" is not supported, you can invoke getSupportProfileNames function to get supported profile";o.default.warn(g),r(f.createError(f.ErrorCodes.INVALID_PARAMETER,g))}},e.prototype.switchDevice=function(e,t,r){var n,o,i;if("object"==typeof e)n=e.streamId,o=e.deviceId,i=e.type;else{var a=Array.prototype.slice.call(arguments),s=a[0],c=a[1],u=a[2],d=a[3];i=s,o=c,t=u,r=d}var p=function(e){"function"==typeof t&&t(e)},l=function(e){"function"==typeof r&&r(e)};if(o&&"string"==typeof o){var m=this.getStream(n);if(m){var h=this.previewStreamManager.getStream(m.sid);if(!h&&this.sessionManager&&(h=this.sessionManager.streamManager.getLocalStream(m.sid)),h)switch(i){case"audio":h.switchMicrophone(o).then(p).catch(l);break;case"video":h.switchCamera(o).then(p).catch(l);break;default:v="device type unknown";l(f.createError(f.ErrorCodes.INVALID_PARAMETER,v))}else{v="stream is not found";l(f.createError(f.ErrorCodes.STREAM_NOT_EXISTS,v))}}else{var v="stream is not found";l(f.createError(f.ErrorCodes.STREAM_NOT_EXISTS,v))}}else{var v="device Id is invalid";l(f.createError(f.ErrorCodes.INVALID_PARAMETER,v))}},e.prototype.switchScreen=function(e,t,r){var n;if("function"==typeof e){if(r=t,t=e,!(a=this.getStream())){var i="stream is not found";return o.default.warn(i),void(r&&r(i))}n=a.sid}else if("string"==typeof e)n=e;else{if(e){i="the arguments are invalid";return o.default.warn(i),void(r&&r(i))}var a;if(!(a=this.getStream())){var i="stream is not found";return o.default.warn(i),void(r&&r(i))}n=a.sid}if("function"!=typeof t&&(t=function(){}),"function"!=typeof r&&(r=function(){}),!this.sessionManager){i="please join room first";return o.default.warn(i),void r(f.createError(f.ErrorCodes.NOT_JOIN,i))}var s=this.sessionManager.streamManager.getLocalStream(n);if(!s){i="stream is not found";return o.default.warn(i),void r(i)}s.switchScreen().then(t).catch(r)},e.prototype.switchImage=function(e,t,r){var n,i;"object"!=typeof e||e instanceof File?i=e:(n=e.streamId,i=e.file?e.file:e.filePath?e.filePath:"");var a,s=function(e){"function"==typeof r&&r(e)};if(!i||!("string"==typeof i||i instanceof File)){var c="both file and filePath are invalid";return o.default.warn(c),void s(f.createError(f.ErrorCodes.INVALID_PARAMETER,c))}if(n)a=n;else{var u=this.getStream();if(!u){c="stream is not found";return o.default.warn(c),void s(f.createError(f.ErrorCodes.STREAM_NOT_EXISTS,c))}a=u.sid}if(!this.sessionManager){c="please join room first";return o.default.warn(c),void s(f.createError(f.ErrorCodes.NOT_JOIN,c))}var d=this.sessionManager.streamManager.getLocalStream(a);if(!d){c="stream is not found";return o.default.warn(c),void s(f.createError(f.ErrorCodes.STREAM_NOT_EXISTS,c))}d.switchImage(i).then((function(e){"function"==typeof t&&t(e)})).catch(s)},e.prototype.getAudioVolume=function(e){if(d.streamValidator.isValidStreamId(e)){var t=this.previewStreamManager.getStream(e);if(t)return Math.floor(100*t.getAudioVolume())}var r=this.getStream(e);if(!r)return o.default.warn("stream is not found"),0;if(this.sessionManager){var n=this.sessionManager.streamManager.getStream(r.sid);if(n)return Math.floor(100*n.getAudioVolume())}return o.default.warn("stream is not found"),0},e.prototype.setAudioVolume=function(e,t){var r=(e=e||{}).streamId,n=e.volume;if("function"!=typeof t&&(t=function(){}),d.isValidVolume(n)){if(d.streamValidator.isValidStreamId(r)){var o=this.previewStreamManager.getStream(r);o&&o.setAudioVolume(n).then(t).catch(t)}var i=this.getStream(r);if(i){if(this.sessionManager){var a=this.sessionManager.streamManager.getStream(i.sid);if(a)a.isSubscriber?e.element instanceof HTMLMediaElement?(e.element.volume=n/100,t()):this.sessionManager.streamManager.setAudioVolume(a,n).then(t).catch(t):a.setAudioVolume(n).then(t).catch(t);else{s="stream is not found";t(f.createError(f.ErrorCodes.STREAM_NOT_EXISTS,s))}}}else{var s="stream is not found";t(f.createError(f.ErrorCodes.STREAM_NOT_EXISTS,s))}}else{var s="volume is invalid";t(f.createError(f.ErrorCodes.INVALID_PARAMETER,s))}},e.prototype.getAudioStats=function(e,t,r){var n;if("function"==typeof e){if(r=t,t=e,!(a=this.getStream())){var i="stream is not found";return o.default.warn(i),void(r&&r(f.createError(f.ErrorCodes.STREAM_NOT_EXISTS,i)))}n=a.sid}else if("string"==typeof e)n=e;else{if(e){i="the arguments are invalid";return o.default.warn(i),void(r&&r(f.createError(f.ErrorCodes.INVALID_PARAMETER,i)))}var a;if(!(a=this.getStream())){var i="stream is not found";return o.default.warn(i),void(r&&r(f.createError(f.ErrorCodes.STREAM_NOT_EXISTS,i)))}n=a.sid}if("function"!=typeof t&&(t=function(){}),"function"!=typeof r&&(r=function(){}),!this.sessionManager){i="please join room first";return o.default.warn(i),void r(f.createError(f.ErrorCodes.NOT_JOIN,i))}var s=this.sessionManager.streamManager.getStream(n);if(!s){i="stream is not found";return o.default.warn(i),void(r&&r(f.createError(f.ErrorCodes.STREAM_NOT_EXISTS,i)))}s.getStats2().then((function(e){t&&t(e.audio)})).catch(r)},e.prototype.getVideoStats=function(e,t,r){var n;if("function"==typeof e){if(r=t,t=e,!(a=this.getStream())){var i="stream is not found";return o.default.warn(i),void(r&&r(f.createError(f.ErrorCodes.STREAM_NOT_EXISTS,i)))}n=a.sid}else if("string"==typeof e)n=e;else{if(e){i="the arguments are invalid";return o.default.warn(i),void(r&&r(f.createError(f.ErrorCodes.INVALID_PARAMETER,i)))}var a;if(!(a=this.getStream())){var i="stream is not found";return o.default.warn(i),void(r&&r(f.createError(f.ErrorCodes.STREAM_NOT_EXISTS,i)))}n=a.sid}if("function"!=typeof t&&(t=function(){}),"function"!=typeof r&&(r=function(){}),!this.sessionManager){i="please join room first";return o.default.warn(i),void r(f.createError(f.ErrorCodes.NOT_JOIN,i))}var s=this.sessionManager.streamManager.getStream(n);if(!s){i="stream is not found";return o.default.warn(i),void(r&&r(f.createError(f.ErrorCodes.STREAM_NOT_EXISTS,i)))}s.getStats2().then((function(e){t&&t(e.video)})).catch(r)},e.prototype.getNetworkStats=function(e,t,r){var n;if("function"==typeof e){if(r=t,t=e,!(a=this.getStream())){var i="stream is not found";return o.default.warn(i),void(r&&r(f.createError(f.ErrorCodes.STREAM_NOT_EXISTS,i)))}n=a.sid}else if("string"==typeof e)n=e;else{if(e){i="the arguments are invalid";return o.default.warn(i),void(r&&r(f.createError(f.ErrorCodes.INVALID_PARAMETER,i)))}var a;if(!(a=this.getStream())){var i="stream is not found";return o.default.warn(i),void(r&&r(f.createError(f.ErrorCodes.STREAM_NOT_EXISTS,i)))}n=a.sid}if("function"!=typeof t&&(t=function(){}),"function"!=typeof r&&(r=function(){}),!this.sessionManager){i="please join room first";return o.default.warn(i),void(r&&r(f.createError(f.ErrorCodes.NOT_JOIN,i)))}var s=this.sessionManager.streamManager.getStream(n);if(!s){i="stream is not found";return o.default.warn(i),void(r&&r(f.createError(f.ErrorCodes.STREAM_NOT_EXISTS,i)))}s.getStats2().then((function(e){var r={rtt:-1!==e.connection.rtt?e.connection.rtt:e.connection.delay};t&&t(r)})).catch(r)},e.prototype.preloadEffect=function(e,t,r){var n;if("function"!=typeof r&&(r=function(){}),!d.effectValidator.isValidId(e))return n="effectId is invalid",o.default.warn(n),void r(f.createError(f.ErrorCodes.INVALID_PARAMETER,n));if(!d.effectValidator.isValidFilePath(t,!0))return n="filePath is invalid",o.default.warn(n),void r(f.createError(f.ErrorCodes.INVALID_PARAMETER,n));if(!this.sessionManager){var i="please join room first";return o.default.warn(i),void r(f.createError(f.ErrorCodes.NOT_JOIN,i))}this.sessionManager.streamManager.preloadEffect(e,t,r)},e.prototype.unloadEffect=function(e){if(!d.effectValidator.isValidId(e))return"effectId is invalid",void o.default.warn("effectId is invalid");if(this.sessionManager)this.sessionManager.streamManager.unloadEffect(e);else{o.default.warn("please join room first")}},e.prototype.playEffect=function(e,t){if("function"!=typeof t&&(t=function(){}),!d.effectValidator.isValidEffectOptions(e)){var r="EffectOptions is invalid";return o.default.warn(r),void t(f.createError(f.ErrorCodes.INVALID_PARAMETER,r))}var n,i={effectId:e.effectId,loop:!1,playTime:0,replace:!1};if(e.filePath&&(i.filePath=e.filePath),e.playTime&&(i.playTime=e.playTime),e.loop&&(i.loop=!0),e.replace&&(i.replace=!0),e.streamId)n=e.streamId;else{var a=this.getStream();if(!a){r="stream is not found";return o.default.warn(r),void t(f.createError(f.ErrorCodes.STREAM_NOT_EXISTS,r))}n=a.sid}if(!this.sessionManager){r="please join room first";return o.default.warn(r),void t(f.createError(f.ErrorCodes.NOT_JOIN,r))}this.sessionManager.streamManager.playEffect(n,i,t)},e.prototype.pauseEffect=function(e,t){if("function"!=typeof t&&(t=function(){}),!d.effectValidator.isValidEffectOptions(e)){var r="EffectOptions is invalid";return o.default.warn(r),void t(f.createError(f.ErrorCodes.INVALID_PARAMETER,r))}var n;if(e.streamId)n=e.streamId;else{var i=this.getStream();if(!i){r="stream is not found";return o.default.warn(r),void t(f.createError(f.ErrorCodes.STREAM_NOT_EXISTS,r))}n=i.sid}if(!this.sessionManager){r="please join room first";return o.default.warn(r),void t(f.createError(f.ErrorCodes.NOT_JOIN,r))}this.sessionManager.streamManager.pauseEffect(n,e.effectId,t)},e.prototype.resumeEffect=function(e,t){if("function"!=typeof t&&(t=function(){}),!d.effectValidator.isValidEffectOptions(e)){var r="EffectOptions is invalid";return o.default.warn(r),void t(f.createError(f.ErrorCodes.INVALID_PARAMETER,r))}var n;if(e.streamId)n=e.streamId;else{var i=this.getStream();if(!i){r="stream is not found";return o.default.warn(r),void t(f.createError(f.ErrorCodes.STREAM_NOT_EXISTS,r))}n=i.sid}if(!this.sessionManager){r="please join room first";return o.default.warn(r),void t(f.createError(f.ErrorCodes.NOT_JOIN,r))}this.sessionManager.streamManager.resumeEffect(n,e.effectId,t)},e.prototype.stopEffect=function(e,t){if("function"!=typeof t&&(t=function(){}),!d.effectValidator.isValidEffectOptions(e)){var r="EffectOptions is invalid";return o.default.warn(r),void t(f.createError(f.ErrorCodes.INVALID_PARAMETER,r))}var n;if(e.streamId)n=e.streamId;else{var i=this.getStream();if(!i){r="stream is not found";return o.default.warn(r),void t(f.createError(f.ErrorCodes.STREAM_NOT_EXISTS,r))}n=i.sid}if(!this.sessionManager){r="please join room first";return o.default.warn(r),void t(f.createError(f.ErrorCodes.NOT_JOIN,r))}this.sessionManager.streamManager.stopEffect(n,e.effectId,t)},e.prototype.setEffectVolume=function(e,t){if("function"!=typeof t&&(t=function(){}),!d.effectValidator.isValidEffectOptions(e)){var r="EffectVolumeOptions is invalid";return o.default.warn(r),void t(f.createError(f.ErrorCodes.INVALID_PARAMETER,r))}var n;if(e.streamId)n=e.streamId;else{var i=this.getStream();if(!i){r="stream is not found";return o.default.warn(r),void t(f.createError(f.ErrorCodes.STREAM_NOT_EXISTS,r))}n=i.sid}if(!this.sessionManager){r="please join room first";return o.default.warn(r),void t(f.createError(f.ErrorCodes.NOT_JOIN,r))}this.sessionManager.streamManager.setEffectVolume(n,e.effectId,e.volume,t)},e.prototype.snapshot=function(e,t,r){"function"==typeof e&&(r=t,t=e,e={});var n,i,a=function(e){"function"==typeof r&&r(e)},s=(e=e||{}).streamId,c=e.download;if(s)n=s;else{var u=this.getStream();if(!u){var d="stream is not found";return o.default.warn(d),void a(f.createError(f.ErrorCodes.STREAM_NOT_EXISTS,d))}n=u.sid}if(c){if("string"!=typeof c&&"boolean"!=typeof c){d="download is invalid, it should be string or boolean";return o.default.warn(d),void a(f.createError(f.ErrorCodes.INVALID_PARAMETER,d))}i=c}else i=!1;if(!this.sessionManager){d="please join room first";return o.default.warn(d),void a(f.createError(f.ErrorCodes.NOT_JOIN,d))}this.sessionManager.streamManager.snapshot(n,i).then((function(e){"function"==typeof t&&t(e)})).catch(a)},e.prototype.startPreviewing=function(e,t,r){"function"==typeof e&&(r=t,t=e,e={audio:!0,video:!0});var n=function(e){"function"==typeof r&&r(e)},i={audio:!0,video:!0,screen:!1};if("object"==typeof e&&(i.audio=e.audio,i.video=e.video,i.facingMode=e.facingMode,i.microphoneId=e.microphoneId,i.cameraId=e.cameraId),!i.audio&&!i.video){var a="audio or video must be true";return o.default.warn(a),void n(f.createError(f.ErrorCodes.INVALID_PARAMETER,a))}if(i.facingMode&&!h.includes(i.facingMode)){a="facingMode is invalid";return o.default.warn(a),void n(f.createError(f.ErrorCodes.INVALID_PARAMETER,a))}if(i.microphoneId&&"string"!=typeof i.microphoneId){a="microphoneId is invalid";return o.default.warn(a),void n(f.createError(f.ErrorCodes.INVALID_PARAMETER,a))}if(i.cameraId&&"string"!=typeof i.cameraId){a="cameraId is invalid";return o.default.warn(a),void n(f.createError(f.ErrorCodes.INVALID_PARAMETER,a))}if(this.previewStreamManager.getStream("preview")){a="you are previewing";n(f.createError(f.ErrorCodes.OTHERS,a))}else{var s=this.getUser(),c=s?s.uid:"unknown";this.previewStreamManager.createStream(c,"preview",i,this.profileName).then((function(e){!function(e){"function"==typeof t&&t(e)}(e.getMediaStream())})).catch(n)}},e.prototype.stopPreviewing=function(){this.previewStreamManager.removeStream("preview",!1).catch((function(e){o.default.warn("stop previewing "+e)}))},e.prototype.deviceDetection=function(e,t){"function"==typeof e&&(t=e,e={audio:!0,video:!0});var r={audio:!0,video:!0};if("object"==typeof e&&(r.audio=e.audio,r.video=e.video,r.microphoneId=e.microphoneId,r.cameraId=e.cameraId),r.audio||r.video)if(r.microphoneId&&"string"!=typeof r.microphoneId){n="microphoneId is invalid";o.default.warn(n)}else if(r.cameraId&&"string"!=typeof r.cameraId){n="cameraId is invalid";o.default.warn(n)}else c.StreamManager.deviceDetection(r).then((function(e){"function"==typeof t&&t(e)})).catch((function(e){o.default.warn("device detection ",e)}));else{var n="audio or video must be true";o.default.warn(n)}},e.prototype.replaceTrack=function(e,t){var r=(e=e||{}).streamId,n=e.track,o=e.retain;if("function"!=typeof t&&(t=function(){}),n instanceof MediaStreamTrack){var i=!!o;if(d.streamValidator.isValidStreamId(r))if(s=this.previewStreamManager.getStream(r)){try{t(void 0,s.replaceTrack(n,i))}catch(c){t(c)}return}var a=this.getStream(r);if(a)if(this.sessionManager){var s;if(s=this.sessionManager.streamManager.getLocalStream(a.sid)){try{t(void 0,s.replaceTrack(n,i))}catch(c){t(c)}return}c="stream is not found";t(f.createError(f.ErrorCodes.STREAM_NOT_EXISTS,c))}else t(f.createError(f.ErrorCodes.STREAM_NOT_EXISTS,"stream is not found"));else{var c="stream is not found";t(f.createError(f.ErrorCodes.STREAM_NOT_EXISTS,c))}}else{var c="invalid track, please check the 'track' parameter";t(f.createError(f.ErrorCodes.INVALID_PARAMETER,c))}},e.prototype.startMix=function(e,t){e=e||{bucket:"",region:""},"function"!=typeof t&&(t=function(){});var r=this.getUser(),n=s.ENUM_MIX_TYPE.record;switch(e.type){case"relay":n=s.ENUM_MIX_TYPE.relay;break;case"relay-and-record":n=s.ENUM_MIX_TYPE.relayRecord;break;case"update-config":n=s.ENUM_MIX_TYPE.update;break;case"record":default:n=s.ENUM_MIX_TYPE.record}var i=[];if(n===s.ENUM_MIX_TYPE.relay||n===s.ENUM_MIX_TYPE.relayRecord){if("[object Array]"!==Object.prototype.toString.call(e.pushURL))return void t(k=f.createError(f.ErrorCodes.INVALID_PARAMETER,"type is "+n+", pushURL must be an array"));i=e.pushURL?e.pushURL:i}var a=0;if("number"==typeof e.timeoutPeriod){var c=e.timeoutPeriod;if(!(c>=60&&c<=86400))return void t(k=f.createError(f.ErrorCodes.INVALID_PARAMETER,"timeoutPeriod must be >= 60 and <= 86400"));a=c}var u=s.ENUM_MIX_LAYOUT.flow,d=[],p=r&&r.uid||"",l=s.ENUM_MEDIA_TYPE.camera,m=[];if(e.layout&&"object"==typeof e.layout){switch(p=e.layout.mainViewUId?e.layout.mainViewUId:p,e.layout.mainViewType){case"screen":case"desktop":l=s.ENUM_MEDIA_TYPE.desktop;break;case"camera":default:l=s.ENUM_MEDIA_TYPE.camera}switch(e.layout.type){case"main":u=s.ENUM_MIX_LAYOUT.main;break;case"custom":u=s.ENUM_MIX_LAYOUT.custom,d=e.layout.custom?e.layout.custom:d;break;case"customMain":u=s.ENUM_MIX_LAYOUT.customMain;break;case"customFlow":u=s.ENUM_MIX_LAYOUT.customFlow;break;case"single":u=s.ENUM_MIX_LAYOUT.single;break;case"flow":default:u=s.ENUM_MIX_LAYOUT.flow}if(e.layout.standbyTypes&&"[object Array]"===Object.prototype.toString.call(e.layout.standbyTypes)&&e.layout.standbyTypes.forEach((function(e){switch(e){case"flow":m.push(s.ENUM_MIX_LAYOUT.flow);break;case"main":m.push(s.ENUM_MIX_LAYOUT.main);break;case"customMain":m.push(s.ENUM_MIX_LAYOUT.customMain);break;case"customFlow":m.push(s.ENUM_MIX_LAYOUT.customFlow);break;case"single":m.push(s.ENUM_MIX_LAYOUT.single)}})),n!==s.ENUM_MIX_TYPE.update){var h=m.indexOf(u);h>=0&&m.splice(h,1),m.unshift(u),m.length>3&&(m.length=3)}}var g="aac";e.audio&&"object"==typeof e.audio&&(g=e.audio.codec?e.audio.codec:g);var y="h264",b="CB",E=15,_=500;e.video&&"object"==typeof e.video&&(y=e.video.codec?e.video.codec:y,b=e.video.quality?e.video.quality:b,e.video.frameRate&&(v.includes(e.video.frameRate)?E=e.video.frameRate:o.default.warn("video framte rate must be one of "+v)),_=e.video.bitRate?e.video.bitRate:_);var S=s.ENUM_MIX_OUTPUT_MODE.audioVideo;switch(e.outputMode){case"audio":S=s.ENUM_MIX_OUTPUT_MODE.audio;break;case"audio-video":default:S=s.ENUM_MIX_OUTPUT_MODE.audioVideo}var T=1280,R=720;"number"==typeof e.width&&e.width>0&&(T=e.width),"number"==typeof e.height&&e.height>0&&(R=e.height);var w={r:0,g:0,b:0};e.backgroundColor&&"object"==typeof e.backgroundColor&&(w.r=e.backgroundColor.r?e.backgroundColor.r:0,w.g=e.backgroundColor.g?e.backgroundColor.g:0,w.b=e.backgroundColor.b?e.backgroundColor.b:0);var M=s.ENUM_WATER_MARK_POS.lt,C=s.ENUM_WATER_MARK_TYPE.none,P="";if(e.waterMark&&"object"==typeof e.waterMark){switch(e.waterMark.position){case"left-top":M=s.ENUM_WATER_MARK_POS.lt;break;case"left-bottom":M=s.ENUM_WATER_MARK_POS.lb;break;case"right-top":M=s.ENUM_WATER_MARK_POS.rt;break;case"right-bottom":M=s.ENUM_WATER_MARK_POS.rb;break;default:M=s.ENUM_WATER_MARK_POS.lt}switch(e.waterMark.type){case"image":C=s.ENUM_WATER_MARK_TYPE.image,"string"==typeof e.waterMark.remarks&&(P=e.waterMark.remarks);break;case"text":C=s.ENUM_WATER_MARK_TYPE.text,"string"==typeof e.waterMark.remarks&&(P=e.waterMark.remarks);break;case"time":default:C=s.ENUM_WATER_MARK_TYPE.time,P=""}}var O=s.ENUM_MIX_STREAM_ADD_MODE.auto;switch(e.streamAddMode){case"manual":O=s.ENUM_MIX_STREAM_ADD_MODE.manual;break;case"automatic":default:O=s.ENUM_MIX_STREAM_ADD_MODE.auto}var A={bucket:e.bucket,region:e.region,pushurl:i,layout:u,custom:d,audiocodec:g,videocodec:y,qualitylevel:b,framerate:E,bitrate:_,mainviewuid:p,mainviewtype:l,width:T,height:R,bgColor:w,watertype:C,waterpos:M,waterurl:P,mimetype:S,addstreammode:O};a>=60&&(A.expand=A.expand||{},A.expand.taskTimeout=a),n!==s.ENUM_MIX_TYPE.update&&(A.layouts=m);var I=[];if(e.streams&&"[object Array]"===Object.prototype.toString.call(e.streams)&&(this.mixStreams=e.streams,I=e.streams.map((function(e){var t;switch(e.mediaType){case"screen":t=s.ENUM_MEDIA_TYPE.desktop;break;case"camera":default:t=s.ENUM_MEDIA_TYPE.camera}return{user_id:e.uid,media_type:t}}))),!this.sessionManager){var k=f.createError(f.ErrorCodes.NOT_JOIN,"please join room first");return o.default.warn("startMix - "+k),void t(k)}this.mixLayout=A.layout,this.mixStreamMode=A.addstreammode,this.sessionManager.startMix(n,I,A,t)},e.prototype.stopMix=function(e,t){if(e=e||{type:"record"},"function"!=typeof t&&(t=function(){}),!this.sessionManager){var r=f.createError(f.ErrorCodes.NOT_JOIN,"please join room first");return o.default.warn("stopMix - "+r),void t(r)}var n;switch(e.type){case"relay":n=s.ENUM_MIX_TYPE.relay;break;case"relay-and-record":n=s.ENUM_MIX_TYPE.relayRecord;break;case"record":default:n=s.ENUM_MIX_TYPE.record}var i=[];n!==s.ENUM_MIX_TYPE.relay&&n!==s.ENUM_MIX_TYPE.relayRecord||"[object Array]"===Object.prototype.toString.call(e.pushURL)&&(i=e.pushURL?e.pushURL:i),this.sessionManager.stopMix(n,i,t)},e.prototype.queryMix=function(e){if("function"!=typeof e&&(e=function(){}),!this.sessionManager){var t=f.createError(f.ErrorCodes.NOT_JOIN,"please join room first");return o.default.warn("queryMix - "+t),void e(t)}this.sessionManager.queryMix(e)},e.prototype.addMixStreams=function(e,t){var r=this;if(e=e||{streams:[]},"function"!=typeof t&&(t=function(){}),"[object Array]"!==Object.prototype.toString.call(e.streams)){var n=f.createError(f.ErrorCodes.INVALID_PARAMETER,"streams must be an array");return o.default.warn("addMixStreams - "+n),void t(n)}if(!this.sessionManager){n=f.createError(f.ErrorCodes.NOT_JOIN,"please join room first");return o.default.warn("addMixStreams - "+n),void t(n)}e.streams.forEach((function(e){e.uid&&e.mediaType&&r.mixStreams&&(r.mixStreams.findIndex((function(t){return t.uid===e.uid&&t.mediaType===e.mediaType}))<0&&r.mixStreams.push(e))}));var i=e.streams.map((function(e){var t;switch(e.mediaType){case"screen":t=s.ENUM_MEDIA_TYPE.desktop;break;case"camera":default:t=s.ENUM_MEDIA_TYPE.camera}return{user_id:e.uid,media_type:t}}));this.sessionManager.addMixStreams(i,t)},e.prototype.removeMixStreams=function(e,t){var r=this;if(e=e||{streams:[]},"function"!=typeof t&&(t=function(){}),"[object Array]"!==Object.prototype.toString.call(e.streams)){var n=f.createError(f.ErrorCodes.INVALID_PARAMETER,"streams must be an array");return o.default.warn("removeMixStreams - "+n),void t(n)}if(!this.sessionManager){n=f.createError(f.ErrorCodes.INVALID_PARAMETER,"please join room first");return o.default.warn("removeMixStreams - "+n),void t(n)}e.streams.forEach((function(e){if(e.uid&&e.mediaType&&r.mixStreams){var t=r.mixStreams.findIndex((function(t){return t.uid===e.uid&&t.mediaType===e.mediaType}));t>=0&&r.mixStreams.splice(t,1)}}));var i=e.streams.map((function(e){var t;switch(e.mediaType){case"screen":t=s.ENUM_MEDIA_TYPE.desktop;break;case"camera":default:t=s.ENUM_MEDIA_TYPE.camera}return{user_id:e.uid,media_type:t}}));this.sessionManager.removeMixStreams(i,t)},e.prototype.startRecord=function(e,t){var r=n.__assign(n.__assign({},e),{type:"record"});this.startMix(r,(function(e,r){if("function"==typeof t)if(r){var n={Id:r.MixId,FileName:r.FileName};t(e,n)}else t(e)}))},e.prototype.stopRecord=function(e){this.stopMix({type:"record"},(function(t,r){if("function"==typeof e)if(r){var n={Id:r.MixId,FileName:r.FileName};e(t,n)}else e(t)}))},e.prototype.updateRecordStreams=function(e,t){function r(e,r){if("function"==typeof t)if(r){var n={Id:r.MixId,FileName:r.FileName};t(e,n)}else t(e)}if(e=e||{},!g.includes(e.type)){var n=f.createError(f.ErrorCodes.INVALID_PARAMETER,"type must be one of "+g);return o.default.warn("updateRecordStreams - "+n),void r(n)}if("[object Array]"!==Object.prototype.toString.call(e.streams)){n=f.createError(f.ErrorCodes.INVALID_PARAMETER,"streams must be an array");return o.default.warn("updateRecordStreams - "+n),void r(n)}if(!this.sessionManager){n=f.createError(f.ErrorCodes.NOT_JOIN,"please join room first");return o.default.warn("updateRecordStreams - "+n),void r(n)}switch(e.type){case"remove":this.removeMixStreams({streams:e.streams},r);break;case"add":this.addMixStreams({streams:e.streams},r);break;case"replace":var i=[];e.streams&&"[object Array]"===Object.prototype.toString.call(e.streams)&&(this.mixStreams=e.streams,i=e.streams.map((function(e){var t;switch(e.mediaType){case"screen":t=s.ENUM_MEDIA_TYPE.desktop;break;case"camera":default:t=s.ENUM_MEDIA_TYPE.camera}return{user_id:e.uid,media_type:t}})));var a={layout:-1,addstreammode:-1,watertype:-1};i[0]&&(a.mainviewuid=i[0].user_id,a.mainviewtype=i[0].media_type),this.mixLayout&&(a.layout=this.mixLayout),this.mixStreamMode&&(a.addstreammode=this.mixStreamMode),this.sessionManager.updateMix(i,a,r)}},e.prototype.startRelay=function(e,t){var r=n.__assign(n.__assign({},e),{type:"relay"});this.startMix(r,(function(e,r){if("function"==typeof t)if(r){var n={Id:r.MixId,PushURL:r.PushURL};t(e,n)}else t(e)}))},e.prototype.stopRelay=function(e){this.stopMix({type:"relay"},(function(t,r){if("function"==typeof e)if(r){var n={Id:r.MixId,PushURL:r.PushURL};e(t,n)}else e(t)}))},e.prototype.updateRelayStreams=function(e,t){function r(e,r){if("function"==typeof t)if(r){var n={Id:r.MixId,PushURL:r.PushURL};t(e,n)}else t(e)}if(e=e||{},!g.includes(e.type)){var n=f.createError(f.ErrorCodes.INVALID_PARAMETER,"type must be one of "+g);return o.default.warn("updateRelayStreams - "+n),void r(n)}if("[object Array]"!==Object.prototype.toString.call(e.streams)){n=f.createError(f.ErrorCodes.INVALID_PARAMETER,"streams must be an array");return o.default.warn("updateRelayStreams - "+n),void r(n)}if(!this.sessionManager){n=f.createError(f.ErrorCodes.NOT_JOIN,"please join room first");return o.default.warn("updateRelayStreams - "+n),void r(n)}switch(e.type){case"remove":this.removeMixStreams(e,r);break;case"add":this.addMixStreams(e,r);break;case"replace":var i=[];e.streams&&"[object Array]"===Object.prototype.toString.call(e.streams)&&(this.mixStreams=e.streams,i=e.streams.map((function(e){var t;switch(e.mediaType){case"screen":t=s.ENUM_MEDIA_TYPE.desktop;break;case"camera":default:t=s.ENUM_MEDIA_TYPE.camera}return{user_id:e.uid,media_type:t}})));var a={layout:-1,addstreammode:-1,watertype:-1};i[0]&&(a.mainviewuid=i[0].user_id,a.mainviewtype=i[0].media_type),this.mixLayout&&(a.layout=this.mixLayout),this.mixStreamMode&&(a.addstreammode=this.mixStreamMode),this.sessionManager.updateMix(i,a,r)}},e.prototype.updateRelayPushURL=function(e,t){function r(e,r){if("function"==typeof t)if(r){var n={Id:r.MixId,PushURL:r.PushURL};t(e,n)}else t(e)}if(e=e||{},!y.includes(e.type)){var n=f.createError(f.ErrorCodes.INVALID_PARAMETER,"type must be one of "+y);return o.default.warn("updateRelayPushURL - "+n),void r(n)}if("[object Array]"!==Object.prototype.toString.call(e.pushURL)){n=f.createError(f.ErrorCodes.INVALID_PARAMETER,"pushURL must be an array");return o.default.warn("updateRelayPushURL - "+n),void r(n)}if(!this.sessionManager){n=f.createError(f.ErrorCodes.NOT_JOIN,"please join room first");return o.default.warn("updateRelayStreams - "+n),void r(n)}switch(e.type){case"remove":var i={type:"relay",pushURL:e.pushURL};this.stopMix(i,r);break;case"add":if(!(e.pushURL.length>0))return void r(n=f.createError(f.ErrorCodes.INVALID_PARAMETER,"pushURL must be an non-empty array"));var a={layout:-1,addstreammode:-1,watertype:-1,pushurl:e.pushURL};this.mixLayout&&(a.layout=this.mixLayout);var c=[];this.mixStreamMode&&(a.addstreammode=this.mixStreamMode,this.mixStreamMode===s.ENUM_MIX_STREAM_ADD_MODE.manual&&this.mixStreams&&(c=this.mixStreams.map((function(e){var t;switch(e.mediaType){case"screen":t=s.ENUM_MEDIA_TYPE.desktop;break;case"camera":default:t=s.ENUM_MEDIA_TYPE.camera}return{user_id:e.uid,media_type:t}})))),this.sessionManager.updateMix(c,a,r)}},e.prototype.updateRelayLayout=function(e,t){function r(e,r){if("function"==typeof t)if(r){var n={Id:r.MixId,PushURL:r.PushURL};t(e,n)}else t(e)}if((e=e||{}).layout&&"object"!=typeof e.layout){var n=f.createError(f.ErrorCodes.INVALID_PARAMETER,"layout is invalid");return o.default.warn("updateRelayLayout - "+n),void r(n)}if(!this.sessionManager){n=f.createError(f.ErrorCodes.NOT_JOIN,"please join room first");return o.default.warn("updateRelayLayout - "+n),void r(n)}var i={layout:-1,addstreammode:-1,watertype:-1};if(e.layout.mainViewUId)i.mainviewuid=e.layout.mainViewUId;else{var a=this.getUser();a&&(i.mainviewuid=a.uid)}switch(e.layout.mainViewType){case"screen":case"desktop":i.mainviewtype=s.ENUM_MEDIA_TYPE.desktop;break;case"camera":default:i.mainviewtype=s.ENUM_MEDIA_TYPE.camera}switch(e.layout.type){case"main":i.layout=s.ENUM_MIX_LAYOUT.main;break;case"custom":i.layout=s.ENUM_MIX_LAYOUT.custom,e.layout.custom&&(i.custom=e.layout.custom);break;case"customMain":i.layout=s.ENUM_MIX_LAYOUT.customMain;break;case"customFlow":i.layout=s.ENUM_MIX_LAYOUT.customFlow;break;case"single":i.layout=s.ENUM_MIX_LAYOUT.single;break;case"flow":i.layout=s.ENUM_MIX_LAYOUT.flow;default:this.mixLayout&&(i.layout=this.mixLayout)}i.layout&&(this.mixLayout=i.layout);var c=[];this.mixStreamMode&&(i.addstreammode=this.mixStreamMode,this.mixStreamMode===s.ENUM_MIX_STREAM_ADD_MODE.manual&&this.mixStreams&&(c=this.mixStreams.map((function(e){var t;switch(e.mediaType){case"screen":t=s.ENUM_MEDIA_TYPE.desktop;break;case"camera":default:t=s.ENUM_MEDIA_TYPE.camera}return{user_id:e.uid,media_type:t}})))),this.sessionManager.updateMix(c,i,r)},e.prototype.createStream=function(e,t){if("function"!=typeof t&&(t=function(){}),"object"!=typeof e){var r="the options is invalid";return o.default.warn(r),void t(f.createError(f.ErrorCodes.INVALID_PARAMETER,r))}if(!d.streamValidator.isValidStreamId(e.previewId)){r="type error, the previewId isnot a valid string";return o.default.warn(r),void t(f.createError(f.ErrorCodes.INVALID_PARAMETER,r))}var n={audio:!1,video:!1,screen:!1,mediaStream:e.mediaStream};if("boolean"==typeof e.audio&&(n.audio=e.audio),"boolean"==typeof e.video&&(n.video=e.video),"boolean"==typeof e.screen&&(n.screen=e.screen),"boolean"==typeof e.screenAudio&&(n.screenAudio=e.screenAudio),n.screen&&n.video&&o.default.warn("both video and screen are true, only camera's video will be used"),n.screen&&n.audio&&o.default.warn("both audio and screen are true, only microphone's audio will be used"),n.audio&&n.video&&n.screen){r="audio, video and screen cannot be true at the same time";return o.default.warn(r),void t(f.createError(f.ErrorCodes.INVALID_PARAMETER,r))}if(!(n.audio||n.video||n.screen||n.mediaStream)){r="audio, video and screen cannot be false at the same time";return o.default.warn(r),void t(f.createError(f.ErrorCodes.INVALID_PARAMETER,r))}if(["microphoneId","cameraId","extensionId","file","filePath"].forEach((function(t){n[t]=e[t]})),e.facingMode&&h.includes(e.facingMode)&&(n.facingMode=e.facingMode),!d.isValidString(n.microphoneId)){r="type error, the microphoneId is not blank or a valid string";return o.default.warn(r),void t(f.createError(f.ErrorCodes.INVALID_PARAMETER,r))}if(!d.isValidString(n.cameraId)){r="type error, the cameraId is not blank or a valid string";return o.default.warn(r),void t(f.createError(f.ErrorCodes.INVALID_PARAMETER,r))}if(n.mediaStream&&!(n.mediaStream instanceof MediaStream)){r="type error, the mediaStream is not a valid MediaStream";return o.default.warn(r),void t(f.createError(f.ErrorCodes.INVALID_PARAMETER,r))}var i=this.getUser(),a=i?i.uid:"unknown";this.previewStreamManager.createStream(a,e.previewId,n,this.profileName).then((function(e){t(void 0,e.convertToOuterStream())})).catch(t)},e.prototype.publishStream=function(e,t){var r=this;if(!d.streamValidator.isValidStreamId(e)){var n="type error, the streamId isnot a valid string";return o.default.warn(n),void(t&&t(f.createError(f.ErrorCodes.INVALID_PARAMETER,n)))}if(!this.sessionManager){n="please join room first";return o.default.warn(n),void(t&&t(f.createError(f.ErrorCodes.NOT_JOIN,n)))}var i=this.previewStreamManager.getStream(e);if(!i){n="stream isnot found, maybe it has already been published or destroyed";return o.default.warn(n),void(t&&t(f.createError(f.ErrorCodes.STREAM_NOT_EXISTS,n)))}this.sessionManager.publishStream(i,(function(n){r.previewStreamManager.removeStream(e,!0).then((function(){t&&t(void 0,n.convertToOuterStream())})).catch((function(e){o.default.warn("publish stream failure when remove it "+e),t&&t(e)}))}),(function(e){t&&t(e)}))},e.prototype.unpublishStream=function(e,t){var r=this;if(!d.streamValidator.isValidStreamId(e)){var n="type error, the streamId isnot a valid string";return o.default.warn(n),void(t&&t(f.createError(f.ErrorCodes.INVALID_PARAMETER,n)))}if(!this.sessionManager){n="please join room first";return o.default.warn(n),void(t&&t(f.createError(f.ErrorCodes.NOT_JOIN,n)))}var i=this.sessionManager.streamManager.getLocalStreamByPreviewId(e);if(!i){n="stream is not found";return o.default.warn(n),void(t&&t(f.createError(f.ErrorCodes.STREAM_NOT_EXISTS,n)))}this.sessionManager.unpublishStream(i,(function(e){r.previewStreamManager.copyStream(e).then((function(n){var o;null===(o=r.sessionManager)||void 0===o||o.streamManager.removeLocalStream(e,!0),t&&t(void 0,n.convertToOuterStream())}))}),(function(e){t&&t(e)}))},e.prototype.removeStream=function(e,t){this.destroyStream(e,t)},e.prototype.destroyStream=function(e,t){if("function"!=typeof t&&(t=function(){}),!d.streamValidator.isValidStreamId(e)){var r="type error, the previewId isnot a valid string";return o.default.warn(r),void t(f.createError(f.ErrorCodes.INVALID_PARAMETER,r))}this.previewStreamManager.removeStream(e,!1).then((function(){t()})).catch((function(e){t(e)}))},e.prototype.enableAudioVolumeIndicator=function(e){d.isNil(e)?(this.audioVolumeIndicatorInterval=2e3,this.sessionManager&&this.sessionManager.enableAudioVolumeIndicator()):d.isValidNumber(e,!0)&&e>=200&&(this.audioVolumeIndicatorInterval=e,this.sessionManager&&this.sessionManager.enableAudioVolumeIndicator(e))},e}();t.default=b},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(6),o=function(){function e(){this.emitter=new n.EventEmitter}return e.prototype.bind=function(e){e.emitter=this.emitter},e.prototype.on=function(e,t){this.emitter.on(e,t)},e.prototype.off=function(e,t){this.emitter.off(e,t)},e}();t.EventManager=o},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(6),o=r(20),i=r(71),a=r(12),s=r(14),c=r(35),u=r(18),d=r(41),p=r(0),f=r(36),l=r(5),m=r(4),h=r(42),v=r(10),g=r(82),y=r(3),b=r(31),E=r(83),_=function(){function e(){}return Object.defineProperty(e.prototype,"devinfo",{get:function(){return d.encode(this._devinfo)},enumerable:!0,configurable:!0}),e}(),S=function(){function e(e,t,r,o,i,s){var d=this;this.session=new _,this.signalManager=new b.SignalManager,this.reconnectTimes=0,this.rpcMap={},this.joinStatus=m.ENUM_ROOM_STATUS.unjoin,this.recordId="",this.recordStreamType=m.ENUM_STREAM_TYPE.publish,this.recordMediaType=m.ENUM_MEDIA_TYPE.camera,this.recordStatus=m.ENUM_RECORD_STATUS.unrecord,this.users=[],this.isDestroyed=!1;var p=l.getDeviceInfo(),h=l.getSystemInfo(),v=l.getCPUInfo();this.sessionId="",this.session.app_id=e,this.session.room_token=t,this.session.room_type=r,this.session.role_type=o;var y={sdkv:u.version,agent:f.getAgent(),device:p.vendor+"_"+p.brand+"_"+p.model,system:""+h.name+h.version+"_"+h.versionName,network:""+l.getNetworkInfo().network,cpu:v.brand+"_"+v.model+"_"+v.core,mem:l.getMemInfo().capacity+"MB"};this.session._devinfo=y,this.innerEmitter=new n.EventEmitter,this.innerEmitter.on("mediaStreamPublished",this.onMediaStreamPublished.bind(this)),this.innerEmitter.on("mediaStreamSubscribed",this.onMediaStreamSubscribed.bind(this)),this.innerEmitter.on("screenMediaStreamEnded",this.onScreenMediaStreamEnded.bind(this)),this.innerEmitter.on("streamConnectionClosed",this.onStreamConnectionClosed.bind(this)),this.innerEmitter.on("streamConnectionReconnecting",this.onStreamConnectionReconnecting.bind(this)),this.innerEmitter.on("streamConnectionReconnected",this.onStreamConnectionReconnected.bind(this)),this.innerEmitter.on("streamConnectionDisconnected",this.onStreamConnectionDisconnected.bind(this)),this.streamManager=new a.StreamManager(i,s),this.logReporter=new c.LogReporter,this.streamManager.emitter=this.innerEmitter,this.streamManager.logReporter=this.logReporter,this.networkQualityEvaluator=new g.NetworkQualityEvaluator(this.streamManager),this.networkQualityEvaluator.on("network-quality-audio",(function(e){e.rtt>0&&(e.rtt<100?d.signalManager.award():d.signalManager.punish())})),this.networkQualityEvaluator.on("network-quality",(function(e,t){d._emitter&&d._emitter.emit("network-quality",{uplink:g.NetworkQualityEvaluator.convert2Quality(e),downlink:g.NetworkQualityEvaluator.convert2Quality(t)})}))}return Object.defineProperty(e.prototype,"emitter",{set:function(e){this._emitter=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"isJoinedRoom",{get:function(){return this.joinStatus===m.ENUM_ROOM_STATUS.joined},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"isRecording",{get:function(){return this.recordStatus===m.ENUM_RECORD_STATUS.recording},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"user",{get:function(){return{user_id:this.session.user_id}},enumerable:!0,configurable:!0}),e.prototype.connect=function(e){var t=this;this.socketManager=new i.SocketManager(e),this.socketManager.init((function(e){var r;try{r=JSON.parse(e.data)}catch(e){return void p.default.error("socket onmessage ",e)}if(r){var n=t.rpcMap[r.rpc_id]||{},o=n.req,i=n.resource,a=t.rpcMap[r.rpc_id]||{},s=a.onSuccess,c=a.onFailure;if(delete t.rpcMap[r.rpc_id],p.default.debug("socket request: ",o),p.default.debug("socket response: ",r),o){if("function"!=typeof s&&(s=function(){}),0!==r.err){if("queymix"===o.method&&"can't find job"===r.msg)return void t.onQueryMix(void 0,s);if("startmix"===o.method&&o.data&&o.data.type!==m.ENUM_MIX_TYPE.update&&(1072===r.err||1073===r.err)){var u=new Promise((function(e,r){t.queryMix((function(t,n){t?(p.default.warn("start & query mix ",t),r(t)):(p.default.debug("start & query mix ",n),e(n))}))})),d=new Promise((function(e,r){var n=o.data.config,i=o.data.streams||[],a={layout:n.layout,watertype:n.watertype,addstreammode:n.addstreammode};n.pushurl&&n.pushurl.length>0&&(a.pushurl=n.pushurl),n.custom&&n.custom.length>0&&(a.custom=n.custom),n.layouts&&n.layouts.length>0&&(a.layouts=n.layouts),n.mainviewuid&&(a.mainviewuid=n.mainviewuid),n.mainviewtype&&n.mainviewtype>=0&&(a.mainviewtype=n.mainviewtype),n.waterpos&&n.waterpos>=0&&(a.waterpos=n.waterpos),n.waterurl&&(a.waterurl=n.waterurl),t.updateMix(i,a,(function(t,n){t?(p.default.warn("start & update mix ",t),r(t)):(p.default.debug("start & update mix ",n),e(n))}))}));return void Promise.all([u,d]).then((function(e){s&&s(e[0])})).catch((function(e){c&&c(e)}))}return"stopmix"===o.method&&1040===r.err?(p.default.debug("onStopMix 1040"),void(s&&s({MixId:"",PushURL:[]}))):void("function"==typeof c?c(y.createError(""+r.err,r.msg)):t.onError({method:o.method,code:""+r.err,msg:r.msg}))}switch("function"!=typeof c&&(c=function(){}),o.method){case"joinroom":switch(t.joinStatus){case m.ENUM_ROOM_STATUS.joining:t.onJoinRoom(r.data,s);break;case m.ENUM_ROOM_STATUS.rejoining:t.onRejoinRoom(r.data,s);break;default:p.default.warn("ignore, room status is "+m.ENUM_ROOM_STATUS[t.joinStatus])}break;case"leaveroom":t.onLeaveRoom(r.data,s);break;case"subscribe":t.onSubscribe({streamsub_id:r.data.streamsub_id,stream_id:r.data.stream_id,media_type:r.data.media_type,user_id:o.data.dst.user_id},s,c,i);break;case"unsubscribe":t.onUnsubscribe(r.data,s,c,i);break;case"publish":t.onPublish(r.data,s,c,i);break;case"unpublish":t.onUnpublish(r.data,s,c,i);break;case"sdp":r.data.stream_type===m.ENUM_STREAM_TYPE.publish&&t.onSdpPublish(r.data,s,c,i),r.data.stream_type===m.ENUM_STREAM_TYPE.subscribe&&t.onSdpSubscribe(r.data,s,c,i);break;case"mute":s();break;case"startrecord":t.onStartRecord(r.data,s);break;case"stoprecord":t.onStopRecord(r.data,s);break;case"startmix":t.onStartMix(r.data,s);break;case"stopmix":t.onStopMix(r.data,s);break;case"queymix":t.onQueryMix(r.data,s);break;case"addmixstream":t.onAddMixStreams(r.data,s);break;case"delmixstream":t.onRemoveMixStreams(r.data,s)}}else switch(r.method){case"userst":r.data.cmdtype===m.ENUM_USER_CMD_TYPE.userJoin&&t.onUserJoin(r.data),r.data.cmdtype===m.ENUM_USER_CMD_TYPE.userLeave&&t.onUserLeave(r.data);break;case"streamst":r.data.cmdtype===m.ENUM_STREAM_CMD_TYPE.add&&t.onAddStream(r.data),r.data.cmdtype===m.ENUM_STREAM_CMD_TYPE.remove&&t.onRemoveStream(r.data);break;case"transportclose":t.onTransportClose(r.data);break;case"transporttimeout":t.onTransportTimeout(r.data);break;case"trackst":switch(r.data.track_type){case m.ENUM_TRACK_TYPE.audio:t.onAudioTrackst(r.data);break;case m.ENUM_TRACK_TYPE.video:t.onVideoTrackst(r.data);break;case m.ENUM_TRACK_TYPE.data:t.onDataTrackst(r.data);break;default:p.default.warn("trackst unknown track type ",r.data.track_type)}break;case"kickoff":t.onKickoff(r.data);break;case"mixnotify":t.onMixNotify(r.err,r.msg,r.data)}}else p.default.warn("socket receives message ",r)}),(function(e,r){var n,o,i,a,s,c,u;p.default.debug("connection-state-change ",e,r),"CLOSED"===e&&"CONNECTING"===r&&(t.joinStatus===m.ENUM_ROOM_STATUS.joining?null===(n=t._emitter)||void 0===n||n.emit("connection-state-change",{previous:e,current:r}):t.joinStatus===m.ENUM_ROOM_STATUS.joined?(t.clearCachedRPC(),0===t.reconnectTimes&&(null===(o=t._emitter)||void 0===o||o.emit("connection-state-change",{previous:"OPEN",current:"RECONNECTING"})),t.reconnectTimes+=1):p.default.warn("connection exception ",e,r)),"OPEN"===e&&"CLOSED"===r&&p.default.warn("connection is closed and will reconnect automatically"),"CONNECTING"===e&&"CLOSED"===r&&t.reconnectTimes>=60&&(p.default.error("connection is closed and reconnect failed"),t.disconnect("reconnect failed"),t.destroy(),null===(i=t._emitter)||void 0===i||i.emit("connection-state-change",{previous:"RECONNECTING",current:r})),"CONNECTING"===e&&"OPEN"===r&&(0===t.reconnectTimes?null===(a=t._emitter)||void 0===a||a.emit("connection-state-change",{previous:e,current:r}):(t.joinStatus===m.ENUM_ROOM_STATUS.joined&&t.rejoinRoom().then((function(){p.default.info("rejoin room successfully")})).catch((function(e){return p.default.error("rejoin room unsuccessfully with error: ",e),t.rejoinRoom().then((function(){p.default.info("rejoin room2 successfully")}))})).catch((function(e){p.default.error("rejoin room2 unsuccessfully with error: ",e)})),t.reconnectTimes=0,null===(s=t._emitter)||void 0===s||s.emit("connection-state-change",{previous:"RECONNECTING",current:r}))),"OPEN"===e&&"CLOSING"===r&&(null===(c=t._emitter)||void 0===c||c.emit("connection-state-change",{previous:e,current:r})),"CLOSING"===e&&"CLOSED"===r&&(null===(u=t._emitter)||void 0===u||u.emit("connection-state-change",{previous:e,current:r}))}),(function(e){var r;p.default.debug("connection-error ",e),null===(r=t._emitter)||void 0===r||r.emit("connection-error",e)}));return this.socketManager.initHeartBeat((function(){var e={method:"ping",version:.1,rpc_id:f.getId(),data:{}};return JSON.stringify(e)}),3e4),this.socketManager.connect()},e.prototype.clearCachedRPC=function(){for(var e in this.rpcMap){var t=(this.rpcMap[e]||{}).onFailure;t&&t(y.createError(y.ErrorCodes.BAD_REQUEST,"request failed")),delete this.rpcMap[e]}},e.prototype.disconnect=function(e){var t=this;this.reconnectTimes=0,this.socketManager&&this.socketManager.close(1e3,e||"disconnect").catch((function(e){p.default.error("connect close - ",e)})).finally((function(){t.socketManager&&t.socketManager.destroy(),t.socketManager=void 0}))},e.prototype.send=function(e,t,r,n,o){var i=this,a=f.getId(),s={method:e,version:.1,rpc_id:a,data:t};this.rpcMap[a]={req:s,onSuccess:r,onFailure:n,resource:o};var c=JSON.stringify(s);if(this.socketManager)this.socketManager.send(c).catch((function(e){n&&n(e),delete i.rpcMap[a]}));else{n&&n(y.createError(y.ErrorCodes.OTHERS,"connection isnot open")),delete this.rpcMap[a]}},e.prototype.destroy=function(){var e,t=this;this.isDestroyed=!0,setTimeout((function(){t._emitter=void 0}),0),this.rpcMap={},this.users=[],this.networkQualityEvaluator.destory(),this.logReporter.destroy(),null===(e=this.audioVolumeIndicator)||void 0===e||e.destroy(),this.recordId="",this.recordStatus=m.ENUM_RECORD_STATUS.unrecord,this.streamManager.removeAllLocalStreams(),this.streamManager.removeAllRemoteStreams(),this.streamManager.removeAllEffect()},e.prototype.getGW=function(){return o.get({data:{Action:"rsugetrtcgateway",rpc_id:f.getId(),user_id:this.session.user_id,room_id:this.session.room_id,app_id:this.session.app_id,token:this.session.room_token,devinfo:this.session.devinfo}}).then((function(e){return e.data.access_token}))},e.prototype.getLiveGW=function(){return o.get({data:{Action:"rsugetlivegateway",rpc_id:f.getId(),user_id:this.session.user_id,room_id:this.session.room_id,app_id:this.session.app_id,token:this.session.room_token,role:this.session.role_type,devinfo:this.session.devinfo}}).then((function(e){return e.data.access_token}))},e.prototype.setRole=function(e){this.session.role_type=e},e.prototype.joinRoom=function(e,t,r,n){var o=this,i="";switch(this.joinStatus){case m.ENUM_ROOM_STATUS.rejoining:case m.ENUM_ROOM_STATUS.joining:return i="you are joining the room",p.default.debug("joinRoom - ",i),void n(i);case m.ENUM_ROOM_STATUS.leaving:return i="you are leaving the room",p.default.debug("joinRoom - ",i),void n(i);case m.ENUM_ROOM_STATUS.joined:return i="you have already joined the room",p.default.debug("joinRoom - ",i),void n(i);case m.ENUM_ROOM_STATUS.unjoin:}this.joinStatus=m.ENUM_ROOM_STATUS.joining,this.session.room_id=e,this.session.user_id=t,this.logReporter.init(this.session.app_id,e,t);var a=function(){p.default.debug("joinRoom success"),o.joinStatus=m.ENUM_ROOM_STATUS.joined,r(h.convertToOuterUser(o.user))},s=function(e){o.logReporter.destroy(),o.session.user_id="",o.session.room_id="",o.joinStatus=m.ENUM_ROOM_STATUS.unjoin,o.logReporter.reportExceptionLog(c.ENUM_LOG_EXCEPTION_TYPE.joinRoom,{msg:""+e}),n(e)},u=function(e,t,r){o.connect(e).then((function(){var e={app_id:o.session.app_id,room_id:o.session.room_id,user_id:o.session.user_id,authtoken:o.session.room_token,devinfo:o.session.devinfo,role_type:o.session.role_type,room_type:o.session.room_type,sessionid:o.sessionId};o.send("joinroom",e,t,r)})).catch(r)};if(v.SERVER_CONFIG.signal){if(!/^wss:\/\/[\w\.]+:\d+$/i.test(v.SERVER_CONFIG.signal))return void s(y.createError(y.ErrorCodes.INVALID_PARAMETER,"invalid signal address "+v.SERVER_CONFIG.signal));var f=v.SERVER_CONFIG.signal.match(/[\w\.]+/gi);if(!(f&&f.length>=3))return void s(y.createError(y.ErrorCodes.INVALID_PARAMETER,"invalid signal address "+v.SERVER_CONFIG.signal));this.signalManager.add(new b.Signal(f[1],f[2],1)),u(this.signalManager,a,s)}else this.session.room_type===m.ENUM_ROOM_TYPE.live?this.getLiveGW().then((function(e){var t;p.default.debug("getLiveGW token ",e);try{t=d.decode(e),p.default.debug("getLiveGW token ",t)}catch(t){throw y.createError(y.ErrorCodes.SERVER_API,"get invalid access token "+e)}if(!(t.length>=0))throw y.createError(y.ErrorCodes.SERVER_API,"get blank access token "+e);t.forEach((function(e){o.signalManager.add(new b.Signal(e.singal,e.port,e.ssl))})),u(o.signalManager,a,s)})).catch(s):this.getGW().then((function(e){var t;p.default.debug("getGW token ",e);try{t=d.decode(e)}catch(t){throw y.createError(y.ErrorCodes.SERVER_API,"get invalid access token "+e)}if(!(t.length>=0))throw y.createError(y.ErrorCodes.SERVER_API,"get blank access token "+e);t.forEach((function(e){o.signalManager.add(new b.Signal(e.singal,e.port,e.ssl))})),u(o.signalManager,a,s)})).catch(s)},e.prototype.onJoinRoom=function(e,t){var r=this,n=e.users,o=void 0===n?[]:n,i=e.streams,a=void 0===i?[]:i;p.default.debug("onJoinRoom ",o,a),o=o||[],a=a||[],this.users=o.filter((function(e){return e.user_id!==r.user.user_id})),a.forEach((function(e){e.uid!==r.user.user_id&&r.streamManager.createRemoteStream(e)})),this.logReporter.reportJoinRoomLog(),t(),setTimeout((function(){r.users.forEach((function(e){r._emitter&&r._emitter.emit("user-added",h.convertToOuterUser(e))})),r.streamManager.getAllRemoteStreams().forEach((function(e){r._emitter&&r._emitter.emit("stream-added",e.convertToOuterStream())}))}),0)},e.prototype.rejoinRoom=function(){var e=this,t="";switch(this.joinStatus){case m.ENUM_ROOM_STATUS.rejoining:case m.ENUM_ROOM_STATUS.joining:return t="you are joining the room",p.default.debug("rejoinRoom - ",t),Promise.reject(t);case m.ENUM_ROOM_STATUS.leaving:return t="you are leaving the room",p.default.debug("rejoinRoom - ",t),Promise.reject(t);case m.ENUM_ROOM_STATUS.unjoin:return t="you have not joined the room",p.default.debug("rejoinRoom - ",t),Promise.reject(t);case m.ENUM_ROOM_STATUS.joined:}return this.joinStatus=m.ENUM_ROOM_STATUS.rejoining,new Promise((function(t,r){var n={app_id:e.session.app_id,room_id:e.session.room_id,user_id:e.session.user_id,authtoken:e.session.room_token,devinfo:e.session.devinfo,role_type:e.session.role_type,room_type:e.session.room_type,sessionid:e.sessionId};setTimeout((function(){e.send("joinroom",n,(function(){p.default.debug("rejoinRoom success"),e.joinStatus=m.ENUM_ROOM_STATUS.joined,t()}),(function(t){e.joinStatus=m.ENUM_ROOM_STATUS.joined,r(t)}))}),0)}))},e.prototype.onRejoinRoom=function(e,t){var r=this,n=e.users,o=void 0===n?[]:n,i=e.streams,a=void 0===i?[]:i;p.default.debug("onRejoinRoom ",o,a),t(),a=a||[];var s=[],c=[],u=[];(o=o||[]).forEach((function(e){e.user_id!==r.user.user_id&&(r.users.findIndex((function(t){return t.user_id===e.user_id}))>=0?s.push(e):c.push(e))})),this.users.forEach((function(e){s.findIndex((function(t){return t.user_id===e.user_id}))<0&&u.push(e)})),this.users=s.concat(c),c.forEach((function(e){r._emitter&&r._emitter.emit("user-added",h.convertToOuterUser(e))})),u.forEach((function(e){r._emitter&&r._emitter.emit("user-removed",h.convertToOuterUser(e))}));var d=this.streamManager.getAllRemoteStreams(),f=[],l=[],v=[];a.forEach((function(e){e.uid!==r.user.user_id&&(d.findIndex((function(t){return t.streamId===e.sid}))>=0?f.push(e):l.push(e))})),d.forEach((function(e){f.findIndex((function(t){return t.sid===e.streamId}))<0&&v.push(e)})),f.forEach((function(e){var t=r.streamManager.getRemoteStream(e.sid);t&&t.status===m.ENUM_SUBSCRIBE_STATUS.subscribed&&(p.default.debug("onRejoin - remote stream will resubscribe ",t),r.resubscribe(t))})),l.forEach((function(e){var t=r.streamManager.createRemoteStream(e);t&&r._emitter&&r._emitter.emit("stream-added",t.convertToOuterStream())})),v.forEach((function(e){r.streamManager.removeRemoteStream(e),r._emitter&&r._emitter.emit("stream-removed",e.convertToOuterStream())})),this.streamManager.getAllLocalStreams().forEach((function(e){p.default.debug("onRejoin - local stream will republish ",e),r.republish(e)}))},e.prototype.leaveRoom=function(e,t,r){var n=this,o="";switch(this.joinStatus){case m.ENUM_ROOM_STATUS.unjoin:return o="you have not joined the room",p.default.debug("leaveRoom - ",o),void r(y.createError(y.ErrorCodes.NOT_JOIN,o));case m.ENUM_ROOM_STATUS.joining:return o="you are joining the room",p.default.debug("leaveRoom - ",o),void r(y.createError(y.ErrorCodes.JOINING,o));case m.ENUM_ROOM_STATUS.leaving:return o="you are leaving the room",r(y.createError(y.ErrorCodes.LEAVING,o)),void r(o);case m.ENUM_ROOM_STATUS.joined:case m.ENUM_ROOM_STATUS.rejoining:}this.joinStatus=m.ENUM_ROOM_STATUS.leaving,this.isRecording&&!e.keepRecording&&this.socketManager&&this.stopRecording((function(){p.default.debug("leave room - stopRecording ")}),(function(e){p.default.warn("leave room - stop recording failed ",e)})),this.streamManager.getAllLocalStreams().forEach((function(e){e.connectionState!==s.ENUM_STREAM_CONNECTION_STATE.disconnected?(e.canUnPublish&&n.socketManager&&n._unpublish(e,(function(){p.default.info("leave room - unpublish success")}),(function(e){p.default.warn("leave room - unpublish failed ",e)})),e.close()):n.streamManager.removeLocalStream(e)})),this.streamManager.getAllRemoteStreams().forEach((function(e){e.connectionState!==s.ENUM_STREAM_CONNECTION_STATE.disconnected?(e.canUnSubscribe&&n.socketManager&&n._unsubscribe(n.user.user_id,e,(function(){p.default.info("leave room - unsubscribe success")}),(function(e){p.default.warn("leave room - unsubscribe failed ",e)})),e.close()):n.streamManager.removeRemoteStream(e)}));var i=function(){p.default.debug("leaveRoom success"),n.joinStatus=m.ENUM_ROOM_STATUS.unjoin,n.disconnect("leave room"),n.destroy(),t(h.convertToOuterUser(n.user))};this.socketManager&&this.socketManager.isOpened?this.send("leaveroom",{room_id:this.session.room_id},i,(function(e){p.default.debug("leaveRoom failed ",e),n.joinStatus=m.ENUM_ROOM_STATUS.joined,r(e)})):i()},e.prototype.onLeaveRoom=function(e,t){p.default.debug("onLeaveRoom ",e),t()},e.prototype.publish=function(e,t,r){var n=this,o="";if(!this.isJoinedRoom)return o="you have not joined the room",p.default.warn("publish - ",o),void r(y.createError(y.ErrorCodes.NOT_JOIN,o));if(this.session.role_type===m.ENUM_ROLE_TYPE.pullStream)return o="role type is pull",p.default.warn("publish - ",o),void r(y.createError(y.ErrorCodes.ROLE_TYPE_NOT_MATCH,o));var i=a.StreamManager.generatePublishConfig(e),s=this.streamManager.getAllLocalStreams().find((function(e){return e.mediaType===i.mediaType}));if(s){var u=void 0;switch(s.mediaType){case m.ENUM_MEDIA_TYPE.desktop:u="screen";break;case m.ENUM_MEDIA_TYPE.camera:default:u="camera"}return o="the stream with "+u+" type exists, only one "+u+" stream can be published",p.default.warn(o),void r(y.createError(y.ErrorCodes.STREAM_EXISTS,o))}var d,f=function(e){p.default.debug("publish success"),t(e.convertToOuterStream())},l=function(e){p.default.warn("publish - ",e),n.logReporter.reportExceptionLog(c.ENUM_LOG_EXCEPTION_TYPE.publish,{stype:m.ENUM_STREAM_TYPE.publish,mtype:i.mediaType}),r(e)};try{d=this.streamManager.createLocalStream(this.user.user_id,i)}catch(o){return p.default.warn("publish - ",o),void l(o)}p.default.debug("create local stream ",d),d.video&&d.updateVP(),d.status=m.ENUM_PUBLISH_STATUS.publishing;var h=function(e){n.streamManager.removeLocalStream(d),l(e)};d.init(e).then((function(){n.send("publish",{user_id:d.userId,media_type:d.mediaType,audio:d.audio,video:d.video,data:d.data,vp:d.vp,payload:d.videoCodec},f,h,d)})).catch(h)},e.prototype.publishStream=function(e,t,r){var n=this,o="";if(!this.isJoinedRoom)return o="you have not joined the room",p.default.warn("publish - ",o),void r(y.createError(y.ErrorCodes.NOT_JOIN,o));if(this.session.role_type===m.ENUM_ROLE_TYPE.pullStream)return o="role type is pull",p.default.warn("publish - ",o),void r(y.createError(y.ErrorCodes.ROLE_TYPE_NOT_MATCH,o));var i=this.streamManager.getAllLocalStreams().find((function(t){return t.mediaType===e.mediaType}));if(i){var a=void 0;switch(i.mediaType){case m.ENUM_MEDIA_TYPE.desktop:a="screen";break;case m.ENUM_MEDIA_TYPE.camera:default:a="camera"}return o="the stream with "+a+" type exists, only one "+a+" stream can be published",p.default.warn(o),void r(y.createError(y.ErrorCodes.STREAM_EXISTS,o))}var s,u=function(e){p.default.debug("publish success"),e.muteaudio&&n.muteAudioSync(e,e.muteaudio),e.mutevideo&&n.muteVideoSync(e,e.mutevideo),t(e)},d=function(t){p.default.warn("publish - ",t),n.logReporter.reportExceptionLog(c.ENUM_LOG_EXCEPTION_TYPE.publish,{stype:m.ENUM_STREAM_TYPE.publish,mtype:e.mediaType}),r(t)};try{s=this.streamManager.createLocalStream(this.user.user_id,e.config)}catch(o){return p.default.warn("publish - ",o),void d(o)}p.default.debug("create local stream ",s),s.video&&s.updateVP(),s.status=m.ENUM_PUBLISH_STATUS.publishing;var f=function(e){n.streamManager.removeLocalStream(s),d(e)};s.init({},e).then((function(){n.send("publish",{user_id:s.userId,media_type:s.mediaType,audio:s.audio,video:s.video,data:s.data,vp:s.vp,payload:s.videoCodec},u,f,s)})).catch(f)},e.prototype.republish=function(e){var t=this,r=e.convertToOuterStream();e.destroyConnection(),this.streamManager.destroyPlayer(e),p.default.debug("republish old stream ",r);this.send("publish",{user_id:e.userId,media_type:e.mediaType,audio:e.audio,video:e.video,data:e.data,vp:e.vp,payload:e.videoCodec},(function(n){var o=n.convertToOuterStream();p.default.debug("republish new stream ",o),function(e,r){e.audio&&e.muteaudio&&(t.send("mute",{user_id:r.userId,stream_id:r.streamId,stream_type:r.streamType,track_type:m.ENUM_TRACK_TYPE.audio,mute:!0},(function(){p.default.info("restore mute audio success after republish")}),(function(){p.default.warn("restore mute audio failure after republish")})),r.muteAudio()),e.video&&e.mutevideo&&(t.send("mute",{user_id:r.userId,stream_id:r.streamId,stream_type:r.streamType,track_type:m.ENUM_TRACK_TYPE.video,mute:!0},(function(){p.default.info("restore mute video success after republish")}),(function(){p.default.warn("restore mute video failure after republish")})),r.muteVideo())}(e,n),t._emitter&&t._emitter.emit("stream-reconnected",{previous:r,current:o})}),(function(e){p.default.debug("republish error",e)}),e)},e.prototype.onPublish=function(e,t,r,n){var o=this,i=e.stream_id,a=e.media_type;p.default.debug("onPublish ",i,a),this.logReporter.reportOperationLog(c.ENUM_LOG_OPERATION_TYPE.publish,{streamId:i,stype:n.streamType,mtype:n.mediaType});var s=function(e){p.default.info("rollback publish ",e),o._unpublish(n,(function(){p.default.info("rollback publish success"),r(e)}),(function(t){p.default.warn("rollback publish failed ",t),r(e)}))};n.status===m.ENUM_PUBLISH_STATUS.published&&(n.initConnection(),n.initMediaStream(),n.addTracks2PeerConnection()),n.connect(i).then((function(e){o.sdpPublish(n,e,(function(){t(n)}),s)})).catch(s)},e.prototype.muteAudioSync=function(e,t){this.send("mute",{user_id:e.userId,stream_id:e.streamId,stream_type:e.streamType,track_type:m.ENUM_TRACK_TYPE.audio,mute:t},(function(){p.default.info("mute audio sync success after publish")}),(function(){p.default.warn("mute audio sync failure after publish")}))},e.prototype.muteVideoSync=function(e,t){this.send("mute",{user_id:e.userId,stream_id:e.streamId,stream_type:e.streamType,track_type:m.ENUM_TRACK_TYPE.video,mute:t},(function(){p.default.info("mute video sync success after publish")}),(function(){p.default.warn("mute video sync failure after publish")}))},e.prototype.unpublish=function(e,t,r){var n,o=this,i=this.streamManager.getLocalStream(e);if(!i)return n="cannot find stream",void r(y.createError(y.ErrorCodes.STREAM_NOT_EXISTS,n));if(!i.canUnPublish)return n="the stream cannot unpublish",void r(y.createError(y.ErrorCodes.OTHERS,n));if(i.connectionState===s.ENUM_STREAM_CONNECTION_STATE.disconnected)return this.streamManager.removeLocalStream(i),void t(i.convertToOuterStream());i.status=m.ENUM_PUBLISH_STATUS.unpublishing,this.send("unpublish",{user_id:i.userId,stream_id:i.streamId,media_type:i.mediaType},(function(){o.streamManager.removeLocalStream(i),p.default.debug("unpublish success "),t(i.convertToOuterStream())}),(function(e){p.default.error("unpublish ",e),i.status=m.ENUM_PUBLISH_STATUS.published,r(e)}),i)},e.prototype.unpublishStream=function(e,t,r){this.send("unpublish",{user_id:e.userId,stream_id:e.streamId,media_type:e.mediaType},(function(){p.default.debug("unpublish success "),t(e)}),(function(t){p.default.error("unpublish ",t),e.status=m.ENUM_PUBLISH_STATUS.published,r(t)}),e)},e.prototype._unpublish=function(e,t,r){var n=this;this.send("unpublish",{user_id:e.userId,stream_id:e.streamId,media_type:e.mediaType},(function(){n.logReporter.reportOperationLog(c.ENUM_LOG_OPERATION_TYPE.unpublish,{streamId:e.streamId,stype:e.streamType,mtype:e.mediaType}),t()}),(function(e){r(y.createError(y.ErrorCodes.SERVER_API,e))}))},e.prototype.onUnpublish=function(e,t,r,n){p.default.debug("onUnpublish ",e),p.default.debug("onUnpublish placeholder ",r),n?(this.logReporter.reportOperationLog(c.ENUM_LOG_OPERATION_TYPE.unpublish,{streamId:n.streamId,stype:n.streamType,mtype:n.mediaType}),t()):t()},e.prototype.subscribe=function(e,t,r){var n=this,o="";if(!this.isJoinedRoom)return o="you have not joined the room",p.default.warn(o),void r(y.createError(y.ErrorCodes.NOT_JOIN,o));var i=this.streamManager.getRemoteStream(e);if(p.default.debug("subscribe - ",e,i),!i)return o="stream - "+e+" is not found",p.default.warn(o),void r(y.createError(y.ErrorCodes.STREAM_NOT_EXISTS,o));if(!i.canSubscribe)return o="the stream cannot be subscribed",p.default.warn(o),void r(y.createError(y.ErrorCodes.OTHERS,o));i.status=m.ENUM_SUBSCRIBE_STATUS.subscribing,this.send("subscribe",{src:{user_id:this.user.user_id,audio:i.audio,video:i.video,data:i.data},dst:{user_id:i.userId,stream_id:i.streamId,media_type:i.mediaType}},(function(e){p.default.debug("subscribe success "),t(e.convertToOuterStream())}),(function(e){p.default.debug("subscribe - ",e),i.status=m.ENUM_SUBSCRIBE_STATUS.unsubscribe,n.logReporter.reportExceptionLog(c.ENUM_LOG_EXCEPTION_TYPE.subscribe,{userId:i.userId,streamId:i.streamId,stype:i.streamType,mtype:i.mediaType}),r(e)}),i)},e.prototype.resubscribe=function(e){var t=this,r=e.convertToOuterStream();e.destroyMediaStream(),e.destroyConnection(),this.streamManager.destroyPlayer(e),p.default.debug("resubscribe old stream ",r);this.send("subscribe",{src:{user_id:this.user.user_id,audio:e.audio,video:e.video,data:e.data},dst:{user_id:e.userId,stream_id:e.streamId,media_type:e.mediaType}},(function(e){var n=e.convertToOuterStream();p.default.debug("resubscribe new stream ",n),t._emitter&&t._emitter.emit("stream-reconnected",{previous:r,current:n})}),(function(r){p.default.debug("resubscribe error",r),t.streamManager.removeRemoteStream(e),t._emitter&&t._emitter.emit("stream-removed",e.convertToOuterStream())}),e)},e.prototype.onSubscribe=function(e,t,r,n){var o=this,i=e.streamsub_id,a=e.stream_id,s=e.media_type,u=e.user_id;p.default.debug("onSubscribe ",i,a,s,u),this.logReporter.reportOperationLog(c.ENUM_LOG_OPERATION_TYPE.subscribe,{streamId:n.streamId,userId:n.userId,stype:n.streamType,mtype:n.mediaType});var d=function(e){p.default.debug("rollback subscribe ",e),o._unsubscribe(o.user.user_id,n,(function(){p.default.info("rollback subscribe success"),n.close(),r(y.createError(y.ErrorCodes.SERVER_API,e))}),(function(e){p.default.warn("rollback subscribe failed ",e),n.close(),r(y.createError(y.ErrorCodes.SERVER_API,e))}))};n.initConnection(),n.initMediaStream(),n.handlePeerConnectionTrackEvent(),n.connect(i).then((function(e){o.sdpSubscribe(n,e,(function(){t(n)}),d)})).catch(d)},e.prototype.unsubscribe=function(e,t,r){var n="",o=this.streamManager.getRemoteStream(e);if(!o)return n="stream is not found",p.default.warn(n),void r(n);if(p.default.debug("unsubscribe ",e,o),!o.canUnSubscribe)return n="the stream cannot be unsubscribed",p.default.warn(n),void r(n);o.status=m.ENUM_SUBSCRIBE_STATUS.unsubscribing,this.send("unsubscribe",{src:{user_id:this.user.user_id,streamsub_id:o.streamSubId},dst:{user_id:o.userId,stream_id:o.streamId,media_type:o.mediaType}},(function(){p.default.debug("unsubscribe success"),t(o.convertToOuterStream())}),(function(e){p.default.debug("unsubscribe - ",e),o.status=m.ENUM_SUBSCRIBE_STATUS.subscribed,r(e)}),o)},e.prototype._unsubscribe=function(e,t,r,n){var o=this;this.send("unsubscribe",{src:{user_id:e,streamsub_id:t.streamSubId},dst:{user_id:t.userId,stream_id:t.streamId,media_type:t.mediaType}},(function(){o.logReporter.reportOperationLog(c.ENUM_LOG_OPERATION_TYPE.unsubscribe,{streamId:t.streamId,userId:t.userId,stype:t.streamType,mtype:t.mediaType}),r()}),n)},e.prototype.onUnsubscribe=function(e,t,r,n){var o=e.user_id,i=e.media_type;p.default.debug("onUnsubscribe ",o,i,n),p.default.debug("onUnsubscribe placeholder ",r),n?(this.logReporter.reportOperationLog(c.ENUM_LOG_OPERATION_TYPE.unsubscribe,{streamId:n.streamId,userId:n.userId,stype:n.streamType,mtype:n.mediaType}),n.close(),t()):t()},e.prototype.sdpPublish=function(e,t,r,n){p.default.debug("sdpPublish ",e,t);this.send("sdp",{src:{user_id:e.userId,stream_id:e.streamId,stream_type:e.streamType,media_type:e.mediaType},sdp:{type:"offer",sdpcontent:t.sdp,minbitrate:e.minVideoBitRate,maxbitrate:e.maxVideoBitRate}},(function(){p.default.debug("sdpPublish"),r()}),(function(e){p.default.error("sdpPublish - ",e),n(y.createError(y.ErrorCodes.SERVER_API,e))}),e)},e.prototype.onSdpPublish=function(e,t,r,n){p.default.debug("onSdpPublish ",e);var o=e.sdp;n.answer(o).then((function(){p.default.debug("onSdpPublish"),t()})).catch((function(e){p.default.error("onSdpPublish - ",e),r(e)}))},e.prototype.sdpSubscribe=function(e,t,r,n){p.default.debug("sdpSubscribe ",e,t);this.send("sdp",{src:{user_id:this.user.user_id,stream_id:e.streamSubId,stream_type:e.streamType,media_type:e.mediaType},sdp:{type:"offer",sdpcontent:t.sdp}},(function(){p.default.debug("sdpSubscribe"),r()}),(function(e){p.default.debug("sdpSubscribe - ",e),n(e)}),e)},e.prototype.onSdpSubscribe=function(e,t,r,n){p.default.debug("onSdpSubscribe ",e);var o=e.sdp;n.answer(o).then((function(){p.default.debug("onSdpSubscribe"),n.status=m.ENUM_SUBSCRIBE_STATUS.subscribed,t()})).catch((function(e){p.default.debug("onSdpSubscribe - ",e),r(e)}))},e.prototype.muteVideo=function(e){var t=this,r=this.streamManager.getStream(e);if(!r){return p.default.warn("cannot find stream"),!1}var n=this.user.user_id,o=r.streamId;r.streamType===m.ENUM_STREAM_TYPE.subscribe&&(o=r.streamSubId);var i=function(){t.logReporter.reportOperationLog(c.ENUM_LOG_OPERATION_TYPE.muteVideo,{streamId:o,userId:n,stype:r.streamType,mtype:r.mediaType})},a=function(){r.unmuteVideo()},s=function(){t.send("mute",{user_id:n,stream_id:o,stream_type:r.streamType,track_type:m.ENUM_TRACK_TYPE.video,mute:!0},i,a)},u=300-(Date.now()-r.firstEmitTime);return!r.isSubscriber&&u>0?setTimeout(s,u):s(),r.muteVideo()},e.prototype.unmuteVideo=function(e){var t=this,r=this.streamManager.getStream(e);if(!r){return p.default.warn("cannot find stream"),!1}var n=this.user.user_id,o=r.streamId;r.streamType===m.ENUM_STREAM_TYPE.subscribe&&(o=r.streamSubId);return this.send("mute",{user_id:n,stream_id:o,stream_type:r.streamType,track_type:m.ENUM_TRACK_TYPE.video,mute:!1},(function(){t.logReporter.reportOperationLog(c.ENUM_LOG_OPERATION_TYPE.unmuteVideo,{streamId:o,userId:n,stype:r.streamType,mtype:r.mediaType})}),(function(){r.muteVideo()})),r.unmuteVideo()},e.prototype.muteAudio=function(e){var t=this,r=this.streamManager.getStream(e);if(!r){return p.default.warn("cannot find stream"),!1}var n=this.user.user_id,o=r.streamId;r.streamType===m.ENUM_STREAM_TYPE.subscribe&&(o=r.streamSubId);var i=function(){t.logReporter.reportOperationLog(c.ENUM_LOG_OPERATION_TYPE.muteAudio,{streamId:o,userId:n,stype:r.streamType,mtype:r.mediaType})},a=function(){r.unmuteAudio()},s=function(){t.send("mute",{user_id:n,stream_id:o,stream_type:r.streamType,track_type:m.ENUM_TRACK_TYPE.audio,mute:!0},i,a)},u=300-(Date.now()-r.firstEmitTime);return!r.isSubscriber&&u>0?setTimeout(s,u):s(),r.muteAudio()},e.prototype.unmuteAudio=function(e){var t=this,r=this.streamManager.getStream(e);if(!r){return p.default.warn("cannot find stream"),!1}var n=this.user.user_id,o=r.streamId;r.streamType===m.ENUM_STREAM_TYPE.subscribe&&(o=r.streamSubId);return this.send("mute",{user_id:n,stream_id:o,stream_type:r.streamType,track_type:m.ENUM_TRACK_TYPE.audio,mute:!1},(function(){t.logReporter.reportOperationLog(c.ENUM_LOG_OPERATION_TYPE.unmuteAudio,{streamId:o,userId:n,stype:r.streamType,mtype:r.mediaType})}),(function(){r.muteAudio()})),r.unmuteAudio()},e.prototype.muteData=function(){},e.prototype.unmuteData=function(){},e.prototype.startRecording=function(e,t,r){var n,o,i=this,a="";if(!(n=e.mixStreamUId===this.user.user_id?this.streamManager.getAllLocalStreams().find((function(t){return t.mediaType===e.mixStreamType})):this.streamManager.getAllRemoteStreams().find((function(t){return t.userId===e.mixStreamUId&&t.mediaType===e.mixStreamType})))){var s="cannot find corresponding stream";return p.default.warn(s),void r(y.createError(y.ErrorCodes.STREAM_NOT_EXISTS,s))}switch(this.recordStatus){case m.ENUM_RECORD_STATUS.starting:return a="record is starting",p.default.warn(a),void r(y.createError(y.ErrorCodes.OTHERS,a));case m.ENUM_RECORD_STATUS.stopping:return a="record is stopping",p.default.warn(a),void r(y.createError(y.ErrorCodes.OTHERS,a));case m.ENUM_RECORD_STATUS.recording:return a="is recording",p.default.warn(a),void r(y.createError(y.ErrorCodes.OTHERS,a));case m.ENUM_RECORD_STATUS.unrecord:}if(n.audio&&n.video)o=m.ENUM_RECORD_MIME.audioVideo;else if(n.audio)o=m.ENUM_RECORD_MIME.audio;else{if(!n.video)return a="stream config is incorrect",p.default.warn(a),void r(y.createError(y.ErrorCodes.OTHERS,a));o=m.ENUM_RECORD_MIME.video}var u=this.recordStreamType=n.streamType,d=this.recordMediaType=n.mediaType;this.recordStatus=m.ENUM_RECORD_STATUS.starting;var f={mimetype:o,mainviewuid:e.mixStreamUId,mainviewtype:e.mixStreamType,width:e.mixStreamWidth,height:e.mixStreamHeight,watermarkpos:e.waterMarkPos,watertype:e.waterMarkType,waterurl:e.waterMarkRemarks,wtemplate:e.mixStreamTemplate,isaverage:e.isAverage,bucket:e.bucket,region:e.region};e.isRelay?(f.isrelay=e.isRelay,f.time=e.relayTime,f.fragment=e.relayFragment):e.isrelay=e.isRelay,this.send("startrecord",{room_id:this.session.room_id,app_id:this.session.app_id,user_id:this.session.user_id,config:f},(function(e){p.default.debug("startRecording success",e),i.logReporter.reportOperationLog(c.ENUM_LOG_OPERATION_TYPE.startRecord,{recordId:e.RecordId,stype:u,mtype:d}),i.recordStatus=m.ENUM_RECORD_STATUS.recording,t({FileName:e.FileName,RecordId:e.RecordId})}),(function(e){p.default.error("startRecording - ",e),i.recordStatus=m.ENUM_RECORD_STATUS.unrecord,r(e)}))},e.prototype.onStartRecord=function(e,t){p.default.debug("onStartRecord ",e);var r=e.RecordId,n=e.FileName;this.recordId=r,t({RecordId:r,FileName:n})},e.prototype.stopRecording=function(e,t){var r=this,n="";switch(this.recordStatus){case m.ENUM_RECORD_STATUS.starting:return n="local stream record is starting",p.default.warn(n),void t(y.createError(y.ErrorCodes.OTHERS,n));case m.ENUM_RECORD_STATUS.stopping:return n="local stream record is stopping",p.default.warn(n),void t(y.createError(y.ErrorCodes.OTHERS,n));case m.ENUM_RECORD_STATUS.unrecord:return n="local stream isnot recording",p.default.warn(n),void t(y.createError(y.ErrorCodes.OTHERS,n));case m.ENUM_RECORD_STATUS.recording:}this.recordStatus=m.ENUM_RECORD_STATUS.stopping;var o=this.recordId,i=this.recordStreamType,a=this.recordMediaType;this.send("stoprecord",{room_id:this.session.room_id,app_id:this.session.app_id,user_id:this.session.user_id},(function(){p.default.debug("stopRecording success"),r.logReporter.reportOperationLog(c.ENUM_LOG_OPERATION_TYPE.stopRecord,{recordId:o,stype:i,mtype:a}),r.recordStatus=m.ENUM_RECORD_STATUS.unrecord,e()}),(function(e){p.default.debug("stopRecording - ",e),r.recordStatus=m.ENUM_RECORD_STATUS.recording,t(e)}))},e.prototype.onStopRecord=function(e,t){p.default.debug("onStopRecord ",e),this.recordId="",this.recordStreamType=m.ENUM_STREAM_TYPE.publish,this.recordMediaType=m.ENUM_MEDIA_TYPE.camera,t()},e.prototype.startMix=function(e,t,r,n){var o=this,i=m.ENUM_STREAM_TYPE.publish;i=r.mainviewuid&&r.mainviewuid===this.user.user_id?m.ENUM_STREAM_TYPE.subscribe:m.ENUM_STREAM_TYPE.publish;var a=m.ENUM_MEDIA_TYPE.camera;r.mainviewtype&&(a=r.mainviewtype),this.mixStream={streamType:i,mediaType:a};this.send("startmix",{type:e,app_id:this.session.app_id,room_id:this.session.room_id,user_id:this.session.user_id,streams:t||[],config:r},(function(t){switch(p.default.debug("startMix success",t),e){case m.ENUM_MIX_TYPE.relay:o.logReporter.reportOperationLog(c.ENUM_LOG_OPERATION_TYPE.startRelay,{recordId:t.MixId,stype:i,mtype:a});break;case m.ENUM_MIX_TYPE.record:o.logReporter.reportOperationLog(c.ENUM_LOG_OPERATION_TYPE.startRecord,{recordId:t.MixId,stype:i,mtype:a});break;case m.ENUM_MIX_TYPE.relayRecord:o.logReporter.reportOperationLog(c.ENUM_LOG_OPERATION_TYPE.startRelay,{recordId:t.MixId,stype:i,mtype:a}),o.logReporter.reportOperationLog(c.ENUM_LOG_OPERATION_TYPE.startRecord,{recordId:t.MixId,stype:i,mtype:a})}n(void 0,t)}),(function(t){switch(p.default.debug("startMix - "+t),e){case m.ENUM_MIX_TYPE.relay:o.logReporter.reportExceptionLog(c.ENUM_LOG_EXCEPTION_TYPE.relay,{msg:""+t});break;case m.ENUM_MIX_TYPE.record:o.logReporter.reportExceptionLog(c.ENUM_LOG_EXCEPTION_TYPE.record,{msg:""+t});break;case m.ENUM_MIX_TYPE.relayRecord:o.logReporter.reportExceptionLog(c.ENUM_LOG_EXCEPTION_TYPE.relay,{msg:""+t}),o.logReporter.reportExceptionLog(c.ENUM_LOG_EXCEPTION_TYPE.record,{msg:""+t})}n(t)}))},e.prototype.updateMix=function(e,t,r){var n={type:m.ENUM_MIX_TYPE.update,app_id:this.session.app_id,room_id:this.session.room_id,user_id:this.session.user_id,config:t};e.length>0&&(n.streams=e,n.config.layoutUserlimit=e.length),this.send("startmix",n,(function(e){p.default.debug("updateMix success",e),r(void 0,e)}),(function(e){p.default.debug("updateMix - "+e),r(e)}))},e.prototype.onStartMix=function(e,t){p.default.debug("onStartMix ",e),t({MixId:e.mix_id,FileName:e.filename})},e.prototype.stopMix=function(e,t,r){var n=this;this.send("stopmix",{type:e,pushurl:t,app_id:this.session.app_id,room_id:this.session.room_id,user_id:this.session.user_id},(function(t){p.default.debug("stopMix success");var o=n.mixStream||{},i=o.streamType,a=o.mediaType,s=t.MixId;switch(e){case m.ENUM_MIX_TYPE.relay:n.logReporter.reportOperationLog(c.ENUM_LOG_OPERATION_TYPE.stopRelay,{recordId:s,stype:i,mtype:a});break;case m.ENUM_MIX_TYPE.record:n.logReporter.reportOperationLog(c.ENUM_LOG_OPERATION_TYPE.stopRecord,{recordId:s,stype:i,mtype:a});break;case m.ENUM_MIX_TYPE.relayRecord:n.logReporter.reportOperationLog(c.ENUM_LOG_OPERATION_TYPE.stopRelay,{recordId:s,stype:i,mtype:a}),n.logReporter.reportOperationLog(c.ENUM_LOG_OPERATION_TYPE.stopRecord,{recordId:s,stype:i,mtype:a})}r(void 0,t)}),(function(e){p.default.warn("stopMix - "+e),n.logReporter.reportExceptionLog(c.ENUM_LOG_EXCEPTION_TYPE.others,{msg:"stopMix - "+e}),r(e)}))},e.prototype.onStopMix=function(e,t){p.default.debug("onStopMix ",e);var r=e.mix_id,n=void 0===r?"":r,o=e.pushurl,i=void 0===o?[]:o;t({MixId:n,PushURL:i=i||[]})},e.prototype.queryMix=function(e){this.send("queymix",{app_id:this.session.app_id,room_id:this.session.room_id,user_id:this.session.user_id},(function(t){p.default.debug("queryMix success"),e(void 0,t)}),(function(t){p.default.error("queryMix - "+t),e(t)}))},e.prototype.onQueryMix=function(e,t){if(p.default.debug("onQueryMix ",e),e){var r,n=e.type,o=e.mix_id,i=e.filename;switch(n){case m.ENUM_MIX_TYPE.relay:r="relay";break;case m.ENUM_MIX_TYPE.relayRecord:r="relay-and-record";break;case m.ENUM_MIX_TYPE.record:default:r="record"}t({Type:r,MixId:o,FileName:i})}else t({MixId:void 0})},e.prototype.addMixStreams=function(e,t){this.send("addmixstream",{app_id:this.session.app_id,room_id:this.session.room_id,user_id:this.session.user_id,streams:e||[]},(function(e){p.default.debug("addMixStreams success",e),t(void 0,e)}),(function(e){p.default.error("addMixStreams - "+e),t(e)}))},e.prototype.onAddMixStreams=function(e,t){t({MixId:e.mix_id})},e.prototype.removeMixStreams=function(e,t){this.send("delmixstream",{app_id:this.session.app_id,room_id:this.session.room_id,user_id:this.session.user_id,streams:e||[]},(function(e){p.default.debug("removeMixStreams success",e),t(void 0,e)}),(function(e){p.default.error("removeMixStreams - "+e),t(e)}))},e.prototype.onRemoveMixStreams=function(e,t){t({MixId:e.mix_id})},e.prototype.onError=function(e){p.default.warn("onError - method: "+e.method+", code: "+e.code+", msg: "+e.msg)},e.prototype.onUserJoin=function(e){var t=e.user_id,r=e.cmdtype,n=e.reason;if(p.default.debug("onUserJoin ",t,r,n),!this.users.find((function(e){return e.user_id===t}))){var o={user_id:t};this.users.push(o),this._emitter&&this._emitter.emit("user-added",h.convertToOuterUser(o))}},e.prototype.onUserLeave=function(e){var t=e.user_id,r=e.cmdtype,n=e.reason;p.default.debug("onUserLeave ",t,r,n);var o=this.users.findIndex((function(e){return e.user_id===t}));if(o>=0){var i=this.users[o];this.users.splice(o,1),this._emitter&&this._emitter.emit("user-removed",h.convertToOuterUser(i))}},e.prototype.onAddStream=function(e){var t=e.user_id,r=e.cmdtype,n=e.stream;if(p.default.debug("onAddStream ",t,r,n),!this.users.find((function(e){return e.user_id===t}))){var o={user_id:t};this.users.push(o),this._emitter&&this._emitter.emit("user-added",h.convertToOuterUser(o))}var i=Object.assign({uid:t},n),a=this.streamManager.getAllRemoteStreams().find((function(e){return e.userId===i.uid&&i.media_type===e.mediaType}));a&&(this.streamManager.removeRemoteStream(a),this._emitter&&this._emitter.emit("stream-removed",a.convertToOuterStream()));var s=this.streamManager.createRemoteStream(i);s&&this._emitter&&this._emitter.emit("stream-added",s.convertToOuterStream())},e.prototype.onRemoveStream=function(e){var t=e.user_id,r=e.stream;p.default.debug("onRemoveStream ",t,r);var n=this.streamManager.getRemoteStream(r.sid);if(n)this.streamManager.removeRemoteStream(n),this._emitter&&this._emitter.emit("stream-removed",n.convertToOuterStream());else{var o="stream "+r.sid+" is not found";p.default.debug("onRemoveStream - ",o)}},e.prototype.onTransportClose=function(e){var t=e.user_id,r=e.stream;p.default.debug("onTransportClose ",t,r),t===this.user.user_id||this.onRemoveStream({user_id:t,stream:r})},e.prototype.onTransportTimeout=function(e){p.default.debug("onTransportTimeout",e);var t=e.user_id,r=e.stream;t===this.user.user_id||this.onRemoveStream({user_id:t,stream:r})},e.prototype.onAudioTrackst=function(e){var t=e.user_id,r=e.stream_id,n=e.mute,o=e.track_type,i=e.media_type;p.default.debug("onAudioTrackst ",t,r,n,o,i);var a=this.streamManager.getRemoteStream(r);if(a)n?(a.muteAudio(),this._emitter&&this._emitter.emit("mute-audio",a.convertToOuterStream())):(a.unmuteAudio(),this._emitter&&this._emitter.emit("unmute-audio",a.convertToOuterStream()));else{var s="stream "+r+" is not found";p.default.warn("onAudioTrackst - ",s)}},e.prototype.onVideoTrackst=function(e){var t=e.user_id,r=e.stream_id,n=e.mute,o=e.track_type,i=e.media_type;p.default.debug("onVideoTrackst ",t,r,n,o,i);var a=this.streamManager.getRemoteStream(r);if(a)n?(a.muteVideo(),this._emitter&&this._emitter.emit("mute-video",a.convertToOuterStream())):(a.unmuteVideo(),this._emitter&&this._emitter.emit("unmute-video",a.convertToOuterStream()));else{var s="stream "+r+" is not found";p.default.warn("onVideoTrackst - ",s)}},e.prototype.onDataTrackst=function(e){var t=e.user_id,r=e.stream_id,n=e.mute,o=e.track_type,i=e.media_type;p.default.debug("onDataTrackst ",t,r,n,o,i);var a=this.streamManager.getRemoteStream(r);if(a)n?this._emitter&&this._emitter.emit("mute-data",a.convertToOuterStream()):this._emitter&&this._emitter.emit("unmute-data",a.convertToOuterStream());else{var s="stream "+r+" is not found";p.default.warn("onDataTrackst - ",s)}},e.prototype.onKickoff=function(e){this.disconnect("kick off"),this.destroy(),this._emitter&&this._emitter.emit("kick-off",e)},e.prototype.onMixNotify=function(e,t,r){var n;switch(e){case 24149:case 24150:case 24152:n=y.createError(""+e,t)}var o={code:""+e,message:""+t};r.filename?(n&&this.logReporter.reportExceptionLog(c.ENUM_LOG_EXCEPTION_TYPE.record,{msg:e+" "+t}),this._emitter&&this._emitter.emit("record-notify",o)):r.pushurl&&r.pushurl.length>0&&(n&&this.logReporter.reportExceptionLog(c.ENUM_LOG_EXCEPTION_TYPE.relay,{msg:e+" "+t}),this._emitter&&this._emitter.emit("relay-notify",o))},e.prototype.onMediaStreamPublished=function(e){this._emitter&&this._emitter.emit("stream-published",e.convertToOuterStream())},e.prototype.onMediaStreamSubscribed=function(e){this._emitter&&this._emitter.emit("stream-subscribed",e.convertToOuterStream())},e.prototype.onScreenMediaStreamEnded=function(e){this._emitter&&this._emitter.emit("screenshare-stopped",e.convertToOuterStream())},e.prototype.onStreamConnectionClosed=function(e){var t;p.default.debug("stream peerconnection closed ",e),(null===(t=this.socketManager)||void 0===t?void 0:t.isOpened)&&(e.isSubscriber?this.resubscribe(e):this.republish(e))},e.prototype.onStreamConnectionReconnecting=function(e){p.default.debug("stream peerconnection reconnecting ",e)},e.prototype.onStreamConnectionReconnected=function(e){p.default.debug("stream peerconnection reconnected ",e)},e.prototype.onStreamConnectionDisconnected=function(e){var t;p.default.debug("stream peerconnection disconnected ",e),null===(t=this.socketManager)||void 0===t||t.heartBeat()},e.prototype.enableAudioVolumeIndicator=function(e){var t=this;this.audioVolumeIndicator||(this.audioVolumeIndicator=new E.default(this.streamManager,e)),this.audioVolumeIndicator.start((function(e){var r;null===(r=t._emitter)||void 0===r||r.emit("volume-indicator",e)}),e)},e}();t.SessionManager=S},function(e,t,r){"use strict";var n=r(1),o=r(22),i=r(51),a=r(28);function s(e){var t=new i(e),r=o(i.prototype.request,t);return n.extend(r,i.prototype,t),n.extend(r,t),r}var c=s(r(25));c.Axios=i,c.create=function(e){return s(a(c.defaults,e))},c.Cancel=r(29),c.CancelToken=r(63),c.isCancel=r(24),c.all=function(e){return Promise.all(e)},c.spread=r(64),e.exports=c,e.exports.default=c},function(e,t){
- /*!
- * Determine if an object is a Buffer
- *
- * @author Feross Aboukhadijeh <https://feross.org>
- * @license MIT
- */
- e.exports=function(e){return null!=e&&null!=e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)}},function(e,t,r){"use strict";var n=r(1),o=r(23),i=r(52),a=r(53),s=r(28);function c(e){this.defaults=e,this.interceptors={request:new i,response:new i}}c.prototype.request=function(e){"string"==typeof e?(e=arguments[1]||{}).url=arguments[0]:e=e||{},(e=s(this.defaults,e)).method=e.method?e.method.toLowerCase():"get";var t=[a,void 0],r=Promise.resolve(e);for(this.interceptors.request.forEach((function(e){t.unshift(e.fulfilled,e.rejected)})),this.interceptors.response.forEach((function(e){t.push(e.fulfilled,e.rejected)}));t.length;)r=r.then(t.shift(),t.shift());return r},c.prototype.getUri=function(e){return e=s(this.defaults,e),o(e.url,e.params,e.paramsSerializer).replace(/^\?/,"")},n.forEach(["delete","get","head","options"],(function(e){c.prototype[e]=function(t,r){return this.request(n.merge(r||{},{method:e,url:t}))}})),n.forEach(["post","put","patch"],(function(e){c.prototype[e]=function(t,r,o){return this.request(n.merge(o||{},{method:e,url:t,data:r}))}})),e.exports=c},function(e,t,r){"use strict";var n=r(1);function o(){this.handlers=[]}o.prototype.use=function(e,t){return this.handlers.push({fulfilled:e,rejected:t}),this.handlers.length-1},o.prototype.eject=function(e){this.handlers[e]&&(this.handlers[e]=null)},o.prototype.forEach=function(e){n.forEach(this.handlers,(function(t){null!==t&&e(t)}))},e.exports=o},function(e,t,r){"use strict";var n=r(1),o=r(54),i=r(24),a=r(25),s=r(61),c=r(62);function u(e){e.cancelToken&&e.cancelToken.throwIfRequested()}e.exports=function(e){return u(e),e.baseURL&&!s(e.url)&&(e.url=c(e.baseURL,e.url)),e.headers=e.headers||{},e.data=o(e.data,e.headers,e.transformRequest),e.headers=n.merge(e.headers.common||{},e.headers[e.method]||{},e.headers||{}),n.forEach(["delete","get","head","post","put","patch","common"],(function(t){delete e.headers[t]})),(e.adapter||a.adapter)(e).then((function(t){return u(e),t.data=o(t.data,t.headers,e.transformResponse),t}),(function(t){return i(t)||(u(e),t&&t.response&&(t.response.data=o(t.response.data,t.response.headers,e.transformResponse))),Promise.reject(t)}))}},function(e,t,r){"use strict";var n=r(1);e.exports=function(e,t,r){return n.forEach(r,(function(r){e=r(e,t)})),e}},function(e,t,r){"use strict";var n=r(1);e.exports=function(e,t){n.forEach(e,(function(r,n){n!==t&&n.toUpperCase()===t.toUpperCase()&&(e[t]=r,delete e[n])}))}},function(e,t,r){"use strict";var n=r(27);e.exports=function(e,t,r){var o=r.config.validateStatus;!o||o(r.status)?e(r):t(n("Request failed with status code "+r.status,r.config,null,r.request,r))}},function(e,t,r){"use strict";e.exports=function(e,t,r,n,o){return e.config=t,r&&(e.code=r),e.request=n,e.response=o,e.isAxiosError=!0,e.toJSON=function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:this.config,code:this.code}},e}},function(e,t,r){"use strict";var n=r(1),o=["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"];e.exports=function(e){var t,r,i,a={};return e?(n.forEach(e.split("\n"),(function(e){if(i=e.indexOf(":"),t=n.trim(e.substr(0,i)).toLowerCase(),r=n.trim(e.substr(i+1)),t){if(a[t]&&o.indexOf(t)>=0)return;a[t]="set-cookie"===t?(a[t]?a[t]:[]).concat([r]):a[t]?a[t]+", "+r:r}})),a):a}},function(e,t,r){"use strict";var n=r(1);e.exports=n.isStandardBrowserEnv()?function(){var e,t=/(msie|trident)/i.test(navigator.userAgent),r=document.createElement("a");function o(e){var n=e;return t&&(r.setAttribute("href",n),n=r.href),r.setAttribute("href",n),{href:r.href,protocol:r.protocol?r.protocol.replace(/:$/,""):"",host:r.host,search:r.search?r.search.replace(/^\?/,""):"",hash:r.hash?r.hash.replace(/^#/,""):"",hostname:r.hostname,port:r.port,pathname:"/"===r.pathname.charAt(0)?r.pathname:"/"+r.pathname}}return e=o(window.location.href),function(t){var r=n.isString(t)?o(t):t;return r.protocol===e.protocol&&r.host===e.host}}():function(){return!0}},function(e,t,r){"use strict";var n=r(1);e.exports=n.isStandardBrowserEnv()?{write:function(e,t,r,o,i,a){var s=[];s.push(e+"="+encodeURIComponent(t)),n.isNumber(r)&&s.push("expires="+new Date(r).toGMTString()),n.isString(o)&&s.push("path="+o),n.isString(i)&&s.push("domain="+i),!0===a&&s.push("secure"),document.cookie=s.join("; ")},read:function(e){var t=document.cookie.match(new RegExp("(^|;\\s*)("+e+")=([^;]*)"));return t?decodeURIComponent(t[3]):null},remove:function(e){this.write(e,"",Date.now()-864e5)}}:{write:function(){},read:function(){return null},remove:function(){}}},function(e,t,r){"use strict";e.exports=function(e){return/^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(e)}},function(e,t,r){"use strict";e.exports=function(e,t){return t?e.replace(/\/+$/,"")+"/"+t.replace(/^\/+/,""):e}},function(e,t,r){"use strict";var n=r(29);function o(e){if("function"!=typeof e)throw new TypeError("executor must be a function.");var t;this.promise=new Promise((function(e){t=e}));var r=this;e((function(e){r.reason||(r.reason=new n(e),t(r.reason))}))}o.prototype.throwIfRequested=function(){if(this.reason)throw this.reason},o.source=function(){var e;return{token:new o((function(t){e=t})),cancel:e}},e.exports=o},function(e,t,r){"use strict";e.exports=function(e){return function(t){return e.apply(null,t)}}},function(e,t,r){var n=r(66)("jsonp");e.exports=function(e,t,r){"function"==typeof t&&(r=t,t={});t||(t={});var a,s,c=t.prefix||"__jp",u=t.name||c+o++,d=t.param||"callback",p=null!=t.timeout?t.timeout:6e4,f=encodeURIComponent,l=document.getElementsByTagName("script")[0]||document.head;p&&(s=setTimeout((function(){m(),r&&r(new Error("Timeout"))}),p));function m(){a.parentNode&&a.parentNode.removeChild(a),window[u]=i,s&&clearTimeout(s)}return window[u]=function(e){n("jsonp got",e),m(),r&&r(null,e)},e=(e+=(~e.indexOf("?")?"&":"?")+d+"="+f(u)).replace("?&","?"),n('jsonp req "%s"',e),(a=document.createElement("script")).src=e,l.parentNode.insertBefore(a,l),function(){window[u]&&m()}};var o=0;function i(){}},function(e,t,r){(function(n){function o(){var e;try{e=t.storage.debug}catch(e){}return!e&&void 0!==n&&"env"in n&&(e=n.env.DEBUG),e}(t=e.exports=r(67)).log=function(){return"object"==typeof console&&console.log&&Function.prototype.apply.call(console.log,console,arguments)},t.formatArgs=function(e){var r=this.useColors;if(e[0]=(r?"%c":"")+this.namespace+(r?" %c":" ")+e[0]+(r?"%c ":" ")+"+"+t.humanize(this.diff),!r)return;var n="color: "+this.color;e.splice(1,0,n,"color: inherit");var o=0,i=0;e[0].replace(/%[a-zA-Z%]/g,(function(e){"%%"!==e&&(o++,"%c"===e&&(i=o))})),e.splice(i,0,n)},t.save=function(e){try{null==e?t.storage.removeItem("debug"):t.storage.debug=e}catch(e){}},t.load=o,t.useColors=function(){if("undefined"!=typeof window&&window.process&&"renderer"===window.process.type)return!0;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+)/)},t.storage="undefined"!=typeof chrome&&void 0!==chrome.storage?chrome.storage.local:function(){try{return window.localStorage}catch(e){}}(),t.colors=["lightseagreen","forestgreen","goldenrod","dodgerblue","darkorchid","crimson"],t.formatters.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}},t.enable(o())}).call(this,r(11))},function(e,t,r){var n;function o(e){function r(){if(r.enabled){var e=r,o=+new Date,i=o-(n||o);e.diff=i,e.prev=n,e.curr=o,n=o;for(var a=new Array(arguments.length),s=0;s<a.length;s++)a[s]=arguments[s];a[0]=t.coerce(a[0]),"string"!=typeof a[0]&&a.unshift("%O");var c=0;a[0]=a[0].replace(/%([a-zA-Z%])/g,(function(r,n){if("%%"===r)return r;c++;var o=t.formatters[n];if("function"==typeof o){var i=a[c];r=o.call(e,i),a.splice(c,1),c--}return r})),t.formatArgs.call(e,a),(r.log||t.log||console.log.bind(console)).apply(e,a)}}return r.namespace=e,r.enabled=t.enabled(e),r.useColors=t.useColors(),r.color=function(e){var r,n=0;for(r in e)n=(n<<5)-n+e.charCodeAt(r),n|=0;return t.colors[Math.abs(n)%t.colors.length]}(e),"function"==typeof t.init&&t.init(r),r}(t=e.exports=o.debug=o.default=o).coerce=function(e){return e instanceof Error?e.stack||e.message:e},t.disable=function(){t.enable("")},t.enable=function(e){t.save(e),t.names=[],t.skips=[];for(var r=("string"==typeof e?e:"").split(/[\s,]+/),n=r.length,o=0;o<n;o++)r[o]&&("-"===(e=r[o].replace(/\*/g,".*?"))[0]?t.skips.push(new RegExp("^"+e.substr(1)+"$")):t.names.push(new RegExp("^"+e+"$")))},t.enabled=function(e){var r,n;for(r=0,n=t.skips.length;r<n;r++)if(t.skips[r].test(e))return!1;for(r=0,n=t.names.length;r<n;r++)if(t.names[r].test(e))return!0;return!1},t.humanize=r(68),t.names=[],t.skips=[],t.formatters={}},function(e,t){var r=1e3,n=60*r,o=60*n,i=24*o,a=365.25*i;function s(e,t,r){if(!(e<t))return e<1.5*t?Math.floor(e/t)+" "+r:Math.ceil(e/t)+" "+r+"s"}e.exports=function(e,t){t=t||{};var c,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 s=parseFloat(t[1]);switch((t[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return s*a;case"days":case"day":case"d":return s*i;case"hours":case"hour":case"hrs":case"hr":case"h":return s*o;case"minutes":case"minute":case"mins":case"min":case"m":return s*n;case"seconds":case"second":case"secs":case"sec":case"s":return s*r;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return s;default:return}}(e);if("number"===u&&!1===isNaN(e))return t.long?s(c=e,i,"day")||s(c,o,"hour")||s(c,n,"minute")||s(c,r,"second")||c+" ms":function(e){if(e>=i)return Math.round(e/i)+"d";if(e>=o)return Math.round(e/o)+"h";if(e>=n)return Math.round(e/n)+"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))}},function(e,t,r){"use strict";e.exports=function(e,t){if(t=t.split(":")[0],!(e=+e))return!1;switch(t){case"http":case"ws":return 80!==e;case"https":case"wss":return 443!==e;case"ftp":return 21!==e;case"gopher":return 70!==e;case"file":return!1}return 0!==e}},function(e,t,r){"use strict";var n,o=Object.prototype.hasOwnProperty;function i(e){try{return decodeURIComponent(e.replace(/\+/g," "))}catch(e){return null}}t.stringify=function(e,t){t=t||"";var r,i,a=[];for(i in"string"!=typeof t&&(t="?"),e)if(o.call(e,i)){if((r=e[i])||null!==r&&r!==n&&!isNaN(r)||(r=""),i=encodeURIComponent(i),r=encodeURIComponent(r),null===i||null===r)continue;a.push(i+"="+r)}return a.length?t+a.join("&"):""},t.parse=function(e){for(var t,r=/([^=?&]+)=?([^&]*)/g,n={};t=r.exec(e);){var o=i(t[1]),a=i(t[2]);null===o||null===a||o in n||(n[o]=a)}return n}},function(e,t,r){"use strict";(function(e){Object.defineProperty(t,"__esModule",{value:!0});var n=r(72),o=r(0),i=r(31),a=r(3),s=function(){function t(e){this.readyState=n.w3cwebsocket.CLOSED,this.BEATTIM=6e4,this.pingTimeout=0,this.retry=0,this.signalManager=e}return t.prototype.init=function(e,t,r){var n=this;this.messageCb=e,this.stateChangeCb=t,this.errorCb=r,this.signalManager.on("change-signal",(function(e,t){o.default.debug("change signal "+e.wss+" => "+t.wss),e&&(e.status=i.SignalStatus.unconnected),n.reconnect()}))},t.prototype.initHeartBeat=function(e,t){this.getHeartBeatData=e,t&&(this.BEATTIM=t)},t.prototype.startHeartBeat=function(){var e=this;o.default.debug("socket manager - start head beat"),this.keepAlive&&window.clearInterval(this.keepAlive),this.getHeartBeatData&&(this.keepAlive=window.setInterval((function(){e.heartBeat()}),this.BEATTIM))},t.prototype.heartBeat=function(){var e=this;if(this.getHeartBeatData&&this.readyState===n.w3cwebsocket.OPEN){this.pingTimeout||(this.pingTimeout=window.setTimeout((function(){e.pingTimeout=0,e.stopHeartBeat(),e.onStateChanged(e.readyState,n.w3cwebsocket.CLOSED),e.readyState=n.w3cwebsocket.CLOSED,e.reconnect()}),1e4));var t=this.getHeartBeatData();this.send(t).catch((function(e){o.default.warn("head beat ",e)}))}},t.prototype.stopHeartBeat=function(){o.default.debug("socket manager - stop head beat"),this.keepAlive&&window.clearInterval(this.keepAlive)},t.prototype.destroy=function(){this.stopHeartBeat(),this.messageCb=void 0,this.stateChangeCb=void 0,this.errorCb=void 0,this.retry&&(window.clearInterval(this.retry),this.retry=0)},t.prototype.connect=function(e){var t=this;return o.default.debug("socket manager - connect ",this.readyState,e),new Promise((function(r,s){if(e||t.signalManager.current){t.readyState=n.w3cwebsocket.CLOSED;var c=t.signalManager.current,u=!0;try{t._websocket=new n.w3cwebsocket(e||c.wss),c.status=i.SignalStatus.connecting}catch(e){return o.default.debug("socket manager - connect error ",e),void s(a.createError(a.ErrorCodes.OTHERS,"Create Socket Error"))}t.onconnecting(t.readyState,n.w3cwebsocket.CONNECTING),t.readyState=n.w3cwebsocket.CONNECTING,t._websocket.onopen=function(){var e=t.readyState;t.readyState=n.w3cwebsocket.OPEN,c.status=i.SignalStatus.connected,t.onopened(e,n.w3cwebsocket.OPEN),u&&(u=!1,r("opened"))},t._websocket.onclose=function(){o.default.debug("socket manager - onclose ",t.readyState);var e=t.readyState;t.readyState=n.w3cwebsocket.CLOSED,c.status=i.SignalStatus.unconnected,t.onclosed(e,n.w3cwebsocket.CLOSED)},t._websocket.onmessage=function(e){t.pingTimeout&&(window.clearTimeout(t.pingTimeout),t.pingTimeout=0),t.onmessage(e)},t._websocket.onerror=function(e){var r;o.default.debug("socket manager - onerror ",e),o.default.debug("socket manager - onerror state ",t.readyState,null===(r=t._websocket)||void 0===r?void 0:r.readyState),u?(u=!1,s(a.createError(a.ErrorCodes.OTHERS,"connection error"))):t.onerror("connection error")}}else s(a.createError(a.ErrorCodes.OTHERS,"signal is blank"))}))},t.prototype.onmessage=function(e){this.messageCb&&this.messageCb(e)},t.prototype.onStateChanged=function(e,t){function r(e){var t="CLOSED";switch(e){case n.w3cwebsocket.OPEN:t="OPEN";break;case n.w3cwebsocket.CONNECTING:t="CONNECTING";break;case n.w3cwebsocket.CLOSING:t="CLOSING";break;case n.w3cwebsocket.CLOSED:t="CLOSED"}return t}var i=r(e),a=r(t);o.default.debug("socket manager - onStateChanged ",i,a),this.stateChangeCb&&this.stateChangeCb(i,a)},t.prototype.onconnecting=function(e,t){o.default.debug("socket manager - onconnecting ",e,t),this.onStateChanged(e,t)},t.prototype.onopened=function(e,t){o.default.debug("socket manager - onopened ",e,t),this.startHeartBeat(),this.onStateChanged(e,t)},t.prototype.ondisconnecting=function(e,t){o.default.debug("socket manager - ondisconnecting ",e,t),this.onStateChanged(e,t)},t.prototype.onclosed=function(t,r){var i=this;o.default.debug("socket manager - onclosed ",t,r),this.stopHeartBeat(),this.onStateChanged(t,r),t===n.w3cwebsocket.OPEN&&e((function(){o.default.warn("connection is closed - reconnecting..."),i.reconnect()}))},t.prototype.onerror=function(e){o.default.debug("socket manager - onerror ",e),this.errorCb&&this.errorCb(e)},t.prototype.send=function(e){var t=this;return new Promise((function(r,n){var o;t.isOpened?(null===(o=t._websocket)||void 0===o||o.send(e),r()):n(a.createError(a.ErrorCodes.OTHERS,"connection isnot open"))}))},t.prototype.close=function(e,t){var r=this;return void 0===e&&(e=1e3),o.default.debug("socket manager - close ",this.readyState),this.ondisconnecting(this.readyState,n.w3cwebsocket.CLOSING),this.readyState=n.w3cwebsocket.CLOSING,new Promise((function(n,o){r._websocket?(r._websocket.close(e,t),n()):o(a.createError(a.ErrorCodes.OTHERS,"no socket connection"))}))},Object.defineProperty(t.prototype,"isOpened",{get:function(){return this.readyState===n.w3cwebsocket.OPEN},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"isClosed",{get:function(){return this.readyState===n.w3cwebsocket.CLOSED},enumerable:!0,configurable:!0}),t.prototype.reconnect=function(){var e=this;if(o.default.debug("socket manager - reconnect ",this.readyState),this._websocket){var t=this._websocket,r=function(){};this._websocket.onopen=r,this._websocket.onclose=r,this._websocket.onmessage=r,this._websocket.onerror=r,this._websocket=void 0;try{t.close(1e3,"reconnect")}catch(e){o.default.warn("reconenct - close websocket "+e)}}var n=function(){e.connect().then((function(){e.retry&&(window.clearInterval(e.retry),e.retry=0)})).catch((function(e){o.default.warn("reconnect unsuccessfully with error: ",e),o.default.warn("reconnection will restart later...")}))};this.retry=window.setInterval(n,1e4),n()},t}();t.SocketManager=s}).call(this,r(19).setImmediate)},function(e,t,r){(function(t){var n=function(){return this||void 0===t?this:t}(),o=n.WebSocket||n.MozWebSocket,i=r(73);function a(e,t){return t?new o(e,t):new o(e)}o&&["CONNECTING","OPEN","CLOSING","CLOSED"].forEach((function(e){Object.defineProperty(a,e,{get:function(){return o[e]}})})),e.exports={w3cwebsocket:o?a:null,version:i}}).call(this,r(8))},function(e,t,r){e.exports=r(74).version},function(e){e.exports=JSON.parse('{"name":"websocket","description":"Websocket Client & Server Library implementing the WebSocket protocol as specified in RFC 6455.","keywords":["websocket","websockets","socket","networking","comet","push","RFC-6455","realtime","server","client"],"author":"Brian McKelvey <theturtle32@gmail.com> (https://github.com/theturtle32)","contributors":["Iñaki Baz Castillo <ibc@aliax.net> (http://dev.sipdoc.net)"],"version":"1.0.30","repository":{"type":"git","url":"https://github.com/theturtle32/WebSocket-Node.git"},"homepage":"https://github.com/theturtle32/WebSocket-Node","engines":{"node":">=0.10.0"},"dependencies":{"debug":"^2.2.0","nan":"^2.14.0","typedarray-to-buffer":"^3.1.5","yaeti":"^0.0.6"},"devDependencies":{"buffer-equal":"^1.0.0","faucet":"^0.0.1","gulp":"^4.0.2","gulp-jshint":"^2.0.4","jshint-stylish":"^2.2.1","jshint":"^2.0.0","tape":"^4.9.1"},"config":{"verbose":false},"scripts":{"install":"(node-gyp rebuild 2> builderror.log) || (exit 0)","test":"faucet test/unit","gulp":"gulp"},"main":"index","directories":{"lib":"./lib"},"browser":"lib/browser.js","license":"Apache-2.0"}')},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ErrorCodes={NOT_JOIN:"NotJoinRoomError",JOINING:"JoiningRoomError",LEAVING:"LeavingRoomError",DUPLICATED_JOIN:"DuplicatedJoinRoomError",ROLE_TYPE_NOT_MATCH:"RoleTypeNotMatchError",INVALID_MEDIASTREAM:"InvalidMediaStreamError",STREAM_EXISTS:"StreamExistsError",CREATE_STREAM:"CreateStreamError",STREAM_NOT_EXISTS:"StreamNotExistsError",AUDIO_TRACK_NOT_EXISTS:"AudioTrackNotExistsError",VIDEO_TRACK_NOT_EXISTS:"VideoTrackNotExistsError",SERVER_API:"ServerError",INVALID_PARAMETER:"InvalidParameterError",NOT_SUPPORT:"NotSupportError",BAD_REQUEST:"BadRequestError",OTHERS:"OtherError"}},function(e,t,r){e.exports=function(e){var t={};function r(n){if(t[n])return t[n].exports;var o=t[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)r.d(n,o,function(t){return e[t]}.bind(null,o));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=90)}({17:function(e,t,r){"use strict";t.__esModule=!0,t.default=void 0;var n=r(18),o=function(){function e(){}return e.getFirstMatch=function(e,t){var r=t.match(e);return r&&r.length>0&&r[1]||""},e.getSecondMatch=function(e,t){var r=t.match(e);return r&&r.length>1&&r[2]||""},e.matchAndReturnConst=function(e,t,r){if(e.test(t))return r},e.getWindowsVersionName=function(e){switch(e){case"NT":return"NT";case"XP":return"XP";case"NT 5.0":return"2000";case"NT 5.1":return"XP";case"NT 5.2":return"2003";case"NT 6.0":return"Vista";case"NT 6.1":return"7";case"NT 6.2":return"8";case"NT 6.3":return"8.1";case"NT 10.0":return"10";default:return}},e.getMacOSVersionName=function(e){var t=e.split(".").splice(0,2).map((function(e){return parseInt(e,10)||0}));if(t.push(0),10===t[0])switch(t[1]){case 5:return"Leopard";case 6:return"Snow Leopard";case 7:return"Lion";case 8:return"Mountain Lion";case 9:return"Mavericks";case 10:return"Yosemite";case 11:return"El Capitan";case 12:return"Sierra";case 13:return"High Sierra";case 14:return"Mojave";case 15:return"Catalina";default:return}},e.getAndroidVersionName=function(e){var t=e.split(".").splice(0,2).map((function(e){return parseInt(e,10)||0}));if(t.push(0),!(1===t[0]&&t[1]<5))return 1===t[0]&&t[1]<6?"Cupcake":1===t[0]&&t[1]>=6?"Donut":2===t[0]&&t[1]<2?"Eclair":2===t[0]&&2===t[1]?"Froyo":2===t[0]&&t[1]>2?"Gingerbread":3===t[0]?"Honeycomb":4===t[0]&&t[1]<1?"Ice Cream Sandwich":4===t[0]&&t[1]<4?"Jelly Bean":4===t[0]&&t[1]>=4?"KitKat":5===t[0]?"Lollipop":6===t[0]?"Marshmallow":7===t[0]?"Nougat":8===t[0]?"Oreo":9===t[0]?"Pie":void 0},e.getVersionPrecision=function(e){return e.split(".").length},e.compareVersions=function(t,r,n){void 0===n&&(n=!1);var o=e.getVersionPrecision(t),i=e.getVersionPrecision(r),a=Math.max(o,i),s=0,c=e.map([t,r],(function(t){var r=a-e.getVersionPrecision(t),n=t+new Array(r+1).join(".0");return e.map(n.split("."),(function(e){return new Array(20-e.length).join("0")+e})).reverse()}));for(n&&(s=a-Math.min(o,i)),a-=1;a>=s;){if(c[0][a]>c[1][a])return 1;if(c[0][a]===c[1][a]){if(a===s)return 0;a-=1}else if(c[0][a]<c[1][a])return-1}},e.map=function(e,t){var r,n=[];if(Array.prototype.map)return Array.prototype.map.call(e,t);for(r=0;r<e.length;r+=1)n.push(t(e[r]));return n},e.getBrowserAlias=function(e){return n.BROWSER_ALIASES_MAP[e]},e.getBrowserTypeByAlias=function(e){return n.BROWSER_MAP[e]||""},e}();t.default=o,e.exports=t.default},18:function(e,t,r){"use strict";t.__esModule=!0,t.ENGINE_MAP=t.OS_MAP=t.PLATFORMS_MAP=t.BROWSER_MAP=t.BROWSER_ALIASES_MAP=void 0,t.BROWSER_ALIASES_MAP={"Amazon Silk":"amazon_silk","Android Browser":"android",Bada:"bada",BlackBerry:"blackberry",Chrome:"chrome",Chromium:"chromium",Epiphany:"epiphany",Firefox:"firefox",Focus:"focus",Generic:"generic","Google Search":"google_search",Googlebot:"googlebot","Internet Explorer":"ie","K-Meleon":"k_meleon",Maxthon:"maxthon","Microsoft Edge":"edge","MZ Browser":"mz","NAVER Whale Browser":"naver",Opera:"opera","Opera Coast":"opera_coast",PhantomJS:"phantomjs",Puffin:"puffin",QupZilla:"qupzilla",QQ:"qq",QQLite:"qqlite",Safari:"safari",Sailfish:"sailfish","Samsung Internet for Android":"samsung_internet",SeaMonkey:"seamonkey",Sleipnir:"sleipnir",Swing:"swing",Tizen:"tizen","UC Browser":"uc",Vivaldi:"vivaldi","WebOS Browser":"webos",WeChat:"wechat","Yandex Browser":"yandex",Roku:"roku"},t.BROWSER_MAP={amazon_silk:"Amazon Silk",android:"Android Browser",bada:"Bada",blackberry:"BlackBerry",chrome:"Chrome",chromium:"Chromium",epiphany:"Epiphany",firefox:"Firefox",focus:"Focus",generic:"Generic",googlebot:"Googlebot",google_search:"Google Search",ie:"Internet Explorer",k_meleon:"K-Meleon",maxthon:"Maxthon",edge:"Microsoft Edge",mz:"MZ Browser",naver:"NAVER Whale Browser",opera:"Opera",opera_coast:"Opera Coast",phantomjs:"PhantomJS",puffin:"Puffin",qupzilla:"QupZilla",qq:"QQ Browser",qqlite:"QQ Browser Lite",safari:"Safari",sailfish:"Sailfish",samsung_internet:"Samsung Internet for Android",seamonkey:"SeaMonkey",sleipnir:"Sleipnir",swing:"Swing",tizen:"Tizen",uc:"UC Browser",vivaldi:"Vivaldi",webos:"WebOS Browser",wechat:"WeChat",yandex:"Yandex Browser"},t.PLATFORMS_MAP={tablet:"tablet",mobile:"mobile",desktop:"desktop",tv:"tv"},t.OS_MAP={WindowsPhone:"Windows Phone",Windows:"Windows",MacOS:"macOS",iOS:"iOS",Android:"Android",WebOS:"WebOS",BlackBerry:"BlackBerry",Bada:"Bada",Tizen:"Tizen",Linux:"Linux",ChromeOS:"Chrome OS",PlayStation4:"PlayStation 4",Roku:"Roku"},t.ENGINE_MAP={EdgeHTML:"EdgeHTML",Blink:"Blink",Trident:"Trident",Presto:"Presto",Gecko:"Gecko",WebKit:"WebKit"}},90:function(e,t,r){"use strict";t.__esModule=!0,t.default=void 0;var n,o=(n=r(91))&&n.__esModule?n:{default:n},i=r(18);function a(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}var s=function(){function e(){}var t,r;return e.getParser=function(e,t){if(void 0===t&&(t=!1),"string"!=typeof e)throw new Error("UserAgent should be a string");return new o.default(e,t)},e.parse=function(e){return new o.default(e).getResult()},t=e,(r=[{key:"BROWSER_MAP",get:function(){return i.BROWSER_MAP}},{key:"ENGINE_MAP",get:function(){return i.ENGINE_MAP}},{key:"OS_MAP",get:function(){return i.OS_MAP}},{key:"PLATFORMS_MAP",get:function(){return i.PLATFORMS_MAP}}])&&a(t,r),e}();t.default=s,e.exports=t.default},91:function(e,t,r){"use strict";t.__esModule=!0,t.default=void 0;var n=c(r(92)),o=c(r(93)),i=c(r(94)),a=c(r(95)),s=c(r(17));function c(e){return e&&e.__esModule?e:{default:e}}var u=function(){function e(e,t){if(void 0===t&&(t=!1),null==e||""===e)throw new Error("UserAgent parameter can't be empty");this._ua=e,this.parsedResult={},!0!==t&&this.parse()}var t=e.prototype;return t.getUA=function(){return this._ua},t.test=function(e){return e.test(this._ua)},t.parseBrowser=function(){var e=this;this.parsedResult.browser={};var t=n.default.find((function(t){if("function"==typeof t.test)return t.test(e);if(t.test instanceof Array)return t.test.some((function(t){return e.test(t)}));throw new Error("Browser's test function is not valid")}));return t&&(this.parsedResult.browser=t.describe(this.getUA())),this.parsedResult.browser},t.getBrowser=function(){return this.parsedResult.browser?this.parsedResult.browser:this.parseBrowser()},t.getBrowserName=function(e){return e?String(this.getBrowser().name).toLowerCase()||"":this.getBrowser().name||""},t.getBrowserVersion=function(){return this.getBrowser().version},t.getOS=function(){return this.parsedResult.os?this.parsedResult.os:this.parseOS()},t.parseOS=function(){var e=this;this.parsedResult.os={};var t=o.default.find((function(t){if("function"==typeof t.test)return t.test(e);if(t.test instanceof Array)return t.test.some((function(t){return e.test(t)}));throw new Error("Browser's test function is not valid")}));return t&&(this.parsedResult.os=t.describe(this.getUA())),this.parsedResult.os},t.getOSName=function(e){var t=this.getOS().name;return e?String(t).toLowerCase()||"":t||""},t.getOSVersion=function(){return this.getOS().version},t.getPlatform=function(){return this.parsedResult.platform?this.parsedResult.platform:this.parsePlatform()},t.getPlatformType=function(e){void 0===e&&(e=!1);var t=this.getPlatform().type;return e?String(t).toLowerCase()||"":t||""},t.parsePlatform=function(){var e=this;this.parsedResult.platform={};var t=i.default.find((function(t){if("function"==typeof t.test)return t.test(e);if(t.test instanceof Array)return t.test.some((function(t){return e.test(t)}));throw new Error("Browser's test function is not valid")}));return t&&(this.parsedResult.platform=t.describe(this.getUA())),this.parsedResult.platform},t.getEngine=function(){return this.parsedResult.engine?this.parsedResult.engine:this.parseEngine()},t.getEngineName=function(e){return e?String(this.getEngine().name).toLowerCase()||"":this.getEngine().name||""},t.parseEngine=function(){var e=this;this.parsedResult.engine={};var t=a.default.find((function(t){if("function"==typeof t.test)return t.test(e);if(t.test instanceof Array)return t.test.some((function(t){return e.test(t)}));throw new Error("Browser's test function is not valid")}));return t&&(this.parsedResult.engine=t.describe(this.getUA())),this.parsedResult.engine},t.parse=function(){return this.parseBrowser(),this.parseOS(),this.parsePlatform(),this.parseEngine(),this},t.getResult=function(){return Object.assign({},this.parsedResult)},t.satisfies=function(e){var t=this,r={},n=0,o={},i=0;if(Object.keys(e).forEach((function(t){var a=e[t];"string"==typeof a?(o[t]=a,i+=1):"object"==typeof a&&(r[t]=a,n+=1)})),n>0){var a=Object.keys(r),s=a.find((function(e){return t.isOS(e)}));if(s){var c=this.satisfies(r[s]);if(void 0!==c)return c}var u=a.find((function(e){return t.isPlatform(e)}));if(u){var d=this.satisfies(r[u]);if(void 0!==d)return d}}if(i>0){var p=Object.keys(o).find((function(e){return t.isBrowser(e,!0)}));if(void 0!==p)return this.compareVersion(o[p])}},t.isBrowser=function(e,t){void 0===t&&(t=!1);var r=this.getBrowserName().toLowerCase(),n=e.toLowerCase(),o=s.default.getBrowserTypeByAlias(n);return t&&o&&(n=o.toLowerCase()),n===r},t.compareVersion=function(e){var t=[0],r=e,n=!1,o=this.getBrowserVersion();if("string"==typeof o)return">"===e[0]||"<"===e[0]?(r=e.substr(1),"="===e[1]?(n=!0,r=e.substr(2)):t=[],">"===e[0]?t.push(1):t.push(-1)):"="===e[0]?r=e.substr(1):"~"===e[0]&&(n=!0,r=e.substr(1)),t.indexOf(s.default.compareVersions(o,r,n))>-1},t.isOS=function(e){return this.getOSName(!0)===String(e).toLowerCase()},t.isPlatform=function(e){return this.getPlatformType(!0)===String(e).toLowerCase()},t.isEngine=function(e){return this.getEngineName(!0)===String(e).toLowerCase()},t.is=function(e){return this.isBrowser(e)||this.isOS(e)||this.isPlatform(e)},t.some=function(e){var t=this;return void 0===e&&(e=[]),e.some((function(e){return t.is(e)}))},e}();t.default=u,e.exports=t.default},92:function(e,t,r){"use strict";t.__esModule=!0,t.default=void 0;var n,o=(n=r(17))&&n.__esModule?n:{default:n},i=/version\/(\d+(\.?_?\d+)+)/i,a=[{test:[/googlebot/i],describe:function(e){var t={name:"Googlebot"},r=o.default.getFirstMatch(/googlebot\/(\d+(\.\d+))/i,e)||o.default.getFirstMatch(i,e);return r&&(t.version=r),t}},{test:[/opera/i],describe:function(e){var t={name:"Opera"},r=o.default.getFirstMatch(i,e)||o.default.getFirstMatch(/(?:opera)[\s/](\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/opr\/|opios/i],describe:function(e){var t={name:"Opera"},r=o.default.getFirstMatch(/(?:opr|opios)[\s/](\S+)/i,e)||o.default.getFirstMatch(i,e);return r&&(t.version=r),t}},{test:[/SamsungBrowser/i],describe:function(e){var t={name:"Samsung Internet for Android"},r=o.default.getFirstMatch(i,e)||o.default.getFirstMatch(/(?:SamsungBrowser)[\s/](\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/Whale/i],describe:function(e){var t={name:"NAVER Whale Browser"},r=o.default.getFirstMatch(i,e)||o.default.getFirstMatch(/(?:whale)[\s/](\d+(?:\.\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/MZBrowser/i],describe:function(e){var t={name:"MZ Browser"},r=o.default.getFirstMatch(/(?:MZBrowser)[\s/](\d+(?:\.\d+)+)/i,e)||o.default.getFirstMatch(i,e);return r&&(t.version=r),t}},{test:[/focus/i],describe:function(e){var t={name:"Focus"},r=o.default.getFirstMatch(/(?:focus)[\s/](\d+(?:\.\d+)+)/i,e)||o.default.getFirstMatch(i,e);return r&&(t.version=r),t}},{test:[/swing/i],describe:function(e){var t={name:"Swing"},r=o.default.getFirstMatch(/(?:swing)[\s/](\d+(?:\.\d+)+)/i,e)||o.default.getFirstMatch(i,e);return r&&(t.version=r),t}},{test:[/coast/i],describe:function(e){var t={name:"Opera Coast"},r=o.default.getFirstMatch(i,e)||o.default.getFirstMatch(/(?:coast)[\s/](\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/yabrowser/i],describe:function(e){var t={name:"Yandex Browser"},r=o.default.getFirstMatch(/(?:yabrowser)[\s/](\d+(\.?_?\d+)+)/i,e)||o.default.getFirstMatch(i,e);return r&&(t.version=r),t}},{test:[/ucbrowser/i],describe:function(e){var t={name:"UC Browser"},r=o.default.getFirstMatch(i,e)||o.default.getFirstMatch(/(?:ucbrowser)[\s/](\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/Maxthon|mxios/i],describe:function(e){var t={name:"Maxthon"},r=o.default.getFirstMatch(i,e)||o.default.getFirstMatch(/(?:Maxthon|mxios)[\s/](\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/epiphany/i],describe:function(e){var t={name:"Epiphany"},r=o.default.getFirstMatch(i,e)||o.default.getFirstMatch(/(?:epiphany)[\s/](\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/puffin/i],describe:function(e){var t={name:"Puffin"},r=o.default.getFirstMatch(i,e)||o.default.getFirstMatch(/(?:puffin)[\s/](\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/sleipnir/i],describe:function(e){var t={name:"Sleipnir"},r=o.default.getFirstMatch(i,e)||o.default.getFirstMatch(/(?:sleipnir)[\s/](\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/k-meleon/i],describe:function(e){var t={name:"K-Meleon"},r=o.default.getFirstMatch(i,e)||o.default.getFirstMatch(/(?:k-meleon)[\s/](\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/micromessenger/i],describe:function(e){var t={name:"WeChat"},r=o.default.getFirstMatch(/(?:micromessenger)[\s/](\d+(\.?_?\d+)+)/i,e)||o.default.getFirstMatch(i,e);return r&&(t.version=r),t}},{test:[/qqbrowser/i],describe:function(e){var t={name:/qqbrowserlite/i.test(e)?"QQ Browser Lite":"QQ Browser"},r=o.default.getFirstMatch(/(?:qqbrowserlite|qqbrowser)[/](\d+(\.?_?\d+)+)/i,e)||o.default.getFirstMatch(i,e);return r&&(t.version=r),t}},{test:[/msie|trident/i],describe:function(e){var t={name:"Internet Explorer"},r=o.default.getFirstMatch(/(?:msie |rv:)(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/\sedg\//i],describe:function(e){var t={name:"Microsoft Edge"},r=o.default.getFirstMatch(/\sedg\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/edg([ea]|ios)/i],describe:function(e){var t={name:"Microsoft Edge"},r=o.default.getSecondMatch(/edg([ea]|ios)\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/vivaldi/i],describe:function(e){var t={name:"Vivaldi"},r=o.default.getFirstMatch(/vivaldi\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/seamonkey/i],describe:function(e){var t={name:"SeaMonkey"},r=o.default.getFirstMatch(/seamonkey\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/sailfish/i],describe:function(e){var t={name:"Sailfish"},r=o.default.getFirstMatch(/sailfish\s?browser\/(\d+(\.\d+)?)/i,e);return r&&(t.version=r),t}},{test:[/silk/i],describe:function(e){var t={name:"Amazon Silk"},r=o.default.getFirstMatch(/silk\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/phantom/i],describe:function(e){var t={name:"PhantomJS"},r=o.default.getFirstMatch(/phantomjs\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/slimerjs/i],describe:function(e){var t={name:"SlimerJS"},r=o.default.getFirstMatch(/slimerjs\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/blackberry|\bbb\d+/i,/rim\stablet/i],describe:function(e){var t={name:"BlackBerry"},r=o.default.getFirstMatch(i,e)||o.default.getFirstMatch(/blackberry[\d]+\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/(web|hpw)[o0]s/i],describe:function(e){var t={name:"WebOS Browser"},r=o.default.getFirstMatch(i,e)||o.default.getFirstMatch(/w(?:eb)?[o0]sbrowser\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/bada/i],describe:function(e){var t={name:"Bada"},r=o.default.getFirstMatch(/dolfin\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/tizen/i],describe:function(e){var t={name:"Tizen"},r=o.default.getFirstMatch(/(?:tizen\s?)?browser\/(\d+(\.?_?\d+)+)/i,e)||o.default.getFirstMatch(i,e);return r&&(t.version=r),t}},{test:[/qupzilla/i],describe:function(e){var t={name:"QupZilla"},r=o.default.getFirstMatch(/(?:qupzilla)[\s/](\d+(\.?_?\d+)+)/i,e)||o.default.getFirstMatch(i,e);return r&&(t.version=r),t}},{test:[/firefox|iceweasel|fxios/i],describe:function(e){var t={name:"Firefox"},r=o.default.getFirstMatch(/(?:firefox|iceweasel|fxios)[\s/](\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/chromium/i],describe:function(e){var t={name:"Chromium"},r=o.default.getFirstMatch(/(?:chromium)[\s/](\d+(\.?_?\d+)+)/i,e)||o.default.getFirstMatch(i,e);return r&&(t.version=r),t}},{test:[/chrome|crios|crmo/i],describe:function(e){var t={name:"Chrome"},r=o.default.getFirstMatch(/(?:chrome|crios|crmo)\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/GSA/i],describe:function(e){var t={name:"Google Search"},r=o.default.getFirstMatch(/(?:GSA)\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:function(e){var t=!e.test(/like android/i),r=e.test(/android/i);return t&&r},describe:function(e){var t={name:"Android Browser"},r=o.default.getFirstMatch(i,e);return r&&(t.version=r),t}},{test:[/playstation 4/i],describe:function(e){var t={name:"PlayStation 4"},r=o.default.getFirstMatch(i,e);return r&&(t.version=r),t}},{test:[/safari|applewebkit/i],describe:function(e){var t={name:"Safari"},r=o.default.getFirstMatch(i,e);return r&&(t.version=r),t}},{test:[/.*/i],describe:function(e){var t=-1!==e.search("\\(")?/^(.*)\/(.*)[ \t]\((.*)/:/^(.*)\/(.*) /;return{name:o.default.getFirstMatch(t,e),version:o.default.getSecondMatch(t,e)}}}];t.default=a,e.exports=t.default},93:function(e,t,r){"use strict";t.__esModule=!0,t.default=void 0;var n,o=(n=r(17))&&n.__esModule?n:{default:n},i=r(18),a=[{test:[/Roku\/DVP/],describe:function(e){var t=o.default.getFirstMatch(/Roku\/DVP-(\d+\.\d+)/i,e);return{name:i.OS_MAP.Roku,version:t}}},{test:[/windows phone/i],describe:function(e){var t=o.default.getFirstMatch(/windows phone (?:os)?\s?(\d+(\.\d+)*)/i,e);return{name:i.OS_MAP.WindowsPhone,version:t}}},{test:[/windows/i],describe:function(e){var t=o.default.getFirstMatch(/Windows ((NT|XP)( \d\d?.\d)?)/i,e),r=o.default.getWindowsVersionName(t);return{name:i.OS_MAP.Windows,version:t,versionName:r}}},{test:[/macintosh/i],describe:function(e){var t=o.default.getFirstMatch(/mac os x (\d+(\.?_?\d+)+)/i,e).replace(/[_\s]/g,"."),r=o.default.getMacOSVersionName(t),n={name:i.OS_MAP.MacOS,version:t};return r&&(n.versionName=r),n}},{test:[/(ipod|iphone|ipad)/i],describe:function(e){var t=o.default.getFirstMatch(/os (\d+([_\s]\d+)*) like mac os x/i,e).replace(/[_\s]/g,".");return{name:i.OS_MAP.iOS,version:t}}},{test:function(e){var t=!e.test(/like android/i),r=e.test(/android/i);return t&&r},describe:function(e){var t=o.default.getFirstMatch(/android[\s/-](\d+(\.\d+)*)/i,e),r=o.default.getAndroidVersionName(t),n={name:i.OS_MAP.Android,version:t};return r&&(n.versionName=r),n}},{test:[/(web|hpw)[o0]s/i],describe:function(e){var t=o.default.getFirstMatch(/(?:web|hpw)[o0]s\/(\d+(\.\d+)*)/i,e),r={name:i.OS_MAP.WebOS};return t&&t.length&&(r.version=t),r}},{test:[/blackberry|\bbb\d+/i,/rim\stablet/i],describe:function(e){var t=o.default.getFirstMatch(/rim\stablet\sos\s(\d+(\.\d+)*)/i,e)||o.default.getFirstMatch(/blackberry\d+\/(\d+([_\s]\d+)*)/i,e)||o.default.getFirstMatch(/\bbb(\d+)/i,e);return{name:i.OS_MAP.BlackBerry,version:t}}},{test:[/bada/i],describe:function(e){var t=o.default.getFirstMatch(/bada\/(\d+(\.\d+)*)/i,e);return{name:i.OS_MAP.Bada,version:t}}},{test:[/tizen/i],describe:function(e){var t=o.default.getFirstMatch(/tizen[/\s](\d+(\.\d+)*)/i,e);return{name:i.OS_MAP.Tizen,version:t}}},{test:[/linux/i],describe:function(){return{name:i.OS_MAP.Linux}}},{test:[/CrOS/],describe:function(){return{name:i.OS_MAP.ChromeOS}}},{test:[/PlayStation 4/],describe:function(e){var t=o.default.getFirstMatch(/PlayStation 4[/\s](\d+(\.\d+)*)/i,e);return{name:i.OS_MAP.PlayStation4,version:t}}}];t.default=a,e.exports=t.default},94:function(e,t,r){"use strict";t.__esModule=!0,t.default=void 0;var n,o=(n=r(17))&&n.__esModule?n:{default:n},i=r(18),a=[{test:[/googlebot/i],describe:function(){return{type:"bot",vendor:"Google"}}},{test:[/huawei/i],describe:function(e){var t=o.default.getFirstMatch(/(can-l01)/i,e)&&"Nova",r={type:i.PLATFORMS_MAP.mobile,vendor:"Huawei"};return t&&(r.model=t),r}},{test:[/nexus\s*(?:7|8|9|10).*/i],describe:function(){return{type:i.PLATFORMS_MAP.tablet,vendor:"Nexus"}}},{test:[/ipad/i],describe:function(){return{type:i.PLATFORMS_MAP.tablet,vendor:"Apple",model:"iPad"}}},{test:[/kftt build/i],describe:function(){return{type:i.PLATFORMS_MAP.tablet,vendor:"Amazon",model:"Kindle Fire HD 7"}}},{test:[/silk/i],describe:function(){return{type:i.PLATFORMS_MAP.tablet,vendor:"Amazon"}}},{test:[/tablet(?! pc)/i],describe:function(){return{type:i.PLATFORMS_MAP.tablet}}},{test:function(e){var t=e.test(/ipod|iphone/i),r=e.test(/like (ipod|iphone)/i);return t&&!r},describe:function(e){var t=o.default.getFirstMatch(/(ipod|iphone)/i,e);return{type:i.PLATFORMS_MAP.mobile,vendor:"Apple",model:t}}},{test:[/nexus\s*[0-6].*/i,/galaxy nexus/i],describe:function(){return{type:i.PLATFORMS_MAP.mobile,vendor:"Nexus"}}},{test:[/[^-]mobi/i],describe:function(){return{type:i.PLATFORMS_MAP.mobile}}},{test:function(e){return"blackberry"===e.getBrowserName(!0)},describe:function(){return{type:i.PLATFORMS_MAP.mobile,vendor:"BlackBerry"}}},{test:function(e){return"bada"===e.getBrowserName(!0)},describe:function(){return{type:i.PLATFORMS_MAP.mobile}}},{test:function(e){return"windows phone"===e.getBrowserName()},describe:function(){return{type:i.PLATFORMS_MAP.mobile,vendor:"Microsoft"}}},{test:function(e){var t=Number(String(e.getOSVersion()).split(".")[0]);return"android"===e.getOSName(!0)&&t>=3},describe:function(){return{type:i.PLATFORMS_MAP.tablet}}},{test:function(e){return"android"===e.getOSName(!0)},describe:function(){return{type:i.PLATFORMS_MAP.mobile}}},{test:function(e){return"macos"===e.getOSName(!0)},describe:function(){return{type:i.PLATFORMS_MAP.desktop,vendor:"Apple"}}},{test:function(e){return"windows"===e.getOSName(!0)},describe:function(){return{type:i.PLATFORMS_MAP.desktop}}},{test:function(e){return"linux"===e.getOSName(!0)},describe:function(){return{type:i.PLATFORMS_MAP.desktop}}},{test:function(e){return"playstation 4"===e.getOSName(!0)},describe:function(){return{type:i.PLATFORMS_MAP.tv}}},{test:function(e){return"roku"===e.getOSName(!0)},describe:function(){return{type:i.PLATFORMS_MAP.tv}}}];t.default=a,e.exports=t.default},95:function(e,t,r){"use strict";t.__esModule=!0,t.default=void 0;var n,o=(n=r(17))&&n.__esModule?n:{default:n},i=r(18),a=[{test:function(e){return"microsoft edge"===e.getBrowserName(!0)},describe:function(e){if(/\sedg\//i.test(e))return{name:i.ENGINE_MAP.Blink};var t=o.default.getFirstMatch(/edge\/(\d+(\.?_?\d+)+)/i,e);return{name:i.ENGINE_MAP.EdgeHTML,version:t}}},{test:[/trident/i],describe:function(e){var t={name:i.ENGINE_MAP.Trident},r=o.default.getFirstMatch(/trident\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:function(e){return e.test(/presto/i)},describe:function(e){var t={name:i.ENGINE_MAP.Presto},r=o.default.getFirstMatch(/presto\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:function(e){var t=e.test(/gecko/i),r=e.test(/like gecko/i);return t&&!r},describe:function(e){var t={name:i.ENGINE_MAP.Gecko},r=o.default.getFirstMatch(/gecko\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/(apple)?webkit\/537\.36/i],describe:function(){return{name:i.ENGINE_MAP.Blink}}},{test:[/(apple)?webkit/i],describe:function(e){var t={name:i.ENGINE_MAP.WebKit},r=o.default.getFirstMatch(/webkit\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}}];t.default=a,e.exports=t.default}})},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(0),o=function(){function e(e){var t=this;if(!!!Worker)throw new Error("Web Worker is Not Enabled");var r=e.toString().replace(/^[^{]*{\s*/,"").replace(/\s*}[^}]*$/,"");this.worker=new Worker(URL.createObjectURL(new Blob([r],{type:"text/javascript"}))),this.worker.onmessage=function(e){t.onmessage(e)},this.worker.onerror=function(e){t.onerror(e)}}return e.prototype.postMessage=function(e){this.worker.postMessage(e)},e.prototype.onmessage=function(e){n.default.debug("onmessage ",e)},e.prototype.onerror=function(e){n.default.debug("onerror ",e)},e.prototype.terminate=function(){var e;null===(e=this.worker)||void 0===e||e.terminate()},e}();t.InlineWorker=o},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(2),o=r(6),i=r(16),a=r(39),s=r(9),c=r(0),u=r(40),d=r(3),p=r(4),f=function(e){function t(){var t=e.call(this)||this;return t.streams=new Map,t.players=new Map,t.on("screen-track-ended",(function(e){c.default.debug("screen-track-ended",e);var r=t.getStream(e.streamId);r&&t.emitter&&t.emitter.emit("screenshare-stopped",r.convertToOuterStream())})),t.on("stream-close",(function(e){t.destroyPlayer(e)})),t}return n.__extends(t,e),t.prototype.createStream=function(e,t,r,o){var c,u=this;c="preview"===t?{audio:r.audio,video:r.video,screen:!1,data:!1,mediaType:p.ENUM_MEDIA_TYPE.camera,microphoneId:r.microphoneId,cameraId:r.cameraId,facingMode:r.facingMode}:a.StreamManager.generatePublishConfig(r);var d=new i.LocalStream(e,c,this);return d.previewId=t,d.streamId=t,d.setResolution(s.getResolution(o)),this.streams.set(d.streamId,d),new Promise((function(e,t){return n.__awaiter(u,void 0,void 0,(function(){var o;return n.__generator(this,(function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),[4,d.init(r)];case 1:return n.sent(),e(d),[3,3];case 2:return o=n.sent(),d.close(),t(o),[3,3];case 3:return[2]}}))}))}))},t.prototype.copyStream=function(e){var t=this,r=new i.LocalStream(e.userId,e.config,this);return r.previewId=e.previewId,r.streamId=e.previewId,r.setResolution(e.resolution),this.streams.set(r.streamId,r),new Promise((function(o,i){return n.__awaiter(t,void 0,void 0,(function(){var t;return n.__generator(this,(function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),[4,r.init({},e)];case 1:return n.sent(),o(r),[3,3];case 2:return t=n.sent(),i(t),[3,3];case 3:return[2]}}))}))}))},t.prototype.removeStream=function(e,t){var r=this;return new Promise((function(n,o){var i=r.streams.get(e);i?(i.close(t),r.streams.delete(e),n()):o(d.createError(d.ErrorCodes.STREAM_NOT_EXISTS,"stream isnot found"))}))},t.prototype.removeAllStreams=function(){var e=this;return new Promise((function(t,r){try{e.streams.forEach((function(e){e.close()})),e.streams.clear(),t()}catch(e){r(e)}}))},t.prototype.getStream=function(e){return this.streams.get(e)},t.prototype.getAllStreams=function(){var e=[];return this.streams.forEach((function(t){e.push(t)})),e},t.prototype.play=function(e,t,r){var n=this.players.get(e.streamId);return n?Promise.reject(d.createError(d.ErrorCodes.OTHERS,"the play function has already been invoked, you can invoke the resume function to play")):(n=new u.Player(e,t,r),this.players.set(e.streamId,n),n.play())},t.prototype.resume=function(e){e.resumeAudio().catch((function(e){c.default.warn("resume audio faild "+e)}));var t=this.players.get(e.streamId);return t?t.resume():Promise.reject(d.createError(d.ErrorCodes.OTHERS,"stream isn't playing"))},t.prototype.stop=function(e){var t=this.players.get(e.streamId);return t?(t.stop(),Promise.resolve()):Promise.reject(d.createError(d.ErrorCodes.OTHERS,"stream isn't playing"))},t.prototype.destroyPlayer=function(e){var t=this.players.get(e.streamId);t&&(t.destroy(),this.players.delete(e.streamId))},t.prototype.setVideoProfile=function(e,t){var r=s.getResolution(t),n=this.getStream(e);return n?(n.setResolution(r),n.applyResolution(r)):Promise.reject(d.createError(d.ErrorCodes.STREAM_NOT_EXISTS,"stream isn't found"))},t.prototype.destroy=function(){this.removeAllStreams().catch((function(e){c.default.warn("remove all preview streams error: "+e)}))},t}(o.EventEmitter);t.PreviewStreamManager=f},function(module,exports,__webpack_require__){(function(global){var __WEBPACK_AMD_DEFINE_ARRAY__,__WEBPACK_AMD_DEFINE_RESULT__;!function(e,t){module.exports=t(e)}("undefined"!=typeof self?self:"undefined"!=typeof window?window:void 0!==global?global:this,(function(global){"use strict";global=global||{};var _Base64=global.Base64,version="2.5.1",buffer;if(module.exports)try{buffer=eval("require('buffer').Buffer")}catch(e){buffer=void 0}var b64chars="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",b64tab=function(e){for(var t={},r=0,n=e.length;r<n;r++)t[e.charAt(r)]=r;return t}(b64chars),fromCharCode=String.fromCharCode,cb_utob=function(e){if(e.length<2)return(t=e.charCodeAt(0))<128?e:t<2048?fromCharCode(192|t>>>6)+fromCharCode(128|63&t):fromCharCode(224|t>>>12&15)+fromCharCode(128|t>>>6&63)+fromCharCode(128|63&t);var t=65536+1024*(e.charCodeAt(0)-55296)+(e.charCodeAt(1)-56320);return fromCharCode(240|t>>>18&7)+fromCharCode(128|t>>>12&63)+fromCharCode(128|t>>>6&63)+fromCharCode(128|63&t)},re_utob=/[\uD800-\uDBFF][\uDC00-\uDFFFF]|[^\x00-\x7F]/g,utob=function(e){return e.replace(re_utob,cb_utob)},cb_encode=function(e){var t=[0,2,1][e.length%3],r=e.charCodeAt(0)<<16|(e.length>1?e.charCodeAt(1):0)<<8|(e.length>2?e.charCodeAt(2):0);return[b64chars.charAt(r>>>18),b64chars.charAt(r>>>12&63),t>=2?"=":b64chars.charAt(r>>>6&63),t>=1?"=":b64chars.charAt(63&r)].join("")},btoa=global.btoa?function(e){return global.btoa(e)}:function(e){return e.replace(/[\s\S]{1,3}/g,cb_encode)},_encode=buffer?buffer.from&&Uint8Array&&buffer.from!==Uint8Array.from?function(e){return(e.constructor===buffer.constructor?e:buffer.from(e)).toString("base64")}:function(e){return(e.constructor===buffer.constructor?e:new buffer(e)).toString("base64")}:function(e){return btoa(utob(e))},encode=function(e,t){return t?_encode(String(e)).replace(/[+\/]/g,(function(e){return"+"==e?"-":"_"})).replace(/=/g,""):_encode(String(e))},encodeURI=function(e){return encode(e,!0)},re_btou=new RegExp(["[À-ß][-¿]","[à-ï][-¿]{2}","[ð-÷][-¿]{3}"].join("|"),"g"),cb_btou=function(e){switch(e.length){case 4:var t=((7&e.charCodeAt(0))<<18|(63&e.charCodeAt(1))<<12|(63&e.charCodeAt(2))<<6|63&e.charCodeAt(3))-65536;return fromCharCode(55296+(t>>>10))+fromCharCode(56320+(1023&t));case 3:return fromCharCode((15&e.charCodeAt(0))<<12|(63&e.charCodeAt(1))<<6|63&e.charCodeAt(2));default:return fromCharCode((31&e.charCodeAt(0))<<6|63&e.charCodeAt(1))}},btou=function(e){return e.replace(re_btou,cb_btou)},cb_decode=function(e){var t=e.length,r=t%4,n=(t>0?b64tab[e.charAt(0)]<<18:0)|(t>1?b64tab[e.charAt(1)]<<12:0)|(t>2?b64tab[e.charAt(2)]<<6:0)|(t>3?b64tab[e.charAt(3)]:0),o=[fromCharCode(n>>>16),fromCharCode(n>>>8&255),fromCharCode(255&n)];return o.length-=[0,0,2,1][r],o.join("")},_atob=global.atob?function(e){return global.atob(e)}:function(e){return e.replace(/\S{1,4}/g,cb_decode)},atob=function(e){return _atob(String(e).replace(/[^A-Za-z0-9\+\/]/g,""))},_decode=buffer?buffer.from&&Uint8Array&&buffer.from!==Uint8Array.from?function(e){return(e.constructor===buffer.constructor?e:buffer.from(e,"base64")).toString()}:function(e){return(e.constructor===buffer.constructor?e:new buffer(e,"base64")).toString()}:function(e){return btou(_atob(e))},decode=function(e){return _decode(String(e).replace(/[-_]/g,(function(e){return"-"==e?"+":"/"})).replace(/[^A-Za-z0-9\+\/]/g,""))},noConflict=function(){var e=global.Base64;return global.Base64=_Base64,e};if(global.Base64={VERSION:version,atob:atob,btoa:btoa,fromBase64:decode,toBase64:encode,utob:utob,encode:encode,encodeURI:encodeURI,btou:btou,decode:decode,noConflict:noConflict,__buffer__:buffer},"function"==typeof Object.defineProperty){var noEnum=function(e){return{value:e,enumerable:!1,writable:!0,configurable:!0}};global.Base64.extendString=function(){Object.defineProperty(String.prototype,"fromBase64",noEnum((function(){return decode(this)}))),Object.defineProperty(String.prototype,"toBase64",noEnum((function(e){return encode(this,e)}))),Object.defineProperty(String.prototype,"toBase64URI",noEnum((function(){return encode(this,!0)})))}}return global.Meteor&&(Base64=global.Base64),module.exports?module.exports.Base64=global.Base64:(__WEBPACK_AMD_DEFINE_ARRAY__=[],__WEBPACK_AMD_DEFINE_RESULT__=function(){return global.Base64}.apply(exports,__WEBPACK_AMD_DEFINE_ARRAY__),void 0===__WEBPACK_AMD_DEFINE_RESULT__||(module.exports=__WEBPACK_AMD_DEFINE_RESULT__)),{Base64:global.Base64}}))}).call(this,__webpack_require__(8))},function(e,t,r){"use strict";var n;!function(o){function i(e,t,r){var n,o,i,a,l,m,h,v,g,y=0,b=[],E=0,_=!1,S=[],T=[],R=!1,w=!1,M=-1;if(n=(r=r||{}).encoding||"UTF8",(g=r.numRounds||1)!==parseInt(g,10)||1>g)throw Error("numRounds must a integer >= 1");if("SHA-1"===e)l=512,m=D,h=V,a=160,v=function(e){return e.slice()};else if(0===e.lastIndexOf("SHA-",0))if(m=function(t,r){return B(t,r,e)},h=function(t,r,n,o){var i,a;if("SHA-224"===e||"SHA-256"===e)i=15+(r+65>>>9<<4),a=16;else{if("SHA-384"!==e&&"SHA-512"!==e)throw Error("Unexpected error in SHA-2 implementation");i=31+(r+129>>>10<<5),a=32}for(;t.length<=i;)t.push(0);for(t[r>>>5]|=128<<24-r%32,r+=n,t[i]=4294967295&r,t[i-1]=r/4294967296|0,n=t.length,r=0;r<n;r+=a)o=B(t.slice(r,r+a),o,e);if("SHA-224"===e)t=[o[0],o[1],o[2],o[3],o[4],o[5],o[6]];else if("SHA-256"===e)t=o;else if("SHA-384"===e)t=[o[0].a,o[0].b,o[1].a,o[1].b,o[2].a,o[2].b,o[3].a,o[3].b,o[4].a,o[4].b,o[5].a,o[5].b];else{if("SHA-512"!==e)throw Error("Unexpected error in SHA-2 implementation");t=[o[0].a,o[0].b,o[1].a,o[1].b,o[2].a,o[2].b,o[3].a,o[3].b,o[4].a,o[4].b,o[5].a,o[5].b,o[6].a,o[6].b,o[7].a,o[7].b]}return t},v=function(e){return e.slice()},"SHA-224"===e)l=512,a=224;else if("SHA-256"===e)l=512,a=256;else if("SHA-384"===e)l=1024,a=384;else{if("SHA-512"!==e)throw Error("Chosen SHA variant is not supported");l=1024,a=512}else{if(0!==e.lastIndexOf("SHA3-",0)&&0!==e.lastIndexOf("SHAKE",0))throw Error("Chosen SHA variant is not supported");var C=6;if(m=F,v=function(e){var t,r=[];for(t=0;5>t;t+=1)r[t]=e[t].slice();return r},M=1,"SHA3-224"===e)l=1152,a=224;else if("SHA3-256"===e)l=1088,a=256;else if("SHA3-384"===e)l=832,a=384;else if("SHA3-512"===e)l=576,a=512;else if("SHAKE128"===e)l=1344,a=-1,C=31,w=!0;else{if("SHAKE256"!==e)throw Error("Chosen SHA variant is not supported");l=1088,a=-1,C=31,w=!0}h=function(e,t,r,n,o){var i,a=C,s=[],c=(r=l)>>>5,u=0,d=t>>>5;for(i=0;i<d&&t>=r;i+=c)n=F(e.slice(i,i+c),n),t-=r;for(e=e.slice(i),t%=r;e.length<c;)e.push(0);for(e[(i=t>>>3)>>2]^=a<<i%4*8,e[c-1]^=2147483648,n=F(e,n);32*s.length<o&&(e=n[u%5][u/5|0],s.push(e.b),!(32*s.length>=o));)s.push(e.a),0==64*(u+=1)%r&&F(null,n);return s}}i=f(t,n,M),o=j(e),this.setHMACKey=function(t,r,i){var s;if(!0===_)throw Error("HMAC key already set");if(!0===R)throw Error("Cannot set HMAC key after calling update");if(!0===w)throw Error("SHAKE is not supported for HMAC");if(t=(r=f(r,n=(i||{}).encoding||"UTF8",M)(t)).binLen,r=r.value,i=(s=l>>>3)/4-1,s<t/8){for(r=h(r,t,0,j(e),a);r.length<=i;)r.push(0);r[i]&=4294967040}else if(s>t/8){for(;r.length<=i;)r.push(0);r[i]&=4294967040}for(t=0;t<=i;t+=1)S[t]=909522486^r[t],T[t]=1549556828^r[t];o=m(S,o),y=l,_=!0},this.update=function(e){var t,r,n,a=0,s=l>>>5;for(e=(t=i(e,b,E)).binLen,r=t.value,t=e>>>5,n=0;n<t;n+=s)a+l<=e&&(o=m(r.slice(n,n+s),o),a+=l);y+=a,b=r.slice(a>>>5),E=e%l,R=!0},this.getHash=function(t,r){var n,i,f,l;if(!0===_)throw Error("Cannot call getHash after setting HMAC key");if(f=p(r),!0===w){if(-1===f.shakeLen)throw Error("shakeLen must be specified in options");a=f.shakeLen}switch(t){case"HEX":n=function(e){return s(e,a,M,f)};break;case"B64":n=function(e){return c(e,a,M,f)};break;case"BYTES":n=function(e){return u(e,a,M)};break;case"ARRAYBUFFER":try{i=new ArrayBuffer(0)}catch(e){throw Error("ARRAYBUFFER not supported by this environment")}n=function(e){return d(e,a,M)};break;default:throw Error("format must be HEX, B64, BYTES, or ARRAYBUFFER")}for(l=h(b.slice(),E,y,v(o),a),i=1;i<g;i+=1)!0===w&&0!=a%32&&(l[l.length-1]&=16777215>>>24-a%32),l=h(l,a,0,j(e),a);return n(l)},this.getHMAC=function(t,r){var n,i,f,g;if(!1===_)throw Error("Cannot call getHMAC without first setting HMAC key");switch(f=p(r),t){case"HEX":n=function(e){return s(e,a,M,f)};break;case"B64":n=function(e){return c(e,a,M,f)};break;case"BYTES":n=function(e){return u(e,a,M)};break;case"ARRAYBUFFER":try{n=new ArrayBuffer(0)}catch(e){throw Error("ARRAYBUFFER not supported by this environment")}n=function(e){return d(e,a,M)};break;default:throw Error("outputFormat must be HEX, B64, BYTES, or ARRAYBUFFER")}return i=h(b.slice(),E,y,v(o),a),g=m(T,j(e)),n(g=h(i,a,l,g,a))}}function a(e,t){this.a=e,this.b=t}function s(e,t,r,n){var o,i,a,s="";for(t/=8,a=-1===r?3:0,o=0;o<t;o+=1)i=e[o>>>2]>>>8*(a+o%4*r),s+="0123456789abcdef".charAt(i>>>4&15)+"0123456789abcdef".charAt(15&i);return n.outputUpper?s.toUpperCase():s}function c(e,t,r,n){var o,i,a,s,c="",u=t/8;for(s=-1===r?3:0,o=0;o<u;o+=3)for(i=o+1<u?e[o+1>>>2]:0,a=o+2<u?e[o+2>>>2]:0,a=(e[o>>>2]>>>8*(s+o%4*r)&255)<<16|(i>>>8*(s+(o+1)%4*r)&255)<<8|a>>>8*(s+(o+2)%4*r)&255,i=0;4>i;i+=1)c+=8*o+6*i<=t?"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(a>>>6*(3-i)&63):n.b64Pad;return c}function u(e,t,r){var n,o,i,a="";for(t/=8,i=-1===r?3:0,n=0;n<t;n+=1)o=e[n>>>2]>>>8*(i+n%4*r)&255,a+=String.fromCharCode(o);return a}function d(e,t,r){t/=8;var n,o,i,a=new ArrayBuffer(t);for(i=new Uint8Array(a),o=-1===r?3:0,n=0;n<t;n+=1)i[n]=e[n>>>2]>>>8*(o+n%4*r)&255;return a}function p(e){var t={outputUpper:!1,b64Pad:"=",shakeLen:-1};if(e=e||{},t.outputUpper=e.outputUpper||!1,!0===e.hasOwnProperty("b64Pad")&&(t.b64Pad=e.b64Pad),!0===e.hasOwnProperty("shakeLen")){if(0!=e.shakeLen%8)throw Error("shakeLen must be a multiple of 8");t.shakeLen=e.shakeLen}if("boolean"!=typeof t.outputUpper)throw Error("Invalid outputUpper formatting option");if("string"!=typeof t.b64Pad)throw Error("Invalid b64Pad formatting option");return t}function f(e,t,r){switch(t){case"UTF8":case"UTF16BE":case"UTF16LE":break;default:throw Error("encoding must be UTF8, UTF16BE, or UTF16LE")}switch(e){case"HEX":e=function(e,t,n){var o,i,a,s,c,u,d=e.length;if(0!=d%2)throw Error("String of HEX type must be in byte increments");for(t=t||[0],c=(n=n||0)>>>3,u=-1===r?3:0,o=0;o<d;o+=2){if(i=parseInt(e.substr(o,2),16),isNaN(i))throw Error("String of HEX type contains invalid characters");for(a=(s=(o>>>1)+c)>>>2;t.length<=a;)t.push(0);t[a]|=i<<8*(u+s%4*r)}return{value:t,binLen:4*d+n}};break;case"TEXT":e=function(e,n,o){var i,a,s,c,u,d,p,f,l=0;if(n=n||[0],u=(o=o||0)>>>3,"UTF8"===t)for(f=-1===r?3:0,s=0;s<e.length;s+=1)for(a=[],128>(i=e.charCodeAt(s))?a.push(i):2048>i?(a.push(192|i>>>6),a.push(128|63&i)):55296>i||57344<=i?a.push(224|i>>>12,128|i>>>6&63,128|63&i):(s+=1,i=65536+((1023&i)<<10|1023&e.charCodeAt(s)),a.push(240|i>>>18,128|i>>>12&63,128|i>>>6&63,128|63&i)),c=0;c<a.length;c+=1){for(d=(p=l+u)>>>2;n.length<=d;)n.push(0);n[d]|=a[c]<<8*(f+p%4*r),l+=1}else if("UTF16BE"===t||"UTF16LE"===t)for(f=-1===r?2:0,a="UTF16LE"===t&&1!==r||"UTF16LE"!==t&&1===r,s=0;s<e.length;s+=1){for(i=e.charCodeAt(s),!0===a&&(i=(c=255&i)<<8|i>>>8),d=(p=l+u)>>>2;n.length<=d;)n.push(0);n[d]|=i<<8*(f+p%4*r),l+=2}return{value:n,binLen:8*l+o}};break;case"B64":e=function(e,t,n){var o,i,a,s,c,u,d,p,f=0;if(-1===e.search(/^[a-zA-Z0-9=+\/]+$/))throw Error("Invalid character in base-64 string");if(i=e.indexOf("="),e=e.replace(/\=/g,""),-1!==i&&i<e.length)throw Error("Invalid '=' found in base-64 string");for(t=t||[0],u=(n=n||0)>>>3,p=-1===r?3:0,i=0;i<e.length;i+=4){for(c=e.substr(i,4),a=s=0;a<c.length;a+=1)s|=(o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".indexOf(c[a]))<<18-6*a;for(a=0;a<c.length-1;a+=1){for(o=(d=f+u)>>>2;t.length<=o;)t.push(0);t[o]|=(s>>>16-8*a&255)<<8*(p+d%4*r),f+=1}}return{value:t,binLen:8*f+n}};break;case"BYTES":e=function(e,t,n){var o,i,a,s,c,u;for(t=t||[0],a=(n=n||0)>>>3,u=-1===r?3:0,i=0;i<e.length;i+=1)o=e.charCodeAt(i),s=(c=i+a)>>>2,t.length<=s&&t.push(0),t[s]|=o<<8*(u+c%4*r);return{value:t,binLen:8*e.length+n}};break;case"ARRAYBUFFER":try{e=new ArrayBuffer(0)}catch(e){throw Error("ARRAYBUFFER not supported by this environment")}e=function(e,t,n){var o,i,a,s,c,u;for(t=t||[0],i=(n=n||0)>>>3,c=-1===r?3:0,u=new Uint8Array(e),o=0;o<e.byteLength;o+=1)a=(s=o+i)>>>2,t.length<=a&&t.push(0),t[a]|=u[o]<<8*(c+s%4*r);return{value:t,binLen:8*e.byteLength+n}};break;default:throw Error("format must be HEX, TEXT, B64, BYTES, or ARRAYBUFFER")}return e}function l(e,t){return e<<t|e>>>32-t}function m(e,t){return 32<t?(t-=32,new a(e.b<<t|e.a>>>32-t,e.a<<t|e.b>>>32-t)):0!==t?new a(e.a<<t|e.b>>>32-t,e.b<<t|e.a>>>32-t):e}function h(e,t){return e>>>t|e<<32-t}function v(e,t){var r=null;r=new a(e.a,e.b);return 32>=t?new a(r.a>>>t|r.b<<32-t&4294967295,r.b>>>t|r.a<<32-t&4294967295):new a(r.b>>>t-32|r.a<<64-t&4294967295,r.a>>>t-32|r.b<<64-t&4294967295)}function g(e,t){return 32>=t?new a(e.a>>>t,e.b>>>t|e.a<<32-t&4294967295):new a(0,e.a>>>t-32)}function y(e,t,r){return e&t^~e&r}function b(e,t,r){return new a(e.a&t.a^~e.a&r.a,e.b&t.b^~e.b&r.b)}function E(e,t,r){return e&t^e&r^t&r}function _(e,t,r){return new a(e.a&t.a^e.a&r.a^t.a&r.a,e.b&t.b^e.b&r.b^t.b&r.b)}function S(e){return h(e,2)^h(e,13)^h(e,22)}function T(e){var t=v(e,28),r=v(e,34);return e=v(e,39),new a(t.a^r.a^e.a,t.b^r.b^e.b)}function R(e){return h(e,6)^h(e,11)^h(e,25)}function w(e){var t=v(e,14),r=v(e,18);return e=v(e,41),new a(t.a^r.a^e.a,t.b^r.b^e.b)}function M(e){return h(e,7)^h(e,18)^e>>>3}function C(e){var t=v(e,1),r=v(e,8);return e=g(e,7),new a(t.a^r.a^e.a,t.b^r.b^e.b)}function P(e){return h(e,17)^h(e,19)^e>>>10}function O(e){var t=v(e,19),r=v(e,61);return e=g(e,6),new a(t.a^r.a^e.a,t.b^r.b^e.b)}function A(e,t){var r=(65535&e)+(65535&t);return((e>>>16)+(t>>>16)+(r>>>16)&65535)<<16|65535&r}function I(e,t,r,n){var o=(65535&e)+(65535&t)+(65535&r)+(65535&n);return((e>>>16)+(t>>>16)+(r>>>16)+(n>>>16)+(o>>>16)&65535)<<16|65535&o}function k(e,t,r,n,o){var i=(65535&e)+(65535&t)+(65535&r)+(65535&n)+(65535&o);return((e>>>16)+(t>>>16)+(r>>>16)+(n>>>16)+(o>>>16)+(i>>>16)&65535)<<16|65535&i}function N(e,t){var r,n,o;return r=(65535&e.b)+(65535&t.b),o=(65535&(n=(e.b>>>16)+(t.b>>>16)+(r>>>16)))<<16|65535&r,r=(65535&e.a)+(65535&t.a)+(n>>>16),new a((65535&(n=(e.a>>>16)+(t.a>>>16)+(r>>>16)))<<16|65535&r,o)}function x(e,t,r,n){var o,i,s;return o=(65535&e.b)+(65535&t.b)+(65535&r.b)+(65535&n.b),s=(65535&(i=(e.b>>>16)+(t.b>>>16)+(r.b>>>16)+(n.b>>>16)+(o>>>16)))<<16|65535&o,o=(65535&e.a)+(65535&t.a)+(65535&r.a)+(65535&n.a)+(i>>>16),new a((65535&(i=(e.a>>>16)+(t.a>>>16)+(r.a>>>16)+(n.a>>>16)+(o>>>16)))<<16|65535&o,s)}function U(e,t,r,n,o){var i,s,c;return i=(65535&e.b)+(65535&t.b)+(65535&r.b)+(65535&n.b)+(65535&o.b),c=(65535&(s=(e.b>>>16)+(t.b>>>16)+(r.b>>>16)+(n.b>>>16)+(o.b>>>16)+(i>>>16)))<<16|65535&i,i=(65535&e.a)+(65535&t.a)+(65535&r.a)+(65535&n.a)+(65535&o.a)+(s>>>16),new a((65535&(s=(e.a>>>16)+(t.a>>>16)+(r.a>>>16)+(n.a>>>16)+(o.a>>>16)+(i>>>16)))<<16|65535&i,c)}function L(e,t){return new a(e.a^t.a,e.b^t.b)}function j(e){var t,r=[];if("SHA-1"===e)r=[1732584193,4023233417,2562383102,271733878,3285377520];else if(0===e.lastIndexOf("SHA-",0))switch(r=[3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428],t=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225],e){case"SHA-224":break;case"SHA-256":r=t;break;case"SHA-384":r=[new a(3418070365,r[0]),new a(1654270250,r[1]),new a(2438529370,r[2]),new a(355462360,r[3]),new a(1731405415,r[4]),new a(41048885895,r[5]),new a(3675008525,r[6]),new a(1203062813,r[7])];break;case"SHA-512":r=[new a(t[0],4089235720),new a(t[1],2227873595),new a(t[2],4271175723),new a(t[3],1595750129),new a(t[4],2917565137),new a(t[5],725511199),new a(t[6],4215389547),new a(t[7],327033209)];break;default:throw Error("Unknown SHA variant")}else{if(0!==e.lastIndexOf("SHA3-",0)&&0!==e.lastIndexOf("SHAKE",0))throw Error("No SHA variants supported");for(e=0;5>e;e+=1)r[e]=[new a(0,0),new a(0,0),new a(0,0),new a(0,0),new a(0,0)]}return r}function D(e,t){var r,n,o,i,a,s,c,u=[];for(r=t[0],n=t[1],o=t[2],i=t[3],a=t[4],c=0;80>c;c+=1)u[c]=16>c?e[c]:l(u[c-3]^u[c-8]^u[c-14]^u[c-16],1),s=20>c?k(l(r,5),n&o^~n&i,a,1518500249,u[c]):40>c?k(l(r,5),n^o^i,a,1859775393,u[c]):60>c?k(l(r,5),E(n,o,i),a,2400959708,u[c]):k(l(r,5),n^o^i,a,3395469782,u[c]),a=i,i=o,o=l(n,30),n=r,r=s;return t[0]=A(r,t[0]),t[1]=A(n,t[1]),t[2]=A(o,t[2]),t[3]=A(i,t[3]),t[4]=A(a,t[4]),t}function V(e,t,r,n){var o;for(o=15+(t+65>>>9<<4);e.length<=o;)e.push(0);for(e[t>>>5]|=128<<24-t%32,t+=r,e[o]=4294967295&t,e[o-1]=t/4294967296|0,t=e.length,o=0;o<t;o+=16)n=D(e.slice(o,o+16),n);return n}function B(e,t,r){var n,o,i,s,c,u,d,p,f,l,m,h,v,g,L,j,D,V,B,F,G,W,X,J=[];if("SHA-224"===r||"SHA-256"===r)l=64,h=1,W=Number,v=A,g=I,L=k,j=M,D=P,V=S,B=R,G=E,F=y,X=H;else{if("SHA-384"!==r&&"SHA-512"!==r)throw Error("Unexpected error in SHA-2 implementation");l=80,h=2,W=a,v=N,g=x,L=U,j=C,D=O,V=T,B=w,G=_,F=b,X=Y}for(r=t[0],n=t[1],o=t[2],i=t[3],s=t[4],c=t[5],u=t[6],d=t[7],m=0;m<l;m+=1)16>m?(f=m*h,p=e.length<=f?0:e[f],f=e.length<=f+1?0:e[f+1],J[m]=new W(p,f)):J[m]=g(D(J[m-2]),J[m-7],j(J[m-15]),J[m-16]),p=L(d,B(s),F(s,c,u),X[m],J[m]),f=v(V(r),G(r,n,o)),d=u,u=c,c=s,s=v(i,p),i=o,o=n,n=r,r=v(p,f);return t[0]=v(r,t[0]),t[1]=v(n,t[1]),t[2]=v(o,t[2]),t[3]=v(i,t[3]),t[4]=v(s,t[4]),t[5]=v(c,t[5]),t[6]=v(u,t[6]),t[7]=v(d,t[7]),t}function F(e,t){var r,n,o,i,s=[],c=[];if(null!==e)for(n=0;n<e.length;n+=2)t[(n>>>1)%5][(n>>>1)/5|0]=L(t[(n>>>1)%5][(n>>>1)/5|0],new a(e[n+1],e[n]));for(r=0;24>r;r+=1){for(i=j("SHA3-"),n=0;5>n;n+=1){o=t[n][0];var u=t[n][1],d=t[n][2],p=t[n][3],f=t[n][4];s[n]=new a(o.a^u.a^d.a^p.a^f.a,o.b^u.b^d.b^p.b^f.b)}for(n=0;5>n;n+=1)c[n]=L(s[(n+4)%5],m(s[(n+1)%5],1));for(n=0;5>n;n+=1)for(o=0;5>o;o+=1)t[n][o]=L(t[n][o],c[n]);for(n=0;5>n;n+=1)for(o=0;5>o;o+=1)i[o][(2*n+3*o)%5]=m(t[n][o],G[n][o]);for(n=0;5>n;n+=1)for(o=0;5>o;o+=1)t[n][o]=L(i[n][o],new a(~i[(n+1)%5][o].a&i[(n+2)%5][o].a,~i[(n+1)%5][o].b&i[(n+2)%5][o].b));t[0][0]=L(t[0][0],W[r])}return t}var H,Y,G,W;Y=[new a((H=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298])[0],3609767458),new a(H[1],602891725),new a(H[2],3964484399),new a(H[3],2173295548),new a(H[4],4081628472),new a(H[5],3053834265),new a(H[6],2937671579),new a(H[7],3664609560),new a(H[8],2734883394),new a(H[9],1164996542),new a(H[10],1323610764),new a(H[11],3590304994),new a(H[12],4068182383),new a(H[13],991336113),new a(H[14],633803317),new a(H[15],3479774868),new a(H[16],2666613458),new a(H[17],944711139),new a(H[18],2341262773),new a(H[19],2007800933),new a(H[20],1495990901),new a(H[21],1856431235),new a(H[22],3175218132),new a(H[23],2198950837),new a(H[24],3999719339),new a(H[25],766784016),new a(H[26],2566594879),new a(H[27],3203337956),new a(H[28],1034457026),new a(H[29],2466948901),new a(H[30],3758326383),new a(H[31],168717936),new a(H[32],1188179964),new a(H[33],1546045734),new a(H[34],1522805485),new a(H[35],2643833823),new a(H[36],2343527390),new a(H[37],1014477480),new a(H[38],1206759142),new a(H[39],344077627),new a(H[40],1290863460),new a(H[41],3158454273),new a(H[42],3505952657),new a(H[43],106217008),new a(H[44],3606008344),new a(H[45],1432725776),new a(H[46],1467031594),new a(H[47],851169720),new a(H[48],3100823752),new a(H[49],1363258195),new a(H[50],3750685593),new a(H[51],3785050280),new a(H[52],3318307427),new a(H[53],3812723403),new a(H[54],2003034995),new a(H[55],3602036899),new a(H[56],1575990012),new a(H[57],1125592928),new a(H[58],2716904306),new a(H[59],442776044),new a(H[60],593698344),new a(H[61],3733110249),new a(H[62],2999351573),new a(H[63],3815920427),new a(3391569614,3928383900),new a(3515267271,566280711),new a(3940187606,3454069534),new a(4118630271,4000239992),new a(116418474,1914138554),new a(174292421,2731055270),new a(289380356,3203993006),new a(460393269,320620315),new a(685471733,587496836),new a(852142971,1086792851),new a(1017036298,365543100),new a(1126000580,2618297676),new a(1288033470,3409855158),new a(1501505948,4234509866),new a(1607167915,987167468),new a(1816402316,1246189591)],W=[new a(0,1),new a(0,32898),new a(2147483648,32906),new a(2147483648,2147516416),new a(0,32907),new a(0,2147483649),new a(2147483648,2147516545),new a(2147483648,32777),new a(0,138),new a(0,136),new a(0,2147516425),new a(0,2147483658),new a(0,2147516555),new a(2147483648,139),new a(2147483648,32905),new a(2147483648,32771),new a(2147483648,32770),new a(2147483648,128),new a(0,32778),new a(2147483648,2147483658),new a(2147483648,2147516545),new a(2147483648,32896),new a(0,2147483649),new a(2147483648,2147516424)],G=[[0,36,3,41,18],[1,44,10,45,2],[62,6,43,15,61],[28,55,25,21,56],[27,20,39,8,14]],void 0===(n=function(){return i}.call(t,r,t,e))||(e.exports=n)}()},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.randNum=function(e){for(var t="",r=0;r<e;++r)t+="0123456789".charAt(Math.floor(100*Math.random()%10));return t}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(2),o=r(6),i=1e3,a=function(e){function t(t){var r=e.call(this)||this;return r.timer=0,r.streamManager=t,r.timer=window.setInterval((function(){var e=r.compute();-1===e.up&&-1===e.down||r.emit("network-quality",e.up,e.down);var t=r.computeAudioQuality();-1!==t.bitRate&&r.emit("network-quality-audio",t)}),i),r}return n.__extends(t,e),t.prototype.destory=function(){window.clearInterval(this.timer),this.timer=0},t.prototype.compute=function(){var e=this.streamManager.getAllLocalStreams(),t=this.streamManager.getAllRemoteStreams();return{up:this.computeStreamsScore(e,!0),down:this.computeStreamsScore(t,!1)}},t.prototype.computeAudioQuality=function(){var e=this.streamManager.getAllLocalStreams(),t=[],r=[],n=[];e.forEach((function(e){if(e.audio&&!e.muteaudio){var o=e.getLastPeerConnectionStats();if(o){var i=e.getCurrentPeerConnectionStats(),a=Math.round((i.timestamp-o.timestamp)/1e3),s=i.audioOutputReports.bytesSent-o.audioOutputReports.bytesSent,c=i.audioOutputReports.packetsSent-o.audioOutputReports.packetsSent,u=i.audioOutputReports.packetsLost-o.audioOutputReports.packetsLost;if(s>0){var d=Math.round(8*s/a);t.push(d)}if(c>0&&u>=0){var p=Math.round(u/(c+u)*100);n.push(p)}else 0===c&&n.push(100);if(i.audioOutputReports.roundTripTime>=0){var f=Math.round(1e3*i.audioOutputReports.roundTripTime);r.push(f)}}}}));var o=-1,i=-1,a=-1;t.length>0&&(o=t.reduce((function(e,t){return e+=t}),0)/t.length);n.length>0&&(i=n.reduce((function(e,t){return e+=t}),0)/n.length);r.length>0&&(a=r.reduce((function(e,t){return e+=t}),0)/r.length);return{bitRate:o,lossRate:i,rtt:a}},t.prototype.computeStreamsScore=function(e,t){var r=this,n=-1;if(0===e.length)return n;var o=!1;if(e.forEach((function(e){switch(e.peerConnectionState){case"connected":o=!0}})),!o)return n=0;var i=e.map((function(e){var n=e.getLastPeerConnectionStats();if(n){var o=e.getCurrentPeerConnectionStats();return t?r.computeUpStreamScore(n,o):r.computeDownStreamScore(n,o)}})),a=i.reduce((function(e,t){return e+=t}),0);return n=a?a/i.length:-1},t.prototype.computeUpStreamScore=function(e,t){var r=0,n=0;if(t.audioOutputReports&&e.audioOutputReports){var o=t.audioOutputReports.packetsSent-e.audioOutputReports.packetsSent;r=(i=t.audioOutputReports.packetsLost-e.audioOutputReports.packetsLost)>=0&&o>0?Math.round(i/(o+i)*100):0,n=t.audioOutputReports.jitter}else if(t.videoOutputReports&&e.videoOutputReports){var i;o=t.videoOutputReports.packetsSent-e.videoOutputReports.packetsSent;r=(i=t.videoOutputReports.packetsLost-e.videoOutputReports.packetsLost)>=0&&o>0?Math.round(i/(o+i)*100):0,n=t.videoOutputReports.jitter}var a=0;return t.candidatePairReports&&(a=Math.round(1e3*t.candidatePairReports.currentRoundTripTime)||0),this.computeScore(a,n,r)},t.prototype.computeDownStreamScore=function(e,t){var r=0,n=0;if(t.audioInputReports&&e.audioInputReports){var o=t.audioInputReports.packetsReceived-e.audioInputReports.packetsReceived;r=(i=t.audioInputReports.packetsLost-e.audioInputReports.packetsLost)>=0&&o>0?Math.round(i/(o+i)*100):0,n=t.audioInputReports.jitter}if(t.videoInputReports&&e.videoInputReports){var i;o=t.videoInputReports.packetsReceived-e.videoInputReports.packetsReceived;r=(i=t.videoInputReports.packetsLost-e.videoInputReports.packetsLost)>=0&&o>0?Math.round(i/(o+i)*100):0}var a=0;return t.candidatePairReports&&(a=Math.round(1e3*t.candidatePairReports.currentRoundTripTime)||0),this.computeScore(a,n,r)},t.prototype.computeScore=function(e,t,r){var n=95,o=e+2*t+10;return o<200?n-=o/40:o>=200&&(n-=(o-120)/10),n-=2.5*r},t.convert2Quality=function(e){return-1===e?"0":e>=90?"1":e>=80&&e<90?"2":e>=70&&e<80?"3":e>=60&&e<70?"4":e>=50&&e<60?"5":"6"},t}(o.EventEmitter);t.NetworkQualityEvaluator=a},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(4),o=function(){function e(e,t){this.timer=0,this.interval=2e3,this.streamManager=e,t&&(this.interval=t)}return e.prototype.compute=function(){return this.streamManager.getAllRemoteStreams().filter((function(e){return e.audio})).map((function(e){return{uid:e.userId,sid:e.streamId,mediaType:e.mediaType===n.ENUM_MEDIA_TYPE.desktop?"screen":"camera",volume:Math.floor(100*e.getAudioVolume())}})).sort((function(e,t){return t.volume-e.volume}))},e.prototype.start=function(e,t){var r=this;this.timer&&window.clearInterval(this.timer),t&&(this.interval=t),this.timer=window.setInterval((function(){e(r.compute())}),this.interval)},e.prototype.destroy=function(){this.timer&&window.clearInterval(this.timer),this.timer=0},e}();t.default=o},function(e,t,r){"use strict";function n(e,t){return"string"!=typeof e?!t&&null==e:!(!e&&t)}function o(e,t){return"number"!=typeof e?!t&&null==e:!(e<0||!Number.isInteger(e))}function i(e){return n(e,!0)}function a(e){return"number"==typeof e&&!(e<0||e>100||!Number.isInteger(e))}Object.defineProperty(t,"__esModule",{value:!0}),t.isNil=function(e){return null==e},t.isValidString=n,t.isValidNumber=o,t.isValidStreamId=i,t.isValidVolume=a,t.streamValidator={isValidStreamId:i},t.effectValidator={isValidId:function(e){return"number"==typeof e&&!!Number.isInteger(e)},isValidFilePath:function(e,t){return n(e,t)},isValidPlayTime:function(e,t){return o(e,t)},isValidVolume:a,isValidEffectOptions:function(e){return"object"==typeof e&&(!!e&&(!!this.isValidId(e.effectId)&&(!!this.isValidFilePath(e.filePath)&&!!this.isValidPlayTime(e.playTime))))},isValidEffectVolumeOptions:function(e){return"object"==typeof e&&(!!e&&(!!this.isValidId(e.effectId)&&!!this.isVolume(e.volume)))}}},function(e,t,r){"use strict";r.r(t);var n={};r.r(n),r.d(n,"shimGetUserMedia",(function(){return _})),r.d(n,"shimGetDisplayMedia",(function(){return S})),r.d(n,"shimMediaStream",(function(){return T})),r.d(n,"shimOnTrack",(function(){return R})),r.d(n,"shimGetSendersWithDtmf",(function(){return w})),r.d(n,"shimGetStats",(function(){return M})),r.d(n,"shimSenderReceiverGetStats",(function(){return C})),r.d(n,"shimAddTrackRemoveTrackWithNative",(function(){return P})),r.d(n,"shimAddTrackRemoveTrack",(function(){return O})),r.d(n,"shimPeerConnection",(function(){return A})),r.d(n,"fixNegotiationNeeded",(function(){return I}));var o={};r.r(o),r.d(o,"shimGetUserMedia",(function(){return x})),r.d(o,"shimGetDisplayMedia",(function(){return U})),r.d(o,"shimPeerConnection",(function(){return L})),r.d(o,"shimReplaceTrack",(function(){return j}));var i={};r.r(i),r.d(i,"shimGetUserMedia",(function(){return D})),r.d(i,"shimGetDisplayMedia",(function(){return V})),r.d(i,"shimOnTrack",(function(){return B})),r.d(i,"shimPeerConnection",(function(){return F})),r.d(i,"shimSenderGetStats",(function(){return H})),r.d(i,"shimReceiverGetStats",(function(){return Y})),r.d(i,"shimRemoveStream",(function(){return G})),r.d(i,"shimRTCDataChannel",(function(){return W})),r.d(i,"shimAddTransceiver",(function(){return X})),r.d(i,"shimCreateOffer",(function(){return J})),r.d(i,"shimCreateAnswer",(function(){return q}));var a={};r.r(a),r.d(a,"shimLocalStreamsAPI",(function(){return z})),r.d(a,"shimRemoteStreamsAPI",(function(){return K})),r.d(a,"shimCallbacksAPI",(function(){return Q})),r.d(a,"shimGetUserMedia",(function(){return $})),r.d(a,"shimConstraints",(function(){return Z})),r.d(a,"shimRTCIceServerUrls",(function(){return ee})),r.d(a,"shimTrackEventTransceiver",(function(){return te})),r.d(a,"shimCreateOfferLegacy",(function(){return re}));var s={};r.r(s),r.d(s,"shimRTCIceCandidate",(function(){return ie})),r.d(s,"shimMaxMessageSize",(function(){return ae})),r.d(s,"shimSendThrowTypeError",(function(){return se})),r.d(s,"shimConnectionState",(function(){return ce})),r.d(s,"removeAllowExtmapMixed",(function(){return ue}));let c=!0,u=!0;function d(e,t,r){const n=e.match(t);return n&&n.length>=r&&parseInt(n[r],10)}function p(e,t,r){if(!e.RTCPeerConnection)return;const n=e.RTCPeerConnection.prototype,o=n.addEventListener;n.addEventListener=function(e,n){if(e!==t)return o.apply(this,arguments);const i=e=>{const t=r(e);t&&n(t)};return this._eventMap=this._eventMap||{},this._eventMap[n]=i,o.apply(this,[e,i])};const i=n.removeEventListener;n.removeEventListener=function(e,r){if(e!==t||!this._eventMap||!this._eventMap[r])return i.apply(this,arguments);const n=this._eventMap[r];return delete this._eventMap[r],i.apply(this,[e,n])},Object.defineProperty(n,"on"+t,{get(){return this["_on"+t]},set(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})}function f(e){return"boolean"!=typeof e?new Error("Argument type: "+typeof e+". Please use a boolean."):(c=e,e?"adapter.js logging disabled":"adapter.js logging enabled")}function l(e){return"boolean"!=typeof e?new Error("Argument type: "+typeof e+". Please use a boolean."):(u=!e,"adapter.js deprecation warnings "+(e?"disabled":"enabled"))}function m(){if("object"==typeof window){if(c)return;"undefined"!=typeof console&&"function"==typeof console.log&&console.log.apply(console,arguments)}}function h(e,t){u&&console.warn(e+" is deprecated, please use "+t+" instead.")}function v(e){const{navigator:t}=e,r={browser:null,version:null};if(void 0===e||!e.navigator)return r.browser="Not a browser.",r;if(t.mozGetUserMedia)r.browser="firefox",r.version=d(t.userAgent,/Firefox\/(\d+)\./,1);else if(t.webkitGetUserMedia||!1===e.isSecureContext&&e.webkitRTCPeerConnection&&!e.RTCIceGatherer)r.browser="chrome",r.version=d(t.userAgent,/Chrom(e|ium)\/(\d+)\./,2);else if(t.mediaDevices&&t.userAgent.match(/Edge\/(\d+).(\d+)$/))r.browser="edge",r.version=d(t.userAgent,/Edge\/(\d+).(\d+)$/,2);else{if(!e.RTCPeerConnection||!t.userAgent.match(/AppleWebKit\/(\d+)\./))return r.browser="Not a supported browser.",r;r.browser="safari",r.version=d(t.userAgent,/AppleWebKit\/(\d+)\./,1),r.supportsUnifiedPlan=e.RTCRtpTransceiver&&"currentDirection"in e.RTCRtpTransceiver.prototype}return r}function g(e){return"[object Object]"===Object.prototype.toString.call(e)}function y(e){return g(e)?Object.keys(e).reduce((function(t,r){const n=g(e[r]),o=n?y(e[r]):e[r],i=n&&!Object.keys(o).length;return void 0===o||i?t:Object.assign(t,{[r]:o})}),{}):e}function b(e,t,r){const n=r?"outbound-rtp":"inbound-rtp",o=new Map;if(null===t)return o;const i=[];return e.forEach(e=>{"track"===e.type&&e.trackIdentifier===t.id&&i.push(e)}),i.forEach(t=>{e.forEach(r=>{r.type===n&&r.trackId===t.id&&function e(t,r,n){r&&!n.has(r.id)&&(n.set(r.id,r),Object.keys(r).forEach(o=>{o.endsWith("Id")?e(t,t.get(r[o]),n):o.endsWith("Ids")&&r[o].forEach(r=>{e(t,t.get(r),n)})}))}(e,r,o)})}),o}const E=m;function _(e){const t=e&&e.navigator;if(!t.mediaDevices)return;const r=v(e),n=function(e){if("object"!=typeof e||e.mandatory||e.optional)return e;const t={};return Object.keys(e).forEach(r=>{if("require"===r||"advanced"===r||"mediaSource"===r)return;const n="object"==typeof e[r]?e[r]:{ideal:e[r]};void 0!==n.exact&&"number"==typeof n.exact&&(n.min=n.max=n.exact);const o=function(e,t){return e?e+t.charAt(0).toUpperCase()+t.slice(1):"deviceId"===t?"sourceId":t};if(void 0!==n.ideal){t.optional=t.optional||[];let e={};"number"==typeof n.ideal?(e[o("min",r)]=n.ideal,t.optional.push(e),(e={})[o("max",r)]=n.ideal,t.optional.push(e)):(e[o("",r)]=n.ideal,t.optional.push(e))}void 0!==n.exact&&"number"!=typeof n.exact?(t.mandatory=t.mandatory||{},t.mandatory[o("",r)]=n.exact):["min","max"].forEach(e=>{void 0!==n[e]&&(t.mandatory=t.mandatory||{},t.mandatory[o(e,r)]=n[e])})}),e.advanced&&(t.optional=(t.optional||[]).concat(e.advanced)),t},o=function(e,o){if(r.version>=61)return o(e);if((e=JSON.parse(JSON.stringify(e)))&&"object"==typeof e.audio){const t=function(e,t,r){t in e&&!(r in e)&&(e[r]=e[t],delete e[t])};t((e=JSON.parse(JSON.stringify(e))).audio,"autoGainControl","googAutoGainControl"),t(e.audio,"noiseSuppression","googNoiseSuppression"),e.audio=n(e.audio)}if(e&&"object"==typeof e.video){let i=e.video.facingMode;i=i&&("object"==typeof i?i:{ideal:i});const a=r.version<66;if(i&&("user"===i.exact||"environment"===i.exact||"user"===i.ideal||"environment"===i.ideal)&&(!t.mediaDevices.getSupportedConstraints||!t.mediaDevices.getSupportedConstraints().facingMode||a)){let r;if(delete e.video.facingMode,"environment"===i.exact||"environment"===i.ideal?r=["back","rear"]:"user"!==i.exact&&"user"!==i.ideal||(r=["front"]),r)return t.mediaDevices.enumerateDevices().then(t=>{let a=(t=t.filter(e=>"videoinput"===e.kind)).find(e=>r.some(t=>e.label.toLowerCase().includes(t)));return!a&&t.length&&r.includes("back")&&(a=t[t.length-1]),a&&(e.video.deviceId=i.exact?{exact:a.deviceId}:{ideal:a.deviceId}),e.video=n(e.video),E("chrome: "+JSON.stringify(e)),o(e)})}e.video=n(e.video)}return E("chrome: "+JSON.stringify(e)),o(e)},i=function(e){return r.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(){return this.name+(this.message&&": ")+this.message}}};if(t.getUserMedia=function(e,r,n){o(e,e=>{t.webkitGetUserMedia(e,r,e=>{n&&n(i(e))})})}.bind(t),t.mediaDevices.getUserMedia){const e=t.mediaDevices.getUserMedia.bind(t.mediaDevices);t.mediaDevices.getUserMedia=function(t){return o(t,t=>e(t).then(e=>{if(t.audio&&!e.getAudioTracks().length||t.video&&!e.getVideoTracks().length)throw e.getTracks().forEach(e=>{e.stop()}),new DOMException("","NotFoundError");return e},e=>Promise.reject(i(e))))}}}function S(e,t){e.navigator.mediaDevices&&"getDisplayMedia"in e.navigator.mediaDevices||e.navigator.mediaDevices&&("function"==typeof t?e.navigator.mediaDevices.getDisplayMedia=function(r){return t(r).then(t=>{const n=r.video&&r.video.width,o=r.video&&r.video.height,i=r.video&&r.video.frameRate;return r.video={mandatory:{chromeMediaSource:"desktop",chromeMediaSourceId:t,maxFrameRate:i||3}},n&&(r.video.mandatory.maxWidth=n),o&&(r.video.mandatory.maxHeight=o),e.navigator.mediaDevices.getUserMedia(r)})}:console.error("shimGetDisplayMedia: getSourceId argument is not a function"))}function T(e){e.MediaStream=e.MediaStream||e.webkitMediaStream}function R(e){if("object"!=typeof e||!e.RTCPeerConnection||"ontrack"in e.RTCPeerConnection.prototype)p(e,"track",e=>(e.transceiver||Object.defineProperty(e,"transceiver",{value:{receiver:e.receiver}}),e));else{Object.defineProperty(e.RTCPeerConnection.prototype,"ontrack",{get(){return this._ontrack},set(e){this._ontrack&&this.removeEventListener("track",this._ontrack),this.addEventListener("track",this._ontrack=e)},enumerable:!0,configurable:!0});const t=e.RTCPeerConnection.prototype.setRemoteDescription;e.RTCPeerConnection.prototype.setRemoteDescription=function(){return this._ontrackpoly||(this._ontrackpoly=t=>{t.stream.addEventListener("addtrack",r=>{let n;n=e.RTCPeerConnection.prototype.getReceivers?this.getReceivers().find(e=>e.track&&e.track.id===r.track.id):{track:r.track};const o=new Event("track");o.track=r.track,o.receiver=n,o.transceiver={receiver:n},o.streams=[t.stream],this.dispatchEvent(o)}),t.stream.getTracks().forEach(r=>{let n;n=e.RTCPeerConnection.prototype.getReceivers?this.getReceivers().find(e=>e.track&&e.track.id===r.id):{track:r};const o=new Event("track");o.track=r,o.receiver=n,o.transceiver={receiver:n},o.streams=[t.stream],this.dispatchEvent(o)})},this.addEventListener("addstream",this._ontrackpoly)),t.apply(this,arguments)}}}function w(e){if("object"==typeof e&&e.RTCPeerConnection&&!("getSenders"in e.RTCPeerConnection.prototype)&&"createDTMFSender"in e.RTCPeerConnection.prototype){const 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()};const r=e.RTCPeerConnection.prototype.addTrack;e.RTCPeerConnection.prototype.addTrack=function(e,n){let o=r.apply(this,arguments);return o||(o=t(this,e),this._senders.push(o)),o};const n=e.RTCPeerConnection.prototype.removeTrack;e.RTCPeerConnection.prototype.removeTrack=function(e){n.apply(this,arguments);const t=this._senders.indexOf(e);-1!==t&&this._senders.splice(t,1)}}const r=e.RTCPeerConnection.prototype.addStream;e.RTCPeerConnection.prototype.addStream=function(e){this._senders=this._senders||[],r.apply(this,[e]),e.getTracks().forEach(e=>{this._senders.push(t(this,e))})};const n=e.RTCPeerConnection.prototype.removeStream;e.RTCPeerConnection.prototype.removeStream=function(e){this._senders=this._senders||[],n.apply(this,[e]),e.getTracks().forEach(e=>{const t=this._senders.find(t=>t.track===e);t&&this._senders.splice(this._senders.indexOf(t),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)){const t=e.RTCPeerConnection.prototype.getSenders;e.RTCPeerConnection.prototype.getSenders=function(){const e=t.apply(this,[]);return e.forEach(e=>e._pc=this),e},Object.defineProperty(e.RTCRtpSender.prototype,"dtmf",{get(){return void 0===this._dtmf&&("audio"===this.track.kind?this._dtmf=this._pc.createDTMFSender(this.track):this._dtmf=null),this._dtmf}})}}function M(e){if(!e.RTCPeerConnection)return;const t=e.RTCPeerConnection.prototype.getStats;e.RTCPeerConnection.prototype.getStats=function(){const[e,r,n]=arguments;if(arguments.length>0&&"function"==typeof e)return t.apply(this,arguments);if(0===t.length&&(0===arguments.length||"function"!=typeof e))return t.apply(this,[]);const o=function(e){const t={};return e.result().forEach(e=>{const r={id:e.id,timestamp:e.timestamp,type:{localcandidate:"local-candidate",remotecandidate:"remote-candidate"}[e.type]||e.type};e.names().forEach(t=>{r[t]=e.stat(t)}),t[r.id]=r}),t},i=function(e){return new Map(Object.keys(e).map(t=>[t,e[t]]))};if(arguments.length>=2){const n=function(e){r(i(o(e)))};return t.apply(this,[n,e])}return new Promise((e,r)=>{t.apply(this,[function(t){e(i(o(t)))},r])}).then(r,n)}}function C(e){if(!("object"==typeof e&&e.RTCPeerConnection&&e.RTCRtpSender&&e.RTCRtpReceiver))return;if(!("getStats"in e.RTCRtpSender.prototype)){const t=e.RTCPeerConnection.prototype.getSenders;t&&(e.RTCPeerConnection.prototype.getSenders=function(){const e=t.apply(this,[]);return e.forEach(e=>e._pc=this),e});const r=e.RTCPeerConnection.prototype.addTrack;r&&(e.RTCPeerConnection.prototype.addTrack=function(){const e=r.apply(this,arguments);return e._pc=this,e}),e.RTCRtpSender.prototype.getStats=function(){const e=this;return this._pc.getStats().then(t=>b(t,e.track,!0))}}if(!("getStats"in e.RTCRtpReceiver.prototype)){const t=e.RTCPeerConnection.prototype.getReceivers;t&&(e.RTCPeerConnection.prototype.getReceivers=function(){const e=t.apply(this,[]);return e.forEach(e=>e._pc=this),e}),p(e,"track",e=>(e.receiver._pc=e.srcElement,e)),e.RTCRtpReceiver.prototype.getStats=function(){const e=this;return this._pc.getStats().then(t=>b(t,e.track,!1))}}if(!("getStats"in e.RTCRtpSender.prototype&&"getStats"in e.RTCRtpReceiver.prototype))return;const t=e.RTCPeerConnection.prototype.getStats;e.RTCPeerConnection.prototype.getStats=function(){if(arguments.length>0&&arguments[0]instanceof e.MediaStreamTrack){const e=arguments[0];let t,r,n;return this.getSenders().forEach(r=>{r.track===e&&(t?n=!0:t=r)}),this.getReceivers().forEach(t=>(t.track===e&&(r?n=!0:r=t),t.track===e)),n||t&&r?Promise.reject(new DOMException("There are more than one sender or receiver for the track.","InvalidAccessError")):t?t.getStats():r?r.getStats():Promise.reject(new DOMException("There is no sender or receiver for the track.","InvalidAccessError"))}return t.apply(this,arguments)}}function P(e){e.RTCPeerConnection.prototype.getLocalStreams=function(){return this._shimmedLocalStreams=this._shimmedLocalStreams||{},Object.keys(this._shimmedLocalStreams).map(e=>this._shimmedLocalStreams[e][0])};const t=e.RTCPeerConnection.prototype.addTrack;e.RTCPeerConnection.prototype.addTrack=function(e,r){if(!r)return t.apply(this,arguments);this._shimmedLocalStreams=this._shimmedLocalStreams||{};const n=t.apply(this,arguments);return this._shimmedLocalStreams[r.id]?-1===this._shimmedLocalStreams[r.id].indexOf(n)&&this._shimmedLocalStreams[r.id].push(n):this._shimmedLocalStreams[r.id]=[r,n],n};const r=e.RTCPeerConnection.prototype.addStream;e.RTCPeerConnection.prototype.addStream=function(e){this._shimmedLocalStreams=this._shimmedLocalStreams||{},e.getTracks().forEach(e=>{if(this.getSenders().find(t=>t.track===e))throw new DOMException("Track already exists.","InvalidAccessError")});const t=this.getSenders();r.apply(this,arguments);const n=this.getSenders().filter(e=>-1===t.indexOf(e));this._shimmedLocalStreams[e.id]=[e].concat(n)};const n=e.RTCPeerConnection.prototype.removeStream;e.RTCPeerConnection.prototype.removeStream=function(e){return this._shimmedLocalStreams=this._shimmedLocalStreams||{},delete this._shimmedLocalStreams[e.id],n.apply(this,arguments)};const o=e.RTCPeerConnection.prototype.removeTrack;e.RTCPeerConnection.prototype.removeTrack=function(e){return this._shimmedLocalStreams=this._shimmedLocalStreams||{},e&&Object.keys(this._shimmedLocalStreams).forEach(t=>{const r=this._shimmedLocalStreams[t].indexOf(e);-1!==r&&this._shimmedLocalStreams[t].splice(r,1),1===this._shimmedLocalStreams[t].length&&delete this._shimmedLocalStreams[t]}),o.apply(this,arguments)}}function O(e){if(!e.RTCPeerConnection)return;const t=v(e);if(e.RTCPeerConnection.prototype.addTrack&&t.version>=65)return P(e);const r=e.RTCPeerConnection.prototype.getLocalStreams;e.RTCPeerConnection.prototype.getLocalStreams=function(){const e=r.apply(this);return this._reverseStreams=this._reverseStreams||{},e.map(e=>this._reverseStreams[e.id])};const n=e.RTCPeerConnection.prototype.addStream;e.RTCPeerConnection.prototype.addStream=function(t){if(this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{},t.getTracks().forEach(e=>{if(this.getSenders().find(t=>t.track===e))throw new DOMException("Track already exists.","InvalidAccessError")}),!this._reverseStreams[t.id]){const r=new e.MediaStream(t.getTracks());this._streams[t.id]=r,this._reverseStreams[r.id]=t,t=r}n.apply(this,[t])};const o=e.RTCPeerConnection.prototype.removeStream;function i(e,t){let r=t.sdp;return Object.keys(e._reverseStreams||[]).forEach(t=>{const n=e._reverseStreams[t],o=e._streams[n.id];r=r.replace(new RegExp(o.id,"g"),n.id)}),new RTCSessionDescription({type:t.type,sdp:r})}function a(e,t){let r=t.sdp;return Object.keys(e._reverseStreams||[]).forEach(t=>{const n=e._reverseStreams[t],o=e._streams[n.id];r=r.replace(new RegExp(n.id,"g"),o.id)}),new RTCSessionDescription({type:t.type,sdp:r})}e.RTCPeerConnection.prototype.removeStream=function(e){this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{},o.apply(this,[this._streams[e.id]||e]),delete this._reverseStreams[this._streams[e.id]?this._streams[e.id].id:e.id],delete this._streams[e.id]},e.RTCPeerConnection.prototype.addTrack=function(t,r){if("closed"===this.signalingState)throw new DOMException("The RTCPeerConnection's signalingState is 'closed'.","InvalidStateError");const n=[].slice.call(arguments,1);if(1!==n.length||!n[0].getTracks().find(e=>e===t))throw new DOMException("The adapter.js addTrack polyfill only supports a single stream which is associated with the specified track.","NotSupportedError");const o=this.getSenders().find(e=>e.track===t);if(o)throw new DOMException("Track already exists.","InvalidAccessError");this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{};const i=this._streams[r.id];if(i)i.addTrack(t),Promise.resolve().then(()=>{this.dispatchEvent(new Event("negotiationneeded"))});else{const n=new e.MediaStream([t]);this._streams[r.id]=n,this._reverseStreams[n.id]=r,this.addStream(n)}return this.getSenders().find(e=>e.track===t)},["createOffer","createAnswer"].forEach((function(t){const r=e.RTCPeerConnection.prototype[t],n={[t](){const e=arguments;return arguments.length&&"function"==typeof arguments[0]?r.apply(this,[t=>{const r=i(this,t);e[0].apply(null,[r])},t=>{e[1]&&e[1].apply(null,t)},arguments[2]]):r.apply(this,arguments).then(e=>i(this,e))}};e.RTCPeerConnection.prototype[t]=n[t]}));const s=e.RTCPeerConnection.prototype.setLocalDescription;e.RTCPeerConnection.prototype.setLocalDescription=function(){return arguments.length&&arguments[0].type?(arguments[0]=a(this,arguments[0]),s.apply(this,arguments)):s.apply(this,arguments)};const c=Object.getOwnPropertyDescriptor(e.RTCPeerConnection.prototype,"localDescription");Object.defineProperty(e.RTCPeerConnection.prototype,"localDescription",{get(){const e=c.get.apply(this);return""===e.type?e:i(this,e)}}),e.RTCPeerConnection.prototype.removeTrack=function(e){if("closed"===this.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===this))throw new DOMException("Sender was not created by this connection.","InvalidAccessError");let t;this._streams=this._streams||{},Object.keys(this._streams).forEach(r=>{this._streams[r].getTracks().find(t=>e.track===t)&&(t=this._streams[r])}),t&&(1===t.getTracks().length?this.removeStream(this._reverseStreams[t.id]):t.removeTrack(e.track),this.dispatchEvent(new Event("negotiationneeded")))}}function A(e){const t=v(e);if(!e.RTCPeerConnection&&e.webkitRTCPeerConnection&&(e.RTCPeerConnection=e.webkitRTCPeerConnection),!e.RTCPeerConnection)return;t.version<53&&["setLocalDescription","setRemoteDescription","addIceCandidate"].forEach((function(t){const r=e.RTCPeerConnection.prototype[t],n={[t](){return arguments[0]=new("addIceCandidate"===t?e.RTCIceCandidate:e.RTCSessionDescription)(arguments[0]),r.apply(this,arguments)}};e.RTCPeerConnection.prototype[t]=n[t]}));const r=e.RTCPeerConnection.prototype.addIceCandidate;e.RTCPeerConnection.prototype.addIceCandidate=function(){return arguments[0]?t.version<78&&arguments[0]&&""===arguments[0].candidate?Promise.resolve():r.apply(this,arguments):(arguments[1]&&arguments[1].apply(null),Promise.resolve())}}function I(e){p(e,"negotiationneeded",e=>{if("stable"===e.target.signalingState)return e})}var k=r(43),N=r.n(k);function x(e){const t=e&&e.navigator,r=t.mediaDevices.getUserMedia.bind(t.mediaDevices);t.mediaDevices.getUserMedia=function(e){return r(e).catch(e=>Promise.reject(function(e){return{name:{PermissionDeniedError:"NotAllowedError"}[e.name]||e.name,message:e.message,constraint:e.constraint,toString(){return this.name}}}(e)))}}function U(e){"getDisplayMedia"in e.navigator&&e.navigator.mediaDevices&&(e.navigator.mediaDevices&&"getDisplayMedia"in e.navigator.mediaDevices||(e.navigator.mediaDevices.getDisplayMedia=e.navigator.getDisplayMedia.bind(e.navigator)))}function L(e){const t=v(e);if(e.RTCIceGatherer&&(e.RTCIceCandidate||(e.RTCIceCandidate=function(e){return e}),e.RTCSessionDescription||(e.RTCSessionDescription=function(e){return e}),t.version<15025)){const t=Object.getOwnPropertyDescriptor(e.MediaStreamTrack.prototype,"enabled");Object.defineProperty(e.MediaStreamTrack.prototype,"enabled",{set(e){t.set.call(this,e);const r=new Event("enabled");r.enabled=e,this.dispatchEvent(r)}})}!e.RTCRtpSender||"dtmf"in e.RTCRtpSender.prototype||Object.defineProperty(e.RTCRtpSender.prototype,"dtmf",{get(){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);const r=N()(e,t.version);e.RTCPeerConnection=function(e){return e&&e.iceServers&&(e.iceServers=function(e,t){let r=!1;return(e=JSON.parse(JSON.stringify(e))).filter(e=>{if(e&&(e.urls||e.url)){var t=e.urls||e.url;e.url&&!e.urls&&h("RTCIceServer.url","RTCIceServer.urls");const n="string"==typeof t;return n&&(t=[t]),t=t.filter(e=>{if(0===e.indexOf("stun:"))return!1;const t=e.startsWith("turn")&&!e.startsWith("turn:[")&&e.includes("transport=udp");return t&&!r?(r=!0,!0):t&&!r}),delete e.url,e.urls=n?t[0]:t,!!t.length}})}(e.iceServers,t.version),m("ICE servers after filtering:",e.iceServers)),new r(e)},e.RTCPeerConnection.prototype=r.prototype}function j(e){!e.RTCRtpSender||"replaceTrack"in e.RTCRtpSender.prototype||(e.RTCRtpSender.prototype.replaceTrack=e.RTCRtpSender.prototype.setTrack)}function D(e){const t=v(e),r=e&&e.navigator,n=e&&e.MediaStreamTrack;if(r.getUserMedia=function(e,t,n){h("navigator.getUserMedia","navigator.mediaDevices.getUserMedia"),r.mediaDevices.getUserMedia(e).then(t,n)},!(t.version>55&&"autoGainControl"in r.mediaDevices.getSupportedConstraints())){const e=function(e,t,r){t in e&&!(r in e)&&(e[r]=e[t],delete e[t])},t=r.mediaDevices.getUserMedia.bind(r.mediaDevices);if(r.mediaDevices.getUserMedia=function(r){return"object"==typeof r&&"object"==typeof r.audio&&(r=JSON.parse(JSON.stringify(r)),e(r.audio,"autoGainControl","mozAutoGainControl"),e(r.audio,"noiseSuppression","mozNoiseSuppression")),t(r)},n&&n.prototype.getSettings){const t=n.prototype.getSettings;n.prototype.getSettings=function(){const r=t.apply(this,arguments);return e(r,"mozAutoGainControl","autoGainControl"),e(r,"mozNoiseSuppression","noiseSuppression"),r}}if(n&&n.prototype.applyConstraints){const t=n.prototype.applyConstraints;n.prototype.applyConstraints=function(r){return"audio"===this.kind&&"object"==typeof r&&(r=JSON.parse(JSON.stringify(r)),e(r,"autoGainControl","mozAutoGainControl"),e(r,"noiseSuppression","mozNoiseSuppression")),t.apply(this,[r])}}}}function V(e,t){e.navigator.mediaDevices&&"getDisplayMedia"in e.navigator.mediaDevices||e.navigator.mediaDevices&&(e.navigator.mediaDevices.getDisplayMedia=function(r){if(!r||!r.video){const e=new DOMException("getDisplayMedia without video constraints is undefined");return e.name="NotFoundError",e.code=8,Promise.reject(e)}return!0===r.video?r.video={mediaSource:t}:r.video.mediaSource=t,e.navigator.mediaDevices.getUserMedia(r)})}function B(e){"object"==typeof e&&e.RTCTrackEvent&&"receiver"in e.RTCTrackEvent.prototype&&!("transceiver"in e.RTCTrackEvent.prototype)&&Object.defineProperty(e.RTCTrackEvent.prototype,"transceiver",{get(){return{receiver:this.receiver}}})}function F(e){const t=v(e);if("object"!=typeof e||!e.RTCPeerConnection&&!e.mozRTCPeerConnection)return;if(!e.RTCPeerConnection&&e.mozRTCPeerConnection&&(e.RTCPeerConnection=e.mozRTCPeerConnection),t.version<53&&["setLocalDescription","setRemoteDescription","addIceCandidate"].forEach((function(t){const r=e.RTCPeerConnection.prototype[t],n={[t](){return arguments[0]=new("addIceCandidate"===t?e.RTCIceCandidate:e.RTCSessionDescription)(arguments[0]),r.apply(this,arguments)}};e.RTCPeerConnection.prototype[t]=n[t]})),t.version<68){const t=e.RTCPeerConnection.prototype.addIceCandidate;e.RTCPeerConnection.prototype.addIceCandidate=function(){return arguments[0]?arguments[0]&&""===arguments[0].candidate?Promise.resolve():t.apply(this,arguments):(arguments[1]&&arguments[1].apply(null),Promise.resolve())}}const r={inboundrtp:"inbound-rtp",outboundrtp:"outbound-rtp",candidatepair:"candidate-pair",localcandidate:"local-candidate",remotecandidate:"remote-candidate"},n=e.RTCPeerConnection.prototype.getStats;e.RTCPeerConnection.prototype.getStats=function(){const[e,o,i]=arguments;return n.apply(this,[e||null]).then(e=>{if(t.version<53&&!o)try{e.forEach(e=>{e.type=r[e.type]||e.type})}catch(t){if("TypeError"!==t.name)throw t;e.forEach((t,n)=>{e.set(n,Object.assign({},t,{type:r[t.type]||t.type}))})}return e}).then(o,i)}}function H(e){if("object"!=typeof e||!e.RTCPeerConnection||!e.RTCRtpSender)return;if(e.RTCRtpSender&&"getStats"in e.RTCRtpSender.prototype)return;const t=e.RTCPeerConnection.prototype.getSenders;t&&(e.RTCPeerConnection.prototype.getSenders=function(){const e=t.apply(this,[]);return e.forEach(e=>e._pc=this),e});const r=e.RTCPeerConnection.prototype.addTrack;r&&(e.RTCPeerConnection.prototype.addTrack=function(){const e=r.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)}}function Y(e){if("object"!=typeof e||!e.RTCPeerConnection||!e.RTCRtpSender)return;if(e.RTCRtpSender&&"getStats"in e.RTCRtpReceiver.prototype)return;const t=e.RTCPeerConnection.prototype.getReceivers;t&&(e.RTCPeerConnection.prototype.getReceivers=function(){const e=t.apply(this,[]);return e.forEach(e=>e._pc=this),e}),p(e,"track",e=>(e.receiver._pc=e.srcElement,e)),e.RTCRtpReceiver.prototype.getStats=function(){return this._pc.getStats(this.track)}}function G(e){!e.RTCPeerConnection||"removeStream"in e.RTCPeerConnection.prototype||(e.RTCPeerConnection.prototype.removeStream=function(e){h("removeStream","removeTrack"),this.getSenders().forEach(t=>{t.track&&e.getTracks().includes(t.track)&&this.removeTrack(t)})})}function W(e){e.DataChannel&&!e.RTCDataChannel&&(e.RTCDataChannel=e.DataChannel)}function X(e){if("object"!=typeof e||!e.RTCPeerConnection)return;const t=e.RTCPeerConnection.prototype.addTransceiver;t&&(e.RTCPeerConnection.prototype.addTransceiver=function(){this.setParametersPromises=[];const e=arguments[1],r=e&&"sendEncodings"in e;r&&e.sendEncodings.forEach(e=>{if("rid"in e){if(!/^[a-z0-9]{0,16}$/i.test(e.rid))throw new TypeError("Invalid RID value provided.")}if("scaleResolutionDownBy"in e&&!(parseFloat(e.scaleResolutionDownBy)>=1))throw new RangeError("scale_resolution_down_by must be >= 1.0");if("maxFramerate"in e&&!(parseFloat(e.maxFramerate)>=0))throw new RangeError("max_framerate must be >= 0.0")});const n=t.apply(this,arguments);if(r){const{sender:t}=n,r=t.getParameters();"encodings"in r||(r.encodings=e.sendEncodings,this.setParametersPromises.push(t.setParameters(r).catch(()=>{})))}return n})}function J(e){if("object"!=typeof e||!e.RTCPeerConnection)return;const t=e.RTCPeerConnection.prototype.createOffer;e.RTCPeerConnection.prototype.createOffer=function(){return this.setParametersPromises&&this.setParametersPromises.length?Promise.all(this.setParametersPromises).then(()=>t.apply(this,arguments)).finally(()=>{this.setParametersPromises=[]}):t.apply(this,arguments)}}function q(e){if("object"!=typeof e||!e.RTCPeerConnection)return;const t=e.RTCPeerConnection.prototype.createAnswer;e.RTCPeerConnection.prototype.createAnswer=function(){return this.setParametersPromises&&this.setParametersPromises.length?Promise.all(this.setParametersPromises).then(()=>t.apply(this,arguments)).finally(()=>{this.setParametersPromises=[]}):t.apply(this,arguments)}}function z(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}),!("addStream"in e.RTCPeerConnection.prototype)){const t=e.RTCPeerConnection.prototype.addTrack;e.RTCPeerConnection.prototype.addStream=function(e){this._localStreams||(this._localStreams=[]),this._localStreams.includes(e)||this._localStreams.push(e),e.getAudioTracks().forEach(r=>t.call(this,r,e)),e.getVideoTracks().forEach(r=>t.call(this,r,e))},e.RTCPeerConnection.prototype.addTrack=function(e){const r=arguments[1];return r&&(this._localStreams?this._localStreams.includes(r)||this._localStreams.push(r):this._localStreams=[r]),t.apply(this,arguments)}}"removeStream"in e.RTCPeerConnection.prototype||(e.RTCPeerConnection.prototype.removeStream=function(e){this._localStreams||(this._localStreams=[]);const t=this._localStreams.indexOf(e);if(-1===t)return;this._localStreams.splice(t,1);const r=e.getTracks();this.getSenders().forEach(e=>{r.includes(e.track)&&this.removeTrack(e)})})}}function K(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(){return this._onaddstream},set(e){this._onaddstream&&(this.removeEventListener("addstream",this._onaddstream),this.removeEventListener("track",this._onaddstreampoly)),this.addEventListener("addstream",this._onaddstream=e),this.addEventListener("track",this._onaddstreampoly=e=>{e.streams.forEach(e=>{if(this._remoteStreams||(this._remoteStreams=[]),this._remoteStreams.includes(e))return;this._remoteStreams.push(e);const t=new Event("addstream");t.stream=e,this.dispatchEvent(t)})})}});const t=e.RTCPeerConnection.prototype.setRemoteDescription;e.RTCPeerConnection.prototype.setRemoteDescription=function(){const e=this;return this._onaddstreampoly||this.addEventListener("track",this._onaddstreampoly=function(t){t.streams.forEach(t=>{if(e._remoteStreams||(e._remoteStreams=[]),e._remoteStreams.indexOf(t)>=0)return;e._remoteStreams.push(t);const r=new Event("addstream");r.stream=t,e.dispatchEvent(r)})}),t.apply(e,arguments)}}}function Q(e){if("object"!=typeof e||!e.RTCPeerConnection)return;const t=e.RTCPeerConnection.prototype,r=t.createOffer,n=t.createAnswer,o=t.setLocalDescription,i=t.setRemoteDescription,a=t.addIceCandidate;t.createOffer=function(e,t){const n=arguments.length>=2?arguments[2]:arguments[0],o=r.apply(this,[n]);return t?(o.then(e,t),Promise.resolve()):o},t.createAnswer=function(e,t){const r=arguments.length>=2?arguments[2]:arguments[0],o=n.apply(this,[r]);return t?(o.then(e,t),Promise.resolve()):o};let s=function(e,t,r){const n=o.apply(this,[e]);return r?(n.then(t,r),Promise.resolve()):n};t.setLocalDescription=s,s=function(e,t,r){const n=i.apply(this,[e]);return r?(n.then(t,r),Promise.resolve()):n},t.setRemoteDescription=s,s=function(e,t,r){const n=a.apply(this,[e]);return r?(n.then(t,r),Promise.resolve()):n},t.addIceCandidate=s}function $(e){const t=e&&e.navigator;if(t.mediaDevices&&t.mediaDevices.getUserMedia){const e=t.mediaDevices,r=e.getUserMedia.bind(e);t.mediaDevices.getUserMedia=e=>r(Z(e))}!t.getUserMedia&&t.mediaDevices&&t.mediaDevices.getUserMedia&&(t.getUserMedia=function(e,r,n){t.mediaDevices.getUserMedia(e).then(r,n)}.bind(t))}function Z(e){return e&&void 0!==e.video?Object.assign({},e,{video:y(e.video)}):e}function ee(e){const t=e.RTCPeerConnection;e.RTCPeerConnection=function(e,r){if(e&&e.iceServers){const t=[];for(let r=0;r<e.iceServers.length;r++){let n=e.iceServers[r];!n.hasOwnProperty("urls")&&n.hasOwnProperty("url")?(h("RTCIceServer.url","RTCIceServer.urls"),(n=JSON.parse(JSON.stringify(n))).urls=n.url,delete n.url,t.push(n)):t.push(e.iceServers[r])}e.iceServers=t}return new t(e,r)},e.RTCPeerConnection.prototype=t.prototype,"generateCertificate"in e.RTCPeerConnection&&Object.defineProperty(e.RTCPeerConnection,"generateCertificate",{get:()=>t.generateCertificate})}function te(e){"object"==typeof e&&e.RTCTrackEvent&&"receiver"in e.RTCTrackEvent.prototype&&!("transceiver"in e.RTCTrackEvent.prototype)&&Object.defineProperty(e.RTCTrackEvent.prototype,"transceiver",{get(){return{receiver:this.receiver}}})}function re(e){const t=e.RTCPeerConnection.prototype.createOffer;e.RTCPeerConnection.prototype.createOffer=function(e){if(e){void 0!==e.offerToReceiveAudio&&(e.offerToReceiveAudio=!!e.offerToReceiveAudio);const t=this.getTransceivers().find(e=>"audio"===e.receiver.track.kind);!1===e.offerToReceiveAudio&&t?"sendrecv"===t.direction?t.setDirection?t.setDirection("sendonly"):t.direction="sendonly":"recvonly"===t.direction&&(t.setDirection?t.setDirection("inactive"):t.direction="inactive"):!0!==e.offerToReceiveAudio||t||this.addTransceiver("audio"),void 0!==e.offerToReceiveVideo&&(e.offerToReceiveVideo=!!e.offerToReceiveVideo);const r=this.getTransceivers().find(e=>"video"===e.receiver.track.kind);!1===e.offerToReceiveVideo&&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.offerToReceiveVideo||r||this.addTransceiver("video")}return t.apply(this,arguments)}}var ne=r(7),oe=r.n(ne);function ie(e){if(!e.RTCIceCandidate||e.RTCIceCandidate&&"foundation"in e.RTCIceCandidate.prototype)return;const 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){const r=new t(e),n=oe.a.parseCandidate(e.candidate),o=Object.assign(r,n);return o.toJSON=function(){return{candidate:o.candidate,sdpMid:o.sdpMid,sdpMLineIndex:o.sdpMLineIndex,usernameFragment:o.usernameFragment}},o}return new t(e)},e.RTCIceCandidate.prototype=t.prototype,p(e,"icecandidate",t=>(t.candidate&&Object.defineProperty(t,"candidate",{value:new e.RTCIceCandidate(t.candidate),writable:"false"}),t))}function ae(e){if(!e.RTCPeerConnection)return;const t=v(e);"sctp"in e.RTCPeerConnection.prototype||Object.defineProperty(e.RTCPeerConnection.prototype,"sctp",{get(){return void 0===this._sctp?null:this._sctp}});const r=function(e){if(!e||!e.sdp)return!1;const t=oe.a.splitSections(e.sdp);return t.shift(),t.some(e=>{const t=oe.a.parseMLine(e);return t&&"application"===t.kind&&-1!==t.protocol.indexOf("SCTP")})},n=function(e){const t=e.sdp.match(/mozilla...THIS_IS_SDPARTA-(\d+)/);if(null===t||t.length<2)return-1;const r=parseInt(t[1],10);return r!=r?-1:r},o=function(e){let r=65536;return"firefox"===t.browser&&(r=t.version<57?-1===e?16384:2147483637:t.version<60?57===t.version?65535:65536:2147483637),r},i=function(e,r){let n=65536;"firefox"===t.browser&&57===t.version&&(n=65535);const o=oe.a.matchPrefix(e.sdp,"a=max-message-size:");return o.length>0?n=parseInt(o[0].substr(19),10):"firefox"===t.browser&&-1!==r&&(n=2147483637),n},a=e.RTCPeerConnection.prototype.setRemoteDescription;e.RTCPeerConnection.prototype.setRemoteDescription=function(){if(this._sctp=null,"chrome"===t.browser&&t.version>=76){const{sdpSemantics:e}=this.getConfiguration();"plan-b"===e&&Object.defineProperty(this,"sctp",{get(){return void 0===this._sctp?null:this._sctp},enumerable:!0,configurable:!0})}if(r(arguments[0])){const e=n(arguments[0]),t=o(e),r=i(arguments[0],e);let a;a=0===t&&0===r?Number.POSITIVE_INFINITY:0===t||0===r?Math.max(t,r):Math.min(t,r);const s={};Object.defineProperty(s,"maxMessageSize",{get:()=>a}),this._sctp=s}return a.apply(this,arguments)}}function se(e){if(!(e.RTCPeerConnection&&"createDataChannel"in e.RTCPeerConnection.prototype))return;function t(e,t){const r=e.send;e.send=function(){const n=arguments[0],o=n.length||n.size||n.byteLength;if("open"===e.readyState&&t.sctp&&o>t.sctp.maxMessageSize)throw new TypeError("Message too large (can send a maximum of "+t.sctp.maxMessageSize+" bytes)");return r.apply(e,arguments)}}const r=e.RTCPeerConnection.prototype.createDataChannel;e.RTCPeerConnection.prototype.createDataChannel=function(){const e=r.apply(this,arguments);return t(e,this),e},p(e,"datachannel",e=>(t(e.channel,e.target),e))}function ce(e){if(!e.RTCPeerConnection||"connectionState"in e.RTCPeerConnection.prototype)return;const t=e.RTCPeerConnection.prototype;Object.defineProperty(t,"connectionState",{get(){return{completed:"connected",checking:"connecting"}[this.iceConnectionState]||this.iceConnectionState},enumerable:!0,configurable:!0}),Object.defineProperty(t,"onconnectionstatechange",{get(){return this._onconnectionstatechange||null},set(e){this._onconnectionstatechange&&(this.removeEventListener("connectionstatechange",this._onconnectionstatechange),delete this._onconnectionstatechange),e&&this.addEventListener("connectionstatechange",this._onconnectionstatechange=e)},enumerable:!0,configurable:!0}),["setLocalDescription","setRemoteDescription"].forEach(e=>{const r=t[e];t[e]=function(){return this._connectionstatechangepoly||(this._connectionstatechangepoly=e=>{const t=e.target;if(t._lastConnectionState!==t.connectionState){t._lastConnectionState=t.connectionState;const r=new Event("connectionstatechange",e);t.dispatchEvent(r)}return e},this.addEventListener("iceconnectionstatechange",this._connectionstatechangepoly)),r.apply(this,arguments)}})}function ue(e){if(!e.RTCPeerConnection)return;const t=v(e);if("chrome"===t.browser&&t.version>=71)return;const r=e.RTCPeerConnection.prototype.setRemoteDescription;e.RTCPeerConnection.prototype.setRemoteDescription=function(e){return e&&e.sdp&&-1!==e.sdp.indexOf("\na=extmap-allow-mixed")&&(e.sdp=e.sdp.split("\n").filter(e=>"a=extmap-allow-mixed"!==e.trim()).join("\n")),r.apply(this,arguments)}}const de=function({window:e}={},t={shimChrome:!0,shimFirefox:!0,shimEdge:!0,shimSafari:!0}){const r=m,c=v(e),u={browserDetails:c,commonShim:s,extractVersion:d,disableLog:f,disableWarnings:l};switch(c.browser){case"chrome":if(!n||!A||!t.shimChrome)return r("Chrome shim is not included in this adapter release."),u;r("adapter.js shimming chrome."),u.browserShim=n,_(e),T(e),A(e),R(e),O(e),w(e),M(e),C(e),I(e),ie(e),ce(e),ae(e),se(e),ue(e);break;case"firefox":if(!i||!F||!t.shimFirefox)return r("Firefox shim is not included in this adapter release."),u;r("adapter.js shimming firefox."),u.browserShim=i,D(e),F(e),B(e),G(e),H(e),Y(e),W(e),X(e),J(e),q(e),ie(e),ce(e),ae(e),se(e);break;case"edge":if(!o||!L||!t.shimEdge)return r("MS edge shim is not included in this adapter release."),u;r("adapter.js shimming edge."),u.browserShim=o,x(e),U(e),L(e),j(e),ae(e),se(e);break;case"safari":if(!a||!t.shimSafari)return r("Safari shim is not included in this adapter release."),u;r("adapter.js shimming safari."),u.browserShim=a,ee(e),re(e),Q(e),z(e),K(e),te(e),$(e),ie(e),ae(e),se(e),ue(e);break;default:r("Unsupported browser!")}return u}({window:window});t.default=de}])}));
|