@byteplus/rtc 4.46.11 → 4.46.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.esm.min.js +2 -2
- package/index.min.js +2 -2
- package/package.json +2 -2
package/index.esm.min.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/*
|
|
2
2
|
* Copyright (c) 2020 The BytePlusRTC project authors. All Rights Reserved.
|
|
3
3
|
* @brief BytePlusRTC Advance API
|
|
4
|
-
* version: 4.46.
|
|
4
|
+
* version: 4.46.13
|
|
5
5
|
*/
|
|
6
|
-
function _mergeNamespaces(e,t){return t.forEach((function(t){t&&"string"!=typeof t&&!Array.isArray(t)&&Object.keys(t).forEach((function(r){if("default"!==r&&!(r in e)){var n=Object.getOwnPropertyDescriptor(t,r);Object.defineProperty(e,r,n.get?n:{enumerable:!0,get:function(){return t[r]}})}}))})),Object.freeze(Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}))}function _asyncIterator(e){var t,r,n,i=2;for("undefined"!=typeof Symbol&&(r=Symbol.asyncIterator,n=Symbol.iterator);i--;){if(r&&null!=(t=e[r]))return t.call(e);if(n&&null!=(t=e[n]))return new AsyncFromSyncIterator(t.call(e));r="@@asyncIterator",n="@@iterator"}throw new TypeError("Object is not async iterable")}function AsyncFromSyncIterator(e){function t(e){if(Object(e)!==e)return Promise.reject(new TypeError(e+" is not an object."));var t=e.done;return Promise.resolve(e.value).then((function(e){return{value:e,done:t}}))}return AsyncFromSyncIterator=function(e){this.s=e,this.n=e.next},AsyncFromSyncIterator.prototype={s:null,n:null,next:function(){return t(this.n.apply(this.s,arguments))},return:function(e){var r=this.s.return;return void 0===r?Promise.resolve({value:e,done:!0}):t(r.apply(this.s,arguments))},throw:function(e){var r=this.s.return;return void 0===r?Promise.reject(e):t(r.apply(this.s,arguments))}},new AsyncFromSyncIterator(e)}function ownKeys$2(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function _objectSpread2(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?ownKeys$2(Object(r),!0).forEach((function(t){_defineProperty(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):ownKeys$2(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function _regeneratorRuntime(){_regeneratorRuntime=function(){return e};var e={},t=Object.prototype,r=t.hasOwnProperty,n=Object.defineProperty||function(e,t,r){e[t]=r.value},i="function"==typeof Symbol?Symbol:{},o=i.iterator||"@@iterator",a=i.asyncIterator||"@@asyncIterator",s=i.toStringTag||"@@toStringTag";function c(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{c({},"")}catch(e){c=function(e,t,r){return e[t]=r}}function u(e,t,r,i){var o=t&&t.prototype instanceof p?t:p,a=Object.create(o.prototype),s=new I(i||[]);return n(a,"_invoke",{value:E(e,r,s)}),a}function l(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}e.wrap=u;var d={};function p(){}function _(){}function f(){}var h={};c(h,o,(function(){return this}));var m=Object.getPrototypeOf,y=m&&m(m($([])));y&&y!==t&&r.call(y,o)&&(h=y);var v=f.prototype=p.prototype=Object.create(h);function S(e){["next","throw","return"].forEach((function(t){c(e,t,(function(e){return this._invoke(t,e)}))}))}function g(e,t){function i(n,o,a,s){var c=l(e[n],e,o);if("throw"!==c.type){var u=c.arg,d=u.value;return d&&"object"==typeof d&&r.call(d,"__await")?t.resolve(d.__await).then((function(e){i("next",e,a,s)}),(function(e){i("throw",e,a,s)})):t.resolve(d).then((function(e){u.value=e,a(u)}),(function(e){return i("throw",e,a,s)}))}s(c.arg)}var o;n(this,"_invoke",{value:function(e,r){function n(){return new t((function(t,n){i(e,r,t,n)}))}return o=o?o.then(n,n):n()}})}function E(e,t,r){var n="suspendedStart";return function(i,o){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===i)throw o;return A()}for(r.method=i,r.arg=o;;){var a=r.delegate;if(a){var s=T(a,r);if(s){if(s===d)continue;return s}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var c=l(e,t,r);if("normal"===c.type){if(n=r.done?"completed":"suspendedYield",c.arg===d)continue;return{value:c.arg,done:r.done}}"throw"===c.type&&(n="completed",r.method="throw",r.arg=c.arg)}}}function T(e,t){var r=e.iterator[t.method];if(void 0===r){if(t.delegate=null,"throw"===t.method){if(e.iterator.return&&(t.method="return",t.arg=void 0,T(e,t),"throw"===t.method))return d;t.method="throw",t.arg=new TypeError("The iterator does not provide a 'throw' method")}return d}var n=l(r,e.iterator,t.arg);if("throw"===n.type)return t.method="throw",t.arg=n.arg,t.delegate=null,d;var i=n.arg;return i?i.done?(t[e.resultName]=i.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,d):i:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,d)}function b(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function R(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function I(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(b,this),this.reset(!0)}function $(e){if(e){var t=e[o];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var n=-1,i=function t(){for(;++n<e.length;)if(r.call(e,n))return t.value=e[n],t.done=!1,t;return t.value=void 0,t.done=!0,t};return i.next=i}}return{next:A}}function A(){return{value:void 0,done:!0}}return _.prototype=f,n(v,"constructor",{value:f,configurable:!0}),n(f,"constructor",{value:_,configurable:!0}),_.displayName=c(f,s,"GeneratorFunction"),e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===_||"GeneratorFunction"===(t.displayName||t.name))},e.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,f):(e.__proto__=f,c(e,s,"GeneratorFunction")),e.prototype=Object.create(v),e},e.awrap=function(e){return{__await:e}},S(g.prototype),c(g.prototype,a,(function(){return this})),e.AsyncIterator=g,e.async=function(t,r,n,i,o){void 0===o&&(o=Promise);var a=new g(u(t,r,n,i),o);return e.isGeneratorFunction(r)?a:a.next().then((function(e){return e.done?e.value:a.next()}))},S(v),c(v,s,"Generator"),c(v,o,(function(){return this})),c(v,"toString",(function(){return"[object Generator]"})),e.keys=function(e){var t=Object(e),r=[];for(var n in t)r.push(n);return r.reverse(),function e(){for(;r.length;){var n=r.pop();if(n in t)return e.value=n,e.done=!1,e}return e.done=!0,e}},e.values=$,I.prototype={constructor:I,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(R),!e)for(var t in this)"t"===t.charAt(0)&&r.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=void 0)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var t=this;function n(r,n){return a.type="throw",a.arg=e,t.next=r,n&&(t.method="next",t.arg=void 0),!!n}for(var i=this.tryEntries.length-1;i>=0;--i){var o=this.tryEntries[i],a=o.completion;if("root"===o.tryLoc)return n("end");if(o.tryLoc<=this.prev){var s=r.call(o,"catchLoc"),c=r.call(o,"finallyLoc");if(s&&c){if(this.prev<o.catchLoc)return n(o.catchLoc,!0);if(this.prev<o.finallyLoc)return n(o.finallyLoc)}else if(s){if(this.prev<o.catchLoc)return n(o.catchLoc,!0)}else{if(!c)throw new Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return n(o.finallyLoc)}}}},abrupt:function(e,t){for(var n=this.tryEntries.length-1;n>=0;--n){var i=this.tryEntries[n];if(i.tryLoc<=this.prev&&r.call(i,"finallyLoc")&&this.prev<i.finallyLoc){var o=i;break}}o&&("break"===e||"continue"===e)&&o.tryLoc<=t&&t<=o.finallyLoc&&(o=null);var a=o?o.completion:{};return a.type=e,a.arg=t,o?(this.method="next",this.next=o.finallyLoc,d):this.complete(a)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),d},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),R(r),d}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var n=r.completion;if("throw"===n.type){var i=n.arg;R(r)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,r){return this.delegate={iterator:$(e),resultName:t,nextLoc:r},"next"===this.method&&(this.arg=void 0),d}},e}function _typeof(e){return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},_typeof(e)}function asyncGeneratorStep(e,t,r,n,i,o,a){try{var s=e[o](a),c=s.value}catch(e){return void r(e)}s.done?t(c):Promise.resolve(c).then(n,i)}function _asyncToGenerator(e){return function(){var t=this,r=arguments;return new Promise((function(n,i){var o=e.apply(t,r);function a(e){asyncGeneratorStep(o,n,i,a,s,"next",e)}function s(e){asyncGeneratorStep(o,n,i,a,s,"throw",e)}a(void 0)}))}}function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function _defineProperties(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)}}function _createClass(e,t,r){return t&&_defineProperties(e.prototype,t),r&&_defineProperties(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function _defineProperty(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function _inherits(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&_setPrototypeOf(e,t)}function _getPrototypeOf(e){return _getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},_getPrototypeOf(e)}function _setPrototypeOf(e,t){return _setPrototypeOf=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},_setPrototypeOf(e,t)}function _isNativeReflectConstruct(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}function _objectWithoutPropertiesLoose(e,t){if(null==e)return{};var r,n,i={},o=Object.keys(e);for(n=0;n<o.length;n++)r=o[n],t.indexOf(r)>=0||(i[r]=e[r]);return i}function _objectWithoutProperties(e,t){if(null==e)return{};var r,n,i=_objectWithoutPropertiesLoose(e,t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(n=0;n<o.length;n++)r=o[n],t.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(i[r]=e[r])}return i}function _assertThisInitialized(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function _possibleConstructorReturn(e,t){if(t&&("object"==typeof t||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return _assertThisInitialized(e)}function _createSuper(e){var t=_isNativeReflectConstruct();return function(){var r,n=_getPrototypeOf(e);if(t){var i=_getPrototypeOf(this).constructor;r=Reflect.construct(n,arguments,i)}else r=n.apply(this,arguments);return _possibleConstructorReturn(this,r)}}function _superPropBase(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=_getPrototypeOf(e)););return e}function _get(){return _get="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(e,t,r){var n=_superPropBase(e,t);if(n){var i=Object.getOwnPropertyDescriptor(n,t);return i.get?i.get.call(arguments.length<3?e:r):i.value}},_get.apply(this,arguments)}function _slicedToArray(e,t){return _arrayWithHoles(e)||_iterableToArrayLimit(e,t)||_unsupportedIterableToArray(e,t)||_nonIterableRest()}function _toConsumableArray(e){return _arrayWithoutHoles(e)||_iterableToArray(e)||_unsupportedIterableToArray(e)||_nonIterableSpread()}function _arrayWithoutHoles(e){if(Array.isArray(e))return _arrayLikeToArray(e)}function _arrayWithHoles(e){if(Array.isArray(e))return e}function _iterableToArray(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}function _iterableToArrayLimit(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var n,i,o=[],a=!0,s=!1;try{for(r=r.call(e);!(a=(n=r.next()).done)&&(o.push(n.value),!t||o.length!==t);a=!0);}catch(e){s=!0,i=e}finally{try{a||null==r.return||r.return()}finally{if(s)throw i}}return o}}function _unsupportedIterableToArray(e,t){if(e){if("string"==typeof e)return _arrayLikeToArray(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?_arrayLikeToArray(e,t):void 0}}function _arrayLikeToArray(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function _nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _createForOfIteratorHelper(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=_unsupportedIterableToArray(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0,i=function(){};return{s:i,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,s=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return a=e.done,e},e:function(e){s=!0,o=e},f:function(){try{a||null==r.return||r.return()}finally{if(s)throw o}}}}var commonjsGlobal="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},check=function(e){return e&&e.Math==Math&&e},global$K=check("object"==typeof globalThis&&globalThis)||check("object"==typeof window&&window)||check("object"==typeof self&&self)||check("object"==typeof commonjsGlobal&&commonjsGlobal)||function(){return this}()||Function("return this")(),shared$7={exports:{}},isPure=!1,global$J=global$K,defineProperty$i=Object.defineProperty,defineGlobalProperty$3=function(e,t){try{defineProperty$i(global$J,e,{value:t,configurable:!0,writable:!0})}catch(r){global$J[e]=t}return t},global$I=global$K,defineGlobalProperty$2=defineGlobalProperty$3,SHARED="__core-js_shared__",store$3=global$I[SHARED]||defineGlobalProperty$2(SHARED,{}),sharedStore=store$3,store$2=sharedStore;(shared$7.exports=function(e,t){return store$2[e]||(store$2[e]=void 0!==t?t:{})})("versions",[]).push({version:"3.26.1",mode:"global",copyright:"© 2014-2022 Denis Pushkarev (zloirock.ru)",license:"https://github.com/zloirock/core-js/blob/v3.26.1/LICENSE",source:"https://github.com/zloirock/core-js"});var match,version,fails$U=function(e){try{return!!e()}catch(e){return!0}},fails$T=fails$U,functionBindNative=!fails$T((function(){var e=function(){}.bind();return"function"!=typeof e||e.hasOwnProperty("prototype")})),NATIVE_BIND$3=functionBindNative,FunctionPrototype$2=Function.prototype,call$y=FunctionPrototype$2.call,uncurryThisWithBind=NATIVE_BIND$3&&FunctionPrototype$2.bind.bind(call$y,call$y),functionUncurryThis=NATIVE_BIND$3?uncurryThisWithBind:function(e){return function(){return call$y.apply(e,arguments)}},isNullOrUndefined$b=function(e){return null==e},isNullOrUndefined$a=isNullOrUndefined$b,$TypeError$l=TypeError,requireObjectCoercible$d=function(e){if(isNullOrUndefined$a(e))throw $TypeError$l("Can't call method on "+e);return e},requireObjectCoercible$c=requireObjectCoercible$d,$Object$4=Object,toObject$i=function(e){return $Object$4(requireObjectCoercible$c(e))},uncurryThis$Q=functionUncurryThis,toObject$h=toObject$i,hasOwnProperty$7=uncurryThis$Q({}.hasOwnProperty),hasOwnProperty_1=Object.hasOwn||function(e,t){return hasOwnProperty$7(toObject$h(e),t)},uncurryThis$P=functionUncurryThis,id$2=0,postfix=Math.random(),toString$p=uncurryThis$P(1..toString),uid$5=function(e){return"Symbol("+(void 0===e?"":e)+")_"+toString$p(++id$2+postfix,36)},documentAll$2="object"==typeof document&&document.all,IS_HTMLDDA=void 0===documentAll$2&&void 0!==documentAll$2,documentAll_1={all:documentAll$2,IS_HTMLDDA:IS_HTMLDDA},$documentAll$1=documentAll_1,documentAll$1=$documentAll$1.all,isCallable$t=$documentAll$1.IS_HTMLDDA?function(e){return"function"==typeof e||e===documentAll$1}:function(e){return"function"==typeof e},global$H=global$K,isCallable$s=isCallable$t,aFunction=function(e){return isCallable$s(e)?e:void 0},getBuiltIn$g=function(e,t){return arguments.length<2?aFunction(global$H[e]):global$H[e]&&global$H[e][t]},getBuiltIn$f=getBuiltIn$g,engineUserAgent=getBuiltIn$f("navigator","userAgent")||"",global$G=global$K,userAgent$6=engineUserAgent,process$3=global$G.process,Deno$1=global$G.Deno,versions=process$3&&process$3.versions||Deno$1&&Deno$1.version,v8=versions&&versions.v8;v8&&(version=(match=v8.split("."))[0]>0&&match[0]<4?1:+(match[0]+match[1])),!version&&userAgent$6&&(!(match=userAgent$6.match(/Edge\/(\d+)/))||match[1]>=74)&&(match=userAgent$6.match(/Chrome\/(\d+)/))&&(version=+match[1]);var engineV8Version=version,V8_VERSION$3=engineV8Version,fails$S=fails$U,symbolConstructorDetection=!!Object.getOwnPropertySymbols&&!fails$S((function(){var e=Symbol();return!String(e)||!(Object(e)instanceof Symbol)||!Symbol.sham&&V8_VERSION$3&&V8_VERSION$3<41})),NATIVE_SYMBOL$5=symbolConstructorDetection,useSymbolAsUid=NATIVE_SYMBOL$5&&!Symbol.sham&&"symbol"==typeof Symbol.iterator,global$F=global$K,shared$6=shared$7.exports,hasOwn$q=hasOwnProperty_1,uid$4=uid$5,NATIVE_SYMBOL$4=symbolConstructorDetection,USE_SYMBOL_AS_UID$1=useSymbolAsUid,WellKnownSymbolsStore$1=shared$6("wks"),Symbol$5=global$F.Symbol,symbolFor=Symbol$5&&Symbol$5.for,createWellKnownSymbol=USE_SYMBOL_AS_UID$1?Symbol$5:Symbol$5&&Symbol$5.withoutSetter||uid$4,wellKnownSymbol$u=function(e){if(!hasOwn$q(WellKnownSymbolsStore$1,e)||!NATIVE_SYMBOL$4&&"string"!=typeof WellKnownSymbolsStore$1[e]){var t="Symbol."+e;NATIVE_SYMBOL$4&&hasOwn$q(Symbol$5,e)?WellKnownSymbolsStore$1[e]=Symbol$5[e]:WellKnownSymbolsStore$1[e]=USE_SYMBOL_AS_UID$1&&symbolFor?symbolFor(t):createWellKnownSymbol(t)}return WellKnownSymbolsStore$1[e]},wellKnownSymbol$t=wellKnownSymbol$u,TO_STRING_TAG$4=wellKnownSymbol$t("toStringTag"),test$1={};test$1[TO_STRING_TAG$4]="z";var toStringTagSupport="[object z]"===String(test$1),objectDefineProperty={},fails$R=fails$U,descriptors=!fails$R((function(){return 7!=Object.defineProperty({},1,{get:function(){return 7}})[1]})),isCallable$r=isCallable$t,$documentAll=documentAll_1,documentAll=$documentAll.all,isObject$s=$documentAll.IS_HTMLDDA?function(e){return"object"==typeof e?null!==e:isCallable$r(e)||e===documentAll}:function(e){return"object"==typeof e?null!==e:isCallable$r(e)},global$E=global$K,isObject$r=isObject$s,document$3=global$E.document,EXISTS$1=isObject$r(document$3)&&isObject$r(document$3.createElement),documentCreateElement$2=function(e){return EXISTS$1?document$3.createElement(e):{}},DESCRIPTORS$u=descriptors,fails$Q=fails$U,createElement$2=documentCreateElement$2,ie8DomDefine=!DESCRIPTORS$u&&!fails$Q((function(){return 7!=Object.defineProperty(createElement$2("div"),"a",{get:function(){return 7}}).a})),DESCRIPTORS$t=descriptors,fails$P=fails$U,v8PrototypeDefineBug=DESCRIPTORS$t&&fails$P((function(){return 42!=Object.defineProperty((function(){}),"prototype",{value:42,writable:!1}).prototype})),isObject$q=isObject$s,$String$3=String,$TypeError$k=TypeError,anObject$q=function(e){if(isObject$q(e))return e;throw $TypeError$k($String$3(e)+" is not an object")},NATIVE_BIND$2=functionBindNative,call$x=Function.prototype.call,functionCall=NATIVE_BIND$2?call$x.bind(call$x):function(){return call$x.apply(call$x,arguments)},uncurryThis$O=functionUncurryThis,objectIsPrototypeOf=uncurryThis$O({}.isPrototypeOf),getBuiltIn$e=getBuiltIn$g,isCallable$q=isCallable$t,isPrototypeOf$9=objectIsPrototypeOf,USE_SYMBOL_AS_UID=useSymbolAsUid,$Object$3=Object,isSymbol$6=USE_SYMBOL_AS_UID?function(e){return"symbol"==typeof e}:function(e){var t=getBuiltIn$e("Symbol");return isCallable$q(t)&&isPrototypeOf$9(t.prototype,$Object$3(e))},$String$2=String,tryToString$7=function(e){try{return $String$2(e)}catch(e){return"Object"}},isCallable$p=isCallable$t,tryToString$6=tryToString$7,$TypeError$j=TypeError,aCallable$b=function(e){if(isCallable$p(e))return e;throw $TypeError$j(tryToString$6(e)+" is not a function")},aCallable$a=aCallable$b,isNullOrUndefined$9=isNullOrUndefined$b,getMethod$7=function(e,t){var r=e[t];return isNullOrUndefined$9(r)?void 0:aCallable$a(r)},call$w=functionCall,isCallable$o=isCallable$t,isObject$p=isObject$s,$TypeError$i=TypeError,ordinaryToPrimitive$1=function(e,t){var r,n;if("string"===t&&isCallable$o(r=e.toString)&&!isObject$p(n=call$w(r,e)))return n;if(isCallable$o(r=e.valueOf)&&!isObject$p(n=call$w(r,e)))return n;if("string"!==t&&isCallable$o(r=e.toString)&&!isObject$p(n=call$w(r,e)))return n;throw $TypeError$i("Can't convert object to primitive value")},call$v=functionCall,isObject$o=isObject$s,isSymbol$5=isSymbol$6,getMethod$6=getMethod$7,ordinaryToPrimitive=ordinaryToPrimitive$1,wellKnownSymbol$s=wellKnownSymbol$u,$TypeError$h=TypeError,TO_PRIMITIVE=wellKnownSymbol$s("toPrimitive"),toPrimitive$3=function(e,t){if(!isObject$o(e)||isSymbol$5(e))return e;var r,n=getMethod$6(e,TO_PRIMITIVE);if(n){if(void 0===t&&(t="default"),r=call$v(n,e,t),!isObject$o(r)||isSymbol$5(r))return r;throw $TypeError$h("Can't convert object to primitive value")}return void 0===t&&(t="number"),ordinaryToPrimitive(e,t)},toPrimitive$2=toPrimitive$3,isSymbol$4=isSymbol$6,toPropertyKey$5=function(e){var t=toPrimitive$2(e,"string");return isSymbol$4(t)?t:t+""},DESCRIPTORS$s=descriptors,IE8_DOM_DEFINE$1=ie8DomDefine,V8_PROTOTYPE_DEFINE_BUG$1=v8PrototypeDefineBug,anObject$p=anObject$q,toPropertyKey$4=toPropertyKey$5,$TypeError$g=TypeError,$defineProperty$1=Object.defineProperty,$getOwnPropertyDescriptor$2=Object.getOwnPropertyDescriptor,ENUMERABLE="enumerable",CONFIGURABLE$1="configurable",WRITABLE="writable";objectDefineProperty.f=DESCRIPTORS$s?V8_PROTOTYPE_DEFINE_BUG$1?function(e,t,r){if(anObject$p(e),t=toPropertyKey$4(t),anObject$p(r),"function"==typeof e&&"prototype"===t&&"value"in r&&WRITABLE in r&&!r[WRITABLE]){var n=$getOwnPropertyDescriptor$2(e,t);n&&n[WRITABLE]&&(e[t]=r.value,r={configurable:CONFIGURABLE$1 in r?r[CONFIGURABLE$1]:n[CONFIGURABLE$1],enumerable:ENUMERABLE in r?r[ENUMERABLE]:n[ENUMERABLE],writable:!1})}return $defineProperty$1(e,t,r)}:$defineProperty$1:function(e,t,r){if(anObject$p(e),t=toPropertyKey$4(t),anObject$p(r),IE8_DOM_DEFINE$1)try{return $defineProperty$1(e,t,r)}catch(e){}if("get"in r||"set"in r)throw $TypeError$g("Accessors not supported");return"value"in r&&(e[t]=r.value),e};var makeBuiltIn$3={exports:{}},DESCRIPTORS$r=descriptors,hasOwn$p=hasOwnProperty_1,FunctionPrototype$1=Function.prototype,getDescriptor=DESCRIPTORS$r&&Object.getOwnPropertyDescriptor,EXISTS=hasOwn$p(FunctionPrototype$1,"name"),PROPER=EXISTS&&"something"===function(){}.name,CONFIGURABLE=EXISTS&&(!DESCRIPTORS$r||DESCRIPTORS$r&&getDescriptor(FunctionPrototype$1,"name").configurable),functionName={EXISTS:EXISTS,PROPER:PROPER,CONFIGURABLE:CONFIGURABLE},uncurryThis$N=functionUncurryThis,isCallable$n=isCallable$t,store$1=sharedStore,functionToString=uncurryThis$N(Function.toString);isCallable$n(store$1.inspectSource)||(store$1.inspectSource=function(e){return functionToString(e)});var set$3,get$2,has,inspectSource$3=store$1.inspectSource,global$D=global$K,isCallable$m=isCallable$t,WeakMap$2=global$D.WeakMap,weakMapBasicDetection=isCallable$m(WeakMap$2)&&/native code/.test(String(WeakMap$2)),createPropertyDescriptor$b=function(e,t){return{enumerable:!(1&e),configurable:!(2&e),writable:!(4&e),value:t}},DESCRIPTORS$q=descriptors,definePropertyModule$8=objectDefineProperty,createPropertyDescriptor$a=createPropertyDescriptor$b,createNonEnumerableProperty$c=DESCRIPTORS$q?function(e,t,r){return definePropertyModule$8.f(e,t,createPropertyDescriptor$a(1,r))}:function(e,t,r){return e[t]=r,e},shared$5=shared$7.exports,uid$3=uid$5,keys$4=shared$5("keys"),sharedKey$4=function(e){return keys$4[e]||(keys$4[e]=uid$3(e))},hiddenKeys$6={},NATIVE_WEAK_MAP$1=weakMapBasicDetection,global$C=global$K,isObject$n=isObject$s,createNonEnumerableProperty$b=createNonEnumerableProperty$c,hasOwn$o=hasOwnProperty_1,shared$4=sharedStore,sharedKey$3=sharedKey$4,hiddenKeys$5=hiddenKeys$6,OBJECT_ALREADY_INITIALIZED="Object already initialized",TypeError$7=global$C.TypeError,WeakMap$1=global$C.WeakMap,enforce=function(e){return has(e)?get$2(e):set$3(e,{})},getterFor$1=function(e){return function(t){var r;if(!isObject$n(t)||(r=get$2(t)).type!==e)throw TypeError$7("Incompatible receiver, "+e+" required");return r}};if(NATIVE_WEAK_MAP$1||shared$4.state){var store=shared$4.state||(shared$4.state=new WeakMap$1);store.get=store.get,store.has=store.has,store.set=store.set,set$3=function(e,t){if(store.has(e))throw TypeError$7(OBJECT_ALREADY_INITIALIZED);return t.facade=e,store.set(e,t),t},get$2=function(e){return store.get(e)||{}},has=function(e){return store.has(e)}}else{var STATE=sharedKey$3("state");hiddenKeys$5[STATE]=!0,set$3=function(e,t){if(hasOwn$o(e,STATE))throw TypeError$7(OBJECT_ALREADY_INITIALIZED);return t.facade=e,createNonEnumerableProperty$b(e,STATE,t),t},get$2=function(e){return hasOwn$o(e,STATE)?e[STATE]:{}},has=function(e){return hasOwn$o(e,STATE)}}var internalState={set:set$3,get:get$2,has:has,enforce:enforce,getterFor:getterFor$1},fails$O=fails$U,isCallable$l=isCallable$t,hasOwn$n=hasOwnProperty_1,DESCRIPTORS$p=descriptors,CONFIGURABLE_FUNCTION_NAME$2=functionName.CONFIGURABLE,inspectSource$2=inspectSource$3,InternalStateModule$c=internalState,enforceInternalState$4=InternalStateModule$c.enforce,getInternalState$a=InternalStateModule$c.get,defineProperty$h=Object.defineProperty,CONFIGURABLE_LENGTH=DESCRIPTORS$p&&!fails$O((function(){return 8!==defineProperty$h((function(){}),"length",{value:8}).length})),TEMPLATE=String(String).split("String"),makeBuiltIn$2=makeBuiltIn$3.exports=function(e,t,r){"Symbol("===String(t).slice(0,7)&&(t="["+String(t).replace(/^Symbol\(([^)]*)\)/,"$1")+"]"),r&&r.getter&&(t="get "+t),r&&r.setter&&(t="set "+t),(!hasOwn$n(e,"name")||CONFIGURABLE_FUNCTION_NAME$2&&e.name!==t)&&(DESCRIPTORS$p?defineProperty$h(e,"name",{value:t,configurable:!0}):e.name=t),CONFIGURABLE_LENGTH&&r&&hasOwn$n(r,"arity")&&e.length!==r.arity&&defineProperty$h(e,"length",{value:r.arity});try{r&&hasOwn$n(r,"constructor")&&r.constructor?DESCRIPTORS$p&&defineProperty$h(e,"prototype",{writable:!1}):e.prototype&&(e.prototype=void 0)}catch(e){}var n=enforceInternalState$4(e);return hasOwn$n(n,"source")||(n.source=TEMPLATE.join("string"==typeof t?t:"")),e};Function.prototype.toString=makeBuiltIn$2((function(){return isCallable$l(this)&&getInternalState$a(this).source||inspectSource$2(this)}),"toString");var isCallable$k=isCallable$t,definePropertyModule$7=objectDefineProperty,makeBuiltIn$1=makeBuiltIn$3.exports,defineGlobalProperty$1=defineGlobalProperty$3,defineBuiltIn$j=function(e,t,r,n){n||(n={});var i=n.enumerable,o=void 0!==n.name?n.name:t;if(isCallable$k(r)&&makeBuiltIn$1(r,o,n),n.global)i?e[t]=r:defineGlobalProperty$1(t,r);else{try{n.unsafe?e[t]&&(i=!0):delete e[t]}catch(e){}i?e[t]=r:definePropertyModule$7.f(e,t,{value:r,enumerable:!1,configurable:!n.nonConfigurable,writable:!n.nonWritable})}return e},uncurryThis$M=functionUncurryThis,toString$o=uncurryThis$M({}.toString),stringSlice$a=uncurryThis$M("".slice),classofRaw$2=function(e){return stringSlice$a(toString$o(e),8,-1)},TO_STRING_TAG_SUPPORT$2=toStringTagSupport,isCallable$j=isCallable$t,classofRaw$1=classofRaw$2,wellKnownSymbol$r=wellKnownSymbol$u,TO_STRING_TAG$3=wellKnownSymbol$r("toStringTag"),$Object$2=Object,CORRECT_ARGUMENTS="Arguments"==classofRaw$1(function(){return arguments}()),tryGet=function(e,t){try{return e[t]}catch(e){}},classof$i=TO_STRING_TAG_SUPPORT$2?classofRaw$1:function(e){var t,r,n;return void 0===e?"Undefined":null===e?"Null":"string"==typeof(r=tryGet(t=$Object$2(e),TO_STRING_TAG$3))?r:CORRECT_ARGUMENTS?classofRaw$1(t):"Object"==(n=classofRaw$1(t))&&isCallable$j(t.callee)?"Arguments":n},TO_STRING_TAG_SUPPORT$1=toStringTagSupport,classof$h=classof$i,objectToString$1=TO_STRING_TAG_SUPPORT$1?{}.toString:function(){return"[object "+classof$h(this)+"]"},TO_STRING_TAG_SUPPORT=toStringTagSupport,defineBuiltIn$i=defineBuiltIn$j,toString$n=objectToString$1;TO_STRING_TAG_SUPPORT||defineBuiltIn$i(Object.prototype,"toString",toString$n,{unsafe:!0});var domIterables={CSSRuleList:0,CSSStyleDeclaration:0,CSSValueList:0,ClientRectList:0,DOMRectList:0,DOMStringList:0,DOMTokenList:1,DataTransferItemList:0,FileList:0,HTMLAllCollection:0,HTMLCollection:0,HTMLFormElement:0,HTMLSelectElement:0,MediaList:0,MimeTypeArray:0,NamedNodeMap:0,NodeList:1,PaintRequestList:0,Plugin:0,PluginArray:0,SVGLengthList:0,SVGNumberList:0,SVGPathSegList:0,SVGPointList:0,SVGStringList:0,SVGTransformList:0,SourceBufferList:0,StyleSheetList:0,TextTrackCueList:0,TextTrackList:0,TouchList:0},documentCreateElement$1=documentCreateElement$2,classList=documentCreateElement$1("span").classList,DOMTokenListPrototype$2=classList&&classList.constructor&&classList.constructor.prototype,domTokenListPrototype=DOMTokenListPrototype$2===Object.prototype?void 0:DOMTokenListPrototype$2,classofRaw=classofRaw$2,uncurryThis$L=functionUncurryThis,functionUncurryThisClause=function(e){if("Function"===classofRaw(e))return uncurryThis$L(e)},uncurryThis$K=functionUncurryThisClause,aCallable$9=aCallable$b,NATIVE_BIND$1=functionBindNative,bind$b=functionUncurryThisClause(functionUncurryThisClause.bind),functionBindContext=function(e,t){return aCallable$9(e),void 0===t?e:NATIVE_BIND$1?bind$b(e,t):function(){return e.apply(t,arguments)}},uncurryThis$J=functionUncurryThis,fails$N=fails$U,classof$g=classofRaw$2,$Object$1=Object,split$3=uncurryThis$J("".split),indexedObject=fails$N((function(){return!$Object$1("z").propertyIsEnumerable(0)}))?function(e){return"String"==classof$g(e)?split$3(e,""):$Object$1(e)}:$Object$1,ceil$1=Math.ceil,floor$7=Math.floor,mathTrunc=Math.trunc||function(e){var t=+e;return(t>0?floor$7:ceil$1)(t)},trunc=mathTrunc,toIntegerOrInfinity$d=function(e){var t=+e;return t!=t||0===t?0:trunc(t)},toIntegerOrInfinity$c=toIntegerOrInfinity$d,min$8=Math.min,toLength$a=function(e){return e>0?min$8(toIntegerOrInfinity$c(e),9007199254740991):0},toLength$9=toLength$a,lengthOfArrayLike$m=function(e){return toLength$9(e.length)},classof$f=classofRaw$2,isArray$7=Array.isArray||function(e){return"Array"==classof$f(e)},uncurryThis$I=functionUncurryThis,fails$M=fails$U,isCallable$i=isCallable$t,classof$e=classof$i,getBuiltIn$d=getBuiltIn$g,inspectSource$1=inspectSource$3,noop=function(){},empty=[],construct=getBuiltIn$d("Reflect","construct"),constructorRegExp=/^\s*(?:class|function)\b/,exec$7=uncurryThis$I(constructorRegExp.exec),INCORRECT_TO_STRING$2=!constructorRegExp.exec(noop),isConstructorModern=function(e){if(!isCallable$i(e))return!1;try{return construct(noop,empty,e),!0}catch(e){return!1}},isConstructorLegacy=function(e){if(!isCallable$i(e))return!1;switch(classof$e(e)){case"AsyncFunction":case"GeneratorFunction":case"AsyncGeneratorFunction":return!1}try{return INCORRECT_TO_STRING$2||!!exec$7(constructorRegExp,inspectSource$1(e))}catch(e){return!0}};isConstructorLegacy.sham=!0;var isConstructor$4=!construct||fails$M((function(){var e;return isConstructorModern(isConstructorModern.call)||!isConstructorModern(Object)||!isConstructorModern((function(){e=!0}))||e}))?isConstructorLegacy:isConstructorModern,isArray$6=isArray$7,isConstructor$3=isConstructor$4,isObject$m=isObject$s,wellKnownSymbol$q=wellKnownSymbol$u,SPECIES$6=wellKnownSymbol$q("species"),$Array$4=Array,arraySpeciesConstructor$1=function(e){var t;return isArray$6(e)&&(t=e.constructor,(isConstructor$3(t)&&(t===$Array$4||isArray$6(t.prototype))||isObject$m(t)&&null===(t=t[SPECIES$6]))&&(t=void 0)),void 0===t?$Array$4:t},arraySpeciesConstructor=arraySpeciesConstructor$1,arraySpeciesCreate$3=function(e,t){return new(arraySpeciesConstructor(e))(0===t?0:t)},bind$a=functionBindContext,uncurryThis$H=functionUncurryThis,IndexedObject$4=indexedObject,toObject$g=toObject$i,lengthOfArrayLike$l=lengthOfArrayLike$m,arraySpeciesCreate$2=arraySpeciesCreate$3,push$9=uncurryThis$H([].push),createMethod$7=function(e){var t=1==e,r=2==e,n=3==e,i=4==e,o=6==e,a=7==e,s=5==e||o;return function(c,u,l,d){for(var p,_,f=toObject$g(c),h=IndexedObject$4(f),m=bind$a(u,l),y=lengthOfArrayLike$l(h),v=0,S=d||arraySpeciesCreate$2,g=t?S(c,y):r||a?S(c,0):void 0;y>v;v++)if((s||v in h)&&(_=m(p=h[v],v,f),e))if(t)g[v]=_;else if(_)switch(e){case 3:return!0;case 5:return p;case 6:return v;case 2:push$9(g,p)}else switch(e){case 4:return!1;case 7:push$9(g,p)}return o?-1:n||i?i:g}},arrayIteration={forEach:createMethod$7(0),map:createMethod$7(1),filter:createMethod$7(2),some:createMethod$7(3),every:createMethod$7(4),find:createMethod$7(5),findIndex:createMethod$7(6),filterReject:createMethod$7(7)},fails$L=fails$U,arrayMethodIsStrict$5=function(e,t){var r=[][e];return!!r&&fails$L((function(){r.call(null,t||function(){return 1},1)}))},$forEach$2=arrayIteration.forEach,arrayMethodIsStrict$4=arrayMethodIsStrict$5,STRICT_METHOD$4=arrayMethodIsStrict$4("forEach"),arrayForEach=STRICT_METHOD$4?[].forEach:function(e){return $forEach$2(this,e,arguments.length>1?arguments[1]:void 0)},global$B=global$K,DOMIterables$1=domIterables,DOMTokenListPrototype$1=domTokenListPrototype,forEach$1=arrayForEach,createNonEnumerableProperty$a=createNonEnumerableProperty$c,handlePrototype$1=function(e){if(e&&e.forEach!==forEach$1)try{createNonEnumerableProperty$a(e,"forEach",forEach$1)}catch(t){e.forEach=forEach$1}};for(var COLLECTION_NAME$1 in DOMIterables$1)DOMIterables$1[COLLECTION_NAME$1]&&handlePrototype$1(global$B[COLLECTION_NAME$1]&&global$B[COLLECTION_NAME$1].prototype);handlePrototype$1(DOMTokenListPrototype$1);var objectGetOwnPropertyDescriptor={},objectPropertyIsEnumerable={},$propertyIsEnumerable$2={}.propertyIsEnumerable,getOwnPropertyDescriptor$7=Object.getOwnPropertyDescriptor,NASHORN_BUG=getOwnPropertyDescriptor$7&&!$propertyIsEnumerable$2.call({1:2},1);objectPropertyIsEnumerable.f=NASHORN_BUG?function(e){var t=getOwnPropertyDescriptor$7(this,e);return!!t&&t.enumerable}:$propertyIsEnumerable$2;var IndexedObject$3=indexedObject,requireObjectCoercible$b=requireObjectCoercible$d,toIndexedObject$c=function(e){return IndexedObject$3(requireObjectCoercible$b(e))},DESCRIPTORS$o=descriptors,call$u=functionCall,propertyIsEnumerableModule$2=objectPropertyIsEnumerable,createPropertyDescriptor$9=createPropertyDescriptor$b,toIndexedObject$b=toIndexedObject$c,toPropertyKey$3=toPropertyKey$5,hasOwn$m=hasOwnProperty_1,IE8_DOM_DEFINE=ie8DomDefine,$getOwnPropertyDescriptor$1=Object.getOwnPropertyDescriptor;objectGetOwnPropertyDescriptor.f=DESCRIPTORS$o?$getOwnPropertyDescriptor$1:function(e,t){if(e=toIndexedObject$b(e),t=toPropertyKey$3(t),IE8_DOM_DEFINE)try{return $getOwnPropertyDescriptor$1(e,t)}catch(e){}if(hasOwn$m(e,t))return createPropertyDescriptor$9(!call$u(propertyIsEnumerableModule$2.f,e,t),e[t])};var objectGetOwnPropertyNames={},toIntegerOrInfinity$b=toIntegerOrInfinity$d,max$4=Math.max,min$7=Math.min,toAbsoluteIndex$6=function(e,t){var r=toIntegerOrInfinity$b(e);return r<0?max$4(r+t,0):min$7(r,t)},toIndexedObject$a=toIndexedObject$c,toAbsoluteIndex$5=toAbsoluteIndex$6,lengthOfArrayLike$k=lengthOfArrayLike$m,createMethod$6=function(e){return function(t,r,n){var i,o=toIndexedObject$a(t),a=lengthOfArrayLike$k(o),s=toAbsoluteIndex$5(n,a);if(e&&r!=r){for(;a>s;)if((i=o[s++])!=i)return!0}else for(;a>s;s++)if((e||s in o)&&o[s]===r)return e||s||0;return!e&&-1}},arrayIncludes={includes:createMethod$6(!0),indexOf:createMethod$6(!1)},uncurryThis$G=functionUncurryThis,hasOwn$l=hasOwnProperty_1,toIndexedObject$9=toIndexedObject$c,indexOf$1=arrayIncludes.indexOf,hiddenKeys$4=hiddenKeys$6,push$8=uncurryThis$G([].push),objectKeysInternal=function(e,t){var r,n=toIndexedObject$9(e),i=0,o=[];for(r in n)!hasOwn$l(hiddenKeys$4,r)&&hasOwn$l(n,r)&&push$8(o,r);for(;t.length>i;)hasOwn$l(n,r=t[i++])&&(~indexOf$1(o,r)||push$8(o,r));return o},enumBugKeys$3=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"],internalObjectKeys$1=objectKeysInternal,enumBugKeys$2=enumBugKeys$3,hiddenKeys$3=enumBugKeys$2.concat("length","prototype");objectGetOwnPropertyNames.f=Object.getOwnPropertyNames||function(e){return internalObjectKeys$1(e,hiddenKeys$3)};var objectGetOwnPropertySymbols={};objectGetOwnPropertySymbols.f=Object.getOwnPropertySymbols;var getBuiltIn$c=getBuiltIn$g,uncurryThis$F=functionUncurryThis,getOwnPropertyNamesModule$2=objectGetOwnPropertyNames,getOwnPropertySymbolsModule$3=objectGetOwnPropertySymbols,anObject$o=anObject$q,concat$2=uncurryThis$F([].concat),ownKeys$1=getBuiltIn$c("Reflect","ownKeys")||function(e){var t=getOwnPropertyNamesModule$2.f(anObject$o(e)),r=getOwnPropertySymbolsModule$3.f;return r?concat$2(t,r(e)):t},hasOwn$k=hasOwnProperty_1,ownKeys=ownKeys$1,getOwnPropertyDescriptorModule$4=objectGetOwnPropertyDescriptor,definePropertyModule$6=objectDefineProperty,copyConstructorProperties$2=function(e,t,r){for(var n=ownKeys(t),i=definePropertyModule$6.f,o=getOwnPropertyDescriptorModule$4.f,a=0;a<n.length;a++){var s=n[a];hasOwn$k(e,s)||r&&hasOwn$k(r,s)||i(e,s,o(t,s))}},fails$K=fails$U,isCallable$h=isCallable$t,replacement=/#|\.prototype\./,isForced$5=function(e,t){var r=data[normalize(e)];return r==POLYFILL||r!=NATIVE&&(isCallable$h(t)?fails$K(t):!!t)},normalize=isForced$5.normalize=function(e){return String(e).replace(replacement,".").toLowerCase()},data=isForced$5.data={},NATIVE=isForced$5.NATIVE="N",POLYFILL=isForced$5.POLYFILL="P",isForced_1=isForced$5,global$A=global$K,getOwnPropertyDescriptor$6=objectGetOwnPropertyDescriptor.f,createNonEnumerableProperty$9=createNonEnumerableProperty$c,defineBuiltIn$h=defineBuiltIn$j,defineGlobalProperty=defineGlobalProperty$3,copyConstructorProperties$1=copyConstructorProperties$2,isForced$4=isForced_1,_export=function(e,t){var r,n,i,o,a,s=e.target,c=e.global,u=e.stat;if(r=c?global$A:u?global$A[s]||defineGlobalProperty(s,{}):(global$A[s]||{}).prototype)for(n in t){if(o=t[n],i=e.dontCallGetSet?(a=getOwnPropertyDescriptor$6(r,n))&&a.value:r[n],!isForced$4(c?n:s+(u?".":"#")+n,e.forced)&&void 0!==i){if(typeof o==typeof i)continue;copyConstructorProperties$1(o,i)}(e.sham||i&&i.sham)&&createNonEnumerableProperty$9(o,"sham",!0),defineBuiltIn$h(r,n,o,e)}},objectDefineProperties={},internalObjectKeys=objectKeysInternal,enumBugKeys$1=enumBugKeys$3,objectKeys$4=Object.keys||function(e){return internalObjectKeys(e,enumBugKeys$1)},DESCRIPTORS$n=descriptors,V8_PROTOTYPE_DEFINE_BUG=v8PrototypeDefineBug,definePropertyModule$5=objectDefineProperty,anObject$n=anObject$q,toIndexedObject$8=toIndexedObject$c,objectKeys$3=objectKeys$4;objectDefineProperties.f=DESCRIPTORS$n&&!V8_PROTOTYPE_DEFINE_BUG?Object.defineProperties:function(e,t){anObject$n(e);for(var r,n=toIndexedObject$8(t),i=objectKeys$3(t),o=i.length,a=0;o>a;)definePropertyModule$5.f(e,r=i[a++],n[r]);return e};var activeXDocument,getBuiltIn$b=getBuiltIn$g,html$2=getBuiltIn$b("document","documentElement"),anObject$m=anObject$q,definePropertiesModule$1=objectDefineProperties,enumBugKeys=enumBugKeys$3,hiddenKeys$2=hiddenKeys$6,html$1=html$2,documentCreateElement=documentCreateElement$2,sharedKey$2=sharedKey$4,GT=">",LT="<",PROTOTYPE$2="prototype",SCRIPT="script",IE_PROTO$1=sharedKey$2("IE_PROTO"),EmptyConstructor=function(){},scriptTag=function(e){return LT+SCRIPT+GT+e+LT+"/"+SCRIPT+GT},NullProtoObjectViaActiveX=function(e){e.write(scriptTag("")),e.close();var t=e.parentWindow.Object;return e=null,t},NullProtoObjectViaIFrame=function(){var e,t=documentCreateElement("iframe"),r="java"+SCRIPT+":";return t.style.display="none",html$1.appendChild(t),t.src=String(r),(e=t.contentWindow.document).open(),e.write(scriptTag("document.F=Object")),e.close(),e.F},NullProtoObject=function(){try{activeXDocument=new ActiveXObject("htmlfile")}catch(e){}NullProtoObject="undefined"!=typeof document?document.domain&&activeXDocument?NullProtoObjectViaActiveX(activeXDocument):NullProtoObjectViaIFrame():NullProtoObjectViaActiveX(activeXDocument);for(var e=enumBugKeys.length;e--;)delete NullProtoObject[PROTOTYPE$2][enumBugKeys[e]];return NullProtoObject()};hiddenKeys$2[IE_PROTO$1]=!0;var objectCreate=Object.create||function(e,t){var r;return null!==e?(EmptyConstructor[PROTOTYPE$2]=anObject$m(e),r=new EmptyConstructor,EmptyConstructor[PROTOTYPE$2]=null,r[IE_PROTO$1]=e):r=NullProtoObject(),void 0===t?r:definePropertiesModule$1.f(r,t)},wellKnownSymbol$p=wellKnownSymbol$u,create$7=objectCreate,defineProperty$g=objectDefineProperty.f,UNSCOPABLES=wellKnownSymbol$p("unscopables"),ArrayPrototype$1=Array.prototype;null==ArrayPrototype$1[UNSCOPABLES]&&defineProperty$g(ArrayPrototype$1,UNSCOPABLES,{configurable:!0,value:create$7(null)});var addToUnscopables$4=function(e){ArrayPrototype$1[UNSCOPABLES][e]=!0},$$S=_export,$includes$1=arrayIncludes.includes,fails$J=fails$U,addToUnscopables$3=addToUnscopables$4,BROKEN_ON_SPARSE=fails$J((function(){return!Array(1).includes()}));$$S({target:"Array",proto:!0,forced:BROKEN_ON_SPARSE},{includes:function(e){return $includes$1(this,e,arguments.length>1?arguments[1]:void 0)}}),addToUnscopables$3("includes");var isObject$l=isObject$s,classof$d=classofRaw$2,wellKnownSymbol$o=wellKnownSymbol$u,MATCH$3=wellKnownSymbol$o("match"),isRegexp=function(e){var t;return isObject$l(e)&&(void 0!==(t=e[MATCH$3])?!!t:"RegExp"==classof$d(e))},isRegExp$2=isRegexp,$TypeError$f=TypeError,notARegexp=function(e){if(isRegExp$2(e))throw $TypeError$f("The method doesn't accept regular expressions");return e},classof$c=classof$i,$String$1=String,toString$m=function(e){if("Symbol"===classof$c(e))throw TypeError("Cannot convert a Symbol value to a string");return $String$1(e)},wellKnownSymbol$n=wellKnownSymbol$u,MATCH$2=wellKnownSymbol$n("match"),correctIsRegexpLogic=function(e){var t=/./;try{"/./"[e](t)}catch(r){try{return t[MATCH$2]=!1,"/./"[e](t)}catch(e){}}return!1},$$R=_export,uncurryThis$E=functionUncurryThis,notARegExp$2=notARegexp,requireObjectCoercible$a=requireObjectCoercible$d,toString$l=toString$m,correctIsRegExpLogic$2=correctIsRegexpLogic,stringIndexOf$2=uncurryThis$E("".indexOf);$$R({target:"String",proto:!0,forced:!correctIsRegExpLogic$2("includes")},{includes:function(e){return!!~stringIndexOf$2(toString$l(requireObjectCoercible$a(this)),toString$l(notARegExp$2(e)),arguments.length>1?arguments[1]:void 0)}});var anObject$l=anObject$q,regexpFlags$1=function(){var e=anObject$l(this),t="";return e.hasIndices&&(t+="d"),e.global&&(t+="g"),e.ignoreCase&&(t+="i"),e.multiline&&(t+="m"),e.dotAll&&(t+="s"),e.unicode&&(t+="u"),e.unicodeSets&&(t+="v"),e.sticky&&(t+="y"),t},fails$I=fails$U,global$z=global$K,$RegExp$2=global$z.RegExp,UNSUPPORTED_Y$3=fails$I((function(){var e=$RegExp$2("a","y");return e.lastIndex=2,null!=e.exec("abcd")})),MISSED_STICKY$2=UNSUPPORTED_Y$3||fails$I((function(){return!$RegExp$2("a","y").sticky})),BROKEN_CARET=UNSUPPORTED_Y$3||fails$I((function(){var e=$RegExp$2("^r","gy");return e.lastIndex=2,null!=e.exec("str")})),regexpStickyHelpers={BROKEN_CARET:BROKEN_CARET,MISSED_STICKY:MISSED_STICKY$2,UNSUPPORTED_Y:UNSUPPORTED_Y$3},fails$H=fails$U,global$y=global$K,$RegExp$1=global$y.RegExp,regexpUnsupportedDotAll=fails$H((function(){var e=$RegExp$1(".","s");return!(e.dotAll&&e.exec("\n")&&"s"===e.flags)})),fails$G=fails$U,global$x=global$K,$RegExp=global$x.RegExp,regexpUnsupportedNcg=fails$G((function(){var e=$RegExp("(?<a>b)","g");return"b"!==e.exec("b").groups.a||"bc"!=="b".replace(e,"$<a>c")})),call$t=functionCall,uncurryThis$D=functionUncurryThis,toString$k=toString$m,regexpFlags=regexpFlags$1,stickyHelpers$2=regexpStickyHelpers,shared$3=shared$7.exports,create$6=objectCreate,getInternalState$9=internalState.get,UNSUPPORTED_DOT_ALL$2=regexpUnsupportedDotAll,UNSUPPORTED_NCG$1=regexpUnsupportedNcg,nativeReplace=shared$3("native-string-replace",String.prototype.replace),nativeExec=RegExp.prototype.exec,patchedExec=nativeExec,charAt$9=uncurryThis$D("".charAt),indexOf=uncurryThis$D("".indexOf),replace$8=uncurryThis$D("".replace),stringSlice$9=uncurryThis$D("".slice),UPDATES_LAST_INDEX_WRONG=function(){var e=/a/,t=/b*/g;return call$t(nativeExec,e,"a"),call$t(nativeExec,t,"a"),0!==e.lastIndex||0!==t.lastIndex}(),UNSUPPORTED_Y$2=stickyHelpers$2.BROKEN_CARET,NPCG_INCLUDED=void 0!==/()??/.exec("")[1],PATCH=UPDATES_LAST_INDEX_WRONG||NPCG_INCLUDED||UNSUPPORTED_Y$2||UNSUPPORTED_DOT_ALL$2||UNSUPPORTED_NCG$1;PATCH&&(patchedExec=function(e){var t,r,n,i,o,a,s,c=this,u=getInternalState$9(c),l=toString$k(e),d=u.raw;if(d)return d.lastIndex=c.lastIndex,t=call$t(patchedExec,d,l),c.lastIndex=d.lastIndex,t;var p=u.groups,_=UNSUPPORTED_Y$2&&c.sticky,f=call$t(regexpFlags,c),h=c.source,m=0,y=l;if(_&&(f=replace$8(f,"y",""),-1===indexOf(f,"g")&&(f+="g"),y=stringSlice$9(l,c.lastIndex),c.lastIndex>0&&(!c.multiline||c.multiline&&"\n"!==charAt$9(l,c.lastIndex-1))&&(h="(?: "+h+")",y=" "+y,m++),r=new RegExp("^(?:"+h+")",f)),NPCG_INCLUDED&&(r=new RegExp("^"+h+"$(?!\\s)",f)),UPDATES_LAST_INDEX_WRONG&&(n=c.lastIndex),i=call$t(nativeExec,_?r:c,y),_?i?(i.input=stringSlice$9(i.input,m),i[0]=stringSlice$9(i[0],m),i.index=c.lastIndex,c.lastIndex+=i[0].length):c.lastIndex=0:UPDATES_LAST_INDEX_WRONG&&i&&(c.lastIndex=c.global?i.index+i[0].length:n),NPCG_INCLUDED&&i&&i.length>1&&call$t(nativeReplace,i[0],r,(function(){for(o=1;o<arguments.length-2;o++)void 0===arguments[o]&&(i[o]=void 0)})),i&&p)for(i.groups=a=create$6(null),o=0;o<p.length;o++)a[(s=p[o])[0]]=i[s[1]];return i});var regexpExec$3=patchedExec,$$Q=_export,exec$6=regexpExec$3;$$Q({target:"RegExp",proto:!0,forced:/./.exec!==regexpExec$3},{exec:regexpExec$3});var uncurryThis$C=functionUncurryThisClause,defineBuiltIn$g=defineBuiltIn$j,regexpExec$2=regexpExec$3,fails$F=fails$U,wellKnownSymbol$m=wellKnownSymbol$u,createNonEnumerableProperty$8=createNonEnumerableProperty$c,SPECIES$5=wellKnownSymbol$m("species"),RegExpPrototype$6=RegExp.prototype,fixRegexpWellKnownSymbolLogic=function(e,t,r,n){var i=wellKnownSymbol$m(e),o=!fails$F((function(){var t={};return t[i]=function(){return 7},7!=""[e](t)})),a=o&&!fails$F((function(){var t=!1,r=/a/;return"split"===e&&((r={}).constructor={},r.constructor[SPECIES$5]=function(){return r},r.flags="",r[i]=/./[i]),r.exec=function(){return t=!0,null},r[i](""),!t}));if(!o||!a||r){var s=uncurryThis$C(/./[i]),c=t(i,""[e],(function(e,t,r,n,i){var a=uncurryThis$C(e),c=t.exec;return c===regexpExec$2||c===RegExpPrototype$6.exec?o&&!i?{done:!0,value:s(t,r,n)}:{done:!0,value:a(r,t,n)}:{done:!1}}));defineBuiltIn$g(String.prototype,e,c[0]),defineBuiltIn$g(RegExpPrototype$6,i,c[1])}n&&createNonEnumerableProperty$8(RegExpPrototype$6[i],"sham",!0)},sameValue$1=Object.is||function(e,t){return e===t?0!==e||1/e==1/t:e!=e&&t!=t},call$s=functionCall,anObject$k=anObject$q,isCallable$g=isCallable$t,classof$b=classofRaw$2,regexpExec$1=regexpExec$3,$TypeError$e=TypeError,regexpExecAbstract=function(e,t){var r=e.exec;if(isCallable$g(r)){var n=call$s(r,e,t);return null!==n&&anObject$k(n),n}if("RegExp"===classof$b(e))return call$s(regexpExec$1,e,t);throw $TypeError$e("RegExp#exec called on incompatible receiver")},call$r=functionCall,fixRegExpWellKnownSymbolLogic$3=fixRegexpWellKnownSymbolLogic,anObject$j=anObject$q,isNullOrUndefined$8=isNullOrUndefined$b,requireObjectCoercible$9=requireObjectCoercible$d,sameValue=sameValue$1,toString$j=toString$m,getMethod$5=getMethod$7,regExpExec$2=regexpExecAbstract;fixRegExpWellKnownSymbolLogic$3("search",(function(e,t,r){return[function(t){var r=requireObjectCoercible$9(this),n=isNullOrUndefined$8(t)?void 0:getMethod$5(t,e);return n?call$r(n,t,r):new RegExp(t)[e](toString$j(r))},function(e){var n=anObject$j(this),i=toString$j(e),o=r(t,n,i);if(o.done)return o.value;var a=n.lastIndex;sameValue(a,0)||(n.lastIndex=0);var s=regExpExec$2(n,i);return sameValue(n.lastIndex,a)||(n.lastIndex=a),null===s?-1:s.index}]}));var uncurryThis$B=functionUncurryThis,toIntegerOrInfinity$a=toIntegerOrInfinity$d,toString$i=toString$m,requireObjectCoercible$8=requireObjectCoercible$d,charAt$8=uncurryThis$B("".charAt),charCodeAt$3=uncurryThis$B("".charCodeAt),stringSlice$8=uncurryThis$B("".slice),createMethod$5=function(e){return function(t,r){var n,i,o=toString$i(requireObjectCoercible$8(t)),a=toIntegerOrInfinity$a(r),s=o.length;return a<0||a>=s?e?"":void 0:(n=charCodeAt$3(o,a))<55296||n>56319||a+1===s||(i=charCodeAt$3(o,a+1))<56320||i>57343?e?charAt$8(o,a):n:e?stringSlice$8(o,a,a+2):i-56320+(n-55296<<10)+65536}},stringMultibyte={codeAt:createMethod$5(!1),charAt:createMethod$5(!0)},charAt$7=stringMultibyte.charAt,advanceStringIndex$3=function(e,t,r){return t+(r?charAt$7(e,t).length:1)},call$q=functionCall,fixRegExpWellKnownSymbolLogic$2=fixRegexpWellKnownSymbolLogic,anObject$i=anObject$q,isNullOrUndefined$7=isNullOrUndefined$b,toLength$8=toLength$a,toString$h=toString$m,requireObjectCoercible$7=requireObjectCoercible$d,getMethod$4=getMethod$7,advanceStringIndex$2=advanceStringIndex$3,regExpExec$1=regexpExecAbstract;fixRegExpWellKnownSymbolLogic$2("match",(function(e,t,r){return[function(t){var r=requireObjectCoercible$7(this),n=isNullOrUndefined$7(t)?void 0:getMethod$4(t,e);return n?call$q(n,t,r):new RegExp(t)[e](toString$h(r))},function(e){var n=anObject$i(this),i=toString$h(e),o=r(t,n,i);if(o.done)return o.value;if(!n.global)return regExpExec$1(n,i);var a=n.unicode;n.lastIndex=0;for(var s,c=[],u=0;null!==(s=regExpExec$1(n,i));){var l=toString$h(s[0]);c[u]=l,""===l&&(n.lastIndex=advanceStringIndex$2(i,toLength$8(n.lastIndex),a)),u++}return 0===u?null:c}]}));var whitespaces$4="\t\n\v\f\r \u2028\u2029\ufeff",uncurryThis$A=functionUncurryThis,requireObjectCoercible$6=requireObjectCoercible$d,toString$g=toString$m,whitespaces$3=whitespaces$4,replace$7=uncurryThis$A("".replace),whitespace="["+whitespaces$3+"]",ltrim=RegExp("^"+whitespace+whitespace+"*"),rtrim=RegExp(whitespace+whitespace+"*$"),createMethod$4=function(e){return function(t){var r=toString$g(requireObjectCoercible$6(t));return 1&e&&(r=replace$7(r,ltrim,"")),2&e&&(r=replace$7(r,rtrim,"")),r}},stringTrim={start:createMethod$4(1),end:createMethod$4(2),trim:createMethod$4(3)},global$w=global$K,fails$E=fails$U,uncurryThis$z=functionUncurryThis,toString$f=toString$m,trim$2=stringTrim.trim,whitespaces$2=whitespaces$4,$parseInt$1=global$w.parseInt,Symbol$4=global$w.Symbol,ITERATOR$a=Symbol$4&&Symbol$4.iterator,hex=/^[+-]?0x/i,exec$5=uncurryThis$z(hex.exec),FORCED$a=8!==$parseInt$1(whitespaces$2+"08")||22!==$parseInt$1(whitespaces$2+"0x16")||ITERATOR$a&&!fails$E((function(){$parseInt$1(Object(ITERATOR$a))})),numberParseInt=FORCED$a?function(e,t){var r=trim$2(toString$f(e));return $parseInt$1(r,t>>>0||(exec$5(hex,r)?16:10))}:$parseInt$1,$$P=_export,$parseInt=numberParseInt;$$P({global:!0,forced:parseInt!=numberParseInt},{parseInt:numberParseInt});var IteratorPrototype$2,PrototypeOfArrayIteratorPrototype,arrayIterator,iterators={},fails$D=fails$U,correctPrototypeGetter=!fails$D((function(){function e(){}return e.prototype.constructor=null,Object.getPrototypeOf(new e)!==e.prototype})),hasOwn$j=hasOwnProperty_1,isCallable$f=isCallable$t,toObject$f=toObject$i,sharedKey$1=sharedKey$4,CORRECT_PROTOTYPE_GETTER=correctPrototypeGetter,IE_PROTO=sharedKey$1("IE_PROTO"),$Object=Object,ObjectPrototype$3=$Object.prototype,objectGetPrototypeOf=CORRECT_PROTOTYPE_GETTER?$Object.getPrototypeOf:function(e){var t=toObject$f(e);if(hasOwn$j(t,IE_PROTO))return t[IE_PROTO];var r=t.constructor;return isCallable$f(r)&&t instanceof r?r.prototype:t instanceof $Object?ObjectPrototype$3:null},fails$C=fails$U,isCallable$e=isCallable$t,isObject$k=isObject$s,getPrototypeOf$5=objectGetPrototypeOf,defineBuiltIn$f=defineBuiltIn$j,wellKnownSymbol$l=wellKnownSymbol$u,ITERATOR$9=wellKnownSymbol$l("iterator"),BUGGY_SAFARI_ITERATORS$1=!1;[].keys&&("next"in(arrayIterator=[].keys())?(PrototypeOfArrayIteratorPrototype=getPrototypeOf$5(getPrototypeOf$5(arrayIterator)))!==Object.prototype&&(IteratorPrototype$2=PrototypeOfArrayIteratorPrototype):BUGGY_SAFARI_ITERATORS$1=!0);var NEW_ITERATOR_PROTOTYPE=!isObject$k(IteratorPrototype$2)||fails$C((function(){var e={};return IteratorPrototype$2[ITERATOR$9].call(e)!==e}));NEW_ITERATOR_PROTOTYPE&&(IteratorPrototype$2={}),isCallable$e(IteratorPrototype$2[ITERATOR$9])||defineBuiltIn$f(IteratorPrototype$2,ITERATOR$9,(function(){return this}));var iteratorsCore={IteratorPrototype:IteratorPrototype$2,BUGGY_SAFARI_ITERATORS:BUGGY_SAFARI_ITERATORS$1},defineProperty$f=objectDefineProperty.f,hasOwn$i=hasOwnProperty_1,wellKnownSymbol$k=wellKnownSymbol$u,TO_STRING_TAG$2=wellKnownSymbol$k("toStringTag"),setToStringTag$a=function(e,t,r){e&&!r&&(e=e.prototype),e&&!hasOwn$i(e,TO_STRING_TAG$2)&&defineProperty$f(e,TO_STRING_TAG$2,{configurable:!0,value:t})},IteratorPrototype$1=iteratorsCore.IteratorPrototype,create$5=objectCreate,createPropertyDescriptor$8=createPropertyDescriptor$b,setToStringTag$9=setToStringTag$a,Iterators$4=iterators,returnThis$1=function(){return this},iteratorCreateConstructor=function(e,t,r,n){var i=t+" Iterator";return e.prototype=create$5(IteratorPrototype$1,{next:createPropertyDescriptor$8(+!n,r)}),setToStringTag$9(e,i,!1),Iterators$4[i]=returnThis$1,e},isCallable$d=isCallable$t,$String=String,$TypeError$d=TypeError,aPossiblePrototype$1=function(e){if("object"==typeof e||isCallable$d(e))return e;throw $TypeError$d("Can't set "+$String(e)+" as a prototype")},uncurryThis$y=functionUncurryThis,anObject$h=anObject$q,aPossiblePrototype=aPossiblePrototype$1,objectSetPrototypeOf=Object.setPrototypeOf||("__proto__"in{}?function(){var e,t=!1,r={};try{(e=uncurryThis$y(Object.getOwnPropertyDescriptor(Object.prototype,"__proto__").set))(r,[]),t=r instanceof Array}catch(e){}return function(r,n){return anObject$h(r),aPossiblePrototype(n),t?e(r,n):r.__proto__=n,r}}():void 0),$$O=_export,call$p=functionCall,FunctionName$1=functionName,isCallable$c=isCallable$t,createIteratorConstructor$1=iteratorCreateConstructor,getPrototypeOf$4=objectGetPrototypeOf,setPrototypeOf$6=objectSetPrototypeOf,setToStringTag$8=setToStringTag$a,createNonEnumerableProperty$7=createNonEnumerableProperty$c,defineBuiltIn$e=defineBuiltIn$j,wellKnownSymbol$j=wellKnownSymbol$u,Iterators$3=iterators,IteratorsCore=iteratorsCore,PROPER_FUNCTION_NAME$3=FunctionName$1.PROPER,CONFIGURABLE_FUNCTION_NAME$1=FunctionName$1.CONFIGURABLE,IteratorPrototype=IteratorsCore.IteratorPrototype,BUGGY_SAFARI_ITERATORS=IteratorsCore.BUGGY_SAFARI_ITERATORS,ITERATOR$8=wellKnownSymbol$j("iterator"),KEYS="keys",VALUES="values",ENTRIES="entries",returnThis=function(){return this},iteratorDefine=function(e,t,r,n,i,o,a){createIteratorConstructor$1(r,t,n);var s,c,u,l=function(e){if(e===i&&h)return h;if(!BUGGY_SAFARI_ITERATORS&&e in _)return _[e];switch(e){case KEYS:case VALUES:case ENTRIES:return function(){return new r(this,e)}}return function(){return new r(this)}},d=t+" Iterator",p=!1,_=e.prototype,f=_[ITERATOR$8]||_["@@iterator"]||i&&_[i],h=!BUGGY_SAFARI_ITERATORS&&f||l(i),m="Array"==t&&_.entries||f;if(m&&(s=getPrototypeOf$4(m.call(new e)))!==Object.prototype&&s.next&&(getPrototypeOf$4(s)!==IteratorPrototype&&(setPrototypeOf$6?setPrototypeOf$6(s,IteratorPrototype):isCallable$c(s[ITERATOR$8])||defineBuiltIn$e(s,ITERATOR$8,returnThis)),setToStringTag$8(s,d,!0)),PROPER_FUNCTION_NAME$3&&i==VALUES&&f&&f.name!==VALUES&&(CONFIGURABLE_FUNCTION_NAME$1?createNonEnumerableProperty$7(_,"name",VALUES):(p=!0,h=function(){return call$p(f,this)})),i)if(c={values:l(VALUES),keys:o?h:l(KEYS),entries:l(ENTRIES)},a)for(u in c)(BUGGY_SAFARI_ITERATORS||p||!(u in _))&&defineBuiltIn$e(_,u,c[u]);else $$O({target:t,proto:!0,forced:BUGGY_SAFARI_ITERATORS||p},c);return _[ITERATOR$8]!==h&&defineBuiltIn$e(_,ITERATOR$8,h,{name:i}),Iterators$3[t]=h,c},createIterResultObject$3=function(e,t){return{value:e,done:t}},toIndexedObject$7=toIndexedObject$c,addToUnscopables$2=addToUnscopables$4,Iterators$2=iterators,InternalStateModule$b=internalState,defineProperty$e=objectDefineProperty.f,defineIterator$2=iteratorDefine,createIterResultObject$2=createIterResultObject$3,DESCRIPTORS$m=descriptors,ARRAY_ITERATOR="Array Iterator",setInternalState$a=InternalStateModule$b.set,getInternalState$8=InternalStateModule$b.getterFor(ARRAY_ITERATOR),es_array_iterator=defineIterator$2(Array,"Array",(function(e,t){setInternalState$a(this,{type:ARRAY_ITERATOR,target:toIndexedObject$7(e),index:0,kind:t})}),(function(){var e=getInternalState$8(this),t=e.target,r=e.kind,n=e.index++;return!t||n>=t.length?(e.target=void 0,createIterResultObject$2(void 0,!0)):createIterResultObject$2("keys"==r?n:"values"==r?t[n]:[n,t[n]],!1)}),"values"),values$1=Iterators$2.Arguments=Iterators$2.Array;if(addToUnscopables$2("keys"),addToUnscopables$2("values"),addToUnscopables$2("entries"),DESCRIPTORS$m&&"values"!==values$1.name)try{defineProperty$e(values$1,"name",{value:"values"})}catch(e){}var internalMetadata={exports:{}},objectGetOwnPropertyNamesExternal={},toPropertyKey$2=toPropertyKey$5,definePropertyModule$4=objectDefineProperty,createPropertyDescriptor$7=createPropertyDescriptor$b,createProperty$5=function(e,t,r){var n=toPropertyKey$2(t);n in e?definePropertyModule$4.f(e,n,createPropertyDescriptor$7(0,r)):e[n]=r},toAbsoluteIndex$4=toAbsoluteIndex$6,lengthOfArrayLike$j=lengthOfArrayLike$m,createProperty$4=createProperty$5,$Array$3=Array,max$3=Math.max,arraySliceSimple=function(e,t,r){for(var n=lengthOfArrayLike$j(e),i=toAbsoluteIndex$4(t,n),o=toAbsoluteIndex$4(void 0===r?n:r,n),a=$Array$3(max$3(o-i,0)),s=0;i<o;i++,s++)createProperty$4(a,s,e[i]);return a.length=s,a},classof$a=classofRaw$2,toIndexedObject$6=toIndexedObject$c,$getOwnPropertyNames$1=objectGetOwnPropertyNames.f,arraySlice$a=arraySliceSimple,windowNames="object"==typeof window&&window&&Object.getOwnPropertyNames?Object.getOwnPropertyNames(window):[],getWindowNames=function(e){try{return $getOwnPropertyNames$1(e)}catch(e){return arraySlice$a(windowNames)}};objectGetOwnPropertyNamesExternal.f=function(e){return windowNames&&"Window"==classof$a(e)?getWindowNames(e):$getOwnPropertyNames$1(toIndexedObject$6(e))};var fails$B=fails$U,arrayBufferNonExtensible=fails$B((function(){if("function"==typeof ArrayBuffer){var e=new ArrayBuffer(8);Object.isExtensible(e)&&Object.defineProperty(e,"a",{value:8})}})),fails$A=fails$U,isObject$j=isObject$s,classof$9=classofRaw$2,ARRAY_BUFFER_NON_EXTENSIBLE=arrayBufferNonExtensible,$isExtensible=Object.isExtensible,FAILS_ON_PRIMITIVES$2=fails$A((function(){$isExtensible(1)})),objectIsExtensible=FAILS_ON_PRIMITIVES$2||ARRAY_BUFFER_NON_EXTENSIBLE?function(e){return!!isObject$j(e)&&((!ARRAY_BUFFER_NON_EXTENSIBLE||"ArrayBuffer"!=classof$9(e))&&(!$isExtensible||$isExtensible(e)))}:$isExtensible,fails$z=fails$U,freezing=!fails$z((function(){return Object.isExtensible(Object.preventExtensions({}))})),$$N=_export,uncurryThis$x=functionUncurryThis,hiddenKeys$1=hiddenKeys$6,isObject$i=isObject$s,hasOwn$h=hasOwnProperty_1,defineProperty$d=objectDefineProperty.f,getOwnPropertyNamesModule$1=objectGetOwnPropertyNames,getOwnPropertyNamesExternalModule=objectGetOwnPropertyNamesExternal,isExtensible$1=objectIsExtensible,uid$2=uid$5,FREEZING=freezing,REQUIRED=!1,METADATA=uid$2("meta"),id$1=0,setMetadata=function(e){defineProperty$d(e,METADATA,{value:{objectID:"O"+id$1++,weakData:{}}})},fastKey$1=function(e,t){if(!isObject$i(e))return"symbol"==typeof e?e:("string"==typeof e?"S":"P")+e;if(!hasOwn$h(e,METADATA)){if(!isExtensible$1(e))return"F";if(!t)return"E";setMetadata(e)}return e[METADATA].objectID},getWeakData$1=function(e,t){if(!hasOwn$h(e,METADATA)){if(!isExtensible$1(e))return!0;if(!t)return!1;setMetadata(e)}return e[METADATA].weakData},onFreeze=function(e){return FREEZING&&REQUIRED&&isExtensible$1(e)&&!hasOwn$h(e,METADATA)&&setMetadata(e),e},enable=function(){meta.enable=function(){},REQUIRED=!0;var e=getOwnPropertyNamesModule$1.f,t=uncurryThis$x([].splice),r={};r[METADATA]=1,e(r).length&&(getOwnPropertyNamesModule$1.f=function(r){for(var n=e(r),i=0,o=n.length;i<o;i++)if(n[i]===METADATA){t(n,i,1);break}return n},$$N({target:"Object",stat:!0,forced:!0},{getOwnPropertyNames:getOwnPropertyNamesExternalModule.f}))},meta=internalMetadata.exports={enable:enable,fastKey:fastKey$1,getWeakData:getWeakData$1,onFreeze:onFreeze};hiddenKeys$1[METADATA]=!0;var wellKnownSymbol$i=wellKnownSymbol$u,Iterators$1=iterators,ITERATOR$7=wellKnownSymbol$i("iterator"),ArrayPrototype=Array.prototype,isArrayIteratorMethod$3=function(e){return void 0!==e&&(Iterators$1.Array===e||ArrayPrototype[ITERATOR$7]===e)},classof$8=classof$i,getMethod$3=getMethod$7,isNullOrUndefined$6=isNullOrUndefined$b,Iterators=iterators,wellKnownSymbol$h=wellKnownSymbol$u,ITERATOR$6=wellKnownSymbol$h("iterator"),getIteratorMethod$5=function(e){if(!isNullOrUndefined$6(e))return getMethod$3(e,ITERATOR$6)||getMethod$3(e,"@@iterator")||Iterators[classof$8(e)]},call$o=functionCall,aCallable$8=aCallable$b,anObject$g=anObject$q,tryToString$5=tryToString$7,getIteratorMethod$4=getIteratorMethod$5,$TypeError$c=TypeError,getIterator$4=function(e,t){var r=arguments.length<2?getIteratorMethod$4(e):t;if(aCallable$8(r))return anObject$g(call$o(r,e));throw $TypeError$c(tryToString$5(e)+" is not iterable")},call$n=functionCall,anObject$f=anObject$q,getMethod$2=getMethod$7,iteratorClose$2=function(e,t,r){var n,i;anObject$f(e);try{if(!(n=getMethod$2(e,"return"))){if("throw"===t)throw r;return r}n=call$n(n,e)}catch(e){i=!0,n=e}if("throw"===t)throw r;if(i)throw n;return anObject$f(n),r},bind$9=functionBindContext,call$m=functionCall,anObject$e=anObject$q,tryToString$4=tryToString$7,isArrayIteratorMethod$2=isArrayIteratorMethod$3,lengthOfArrayLike$i=lengthOfArrayLike$m,isPrototypeOf$8=objectIsPrototypeOf,getIterator$3=getIterator$4,getIteratorMethod$3=getIteratorMethod$5,iteratorClose$1=iteratorClose$2,$TypeError$b=TypeError,Result=function(e,t){this.stopped=e,this.result=t},ResultPrototype=Result.prototype,iterate$5=function(e,t,r){var n,i,o,a,s,c,u,l=r&&r.that,d=!(!r||!r.AS_ENTRIES),p=!(!r||!r.IS_RECORD),_=!(!r||!r.IS_ITERATOR),f=!(!r||!r.INTERRUPTED),h=bind$9(t,l),m=function(e){return n&&iteratorClose$1(n,"normal",e),new Result(!0,e)},y=function(e){return d?(anObject$e(e),f?h(e[0],e[1],m):h(e[0],e[1])):f?h(e,m):h(e)};if(p)n=e.iterator;else if(_)n=e;else{if(!(i=getIteratorMethod$3(e)))throw $TypeError$b(tryToString$4(e)+" is not iterable");if(isArrayIteratorMethod$2(i)){for(o=0,a=lengthOfArrayLike$i(e);a>o;o++)if((s=y(e[o]))&&isPrototypeOf$8(ResultPrototype,s))return s;return new Result(!1)}n=getIterator$3(e,i)}for(c=p?e.next:n.next;!(u=call$m(c,n)).done;){try{s=y(u.value)}catch(e){iteratorClose$1(n,"throw",e)}if("object"==typeof s&&s&&isPrototypeOf$8(ResultPrototype,s))return s}return new Result(!1)},isPrototypeOf$7=objectIsPrototypeOf,$TypeError$a=TypeError,anInstance$a=function(e,t){if(isPrototypeOf$7(t,e))return e;throw $TypeError$a("Incorrect invocation")},wellKnownSymbol$g=wellKnownSymbol$u,ITERATOR$5=wellKnownSymbol$g("iterator"),SAFE_CLOSING=!1;try{var called=0,iteratorWithReturn={next:function(){return{done:!!called++}},return:function(){SAFE_CLOSING=!0}};iteratorWithReturn[ITERATOR$5]=function(){return this},Array.from(iteratorWithReturn,(function(){throw 2}))}catch(e){}var checkCorrectnessOfIteration$4=function(e,t){if(!t&&!SAFE_CLOSING)return!1;var r=!1;try{var n={};n[ITERATOR$5]=function(){return{next:function(){return{done:r=!0}}}},e(n)}catch(e){}return r},isCallable$b=isCallable$t,isObject$h=isObject$s,setPrototypeOf$5=objectSetPrototypeOf,inheritIfRequired$6=function(e,t,r){var n,i;return setPrototypeOf$5&&isCallable$b(n=t.constructor)&&n!==r&&isObject$h(i=n.prototype)&&i!==r.prototype&&setPrototypeOf$5(e,i),e},$$M=_export,global$v=global$K,uncurryThis$w=functionUncurryThis,isForced$3=isForced_1,defineBuiltIn$d=defineBuiltIn$j,InternalMetadataModule$1=internalMetadata.exports,iterate$4=iterate$5,anInstance$9=anInstance$a,isCallable$a=isCallable$t,isNullOrUndefined$5=isNullOrUndefined$b,isObject$g=isObject$s,fails$y=fails$U,checkCorrectnessOfIteration$3=checkCorrectnessOfIteration$4,setToStringTag$7=setToStringTag$a,inheritIfRequired$5=inheritIfRequired$6,collection$2=function(e,t,r){var n=-1!==e.indexOf("Map"),i=-1!==e.indexOf("Weak"),o=n?"set":"add",a=global$v[e],s=a&&a.prototype,c=a,u={},l=function(e){var t=uncurryThis$w(s[e]);defineBuiltIn$d(s,e,"add"==e?function(e){return t(this,0===e?0:e),this}:"delete"==e?function(e){return!(i&&!isObject$g(e))&&t(this,0===e?0:e)}:"get"==e?function(e){return i&&!isObject$g(e)?void 0:t(this,0===e?0:e)}:"has"==e?function(e){return!(i&&!isObject$g(e))&&t(this,0===e?0:e)}:function(e,r){return t(this,0===e?0:e,r),this})};if(isForced$3(e,!isCallable$a(a)||!(i||s.forEach&&!fails$y((function(){(new a).entries().next()})))))c=r.getConstructor(t,e,n,o),InternalMetadataModule$1.enable();else if(isForced$3(e,!0)){var d=new c,p=d[o](i?{}:-0,1)!=d,_=fails$y((function(){d.has(1)})),f=checkCorrectnessOfIteration$3((function(e){new a(e)})),h=!i&&fails$y((function(){for(var e=new a,t=5;t--;)e[o](t,t);return!e.has(-0)}));f||((c=t((function(e,t){anInstance$9(e,s);var r=inheritIfRequired$5(new a,e,c);return isNullOrUndefined$5(t)||iterate$4(t,r[o],{that:r,AS_ENTRIES:n}),r}))).prototype=s,s.constructor=c),(_||h)&&(l("delete"),l("has"),n&&l("get")),(h||p)&&l(o),i&&s.clear&&delete s.clear}return u[e]=c,$$M({global:!0,constructor:!0,forced:c!=a},u),setToStringTag$7(c,e),i||r.setStrong(c,e,n),c},defineBuiltIn$c=defineBuiltIn$j,defineBuiltIns$5=function(e,t,r){for(var n in t)defineBuiltIn$c(e,n,t[n],r);return e},getBuiltIn$a=getBuiltIn$g,definePropertyModule$3=objectDefineProperty,wellKnownSymbol$f=wellKnownSymbol$u,DESCRIPTORS$l=descriptors,SPECIES$4=wellKnownSymbol$f("species"),setSpecies$4=function(e){var t=getBuiltIn$a(e),r=definePropertyModule$3.f;DESCRIPTORS$l&&t&&!t[SPECIES$4]&&r(t,SPECIES$4,{configurable:!0,get:function(){return this}})},defineProperty$c=objectDefineProperty.f,create$4=objectCreate,defineBuiltIns$4=defineBuiltIns$5,bind$8=functionBindContext,anInstance$8=anInstance$a,isNullOrUndefined$4=isNullOrUndefined$b,iterate$3=iterate$5,defineIterator$1=iteratorDefine,createIterResultObject$1=createIterResultObject$3,setSpecies$3=setSpecies$4,DESCRIPTORS$k=descriptors,fastKey=internalMetadata.exports.fastKey,InternalStateModule$a=internalState,setInternalState$9=InternalStateModule$a.set,internalStateGetterFor$1=InternalStateModule$a.getterFor,collectionStrong$1={getConstructor:function(e,t,r,n){var i=e((function(e,i){anInstance$8(e,o),setInternalState$9(e,{type:t,index:create$4(null),first:void 0,last:void 0,size:0}),DESCRIPTORS$k||(e.size=0),isNullOrUndefined$4(i)||iterate$3(i,e[n],{that:e,AS_ENTRIES:r})})),o=i.prototype,a=internalStateGetterFor$1(t),s=function(e,t,r){var n,i,o=a(e),s=c(e,t);return s?s.value=r:(o.last=s={index:i=fastKey(t,!0),key:t,value:r,previous:n=o.last,next:void 0,removed:!1},o.first||(o.first=s),n&&(n.next=s),DESCRIPTORS$k?o.size++:e.size++,"F"!==i&&(o.index[i]=s)),e},c=function(e,t){var r,n=a(e),i=fastKey(t);if("F"!==i)return n.index[i];for(r=n.first;r;r=r.next)if(r.key==t)return r};return defineBuiltIns$4(o,{clear:function(){for(var e=a(this),t=e.index,r=e.first;r;)r.removed=!0,r.previous&&(r.previous=r.previous.next=void 0),delete t[r.index],r=r.next;e.first=e.last=void 0,DESCRIPTORS$k?e.size=0:this.size=0},delete:function(e){var t=this,r=a(t),n=c(t,e);if(n){var i=n.next,o=n.previous;delete r.index[n.index],n.removed=!0,o&&(o.next=i),i&&(i.previous=o),r.first==n&&(r.first=i),r.last==n&&(r.last=o),DESCRIPTORS$k?r.size--:t.size--}return!!n},forEach:function(e){for(var t,r=a(this),n=bind$8(e,arguments.length>1?arguments[1]:void 0);t=t?t.next:r.first;)for(n(t.value,t.key,this);t&&t.removed;)t=t.previous},has:function(e){return!!c(this,e)}}),defineBuiltIns$4(o,r?{get:function(e){var t=c(this,e);return t&&t.value},set:function(e,t){return s(this,0===e?0:e,t)}}:{add:function(e){return s(this,e=0===e?0:e,e)}}),DESCRIPTORS$k&&defineProperty$c(o,"size",{get:function(){return a(this).size}}),i},setStrong:function(e,t,r){var n=t+" Iterator",i=internalStateGetterFor$1(t),o=internalStateGetterFor$1(n);defineIterator$1(e,t,(function(e,t){setInternalState$9(this,{type:n,target:e,state:i(e),kind:t,last:void 0})}),(function(){for(var e=o(this),t=e.kind,r=e.last;r&&r.removed;)r=r.previous;return e.target&&(e.last=r=r?r.next:e.state.first)?createIterResultObject$1("keys"==t?r.key:"values"==t?r.value:[r.key,r.value],!1):(e.target=void 0,createIterResultObject$1(void 0,!0))}),r?"entries":"values",!r,!0),setSpecies$3(t)}},collection$1=collection$2,collectionStrong=collectionStrong$1;collection$1("Map",(function(e){return function(){return e(this,arguments.length?arguments[0]:void 0)}}),collectionStrong);var charAt$6=stringMultibyte.charAt,toString$e=toString$m,InternalStateModule$9=internalState,defineIterator=iteratorDefine,createIterResultObject=createIterResultObject$3,STRING_ITERATOR="String Iterator",setInternalState$8=InternalStateModule$9.set,getInternalState$7=InternalStateModule$9.getterFor(STRING_ITERATOR);defineIterator(String,"String",(function(e){setInternalState$8(this,{type:STRING_ITERATOR,string:toString$e(e),index:0})}),(function(){var e,t=getInternalState$7(this),r=t.string,n=t.index;return n>=r.length?createIterResultObject(void 0,!0):(e=charAt$6(r,n),t.index+=e.length,createIterResultObject(e,!1))}));var global$u=global$K,DOMIterables=domIterables,DOMTokenListPrototype=domTokenListPrototype,ArrayIteratorMethods=es_array_iterator,createNonEnumerableProperty$6=createNonEnumerableProperty$c,wellKnownSymbol$e=wellKnownSymbol$u,ITERATOR$4=wellKnownSymbol$e("iterator"),TO_STRING_TAG$1=wellKnownSymbol$e("toStringTag"),ArrayValues=ArrayIteratorMethods.values,handlePrototype=function(e,t){if(e){if(e[ITERATOR$4]!==ArrayValues)try{createNonEnumerableProperty$6(e,ITERATOR$4,ArrayValues)}catch(t){e[ITERATOR$4]=ArrayValues}if(e[TO_STRING_TAG$1]||createNonEnumerableProperty$6(e,TO_STRING_TAG$1,t),DOMIterables[t])for(var r in ArrayIteratorMethods)if(e[r]!==ArrayIteratorMethods[r])try{createNonEnumerableProperty$6(e,r,ArrayIteratorMethods[r])}catch(t){e[r]=ArrayIteratorMethods[r]}}};for(var COLLECTION_NAME in DOMIterables)handlePrototype(global$u[COLLECTION_NAME]&&global$u[COLLECTION_NAME].prototype,COLLECTION_NAME);handlePrototype(DOMTokenListPrototype,"DOMTokenList");var $$L=_export,toObject$e=toObject$i,nativeKeys$2=objectKeys$4,fails$x=fails$U,FAILS_ON_PRIMITIVES$1=fails$x((function(){nativeKeys$2(1)}));$$L({target:"Object",stat:!0,forced:FAILS_ON_PRIMITIVES$1},{keys:function(e){return nativeKeys$2(toObject$e(e))}});var $$K=_export,DESCRIPTORS$j=descriptors,defineProperty$b=objectDefineProperty.f;$$K({target:"Object",stat:!0,forced:Object.defineProperty!==defineProperty$b,sham:!DESCRIPTORS$j},{defineProperty:defineProperty$b});var NATIVE_BIND=functionBindNative,FunctionPrototype=Function.prototype,apply$9=FunctionPrototype.apply,call$l=FunctionPrototype.call,functionApply="object"==typeof Reflect&&Reflect.apply||(NATIVE_BIND?call$l.bind(apply$9):function(){return call$l.apply(apply$9,arguments)}),defineProperty$a=objectDefineProperty.f,proxyAccessor$2=function(e,t,r){r in e||defineProperty$a(e,r,{configurable:!0,get:function(){return t[r]},set:function(e){t[r]=e}})},toString$d=toString$m,normalizeStringArgument$4=function(e,t){return void 0===e?arguments.length<2?"":t:toString$d(e)},isObject$f=isObject$s,createNonEnumerableProperty$5=createNonEnumerableProperty$c,installErrorCause$1=function(e,t){isObject$f(t)&&"cause"in t&&createNonEnumerableProperty$5(e,"cause",t.cause)},uncurryThis$v=functionUncurryThis,$Error=Error,replace$6=uncurryThis$v("".replace),TEST=String($Error("zxcasd").stack),V8_OR_CHAKRA_STACK_ENTRY=/\n\s*at [^:]*:[^\n]*/,IS_V8_OR_CHAKRA_STACK=V8_OR_CHAKRA_STACK_ENTRY.test(TEST),errorStackClear=function(e,t){if(IS_V8_OR_CHAKRA_STACK&&"string"==typeof e&&!$Error.prepareStackTrace)for(;t--;)e=replace$6(e,V8_OR_CHAKRA_STACK_ENTRY,"");return e},fails$w=fails$U,createPropertyDescriptor$6=createPropertyDescriptor$b,errorStackInstallable=!fails$w((function(){var e=Error("a");return!("stack"in e)||(Object.defineProperty(e,"stack",createPropertyDescriptor$6(1,7)),7!==e.stack)})),getBuiltIn$9=getBuiltIn$g,hasOwn$g=hasOwnProperty_1,createNonEnumerableProperty$4=createNonEnumerableProperty$c,isPrototypeOf$6=objectIsPrototypeOf,setPrototypeOf$4=objectSetPrototypeOf,copyConstructorProperties=copyConstructorProperties$2,proxyAccessor$1=proxyAccessor$2,inheritIfRequired$4=inheritIfRequired$6,normalizeStringArgument$3=normalizeStringArgument$4,installErrorCause=installErrorCause$1,clearErrorStack$2=errorStackClear,ERROR_STACK_INSTALLABLE=errorStackInstallable,DESCRIPTORS$i=descriptors,wrapErrorConstructorWithCause$1=function(e,t,r,n){var i="stackTraceLimit",o=n?2:1,a=e.split("."),s=a[a.length-1],c=getBuiltIn$9.apply(null,a);if(c){var u=c.prototype;if(hasOwn$g(u,"cause")&&delete u.cause,!r)return c;var l=getBuiltIn$9("Error"),d=t((function(e,t){var r=normalizeStringArgument$3(n?t:e,void 0),i=n?new c(e):new c;return void 0!==r&&createNonEnumerableProperty$4(i,"message",r),ERROR_STACK_INSTALLABLE&&createNonEnumerableProperty$4(i,"stack",clearErrorStack$2(i.stack,2)),this&&isPrototypeOf$6(u,this)&&inheritIfRequired$4(i,this,d),arguments.length>o&&installErrorCause(i,arguments[o]),i}));d.prototype=u,"Error"!==s?setPrototypeOf$4?setPrototypeOf$4(d,l):copyConstructorProperties(d,l,{name:!0}):DESCRIPTORS$i&&i in c&&(proxyAccessor$1(d,c,i),proxyAccessor$1(d,c,"prepareStackTrace")),copyConstructorProperties(d,c);try{u.name!==s&&createNonEnumerableProperty$4(u,"name",s),u.constructor=d}catch(e){}return d}},$$J=_export,global$t=global$K,apply$8=functionApply,wrapErrorConstructorWithCause=wrapErrorConstructorWithCause$1,WEB_ASSEMBLY="WebAssembly",WebAssembly=global$t[WEB_ASSEMBLY],FORCED$9=7!==Error("e",{cause:7}).cause,exportGlobalErrorCauseWrapper=function(e,t){var r={};r[e]=wrapErrorConstructorWithCause(e,t,FORCED$9),$$J({global:!0,constructor:!0,arity:1,forced:FORCED$9},r)},exportWebAssemblyErrorCauseWrapper=function(e,t){if(WebAssembly&&WebAssembly[e]){var r={};r[e]=wrapErrorConstructorWithCause(WEB_ASSEMBLY+"."+e,t,FORCED$9),$$J({target:WEB_ASSEMBLY,stat:!0,constructor:!0,arity:1,forced:FORCED$9},r)}};exportGlobalErrorCauseWrapper("Error",(function(e){return function(t){return apply$8(e,this,arguments)}})),exportGlobalErrorCauseWrapper("EvalError",(function(e){return function(t){return apply$8(e,this,arguments)}})),exportGlobalErrorCauseWrapper("RangeError",(function(e){return function(t){return apply$8(e,this,arguments)}})),exportGlobalErrorCauseWrapper("ReferenceError",(function(e){return function(t){return apply$8(e,this,arguments)}})),exportGlobalErrorCauseWrapper("SyntaxError",(function(e){return function(t){return apply$8(e,this,arguments)}})),exportGlobalErrorCauseWrapper("TypeError",(function(e){return function(t){return apply$8(e,this,arguments)}})),exportGlobalErrorCauseWrapper("URIError",(function(e){return function(t){return apply$8(e,this,arguments)}})),exportWebAssemblyErrorCauseWrapper("CompileError",(function(e){return function(t){return apply$8(e,this,arguments)}})),exportWebAssemblyErrorCauseWrapper("LinkError",(function(e){return function(t){return apply$8(e,this,arguments)}})),exportWebAssemblyErrorCauseWrapper("RuntimeError",(function(e){return function(t){return apply$8(e,this,arguments)}}));var aCallable$7=aCallable$b,toObject$d=toObject$i,IndexedObject$2=indexedObject,lengthOfArrayLike$h=lengthOfArrayLike$m,$TypeError$9=TypeError,createMethod$3=function(e){return function(t,r,n,i){aCallable$7(r);var o=toObject$d(t),a=IndexedObject$2(o),s=lengthOfArrayLike$h(o),c=e?s-1:0,u=e?-1:1;if(n<2)for(;;){if(c in a){i=a[c],c+=u;break}if(c+=u,e?c<0:s<=c)throw $TypeError$9("Reduce of empty array with no initial value")}for(;e?c>=0:s>c;c+=u)c in a&&(i=r(i,a[c],c,o));return i}},arrayReduce={left:createMethod$3(!1),right:createMethod$3(!0)},classof$7=classofRaw$2,global$s=global$K,engineIsNode="process"==classof$7(global$s.process),$$I=_export,$reduce$1=arrayReduce.left,arrayMethodIsStrict$3=arrayMethodIsStrict$5,CHROME_VERSION=engineV8Version,IS_NODE$5=engineIsNode,STRICT_METHOD$3=arrayMethodIsStrict$3("reduce"),CHROME_BUG=!IS_NODE$5&&CHROME_VERSION>79&&CHROME_VERSION<83;$$I({target:"Array",proto:!0,forced:!STRICT_METHOD$3||CHROME_BUG},{reduce:function(e){var t=arguments.length;return $reduce$1(this,e,t,t>1?arguments[1]:void 0)}});var DESCRIPTORS$h=descriptors,uncurryThis$u=functionUncurryThis,call$k=functionCall,fails$v=fails$U,objectKeys$2=objectKeys$4,getOwnPropertySymbolsModule$2=objectGetOwnPropertySymbols,propertyIsEnumerableModule$1=objectPropertyIsEnumerable,toObject$c=toObject$i,IndexedObject$1=indexedObject,$assign=Object.assign,defineProperty$9=Object.defineProperty,concat$1=uncurryThis$u([].concat),objectAssign=!$assign||fails$v((function(){if(DESCRIPTORS$h&&1!==$assign({b:1},$assign(defineProperty$9({},"a",{enumerable:!0,get:function(){defineProperty$9(this,"b",{value:3,enumerable:!1})}}),{b:2})).b)return!0;var e={},t={},r=Symbol(),n="abcdefghijklmnopqrst";return e[r]=7,n.split("").forEach((function(e){t[e]=e})),7!=$assign({},e)[r]||objectKeys$2($assign({},t)).join("")!=n}))?function(e,t){for(var r=toObject$c(e),n=arguments.length,i=1,o=getOwnPropertySymbolsModule$2.f,a=propertyIsEnumerableModule$1.f;n>i;)for(var s,c=IndexedObject$1(arguments[i++]),u=o?concat$1(objectKeys$2(c),o(c)):objectKeys$2(c),l=u.length,d=0;l>d;)s=u[d++],DESCRIPTORS$h&&!call$k(a,c,s)||(r[s]=c[s]);return r}:$assign,$$H=_export,assign$2=objectAssign;$$H({target:"Object",stat:!0,arity:2,forced:Object.assign!==assign$2},{assign:assign$2});var $$G=_export,uncurryThis$t=functionUncurryThisClause,getOwnPropertyDescriptor$5=objectGetOwnPropertyDescriptor.f,toLength$7=toLength$a,toString$c=toString$m,notARegExp$1=notARegexp,requireObjectCoercible$5=requireObjectCoercible$d,correctIsRegExpLogic$1=correctIsRegexpLogic,nativeEndsWith=uncurryThis$t("".endsWith),slice$2=uncurryThis$t("".slice),min$6=Math.min,CORRECT_IS_REGEXP_LOGIC$1=correctIsRegExpLogic$1("endsWith"),MDN_POLYFILL_BUG$1=!CORRECT_IS_REGEXP_LOGIC$1&&!!function(){var e=getOwnPropertyDescriptor$5(String.prototype,"endsWith");return e&&!e.writable}();$$G({target:"String",proto:!0,forced:!MDN_POLYFILL_BUG$1&&!CORRECT_IS_REGEXP_LOGIC$1},{endsWith:function(e){var t=toString$c(requireObjectCoercible$5(this));notARegExp$1(e);var r=arguments.length>1?arguments[1]:void 0,n=t.length,i=void 0===r?n:min$6(toLength$7(r),n),o=toString$c(e);return nativeEndsWith?nativeEndsWith(t,o,i):slice$2(t,i-o.length,i)===o}});var DESCRIPTORS$g=descriptors,isArray$5=isArray$7,$TypeError$8=TypeError,getOwnPropertyDescriptor$4=Object.getOwnPropertyDescriptor,SILENT_ON_NON_WRITABLE_LENGTH_SET=DESCRIPTORS$g&&!function(){if(void 0!==this)return!0;try{Object.defineProperty([],"length",{writable:!1}).length=1}catch(e){return e instanceof TypeError}}(),arraySetLength=SILENT_ON_NON_WRITABLE_LENGTH_SET?function(e,t){if(isArray$5(e)&&!getOwnPropertyDescriptor$4(e,"length").writable)throw $TypeError$8("Cannot set read only .length");return e.length=t}:function(e,t){return e.length=t},$TypeError$7=TypeError,MAX_SAFE_INTEGER$2=9007199254740991,doesNotExceedSafeInteger$4=function(e){if(e>MAX_SAFE_INTEGER$2)throw $TypeError$7("Maximum allowed index exceeded");return e},$$F=_export,toObject$b=toObject$i,lengthOfArrayLike$g=lengthOfArrayLike$m,setArrayLength$2=arraySetLength,doesNotExceedSafeInteger$3=doesNotExceedSafeInteger$4,fails$u=fails$U,INCORRECT_TO_LENGTH=fails$u((function(){return 4294967297!==[].push.call({length:4294967296},1)})),SILENT_ON_NON_WRITABLE_LENGTH$1=!function(){try{Object.defineProperty([],"length",{writable:!1}).push()}catch(e){return e instanceof TypeError}}();$$F({target:"Array",proto:!0,arity:1,forced:INCORRECT_TO_LENGTH||SILENT_ON_NON_WRITABLE_LENGTH$1},{push:function(e){var t=toObject$b(this),r=lengthOfArrayLike$g(t),n=arguments.length;doesNotExceedSafeInteger$3(r+n);for(var i=0;i<n;i++)t[r]=arguments[i],r++;return setArrayLength$2(t,r),r}});var logDisabled_=!0,deprecationWarnings_=!0;function extractVersion(e,t,r){var n=e.match(t);return n&&n.length>=r&&parseInt(n[r],10)}function wrapPeerConnectionEvent(e,t,r){if(e.RTCPeerConnection){var n=e.RTCPeerConnection.prototype,i=n.addEventListener;n.addEventListener=function(e,n){if(e!==t)return i.apply(this,arguments);var o=function(e){var t=r(e);t&&(n.handleEvent?n.handleEvent(t):n(t))};return this._eventMap=this._eventMap||{},this._eventMap[t]||(this._eventMap[t]=new Map),this._eventMap[t].set(n,o),i.apply(this,[e,o])};var o=n.removeEventListener;n.removeEventListener=function(e,r){if(e!==t||!this._eventMap||!this._eventMap[t])return o.apply(this,arguments);if(!this._eventMap[t].has(r))return o.apply(this,arguments);var n=this._eventMap[t].get(r);return this._eventMap[t].delete(r),0===this._eventMap[t].size&&delete this._eventMap[t],0===Object.keys(this._eventMap).length&&delete this._eventMap,o.apply(this,[e,n])},Object.defineProperty(n,"on"+t,{get:function(){return this["_on"+t]},set:function(e){this["_on"+t]&&(this.removeEventListener(t,this["_on"+t]),delete this["_on"+t]),e&&this.addEventListener(t,this["_on"+t]=e)},enumerable:!0,configurable:!0})}}function disableLog(e){return"boolean"!=typeof e?new Error("Argument type: "+_typeof(e)+". Please use a boolean."):(logDisabled_=e,e?"adapter.js logging disabled":"adapter.js logging enabled")}function disableWarnings(e){return"boolean"!=typeof e?new Error("Argument type: "+_typeof(e)+". Please use a boolean."):(deprecationWarnings_=!e,"adapter.js deprecation warnings "+(e?"disabled":"enabled"))}function log$2(){if("object"===("undefined"==typeof window?"undefined":_typeof(window))){if(logDisabled_)return;"undefined"!=typeof console&&"function"==typeof console.log&&console.log.apply(console,arguments)}}function deprecated(e,t){deprecationWarnings_&&console.warn(e+" is deprecated, please use "+t+" instead.")}function detectBrowser(e){var t={browser:null,version:null};if(void 0===e||!e.navigator)return t.browser="Not a browser.",t;var r=e.navigator;if(r.mozGetUserMedia)t.browser="firefox",t.version=extractVersion(r.userAgent,/Firefox\/(\d+)\./,1);else if(r.webkitGetUserMedia||!1===e.isSecureContext&&e.webkitRTCPeerConnection)t.browser="chrome",t.version=extractVersion(r.userAgent,/Chrom(e|ium)\/(\d+)\./,2);else{if(!e.RTCPeerConnection||!r.userAgent.match(/AppleWebKit\/(\d+)\./))return t.browser="Not a supported browser.",t;t.browser="safari",t.version=extractVersion(r.userAgent,/AppleWebKit\/(\d+)\./,1),t.supportsUnifiedPlan=e.RTCRtpTransceiver&&"currentDirection"in e.RTCRtpTransceiver.prototype}return t}function isObject$e(e){return"[object Object]"===Object.prototype.toString.call(e)}function compactObject(e){return isObject$e(e)?Object.keys(e).reduce((function(t,r){var n=isObject$e(e[r]),i=n?compactObject(e[r]):e[r],o=n&&!Object.keys(i).length;return void 0===i||o?t:Object.assign(t,_defineProperty({},r,i))}),{}):e}function walkStats(e,t,r){t&&!r.has(t.id)&&(r.set(t.id,t),Object.keys(t).forEach((function(n){n.endsWith("Id")?walkStats(e,e.get(t[n]),r):n.endsWith("Ids")&&t[n].forEach((function(t){walkStats(e,e.get(t),r)}))})))}function filterStats(e,t,r){var n=r?"outbound-rtp":"inbound-rtp",i=new Map;if(null===t)return i;var o=[];return e.forEach((function(e){"track"===e.type&&e.trackIdentifier===t.id&&o.push(e)})),o.forEach((function(t){e.forEach((function(r){r.type===n&&r.trackId===t.id&&walkStats(e,r,i)}))})),i}var $$E=_export,$find$1=arrayIteration.find,addToUnscopables$1=addToUnscopables$4,FIND="find",SKIPS_HOLES$1=!0;FIND in[]&&Array(1)[FIND]((function(){SKIPS_HOLES$1=!1})),$$E({target:"Array",proto:!0,forced:SKIPS_HOLES$1},{find:function(e){return $find$1(this,e,arguments.length>1?arguments[1]:void 0)}}),addToUnscopables$1(FIND);var fails$t=fails$U,wellKnownSymbol$d=wellKnownSymbol$u,V8_VERSION$2=engineV8Version,SPECIES$3=wellKnownSymbol$d("species"),arrayMethodHasSpeciesSupport$5=function(e){return V8_VERSION$2>=51||!fails$t((function(){var t=[];return(t.constructor={})[SPECIES$3]=function(){return{foo:1}},1!==t[e](Boolean).foo}))},uncurryThis$s=functionUncurryThis,arraySlice$9=uncurryThis$s([].slice),$$D=_export,isArray$4=isArray$7,isConstructor$2=isConstructor$4,isObject$d=isObject$s,toAbsoluteIndex$3=toAbsoluteIndex$6,lengthOfArrayLike$f=lengthOfArrayLike$m,toIndexedObject$5=toIndexedObject$c,createProperty$3=createProperty$5,wellKnownSymbol$c=wellKnownSymbol$u,arrayMethodHasSpeciesSupport$4=arrayMethodHasSpeciesSupport$5,nativeSlice=arraySlice$9,HAS_SPECIES_SUPPORT$3=arrayMethodHasSpeciesSupport$4("slice"),SPECIES$2=wellKnownSymbol$c("species"),$Array$2=Array,max$2=Math.max;$$D({target:"Array",proto:!0,forced:!HAS_SPECIES_SUPPORT$3},{slice:function(e,t){var r,n,i,o=toIndexedObject$5(this),a=lengthOfArrayLike$f(o),s=toAbsoluteIndex$3(e,a),c=toAbsoluteIndex$3(void 0===t?a:t,a);if(isArray$4(o)&&(r=o.constructor,(isConstructor$2(r)&&(r===$Array$2||isArray$4(r.prototype))||isObject$d(r)&&null===(r=r[SPECIES$2]))&&(r=void 0),r===$Array$2||void 0===r))return nativeSlice(o,s,c);for(n=new(void 0===r?$Array$2:r)(max$2(c-s,0)),i=0;s<c;s++,i++)s in o&&createProperty$3(n,i,o[s]);return n.length=i,n}});var $$C=_export,uncurryThis$r=functionUncurryThisClause,$indexOf$1=arrayIncludes.indexOf,arrayMethodIsStrict$2=arrayMethodIsStrict$5,nativeIndexOf=uncurryThis$r([].indexOf),NEGATIVE_ZERO$1=!!nativeIndexOf&&1/nativeIndexOf([1],1,-0)<0,STRICT_METHOD$2=arrayMethodIsStrict$2("indexOf");$$C({target:"Array",proto:!0,forced:NEGATIVE_ZERO$1||!STRICT_METHOD$2},{indexOf:function(e){var t=arguments.length>1?arguments[1]:void 0;return NEGATIVE_ZERO$1?nativeIndexOf(this,e,t)||0:$indexOf$1(this,e,t)}});var tryToString$3=tryToString$7,$TypeError$6=TypeError,deletePropertyOrThrow$4=function(e,t){if(!delete e[t])throw $TypeError$6("Cannot delete property "+tryToString$3(t)+" of "+tryToString$3(e))},$$B=_export,toObject$a=toObject$i,toAbsoluteIndex$2=toAbsoluteIndex$6,toIntegerOrInfinity$9=toIntegerOrInfinity$d,lengthOfArrayLike$e=lengthOfArrayLike$m,setArrayLength$1=arraySetLength,doesNotExceedSafeInteger$2=doesNotExceedSafeInteger$4,arraySpeciesCreate$1=arraySpeciesCreate$3,createProperty$2=createProperty$5,deletePropertyOrThrow$3=deletePropertyOrThrow$4,arrayMethodHasSpeciesSupport$3=arrayMethodHasSpeciesSupport$5,HAS_SPECIES_SUPPORT$2=arrayMethodHasSpeciesSupport$3("splice"),max$1=Math.max,min$5=Math.min;$$B({target:"Array",proto:!0,forced:!HAS_SPECIES_SUPPORT$2},{splice:function(e,t){var r,n,i,o,a,s,c=toObject$a(this),u=lengthOfArrayLike$e(c),l=toAbsoluteIndex$2(e,u),d=arguments.length;for(0===d?r=n=0:1===d?(r=0,n=u-l):(r=d-2,n=min$5(max$1(toIntegerOrInfinity$9(t),0),u-l)),doesNotExceedSafeInteger$2(u+r-n),i=arraySpeciesCreate$1(c,n),o=0;o<n;o++)(a=l+o)in c&&createProperty$2(i,o,c[a]);if(i.length=n,r<n){for(o=l;o<u-n;o++)s=o+r,(a=o+n)in c?c[s]=c[a]:deletePropertyOrThrow$3(c,s);for(o=u;o>u-n+r;o--)deletePropertyOrThrow$3(c,o-1)}else if(r>n)for(o=u-n;o>l;o--)s=o+r-1,(a=o+n-1)in c?c[s]=c[a]:deletePropertyOrThrow$3(c,s);for(o=0;o<r;o++)c[o+l]=arguments[o+2];return setArrayLength$1(c,u-n+r),i}});var $$A=_export,$map$1=arrayIteration.map,arrayMethodHasSpeciesSupport$2=arrayMethodHasSpeciesSupport$5,HAS_SPECIES_SUPPORT$1=arrayMethodHasSpeciesSupport$2("map");$$A({target:"Array",proto:!0,forced:!HAS_SPECIES_SUPPORT$1},{map:function(e){return $map$1(this,e,arguments.length>1?arguments[1]:void 0)}});var $location,defer,channel,port,isConstructor$1=isConstructor$4,tryToString$2=tryToString$7,$TypeError$5=TypeError,aConstructor$2=function(e){if(isConstructor$1(e))return e;throw $TypeError$5(tryToString$2(e)+" is not a constructor")},anObject$d=anObject$q,aConstructor$1=aConstructor$2,isNullOrUndefined$3=isNullOrUndefined$b,wellKnownSymbol$b=wellKnownSymbol$u,SPECIES$1=wellKnownSymbol$b("species"),speciesConstructor$4=function(e,t){var r,n=anObject$d(e).constructor;return void 0===n||isNullOrUndefined$3(r=anObject$d(n)[SPECIES$1])?t:aConstructor$1(r)},$TypeError$4=TypeError,validateArgumentsLength$3=function(e,t){if(e<t)throw $TypeError$4("Not enough arguments");return e},userAgent$5=engineUserAgent,engineIsIos=/(?:ipad|iphone|ipod).*applewebkit/i.test(userAgent$5),global$r=global$K,apply$7=functionApply,bind$7=functionBindContext,isCallable$9=isCallable$t,hasOwn$f=hasOwnProperty_1,fails$s=fails$U,html=html$2,arraySlice$8=arraySlice$9,createElement$1=documentCreateElement$2,validateArgumentsLength$2=validateArgumentsLength$3,IS_IOS$1=engineIsIos,IS_NODE$4=engineIsNode,set$2=global$r.setImmediate,clear=global$r.clearImmediate,process$2=global$r.process,Dispatch=global$r.Dispatch,Function$1=global$r.Function,MessageChannel=global$r.MessageChannel,String$1=global$r.String,counter=0,queue$1={},ONREADYSTATECHANGE="onreadystatechange";try{$location=global$r.location}catch(e){}var run=function(e){if(hasOwn$f(queue$1,e)){var t=queue$1[e];delete queue$1[e],t()}},runner=function(e){return function(){run(e)}},listener=function(e){run(e.data)},post=function(e){global$r.postMessage(String$1(e),$location.protocol+"//"+$location.host)};set$2&&clear||(set$2=function(e){validateArgumentsLength$2(arguments.length,1);var t=isCallable$9(e)?e:Function$1(e),r=arraySlice$8(arguments,1);return queue$1[++counter]=function(){apply$7(t,void 0,r)},defer(counter),counter},clear=function(e){delete queue$1[e]},IS_NODE$4?defer=function(e){process$2.nextTick(runner(e))}:Dispatch&&Dispatch.now?defer=function(e){Dispatch.now(runner(e))}:MessageChannel&&!IS_IOS$1?(port=(channel=new MessageChannel).port2,channel.port1.onmessage=listener,defer=bind$7(port.postMessage,port)):global$r.addEventListener&&isCallable$9(global$r.postMessage)&&!global$r.importScripts&&$location&&"file:"!==$location.protocol&&!fails$s(post)?(defer=post,global$r.addEventListener("message",listener,!1)):defer=ONREADYSTATECHANGE in createElement$1("script")?function(e){html.appendChild(createElement$1("script"))[ONREADYSTATECHANGE]=function(){html.removeChild(this),run(e)}}:function(e){setTimeout(runner(e),0)});var flush,head,last,notify$1,toggle,node,promise,then,task$1={set:set$2,clear:clear},userAgent$4=engineUserAgent,global$q=global$K,engineIsIosPebble=/ipad|iphone|ipod/i.test(userAgent$4)&&void 0!==global$q.Pebble,userAgent$3=engineUserAgent,engineIsWebosWebkit=/web0s(?!.*chrome)/i.test(userAgent$3),global$p=global$K,bind$6=functionBindContext,getOwnPropertyDescriptor$3=objectGetOwnPropertyDescriptor.f,macrotask=task$1.set,IS_IOS=engineIsIos,IS_IOS_PEBBLE=engineIsIosPebble,IS_WEBOS_WEBKIT=engineIsWebosWebkit,IS_NODE$3=engineIsNode,MutationObserver=global$p.MutationObserver||global$p.WebKitMutationObserver,document$2=global$p.document,process$1=global$p.process,Promise$1=global$p.Promise,queueMicrotaskDescriptor=getOwnPropertyDescriptor$3(global$p,"queueMicrotask"),queueMicrotask=queueMicrotaskDescriptor&&queueMicrotaskDescriptor.value;queueMicrotask||(flush=function(){var e,t;for(IS_NODE$3&&(e=process$1.domain)&&e.exit();head;){t=head.fn,head=head.next;try{t()}catch(e){throw head?notify$1():last=void 0,e}}last=void 0,e&&e.enter()},IS_IOS||IS_NODE$3||IS_WEBOS_WEBKIT||!MutationObserver||!document$2?!IS_IOS_PEBBLE&&Promise$1&&Promise$1.resolve?((promise=Promise$1.resolve(void 0)).constructor=Promise$1,then=bind$6(promise.then,promise),notify$1=function(){then(flush)}):IS_NODE$3?notify$1=function(){process$1.nextTick(flush)}:(macrotask=bind$6(macrotask,global$p),notify$1=function(){macrotask(flush)}):(toggle=!0,node=document$2.createTextNode(""),new MutationObserver(flush).observe(node,{characterData:!0}),notify$1=function(){node.data=toggle=!toggle}));var microtask$1=queueMicrotask||function(e){var t={fn:e,next:void 0};last&&(last.next=t),head||(head=t,notify$1()),last=t},global$o=global$K,hostReportErrors$1=function(e,t){var r=global$o.console;r&&r.error&&(1==arguments.length?r.error(e):r.error(e,t))},perform$3=function(e){try{return{error:!1,value:e()}}catch(e){return{error:!0,value:e}}},Queue$1=function(){this.head=null,this.tail=null};Queue$1.prototype={add:function(e){var t={item:e,next:null};this.head?this.tail.next=t:this.head=t,this.tail=t},get:function(){var e=this.head;if(e)return this.head=e.next,this.tail===e&&(this.tail=null),e.item}};var queue=Queue$1,global$n=global$K,promiseNativeConstructor=global$n.Promise,engineIsDeno="object"==typeof Deno&&Deno&&"object"==typeof Deno.version,IS_DENO$1=engineIsDeno,IS_NODE$2=engineIsNode,engineIsBrowser=!IS_DENO$1&&!IS_NODE$2&&"object"==typeof window&&"object"==typeof document,global$m=global$K,NativePromiseConstructor$4=promiseNativeConstructor,isCallable$8=isCallable$t,isForced$2=isForced_1,inspectSource=inspectSource$3,wellKnownSymbol$a=wellKnownSymbol$u,IS_BROWSER=engineIsBrowser,IS_DENO=engineIsDeno,V8_VERSION$1=engineV8Version;NativePromiseConstructor$4&&NativePromiseConstructor$4.prototype;var SPECIES=wellKnownSymbol$a("species"),SUBCLASSING=!1,NATIVE_PROMISE_REJECTION_EVENT$1=isCallable$8(global$m.PromiseRejectionEvent),FORCED_PROMISE_CONSTRUCTOR$5=isForced$2("Promise",(function(){var e=inspectSource(NativePromiseConstructor$4),t=e!==String(NativePromiseConstructor$4);if(!t&&66===V8_VERSION$1)return!0;if(!V8_VERSION$1||V8_VERSION$1<51||!/native code/.test(e)){var r=new NativePromiseConstructor$4((function(e){e(1)})),n=function(e){e((function(){}),(function(){}))};if((r.constructor={})[SPECIES]=n,!(SUBCLASSING=r.then((function(){}))instanceof n))return!0}return!t&&(IS_BROWSER||IS_DENO)&&!NATIVE_PROMISE_REJECTION_EVENT$1})),promiseConstructorDetection={CONSTRUCTOR:FORCED_PROMISE_CONSTRUCTOR$5,REJECTION_EVENT:NATIVE_PROMISE_REJECTION_EVENT$1,SUBCLASSING:SUBCLASSING},newPromiseCapability$2={},aCallable$6=aCallable$b,$TypeError$3=TypeError,PromiseCapability=function(e){var t,r;this.promise=new e((function(e,n){if(void 0!==t||void 0!==r)throw $TypeError$3("Bad Promise constructor");t=e,r=n})),this.resolve=aCallable$6(t),this.reject=aCallable$6(r)};newPromiseCapability$2.f=function(e){return new PromiseCapability(e)};var Internal,OwnPromiseCapability,PromiseWrapper,nativeThen,$$z=_export,IS_NODE$1=engineIsNode,global$l=global$K,call$j=functionCall,defineBuiltIn$b=defineBuiltIn$j,setPrototypeOf$3=objectSetPrototypeOf,setToStringTag$6=setToStringTag$a,setSpecies$2=setSpecies$4,aCallable$5=aCallable$b,isCallable$7=isCallable$t,isObject$c=isObject$s,anInstance$7=anInstance$a,speciesConstructor$3=speciesConstructor$4,task=task$1.set,microtask=microtask$1,hostReportErrors=hostReportErrors$1,perform$2=perform$3,Queue=queue,InternalStateModule$8=internalState,NativePromiseConstructor$3=promiseNativeConstructor,PromiseConstructorDetection=promiseConstructorDetection,newPromiseCapabilityModule$3=newPromiseCapability$2,PROMISE="Promise",FORCED_PROMISE_CONSTRUCTOR$4=PromiseConstructorDetection.CONSTRUCTOR,NATIVE_PROMISE_REJECTION_EVENT=PromiseConstructorDetection.REJECTION_EVENT,NATIVE_PROMISE_SUBCLASSING=PromiseConstructorDetection.SUBCLASSING,getInternalPromiseState=InternalStateModule$8.getterFor(PROMISE),setInternalState$7=InternalStateModule$8.set,NativePromisePrototype$2=NativePromiseConstructor$3&&NativePromiseConstructor$3.prototype,PromiseConstructor=NativePromiseConstructor$3,PromisePrototype=NativePromisePrototype$2,TypeError$6=global$l.TypeError,document$1=global$l.document,process=global$l.process,newPromiseCapability$1=newPromiseCapabilityModule$3.f,newGenericPromiseCapability=newPromiseCapability$1,DISPATCH_EVENT=!!(document$1&&document$1.createEvent&&global$l.dispatchEvent),UNHANDLED_REJECTION="unhandledrejection",REJECTION_HANDLED="rejectionhandled",PENDING=0,FULFILLED=1,REJECTED=2,HANDLED=1,UNHANDLED=2,isThenable=function(e){var t;return!(!isObject$c(e)||!isCallable$7(t=e.then))&&t},callReaction=function(e,t){var r,n,i,o=t.value,a=t.state==FULFILLED,s=a?e.ok:e.fail,c=e.resolve,u=e.reject,l=e.domain;try{s?(a||(t.rejection===UNHANDLED&&onHandleUnhandled(t),t.rejection=HANDLED),!0===s?r=o:(l&&l.enter(),r=s(o),l&&(l.exit(),i=!0)),r===e.promise?u(TypeError$6("Promise-chain cycle")):(n=isThenable(r))?call$j(n,r,c,u):c(r)):u(o)}catch(e){l&&!i&&l.exit(),u(e)}},notify=function(e,t){e.notified||(e.notified=!0,microtask((function(){for(var r,n=e.reactions;r=n.get();)callReaction(r,e);e.notified=!1,t&&!e.rejection&&onUnhandled(e)})))},dispatchEvent=function(e,t,r){var n,i;DISPATCH_EVENT?((n=document$1.createEvent("Event")).promise=t,n.reason=r,n.initEvent(e,!1,!0),global$l.dispatchEvent(n)):n={promise:t,reason:r},!NATIVE_PROMISE_REJECTION_EVENT&&(i=global$l["on"+e])?i(n):e===UNHANDLED_REJECTION&&hostReportErrors("Unhandled promise rejection",r)},onUnhandled=function(e){call$j(task,global$l,(function(){var t,r=e.facade,n=e.value;if(isUnhandled(e)&&(t=perform$2((function(){IS_NODE$1?process.emit("unhandledRejection",n,r):dispatchEvent(UNHANDLED_REJECTION,r,n)})),e.rejection=IS_NODE$1||isUnhandled(e)?UNHANDLED:HANDLED,t.error))throw t.value}))},isUnhandled=function(e){return e.rejection!==HANDLED&&!e.parent},onHandleUnhandled=function(e){call$j(task,global$l,(function(){var t=e.facade;IS_NODE$1?process.emit("rejectionHandled",t):dispatchEvent(REJECTION_HANDLED,t,e.value)}))},bind$5=function(e,t,r){return function(n){e(t,n,r)}},internalReject=function(e,t,r){e.done||(e.done=!0,r&&(e=r),e.value=t,e.state=REJECTED,notify(e,!0))},internalResolve=function(e,t,r){if(!e.done){e.done=!0,r&&(e=r);try{if(e.facade===t)throw TypeError$6("Promise can't be resolved itself");var n=isThenable(t);n?microtask((function(){var r={done:!1};try{call$j(n,t,bind$5(internalResolve,r,e),bind$5(internalReject,r,e))}catch(t){internalReject(r,t,e)}})):(e.value=t,e.state=FULFILLED,notify(e,!1))}catch(t){internalReject({done:!1},t,e)}}};if(FORCED_PROMISE_CONSTRUCTOR$4&&(PromisePrototype=(PromiseConstructor=function(e){anInstance$7(this,PromisePrototype),aCallable$5(e),call$j(Internal,this);var t=getInternalPromiseState(this);try{e(bind$5(internalResolve,t),bind$5(internalReject,t))}catch(e){internalReject(t,e)}}).prototype,(Internal=function(e){setInternalState$7(this,{type:PROMISE,done:!1,notified:!1,parent:!1,reactions:new Queue,rejection:!1,state:PENDING,value:void 0})}).prototype=defineBuiltIn$b(PromisePrototype,"then",(function(e,t){var r=getInternalPromiseState(this),n=newPromiseCapability$1(speciesConstructor$3(this,PromiseConstructor));return r.parent=!0,n.ok=!isCallable$7(e)||e,n.fail=isCallable$7(t)&&t,n.domain=IS_NODE$1?process.domain:void 0,r.state==PENDING?r.reactions.add(n):microtask((function(){callReaction(n,r)})),n.promise})),OwnPromiseCapability=function(){var e=new Internal,t=getInternalPromiseState(e);this.promise=e,this.resolve=bind$5(internalResolve,t),this.reject=bind$5(internalReject,t)},newPromiseCapabilityModule$3.f=newPromiseCapability$1=function(e){return e===PromiseConstructor||e===PromiseWrapper?new OwnPromiseCapability(e):newGenericPromiseCapability(e)},isCallable$7(NativePromiseConstructor$3)&&NativePromisePrototype$2!==Object.prototype)){nativeThen=NativePromisePrototype$2.then,NATIVE_PROMISE_SUBCLASSING||defineBuiltIn$b(NativePromisePrototype$2,"then",(function(e,t){var r=this;return new PromiseConstructor((function(e,t){call$j(nativeThen,r,e,t)})).then(e,t)}),{unsafe:!0});try{delete NativePromisePrototype$2.constructor}catch(e){}setPrototypeOf$3&&setPrototypeOf$3(NativePromisePrototype$2,PromisePrototype)}$$z({global:!0,constructor:!0,wrap:!0,forced:FORCED_PROMISE_CONSTRUCTOR$4},{Promise:PromiseConstructor}),setToStringTag$6(PromiseConstructor,PROMISE,!1),setSpecies$2(PROMISE);var NativePromiseConstructor$2=promiseNativeConstructor,checkCorrectnessOfIteration$2=checkCorrectnessOfIteration$4,FORCED_PROMISE_CONSTRUCTOR$3=promiseConstructorDetection.CONSTRUCTOR,promiseStaticsIncorrectIteration=FORCED_PROMISE_CONSTRUCTOR$3||!checkCorrectnessOfIteration$2((function(e){NativePromiseConstructor$2.all(e).then(void 0,(function(){}))})),$$y=_export,call$i=functionCall,aCallable$4=aCallable$b,newPromiseCapabilityModule$2=newPromiseCapability$2,perform$1=perform$3,iterate$2=iterate$5,PROMISE_STATICS_INCORRECT_ITERATION$1=promiseStaticsIncorrectIteration;$$y({target:"Promise",stat:!0,forced:PROMISE_STATICS_INCORRECT_ITERATION$1},{all:function(e){var t=this,r=newPromiseCapabilityModule$2.f(t),n=r.resolve,i=r.reject,o=perform$1((function(){var r=aCallable$4(t.resolve),o=[],a=0,s=1;iterate$2(e,(function(e){var c=a++,u=!1;s++,call$i(r,t,e).then((function(e){u||(u=!0,o[c]=e,--s||n(o))}),i)})),--s||n(o)}));return o.error&&i(o.value),r.promise}});var $$x=_export,FORCED_PROMISE_CONSTRUCTOR$2=promiseConstructorDetection.CONSTRUCTOR,NativePromiseConstructor$1=promiseNativeConstructor,getBuiltIn$8=getBuiltIn$g,isCallable$6=isCallable$t,defineBuiltIn$a=defineBuiltIn$j,NativePromisePrototype$1=NativePromiseConstructor$1&&NativePromiseConstructor$1.prototype;if($$x({target:"Promise",proto:!0,forced:FORCED_PROMISE_CONSTRUCTOR$2,real:!0},{catch:function(e){return this.then(void 0,e)}}),isCallable$6(NativePromiseConstructor$1)){var method$1=getBuiltIn$8("Promise").prototype.catch;NativePromisePrototype$1.catch!==method$1&&defineBuiltIn$a(NativePromisePrototype$1,"catch",method$1,{unsafe:!0})}var $$w=_export,call$h=functionCall,aCallable$3=aCallable$b,newPromiseCapabilityModule$1=newPromiseCapability$2,perform=perform$3,iterate$1=iterate$5,PROMISE_STATICS_INCORRECT_ITERATION=promiseStaticsIncorrectIteration;$$w({target:"Promise",stat:!0,forced:PROMISE_STATICS_INCORRECT_ITERATION},{race:function(e){var t=this,r=newPromiseCapabilityModule$1.f(t),n=r.reject,i=perform((function(){var i=aCallable$3(t.resolve);iterate$1(e,(function(e){call$h(i,t,e).then(r.resolve,n)}))}));return i.error&&n(i.value),r.promise}});var $$v=_export,call$g=functionCall,newPromiseCapabilityModule=newPromiseCapability$2,FORCED_PROMISE_CONSTRUCTOR$1=promiseConstructorDetection.CONSTRUCTOR;$$v({target:"Promise",stat:!0,forced:FORCED_PROMISE_CONSTRUCTOR$1},{reject:function(e){var t=newPromiseCapabilityModule.f(this);return call$g(t.reject,void 0,e),t.promise}});var anObject$c=anObject$q,isObject$b=isObject$s,newPromiseCapability=newPromiseCapability$2,promiseResolve$2=function(e,t){if(anObject$c(e),isObject$b(t)&&t.constructor===e)return t;var r=newPromiseCapability.f(e);return(0,r.resolve)(t),r.promise},$$u=_export,getBuiltIn$7=getBuiltIn$g,FORCED_PROMISE_CONSTRUCTOR=promiseConstructorDetection.CONSTRUCTOR,promiseResolve$1=promiseResolve$2;getBuiltIn$7("Promise"),$$u({target:"Promise",stat:!0,forced:FORCED_PROMISE_CONSTRUCTOR},{resolve:function(e){return promiseResolve$1(this,e)}});var IS_NODE=engineIsNode,tryNodeRequire$1=function(e){try{if(IS_NODE)return Function('return require("'+e+'")')()}catch(e){}},makeBuiltIn=makeBuiltIn$3.exports,defineProperty$8=objectDefineProperty,defineBuiltInAccessor$5=function(e,t,r){return r.get&&makeBuiltIn(r.get,t,{getter:!0}),r.set&&makeBuiltIn(r.set,t,{setter:!0}),defineProperty$8.f(e,t,r)},DESCRIPTORS$f=descriptors,fails$r=fails$U,anObject$b=anObject$q,create$3=objectCreate,normalizeStringArgument$2=normalizeStringArgument$4,nativeErrorToString=Error.prototype.toString,INCORRECT_TO_STRING$1=fails$r((function(){if(DESCRIPTORS$f){var e=create$3(Object.defineProperty({},"name",{get:function(){return this===e}}));if("true"!==nativeErrorToString.call(e))return!0}return"2: 1"!==nativeErrorToString.call({message:1,name:2})||"Error"!==nativeErrorToString.call({})})),errorToString$1=INCORRECT_TO_STRING$1?function(){var e=anObject$b(this),t=normalizeStringArgument$2(e.name,"Error"),r=normalizeStringArgument$2(e.message);return t?r?t+": "+r:t:r}:nativeErrorToString,domExceptionConstants={IndexSizeError:{s:"INDEX_SIZE_ERR",c:1,m:1},DOMStringSizeError:{s:"DOMSTRING_SIZE_ERR",c:2,m:0},HierarchyRequestError:{s:"HIERARCHY_REQUEST_ERR",c:3,m:1},WrongDocumentError:{s:"WRONG_DOCUMENT_ERR",c:4,m:1},InvalidCharacterError:{s:"INVALID_CHARACTER_ERR",c:5,m:1},NoDataAllowedError:{s:"NO_DATA_ALLOWED_ERR",c:6,m:0},NoModificationAllowedError:{s:"NO_MODIFICATION_ALLOWED_ERR",c:7,m:1},NotFoundError:{s:"NOT_FOUND_ERR",c:8,m:1},NotSupportedError:{s:"NOT_SUPPORTED_ERR",c:9,m:1},InUseAttributeError:{s:"INUSE_ATTRIBUTE_ERR",c:10,m:1},InvalidStateError:{s:"INVALID_STATE_ERR",c:11,m:1},SyntaxError:{s:"SYNTAX_ERR",c:12,m:1},InvalidModificationError:{s:"INVALID_MODIFICATION_ERR",c:13,m:1},NamespaceError:{s:"NAMESPACE_ERR",c:14,m:1},InvalidAccessError:{s:"INVALID_ACCESS_ERR",c:15,m:1},ValidationError:{s:"VALIDATION_ERR",c:16,m:0},TypeMismatchError:{s:"TYPE_MISMATCH_ERR",c:17,m:1},SecurityError:{s:"SECURITY_ERR",c:18,m:1},NetworkError:{s:"NETWORK_ERR",c:19,m:1},AbortError:{s:"ABORT_ERR",c:20,m:1},URLMismatchError:{s:"URL_MISMATCH_ERR",c:21,m:1},QuotaExceededError:{s:"QUOTA_EXCEEDED_ERR",c:22,m:1},TimeoutError:{s:"TIMEOUT_ERR",c:23,m:1},InvalidNodeTypeError:{s:"INVALID_NODE_TYPE_ERR",c:24,m:1},DataCloneError:{s:"DATA_CLONE_ERR",c:25,m:1}},$$t=_export,tryNodeRequire=tryNodeRequire$1,getBuiltIn$6=getBuiltIn$g,fails$q=fails$U,create$2=objectCreate,createPropertyDescriptor$5=createPropertyDescriptor$b,defineProperty$7=objectDefineProperty.f,defineBuiltIn$9=defineBuiltIn$j,defineBuiltInAccessor$4=defineBuiltInAccessor$5,hasOwn$e=hasOwnProperty_1,anInstance$6=anInstance$a,anObject$a=anObject$q,errorToString=errorToString$1,normalizeStringArgument$1=normalizeStringArgument$4,DOMExceptionConstants$1=domExceptionConstants,clearErrorStack$1=errorStackClear,InternalStateModule$7=internalState,DESCRIPTORS$e=descriptors,DOM_EXCEPTION$2="DOMException",DATA_CLONE_ERR="DATA_CLONE_ERR",Error$2=getBuiltIn$6("Error"),NativeDOMException$1=getBuiltIn$6(DOM_EXCEPTION$2)||function(){try{(new(getBuiltIn$6("MessageChannel")||tryNodeRequire("worker_threads").MessageChannel)).port1.postMessage(new WeakMap)}catch(e){if(e.name==DATA_CLONE_ERR&&25==e.code)return e.constructor}}(),NativeDOMExceptionPrototype=NativeDOMException$1&&NativeDOMException$1.prototype,ErrorPrototype=Error$2.prototype,setInternalState$6=InternalStateModule$7.set,getInternalState$6=InternalStateModule$7.getterFor(DOM_EXCEPTION$2),HAS_STACK="stack"in Error$2(DOM_EXCEPTION$2),codeFor=function(e){return hasOwn$e(DOMExceptionConstants$1,e)&&DOMExceptionConstants$1[e].m?DOMExceptionConstants$1[e].c:0},$DOMException$1=function(){anInstance$6(this,DOMExceptionPrototype$1);var e=arguments.length,t=normalizeStringArgument$1(e<1?void 0:arguments[0]),r=normalizeStringArgument$1(e<2?void 0:arguments[1],"Error"),n=codeFor(r);if(setInternalState$6(this,{type:DOM_EXCEPTION$2,name:r,message:t,code:n}),DESCRIPTORS$e||(this.name=r,this.message=t,this.code=n),HAS_STACK){var i=Error$2(t);i.name=DOM_EXCEPTION$2,defineProperty$7(this,"stack",createPropertyDescriptor$5(1,clearErrorStack$1(i.stack,1)))}},DOMExceptionPrototype$1=$DOMException$1.prototype=create$2(ErrorPrototype),createGetterDescriptor=function(e){return{enumerable:!0,configurable:!0,get:e}},getterFor=function(e){return createGetterDescriptor((function(){return getInternalState$6(this)[e]}))};DESCRIPTORS$e&&(defineBuiltInAccessor$4(DOMExceptionPrototype$1,"code",getterFor("code")),defineBuiltInAccessor$4(DOMExceptionPrototype$1,"message",getterFor("message")),defineBuiltInAccessor$4(DOMExceptionPrototype$1,"name",getterFor("name"))),defineProperty$7(DOMExceptionPrototype$1,"constructor",createPropertyDescriptor$5(1,$DOMException$1));var INCORRECT_CONSTRUCTOR=fails$q((function(){return!(new NativeDOMException$1 instanceof Error$2)})),INCORRECT_TO_STRING=INCORRECT_CONSTRUCTOR||fails$q((function(){return ErrorPrototype.toString!==errorToString||"2: 1"!==String(new NativeDOMException$1(1,2))})),INCORRECT_CODE=INCORRECT_CONSTRUCTOR||fails$q((function(){return 25!==new NativeDOMException$1(1,"DataCloneError").code}));INCORRECT_CONSTRUCTOR||25!==NativeDOMException$1[DATA_CLONE_ERR]||NativeDOMExceptionPrototype[DATA_CLONE_ERR];var FORCED_CONSTRUCTOR$1=INCORRECT_CONSTRUCTOR;$$t({global:!0,constructor:!0,forced:INCORRECT_CONSTRUCTOR},{DOMException:INCORRECT_CONSTRUCTOR?$DOMException$1:NativeDOMException$1});var PolyfilledDOMException$1=getBuiltIn$6(DOM_EXCEPTION$2),PolyfilledDOMExceptionPrototype$1=PolyfilledDOMException$1.prototype;for(var key$3 in INCORRECT_TO_STRING&&NativeDOMException$1===PolyfilledDOMException$1&&defineBuiltIn$9(PolyfilledDOMExceptionPrototype$1,"toString",errorToString),INCORRECT_CODE&&DESCRIPTORS$e&&NativeDOMException$1===PolyfilledDOMException$1&&defineBuiltInAccessor$4(PolyfilledDOMExceptionPrototype$1,"code",createGetterDescriptor((function(){return codeFor(anObject$a(this).name)}))),DOMExceptionConstants$1)if(hasOwn$e(DOMExceptionConstants$1,key$3)){var constant$2=DOMExceptionConstants$1[key$3],constantName$1=constant$2.s,descriptor$1=createPropertyDescriptor$5(6,constant$2.c);hasOwn$e(PolyfilledDOMException$1,constantName$1)||defineProperty$7(PolyfilledDOMException$1,constantName$1,descriptor$1),hasOwn$e(PolyfilledDOMExceptionPrototype$1,constantName$1)||defineProperty$7(PolyfilledDOMExceptionPrototype$1,constantName$1,descriptor$1)}var $$s=_export,global$k=global$K,getBuiltIn$5=getBuiltIn$g,createPropertyDescriptor$4=createPropertyDescriptor$b,defineProperty$6=objectDefineProperty.f,hasOwn$d=hasOwnProperty_1,anInstance$5=anInstance$a,inheritIfRequired$3=inheritIfRequired$6,normalizeStringArgument=normalizeStringArgument$4,DOMExceptionConstants=domExceptionConstants,clearErrorStack=errorStackClear,DESCRIPTORS$d=descriptors,DOM_EXCEPTION$1="DOMException",Error$1=getBuiltIn$5("Error"),NativeDOMException=getBuiltIn$5(DOM_EXCEPTION$1),$DOMException=function(){anInstance$5(this,DOMExceptionPrototype);var e=arguments.length,t=normalizeStringArgument(e<1?void 0:arguments[0]),r=normalizeStringArgument(e<2?void 0:arguments[1],"Error"),n=new NativeDOMException(t,r),i=Error$1(t);return i.name=DOM_EXCEPTION$1,defineProperty$6(n,"stack",createPropertyDescriptor$4(1,clearErrorStack(i.stack,1))),inheritIfRequired$3(n,this,$DOMException),n},DOMExceptionPrototype=$DOMException.prototype=NativeDOMException.prototype,ERROR_HAS_STACK="stack"in Error$1(DOM_EXCEPTION$1),DOM_EXCEPTION_HAS_STACK="stack"in new NativeDOMException(1,2),descriptor=NativeDOMException&&DESCRIPTORS$d&&Object.getOwnPropertyDescriptor(global$k,DOM_EXCEPTION$1),BUGGY_DESCRIPTOR=!(!descriptor||descriptor.writable&&descriptor.configurable),FORCED_CONSTRUCTOR=ERROR_HAS_STACK&&!BUGGY_DESCRIPTOR&&!DOM_EXCEPTION_HAS_STACK;$$s({global:!0,constructor:!0,forced:FORCED_CONSTRUCTOR},{DOMException:FORCED_CONSTRUCTOR?$DOMException:NativeDOMException});var PolyfilledDOMException=getBuiltIn$5(DOM_EXCEPTION$1),PolyfilledDOMExceptionPrototype=PolyfilledDOMException.prototype;if(PolyfilledDOMExceptionPrototype.constructor!==PolyfilledDOMException)for(var key$2 in defineProperty$6(PolyfilledDOMExceptionPrototype,"constructor",createPropertyDescriptor$4(1,PolyfilledDOMException)),DOMExceptionConstants)if(hasOwn$d(DOMExceptionConstants,key$2)){var constant$1=DOMExceptionConstants[key$2],constantName=constant$1.s;hasOwn$d(PolyfilledDOMException,constantName)||defineProperty$6(PolyfilledDOMException,constantName,createPropertyDescriptor$4(6,constant$1.c))}var getBuiltIn$4=getBuiltIn$g,setToStringTag$5=setToStringTag$a,DOM_EXCEPTION="DOMException";setToStringTag$5(getBuiltIn$4(DOM_EXCEPTION),DOM_EXCEPTION);var $$r=_export,$filter$1=arrayIteration.filter,arrayMethodHasSpeciesSupport$1=arrayMethodHasSpeciesSupport$5,HAS_SPECIES_SUPPORT=arrayMethodHasSpeciesSupport$1("filter");$$r({target:"Array",proto:!0,forced:!HAS_SPECIES_SUPPORT},{filter:function(e){return $filter$1(this,e,arguments.length>1?arguments[1]:void 0)}});var $$q=_export,fails$p=fails$U,isArray$3=isArray$7,isObject$a=isObject$s,toObject$9=toObject$i,lengthOfArrayLike$d=lengthOfArrayLike$m,doesNotExceedSafeInteger$1=doesNotExceedSafeInteger$4,createProperty$1=createProperty$5,arraySpeciesCreate=arraySpeciesCreate$3,arrayMethodHasSpeciesSupport=arrayMethodHasSpeciesSupport$5,wellKnownSymbol$9=wellKnownSymbol$u,V8_VERSION=engineV8Version,IS_CONCAT_SPREADABLE=wellKnownSymbol$9("isConcatSpreadable"),IS_CONCAT_SPREADABLE_SUPPORT=V8_VERSION>=51||!fails$p((function(){var e=[];return e[IS_CONCAT_SPREADABLE]=!1,e.concat()[0]!==e})),SPECIES_SUPPORT=arrayMethodHasSpeciesSupport("concat"),isConcatSpreadable=function(e){if(!isObject$a(e))return!1;var t=e[IS_CONCAT_SPREADABLE];return void 0!==t?!!t:isArray$3(e)},FORCED$8=!IS_CONCAT_SPREADABLE_SUPPORT||!SPECIES_SUPPORT;$$q({target:"Array",proto:!0,arity:1,forced:FORCED$8},{concat:function(e){var t,r,n,i,o,a=toObject$9(this),s=arraySpeciesCreate(a,0),c=0;for(t=-1,n=arguments.length;t<n;t++)if(isConcatSpreadable(o=-1===t?a:arguments[t]))for(i=lengthOfArrayLike$d(o),doesNotExceedSafeInteger$1(c+i),r=0;r<i;r++,c++)r in o&&createProperty$1(s,c,o[r]);else doesNotExceedSafeInteger$1(c+1),createProperty$1(s,c++,o);return s.length=c,s}});var uncurryThis$q=functionUncurryThis,toObject$8=toObject$i,floor$6=Math.floor,charAt$5=uncurryThis$q("".charAt),replace$5=uncurryThis$q("".replace),stringSlice$7=uncurryThis$q("".slice),SUBSTITUTION_SYMBOLS=/\$([$&'`]|\d{1,2}|<[^>]*>)/g,SUBSTITUTION_SYMBOLS_NO_NAMED=/\$([$&'`]|\d{1,2})/g,getSubstitution$1=function(e,t,r,n,i,o){var a=r+e.length,s=n.length,c=SUBSTITUTION_SYMBOLS_NO_NAMED;return void 0!==i&&(i=toObject$8(i),c=SUBSTITUTION_SYMBOLS),replace$5(o,c,(function(o,c){var u;switch(charAt$5(c,0)){case"$":return"$";case"&":return e;case"`":return stringSlice$7(t,0,r);case"'":return stringSlice$7(t,a);case"<":u=i[stringSlice$7(c,1,-1)];break;default:var l=+c;if(0===l)return o;if(l>s){var d=floor$6(l/10);return 0===d?o:d<=s?void 0===n[d-1]?charAt$5(c,1):n[d-1]+charAt$5(c,1):o}u=n[l-1]}return void 0===u?"":u}))},apply$6=functionApply,call$f=functionCall,uncurryThis$p=functionUncurryThis,fixRegExpWellKnownSymbolLogic$1=fixRegexpWellKnownSymbolLogic,fails$o=fails$U,anObject$9=anObject$q,isCallable$5=isCallable$t,isNullOrUndefined$2=isNullOrUndefined$b,toIntegerOrInfinity$8=toIntegerOrInfinity$d,toLength$6=toLength$a,toString$b=toString$m,requireObjectCoercible$4=requireObjectCoercible$d,advanceStringIndex$1=advanceStringIndex$3,getMethod$1=getMethod$7,getSubstitution=getSubstitution$1,regExpExec=regexpExecAbstract,wellKnownSymbol$8=wellKnownSymbol$u,REPLACE=wellKnownSymbol$8("replace"),max=Math.max,min$4=Math.min,concat=uncurryThis$p([].concat),push$7=uncurryThis$p([].push),stringIndexOf$1=uncurryThis$p("".indexOf),stringSlice$6=uncurryThis$p("".slice),maybeToString=function(e){return void 0===e?e:String(e)},REPLACE_KEEPS_$0="$0"==="a".replace(/./,"$0"),REGEXP_REPLACE_SUBSTITUTES_UNDEFINED_CAPTURE=!!/./[REPLACE]&&""===/./[REPLACE]("a","$0"),REPLACE_SUPPORTS_NAMED_GROUPS=!fails$o((function(){var e=/./;return e.exec=function(){var e=[];return e.groups={a:"7"},e},"7"!=="".replace(e,"$<a>")}));fixRegExpWellKnownSymbolLogic$1("replace",(function(e,t,r){var n=REGEXP_REPLACE_SUBSTITUTES_UNDEFINED_CAPTURE?"$":"$0";return[function(e,r){var n=requireObjectCoercible$4(this),i=isNullOrUndefined$2(e)?void 0:getMethod$1(e,REPLACE);return i?call$f(i,e,n,r):call$f(t,toString$b(n),e,r)},function(e,i){var o=anObject$9(this),a=toString$b(e);if("string"==typeof i&&-1===stringIndexOf$1(i,n)&&-1===stringIndexOf$1(i,"$<")){var s=r(t,o,a,i);if(s.done)return s.value}var c=isCallable$5(i);c||(i=toString$b(i));var u=o.global;if(u){var l=o.unicode;o.lastIndex=0}for(var d=[];;){var p=regExpExec(o,a);if(null===p)break;if(push$7(d,p),!u)break;""===toString$b(p[0])&&(o.lastIndex=advanceStringIndex$1(a,toLength$6(o.lastIndex),l))}for(var _="",f=0,h=0;h<d.length;h++){for(var m=toString$b((p=d[h])[0]),y=max(min$4(toIntegerOrInfinity$8(p.index),a.length),0),v=[],S=1;S<p.length;S++)push$7(v,maybeToString(p[S]));var g=p.groups;if(c){var E=concat([m],v,y,a);void 0!==g&&push$7(E,g);var T=toString$b(apply$6(i,void 0,E))}else T=getSubstitution(m,a,y,v,g,i);y>=f&&(_+=stringSlice$6(a,f,y)+T,f=y+m.length)}return _+stringSlice$6(a,f)}]}),!REPLACE_SUPPORTS_NAMED_GROUPS||!REPLACE_KEEPS_$0||REGEXP_REPLACE_SUBSTITUTES_UNDEFINED_CAPTURE);var call$e=functionCall,hasOwn$c=hasOwnProperty_1,isPrototypeOf$5=objectIsPrototypeOf,regExpFlags$1=regexpFlags$1,RegExpPrototype$5=RegExp.prototype,regexpGetFlags=function(e){var t=e.flags;return void 0!==t||"flags"in RegExpPrototype$5||hasOwn$c(e,"flags")||!isPrototypeOf$5(RegExpPrototype$5,e)?t:call$e(regExpFlags$1,e)},DESCRIPTORS$c=descriptors,global$j=global$K,uncurryThis$o=functionUncurryThis,isForced$1=isForced_1,inheritIfRequired$2=inheritIfRequired$6,createNonEnumerableProperty$3=createNonEnumerableProperty$c,getOwnPropertyNames$3=objectGetOwnPropertyNames.f,isPrototypeOf$4=objectIsPrototypeOf,isRegExp$1=isRegexp,toString$a=toString$m,getRegExpFlags$1=regexpGetFlags,stickyHelpers$1=regexpStickyHelpers,proxyAccessor=proxyAccessor$2,defineBuiltIn$8=defineBuiltIn$j,fails$n=fails$U,hasOwn$b=hasOwnProperty_1,enforceInternalState$3=internalState.enforce,setSpecies$1=setSpecies$4,wellKnownSymbol$7=wellKnownSymbol$u,UNSUPPORTED_DOT_ALL$1=regexpUnsupportedDotAll,UNSUPPORTED_NCG=regexpUnsupportedNcg,MATCH$1=wellKnownSymbol$7("match"),NativeRegExp=global$j.RegExp,RegExpPrototype$4=NativeRegExp.prototype,SyntaxError=global$j.SyntaxError,exec$4=uncurryThis$o(RegExpPrototype$4.exec),charAt$4=uncurryThis$o("".charAt),replace$4=uncurryThis$o("".replace),stringIndexOf=uncurryThis$o("".indexOf),stringSlice$5=uncurryThis$o("".slice),IS_NCG=/^\?<[^\s\d!#%&*+<=>@^][^\s!#%&*+<=>@^]*>/,re1=/a/g,re2=/a/g,CORRECT_NEW=new NativeRegExp(re1)!==re1,MISSED_STICKY$1=stickyHelpers$1.MISSED_STICKY,UNSUPPORTED_Y$1=stickyHelpers$1.UNSUPPORTED_Y,BASE_FORCED=DESCRIPTORS$c&&(!CORRECT_NEW||MISSED_STICKY$1||UNSUPPORTED_DOT_ALL$1||UNSUPPORTED_NCG||fails$n((function(){return re2[MATCH$1]=!1,NativeRegExp(re1)!=re1||NativeRegExp(re2)==re2||"/a/i"!=NativeRegExp(re1,"i")}))),handleDotAll=function(e){for(var t,r=e.length,n=0,i="",o=!1;n<=r;n++)"\\"!==(t=charAt$4(e,n))?o||"."!==t?("["===t?o=!0:"]"===t&&(o=!1),i+=t):i+="[\\s\\S]":i+=t+charAt$4(e,++n);return i},handleNCG=function(e){for(var t,r=e.length,n=0,i="",o=[],a={},s=!1,c=!1,u=0,l="";n<=r;n++){if("\\"===(t=charAt$4(e,n)))t+=charAt$4(e,++n);else if("]"===t)s=!1;else if(!s)switch(!0){case"["===t:s=!0;break;case"("===t:exec$4(IS_NCG,stringSlice$5(e,n+1))&&(n+=2,c=!0),i+=t,u++;continue;case">"===t&&c:if(""===l||hasOwn$b(a,l))throw new SyntaxError("Invalid capture group name");a[l]=!0,o[o.length]=[l,u],c=!1,l="";continue}c?l+=t:i+=t}return[i,o]};if(isForced$1("RegExp",BASE_FORCED)){for(var RegExpWrapper=function(e,t){var r,n,i,o,a,s,c=isPrototypeOf$4(RegExpPrototype$4,this),u=isRegExp$1(e),l=void 0===t,d=[],p=e;if(!c&&u&&l&&e.constructor===RegExpWrapper)return e;if((u||isPrototypeOf$4(RegExpPrototype$4,e))&&(e=e.source,l&&(t=getRegExpFlags$1(p))),e=void 0===e?"":toString$a(e),t=void 0===t?"":toString$a(t),p=e,UNSUPPORTED_DOT_ALL$1&&"dotAll"in re1&&(n=!!t&&stringIndexOf(t,"s")>-1)&&(t=replace$4(t,/s/g,"")),r=t,MISSED_STICKY$1&&"sticky"in re1&&(i=!!t&&stringIndexOf(t,"y")>-1)&&UNSUPPORTED_Y$1&&(t=replace$4(t,/y/g,"")),UNSUPPORTED_NCG&&(e=(o=handleNCG(e))[0],d=o[1]),a=inheritIfRequired$2(NativeRegExp(e,t),c?this:RegExpPrototype$4,RegExpWrapper),(n||i||d.length)&&(s=enforceInternalState$3(a),n&&(s.dotAll=!0,s.raw=RegExpWrapper(handleDotAll(e),r)),i&&(s.sticky=!0),d.length&&(s.groups=d)),e!==p)try{createNonEnumerableProperty$3(a,"source",""===p?"(?:)":p)}catch(e){}return a},keys$3=getOwnPropertyNames$3(NativeRegExp),index$1=0;keys$3.length>index$1;)proxyAccessor(RegExpWrapper,NativeRegExp,keys$3[index$1++]);RegExpPrototype$4.constructor=RegExpWrapper,RegExpWrapper.prototype=RegExpPrototype$4,defineBuiltIn$8(global$j,"RegExp",RegExpWrapper,{constructor:!0})}setSpecies$1("RegExp");var DESCRIPTORS$b=descriptors,UNSUPPORTED_DOT_ALL=regexpUnsupportedDotAll,classof$6=classofRaw$2,defineBuiltInAccessor$3=defineBuiltInAccessor$5,getInternalState$5=internalState.get,RegExpPrototype$3=RegExp.prototype,$TypeError$2=TypeError;DESCRIPTORS$b&&UNSUPPORTED_DOT_ALL&&defineBuiltInAccessor$3(RegExpPrototype$3,"dotAll",{configurable:!0,get:function(){if(this!==RegExpPrototype$3){if("RegExp"===classof$6(this))return!!getInternalState$5(this).dotAll;throw $TypeError$2("Incompatible receiver, RegExp required")}}});var DESCRIPTORS$a=descriptors,MISSED_STICKY=regexpStickyHelpers.MISSED_STICKY,classof$5=classofRaw$2,defineBuiltInAccessor$2=defineBuiltInAccessor$5,getInternalState$4=internalState.get,RegExpPrototype$2=RegExp.prototype,$TypeError$1=TypeError;DESCRIPTORS$a&&MISSED_STICKY&&defineBuiltInAccessor$2(RegExpPrototype$2,"sticky",{configurable:!0,get:function(){if(this!==RegExpPrototype$2){if("RegExp"===classof$5(this))return!!getInternalState$4(this).sticky;throw $TypeError$1("Incompatible receiver, RegExp required")}}});var PROPER_FUNCTION_NAME$2=functionName.PROPER,defineBuiltIn$7=defineBuiltIn$j,anObject$8=anObject$q,$toString$3=toString$m,fails$m=fails$U,getRegExpFlags=regexpGetFlags,TO_STRING="toString",RegExpPrototype$1=RegExp.prototype,nativeToString=RegExpPrototype$1[TO_STRING],NOT_GENERIC=fails$m((function(){return"/a/b"!=nativeToString.call({source:"a",flags:"b"})})),INCORRECT_NAME=PROPER_FUNCTION_NAME$2&&nativeToString.name!=TO_STRING;(NOT_GENERIC||INCORRECT_NAME)&&defineBuiltIn$7(RegExp.prototype,TO_STRING,(function(){var e=anObject$8(this);return"/"+$toString$3(e.source)+"/"+$toString$3(getRegExpFlags(e))}),{unsafe:!0});var $$p=_export,fails$l=fails$U,toIndexedObject$4=toIndexedObject$c,nativeGetOwnPropertyDescriptor$2=objectGetOwnPropertyDescriptor.f,DESCRIPTORS$9=descriptors,FAILS_ON_PRIMITIVES=fails$l((function(){nativeGetOwnPropertyDescriptor$2(1)})),FORCED$7=!DESCRIPTORS$9||FAILS_ON_PRIMITIVES;$$p({target:"Object",stat:!0,forced:FORCED$7,sham:!DESCRIPTORS$9},{getOwnPropertyDescriptor:function(e,t){return nativeGetOwnPropertyDescriptor$2(toIndexedObject$4(e),t)}});var $$o=_export,getBuiltIn$3=getBuiltIn$g,apply$5=functionApply,call$d=functionCall,uncurryThis$n=functionUncurryThis,fails$k=fails$U,isArray$2=isArray$7,isCallable$4=isCallable$t,isObject$9=isObject$s,isSymbol$3=isSymbol$6,arraySlice$7=arraySlice$9,NATIVE_SYMBOL$3=symbolConstructorDetection,$stringify=getBuiltIn$3("JSON","stringify"),exec$3=uncurryThis$n(/./.exec),charAt$3=uncurryThis$n("".charAt),charCodeAt$2=uncurryThis$n("".charCodeAt),replace$3=uncurryThis$n("".replace),numberToString$1=uncurryThis$n(1..toString),tester=/[\uD800-\uDFFF]/g,low=/^[\uD800-\uDBFF]$/,hi=/^[\uDC00-\uDFFF]$/,WRONG_SYMBOLS_CONVERSION=!NATIVE_SYMBOL$3||fails$k((function(){var e=getBuiltIn$3("Symbol")();return"[null]"!=$stringify([e])||"{}"!=$stringify({a:e})||"{}"!=$stringify(Object(e))})),ILL_FORMED_UNICODE=fails$k((function(){return'"\\udf06\\ud834"'!==$stringify("\udf06\ud834")||'"\\udead"'!==$stringify("\udead")})),stringifyWithSymbolsFix=function(e,t){var r=arraySlice$7(arguments),n=t;if((isObject$9(t)||void 0!==e)&&!isSymbol$3(e))return isArray$2(t)||(t=function(e,t){if(isCallable$4(n)&&(t=call$d(n,this,e,t)),!isSymbol$3(t))return t}),r[1]=t,apply$5($stringify,null,r)},fixIllFormed=function(e,t,r){var n=charAt$3(r,t-1),i=charAt$3(r,t+1);return exec$3(low,e)&&!exec$3(hi,i)||exec$3(hi,e)&&!exec$3(low,n)?"\\u"+numberToString$1(charCodeAt$2(e,0),16):e};$stringify&&$$o({target:"JSON",stat:!0,arity:3,forced:WRONG_SYMBOLS_CONVERSION||ILL_FORMED_UNICODE},{stringify:function(e,t,r){var n=arraySlice$7(arguments),i=apply$5(WRONG_SYMBOLS_CONVERSION?stringifyWithSymbolsFix:$stringify,null,n);return ILL_FORMED_UNICODE&&"string"==typeof i?replace$3(i,tester,fixIllFormed):i}});var logging=log$2;function shimGetUserMedia$2(e,t){var r=e&&e.navigator;if(r.mediaDevices){var n=function(e){if("object"!==_typeof(e)||e.mandatory||e.optional)return e;var t={};return Object.keys(e).forEach((function(r){if("require"!==r&&"advanced"!==r&&"mediaSource"!==r){var n="object"===_typeof(e[r])?e[r]:{ideal:e[r]};void 0!==n.exact&&"number"==typeof n.exact&&(n.min=n.max=n.exact);var i=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||[];var o={};"number"==typeof n.ideal?(o[i("min",r)]=n.ideal,t.optional.push(o),(o={})[i("max",r)]=n.ideal,t.optional.push(o)):(o[i("",r)]=n.ideal,t.optional.push(o))}void 0!==n.exact&&"number"!=typeof n.exact?(t.mandatory=t.mandatory||{},t.mandatory[i("",r)]=n.exact):["min","max"].forEach((function(e){void 0!==n[e]&&(t.mandatory=t.mandatory||{},t.mandatory[i(e,r)]=n[e])}))}})),e.advanced&&(t.optional=(t.optional||[]).concat(e.advanced)),t},i=function(e,i){if(t.version>=61)return i(e);if((e=JSON.parse(JSON.stringify(e)))&&"object"===_typeof(e.audio)){var o=function(e,t,r){t in e&&!(r in e)&&(e[r]=e[t],delete e[t])};o((e=JSON.parse(JSON.stringify(e))).audio,"autoGainControl","googAutoGainControl"),o(e.audio,"noiseSuppression","googNoiseSuppression"),e.audio=n(e.audio)}if(e&&"object"===_typeof(e.video)){var a=e.video.facingMode;a=a&&("object"===_typeof(a)?a:{ideal:a});var s,c=t.version<66;if(a&&("user"===a.exact||"environment"===a.exact||"user"===a.ideal||"environment"===a.ideal)&&(!r.mediaDevices.getSupportedConstraints||!r.mediaDevices.getSupportedConstraints().facingMode||c))if(delete e.video.facingMode,"environment"===a.exact||"environment"===a.ideal?s=["back","rear"]:"user"!==a.exact&&"user"!==a.ideal||(s=["front"]),s)return r.mediaDevices.enumerateDevices().then((function(t){var r=(t=t.filter((function(e){return"videoinput"===e.kind}))).find((function(e){return s.some((function(t){return e.label.toLowerCase().includes(t)}))}));return!r&&t.length&&s.includes("back")&&(r=t[t.length-1]),r&&(e.video.deviceId=a.exact?{exact:r.deviceId}:{ideal:r.deviceId}),e.video=n(e.video),logging("chrome: "+JSON.stringify(e)),i(e)}));e.video=n(e.video)}return logging("chrome: "+JSON.stringify(e)),i(e)},o=function(e){return t.version>=64?e:{name:{PermissionDeniedError:"NotAllowedError",PermissionDismissedError:"NotAllowedError",InvalidStateError:"NotAllowedError",DevicesNotFoundError:"NotFoundError",ConstraintNotSatisfiedError:"OverconstrainedError",TrackStartError:"NotReadableError",MediaDeviceFailedDueToShutdown:"NotAllowedError",MediaDeviceKillSwitchOn:"NotAllowedError",TabCaptureError:"AbortError",ScreenCaptureError:"AbortError",DeviceCaptureError:"AbortError"}[e.name]||e.name,message:e.message,constraint:e.constraint||e.constraintName,toString:function(){return this.name+(this.message&&": ")+this.message}}};if(r.getUserMedia=function(e,t,n){i(e,(function(e){r.webkitGetUserMedia(e,t,(function(e){n&&n(o(e))}))}))}.bind(r),r.mediaDevices.getUserMedia){var a=r.mediaDevices.getUserMedia.bind(r.mediaDevices);r.mediaDevices.getUserMedia=function(e){return i(e,(function(e){return a(e).then((function(t){if(e.audio&&!t.getAudioTracks().length||e.video&&!t.getVideoTracks().length)throw t.getTracks().forEach((function(e){e.stop()})),new DOMException("","NotFoundError");return t}),(function(e){return Promise.reject(o(e))}))}))}}}}function shimGetDisplayMedia$1(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((function(t){var n=r.video&&r.video.width,i=r.video&&r.video.height,o=r.video&&r.video.frameRate;return r.video={mandatory:{chromeMediaSource:"desktop",chromeMediaSourceId:t,maxFrameRate:o||3}},n&&(r.video.mandatory.maxWidth=n),i&&(r.video.mandatory.maxHeight=i),e.navigator.mediaDevices.getUserMedia(r)}))}:console.error("shimGetDisplayMedia: getSourceId argument is not a function"))}function shimMediaStream(e){e.MediaStream=e.MediaStream||e.webkitMediaStream}function shimOnTrack$1(e){if("object"===_typeof(e)&&e.RTCPeerConnection&&!("ontrack"in e.RTCPeerConnection.prototype)){Object.defineProperty(e.RTCPeerConnection.prototype,"ontrack",{get:function(){return this._ontrack},set:function(e){this._ontrack&&this.removeEventListener("track",this._ontrack),this.addEventListener("track",this._ontrack=e)},enumerable:!0,configurable:!0});var t=e.RTCPeerConnection.prototype.setRemoteDescription;e.RTCPeerConnection.prototype.setRemoteDescription=function(){var r=this;return this._ontrackpoly||(this._ontrackpoly=function(t){t.stream.addEventListener("addtrack",(function(n){var i;i=e.RTCPeerConnection.prototype.getReceivers?r.getReceivers().find((function(e){return e.track&&e.track.id===n.track.id})):{track:n.track};var o=new Event("track");o.track=n.track,o.receiver=i,o.transceiver={receiver:i},o.streams=[t.stream],r.dispatchEvent(o)})),t.stream.getTracks().forEach((function(n){var i;i=e.RTCPeerConnection.prototype.getReceivers?r.getReceivers().find((function(e){return e.track&&e.track.id===n.id})):{track:n};var o=new Event("track");o.track=n,o.receiver=i,o.transceiver={receiver:i},o.streams=[t.stream],r.dispatchEvent(o)}))},this.addEventListener("addstream",this._ontrackpoly)),t.apply(this,arguments)}}else wrapPeerConnectionEvent(e,"track",(function(e){return e.transceiver||Object.defineProperty(e,"transceiver",{value:{receiver:e.receiver}}),e}))}function shimGetSendersWithDtmf(e){if("object"===_typeof(e)&&e.RTCPeerConnection&&!("getSenders"in e.RTCPeerConnection.prototype)&&"createDTMFSender"in e.RTCPeerConnection.prototype){var t=function(e,t){return{track:t,get dtmf(){return void 0===this._dtmf&&("audio"===t.kind?this._dtmf=e.createDTMFSender(t):this._dtmf=null),this._dtmf},_pc:e}};if(!e.RTCPeerConnection.prototype.getSenders){e.RTCPeerConnection.prototype.getSenders=function(){return this._senders=this._senders||[],this._senders.slice()};var r=e.RTCPeerConnection.prototype.addTrack;e.RTCPeerConnection.prototype.addTrack=function(e,n){var i=r.apply(this,arguments);return i||(i=t(this,e),this._senders.push(i)),i};var n=e.RTCPeerConnection.prototype.removeTrack;e.RTCPeerConnection.prototype.removeTrack=function(e){n.apply(this,arguments);var t=this._senders.indexOf(e);-1!==t&&this._senders.splice(t,1)}}var i=e.RTCPeerConnection.prototype.addStream;e.RTCPeerConnection.prototype.addStream=function(e){var r=this;this._senders=this._senders||[],i.apply(this,[e]),e.getTracks().forEach((function(e){r._senders.push(t(r,e))}))};var o=e.RTCPeerConnection.prototype.removeStream;e.RTCPeerConnection.prototype.removeStream=function(e){var t=this;this._senders=this._senders||[],o.apply(this,[e]),e.getTracks().forEach((function(e){var r=t._senders.find((function(t){return t.track===e}));r&&t._senders.splice(t._senders.indexOf(r),1)}))}}else if("object"===_typeof(e)&&e.RTCPeerConnection&&"getSenders"in e.RTCPeerConnection.prototype&&"createDTMFSender"in e.RTCPeerConnection.prototype&&e.RTCRtpSender&&!("dtmf"in e.RTCRtpSender.prototype)){var a=e.RTCPeerConnection.prototype.getSenders;e.RTCPeerConnection.prototype.getSenders=function(){var e=this,t=a.apply(this,[]);return t.forEach((function(t){return t._pc=e})),t},Object.defineProperty(e.RTCRtpSender.prototype,"dtmf",{get:function(){return void 0===this._dtmf&&("audio"===this.track.kind?this._dtmf=this._pc.createDTMFSender(this.track):this._dtmf=null),this._dtmf}})}}function shimGetStats(e){if(e.RTCPeerConnection){var t=e.RTCPeerConnection.prototype.getStats;e.RTCPeerConnection.prototype.getStats=function(){var e=this,r=Array.prototype.slice.call(arguments),n=r[0],i=r[1],o=r[2];if(arguments.length>0&&"function"==typeof n)return t.apply(this,arguments);if(0===t.length&&(0===arguments.length||"function"!=typeof n))return t.apply(this,[]);var a=function(e){var t={};return e.result().forEach((function(e){var r={id:e.id,timestamp:e.timestamp,type:{localcandidate:"local-candidate",remotecandidate:"remote-candidate"}[e.type]||e.type};e.names().forEach((function(t){r[t]=e.stat(t)})),t[r.id]=r})),t},s=function(e){return new Map(Object.keys(e).map((function(t){return[t,e[t]]})))};if(arguments.length>=2){var c=function(e){i(s(a(e)))};return t.apply(this,[c,n])}return new Promise((function(r,n){t.apply(e,[function(e){r(s(a(e)))},n])})).then(i,o)}}}function shimSenderReceiverGetStats(e){if("object"===_typeof(e)&&e.RTCPeerConnection&&e.RTCRtpSender&&e.RTCRtpReceiver){if(!("getStats"in e.RTCRtpSender.prototype)){var t=e.RTCPeerConnection.prototype.getSenders;t&&(e.RTCPeerConnection.prototype.getSenders=function(){var e=this,r=t.apply(this,[]);return r.forEach((function(t){return t._pc=e})),r});var r=e.RTCPeerConnection.prototype.addTrack;r&&(e.RTCPeerConnection.prototype.addTrack=function(){var e=r.apply(this,arguments);return e._pc=this,e}),e.RTCRtpSender.prototype.getStats=function(){var e=this;return this._pc.getStats().then((function(t){return filterStats(t,e.track,!0)}))}}if(!("getStats"in e.RTCRtpReceiver.prototype)){var n=e.RTCPeerConnection.prototype.getReceivers;n&&(e.RTCPeerConnection.prototype.getReceivers=function(){var e=this,t=n.apply(this,[]);return t.forEach((function(t){return t._pc=e})),t}),wrapPeerConnectionEvent(e,"track",(function(e){return e.receiver._pc=e.srcElement,e})),e.RTCRtpReceiver.prototype.getStats=function(){var e=this;return this._pc.getStats().then((function(t){return filterStats(t,e.track,!1)}))}}if("getStats"in e.RTCRtpSender.prototype&&"getStats"in e.RTCRtpReceiver.prototype){var i=e.RTCPeerConnection.prototype.getStats;e.RTCPeerConnection.prototype.getStats=function(){if(arguments.length>0&&arguments[0]instanceof e.MediaStreamTrack){var t,r,n,o=arguments[0];return this.getSenders().forEach((function(e){e.track===o&&(t?n=!0:t=e)})),this.getReceivers().forEach((function(e){return e.track===o&&(r?n=!0:r=e),e.track===o})),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 i.apply(this,arguments)}}}}function shimAddTrackRemoveTrackWithNative(e){e.RTCPeerConnection.prototype.getLocalStreams=function(){var e=this;return this._shimmedLocalStreams=this._shimmedLocalStreams||{},Object.keys(this._shimmedLocalStreams).map((function(t){return e._shimmedLocalStreams[t][0]}))};var t=e.RTCPeerConnection.prototype.addTrack;e.RTCPeerConnection.prototype.addTrack=function(e,r){if(!r)return t.apply(this,arguments);this._shimmedLocalStreams=this._shimmedLocalStreams||{};var 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};var r=e.RTCPeerConnection.prototype.addStream;e.RTCPeerConnection.prototype.addStream=function(e){var t=this;this._shimmedLocalStreams=this._shimmedLocalStreams||{},e.getTracks().forEach((function(e){if(t.getSenders().find((function(t){return t.track===e})))throw new DOMException("Track already exists.","InvalidAccessError")}));var n=this.getSenders();r.apply(this,arguments);var i=this.getSenders().filter((function(e){return-1===n.indexOf(e)}));this._shimmedLocalStreams[e.id]=[e].concat(i)};var 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)};var i=e.RTCPeerConnection.prototype.removeTrack;e.RTCPeerConnection.prototype.removeTrack=function(e){var t=this;return this._shimmedLocalStreams=this._shimmedLocalStreams||{},e&&Object.keys(this._shimmedLocalStreams).forEach((function(r){var n=t._shimmedLocalStreams[r].indexOf(e);-1!==n&&t._shimmedLocalStreams[r].splice(n,1),1===t._shimmedLocalStreams[r].length&&delete t._shimmedLocalStreams[r]})),i.apply(this,arguments)}}function shimAddTrackRemoveTrack(e,t){if(e.RTCPeerConnection){if(e.RTCPeerConnection.prototype.addTrack&&t.version>=65)return shimAddTrackRemoveTrackWithNative(e);var r=e.RTCPeerConnection.prototype.getLocalStreams;e.RTCPeerConnection.prototype.getLocalStreams=function(){var e=this,t=r.apply(this);return this._reverseStreams=this._reverseStreams||{},t.map((function(t){return e._reverseStreams[t.id]}))};var n=e.RTCPeerConnection.prototype.addStream;e.RTCPeerConnection.prototype.addStream=function(t){var r=this;if(this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{},t.getTracks().forEach((function(e){if(r.getSenders().find((function(t){return t.track===e})))throw new DOMException("Track already exists.","InvalidAccessError")})),!this._reverseStreams[t.id]){var i=new e.MediaStream(t.getTracks());this._streams[t.id]=i,this._reverseStreams[i.id]=t,t=i}n.apply(this,[t])};var i=e.RTCPeerConnection.prototype.removeStream;e.RTCPeerConnection.prototype.removeStream=function(e){this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{},i.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){var n=this;if("closed"===this.signalingState)throw new DOMException("The RTCPeerConnection's signalingState is 'closed'.","InvalidStateError");var i=[].slice.call(arguments,1);if(1!==i.length||!i[0].getTracks().find((function(e){return e===t})))throw new DOMException("The adapter.js addTrack polyfill only supports a single stream which is associated with the specified track.","NotSupportedError");var o=this.getSenders().find((function(e){return e.track===t}));if(o)throw new DOMException("Track already exists.","InvalidAccessError");this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{};var a=this._streams[r.id];if(a)a.addTrack(t),Promise.resolve().then((function(){n.dispatchEvent(new Event("negotiationneeded"))}));else{var s=new e.MediaStream([t]);this._streams[r.id]=s,this._reverseStreams[s.id]=r,this.addStream(s)}return this.getSenders().find((function(e){return e.track===t}))},["createOffer","createAnswer"].forEach((function(t){var r=e.RTCPeerConnection.prototype[t],n=_defineProperty({},t,(function(){var e=this,t=arguments,n=arguments.length&&"function"==typeof arguments[0];return n?r.apply(this,[function(r){var n=s(e,r);t[0].apply(null,[n])},function(e){t[1]&&t[1].apply(null,e)},arguments[2]]):r.apply(this,arguments).then((function(t){return s(e,t)}))}));e.RTCPeerConnection.prototype[t]=n[t]}));var o=e.RTCPeerConnection.prototype.setLocalDescription;e.RTCPeerConnection.prototype.setLocalDescription=function(){return arguments.length&&arguments[0].type?(arguments[0]=c(this,arguments[0]),o.apply(this,arguments)):o.apply(this,arguments)};var a=Object.getOwnPropertyDescriptor(e.RTCPeerConnection.prototype,"localDescription");Object.defineProperty(e.RTCPeerConnection.prototype,"localDescription",{get:function(){var e=a.get.apply(this);return""===e.type?e:s(this,e)}}),e.RTCPeerConnection.prototype.removeTrack=function(e){var t,r=this;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");this._streams=this._streams||{},Object.keys(this._streams).forEach((function(n){r._streams[n].getTracks().find((function(t){return e.track===t}))&&(t=r._streams[n])})),t&&(1===t.getTracks().length?this.removeStream(this._reverseStreams[t.id]):t.removeTrack(e.track),this.dispatchEvent(new Event("negotiationneeded")))}}function s(e,t){var r=t.sdp;return Object.keys(e._reverseStreams||[]).forEach((function(t){var n=e._reverseStreams[t],i=e._streams[n.id];r=r.replace(new RegExp(i.id,"g"),n.id)})),new RTCSessionDescription({type:t.type,sdp:r})}function c(e,t){var r=t.sdp;return Object.keys(e._reverseStreams||[]).forEach((function(t){var n=e._reverseStreams[t],i=e._streams[n.id];r=r.replace(new RegExp(n.id,"g"),i.id)})),new RTCSessionDescription({type:t.type,sdp:r})}}function shimPeerConnection$1(e,t){!e.RTCPeerConnection&&e.webkitRTCPeerConnection&&(e.RTCPeerConnection=e.webkitRTCPeerConnection),e.RTCPeerConnection&&t.version<53&&["setLocalDescription","setRemoteDescription","addIceCandidate"].forEach((function(t){var r=e.RTCPeerConnection.prototype[t],n=_defineProperty({},t,(function(){return arguments[0]=new("addIceCandidate"===t?e.RTCIceCandidate:e.RTCSessionDescription)(arguments[0]),r.apply(this,arguments)}));e.RTCPeerConnection.prototype[t]=n[t]}))}function fixNegotiationNeeded(e,t){wrapPeerConnectionEvent(e,"negotiationneeded",(function(e){var r=e.target;if(!(t.version<72||r.getConfiguration&&"plan-b"===r.getConfiguration().sdpSemantics)||"stable"===r.signalingState)return e}))}var chromeShim=Object.freeze(Object.defineProperty({__proto__:null,shimMediaStream:shimMediaStream,shimOnTrack:shimOnTrack$1,shimGetSendersWithDtmf:shimGetSendersWithDtmf,shimGetStats:shimGetStats,shimSenderReceiverGetStats:shimSenderReceiverGetStats,shimAddTrackRemoveTrackWithNative:shimAddTrackRemoveTrackWithNative,shimAddTrackRemoveTrack:shimAddTrackRemoveTrack,shimPeerConnection:shimPeerConnection$1,fixNegotiationNeeded:fixNegotiationNeeded,shimGetUserMedia:shimGetUserMedia$2,shimGetDisplayMedia:shimGetDisplayMedia$1},Symbol.toStringTag,{value:"Module"})),$$n=_export,call$c=functionCall,isCallable$3=isCallable$t,anObject$7=anObject$q,toString$9=toString$m,DELEGATES_TO_EXEC=function(){var e=!1,t=/[ac]/;return t.exec=function(){return e=!0,/./.exec.apply(this,arguments)},!0===t.test("abc")&&e}(),nativeTest=/./.test;$$n({target:"RegExp",proto:!0,forced:!DELEGATES_TO_EXEC},{test:function(e){var t=anObject$7(this),r=toString$9(e),n=t.exec;if(!isCallable$3(n))return call$c(nativeTest,t,r);var i=call$c(n,t,r);return null!==i&&(anObject$7(i),!0)}});var global$i=global$K,fails$j=fails$U,uncurryThis$m=functionUncurryThis,toString$8=toString$m,trim$1=stringTrim.trim,whitespaces$1=whitespaces$4,charAt$2=uncurryThis$m("".charAt),$parseFloat$1=global$i.parseFloat,Symbol$3=global$i.Symbol,ITERATOR$3=Symbol$3&&Symbol$3.iterator,FORCED$6=1/$parseFloat$1(whitespaces$1+"-0")!=-1/0||ITERATOR$3&&!fails$j((function(){$parseFloat$1(Object(ITERATOR$3))})),numberParseFloat=FORCED$6?function(e){var t=trim$1(toString$8(e)),r=$parseFloat$1(t);return 0===r&&"-"==charAt$2(t,0)?-0:r}:$parseFloat$1,$$m=_export,$parseFloat=numberParseFloat;$$m({global:!0,forced:parseFloat!=numberParseFloat},{parseFloat:numberParseFloat});var $$l=_export,NativePromiseConstructor=promiseNativeConstructor,fails$i=fails$U,getBuiltIn$2=getBuiltIn$g,isCallable$2=isCallable$t,speciesConstructor$2=speciesConstructor$4,promiseResolve=promiseResolve$2,defineBuiltIn$6=defineBuiltIn$j,NativePromisePrototype=NativePromiseConstructor&&NativePromiseConstructor.prototype,NON_GENERIC=!!NativePromiseConstructor&&fails$i((function(){NativePromisePrototype.finally.call({then:function(){}},(function(){}))}));if($$l({target:"Promise",proto:!0,real:!0,forced:NON_GENERIC},{finally:function(e){var t=speciesConstructor$2(this,getBuiltIn$2("Promise")),r=isCallable$2(e);return this.then(r?function(r){return promiseResolve(t,e()).then((function(){return r}))}:e,r?function(r){return promiseResolve(t,e()).then((function(){throw r}))}:e)}}),isCallable$2(NativePromiseConstructor)){var method=getBuiltIn$2("Promise").prototype.finally;NativePromisePrototype.finally!==method&&defineBuiltIn$6(NativePromisePrototype,"finally",method,{unsafe:!0})}function shimGetUserMedia$1(e,t){var r=e&&e.navigator,n=e&&e.MediaStreamTrack;if(r.getUserMedia=function(e,t,n){deprecated("navigator.getUserMedia","navigator.mediaDevices.getUserMedia"),r.mediaDevices.getUserMedia(e).then(t,n)},!(t.version>55&&"autoGainControl"in r.mediaDevices.getSupportedConstraints())){var i=function(e,t,r){t in e&&!(r in e)&&(e[r]=e[t],delete e[t])},o=r.mediaDevices.getUserMedia.bind(r.mediaDevices);if(r.mediaDevices.getUserMedia=function(e){return"object"===_typeof(e)&&"object"===_typeof(e.audio)&&(e=JSON.parse(JSON.stringify(e)),i(e.audio,"autoGainControl","mozAutoGainControl"),i(e.audio,"noiseSuppression","mozNoiseSuppression")),o(e)},n&&n.prototype.getSettings){var a=n.prototype.getSettings;n.prototype.getSettings=function(){var e=a.apply(this,arguments);return i(e,"mozAutoGainControl","autoGainControl"),i(e,"mozNoiseSuppression","noiseSuppression"),e}}if(n&&n.prototype.applyConstraints){var s=n.prototype.applyConstraints;n.prototype.applyConstraints=function(e){return"audio"===this.kind&&"object"===_typeof(e)&&(e=JSON.parse(JSON.stringify(e)),i(e,"autoGainControl","mozAutoGainControl"),i(e,"noiseSuppression","mozNoiseSuppression")),s.apply(this,[e])}}}}function shimGetDisplayMedia(e,t){e.navigator.mediaDevices&&"getDisplayMedia"in e.navigator.mediaDevices||e.navigator.mediaDevices&&(e.navigator.mediaDevices.getDisplayMedia=function(r){if(!r||!r.video){var n=new DOMException("getDisplayMedia without video constraints is undefined");return n.name="NotFoundError",n.code=8,Promise.reject(n)}return!0===r.video?r.video={mediaSource:t}:r.video.mediaSource=t,e.navigator.mediaDevices.getUserMedia(r)})}function shimOnTrack(e){"object"===_typeof(e)&&e.RTCTrackEvent&&"receiver"in e.RTCTrackEvent.prototype&&!("transceiver"in e.RTCTrackEvent.prototype)&&Object.defineProperty(e.RTCTrackEvent.prototype,"transceiver",{get:function(){return{receiver:this.receiver}}})}function shimPeerConnection(e,t){if("object"===_typeof(e)&&(e.RTCPeerConnection||e.mozRTCPeerConnection)){!e.RTCPeerConnection&&e.mozRTCPeerConnection&&(e.RTCPeerConnection=e.mozRTCPeerConnection),t.version<53&&["setLocalDescription","setRemoteDescription","addIceCandidate"].forEach((function(t){var r=e.RTCPeerConnection.prototype[t],n=_defineProperty({},t,(function(){return arguments[0]=new("addIceCandidate"===t?e.RTCIceCandidate:e.RTCSessionDescription)(arguments[0]),r.apply(this,arguments)}));e.RTCPeerConnection.prototype[t]=n[t]}));var 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(){var e=Array.prototype.slice.call(arguments),i=e[0],o=e[1],a=e[2];return n.apply(this,[i||null]).then((function(e){if(t.version<53&&!o)try{e.forEach((function(e){e.type=r[e.type]||e.type}))}catch(t){if("TypeError"!==t.name)throw t;e.forEach((function(t,n){e.set(n,Object.assign({},t,{type:r[t.type]||t.type}))}))}return e})).then(o,a)}}}function shimSenderGetStats(e){if("object"===_typeof(e)&&e.RTCPeerConnection&&e.RTCRtpSender&&(!e.RTCRtpSender||!("getStats"in e.RTCRtpSender.prototype))){var t=e.RTCPeerConnection.prototype.getSenders;t&&(e.RTCPeerConnection.prototype.getSenders=function(){var e=this,r=t.apply(this,[]);return r.forEach((function(t){return t._pc=e})),r});var r=e.RTCPeerConnection.prototype.addTrack;r&&(e.RTCPeerConnection.prototype.addTrack=function(){var 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 shimReceiverGetStats(e){if("object"===_typeof(e)&&e.RTCPeerConnection&&e.RTCRtpSender&&(!e.RTCRtpSender||!("getStats"in e.RTCRtpReceiver.prototype))){var t=e.RTCPeerConnection.prototype.getReceivers;t&&(e.RTCPeerConnection.prototype.getReceivers=function(){var e=this,r=t.apply(this,[]);return r.forEach((function(t){return t._pc=e})),r}),wrapPeerConnectionEvent(e,"track",(function(e){return e.receiver._pc=e.srcElement,e})),e.RTCRtpReceiver.prototype.getStats=function(){return this._pc.getStats(this.track)}}}function shimRemoveStream(e){e.RTCPeerConnection&&!("removeStream"in e.RTCPeerConnection.prototype)&&(e.RTCPeerConnection.prototype.removeStream=function(e){var t=this;deprecated("removeStream","removeTrack"),this.getSenders().forEach((function(r){r.track&&e.getTracks().includes(r.track)&&t.removeTrack(r)}))})}function shimRTCDataChannel(e){e.DataChannel&&!e.RTCDataChannel&&(e.RTCDataChannel=e.DataChannel)}function shimAddTransceiver(e){if("object"===_typeof(e)&&e.RTCPeerConnection){var t=e.RTCPeerConnection.prototype.addTransceiver;t&&(e.RTCPeerConnection.prototype.addTransceiver=function(){this.setParametersPromises=[];var e=arguments[1]&&arguments[1].sendEncodings;void 0===e&&(e=[]);var r=(e=_toConsumableArray(e)).length>0;r&&e.forEach((function(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")}));var n=t.apply(this,arguments);if(r){var i=n.sender,o=i.getParameters();(!("encodings"in o)||1===o.encodings.length&&0===Object.keys(o.encodings[0]).length)&&(o.encodings=e,i.sendEncodings=e,this.setParametersPromises.push(i.setParameters(o).then((function(){delete i.sendEncodings})).catch((function(){delete i.sendEncodings}))))}return n})}}function shimGetParameters(e){if("object"===_typeof(e)&&e.RTCRtpSender){var t=e.RTCRtpSender.prototype.getParameters;t&&(e.RTCRtpSender.prototype.getParameters=function(){var e=t.apply(this,arguments);return"encodings"in e||(e.encodings=[].concat(this.sendEncodings||[{}])),e})}}function shimCreateOffer(e){if("object"===_typeof(e)&&e.RTCPeerConnection){var t=e.RTCPeerConnection.prototype.createOffer;e.RTCPeerConnection.prototype.createOffer=function(){var e=arguments,r=this;return this.setParametersPromises&&this.setParametersPromises.length?Promise.all(this.setParametersPromises).then((function(){return t.apply(r,e)})).finally((function(){r.setParametersPromises=[]})):t.apply(this,arguments)}}}function shimCreateAnswer(e){if("object"===_typeof(e)&&e.RTCPeerConnection){var t=e.RTCPeerConnection.prototype.createAnswer;e.RTCPeerConnection.prototype.createAnswer=function(){var e=arguments,r=this;return this.setParametersPromises&&this.setParametersPromises.length?Promise.all(this.setParametersPromises).then((function(){return t.apply(r,e)})).finally((function(){r.setParametersPromises=[]})):t.apply(this,arguments)}}}var firefoxShim=Object.freeze(Object.defineProperty({__proto__:null,shimOnTrack:shimOnTrack,shimPeerConnection:shimPeerConnection,shimSenderGetStats:shimSenderGetStats,shimReceiverGetStats:shimReceiverGetStats,shimRemoveStream:shimRemoveStream,shimRTCDataChannel:shimRTCDataChannel,shimAddTransceiver:shimAddTransceiver,shimGetParameters:shimGetParameters,shimCreateOffer:shimCreateOffer,shimCreateAnswer:shimCreateAnswer,shimGetUserMedia:shimGetUserMedia$1,shimGetDisplayMedia:shimGetDisplayMedia},Symbol.toStringTag,{value:"Module"}));function shimLocalStreamsAPI(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)){var t=e.RTCPeerConnection.prototype.addTrack;e.RTCPeerConnection.prototype.addStream=function(e){var r=this;this._localStreams||(this._localStreams=[]),this._localStreams.includes(e)||this._localStreams.push(e),e.getAudioTracks().forEach((function(n){return t.call(r,n,e)})),e.getVideoTracks().forEach((function(n){return t.call(r,n,e)}))},e.RTCPeerConnection.prototype.addTrack=function(e){for(var r=this,n=arguments.length,i=new Array(n>1?n-1:0),o=1;o<n;o++)i[o-1]=arguments[o];return i&&i.forEach((function(e){r._localStreams?r._localStreams.includes(e)||r._localStreams.push(e):r._localStreams=[e]})),t.apply(this,arguments)}}"removeStream"in e.RTCPeerConnection.prototype||(e.RTCPeerConnection.prototype.removeStream=function(e){var t=this;this._localStreams||(this._localStreams=[]);var r=this._localStreams.indexOf(e);if(-1!==r){this._localStreams.splice(r,1);var n=e.getTracks();this.getSenders().forEach((function(e){n.includes(e.track)&&t.removeTrack(e)}))}})}}function shimRemoteStreamsAPI(e){if("object"===_typeof(e)&&e.RTCPeerConnection&&("getRemoteStreams"in e.RTCPeerConnection.prototype||(e.RTCPeerConnection.prototype.getRemoteStreams=function(){return this._remoteStreams?this._remoteStreams:[]}),!("onaddstream"in e.RTCPeerConnection.prototype))){Object.defineProperty(e.RTCPeerConnection.prototype,"onaddstream",{get:function(){return this._onaddstream},set:function(e){var t=this;this._onaddstream&&(this.removeEventListener("addstream",this._onaddstream),this.removeEventListener("track",this._onaddstreampoly)),this.addEventListener("addstream",this._onaddstream=e),this.addEventListener("track",this._onaddstreampoly=function(e){e.streams.forEach((function(e){if(t._remoteStreams||(t._remoteStreams=[]),!t._remoteStreams.includes(e)){t._remoteStreams.push(e);var r=new Event("addstream");r.stream=e,t.dispatchEvent(r)}}))})}});var t=e.RTCPeerConnection.prototype.setRemoteDescription;e.RTCPeerConnection.prototype.setRemoteDescription=function(){var e=this;return this._onaddstreampoly||this.addEventListener("track",this._onaddstreampoly=function(t){t.streams.forEach((function(t){if(e._remoteStreams||(e._remoteStreams=[]),!(e._remoteStreams.indexOf(t)>=0)){e._remoteStreams.push(t);var r=new Event("addstream");r.stream=t,e.dispatchEvent(r)}}))}),t.apply(e,arguments)}}}function shimCallbacksAPI(e){if("object"===_typeof(e)&&e.RTCPeerConnection){var t=e.RTCPeerConnection.prototype,r=t.createOffer,n=t.createAnswer,i=t.setLocalDescription,o=t.setRemoteDescription,a=t.addIceCandidate;t.createOffer=function(e,t){var n=arguments.length>=2?arguments[2]:arguments[0],i=r.apply(this,[n]);return t?(i.then(e,t),Promise.resolve()):i},t.createAnswer=function(e,t){var r=arguments.length>=2?arguments[2]:arguments[0],i=n.apply(this,[r]);return t?(i.then(e,t),Promise.resolve()):i};var s=function(e,t,r){var n=i.apply(this,[e]);return r?(n.then(t,r),Promise.resolve()):n};t.setLocalDescription=s,s=function(e,t,r){var n=o.apply(this,[e]);return r?(n.then(t,r),Promise.resolve()):n},t.setRemoteDescription=s,s=function(e,t,r){var n=a.apply(this,[e]);return r?(n.then(t,r),Promise.resolve()):n},t.addIceCandidate=s}}function shimGetUserMedia(e){var t=e&&e.navigator;if(t.mediaDevices&&t.mediaDevices.getUserMedia){var r=t.mediaDevices,n=r.getUserMedia.bind(r);t.mediaDevices.getUserMedia=function(e){return n(shimConstraints(e))}}!t.getUserMedia&&t.mediaDevices&&t.mediaDevices.getUserMedia&&(t.getUserMedia=function(e,r,n){t.mediaDevices.getUserMedia(e).then(r,n)}.bind(t))}function shimConstraints(e){return e&&void 0!==e.video?Object.assign({},e,{video:compactObject(e.video)}):e}function shimRTCIceServerUrls(e){if(e.RTCPeerConnection){var t=e.RTCPeerConnection;e.RTCPeerConnection=function(e,r){if(e&&e.iceServers){for(var n=[],i=0;i<e.iceServers.length;i++){var o=e.iceServers[i];!o.hasOwnProperty("urls")&&o.hasOwnProperty("url")?(deprecated("RTCIceServer.url","RTCIceServer.urls"),(o=JSON.parse(JSON.stringify(o))).urls=o.url,delete o.url,n.push(o)):n.push(e.iceServers[i])}e.iceServers=n}return new t(e,r)},e.RTCPeerConnection.prototype=t.prototype,"generateCertificate"in t&&Object.defineProperty(e.RTCPeerConnection,"generateCertificate",{get:function(){return t.generateCertificate}})}}function shimTrackEventTransceiver(e){"object"===_typeof(e)&&e.RTCTrackEvent&&"receiver"in e.RTCTrackEvent.prototype&&!("transceiver"in e.RTCTrackEvent.prototype)&&Object.defineProperty(e.RTCTrackEvent.prototype,"transceiver",{get:function(){return{receiver:this.receiver}}})}function shimCreateOfferLegacy(e){var t=e.RTCPeerConnection.prototype.createOffer;e.RTCPeerConnection.prototype.createOffer=function(e){if(e){void 0!==e.offerToReceiveAudio&&(e.offerToReceiveAudio=!!e.offerToReceiveAudio);var r=this.getTransceivers().find((function(e){return"audio"===e.receiver.track.kind}));!1===e.offerToReceiveAudio&&r?"sendrecv"===r.direction?r.setDirection?r.setDirection("sendonly"):r.direction="sendonly":"recvonly"===r.direction&&(r.setDirection?r.setDirection("inactive"):r.direction="inactive"):!0!==e.offerToReceiveAudio||r||this.addTransceiver("audio",{direction:"recvonly"}),void 0!==e.offerToReceiveVideo&&(e.offerToReceiveVideo=!!e.offerToReceiveVideo);var n=this.getTransceivers().find((function(e){return"video"===e.receiver.track.kind}));!1===e.offerToReceiveVideo&&n?"sendrecv"===n.direction?n.setDirection?n.setDirection("sendonly"):n.direction="sendonly":"recvonly"===n.direction&&(n.setDirection?n.setDirection("inactive"):n.direction="inactive"):!0!==e.offerToReceiveVideo||n||this.addTransceiver("video",{direction:"recvonly"})}return t.apply(this,arguments)}}function shimAudioContext(e){"object"!==_typeof(e)||e.AudioContext||(e.AudioContext=e.webkitAudioContext)}var safariShim=Object.freeze(Object.defineProperty({__proto__:null,shimLocalStreamsAPI:shimLocalStreamsAPI,shimRemoteStreamsAPI:shimRemoteStreamsAPI,shimCallbacksAPI:shimCallbacksAPI,shimGetUserMedia:shimGetUserMedia,shimConstraints:shimConstraints,shimRTCIceServerUrls:shimRTCIceServerUrls,shimTrackEventTransceiver:shimTrackEventTransceiver,shimCreateOfferLegacy:shimCreateOfferLegacy,shimAudioContext:shimAudioContext},Symbol.toStringTag,{value:"Module"})),$$k=_export,call$b=functionCall;$$k({target:"URL",proto:!0,enumerable:!0},{toJSON:function(){return call$b(URL.prototype.toString,this)}});var uncurryThis$l=functionUncurryThis,thisNumberValue$1=uncurryThis$l(1..valueOf),DESCRIPTORS$8=descriptors,global$h=global$K,uncurryThis$k=functionUncurryThis,isForced=isForced_1,defineBuiltIn$5=defineBuiltIn$j,hasOwn$a=hasOwnProperty_1,inheritIfRequired$1=inheritIfRequired$6,isPrototypeOf$3=objectIsPrototypeOf,isSymbol$2=isSymbol$6,toPrimitive$1=toPrimitive$3,fails$h=fails$U,getOwnPropertyNames$2=objectGetOwnPropertyNames.f,getOwnPropertyDescriptor$2=objectGetOwnPropertyDescriptor.f,defineProperty$5=objectDefineProperty.f,thisNumberValue=thisNumberValue$1,trim=stringTrim.trim,NUMBER="Number",NativeNumber=global$h[NUMBER],NumberPrototype=NativeNumber.prototype,TypeError$5=global$h.TypeError,arraySlice$6=uncurryThis$k("".slice),charCodeAt$1=uncurryThis$k("".charCodeAt),toNumeric=function(e){var t=toPrimitive$1(e,"number");return"bigint"==typeof t?t:toNumber(t)},toNumber=function(e){var t,r,n,i,o,a,s,c,u=toPrimitive$1(e,"number");if(isSymbol$2(u))throw TypeError$5("Cannot convert a Symbol value to a number");if("string"==typeof u&&u.length>2)if(u=trim(u),43===(t=charCodeAt$1(u,0))||45===t){if(88===(r=charCodeAt$1(u,2))||120===r)return NaN}else if(48===t){switch(charCodeAt$1(u,1)){case 66:case 98:n=2,i=49;break;case 79:case 111:n=8,i=55;break;default:return+u}for(a=(o=arraySlice$6(u,2)).length,s=0;s<a;s++)if((c=charCodeAt$1(o,s))<48||c>i)return NaN;return parseInt(o,n)}return+u};if(isForced(NUMBER,!NativeNumber(" 0o1")||!NativeNumber("0b1")||NativeNumber("+0x1"))){for(var key$1,NumberWrapper=function(e){var t=arguments.length<1?0:NativeNumber(toNumeric(e)),r=this;return isPrototypeOf$3(NumberPrototype,r)&&fails$h((function(){thisNumberValue(r)}))?inheritIfRequired$1(Object(t),r,NumberWrapper):t},keys$2=DESCRIPTORS$8?getOwnPropertyNames$2(NativeNumber):"MAX_VALUE,MIN_VALUE,NaN,NEGATIVE_INFINITY,POSITIVE_INFINITY,EPSILON,MAX_SAFE_INTEGER,MIN_SAFE_INTEGER,isFinite,isInteger,isNaN,isSafeInteger,parseFloat,parseInt,fromString,range".split(","),j$1=0;keys$2.length>j$1;j$1++)hasOwn$a(NativeNumber,key$1=keys$2[j$1])&&!hasOwn$a(NumberWrapper,key$1)&&defineProperty$5(NumberWrapper,key$1,getOwnPropertyDescriptor$2(NativeNumber,key$1));NumberWrapper.prototype=NumberPrototype,NumberPrototype.constructor=NumberWrapper,defineBuiltIn$5(global$h,NUMBER,NumberWrapper,{constructor:!0})}var PROPER_FUNCTION_NAME$1=functionName.PROPER,fails$g=fails$U,whitespaces=whitespaces$4,non="
",stringTrimForced=function(e){return fails$g((function(){return!!whitespaces[e]()||non[e]()!==non||PROPER_FUNCTION_NAME$1&&whitespaces[e].name!==e}))},$$j=_export,$trim=stringTrim.trim,forcedStringTrimMethod=stringTrimForced;$$j({target:"String",proto:!0,forced:forcedStringTrimMethod("trim")},{trim:function(){return $trim(this)}});var sdp$1={exports:{}};!function(e){var t={generateIdentifier:function(){return Math.random().toString(36).substr(2,10)}};t.localCName=t.generateIdentifier(),t.splitLines=function(e){return e.trim().split("\n").map((function(e){return e.trim()}))},t.splitSections=function(e){return e.split("\nm=").map((function(e,t){return(t>0?"m="+e:e).trim()+"\r\n"}))},t.getDescription=function(e){var r=t.splitSections(e);return r&&r[0]},t.getMediaSections=function(e){var r=t.splitSections(e);return r.shift(),r},t.matchPrefix=function(e,r){return t.splitLines(e).filter((function(e){return 0===e.indexOf(r)}))},t.parseCandidate=function(e){for(var t,r={foundation:(t=0===e.indexOf("a=candidate:")?e.substring(12).split(" "):e.substring(10).split(" "))[0],component:{1:"rtp",2:"rtcp"}[t[1]]||t[1],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:void 0===r[t[n]]&&(r[t[n]]=t[n+1])}return r},t.writeCandidate=function(e){var t=[];t.push(e.foundation);var r=e.component;"rtp"===r?t.push(1):"rtcp"===r?t.push(2):t.push(r),t.push(e.protocol.toUpperCase()),t.push(e.priority),t.push(e.address||e.ip),t.push(e.port);var n=e.type;return t.push("typ"),t.push(n),"host"!==n&&e.relatedAddress&&e.relatedPort&&(t.push("raddr"),t.push(e.relatedAddress),t.push("rport"),t.push(e.relatedPort)),e.tcpType&&"tcp"===e.protocol.toLowerCase()&&(t.push("tcptype"),t.push(e.tcpType)),(e.usernameFragment||e.ufrag)&&(t.push("ufrag"),t.push(e.usernameFragment||e.ufrag)),"candidate:"+t.join(" ")},t.parseIceOptions=function(e){return e.substr(14).split(" ")},t.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},t.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"},t.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]}},t.writeExtmap=function(e){return"a=extmap:"+(e.id||e.preferredId)+(e.direction&&"sendrecv"!==e.direction?"/"+e.direction:"")+" "+e.uri+"\r\n"},t.parseFmtp=function(e){for(var t,r={},n=e.substr(e.indexOf(" ")+1).split(";"),i=0;i<n.length;i++)r[(t=n[i].trim().split("="))[0].trim()]=t[1];return r},t.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){void 0!==e.parameters[t]?n.push(t+"="+e.parameters[t]):n.push(t)})),t+="a=fmtp:"+r+" "+n.join(";")+"\r\n"}return t},t.parseRtcpFb=function(e){var t=e.substr(e.indexOf(" ")+1).split(" ");return{type:t.shift(),parameter:t.join(" ")}},t.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},t.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},t.parseSsrcGroup=function(e){var t=e.substr(13).split(" ");return{semantics:t.shift(),ssrcs:t.map((function(e){return parseInt(e,10)}))}},t.getMid=function(e){var r=t.matchPrefix(e,"a=mid:")[0];if(r)return r.substr(6)},t.parseFingerprint=function(e){var t=e.substr(14).split(" ");return{algorithm:t[0].toLowerCase(),value:t[1].toUpperCase()}},t.getDtlsParameters=function(e,r){return{role:"auto",fingerprints:t.matchPrefix(e+r,"a=fingerprint:").map(t.parseFingerprint)}},t.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},t.parseCryptoLine=function(e){var t=e.substr(9).split(" ");return{tag:parseInt(t[0],10),cryptoSuite:t[1],keyParams:t[2],sessionParams:t.slice(3)}},t.writeCryptoLine=function(e){return"a=crypto:"+e.tag+" "+e.cryptoSuite+" "+("object"===_typeof(e.keyParams)?t.writeCryptoKeyParams(e.keyParams):e.keyParams)+(e.sessionParams?" "+e.sessionParams.join(" "):"")+"\r\n"},t.parseCryptoKeyParams=function(e){if(0!==e.indexOf("inline:"))return null;var t=e.substr(7).split("|");return{keyMethod:"inline",keySalt:t[0],lifeTime:t[1],mkiValue:t[2]?t[2].split(":")[0]:void 0,mkiLength:t[2]?t[2].split(":")[1]:void 0}},t.writeCryptoKeyParams=function(e){return e.keyMethod+":"+e.keySalt+(e.lifeTime?"|"+e.lifeTime:"")+(e.mkiValue&&e.mkiLength?"|"+e.mkiValue+":"+e.mkiLength:"")},t.getCryptoParameters=function(e,r){return t.matchPrefix(e+r,"a=crypto:").map(t.parseCryptoLine)},t.getIceParameters=function(e,r){var n=t.matchPrefix(e+r,"a=ice-ufrag:")[0],i=t.matchPrefix(e+r,"a=ice-pwd:")[0];return n&&i?{usernameFragment:n.substr(12),password:i.substr(10)}:null},t.writeIceParameters=function(e){var t="a=ice-ufrag:"+e.usernameFragment+"\r\na=ice-pwd:"+e.password+"\r\n";return e.iceLite&&(t+="a=ice-lite\r\n"),t},t.parseRtpParameters=function(e){for(var r={codecs:[],headerExtensions:[],fecMechanisms:[],rtcp:[]},n=t.splitLines(e)[0].split(" "),i=3;i<n.length;i++){var o=n[i],a=t.matchPrefix(e,"a=rtpmap:"+o+" ")[0];if(a){var s=t.parseRtpMap(a),c=t.matchPrefix(e,"a=fmtp:"+o+" ");switch(s.parameters=c.length?t.parseFmtp(c[0]):{},s.rtcpFeedback=t.matchPrefix(e,"a=rtcp-fb:"+o+" ").map(t.parseRtcpFb),r.codecs.push(s),s.name.toUpperCase()){case"RED":case"ULPFEC":r.fecMechanisms.push(s.name.toUpperCase())}}}return t.matchPrefix(e,"a=extmap:").forEach((function(e){r.headerExtensions.push(t.parseExtmap(e))})),r},t.writeRtpDescription=function(e,r){var n="";n+="m="+e+" ",n+=r.codecs.length>0?"9":"0",n+=" UDP/TLS/RTP/SAVPF ",n+=r.codecs.map((function(e){return void 0!==e.preferredPayloadType?e.preferredPayloadType:e.payloadType})).join(" ")+"\r\n",n+="c=IN IP4 0.0.0.0\r\n",n+="a=rtcp:9 IN IP4 0.0.0.0\r\n",r.codecs.forEach((function(e){n+=t.writeRtpMap(e),n+=t.writeFmtp(e),n+=t.writeRtcpFb(e)}));var i=0;return r.codecs.forEach((function(e){e.maxptime>i&&(i=e.maxptime)})),i>0&&(n+="a=maxptime:"+i+"\r\n"),r.headerExtensions&&r.headerExtensions.forEach((function(e){n+=t.writeExtmap(e)})),n},t.parseRtpEncodingParameters=function(e){var r,n=[],i=t.parseRtpParameters(e),o=-1!==i.fecMechanisms.indexOf("RED"),a=-1!==i.fecMechanisms.indexOf("ULPFEC"),s=t.matchPrefix(e,"a=ssrc:").map((function(e){return t.parseSsrcMedia(e)})).filter((function(e){return"cname"===e.attribute})),c=s.length>0&&s[0].ssrc,u=t.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&&(r=u[0][1]),i.codecs.forEach((function(e){if("RTX"===e.name.toUpperCase()&&e.parameters.apt){var t={ssrc:c,codecPayloadType:parseInt(e.parameters.apt,10)};c&&r&&(t.rtx={ssrc:r}),n.push(t),o&&((t=JSON.parse(JSON.stringify(t))).fec={ssrc:c,mechanism:a?"red+ulpfec":"red"},n.push(t))}})),0===n.length&&c&&n.push({ssrc:c});var l=t.matchPrefix(e,"b=");return l.length&&(l=0===l[0].indexOf("b=TIAS:")?parseInt(l[0].substr(7),10):0===l[0].indexOf("b=AS:")?1e3*parseInt(l[0].substr(5),10)*.95-16e3:void 0,n.forEach((function(e){e.maxBitrate=l}))),n},t.parseRtcpParameters=function(e){var r={},n=t.matchPrefix(e,"a=ssrc:").map((function(e){return t.parseSsrcMedia(e)})).filter((function(e){return"cname"===e.attribute}))[0];n&&(r.cname=n.value,r.ssrc=n.ssrc);var i=t.matchPrefix(e,"a=rtcp-rsize");r.reducedSize=i.length>0,r.compound=0===i.length;var o=t.matchPrefix(e,"a=rtcp-mux");return r.mux=o.length>0,r},t.writeRtcpParameters=function(e){var t="";return e.reducedSize&&(t+="a=rtcp-rsize\r\n"),e.mux&&(t+="a=rtcp-mux\r\n"),void 0!==e.ssrc&&e.cname&&(t+="a=ssrc:"+e.ssrc+" cname:"+e.cname+"\r\n"),t},t.parseMsid=function(e){var r,n=t.matchPrefix(e,"a=msid:");if(1===n.length)return{stream:(r=n[0].substr(7).split(" "))[0],track:r[1]};var i=t.matchPrefix(e,"a=ssrc:").map((function(e){return t.parseSsrcMedia(e)})).filter((function(e){return"msid"===e.attribute}));return i.length>0?{stream:(r=i[0].value.split(" "))[0],track:r[1]}:void 0},t.parseSctpDescription=function(e){var r,n=t.parseMLine(e),i=t.matchPrefix(e,"a=max-message-size:");i.length>0&&(r=parseInt(i[0].substr(19),10)),isNaN(r)&&(r=65536);var o=t.matchPrefix(e,"a=sctp-port:");if(o.length>0)return{port:parseInt(o[0].substr(12),10),protocol:n.fmt,maxMessageSize:r};var a=t.matchPrefix(e,"a=sctpmap:");if(a.length>0){var s=a[0].substr(10).split(" ");return{port:parseInt(s[0],10),protocol:s[1],maxMessageSize:r}}},t.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("")},t.generateSessionId=function(){return Math.random().toString().substr(2,21)},t.writeSessionBoilerplate=function(e,r,n){var i=void 0!==r?r:2;return"v=0\r\no="+(n||"thisisadapterortc")+" "+(e||t.generateSessionId())+" "+i+" IN IP4 127.0.0.1\r\ns=-\r\nt=0 0\r\n"},t.getDirection=function(e,r){for(var n=t.splitLines(e),i=0;i<n.length;i++)switch(n[i]){case"a=sendrecv":case"a=sendonly":case"a=recvonly":case"a=inactive":return n[i].substr(2)}return r?t.getDirection(r):"sendrecv"},t.getKind=function(e){return t.splitLines(e)[0].split(" ")[0].substr(2)},t.isRejected=function(e){return"0"===e.split(" ",2)[1]},t.parseMLine=function(e){var r=t.splitLines(e)[0].substr(2).split(" ");return{kind:r[0],port:parseInt(r[1],10),protocol:r[2],fmt:r.slice(3).join(" ")}},t.parseOLine=function(e){var r=t.matchPrefix(e,"o=")[0].substr(2).split(" ");return{username:r[0],sessionId:r[1],sessionVersion:parseInt(r[2],10),netType:r[3],addressType:r[4],address:r[5]}},t.isValidSDP=function(e){if("string"!=typeof e||0===e.length)return!1;for(var r=t.splitLines(e),n=0;n<r.length;n++)if(r[n].length<2||"="!==r[n].charAt(1))return!1;return!0},e.exports=t}(sdp$1);var SDPUtils=sdp$1.exports,sdp=_mergeNamespaces({__proto__:null,default:SDPUtils},[sdp$1.exports]);function shimRTCIceCandidate(e){if(!(!e.RTCIceCandidate||e.RTCIceCandidate&&"foundation"in e.RTCIceCandidate.prototype)){var t=e.RTCIceCandidate;e.RTCIceCandidate=function(e){if("object"===_typeof(e)&&e.candidate&&0===e.candidate.indexOf("a=")&&((e=JSON.parse(JSON.stringify(e))).candidate=e.candidate.substr(2)),e.candidate&&e.candidate.length){var r=new t(e),n=SDPUtils.parseCandidate(e.candidate),i=Object.assign(r,n);return i.toJSON=function(){return{candidate:i.candidate,sdpMid:i.sdpMid,sdpMLineIndex:i.sdpMLineIndex,usernameFragment:i.usernameFragment}},i}return new t(e)},e.RTCIceCandidate.prototype=t.prototype,wrapPeerConnectionEvent(e,"icecandidate",(function(t){return t.candidate&&Object.defineProperty(t,"candidate",{value:new e.RTCIceCandidate(t.candidate),writable:"false"}),t}))}}function shimRTCIceCandidateRelayProtocol(e){!e.RTCIceCandidate||e.RTCIceCandidate&&"relayProtocol"in e.RTCIceCandidate.prototype||wrapPeerConnectionEvent(e,"icecandidate",(function(e){if(e.candidate){var t=SDPUtils.parseCandidate(e.candidate.candidate);"relay"===t.type&&(e.candidate.relayProtocol={0:"tls",1:"tcp",2:"udp"}[t.priority>>24])}return e}))}function shimMaxMessageSize(e,t){if(e.RTCPeerConnection){"sctp"in e.RTCPeerConnection.prototype||Object.defineProperty(e.RTCPeerConnection.prototype,"sctp",{get:function(){return void 0===this._sctp?null:this._sctp}});var r=function(e){if(!e||!e.sdp)return!1;var t=SDPUtils.splitSections(e.sdp);return t.shift(),t.some((function(e){var t=SDPUtils.parseMLine(e);return t&&"application"===t.kind&&-1!==t.protocol.indexOf("SCTP")}))},n=function(e){var t=e.sdp.match(/mozilla...THIS_IS_SDPARTA-(\d+)/);if(null===t||t.length<2)return-1;var r=parseInt(t[1],10);return r!=r?-1:r},i=function(e){var r=65536;return"firefox"===t.browser&&(r=t.version<57?-1===e?16384:2147483637:t.version<60?57===t.version?65535:65536:2147483637),r},o=function(e,r){var n=65536;"firefox"===t.browser&&57===t.version&&(n=65535);var i=SDPUtils.matchPrefix(e.sdp,"a=max-message-size:");return i.length>0?n=parseInt(i[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){var e=this.getConfiguration(),s=e.sdpSemantics;"plan-b"===s&&Object.defineProperty(this,"sctp",{get:function(){return void 0===this._sctp?null:this._sctp},enumerable:!0,configurable:!0})}if(r(arguments[0])){var c,u=n(arguments[0]),l=i(u),d=o(arguments[0],u);c=0===l&&0===d?Number.POSITIVE_INFINITY:0===l||0===d?Math.max(l,d):Math.min(l,d);var p={};Object.defineProperty(p,"maxMessageSize",{get:function(){return c}}),this._sctp=p}return a.apply(this,arguments)}}}function shimSendThrowTypeError(e){if(e.RTCPeerConnection&&"createDataChannel"in e.RTCPeerConnection.prototype){var t=e.RTCPeerConnection.prototype.createDataChannel;e.RTCPeerConnection.prototype.createDataChannel=function(){var e=t.apply(this,arguments);return r(e,this),e},wrapPeerConnectionEvent(e,"datachannel",(function(e){return r(e.channel,e.target),e}))}function r(e,t){var r=e.send;e.send=function(){var n=arguments[0],i=n.length||n.size||n.byteLength;if("open"===e.readyState&&t.sctp&&i>t.sctp.maxMessageSize)throw new TypeError("Message too large (can send a maximum of "+t.sctp.maxMessageSize+" bytes)");return r.apply(e,arguments)}}}function shimConnectionState(e){if(e.RTCPeerConnection&&!("connectionState"in e.RTCPeerConnection.prototype)){var t=e.RTCPeerConnection.prototype;Object.defineProperty(t,"connectionState",{get:function(){return{completed:"connected",checking:"connecting"}[this.iceConnectionState]||this.iceConnectionState},enumerable:!0,configurable:!0}),Object.defineProperty(t,"onconnectionstatechange",{get:function(){return this._onconnectionstatechange||null},set:function(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((function(e){var r=t[e];t[e]=function(){return this._connectionstatechangepoly||(this._connectionstatechangepoly=function(e){var t=e.target;if(t._lastConnectionState!==t.connectionState){t._lastConnectionState=t.connectionState;var r=new Event("connectionstatechange",e);t.dispatchEvent(r)}return e},this.addEventListener("iceconnectionstatechange",this._connectionstatechangepoly)),r.apply(this,arguments)}}))}}function removeExtmapAllowMixed(e,t){if(e.RTCPeerConnection&&!("chrome"===t.browser&&t.version>=71||"safari"===t.browser&&t.version>=605)){var r=e.RTCPeerConnection.prototype.setRemoteDescription;e.RTCPeerConnection.prototype.setRemoteDescription=function(t){if(t&&t.sdp&&-1!==t.sdp.indexOf("\na=extmap-allow-mixed")){var n=t.sdp.split("\n").filter((function(e){return"a=extmap-allow-mixed"!==e.trim()})).join("\n");e.RTCSessionDescription&&t instanceof e.RTCSessionDescription?arguments[0]=new e.RTCSessionDescription({type:t.type,sdp:n}):t.sdp=n}return r.apply(this,arguments)}}}function shimAddIceCandidateNullOrEmpty(e,t){if(e.RTCPeerConnection&&e.RTCPeerConnection.prototype){var r=e.RTCPeerConnection.prototype.addIceCandidate;r&&0!==r.length&&(e.RTCPeerConnection.prototype.addIceCandidate=function(){return arguments[0]?("chrome"===t.browser&&t.version<78||"firefox"===t.browser&&t.version<68||"safari"===t.browser)&&arguments[0]&&""===arguments[0].candidate?Promise.resolve():r.apply(this,arguments):(arguments[1]&&arguments[1].apply(null),Promise.resolve())})}}function shimParameterlessSetLocalDescription(e,t){if(e.RTCPeerConnection&&e.RTCPeerConnection.prototype){var r=e.RTCPeerConnection.prototype.setLocalDescription;r&&0!==r.length&&(e.RTCPeerConnection.prototype.setLocalDescription=function(){var e=this,t=arguments[0]||{};if("object"!==_typeof(t)||t.type&&t.sdp)return r.apply(this,arguments);if(!(t={type:t.type,sdp:t.sdp}).type)switch(this.signalingState){case"stable":case"have-local-offer":case"have-remote-pranswer":t.type="offer";break;default:t.type="answer"}if(t.sdp||"offer"!==t.type&&"answer"!==t.type)return r.apply(this,[t]);var n="offer"===t.type?this.createOffer:this.createAnswer;return n.apply(this).then((function(t){return r.apply(e,[t])}))})}}var commonShim=Object.freeze(Object.defineProperty({__proto__:null,shimRTCIceCandidate:shimRTCIceCandidate,shimRTCIceCandidateRelayProtocol:shimRTCIceCandidateRelayProtocol,shimMaxMessageSize:shimMaxMessageSize,shimSendThrowTypeError:shimSendThrowTypeError,shimConnectionState:shimConnectionState,removeExtmapAllowMixed:removeExtmapAllowMixed,shimAddIceCandidateNullOrEmpty:shimAddIceCandidateNullOrEmpty,shimParameterlessSetLocalDescription:shimParameterlessSetLocalDescription},Symbol.toStringTag,{value:"Module"}));function adapterFactory(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.window,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{shimChrome:!0,shimFirefox:!0,shimSafari:!0},n=log$2,i=detectBrowser(t),o={browserDetails:i,commonShim:commonShim,extractVersion:extractVersion,disableLog:disableLog,disableWarnings:disableWarnings,sdp:sdp};switch(i.browser){case"chrome":if(!chromeShim||!shimPeerConnection$1||!r.shimChrome)return n("Chrome shim is not included in this adapter release."),o;if(null===i.version)return n("Chrome shim can not determine version, not shimming."),o;n("adapter.js shimming chrome."),o.browserShim=chromeShim,shimAddIceCandidateNullOrEmpty(t,i),shimParameterlessSetLocalDescription(t),shimGetUserMedia$2(t,i),shimMediaStream(t),shimPeerConnection$1(t,i),shimOnTrack$1(t),shimAddTrackRemoveTrack(t,i),shimGetSendersWithDtmf(t),shimGetStats(t),shimSenderReceiverGetStats(t),fixNegotiationNeeded(t,i),shimRTCIceCandidate(t),shimRTCIceCandidateRelayProtocol(t),shimConnectionState(t),shimMaxMessageSize(t,i),shimSendThrowTypeError(t),removeExtmapAllowMixed(t,i);break;case"firefox":if(!firefoxShim||!shimPeerConnection||!r.shimFirefox)return n("Firefox shim is not included in this adapter release."),o;n("adapter.js shimming firefox."),o.browserShim=firefoxShim,shimAddIceCandidateNullOrEmpty(t,i),shimParameterlessSetLocalDescription(t),shimGetUserMedia$1(t,i),shimPeerConnection(t,i),shimOnTrack(t),shimRemoveStream(t),shimSenderGetStats(t),shimReceiverGetStats(t),shimRTCDataChannel(t),shimAddTransceiver(t),shimGetParameters(t),shimCreateOffer(t),shimCreateAnswer(t),shimRTCIceCandidate(t),shimConnectionState(t),shimMaxMessageSize(t,i),shimSendThrowTypeError(t);break;case"safari":if(!safariShim||!r.shimSafari)return n("Safari shim is not included in this adapter release."),o;n("adapter.js shimming safari."),o.browserShim=safariShim,shimAddIceCandidateNullOrEmpty(t,i),shimParameterlessSetLocalDescription(t),shimRTCIceServerUrls(t),shimCreateOfferLegacy(t),shimCallbacksAPI(t),shimLocalStreamsAPI(t),shimRemoteStreamsAPI(t),shimTrackEventTransceiver(t),shimGetUserMedia(t),shimAudioContext(t),shimRTCIceCandidate(t),shimRTCIceCandidateRelayProtocol(t),shimMaxMessageSize(t,i),shimSendThrowTypeError(t),removeExtmapAllowMixed(t,i);break;default:n("Unsupported browser!")}return o}adapterFactory({window:"undefined"==typeof window?void 0:window});var arraySlice$5=arraySliceSimple,floor$5=Math.floor,mergeSort=function(e,t){var r=e.length,n=floor$5(r/2);return r<8?insertionSort(e,t):merge(e,mergeSort(arraySlice$5(e,0,n),t),mergeSort(arraySlice$5(e,n),t),t)},insertionSort=function(e,t){for(var r,n,i=e.length,o=1;o<i;){for(n=o,r=e[o];n&&t(e[n-1],r)>0;)e[n]=e[--n];n!==o++&&(e[n]=r)}return e},merge=function(e,t,r,n){for(var i=t.length,o=r.length,a=0,s=0;a<i||s<o;)e[a+s]=a<i&&s<o?n(t[a],r[s])<=0?t[a++]:r[s++]:a<i?t[a++]:r[s++];return e},arraySort$1=mergeSort,userAgent$2=engineUserAgent,firefox=userAgent$2.match(/firefox\/(\d+)/i),engineFfVersion=!!firefox&&+firefox[1],UA=engineUserAgent,engineIsIeOrEdge=/MSIE|Trident/.test(UA),userAgent$1=engineUserAgent,webkit=userAgent$1.match(/AppleWebKit\/(\d+)\./),engineWebkitVersion=!!webkit&&+webkit[1],$$i=_export,uncurryThis$j=functionUncurryThis,aCallable$2=aCallable$b,toObject$7=toObject$i,lengthOfArrayLike$c=lengthOfArrayLike$m,deletePropertyOrThrow$2=deletePropertyOrThrow$4,toString$7=toString$m,fails$f=fails$U,internalSort$1=arraySort$1,arrayMethodIsStrict$1=arrayMethodIsStrict$5,FF$1=engineFfVersion,IE_OR_EDGE$1=engineIsIeOrEdge,V8$1=engineV8Version,WEBKIT$1=engineWebkitVersion,test=[],nativeSort$1=uncurryThis$j(test.sort),push$6=uncurryThis$j(test.push),FAILS_ON_UNDEFINED=fails$f((function(){test.sort(void 0)})),FAILS_ON_NULL=fails$f((function(){test.sort(null)})),STRICT_METHOD$1=arrayMethodIsStrict$1("sort"),STABLE_SORT$1=!fails$f((function(){if(V8$1)return V8$1<70;if(!(FF$1&&FF$1>3)){if(IE_OR_EDGE$1)return!0;if(WEBKIT$1)return WEBKIT$1<603;var e,t,r,n,i="";for(e=65;e<76;e++){switch(t=String.fromCharCode(e),e){case 66:case 69:case 70:case 72:r=3;break;case 68:case 71:r=4;break;default:r=2}for(n=0;n<47;n++)test.push({k:t+n,v:r})}for(test.sort((function(e,t){return t.v-e.v})),n=0;n<test.length;n++)t=test[n].k.charAt(0),i.charAt(i.length-1)!==t&&(i+=t);return"DGBEFHACIJK"!==i}})),FORCED$5=FAILS_ON_UNDEFINED||!FAILS_ON_NULL||!STRICT_METHOD$1||!STABLE_SORT$1,getSortCompare$1=function(e){return function(t,r){return void 0===r?-1:void 0===t?1:void 0!==e?+e(t,r)||0:toString$7(t)>toString$7(r)?1:-1}};$$i({target:"Array",proto:!0,forced:FORCED$5},{sort:function(e){void 0!==e&&aCallable$2(e);var t=toObject$7(this);if(STABLE_SORT$1)return void 0===e?nativeSort$1(t):nativeSort$1(t,e);var r,n,i=[],o=lengthOfArrayLike$c(t);for(n=0;n<o;n++)n in t&&push$6(i,t[n]);for(internalSort$1(i,getSortCompare$1(e)),r=lengthOfArrayLike$c(i),n=0;n<r;)t[n]=i[n++];for(;n<o;)deletePropertyOrThrow$2(t,n++);return t}});var NAME$1,Constructor,Prototype,typedArrayConstructor={exports:{}},arrayBufferBasicDetection="undefined"!=typeof ArrayBuffer&&"undefined"!=typeof DataView,NATIVE_ARRAY_BUFFER$1=arrayBufferBasicDetection,DESCRIPTORS$7=descriptors,global$g=global$K,isCallable$1=isCallable$t,isObject$8=isObject$s,hasOwn$9=hasOwnProperty_1,classof$4=classof$i,tryToString$1=tryToString$7,createNonEnumerableProperty$2=createNonEnumerableProperty$c,defineBuiltIn$4=defineBuiltIn$j,defineProperty$4=objectDefineProperty.f,isPrototypeOf$2=objectIsPrototypeOf,getPrototypeOf$3=objectGetPrototypeOf,setPrototypeOf$2=objectSetPrototypeOf,wellKnownSymbol$6=wellKnownSymbol$u,uid$1=uid$5,InternalStateModule$6=internalState,enforceInternalState$2=InternalStateModule$6.enforce,getInternalState$3=InternalStateModule$6.get,Int8Array$4=global$g.Int8Array,Int8ArrayPrototype$1=Int8Array$4&&Int8Array$4.prototype,Uint8ClampedArray$1=global$g.Uint8ClampedArray,Uint8ClampedArrayPrototype=Uint8ClampedArray$1&&Uint8ClampedArray$1.prototype,TypedArray$1=Int8Array$4&&getPrototypeOf$3(Int8Array$4),TypedArrayPrototype$2=Int8ArrayPrototype$1&&getPrototypeOf$3(Int8ArrayPrototype$1),ObjectPrototype$2=Object.prototype,TypeError$4=global$g.TypeError,TO_STRING_TAG=wellKnownSymbol$6("toStringTag"),TYPED_ARRAY_TAG$1=uid$1("TYPED_ARRAY_TAG"),TYPED_ARRAY_CONSTRUCTOR="TypedArrayConstructor",NATIVE_ARRAY_BUFFER_VIEWS$2=NATIVE_ARRAY_BUFFER$1&&!!setPrototypeOf$2&&"Opera"!==classof$4(global$g.opera),TYPED_ARRAY_TAG_REQUIRED=!1,TypedArrayConstructorsList={Int8Array:1,Uint8Array:1,Uint8ClampedArray:1,Int16Array:2,Uint16Array:2,Int32Array:4,Uint32Array:4,Float32Array:4,Float64Array:8},BigIntArrayConstructorsList={BigInt64Array:8,BigUint64Array:8},isView=function(e){if(!isObject$8(e))return!1;var t=classof$4(e);return"DataView"===t||hasOwn$9(TypedArrayConstructorsList,t)||hasOwn$9(BigIntArrayConstructorsList,t)},getTypedArrayConstructor$4=function(e){var t=getPrototypeOf$3(e);if(isObject$8(t)){var r=getInternalState$3(t);return r&&hasOwn$9(r,TYPED_ARRAY_CONSTRUCTOR)?r[TYPED_ARRAY_CONSTRUCTOR]:getTypedArrayConstructor$4(t)}},isTypedArray$3=function(e){if(!isObject$8(e))return!1;var t=classof$4(e);return hasOwn$9(TypedArrayConstructorsList,t)||hasOwn$9(BigIntArrayConstructorsList,t)},aTypedArray$r=function(e){if(isTypedArray$3(e))return e;throw TypeError$4("Target is not a typed array")},aTypedArrayConstructor$3=function(e){if(isCallable$1(e)&&(!setPrototypeOf$2||isPrototypeOf$2(TypedArray$1,e)))return e;throw TypeError$4(tryToString$1(e)+" is not a typed array constructor")},exportTypedArrayMethod$s=function(e,t,r,n){if(DESCRIPTORS$7){if(r)for(var i in TypedArrayConstructorsList){var o=global$g[i];if(o&&hasOwn$9(o.prototype,e))try{delete o.prototype[e]}catch(r){try{o.prototype[e]=t}catch(e){}}}TypedArrayPrototype$2[e]&&!r||defineBuiltIn$4(TypedArrayPrototype$2,e,r?t:NATIVE_ARRAY_BUFFER_VIEWS$2&&Int8ArrayPrototype$1[e]||t,n)}},exportTypedArrayStaticMethod=function(e,t,r){var n,i;if(DESCRIPTORS$7){if(setPrototypeOf$2){if(r)for(n in TypedArrayConstructorsList)if((i=global$g[n])&&hasOwn$9(i,e))try{delete i[e]}catch(e){}if(TypedArray$1[e]&&!r)return;try{return defineBuiltIn$4(TypedArray$1,e,r?t:NATIVE_ARRAY_BUFFER_VIEWS$2&&TypedArray$1[e]||t)}catch(e){}}for(n in TypedArrayConstructorsList)!(i=global$g[n])||i[e]&&!r||defineBuiltIn$4(i,e,t)}};for(NAME$1 in TypedArrayConstructorsList)(Prototype=(Constructor=global$g[NAME$1])&&Constructor.prototype)?enforceInternalState$2(Prototype)[TYPED_ARRAY_CONSTRUCTOR]=Constructor:NATIVE_ARRAY_BUFFER_VIEWS$2=!1;for(NAME$1 in BigIntArrayConstructorsList)(Prototype=(Constructor=global$g[NAME$1])&&Constructor.prototype)&&(enforceInternalState$2(Prototype)[TYPED_ARRAY_CONSTRUCTOR]=Constructor);if((!NATIVE_ARRAY_BUFFER_VIEWS$2||!isCallable$1(TypedArray$1)||TypedArray$1===Function.prototype)&&(TypedArray$1=function(){throw TypeError$4("Incorrect invocation")},NATIVE_ARRAY_BUFFER_VIEWS$2))for(NAME$1 in TypedArrayConstructorsList)global$g[NAME$1]&&setPrototypeOf$2(global$g[NAME$1],TypedArray$1);if((!NATIVE_ARRAY_BUFFER_VIEWS$2||!TypedArrayPrototype$2||TypedArrayPrototype$2===ObjectPrototype$2)&&(TypedArrayPrototype$2=TypedArray$1.prototype,NATIVE_ARRAY_BUFFER_VIEWS$2))for(NAME$1 in TypedArrayConstructorsList)global$g[NAME$1]&&setPrototypeOf$2(global$g[NAME$1].prototype,TypedArrayPrototype$2);if(NATIVE_ARRAY_BUFFER_VIEWS$2&&getPrototypeOf$3(Uint8ClampedArrayPrototype)!==TypedArrayPrototype$2&&setPrototypeOf$2(Uint8ClampedArrayPrototype,TypedArrayPrototype$2),DESCRIPTORS$7&&!hasOwn$9(TypedArrayPrototype$2,TO_STRING_TAG))for(NAME$1 in TYPED_ARRAY_TAG_REQUIRED=!0,defineProperty$4(TypedArrayPrototype$2,TO_STRING_TAG,{get:function(){return isObject$8(this)?this[TYPED_ARRAY_TAG$1]:void 0}}),TypedArrayConstructorsList)global$g[NAME$1]&&createNonEnumerableProperty$2(global$g[NAME$1],TYPED_ARRAY_TAG$1,NAME$1);var arrayBufferViewCore={NATIVE_ARRAY_BUFFER_VIEWS:NATIVE_ARRAY_BUFFER_VIEWS$2,TYPED_ARRAY_TAG:TYPED_ARRAY_TAG_REQUIRED&&TYPED_ARRAY_TAG$1,aTypedArray:aTypedArray$r,aTypedArrayConstructor:aTypedArrayConstructor$3,exportTypedArrayMethod:exportTypedArrayMethod$s,exportTypedArrayStaticMethod:exportTypedArrayStaticMethod,getTypedArrayConstructor:getTypedArrayConstructor$4,isView:isView,isTypedArray:isTypedArray$3,TypedArray:TypedArray$1,TypedArrayPrototype:TypedArrayPrototype$2},global$f=global$K,fails$e=fails$U,checkCorrectnessOfIteration$1=checkCorrectnessOfIteration$4,NATIVE_ARRAY_BUFFER_VIEWS$1=arrayBufferViewCore.NATIVE_ARRAY_BUFFER_VIEWS,ArrayBuffer$2=global$f.ArrayBuffer,Int8Array$3=global$f.Int8Array,typedArrayConstructorsRequireWrappers=!NATIVE_ARRAY_BUFFER_VIEWS$1||!fails$e((function(){Int8Array$3(1)}))||!fails$e((function(){new Int8Array$3(-1)}))||!checkCorrectnessOfIteration$1((function(e){new Int8Array$3,new Int8Array$3(null),new Int8Array$3(1.5),new Int8Array$3(e)}),!0)||fails$e((function(){return 1!==new Int8Array$3(new ArrayBuffer$2(2),1,void 0).length})),toIntegerOrInfinity$7=toIntegerOrInfinity$d,toLength$5=toLength$a,$RangeError$5=RangeError,toIndex$2=function(e){if(void 0===e)return 0;var t=toIntegerOrInfinity$7(e),r=toLength$5(t);if(t!==r)throw $RangeError$5("Wrong length or index");return r},$Array$1=Array,abs=Math.abs,pow$1=Math.pow,floor$4=Math.floor,log$1=Math.log,LN2=Math.LN2,pack=function(e,t,r){var n,i,o,a=$Array$1(r),s=8*r-t-1,c=(1<<s)-1,u=c>>1,l=23===t?pow$1(2,-24)-pow$1(2,-77):0,d=e<0||0===e&&1/e<0?1:0,p=0;for((e=abs(e))!=e||e===1/0?(i=e!=e?1:0,n=c):(n=floor$4(log$1(e)/LN2),e*(o=pow$1(2,-n))<1&&(n--,o*=2),(e+=n+u>=1?l/o:l*pow$1(2,1-u))*o>=2&&(n++,o/=2),n+u>=c?(i=0,n=c):n+u>=1?(i=(e*o-1)*pow$1(2,t),n+=u):(i=e*pow$1(2,u-1)*pow$1(2,t),n=0));t>=8;)a[p++]=255&i,i/=256,t-=8;for(n=n<<t|i,s+=t;s>0;)a[p++]=255&n,n/=256,s-=8;return a[--p]|=128*d,a},unpack=function(e,t){var r,n=e.length,i=8*n-t-1,o=(1<<i)-1,a=o>>1,s=i-7,c=n-1,u=e[c--],l=127&u;for(u>>=7;s>0;)l=256*l+e[c--],s-=8;for(r=l&(1<<-s)-1,l>>=-s,s+=t;s>0;)r=256*r+e[c--],s-=8;if(0===l)l=1-a;else{if(l===o)return r?NaN:u?-1/0:1/0;r+=pow$1(2,t),l-=a}return(u?-1:1)*r*pow$1(2,l-t)},ieee754={pack:pack,unpack:unpack},toObject$6=toObject$i,toAbsoluteIndex$1=toAbsoluteIndex$6,lengthOfArrayLike$b=lengthOfArrayLike$m,arrayFill$1=function(e){for(var t=toObject$6(this),r=lengthOfArrayLike$b(t),n=arguments.length,i=toAbsoluteIndex$1(n>1?arguments[1]:void 0,r),o=n>2?arguments[2]:void 0,a=void 0===o?r:toAbsoluteIndex$1(o,r);a>i;)t[i++]=e;return t},global$e=global$K,uncurryThis$i=functionUncurryThis,DESCRIPTORS$6=descriptors,NATIVE_ARRAY_BUFFER=arrayBufferBasicDetection,FunctionName=functionName,createNonEnumerableProperty$1=createNonEnumerableProperty$c,defineBuiltIns$3=defineBuiltIns$5,fails$d=fails$U,anInstance$4=anInstance$a,toIntegerOrInfinity$6=toIntegerOrInfinity$d,toLength$4=toLength$a,toIndex$1=toIndex$2,IEEE754=ieee754,getPrototypeOf$2=objectGetPrototypeOf,setPrototypeOf$1=objectSetPrototypeOf,getOwnPropertyNames$1=objectGetOwnPropertyNames.f,defineProperty$3=objectDefineProperty.f,arrayFill=arrayFill$1,arraySlice$4=arraySliceSimple,setToStringTag$4=setToStringTag$a,InternalStateModule$5=internalState,PROPER_FUNCTION_NAME=FunctionName.PROPER,CONFIGURABLE_FUNCTION_NAME=FunctionName.CONFIGURABLE,getInternalState$2=InternalStateModule$5.get,setInternalState$5=InternalStateModule$5.set,ARRAY_BUFFER="ArrayBuffer",DATA_VIEW="DataView",PROTOTYPE$1="prototype",WRONG_LENGTH$1="Wrong length",WRONG_INDEX="Wrong index",NativeArrayBuffer=global$e[ARRAY_BUFFER],$ArrayBuffer=NativeArrayBuffer,ArrayBufferPrototype$1=$ArrayBuffer&&$ArrayBuffer[PROTOTYPE$1],$DataView=global$e[DATA_VIEW],DataViewPrototype=$DataView&&$DataView[PROTOTYPE$1],ObjectPrototype$1=Object.prototype,Array$1=global$e.Array,RangeError$3=global$e.RangeError,fill=uncurryThis$i(arrayFill),reverse=uncurryThis$i([].reverse),packIEEE754=IEEE754.pack,unpackIEEE754=IEEE754.unpack,packInt8=function(e){return[255&e]},packInt16=function(e){return[255&e,e>>8&255]},packInt32=function(e){return[255&e,e>>8&255,e>>16&255,e>>24&255]},unpackInt32=function(e){return e[3]<<24|e[2]<<16|e[1]<<8|e[0]},packFloat32=function(e){return packIEEE754(e,23,4)},packFloat64=function(e){return packIEEE754(e,52,8)},addGetter$1=function(e,t){defineProperty$3(e[PROTOTYPE$1],t,{get:function(){return getInternalState$2(this)[t]}})},get$1=function(e,t,r,n){var i=toIndex$1(r),o=getInternalState$2(e);if(i+t>o.byteLength)throw RangeError$3(WRONG_INDEX);var a=getInternalState$2(o.buffer).bytes,s=i+o.byteOffset,c=arraySlice$4(a,s,s+t);return n?c:reverse(c)},set$1=function(e,t,r,n,i,o){var a=toIndex$1(r),s=getInternalState$2(e);if(a+t>s.byteLength)throw RangeError$3(WRONG_INDEX);for(var c=getInternalState$2(s.buffer).bytes,u=a+s.byteOffset,l=n(+i),d=0;d<t;d++)c[u+d]=l[o?d:t-d-1]};if(NATIVE_ARRAY_BUFFER){var INCORRECT_ARRAY_BUFFER_NAME=PROPER_FUNCTION_NAME&&NativeArrayBuffer.name!==ARRAY_BUFFER;if(fails$d((function(){NativeArrayBuffer(1)}))&&fails$d((function(){new NativeArrayBuffer(-1)}))&&!fails$d((function(){return new NativeArrayBuffer,new NativeArrayBuffer(1.5),new NativeArrayBuffer(NaN),1!=NativeArrayBuffer.length||INCORRECT_ARRAY_BUFFER_NAME&&!CONFIGURABLE_FUNCTION_NAME})))INCORRECT_ARRAY_BUFFER_NAME&&CONFIGURABLE_FUNCTION_NAME&&createNonEnumerableProperty$1(NativeArrayBuffer,"name",ARRAY_BUFFER);else{($ArrayBuffer=function(e){return anInstance$4(this,ArrayBufferPrototype$1),new NativeArrayBuffer(toIndex$1(e))})[PROTOTYPE$1]=ArrayBufferPrototype$1;for(var key,keys$1=getOwnPropertyNames$1(NativeArrayBuffer),j=0;keys$1.length>j;)(key=keys$1[j++])in $ArrayBuffer||createNonEnumerableProperty$1($ArrayBuffer,key,NativeArrayBuffer[key]);ArrayBufferPrototype$1.constructor=$ArrayBuffer}setPrototypeOf$1&&getPrototypeOf$2(DataViewPrototype)!==ObjectPrototype$1&&setPrototypeOf$1(DataViewPrototype,ObjectPrototype$1);var testView=new $DataView(new $ArrayBuffer(2)),$setInt8=uncurryThis$i(DataViewPrototype.setInt8);testView.setInt8(0,2147483648),testView.setInt8(1,2147483649),!testView.getInt8(0)&&testView.getInt8(1)||defineBuiltIns$3(DataViewPrototype,{setInt8:function(e,t){$setInt8(this,e,t<<24>>24)},setUint8:function(e,t){$setInt8(this,e,t<<24>>24)}},{unsafe:!0})}else ArrayBufferPrototype$1=($ArrayBuffer=function(e){anInstance$4(this,ArrayBufferPrototype$1);var t=toIndex$1(e);setInternalState$5(this,{bytes:fill(Array$1(t),0),byteLength:t}),DESCRIPTORS$6||(this.byteLength=t)})[PROTOTYPE$1],DataViewPrototype=($DataView=function(e,t,r){anInstance$4(this,DataViewPrototype),anInstance$4(e,ArrayBufferPrototype$1);var n=getInternalState$2(e).byteLength,i=toIntegerOrInfinity$6(t);if(i<0||i>n)throw RangeError$3("Wrong offset");if(i+(r=void 0===r?n-i:toLength$4(r))>n)throw RangeError$3(WRONG_LENGTH$1);setInternalState$5(this,{buffer:e,byteLength:r,byteOffset:i}),DESCRIPTORS$6||(this.buffer=e,this.byteLength=r,this.byteOffset=i)})[PROTOTYPE$1],DESCRIPTORS$6&&(addGetter$1($ArrayBuffer,"byteLength"),addGetter$1($DataView,"buffer"),addGetter$1($DataView,"byteLength"),addGetter$1($DataView,"byteOffset")),defineBuiltIns$3(DataViewPrototype,{getInt8:function(e){return get$1(this,1,e)[0]<<24>>24},getUint8:function(e){return get$1(this,1,e)[0]},getInt16:function(e){var t=get$1(this,2,e,arguments.length>1?arguments[1]:void 0);return(t[1]<<8|t[0])<<16>>16},getUint16:function(e){var t=get$1(this,2,e,arguments.length>1?arguments[1]:void 0);return t[1]<<8|t[0]},getInt32:function(e){return unpackInt32(get$1(this,4,e,arguments.length>1?arguments[1]:void 0))},getUint32:function(e){return unpackInt32(get$1(this,4,e,arguments.length>1?arguments[1]:void 0))>>>0},getFloat32:function(e){return unpackIEEE754(get$1(this,4,e,arguments.length>1?arguments[1]:void 0),23)},getFloat64:function(e){return unpackIEEE754(get$1(this,8,e,arguments.length>1?arguments[1]:void 0),52)},setInt8:function(e,t){set$1(this,1,e,packInt8,t)},setUint8:function(e,t){set$1(this,1,e,packInt8,t)},setInt16:function(e,t){set$1(this,2,e,packInt16,t,arguments.length>2?arguments[2]:void 0)},setUint16:function(e,t){set$1(this,2,e,packInt16,t,arguments.length>2?arguments[2]:void 0)},setInt32:function(e,t){set$1(this,4,e,packInt32,t,arguments.length>2?arguments[2]:void 0)},setUint32:function(e,t){set$1(this,4,e,packInt32,t,arguments.length>2?arguments[2]:void 0)},setFloat32:function(e,t){set$1(this,4,e,packFloat32,t,arguments.length>2?arguments[2]:void 0)},setFloat64:function(e,t){set$1(this,8,e,packFloat64,t,arguments.length>2?arguments[2]:void 0)}});setToStringTag$4($ArrayBuffer,ARRAY_BUFFER),setToStringTag$4($DataView,DATA_VIEW);var arrayBuffer={ArrayBuffer:$ArrayBuffer,DataView:$DataView},isObject$7=isObject$s,floor$3=Math.floor,isIntegralNumber$1=Number.isInteger||function(e){return!isObject$7(e)&&isFinite(e)&&floor$3(e)===e},toIntegerOrInfinity$5=toIntegerOrInfinity$d,$RangeError$4=RangeError,toPositiveInteger$1=function(e){var t=toIntegerOrInfinity$5(e);if(t<0)throw $RangeError$4("The argument can't be less than 0");return t},toPositiveInteger=toPositiveInteger$1,$RangeError$3=RangeError,toOffset$2=function(e,t){var r=toPositiveInteger(e);if(r%t)throw $RangeError$3("Wrong offset");return r},classof$3=classof$i,uncurryThis$h=functionUncurryThis,slice$1=uncurryThis$h("".slice),isBigIntArray$2=function(e){return"Big"===slice$1(classof$3(e),0,3)},toPrimitive=toPrimitive$3,$TypeError=TypeError,toBigInt$3=function(e){var t=toPrimitive(e,"number");if("number"==typeof t)throw $TypeError("Can't convert number to bigint");return BigInt(t)},bind$4=functionBindContext,call$a=functionCall,aConstructor=aConstructor$2,toObject$5=toObject$i,lengthOfArrayLike$a=lengthOfArrayLike$m,getIterator$2=getIterator$4,getIteratorMethod$2=getIteratorMethod$5,isArrayIteratorMethod$1=isArrayIteratorMethod$3,isBigIntArray$1=isBigIntArray$2,aTypedArrayConstructor$2=arrayBufferViewCore.aTypedArrayConstructor,toBigInt$2=toBigInt$3,typedArrayFrom$1=function(e){var t,r,n,i,o,a,s,c,u=aConstructor(this),l=toObject$5(e),d=arguments.length,p=d>1?arguments[1]:void 0,_=void 0!==p,f=getIteratorMethod$2(l);if(f&&!isArrayIteratorMethod$1(f))for(c=(s=getIterator$2(l,f)).next,l=[];!(a=call$a(c,s)).done;)l.push(a.value);for(_&&d>2&&(p=bind$4(p,arguments[2])),r=lengthOfArrayLike$a(l),n=new(aTypedArrayConstructor$2(u))(r),i=isBigIntArray$1(n),t=0;r>t;t++)o=_?p(l[t],t):l[t],n[t]=i?toBigInt$2(o):+o;return n},$$h=_export,global$d=global$K,call$9=functionCall,DESCRIPTORS$5=descriptors,TYPED_ARRAYS_CONSTRUCTORS_REQUIRES_WRAPPERS=typedArrayConstructorsRequireWrappers,ArrayBufferViewCore$s=arrayBufferViewCore,ArrayBufferModule=arrayBuffer,anInstance$3=anInstance$a,createPropertyDescriptor$3=createPropertyDescriptor$b,createNonEnumerableProperty=createNonEnumerableProperty$c,isIntegralNumber=isIntegralNumber$1,toLength$3=toLength$a,toIndex=toIndex$2,toOffset$1=toOffset$2,toPropertyKey$1=toPropertyKey$5,hasOwn$8=hasOwnProperty_1,classof$2=classof$i,isObject$6=isObject$s,isSymbol$1=isSymbol$6,create$1=objectCreate,isPrototypeOf$1=objectIsPrototypeOf,setPrototypeOf=objectSetPrototypeOf,getOwnPropertyNames=objectGetOwnPropertyNames.f,typedArrayFrom=typedArrayFrom$1,forEach=arrayIteration.forEach,setSpecies=setSpecies$4,definePropertyModule$2=objectDefineProperty,getOwnPropertyDescriptorModule$3=objectGetOwnPropertyDescriptor,InternalStateModule$4=internalState,inheritIfRequired=inheritIfRequired$6,getInternalState$1=InternalStateModule$4.get,setInternalState$4=InternalStateModule$4.set,enforceInternalState$1=InternalStateModule$4.enforce,nativeDefineProperty$1=definePropertyModule$2.f,nativeGetOwnPropertyDescriptor$1=getOwnPropertyDescriptorModule$3.f,round=Math.round,RangeError$2=global$d.RangeError,ArrayBuffer$1=ArrayBufferModule.ArrayBuffer,ArrayBufferPrototype=ArrayBuffer$1.prototype,DataView$1=ArrayBufferModule.DataView,NATIVE_ARRAY_BUFFER_VIEWS=ArrayBufferViewCore$s.NATIVE_ARRAY_BUFFER_VIEWS,TYPED_ARRAY_TAG=ArrayBufferViewCore$s.TYPED_ARRAY_TAG,TypedArray=ArrayBufferViewCore$s.TypedArray,TypedArrayPrototype$1=ArrayBufferViewCore$s.TypedArrayPrototype,aTypedArrayConstructor$1=ArrayBufferViewCore$s.aTypedArrayConstructor,isTypedArray$2=ArrayBufferViewCore$s.isTypedArray,BYTES_PER_ELEMENT="BYTES_PER_ELEMENT",WRONG_LENGTH="Wrong length",fromList=function(e,t){aTypedArrayConstructor$1(e);for(var r=0,n=t.length,i=new e(n);n>r;)i[r]=t[r++];return i},addGetter=function(e,t){nativeDefineProperty$1(e,t,{get:function(){return getInternalState$1(this)[t]}})},isArrayBuffer=function(e){var t;return isPrototypeOf$1(ArrayBufferPrototype,e)||"ArrayBuffer"==(t=classof$2(e))||"SharedArrayBuffer"==t},isTypedArrayIndex=function(e,t){return isTypedArray$2(e)&&!isSymbol$1(t)&&t in e&&isIntegralNumber(+t)&&t>=0},wrappedGetOwnPropertyDescriptor=function(e,t){return t=toPropertyKey$1(t),isTypedArrayIndex(e,t)?createPropertyDescriptor$3(2,e[t]):nativeGetOwnPropertyDescriptor$1(e,t)},wrappedDefineProperty=function(e,t,r){return t=toPropertyKey$1(t),!(isTypedArrayIndex(e,t)&&isObject$6(r)&&hasOwn$8(r,"value"))||hasOwn$8(r,"get")||hasOwn$8(r,"set")||r.configurable||hasOwn$8(r,"writable")&&!r.writable||hasOwn$8(r,"enumerable")&&!r.enumerable?nativeDefineProperty$1(e,t,r):(e[t]=r.value,e)};DESCRIPTORS$5?(NATIVE_ARRAY_BUFFER_VIEWS||(getOwnPropertyDescriptorModule$3.f=wrappedGetOwnPropertyDescriptor,definePropertyModule$2.f=wrappedDefineProperty,addGetter(TypedArrayPrototype$1,"buffer"),addGetter(TypedArrayPrototype$1,"byteOffset"),addGetter(TypedArrayPrototype$1,"byteLength"),addGetter(TypedArrayPrototype$1,"length")),$$h({target:"Object",stat:!0,forced:!NATIVE_ARRAY_BUFFER_VIEWS},{getOwnPropertyDescriptor:wrappedGetOwnPropertyDescriptor,defineProperty:wrappedDefineProperty}),typedArrayConstructor.exports=function(e,t,r){var n=e.match(/\d+$/)[0]/8,i=e+(r?"Clamped":"")+"Array",o="get"+e,a="set"+e,s=global$d[i],c=s,u=c&&c.prototype,l={},d=function(e,t){nativeDefineProperty$1(e,t,{get:function(){return function(e,t){var r=getInternalState$1(e);return r.view[o](t*n+r.byteOffset,!0)}(this,t)},set:function(e){return function(e,t,i){var o=getInternalState$1(e);r&&(i=(i=round(i))<0?0:i>255?255:255&i),o.view[a](t*n+o.byteOffset,i,!0)}(this,t,e)},enumerable:!0})};NATIVE_ARRAY_BUFFER_VIEWS?TYPED_ARRAYS_CONSTRUCTORS_REQUIRES_WRAPPERS&&(c=t((function(e,t,r,i){return anInstance$3(e,u),inheritIfRequired(isObject$6(t)?isArrayBuffer(t)?void 0!==i?new s(t,toOffset$1(r,n),i):void 0!==r?new s(t,toOffset$1(r,n)):new s(t):isTypedArray$2(t)?fromList(c,t):call$9(typedArrayFrom,c,t):new s(toIndex(t)),e,c)})),setPrototypeOf&&setPrototypeOf(c,TypedArray),forEach(getOwnPropertyNames(s),(function(e){e in c||createNonEnumerableProperty(c,e,s[e])})),c.prototype=u):(c=t((function(e,t,r,i){anInstance$3(e,u);var o,a,s,l=0,p=0;if(isObject$6(t)){if(!isArrayBuffer(t))return isTypedArray$2(t)?fromList(c,t):call$9(typedArrayFrom,c,t);o=t,p=toOffset$1(r,n);var _=t.byteLength;if(void 0===i){if(_%n)throw RangeError$2(WRONG_LENGTH);if((a=_-p)<0)throw RangeError$2(WRONG_LENGTH)}else if((a=toLength$3(i)*n)+p>_)throw RangeError$2(WRONG_LENGTH);s=a/n}else s=toIndex(t),o=new ArrayBuffer$1(a=s*n);for(setInternalState$4(e,{buffer:o,byteOffset:p,byteLength:a,length:s,view:new DataView$1(o)});l<s;)d(e,l++)})),setPrototypeOf&&setPrototypeOf(c,TypedArray),u=c.prototype=create$1(TypedArrayPrototype$1)),u.constructor!==c&&createNonEnumerableProperty(u,"constructor",c),enforceInternalState$1(u).TypedArrayConstructor=c,TYPED_ARRAY_TAG&&createNonEnumerableProperty(u,TYPED_ARRAY_TAG,i);var p=c!=s;l[i]=c,$$h({global:!0,constructor:!0,forced:p,sham:!NATIVE_ARRAY_BUFFER_VIEWS},l),BYTES_PER_ELEMENT in c||createNonEnumerableProperty(c,BYTES_PER_ELEMENT,n),BYTES_PER_ELEMENT in u||createNonEnumerableProperty(u,BYTES_PER_ELEMENT,n),setSpecies(i)}):typedArrayConstructor.exports=function(){};var createTypedArrayConstructor$2=typedArrayConstructor.exports;createTypedArrayConstructor$2("Uint8",(function(e){return function(t,r,n){return e(this,t,r,n)}}));var ArrayBufferViewCore$r=arrayBufferViewCore,lengthOfArrayLike$9=lengthOfArrayLike$m,toIntegerOrInfinity$4=toIntegerOrInfinity$d,aTypedArray$q=ArrayBufferViewCore$r.aTypedArray,exportTypedArrayMethod$r=ArrayBufferViewCore$r.exportTypedArrayMethod;exportTypedArrayMethod$r("at",(function(e){var t=aTypedArray$q(this),r=lengthOfArrayLike$9(t),n=toIntegerOrInfinity$4(e),i=n>=0?n:r+n;return i<0||i>=r?void 0:t[i]}));var toObject$4=toObject$i,toAbsoluteIndex=toAbsoluteIndex$6,lengthOfArrayLike$8=lengthOfArrayLike$m,deletePropertyOrThrow$1=deletePropertyOrThrow$4,min$3=Math.min,arrayCopyWithin=[].copyWithin||function(e,t){var r=toObject$4(this),n=lengthOfArrayLike$8(r),i=toAbsoluteIndex(e,n),o=toAbsoluteIndex(t,n),a=arguments.length>2?arguments[2]:void 0,s=min$3((void 0===a?n:toAbsoluteIndex(a,n))-o,n-i),c=1;for(o<i&&i<o+s&&(c=-1,o+=s-1,i+=s-1);s-- >0;)o in r?r[i]=r[o]:deletePropertyOrThrow$1(r,i),i+=c,o+=c;return r},uncurryThis$g=functionUncurryThis,ArrayBufferViewCore$q=arrayBufferViewCore,$ArrayCopyWithin=arrayCopyWithin,u$ArrayCopyWithin=uncurryThis$g($ArrayCopyWithin),aTypedArray$p=ArrayBufferViewCore$q.aTypedArray,exportTypedArrayMethod$q=ArrayBufferViewCore$q.exportTypedArrayMethod;exportTypedArrayMethod$q("copyWithin",(function(e,t){return u$ArrayCopyWithin(aTypedArray$p(this),e,t,arguments.length>2?arguments[2]:void 0)}));var ArrayBufferViewCore$p=arrayBufferViewCore,$every=arrayIteration.every,aTypedArray$o=ArrayBufferViewCore$p.aTypedArray,exportTypedArrayMethod$p=ArrayBufferViewCore$p.exportTypedArrayMethod;exportTypedArrayMethod$p("every",(function(e){return $every(aTypedArray$o(this),e,arguments.length>1?arguments[1]:void 0)}));var ArrayBufferViewCore$o=arrayBufferViewCore,$fill=arrayFill$1,toBigInt$1=toBigInt$3,classof$1=classof$i,call$8=functionCall,uncurryThis$f=functionUncurryThis,fails$c=fails$U,aTypedArray$n=ArrayBufferViewCore$o.aTypedArray,exportTypedArrayMethod$o=ArrayBufferViewCore$o.exportTypedArrayMethod,slice=uncurryThis$f("".slice),CONVERSION_BUG=fails$c((function(){var e=0;return new Int8Array(2).fill({valueOf:function(){return e++}}),1!==e}));exportTypedArrayMethod$o("fill",(function(e){var t=arguments.length;aTypedArray$n(this);var r="Big"===slice(classof$1(this),0,3)?toBigInt$1(e):+e;return call$8($fill,this,r,t>1?arguments[1]:void 0,t>2?arguments[2]:void 0)}),CONVERSION_BUG);var lengthOfArrayLike$7=lengthOfArrayLike$m,arrayFromConstructorAndList$2=function(e,t){for(var r=0,n=lengthOfArrayLike$7(t),i=new e(n);n>r;)i[r]=t[r++];return i},ArrayBufferViewCore$n=arrayBufferViewCore,speciesConstructor$1=speciesConstructor$4,aTypedArrayConstructor=ArrayBufferViewCore$n.aTypedArrayConstructor,getTypedArrayConstructor$3=ArrayBufferViewCore$n.getTypedArrayConstructor,typedArraySpeciesConstructor$3=function(e){return aTypedArrayConstructor(speciesConstructor$1(e,getTypedArrayConstructor$3(e)))},arrayFromConstructorAndList$1=arrayFromConstructorAndList$2,typedArraySpeciesConstructor$2=typedArraySpeciesConstructor$3,typedArrayFromSpeciesAndList=function(e,t){return arrayFromConstructorAndList$1(typedArraySpeciesConstructor$2(e),t)},ArrayBufferViewCore$m=arrayBufferViewCore,$filter=arrayIteration.filter,fromSpeciesAndList=typedArrayFromSpeciesAndList,aTypedArray$m=ArrayBufferViewCore$m.aTypedArray,exportTypedArrayMethod$n=ArrayBufferViewCore$m.exportTypedArrayMethod;exportTypedArrayMethod$n("filter",(function(e){var t=$filter(aTypedArray$m(this),e,arguments.length>1?arguments[1]:void 0);return fromSpeciesAndList(this,t)}));var ArrayBufferViewCore$l=arrayBufferViewCore,$find=arrayIteration.find,aTypedArray$l=ArrayBufferViewCore$l.aTypedArray,exportTypedArrayMethod$m=ArrayBufferViewCore$l.exportTypedArrayMethod;exportTypedArrayMethod$m("find",(function(e){return $find(aTypedArray$l(this),e,arguments.length>1?arguments[1]:void 0)}));var ArrayBufferViewCore$k=arrayBufferViewCore,$findIndex$1=arrayIteration.findIndex,aTypedArray$k=ArrayBufferViewCore$k.aTypedArray,exportTypedArrayMethod$l=ArrayBufferViewCore$k.exportTypedArrayMethod;exportTypedArrayMethod$l("findIndex",(function(e){return $findIndex$1(aTypedArray$k(this),e,arguments.length>1?arguments[1]:void 0)}));var bind$3=functionBindContext,IndexedObject=indexedObject,toObject$3=toObject$i,lengthOfArrayLike$6=lengthOfArrayLike$m,createMethod$2=function(e){var t=1==e;return function(r,n,i){for(var o,a=toObject$3(r),s=IndexedObject(a),c=bind$3(n,i),u=lengthOfArrayLike$6(s);u-- >0;)if(c(o=s[u],u,a))switch(e){case 0:return o;case 1:return u}return t?-1:void 0}},arrayIterationFromLast={findLast:createMethod$2(0),findLastIndex:createMethod$2(1)},ArrayBufferViewCore$j=arrayBufferViewCore,$findLast=arrayIterationFromLast.findLast,aTypedArray$j=ArrayBufferViewCore$j.aTypedArray,exportTypedArrayMethod$k=ArrayBufferViewCore$j.exportTypedArrayMethod;exportTypedArrayMethod$k("findLast",(function(e){return $findLast(aTypedArray$j(this),e,arguments.length>1?arguments[1]:void 0)}));var ArrayBufferViewCore$i=arrayBufferViewCore,$findLastIndex=arrayIterationFromLast.findLastIndex,aTypedArray$i=ArrayBufferViewCore$i.aTypedArray,exportTypedArrayMethod$j=ArrayBufferViewCore$i.exportTypedArrayMethod;exportTypedArrayMethod$j("findLastIndex",(function(e){return $findLastIndex(aTypedArray$i(this),e,arguments.length>1?arguments[1]:void 0)}));var ArrayBufferViewCore$h=arrayBufferViewCore,$forEach$1=arrayIteration.forEach,aTypedArray$h=ArrayBufferViewCore$h.aTypedArray,exportTypedArrayMethod$i=ArrayBufferViewCore$h.exportTypedArrayMethod;exportTypedArrayMethod$i("forEach",(function(e){$forEach$1(aTypedArray$h(this),e,arguments.length>1?arguments[1]:void 0)}));var ArrayBufferViewCore$g=arrayBufferViewCore,$includes=arrayIncludes.includes,aTypedArray$g=ArrayBufferViewCore$g.aTypedArray,exportTypedArrayMethod$h=ArrayBufferViewCore$g.exportTypedArrayMethod;exportTypedArrayMethod$h("includes",(function(e){return $includes(aTypedArray$g(this),e,arguments.length>1?arguments[1]:void 0)}));var ArrayBufferViewCore$f=arrayBufferViewCore,$indexOf=arrayIncludes.indexOf,aTypedArray$f=ArrayBufferViewCore$f.aTypedArray,exportTypedArrayMethod$g=ArrayBufferViewCore$f.exportTypedArrayMethod;exportTypedArrayMethod$g("indexOf",(function(e){return $indexOf(aTypedArray$f(this),e,arguments.length>1?arguments[1]:void 0)}));var global$c=global$K,fails$b=fails$U,uncurryThis$e=functionUncurryThis,ArrayBufferViewCore$e=arrayBufferViewCore,ArrayIterators=es_array_iterator,wellKnownSymbol$5=wellKnownSymbol$u,ITERATOR$2=wellKnownSymbol$5("iterator"),Uint8Array$2=global$c.Uint8Array,arrayValues=uncurryThis$e(ArrayIterators.values),arrayKeys=uncurryThis$e(ArrayIterators.keys),arrayEntries=uncurryThis$e(ArrayIterators.entries),aTypedArray$e=ArrayBufferViewCore$e.aTypedArray,exportTypedArrayMethod$f=ArrayBufferViewCore$e.exportTypedArrayMethod,TypedArrayPrototype=Uint8Array$2&&Uint8Array$2.prototype,GENERIC=!fails$b((function(){TypedArrayPrototype[ITERATOR$2].call([1])})),ITERATOR_IS_VALUES=!!TypedArrayPrototype&&TypedArrayPrototype.values&&TypedArrayPrototype[ITERATOR$2]===TypedArrayPrototype.values&&"values"===TypedArrayPrototype.values.name,typedArrayValues=function(){return arrayValues(aTypedArray$e(this))};exportTypedArrayMethod$f("entries",(function(){return arrayEntries(aTypedArray$e(this))}),GENERIC),exportTypedArrayMethod$f("keys",(function(){return arrayKeys(aTypedArray$e(this))}),GENERIC),exportTypedArrayMethod$f("values",typedArrayValues,GENERIC||!ITERATOR_IS_VALUES,{name:"values"}),exportTypedArrayMethod$f(ITERATOR$2,typedArrayValues,GENERIC||!ITERATOR_IS_VALUES,{name:"values"});var ArrayBufferViewCore$d=arrayBufferViewCore,uncurryThis$d=functionUncurryThis,aTypedArray$d=ArrayBufferViewCore$d.aTypedArray,exportTypedArrayMethod$e=ArrayBufferViewCore$d.exportTypedArrayMethod,$join=uncurryThis$d([].join);exportTypedArrayMethod$e("join",(function(e){return $join(aTypedArray$d(this),e)}));var apply$4=functionApply,toIndexedObject$3=toIndexedObject$c,toIntegerOrInfinity$3=toIntegerOrInfinity$d,lengthOfArrayLike$5=lengthOfArrayLike$m,arrayMethodIsStrict=arrayMethodIsStrict$5,min$2=Math.min,$lastIndexOf$1=[].lastIndexOf,NEGATIVE_ZERO=!!$lastIndexOf$1&&1/[1].lastIndexOf(1,-0)<0,STRICT_METHOD=arrayMethodIsStrict("lastIndexOf"),FORCED$4=NEGATIVE_ZERO||!STRICT_METHOD,arrayLastIndexOf=FORCED$4?function(e){if(NEGATIVE_ZERO)return apply$4($lastIndexOf$1,this,arguments)||0;var t=toIndexedObject$3(this),r=lengthOfArrayLike$5(t),n=r-1;for(arguments.length>1&&(n=min$2(n,toIntegerOrInfinity$3(arguments[1]))),n<0&&(n=r+n);n>=0;n--)if(n in t&&t[n]===e)return n||0;return-1}:$lastIndexOf$1,ArrayBufferViewCore$c=arrayBufferViewCore,apply$3=functionApply,$lastIndexOf=arrayLastIndexOf,aTypedArray$c=ArrayBufferViewCore$c.aTypedArray,exportTypedArrayMethod$d=ArrayBufferViewCore$c.exportTypedArrayMethod;exportTypedArrayMethod$d("lastIndexOf",(function(e){var t=arguments.length;return apply$3($lastIndexOf,aTypedArray$c(this),t>1?[e,arguments[1]]:[e])}));var ArrayBufferViewCore$b=arrayBufferViewCore,$map=arrayIteration.map,typedArraySpeciesConstructor$1=typedArraySpeciesConstructor$3,aTypedArray$b=ArrayBufferViewCore$b.aTypedArray,exportTypedArrayMethod$c=ArrayBufferViewCore$b.exportTypedArrayMethod;exportTypedArrayMethod$c("map",(function(e){return $map(aTypedArray$b(this),e,arguments.length>1?arguments[1]:void 0,(function(e,t){return new(typedArraySpeciesConstructor$1(e))(t)}))}));var ArrayBufferViewCore$a=arrayBufferViewCore,$reduce=arrayReduce.left,aTypedArray$a=ArrayBufferViewCore$a.aTypedArray,exportTypedArrayMethod$b=ArrayBufferViewCore$a.exportTypedArrayMethod;exportTypedArrayMethod$b("reduce",(function(e){var t=arguments.length;return $reduce(aTypedArray$a(this),e,t,t>1?arguments[1]:void 0)}));var ArrayBufferViewCore$9=arrayBufferViewCore,$reduceRight=arrayReduce.right,aTypedArray$9=ArrayBufferViewCore$9.aTypedArray,exportTypedArrayMethod$a=ArrayBufferViewCore$9.exportTypedArrayMethod;exportTypedArrayMethod$a("reduceRight",(function(e){var t=arguments.length;return $reduceRight(aTypedArray$9(this),e,t,t>1?arguments[1]:void 0)}));var ArrayBufferViewCore$8=arrayBufferViewCore,aTypedArray$8=ArrayBufferViewCore$8.aTypedArray,exportTypedArrayMethod$9=ArrayBufferViewCore$8.exportTypedArrayMethod,floor$2=Math.floor;exportTypedArrayMethod$9("reverse",(function(){for(var e,t=this,r=aTypedArray$8(t).length,n=floor$2(r/2),i=0;i<n;)e=t[i],t[i++]=t[--r],t[r]=e;return t}));var global$b=global$K,call$7=functionCall,ArrayBufferViewCore$7=arrayBufferViewCore,lengthOfArrayLike$4=lengthOfArrayLike$m,toOffset=toOffset$2,toIndexedObject$2=toObject$i,fails$a=fails$U,RangeError$1=global$b.RangeError,Int8Array$2=global$b.Int8Array,Int8ArrayPrototype=Int8Array$2&&Int8Array$2.prototype,$set=Int8ArrayPrototype&&Int8ArrayPrototype.set,aTypedArray$7=ArrayBufferViewCore$7.aTypedArray,exportTypedArrayMethod$8=ArrayBufferViewCore$7.exportTypedArrayMethod,WORKS_WITH_OBJECTS_AND_GEERIC_ON_TYPED_ARRAYS=!fails$a((function(){var e=new Uint8ClampedArray(2);return call$7($set,e,{length:1,0:3},1),3!==e[1]})),TO_OBJECT_BUG=WORKS_WITH_OBJECTS_AND_GEERIC_ON_TYPED_ARRAYS&&ArrayBufferViewCore$7.NATIVE_ARRAY_BUFFER_VIEWS&&fails$a((function(){var e=new Int8Array$2(2);return e.set(1),e.set("2",1),0!==e[0]||2!==e[1]}));exportTypedArrayMethod$8("set",(function(e){aTypedArray$7(this);var t=toOffset(arguments.length>1?arguments[1]:void 0,1),r=toIndexedObject$2(e);if(WORKS_WITH_OBJECTS_AND_GEERIC_ON_TYPED_ARRAYS)return call$7($set,this,r,t);var n=this.length,i=lengthOfArrayLike$4(r),o=0;if(i+t>n)throw RangeError$1("Wrong length");for(;o<i;)this[t+o]=r[o++]}),!WORKS_WITH_OBJECTS_AND_GEERIC_ON_TYPED_ARRAYS||TO_OBJECT_BUG);var ArrayBufferViewCore$6=arrayBufferViewCore,typedArraySpeciesConstructor=typedArraySpeciesConstructor$3,fails$9=fails$U,arraySlice$3=arraySlice$9,aTypedArray$6=ArrayBufferViewCore$6.aTypedArray,exportTypedArrayMethod$7=ArrayBufferViewCore$6.exportTypedArrayMethod,FORCED$3=fails$9((function(){new Int8Array(1).slice()}));exportTypedArrayMethod$7("slice",(function(e,t){for(var r=arraySlice$3(aTypedArray$6(this),e,t),n=typedArraySpeciesConstructor(this),i=0,o=r.length,a=new n(o);o>i;)a[i]=r[i++];return a}),FORCED$3);var ArrayBufferViewCore$5=arrayBufferViewCore,$some=arrayIteration.some,aTypedArray$5=ArrayBufferViewCore$5.aTypedArray,exportTypedArrayMethod$6=ArrayBufferViewCore$5.exportTypedArrayMethod;exportTypedArrayMethod$6("some",(function(e){return $some(aTypedArray$5(this),e,arguments.length>1?arguments[1]:void 0)}));var global$a=global$K,uncurryThis$c=functionUncurryThisClause,fails$8=fails$U,aCallable$1=aCallable$b,internalSort=arraySort$1,ArrayBufferViewCore$4=arrayBufferViewCore,FF=engineFfVersion,IE_OR_EDGE=engineIsIeOrEdge,V8=engineV8Version,WEBKIT=engineWebkitVersion,aTypedArray$4=ArrayBufferViewCore$4.aTypedArray,exportTypedArrayMethod$5=ArrayBufferViewCore$4.exportTypedArrayMethod,Uint16Array$1=global$a.Uint16Array,nativeSort=Uint16Array$1&&uncurryThis$c(Uint16Array$1.prototype.sort),ACCEPT_INCORRECT_ARGUMENTS=!(!nativeSort||fails$8((function(){nativeSort(new Uint16Array$1(2),null)}))&&fails$8((function(){nativeSort(new Uint16Array$1(2),{})}))),STABLE_SORT=!!nativeSort&&!fails$8((function(){if(V8)return V8<74;if(FF)return FF<67;if(IE_OR_EDGE)return!0;if(WEBKIT)return WEBKIT<602;var e,t,r=new Uint16Array$1(516),n=Array(516);for(e=0;e<516;e++)t=e%4,r[e]=515-e,n[e]=e-2*t+3;for(nativeSort(r,(function(e,t){return(e/4|0)-(t/4|0)})),e=0;e<516;e++)if(r[e]!==n[e])return!0})),getSortCompare=function(e){return function(t,r){return void 0!==e?+e(t,r)||0:r!=r?-1:t!=t?1:0===t&&0===r?1/t>0&&1/r<0?1:-1:t>r}};exportTypedArrayMethod$5("sort",(function(e){return void 0!==e&&aCallable$1(e),STABLE_SORT?nativeSort(this,e):internalSort(aTypedArray$4(this),getSortCompare(e))}),!STABLE_SORT||ACCEPT_INCORRECT_ARGUMENTS);var global$9=global$K,apply$2=functionApply,ArrayBufferViewCore$3=arrayBufferViewCore,fails$7=fails$U,arraySlice$2=arraySlice$9,Int8Array$1=global$9.Int8Array,aTypedArray$3=ArrayBufferViewCore$3.aTypedArray,exportTypedArrayMethod$4=ArrayBufferViewCore$3.exportTypedArrayMethod,$toLocaleString=[].toLocaleString,TO_LOCALE_STRING_BUG=!!Int8Array$1&&fails$7((function(){$toLocaleString.call(new Int8Array$1(1))})),FORCED$2=fails$7((function(){return[1,2].toLocaleString()!=new Int8Array$1([1,2]).toLocaleString()}))||!fails$7((function(){Int8Array$1.prototype.toLocaleString.call([1,2])}));exportTypedArrayMethod$4("toLocaleString",(function(){return apply$2($toLocaleString,TO_LOCALE_STRING_BUG?arraySlice$2(aTypedArray$3(this)):aTypedArray$3(this),arraySlice$2(arguments))}),FORCED$2);var exportTypedArrayMethod$3=arrayBufferViewCore.exportTypedArrayMethod,fails$6=fails$U,global$8=global$K,uncurryThis$b=functionUncurryThis,Uint8Array$1=global$8.Uint8Array,Uint8ArrayPrototype=Uint8Array$1&&Uint8Array$1.prototype||{},arrayToString=[].toString,join$3=uncurryThis$b([].join);fails$6((function(){arrayToString.call({})}))&&(arrayToString=function(){return join$3(this)});var IS_NOT_ARRAY_METHOD=Uint8ArrayPrototype.toString!=arrayToString;exportTypedArrayMethod$3("toString",arrayToString,IS_NOT_ARRAY_METHOD);var lengthOfArrayLike$3=lengthOfArrayLike$m,arrayToReversed$1=function(e,t){for(var r=lengthOfArrayLike$3(e),n=new t(r),i=0;i<r;i++)n[i]=e[r-i-1];return n},arrayToReversed=arrayToReversed$1,ArrayBufferViewCore$2=arrayBufferViewCore,aTypedArray$2=ArrayBufferViewCore$2.aTypedArray,exportTypedArrayMethod$2=ArrayBufferViewCore$2.exportTypedArrayMethod,getTypedArrayConstructor$2=ArrayBufferViewCore$2.getTypedArrayConstructor;exportTypedArrayMethod$2("toReversed",(function(){return arrayToReversed(aTypedArray$2(this),getTypedArrayConstructor$2(this))}));var ArrayBufferViewCore$1=arrayBufferViewCore,uncurryThis$a=functionUncurryThis,aCallable=aCallable$b,arrayFromConstructorAndList=arrayFromConstructorAndList$2,aTypedArray$1=ArrayBufferViewCore$1.aTypedArray,getTypedArrayConstructor$1=ArrayBufferViewCore$1.getTypedArrayConstructor,exportTypedArrayMethod$1=ArrayBufferViewCore$1.exportTypedArrayMethod,sort=uncurryThis$a(ArrayBufferViewCore$1.TypedArrayPrototype.sort);exportTypedArrayMethod$1("toSorted",(function(e){void 0!==e&&aCallable(e);var t=aTypedArray$1(this),r=arrayFromConstructorAndList(getTypedArrayConstructor$1(t),t);return sort(r,e)}));var lengthOfArrayLike$2=lengthOfArrayLike$m,toIntegerOrInfinity$2=toIntegerOrInfinity$d,$RangeError$2=RangeError,arrayWith$1=function(e,t,r,n){var i=lengthOfArrayLike$2(e),o=toIntegerOrInfinity$2(r),a=o<0?i+o:o;if(a>=i||a<0)throw $RangeError$2("Incorrect index");for(var s=new t(i),c=0;c<i;c++)s[c]=c===a?n:e[c];return s},arrayWith=arrayWith$1,ArrayBufferViewCore=arrayBufferViewCore,isBigIntArray=isBigIntArray$2,toIntegerOrInfinity$1=toIntegerOrInfinity$d,toBigInt=toBigInt$3,aTypedArray=ArrayBufferViewCore.aTypedArray,getTypedArrayConstructor=ArrayBufferViewCore.getTypedArrayConstructor,exportTypedArrayMethod=ArrayBufferViewCore.exportTypedArrayMethod,PROPER_ORDER=!!function(){try{new Int8Array(1).with(2,{valueOf:function(){throw 8}})}catch(e){return 8===e}}();exportTypedArrayMethod("with",{with:function(e,t){var r=aTypedArray(this),n=toIntegerOrInfinity$1(e),i=isBigIntArray(r)?toBigInt(t):+t;return arrayWith(r,getTypedArrayConstructor(r),n,i)}}.with,!PROPER_ORDER);var $$g=_export,$findIndex=arrayIteration.findIndex,addToUnscopables=addToUnscopables$4,FIND_INDEX="findIndex",SKIPS_HOLES=!0;FIND_INDEX in[]&&Array(1)[FIND_INDEX]((function(){SKIPS_HOLES=!1})),$$g({target:"Array",proto:!0,forced:SKIPS_HOLES},{findIndex:function(e){return $findIndex(this,e,arguments.length>1?arguments[1]:void 0)}}),addToUnscopables(FIND_INDEX);var ErrorCode=function(e){return e.INVALID_ENGINE="INVALID_ENGINE",e.INVALID_PARAMS="INVALID_PARAMS",e.INVOKED_BEFORE_JOIN_ROOM="INVOKED_BEFORE_JOIN_ROOM",e.INVALID_TOKEN="INVALID_TOKEN",e.EXPIRED_TOKEN="EXPIRED_TOKEN",e.JOIN_ROOM_FAILED="JOIN_ROOM_FAILED",e.UPDATE_TOKEN_WITH_INVALID_TOKEN="UPDATE_TOKEN_WITH_INVALID_TOKEN",e.UPDATE_TOKEN_BEFORE_JOIN="UPDATE_TOKEN_BEFORE_JOIN",e.REPEAT_JOIN="REPEAT_JOIN",e.REPEAT_PUBLISH="REPEAT_PUBLISH",e.REPEAT_PUSH="REPEAT_PUSH",e.REPEAT_PLAY="REPEAT_PLAY",e.PUBLISH_BEFORE_JOIN="PUBLISH_BEFORE_JOIN",e.UNPUBLISH_BEFORE_JOIN="UNPUBLISH_BEFORE_JOIN",e.SUBSCRIBE_BEFORE_JOIN="SUBSCRIBE_BEFORE_JOIN",e.UNSUBSCRIBE_BEFORE_JOIN="UNSUBSCRIBE_BEFORE_JOIN",e.NO_PUBLISH_PERMISSION="NO_PUBLISH_PERMISSION",e.STREAM_NOT_EXIST="STREAM_NOT_EXIST",e.EMPTY_STREAM="EMPTY_STREAM",e.NOT_CONNECTED_YET="NOT_CONNECTED_YET",e.IM_BEFORE_JOIN="IM_BEFORE_JOIN",e.USER_NOT_EXIST="USER_NOT_EXIST",e.ALREADY_IN_ROOM="ALREADY_IN_ROOM",e.KICKED_OUT="KICKED_OUT",e.ROOM_DISMISS="ROOM_DISMISS",e.TOKEN_EXPIRED="TOKEN_EXPIRED",e.DUPLICATE_LOGIN="DUPLICATE_LOGIN",e.INVOKED_BEFORE_CAPTURE="INVOKED_BEFORE_CAPTURE",e.REPEAT_CAPTURE="REPEAT_CAPTURE",e.GET_VIDEO_TRACK_FAILED="GET_VIDEO_TRACK_FAILED",e.GET_AUDIO_TRACK_FAILED="GET_AUDIO_TRACK_FAILED",e.GET_SCREEN_TRACK_FAILED="GET_SCREEN_TRACK_FAILED",e.STREAM_TYPE_NOT_MATCH="STREAM_TYPE_NOT_MATCH",e.CANT_FIND_DOM="CANT_FIND_DOM",e.INVALID_DEVICE_ID="INVALID_DEVICE_ID",e.NO_PERMISSION="NO_PERMISSION",e.NOT_SUPPORTED="NOT_SUPPORTED",e.INTERRUPT="INTERRUPT",e.ICE_SERVER_WRONG="ICE_SERVER_WRONG",e.ESTABLISH_DATACHANNEL_FAILED="ESTABLISH_DATACHANNEL_FAILED",e.LOAD_RESOURCES_FAILED="LOAD_RESOURCES_FAILED",e.SIGNALING_CHANNEL_NOT_OPEN="SIGNALING_CHANNEL_NOT_OPEN",e.TIME_OUT="TIME_OUT",e.REFUSE_OPERATION_IN_DISCONNECT="REFUSE_OPERATION_IN_DISCONNECT",e.ADD_TRANSCEIVER_FAILED="ADD_TRANSCEIVER_FAILED",e.UPDATE_TRACK_FAILED="UPDATE_TRACK_FAILED",e.PUBLISH_FAILED="PUBLISH_FAILED",e.UNPUBLISH_FAILED="UNPUBLISH_FAILED",e.SUBSCRIBE_FAILED="SUBSCRIBE_FAILED",e.UNSUBSCRIBE_FAILED="UNSUBSCRIBE_FAILED",e.OPERATION_CANCEL="OPERATION_CANCEL",e.START_CLOUD_PROXY_AFTER_JOIN="START_CLOUD_PROXY_AFTER_JOIN",e.STOP_CLOUD_PROXY_BEFORE_LEAVE="STOP_CLOUD_PROXY_BEFORE_LEAVE",e.UNEXPECTED_ERROR="UNEXPECTED_ERROR",e.REPEAT_DEVICE_TEST="REPEAT_DEVICE_TEST",e.AUDIO_DEVICE_TEST_FAILED="AUDIO_DEVICE_RECORD_FAILED",e.ALREADY_LOGIN="ALREADY_LOGIN",e.LOGIN_FAILED="LOGIN_FAILED",e.NOT_LOGIN="NOT_LOGIN",e.RTM_DUPLICATE_LOGIN="RTM_DUPLICATE_LOGIN",e.RTM_TOKEN_ERROR="RTM_TOKEN_ERROR",e.USER_MESSAGE_TIMEOUT="USER_MESSAGE_TIMEOUT",e.USER_MESSAGE_BROKEN="USER_MESSAGE_BROKEN",e.USER_MESSAGE_NO_RECEIVER="USER_MESSAGE_NO_RECEIVER",e.USER_MESSAGE_NO_RELAYPATH="USER_MESSAGE_NO_RELAYPATH",e.USER_MESSAGE_SEND_TO_SERVER_ERROR="USER_MESSAGE_SEND_TO_SERVER_ERROR",e.USER_MESSAGE_SERVER_RESPONSE_ERROR="USER_MESSAGE_SERVER_RESPONSE_ERROR",e.USER_MESSAGE_NOT_JOIN="USER_MESSAGE_NOT_JOIN",e.USER_MESSAGE_INIT="USER_MESSAGE_INIT",e.USER_MESSAGE_NO_CONNECTION="USER_MESSAGE_NO_CONNECTION",e.USER_MESSAGE_NOT_LOGIN="USER_MESSAGE_NOT_LOGIN",e.USER_MESSAGE_SERVER_PARAMS_NOTSET="USER_MESSAGE_SERVER_PARAMS_NOTSET",e.USER_MESSAGE_UNKNOWN="USER_MESSAGE_UNKNOWN",e.START_PUBLIC_STREAM_BEFORE_JOIN="START_PUBLIC_STREAM_BEFORE_JOIN",e.RECONNECT_FAILED="RECONNECT_FAILED",e}(ErrorCode||{}),AudioMixingError=function(e){return e[e.AUDIO_MIXING_ERROR_OK=0]="AUDIO_MIXING_ERROR_OK",e[e.AUDIO_MIXING_ERROR_PRELOAD_FAILED=1]="AUDIO_MIXING_ERROR_PRELOAD_FAILED",e[e.AUDIO_MIXING_ERROR_START_FAILED=2]="AUDIO_MIXING_ERROR_START_FAILED",e[e.AUDIO_MIXING_ERROR_ID_NOT_FOUND=3]="AUDIO_MIXING_ERROR_ID_NOT_FOUND",e[e.AUDIO_MIXING_ERROR_SET_POSITION_FAILED=4]="AUDIO_MIXING_ERROR_SET_POSITION_FAILED",e[e.AUDIO_MIXING_ERROR_INVALID_VOLUME=5]="AUDIO_MIXING_ERROR_INVALID_VOLUME",e[e.AUDIO_MIXING_ERROR_LOAD_CONFLICT=6]="AUDIO_MIXING_ERROR_LOAD_CONFLICT",e[e.AUDIO_MIXING_ERROR_ID_TYPE_NOT_MATCH=7]="AUDIO_MIXING_ERROR_ID_TYPE_NOT_MATCH",e[e.AUDIO_MIXING_ERROR_ID_TYPE_INVALID_PITCH=8]="AUDIO_MIXING_ERROR_ID_TYPE_INVALID_PITCH",e[e.AUDIO_MIXING_ERROR_INVALID_AUDIO_TRACK=9]="AUDIO_MIXING_ERROR_INVALID_AUDIO_TRACK",e}(AudioMixingError||{}),SDKError=_createClass((function e(t,r,n){_classCallCheck(this,e),_defineProperty(this,"code",void 0),_defineProperty(this,"message",void 0),_defineProperty(this,"error",void 0),this.code=t,this.message=r,this.error=n})),DESCRIPTORS$4=descriptors,uncurryThis$9=functionUncurryThis,objectKeys$1=objectKeys$4,toIndexedObject$1=toIndexedObject$c,$propertyIsEnumerable$1=objectPropertyIsEnumerable.f,propertyIsEnumerable$1=uncurryThis$9($propertyIsEnumerable$1),push$5=uncurryThis$9([].push),createMethod$1=function(e){return function(t){for(var r,n=toIndexedObject$1(t),i=objectKeys$1(n),o=i.length,a=0,s=[];o>a;)r=i[a++],DESCRIPTORS$4&&!propertyIsEnumerable$1(n,r)||push$5(s,e?[r,n[r]]:n[r]);return s}},objectToArray={entries:createMethod$1(!0),values:createMethod$1(!1)},$$f=_export,$entries=objectToArray.entries;$$f({target:"Object",stat:!0},{entries:function(e){return $entries(e)}});var toIntegerOrInfinity=toIntegerOrInfinity$d,toString$6=toString$m,requireObjectCoercible$3=requireObjectCoercible$d,$RangeError$1=RangeError,stringRepeat=function(e){var t=toString$6(requireObjectCoercible$3(this)),r="",n=toIntegerOrInfinity(e);if(n<0||n==1/0)throw $RangeError$1("Wrong number of repetitions");for(;n>0;(n>>>=1)&&(t+=t))1&n&&(r+=t);return r},uncurryThis$8=functionUncurryThis,toLength$2=toLength$a,toString$5=toString$m,$repeat=stringRepeat,requireObjectCoercible$2=requireObjectCoercible$d,repeat=uncurryThis$8($repeat),stringSlice$4=uncurryThis$8("".slice),ceil=Math.ceil,createMethod=function(e){return function(t,r,n){var i,o,a=toString$5(requireObjectCoercible$2(t)),s=toLength$2(r),c=a.length,u=void 0===n?" ":toString$5(n);return s<=c||""==u?a:((o=repeat(u,ceil((i=s-c)/u.length))).length>i&&(o=stringSlice$4(o,0,i)),e?a+o:o+a)}},stringPad={start:createMethod(!1),end:createMethod(!0)},userAgent=engineUserAgent,stringPadWebkitBug=/Version\/10(?:\.\d+){1,2}(?: [\w./]+)?(?: Mobile\/\w+)? Safari\//.test(userAgent),$$e=_export,$padEnd=stringPad.end,WEBKIT_BUG=stringPadWebkitBug;$$e({target:"String",proto:!0,forced:WEBKIT_BUG},{padEnd:function(e){return $padEnd(this,e,arguments.length>1?arguments[1]:void 0)}});var $$d=_export,parseInt$2=numberParseInt;$$d({target:"Number",stat:!0,forced:Number.parseInt!=parseInt$2},{parseInt:parseInt$2});var anObject$6=anObject$q,iteratorClose=iteratorClose$2,callWithSafeIterationClosing$1=function(e,t,r,n){try{return n?t(anObject$6(r)[0],r[1]):t(r)}catch(t){iteratorClose(e,"throw",t)}},bind$2=functionBindContext,call$6=functionCall,toObject$2=toObject$i,callWithSafeIterationClosing=callWithSafeIterationClosing$1,isArrayIteratorMethod=isArrayIteratorMethod$3,isConstructor=isConstructor$4,lengthOfArrayLike$1=lengthOfArrayLike$m,createProperty=createProperty$5,getIterator$1=getIterator$4,getIteratorMethod$1=getIteratorMethod$5,$Array=Array,arrayFrom$1=function(e){var t=toObject$2(e),r=isConstructor(this),n=arguments.length,i=n>1?arguments[1]:void 0,o=void 0!==i;o&&(i=bind$2(i,n>2?arguments[2]:void 0));var a,s,c,u,l,d,p=getIteratorMethod$1(t),_=0;if(!p||this===$Array&&isArrayIteratorMethod(p))for(a=lengthOfArrayLike$1(t),s=r?new this(a):$Array(a);a>_;_++)d=o?i(t[_],_):t[_],createProperty(s,_,d);else for(l=(u=getIterator$1(t,p)).next,s=r?new this:[];!(c=call$6(l,u)).done;_++)d=o?callWithSafeIterationClosing(u,i,[c.value,_],!0):c.value,createProperty(s,_,d);return s.length=_,s},$$c=_export,from=arrayFrom$1,checkCorrectnessOfIteration=checkCorrectnessOfIteration$4,INCORRECT_ITERATION=!checkCorrectnessOfIteration((function(e){Array.from(e)}));$$c({target:"Array",stat:!0,forced:INCORRECT_ITERATION},{from:from});var log=Math.log,LOG10E=Math.LOG10E,mathLog10=Math.log10||function(e){return log(e)*LOG10E},$$b=_export,log10=mathLog10;$$b({target:"Math",stat:!0},{log10:log10});var $$a=_export,uncurryThis$7=functionUncurryThisClause,getOwnPropertyDescriptor$1=objectGetOwnPropertyDescriptor.f,toLength$1=toLength$a,toString$4=toString$m,notARegExp=notARegexp,requireObjectCoercible$1=requireObjectCoercible$d,correctIsRegExpLogic=correctIsRegexpLogic,nativeStartsWith=uncurryThis$7("".startsWith),stringSlice$3=uncurryThis$7("".slice),min$1=Math.min,CORRECT_IS_REGEXP_LOGIC=correctIsRegExpLogic("startsWith"),MDN_POLYFILL_BUG=!CORRECT_IS_REGEXP_LOGIC&&!!function(){var e=getOwnPropertyDescriptor$1(String.prototype,"startsWith");return e&&!e.writable}();$$a({target:"String",proto:!0,forced:!MDN_POLYFILL_BUG&&!CORRECT_IS_REGEXP_LOGIC},{startsWith:function(e){var t=toString$4(requireObjectCoercible$1(this));notARegExp(e);var r=toLength$1(min$1(arguments.length>1?arguments[1]:void 0,t.length)),n=toString$4(e);return nativeStartsWith?nativeStartsWith(t,n,r):stringSlice$3(t,r,r+n.length)===n}});var getRandomValues,VideoSourceType=function(e){return e[e.VIDEO_SOURCE_TYPE_EXTERNAL=0]="VIDEO_SOURCE_TYPE_EXTERNAL",e[e.VIDEO_SOURCE_TYPE_INTERNAL=1]="VIDEO_SOURCE_TYPE_INTERNAL",e}(VideoSourceType||{}),AudioSourceType=function(e){return e[e.AUDIO_SOURCE_TYPE_EXTERNAL=0]="AUDIO_SOURCE_TYPE_EXTERNAL",e[e.AUDIO_SOURCE_TYPE_INTERNAL=1]="AUDIO_SOURCE_TYPE_INTERNAL",e}(AudioSourceType||{}),UserOfflineReason=function(e){return e[e.QUIT=0]="QUIT",e[e.DROPPED=1]="DROPPED",e[e.SWITCH_TO_INVISIBLE=2]="SWITCH_TO_INVISIBLE",e[e.KICKED_BY_ADMIN=3]="KICKED_BY_ADMIN",e}(UserOfflineReason||{}),ChannelProfile=function(e){return e[e.CHANNEL_PROFILE_COMMUNICATION=0]="CHANNEL_PROFILE_COMMUNICATION",e[e.CHANNEL_PROFILE_LIVE_BROADCASTING=1]="CHANNEL_PROFILE_LIVE_BROADCASTING",e}(ChannelProfile||{}),SubscribeMode=function(e){return e[e.AUTO_SUBSCRIBE_MODE=0]="AUTO_SUBSCRIBE_MODE",e[e.MANUAL_SUBSCRIBE_MODE=1]="MANUAL_SUBSCRIBE_MODE",e}(SubscribeMode||{}),SubscribeState=function(e){return e[e.SUBSCRIBE_SUCC=0]="SUBSCRIBE_SUCC",e[e.SUBSCRIBE_FAIL=1]="SUBSCRIBE_FAIL",e}(SubscribeState||{}),PublishState=function(e){return e[e.PUBLISH_SUCC=0]="PUBLISH_SUCC",e[e.PUBLISH_FAIL=1]="PUBLISH_FAIL",e}(PublishState||{}),MirrorMode=function(e){return e[e.MIRROR_MODE_OFF=0]="MIRROR_MODE_OFF",e[e.MIRROR_MODE_ON=1]="MIRROR_MODE_ON",e}(MirrorMode||{}),VideoRenderMode=function(e){return e[e.RENDER_MODE_HIDDEN=0]="RENDER_MODE_HIDDEN",e[e.RENDER_MODE_FIT=1]="RENDER_MODE_FIT",e}(VideoRenderMode||{}),StreamIndex=function(e){return e[e.STREAM_INDEX_MAIN=0]="STREAM_INDEX_MAIN",e[e.STREAM_INDEX_SCREEN=1]="STREAM_INDEX_SCREEN",e}(StreamIndex||{}),MediaType=function(e){return e[e.AUDIO=1]="AUDIO",e[e.VIDEO=2]="VIDEO",e[e.AUDIO_AND_VIDEO=3]="AUDIO_AND_VIDEO",e}(MediaType||{}),StreamRemoveReason=function(e){return e[e.STREAM_REMOVE_REASON_UNPUBLISH=0]="STREAM_REMOVE_REASON_UNPUBLISH",e[e.STREAM_REMOVE_REASON_PUBLISH_FAILED=1]="STREAM_REMOVE_REASON_PUBLISH_FAILED",e[e.STREAM_REMOVE_REASON_KEEP_LIVE_FAILED=2]="STREAM_REMOVE_REASON_KEEP_LIVE_FAILED",e[e.STREAM_REMOVE_REASON_CLIENT_DISCONNECTED=3]="STREAM_REMOVE_REASON_CLIENT_DISCONNECTED",e[e.STREAM_REMOVE_REASON_REPUBLISH=4]="STREAM_REMOVE_REASON_REPUBLISH",e[e.STREAM_REMOVE_REASON_OTHER=5]="STREAM_REMOVE_REASON_OTHER",e}(StreamRemoveReason||{}),ConnectionState=function(e){return e[e.CONNECTION_START=0]="CONNECTION_START",e[e.CONNECTION_STATE_DISCONNECTED=1]="CONNECTION_STATE_DISCONNECTED",e[e.CONNECTION_STATE_CONNECTING=2]="CONNECTION_STATE_CONNECTING",e[e.CONNECTION_STATE_CONNECTED=3]="CONNECTION_STATE_CONNECTED",e[e.CONNECTION_STATE_RECONNECTING=4]="CONNECTION_STATE_RECONNECTING",e[e.CONNECTION_STATE_RECONNECTED=5]="CONNECTION_STATE_RECONNECTED",e[e.CONNECTION_STATE_LOST=6]="CONNECTION_STATE_LOST",e}(ConnectionState||{}),MirrorType=function(e){return e[e.MIRROR_TYPE_NONE=0]="MIRROR_TYPE_NONE",e[e.MIRROR_TYPE_RENDER=1]="MIRROR_TYPE_RENDER",e}(MirrorType||{}),LogChannel=function(e){return e[e.domestic=0]="domestic",e[e.overseas=1]="overseas",e}(LogChannel||{}),USER_ONLINE_STATUS=function(e){return e[e.OFFLINE=0]="OFFLINE",e[e.ONLINE=1]="ONLINE",e[e.UNREACHABLE=2]="UNREACHABLE",e}(USER_ONLINE_STATUS||{}),PublicStreamType=function(e){return e[e.AUDIO_AND_VIDEO=0]="AUDIO_AND_VIDEO",e[e.AUDIO_ONLY=1]="AUDIO_ONLY",e[e.VIDEO_ONLY=2]="VIDEO_ONLY",e}(PublicStreamType||{}),PublicInterpolationMode=function(e){return e[e.PREV_FRAME=0]="PREV_FRAME",e[e.OTHER_FRAME=1]="OTHER_FRAME",e}(PublicInterpolationMode||{}),SubscribeFallbackOption=function(e){return e[e.DISABLE=0]="DISABLE",e[e.VIDEO_STREAM_LOW=1]="VIDEO_STREAM_LOW",e[e.AUDIO_ONLY=2]="AUDIO_ONLY",e}(SubscribeFallbackOption||{}),RemoteUserPriority=function(e){return e[e.LOW=0]="LOW",e[e.MEDIUM=100]="MEDIUM",e[e.HIGH=200]="HIGH",e}(RemoteUserPriority||{}),NetworkQuality=function(e){return e[e.UNKNOWN=0]="UNKNOWN",e[e.EXCELLENT=1]="EXCELLENT",e[e.GOOD=2]="GOOD",e[e.POOR=3]="POOR",e[e.BAD=4]="BAD",e[e.VBAD=5]="VBAD",e}(NetworkQuality||{}),FallbackOrRecoverReason=function(e){return e[e.Unknown=-1]="Unknown",e[e.SubscribeFallbackByBandwidth=0]="SubscribeFallbackByBandwidth",e[e.SubscribeRecoverByBandwidth=2]="SubscribeRecoverByBandwidth",e}(FallbackOrRecoverReason||{}),RoomProfileType=function(e){return e[e.communication=0]="communication",e[e.chat=5]="chat",e[e.chatRoom=6]="chatRoom",e[e.coHost=9]="coHost",e[e.meeting=16]="meeting",e[e.classRoom=18]="classRoom",e}(RoomProfileType||{}),AudioProfileType=function(e){return e[e.default=0]="default",e[e.fluent=1]="fluent",e[e.standard=2]="standard",e[e.hd=3]="hd",e[e.standardStereo=4]="standardStereo",e[e.hdMono=5]="hdMono",e}(AudioProfileType||{}),RTCAutoPlayPolicy=function(e){return e[e.AUTO_PLAY=0]="AUTO_PLAY",e[e.VIDEO_ONLY=1]="VIDEO_ONLY",e[e.PLAY_MANUALLY=2]="PLAY_MANUALLY",e}(RTCAutoPlayPolicy||{}),rnds8=new Uint8Array(16);function rng(){if(!getRandomValues&&!(getRandomValues="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto)))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return getRandomValues(rnds8)}var REGEX=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;function validate(e){return"string"==typeof e&®EX.test(e)}for(var byteToHex=[],i=0;i<256;++i)byteToHex.push((i+256).toString(16).substr(1));function stringify(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=(byteToHex[e[t+0]]+byteToHex[e[t+1]]+byteToHex[e[t+2]]+byteToHex[e[t+3]]+"-"+byteToHex[e[t+4]]+byteToHex[e[t+5]]+"-"+byteToHex[e[t+6]]+byteToHex[e[t+7]]+"-"+byteToHex[e[t+8]]+byteToHex[e[t+9]]+"-"+byteToHex[e[t+10]]+byteToHex[e[t+11]]+byteToHex[e[t+12]]+byteToHex[e[t+13]]+byteToHex[e[t+14]]+byteToHex[e[t+15]]).toLowerCase();if(!validate(r))throw TypeError("Stringified UUID is invalid");return r}function v4(e,t,r){var n=(e=e||{}).random||(e.rng||rng)();if(n[6]=15&n[6]|64,n[8]=63&n[8]|128,t){r=r||0;for(var i=0;i<16;++i)t[r+i]=n[i];return t}return stringify(n)}var textDecoder=new TextDecoder,textEncoder=new TextEncoder,genUuid=function(){return v4()},getServerNow=function(){return Date.now()};function concatenate(e){for(var t=0,r=arguments.length,n=new Array(r>1?r-1:0),i=1;i<r;i++)n[i-1]=arguments[i];for(var o=0,a=n;o<a.length;o++){var s=a[o];t+=s.length}for(var c=new e(t),u=0,l=0,d=n;l<d.length;l++){var p=d[l];c.set(p,u),u+=p.length}return c}var isSSR=function(){return"undefined"==typeof window},Utils=function(){function e(){_classCallCheck(this,e)}var t,r;return _createClass(e,null,[{key:"token2auth",value:function(t,r,n,i){return i?"Bearer ".concat(i):"Basic ".concat(e.createUnsafeToken(t,r,n))}},{key:"createUnsafeToken",value:function(e,t,r){return window.btoa([e,t,r].filter((function(e){return null!==e})).join(":"))}},{key:"merge",value:function(){for(var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=0,i=Object.entries(t);n<i.length;n++){var o=_slicedToArray(i[n],2),a=o[0],s=o[1];null!==s&&"object"===_typeof(s)?e.merge(t[a],r[a]):void 0!==r[a]&&(t[a]=r[a])}}},{key:"ab2str",value:function(e){return textDecoder.decode(e)}},{key:"ab2obj",value:function(t){try{var r=e.ab2str(t);return JSON.parse(r)}catch(e){return{}}}},{key:"str2ab",value:function(e){return textEncoder.encode(e).buffer}},{key:"ab2b64str",value:(r=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){var r;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,new Promise((function(e){var r=new FileReader;r.onload=function(){return e(r.result)},r.readAsDataURL(new Blob([t]))}));case 2:return r=e.sent,e.abrupt("return",r.split(",",2)[1]);case 4:case"end":return e.stop()}}),e)}))),function(e){return r.apply(this,arguments)})},{key:"b64str2ab",value:(t=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",fetch("data:application/octet;base64,"+t).then((function(e){return e.arrayBuffer()})));case 1:case"end":return e.stop()}}),e)}))),function(e){return t.apply(this,arguments)})}]),e}();function wait(e){return new Promise((function(t){window.setTimeout(t,e)}))}function getBrowser(){var e="none";return isSSR()||(null!==window.navigator.userAgent.match("Firefox")?e="mozilla":null!==window.navigator.userAgent.match("Chrome")?(e="chrome-stable",null!==window.navigator.userAgent.match("Electron")&&(e="electron")):(null!==window.navigator.userAgent.match("Safari")||null!==window.navigator.userAgent.match("AppleWebKit"))&&(e="safari")),e}var isFirefox="mozilla"===getBrowser(),isSafari="safari"===getBrowser(),isMobile=!isSSR()&&navigator.userAgent.toLowerCase().includes("mobile");function createRandomId(){for(var e=(+"".concat(Math.random()).slice(-7).padEnd(7,"0")).toString(2).padEnd(28,"1").split(""),t=[];e.length;)t.push(e.splice(0,7));return t.map((function(e,r){var n=r===t.length-1?"0":"1";return Number.parseInt(n+e.join(""),2)}))}var genEventSessionId=function(){return Math.floor(65535*Math.random())};function isByteId(e){return 128==(128&e)}function isRttMessage(e){return"string"==typeof e&&e.indexOf("__web__rtc__rtt__")>-1}var maxBinaryLength=10;function reportParamsCheck(e){return e.map((function e(t){if(t instanceof HTMLElement)return t.toString();if(t instanceof ArrayBuffer||ArrayBuffer.isView(t)){var r=ArrayBuffer.isView(t)?t.buffer:t,n=r.byteLength,i=[];if(n>maxBinaryLength){var o=new DataView(r),a=Array.from({length:maxBinaryLength/2}).map((function(e,t){return o.getUint8(t)})),s=Array.from({length:maxBinaryLength/2}).map((function(e,t){return n-1-t})).reverse().map((function(e){return o.getUint8(e)}));i=[].concat(_toConsumableArray(a),["..."],_toConsumableArray(s))}else i=Array.from(new Uint8Array(r));return"".concat(t.constructor.name,"(").concat(n,") [").concat(i.join(", "),"]")}if(t instanceof ImageData)return"ImageData";if(Array.isArray(t))return t.map(e);if("[object Object]"===Object.prototype.toString.call(t)){var c={};for(var u in t)c[u]=e(t[u]);return c}return t}))}var createDefaultSdp=function(){var e=_asyncToGenerator(_regeneratorRuntime().mark((function e(){var t,r,n,i=arguments;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=i.length>0&&void 0!==i[0]&&i[0],e.prev=1,(r=new RTCPeerConnection({iceServers:[],iceTransportPolicy:"all",bundlePolicy:"max-bundle",rtcpMuxPolicy:"require",sdpSemantics:"unified-plan"})).createDataChannel("default"),r.addTransceiver("audio",{direction:"recvonly"}),r.addTransceiver("video",{direction:"recvonly"}),t&&(r.addTransceiver("audio",{direction:"sendonly"}),r.addTransceiver("video",{direction:"sendonly"})),e.next=9,r.createOffer();case 9:return n=e.sent,r.close(),e.abrupt("return",n.sdp);case 14:e.prev=14,e.t0=e.catch(1);case 16:case"end":return e.stop()}}),e,null,[[1,14]])})));return function(){return e.apply(this,arguments)}}(),promiseAny=function(e){return new Promise((function(t,r){var n=(e=Array.isArray(e)?e:[]).length,i=[];0===n?r([]):e.forEach((function(e){e.then((function(e){t(e)}),(function(e){n--,i.push(e),0===n&&r(i)}))}))}))};function getNonlinearVolume(e){return+Math.max(-127,10*Math.log10(Math.pow(e/255,2))).toFixed(2)}function audioInMediaType(e){return(e&MediaType.AUDIO)===MediaType.AUDIO}function videoInMediaType(e){return(e&MediaType.VIDEO)===MediaType.VIDEO}function getPublicStats(e){var t={};return Object.keys(e).forEach((function(r){"object"===_typeof(e[r])?t[r]=getPublicStats(e[r]):r.startsWith("_")||(t[r]=e[r])})),t}function splitPublicStreamSei(e){var t=new DataView(e.buffer);if(t.byteLength<=4||65535!==t.getUint16(0))return{seiCount:1,seis:[e]};for(var r={seiCount:0,seis:[]},n=!1,i=2;i<t.byteLength;){var o=t.getUint16(i);if(i+=2,t.byteLength-i<o){n=!0;break}var a=new Uint8Array(e.buffer,i,o);if(i+=o,t.byteLength-i>0&&t.byteLength-i<=2){n=!0;break}r.seiCount++,r.seis.push(a)}return n&&(r.seiCount=1,r.seis=[e]),r}var EngineEventsTypes=function(e){return e.onTrackEnded="onTrackEnded",e.onPlayerEvent="onPlayerEvent",e.onAutoplayFailed="onAutoplayFailed",e.onUserJoined="onUserJoined",e.onUserLeave="onUserLeave",e.onConnectionStateChanged="onConnectionStateChanged",e.onUserPublishStream="onUserPublishStream",e.onUserUnpublishStream="onUserUnpublishStream",e.onUserPublishScreen="onUserPublishScreen",e.onUserUnpublishScreen="onUserUnpublishScreen",e.onRoomMessageReceived="onRoomMessageReceived",e.onRoomBinaryMessageReceived="onRoomBinaryMessageReceived",e.onUserMessageReceived="onUserMessageReceived",e.onUserBinaryMessageReceived="onUserBinaryMessageReceived",e.onVideoFirstFrameRendered="onVideoFirstFrameRendered",e.onVideoFirstFrameDecoded="onVideoFirstFrameDecoded",e.onAudioFirstFrameDecoded="onAudioFirstFrameDecoded",e.onFirstPublicStreamVideoFrameRendered="onFirstPublicStreamVideoFrameRendered",e.onFirstPublicStreamVideoFrameDecoded="onFirstPublicStreamVideoFrameDecoded",e.onFirstPublicStreamAudioFrameDecoded="onFirstPublicStreamAudioFrameDecoded",e.onVideoDeviceStateChanged="onVideoDeviceStateChanged",e.onAudioDeviceStateChanged="onAudioDeviceStateChanged",e.onRemoteStreamStats="onRemoteStreamStats",e.onPublicStreamStats="onPublicStreamStats",e.onLocalStreamStats="onLocalStreamStats",e.onAudioVolumeIndication="onAudioVolumeIndication",e.onLocalAudioPropertiesReport="onLocalAudioPropertiesReport",e.onRemoteAudioPropertiesReport="onRemoteAudioPropertiesReport",e.onActiveSpeaker="onActiveSpeaker",e.onAudioPlaybackDeviceChanged="onAudioPlaybackDeviceChanged",e.onUserStartVideoCapture="onUserStartVideoCapture",e.onUserStopVideoCapture="onUserStopVideoCapture",e.onUserStartAudioCapture="onUserStartAudioCapture",e.onUserStopAudioCapture="onUserStopAudioCapture",e.onAutoPublishResult="onAutoPublishResult",e.onAutoSubscribeResult="onAutoSubscribeResult",e.onLiveTranscodingResult="onLiveTranscodingResult",e.onStreamMixingEvent="onStreamMixingEvent",e.onAudioPlaybackDeviceTestVolume="onAudioPlaybackDeviceTestVolume",e.onSEIMessageReceived="onSEIMessageReceived",e.onError="onError",e.onAudioMixingStateChanged="onAudioMixingStateChanged",e.onUserMessageReceivedOutsideRoom="onUserMessageReceivedOutsideRoom",e.onUserBinaryMessageReceivedOutsideRoom="onUserBinaryMessageReceivedOutsideRoom",e.onTokenWillExpire="onTokenWillExpire",e.onCloudProxyConnected="onCloudProxyConnected",e.onPushPublicStreamResult="onPushPublicStreamResult",e.onPublicStreamSEIMessageReceived="onPublicStreamSEIMessageReceived",e.onNetworkQuality="onNetworkQuality",e.onSimulcastSubscribeFallback="onSimulcastSubscribeFallback",e.onRemoteVideoSizeChanged="onRemoteVideoSizeChanged",e.onVideoStreamBanned="onVideoStreamBanned",e.onAudioStreamBanned="onAudioStreamBanned",e.onLocalVideoSizeChanged="onLocalVideoSizeChanged",e.onServerParamsSetResult="onServerParamsSetResult",e}(EngineEventsTypes||{});function checkBoolean(e,t){if("boolean"!=typeof e)throw new SDKError(ErrorCode.INVALID_PARAMS,"Invalid ".concat(t,": The value should be boolean type."))}function checkNumber(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:Number.POSITIVE_INFINITY;if(e<r||e>n||"number"!=typeof e){var i=new SDKError(ErrorCode.INVALID_PARAMS,"Invalid ".concat(t,": the value range is [").concat(r,", ").concat(n,"]. integer only"));throw i}}function checkString(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:Number.POSITIVE_INFINITY;if(null==e)throw new SDKError(ErrorCode.INVALID_PARAMS,"".concat(t," cannot be empty"));if(!isValidString(e,r,n))throw new SDKError(ErrorCode.INVALID_PARAMS,"Invalid ".concat(t,": The value should be string type. Length of the string: [").concat(r,",").concat(n,"]"))}function checkEnum(e,t,r){if(!r.includes(e))throw new SDKError(ErrorCode.INVALID_PARAMS,"Invalid ".concat(t,": The value can only be set as ").concat(JSON.stringify(r)))}function checkEmpty(e,t){if(isEmpty(e))throw new SDKError(ErrorCode.INVALID_PARAMS,"Invalid ".concat(t,", should not be empty"))}function checkArrayBuffer(e,t){if(!(e instanceof ArrayBuffer))throw new SDKError(ErrorCode.INVALID_PARAMS,"Invalid ".concat(t,", should be ArrayBuffer"))}function checkSupportedConstraints(e){try{for(var t=navigator.mediaDevices.getSupportedConstraints(),r=0,n=Object.keys(e);r<n.length;r++){var i=n[r];t[i]||delete e[i]}}catch(e){}}function isValidString(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:Number.POSITIVE_INFINITY;return"string"==typeof e&&e.length<=r&&e.length>=t}function isEmpty(e){return null==e}function checkRoomId(e){if("string"!=typeof e||!/^[a-zA-Z0-9@._\-]{1,128}$/.test(e))throw new SDKError(ErrorCode.INVALID_PARAMS,"The RoomId must be within 128 bytes. The supported characters: a-z,A-Z,0-9,@,-,_,.")}function checkUserId(e){if("string"!=typeof e||!/^[a-zA-Z0-9@._\-]{1,128}$/.test(e))throw new SDKError(ErrorCode.INVALID_PARAMS,"The userId must be within 128 bytes. The supported characters: a-z,A-Z,0-9,@,-,_,.")}function checkPublicStreamId(e){if("string"!=typeof e||!/^[a-zA-Z0-9@._\-]{1,128}$/.test(e))throw new SDKError(ErrorCode.INVALID_PARAMS,"The publicStreamId must be within 128 bytes. The supported characters: a-z,A-Z,0-9,@,-,_,.")}function illegalBusinessId(e){return"string"!=typeof e}function checkUserInfo(e){checkEmpty(e,"userInfo"),checkUserId(e.userId),isEmpty(e.extraInfo)||checkString(e.extraInfo,"userInfo.extraInfo",1,200)}function checkRoomConfig(e){checkEmpty(e,"roomConfig"),checkBoolean(e.isAutoPublish,"roomConfig.isAutoPublish"),checkBoolean(e.isAutoSubscribeAudio,"roomConfig.isAutoSubscribeAudio"),checkBoolean(e.isAutoSubscribeVideo,"roomConfig.isAutoSubscribeVideo")}function checkVideoPlayerOption(e){checkEmpty(e,"videoPlayerOption")}function checkBufferSize(e){var t,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:64;if(!e||0===(null==e?void 0:e.byteLength))throw new SDKError(ErrorCode.INVALID_PARAMS,"The message cannot be empty");if((null===(t=e instanceof ArrayBuffer?e:Utils.str2ab(JSON.stringify(e)))||void 0===t?void 0:t.byteLength)>1e3*r)throw new SDKError(ErrorCode.INVALID_PARAMS,"The message length must be less than ".concat(r,"K"))}function isReportCallback(e){return![EngineEventsTypes.onRemoteStreamStats,EngineEventsTypes.onLocalStreamStats,EngineEventsTypes.onAudioVolumeIndication,EngineEventsTypes.onLocalAudioPropertiesReport,EngineEventsTypes.onRemoteAudioPropertiesReport].includes(e)}function checkRemoteConfig(e){if("number"!=typeof(null==e?void 0:e.width)||"number"!=typeof(null==e?void 0:e.height))throw new SDKError(ErrorCode.INVALID_PARAMS,"remoteVideoConfig must contain width, height, frameRate")}var wellKnownSymbolWrapped={},wellKnownSymbol$4=wellKnownSymbol$u;wellKnownSymbolWrapped.f=wellKnownSymbol$4;var global$7=global$K,path$1=global$7,path=path$1,hasOwn$7=hasOwnProperty_1,wrappedWellKnownSymbolModule$1=wellKnownSymbolWrapped,defineProperty$2=objectDefineProperty.f,wellKnownSymbolDefine=function(e){var t=path.Symbol||(path.Symbol={});hasOwn$7(t,e)||defineProperty$2(t,e,{value:wrappedWellKnownSymbolModule$1.f(e)})},call$5=functionCall,getBuiltIn$1=getBuiltIn$g,wellKnownSymbol$3=wellKnownSymbol$u,defineBuiltIn$3=defineBuiltIn$j,symbolDefineToPrimitive=function(){var e=getBuiltIn$1("Symbol"),t=e&&e.prototype,r=t&&t.valueOf,n=wellKnownSymbol$3("toPrimitive");t&&!t[n]&&defineBuiltIn$3(t,n,(function(e){return call$5(r,this)}),{arity:1})},$$9=_export,global$6=global$K,call$4=functionCall,uncurryThis$6=functionUncurryThis,DESCRIPTORS$3=descriptors,NATIVE_SYMBOL$2=symbolConstructorDetection,fails$5=fails$U,hasOwn$6=hasOwnProperty_1,isPrototypeOf=objectIsPrototypeOf,anObject$5=anObject$q,toIndexedObject=toIndexedObject$c,toPropertyKey=toPropertyKey$5,$toString$2=toString$m,createPropertyDescriptor$2=createPropertyDescriptor$b,nativeObjectCreate=objectCreate,objectKeys=objectKeys$4,getOwnPropertyNamesModule=objectGetOwnPropertyNames,getOwnPropertyNamesExternal=objectGetOwnPropertyNamesExternal,getOwnPropertySymbolsModule$1=objectGetOwnPropertySymbols,getOwnPropertyDescriptorModule$2=objectGetOwnPropertyDescriptor,definePropertyModule$1=objectDefineProperty,definePropertiesModule=objectDefineProperties,propertyIsEnumerableModule=objectPropertyIsEnumerable,defineBuiltIn$2=defineBuiltIn$j,shared$2=shared$7.exports,sharedKey=sharedKey$4,hiddenKeys=hiddenKeys$6,uid=uid$5,wellKnownSymbol$2=wellKnownSymbol$u,wrappedWellKnownSymbolModule=wellKnownSymbolWrapped,defineWellKnownSymbol=wellKnownSymbolDefine,defineSymbolToPrimitive=symbolDefineToPrimitive,setToStringTag$3=setToStringTag$a,InternalStateModule$3=internalState,$forEach=arrayIteration.forEach,HIDDEN=sharedKey("hidden"),SYMBOL="Symbol",PROTOTYPE="prototype",setInternalState$3=InternalStateModule$3.set,getInternalState=InternalStateModule$3.getterFor(SYMBOL),ObjectPrototype=Object[PROTOTYPE],$Symbol=global$6.Symbol,SymbolPrototype=$Symbol&&$Symbol[PROTOTYPE],TypeError$3=global$6.TypeError,QObject=global$6.QObject,nativeGetOwnPropertyDescriptor=getOwnPropertyDescriptorModule$2.f,nativeDefineProperty=definePropertyModule$1.f,nativeGetOwnPropertyNames=getOwnPropertyNamesExternal.f,nativePropertyIsEnumerable=propertyIsEnumerableModule.f,push$4=uncurryThis$6([].push),AllSymbols=shared$2("symbols"),ObjectPrototypeSymbols=shared$2("op-symbols"),WellKnownSymbolsStore=shared$2("wks"),USE_SETTER=!QObject||!QObject[PROTOTYPE]||!QObject[PROTOTYPE].findChild,setSymbolDescriptor=DESCRIPTORS$3&&fails$5((function(){return 7!=nativeObjectCreate(nativeDefineProperty({},"a",{get:function(){return nativeDefineProperty(this,"a",{value:7}).a}})).a}))?function(e,t,r){var n=nativeGetOwnPropertyDescriptor(ObjectPrototype,t);n&&delete ObjectPrototype[t],nativeDefineProperty(e,t,r),n&&e!==ObjectPrototype&&nativeDefineProperty(ObjectPrototype,t,n)}:nativeDefineProperty,wrap=function(e,t){var r=AllSymbols[e]=nativeObjectCreate(SymbolPrototype);return setInternalState$3(r,{type:SYMBOL,tag:e,description:t}),DESCRIPTORS$3||(r.description=t),r},$defineProperty=function(e,t,r){e===ObjectPrototype&&$defineProperty(ObjectPrototypeSymbols,t,r),anObject$5(e);var n=toPropertyKey(t);return anObject$5(r),hasOwn$6(AllSymbols,n)?(r.enumerable?(hasOwn$6(e,HIDDEN)&&e[HIDDEN][n]&&(e[HIDDEN][n]=!1),r=nativeObjectCreate(r,{enumerable:createPropertyDescriptor$2(0,!1)})):(hasOwn$6(e,HIDDEN)||nativeDefineProperty(e,HIDDEN,createPropertyDescriptor$2(1,{})),e[HIDDEN][n]=!0),setSymbolDescriptor(e,n,r)):nativeDefineProperty(e,n,r)},$defineProperties=function(e,t){anObject$5(e);var r=toIndexedObject(t),n=objectKeys(r).concat($getOwnPropertySymbols(r));return $forEach(n,(function(t){DESCRIPTORS$3&&!call$4($propertyIsEnumerable,r,t)||$defineProperty(e,t,r[t])})),e},$create=function(e,t){return void 0===t?nativeObjectCreate(e):$defineProperties(nativeObjectCreate(e),t)},$propertyIsEnumerable=function(e){var t=toPropertyKey(e),r=call$4(nativePropertyIsEnumerable,this,t);return!(this===ObjectPrototype&&hasOwn$6(AllSymbols,t)&&!hasOwn$6(ObjectPrototypeSymbols,t))&&(!(r||!hasOwn$6(this,t)||!hasOwn$6(AllSymbols,t)||hasOwn$6(this,HIDDEN)&&this[HIDDEN][t])||r)},$getOwnPropertyDescriptor=function(e,t){var r=toIndexedObject(e),n=toPropertyKey(t);if(r!==ObjectPrototype||!hasOwn$6(AllSymbols,n)||hasOwn$6(ObjectPrototypeSymbols,n)){var i=nativeGetOwnPropertyDescriptor(r,n);return!i||!hasOwn$6(AllSymbols,n)||hasOwn$6(r,HIDDEN)&&r[HIDDEN][n]||(i.enumerable=!0),i}},$getOwnPropertyNames=function(e){var t=nativeGetOwnPropertyNames(toIndexedObject(e)),r=[];return $forEach(t,(function(e){hasOwn$6(AllSymbols,e)||hasOwn$6(hiddenKeys,e)||push$4(r,e)})),r},$getOwnPropertySymbols=function(e){var t=e===ObjectPrototype,r=nativeGetOwnPropertyNames(t?ObjectPrototypeSymbols:toIndexedObject(e)),n=[];return $forEach(r,(function(e){!hasOwn$6(AllSymbols,e)||t&&!hasOwn$6(ObjectPrototype,e)||push$4(n,AllSymbols[e])})),n};NATIVE_SYMBOL$2||(defineBuiltIn$2(SymbolPrototype=($Symbol=function(){if(isPrototypeOf(SymbolPrototype,this))throw TypeError$3("Symbol is not a constructor");var e=arguments.length&&void 0!==arguments[0]?$toString$2(arguments[0]):void 0,t=uid(e),r=function(e){this===ObjectPrototype&&call$4(r,ObjectPrototypeSymbols,e),hasOwn$6(this,HIDDEN)&&hasOwn$6(this[HIDDEN],t)&&(this[HIDDEN][t]=!1),setSymbolDescriptor(this,t,createPropertyDescriptor$2(1,e))};return DESCRIPTORS$3&&USE_SETTER&&setSymbolDescriptor(ObjectPrototype,t,{configurable:!0,set:r}),wrap(t,e)})[PROTOTYPE],"toString",(function(){return getInternalState(this).tag})),defineBuiltIn$2($Symbol,"withoutSetter",(function(e){return wrap(uid(e),e)})),propertyIsEnumerableModule.f=$propertyIsEnumerable,definePropertyModule$1.f=$defineProperty,definePropertiesModule.f=$defineProperties,getOwnPropertyDescriptorModule$2.f=$getOwnPropertyDescriptor,getOwnPropertyNamesModule.f=getOwnPropertyNamesExternal.f=$getOwnPropertyNames,getOwnPropertySymbolsModule$1.f=$getOwnPropertySymbols,wrappedWellKnownSymbolModule.f=function(e){return wrap(wellKnownSymbol$2(e),e)},DESCRIPTORS$3&&(nativeDefineProperty(SymbolPrototype,"description",{configurable:!0,get:function(){return getInternalState(this).description}}),defineBuiltIn$2(ObjectPrototype,"propertyIsEnumerable",$propertyIsEnumerable,{unsafe:!0}))),$$9({global:!0,constructor:!0,wrap:!0,forced:!NATIVE_SYMBOL$2,sham:!NATIVE_SYMBOL$2},{Symbol:$Symbol}),$forEach(objectKeys(WellKnownSymbolsStore),(function(e){defineWellKnownSymbol(e)})),$$9({target:SYMBOL,stat:!0,forced:!NATIVE_SYMBOL$2},{useSetter:function(){USE_SETTER=!0},useSimple:function(){USE_SETTER=!1}}),$$9({target:"Object",stat:!0,forced:!NATIVE_SYMBOL$2,sham:!DESCRIPTORS$3},{create:$create,defineProperty:$defineProperty,defineProperties:$defineProperties,getOwnPropertyDescriptor:$getOwnPropertyDescriptor}),$$9({target:"Object",stat:!0,forced:!NATIVE_SYMBOL$2},{getOwnPropertyNames:$getOwnPropertyNames}),defineSymbolToPrimitive(),setToStringTag$3($Symbol,SYMBOL),hiddenKeys[HIDDEN]=!0;var NATIVE_SYMBOL$1=symbolConstructorDetection,symbolRegistryDetection=NATIVE_SYMBOL$1&&!!Symbol.for&&!!Symbol.keyFor,$$8=_export,getBuiltIn=getBuiltIn$g,hasOwn$5=hasOwnProperty_1,toString$3=toString$m,shared$1=shared$7.exports,NATIVE_SYMBOL_REGISTRY$1=symbolRegistryDetection,StringToSymbolRegistry=shared$1("string-to-symbol-registry"),SymbolToStringRegistry$1=shared$1("symbol-to-string-registry");$$8({target:"Symbol",stat:!0,forced:!NATIVE_SYMBOL_REGISTRY$1},{for:function(e){var t=toString$3(e);if(hasOwn$5(StringToSymbolRegistry,t))return StringToSymbolRegistry[t];var r=getBuiltIn("Symbol")(t);return StringToSymbolRegistry[t]=r,SymbolToStringRegistry$1[r]=t,r}});var $$7=_export,hasOwn$4=hasOwnProperty_1,isSymbol=isSymbol$6,tryToString=tryToString$7,shared=shared$7.exports,NATIVE_SYMBOL_REGISTRY=symbolRegistryDetection,SymbolToStringRegistry=shared("symbol-to-string-registry");$$7({target:"Symbol",stat:!0,forced:!NATIVE_SYMBOL_REGISTRY},{keyFor:function(e){if(!isSymbol(e))throw TypeError(tryToString(e)+" is not a symbol");if(hasOwn$4(SymbolToStringRegistry,e))return SymbolToStringRegistry[e]}});var $$6=_export,NATIVE_SYMBOL=symbolConstructorDetection,fails$4=fails$U,getOwnPropertySymbolsModule=objectGetOwnPropertySymbols,toObject$1=toObject$i,FORCED$1=!NATIVE_SYMBOL||fails$4((function(){getOwnPropertySymbolsModule.f(1)}));$$6({target:"Object",stat:!0,forced:FORCED$1},{getOwnPropertySymbols:function(e){var t=getOwnPropertySymbolsModule.f;return t?t(toObject$1(e)):[]}});var eventemitter3={exports:{}};!function(e){var t=Object.prototype.hasOwnProperty,r="~";function n(){}function i(e,t,r){this.fn=e,this.context=t,this.once=r||!1}function o(e,t,n,o,a){if("function"!=typeof n)throw new TypeError("The listener must be a function");var s=new i(n,o||e,a),c=r?r+t:t;return e._events[c]?e._events[c].fn?e._events[c]=[e._events[c],s]:e._events[c].push(s):(e._events[c]=s,e._eventsCount++),e}function a(e,t){0==--e._eventsCount?e._events=new n:delete e._events[t]}function s(){this._events=new n,this._eventsCount=0}Object.create&&(n.prototype=Object.create(null),(new n).__proto__||(r=!1)),s.prototype.eventNames=function(){var e,n,i=[];if(0===this._eventsCount)return i;for(n in e=this._events)t.call(e,n)&&i.push(r?n.slice(1):n);return Object.getOwnPropertySymbols?i.concat(Object.getOwnPropertySymbols(e)):i},s.prototype.listeners=function(e){var t=r?r+e:e,n=this._events[t];if(!n)return[];if(n.fn)return[n.fn];for(var i=0,o=n.length,a=new Array(o);i<o;i++)a[i]=n[i].fn;return a},s.prototype.listenerCount=function(e){var t=r?r+e:e,n=this._events[t];return n?n.fn?1:n.length:0},s.prototype.emit=function(e,t,n,i,o,a){var s=r?r+e:e;if(!this._events[s])return!1;var c,u,l=this._events[s],d=arguments.length;if(l.fn){switch(l.once&&this.removeListener(e,l.fn,void 0,!0),d){case 1:return l.fn.call(l.context),!0;case 2:return l.fn.call(l.context,t),!0;case 3:return l.fn.call(l.context,t,n),!0;case 4:return l.fn.call(l.context,t,n,i),!0;case 5:return l.fn.call(l.context,t,n,i,o),!0;case 6:return l.fn.call(l.context,t,n,i,o,a),!0}for(u=1,c=new Array(d-1);u<d;u++)c[u-1]=arguments[u];l.fn.apply(l.context,c)}else{var p,_=l.length;for(u=0;u<_;u++)switch(l[u].once&&this.removeListener(e,l[u].fn,void 0,!0),d){case 1:l[u].fn.call(l[u].context);break;case 2:l[u].fn.call(l[u].context,t);break;case 3:l[u].fn.call(l[u].context,t,n);break;case 4:l[u].fn.call(l[u].context,t,n,i);break;default:if(!c)for(p=1,c=new Array(d-1);p<d;p++)c[p-1]=arguments[p];l[u].fn.apply(l[u].context,c)}}return!0},s.prototype.on=function(e,t,r){return o(this,e,t,r,!1)},s.prototype.once=function(e,t,r){return o(this,e,t,r,!0)},s.prototype.removeListener=function(e,t,n,i){var o=r?r+e:e;if(!this._events[o])return this;if(!t)return a(this,o),this;var s=this._events[o];if(s.fn)s.fn!==t||i&&!s.once||n&&s.context!==n||a(this,o);else{for(var c=0,u=[],l=s.length;c<l;c++)(s[c].fn!==t||i&&!s[c].once||n&&s[c].context!==n)&&u.push(s[c]);u.length?this._events[o]=1===u.length?u[0]:u:a(this,o)}return this},s.prototype.removeAllListeners=function(e){var t;return e?(t=r?r+e:e,this._events[t]&&a(this,t)):(this._events=new n,this._eventsCount=0),this},s.prototype.off=s.prototype.removeListener,s.prototype.addListener=s.prototype.on,s.prefixed=r,s.EventEmitter=s,e.exports=s}(eventemitter3);var EventEmitter=eventemitter3.exports,HEAD_TEXT="[VERTC]",colorMap=["#0050b3","#0050b3","#0050b3","#0050b3","#0050b3"],enable_log=!isSSR()&&window.location.search.includes("_rtc_debug_"),Logger=function(){function e(t,r,n){_classCallCheck(this,e),_defineProperty(this,"_indent",void 0),_defineProperty(this,"_module",void 0),_defineProperty(this,"_id",void 0),this._module=t,this._indent=r}return _createClass(e,[{key:"print",value:function(e){var t;if(enable_log){for(var r="",n=0;n<this._indent;n++)r+=" ";for(var i=arguments.length,o=new Array(i>1?i-1:0),a=1;a<i;a++)o[a-1]=arguments[a];(t=console).log.apply(t,["%c".concat(HEAD_TEXT).concat(r,"[").concat(this._module,".").concat(e,"] ").concat(o.shift()),"color:".concat(colorMap[this._indent],";")].concat(o))}}}]),e}(),logger$i=new Logger("VERTC",0),EnhancedEventEmitter=function(e){_inherits(n,eventemitter3.exports.EventEmitter);var t,r=_createSuper(n);function n(){return _classCallCheck(this,n),r.apply(this,arguments)}return _createClass(n,[{key:"safeEmit",value:function(e){var t=this.listenerCount(e);try{for(var r,i=arguments.length,o=new Array(i>1?i-1:0),a=1;a<i;a++)o[a-1]=arguments[a];return(r=_get(_getPrototypeOf(n.prototype),"emit",this)).call.apply(r,[this,e].concat(o))}catch(r){return logger$i.print("safaEmit","safeEmit() | event listener threw an error [event:%s]:%o",e,r),Boolean(t)}}},{key:"safeEmitAsPromise",value:(t=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){var r,n,i,o=this,a=arguments;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:for(r=a.length,n=new Array(r>1?r-1:0),i=1;i<r;i++)n[i-1]=a[i];return e.abrupt("return",new Promise((function(e,r){try{o.emit.apply(o,[t].concat(n,[e,r]))}catch(e){logger$i.print("safeEmitAsPromise","safeEmitAsPromise() | event listener threw an error [event:%s]:%o",t,e),r(e)}})));case 2:case"end":return e.stop()}}),e)}))),function(e){return t.apply(this,arguments)})}]),n}(),hasOwn$3=hasOwnProperty_1,isDataDescriptor$2=function(e){return void 0!==e&&(hasOwn$3(e,"value")||hasOwn$3(e,"writable"))},$$5=_export,call$3=functionCall,isObject$5=isObject$s,anObject$4=anObject$q,isDataDescriptor$1=isDataDescriptor$2,getOwnPropertyDescriptorModule$1=objectGetOwnPropertyDescriptor,getPrototypeOf$1=objectGetPrototypeOf;function get(e,t){var r,n,i=arguments.length<3?e:arguments[2];return anObject$4(e)===i?e[t]:(r=getOwnPropertyDescriptorModule$1.f(e,t))?isDataDescriptor$1(r)?r.value:void 0===r.get?void 0:call$3(r.get,i):isObject$5(n=getPrototypeOf$1(e))?get(n,t,i):void 0}$$5({target:"Reflect",stat:!0},{get:get});var $$4=_export,global$5=global$K,setToStringTag$2=setToStringTag$a;$$4({global:!0},{Reflect:{}}),setToStringTag$2(global$5.Reflect,"Reflect",!0);var $$3=_export,call$2=functionCall,anObject$3=anObject$q,isObject$4=isObject$s,isDataDescriptor=isDataDescriptor$2,fails$3=fails$U,definePropertyModule=objectDefineProperty,getOwnPropertyDescriptorModule=objectGetOwnPropertyDescriptor,getPrototypeOf=objectGetPrototypeOf,createPropertyDescriptor$1=createPropertyDescriptor$b;function set(e,t,r){var n,i,o,a=arguments.length<4?e:arguments[3],s=getOwnPropertyDescriptorModule.f(anObject$3(e),t);if(!s){if(isObject$4(i=getPrototypeOf(e)))return set(i,t,r,a);s=createPropertyDescriptor$1(0)}if(isDataDescriptor(s)){if(!1===s.writable||!isObject$4(a))return!1;if(n=getOwnPropertyDescriptorModule.f(a,t)){if(n.get||n.set||!1===n.writable)return!1;n.value=r,definePropertyModule.f(a,t,n)}else definePropertyModule.f(a,t,createPropertyDescriptor$1(0,r))}else{if(void 0===(o=s.set))return!1;call$2(o,a,r)}return!0}var MS_EDGE_BUG=fails$3((function(){var e=function(){},t=definePropertyModule.f(new e,"a",{configurable:!0});return!1!==Reflect.set(e.prototype,"a",1,t)}));$$3({target:"Reflect",stat:!0,forced:MS_EDGE_BUG},{set:set});var $$2=_export,toObject=toObject$i,lengthOfArrayLike=lengthOfArrayLike$m,setArrayLength=arraySetLength,deletePropertyOrThrow=deletePropertyOrThrow$4,doesNotExceedSafeInteger=doesNotExceedSafeInteger$4,INCORRECT_RESULT=1!==[].unshift(0),SILENT_ON_NON_WRITABLE_LENGTH=!function(){try{Object.defineProperty([],"length",{writable:!1}).unshift()}catch(e){return e instanceof TypeError}}();$$2({target:"Array",proto:!0,arity:1,forced:INCORRECT_RESULT||SILENT_ON_NON_WRITABLE_LENGTH},{unshift:function(e){var t=toObject(this),r=lengthOfArrayLike(t),n=arguments.length;if(n){doesNotExceedSafeInteger(r+n);for(var i=r;i--;){var o=i+n;i in t?t[o]=t[i]:deletePropertyOrThrow(t,o)}for(var a=0;a<n;a++)t[a]=arguments[a]}return setArrayLength(t,r+n)}});var createTypedArrayConstructor$1=typedArrayConstructor.exports;createTypedArrayConstructor$1("Uint16",(function(e){return function(t,r,n){return e(this,t,r,n)}}));var createTypedArrayConstructor=typedArrayConstructor.exports;createTypedArrayConstructor("Int32",(function(e){return function(t,r,n){return e(this,t,r,n)}}));var common={};!function(e){var t="undefined"!=typeof Uint8Array&&"undefined"!=typeof Uint16Array&&"undefined"!=typeof Int32Array;function r(e,t){return Object.prototype.hasOwnProperty.call(e,t)}e.assign=function(e){for(var t=Array.prototype.slice.call(arguments,1);t.length;){var n=t.shift();if(n){if("object"!==_typeof(n))throw new TypeError(n+"must be non-object");for(var i in n)r(n,i)&&(e[i]=n[i])}}return e},e.shrinkBuf=function(e,t){return e.length===t?e:e.subarray?e.subarray(0,t):(e.length=t,e)};var n={arraySet:function(e,t,r,n,i){if(t.subarray&&e.subarray)e.set(t.subarray(r,r+n),i);else for(var o=0;o<n;o++)e[i+o]=t[r+o]},flattenChunks:function(e){var t,r,n,i,o,a;for(n=0,t=0,r=e.length;t<r;t++)n+=e[t].length;for(a=new Uint8Array(n),i=0,t=0,r=e.length;t<r;t++)o=e[t],a.set(o,i),i+=o.length;return a}},i={arraySet:function(e,t,r,n,i){for(var o=0;o<n;o++)e[i+o]=t[r+o]},flattenChunks:function(e){return[].concat.apply([],e)}};e.setTyped=function(t){t?(e.Buf8=Uint8Array,e.Buf16=Uint16Array,e.Buf32=Int32Array,e.assign(e,n)):(e.Buf8=Array,e.Buf16=Array,e.Buf32=Array,e.assign(e,i))},e.setTyped(t)}(common);var deflate$4={},deflate$3={},trees$1={},utils$6=common,Z_FIXED$1=4,Z_BINARY=0,Z_TEXT=1,Z_UNKNOWN$1=2;function zero$1(e){for(var t=e.length;--t>=0;)e[t]=0}var STORED_BLOCK=0,STATIC_TREES=1,DYN_TREES=2,MIN_MATCH$1=3,MAX_MATCH$1=258,LENGTH_CODES$1=29,LITERALS$1=256,L_CODES$1=LITERALS$1+1+LENGTH_CODES$1,D_CODES$1=30,BL_CODES$1=19,HEAP_SIZE$1=2*L_CODES$1+1,MAX_BITS$1=15,Buf_size=16,MAX_BL_BITS=7,END_BLOCK=256,REP_3_6=16,REPZ_3_10=17,REPZ_11_138=18,extra_lbits=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0],extra_dbits=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13],extra_blbits=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],bl_order=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],DIST_CODE_LEN=512,static_ltree=new Array(2*(L_CODES$1+2));zero$1(static_ltree);var static_dtree=new Array(2*D_CODES$1);zero$1(static_dtree);var _dist_code=new Array(DIST_CODE_LEN);zero$1(_dist_code);var _length_code=new Array(MAX_MATCH$1-MIN_MATCH$1+1);zero$1(_length_code);var base_length=new Array(LENGTH_CODES$1);zero$1(base_length);var static_l_desc,static_d_desc,static_bl_desc,base_dist=new Array(D_CODES$1);function StaticTreeDesc(e,t,r,n,i){this.static_tree=e,this.extra_bits=t,this.extra_base=r,this.elems=n,this.max_length=i,this.has_stree=e&&e.length}function TreeDesc(e,t){this.dyn_tree=e,this.max_code=0,this.stat_desc=t}function d_code(e){return e<256?_dist_code[e]:_dist_code[256+(e>>>7)]}function put_short(e,t){e.pending_buf[e.pending++]=255&t,e.pending_buf[e.pending++]=t>>>8&255}function send_bits(e,t,r){e.bi_valid>Buf_size-r?(e.bi_buf|=t<<e.bi_valid&65535,put_short(e,e.bi_buf),e.bi_buf=t>>Buf_size-e.bi_valid,e.bi_valid+=r-Buf_size):(e.bi_buf|=t<<e.bi_valid&65535,e.bi_valid+=r)}function send_code(e,t,r){send_bits(e,r[2*t],r[2*t+1])}function bi_reverse(e,t){var r=0;do{r|=1&e,e>>>=1,r<<=1}while(--t>0);return r>>>1}function bi_flush(e){16===e.bi_valid?(put_short(e,e.bi_buf),e.bi_buf=0,e.bi_valid=0):e.bi_valid>=8&&(e.pending_buf[e.pending++]=255&e.bi_buf,e.bi_buf>>=8,e.bi_valid-=8)}function gen_bitlen(e,t){var r,n,i,o,a,s,c=t.dyn_tree,u=t.max_code,l=t.stat_desc.static_tree,d=t.stat_desc.has_stree,p=t.stat_desc.extra_bits,_=t.stat_desc.extra_base,f=t.stat_desc.max_length,h=0;for(o=0;o<=MAX_BITS$1;o++)e.bl_count[o]=0;for(c[2*e.heap[e.heap_max]+1]=0,r=e.heap_max+1;r<HEAP_SIZE$1;r++)(o=c[2*c[2*(n=e.heap[r])+1]+1]+1)>f&&(o=f,h++),c[2*n+1]=o,n>u||(e.bl_count[o]++,a=0,n>=_&&(a=p[n-_]),s=c[2*n],e.opt_len+=s*(o+a),d&&(e.static_len+=s*(l[2*n+1]+a)));if(0!==h){do{for(o=f-1;0===e.bl_count[o];)o--;e.bl_count[o]--,e.bl_count[o+1]+=2,e.bl_count[f]--,h-=2}while(h>0);for(o=f;0!==o;o--)for(n=e.bl_count[o];0!==n;)(i=e.heap[--r])>u||(c[2*i+1]!==o&&(e.opt_len+=(o-c[2*i+1])*c[2*i],c[2*i+1]=o),n--)}}function gen_codes(e,t,r){var n,i,o=new Array(MAX_BITS$1+1),a=0;for(n=1;n<=MAX_BITS$1;n++)o[n]=a=a+r[n-1]<<1;for(i=0;i<=t;i++){var s=e[2*i+1];0!==s&&(e[2*i]=bi_reverse(o[s]++,s))}}function tr_static_init(){var e,t,r,n,i,o=new Array(MAX_BITS$1+1);for(r=0,n=0;n<LENGTH_CODES$1-1;n++)for(base_length[n]=r,e=0;e<1<<extra_lbits[n];e++)_length_code[r++]=n;for(_length_code[r-1]=n,i=0,n=0;n<16;n++)for(base_dist[n]=i,e=0;e<1<<extra_dbits[n];e++)_dist_code[i++]=n;for(i>>=7;n<D_CODES$1;n++)for(base_dist[n]=i<<7,e=0;e<1<<extra_dbits[n]-7;e++)_dist_code[256+i++]=n;for(t=0;t<=MAX_BITS$1;t++)o[t]=0;for(e=0;e<=143;)static_ltree[2*e+1]=8,e++,o[8]++;for(;e<=255;)static_ltree[2*e+1]=9,e++,o[9]++;for(;e<=279;)static_ltree[2*e+1]=7,e++,o[7]++;for(;e<=287;)static_ltree[2*e+1]=8,e++,o[8]++;for(gen_codes(static_ltree,L_CODES$1+1,o),e=0;e<D_CODES$1;e++)static_dtree[2*e+1]=5,static_dtree[2*e]=bi_reverse(e,5);static_l_desc=new StaticTreeDesc(static_ltree,extra_lbits,LITERALS$1+1,L_CODES$1,MAX_BITS$1),static_d_desc=new StaticTreeDesc(static_dtree,extra_dbits,0,D_CODES$1,MAX_BITS$1),static_bl_desc=new StaticTreeDesc(new Array(0),extra_blbits,0,BL_CODES$1,MAX_BL_BITS)}function init_block(e){var t;for(t=0;t<L_CODES$1;t++)e.dyn_ltree[2*t]=0;for(t=0;t<D_CODES$1;t++)e.dyn_dtree[2*t]=0;for(t=0;t<BL_CODES$1;t++)e.bl_tree[2*t]=0;e.dyn_ltree[2*END_BLOCK]=1,e.opt_len=e.static_len=0,e.last_lit=e.matches=0}function bi_windup(e){e.bi_valid>8?put_short(e,e.bi_buf):e.bi_valid>0&&(e.pending_buf[e.pending++]=e.bi_buf),e.bi_buf=0,e.bi_valid=0}function copy_block(e,t,r,n){bi_windup(e),n&&(put_short(e,r),put_short(e,~r)),utils$6.arraySet(e.pending_buf,e.window,t,r,e.pending),e.pending+=r}function smaller(e,t,r,n){var i=2*t,o=2*r;return e[i]<e[o]||e[i]===e[o]&&n[t]<=n[r]}function pqdownheap(e,t,r){for(var n=e.heap[r],i=r<<1;i<=e.heap_len&&(i<e.heap_len&&smaller(t,e.heap[i+1],e.heap[i],e.depth)&&i++,!smaller(t,n,e.heap[i],e.depth));)e.heap[r]=e.heap[i],r=i,i<<=1;e.heap[r]=n}function compress_block(e,t,r){var n,i,o,a,s=0;if(0!==e.last_lit)do{n=e.pending_buf[e.d_buf+2*s]<<8|e.pending_buf[e.d_buf+2*s+1],i=e.pending_buf[e.l_buf+s],s++,0===n?send_code(e,i,t):(send_code(e,(o=_length_code[i])+LITERALS$1+1,t),0!==(a=extra_lbits[o])&&send_bits(e,i-=base_length[o],a),send_code(e,o=d_code(--n),r),0!==(a=extra_dbits[o])&&send_bits(e,n-=base_dist[o],a))}while(s<e.last_lit);send_code(e,END_BLOCK,t)}function build_tree(e,t){var r,n,i,o=t.dyn_tree,a=t.stat_desc.static_tree,s=t.stat_desc.has_stree,c=t.stat_desc.elems,u=-1;for(e.heap_len=0,e.heap_max=HEAP_SIZE$1,r=0;r<c;r++)0!==o[2*r]?(e.heap[++e.heap_len]=u=r,e.depth[r]=0):o[2*r+1]=0;for(;e.heap_len<2;)o[2*(i=e.heap[++e.heap_len]=u<2?++u:0)]=1,e.depth[i]=0,e.opt_len--,s&&(e.static_len-=a[2*i+1]);for(t.max_code=u,r=e.heap_len>>1;r>=1;r--)pqdownheap(e,o,r);i=c;do{r=e.heap[1],e.heap[1]=e.heap[e.heap_len--],pqdownheap(e,o,1),n=e.heap[1],e.heap[--e.heap_max]=r,e.heap[--e.heap_max]=n,o[2*i]=o[2*r]+o[2*n],e.depth[i]=(e.depth[r]>=e.depth[n]?e.depth[r]:e.depth[n])+1,o[2*r+1]=o[2*n+1]=i,e.heap[1]=i++,pqdownheap(e,o,1)}while(e.heap_len>=2);e.heap[--e.heap_max]=e.heap[1],gen_bitlen(e,t),gen_codes(o,u,e.bl_count)}function scan_tree(e,t,r){var n,i,o=-1,a=t[1],s=0,c=7,u=4;for(0===a&&(c=138,u=3),t[2*(r+1)+1]=65535,n=0;n<=r;n++)i=a,a=t[2*(n+1)+1],++s<c&&i===a||(s<u?e.bl_tree[2*i]+=s:0!==i?(i!==o&&e.bl_tree[2*i]++,e.bl_tree[2*REP_3_6]++):s<=10?e.bl_tree[2*REPZ_3_10]++:e.bl_tree[2*REPZ_11_138]++,s=0,o=i,0===a?(c=138,u=3):i===a?(c=6,u=3):(c=7,u=4))}function send_tree(e,t,r){var n,i,o=-1,a=t[1],s=0,c=7,u=4;for(0===a&&(c=138,u=3),n=0;n<=r;n++)if(i=a,a=t[2*(n+1)+1],!(++s<c&&i===a)){if(s<u)do{send_code(e,i,e.bl_tree)}while(0!=--s);else 0!==i?(i!==o&&(send_code(e,i,e.bl_tree),s--),send_code(e,REP_3_6,e.bl_tree),send_bits(e,s-3,2)):s<=10?(send_code(e,REPZ_3_10,e.bl_tree),send_bits(e,s-3,3)):(send_code(e,REPZ_11_138,e.bl_tree),send_bits(e,s-11,7));s=0,o=i,0===a?(c=138,u=3):i===a?(c=6,u=3):(c=7,u=4)}}function build_bl_tree(e){var t;for(scan_tree(e,e.dyn_ltree,e.l_desc.max_code),scan_tree(e,e.dyn_dtree,e.d_desc.max_code),build_tree(e,e.bl_desc),t=BL_CODES$1-1;t>=3&&0===e.bl_tree[2*bl_order[t]+1];t--);return e.opt_len+=3*(t+1)+5+5+4,t}function send_all_trees(e,t,r,n){var i;for(send_bits(e,t-257,5),send_bits(e,r-1,5),send_bits(e,n-4,4),i=0;i<n;i++)send_bits(e,e.bl_tree[2*bl_order[i]+1],3);send_tree(e,e.dyn_ltree,t-1),send_tree(e,e.dyn_dtree,r-1)}function detect_data_type(e){var t,r=4093624447;for(t=0;t<=31;t++,r>>>=1)if(1&r&&0!==e.dyn_ltree[2*t])return Z_BINARY;if(0!==e.dyn_ltree[18]||0!==e.dyn_ltree[20]||0!==e.dyn_ltree[26])return Z_TEXT;for(t=32;t<LITERALS$1;t++)if(0!==e.dyn_ltree[2*t])return Z_TEXT;return Z_BINARY}zero$1(base_dist);var static_init_done=!1;function _tr_init(e){static_init_done||(tr_static_init(),static_init_done=!0),e.l_desc=new TreeDesc(e.dyn_ltree,static_l_desc),e.d_desc=new TreeDesc(e.dyn_dtree,static_d_desc),e.bl_desc=new TreeDesc(e.bl_tree,static_bl_desc),e.bi_buf=0,e.bi_valid=0,init_block(e)}function _tr_stored_block(e,t,r,n){send_bits(e,(STORED_BLOCK<<1)+(n?1:0),3),copy_block(e,t,r,!0)}function _tr_align(e){send_bits(e,STATIC_TREES<<1,3),send_code(e,END_BLOCK,static_ltree),bi_flush(e)}function _tr_flush_block(e,t,r,n){var i,o,a=0;e.level>0?(e.strm.data_type===Z_UNKNOWN$1&&(e.strm.data_type=detect_data_type(e)),build_tree(e,e.l_desc),build_tree(e,e.d_desc),a=build_bl_tree(e),i=e.opt_len+3+7>>>3,(o=e.static_len+3+7>>>3)<=i&&(i=o)):i=o=r+5,r+4<=i&&-1!==t?_tr_stored_block(e,t,r,n):e.strategy===Z_FIXED$1||o===i?(send_bits(e,(STATIC_TREES<<1)+(n?1:0),3),compress_block(e,static_ltree,static_dtree)):(send_bits(e,(DYN_TREES<<1)+(n?1:0),3),send_all_trees(e,e.l_desc.max_code+1,e.d_desc.max_code+1,a+1),compress_block(e,e.dyn_ltree,e.dyn_dtree)),init_block(e),n&&bi_windup(e)}function _tr_tally(e,t,r){return e.pending_buf[e.d_buf+2*e.last_lit]=t>>>8&255,e.pending_buf[e.d_buf+2*e.last_lit+1]=255&t,e.pending_buf[e.l_buf+e.last_lit]=255&r,e.last_lit++,0===t?e.dyn_ltree[2*r]++:(e.matches++,t--,e.dyn_ltree[2*(_length_code[r]+LITERALS$1+1)]++,e.dyn_dtree[2*d_code(t)]++),e.last_lit===e.lit_bufsize-1}function adler32$2(e,t,r,n){for(var i=65535&e|0,o=e>>>16&65535|0,a=0;0!==r;){r-=a=r>2e3?2e3:r;do{o=o+(i=i+t[n++]|0)|0}while(--a);i%=65521,o%=65521}return i|o<<16|0}trees$1._tr_init=_tr_init,trees$1._tr_stored_block=_tr_stored_block,trees$1._tr_flush_block=_tr_flush_block,trees$1._tr_tally=_tr_tally,trees$1._tr_align=_tr_align;var adler32_1=adler32$2;function makeTable(){for(var e,t=[],r=0;r<256;r++){e=r;for(var n=0;n<8;n++)e=1&e?3988292384^e>>>1:e>>>1;t[r]=e}return t}var crcTable=makeTable();function crc32$2(e,t,r,n){var i=crcTable,o=n+r;e^=-1;for(var a=n;a<o;a++)e=e>>>8^i[255&(e^t[a])];return-1^e}var configuration_table,crc32_1=crc32$2,messages={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"},utils$5=common,trees=trees$1,adler32$1=adler32_1,crc32$1=crc32_1,msg$2=messages,Z_NO_FLUSH$1=0,Z_PARTIAL_FLUSH=1,Z_FULL_FLUSH=3,Z_FINISH$2=4,Z_BLOCK$1=5,Z_OK$2=0,Z_STREAM_END$2=1,Z_STREAM_ERROR$1=-2,Z_DATA_ERROR$1=-3,Z_BUF_ERROR$1=-5,Z_DEFAULT_COMPRESSION$1=-1,Z_FILTERED=1,Z_HUFFMAN_ONLY=2,Z_RLE=3,Z_FIXED=4,Z_DEFAULT_STRATEGY$1=0,Z_UNKNOWN=2,Z_DEFLATED$2=8,MAX_MEM_LEVEL=9,MAX_WBITS$1=15,DEF_MEM_LEVEL=8,LENGTH_CODES=29,LITERALS=256,L_CODES=LITERALS+1+LENGTH_CODES,D_CODES=30,BL_CODES=19,HEAP_SIZE=2*L_CODES+1,MAX_BITS=15,MIN_MATCH=3,MAX_MATCH=258,MIN_LOOKAHEAD=MAX_MATCH+MIN_MATCH+1,PRESET_DICT=32,INIT_STATE=42,EXTRA_STATE=69,NAME_STATE=73,COMMENT_STATE=91,HCRC_STATE=103,BUSY_STATE=113,FINISH_STATE=666,BS_NEED_MORE=1,BS_BLOCK_DONE=2,BS_FINISH_STARTED=3,BS_FINISH_DONE=4,OS_CODE=3;function err(e,t){return e.msg=msg$2[t],t}function rank(e){return(e<<1)-(e>4?9:0)}function zero(e){for(var t=e.length;--t>=0;)e[t]=0}function flush_pending(e){var t=e.state,r=t.pending;r>e.avail_out&&(r=e.avail_out),0!==r&&(utils$5.arraySet(e.output,t.pending_buf,t.pending_out,r,e.next_out),e.next_out+=r,t.pending_out+=r,e.total_out+=r,e.avail_out-=r,t.pending-=r,0===t.pending&&(t.pending_out=0))}function flush_block_only(e,t){trees._tr_flush_block(e,e.block_start>=0?e.block_start:-1,e.strstart-e.block_start,t),e.block_start=e.strstart,flush_pending(e.strm)}function put_byte(e,t){e.pending_buf[e.pending++]=t}function putShortMSB(e,t){e.pending_buf[e.pending++]=t>>>8&255,e.pending_buf[e.pending++]=255&t}function read_buf(e,t,r,n){var i=e.avail_in;return i>n&&(i=n),0===i?0:(e.avail_in-=i,utils$5.arraySet(t,e.input,e.next_in,i,r),1===e.state.wrap?e.adler=adler32$1(e.adler,t,i,r):2===e.state.wrap&&(e.adler=crc32$1(e.adler,t,i,r)),e.next_in+=i,e.total_in+=i,i)}function longest_match(e,t){var r,n,i=e.max_chain_length,o=e.strstart,a=e.prev_length,s=e.nice_match,c=e.strstart>e.w_size-MIN_LOOKAHEAD?e.strstart-(e.w_size-MIN_LOOKAHEAD):0,u=e.window,l=e.w_mask,d=e.prev,p=e.strstart+MAX_MATCH,_=u[o+a-1],f=u[o+a];e.prev_length>=e.good_match&&(i>>=2),s>e.lookahead&&(s=e.lookahead);do{if(u[(r=t)+a]===f&&u[r+a-1]===_&&u[r]===u[o]&&u[++r]===u[o+1]){o+=2,r++;do{}while(u[++o]===u[++r]&&u[++o]===u[++r]&&u[++o]===u[++r]&&u[++o]===u[++r]&&u[++o]===u[++r]&&u[++o]===u[++r]&&u[++o]===u[++r]&&u[++o]===u[++r]&&o<p);if(n=MAX_MATCH-(p-o),o=p-MAX_MATCH,n>a){if(e.match_start=t,a=n,n>=s)break;_=u[o+a-1],f=u[o+a]}}}while((t=d[t&l])>c&&0!=--i);return a<=e.lookahead?a:e.lookahead}function fill_window(e){var t,r,n,i,o,a=e.w_size;do{if(i=e.window_size-e.lookahead-e.strstart,e.strstart>=a+(a-MIN_LOOKAHEAD)){utils$5.arraySet(e.window,e.window,a,a,0),e.match_start-=a,e.strstart-=a,e.block_start-=a,t=r=e.hash_size;do{n=e.head[--t],e.head[t]=n>=a?n-a:0}while(--r);t=r=a;do{n=e.prev[--t],e.prev[t]=n>=a?n-a:0}while(--r);i+=a}if(0===e.strm.avail_in)break;if(r=read_buf(e.strm,e.window,e.strstart+e.lookahead,i),e.lookahead+=r,e.lookahead+e.insert>=MIN_MATCH)for(o=e.strstart-e.insert,e.ins_h=e.window[o],e.ins_h=(e.ins_h<<e.hash_shift^e.window[o+1])&e.hash_mask;e.insert&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[o+MIN_MATCH-1])&e.hash_mask,e.prev[o&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=o,o++,e.insert--,!(e.lookahead+e.insert<MIN_MATCH)););}while(e.lookahead<MIN_LOOKAHEAD&&0!==e.strm.avail_in)}function deflate_stored(e,t){var r=65535;for(r>e.pending_buf_size-5&&(r=e.pending_buf_size-5);;){if(e.lookahead<=1){if(fill_window(e),0===e.lookahead&&t===Z_NO_FLUSH$1)return BS_NEED_MORE;if(0===e.lookahead)break}e.strstart+=e.lookahead,e.lookahead=0;var n=e.block_start+r;if((0===e.strstart||e.strstart>=n)&&(e.lookahead=e.strstart-n,e.strstart=n,flush_block_only(e,!1),0===e.strm.avail_out))return BS_NEED_MORE;if(e.strstart-e.block_start>=e.w_size-MIN_LOOKAHEAD&&(flush_block_only(e,!1),0===e.strm.avail_out))return BS_NEED_MORE}return e.insert=0,t===Z_FINISH$2?(flush_block_only(e,!0),0===e.strm.avail_out?BS_FINISH_STARTED:BS_FINISH_DONE):(e.strstart>e.block_start&&(flush_block_only(e,!1),e.strm.avail_out),BS_NEED_MORE)}function deflate_fast(e,t){for(var r,n;;){if(e.lookahead<MIN_LOOKAHEAD){if(fill_window(e),e.lookahead<MIN_LOOKAHEAD&&t===Z_NO_FLUSH$1)return BS_NEED_MORE;if(0===e.lookahead)break}if(r=0,e.lookahead>=MIN_MATCH&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+MIN_MATCH-1])&e.hash_mask,r=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),0!==r&&e.strstart-r<=e.w_size-MIN_LOOKAHEAD&&(e.match_length=longest_match(e,r)),e.match_length>=MIN_MATCH)if(n=trees._tr_tally(e,e.strstart-e.match_start,e.match_length-MIN_MATCH),e.lookahead-=e.match_length,e.match_length<=e.max_lazy_match&&e.lookahead>=MIN_MATCH){e.match_length--;do{e.strstart++,e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+MIN_MATCH-1])&e.hash_mask,r=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart}while(0!=--e.match_length);e.strstart++}else e.strstart+=e.match_length,e.match_length=0,e.ins_h=e.window[e.strstart],e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+1])&e.hash_mask;else n=trees._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++;if(n&&(flush_block_only(e,!1),0===e.strm.avail_out))return BS_NEED_MORE}return e.insert=e.strstart<MIN_MATCH-1?e.strstart:MIN_MATCH-1,t===Z_FINISH$2?(flush_block_only(e,!0),0===e.strm.avail_out?BS_FINISH_STARTED:BS_FINISH_DONE):e.last_lit&&(flush_block_only(e,!1),0===e.strm.avail_out)?BS_NEED_MORE:BS_BLOCK_DONE}function deflate_slow(e,t){for(var r,n,i;;){if(e.lookahead<MIN_LOOKAHEAD){if(fill_window(e),e.lookahead<MIN_LOOKAHEAD&&t===Z_NO_FLUSH$1)return BS_NEED_MORE;if(0===e.lookahead)break}if(r=0,e.lookahead>=MIN_MATCH&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+MIN_MATCH-1])&e.hash_mask,r=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),e.prev_length=e.match_length,e.prev_match=e.match_start,e.match_length=MIN_MATCH-1,0!==r&&e.prev_length<e.max_lazy_match&&e.strstart-r<=e.w_size-MIN_LOOKAHEAD&&(e.match_length=longest_match(e,r),e.match_length<=5&&(e.strategy===Z_FILTERED||e.match_length===MIN_MATCH&&e.strstart-e.match_start>4096)&&(e.match_length=MIN_MATCH-1)),e.prev_length>=MIN_MATCH&&e.match_length<=e.prev_length){i=e.strstart+e.lookahead-MIN_MATCH,n=trees._tr_tally(e,e.strstart-1-e.prev_match,e.prev_length-MIN_MATCH),e.lookahead-=e.prev_length-1,e.prev_length-=2;do{++e.strstart<=i&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+MIN_MATCH-1])&e.hash_mask,r=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart)}while(0!=--e.prev_length);if(e.match_available=0,e.match_length=MIN_MATCH-1,e.strstart++,n&&(flush_block_only(e,!1),0===e.strm.avail_out))return BS_NEED_MORE}else if(e.match_available){if((n=trees._tr_tally(e,0,e.window[e.strstart-1]))&&flush_block_only(e,!1),e.strstart++,e.lookahead--,0===e.strm.avail_out)return BS_NEED_MORE}else e.match_available=1,e.strstart++,e.lookahead--}return e.match_available&&(n=trees._tr_tally(e,0,e.window[e.strstart-1]),e.match_available=0),e.insert=e.strstart<MIN_MATCH-1?e.strstart:MIN_MATCH-1,t===Z_FINISH$2?(flush_block_only(e,!0),0===e.strm.avail_out?BS_FINISH_STARTED:BS_FINISH_DONE):e.last_lit&&(flush_block_only(e,!1),0===e.strm.avail_out)?BS_NEED_MORE:BS_BLOCK_DONE}function deflate_rle(e,t){for(var r,n,i,o,a=e.window;;){if(e.lookahead<=MAX_MATCH){if(fill_window(e),e.lookahead<=MAX_MATCH&&t===Z_NO_FLUSH$1)return BS_NEED_MORE;if(0===e.lookahead)break}if(e.match_length=0,e.lookahead>=MIN_MATCH&&e.strstart>0&&(n=a[i=e.strstart-1])===a[++i]&&n===a[++i]&&n===a[++i]){o=e.strstart+MAX_MATCH;do{}while(n===a[++i]&&n===a[++i]&&n===a[++i]&&n===a[++i]&&n===a[++i]&&n===a[++i]&&n===a[++i]&&n===a[++i]&&i<o);e.match_length=MAX_MATCH-(o-i),e.match_length>e.lookahead&&(e.match_length=e.lookahead)}if(e.match_length>=MIN_MATCH?(r=trees._tr_tally(e,1,e.match_length-MIN_MATCH),e.lookahead-=e.match_length,e.strstart+=e.match_length,e.match_length=0):(r=trees._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++),r&&(flush_block_only(e,!1),0===e.strm.avail_out))return BS_NEED_MORE}return e.insert=0,t===Z_FINISH$2?(flush_block_only(e,!0),0===e.strm.avail_out?BS_FINISH_STARTED:BS_FINISH_DONE):e.last_lit&&(flush_block_only(e,!1),0===e.strm.avail_out)?BS_NEED_MORE:BS_BLOCK_DONE}function deflate_huff(e,t){for(var r;;){if(0===e.lookahead&&(fill_window(e),0===e.lookahead)){if(t===Z_NO_FLUSH$1)return BS_NEED_MORE;break}if(e.match_length=0,r=trees._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++,r&&(flush_block_only(e,!1),0===e.strm.avail_out))return BS_NEED_MORE}return e.insert=0,t===Z_FINISH$2?(flush_block_only(e,!0),0===e.strm.avail_out?BS_FINISH_STARTED:BS_FINISH_DONE):e.last_lit&&(flush_block_only(e,!1),0===e.strm.avail_out)?BS_NEED_MORE:BS_BLOCK_DONE}function Config$1(e,t,r,n,i){this.good_length=e,this.max_lazy=t,this.nice_length=r,this.max_chain=n,this.func=i}function lm_init(e){e.window_size=2*e.w_size,zero(e.head),e.max_lazy_match=configuration_table[e.level].max_lazy,e.good_match=configuration_table[e.level].good_length,e.nice_match=configuration_table[e.level].nice_length,e.max_chain_length=configuration_table[e.level].max_chain,e.strstart=0,e.block_start=0,e.lookahead=0,e.insert=0,e.match_length=e.prev_length=MIN_MATCH-1,e.match_available=0,e.ins_h=0}function DeflateState(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=Z_DEFLATED$2,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new utils$5.Buf16(2*HEAP_SIZE),this.dyn_dtree=new utils$5.Buf16(2*(2*D_CODES+1)),this.bl_tree=new utils$5.Buf16(2*(2*BL_CODES+1)),zero(this.dyn_ltree),zero(this.dyn_dtree),zero(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new utils$5.Buf16(MAX_BITS+1),this.heap=new utils$5.Buf16(2*L_CODES+1),zero(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new utils$5.Buf16(2*L_CODES+1),zero(this.depth),this.l_buf=0,this.lit_bufsize=0,this.last_lit=0,this.d_buf=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}function deflateResetKeep(e){var t;return e&&e.state?(e.total_in=e.total_out=0,e.data_type=Z_UNKNOWN,(t=e.state).pending=0,t.pending_out=0,t.wrap<0&&(t.wrap=-t.wrap),t.status=t.wrap?INIT_STATE:BUSY_STATE,e.adler=2===t.wrap?0:1,t.last_flush=Z_NO_FLUSH$1,trees._tr_init(t),Z_OK$2):err(e,Z_STREAM_ERROR$1)}function deflateReset(e){var t=deflateResetKeep(e);return t===Z_OK$2&&lm_init(e.state),t}function deflateSetHeader(e,t){return e&&e.state?2!==e.state.wrap?Z_STREAM_ERROR$1:(e.state.gzhead=t,Z_OK$2):Z_STREAM_ERROR$1}function deflateInit2(e,t,r,n,i,o){if(!e)return Z_STREAM_ERROR$1;var a=1;if(t===Z_DEFAULT_COMPRESSION$1&&(t=6),n<0?(a=0,n=-n):n>15&&(a=2,n-=16),i<1||i>MAX_MEM_LEVEL||r!==Z_DEFLATED$2||n<8||n>15||t<0||t>9||o<0||o>Z_FIXED)return err(e,Z_STREAM_ERROR$1);8===n&&(n=9);var s=new DeflateState;return e.state=s,s.strm=e,s.wrap=a,s.gzhead=null,s.w_bits=n,s.w_size=1<<s.w_bits,s.w_mask=s.w_size-1,s.hash_bits=i+7,s.hash_size=1<<s.hash_bits,s.hash_mask=s.hash_size-1,s.hash_shift=~~((s.hash_bits+MIN_MATCH-1)/MIN_MATCH),s.window=new utils$5.Buf8(2*s.w_size),s.head=new utils$5.Buf16(s.hash_size),s.prev=new utils$5.Buf16(s.w_size),s.lit_bufsize=1<<i+6,s.pending_buf_size=4*s.lit_bufsize,s.pending_buf=new utils$5.Buf8(s.pending_buf_size),s.d_buf=1*s.lit_bufsize,s.l_buf=3*s.lit_bufsize,s.level=t,s.strategy=o,s.method=r,deflateReset(e)}function deflateInit(e,t){return deflateInit2(e,t,Z_DEFLATED$2,MAX_WBITS$1,DEF_MEM_LEVEL,Z_DEFAULT_STRATEGY$1)}function deflate$2(e,t){var r,n,i,o;if(!e||!e.state||t>Z_BLOCK$1||t<0)return e?err(e,Z_STREAM_ERROR$1):Z_STREAM_ERROR$1;if(n=e.state,!e.output||!e.input&&0!==e.avail_in||n.status===FINISH_STATE&&t!==Z_FINISH$2)return err(e,0===e.avail_out?Z_BUF_ERROR$1:Z_STREAM_ERROR$1);if(n.strm=e,r=n.last_flush,n.last_flush=t,n.status===INIT_STATE)if(2===n.wrap)e.adler=0,put_byte(n,31),put_byte(n,139),put_byte(n,8),n.gzhead?(put_byte(n,(n.gzhead.text?1:0)+(n.gzhead.hcrc?2:0)+(n.gzhead.extra?4:0)+(n.gzhead.name?8:0)+(n.gzhead.comment?16:0)),put_byte(n,255&n.gzhead.time),put_byte(n,n.gzhead.time>>8&255),put_byte(n,n.gzhead.time>>16&255),put_byte(n,n.gzhead.time>>24&255),put_byte(n,9===n.level?2:n.strategy>=Z_HUFFMAN_ONLY||n.level<2?4:0),put_byte(n,255&n.gzhead.os),n.gzhead.extra&&n.gzhead.extra.length&&(put_byte(n,255&n.gzhead.extra.length),put_byte(n,n.gzhead.extra.length>>8&255)),n.gzhead.hcrc&&(e.adler=crc32$1(e.adler,n.pending_buf,n.pending,0)),n.gzindex=0,n.status=EXTRA_STATE):(put_byte(n,0),put_byte(n,0),put_byte(n,0),put_byte(n,0),put_byte(n,0),put_byte(n,9===n.level?2:n.strategy>=Z_HUFFMAN_ONLY||n.level<2?4:0),put_byte(n,OS_CODE),n.status=BUSY_STATE);else{var a=Z_DEFLATED$2+(n.w_bits-8<<4)<<8;a|=(n.strategy>=Z_HUFFMAN_ONLY||n.level<2?0:n.level<6?1:6===n.level?2:3)<<6,0!==n.strstart&&(a|=PRESET_DICT),a+=31-a%31,n.status=BUSY_STATE,putShortMSB(n,a),0!==n.strstart&&(putShortMSB(n,e.adler>>>16),putShortMSB(n,65535&e.adler)),e.adler=1}if(n.status===EXTRA_STATE)if(n.gzhead.extra){for(i=n.pending;n.gzindex<(65535&n.gzhead.extra.length)&&(n.pending!==n.pending_buf_size||(n.gzhead.hcrc&&n.pending>i&&(e.adler=crc32$1(e.adler,n.pending_buf,n.pending-i,i)),flush_pending(e),i=n.pending,n.pending!==n.pending_buf_size));)put_byte(n,255&n.gzhead.extra[n.gzindex]),n.gzindex++;n.gzhead.hcrc&&n.pending>i&&(e.adler=crc32$1(e.adler,n.pending_buf,n.pending-i,i)),n.gzindex===n.gzhead.extra.length&&(n.gzindex=0,n.status=NAME_STATE)}else n.status=NAME_STATE;if(n.status===NAME_STATE)if(n.gzhead.name){i=n.pending;do{if(n.pending===n.pending_buf_size&&(n.gzhead.hcrc&&n.pending>i&&(e.adler=crc32$1(e.adler,n.pending_buf,n.pending-i,i)),flush_pending(e),i=n.pending,n.pending===n.pending_buf_size)){o=1;break}o=n.gzindex<n.gzhead.name.length?255&n.gzhead.name.charCodeAt(n.gzindex++):0,put_byte(n,o)}while(0!==o);n.gzhead.hcrc&&n.pending>i&&(e.adler=crc32$1(e.adler,n.pending_buf,n.pending-i,i)),0===o&&(n.gzindex=0,n.status=COMMENT_STATE)}else n.status=COMMENT_STATE;if(n.status===COMMENT_STATE)if(n.gzhead.comment){i=n.pending;do{if(n.pending===n.pending_buf_size&&(n.gzhead.hcrc&&n.pending>i&&(e.adler=crc32$1(e.adler,n.pending_buf,n.pending-i,i)),flush_pending(e),i=n.pending,n.pending===n.pending_buf_size)){o=1;break}o=n.gzindex<n.gzhead.comment.length?255&n.gzhead.comment.charCodeAt(n.gzindex++):0,put_byte(n,o)}while(0!==o);n.gzhead.hcrc&&n.pending>i&&(e.adler=crc32$1(e.adler,n.pending_buf,n.pending-i,i)),0===o&&(n.status=HCRC_STATE)}else n.status=HCRC_STATE;if(n.status===HCRC_STATE&&(n.gzhead.hcrc?(n.pending+2>n.pending_buf_size&&flush_pending(e),n.pending+2<=n.pending_buf_size&&(put_byte(n,255&e.adler),put_byte(n,e.adler>>8&255),e.adler=0,n.status=BUSY_STATE)):n.status=BUSY_STATE),0!==n.pending){if(flush_pending(e),0===e.avail_out)return n.last_flush=-1,Z_OK$2}else if(0===e.avail_in&&rank(t)<=rank(r)&&t!==Z_FINISH$2)return err(e,Z_BUF_ERROR$1);if(n.status===FINISH_STATE&&0!==e.avail_in)return err(e,Z_BUF_ERROR$1);if(0!==e.avail_in||0!==n.lookahead||t!==Z_NO_FLUSH$1&&n.status!==FINISH_STATE){var s=n.strategy===Z_HUFFMAN_ONLY?deflate_huff(n,t):n.strategy===Z_RLE?deflate_rle(n,t):configuration_table[n.level].func(n,t);if(s!==BS_FINISH_STARTED&&s!==BS_FINISH_DONE||(n.status=FINISH_STATE),s===BS_NEED_MORE||s===BS_FINISH_STARTED)return 0===e.avail_out&&(n.last_flush=-1),Z_OK$2;if(s===BS_BLOCK_DONE&&(t===Z_PARTIAL_FLUSH?trees._tr_align(n):t!==Z_BLOCK$1&&(trees._tr_stored_block(n,0,0,!1),t===Z_FULL_FLUSH&&(zero(n.head),0===n.lookahead&&(n.strstart=0,n.block_start=0,n.insert=0))),flush_pending(e),0===e.avail_out))return n.last_flush=-1,Z_OK$2}return t!==Z_FINISH$2?Z_OK$2:n.wrap<=0?Z_STREAM_END$2:(2===n.wrap?(put_byte(n,255&e.adler),put_byte(n,e.adler>>8&255),put_byte(n,e.adler>>16&255),put_byte(n,e.adler>>24&255),put_byte(n,255&e.total_in),put_byte(n,e.total_in>>8&255),put_byte(n,e.total_in>>16&255),put_byte(n,e.total_in>>24&255)):(putShortMSB(n,e.adler>>>16),putShortMSB(n,65535&e.adler)),flush_pending(e),n.wrap>0&&(n.wrap=-n.wrap),0!==n.pending?Z_OK$2:Z_STREAM_END$2)}function deflateEnd(e){var t;return e&&e.state?(t=e.state.status)!==INIT_STATE&&t!==EXTRA_STATE&&t!==NAME_STATE&&t!==COMMENT_STATE&&t!==HCRC_STATE&&t!==BUSY_STATE&&t!==FINISH_STATE?err(e,Z_STREAM_ERROR$1):(e.state=null,t===BUSY_STATE?err(e,Z_DATA_ERROR$1):Z_OK$2):Z_STREAM_ERROR$1}function deflateSetDictionary(e,t){var r,n,i,o,a,s,c,u,l=t.length;if(!e||!e.state)return Z_STREAM_ERROR$1;if(2===(o=(r=e.state).wrap)||1===o&&r.status!==INIT_STATE||r.lookahead)return Z_STREAM_ERROR$1;for(1===o&&(e.adler=adler32$1(e.adler,t,l,0)),r.wrap=0,l>=r.w_size&&(0===o&&(zero(r.head),r.strstart=0,r.block_start=0,r.insert=0),u=new utils$5.Buf8(r.w_size),utils$5.arraySet(u,t,l-r.w_size,r.w_size,0),t=u,l=r.w_size),a=e.avail_in,s=e.next_in,c=e.input,e.avail_in=l,e.next_in=0,e.input=t,fill_window(r);r.lookahead>=MIN_MATCH;){n=r.strstart,i=r.lookahead-(MIN_MATCH-1);do{r.ins_h=(r.ins_h<<r.hash_shift^r.window[n+MIN_MATCH-1])&r.hash_mask,r.prev[n&r.w_mask]=r.head[r.ins_h],r.head[r.ins_h]=n,n++}while(--i);r.strstart=n,r.lookahead=MIN_MATCH-1,fill_window(r)}return r.strstart+=r.lookahead,r.block_start=r.strstart,r.insert=r.lookahead,r.lookahead=0,r.match_length=r.prev_length=MIN_MATCH-1,r.match_available=0,e.next_in=s,e.input=c,e.avail_in=a,r.wrap=o,Z_OK$2}configuration_table=[new Config$1(0,0,0,0,deflate_stored),new Config$1(4,4,8,4,deflate_fast),new Config$1(4,5,16,8,deflate_fast),new Config$1(4,6,32,32,deflate_fast),new Config$1(4,4,16,16,deflate_slow),new Config$1(8,16,32,32,deflate_slow),new Config$1(8,16,128,128,deflate_slow),new Config$1(8,32,128,256,deflate_slow),new Config$1(32,128,258,1024,deflate_slow),new Config$1(32,258,258,4096,deflate_slow)],deflate$3.deflateInit=deflateInit,deflate$3.deflateInit2=deflateInit2,deflate$3.deflateReset=deflateReset,deflate$3.deflateResetKeep=deflateResetKeep,deflate$3.deflateSetHeader=deflateSetHeader,deflate$3.deflate=deflate$2,deflate$3.deflateEnd=deflateEnd,deflate$3.deflateSetDictionary=deflateSetDictionary,deflate$3.deflateInfo="pako deflate (from Nodeca project)";var strings$2={},utils$4=common,STR_APPLY_OK=!0,STR_APPLY_UIA_OK=!0;try{String.fromCharCode.apply(null,[0])}catch(e){STR_APPLY_OK=!1}try{String.fromCharCode.apply(null,new Uint8Array(1))}catch(e){STR_APPLY_UIA_OK=!1}for(var _utf8len=new utils$4.Buf8(256),q=0;q<256;q++)_utf8len[q]=q>=252?6:q>=248?5:q>=240?4:q>=224?3:q>=192?2:1;function buf2binstring(e,t){if(t<65534&&(e.subarray&&STR_APPLY_UIA_OK||!e.subarray&&STR_APPLY_OK))return String.fromCharCode.apply(null,utils$4.shrinkBuf(e,t));for(var r="",n=0;n<t;n++)r+=String.fromCharCode(e[n]);return r}function ZStream$2(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}_utf8len[254]=_utf8len[254]=1,strings$2.string2buf=function(e){var t,r,n,i,o,a=e.length,s=0;for(i=0;i<a;i++)55296==(64512&(r=e.charCodeAt(i)))&&i+1<a&&56320==(64512&(n=e.charCodeAt(i+1)))&&(r=65536+(r-55296<<10)+(n-56320),i++),s+=r<128?1:r<2048?2:r<65536?3:4;for(t=new utils$4.Buf8(s),o=0,i=0;o<s;i++)55296==(64512&(r=e.charCodeAt(i)))&&i+1<a&&56320==(64512&(n=e.charCodeAt(i+1)))&&(r=65536+(r-55296<<10)+(n-56320),i++),r<128?t[o++]=r:r<2048?(t[o++]=192|r>>>6,t[o++]=128|63&r):r<65536?(t[o++]=224|r>>>12,t[o++]=128|r>>>6&63,t[o++]=128|63&r):(t[o++]=240|r>>>18,t[o++]=128|r>>>12&63,t[o++]=128|r>>>6&63,t[o++]=128|63&r);return t},strings$2.buf2binstring=function(e){return buf2binstring(e,e.length)},strings$2.binstring2buf=function(e){for(var t=new utils$4.Buf8(e.length),r=0,n=t.length;r<n;r++)t[r]=e.charCodeAt(r);return t},strings$2.buf2string=function(e,t){var r,n,i,o,a=t||e.length,s=new Array(2*a);for(n=0,r=0;r<a;)if((i=e[r++])<128)s[n++]=i;else if((o=_utf8len[i])>4)s[n++]=65533,r+=o-1;else{for(i&=2===o?31:3===o?15:7;o>1&&r<a;)i=i<<6|63&e[r++],o--;o>1?s[n++]=65533:i<65536?s[n++]=i:(i-=65536,s[n++]=55296|i>>10&1023,s[n++]=56320|1023&i)}return buf2binstring(s,n)},strings$2.utf8border=function(e,t){var r;for((t=t||e.length)>e.length&&(t=e.length),r=t-1;r>=0&&128==(192&e[r]);)r--;return r<0||0===r?t:r+_utf8len[e[r]]>t?r:t};var zstream=ZStream$2,zlib_deflate=deflate$3,utils$3=common,strings$1=strings$2,msg$1=messages,ZStream$1=zstream,toString$2=Object.prototype.toString,Z_NO_FLUSH=0,Z_FINISH$1=4,Z_OK$1=0,Z_STREAM_END$1=1,Z_SYNC_FLUSH=2,Z_DEFAULT_COMPRESSION=-1,Z_DEFAULT_STRATEGY=0,Z_DEFLATED$1=8;function Deflate(e){if(!(this instanceof Deflate))return new Deflate(e);this.options=utils$3.assign({level:Z_DEFAULT_COMPRESSION,method:Z_DEFLATED$1,chunkSize:16384,windowBits:15,memLevel:8,strategy:Z_DEFAULT_STRATEGY,to:""},e||{});var t=this.options;t.raw&&t.windowBits>0?t.windowBits=-t.windowBits:t.gzip&&t.windowBits>0&&t.windowBits<16&&(t.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new ZStream$1,this.strm.avail_out=0;var r=zlib_deflate.deflateInit2(this.strm,t.level,t.method,t.windowBits,t.memLevel,t.strategy);if(r!==Z_OK$1)throw new Error(msg$1[r]);if(t.header&&zlib_deflate.deflateSetHeader(this.strm,t.header),t.dictionary){var n;if(n="string"==typeof t.dictionary?strings$1.string2buf(t.dictionary):"[object ArrayBuffer]"===toString$2.call(t.dictionary)?new Uint8Array(t.dictionary):t.dictionary,(r=zlib_deflate.deflateSetDictionary(this.strm,n))!==Z_OK$1)throw new Error(msg$1[r]);this._dict_set=!0}}function deflate$1(e,t){var r=new Deflate(t);if(r.push(e,!0),r.err)throw r.msg||msg$1[r.err];return r.result}function deflateRaw(e,t){return(t=t||{}).raw=!0,deflate$1(e,t)}function gzip(e,t){return(t=t||{}).gzip=!0,deflate$1(e,t)}Deflate.prototype.push=function(e,t){var r,n,i=this.strm,o=this.options.chunkSize;if(this.ended)return!1;n=t===~~t?t:!0===t?Z_FINISH$1:Z_NO_FLUSH,"string"==typeof e?i.input=strings$1.string2buf(e):"[object ArrayBuffer]"===toString$2.call(e)?i.input=new Uint8Array(e):i.input=e,i.next_in=0,i.avail_in=i.input.length;do{if(0===i.avail_out&&(i.output=new utils$3.Buf8(o),i.next_out=0,i.avail_out=o),(r=zlib_deflate.deflate(i,n))!==Z_STREAM_END$1&&r!==Z_OK$1)return this.onEnd(r),this.ended=!0,!1;0!==i.avail_out&&(0!==i.avail_in||n!==Z_FINISH$1&&n!==Z_SYNC_FLUSH)||("string"===this.options.to?this.onData(strings$1.buf2binstring(utils$3.shrinkBuf(i.output,i.next_out))):this.onData(utils$3.shrinkBuf(i.output,i.next_out)))}while((i.avail_in>0||0===i.avail_out)&&r!==Z_STREAM_END$1);return n===Z_FINISH$1?(r=zlib_deflate.deflateEnd(this.strm),this.onEnd(r),this.ended=!0,r===Z_OK$1):n!==Z_SYNC_FLUSH||(this.onEnd(Z_OK$1),i.avail_out=0,!0)},Deflate.prototype.onData=function(e){this.chunks.push(e)},Deflate.prototype.onEnd=function(e){e===Z_OK$1&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=utils$3.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg},deflate$4.Deflate=Deflate,deflate$4.deflate=deflate$1,deflate$4.deflateRaw=deflateRaw,deflate$4.gzip=gzip;var inflate$4={},global$4=global$K,DESCRIPTORS$2=descriptors,defineBuiltInAccessor$1=defineBuiltInAccessor$5,regExpFlags=regexpFlags$1,fails$2=fails$U,RegExp$2=global$4.RegExp,RegExpPrototype=RegExp$2.prototype,FORCED=DESCRIPTORS$2&&fails$2((function(){var e=!0;try{RegExp$2(".","d")}catch(t){e=!1}var t={},r="",n=e?"dgimsy":"gimsy",i=function(e,n){Object.defineProperty(t,e,{get:function(){return r+=n,!0}})},o={dotAll:"s",global:"g",ignoreCase:"i",multiline:"m",sticky:"y"};for(var a in e&&(o.hasIndices="d"),o)i(a,o[a]);return Object.getOwnPropertyDescriptor(RegExpPrototype,"flags").get.call(t)!==n||r!==n}));FORCED&&defineBuiltInAccessor$1(RegExpPrototype,"flags",{configurable:!0,get:regExpFlags});var inflate$3={},BAD$1=30,TYPE$1=12,inffast=function(e,t){var r,n,i,o,a,s,c,u,l,d,p,_,f,h,m,y,v,S,g,E,T,b,R,I,$;r=e.state,n=e.next_in,I=e.input,i=n+(e.avail_in-5),o=e.next_out,$=e.output,a=o-(t-e.avail_out),s=o+(e.avail_out-257),c=r.dmax,u=r.wsize,l=r.whave,d=r.wnext,p=r.window,_=r.hold,f=r.bits,h=r.lencode,m=r.distcode,y=(1<<r.lenbits)-1,v=(1<<r.distbits)-1;e:do{f<15&&(_+=I[n++]<<f,f+=8,_+=I[n++]<<f,f+=8),S=h[_&y];t:for(;;){if(_>>>=g=S>>>24,f-=g,0===(g=S>>>16&255))$[o++]=65535&S;else{if(!(16&g)){if(0==(64&g)){S=h[(65535&S)+(_&(1<<g)-1)];continue t}if(32&g){r.mode=TYPE$1;break e}e.msg="invalid literal/length code",r.mode=BAD$1;break e}E=65535&S,(g&=15)&&(f<g&&(_+=I[n++]<<f,f+=8),E+=_&(1<<g)-1,_>>>=g,f-=g),f<15&&(_+=I[n++]<<f,f+=8,_+=I[n++]<<f,f+=8),S=m[_&v];r:for(;;){if(_>>>=g=S>>>24,f-=g,!(16&(g=S>>>16&255))){if(0==(64&g)){S=m[(65535&S)+(_&(1<<g)-1)];continue r}e.msg="invalid distance code",r.mode=BAD$1;break e}if(T=65535&S,f<(g&=15)&&(_+=I[n++]<<f,(f+=8)<g&&(_+=I[n++]<<f,f+=8)),(T+=_&(1<<g)-1)>c){e.msg="invalid distance too far back",r.mode=BAD$1;break e}if(_>>>=g,f-=g,T>(g=o-a)){if((g=T-g)>l&&r.sane){e.msg="invalid distance too far back",r.mode=BAD$1;break e}if(b=0,R=p,0===d){if(b+=u-g,g<E){E-=g;do{$[o++]=p[b++]}while(--g);b=o-T,R=$}}else if(d<g){if(b+=u+d-g,(g-=d)<E){E-=g;do{$[o++]=p[b++]}while(--g);if(b=0,d<E){E-=g=d;do{$[o++]=p[b++]}while(--g);b=o-T,R=$}}}else if(b+=d-g,g<E){E-=g;do{$[o++]=p[b++]}while(--g);b=o-T,R=$}for(;E>2;)$[o++]=R[b++],$[o++]=R[b++],$[o++]=R[b++],E-=3;E&&($[o++]=R[b++],E>1&&($[o++]=R[b++]))}else{b=o-T;do{$[o++]=$[b++],$[o++]=$[b++],$[o++]=$[b++],E-=3}while(E>2);E&&($[o++]=$[b++],E>1&&($[o++]=$[b++]))}break}}break}}while(n<i&&o<s);n-=E=f>>3,_&=(1<<(f-=E<<3))-1,e.next_in=n,e.next_out=o,e.avail_in=n<i?i-n+5:5-(n-i),e.avail_out=o<s?s-o+257:257-(o-s),r.hold=_,r.bits=f},utils$2=common,MAXBITS=15,ENOUGH_LENS$1=852,ENOUGH_DISTS$1=592,CODES$1=0,LENS$1=1,DISTS$1=2,lbase=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0],lext=[16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78],dbase=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0],dext=[16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64],inftrees=function(e,t,r,n,i,o,a,s){var c,u,l,d,p,_,f,h,m,y=s.bits,v=0,S=0,g=0,E=0,T=0,b=0,R=0,I=0,$=0,A=0,C=null,O=0,P=new utils$2.Buf16(MAXBITS+1),k=new utils$2.Buf16(MAXBITS+1),w=null,N=0;for(v=0;v<=MAXBITS;v++)P[v]=0;for(S=0;S<n;S++)P[t[r+S]]++;for(T=y,E=MAXBITS;E>=1&&0===P[E];E--);if(T>E&&(T=E),0===E)return i[o++]=20971520,i[o++]=20971520,s.bits=1,0;for(g=1;g<E&&0===P[g];g++);for(T<g&&(T=g),I=1,v=1;v<=MAXBITS;v++)if(I<<=1,(I-=P[v])<0)return-1;if(I>0&&(e===CODES$1||1!==E))return-1;for(k[1]=0,v=1;v<MAXBITS;v++)k[v+1]=k[v]+P[v];for(S=0;S<n;S++)0!==t[r+S]&&(a[k[t[r+S]]++]=S);if(e===CODES$1?(C=w=a,_=19):e===LENS$1?(C=lbase,O-=257,w=lext,N-=257,_=256):(C=dbase,w=dext,_=-1),A=0,S=0,v=g,p=o,b=T,R=0,l=-1,d=($=1<<T)-1,e===LENS$1&&$>ENOUGH_LENS$1||e===DISTS$1&&$>ENOUGH_DISTS$1)return 1;for(;;){f=v-R,a[S]<_?(h=0,m=a[S]):a[S]>_?(h=w[N+a[S]],m=C[O+a[S]]):(h=96,m=0),c=1<<v-R,g=u=1<<b;do{i[p+(A>>R)+(u-=c)]=f<<24|h<<16|m|0}while(0!==u);for(c=1<<v-1;A&c;)c>>=1;if(0!==c?(A&=c-1,A+=c):A=0,S++,0==--P[v]){if(v===E)break;v=t[r+a[S]]}if(v>T&&(A&d)!==l){for(0===R&&(R=T),p+=g,I=1<<(b=v-R);b+R<E&&!((I-=P[b+R])<=0);)b++,I<<=1;if($+=1<<b,e===LENS$1&&$>ENOUGH_LENS$1||e===DISTS$1&&$>ENOUGH_DISTS$1)return 1;i[l=A&d]=T<<24|b<<16|p-o|0}}return 0!==A&&(i[p+A]=v-R<<24|64<<16|0),s.bits=T,0},utils$1=common,adler32=adler32_1,crc32=crc32_1,inflate_fast=inffast,inflate_table=inftrees,CODES=0,LENS=1,DISTS=2,Z_FINISH=4,Z_BLOCK=5,Z_TREES=6,Z_OK=0,Z_STREAM_END=1,Z_NEED_DICT=2,Z_STREAM_ERROR=-2,Z_DATA_ERROR=-3,Z_MEM_ERROR=-4,Z_BUF_ERROR=-5,Z_DEFLATED=8,HEAD=1,FLAGS=2,TIME=3,OS=4,EXLEN=5,EXTRA=6,NAME=7,COMMENT=8,HCRC=9,DICTID=10,DICT=11,TYPE=12,TYPEDO=13,STORED=14,COPY_=15,COPY=16,TABLE=17,LENLENS=18,CODELENS=19,LEN_=20,LEN=21,LENEXT=22,DIST=23,DISTEXT=24,MATCH=25,LIT=26,CHECK=27,LENGTH=28,DONE=29,BAD=30,MEM=31,SYNC=32,ENOUGH_LENS=852,ENOUGH_DISTS=592,MAX_WBITS=15,DEF_WBITS=MAX_WBITS;function zswap32(e){return(e>>>24&255)+(e>>>8&65280)+((65280&e)<<8)+((255&e)<<24)}function InflateState(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new utils$1.Buf16(320),this.work=new utils$1.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function inflateResetKeep(e){var t;return e&&e.state?(t=e.state,e.total_in=e.total_out=t.total=0,e.msg="",t.wrap&&(e.adler=1&t.wrap),t.mode=HEAD,t.last=0,t.havedict=0,t.dmax=32768,t.head=null,t.hold=0,t.bits=0,t.lencode=t.lendyn=new utils$1.Buf32(ENOUGH_LENS),t.distcode=t.distdyn=new utils$1.Buf32(ENOUGH_DISTS),t.sane=1,t.back=-1,Z_OK):Z_STREAM_ERROR}function inflateReset(e){var t;return e&&e.state?((t=e.state).wsize=0,t.whave=0,t.wnext=0,inflateResetKeep(e)):Z_STREAM_ERROR}function inflateReset2(e,t){var r,n;return e&&e.state?(n=e.state,t<0?(r=0,t=-t):(r=1+(t>>4),t<48&&(t&=15)),t&&(t<8||t>15)?Z_STREAM_ERROR:(null!==n.window&&n.wbits!==t&&(n.window=null),n.wrap=r,n.wbits=t,inflateReset(e))):Z_STREAM_ERROR}function inflateInit2(e,t){var r,n;return e?(n=new InflateState,e.state=n,n.window=null,(r=inflateReset2(e,t))!==Z_OK&&(e.state=null),r):Z_STREAM_ERROR}function inflateInit(e){return inflateInit2(e,DEF_WBITS)}var lenfix,distfix,virgin=!0;function fixedtables(e){if(virgin){var t;for(lenfix=new utils$1.Buf32(512),distfix=new utils$1.Buf32(32),t=0;t<144;)e.lens[t++]=8;for(;t<256;)e.lens[t++]=9;for(;t<280;)e.lens[t++]=7;for(;t<288;)e.lens[t++]=8;for(inflate_table(LENS,e.lens,0,288,lenfix,0,e.work,{bits:9}),t=0;t<32;)e.lens[t++]=5;inflate_table(DISTS,e.lens,0,32,distfix,0,e.work,{bits:5}),virgin=!1}e.lencode=lenfix,e.lenbits=9,e.distcode=distfix,e.distbits=5}function updatewindow(e,t,r,n){var i,o=e.state;return null===o.window&&(o.wsize=1<<o.wbits,o.wnext=0,o.whave=0,o.window=new utils$1.Buf8(o.wsize)),n>=o.wsize?(utils$1.arraySet(o.window,t,r-o.wsize,o.wsize,0),o.wnext=0,o.whave=o.wsize):((i=o.wsize-o.wnext)>n&&(i=n),utils$1.arraySet(o.window,t,r-n,i,o.wnext),(n-=i)?(utils$1.arraySet(o.window,t,r-n,n,0),o.wnext=n,o.whave=o.wsize):(o.wnext+=i,o.wnext===o.wsize&&(o.wnext=0),o.whave<o.wsize&&(o.whave+=i))),0}function inflate$2(e,t){var r,n,i,o,a,s,c,u,l,d,p,_,f,h,m,y,v,S,g,E,T,b,R,I,$=0,A=new utils$1.Buf8(4),C=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];if(!e||!e.state||!e.output||!e.input&&0!==e.avail_in)return Z_STREAM_ERROR;(r=e.state).mode===TYPE&&(r.mode=TYPEDO),a=e.next_out,i=e.output,c=e.avail_out,o=e.next_in,n=e.input,s=e.avail_in,u=r.hold,l=r.bits,d=s,p=c,b=Z_OK;e:for(;;)switch(r.mode){case HEAD:if(0===r.wrap){r.mode=TYPEDO;break}for(;l<16;){if(0===s)break e;s--,u+=n[o++]<<l,l+=8}if(2&r.wrap&&35615===u){r.check=0,A[0]=255&u,A[1]=u>>>8&255,r.check=crc32(r.check,A,2,0),u=0,l=0,r.mode=FLAGS;break}if(r.flags=0,r.head&&(r.head.done=!1),!(1&r.wrap)||(((255&u)<<8)+(u>>8))%31){e.msg="incorrect header check",r.mode=BAD;break}if((15&u)!==Z_DEFLATED){e.msg="unknown compression method",r.mode=BAD;break}if(l-=4,T=8+(15&(u>>>=4)),0===r.wbits)r.wbits=T;else if(T>r.wbits){e.msg="invalid window size",r.mode=BAD;break}r.dmax=1<<T,e.adler=r.check=1,r.mode=512&u?DICTID:TYPE,u=0,l=0;break;case FLAGS:for(;l<16;){if(0===s)break e;s--,u+=n[o++]<<l,l+=8}if(r.flags=u,(255&r.flags)!==Z_DEFLATED){e.msg="unknown compression method",r.mode=BAD;break}if(57344&r.flags){e.msg="unknown header flags set",r.mode=BAD;break}r.head&&(r.head.text=u>>8&1),512&r.flags&&(A[0]=255&u,A[1]=u>>>8&255,r.check=crc32(r.check,A,2,0)),u=0,l=0,r.mode=TIME;case TIME:for(;l<32;){if(0===s)break e;s--,u+=n[o++]<<l,l+=8}r.head&&(r.head.time=u),512&r.flags&&(A[0]=255&u,A[1]=u>>>8&255,A[2]=u>>>16&255,A[3]=u>>>24&255,r.check=crc32(r.check,A,4,0)),u=0,l=0,r.mode=OS;case OS:for(;l<16;){if(0===s)break e;s--,u+=n[o++]<<l,l+=8}r.head&&(r.head.xflags=255&u,r.head.os=u>>8),512&r.flags&&(A[0]=255&u,A[1]=u>>>8&255,r.check=crc32(r.check,A,2,0)),u=0,l=0,r.mode=EXLEN;case EXLEN:if(1024&r.flags){for(;l<16;){if(0===s)break e;s--,u+=n[o++]<<l,l+=8}r.length=u,r.head&&(r.head.extra_len=u),512&r.flags&&(A[0]=255&u,A[1]=u>>>8&255,r.check=crc32(r.check,A,2,0)),u=0,l=0}else r.head&&(r.head.extra=null);r.mode=EXTRA;case EXTRA:if(1024&r.flags&&((_=r.length)>s&&(_=s),_&&(r.head&&(T=r.head.extra_len-r.length,r.head.extra||(r.head.extra=new Array(r.head.extra_len)),utils$1.arraySet(r.head.extra,n,o,_,T)),512&r.flags&&(r.check=crc32(r.check,n,_,o)),s-=_,o+=_,r.length-=_),r.length))break e;r.length=0,r.mode=NAME;case NAME:if(2048&r.flags){if(0===s)break e;_=0;do{T=n[o+_++],r.head&&T&&r.length<65536&&(r.head.name+=String.fromCharCode(T))}while(T&&_<s);if(512&r.flags&&(r.check=crc32(r.check,n,_,o)),s-=_,o+=_,T)break e}else r.head&&(r.head.name=null);r.length=0,r.mode=COMMENT;case COMMENT:if(4096&r.flags){if(0===s)break e;_=0;do{T=n[o+_++],r.head&&T&&r.length<65536&&(r.head.comment+=String.fromCharCode(T))}while(T&&_<s);if(512&r.flags&&(r.check=crc32(r.check,n,_,o)),s-=_,o+=_,T)break e}else r.head&&(r.head.comment=null);r.mode=HCRC;case HCRC:if(512&r.flags){for(;l<16;){if(0===s)break e;s--,u+=n[o++]<<l,l+=8}if(u!==(65535&r.check)){e.msg="header crc mismatch",r.mode=BAD;break}u=0,l=0}r.head&&(r.head.hcrc=r.flags>>9&1,r.head.done=!0),e.adler=r.check=0,r.mode=TYPE;break;case DICTID:for(;l<32;){if(0===s)break e;s--,u+=n[o++]<<l,l+=8}e.adler=r.check=zswap32(u),u=0,l=0,r.mode=DICT;case DICT:if(0===r.havedict)return e.next_out=a,e.avail_out=c,e.next_in=o,e.avail_in=s,r.hold=u,r.bits=l,Z_NEED_DICT;e.adler=r.check=1,r.mode=TYPE;case TYPE:if(t===Z_BLOCK||t===Z_TREES)break e;case TYPEDO:if(r.last){u>>>=7&l,l-=7&l,r.mode=CHECK;break}for(;l<3;){if(0===s)break e;s--,u+=n[o++]<<l,l+=8}switch(r.last=1&u,l-=1,3&(u>>>=1)){case 0:r.mode=STORED;break;case 1:if(fixedtables(r),r.mode=LEN_,t===Z_TREES){u>>>=2,l-=2;break e}break;case 2:r.mode=TABLE;break;case 3:e.msg="invalid block type",r.mode=BAD}u>>>=2,l-=2;break;case STORED:for(u>>>=7&l,l-=7&l;l<32;){if(0===s)break e;s--,u+=n[o++]<<l,l+=8}if((65535&u)!=(u>>>16^65535)){e.msg="invalid stored block lengths",r.mode=BAD;break}if(r.length=65535&u,u=0,l=0,r.mode=COPY_,t===Z_TREES)break e;case COPY_:r.mode=COPY;case COPY:if(_=r.length){if(_>s&&(_=s),_>c&&(_=c),0===_)break e;utils$1.arraySet(i,n,o,_,a),s-=_,o+=_,c-=_,a+=_,r.length-=_;break}r.mode=TYPE;break;case TABLE:for(;l<14;){if(0===s)break e;s--,u+=n[o++]<<l,l+=8}if(r.nlen=257+(31&u),u>>>=5,l-=5,r.ndist=1+(31&u),u>>>=5,l-=5,r.ncode=4+(15&u),u>>>=4,l-=4,r.nlen>286||r.ndist>30){e.msg="too many length or distance symbols",r.mode=BAD;break}r.have=0,r.mode=LENLENS;case LENLENS:for(;r.have<r.ncode;){for(;l<3;){if(0===s)break e;s--,u+=n[o++]<<l,l+=8}r.lens[C[r.have++]]=7&u,u>>>=3,l-=3}for(;r.have<19;)r.lens[C[r.have++]]=0;if(r.lencode=r.lendyn,r.lenbits=7,R={bits:r.lenbits},b=inflate_table(CODES,r.lens,0,19,r.lencode,0,r.work,R),r.lenbits=R.bits,b){e.msg="invalid code lengths set",r.mode=BAD;break}r.have=0,r.mode=CODELENS;case CODELENS:for(;r.have<r.nlen+r.ndist;){for(;y=($=r.lencode[u&(1<<r.lenbits)-1])>>>16&255,v=65535&$,!((m=$>>>24)<=l);){if(0===s)break e;s--,u+=n[o++]<<l,l+=8}if(v<16)u>>>=m,l-=m,r.lens[r.have++]=v;else{if(16===v){for(I=m+2;l<I;){if(0===s)break e;s--,u+=n[o++]<<l,l+=8}if(u>>>=m,l-=m,0===r.have){e.msg="invalid bit length repeat",r.mode=BAD;break}T=r.lens[r.have-1],_=3+(3&u),u>>>=2,l-=2}else if(17===v){for(I=m+3;l<I;){if(0===s)break e;s--,u+=n[o++]<<l,l+=8}l-=m,T=0,_=3+(7&(u>>>=m)),u>>>=3,l-=3}else{for(I=m+7;l<I;){if(0===s)break e;s--,u+=n[o++]<<l,l+=8}l-=m,T=0,_=11+(127&(u>>>=m)),u>>>=7,l-=7}if(r.have+_>r.nlen+r.ndist){e.msg="invalid bit length repeat",r.mode=BAD;break}for(;_--;)r.lens[r.have++]=T}}if(r.mode===BAD)break;if(0===r.lens[256]){e.msg="invalid code -- missing end-of-block",r.mode=BAD;break}if(r.lenbits=9,R={bits:r.lenbits},b=inflate_table(LENS,r.lens,0,r.nlen,r.lencode,0,r.work,R),r.lenbits=R.bits,b){e.msg="invalid literal/lengths set",r.mode=BAD;break}if(r.distbits=6,r.distcode=r.distdyn,R={bits:r.distbits},b=inflate_table(DISTS,r.lens,r.nlen,r.ndist,r.distcode,0,r.work,R),r.distbits=R.bits,b){e.msg="invalid distances set",r.mode=BAD;break}if(r.mode=LEN_,t===Z_TREES)break e;case LEN_:r.mode=LEN;case LEN:if(s>=6&&c>=258){e.next_out=a,e.avail_out=c,e.next_in=o,e.avail_in=s,r.hold=u,r.bits=l,inflate_fast(e,p),a=e.next_out,i=e.output,c=e.avail_out,o=e.next_in,n=e.input,s=e.avail_in,u=r.hold,l=r.bits,r.mode===TYPE&&(r.back=-1);break}for(r.back=0;y=($=r.lencode[u&(1<<r.lenbits)-1])>>>16&255,v=65535&$,!((m=$>>>24)<=l);){if(0===s)break e;s--,u+=n[o++]<<l,l+=8}if(y&&0==(240&y)){for(S=m,g=y,E=v;y=($=r.lencode[E+((u&(1<<S+g)-1)>>S)])>>>16&255,v=65535&$,!(S+(m=$>>>24)<=l);){if(0===s)break e;s--,u+=n[o++]<<l,l+=8}u>>>=S,l-=S,r.back+=S}if(u>>>=m,l-=m,r.back+=m,r.length=v,0===y){r.mode=LIT;break}if(32&y){r.back=-1,r.mode=TYPE;break}if(64&y){e.msg="invalid literal/length code",r.mode=BAD;break}r.extra=15&y,r.mode=LENEXT;case LENEXT:if(r.extra){for(I=r.extra;l<I;){if(0===s)break e;s--,u+=n[o++]<<l,l+=8}r.length+=u&(1<<r.extra)-1,u>>>=r.extra,l-=r.extra,r.back+=r.extra}r.was=r.length,r.mode=DIST;case DIST:for(;y=($=r.distcode[u&(1<<r.distbits)-1])>>>16&255,v=65535&$,!((m=$>>>24)<=l);){if(0===s)break e;s--,u+=n[o++]<<l,l+=8}if(0==(240&y)){for(S=m,g=y,E=v;y=($=r.distcode[E+((u&(1<<S+g)-1)>>S)])>>>16&255,v=65535&$,!(S+(m=$>>>24)<=l);){if(0===s)break e;s--,u+=n[o++]<<l,l+=8}u>>>=S,l-=S,r.back+=S}if(u>>>=m,l-=m,r.back+=m,64&y){e.msg="invalid distance code",r.mode=BAD;break}r.offset=v,r.extra=15&y,r.mode=DISTEXT;case DISTEXT:if(r.extra){for(I=r.extra;l<I;){if(0===s)break e;s--,u+=n[o++]<<l,l+=8}r.offset+=u&(1<<r.extra)-1,u>>>=r.extra,l-=r.extra,r.back+=r.extra}if(r.offset>r.dmax){e.msg="invalid distance too far back",r.mode=BAD;break}r.mode=MATCH;case MATCH:if(0===c)break e;if(_=p-c,r.offset>_){if((_=r.offset-_)>r.whave&&r.sane){e.msg="invalid distance too far back",r.mode=BAD;break}_>r.wnext?(_-=r.wnext,f=r.wsize-_):f=r.wnext-_,_>r.length&&(_=r.length),h=r.window}else h=i,f=a-r.offset,_=r.length;_>c&&(_=c),c-=_,r.length-=_;do{i[a++]=h[f++]}while(--_);0===r.length&&(r.mode=LEN);break;case LIT:if(0===c)break e;i[a++]=r.length,c--,r.mode=LEN;break;case CHECK:if(r.wrap){for(;l<32;){if(0===s)break e;s--,u|=n[o++]<<l,l+=8}if(p-=c,e.total_out+=p,r.total+=p,p&&(e.adler=r.check=r.flags?crc32(r.check,i,p,a-p):adler32(r.check,i,p,a-p)),p=c,(r.flags?u:zswap32(u))!==r.check){e.msg="incorrect data check",r.mode=BAD;break}u=0,l=0}r.mode=LENGTH;case LENGTH:if(r.wrap&&r.flags){for(;l<32;){if(0===s)break e;s--,u+=n[o++]<<l,l+=8}if(u!==(4294967295&r.total)){e.msg="incorrect length check",r.mode=BAD;break}u=0,l=0}r.mode=DONE;case DONE:b=Z_STREAM_END;break e;case BAD:b=Z_DATA_ERROR;break e;case MEM:return Z_MEM_ERROR;default:return Z_STREAM_ERROR}return e.next_out=a,e.avail_out=c,e.next_in=o,e.avail_in=s,r.hold=u,r.bits=l,(r.wsize||p!==e.avail_out&&r.mode<BAD&&(r.mode<CHECK||t!==Z_FINISH))&&updatewindow(e,e.output,e.next_out,p-e.avail_out),d-=e.avail_in,p-=e.avail_out,e.total_in+=d,e.total_out+=p,r.total+=p,r.wrap&&p&&(e.adler=r.check=r.flags?crc32(r.check,i,p,e.next_out-p):adler32(r.check,i,p,e.next_out-p)),e.data_type=r.bits+(r.last?64:0)+(r.mode===TYPE?128:0)+(r.mode===LEN_||r.mode===COPY_?256:0),(0===d&&0===p||t===Z_FINISH)&&b===Z_OK&&(b=Z_BUF_ERROR),b}function inflateEnd(e){if(!e||!e.state)return Z_STREAM_ERROR;var t=e.state;return t.window&&(t.window=null),e.state=null,Z_OK}function inflateGetHeader(e,t){var r;return e&&e.state?0==(2&(r=e.state).wrap)?Z_STREAM_ERROR:(r.head=t,t.done=!1,Z_OK):Z_STREAM_ERROR}function inflateSetDictionary(e,t){var r,n=t.length;return e&&e.state?0!==(r=e.state).wrap&&r.mode!==DICT?Z_STREAM_ERROR:r.mode===DICT&&adler32(1,t,n,0)!==r.check?Z_DATA_ERROR:updatewindow(e,t,n,n)?(r.mode=MEM,Z_MEM_ERROR):(r.havedict=1,Z_OK):Z_STREAM_ERROR}inflate$3.inflateReset=inflateReset,inflate$3.inflateReset2=inflateReset2,inflate$3.inflateResetKeep=inflateResetKeep,inflate$3.inflateInit=inflateInit,inflate$3.inflateInit2=inflateInit2,inflate$3.inflate=inflate$2,inflate$3.inflateEnd=inflateEnd,inflate$3.inflateGetHeader=inflateGetHeader,inflate$3.inflateSetDictionary=inflateSetDictionary,inflate$3.inflateInfo="pako inflate (from Nodeca project)";var constants$1={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8};function GZheader$1(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1}var gzheader=GZheader$1,zlib_inflate=inflate$3,utils=common,strings=strings$2,c=constants$1,msg=messages,ZStream=zstream,GZheader=gzheader,toString$1=Object.prototype.toString;function Inflate(e){if(!(this instanceof Inflate))return new Inflate(e);this.options=utils.assign({chunkSize:16384,windowBits:0,to:""},e||{});var t=this.options;t.raw&&t.windowBits>=0&&t.windowBits<16&&(t.windowBits=-t.windowBits,0===t.windowBits&&(t.windowBits=-15)),!(t.windowBits>=0&&t.windowBits<16)||e&&e.windowBits||(t.windowBits+=32),t.windowBits>15&&t.windowBits<48&&0==(15&t.windowBits)&&(t.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new ZStream,this.strm.avail_out=0;var r=zlib_inflate.inflateInit2(this.strm,t.windowBits);if(r!==c.Z_OK)throw new Error(msg[r]);if(this.header=new GZheader,zlib_inflate.inflateGetHeader(this.strm,this.header),t.dictionary&&("string"==typeof t.dictionary?t.dictionary=strings.string2buf(t.dictionary):"[object ArrayBuffer]"===toString$1.call(t.dictionary)&&(t.dictionary=new Uint8Array(t.dictionary)),t.raw&&(r=zlib_inflate.inflateSetDictionary(this.strm,t.dictionary))!==c.Z_OK))throw new Error(msg[r])}function inflate$1(e,t){var r=new Inflate(t);if(r.push(e,!0),r.err)throw r.msg||msg[r.err];return r.result}function inflateRaw(e,t){return(t=t||{}).raw=!0,inflate$1(e,t)}Inflate.prototype.push=function(e,t){var r,n,i,o,a,s=this.strm,u=this.options.chunkSize,l=this.options.dictionary,d=!1;if(this.ended)return!1;n=t===~~t?t:!0===t?c.Z_FINISH:c.Z_NO_FLUSH,"string"==typeof e?s.input=strings.binstring2buf(e):"[object ArrayBuffer]"===toString$1.call(e)?s.input=new Uint8Array(e):s.input=e,s.next_in=0,s.avail_in=s.input.length;do{if(0===s.avail_out&&(s.output=new utils.Buf8(u),s.next_out=0,s.avail_out=u),(r=zlib_inflate.inflate(s,c.Z_NO_FLUSH))===c.Z_NEED_DICT&&l&&(r=zlib_inflate.inflateSetDictionary(this.strm,l)),r===c.Z_BUF_ERROR&&!0===d&&(r=c.Z_OK,d=!1),r!==c.Z_STREAM_END&&r!==c.Z_OK)return this.onEnd(r),this.ended=!0,!1;s.next_out&&(0!==s.avail_out&&r!==c.Z_STREAM_END&&(0!==s.avail_in||n!==c.Z_FINISH&&n!==c.Z_SYNC_FLUSH)||("string"===this.options.to?(i=strings.utf8border(s.output,s.next_out),o=s.next_out-i,a=strings.buf2string(s.output,i),s.next_out=o,s.avail_out=u-o,o&&utils.arraySet(s.output,s.output,i,o,0),this.onData(a)):this.onData(utils.shrinkBuf(s.output,s.next_out)))),0===s.avail_in&&0===s.avail_out&&(d=!0)}while((s.avail_in>0||0===s.avail_out)&&r!==c.Z_STREAM_END);return r===c.Z_STREAM_END&&(n=c.Z_FINISH),n===c.Z_FINISH?(r=zlib_inflate.inflateEnd(this.strm),this.onEnd(r),this.ended=!0,r===c.Z_OK):n!==c.Z_SYNC_FLUSH||(this.onEnd(c.Z_OK),s.avail_out=0,!0)},Inflate.prototype.onData=function(e){this.chunks.push(e)},Inflate.prototype.onEnd=function(e){e===c.Z_OK&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=utils.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg},inflate$4.Inflate=Inflate,inflate$4.inflate=inflate$1,inflate$4.inflateRaw=inflateRaw,inflate$4.ungzip=inflate$1;var assign$1=common.assign,deflate=deflate$4,inflate=inflate$4,constants=constants$1,pako={};assign$1(pako,deflate,inflate,constants);var pako_1=pako,CommonProductLine=function(e){return e.RTC="rtc",e}(CommonProductLine||{}),CommonReportVersion=function(e){return e.W_5="5",e}(CommonReportVersion||{}),CommonOs=function(e){return e.IOS="ios",e.ANDROID="android",e.WEB="web",e.WINDOWS="windows",e.MAC="mac",e.LINUX="linux",e}(CommonOs||{}),RtcgetconfigType=function(e){return e.REQUEST="request",e.RESPONSE="response",e}(RtcgetconfigType||{}),RtcreconnectMessage=function(e){return e.WEBSOCKET_RECONNECTING="websocket reconnecting",e.PEERCONNECTION_RECONNECTING="peerconnection reconnecting",e.DISCONNECTED="DISCONNECTED",e.LAN="LAN",e.WIFI="WIFI",e.W_2="2G",e.W_3="3G",e.W_4="4G",e.W_5="5G",e.UNKNOWN="UNKNOWN",e}(RtcreconnectMessage||{}),RtcreconnectReconnectType=function(e){return e.WEBSOCKET="websocket",e.NETWORKCHANGED="networkChanged",e.PEERCONNECTION="peerconnection",e}(RtcreconnectReconnectType||{}),RtcreconnectedMessage=function(e){return e.WEBSOCKET_RECONNECTED="websocket reconnected",e.PEERCONNECTION_RECONNECTED="peerconnection reconnected",e}(RtcreconnectedMessage||{}),RtcreconnectedReconnectType=function(e){return e.WEBSOCKET="websocket",e.NETWORKCHANGED="networkChanged",e.PEERCONNECTION="peerconnection",e}(RtcreconnectedReconnectType||{}),RtcgetaccessType=function(e){return e.REQUEST="request",e.RESPONSE="response",e.KCP_REQUEST="kcp request",e.KCP_RESPONSE="kcp response",e.QUIC_REQUEST="quic request",e.QUIC_RESPONSE="quic response",e}(RtcgetaccessType||{}),RtcpreicestateIceState=function(e){return e.NEW="NEW",e.CHECKING="CHECKING",e.CONNECTED="CONNECTED",e.COMPLETED="COMPLETED",e.FAILED="FAILED",e.DISCONNECTED="DISCONNECTED",e.CLOSED="CLOSED",e.DATACHANNEL_CONNECTING="DATACHANNEL_CONNECTING",e.DATACHANNEL_OPEN="DATACHANNEL_OPEN",e.DATACHANNEL_CLOSING="DATACHANNEL_CLOSING",e.DATACHANNEL_CLOSED="DATACHANNEL_CLOSED",e}(RtcpreicestateIceState||{}),RtcsignalingmsgerrorReason=function(e){return e.SUCCEED="succeed",e.MESSAGE_ID_ERROR="message id error",e.ZIP_FAILED="zip failed",e.UNZIP_FAILED="unzip failed",e.MESSAGE_KEY_EMPTY="message key empty",e.MESSAGE_KEY_PARSE_FAILED="message key parse failed",e.MESSAGE_KEY_INVALID="message key invalid",e.ENCRYPT_FAILED="encrypt failed",e.DECRYPT_FAILED="decrypt failed",e.MESSAGE_TOO_BIG="message too big",e.INVALID_DATA="invalid data",e.MESSAGE_PARSE_FAILED="message parse failed",e}(RtcsignalingmsgerrorReason||{}),RtcsignalingDirection=function(e){return e.UP="up",e.DOWN="down",e.DIRECT="direct",e}(RtcsignalingDirection||{}),RtcbegincreateofferDirection=function(e){return e.UP="up",e.DOWN="down",e.PRE="pre",e}(RtcbegincreateofferDirection||{}),RtccreateofferDirection=function(e){return e.UP="up",e.DOWN="down",e.PRE="pre",e}(RtccreateofferDirection||{}),RtcsetdescriptionIsLocal=function(e){return e.W_0="0",e.W_1="1",e}(RtcsetdescriptionIsLocal||{}),RtcsetdescriptionDirection=function(e){return e.UP="up",e.DOWN="down",e}(RtcsetdescriptionDirection||{}),RtcrecvanswerAnswerType=function(e){return e.ANSWER="answer",e.INCRANSWER="incranswer",e}(RtcrecvanswerAnswerType||{}),RtcrecvanswerDirection=function(e){return e.UP="up",e.DOWN="down",e}(RtcrecvanswerDirection||{}),RtcpublishstatResult=function(e){return e.SUCCESS="success",e.FAIL="fail",e}(RtcpublishstatResult||{}),RtcpublishstatIsScreen=function(e){return e.W_0="0",e.W_1="1",e}(RtcpublishstatIsScreen||{}),RtcpublishstatMessage=function(e){return e.LEAVE_ROOM="leave room",e.ACK_FAILED="ack failed",e.SET_ANSWER_SDP_FAILED="set answer sdp failed",e.ICE_FAILED="ice failed",e.STREAM_FAILED="stream failed",e.NETWORK_RECONNECTED="network reconnected",e.JOIN_ROOM_ACK_FAILED="join room ack failed",e.UNKNOWN="unknown",e}(RtcpublishstatMessage||{}),RtcsubscribestatResult=function(e){return e.SUCCESS="success",e.FAIL="fail",e.IGNORE="ignore",e}(RtcsubscribestatResult||{}),RtcsubscribestatMessage=function(e){return e.LEAVE_ROOM="leave room",e.ACK_FAILED="ack failed",e.SET_ANSWER_SDP_FAILED="set answer sdp failed",e.ICE_FAILED="ice failed",e.STREAM_FAILED="stream failed",e.NETWORK_RECONNECTED="network reconnected",e.ON_STREAM_REMOVE="on stream remove",e.PUBLISH_MUTE="publish mute",e.UNKNOWN="unknown",e.ON_STREAM_REMOVE_CLIENT_UNPUBLISHED="on stream remove:client unpublished",e.ON_STREAM_REMOVE_PUBLISH_FAILED="on stream remove:publish failed",e.ON_STREAM_REMOVE_STREAM_REMOVED="on stream remove:stream removed",e.ON_STREAM_REMOVE_CLIENT_DISCONNECTED="on stream remove:client disconnected",e.ON_STREAM_REMOVE_CLIENT_REPUBLISH="on stream remove:client republish",e}(RtcsubscribestatMessage||{}),RtcaudiodeviceAudioEvent=function(e){return e.PLAYOUT_DEVICE_SWITCH="playout_device_switch",e.RECORD_DEVICE_SWITCH="record_device_switch",e.UNKNOWN="unknown",e}(RtcaudiodeviceAudioEvent||{}),FirstframeinfoEventType=function(e){return e.BEGIN_SEND="begin_send",e.SENT_END="sent_end",e.BEGIN_RECV="begin_recv",e.RECV_END="recv_end",e}(FirstframeinfoEventType||{}),FirstframeinfoMediaType=function(e){return e.AUDIO="audio",e.VIDEO="video",e.SCREEN_VIDEO="screen_video",e.SCREEN_AUDIO="screen_audio",e}(FirstframeinfoMediaType||{}),FirstframeinfoType=function(e){return e.LOGIN="login",e.PUBLISHER="publisher",e.UNMUTE="unmute",e.ENABLE="enable",e.PUSH="push",e.PUBLISH="publish",e.ONDEMAND="ondemand",e.SUBSCRIBE="subscribe",e.PUSH_TRACK="push_track",e.REMOTE_UNMUTE="remote_unmute",e.P2P="p2p",e}(FirstframeinfoType||{}),FirstframeinfoReason=function(e){return e.TIMEOUT="timeout",e.AUDIENCE="audience",e.MUTE="mute",e.DISABLE="disable",e.STOP_PUSH="stop_push",e.UNPUBLISH="unpublish",e.NO_DEMAND="no_demand",e.LEAVE_ROOM="leave_room",e.UNSUBSCRIBE="unsubscribe",e.REMOVE_TRACK="remove_track",e.REMOTE_MUTE="remote_mute",e.USER_LEAVE="user_leave",e}(FirstframeinfoReason||{}),SdkinitengineType=function(e){return e.BEGIN="begin",e.END="end",e}(SdkinitengineType||{}),JoinroomType=function(e){return e.BEGIN="begin",e.END="end",e}(JoinroomType||{}),JoinroomReason=function(e){return e.LEAVE_ROOM="leave_room",e.ACK_FAILED="ack_failed",e.TOKEN_ERROR="token_error",e.SIGNALING_ERROR="signaling_error",e.TIMEOUT_10="timeout_10",e.TIMEOUT_60="timeout_60",e}(JoinroomReason||{}),DcusermessageDcMessageType=function(e){return e.P2P="p2p",e.P2P_OUTSIDE_ROOM="p2p_outside_room",e.P2SERVER="p2server",e}(DcusermessageDcMessageType||{}),CaptureeventinfoEventType=function(e){return e.START="start",e.START_CAPTURE_RESULT="start_capture_result",e.STARTED="started",e.RUNNING_FAILED="running_failed",e.STOP="stop",e.STOPPED="stopped",e}(CaptureeventinfoEventType||{}),CaptureeventinfoReason=function(e){return e.SUCCESS="success",e.CAMERA_DEVICE_NO_PERMISSION="camera_device_no_permission",e.CAMERA_DEVICE_BUSY="camera_device_busy",e.CAMERA_DEVICE_FAILURE="camera_device_failure",e.CAMERA_DEVICE_NOT_FOUND="camera_device_not_found",e.CAMERA_DEVICE_DISCONNECTED="camera_device_disconnected",e.TIMEOUT="timeout",e.ABORT="abort",e}(CaptureeventinfoReason||{}),Stats$1=function(){function e(t){_classCallCheck(this,e),_defineProperty(this,"_event_key",void 0),_defineProperty(this,"_device_id",void 0),_defineProperty(this,"_rtc_app_id",void 0),_defineProperty(this,"_product_line",void 0),_defineProperty(this,"_report_version",void 0),_defineProperty(this,"_os",void 0),_defineProperty(this,"_rtc_sdk_version",void 0),_defineProperty(this,"_rtc_timestamp",void 0),_defineProperty(this,"_rtc_sdk_git_commit",void 0),_defineProperty(this,"_report_id",void 0),_defineProperty(this,"_connection_id",void 0),_defineProperty(this,"_rtc_sid",void 0),_defineProperty(this,"_engine_session_id",void 0),_defineProperty(this,"_rtc_business_id",void 0),_defineProperty(this,"_project_key",void 0),_defineProperty(this,"_network_type",void 0),_defineProperty(this,"_app_version",void 0),_defineProperty(this,"_aid",void 0),_defineProperty(this,"_device_model",void 0),_defineProperty(this,"_device_brand",void 0),_defineProperty(this,"_common_extra_info",void 0),_defineProperty(this,"_had_selected_p2p",void 0),_defineProperty(this,"_rtc_env_type",void 0),_defineProperty(this,"_room_id",void 0),_defineProperty(this,"_user_id",void 0),_defineProperty(this,"_rtc_session_id",void 0),_defineProperty(this,"_user_agent",void 0),_defineProperty(this,"_auto_play_policy",void 0),this.monitor=t}return _createClass(e,[{key:"setStats",value:function(e){var t=this;Object.keys(e).forEach((function(r){t["_"+r]=e[r]})),this.monitor.StartUp()}},{key:"event_key",get:function(){return this._event_key}},{key:"device_id",get:function(){return this._device_id}},{key:"rtc_app_id",get:function(){return this._rtc_app_id}},{key:"product_line",get:function(){return this._product_line}},{key:"report_version",get:function(){return this._report_version}},{key:"os",get:function(){return this._os}},{key:"rtc_sdk_version",get:function(){return this._rtc_sdk_version}},{key:"rtc_timestamp",get:function(){return this._rtc_timestamp}},{key:"rtc_sdk_git_commit",get:function(){return this._rtc_sdk_git_commit}},{key:"report_id",get:function(){return this._report_id}},{key:"connection_id",get:function(){return this._connection_id}},{key:"rtc_sid",get:function(){return this._rtc_sid}},{key:"engine_session_id",get:function(){return this._engine_session_id}},{key:"rtc_business_id",get:function(){return this._rtc_business_id}},{key:"project_key",get:function(){return this._project_key}},{key:"network_type",get:function(){return this._network_type}},{key:"app_version",get:function(){return this._app_version}},{key:"aid",get:function(){return this._aid}},{key:"device_model",get:function(){return this._device_model}},{key:"device_brand",get:function(){return this._device_brand}},{key:"common_extra_info",get:function(){return this._common_extra_info}},{key:"had_selected_p2p",get:function(){return this._had_selected_p2p}},{key:"rtc_env_type",get:function(){return this._rtc_env_type}},{key:"room_id",get:function(){return this._room_id}},{key:"user_id",get:function(){return this._user_id}},{key:"rtc_session_id",get:function(){return this._rtc_session_id}},{key:"user_agent",get:function(){return this._user_agent}},{key:"auto_play_policy",get:function(){return this._auto_play_policy}}]),e}(),ReportLimit=4e3,XMLHttpRequestTimeout=1e4,Monitor=function(e){_inherits(r,EnhancedEventEmitter);var t=_createSuper(r);function r(){var e;return _classCallCheck(this,r),_defineProperty(_assertThisInitialized(e=t.call(this)),"report_id",void 0),_defineProperty(_assertThisInitialized(e),"report_common",void 0),_defineProperty(_assertThisInitialized(e),"modify_ids",void 0),_defineProperty(_assertThisInitialized(e),"dataBuffer",void 0),_defineProperty(_assertThisInitialized(e),"posting",void 0),_defineProperty(_assertThisInitialized(e),"sucSendTimer",void 0),_defineProperty(_assertThisInitialized(e),"preSucTime",void 0),_defineProperty(_assertThisInitialized(e),"errSendTimer",void 0),_defineProperty(_assertThisInitialized(e),"errSendDelay",void 0),_defineProperty(_assertThisInitialized(e),"commonStats",void 0),e.report_id=0,e.dataBuffer=[],e.posting=!1,e.report_common={},e.modify_ids={},e.preSucTime=0,e.errSendDelay=100,e.commonStats=new Stats$1(_assertThisInitialized(e)),isSSR()||window.addEventListener("beforeunload",(function(){clearTimeout(e.errSendTimer),clearTimeout(e.sucSendTimer),e.send(null,!0)})),e}return _createClass(r,[{key:"push",value:function(e,t){t?this.send(e):(this.dataBuffer.push(e),!this.posting&&!this.errSendTimer&&Date.now()-this.preSucTime>2e3&&(clearTimeout(this.sucSendTimer),this.send()))}},{key:"unshift",value:function(e){this.dataBuffer=e.concat(this.dataBuffer)}},{key:"send",value:function(e,t){var r=this;if(e||this.dataBuffer.length){var n={data:e||this.dataBuffer.splice(0,ReportLimit),header:this.report_common,from:"web",os:"web",version:"1"},i=new XMLHttpRequest;i.timeout=XMLHttpRequestTimeout,i.onreadystatechange=function(){if(4===i.readyState){var o;if(e||(r.posting=!1),200===i.status||304===i.status)try{o=JSON.parse(i.responseText)}catch(e){}o&&0===o.StatusCode?e||t||r.sucSend():e?r.send(e):(r.unshift(n.data),t?r.send():r.errSend())}};var o=Config.LOG_SERVER_URL;if(i.open("POST",o,!0),e||(this.posting=!0),!isSSR()&&location.search.includes("_rtc_autotest_"))this.safeEmit("report_event",n),0!==this.dataBuffer.length?this.sucSend():this.posting=!1;else if(!isSSR()&&location.search.includes("_rtc_debug_"))i.send(JSON.stringify(n));else{var a=pako_1.gzip(JSON.stringify(n));i.setRequestHeader("Content-Encoding","gzip"),i.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=UTF-8"),i.send(a)}}}},{key:"sucSend",value:function(){this.errSendDelay=100,this.preSucTime=Date.now(),this.sucSendTimer=setTimeout(this.send.bind(this),2e3)}},{key:"errSend",value:function(){var e=this;this.errSendTimer=setTimeout((function(){e.send(),e.errSendTimer=null}),this.errSendDelay),this.errSendDelay*=2}},{key:"StartUp",value:function(){var e=this.report_common,t=this.commonStats,r=t.event_key,n=t.device_id,i=t.rtc_app_id,o=t.product_line,a=t.report_version,s=t.os,c=t.rtc_sdk_version,u=t.rtc_timestamp,l=t.rtc_sdk_git_commit,d=t.report_id,p=t.rtc_sid,_=t.engine_session_id,f=t.rtc_business_id,h=t.project_key,m=t.network_type,y=t.app_version,v=t.aid,S=t.device_model,g=t.device_brand,E=t.common_extra_info,T=t.had_selected_p2p,b=t.rtc_env_type,R=t.user_agent,I=t.auto_play_policy;Object.assign(e,{event_key:r,device_id:n,rtc_app_id:i,product_line:o,report_version:a,os:s,rtc_sdk_version:c,rtc_timestamp:u,rtc_sdk_git_commit:l,report_id:d,rtc_sid:p,engine_session_id:_,rtc_business_id:f,project_key:h,network_type:m,app_version:y,aid:v,device_model:S,device_brand:g,common_extra_info:E,had_selected_p2p:T,rtc_env_type:b,user_agent:R,auto_play_policy:I}),this.commonStats.room_id&&(this.modify_ids.room_id=this.commonStats.room_id),this.commonStats.user_id&&(this.modify_ids.user_id=this.commonStats.user_id),this.commonStats.rtc_session_id&&(this.modify_ids.rtc_session_id=this.commonStats.rtc_session_id),this.commonStats.connection_id&&(this.modify_ids.connection_id=this.commonStats.connection_id)}},{key:"rtcSdkApiCall",value:function(e,t,r){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},i=_objectSpread2(_objectSpread2({event_key:"rtc_sdk_api_call",report_id:this.report_id++,rtc_timestamp:Date.now(),sdk_api_name:e,error_code:t,message:r},this.modify_ids),{},{common_extra_info:JSON.stringify(n)});this.push(i)}},{key:"rtcSdkCallback",value:function(e,t,r){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},i=_objectSpread2(_objectSpread2({event_key:"rtc_sdk_callback",report_id:this.report_id++,rtc_timestamp:Date.now(),sdk_callback_name:e,error_code:t,message:r},this.modify_ids),{},{common_extra_info:JSON.stringify(n)});this.push(i)}},{key:"rtcGetConfig",value:function(e,t,r,n,i,o,a){var s=arguments.length>7&&void 0!==arguments[7]?arguments[7]:{},c=_objectSpread2(_objectSpread2({event_key:"rtc_get_config",report_id:this.report_id++,rtc_timestamp:Date.now(),error_code:e,message:t,elapse:r,host:n,type:i,config_id:o,enable_cloud_proxy:a},this.modify_ids),{},{common_extra_info:JSON.stringify(s)});this.push(c)}},{key:"rtcReconnect",value:function(e,t,r,n){var i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{},o=_objectSpread2(_objectSpread2({event_key:"rtc_reconnect",report_id:this.report_id++,rtc_timestamp:Date.now(),error_code:e,message:t,reconnect_id:r,reconnect_type:n},this.modify_ids),{},{common_extra_info:JSON.stringify(i)});this.push(o)}},{key:"rtcReconnected",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n=_objectSpread2(_objectSpread2({event_key:"rtc_reconnected",report_id:this.report_id++,rtc_timestamp:Date.now(),message:e,reconnect_type:t},this.modify_ids),{},{common_extra_info:JSON.stringify(r)});this.push(n)}},{key:"rtcGetAccess",value:function(e,t,r,n,i,o){var a=arguments.length>6&&void 0!==arguments[6]?arguments[6]:{},s=_objectSpread2(_objectSpread2({event_key:"rtc_get_access",report_id:this.report_id++,rtc_timestamp:Date.now(),error_code:e,message:t,elapse:r,type:n,host:i,connect_session_id:o},this.modify_ids),{},{common_extra_info:JSON.stringify(a)});this.push(s)}},{key:"rtcPreIceState",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n=_objectSpread2(_objectSpread2({event_key:"rtc_pre_ice_state",report_id:this.report_id++,rtc_timestamp:Date.now(),message:e,ice_state:t},this.modify_ids),{},{common_extra_info:JSON.stringify(r)});this.push(n)}},{key:"rtcNodeChange",value:function(e,t,r){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},i=_objectSpread2(_objectSpread2({event_key:"rtc_node_change",report_id:this.report_id++,rtc_timestamp:Date.now(),error_code:e,message:t,reason:r},this.modify_ids),{},{common_extra_info:JSON.stringify(n)});this.push(i)}},{key:"rtcSignalingMsgError",value:function(e,t,r){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},i=_objectSpread2(_objectSpread2({event_key:"rtc_signaling_msg_error",report_id:this.report_id++,rtc_timestamp:Date.now(),error_code:e,message:t,reason:r},this.modify_ids),{},{common_extra_info:JSON.stringify(n)});this.push(i)}},{key:"rtcSignaling",value:function(e,t,r,n,i){var o=arguments.length>5&&void 0!==arguments[5]?arguments[5]:{},a=_objectSpread2(_objectSpread2({event_key:"rtc_signaling",report_id:this.report_id++,rtc_timestamp:Date.now(),error_code:e,message:t,signaling_event:r,signaling_type:n,direction:i},this.modify_ids),{},{common_extra_info:JSON.stringify(o)});this.push(a)}},{key:"rtcJoinRoom",value:function(e,t,r,n){var i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{},o=_objectSpread2(_objectSpread2({event_key:"rtc_join_room",report_id:this.report_id++,rtc_timestamp:Date.now(),error_code:e,deviceModel:t,deviceManufacturer:r,elapse:n},this.modify_ids),{},{common_extra_info:JSON.stringify(i)});this.push(o)}},{key:"rtcLeaveRoom",value:function(e,t,r){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},i=_objectSpread2(_objectSpread2({event_key:"rtc_leave_room",report_id:this.report_id++,rtc_timestamp:Date.now(),error_code:e,message:t,elapse:r},this.modify_ids),{},{common_extra_info:JSON.stringify(n)});this.push(i)}},{key:"rtcBeginCreateOffer",value:function(e,t,r){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},i=_objectSpread2(_objectSpread2({event_key:"rtc_begin_create_offer",report_id:this.report_id++,rtc_timestamp:Date.now(),direction:e,stream_id:t,stream_user_id:r},this.modify_ids),{},{common_extra_info:JSON.stringify(n)});this.push(i)}},{key:"rtcCreateOffer",value:function(e,t,r,n,i){var o=arguments.length>5&&void 0!==arguments[5]?arguments[5]:{},a=_objectSpread2(_objectSpread2({event_key:"rtc_create_offer",report_id:this.report_id++,rtc_timestamp:Date.now(),error_code:e,direction:t,stream_id:r,stream_user_id:n,elapse:i},this.modify_ids),{},{common_extra_info:JSON.stringify(o)});this.push(a)}},{key:"rtcSetDescription",value:function(e,t,r,n,i,o,a){var s=arguments.length>7&&void 0!==arguments[7]?arguments[7]:{},c=_objectSpread2(_objectSpread2({event_key:"rtc_set_description",report_id:this.report_id++,rtc_timestamp:Date.now(),error_code:e,message:t,is_local:r,direction:n,stream_id:i,stream_user_id:o,elapse:a},this.modify_ids),{},{common_extra_info:JSON.stringify(s)});this.push(c)}},{key:"rtcRecvAnswer",value:function(e,t,r,n,i,o,a){var s=arguments.length>7&&void 0!==arguments[7]?arguments[7]:{},c=_objectSpread2(_objectSpread2({event_key:"rtc_recv_answer",report_id:this.report_id++,rtc_timestamp:Date.now(),error_code:e,answer_type:t,sequence_id:r,message:n,direction:i,stream_id:o,stream_user_id:a},this.modify_ids),{},{common_extra_info:JSON.stringify(s)});this.push(c)}},{key:"firstRemoteAudioRender",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n=_objectSpread2(_objectSpread2({event_key:"first_remote_audio_render",report_id:this.report_id++,rtc_timestamp:Date.now(),stream_id:e,stream_user_id:t},this.modify_ids),{},{common_extra_info:JSON.stringify(r)});this.push(n)}},{key:"firstRemoteVideoRender",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n=_objectSpread2(_objectSpread2({event_key:"first_remote_video_render",report_id:this.report_id++,rtc_timestamp:Date.now(),stream_id:e,stream_user_id:t},this.modify_ids),{},{common_extra_info:JSON.stringify(r)});this.push(n)}},{key:"rtcPublishStat",value:function(e,t,r,n){var i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{},o=_objectSpread2(_objectSpread2({event_key:"rtc_publish_stat",report_id:this.report_id++,rtc_timestamp:Date.now(),result:e,is_screen:t,start:r,message:n},this.modify_ids),{},{common_extra_info:JSON.stringify(i)});this.push(o)}},{key:"rtcSubscribeStat",value:function(e,t,r,n){var i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{},o=_objectSpread2(_objectSpread2({event_key:"rtc_subscribe_stat",report_id:this.report_id++,rtc_timestamp:Date.now(),result:e,start:t,message:r,stream_user_id:n},this.modify_ids),{},{common_extra_info:JSON.stringify(i)});this.push(o)}},{key:"rtcAudioDevice",value:function(e,t,r){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},i=_objectSpread2(_objectSpread2({event_key:"rtc_audio_device",report_id:this.report_id++,rtc_timestamp:Date.now(),audio_event:e,message:t,error_code:r},this.modify_ids),{},{common_extra_info:JSON.stringify(n)});this.push(i)}},{key:"rtcMediaStatistics",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n=_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2({event_key:"rtc_media_statistics",report_id:this.report_id++,rtc_timestamp:Date.now()},e),t),this.modify_ids),{},{common_extra_info:JSON.stringify(r)});this.push(n)}},{key:"rtcMessageStatistics",value:function(e,t,r){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},i=_objectSpread2(_objectSpread2({event_key:"rtc_message_statistics",report_id:this.report_id++,rtc_timestamp:Date.now(),dc_user_message:e,dc_room_message:t,media_server_ip:r},this.modify_ids),{},{common_extra_info:JSON.stringify(n)});this.push(i)}},{key:"rtcError",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n=_objectSpread2(_objectSpread2({event_key:"rtc_error",report_id:this.report_id++,rtc_timestamp:Date.now(),message:e,error_code:t},this.modify_ids),{},{common_extra_info:JSON.stringify(r)});this.push(n)}},{key:"rtcInvokeStatus",value:function(e,t,r,n,i){var o=arguments.length>5&&void 0!==arguments[5]?arguments[5]:{},a=_objectSpread2(_objectSpread2({event_key:"rtc_invoke_status",report_id:this.report_id++,rtc_timestamp:Date.now(),message:e,error_code:t,sdk_api_name:r,stream_id:n,elapse:i},this.modify_ids),{},{common_extra_info:JSON.stringify(o)});this.push(a)}},{key:"rtcFirstFrame",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=_objectSpread2(_objectSpread2(_objectSpread2({event_key:"rtc_first_frame",report_id:this.report_id++,rtc_timestamp:Date.now()},e),this.modify_ids),{},{common_extra_info:JSON.stringify(t)});this.push(r)}},{key:"rtcMuteRemote",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n=_objectSpread2(_objectSpread2({event_key:"rtc_mute_remote",report_id:this.report_id++,rtc_timestamp:Date.now(),mute_info:e,media_type:t},this.modify_ids),{},{common_extra_info:JSON.stringify(r)});this.push(n)}},{key:"sdkInitEngine",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n=_objectSpread2(_objectSpread2({event_key:"sdk_init_engine",report_id:this.report_id++,rtc_timestamp:Date.now(),start:e,type:t},this.modify_ids),{},{common_extra_info:JSON.stringify(r)});this.push(n)}},{key:"joinRoom",value:function(e,t,r,n){var i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{},o=_objectSpread2(_objectSpread2({event_key:"join_room",report_id:this.report_id++,rtc_timestamp:Date.now(),type:e,start:t,result:r,reason:n},this.modify_ids),{},{common_extra_info:JSON.stringify(i)});this.push(o)}},{key:"p2pConnectionStatus",value:function(e,t,r,n,i){var o=arguments.length>5&&void 0!==arguments[5]?arguments[5]:{},a=_objectSpread2(_objectSpread2({event_key:"p2p_connection_status",report_id:this.report_id++,rtc_timestamp:Date.now(),room_id:e,user_id:t,peer_user_id:r,status:n,elapse:i},this.modify_ids),{},{common_extra_info:JSON.stringify(o)});this.push(a)}},{key:"p2pConnectClosed",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=_objectSpread2(_objectSpread2({event_key:"p2p_connect_closed",report_id:this.report_id++,rtc_timestamp:Date.now(),p2p_selected:e},this.modify_ids),{},{common_extra_info:JSON.stringify(t)});this.push(r)}},{key:"rtcDeviceError",value:function(e,t,r,n,i,o,a,s,c,u,l,d,p,_,f,h){var m=arguments.length>16&&void 0!==arguments[16]?arguments[16]:{},y=_objectSpread2(_objectSpread2({event_key:"rtc_device_error",report_id:this.report_id++,rtc_timestamp:Date.now(),device_type:e,device_stage:t,error_code:r,system_error_code:n,system_api:i,call_parameters:o,location:a,message:s,media_device_id:c,media_device_name:u,elapse:l,scenario:d,event_session_id:p,device_pid:_,device_vid:f,media_mode:h},this.modify_ids),{},{common_extra_info:JSON.stringify(m)});this.push(y)}},{key:"rtcVideoDevice",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n=_objectSpread2(_objectSpread2({event_key:"rtc_video_device",report_id:this.report_id++,rtc_timestamp:Date.now(),media_device_id:e,media_device_name:t},this.modify_ids),{},{common_extra_info:JSON.stringify(r)});this.push(n)}},{key:"rtcVideoCaptureEvent",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=_objectSpread2(_objectSpread2(_objectSpread2({event_key:"rtc_video_capture_event",report_id:this.report_id++,rtc_timestamp:Date.now()},e),this.modify_ids),{},{common_extra_info:JSON.stringify(t)});this.push(r)}},{key:"rtcEncodeFirstFrame",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n=_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2({event_key:"rtc_encode_first_frame",report_id:this.report_id++,rtc_timestamp:Date.now()},e),t),this.modify_ids),{},{common_extra_info:JSON.stringify(r)});this.push(n)}},{key:"rtcFirstFrameEncoded",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n=_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2({event_key:"rtc_first_frame_encoded",report_id:this.report_id++,rtc_timestamp:Date.now()},e),t),this.modify_ids),{},{common_extra_info:JSON.stringify(r)});this.push(n)}},{key:"rtcSendFirstPacket",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n=_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2({event_key:"rtc_send_first_packet",report_id:this.report_id++,rtc_timestamp:Date.now()},e),t),this.modify_ids),{},{common_extra_info:JSON.stringify(r)});this.push(n)}},{key:"rtcRecvFirstPacket",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n=_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2({event_key:"rtc_recv_first_packet",report_id:this.report_id++,rtc_timestamp:Date.now()},e),t),this.modify_ids),{},{common_extra_info:JSON.stringify(r)});this.push(n)}},{key:"rtcRecvFirstFrame",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n=_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2({event_key:"rtc_recv_first_frame",report_id:this.report_id++,rtc_timestamp:Date.now()},e),t),this.modify_ids),{},{common_extra_info:JSON.stringify(r)});this.push(n)}},{key:"rtcDecodeFirstFrame",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n=_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2({event_key:"rtc_decode_first_frame",report_id:this.report_id++,rtc_timestamp:Date.now()},e),t),this.modify_ids),{},{common_extra_info:JSON.stringify(r)});this.push(n)}}]),r}(),monitor=new Monitor,rtmMonitor=new Monitor,outsideRoomMonitor=new Monitor,commonStats=monitor.commonStats,rtmCommonStats=rtmMonitor.commonStats,outsideRoomCommonStats=outsideRoomMonitor.commonStats,monitorMap={default:monitor,rtm:rtmMonitor,outsideRoom:outsideRoomMonitor};function reportRtcSdkApiCall(){for(var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"default",t=arguments.length,r=new Array(t>1?t-1:0),n=1;n<t;n++)r[n-1]=arguments[n];return function(t,n,i){if("function"==typeof i.value){var o=i.value;i.value=function(){for(var t=arguments.length,i=new Array(t),a=0;a<t;a++)i[a]=arguments[a];var s={};r.forEach((function(e,t){s[e]=i[t]})),"joinRoom"===n&&commonStats.setStats({room_id:i[1]}),monitorMap[e].rtcSdkApiCall(n,0,JSON.stringify(reportParamsCheck(i)),s);var c=o.apply(this,i);return"function"==typeof(null==c?void 0:c.then)?c.then((function(t){return monitorMap[e].rtcSdkCallback(n,0,JSON.stringify(reportParamsCheck([t||{}]))),t})).catch((function(t){throw monitorMap[e].rtcSdkCallback(n,t.code,JSON.stringify(t.message)),t})):(monitorMap[e].rtcSdkCallback(n,0,JSON.stringify(reportParamsCheck([c||{}]))),c)}}}}function reportRtcSdkCallback(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,n=e===EngineEventsTypes.onUserMessageReceivedOutsideRoom||e===EngineEventsTypes.onUserBinaryMessageReceivedOutsideRoom;(n?rtmMonitor:monitor).rtcSdkCallback(e,r,JSON.stringify(t))}function reportRtcInvokeStatus(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,n=arguments.length>3&&void 0!==arguments[3]&&arguments[3];(n?rtmMonitor:monitor).rtcInvokeStatus(JSON.stringify(t),r,e,"",0)}var PLATFORM_KEY="BytePlus",RTC_DEVICE_ID="RTC_DEVICE_ID",RTC_ACCESS_NODE="RTC_ACCESS_NODE",RTC_ACCESS_URLS="RTC_ACCESS_URLS",RTC_H264_BLACK_LIST="RTC_H264_BLACK_LIST",RTC_AUDIO_PROFILE="engine_BAC",Cache=function(){function e(){_classCallCheck(this,e)}return _createClass(e,[{key:"get",value:function(e){var t=localStorage.getItem(e);if(!t)return null;try{var r=JSON.parse(t);return r.ttl>0&&Date.now()-r.saveTime>r.ttl?(this.delete(e),null):r.message}catch(e){return null}}},{key:"set",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:-1,n={ttl:r,saveTime:Date.now(),message:t};try{return localStorage.setItem(e,JSON.stringify(n)),!0}catch(e){return!1}}},{key:"delete",value:function(e){try{return localStorage.removeItem(e),!0}catch(e){return!1}}}]),e}(),SDKCache=function(e){_inherits(r,Cache);var t=_createSuper(r);function r(){return _classCallCheck(this,r),t.apply(this,arguments)}return _createClass(r,[{key:"getDeviceId",value:function(){if(isSSR())return"";var e=this.get(RTC_DEVICE_ID);return e||(e=v4()),this.set(RTC_DEVICE_ID,e),e}},{key:"setDeviceId",value:function(e){return[commonStats,rtmCommonStats,outsideRoomCommonStats].forEach((function(t){return t.setStats({device_id:e})})),this.set(RTC_DEVICE_ID,e),e}},{key:"getAccessNode",value:function(e){return this.get("".concat(RTC_ACCESS_NODE,"_").concat(e,"-").concat(PLATFORM_KEY))}},{key:"setAccessNode",value:function(e,t,r){return this.set("".concat(RTC_ACCESS_NODE,"_").concat(e,"-").concat(PLATFORM_KEY),t,1e3*r)}},{key:"clearAccessNode",value:function(e){this.delete("".concat(RTC_ACCESS_NODE,"_").concat(e,"-").concat(PLATFORM_KEY))}},{key:"getAccessUrls",value:function(){return this.get("".concat(RTC_ACCESS_URLS,"-").concat(PLATFORM_KEY))}},{key:"setAccessUrls",value:function(e){var t=e.map((function(e){var t=e.host,r=e.path;return"https://".concat(t).concat(r)}));return this.set("".concat(RTC_ACCESS_URLS,"-").concat(PLATFORM_KEY),t)}},{key:"clearAccessUrls",value:function(){this.delete("".concat(RTC_ACCESS_URLS,"-").concat(PLATFORM_KEY))}},{key:"getH264BlackList",value:function(){return this.get(RTC_H264_BLACK_LIST)}},{key:"setH264BlackList",value:function(e){return this.set(RTC_H264_BLACK_LIST,e)}},{key:"getAudioProfile",value:function(){return this.get(RTC_AUDIO_PROFILE)}},{key:"setAudioProfile",value:function(e){return this.set(RTC_AUDIO_PROFILE,e)}}]),r}(),sdkCache=new SDKCache,internalAccessDomains="rtc-access.rtcplus.com,rtc-access-sg.rtcplus.com,rtc-access-va.rtcplus.com,rtc-access-fr.rtcplus.com".split(",");function getFullAccessUrl(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return/^https?:\/\/.+/.test(e)||(e="https://"+e),"".concat(e,"/dispatch/v1/AccessInfo?Action=GetAccessInfo")}function getFullLogServerUrl(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return/^https?:\/\/.+/.test(e)||(e="https://"+e),"".concat(e,"/video/v1/webrtc_log/")}var domesticLogServerUrl="https://web-log-report.rtcplus.com/video/v1/webrtc_log/",overseasLogServerUrl="https://web-log-report.rtcplus.com/video/v1/webrtc_log/",configDomains="rtc.rtcplus.com".split(","),Config={VERSION:"4.46.11",ICE_CONFIG_REQUEST_URLS_INTERNAL:internalAccessDomains.map(getFullAccessUrl),ICE_CONFIG_REQUEST_URLS:[],EXPECTED_ADDR:"",LOG_SERVER_URL:domesticLogServerUrl,CONFIG_REQUEST_DOMAINS:configDomains,DEVICE_ID:"",OVERSEA:!1};function setParameter(e,t){if("VERSION"!==e)return"ICE_CONFIG_REQUEST_URLS"===e?("string"==typeof t&&(t=[t]),void(Config.ICE_CONFIG_REQUEST_URLS=t.map(getFullAccessUrl))):void("LOG_SERVER_URL"!==e||t!==LogChannel.overseas?"LOG_SERVER_URL"!==e||t!==LogChannel.domestic?"LOG_SERVER_URL"!==e||"string"!=typeof t?"OVERSEA"!==e?("DEVICE_ID"===e&&sdkCache.setDeviceId(t),Config[e]=t):Config.OVERSEA=t:Config.LOG_SERVER_URL=t:Config.LOG_SERVER_URL=domesticLogServerUrl:Config.LOG_SERVER_URL=overseasLogServerUrl)}function getParameter(e){return"DEVICE_ID"===e?sdkCache.getDeviceId():Config[e]}function getTranscodeControlMessage(e,t){var r,n,i,o,a,s,c,u,l,d,p,_,f,h,m,y,v;return{type:"transcode",action:e,transcodeMeta:{transcode:{url:t.url},control:{protocol:"2.0"},audio:{codec:(null===(r=t.audio)||void 0===r?void 0:r.codec)||defaultTranscoding.audio.codec,bitRate:1e3*((null===(n=t.audio)||void 0===n?void 0:n.kBitRate)||defaultTranscoding.audio.kBitRate),sampleRate:1e3*((null===(i=t.audio)||void 0===i?void 0:i.sampleRate)||defaultTranscoding.audio.sampleRate),channels:(null===(o=t.audio)||void 0===o?void 0:o.channels)||defaultTranscoding.audio.channels,profile:(null===(a=t.audio)||void 0===a?void 0:a.AACProfile)||defaultTranscoding.audio.AACProfile},video:{codec:(null===(s=t.video)||void 0===s?void 0:s.codec)||defaultTranscoding.video.codec,fps:(null===(c=t.video)||void 0===c?void 0:c.fps)||defaultTranscoding.video.fps,gop:(null===(u=t.video)||void 0===u?void 0:u.gop)||defaultTranscoding.video.gop,lowLatency:null!==(l=null===(d=t.video)||void 0===d?void 0:d.lowLatency)&&void 0!==l?l:defaultTranscoding.video.lowLatency,bitRate:1e3*((null===(p=t.video)||void 0===p?void 0:p.kBitRate)||defaultTranscoding.video.kBitRate),width:(null===(_=t.video)||void 0===_?void 0:_.width)||defaultTranscoding.video.width,height:(null===(f=t.video)||void 0===f?void 0:f.height)||defaultTranscoding.video.height},layout:{canvas:{bgnd:(null===(h=t.layout)||void 0===h?void 0:h.backgroundColor)||defaultTranscoding.layout.backgroundColor},regions:(null===(m=t.layout)||void 0===m||null===(y=m.regions)||void 0===y?void 0:y.map((function(e){return{alpha:Math.min(Math.max(+e.alpha,0),1),uid:e.userId,zorder:e.zorder,x:Math.min(Math.max(+e.x,0),1),y:Math.min(Math.max(+e.y,0),1),w:Math.min(Math.max(+e.w,0),1),h:Math.min(Math.max(+e.h,0),1),renderMode:e.renderMode||1,contentControl:e.contentControl||0,screen:e.isScreenStream,local_user:e.isLocalUser}})))||[],app_data:(null===(v=t.layout)||void 0===v?void 0:v.appData)||defaultTranscoding.layout.appData}}}}function getPublicStreamControlMessage(e,t,r){var n,i,o,a,s,c,u,l,d;return{type:"publicstream",action:t,publicStreamID:e,publicStreamMeta:{audio:{},video:{fps:(null===(n=r.video)||void 0===n?void 0:n.fps)||15,bitrate:1e3*((null===(i=r.video)||void 0===i?void 0:i.kBitRate)||40),width:(null===(o=r.video)||void 0===o?void 0:o.width)||640,height:(null===(a=r.video)||void 0===a?void 0:a.height)||360},layout:{layoutMode:2,interpolationMode:(null===(s=r.layout)||void 0===s?void 0:s.interpolationMode)||PublicInterpolationMode.PREV_FRAME,canvas:{bgColor:(null===(c=r.layout)||void 0===c?void 0:c.backgroundColor)||"#000000",bgImage:(null===(u=r.layout)||void 0===u?void 0:u.backgroundImage)||""},regions:(null===(l=r.layout)||void 0===l||null===(d=l.regions)||void 0===d?void 0:d.map((function(e){return{roomId:e.roomId,userId:e.userId,alterImage:e.alertImage||"",alpha:e.alpha,x:Math.min(Math.max(+e.x,0),1),y:Math.min(Math.max(+e.y,0),1),w:Math.min(Math.max(+e.w,0),1),h:Math.min(Math.max(+e.h,0),1),zorder:e.zorder,renderMode:void 0===e.renderMode?1:e.renderMode,streamType:e.isScreenStream?1:0,mediaType:e.mediaType||0,sourceCrop:e.sourceCrop}})))||[]}}}}var _USER_MESSAGE_SEND_RE,defaultTranscoding={url:"",video:{codec:"H264",width:640,height:360,fps:30,gop:60,kBitRate:600,lowLatency:!0},audio:{codec:"AAC",kBitRate:64,sampleRate:48,channels:2,AACProfile:"LC"},layout:{regions:[],appData:"",backgroundColor:"#000000"}},defaultVideoEncoderConfig={width:640,height:360,frameRate:30,maxKbps:600},defaultScreenEncoderConfig={width:1920,height:1080,frameRate:15,maxKbps:3e3},RemoveStreamMessage=function(e){return e.streamRemovedBySchedule308="stream removed",e.clientRePublish="client republish",e.publishStreamFaied="publish failed",e.clientUnPublish="client unpublished",e.clientDisconnected="client disconnected",e.videoMuted="video muted",e}(RemoveStreamMessage||{}),StreamControlType=function(e){return e.PushLimitWarn="PushLimitWarn",e}(StreamControlType||{}),SignalEvent=function(e){return e.ON_ADD_STREAM="onAddStream",e.ON_REMOVE_STREAM="onRemoveStream",e.USER_DISCONNECTION="userDisconnection",e.USER_CONNECTION="userConnection",e.ON_UPDATE_STREAM_ATTRIBUTES="onUpdateStreamAttributes",e.ON_UPDATE_ROOM_ATTRIBUTES="onUpdateRoomAttributes",e.ON_UPDATE_USER_ATTRIBUTES="onUpdateUserAttributes",e.ON_PUSH_TRACK="onPushTrack",e.ON_REMOVE_TRACK="onRemoveTrack",e.ON_CUSTOM_MESSAGE="onCustomMessage",e.NODE_CHANGE="nodeChange",e.USER_MESSAGE_RECEIVED="userMessageReceived",e.USER_BINARY_MESSAGE_RECEIVED="userBinaryMessageReceived",e.USER_MESSAGE_RECEIVED_OUTSIDE_ROOM="userMessageReceivedOutsideRoom",e.USER_BINARY_MESSAGE_RECEIVED_OUTSIDE_ROOM="userBinaryMessageReceivedOutsideRoom",e.POST_PROCESSING_MESSAGE="postProcessingMessage",e.ON_USER_TOKEN_WILL_EXPIRE="onUserTokenWillExpire",e.STREAM_CONTROL_MESSAGE="streamControlMessage",e.ON_SCENE_CONFIG="onSceneConfig",e}(SignalEvent||{}),MediaServerSignalEvent=function(e){return e.RSCP="RSCP",e}(MediaServerSignalEvent||{}),StateEvent=function(e){return e.ON_CONNECTION_STATE_CHANGE="onConnectionStateChange",e.ABNORMAL_DISCONNECTION="normalConnection",e}(StateEvent||{}),UserDisconnectionTag=function(e){return e.userLeave="userLeave",e.connectionLost="connectionLost",e.userDuplicateLogin="userDuplicateLogin",e.kickedByAdmin="kickedByAdmin",e.roleChanged="roleChanged",e.onUserTokenDidExpire="onUserTokenDidExpire",e}(UserDisconnectionTag||{}),UserDisconnectionCode=function(e){return e[e.roomDismissByAdmin=2]="roomDismissByAdmin",e}(UserDisconnectionCode||{}),DC_MESSAGE_DIRECTION=function(e){return e[e.SEND=0]="SEND",e[e.FEEDBACK=1]="FEEDBACK",e}(DC_MESSAGE_DIRECTION||{}),DC_MESSAGE_FUNCTION_TYPE=function(e){return e[e.P2P=0]="P2P",e[e.SIGNAL=1]="SIGNAL",e[e.BROADCAST=2]="BROADCAST",e[e.BUSINESS_SERVER=3]="BUSINESS_SERVER",e}(DC_MESSAGE_FUNCTION_TYPE||{}),USER_MESSAGE_SEND_RESULT=function(e){return e[e.SUCCESS=0]="SUCCESS",e[e.TIMEOUT=1]="TIMEOUT",e[e.BROKEN=2]="BROKEN",e[e.NO_RECEIVER=3]="NO_RECEIVER",e[e.NO_RELAYPATH=4]="NO_RELAYPATH",e[e.SEND_TO_SERVER_ERROR=17]="SEND_TO_SERVER_ERROR",e[e.SERVER_RESPONSE_ERROR=18]="SERVER_RESPONSE_ERROR",e[e.NOT_JOIN=100]="NOT_JOIN",e[e.INIT=101]="INIT",e[e.NO_CONNECTION=102]="NO_CONNECTION",e[e.NOT_LOGIN=105]="NOT_LOGIN",e[e.SERVER_PARAMS_NOTSET=106]="SERVER_PARAMS_NOTSET",e[e.UNKNOWN=1e3]="UNKNOWN",e}(USER_MESSAGE_SEND_RESULT||{}),USER_MESSAGE_SEND_RESULT_EXPLAIN=(_defineProperty(_USER_MESSAGE_SEND_RE={},0,[0,"success"]),_defineProperty(_USER_MESSAGE_SEND_RE,1,[ErrorCode.USER_MESSAGE_TIMEOUT,"timeout, failed to send."]),_defineProperty(_USER_MESSAGE_SEND_RE,2,[ErrorCode.USER_MESSAGE_BROKEN,"dataChannel broken, failed to send."]),_defineProperty(_USER_MESSAGE_SEND_RE,3,[ErrorCode.USER_MESSAGE_NO_RECEIVER,"cannot find the receiver."]),_defineProperty(_USER_MESSAGE_SEND_RE,4,[ErrorCode.USER_MESSAGE_NO_RELAYPATH,"cannot find relay path."]),_defineProperty(_USER_MESSAGE_SEND_RE,17,[ErrorCode.USER_MESSAGE_SEND_TO_SERVER_ERROR,"failed to send to business server."]),_defineProperty(_USER_MESSAGE_SEND_RE,18,[ErrorCode.USER_MESSAGE_SERVER_RESPONSE_ERROR,"business server response error."]),_defineProperty(_USER_MESSAGE_SEND_RE,100,[ErrorCode.USER_MESSAGE_NOT_JOIN,"not join room"]),_defineProperty(_USER_MESSAGE_SEND_RE,101,[ErrorCode.USER_MESSAGE_INIT,"not init."]),_defineProperty(_USER_MESSAGE_SEND_RE,102,[ErrorCode.USER_MESSAGE_NO_CONNECTION,"no connection."]),_defineProperty(_USER_MESSAGE_SEND_RE,105,[ErrorCode.USER_MESSAGE_NOT_LOGIN,"not login."]),_defineProperty(_USER_MESSAGE_SEND_RE,106,[ErrorCode.USER_MESSAGE_SERVER_PARAMS_NOTSET,"server param is not set."]),_defineProperty(_USER_MESSAGE_SEND_RE,1e3,[ErrorCode.USER_MESSAGE_UNKNOWN,"unknown."]),_USER_MESSAGE_SEND_RE),_excluded=["msg"],logger$h=new Logger("DataChannelSignaling",3),SIGNALING_FUNCTION_TYPE=function(e){return e[e.C2S=0]="C2S",e[e.C2C=1]="C2C",e[e.C2GW=2]="C2GW",e[e.C2CDirect=3]="C2CDirect",e[e.C2RTM=4]="C2RTM",e}(SIGNALING_FUNCTION_TYPE||{}),DATA_CHANNEL_MESSAGE_TIMEOUT=6e4,DataChannelSignaling=function(e){_inherits(i,eventemitter3.exports.EventEmitter);var t,r,n=_createSuper(i);function i(e){var t;return _classCallCheck(this,i),_defineProperty(_assertThisInitialized(t=n.call(this)),"_singlingCache",new Map),_defineProperty(_assertThisInitialized(t),"_p2pCache",new Map),_defineProperty(_assertThisInitialized(t),"_rttIds",{}),_defineProperty(_assertThisInitialized(t),"_p2pMessageId",0),_defineProperty(_assertThisInitialized(t),"_clearDataChannelListener",void 0),t._dataChannel=e,t._clearDataChannelListener=t._handleHandler(),window.__rtc_mock_signaling__=t.emit.bind(_assertThisInitialized(t)),t}return _createClass(i,[{key:"destroy",value:function(){this._dataChannel&&(this._clearDataChannelListener(),this._dataChannel.close()),this._singlingCache.clear(),this._p2pCache.clear(),this._p2pMessageId=0,this._rttIds={}}},{key:"sendSignaling",value:function(e,t,r){var n=this;return monitor.rtcSignaling(0,JSON.stringify(t),"call-".concat(e),"Send",RtcsignalingDirection.UP),new Promise((function(i,o){var a=n._genHeader(r);a.id=createRandomId();var s=a.id.join("-"),c=setTimeout((function(){n._singlingCache.delete(s),o(new SDKError(ErrorCode.TIME_OUT,"".concat(e," message time out")))}),DATA_CHANNEL_MESSAGE_TIMEOUT);n._singlingCache.set(s,{signalingType:e,success:function(e){clearTimeout(c),i(e)},error:function(e){clearTimeout(c),o(e)}}),logger$h.print("Signal",">>>>>> [".concat(e,"][").concat(s,"]"),t),n._sendMessage(e,a,t)}))}},{key:"sendPingSignaling",value:function(){return this.sendSignaling("CheckConnectivity",{ts:Date.now()},{functionType:2})}},{key:"sendP2PMessage",value:(r=_asyncToGenerator(_regeneratorRuntime().mark((function e(t,r){var n,i,o;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=t.msg,i=_objectWithoutProperties(t,_excluded),o=n instanceof ArrayBuffer,e.t0=this,e.t1=_objectSpread2,e.t2=_objectSpread2({ver:1,id:this._p2pMessageId++,time:Date.now(),dir:DC_MESSAGE_DIRECTION.SEND,type:DC_MESSAGE_FUNCTION_TYPE.P2P,err:USER_MESSAGE_SEND_RESULT.SUCCESS},i),e.t3={},e.t4=o,!o){e.next=13;break}return e.next=10,Utils.ab2b64str(n);case 10:e.t5=e.sent,e.next=14;break;case 13:e.t5=n;case 14:return e.t6=e.t5,e.t7={binary:e.t4,msg:e.t6},e.t8=(0,e.t1)(e.t2,e.t3,e.t7),e.t9=r,e.abrupt("return",e.t0._sendP2PMessage.call(e.t0,e.t8,e.t9));case 19:case"end":return e.stop()}}),e,this)}))),function(e,t){return r.apply(this,arguments)})},{key:"_sendP2PMessage",value:function(e){var t=this,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return isRttMessage(e.msg)?this._rttIds[e.id]=e.id:e.dir===DC_MESSAGE_DIRECTION.SEND&&logger$h.print("_sendP2PMessage [DC Signaling p2p >>]",JSON.stringify(e)),new Promise((function(n,i){var o=t._genHeader(_objectSpread2(_objectSpread2({needAck:!0,functionType:1},r),{},{id:createRandomId()}));if(e.dir===DC_MESSAGE_DIRECTION.SEND){var a=setTimeout((function(){t._p2pCache.delete(e.id),i(new SDKError(ErrorCode.TIME_OUT,"P2P message timeout"))}),DATA_CHANNEL_MESSAGE_TIMEOUT);t._p2pCache.set(e.id,{success:function(e,t){clearTimeout(a),n(t)},error:function(e){clearTimeout(a);var t=_slicedToArray(USER_MESSAGE_SEND_RESULT_EXPLAIN[e.err]||[ErrorCode.USER_MESSAGE_UNKNOWN,"err: ".concat(e.err,", msg: ").concat(e.msg)],2),r=t[0],n=t[1];i({code:r,message:e.msg||n})}})}t._sendMessage("p2p",o,e)}))}},{key:"_sendMessage",value:function(e,t,r){if(!this._dataChannel||"open"!==this._dataChannel.readyState)throw new SDKError(ErrorCode.SIGNALING_CHANNEL_NOT_OPEN,"DataChannel not open");var n=t.version+(+t.zip<<5)+(+t.encrypt<<6),i=+t.needAck+(+t.direction<<1)+(+t.functionType<<2)+(+t.binary<<6),o=Utils.str2ab(JSON.stringify([e,r])),a=concatenate(Uint8Array,[n,i].concat(_toConsumableArray(t.id||[])),new Uint8Array(o));this._dataChannel.send(a.buffer)}},{key:"_dispartData",value:function(e){var t=new Uint8Array(e),r=0,n=t[r++],i=t[r++],o={version:15&n,zip:16==(16&n),encrypt:32==(32&n),needAck:1==(1&i),direction:(2&i)>>1,functionType:(60&i)>>2,binary:64==(64&i)};if(o.needAck||1===o.direction){for(;r<=6;r++)if(!isByteId(t[r])){r++;break}o.id=Array.from(t.slice(2,r))}return{header:o,data:t.slice(r)}}},{key:"_feedbackSignaling",value:function(e,t){var r=this._genHeader({needAck:!0,direction:1,id:e.split("-").map((function(e){return+e}))});logger$h.print("Signal",">>>>>> [".concat(t,"-res][").concat(e,"]")),this._sendMessage("".concat(t,"-res"),r,"")}},{key:"_handleMessage",value:(t=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){var r,n,i,o,a,s,c,u,l,d,p,_,f,h,m,y,v,S,g,E,T,b,R,I,$,A,C,O,P,k,w;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:s=this._dispartData(t),c=s.data,(u=s.header).zip&&((l=new pako_1.Inflate).push(c,!0),c=l.result),d=Utils.ab2str(c),p=[],e.prev=6,p=JSON.parse(d),e.next=14;break;case 10:return e.prev=10,e.t0=e.catch(6),e.t0 instanceof Error&&monitor.rtcSignalingMsgError(-1,e.t0.message,RtcsignalingmsgerrorReason.MESSAGE_PARSE_FAILED),e.abrupt("return");case 14:e.t1=u.functionType,e.next=0===e.t1?17:1===e.t1?34:2===e.t1?83:99;break;case 17:if(_=(null===(r=u.id)||void 0===r?void 0:r.join("-"))||"",1!==u.direction){e.next=22;break}this._handleAckMessage(_,p[0]||{},d),e.next=33;break;case 22:if(!Array.isArray(p)){e.next=33;break}if(f=p[0],p=p[1],logger$h.print("Signal","<<<<<< ".concat(f),p,_),this._feedbackSignaling(_,f),!p.binary||"string"!=typeof p.message){e.next=31;break}return e.next=30,Utils.b64str2ab(p.message);case 30:p.message=e.sent;case 31:this.emit(f,_objectSpread2({},p)),monitor.rtcSignaling(0,d,"on-".concat(f),"Recv",RtcsignalingDirection.DOWN);case 33:return e.abrupt("break",100);case 34:Array.isArray(p)&&(p=p[1]),h=null===(n=p)||void 0===n?void 0:n.id,this._rttIds[h]||(null===(i=p)||void 0===i?void 0:i.dir)===DC_MESSAGE_DIRECTION.FEEDBACK||isRttMessage(null===(o=p)||void 0===o?void 0:o.msg)?delete this._rttIds[h]:logger$h.print("Signal","<<<<<< p2p response",p),e.t2=p.dir,e.next=e.t2===DC_MESSAGE_DIRECTION.SEND?40:e.t2===DC_MESSAGE_DIRECTION.FEEDBACK?78:81;break;case 40:if(isRttMessage(null===(a=p)||void 0===a?void 0:a.msg)){e.next=76;break}if(y=(m=p).binary,v=m.msg,S=m.room,g=m.to,E=m.from,T=""===S?y?SignalEvent.USER_BINARY_MESSAGE_RECEIVED_OUTSIDE_ROOM:SignalEvent.USER_MESSAGE_RECEIVED_OUTSIDE_ROOM:y?SignalEvent.USER_BINARY_MESSAGE_RECEIVED:SignalEvent.USER_MESSAGE_RECEIVED,g){e.next=60;break}if(e.t3=this,e.t4=SignalEvent.ON_CUSTOM_MESSAGE,e.t5=E,e.t6=y,!y){e.next=54;break}return e.next=51,Utils.b64str2ab(v);case 51:e.t7=e.sent,e.next=55;break;case 54:e.t7=v;case 55:e.t8=e.t7,e.t9={clientId:e.t5,binary:e.t6,message:e.t8},e.t3.emit.call(e.t3,e.t4,e.t9),e.next=76;break;case 60:if(e.t10=this,e.t11=T,e.t12=_objectSpread2,e.t13=_objectSpread2({},p),e.t14={},!y){e.next=71;break}return e.next=68,Utils.b64str2ab(v);case 68:e.t15=e.sent,e.next=72;break;case 71:e.t15=v;case 72:e.t16=e.t15,e.t17={msg:e.t16},e.t18=(0,e.t12)(e.t13,e.t14,e.t17),e.t10.emit.call(e.t10,e.t11,e.t18);case 76:return this._sendP2PMessage(_objectSpread2(_objectSpread2({},p),{},{dir:DC_MESSAGE_DIRECTION.FEEDBACK,msg:""})),e.abrupt("break",82);case 78:return(b=this._p2pCache.get(p.id))&&(this._p2pCache.delete(p.id),p.err===USER_MESSAGE_SEND_RESULT.SUCCESS?b.success(p.id,p):b.error(p)),e.abrupt("break",82);case 81:return e.abrupt("break",82);case 82:return e.abrupt("break",100);case 83:if(1!==u.direction){e.next=88;break}I=(null===(R=u.id)||void 0===R?void 0:R.join("-"))||"",this._handleAckMessage(I,p[0]||{},d),e.next=98;break;case 88:if($=_slicedToArray(p,2),A=$[0],C=$[1],O=void 0===C?{}:C,"RXMediaMsg"!==A){e.next=98;break}P=O.type,k=O.data,monitor.rtcSignaling(0,d,"on-".concat(P),"Recv",RtcsignalingDirection.DOWN),e.t19=P,e.next="RSCP"===e.t19?95:97;break;case 95:try{w=JSON.parse(k),Array.isArray(w)&&this.emit(P,w)}catch(e){}return e.abrupt("break",98);case 97:return e.abrupt("break",98);case 98:case 99:return e.abrupt("break",100);case 100:case"end":return e.stop()}}),e,this,[[6,10]])}))),function(e){return t.apply(this,arguments)})},{key:"_handleHandler",value:function(){var e=this,t=function(t){logger$h.print("_handleHandler","dataChannel close",t),e.emit("close",t)},r=function(t){logger$h.print("_handleHandler","dataChannel error",t),e.emit("close",t)},n=function(t){e._handleMessage(t.data)};return this._dataChannel.addEventListener("close",t),this._dataChannel.addEventListener("error",r),this._dataChannel.addEventListener("message",n),function(){e._dataChannel.removeEventListener("close",t),e._dataChannel.removeEventListener("error",r),e._dataChannel.removeEventListener("message",n)}}},{key:"_genHeader",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return _objectSpread2({version:2,zip:!1,encrypt:!1,needAck:!0,direction:0,functionType:0,binary:!1},e)}},{key:"_handleAckMessage",value:function(e,t,r){var n=this._singlingCache.get(e);n&&(this._singlingCache.delete(e),200===t.code?n.success(t):n.error(t),logger$h.print("Signal","<<<<<< [".concat(n.signalingType,"-ack]"),t)),monitor.rtcSignaling(0,r,null==n?void 0:n.signalingType,"Ack",RtcsignalingDirection.DOWN)}}]),i}(),HttpRequest=function(){function e(){_classCallCheck(this,e),_defineProperty(this,"xhr",void 0),_defineProperty(this,"isSending",void 0),_defineProperty(this,"timeout",void 0),this.isSending=!1}return _createClass(e,[{key:"ajax",value:function(e){var t=this,r=e.method,n=e.url,i=e.body,o=void 0===i?{}:i,a=e.headers,s=void 0===a?{}:a,c=e.stringify,u=void 0===c||c;return new Promise((function(e,i){t.isSending=!0;var a=new XMLHttpRequest;a.open(r,n,!0);for(var c=0,l=Object.entries(s);c<l.length;c++){var d=_slicedToArray(l[c],2),p=d[0],_=d[1];a.setRequestHeader(p,_)}a.onreadystatechange=function(){4===a.readyState&&(t.isSending=!1,200===a.status?e(JSON.parse(a.responseText)):i({message:a.statusText,code:a.status})),0===a.status&&i({code:0,message:"Request abort"})},a.onerror=function(e){t.isSending=!1,i({code:-1,message:a.responseText||"unknown"})},t.timeout&&(a.timeout=t.timeout),u&&(o=JSON.stringify(o)),a.send(o),t.xhr=a}))}},{key:"get",value:function(e,t){return this.ajax({method:"GET",url:e,headers:t})}},{key:"post",value:function(e,t,r,n){return this.ajax({method:"POST",url:e,body:t,headers:r,stringify:n})}},{key:"abort",value:function(){var e;null===(e=this.xhr)||void 0===e||e.abort()}}]),e}(),logger$g=new Logger("ICE Request",3),IceConfigRequestManager=function(){function e(){_classCallCheck(this,e),_defineProperty(this,"_request",void 0),this._request=new HttpRequest}var t,r,n;return _createClass(e,[{key:"getAccessNode",value:(n=_asyncToGenerator(_regeneratorRuntime().mark((function e(t,r,n,i,o,a,s){var c;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(c=sdkCache.getAccessNode(t))){e.next=9;break}if(this.getAccessNodeFromServer(t,r,n,i,o,a,s),reportRtcInvokeStatus("es.R.node.cache",c),!Array.isArray(c)){e.next=8;break}return e.abrupt("return",Promise.resolve(c));case 8:return e.abrupt("return",Promise.resolve([c]));case 9:return e.abrupt("return",this.getAccessNodeFromServer(t,r,n,i,o,a,s));case 10:case"end":return e.stop()}}),e,this)}))),function(e,t,r,i,o,a,s){return n.apply(this,arguments)})},{key:"getAccessNodeFromServer",value:(r=_asyncToGenerator(_regeneratorRuntime().mark((function e(t,r,n,i,o,a,s){var c,u,l,d,p=this;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return l=sdkCache.getAccessUrls(),d=!0,reportRtcInvokeStatus("es.R.req.cache.urls",l),(null===(c=l)||void 0===c?void 0:c.length)>0||(l=Config.ICE_CONFIG_REQUEST_URLS,d=!1,reportRtcInvokeStatus("es.R.req.external.urls",l)),(null===(u=l)||void 0===u?void 0:u.length)>0||(l=Config.ICE_CONFIG_REQUEST_URLS_INTERNAL,d=!1,reportRtcInvokeStatus("es.R.req.internal.urls",l)),e.abrupt("return",this.getICEConfigFromServer(l,t,r,n,i,o,a,s).then((function(e){var r=e.nodes;return sdkCache.setAccessNode(t,r,e.ttl||11200),e.dispatchDomains&&sdkCache.setAccessUrls(e.dispatchDomains),r})).catch((function(e){if(d)return reportRtcInvokeStatus("es.R.req.fallback",""),sdkCache.clearAccessUrls(),p.getAccessNodeFromServer(t,r,n,i,o,a,s);throw e})));case 6:case"end":return e.stop()}}),e,this)}))),function(e,t,n,i,o,a,s){return r.apply(this,arguments)})},{key:"getICEConfigFromServer",value:(t=_asyncToGenerator(_regeneratorRuntime().mark((function e(t,r,n,i,o,a,s,c){var u,l,d,p,_=this;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return u={appID:r,userID:i,deviceID:o,connectSessionID:genUuid(),os:"web",sdkVersion:Config.VERSION,isOversea:Config.OVERSEA,expectedAddr:getParameter("EXPECTED_ADDR"),productPlatform:"BytePlus",enableCloudProxy:c},a&&s&&(u.feedbackInfo=[{feedbackIP:null===(l=s.publicIPs[0])||void 0===l?void 0:l.ip,feedbackReason:{type:"NODE_CHANGED",reason:a}}],delete u.expectedAddr),d=Date.now(),monitor.rtcGetAccess(0,JSON.stringify(u),0,RtcgetaccessType.REQUEST,t.join(","),u.connectSessionID),p=t.map(function(){var e=_asyncToGenerator(_regeneratorRuntime().mark((function e(t,r){var n,i;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,_._request.post(t,u);case 3:n=e.sent,e.next=9;break;case 6:throw e.prev=6,e.t0=e.catch(0),new SDKError(ErrorCode.ICE_SERVER_WRONG,"get ICE config failed",e.t0);case 9:if(200===n.code){e.next=11;break}throw new SDKError(ErrorCode.ICE_SERVER_WRONG,"get ICE config failed",{server_code:n.code,message:JSON.stringify(n)});case 11:if(i=n.nodes[0]){e.next=14;break}throw new SDKError(ErrorCode.ICE_SERVER_WRONG,"ICE config server return empty nodes",{code:n.code,message:JSON.stringify(n)});case 14:return e.abrupt("return",{result:n,firstNode:i,index:r});case 15:case"end":return e.stop()}}),e,null,[[0,6]])})));return function(t,r){return e.apply(this,arguments)}}()),e.abrupt("return",promiseAny(p).then((function(e){var r=e.result;e.firstNode;var n=e.index;return monitor.rtcGetAccess(200,JSON.stringify(r),Date.now()-d,RtcgetaccessType.RESPONSE,t[n],u.connectSessionID),r})).catch((function(e){var r,n,i=null===(r=e[0])||void 0===r?void 0:r.error;throw monitor.rtcGetAccess(+((null==i?void 0:i.code)||(null==i?void 0:i.server_code)),null===(n=e[0])||void 0===n?void 0:n.message,Date.now()-d,RtcgetaccessType.RESPONSE,t.join(","),u.connectSessionID,{error:JSON.stringify(i)}),e})));case 6:case"end":return e.stop()}}),e)}))),function(e,r,n,i,o,a,s,c){return t.apply(this,arguments)})},{key:"abort",value:function(){this._request.isSending&&(logger$g.print("abort","HTTP Request of [getICEConfigFromServer] abort"),this._request.abort())}}]),e}(),MultiConfigRequestManager=function(){function e(){_classCallCheck(this,e),_defineProperty(this,"_request",void 0),this._request=new HttpRequest}return _createClass(e,[{key:"getH264BlackList",value:function(){var e=this,t={keys:["web_h264_black_list"],labelSelector:"",sdkVersion:"4.46.11",deviceType:"web"};this._request.timeout=800;var r=Config.CONFIG_REQUEST_DOMAINS.map((function(e){return"https://".concat(e,"/decision/v1/multi")}));monitor.rtcGetConfig(0,JSON.stringify(t),0,r.join(","),RtcgetconfigType.REQUEST,"",!1);var n=r.map(function(){var r=_asyncToGenerator(_regeneratorRuntime().mark((function r(n,i){var o,a;return _regeneratorRuntime().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return r.prev=0,r.next=3,e._request.post(n,t);case 3:a=r.sent,r.next=9;break;case 6:throw r.prev=6,r.t0=r.catch(0),new SDKError(ErrorCode.ICE_SERVER_WRONG,"get config failed");case 9:if(Array.isArray(null===(o=a)||void 0===o?void 0:o.web_h264_black_list)){r.next=11;break}throw new SDKError(ErrorCode.ICE_SERVER_WRONG,"get config failed");case 11:return r.abrupt("return",{result:a,index:i});case 12:case"end":return r.stop()}}),r,null,[[0,6]])})));return function(e,t){return r.apply(this,arguments)}}());return new Promise((function(e){promiseAny(n).then((function(t){var n=t.result,i=t.index;sdkCache.setH264BlackList(n.web_h264_black_list),monitor.rtcGetConfig(200,JSON.stringify(n),0,r[i],RtcgetconfigType.RESPONSE,"",!1),e(n.web_h264_black_list)})).catch((function(t){monitor.rtcGetConfig(500,t.message,0,"",RtcgetconfigType.RESPONSE,"",!1),e(sdkCache.getH264BlackList()||[])}))}))}},{key:"getAudioProfile",value:function(){var e=this,t={keys:["engine_BAC"],labelSelector:"",sdkVersion:"4.46.11",deviceType:"web"},r=Config.CONFIG_REQUEST_DOMAINS.map((function(e){return"https://".concat(e,"/decision/v1/multi")}));monitor.rtcGetConfig(0,JSON.stringify(t),0,r.join(","),RtcgetconfigType.REQUEST,"",!1);var n=r.map(function(){var r=_asyncToGenerator(_regeneratorRuntime().mark((function r(n,i){var o,a;return _regeneratorRuntime().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return r.prev=0,r.next=3,e._request.post(n,t);case 3:a=r.sent,r.next=9;break;case 6:throw r.prev=6,r.t0=r.catch(0),new SDKError(ErrorCode.ICE_SERVER_WRONG,"get config failed");case 9:if(Array.isArray(null===(o=a)||void 0===o?void 0:o.engine_BAC)){r.next=11;break}throw new SDKError(ErrorCode.ICE_SERVER_WRONG,"get config failed");case 11:return r.abrupt("return",{result:a,index:i});case 12:case"end":return r.stop()}}),r,null,[[0,6]])})));return function(e,t){return r.apply(this,arguments)}}());return new Promise((function(e){promiseAny(n).then((function(t){var n=t.result,i=t.index;sdkCache.setAudioProfile(n.engine_BAC),monitor.rtcGetConfig(200,JSON.stringify(n),0,r[i],RtcgetconfigType.RESPONSE,"",!1),e(n.engine_BAC)})).catch((function(t){monitor.rtcGetConfig(500,t.message,0,"",RtcgetconfigType.RESPONSE,"",!1),e(sdkCache.getAudioProfile()||[])}))}))}}]),e}();function getBaseEncoderConfig(e,t){var r=1,n=e;(e.width>t.width||e.height>t.height)&&(r=e.width/e.height>t.width/t.height?e.width/t.width:e.height/t.height,n={width:Math.floor(e.width/r),height:Math.floor(e.height/r)});return _objectSpread2(_objectSpread2({},n),{},{scaleResolutionDownBy:r})}var subVideoDescriptions=[{sub_index:0,video_index:0,framerate:30,height:1080,maxkbps:3e3,width:1920},{sub_index:1,video_index:0,framerate:30,height:720,maxkbps:1200,width:1280},{sub_index:2,video_index:0,framerate:30,height:630,maxkbps:1100,width:1120},{sub_index:3,video_index:0,framerate:30,height:540,maxkbps:1e3,width:960},{sub_index:4,video_index:1,framerate:30,height:450,maxkbps:800,width:800},{sub_index:5,video_index:1,framerate:30,height:360,maxkbps:600,width:640},{sub_index:6,video_index:1,framerate:30,height:270,maxkbps:400,width:480},{sub_index:7,video_index:2,framerate:15,height:180,maxkbps:300,width:320},{sub_index:8,video_index:2,framerate:15,height:144,maxkbps:200,width:256},{sub_index:9,video_index:3,framerate:15,height:90,maxkbps:100,width:160}],simulcastFormats=[{width:1920,height:1080,maxLayers:3,totalPixels:2073600},{width:1280,height:720,maxLayers:3,totalPixels:921600},{width:960,height:540,maxLayers:3,totalPixels:518400},{width:640,height:360,maxLayers:2,totalPixels:230400},{width:480,height:270,maxLayers:2,totalPixels:129600},{width:320,height:180,maxLayers:1,totalPixels:57600},{width:0,height:0,maxLayers:1,totalPixels:0}];function getSimulcastLayers(e){for(var t=0,r=e.width*e.height,n=0;n<simulcastFormats.length;n++)if(r>=simulcastFormats[n].totalPixels){t=n;break}if(0===t)return simulcastFormats[t].maxLayers;var i=simulcastFormats[t-1].totalPixels;return(i-r)/(i-simulcastFormats[t].totalPixels)<.1?simulcastFormats[t-1].maxLayers:simulcastFormats[t].maxLayers}var defaultEncoderConfig={"90p":{width:160,height:90,frameRate:15,maxkbps:100},"270p":{width:480,height:270,frameRate:15,maxkbps:400}};function fillSimulcastLayers(e,t){var r=[];if(t<=1)return r;var n=1,i=1;return e.width/e.height>16/9?(n=e.width/defaultEncoderConfig["90p"].width,i=e.width/defaultEncoderConfig["270p"].width):(n=e.height/defaultEncoderConfig["90p"].height,i=e.height/defaultEncoderConfig["270p"].height),r.push({maxkbps:defaultEncoderConfig["90p"].maxkbps,scaleResolutionDownBy:n,frameRate:defaultEncoderConfig["90p"].frameRate,width:Math.floor(e.width/n),height:Math.floor(e.height/n)}),t<=2||n>2&&r.unshift({maxkbps:defaultEncoderConfig["270p"].maxkbps,scaleResolutionDownBy:i,frameRate:defaultEncoderConfig["270p"].frameRate,width:Math.floor(e.width/i),height:Math.floor(e.height/i)}),r}function getSubVideoDescriptions(e){if(!e.length)return[];var t=e.shift(),r=t.width/t.height,n=0,i=0,o=_objectSpread2(_objectSpread2({},t),{},{video_index:i,sub_index:n++});delete o.rid;for(var a=[o],s=0,c=0;c<subVideoDescriptions.length;c++)if(subVideoDescriptions[c].height<t.height){s=c;break}for(var u=e.shift(),l=s;l<subVideoDescriptions.length;l++){var d,p=subVideoDescriptions[l];if(u&&p.height<=(null===(d=u)||void 0===d?void 0:d.height)){var _,f=p.height===(null===(_=u)||void 0===_?void 0:_.height),h=_objectSpread2(_objectSpread2({},u),{},{video_index:++i,sub_index:n++});if(delete h.rid,a.push(h),u=e.shift(),f)continue}a.push(_objectSpread2(_objectSpread2({},p),{},{width:Math.floor(p.height*r),video_index:i,sub_index:n++}))}return a}var cachedSupportedCodecs,isMobileChrome,isChrome="chrome-stable"===getBrowser(),StatProcess=function(){function e(t){_classCallCheck(this,e),_defineProperty(this,"peer",void 0),_defineProperty(this,"stats",void 0),this.peer=t,this.stats=[]}var t,r;return _createClass(e,[{key:"handleCodec",value:function(e){return e}},{key:"handleInboundRtp",value:function(e){return e}},{key:"handleOutboundRtp",value:function(e){var t=e.ssrc;return t&&(e.rtxSsrc=t),e}},{key:"handleRemoteInboundRtp",value:function(e){return e}},{key:"handleRemoteOutboundRtp",value:function(e){return e}},{key:"handleMediaSource",value:function(e){return e}},{key:"handleCsrc",value:function(e){return e}},{key:"handlePeerConnection",value:function(e){return e}},{key:"handleDataChannel",value:function(e){return e}},{key:"handleStream",value:function(e){return e}},{key:"handleTrack",value:function(e){return e}},{key:"handleTransceiver",value:function(e){return e}},{key:"handleSender",value:function(e){return e}},{key:"handleReceiver",value:function(e){return e}},{key:"handleTransport",value:function(e){return e}},{key:"handleSctpTransport",value:function(e){return e}},{key:"handleCandidatePair",value:function(e){return e}},{key:"handleLocalCandidate",value:function(e){return e}},{key:"handleRemoteCandidate",value:function(e){return e}},{key:"handleCertificate",value:function(e){return e}},{key:"handleIceServer",value:function(e){return e}},{key:"processStats",value:function(e){var t=this;e.forEach((function(e){var r;switch(e.type){case"candidate-pair":r=t.handleCandidatePair;break;case"certificate":r=t.handleCertificate;break;case"remote-candidate":r=t.handleRemoteCandidate;break;case"remote-inbound-rtp":case"inbound-rtp":r=t.handleInboundRtp;break;case"remote-outbound-rtp":case"outbound-rtp":r=t.handleOutboundRtp;break;case"sctp-transport":r=t.handleSctpTransport;break;case"sender":r=t.handleSender;break;case"stream":r=t.handleStream;break;case"track":r=t.handleTrack;break;case"transceiver":r=t.handleTransceiver;break;case"transport":r=t.handleTransport;break;case"codec":r=t.handleCodec;break;case"csrc":r=t.handleCsrc;break;case"data-channel":r=t.handleDataChannel;break;case"ice-server":r=t.handleIceServer;break;case"media-source":r=t.handleMediaSource;break;case"peer-connection":r=t.handlePeerConnection;break;case"receiver":r=t.handleReceiver;break;case"local-candidate":r=t.handleLocalCandidate;break;default:r=function(e){return e}}r=r.bind(t),t.stats.push(r(e))}))}},{key:"getExtraStats",value:(r=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){var r=this;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",new Promise((function(e,n){if(!isChrome||void 0!==window.InstallTrigger)return e(r.stats);try{r.peer.getStats((function(n){n.result().forEach((function(e){if(!stasType.includes(e.type)){var n={};e.names().forEach((function(t){n[t]=e.stat(t)})),n.id=e.id,n.type=e.type,n.timestamp=e.timestamp,"ssrc"===n.type&&t&&t.id?t.id===n.googTrackId&&r.stats.push(n):r.stats.push(n)}})),e(r.stats)}))}catch(e){n(e)}})));case 1:case"end":return e.stop()}}),e)}))),function(e){return r.apply(this,arguments)})},{key:"getStats",value:(t=_asyncToGenerator(_regeneratorRuntime().mark((function e(t,r){var n;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,this.peer.getStats(t);case 3:if(n=e.sent,this.processStats(n),e.prev=5,r){e.next=9;break}return e.next=9,this.getExtraStats(t);case 9:e.next=13;break;case 11:e.prev=11,e.t0=e.catch(5);case 13:e.next=17;break;case 15:e.prev=15,e.t1=e.catch(0);case 17:return e.abrupt("return",this.stats);case 18:case"end":return e.stop()}}),e,this,[[0,15],[5,11]])}))),function(e,r){return t.apply(this,arguments)})}]),e}(),stasType=["codec","inbound-rtp","outbound-rtp","remote-inbound-rtp","remote-outbound-rtp","media-source","csrc","peer-connection","data-channel","stream","track","transceiver","sender","receiver","transport","sctp-transport","candidate-pair","local-candidate","remote-candidate","certificate","ice-server"],getStats=function(){var e=_asyncToGenerator(_regeneratorRuntime().mark((function e(t,r,n){var i,o;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(i=[],t instanceof RTCPeerConnection){e.next=3;break}return e.abrupt("return",i);case 3:return o=new StatProcess(t),e.next=6,o.getStats(r,n);case 6:return i=e.sent,e.abrupt("return",i);case 8:case"end":return e.stop()}}),e)})));return function(t,r,n){return e.apply(this,arguments)}}(),AudioMixingDualMonoMode=function(e){return e[e.AUTO=0]="AUTO",e[e.MODE_L=1]="MODE_L",e[e.MODE_R=2]="MODE_R",e[e.MODE_MIX=3]="MODE_MIX",e}(AudioMixingDualMonoMode||{}),AudioMixingType=function(e){return e[e.PLAYOUT=0]="PLAYOUT",e[e.PUBLISH=1]="PUBLISH",e[e.PLAYOUT_AND_PUBLISH=2]="PLAYOUT_AND_PUBLISH",e}(AudioMixingType||{}),AudioMixingState=function(e){return e[e.AUDIO_MIXING_STATE_PRELOADED=0]="AUDIO_MIXING_STATE_PRELOADED",e[e.AUDIO_MIXING_STATE_PLAYING=1]="AUDIO_MIXING_STATE_PLAYING",e[e.AUDIO_MIXING_STATE_PAUSED=2]="AUDIO_MIXING_STATE_PAUSED",e[e.AUDIO_MIXING_STATE_STOPPED=3]="AUDIO_MIXING_STATE_STOPPED",e[e.AUDIO_MIXING_STATE_FAILED=4]="AUDIO_MIXING_STATE_FAILED",e[e.AUDIO_MIXING_STATE_FINISHED=5]="AUDIO_MIXING_STATE_FINISHED",e[e.AUDIO_MIXING_STATE_PCM_ENABLED=6]="AUDIO_MIXING_STATE_PCM_ENABLED",e[e.AUDIO_MIXING_STATE_PCM_DISABLED=7]="AUDIO_MIXING_STATE_PCM_DISABLED",e}(AudioMixingState||{}),isSupported=function(){var e=_asyncToGenerator(_regeneratorRuntime().mark((function e(){var t;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(e.prev=0,!isSSR()&&window.RTCPeerConnection&&window.RTCPeerConnection.prototype.addTransceiver&&window.RTCPeerConnection.prototype.createDataChannel){e.next=3;break}return e.abrupt("return",!1);case 3:return e.next=5,internalGetSupportedCodecs();case 5:return t=e.sent,e.abrupt("return",null==t?void 0:t.includes("H264"));case 9:return e.prev=9,e.t0=e.catch(0),e.abrupt("return",!1);case 12:case"end":return e.stop()}}),e,null,[[0,9]])})));return function(){return e.apply(this,arguments)}}(),internalGetSupportedCodecs=function(){var e=_asyncToGenerator(_regeneratorRuntime().mark((function e(){var t,r,n,i,o,a,s,c;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!cachedSupportedCodecs){e.next=2;break}return e.abrupt("return",cachedSupportedCodecs);case 2:return t=[],e.prev=3,e.next=6,createDefaultSdp();case 6:if(r=e.sent){e.next=9;break}return e.abrupt("return",t);case 9:if(!(null!=r&&r.includes("level-asymmetry-allowed=1;packetization-mode=1;profile-level-id=42e01f")||null!=r&&r.includes("profile-level-id=42e01f;level-asymmetry-allowed=1;packetization-mode=1")||null!=r&&r.includes("packetization-mode=1;profile-level-id=42e01f;level-asymmetry-allowed=1"))){e.next=20;break}return n=navigator.userAgent.toLowerCase(),i=!1,o=["heytapbrowser","mqqbrowser","miuibrowser"],a=new MultiConfigRequestManager,e.next=16,a.getH264BlackList();case 16:for(s=e.sent,o.push.apply(o,_toConsumableArray(s)),c=0;c<o.length;c++)n.includes(o[c])&&(i=!0);!i&&t.push("H264");case 20:return null!=r&&r.includes("VP8")&&t.push("vp8"),cachedSupportedCodecs=t,e.abrupt("return",t);case 25:return e.prev=25,e.t0=e.catch(3),e.abrupt("return",t);case 28:case"end":return e.stop()}}),e,null,[[3,25]])})));return function(){return e.apply(this,arguments)}}(),getSupportedCodecs=function(){var e=_asyncToGenerator(_regeneratorRuntime().mark((function e(){var t;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,internalGetSupportedCodecs();case 2:return t=e.sent,e.abrupt("return",t.map((function(e){return e.toUpperCase()})));case 4:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),isEncodedTransformSupported=function(){return"undefined"!=typeof TransformStream&&"undefined"!=typeof RTCRtpSender&&"undefined"!=typeof RTCRtpReceiver&&void 0!==RTCRtpSender.prototype.createEncodedStreams&&void 0!==RTCRtpReceiver.prototype.createEncodedStreams},logger$f=new Logger("BasicHandler",3),encodedTransformSupported$1=isEncodedTransformSupported(),peerConnectionConfiguration={iceServers:[],iceTransportPolicy:"all",bundlePolicy:"max-bundle",rtcpMuxPolicy:"require",sdpSemantics:"unified-plan",encodedInsertableStreams:!!encodedTransformSupported$1||void 0};function ensureScaleResolutionDownByBeInt(e){if(void 0===isMobileChrome){var t=navigator.userAgent.toLowerCase();isMobileChrome=t.includes("chrome")&&t.includes("mobile")}return isMobileChrome?Math.ceil(e):e}var BasicHandler=function(e){_inherits(a,eventemitter3.exports.EventEmitter);var t,r,n,i,o=_createSuper(a);function a(e,t){var r;return _classCallCheck(this,a),_defineProperty(_assertThisInitialized(r=o.call(this)),"_peerConnection",void 0),_defineProperty(_assertThisInitialized(r),"_dataChannel",void 0),_defineProperty(_assertThisInitialized(r),"_context",void 0),_defineProperty(_assertThisInitialized(r),"monitor",void 0),_defineProperty(_assertThisInitialized(r),"_offerIce",{}),_defineProperty(_assertThisInitialized(r),"_answerIce",{}),_defineProperty(_assertThisInitialized(r),"_initSctpEvents",!1),r.monitor=e,r._peerConnection=new RTCPeerConnection(peerConnectionConfiguration),r._dataChannel=r._peerConnection.createDataChannel("signaling",{negotiated:!0,id:100}),r._context=t,r._dataChannel.binaryType="arraybuffer",r._peerConnection.ontrack=function(e){var t,n;logger$f.print("constructor","pc.ontrack ".concat(e.track.kind," ").concat(e.track.id," ").concat(null===(t=e.streams)||void 0===t||null===(n=t[0])||void 0===n?void 0:n.id)),r.emit("ontrack",e)},r._peerConnection.onconnectionstatechange=function(e){logger$f.print("constructor","onconnectionstatechange ".concat(r._peerConnection.iceConnectionState," -> ").concat(r._peerConnection.connectionState)),"failed"!==r._peerConnection.iceConnectionState&&"closed"!==r._peerConnection.iceConnectionState&&"failed"!==r._peerConnection.connectionState||r.emit("disconnect")},r._peerConnection.oniceconnectionstatechange=function(){var t=r._peerConnection.iceConnectionState;e.rtcPreIceState(t,RtcpreicestateIceState["".concat(t.toUpperCase())])},r}return _createClass(a,[{key:"disconnect",value:function(){this._peerConnection.close(),this._dataChannel.close(),this._peerConnection.ontrack=null}},{key:"destroy",value:function(){logger$f.print("destroy"),this.disconnect(),this._context=void 0}},{key:"_simulcast",value:function(e,t,r,n,i){var o=[],a=getSimulcastLayers(t);logger$f.print("simulcast() ","maxLayers: %o",a),1===e.videoEncodeConfig.length?(o=fillSimulcastLayers(r,a),logger$f.print("simulcast() ","simulcastLayers: %o",o)):(o=e.videoEncodeConfig.slice(1).slice(1-a).map((function(e){return _objectSpread2({frameRate:e.frameRate||15,maxkbps:e.maxKbps||600},getBaseEncoderConfig(r,e))})),logger$f.print("simulcast() ","simulcastLayers2: %o",o)),o.forEach((function(e,t){var r,o={maxBitrate:1e3*e.maxkbps,scaleResolutionDownBy:ensureScaleResolutionDownByBeInt(e.scaleResolutionDownBy),rid:"".concat(t+1),maxFramerate:e.frameRate};null===(r=n.sendEncodings)||void 0===r||r.unshift(o),i.push({width:e.width,height:e.height,framerate:e.frameRate,maxkbps:e.maxkbps,rid:"".concat(t+1)})}))}},{key:"internalPublish",value:function(e,t){var r=e.stream,n=e.videoTrack,i=e.audioTrack,o=e.enableSimulcast,a=e.pubAudio,s=e.pubVideo,c={direction:"sendonly",streams:[r]},u={direction:"sendonly",streams:[r]},l=[],d=[];if(Array.isArray(null==e?void 0:e.videoEncodeConfig)&&e.videoEncodeConfig.length){var p=null==n?void 0:n.getTrack(),_={width:640,height:360,frameRate:30};if(p){var f=null==p?void 0:p.getSettings();_={width:Math.floor(f.width),height:Math.floor(f.height),frameRate:Math.floor(f.frameRate)}}var h=null==e?void 0:e.videoEncodeConfig[0],m=getBaseEncoderConfig(_,h);e.prevScaleResolutionDownBy=m.scaleResolutionDownBy,e.videoInputConfig=_;var y={maxBitrate:1e3*h.maxKbps,scaleResolutionDownBy:ensureScaleResolutionDownByBeInt(m.scaleResolutionDownBy),rid:"0",maxFramerate:h.frameRate||15};u.sendEncodings=[y],l.push({width:m.width,height:m.height,framerate:h.frameRate,maxkbps:h.maxKbps,rid:"0"}),o&&(this._simulcast(e,m,_,u,l),null!=t&&t.simulcastOnDemand&&(d=getSubVideoDescriptions([].concat(l))),logger$f.print("subVideoDesc","desc: %o ",d))}logger$f.print("publish videoTransceiverInit videoDescriptions","",u,l);var v=null==i?void 0:i.getTrack();(null==i?void 0:i.mixType)!==AudioMixingType.PLAYOUT&&null!=i&&i.mixedAudioTrack&&(v=null==i?void 0:i.mixedAudioTrack),v=a&&v?v:"audio";var S=null==n?void 0:n.getTrack();return{semantics:"unified-plan",videoDescriptions:l,subVideoDescriptions:d,transceiverInit:{aTrack:v,vTrack:S=s&&S?S:"video",audioTransceiverInit:c,videoTransceiverInit:u}}}},{key:"updateScaleResolutionDownBy",value:(i=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){var r,n,i,o,a,s,c,u,l,d;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(logger$f.print("updateScaleResolutionDownBy()"),i=null===(r=t.videoTrack)||void 0===r?void 0:r.getTrack(),o=t.videoTransceiver,i&&t.pubVideo&&o){e.next=6;break}return logger$f.print("updateScaleResolutionDownBy()","no pub"),e.abrupt("return");case 6:a=null==i?void 0:i.getSettings(),s={width:Math.floor(a.width),height:Math.floor(a.height),frameRate:Math.floor(a.frameRate)},(c=getBaseEncoderConfig(s,t.videoEncodeConfig[0])).scaleResolutionDownBy===t.prevScaleResolutionDownBy&&logger$f.print("updateScaleResolutionDownBy()","no change %o",t.prevScaleResolutionDownBy),(u=null===(n=o.sender)||void 0===n?void 0:n.getParameters())&&(d=c.scaleResolutionDownBy/t.prevScaleResolutionDownBy,u.encodings=null==u||null===(l=u.encodings)||void 0===l?void 0:l.map((function(e){var r,n;Math.max(e.scaleResolutionDownBy=(e.scaleResolutionDownBy||1)*d,1);var i=+e.rid||0;e.maxFramerate=(null===(r=t.videoEncodeConfig[i])||void 0===r?void 0:r.frameRate)||e.maxFramerate;var o=null===(n=t.videoEncodeConfig[i])||void 0===n?void 0:n.maxKbps;return"number"==typeof o&&(e.maxBitrate=1e3*o),e})),t.prevScaleResolutionDownBy=c.scaleResolutionDownBy,t.videoInputConfig=s,null==o||o.sender.setParameters(u));case 12:case"end":return e.stop()}}),e)}))),function(e){return i.apply(this,arguments)})},{key:"getStats",value:function(e,t){return getStats(this._peerConnection,e,t)}},{key:"setLocalDescription",value:(n=_asyncToGenerator(_regeneratorRuntime().mark((function e(t,r){var n,i,o,a=this;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=getServerNow(),e.prev=1,e.next=4,this._peerConnection.setLocalDescription(new RTCSessionDescription({type:"offer",sdp:t}));case 4:this.monitor.rtcSetDescription(0,t,RtcsetdescriptionIsLocal.W_1,"local"===(null==r?void 0:r.streamUserId)?RtcsetdescriptionDirection.UP:RtcsetdescriptionDirection.DOWN,(null==r?void 0:r.streamId)||"",(null==r?void 0:r.streamUserId)||"",getServerNow()-n,{type:"offer"}),this._initSctpEvents||(this._initSctpEvents=!0,(o=null===(i=this._peerConnection)||void 0===i?void 0:i.sctp)&&(o.onstatechange=function(){a.monitor.rtcInvokeStatus("sctp state change TO: ".concat(o.state),0,"sctp","",0)},o.transport&&(o.transport.onstatechange=function(){var e;a.monitor.rtcInvokeStatus("dtls state change TO: ".concat(null==o||null===(e=o.transport)||void 0===e?void 0:e.state),0,"dtls","",0)}))),e.next=12;break;case 8:e.prev=8,e.t0=e.catch(1),console.error("setLocal",e.t0),this.monitor.rtcSetDescription(-1,e.t0.message+t,RtcsetdescriptionIsLocal.W_1,"local"===(null==r?void 0:r.streamUserId)?RtcsetdescriptionDirection.UP:RtcsetdescriptionDirection.DOWN,"","",getServerNow()-n,{type:"offer"});case 12:case"end":return e.stop()}}),e,this,[[1,8]])}))),function(e,t){return n.apply(this,arguments)})},{key:"setRemoteDescription",value:(r=_asyncToGenerator(_regeneratorRuntime().mark((function e(t,r){var n;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=getServerNow(),e.prev=1,e.next=4,this._peerConnection.setRemoteDescription(new RTCSessionDescription({type:"answer",sdp:t}));case 4:this.monitor.rtcSetDescription(0,t,RtcsetdescriptionIsLocal.W_0,"local"===(null==r?void 0:r.streamUserId)?RtcsetdescriptionDirection.UP:RtcsetdescriptionDirection.DOWN,(null==r?void 0:r.streamId)||"",(null==r?void 0:r.streamUserId)||"",getServerNow()-n,{type:"answer"}),e.next=11;break;case 7:e.prev=7,e.t0=e.catch(1),console.error("setRemote",e.t0),this.monitor.rtcSetDescription(-1,e.t0.message+t,RtcsetdescriptionIsLocal.W_1,"local"===(null==r?void 0:r.streamUserId)?RtcsetdescriptionDirection.UP:RtcsetdescriptionDirection.DOWN,(null==r?void 0:r.streamId)||"",(null==r?void 0:r.streamUserId)||"",getServerNow()-n,{type:"answer"});case 11:case"end":return e.stop()}}),e,this,[[1,7]])}))),function(e,t){return r.apply(this,arguments)})},{key:"setCurrentDescription",value:(t=_asyncToGenerator(_regeneratorRuntime().mark((function e(){return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:case"end":return e.stop()}}),e)}))),function(){return t.apply(this,arguments)})},{key:"pc",get:function(){return this._peerConnection}},{key:"addBitrateLimit",value:function(e,t){null==e||e.rtp.forEach((function(r){var n=r.codec,i=r.payload;if(["vp8","h264"].includes(n.toLocaleLowerCase())){var o=e.fmtp.find((function(e){return e.payload===i}));o&&(o.config=[].concat(_toConsumableArray(o.config.split(";")),["x-google-min-bitrate=100","x-google-start-bitrate=".concat(t)]).join(";"))}}))}}]),a}(),lib={},apply$1=functionApply,call$1=functionCall,uncurryThis$5=functionUncurryThis,fixRegExpWellKnownSymbolLogic=fixRegexpWellKnownSymbolLogic,anObject$2=anObject$q,isNullOrUndefined$1=isNullOrUndefined$b,isRegExp=isRegexp,requireObjectCoercible=requireObjectCoercible$d,speciesConstructor=speciesConstructor$4,advanceStringIndex=advanceStringIndex$3,toLength=toLength$a,toString=toString$m,getMethod=getMethod$7,arraySlice$1=arraySliceSimple,callRegExpExec=regexpExecAbstract,regexpExec=regexpExec$3,stickyHelpers=regexpStickyHelpers,fails$1=fails$U,UNSUPPORTED_Y=stickyHelpers.UNSUPPORTED_Y,MAX_UINT32=4294967295,min=Math.min,$push=[].push,exec$2=uncurryThis$5(/./.exec),push$3=uncurryThis$5($push),stringSlice$2=uncurryThis$5("".slice),SPLIT_WORKS_WITH_OVERWRITTEN_EXEC=!fails$1((function(){var e=/(?:)/,t=e.exec;e.exec=function(){return t.apply(this,arguments)};var r="ab".split(e);return 2!==r.length||"a"!==r[0]||"b"!==r[1]}));fixRegExpWellKnownSymbolLogic("split",(function(e,t,r){var n;return n="c"=="abbc".split(/(b)*/)[1]||4!="test".split(/(?:)/,-1).length||2!="ab".split(/(?:ab)*/).length||4!=".".split(/(.?)(.?)/).length||".".split(/()()/).length>1||"".split(/.?/).length?function(e,r){var n=toString(requireObjectCoercible(this)),i=void 0===r?MAX_UINT32:r>>>0;if(0===i)return[];if(void 0===e)return[n];if(!isRegExp(e))return call$1(t,n,e,i);for(var o,a,s,c=[],u=(e.ignoreCase?"i":"")+(e.multiline?"m":"")+(e.unicode?"u":"")+(e.sticky?"y":""),l=0,d=new RegExp(e.source,u+"g");(o=call$1(regexpExec,d,n))&&!((a=d.lastIndex)>l&&(push$3(c,stringSlice$2(n,l,o.index)),o.length>1&&o.index<n.length&&apply$1($push,c,arraySlice$1(o,1)),s=o[0].length,l=a,c.length>=i));)d.lastIndex===o.index&&d.lastIndex++;return l===n.length?!s&&exec$2(d,"")||push$3(c,""):push$3(c,stringSlice$2(n,l)),c.length>i?arraySlice$1(c,0,i):c}:"0".split(void 0,0).length?function(e,r){return void 0===e&&0===r?[]:call$1(t,this,e,r)}:t,[function(t,r){var i=requireObjectCoercible(this),o=isNullOrUndefined$1(t)?void 0:getMethod(t,e);return o?call$1(o,t,i,r):call$1(n,toString(i),t,r)},function(e,i){var o=anObject$2(this),a=toString(e),s=r(n,o,a,i,n!==t);if(s.done)return s.value;var c=speciesConstructor(o,RegExp),u=o.unicode,l=(o.ignoreCase?"i":"")+(o.multiline?"m":"")+(o.unicode?"u":"")+(UNSUPPORTED_Y?"g":"y"),d=new c(UNSUPPORTED_Y?"^(?:"+o.source+")":o,l),p=void 0===i?MAX_UINT32:i>>>0;if(0===p)return[];if(0===a.length)return null===callRegExpExec(d,a)?[a]:[];for(var _=0,f=0,h=[];f<a.length;){d.lastIndex=UNSUPPORTED_Y?0:f;var m,y=callRegExpExec(d,UNSUPPORTED_Y?stringSlice$2(a,f):a);if(null===y||(m=min(toLength(d.lastIndex+(UNSUPPORTED_Y?f:0)),a.length))===_)f=advanceStringIndex(a,f,u);else{if(push$3(h,stringSlice$2(a,_,f)),h.length===p)return h;for(var v=1;v<=y.length-1;v++)if(push$3(h,y[v]),h.length===p)return h;f=_=m}}return push$3(h,stringSlice$2(a,_)),h}]}),!SPLIT_WORKS_WITH_OVERWRITTEN_EXEC,UNSUPPORTED_Y);var parser$1={},grammar$2={exports:{}},grammar$1=grammar$2.exports={v:[{name:"version",reg:/^(\d*)$/}],o:[{name:"origin",reg:/^(\S*) (\d*) (\d*) (\S*) IP(\d) (\S*)/,names:["username","sessionId","sessionVersion","netType","ipVer","address"],format:"%s %s %d %s IP%d %s"}],s:[{name:"name"}],i:[{name:"description"}],u:[{name:"uri"}],e:[{name:"email"}],p:[{name:"phone"}],z:[{name:"timezones"}],r:[{name:"repeats"}],t:[{name:"timing",reg:/^(\d*) (\d*)/,names:["start","stop"],format:"%d %d"}],c:[{name:"connection",reg:/^IN IP(\d) (\S*)/,names:["version","ip"],format:"IN IP%d %s"}],b:[{push:"bandwidth",reg:/^(TIAS|AS|CT|RR|RS):(\d*)/,names:["type","limit"],format:"%s:%s"}],m:[{reg:/^(\w*) (\d*) ([\w/]*)(?: (.*))?/,names:["type","port","protocol","payloads"],format:"%s %d %s %s"}],a:[{push:"rtp",reg:/^rtpmap:(\d*) ([\w\-.]*)(?:\s*\/(\d*)(?:\s*\/(\S*))?)?/,names:["payload","codec","rate","encoding"],format:function(e){return e.encoding?"rtpmap:%d %s/%s/%s":e.rate?"rtpmap:%d %s/%s":"rtpmap:%d %s"}},{push:"fmtp",reg:/^fmtp:(\d*) ([\S| ]*)/,names:["payload","config"],format:"fmtp:%d %s"},{name:"control",reg:/^control:(.*)/,format:"control:%s"},{name:"rtcp",reg:/^rtcp:(\d*)(?: (\S*) IP(\d) (\S*))?/,names:["port","netType","ipVer","address"],format:function(e){return null!=e.address?"rtcp:%d %s IP%d %s":"rtcp:%d"}},{push:"rtcpFbTrrInt",reg:/^rtcp-fb:(\*|\d*) trr-int (\d*)/,names:["payload","value"],format:"rtcp-fb:%s trr-int %d"},{push:"rtcpFb",reg:/^rtcp-fb:(\*|\d*) ([\w-_]*)(?: ([\w-_]*))?/,names:["payload","type","subtype"],format:function(e){return null!=e.subtype?"rtcp-fb:%s %s %s":"rtcp-fb:%s %s"}},{push:"ext",reg:/^extmap:(\d+)(?:\/(\w+))?(?: (urn:ietf:params:rtp-hdrext:encrypt))? (\S*)(?: (\S*))?/,names:["value","direction","encrypt-uri","uri","config"],format:function(e){return"extmap:%d"+(e.direction?"/%s":"%v")+(e["encrypt-uri"]?" %s":"%v")+" %s"+(e.config?" %s":"")}},{name:"extmapAllowMixed",reg:/^(extmap-allow-mixed)/},{push:"crypto",reg:/^crypto:(\d*) ([\w_]*) (\S*)(?: (\S*))?/,names:["id","suite","config","sessionConfig"],format:function(e){return null!=e.sessionConfig?"crypto:%d %s %s %s":"crypto:%d %s %s"}},{name:"setup",reg:/^setup:(\w*)/,format:"setup:%s"},{name:"connectionType",reg:/^connection:(new|existing)/,format:"connection:%s"},{name:"mid",reg:/^mid:([^\s]*)/,format:"mid:%s"},{name:"msid",reg:/^msid:(.*)/,format:"msid:%s"},{name:"ptime",reg:/^ptime:(\d*(?:\.\d*)*)/,format:"ptime:%d"},{name:"maxptime",reg:/^maxptime:(\d*(?:\.\d*)*)/,format:"maxptime:%d"},{name:"direction",reg:/^(sendrecv|recvonly|sendonly|inactive)/},{name:"icelite",reg:/^(ice-lite)/},{name:"iceUfrag",reg:/^ice-ufrag:(\S*)/,format:"ice-ufrag:%s"},{name:"icePwd",reg:/^ice-pwd:(\S*)/,format:"ice-pwd:%s"},{name:"fingerprint",reg:/^fingerprint:(\S*) (\S*)/,names:["type","hash"],format:"fingerprint:%s %s"},{push:"candidates",reg:/^candidate:(\S*) (\d*) (\S*) (\d*) (\S*) (\d*) typ (\S*)(?: raddr (\S*) rport (\d*))?(?: tcptype (\S*))?(?: generation (\d*))?(?: network-id (\d*))?(?: network-cost (\d*))?/,names:["foundation","component","transport","priority","ip","port","type","raddr","rport","tcptype","generation","network-id","network-cost"],format:function(e){var t="candidate:%s %d %s %d %s %d typ %s";return t+=null!=e.raddr?" raddr %s rport %d":"%v%v",t+=null!=e.tcptype?" tcptype %s":"%v",null!=e.generation&&(t+=" generation %d"),t+=null!=e["network-id"]?" network-id %d":"%v",t+=null!=e["network-cost"]?" network-cost %d":"%v"}},{name:"endOfCandidates",reg:/^(end-of-candidates)/},{name:"remoteCandidates",reg:/^remote-candidates:(.*)/,format:"remote-candidates:%s"},{name:"iceOptions",reg:/^ice-options:(\S*)/,format:"ice-options:%s"},{push:"ssrcs",reg:/^ssrc:(\d*) ([\w_-]*)(?::(.*))?/,names:["id","attribute","value"],format:function(e){var t="ssrc:%d";return null!=e.attribute&&(t+=" %s",null!=e.value&&(t+=":%s")),t}},{push:"ssrcGroups",reg:/^ssrc-group:([\x21\x23\x24\x25\x26\x27\x2A\x2B\x2D\x2E\w]*) (.*)/,names:["semantics","ssrcs"],format:"ssrc-group:%s %s"},{name:"msidSemantic",reg:/^msid-semantic:\s?(\w*) (\S*)/,names:["semantic","token"],format:"msid-semantic: %s %s"},{push:"groups",reg:/^group:(\w*) (.*)/,names:["type","mids"],format:"group:%s %s"},{name:"rtcpMux",reg:/^(rtcp-mux)/},{name:"rtcpRsize",reg:/^(rtcp-rsize)/},{name:"sctpmap",reg:/^sctpmap:([\w_/]*) (\S*)(?: (\S*))?/,names:["sctpmapNumber","app","maxMessageSize"],format:function(e){return null!=e.maxMessageSize?"sctpmap:%s %s %s":"sctpmap:%s %s"}},{name:"xGoogleFlag",reg:/^x-google-flag:([^\s]*)/,format:"x-google-flag:%s"},{push:"rids",reg:/^rid:([\d\w]+) (\w+)(?: ([\S| ]*))?/,names:["id","direction","params"],format:function(e){return e.params?"rid:%s %s %s":"rid:%s %s"}},{push:"imageattrs",reg:new RegExp("^imageattr:(\\d+|\\*)[\\s\\t]+(send|recv)[\\s\\t]+(\\*|\\[\\S+\\](?:[\\s\\t]+\\[\\S+\\])*)(?:[\\s\\t]+(recv|send)[\\s\\t]+(\\*|\\[\\S+\\](?:[\\s\\t]+\\[\\S+\\])*))?"),names:["pt","dir1","attrs1","dir2","attrs2"],format:function(e){return"imageattr:%s %s %s"+(e.dir2?" %s %s":"")}},{name:"simulcast",reg:new RegExp("^simulcast:(send|recv) ([a-zA-Z0-9\\-_~;,]+)(?:\\s?(send|recv) ([a-zA-Z0-9\\-_~;,]+))?$"),names:["dir1","list1","dir2","list2"],format:function(e){return"simulcast:%s %s"+(e.dir2?" %s %s":"")}},{name:"simulcast_03",reg:/^simulcast:[\s\t]+([\S+\s\t]+)$/,names:["value"],format:"simulcast: %s"},{name:"framerate",reg:/^framerate:(\d+(?:$|\.\d+))/,format:"framerate:%s"},{name:"sourceFilter",reg:/^source-filter: *(excl|incl) (\S*) (IP4|IP6|\*) (\S*) (.*)/,names:["filterMode","netType","addressTypes","destAddress","srcList"],format:"source-filter: %s %s %s %s %s"},{name:"bundleOnly",reg:/^(bundle-only)/},{name:"label",reg:/^label:(.+)/,format:"label:%s"},{name:"sctpPort",reg:/^sctp-port:(\d+)$/,format:"sctp-port:%s"},{name:"maxMessageSize",reg:/^max-message-size:(\d+)$/,format:"max-message-size:%s"},{push:"tsRefClocks",reg:/^ts-refclk:([^\s=]*)(?:=(\S*))?/,names:["clksrc","clksrcExt"],format:function(e){return"ts-refclk:%s"+(null!=e.clksrcExt?"=%s":"")}},{name:"mediaClk",reg:/^mediaclk:(?:id=(\S*))? *([^\s=]*)(?:=(\S*))?(?: *rate=(\d+)\/(\d+))?/,names:["id","mediaClockName","mediaClockValue","rateNumerator","rateDenominator"],format:function(e){var t="mediaclk:";return t+=null!=e.id?"id=%s %s":"%v%s",t+=null!=e.mediaClockValue?"=%s":"",t+=null!=e.rateNumerator?" rate=%s":"",t+=null!=e.rateDenominator?"/%s":""}},{name:"keywords",reg:/^keywds:(.+)$/,format:"keywds:%s"},{name:"content",reg:/^content:(.+)/,format:"content:%s"},{name:"bfcpFloorCtrl",reg:/^floorctrl:(c-only|s-only|c-s)/,format:"floorctrl:%s"},{name:"bfcpConfId",reg:/^confid:(\d+)/,format:"confid:%s"},{name:"bfcpUserId",reg:/^userid:(\d+)/,format:"userid:%s"},{name:"bfcpFloorId",reg:/^floorid:(.+) (?:m-stream|mstrm):(.+)/,names:["id","mStream"],format:"floorid:%s mstrm:%s"},{push:"invalid",names:["value"]}]};Object.keys(grammar$1).forEach((function(e){grammar$1[e].forEach((function(e){e.reg||(e.reg=/(.*)/),e.format||(e.format="%s")}))})),function(e){var t=function(e){return String(Number(e))===e?Number(e):e},r=function(e,r,n){var i=e.name&&e.names;e.push&&!r[e.push]?r[e.push]=[]:i&&!r[e.name]&&(r[e.name]={});var o=e.push?{}:i?r[e.name]:r;!function(e,r,n,i){if(i&&!n)r[i]=t(e[1]);else for(var o=0;o<n.length;o+=1)null!=e[o+1]&&(r[n[o]]=t(e[o+1]))}(n.match(e.reg),o,e.names,e.name),e.push&&r[e.push].push(o)},n=grammar$2.exports,i=RegExp.prototype.test.bind(/^([a-z])=(.*)/);e.parse=function(e){var t={},o=[],a=t;return e.split(/(\r\n|\r|\n)/).filter(i).forEach((function(e){var t=e[0],i=e.slice(2);"m"===t&&(o.push({rtp:[],fmtp:[]}),a=o[o.length-1]);for(var s=0;s<(n[t]||[]).length;s+=1){var c=n[t][s];if(c.reg.test(i))return r(c,a,i)}})),t.media=o,t};var o=function(e,r){var n=r.split(/=(.+)/,2);return 2===n.length?e[n[0]]=t(n[1]):1===n.length&&r.length>1&&(e[n[0]]=void 0),e};e.parseParams=function(e){return e.split(/;\s?/).reduce(o,{})},e.parseFmtpConfig=e.parseParams,e.parsePayloads=function(e){return e.toString().split(" ").map(Number)},e.parseRemoteCandidates=function(e){for(var r=[],n=e.split(" ").map(t),i=0;i<n.length;i+=3)r.push({component:n[i],ip:n[i+1],port:n[i+2]});return r},e.parseImageAttributes=function(e){return e.split(" ").map((function(e){return e.substring(1,e.length-1).split(",").reduce(o,{})}))},e.parseSimulcastStreamList=function(e){return e.split(";").map((function(e){return e.split(",").map((function(e){var r,n=!1;return"~"!==e[0]?r=t(e):(r=t(e.substring(1,e.length)),n=!0),{scid:r,paused:n}}))}))}}(parser$1);var grammar=grammar$2.exports,formatRegExp=/%[sdv%]/g,format=function(e){var t=1,r=arguments,n=r.length;return e.replace(formatRegExp,(function(e){if(t>=n)return e;var i=r[t];switch(t+=1,e){case"%%":return"%";case"%s":return String(i);case"%d":return Number(i);case"%v":return""}}))},makeLine=function(e,t,r){var n=[e+"="+(t.format instanceof Function?t.format(t.push?r:r[t.name]):t.format)];if(t.names)for(var i=0;i<t.names.length;i+=1){var o=t.names[i];t.name?n.push(r[t.name][o]):n.push(r[t.names[i]])}else n.push(r[t.name]);return format.apply(null,n)},defaultOuterOrder=["v","o","s","i","u","e","p","c","b","t","r","z","a"],defaultInnerOrder=["i","c","b","a"],writer$1=function(e,t){t=t||{},null==e.version&&(e.version=0),null==e.name&&(e.name=" "),e.media.forEach((function(e){null==e.payloads&&(e.payloads="")}));var r=t.outerOrder||defaultOuterOrder,n=t.innerOrder||defaultInnerOrder,i=[];return r.forEach((function(t){grammar[t].forEach((function(r){r.name in e&&null!=e[r.name]?i.push(makeLine(t,r,e)):r.push in e&&null!=e[r.push]&&e[r.push].forEach((function(e){i.push(makeLine(t,r,e))}))}))})),e.media.forEach((function(e){i.push(makeLine("m",grammar.m[0],e)),n.forEach((function(t){grammar[t].forEach((function(r){r.name in e&&null!=e[r.name]?i.push(makeLine(t,r,e)):r.push in e&&null!=e[r.push]&&e[r.push].forEach((function(e){i.push(makeLine(t,r,e))}))}))}))})),i.join("\r\n")+"\r\n"},parser=parser$1,writer=writer$1;lib.write=writer,lib.parse=parser.parse,lib.parseParams=parser.parseParams,lib.parseFmtpConfig=parser.parseFmtpConfig,lib.parsePayloads=parser.parsePayloads,lib.parseRemoteCandidates=parser.parseRemoteCandidates,lib.parseImageAttributes=parser.parseImageAttributes,lib.parseSimulcastStreamList=parser.parseSimulcastStreamList;var SSRC_MAX=Math.pow(2,32),SSRC_MIN=1e3,generateSsrcId=function(){return Math.floor(Math.random()*SSRC_MAX+SSRC_MIN)},generateSsrc=function(e,t,r){return r||(r=generateSsrcId()),[{id:r,attribute:"cname",value:"kp34Za0H+aVf862l"},{id:r,attribute:"msid",value:"".concat(e.id," ").concat(e.id,"-").concat(t)},{id:r,attribute:"mslabel",value:"".concat(e.id)},{id:r,attribute:"label",value:"".concat(e.id,"-").concat(t)}]},generateSsrcs=function(e,t){var r=generateSsrcId(),n=generateSsrcId();return{ssrcs:[r,n].reduce((function(r,n){return r.concat(generateSsrc(e,t,n))}),[]),ssrcGroups:[{semantics:"FID",ssrcs:"".concat(r," ").concat(n)}]}};function closeMline(e){return e.direction="inactive",e.port=0,delete e.ext,delete e.ssrcs,delete e.ssrcGroups,delete e.simulcast,delete e.simulcast_03,delete e.rids,delete e.extmapAllowMixed,delete e.bundleOnly,e}var getLocalPartialSdp=function(e,t,r){var n=_objectSpread2(_objectSpread2({},e),{},{invalid:[{value:"realx-exts:rscp"}],media:[t,r]});return delete n.groups,delete n.msidSemantic,lib.write(n)};function parseAnswerIceParams(e){return _parseAnswerIceParams.apply(this,arguments)}function _parseAnswerIceParams(){return(_parseAnswerIceParams=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){var r,n,i,o;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r={},n=t.publicIPs,i=t.certFingerprint,o=t.iceParams,r.fingerprint={type:"sha-256",hash:i},r.icePwd=o.serverIcePwd,e.next=6,getServerUfrag(o.serverIceUfrag);case 6:return r.iceUfrag=e.sent,commonStats.setStats({connection_id:r.iceUfrag}),r.candidates=genCandidates(n),r.setup="active",r.iceOptions="renomination",e.abrupt("return",r);case 12:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function genCandidates(e){if(!Array.isArray(e))return[];var t=0,r=2130706431,n=[];return e.forEach((function(e){var i={component:1,ip:e.ip,type:"host",generation:e.generation};e.udpPorts&&e.udpPorts.forEach((function(e){n.push(_objectSpread2(_objectSpread2({},i),{},{foundation:t++,transport:"udp",port:e,priority:r}))})),e.tcpPorts&&e.tcpPorts.forEach((function(e){n.push(_objectSpread2(_objectSpread2({},i),{},{foundation:t++,transport:"tcp",port:e,tcptype:"passive",priority:2130705431}))}))})),n}var getServerUfrag=function(){var e=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){var r,n,i,o,a,s,c;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=new TextEncoder,n=r.encode("PREC"),e.t0=Uint8Array,e.next=5,Utils.b64str2ab(t);case 5:return e.t1=e.sent,i=new e.t0(e.t1),o=r.encode(Date.now().toString()).slice(-4),(a=new Uint8Array(2))[0]=0,a[1]=1,s=concatenate(Uint8Array,n,i,o,a),e.next=14,Utils.ab2b64str(s.buffer);case 14:return c=e.sent,e.abrupt("return",c);case 16:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),uncurryThis$4=functionUncurryThis,defineBuiltIns$2=defineBuiltIns$5,getWeakData=internalMetadata.exports.getWeakData,anInstance$2=anInstance$a,anObject$1=anObject$q,isNullOrUndefined=isNullOrUndefined$b,isObject$3=isObject$s,iterate=iterate$5,ArrayIterationModule=arrayIteration,hasOwn$2=hasOwnProperty_1,InternalStateModule$2=internalState,setInternalState$2=InternalStateModule$2.set,internalStateGetterFor=InternalStateModule$2.getterFor,find$1=ArrayIterationModule.find,findIndex=ArrayIterationModule.findIndex,splice$1=uncurryThis$4([].splice),id=0,uncaughtFrozenStore=function(e){return e.frozen||(e.frozen=new UncaughtFrozenStore)},UncaughtFrozenStore=function(){this.entries=[]},findUncaughtFrozen=function(e,t){return find$1(e.entries,(function(e){return e[0]===t}))};UncaughtFrozenStore.prototype={get:function(e){var t=findUncaughtFrozen(this,e);if(t)return t[1]},has:function(e){return!!findUncaughtFrozen(this,e)},set:function(e,t){var r=findUncaughtFrozen(this,e);r?r[1]=t:this.entries.push([e,t])},delete:function(e){var t=findIndex(this.entries,(function(t){return t[0]===e}));return~t&&splice$1(this.entries,t,1),!!~t}};var InternalWeakMap,collectionWeak$1={getConstructor:function(e,t,r,n){var i=e((function(e,i){anInstance$2(e,o),setInternalState$2(e,{type:t,id:id++,frozen:void 0}),isNullOrUndefined(i)||iterate(i,e[n],{that:e,AS_ENTRIES:r})})),o=i.prototype,a=internalStateGetterFor(t),s=function(e,t,r){var n=a(e),i=getWeakData(anObject$1(t),!0);return!0===i?uncaughtFrozenStore(n).set(t,r):i[n.id]=r,e};return defineBuiltIns$2(o,{delete:function(e){var t=a(this);if(!isObject$3(e))return!1;var r=getWeakData(e);return!0===r?uncaughtFrozenStore(t).delete(e):r&&hasOwn$2(r,t.id)&&delete r[t.id]},has:function(e){var t=a(this);if(!isObject$3(e))return!1;var r=getWeakData(e);return!0===r?uncaughtFrozenStore(t).has(e):r&&hasOwn$2(r,t.id)}}),defineBuiltIns$2(o,r?{get:function(e){var t=a(this);if(isObject$3(e)){var r=getWeakData(e);return!0===r?uncaughtFrozenStore(t).get(e):r?r[t.id]:void 0}},set:function(e,t){return s(this,e,t)}}:{add:function(e){return s(this,e,!0)}}),i}},global$3=global$K,uncurryThis$3=functionUncurryThis,defineBuiltIns$1=defineBuiltIns$5,InternalMetadataModule=internalMetadata.exports,collection=collection$2,collectionWeak=collectionWeak$1,isObject$2=isObject$s,isExtensible=objectIsExtensible,enforceInternalState=internalState.enforce,NATIVE_WEAK_MAP=weakMapBasicDetection,IS_IE11=!global$3.ActiveXObject&&"ActiveXObject"in global$3,wrapper=function(e){return function(){return e(this,arguments.length?arguments[0]:void 0)}},$WeakMap=collection("WeakMap",wrapper,collectionWeak);if(NATIVE_WEAK_MAP&&IS_IE11){InternalWeakMap=collectionWeak.getConstructor(wrapper,"WeakMap",!0),InternalMetadataModule.enable();var WeakMapPrototype=$WeakMap.prototype,nativeDelete=uncurryThis$3(WeakMapPrototype.delete),nativeHas=uncurryThis$3(WeakMapPrototype.has),nativeGet=uncurryThis$3(WeakMapPrototype.get),nativeSet=uncurryThis$3(WeakMapPrototype.set);defineBuiltIns$1(WeakMapPrototype,{delete:function(e){if(isObject$2(e)&&!isExtensible(e)){var t=enforceInternalState(this);return t.frozen||(t.frozen=new InternalWeakMap),nativeDelete(this,e)||t.frozen.delete(e)}return nativeDelete(this,e)},has:function(e){if(isObject$2(e)&&!isExtensible(e)){var t=enforceInternalState(this);return t.frozen||(t.frozen=new InternalWeakMap),nativeHas(this,e)||t.frozen.has(e)}return nativeHas(this,e)},get:function(e){if(isObject$2(e)&&!isExtensible(e)){var t=enforceInternalState(this);return t.frozen||(t.frozen=new InternalWeakMap),nativeHas(this,e)?nativeGet(this,e):t.frozen.get(e)}return nativeGet(this,e)},set:function(e,t){if(isObject$2(e)&&!isExtensible(e)){var r=enforceInternalState(this);r.frozen||(r.frozen=new InternalWeakMap),nativeHas(this,e)?nativeSet(this,e,t):r.frozen.set(e,t)}else nativeSet(this,e,t);return this}})}var DeviceDetector=function(e){_inherits(h,EnhancedEventEmitter);var t,r,n,i,o,a,s,c,u,l,d,p,_,f=_createSuper(h);function h(){var e;return _classCallCheck(this,h),_defineProperty(_assertThisInitialized(e=f.call(this)),"inited",!1),_defineProperty(_assertThisInitialized(e),"deviceMap",{audioinput:new Map,audiooutput:new Map,videoinput:new Map}),e._handleDeviceChange=e._handleDeviceChange.bind(_assertThisInitialized(e)),!isSSR()&&e.refreshDevices(),e}return _createClass(h,[{key:"refreshDevices",value:(_=_asyncToGenerator(_regeneratorRuntime().mark((function e(){var t,r,n=this;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(navigator.mediaDevices){e.next=2;break}return e.abrupt("return");case 2:if(t=void 0,!isFirefox){e.next=7;break}return e.next=6,navigator.mediaDevices.getUserMedia({audio:!0});case 6:t=e.sent;case 7:return e.next=9,navigator.mediaDevices.enumerateDevices();case 9:r=e.sent,t&&t.getTracks().forEach((function(e){return e.stop()})),r.forEach((function(e){var t;e.deviceId&&(null===(t=n.deviceMap[e.kind])||void 0===t||t.set(e.deviceId,e))})),this.inited||this.initListener(),this.inited=!0;case 14:case"end":return e.stop()}}),e,this)}))),function(){return _.apply(this,arguments)})},{key:"initListener",value:(p=_asyncToGenerator(_regeneratorRuntime().mark((function e(){var t,r=this;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:"function"==typeof(null===(t=navigator.mediaDevices)||void 0===t?void 0:t.addEventListener)&&navigator.mediaDevices.addEventListener("devicechange",(function(){r._handleDeviceChange(),setTimeout((function(){r._handleDeviceChange()}),300)}));case 1:case"end":return e.stop()}}),e)}))),function(){return p.apply(this,arguments)})},{key:"_handleDeviceChange",value:(d=_asyncToGenerator(_regeneratorRuntime().mark((function e(){var t,r,n,i=this;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=void 0,!isFirefox){e.next=5;break}return e.next=4,navigator.mediaDevices.getUserMedia({audio:!0});case 4:t=e.sent;case 5:return e.next=7,navigator.mediaDevices.enumerateDevices();case 7:r=e.sent,t&&t.getTracks().forEach((function(e){return e.stop()})),n=Array.from([].concat(_toConsumableArray(this.deviceMap.audioinput.values()),_toConsumableArray(this.deviceMap.videoinput.values()),_toConsumableArray(this.deviceMap.audiooutput.values()))),r.forEach((function(e){var t=i.deviceMap[e.kind].get(e.deviceId);i.deviceMap[e.kind].set(e.deviceId,e),t||(e.kind.includes("video")?i.emit(EngineEventsTypes.onVideoDeviceStateChanged,{mediaDeviceInfo:e,deviceState:"active"}):e.kind.includes("audio")&&i.emit(EngineEventsTypes.onAudioDeviceStateChanged,{mediaDeviceInfo:e,deviceState:"active"}))})),n.forEach((function(e){r.find((function(t){return t.deviceId===e.deviceId&&t.kind===e.kind}))||(i.deviceMap[e.kind].delete(e.deviceId),e.kind.includes("video")?i.emit(EngineEventsTypes.onVideoDeviceStateChanged,{mediaDeviceInfo:e,deviceState:"inactive"}):e.kind.includes("audio")&&i.emit(EngineEventsTypes.onAudioDeviceStateChanged,{mediaDeviceInfo:e,deviceState:"inactive"}))}));case 12:case"end":return e.stop()}}),e,this)}))),function(){return d.apply(this,arguments)})},{key:"getVideoPermission",value:(l=_asyncToGenerator(_regeneratorRuntime().mark((function e(){var t;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=this._getVideoPermission(),e.next=3,this.refreshDevices();case 3:return e.abrupt("return",t);case 4:case"end":return e.stop()}}),e,this)}))),function(){return l.apply(this,arguments)})},{key:"_getVideoPermission",value:(u=_asyncToGenerator(_regeneratorRuntime().mark((function e(){var t,r;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._getNavigatorPermission("camera");case 2:if(!e.sent){e.next=4;break}return e.abrupt("return",!0);case 4:if(r=!1,null===(t=navigator.mediaDevices)||void 0===t||!t.getUserMedia){e.next=8;break}return e.next=8,navigator.mediaDevices.getUserMedia({audio:!1,video:!0}).then((function(e){e&&(e.getTracks().forEach((function(e){return e.stop()})),r=!0)})).catch((function(){}));case 8:return e.abrupt("return",r);case 9:case"end":return e.stop()}}),e,this)}))),function(){return u.apply(this,arguments)})},{key:"getAudioPermission",value:(c=_asyncToGenerator(_regeneratorRuntime().mark((function e(){var t;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=this._getAudioPermission(),e.next=3,this.refreshDevices();case 3:return e.abrupt("return",t);case 4:case"end":return e.stop()}}),e,this)}))),function(){return c.apply(this,arguments)})},{key:"_getAudioPermission",value:(s=_asyncToGenerator(_regeneratorRuntime().mark((function e(){var t,r;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._getNavigatorPermission("microphone");case 2:if(!e.sent){e.next=4;break}return e.abrupt("return",!0);case 4:if(r=!1,null===(t=navigator.mediaDevices)||void 0===t||!t.getUserMedia){e.next=8;break}return e.next=8,navigator.mediaDevices.getUserMedia({audio:!0,video:!1}).then((function(e){e&&(e.getTracks().forEach((function(e){return e.stop()})),r=!0)})).catch((function(){}));case 8:return e.abrupt("return",r);case 9:case"end":return e.stop()}}),e,this)}))),function(){return s.apply(this,arguments)})},{key:"enumerateDevices",value:(a=_asyncToGenerator(_regeneratorRuntime().mark((function e(){return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._getVideoPermission();case 2:return e.next=4,this._getAudioPermission();case 4:return e.abrupt("return",Array.from([].concat(_toConsumableArray(this.deviceMap.audioinput.values()),_toConsumableArray(this.deviceMap.videoinput.values()),_toConsumableArray(this.deviceMap.audiooutput.values()))));case 5:case"end":return e.stop()}}),e,this)}))),function(){return a.apply(this,arguments)})},{key:"enumerateAudioCaptureDevices",value:(o=_asyncToGenerator(_regeneratorRuntime().mark((function e(){return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._getAudioPermission();case 2:return e.abrupt("return",Array.from(this.deviceMap.audioinput.values()));case 3:case"end":return e.stop()}}),e,this)}))),function(){return o.apply(this,arguments)})},{key:"enumerateVideoCaptureDevices",value:(i=_asyncToGenerator(_regeneratorRuntime().mark((function e(){return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._getVideoPermission();case 2:return e.abrupt("return",Array.from(this.deviceMap.videoinput.values()));case 3:case"end":return e.stop()}}),e,this)}))),function(){return i.apply(this,arguments)})},{key:"enumerateAudioPlaybackDevices",value:(n=_asyncToGenerator(_regeneratorRuntime().mark((function e(){return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._getAudioPermission();case 2:return e.abrupt("return",Array.from(this.deviceMap.audiooutput.values()));case 3:case"end":return e.stop()}}),e,this)}))),function(){return n.apply(this,arguments)})},{key:"getDeviceById",value:(r=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){var r;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.enumerateDevices();case 2:return r=e.sent,e.abrupt("return",r.find((function(e){return e.deviceId===t})));case 4:case"end":return e.stop()}}),e,this)}))),function(e){return r.apply(this,arguments)})},{key:"_getNavigatorPermission",value:(t=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){var r,n,i,o;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=!1,null===(r=navigator.permissions)||void 0===r||!r.query){e.next=12;break}return e.prev=2,e.next=5,navigator.permissions.query({name:t});case 5:i=e.sent,o=i.state,n="granted"===o,e.next=12;break;case 10:e.prev=10,e.t0=e.catch(2);case 12:return e.abrupt("return",n);case 13:case"end":return e.stop()}}),e,null,[[2,10]])}))),function(e){return t.apply(this,arguments)})}]),h}(),detector=new DeviceDetector,WebAudioManager=function(){function e(){_classCallCheck(this,e),_defineProperty(this,"_audioContextInstance",void 0)}return _createClass(e,[{key:"getAudioContextInstance",value:function(){if(!this._audioContextInstance){var e=window.AudioContext||window.webkitAudioContext;this._audioContextInstance=new e}return this._audioContextInstance}}]),e}(),AudioLevelFetcher=function(){function e(t){_classCallCheck(this,e),_defineProperty(this,"_ctx",void 0),_defineProperty(this,"_analyserNode",void 0),_defineProperty(this,"_audioSource",void 0);var r=audioContextManager.getAudioContextInstance();if(t instanceof MediaStreamTrack){var n=new MediaStream;n.addTrack(t),this._audioSource=r.createMediaStreamSource(n)}else t instanceof AudioNode?this._audioSource=t:(this._audioSource=r.createMediaElementSource(t),this._audioSource.connect(r.destination));var i=r.createAnalyser();this._audioSource.connect(i),this._analyserNode=i,this._ctx=r}return _createClass(e,[{key:"getAudioLevel",value:function(){var e;"suspended"===(null===(e=this._ctx)||void 0===e?void 0:e.state)&&this._ctx.resume();var t=new Uint8Array(2048);this._analyserNode.getByteTimeDomainData(t);var r=0;return t.forEach((function(e){return r=Math.max(r,Math.abs(e-128))})),r/128*255}},{key:"destroy",value:function(){this._audioSource.disconnect(),this._analyserNode.disconnect()}}]),e}(),AudioVolumeGain=function(){function e(t){_classCallCheck(this,e),_defineProperty(this,"_gainNode",void 0),_defineProperty(this,"_audioDestination",void 0),_defineProperty(this,"_audioSource",void 0);var r=audioContextManager.getAudioContextInstance();this._audioDestination=r.createMediaStreamDestination();var n=new MediaStream;n.addTrack(t),this._audioSource=r.createMediaStreamSource(n),this._gainNode=r.createGain(),this._audioSource.connect(this._gainNode).connect(this._audioDestination)}return _createClass(e,[{key:"setVolumeGain",value:function(e){this._gainNode.gain.value=e}},{key:"getAudioTrack",value:function(){return this._audioDestination.stream.getAudioTracks()[0]}},{key:"destroy",value:function(){this._audioSource.disconnect(),this._gainNode.disconnect()}}]),e}(),audioContextManager=new WebAudioManager,logger$e=new Logger("VERTC",0),trackStreamMap=new WeakMap,getMediaStreamByTrack=function(e){return trackStreamMap.get(e)},Track=function(e){_inherits(r,EnhancedEventEmitter);var t=_createSuper(r);function r(e,n){var i;return _classCallCheck(this,r),_defineProperty(_assertThisInitialized(i=t.call(this)),"mediaType",void 0),_defineProperty(_assertThisInitialized(i),"_trackId",void 0),i._trackId=e,i.mediaType=n,i}return _createClass(r,[{key:"getId",value:function(){return this._trackId}}]),r}(),LocalTrack=function(e){_inherits(r,Track);var t=_createSuper(r);function r(e,n,i){var o;return _classCallCheck(this,r),_defineProperty(_assertThisInitialized(o=t.call(this,n,i)),"_mediaTrack",void 0),o._mediaTrack=e,o._initListeners(),o}return _createClass(r,[{key:"getTrack",value:function(){return this._mediaTrack}},{key:"setTrack",value:function(e){this._mediaTrack=e}},{key:"close",value:function(){var e;return null===(e=this._mediaTrack)||void 0===e?void 0:e.stop()}},{key:"_initListeners",value:function(){var e=this;this._mediaTrack instanceof MediaStreamTrack&&this._mediaTrack.addEventListener("ended",(function(){monitor.rtcError("track-ended mediaType: ".concat(e._mediaTrack.kind),-1001),e.emit("track-ended",e)}))}}]),r}(),RemoteTrack=function(e){_inherits(r,Track);var t=_createSuper(r);function r(e,n,i){var o;return _classCallCheck(this,r),_defineProperty(_assertThisInitialized(o=t.call(this,n,i)),"_mediaTrack",void 0),o._mediaTrack=e,o}return _createClass(r,[{key:"getTrack",value:function(){return this._mediaTrack}}]),r}(),LocalVideoTrack=function(e){_inherits(n,LocalTrack);var t,r=_createSuper(n);function n(e,t){var i;return _classCallCheck(this,n),_defineProperty(_assertThisInitialized(i=r.call(this,e,t,"video")),"resolution",void 0),_defineProperty(_assertThisInitialized(i),"videoCaptureConfig",void 0),_defineProperty(_assertThisInitialized(i),"dummy",!1),i.resolution={width:0,height:0},i}return _createClass(n,[{key:"updateVideoCaptureConfig",value:(t=_asyncToGenerator(_regeneratorRuntime().mark((function e(){var t;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.videoCaptureConfig&&this.getTrack()){e.next=2;break}return e.abrupt("return");case 2:return logger$e.print("updateVideoEncoderConfig","update localVideoTrack: ",this.videoCaptureConfig),delete _objectSpread2({},this.videoCaptureConfig).contentHint,e.next=7,this.getTrack().applyConstraints(this.videoCaptureConfig);case 7:((t=this.getTrack().getSettings()).width&&t.width!==this.resolution.width||t.height&&t.height!==this.resolution.height)&&(this.resolution={width:t.width,height:t.height},this.emit("resolution-change",this.resolution));case 9:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})},{key:"replaceTrack",value:function(e){this.setTrack(e)}},{key:"setContentHint",value:function(e){this._mediaTrack&&"contentHint"in this._mediaTrack&&["text","motion","detail"].includes(e)&&(this._mediaTrack.contentHint=e)}}]),n}(),LocalAudioTrack=function(e){_inherits(n,LocalTrack);var t,r=_createSuper(n);function n(e,t){var i;return _classCallCheck(this,n),_defineProperty(_assertThisInitialized(i=r.call(this,e,t,"audio")),"audioCaptureConfig",void 0),_defineProperty(_assertThisInitialized(i),"_audioLevelFetcher",void 0),_defineProperty(_assertThisInitialized(i),"mixedAudioTrack",void 0),_defineProperty(_assertThisInitialized(i),"mixType",AudioMixingType.PLAYOUT_AND_PUBLISH),_defineProperty(_assertThisInitialized(i),"_audioVolumeGain",void 0),_defineProperty(_assertThisInitialized(i),"gainAudioTrack",void 0),i}return _createClass(n,[{key:"getPublishTrack",value:function(){var e=null==this?void 0:this.getTrack();return(null==this?void 0:this.mixType)!==AudioMixingType.PLAYOUT&&null!=this&&this.mixedAudioTrack?e=null==this?void 0:this.mixedAudioTrack:null!=this&&this.gainAudioTrack&&(e=this.gainAudioTrack),e}},{key:"setCaptureVolume",value:function(e){this._audioVolumeGain||(this._audioVolumeGain=new AudioVolumeGain(this.getTrack()),this.gainAudioTrack=this._audioVolumeGain.getAudioTrack()),this._audioVolumeGain.setVolumeGain(e/100)}},{key:"getAudioLevel",value:function(){return this._audioLevelFetcher||(this._audioLevelFetcher=new AudioLevelFetcher(this.getTrack())),this._audioLevelFetcher.getAudioLevel()}},{key:"updateAudioCaptureConfig",value:(t=_asyncToGenerator(_regeneratorRuntime().mark((function e(){var t;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.audioCaptureConfig){e.next=2;break}return e.abrupt("return");case 2:return logger$e.print("updateAudioCaptureConfig","update localAudioTrack: ",this.audioCaptureConfig),e.next=5,null===(t=this.getTrack())||void 0===t?void 0:t.applyConstraints(this.audioCaptureConfig);case 5:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})}]),n}(),RemoteVideoTrack=function(e){_inherits(r,RemoteTrack);var t=_createSuper(r);function r(e,n){return _classCallCheck(this,r),t.call(this,e,n,"video")}return _createClass(r)}(),RemoteAudioTrack=function(e){_inherits(r,RemoteTrack);var t=_createSuper(r);function r(e,n){var i;return _classCallCheck(this,r),_defineProperty(_assertThisInitialized(i=t.call(this,e,n,"audio")),"_audioLevelFetcher",void 0),i}return _createClass(r,[{key:"getAudioLevel",value:function(){return this._audioLevelFetcher||(this._audioLevelFetcher=new AudioLevelFetcher(this.getTrack())),this._audioLevelFetcher.getAudioLevel()}}]),r}(),MicrophoneAudioTrack=function(e){_inherits(r,LocalAudioTrack);var t=_createSuper(r);function r(){return _classCallCheck(this,r),t.apply(this,arguments)}return _createClass(r)}(),CameraVideoTrack=function(e){_inherits(r,LocalVideoTrack);var t=_createSuper(r);function r(){return _classCallCheck(this,r),t.apply(this,arguments)}return _createClass(r)}(),ScreenVideoTrack=function(e){_inherits(r,LocalVideoTrack);var t=_createSuper(r);function r(){return _classCallCheck(this,r),t.apply(this,arguments)}return _createClass(r)}(),ScreenAudioTrack=function(e){_inherits(r,LocalAudioTrack);var t=_createSuper(r);function r(){return _classCallCheck(this,r),t.apply(this,arguments)}return _createClass(r)}(),CustomVideoLocalTrack=function(e){_inherits(r,LocalVideoTrack);var t=_createSuper(r);function r(){return _classCallCheck(this,r),t.apply(this,arguments)}return _createClass(r)}(),CustomAudioLocalTrack=function(e){_inherits(r,LocalAudioTrack);var t=_createSuper(r);function r(){return _classCallCheck(this,r),t.apply(this,arguments)}return _createClass(r)}();function createDummyVideoLocalTrack(e){return new CameraVideoTrack(e,genUuid())}function createDummyScreenVideoLocalTrack(e){return new ScreenVideoTrack(e,genUuid())}function createCameraVideoTrack(e){return _createCameraVideoTrack.apply(this,arguments)}function _createCameraVideoTrack(){return(_createCameraVideoTrack=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){var r,n,i,o,a,s;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=(null==t||null===(r=t.deviceId)||void 0===r?void 0:r.exact)||"default",e.prev=1,logger$e.print("createCameraVideoTrack","constraints:",t),monitor.rtcVideoCaptureEvent({event_type:CaptureeventinfoEventType.START,media_device_id:i}),o=getServerNow(),e.next=7,navigator.mediaDevices.getUserMedia({video:t});case 7:n=e.sent,monitor.rtcVideoCaptureEvent({event_type:CaptureeventinfoEventType.START_CAPTURE_RESULT,media_device_id:i,reason:CaptureeventinfoReason.SUCCESS,elapse:getServerNow()-o}),detector.refreshDevices(),e.next=16;break;case 12:throw e.prev=12,e.t0=e.catch(1),monitor.rtcVideoCaptureEvent({event_type:CaptureeventinfoEventType.RUNNING_FAILED,media_device_id:i,error_code:e.t0.code,reason:e.t0.name+e.t0.message}),new SDKError(ErrorCode.GET_VIDEO_TRACK_FAILED,"throw error from getUserMedia",e.t0);case 16:return a=n.getVideoTracks()[0],trackStreamMap.set(a,n),(s=new CameraVideoTrack(a,genUuid())).videoCaptureConfig=t,e.abrupt("return",s);case 21:case"end":return e.stop()}}),e,null,[[1,12]])})))).apply(this,arguments)}function createMicrophoneAudioTrack(e,t){return _createMicrophoneAudioTrack.apply(this,arguments)}function _createMicrophoneAudioTrack(){return _createMicrophoneAudioTrack=_asyncToGenerator(_regeneratorRuntime().mark((function e(t,r){var n,i,o,a,s,c,u,l,d,p,_;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return logger$e.print("createCameraVideoTrack","constraints:",t),o=(null==t||null===(n=t.deviceId)||void 0===n?void 0:n.exact)||"default",s=(a=r||{}).sampleRate,c=a.channel,u=a.agc,l=a.ans,d=a.aec,void 0===t.sampleRate&&(t.sampleRate=s),void 0===t.channelCount&&(t.channelCount=c),void 0===t.autoGainControl&&(t.autoGainControl=u),void 0===t.noiseSuppression&&(t.noiseSuppression=l),void 0===t.echoCancellation&&(t.echoCancellation=d),e.prev=8,monitor.rtcVideoCaptureEvent({event_type:CaptureeventinfoEventType.START,media_device_id:o}),p=getServerNow(),e.next=13,navigator.mediaDevices.getUserMedia({audio:t});case 13:i=e.sent,monitor.rtcVideoCaptureEvent({event_type:CaptureeventinfoEventType.START_CAPTURE_RESULT,media_device_id:o,reason:CaptureeventinfoReason.SUCCESS,elapse:getServerNow()-p}),detector.refreshDevices(),e.next=22;break;case 18:throw e.prev=18,e.t0=e.catch(8),monitor.rtcVideoCaptureEvent({event_type:CaptureeventinfoEventType.RUNNING_FAILED,media_device_id:o,error_code:e.t0.code,reason:e.t0.name+e.t0.message}),new SDKError(ErrorCode.GET_AUDIO_TRACK_FAILED,"throw error from getUserMedia",e.t0);case 22:return _=i.getAudioTracks()[0],trackStreamMap.set(_,i),e.abrupt("return",new MicrophoneAudioTrack(_,genUuid()));case 25:case"end":return e.stop()}}),e,null,[[8,18]])}))),_createMicrophoneAudioTrack.apply(this,arguments)}function createScreenStream(){return _createScreenStream.apply(this,arguments)}function _createScreenStream(){return _createScreenStream=_asyncToGenerator(_regeneratorRuntime().mark((function e(){var t,r,n,i,o=arguments;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=o.length>0&&void 0!==o[0]&&o[0],r=o.length>1?o[1]:void 0,logger$e.print("createScreenTracks","withAudio: %o, constraints: %o",t,r),e.prev=3,monitor.rtcVideoCaptureEvent({event_type:CaptureeventinfoEventType.START,media_device_id:"screen"}),i=getServerNow(),e.next=8,navigator.mediaDevices.getDisplayMedia({video:!(r&&!isSafari)||r,audio:!!t&&{channelCount:2,noiseSuppression:!1,echoCancellation:!1,autoGainControl:!1}});case 8:n=e.sent,monitor.rtcVideoCaptureEvent({event_type:CaptureeventinfoEventType.START_CAPTURE_RESULT,media_device_id:"screen",reason:CaptureeventinfoReason.SUCCESS,elapse:getServerNow()-i}),e.next=16;break;case 12:throw e.prev=12,e.t0=e.catch(3),monitor.rtcVideoCaptureEvent({event_type:CaptureeventinfoEventType.RUNNING_FAILED,media_device_id:"screen",error_code:e.t0.code,reason:e.t0.name+e.t0.message}),new SDKError(ErrorCode.GET_SCREEN_TRACK_FAILED,"throw error from getDisplayMedia",e.t0);case 16:return e.abrupt("return",n);case 17:case"end":return e.stop()}}),e,null,[[3,12]])}))),_createScreenStream.apply(this,arguments)}var ExtendMediaType=function(e){return e[e.NONE=0]="NONE",e}(ExtendMediaType||{}),Nalunit=function(){function e(){_classCallCheck(this,e)}return _createClass(e,null,[{key:"getNalunits",value:function(t){if(t.length-t.position<4)return[];var r=t.position;return 1===t.getInt32(r)||0===t.getInt16(r)&&1===t.getInt8(r+2)?e.getAnnexbNals(t):e.getAvccNals(t)}},{key:"getAnnexbNals",value:function(t){for(var r=[],n=e.getHeaderPositionAnnexB(t),i=n.pos,o=i;i<t.length-4;){var a=new Uint8Array(t.buffer.slice(i,i+n.headerLength));n.pos===t.position&&t.skip(n.headerLength),o=(n=e.getHeaderPositionAnnexB(t)).pos;var s={header:a,body:new Uint8Array(t.buffer.slice(i+a.byteLength,o)),type:-1};e.analyseNal(s),s.type<=9&&0!==s.type&&r.push(s),t.skip(o-t.position),i=o}return r}},{key:"getAvccNals",value:function(t){for(var r=[];t.position<t.length-4;){var n=t.getInt32(t.position);if(!(t.length-t.position>=n))break;var i=new Uint8Array(t.buffer.slice(t.position,t.position+4));t.skip(4);var o=new Uint8Array(t.buffer.slice(t.position,t.position+n));t.skip(n);var a={header:i,body:o,type:-1};e.analyseNal(a),a.type<=9&&0!==a.type&&r.push(a)}return r}},{key:"analyseNal",value:function(e){var t=31&e.body[0];switch(e.type=t,t){case 1:e.ndr=!0;break;case 5:e.idr=!0;break;case 6:e.sei=!0;break;case 7:e.sps=!0;break;case 8:e.pps=!0}}},{key:"getHeaderPositionAnnexB",value:function(e){for(var t=e.position,r=0,n=e.length;3!==r&&4!==r&&t<n-4;)0===e.getInt16(t)?1===e.getInt16(t+2)?r=4:1===e.getInt8(t+2)?r=3:t++:t++;return t===n-4&&(0===e.getInt16(t)?1===e.getInt16(t+2)?r=4:t=n:(t++,0===e.getInt16(t)&&1===e.getInt8(t)?r=3:t=n)),{pos:t,headerLength:r}}},{key:"getAvcc",value:function(e,t){var r=new Uint8Array(e.byteLength+t.byteLength+11);r[0]=1,r[1]=e[1],r[2]=e[2],r[3]=e[3],r[4]=255,r[5]=225;var n=6;return r.set(new Uint8Array([e.byteLength>>>8&255,255&e.byteLength]),n),n+=2,r.set(e,n),r[n+=e.byteLength]=1,n++,r.set(new Uint8Array([t.byteLength>>>8&255,255&t.byteLength]),n),n+=2,r.set(t,n),r}}]),e}(),RTCDataView=function(){function e(t){_classCallCheck(this,e),_defineProperty(this,"_position",0),_defineProperty(this,"_dataview",void 0),this._dataview=new DataView(t)}return _createClass(e,[{key:"length",get:function(){return this.buffer.byteLength}},{key:"buffer",get:function(){return this._dataview.buffer}},{key:"position",get:function(){return this._position},set:function(e){this._position=e}},{key:"back",value:function(e){this.position-=e}},{key:"getUint8",value:function(e){return this._dataview.getUint8(e)}},{key:"getInt8",value:function(e){return this._dataview.getInt8(e)}},{key:"getInt16",value:function(e){return this._dataview.getInt16(e)}},{key:"getUint16",value:function(e){return this._dataview.getUint16(e)}},{key:"getUint32",value:function(e){return this._dataview.getUint32(e)}},{key:"getInt32",value:function(e){return this._dataview.getInt32(e)}},{key:"skip",value:function(t){for(var r=Math.floor(t/4),n=t%4,i=0;i<r;i++)e.readByte(this,4);n>0&&e.readByte(this,n)}},{key:"readUint8",value:function(){return e.readByte(this,1)}},{key:"readUint16",value:function(){return e.readByte(this,2)}},{key:"readUint24",value:function(){return e.readByte(this,3)}},{key:"readUint32",value:function(){return e.readByte(this,4)}},{key:"readUint64",value:function(){return e.readByte(this,8)}},{key:"readInt8",value:function(){return e.readByte(this,1,!0)}},{key:"readInt16",value:function(){return e.readByte(this,2,!0)}},{key:"readInt32",value:function(){return e.readByte(this,4,!0)}},{key:"writeUint32",value:function(e){return new Uint8Array([e>>>24&255,e>>>16&255,e>>>8&255,255&e])}}],[{key:"readByte",value:function(e,t,r){var n;switch(t){case 1:n=r?e.getInt8(e.position):e.getUint8(e.position);break;case 2:n=r?e.getInt16(e.position):e.getUint16(e.position);break;case 3:if(r)throw new Error("not supported for readByte 3");n=e.getUint8(e.position)<<16,n|=e.getUint8(e.position+1)<<8,n|=e.getUint8(e.position+2);break;case 4:n=r?e.getInt32(e.position):e.getUint32(e.position);break;case 8:if(r)throw new Error("not supported for readBody 8");n=e.getUint32(e.position)<<32,n|=e.getUint32(e.position+4);break;default:n=""}return e.position+=t,n}}]),e}(),RTC_SEI_TYPE=function(e){return e[e.internal=0]="internal",e[e.external=1]="external",e[e.bypass=2]="bypass",e}(RTC_SEI_TYPE||{}),UUID_INTERNAL=new Uint8Array([109,167,53,190,103,90,72,1,170,89,63,164,194,199,19,85]),UUID_EXTERNAL=new Uint8Array([109,167,53,190,103,90,72,1,170,89,63,164,194,199,19,84]),rbsp2ebsp=function(e){for(var t=[],r=0;r<e.length;r++)e[r]<=3&&0===e[r-1]&&0===e[r-2]&&t.push(3),t.push(e[r]);return new Uint8Array(t)},ebsp2rbsp=function(e){for(var t=[],r=0;r<e.length;r++)e[r]<=3&&0===e[r-1]&&0===e[r-2]||t.push(e[r]);return new Uint8Array(t)};function serializeData(e){for(var t=[];e>=255;)e-=255,t.push(255);return t.push(e),new Uint8Array(t)}function deserializeData(e){for(var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=0;255===e[t]&&t<e.byteLength;)t++,r+=255;return t<e.byteLength&&(r+=e[t++]),[r,t]}var SEIHelper=function(){function e(){_classCallCheck(this,e)}return _createClass(e,null,[{key:"generateSEI",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=new Uint8Array([0,0,0,1]),n=new Uint8Array([6]),i=new Uint8Array([5]),o=t?UUID_INTERNAL:UUID_EXTERNAL,a=serializeData(e.byteLength+o.byteLength),s=rbsp2ebsp(e);return new Uint8Array([].concat(_toConsumableArray(r),_toConsumableArray(n),_toConsumableArray(i),_toConsumableArray(a),_toConsumableArray(o),_toConsumableArray(s),[128]))}},{key:"decodeSeiBody",value:function(e){e=e.slice(0,e.length-1);var t=ebsp2rbsp(e);if(!(t.byteLength<2)){var r=0;if(5===t[1]||100===t[1]){var n=_slicedToArray(deserializeData(t,r+=2),2),i=n[0],o=2,a=(r=n[1])+i;return t.byteLength>=UUID_EXTERNAL.byteLength&&i>=UUID_EXTERNAL.byteLength&&t.slice(r,r+UUID_EXTERNAL.byteLength).toString()===UUID_EXTERNAL.toString()?(r+=UUID_EXTERNAL.byteLength,o=1):t.byteLength>=UUID_EXTERNAL.byteLength&&i>=UUID_EXTERNAL.byteLength&&t.slice(r,r+UUID_INTERNAL.byteLength).toString()===UUID_INTERNAL.toString()&&(r+=UUID_INTERNAL.byteLength,o=0),{type:o,payload:t.slice(r,a)}}}}},{key:"parseInternalSEI",value:function(e){var t=new Map,r=0;if(0===e.type){for(;e.payload.byteLength-r>=2;){var n=_slicedToArray(deserializeData(e.payload,r),2),i=n[0];r=n[1];var o=_slicedToArray(deserializeData(e.payload,r),2),a=o[0];if(r=o[1],t.get(i)||!(a<e.payload.byteLength-r))break;t.set(i,e.payload.slice(r,r+a))}return t}}},{key:"makeInternalSei",value:function(e){var t,r=[],n=_createForOfIteratorHelper(e);try{for(n.s();!(t=n.n()).done;){var i=_slicedToArray(t.value,2),o=i[0],a=i[1],s=serializeData(o),c=serializeData(a.byteLength);r.push(s,c,a)}}catch(e){n.e(e)}finally{n.f()}var u=r.reduce((function(e,t){return e+t.byteLength}),0),l=new Uint8Array(u);return r.reduce((function(e,t){return l.set(t,e),e+t.byteLength}),0),l}}]),e}(),Stats=function(){function e(t){_classCallCheck(this,e),_defineProperty(this,"_stream",void 0),_defineProperty(this,"_timer",void 0),_defineProperty(this,"client",void 0),_defineProperty(this,"handler",void 0),_defineProperty(this,"monitor",void 0),this._stream=t}return _createClass(e,[{key:"setVar",value:function(e,t,r){this.client=e,this.handler=t,this.monitor=r}},{key:"delStatsEvtInterval",value:function(){clearTimeout(this._timer),this._timer=void 0}},{key:"destroy",value:function(){this.delStatsEvtInterval()}}]),e}(),LocalStatsReport=function(e){_inherits(i,Stats);var t,r,n=_createSuper(i);function i(e){var t;return _classCallCheck(this,i),(t=n.call(this,e))._stream=e,t}return _createClass(i,[{key:"setLocalStreamStatsEvtInterval",value:function(e,t,r){var n,i,o,a=this;if(!this._timer){this.setVar(e,t,r),e.once(StateEvent.ABNORMAL_DISCONNECTION,(function(){a.destroy()}));var s={audio:{},video:{}},c=this._stream,u=null===(n=c.audioTrack)||void 0===n?void 0:n.getPublishTrack(),l=null===(i=c.videoTrack)||void 0===i?void 0:i.getTrack();this.getAudioStats(u,s,null===(o=c.audioTrack)||void 0===o?void 0:o.getAudioLevel()),this.getVideoStats(l,s),this.delStatsEvtInterval();var d=function(){var e=_asyncToGenerator(_regeneratorRuntime().mark((function e(){var t,r,n,i,o,u,l;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=null===(t=c.audioTrack)||void 0===t?void 0:t.getPublishTrack(),o=null===(r=c.videoTrack)||void 0===r?void 0:r.getTrack(),e.next=4,a.getAudioStats(i,s,null===(n=c.audioTrack)||void 0===n?void 0:n.getAudioLevel());case 4:return u=e.sent,e.next=7,a.getVideoStats(o,s);case 7:return l=e.sent,e.abrupt("return",{audioStats:u,videoStats:l,isScreen:c.isScreen});case 9:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),p=function(){var e=_asyncToGenerator(_regeneratorRuntime().mark((function e(){var t,r;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,d();case 2:r=e.sent,null===(t=a.client)||void 0===t||t.emit("onLocalStreamStats",r),a._timer=setTimeout(p,2e3);case 5:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}();this._timer=setTimeout(p,2e3)}}},{key:"unpublish",value:function(){this.delStatsEvtInterval()}},{key:"getAudioStats",value:(r=_asyncToGenerator(_regeneratorRuntime().mark((function e(t,r,n){var i,o,a,s,c,u,l,d,p,_;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(i={},o={timestamp:Date.now()},a=this._stream,s=a.streamId,c=a.audioMid,u=a.isScreen,l=a.pubAttributes,d={media_type:"audio",is_screen:!!u,direction:"up",stream_id:s,vid:c,connection_status:navigator.onLine,capture_state:l.localaudio?"capture_state_on":"capture_state_off"},t&&this.handler){e.next=6;break}return e.abrupt("return",i);case 6:return e.next=8,this.handler.getStats(t);case 8:if((p=e.sent).length){e.next=11;break}return e.abrupt("return",i);case 11:if(p.forEach((function(e){var t=e.type,r=e.packetsSent,n=e.packetsLost,a=e.bytesSent,s=e.clockRate,c=e.roundTripTime,u=e.channels,l=e.audioLevel,p=e.googRtt,_=e.mimeType,f=e.availableIncomingBitrate,h=e.availableOutgoingBitrate,m=e.bytesReceived,y=e.nominated,v=e.id,S=e.currentRoundTripTime,g=e.state,E=e.writable,T=e.requestsReceived,b=e.responsesReceived,R=e.requestsSent,I=e.consentRequestsSent,$=e.responsesSent,A=e.jitter,C=e.candidateType,O=e.ip,P=e.address,k=e.networkType,w=e.port,N=e.protocol,D=e.nackCount,M=e.retransmittedBytesSent,x=e.retransmittedPacketsSent,L=e.roundTripTimeMeasurements,U=e.audioInputLevel,F=e.ssrc,B=e.totalAudioEnergy,V=e.totalSamplesDuration,j=e.mediaType,G=e.fractionLost;"outbound-rtp"===t?(o.packetsSent=r,o.bytesSent=a,d.bytes=a,d.packetsSent=r,d.nackCount=D,d.ssrc=F,d.retransmitted_bytes_sent=M,d.retransmitted_packets_sent=x,o.retransmittedPacketsSent=x):"remote-inbound-rtp"===t?(o.packetsLost=n,d.packetsLost=n,d.jitter=1e3*A,i.rtt=1e3*c,d.rtt=i.rtt,d.round_trip_time_measurements=L,i._fractionLost=G||0):"codec"===t?(i.recordSampleRate=s,i.numChannels=u,d.codecName=_):"media-source"===t&&void 0!==l?(d.audio_level=l?-10*Math.log10(Math.pow(l,2)):l,d.volume=255*l,d.total_audio_energy=B,d.total_samples_duration=V):"ssrc"===t&&"audio"===j?(d.audio_network_elapse=p,d.send_level=U):"candidate-pair"===t?(d.ice_available_incoming_bitrate=f,d.ice_available_outgoing_bitrate=h,d.ice_bytes_received=m,d.ice_bytes_sent=a,d.ice_nominated=+y,d.ice_pair_id=v,d.ice_pair_rtt=S,d.ice_pair_state=g,d.ice_pair_writable=E,d.recv_ping_requests=T,d.recv_ping_responses=b,d.sent_ping_requests_before_first_response=R,d.sent_ping_requests_total=R+(I||0),d.sent_ping_responses=$):"local-candidate"===t?(d.local_candidate_type=C,d.local_ip=O||P,d.local_network_type=k,d.local_port=w,d.protocol=N):"remote-candidate"===t&&(d.remote_candidate_type=C,d.remote_ip=O||P,d.remote_port=w)})),void 0===d.volume&&void 0!==n&&(d.volume=n,d.audio_level=n?-10*Math.log10(Math.pow(n/255,2)):n),(_=r.audio).timestamp){e.next=17;break}return r.audio=o,e.abrupt("return",i);case 17:return void 0!==o.packetsLost&&(i.audioLossRate=(o.packetsLost-_.packetsLost)/(o.packetsSent-_.packetsSent),i.audioLossRate=Number.isNaN(i.audioLossRate)?0:i.audioLossRate,d.fraction_lost=i.audioLossRate),i.statsInterval=o.timestamp-_.timestamp,d.stats_interval=i.statsInterval,i.sendKBitrate=(o.bytesSent-_.bytesSent||0)/i.statsInterval*8,d.bitrate=Math.round(1e3*i.sendKBitrate),d.bandwidth=Math.round(d.bitrate/1024),r.audio=o,this.monitor.rtcMediaStatistics(d,{}),i._retransmittedRate=(o.retransmittedPacketsSent-_.retransmittedPacketsSent)/(o.packetsSent-_.packetsSent),i._fractionLost=Math.max(i._fractionLost,i.audioLossRate),e.abrupt("return",i);case 28:case"end":return e.stop()}}),e,this)}))),function(e,t,n){return r.apply(this,arguments)})},{key:"getVideoStats",value:(t=_asyncToGenerator(_regeneratorRuntime().mark((function e(t,r){var n,i,o,a,s,c,u,l,d,p,_,f,h,m;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n={},i={timestamp:Date.now(),simulcast:{}},o=this._stream,a=o.streamId,s=o.videoMid,c=o.isScreen,u=o.pubAttributes,l=o.enableSimulcast,d={media_type:"video",is_screen:!!c,direction:"up",stream_id:a,vid:s,connection_status:navigator.onLine,capture_state:u.localvideo?"capture_state_on":"capture_state_off"},t&&this.handler){e.next=6;break}return e.abrupt("return",n);case 6:return n.isScreen=c,e.next=9,this.handler.getStats(t);case 9:if((p=e.sent).length){e.next=12;break}return e.abrupt("return",n);case 12:if(_=0,p.forEach((function(e){var t=e.type,r=e.framesEncoded,o=e.packetsLost,a=e.bytesSent,s=e.framesSent,c=e.roundTripTime,u=e.mimeType,p=e.frameWidth,f=e.frameHeight,h=e.packetsSent,m=e.googActualEncBitrate,y=e.googAvailableReceiveBandwidth,v=e.googAvailableSendBandwidth,S=e.googAvgEncodeMs,g=e.googBucketDelay,E=e.googEncodeUsagePercent,T=e.googFrameRateInput,b=e.availableIncomingBitrate,R=e.availableOutgoingBitrate,I=e.bytesReceived,$=e.nominated,A=e.id,C=e.currentRoundTripTime,O=e.state,P=e.writable,k=e.candidateType,w=e.ip,N=e.address,D=e.networkType,M=e.port,x=e.nackCount,L=e.pliCount,U=e.protocol,F=e.qpSum,B=e.requestsReceived,V=e.responsesReceived,j=e.googRetransmitBitrate,G=e.requestsSent,H=e.consentRequestsSent,K=e.responsesSent,z=e.ssrc,Y=e.googTargetEncBitrate,W=e.googTransmitBitrate,q=e.googRtt,X=e.retransmittedPacketsSent,Z=e.encoderImplementation,J=e.jitter,Q=e.rid,ee=e.fractionLost;"outbound-rtp"===t?(l&&(Q?i.simulcast[Q]=e:i.simulcast[_]=e,_++),i.framesEncoded=r,i.bytesSent=a,i.framesSent=s,d.bytes=a,i.packetsSent=h,d.packetsSent=h,d.nackCount=x,d.pli_count=L,d.qp_sum=F,d.ssrc=z,d.retransmitted_packets_sent=X,i.retransmittedPacketsSent=X,d.encoder_implementation=Z,void 0!==p&&(n.encodedFrameWidth=p,n.encodedFrameHeight=f,d.frame_size_height=f,d.frame_size_width=p)):"track"===t?(n.encodedFrameWidth=p,n.encodedFrameHeight=f,d.frame_size_height=f,d.frame_size_width=p):"remote-inbound-rtp"===t?(i.packetsLost=o,n.rtt=1e3*c,d.rtt=n.rtt,d.jitter=J,d.packetsLost=o,n._fractionLost=ee||0):"codec"===t?(n.codecType=u,d.codecName=u):"candidate-pair"===t?(d.ice_available_incoming_bitrate=b,d.ice_available_outgoing_bitrate=R,d.ice_bytes_received=I,d.ice_bytes_sent=a,d.ice_nominated=+$,d.ice_pair_id=A,d.ice_pair_rtt=C,d.ice_pair_state=O,d.ice_pair_writable=P,d.recv_ping_requests=B,d.recv_ping_responses=V,d.sent_ping_requests_before_first_response=G,d.sent_ping_requests_total=G+H,d.sent_ping_responses=K):"local-candidate"===t?(d.local_candidate_type=k,d.local_ip=w||N,d.local_network_type=D,d.local_port=M,d.protocol=U):"remote-candidate"===t?(d.remote_candidate_type=k,d.remote_ip=w||N,d.remote_port=M):"VideoBwe"===t?(d.encBitratebps=m,d.available_receive_bandwidth=y,d.available_send_bandwidth=v,d.bucket_delay=g,d.retransmitBitratebps=j,d.targetEncBitratebps=Y,d.transmit_bitrate=W,n._sendBandWidth=+v):"ssrc"===t&&(d.video_network_elapse=q,d.avg_encode_ms=S,d.encodeUsage=E,d.frame_rate_input=T,d.orignal_input_Framerate=+T)})),(f=r.video).timestamp){e.next=18;break}return r.video=i,e.abrupt("return",n);case 18:return n.statsInterval=i.timestamp-f.timestamp,d.stats_interval=n.statsInterval,h=Object.keys(i.simulcast),l?(d.sim_enc_width=[],d.sim_enc_height=[],d.sim_enc_bps=[],d.sim_enc_framerate=[],d.sim_rids=[],d.sim_enc_bandwidth=[],d.sim_sent_framerate=[],d.sim_fraction_lost=[],m=!1,h.sort((function(e,t){return+e-+t})).forEach((function(e){var t=i.simulcast[e],r=t.frameWidth,o=t.frameHeight,a=t.bytesSent,s=t.framesEncoded,c=t.framesSent,u=t.packetsLost,l=t.packetsSent,p=t.qualityLimitationReason,_=t.qualityLimitationDurations,h=t.qualityLimitationResolutionChanges,y=t.retransmittedPacketsSent;void 0!==p&&(d.sim_qualityLimitationReason||(d.sim_qualityLimitationReason=[],d.sim_qualityLimitationDurations=[],d.sim_qualityLimitationResolutionChanges=[]),d.sim_qualityLimitationReason.push(p),d.sim_qualityLimitationDurations.push(_),d.sim_qualityLimitationResolutionChanges.push(h));var v=f.simulcast[e];if(d.sim_enc_width.push(r||0),d.sim_enc_height.push(o||0),v){var S=(a-v.bytesSent||0)/n.statsInterval;d.sim_enc_bps.push(Math.round(8e3*S)),d.sim_enc_bandwidth.push(Math.round(8e3*S/1024));var g=1e3*(s-v.framesEncoded)/n.statsInterval;d.sim_enc_framerate.push(Math.round(g)),d.sim_rids.push(e);var E=void 0!==c?c-v.framesSent:s-v.framesEncoded,T=1e3*E/n.statsInterval;d.sim_sent_framerate.push(Math.round(T));var b=(u-v.packetsLost)/(l-v.packetsSent);n._retransmittedRate=(y-v.retransmittedPacketsSent)/(l-v.packetsSent),b=Number.isNaN(b)?0:b,d.sim_fraction_lost.push(b),r>0&&!m&&(n.sentKBitrate=8*S,n.encoderOutputFrameRate=g,n.encodedFrameCount=E,n.sentFrameRate=T,n.videoLossRate=b,m=!0)}})),this.monitor.rtcMediaStatistics(d,{})):(n.encodedFrameCount=void 0!==i.framesSent?i.framesSent-f.framesSent:i.framesEncoded-f.framesEncoded,n.sentKBitrate=(i.bytesSent-f.bytesSent||0)/n.statsInterval*8,d.bitrate=Math.round(1e3*n.sentKBitrate),d.bandwidth=Math.round(d.bitrate/1024),n.encoderOutputFrameRate=1e3*(i.framesEncoded-f.framesEncoded)/n.statsInterval,d.frame_rate_encoded=Math.round(n.encoderOutputFrameRate),n.sentFrameRate=1e3*n.encodedFrameCount/n.statsInterval,d.frame_rate_sent=Math.round(n.sentFrameRate),n.videoLossRate=(i.packetsLost-f.packetsLost)/(i.packetsSent-f.packetsSent),n.videoLossRate=Number.isNaN(n.videoLossRate)?0:n.videoLossRate,d.fraction_lost=n.videoLossRate,n._retransmittedRate=(i.retransmittedPacketsSent-f.retransmittedPacketsSent)/(i.packetsSent-f.packetsSent),this.monitor.rtcMediaStatistics(d,{})),r.video=i,n._fractionLost=Math.max(n._fractionLost,n.videoLossRate),e.abrupt("return",n);case 25:case"end":return e.stop()}}),e,this)}))),function(e,r){return t.apply(this,arguments)})}]),i}(),RemoteStatsReport=function(e){_inherits(o,Stats);var t,r,n,i=_createSuper(o);function o(e){var t;return _classCallCheck(this,o),_defineProperty(_assertThisInitialized(t=i.call(this,e)),"_audioStallCount",void 0),_defineProperty(_assertThisInitialized(t),"_setAudioStallCount",void 0),_defineProperty(_assertThisInitialized(t),"_audioStallTimer",void 0),_defineProperty(_assertThisInitialized(t),"_audioStallInterval",void 0),_defineProperty(_assertThisInitialized(t),"_audioStallRatio",void 0),_defineProperty(_assertThisInitialized(t),"_videoInWaiting",void 0),t._videoInWaiting=!1,t}return _createClass(o,[{key:"setRemoteStreamStatsEvtInterval",value:(n=_asyncToGenerator(_regeneratorRuntime().mark((function e(t,r,n){var i,a,s,c,u,l,d,p,_,f,h,m,y,v,S=this;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._timer){e.next=2;break}return e.abrupt("return");case 2:return this.setVar(t,r,n),t.once(StateEvent.ABNORMAL_DISCONNECTION,(function(){S.destroy()})),this._audioStallInterval=o.audioStallInterval||100,this._audioStallRatio=o.audioStallRatio||.6,s={audio:{},video:{}},c=this._stream,u=null===(i=c.audioTrack)||void 0===i?void 0:i.getTrack(),l=null===(a=c.videoTrack)||void 0===a?void 0:a.getTrack(),this.getRemoteVideoStats(l,s),e.next=13,this.getRemoteAudioStats(u,s);case 13:this.delStatsEvtInterval(),d=0,p=0,f=[],h=0,m=getServerNow(),this._setAudioStallCount=function(){if(S._audioStallInterval>0&&void 0!==s.audio.concealedSamples){var e=s.audio.concealedSamples,t=s.audio.totalSamplesReceived;m=getServerNow();var r={isStall:!1,counted:!1,diff:0},n=.5*S._audioStallInterval;S._audioStallCount=_asyncToGenerator(_regeneratorRuntime().mark((function i(){var o,a,s,u,l,_,y,v,g,E,T,b,R,I,$;return _regeneratorRuntime().wrap((function(i){for(;;)switch(i.prev=i.next){case 0:if(a=c.hasAudio,s=c.subAudio,a&&s){i.next=7;break}return r.isStall=!1,r.counted=!1,f.push({reason:"hasAudio: ".concat(a,", subAudio: ").concat(s)}),m=getServerNow(),i.abrupt("return",{stall_count:d,stall_duration:p,stall_list:f,stats_count:h});case 7:return u=null===(o=c.audioTrack)||void 0===o?void 0:o.getTrack(),l=Date.now(),i.next=11,S.handler.getStats(u,!0);case 11:if(_=i.sent,y=Date.now(),v=getServerNow(),!((g=v-m)<n)){i.next=18;break}return f.push({diff:g,start:m,end:v,get_stats_cost:y-l,get_stats_start:l,get_stats_end:y,reason:"diff(".concat(g,") < minInterval(").concat(n,")")}),i.abrupt("return",{stall_count:d,stall_duration:p,stall_list:f,stats_count:h});case 18:if(E=_.length,T=_.find((function(e){return"inbound-rtp"===e.type}))){i.next=23;break}return f.push({diff:g,start:m,end:v,get_stats_cost:y-l,get_stats_start:l,get_stats_end:y,reason:E?"no inbound-rtp":"no report"}),i.abrupt("return",{stall_count:d,stall_duration:p,stall_list:f,stats_count:h});case 23:return b=T.concealedSamples,R=T.totalSamplesReceived,$=R-t,(I=b-e)>=0&&$>=0&&I>=S._audioStallRatio*$?(f.push({concealed:I,received:$,diff:g,start:m,end:v,get_stats_cost:y-l,get_stats_start:l,get_stats_end:y,is_stall:!0}),r.isStall?(r.counted?p+=g:(p=p+r.diff+g,d++),r.counted=!0):g>=200?(p+=g,d++,r.counted=!0):(r.counted=!1,r.diff=g),r.isStall=!0):(f.push({concealed:I,received:$,diff:g,start:m,end:v,get_stats_cost:y-l,get_stats_start:l,get_stats_end:y}),r.isStall=!1,r.counted=!1),e=b,t=R,m=v,h++,i.abrupt("return",{stall_count:d,stall_duration:p,stall_list:f,stats_count:h});case 32:case"end":return i.stop()}}),i)}))),_=function(){var e=_asyncToGenerator(_regeneratorRuntime().mark((function e(){return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!S._audioStallCount&&S._setAudioStallCount&&S._setAudioStallCount(),!S._audioStallCount){e.next=5;break}return e.next=4,S._audioStallCount();case 4:S._audioStallTimer=setTimeout(_,S._audioStallInterval);case 5:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),S._audioStallTimer=setTimeout(_,S._audioStallInterval)}},this._setAudioStallCount(),y=function(){var e=_asyncToGenerator(_regeneratorRuntime().mark((function e(){var t,r,n,i,o,a;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=null===(t=c.audioTrack)||void 0===t?void 0:t.getTrack(),i=null===(r=c.videoTrack)||void 0===r?void 0:r.getTrack(),e.next=4,S.getRemoteAudioStats(n,s);case 4:return o=e.sent,d=0,p=0,f=[],h=0,e.next=11,S.getRemoteVideoStats(i,s);case 11:return a=e.sent,e.abrupt("return",{audioStats:o,videoStats:a,isScreen:c.isScreen,userId:c.userId});case 13:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),v=function(){var e=_asyncToGenerator(_regeneratorRuntime().mark((function e(){var t,r;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,y();case 2:r=e.sent,null===(t=S.client)||void 0===t||t.emit("onRemoteStreamStats",r),_&&(m=getServerNow(),S._audioStallTimer=setTimeout(_,S._audioStallInterval)),S._timer=setTimeout(v,2e3);case 6:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),this._timer=setTimeout(v,2e3);case 24:case"end":return e.stop()}}),e,this)}))),function(e,t,r){return n.apply(this,arguments)})},{key:"delStatsEvtInterval",value:function(){_get(_getPrototypeOf(o.prototype),"delStatsEvtInterval",this).call(this),clearTimeout(this._audioStallTimer),this._audioStallCount=void 0,this._setAudioStallCount=void 0}},{key:"unsubscribe",value:function(){this.delStatsEvtInterval(),this._videoInWaiting=!1}},{key:"getRemoteAudioStats",value:(r=_asyncToGenerator(_regeneratorRuntime().mark((function e(t,r){var n,i,o,a,s,c,u,l,d,p,_,f,h,m,y,v,S,g;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n={},i={},o=this._stream,a=o.streamId,s=o.userId,c=o.isScreen,u=o.audioMid,l=o.subMediaType,d=o._attributes,p={media_type:"audio",is_screen:!!c,direction:"down",stream_id:a,stream_user_id:s,vid:u,connection_status:navigator.onLine,mute_state:audioInMediaType(l)?"mute_state_off":"mute_state_on",remote_user_capture_state:d.localaudio?"capture_state_on":"capture_state_off",remote_user_mute_state:d.localaudio&&d.audiostream?"mute_state_off":"mute_state_on"},t&&this.handler){e.next=6;break}return e.abrupt("return",n);case 6:return e.next=8,this.handler.getStats(t);case 8:if((_=e.sent).length){e.next=11;break}return e.abrupt("return",n);case 11:if(_.forEach((function(e){var t=e.type,r=e.packetsLost,o=e.packetsReceived,a=e.bytesReceived,s=e.jitterBufferDelay,c=e.jitterBufferEmittedCount,u=e.clockRate,l=e.channels,d=e.totalSamplesReceived,_=e.concealedSamples,f=e.silentConcealedSamples,h=e.concealmentEvents,m=e.totalRoundTripTime,y=e.state,v=e.currentRoundTripTime,S=e.audioLevel,g=e.totalAudioEnergy,E=e.totalSamplesDuration,T=e.mimeType,b=e.googDecodingNormal,R=e.fecPacketsReceived,I=e.availableIncomingBitrate,$=e.availableOutgoingBitrate,A=e.bytesSent,C=e.nominated,O=e.id,P=e.writable,k=e.jitter,w=e.candidateType,N=e.ip,D=e.address,M=e.networkType,x=e.port,L=e.protocol,U=e.audioOutputLevel,F=e.requestsReceived,B=e.responsesReceived,V=e.requestsSent,j=e.consentRequestsSent,G=e.responsesSent,H=e.ssrc;e.kind,"inbound-rtp"===t?(i.packetsLost=r,i.packetsReceived=o,p.packetsReceived=o,i.bytesReceived=a,p.bytes=a,void 0!==s&&(n.jitterBufferDelay=s/c*1e3,p.average_jitter_buffer_delay_ms=n.jitterBufferDelay),void 0!==d&&(i.totalSamplesReceived=d,n.concealedSamples=_,i.concealedSamples=_,i.silentConcealedSamples=f,p.concealedSamples=_,n.concealmentEvents=h,p.totalSamplesReceived=d),void 0!==R&&(p.fec_packets_received=R),p.jitter=1e3*k,p.ssrc=H):"codec"===t?(n.recordSampleRate=u,l&&(n.numChannels=l),p.codecName=T):"candidate-pair"===t?(p.ice_available_incoming_bitrate=I,p.ice_available_outgoing_bitrate=$,p.ice_bytes_received=a,p.ice_bytes_sent=A,p.ice_nominated=+C,p.ice_pair_id=O,p.ice_pair_rtt=v,p.rtt=1e3*v,p.ice_pair_state=y,p.ice_pair_writable=P,p.recv_ping_requests=F,p.recv_ping_responses=B,p.sent_ping_requests_before_first_response=V,p.sent_ping_requests_total=V+(j||0),p.sent_ping_responses=G,"succeeded"===y&&(n.rtt=1e3*v,n.total_rtt=1e3*m)):"track"===t&&void 0!==S?(p.audio_level=S?-10*Math.log10(Math.pow(S,2)):S,p.volume=255*S,p.total_audio_energy=g,p.totalAudioDuration=E):"ssrc"===t?(p.decodingNormal=b,p.recvAudioLevel=U):"local-candidate"===t?(p.local_candidate_type=w,p.local_ip=N||D,p.local_network_type=M,p.local_port=x,p.protocol=L):"remote-candidate"===t&&(p.remote_candidate_type=w,p.remote_ip=N||D,p.remote_port=x)})),(f=r.audio).timestamp){e.next=17;break}return i.timestamp=Date.now(),r.audio=i,e.abrupt("return",n);case 17:if(h={},void 0!==i.concealedSamples&&(p.interval_concealed_samples=i.concealedSamples-f.concealedSamples,p.interval_samples_received=i.totalSamplesReceived-f.totalSamplesReceived,p.interval_silent_concealed_samples=i.silentConcealedSamples-f.silentConcealedSamples),!(this._audioStallInterval>0&&void 0!==f.concealedSamples)){e.next=35;break}if(!this._audioStallCount&&this._setAudioStallCount&&this._setAudioStallCount(),clearTimeout(this._audioStallTimer),!this._audioStallCount){e.next=35;break}return e.next=25,this._audioStallCount();case 25:m=e.sent,y=m.stall_count,v=m.stall_duration,S=m.stall_list,g=m.stats_count,h.stall_list=S,h.stats_count=g,p.concealedSamples===p.interval_concealed_samples&&p.totalSamplesReceived===p.interval_samples_received?(p.stall_count=0,p.stall_duration=0):(p.stall_count=y,p.stall_duration=v),n.stallCount=p.stall_count,n.stallDuration=p.stall_duration;case 35:return i.timestamp=Date.now(),n.audioLossRate=(i.packetsLost-f.packetsLost)/(i.packetsReceived-f.packetsReceived+(i.packetsLost-f.packetsLost)),n.audioLossRate=Number.isNaN(n.audioLossRate)?0:n.audioLossRate,p.packetsLost=Math.round(i.packetsLost-f.packetsLost),p.fraction_lost=n.audioLossRate,p.packets_lost_rate=n.audioLossRate,n.statsInterval=i.timestamp-f.timestamp,p.stats_interval=n.statsInterval,n.receivedKBitrate=(i.bytesReceived-f.bytesReceived||0)/n.statsInterval*8,p.bitrate=Math.round(1e3*n.receivedKBitrate),p.bandwidth=Math.round(p.bitrate/1024),void 0!==i.concealedSamples&&(n.receivedSampleRate=1e3*p.interval_samples_received/n.statsInterval),r.audio=i,this.monitor.rtcMediaStatistics(p,{},h),e.abrupt("return",n);case 50:case"end":return e.stop()}}),e,this)}))),function(e,t){return r.apply(this,arguments)})},{key:"getRemoteVideoStats",value:(t=_asyncToGenerator(_regeneratorRuntime().mark((function e(t,r){var n,i,o,a,s,c,u,l,d,p,_;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n={},i={timestamp:Date.now()},o=this._stream,a=o.streamId,s=o.userId,c=o.isScreen,u=o.subMediaType,l=o._attributes,d={media_type:"video",is_screen:!!c,direction:"down",stream_id:a,stream_user_id:s,vid:this._stream.videoMid,connection_status:navigator.onLine,mute_state:videoInMediaType(u)?"mute_state_off":"mute_state_on",remote_user_capture_state:l.localvideo?"capture_state_on":"capture_state_off",remote_user_mute_state:l.localvideo&&l.videostream?"mute_state_off":"mute_state_on"},t&&this.handler){e.next=6;break}return e.abrupt("return",n);case 6:return n.isScreen=c,e.next=9,this.handler.getStats(t);case 9:if((p=e.sent).length){e.next=12;break}return e.abrupt("return",n);case 12:if(p.forEach((function(e){var t=e.type,r=e.frameHeight,o=e.frameWidth,a=e.packetsLost,s=e.packetsReceived,c=e.bytesReceived,u=e.framesDecoded,l=e.jitterBufferDelay,p=e.jitterBufferEmittedCount,_=e.mimeType,f=e.firCount,h=e.availableIncomingBitrate,m=e.availableOutgoingBitrate,y=e.bytesSent,v=e.nominated,S=e.id,g=e.currentRoundTripTime,E=e.state,T=e.writable,b=e.candidateType,R=e.ip,I=e.address,$=e.networkType,A=e.port,C=e.nackCount,O=e.pliCount,P=e.protocol,k=e.requestsReceived,w=e.responsesReceived,N=e.requestsSent,D=e.consentRequestsSent,M=e.responsesSent,x=e.ssrc;e.kind;var L=e.jitter,U=e.framesReceived,F=e.keyFramesDecoded,B=e.totalDecodeTime,V=e.decoderImplementation,j=e.lastPacketReceivedTimestamp;"inbound-rtp"===t?(i.packetsLost=a,d.packetsLost=a,i.packetsReceived=s,d.packetsReceived=s,i.bytesReceived=c,d.bytes=c,i.framesDecoded=u,void 0!==l&&(i.jitterBufferDelay=l/p*1e3,d.average_jitter_buffer_delay_ms=i.jitterBufferDelay),d.fir_count=f,d.nackCount=C,i.nackCount=C,d.pli_count=O,d.ssrc=x,d.jitter=L,d.framesReceived=U,i.framesReceived=U,d.framesDecoded=u,d.key_frames_decoded=F,d.total_decode_time=B,d.decoder_name=V,d.last_packet_received_timestamp=j,void 0!==o&&(n.width=o,d.frame_size_width=o,n.height=r,d.frame_size_height=r)):"track"===t&&void 0!==o?(n.width=o,d.frame_size_width=o,n.height=r,d.frame_size_height=r,void 0!==U&&(d.framesReceived=U,i.framesReceived=U)):"codec"===t?d.codecName=_:"candidate-pair"===t?(d.ice_available_incoming_bitrate=h,d.ice_available_outgoing_bitrate=m,d.ice_bytes_received=c,d.ice_bytes_sent=y,d.ice_nominated=+v,d.ice_pair_id=S,d.ice_pair_rtt=g,d.rtt=1e3*g,n.rtt=d.rtt,d.ice_pair_state=E,d.ice_pair_writable=T,d.recv_ping_requests=k,d.recv_ping_responses=w,d.sent_ping_requests_before_first_response=N,d.sent_ping_requests_total=N+(D||0),d.sent_ping_responses=M):"local-candidate"===t?(d.local_candidate_type=b,d.local_ip=R||I,d.local_network_type=$,d.local_port=A,d.protocol=P):"remote-candidate"===t&&(d.remote_candidate_type=b,d.remote_ip=R||I,d.remote_port=A)})),(_=r.video).timestamp){e.next=17;break}return r.video=i,e.abrupt("return",n);case 17:return n.videoLossRate=(i.packetsLost-_.packetsLost)/(i.packetsReceived-_.packetsReceived+(i.packetsLost-_.packetsLost)),n._retransmittedRate=(i.nackCount-_.nackCount)/(i.packetsReceived-_.packetsReceived+(i.packetsLost-_.packetsLost)),n.videoLossRate=Number.isNaN(n.videoLossRate)?0:n.videoLossRate,d.fraction_lost=n.videoLossRate,d.packets_lost_rate=n.videoLossRate,n.statsInterval=i.timestamp-_.timestamp,d.stats_interval=n.statsInterval,n.receivedKBitrate=(i.bytesReceived-_.bytesReceived||0)/n.statsInterval*8,d.bitrate=Math.round(1e3*n.receivedKBitrate),d.bandwidth=Math.round(d.bitrate/1024),n.decoderOutputFrameRate=1e3*(i.framesDecoded-_.framesDecoded)/n.statsInterval,n.receivedFrameRate=1e3*(i.framesReceived-_.framesReceived)/n.statsInterval,d.frame_rate_decoded=Math.round(n.decoderOutputFrameRate),d.frame_rate_received=d.frame_rate_decoded,r.video=i,this.processStall(this._stream,d,n,c),this.monitor.rtcMediaStatistics(d,{}),e.abrupt("return",n);case 35:case"end":return e.stop()}}),e,this)}))),function(e,r){return t.apply(this,arguments)})},{key:"processStall",value:function(e,t,r,n){var i=0,o=0,a=0;if(e.recordedVideoFrames){e.recordedVideoFrames.forEach((function(e){e.isStall&&(i+=e.stallCount,o+=e.stallDuration),a=e.playTime})),e.recordedVideoFrames.length||(o=2e3,i=this._videoInWaiting?0:1,this._videoInWaiting=!0);var s=e.recordedVideoFrames.pop();s&&(s.isStall?this._videoInWaiting=!0:this._videoInWaiting=!1),e.recordedVideoFrames=[]}t.stall_count=i,n?(t.stuck_length=o,t.stall_duration=void 0):(t.stall_duration=o,t.stuck_length=void 0),t.play_time=a,r.stallCount=i,r.stallDuration=o}},{key:"destroy",value:function(){_get(_getPrototypeOf(o.prototype),"destroy",this).call(this),this.delStatsEvtInterval(),this._videoInWaiting=!1}}],[{key:"audioStallConfig",set:function(e){o.audioStallInterval=((null==e?void 0:e.audio_stall_interval)||200)/2,o.audioStallRatio=null==e?void 0:e.audio_stall_ratio}}]),o}();_defineProperty(RemoteStatsReport,"audioStallInterval",void 0),_defineProperty(RemoteStatsReport,"audioStallRatio",void 0);var _negativedAction,_aggregationSdpStrate,_RoomProfileMap,RoomEvent=function(e){return e.RESUBSCRIBE="resubscribe",e.STREAM_FAILED="stream_failed",e.SUBSCRIBE_PUSH_TRACK="subscribe_push_track",e.REMOVE_PUSH_TRACK="remove_push_track",e.VIDEO_FIRST_FRAME="video_first_frame",e.ON_USER_PUBLISH_STATE_CHANGE="on_user_publish_state_change",e.ON_USER_START_AUDIO_CAPTURE="on_user_start_audio_capture",e.ON_USER_STOP_AUDIO_CAPTURE="on_user_stop_audio_capture",e.ON_USER_START_VIDEO_CAPTURE="on_user_start_video_capture",e.ON_USER_STOP_VIDEO_CAPTURE="on_user_stop_video_capture",e.ON_SEI_MESSAGED_RECEIVED="on_sei_messaged_received",e.ON_PUBLISH_RESULT="on_publish_result",e.ON_UPDATE_TOKEN_SUCCESS="on_update_token_success",e.ON_REMOTE_STREAM_STATS="ON_REMOTE_STREAM_STATS",e.ON_LOCAL_STREAM_STATS="ON_LOCAL_STREAM_STATS",e.ON_USER_LEAVE="on_user_leave",e.ON_ROOM_ERROR="on_room_error",e.ON_NETWORK_QUALITY="on_network_quality",e.ON_SIMULCAST_SUBSCRIBE_FALLBACK="on_simulcast_subscribe_fallback",e.ON_REMOTE_VIDEO_SIZE_CHANGED="on_remote_video_size_changed",e.RECONNECT_FAILED="reconnect_failed",e.ON_VIDEO_STREAM_BANNED="ON_VIDEO_STREAM_BANNED",e.ON_AUDIO_STREAM_BANNED="ON_AUDIO_STREAM_BANNED",e}(RoomEvent||{}),StreamMixingEventType=function(e){return e[e.START=1]="START",e[e.START_SUCCESS=2]="START_SUCCESS",e[e.START_FAILED=3]="START_FAILED",e[e.UPDATE=4]="UPDATE",e[e.UPDATE_SUCCESS=5]="UPDATE_SUCCESS",e[e.UPDATE_FAILED=6]="UPDATE_FAILED",e[e.STOP=7]="STOP",e[e.STOP_SUCCESS=8]="STOP_SUCCESS",e[e.STOP_FAILED=9]="STOP_FAILED",e}(StreamMixingEventType||{}),PubState=function(e){return e[e.PUB=0]="PUB",e[e.UNPUB=1]="UNPUB",e}(PubState||{}),SubState=function(e){return e[e.SUB=0]="SUB",e[e.UNSUB=1]="UNSUB",e}(SubState||{}),logger$d=new Logger("Stream",0),StreamState=function(e){return e[e.INIT=0]="INIT",e[e.SUB_ING=1]="SUB_ING",e[e.SUB_ED=2]="SUB_ED",e}(StreamState||{}),LocalStream=function(){function e(){_classCallCheck(this,e),_defineProperty(this,"isScreen",!1),_defineProperty(this,"stream",void 0),_defineProperty(this,"streamId",void 0),_defineProperty(this,"audioMid",void 0),_defineProperty(this,"videoMid",void 0),_defineProperty(this,"seiList",[]),_defineProperty(this,"videoTrack",void 0),_defineProperty(this,"audioTrack",void 0),_defineProperty(this,"videoTransceiver",void 0),_defineProperty(this,"audioTransceiver",void 0),_defineProperty(this,"videoInputConfig",void 0),_defineProperty(this,"videoEncodeConfig",[defaultVideoEncoderConfig]),_defineProperty(this,"subVideoDescriptions",[]),_defineProperty(this,"enableSimulcast",!1),_defineProperty(this,"observer",void 0),_defineProperty(this,"statsReport",void 0),_defineProperty(this,"prevScaleResolutionDownBy",1),_defineProperty(this,"pubAudio",!1),_defineProperty(this,"pubVideo",!1),_defineProperty(this,"pubAttributes",void 0),this.stream=new MediaStream,this.videoInputConfig={width:640,height:360,frameRate:30},this.pubAttributes={localaudio:!1,localvideo:!1,videostream:!1,audiostream:!1,extvideo:!1,extaudio:!1},this.statsReport=new LocalStatsReport(this)}return _createClass(e,[{key:"hasPublished",get:function(){return this.videoTransceiver&&this.audioTransceiver}},{key:"isEmptyStream",get:function(){return!this.audioTrack&&!this.videoTrack}},{key:"initStreamId",get:function(){return this.stream.id}},{key:"initVideoEncodedTransform",value:function(){var e=this;if(this.videoTransceiver&&this.videoTransceiver.sender){var t=this.videoTransceiver.sender;if(isEncodedTransformSupported()){var r=t.createEncodedStreams(),n=r.readable,i=r.writable,o=new TransformStream({transform:function(t,r){var n=e.seiList[0];if(n){var i=SEIHelper.generateSEI(n.content),o=new Uint8Array(i.byteLength+t.data.byteLength);0===n.repeatCount&&e.seiList.splice(0,1),n.repeatCount--,o.set(new Uint8Array(t.data)),o.set(i,t.data.byteLength),t.data=o.buffer,r.enqueue(t)}else r.enqueue(t)}});n.pipeThrough(o).pipeTo(i)}}else logger$d.print("no sender found when trying to bind encodedTransform")}},{key:"initAudioEncodedTransform",value:function(){if(this.audioTransceiver&&this.audioTransceiver.sender){var e=this.audioTransceiver.sender.createEncodedStreams(),t=e.readable,r=e.writable;t.pipeThrough(new TransformStream({transform:function(e,t){t.enqueue(e)}})).pipeTo(r)}else logger$d.print("no sender found when trying to bind encodedTransform")}},{key:"clean",value:function(){var e;this.audioMid=void 0,this.videoMid=void 0,this.videoTransceiver=void 0,this.audioTransceiver=void 0,null===(e=this.observer)||void 0===e||e.reset(),this.statsReport.destroy(),this.prevScaleResolutionDownBy=1,this.subVideoDescriptions=[]}},{key:"switchTrackEnableState",value:function(e,t){var r,n;"audio"===e?n=this.audioTrack:"video"===e&&(n=this.videoTrack);var i=null===(r=n)||void 0===r?void 0:r.getTrack();return!(!i||(null==i?void 0:i.enabled)===t)&&(i.enabled=t,!0)}}]),e}(),RemoteStream=function(e){_inherits(r,EnhancedEventEmitter);var t=_createSuper(r);function r(e,n,i,o){var a,s=arguments.length>4&&void 0!==arguments[4]?arguments[4]:RemoteUserPriority.LOW;return _classCallCheck(this,r),_defineProperty(_assertThisInitialized(a=t.call(this)),"streamId",void 0),_defineProperty(_assertThisInitialized(a),"userId",void 0),_defineProperty(_assertThisInitialized(a),"isScreen",void 0),_defineProperty(_assertThisInitialized(a),"hasVideo",void 0),_defineProperty(_assertThisInitialized(a),"hasAudio",void 0),_defineProperty(_assertThisInitialized(a),"_attributes",void 0),_defineProperty(_assertThisInitialized(a),"streamState",void 0),_defineProperty(_assertThisInitialized(a),"observer",void 0),_defineProperty(_assertThisInitialized(a),"statsReport",void 0),_defineProperty(_assertThisInitialized(a),"subVideo",void 0),_defineProperty(_assertThisInitialized(a),"subAudio",void 0),_defineProperty(_assertThisInitialized(a),"subMediaType",void 0),_defineProperty(_assertThisInitialized(a),"subLayer",void 0),_defineProperty(_assertThisInitialized(a),"audioMid",void 0),_defineProperty(_assertThisInitialized(a),"videoMid",void 0),_defineProperty(_assertThisInitialized(a),"autosubAudioMid",void 0),_defineProperty(_assertThisInitialized(a),"autosubVideoMid",void 0),_defineProperty(_assertThisInitialized(a),"_sequenceId",void 0),_defineProperty(_assertThisInitialized(a),"stream",void 0),_defineProperty(_assertThisInitialized(a),"videoTrack",void 0),_defineProperty(_assertThisInitialized(a),"audioTrack",void 0),_defineProperty(_assertThisInitialized(a),"videoTransceiver",void 0),_defineProperty(_assertThisInitialized(a),"audioTransceiver",void 0),_defineProperty(_assertThisInitialized(a),"recordedVideoFrames",void 0),_defineProperty(_assertThisInitialized(a),"stillExist",void 0),_defineProperty(_assertThisInitialized(a),"_workaround_1_",void 0),_defineProperty(_assertThisInitialized(a),"paused",void 0),_defineProperty(_assertThisInitialized(a),"originalMediaType",void 0),_defineProperty(_assertThisInitialized(a),"originalStreamIndex",0),a.userPriority=s,a.userId=e,a.isScreen=i,a.streamId=n,a.hasAudio=o.audiostream&&o.localaudio,a.hasVideo=o.videostream&&o.localvideo,a._attributes=o,a.subVideo=!1,a.subAudio=!1,a._sequenceId=0,a.subMediaType=ExtendMediaType.NONE,a.subLayer={spatialLayer:0,spatialSubLayer:-1},a.streamState=0,a.statsReport=new RemoteStatsReport(_assertThisInitialized(a)),a}return _createClass(r,[{key:"sequenceId",get:function(){return this._sequenceId||-1},set:function(e){"number"==typeof e&&(this._sequenceId=e)}},{key:"hasSubscribed",get:function(){return 2===this.streamState}},{key:"attributes",get:function(){return this._attributes},set:function(e){this.hasVideo=e.localvideo&&e.videostream,this.hasAudio=e.localaudio&&e.audiostream,this._attributes=e}},{key:"initVideoEncodedTransform",value:function(){var e=this;if(this.videoTransceiver&&this.videoTransceiver.receiver){var t=this.videoTransceiver.receiver.createEncodedStreams(),r=t.readable,n=t.writable;r.pipeThrough(new TransformStream({transform:function(t,r){Nalunit.getNalunits(new RTCDataView(t.data)).forEach((function(t){if(t.sei){var r=SEIHelper.decodeSeiBody(t.body);r&&r.type!==RTC_SEI_TYPE.internal&&e.safeEmit("onSEIMessage",r.payload)}})),r.enqueue(t)}})).pipeTo(n)}else logger$d.print("no receiver found when trying to bind encodedTransform")}},{key:"initAudioEncodedTransform",value:function(){if(this.audioTransceiver&&this.audioTransceiver.receiver){var e=this.audioTransceiver.receiver.createEncodedStreams(),t=e.readable,r=e.writable;t.pipeThrough(new TransformStream({transform:function(e,t){t.enqueue(e)}})).pipeTo(r)}else logger$d.print("no receiver found when trying to bind encodedTransform")}},{key:"ontrack",value:function(e){var t,r;if((null===(t=e.streams)||void 0===t||null===(r=t[0])||void 0===r?void 0:r.id)===this.streamId){var n,i=e.track;"video"===(null==i?void 0:i.kind)?this._setVideoTrack(i):"audio"===(null===(n=e.track)||void 0===n?void 0:n.kind)&&this._setAudioTrack(i),this._setStream(e.streams[0])}this.safeEmit("ontrack",e)}},{key:"clean",value:function(){var e;logger$d.print("clean","exec stream.clean ".concat(this.streamId," ").concat(this.userId)),this.subAudio=!1,this.subVideo=!1,this.audioMid=void 0,this.videoMid=void 0,this.sequenceId=0,this.videoTrack=void 0,this.audioTrack=void 0,this.stream=void 0,this.videoTransceiver=void 0,this.audioTransceiver=void 0,this.recordedVideoFrames=void 0,this.paused=!1,this._workaround_1_=!1,null===(e=this.observer)||void 0===e||e.reset(),this.statsReport.destroy()}},{key:"resetHasSubscribed",value:function(){this.streamState=0}},{key:"setRemoteUserPriority",value:function(e){this.userPriority=e}},{key:"getStreamPriority",value:function(){var e=this.isScreen?20:this.hasAudio||this.hasVideo?this.attributes.videoDescriptions.length>1?10-this.subLayer.spatialLayer:9:0;return 1e4*this.userPriority+100*e}},{key:"getSubscribeFallbackParams",value:function(e){if(e!==SubscribeFallbackOption.DISABLE&&this.subVideo){if(this.attributes.videoDescriptions.length-1>this.subLayer.spatialLayer)return[this.originalMediaType,SubState.SUB,this._getSubLayerBySpatialLayer(this.subLayer.spatialLayer+1)];if(e===SubscribeFallbackOption.AUDIO_ONLY)return[MediaType.VIDEO,SubState.UNSUB]}return null}},{key:"getSubscribeRecoverParams",value:function(){if(this.originalMediaType&&videoInMediaType(this.originalMediaType)){if(!1===this.subVideo)return[this.originalMediaType,SubState.SUB,this.subLayer];if("number"==typeof this.originalStreamIndex&&this.subLayer.spatialLayer>this.originalStreamIndex)return[this.originalMediaType,SubState.SUB,this._getSubLayerBySpatialLayer(this.subLayer.spatialLayer-1)]}return null}},{key:"_setStream",value:function(e){var t=this;this.stream=e,e.onaddtrack=function(e){"video"===e.track.kind?t._setVideoTrack(e.track):"audio"===e.track.kind&&t._setAudioTrack(e.track)}}},{key:"_setAudioTrack",value:function(e){var t,r;(null===(t=this.audioTrack)||void 0===t||null===(r=t.getTrack())||void 0===r?void 0:r.id)!==(null==e?void 0:e.id)&&(this.audioTrack=new RemoteAudioTrack(e,genUuid()),this.emit("ontrack",this.audioTrack))}},{key:"_setVideoTrack",value:function(e){var t,r;(null===(t=this.videoTrack)||void 0===t||null===(r=t.getTrack())||void 0===r?void 0:r.id)!==(null==e?void 0:e.id)&&(this.videoTrack=new RemoteVideoTrack(e,genUuid()),this.emit("ontrack",this.videoTrack))}},{key:"_getSubLayerBySpatialLayer",value:function(e){var t=this._attributes,r=t.videoDescriptions,n=t.subVideoDescriptions,i=void 0===n?[]:n,o=r[e],a=o.width,s=o.height,c=i.find((function(e){return e.width===a&&e.height===s}));return{spatialLayer:e,spatialSubLayer:(null==c?void 0:c.sub_index)||-1}}}]),r}(),logger$c=new Logger("queue",4),SdpStrategy=function(e){return e[e.ADD=0]="ADD",e[e.CLOSE=1]="CLOSE",e}(SdpStrategy||{}),SdpAction=function(e){return e.publish="publish",e.unpublish="unpublish",e.subscribe="subscribe",e.unsubscribe="unsubscribe",e.pushtrack="pushtrack",e.removetrack="removetrack",e}(SdpAction||{}),negativedAction=(_defineProperty(_negativedAction={},"publish","unpublish"),_defineProperty(_negativedAction,"subscribe","unsubscribe"),_defineProperty(_negativedAction,"pushtrack","removetrack"),_negativedAction),aggregationSdpStrategy=(_defineProperty(_aggregationSdpStrate={},"publish",0),_defineProperty(_aggregationSdpStrate,"subscribe",0),_defineProperty(_aggregationSdpStrate,"pushtrack",0),_defineProperty(_aggregationSdpStrate,"unpublish",1),_defineProperty(_aggregationSdpStrate,"unsubscribe",1),_defineProperty(_aggregationSdpStrate,"removetrack",1),_aggregationSdpStrate),SdpQueue=function(e){_inherits(r,EventEmitter);var t=_createSuper(r);function r(){var e;return _classCallCheck(this,r),_defineProperty(_assertThisInitialized(e=t.call(this)),"_queue",void 0),e._queue=[],e}return _createClass(r,[{key:"queue",get:function(){return this._queue}},{key:"enqueue",value:function(e){var t=this._queue.length,r="";return this._queue=this._queue.filter((function(t){return t.streamId!==e.streamId||e.action!==negativedAction[t.action]||(r=t.streamId,logger$c.print("offsetStreamId",r),!1)})),this._queue.length===t&&this._queue.push(e),this.emit("start"),r}},{key:"dequeue",value:function(){if(!this._queue.length)return null;for(var e=aggregationSdpStrategy[this._queue[0].action],t=1;t<this._queue.length;t++)if(aggregationSdpStrategy[this._queue[t].action]!==e)return{sdpStrategy:e,items:this._queue.splice(0,t)};return{sdpStrategy:e,items:this._queue.splice(0,this._queue.length)}}}]),r}(),logger$b=new Logger("ChromeHandler",3),encodedTransformSupported=isEncodedTransformSupported(),ChromeHandler=function(e){_inherits(l,BasicHandler);var t,r,n,i,o,a,s,c,u=_createSuper(l);function l(e,t){var r;return _classCallCheck(this,l),_defineProperty(_assertThisInitialized(r=u.call(this,e,t)),"name","chrome"),_defineProperty(_assertThisInitialized(r),"_queueBusy",!1),_defineProperty(_assertThisInitialized(r),"_sdpQueue",void 0),_defineProperty(_assertThisInitialized(r),"_aSendonlyOfferTpl",void 0),_defineProperty(_assertThisInitialized(r),"_vSendonlyOfferTpl",void 0),_defineProperty(_assertThisInitialized(r),"_aRecvonlyOfferTpl",void 0),_defineProperty(_assertThisInitialized(r),"_vRecvonlyOfferTpl",void 0),_defineProperty(_assertThisInitialized(r),"_mid",0),_defineProperty(_assertThisInitialized(r),"_offerSession",void 0),_defineProperty(_assertThisInitialized(r),"_answerSession",void 0),_defineProperty(_assertThisInitialized(r),"_offerMlines",[]),_defineProperty(_assertThisInitialized(r),"_answerMlines",[]),_defineProperty(_assertThisInitialized(r),"_inactiveMlineIndex",[]),_defineProperty(_assertThisInitialized(r),"_msidIndexMap",{}),_defineProperty(_assertThisInitialized(r),"_mlinesCache",{}),r._sdpQueue=new SdpQueue,r._sdpQueue.on("start",(function(){r._queueBusy||"stable"!==r._peerConnection.signalingState||(logger$b.print("dequeue start"),r.dequeue())})),r}return _createClass(l,[{key:"connect",value:(c=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){var r,n,i,o,a,s,c,u=this;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return logger$b.print("connect","invoke connect"),this._offerIce={iceUfrag:null===(r=t.iceParams)||void 0===r?void 0:r.clientIceUfrag,icePwd:null===(n=t.iceParams)||void 0===n?void 0:n.clientIcePwd,iceOptions:"renomination"},e.next=4,parseAnswerIceParams(t);case 4:return this._answerIce=e.sent,e.next=7,this._peerConnection.createOffer();case 7:return i=e.sent,o=lib.parse(i.sdp),a=_slicedToArray(o.media,1),s=a[0],this._offerIce.fingerprint=o.fingerprint||s.fingerprint,delete o.media,this._offerSession=_objectSpread2({},o),this._answerSession=_objectSpread2({},o),this._answerSession.fingerprint&&(this._answerSession.fingerprint=this._answerIce.fingerprint),c=this._mid++,this._offerMlines=[_objectSpread2(_objectSpread2(_objectSpread2({},s),this._offerIce),{},{mid:"".concat(c)})],this._answerMlines=[_objectSpread2(_objectSpread2(_objectSpread2({},s),this._answerIce),{},{sctpmap:{sctpmapNumber:5e3,app:"webrtc-datachannel",maxMessageSize:262144},mid:"".concat(c)})],this.setDescription(),e.next=21,new Promise((function(e,t){u._dataChannel.onopen=function(){logger$b.print("connect","dataChannel open"),reportRtcInvokeStatus("es.dc.open",""),e("")},u._dataChannel.onerror=function(e){monitor.rtcSignalingMsgError(e.error.sdpLineNumber,e.error.errorDetail,RtcsignalingmsgerrorReason.INVALID_DATA),reportRtcInvokeStatus("es.dc.error",""),t(e)},u._dataChannel.onclose=function(e){reportRtcInvokeStatus("es.dc.close",""),t(e)},u._peerConnection.addEventListener("connectionstatechange",(function(e){"failed"!==u._peerConnection.iceConnectionState&&"closed"!==u._peerConnection.iceConnectionState&&"failed"!==u._peerConnection.connectionState||t(e)}))}));case 21:return logger$b.print("connect","dataChannel establish success"),e.abrupt("return",this._dataChannel);case 23:case"end":return e.stop()}}),e,this)}))),function(e){return c.apply(this,arguments)})},{key:"disconnect",value:function(){this._peerConnection.close(),this._dataChannel.close(),this._peerConnection.ontrack=null}},{key:"destroy",value:function(){_get(_getPrototypeOf(l.prototype),"destroy",this).call(this),this._mlinesCache={}}},{key:"publish",value:(s=_asyncToGenerator(_regeneratorRuntime().mark((function e(t,r){var n,i,o,a,s,c,u,d,p,_,f,h,m,y,v,S,g,E,T,b;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=t.stream,i=t.enableSimulcast,o=_get(_getPrototypeOf(l.prototype),"internalPublish",this).call(this,t,r),a=o.videoDescriptions,s=o.subVideoDescriptions,c=o.transceiverInit,u="".concat(this._mid++),d="".concat(this._mid++),p=_objectSpread2(_objectSpread2(_objectSpread2({},this._aSendonlyOfferTpl),this._offerIce),{},{mid:u,msid:"".concat(n.id," ").concat(n.id,"-audio"),ssrcs:generateSsrc(n,"audio")}),_=_objectSpread2(_objectSpread2(_objectSpread2({},this._vSendonlyOfferTpl),this._offerIce),{},{mid:d,msid:"".concat(n.id," ").concat(n.id,"-video")}),i?(logger$b.print("subVideoDesc","desc: %o ",s),delete _.ssrcGroups,delete _.ssrcs,f=[],_.rids=a.map((function(e){var t=e.rid;return f.unshift(t),{id:t,direction:"send"}})),_.simulcast={dir1:"send",list1:f.join(";")}):(h=generateSsrcs(n,"video"),m=h.ssrcs,y=h.ssrcGroups,_.ssrcs=m,_.ssrcGroups=y),isSafari&&isMobile&&Array.isArray(_.ext)&&(_.ext=_.ext.filter((function(e){var t;return!(null!=e&&null!==(t=e.uri)&&void 0!==t&&t.includes("video-orientation"))}))),null!=r&&r.audioRed&&Array.isArray(p.rtp)&&-1!==(v=p.rtp.findIndex((function(e){return"red"===e.codec})))&&(S=p.rtp.splice(v,1),g=_slicedToArray(S,1),E=g[0],p.rtp.unshift(E)),(T=null==p?void 0:p.rtp.find((function(e){return"opus"===e.codec})))&&p.fmtp&&(b=p.fmtp.find((function(e){return e.payload===T.payload})))&&this._context&&(b.config+=this._context.audioProfileManager.getOpusConfigStr()),this.addBitrateLimit(_,t.videoEncodeConfig[0].maxKbps),this._mlinesCache[t.stream.id]=[p,_],e.abrupt("return",{partialSdp:getLocalPartialSdp(this._offerSession,p,_),audioMid:u,videoMid:d,type:"incroffer",semantics:"unified-plan",videoDescriptions:a,subVideoDescriptions:s,transceiverInit:c});case 14:case"end":return e.stop()}}),e,this)}))),function(e,t){return s.apply(this,arguments)})},{key:"subscribe",value:(a=_asyncToGenerator(_regeneratorRuntime().mark((function e(t,r){var n,i,o,a,s,c,u,l,d,p;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(logger$b.print("subscribe","mids: ",r),n="incroffer",i="unified-plan",this._aRecvonlyOfferTpl&&this._vRecvonlyOfferTpl){e.next=11;break}return e.next=6,createDefaultSdp(!0);case 6:if(o=e.sent){e.next=9;break}throw new SDKError(ErrorCode.NOT_SUPPORTED,"Get offer Error");case 9:return e.next=11,this.createAVMlineOfferTpl(o);case 11:if(!this._mlinesCache[t.streamId]){e.next=16;break}return a=_slicedToArray(this._mlinesCache[t.streamId],2),s=a[0],c=a[1],s.mid=t.audioMid,c.mid=t.videoMid,e.abrupt("return",{partialSdp:getLocalPartialSdp(this._offerSession,s,c),audioMid:s.mid,videoMid:c.mid,type:n,semantics:i});case 16:return u="".concat(this._mid++),l="".concat(this._mid++),d=_objectSpread2(_objectSpread2(_objectSpread2({},this._aRecvonlyOfferTpl),this._offerIce),{},{mid:u}),p=_objectSpread2(_objectSpread2(_objectSpread2({},this._vRecvonlyOfferTpl),this._offerIce),{},{mid:l}),this._mlinesCache[t.streamId]=[d,p],e.abrupt("return",{partialSdp:getLocalPartialSdp(this._offerSession,d,p),audioMid:u,videoMid:l,type:n,semantics:i,transceiverInit:{aTrack:"audio",vTrack:"video",audioTransceiverInit:{direction:"recvonly"},videoTransceiverInit:{direction:"recvonly"}}});case 22:case"end":return e.stop()}}),e,this)}))),function(e,t){return a.apply(this,arguments)})},{key:"handleAck",value:(o=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return logger$b.print("handleAck()","item: %o",t),e.abrupt("return",this._sdpQueue.enqueue(t));case 2:case"end":return e.stop()}}),e,this)}))),function(e){return o.apply(this,arguments)})},{key:"dequeue",value:(i=_asyncToGenerator(_regeneratorRuntime().mark((function e(){var t,r,n,i,o,a,s,c,u,l,d,p=this;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._queueBusy=!0,t=this._sdpQueue.dequeue(),logger$b.print("dequeue()","ret: %o",t),t){e.next=6;break}return this._queueBusy=!1,e.abrupt("return");case 6:if(e.prev=6,r=t.items,n=t.sdpStrategy,i=[],o=[],n!==SdpStrategy.ADD){e.next=14;break}return e.delegateYield(_regeneratorRuntime().mark((function e(){var t,n;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:delete(t=_objectSpread2({},p._answerIce)).candidates,a=!1,s=!1,e.prev=4,u=_asyncIterator(r);case 6:return e.next=8,u.next();case 8:if(!(a=!(l=e.sent).done)){e.next=17;break}return n=l.value,e.delegateYield(_regeneratorRuntime().mark((function e(){var r,a,s,c,u,l,d,_,f,h,m,y,v,S,g,E,T,b,R,I,$;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=n.action,a=n.transceiverInit,s=n.signalingAck,c=n.stream,!((u=c instanceof RemoteStream)&&(null==s?void 0:s.sequenceId)<c.sequenceId)){e.next=4;break}return e.abrupt("return","break");case 4:if(l={},d={},_=lib.parse(s.sdp),Array.isArray(_.media)&&(f="",_.media.sort((function(e,t){var r;return null==e||null===(r=e.type)||void 0===r?void 0:r.localeCompare(null==t?void 0:t.type)})).forEach((function(e){"audio"===(e=_objectSpread2(_objectSpread2({},e),t)).type?(l=e,logger$b.print("audioMsid",e.msid),e.msid&&(f=e.msid.replace("audio","video"))):(d=e,logger$b.print("videoMsid",f),f&&(d.msid=f,f=""))}))),h=c.streamId,r===SdpAction.publish&&(h=null===(m=c.stream)||void 0===m?void 0:m.id),p._mlinesCache[h]){e.next=12;break}return e.abrupt("return","break");case 12:if(y=_slicedToArray(p._mlinesCache[h],2),v=y[0],S=y[1],!a){e.next=30;break}c.audioTransceiver=p._peerConnection.addTransceiver(a.aTrack,a.audioTransceiverInit),c.videoTransceiver=p._peerConnection.addTransceiver(a.vTrack,a.videoTransceiverInit),(g=p._inactiveMlineIndex.shift())||(g=p._offerMlines.length),p._offerMlines[g]=_objectSpread2(_objectSpread2({},v),{},{mid:l.mid}),p._answerMlines[g]=l,(E=p._inactiveMlineIndex.shift())||(E=p._offerMlines.length),p._offerMlines[E]=_objectSpread2(_objectSpread2({},S),{},{mid:d.mid}),p._answerMlines[E]=d,p._msidIndexMap[c.streamId]=[g,E],encodedTransformSupported&&(c.initAudioEncodedTransform(),c.initVideoEncodedTransform()),i.push(c.streamId||""),o.push(u?c.userId:"local"),e.next=48;break;case 30:if(!u){e.next=48;break}if(T=p._msidIndexMap[c.streamId]||[],b=_slicedToArray(T,2),R=b[0],I=b[1],!R||!I){e.next=47;break}if((null===($=p._offerMlines[R])||void 0===$?void 0:$.mid)===l.mid){e.next=43;break}return p._offerMlines[R]=closeMline(p._offerMlines[R]),p._offerMlines[I]=closeMline(p._offerMlines[I]),p._answerMlines[R]=closeMline(p._answerMlines[R]),p._answerMlines[I]=closeMline(p._answerMlines[I]),e.next=40,p.setDescription();case 40:p._offerMlines[R]=_objectSpread2(_objectSpread2({},p._aRecvonlyOfferTpl),{},{mid:l.mid}),p._offerMlines[I]=_objectSpread2(_objectSpread2({},p._vRecvonlyOfferTpl),{},{mid:d.mid}),logger$b.print("enqueue","hack: %o",c.streamId);case 43:p._answerMlines[R]=l,p._answerMlines[I]=d,e.next=48;break;case 47:logger$b.print("dequeue","pushtrack before subscribe: %o",c.userId);case 48:u&&(c.sequenceId=null==s?void 0:s.sequenceId);case 49:case"end":return e.stop()}}),e)}))(),"t0",11);case 11:if("break"!==e.t0){e.next=14;break}return e.abrupt("break",17);case 14:a=!1,e.next=6;break;case 17:e.next=23;break;case 19:e.prev=19,e.t1=e.catch(4),s=!0,c=e.t1;case 23:if(e.prev=23,e.prev=24,!a||null==u.return){e.next=28;break}return e.next=28,u.return();case 28:if(e.prev=28,!s){e.next=31;break}throw c;case 31:return e.finish(28);case 32:return e.finish(23);case 33:case"end":return e.stop()}}),e,null,[[4,19,23,33],[24,,28,32]])}))(),"t0",12);case 12:e.next=19;break;case 14:d={},r.forEach((function(e){var t,r,n=e.audioMid,i=e.videoMid,o=e.stream;d[n]=n,d[i]=i,delete p._msidIndexMap[null===(t=e.stream)||void 0===t?void 0:t.streamId],o instanceof LocalStream?delete p._mlinesCache[null==o||null===(r=o.stream)||void 0===r?void 0:r.id]:delete p._mlinesCache[null==o?void 0:o.streamId]})),this._offerMlines=this._offerMlines.map((function(e,t){return d[e.mid]&&(e=closeMline(e),p._inactiveMlineIndex.push(t)),e})),this._inactiveMlineIndex.sort((function(e,t){return e-t})),this._answerMlines=this._answerMlines.map((function(e){return d[e.mid]&&(e=closeMline(e)),e}));case 19:return e.next=21,this.setDescription(i.length?{streamId:i.join(","),streamUserId:o.join(",")}:void 0);case 21:logger$b.print("dequeue","loop"),e.next=27;break;case 24:e.prev=24,e.t1=e.catch(6),logger$b.print("dequeue","unknown error: %o",e.t1);case 27:return e.prev=27,this.dequeue(),e.finish(27);case 30:case"end":return e.stop()}}),e,this,[[6,24,27,30]])}))),function(){return i.apply(this,arguments)})},{key:"setDescription",value:(n=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){var r,n;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return logger$b.print("setDescription","_offerMlines: %o, _answerMlines: %o",this._offerMlines,this._answerMlines),this._offerSession.media=this._offerMlines,this._answerSession.media=this._answerMlines,r=[],this._offerMlines.forEach((function(e){"inactive"!==e.direction&&r.push(e.mid)})),this._offerSession.groups&&this._answerSession.groups&&(this._offerSession.groups[0].mids=r.join(" "),this._answerSession.groups[0].mids=r.join(" ")),n=getServerNow(),t&&monitor.rtcBeginCreateOffer("local"===t.streamUserId?RtcbegincreateofferDirection.UP:RtcbegincreateofferDirection.DOWN,t.streamId,t.streamUserId),e.next=10,this._peerConnection.createOffer();case 10:return t&&monitor.rtcCreateOffer(0,"local"===t.streamUserId?RtccreateofferDirection.UP:RtccreateofferDirection.DOWN,t.streamId,t.streamUserId,getServerNow()-n),e.next=13,this.setLocalDescription(lib.write(this._offerSession),t);case 13:return e.next=15,this.setRemoteDescription(lib.write(this._answerSession),t);case 15:case"end":return e.stop()}}),e,this)}))),function(e){return n.apply(this,arguments)})},{key:"getDefaultSdp",value:(r=_asyncToGenerator(_regeneratorRuntime().mark((function e(){var t,r,n;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,createDefaultSdp(!0);case 2:if(t=e.sent){e.next=5;break}throw new SDKError(ErrorCode.NOT_SUPPORTED,"Get offer Error");case 5:return this.createAVMlineOfferTpl(t),r=lib.parse(t),n=[],r.media=r.media.filter((function(e){return"recvonly"===e.direction&&(n.push(e.mid+""),!0)})),r.groups=[{mids:n.join(" "),type:"BUNDLE"}],e.abrupt("return",{sdp:lib.write(r),semantics:"unified-plan",type:"offer"});case 11:case"end":return e.stop()}}),e,this)}))),function(){return r.apply(this,arguments)})},{key:"rollback",value:(t=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:delete this._mlinesCache[t];case 1:case"end":return e.stop()}}),e,this)}))),function(e){return t.apply(this,arguments)})},{key:"createAVMlineOfferTpl",value:function(e){var t=this;lib.parse(e).media.forEach((function(e){"audio"===e.type?"sendonly"===e.direction?t._aSendonlyOfferTpl=e:t._aRecvonlyOfferTpl=e:"video"===e.type&&("sendonly"===e.direction?t._vSendonlyOfferTpl=e:t._vRecvonlyOfferTpl=e)}))}}]),l}(),logger$a=new Logger("FirefoxHandler",3),FirefoxHandler=function(e){_inherits(l,BasicHandler);var t,r,n,i,o,a,s,c,u=_createSuper(l);function l(){var e;_classCallCheck(this,l);for(var t=arguments.length,r=new Array(t),n=0;n<t;n++)r[n]=arguments[n];return _defineProperty(_assertThisInitialized(e=u.call.apply(u,[this].concat(r))),"name","firefox"),e}return _createClass(l,[{key:"connect",value:(c=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){var r,n,i,o,a,s,c,u=this;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return logger$a.print("connect","invoke connect"),this._offerIce={iceUfrag:null===(r=t.iceParams)||void 0===r?void 0:r.clientIceUfrag,icePwd:null===(n=t.iceParams)||void 0===n?void 0:n.clientIcePwd,iceOptions:"renomination"},e.next=4,parseAnswerIceParams(t);case 4:return this._answerIce=e.sent,this._peerConnection.addTransceiver("audio",{direction:"recvonly"}),this._peerConnection.addTransceiver("video",{direction:"recvonly"}),e.next=9,this._peerConnection.createOffer();case 9:return i=e.sent,o=lib.parse(i.sdp),a=_slicedToArray(o.media,1),s=a[0],this._offerIce.fingerprint=o.fingerprint||s.fingerprint,o.media=o.media.map((function(e){return _objectSpread2(_objectSpread2({},e),u._offerIce)})),(c=_objectSpread2({},o)).fingerprint=this._answerIce.fingerprint,c.media=c.media.map((function(e){return delete(e=_objectSpread2(_objectSpread2({},e),u._answerIce)).bundleOnly,e.port=9,"application"===e.type?e.sctpmap={sctpmapNumber:5e3,app:"webrtc-datachannel",maxMessageSize:262144}:e.direction="sendonly",e})),e.next=19,this.setLocalDescription(lib.write(o));case 19:return e.next=21,this.setRemoteDescription(lib.write(c));case 21:return e.next=23,new Promise((function(e,t){u._dataChannel.onopen=function(){logger$a.print("connect","dataChannel open"),reportRtcInvokeStatus("es.dc.open",""),e("")},u._dataChannel.onerror=function(e){monitor.rtcSignalingMsgError(e.error.sdpLineNumber,e.error.errorDetail,RtcsignalingmsgerrorReason.INVALID_DATA),reportRtcInvokeStatus("es.dc.error",""),t(e)},u._dataChannel.onclose=function(e){reportRtcInvokeStatus("es.dc.close",""),t(e)},u._peerConnection.addEventListener("connectionstatechange",(function(e){"failed"!==u._peerConnection.iceConnectionState&&"closed"!==u._peerConnection.iceConnectionState&&"failed"!==u._peerConnection.connectionState||t(e)}))}));case 23:return logger$a.print("connect","dataChannel establish success"),e.abrupt("return",this._dataChannel);case 25:case"end":return e.stop()}}),e,this)}))),function(e){return c.apply(this,arguments)})},{key:"publish",value:(s=_asyncToGenerator(_regeneratorRuntime().mark((function e(t,r){var n,i,o,a,s,c,u,d,p,_,f,h,m,y=this;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return o=_get(_getPrototypeOf(l.prototype),"internalPublish",this).call(this,t,r),a=o.videoDescriptions,s=o.subVideoDescriptions,c=o.transceiverInit,t.audioTransceiver=this._peerConnection.addTransceiver(c.aTrack,c.audioTransceiverInit),t.videoTransceiver=this._peerConnection.addTransceiver(c.vTrack,c.videoTransceiverInit),u=getServerNow(),monitor.rtcBeginCreateOffer(RtcbegincreateofferDirection.UP,"",""),e.next=7,this._peerConnection.createOffer();case 7:return d=e.sent,monitor.rtcCreateOffer(0,RtccreateofferDirection.UP,"","",getServerNow()-u),(p=lib.parse(d.sdp)).media=null===(n=p.media)||void 0===n?void 0:n.map((function(e){return _objectSpread2(_objectSpread2({},e),y._offerIce)})),e.next=13,this.setLocalDescription(lib.write(p));case 13:return _=t.audioTransceiver.mid,f=t.videoTransceiver.mid,h=null,m=null,p.media=null===(i=p.media)||void 0===i?void 0:i.map((function(e){if("".concat(e.mid)===_){var t,r=null===(t=h=e)||void 0===t?void 0:t.rtp.find((function(e){return"opus"===e.codec}));if(r&&h.fmtp){var n=h.fmtp.find((function(e){return e.payload===r.payload}));n&&y._context&&(n.config+=y._context.audioProfileManager.getOpusConfigStr())}}else"".concat(e.mid)===f&&(m=e);return e})),this.addBitrateLimit(m,t.videoEncodeConfig[0].maxKbps),e.next=21,this.setLocalDescription(lib.write(p));case 21:return e.abrupt("return",{partialSdp:getLocalPartialSdp(p,h,m),audioMid:_,videoMid:f,type:"incroffer",semantics:"unified-plan",videoDescriptions:a,subVideoDescriptions:s,transceiverInit:c});case 22:case"end":return e.stop()}}),e,this)}))),function(e,t){return s.apply(this,arguments)})},{key:"subscribe",value:(a=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){var r,n,i,o,a,s,c,u,l,d,p,_,f,h,m=this;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(logger$a.print("subscribe()"),!t.audioMid||!t.videoMid){e.next=11;break}return a=lib.parse(null===(i=this._peerConnection.localDescription)||void 0===i?void 0:i.sdp),s=null,c=null,a.media.forEach((function(e){"".concat(e.mid)===t.audioMid?(s=e,t.autosubAudioMid&&(s.mid=t.autosubAudioMid)):"".concat(e.mid)===t.videoMid&&(c=e,t.autosubVideoMid&&(c.mid=t.autosubVideoMid))})),e.next=8,this._peerConnection.createOffer();case 8:return e.next=10,this.setLocalDescription(null===(o=this._peerConnection.localDescription)||void 0===o?void 0:o.sdp,{streamId:t.streamId||"",streamUserId:t.userId});case 10:return e.abrupt("return",{partialSdp:getLocalPartialSdp(a,s,c),audioMid:t.audioMid,videoMid:t.videoMid,autosubAudioMid:t.autosubAudioMid,autosubVideoMid:t.autosubVideoMid,type:"incroffer",semantics:"unified-plan"});case 11:return t.audioTransceiver=this._peerConnection.addTransceiver("audio",{direction:"recvonly"}),t.videoTransceiver=this._peerConnection.addTransceiver("video",{direction:"recvonly"}),u=getServerNow(),monitor.rtcBeginCreateOffer(RtcbegincreateofferDirection.UP,t.streamId,t.userId),e.next=17,this._peerConnection.createOffer();case 17:return l=e.sent,monitor.rtcCreateOffer(0,RtccreateofferDirection.UP,t.streamId,t.userId,getServerNow()-u),(d=lib.parse(l.sdp)).media=null===(r=d.media)||void 0===r?void 0:r.map((function(e){return _objectSpread2(_objectSpread2({},e),m._offerIce)})),e.next=23,this.setLocalDescription(lib.write(d),{streamId:t.streamId||"",streamUserId:t.userId});case 23:return p=t.audioTransceiver.mid,_=t.videoTransceiver.mid,f=null,h=null,null===(n=d.media)||void 0===n||n.forEach((function(e){"".concat(e.mid)===p?f=e:"".concat(e.mid)===_&&(h=e)})),e.abrupt("return",{partialSdp:getLocalPartialSdp(d,f,h),audioMid:p,videoMid:_,type:"incroffer",semantics:"unified-plan"});case 29:case"end":return e.stop()}}),e,this)}))),function(e){return a.apply(this,arguments)})},{key:"handleAck",value:(o=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){var r,n,i,o,a,s,c,u,l,d=this;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(i=t.signalingAck,o=t.stream,(a=t.action)!==SdpAction.unpublish&&a!==SdpAction.unsubscribe&&a!==SdpAction.removetrack){e.next=5;break}return e.next=4,this.close(o.streamId,o);case 4:return e.abrupt("return",o.streamId);case 5:return s={},(c=lib.parse(null===(r=this._peerConnection.remoteDescription)||void 0===r?void 0:r.sdp)).media.forEach((function(e){void 0!==e.mid&&(s[e.mid]=e)})),lib.parse(null==i?void 0:i.sdp).media.forEach((function(e){"audio"===(e=_objectSpread2(_objectSpread2({},e),d._answerIce)).type&&(o.audioMid?(e.mid=o.audioMid,s[o.audioMid]=e):s[e.mid]=e),"video"===e.type&&(o.videoMid?(e.mid=o.videoMid,s[o.videoMid]=e):s[e.mid]=e)})),u=lib.parse(null===(n=this._peerConnection.localDescription)||void 0===n?void 0:n.sdp),l=u.media.map((function(e){var t=s[e.mid];return"inactive"===e.direction?e:t})),c.groups=u.groups,c.media=l,this.setRemoteDescription(lib.write(c)),e.abrupt("return","");case 16:case"end":return e.stop()}}),e,this)}))),function(e){return o.apply(this,arguments)})},{key:"getDefaultSdp",value:(i=_asyncToGenerator(_regeneratorRuntime().mark((function e(){var t,r,n;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=lib.parse(null===(t=this._peerConnection.localDescription)||void 0===t?void 0:t.sdp),n=[],r.media=r.media.filter((function(e){return"recvonly"===e.direction&&(n.push(e.mid+""),!0)})),r.groups=[{mids:n.join(" "),type:"BUNDLE"}],e.abrupt("return",{sdp:lib.write(r),semantics:"unified-plan",type:"offer"});case 5:case"end":return e.stop()}}),e,this)}))),function(){return i.apply(this,arguments)})},{key:"rollback",value:(n=_asyncToGenerator(_regeneratorRuntime().mark((function e(t,r){return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.close(t,r));case 1:case"end":return e.stop()}}),e,this)}))),function(e,t){return n.apply(this,arguments)})},{key:"close",value:(r=_asyncToGenerator(_regeneratorRuntime().mark((function e(t,r){var n,i,o,a,s,c,u=this;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(logger$a.print("close()"),!r.audioTransceiver||!r.videoTransceiver){e.next=19;break}return r.audioTransceiver.stop(),r.videoTransceiver.stop(),i=[],e.next=7,this._peerConnection.createOffer();case 7:return o=e.sent,(a=lib.parse(null==o?void 0:o.sdp)).media=a.media.map((function(e){return"".concat(e.mid)!==r.audioMid&&"".concat(e.mid)!==r.videoMid||(e=closeMline(e)),"inactive"!==e.direction&&i.push(e.mid),_objectSpread2(_objectSpread2({},e),u._offerIce)})),s=lib.parse(null===(n=this._peerConnection.remoteDescription)||void 0===n?void 0:n.sdp),c={},s.media.forEach((function(e){c[e.mid]=e})),s.media=a.media.map((function(e){return"inactive"===e.direction?e:c[e.mid]})),a.groups&&s.groups&&(a.groups[0].mids=i.join(" "),s.groups[0].mids=i.join(" ")),e.next=17,this.setLocalDescription(lib.write(a));case 17:return e.next=19,this.setRemoteDescription(lib.write(s));case 19:case"end":return e.stop()}}),e,this)}))),function(e,t){return r.apply(this,arguments)})},{key:"setCurrentDescription",value:(t=_asyncToGenerator(_regeneratorRuntime().mark((function e(){return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._peerConnection.createOffer();case 2:if(!this._peerConnection.localDescription||!this._peerConnection.remoteDescription){e.next=7;break}return e.next=5,this._peerConnection.setLocalDescription(this._peerConnection.localDescription);case 5:return e.next=7,this._peerConnection.setRemoteDescription(this._peerConnection.remoteDescription);case 7:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})}]),l}(),createHandler=function(e,t){return isFirefox?new FirefoxHandler(e,t):new ChromeHandler(e,t)},logger$9=new Logger("Locker",2),lockId=1,PromiseLock=function(){function e(t){_classCallCheck(this,e),_defineProperty(this,"lockingPromise",Promise.resolve()),_defineProperty(this,"locks",0),_defineProperty(this,"name",""),_defineProperty(this,"lockId",void 0),this.lockId=lockId++,t&&(this.name=t),logger$9.print("[lock-".concat(this.name,"-").concat(this.lockId,"] is created."))}return _createClass(e,[{key:"isLocked",get:function(){return this.locks>0}},{key:"lock",value:function(){var e,t=this;this.locks+=1,logger$9.print("[lock-".concat(this.name,"-").concat(this.lockId,"] locked, current queue ").concat(this.locks,"."));var r=new Promise((function(r){e=function(){t.locks-=1,logger$9.print("[lock-".concat(t.name,"-").concat(t.lockId,"] unlocked, current queue ").concat(t.locks,".")),r()}})),n=this.lockingPromise.then((function(){return e}));return this.lockingPromise=this.lockingPromise.then((function(){return r})),n}}]),e}(),RoomProfileMap=(_defineProperty(_RoomProfileMap={},RoomProfileType.communication,[0]),_defineProperty(_RoomProfileMap,RoomProfileType.chat,[0]),_defineProperty(_RoomProfileMap,RoomProfileType.chatRoom,[1,"IES_chatroom"]),_defineProperty(_RoomProfileMap,RoomProfileType.coHost,[1,"IES_PK"]),_defineProperty(_RoomProfileMap,RoomProfileType.meeting,[16]),_defineProperty(_RoomProfileMap,RoomProfileType.classRoom,[0]),_RoomProfileMap),__defProp$2=Object.defineProperty,__getOwnPropDesc$2=Object.getOwnPropertyDescriptor,__decorateClass$2=function(e,t,r,n){for(var i,o=n>1?void 0:n?__getOwnPropDesc$2(t,r):t,a=e.length-1;a>=0;a--)(i=e[a])&&(o=(n?i(t,r,o):i(o))||o);return n&&o&&__defProp$2(t,r,o),o},logger$8=new Logger("MediaServerClient",2),WAIT_TRACK_TIMEOUT=6e4,MediaConnectionState=function(e){return e.DISCONNECTED="disconnected",e.DISCONNECTING="disconnecting",e.CONNECTED="connected",e.CONNECTING="connecting",e}(MediaConnectionState||{}),logRemoteStream=function(e,t){logger$8.print(e,"userId: %o, subAudio: %o, subVideo: %o, paused: %o, audioMid: %o, videoMid: %o, workaround_1_: %o, sequenceId: %o",t.userId,t.subAudio,t.subVideo,t.paused,t.audioMid,t.videoMid,t._workaround_1_,t.sequenceId)},MediaServerClient=function(e){_inherits(g,EnhancedEventEmitter);var t,r,n,i,o,a,s,c,u,l,d,p,_,f,h,m,y,v,S=_createSuper(g);function g(e){var t,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:monitor;return _classCallCheck(this,g),_defineProperty(_assertThisInitialized(t=S.call(this)),"_token",void 0),_defineProperty(_assertThisInitialized(t),"_appId",void 0),_defineProperty(_assertThisInitialized(t),"_roomId",void 0),_defineProperty(_assertThisInitialized(t),"_roomAttributes",void 0),_defineProperty(_assertThisInitialized(t),"_clientId",void 0),_defineProperty(_assertThisInitialized(t),"_businessId",void 0),_defineProperty(_assertThisInitialized(t),"_userInfo",void 0),_defineProperty(_assertThisInitialized(t),"_useCloudProxy",void 0),_defineProperty(_assertThisInitialized(t),"_authorization",void 0),_defineProperty(_assertThisInitialized(t),"_sessionId",void 0),_defineProperty(_assertThisInitialized(t),"_iceConfigRequestManager",void 0),_defineProperty(_assertThisInitialized(t),"_ontrackCallbackMap",new Map),_defineProperty(_assertThisInitialized(t),"_subResolves",{}),_defineProperty(_assertThisInitialized(t),"supportConcurrent",!1),_defineProperty(_assertThisInitialized(t),"_handler",void 0),_defineProperty(_assertThisInitialized(t),"_pubSubLock",void 0),_defineProperty(_assertThisInitialized(t),"_joinLeaveLock",void 0),_defineProperty(_assertThisInitialized(t),"_state",void 0),_defineProperty(_assertThisInitialized(t),"_dataChannelSignal",void 0),_defineProperty(_assertThisInitialized(t),"_pubConfig",{}),_defineProperty(_assertThisInitialized(t),"_subConfig",{}),_defineProperty(_assertThisInitialized(t),"monitor",void 0),_defineProperty(_assertThisInitialized(t),"_roomProfile",RoomProfileType.communication),_defineProperty(_assertThisInitialized(t),"_context",void 0),_defineProperty(_assertThisInitialized(t),"_subStreamQueue",{}),t.monitor=r,t._pubSubLock=new PromiseLock("pubSubLock"),t._joinLeaveLock=new PromiseLock("joinLeaveLock"),t._state="disconnected",t._roomAttributes={multiChatMode:!1,bigRoomMode:!1},t._context=e,t.on("SUB_END",(function(e){return t._handleSubStreamQueue(e)})),t}return _createClass(g,[{key:"_addHandlerEvents",value:function(){var e,t=this;null===(e=this._handler)||void 0===e||e.once("disconnect",(function(){logger$8.print("emit ABNORMAL_DISCONNECTION ice"),t.safeEmit(StateEvent.ABNORMAL_DISCONNECTION)}))}},{key:"_addSignalEventHandler",value:function(){var e,t=this;[SignalEvent.ON_ADD_STREAM,SignalEvent.ON_REMOVE_STREAM,SignalEvent.USER_CONNECTION,SignalEvent.USER_DISCONNECTION,SignalEvent.ON_UPDATE_STREAM_ATTRIBUTES,SignalEvent.ON_UPDATE_ROOM_ATTRIBUTES,SignalEvent.ON_PUSH_TRACK,SignalEvent.ON_REMOVE_TRACK,SignalEvent.NODE_CHANGE,SignalEvent.ON_CUSTOM_MESSAGE,SignalEvent.USER_MESSAGE_RECEIVED,SignalEvent.USER_BINARY_MESSAGE_RECEIVED,SignalEvent.POST_PROCESSING_MESSAGE,SignalEvent.ON_USER_TOKEN_WILL_EXPIRE,SignalEvent.STREAM_CONTROL_MESSAGE,SignalEvent.ON_SCENE_CONFIG,SignalEvent.ON_UPDATE_USER_ATTRIBUTES,MediaServerSignalEvent.RSCP].forEach((function(e){var r;null===(r=t._dataChannelSignal)||void 0===r||r.on(e,(function(r){t.safeEmit(e,r)}))})),null===(e=this._dataChannelSignal)||void 0===e||e.once("close",(function(){logger$8.print("emit ABNORMAL_DISCONNECTION datachannel"),t.safeEmit(StateEvent.ABNORMAL_DISCONNECTION)}))}},{key:"_removeSignalEventHandler",value:function(){var e,t;null===(e=this._dataChannelSignal)||void 0===e||e.removeAllListeners(),null===(t=this._handler)||void 0===t||t.removeAllListeners()}},{key:"connectionState",get:function(){return this._state},set:function(e){this._state!==e&&(this.safeEmit(StateEvent.ON_CONNECTION_STATE_CHANGE,{prev:this._state,next:e}),this._state=e)}},{key:"connect",value:(v=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){var r,n,i,o,a,s,c,u,l=this,d=arguments;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=d.length>1&&void 0!==d[1]?d[1]:"",n=d.length>2&&void 0!==d[2]?d[2]:"",i=d.length>3&&void 0!==d[3]?d[3]:{},this.connectionState="connecting",this._appId=t,this._handler&&(this._removeSignalEventHandler(),this._handler.destroy()),!i.node){e.next=11;break}o=[i.node],reportRtcInvokeStatus("es.join.nodeChange",i),e.next=20;break;case 11:return Promise.resolve().then((function(){return l.emit("onGetIceConfigHook")})),this._iceConfigRequestManager=new IceConfigRequestManager,e.next=15,null===(a=this._iceConfigRequestManager)||void 0===a?void 0:a.getAccessNode(t,r,n,sdkCache.getDeviceId(),null==i?void 0:i.reason,null==i?void 0:i.feedbackNode,this._useCloudProxy);case 15:if(o=e.sent){e.next=19;break}throw reportRtcInvokeStatus("es.join.getNodeFailed",""),new SDKError(ErrorCode.ICE_SERVER_WRONG,"get ICE config failed");case 19:reportRtcInvokeStatus("es.join.getNodeSuccess",o);case 20:return this._addHandlerEvents(),Promise.resolve().then((function(){return l.emit("onEstablishConnectionHook")})),e.prev=22,c=!1,u=o.map((function(e){var t=createHandler(l.monitor,l._context);return t.connect(e).then((function(r){c?t.destroy():(c=!0,s=r,l.safeEmit("prevIceNode",e),l._handler=t,l.supportConcurrent="chrome"===t.name,l._addHandlerEvents())})).catch((function(){t.destroy()}))})),e.next=27,promiseAny(u);case 27:logger$8.print("join","establish peerConnection success"),e.next=34;break;case 30:throw e.prev=30,e.t0=e.catch(22),this.connectionState="disconnected",new SDKError(ErrorCode.ESTABLISH_DATACHANNEL_FAILED,"establish dataChannel failed",e.t0);case 34:if(!s){e.next=40;break}this._dataChannelSignal=new DataChannelSignaling(s),this._addSignalEventHandler(),this._dataChannelSignal.sendPingSignaling(),e.next=42;break;case 40:throw this.connectionState="disconnected",new SDKError(ErrorCode.ESTABLISH_DATACHANNEL_FAILED,"establish dataChannel failed");case 42:case"end":return e.stop()}}),e,this,[[22,30]])}))),function(e){return v.apply(this,arguments)})},{key:"join",value:(y=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){var r,n,i,o,a,s,c,u,l,d,p,_,f,h,m,y,v=this,S=arguments;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=S.length>1&&void 0!==S[1]?S[1]:{},i=S.length>2&&void 0!==S[2]&&S[2],o=S.length>3?S[3]:void 0,logger$8.print("join()","info: %o, params: %o, reconnect: %o, controlMessage: %o",t,n,i,o),this._appId=t.appId,this._token=t.token,this._roomId=t.roomId,this._clientId=t.userInfo.userId,this._businessId=t.userInfo.businessId,this._userInfo=t.userInfo,this._useCloudProxy=t.useCloudProxy,this._roomProfile=t.roomProfile,this._sessionId=n.sessionId,e.next=15,this.connect(this._appId,this._roomId,this._clientId,n);case 15:return e.t0=Utils.token2auth(this._appId,this._roomId,this._clientId,this._token),e.t1=this._sessionId||"",e.t2=Date.now(),e.t3=o,e.t4={extra_info:this._userInfo.extraInfo,role:this._userInfo.role},e.next=22,null===(r=this._handler)||void 0===r?void 0:r.getDefaultSdp();case 22:return e.t5=e.sent,e.next=25,internalGetSupportedCodecs();case 25:return e.t6=e.sent,e.t7=window.navigator.userAgent,e.t8=Config.VERSION,e.t9=sdkCache.getDeviceId(),e.t10=this._appId,e.t11=this._roomId,e.t12=this._clientId,e.t13=this._businessId,e.t14=this._useCloudProxy,e.t15=RoomProfileMap[this._roomProfile]?RoomProfileMap[this._roomProfile][0]+"":"0",e.t16={supportedCodecs:e.t6,deviceType:"web",userAgent:e.t7,sdkVersion:e.t8,deviceId:e.t9,appId:e.t10,roomId:e.t11,userId:e.t12,businessId:e.t13,enable_cloud_proxy:e.t14,channelProfile:e.t15},e.t17={supportTokenExpireCallBack:!0,enableSceneConfigV2:!0,enableUnBundleMode:!0},a={Authorization:e.t0,sessionId:e.t1,timestamp:e.t2,controlMessage:e.t3,userAttributes:e.t4,sdpInfo:e.t5,params:e.t16,options:e.t17},Promise.resolve().then((function(){return v.emit("onSendingJoinMessageHook")})),e.prev=39,m=i?"reconnected":"joinRoom",e.next=43,this._dataChannelSignal.sendSignaling(m,a);case 43:return y=e.sent,logger$8.print("join","send join message success"),this._authorization=a.Authorization,this.connectionState="connected",RemoteStatsReport.audioStallConfig=null===(s=y.config)||void 0===s?void 0:s.engine_WEB,this._pubConfig.audioRed=!(null===(c=y.config)||void 0===c||null===(u=c.engine_WEB)||void 0===u||!u.pub_audio_red),this._subConfig.muteReplaceUnsub=!(null===(l=y.config)||void 0===l||!l.mute_replace_unsub),this._pubConfig.simulcastOnDemand=!(!1===(null===(d=y.config)||void 0===d||null===(p=d.engine_VPM)||void 0===p||null===(_=p.ondemand)||void 0===_?void 0:_.enable)),null===(f=this._context)||void 0===f||f.audioProfileManager.updateEngineBAC(null===(h=y.config)||void 0===h?void 0:h.engine_BAC),e.abrupt("return",y);case 55:if(e.prev=55,e.t18=e.catch(39),this.connectionState="disconnected",!((null===e.t18||void 0===e.t18?void 0:e.t18.code)>=700&&(null===e.t18||void 0===e.t18?void 0:e.t18.code)<800)){e.next=60;break}throw new SDKError(ErrorCode.INVALID_TOKEN,(null===e.t18||void 0===e.t18?void 0:e.t18.message)||"Invalid token");case 60:if(200===(null===e.t18||void 0===e.t18?void 0:e.t18.code)){e.next=62;break}throw new SDKError(ErrorCode.JOIN_ROOM_FAILED,(null===e.t18||void 0===e.t18?void 0:e.t18.message)||"Join room failed");case 62:case"end":return e.stop()}}),e,this,[[39,55]])}))),function(e){return y.apply(this,arguments)})},{key:"publish",value:(m=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){var r,n,i,o,a,s,c,u,l,d,p,_,f,h,m,y,v,S;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return logger$8.print("publish()","localStream: %o",t),r=t.videoTrack,n=t.audioTrack,i=getServerNow(),o="",a="",e.prev=6,e.next=9,null===(s=this._handler)||void 0===s?void 0:s.publish(t,this._pubConfig);case 9:if(m=e.sent){e.next=12;break}throw new SDKError(ErrorCode.ADD_TRANSCEIVER_FAILED,"add transceiver failed");case 12:return o=m.audioMid,a=m.videoMid,t.pubAttributes={localaudio:!!n,localvideo:!!r,videostream:t.pubVideo,audiostream:t.pubAudio,extvideo:!!(r instanceof CustomVideoLocalTrack),extaudio:!!(n instanceof CustomAudioLocalTrack)},y={attributes:_objectSpread2({videoDescriptions:m.videoDescriptions},t.pubAttributes),audio:!0,video:!0,screen:t.isScreen,audioMid:o,videoMid:a,sdpInfo:{msid:t.stream.id,type:m.type,sdp:m.partialSdp,semantics:m.semantics}},t.enableSimulcast&&this._pubConfig.simulcastOnDemand&&(y.attributes.subVideoDescriptions=m.subVideoDescriptions),e.next=19,null===(c=this._dataChannelSignal)||void 0===c?void 0:c.sendSignaling("publish",y);case 19:if(200===(null==(v=e.sent)?void 0:v.code)){e.next=22;break}throw new SDKError(ErrorCode.PUBLISH_FAILED,(null==v?void 0:v.message)||"publish failed");case 22:return monitor.rtcRecvAnswer(0,RtcrecvanswerAnswerType.INCRANSWER,(null==v||null===(u=v.relayMessage)||void 0===u?void 0:u.sequenceId)||0,null==v||null===(l=v.relayMessage)||void 0===l?void 0:l.sdp,RtcrecvanswerDirection.UP,"",""),e.next=25,null===(d=this._handler)||void 0===d?void 0:d.handleAck({action:SdpAction.publish,streamId:v.streamId,audioMid:o,videoMid:a,transceiverInit:m.transceiverInit,signalingAck:{audioMid:null==v||null===(p=v.relayMessage)||void 0===p?void 0:p.audioMid,videoMid:null==v||null===(_=v.relayMessage)||void 0===_?void 0:_.videoMid,sdp:null==v||null===(f=v.relayMessage)||void 0===f?void 0:f.sdp,sequenceId:null==v||null===(h=v.relayMessage)||void 0===h?void 0:h.sequenceId},stream:t});case 25:return t.streamId=v.streamId,t.videoMid=a,t.audioMid=o,t.subVideoDescriptions=m.subVideoDescriptions,this.monitor.rtcPublishStat(RtcpublishstatResult.SUCCESS,RtcpublishstatIsScreen.W_0,i,RtcpublishstatMessage.UNKNOWN),t.statsReport.setLocalStreamStatsEvtInterval(this,this._handler,this.monitor),e.abrupt("return");case 34:return e.prev=34,e.t0=e.catch(6),e.t0 instanceof Error&&this.monitor.rtcPublishStat(RtcpublishstatResult.FAIL,RtcpublishstatIsScreen.W_0,i,e.t0.message),e.next=39,null===(S=this._handler)||void 0===S?void 0:S.rollback(t.stream.id,t);case 39:throw e.t0;case 40:case"end":return e.stop()}}),e,this,[[6,34]])}))),function(e){return m.apply(this,arguments)})},{key:"updatePubTrack",value:(h=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){var r,n,i,o,a,s,c,u,l,d,p,_,f,h,m,y,v,S,g,E,T,b,R,I,$,A,C,O,P,k,w,N;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:for(logger$8.print("updatePubTrack()","localStream: %o",t),i=t.videoTrack,o=t.audioTrack,a=t.pubAudio,s=t.pubVideo,c=null==o?void 0:o.getTrack(),u=null==i?void 0:i.getTrack(),s&&u?null===(l=t.videoTransceiver)||void 0===l||l.sender.replaceTrack(u):null===(d=t.videoTransceiver)||void 0===d||d.sender.replaceTrack(null),null===(r=this._handler)||void 0===r||r.updateScaleResolutionDownBy(t),a&&c?(_=o.mixType,f=o.mixedAudioTrack,h=o.gainAudioTrack,f&&_!==AudioMixingType.PLAYOUT&&!0===c.enabled?c=f:h&&"safari"!==getBrowser()&&(c=h),null===(p=t.audioTransceiver)||void 0===p||p.sender.replaceTrack(c)):null===(m=t.audioTransceiver)||void 0===m||m.sender.replaceTrack(null),y={localaudio:!!o,localvideo:!!i,videostream:s,audiostream:a,extvideo:!!(i instanceof CustomVideoLocalTrack),extaudio:!!(o instanceof CustomAudioLocalTrack)},v={},S=0,g=Object.entries(y);S<g.length;S++)E=_slicedToArray(g[S],2),T=E[0],(b=E[1])!==Reflect.get(t.pubAttributes,T)&&Reflect.set(v,T,b);if(Object.keys(v).length){e.next=12;break}return e.abrupt("return");case 12:return t.observer&&(R=t.observer,I=v.audiostream,$=v.videostream,A=v.localaudio,C=v.localvideo,O=v.extaudio,P=v.extvideo,void 0!==C?void 0!==P?R.setPushVideo(P):R.setEnableVideo(C):void 0!==$&&R.setUnmuteVideo($),void 0!==A?void 0!==O?R.setPushAudio(O):R.setEnableAudio(A):void 0!==I&&R.setUnmuteAudio(I)),t.pubAttributes=y,k={roomId:this._roomId,streamId:t.streamId,attributes:v},e.next=17,null===(n=this._dataChannelSignal)||void 0===n?void 0:n.sendSignaling("updateStreamAttributes",k);case 17:if(200===(null==(w=e.sent)?void 0:w.code)){e.next=20;break}throw new SDKError(ErrorCode.UPDATE_TRACK_FAILED,(null==w?void 0:w.message)||"update track failed");case 20:if(!isFirefox){e.next=23;break}return e.next=23,null===(N=this._handler)||void 0===N?void 0:N.setCurrentDescription();case 23:case"end":return e.stop()}}),e,this)}))),function(e){return h.apply(this,arguments)})},{key:"updateToken",value:(f=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){var r,n,i,o,a;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(logger$8.print("updateToken()","newToken: %o",t),this._token=t,this._appId&&null!==(r=this._userInfo)&&void 0!==r&&r.userId&&this._roomId){e.next=4;break}return e.abrupt("return");case 4:return i={roomId:this._roomId,userId:null===(n=this._userInfo)||void 0===n?void 0:n.userId,appId:this._appId,token:"Bearer ".concat(t)},e.prev=5,e.next=8,null===(o=this._dataChannelSignal)||void 0===o?void 0:o.sendSignaling("updateToken",i);case 8:if(200===(null==(a=e.sent)?void 0:a.code)){e.next=11;break}throw new SDKError(ErrorCode.UPDATE_TOKEN_WITH_INVALID_TOKEN,"invoke updateToken with an invalid token");case 11:e.next=16;break;case 13:throw e.prev=13,e.t0=e.catch(5),new SDKError(ErrorCode.UPDATE_TOKEN_WITH_INVALID_TOKEN,"invoke updateToken with an invalid token");case 16:case"end":return e.stop()}}),e,this,[[5,13]])}))),function(e){return f.apply(this,arguments)})},{key:"unpublish",value:(_=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){var r,n,i;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return logger$8.print("unpublish()","localStream: %o",t),i={roomId:this._roomId,initStreamId:t.initStreamId,streamId:t.streamId},null===(r=this._dataChannelSignal)||void 0===r||r.sendSignaling("unpublish",i),e.next=5,null===(n=this._handler)||void 0===n?void 0:n.handleAck({action:SdpAction.unpublish,audioMid:t.audioMid,videoMid:t.videoMid,stream:t,streamId:t.streamId});case 5:t.statsReport.unpublish();case 6:case"end":return e.stop()}}),e,this)}))),function(e){return _.apply(this,arguments)})},{key:"subscribe",value:(p=_asyncToGenerator(_regeneratorRuntime().mark((function e(t,r,n){var i=this;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",new Promise(function(){var e=_asyncToGenerator(_regeneratorRuntime().mark((function e(o,a){var s,c,u,l,d,p,_,f,h,m,y,v,S,g,E,T,b,R,I,$,A,C,O,P,k,w,N,D,M,x,L,U,F,B,V,j,G,H;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t.streamState!==StreamState.SUB_ED){e.next=2;break}return e.abrupt("return",i._updateSubTrack(t,r,SubState.SUB,n).then(o,a));case 2:if(t.streamState!==StreamState.SUB_ING){e.next=7;break}return i._subStreamQueue[t.streamId]||(i._subStreamQueue[t.streamId]=[]),logger$8.print("_subStreamQueue","streamId: %o, enqueue",t.streamId),i._subStreamQueue[t.streamId].push({fn:i.subscribe,args:[t,r,n],resolve:o,reject:a}),e.abrupt("return");case 7:if(logger$8.print("subscribe()","mediaType: %o",r),logRemoteStream("subscribe()",t),t.streamState=StreamState.SUB_ING,s=!1,c=!1,audioInMediaType(r)&&(c=!0),videoInMediaType(r)&&(s=!0),s||!i._multiChatMode()){e.next=17;break}return t.streamState=StreamState.INIT,i.emit("SUB_END",t.streamId),e.abrupt("return",o(null));case 17:if(u=getServerNow(),l=t.audioMid,d=t.videoMid,_=t.paused,f=t.subVideo,e.prev=22,!l||!d){e.next=29;break}return e.next=26,null===(k=i._handler)||void 0===k?void 0:k.subscribe(t,{audioMid:l,videoMid:d});case 26:p=e.sent,e.next=36;break;case 29:return e.next=31,null===(w=i._handler)||void 0===w?void 0:w.subscribe(t);case 31:if(p=e.sent){e.next=34;break}throw new SDKError(ErrorCode.ADD_TRANSCEIVER_FAILED,"add transceiver failed");case 34:l=p.audioMid,d=p.videoMid;case 36:return t.paused=!s,t.subVideo=s,N={spatialLayer:(null==n?void 0:n.spatialLayer)||0,temporalLayer:0,spatialSubLayer:(null==n?void 0:n.spatialSubLayer)||-1},D={audio:!i._multiChatMode(),video:!0,data:!0,screen:t.isScreen,browser:"chrome-stable",videoMid:(null===(h=p)||void 0===h?void 0:h.autosubVideoMid)||d,audioMid:(null===(m=p)||void 0===m?void 0:m.autosubAudioMid)||l,sdpInfo:{sdp:null===(y=p)||void 0===y?void 0:y.partialSdp,semantics:null===(v=p)||void 0===v?void 0:v.semantics,type:null===(S=p)||void 0===S?void 0:S.type},streamUserId:t.userId,streamId:t.streamId,config:{enableMediaType:{audio:!!i._multiChatMode()||c,video:s},qualityLayer:N}},e.next=42,null===(g=i._dataChannelSignal)||void 0===g?void 0:g.sendSignaling("subscribe",D);case 42:if(200===(null==(M=e.sent)?void 0:M.code)){e.next=45;break}throw new SDKError(ErrorCode.SUBSCRIBE_FAILED,(null==M?void 0:M.message)||"subscribe failed");case 45:return x=[],L=!i._multiChatMode(),U=!t.videoTrack,i._subResolves[t.streamId]||(i._subResolves[t.streamId]=[]),U&&x.push(new Promise((function(e,r){i._subResolves[t.streamId].push(e);var n=setTimeout((function(){return r(new SDKError(ErrorCode.TIME_OUT,"wait video timeout for userId: ".concat(t.userId)))}),WAIT_TRACK_TIMEOUT);t.on("ontrack",(function r(i){"video"===i.mediaType&&(logger$8.print("remoteStream ".concat(t.userId," received video track")),t.off("ontrack",r),clearTimeout(n),e(0))}))}))),L&&x.push(new Promise((function(e,r){i._subResolves[t.streamId].push(e);var n=setTimeout((function(){return r(new SDKError(ErrorCode.TIME_OUT,"wait audio timeout for userId: ".concat(t.userId)))}),WAIT_TRACK_TIMEOUT);t.on("ontrack",(function r(i){"audio"===i.mediaType&&(logger$8.print("remoteStream ".concat(t.userId," received audio track")),t.off("ontrack",r),clearTimeout(n),e(0))}))}))),F=function(e){t.ontrack(e)},null===(E=i._handler)||void 0===E||E.on("ontrack",F),i._ontrackCallbackMap.set(t,F),B=null==M?void 0:M.relayMessage,V=B.audioMid,j=B.videoMid,_defineProperty(T={},l,V),_defineProperty(T,d,j),G=T,logger$8.print("sub midmap",t.userId,G),isFirefox?(t.videoMid=d,t.audioMid=l):(t.videoMid=j,t.audioMid=V),t._workaround_1_=!1,t.subMediaType=r,t.streamState=StreamState.SUB_ED,t.subLayer=N,monitor.rtcRecvAnswer(0,RtcrecvanswerAnswerType.INCRANSWER,(null==M||null===(b=M.relayMessage)||void 0===b?void 0:b.sequenceId)||0,null==M||null===(R=M.relayMessage)||void 0===R?void 0:R.sdp,RtcrecvanswerDirection.DOWN,t.streamId,t.userId),e.next=65,null===(I=i._handler)||void 0===I?void 0:I.handleAck({action:SdpAction.subscribe,streamId:t.streamId,audioMid:l,videoMid:d,transceiverInit:null===($=p)||void 0===$?void 0:$.transceiverInit,signalingAck:{audioMid:null==M||null===(A=M.relayMessage)||void 0===A?void 0:A.audioMid,videoMid:null==M||null===(C=M.relayMessage)||void 0===C?void 0:C.videoMid,sdp:null==M||null===(O=M.relayMessage)||void 0===O?void 0:O.sdp,sequenceId:null==M||null===(P=M.relayMessage)||void 0===P?void 0:P.sequenceId},stream:t});case 65:return e.next=67,Promise.all(x);case 67:i._multiChatMode()||(t.subAudio=c),i.monitor.rtcSubscribeStat(RtcsubscribestatResult.SUCCESS,u,RtcsubscribestatMessage.UNKNOWN,t.userId),t.statsReport.setRemoteStreamStatsEvtInterval(i,i._handler,i.monitor),o(null),i.emit("SUB_END",t.streamId),e.next=84;break;case 74:return e.prev=74,e.t0=e.catch(22),e.t0 instanceof Error&&i.monitor.rtcSubscribeStat(RtcsubscribestatResult.FAIL,u,e.t0.message,t.userId),t.paused=_,t.subVideo=f,t.streamState=StreamState.INIT,e.next=82,null===(H=i._handler)||void 0===H?void 0:H.rollback(t.streamId,t);case 82:a(e.t0),i.emit("SUB_END",t.streamId);case 84:case"end":return e.stop()}}),e,null,[[22,74]])})));return function(t,r){return e.apply(this,arguments)}}()));case 1:case"end":return e.stop()}}),e)}))),function(e,t,r){return p.apply(this,arguments)})},{key:"_handleSubStreamQueue",value:function(e){var t,r=this;if(null!==(t=this._subStreamQueue[e])&&void 0!==t&&t.length){logger$8.print("_subStreamQueue","streamId: %o, exec",e);var n=this._subStreamQueue[e].shift(),i=n.fn,o=n.args,a=n.resolve,s=n.reject;i.apply(this,o).then(a,s).finally((function(){return r._handleSubStreamQueue(e)}))}else logger$8.print("_subStreamQueue","streamId: %o, END",e)}},{key:"controlMessage",value:(d=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){var r,n;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return logger$8.print("controlMessage()","params: %o",t),n=t,"transcode"===t.type&&(n.roomId=this._roomId),e.next=5,null===(r=this._dataChannelSignal)||void 0===r?void 0:r.sendSignaling("controlMessage",n);case 5:case"end":return e.stop()}}),e,this)}))),function(e){return d.apply(this,arguments)})},{key:"updateUserAttributes",value:(l=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){var r;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return logger$8.print("updateUserAttributes()","attributes: %o",t),e.next=3,null===(r=this._dataChannelSignal)||void 0===r?void 0:r.sendSignaling("updateUserAttributes",{roomId:this._roomId,sessionId:this._sessionId,attributes:t});case 3:case"end":return e.stop()}}),e,this)}))),function(e){return l.apply(this,arguments)})},{key:"updateSubTrack",value:(u=_asyncToGenerator(_regeneratorRuntime().mark((function e(t,r,n,i){return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this._updateSubTrack(t,r,n,i||t.subLayer));case 1:case"end":return e.stop()}}),e,this)}))),function(e,t,r,n){return u.apply(this,arguments)})},{key:"_updateSubTrack",value:(c=_asyncToGenerator(_regeneratorRuntime().mark((function e(t,r,n,i){var o,a,s,c,u,l,d,p,_;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return logger$8.print("updateSubTrack()","mediaType: %o, subLayer: %o",r,i),logRemoteStream("updateSubTrack()",t),s=0,s=n===SubState.SUB?t.subMediaType|r:t.subMediaType-(t.subMediaType&r),logger$8.print("updateSubTrack","prev: %o, direction: %o, mediaType: %o, newMediaType: %o",t.subMediaType,n,r,s),t.subMediaType===s&&logger$8.print("updateSubTrack","mediaType no change"),c=!1,u=!1,audioInMediaType(s)&&(u=!0),videoInMediaType(s)&&(c=!0),l=i||t.subLayer,d={roomId:this._roomId,streamList:[t.streamId],config:{enableMediaType:{video:c,audio:!!this._multiChatMode()||u},qualityLayer:l}},e.next=13,null===(o=this._dataChannelSignal)||void 0===o?void 0:o.sendSignaling("updateSubscribe",d);case 13:if(200===(null==(p=e.sent)?void 0:p.code)){e.next=16;break}throw new SDKError(ErrorCode.UPDATE_TRACK_FAILED,(null==p?void 0:p.message)||"update track failed");case 16:return t.paused=!c,this._multiChatMode()||(null===(_=t.observer)||void 0===_||_.setUnmuteAudio(u),t.subAudio=u),null===(a=t.observer)||void 0===a||a.setUnmuteVideo(c),t.subVideo=c,t.subMediaType=s,t.subLayer=l,e.abrupt("return",t);case 23:case"end":return e.stop()}}),e,this)}))),function(e,t,r,n){return c.apply(this,arguments)})},{key:"subscribe4pushTrack",value:(s=_asyncToGenerator(_regeneratorRuntime().mark((function e(t,r){var n,i,o,a,s,c,u,l,d,p,_,f,h,m,y,v,S,g=this;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(logger$8.print("subscribe4pushTrack()","streamInfo: %o",r),logRemoteStream("subscribe4pushTrack()",t),c=null==r?void 0:r.message,u=c.audioMid,l=c.videoMid,d=c.sequenceId,t.subAudio=!0,!(d<t.sequenceId)){e.next=7;break}return logger$8.print("subscribe4pushTrack","sequenceId return",d,t.sequenceId),e.abrupt("return");case 7:if(p=t.audioMid,_=t.videoMid,null===(n=t.observer)||void 0===n||n.setPushTrack(!0),!p||!_){e.next=16;break}return e.next=13,null===(h=this._handler)||void 0===h?void 0:h.subscribe(t,{audioMid:p,videoMid:_});case 13:f=e.sent,e.next=23;break;case 16:return e.next=18,null===(m=this._handler)||void 0===m?void 0:m.subscribe(t);case 18:if(f=e.sent){e.next=21;break}throw new SDKError(ErrorCode.ADD_TRANSCEIVER_FAILED,"add transceiver failed");case 21:p=f.audioMid,_=f.videoMid;case 23:return _defineProperty(i={},p,u),_defineProperty(i,_,l),y=i,logger$8.print("onpushtrack midmap",t.userId,y),isFirefox?(t.audioMid=p,t.videoMid=_):(t.audioMid=u,t.videoMid=l),t.autosubAudioMid=u,t.autosubVideoMid=l,t.sequenceId=d,this._subResolves[t.streamId]||(this._subResolves[t.streamId]=[]),v=[],t.audioTrack||v.push(new Promise((function(e,r){g._subResolves[t.streamId].push(e);var n=setTimeout((function(){return r(new SDKError(ErrorCode.TIME_OUT,"wait audio timeout for userId: ".concat(t.userId)))}),WAIT_TRACK_TIMEOUT);t.on("ontrack",(function r(i){"audio"===i.mediaType&&(logger$8.print("remoteStream ".concat(t.userId," received audio track")),t.off("ontrack",r),clearTimeout(n),e(0))}))}))),S=function(e){t.ontrack(e)},null===(o=this._handler)||void 0===o||o.on("ontrack",S),this._ontrackCallbackMap.set(t,S),e.next=37,null===(a=this._handler)||void 0===a?void 0:a.handleAck({action:SdpAction.pushtrack,streamId:t.streamId,audioMid:p,videoMid:_,stream:t,transceiverInit:null===(s=f)||void 0===s?void 0:s.transceiverInit,signalingAck:null==r?void 0:r.message});case 37:return e.next=39,Promise.all(v);case 39:t.statsReport.setRemoteStreamStatsEvtInterval(this,this._handler,this.monitor);case 40:case"end":return e.stop()}}),e,this)}))),function(e,t){return s.apply(this,arguments)})},{key:"unsubscribe4removeTrack",value:(a=_asyncToGenerator(_regeneratorRuntime().mark((function e(t,r){var n,i;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(logRemoteStream("unsubscribe4removeTrack()",t),logger$8.print("unsubscribe4removeTrack()","sequenceId: ",r.sequenceId),!(r.sequenceId<t.sequenceId)){e.next=5;break}return logger$8.print("unsubscribe4removeTrack()","sequenceId return"),e.abrupt("return");case 5:if(t.subAudio=!1,!t.subVideo&&!t.paused){e.next=10;break}return t.sequenceId=r.sequenceId,logger$8.print("unsubscribe4removeTrack()","foo %o",t.userId),e.abrupt("return");case 10:return null===(n=t.observer)||void 0===n||n.setPushTrack(!1),e.next=13,null===(i=this._handler)||void 0===i?void 0:i.handleAck({action:SdpAction.removetrack,streamId:t.streamId,audioMid:t.audioMid,videoMid:t.videoMid,stream:t});case 13:this._subResolves[t.streamId]&&this._subResolves[t.streamId].forEach((function(e){return e(0)})),logger$8.print("clean unsubscribe4removeTrack"),t.clean(),t.resetHasSubscribed(),t.statsReport.unsubscribe();case 18:case"end":return e.stop()}}),e,this)}))),function(e,t){return a.apply(this,arguments)})},{key:"unsubscribe",value:(o=_asyncToGenerator(_regeneratorRuntime().mark((function e(t,r){var n,i,o,a,s,c,u,l,d=arguments;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(o=d.length>2&&void 0!==d[2]&&d[2],logRemoteStream("unsubscribe()",t),a=t.subMediaType-(t.subMediaType&r),o||!this._subConfig.muteReplaceUnsub&&a===ExtendMediaType.NONE){e.next=5;break}return e.abrupt("return",this._updateSubTrack(t,r,SubState.UNSUB));case 5:if(s={roomId:this._roomId,streamId:t.streamId,userId:t.userId},null===(n=this._dataChannelSignal)||void 0===n||n.sendSignaling("unsubscribe",s).catch((function(){})),t.streamState=StreamState.INIT,this._subStreamQueue[t.streamId]&&(this._subStreamQueue[t.streamId].forEach((function(e){return(0,e.resolve)(null)})),delete this._subStreamQueue[t.streamId]),t.subVideo=!1,t.paused=!1,t._workaround_1_||(t.subAudio=!1),null===(i=t.observer)||void 0===i||i.setSubscribeVideo(!1),t.subAudio){e.next=23;break}return null===(c=t.observer)||void 0===c||c.setSubscribeAudio(!1),e.next=17,null===(u=this._handler)||void 0===u?void 0:u.handleAck({action:SdpAction.unsubscribe,streamId:t.streamId,audioMid:t.audioMid,videoMid:t.videoMid,stream:t});case 17:l=e.sent,this._subResolves[l]&&this._subResolves[l].forEach((function(e){return e(0)})),logger$8.print("unsubscribe","clean unsub ".concat(t.userId)),t.clean(),this.removeOnTrackListener(t),t.statsReport.unsubscribe();case 23:case"end":return e.stop()}}),e,this)}))),function(e,t){return o.apply(this,arguments)})},{key:"removeOnTrackListener",value:function(e){var t,r=this._ontrackCallbackMap.get(e);r&&(null===(t=this._handler)||void 0===t||t.off("ontrack",r),this._ontrackCallbackMap.delete(e))}},{key:"handleRemoveStream",value:(i=_asyncToGenerator(_regeneratorRuntime().mark((function e(t,r){return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(logRemoteStream("handleRemoveStream()",t),t.subVideo=!1,r.message&&r.message!==RemoveStreamMessage.videoMuted?t._workaround_1_=!1:t._workaround_1_=!0,t.hasSubscribed){e.next=5;break}return e.abrupt("return");case 5:this.unsubscribe(t,MediaType.AUDIO_AND_VIDEO,!0);case 6:case"end":return e.stop()}}),e,this)}))),function(e,t){return i.apply(this,arguments)})},{key:"leave",value:(n=_asyncToGenerator(_regeneratorRuntime().mark((function e(){var t,r,n;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(logger$8.print("leave()"),"connected"!==this.connectionState){e.next=22;break}return this.connectionState="disconnecting",t={Authorization:this._authorization,roomId:this._roomId,sessionId:this._sessionId},e.next=6,this._joinLeaveLock.lock();case 6:return r=e.sent,e.prev=7,e.next=10,null===(n=this._dataChannelSignal)||void 0===n?void 0:n.sendSignaling("leaveRoom",t);case 10:this.connectionState="disconnected",e.next=17;break;case 13:throw e.prev=13,e.t0=e.catch(7),this.connectionState="connected",e.t0;case 17:return e.prev=17,r(),e.finish(17);case 20:e.next=23;break;case 22:return e.abrupt("return",Promise.reject(new SDKError(ErrorCode.NOT_CONNECTED_YET,"server not connected")));case 23:case"end":return e.stop()}}),e,this,[[7,13,17,20]])}))),function(){return n.apply(this,arguments)})},{key:"subscribePublicStream",value:(r=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){var r,n,i,o,a,s,c,u,l,d,p,_,f,h,m,y,v,S=this;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,null===(r=this._handler)||void 0===r?void 0:r.subscribe(t);case 2:if(a=e.sent){e.next=5;break}throw new SDKError(ErrorCode.ADD_TRANSCEIVER_FAILED,"add transceiver failed");case 5:return s=getServerNow(),c=a.audioMid,u=a.videoMid,l={appId:this._appId,streamId:t.streamId,audio:!0,video:!0,data:!0,audioMid:c,videoMid:u,sdpInfo:{sdp:null==a?void 0:a.partialSdp,semantics:null==a?void 0:a.semantics,type:null==a?void 0:a.type},config:{enableMediaType:{audio:!0,video:!0},qualityLayer:{spatialLayer:0,temporalLayer:0}}},e.next=11,null===(n=this._dataChannelSignal)||void 0===n?void 0:n.sendSignaling("startPullStream",l);case 11:return d=e.sent,p=[],this._subResolves[t.streamId]=[],p.push(new Promise((function(e,r){S._subResolves[t.streamId].push(e);var n=setTimeout((function(){return r(new SDKError(ErrorCode.TIME_OUT,"wait video timeout for streamId: ".concat(t.streamId)))}),WAIT_TRACK_TIMEOUT);t.on("ontrack",(function r(i){"video"===i.mediaType&&(logger$8.print("remoteStream ".concat(t.userId," received video track")),t.off("ontrack",r),clearTimeout(n),e(0))}))}))),p.push(new Promise((function(e,r){S._subResolves[t.streamId].push(e);var n=setTimeout((function(){return r(new SDKError(ErrorCode.TIME_OUT,"wait audio timeout for streamId: ".concat(t.streamId)))}),WAIT_TRACK_TIMEOUT);t.on("ontrack",(function r(i){"audio"===i.mediaType&&(logger$8.print("remoteStream ".concat(t.userId," received audio track")),t.off("ontrack",r),clearTimeout(n),e(0))}))}))),_=function(e){t.ontrack(e)},null===(i=this._handler)||void 0===i||i.on("ontrack",_),this._ontrackCallbackMap.set(t,_),f=null==d?void 0:d.relayMessage,h=f.audioMid,m=f.videoMid,y=f.sequenceId,v=f.sdp,t.videoMid=m,t.audioMid=h,t.sequenceId=y,t._workaround_1_=!1,t.paused=!1,t.streamState=StreamState.SUB_ED,t.subAudio=!0,t.subVideo=!0,e.next=30,null===(o=this._handler)||void 0===o?void 0:o.handleAck({action:SdpAction.subscribe,streamId:t.streamId,audioMid:c,videoMid:u,transceiverInit:null==a?void 0:a.transceiverInit,signalingAck:{audioMid:h,videoMid:m,sdp:v,sequenceId:y},stream:t});case 30:return e.next=32,Promise.all(p);case 32:this.monitor.rtcSubscribeStat(RtcsubscribestatResult.SUCCESS,s,RtcsubscribestatMessage.UNKNOWN,t.userId),t.statsReport.setRemoteStreamStatsEvtInterval(this,this._handler,this.monitor);case 34:case"end":return e.stop()}}),e,this)}))),function(e){return r.apply(this,arguments)})},{key:"unsubscribePublicStream",value:(t=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){var r,n,i;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return logRemoteStream("unsubscribePublicStream()",t),n={appId:this._appId,streamId:t.streamId},e.prev=2,e.next=5,null===(i=this._dataChannelSignal)||void 0===i?void 0:i.sendSignaling("stopPullStream",n);case 5:e.next=9;break;case 7:e.prev=7,e.t0=e.catch(2);case 9:return t.streamState=StreamState.INIT,t.subVideo=!1,t.subAudio=!1,e.next=14,null===(r=this._handler)||void 0===r?void 0:r.handleAck({action:SdpAction.unsubscribe,streamId:t.streamId,audioMid:t.audioMid,videoMid:t.videoMid,stream:t});case 14:t.clean(),this.removeOnTrackListener(t),t.statsReport.unsubscribe();case 17:case"end":return e.stop()}}),e,this,[[2,7]])}))),function(e){return t.apply(this,arguments)})},{key:"destroy",value:function(){var e,t,r;logger$8.print("destroy()"),this._token=void 0,this._appId=void 0,this._roomId=void 0,this._clientId=void 0,this._authorization=void 0,this._sessionId=void 0,this._context=void 0,null===(e=this._handler)||void 0===e||e.destroy(),null===(t=this._dataChannelSignal)||void 0===t||t.destroy(),null===(r=this._iceConfigRequestManager)||void 0===r||r.abort(),this._handler=void 0,this._dataChannelSignal=void 0,this._iceConfigRequestManager=void 0,this._removeSignalEventHandler(),this.connectionState="disconnected",this.emit("INTERRUPT")}},{key:"sendUserMessage",value:function(e,t){var r;return null===(r=this._dataChannelSignal)||void 0===r?void 0:r.sendP2PMessage({to:e,from:this._userInfo.userId,room:this._roomId,app:this._appId,msg:t})}},{key:"sendRoomMessage",value:function(e){var t;return null===(t=this._dataChannelSignal)||void 0===t?void 0:t.sendSignaling("customMessage",e)}},{key:"_multiChatMode",value:function(){var e;return null===(e=this._roomAttributes)||void 0===e?void 0:e.multiChatMode}},{key:"handler",get:function(){return this._handler}},{key:"roomAttributes",get:function(){return this._roomAttributes},set:function(e){this._roomAttributes=e}}]),g}();function checkConnection(e,t,r){var n=r.value;return r.value=_asyncToGenerator(_regeneratorRuntime().mark((function e(){var r,i,o,a=arguments;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._handler||"connected"!==this._state){e.next=6;break}for(r=a.length,i=new Array(r),o=0;o<r;o++)i[o]=a[o];return e.next=4,n.apply(this,i);case 4:e.next=7;break;case 6:throw new SDKError(ErrorCode.NOT_CONNECTED_YET,"error in ".concat(t,": try again after joined"));case 7:case"end":return e.stop()}}),e,this)}))),r}function pubSubLock(e,t,r){var n=r.value;return r.value=_asyncToGenerator(_regeneratorRuntime().mark((function e(){var t,r,i,o,a=arguments;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._pubSubLock.lock();case 2:for(t=e.sent,this.supportConcurrent&&t(),e.prev=4,r=a.length,i=new Array(r),o=0;o<r;o++)i[o]=a[o];return e.next=8,n.apply(this,i);case 8:return e.abrupt("return",e.sent);case 9:return e.prev=9,this.supportConcurrent||t(),e.finish(9);case 12:case"end":return e.stop()}}),e,this,[[4,,9,12]])}))),r}function interrupt(e,t,r){var n=r.value;return r.value=_asyncToGenerator(_regeneratorRuntime().mark((function e(){var t,r,i,o,a=this,s=arguments;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:for(t=s.length,r=new Array(t),i=0;i<t;i++)r[i]=s[i];return o=!1,e.abrupt("return",new Promise(function(){var e=_asyncToGenerator(_regeneratorRuntime().mark((function e(t,i){var s;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return a.on("INTERRUPT",(function(){o=!0,i(new SDKError(ErrorCode.OPERATION_CANCEL,"operation not finish when leave"))})),e.prev=1,e.next=4,n.apply(a,r);case 4:s=e.sent,t(s),e.next=11;break;case 8:e.prev=8,e.t0=e.catch(1),o||i(e.t0);case 11:case"end":return e.stop()}}),e,null,[[1,8]])})));return function(t,r){return e.apply(this,arguments)}}()));case 3:case"end":return e.stop()}}),e)}))),r}__decorateClass$2([interrupt],MediaServerClient.prototype,"join",1),__decorateClass$2([pubSubLock,checkConnection],MediaServerClient.prototype,"publish",1),__decorateClass$2([pubSubLock,checkConnection],MediaServerClient.prototype,"updatePubTrack",1),__decorateClass$2([pubSubLock,checkConnection],MediaServerClient.prototype,"unpublish",1),__decorateClass$2([pubSubLock,checkConnection],MediaServerClient.prototype,"subscribe",1),__decorateClass$2([checkConnection],MediaServerClient.prototype,"controlMessage",1),__decorateClass$2([checkConnection],MediaServerClient.prototype,"updateUserAttributes",1),__decorateClass$2([checkConnection],MediaServerClient.prototype,"updateSubTrack",1),__decorateClass$2([pubSubLock,checkConnection],MediaServerClient.prototype,"subscribe4pushTrack",1),__decorateClass$2([pubSubLock,checkConnection],MediaServerClient.prototype,"unsubscribe4removeTrack",1),__decorateClass$2([pubSubLock,checkConnection],MediaServerClient.prototype,"unsubscribe",1),__decorateClass$2([checkConnection],MediaServerClient.prototype,"handleRemoveStream",1),__decorateClass$2([pubSubLock],MediaServerClient.prototype,"subscribePublicStream",1),__decorateClass$2([pubSubLock],MediaServerClient.prototype,"unsubscribePublicStream",1);var _CONFIG,RecvFrameObserver=function(){function e(t,r){_classCallCheck(this,e),_defineProperty(this,"_audioEventSessionId",genEventSessionId()),_defineProperty(this,"_videoEventSessionId",genEventSessionId()),_defineProperty(this,"_handler",void 0),_defineProperty(this,"_stream",void 0),_defineProperty(this,"_firstAudioFrameTimer",void 0),_defineProperty(this,"_firstVideoFrameTimer",void 0),_defineProperty(this,"_transportDelayInterval",void 0),_defineProperty(this,"_transportDelay",void 0),_defineProperty(this,"_firstVideoFrameInterval",void 0),_defineProperty(this,"_firstAudioFrameInterval",void 0),_defineProperty(this,"_isScreen",!1),_defineProperty(this,"_audioFirstFrameState",0),_defineProperty(this,"_videoFirstFrameState",0),_defineProperty(this,"_timeout",1e4),_defineProperty(this,"_currentAudioRecv",{startTime:0,eventSessionId:0,type:FirstframeinfoType.LOGIN}),_defineProperty(this,"_currentVideoRecv",{startTime:0,eventSessionId:0,type:FirstframeinfoType.LOGIN}),_defineProperty(this,"_login",!1),_defineProperty(this,"_unMuteAudio",!1),_defineProperty(this,"_enableAudio",!1),_defineProperty(this,"_unMuteVideo",!1),_defineProperty(this,"_enableVideo",!1),_defineProperty(this,"_remoteUnmuteAudio",!1),_defineProperty(this,"_remoteUnmuteVideo",!1),_defineProperty(this,"_audioExternal",!1),_defineProperty(this,"_pushAudio",!1),_defineProperty(this,"_videoExternal",!1),_defineProperty(this,"_pushVideo",!1),_defineProperty(this,"_autoSubscribeVideo",!1),_defineProperty(this,"_autoSubscribeAudio",!1),_defineProperty(this,"_autoSubscribe",!1),_defineProperty(this,"_publishVideo",!1),_defineProperty(this,"_publishAudio",!1),_defineProperty(this,"_subscribeAudio",!1),_defineProperty(this,"_subscribeVideo",!1),_defineProperty(this,"_subscribe",!1),_defineProperty(this,"_pushTrack",!1),_defineProperty(this,"_multiChatMode",!1),this._stream=t,this._handler=r,this.getTransportDelay()}var t,r,n,i;return _createClass(e,[{key:"beginRecvFrame",value:(i=_asyncToGenerator(_regeneratorRuntime().mark((function e(t,r){var n,i,o,a,s,c,u,l,d,p,_,f,h,m=this;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.getTransportDelay();case 2:n=this._transportDelay,i=!0,o=FirstframeinfoType.LOGIN,a=FirstframeinfoType.UNMUTE,s=FirstframeinfoType.SUBSCRIBE,c=FirstframeinfoType.PUSH_TRACK,[o,a,s,c].indexOf(r)>=0&&(n=0,i=!1),t===FirstframeinfoMediaType.AUDIO?(i||this._audioEventSessionId++,this._currentAudioRecv={startTime:Date.now(),eventSessionId:this._audioEventSessionId,type:r},d={media_type:t,event_type:FirstframeinfoEventType.BEGIN_RECV,type:r,start:null===(u=this._currentAudioRecv)||void 0===u?void 0:u.startTime,event_session_id:this._audioEventSessionId,stream_user_id:null===(l=this._stream)||void 0===l?void 0:l.userId,transport_delay:n},this._firstAudioFrameTimer&&window.clearTimeout(this._firstAudioFrameTimer),this._firstAudioFrameTimer=window.setTimeout((function(){m.stopRecvFrame(FirstframeinfoMediaType.AUDIO,FirstframeinfoReason.TIMEOUT),m._firstAudioFrameInterval&&window.clearInterval(m._firstAudioFrameInterval)}),this._timeout),monitor.rtcFirstFrame(d),this._watchForFirstAudioFrameRecv(),this._audioFirstFrameState=1,this._login=!0,this._unMuteAudio=!0,this._enableAudio=!0,this._remoteUnmuteAudio=!0):t===FirstframeinfoMediaType.VIDEO&&(i||this._videoEventSessionId++,this._currentVideoRecv={startTime:Date.now(),eventSessionId:this._videoEventSessionId,type:r},h={media_type:null!==(p=this._stream)&&void 0!==p&&p.isScreen?FirstframeinfoMediaType.SCREEN_VIDEO:t,event_type:FirstframeinfoEventType.BEGIN_RECV,type:r,start:null===(_=this._currentVideoRecv)||void 0===_?void 0:_.startTime,event_session_id:this._videoEventSessionId,stream_user_id:null===(f=this._stream)||void 0===f?void 0:f.userId,transport_delay:n},this._firstVideoFrameTimer&&window.clearTimeout(this._firstVideoFrameTimer),this._firstVideoFrameTimer=window.setTimeout((function(){m.stopRecvFrame(FirstframeinfoMediaType.VIDEO,FirstframeinfoReason.TIMEOUT),m._firstVideoFrameInterval&&window.clearInterval(m._firstVideoFrameInterval)}),this._timeout),this._watchForFirstVideoFrameRecv(),monitor.rtcFirstFrame(h),this._videoFirstFrameState=1,this._login=!0,this._unMuteVideo=!0,this._enableVideo=!0,this._remoteUnmuteVideo=!0);case 7:case"end":return e.stop()}}),e,this)}))),function(e,t){return i.apply(this,arguments)})},{key:"stopRecvFrame",value:function(e,t){if(e===FirstframeinfoMediaType.AUDIO){var r,n,i;if(1!==this._audioFirstFrameState)return;var o={event_type:FirstframeinfoEventType.RECV_END,media_type:e,start:null===(r=this._currentAudioRecv)||void 0===r?void 0:r.startTime,reason:t,result:!1,stream_user_id:null===(n=this._stream)||void 0===n?void 0:n.userId,event_session_id:this._audioEventSessionId,type:null===(i=this._currentAudioRecv)||void 0===i?void 0:i.type};this._firstAudioFrameTimer&&window.clearTimeout(this._firstAudioFrameTimer),delete this._currentAudioRecv,monitor.rtcFirstFrame(o),this._audioFirstFrameState=2}else if(e===FirstframeinfoMediaType.VIDEO){var a,s,c,u;if(1!==this._videoFirstFrameState)return;var l={event_type:FirstframeinfoEventType.RECV_END,media_type:null!==(a=this._stream)&&void 0!==a&&a.isScreen?FirstframeinfoMediaType.SCREEN_VIDEO:e,start:null===(s=this._currentVideoRecv)||void 0===s?void 0:s.startTime,reason:t,result:!1,stream_user_id:null===(c=this._stream)||void 0===c?void 0:c.userId,event_session_id:this._videoEventSessionId,type:null===(u=this._currentVideoRecv)||void 0===u?void 0:u.type};this._firstVideoFrameTimer&&window.clearTimeout(this._firstVideoFrameTimer),delete this._currentVideoRecv,monitor.rtcFirstFrame(l),this._videoFirstFrameState=2}}},{key:"recvFrameFinish",value:(n=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){var r,n,i,o,a,s,c,u,l,d,p,_,f,h,m,y;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.getTransportDelay();case 2:if(r=this._transportDelay,n=FirstframeinfoType.LOGIN,i=FirstframeinfoType.UNMUTE,o=FirstframeinfoType.SUBSCRIBE,a=FirstframeinfoType.PUSH_TRACK,t!==FirstframeinfoMediaType.AUDIO){e.next=18;break}if(1===this._audioFirstFrameState){e.next=7;break}return e.abrupt("return");case 7:if(this._currentAudioRecv){e.next=9;break}return e.abrupt("return");case 9:c=this._currentAudioRecv,u=c.type,l=c.startTime,[n,i,o,a].indexOf(u)>=0&&(r=0),d={event_type:FirstframeinfoEventType.RECV_END,media_type:t,start:l,result:!0,stream_user_id:null===(s=this._stream)||void 0===s?void 0:s.userId,event_session_id:this._audioEventSessionId,type:u,transport_delay:r},delete this._currentAudioRecv,this._firstAudioFrameTimer&&window.clearTimeout(this._firstAudioFrameTimer),monitor.rtcFirstFrame(d),this._audioFirstFrameState=3,e.next=30;break;case 18:if(t!==FirstframeinfoMediaType.VIDEO){e.next=30;break}if(1===this._videoFirstFrameState){e.next=21;break}return e.abrupt("return");case 21:if(this._currentVideoRecv){e.next=23;break}return e.abrupt("return");case 23:f=this._currentVideoRecv,h=f.type,m=f.startTime,[n,i,o,a].indexOf(h)>=0&&(r=0),y={event_type:FirstframeinfoEventType.RECV_END,media_type:null!==(p=this._stream)&&void 0!==p&&p.isScreen?FirstframeinfoMediaType.SCREEN_VIDEO:t,start:m,result:!0,stream_user_id:null===(_=this._stream)||void 0===_?void 0:_.userId,event_session_id:this._videoEventSessionId,type:h,transport_delay:r},delete this._currentVideoRecv,this._firstVideoFrameTimer&&window.clearTimeout(this._firstVideoFrameTimer),monitor.rtcFirstFrame(y),this._videoFirstFrameState=3;case 30:case"end":return e.stop()}}),e,this)}))),function(e){return n.apply(this,arguments)})},{key:"setLogin",value:function(e){var t,r,n,i,o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{audio:!0,video:!0};this._login!==e&&(this._login=e,e&&null!==(t=this._stream)&&void 0!==t&&t.hasAudio&&o.audio&&this.beginRecvFrame(FirstframeinfoMediaType.AUDIO,FirstframeinfoType.LOGIN),e&&null!==(r=this._stream)&&void 0!==r&&r.hasVideo&&o.video&&this.beginRecvFrame(FirstframeinfoMediaType.VIDEO,FirstframeinfoType.LOGIN),!e&&null!==(n=this._stream)&&void 0!==n&&n.hasAudio&&this.stopRecvFrame(FirstframeinfoMediaType.AUDIO,FirstframeinfoReason.LEAVE_ROOM),!e&&null!==(i=this._stream)&&void 0!==i&&i.hasVideo&&this.stopRecvFrame(FirstframeinfoMediaType.VIDEO,FirstframeinfoReason.LEAVE_ROOM))}},{key:"setUnmuteAudio",value:function(e){var t;this._unMuteAudio!==e&&(this._unMuteAudio=e,this._unMuteAudio?this.beginRecvFrame(FirstframeinfoMediaType.AUDIO,FirstframeinfoType.UNMUTE):null!==(t=this._stream)&&void 0!==t&&t.hasAudio&&this.stopRecvFrame(FirstframeinfoMediaType.AUDIO,FirstframeinfoReason.MUTE))}},{key:"setRemoteUnmuteAudio",value:function(e){var t;this._remoteUnmuteAudio!==e&&(this._remoteUnmuteAudio=e,this._remoteUnmuteAudio?this.beginRecvFrame(FirstframeinfoMediaType.AUDIO,FirstframeinfoType.REMOTE_UNMUTE):null!==(t=this._stream)&&void 0!==t&&t.hasAudio&&this.stopRecvFrame(FirstframeinfoMediaType.AUDIO,FirstframeinfoReason.REMOTE_MUTE))}},{key:"setEnableAudio",value:function(e){var t;this._enableAudio!==e&&(this._enableAudio=e,this._enableAudio?this.beginRecvFrame(FirstframeinfoMediaType.AUDIO,FirstframeinfoType.ENABLE):null!==(t=this._stream)&&void 0!==t&&t.hasAudio&&this.stopRecvFrame(FirstframeinfoMediaType.AUDIO,FirstframeinfoReason.DISABLE))}},{key:"setUnmuteVideo",value:function(e){var t;this._unMuteVideo!==e&&(this._unMuteVideo=e,this._unMuteVideo?this.beginRecvFrame(FirstframeinfoMediaType.VIDEO,FirstframeinfoType.UNMUTE):null!==(t=this._stream)&&void 0!==t&&t.hasVideo&&this.stopRecvFrame(FirstframeinfoMediaType.VIDEO,FirstframeinfoReason.MUTE))}},{key:"setRemoteUnmuteVideo",value:function(e){var t;this._remoteUnmuteVideo!==e&&(this._remoteUnmuteVideo=e,this._remoteUnmuteVideo?this.beginRecvFrame(FirstframeinfoMediaType.VIDEO,FirstframeinfoType.REMOTE_UNMUTE):null!==(t=this._stream)&&void 0!==t&&t.hasAudio&&this.stopRecvFrame(FirstframeinfoMediaType.VIDEO,FirstframeinfoReason.REMOTE_MUTE))}},{key:"setEnableVideo",value:function(e){this._enableVideo!==e&&(this._enableVideo=e,this._enableVideo?this.beginRecvFrame(FirstframeinfoMediaType.VIDEO,FirstframeinfoType.ENABLE):this.stopRecvFrame(FirstframeinfoMediaType.VIDEO,FirstframeinfoReason.DISABLE))}},{key:"setExternalAudioSource",value:function(e){this._audioExternal=e}},{key:"setPushAudio",value:function(e){var t;this._audioExternal&&this._pushAudio!==e&&(this._pushAudio=e),this._pushAudio&&this.beginRecvFrame(FirstframeinfoMediaType.AUDIO,FirstframeinfoType.PUSH),!e&&null!==(t=this._stream)&&void 0!==t&&t.hasAudio&&this.beginRecvFrame(FirstframeinfoMediaType.AUDIO,FirstframeinfoType.PUSH)}},{key:"setExternalVideoSource",value:function(e){this._videoExternal=e}},{key:"setPushVideo",value:function(e){var t;this._videoExternal&&this._pushVideo!==e&&(this._pushVideo=e),this._pushVideo&&this.beginRecvFrame(FirstframeinfoMediaType.VIDEO,FirstframeinfoType.PUSH),!e&&null!==(t=this._stream)&&void 0!==t&&t.hasVideo&&this.beginRecvFrame(FirstframeinfoMediaType.VIDEO,FirstframeinfoType.PUSH)}},{key:"setPublishVideo",value:function(e){var t;this._publishVideo!==e&&(this._publishVideo=e),this._publishVideo&&this.beginRecvFrame(FirstframeinfoMediaType.VIDEO,FirstframeinfoType.PUBLISH),!e&&null!==(t=this._stream)&&void 0!==t&&t.hasVideo&&this.stopRecvFrame(FirstframeinfoMediaType.VIDEO,FirstframeinfoReason.UNPUBLISH)}},{key:"setPublishAudio",value:function(e){var t;this._publishAudio!==e&&(this._publishAudio=e),this._publishAudio&&this.beginRecvFrame(FirstframeinfoMediaType.AUDIO,FirstframeinfoType.PUBLISH),!e&&null!==(t=this._stream)&&void 0!==t&&t.hasAudio&&this.stopRecvFrame(FirstframeinfoMediaType.AUDIO,FirstframeinfoReason.UNPUBLISH)}},{key:"setAutoSubscribe",value:function(e){this._autoSubscribe=e}},{key:"setAutoSubscribeVideo",value:function(e){this._autoSubscribeVideo=e}},{key:"setAutoSubscribeAudio",value:function(e){this._autoSubscribeAudio=e}},{key:"setSubscribeAudio",value:function(e){var t,r;this._autoSubscribeAudio||this._subscribeAudio===e||(this._subscribe=e,e&&null!==(r=this._stream)&&void 0!==r&&r.hasAudio&&this.beginRecvFrame(FirstframeinfoMediaType.AUDIO,FirstframeinfoType.SUBSCRIBE));!e&&null!==(t=this._stream)&&void 0!==t&&t.hasAudio&&this.stopRecvFrame(FirstframeinfoMediaType.AUDIO,FirstframeinfoReason.UNSUBSCRIBE)}},{key:"setSubscribeVideo",value:function(e){var t,r;this._autoSubscribeVideo||this._subscribeVideo===e||(this._subscribeVideo=e,e&&null!==(r=this._stream)&&void 0!==r&&r.hasVideo&&this.beginRecvFrame(FirstframeinfoMediaType.VIDEO,FirstframeinfoType.SUBSCRIBE));!e&&null!==(t=this._stream)&&void 0!==t&&t.hasVideo&&this.stopRecvFrame(FirstframeinfoMediaType.VIDEO,FirstframeinfoReason.UNSUBSCRIBE)}},{key:"setPushTrack",value:function(e){var t;this._pushTrack!==e&&(e&&!this._isScreen&&this.beginRecvFrame(FirstframeinfoMediaType.AUDIO,FirstframeinfoType.PUSH_TRACK),!e&&null!==(t=this._stream)&&void 0!==t&&t.hasAudio&&this.stopRecvFrame(FirstframeinfoMediaType.AUDIO,FirstframeinfoReason.REMOVE_TRACK))}},{key:"setMultiChatMode",value:function(e){this._multiChatMode=e}},{key:"setTimeout",value:function(e){this._timeout=e}},{key:"_watchForFirstVideoFrameRecv",value:function(){var e=this,t=-1,r=-1;this._firstVideoFrameInterval=window.setInterval(_asyncToGenerator(_regeneratorRuntime().mark((function n(){var i,o,a,s,c,u,l,d;return _regeneratorRuntime().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(null===(i=e._handler)||void 0===i||!i.pc||null===(o=e._stream)||void 0===o||null===(a=o.videoTrack)||void 0===a||!a.getTrack()){n.next=12;break}return n.next=3,getStats(null===(s=e._handler)||void 0===s?void 0:s.pc,null===(c=e._stream)||void 0===c||null===(u=c.videoTrack)||void 0===u?void 0:u.getTrack());case 3:if(l=n.sent,!(d=l.find((function(e){return"inbound-rtp"===e.type})))||!(d.framesReceived>t||d.packetsReceived>r)){n.next=12;break}if(-1!==t||-1!==r){n.next=10;break}return t=d.framesReceived,r=d.packetsReceived,n.abrupt("return");case 10:e.recvFrameFinish(FirstframeinfoMediaType.VIDEO),window.clearInterval(e._firstVideoFrameInterval);case 12:case"end":return n.stop()}}),n)}))),200)}},{key:"_watchForFirstAudioFrameRecv",value:function(){var e=this,t=-1,r=-1;this._firstAudioFrameInterval=window.setInterval(_asyncToGenerator(_regeneratorRuntime().mark((function n(){var i,o,a,s,c,u,l,d;return _regeneratorRuntime().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(null===(i=e._handler)||void 0===i||!i.pc||null===(o=e._stream)||void 0===o||null===(a=o.audioTrack)||void 0===a||!a.getTrack()){n.next=12;break}return n.next=3,getStats(null===(s=e._handler)||void 0===s?void 0:s.pc,null===(c=e._stream)||void 0===c||null===(u=c.audioTrack)||void 0===u?void 0:u.getTrack());case 3:if(l=n.sent,!(d=l.find((function(e){return"inbound-rtp"===e.type})))||!(d.totalSamplesReceived>t||d.packetsReceived>r)){n.next=12;break}if(-1!==t||-1!==r){n.next=10;break}return t=d.totalSamplesReceived,r=d.packetsReceived,n.abrupt("return");case 10:e.recvFrameFinish(FirstframeinfoMediaType.AUDIO),window.clearInterval(e._firstAudioFrameInterval);case 12:case"end":return n.stop()}}),n)}))),200)}},{key:"getTransportDelay",value:(r=_asyncToGenerator(_regeneratorRuntime().mark((function e(){var t=this;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.getTransportDelayIntl();case 2:window.clearInterval(this._transportDelayInterval),this._transportDelayInterval=window.setInterval(_asyncToGenerator(_regeneratorRuntime().mark((function e(){return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,t.getTransportDelayIntl();case 2:case"end":return e.stop()}}),e)}))),2e3);case 4:case"end":return e.stop()}}),e,this)}))),function(){return r.apply(this,arguments)})},{key:"getTransportDelayIntl",value:(t=_asyncToGenerator(_regeneratorRuntime().mark((function e(){var t,r,n,i,o;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(null===(t=this._handler)||void 0===t||!t.pc){e.next=7;break}return e.next=3,getStats(null===(r=this._handler)||void 0===r?void 0:r.pc);case 3:n=e.sent,i=n.find((function(e){return"transport"===e.type&&"connected"===e.dtlsState})),(o=n.find((function(e){return"candidate-pair"===e.type&&"succeeded"===e.state&&e.id===(null==i?void 0:i.selectedCandidatePairId)})))&&(this._transportDelay=Math.round(1e3*o.currentRoundTripTime/2));case 7:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})},{key:"reset",value:function(){this._currentAudioRecv={startTime:0,eventSessionId:0,type:FirstframeinfoType.LOGIN},this._currentVideoRecv={startTime:0,eventSessionId:0,type:FirstframeinfoType.LOGIN},this._login=!1,this._unMuteAudio=!1,this._enableAudio=!1,this._unMuteVideo=!1,this._remoteUnmuteAudio=!1,this._remoteUnmuteVideo=!1,this._enableVideo=!1,this._audioExternal=!1,this._pushAudio=!1,this._videoExternal=!1,this._pushVideo=!1,this._autoSubscribeVideo=!1,this._autoSubscribeAudio=!1,this._autoSubscribe=!1,this._subscribeAudio=!1,this._subscribeVideo=!1,this._subscribe=!1,this._pushTrack=!1,this._multiChatMode=!1,this._firstAudioFrameTimer&&window.clearTimeout(this._firstAudioFrameTimer),this._firstVideoFrameTimer&&window.clearTimeout(this._firstVideoFrameTimer),this._firstAudioFrameInterval&&window.clearInterval(this._firstAudioFrameInterval),this._firstVideoFrameInterval&&window.clearInterval(this._firstVideoFrameInterval),this._transportDelayInterval&&window.clearInterval(this._transportDelayInterval)}}]),e}(),SendFrameObserver=function(){function e(t,r){_classCallCheck(this,e),_defineProperty(this,"_audioEventSessionId",genEventSessionId()),_defineProperty(this,"_videoEventSessionId",genEventSessionId()),_defineProperty(this,"_pcSessionId",void 0),_defineProperty(this,"_handler",void 0),_defineProperty(this,"_firstAudioFrameTimer",void 0),_defineProperty(this,"_firstVideoFrameTimer",void 0),_defineProperty(this,"_stream",void 0),_defineProperty(this,"_firstVideoFrameInterval",void 0),_defineProperty(this,"_firstAudioFrameInterval",void 0),_defineProperty(this,"_currentAudioSend",{startTime:0,eventSessionId:0,type:FirstframeinfoType.LOGIN}),_defineProperty(this,"_currentVideoSend",{startTime:0,eventSessionId:0,type:FirstframeinfoType.LOGIN}),_defineProperty(this,"_login",!1),_defineProperty(this,"_publisher",!1),_defineProperty(this,"_unMuteAudio",!1),_defineProperty(this,"_enableAudio",!1),_defineProperty(this,"_unMuteVideo",!1),_defineProperty(this,"_enableVideo",!1),_defineProperty(this,"_audioExternal",!1),_defineProperty(this,"_pushAudio",!1),_defineProperty(this,"_videoExternal",!1),_defineProperty(this,"_pushVideo",!1),_defineProperty(this,"_autoPublish",!1),_defineProperty(this,"_publish",!1),_defineProperty(this,"_timeout",1e4),_defineProperty(this,"_audioFirstFrameState",0),_defineProperty(this,"_videoFirstFrameState",0),this._stream=t,this._handler=r}var t,r;return _createClass(e,[{key:"beginSendFrame",value:function(e,t){var r=this;if(e===FirstframeinfoMediaType.AUDIO){var n;this._audioEventSessionId++,this._currentAudioSend={startTime:Date.now(),eventSessionId:this._audioEventSessionId,type:t};var i={media_type:e,event_type:FirstframeinfoEventType.BEGIN_SEND,type:t,start:null===(n=this._currentAudioSend)||void 0===n?void 0:n.startTime,event_session_id:this._audioEventSessionId};this._firstAudioFrameTimer&&window.clearTimeout(this._firstAudioFrameTimer),this._firstAudioFrameTimer=window.setTimeout((function(){r.stopSendFrame(FirstframeinfoMediaType.AUDIO,FirstframeinfoReason.TIMEOUT),r._firstAudioFrameInterval&&window.clearInterval(r._firstAudioFrameInterval)}),this._timeout),monitor.rtcFirstFrame(i),this._watchForFirstAudioFrameSend(),this._audioFirstFrameState=1,this._login=!0,this._publisher=!0,this._publish=!0,this._unMuteAudio=!0,this._pushAudio||(this._enableAudio=!0)}else if(e===FirstframeinfoMediaType.VIDEO){var o,a;this._videoEventSessionId++,this._currentVideoSend={startTime:Date.now(),eventSessionId:this._videoEventSessionId,type:t};var s={media_type:null!==(o=this._stream)&&void 0!==o&&o.isScreen?FirstframeinfoMediaType.SCREEN_VIDEO:e,event_type:FirstframeinfoEventType.BEGIN_SEND,type:t,start:null===(a=this._currentVideoSend)||void 0===a?void 0:a.startTime,event_session_id:this._videoEventSessionId};this._firstVideoFrameTimer&&window.clearTimeout(this._firstVideoFrameTimer),this._firstVideoFrameTimer=window.setTimeout((function(){r.stopSendFrame(FirstframeinfoMediaType.VIDEO,FirstframeinfoReason.TIMEOUT),r._firstVideoFrameInterval&&window.clearInterval(r._firstVideoFrameInterval)}),this._timeout),this._watchForFirstVideoFrameSend(),monitor.rtcFirstFrame(s),this._videoFirstFrameState=1,this._login=!0,this._publisher=!0,this._publish=!0,this._unMuteVideo=!0,this._pushVideo||(this._enableVideo=!0)}}},{key:"stopSendFrame",value:function(e,t){if(e===FirstframeinfoMediaType.AUDIO){var r,n;if(1!==this._audioFirstFrameState)return;var i={event_type:FirstframeinfoEventType.SENT_END,media_type:e,start:null===(r=this._currentAudioSend)||void 0===r?void 0:r.startTime,reason:t,result:!1,event_session_id:this._audioEventSessionId,type:null===(n=this._currentAudioSend)||void 0===n?void 0:n.type};this._firstAudioFrameTimer&&window.clearTimeout(this._firstAudioFrameTimer),delete this._currentAudioSend,monitor.rtcFirstFrame(i),this._audioFirstFrameState=2}else if(e===FirstframeinfoMediaType.VIDEO){var o,a,s;if(1!==this._videoFirstFrameState)return;var c={event_type:FirstframeinfoEventType.SENT_END,media_type:null!==(o=this._stream)&&void 0!==o&&o.isScreen?FirstframeinfoMediaType.SCREEN_VIDEO:e,start:null===(a=this._currentVideoSend)||void 0===a?void 0:a.startTime,reason:t,result:!1,event_session_id:this._videoEventSessionId,type:null===(s=this._currentVideoSend)||void 0===s?void 0:s.type};this._firstVideoFrameTimer&&window.clearTimeout(this._firstVideoFrameTimer),delete this._currentVideoSend,monitor.rtcFirstFrame(c),this._videoFirstFrameState=2}}},{key:"sendFrameFinish",value:function(e){if(e===FirstframeinfoMediaType.AUDIO){if(1!==this._audioFirstFrameState)return;if(!this._currentAudioSend)return;var t=this._currentAudioSend,r=t.type,n=t.startTime,i={event_type:FirstframeinfoEventType.SENT_END,media_type:e,start:n,result:!0,event_session_id:this._audioEventSessionId,type:r};delete this._currentAudioSend,this._firstAudioFrameTimer&&window.clearTimeout(this._firstAudioFrameTimer),monitor.rtcFirstFrame(i),this._audioFirstFrameState=3}else if(e===FirstframeinfoMediaType.VIDEO){var o;if(1!==this._videoFirstFrameState)return;if(!this._currentVideoSend)return;var a=this._currentVideoSend,s=a.type,c=a.startTime,u={event_type:FirstframeinfoEventType.SENT_END,media_type:null!==(o=this._stream)&&void 0!==o&&o.isScreen?FirstframeinfoMediaType.SCREEN_VIDEO:e,start:c,result:!0,event_session_id:this._videoEventSessionId,type:s};delete this._currentVideoSend,this._firstVideoFrameTimer&&window.clearTimeout(this._firstVideoFrameTimer),monitor.rtcFirstFrame(u),this._videoFirstFrameState=3}}},{key:"setLogin",value:function(e){if(this._login!==e){var t,r;if(this._login=e,e)null!==(t=this._stream)&&void 0!==t&&t.videoTrack&&this.beginSendFrame(FirstframeinfoMediaType.VIDEO,FirstframeinfoType.LOGIN),null!==(r=this._stream)&&void 0!==r&&r.audioTrack&&this.beginSendFrame(FirstframeinfoMediaType.AUDIO,FirstframeinfoType.LOGIN);!e&&this._audioSending&&this.stopSendFrame(FirstframeinfoMediaType.AUDIO,FirstframeinfoReason.LEAVE_ROOM),!e&&this._videoSending&&this.stopSendFrame(FirstframeinfoMediaType.VIDEO,FirstframeinfoReason.LEAVE_ROOM)}}},{key:"setPublish",value:function(e){if(this._publish!==e){var t,r;if(this._publish=e,e)(null===(t=this._stream)||void 0===t?void 0:t.videoTrack)&&this.beginSendFrame(FirstframeinfoMediaType.VIDEO,FirstframeinfoType.PUBLISH),(null===(r=this._stream)||void 0===r?void 0:r.audioTrack)&&this.beginSendFrame(FirstframeinfoMediaType.AUDIO,FirstframeinfoType.PUBLISH);!e&&this._audioSending&&this.stopSendFrame(FirstframeinfoMediaType.AUDIO,FirstframeinfoReason.UNPUBLISH),!e&&this._videoSending&&this.stopSendFrame(FirstframeinfoMediaType.VIDEO,FirstframeinfoReason.UNPUBLISH)}}},{key:"setUnmuteAudio",value:function(e){this._unMuteAudio!==e&&(this._unMuteAudio=e,e&&this.beginSendFrame(FirstframeinfoMediaType.AUDIO,FirstframeinfoType.UNMUTE),!e&&this._audioSending&&this.stopSendFrame(FirstframeinfoMediaType.AUDIO,FirstframeinfoReason.MUTE))}},{key:"setEnableAudio",value:function(e){this._enableAudio!==e&&(this._enableAudio=e,e&&this.beginSendFrame(FirstframeinfoMediaType.AUDIO,FirstframeinfoType.ENABLE),!e&&this._audioSending&&this.stopSendFrame(FirstframeinfoMediaType.AUDIO,FirstframeinfoReason.DISABLE))}},{key:"setUnmuteVideo",value:function(e){this._unMuteVideo!==e&&(this._unMuteVideo=e,e&&this.beginSendFrame(FirstframeinfoMediaType.VIDEO,FirstframeinfoType.UNMUTE),!e&&this._videoSending&&this.stopSendFrame(FirstframeinfoMediaType.VIDEO,FirstframeinfoReason.MUTE))}},{key:"setEnableVideo",value:function(e){this._enableVideo!==e&&(this._enableVideo=e,e&&this.beginSendFrame(FirstframeinfoMediaType.VIDEO,FirstframeinfoType.ENABLE),!e&&this._videoSending&&this.stopSendFrame(FirstframeinfoMediaType.VIDEO,FirstframeinfoReason.DISABLE))}},{key:"setExternalAudioSource",value:function(e){this._audioExternal!==e&&(this._audioExternal=e,e&&(this._audioSending&&this.stopSendFrame(FirstframeinfoMediaType.AUDIO,FirstframeinfoReason.DISABLE),this._enableAudio=!1),e||(this._audioSending&&this.stopSendFrame(FirstframeinfoMediaType.AUDIO,FirstframeinfoReason.STOP_PUSH),this._pushAudio=!1))}},{key:"setPushAudio",value:function(e){this._pushAudio!==e&&(this._pushAudio=e,e&&this.beginSendFrame(FirstframeinfoMediaType.AUDIO,FirstframeinfoType.PUSH),!e&&this._audioSending&&this.stopSendFrame(FirstframeinfoMediaType.AUDIO,FirstframeinfoReason.STOP_PUSH))}},{key:"setExternalVideoSource",value:function(e){this._videoExternal!==e&&(this._videoExternal=e,e&&(this._videoSending&&this.stopSendFrame(FirstframeinfoMediaType.VIDEO,FirstframeinfoReason.DISABLE),this._enableVideo=!1),e||(this._videoSending&&this.stopSendFrame(FirstframeinfoMediaType.VIDEO,FirstframeinfoReason.STOP_PUSH),this._pushVideo=!1))}},{key:"setPushVideo",value:function(e){this._pushVideo!==e&&(this._pushVideo=e,e&&this.beginSendFrame(FirstframeinfoMediaType.VIDEO,FirstframeinfoType.PUSH),!e&&this._videoSending&&this.stopSendFrame(FirstframeinfoMediaType.VIDEO,FirstframeinfoReason.STOP_PUSH))}},{key:"setAutoPublish",value:function(e){this._autoPublish=e}},{key:"setPublisher",value:function(e){this._publisher!==e&&(this._publisher=e,!e&&this._audioSending&&this.stopSendFrame(FirstframeinfoMediaType.AUDIO,FirstframeinfoReason.AUDIENCE),!e&&this._videoSending&&this.stopSendFrame(FirstframeinfoMediaType.VIDEO,FirstframeinfoReason.AUDIENCE))}},{key:"setTimeout",value:function(e){this._timeout=e}},{key:"setPCSessionId",value:function(e){this._pcSessionId=e}},{key:"setHandler",value:function(e){this._handler=e}},{key:"_getFirstVideoFrameStats",value:(r=_asyncToGenerator(_regeneratorRuntime().mark((function e(){var t,r,n,i,o,a,s,c;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(null===(t=this._handler)||void 0===t||!t.pc||null===(r=this._stream)||void 0===r||null===(n=r.videoTrack)||void 0===n||!n.getTrack()){e.next=6;break}return e.next=3,getStats(null===(i=this._handler)||void 0===i?void 0:i.pc,null===(o=this._stream)||void 0===o||null===(a=o.videoTrack)||void 0===a?void 0:a.getTrack());case 3:return s=e.sent,c=s.find((function(e){return"outbound-rtp"===e.type})),e.abrupt("return",c);case 6:case"end":return e.stop()}}),e,this)}))),function(){return r.apply(this,arguments)})},{key:"_getFirstAudioFrameStats",value:(t=_asyncToGenerator(_regeneratorRuntime().mark((function e(){var t,r,n,i,o,a,s,c;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(null===(t=this._handler)||void 0===t||!t.pc||null===(r=this._stream)||void 0===r||null===(n=r.audioTrack)||void 0===n||!n.getPublishTrack()){e.next=6;break}return e.next=3,getStats(null===(i=this._handler)||void 0===i?void 0:i.pc,null===(o=this._stream)||void 0===o||null===(a=o.audioTrack)||void 0===a?void 0:a.getPublishTrack());case 3:return s=e.sent,c=s.find((function(e){return"outbound-rtp"===e.type})),e.abrupt("return",c);case 6:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})},{key:"_watchForFirstVideoFrameSend",value:function(){var e=this,t=-1,r=-1;this._firstVideoFrameInterval=window.setInterval(_asyncToGenerator(_regeneratorRuntime().mark((function n(){var i;return _regeneratorRuntime().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,e._getFirstVideoFrameStats();case 2:if(!(i=n.sent)||!(i.framesSent>t||i.packetsSent>r)){n.next=10;break}if(-1!==t||-1!==r){n.next=8;break}return t=i.framesSent,r=i.packetsSent,n.abrupt("return");case 8:e.sendFrameFinish(FirstframeinfoMediaType.VIDEO),window.clearInterval(e._firstVideoFrameInterval);case 10:case"end":return n.stop()}}),n)}))),100)}},{key:"_watchForFirstAudioFrameSend",value:function(){var e=this,t=-1;this._firstAudioFrameInterval=window.setInterval(_asyncToGenerator(_regeneratorRuntime().mark((function r(){var n;return _regeneratorRuntime().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,e._getFirstAudioFrameStats();case 2:if(!((n=r.sent)&&n.packetsSent>t)){r.next=9;break}if(-1!==t){r.next=7;break}return t=n.packetsSent,r.abrupt("return");case 7:e.sendFrameFinish(FirstframeinfoMediaType.AUDIO),window.clearInterval(e._firstAudioFrameInterval);case 9:case"end":return r.stop()}}),r)}))),100)}},{key:"reset",value:function(){this._login=!1,this._publisher=!1,this._unMuteAudio=!1,this._enableAudio=!1,this._unMuteVideo=!1,this._enableVideo=!1,this._audioExternal=!1,this._pushAudio=!1,this._videoExternal=!1,this._pushVideo=!1,this._autoPublish=!1,this._publish=!1,this._audioFirstFrameState=0,this._videoFirstFrameState=0,this._currentAudioSend={startTime:0,eventSessionId:0,type:FirstframeinfoType.LOGIN},this._currentVideoSend={startTime:0,eventSessionId:0,type:FirstframeinfoType.LOGIN},window.clearTimeout(this._firstAudioFrameTimer),window.clearTimeout(this._firstVideoFrameTimer),window.clearInterval(this._firstAudioFrameInterval),window.clearInterval(this._firstVideoFrameInterval)}},{key:"destroy",value:function(){this.reset(),delete this._stream,delete this._handler}},{key:"_audioSending",get:function(){return 1===this._audioFirstFrameState}},{key:"_videoSending",get:function(){return 1===this._videoFirstFrameState}}]),e}(),CONFIG=(_defineProperty(_CONFIG={},"audio",{delay:1200,stallRadio:.3}),_defineProperty(_CONFIG,"video",{delay:1200,stallRadio:.6}),_defineProperty(_CONFIG,"screen_audio",{delay:1600,stallRadio:.8}),_defineProperty(_CONFIG,"screen_video",{delay:1600,stallRadio:.8}),_CONFIG),NetworkQualityManager=function(){function e(){_classCallCheck(this,e),_defineProperty(this,"_preUplinkStats",new Map),_defineProperty(this,"_preDownlinkStats",new Map),_defineProperty(this,"_timer",void 0),_defineProperty(this,"_delayTimer",void 0),_defineProperty(this,"_connectionState",MediaConnectionState.CONNECTED),_defineProperty(this,"reportor",void 0)}return _createClass(e,[{key:"updateUplinkStats",value:function(e){var t=e.audioStats,r=e.videoStats,n=e.isScreen;if(t.sendKBitrate>0&&t.rtt){var i=n?"screen_audio":"audio",o=t.rtt,a=t._fractionLost,s=t._retransmittedRate,c=this._getQosLevel(o,a||0,s||0),u=this._preUplinkStats.get(i)||[c];this._preUplinkStats.set(i,[].concat(_toConsumableArray(u),[c]).slice(-2))}if(r.sentKBitrate>0&&r.rtt){var l=n?"screen_video":"video",d=r._fractionLost,p=r.rtt,_=r._sendBandWidth,f=r._retransmittedRate;0===_&&(d=Math.max(.65,d));var h=this._getQosLevel(p,d||0,f||0),m=this._preUplinkStats.get(l)||[h];this._preUplinkStats.set(l,[].concat(_toConsumableArray(m),[h]).slice(-2))}this._startNetworkQualityReport()}},{key:"updateDownlinkStats",value:function(e,t){if(t){var r,n,i=this._getStreamActiveState(t),o=i.audioActive,a=i.videoActive,s=e.audioStats,c=e.videoStats,u=e.isScreen,l=e.userId;if(o&&s.rtt)if(0===s.receivedKBitrate)r=NetworkQuality.VBAD;else{var d=s.rtt,p=s.audioLossRate,_=s.stallDuration,f=s.statsInterval,h=s.e2eDelay,m=_/f,y=u?"screen_audio":"audio",v=this._getQosLevel(d,p||0,c._retransmittedRate||0),S=this._getDownlinkQoE(y,m,h);r=this._getNetworkQuality(v,S)}if(a)if(0===c.receivedKBitrate||0===c.rtt)n=NetworkQuality.VBAD;else{var g=c.rtt,E=c.videoLossRate,T=c.stallDuration,b=c.statsInterval,R=c.e2eDelay,I=c._retransmittedRate,$=T/b,A=u?"screen_video":"video",C=this._getQosLevel(g,E||0,I||0),O=this._getDownlinkQoE(A,$,R);n=this._getNetworkQuality(C,O)}var P=r&&n?Math.ceil((r+n)/2):r||n;if(P){var k="".concat(l).concat(u?"_screen":""),w=this._preDownlinkStats.get(k)||[P];this._preDownlinkStats.set(k,[].concat(_toConsumableArray(w),[P]).slice(-2)),this._startNetworkQualityReport()}}}},{key:"setConnectionState",value:function(e){this._connectionState=e}},{key:"destroy",value:function(){this._timer&&(window.clearInterval(this._timer),delete this._timer),this._delayTimer&&(window.clearTimeout(this._delayTimer),delete this._delayTimer),this._preUplinkStats.clear(),this._preDownlinkStats.clear()}},{key:"_startNetworkQualityReport",value:function(){var e=this;this._delayTimer||this._timer||(this._preUplinkStats.size>0||this._preDownlinkStats.size>0)&&(this._delayTimer=window.setTimeout((function(){delete e._delayTimer,e._reportNetworkQuality(),e._timer=window.setInterval((function(){e._reportNetworkQuality()}),2e3)}),300))}},{key:"_reportNetworkQuality",value:function(){var e,t,r=this;if(this._connectionState!==MediaConnectionState.CONNECTED)e=t=NetworkQuality.VBAD;else{var n=this._getBetterQualityAndRemoveOldest("audio","up"),i=this._getBetterQualityAndRemoveOldest("video","up");e=n&&i?Math.ceil((n+i)/2):n||i||this._getBetterQualityAndRemoveOldest("screen_video","up")||this._getBetterQualityAndRemoveOldest("screen_audio","up")||NetworkQuality.UNKNOWN;var o=Array.from(this._preDownlinkStats.keys()).map((function(e){return r._getBetterQualityAndRemoveOldest(e,"down")})).filter((function(e){return e}));t=Math.ceil(o.reduce((function(e,t){return t+e}),0)/o.length)||NetworkQuality.UNKNOWN}this.reportor&&this.reportor(e,t)}},{key:"_getNetworkQuality",value:function(e,t){return 1===t?Math.max(e-2,1):2===t?e:Math.min(e+1,5)}},{key:"_getQosLevel",value:function(e,t,r){var n;return n=e<=250&&t<=.15?1:e<=500&&t<=.3?2:e<=750&&t<=.45?3:e<=1e3&&t<=.6?4:5,r>.5?n=Math.max(n,4):r>.35?n=Math.max(n,3):r>.15&&(n=Math.max(n,2)),n}},{key:"_getUplinkQoE",value:function(e,t){var r=0;switch(e){case"audio":case"video":r=t<.05?1:t<.1?2:3;break;case"screen_video":case"screen_audio":r=t<.04?1:t<.08?2:3}return r}},{key:"_getDownlinkQoE",value:function(e,t,r){var n=CONFIG[e];return t>n.stallRadio||r>n.delay||t>n.stallRadio/2&&r>n.delay/2?3:(t>n.stallRadio/2||n.delay,2)}},{key:"_getBetterQualityAndRemoveOldest",value:function(e,t){var r=NetworkQuality.UNKNOWN,n="up"===t?this._preUplinkStats:this._preDownlinkStats,i=n.get(e);if(i){var o=i.filter((function(e){return e}));o.length>0&&(r=Math.min.apply(Math,_toConsumableArray(o))),i.shift(),0===i.length&&n.delete(e)}return r}},{key:"_getStreamActiveState",value:function(e){var t=e.subMediaType,r=e._attributes,n=e.subVideo;return{audioActive:e.subAudio&&audioInMediaType(t)&&r.localaudio&&r.audiostream,videoActive:n&&videoInMediaType(t)&&r.localvideo&&r.videostream}}}]),e}(),VideoSizeObserver=function(){function e(t){_classCallCheck(this,e),_defineProperty(this,"_timer",void 0),_defineProperty(this,"_remoteVideoSizeCache",{}),_defineProperty(this,"_remoteScreenSizeCache",{}),_defineProperty(this,"onchange",void 0),this._room=t,this._start()}return _createClass(e,[{key:"destroy",value:function(){this._timer&&(window.clearInterval(this._timer),delete this._timer),this._remoteVideoSizeCache={},this._remoteScreenSizeCache={}}},{key:"_start",value:function(){var e=this;this._timer||(this._timer=window.setInterval((function(){var t={},r={};e._room.remoteStreams.forEach((function(n,i){n.forEach((function(n){var o,a=null===(o=n.videoTrack)||void 0===o?void 0:o.getTrack();if(a){var s=n.isScreen?e._remoteScreenSizeCache:e._remoteVideoSizeCache,c=s[i]||{},u=c.width,l=void 0===u?0:u,d=c.height,p=void 0===d?0:d,_=a.getSettings(),f=_.width,h=void 0===f?0:f,m=_.height,y=void 0===m?0:m;p===y&&l===h||e.onchange&&e.onchange(i,n.isScreen,h,y),delete s[i],(n.isScreen?r:t)[i]={width:h,height:y}}}))})),Object.keys(e._remoteVideoSizeCache).forEach((function(t){e.onchange&&e.onchange(t,!1,0,0)})),Object.keys(e._remoteScreenSizeCache).forEach((function(t){e.onchange&&e.onchange(t,!0,0,0)})),e._remoteVideoSizeCache=t,e._remoteScreenSizeCache=r}),1e3))}}]),e}(),logger$7=new Logger("SubscribeFallbackManager",2),SubscribeRecoverCheckDuration=1e4,SubscribeFallbackManager=function(){function e(t){_classCallCheck(this,e),_defineProperty(this,"_preDownlinkNetworkQuality",[]),_defineProperty(this,"_isSubscribeFallbackOrRecover",!1),_defineProperty(this,"_inSubscribeRecoverChecking",!1),_defineProperty(this,"_subRecoverCheckTimer",void 0),_defineProperty(this,"_forbidSubRecover",!1),_defineProperty(this,"_forbidSubRecoverTimer",void 0),_defineProperty(this,"_forbidSubRecoverDuration",SubscribeRecoverCheckDuration),_defineProperty(this,"onSubscribeFallback",void 0),this._room=t}var t;return _createClass(e,[{key:"updateNetworkQuality",value:function(e,t){this._preDownlinkNetworkQuality.push(t),this._preDownlinkNetworkQuality=this._preDownlinkNetworkQuality.slice(-10),this._inSubscribeRecoverChecking&&this._preDownlinkNetworkQuality.find((function(e){return e===NetworkQuality.BAD||e===NetworkQuality.VBAD}))&&this._startForbidSubRecover(),this._preDownlinkNetworkQuality.slice(-3).reduce((function(e,t){return e+t}),0)>3*NetworkQuality.POOR&&this._subscribeFallbackOrRecover("fallback"),!this._forbidSubRecover&&10===this._preDownlinkNetworkQuality.length&&this._preDownlinkNetworkQuality.every((function(e){return e===NetworkQuality.EXCELLENT}))&&this._subscribeFallbackOrRecover("recover")}},{key:"destroy",value:function(){this._stopSubscribeRecoverCheck(),this._stopForbidSubRecover(),delete this.onSubscribeFallback}},{key:"_subscribeFallbackOrRecover",value:(t=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){var r,n,i,o,a,s,c,u,l,d,p=this;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._isSubscribeFallbackOrRecover&&this._room.connectionState===MediaConnectionState.CONNECTED){e.next=2;break}return e.abrupt("return");case 2:if(this._room.subscribeFallbackOption!==SubscribeFallbackOption.AUDIO_ONLY&&this._room.subscribeFallbackOption!==SubscribeFallbackOption.VIDEO_STREAM_LOW){e.next=24;break}if(r=new Map,this._room.remoteStreams.forEach((function(e){e.forEach((function(e){if(e.hasSubscribed){var n="fallback"===t?e.getSubscribeFallbackParams(p._room.subscribeFallbackOption):e.getSubscribeRecoverParams();if(n){var i=e.getStreamPriority(),o=r.get(i)||[];o.push({stream:e,fallbackOrRecoverOption:n}),r.set(i,o)}}}))})),!(r.size>0)){e.next=24;break}if(logger$7.print("_subscribeFallbackOrRecover()","start subscribe ".concat(t,".")),n=Array.from(r.keys()).sort((function(e,t){return e-t}))["fallback"===t?0:r.size-1],i=r.get(n)||[],o=_slicedToArray(i,1),!(a=o[0])){e.next=24;break}return s=a.stream,c=a.fallbackOrRecoverOption,this._isSubscribeFallbackOrRecover=!0,u=s.subLayer.spatialLayer,l=s.subVideo,logger$7.print("_subscribeFallbackOrRecover()","".concat(s.userId,"'s stream will be ").concat(t," to: MediaType=").concat(c[0]," subState=").concat(c[1]," subLayer=").concat(c[2])),e.prev=15,e.next=18,promiseAny([(d=this._room).updateSubTrack.apply(d,[s].concat(_toConsumableArray(c))).then((function(){"recover"===t?p._startSubscribeRecoverCheck():logger$7.print("_subscribeFallbackOrRecover()","fallback success."),p.onSubscribeFallback&&p.onSubscribeFallback({userId:s.userId,isScreen:s.isScreen,beforeEnable:l,beforeVideoIndex:u,afterEnable:s.subVideo,afterVideoIndex:s.subLayer.spatialLayer,reason:"fallback"===t?FallbackOrRecoverReason.SubscribeFallbackByBandwidth:FallbackOrRecoverReason.SubscribeRecoverByBandwidth})})),wait(2e3)]);case 18:e.next=22;break;case 20:e.prev=20,e.t0=e.catch(15);case 22:this._preDownlinkNetworkQuality=[],this._isSubscribeFallbackOrRecover=!1;case 24:case"end":return e.stop()}}),e,this,[[15,20]])}))),function(e){return t.apply(this,arguments)})},{key:"_startSubscribeRecoverCheck",value:function(){var e=this;this._stopSubscribeRecoverCheck(),this._inSubscribeRecoverChecking=!0,this._subRecoverCheckTimer=window.setTimeout((function(){e._inSubscribeRecoverChecking=!1,e._forbidSubRecoverDuration=SubscribeRecoverCheckDuration,delete e._subRecoverCheckTimer,logger$7.print("_subscribeFallbackOrRecover()","recover success.")}),2*SubscribeRecoverCheckDuration)}},{key:"_stopSubscribeRecoverCheck",value:function(){this._subRecoverCheckTimer&&(window.clearTimeout(this._subRecoverCheckTimer),delete this._subRecoverCheckTimer),this._inSubscribeRecoverChecking=!1}},{key:"_startForbidSubRecover",value:function(){var e=this;this._stopSubscribeRecoverCheck(),this._stopForbidSubRecover(),this._forbidSubRecoverDuration=Math.min(this._forbidSubRecoverDuration+2*SubscribeRecoverCheckDuration,12e4),logger$7.print("_subscribeFallbackOrRecover()","subscribe-recover failed, and subscribe-recover not allowed within ".concat(this._forbidSubRecoverDuration/1e3,"s")),this._forbidSubRecover=!0,this._forbidSubRecoverTimer=window.setTimeout((function(){e._forbidSubRecover=!1,delete e._forbidSubRecoverTimer}),this._forbidSubRecoverDuration)}},{key:"_stopForbidSubRecover",value:function(){this._forbidSubRecoverTimer&&(window.clearTimeout(this._forbidSubRecoverTimer),delete this._forbidSubRecoverTimer)}}]),e}(),logger$6=new Logger("Room",1),Room=function(e){_inherits(T,EnhancedEventEmitter);var t,r,n,i,o,a,s,c,u,l,d,p,_,f,h,m,y,v,S,g,E=_createSuper(T);function T(e,t){var r;return _classCallCheck(this,T),_defineProperty(_assertThisInitialized(r=E.call(this)),"_mediaServerClient",void 0),_defineProperty(_assertThisInitialized(r),"_localStream",void 0),_defineProperty(_assertThisInitialized(r),"_localScreenStream",void 0),_defineProperty(_assertThisInitialized(r),"_remoteUsers",new Map),_defineProperty(_assertThisInitialized(r),"_remoteStreams",new Map),_defineProperty(_assertThisInitialized(r),"_joinResolveCallback",void 0),_defineProperty(_assertThisInitialized(r),"_joinRejectCallback",void 0),_defineProperty(_assertThisInitialized(r),"_getAccessNode",void 0),_defineProperty(_assertThisInitialized(r),"_getAccessFeedback",void 0),_defineProperty(_assertThisInitialized(r),"_getAccessFeedbackIceNode",void 0),_defineProperty(_assertThisInitialized(r),"_reconnectTimer",void 0),_defineProperty(_assertThisInitialized(r),"_isReconnecting",void 0),_defineProperty(_assertThisInitialized(r),"_context",void 0),_defineProperty(_assertThisInitialized(r),"_sessionId",void 0),_defineProperty(_assertThisInitialized(r),"_reconnectRecord",void 0),_defineProperty(_assertThisInitialized(r),"_connectionLostTimer",void 0),_defineProperty(_assertThisInitialized(r),"_liveControlMessage",void 0),_defineProperty(_assertThisInitialized(r),"_serverConfig",void 0),_defineProperty(_assertThisInitialized(r),"_roomConfig",void 0),_defineProperty(_assertThisInitialized(r),"_roomInfo",void 0),_defineProperty(_assertThisInitialized(r),"_waitForNewToken",!1),_defineProperty(_assertThisInitialized(r),"_userDuplicateLoginTimerMap",new Map),_defineProperty(_assertThisInitialized(r),"_networkQualityManager",void 0),_defineProperty(_assertThisInitialized(r),"userPriorityMap",void 0),_defineProperty(_assertThisInitialized(r),"subscribeFallbackOption",void 0),_defineProperty(_assertThisInitialized(r),"_videoSizeObserver",void 0),_defineProperty(_assertThisInitialized(r),"_subFallbackManager",void 0),_defineProperty(_assertThisInitialized(r),"_hasPublished",!1),r._roomConfig=e,r._mediaServerClient=new MediaServerClient(t),r._reconnectRecord=new ReconnectRecord,r._addHandlerEventHandler(),r._isReconnecting=!1,r._networkQualityManager=new NetworkQualityManager,r._networkQualityManager.reportor=r._reportNetworkQuality.bind(_assertThisInitialized(r)),r._videoSizeObserver=new VideoSizeObserver(_assertThisInitialized(r)),r._videoSizeObserver.onchange=r._emitVideoSizeChange.bind(_assertThisInitialized(r)),r._subFallbackManager=new SubscribeFallbackManager(_assertThisInitialized(r)),r._subFallbackManager.onSubscribeFallback=r._emitSubscribeFallback.bind(_assertThisInitialized(r)),r._context=t,r}return _createClass(T,[{key:"hasScreenPublished",get:function(){var e;return null===(e=this._localScreenStream)||void 0===e?void 0:e.hasPublished}},{key:"hasPublished",get:function(){var e;return null===(e=this._localStream)||void 0===e?void 0:e.hasPublished}},{key:"connectionState",get:function(){return this._mediaServerClient.connectionState}},{key:"remoteUsers",get:function(){return this._remoteUsers}},{key:"remoteStreams",get:function(){return this._remoteStreams}},{key:"localStream",get:function(){return this._localStream}},{key:"localScreenStream",get:function(){return this._localScreenStream}},{key:"roomInfo",get:function(){return this._roomInfo}},{key:"_addHandlerEventHandler",value:function(){var e,t,r,n,i,o,a,s,c,u,l,d,p,_,f,h,m,y,v,S,g,E,T,b,R=this;null===(e=this._mediaServerClient)||void 0===e||e.on(SignalEvent.ON_ADD_STREAM,this._onAddStream.bind(this)),null===(t=this._mediaServerClient)||void 0===t||t.on(SignalEvent.ON_REMOVE_STREAM,this._onRemoveStream.bind(this)),null===(r=this._mediaServerClient)||void 0===r||r.on(SignalEvent.USER_CONNECTION,this._onUserConnection.bind(this)),null===(n=this._mediaServerClient)||void 0===n||n.on(SignalEvent.USER_DISCONNECTION,this._onUserDisconnection.bind(this)),null===(i=this._mediaServerClient)||void 0===i||i.on(SignalEvent.ON_UPDATE_ROOM_ATTRIBUTES,this._onUpdateRoomAttributes.bind(this)),null===(o=this._mediaServerClient)||void 0===o||o.on(SignalEvent.ON_UPDATE_USER_ATTRIBUTES,this._onUpdateUserAttributes.bind(this)),null===(a=this._mediaServerClient)||void 0===a||a.on(SignalEvent.ON_UPDATE_STREAM_ATTRIBUTES,this._onUpdateStreamAttributes.bind(this)),null===(s=this._mediaServerClient)||void 0===s||s.on(SignalEvent.ON_PUSH_TRACK,this._onPushTrack.bind(this)),null===(c=this._mediaServerClient)||void 0===c||c.on(SignalEvent.ON_REMOVE_TRACK,this._onRemoveTrack.bind(this)),null===(u=this._mediaServerClient)||void 0===u||u.on(SignalEvent.NODE_CHANGE,this._nodeChange.bind(this)),null===(l=this._mediaServerClient)||void 0===l||l.on(SignalEvent.ON_CUSTOM_MESSAGE,this._onCustomMessage.bind(this)),null===(d=this._mediaServerClient)||void 0===d||d.on(SignalEvent.USER_MESSAGE_RECEIVED,this._onUserMessageReceived.bind(this)),null===(p=this._mediaServerClient)||void 0===p||p.on(SignalEvent.USER_BINARY_MESSAGE_RECEIVED,this._onUserBinaryMessageReceived.bind(this)),null===(_=this._mediaServerClient)||void 0===_||_.on(SignalEvent.POST_PROCESSING_MESSAGE,this._onPostProcessingMessage.bind(this)),null===(f=this._mediaServerClient)||void 0===f||f.on(SignalEvent.ON_USER_TOKEN_WILL_EXPIRE,this._onUserTokenWillExpire.bind(this)),null===(h=this._mediaServerClient)||void 0===h||h.on(SignalEvent.STREAM_CONTROL_MESSAGE,this._onStreamControlMessage.bind(this)),null===(m=this._mediaServerClient)||void 0===m||m.on(SignalEvent.ON_SCENE_CONFIG,this._onSceneConfig.bind(this)),null===(y=this._mediaServerClient)||void 0===y||y.on(MediaServerSignalEvent.RSCP,this._onPublishOnDemand.bind(this)),null===(v=this._mediaServerClient)||void 0===v||v.on(StateEvent.ON_CONNECTION_STATE_CHANGE,this._onConnectionStateChange.bind(this)),null===(S=this._mediaServerClient)||void 0===S||S.on(StateEvent.ABNORMAL_DISCONNECTION,this._handleAbnormalDisconnection.bind(this)),null===(g=this._mediaServerClient)||void 0===g||g.on("onRemoteStreamStats",(function(e){R._networkQualityManager.updateDownlinkStats(e,R._findRemoteStreamByScreen(e.userId,e.isScreen)),R.emit(RoomEvent.ON_REMOTE_STREAM_STATS,getPublicStats(e))})),null===(E=this._mediaServerClient)||void 0===E||E.on("onLocalStreamStats",(function(e){R._networkQualityManager.updateUplinkStats(e),R.emit(RoomEvent.ON_LOCAL_STREAM_STATS,getPublicStats(e))})),null===(T=this._mediaServerClient)||void 0===T||T.on("prevIceNode",(function(e){R._getAccessFeedbackIceNode=e})),null===(b=this._mediaServerClient)||void 0===b||b.on("prevIceNode",(function(e){R._getAccessFeedbackIceNode=e}))}},{key:"_removeHandlerEventHandler",value:function(){var e;null===(e=this._mediaServerClient)||void 0===e||e.removeAllListeners()}},{key:"join",value:(g=_asyncToGenerator(_regeneratorRuntime().mark((function e(t,r,n,i,o,a){var s=this;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return commonStats.setStats({rtc_app_id:t,room_id:r,user_id:i.userId}),logger$6.print("join()"),e.abrupt("return",new Promise((function(e,c){var u;s._joinResolveCallback=function(t){var r;monitor.joinRoom(JoinroomType.END,l,!0,"",{enable_cloud_proxy:null===(r=s._roomInfo)||void 0===r?void 0:r.useCloudProxy}),e(t)},s._joinRejectCallback=function(e){var t;monitor.joinRoom(JoinroomType.END,l,!1,e.message,{enable_cloud_proxy:null===(t=s._roomInfo)||void 0===t?void 0:t.useCloudProxy}),c(e)},s._liveControlMessage=o,s._roomInfo={appId:t,roomId:r,token:n,userInfo:i,useCloudProxy:a,roomProfile:s._roomConfig.roomProfileType};var l=getServerNow();s.setSessionId(),monitor.joinRoom(JoinroomType.BEGIN,l,!1,"",{enable_cloud_proxy:null===(u=s._roomInfo)||void 0===u?void 0:u.useCloudProxy}),s._join(s._joinResolveCallback,s._joinRejectCallback,!1)})));case 3:case"end":return e.stop()}}),e)}))),function(e,t,r,n,i,o){return g.apply(this,arguments)})},{key:"_join",value:(S=_asyncToGenerator(_regeneratorRuntime().mark((function e(t,r){var n,i,o,a=arguments;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=a.length>2&&void 0!==a[2]&&a[2],i=getServerNow(),logger$6.print("_join()"),e.prev=3,e.next=6,this._mediaServerClient.join(this._roomInfo,{node:this._getAccessNode,reason:this._getAccessFeedback,sessionId:this._sessionId,feedbackNode:this._getAccessFeedbackIceNode},n,this._liveControlMessage);case 6:o=e.sent,this._mediaServerClient.roomAttributes=o.roomAttributes,this._reconnectRecord.clear(),this._joinResolveCallback=void 0,this._joinRejectCallback=void 0,this._getAccessFeedback=void 0,this._getAccessNode=void 0,"function"==typeof t&&t({users:o.clients,streams:o.streams}),this._isReconnecting=!1,monitor.rtcJoinRoom(0,"web","web",getServerNow()-i),this._onJoinSucc(o,n),e.next=23;break;case 19:if(e.prev=19,e.t0=e.catch(3),e.t0.code===ErrorCode.OPERATION_CANCEL||"function"!=typeof r){e.next=23;break}return e.abrupt("return",r(e.t0));case 23:case"end":return e.stop()}}),e,this,[[3,19]])}))),function(e,t){return S.apply(this,arguments)})},{key:"publishScreen",value:(v=_asyncToGenerator(_regeneratorRuntime().mark((function e(t,r,n,i,o){var a,s,c,u,l,d,p,_,f,h;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(logger$6.print("publishScreen()"),this._localScreenStream||(this._localScreenStream=new LocalStream,this._localScreenStream.isScreen=!0,this._mediaServerClient.handler&&(this._localScreenStream.observer=new SendFrameObserver(this._localScreenStream,this._mediaServerClient.handler))),a=!1,s=!1,c=!1,u=!1,!this._localScreenStream.videoTrack&&r?(r instanceof CustomVideoLocalTrack&&(s=!0),a=!0):this._localScreenStream.videoTrack&&!r&&(a=!1),!this._localScreenStream.audioTrack&&n?(n instanceof CustomAudioLocalTrack&&(u=!0),c=!0):this._localScreenStream.audioTrack&&!n&&(c=!1),this._localScreenStream.videoTrack=r,this._localScreenStream.audioTrack=n,this._localScreenStream.videoEncodeConfig=t,i&&(audioInMediaType(i)&&(this._localScreenStream.pubAudio=o===PubState.PUB),videoInMediaType(i)&&(this._localScreenStream.pubVideo=o===PubState.PUB),logger$6.print("publishScreen mediaType","pubAudio: %o, pubVideo: %o",this._localScreenStream.pubAudio,this._localScreenStream.pubVideo)),this._localScreenStream.pubAudio||this._localScreenStream.pubVideo){e.next=18;break}if(null===(l=this._localScreenStream)||void 0===l||!l.hasPublished){e.next=17;break}return e.abrupt("return",this.unpublishScreen());case 17:return e.abrupt("return");case 18:if(this._localScreenStream.hasPublished){e.next=24;break}return null===(d=this._localScreenStream.observer)||void 0===d||d.setPublish(!0),e.next=22,this._mediaServerClient.publish(this._localScreenStream);case 22:e.next=28;break;case 24:return s?null===(p=this._localScreenStream.observer)||void 0===p||p.setPushVideo(a):null===(_=this._localScreenStream.observer)||void 0===_||_.setEnableVideo(a),u?null===(f=this._localScreenStream.observer)||void 0===f||f.setPushAudio(c):null===(h=this._localScreenStream.observer)||void 0===h||h.setEnableAudio(c),e.next=28,this.updatePubScreenTrack();case 28:case"end":return e.stop()}}),e,this)}))),function(e,t,r,n,i){return v.apply(this,arguments)})},{key:"updatePubScreenTrack",value:(y=_asyncToGenerator(_regeneratorRuntime().mark((function e(){return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(logger$6.print("updatePubScreenTrack","Invoke updatePubScreenTrack"),!this._localScreenStream){e.next=4;break}return e.next=4,this._mediaServerClient.updatePubTrack(this._localScreenStream);case 4:case"end":return e.stop()}}),e,this)}))),function(){return y.apply(this,arguments)})},{key:"unpublishScreen",value:(m=_asyncToGenerator(_regeneratorRuntime().mark((function e(){var t;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(logger$6.print("unpublish","Invoke unpublishScreen"),!this._localScreenStream){e.next=7;break}return null===(t=this._localScreenStream.observer)||void 0===t||t.setPublish(!1),e.next=5,this._mediaServerClient.unpublish(this._localScreenStream);case 5:this._localScreenStream.clean(),this._localScreenStream=void 0;case 7:case"end":return e.stop()}}),e,this)}))),function(){return m.apply(this,arguments)})},{key:"liveControlMessage",value:(h=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){var r,n=this;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return logger$6.print("controlMessage","Invoke controlMessage"),null===(r=t.transcodeMeta)||void 0===r||r.layout.regions.forEach((function(e){n.roomInfo&&(e.roomID=n.roomInfo.roomId)})),this._liveControlMessage=t,e.next=5,this._mediaServerClient.controlMessage(t);case 5:"stopped"===t.action&&delete this._liveControlMessage;case 6:case"end":return e.stop()}}),e,this)}))),function(e){return h.apply(this,arguments)})},{key:"publicStreamControlMessage",value:(f=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return"stopped"===t.action&&delete t.publicStreamMeta,e.next=3,this._mediaServerClient.controlMessage(t);case 3:case"end":return e.stop()}}),e,this)}))),function(e){return f.apply(this,arguments)})},{key:"updateUserAttributes",value:(_=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return logger$6.print("updateUserAttributes","Invoke updateUserAttributes"),t.role&&this._roomInfo&&(this._roomInfo.userInfo.role=t.role),e.next=4,this._mediaServerClient.updateUserAttributes(t);case 4:case"end":return e.stop()}}),e,this)}))),function(e){return _.apply(this,arguments)})},{key:"publish",value:(p=_asyncToGenerator(_regeneratorRuntime().mark((function e(t,r,n,i,o,a){var s,c,u,l,d,p,_,f,h,m,y,v,S=arguments;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(s=S.length>6&&void 0!==S[6]&&S[6],logger$6.print("publish","Invoke publish"),c=!1,this._localStream||(this._localStream=new LocalStream,this._mediaServerClient.handler&&(this._localStream.observer=new SendFrameObserver(this._localStream,this._mediaServerClient.handler)),c=!0),this._localStream.videoTrack=n,this._localStream.audioTrack=i,this._localStream.videoEncodeConfig=t,this._localStream.enableSimulcast=r,o&&(audioInMediaType(o)&&(this._localStream.pubAudio=a===PubState.PUB),videoInMediaType(o)&&(this._localStream.pubVideo=a===PubState.PUB),logger$6.print("publish mediaType","pubAudio: %o, pubVideo: %o",this._localStream.pubAudio,this._localStream.pubVideo)),this._localStream.hasPublished){e.next=26;break}if(this._localStream.pubAudio||this._localStream.pubVideo){e.next=12;break}return e.abrupt("return");case 12:return e.prev=12,s?null===(u=this._localStream.observer)||void 0===u||u.setLogin(!0):c&&(l=!!this._localStream.videoTrack,d=!!this._localStream.audioTrack,p=this._localStream.videoTrack instanceof CustomVideoLocalTrack,_=this._localStream.audioTrack instanceof CustomAudioLocalTrack,this._roomConfig.isAutoPublish&&!this._hasPublished?(l&&(p?null===(f=this._localStream.observer)||void 0===f||f.setPushVideo(!0):null===(h=this._localStream.observer)||void 0===h||h.setEnableVideo(!0)),d&&(_?null===(m=this._localStream.observer)||void 0===m||m.setPushAudio(!0):null===(y=this._localStream.observer)||void 0===y||y.setEnableAudio(!0))):null===(v=this._localStream.observer)||void 0===v||v.setPublish(!0)),e.next=16,this._mediaServerClient.publish(this._localStream);case 16:this._hasPublished=!0,this.emit(RoomEvent.ON_PUBLISH_RESULT,{isScreen:!1,state:PublishState.PUBLISH_SUCC}),e.next=24;break;case 20:throw e.prev=20,e.t0=e.catch(12),this.emit(RoomEvent.ON_PUBLISH_RESULT,{isScreen:!1,state:PublishState.PUBLISH_FAIL}),e.t0;case 24:e.next=28;break;case 26:return e.next=28,this.updatePubTrack();case 28:case"end":return e.stop()}}),e,this,[[12,20]])}))),function(e,t,r,n,i,o){return p.apply(this,arguments)})},{key:"updatePubTrack",value:(d=_asyncToGenerator(_regeneratorRuntime().mark((function e(){return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(logger$6.print("updatePubTrack","Invoke updatePubTrack"),!this._localStream){e.next=4;break}return e.next=4,this._mediaServerClient.updatePubTrack(this._localStream);case 4:case"end":return e.stop()}}),e,this)}))),function(){return d.apply(this,arguments)})},{key:"unpublish",value:(l=_asyncToGenerator(_regeneratorRuntime().mark((function e(){return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(logger$6.print("unpublish","Invoke unpublish"),!this._localStream){e.next=6;break}return e.next=4,this._mediaServerClient.unpublish(this._localStream);case 4:this._localStream.clean(),this._localStream=void 0;case 6:case"end":return e.stop()}}),e,this)}))),function(){return l.apply(this,arguments)})},{key:"subscribe",value:(u=_asyncToGenerator(_regeneratorRuntime().mark((function e(t,r,n){var i;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return logger$6.print("subscribe","remoteStream %o",t),i=void 0,n&&(i=this._getSubLayer(n,t)),e.next=5,this._mediaServerClient.subscribe(t,r,i);case 5:case"end":return e.stop()}}),e,this)}))),function(e,t,r){return u.apply(this,arguments)})},{key:"updateSubTrack",value:(c=_asyncToGenerator(_regeneratorRuntime().mark((function e(t,r,n,i){var o;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return logger$6.print("updateSubTrack","Invoke updateSubTrack"),e.abrupt("return",null===(o=this._mediaServerClient)||void 0===o?void 0:o.updateSubTrack(t,r,n,i));case 2:case"end":return e.stop()}}),e,this)}))),function(e,t,r,n){return c.apply(this,arguments)})},{key:"updateSubVideoConfig",value:(s=_asyncToGenerator(_regeneratorRuntime().mark((function e(t,r){var n,i,o,a,s;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if((a=this._findRemoteStreamByScreen(t,!1))&&a.hasSubscribed&&!((null==a||null===(n=a.attributes)||void 0===n||null===(i=n.videoDescriptions)||void 0===i?void 0:i.length)<=1)){e.next=3;break}return e.abrupt("return");case 3:return s=this._getSubLayer(r,a),a.originalStreamIndex=s.spatialLayer,e.abrupt("return",null===(o=this._mediaServerClient)||void 0===o?void 0:o.updateSubTrack(a,a.subMediaType,SubState.SUB,s));case 6:case"end":return e.stop()}}),e,this)}))),function(e,t){return s.apply(this,arguments)})},{key:"_getSubLayer",value:function(e,t){for(var r,n,i,o,a,s=null==t?void 0:t.attributes,c=s.videoDescriptions,u=s.subVideoDescriptions,l=Array.isArray(u)?u:c,d=-1,p=e.width*e.height,_=0;_<(null==l?void 0:l.length);_++){var f,h;if(p>=(null===(f=l[_])||void 0===f?void 0:f.width)*(null===(h=l[_])||void 0===h?void 0:h.height)){d=_;break}}var m=l[0];if(-1===d)m=l[d=l.length-1];else if(0!==d){var y=l[d-1].width*l[d-1].height,v=(y-p)/(y-l[d].width*l[d].height);m=v<.1?l[d-1]:l[d],d=v<.1?d-1:d}return a=null!==(r=null===(n=m)||void 0===n?void 0:n.sub_index)&&void 0!==r?r:-1,{spatialLayer:null!==(i=null===(o=m)||void 0===o?void 0:o.video_index)&&void 0!==i?i:d,spatialSubLayer:a}}},{key:"unsubscribe",value:(a=_asyncToGenerator(_regeneratorRuntime().mark((function e(t,r){return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return logger$6.print("unsubscribe","Invoke unsubscribe"),e.next=3,this._mediaServerClient.unsubscribe(t,r);case 3:case"end":return e.stop()}}),e,this)}))),function(e,t){return a.apply(this,arguments)})},{key:"leave",value:(o=_asyncToGenerator(_regeneratorRuntime().mark((function e(){var t,r,n,i,o,a,s=arguments;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=s.length>0&&void 0!==s[0]&&s[0],logger$6.print("leave","Invoke leave"),r=getServerNow(),e.prev=3,clearTimeout(this._reconnectTimer),n=_createForOfIteratorHelper(this._remoteStreams.values());try{for(n.s();!(i=n.n()).done;)o=i.value,Array.isArray(o)&&o.forEach((function(e){var t;null===(t=e.observer)||void 0===t||t.setLogin(!1)}))}catch(e){n.e(e)}finally{n.f()}return this._localStream&&(null===(a=this._localStream.observer)||void 0===a||a.setLogin(!1)),e.next=10,this._mediaServerClient.leave();case 10:this.destroy(),monitor.rtcLeaveRoom(0,"",getServerNow()-r),e.next=23;break;case 14:if(e.prev=14,e.t0=e.catch(3),e.t0 instanceof SDKError&&e.t0.code===ErrorCode.NOT_CONNECTED_YET&&this._joinRejectCallback&&this._joinRejectCallback(new Error(JoinroomReason.LEAVE_ROOM)),!t){e.next=21;break}throw e.t0;case 21:this.destroy();case 22:e.t0 instanceof Error&&monitor.rtcLeaveRoom(-1,e.t0.message,getServerNow()-r);case 23:case"end":return e.stop()}}),e,this,[[3,14]])}))),function(){return o.apply(this,arguments)})},{key:"setRemoteUserPriority",value:function(e,t){var r,n;null===(r=this.remoteStreams.get(e))||void 0===r||r.forEach((function(e){return e.setRemoteUserPriority(t)})),null===(n=this.userPriorityMap)||void 0===n||n.set(e,t)}},{key:"destroy",value:function(){logger$6.print("destroy","Invoke destroy"),this._destroyAndInitMediaServerClient(),this._roomInfo=void 0,this._remoteUsers=new Map;var e,t,r,n=_createForOfIteratorHelper(this._remoteStreams);try{for(n.s();!(e=n.n()).done;){var i=_slicedToArray(e.value,2)[1];Array.isArray(i)&&i.forEach((function(e){e&&e.clean()}))}}catch(e){n.e(e)}finally{n.f()}(this._remoteStreams=new Map,this._localStream)&&(null===(t=this._localStream)||void 0===t||t.clean(),this._localStream=void 0);this._localScreenStream&&(null===(r=this._localScreenStream)||void 0===r||r.clean(),this._localScreenStream=void 0);this._context=void 0,this._reconnectRecord=new ReconnectRecord,this._removeHandlerEventHandler(),clearTimeout(this._connectionLostTimer),this._userDuplicateLoginTimerMap.forEach((function(e){clearTimeout(e)})),this._userDuplicateLoginTimerMap.clear(),this._networkQualityManager.destroy(),this._videoSizeObserver.destroy(),this._subFallbackManager.destroy()}},{key:"updateToken",value:(i=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return logger$6.print("updateToken","Invoke updateToken"),this._roomInfo&&(this._roomInfo.token=t),e.next=4,this._mediaServerClient.updateToken(t);case 4:case"end":return e.stop()}}),e,this)}))),function(e){return i.apply(this,arguments)})},{key:"pauseAllSubscribedStream",value:(n=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){var r,n,i,o,a=this;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:r=[],n=_createForOfIteratorHelper(this._remoteStreams.values());try{for(n.s();!(i=n.n()).done;)o=i.value,Array.isArray(o)&&o.forEach((function(e){if(e.hasSubscribed){var n=a.updateSubTrack(e,t,SubState.UNSUB);n&&r.push(n)}}))}catch(e){n.e(e)}finally{n.f()}return e.abrupt("return",Promise.all(r));case 4:case"end":return e.stop()}}),e,this)}))),function(e){return n.apply(this,arguments)})},{key:"resumeAllSubscribedStream",value:(r=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){var r,n,i,o,a=this;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:r=[],n=_createForOfIteratorHelper(this._remoteStreams.values());try{for(n.s();!(i=n.n()).done;)o=i.value,Array.isArray(o)&&o.forEach((function(e){if(e.hasSubscribed&&e.hasSubscribed){var n=a.updateSubTrack(e,t,SubState.SUB);n&&r.push(n)}}))}catch(e){n.e(e)}finally{n.f()}return e.abrupt("return",Promise.all(r));case 4:case"end":return e.stop()}}),e,this)}))),function(e){return r.apply(this,arguments)})},{key:"sendUserMessage",value:function(e,t){var r;return null===(r=this._mediaServerClient)||void 0===r?void 0:r.sendUserMessage(e,t)}},{key:"setSessionId",value:function(){this._sessionId=v4(),commonStats.setStats({rtc_session_id:this._sessionId})}},{key:"sendRoomMessage",value:(t=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){var r,n,i,o,a=arguments;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(i=a.length>1&&void 0!==a[1]&&a[1],o={clientId:null===(r=this._roomInfo)||void 0===r?void 0:r.userInfo.userId,binary:i,message:""},!i){e.next=8;break}return e.next=5,Utils.ab2b64str(t);case 5:o.message=e.sent,e.next=9;break;case 8:o.message=t;case 9:return e.abrupt("return",null===(n=this._mediaServerClient)||void 0===n?void 0:n.sendRoomMessage(o));case 10:case"end":return e.stop()}}),e,this)}))),function(e){return t.apply(this,arguments)})},{key:"_destroyAndInitMediaServerClient",value:function(){logger$6.print("_destroyAndInitMediaServerClient()"),this._mediaServerClient&&(this._mediaServerClient.destroy(),this._removeHandlerEventHandler()),this._mediaServerClient=new MediaServerClient(this._context),this._addHandlerEventHandler()}},{key:"_onJoinSucc",value:function(e,t){var r,n=this;logger$6.print("JoinSuccess()"),this._serverConfig=e.config;var i=[],o=[],a=[],s=[];null===(r=e.clientsDetail)||void 0===r||r.forEach((function(t){if(t.attributes&&(t.attributes.serverMuteVideo&&n.safeEmit(RoomEvent.ON_VIDEO_STREAM_BANNED,{uid:t.clientId,banned:1===t.attributes.serverMuteVideo}),t.attributes.serverMuteAudio&&n.safeEmit(RoomEvent.ON_AUDIO_STREAM_BANNED,{uid:t.clientId,banned:1===t.attributes.serverMuteAudio})),t.clientId!==e.clientId){var r=n._remoteUsers.get(t.clientId);r?r._stillExist=!0:i.push(t)}}));var c,u=_createForOfIteratorHelper(this._remoteUsers.values());try{for(u.s();!(c=u.n()).done;){var l=c.value;l._stillExist||o.push({clientId:l.userId}),delete l._stillExist}}catch(e){u.e(e)}finally{u.f()}e.streams.forEach((function(e){var t=n._findRemoteStreamByScreen(e.clientId,e.screen);t?(t.stillExist=!0,t.streamId=e.streamId):s.push(e)}));var d,p=_createForOfIteratorHelper(this._remoteStreams.values());try{for(p.s();!(d=p.n()).done;){var _=d.value;Array.isArray(_)&&_.forEach((function(e){e.stillExist?delete e.stillExist:a.push({clientId:e.userId,streamId:e.streamId,message:RemoveStreamMessage.clientDisconnected})}))}}catch(e){p.e(e)}finally{p.f()}setTimeout((function(){o.forEach((function(e){return n._onUserDisconnection(e)})),i.forEach((function(e){return n._onUserConnection(e)})),a.forEach((function(e){return n._onRemoveStream(e)})),s.forEach((function(e){return n._onAddStream(e,!0,!1)})),t&&n._handleSendOrRecvStreamAfterReconnect()}))}},{key:"_handleSendOrRecvStreamAfterReconnect",value:function(){var e=this;this._localStream&&(this._localStream.clean(),this._mediaServerClient.publish(this._localStream).catch((function(e){}))),this._localScreenStream&&(this._localScreenStream.clean(),this._mediaServerClient.publish(this._localScreenStream).catch((function(e){})));var t,r=_createForOfIteratorHelper(this._remoteStreams.values());try{for(r.s();!(t=r.n()).done;){var n=t.value;Array.isArray(n)&&n.forEach(function(){var t=_asyncToGenerator(_regeneratorRuntime().mark((function t(r){return _regeneratorRuntime().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!r.hasSubscribed){t.next=15;break}return r.resetHasSubscribed(),t.prev=2,logger$6.print("start resubscribe ".concat(r.userId," with ").concat(r.subMediaType)),t.next=6,e._mediaServerClient.subscribe(r,r.subMediaType);case 6:logger$6.print("success resubscribe ".concat(r.userId," with ").concat(r.subMediaType)),e.safeEmit(RoomEvent.RESUBSCRIBE,{stream:r}),t.next=15;break;case 10:t.prev=10,t.t0=t.catch(2),logger$6.print("failed resubscribe ".concat(r.userId," with ").concat(r.subMediaType,", error:").concat(t.t0)),r.clean(),null==r||r.resetHasSubscribed();case 15:case"end":return t.stop()}}),t,null,[[2,10]])})));return function(e){return t.apply(this,arguments)}}())}}catch(e){r.e(e)}finally{r.f()}}},{key:"_findRemoteStream",value:function(e,t){var r=this._remoteStreams.get(e);return Array.isArray(r)?r.find((function(e){return e.streamId===t})):null}},{key:"_findRemoteStreamByScreen",value:function(e,t){var r=this._remoteStreams.get(e);return Array.isArray(r)?r.find((function(e){return e.isScreen===t})):null}},{key:"_onAddStream",value:function(e){var t,r=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];if(e.clientId!==(null===(t=this._roomInfo)||void 0===t?void 0:t.userInfo.userId)){var i=this._roomConfig,o=i.isAutoSubscribeAudio,a=i.isAutoSubscribeVideo,s=this._findRemoteStreamByScreen(e.clientId,e.screen);if(s&&s.streamId!==e.streamId){var c,u=null===(c=this._remoteStreams.get(e.clientId))||void 0===c?void 0:c.filter((function(e){return e.streamId!==s.streamId}));s.clean(),this._remoteStreams.set(e.clientId,u||[])}var l=this._findRemoteStream(e.clientId,e.streamId);if(l)l.attributes=e.attributes;else{var d;l=new RemoteStream(e.clientId,e.streamId,e.screen,e.attributes,null===(d=this.userPriorityMap)||void 0===d?void 0:d.get(e.clientId)),this._initStreamListeners(l);var p=this._remoteStreams.get(e.clientId);p?p.push(l):this._remoteStreams.set(e.clientId,[l])}if(this._mediaServerClient.handler&&(l.observer=new RecvFrameObserver(l,this._mediaServerClient.handler)),!l.isScreen&&a){var _,f,h,m,y,v,S,g;if(n&&l.hasVideo)if(l.attributes.extvideo)null===(_=l.observer)||void 0===_||_.setExternalVideoSource(!0),null===(f=l.observer)||void 0===f||f.setPushVideo(!0);else null===(h=l.observer)||void 0===h||h.setExternalVideoSource(!1),null===(m=l.observer)||void 0===m||m.setPublishVideo(!0);if(n&&l.hasAudio&&o&&!this._mediaServerClient.roomAttributes.multiChatMode)if(l.attributes.extaudio)null===(y=l.observer)||void 0===y||y.setExternalAudioSource(!0),null===(v=l.observer)||void 0===v||v.setPushAudio(!0);else null===(S=l.observer)||void 0===S||S.setExternalAudioSource(!1),null===(g=l.observer)||void 0===g||g.setPublishAudio(!0);if(!0===r&&!1===n){var E,T=this._roomConfig,b=T.isAutoSubscribeAudio,R=T.isAutoSubscribeVideo;null===(E=l.observer)||void 0===E||E.setLogin(!0,{audio:!!b,video:!!R})}}return r&&this.safeEmit(SignalEvent.ON_ADD_STREAM,{stream:l}),l}}},{key:"_onUserConnection",value:function(e){var t;if(e.clientId!==(null===(t=this._roomInfo)||void 0===t?void 0:t.userInfo.userId)){var r=this._userDuplicateLoginTimerMap.get(e.clientId);if("number"==typeof r)return this._userDuplicateLoginTimerMap.delete(e.clientId),void self.clearTimeout(r);var n={userId:e.clientId,extraInfo:e.attributes.extra_info};this._remoteUsers.set(e.clientId,_objectSpread2({},n)),this.safeEmit(SignalEvent.USER_CONNECTION,{userInfo:n}),e.attributes&&(e.attributes.serverMuteVideo&&this.safeEmit(RoomEvent.ON_VIDEO_STREAM_BANNED,{uid:e.clientId,banned:1===e.attributes.serverMuteVideo}),e.attributes.serverMuteAudio&&this.safeEmit(RoomEvent.ON_AUDIO_STREAM_BANNED,{uid:e.clientId,banned:1===e.attributes.serverMuteAudio}))}}},{key:"_onUserDisconnection",value:function(e){var t,r=this,n=e.clientId,i=e.tag,o=e.code;if(n)if(n===(null===(t=this.roomInfo)||void 0===t?void 0:t.userInfo.userId)){var a=null;i===UserDisconnectionTag.kickedByAdmin?a=ErrorCode.KICKED_OUT:i===UserDisconnectionTag.onUserTokenDidExpire?a=ErrorCode.TOKEN_EXPIRED:i===UserDisconnectionTag.userDuplicateLogin&&(a=ErrorCode.DUPLICATE_LOGIN),o===UserDisconnectionCode.roomDismissByAdmin&&(a=ErrorCode.ROOM_DISMISS),a&&this.safeEmit(RoomEvent.ON_ROOM_ERROR,{errorCode:a})}else{var s=UserOfflineReason.DROPPED;i===UserDisconnectionTag.userLeave?s=UserOfflineReason.QUIT:i===UserDisconnectionTag.kickedByAdmin?s=UserOfflineReason.KICKED_BY_ADMIN:i===UserDisconnectionTag.roleChanged&&(s=UserOfflineReason.SWITCH_TO_INVISIBLE);var c=function(){var e;r._remoteUsers.delete(n),null===(e=r._remoteStreams.get(n))||void 0===e||e.forEach((function(e){r._onRemoveStream({clientId:e.userId,streamId:e.streamId,message:"client disconnected"})})),r._remoteStreams.delete(n),r.safeEmit(RoomEvent.ON_USER_LEAVE,{userInfo:{userId:n},reason:s})};if(i===UserDisconnectionTag.userDuplicateLogin){var u=this._userDuplicateLoginTimerMap.get(n);null!=u||self.clearTimeout(u);var l=self.setTimeout(c,5e3);this._userDuplicateLoginTimerMap.set(n,l)}else c()}}},{key:"_onRemoveStream",value:function(e){var t,r=this;if(e.clientId!==(null===(t=this._roomInfo)||void 0===t?void 0:t.userInfo.userId)){var n=this._remoteStreams.get(e.clientId);if(n){var i=n.find((function(t){return t.streamId===e.streamId}));if(i){var o,a,s;if(null===(o=this._mediaServerClient)||void 0===o||o.handleRemoveStream(i,e).then((function(){if(null==i||!i._workaround_1_){var t=r._remoteStreams.get(e.clientId);if(!t)return;t=t.filter((function(t){return t.streamId!==e.streamId})),r._remoteStreams.set(e.clientId,t)}})).finally((function(){r.safeEmit(SignalEvent.ON_REMOVE_STREAM,{stream:i,reason:e.message})})),i.hasVideo)null===(a=i.observer)||void 0===a||a.setPublishVideo(!1);if(i.hasAudio&&!this._mediaServerClient.roomAttributes.multiChatMode)null===(s=i.observer)||void 0===s||s.setPublishAudio(!1)}}}}},{key:"_onUpdateUserAttributes",value:function(e){e.attributes&&(e.attributes.serverMuteVideo&&this.safeEmit(RoomEvent.ON_VIDEO_STREAM_BANNED,{uid:e.clientId,banned:1===e.attributes.serverMuteVideo}),e.attributes.serverMuteAudio&&this.safeEmit(RoomEvent.ON_AUDIO_STREAM_BANNED,{uid:e.clientId,banned:1===e.attributes.serverMuteAudio}))}},{key:"_onUpdateRoomAttributes",value:function(e){e.roomAttributes&&(this._mediaServerClient.roomAttributes=_objectSpread2(_objectSpread2({},this._mediaServerClient.roomAttributes),e.roomAttributes))}},{key:"_onUpdateStreamAttributes",value:function(e){var t=this._roomConfig,r=t.isAutoSubscribeAudio,n=t.isAutoSubscribeVideo,i=e.clientId,o=e.streamId,a=e.attributes,s=this._findRemoteStream(i,o);if(s){var c,u,l=s.attributes,d=_objectSpread2(_objectSpread2({},l),a),p=!1,_=d.localaudio!==l.localaudio,f=!1,h=!1,m=d.localvideo!==l.localvideo,y=!1,v=ExtendMediaType.NONE,S=ExtendMediaType.NONE;if(d.audiostream!==l.audiostream&&(p=d.localaudio,f=!!d.audiostream,d.audiostream?v|=MediaType.AUDIO:S|=MediaType.AUDIO),d.videostream!==l.videostream&&(h=d.localvideo,y=!!d.videostream,d.videostream?v|=MediaType.VIDEO:S|=MediaType.VIDEO),v&&this.safeEmit(RoomEvent.ON_USER_PUBLISH_STATE_CHANGE,{userId:i,mediaType:v,isScreen:s.isScreen,pubState:PubState.PUB,remoteStream:s}),S&&this.safeEmit(RoomEvent.ON_USER_PUBLISH_STATE_CHANGE,{userId:i,mediaType:S,isScreen:s.isScreen,pubState:PubState.UNPUB,remoteStream:s}),d.localaudio!==l.localaudio)if(d.localaudio&&r){var g,E,T,b;if(d.extaudio)null===(g=s.observer)||void 0===g||g.setExternalAudioSource(!0),null===(E=s.observer)||void 0===E||E.setPushAudio(!0);else null===(T=s.observer)||void 0===T||T.setExternalAudioSource(!1),null===(b=s.observer)||void 0===b||b.setEnableAudio(!0);this.safeEmit(RoomEvent.ON_USER_START_AUDIO_CAPTURE,{userId:i})}else{var R,I,$,A;if(d.extaudio)null===(R=s.observer)||void 0===R||R.setExternalAudioSource(!0),null===(I=s.observer)||void 0===I||I.setPushAudio(!1);else null===($=s.observer)||void 0===$||$.setExternalAudioSource(!1),null===(A=s.observer)||void 0===A||A.setEnableAudio(!1);!s.isScreen&&this.safeEmit(RoomEvent.ON_USER_STOP_AUDIO_CAPTURE,{userId:i})}if(d.localvideo!==l.localvideo)if(d.localvideo&&n){var C,O,P,k;if(d.extvideo)null===(C=s.observer)||void 0===C||C.setExternalVideoSource(!0),null===(O=s.observer)||void 0===O||O.setPushVideo(!0);else null===(P=s.observer)||void 0===P||P.setExternalVideoSource(!1),null===(k=s.observer)||void 0===k||k.setEnableVideo(!0);this.safeEmit(RoomEvent.ON_USER_START_VIDEO_CAPTURE,{userId:i})}else{var w,N,D,M;if(d.extvideo)null===(w=s.observer)||void 0===w||w.setExternalVideoSource(!0),null===(N=s.observer)||void 0===N||N.setPushVideo(!1);else null===(D=s.observer)||void 0===D||D.setExternalVideoSource(!1),null===(M=s.observer)||void 0===M||M.setEnableVideo(!1);!s.isScreen&&this.safeEmit(RoomEvent.ON_USER_STOP_VIDEO_CAPTURE,{userId:i})}if(p&&!_)null===(c=s.observer)||void 0===c||c.setRemoteUnmuteAudio(f);if(h&&!m)null===(u=s.observer)||void 0===u||u.setRemoteUnmuteVideo(y);s.attributes=d}}},{key:"_onPushTrack",value:function(e){var t=this,r=e.clientId,n=e.streamId,i=this._findRemoteStream(r,n);i||(i=this._onAddStream(e,!1,!1)),this._mediaServerClient.subscribe4pushTrack(i,e).then((function(){return t.safeEmit(RoomEvent.SUBSCRIBE_PUSH_TRACK,{stream:i})})).catch((function(e){logger$6.print("subscribe push track failed: ".concat(e))}))}},{key:"_onRemoveTrack",value:function(e){var t=this,r=e.clientId,n=e.streamId,i=e.message,o=this._findRemoteStream(r,n);o&&this._mediaServerClient.unsubscribe4removeTrack(o,i).then((function(){if(o._workaround_1_){var e,i=null===(e=t._remoteStreams.get(r))||void 0===e?void 0:e.filter((function(e){return e.streamId!==n}));t._remoteStreams.set(r,i||[])}t.safeEmit(RoomEvent.REMOVE_PUSH_TRACK,{stream:o})})).catch((function(e){logger$6.print("remove push track failed: ".concat(e))}))}},{key:"_nodeChange",value:function(e){var t,r=e.nodes,n=e.reason;sdkCache.clearAccessNode(null===(t=this._roomInfo)||void 0===t?void 0:t.appId),this._destroyAndInitMediaServerClient(),Array.isArray(r)&&r.length?this._getAccessNode=r[0]:this._getAccessFeedback=n,monitor.rtcNodeChange(0,JSON.stringify(e),JSON.stringify(n)),this._joinResolveCallback&&this._joinRejectCallback?this._join(this._joinResolveCallback,this._joinRejectCallback):this._reconnect()}},{key:"_reconnect",value:function(){var e=this;this._isReconnecting=!0;var t,r=_createForOfIteratorHelper(this._remoteStreams.values());try{for(r.s();!(t=r.n()).done;){var n=t.value;Array.isArray(n)&&n.forEach((function(e){return e.clean()}))}}catch(e){r.e(e)}finally{r.f()}monitor.rtcReconnect(1002,RtcreconnectMessage.PEERCONNECTION_RECONNECTING,this._roomInfo.userInfo.userId,RtcreconnectReconnectType.PEERCONNECTION),this._join((function(){monitor.rtcReconnected(RtcreconnectedMessage.PEERCONNECTION_RECONNECTED,RtcreconnectedReconnectType.PEERCONNECTION)}),(function(t){e._reconnectRecord.record(t),e._reconnectRecord.shouldReconnect?(logger$6.print("Reconnecting error, will reconnect after 3s",t),e._reconnectTimer=window.setTimeout(e._reconnect.bind(e),3e3)):(e.safeEmit(RoomEvent.RECONNECT_FAILED),e.destroy())}),!0)}},{key:"_handleAbnormalDisconnection",value:function(){logger$6.print("on ABNORMAL_DISCONNECTION"),this._destroyAndInitMediaServerClient(),navigator.onLine?this._reconnect():this._reconnectTimer=window.setTimeout(this._reconnect.bind(this),3e3)}},{key:"_onConnectionStateChange",value:function(e){var t,r=this;if(e.next===MediaConnectionState.DISCONNECTED)t=ConnectionState.CONNECTION_STATE_DISCONNECTED;else if(e.next===MediaConnectionState.CONNECTED)clearTimeout(this._connectionLostTimer),t=this._isReconnecting?ConnectionState.CONNECTION_STATE_RECONNECTED:ConnectionState.CONNECTION_STATE_CONNECTED;else{if(e.next!==MediaConnectionState.CONNECTING)return;t=this._isReconnecting?ConnectionState.CONNECTION_STATE_RECONNECTING:ConnectionState.CONNECTION_STATE_CONNECTING}e.prev===MediaConnectionState.CONNECTED&&e.next===MediaConnectionState.DISCONNECTED&&(this._connectionLostTimer=window.setTimeout((function(){r.safeEmit(StateEvent.ON_CONNECTION_STATE_CHANGE,{state:ConnectionState.CONNECTION_STATE_LOST})}),1e4)),this._networkQualityManager.setConnectionState(e.next),this.safeEmit(StateEvent.ON_CONNECTION_STATE_CHANGE,{state:t})}},{key:"_initStreamListeners",value:function(e){var t=this;e.on("ontrack",(function(e){e.track})),e.on("onSEIMessage",(function(r){var n;t.emit(RoomEvent.ON_SEI_MESSAGED_RECEIVED,{sei:r,remoteStreamKey:{userId:e.userId,roomId:null===(n=t._roomInfo)||void 0===n?void 0:n.roomId,streamIndex:e.isScreen?StreamIndex.STREAM_INDEX_SCREEN:StreamIndex.STREAM_INDEX_MAIN}})}))}},{key:"_onCustomMessage",value:function(e){this.safeEmit(SignalEvent.ON_CUSTOM_MESSAGE,e)}},{key:"_onUserMessageReceived",value:function(e){this.safeEmit(SignalEvent.USER_MESSAGE_RECEIVED,{userId:e.from,message:e.msg})}},{key:"_onUserBinaryMessageReceived",value:function(e){this.safeEmit(SignalEvent.USER_BINARY_MESSAGE_RECEIVED,{userId:e.from,message:e.msg})}},{key:"_onPostProcessingMessage",value:function(e){if(e.body){var t=e.body,r=t.error||0,n=StreamMixingEventType.START,i=["success","parameter error","subscription timeout","ffmpeg error","cdn error","publish error"];if("2.0"===t.protocol){switch(t.eventType){case"TranscodeStarted":0!==t.error&&(n=StreamMixingEventType.START_FAILED);break;case"TranscodeStateChanged":n=0!==t.error?StreamMixingEventType.START_FAILED:StreamMixingEventType.START_SUCCESS;break;case"TranscodeStopped":n=0!==t.error?StreamMixingEventType.STOP_FAILED:StreamMixingEventType.STOP_SUCCESS;break;case"TranscodeUpdated":n=0!==t.error?StreamMixingEventType.UPDATE_FAILED:StreamMixingEventType.UPDATE_SUCCESS}this.safeEmit(SignalEvent.POST_PROCESSING_MESSAGE,{code:r,protocol:t.protocol,error:t.error,eventType:n,message:i[r]})}this.safeEmit(SignalEvent.POST_PROCESSING_MESSAGE,{code:r,message:i[r],type:e.type})}}},{key:"_onUserTokenWillExpire",value:function(){this.safeEmit(SignalEvent.ON_USER_TOKEN_WILL_EXPIRE,null)}},{key:"_onSceneConfig",value:function(e){var t=e.multiSceneConfig,r=RoomProfileMap[this._roomConfig.roomProfileType][1];if(t){var n,i,o=t[r];if(o&&o.engine_BAC)null===(n=this._context)||void 0===n||n.audioProfileManager.updateEngineBAC(o.engine_BAC);if(o&&o.engine_ANM)null===(i=this._context)||void 0===i||i.audioProfileManager.updateEngineANM(o.engine_ANM)}}},{key:"_onStreamControlMessage",value:function(e){var t,r;e.type===StreamControlType.PushLimitWarn&&(null!==(t=this._localStream)&&void 0!==t&&t.pubAudio||null!==(r=this._localStream)&&void 0!==r&&r.pubVideo||this.unpublish())}},{key:"_onPublishOnDemand",value:function(e){var t,r,n,i,o;if(!1!==(null===(t=this._serverConfig)||void 0===t||null===(r=t.engine_VPM)||void 0===r||null===(n=r.ondemand)||void 0===n?void 0:n.enable)&&null!==(i=this._localStream)&&void 0!==i&&i.enableSimulcast&&null!==(o=this._localStream)&&void 0!==o&&o.videoTransceiver){var a,s,c=null===(a=this._localStream)||void 0===a?void 0:a.stream.id,u=null===(s=this._localStream)||void 0===s?void 0:s.videoTransceiver.sender,l=u.getParameters();if(Array.isArray(l.encodings)&&Array.isArray(e)){var d,p,_,f,h={};logger$6.print("_onPublishOnDemand","usedDescriptions: %o",e),e.forEach((function(e){var t;if(null!=e&&null!==(t=e.StreamIds)&&void 0!==t&&t.includes(c)){var r=null==e?void 0:e.Metadata.SubvideoIndex;h[r]=r}}));var m={};null===(d=this._localStream)||void 0===d||null===(p=d.subVideoDescriptions)||void 0===p||p.forEach((function(e){void 0!==h[e.sub_index]&&(m[e.video_index]=e)}));var y=(null===(_=u.track)||void 0===_||null===(f=_.getSettings())||void 0===f?void 0:f.height)||720,v=[];l.encodings=l.encodings.map((function(e){return e.rid&&(m[e.rid]?(e.active=!0,e.scaleResolutionDownBy=Math.max(y/m[e.rid].height,1),v.push({type:1,rid:e.rid,downBy:e.scaleResolutionDownBy})):(v.push({type:0,rid:e.rid}),e.active=!1)),e})),monitor.rtcInvokeStatus(JSON.stringify(v),0,"rscp",c,0)}u.setParameters(l)}}},{key:"_reportNetworkQuality",value:function(e,t){this._subFallbackManager.updateNetworkQuality(e,t),this.emit(RoomEvent.ON_NETWORK_QUALITY,e,t)}},{key:"_emitVideoSizeChange",value:function(e,t,r,n){var i;this.emit(RoomEvent.ON_REMOTE_VIDEO_SIZE_CHANGED,{roomId:null===(i=this.roomInfo)||void 0===i?void 0:i.roomId,userId:e,streamIndex:t?StreamIndex.STREAM_INDEX_SCREEN:StreamIndex.STREAM_INDEX_MAIN},{width:r,height:n})}},{key:"_emitSubscribeFallback",value:function(e){this.emit(RoomEvent.ON_SIMULCAST_SUBSCRIBE_FALLBACK,e)}}]),T}(),ReconnectRecord=function(){function e(){_classCallCheck(this,e),_defineProperty(this,"_all_201_count",void 0),_defineProperty(this,"_has_4xx",void 0),this._all_201_count=0,this._has_4xx=!1}return _createClass(e,[{key:"shouldReconnect",get:function(){return!(this._all_201_count>=3||this._has_4xx)}},{key:"record",value:function(e){var t=!1,r=!1;if(Array.isArray(e)){var n=0;e.map((function(e){var t,i,o;400<=(null===(t=e.error)||void 0===t?void 0:t.code)&&(null===(i=e.error)||void 0===i?void 0:i.code)<500&&(r=!0),201===(null===(o=e.error)||void 0===o?void 0:o.code)&&n++})),n===e.length&&(t=!0),t&&this._all_201_count++,r&&(this._has_4xx=!0)}}},{key:"clear",value:function(){this._all_201_count=0,this._has_4xx=!1}}]),e}(),createElement=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=document.createElement(e);return t.id&&(r.id=t.id),t.classList&&t.classList.forEach((function(e){r.classList.add(e)})),t.style&&Object.assign(r.style,t.style),t.attributes&&Object.entries(t.attributes).forEach((function(e){var t=_slicedToArray(e,2),n=t[0],i=t[1];"muted"===n?r.muted=!0:r.setAttribute(n,i)})),r},decorateElement=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return t.id&&(e.id=t.id),t.classList&&t.classList.forEach((function(t){e.classList.add(t)})),t.style&&Object.assign(e.style,t.style),t.attributes&&Object.entries(t.attributes).forEach((function(t){var r=_slicedToArray(t,2),n=r[0],i=r[1];e.setAttribute(n,i)})),e},logger$5=new Logger("Player",0),MEDIA_EVENTS=["play","playing","pause","ended","error","seeking","seeked","waiting","canplay","canplaythrough","durationchange","volumechange","loadedmetadata","loadeddata","loadstart","timeupdate"],AUDIO_ATTRIBUTES={playsinline:"","webkit-playsinline":""},VIDEO_ATTRIBUTES={playsinline:"","webkit-playsinline":"","x5-playsinline":"","x5-video-player-type":"h5","x-webkit-airplay":"allow",preload:"",muted:""},RecycleMedia=function(){function e(){_classCallCheck(this,e),_defineProperty(this,"videoCache",[]),_defineProperty(this,"audioCache",[])}return _createClass(e,[{key:"getOrCreate",value:function(e,t){var r="audio"===e?AUDIO_ATTRIBUTES:VIDEO_ATTRIBUTES;if("video"===e&&this.videoCache.length>0){var n=this.videoCache.pop();if(n)return decorateElement(n,{style:t,attributes:r}),n}else if("audio"===e&&this.audioCache.length>0){var i=this.audioCache.pop();if(i)return decorateElement(i,{style:t,attributes:r}),i}return createElement(e,{style:t,attributes:r})}},{key:"recycle",value:function(e){for(;e.attributes.length>0;)e.removeAttribute(e.attributes[0].name);e instanceof HTMLVideoElement?this.videoCache.push(e):this.audioCache.push(e)}}]),e}(),recycle=new RecycleMedia,VideoPlayer=function(e){_inherits(n,eventemitter3.exports.EventEmitter);var t,r=_createSuper(n);function n(e){var t;_classCallCheck(this,n),_defineProperty(_assertThisInitialized(t=r.call(this)),"_containerDom",void 0),_defineProperty(_assertThisInitialized(t),"_videoDom",void 0),_defineProperty(_assertThisInitialized(t),"__cumulativeTime",void 0),_defineProperty(_assertThisInitialized(t),"userId",void 0),_defineProperty(_assertThisInitialized(t),"renderMode",void 0),_defineProperty(_assertThisInitialized(t),"mirrorType",MirrorType.MIRROR_TYPE_NONE),_defineProperty(_assertThisInitialized(t),"isScreen",void 0),_defineProperty(_assertThisInitialized(t),"played",!1),_defineProperty(_assertThisInitialized(t),"_emitPlayFailed",!1),_defineProperty(_assertThisInitialized(t),"emitVideoEvent",(function(e){var r,n,i={type:"video",rawEvent:e,readyState:(null===(r=t._videoDom)||void 0===r?void 0:r.readyState)||0,userId:t.userId,eventName:e.type,currentTime:(null===(n=t._videoDom)||void 0===n?void 0:n.currentTime)||0,isScreen:t.isScreen};t.emit("playback_event",i)})),_defineProperty(_assertThisInitialized(t),"_internalPlay",(function(){var e;if(null!==(e=t._videoDom)&&void 0!==e&&e.paused){var r=t._videoDom.play();null!=r&&r.then&&r.catch((function(e){var r,n;t._emitPlayFailed||(t._emitPlayFailed=!0,monitor.rtcError("video autoplay failed, userId: ".concat(t.userId),-1e3),t.emit("playback_event",{type:"video",rawEvent:e,readyState:(null===(r=t._videoDom)||void 0===r?void 0:r.readyState)||0,userId:t.userId,eventName:"autoplay-error",currentTime:(null===(n=t._videoDom)||void 0===n?void 0:n.currentTime)||0}))}))}}));var i=e.renderDom,o=e.userId;t.renderMode=void 0!==e.renderMode?e.renderMode:VideoRenderMode.RENDER_MODE_FIT;var a="string"==typeof i?document.getElementById(i):i;if(!a)throw new SDKError(ErrorCode.CANT_FIND_DOM,"can't find dom");return t._containerDom=a,t.userId=o,t.isScreen=!!e.isScreen,t._initVideo(),t}return _createClass(n,[{key:"_initVideo",value:function(){this._videoDom||(this._videoDom=recycle.getOrCreate("video",{width:"100%",height:"100%"}),this._videoDom.id="".concat(this.userId,"_").concat(genUuid()),this.renderMode===VideoRenderMode.RENDER_MODE_FIT?this._videoDom.style.objectFit="contain":this._videoDom.style.objectFit="cover",this.mirror(this.mirrorType===MirrorType.MIRROR_TYPE_RENDER)),this._containerDom.appendChild(this._videoDom),this._initListeners()}},{key:"_initListeners",value:function(){var e=this;this._videoDom&&MEDIA_EVENTS.forEach((function(t){var r;null===(r=e._videoDom)||void 0===r||r.addEventListener(t,e.emitVideoEvent)}))}},{key:"_removeListeners",value:function(){var e=this;this._videoDom&&(MEDIA_EVENTS.forEach((function(t){var r;null===(r=e._videoDom)||void 0===r||r.removeEventListener(t,e.emitVideoEvent)})),this._videoDom.addEventListener("canplay",this._internalPlay),this._videoDom.addEventListener("loadeddata",this._internalPlay))}},{key:"_recordFrame",value:function(e){var t=this;this.on("playback_event",(function(r){var n,i=e.isScreen?1.5:.5;if("timeupdate"===r.eventName){if(e.isScreen,0===(null===(n=t._videoDom)||void 0===n?void 0:n.currentTime))return;if(void 0===t.__cumulativeTime)return void(t.__cumulativeTime=t._videoDom.currentTime);if(e.recordedVideoFrames||(e.recordedVideoFrames=[]),t._videoDom.currentTime>t.__cumulativeTime){var o=Math.floor(1e3*(t._videoDom.currentTime-t.__cumulativeTime)),a=t._videoDom.currentTime-t.__cumulativeTime>i;e.recordedVideoFrames.push({playTime:t._videoDom.currentTime,isStall:a,stallCount:a?1:0,stallDuration:o%2e3})}t.__cumulativeTime=t._videoDom.currentTime}}))}},{key:"playVideo",value:(t=_asyncToGenerator(_regeneratorRuntime().mark((function e(t,r){var n,i,o,a,s=this;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(o=this._videoDom,logger$5.print("playVideo","play video track: ".concat(this.userId)),!(o&&o.srcObject instanceof MediaStream&&o.srcObject.getTrackById(null===(n=t.getTrack())||void 0===n?void 0:n.id))){e.next=4;break}return e.abrupt("return");case 4:o||(this._initVideo(),o=this._videoDom),logger$5.print("playVideo","play video by dom: ".concat(null===(i=o)||void 0===i?void 0:i.id)),(a=new MediaStream).addTrack(t.getTrack()),o.srcObject=a,o&&!this._containerDom.contains(o)&&this._containerDom.appendChild(o),o.addEventListener("canplay",this._internalPlay),o.addEventListener("loadeddata",this._internalPlay),setTimeout((function(){return s._internalPlay()})),r&&this._recordFrame(r),this.played=!0;case 15:case"end":return e.stop()}}),e,this)}))),function(e,r){return t.apply(this,arguments)})},{key:"updateSrcObject",value:function(e){var t=e.getTrack();if(t&&this._videoDom){var r=new MediaStream;r.addTrack(t),this._videoDom.srcObject=r}}},{key:"manuallyPlay",value:function(){if(logger$5.print("Invoke VideoPlayer.manuallyPlay"),this._emitPlayFailed=!1,!this._videoDom)throw new SDKError(ErrorCode.INVALID_PARAMS,"Player not found");return this._videoDom.play()}},{key:"mirror",value:function(e){logger$5.print("mirror","".concat(this.userId," set mirror: ").concat(e)),this.mirrorType=e?MirrorType.MIRROR_TYPE_RENDER:MirrorType.MIRROR_TYPE_NONE,this._videoDom&&(this._videoDom.style.transform=e?"rotateY(180deg)":"")}},{key:"stop",value:function(){var e=this._containerDom;logger$5.print("stop","stop video track: ".concat(this.userId)),this._videoDom&&(this._videoDom.srcObject=null,e&&e.contains(this._videoDom)&&e.removeChild(this._videoDom)),this.__cumulativeTime=void 0,this.played=!1}},{key:"destroy",value:function(){logger$5.print("destroy","video player: ".concat(this.userId)),this.stop(),_get(_getPrototypeOf(n.prototype),"removeAllListeners",this).call(this),this._removeListeners(),this._videoDom&&(recycle.recycle(this._videoDom),delete this._videoDom)}},{key:"domElement",get:function(){return this._videoDom}}]),n}(),AudioPlayer=function(e){_inherits(i,eventemitter3.exports.EventEmitter);var t,r,n=_createSuper(i);function i(e){var t,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{divId:void 0,muted:!1},o=r.divId,a=r.muted;if(_classCallCheck(this,i),_defineProperty(_assertThisInitialized(t=n.call(this)),"_containerDom",void 0),_defineProperty(_assertThisInitialized(t),"_audioDom",void 0),_defineProperty(_assertThisInitialized(t),"_fakeAudioDom",void 0),_defineProperty(_assertThisInitialized(t),"userId",void 0),_defineProperty(_assertThisInitialized(t),"muted",!1),_defineProperty(_assertThisInitialized(t),"_emitPlayFailed",!1),_defineProperty(_assertThisInitialized(t),"played",!1),_defineProperty(_assertThisInitialized(t),"emitAudioEvent",(function(e){var r,n,i={type:"audio",rawEvent:e,readyState:(null===(r=t._audioDom)||void 0===r?void 0:r.readyState)||0,userId:t.userId,eventName:e.type,currentTime:(null===(n=t._audioDom)||void 0===n?void 0:n.currentTime)||0};t.emit("playback_event",i)})),_defineProperty(_assertThisInitialized(t),"_internalPlay",(function(){var e,r;if(reportRtcInvokeStatus("_internalPlay",{paused:null===(e=t._audioDom)||void 0===e?void 0:e.paused}),null!==(r=t._audioDom)&&void 0!==r&&r.paused)try{var n=t._audioDom.play();null!=n&&n.then&&n.catch((function(e){t._autoPlayError(e)})).then((function(){reportRtcInvokeStatus("_internalPlay successfully",{userId:t.userId})}))}catch(e){t._autoPlayError(e)}})),o){var s=document.getElementById(o);if(!s)throw new SDKError(ErrorCode.CANT_FIND_DOM,"can't find dom");t._containerDom=s}else t._containerDom=document.body;return t.userId=e,t.muted=a,t._initAudio(),t}return _createClass(i,[{key:"_initAudio",value:function(){this._audioDom||(this._audioDom=recycle.getOrCreate("audio",{display:"none"}),this._audioDom.volume=this.muted?0:1,this._audioDom.id="".concat(this.userId,"_").concat(genUuid()),this._containerDom.appendChild(this._audioDom)),this._initListeners()}},{key:"_initListeners",value:function(){var e=this;this._audioDom&&MEDIA_EVENTS.forEach((function(t){var r;null===(r=e._audioDom)||void 0===r||r.addEventListener(t,e.emitAudioEvent)}))}},{key:"_removeListeners",value:function(){var e=this;this._audioDom&&(MEDIA_EVENTS.forEach((function(t){var r;null===(r=e._audioDom)||void 0===r||r.removeEventListener(t,e.emitAudioEvent)})),this._audioDom.removeEventListener("canplay",this._internalPlay),this._audioDom.removeEventListener("loadeddata",this._internalPlay))}},{key:"playAudio",value:(r=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){var r,n,i,o,a,s=this;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(logger$5.print("playAudio","play audio track: ".concat(this.userId)),!((o=this._audioDom)&&o.srcObject instanceof MediaStream&&o.srcObject.getTrackById(null===(r=t.getTrack())||void 0===r?void 0:r.id))){e.next=4;break}return e.abrupt("return");case 4:o||(this._initAudio(),o=this._audioDom),(a=new MediaStream).addTrack(t.getTrack()),o.srcObject=a,null===(n=o)||void 0===n||n.addEventListener("canplay",this._internalPlay),null===(i=o)||void 0===i||i.addEventListener("loadeddata",this._internalPlay),setTimeout((function(){return s._internalPlay()})),this.played=!0;case 12:case"end":return e.stop()}}),e,this)}))),function(e){return r.apply(this,arguments)})},{key:"_autoPlayError",value:function(e){var t,r;this._emitPlayFailed||(this._emitPlayFailed=!0,monitor.rtcError("audio autoplay failed, userId: ".concat(this.userId,": ").concat(e.message),-1e3),this.emit("playback_event",{type:"audio",rawEvent:e,readyState:(null===(t=this._audioDom)||void 0===t?void 0:t.readyState)||0,userId:this.userId,eventName:"autoplay-error",currentTime:(null===(r=this._audioDom)||void 0===r?void 0:r.currentTime)||0}))}},{key:"manuallyPlay",value:function(){var e;if(logger$5.print("Invoke AudioPlayer.manuallyPlay"),this._emitPlayFailed=!1,!this._audioDom)throw new SDKError(ErrorCode.INVALID_PARAMS,"Player not found");this._audioDom.volume=1,null===(e=this._fakeAudioDom)||void 0===e||e.play();var t=this._audioDom.play();return null!=t&&t.then?t:Promise.resolve(t)}},{key:"setPlaybackDevice",value:(t=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return logger$5.print("setPlaybackDevice","setPlaybackDevice: ".concat(t)),e.next=3,detector.enumerateAudioPlaybackDevices();case 3:if(e.sent.map((function(e){return e.deviceId})).includes(t)&&this._audioDom&&this._audioDom.setSinkId){e.next=7;break}return e.abrupt("return");case 7:return e.next=9,this._audioDom.setSinkId(t);case 9:case"end":return e.stop()}}),e,this)}))),function(e){return t.apply(this,arguments)})},{key:"stop",value:function(){var e=this._containerDom;logger$5.print("stopAudio","stop audio track: ".concat(this.userId)),this._audioDom&&(this._audioDom.srcObject=null,e&&e.contains(this._audioDom)&&e.removeChild(this._audioDom)),this._fakeAudioDom&&(this._fakeAudioDom.srcObject=null,this._fakeAudioDom=void 0)}},{key:"domElement",get:function(){return this._audioDom}},{key:"destroy",value:function(){logger$5.print("destroy","audio player: ".concat(this.userId)),this.stop(),_get(_getPrototypeOf(i.prototype),"removeAllListeners",this).call(this),this._removeListeners(),this._audioDom&&(recycle.recycle(this._audioDom),delete this._audioDom)}}]),i}(),MessageStatisticsObserver=function(){function e(){_classCallCheck(this,e),_defineProperty(this,"_timer",void 0),_defineProperty(this,"userMessage",void 0),_defineProperty(this,"roomMessage",void 0),this.userMessage={},this.roomMessage={},this._setTimer()}return _createClass(e,[{key:"_setTimer",value:function(){var e=this;!function t(){e._reportAndgReset(),clearTimeout(e._timer),e._timer=setTimeout(t,1e4)}()}},{key:"_reportAndgReset",value:function(){this._report(),this._reset()}},{key:"_report",value:function(){var e=this;monitor.rtcMessageStatistics(Object.keys(this.userMessage).map((function(t){return e.userMessage[t]})),Object.keys(this.roomMessage).map((function(t){return e.roomMessage[t]})),"")}},{key:"_reset",value:function(){this.userMessage={},this.roomMessage={}}},{key:"_checkInitUserMessage",value:function(e,t){this.userMessage["".concat(t,"-").concat(e)]||(this.userMessage["".concat(t,"-").concat(e)]={dc_peer_user_id:e,dc_send_total:0,dc_recv_total:0,dc_send_ack:0,dc_send_fail:0,dc_cost_time:0,dc_cost_e2s:0,dc_cost_s2s:0,dc_least_time:1/0,dc_most_time:0,dc_cost_peer_s2e:0,dc_send_ack_100:0,dc_send_ack_200:0,dc_send_ack_400:0,dc_send_ack_1s:0,dc_message_type:t,dc_send_binary:0})}},{key:"_sendUserMessage",value:function(e,t,r){this._checkInitUserMessage(e,t),this.userMessage["".concat(t,"-").concat(e)].dc_send_total++,r&&this.userMessage["".concat(t,"-").concat(e)].dc_send_binary++}},{key:"_recvUserMessage",value:function(e,t){this._checkInitUserMessage(e,t),this.userMessage["".concat(t,"-").concat(e)].dc_recv_total++}},{key:"_sendUserFail",value:function(e,t){var r=this.userMessage["".concat(t,"-").concat(e)];r&&r.dc_send_fail++}},{key:"_sendUserAck",value:function(e,t,r,n,i){var o=this.userMessage["".concat(t,"-").concat(e)];o&&(o.dc_send_ack++,o.dc_cost_time+=r,o.dc_cost_s2s+=n||0,o.dc_cost_peer_s2e+=i,o.dc_cost_e2s+=r-(n||0)-i,r<=100?(o.dc_send_ack_100++,o.dc_send_ack_200++,o.dc_send_ack_400++,o.dc_send_ack_1s++):r<=200?(o.dc_send_ack_200++,o.dc_send_ack_400++,o.dc_send_ack_1s++):r<=400?(o.dc_send_ack_400++,o.dc_send_ack_1s++):r<=1e3&&o.dc_send_ack_1s++,r<o.dc_least_time&&(o.dc_least_time=r),r>o.dc_most_time&&(o.dc_most_time=r))}},{key:"sendRoomMessage",value:function(e,t){this.roomMessage[e]||(this.roomMessage[e]={dc_room_id:e,dc_send_total:0,dc_send_ack:0,dc_cost_time:0,dc_least_time:1/0,dc_most_time:0,dc_send_fail:0,dc_send_ack_100:0,dc_send_ack_200:0,dc_send_ack_400:0,dc_send_ack_1s:0,dc_send_binary:0}),this.roomMessage[e].dc_send_total++,t&&this.roomMessage[e].dc_send_binary++}},{key:"sendRoomFail",value:function(e){var t=this.roomMessage[e];t&&t.dc_send_fail++}},{key:"sendRoomAck",value:function(e,t){var r=this.roomMessage[e];r&&(r.dc_send_ack++,r.dc_cost_time+=t,t<r.dc_least_time&&(r.dc_least_time=t),t>r.dc_most_time&&(r.dc_most_time=t),t<=100?(r.dc_send_ack_100++,r.dc_send_ack_200++,r.dc_send_ack_400++,r.dc_send_ack_1s++):t<=200?(r.dc_send_ack_200++,r.dc_send_ack_400++,r.dc_send_ack_1s++):t<=400?(r.dc_send_ack_400++,r.dc_send_ack_1s++):t<=1e3&&r.dc_send_ack_1s++)}},{key:"sendP2PMessage",value:function(e,t){this._sendUserMessage(e,DcusermessageDcMessageType.P2P,t)}},{key:"recvP2PMessage",value:function(e){this._recvUserMessage(e,DcusermessageDcMessageType.P2P)}},{key:"sendP2PFail",value:function(e){this._sendUserFail(e,DcusermessageDcMessageType.P2P)}},{key:"sendP2PAck",value:function(e,t,r,n){this._sendUserAck(e,DcusermessageDcMessageType.P2P,t,r,n)}},{key:"sendP2POutRoomMessage",value:function(e,t){this._sendUserMessage(e,DcusermessageDcMessageType.P2P_OUTSIDE_ROOM,t)}},{key:"recvP2POutRoomMessage",value:function(e){this._recvUserMessage(e,DcusermessageDcMessageType.P2P_OUTSIDE_ROOM)}},{key:"sendP2POutRoomFail",value:function(e){this._sendUserFail(e,DcusermessageDcMessageType.P2P_OUTSIDE_ROOM)}},{key:"sendP2POutRoomAck",value:function(e,t,r,n){this._sendUserAck(e,DcusermessageDcMessageType.P2P_OUTSIDE_ROOM,t,r,n)}},{key:"sendP2serverMessage",value:function(e){this._sendUserMessage("",DcusermessageDcMessageType.P2SERVER,e)}},{key:"sendP2serverFail",value:function(){this._sendUserFail("",DcusermessageDcMessageType.P2SERVER)}},{key:"sendP2serveAck",value:function(e){this._sendUserAck("",DcusermessageDcMessageType.P2SERVER,e,0,0)}},{key:"countP2PMessage",value:function(e,t,r,n,i){this.sendP2PMessage(t,r),e?this.sendP2PAck(t,Date.now()-n,i.s2s_time,i.s2e_time):this.sendP2PFail(t)}},{key:"countRoomMessage",value:function(e,t,r,n){this.sendRoomMessage(t,r),e?this.sendRoomAck(t,Date.now()-n):this.sendRoomFail(t)}},{key:"countUserMessageOutsideRoom",value:function(e,t,r,n,i){this.sendP2POutRoomMessage(t,r),e?this.sendP2POutRoomAck(t,Date.now()-n,i.s2s_time,i.s2e_time):this.sendP2POutRoomFail(t)}},{key:"countServerMessage",value:function(e,t,r){this.sendP2serverMessage(t),e?this.sendP2serveAck(Date.now()-r):this.sendP2serverFail()}},{key:"destroy",value:function(){this._reset(),clearTimeout(this._timer)}}]),e}(),freeGlobal="object"==typeof global&&global&&global.Object===Object&&global,freeGlobal$1=freeGlobal,freeSelf="object"==typeof self&&self&&self.Object===Object&&self,root=freeGlobal$1||freeSelf||Function("return this")(),root$1=root,Symbol$1=root$1.Symbol,Symbol$2=Symbol$1,objectProto$8=Object.prototype,hasOwnProperty$6=objectProto$8.hasOwnProperty,nativeObjectToString$1=objectProto$8.toString,symToStringTag$1=Symbol$2?Symbol$2.toStringTag:void 0;function getRawTag(e){var t=hasOwnProperty$6.call(e,symToStringTag$1),r=e[symToStringTag$1];try{e[symToStringTag$1]=void 0;var n=!0}catch(e){}var i=nativeObjectToString$1.call(e);return n&&(t?e[symToStringTag$1]=r:delete e[symToStringTag$1]),i}var objectProto$7=Object.prototype,nativeObjectToString=objectProto$7.toString;function objectToString(e){return nativeObjectToString.call(e)}var nullTag="[object Null]",undefinedTag="[object Undefined]",symToStringTag=Symbol$2?Symbol$2.toStringTag:void 0;function baseGetTag(e){return null==e?void 0===e?undefinedTag:nullTag:symToStringTag&&symToStringTag in Object(e)?getRawTag(e):objectToString(e)}function isObjectLike(e){return null!=e&&"object"==typeof e}function arrayMap(e,t){for(var r=-1,n=null==e?0:e.length,i=Array(n);++r<n;)i[r]=t(e[r],r,e);return i}var isArray=Array.isArray,isArray$1=isArray;function isObject$1(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)}function identity(e){return e}var asyncTag="[object AsyncFunction]",funcTag$1="[object Function]",genTag="[object GeneratorFunction]",proxyTag="[object Proxy]";function isFunction(e){if(!isObject$1(e))return!1;var t=baseGetTag(e);return t==funcTag$1||t==genTag||t==asyncTag||t==proxyTag}var coreJsData=root$1["__core-js_shared__"],coreJsData$1=coreJsData,maskSrcKey=function(){var e=/[^.]+$/.exec(coreJsData$1&&coreJsData$1.keys&&coreJsData$1.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""}();function isMasked(e){return!!maskSrcKey&&maskSrcKey in e}var funcProto$1=Function.prototype,funcToString$1=funcProto$1.toString;function toSource(e){if(null!=e){try{return funcToString$1.call(e)}catch(e){}try{return e+""}catch(e){}}return""}var reRegExpChar=/[\\^$.*+?()[\]{}|]/g,reIsHostCtor=/^\[object .+?Constructor\]$/,funcProto=Function.prototype,objectProto$6=Object.prototype,funcToString=funcProto.toString,hasOwnProperty$5=objectProto$6.hasOwnProperty,reIsNative=RegExp("^"+funcToString.call(hasOwnProperty$5).replace(reRegExpChar,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function baseIsNative(e){return!(!isObject$1(e)||isMasked(e))&&(isFunction(e)?reIsNative:reIsHostCtor).test(toSource(e))}function getValue(e,t){return null==e?void 0:e[t]}function getNative(e,t){var r=getValue(e,t);return baseIsNative(r)?r:void 0}function apply(e,t,r){switch(r.length){case 0:return e.call(t);case 1:return e.call(t,r[0]);case 2:return e.call(t,r[0],r[1]);case 3:return e.call(t,r[0],r[1],r[2])}return e.apply(t,r)}var HOT_COUNT=800,HOT_SPAN=16,nativeNow=Date.now;function shortOut(e){var t=0,r=0;return function(){var n=nativeNow(),i=HOT_SPAN-(n-r);if(r=n,i>0){if(++t>=HOT_COUNT)return arguments[0]}else t=0;return e.apply(void 0,arguments)}}function constant(e){return function(){return e}}var defineProperty=function(){try{var e=getNative(Object,"defineProperty");return e({},"",{}),e}catch(e){}}(),defineProperty$1=defineProperty,baseSetToString=defineProperty$1?function(e,t){return defineProperty$1(e,"toString",{configurable:!0,enumerable:!1,value:constant(t),writable:!0})}:identity,baseSetToString$1=baseSetToString,setToString=shortOut(baseSetToString$1),setToString$1=setToString,MAX_SAFE_INTEGER$1=9007199254740991,reIsUint=/^(?:0|[1-9]\d*)$/;function isIndex(e,t){var r=typeof e;return!!(t=null==t?MAX_SAFE_INTEGER$1:t)&&("number"==r||"symbol"!=r&&reIsUint.test(e))&&e>-1&&e%1==0&&e<t}function baseAssignValue(e,t,r){"__proto__"==t&&defineProperty$1?defineProperty$1(e,t,{configurable:!0,enumerable:!0,value:r,writable:!0}):e[t]=r}function eq(e,t){return e===t||e!=e&&t!=t}var objectProto$5=Object.prototype,hasOwnProperty$4=objectProto$5.hasOwnProperty;function assignValue(e,t,r){var n=e[t];hasOwnProperty$4.call(e,t)&&eq(n,r)&&(void 0!==r||t in e)||baseAssignValue(e,t,r)}function copyObject(e,t,r,n){var i=!r;r||(r={});for(var o=-1,a=t.length;++o<a;){var s=t[o],c=n?n(r[s],e[s],s,r,e):void 0;void 0===c&&(c=e[s]),i?baseAssignValue(r,s,c):assignValue(r,s,c)}return r}var nativeMax=Math.max;function overRest(e,t,r){return t=nativeMax(void 0===t?e.length-1:t,0),function(){for(var n=arguments,i=-1,o=nativeMax(n.length-t,0),a=Array(o);++i<o;)a[i]=n[t+i];i=-1;for(var s=Array(t+1);++i<t;)s[i]=n[i];return s[t]=r(a),apply(e,this,s)}}function baseRest(e,t){return setToString$1(overRest(e,t,identity),e+"")}var MAX_SAFE_INTEGER=9007199254740991;function isLength(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=MAX_SAFE_INTEGER}function isArrayLike(e){return null!=e&&isLength(e.length)&&!isFunction(e)}function isIterateeCall(e,t,r){if(!isObject$1(r))return!1;var n=typeof t;return!!("number"==n?isArrayLike(r)&&isIndex(t,r.length):"string"==n&&t in r)&&eq(r[t],e)}function createAssigner(e){return baseRest((function(t,r){var n=-1,i=r.length,o=i>1?r[i-1]:void 0,a=i>2?r[2]:void 0;for(o=e.length>3&&"function"==typeof o?(i--,o):void 0,a&&isIterateeCall(r[0],r[1],a)&&(o=i<3?void 0:o,i=1),t=Object(t);++n<i;){var s=r[n];s&&e(t,s,n,o)}return t}))}var objectProto$4=Object.prototype;function isPrototype(e){var t=e&&e.constructor;return e===("function"==typeof t&&t.prototype||objectProto$4)}function baseTimes(e,t){for(var r=-1,n=Array(e);++r<e;)n[r]=t(r);return n}var argsTag$1="[object Arguments]";function baseIsArguments(e){return isObjectLike(e)&&baseGetTag(e)==argsTag$1}var objectProto$3=Object.prototype,hasOwnProperty$3=objectProto$3.hasOwnProperty,propertyIsEnumerable=objectProto$3.propertyIsEnumerable,isArguments=baseIsArguments(function(){return arguments}())?baseIsArguments:function(e){return isObjectLike(e)&&hasOwnProperty$3.call(e,"callee")&&!propertyIsEnumerable.call(e,"callee")},isArguments$1=isArguments;function stubFalse(){return!1}var freeExports$1="object"==typeof exports&&exports&&!exports.nodeType&&exports,freeModule$1=freeExports$1&&"object"==typeof module&&module&&!module.nodeType&&module,moduleExports$1=freeModule$1&&freeModule$1.exports===freeExports$1,Buffer=moduleExports$1?root$1.Buffer:void 0,nativeIsBuffer=Buffer?Buffer.isBuffer:void 0,isBuffer=nativeIsBuffer||stubFalse,isBuffer$1=isBuffer,argsTag="[object Arguments]",arrayTag="[object Array]",boolTag="[object Boolean]",dateTag="[object Date]",errorTag="[object Error]",funcTag="[object Function]",mapTag="[object Map]",numberTag="[object Number]",objectTag="[object Object]",regexpTag="[object RegExp]",setTag="[object Set]",stringTag="[object String]",weakMapTag="[object WeakMap]",arrayBufferTag="[object ArrayBuffer]",dataViewTag="[object DataView]",float32Tag="[object Float32Array]",float64Tag="[object Float64Array]",int8Tag="[object Int8Array]",int16Tag="[object Int16Array]",int32Tag="[object Int32Array]",uint8Tag="[object Uint8Array]",uint8ClampedTag="[object Uint8ClampedArray]",uint16Tag="[object Uint16Array]",uint32Tag="[object Uint32Array]",typedArrayTags={};function baseIsTypedArray(e){return isObjectLike(e)&&isLength(e.length)&&!!typedArrayTags[baseGetTag(e)]}function baseUnary(e){return function(t){return e(t)}}typedArrayTags[float32Tag]=typedArrayTags[float64Tag]=typedArrayTags[int8Tag]=typedArrayTags[int16Tag]=typedArrayTags[int32Tag]=typedArrayTags[uint8Tag]=typedArrayTags[uint8ClampedTag]=typedArrayTags[uint16Tag]=typedArrayTags[uint32Tag]=!0,typedArrayTags[argsTag]=typedArrayTags[arrayTag]=typedArrayTags[arrayBufferTag]=typedArrayTags[boolTag]=typedArrayTags[dataViewTag]=typedArrayTags[dateTag]=typedArrayTags[errorTag]=typedArrayTags[funcTag]=typedArrayTags[mapTag]=typedArrayTags[numberTag]=typedArrayTags[objectTag]=typedArrayTags[regexpTag]=typedArrayTags[setTag]=typedArrayTags[stringTag]=typedArrayTags[weakMapTag]=!1;var freeExports="object"==typeof exports&&exports&&!exports.nodeType&&exports,freeModule=freeExports&&"object"==typeof module&&module&&!module.nodeType&&module,moduleExports=freeModule&&freeModule.exports===freeExports,freeProcess=moduleExports&&freeGlobal$1.process,nodeUtil=function(){try{var e=freeModule&&freeModule.require&&freeModule.require("util").types;return e||freeProcess&&freeProcess.binding&&freeProcess.binding("util")}catch(e){}}(),nodeUtil$1=nodeUtil,nodeIsTypedArray=nodeUtil&&nodeUtil.isTypedArray,isTypedArray=nodeIsTypedArray?baseUnary(nodeIsTypedArray):baseIsTypedArray,isTypedArray$1=isTypedArray,objectProto$2=Object.prototype,hasOwnProperty$2=objectProto$2.hasOwnProperty;function arrayLikeKeys(e,t){var r=isArray$1(e),n=!r&&isArguments$1(e),i=!r&&!n&&isBuffer$1(e),o=!r&&!n&&!i&&isTypedArray$1(e),a=r||n||i||o,s=a?baseTimes(e.length,String):[],c=s.length;for(var u in e)!t&&!hasOwnProperty$2.call(e,u)||a&&("length"==u||i&&("offset"==u||"parent"==u)||o&&("buffer"==u||"byteLength"==u||"byteOffset"==u)||isIndex(u,c))||s.push(u);return s}function overArg(e,t){return function(r){return e(t(r))}}var nativeKeys=overArg(Object.keys,Object),nativeKeys$1=nativeKeys,objectProto$1=Object.prototype,hasOwnProperty$1=objectProto$1.hasOwnProperty;function baseKeys(e){if(!isPrototype(e))return nativeKeys$1(e);var t=[];for(var r in Object(e))hasOwnProperty$1.call(e,r)&&"constructor"!=r&&t.push(r);return t}function keys(e){return isArrayLike(e)?arrayLikeKeys(e):baseKeys(e)}function nativeKeysIn(e){var t=[];if(null!=e)for(var r in Object(e))t.push(r);return t}var objectProto=Object.prototype,hasOwnProperty=objectProto.hasOwnProperty;function baseKeysIn(e){if(!isObject$1(e))return nativeKeysIn(e);var t=isPrototype(e),r=[];for(var n in e)("constructor"!=n||!t&&hasOwnProperty.call(e,n))&&r.push(n);return r}function keysIn(e){return isArrayLike(e)?arrayLikeKeys(e,!0):baseKeysIn(e)}var assignIn=createAssigner((function(e,t){copyObject(t,keysIn(t),e)})),assignIn$1=assignIn;function baseValues(e,t){return arrayMap(t,(function(t){return e[t]}))}function values(e){return null==e?[]:baseValues(e,keys(e))}var fails=fails$U,wellKnownSymbol$1=wellKnownSymbol$u,IS_PURE=isPure,ITERATOR$1=wellKnownSymbol$1("iterator"),urlConstructorDetection=!fails((function(){var e=new URL("b?a=1&b=2&c=3","http://a"),t=e.searchParams,r="";return e.pathname="c%20d",t.forEach((function(e,n){t.delete("b"),r+=n+e})),IS_PURE&&!e.toJSON||!t.sort||"http://a/c%20d?a=1&c=3"!==e.href||"3"!==t.get("c")||"a=1"!==String(new URLSearchParams("?a=1"))||!t[ITERATOR$1]||"a"!==new URL("https://a@b").username||"b"!==new URLSearchParams(new URLSearchParams("a=b")).get("a")||"xn--e1aybc"!==new URL("http://тест").host||"#%D0%B1"!==new URL("http://a#б").hash||"a1c3"!==r||"x"!==new URL("http://x",void 0).host})),uncurryThis$2=functionUncurryThis,maxInt=2147483647,base=36,tMin=1,tMax=26,skew=38,damp=700,initialBias=72,initialN=128,delimiter="-",regexNonASCII=/[^\0-\u007E]/,regexSeparators=/[.\u3002\uFF0E\uFF61]/g,OVERFLOW_ERROR="Overflow: input needs wider integers to process",baseMinusTMin=base-tMin,$RangeError=RangeError,exec$1=uncurryThis$2(regexSeparators.exec),floor$1=Math.floor,fromCharCode=String.fromCharCode,charCodeAt=uncurryThis$2("".charCodeAt),join$2=uncurryThis$2([].join),push$2=uncurryThis$2([].push),replace$2=uncurryThis$2("".replace),split$2=uncurryThis$2("".split),toLowerCase$1=uncurryThis$2("".toLowerCase),ucs2decode=function(e){for(var t=[],r=0,n=e.length;r<n;){var i=charCodeAt(e,r++);if(i>=55296&&i<=56319&&r<n){var o=charCodeAt(e,r++);56320==(64512&o)?push$2(t,((1023&i)<<10)+(1023&o)+65536):(push$2(t,i),r--)}else push$2(t,i)}return t},digitToBasic=function(e){return e+22+75*(e<26)},adapt=function(e,t,r){var n=0;for(e=r?floor$1(e/damp):e>>1,e+=floor$1(e/t);e>baseMinusTMin*tMax>>1;)e=floor$1(e/baseMinusTMin),n+=base;return floor$1(n+(baseMinusTMin+1)*e/(e+skew))},encode=function(e){var t,r,n=[],i=(e=ucs2decode(e)).length,o=initialN,a=0,s=initialBias;for(t=0;t<e.length;t++)(r=e[t])<128&&push$2(n,fromCharCode(r));var c=n.length,u=c;for(c&&push$2(n,delimiter);u<i;){var l=maxInt;for(t=0;t<e.length;t++)(r=e[t])>=o&&r<l&&(l=r);var d=u+1;if(l-o>floor$1((maxInt-a)/d))throw $RangeError(OVERFLOW_ERROR);for(a+=(l-o)*d,o=l,t=0;t<e.length;t++){if((r=e[t])<o&&++a>maxInt)throw $RangeError(OVERFLOW_ERROR);if(r==o){for(var p=a,_=base;;){var f=_<=s?tMin:_>=s+tMax?tMax:_-s;if(p<f)break;var h=p-f,m=base-f;push$2(n,fromCharCode(digitToBasic(f+h%m))),p=floor$1(h/m),_+=base}push$2(n,fromCharCode(digitToBasic(p))),s=adapt(a,d,u==c),a=0,u++}}a++,o++}return join$2(n,"")},stringPunycodeToAscii=function(e){var t,r,n=[],i=split$2(replace$2(toLowerCase$1(e),regexSeparators,"."),".");for(t=0;t<i.length;t++)r=i[t],push$2(n,exec$1(regexNonASCII,r)?"xn--"+encode(r):r);return join$2(n,".")},$$1=_export,global$2=global$K,call=functionCall,uncurryThis$1=functionUncurryThis,DESCRIPTORS$1=descriptors,USE_NATIVE_URL$1=urlConstructorDetection,defineBuiltIn$1=defineBuiltIn$j,defineBuiltIns=defineBuiltIns$5,setToStringTag$1=setToStringTag$a,createIteratorConstructor=iteratorCreateConstructor,InternalStateModule$1=internalState,anInstance$1=anInstance$a,isCallable=isCallable$t,hasOwn$1=hasOwnProperty_1,bind$1=functionBindContext,classof=classof$i,anObject=anObject$q,isObject=isObject$s,$toString$1=toString$m,create=objectCreate,createPropertyDescriptor=createPropertyDescriptor$b,getIterator=getIterator$4,getIteratorMethod=getIteratorMethod$5,validateArgumentsLength$1=validateArgumentsLength$3,wellKnownSymbol=wellKnownSymbol$u,arraySort=arraySort$1,ITERATOR=wellKnownSymbol("iterator"),URL_SEARCH_PARAMS="URLSearchParams",URL_SEARCH_PARAMS_ITERATOR=URL_SEARCH_PARAMS+"Iterator",setInternalState$1=InternalStateModule$1.set,getInternalParamsState=InternalStateModule$1.getterFor(URL_SEARCH_PARAMS),getInternalIteratorState=InternalStateModule$1.getterFor(URL_SEARCH_PARAMS_ITERATOR),getOwnPropertyDescriptor=Object.getOwnPropertyDescriptor,safeGetBuiltIn=function(e){if(!DESCRIPTORS$1)return global$2[e];var t=getOwnPropertyDescriptor(global$2,e);return t&&t.value},nativeFetch=safeGetBuiltIn("fetch"),NativeRequest=safeGetBuiltIn("Request"),Headers=safeGetBuiltIn("Headers"),RequestPrototype=NativeRequest&&NativeRequest.prototype,HeadersPrototype=Headers&&Headers.prototype,RegExp$1=global$2.RegExp,TypeError$2=global$2.TypeError,decodeURIComponent=global$2.decodeURIComponent,encodeURIComponent$1=global$2.encodeURIComponent,charAt$1=uncurryThis$1("".charAt),join$1=uncurryThis$1([].join),push$1=uncurryThis$1([].push),replace$1=uncurryThis$1("".replace),shift$1=uncurryThis$1([].shift),splice=uncurryThis$1([].splice),split$1=uncurryThis$1("".split),stringSlice$1=uncurryThis$1("".slice),plus=/\+/g,sequences=Array(4),percentSequence=function(e){return sequences[e-1]||(sequences[e-1]=RegExp$1("((?:%[\\da-f]{2}){"+e+"})","gi"))},percentDecode=function(e){try{return decodeURIComponent(e)}catch(t){return e}},deserialize=function(e){var t=replace$1(e,plus," "),r=4;try{return decodeURIComponent(t)}catch(e){for(;r;)t=replace$1(t,percentSequence(r--),percentDecode);return t}},find=/[!'()~]|%20/g,replacements={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+"},replacer=function(e){return replacements[e]},serialize=function(e){return replace$1(encodeURIComponent$1(e),find,replacer)},URLSearchParamsIterator=createIteratorConstructor((function(e,t){setInternalState$1(this,{type:URL_SEARCH_PARAMS_ITERATOR,iterator:getIterator(getInternalParamsState(e).entries),kind:t})}),"Iterator",(function(){var e=getInternalIteratorState(this),t=e.kind,r=e.iterator.next(),n=r.value;return r.done||(r.value="keys"===t?n.key:"values"===t?n.value:[n.key,n.value]),r}),!0),URLSearchParamsState=function(e){this.entries=[],this.url=null,void 0!==e&&(isObject(e)?this.parseObject(e):this.parseQuery("string"==typeof e?"?"===charAt$1(e,0)?stringSlice$1(e,1):e:$toString$1(e)))};URLSearchParamsState.prototype={type:URL_SEARCH_PARAMS,bindURL:function(e){this.url=e,this.update()},parseObject:function(e){var t,r,n,i,o,a,s,c=getIteratorMethod(e);if(c)for(r=(t=getIterator(e,c)).next;!(n=call(r,t)).done;){if(o=(i=getIterator(anObject(n.value))).next,(a=call(o,i)).done||(s=call(o,i)).done||!call(o,i).done)throw TypeError$2("Expected sequence with length 2");push$1(this.entries,{key:$toString$1(a.value),value:$toString$1(s.value)})}else for(var u in e)hasOwn$1(e,u)&&push$1(this.entries,{key:u,value:$toString$1(e[u])})},parseQuery:function(e){if(e)for(var t,r,n=split$1(e,"&"),i=0;i<n.length;)(t=n[i++]).length&&(r=split$1(t,"="),push$1(this.entries,{key:deserialize(shift$1(r)),value:deserialize(join$1(r,"="))}))},serialize:function(){for(var e,t=this.entries,r=[],n=0;n<t.length;)e=t[n++],push$1(r,serialize(e.key)+"="+serialize(e.value));return join$1(r,"&")},update:function(){this.entries.length=0,this.parseQuery(this.url.query)},updateURL:function(){this.url&&this.url.update()}};var URLSearchParamsConstructor=function(){anInstance$1(this,URLSearchParamsPrototype);var e=arguments.length>0?arguments[0]:void 0;setInternalState$1(this,new URLSearchParamsState(e))},URLSearchParamsPrototype=URLSearchParamsConstructor.prototype;if(defineBuiltIns(URLSearchParamsPrototype,{append:function(e,t){validateArgumentsLength$1(arguments.length,2);var r=getInternalParamsState(this);push$1(r.entries,{key:$toString$1(e),value:$toString$1(t)}),r.updateURL()},delete:function(e){validateArgumentsLength$1(arguments.length,1);for(var t=getInternalParamsState(this),r=t.entries,n=$toString$1(e),i=0;i<r.length;)r[i].key===n?splice(r,i,1):i++;t.updateURL()},get:function(e){validateArgumentsLength$1(arguments.length,1);for(var t=getInternalParamsState(this).entries,r=$toString$1(e),n=0;n<t.length;n++)if(t[n].key===r)return t[n].value;return null},getAll:function(e){validateArgumentsLength$1(arguments.length,1);for(var t=getInternalParamsState(this).entries,r=$toString$1(e),n=[],i=0;i<t.length;i++)t[i].key===r&&push$1(n,t[i].value);return n},has:function(e){validateArgumentsLength$1(arguments.length,1);for(var t=getInternalParamsState(this).entries,r=$toString$1(e),n=0;n<t.length;)if(t[n++].key===r)return!0;return!1},set:function(e,t){validateArgumentsLength$1(arguments.length,1);for(var r,n=getInternalParamsState(this),i=n.entries,o=!1,a=$toString$1(e),s=$toString$1(t),c=0;c<i.length;c++)(r=i[c]).key===a&&(o?splice(i,c--,1):(o=!0,r.value=s));o||push$1(i,{key:a,value:s}),n.updateURL()},sort:function(){var e=getInternalParamsState(this);arraySort(e.entries,(function(e,t){return e.key>t.key?1:-1})),e.updateURL()},forEach:function(e){for(var t,r=getInternalParamsState(this).entries,n=bind$1(e,arguments.length>1?arguments[1]:void 0),i=0;i<r.length;)n((t=r[i++]).value,t.key,this)},keys:function(){return new URLSearchParamsIterator(this,"keys")},values:function(){return new URLSearchParamsIterator(this,"values")},entries:function(){return new URLSearchParamsIterator(this,"entries")}},{enumerable:!0}),defineBuiltIn$1(URLSearchParamsPrototype,ITERATOR,URLSearchParamsPrototype.entries,{name:"entries"}),defineBuiltIn$1(URLSearchParamsPrototype,"toString",(function(){return getInternalParamsState(this).serialize()}),{enumerable:!0}),setToStringTag$1(URLSearchParamsConstructor,URL_SEARCH_PARAMS),$$1({global:!0,constructor:!0,forced:!USE_NATIVE_URL$1},{URLSearchParams:URLSearchParamsConstructor}),!USE_NATIVE_URL$1&&isCallable(Headers)){var headersHas=uncurryThis$1(HeadersPrototype.has),headersSet=uncurryThis$1(HeadersPrototype.set),wrapRequestOptions=function(e){if(isObject(e)){var t,r=e.body;if(classof(r)===URL_SEARCH_PARAMS)return t=e.headers?new Headers(e.headers):new Headers,headersHas(t,"content-type")||headersSet(t,"content-type","application/x-www-form-urlencoded;charset=UTF-8"),create(e,{body:createPropertyDescriptor(0,$toString$1(r)),headers:createPropertyDescriptor(0,t)})}return e};if(isCallable(nativeFetch)&&$$1({global:!0,enumerable:!0,dontCallGetSet:!0,forced:!0},{fetch:function(e){return nativeFetch(e,arguments.length>1?wrapRequestOptions(arguments[1]):{})}}),isCallable(NativeRequest)){var RequestConstructor=function(e){return anInstance$1(this,RequestPrototype),new NativeRequest(e,arguments.length>1?wrapRequestOptions(arguments[1]):{})};RequestPrototype.constructor=RequestConstructor,RequestConstructor.prototype=RequestPrototype,$$1({global:!0,constructor:!0,dontCallGetSet:!0,forced:!0},{Request:RequestConstructor})}}var EOF,web_urlSearchParams_constructor={URLSearchParams:URLSearchParamsConstructor,getState:getInternalParamsState},$=_export,DESCRIPTORS=descriptors,USE_NATIVE_URL=urlConstructorDetection,global$1=global$K,bind=functionBindContext,uncurryThis=functionUncurryThis,defineBuiltIn=defineBuiltIn$j,defineBuiltInAccessor=defineBuiltInAccessor$5,anInstance=anInstance$a,hasOwn=hasOwnProperty_1,assign=objectAssign,arrayFrom=arrayFrom$1,arraySlice=arraySliceSimple,codeAt=stringMultibyte.codeAt,toASCII=stringPunycodeToAscii,$toString=toString$m,setToStringTag=setToStringTag$a,validateArgumentsLength=validateArgumentsLength$3,URLSearchParamsModule=web_urlSearchParams_constructor,InternalStateModule=internalState,setInternalState=InternalStateModule.set,getInternalURLState=InternalStateModule.getterFor("URL"),URLSearchParams$1=URLSearchParamsModule.URLSearchParams,getInternalSearchParamsState=URLSearchParamsModule.getState,NativeURL=global$1.URL,TypeError$1=global$1.TypeError,parseInt$1=global$1.parseInt,floor=Math.floor,pow=Math.pow,charAt=uncurryThis("".charAt),exec=uncurryThis(/./.exec),join=uncurryThis([].join),numberToString=uncurryThis(1..toString),pop=uncurryThis([].pop),push=uncurryThis([].push),replace=uncurryThis("".replace),shift=uncurryThis([].shift),split=uncurryThis("".split),stringSlice=uncurryThis("".slice),toLowerCase=uncurryThis("".toLowerCase),unshift=uncurryThis([].unshift),INVALID_AUTHORITY="Invalid authority",INVALID_SCHEME="Invalid scheme",INVALID_HOST="Invalid host",INVALID_PORT="Invalid port",ALPHA=/[a-z]/i,ALPHANUMERIC=/[\d+-.a-z]/i,DIGIT=/\d/,HEX_START=/^0x/i,OCT=/^[0-7]+$/,DEC=/^\d+$/,HEX=/^[\da-f]+$/i,FORBIDDEN_HOST_CODE_POINT=/[\0\t\n\r #%/:<>?@[\\\]^|]/,FORBIDDEN_HOST_CODE_POINT_EXCLUDING_PERCENT=/[\0\t\n\r #/:<>?@[\\\]^|]/,LEADING_AND_TRAILING_C0_CONTROL_OR_SPACE=/^[\u0000-\u0020]+|[\u0000-\u0020]+$/g,TAB_AND_NEW_LINE=/[\t\n\r]/g,parseIPv4=function(e){var t,r,n,i,o,a,s,c=split(e,".");if(c.length&&""==c[c.length-1]&&c.length--,(t=c.length)>4)return e;for(r=[],n=0;n<t;n++){if(""==(i=c[n]))return e;if(o=10,i.length>1&&"0"==charAt(i,0)&&(o=exec(HEX_START,i)?16:8,i=stringSlice(i,8==o?1:2)),""===i)a=0;else{if(!exec(10==o?DEC:8==o?OCT:HEX,i))return e;a=parseInt$1(i,o)}push(r,a)}for(n=0;n<t;n++)if(a=r[n],n==t-1){if(a>=pow(256,5-t))return null}else if(a>255)return null;for(s=pop(r),n=0;n<r.length;n++)s+=r[n]*pow(256,3-n);return s},parseIPv6=function(e){var t,r,n,i,o,a,s,c=[0,0,0,0,0,0,0,0],u=0,l=null,d=0,p=function(){return charAt(e,d)};if(":"==p()){if(":"!=charAt(e,1))return;d+=2,l=++u}for(;p();){if(8==u)return;if(":"!=p()){for(t=r=0;r<4&&exec(HEX,p());)t=16*t+parseInt$1(p(),16),d++,r++;if("."==p()){if(0==r)return;if(d-=r,u>6)return;for(n=0;p();){if(i=null,n>0){if(!("."==p()&&n<4))return;d++}if(!exec(DIGIT,p()))return;for(;exec(DIGIT,p());){if(o=parseInt$1(p(),10),null===i)i=o;else{if(0==i)return;i=10*i+o}if(i>255)return;d++}c[u]=256*c[u]+i,2!=++n&&4!=n||u++}if(4!=n)return;break}if(":"==p()){if(d++,!p())return}else if(p())return;c[u++]=t}else{if(null!==l)return;d++,l=++u}}if(null!==l)for(a=u-l,u=7;0!=u&&a>0;)s=c[u],c[u--]=c[l+a-1],c[l+--a]=s;else if(8!=u)return;return c},findLongestZeroSequence=function(e){for(var t=null,r=1,n=null,i=0,o=0;o<8;o++)0!==e[o]?(i>r&&(t=n,r=i),n=null,i=0):(null===n&&(n=o),++i);return i>r&&(t=n,r=i),t},serializeHost=function(e){var t,r,n,i;if("number"==typeof e){for(t=[],r=0;r<4;r++)unshift(t,e%256),e=floor(e/256);return join(t,".")}if("object"==typeof e){for(t="",n=findLongestZeroSequence(e),r=0;r<8;r++)i&&0===e[r]||(i&&(i=!1),n===r?(t+=r?":":"::",i=!0):(t+=numberToString(e[r],16),r<7&&(t+=":")));return"["+t+"]"}return e},C0ControlPercentEncodeSet={},fragmentPercentEncodeSet=assign({},C0ControlPercentEncodeSet,{" ":1,'"':1,"<":1,">":1,"`":1}),pathPercentEncodeSet=assign({},fragmentPercentEncodeSet,{"#":1,"?":1,"{":1,"}":1}),userinfoPercentEncodeSet=assign({},pathPercentEncodeSet,{"/":1,":":1,";":1,"=":1,"@":1,"[":1,"\\":1,"]":1,"^":1,"|":1}),percentEncode=function(e,t){var r=codeAt(e,0);return r>32&&r<127&&!hasOwn(t,e)?e:encodeURIComponent(e)},specialSchemes={ftp:21,file:null,http:80,https:443,ws:80,wss:443},isWindowsDriveLetter=function(e,t){var r;return 2==e.length&&exec(ALPHA,charAt(e,0))&&(":"==(r=charAt(e,1))||!t&&"|"==r)},startsWithWindowsDriveLetter=function(e){var t;return e.length>1&&isWindowsDriveLetter(stringSlice(e,0,2))&&(2==e.length||"/"===(t=charAt(e,2))||"\\"===t||"?"===t||"#"===t)},isSingleDot=function(e){return"."===e||"%2e"===toLowerCase(e)},isDoubleDot=function(e){return".."===(e=toLowerCase(e))||"%2e."===e||".%2e"===e||"%2e%2e"===e},SCHEME_START={},SCHEME={},NO_SCHEME={},SPECIAL_RELATIVE_OR_AUTHORITY={},PATH_OR_AUTHORITY={},RELATIVE={},RELATIVE_SLASH={},SPECIAL_AUTHORITY_SLASHES={},SPECIAL_AUTHORITY_IGNORE_SLASHES={},AUTHORITY={},HOST={},HOSTNAME={},PORT={},FILE={},FILE_SLASH={},FILE_HOST={},PATH_START={},PATH={},CANNOT_BE_A_BASE_URL_PATH={},QUERY={},FRAGMENT={},URLState=function(e,t,r){var n,i,o,a=$toString(e);if(t){if(i=this.parse(a))throw TypeError$1(i);this.searchParams=null}else{if(void 0!==r&&(n=new URLState(r,!0)),i=this.parse(a,null,n))throw TypeError$1(i);(o=getInternalSearchParamsState(new URLSearchParams$1)).bindURL(this),this.searchParams=o}};URLState.prototype={type:"URL",parse:function(e,t,r){var n,i,o,a,s=this,c=t||SCHEME_START,u=0,l="",d=!1,p=!1,_=!1;for(e=$toString(e),t||(s.scheme="",s.username="",s.password="",s.host=null,s.port=null,s.path=[],s.query=null,s.fragment=null,s.cannotBeABaseURL=!1,e=replace(e,LEADING_AND_TRAILING_C0_CONTROL_OR_SPACE,"")),e=replace(e,TAB_AND_NEW_LINE,""),n=arrayFrom(e);u<=n.length;){switch(i=n[u],c){case SCHEME_START:if(!i||!exec(ALPHA,i)){if(t)return INVALID_SCHEME;c=NO_SCHEME;continue}l+=toLowerCase(i),c=SCHEME;break;case SCHEME:if(i&&(exec(ALPHANUMERIC,i)||"+"==i||"-"==i||"."==i))l+=toLowerCase(i);else{if(":"!=i){if(t)return INVALID_SCHEME;l="",c=NO_SCHEME,u=0;continue}if(t&&(s.isSpecial()!=hasOwn(specialSchemes,l)||"file"==l&&(s.includesCredentials()||null!==s.port)||"file"==s.scheme&&!s.host))return;if(s.scheme=l,t)return void(s.isSpecial()&&specialSchemes[s.scheme]==s.port&&(s.port=null));l="","file"==s.scheme?c=FILE:s.isSpecial()&&r&&r.scheme==s.scheme?c=SPECIAL_RELATIVE_OR_AUTHORITY:s.isSpecial()?c=SPECIAL_AUTHORITY_SLASHES:"/"==n[u+1]?(c=PATH_OR_AUTHORITY,u++):(s.cannotBeABaseURL=!0,push(s.path,""),c=CANNOT_BE_A_BASE_URL_PATH)}break;case NO_SCHEME:if(!r||r.cannotBeABaseURL&&"#"!=i)return INVALID_SCHEME;if(r.cannotBeABaseURL&&"#"==i){s.scheme=r.scheme,s.path=arraySlice(r.path),s.query=r.query,s.fragment="",s.cannotBeABaseURL=!0,c=FRAGMENT;break}c="file"==r.scheme?FILE:RELATIVE;continue;case SPECIAL_RELATIVE_OR_AUTHORITY:if("/"!=i||"/"!=n[u+1]){c=RELATIVE;continue}c=SPECIAL_AUTHORITY_IGNORE_SLASHES,u++;break;case PATH_OR_AUTHORITY:if("/"==i){c=AUTHORITY;break}c=PATH;continue;case RELATIVE:if(s.scheme=r.scheme,i==EOF)s.username=r.username,s.password=r.password,s.host=r.host,s.port=r.port,s.path=arraySlice(r.path),s.query=r.query;else if("/"==i||"\\"==i&&s.isSpecial())c=RELATIVE_SLASH;else if("?"==i)s.username=r.username,s.password=r.password,s.host=r.host,s.port=r.port,s.path=arraySlice(r.path),s.query="",c=QUERY;else{if("#"!=i){s.username=r.username,s.password=r.password,s.host=r.host,s.port=r.port,s.path=arraySlice(r.path),s.path.length--,c=PATH;continue}s.username=r.username,s.password=r.password,s.host=r.host,s.port=r.port,s.path=arraySlice(r.path),s.query=r.query,s.fragment="",c=FRAGMENT}break;case RELATIVE_SLASH:if(!s.isSpecial()||"/"!=i&&"\\"!=i){if("/"!=i){s.username=r.username,s.password=r.password,s.host=r.host,s.port=r.port,c=PATH;continue}c=AUTHORITY}else c=SPECIAL_AUTHORITY_IGNORE_SLASHES;break;case SPECIAL_AUTHORITY_SLASHES:if(c=SPECIAL_AUTHORITY_IGNORE_SLASHES,"/"!=i||"/"!=charAt(l,u+1))continue;u++;break;case SPECIAL_AUTHORITY_IGNORE_SLASHES:if("/"!=i&&"\\"!=i){c=AUTHORITY;continue}break;case AUTHORITY:if("@"==i){d&&(l="%40"+l),d=!0,o=arrayFrom(l);for(var f=0;f<o.length;f++){var h=o[f];if(":"!=h||_){var m=percentEncode(h,userinfoPercentEncodeSet);_?s.password+=m:s.username+=m}else _=!0}l=""}else if(i==EOF||"/"==i||"?"==i||"#"==i||"\\"==i&&s.isSpecial()){if(d&&""==l)return INVALID_AUTHORITY;u-=arrayFrom(l).length+1,l="",c=HOST}else l+=i;break;case HOST:case HOSTNAME:if(t&&"file"==s.scheme){c=FILE_HOST;continue}if(":"!=i||p){if(i==EOF||"/"==i||"?"==i||"#"==i||"\\"==i&&s.isSpecial()){if(s.isSpecial()&&""==l)return INVALID_HOST;if(t&&""==l&&(s.includesCredentials()||null!==s.port))return;if(a=s.parseHost(l))return a;if(l="",c=PATH_START,t)return;continue}"["==i?p=!0:"]"==i&&(p=!1),l+=i}else{if(""==l)return INVALID_HOST;if(a=s.parseHost(l))return a;if(l="",c=PORT,t==HOSTNAME)return}break;case PORT:if(!exec(DIGIT,i)){if(i==EOF||"/"==i||"?"==i||"#"==i||"\\"==i&&s.isSpecial()||t){if(""!=l){var y=parseInt$1(l,10);if(y>65535)return INVALID_PORT;s.port=s.isSpecial()&&y===specialSchemes[s.scheme]?null:y,l=""}if(t)return;c=PATH_START;continue}return INVALID_PORT}l+=i;break;case FILE:if(s.scheme="file","/"==i||"\\"==i)c=FILE_SLASH;else{if(!r||"file"!=r.scheme){c=PATH;continue}if(i==EOF)s.host=r.host,s.path=arraySlice(r.path),s.query=r.query;else if("?"==i)s.host=r.host,s.path=arraySlice(r.path),s.query="",c=QUERY;else{if("#"!=i){startsWithWindowsDriveLetter(join(arraySlice(n,u),""))||(s.host=r.host,s.path=arraySlice(r.path),s.shortenPath()),c=PATH;continue}s.host=r.host,s.path=arraySlice(r.path),s.query=r.query,s.fragment="",c=FRAGMENT}}break;case FILE_SLASH:if("/"==i||"\\"==i){c=FILE_HOST;break}r&&"file"==r.scheme&&!startsWithWindowsDriveLetter(join(arraySlice(n,u),""))&&(isWindowsDriveLetter(r.path[0],!0)?push(s.path,r.path[0]):s.host=r.host),c=PATH;continue;case FILE_HOST:if(i==EOF||"/"==i||"\\"==i||"?"==i||"#"==i){if(!t&&isWindowsDriveLetter(l))c=PATH;else if(""==l){if(s.host="",t)return;c=PATH_START}else{if(a=s.parseHost(l))return a;if("localhost"==s.host&&(s.host=""),t)return;l="",c=PATH_START}continue}l+=i;break;case PATH_START:if(s.isSpecial()){if(c=PATH,"/"!=i&&"\\"!=i)continue}else if(t||"?"!=i)if(t||"#"!=i){if(i!=EOF&&(c=PATH,"/"!=i))continue}else s.fragment="",c=FRAGMENT;else s.query="",c=QUERY;break;case PATH:if(i==EOF||"/"==i||"\\"==i&&s.isSpecial()||!t&&("?"==i||"#"==i)){if(isDoubleDot(l)?(s.shortenPath(),"/"==i||"\\"==i&&s.isSpecial()||push(s.path,"")):isSingleDot(l)?"/"==i||"\\"==i&&s.isSpecial()||push(s.path,""):("file"==s.scheme&&!s.path.length&&isWindowsDriveLetter(l)&&(s.host&&(s.host=""),l=charAt(l,0)+":"),push(s.path,l)),l="","file"==s.scheme&&(i==EOF||"?"==i||"#"==i))for(;s.path.length>1&&""===s.path[0];)shift(s.path);"?"==i?(s.query="",c=QUERY):"#"==i&&(s.fragment="",c=FRAGMENT)}else l+=percentEncode(i,pathPercentEncodeSet);break;case CANNOT_BE_A_BASE_URL_PATH:"?"==i?(s.query="",c=QUERY):"#"==i?(s.fragment="",c=FRAGMENT):i!=EOF&&(s.path[0]+=percentEncode(i,C0ControlPercentEncodeSet));break;case QUERY:t||"#"!=i?i!=EOF&&("'"==i&&s.isSpecial()?s.query+="%27":s.query+="#"==i?"%23":percentEncode(i,C0ControlPercentEncodeSet)):(s.fragment="",c=FRAGMENT);break;case FRAGMENT:i!=EOF&&(s.fragment+=percentEncode(i,fragmentPercentEncodeSet))}u++}},parseHost:function(e){var t,r,n;if("["==charAt(e,0)){if("]"!=charAt(e,e.length-1))return INVALID_HOST;if(!(t=parseIPv6(stringSlice(e,1,-1))))return INVALID_HOST;this.host=t}else if(this.isSpecial()){if(e=toASCII(e),exec(FORBIDDEN_HOST_CODE_POINT,e))return INVALID_HOST;if(null===(t=parseIPv4(e)))return INVALID_HOST;this.host=t}else{if(exec(FORBIDDEN_HOST_CODE_POINT_EXCLUDING_PERCENT,e))return INVALID_HOST;for(t="",r=arrayFrom(e),n=0;n<r.length;n++)t+=percentEncode(r[n],C0ControlPercentEncodeSet);this.host=t}},cannotHaveUsernamePasswordPort:function(){return!this.host||this.cannotBeABaseURL||"file"==this.scheme},includesCredentials:function(){return""!=this.username||""!=this.password},isSpecial:function(){return hasOwn(specialSchemes,this.scheme)},shortenPath:function(){var e=this.path,t=e.length;!t||"file"==this.scheme&&1==t&&isWindowsDriveLetter(e[0],!0)||e.length--},serialize:function(){var e=this,t=e.scheme,r=e.username,n=e.password,i=e.host,o=e.port,a=e.path,s=e.query,c=e.fragment,u=t+":";return null!==i?(u+="//",e.includesCredentials()&&(u+=r+(n?":"+n:"")+"@"),u+=serializeHost(i),null!==o&&(u+=":"+o)):"file"==t&&(u+="//"),u+=e.cannotBeABaseURL?a[0]:a.length?"/"+join(a,"/"):"",null!==s&&(u+="?"+s),null!==c&&(u+="#"+c),u},setHref:function(e){var t=this.parse(e);if(t)throw TypeError$1(t);this.searchParams.update()},getOrigin:function(){var e=this.scheme,t=this.port;if("blob"==e)try{return new URLConstructor(e.path[0]).origin}catch(e){return"null"}return"file"!=e&&this.isSpecial()?e+"://"+serializeHost(this.host)+(null!==t?":"+t:""):"null"},getProtocol:function(){return this.scheme+":"},setProtocol:function(e){this.parse($toString(e)+":",SCHEME_START)},getUsername:function(){return this.username},setUsername:function(e){var t=arrayFrom($toString(e));if(!this.cannotHaveUsernamePasswordPort()){this.username="";for(var r=0;r<t.length;r++)this.username+=percentEncode(t[r],userinfoPercentEncodeSet)}},getPassword:function(){return this.password},setPassword:function(e){var t=arrayFrom($toString(e));if(!this.cannotHaveUsernamePasswordPort()){this.password="";for(var r=0;r<t.length;r++)this.password+=percentEncode(t[r],userinfoPercentEncodeSet)}},getHost:function(){var e=this.host,t=this.port;return null===e?"":null===t?serializeHost(e):serializeHost(e)+":"+t},setHost:function(e){this.cannotBeABaseURL||this.parse(e,HOST)},getHostname:function(){var e=this.host;return null===e?"":serializeHost(e)},setHostname:function(e){this.cannotBeABaseURL||this.parse(e,HOSTNAME)},getPort:function(){var e=this.port;return null===e?"":$toString(e)},setPort:function(e){this.cannotHaveUsernamePasswordPort()||(""==(e=$toString(e))?this.port=null:this.parse(e,PORT))},getPathname:function(){var e=this.path;return this.cannotBeABaseURL?e[0]:e.length?"/"+join(e,"/"):""},setPathname:function(e){this.cannotBeABaseURL||(this.path=[],this.parse(e,PATH_START))},getSearch:function(){var e=this.query;return e?"?"+e:""},setSearch:function(e){""==(e=$toString(e))?this.query=null:("?"==charAt(e,0)&&(e=stringSlice(e,1)),this.query="",this.parse(e,QUERY)),this.searchParams.update()},getSearchParams:function(){return this.searchParams.facade},getHash:function(){var e=this.fragment;return e?"#"+e:""},setHash:function(e){""!=(e=$toString(e))?("#"==charAt(e,0)&&(e=stringSlice(e,1)),this.fragment="",this.parse(e,FRAGMENT)):this.fragment=null},update:function(){this.query=this.searchParams.serialize()||null}};var URLConstructor=function(e){var t=anInstance(this,URLPrototype),r=validateArgumentsLength(arguments.length,1)>1?arguments[1]:void 0,n=setInternalState(t,new URLState(e,!1,r));DESCRIPTORS||(t.href=n.serialize(),t.origin=n.getOrigin(),t.protocol=n.getProtocol(),t.username=n.getUsername(),t.password=n.getPassword(),t.host=n.getHost(),t.hostname=n.getHostname(),t.port=n.getPort(),t.pathname=n.getPathname(),t.search=n.getSearch(),t.searchParams=n.getSearchParams(),t.hash=n.getHash())},URLPrototype=URLConstructor.prototype,accessorDescriptor=function(e,t){return{get:function(){return getInternalURLState(this)[e]()},set:t&&function(e){return getInternalURLState(this)[t](e)},configurable:!0,enumerable:!0}};if(DESCRIPTORS&&(defineBuiltInAccessor(URLPrototype,"href",accessorDescriptor("serialize","setHref")),defineBuiltInAccessor(URLPrototype,"origin",accessorDescriptor("getOrigin")),defineBuiltInAccessor(URLPrototype,"protocol",accessorDescriptor("getProtocol","setProtocol")),defineBuiltInAccessor(URLPrototype,"username",accessorDescriptor("getUsername","setUsername")),defineBuiltInAccessor(URLPrototype,"password",accessorDescriptor("getPassword","setPassword")),defineBuiltInAccessor(URLPrototype,"host",accessorDescriptor("getHost","setHost")),defineBuiltInAccessor(URLPrototype,"hostname",accessorDescriptor("getHostname","setHostname")),defineBuiltInAccessor(URLPrototype,"port",accessorDescriptor("getPort","setPort")),defineBuiltInAccessor(URLPrototype,"pathname",accessorDescriptor("getPathname","setPathname")),defineBuiltInAccessor(URLPrototype,"search",accessorDescriptor("getSearch","setSearch")),defineBuiltInAccessor(URLPrototype,"searchParams",accessorDescriptor("getSearchParams")),defineBuiltInAccessor(URLPrototype,"hash",accessorDescriptor("getHash","setHash"))),defineBuiltIn(URLPrototype,"toJSON",(function(){return getInternalURLState(this).serialize()}),{enumerable:!0}),defineBuiltIn(URLPrototype,"toString",(function(){return getInternalURLState(this).serialize()}),{enumerable:!0}),NativeURL){var nativeCreateObjectURL=NativeURL.createObjectURL,nativeRevokeObjectURL=NativeURL.revokeObjectURL;nativeCreateObjectURL&&defineBuiltIn(URLConstructor,"createObjectURL",bind(nativeCreateObjectURL,NativeURL)),nativeRevokeObjectURL&&defineBuiltIn(URLConstructor,"revokeObjectURL",bind(nativeRevokeObjectURL,NativeURL))}setToStringTag(URLConstructor,"URL"),$({global:!0,constructor:!0,forced:!USE_NATIVE_URL,sham:!DESCRIPTORS},{URL:URLConstructor});var isValidAudioFile=function(){var e=_asyncToGenerator(_regeneratorRuntime().mark((function e(t,r){var n;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=new Audio(URL.createObjectURL(new Blob([t],r))),e.prev=1,n.muted=!0,e.next=5,n.play();case 5:return n.pause(),e.abrupt("return",!0);case 9:return e.prev=9,e.t0=e.catch(1),e.abrupt("return",!1);case 12:case"end":return e.stop()}}),e,null,[[1,9]])})));return function(t,r){return e.apply(this,arguments)}}(),__defProp$1=Object.defineProperty,__getOwnPropDesc$1=Object.getOwnPropertyDescriptor,__decorateClass$1=function(e,t,r,n){for(var i,o=n>1?void 0:n?__getOwnPropDesc$1(t,r):t,a=e.length-1;a>=0;a--)(i=e[a])&&(o=(n?i(t,r,o):i(o))||o);return n&&o&&__defProp$1(t,r,o),o},AudioMixingManager=function(){function e(t){_classCallCheck(this,e),_defineProperty(this,"_sharedAudioContext",new AudioContext),_defineProperty(this,"_audioDestination",this._sharedAudioContext.createMediaStreamDestination()),_defineProperty(this,"_localGainNode",this._sharedAudioContext.createGain()),_defineProperty(this,"_bufferGainNode",this._sharedAudioContext.createGain()),_defineProperty(this,"_audioBufferSource",void 0),_defineProperty(this,"_localSource",void 0),_defineProperty(this,"_context",void 0),_defineProperty(this,"_failedAudioList",[]),_defineProperty(this,"mixingMap",new Map),_defineProperty(this,"resourcesCache",new Map),_defineProperty(this,"volumeConfig",new Map),_defineProperty(this,"cachedBuffer",[]),this._context=t,this._localGainNode.gain.value=1}var t,r,n;return _createClass(e,[{key:"mixMediaStream",value:function(e){this._localSource&&this._localSource.disconnect(this._localGainNode),this._localSource=this._sharedAudioContext.createMediaStreamSource(e),this._localSource.connect(this._localGainNode).connect(this._audioDestination)}},{key:"startAudioMixing",value:(n=_asyncToGenerator(_regeneratorRuntime().mark((function e(t,r,n){var i,o,a,s,c,u,l,d,p,_,f,h,m,y=this;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(i=n.playCount,checkEnum(o=n.type,"mixingType",values(AudioMixingType)),a=this._context.getLocalAudioTrack()){e.next=5;break}return e.abrupt("return");case 5:if(a.gainAudioTrack?(s=new MediaStream).addTrack(a.gainAudioTrack):s=getMediaStreamByTrack(a.getTrack()),s&&this.mixMediaStream(s),(c=this.mixingMap.get(t))&&c.audioNode){c.audioNode.pause(),this._context.emitMessage({mixId:t,state:AudioMixingState.AUDIO_MIXING_STATE_STOPPED,error:AudioMixingError.AUDIO_MIXING_ERROR_OK});try{c.gainNode.disconnect(this._audioDestination),c.audioSource.disconnect(c.gainNode)}catch(e){}}if(!(l=this.resourcesCache.get(t))||l.filePath!==r){e.next=14;break}u=l.getAudioNode(),e.next=28;break;case 14:return e.next=16,fetch(r,{mode:"cors",credentials:"include"}).then((function(e){if(e.ok)return e.arrayBuffer();throw y._context.emitMessage({mixId:t,state:AudioMixingState.AUDIO_MIXING_STATE_FAILED,error:AudioMixingError.AUDIO_MIXING_ERROR_START_FAILED}),new SDKError(ErrorCode.LOAD_RESOURCES_FAILED,e.statusText)}));case 16:return d=e.sent,r.endsWith("mp3")?p={type:"audio/mpeg"}:r.endsWith("aac")&&(p={type:"audio/aac"}),e.next=20,isValidAudioFile(d,p);case 20:if(e.sent){e.next=25;break}throw this._context.emitMessage({mixId:t,state:AudioMixingState.AUDIO_MIXING_STATE_FAILED,error:AudioMixingError.AUDIO_MIXING_ERROR_START_FAILED}),new SDKError(ErrorCode.LOAD_RESOURCES_FAILED,"invalid audio resource");case 25:(u=new Audio).crossOrigin="anonymous",u.src=URL.createObjectURL(new Blob([d],p));case 28:return i<=0?u.loop=!0:i>0&&(_=i,u.onended=function(){--_>0?u.play():(y.mixingMap.delete(t),y._context.emitMessage({mixId:t,state:AudioMixingState.AUDIO_MIXING_STATE_FINISHED,error:AudioMixingError.AUDIO_MIXING_ERROR_OK}))}),e.prev=29,e.next=32,u.play();case 32:e.next=39;break;case 34:e.prev=34,e.t0=e.catch(29),console.error(e.t0),this._failedAudioList.push(u),this._context.onAutoPlayFailed();case 39:if(f=this._sharedAudioContext.createMediaElementSource(u),h=this._sharedAudioContext.createGain(),m=this.volumeConfig.get(t),h.gain.value=m?m/100:1,f.connect(h).connect(this._audioDestination),this.mixingMap.set(t,{audioSource:f,audioNode:u,gainNode:h,type:"file"}),o===AudioMixingType.PUBLISH)try{h.disconnect(this._sharedAudioContext.destination)}catch(e){}else h.connect(this._sharedAudioContext.destination);this._context.updateLocalAudioTrack(this._audioDestination.stream.getAudioTracks()[0],n.type),this._context.emitMessage({mixId:t,state:AudioMixingState.AUDIO_MIXING_STATE_PLAYING,error:AudioMixingError.AUDIO_MIXING_ERROR_OK});case 48:case"end":return e.stop()}}),e,this,[[29,34]])}))),function(e,t,r){return n.apply(this,arguments)})},{key:"stopAudioMixing",value:function(e){var t=this.mixingMap.get(e);t&&"file"===t.type&&(this.mixingMap.delete(e),t.audioNode.pause(),t.audioSource.disconnect(t.gainNode),t.gainNode.disconnect(this._audioDestination),this._context.emitMessage({mixId:e,state:AudioMixingState.AUDIO_MIXING_STATE_STOPPED,error:AudioMixingError.AUDIO_MIXING_ERROR_OK}))}},{key:"pauseAudioMixing",value:function(e){var t=this.mixingMap.get(e);t&&(this._context.emitMessage({mixId:e,state:AudioMixingState.AUDIO_MIXING_STATE_PAUSED,error:AudioMixingError.AUDIO_MIXING_ERROR_OK}),t.audioNode.pause())}},{key:"resumeAudioMixing",value:function(e){var t=this.mixingMap.get(e);t&&(this._context.emitMessage({mixId:e,state:AudioMixingState.AUDIO_MIXING_STATE_PLAYING,error:AudioMixingError.AUDIO_MIXING_ERROR_OK}),t.audioNode.play())}},{key:"preloadAudioMixing",value:(r=_asyncToGenerator(_regeneratorRuntime().mark((function e(t,r){var n,i=this;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.stopAudioMixing(t),e.next=3,fetch(r,{mode:"cors",credentials:"include"}).then((function(e){if(e.ok)return e.arrayBuffer();throw i._context.emitMessage({mixId:t,state:AudioMixingState.AUDIO_MIXING_STATE_FAILED,error:AudioMixingError.AUDIO_MIXING_ERROR_PRELOAD_FAILED}),new SDKError(ErrorCode.LOAD_RESOURCES_FAILED,e.statusText)})).catch((function(e){throw i._context.emitMessage({mixId:t,state:AudioMixingState.AUDIO_MIXING_STATE_FAILED,error:AudioMixingError.AUDIO_MIXING_ERROR_PRELOAD_FAILED}),new SDKError(ErrorCode.LOAD_RESOURCES_FAILED,"Load resources failed",e)}));case 3:return n=e.sent,e.next=6,isValidAudioFile(n);case 6:if(e.sent){e.next=10;break}throw this._context.emitMessage({mixId:t,state:AudioMixingState.AUDIO_MIXING_STATE_FAILED,error:AudioMixingError.AUDIO_MIXING_ERROR_PRELOAD_FAILED}),new SDKError(ErrorCode.LOAD_RESOURCES_FAILED,"Load resources failed");case 10:this._context.emitMessage({mixId:t,state:AudioMixingState.AUDIO_MIXING_STATE_PRELOADED,error:AudioMixingError.AUDIO_MIXING_ERROR_OK}),this.resourcesCache.set(t,{getAudioNode:function(){return new Audio(URL.createObjectURL(new Blob([n])))},filePath:r});case 12:case"end":return e.stop()}}),e,this)}))),function(e,t){return r.apply(this,arguments)})},{key:"unloadAudioMixing",value:function(e){this.resourcesCache.has(e)&&this.resourcesCache.delete(e)}},{key:"getAudioMixingVolume",value:function(e){var t=this.mixingMap.get(e);return t?100*t.gainNode.gain.value:0}},{key:"setAudioMixingVolume",value:function(e,t){t<0?t=0:t>400&&(t=400),this.volumeConfig.set(e,t);var r=this.mixingMap.get(e);r&&(r.gainNode.gain.value=Number(t)/100)}},{key:"getAudioMixingDuration",value:function(e){var t=this.mixingMap.get(e),r=this.mixingMap.get(e);return t||r?t?1e3*t.audioNode.duration:r?1e3*r.audioNode.duration:0:0}},{key:"getAudioMixingCurrentPosition",value:function(e){var t=this.mixingMap.get(e);return t?1e3*t.audioNode.currentTime:0}},{key:"setAudioMixingPosition",value:function(e,t){var r=this.mixingMap.get(e);r&&(r.audioNode.currentTime=t/1e3,r.audioNode.play())}},{key:"enableAudioMixingBuffer",value:function(e){checkEnum(e,"type",values(AudioMixingType));var t=this._context.getLocalAudioTrack();if(t){var r=getMediaStreamByTrack(t.getTrack());if(r&&this.mixMediaStream(r),e===AudioMixingType.PUBLISH)try{this._bufferGainNode.disconnect(this._sharedAudioContext.destination)}catch(e){}else this._bufferGainNode.connect(this._sharedAudioContext.destination);this._context.updateLocalAudioTrack(this._audioDestination.stream.getAudioTracks()[0],e),this._bufferGainNode.connect(this._audioDestination),this._context.emitMessage({mixId:-1,state:AudioMixingState.AUDIO_MIXING_STATE_PCM_ENABLED,error:AudioMixingError.AUDIO_MIXING_ERROR_OK})}}},{key:"disableAudioMixingBuffer",value:function(){if(this.cachedBuffer=[],this._audioBufferSource){try{this._audioBufferSource.disconnect(this._bufferGainNode),this._bufferGainNode.disconnect(this._audioDestination),this._bufferGainNode.disconnect(this._sharedAudioContext.destination)}catch(e){}finally{this._audioBufferSource=void 0}this._context.updateLocalAudioTrack(),this._context.emitMessage({mixId:-1,state:AudioMixingState.AUDIO_MIXING_STATE_PCM_DISABLED,error:AudioMixingError.AUDIO_MIXING_ERROR_OK})}}},{key:"pushAudioMixingBuffer",value:function(e){var t=this;if(!(this._audioBufferSource&&(this.cachedBuffer.push(e),this.cachedBuffer.length>0))){this._audioBufferSource=this._sharedAudioContext.createBufferSource(),this._audioBufferSource.buffer=e,this._audioBufferSource.connect(this._bufferGainNode);try{this._audioBufferSource.start()}catch(e){this._failedAudioList.push(this._audioBufferSource)}this._audioBufferSource.onended=function(){var e;if(null===(e=t._audioBufferSource)||void 0===e||e.disconnect(t._bufferGainNode),t._audioBufferSource=void 0,t.cachedBuffer.length){var r=t.cachedBuffer.shift();r&&t.pushAudioMixingBuffer(r)}}}}},{key:"stopAll",value:function(){var e=this;if(this._localSource)try{this._localSource.disconnect(this._localGainNode),delete this._localSource}catch(e){}this.mixingMap.forEach((function(t,r){e.stopAudioMixing(r)}))}},{key:"mixTrack",get:function(){return this._audioDestination.stream.getAudioTracks()[0]}},{key:"sharedAudioContext",get:function(){return this._sharedAudioContext}},{key:"resumeLocalPlay",value:(t=_asyncToGenerator(_regeneratorRuntime().mark((function e(){var t,r,n,i;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=[],r=_createForOfIteratorHelper(this._failedAudioList),e.prev=2,r.s();case 4:if((n=r.n()).done){e.next=24;break}if(i=n.value,e.prev=6,!(i instanceof HTMLAudioElement)){e.next=13;break}return i.muted=!1,e.next=11,i.play();case 11:e.next=14;break;case 13:i.start();case 14:e.next=22;break;case 16:return e.prev=16,e.t0=e.catch(6),t.push(i),console.error(e.t0),this._context.onAutoPlayFailed(),e.abrupt("break",24);case 22:e.next=4;break;case 24:e.next=29;break;case 26:e.prev=26,e.t1=e.catch(2),r.e(e.t1);case 29:return e.prev=29,r.f(),e.finish(29);case 32:this._failedAudioList=t;case 33:case"end":return e.stop()}}),e,this,[[2,26,29,32],[6,16]])}))),function(){return t.apply(this,arguments)})},{key:"destroy",value:function(){var e=this._sharedAudioContext;"closed"!==e.state&&"function"==typeof e.close&&e.close(),this.cachedBuffer=[],this.mixingMap.clear(),this.resourcesCache.clear(),this.volumeConfig.clear()}}]),e}();__decorateClass$1([reportRtcSdkApiCall("default","id","filePath","options")],AudioMixingManager.prototype,"startAudioMixing",1),__decorateClass$1([reportRtcSdkApiCall("default","id")],AudioMixingManager.prototype,"stopAudioMixing",1),__decorateClass$1([reportRtcSdkApiCall("default","id")],AudioMixingManager.prototype,"pauseAudioMixing",1),__decorateClass$1([reportRtcSdkApiCall("default","id")],AudioMixingManager.prototype,"resumeAudioMixing",1),__decorateClass$1([reportRtcSdkApiCall("default","id")],AudioMixingManager.prototype,"preloadAudioMixing",1),__decorateClass$1([reportRtcSdkApiCall("default","id")],AudioMixingManager.prototype,"unloadAudioMixing",1),__decorateClass$1([reportRtcSdkApiCall("default","id")],AudioMixingManager.prototype,"getAudioMixingVolume",1),__decorateClass$1([reportRtcSdkApiCall("default","id","volume")],AudioMixingManager.prototype,"setAudioMixingVolume",1),__decorateClass$1([reportRtcSdkApiCall("default","id")],AudioMixingManager.prototype,"getAudioMixingDuration",1),__decorateClass$1([reportRtcSdkApiCall("default","id")],AudioMixingManager.prototype,"getAudioMixingCurrentPosition",1),__decorateClass$1([reportRtcSdkApiCall("default","id","position")],AudioMixingManager.prototype,"setAudioMixingPosition",1),__decorateClass$1([reportRtcSdkApiCall("default","type")],AudioMixingManager.prototype,"enableAudioMixingBuffer",1),__decorateClass$1([reportRtcSdkApiCall()],AudioMixingManager.prototype,"disableAudioMixingBuffer",1),__decorateClass$1([reportRtcSdkApiCall("default","buffer")],AudioMixingManager.prototype,"pushAudioMixingBuffer",1);var UserRole=function(e){return e.NORMAL_USER="normalUser",e.SILENT_USER="silentUser",e}(UserRole||{}),logger$4=new Logger("RTMClient",1),RTMClient=function(e){_inherits(u,eventemitter3.exports.EventEmitter);var t,r,n,i,o,a,s,c=_createSuper(u);function u(e){var t;return _classCallCheck(this,u),_defineProperty(_assertThisInitialized(t=c.call(this)),"_dataChannelSignal",null),_defineProperty(_assertThisInitialized(t),"_handler",null),_defineProperty(_assertThisInitialized(t),"_dataChannelSignalState",MediaConnectionState.DISCONNECTED),_defineProperty(_assertThisInitialized(t),"_loginSessionId",null),_defineProperty(_assertThisInitialized(t),"_userId",null),_defineProperty(_assertThisInitialized(t),"_token",null),_defineProperty(_assertThisInitialized(t),"_isReconnecting",!1),_defineProperty(_assertThisInitialized(t),"_reconnectTimer",null),_defineProperty(_assertThisInitialized(t),"_loginResolveCallback",null),_defineProperty(_assertThisInitialized(t),"_loginRejectCallback",null),_defineProperty(_assertThisInitialized(t),"_iceConfigNode",null),_defineProperty(_assertThisInitialized(t),"_wait_login_token",!1),_defineProperty(_assertThisInitialized(t),"_serverParamsCache",void 0),t._appId=e,t}return _createClass(u,[{key:"login",value:function(e,t){var r=this;return new Promise((function(n,i){if(logger$4.print("login","invoke login, token: %o, userId: %o",e,t),r._loginSessionId)throw new SDKError(ErrorCode.ALREADY_LOGIN,"Already logined");if(r._loginResolveCallback)throw new SDKError(ErrorCode.LOGIN_FAILED,"Is logging in, please try again later.");r._userId=t,r._token=e,rtmCommonStats.setStats({rtc_app_id:r._appId,user_id:t}),r._loginResolveCallback=n,r._loginRejectCallback=i,r._dataChannelSignal?r._login():(logger$4.print("login","init dataChannelSingling"),r._dataChannelSignalState=MediaConnectionState.CONNECTING,r._createDataChannelSignaling(t).then((function(e){r._dataChannelSignal=e,r._login()})).catch((function(){r._onDisconnect()})))}))}},{key:"logout",value:(s=_asyncToGenerator(_regeneratorRuntime().mark((function e(){var t;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._loginSessionId&&this._userId){e.next=2;break}throw new SDKError(ErrorCode.NOT_LOGIN,"login first");case 2:return e.next=4,null===(t=this._dataChannelSignal)||void 0===t?void 0:t.sendSignaling("logout",{loginSessionId:this._loginSessionId,userId:this._userId,appId:this._appId},{functionType:SIGNALING_FUNCTION_TYPE.C2RTM}).catch((function(){}));case 4:this._closeDataChannelSignaling(),this._clearState();case 6:case"end":return e.stop()}}),e,this)}))),function(){return s.apply(this,arguments)})},{key:"updateLoginToken",value:(a=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){var r=this;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this._token=t,e.abrupt("return",new Promise((function(e,t){r._wait_login_token?(r._loginResolveCallback=e,r._loginRejectCallback=t,r._login()):e()})));case 2:case"end":return e.stop()}}),e,this)}))),function(e){return a.apply(this,arguments)})},{key:"getPeerOnlineStatus",value:(o=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){var r;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._loginSessionId&&this._userId){e.next=2;break}throw new SDKError(ErrorCode.NOT_LOGIN,"login first");case 2:return this._checkDataChannelSignal(),e.next=5,this._dataChannelSignal.sendSignaling("getPeerOnlineStatus",{loginSessionId:this._loginSessionId,userId:this._userId,appId:this._appId,peerUserId:t},{functionType:SIGNALING_FUNCTION_TYPE.C2RTM});case 5:return r=e.sent,e.abrupt("return",null==r?void 0:r.status);case 7:case"end":return e.stop()}}),e,this)}))),function(e){return o.apply(this,arguments)})},{key:"sendUserMessageOutsideRoom",value:(i=_asyncToGenerator(_regeneratorRuntime().mark((function e(t,r){return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._loginSessionId&&this._userId){e.next=2;break}throw new SDKError(ErrorCode.NOT_LOGIN,"login first");case 2:return this._checkDataChannelSignal(),e.abrupt("return",this._dataChannelSignal.sendP2PMessage({from:this._userId,app:this._appId,to:t,room:"",msg:r}));case 4:case"end":return e.stop()}}),e,this)}))),function(e,t){return i.apply(this,arguments)})},{key:"setServerParams",value:(n=_asyncToGenerator(_regeneratorRuntime().mark((function e(t,r){return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(e.prev=0,checkString(t,"signature"),checkString(r,"url"),this._loginSessionId&&this._userId){e.next=5;break}throw new SDKError(ErrorCode.NOT_LOGIN,"login first");case 5:return this._checkDataChannelSignal(),e.next=8,this._dataChannelSignal.sendSignaling("setServerParams",{loginSessionId:this._loginSessionId,userId:this._userId,appId:this._appId,signature:t,url:r},{functionType:SIGNALING_FUNCTION_TYPE.C2RTM}).catch((function(e){throw new SDKError(ErrorCode.UNEXPECTED_ERROR,e.msg)}));case 8:this._serverParamsCache={signature:t,url:r},this.emit("onServerParamsSetResult"),e.next=16;break;case 12:throw e.prev=12,e.t0=e.catch(0),this.emit("onServerParamsSetResult",e.t0),e.t0;case 16:case"end":return e.stop()}}),e,this,[[0,12]])}))),function(e,t){return n.apply(this,arguments)})},{key:"sendServerMessage",value:(r=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._loginSessionId&&this._userId){e.next=2;break}throw new SDKError(ErrorCode.NOT_LOGIN,"login first");case 2:return this._checkDataChannelSignal(),e.abrupt("return",this._dataChannelSignal.sendP2PMessage({from:this._userId,app:this._appId,to:"",room:"",type:DC_MESSAGE_FUNCTION_TYPE.BUSINESS_SERVER,msg:t}));case 4:case"end":return e.stop()}}),e,this)}))),function(e){return r.apply(this,arguments)})},{key:"destroy",value:function(){this._clearState(),this._closeDataChannelSignaling(),_get(_getPrototypeOf(u.prototype),"removeAllListeners",this).call(this),delete this._serverParamsCache}},{key:"_login",value:function(){var e=this;if(this._userId){var t=genUuid();this._checkDataChannelSignal(),this._dataChannelSignal.sendSignaling("login",{Token:Utils.token2auth(this._appId,null,this._userId,this._token),timestamp:Date.now(),loginSessionId:t,params:{deviceType:"web",userAgent:window.navigator.userAgent,sdkVersion:Config.VERSION,deviceId:sdkCache.getDeviceId(),appId:this._appId,userId:this._userId}},{functionType:SIGNALING_FUNCTION_TYPE.C2RTM}).then((function(){e._loginResolveCallback&&e._loginResolveCallback(),e._loginSessionId=t,e._wait_login_token=!1,e._serverParamsCache&&e.setServerParams(e._serverParamsCache.signature,e._serverParamsCache.url)})).catch((function(t){var r,n,i=t||{},o=i.code,a=i.message;e._wait_login_token=!1,o>=700&&o<800?708===o?(r=ErrorCode.INVALID_PARAMS,n="Invalid userId"):(r=ErrorCode.INVALID_TOKEN,n="Invalid token",e._wait_login_token=!0,e._loginRejectCallback||e.emit("onRTMTokenError")):(r=ErrorCode.LOGIN_FAILED,n="login failed"),e._loginRejectCallback&&e._loginRejectCallback(new SDKError(r,a||n))})).finally((function(){e._loginResolveCallback=null,e._loginRejectCallback=null}))}}},{key:"_createDataChannelSignaling",value:(t=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){var r,n,i,o,a,s,c,u=this;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=new IceConfigRequestManager,i=this._iceConfigNode){e.next=16;break}return e.prev=3,e.next=6,null==n?void 0:n.getAccessNode(this._appId,"",t,sdkCache.getDeviceId(),"");case 6:if(o=e.sent,i=o[0]){e.next=10;break}throw new Error;case 10:e.next=16;break;case 12:throw e.prev=12,e.t0=e.catch(3),reportRtcInvokeStatus("rtm.login.getNodeFailed","",0,!0),new SDKError(ErrorCode.ICE_SERVER_WRONG,"get ICE config failed");case 16:return reportRtcInvokeStatus("rtm.login.getNodeSuccess",i,0,!0),logger$4.print("_createDataChannelSignaling()","get node success",i),this._handler=createHandler(rtmMonitor),null===(r=this._handler)||void 0===r||r.once("disconnect",(function(){logger$4.print("_createDataChannelSignaling()","recv BasicHandler event: disconnect"),u._onDisconnect()})),e.prev=20,e.next=23,null===(s=this._handler)||void 0===s?void 0:s.connect(i);case 23:a=e.sent,logger$4.print("_createDataChannelSignaling()","establish peerConnection success"),this._dataChannelSignalState=MediaConnectionState.CONNECTED,e.next=33;break;case 28:throw e.prev=28,e.t1=e.catch(20),this._iceConfigNode=null,this._dataChannelSignalState=MediaConnectionState.DISCONNECTED,new SDKError(ErrorCode.ESTABLISH_DATACHANNEL_FAILED,"establish dataChannel failed",e.t1);case 33:return c=new DataChannelSignaling(a),logger$4.print("_createDataChannelSignaling()","send ping"),c.sendPingSignaling(),c.once("close",(function(){logger$4.print("_createDataChannelSignaling()","recv DataChannelSignaling event: close"),u._onDisconnect()})),c.on(SignalEvent.USER_MESSAGE_RECEIVED_OUTSIDE_ROOM,(function(e){u.emit("onUserMessageReceivedOutsideRoom",{userId:e.from,message:e.msg})})),c.on(SignalEvent.USER_BINARY_MESSAGE_RECEIVED_OUTSIDE_ROOM,(function(e){u.emit("onUserBinaryMessageReceivedOutsideRoom",{userId:e.from,message:e.msg})})),c.on(SignalEvent.USER_DISCONNECTION,(function(){u.emit("onUserDisconnection"),u._clearState()})),c.on(SignalEvent.NODE_CHANGE,(function(e){reportRtcInvokeStatus("rtm.nodeChange",JSON.stringify(e),0,!0),Array.isArray(e.nodes)&&e.nodes.length&&(u._iceConfigNode=e.nodes[0]),u._loginResolveCallback&&u._loginRejectCallback?u._login():u._reconnect()})),e.abrupt("return",c);case 42:case"end":return e.stop()}}),e,this,[[3,12],[20,28]])}))),function(e){return t.apply(this,arguments)})},{key:"_closeDataChannelSignaling",value:function(){var e,t;null===(e=this._dataChannelSignal)||void 0===e||e.destroy(),this._dataChannelSignal=null,null===(t=this._handler)||void 0===t||t.destroy(),this._handler=null}},{key:"_checkDataChannelSignal",value:function(){if(!this._dataChannelSignal||this._dataChannelSignalState!==MediaConnectionState.CONNECTED)throw new SDKError(ErrorCode.NOT_CONNECTED_YET,"datachannel not connect")}},{key:"_onDisconnect",value:function(){this._dataChannelSignalState=MediaConnectionState.DISCONNECTED,this._closeDataChannelSignaling(),navigator.onLine?this._reconnect():this._reconnectTimer=self.setTimeout(this._reconnect.bind(this),3e3)}},{key:"_reconnect",value:function(){var e=this;!this._isReconnecting&&this._userId&&(logger$4.print("_reconnect()","start reconnect..."),this._isReconnecting=!0,this._createDataChannelSignaling(this._userId).then((function(t){logger$4.print("_reconnect()","reconnect success!"),e._dataChannelSignal=t,e._login(),e._reconnectTimer=null})).catch((function(t){logger$4.print("_reconnect()","Reconnecting error, will reconnect after 3s",t),e._reconnectTimer=self.setTimeout(e._reconnect.bind(e),3e3)})).finally((function(){e._isReconnecting=!1})))}},{key:"_clearState",value:function(){this._userId=null,this._token=null,this._loginSessionId=null,null!==this._reconnectTimer&&(self.clearTimeout(this._reconnectTimer),this._reconnectTimer=null)}}]),u}(),OutsideRoom=function(e){_inherits(o,EnhancedEventEmitter);var t,r,n,i=_createSuper(o);function o(e){var t;return _classCallCheck(this,o),_defineProperty(_assertThisInitialized(t=i.call(this)),"_mediaServerClient",void 0),_defineProperty(_assertThisInitialized(t),"_appId",void 0),_defineProperty(_assertThisInitialized(t),"_reconnectTimer",void 0),_defineProperty(_assertThisInitialized(t),"remoteStreams",void 0),t._appId=e,t.remoteStreams=new Map,t}return _createClass(o,[{key:"connect",value:(n=_asyncToGenerator(_regeneratorRuntime().mark((function e(){return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this._mediaServerClient=new MediaServerClient,this._bindEvents(),e.next=4,this._mediaServerClient.connect(this._appId);case 4:case"end":return e.stop()}}),e,this)}))),function(){return n.apply(this,arguments)})},{key:"startPlayPublicStream",value:(r=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){var r,n=this;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.remoteStreams.get(t)){e.next=2;break}throw new SDKError(ErrorCode.REPEAT_PLAY,"repeat play public media stream");case 2:return(r=new RemoteStream(t,t,!1,{audiostream:!0,localaudio:!0,videostream:!0,localvideo:!0,extaudio:!1,extvideo:!1,videoDescriptions:[]})).on("onSEIMessage",(function(e){if(e instanceof Uint8Array)for(var t=splitPublicStreamSei(e),i=0;i<t.seiCount;i++)n.emit(RoomEvent.ON_SEI_MESSAGED_RECEIVED,{sei:t.seis[i],publicStreamId:r.streamId})})),e.next=6,this._mediaServerClient.subscribePublicStream(r);case 6:return this.remoteStreams.set(t,r),e.abrupt("return",r);case 8:case"end":return e.stop()}}),e,this)}))),function(e){return r.apply(this,arguments)})},{key:"stopPlayPublicStream",value:function(e){var t=this.remoteStreams.get(e);if(t)return this.remoteStreams.delete(e),this._mediaServerClient.unsubscribePublicStream(t)}},{key:"destroy",value:function(){this.remoteStreams=new Map,this._mediaServerClient&&this._mediaServerClient.destroy()}},{key:"_handleReconnected",value:(t=_asyncToGenerator(_regeneratorRuntime().mark((function e(){var t,r,n,i=this;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:clearTimeout(this._reconnectTimer),t=_createForOfIteratorHelper(this.remoteStreams);try{for(n=function(){var e=_slicedToArray(r.value,1)[0];i.remoteStreams.delete(e),i.startPlayPublicStream(e).then((function(){var t=i.remoteStreams.get(e);i.safeEmit(RoomEvent.RESUBSCRIBE,{stream:t})}))},t.s();!(r=t.n()).done;)n()}catch(e){t.e(e)}finally{t.f()}case 3:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})},{key:"_reconnect",value:function(){var e=this;this._mediaServerClient.removeAllListeners(),this._mediaServerClient.destroy(),navigator.onLine?this.connect().then(this._handleReconnected.bind(this)):this._reconnectTimer=setTimeout((function(){return e.connect().then(e._handleReconnected.bind(e))}),3e3)}},{key:"_bindEvents",value:function(){var e,t,r=this;null===(e=this._mediaServerClient)||void 0===e||e.on(StateEvent.ABNORMAL_DISCONNECTION,this._reconnect.bind(this)),null===(t=this._mediaServerClient)||void 0===t||t.on("onRemoteStreamStats",(function(e){r.emit("onRemoteStreamStats",e)}))}}]),o}(),MAX_RECORDER_DURATION=3e4,logger$3=new Logger("AudioDeviceManager",1),AudioDeviceManager=function(e){_inherits(o,eventemitter3.exports.EventEmitter);var t,r,n,i=_createSuper(o);function o(){var e;_classCallCheck(this,o);for(var t=arguments.length,r=new Array(t),n=0;n<t;n++)r[n]=arguments[n];return _defineProperty(_assertThisInitialized(e=i.call.apply(i,[this].concat(r))),"_audioLevelFetcher",void 0),_defineProperty(_assertThisInitialized(e),"_playbackDeviceTestTimer",void 0),_defineProperty(_assertThisInitialized(e),"_audioElement",void 0),_defineProperty(_assertThisInitialized(e),"_audioTrack",void 0),_defineProperty(_assertThisInitialized(e),"_mediaRecorder",void 0),_defineProperty(_assertThisInitialized(e),"_recoderTimer",void 0),_defineProperty(_assertThisInitialized(e),"_isAudioPlaybackDeviceTesting",!1),_defineProperty(_assertThisInitialized(e),"_isAudioDeviceRecordTesting",!1),_defineProperty(_assertThisInitialized(e),"_audioCaptureAndRecoderResolve",void 0),e}return _createClass(o,[{key:"startAudioPlaybackDeviceTest",value:(n=_asyncToGenerator(_regeneratorRuntime().mark((function e(t,r){return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._isAudioPlaybackDeviceTesting&&!this._isAudioDeviceRecordTesting){e.next=2;break}throw new SDKError(ErrorCode.REPEAT_DEVICE_TEST,"device test cannot be called repeatedly at the same time.");case 2:return this._isAudioPlaybackDeviceTesting=!0,logger$3.print("startAudioPlaybackDeviceTest()","Invoke"),e.prev=4,e.next=7,this._playAudioFile(t,{loop:!0});case 7:e.next=13;break;case 9:throw e.prev=9,e.t0=e.catch(4),this.stopAudioPlaybackDeviceTest(),e.t0;case 13:this._startEmitAudioPlaybackDeviceTestVolume(r);case 14:case"end":return e.stop()}}),e,this,[[4,9]])}))),function(e,t){return n.apply(this,arguments)})},{key:"stopAudioPlaybackDeviceTest",value:function(){this._isAudioPlaybackDeviceTesting&&(logger$3.print("stopAudioPlaybackDeviceTest()","Invoke"),this._isAudioPlaybackDeviceTesting=!1,this._stopEmitAudioPlaybackDeviceTestVolume(),this._destroyAudioElement())}},{key:"startAudioDeviceRecordTest",value:(r=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){var r=this;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._isAudioDeviceRecordTesting){e.next=2;break}throw new SDKError(ErrorCode.REPEAT_DEVICE_TEST,"device test cannot be called repeatedly at the same time.");case 2:return this._isAudioDeviceRecordTesting=!0,logger$3.print("startAudioDeviceRecordTest()","Invoke"),this._recoderTimer=window.setTimeout((function(){logger$3.print("startAudioDeviceRecordTest()","".concat(MAX_RECORDER_DURATION,'ms automatic call method "stopAudioDeviceRecordAndPlayTest"')),r._stopAudioCaptureAndRecoder()}),MAX_RECORDER_DURATION),e.next=7,this._startAudioCaptureAndRecoder(t);case 7:delete this._audioCaptureAndRecoderResolve;case 8:case"end":return e.stop()}}),e,this)}))),function(e){return r.apply(this,arguments)})},{key:"stopAudioDeviceRecordAndPlayTest",value:function(){logger$3.print("stopAudioDeviceRecordAndPlayTest()","Invoke"),void 0!==this._recoderTimer&&(clearTimeout(this._recoderTimer),delete this._recoderTimer),this._stopAudioCaptureAndRecoder()}},{key:"stopAudioDevicePlayTest",value:function(){this._isAudioDeviceRecordTesting&&(logger$3.print("stopAudioDevicePlayTest()","Invoke"),this._isAudioDeviceRecordTesting=!1,this.stopAudioDeviceRecordAndPlayTest(),this._stopEmitAudioPlaybackDeviceTestVolume(),this._destroyAudioElement())}},{key:"getRecordTrack",value:function(){return this._audioTrack}},{key:"destroy",value:function(){logger$3.print("destroy()","Invoke"),_get(_getPrototypeOf(o.prototype),"removeAllListeners",this).call(this),this.stopAudioPlaybackDeviceTest(),this.stopAudioDevicePlayTest()}},{key:"_playAudioFile",value:function(e,t){var r=this;return new Promise((function(n,i){r._audioElement=createElement("audio",{attributes:{src:e,crossOrigin:"",autoplay:"true"}}),r._audioElement.loop=t.loop,logger$3.print("_playAudioFile()","url=".concat(e,";loop=").concat(t.loop)),r._audioElement.oncanplay=function(){logger$3.print("_playAudioFile()","oncanplay"),n()},r._audioElement.onerror=function(e){var t,n;i(new SDKError(ErrorCode.LOAD_RESOURCES_FAILED,"audio error: ".concat(e.message||(null===(t=r._audioElement)||void 0===t||null===(n=t.error)||void 0===n?void 0:n.message))))}}))}},{key:"_destroyAudioElement",value:function(){this._audioElement&&(logger$3.print("_destroyAudioElement()","Invoke"),this._audioElement.src="",delete this._audioElement,this._audioCaptureAndRecoderResolve&&this._audioCaptureAndRecoderResolve())}},{key:"_startEmitAudioPlaybackDeviceTestVolume",value:function(e){var t=this;e=Math.max(e,100),this._audioElement&&(logger$3.print("_startEmitAudioPlaybackDeviceTestVolume()","start timer(".concat(e,"ms)")),this._audioLevelFetcher=new AudioLevelFetcher(this._audioElement),this._playbackDeviceTestTimer=self.setInterval((function(){t._audioLevelFetcher&&t.emit("onAudioPlaybackDeviceTestVolume",t._audioLevelFetcher.getAudioLevel())}),e))}},{key:"_stopEmitAudioPlaybackDeviceTestVolume",value:function(){var e;void 0!==this._playbackDeviceTestTimer&&(logger$3.print("_stopEmitAudioPlaybackDeviceTestVolume()","stop timer"),self.clearInterval(this._playbackDeviceTestTimer),delete this._playbackDeviceTestTimer),null===(e=this._audioLevelFetcher)||void 0===e||e.destroy(),delete this._audioLevelFetcher}},{key:"_startAudioCaptureAndRecoder",value:(t=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){var r,n=this;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,createMicrophoneAudioTrack({});case 2:return this._audioTrack=e.sent,r=getMediaStreamByTrack(this._audioTrack.getTrack()),logger$3.print("startAudioDeviceRecordTest()","create microphone track success!"),e.abrupt("return",new Promise((function(e,i){n._mediaRecorder=new MediaRecorder(r),n._mediaRecorder.ondataavailable=function(){var r=_asyncToGenerator(_regeneratorRuntime().mark((function r(o){var a,s;return _regeneratorRuntime().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(!n._isAudioDeviceRecordTesting){r.next=16;break}return logger$3.print("startAudioDeviceRecordTest()","get recorded file."),s=new Blob([o.data]),r.prev=3,r.next=6,n._playAudioFile(URL.createObjectURL(s),{loop:!1});case 6:r.next=11;break;case 8:return r.prev=8,r.t0=r.catch(3),r.abrupt("return",i(r.t0));case 11:n._startEmitAudioPlaybackDeviceTestVolume(t),null===(a=n._audioElement)||void 0===a||a.addEventListener("ended",(function(){n.stopAudioDevicePlayTest(),e()})),n._audioCaptureAndRecoderResolve=e,r.next=17;break;case 16:e();case 17:case"end":return r.stop()}}),r,null,[[3,8]])})));return function(e){return r.apply(this,arguments)}}(),n._mediaRecorder.onerror=function(e){i(new SDKError(ErrorCode.AUDIO_DEVICE_TEST_FAILED,e.message||"mediaRecorder error"))},n._mediaRecorder.start()})));case 6:case"end":return e.stop()}}),e,this)}))),function(e){return t.apply(this,arguments)})},{key:"_stopAudioCaptureAndRecoder",value:function(){var e;this._mediaRecorder&&("recording"===this._mediaRecorder.state&&this._mediaRecorder.stop(),delete this._mediaRecorder),null===(e=this._audioTrack)||void 0===e||e.close(),delete this._audioTrack}}]),o}(),AudioProfileManager=function(){function e(){_classCallCheck(this,e),_defineProperty(this,"engineBAC",{adm:{},agc:{},ans:{}}),_defineProperty(this,"engineANM",{}),_defineProperty(this,"bitrate",void 0),_defineProperty(this,"sampleRate",void 0),_defineProperty(this,"channel",void 0),_defineProperty(this,"aec",void 0),_defineProperty(this,"agc",void 0),_defineProperty(this,"ans",void 0),this._init()}var t;return _createClass(e,[{key:"_init",value:(t=_asyncToGenerator(_regeneratorRuntime().mark((function e(){var t;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=new MultiConfigRequestManager,e.next=3,t.getAudioProfile();case 3:this.engineBAC=e.sent;case 4:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})},{key:"updateEngineBAC",value:function(e){e&&(this.engineBAC={codec:this.engineBAC.codec,adm:_objectSpread2(_objectSpread2({},this.engineBAC.adm),e.adm)},this.setAEC(!!e.aec),this.setAGC(!!e.agc))}},{key:"updateEngineANM",value:function(e){e&&(this.engineANM=e)}},{key:"setAudioProfile",value:function(e){var t,r,n;switch(e){case AudioProfileType.fluent:r=16e3,t=24e3;break;case AudioProfileType.standard:r=48e3,t=48e3;break;case AudioProfileType.hd:r=48e3,t=128e3,n=2;break;case AudioProfileType.standardStereo:r=48e3,t=8e4,n=2;break;case AudioProfileType.hdMono:r=48e3,t=128e3}t&&(this.bitrate=t),n&&(this.channel=n),r&&(this.sampleRate=r)}},{key:"setBitrate",value:function(e){e>128e3&&(e=128e3),this.bitrate=e}},{key:"setAEC",value:function(e){this.aec=e}},{key:"setAGC",value:function(e){this.agc=e}},{key:"setANS",value:function(e){this.ans=e}},{key:"getOpusConfigStr",value:function(){var e=";",t=this.config;return t.bitrate&&(e+="maxaveragebitrate=".concat(t.bitrate,";")),t.sampleRate&&(e+="sprop-maxcapturerate=".concat(t.sampleRate,";")),t.playbackRate&&(e+="maxplaybackrate=".concat(t.playbackRate,";")),t.channel&&t.channel>1&&(e+="sprop-stereo=1;"),t.playChannel&&t.playChannel>1&&(e+="stereo=1;"),e.slice(0,-1)}},{key:"config",get:function(){var e,t,r,n,i,o,a,s,c,u,l,d,p;return{bitrate:this.bitrate||(null===(e=this.engineANM.enc_param)||void 0===e?void 0:e.bitrate)||0,playChannel:(null===(t=this.engineBAC.adm)||void 0===t||null===(r=t.play)||void 0===r?void 0:r.chn)||1,channel:this.channel||(null===(n=this.engineBAC.adm)||void 0===n||null===(i=n.record)||void 0===i?void 0:i.chn)||(null===(o=this.engineANM)||void 0===o||null===(a=o.enc_param)||void 0===a?void 0:a.chn),aec:this.aec,agc:this.agc,ans:this.ans,sampleRate:this.sampleRate||(null===(s=this.engineBAC.adm)||void 0===s||null===(c=s.record)||void 0===c?void 0:c.sr)||(null===(u=this.engineBAC.codec)||void 0===u?void 0:u.enc_fs)||(null===(l=this.engineANM.enc_param)||void 0===l?void 0:l.sr),playbackRate:null===(d=this.engineBAC.adm)||void 0===d||null===(p=d.play)||void 0===p?void 0:p.sr}}}]),e}(),logger$2=new Logger("VideoSnapshot",1),getPlayingVideoDom=function(e){var t=null==e?void 0:e.domElement;if(t&&!t.paused&&4===t.readyState)return t},takeSnapshot=function(){var e=_asyncToGenerator(_regeneratorRuntime().mark((function e(t,r,n){var i,o,a,s,c,u,l,d;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(i=document.createElement("canvas"),o=i.getContext("2d")){e.next=4;break}throw new Error("canvas.getContext error");case 4:if(a=function(e,t,n){return t=t||e.width,n=n||e.height,i.width=t,i.height=n,r?o.setTransform(-1,0,0,1,t,0):o.setTransform(1,0,0,1,0,0),o.drawImage(e,0,0,t,n),o.getImageData(0,0,t,n)},s=Date.now(),!(c=getPlayingVideoDom(n))){e.next=16;break}return logger$2.print("takeSnapshot","VideoPlayer already set."),e.next=11,a(c,c.videoWidth,c.videoHeight);case 11:return u=e.sent,logger$2.print("takeSnapshot","success, cost ".concat(Date.now()-s,"ms")),e.abrupt("return",u);case 16:if(!window.ImageCapture){e.next=29;break}if("live"!==(l=new window.ImageCapture(t)).track.readyState||!l.track.enabled||l.track.muted){e.next=29;break}return logger$2.print("takeSnapshot","use ImageCapture"),e.t0=a,e.next=23,l.grabFrame();case 23:return e.t1=e.sent,e.next=26,(0,e.t0)(e.t1);case 26:return d=e.sent,logger$2.print("takeSnapshot","success, cost ".concat(Date.now()-s,"ms")),e.abrupt("return",d);case 29:return logger$2.print("takeSnapshot","use temp video"),e.abrupt("return",new Promise((function(e,r){var n=new MediaStream([t]),i=document.createElement("video");i.setAttribute("playsinline",""),i.muted=!0,document.body.appendChild(i),i.onplaying=function(){var r=a(i,i.videoWidth,i.videoHeight);logger$2.print("takeSnapshot","success, cost ".concat(Date.now()-s,"ms")),e(r),n.removeTrack(t),i.srcObject=null,i.load()},i.onerror=r,i.srcObject=n,i.play()})));case 31:case"end":return e.stop()}}),e)})));return function(t,r,n){return e.apply(this,arguments)}}(),__defProp=Object.defineProperty,__getOwnPropDesc=Object.getOwnPropertyDescriptor,__decorateClass=function(e,t,r,n){for(var i,o=n>1?void 0:n?__getOwnPropDesc(t,r):t,a=e.length-1;a>=0;a--)(i=e[a])&&(o=(n?i(t,r,o):i(o))||o);return n&&o&&__defProp(t,r,o),o},logger$1=new Logger("Engine",0),RTCEngine=function(e){_inherits(de,EnhancedEventEmitter);var t,r,n,i,o,a,s,c,u,l,d,p,_,f,h,m,y,v,S,g,E,T,b,R,I,$,A,C,O,P,k,w,N,D,M,x,L,U,F,B,V,j,G,H,K,z,Y,W,q,X,Z,J,Q,ee,te,re,ne,ie,oe,ae,se,ce,ue,le=_createSuper(de);function de(e,t){var r;return _classCallCheck(this,de),_defineProperty(_assertThisInitialized(r=le.call(this)),"_room",void 0),_defineProperty(_assertThisInitialized(r),"_outsideRoom",void 0),_defineProperty(_assertThisInitialized(r),"_appId",void 0),_defineProperty(_assertThisInitialized(r),"_businessId",void 0),_defineProperty(_assertThisInitialized(r),"_visibility",!0),_defineProperty(_assertThisInitialized(r),"_localVideoTrack",void 0),_defineProperty(_assertThisInitialized(r),"_localAudioTrack",void 0),_defineProperty(_assertThisInitialized(r),"_localImgVideoTrack",void 0),_defineProperty(_assertThisInitialized(r),"_localImgScreenTrack",void 0),_defineProperty(_assertThisInitialized(r),"_localScreenVideoTrack",void 0),_defineProperty(_assertThisInitialized(r),"_localScreenAudioTrack",void 0),_defineProperty(_assertThisInitialized(r),"_tempMixingAudioTrack",void 0),_defineProperty(_assertThisInitialized(r),"_localAudioTrackVolume",void 0),_defineProperty(_assertThisInitialized(r),"_localScreenAudioTrackVolume",void 0),_defineProperty(_assertThisInitialized(r),"_remoteAudioTrackVolumeMap",new Map),_defineProperty(_assertThisInitialized(r),"_remoteScreenAudioTrackVolumeMap",new Map),_defineProperty(_assertThisInitialized(r),"_remotePublicAudioTrackVolumeMap",new Map),_defineProperty(_assertThisInitialized(r),"_audioPlaybackDeviceId",void 0),_defineProperty(_assertThisInitialized(r),"_videoPlayer",void 0),_defineProperty(_assertThisInitialized(r),"_screenPlayer",void 0),_defineProperty(_assertThisInitialized(r),"_remoteVideoPlayer",new Map),_defineProperty(_assertThisInitialized(r),"_remoteScreenPlayer",new Map),_defineProperty(_assertThisInitialized(r),"_remoteAudioPlayer",new Map),_defineProperty(_assertThisInitialized(r),"_publicStreamAudioPlayer",new Map),_defineProperty(_assertThisInitialized(r),"_publicStreamVideoPlayer",new Map),_defineProperty(_assertThisInitialized(r),"_publicStreamIds",new Map),_defineProperty(_assertThisInitialized(r),"_roomConfig",void 0),_defineProperty(_assertThisInitialized(r),"_videoStreamConstraints",{}),_defineProperty(_assertThisInitialized(r),"_audioStreamConstraints",{}),_defineProperty(_assertThisInitialized(r),"_enableSimulcast",!1),_defineProperty(_assertThisInitialized(r),"_videoStreamEncodeConfig",[defaultVideoEncoderConfig]),_defineProperty(_assertThisInitialized(r),"_screenStreamEncodeConfig",[defaultScreenEncoderConfig]),_defineProperty(_assertThisInitialized(r),"_trackSourceType",void 0),_defineProperty(_assertThisInitialized(r),"_liveTranscodeConfig",void 0),_defineProperty(_assertThisInitialized(r),"_useCloudProxy",void 0),_defineProperty(_assertThisInitialized(r),"_startCloudProxyTimestamp",void 0),_defineProperty(_assertThisInitialized(r),"_localVideoDeviceId",void 0),_defineProperty(_assertThisInitialized(r),"_localAudioDeviceId",void 0),_defineProperty(_assertThisInitialized(r),"_pauseAllSubscribeState",{audio:!1,video:!1}),_defineProperty(_assertThisInitialized(r),"_audioVolumeIndicationTimer",void 0),_defineProperty(_assertThisInitialized(r),"_dummyTimer",void 0),_defineProperty(_assertThisInitialized(r),"_audioPropertiesReportTimer",null),_defineProperty(_assertThisInitialized(r),"_mirrorType",MirrorType.MIRROR_TYPE_RENDER),_defineProperty(_assertThisInitialized(r),"_audioMixingManager",void 0),_defineProperty(_assertThisInitialized(r),"_pubLock",void 0),_defineProperty(_assertThisInitialized(r),"_rtmClient",void 0),_defineProperty(_assertThisInitialized(r),"_messageStatisticsObserver",void 0),_defineProperty(_assertThisInitialized(r),"_tempRoomConfig",void 0),_defineProperty(_assertThisInitialized(r),"_originIceConfigRequestUrls",void 0),_defineProperty(_assertThisInitialized(r),"_originConfigServerUrls",void 0),_defineProperty(_assertThisInitialized(r),"_originLogServerUrl",void 0),_defineProperty(_assertThisInitialized(r),"_audioDeviceManager",new AudioDeviceManager),_defineProperty(_assertThisInitialized(r),"_audioProfileManager",new AudioProfileManager),_defineProperty(_assertThisInitialized(r),"_remoteVideoConfig",new Map),_defineProperty(_assertThisInitialized(r),"_userPriorityMap",new Map),_defineProperty(_assertThisInitialized(r),"_subscribeFallbackOption",SubscribeFallbackOption.DISABLE),_defineProperty(_assertThisInitialized(r),"_cameraCapturing",!1),_defineProperty(_assertThisInitialized(r),"_interruptCameraCapture",!1),_defineProperty(_assertThisInitialized(r),"_micCapturing",!1),_defineProperty(_assertThisInitialized(r),"_interruptMicCapture",!1),_defineProperty(_assertThisInitialized(r),"_config",void 0),_defineProperty(_assertThisInitialized(r),"_updateMixAudioTrack",function(){var e=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){var n,i,o=arguments;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(i=o.length>1&&void 0!==o[1]?o[1]:AudioMixingType.PLAYOUT_AND_PUBLISH,logger$1.print("_updateMixAudioTrack()"),r._localAudioTrack){e.next=5;break}return t&&(r._tempMixingAudioTrack={track:t,type:i}),e.abrupt("return");case 5:if(t?(r._localAudioTrack.mixType=i,r._localAudioTrack.mixedAudioTrack=t):(delete r._localAudioTrack.mixType,delete r._localAudioTrack.mixedAudioTrack),null===(n=r._room)||void 0===n||!n.hasPublished){e.next=9;break}return e.next=9,r._updatePublish();case 9:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}()),_defineProperty(_assertThisInitialized(r),"_onAudioMixingMessage",(function(e){r.safeEmit(EngineEventsTypes.onAudioMixingStateChanged,e)})),_defineProperty(_assertThisInitialized(r),"_onAudioMixingAutoplayFailed",(function(){r.safeEmit(EngineEventsTypes.onAutoplayFailed,{})})),r._appId=e,r._pubLock=new PromiseLock("pubLock"),r._addDeviceEventHandler(),r._audioMixingManager=new AudioMixingManager({getLocalAudioTrack:function(){return r._localAudioTrack},updateLocalAudioTrack:r._updateMixAudioTrack,emitMessage:r._onAudioMixingMessage,onAutoPlayFailed:r._onAudioMixingAutoplayFailed}),window.__rtc_engine__=_assertThisInitialized(r),window["__rtc_engine__".concat(Math.floor(100*Math.random()+1))]=_assertThisInitialized(r),r._trackSourceType={video:VideoSourceType.VIDEO_SOURCE_TYPE_INTERNAL,screenVideo:VideoSourceType.VIDEO_SOURCE_TYPE_INTERNAL,audio:AudioSourceType.AUDIO_SOURCE_TYPE_INTERNAL,screenAudio:AudioSourceType.AUDIO_SOURCE_TYPE_INTERNAL},r._config=t,r._rtmClient=new RTMClient(e),r._handleRTMClient(r._rtmClient),r._useCloudProxy=!1,r._handleAudioDeviceManager(),r._messageStatisticsObserver=new MessageStatisticsObserver,r}return _createClass(de,[{key:"appId",get:function(){return this._appId},set:function(e){this._appId=e}},{key:"updateToken",value:(ue=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){var r,n,i,o,a,s,c;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(logger$1.print("updateToken()","token: %s",t),checkString(t,"token"),!(this.waitForNewToken&&null!==(r=this._room)&&void 0!==r&&r._roomInfo&&this._tempRoomConfig)){e.next=9;break}return o=null===(i=this._room)||void 0===i?void 0:i._roomInfo,a=o.roomId,s=o.userInfo,c=this._tempRoomConfig,delete this._tempRoomConfig,e.next=8,this.joinRoom(t,a,s,c);case 8:return e.abrupt("return",e.sent);case 9:if(this._room){e.next=11;break}throw new SDKError(ErrorCode.UPDATE_TOKEN_BEFORE_JOIN,"update token before join room");case 11:return e.next=13,null===(n=this._room)||void 0===n?void 0:n.updateToken(t);case 13:case"end":return e.stop()}}),e,this)}))),function(e){return ue.apply(this,arguments)})},{key:"setVideoCaptureDevice",value:(ce=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){var r,n;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(logger$1.print("setVideoCaptureDevice()","deviceId: %s",t),checkString(t,"deviceId"),this._localVideoDeviceId=t,this._localVideoTrack){e.next=5;break}return e.abrupt("return");case 5:return r=this._videoStreamConstraints,"user"===t||"environment"===t||"left"===t||"right"===t?(delete r.deviceId,r.facingMode=t):r.deviceId={exact:t},this._videoStreamConstraints=r,e.next=10,createCameraVideoTrack(r);case 10:if(n=e.sent,this._initLocalTrackEvents(n),this._localVideoTrack.close(),this._localVideoTrack=n,this._videoPlayer&&this._videoPlayer.played&&(this._videoPlayer.stop(),this._videoPlayer.playVideo(n),this._videoPlayer.mirror(!!this._mirrorType)),this._room){e.next=17;break}return e.abrupt("return");case 17:if(!this._room.hasPublished){e.next=20;break}return e.next=20,this._updatePublish();case 20:case"end":return e.stop()}}),e,this)}))),function(e){return ce.apply(this,arguments)})},{key:"setAudioCaptureDevice",value:(se=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){var r,n;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(logger$1.print("setAudioCaptureDevice()","deviceId: %s",t),checkString(t,"deviceId"),this._localAudioDeviceId=t,this._localAudioTrack){e.next=5;break}return e.abrupt("return");case 5:return(r=this._audioStreamConstraints).deviceId={exact:t},this._audioStreamConstraints=r,this._localAudioTrack.close(),e.next=11,createMicrophoneAudioTrack(r,this._audioProfileManager);case 11:if(n=e.sent,void 0!==this._localAudioTrackVolume&&n.setCaptureVolume(this._localAudioTrackVolume),this._initLocalTrackEvents(n),this._localAudioTrack=n,this._room){e.next=17;break}return e.abrupt("return");case 17:if(!this._room.hasPublished){e.next=20;break}return e.next=20,this._updatePublish();case 20:case"end":return e.stop()}}),e,this)}))),function(e){return se.apply(this,arguments)})},{key:"_addDeviceEventHandler",value:function(){detector.on(EngineEventsTypes.onVideoDeviceStateChanged,this._onVideoDeviceStateChange.bind(this)),detector.on(EngineEventsTypes.onAudioDeviceStateChanged,this._onAudioDeviceStateChange.bind(this))}},{key:"_addHandlerEventHandler",value:function(){var e,t,r,n,i,o,a,s,c,u,l,d,p,_,f,h,m,y,v,S,g,E,T,b,R,I,$,A,C,O,P=this;null===(e=this._room)||void 0===e||e.on(SignalEvent.ON_ADD_STREAM,this._onAddStream.bind(this)),null===(t=this._room)||void 0===t||t.on(SignalEvent.ON_REMOVE_STREAM,this._onRemoveStream.bind(this)),null===(r=this._room)||void 0===r||r.on(SignalEvent.USER_CONNECTION,this._onUserConnection.bind(this)),null===(n=this._room)||void 0===n||n.on(RoomEvent.ON_USER_LEAVE,this._onUserLeave.bind(this)),null===(i=this._room)||void 0===i||i.on(RoomEvent.ON_ROOM_ERROR,this._onRoomError.bind(this)),null===(o=this._room)||void 0===o||o.on(RoomEvent.ON_NETWORK_QUALITY,this._onNetworkQuality.bind(this)),null===(a=this._room)||void 0===a||a.on(SignalEvent.ON_CUSTOM_MESSAGE,this._onCustomMessage.bind(this)),null===(s=this._room)||void 0===s||s.on(SignalEvent.USER_MESSAGE_RECEIVED,this._onUserMessageReceived.bind(this)),null===(c=this._room)||void 0===c||c.on(SignalEvent.USER_BINARY_MESSAGE_RECEIVED,this._onUserBinaryMessageReceived.bind(this)),null===(u=this._room)||void 0===u||u.on(SignalEvent.ON_USER_TOKEN_WILL_EXPIRE,this._onUserTokenWillExpire.bind(this)),null===(l=this._room)||void 0===l||l.on(SignalEvent.POST_PROCESSING_MESSAGE,(function(e){"2.0"===e.protocol?P._onStreamMixingEvent({error:e.error,event:e.eventType,message:e.message}):"publicStreamCallback"===e.type?P._onPushPublicStreamResult(e):"transcodeStatusCallback"===e.type&&P._onLiveTranscodingResult(e)})),null===(d=this._room)||void 0===d||d.on(StateEvent.ON_CONNECTION_STATE_CHANGE,this._onConnectionStateChange.bind(this)),null===(p=this._room)||void 0===p||p.on(RoomEvent.RESUBSCRIBE,this._onResubscribe.bind(this)),null===(_=this._room)||void 0===_||_.on(RoomEvent.SUBSCRIBE_PUSH_TRACK,this._onSubscribePushTrack.bind(this)),null===(f=this._room)||void 0===f||f.on(RoomEvent.REMOVE_PUSH_TRACK,this._onRemovePushTrack.bind(this)),null===(h=this._room)||void 0===h||h.on(RoomEvent.VIDEO_FIRST_FRAME,this._onVideoFirstFrameDecoded.bind(this)),null===(m=this._room)||void 0===m||m.on(RoomEvent.ON_PUBLISH_RESULT,(function(e){var t;null!==(t=P._room)&&void 0!==t&&t._roomConfig.isAutoPublish&&P.safeEmit(EngineEventsTypes.onAutoPublishResult,e)})),null===(y=this._room)||void 0===y||y.on(RoomEvent.ON_REMOTE_STREAM_STATS,(function(e){P.safeEmit(EngineEventsTypes.onRemoteStreamStats,e)})),null===(v=this._room)||void 0===v||v.on(RoomEvent.ON_LOCAL_STREAM_STATS,(function(e){P.safeEmit(EngineEventsTypes.onLocalStreamStats,e)})),null===(S=this._room)||void 0===S||S.on(RoomEvent.ON_USER_PUBLISH_STATE_CHANGE,this._onUserPublishStateChange.bind(this)),null===(g=this._room)||void 0===g||g.on(RoomEvent.ON_USER_START_AUDIO_CAPTURE,(function(e){var t=e.userId;P.safeEmit(EngineEventsTypes.onUserStartAudioCapture,{userId:t})})),null===(E=this._room)||void 0===E||E.on(RoomEvent.ON_USER_STOP_AUDIO_CAPTURE,(function(e){var t=e.userId;P.safeEmit(EngineEventsTypes.onUserStopAudioCapture,{userId:t})})),null===(T=this._room)||void 0===T||T.on(RoomEvent.ON_USER_START_VIDEO_CAPTURE,(function(e){var t=e.userId;P.safeEmit(EngineEventsTypes.onUserStartVideoCapture,{userId:t})})),null===(b=this._room)||void 0===b||b.on(RoomEvent.ON_USER_STOP_VIDEO_CAPTURE,(function(e){var t=e.userId;P.safeEmit(EngineEventsTypes.onUserStopVideoCapture,{userId:t})})),null===(R=this._room)||void 0===R||R.on(RoomEvent.ON_SEI_MESSAGED_RECEIVED,(function(e){P.safeEmit(EngineEventsTypes.onSEIMessageReceived,e)})),null===(I=this._room)||void 0===I||I.on(RoomEvent.ON_REMOTE_VIDEO_SIZE_CHANGED,(function(e,t){P.safeEmit(EngineEventsTypes.onRemoteVideoSizeChanged,e,t)})),null===($=this._room)||void 0===$||$.on(RoomEvent.ON_SIMULCAST_SUBSCRIBE_FALLBACK,(function(e){return P.safeEmit(EngineEventsTypes.onSimulcastSubscribeFallback,e)})),null===(A=this._room)||void 0===A||A.on(RoomEvent.RECONNECT_FAILED,(function(){P.safeEmit(EngineEventsTypes.onError,{errorCode:ErrorCode.RECONNECT_FAILED})})),null===(C=this._room)||void 0===C||C.on(RoomEvent.ON_VIDEO_STREAM_BANNED,(function(e){P.safeEmit(EngineEventsTypes.onVideoStreamBanned,{uid:e.uid,banned:e.banned})})),null===(O=this._room)||void 0===O||O.on(RoomEvent.ON_AUDIO_STREAM_BANNED,(function(e){P.safeEmit(EngineEventsTypes.onAudioStreamBanned,{uid:e.uid,banned:e.banned})}))}},{key:"safeEmit",value:function(e){for(var t,r=arguments.length,n=new Array(r>1?r-1:0),i=1;i<r;i++)n[i-1]=arguments[i];return isReportCallback(e)&&reportRtcSdkCallback(e,reportParamsCheck(n)),(t=_get(_getPrototypeOf(de.prototype),"safeEmit",this)).call.apply(t,[this,e].concat(n))}},{key:"_removeHandlerEventHandler",value:function(){var e;null===(e=this._room)||void 0===e||e.removeAllListeners()}},{key:"joinRoom",value:(ae=_asyncToGenerator(_regeneratorRuntime().mark((function e(t,r,n,i){var o,a,s;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(logger$1.print("joinRoom()","token: %o roomId: %o, userInfo: %o, roomConfig: %o",t,r,n,i),isEmpty(t)||checkString(t,"token"),checkRoomId(r),checkUserInfo(n),o={isAutoPublish:!0,isAutoSubscribeAudio:!0,isAutoSubscribeVideo:!0,roomProfileType:RoomProfileType.communication},assignIn$1(o,i),checkRoomConfig(o),!this._room||this._room.connectionState===MediaConnectionState.DISCONNECTED){e.next=11;break}throw new SDKError(ErrorCode.REPEAT_JOIN,"Already joined");case 11:return this._room=new Room(i,{audioProfileManager:this._audioProfileManager}),this._room.userPriorityMap=this._userPriorityMap,this._room.subscribeFallbackOption=this._subscribeFallbackOption,this._addHandlerEventHandler(),a=this._liveTranscodeConfig&&getTranscodeControlMessage("started",this._liveTranscodeConfig),e.prev=16,this._useCloudProxy&&(this._startCloudProxyTimestamp=Date.now()),e.next=20,this._room.join(this._appId,r,t,_objectSpread2(_objectSpread2({},n),{},{businessId:this._businessId,role:this._visibility?UserRole.NORMAL_USER:UserRole.SILENT_USER}),a,this._useCloudProxy);case 20:return s=e.sent,this._roomConfig=i,this._tempRoomConfig&&delete this._tempRoomConfig,null!=i&&i.isAutoPublish&&(this._visibility?this._updatePublish({invokeByJoinRoom:!0,mediaType:MediaType.AUDIO_AND_VIDEO}):this.safeEmit(EngineEventsTypes.onAutoPublishResult,{isScreen:!1,state:PublishState.PUBLISH_FAIL})),e.abrupt("return",s);case 27:throw e.prev=27,e.t0=e.catch(16),e.t0.code===ErrorCode.INVALID_TOKEN&&(this._tempRoomConfig=i),e.t0;case 31:case"end":return e.stop()}}),e,this,[[16,27]])}))),function(e,t,r,n){return ae.apply(this,arguments)})},{key:"leaveRoom",value:(oe=_asyncToGenerator(_regeneratorRuntime().mark((function e(){var t,r,n,i=arguments;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=i.length>0&&void 0!==i[0]&&i[0],logger$1.print("leaveRoom()"),!t){e.next=7;break}return e.next=5,null===(r=this._room)||void 0===r?void 0:r.leave(t);case 5:e.next=8;break;case 7:null===(n=this._room)||void 0===n||n.leave(t).catch();case 8:this._removeHandlerEventHandler(),this._liveTranscodeConfig&&this.stopLiveTranscoding(),this._room=void 0,this._remoteAudioPlayer.forEach((function(e){return e.destroy()})),this._remoteAudioPlayer=new Map,this._remoteScreenPlayer.forEach((function(e){return e.destroy()})),this._remoteScreenPlayer=new Map,this._remoteVideoPlayer.forEach((function(e){return e.destroy()})),this._remoteVideoPlayer=new Map,this._roomConfig=void 0,this._publicStreamIds=new Map;case 19:case"end":return e.stop()}}),e,this)}))),function(){return oe.apply(this,arguments)})},{key:"destroy",value:function(){var e,t,r,n,i,o;logger$1.print("destroy()"),this.removeAllListeners(),this._removeHandlerEventHandler(),null===(e=this._room)||void 0===e||e.destroy(),this._room=void 0,null===(t=this._videoPlayer)||void 0===t||t.destroy(),this._videoPlayer=void 0,this._screenPlayer=void 0,this._videoStreamConstraints={},this._audioStreamConstraints={},this._videoStreamEncodeConfig=[defaultVideoEncoderConfig],this._screenStreamEncodeConfig=[defaultScreenEncoderConfig],this._pauseAllSubscribeState={audio:!1,video:!1},this._messageStatisticsObserver.destroy(),clearInterval(this._audioVolumeIndicationTimer),clearInterval(this._dummyTimer),this._audioVolumeIndicationTimer=void 0,this._stopAudioPropertiesReport(),this._localAudioTrack&&(this._localAudioTrack.close(),this._localAudioTrack=void 0),this._localVideoTrack&&(this._localVideoTrack.close(),this._localVideoTrack=void 0),this._localScreenAudioTrack&&(this._localScreenAudioTrack.close(),this._localScreenAudioTrack=void 0),this._localScreenVideoTrack&&(this._localScreenVideoTrack.close(),this._localScreenVideoTrack=void 0),this._localImgVideoTrack&&(this._localImgVideoTrack.stop(),this._localImgVideoTrack=void 0),this._localImgScreenTrack&&(this._localImgScreenTrack.stop(),this._localImgScreenTrack=void 0),this._remoteAudioPlayer.forEach((function(e){return e.destroy()})),this._remoteAudioPlayer=new Map,this._remoteScreenPlayer.forEach((function(e){return e.destroy()})),this._remoteScreenPlayer=new Map,this._remoteVideoPlayer.forEach((function(e){return e.destroy()})),this._remoteVideoPlayer=new Map,this._publicStreamAudioPlayer.forEach((function(e){return e.destroy()})),this._publicStreamAudioPlayer=new Map,this._publicStreamVideoPlayer.forEach((function(e){return e.destroy()})),this._publicStreamVideoPlayer=new Map,this._roomConfig=void 0,this._audioMixingManager.destroy(),this._rtmClient.destroy(),null===(r=this._outsideRoom)||void 0===r||r.destroy(),this._publicStreamIds=new Map,this._audioDeviceManager.destroy(),this._remoteVideoConfig=new Map,this._userPriorityMap.clear(),this._localAudioTrackVolume=100,this._localScreenAudioTrackVolume=100,null===(n=this._remoteAudioTrackVolumeMap)||void 0===n||n.clear(),null===(i=this._remoteScreenAudioTrackVolumeMap)||void 0===i||i.clear(),null===(o=this._remotePublicAudioTrackVolumeMap)||void 0===o||o.clear(),this._cameraCapturing=!1,this._micCapturing=!1,this._interruptCameraCapture=!1,this._interruptMicCapture=!1}},{key:"publishStream",value:(ie=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return logger$1.print("publishStream()","mediaType: %o",t),this._checkMediaType(t),this._assertNotInRoom(),videoInMediaType(t)&&!this._localVideoTrack&&this._localImgVideoTrack&&(this._localVideoTrack=createDummyVideoLocalTrack(this._localImgVideoTrack),this._localVideoTrack.dummy=!0),e.next=6,this._updatePublish({mediaType:t});case 6:case"end":return e.stop()}}),e,this)}))),function(e){return ie.apply(this,arguments)})},{key:"unpublishStream",value:(ne=_asyncToGenerator(_regeneratorRuntime().mark((function e(t,r){var n;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(logger$1.print("unpublishStream()","mediaType: %o",t),this._checkMediaType(t),this._assertNotInRoom(),!r){e.next=5;break}return e.abrupt("return",null===(n=this._room)||void 0===n?void 0:n.unpublish());case 5:return e.next=7,this._updatePublish({mediaType:t,pubState:PubState.UNPUB});case 7:case"end":return e.stop()}}),e,this)}))),function(e,t){return ne.apply(this,arguments)})},{key:"publishScreen",value:(re=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return logger$1.print("publishScreen()","mediaType: %o",t),this._checkMediaType(t),this._assertNotInRoom(),e.prev=3,videoInMediaType(t)&&!this._localScreenVideoTrack&&this._localImgScreenTrack&&(this._localScreenVideoTrack=createDummyScreenVideoLocalTrack(this._localImgScreenTrack),this._localScreenVideoTrack.dummy=!0),e.next=7,this._updateScreenPublish({mediaType:t,pubState:PubState.PUB});case 7:e.next=16;break;case 9:if(e.prev=9,e.t0=e.catch(3),!(e.t0 instanceof SDKError)){e.next=15;break}throw e.t0;case 15:throw new SDKError(ErrorCode.UNEXPECTED_ERROR,"unexpected error",e.t0);case 16:case"end":return e.stop()}}),e,this,[[3,9]])}))),function(e){return re.apply(this,arguments)})},{key:"unpublishScreen",value:(te=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return logger$1.print("unpublishScreen()","mediaType: %o",t),this._checkMediaType(t),this._assertNotInRoom(),e.next=5,this._updateScreenPublish({mediaType:t,pubState:PubState.UNPUB});case 5:case"end":return e.stop()}}),e,this)}))),function(e){return te.apply(this,arguments)})},{key:"subscribeStream",value:(ee=_asyncToGenerator(_regeneratorRuntime().mark((function e(t,r){return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return logger$1.print("subscribeStream()","userId: %o, mediaType: %o",t,r),e.abrupt("return",this._subscribe(!1,t,r));case 2:case"end":return e.stop()}}),e,this)}))),function(e,t){return ee.apply(this,arguments)})},{key:"_subscribe",value:(Q=_asyncToGenerator(_regeneratorRuntime().mark((function e(t,r,n){var i,o,a,s,c,u,l,d,p,_;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._checkMediaType(n),this._assertNotInRoom(),s=this._room.remoteStreams.get(r),c=null==s?void 0:s.find((function(e){return e.isScreen===t}))){e.next=6;break}throw new SDKError(ErrorCode.STREAM_NOT_EXIST,"stream not exist");case 6:return this._pauseAllSubscribeState.audio&&(n-=n&MediaType.AUDIO),this._pauseAllSubscribeState.video&&(n-=n&MediaType.VIDEO),logger$1.print("subscribeStream()","due to pauseAll mediaType: %o",n),u=c.hasSubscribed,l=this._remoteVideoConfig.get(r)||(null===(i=this._roomConfig)||void 0===i?void 0:i.remoteVideoConfig),c.originalMediaType=n,e.next=14,this._room.subscribe(c,n,l);case 14:audioInMediaType(n)&&this._updateAudioPlayerState(c),videoInMediaType(n)&&this._updateVideoPlayerState(c),!t&&(null!==(o=this._roomConfig)&&void 0!==o&&o.isAutoSubscribeAudio||null!==(a=this._roomConfig)&&void 0!==a&&a.isAutoSubscribeVideo)&&(c.audioTrack||c.videoTrack)&&(d={userId:r,isScreen:!1,state:SubscribeState.SUBSCRIBE_SUCC},this.safeEmit(EngineEventsTypes.onAutoSubscribeResult,d)),!u&&audioInMediaType(n)&&c.hasAudio&&(null===(p=c.observer)||void 0===p||p.setSubscribeAudio(!0)),!u&&videoInMediaType(n)&&c.hasVideo&&(null===(_=c.observer)||void 0===_||_.setSubscribeVideo(!0));case 19:case"end":return e.stop()}}),e,this)}))),function(e,t,r){return Q.apply(this,arguments)})},{key:"unsubscribeStream",value:(J=_asyncToGenerator(_regeneratorRuntime().mark((function e(t,r){var n,i;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(logger$1.print("unsubscribeStream()","userId: %o, mediaType: %o",t,r),this._checkMediaType(r),this._assertNotInRoom(),n=this._room.remoteStreams.get(t),null!=(i=null==n?void 0:n.find((function(e){return!e.isScreen})))&&i.hasSubscribed){e.next=7;break}throw new SDKError(ErrorCode.STREAM_NOT_EXIST,"stream not exist");case 7:this._room.unsubscribe(i,r);case 8:case"end":return e.stop()}}),e,this)}))),function(e,t){return J.apply(this,arguments)})},{key:"subscribeScreen",value:(Z=_asyncToGenerator(_regeneratorRuntime().mark((function e(t,r){return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return logger$1.print("subscribeScreen() userId: %o, mediaType: %o",t,r),e.abrupt("return",this._subscribe(!0,t,r));case 2:case"end":return e.stop()}}),e,this)}))),function(e,t){return Z.apply(this,arguments)})},{key:"unsubscribeScreen",value:(X=_asyncToGenerator(_regeneratorRuntime().mark((function e(t,r){var n,i;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(logger$1.print("unsubscribeScreen() userId: %o, mediaType: %o",t,r),this._checkMediaType(r),this._assertNotInRoom(),n=this._room.remoteStreams.get(t),null!=(i=null==n?void 0:n.find((function(e){return e.isScreen})))&&i.hasSubscribed){e.next=7;break}throw new SDKError(ErrorCode.STREAM_NOT_EXIST,"stream not exist");case 7:this._room.unsubscribe(i,r);case 8:case"end":return e.stop()}}),e,this)}))),function(e,t){return X.apply(this,arguments)})},{key:"setRemoteVideoConfig",value:(q=_asyncToGenerator(_regeneratorRuntime().mark((function e(t,r){var n;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return logger$1.print("setRemoteVideoConfig() userId: %o, remoteVideoConfig: %o",t,r),checkUserId(t),checkRemoteConfig(r),this._remoteVideoConfig.set(t,r),e.abrupt("return",null===(n=this._room)||void 0===n?void 0:n.updateSubVideoConfig(t,r).then((function(){})));case 5:case"end":return e.stop()}}),e,this)}))),function(e,t){return q.apply(this,arguments)})},{key:"startVideoCapture",value:(W=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){var r,n,i,o,a,s,c,u,l,d=this;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(logger$1.print("startVideoCapture()","deviceId: %s",t),isEmpty(t)||checkString(t,"deviceId"),t=t||this._localVideoDeviceId,this._localVideoDeviceId=t,!(this._cameraCapturing||this._localVideoTrack&&!this._localVideoTrack.dummy)){e.next=6;break}throw new SDKError(ErrorCode.REPEAT_CAPTURE,"Has already capture");case 6:return i=this._videoStreamConstraints,t&&("user"===t||"environment"===t||"left"===t||"right"===t?i.facingMode=t:i.deviceId={exact:t},this._videoStreamConstraints=i),o={},e.prev=9,this._cameraCapturing=!0,e.next=13,createCameraVideoTrack(i);case 13:if(s=e.sent,!this._interruptCameraCapture){e.next=18;break}throw this._interruptCameraCapture=!1,s.close(),new SDKError(ErrorCode.INTERRUPT,"interrupt by stopVideoCapture");case 18:this._initLocalTrackEvents(s),this._localVideoTrack=s,null===(a=this._videoPlayer)||void 0===a||a.playVideo(s),(c=null==s?void 0:s.getTrack())&&(o=c.getSettings(),u={width:o.width,height:o.height},this._localVideoTrack.resolution=u,setTimeout((function(){return d.safeEmit(EngineEventsTypes.onLocalVideoSizeChanged,{streamIndex:StreamIndex.STREAM_INDEX_MAIN,info:u})})));case 23:return e.prev=23,this._cameraCapturing=!1,e.finish(23);case 26:if(this._room){e.next=28;break}return e.abrupt("return",o);case 28:return l=this._room._roomConfig.isAutoPublish,(this._room.hasPublished||l)&&(this._visibility?this._updatePublish():this.safeEmit(EngineEventsTypes.onAutoPublishResult,{isScreen:!1,state:PublishState.PUBLISH_FAIL})),null===(r=this._room.localStream)||void 0===r||null===(n=r.observer)||void 0===n||n.setEnableVideo(!0),e.abrupt("return",o);case 32:case"end":return e.stop()}}),e,this,[[9,,23,26]])}))),function(e){return W.apply(this,arguments)})},{key:"stopVideoCapture",value:(Y=_asyncToGenerator(_regeneratorRuntime().mark((function e(){var t,r,n,i,o;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(logger$1.print("stopVideoCapture()"),!this._cameraCapturing){e.next=5;break}return this._interruptCameraCapture=!0,logger$1.print("stopVideoCapture()","capturing"),e.abrupt("return");case 5:if(this._trackSourceType.video!==VideoSourceType.VIDEO_SOURCE_TYPE_EXTERNAL){e.next=7;break}throw new SDKError(ErrorCode.STREAM_TYPE_NOT_MATCH,"setVideoSourceType as internal first");case 7:if(null===(t=this._videoPlayer)||void 0===t||t.stop(),null===(r=this._localVideoTrack)||void 0===r||r.close(),this._localImgVideoTrack&&this._localVideoTrack?(null===(o=this._localVideoTrack)||void 0===o||o.setTrack(this._localImgVideoTrack),this._localVideoTrack.dummy=!0):this._localVideoTrack=void 0,this._room){e.next=12;break}return e.abrupt("return");case 12:if(!this._room.hasPublished){e.next=15;break}return e.next=15,this._updatePublish();case 15:null===(n=this._room.localStream)||void 0===n||null===(i=n.observer)||void 0===i||i.setEnableVideo(!1);case 16:case"end":return e.stop()}}),e,this)}))),function(){return Y.apply(this,arguments)})},{key:"startAudioCapture",value:(z=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){var r,n,i,o,a;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(logger$1.print("startAudioCapture()","deviceId: $o",t),isEmpty(t)||checkString(t,"deviceId"),t=t||this._localAudioDeviceId,this._localAudioDeviceId=t,!this._micCapturing&&!this._localAudioTrack){e.next=6;break}throw new SDKError(ErrorCode.REPEAT_CAPTURE,"Has already capture");case 6:return i=this._audioStreamConstraints,t&&(i.deviceId={exact:t},this._audioStreamConstraints=i),e.prev=8,this._micCapturing=!0,e.next=12,createMicrophoneAudioTrack(i,this._audioProfileManager);case 12:if(o=e.sent,!this._interruptMicCapture){e.next=17;break}throw this._interruptMicCapture=!1,o.close(),new SDKError(ErrorCode.INTERRUPT,"interrupt by stopAudioCapture");case 17:this._initLocalTrackEvents(o),this._localAudioTrack=o,this._tempMixingAudioTrack&&(this._localAudioTrack.mixType=this._tempMixingAudioTrack.type,this._localAudioTrack.mixedAudioTrack=this._tempMixingAudioTrack.track,delete this._tempMixingAudioTrack),void 0!==this._localAudioTrackVolume&&this._localAudioTrack.setCaptureVolume(this._localAudioTrackVolume);case 21:return e.prev=21,this._micCapturing=!1,e.finish(21);case 24:if(this._room){e.next=26;break}return e.abrupt("return");case 26:a=this._room._roomConfig.isAutoPublish,(this._room.hasPublished||a)&&(this._visibility?this._updatePublish():this.safeEmit(EngineEventsTypes.onAutoPublishResult,{isScreen:!1,state:PublishState.PUBLISH_FAIL})),null===(r=this._room.localStream)||void 0===r||null===(n=r.observer)||void 0===n||n.setEnableAudio(!0);case 29:case"end":return e.stop()}}),e,this,[[8,,21,24]])}))),function(e){return z.apply(this,arguments)})},{key:"stopAudioCapture",value:(K=_asyncToGenerator(_regeneratorRuntime().mark((function e(){var t,r,n;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(logger$1.print("stopAudioCapture()"),!this._micCapturing){e.next=5;break}return this._interruptMicCapture=!0,logger$1.print("stopAudioCapture()","capturing"),e.abrupt("return");case 5:if(null===(t=this._localAudioTrack)||void 0===t||t.close(),this._localAudioTrack=void 0,this._audioMixingManager.stopAll(),this._trackSourceType.audio!==AudioSourceType.AUDIO_SOURCE_TYPE_EXTERNAL){e.next=10;break}throw new SDKError(ErrorCode.STREAM_TYPE_NOT_MATCH,"setAudioSourceType as internal first");case 10:if(this._room){e.next=12;break}return e.abrupt("return");case 12:if(!this._room.hasPublished){e.next=15;break}return e.next=15,this._updatePublish();case 15:null===(r=this._room.localStream)||void 0===r||null===(n=r.observer)||void 0===n||n.setEnableAudio(!1);case 16:case"end":return e.stop()}}),e,this)}))),function(){return K.apply(this,arguments)})},{key:"getAudioMixingManager",value:function(){return logger$1.print("getAudioMixingManager()"),this._audioMixingManager}},{key:"startScreenCapture",value:(H=_asyncToGenerator(_regeneratorRuntime().mark((function e(){var t,r,n,i,o,a,s,c,u,l,d,p,_,f,h,m,y,v=this,S=arguments;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(c=S.length>0&&void 0!==S[0]?S[0]:{},logger$1.print("startScreenCapture()","config: %o",c),!this._localScreenVideoTrack||null!==(t=this._localScreenVideoTrack)&&void 0!==t&&t.dummy||(u=this._localScreenVideoTrack),l=c.enableAudio,d=void 0!==l&&l,this._trackSourceType.screenVideo!==VideoSourceType.VIDEO_SOURCE_TYPE_EXTERNAL){e.next=6;break}throw new SDKError(ErrorCode.STREAM_TYPE_NOT_MATCH,"setVideoSourceType as internal first");case 6:if(this._trackSourceType.screenAudio!==AudioSourceType.AUDIO_SOURCE_TYPE_EXTERNAL){e.next=8;break}throw new SDKError(ErrorCode.STREAM_TYPE_NOT_MATCH,"setAudioSourceType as internal first");case 8:return e.next=10,createScreenStream(d,this._screenStreamEncodeConfig[0]);case 10:if(p=e.sent,this._localScreenVideoTrack=new ScreenVideoTrack(p.getVideoTracks()[0],genUuid()),null===(r=u)||void 0===r||r.close(),null===(n=this.localScreenAudioTrack)||void 0===n||n.close(),this._localScreenAudioTrack=void 0,null!==(i=this._screenStreamEncodeConfig[0])&&void 0!==i&&i.contentHint&&this._localScreenVideoTrack.setContentHint(null===(_=this._screenStreamEncodeConfig[0])||void 0===_?void 0:_.contentHint),(f=null===(o=this._localScreenVideoTrack)||void 0===o?void 0:o.getTrack())&&(h=f.getSettings(),m={width:h.width,height:h.height},this._localScreenVideoTrack.resolution=m,setTimeout((function(){return v.safeEmit(EngineEventsTypes.onLocalVideoSizeChanged,{streamIndex:StreamIndex.STREAM_INDEX_SCREEN,info:{width:h.width,height:h.height}})}))),(y=p.getAudioTracks()).length&&(this._localScreenAudioTrack=new ScreenAudioTrack(y[0],genUuid()),this._initLocalTrackEvents(this._localScreenAudioTrack),void 0!==this._localScreenAudioTrackVolume&&this._localScreenAudioTrack.setCaptureVolume(this._localScreenAudioTrackVolume)),null===(a=this._screenPlayer)||void 0===a||a.playVideo(this._localScreenVideoTrack),this._initLocalTrackEvents(this._localScreenVideoTrack,!0),null===(s=this._room)||void 0===s||!s.hasScreenPublished){e.next=25;break}return e.next=25,this._updateScreenPublish();case 25:case"end":return e.stop()}}),e,this)}))),function(){return H.apply(this,arguments)})},{key:"stopScreenCapture",value:(G=_asyncToGenerator(_regeneratorRuntime().mark((function e(){var t,r,n,i;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(logger$1.print("stopScreenCapture()"),null===(t=this._screenPlayer)||void 0===t||t.stop(),null===(r=this._localScreenVideoTrack)||void 0===r||r.close(),this._localImgScreenTrack&&this._localScreenVideoTrack?(this._localScreenVideoTrack.setTrack(this._localImgScreenTrack),this._localScreenVideoTrack.dummy=!0):this._localScreenVideoTrack=void 0,null===(n=this._localScreenAudioTrack)||void 0===n||n.close(),this._localScreenAudioTrack=void 0,null===(i=this._room)||void 0===i||!i.hasScreenPublished){e.next=9;break}return e.next=9,this._updateScreenPublish();case 9:case"end":return e.stop()}}),e,this)}))),function(){return G.apply(this,arguments)})},{key:"setLocalVideoPlayer",value:function(e,t){if(logger$1.print("setLocalVideoPlayer()","streamIndex: %o, videoPlayerOption: %o",e,t),checkEnum(e,"streamIndex",[StreamIndex.STREAM_INDEX_MAIN,StreamIndex.STREAM_INDEX_SCREEN]),t&&t.renderDom){var r,n,i=_objectSpread2({userId:this._getUserId()},t);if(checkVideoPlayerOption(i),e===StreamIndex.STREAM_INDEX_MAIN&&!this._videoPlayer)return this._videoPlayer=new VideoPlayer(i),this._initPlayerEvents(this._videoPlayer),this._videoPlayer.mirror(!!this._mirrorType),this._localVideoTrack&&!this._localVideoTrack.dummy&&(null===(r=this._config)||void 0===r?void 0:r.autoPlayPolicy)!==RTCAutoPlayPolicy.PLAY_MANUALLY&&this._videoPlayer.playVideo(this._localVideoTrack),this._videoPlayer.domElement;if(e===StreamIndex.STREAM_INDEX_SCREEN&&!this._screenPlayer)return this._screenPlayer=new VideoPlayer(_objectSpread2(_objectSpread2({},i),{},{isScreen:!0})),this._initPlayerEvents(this._screenPlayer),this._localScreenVideoTrack&&!this._localScreenVideoTrack.dummy&&(null===(n=this._config)||void 0===n?void 0:n.autoPlayPolicy)!==RTCAutoPlayPolicy.PLAY_MANUALLY&&this._screenPlayer.playVideo(this._localScreenVideoTrack),this._screenPlayer.domElement}else{var o,a;e===StreamIndex.STREAM_INDEX_MAIN?(null===(o=this._videoPlayer)||void 0===o||o.destroy(),delete this._videoPlayer):(null===(a=this._screenPlayer)||void 0===a||a.destroy(),delete this._screenPlayer)}}},{key:"startLiveTranscoding",value:(j=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){var r;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return logger$1.print("startLiveTranscoding()","transcode: %o",t),checkString(t.url,"liveTranscode.url"),this._liveTranscodeConfig=t,e.prev=3,this.safeEmit(EngineEventsTypes.onStreamMixingEvent,{event:StreamMixingEventType.START,error:0,message:""}),e.next=7,null===(r=this._room)||void 0===r?void 0:r.liveControlMessage(getTranscodeControlMessage("started",this._liveTranscodeConfig));case 7:e.next=16;break;case 9:if(e.prev=9,e.t0=e.catch(3),!(e.t0 instanceof SDKError)){e.next=15;break}throw e.t0;case 15:throw new SDKError(ErrorCode.UNEXPECTED_ERROR,"unexpected error",e.t0);case 16:case"end":return e.stop()}}),e,this,[[3,9]])}))),function(e){return j.apply(this,arguments)})},{key:"updateLiveTranscoding",value:(V=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){var r;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(logger$1.print("updateLiveTranscoding()","transcode: %o",t),this._liveTranscodeConfig){e.next=3;break}return e.abrupt("return");case 3:return this._liveTranscodeConfig=assignIn$1(this._liveTranscodeConfig,t),e.prev=4,this.safeEmit(EngineEventsTypes.onStreamMixingEvent,{event:StreamMixingEventType.UPDATE,error:0,message:""}),e.next=8,null===(r=this._room)||void 0===r?void 0:r.liveControlMessage(getTranscodeControlMessage("layoutChanged",this._liveTranscodeConfig));case 8:e.next=17;break;case 10:if(e.prev=10,e.t0=e.catch(4),!(e.t0 instanceof SDKError)){e.next=16;break}throw e.t0;case 16:throw new SDKError(ErrorCode.UNEXPECTED_ERROR,"unexpected error",e.t0);case 17:case"end":return e.stop()}}),e,this,[[4,10]])}))),function(e){return V.apply(this,arguments)})},{key:"stopLiveTranscoding",value:(B=_asyncToGenerator(_regeneratorRuntime().mark((function e(){var t;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(logger$1.print("stopLiveTranscoding()"),this._liveTranscodeConfig){e.next=3;break}return e.abrupt("return");case 3:return delete this._liveTranscodeConfig,e.prev=4,this.safeEmit(EngineEventsTypes.onStreamMixingEvent,{event:StreamMixingEventType.STOP,error:0,message:""}),e.next=8,null===(t=this._room)||void 0===t?void 0:t.liveControlMessage({action:"stopped",type:"transcode"});case 8:e.next=17;break;case 10:if(e.prev=10,e.t0=e.catch(4),!(e.t0 instanceof SDKError)){e.next=16;break}throw e.t0;case 16:throw new SDKError(ErrorCode.UNEXPECTED_ERROR,"unexpected error",e.t0);case 17:case"end":return e.stop()}}),e,this,[[4,10]])}))),function(){return B.apply(this,arguments)})},{key:"setBusinessId",value:function(e){return logger$1.print("setBusinessId()","businessId: %s",e),!illegalBusinessId(e)&&!this._room&&(commonStats.setStats({rtc_business_id:e}),this._businessId=e,!0)}},{key:"setUserVisibility",value:(F=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){var r,n;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(logger$1.print("setUserVisibility()","enable: %o",t),t=!!t,this._visibility!==t){e.next=4;break}return e.abrupt("return");case 4:if(this._room){e.next=7;break}return this._visibility=t,e.abrupt("return");case 7:if(this._room.connectionState===MediaConnectionState.CONNECTED){e.next=9;break}throw new SDKError(ErrorCode.NOT_CONNECTED_YET,"server not connected");case 9:if(this._room.localStream&&(null===(n=this._room.localStream.observer)||void 0===n||n.setPublisher(t)),e.t0=!t,!e.t0){e.next=14;break}return e.next=14,this._room.unpublish();case 14:return e.next=16,this._room.updateUserAttributes({role:t?UserRole.NORMAL_USER:UserRole.SILENT_USER});case 16:this._visibility=t,t&&null!==(r=this._roomConfig)&&void 0!==r&&r.isAutoPublish&&this._updatePublish({mediaType:MediaType.AUDIO_AND_VIDEO});case 18:case"end":return e.stop()}}),e,this)}))),function(e){return F.apply(this,arguments)})},{key:"_initPlayerEvents",value:function(e){var t=this,r=arguments.length>1&&void 0!==arguments[1]&&arguments[1];e.on("playback_event",(function(n){switch(n.eventName){case"timeupdate":return;case"loadeddata":if("audio"===n.type)r?t.safeEmit(EngineEventsTypes.onFirstPublicStreamAudioFrameDecoded,{publicStreamId:e.userId}):t.safeEmit(EngineEventsTypes.onAudioFirstFrameDecoded,{userId:e.userId}),monitor.firstRemoteAudioRender("",n.userId||"");else{var i,o,a={userId:e.userId,height:(null===(i=e.domElement)||void 0===i?void 0:i.videoHeight)||0,width:(null===(o=e.domElement)||void 0===o?void 0:o.videoWidth)||0};r?(a.publicStreamId=a.userId,delete a.userId,t.safeEmit(EngineEventsTypes.onFirstPublicStreamVideoFrameDecoded,a),t.safeEmit(EngineEventsTypes.onFirstPublicStreamVideoFrameRendered,a)):(t.safeEmit(EngineEventsTypes.onVideoFirstFrameDecoded,a),t.safeEmit(EngineEventsTypes.onVideoFirstFrameRendered,a)),monitor.firstRemoteVideoRender("",n.userId||"")}break;case"autoplay-error":return r&&(n.publicStreamId=n.userId),void t.safeEmit(EngineEventsTypes.onAutoplayFailed,{userId:n.userId||n.publicStreamId,kind:e instanceof VideoPlayer?"video":"audio"})}t.safeEmit(EngineEventsTypes.onPlayerEvent,n)}))}},{key:"_initLocalTrackEvents",value:function(e){var t=this,r=arguments.length>1&&void 0!==arguments[1]&&arguments[1];e.on("track-ended",(function(e){var r=!1;e!==t._localScreenAudioTrack&&e!==t._localScreenVideoTrack||(r=!0),t.safeEmit(EngineEventsTypes.onTrackEnded,{kind:e.getTrack().kind,isScreen:r})})),e.on("resolution-change",(function(e){t.safeEmit(EngineEventsTypes.onLocalVideoSizeChanged,{streamIndex:r?StreamIndex.STREAM_INDEX_SCREEN:StreamIndex.STREAM_INDEX_MAIN,info:e})}))}},{key:"setRemoteVideoPlayer",value:function(e,t){logger$1.print("setRemoteVideoPlayer()","streamIndex: %o, videoPlayerOption: %o",e,t),checkEnum(e,"streamIndex",[StreamIndex.STREAM_INDEX_MAIN,StreamIndex.STREAM_INDEX_SCREEN]),checkVideoPlayerOption(t);var r,n,i,o=t.userId;if(e===StreamIndex.STREAM_INDEX_MAIN){var a,s,c;if(null===(a=this._remoteVideoPlayer.get(o))||void 0===a||a.destroy(),!t.renderDom)return;var u=new VideoPlayer(t);this._initPlayerEvents(u),this._remoteVideoPlayer.set(o,u);var l=null===(s=this._room)||void 0===s||null===(c=s.remoteStreams.get(o))||void 0===c?void 0:c.find((function(e){return!e.isScreen}));return l&&this._updateVideoPlayerState(l),u.domElement}if(null===(r=this._remoteScreenPlayer.get(o))||void 0===r||r.destroy(),t.renderDom){var d=new VideoPlayer(_objectSpread2(_objectSpread2({},t),{},{isScreen:!0}));this._remoteScreenPlayer.set(o,d),this._initPlayerEvents(d);var p=null===(n=this._room)||void 0===n||null===(i=n.remoteStreams.get(o))||void 0===i?void 0:i.find((function(e){return e.isScreen}));return p&&this._updateVideoPlayerState(p),d.domElement}}},{key:"setLocalVideoMirrorType",value:function(e){logger$1.print("setLocalVideoMirrorType()","mirrorType: %o",e),checkEnum(e,"mirrorType",[MirrorType.MIRROR_TYPE_NONE,MirrorType.MIRROR_TYPE_RENDER]),this._mirrorType=e,this._videoPlayer&&this._videoPlayer.mirror(!!e)}},{key:"setAudioPlaybackDevice",value:(U=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){var r;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(logger$1.print("setAudioPlaybackDevice()","deviceId: %s",t),checkString(t,"deviceId"),void 0!==HTMLAudioElement.prototype.setSinkId){e.next=5;break}return logger$1.print("setAudioPlaybackDevice failed","setSinkId not supported by current browser"),e.abrupt("return");case 5:return e.next=7,detector.getDeviceById(t);case 7:if(r=e.sent){e.next=10;break}throw new SDKError(ErrorCode.INVALID_DEVICE_ID,"audio playback device id ".concat(t," is invalid"));case 10:this._remoteAudioPlayer.forEach((function(e){e.setPlaybackDevice(t)})),this._audioPlaybackDeviceId=t,r&&this.safeEmit(EngineEventsTypes.onAudioPlaybackDeviceChanged,r),monitor.rtcAudioDevice(RtcaudiodeviceAudioEvent.PLAYOUT_DEVICE_SWITCH,t,0);case 14:case"end":return e.stop()}}),e,this)}))),function(e){return U.apply(this,arguments)})},{key:"play",value:(L=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){var r,n,i,o,a,s,c,u,l;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(logger$1.print("play()","userId | publicStreamId: %s",t),a=null===(r=this._room)||void 0===r||null===(n=r.remoteStreams.get(t||""))||void 0===n?void 0:n.find((function(e){return!e.isScreen})),i=this._remoteAudioPlayer.get(t||""),o=this._remoteVideoPlayer.get(t||""),i||(i=this._publicStreamAudioPlayer.get(t||"")),o||(o=this._publicStreamVideoPlayer.get(t||"")),!t&&this._videoPlayer&&(o=this._videoPlayer),o&&(o.played?o.manuallyPlay():a&&a.videoTrack?o.playVideo(a.videoTrack,a):!t&&this._localVideoTrack&&(o.mirror(!!this._mirrorType),o.playVideo(this._localVideoTrack))),i&&(i.played?i.manuallyPlay():null!=a&&a.audioTrack&&(i.playAudio(a.audioTrack),(c=null==a||null===(s=a.audioTrack._audioLevelFetcher)||void 0===s?void 0:s._ctx)&&c.resume())),null!=a&&a.audioTrack&&(l=null==a||null===(u=a.audioTrack._audioLevelFetcher)||void 0===u?void 0:u._ctx)&&"suspended"===l.state&&l.resume(),t||!this._audioMixingManager){e.next=13;break}return e.next=13,this._audioMixingManager.resumeLocalPlay();case 13:case"end":return e.stop()}}),e,this)}))),function(e){return L.apply(this,arguments)})},{key:"pauseAllSubscribedStream",value:(x=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){var r,n=this;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(logger$1.print("pauseAllSubscribedStream()","mediaType: %o",t),this._checkMediaType(t),!this._pauseAllSubscribeState.audio||!this._pauseAllSubscribeState.video){e.next=4;break}return e.abrupt("return",Promise.resolve());case 4:if(r=function(){audioInMediaType(t)&&(n._pauseAllSubscribeState.audio=!0),videoInMediaType(t)&&(n._pauseAllSubscribeState.video=!0)},this._room){e.next=8;break}return r(),e.abrupt("return",Promise.resolve());case 8:return e.abrupt("return",this._room.pauseAllSubscribedStream(t).then((function(){r()})));case 9:case"end":return e.stop()}}),e,this)}))),function(e){return x.apply(this,arguments)})},{key:"resumeAllSubscribedStream",value:(M=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){var r,n=this;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(logger$1.print("resumeAllSubscribedStream()","mediaType: %o",t),this._checkMediaType(t),this._pauseAllSubscribeState.audio||this._pauseAllSubscribeState.video){e.next=4;break}return e.abrupt("return",Promise.resolve());case 4:if(r=function(){audioInMediaType(t)&&(n._pauseAllSubscribeState.audio=!1),videoInMediaType(t)&&(n._pauseAllSubscribeState.video=!1)},this._room){e.next=8;break}return r(),e.abrupt("return",Promise.resolve());case 8:return e.abrupt("return",this._room.resumeAllSubscribedStream(t).then((function(){var e,t;r(),null===(e=n._room)||void 0===e||null===(t=e.remoteStreams)||void 0===t||t.forEach((function(e){Array.isArray(e)&&e.forEach((function(e){n._updateAudioPlayerState(e),n._updateVideoPlayerState(e)}))}))})));case 9:case"end":return e.stop()}}),e,this)}))),function(e){return M.apply(this,arguments)})},{key:"sendUserMessage",value:(D=_asyncToGenerator(_regeneratorRuntime().mark((function e(t,r){var n,i,o=this;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(checkUserId(t),checkBufferSize(r),this._room&&this._room.connectionState===MediaConnectionState.CONNECTED){e.next=4;break}throw new SDKError(ErrorCode.IM_BEFORE_JOIN,"join first");case 4:return i=Date.now(),e.abrupt("return",null===(n=this._room.sendUserMessage(t,r))||void 0===n?void 0:n.then((function(e){return o._messageStatisticsObserver.countP2PMessage(!0,t,!1,i,e),e.id})).catch((function(e){throw o._messageStatisticsObserver.countP2PMessage(!1,t,!1,i),e})));case 6:case"end":return e.stop()}}),e,this)}))),function(e,t){return D.apply(this,arguments)})},{key:"sendUserBinaryMessage",value:(N=_asyncToGenerator(_regeneratorRuntime().mark((function e(t,r){var n,i,o=this;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(checkUserId(t),checkArrayBuffer(r,"message"),checkBufferSize(r),this._room&&this._room.connectionState===MediaConnectionState.CONNECTED){e.next=5;break}throw new SDKError(ErrorCode.IM_BEFORE_JOIN,"join first");case 5:return i=Date.now(),e.abrupt("return",null===(n=this._room.sendUserMessage(t,r))||void 0===n?void 0:n.then((function(e){return o._messageStatisticsObserver.countP2PMessage(!0,t,!0,i,e),e.id})).catch((function(e){throw o._messageStatisticsObserver.countP2PMessage(!1,t,!0,i),e})));case 7:case"end":return e.stop()}}),e,this)}))),function(e,t){return N.apply(this,arguments)})},{key:"sendRoomMessage",value:(w=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){var r,n=this;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(checkBufferSize(t),this._room&&this._room.connectionState===MediaConnectionState.CONNECTED){e.next=3;break}throw new SDKError(ErrorCode.IM_BEFORE_JOIN,"join first");case 3:return r=Date.now(),e.abrupt("return",this._room.sendRoomMessage(t).then((function(e){var t,i;return n._messageStatisticsObserver.countRoomMessage(!0,null===(t=n._room)||void 0===t||null===(i=t.roomInfo)||void 0===i?void 0:i.roomId,!1,r),e})).catch((function(e){var t,i;throw n._messageStatisticsObserver.countRoomMessage(!1,null===(t=n._room)||void 0===t||null===(i=t.roomInfo)||void 0===i?void 0:i.roomId,!1,r),e})));case 5:case"end":return e.stop()}}),e,this)}))),function(e){return w.apply(this,arguments)})},{key:"sendRoomBinaryMessage",value:(k=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){var r,n=this;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(checkBufferSize(t),this._room&&this._room.connectionState===MediaConnectionState.CONNECTED){e.next=3;break}throw new SDKError(ErrorCode.IM_BEFORE_JOIN,"join first");case 3:return r=Date.now(),e.abrupt("return",this._room.sendRoomMessage(t,!0).then((function(e){var t,i;return n._messageStatisticsObserver.countRoomMessage(!0,null===(t=n._room)||void 0===t||null===(i=t.roomInfo)||void 0===i?void 0:i.roomId,!0,r),e})).catch((function(e){var t,i;throw n._messageStatisticsObserver.countRoomMessage(!1,null===(t=n._room)||void 0===t||null===(i=t.roomInfo)||void 0===i?void 0:i.roomId,!0,r),e})));case 5:case"end":return e.stop()}}),e,this)}))),function(e){return k.apply(this,arguments)})},{key:"setAudioCaptureConfig",value:(P=_asyncToGenerator(_regeneratorRuntime().mark((function e(){var t,r,n,i=arguments;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=i.length>0&&void 0!==i[0]?i[0]:{},logger$1.print("setAudioCaptureConfig()","config: %o",t),delete t.deviceId,checkSupportedConstraints(t),r=this._audioStreamConstraints.deviceId,this._audioStreamConstraints=t,r&&(this._audioStreamConstraints.deviceId=r),!this._localAudioTrack){e.next=11;break}return this._localAudioTrack.audioCaptureConfig=this._audioStreamConstraints,e.next=11,null===(n=this._localAudioTrack)||void 0===n?void 0:n.updateAudioCaptureConfig();case 11:case"end":return e.stop()}}),e,this)}))),function(){return P.apply(this,arguments)})},{key:"setVideoCaptureConfig",value:(O=_asyncToGenerator(_regeneratorRuntime().mark((function e(){var t,r,n,i=arguments;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=i.length>0&&void 0!==i[0]?i[0]:{},logger$1.print("setVideoCaptureConfig()","config: %o",t),delete t.deviceId,checkSupportedConstraints(t),r=this._videoStreamConstraints.deviceId,this._videoStreamConstraints=t,r&&(this._videoStreamConstraints.deviceId=r),!this._localVideoTrack){e.next=12;break}return this._localVideoTrack.videoCaptureConfig=this._videoStreamConstraints,e.next=11,null===(n=this._localVideoTrack)||void 0===n?void 0:n.updateVideoCaptureConfig();case 11:this._updatePublish();case 12:case"end":return e.stop()}}),e,this)}))),function(){return O.apply(this,arguments)})},{key:"enableSimulcastMode",value:function(e){return logger$1.print("enableSimulcastMode()","enabled: %o",e),this._enableSimulcast=e,!0}},{key:"setVideoEncoderConfig",value:(C=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){var r;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:logger$1.print("setVideoEncoderConfig()"," descriptions: %o",t),Array.isArray(t)||(t=[t]),t.length>3&&(t=t.slice(0,3)),t.sort((function(e,t){return t.maxKbps-e.maxKbps})),this._videoStreamEncodeConfig=t,null!==(r=this._room)&&void 0!==r&&r.hasPublished&&this._updatePublish();case 6:case"end":return e.stop()}}),e,this)}))),function(e){return C.apply(this,arguments)})},{key:"setScreenEncoderConfig",value:(A=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){var r;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:logger$1.print("setScreenEncoderConfig()","description: %o",t),this._screenStreamEncodeConfig=[t],this._localScreenVideoTrack&&(this._localScreenVideoTrack.videoCaptureConfig=t,this._localScreenVideoTrack.updateVideoCaptureConfig(),t.contentHint&&this._localScreenVideoTrack.setContentHint(t.contentHint)),null!==(r=this._room)&&void 0!==r&&r.hasScreenPublished&&this._updateScreenPublish();case 4:case"end":return e.stop()}}),e,this)}))),function(e){return A.apply(this,arguments)})},{key:"sendSEIMessage",value:function(e,t,r){logger$1.print("sendSEIMessage()","streamIdex: %o, message: %o, repeatCount: %o",e,t,r),checkEnum(e,"streamIndex",[StreamIndex.STREAM_INDEX_MAIN,StreamIndex.STREAM_INDEX_SCREEN]),checkNumber(r,"repeatCount",0,30);var n="string"==typeof t?new Uint8Array(Utils.str2ab(t)):t;if(t.length){var i;if(e===StreamIndex.STREAM_INDEX_MAIN){var o,a,s;if(null===(o=this._room)||void 0===o||null===(a=o.localStream)||void 0===a||!a.hasPublished)return;i=null===(s=this._room)||void 0===s?void 0:s.localStream}else{var c,u,l;if(null===(c=this._room)||void 0===c||null===(u=c.localScreenStream)||void 0===u||!u.hasPublished)return;i=null===(l=this._room)||void 0===l?void 0:l.localScreenStream}if(n.byteLength>4096)logger$1.print("sei size must not bigger than 4KB");else{var d=genUuid();i.seiList.push({content:n,uuid:d,repeatCount:r}),setTimeout((function(){if(i){var e=i.seiList.findIndex((function(e){return e.uuid===d}));e&&i.seiList.splice(e,1)}}),2e3)}}else logger$1.print("sei message must not be empty")}},{key:"setAudioVolumeIndicationInterval",value:function(e){var t=this;logger$1.print("setAudioVolumeIndicationInterval()","interval %o: ",e),("number"!=typeof e||e<200)&&(e=200);var r=[];this._audioVolumeIndicationTimer&&clearInterval(this._audioVolumeIndicationTimer),this._audioVolumeIndicationTimer=setInterval((function(){var e,n;r=[],null===(e=t._room)||void 0===e||e.remoteStreams.forEach((function(e,t){var n;if(0!==e.length){var i=e.find((function(e){return!1===e.isScreen})),o=null==i||null===(n=i.audioTrack)||void 0===n?void 0:n.getAudioLevel();r.push({userId:t,volume:o||0})}}));var i=null===(n=t._localAudioTrack)||void 0===n?void 0:n.getAudioLevel();r.push({userId:t._getUserId(),volume:i||0}),t.safeEmit(EngineEventsTypes.onAudioVolumeIndication,{speakers:r})}),e)}},{key:"_sendActiveSpeaker",value:function(e,t){if(this._room&&this._room.remoteUsers.size>=1){var r,n=e[0],i=t.reduce((function(e,t){return e&&e.audioPropertiesInfo.nonlinearVolume>t.audioPropertiesInfo.nonlinearVolume?e:t}),void 0);if((r=n?i?n.audioPropertiesInfo.nonlinearVolume>i.audioPropertiesInfo.nonlinearVolume?n:i:n:i)&&r.audioPropertiesInfo.nonlinearVolume>-60){var o,a;if(r.streamKey)o=this._room.remoteUsers.get(r.streamKey.userId);else o=null===(a=this._room._roomInfo)||void 0===a?void 0:a.userInfo;o&&this.safeEmit(EngineEventsTypes.onActiveSpeaker,{userId:o.userId,extraInfo:o.extraInfo})}}}},{key:"enableAudioPropertiesReport",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};logger$1.print("enableAudioPropertiesReport()","config %o: ",t);var r=t.enableInBackground,n=void 0===r||r,i=t.interval,o=void 0===i?100:i;this._stopAudioPropertiesReport(),o<=0||(o=Math.max(100,o),this._audioPropertiesReportTimer=self.setInterval((function(){if(n||"hidden"!==document.visibilityState){var t=[],r=e._audioDeviceManager.getRecordTrack()||e._localAudioTrack;if(r){var i=r.getAudioLevel();t.push({streamIndex:StreamIndex.STREAM_INDEX_MAIN,audioPropertiesInfo:{linearVolume:i,nonlinearVolume:getNonlinearVolume(i)}})}if(e._localScreenAudioTrack){var o=e._localScreenAudioTrack.getAudioLevel();t.push({streamIndex:StreamIndex.STREAM_INDEX_SCREEN,audioPropertiesInfo:{linearVolume:o,nonlinearVolume:getNonlinearVolume(o)}})}if(e.safeEmit(EngineEventsTypes.onLocalAudioPropertiesReport,t),e._room){var a=[];e._room.remoteStreams.forEach((function(t,r){t.forEach((function(t){if(t.audioTrack){var n,i,o=t.audioTrack.getAudioLevel();a.push({streamKey:{userId:r,streamIndex:t.isScreen?StreamIndex.STREAM_INDEX_SCREEN:StreamIndex.STREAM_INDEX_MAIN,roomId:null===(n=e._room)||void 0===n||null===(i=n.roomInfo)||void 0===i?void 0:i.roomId},audioPropertiesInfo:{linearVolume:o,nonlinearVolume:getNonlinearVolume(o)}})}}))})),e._sendActiveSpeaker(t,a.filter((function(e){return e.streamKey.streamIndex!==StreamIndex.STREAM_INDEX_SCREEN}))),e.safeEmit(EngineEventsTypes.onRemoteAudioPropertiesReport,a)}}}),o))}},{key:"setVideoSourceType",value:($=_asyncToGenerator(_regeneratorRuntime().mark((function e(t,r){var n,i,o,a,s,c,u,l,d,p,_,f,h,m,y,v,S,g,E,T,b;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(logger$1.print("setVideoSourceType()","index: %o, videoSourceType: %o",t,r),checkEnum(t,"streamIndex",[StreamIndex.STREAM_INDEX_MAIN,StreamIndex.STREAM_INDEX_SCREEN]),checkEnum(r,"VideoSourceType",[VideoSourceType.VIDEO_SOURCE_TYPE_EXTERNAL,VideoSourceType.VIDEO_SOURCE_TYPE_INTERNAL]),n=t===StreamIndex.STREAM_INDEX_MAIN?"video":"screenVideo",this._trackSourceType[n]===r){e.next=26;break}if(this._trackSourceType[n]=r,logger$1.print("setVideoSourceType","set ".concat(n," source type to ").concat(r)),!this._localVideoTrack||t!==StreamIndex.STREAM_INDEX_MAIN){e.next=17;break}if(s=!1,r===VideoSourceType.VIDEO_SOURCE_TYPE_EXTERNAL&&(s=!0,this._localVideoTrack.close()),null===(i=this._videoPlayer)||void 0===i||i.stop(),this._localVideoTrack=void 0,c=null===(o=this._room)||void 0===o?void 0:o._roomConfig.isAutoPublish,s?null===(u=this._room)||void 0===u||null===(l=u.localStream)||void 0===l||null===(d=l.observer)||void 0===d||d.setEnableVideo(!1):null===(p=this._room)||void 0===p||null===(_=p.localStream)||void 0===_||null===(f=_.observer)||void 0===f||f.setPushVideo(!1),!(null!==(a=this._room)&&void 0!==a&&a.hasPublished||c)){e.next=17;break}return e.next=17,this._updatePublish();case 17:if(!this._localScreenVideoTrack||t!==StreamIndex.STREAM_INDEX_SCREEN){e.next=26;break}if(y=!1,r===VideoSourceType.VIDEO_SOURCE_TYPE_EXTERNAL&&(y=!0,this._localScreenVideoTrack.close()),null===(h=this._screenPlayer)||void 0===h||h.stop(),this._localScreenVideoTrack=void 0,y?null===(v=this._room)||void 0===v||null===(S=v.localScreenStream)||void 0===S||null===(g=S.observer)||void 0===g||g.setEnableVideo(!1):null===(E=this._room)||void 0===E||null===(T=E.localScreenStream)||void 0===T||null===(b=T.observer)||void 0===b||b.setPushVideo(!1),null===(m=this._room)||void 0===m||!m.hasScreenPublished){e.next=26;break}return e.next=26,this._updateScreenPublish();case 26:case"end":return e.stop()}}),e,this)}))),function(e,t){return $.apply(this,arguments)})},{key:"setExternalVideoTrack",value:(I=_asyncToGenerator(_regeneratorRuntime().mark((function e(t,r){var n,i,o,a,s,c,u,l,d;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(logger$1.print("setExternalVideoTrack()","index: %o, track: %o",t,r),checkEnum(t,"streamIndex",[StreamIndex.STREAM_INDEX_MAIN,StreamIndex.STREAM_INDEX_SCREEN]),t!==StreamIndex.STREAM_INDEX_MAIN){e.next=12;break}if(this._trackSourceType.video===VideoSourceType.VIDEO_SOURCE_TYPE_EXTERNAL){e.next=5;break}throw new SDKError(ErrorCode.STREAM_TYPE_NOT_MATCH,"setVideoSourceType as external first");case 5:if(this._localVideoTrack=new CustomVideoLocalTrack(r,genUuid()),this._initLocalTrackEvents(this._localVideoTrack),null===(n=this._videoPlayer)||void 0===n||n.playVideo(this._localVideoTrack),a=null===(i=this._room)||void 0===i?void 0:i._roomConfig.isAutoPublish,!(null!==(o=this._room)&&void 0!==o&&o.hasPublished||a)){e.next=12;break}return e.next=12,this._updatePublish();case 12:if(t!==StreamIndex.STREAM_INDEX_SCREEN){e.next=22;break}if(this._trackSourceType.screenVideo===VideoSourceType.VIDEO_SOURCE_TYPE_EXTERNAL){e.next=15;break}throw new SDKError(ErrorCode.STREAM_TYPE_NOT_MATCH,"setVideoSourceType as external first");case 15:if(this._localScreenVideoTrack=new CustomVideoLocalTrack(r,genUuid()),this._initLocalTrackEvents(this._localScreenVideoTrack,!0),null===(s=this._screenPlayer)||void 0===s||s.playVideo(this._localScreenVideoTrack),null===(c=this._room)||void 0===c||null===(u=c.localScreenStream)||void 0===u||null===(l=u.observer)||void 0===l||l.setPushVideo(!0),null===(d=this._room)||void 0===d||!d.hasScreenPublished){e.next=22;break}return e.next=22,this._updateScreenPublish();case 22:case"end":return e.stop()}}),e,this)}))),function(e,t){return I.apply(this,arguments)})},{key:"setAudioSourceType",value:(R=_asyncToGenerator(_regeneratorRuntime().mark((function e(t,r){var n,i,o,a,s,c,u,l,d,p,_,f,h,m,y,v,S,g,E;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(logger$1.print("setAudioSourceType()","index: %o, audioSourceType: %o",t,r),checkEnum(t,"streamIndex",[StreamIndex.STREAM_INDEX_MAIN,StreamIndex.STREAM_INDEX_SCREEN]),checkEnum(r,"audioSourceType",[AudioSourceType.AUDIO_SOURCE_TYPE_EXTERNAL,AudioSourceType.AUDIO_SOURCE_TYPE_INTERNAL]),n=t===StreamIndex.STREAM_INDEX_MAIN?"audio":"screenAudio",this._trackSourceType[n]===r){e.next=24;break}if(this._trackSourceType[n]=r,logger$1.print("setVideoSourceType","set ".concat(n," source type to ").concat(r)),!this._localAudioTrack||t!==StreamIndex.STREAM_INDEX_MAIN){e.next=16;break}if(a=!1,this._trackSourceType.audio===AudioSourceType.AUDIO_SOURCE_TYPE_EXTERNAL&&(a=!0,this._localAudioTrack.close()),this._localAudioTrack=void 0,s=null===(i=this._room)||void 0===i?void 0:i._roomConfig.isAutoPublish,a?null===(c=this._room)||void 0===c||null===(u=c.localStream)||void 0===u||null===(l=u.observer)||void 0===l||l.setEnableAudio(!1):null===(d=this._room)||void 0===d||null===(p=d.localStream)||void 0===p||null===(_=p.observer)||void 0===_||_.setPushAudio(!1),!(null!==(o=this._room)&&void 0!==o&&o.hasPublished||s)){e.next=16;break}return e.next=16,this._updatePublish();case 16:if(!this._localScreenAudioTrack||t!==StreamIndex.STREAM_INDEX_SCREEN){e.next=24;break}if(h=!1,this._trackSourceType.audio===AudioSourceType.AUDIO_SOURCE_TYPE_EXTERNAL&&(h=!0,this._localScreenAudioTrack.close()),this._localScreenAudioTrack=void 0,h?null===(m=this._room)||void 0===m||null===(y=m.localScreenStream)||void 0===y||null===(v=y.observer)||void 0===v||v.setEnableAudio(!1):null===(S=this._room)||void 0===S||null===(g=S.localScreenStream)||void 0===g||null===(E=g.observer)||void 0===E||E.setPushAudio(!1),null===(f=this._room)||void 0===f||!f.hasScreenPublished){e.next=24;break}return e.next=24,this._updateScreenPublish();case 24:case"end":return e.stop()}}),e,this)}))),function(e,t){return R.apply(this,arguments)})},{key:"setExternalAudioTrack",value:(b=_asyncToGenerator(_regeneratorRuntime().mark((function e(t,r){var n,i,o,a,s,c,u,l,d,p;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(logger$1.print("setExternalAudioTrack()","index: %o, track: %o",t,r),checkEnum(t,"streamIndex",[StreamIndex.STREAM_INDEX_MAIN,StreamIndex.STREAM_INDEX_SCREEN]),t!==StreamIndex.STREAM_INDEX_MAIN){e.next=12;break}if(this._trackSourceType.audio===AudioSourceType.AUDIO_SOURCE_TYPE_EXTERNAL){e.next=5;break}throw new SDKError(ErrorCode.STREAM_TYPE_NOT_MATCH,"setAudioSourceType as external first");case 5:if(this._localAudioTrack=new CustomAudioLocalTrack(r,genUuid()),this._initLocalTrackEvents(this._localAudioTrack),c=null===(n=this._room)||void 0===n?void 0:n._roomConfig.isAutoPublish,null===(i=this._room)||void 0===i||null===(o=i.localStream)||void 0===o||null===(a=o.observer)||void 0===a||a.setPushAudio(!0),!(null!==(s=this._room)&&void 0!==s&&s.hasPublished||c)){e.next=12;break}return e.next=12,this._updatePublish();case 12:if(t!==StreamIndex.STREAM_INDEX_SCREEN){e.next=21;break}if(this._trackSourceType.screenAudio===AudioSourceType.AUDIO_SOURCE_TYPE_EXTERNAL){e.next=15;break}throw new SDKError(ErrorCode.STREAM_TYPE_NOT_MATCH,"setAudioSourceType as external first");case 15:if(this._localScreenAudioTrack=new CustomAudioLocalTrack(r,genUuid()),this._initLocalTrackEvents(this._localScreenAudioTrack),null===(u=this._room)||void 0===u||null===(l=u.localScreenStream)||void 0===l||null===(d=l.observer)||void 0===d||d.setPushAudio(!0),null===(p=this._room)||void 0===p||!p.hasScreenPublished){e.next=21;break}return e.next=21,this._updateScreenPublish();case 21:case"end":return e.stop()}}),e,this)}))),function(e,t){return b.apply(this,arguments)})},{key:"login",value:(T=_asyncToGenerator(_regeneratorRuntime().mark((function e(t,r){return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return logger$1.print("login()","token: %o, userInfo: %o",t,r),isEmpty(t)||checkString(t,"token"),checkUserId(r),e.abrupt("return",this._rtmClient.login(t,r));case 4:case"end":return e.stop()}}),e,this)}))),function(e,t){return T.apply(this,arguments)})},{key:"logout",value:(E=_asyncToGenerator(_regeneratorRuntime().mark((function e(){return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return logger$1.print("logout()"),e.abrupt("return",this._rtmClient.logout());case 2:case"end":return e.stop()}}),e,this)}))),function(){return E.apply(this,arguments)})},{key:"updateLoginToken",value:(g=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return logger$1.print("updateLoginToken()","token: %o",t),isEmpty(t)||checkString(t,"token"),e.abrupt("return",this._rtmClient.updateLoginToken(t));case 3:case"end":return e.stop()}}),e,this)}))),function(e){return g.apply(this,arguments)})},{key:"getPeerOnlineStatus",value:(S=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return logger$1.print("getPeerOnlineStatus()","userId: %o",t),checkUserId(t),e.abrupt("return",this._rtmClient.getPeerOnlineStatus(t));case 3:case"end":return e.stop()}}),e,this)}))),function(e){return S.apply(this,arguments)})},{key:"sendUserMessageOutsideRoom",value:(v=_asyncToGenerator(_regeneratorRuntime().mark((function e(t,r){var n,i=this;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return checkUserId(t),checkBufferSize(r),n=Date.now(),e.prev=3,e.abrupt("return",this._rtmClient.sendUserMessageOutsideRoom(t,r).then((function(e){return i._messageStatisticsObserver.countUserMessageOutsideRoom(!0,t,!1,n,e),e.id})).catch((function(e){throw i._messageStatisticsObserver.countUserMessageOutsideRoom(!1,t,!1,n),e})));case 7:throw e.prev=7,e.t0=e.catch(3),this._messageStatisticsObserver.countUserMessageOutsideRoom(!1,t,!1,n),e.t0;case 11:case"end":return e.stop()}}),e,this,[[3,7]])}))),function(e,t){return v.apply(this,arguments)})},{key:"sendUserBinaryMessageOutsideRoom",value:(y=_asyncToGenerator(_regeneratorRuntime().mark((function e(t,r){var n,i=this;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return checkUserId(t),checkArrayBuffer(r,"message"),checkBufferSize(r),n=Date.now(),e.prev=4,e.abrupt("return",this._rtmClient.sendUserMessageOutsideRoom(t,r).then((function(e){return i._messageStatisticsObserver.countUserMessageOutsideRoom(!0,t,!0,n,e),e.id})).catch((function(e){throw i._messageStatisticsObserver.countUserMessageOutsideRoom(!1,t,!0,n),e})));case 8:throw e.prev=8,e.t0=e.catch(4),this._messageStatisticsObserver.countUserMessageOutsideRoom(!1,t,!0,n),e.t0;case 12:case"end":return e.stop()}}),e,this,[[4,8]])}))),function(e,t){return y.apply(this,arguments)})},{key:"setServerParams",value:(m=_asyncToGenerator(_regeneratorRuntime().mark((function e(t,r){return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return logger$1.print("setServerParams()","signature: %o, url: %0",t,r),e.abrupt("return",this._rtmClient.setServerParams(t,r));case 2:case"end":return e.stop()}}),e,this)}))),function(e,t){return m.apply(this,arguments)})},{key:"sendServerMessage",value:(h=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){var r,n=this;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return checkString(t,"message"),checkBufferSize(t),r=Date.now(),e.prev=3,e.abrupt("return",this._rtmClient.sendServerMessage(t).then((function(){n._messageStatisticsObserver.countServerMessage(!0,!1,r)})).catch((function(e){throw n._messageStatisticsObserver.countServerMessage(!1,!1,r),e})));case 7:throw e.prev=7,e.t0=e.catch(3),this._messageStatisticsObserver.countServerMessage(!1,!1,r),e.t0;case 11:case"end":return e.stop()}}),e,this,[[3,7]])}))),function(e){return h.apply(this,arguments)})},{key:"sendServerBinaryMessage",value:(f=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){var r,n=this;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return checkArrayBuffer(t,"message"),checkBufferSize(t),r=Date.now(),e.prev=3,e.abrupt("return",this._rtmClient.sendServerMessage(t).then((function(){n._messageStatisticsObserver.countServerMessage(!0,!0,r)})).catch((function(e){throw n._messageStatisticsObserver.countServerMessage(!1,!0,r),e})));case 7:throw e.prev=7,e.t0=e.catch(3),this._messageStatisticsObserver.countServerMessage(!1,!0,r),e.t0;case 11:case"end":return e.stop()}}),e,this,[[3,7]])}))),function(e){return f.apply(this,arguments)})},{key:"startCloudProxy",value:function(e){if(this._room)throw new SDKError(ErrorCode.START_CLOUD_PROXY_AFTER_JOIN,"[startCloudProxy] should be invoke before join room ");logger$1.print("startCloudProxy()",e),checkString(e.logProxy,"logProxy"),checkString(e.accessProxy,"accessProxy"),checkString(e.configProxy,"configProxy"),this._originIceConfigRequestUrls=getParameter("ICE_CONFIG_REQUEST_URLS"),this._originLogServerUrl=getParameter("LOG_SERVER_URL"),this._originConfigServerUrls=getParameter("CONFIG_REQUEST_DOMAINS"),setParameter("ICE_CONFIG_REQUEST_URLS",e.accessProxy),setParameter("LOG_SERVER_URL",getFullLogServerUrl(e.logProxy)),setParameter("CONFIG_REQUEST_DOMAINS",[e.configProxy]),this._useCloudProxy=!0}},{key:"stopCloudProxy",value:function(){if(this._room)throw new SDKError(ErrorCode.STOP_CLOUD_PROXY_BEFORE_LEAVE,"[stopCloudProxy] should be invoke after leave room ");logger$1.print("stopCloudProxy()"),setParameter("ICE_CONFIG_REQUEST_URLS",[]),setParameter("LOG_SERVER_URL",this._originLogServerUrl),setParameter("CONFIG_REQUEST_DOMAINS",this._originConfigServerUrls),this._useCloudProxy=!1,this._startCloudProxyTimestamp=void 0}},{key:"startPushPublicStream",value:(_=_asyncToGenerator(_regeneratorRuntime().mark((function e(t,r){var n,i=this;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(logger$1.print("startPushPublicStream()","publicStreamId: %o, publicStreamParam: %o",t,r),checkPublicStreamId(t),this._room&&this._room.connectionState===MediaConnectionState.CONNECTED){e.next=4;break}throw new SDKError(ErrorCode.START_PUBLIC_STREAM_BEFORE_JOIN,"join first");case 4:if(!this._publicStreamIds.get(t)){e.next=6;break}throw new SDKError(ErrorCode.REPEAT_PUSH,"repeat push public media stream");case 6:return n=getPublicStreamControlMessage(t,"started",r),e.abrupt("return",this._room.publicStreamControlMessage(n).then((function(){i._publicStreamIds.set(t,t)})));case 8:case"end":return e.stop()}}),e,this)}))),function(e,t){return _.apply(this,arguments)})},{key:"updatePublicStreamParam",value:(p=_asyncToGenerator(_regeneratorRuntime().mark((function e(t,r){var n;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(logger$1.print("startPushPublicStream()","publicStreamId: %o, publicStreamParam: %o",t,r),checkPublicStreamId(t),this._room&&this._room.connectionState===MediaConnectionState.CONNECTED){e.next=4;break}throw new SDKError(ErrorCode.START_PUBLIC_STREAM_BEFORE_JOIN,"join first");case 4:return n=getPublicStreamControlMessage(t,"layoutChanged",r),e.abrupt("return",this._room.publicStreamControlMessage(n));case 6:case"end":return e.stop()}}),e,this)}))),function(e,t){return p.apply(this,arguments)})},{key:"stopPushPublicStream",value:(d=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){var r=this;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(logger$1.print("startPushPublicStream()","publicStreamId: %o",t),checkPublicStreamId(t),this._room&&this._room.connectionState===MediaConnectionState.CONNECTED){e.next=4;break}throw new SDKError(ErrorCode.START_PUBLIC_STREAM_BEFORE_JOIN,"join first");case 4:return e.abrupt("return",this._room.publicStreamControlMessage({type:"publicstream",action:"stopped",publicStreamID:t}).then((function(){r._publicStreamIds.delete(t)})));case 5:case"end":return e.stop()}}),e,this)}))),function(e){return d.apply(this,arguments)})},{key:"startPlayPublicStream",value:(l=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){var r,n,i,o,a,s,c=this;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(checkPublicStreamId(t),this._outsideRoom){e.next=8;break}return this._outsideRoom=new OutsideRoom(this._appId),this._outsideRoom.on(RoomEvent.RESUBSCRIBE,(function(e){var t=e.stream;if(t){var r,n=c._publicStreamAudioPlayer.get(t.streamId);n&&t.audioTrack&&(n.stop(),n.playAudio(null===(r=e.stream)||void 0===r?void 0:r.audioTrack));var i,o=c._publicStreamVideoPlayer.get(t.streamId);o&&t.videoTrack&&o.playVideo(null===(i=e.stream)||void 0===i?void 0:i.videoTrack)}})),null===(r=this._outsideRoom)||void 0===r||r.on("onRemoteStreamStats",(function(e){e.publicStreamId=e.userId,delete e.userId,delete e.isScreen,c.safeEmit(EngineEventsTypes.onPublicStreamStats,e)})),null===(n=this._outsideRoom)||void 0===n||n.on(RoomEvent.ON_SEI_MESSAGED_RECEIVED,(function(e){c.safeEmit(EngineEventsTypes.onPublicStreamSEIMessageReceived,e)})),e.next=8,this._outsideRoom.connect();case 8:return e.next=10,this._outsideRoom.startPlayPublicStream(t);case 10:i=e.sent,(o=this._publicStreamVideoPlayer.get(t))&&null!=i&&i.videoTrack&&o.playVideo(i.videoTrack,i),!(a=this._publicStreamAudioPlayer.get(t))&&null!=i&&i.audioTrack&&(a=new AudioPlayer(t,{muted:(null===(s=this._config)||void 0===s?void 0:s.autoPlayPolicy)===RTCAutoPlayPolicy.VIDEO_ONLY}),this._initPlayerEvents(a,!0),a.playAudio(i.audioTrack),this._publicStreamAudioPlayer.set(t,a));case 15:case"end":return e.stop()}}),e,this)}))),function(e){return l.apply(this,arguments)})},{key:"stopPlayPublicStream",value:(u=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){var r;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._outsideRoom){e.next=2;break}return e.abrupt("return");case 2:this._outsideRoom.stopPlayPublicStream(t),(r=this._publicStreamAudioPlayer.get(t))&&(r.destroy(),this._publicStreamAudioPlayer.delete(t));case 5:case"end":return e.stop()}}),e,this)}))),function(e){return u.apply(this,arguments)})},{key:"setAudioProfile",value:(c=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._audioProfileManager.setAudioProfile(t);case 1:case"end":return e.stop()}}),e,this)}))),function(e){return c.apply(this,arguments)})},{key:"setPublicStreamVideoPlayer",value:function(e,t){var r,n,i,o;logger$1.print("setPublicStreamVideoPlayer()","publicStreamId: %o, videoPlayerOption: %o",e,t);var a=this._publicStreamVideoPlayer.get(e);if(null===(r=a)||void 0===r||r.destroy(),null!=t&&t.renderDom){a=new VideoPlayer(_objectSpread2(_objectSpread2({},t),{},{userId:e})),this._initPlayerEvents(a,!0),this._publicStreamVideoPlayer.set(e,a);var s=null===(n=this._outsideRoom)||void 0===n||null===(i=n.remoteStreams)||void 0===i?void 0:i.get(e);null!=s&&s.videoTrack&&(null===(o=this._config)||void 0===o?void 0:o.autoPlayPolicy)!==RTCAutoPlayPolicy.PLAY_MANUALLY&&a.playVideo(s.videoTrack,s)}else this._publicStreamVideoPlayer.delete(e)}},{key:"setDummyCaptureImagePath",value:(s=_asyncToGenerator(_regeneratorRuntime().mark((function e(t,r){var n=this;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",new Promise((function(e,i){checkString(r,"filePath");var o=new Image;o.crossOrigin="anonymous",o.src=r,o.onload=function(){try{var r=document.createElement("canvas"),a=r.getContext("2d");if(!a)return i(new SDKError(ErrorCode.UNEXPECTED_ERROR,"Not support canvas"));r.width=o.width,r.height=o.height,a.drawImage(o,0,0,o.width,o.height),clearInterval(n._dummyTimer),n._dummyTimer=window.setInterval((function(){a.drawImage(o,0,0,o.width,o.height)}),200);var s=r.captureStream(5).getVideoTracks()[0];t===StreamIndex.STREAM_INDEX_MAIN?n._localImgVideoTrack=s:n._localImgScreenTrack=s,e()}catch(e){i(new SDKError(ErrorCode.UNEXPECTED_ERROR,e.message))}},o.onerror=function(){i(new SDKError(ErrorCode.UNEXPECTED_ERROR,"Load image error"))}})));case 1:case"end":return e.stop()}}),e)}))),function(e,t){return s.apply(this,arguments)})},{key:"defaultTranscoding",value:function(){return JSON.parse(JSON.stringify(defaultTranscoding))}},{key:"_updatePublish",value:(a=_asyncToGenerator(_regeneratorRuntime().mark((function e(){var t,r,n,i=arguments;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=i.length>0&&void 0!==i[0]?i[0]:{},logger$1.print("_updatePublish()","config: %o",t),r={mediaType:void 0,invokeByJoinRoom:!1,pubState:PubState.PUB},t=_objectSpread2(_objectSpread2({},r),t),this._visibility){e.next=6;break}throw new SDKError(ErrorCode.NO_PUBLISH_PERMISSION,"no publish permission");case 6:return e.next=8,this._pubLock.lock();case 8:if(n=e.sent,this._room&&this._room.connectionState===MediaConnectionState.CONNECTED){e.next=12;break}return n(),e.abrupt("return");case 12:return e.prev=12,e.next=15,this._room.publish(this._videoStreamEncodeConfig,this._enableSimulcast,this._localVideoTrack,this._localAudioTrack,t.mediaType,t.pubState,t.invokeByJoinRoom);case 15:e.next=24;break;case 17:if(e.prev=17,e.t0=e.catch(12),!(e.t0 instanceof SDKError)){e.next=23;break}throw e.t0;case 23:throw new SDKError(ErrorCode.UNEXPECTED_ERROR,"unexpected error",e.t0);case 24:return e.prev=24,n(),e.finish(24);case 27:case"end":return e.stop()}}),e,this,[[12,17,24,27]])}))),function(){return a.apply(this,arguments)})},{key:"startAudioPlaybackDeviceTest",value:(o=_asyncToGenerator(_regeneratorRuntime().mark((function e(t,r){return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return logger$1.print("startAudioPlaybackDeviceTest()","filePath: %o, indicationInterval: %o",t,r),checkString(t,"filePath"),checkNumber(r,"indicationInterval"),e.next=5,this._audioDeviceManager.startAudioPlaybackDeviceTest(t,r);case 5:return e.abrupt("return",e.sent);case 6:case"end":return e.stop()}}),e,this)}))),function(e,t){return o.apply(this,arguments)})},{key:"stopAudioPlaybackDeviceTest",value:function(){logger$1.print("stopAudioPlaybackDeviceTest()"),this._audioDeviceManager.stopAudioPlaybackDeviceTest()}},{key:"startAudioDeviceRecordTest",value:(i=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return logger$1.print("startAudioDeviceRecordTest()","indicationInterval: %o",t),checkNumber(t,"indicationInterval"),e.next=4,this._audioDeviceManager.startAudioDeviceRecordTest(t);case 4:case"end":return e.stop()}}),e,this)}))),function(e){return i.apply(this,arguments)})},{key:"stopAudioDeviceRecordAndPlayTest",value:function(){logger$1.print("stopAudioDeviceRecordAndPlayTest()"),this._audioDeviceManager.stopAudioDeviceRecordAndPlayTest()}},{key:"stopAudioDevicePlayTest",value:function(){logger$1.print("stopAudioDevicePlayTest()"),this._audioDeviceManager.stopAudioDevicePlayTest()}},{key:"setRemoteUserPriority",value:function(e,t){var r;logger$1.print("setRemoteUserPriority()","userId: %o, priority: %o",e,t);try{checkUserId(e),checkEnum(t,"priority",[RemoteUserPriority.HIGH,RemoteUserPriority.MEDIUM,RemoteUserPriority.LOW])}catch(e){return console.warn(e),!1}return this._userPriorityMap.set(e,t),null===(r=this._room)||void 0===r||r.setRemoteUserPriority(e,t),!0}},{key:"takeLocalSnapshot",value:(n=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){var r,n;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(logger$1.print("takeLocalSnapshot()","streamIndex: %o",t),checkEnum(t,"streamIndex",[StreamIndex.STREAM_INDEX_MAIN,StreamIndex.STREAM_INDEX_SCREEN]),r=t===StreamIndex.STREAM_INDEX_MAIN?this.localVideoTrack:this.localScreenVideoTrack){e.next=5;break}throw new SDKError(ErrorCode.INVOKED_BEFORE_CAPTURE,"capture first");case 5:return n=t===StreamIndex.STREAM_INDEX_MAIN?this._videoPlayer:this._screenPlayer,e.abrupt("return",takeSnapshot(r.getTrack(),(null==n?void 0:n.mirrorType)===MirrorType.MIRROR_TYPE_RENDER,n));case 7:case"end":return e.stop()}}),e,this)}))),function(e){return n.apply(this,arguments)})},{key:"takeRemoteSnapshot",value:(r=_asyncToGenerator(_regeneratorRuntime().mark((function e(t,r){var n,i,o,a,s,c;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(logger$1.print("takeRemoteSnapshot()","id: %o, streamIndex: %o",t,r),checkString(t,"id"),checkEnum(r,"streamIndex",[StreamIndex.STREAM_INDEX_MAIN,StreamIndex.STREAM_INDEX_SCREEN]),c=(null===(n=this._room)||void 0===n||null===(i=n.remoteStreams.get(t))||void 0===i||null===(o=i.find((function(e){return e.isScreen===(r===StreamIndex.STREAM_INDEX_SCREEN)})))||void 0===o?void 0:o.videoTrack)||(null===(a=this._outsideRoom)||void 0===a||null===(s=a.remoteStreams.get(t))||void 0===s?void 0:s.videoTrack)){e.next=6;break}throw new SDKError(ErrorCode.STREAM_NOT_EXIST,"stream not exist");case 6:return e.abrupt("return",takeSnapshot(c.getTrack(),!1,r===StreamIndex.STREAM_INDEX_MAIN?this._remoteVideoPlayer.get(t):this._remoteScreenPlayer.get(t)));case 7:case"end":return e.stop()}}),e,this)}))),function(e,t){return r.apply(this,arguments)})},{key:"setSubscribeFallbackOption",value:function(e){logger$1.print("setSubscribeFallbackOption()","option: %o",e);try{checkEnum(e,"option",[SubscribeFallbackOption.DISABLE,SubscribeFallbackOption.VIDEO_STREAM_LOW,SubscribeFallbackOption.AUDIO_ONLY])}catch(e){return console.warn(e),!1}return!this._room&&(this._subscribeFallbackOption=e,!0)}},{key:"_updateScreenPublish",value:(t=_asyncToGenerator(_regeneratorRuntime().mark((function e(){var t,r,n,i=arguments;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=i.length>0&&void 0!==i[0]?i[0]:{},logger$1.print("_updateScreenPublish()"),r={mediaType:void 0,pubState:PubState.PUB},t=_objectSpread2(_objectSpread2({},r),t),e.next=6,this._pubLock.lock();case 6:if(n=e.sent,this._room&&this._room.connectionState===MediaConnectionState.CONNECTED){e.next=10;break}return n(),e.abrupt("return");case 10:return e.prev=10,e.next=13,this._room.publishScreen(this._screenStreamEncodeConfig,this._localScreenVideoTrack,this._localScreenAudioTrack,t.mediaType,t.pubState);case 13:e.next=22;break;case 15:if(e.prev=15,e.t0=e.catch(10),!(e.t0 instanceof SDKError)){e.next=21;break}throw e.t0;case 21:throw new SDKError(ErrorCode.UNEXPECTED_ERROR,"unexpected error",e.t0);case 22:return e.prev=22,n(),e.finish(22);case 25:case"end":return e.stop()}}),e,this,[[10,15,22,25]])}))),function(){return t.apply(this,arguments)})},{key:"_setCaptureVolume",value:function(e,t){var r;0===t&&logger$1.print("setCaptureVolume: ",t),checkEnum(e,"streamType",[StreamIndex.STREAM_INDEX_MAIN,StreamIndex.STREAM_INDEX_SCREEN]),checkNumber(t,"volume",0,400);var n=!1;e===StreamIndex.STREAM_INDEX_MAIN?(this._localAudioTrack&&(n=!!this._localAudioTrack.gainAudioTrack,this._localAudioTrack.setCaptureVolume(t)),this._localAudioTrackVolume=t):e===StreamIndex.STREAM_INDEX_SCREEN&&(this._localScreenAudioTrack&&(n=!!this._localScreenAudioTrack.gainAudioTrack,this._localScreenAudioTrack.setCaptureVolume(t)),this._localScreenAudioTrackVolume=t),null!==(r=this._room)&&void 0!==r&&r.hasPublished&&!n&&this._updatePublish()}},{key:"_updateAudioPlayerState",value:function(e){logger$1.print("_updateAudioPlayerState()");var t,r=e.userId,n=e.isScreen;if(t=n?this._remoteAudioPlayer.get("".concat(r,"_screen")):this._remoteAudioPlayer.get(r),e.audioTrack&&(e.attributes.audiostream&&e.subAudio||this.multiChatMode)){var i;if(!t){var o,a=n?"".concat(r,"_screen"):r;t=new AudioPlayer(a,{muted:(null===(o=this._config)||void 0===o?void 0:o.autoPlayPolicy)===RTCAutoPlayPolicy.VIDEO_ONLY}),this._initPlayerEvents(t),this._remoteAudioPlayer.set(a,t),this._audioPlaybackDeviceId&&t.setPlaybackDevice(this._audioPlaybackDeviceId)}(null===(i=this._config)||void 0===i?void 0:i.autoPlayPolicy)!==RTCAutoPlayPolicy.PLAY_MANUALLY&&t.playAudio(e.audioTrack)}else{var s;null===(s=t)||void 0===s||s.stop()}}},{key:"_updateVideoPlayerState",value:function(e){var t;logger$1.print("_updateVideoPlayerState()");var r,n,i=e.userId;if(r=e.isScreen?this._remoteScreenPlayer.get(i):this._remoteVideoPlayer.get(i),e.videoTrack)r&&(null===(n=this._config)||void 0===n?void 0:n.autoPlayPolicy)!==RTCAutoPlayPolicy.PLAY_MANUALLY&&r.playVideo(e.videoTrack,e);else if(null!==(t=r)&&void 0!==t&&t.played){var o;null===(o=r)||void 0===o||o.stop()}}},{key:"_onAddStream",value:function(e){var t=e.stream,r=null==t?void 0:t.attributes,n=r.localaudio,i=r.audiostream,o=r.localvideo,a=r.videostream,s=ExtendMediaType.NONE;if(i&&(s|=MediaType.AUDIO),a&&(s|=MediaType.VIDEO),s){var c;if(null!=t&&t.isScreen)this.safeEmit(EngineEventsTypes.onUserPublishScreen,{userId:t.userId,mediaType:s});else this.safeEmit(EngineEventsTypes.onUserPublishStream,{userId:t.userId,mediaType:s,videoStreamDescriptions:null==t||null===(c=t.attributes)||void 0===c?void 0:c.videoDescriptions}),this._handleAutoSubscribe(t,!0);this.safeEmit("onAddStream",{userId:t.userId,mediaType:s,isScreen:!(null==t||!t.isScreen)}),null!=t&&t.isScreen||(n&&this.safeEmit(EngineEventsTypes.onUserStartAudioCapture,{userId:t.userId}),o&&this.safeEmit(EngineEventsTypes.onUserStartVideoCapture,{userId:t.userId}))}}},{key:"_handleAutoSubscribe",value:function(e,t){var r,n,i=ExtendMediaType.NONE;if(null!==(r=this._roomConfig)&&void 0!==r&&r.isAutoSubscribeAudio&&(i|=MediaType.AUDIO),null!==(n=this._roomConfig)&&void 0!==n&&n.isAutoSubscribeVideo&&(i|=MediaType.VIDEO),logger$1.print("_onAddStream","autoSubType: ".concat(i)),i){var o,a;if(t&&audioInMediaType(i))null===(o=e.observer)||void 0===o||o.setAutoSubscribeAudio(!0);if(t&&videoInMediaType(i))null===(a=e.observer)||void 0===a||a.setAutoSubscribeVideo(!0);this._subscribe(!1,e.userId,i)}}},{key:"_onRemoveStream",value:function(e){var t,r=this,n=e.stream,i=null!==(t=StreamRemoveReasonMap[e.reason])&&void 0!==t?t:StreamRemoveReason.STREAM_REMOVE_REASON_OTHER,o=n.isScreen?EngineEventsTypes.onUserUnpublishScreen:EngineEventsTypes.onUserUnpublishStream,a=ExtendMediaType.NONE;n.attributes.audiostream&&(a|=MediaType.AUDIO),n.attributes.videostream&&(a|=MediaType.VIDEO),null!=n&&n._workaround_1_&&(a=MediaType.VIDEO),a!==ExtendMediaType.NONE&&(this.safeEmit(o,{userId:n.userId,mediaType:a,reason:i}),this.safeEmit("onRemoveStream",{userId:n.userId,isScreen:n.isScreen})),this._getRemotePlayer(n.userId,n.isScreen).forEach((function(e){if(null==n||!n._workaround_1_){var t=n.isScreen?"".concat(n.userId,"_screen"):n.userId;r._remoteAudioPlayer.delete(t),n.isScreen?r._remoteScreenPlayer.delete(n.userId):r._remoteVideoPlayer.delete(n.userId),null==e||e.destroy()}}))}},{key:"_onUserConnection",value:function(e){this.safeEmit(EngineEventsTypes.onUserJoined,e)}},{key:"_onUserLeave",value:function(e){this.safeEmit(EngineEventsTypes.onUserLeave,e)}},{key:"_onRoomError",value:function(e){var t;this.safeEmit(EngineEventsTypes.onError,e),null===(t=this._room)||void 0===t||t.destroy(),this._room=void 0}},{key:"_onNetworkQuality",value:function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];this.safeEmit.apply(this,[EngineEventsTypes.onNetworkQuality].concat(t))}},{key:"_onConnectionStateChange",value:function(e){void 0!==this._startCloudProxyTimestamp&&this._useCloudProxy&&e.state===ConnectionState.CONNECTION_STATE_CONNECTED&&this.safeEmit(EngineEventsTypes.onCloudProxyConnected,{interval:Date.now()-this._startCloudProxyTimestamp}),this.safeEmit(EngineEventsTypes.onConnectionStateChanged,e)}},{key:"_getRemotePlayer",value:function(e,t){return[this._remoteAudioPlayer.get(t?"".concat(e,"_screen"):e),(t?this._remoteScreenPlayer:this._remoteVideoPlayer).get(e)]}},{key:"_stopAudioPropertiesReport",value:function(){null!==this._audioPropertiesReportTimer&&(clearInterval(this._audioPropertiesReportTimer),this._audioPropertiesReportTimer=null)}},{key:"_onResubscribe",value:function(e){e.stream&&(this._getRemotePlayer(e.stream.userId,e.stream.isScreen).forEach((function(e){return null==e?void 0:e.stop()})),this._updateAudioPlayerState(e.stream),this._updateVideoPlayerState(e.stream))}},{key:"_onSubscribePushTrack",value:function(e){e.stream&&this._updateAudioPlayerState(e.stream)}},{key:"_onRemovePushTrack",value:function(e){e.stream&&this._updateAudioPlayerState(e.stream)}},{key:"_onVideoFirstFrameDecoded",value:function(e){this.safeEmit(EngineEventsTypes.onVideoFirstFrameDecoded,e)}},{key:"_onVideoDeviceStateChange",value:function(e){this.safeEmit(EngineEventsTypes.onVideoDeviceStateChanged,e)}},{key:"_onAudioDeviceStateChange",value:function(e){this.safeEmit(EngineEventsTypes.onAudioDeviceStateChanged,e)}},{key:"_onUserPublishStateChange",value:function(e){var t,r=e.userId,n=e.isScreen,i=e.mediaType,o=e.pubState,a=e.remoteStream,s={userId:r,mediaType:i};n?o===PubState.PUB?this.safeEmit(EngineEventsTypes.onUserPublishScreen,s):this.safeEmit(EngineEventsTypes.onUserUnpublishScreen,_objectSpread2(_objectSpread2({},s),{},{reason:StreamRemoveReason.STREAM_REMOVE_REASON_UNPUBLISH})):o===PubState.PUB?(s.videoStreamDescriptions=null==a||null===(t=a.attributes)||void 0===t?void 0:t.videoDescriptions,this.safeEmit(EngineEventsTypes.onUserPublishStream,s),this._handleAutoSubscribe(a,!0)):this.safeEmit(EngineEventsTypes.onUserUnpublishStream,_objectSpread2(_objectSpread2({},s),{},{reason:StreamRemoveReason.STREAM_REMOVE_REASON_UNPUBLISH}))}},{key:"_onCustomMessage",value:function(e){var t=e.message;e.binary?this.safeEmit(EngineEventsTypes.onRoomBinaryMessageReceived,{userId:e.clientId,message:t}):this.safeEmit(EngineEventsTypes.onRoomMessageReceived,{userId:e.clientId,message:t})}},{key:"_onUserMessageReceived",value:function(e){this._messageStatisticsObserver.recvP2PMessage(e.userId),this.safeEmit(EngineEventsTypes.onUserMessageReceived,e)}},{key:"_onUserBinaryMessageReceived",value:function(e){this._messageStatisticsObserver.recvP2PMessage(e.userId),this.safeEmit(EngineEventsTypes.onUserBinaryMessageReceived,e)}},{key:"_onLiveTranscodingResult",value:function(e){this.safeEmit(EngineEventsTypes.onLiveTranscodingResult,e)}},{key:"_onStreamMixingEvent",value:function(e){this.safeEmit(EngineEventsTypes.onStreamMixingEvent,e)}},{key:"_onUserTokenWillExpire",value:function(){this.safeEmit(EngineEventsTypes.onTokenWillExpire)}},{key:"_onPushPublicStreamResult",value:function(e){this.safeEmit(EngineEventsTypes.onPushPublicStreamResult,e)}},{key:"_handleRTMClient",value:function(e){var t=this;e.on("onUserMessageReceivedOutsideRoom",(function(e){t._messageStatisticsObserver.recvP2POutRoomMessage(e.userId),t.safeEmit(EngineEventsTypes.onUserMessageReceivedOutsideRoom,e)})),e.on("onUserBinaryMessageReceivedOutsideRoom",(function(e){t._messageStatisticsObserver.recvP2POutRoomMessage(e.userId),t.safeEmit(EngineEventsTypes.onUserBinaryMessageReceivedOutsideRoom,e)})),e.on("onUserDisconnection",(function(){t.safeEmit(EngineEventsTypes.onError,{errorCode:ErrorCode.RTM_DUPLICATE_LOGIN})})),e.on("onRTMTokenError",(function(){t.safeEmit(EngineEventsTypes.onError,{errorCode:ErrorCode.RTM_TOKEN_ERROR})})),e.on("onServerParamsSetResult",(function(e){t.safeEmit(EngineEventsTypes.onServerParamsSetResult,null==e?void 0:e.code)}))}},{key:"waitForNewToken",get:function(){return!!this._tempRoomConfig}},{key:"localAudioTrack",get:function(){return this._localAudioTrack}},{key:"localVideoTrack",get:function(){return this._localVideoTrack}},{key:"localScreenAudioTrack",get:function(){return this._localScreenAudioTrack}},{key:"localScreenVideoTrack",get:function(){return this._localScreenVideoTrack}},{key:"remoteStreams",get:function(){var e,t,r=[];null!==(e=this._room)&&void 0!==e&&e.remoteStreams&&(null===(t=this._room)||void 0===t||t.remoteStreams.forEach((function(e){Array.isArray(e)&&e.forEach((function(e){r.push({userId:e.userId,isScreen:e.isScreen,hasVideo:e.hasVideo,hasAudio:e.hasAudio,videoStreamDescriptions:e.attributes.videoDescriptions})}))})));return r}},{key:"remoteUsers",get:function(){var e,t,r=[];null!==(e=this._room)&&void 0!==e&&e.remoteUsers&&(null===(t=this._room)||void 0===t||t.remoteUsers.forEach((function(e){r.push({userId:e.userId})})));return r}},{key:"multiChatMode",get:function(){var e,t;return!(null===(e=this._room)||void 0===e||null===(t=e._mediaServerClient)||void 0===t||!t.roomAttributes.multiChatMode)}},{key:"_handleAudioDeviceManager",value:function(){var e=this;this._audioDeviceManager.on("onAudioPlaybackDeviceTestVolume",(function(t){e.safeEmit(EngineEventsTypes.onAudioPlaybackDeviceTestVolume,t)}))}},{key:"_assertNotInRoom",value:function(){if(!this._room||this._room.connectionState!==MediaConnectionState.CONNECTED)throw new SDKError(ErrorCode.INVOKED_BEFORE_JOIN_ROOM,"join first")}},{key:"_checkMediaType",value:function(e){checkEnum(e,"mediaType",[MediaType.AUDIO,MediaType.VIDEO,MediaType.AUDIO_AND_VIDEO])}},{key:"_getUserId",value:function(){var e,t;return(null===(e=this._room)||void 0===e||null===(t=e.roomInfo)||void 0===t?void 0:t.userInfo.userId)||"local_user"}}]),de}();__decorateClass([reportRtcSdkApiCall()],RTCEngine.prototype,"updateToken",1),__decorateClass([reportRtcSdkApiCall()],RTCEngine.prototype,"setVideoCaptureDevice",1),__decorateClass([reportRtcSdkApiCall()],RTCEngine.prototype,"setAudioCaptureDevice",1),__decorateClass([reportRtcSdkApiCall()],RTCEngine.prototype,"joinRoom",1),__decorateClass([reportRtcSdkApiCall()],RTCEngine.prototype,"leaveRoom",1),__decorateClass([reportRtcSdkApiCall()],RTCEngine.prototype,"destroy",1),__decorateClass([reportRtcSdkApiCall()],RTCEngine.prototype,"publishStream",1),__decorateClass([reportRtcSdkApiCall()],RTCEngine.prototype,"unpublishStream",1),__decorateClass([reportRtcSdkApiCall()],RTCEngine.prototype,"publishScreen",1),__decorateClass([reportRtcSdkApiCall()],RTCEngine.prototype,"unpublishScreen",1),__decorateClass([reportRtcSdkApiCall()],RTCEngine.prototype,"subscribeStream",1),__decorateClass([reportRtcSdkApiCall()],RTCEngine.prototype,"unsubscribeStream",1),__decorateClass([reportRtcSdkApiCall()],RTCEngine.prototype,"subscribeScreen",1),__decorateClass([reportRtcSdkApiCall()],RTCEngine.prototype,"unsubscribeScreen",1),__decorateClass([reportRtcSdkApiCall()],RTCEngine.prototype,"setRemoteVideoConfig",1),__decorateClass([reportRtcSdkApiCall()],RTCEngine.prototype,"startVideoCapture",1),__decorateClass([reportRtcSdkApiCall()],RTCEngine.prototype,"stopVideoCapture",1),__decorateClass([reportRtcSdkApiCall()],RTCEngine.prototype,"startAudioCapture",1),__decorateClass([reportRtcSdkApiCall()],RTCEngine.prototype,"stopAudioCapture",1),__decorateClass([reportRtcSdkApiCall()],RTCEngine.prototype,"getAudioMixingManager",1),__decorateClass([reportRtcSdkApiCall()],RTCEngine.prototype,"startScreenCapture",1),__decorateClass([reportRtcSdkApiCall()],RTCEngine.prototype,"stopScreenCapture",1),__decorateClass([reportRtcSdkApiCall()],RTCEngine.prototype,"setLocalVideoPlayer",1),__decorateClass([reportRtcSdkApiCall()],RTCEngine.prototype,"startLiveTranscoding",1),__decorateClass([reportRtcSdkApiCall()],RTCEngine.prototype,"updateLiveTranscoding",1),__decorateClass([reportRtcSdkApiCall()],RTCEngine.prototype,"stopLiveTranscoding",1),__decorateClass([reportRtcSdkApiCall()],RTCEngine.prototype,"setBusinessId",1),__decorateClass([reportRtcSdkApiCall()],RTCEngine.prototype,"setUserVisibility",1),__decorateClass([reportRtcSdkApiCall()],RTCEngine.prototype,"setRemoteVideoPlayer",1),__decorateClass([reportRtcSdkApiCall()],RTCEngine.prototype,"setLocalVideoMirrorType",1),__decorateClass([reportRtcSdkApiCall()],RTCEngine.prototype,"setAudioPlaybackDevice",1),__decorateClass([reportRtcSdkApiCall()],RTCEngine.prototype,"play",1),__decorateClass([reportRtcSdkApiCall()],RTCEngine.prototype,"pauseAllSubscribedStream",1),__decorateClass([reportRtcSdkApiCall()],RTCEngine.prototype,"resumeAllSubscribedStream",1),__decorateClass([reportRtcSdkApiCall()],RTCEngine.prototype,"sendUserMessage",1),__decorateClass([reportRtcSdkApiCall()],RTCEngine.prototype,"sendUserBinaryMessage",1),__decorateClass([reportRtcSdkApiCall()],RTCEngine.prototype,"sendRoomMessage",1),__decorateClass([reportRtcSdkApiCall()],RTCEngine.prototype,"sendRoomBinaryMessage",1),__decorateClass([reportRtcSdkApiCall()],RTCEngine.prototype,"setAudioCaptureConfig",1),__decorateClass([reportRtcSdkApiCall()],RTCEngine.prototype,"setVideoCaptureConfig",1),__decorateClass([reportRtcSdkApiCall()],RTCEngine.prototype,"enableSimulcastMode",1),__decorateClass([reportRtcSdkApiCall()],RTCEngine.prototype,"setVideoEncoderConfig",1),__decorateClass([reportRtcSdkApiCall()],RTCEngine.prototype,"setScreenEncoderConfig",1),__decorateClass([reportRtcSdkApiCall()],RTCEngine.prototype,"sendSEIMessage",1),__decorateClass([reportRtcSdkApiCall()],RTCEngine.prototype,"setAudioVolumeIndicationInterval",1),__decorateClass([reportRtcSdkApiCall()],RTCEngine.prototype,"enableAudioPropertiesReport",1),__decorateClass([reportRtcSdkApiCall()],RTCEngine.prototype,"setVideoSourceType",1),__decorateClass([reportRtcSdkApiCall()],RTCEngine.prototype,"setExternalVideoTrack",1),__decorateClass([reportRtcSdkApiCall()],RTCEngine.prototype,"setAudioSourceType",1),__decorateClass([reportRtcSdkApiCall()],RTCEngine.prototype,"setExternalAudioTrack",1),__decorateClass([reportRtcSdkApiCall("rtm")],RTCEngine.prototype,"login",1),__decorateClass([reportRtcSdkApiCall("rtm")],RTCEngine.prototype,"logout",1),__decorateClass([reportRtcSdkApiCall("rtm")],RTCEngine.prototype,"updateLoginToken",1),__decorateClass([reportRtcSdkApiCall("rtm")],RTCEngine.prototype,"getPeerOnlineStatus",1),__decorateClass([reportRtcSdkApiCall("rtm")],RTCEngine.prototype,"sendUserMessageOutsideRoom",1),__decorateClass([reportRtcSdkApiCall("rtm")],RTCEngine.prototype,"sendUserBinaryMessageOutsideRoom",1),__decorateClass([reportRtcSdkApiCall("rtm")],RTCEngine.prototype,"setServerParams",1),__decorateClass([reportRtcSdkApiCall("rtm")],RTCEngine.prototype,"sendServerMessage",1),__decorateClass([reportRtcSdkApiCall("rtm")],RTCEngine.prototype,"sendServerBinaryMessage",1),__decorateClass([reportRtcSdkApiCall()],RTCEngine.prototype,"startCloudProxy",1),__decorateClass([reportRtcSdkApiCall()],RTCEngine.prototype,"stopCloudProxy",1),__decorateClass([reportRtcSdkApiCall()],RTCEngine.prototype,"startPushPublicStream",1),__decorateClass([reportRtcSdkApiCall()],RTCEngine.prototype,"updatePublicStreamParam",1),__decorateClass([reportRtcSdkApiCall()],RTCEngine.prototype,"stopPushPublicStream",1),__decorateClass([reportRtcSdkApiCall("outsideRoom")],RTCEngine.prototype,"startPlayPublicStream",1),__decorateClass([reportRtcSdkApiCall("outsideRoom")],RTCEngine.prototype,"stopPlayPublicStream",1),__decorateClass([reportRtcSdkApiCall()],RTCEngine.prototype,"setAudioProfile",1),__decorateClass([reportRtcSdkApiCall("outsideRoom")],RTCEngine.prototype,"setPublicStreamVideoPlayer",1),__decorateClass([reportRtcSdkApiCall()],RTCEngine.prototype,"setDummyCaptureImagePath",1),__decorateClass([reportRtcSdkApiCall()],RTCEngine.prototype,"startAudioPlaybackDeviceTest",1),__decorateClass([reportRtcSdkApiCall()],RTCEngine.prototype,"stopAudioPlaybackDeviceTest",1),__decorateClass([reportRtcSdkApiCall()],RTCEngine.prototype,"startAudioDeviceRecordTest",1),__decorateClass([reportRtcSdkApiCall()],RTCEngine.prototype,"stopAudioDeviceRecordAndPlayTest",1),__decorateClass([reportRtcSdkApiCall()],RTCEngine.prototype,"stopAudioDevicePlayTest",1),__decorateClass([reportRtcSdkApiCall()],RTCEngine.prototype,"setRemoteUserPriority",1),__decorateClass([reportRtcSdkApiCall()],RTCEngine.prototype,"takeLocalSnapshot",1),__decorateClass([reportRtcSdkApiCall()],RTCEngine.prototype,"takeRemoteSnapshot",1),__decorateClass([reportRtcSdkApiCall()],RTCEngine.prototype,"setSubscribeFallbackOption",1),__decorateClass([reportRtcSdkApiCall()],RTCEngine.prototype,"_setCaptureVolume",1);var StreamRemoveReasonMap={"client unpublished":StreamRemoveReason.STREAM_REMOVE_REASON_UNPUBLISH,"publish failed":StreamRemoveReason.STREAM_REMOVE_REASON_PUBLISH_FAILED,"stream removed":StreamRemoveReason.STREAM_REMOVE_REASON_KEEP_LIVE_FAILED,"client disconnected":StreamRemoveReason.STREAM_REMOVE_REASON_CLIENT_DISCONNECTED,"client republish":StreamRemoveReason.STREAM_REMOVE_REASON_REPUBLISH},logger=new Logger("VERTC",0);[commonStats,rtmCommonStats,outsideRoomCommonStats].forEach((function(e){var t;return e.setStats({rtc_sdk_version:Config.VERSION,product_line:CommonProductLine.RTC,report_version:CommonReportVersion.W_5,os:CommonOs.WEB,device_id:sdkCache.getDeviceId(),user_agent:isSSR()?"":null===(t=navigator)||void 0===t?void 0:t.userAgent})}));var createEngine=function(e,t){return logger.print("createEngine","Invoke VERTC.createEngine"),checkString(e,"appId"),[commonStats,rtmCommonStats,outsideRoomCommonStats].forEach((function(r){return r.setStats({rtc_app_id:e,auto_play_policy:null==t?void 0:t.autoPlayPolicy})})),monitor.sdkInitEngine(Date.now(),SdkinitengineType.BEGIN),new RTCEngine(e,t)},destroyEngine=function(e){if(logger.print("destroyEngine","Invoke VERTC.destroyEngine"),!(e instanceof RTCEngine))throw new SDKError(ErrorCode.INVALID_ENGINE,"Invalid engine object");e.destroy(),monitor.sdkInitEngine(Date.now(),SdkinitengineType.END)},enumerateDevices=function(){var e=_asyncToGenerator(_regeneratorRuntime().mark((function e(){return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",detector.enumerateDevices());case 1:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),enableDevices=function(){var e=_asyncToGenerator(_regeneratorRuntime().mark((function e(){var t,r,n,i,o=arguments;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=o.length>0&&void 0!==o[0]?o[0]:{video:!0,audio:!0},r=t.video,n=t.audio,i={video:!1,audio:!1},!r){e.next=12;break}return e.prev=4,e.next=7,detector.getVideoPermission();case 7:i.video=e.sent,e.next=12;break;case 10:e.prev=10,e.t0=e.catch(4);case 12:if(!n){e.next=21;break}return e.prev=13,e.next=16,detector.getAudioPermission();case 16:i.audio=e.sent,e.next=21;break;case 19:e.prev=19,e.t1=e.catch(13);case 21:return e.abrupt("return",i);case 22:case"end":return e.stop()}}),e,null,[[4,10],[13,19]])})));return function(){return e.apply(this,arguments)}}(),enumerateAudioCaptureDevices=function(){var e=_asyncToGenerator(_regeneratorRuntime().mark((function e(){return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",detector.enumerateAudioCaptureDevices());case 1:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),enumerateVideoCaptureDevices=function(){var e=_asyncToGenerator(_regeneratorRuntime().mark((function e(){return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",detector.enumerateVideoCaptureDevices());case 1:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),enumerateAudioPlaybackDevices=function(){var e=_asyncToGenerator(_regeneratorRuntime().mark((function e(){return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",detector.enumerateAudioPlaybackDevices());case 1:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),getSdkVersion=function(){return Config.VERSION},isSupported2=function(){return monitor.rtcSdkApiCall("isSupported",0,""),isSupported()},getSupportedCodecs2=function(){return monitor.rtcSdkApiCall("getSupportedCodecs",0,""),getSupportedCodecs()};!isSSR()&&location.search.includes("_rtc_autotest_");var VERTC=_createClass((function e(){_classCallCheck(this,e),_defineProperty(this,"getSdkVersion",getSdkVersion),_defineProperty(this,"createEngine",createEngine),_defineProperty(this,"destroyEngine",destroyEngine),_defineProperty(this,"enumerateDevices",enumerateDevices),_defineProperty(this,"enableDevices",enableDevices),_defineProperty(this,"enumerateAudioCaptureDevices",enumerateAudioCaptureDevices),_defineProperty(this,"enumerateVideoCaptureDevices",enumerateVideoCaptureDevices),_defineProperty(this,"enumerateAudioPlaybackDevices",enumerateAudioPlaybackDevices),_defineProperty(this,"getParameter",getParameter),_defineProperty(this,"setParameter",setParameter),_defineProperty(this,"isSupported",isSupported2),_defineProperty(this,"getSupportedCodecs",getSupportedCodecs2),_defineProperty(this,"events",EngineEventsTypes),_defineProperty(this,"ErrorCode",ErrorCode),_defineProperty(this,"platform","".concat({}.PRODUCT_PLATFORM)),_defineProperty(this,"_monitor",monitor)})),index=new VERTC;export{AudioMixingDualMonoMode,AudioMixingType,AudioProfileType,AudioSourceType,ChannelProfile,ConnectionState,FallbackOrRecoverReason,LogChannel,MediaType,MirrorMode,MirrorType,NetworkQuality,PublicInterpolationMode,PublicStreamType,PublishState,RTCAutoPlayPolicy,RemoteUserPriority,RoomProfileType,StreamIndex,StreamRemoveReason,SubscribeFallbackOption,SubscribeMode,SubscribeState,USER_ONLINE_STATUS,UserOfflineReason,VideoRenderMode,VideoSourceType,index as default};
|
|
6
|
+
function _mergeNamespaces(e,t){return t.forEach((function(t){t&&"string"!=typeof t&&!Array.isArray(t)&&Object.keys(t).forEach((function(r){if("default"!==r&&!(r in e)){var n=Object.getOwnPropertyDescriptor(t,r);Object.defineProperty(e,r,n.get?n:{enumerable:!0,get:function(){return t[r]}})}}))})),Object.freeze(Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}))}function _asyncIterator(e){var t,r,n,i=2;for("undefined"!=typeof Symbol&&(r=Symbol.asyncIterator,n=Symbol.iterator);i--;){if(r&&null!=(t=e[r]))return t.call(e);if(n&&null!=(t=e[n]))return new AsyncFromSyncIterator(t.call(e));r="@@asyncIterator",n="@@iterator"}throw new TypeError("Object is not async iterable")}function AsyncFromSyncIterator(e){function t(e){if(Object(e)!==e)return Promise.reject(new TypeError(e+" is not an object."));var t=e.done;return Promise.resolve(e.value).then((function(e){return{value:e,done:t}}))}return AsyncFromSyncIterator=function(e){this.s=e,this.n=e.next},AsyncFromSyncIterator.prototype={s:null,n:null,next:function(){return t(this.n.apply(this.s,arguments))},return:function(e){var r=this.s.return;return void 0===r?Promise.resolve({value:e,done:!0}):t(r.apply(this.s,arguments))},throw:function(e){var r=this.s.return;return void 0===r?Promise.reject(e):t(r.apply(this.s,arguments))}},new AsyncFromSyncIterator(e)}function ownKeys$2(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function _objectSpread2(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?ownKeys$2(Object(r),!0).forEach((function(t){_defineProperty(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):ownKeys$2(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function _regeneratorRuntime(){_regeneratorRuntime=function(){return e};var e={},t=Object.prototype,r=t.hasOwnProperty,n=Object.defineProperty||function(e,t,r){e[t]=r.value},i="function"==typeof Symbol?Symbol:{},o=i.iterator||"@@iterator",a=i.asyncIterator||"@@asyncIterator",s=i.toStringTag||"@@toStringTag";function c(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{c({},"")}catch(e){c=function(e,t,r){return e[t]=r}}function u(e,t,r,i){var o=t&&t.prototype instanceof p?t:p,a=Object.create(o.prototype),s=new I(i||[]);return n(a,"_invoke",{value:E(e,r,s)}),a}function l(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}e.wrap=u;var d={};function p(){}function _(){}function f(){}var h={};c(h,o,(function(){return this}));var m=Object.getPrototypeOf,y=m&&m(m($([])));y&&y!==t&&r.call(y,o)&&(h=y);var v=f.prototype=p.prototype=Object.create(h);function S(e){["next","throw","return"].forEach((function(t){c(e,t,(function(e){return this._invoke(t,e)}))}))}function g(e,t){function i(n,o,a,s){var c=l(e[n],e,o);if("throw"!==c.type){var u=c.arg,d=u.value;return d&&"object"==typeof d&&r.call(d,"__await")?t.resolve(d.__await).then((function(e){i("next",e,a,s)}),(function(e){i("throw",e,a,s)})):t.resolve(d).then((function(e){u.value=e,a(u)}),(function(e){return i("throw",e,a,s)}))}s(c.arg)}var o;n(this,"_invoke",{value:function(e,r){function n(){return new t((function(t,n){i(e,r,t,n)}))}return o=o?o.then(n,n):n()}})}function E(e,t,r){var n="suspendedStart";return function(i,o){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===i)throw o;return A()}for(r.method=i,r.arg=o;;){var a=r.delegate;if(a){var s=T(a,r);if(s){if(s===d)continue;return s}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var c=l(e,t,r);if("normal"===c.type){if(n=r.done?"completed":"suspendedYield",c.arg===d)continue;return{value:c.arg,done:r.done}}"throw"===c.type&&(n="completed",r.method="throw",r.arg=c.arg)}}}function T(e,t){var r=e.iterator[t.method];if(void 0===r){if(t.delegate=null,"throw"===t.method){if(e.iterator.return&&(t.method="return",t.arg=void 0,T(e,t),"throw"===t.method))return d;t.method="throw",t.arg=new TypeError("The iterator does not provide a 'throw' method")}return d}var n=l(r,e.iterator,t.arg);if("throw"===n.type)return t.method="throw",t.arg=n.arg,t.delegate=null,d;var i=n.arg;return i?i.done?(t[e.resultName]=i.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,d):i:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,d)}function b(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function R(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function I(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(b,this),this.reset(!0)}function $(e){if(e){var t=e[o];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var n=-1,i=function t(){for(;++n<e.length;)if(r.call(e,n))return t.value=e[n],t.done=!1,t;return t.value=void 0,t.done=!0,t};return i.next=i}}return{next:A}}function A(){return{value:void 0,done:!0}}return _.prototype=f,n(v,"constructor",{value:f,configurable:!0}),n(f,"constructor",{value:_,configurable:!0}),_.displayName=c(f,s,"GeneratorFunction"),e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===_||"GeneratorFunction"===(t.displayName||t.name))},e.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,f):(e.__proto__=f,c(e,s,"GeneratorFunction")),e.prototype=Object.create(v),e},e.awrap=function(e){return{__await:e}},S(g.prototype),c(g.prototype,a,(function(){return this})),e.AsyncIterator=g,e.async=function(t,r,n,i,o){void 0===o&&(o=Promise);var a=new g(u(t,r,n,i),o);return e.isGeneratorFunction(r)?a:a.next().then((function(e){return e.done?e.value:a.next()}))},S(v),c(v,s,"Generator"),c(v,o,(function(){return this})),c(v,"toString",(function(){return"[object Generator]"})),e.keys=function(e){var t=Object(e),r=[];for(var n in t)r.push(n);return r.reverse(),function e(){for(;r.length;){var n=r.pop();if(n in t)return e.value=n,e.done=!1,e}return e.done=!0,e}},e.values=$,I.prototype={constructor:I,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(R),!e)for(var t in this)"t"===t.charAt(0)&&r.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=void 0)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var t=this;function n(r,n){return a.type="throw",a.arg=e,t.next=r,n&&(t.method="next",t.arg=void 0),!!n}for(var i=this.tryEntries.length-1;i>=0;--i){var o=this.tryEntries[i],a=o.completion;if("root"===o.tryLoc)return n("end");if(o.tryLoc<=this.prev){var s=r.call(o,"catchLoc"),c=r.call(o,"finallyLoc");if(s&&c){if(this.prev<o.catchLoc)return n(o.catchLoc,!0);if(this.prev<o.finallyLoc)return n(o.finallyLoc)}else if(s){if(this.prev<o.catchLoc)return n(o.catchLoc,!0)}else{if(!c)throw new Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return n(o.finallyLoc)}}}},abrupt:function(e,t){for(var n=this.tryEntries.length-1;n>=0;--n){var i=this.tryEntries[n];if(i.tryLoc<=this.prev&&r.call(i,"finallyLoc")&&this.prev<i.finallyLoc){var o=i;break}}o&&("break"===e||"continue"===e)&&o.tryLoc<=t&&t<=o.finallyLoc&&(o=null);var a=o?o.completion:{};return a.type=e,a.arg=t,o?(this.method="next",this.next=o.finallyLoc,d):this.complete(a)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),d},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),R(r),d}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var n=r.completion;if("throw"===n.type){var i=n.arg;R(r)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,r){return this.delegate={iterator:$(e),resultName:t,nextLoc:r},"next"===this.method&&(this.arg=void 0),d}},e}function _typeof(e){return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},_typeof(e)}function asyncGeneratorStep(e,t,r,n,i,o,a){try{var s=e[o](a),c=s.value}catch(e){return void r(e)}s.done?t(c):Promise.resolve(c).then(n,i)}function _asyncToGenerator(e){return function(){var t=this,r=arguments;return new Promise((function(n,i){var o=e.apply(t,r);function a(e){asyncGeneratorStep(o,n,i,a,s,"next",e)}function s(e){asyncGeneratorStep(o,n,i,a,s,"throw",e)}a(void 0)}))}}function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function _defineProperties(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)}}function _createClass(e,t,r){return t&&_defineProperties(e.prototype,t),r&&_defineProperties(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function _defineProperty(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function _inherits(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&_setPrototypeOf(e,t)}function _getPrototypeOf(e){return _getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},_getPrototypeOf(e)}function _setPrototypeOf(e,t){return _setPrototypeOf=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},_setPrototypeOf(e,t)}function _isNativeReflectConstruct(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}function _objectWithoutPropertiesLoose(e,t){if(null==e)return{};var r,n,i={},o=Object.keys(e);for(n=0;n<o.length;n++)r=o[n],t.indexOf(r)>=0||(i[r]=e[r]);return i}function _objectWithoutProperties(e,t){if(null==e)return{};var r,n,i=_objectWithoutPropertiesLoose(e,t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(n=0;n<o.length;n++)r=o[n],t.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(i[r]=e[r])}return i}function _assertThisInitialized(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function _possibleConstructorReturn(e,t){if(t&&("object"==typeof t||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return _assertThisInitialized(e)}function _createSuper(e){var t=_isNativeReflectConstruct();return function(){var r,n=_getPrototypeOf(e);if(t){var i=_getPrototypeOf(this).constructor;r=Reflect.construct(n,arguments,i)}else r=n.apply(this,arguments);return _possibleConstructorReturn(this,r)}}function _superPropBase(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=_getPrototypeOf(e)););return e}function _get(){return _get="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(e,t,r){var n=_superPropBase(e,t);if(n){var i=Object.getOwnPropertyDescriptor(n,t);return i.get?i.get.call(arguments.length<3?e:r):i.value}},_get.apply(this,arguments)}function _slicedToArray(e,t){return _arrayWithHoles(e)||_iterableToArrayLimit(e,t)||_unsupportedIterableToArray(e,t)||_nonIterableRest()}function _toConsumableArray(e){return _arrayWithoutHoles(e)||_iterableToArray(e)||_unsupportedIterableToArray(e)||_nonIterableSpread()}function _arrayWithoutHoles(e){if(Array.isArray(e))return _arrayLikeToArray(e)}function _arrayWithHoles(e){if(Array.isArray(e))return e}function _iterableToArray(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}function _iterableToArrayLimit(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var n,i,o=[],a=!0,s=!1;try{for(r=r.call(e);!(a=(n=r.next()).done)&&(o.push(n.value),!t||o.length!==t);a=!0);}catch(e){s=!0,i=e}finally{try{a||null==r.return||r.return()}finally{if(s)throw i}}return o}}function _unsupportedIterableToArray(e,t){if(e){if("string"==typeof e)return _arrayLikeToArray(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?_arrayLikeToArray(e,t):void 0}}function _arrayLikeToArray(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function _nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _createForOfIteratorHelper(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=_unsupportedIterableToArray(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0,i=function(){};return{s:i,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,s=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return a=e.done,e},e:function(e){s=!0,o=e},f:function(){try{a||null==r.return||r.return()}finally{if(s)throw o}}}}var commonjsGlobal="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},check=function(e){return e&&e.Math==Math&&e},global$K=check("object"==typeof globalThis&&globalThis)||check("object"==typeof window&&window)||check("object"==typeof self&&self)||check("object"==typeof commonjsGlobal&&commonjsGlobal)||function(){return this}()||Function("return this")(),shared$7={exports:{}},isPure=!1,global$J=global$K,defineProperty$i=Object.defineProperty,defineGlobalProperty$3=function(e,t){try{defineProperty$i(global$J,e,{value:t,configurable:!0,writable:!0})}catch(r){global$J[e]=t}return t},global$I=global$K,defineGlobalProperty$2=defineGlobalProperty$3,SHARED="__core-js_shared__",store$3=global$I[SHARED]||defineGlobalProperty$2(SHARED,{}),sharedStore=store$3,store$2=sharedStore;(shared$7.exports=function(e,t){return store$2[e]||(store$2[e]=void 0!==t?t:{})})("versions",[]).push({version:"3.26.1",mode:"global",copyright:"© 2014-2022 Denis Pushkarev (zloirock.ru)",license:"https://github.com/zloirock/core-js/blob/v3.26.1/LICENSE",source:"https://github.com/zloirock/core-js"});var match,version,fails$U=function(e){try{return!!e()}catch(e){return!0}},fails$T=fails$U,functionBindNative=!fails$T((function(){var e=function(){}.bind();return"function"!=typeof e||e.hasOwnProperty("prototype")})),NATIVE_BIND$3=functionBindNative,FunctionPrototype$2=Function.prototype,call$y=FunctionPrototype$2.call,uncurryThisWithBind=NATIVE_BIND$3&&FunctionPrototype$2.bind.bind(call$y,call$y),functionUncurryThis=NATIVE_BIND$3?uncurryThisWithBind:function(e){return function(){return call$y.apply(e,arguments)}},isNullOrUndefined$b=function(e){return null==e},isNullOrUndefined$a=isNullOrUndefined$b,$TypeError$l=TypeError,requireObjectCoercible$d=function(e){if(isNullOrUndefined$a(e))throw $TypeError$l("Can't call method on "+e);return e},requireObjectCoercible$c=requireObjectCoercible$d,$Object$4=Object,toObject$i=function(e){return $Object$4(requireObjectCoercible$c(e))},uncurryThis$Q=functionUncurryThis,toObject$h=toObject$i,hasOwnProperty$7=uncurryThis$Q({}.hasOwnProperty),hasOwnProperty_1=Object.hasOwn||function(e,t){return hasOwnProperty$7(toObject$h(e),t)},uncurryThis$P=functionUncurryThis,id$2=0,postfix=Math.random(),toString$p=uncurryThis$P(1..toString),uid$5=function(e){return"Symbol("+(void 0===e?"":e)+")_"+toString$p(++id$2+postfix,36)},documentAll$2="object"==typeof document&&document.all,IS_HTMLDDA=void 0===documentAll$2&&void 0!==documentAll$2,documentAll_1={all:documentAll$2,IS_HTMLDDA:IS_HTMLDDA},$documentAll$1=documentAll_1,documentAll$1=$documentAll$1.all,isCallable$t=$documentAll$1.IS_HTMLDDA?function(e){return"function"==typeof e||e===documentAll$1}:function(e){return"function"==typeof e},global$H=global$K,isCallable$s=isCallable$t,aFunction=function(e){return isCallable$s(e)?e:void 0},getBuiltIn$g=function(e,t){return arguments.length<2?aFunction(global$H[e]):global$H[e]&&global$H[e][t]},getBuiltIn$f=getBuiltIn$g,engineUserAgent=getBuiltIn$f("navigator","userAgent")||"",global$G=global$K,userAgent$6=engineUserAgent,process$3=global$G.process,Deno$1=global$G.Deno,versions=process$3&&process$3.versions||Deno$1&&Deno$1.version,v8=versions&&versions.v8;v8&&(version=(match=v8.split("."))[0]>0&&match[0]<4?1:+(match[0]+match[1])),!version&&userAgent$6&&(!(match=userAgent$6.match(/Edge\/(\d+)/))||match[1]>=74)&&(match=userAgent$6.match(/Chrome\/(\d+)/))&&(version=+match[1]);var engineV8Version=version,V8_VERSION$3=engineV8Version,fails$S=fails$U,symbolConstructorDetection=!!Object.getOwnPropertySymbols&&!fails$S((function(){var e=Symbol();return!String(e)||!(Object(e)instanceof Symbol)||!Symbol.sham&&V8_VERSION$3&&V8_VERSION$3<41})),NATIVE_SYMBOL$5=symbolConstructorDetection,useSymbolAsUid=NATIVE_SYMBOL$5&&!Symbol.sham&&"symbol"==typeof Symbol.iterator,global$F=global$K,shared$6=shared$7.exports,hasOwn$q=hasOwnProperty_1,uid$4=uid$5,NATIVE_SYMBOL$4=symbolConstructorDetection,USE_SYMBOL_AS_UID$1=useSymbolAsUid,WellKnownSymbolsStore$1=shared$6("wks"),Symbol$5=global$F.Symbol,symbolFor=Symbol$5&&Symbol$5.for,createWellKnownSymbol=USE_SYMBOL_AS_UID$1?Symbol$5:Symbol$5&&Symbol$5.withoutSetter||uid$4,wellKnownSymbol$u=function(e){if(!hasOwn$q(WellKnownSymbolsStore$1,e)||!NATIVE_SYMBOL$4&&"string"!=typeof WellKnownSymbolsStore$1[e]){var t="Symbol."+e;NATIVE_SYMBOL$4&&hasOwn$q(Symbol$5,e)?WellKnownSymbolsStore$1[e]=Symbol$5[e]:WellKnownSymbolsStore$1[e]=USE_SYMBOL_AS_UID$1&&symbolFor?symbolFor(t):createWellKnownSymbol(t)}return WellKnownSymbolsStore$1[e]},wellKnownSymbol$t=wellKnownSymbol$u,TO_STRING_TAG$4=wellKnownSymbol$t("toStringTag"),test$1={};test$1[TO_STRING_TAG$4]="z";var toStringTagSupport="[object z]"===String(test$1),objectDefineProperty={},fails$R=fails$U,descriptors=!fails$R((function(){return 7!=Object.defineProperty({},1,{get:function(){return 7}})[1]})),isCallable$r=isCallable$t,$documentAll=documentAll_1,documentAll=$documentAll.all,isObject$s=$documentAll.IS_HTMLDDA?function(e){return"object"==typeof e?null!==e:isCallable$r(e)||e===documentAll}:function(e){return"object"==typeof e?null!==e:isCallable$r(e)},global$E=global$K,isObject$r=isObject$s,document$3=global$E.document,EXISTS$1=isObject$r(document$3)&&isObject$r(document$3.createElement),documentCreateElement$2=function(e){return EXISTS$1?document$3.createElement(e):{}},DESCRIPTORS$u=descriptors,fails$Q=fails$U,createElement$2=documentCreateElement$2,ie8DomDefine=!DESCRIPTORS$u&&!fails$Q((function(){return 7!=Object.defineProperty(createElement$2("div"),"a",{get:function(){return 7}}).a})),DESCRIPTORS$t=descriptors,fails$P=fails$U,v8PrototypeDefineBug=DESCRIPTORS$t&&fails$P((function(){return 42!=Object.defineProperty((function(){}),"prototype",{value:42,writable:!1}).prototype})),isObject$q=isObject$s,$String$3=String,$TypeError$k=TypeError,anObject$q=function(e){if(isObject$q(e))return e;throw $TypeError$k($String$3(e)+" is not an object")},NATIVE_BIND$2=functionBindNative,call$x=Function.prototype.call,functionCall=NATIVE_BIND$2?call$x.bind(call$x):function(){return call$x.apply(call$x,arguments)},uncurryThis$O=functionUncurryThis,objectIsPrototypeOf=uncurryThis$O({}.isPrototypeOf),getBuiltIn$e=getBuiltIn$g,isCallable$q=isCallable$t,isPrototypeOf$9=objectIsPrototypeOf,USE_SYMBOL_AS_UID=useSymbolAsUid,$Object$3=Object,isSymbol$6=USE_SYMBOL_AS_UID?function(e){return"symbol"==typeof e}:function(e){var t=getBuiltIn$e("Symbol");return isCallable$q(t)&&isPrototypeOf$9(t.prototype,$Object$3(e))},$String$2=String,tryToString$7=function(e){try{return $String$2(e)}catch(e){return"Object"}},isCallable$p=isCallable$t,tryToString$6=tryToString$7,$TypeError$j=TypeError,aCallable$b=function(e){if(isCallable$p(e))return e;throw $TypeError$j(tryToString$6(e)+" is not a function")},aCallable$a=aCallable$b,isNullOrUndefined$9=isNullOrUndefined$b,getMethod$7=function(e,t){var r=e[t];return isNullOrUndefined$9(r)?void 0:aCallable$a(r)},call$w=functionCall,isCallable$o=isCallable$t,isObject$p=isObject$s,$TypeError$i=TypeError,ordinaryToPrimitive$1=function(e,t){var r,n;if("string"===t&&isCallable$o(r=e.toString)&&!isObject$p(n=call$w(r,e)))return n;if(isCallable$o(r=e.valueOf)&&!isObject$p(n=call$w(r,e)))return n;if("string"!==t&&isCallable$o(r=e.toString)&&!isObject$p(n=call$w(r,e)))return n;throw $TypeError$i("Can't convert object to primitive value")},call$v=functionCall,isObject$o=isObject$s,isSymbol$5=isSymbol$6,getMethod$6=getMethod$7,ordinaryToPrimitive=ordinaryToPrimitive$1,wellKnownSymbol$s=wellKnownSymbol$u,$TypeError$h=TypeError,TO_PRIMITIVE=wellKnownSymbol$s("toPrimitive"),toPrimitive$3=function(e,t){if(!isObject$o(e)||isSymbol$5(e))return e;var r,n=getMethod$6(e,TO_PRIMITIVE);if(n){if(void 0===t&&(t="default"),r=call$v(n,e,t),!isObject$o(r)||isSymbol$5(r))return r;throw $TypeError$h("Can't convert object to primitive value")}return void 0===t&&(t="number"),ordinaryToPrimitive(e,t)},toPrimitive$2=toPrimitive$3,isSymbol$4=isSymbol$6,toPropertyKey$5=function(e){var t=toPrimitive$2(e,"string");return isSymbol$4(t)?t:t+""},DESCRIPTORS$s=descriptors,IE8_DOM_DEFINE$1=ie8DomDefine,V8_PROTOTYPE_DEFINE_BUG$1=v8PrototypeDefineBug,anObject$p=anObject$q,toPropertyKey$4=toPropertyKey$5,$TypeError$g=TypeError,$defineProperty$1=Object.defineProperty,$getOwnPropertyDescriptor$2=Object.getOwnPropertyDescriptor,ENUMERABLE="enumerable",CONFIGURABLE$1="configurable",WRITABLE="writable";objectDefineProperty.f=DESCRIPTORS$s?V8_PROTOTYPE_DEFINE_BUG$1?function(e,t,r){if(anObject$p(e),t=toPropertyKey$4(t),anObject$p(r),"function"==typeof e&&"prototype"===t&&"value"in r&&WRITABLE in r&&!r[WRITABLE]){var n=$getOwnPropertyDescriptor$2(e,t);n&&n[WRITABLE]&&(e[t]=r.value,r={configurable:CONFIGURABLE$1 in r?r[CONFIGURABLE$1]:n[CONFIGURABLE$1],enumerable:ENUMERABLE in r?r[ENUMERABLE]:n[ENUMERABLE],writable:!1})}return $defineProperty$1(e,t,r)}:$defineProperty$1:function(e,t,r){if(anObject$p(e),t=toPropertyKey$4(t),anObject$p(r),IE8_DOM_DEFINE$1)try{return $defineProperty$1(e,t,r)}catch(e){}if("get"in r||"set"in r)throw $TypeError$g("Accessors not supported");return"value"in r&&(e[t]=r.value),e};var makeBuiltIn$3={exports:{}},DESCRIPTORS$r=descriptors,hasOwn$p=hasOwnProperty_1,FunctionPrototype$1=Function.prototype,getDescriptor=DESCRIPTORS$r&&Object.getOwnPropertyDescriptor,EXISTS=hasOwn$p(FunctionPrototype$1,"name"),PROPER=EXISTS&&"something"===function(){}.name,CONFIGURABLE=EXISTS&&(!DESCRIPTORS$r||DESCRIPTORS$r&&getDescriptor(FunctionPrototype$1,"name").configurable),functionName={EXISTS:EXISTS,PROPER:PROPER,CONFIGURABLE:CONFIGURABLE},uncurryThis$N=functionUncurryThis,isCallable$n=isCallable$t,store$1=sharedStore,functionToString=uncurryThis$N(Function.toString);isCallable$n(store$1.inspectSource)||(store$1.inspectSource=function(e){return functionToString(e)});var set$3,get$2,has,inspectSource$3=store$1.inspectSource,global$D=global$K,isCallable$m=isCallable$t,WeakMap$2=global$D.WeakMap,weakMapBasicDetection=isCallable$m(WeakMap$2)&&/native code/.test(String(WeakMap$2)),createPropertyDescriptor$b=function(e,t){return{enumerable:!(1&e),configurable:!(2&e),writable:!(4&e),value:t}},DESCRIPTORS$q=descriptors,definePropertyModule$8=objectDefineProperty,createPropertyDescriptor$a=createPropertyDescriptor$b,createNonEnumerableProperty$c=DESCRIPTORS$q?function(e,t,r){return definePropertyModule$8.f(e,t,createPropertyDescriptor$a(1,r))}:function(e,t,r){return e[t]=r,e},shared$5=shared$7.exports,uid$3=uid$5,keys$4=shared$5("keys"),sharedKey$4=function(e){return keys$4[e]||(keys$4[e]=uid$3(e))},hiddenKeys$6={},NATIVE_WEAK_MAP$1=weakMapBasicDetection,global$C=global$K,isObject$n=isObject$s,createNonEnumerableProperty$b=createNonEnumerableProperty$c,hasOwn$o=hasOwnProperty_1,shared$4=sharedStore,sharedKey$3=sharedKey$4,hiddenKeys$5=hiddenKeys$6,OBJECT_ALREADY_INITIALIZED="Object already initialized",TypeError$7=global$C.TypeError,WeakMap$1=global$C.WeakMap,enforce=function(e){return has(e)?get$2(e):set$3(e,{})},getterFor$1=function(e){return function(t){var r;if(!isObject$n(t)||(r=get$2(t)).type!==e)throw TypeError$7("Incompatible receiver, "+e+" required");return r}};if(NATIVE_WEAK_MAP$1||shared$4.state){var store=shared$4.state||(shared$4.state=new WeakMap$1);store.get=store.get,store.has=store.has,store.set=store.set,set$3=function(e,t){if(store.has(e))throw TypeError$7(OBJECT_ALREADY_INITIALIZED);return t.facade=e,store.set(e,t),t},get$2=function(e){return store.get(e)||{}},has=function(e){return store.has(e)}}else{var STATE=sharedKey$3("state");hiddenKeys$5[STATE]=!0,set$3=function(e,t){if(hasOwn$o(e,STATE))throw TypeError$7(OBJECT_ALREADY_INITIALIZED);return t.facade=e,createNonEnumerableProperty$b(e,STATE,t),t},get$2=function(e){return hasOwn$o(e,STATE)?e[STATE]:{}},has=function(e){return hasOwn$o(e,STATE)}}var internalState={set:set$3,get:get$2,has:has,enforce:enforce,getterFor:getterFor$1},fails$O=fails$U,isCallable$l=isCallable$t,hasOwn$n=hasOwnProperty_1,DESCRIPTORS$p=descriptors,CONFIGURABLE_FUNCTION_NAME$2=functionName.CONFIGURABLE,inspectSource$2=inspectSource$3,InternalStateModule$c=internalState,enforceInternalState$4=InternalStateModule$c.enforce,getInternalState$a=InternalStateModule$c.get,defineProperty$h=Object.defineProperty,CONFIGURABLE_LENGTH=DESCRIPTORS$p&&!fails$O((function(){return 8!==defineProperty$h((function(){}),"length",{value:8}).length})),TEMPLATE=String(String).split("String"),makeBuiltIn$2=makeBuiltIn$3.exports=function(e,t,r){"Symbol("===String(t).slice(0,7)&&(t="["+String(t).replace(/^Symbol\(([^)]*)\)/,"$1")+"]"),r&&r.getter&&(t="get "+t),r&&r.setter&&(t="set "+t),(!hasOwn$n(e,"name")||CONFIGURABLE_FUNCTION_NAME$2&&e.name!==t)&&(DESCRIPTORS$p?defineProperty$h(e,"name",{value:t,configurable:!0}):e.name=t),CONFIGURABLE_LENGTH&&r&&hasOwn$n(r,"arity")&&e.length!==r.arity&&defineProperty$h(e,"length",{value:r.arity});try{r&&hasOwn$n(r,"constructor")&&r.constructor?DESCRIPTORS$p&&defineProperty$h(e,"prototype",{writable:!1}):e.prototype&&(e.prototype=void 0)}catch(e){}var n=enforceInternalState$4(e);return hasOwn$n(n,"source")||(n.source=TEMPLATE.join("string"==typeof t?t:"")),e};Function.prototype.toString=makeBuiltIn$2((function(){return isCallable$l(this)&&getInternalState$a(this).source||inspectSource$2(this)}),"toString");var isCallable$k=isCallable$t,definePropertyModule$7=objectDefineProperty,makeBuiltIn$1=makeBuiltIn$3.exports,defineGlobalProperty$1=defineGlobalProperty$3,defineBuiltIn$j=function(e,t,r,n){n||(n={});var i=n.enumerable,o=void 0!==n.name?n.name:t;if(isCallable$k(r)&&makeBuiltIn$1(r,o,n),n.global)i?e[t]=r:defineGlobalProperty$1(t,r);else{try{n.unsafe?e[t]&&(i=!0):delete e[t]}catch(e){}i?e[t]=r:definePropertyModule$7.f(e,t,{value:r,enumerable:!1,configurable:!n.nonConfigurable,writable:!n.nonWritable})}return e},uncurryThis$M=functionUncurryThis,toString$o=uncurryThis$M({}.toString),stringSlice$a=uncurryThis$M("".slice),classofRaw$2=function(e){return stringSlice$a(toString$o(e),8,-1)},TO_STRING_TAG_SUPPORT$2=toStringTagSupport,isCallable$j=isCallable$t,classofRaw$1=classofRaw$2,wellKnownSymbol$r=wellKnownSymbol$u,TO_STRING_TAG$3=wellKnownSymbol$r("toStringTag"),$Object$2=Object,CORRECT_ARGUMENTS="Arguments"==classofRaw$1(function(){return arguments}()),tryGet=function(e,t){try{return e[t]}catch(e){}},classof$i=TO_STRING_TAG_SUPPORT$2?classofRaw$1:function(e){var t,r,n;return void 0===e?"Undefined":null===e?"Null":"string"==typeof(r=tryGet(t=$Object$2(e),TO_STRING_TAG$3))?r:CORRECT_ARGUMENTS?classofRaw$1(t):"Object"==(n=classofRaw$1(t))&&isCallable$j(t.callee)?"Arguments":n},TO_STRING_TAG_SUPPORT$1=toStringTagSupport,classof$h=classof$i,objectToString$1=TO_STRING_TAG_SUPPORT$1?{}.toString:function(){return"[object "+classof$h(this)+"]"},TO_STRING_TAG_SUPPORT=toStringTagSupport,defineBuiltIn$i=defineBuiltIn$j,toString$n=objectToString$1;TO_STRING_TAG_SUPPORT||defineBuiltIn$i(Object.prototype,"toString",toString$n,{unsafe:!0});var domIterables={CSSRuleList:0,CSSStyleDeclaration:0,CSSValueList:0,ClientRectList:0,DOMRectList:0,DOMStringList:0,DOMTokenList:1,DataTransferItemList:0,FileList:0,HTMLAllCollection:0,HTMLCollection:0,HTMLFormElement:0,HTMLSelectElement:0,MediaList:0,MimeTypeArray:0,NamedNodeMap:0,NodeList:1,PaintRequestList:0,Plugin:0,PluginArray:0,SVGLengthList:0,SVGNumberList:0,SVGPathSegList:0,SVGPointList:0,SVGStringList:0,SVGTransformList:0,SourceBufferList:0,StyleSheetList:0,TextTrackCueList:0,TextTrackList:0,TouchList:0},documentCreateElement$1=documentCreateElement$2,classList=documentCreateElement$1("span").classList,DOMTokenListPrototype$2=classList&&classList.constructor&&classList.constructor.prototype,domTokenListPrototype=DOMTokenListPrototype$2===Object.prototype?void 0:DOMTokenListPrototype$2,classofRaw=classofRaw$2,uncurryThis$L=functionUncurryThis,functionUncurryThisClause=function(e){if("Function"===classofRaw(e))return uncurryThis$L(e)},uncurryThis$K=functionUncurryThisClause,aCallable$9=aCallable$b,NATIVE_BIND$1=functionBindNative,bind$b=functionUncurryThisClause(functionUncurryThisClause.bind),functionBindContext=function(e,t){return aCallable$9(e),void 0===t?e:NATIVE_BIND$1?bind$b(e,t):function(){return e.apply(t,arguments)}},uncurryThis$J=functionUncurryThis,fails$N=fails$U,classof$g=classofRaw$2,$Object$1=Object,split$3=uncurryThis$J("".split),indexedObject=fails$N((function(){return!$Object$1("z").propertyIsEnumerable(0)}))?function(e){return"String"==classof$g(e)?split$3(e,""):$Object$1(e)}:$Object$1,ceil$1=Math.ceil,floor$7=Math.floor,mathTrunc=Math.trunc||function(e){var t=+e;return(t>0?floor$7:ceil$1)(t)},trunc=mathTrunc,toIntegerOrInfinity$d=function(e){var t=+e;return t!=t||0===t?0:trunc(t)},toIntegerOrInfinity$c=toIntegerOrInfinity$d,min$8=Math.min,toLength$a=function(e){return e>0?min$8(toIntegerOrInfinity$c(e),9007199254740991):0},toLength$9=toLength$a,lengthOfArrayLike$m=function(e){return toLength$9(e.length)},classof$f=classofRaw$2,isArray$7=Array.isArray||function(e){return"Array"==classof$f(e)},uncurryThis$I=functionUncurryThis,fails$M=fails$U,isCallable$i=isCallable$t,classof$e=classof$i,getBuiltIn$d=getBuiltIn$g,inspectSource$1=inspectSource$3,noop=function(){},empty=[],construct=getBuiltIn$d("Reflect","construct"),constructorRegExp=/^\s*(?:class|function)\b/,exec$7=uncurryThis$I(constructorRegExp.exec),INCORRECT_TO_STRING$2=!constructorRegExp.exec(noop),isConstructorModern=function(e){if(!isCallable$i(e))return!1;try{return construct(noop,empty,e),!0}catch(e){return!1}},isConstructorLegacy=function(e){if(!isCallable$i(e))return!1;switch(classof$e(e)){case"AsyncFunction":case"GeneratorFunction":case"AsyncGeneratorFunction":return!1}try{return INCORRECT_TO_STRING$2||!!exec$7(constructorRegExp,inspectSource$1(e))}catch(e){return!0}};isConstructorLegacy.sham=!0;var isConstructor$4=!construct||fails$M((function(){var e;return isConstructorModern(isConstructorModern.call)||!isConstructorModern(Object)||!isConstructorModern((function(){e=!0}))||e}))?isConstructorLegacy:isConstructorModern,isArray$6=isArray$7,isConstructor$3=isConstructor$4,isObject$m=isObject$s,wellKnownSymbol$q=wellKnownSymbol$u,SPECIES$6=wellKnownSymbol$q("species"),$Array$4=Array,arraySpeciesConstructor$1=function(e){var t;return isArray$6(e)&&(t=e.constructor,(isConstructor$3(t)&&(t===$Array$4||isArray$6(t.prototype))||isObject$m(t)&&null===(t=t[SPECIES$6]))&&(t=void 0)),void 0===t?$Array$4:t},arraySpeciesConstructor=arraySpeciesConstructor$1,arraySpeciesCreate$3=function(e,t){return new(arraySpeciesConstructor(e))(0===t?0:t)},bind$a=functionBindContext,uncurryThis$H=functionUncurryThis,IndexedObject$4=indexedObject,toObject$g=toObject$i,lengthOfArrayLike$l=lengthOfArrayLike$m,arraySpeciesCreate$2=arraySpeciesCreate$3,push$9=uncurryThis$H([].push),createMethod$7=function(e){var t=1==e,r=2==e,n=3==e,i=4==e,o=6==e,a=7==e,s=5==e||o;return function(c,u,l,d){for(var p,_,f=toObject$g(c),h=IndexedObject$4(f),m=bind$a(u,l),y=lengthOfArrayLike$l(h),v=0,S=d||arraySpeciesCreate$2,g=t?S(c,y):r||a?S(c,0):void 0;y>v;v++)if((s||v in h)&&(_=m(p=h[v],v,f),e))if(t)g[v]=_;else if(_)switch(e){case 3:return!0;case 5:return p;case 6:return v;case 2:push$9(g,p)}else switch(e){case 4:return!1;case 7:push$9(g,p)}return o?-1:n||i?i:g}},arrayIteration={forEach:createMethod$7(0),map:createMethod$7(1),filter:createMethod$7(2),some:createMethod$7(3),every:createMethod$7(4),find:createMethod$7(5),findIndex:createMethod$7(6),filterReject:createMethod$7(7)},fails$L=fails$U,arrayMethodIsStrict$5=function(e,t){var r=[][e];return!!r&&fails$L((function(){r.call(null,t||function(){return 1},1)}))},$forEach$2=arrayIteration.forEach,arrayMethodIsStrict$4=arrayMethodIsStrict$5,STRICT_METHOD$4=arrayMethodIsStrict$4("forEach"),arrayForEach=STRICT_METHOD$4?[].forEach:function(e){return $forEach$2(this,e,arguments.length>1?arguments[1]:void 0)},global$B=global$K,DOMIterables$1=domIterables,DOMTokenListPrototype$1=domTokenListPrototype,forEach$1=arrayForEach,createNonEnumerableProperty$a=createNonEnumerableProperty$c,handlePrototype$1=function(e){if(e&&e.forEach!==forEach$1)try{createNonEnumerableProperty$a(e,"forEach",forEach$1)}catch(t){e.forEach=forEach$1}};for(var COLLECTION_NAME$1 in DOMIterables$1)DOMIterables$1[COLLECTION_NAME$1]&&handlePrototype$1(global$B[COLLECTION_NAME$1]&&global$B[COLLECTION_NAME$1].prototype);handlePrototype$1(DOMTokenListPrototype$1);var objectGetOwnPropertyDescriptor={},objectPropertyIsEnumerable={},$propertyIsEnumerable$2={}.propertyIsEnumerable,getOwnPropertyDescriptor$7=Object.getOwnPropertyDescriptor,NASHORN_BUG=getOwnPropertyDescriptor$7&&!$propertyIsEnumerable$2.call({1:2},1);objectPropertyIsEnumerable.f=NASHORN_BUG?function(e){var t=getOwnPropertyDescriptor$7(this,e);return!!t&&t.enumerable}:$propertyIsEnumerable$2;var IndexedObject$3=indexedObject,requireObjectCoercible$b=requireObjectCoercible$d,toIndexedObject$c=function(e){return IndexedObject$3(requireObjectCoercible$b(e))},DESCRIPTORS$o=descriptors,call$u=functionCall,propertyIsEnumerableModule$2=objectPropertyIsEnumerable,createPropertyDescriptor$9=createPropertyDescriptor$b,toIndexedObject$b=toIndexedObject$c,toPropertyKey$3=toPropertyKey$5,hasOwn$m=hasOwnProperty_1,IE8_DOM_DEFINE=ie8DomDefine,$getOwnPropertyDescriptor$1=Object.getOwnPropertyDescriptor;objectGetOwnPropertyDescriptor.f=DESCRIPTORS$o?$getOwnPropertyDescriptor$1:function(e,t){if(e=toIndexedObject$b(e),t=toPropertyKey$3(t),IE8_DOM_DEFINE)try{return $getOwnPropertyDescriptor$1(e,t)}catch(e){}if(hasOwn$m(e,t))return createPropertyDescriptor$9(!call$u(propertyIsEnumerableModule$2.f,e,t),e[t])};var objectGetOwnPropertyNames={},toIntegerOrInfinity$b=toIntegerOrInfinity$d,max$4=Math.max,min$7=Math.min,toAbsoluteIndex$6=function(e,t){var r=toIntegerOrInfinity$b(e);return r<0?max$4(r+t,0):min$7(r,t)},toIndexedObject$a=toIndexedObject$c,toAbsoluteIndex$5=toAbsoluteIndex$6,lengthOfArrayLike$k=lengthOfArrayLike$m,createMethod$6=function(e){return function(t,r,n){var i,o=toIndexedObject$a(t),a=lengthOfArrayLike$k(o),s=toAbsoluteIndex$5(n,a);if(e&&r!=r){for(;a>s;)if((i=o[s++])!=i)return!0}else for(;a>s;s++)if((e||s in o)&&o[s]===r)return e||s||0;return!e&&-1}},arrayIncludes={includes:createMethod$6(!0),indexOf:createMethod$6(!1)},uncurryThis$G=functionUncurryThis,hasOwn$l=hasOwnProperty_1,toIndexedObject$9=toIndexedObject$c,indexOf$1=arrayIncludes.indexOf,hiddenKeys$4=hiddenKeys$6,push$8=uncurryThis$G([].push),objectKeysInternal=function(e,t){var r,n=toIndexedObject$9(e),i=0,o=[];for(r in n)!hasOwn$l(hiddenKeys$4,r)&&hasOwn$l(n,r)&&push$8(o,r);for(;t.length>i;)hasOwn$l(n,r=t[i++])&&(~indexOf$1(o,r)||push$8(o,r));return o},enumBugKeys$3=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"],internalObjectKeys$1=objectKeysInternal,enumBugKeys$2=enumBugKeys$3,hiddenKeys$3=enumBugKeys$2.concat("length","prototype");objectGetOwnPropertyNames.f=Object.getOwnPropertyNames||function(e){return internalObjectKeys$1(e,hiddenKeys$3)};var objectGetOwnPropertySymbols={};objectGetOwnPropertySymbols.f=Object.getOwnPropertySymbols;var getBuiltIn$c=getBuiltIn$g,uncurryThis$F=functionUncurryThis,getOwnPropertyNamesModule$2=objectGetOwnPropertyNames,getOwnPropertySymbolsModule$3=objectGetOwnPropertySymbols,anObject$o=anObject$q,concat$2=uncurryThis$F([].concat),ownKeys$1=getBuiltIn$c("Reflect","ownKeys")||function(e){var t=getOwnPropertyNamesModule$2.f(anObject$o(e)),r=getOwnPropertySymbolsModule$3.f;return r?concat$2(t,r(e)):t},hasOwn$k=hasOwnProperty_1,ownKeys=ownKeys$1,getOwnPropertyDescriptorModule$4=objectGetOwnPropertyDescriptor,definePropertyModule$6=objectDefineProperty,copyConstructorProperties$2=function(e,t,r){for(var n=ownKeys(t),i=definePropertyModule$6.f,o=getOwnPropertyDescriptorModule$4.f,a=0;a<n.length;a++){var s=n[a];hasOwn$k(e,s)||r&&hasOwn$k(r,s)||i(e,s,o(t,s))}},fails$K=fails$U,isCallable$h=isCallable$t,replacement=/#|\.prototype\./,isForced$5=function(e,t){var r=data[normalize(e)];return r==POLYFILL||r!=NATIVE&&(isCallable$h(t)?fails$K(t):!!t)},normalize=isForced$5.normalize=function(e){return String(e).replace(replacement,".").toLowerCase()},data=isForced$5.data={},NATIVE=isForced$5.NATIVE="N",POLYFILL=isForced$5.POLYFILL="P",isForced_1=isForced$5,global$A=global$K,getOwnPropertyDescriptor$6=objectGetOwnPropertyDescriptor.f,createNonEnumerableProperty$9=createNonEnumerableProperty$c,defineBuiltIn$h=defineBuiltIn$j,defineGlobalProperty=defineGlobalProperty$3,copyConstructorProperties$1=copyConstructorProperties$2,isForced$4=isForced_1,_export=function(e,t){var r,n,i,o,a,s=e.target,c=e.global,u=e.stat;if(r=c?global$A:u?global$A[s]||defineGlobalProperty(s,{}):(global$A[s]||{}).prototype)for(n in t){if(o=t[n],i=e.dontCallGetSet?(a=getOwnPropertyDescriptor$6(r,n))&&a.value:r[n],!isForced$4(c?n:s+(u?".":"#")+n,e.forced)&&void 0!==i){if(typeof o==typeof i)continue;copyConstructorProperties$1(o,i)}(e.sham||i&&i.sham)&&createNonEnumerableProperty$9(o,"sham",!0),defineBuiltIn$h(r,n,o,e)}},objectDefineProperties={},internalObjectKeys=objectKeysInternal,enumBugKeys$1=enumBugKeys$3,objectKeys$4=Object.keys||function(e){return internalObjectKeys(e,enumBugKeys$1)},DESCRIPTORS$n=descriptors,V8_PROTOTYPE_DEFINE_BUG=v8PrototypeDefineBug,definePropertyModule$5=objectDefineProperty,anObject$n=anObject$q,toIndexedObject$8=toIndexedObject$c,objectKeys$3=objectKeys$4;objectDefineProperties.f=DESCRIPTORS$n&&!V8_PROTOTYPE_DEFINE_BUG?Object.defineProperties:function(e,t){anObject$n(e);for(var r,n=toIndexedObject$8(t),i=objectKeys$3(t),o=i.length,a=0;o>a;)definePropertyModule$5.f(e,r=i[a++],n[r]);return e};var activeXDocument,getBuiltIn$b=getBuiltIn$g,html$2=getBuiltIn$b("document","documentElement"),anObject$m=anObject$q,definePropertiesModule$1=objectDefineProperties,enumBugKeys=enumBugKeys$3,hiddenKeys$2=hiddenKeys$6,html$1=html$2,documentCreateElement=documentCreateElement$2,sharedKey$2=sharedKey$4,GT=">",LT="<",PROTOTYPE$2="prototype",SCRIPT="script",IE_PROTO$1=sharedKey$2("IE_PROTO"),EmptyConstructor=function(){},scriptTag=function(e){return LT+SCRIPT+GT+e+LT+"/"+SCRIPT+GT},NullProtoObjectViaActiveX=function(e){e.write(scriptTag("")),e.close();var t=e.parentWindow.Object;return e=null,t},NullProtoObjectViaIFrame=function(){var e,t=documentCreateElement("iframe"),r="java"+SCRIPT+":";return t.style.display="none",html$1.appendChild(t),t.src=String(r),(e=t.contentWindow.document).open(),e.write(scriptTag("document.F=Object")),e.close(),e.F},NullProtoObject=function(){try{activeXDocument=new ActiveXObject("htmlfile")}catch(e){}NullProtoObject="undefined"!=typeof document?document.domain&&activeXDocument?NullProtoObjectViaActiveX(activeXDocument):NullProtoObjectViaIFrame():NullProtoObjectViaActiveX(activeXDocument);for(var e=enumBugKeys.length;e--;)delete NullProtoObject[PROTOTYPE$2][enumBugKeys[e]];return NullProtoObject()};hiddenKeys$2[IE_PROTO$1]=!0;var objectCreate=Object.create||function(e,t){var r;return null!==e?(EmptyConstructor[PROTOTYPE$2]=anObject$m(e),r=new EmptyConstructor,EmptyConstructor[PROTOTYPE$2]=null,r[IE_PROTO$1]=e):r=NullProtoObject(),void 0===t?r:definePropertiesModule$1.f(r,t)},wellKnownSymbol$p=wellKnownSymbol$u,create$7=objectCreate,defineProperty$g=objectDefineProperty.f,UNSCOPABLES=wellKnownSymbol$p("unscopables"),ArrayPrototype$1=Array.prototype;null==ArrayPrototype$1[UNSCOPABLES]&&defineProperty$g(ArrayPrototype$1,UNSCOPABLES,{configurable:!0,value:create$7(null)});var addToUnscopables$4=function(e){ArrayPrototype$1[UNSCOPABLES][e]=!0},$$S=_export,$includes$1=arrayIncludes.includes,fails$J=fails$U,addToUnscopables$3=addToUnscopables$4,BROKEN_ON_SPARSE=fails$J((function(){return!Array(1).includes()}));$$S({target:"Array",proto:!0,forced:BROKEN_ON_SPARSE},{includes:function(e){return $includes$1(this,e,arguments.length>1?arguments[1]:void 0)}}),addToUnscopables$3("includes");var isObject$l=isObject$s,classof$d=classofRaw$2,wellKnownSymbol$o=wellKnownSymbol$u,MATCH$3=wellKnownSymbol$o("match"),isRegexp=function(e){var t;return isObject$l(e)&&(void 0!==(t=e[MATCH$3])?!!t:"RegExp"==classof$d(e))},isRegExp$2=isRegexp,$TypeError$f=TypeError,notARegexp=function(e){if(isRegExp$2(e))throw $TypeError$f("The method doesn't accept regular expressions");return e},classof$c=classof$i,$String$1=String,toString$m=function(e){if("Symbol"===classof$c(e))throw TypeError("Cannot convert a Symbol value to a string");return $String$1(e)},wellKnownSymbol$n=wellKnownSymbol$u,MATCH$2=wellKnownSymbol$n("match"),correctIsRegexpLogic=function(e){var t=/./;try{"/./"[e](t)}catch(r){try{return t[MATCH$2]=!1,"/./"[e](t)}catch(e){}}return!1},$$R=_export,uncurryThis$E=functionUncurryThis,notARegExp$2=notARegexp,requireObjectCoercible$a=requireObjectCoercible$d,toString$l=toString$m,correctIsRegExpLogic$2=correctIsRegexpLogic,stringIndexOf$2=uncurryThis$E("".indexOf);$$R({target:"String",proto:!0,forced:!correctIsRegExpLogic$2("includes")},{includes:function(e){return!!~stringIndexOf$2(toString$l(requireObjectCoercible$a(this)),toString$l(notARegExp$2(e)),arguments.length>1?arguments[1]:void 0)}});var anObject$l=anObject$q,regexpFlags$1=function(){var e=anObject$l(this),t="";return e.hasIndices&&(t+="d"),e.global&&(t+="g"),e.ignoreCase&&(t+="i"),e.multiline&&(t+="m"),e.dotAll&&(t+="s"),e.unicode&&(t+="u"),e.unicodeSets&&(t+="v"),e.sticky&&(t+="y"),t},fails$I=fails$U,global$z=global$K,$RegExp$2=global$z.RegExp,UNSUPPORTED_Y$3=fails$I((function(){var e=$RegExp$2("a","y");return e.lastIndex=2,null!=e.exec("abcd")})),MISSED_STICKY$2=UNSUPPORTED_Y$3||fails$I((function(){return!$RegExp$2("a","y").sticky})),BROKEN_CARET=UNSUPPORTED_Y$3||fails$I((function(){var e=$RegExp$2("^r","gy");return e.lastIndex=2,null!=e.exec("str")})),regexpStickyHelpers={BROKEN_CARET:BROKEN_CARET,MISSED_STICKY:MISSED_STICKY$2,UNSUPPORTED_Y:UNSUPPORTED_Y$3},fails$H=fails$U,global$y=global$K,$RegExp$1=global$y.RegExp,regexpUnsupportedDotAll=fails$H((function(){var e=$RegExp$1(".","s");return!(e.dotAll&&e.exec("\n")&&"s"===e.flags)})),fails$G=fails$U,global$x=global$K,$RegExp=global$x.RegExp,regexpUnsupportedNcg=fails$G((function(){var e=$RegExp("(?<a>b)","g");return"b"!==e.exec("b").groups.a||"bc"!=="b".replace(e,"$<a>c")})),call$t=functionCall,uncurryThis$D=functionUncurryThis,toString$k=toString$m,regexpFlags=regexpFlags$1,stickyHelpers$2=regexpStickyHelpers,shared$3=shared$7.exports,create$6=objectCreate,getInternalState$9=internalState.get,UNSUPPORTED_DOT_ALL$2=regexpUnsupportedDotAll,UNSUPPORTED_NCG$1=regexpUnsupportedNcg,nativeReplace=shared$3("native-string-replace",String.prototype.replace),nativeExec=RegExp.prototype.exec,patchedExec=nativeExec,charAt$9=uncurryThis$D("".charAt),indexOf=uncurryThis$D("".indexOf),replace$8=uncurryThis$D("".replace),stringSlice$9=uncurryThis$D("".slice),UPDATES_LAST_INDEX_WRONG=function(){var e=/a/,t=/b*/g;return call$t(nativeExec,e,"a"),call$t(nativeExec,t,"a"),0!==e.lastIndex||0!==t.lastIndex}(),UNSUPPORTED_Y$2=stickyHelpers$2.BROKEN_CARET,NPCG_INCLUDED=void 0!==/()??/.exec("")[1],PATCH=UPDATES_LAST_INDEX_WRONG||NPCG_INCLUDED||UNSUPPORTED_Y$2||UNSUPPORTED_DOT_ALL$2||UNSUPPORTED_NCG$1;PATCH&&(patchedExec=function(e){var t,r,n,i,o,a,s,c=this,u=getInternalState$9(c),l=toString$k(e),d=u.raw;if(d)return d.lastIndex=c.lastIndex,t=call$t(patchedExec,d,l),c.lastIndex=d.lastIndex,t;var p=u.groups,_=UNSUPPORTED_Y$2&&c.sticky,f=call$t(regexpFlags,c),h=c.source,m=0,y=l;if(_&&(f=replace$8(f,"y",""),-1===indexOf(f,"g")&&(f+="g"),y=stringSlice$9(l,c.lastIndex),c.lastIndex>0&&(!c.multiline||c.multiline&&"\n"!==charAt$9(l,c.lastIndex-1))&&(h="(?: "+h+")",y=" "+y,m++),r=new RegExp("^(?:"+h+")",f)),NPCG_INCLUDED&&(r=new RegExp("^"+h+"$(?!\\s)",f)),UPDATES_LAST_INDEX_WRONG&&(n=c.lastIndex),i=call$t(nativeExec,_?r:c,y),_?i?(i.input=stringSlice$9(i.input,m),i[0]=stringSlice$9(i[0],m),i.index=c.lastIndex,c.lastIndex+=i[0].length):c.lastIndex=0:UPDATES_LAST_INDEX_WRONG&&i&&(c.lastIndex=c.global?i.index+i[0].length:n),NPCG_INCLUDED&&i&&i.length>1&&call$t(nativeReplace,i[0],r,(function(){for(o=1;o<arguments.length-2;o++)void 0===arguments[o]&&(i[o]=void 0)})),i&&p)for(i.groups=a=create$6(null),o=0;o<p.length;o++)a[(s=p[o])[0]]=i[s[1]];return i});var regexpExec$3=patchedExec,$$Q=_export,exec$6=regexpExec$3;$$Q({target:"RegExp",proto:!0,forced:/./.exec!==regexpExec$3},{exec:regexpExec$3});var uncurryThis$C=functionUncurryThisClause,defineBuiltIn$g=defineBuiltIn$j,regexpExec$2=regexpExec$3,fails$F=fails$U,wellKnownSymbol$m=wellKnownSymbol$u,createNonEnumerableProperty$8=createNonEnumerableProperty$c,SPECIES$5=wellKnownSymbol$m("species"),RegExpPrototype$6=RegExp.prototype,fixRegexpWellKnownSymbolLogic=function(e,t,r,n){var i=wellKnownSymbol$m(e),o=!fails$F((function(){var t={};return t[i]=function(){return 7},7!=""[e](t)})),a=o&&!fails$F((function(){var t=!1,r=/a/;return"split"===e&&((r={}).constructor={},r.constructor[SPECIES$5]=function(){return r},r.flags="",r[i]=/./[i]),r.exec=function(){return t=!0,null},r[i](""),!t}));if(!o||!a||r){var s=uncurryThis$C(/./[i]),c=t(i,""[e],(function(e,t,r,n,i){var a=uncurryThis$C(e),c=t.exec;return c===regexpExec$2||c===RegExpPrototype$6.exec?o&&!i?{done:!0,value:s(t,r,n)}:{done:!0,value:a(r,t,n)}:{done:!1}}));defineBuiltIn$g(String.prototype,e,c[0]),defineBuiltIn$g(RegExpPrototype$6,i,c[1])}n&&createNonEnumerableProperty$8(RegExpPrototype$6[i],"sham",!0)},sameValue$1=Object.is||function(e,t){return e===t?0!==e||1/e==1/t:e!=e&&t!=t},call$s=functionCall,anObject$k=anObject$q,isCallable$g=isCallable$t,classof$b=classofRaw$2,regexpExec$1=regexpExec$3,$TypeError$e=TypeError,regexpExecAbstract=function(e,t){var r=e.exec;if(isCallable$g(r)){var n=call$s(r,e,t);return null!==n&&anObject$k(n),n}if("RegExp"===classof$b(e))return call$s(regexpExec$1,e,t);throw $TypeError$e("RegExp#exec called on incompatible receiver")},call$r=functionCall,fixRegExpWellKnownSymbolLogic$3=fixRegexpWellKnownSymbolLogic,anObject$j=anObject$q,isNullOrUndefined$8=isNullOrUndefined$b,requireObjectCoercible$9=requireObjectCoercible$d,sameValue=sameValue$1,toString$j=toString$m,getMethod$5=getMethod$7,regExpExec$2=regexpExecAbstract;fixRegExpWellKnownSymbolLogic$3("search",(function(e,t,r){return[function(t){var r=requireObjectCoercible$9(this),n=isNullOrUndefined$8(t)?void 0:getMethod$5(t,e);return n?call$r(n,t,r):new RegExp(t)[e](toString$j(r))},function(e){var n=anObject$j(this),i=toString$j(e),o=r(t,n,i);if(o.done)return o.value;var a=n.lastIndex;sameValue(a,0)||(n.lastIndex=0);var s=regExpExec$2(n,i);return sameValue(n.lastIndex,a)||(n.lastIndex=a),null===s?-1:s.index}]}));var uncurryThis$B=functionUncurryThis,toIntegerOrInfinity$a=toIntegerOrInfinity$d,toString$i=toString$m,requireObjectCoercible$8=requireObjectCoercible$d,charAt$8=uncurryThis$B("".charAt),charCodeAt$3=uncurryThis$B("".charCodeAt),stringSlice$8=uncurryThis$B("".slice),createMethod$5=function(e){return function(t,r){var n,i,o=toString$i(requireObjectCoercible$8(t)),a=toIntegerOrInfinity$a(r),s=o.length;return a<0||a>=s?e?"":void 0:(n=charCodeAt$3(o,a))<55296||n>56319||a+1===s||(i=charCodeAt$3(o,a+1))<56320||i>57343?e?charAt$8(o,a):n:e?stringSlice$8(o,a,a+2):i-56320+(n-55296<<10)+65536}},stringMultibyte={codeAt:createMethod$5(!1),charAt:createMethod$5(!0)},charAt$7=stringMultibyte.charAt,advanceStringIndex$3=function(e,t,r){return t+(r?charAt$7(e,t).length:1)},call$q=functionCall,fixRegExpWellKnownSymbolLogic$2=fixRegexpWellKnownSymbolLogic,anObject$i=anObject$q,isNullOrUndefined$7=isNullOrUndefined$b,toLength$8=toLength$a,toString$h=toString$m,requireObjectCoercible$7=requireObjectCoercible$d,getMethod$4=getMethod$7,advanceStringIndex$2=advanceStringIndex$3,regExpExec$1=regexpExecAbstract;fixRegExpWellKnownSymbolLogic$2("match",(function(e,t,r){return[function(t){var r=requireObjectCoercible$7(this),n=isNullOrUndefined$7(t)?void 0:getMethod$4(t,e);return n?call$q(n,t,r):new RegExp(t)[e](toString$h(r))},function(e){var n=anObject$i(this),i=toString$h(e),o=r(t,n,i);if(o.done)return o.value;if(!n.global)return regExpExec$1(n,i);var a=n.unicode;n.lastIndex=0;for(var s,c=[],u=0;null!==(s=regExpExec$1(n,i));){var l=toString$h(s[0]);c[u]=l,""===l&&(n.lastIndex=advanceStringIndex$2(i,toLength$8(n.lastIndex),a)),u++}return 0===u?null:c}]}));var whitespaces$4="\t\n\v\f\r \u2028\u2029\ufeff",uncurryThis$A=functionUncurryThis,requireObjectCoercible$6=requireObjectCoercible$d,toString$g=toString$m,whitespaces$3=whitespaces$4,replace$7=uncurryThis$A("".replace),whitespace="["+whitespaces$3+"]",ltrim=RegExp("^"+whitespace+whitespace+"*"),rtrim=RegExp(whitespace+whitespace+"*$"),createMethod$4=function(e){return function(t){var r=toString$g(requireObjectCoercible$6(t));return 1&e&&(r=replace$7(r,ltrim,"")),2&e&&(r=replace$7(r,rtrim,"")),r}},stringTrim={start:createMethod$4(1),end:createMethod$4(2),trim:createMethod$4(3)},global$w=global$K,fails$E=fails$U,uncurryThis$z=functionUncurryThis,toString$f=toString$m,trim$2=stringTrim.trim,whitespaces$2=whitespaces$4,$parseInt$1=global$w.parseInt,Symbol$4=global$w.Symbol,ITERATOR$a=Symbol$4&&Symbol$4.iterator,hex=/^[+-]?0x/i,exec$5=uncurryThis$z(hex.exec),FORCED$a=8!==$parseInt$1(whitespaces$2+"08")||22!==$parseInt$1(whitespaces$2+"0x16")||ITERATOR$a&&!fails$E((function(){$parseInt$1(Object(ITERATOR$a))})),numberParseInt=FORCED$a?function(e,t){var r=trim$2(toString$f(e));return $parseInt$1(r,t>>>0||(exec$5(hex,r)?16:10))}:$parseInt$1,$$P=_export,$parseInt=numberParseInt;$$P({global:!0,forced:parseInt!=numberParseInt},{parseInt:numberParseInt});var IteratorPrototype$2,PrototypeOfArrayIteratorPrototype,arrayIterator,iterators={},fails$D=fails$U,correctPrototypeGetter=!fails$D((function(){function e(){}return e.prototype.constructor=null,Object.getPrototypeOf(new e)!==e.prototype})),hasOwn$j=hasOwnProperty_1,isCallable$f=isCallable$t,toObject$f=toObject$i,sharedKey$1=sharedKey$4,CORRECT_PROTOTYPE_GETTER=correctPrototypeGetter,IE_PROTO=sharedKey$1("IE_PROTO"),$Object=Object,ObjectPrototype$3=$Object.prototype,objectGetPrototypeOf=CORRECT_PROTOTYPE_GETTER?$Object.getPrototypeOf:function(e){var t=toObject$f(e);if(hasOwn$j(t,IE_PROTO))return t[IE_PROTO];var r=t.constructor;return isCallable$f(r)&&t instanceof r?r.prototype:t instanceof $Object?ObjectPrototype$3:null},fails$C=fails$U,isCallable$e=isCallable$t,isObject$k=isObject$s,getPrototypeOf$5=objectGetPrototypeOf,defineBuiltIn$f=defineBuiltIn$j,wellKnownSymbol$l=wellKnownSymbol$u,ITERATOR$9=wellKnownSymbol$l("iterator"),BUGGY_SAFARI_ITERATORS$1=!1;[].keys&&("next"in(arrayIterator=[].keys())?(PrototypeOfArrayIteratorPrototype=getPrototypeOf$5(getPrototypeOf$5(arrayIterator)))!==Object.prototype&&(IteratorPrototype$2=PrototypeOfArrayIteratorPrototype):BUGGY_SAFARI_ITERATORS$1=!0);var NEW_ITERATOR_PROTOTYPE=!isObject$k(IteratorPrototype$2)||fails$C((function(){var e={};return IteratorPrototype$2[ITERATOR$9].call(e)!==e}));NEW_ITERATOR_PROTOTYPE&&(IteratorPrototype$2={}),isCallable$e(IteratorPrototype$2[ITERATOR$9])||defineBuiltIn$f(IteratorPrototype$2,ITERATOR$9,(function(){return this}));var iteratorsCore={IteratorPrototype:IteratorPrototype$2,BUGGY_SAFARI_ITERATORS:BUGGY_SAFARI_ITERATORS$1},defineProperty$f=objectDefineProperty.f,hasOwn$i=hasOwnProperty_1,wellKnownSymbol$k=wellKnownSymbol$u,TO_STRING_TAG$2=wellKnownSymbol$k("toStringTag"),setToStringTag$a=function(e,t,r){e&&!r&&(e=e.prototype),e&&!hasOwn$i(e,TO_STRING_TAG$2)&&defineProperty$f(e,TO_STRING_TAG$2,{configurable:!0,value:t})},IteratorPrototype$1=iteratorsCore.IteratorPrototype,create$5=objectCreate,createPropertyDescriptor$8=createPropertyDescriptor$b,setToStringTag$9=setToStringTag$a,Iterators$4=iterators,returnThis$1=function(){return this},iteratorCreateConstructor=function(e,t,r,n){var i=t+" Iterator";return e.prototype=create$5(IteratorPrototype$1,{next:createPropertyDescriptor$8(+!n,r)}),setToStringTag$9(e,i,!1),Iterators$4[i]=returnThis$1,e},isCallable$d=isCallable$t,$String=String,$TypeError$d=TypeError,aPossiblePrototype$1=function(e){if("object"==typeof e||isCallable$d(e))return e;throw $TypeError$d("Can't set "+$String(e)+" as a prototype")},uncurryThis$y=functionUncurryThis,anObject$h=anObject$q,aPossiblePrototype=aPossiblePrototype$1,objectSetPrototypeOf=Object.setPrototypeOf||("__proto__"in{}?function(){var e,t=!1,r={};try{(e=uncurryThis$y(Object.getOwnPropertyDescriptor(Object.prototype,"__proto__").set))(r,[]),t=r instanceof Array}catch(e){}return function(r,n){return anObject$h(r),aPossiblePrototype(n),t?e(r,n):r.__proto__=n,r}}():void 0),$$O=_export,call$p=functionCall,FunctionName$1=functionName,isCallable$c=isCallable$t,createIteratorConstructor$1=iteratorCreateConstructor,getPrototypeOf$4=objectGetPrototypeOf,setPrototypeOf$6=objectSetPrototypeOf,setToStringTag$8=setToStringTag$a,createNonEnumerableProperty$7=createNonEnumerableProperty$c,defineBuiltIn$e=defineBuiltIn$j,wellKnownSymbol$j=wellKnownSymbol$u,Iterators$3=iterators,IteratorsCore=iteratorsCore,PROPER_FUNCTION_NAME$3=FunctionName$1.PROPER,CONFIGURABLE_FUNCTION_NAME$1=FunctionName$1.CONFIGURABLE,IteratorPrototype=IteratorsCore.IteratorPrototype,BUGGY_SAFARI_ITERATORS=IteratorsCore.BUGGY_SAFARI_ITERATORS,ITERATOR$8=wellKnownSymbol$j("iterator"),KEYS="keys",VALUES="values",ENTRIES="entries",returnThis=function(){return this},iteratorDefine=function(e,t,r,n,i,o,a){createIteratorConstructor$1(r,t,n);var s,c,u,l=function(e){if(e===i&&h)return h;if(!BUGGY_SAFARI_ITERATORS&&e in _)return _[e];switch(e){case KEYS:case VALUES:case ENTRIES:return function(){return new r(this,e)}}return function(){return new r(this)}},d=t+" Iterator",p=!1,_=e.prototype,f=_[ITERATOR$8]||_["@@iterator"]||i&&_[i],h=!BUGGY_SAFARI_ITERATORS&&f||l(i),m="Array"==t&&_.entries||f;if(m&&(s=getPrototypeOf$4(m.call(new e)))!==Object.prototype&&s.next&&(getPrototypeOf$4(s)!==IteratorPrototype&&(setPrototypeOf$6?setPrototypeOf$6(s,IteratorPrototype):isCallable$c(s[ITERATOR$8])||defineBuiltIn$e(s,ITERATOR$8,returnThis)),setToStringTag$8(s,d,!0)),PROPER_FUNCTION_NAME$3&&i==VALUES&&f&&f.name!==VALUES&&(CONFIGURABLE_FUNCTION_NAME$1?createNonEnumerableProperty$7(_,"name",VALUES):(p=!0,h=function(){return call$p(f,this)})),i)if(c={values:l(VALUES),keys:o?h:l(KEYS),entries:l(ENTRIES)},a)for(u in c)(BUGGY_SAFARI_ITERATORS||p||!(u in _))&&defineBuiltIn$e(_,u,c[u]);else $$O({target:t,proto:!0,forced:BUGGY_SAFARI_ITERATORS||p},c);return _[ITERATOR$8]!==h&&defineBuiltIn$e(_,ITERATOR$8,h,{name:i}),Iterators$3[t]=h,c},createIterResultObject$3=function(e,t){return{value:e,done:t}},toIndexedObject$7=toIndexedObject$c,addToUnscopables$2=addToUnscopables$4,Iterators$2=iterators,InternalStateModule$b=internalState,defineProperty$e=objectDefineProperty.f,defineIterator$2=iteratorDefine,createIterResultObject$2=createIterResultObject$3,DESCRIPTORS$m=descriptors,ARRAY_ITERATOR="Array Iterator",setInternalState$a=InternalStateModule$b.set,getInternalState$8=InternalStateModule$b.getterFor(ARRAY_ITERATOR),es_array_iterator=defineIterator$2(Array,"Array",(function(e,t){setInternalState$a(this,{type:ARRAY_ITERATOR,target:toIndexedObject$7(e),index:0,kind:t})}),(function(){var e=getInternalState$8(this),t=e.target,r=e.kind,n=e.index++;return!t||n>=t.length?(e.target=void 0,createIterResultObject$2(void 0,!0)):createIterResultObject$2("keys"==r?n:"values"==r?t[n]:[n,t[n]],!1)}),"values"),values$1=Iterators$2.Arguments=Iterators$2.Array;if(addToUnscopables$2("keys"),addToUnscopables$2("values"),addToUnscopables$2("entries"),DESCRIPTORS$m&&"values"!==values$1.name)try{defineProperty$e(values$1,"name",{value:"values"})}catch(e){}var internalMetadata={exports:{}},objectGetOwnPropertyNamesExternal={},toPropertyKey$2=toPropertyKey$5,definePropertyModule$4=objectDefineProperty,createPropertyDescriptor$7=createPropertyDescriptor$b,createProperty$5=function(e,t,r){var n=toPropertyKey$2(t);n in e?definePropertyModule$4.f(e,n,createPropertyDescriptor$7(0,r)):e[n]=r},toAbsoluteIndex$4=toAbsoluteIndex$6,lengthOfArrayLike$j=lengthOfArrayLike$m,createProperty$4=createProperty$5,$Array$3=Array,max$3=Math.max,arraySliceSimple=function(e,t,r){for(var n=lengthOfArrayLike$j(e),i=toAbsoluteIndex$4(t,n),o=toAbsoluteIndex$4(void 0===r?n:r,n),a=$Array$3(max$3(o-i,0)),s=0;i<o;i++,s++)createProperty$4(a,s,e[i]);return a.length=s,a},classof$a=classofRaw$2,toIndexedObject$6=toIndexedObject$c,$getOwnPropertyNames$1=objectGetOwnPropertyNames.f,arraySlice$a=arraySliceSimple,windowNames="object"==typeof window&&window&&Object.getOwnPropertyNames?Object.getOwnPropertyNames(window):[],getWindowNames=function(e){try{return $getOwnPropertyNames$1(e)}catch(e){return arraySlice$a(windowNames)}};objectGetOwnPropertyNamesExternal.f=function(e){return windowNames&&"Window"==classof$a(e)?getWindowNames(e):$getOwnPropertyNames$1(toIndexedObject$6(e))};var fails$B=fails$U,arrayBufferNonExtensible=fails$B((function(){if("function"==typeof ArrayBuffer){var e=new ArrayBuffer(8);Object.isExtensible(e)&&Object.defineProperty(e,"a",{value:8})}})),fails$A=fails$U,isObject$j=isObject$s,classof$9=classofRaw$2,ARRAY_BUFFER_NON_EXTENSIBLE=arrayBufferNonExtensible,$isExtensible=Object.isExtensible,FAILS_ON_PRIMITIVES$2=fails$A((function(){$isExtensible(1)})),objectIsExtensible=FAILS_ON_PRIMITIVES$2||ARRAY_BUFFER_NON_EXTENSIBLE?function(e){return!!isObject$j(e)&&((!ARRAY_BUFFER_NON_EXTENSIBLE||"ArrayBuffer"!=classof$9(e))&&(!$isExtensible||$isExtensible(e)))}:$isExtensible,fails$z=fails$U,freezing=!fails$z((function(){return Object.isExtensible(Object.preventExtensions({}))})),$$N=_export,uncurryThis$x=functionUncurryThis,hiddenKeys$1=hiddenKeys$6,isObject$i=isObject$s,hasOwn$h=hasOwnProperty_1,defineProperty$d=objectDefineProperty.f,getOwnPropertyNamesModule$1=objectGetOwnPropertyNames,getOwnPropertyNamesExternalModule=objectGetOwnPropertyNamesExternal,isExtensible$1=objectIsExtensible,uid$2=uid$5,FREEZING=freezing,REQUIRED=!1,METADATA=uid$2("meta"),id$1=0,setMetadata=function(e){defineProperty$d(e,METADATA,{value:{objectID:"O"+id$1++,weakData:{}}})},fastKey$1=function(e,t){if(!isObject$i(e))return"symbol"==typeof e?e:("string"==typeof e?"S":"P")+e;if(!hasOwn$h(e,METADATA)){if(!isExtensible$1(e))return"F";if(!t)return"E";setMetadata(e)}return e[METADATA].objectID},getWeakData$1=function(e,t){if(!hasOwn$h(e,METADATA)){if(!isExtensible$1(e))return!0;if(!t)return!1;setMetadata(e)}return e[METADATA].weakData},onFreeze=function(e){return FREEZING&&REQUIRED&&isExtensible$1(e)&&!hasOwn$h(e,METADATA)&&setMetadata(e),e},enable=function(){meta.enable=function(){},REQUIRED=!0;var e=getOwnPropertyNamesModule$1.f,t=uncurryThis$x([].splice),r={};r[METADATA]=1,e(r).length&&(getOwnPropertyNamesModule$1.f=function(r){for(var n=e(r),i=0,o=n.length;i<o;i++)if(n[i]===METADATA){t(n,i,1);break}return n},$$N({target:"Object",stat:!0,forced:!0},{getOwnPropertyNames:getOwnPropertyNamesExternalModule.f}))},meta=internalMetadata.exports={enable:enable,fastKey:fastKey$1,getWeakData:getWeakData$1,onFreeze:onFreeze};hiddenKeys$1[METADATA]=!0;var wellKnownSymbol$i=wellKnownSymbol$u,Iterators$1=iterators,ITERATOR$7=wellKnownSymbol$i("iterator"),ArrayPrototype=Array.prototype,isArrayIteratorMethod$3=function(e){return void 0!==e&&(Iterators$1.Array===e||ArrayPrototype[ITERATOR$7]===e)},classof$8=classof$i,getMethod$3=getMethod$7,isNullOrUndefined$6=isNullOrUndefined$b,Iterators=iterators,wellKnownSymbol$h=wellKnownSymbol$u,ITERATOR$6=wellKnownSymbol$h("iterator"),getIteratorMethod$5=function(e){if(!isNullOrUndefined$6(e))return getMethod$3(e,ITERATOR$6)||getMethod$3(e,"@@iterator")||Iterators[classof$8(e)]},call$o=functionCall,aCallable$8=aCallable$b,anObject$g=anObject$q,tryToString$5=tryToString$7,getIteratorMethod$4=getIteratorMethod$5,$TypeError$c=TypeError,getIterator$4=function(e,t){var r=arguments.length<2?getIteratorMethod$4(e):t;if(aCallable$8(r))return anObject$g(call$o(r,e));throw $TypeError$c(tryToString$5(e)+" is not iterable")},call$n=functionCall,anObject$f=anObject$q,getMethod$2=getMethod$7,iteratorClose$2=function(e,t,r){var n,i;anObject$f(e);try{if(!(n=getMethod$2(e,"return"))){if("throw"===t)throw r;return r}n=call$n(n,e)}catch(e){i=!0,n=e}if("throw"===t)throw r;if(i)throw n;return anObject$f(n),r},bind$9=functionBindContext,call$m=functionCall,anObject$e=anObject$q,tryToString$4=tryToString$7,isArrayIteratorMethod$2=isArrayIteratorMethod$3,lengthOfArrayLike$i=lengthOfArrayLike$m,isPrototypeOf$8=objectIsPrototypeOf,getIterator$3=getIterator$4,getIteratorMethod$3=getIteratorMethod$5,iteratorClose$1=iteratorClose$2,$TypeError$b=TypeError,Result=function(e,t){this.stopped=e,this.result=t},ResultPrototype=Result.prototype,iterate$5=function(e,t,r){var n,i,o,a,s,c,u,l=r&&r.that,d=!(!r||!r.AS_ENTRIES),p=!(!r||!r.IS_RECORD),_=!(!r||!r.IS_ITERATOR),f=!(!r||!r.INTERRUPTED),h=bind$9(t,l),m=function(e){return n&&iteratorClose$1(n,"normal",e),new Result(!0,e)},y=function(e){return d?(anObject$e(e),f?h(e[0],e[1],m):h(e[0],e[1])):f?h(e,m):h(e)};if(p)n=e.iterator;else if(_)n=e;else{if(!(i=getIteratorMethod$3(e)))throw $TypeError$b(tryToString$4(e)+" is not iterable");if(isArrayIteratorMethod$2(i)){for(o=0,a=lengthOfArrayLike$i(e);a>o;o++)if((s=y(e[o]))&&isPrototypeOf$8(ResultPrototype,s))return s;return new Result(!1)}n=getIterator$3(e,i)}for(c=p?e.next:n.next;!(u=call$m(c,n)).done;){try{s=y(u.value)}catch(e){iteratorClose$1(n,"throw",e)}if("object"==typeof s&&s&&isPrototypeOf$8(ResultPrototype,s))return s}return new Result(!1)},isPrototypeOf$7=objectIsPrototypeOf,$TypeError$a=TypeError,anInstance$a=function(e,t){if(isPrototypeOf$7(t,e))return e;throw $TypeError$a("Incorrect invocation")},wellKnownSymbol$g=wellKnownSymbol$u,ITERATOR$5=wellKnownSymbol$g("iterator"),SAFE_CLOSING=!1;try{var called=0,iteratorWithReturn={next:function(){return{done:!!called++}},return:function(){SAFE_CLOSING=!0}};iteratorWithReturn[ITERATOR$5]=function(){return this},Array.from(iteratorWithReturn,(function(){throw 2}))}catch(e){}var checkCorrectnessOfIteration$4=function(e,t){if(!t&&!SAFE_CLOSING)return!1;var r=!1;try{var n={};n[ITERATOR$5]=function(){return{next:function(){return{done:r=!0}}}},e(n)}catch(e){}return r},isCallable$b=isCallable$t,isObject$h=isObject$s,setPrototypeOf$5=objectSetPrototypeOf,inheritIfRequired$6=function(e,t,r){var n,i;return setPrototypeOf$5&&isCallable$b(n=t.constructor)&&n!==r&&isObject$h(i=n.prototype)&&i!==r.prototype&&setPrototypeOf$5(e,i),e},$$M=_export,global$v=global$K,uncurryThis$w=functionUncurryThis,isForced$3=isForced_1,defineBuiltIn$d=defineBuiltIn$j,InternalMetadataModule$1=internalMetadata.exports,iterate$4=iterate$5,anInstance$9=anInstance$a,isCallable$a=isCallable$t,isNullOrUndefined$5=isNullOrUndefined$b,isObject$g=isObject$s,fails$y=fails$U,checkCorrectnessOfIteration$3=checkCorrectnessOfIteration$4,setToStringTag$7=setToStringTag$a,inheritIfRequired$5=inheritIfRequired$6,collection$2=function(e,t,r){var n=-1!==e.indexOf("Map"),i=-1!==e.indexOf("Weak"),o=n?"set":"add",a=global$v[e],s=a&&a.prototype,c=a,u={},l=function(e){var t=uncurryThis$w(s[e]);defineBuiltIn$d(s,e,"add"==e?function(e){return t(this,0===e?0:e),this}:"delete"==e?function(e){return!(i&&!isObject$g(e))&&t(this,0===e?0:e)}:"get"==e?function(e){return i&&!isObject$g(e)?void 0:t(this,0===e?0:e)}:"has"==e?function(e){return!(i&&!isObject$g(e))&&t(this,0===e?0:e)}:function(e,r){return t(this,0===e?0:e,r),this})};if(isForced$3(e,!isCallable$a(a)||!(i||s.forEach&&!fails$y((function(){(new a).entries().next()})))))c=r.getConstructor(t,e,n,o),InternalMetadataModule$1.enable();else if(isForced$3(e,!0)){var d=new c,p=d[o](i?{}:-0,1)!=d,_=fails$y((function(){d.has(1)})),f=checkCorrectnessOfIteration$3((function(e){new a(e)})),h=!i&&fails$y((function(){for(var e=new a,t=5;t--;)e[o](t,t);return!e.has(-0)}));f||((c=t((function(e,t){anInstance$9(e,s);var r=inheritIfRequired$5(new a,e,c);return isNullOrUndefined$5(t)||iterate$4(t,r[o],{that:r,AS_ENTRIES:n}),r}))).prototype=s,s.constructor=c),(_||h)&&(l("delete"),l("has"),n&&l("get")),(h||p)&&l(o),i&&s.clear&&delete s.clear}return u[e]=c,$$M({global:!0,constructor:!0,forced:c!=a},u),setToStringTag$7(c,e),i||r.setStrong(c,e,n),c},defineBuiltIn$c=defineBuiltIn$j,defineBuiltIns$5=function(e,t,r){for(var n in t)defineBuiltIn$c(e,n,t[n],r);return e},getBuiltIn$a=getBuiltIn$g,definePropertyModule$3=objectDefineProperty,wellKnownSymbol$f=wellKnownSymbol$u,DESCRIPTORS$l=descriptors,SPECIES$4=wellKnownSymbol$f("species"),setSpecies$4=function(e){var t=getBuiltIn$a(e),r=definePropertyModule$3.f;DESCRIPTORS$l&&t&&!t[SPECIES$4]&&r(t,SPECIES$4,{configurable:!0,get:function(){return this}})},defineProperty$c=objectDefineProperty.f,create$4=objectCreate,defineBuiltIns$4=defineBuiltIns$5,bind$8=functionBindContext,anInstance$8=anInstance$a,isNullOrUndefined$4=isNullOrUndefined$b,iterate$3=iterate$5,defineIterator$1=iteratorDefine,createIterResultObject$1=createIterResultObject$3,setSpecies$3=setSpecies$4,DESCRIPTORS$k=descriptors,fastKey=internalMetadata.exports.fastKey,InternalStateModule$a=internalState,setInternalState$9=InternalStateModule$a.set,internalStateGetterFor$1=InternalStateModule$a.getterFor,collectionStrong$1={getConstructor:function(e,t,r,n){var i=e((function(e,i){anInstance$8(e,o),setInternalState$9(e,{type:t,index:create$4(null),first:void 0,last:void 0,size:0}),DESCRIPTORS$k||(e.size=0),isNullOrUndefined$4(i)||iterate$3(i,e[n],{that:e,AS_ENTRIES:r})})),o=i.prototype,a=internalStateGetterFor$1(t),s=function(e,t,r){var n,i,o=a(e),s=c(e,t);return s?s.value=r:(o.last=s={index:i=fastKey(t,!0),key:t,value:r,previous:n=o.last,next:void 0,removed:!1},o.first||(o.first=s),n&&(n.next=s),DESCRIPTORS$k?o.size++:e.size++,"F"!==i&&(o.index[i]=s)),e},c=function(e,t){var r,n=a(e),i=fastKey(t);if("F"!==i)return n.index[i];for(r=n.first;r;r=r.next)if(r.key==t)return r};return defineBuiltIns$4(o,{clear:function(){for(var e=a(this),t=e.index,r=e.first;r;)r.removed=!0,r.previous&&(r.previous=r.previous.next=void 0),delete t[r.index],r=r.next;e.first=e.last=void 0,DESCRIPTORS$k?e.size=0:this.size=0},delete:function(e){var t=this,r=a(t),n=c(t,e);if(n){var i=n.next,o=n.previous;delete r.index[n.index],n.removed=!0,o&&(o.next=i),i&&(i.previous=o),r.first==n&&(r.first=i),r.last==n&&(r.last=o),DESCRIPTORS$k?r.size--:t.size--}return!!n},forEach:function(e){for(var t,r=a(this),n=bind$8(e,arguments.length>1?arguments[1]:void 0);t=t?t.next:r.first;)for(n(t.value,t.key,this);t&&t.removed;)t=t.previous},has:function(e){return!!c(this,e)}}),defineBuiltIns$4(o,r?{get:function(e){var t=c(this,e);return t&&t.value},set:function(e,t){return s(this,0===e?0:e,t)}}:{add:function(e){return s(this,e=0===e?0:e,e)}}),DESCRIPTORS$k&&defineProperty$c(o,"size",{get:function(){return a(this).size}}),i},setStrong:function(e,t,r){var n=t+" Iterator",i=internalStateGetterFor$1(t),o=internalStateGetterFor$1(n);defineIterator$1(e,t,(function(e,t){setInternalState$9(this,{type:n,target:e,state:i(e),kind:t,last:void 0})}),(function(){for(var e=o(this),t=e.kind,r=e.last;r&&r.removed;)r=r.previous;return e.target&&(e.last=r=r?r.next:e.state.first)?createIterResultObject$1("keys"==t?r.key:"values"==t?r.value:[r.key,r.value],!1):(e.target=void 0,createIterResultObject$1(void 0,!0))}),r?"entries":"values",!r,!0),setSpecies$3(t)}},collection$1=collection$2,collectionStrong=collectionStrong$1;collection$1("Map",(function(e){return function(){return e(this,arguments.length?arguments[0]:void 0)}}),collectionStrong);var charAt$6=stringMultibyte.charAt,toString$e=toString$m,InternalStateModule$9=internalState,defineIterator=iteratorDefine,createIterResultObject=createIterResultObject$3,STRING_ITERATOR="String Iterator",setInternalState$8=InternalStateModule$9.set,getInternalState$7=InternalStateModule$9.getterFor(STRING_ITERATOR);defineIterator(String,"String",(function(e){setInternalState$8(this,{type:STRING_ITERATOR,string:toString$e(e),index:0})}),(function(){var e,t=getInternalState$7(this),r=t.string,n=t.index;return n>=r.length?createIterResultObject(void 0,!0):(e=charAt$6(r,n),t.index+=e.length,createIterResultObject(e,!1))}));var global$u=global$K,DOMIterables=domIterables,DOMTokenListPrototype=domTokenListPrototype,ArrayIteratorMethods=es_array_iterator,createNonEnumerableProperty$6=createNonEnumerableProperty$c,wellKnownSymbol$e=wellKnownSymbol$u,ITERATOR$4=wellKnownSymbol$e("iterator"),TO_STRING_TAG$1=wellKnownSymbol$e("toStringTag"),ArrayValues=ArrayIteratorMethods.values,handlePrototype=function(e,t){if(e){if(e[ITERATOR$4]!==ArrayValues)try{createNonEnumerableProperty$6(e,ITERATOR$4,ArrayValues)}catch(t){e[ITERATOR$4]=ArrayValues}if(e[TO_STRING_TAG$1]||createNonEnumerableProperty$6(e,TO_STRING_TAG$1,t),DOMIterables[t])for(var r in ArrayIteratorMethods)if(e[r]!==ArrayIteratorMethods[r])try{createNonEnumerableProperty$6(e,r,ArrayIteratorMethods[r])}catch(t){e[r]=ArrayIteratorMethods[r]}}};for(var COLLECTION_NAME in DOMIterables)handlePrototype(global$u[COLLECTION_NAME]&&global$u[COLLECTION_NAME].prototype,COLLECTION_NAME);handlePrototype(DOMTokenListPrototype,"DOMTokenList");var $$L=_export,toObject$e=toObject$i,nativeKeys$2=objectKeys$4,fails$x=fails$U,FAILS_ON_PRIMITIVES$1=fails$x((function(){nativeKeys$2(1)}));$$L({target:"Object",stat:!0,forced:FAILS_ON_PRIMITIVES$1},{keys:function(e){return nativeKeys$2(toObject$e(e))}});var $$K=_export,DESCRIPTORS$j=descriptors,defineProperty$b=objectDefineProperty.f;$$K({target:"Object",stat:!0,forced:Object.defineProperty!==defineProperty$b,sham:!DESCRIPTORS$j},{defineProperty:defineProperty$b});var NATIVE_BIND=functionBindNative,FunctionPrototype=Function.prototype,apply$9=FunctionPrototype.apply,call$l=FunctionPrototype.call,functionApply="object"==typeof Reflect&&Reflect.apply||(NATIVE_BIND?call$l.bind(apply$9):function(){return call$l.apply(apply$9,arguments)}),defineProperty$a=objectDefineProperty.f,proxyAccessor$2=function(e,t,r){r in e||defineProperty$a(e,r,{configurable:!0,get:function(){return t[r]},set:function(e){t[r]=e}})},toString$d=toString$m,normalizeStringArgument$4=function(e,t){return void 0===e?arguments.length<2?"":t:toString$d(e)},isObject$f=isObject$s,createNonEnumerableProperty$5=createNonEnumerableProperty$c,installErrorCause$1=function(e,t){isObject$f(t)&&"cause"in t&&createNonEnumerableProperty$5(e,"cause",t.cause)},uncurryThis$v=functionUncurryThis,$Error=Error,replace$6=uncurryThis$v("".replace),TEST=String($Error("zxcasd").stack),V8_OR_CHAKRA_STACK_ENTRY=/\n\s*at [^:]*:[^\n]*/,IS_V8_OR_CHAKRA_STACK=V8_OR_CHAKRA_STACK_ENTRY.test(TEST),errorStackClear=function(e,t){if(IS_V8_OR_CHAKRA_STACK&&"string"==typeof e&&!$Error.prepareStackTrace)for(;t--;)e=replace$6(e,V8_OR_CHAKRA_STACK_ENTRY,"");return e},fails$w=fails$U,createPropertyDescriptor$6=createPropertyDescriptor$b,errorStackInstallable=!fails$w((function(){var e=Error("a");return!("stack"in e)||(Object.defineProperty(e,"stack",createPropertyDescriptor$6(1,7)),7!==e.stack)})),getBuiltIn$9=getBuiltIn$g,hasOwn$g=hasOwnProperty_1,createNonEnumerableProperty$4=createNonEnumerableProperty$c,isPrototypeOf$6=objectIsPrototypeOf,setPrototypeOf$4=objectSetPrototypeOf,copyConstructorProperties=copyConstructorProperties$2,proxyAccessor$1=proxyAccessor$2,inheritIfRequired$4=inheritIfRequired$6,normalizeStringArgument$3=normalizeStringArgument$4,installErrorCause=installErrorCause$1,clearErrorStack$2=errorStackClear,ERROR_STACK_INSTALLABLE=errorStackInstallable,DESCRIPTORS$i=descriptors,wrapErrorConstructorWithCause$1=function(e,t,r,n){var i="stackTraceLimit",o=n?2:1,a=e.split("."),s=a[a.length-1],c=getBuiltIn$9.apply(null,a);if(c){var u=c.prototype;if(hasOwn$g(u,"cause")&&delete u.cause,!r)return c;var l=getBuiltIn$9("Error"),d=t((function(e,t){var r=normalizeStringArgument$3(n?t:e,void 0),i=n?new c(e):new c;return void 0!==r&&createNonEnumerableProperty$4(i,"message",r),ERROR_STACK_INSTALLABLE&&createNonEnumerableProperty$4(i,"stack",clearErrorStack$2(i.stack,2)),this&&isPrototypeOf$6(u,this)&&inheritIfRequired$4(i,this,d),arguments.length>o&&installErrorCause(i,arguments[o]),i}));d.prototype=u,"Error"!==s?setPrototypeOf$4?setPrototypeOf$4(d,l):copyConstructorProperties(d,l,{name:!0}):DESCRIPTORS$i&&i in c&&(proxyAccessor$1(d,c,i),proxyAccessor$1(d,c,"prepareStackTrace")),copyConstructorProperties(d,c);try{u.name!==s&&createNonEnumerableProperty$4(u,"name",s),u.constructor=d}catch(e){}return d}},$$J=_export,global$t=global$K,apply$8=functionApply,wrapErrorConstructorWithCause=wrapErrorConstructorWithCause$1,WEB_ASSEMBLY="WebAssembly",WebAssembly=global$t[WEB_ASSEMBLY],FORCED$9=7!==Error("e",{cause:7}).cause,exportGlobalErrorCauseWrapper=function(e,t){var r={};r[e]=wrapErrorConstructorWithCause(e,t,FORCED$9),$$J({global:!0,constructor:!0,arity:1,forced:FORCED$9},r)},exportWebAssemblyErrorCauseWrapper=function(e,t){if(WebAssembly&&WebAssembly[e]){var r={};r[e]=wrapErrorConstructorWithCause(WEB_ASSEMBLY+"."+e,t,FORCED$9),$$J({target:WEB_ASSEMBLY,stat:!0,constructor:!0,arity:1,forced:FORCED$9},r)}};exportGlobalErrorCauseWrapper("Error",(function(e){return function(t){return apply$8(e,this,arguments)}})),exportGlobalErrorCauseWrapper("EvalError",(function(e){return function(t){return apply$8(e,this,arguments)}})),exportGlobalErrorCauseWrapper("RangeError",(function(e){return function(t){return apply$8(e,this,arguments)}})),exportGlobalErrorCauseWrapper("ReferenceError",(function(e){return function(t){return apply$8(e,this,arguments)}})),exportGlobalErrorCauseWrapper("SyntaxError",(function(e){return function(t){return apply$8(e,this,arguments)}})),exportGlobalErrorCauseWrapper("TypeError",(function(e){return function(t){return apply$8(e,this,arguments)}})),exportGlobalErrorCauseWrapper("URIError",(function(e){return function(t){return apply$8(e,this,arguments)}})),exportWebAssemblyErrorCauseWrapper("CompileError",(function(e){return function(t){return apply$8(e,this,arguments)}})),exportWebAssemblyErrorCauseWrapper("LinkError",(function(e){return function(t){return apply$8(e,this,arguments)}})),exportWebAssemblyErrorCauseWrapper("RuntimeError",(function(e){return function(t){return apply$8(e,this,arguments)}}));var aCallable$7=aCallable$b,toObject$d=toObject$i,IndexedObject$2=indexedObject,lengthOfArrayLike$h=lengthOfArrayLike$m,$TypeError$9=TypeError,createMethod$3=function(e){return function(t,r,n,i){aCallable$7(r);var o=toObject$d(t),a=IndexedObject$2(o),s=lengthOfArrayLike$h(o),c=e?s-1:0,u=e?-1:1;if(n<2)for(;;){if(c in a){i=a[c],c+=u;break}if(c+=u,e?c<0:s<=c)throw $TypeError$9("Reduce of empty array with no initial value")}for(;e?c>=0:s>c;c+=u)c in a&&(i=r(i,a[c],c,o));return i}},arrayReduce={left:createMethod$3(!1),right:createMethod$3(!0)},classof$7=classofRaw$2,global$s=global$K,engineIsNode="process"==classof$7(global$s.process),$$I=_export,$reduce$1=arrayReduce.left,arrayMethodIsStrict$3=arrayMethodIsStrict$5,CHROME_VERSION=engineV8Version,IS_NODE$5=engineIsNode,STRICT_METHOD$3=arrayMethodIsStrict$3("reduce"),CHROME_BUG=!IS_NODE$5&&CHROME_VERSION>79&&CHROME_VERSION<83;$$I({target:"Array",proto:!0,forced:!STRICT_METHOD$3||CHROME_BUG},{reduce:function(e){var t=arguments.length;return $reduce$1(this,e,t,t>1?arguments[1]:void 0)}});var DESCRIPTORS$h=descriptors,uncurryThis$u=functionUncurryThis,call$k=functionCall,fails$v=fails$U,objectKeys$2=objectKeys$4,getOwnPropertySymbolsModule$2=objectGetOwnPropertySymbols,propertyIsEnumerableModule$1=objectPropertyIsEnumerable,toObject$c=toObject$i,IndexedObject$1=indexedObject,$assign=Object.assign,defineProperty$9=Object.defineProperty,concat$1=uncurryThis$u([].concat),objectAssign=!$assign||fails$v((function(){if(DESCRIPTORS$h&&1!==$assign({b:1},$assign(defineProperty$9({},"a",{enumerable:!0,get:function(){defineProperty$9(this,"b",{value:3,enumerable:!1})}}),{b:2})).b)return!0;var e={},t={},r=Symbol(),n="abcdefghijklmnopqrst";return e[r]=7,n.split("").forEach((function(e){t[e]=e})),7!=$assign({},e)[r]||objectKeys$2($assign({},t)).join("")!=n}))?function(e,t){for(var r=toObject$c(e),n=arguments.length,i=1,o=getOwnPropertySymbolsModule$2.f,a=propertyIsEnumerableModule$1.f;n>i;)for(var s,c=IndexedObject$1(arguments[i++]),u=o?concat$1(objectKeys$2(c),o(c)):objectKeys$2(c),l=u.length,d=0;l>d;)s=u[d++],DESCRIPTORS$h&&!call$k(a,c,s)||(r[s]=c[s]);return r}:$assign,$$H=_export,assign$2=objectAssign;$$H({target:"Object",stat:!0,arity:2,forced:Object.assign!==assign$2},{assign:assign$2});var $$G=_export,uncurryThis$t=functionUncurryThisClause,getOwnPropertyDescriptor$5=objectGetOwnPropertyDescriptor.f,toLength$7=toLength$a,toString$c=toString$m,notARegExp$1=notARegexp,requireObjectCoercible$5=requireObjectCoercible$d,correctIsRegExpLogic$1=correctIsRegexpLogic,nativeEndsWith=uncurryThis$t("".endsWith),slice$2=uncurryThis$t("".slice),min$6=Math.min,CORRECT_IS_REGEXP_LOGIC$1=correctIsRegExpLogic$1("endsWith"),MDN_POLYFILL_BUG$1=!CORRECT_IS_REGEXP_LOGIC$1&&!!function(){var e=getOwnPropertyDescriptor$5(String.prototype,"endsWith");return e&&!e.writable}();$$G({target:"String",proto:!0,forced:!MDN_POLYFILL_BUG$1&&!CORRECT_IS_REGEXP_LOGIC$1},{endsWith:function(e){var t=toString$c(requireObjectCoercible$5(this));notARegExp$1(e);var r=arguments.length>1?arguments[1]:void 0,n=t.length,i=void 0===r?n:min$6(toLength$7(r),n),o=toString$c(e);return nativeEndsWith?nativeEndsWith(t,o,i):slice$2(t,i-o.length,i)===o}});var DESCRIPTORS$g=descriptors,isArray$5=isArray$7,$TypeError$8=TypeError,getOwnPropertyDescriptor$4=Object.getOwnPropertyDescriptor,SILENT_ON_NON_WRITABLE_LENGTH_SET=DESCRIPTORS$g&&!function(){if(void 0!==this)return!0;try{Object.defineProperty([],"length",{writable:!1}).length=1}catch(e){return e instanceof TypeError}}(),arraySetLength=SILENT_ON_NON_WRITABLE_LENGTH_SET?function(e,t){if(isArray$5(e)&&!getOwnPropertyDescriptor$4(e,"length").writable)throw $TypeError$8("Cannot set read only .length");return e.length=t}:function(e,t){return e.length=t},$TypeError$7=TypeError,MAX_SAFE_INTEGER$2=9007199254740991,doesNotExceedSafeInteger$4=function(e){if(e>MAX_SAFE_INTEGER$2)throw $TypeError$7("Maximum allowed index exceeded");return e},$$F=_export,toObject$b=toObject$i,lengthOfArrayLike$g=lengthOfArrayLike$m,setArrayLength$2=arraySetLength,doesNotExceedSafeInteger$3=doesNotExceedSafeInteger$4,fails$u=fails$U,INCORRECT_TO_LENGTH=fails$u((function(){return 4294967297!==[].push.call({length:4294967296},1)})),SILENT_ON_NON_WRITABLE_LENGTH$1=!function(){try{Object.defineProperty([],"length",{writable:!1}).push()}catch(e){return e instanceof TypeError}}();$$F({target:"Array",proto:!0,arity:1,forced:INCORRECT_TO_LENGTH||SILENT_ON_NON_WRITABLE_LENGTH$1},{push:function(e){var t=toObject$b(this),r=lengthOfArrayLike$g(t),n=arguments.length;doesNotExceedSafeInteger$3(r+n);for(var i=0;i<n;i++)t[r]=arguments[i],r++;return setArrayLength$2(t,r),r}});var logDisabled_=!0,deprecationWarnings_=!0;function extractVersion(e,t,r){var n=e.match(t);return n&&n.length>=r&&parseInt(n[r],10)}function wrapPeerConnectionEvent(e,t,r){if(e.RTCPeerConnection){var n=e.RTCPeerConnection.prototype,i=n.addEventListener;n.addEventListener=function(e,n){if(e!==t)return i.apply(this,arguments);var o=function(e){var t=r(e);t&&(n.handleEvent?n.handleEvent(t):n(t))};return this._eventMap=this._eventMap||{},this._eventMap[t]||(this._eventMap[t]=new Map),this._eventMap[t].set(n,o),i.apply(this,[e,o])};var o=n.removeEventListener;n.removeEventListener=function(e,r){if(e!==t||!this._eventMap||!this._eventMap[t])return o.apply(this,arguments);if(!this._eventMap[t].has(r))return o.apply(this,arguments);var n=this._eventMap[t].get(r);return this._eventMap[t].delete(r),0===this._eventMap[t].size&&delete this._eventMap[t],0===Object.keys(this._eventMap).length&&delete this._eventMap,o.apply(this,[e,n])},Object.defineProperty(n,"on"+t,{get:function(){return this["_on"+t]},set:function(e){this["_on"+t]&&(this.removeEventListener(t,this["_on"+t]),delete this["_on"+t]),e&&this.addEventListener(t,this["_on"+t]=e)},enumerable:!0,configurable:!0})}}function disableLog(e){return"boolean"!=typeof e?new Error("Argument type: "+_typeof(e)+". Please use a boolean."):(logDisabled_=e,e?"adapter.js logging disabled":"adapter.js logging enabled")}function disableWarnings(e){return"boolean"!=typeof e?new Error("Argument type: "+_typeof(e)+". Please use a boolean."):(deprecationWarnings_=!e,"adapter.js deprecation warnings "+(e?"disabled":"enabled"))}function log$2(){if("object"===("undefined"==typeof window?"undefined":_typeof(window))){if(logDisabled_)return;"undefined"!=typeof console&&"function"==typeof console.log&&console.log.apply(console,arguments)}}function deprecated(e,t){deprecationWarnings_&&console.warn(e+" is deprecated, please use "+t+" instead.")}function detectBrowser(e){var t={browser:null,version:null};if(void 0===e||!e.navigator)return t.browser="Not a browser.",t;var r=e.navigator;if(r.mozGetUserMedia)t.browser="firefox",t.version=extractVersion(r.userAgent,/Firefox\/(\d+)\./,1);else if(r.webkitGetUserMedia||!1===e.isSecureContext&&e.webkitRTCPeerConnection)t.browser="chrome",t.version=extractVersion(r.userAgent,/Chrom(e|ium)\/(\d+)\./,2);else{if(!e.RTCPeerConnection||!r.userAgent.match(/AppleWebKit\/(\d+)\./))return t.browser="Not a supported browser.",t;t.browser="safari",t.version=extractVersion(r.userAgent,/AppleWebKit\/(\d+)\./,1),t.supportsUnifiedPlan=e.RTCRtpTransceiver&&"currentDirection"in e.RTCRtpTransceiver.prototype}return t}function isObject$e(e){return"[object Object]"===Object.prototype.toString.call(e)}function compactObject(e){return isObject$e(e)?Object.keys(e).reduce((function(t,r){var n=isObject$e(e[r]),i=n?compactObject(e[r]):e[r],o=n&&!Object.keys(i).length;return void 0===i||o?t:Object.assign(t,_defineProperty({},r,i))}),{}):e}function walkStats(e,t,r){t&&!r.has(t.id)&&(r.set(t.id,t),Object.keys(t).forEach((function(n){n.endsWith("Id")?walkStats(e,e.get(t[n]),r):n.endsWith("Ids")&&t[n].forEach((function(t){walkStats(e,e.get(t),r)}))})))}function filterStats(e,t,r){var n=r?"outbound-rtp":"inbound-rtp",i=new Map;if(null===t)return i;var o=[];return e.forEach((function(e){"track"===e.type&&e.trackIdentifier===t.id&&o.push(e)})),o.forEach((function(t){e.forEach((function(r){r.type===n&&r.trackId===t.id&&walkStats(e,r,i)}))})),i}var $$E=_export,$find$1=arrayIteration.find,addToUnscopables$1=addToUnscopables$4,FIND="find",SKIPS_HOLES$1=!0;FIND in[]&&Array(1)[FIND]((function(){SKIPS_HOLES$1=!1})),$$E({target:"Array",proto:!0,forced:SKIPS_HOLES$1},{find:function(e){return $find$1(this,e,arguments.length>1?arguments[1]:void 0)}}),addToUnscopables$1(FIND);var fails$t=fails$U,wellKnownSymbol$d=wellKnownSymbol$u,V8_VERSION$2=engineV8Version,SPECIES$3=wellKnownSymbol$d("species"),arrayMethodHasSpeciesSupport$5=function(e){return V8_VERSION$2>=51||!fails$t((function(){var t=[];return(t.constructor={})[SPECIES$3]=function(){return{foo:1}},1!==t[e](Boolean).foo}))},uncurryThis$s=functionUncurryThis,arraySlice$9=uncurryThis$s([].slice),$$D=_export,isArray$4=isArray$7,isConstructor$2=isConstructor$4,isObject$d=isObject$s,toAbsoluteIndex$3=toAbsoluteIndex$6,lengthOfArrayLike$f=lengthOfArrayLike$m,toIndexedObject$5=toIndexedObject$c,createProperty$3=createProperty$5,wellKnownSymbol$c=wellKnownSymbol$u,arrayMethodHasSpeciesSupport$4=arrayMethodHasSpeciesSupport$5,nativeSlice=arraySlice$9,HAS_SPECIES_SUPPORT$3=arrayMethodHasSpeciesSupport$4("slice"),SPECIES$2=wellKnownSymbol$c("species"),$Array$2=Array,max$2=Math.max;$$D({target:"Array",proto:!0,forced:!HAS_SPECIES_SUPPORT$3},{slice:function(e,t){var r,n,i,o=toIndexedObject$5(this),a=lengthOfArrayLike$f(o),s=toAbsoluteIndex$3(e,a),c=toAbsoluteIndex$3(void 0===t?a:t,a);if(isArray$4(o)&&(r=o.constructor,(isConstructor$2(r)&&(r===$Array$2||isArray$4(r.prototype))||isObject$d(r)&&null===(r=r[SPECIES$2]))&&(r=void 0),r===$Array$2||void 0===r))return nativeSlice(o,s,c);for(n=new(void 0===r?$Array$2:r)(max$2(c-s,0)),i=0;s<c;s++,i++)s in o&&createProperty$3(n,i,o[s]);return n.length=i,n}});var $$C=_export,uncurryThis$r=functionUncurryThisClause,$indexOf$1=arrayIncludes.indexOf,arrayMethodIsStrict$2=arrayMethodIsStrict$5,nativeIndexOf=uncurryThis$r([].indexOf),NEGATIVE_ZERO$1=!!nativeIndexOf&&1/nativeIndexOf([1],1,-0)<0,STRICT_METHOD$2=arrayMethodIsStrict$2("indexOf");$$C({target:"Array",proto:!0,forced:NEGATIVE_ZERO$1||!STRICT_METHOD$2},{indexOf:function(e){var t=arguments.length>1?arguments[1]:void 0;return NEGATIVE_ZERO$1?nativeIndexOf(this,e,t)||0:$indexOf$1(this,e,t)}});var tryToString$3=tryToString$7,$TypeError$6=TypeError,deletePropertyOrThrow$4=function(e,t){if(!delete e[t])throw $TypeError$6("Cannot delete property "+tryToString$3(t)+" of "+tryToString$3(e))},$$B=_export,toObject$a=toObject$i,toAbsoluteIndex$2=toAbsoluteIndex$6,toIntegerOrInfinity$9=toIntegerOrInfinity$d,lengthOfArrayLike$e=lengthOfArrayLike$m,setArrayLength$1=arraySetLength,doesNotExceedSafeInteger$2=doesNotExceedSafeInteger$4,arraySpeciesCreate$1=arraySpeciesCreate$3,createProperty$2=createProperty$5,deletePropertyOrThrow$3=deletePropertyOrThrow$4,arrayMethodHasSpeciesSupport$3=arrayMethodHasSpeciesSupport$5,HAS_SPECIES_SUPPORT$2=arrayMethodHasSpeciesSupport$3("splice"),max$1=Math.max,min$5=Math.min;$$B({target:"Array",proto:!0,forced:!HAS_SPECIES_SUPPORT$2},{splice:function(e,t){var r,n,i,o,a,s,c=toObject$a(this),u=lengthOfArrayLike$e(c),l=toAbsoluteIndex$2(e,u),d=arguments.length;for(0===d?r=n=0:1===d?(r=0,n=u-l):(r=d-2,n=min$5(max$1(toIntegerOrInfinity$9(t),0),u-l)),doesNotExceedSafeInteger$2(u+r-n),i=arraySpeciesCreate$1(c,n),o=0;o<n;o++)(a=l+o)in c&&createProperty$2(i,o,c[a]);if(i.length=n,r<n){for(o=l;o<u-n;o++)s=o+r,(a=o+n)in c?c[s]=c[a]:deletePropertyOrThrow$3(c,s);for(o=u;o>u-n+r;o--)deletePropertyOrThrow$3(c,o-1)}else if(r>n)for(o=u-n;o>l;o--)s=o+r-1,(a=o+n-1)in c?c[s]=c[a]:deletePropertyOrThrow$3(c,s);for(o=0;o<r;o++)c[o+l]=arguments[o+2];return setArrayLength$1(c,u-n+r),i}});var $$A=_export,$map$1=arrayIteration.map,arrayMethodHasSpeciesSupport$2=arrayMethodHasSpeciesSupport$5,HAS_SPECIES_SUPPORT$1=arrayMethodHasSpeciesSupport$2("map");$$A({target:"Array",proto:!0,forced:!HAS_SPECIES_SUPPORT$1},{map:function(e){return $map$1(this,e,arguments.length>1?arguments[1]:void 0)}});var $location,defer,channel,port,isConstructor$1=isConstructor$4,tryToString$2=tryToString$7,$TypeError$5=TypeError,aConstructor$2=function(e){if(isConstructor$1(e))return e;throw $TypeError$5(tryToString$2(e)+" is not a constructor")},anObject$d=anObject$q,aConstructor$1=aConstructor$2,isNullOrUndefined$3=isNullOrUndefined$b,wellKnownSymbol$b=wellKnownSymbol$u,SPECIES$1=wellKnownSymbol$b("species"),speciesConstructor$4=function(e,t){var r,n=anObject$d(e).constructor;return void 0===n||isNullOrUndefined$3(r=anObject$d(n)[SPECIES$1])?t:aConstructor$1(r)},$TypeError$4=TypeError,validateArgumentsLength$3=function(e,t){if(e<t)throw $TypeError$4("Not enough arguments");return e},userAgent$5=engineUserAgent,engineIsIos=/(?:ipad|iphone|ipod).*applewebkit/i.test(userAgent$5),global$r=global$K,apply$7=functionApply,bind$7=functionBindContext,isCallable$9=isCallable$t,hasOwn$f=hasOwnProperty_1,fails$s=fails$U,html=html$2,arraySlice$8=arraySlice$9,createElement$1=documentCreateElement$2,validateArgumentsLength$2=validateArgumentsLength$3,IS_IOS$1=engineIsIos,IS_NODE$4=engineIsNode,set$2=global$r.setImmediate,clear=global$r.clearImmediate,process$2=global$r.process,Dispatch=global$r.Dispatch,Function$1=global$r.Function,MessageChannel=global$r.MessageChannel,String$1=global$r.String,counter=0,queue$1={},ONREADYSTATECHANGE="onreadystatechange";try{$location=global$r.location}catch(e){}var run=function(e){if(hasOwn$f(queue$1,e)){var t=queue$1[e];delete queue$1[e],t()}},runner=function(e){return function(){run(e)}},listener=function(e){run(e.data)},post=function(e){global$r.postMessage(String$1(e),$location.protocol+"//"+$location.host)};set$2&&clear||(set$2=function(e){validateArgumentsLength$2(arguments.length,1);var t=isCallable$9(e)?e:Function$1(e),r=arraySlice$8(arguments,1);return queue$1[++counter]=function(){apply$7(t,void 0,r)},defer(counter),counter},clear=function(e){delete queue$1[e]},IS_NODE$4?defer=function(e){process$2.nextTick(runner(e))}:Dispatch&&Dispatch.now?defer=function(e){Dispatch.now(runner(e))}:MessageChannel&&!IS_IOS$1?(port=(channel=new MessageChannel).port2,channel.port1.onmessage=listener,defer=bind$7(port.postMessage,port)):global$r.addEventListener&&isCallable$9(global$r.postMessage)&&!global$r.importScripts&&$location&&"file:"!==$location.protocol&&!fails$s(post)?(defer=post,global$r.addEventListener("message",listener,!1)):defer=ONREADYSTATECHANGE in createElement$1("script")?function(e){html.appendChild(createElement$1("script"))[ONREADYSTATECHANGE]=function(){html.removeChild(this),run(e)}}:function(e){setTimeout(runner(e),0)});var flush,head,last,notify$1,toggle,node,promise,then,task$1={set:set$2,clear:clear},userAgent$4=engineUserAgent,global$q=global$K,engineIsIosPebble=/ipad|iphone|ipod/i.test(userAgent$4)&&void 0!==global$q.Pebble,userAgent$3=engineUserAgent,engineIsWebosWebkit=/web0s(?!.*chrome)/i.test(userAgent$3),global$p=global$K,bind$6=functionBindContext,getOwnPropertyDescriptor$3=objectGetOwnPropertyDescriptor.f,macrotask=task$1.set,IS_IOS=engineIsIos,IS_IOS_PEBBLE=engineIsIosPebble,IS_WEBOS_WEBKIT=engineIsWebosWebkit,IS_NODE$3=engineIsNode,MutationObserver=global$p.MutationObserver||global$p.WebKitMutationObserver,document$2=global$p.document,process$1=global$p.process,Promise$1=global$p.Promise,queueMicrotaskDescriptor=getOwnPropertyDescriptor$3(global$p,"queueMicrotask"),queueMicrotask=queueMicrotaskDescriptor&&queueMicrotaskDescriptor.value;queueMicrotask||(flush=function(){var e,t;for(IS_NODE$3&&(e=process$1.domain)&&e.exit();head;){t=head.fn,head=head.next;try{t()}catch(e){throw head?notify$1():last=void 0,e}}last=void 0,e&&e.enter()},IS_IOS||IS_NODE$3||IS_WEBOS_WEBKIT||!MutationObserver||!document$2?!IS_IOS_PEBBLE&&Promise$1&&Promise$1.resolve?((promise=Promise$1.resolve(void 0)).constructor=Promise$1,then=bind$6(promise.then,promise),notify$1=function(){then(flush)}):IS_NODE$3?notify$1=function(){process$1.nextTick(flush)}:(macrotask=bind$6(macrotask,global$p),notify$1=function(){macrotask(flush)}):(toggle=!0,node=document$2.createTextNode(""),new MutationObserver(flush).observe(node,{characterData:!0}),notify$1=function(){node.data=toggle=!toggle}));var microtask$1=queueMicrotask||function(e){var t={fn:e,next:void 0};last&&(last.next=t),head||(head=t,notify$1()),last=t},global$o=global$K,hostReportErrors$1=function(e,t){var r=global$o.console;r&&r.error&&(1==arguments.length?r.error(e):r.error(e,t))},perform$3=function(e){try{return{error:!1,value:e()}}catch(e){return{error:!0,value:e}}},Queue$1=function(){this.head=null,this.tail=null};Queue$1.prototype={add:function(e){var t={item:e,next:null};this.head?this.tail.next=t:this.head=t,this.tail=t},get:function(){var e=this.head;if(e)return this.head=e.next,this.tail===e&&(this.tail=null),e.item}};var queue=Queue$1,global$n=global$K,promiseNativeConstructor=global$n.Promise,engineIsDeno="object"==typeof Deno&&Deno&&"object"==typeof Deno.version,IS_DENO$1=engineIsDeno,IS_NODE$2=engineIsNode,engineIsBrowser=!IS_DENO$1&&!IS_NODE$2&&"object"==typeof window&&"object"==typeof document,global$m=global$K,NativePromiseConstructor$4=promiseNativeConstructor,isCallable$8=isCallable$t,isForced$2=isForced_1,inspectSource=inspectSource$3,wellKnownSymbol$a=wellKnownSymbol$u,IS_BROWSER=engineIsBrowser,IS_DENO=engineIsDeno,V8_VERSION$1=engineV8Version;NativePromiseConstructor$4&&NativePromiseConstructor$4.prototype;var SPECIES=wellKnownSymbol$a("species"),SUBCLASSING=!1,NATIVE_PROMISE_REJECTION_EVENT$1=isCallable$8(global$m.PromiseRejectionEvent),FORCED_PROMISE_CONSTRUCTOR$5=isForced$2("Promise",(function(){var e=inspectSource(NativePromiseConstructor$4),t=e!==String(NativePromiseConstructor$4);if(!t&&66===V8_VERSION$1)return!0;if(!V8_VERSION$1||V8_VERSION$1<51||!/native code/.test(e)){var r=new NativePromiseConstructor$4((function(e){e(1)})),n=function(e){e((function(){}),(function(){}))};if((r.constructor={})[SPECIES]=n,!(SUBCLASSING=r.then((function(){}))instanceof n))return!0}return!t&&(IS_BROWSER||IS_DENO)&&!NATIVE_PROMISE_REJECTION_EVENT$1})),promiseConstructorDetection={CONSTRUCTOR:FORCED_PROMISE_CONSTRUCTOR$5,REJECTION_EVENT:NATIVE_PROMISE_REJECTION_EVENT$1,SUBCLASSING:SUBCLASSING},newPromiseCapability$2={},aCallable$6=aCallable$b,$TypeError$3=TypeError,PromiseCapability=function(e){var t,r;this.promise=new e((function(e,n){if(void 0!==t||void 0!==r)throw $TypeError$3("Bad Promise constructor");t=e,r=n})),this.resolve=aCallable$6(t),this.reject=aCallable$6(r)};newPromiseCapability$2.f=function(e){return new PromiseCapability(e)};var Internal,OwnPromiseCapability,PromiseWrapper,nativeThen,$$z=_export,IS_NODE$1=engineIsNode,global$l=global$K,call$j=functionCall,defineBuiltIn$b=defineBuiltIn$j,setPrototypeOf$3=objectSetPrototypeOf,setToStringTag$6=setToStringTag$a,setSpecies$2=setSpecies$4,aCallable$5=aCallable$b,isCallable$7=isCallable$t,isObject$c=isObject$s,anInstance$7=anInstance$a,speciesConstructor$3=speciesConstructor$4,task=task$1.set,microtask=microtask$1,hostReportErrors=hostReportErrors$1,perform$2=perform$3,Queue=queue,InternalStateModule$8=internalState,NativePromiseConstructor$3=promiseNativeConstructor,PromiseConstructorDetection=promiseConstructorDetection,newPromiseCapabilityModule$3=newPromiseCapability$2,PROMISE="Promise",FORCED_PROMISE_CONSTRUCTOR$4=PromiseConstructorDetection.CONSTRUCTOR,NATIVE_PROMISE_REJECTION_EVENT=PromiseConstructorDetection.REJECTION_EVENT,NATIVE_PROMISE_SUBCLASSING=PromiseConstructorDetection.SUBCLASSING,getInternalPromiseState=InternalStateModule$8.getterFor(PROMISE),setInternalState$7=InternalStateModule$8.set,NativePromisePrototype$2=NativePromiseConstructor$3&&NativePromiseConstructor$3.prototype,PromiseConstructor=NativePromiseConstructor$3,PromisePrototype=NativePromisePrototype$2,TypeError$6=global$l.TypeError,document$1=global$l.document,process=global$l.process,newPromiseCapability$1=newPromiseCapabilityModule$3.f,newGenericPromiseCapability=newPromiseCapability$1,DISPATCH_EVENT=!!(document$1&&document$1.createEvent&&global$l.dispatchEvent),UNHANDLED_REJECTION="unhandledrejection",REJECTION_HANDLED="rejectionhandled",PENDING=0,FULFILLED=1,REJECTED=2,HANDLED=1,UNHANDLED=2,isThenable=function(e){var t;return!(!isObject$c(e)||!isCallable$7(t=e.then))&&t},callReaction=function(e,t){var r,n,i,o=t.value,a=t.state==FULFILLED,s=a?e.ok:e.fail,c=e.resolve,u=e.reject,l=e.domain;try{s?(a||(t.rejection===UNHANDLED&&onHandleUnhandled(t),t.rejection=HANDLED),!0===s?r=o:(l&&l.enter(),r=s(o),l&&(l.exit(),i=!0)),r===e.promise?u(TypeError$6("Promise-chain cycle")):(n=isThenable(r))?call$j(n,r,c,u):c(r)):u(o)}catch(e){l&&!i&&l.exit(),u(e)}},notify=function(e,t){e.notified||(e.notified=!0,microtask((function(){for(var r,n=e.reactions;r=n.get();)callReaction(r,e);e.notified=!1,t&&!e.rejection&&onUnhandled(e)})))},dispatchEvent=function(e,t,r){var n,i;DISPATCH_EVENT?((n=document$1.createEvent("Event")).promise=t,n.reason=r,n.initEvent(e,!1,!0),global$l.dispatchEvent(n)):n={promise:t,reason:r},!NATIVE_PROMISE_REJECTION_EVENT&&(i=global$l["on"+e])?i(n):e===UNHANDLED_REJECTION&&hostReportErrors("Unhandled promise rejection",r)},onUnhandled=function(e){call$j(task,global$l,(function(){var t,r=e.facade,n=e.value;if(isUnhandled(e)&&(t=perform$2((function(){IS_NODE$1?process.emit("unhandledRejection",n,r):dispatchEvent(UNHANDLED_REJECTION,r,n)})),e.rejection=IS_NODE$1||isUnhandled(e)?UNHANDLED:HANDLED,t.error))throw t.value}))},isUnhandled=function(e){return e.rejection!==HANDLED&&!e.parent},onHandleUnhandled=function(e){call$j(task,global$l,(function(){var t=e.facade;IS_NODE$1?process.emit("rejectionHandled",t):dispatchEvent(REJECTION_HANDLED,t,e.value)}))},bind$5=function(e,t,r){return function(n){e(t,n,r)}},internalReject=function(e,t,r){e.done||(e.done=!0,r&&(e=r),e.value=t,e.state=REJECTED,notify(e,!0))},internalResolve=function(e,t,r){if(!e.done){e.done=!0,r&&(e=r);try{if(e.facade===t)throw TypeError$6("Promise can't be resolved itself");var n=isThenable(t);n?microtask((function(){var r={done:!1};try{call$j(n,t,bind$5(internalResolve,r,e),bind$5(internalReject,r,e))}catch(t){internalReject(r,t,e)}})):(e.value=t,e.state=FULFILLED,notify(e,!1))}catch(t){internalReject({done:!1},t,e)}}};if(FORCED_PROMISE_CONSTRUCTOR$4&&(PromisePrototype=(PromiseConstructor=function(e){anInstance$7(this,PromisePrototype),aCallable$5(e),call$j(Internal,this);var t=getInternalPromiseState(this);try{e(bind$5(internalResolve,t),bind$5(internalReject,t))}catch(e){internalReject(t,e)}}).prototype,(Internal=function(e){setInternalState$7(this,{type:PROMISE,done:!1,notified:!1,parent:!1,reactions:new Queue,rejection:!1,state:PENDING,value:void 0})}).prototype=defineBuiltIn$b(PromisePrototype,"then",(function(e,t){var r=getInternalPromiseState(this),n=newPromiseCapability$1(speciesConstructor$3(this,PromiseConstructor));return r.parent=!0,n.ok=!isCallable$7(e)||e,n.fail=isCallable$7(t)&&t,n.domain=IS_NODE$1?process.domain:void 0,r.state==PENDING?r.reactions.add(n):microtask((function(){callReaction(n,r)})),n.promise})),OwnPromiseCapability=function(){var e=new Internal,t=getInternalPromiseState(e);this.promise=e,this.resolve=bind$5(internalResolve,t),this.reject=bind$5(internalReject,t)},newPromiseCapabilityModule$3.f=newPromiseCapability$1=function(e){return e===PromiseConstructor||e===PromiseWrapper?new OwnPromiseCapability(e):newGenericPromiseCapability(e)},isCallable$7(NativePromiseConstructor$3)&&NativePromisePrototype$2!==Object.prototype)){nativeThen=NativePromisePrototype$2.then,NATIVE_PROMISE_SUBCLASSING||defineBuiltIn$b(NativePromisePrototype$2,"then",(function(e,t){var r=this;return new PromiseConstructor((function(e,t){call$j(nativeThen,r,e,t)})).then(e,t)}),{unsafe:!0});try{delete NativePromisePrototype$2.constructor}catch(e){}setPrototypeOf$3&&setPrototypeOf$3(NativePromisePrototype$2,PromisePrototype)}$$z({global:!0,constructor:!0,wrap:!0,forced:FORCED_PROMISE_CONSTRUCTOR$4},{Promise:PromiseConstructor}),setToStringTag$6(PromiseConstructor,PROMISE,!1),setSpecies$2(PROMISE);var NativePromiseConstructor$2=promiseNativeConstructor,checkCorrectnessOfIteration$2=checkCorrectnessOfIteration$4,FORCED_PROMISE_CONSTRUCTOR$3=promiseConstructorDetection.CONSTRUCTOR,promiseStaticsIncorrectIteration=FORCED_PROMISE_CONSTRUCTOR$3||!checkCorrectnessOfIteration$2((function(e){NativePromiseConstructor$2.all(e).then(void 0,(function(){}))})),$$y=_export,call$i=functionCall,aCallable$4=aCallable$b,newPromiseCapabilityModule$2=newPromiseCapability$2,perform$1=perform$3,iterate$2=iterate$5,PROMISE_STATICS_INCORRECT_ITERATION$1=promiseStaticsIncorrectIteration;$$y({target:"Promise",stat:!0,forced:PROMISE_STATICS_INCORRECT_ITERATION$1},{all:function(e){var t=this,r=newPromiseCapabilityModule$2.f(t),n=r.resolve,i=r.reject,o=perform$1((function(){var r=aCallable$4(t.resolve),o=[],a=0,s=1;iterate$2(e,(function(e){var c=a++,u=!1;s++,call$i(r,t,e).then((function(e){u||(u=!0,o[c]=e,--s||n(o))}),i)})),--s||n(o)}));return o.error&&i(o.value),r.promise}});var $$x=_export,FORCED_PROMISE_CONSTRUCTOR$2=promiseConstructorDetection.CONSTRUCTOR,NativePromiseConstructor$1=promiseNativeConstructor,getBuiltIn$8=getBuiltIn$g,isCallable$6=isCallable$t,defineBuiltIn$a=defineBuiltIn$j,NativePromisePrototype$1=NativePromiseConstructor$1&&NativePromiseConstructor$1.prototype;if($$x({target:"Promise",proto:!0,forced:FORCED_PROMISE_CONSTRUCTOR$2,real:!0},{catch:function(e){return this.then(void 0,e)}}),isCallable$6(NativePromiseConstructor$1)){var method$1=getBuiltIn$8("Promise").prototype.catch;NativePromisePrototype$1.catch!==method$1&&defineBuiltIn$a(NativePromisePrototype$1,"catch",method$1,{unsafe:!0})}var $$w=_export,call$h=functionCall,aCallable$3=aCallable$b,newPromiseCapabilityModule$1=newPromiseCapability$2,perform=perform$3,iterate$1=iterate$5,PROMISE_STATICS_INCORRECT_ITERATION=promiseStaticsIncorrectIteration;$$w({target:"Promise",stat:!0,forced:PROMISE_STATICS_INCORRECT_ITERATION},{race:function(e){var t=this,r=newPromiseCapabilityModule$1.f(t),n=r.reject,i=perform((function(){var i=aCallable$3(t.resolve);iterate$1(e,(function(e){call$h(i,t,e).then(r.resolve,n)}))}));return i.error&&n(i.value),r.promise}});var $$v=_export,call$g=functionCall,newPromiseCapabilityModule=newPromiseCapability$2,FORCED_PROMISE_CONSTRUCTOR$1=promiseConstructorDetection.CONSTRUCTOR;$$v({target:"Promise",stat:!0,forced:FORCED_PROMISE_CONSTRUCTOR$1},{reject:function(e){var t=newPromiseCapabilityModule.f(this);return call$g(t.reject,void 0,e),t.promise}});var anObject$c=anObject$q,isObject$b=isObject$s,newPromiseCapability=newPromiseCapability$2,promiseResolve$2=function(e,t){if(anObject$c(e),isObject$b(t)&&t.constructor===e)return t;var r=newPromiseCapability.f(e);return(0,r.resolve)(t),r.promise},$$u=_export,getBuiltIn$7=getBuiltIn$g,FORCED_PROMISE_CONSTRUCTOR=promiseConstructorDetection.CONSTRUCTOR,promiseResolve$1=promiseResolve$2;getBuiltIn$7("Promise"),$$u({target:"Promise",stat:!0,forced:FORCED_PROMISE_CONSTRUCTOR},{resolve:function(e){return promiseResolve$1(this,e)}});var IS_NODE=engineIsNode,tryNodeRequire$1=function(e){try{if(IS_NODE)return Function('return require("'+e+'")')()}catch(e){}},makeBuiltIn=makeBuiltIn$3.exports,defineProperty$8=objectDefineProperty,defineBuiltInAccessor$5=function(e,t,r){return r.get&&makeBuiltIn(r.get,t,{getter:!0}),r.set&&makeBuiltIn(r.set,t,{setter:!0}),defineProperty$8.f(e,t,r)},DESCRIPTORS$f=descriptors,fails$r=fails$U,anObject$b=anObject$q,create$3=objectCreate,normalizeStringArgument$2=normalizeStringArgument$4,nativeErrorToString=Error.prototype.toString,INCORRECT_TO_STRING$1=fails$r((function(){if(DESCRIPTORS$f){var e=create$3(Object.defineProperty({},"name",{get:function(){return this===e}}));if("true"!==nativeErrorToString.call(e))return!0}return"2: 1"!==nativeErrorToString.call({message:1,name:2})||"Error"!==nativeErrorToString.call({})})),errorToString$1=INCORRECT_TO_STRING$1?function(){var e=anObject$b(this),t=normalizeStringArgument$2(e.name,"Error"),r=normalizeStringArgument$2(e.message);return t?r?t+": "+r:t:r}:nativeErrorToString,domExceptionConstants={IndexSizeError:{s:"INDEX_SIZE_ERR",c:1,m:1},DOMStringSizeError:{s:"DOMSTRING_SIZE_ERR",c:2,m:0},HierarchyRequestError:{s:"HIERARCHY_REQUEST_ERR",c:3,m:1},WrongDocumentError:{s:"WRONG_DOCUMENT_ERR",c:4,m:1},InvalidCharacterError:{s:"INVALID_CHARACTER_ERR",c:5,m:1},NoDataAllowedError:{s:"NO_DATA_ALLOWED_ERR",c:6,m:0},NoModificationAllowedError:{s:"NO_MODIFICATION_ALLOWED_ERR",c:7,m:1},NotFoundError:{s:"NOT_FOUND_ERR",c:8,m:1},NotSupportedError:{s:"NOT_SUPPORTED_ERR",c:9,m:1},InUseAttributeError:{s:"INUSE_ATTRIBUTE_ERR",c:10,m:1},InvalidStateError:{s:"INVALID_STATE_ERR",c:11,m:1},SyntaxError:{s:"SYNTAX_ERR",c:12,m:1},InvalidModificationError:{s:"INVALID_MODIFICATION_ERR",c:13,m:1},NamespaceError:{s:"NAMESPACE_ERR",c:14,m:1},InvalidAccessError:{s:"INVALID_ACCESS_ERR",c:15,m:1},ValidationError:{s:"VALIDATION_ERR",c:16,m:0},TypeMismatchError:{s:"TYPE_MISMATCH_ERR",c:17,m:1},SecurityError:{s:"SECURITY_ERR",c:18,m:1},NetworkError:{s:"NETWORK_ERR",c:19,m:1},AbortError:{s:"ABORT_ERR",c:20,m:1},URLMismatchError:{s:"URL_MISMATCH_ERR",c:21,m:1},QuotaExceededError:{s:"QUOTA_EXCEEDED_ERR",c:22,m:1},TimeoutError:{s:"TIMEOUT_ERR",c:23,m:1},InvalidNodeTypeError:{s:"INVALID_NODE_TYPE_ERR",c:24,m:1},DataCloneError:{s:"DATA_CLONE_ERR",c:25,m:1}},$$t=_export,tryNodeRequire=tryNodeRequire$1,getBuiltIn$6=getBuiltIn$g,fails$q=fails$U,create$2=objectCreate,createPropertyDescriptor$5=createPropertyDescriptor$b,defineProperty$7=objectDefineProperty.f,defineBuiltIn$9=defineBuiltIn$j,defineBuiltInAccessor$4=defineBuiltInAccessor$5,hasOwn$e=hasOwnProperty_1,anInstance$6=anInstance$a,anObject$a=anObject$q,errorToString=errorToString$1,normalizeStringArgument$1=normalizeStringArgument$4,DOMExceptionConstants$1=domExceptionConstants,clearErrorStack$1=errorStackClear,InternalStateModule$7=internalState,DESCRIPTORS$e=descriptors,DOM_EXCEPTION$2="DOMException",DATA_CLONE_ERR="DATA_CLONE_ERR",Error$2=getBuiltIn$6("Error"),NativeDOMException$1=getBuiltIn$6(DOM_EXCEPTION$2)||function(){try{(new(getBuiltIn$6("MessageChannel")||tryNodeRequire("worker_threads").MessageChannel)).port1.postMessage(new WeakMap)}catch(e){if(e.name==DATA_CLONE_ERR&&25==e.code)return e.constructor}}(),NativeDOMExceptionPrototype=NativeDOMException$1&&NativeDOMException$1.prototype,ErrorPrototype=Error$2.prototype,setInternalState$6=InternalStateModule$7.set,getInternalState$6=InternalStateModule$7.getterFor(DOM_EXCEPTION$2),HAS_STACK="stack"in Error$2(DOM_EXCEPTION$2),codeFor=function(e){return hasOwn$e(DOMExceptionConstants$1,e)&&DOMExceptionConstants$1[e].m?DOMExceptionConstants$1[e].c:0},$DOMException$1=function(){anInstance$6(this,DOMExceptionPrototype$1);var e=arguments.length,t=normalizeStringArgument$1(e<1?void 0:arguments[0]),r=normalizeStringArgument$1(e<2?void 0:arguments[1],"Error"),n=codeFor(r);if(setInternalState$6(this,{type:DOM_EXCEPTION$2,name:r,message:t,code:n}),DESCRIPTORS$e||(this.name=r,this.message=t,this.code=n),HAS_STACK){var i=Error$2(t);i.name=DOM_EXCEPTION$2,defineProperty$7(this,"stack",createPropertyDescriptor$5(1,clearErrorStack$1(i.stack,1)))}},DOMExceptionPrototype$1=$DOMException$1.prototype=create$2(ErrorPrototype),createGetterDescriptor=function(e){return{enumerable:!0,configurable:!0,get:e}},getterFor=function(e){return createGetterDescriptor((function(){return getInternalState$6(this)[e]}))};DESCRIPTORS$e&&(defineBuiltInAccessor$4(DOMExceptionPrototype$1,"code",getterFor("code")),defineBuiltInAccessor$4(DOMExceptionPrototype$1,"message",getterFor("message")),defineBuiltInAccessor$4(DOMExceptionPrototype$1,"name",getterFor("name"))),defineProperty$7(DOMExceptionPrototype$1,"constructor",createPropertyDescriptor$5(1,$DOMException$1));var INCORRECT_CONSTRUCTOR=fails$q((function(){return!(new NativeDOMException$1 instanceof Error$2)})),INCORRECT_TO_STRING=INCORRECT_CONSTRUCTOR||fails$q((function(){return ErrorPrototype.toString!==errorToString||"2: 1"!==String(new NativeDOMException$1(1,2))})),INCORRECT_CODE=INCORRECT_CONSTRUCTOR||fails$q((function(){return 25!==new NativeDOMException$1(1,"DataCloneError").code}));INCORRECT_CONSTRUCTOR||25!==NativeDOMException$1[DATA_CLONE_ERR]||NativeDOMExceptionPrototype[DATA_CLONE_ERR];var FORCED_CONSTRUCTOR$1=INCORRECT_CONSTRUCTOR;$$t({global:!0,constructor:!0,forced:INCORRECT_CONSTRUCTOR},{DOMException:INCORRECT_CONSTRUCTOR?$DOMException$1:NativeDOMException$1});var PolyfilledDOMException$1=getBuiltIn$6(DOM_EXCEPTION$2),PolyfilledDOMExceptionPrototype$1=PolyfilledDOMException$1.prototype;for(var key$3 in INCORRECT_TO_STRING&&NativeDOMException$1===PolyfilledDOMException$1&&defineBuiltIn$9(PolyfilledDOMExceptionPrototype$1,"toString",errorToString),INCORRECT_CODE&&DESCRIPTORS$e&&NativeDOMException$1===PolyfilledDOMException$1&&defineBuiltInAccessor$4(PolyfilledDOMExceptionPrototype$1,"code",createGetterDescriptor((function(){return codeFor(anObject$a(this).name)}))),DOMExceptionConstants$1)if(hasOwn$e(DOMExceptionConstants$1,key$3)){var constant$2=DOMExceptionConstants$1[key$3],constantName$1=constant$2.s,descriptor$1=createPropertyDescriptor$5(6,constant$2.c);hasOwn$e(PolyfilledDOMException$1,constantName$1)||defineProperty$7(PolyfilledDOMException$1,constantName$1,descriptor$1),hasOwn$e(PolyfilledDOMExceptionPrototype$1,constantName$1)||defineProperty$7(PolyfilledDOMExceptionPrototype$1,constantName$1,descriptor$1)}var $$s=_export,global$k=global$K,getBuiltIn$5=getBuiltIn$g,createPropertyDescriptor$4=createPropertyDescriptor$b,defineProperty$6=objectDefineProperty.f,hasOwn$d=hasOwnProperty_1,anInstance$5=anInstance$a,inheritIfRequired$3=inheritIfRequired$6,normalizeStringArgument=normalizeStringArgument$4,DOMExceptionConstants=domExceptionConstants,clearErrorStack=errorStackClear,DESCRIPTORS$d=descriptors,DOM_EXCEPTION$1="DOMException",Error$1=getBuiltIn$5("Error"),NativeDOMException=getBuiltIn$5(DOM_EXCEPTION$1),$DOMException=function(){anInstance$5(this,DOMExceptionPrototype);var e=arguments.length,t=normalizeStringArgument(e<1?void 0:arguments[0]),r=normalizeStringArgument(e<2?void 0:arguments[1],"Error"),n=new NativeDOMException(t,r),i=Error$1(t);return i.name=DOM_EXCEPTION$1,defineProperty$6(n,"stack",createPropertyDescriptor$4(1,clearErrorStack(i.stack,1))),inheritIfRequired$3(n,this,$DOMException),n},DOMExceptionPrototype=$DOMException.prototype=NativeDOMException.prototype,ERROR_HAS_STACK="stack"in Error$1(DOM_EXCEPTION$1),DOM_EXCEPTION_HAS_STACK="stack"in new NativeDOMException(1,2),descriptor=NativeDOMException&&DESCRIPTORS$d&&Object.getOwnPropertyDescriptor(global$k,DOM_EXCEPTION$1),BUGGY_DESCRIPTOR=!(!descriptor||descriptor.writable&&descriptor.configurable),FORCED_CONSTRUCTOR=ERROR_HAS_STACK&&!BUGGY_DESCRIPTOR&&!DOM_EXCEPTION_HAS_STACK;$$s({global:!0,constructor:!0,forced:FORCED_CONSTRUCTOR},{DOMException:FORCED_CONSTRUCTOR?$DOMException:NativeDOMException});var PolyfilledDOMException=getBuiltIn$5(DOM_EXCEPTION$1),PolyfilledDOMExceptionPrototype=PolyfilledDOMException.prototype;if(PolyfilledDOMExceptionPrototype.constructor!==PolyfilledDOMException)for(var key$2 in defineProperty$6(PolyfilledDOMExceptionPrototype,"constructor",createPropertyDescriptor$4(1,PolyfilledDOMException)),DOMExceptionConstants)if(hasOwn$d(DOMExceptionConstants,key$2)){var constant$1=DOMExceptionConstants[key$2],constantName=constant$1.s;hasOwn$d(PolyfilledDOMException,constantName)||defineProperty$6(PolyfilledDOMException,constantName,createPropertyDescriptor$4(6,constant$1.c))}var getBuiltIn$4=getBuiltIn$g,setToStringTag$5=setToStringTag$a,DOM_EXCEPTION="DOMException";setToStringTag$5(getBuiltIn$4(DOM_EXCEPTION),DOM_EXCEPTION);var $$r=_export,$filter$1=arrayIteration.filter,arrayMethodHasSpeciesSupport$1=arrayMethodHasSpeciesSupport$5,HAS_SPECIES_SUPPORT=arrayMethodHasSpeciesSupport$1("filter");$$r({target:"Array",proto:!0,forced:!HAS_SPECIES_SUPPORT},{filter:function(e){return $filter$1(this,e,arguments.length>1?arguments[1]:void 0)}});var $$q=_export,fails$p=fails$U,isArray$3=isArray$7,isObject$a=isObject$s,toObject$9=toObject$i,lengthOfArrayLike$d=lengthOfArrayLike$m,doesNotExceedSafeInteger$1=doesNotExceedSafeInteger$4,createProperty$1=createProperty$5,arraySpeciesCreate=arraySpeciesCreate$3,arrayMethodHasSpeciesSupport=arrayMethodHasSpeciesSupport$5,wellKnownSymbol$9=wellKnownSymbol$u,V8_VERSION=engineV8Version,IS_CONCAT_SPREADABLE=wellKnownSymbol$9("isConcatSpreadable"),IS_CONCAT_SPREADABLE_SUPPORT=V8_VERSION>=51||!fails$p((function(){var e=[];return e[IS_CONCAT_SPREADABLE]=!1,e.concat()[0]!==e})),SPECIES_SUPPORT=arrayMethodHasSpeciesSupport("concat"),isConcatSpreadable=function(e){if(!isObject$a(e))return!1;var t=e[IS_CONCAT_SPREADABLE];return void 0!==t?!!t:isArray$3(e)},FORCED$8=!IS_CONCAT_SPREADABLE_SUPPORT||!SPECIES_SUPPORT;$$q({target:"Array",proto:!0,arity:1,forced:FORCED$8},{concat:function(e){var t,r,n,i,o,a=toObject$9(this),s=arraySpeciesCreate(a,0),c=0;for(t=-1,n=arguments.length;t<n;t++)if(isConcatSpreadable(o=-1===t?a:arguments[t]))for(i=lengthOfArrayLike$d(o),doesNotExceedSafeInteger$1(c+i),r=0;r<i;r++,c++)r in o&&createProperty$1(s,c,o[r]);else doesNotExceedSafeInteger$1(c+1),createProperty$1(s,c++,o);return s.length=c,s}});var uncurryThis$q=functionUncurryThis,toObject$8=toObject$i,floor$6=Math.floor,charAt$5=uncurryThis$q("".charAt),replace$5=uncurryThis$q("".replace),stringSlice$7=uncurryThis$q("".slice),SUBSTITUTION_SYMBOLS=/\$([$&'`]|\d{1,2}|<[^>]*>)/g,SUBSTITUTION_SYMBOLS_NO_NAMED=/\$([$&'`]|\d{1,2})/g,getSubstitution$1=function(e,t,r,n,i,o){var a=r+e.length,s=n.length,c=SUBSTITUTION_SYMBOLS_NO_NAMED;return void 0!==i&&(i=toObject$8(i),c=SUBSTITUTION_SYMBOLS),replace$5(o,c,(function(o,c){var u;switch(charAt$5(c,0)){case"$":return"$";case"&":return e;case"`":return stringSlice$7(t,0,r);case"'":return stringSlice$7(t,a);case"<":u=i[stringSlice$7(c,1,-1)];break;default:var l=+c;if(0===l)return o;if(l>s){var d=floor$6(l/10);return 0===d?o:d<=s?void 0===n[d-1]?charAt$5(c,1):n[d-1]+charAt$5(c,1):o}u=n[l-1]}return void 0===u?"":u}))},apply$6=functionApply,call$f=functionCall,uncurryThis$p=functionUncurryThis,fixRegExpWellKnownSymbolLogic$1=fixRegexpWellKnownSymbolLogic,fails$o=fails$U,anObject$9=anObject$q,isCallable$5=isCallable$t,isNullOrUndefined$2=isNullOrUndefined$b,toIntegerOrInfinity$8=toIntegerOrInfinity$d,toLength$6=toLength$a,toString$b=toString$m,requireObjectCoercible$4=requireObjectCoercible$d,advanceStringIndex$1=advanceStringIndex$3,getMethod$1=getMethod$7,getSubstitution=getSubstitution$1,regExpExec=regexpExecAbstract,wellKnownSymbol$8=wellKnownSymbol$u,REPLACE=wellKnownSymbol$8("replace"),max=Math.max,min$4=Math.min,concat=uncurryThis$p([].concat),push$7=uncurryThis$p([].push),stringIndexOf$1=uncurryThis$p("".indexOf),stringSlice$6=uncurryThis$p("".slice),maybeToString=function(e){return void 0===e?e:String(e)},REPLACE_KEEPS_$0="$0"==="a".replace(/./,"$0"),REGEXP_REPLACE_SUBSTITUTES_UNDEFINED_CAPTURE=!!/./[REPLACE]&&""===/./[REPLACE]("a","$0"),REPLACE_SUPPORTS_NAMED_GROUPS=!fails$o((function(){var e=/./;return e.exec=function(){var e=[];return e.groups={a:"7"},e},"7"!=="".replace(e,"$<a>")}));fixRegExpWellKnownSymbolLogic$1("replace",(function(e,t,r){var n=REGEXP_REPLACE_SUBSTITUTES_UNDEFINED_CAPTURE?"$":"$0";return[function(e,r){var n=requireObjectCoercible$4(this),i=isNullOrUndefined$2(e)?void 0:getMethod$1(e,REPLACE);return i?call$f(i,e,n,r):call$f(t,toString$b(n),e,r)},function(e,i){var o=anObject$9(this),a=toString$b(e);if("string"==typeof i&&-1===stringIndexOf$1(i,n)&&-1===stringIndexOf$1(i,"$<")){var s=r(t,o,a,i);if(s.done)return s.value}var c=isCallable$5(i);c||(i=toString$b(i));var u=o.global;if(u){var l=o.unicode;o.lastIndex=0}for(var d=[];;){var p=regExpExec(o,a);if(null===p)break;if(push$7(d,p),!u)break;""===toString$b(p[0])&&(o.lastIndex=advanceStringIndex$1(a,toLength$6(o.lastIndex),l))}for(var _="",f=0,h=0;h<d.length;h++){for(var m=toString$b((p=d[h])[0]),y=max(min$4(toIntegerOrInfinity$8(p.index),a.length),0),v=[],S=1;S<p.length;S++)push$7(v,maybeToString(p[S]));var g=p.groups;if(c){var E=concat([m],v,y,a);void 0!==g&&push$7(E,g);var T=toString$b(apply$6(i,void 0,E))}else T=getSubstitution(m,a,y,v,g,i);y>=f&&(_+=stringSlice$6(a,f,y)+T,f=y+m.length)}return _+stringSlice$6(a,f)}]}),!REPLACE_SUPPORTS_NAMED_GROUPS||!REPLACE_KEEPS_$0||REGEXP_REPLACE_SUBSTITUTES_UNDEFINED_CAPTURE);var call$e=functionCall,hasOwn$c=hasOwnProperty_1,isPrototypeOf$5=objectIsPrototypeOf,regExpFlags$1=regexpFlags$1,RegExpPrototype$5=RegExp.prototype,regexpGetFlags=function(e){var t=e.flags;return void 0!==t||"flags"in RegExpPrototype$5||hasOwn$c(e,"flags")||!isPrototypeOf$5(RegExpPrototype$5,e)?t:call$e(regExpFlags$1,e)},DESCRIPTORS$c=descriptors,global$j=global$K,uncurryThis$o=functionUncurryThis,isForced$1=isForced_1,inheritIfRequired$2=inheritIfRequired$6,createNonEnumerableProperty$3=createNonEnumerableProperty$c,getOwnPropertyNames$3=objectGetOwnPropertyNames.f,isPrototypeOf$4=objectIsPrototypeOf,isRegExp$1=isRegexp,toString$a=toString$m,getRegExpFlags$1=regexpGetFlags,stickyHelpers$1=regexpStickyHelpers,proxyAccessor=proxyAccessor$2,defineBuiltIn$8=defineBuiltIn$j,fails$n=fails$U,hasOwn$b=hasOwnProperty_1,enforceInternalState$3=internalState.enforce,setSpecies$1=setSpecies$4,wellKnownSymbol$7=wellKnownSymbol$u,UNSUPPORTED_DOT_ALL$1=regexpUnsupportedDotAll,UNSUPPORTED_NCG=regexpUnsupportedNcg,MATCH$1=wellKnownSymbol$7("match"),NativeRegExp=global$j.RegExp,RegExpPrototype$4=NativeRegExp.prototype,SyntaxError=global$j.SyntaxError,exec$4=uncurryThis$o(RegExpPrototype$4.exec),charAt$4=uncurryThis$o("".charAt),replace$4=uncurryThis$o("".replace),stringIndexOf=uncurryThis$o("".indexOf),stringSlice$5=uncurryThis$o("".slice),IS_NCG=/^\?<[^\s\d!#%&*+<=>@^][^\s!#%&*+<=>@^]*>/,re1=/a/g,re2=/a/g,CORRECT_NEW=new NativeRegExp(re1)!==re1,MISSED_STICKY$1=stickyHelpers$1.MISSED_STICKY,UNSUPPORTED_Y$1=stickyHelpers$1.UNSUPPORTED_Y,BASE_FORCED=DESCRIPTORS$c&&(!CORRECT_NEW||MISSED_STICKY$1||UNSUPPORTED_DOT_ALL$1||UNSUPPORTED_NCG||fails$n((function(){return re2[MATCH$1]=!1,NativeRegExp(re1)!=re1||NativeRegExp(re2)==re2||"/a/i"!=NativeRegExp(re1,"i")}))),handleDotAll=function(e){for(var t,r=e.length,n=0,i="",o=!1;n<=r;n++)"\\"!==(t=charAt$4(e,n))?o||"."!==t?("["===t?o=!0:"]"===t&&(o=!1),i+=t):i+="[\\s\\S]":i+=t+charAt$4(e,++n);return i},handleNCG=function(e){for(var t,r=e.length,n=0,i="",o=[],a={},s=!1,c=!1,u=0,l="";n<=r;n++){if("\\"===(t=charAt$4(e,n)))t+=charAt$4(e,++n);else if("]"===t)s=!1;else if(!s)switch(!0){case"["===t:s=!0;break;case"("===t:exec$4(IS_NCG,stringSlice$5(e,n+1))&&(n+=2,c=!0),i+=t,u++;continue;case">"===t&&c:if(""===l||hasOwn$b(a,l))throw new SyntaxError("Invalid capture group name");a[l]=!0,o[o.length]=[l,u],c=!1,l="";continue}c?l+=t:i+=t}return[i,o]};if(isForced$1("RegExp",BASE_FORCED)){for(var RegExpWrapper=function(e,t){var r,n,i,o,a,s,c=isPrototypeOf$4(RegExpPrototype$4,this),u=isRegExp$1(e),l=void 0===t,d=[],p=e;if(!c&&u&&l&&e.constructor===RegExpWrapper)return e;if((u||isPrototypeOf$4(RegExpPrototype$4,e))&&(e=e.source,l&&(t=getRegExpFlags$1(p))),e=void 0===e?"":toString$a(e),t=void 0===t?"":toString$a(t),p=e,UNSUPPORTED_DOT_ALL$1&&"dotAll"in re1&&(n=!!t&&stringIndexOf(t,"s")>-1)&&(t=replace$4(t,/s/g,"")),r=t,MISSED_STICKY$1&&"sticky"in re1&&(i=!!t&&stringIndexOf(t,"y")>-1)&&UNSUPPORTED_Y$1&&(t=replace$4(t,/y/g,"")),UNSUPPORTED_NCG&&(e=(o=handleNCG(e))[0],d=o[1]),a=inheritIfRequired$2(NativeRegExp(e,t),c?this:RegExpPrototype$4,RegExpWrapper),(n||i||d.length)&&(s=enforceInternalState$3(a),n&&(s.dotAll=!0,s.raw=RegExpWrapper(handleDotAll(e),r)),i&&(s.sticky=!0),d.length&&(s.groups=d)),e!==p)try{createNonEnumerableProperty$3(a,"source",""===p?"(?:)":p)}catch(e){}return a},keys$3=getOwnPropertyNames$3(NativeRegExp),index$1=0;keys$3.length>index$1;)proxyAccessor(RegExpWrapper,NativeRegExp,keys$3[index$1++]);RegExpPrototype$4.constructor=RegExpWrapper,RegExpWrapper.prototype=RegExpPrototype$4,defineBuiltIn$8(global$j,"RegExp",RegExpWrapper,{constructor:!0})}setSpecies$1("RegExp");var DESCRIPTORS$b=descriptors,UNSUPPORTED_DOT_ALL=regexpUnsupportedDotAll,classof$6=classofRaw$2,defineBuiltInAccessor$3=defineBuiltInAccessor$5,getInternalState$5=internalState.get,RegExpPrototype$3=RegExp.prototype,$TypeError$2=TypeError;DESCRIPTORS$b&&UNSUPPORTED_DOT_ALL&&defineBuiltInAccessor$3(RegExpPrototype$3,"dotAll",{configurable:!0,get:function(){if(this!==RegExpPrototype$3){if("RegExp"===classof$6(this))return!!getInternalState$5(this).dotAll;throw $TypeError$2("Incompatible receiver, RegExp required")}}});var DESCRIPTORS$a=descriptors,MISSED_STICKY=regexpStickyHelpers.MISSED_STICKY,classof$5=classofRaw$2,defineBuiltInAccessor$2=defineBuiltInAccessor$5,getInternalState$4=internalState.get,RegExpPrototype$2=RegExp.prototype,$TypeError$1=TypeError;DESCRIPTORS$a&&MISSED_STICKY&&defineBuiltInAccessor$2(RegExpPrototype$2,"sticky",{configurable:!0,get:function(){if(this!==RegExpPrototype$2){if("RegExp"===classof$5(this))return!!getInternalState$4(this).sticky;throw $TypeError$1("Incompatible receiver, RegExp required")}}});var PROPER_FUNCTION_NAME$2=functionName.PROPER,defineBuiltIn$7=defineBuiltIn$j,anObject$8=anObject$q,$toString$3=toString$m,fails$m=fails$U,getRegExpFlags=regexpGetFlags,TO_STRING="toString",RegExpPrototype$1=RegExp.prototype,nativeToString=RegExpPrototype$1[TO_STRING],NOT_GENERIC=fails$m((function(){return"/a/b"!=nativeToString.call({source:"a",flags:"b"})})),INCORRECT_NAME=PROPER_FUNCTION_NAME$2&&nativeToString.name!=TO_STRING;(NOT_GENERIC||INCORRECT_NAME)&&defineBuiltIn$7(RegExp.prototype,TO_STRING,(function(){var e=anObject$8(this);return"/"+$toString$3(e.source)+"/"+$toString$3(getRegExpFlags(e))}),{unsafe:!0});var $$p=_export,fails$l=fails$U,toIndexedObject$4=toIndexedObject$c,nativeGetOwnPropertyDescriptor$2=objectGetOwnPropertyDescriptor.f,DESCRIPTORS$9=descriptors,FAILS_ON_PRIMITIVES=fails$l((function(){nativeGetOwnPropertyDescriptor$2(1)})),FORCED$7=!DESCRIPTORS$9||FAILS_ON_PRIMITIVES;$$p({target:"Object",stat:!0,forced:FORCED$7,sham:!DESCRIPTORS$9},{getOwnPropertyDescriptor:function(e,t){return nativeGetOwnPropertyDescriptor$2(toIndexedObject$4(e),t)}});var $$o=_export,getBuiltIn$3=getBuiltIn$g,apply$5=functionApply,call$d=functionCall,uncurryThis$n=functionUncurryThis,fails$k=fails$U,isArray$2=isArray$7,isCallable$4=isCallable$t,isObject$9=isObject$s,isSymbol$3=isSymbol$6,arraySlice$7=arraySlice$9,NATIVE_SYMBOL$3=symbolConstructorDetection,$stringify=getBuiltIn$3("JSON","stringify"),exec$3=uncurryThis$n(/./.exec),charAt$3=uncurryThis$n("".charAt),charCodeAt$2=uncurryThis$n("".charCodeAt),replace$3=uncurryThis$n("".replace),numberToString$1=uncurryThis$n(1..toString),tester=/[\uD800-\uDFFF]/g,low=/^[\uD800-\uDBFF]$/,hi=/^[\uDC00-\uDFFF]$/,WRONG_SYMBOLS_CONVERSION=!NATIVE_SYMBOL$3||fails$k((function(){var e=getBuiltIn$3("Symbol")();return"[null]"!=$stringify([e])||"{}"!=$stringify({a:e})||"{}"!=$stringify(Object(e))})),ILL_FORMED_UNICODE=fails$k((function(){return'"\\udf06\\ud834"'!==$stringify("\udf06\ud834")||'"\\udead"'!==$stringify("\udead")})),stringifyWithSymbolsFix=function(e,t){var r=arraySlice$7(arguments),n=t;if((isObject$9(t)||void 0!==e)&&!isSymbol$3(e))return isArray$2(t)||(t=function(e,t){if(isCallable$4(n)&&(t=call$d(n,this,e,t)),!isSymbol$3(t))return t}),r[1]=t,apply$5($stringify,null,r)},fixIllFormed=function(e,t,r){var n=charAt$3(r,t-1),i=charAt$3(r,t+1);return exec$3(low,e)&&!exec$3(hi,i)||exec$3(hi,e)&&!exec$3(low,n)?"\\u"+numberToString$1(charCodeAt$2(e,0),16):e};$stringify&&$$o({target:"JSON",stat:!0,arity:3,forced:WRONG_SYMBOLS_CONVERSION||ILL_FORMED_UNICODE},{stringify:function(e,t,r){var n=arraySlice$7(arguments),i=apply$5(WRONG_SYMBOLS_CONVERSION?stringifyWithSymbolsFix:$stringify,null,n);return ILL_FORMED_UNICODE&&"string"==typeof i?replace$3(i,tester,fixIllFormed):i}});var logging=log$2;function shimGetUserMedia$2(e,t){var r=e&&e.navigator;if(r.mediaDevices){var n=function(e){if("object"!==_typeof(e)||e.mandatory||e.optional)return e;var t={};return Object.keys(e).forEach((function(r){if("require"!==r&&"advanced"!==r&&"mediaSource"!==r){var n="object"===_typeof(e[r])?e[r]:{ideal:e[r]};void 0!==n.exact&&"number"==typeof n.exact&&(n.min=n.max=n.exact);var i=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||[];var o={};"number"==typeof n.ideal?(o[i("min",r)]=n.ideal,t.optional.push(o),(o={})[i("max",r)]=n.ideal,t.optional.push(o)):(o[i("",r)]=n.ideal,t.optional.push(o))}void 0!==n.exact&&"number"!=typeof n.exact?(t.mandatory=t.mandatory||{},t.mandatory[i("",r)]=n.exact):["min","max"].forEach((function(e){void 0!==n[e]&&(t.mandatory=t.mandatory||{},t.mandatory[i(e,r)]=n[e])}))}})),e.advanced&&(t.optional=(t.optional||[]).concat(e.advanced)),t},i=function(e,i){if(t.version>=61)return i(e);if((e=JSON.parse(JSON.stringify(e)))&&"object"===_typeof(e.audio)){var o=function(e,t,r){t in e&&!(r in e)&&(e[r]=e[t],delete e[t])};o((e=JSON.parse(JSON.stringify(e))).audio,"autoGainControl","googAutoGainControl"),o(e.audio,"noiseSuppression","googNoiseSuppression"),e.audio=n(e.audio)}if(e&&"object"===_typeof(e.video)){var a=e.video.facingMode;a=a&&("object"===_typeof(a)?a:{ideal:a});var s,c=t.version<66;if(a&&("user"===a.exact||"environment"===a.exact||"user"===a.ideal||"environment"===a.ideal)&&(!r.mediaDevices.getSupportedConstraints||!r.mediaDevices.getSupportedConstraints().facingMode||c))if(delete e.video.facingMode,"environment"===a.exact||"environment"===a.ideal?s=["back","rear"]:"user"!==a.exact&&"user"!==a.ideal||(s=["front"]),s)return r.mediaDevices.enumerateDevices().then((function(t){var r=(t=t.filter((function(e){return"videoinput"===e.kind}))).find((function(e){return s.some((function(t){return e.label.toLowerCase().includes(t)}))}));return!r&&t.length&&s.includes("back")&&(r=t[t.length-1]),r&&(e.video.deviceId=a.exact?{exact:r.deviceId}:{ideal:r.deviceId}),e.video=n(e.video),logging("chrome: "+JSON.stringify(e)),i(e)}));e.video=n(e.video)}return logging("chrome: "+JSON.stringify(e)),i(e)},o=function(e){return t.version>=64?e:{name:{PermissionDeniedError:"NotAllowedError",PermissionDismissedError:"NotAllowedError",InvalidStateError:"NotAllowedError",DevicesNotFoundError:"NotFoundError",ConstraintNotSatisfiedError:"OverconstrainedError",TrackStartError:"NotReadableError",MediaDeviceFailedDueToShutdown:"NotAllowedError",MediaDeviceKillSwitchOn:"NotAllowedError",TabCaptureError:"AbortError",ScreenCaptureError:"AbortError",DeviceCaptureError:"AbortError"}[e.name]||e.name,message:e.message,constraint:e.constraint||e.constraintName,toString:function(){return this.name+(this.message&&": ")+this.message}}};if(r.getUserMedia=function(e,t,n){i(e,(function(e){r.webkitGetUserMedia(e,t,(function(e){n&&n(o(e))}))}))}.bind(r),r.mediaDevices.getUserMedia){var a=r.mediaDevices.getUserMedia.bind(r.mediaDevices);r.mediaDevices.getUserMedia=function(e){return i(e,(function(e){return a(e).then((function(t){if(e.audio&&!t.getAudioTracks().length||e.video&&!t.getVideoTracks().length)throw t.getTracks().forEach((function(e){e.stop()})),new DOMException("","NotFoundError");return t}),(function(e){return Promise.reject(o(e))}))}))}}}}function shimGetDisplayMedia$1(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((function(t){var n=r.video&&r.video.width,i=r.video&&r.video.height,o=r.video&&r.video.frameRate;return r.video={mandatory:{chromeMediaSource:"desktop",chromeMediaSourceId:t,maxFrameRate:o||3}},n&&(r.video.mandatory.maxWidth=n),i&&(r.video.mandatory.maxHeight=i),e.navigator.mediaDevices.getUserMedia(r)}))}:console.error("shimGetDisplayMedia: getSourceId argument is not a function"))}function shimMediaStream(e){e.MediaStream=e.MediaStream||e.webkitMediaStream}function shimOnTrack$1(e){if("object"===_typeof(e)&&e.RTCPeerConnection&&!("ontrack"in e.RTCPeerConnection.prototype)){Object.defineProperty(e.RTCPeerConnection.prototype,"ontrack",{get:function(){return this._ontrack},set:function(e){this._ontrack&&this.removeEventListener("track",this._ontrack),this.addEventListener("track",this._ontrack=e)},enumerable:!0,configurable:!0});var t=e.RTCPeerConnection.prototype.setRemoteDescription;e.RTCPeerConnection.prototype.setRemoteDescription=function(){var r=this;return this._ontrackpoly||(this._ontrackpoly=function(t){t.stream.addEventListener("addtrack",(function(n){var i;i=e.RTCPeerConnection.prototype.getReceivers?r.getReceivers().find((function(e){return e.track&&e.track.id===n.track.id})):{track:n.track};var o=new Event("track");o.track=n.track,o.receiver=i,o.transceiver={receiver:i},o.streams=[t.stream],r.dispatchEvent(o)})),t.stream.getTracks().forEach((function(n){var i;i=e.RTCPeerConnection.prototype.getReceivers?r.getReceivers().find((function(e){return e.track&&e.track.id===n.id})):{track:n};var o=new Event("track");o.track=n,o.receiver=i,o.transceiver={receiver:i},o.streams=[t.stream],r.dispatchEvent(o)}))},this.addEventListener("addstream",this._ontrackpoly)),t.apply(this,arguments)}}else wrapPeerConnectionEvent(e,"track",(function(e){return e.transceiver||Object.defineProperty(e,"transceiver",{value:{receiver:e.receiver}}),e}))}function shimGetSendersWithDtmf(e){if("object"===_typeof(e)&&e.RTCPeerConnection&&!("getSenders"in e.RTCPeerConnection.prototype)&&"createDTMFSender"in e.RTCPeerConnection.prototype){var t=function(e,t){return{track:t,get dtmf(){return void 0===this._dtmf&&("audio"===t.kind?this._dtmf=e.createDTMFSender(t):this._dtmf=null),this._dtmf},_pc:e}};if(!e.RTCPeerConnection.prototype.getSenders){e.RTCPeerConnection.prototype.getSenders=function(){return this._senders=this._senders||[],this._senders.slice()};var r=e.RTCPeerConnection.prototype.addTrack;e.RTCPeerConnection.prototype.addTrack=function(e,n){var i=r.apply(this,arguments);return i||(i=t(this,e),this._senders.push(i)),i};var n=e.RTCPeerConnection.prototype.removeTrack;e.RTCPeerConnection.prototype.removeTrack=function(e){n.apply(this,arguments);var t=this._senders.indexOf(e);-1!==t&&this._senders.splice(t,1)}}var i=e.RTCPeerConnection.prototype.addStream;e.RTCPeerConnection.prototype.addStream=function(e){var r=this;this._senders=this._senders||[],i.apply(this,[e]),e.getTracks().forEach((function(e){r._senders.push(t(r,e))}))};var o=e.RTCPeerConnection.prototype.removeStream;e.RTCPeerConnection.prototype.removeStream=function(e){var t=this;this._senders=this._senders||[],o.apply(this,[e]),e.getTracks().forEach((function(e){var r=t._senders.find((function(t){return t.track===e}));r&&t._senders.splice(t._senders.indexOf(r),1)}))}}else if("object"===_typeof(e)&&e.RTCPeerConnection&&"getSenders"in e.RTCPeerConnection.prototype&&"createDTMFSender"in e.RTCPeerConnection.prototype&&e.RTCRtpSender&&!("dtmf"in e.RTCRtpSender.prototype)){var a=e.RTCPeerConnection.prototype.getSenders;e.RTCPeerConnection.prototype.getSenders=function(){var e=this,t=a.apply(this,[]);return t.forEach((function(t){return t._pc=e})),t},Object.defineProperty(e.RTCRtpSender.prototype,"dtmf",{get:function(){return void 0===this._dtmf&&("audio"===this.track.kind?this._dtmf=this._pc.createDTMFSender(this.track):this._dtmf=null),this._dtmf}})}}function shimGetStats(e){if(e.RTCPeerConnection){var t=e.RTCPeerConnection.prototype.getStats;e.RTCPeerConnection.prototype.getStats=function(){var e=this,r=Array.prototype.slice.call(arguments),n=r[0],i=r[1],o=r[2];if(arguments.length>0&&"function"==typeof n)return t.apply(this,arguments);if(0===t.length&&(0===arguments.length||"function"!=typeof n))return t.apply(this,[]);var a=function(e){var t={};return e.result().forEach((function(e){var r={id:e.id,timestamp:e.timestamp,type:{localcandidate:"local-candidate",remotecandidate:"remote-candidate"}[e.type]||e.type};e.names().forEach((function(t){r[t]=e.stat(t)})),t[r.id]=r})),t},s=function(e){return new Map(Object.keys(e).map((function(t){return[t,e[t]]})))};if(arguments.length>=2){var c=function(e){i(s(a(e)))};return t.apply(this,[c,n])}return new Promise((function(r,n){t.apply(e,[function(e){r(s(a(e)))},n])})).then(i,o)}}}function shimSenderReceiverGetStats(e){if("object"===_typeof(e)&&e.RTCPeerConnection&&e.RTCRtpSender&&e.RTCRtpReceiver){if(!("getStats"in e.RTCRtpSender.prototype)){var t=e.RTCPeerConnection.prototype.getSenders;t&&(e.RTCPeerConnection.prototype.getSenders=function(){var e=this,r=t.apply(this,[]);return r.forEach((function(t){return t._pc=e})),r});var r=e.RTCPeerConnection.prototype.addTrack;r&&(e.RTCPeerConnection.prototype.addTrack=function(){var e=r.apply(this,arguments);return e._pc=this,e}),e.RTCRtpSender.prototype.getStats=function(){var e=this;return this._pc.getStats().then((function(t){return filterStats(t,e.track,!0)}))}}if(!("getStats"in e.RTCRtpReceiver.prototype)){var n=e.RTCPeerConnection.prototype.getReceivers;n&&(e.RTCPeerConnection.prototype.getReceivers=function(){var e=this,t=n.apply(this,[]);return t.forEach((function(t){return t._pc=e})),t}),wrapPeerConnectionEvent(e,"track",(function(e){return e.receiver._pc=e.srcElement,e})),e.RTCRtpReceiver.prototype.getStats=function(){var e=this;return this._pc.getStats().then((function(t){return filterStats(t,e.track,!1)}))}}if("getStats"in e.RTCRtpSender.prototype&&"getStats"in e.RTCRtpReceiver.prototype){var i=e.RTCPeerConnection.prototype.getStats;e.RTCPeerConnection.prototype.getStats=function(){if(arguments.length>0&&arguments[0]instanceof e.MediaStreamTrack){var t,r,n,o=arguments[0];return this.getSenders().forEach((function(e){e.track===o&&(t?n=!0:t=e)})),this.getReceivers().forEach((function(e){return e.track===o&&(r?n=!0:r=e),e.track===o})),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 i.apply(this,arguments)}}}}function shimAddTrackRemoveTrackWithNative(e){e.RTCPeerConnection.prototype.getLocalStreams=function(){var e=this;return this._shimmedLocalStreams=this._shimmedLocalStreams||{},Object.keys(this._shimmedLocalStreams).map((function(t){return e._shimmedLocalStreams[t][0]}))};var t=e.RTCPeerConnection.prototype.addTrack;e.RTCPeerConnection.prototype.addTrack=function(e,r){if(!r)return t.apply(this,arguments);this._shimmedLocalStreams=this._shimmedLocalStreams||{};var 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};var r=e.RTCPeerConnection.prototype.addStream;e.RTCPeerConnection.prototype.addStream=function(e){var t=this;this._shimmedLocalStreams=this._shimmedLocalStreams||{},e.getTracks().forEach((function(e){if(t.getSenders().find((function(t){return t.track===e})))throw new DOMException("Track already exists.","InvalidAccessError")}));var n=this.getSenders();r.apply(this,arguments);var i=this.getSenders().filter((function(e){return-1===n.indexOf(e)}));this._shimmedLocalStreams[e.id]=[e].concat(i)};var 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)};var i=e.RTCPeerConnection.prototype.removeTrack;e.RTCPeerConnection.prototype.removeTrack=function(e){var t=this;return this._shimmedLocalStreams=this._shimmedLocalStreams||{},e&&Object.keys(this._shimmedLocalStreams).forEach((function(r){var n=t._shimmedLocalStreams[r].indexOf(e);-1!==n&&t._shimmedLocalStreams[r].splice(n,1),1===t._shimmedLocalStreams[r].length&&delete t._shimmedLocalStreams[r]})),i.apply(this,arguments)}}function shimAddTrackRemoveTrack(e,t){if(e.RTCPeerConnection){if(e.RTCPeerConnection.prototype.addTrack&&t.version>=65)return shimAddTrackRemoveTrackWithNative(e);var r=e.RTCPeerConnection.prototype.getLocalStreams;e.RTCPeerConnection.prototype.getLocalStreams=function(){var e=this,t=r.apply(this);return this._reverseStreams=this._reverseStreams||{},t.map((function(t){return e._reverseStreams[t.id]}))};var n=e.RTCPeerConnection.prototype.addStream;e.RTCPeerConnection.prototype.addStream=function(t){var r=this;if(this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{},t.getTracks().forEach((function(e){if(r.getSenders().find((function(t){return t.track===e})))throw new DOMException("Track already exists.","InvalidAccessError")})),!this._reverseStreams[t.id]){var i=new e.MediaStream(t.getTracks());this._streams[t.id]=i,this._reverseStreams[i.id]=t,t=i}n.apply(this,[t])};var i=e.RTCPeerConnection.prototype.removeStream;e.RTCPeerConnection.prototype.removeStream=function(e){this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{},i.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){var n=this;if("closed"===this.signalingState)throw new DOMException("The RTCPeerConnection's signalingState is 'closed'.","InvalidStateError");var i=[].slice.call(arguments,1);if(1!==i.length||!i[0].getTracks().find((function(e){return e===t})))throw new DOMException("The adapter.js addTrack polyfill only supports a single stream which is associated with the specified track.","NotSupportedError");var o=this.getSenders().find((function(e){return e.track===t}));if(o)throw new DOMException("Track already exists.","InvalidAccessError");this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{};var a=this._streams[r.id];if(a)a.addTrack(t),Promise.resolve().then((function(){n.dispatchEvent(new Event("negotiationneeded"))}));else{var s=new e.MediaStream([t]);this._streams[r.id]=s,this._reverseStreams[s.id]=r,this.addStream(s)}return this.getSenders().find((function(e){return e.track===t}))},["createOffer","createAnswer"].forEach((function(t){var r=e.RTCPeerConnection.prototype[t],n=_defineProperty({},t,(function(){var e=this,t=arguments,n=arguments.length&&"function"==typeof arguments[0];return n?r.apply(this,[function(r){var n=s(e,r);t[0].apply(null,[n])},function(e){t[1]&&t[1].apply(null,e)},arguments[2]]):r.apply(this,arguments).then((function(t){return s(e,t)}))}));e.RTCPeerConnection.prototype[t]=n[t]}));var o=e.RTCPeerConnection.prototype.setLocalDescription;e.RTCPeerConnection.prototype.setLocalDescription=function(){return arguments.length&&arguments[0].type?(arguments[0]=c(this,arguments[0]),o.apply(this,arguments)):o.apply(this,arguments)};var a=Object.getOwnPropertyDescriptor(e.RTCPeerConnection.prototype,"localDescription");Object.defineProperty(e.RTCPeerConnection.prototype,"localDescription",{get:function(){var e=a.get.apply(this);return""===e.type?e:s(this,e)}}),e.RTCPeerConnection.prototype.removeTrack=function(e){var t,r=this;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");this._streams=this._streams||{},Object.keys(this._streams).forEach((function(n){r._streams[n].getTracks().find((function(t){return e.track===t}))&&(t=r._streams[n])})),t&&(1===t.getTracks().length?this.removeStream(this._reverseStreams[t.id]):t.removeTrack(e.track),this.dispatchEvent(new Event("negotiationneeded")))}}function s(e,t){var r=t.sdp;return Object.keys(e._reverseStreams||[]).forEach((function(t){var n=e._reverseStreams[t],i=e._streams[n.id];r=r.replace(new RegExp(i.id,"g"),n.id)})),new RTCSessionDescription({type:t.type,sdp:r})}function c(e,t){var r=t.sdp;return Object.keys(e._reverseStreams||[]).forEach((function(t){var n=e._reverseStreams[t],i=e._streams[n.id];r=r.replace(new RegExp(n.id,"g"),i.id)})),new RTCSessionDescription({type:t.type,sdp:r})}}function shimPeerConnection$1(e,t){!e.RTCPeerConnection&&e.webkitRTCPeerConnection&&(e.RTCPeerConnection=e.webkitRTCPeerConnection),e.RTCPeerConnection&&t.version<53&&["setLocalDescription","setRemoteDescription","addIceCandidate"].forEach((function(t){var r=e.RTCPeerConnection.prototype[t],n=_defineProperty({},t,(function(){return arguments[0]=new("addIceCandidate"===t?e.RTCIceCandidate:e.RTCSessionDescription)(arguments[0]),r.apply(this,arguments)}));e.RTCPeerConnection.prototype[t]=n[t]}))}function fixNegotiationNeeded(e,t){wrapPeerConnectionEvent(e,"negotiationneeded",(function(e){var r=e.target;if(!(t.version<72||r.getConfiguration&&"plan-b"===r.getConfiguration().sdpSemantics)||"stable"===r.signalingState)return e}))}var chromeShim=Object.freeze(Object.defineProperty({__proto__:null,shimMediaStream:shimMediaStream,shimOnTrack:shimOnTrack$1,shimGetSendersWithDtmf:shimGetSendersWithDtmf,shimGetStats:shimGetStats,shimSenderReceiverGetStats:shimSenderReceiverGetStats,shimAddTrackRemoveTrackWithNative:shimAddTrackRemoveTrackWithNative,shimAddTrackRemoveTrack:shimAddTrackRemoveTrack,shimPeerConnection:shimPeerConnection$1,fixNegotiationNeeded:fixNegotiationNeeded,shimGetUserMedia:shimGetUserMedia$2,shimGetDisplayMedia:shimGetDisplayMedia$1},Symbol.toStringTag,{value:"Module"})),$$n=_export,call$c=functionCall,isCallable$3=isCallable$t,anObject$7=anObject$q,toString$9=toString$m,DELEGATES_TO_EXEC=function(){var e=!1,t=/[ac]/;return t.exec=function(){return e=!0,/./.exec.apply(this,arguments)},!0===t.test("abc")&&e}(),nativeTest=/./.test;$$n({target:"RegExp",proto:!0,forced:!DELEGATES_TO_EXEC},{test:function(e){var t=anObject$7(this),r=toString$9(e),n=t.exec;if(!isCallable$3(n))return call$c(nativeTest,t,r);var i=call$c(n,t,r);return null!==i&&(anObject$7(i),!0)}});var global$i=global$K,fails$j=fails$U,uncurryThis$m=functionUncurryThis,toString$8=toString$m,trim$1=stringTrim.trim,whitespaces$1=whitespaces$4,charAt$2=uncurryThis$m("".charAt),$parseFloat$1=global$i.parseFloat,Symbol$3=global$i.Symbol,ITERATOR$3=Symbol$3&&Symbol$3.iterator,FORCED$6=1/$parseFloat$1(whitespaces$1+"-0")!=-1/0||ITERATOR$3&&!fails$j((function(){$parseFloat$1(Object(ITERATOR$3))})),numberParseFloat=FORCED$6?function(e){var t=trim$1(toString$8(e)),r=$parseFloat$1(t);return 0===r&&"-"==charAt$2(t,0)?-0:r}:$parseFloat$1,$$m=_export,$parseFloat=numberParseFloat;$$m({global:!0,forced:parseFloat!=numberParseFloat},{parseFloat:numberParseFloat});var $$l=_export,NativePromiseConstructor=promiseNativeConstructor,fails$i=fails$U,getBuiltIn$2=getBuiltIn$g,isCallable$2=isCallable$t,speciesConstructor$2=speciesConstructor$4,promiseResolve=promiseResolve$2,defineBuiltIn$6=defineBuiltIn$j,NativePromisePrototype=NativePromiseConstructor&&NativePromiseConstructor.prototype,NON_GENERIC=!!NativePromiseConstructor&&fails$i((function(){NativePromisePrototype.finally.call({then:function(){}},(function(){}))}));if($$l({target:"Promise",proto:!0,real:!0,forced:NON_GENERIC},{finally:function(e){var t=speciesConstructor$2(this,getBuiltIn$2("Promise")),r=isCallable$2(e);return this.then(r?function(r){return promiseResolve(t,e()).then((function(){return r}))}:e,r?function(r){return promiseResolve(t,e()).then((function(){throw r}))}:e)}}),isCallable$2(NativePromiseConstructor)){var method=getBuiltIn$2("Promise").prototype.finally;NativePromisePrototype.finally!==method&&defineBuiltIn$6(NativePromisePrototype,"finally",method,{unsafe:!0})}function shimGetUserMedia$1(e,t){var r=e&&e.navigator,n=e&&e.MediaStreamTrack;if(r.getUserMedia=function(e,t,n){deprecated("navigator.getUserMedia","navigator.mediaDevices.getUserMedia"),r.mediaDevices.getUserMedia(e).then(t,n)},!(t.version>55&&"autoGainControl"in r.mediaDevices.getSupportedConstraints())){var i=function(e,t,r){t in e&&!(r in e)&&(e[r]=e[t],delete e[t])},o=r.mediaDevices.getUserMedia.bind(r.mediaDevices);if(r.mediaDevices.getUserMedia=function(e){return"object"===_typeof(e)&&"object"===_typeof(e.audio)&&(e=JSON.parse(JSON.stringify(e)),i(e.audio,"autoGainControl","mozAutoGainControl"),i(e.audio,"noiseSuppression","mozNoiseSuppression")),o(e)},n&&n.prototype.getSettings){var a=n.prototype.getSettings;n.prototype.getSettings=function(){var e=a.apply(this,arguments);return i(e,"mozAutoGainControl","autoGainControl"),i(e,"mozNoiseSuppression","noiseSuppression"),e}}if(n&&n.prototype.applyConstraints){var s=n.prototype.applyConstraints;n.prototype.applyConstraints=function(e){return"audio"===this.kind&&"object"===_typeof(e)&&(e=JSON.parse(JSON.stringify(e)),i(e,"autoGainControl","mozAutoGainControl"),i(e,"noiseSuppression","mozNoiseSuppression")),s.apply(this,[e])}}}}function shimGetDisplayMedia(e,t){e.navigator.mediaDevices&&"getDisplayMedia"in e.navigator.mediaDevices||e.navigator.mediaDevices&&(e.navigator.mediaDevices.getDisplayMedia=function(r){if(!r||!r.video){var n=new DOMException("getDisplayMedia without video constraints is undefined");return n.name="NotFoundError",n.code=8,Promise.reject(n)}return!0===r.video?r.video={mediaSource:t}:r.video.mediaSource=t,e.navigator.mediaDevices.getUserMedia(r)})}function shimOnTrack(e){"object"===_typeof(e)&&e.RTCTrackEvent&&"receiver"in e.RTCTrackEvent.prototype&&!("transceiver"in e.RTCTrackEvent.prototype)&&Object.defineProperty(e.RTCTrackEvent.prototype,"transceiver",{get:function(){return{receiver:this.receiver}}})}function shimPeerConnection(e,t){if("object"===_typeof(e)&&(e.RTCPeerConnection||e.mozRTCPeerConnection)){!e.RTCPeerConnection&&e.mozRTCPeerConnection&&(e.RTCPeerConnection=e.mozRTCPeerConnection),t.version<53&&["setLocalDescription","setRemoteDescription","addIceCandidate"].forEach((function(t){var r=e.RTCPeerConnection.prototype[t],n=_defineProperty({},t,(function(){return arguments[0]=new("addIceCandidate"===t?e.RTCIceCandidate:e.RTCSessionDescription)(arguments[0]),r.apply(this,arguments)}));e.RTCPeerConnection.prototype[t]=n[t]}));var 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(){var e=Array.prototype.slice.call(arguments),i=e[0],o=e[1],a=e[2];return n.apply(this,[i||null]).then((function(e){if(t.version<53&&!o)try{e.forEach((function(e){e.type=r[e.type]||e.type}))}catch(t){if("TypeError"!==t.name)throw t;e.forEach((function(t,n){e.set(n,Object.assign({},t,{type:r[t.type]||t.type}))}))}return e})).then(o,a)}}}function shimSenderGetStats(e){if("object"===_typeof(e)&&e.RTCPeerConnection&&e.RTCRtpSender&&(!e.RTCRtpSender||!("getStats"in e.RTCRtpSender.prototype))){var t=e.RTCPeerConnection.prototype.getSenders;t&&(e.RTCPeerConnection.prototype.getSenders=function(){var e=this,r=t.apply(this,[]);return r.forEach((function(t){return t._pc=e})),r});var r=e.RTCPeerConnection.prototype.addTrack;r&&(e.RTCPeerConnection.prototype.addTrack=function(){var 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 shimReceiverGetStats(e){if("object"===_typeof(e)&&e.RTCPeerConnection&&e.RTCRtpSender&&(!e.RTCRtpSender||!("getStats"in e.RTCRtpReceiver.prototype))){var t=e.RTCPeerConnection.prototype.getReceivers;t&&(e.RTCPeerConnection.prototype.getReceivers=function(){var e=this,r=t.apply(this,[]);return r.forEach((function(t){return t._pc=e})),r}),wrapPeerConnectionEvent(e,"track",(function(e){return e.receiver._pc=e.srcElement,e})),e.RTCRtpReceiver.prototype.getStats=function(){return this._pc.getStats(this.track)}}}function shimRemoveStream(e){e.RTCPeerConnection&&!("removeStream"in e.RTCPeerConnection.prototype)&&(e.RTCPeerConnection.prototype.removeStream=function(e){var t=this;deprecated("removeStream","removeTrack"),this.getSenders().forEach((function(r){r.track&&e.getTracks().includes(r.track)&&t.removeTrack(r)}))})}function shimRTCDataChannel(e){e.DataChannel&&!e.RTCDataChannel&&(e.RTCDataChannel=e.DataChannel)}function shimAddTransceiver(e){if("object"===_typeof(e)&&e.RTCPeerConnection){var t=e.RTCPeerConnection.prototype.addTransceiver;t&&(e.RTCPeerConnection.prototype.addTransceiver=function(){this.setParametersPromises=[];var e=arguments[1]&&arguments[1].sendEncodings;void 0===e&&(e=[]);var r=(e=_toConsumableArray(e)).length>0;r&&e.forEach((function(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")}));var n=t.apply(this,arguments);if(r){var i=n.sender,o=i.getParameters();(!("encodings"in o)||1===o.encodings.length&&0===Object.keys(o.encodings[0]).length)&&(o.encodings=e,i.sendEncodings=e,this.setParametersPromises.push(i.setParameters(o).then((function(){delete i.sendEncodings})).catch((function(){delete i.sendEncodings}))))}return n})}}function shimGetParameters(e){if("object"===_typeof(e)&&e.RTCRtpSender){var t=e.RTCRtpSender.prototype.getParameters;t&&(e.RTCRtpSender.prototype.getParameters=function(){var e=t.apply(this,arguments);return"encodings"in e||(e.encodings=[].concat(this.sendEncodings||[{}])),e})}}function shimCreateOffer(e){if("object"===_typeof(e)&&e.RTCPeerConnection){var t=e.RTCPeerConnection.prototype.createOffer;e.RTCPeerConnection.prototype.createOffer=function(){var e=arguments,r=this;return this.setParametersPromises&&this.setParametersPromises.length?Promise.all(this.setParametersPromises).then((function(){return t.apply(r,e)})).finally((function(){r.setParametersPromises=[]})):t.apply(this,arguments)}}}function shimCreateAnswer(e){if("object"===_typeof(e)&&e.RTCPeerConnection){var t=e.RTCPeerConnection.prototype.createAnswer;e.RTCPeerConnection.prototype.createAnswer=function(){var e=arguments,r=this;return this.setParametersPromises&&this.setParametersPromises.length?Promise.all(this.setParametersPromises).then((function(){return t.apply(r,e)})).finally((function(){r.setParametersPromises=[]})):t.apply(this,arguments)}}}var firefoxShim=Object.freeze(Object.defineProperty({__proto__:null,shimOnTrack:shimOnTrack,shimPeerConnection:shimPeerConnection,shimSenderGetStats:shimSenderGetStats,shimReceiverGetStats:shimReceiverGetStats,shimRemoveStream:shimRemoveStream,shimRTCDataChannel:shimRTCDataChannel,shimAddTransceiver:shimAddTransceiver,shimGetParameters:shimGetParameters,shimCreateOffer:shimCreateOffer,shimCreateAnswer:shimCreateAnswer,shimGetUserMedia:shimGetUserMedia$1,shimGetDisplayMedia:shimGetDisplayMedia},Symbol.toStringTag,{value:"Module"}));function shimLocalStreamsAPI(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)){var t=e.RTCPeerConnection.prototype.addTrack;e.RTCPeerConnection.prototype.addStream=function(e){var r=this;this._localStreams||(this._localStreams=[]),this._localStreams.includes(e)||this._localStreams.push(e),e.getAudioTracks().forEach((function(n){return t.call(r,n,e)})),e.getVideoTracks().forEach((function(n){return t.call(r,n,e)}))},e.RTCPeerConnection.prototype.addTrack=function(e){for(var r=this,n=arguments.length,i=new Array(n>1?n-1:0),o=1;o<n;o++)i[o-1]=arguments[o];return i&&i.forEach((function(e){r._localStreams?r._localStreams.includes(e)||r._localStreams.push(e):r._localStreams=[e]})),t.apply(this,arguments)}}"removeStream"in e.RTCPeerConnection.prototype||(e.RTCPeerConnection.prototype.removeStream=function(e){var t=this;this._localStreams||(this._localStreams=[]);var r=this._localStreams.indexOf(e);if(-1!==r){this._localStreams.splice(r,1);var n=e.getTracks();this.getSenders().forEach((function(e){n.includes(e.track)&&t.removeTrack(e)}))}})}}function shimRemoteStreamsAPI(e){if("object"===_typeof(e)&&e.RTCPeerConnection&&("getRemoteStreams"in e.RTCPeerConnection.prototype||(e.RTCPeerConnection.prototype.getRemoteStreams=function(){return this._remoteStreams?this._remoteStreams:[]}),!("onaddstream"in e.RTCPeerConnection.prototype))){Object.defineProperty(e.RTCPeerConnection.prototype,"onaddstream",{get:function(){return this._onaddstream},set:function(e){var t=this;this._onaddstream&&(this.removeEventListener("addstream",this._onaddstream),this.removeEventListener("track",this._onaddstreampoly)),this.addEventListener("addstream",this._onaddstream=e),this.addEventListener("track",this._onaddstreampoly=function(e){e.streams.forEach((function(e){if(t._remoteStreams||(t._remoteStreams=[]),!t._remoteStreams.includes(e)){t._remoteStreams.push(e);var r=new Event("addstream");r.stream=e,t.dispatchEvent(r)}}))})}});var t=e.RTCPeerConnection.prototype.setRemoteDescription;e.RTCPeerConnection.prototype.setRemoteDescription=function(){var e=this;return this._onaddstreampoly||this.addEventListener("track",this._onaddstreampoly=function(t){t.streams.forEach((function(t){if(e._remoteStreams||(e._remoteStreams=[]),!(e._remoteStreams.indexOf(t)>=0)){e._remoteStreams.push(t);var r=new Event("addstream");r.stream=t,e.dispatchEvent(r)}}))}),t.apply(e,arguments)}}}function shimCallbacksAPI(e){if("object"===_typeof(e)&&e.RTCPeerConnection){var t=e.RTCPeerConnection.prototype,r=t.createOffer,n=t.createAnswer,i=t.setLocalDescription,o=t.setRemoteDescription,a=t.addIceCandidate;t.createOffer=function(e,t){var n=arguments.length>=2?arguments[2]:arguments[0],i=r.apply(this,[n]);return t?(i.then(e,t),Promise.resolve()):i},t.createAnswer=function(e,t){var r=arguments.length>=2?arguments[2]:arguments[0],i=n.apply(this,[r]);return t?(i.then(e,t),Promise.resolve()):i};var s=function(e,t,r){var n=i.apply(this,[e]);return r?(n.then(t,r),Promise.resolve()):n};t.setLocalDescription=s,s=function(e,t,r){var n=o.apply(this,[e]);return r?(n.then(t,r),Promise.resolve()):n},t.setRemoteDescription=s,s=function(e,t,r){var n=a.apply(this,[e]);return r?(n.then(t,r),Promise.resolve()):n},t.addIceCandidate=s}}function shimGetUserMedia(e){var t=e&&e.navigator;if(t.mediaDevices&&t.mediaDevices.getUserMedia){var r=t.mediaDevices,n=r.getUserMedia.bind(r);t.mediaDevices.getUserMedia=function(e){return n(shimConstraints(e))}}!t.getUserMedia&&t.mediaDevices&&t.mediaDevices.getUserMedia&&(t.getUserMedia=function(e,r,n){t.mediaDevices.getUserMedia(e).then(r,n)}.bind(t))}function shimConstraints(e){return e&&void 0!==e.video?Object.assign({},e,{video:compactObject(e.video)}):e}function shimRTCIceServerUrls(e){if(e.RTCPeerConnection){var t=e.RTCPeerConnection;e.RTCPeerConnection=function(e,r){if(e&&e.iceServers){for(var n=[],i=0;i<e.iceServers.length;i++){var o=e.iceServers[i];!o.hasOwnProperty("urls")&&o.hasOwnProperty("url")?(deprecated("RTCIceServer.url","RTCIceServer.urls"),(o=JSON.parse(JSON.stringify(o))).urls=o.url,delete o.url,n.push(o)):n.push(e.iceServers[i])}e.iceServers=n}return new t(e,r)},e.RTCPeerConnection.prototype=t.prototype,"generateCertificate"in t&&Object.defineProperty(e.RTCPeerConnection,"generateCertificate",{get:function(){return t.generateCertificate}})}}function shimTrackEventTransceiver(e){"object"===_typeof(e)&&e.RTCTrackEvent&&"receiver"in e.RTCTrackEvent.prototype&&!("transceiver"in e.RTCTrackEvent.prototype)&&Object.defineProperty(e.RTCTrackEvent.prototype,"transceiver",{get:function(){return{receiver:this.receiver}}})}function shimCreateOfferLegacy(e){var t=e.RTCPeerConnection.prototype.createOffer;e.RTCPeerConnection.prototype.createOffer=function(e){if(e){void 0!==e.offerToReceiveAudio&&(e.offerToReceiveAudio=!!e.offerToReceiveAudio);var r=this.getTransceivers().find((function(e){return"audio"===e.receiver.track.kind}));!1===e.offerToReceiveAudio&&r?"sendrecv"===r.direction?r.setDirection?r.setDirection("sendonly"):r.direction="sendonly":"recvonly"===r.direction&&(r.setDirection?r.setDirection("inactive"):r.direction="inactive"):!0!==e.offerToReceiveAudio||r||this.addTransceiver("audio",{direction:"recvonly"}),void 0!==e.offerToReceiveVideo&&(e.offerToReceiveVideo=!!e.offerToReceiveVideo);var n=this.getTransceivers().find((function(e){return"video"===e.receiver.track.kind}));!1===e.offerToReceiveVideo&&n?"sendrecv"===n.direction?n.setDirection?n.setDirection("sendonly"):n.direction="sendonly":"recvonly"===n.direction&&(n.setDirection?n.setDirection("inactive"):n.direction="inactive"):!0!==e.offerToReceiveVideo||n||this.addTransceiver("video",{direction:"recvonly"})}return t.apply(this,arguments)}}function shimAudioContext(e){"object"!==_typeof(e)||e.AudioContext||(e.AudioContext=e.webkitAudioContext)}var safariShim=Object.freeze(Object.defineProperty({__proto__:null,shimLocalStreamsAPI:shimLocalStreamsAPI,shimRemoteStreamsAPI:shimRemoteStreamsAPI,shimCallbacksAPI:shimCallbacksAPI,shimGetUserMedia:shimGetUserMedia,shimConstraints:shimConstraints,shimRTCIceServerUrls:shimRTCIceServerUrls,shimTrackEventTransceiver:shimTrackEventTransceiver,shimCreateOfferLegacy:shimCreateOfferLegacy,shimAudioContext:shimAudioContext},Symbol.toStringTag,{value:"Module"})),$$k=_export,call$b=functionCall;$$k({target:"URL",proto:!0,enumerable:!0},{toJSON:function(){return call$b(URL.prototype.toString,this)}});var uncurryThis$l=functionUncurryThis,thisNumberValue$1=uncurryThis$l(1..valueOf),DESCRIPTORS$8=descriptors,global$h=global$K,uncurryThis$k=functionUncurryThis,isForced=isForced_1,defineBuiltIn$5=defineBuiltIn$j,hasOwn$a=hasOwnProperty_1,inheritIfRequired$1=inheritIfRequired$6,isPrototypeOf$3=objectIsPrototypeOf,isSymbol$2=isSymbol$6,toPrimitive$1=toPrimitive$3,fails$h=fails$U,getOwnPropertyNames$2=objectGetOwnPropertyNames.f,getOwnPropertyDescriptor$2=objectGetOwnPropertyDescriptor.f,defineProperty$5=objectDefineProperty.f,thisNumberValue=thisNumberValue$1,trim=stringTrim.trim,NUMBER="Number",NativeNumber=global$h[NUMBER],NumberPrototype=NativeNumber.prototype,TypeError$5=global$h.TypeError,arraySlice$6=uncurryThis$k("".slice),charCodeAt$1=uncurryThis$k("".charCodeAt),toNumeric=function(e){var t=toPrimitive$1(e,"number");return"bigint"==typeof t?t:toNumber(t)},toNumber=function(e){var t,r,n,i,o,a,s,c,u=toPrimitive$1(e,"number");if(isSymbol$2(u))throw TypeError$5("Cannot convert a Symbol value to a number");if("string"==typeof u&&u.length>2)if(u=trim(u),43===(t=charCodeAt$1(u,0))||45===t){if(88===(r=charCodeAt$1(u,2))||120===r)return NaN}else if(48===t){switch(charCodeAt$1(u,1)){case 66:case 98:n=2,i=49;break;case 79:case 111:n=8,i=55;break;default:return+u}for(a=(o=arraySlice$6(u,2)).length,s=0;s<a;s++)if((c=charCodeAt$1(o,s))<48||c>i)return NaN;return parseInt(o,n)}return+u};if(isForced(NUMBER,!NativeNumber(" 0o1")||!NativeNumber("0b1")||NativeNumber("+0x1"))){for(var key$1,NumberWrapper=function(e){var t=arguments.length<1?0:NativeNumber(toNumeric(e)),r=this;return isPrototypeOf$3(NumberPrototype,r)&&fails$h((function(){thisNumberValue(r)}))?inheritIfRequired$1(Object(t),r,NumberWrapper):t},keys$2=DESCRIPTORS$8?getOwnPropertyNames$2(NativeNumber):"MAX_VALUE,MIN_VALUE,NaN,NEGATIVE_INFINITY,POSITIVE_INFINITY,EPSILON,MAX_SAFE_INTEGER,MIN_SAFE_INTEGER,isFinite,isInteger,isNaN,isSafeInteger,parseFloat,parseInt,fromString,range".split(","),j$1=0;keys$2.length>j$1;j$1++)hasOwn$a(NativeNumber,key$1=keys$2[j$1])&&!hasOwn$a(NumberWrapper,key$1)&&defineProperty$5(NumberWrapper,key$1,getOwnPropertyDescriptor$2(NativeNumber,key$1));NumberWrapper.prototype=NumberPrototype,NumberPrototype.constructor=NumberWrapper,defineBuiltIn$5(global$h,NUMBER,NumberWrapper,{constructor:!0})}var PROPER_FUNCTION_NAME$1=functionName.PROPER,fails$g=fails$U,whitespaces=whitespaces$4,non="
",stringTrimForced=function(e){return fails$g((function(){return!!whitespaces[e]()||non[e]()!==non||PROPER_FUNCTION_NAME$1&&whitespaces[e].name!==e}))},$$j=_export,$trim=stringTrim.trim,forcedStringTrimMethod=stringTrimForced;$$j({target:"String",proto:!0,forced:forcedStringTrimMethod("trim")},{trim:function(){return $trim(this)}});var sdp$1={exports:{}};!function(e){var t={generateIdentifier:function(){return Math.random().toString(36).substr(2,10)}};t.localCName=t.generateIdentifier(),t.splitLines=function(e){return e.trim().split("\n").map((function(e){return e.trim()}))},t.splitSections=function(e){return e.split("\nm=").map((function(e,t){return(t>0?"m="+e:e).trim()+"\r\n"}))},t.getDescription=function(e){var r=t.splitSections(e);return r&&r[0]},t.getMediaSections=function(e){var r=t.splitSections(e);return r.shift(),r},t.matchPrefix=function(e,r){return t.splitLines(e).filter((function(e){return 0===e.indexOf(r)}))},t.parseCandidate=function(e){for(var t,r={foundation:(t=0===e.indexOf("a=candidate:")?e.substring(12).split(" "):e.substring(10).split(" "))[0],component:{1:"rtp",2:"rtcp"}[t[1]]||t[1],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:void 0===r[t[n]]&&(r[t[n]]=t[n+1])}return r},t.writeCandidate=function(e){var t=[];t.push(e.foundation);var r=e.component;"rtp"===r?t.push(1):"rtcp"===r?t.push(2):t.push(r),t.push(e.protocol.toUpperCase()),t.push(e.priority),t.push(e.address||e.ip),t.push(e.port);var n=e.type;return t.push("typ"),t.push(n),"host"!==n&&e.relatedAddress&&e.relatedPort&&(t.push("raddr"),t.push(e.relatedAddress),t.push("rport"),t.push(e.relatedPort)),e.tcpType&&"tcp"===e.protocol.toLowerCase()&&(t.push("tcptype"),t.push(e.tcpType)),(e.usernameFragment||e.ufrag)&&(t.push("ufrag"),t.push(e.usernameFragment||e.ufrag)),"candidate:"+t.join(" ")},t.parseIceOptions=function(e){return e.substr(14).split(" ")},t.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},t.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"},t.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]}},t.writeExtmap=function(e){return"a=extmap:"+(e.id||e.preferredId)+(e.direction&&"sendrecv"!==e.direction?"/"+e.direction:"")+" "+e.uri+"\r\n"},t.parseFmtp=function(e){for(var t,r={},n=e.substr(e.indexOf(" ")+1).split(";"),i=0;i<n.length;i++)r[(t=n[i].trim().split("="))[0].trim()]=t[1];return r},t.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){void 0!==e.parameters[t]?n.push(t+"="+e.parameters[t]):n.push(t)})),t+="a=fmtp:"+r+" "+n.join(";")+"\r\n"}return t},t.parseRtcpFb=function(e){var t=e.substr(e.indexOf(" ")+1).split(" ");return{type:t.shift(),parameter:t.join(" ")}},t.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},t.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},t.parseSsrcGroup=function(e){var t=e.substr(13).split(" ");return{semantics:t.shift(),ssrcs:t.map((function(e){return parseInt(e,10)}))}},t.getMid=function(e){var r=t.matchPrefix(e,"a=mid:")[0];if(r)return r.substr(6)},t.parseFingerprint=function(e){var t=e.substr(14).split(" ");return{algorithm:t[0].toLowerCase(),value:t[1].toUpperCase()}},t.getDtlsParameters=function(e,r){return{role:"auto",fingerprints:t.matchPrefix(e+r,"a=fingerprint:").map(t.parseFingerprint)}},t.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},t.parseCryptoLine=function(e){var t=e.substr(9).split(" ");return{tag:parseInt(t[0],10),cryptoSuite:t[1],keyParams:t[2],sessionParams:t.slice(3)}},t.writeCryptoLine=function(e){return"a=crypto:"+e.tag+" "+e.cryptoSuite+" "+("object"===_typeof(e.keyParams)?t.writeCryptoKeyParams(e.keyParams):e.keyParams)+(e.sessionParams?" "+e.sessionParams.join(" "):"")+"\r\n"},t.parseCryptoKeyParams=function(e){if(0!==e.indexOf("inline:"))return null;var t=e.substr(7).split("|");return{keyMethod:"inline",keySalt:t[0],lifeTime:t[1],mkiValue:t[2]?t[2].split(":")[0]:void 0,mkiLength:t[2]?t[2].split(":")[1]:void 0}},t.writeCryptoKeyParams=function(e){return e.keyMethod+":"+e.keySalt+(e.lifeTime?"|"+e.lifeTime:"")+(e.mkiValue&&e.mkiLength?"|"+e.mkiValue+":"+e.mkiLength:"")},t.getCryptoParameters=function(e,r){return t.matchPrefix(e+r,"a=crypto:").map(t.parseCryptoLine)},t.getIceParameters=function(e,r){var n=t.matchPrefix(e+r,"a=ice-ufrag:")[0],i=t.matchPrefix(e+r,"a=ice-pwd:")[0];return n&&i?{usernameFragment:n.substr(12),password:i.substr(10)}:null},t.writeIceParameters=function(e){var t="a=ice-ufrag:"+e.usernameFragment+"\r\na=ice-pwd:"+e.password+"\r\n";return e.iceLite&&(t+="a=ice-lite\r\n"),t},t.parseRtpParameters=function(e){for(var r={codecs:[],headerExtensions:[],fecMechanisms:[],rtcp:[]},n=t.splitLines(e)[0].split(" "),i=3;i<n.length;i++){var o=n[i],a=t.matchPrefix(e,"a=rtpmap:"+o+" ")[0];if(a){var s=t.parseRtpMap(a),c=t.matchPrefix(e,"a=fmtp:"+o+" ");switch(s.parameters=c.length?t.parseFmtp(c[0]):{},s.rtcpFeedback=t.matchPrefix(e,"a=rtcp-fb:"+o+" ").map(t.parseRtcpFb),r.codecs.push(s),s.name.toUpperCase()){case"RED":case"ULPFEC":r.fecMechanisms.push(s.name.toUpperCase())}}}return t.matchPrefix(e,"a=extmap:").forEach((function(e){r.headerExtensions.push(t.parseExtmap(e))})),r},t.writeRtpDescription=function(e,r){var n="";n+="m="+e+" ",n+=r.codecs.length>0?"9":"0",n+=" UDP/TLS/RTP/SAVPF ",n+=r.codecs.map((function(e){return void 0!==e.preferredPayloadType?e.preferredPayloadType:e.payloadType})).join(" ")+"\r\n",n+="c=IN IP4 0.0.0.0\r\n",n+="a=rtcp:9 IN IP4 0.0.0.0\r\n",r.codecs.forEach((function(e){n+=t.writeRtpMap(e),n+=t.writeFmtp(e),n+=t.writeRtcpFb(e)}));var i=0;return r.codecs.forEach((function(e){e.maxptime>i&&(i=e.maxptime)})),i>0&&(n+="a=maxptime:"+i+"\r\n"),r.headerExtensions&&r.headerExtensions.forEach((function(e){n+=t.writeExtmap(e)})),n},t.parseRtpEncodingParameters=function(e){var r,n=[],i=t.parseRtpParameters(e),o=-1!==i.fecMechanisms.indexOf("RED"),a=-1!==i.fecMechanisms.indexOf("ULPFEC"),s=t.matchPrefix(e,"a=ssrc:").map((function(e){return t.parseSsrcMedia(e)})).filter((function(e){return"cname"===e.attribute})),c=s.length>0&&s[0].ssrc,u=t.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&&(r=u[0][1]),i.codecs.forEach((function(e){if("RTX"===e.name.toUpperCase()&&e.parameters.apt){var t={ssrc:c,codecPayloadType:parseInt(e.parameters.apt,10)};c&&r&&(t.rtx={ssrc:r}),n.push(t),o&&((t=JSON.parse(JSON.stringify(t))).fec={ssrc:c,mechanism:a?"red+ulpfec":"red"},n.push(t))}})),0===n.length&&c&&n.push({ssrc:c});var l=t.matchPrefix(e,"b=");return l.length&&(l=0===l[0].indexOf("b=TIAS:")?parseInt(l[0].substr(7),10):0===l[0].indexOf("b=AS:")?1e3*parseInt(l[0].substr(5),10)*.95-16e3:void 0,n.forEach((function(e){e.maxBitrate=l}))),n},t.parseRtcpParameters=function(e){var r={},n=t.matchPrefix(e,"a=ssrc:").map((function(e){return t.parseSsrcMedia(e)})).filter((function(e){return"cname"===e.attribute}))[0];n&&(r.cname=n.value,r.ssrc=n.ssrc);var i=t.matchPrefix(e,"a=rtcp-rsize");r.reducedSize=i.length>0,r.compound=0===i.length;var o=t.matchPrefix(e,"a=rtcp-mux");return r.mux=o.length>0,r},t.writeRtcpParameters=function(e){var t="";return e.reducedSize&&(t+="a=rtcp-rsize\r\n"),e.mux&&(t+="a=rtcp-mux\r\n"),void 0!==e.ssrc&&e.cname&&(t+="a=ssrc:"+e.ssrc+" cname:"+e.cname+"\r\n"),t},t.parseMsid=function(e){var r,n=t.matchPrefix(e,"a=msid:");if(1===n.length)return{stream:(r=n[0].substr(7).split(" "))[0],track:r[1]};var i=t.matchPrefix(e,"a=ssrc:").map((function(e){return t.parseSsrcMedia(e)})).filter((function(e){return"msid"===e.attribute}));return i.length>0?{stream:(r=i[0].value.split(" "))[0],track:r[1]}:void 0},t.parseSctpDescription=function(e){var r,n=t.parseMLine(e),i=t.matchPrefix(e,"a=max-message-size:");i.length>0&&(r=parseInt(i[0].substr(19),10)),isNaN(r)&&(r=65536);var o=t.matchPrefix(e,"a=sctp-port:");if(o.length>0)return{port:parseInt(o[0].substr(12),10),protocol:n.fmt,maxMessageSize:r};var a=t.matchPrefix(e,"a=sctpmap:");if(a.length>0){var s=a[0].substr(10).split(" ");return{port:parseInt(s[0],10),protocol:s[1],maxMessageSize:r}}},t.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("")},t.generateSessionId=function(){return Math.random().toString().substr(2,21)},t.writeSessionBoilerplate=function(e,r,n){var i=void 0!==r?r:2;return"v=0\r\no="+(n||"thisisadapterortc")+" "+(e||t.generateSessionId())+" "+i+" IN IP4 127.0.0.1\r\ns=-\r\nt=0 0\r\n"},t.getDirection=function(e,r){for(var n=t.splitLines(e),i=0;i<n.length;i++)switch(n[i]){case"a=sendrecv":case"a=sendonly":case"a=recvonly":case"a=inactive":return n[i].substr(2)}return r?t.getDirection(r):"sendrecv"},t.getKind=function(e){return t.splitLines(e)[0].split(" ")[0].substr(2)},t.isRejected=function(e){return"0"===e.split(" ",2)[1]},t.parseMLine=function(e){var r=t.splitLines(e)[0].substr(2).split(" ");return{kind:r[0],port:parseInt(r[1],10),protocol:r[2],fmt:r.slice(3).join(" ")}},t.parseOLine=function(e){var r=t.matchPrefix(e,"o=")[0].substr(2).split(" ");return{username:r[0],sessionId:r[1],sessionVersion:parseInt(r[2],10),netType:r[3],addressType:r[4],address:r[5]}},t.isValidSDP=function(e){if("string"!=typeof e||0===e.length)return!1;for(var r=t.splitLines(e),n=0;n<r.length;n++)if(r[n].length<2||"="!==r[n].charAt(1))return!1;return!0},e.exports=t}(sdp$1);var SDPUtils=sdp$1.exports,sdp=_mergeNamespaces({__proto__:null,default:SDPUtils},[sdp$1.exports]);function shimRTCIceCandidate(e){if(!(!e.RTCIceCandidate||e.RTCIceCandidate&&"foundation"in e.RTCIceCandidate.prototype)){var t=e.RTCIceCandidate;e.RTCIceCandidate=function(e){if("object"===_typeof(e)&&e.candidate&&0===e.candidate.indexOf("a=")&&((e=JSON.parse(JSON.stringify(e))).candidate=e.candidate.substr(2)),e.candidate&&e.candidate.length){var r=new t(e),n=SDPUtils.parseCandidate(e.candidate),i=Object.assign(r,n);return i.toJSON=function(){return{candidate:i.candidate,sdpMid:i.sdpMid,sdpMLineIndex:i.sdpMLineIndex,usernameFragment:i.usernameFragment}},i}return new t(e)},e.RTCIceCandidate.prototype=t.prototype,wrapPeerConnectionEvent(e,"icecandidate",(function(t){return t.candidate&&Object.defineProperty(t,"candidate",{value:new e.RTCIceCandidate(t.candidate),writable:"false"}),t}))}}function shimRTCIceCandidateRelayProtocol(e){!e.RTCIceCandidate||e.RTCIceCandidate&&"relayProtocol"in e.RTCIceCandidate.prototype||wrapPeerConnectionEvent(e,"icecandidate",(function(e){if(e.candidate){var t=SDPUtils.parseCandidate(e.candidate.candidate);"relay"===t.type&&(e.candidate.relayProtocol={0:"tls",1:"tcp",2:"udp"}[t.priority>>24])}return e}))}function shimMaxMessageSize(e,t){if(e.RTCPeerConnection){"sctp"in e.RTCPeerConnection.prototype||Object.defineProperty(e.RTCPeerConnection.prototype,"sctp",{get:function(){return void 0===this._sctp?null:this._sctp}});var r=function(e){if(!e||!e.sdp)return!1;var t=SDPUtils.splitSections(e.sdp);return t.shift(),t.some((function(e){var t=SDPUtils.parseMLine(e);return t&&"application"===t.kind&&-1!==t.protocol.indexOf("SCTP")}))},n=function(e){var t=e.sdp.match(/mozilla...THIS_IS_SDPARTA-(\d+)/);if(null===t||t.length<2)return-1;var r=parseInt(t[1],10);return r!=r?-1:r},i=function(e){var r=65536;return"firefox"===t.browser&&(r=t.version<57?-1===e?16384:2147483637:t.version<60?57===t.version?65535:65536:2147483637),r},o=function(e,r){var n=65536;"firefox"===t.browser&&57===t.version&&(n=65535);var i=SDPUtils.matchPrefix(e.sdp,"a=max-message-size:");return i.length>0?n=parseInt(i[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){var e=this.getConfiguration(),s=e.sdpSemantics;"plan-b"===s&&Object.defineProperty(this,"sctp",{get:function(){return void 0===this._sctp?null:this._sctp},enumerable:!0,configurable:!0})}if(r(arguments[0])){var c,u=n(arguments[0]),l=i(u),d=o(arguments[0],u);c=0===l&&0===d?Number.POSITIVE_INFINITY:0===l||0===d?Math.max(l,d):Math.min(l,d);var p={};Object.defineProperty(p,"maxMessageSize",{get:function(){return c}}),this._sctp=p}return a.apply(this,arguments)}}}function shimSendThrowTypeError(e){if(e.RTCPeerConnection&&"createDataChannel"in e.RTCPeerConnection.prototype){var t=e.RTCPeerConnection.prototype.createDataChannel;e.RTCPeerConnection.prototype.createDataChannel=function(){var e=t.apply(this,arguments);return r(e,this),e},wrapPeerConnectionEvent(e,"datachannel",(function(e){return r(e.channel,e.target),e}))}function r(e,t){var r=e.send;e.send=function(){var n=arguments[0],i=n.length||n.size||n.byteLength;if("open"===e.readyState&&t.sctp&&i>t.sctp.maxMessageSize)throw new TypeError("Message too large (can send a maximum of "+t.sctp.maxMessageSize+" bytes)");return r.apply(e,arguments)}}}function shimConnectionState(e){if(e.RTCPeerConnection&&!("connectionState"in e.RTCPeerConnection.prototype)){var t=e.RTCPeerConnection.prototype;Object.defineProperty(t,"connectionState",{get:function(){return{completed:"connected",checking:"connecting"}[this.iceConnectionState]||this.iceConnectionState},enumerable:!0,configurable:!0}),Object.defineProperty(t,"onconnectionstatechange",{get:function(){return this._onconnectionstatechange||null},set:function(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((function(e){var r=t[e];t[e]=function(){return this._connectionstatechangepoly||(this._connectionstatechangepoly=function(e){var t=e.target;if(t._lastConnectionState!==t.connectionState){t._lastConnectionState=t.connectionState;var r=new Event("connectionstatechange",e);t.dispatchEvent(r)}return e},this.addEventListener("iceconnectionstatechange",this._connectionstatechangepoly)),r.apply(this,arguments)}}))}}function removeExtmapAllowMixed(e,t){if(e.RTCPeerConnection&&!("chrome"===t.browser&&t.version>=71||"safari"===t.browser&&t.version>=605)){var r=e.RTCPeerConnection.prototype.setRemoteDescription;e.RTCPeerConnection.prototype.setRemoteDescription=function(t){if(t&&t.sdp&&-1!==t.sdp.indexOf("\na=extmap-allow-mixed")){var n=t.sdp.split("\n").filter((function(e){return"a=extmap-allow-mixed"!==e.trim()})).join("\n");e.RTCSessionDescription&&t instanceof e.RTCSessionDescription?arguments[0]=new e.RTCSessionDescription({type:t.type,sdp:n}):t.sdp=n}return r.apply(this,arguments)}}}function shimAddIceCandidateNullOrEmpty(e,t){if(e.RTCPeerConnection&&e.RTCPeerConnection.prototype){var r=e.RTCPeerConnection.prototype.addIceCandidate;r&&0!==r.length&&(e.RTCPeerConnection.prototype.addIceCandidate=function(){return arguments[0]?("chrome"===t.browser&&t.version<78||"firefox"===t.browser&&t.version<68||"safari"===t.browser)&&arguments[0]&&""===arguments[0].candidate?Promise.resolve():r.apply(this,arguments):(arguments[1]&&arguments[1].apply(null),Promise.resolve())})}}function shimParameterlessSetLocalDescription(e,t){if(e.RTCPeerConnection&&e.RTCPeerConnection.prototype){var r=e.RTCPeerConnection.prototype.setLocalDescription;r&&0!==r.length&&(e.RTCPeerConnection.prototype.setLocalDescription=function(){var e=this,t=arguments[0]||{};if("object"!==_typeof(t)||t.type&&t.sdp)return r.apply(this,arguments);if(!(t={type:t.type,sdp:t.sdp}).type)switch(this.signalingState){case"stable":case"have-local-offer":case"have-remote-pranswer":t.type="offer";break;default:t.type="answer"}if(t.sdp||"offer"!==t.type&&"answer"!==t.type)return r.apply(this,[t]);var n="offer"===t.type?this.createOffer:this.createAnswer;return n.apply(this).then((function(t){return r.apply(e,[t])}))})}}var commonShim=Object.freeze(Object.defineProperty({__proto__:null,shimRTCIceCandidate:shimRTCIceCandidate,shimRTCIceCandidateRelayProtocol:shimRTCIceCandidateRelayProtocol,shimMaxMessageSize:shimMaxMessageSize,shimSendThrowTypeError:shimSendThrowTypeError,shimConnectionState:shimConnectionState,removeExtmapAllowMixed:removeExtmapAllowMixed,shimAddIceCandidateNullOrEmpty:shimAddIceCandidateNullOrEmpty,shimParameterlessSetLocalDescription:shimParameterlessSetLocalDescription},Symbol.toStringTag,{value:"Module"}));function adapterFactory(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.window,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{shimChrome:!0,shimFirefox:!0,shimSafari:!0},n=log$2,i=detectBrowser(t),o={browserDetails:i,commonShim:commonShim,extractVersion:extractVersion,disableLog:disableLog,disableWarnings:disableWarnings,sdp:sdp};switch(i.browser){case"chrome":if(!chromeShim||!shimPeerConnection$1||!r.shimChrome)return n("Chrome shim is not included in this adapter release."),o;if(null===i.version)return n("Chrome shim can not determine version, not shimming."),o;n("adapter.js shimming chrome."),o.browserShim=chromeShim,shimAddIceCandidateNullOrEmpty(t,i),shimParameterlessSetLocalDescription(t),shimGetUserMedia$2(t,i),shimMediaStream(t),shimPeerConnection$1(t,i),shimOnTrack$1(t),shimAddTrackRemoveTrack(t,i),shimGetSendersWithDtmf(t),shimGetStats(t),shimSenderReceiverGetStats(t),fixNegotiationNeeded(t,i),shimRTCIceCandidate(t),shimRTCIceCandidateRelayProtocol(t),shimConnectionState(t),shimMaxMessageSize(t,i),shimSendThrowTypeError(t),removeExtmapAllowMixed(t,i);break;case"firefox":if(!firefoxShim||!shimPeerConnection||!r.shimFirefox)return n("Firefox shim is not included in this adapter release."),o;n("adapter.js shimming firefox."),o.browserShim=firefoxShim,shimAddIceCandidateNullOrEmpty(t,i),shimParameterlessSetLocalDescription(t),shimGetUserMedia$1(t,i),shimPeerConnection(t,i),shimOnTrack(t),shimRemoveStream(t),shimSenderGetStats(t),shimReceiverGetStats(t),shimRTCDataChannel(t),shimAddTransceiver(t),shimGetParameters(t),shimCreateOffer(t),shimCreateAnswer(t),shimRTCIceCandidate(t),shimConnectionState(t),shimMaxMessageSize(t,i),shimSendThrowTypeError(t);break;case"safari":if(!safariShim||!r.shimSafari)return n("Safari shim is not included in this adapter release."),o;n("adapter.js shimming safari."),o.browserShim=safariShim,shimAddIceCandidateNullOrEmpty(t,i),shimParameterlessSetLocalDescription(t),shimRTCIceServerUrls(t),shimCreateOfferLegacy(t),shimCallbacksAPI(t),shimLocalStreamsAPI(t),shimRemoteStreamsAPI(t),shimTrackEventTransceiver(t),shimGetUserMedia(t),shimAudioContext(t),shimRTCIceCandidate(t),shimRTCIceCandidateRelayProtocol(t),shimMaxMessageSize(t,i),shimSendThrowTypeError(t),removeExtmapAllowMixed(t,i);break;default:n("Unsupported browser!")}return o}adapterFactory({window:"undefined"==typeof window?void 0:window});var arraySlice$5=arraySliceSimple,floor$5=Math.floor,mergeSort=function(e,t){var r=e.length,n=floor$5(r/2);return r<8?insertionSort(e,t):merge(e,mergeSort(arraySlice$5(e,0,n),t),mergeSort(arraySlice$5(e,n),t),t)},insertionSort=function(e,t){for(var r,n,i=e.length,o=1;o<i;){for(n=o,r=e[o];n&&t(e[n-1],r)>0;)e[n]=e[--n];n!==o++&&(e[n]=r)}return e},merge=function(e,t,r,n){for(var i=t.length,o=r.length,a=0,s=0;a<i||s<o;)e[a+s]=a<i&&s<o?n(t[a],r[s])<=0?t[a++]:r[s++]:a<i?t[a++]:r[s++];return e},arraySort$1=mergeSort,userAgent$2=engineUserAgent,firefox=userAgent$2.match(/firefox\/(\d+)/i),engineFfVersion=!!firefox&&+firefox[1],UA=engineUserAgent,engineIsIeOrEdge=/MSIE|Trident/.test(UA),userAgent$1=engineUserAgent,webkit=userAgent$1.match(/AppleWebKit\/(\d+)\./),engineWebkitVersion=!!webkit&&+webkit[1],$$i=_export,uncurryThis$j=functionUncurryThis,aCallable$2=aCallable$b,toObject$7=toObject$i,lengthOfArrayLike$c=lengthOfArrayLike$m,deletePropertyOrThrow$2=deletePropertyOrThrow$4,toString$7=toString$m,fails$f=fails$U,internalSort$1=arraySort$1,arrayMethodIsStrict$1=arrayMethodIsStrict$5,FF$1=engineFfVersion,IE_OR_EDGE$1=engineIsIeOrEdge,V8$1=engineV8Version,WEBKIT$1=engineWebkitVersion,test=[],nativeSort$1=uncurryThis$j(test.sort),push$6=uncurryThis$j(test.push),FAILS_ON_UNDEFINED=fails$f((function(){test.sort(void 0)})),FAILS_ON_NULL=fails$f((function(){test.sort(null)})),STRICT_METHOD$1=arrayMethodIsStrict$1("sort"),STABLE_SORT$1=!fails$f((function(){if(V8$1)return V8$1<70;if(!(FF$1&&FF$1>3)){if(IE_OR_EDGE$1)return!0;if(WEBKIT$1)return WEBKIT$1<603;var e,t,r,n,i="";for(e=65;e<76;e++){switch(t=String.fromCharCode(e),e){case 66:case 69:case 70:case 72:r=3;break;case 68:case 71:r=4;break;default:r=2}for(n=0;n<47;n++)test.push({k:t+n,v:r})}for(test.sort((function(e,t){return t.v-e.v})),n=0;n<test.length;n++)t=test[n].k.charAt(0),i.charAt(i.length-1)!==t&&(i+=t);return"DGBEFHACIJK"!==i}})),FORCED$5=FAILS_ON_UNDEFINED||!FAILS_ON_NULL||!STRICT_METHOD$1||!STABLE_SORT$1,getSortCompare$1=function(e){return function(t,r){return void 0===r?-1:void 0===t?1:void 0!==e?+e(t,r)||0:toString$7(t)>toString$7(r)?1:-1}};$$i({target:"Array",proto:!0,forced:FORCED$5},{sort:function(e){void 0!==e&&aCallable$2(e);var t=toObject$7(this);if(STABLE_SORT$1)return void 0===e?nativeSort$1(t):nativeSort$1(t,e);var r,n,i=[],o=lengthOfArrayLike$c(t);for(n=0;n<o;n++)n in t&&push$6(i,t[n]);for(internalSort$1(i,getSortCompare$1(e)),r=lengthOfArrayLike$c(i),n=0;n<r;)t[n]=i[n++];for(;n<o;)deletePropertyOrThrow$2(t,n++);return t}});var NAME$1,Constructor,Prototype,typedArrayConstructor={exports:{}},arrayBufferBasicDetection="undefined"!=typeof ArrayBuffer&&"undefined"!=typeof DataView,NATIVE_ARRAY_BUFFER$1=arrayBufferBasicDetection,DESCRIPTORS$7=descriptors,global$g=global$K,isCallable$1=isCallable$t,isObject$8=isObject$s,hasOwn$9=hasOwnProperty_1,classof$4=classof$i,tryToString$1=tryToString$7,createNonEnumerableProperty$2=createNonEnumerableProperty$c,defineBuiltIn$4=defineBuiltIn$j,defineProperty$4=objectDefineProperty.f,isPrototypeOf$2=objectIsPrototypeOf,getPrototypeOf$3=objectGetPrototypeOf,setPrototypeOf$2=objectSetPrototypeOf,wellKnownSymbol$6=wellKnownSymbol$u,uid$1=uid$5,InternalStateModule$6=internalState,enforceInternalState$2=InternalStateModule$6.enforce,getInternalState$3=InternalStateModule$6.get,Int8Array$4=global$g.Int8Array,Int8ArrayPrototype$1=Int8Array$4&&Int8Array$4.prototype,Uint8ClampedArray$1=global$g.Uint8ClampedArray,Uint8ClampedArrayPrototype=Uint8ClampedArray$1&&Uint8ClampedArray$1.prototype,TypedArray$1=Int8Array$4&&getPrototypeOf$3(Int8Array$4),TypedArrayPrototype$2=Int8ArrayPrototype$1&&getPrototypeOf$3(Int8ArrayPrototype$1),ObjectPrototype$2=Object.prototype,TypeError$4=global$g.TypeError,TO_STRING_TAG=wellKnownSymbol$6("toStringTag"),TYPED_ARRAY_TAG$1=uid$1("TYPED_ARRAY_TAG"),TYPED_ARRAY_CONSTRUCTOR="TypedArrayConstructor",NATIVE_ARRAY_BUFFER_VIEWS$2=NATIVE_ARRAY_BUFFER$1&&!!setPrototypeOf$2&&"Opera"!==classof$4(global$g.opera),TYPED_ARRAY_TAG_REQUIRED=!1,TypedArrayConstructorsList={Int8Array:1,Uint8Array:1,Uint8ClampedArray:1,Int16Array:2,Uint16Array:2,Int32Array:4,Uint32Array:4,Float32Array:4,Float64Array:8},BigIntArrayConstructorsList={BigInt64Array:8,BigUint64Array:8},isView=function(e){if(!isObject$8(e))return!1;var t=classof$4(e);return"DataView"===t||hasOwn$9(TypedArrayConstructorsList,t)||hasOwn$9(BigIntArrayConstructorsList,t)},getTypedArrayConstructor$4=function(e){var t=getPrototypeOf$3(e);if(isObject$8(t)){var r=getInternalState$3(t);return r&&hasOwn$9(r,TYPED_ARRAY_CONSTRUCTOR)?r[TYPED_ARRAY_CONSTRUCTOR]:getTypedArrayConstructor$4(t)}},isTypedArray$3=function(e){if(!isObject$8(e))return!1;var t=classof$4(e);return hasOwn$9(TypedArrayConstructorsList,t)||hasOwn$9(BigIntArrayConstructorsList,t)},aTypedArray$r=function(e){if(isTypedArray$3(e))return e;throw TypeError$4("Target is not a typed array")},aTypedArrayConstructor$3=function(e){if(isCallable$1(e)&&(!setPrototypeOf$2||isPrototypeOf$2(TypedArray$1,e)))return e;throw TypeError$4(tryToString$1(e)+" is not a typed array constructor")},exportTypedArrayMethod$s=function(e,t,r,n){if(DESCRIPTORS$7){if(r)for(var i in TypedArrayConstructorsList){var o=global$g[i];if(o&&hasOwn$9(o.prototype,e))try{delete o.prototype[e]}catch(r){try{o.prototype[e]=t}catch(e){}}}TypedArrayPrototype$2[e]&&!r||defineBuiltIn$4(TypedArrayPrototype$2,e,r?t:NATIVE_ARRAY_BUFFER_VIEWS$2&&Int8ArrayPrototype$1[e]||t,n)}},exportTypedArrayStaticMethod=function(e,t,r){var n,i;if(DESCRIPTORS$7){if(setPrototypeOf$2){if(r)for(n in TypedArrayConstructorsList)if((i=global$g[n])&&hasOwn$9(i,e))try{delete i[e]}catch(e){}if(TypedArray$1[e]&&!r)return;try{return defineBuiltIn$4(TypedArray$1,e,r?t:NATIVE_ARRAY_BUFFER_VIEWS$2&&TypedArray$1[e]||t)}catch(e){}}for(n in TypedArrayConstructorsList)!(i=global$g[n])||i[e]&&!r||defineBuiltIn$4(i,e,t)}};for(NAME$1 in TypedArrayConstructorsList)(Prototype=(Constructor=global$g[NAME$1])&&Constructor.prototype)?enforceInternalState$2(Prototype)[TYPED_ARRAY_CONSTRUCTOR]=Constructor:NATIVE_ARRAY_BUFFER_VIEWS$2=!1;for(NAME$1 in BigIntArrayConstructorsList)(Prototype=(Constructor=global$g[NAME$1])&&Constructor.prototype)&&(enforceInternalState$2(Prototype)[TYPED_ARRAY_CONSTRUCTOR]=Constructor);if((!NATIVE_ARRAY_BUFFER_VIEWS$2||!isCallable$1(TypedArray$1)||TypedArray$1===Function.prototype)&&(TypedArray$1=function(){throw TypeError$4("Incorrect invocation")},NATIVE_ARRAY_BUFFER_VIEWS$2))for(NAME$1 in TypedArrayConstructorsList)global$g[NAME$1]&&setPrototypeOf$2(global$g[NAME$1],TypedArray$1);if((!NATIVE_ARRAY_BUFFER_VIEWS$2||!TypedArrayPrototype$2||TypedArrayPrototype$2===ObjectPrototype$2)&&(TypedArrayPrototype$2=TypedArray$1.prototype,NATIVE_ARRAY_BUFFER_VIEWS$2))for(NAME$1 in TypedArrayConstructorsList)global$g[NAME$1]&&setPrototypeOf$2(global$g[NAME$1].prototype,TypedArrayPrototype$2);if(NATIVE_ARRAY_BUFFER_VIEWS$2&&getPrototypeOf$3(Uint8ClampedArrayPrototype)!==TypedArrayPrototype$2&&setPrototypeOf$2(Uint8ClampedArrayPrototype,TypedArrayPrototype$2),DESCRIPTORS$7&&!hasOwn$9(TypedArrayPrototype$2,TO_STRING_TAG))for(NAME$1 in TYPED_ARRAY_TAG_REQUIRED=!0,defineProperty$4(TypedArrayPrototype$2,TO_STRING_TAG,{get:function(){return isObject$8(this)?this[TYPED_ARRAY_TAG$1]:void 0}}),TypedArrayConstructorsList)global$g[NAME$1]&&createNonEnumerableProperty$2(global$g[NAME$1],TYPED_ARRAY_TAG$1,NAME$1);var arrayBufferViewCore={NATIVE_ARRAY_BUFFER_VIEWS:NATIVE_ARRAY_BUFFER_VIEWS$2,TYPED_ARRAY_TAG:TYPED_ARRAY_TAG_REQUIRED&&TYPED_ARRAY_TAG$1,aTypedArray:aTypedArray$r,aTypedArrayConstructor:aTypedArrayConstructor$3,exportTypedArrayMethod:exportTypedArrayMethod$s,exportTypedArrayStaticMethod:exportTypedArrayStaticMethod,getTypedArrayConstructor:getTypedArrayConstructor$4,isView:isView,isTypedArray:isTypedArray$3,TypedArray:TypedArray$1,TypedArrayPrototype:TypedArrayPrototype$2},global$f=global$K,fails$e=fails$U,checkCorrectnessOfIteration$1=checkCorrectnessOfIteration$4,NATIVE_ARRAY_BUFFER_VIEWS$1=arrayBufferViewCore.NATIVE_ARRAY_BUFFER_VIEWS,ArrayBuffer$2=global$f.ArrayBuffer,Int8Array$3=global$f.Int8Array,typedArrayConstructorsRequireWrappers=!NATIVE_ARRAY_BUFFER_VIEWS$1||!fails$e((function(){Int8Array$3(1)}))||!fails$e((function(){new Int8Array$3(-1)}))||!checkCorrectnessOfIteration$1((function(e){new Int8Array$3,new Int8Array$3(null),new Int8Array$3(1.5),new Int8Array$3(e)}),!0)||fails$e((function(){return 1!==new Int8Array$3(new ArrayBuffer$2(2),1,void 0).length})),toIntegerOrInfinity$7=toIntegerOrInfinity$d,toLength$5=toLength$a,$RangeError$5=RangeError,toIndex$2=function(e){if(void 0===e)return 0;var t=toIntegerOrInfinity$7(e),r=toLength$5(t);if(t!==r)throw $RangeError$5("Wrong length or index");return r},$Array$1=Array,abs=Math.abs,pow$1=Math.pow,floor$4=Math.floor,log$1=Math.log,LN2=Math.LN2,pack=function(e,t,r){var n,i,o,a=$Array$1(r),s=8*r-t-1,c=(1<<s)-1,u=c>>1,l=23===t?pow$1(2,-24)-pow$1(2,-77):0,d=e<0||0===e&&1/e<0?1:0,p=0;for((e=abs(e))!=e||e===1/0?(i=e!=e?1:0,n=c):(n=floor$4(log$1(e)/LN2),e*(o=pow$1(2,-n))<1&&(n--,o*=2),(e+=n+u>=1?l/o:l*pow$1(2,1-u))*o>=2&&(n++,o/=2),n+u>=c?(i=0,n=c):n+u>=1?(i=(e*o-1)*pow$1(2,t),n+=u):(i=e*pow$1(2,u-1)*pow$1(2,t),n=0));t>=8;)a[p++]=255&i,i/=256,t-=8;for(n=n<<t|i,s+=t;s>0;)a[p++]=255&n,n/=256,s-=8;return a[--p]|=128*d,a},unpack=function(e,t){var r,n=e.length,i=8*n-t-1,o=(1<<i)-1,a=o>>1,s=i-7,c=n-1,u=e[c--],l=127&u;for(u>>=7;s>0;)l=256*l+e[c--],s-=8;for(r=l&(1<<-s)-1,l>>=-s,s+=t;s>0;)r=256*r+e[c--],s-=8;if(0===l)l=1-a;else{if(l===o)return r?NaN:u?-1/0:1/0;r+=pow$1(2,t),l-=a}return(u?-1:1)*r*pow$1(2,l-t)},ieee754={pack:pack,unpack:unpack},toObject$6=toObject$i,toAbsoluteIndex$1=toAbsoluteIndex$6,lengthOfArrayLike$b=lengthOfArrayLike$m,arrayFill$1=function(e){for(var t=toObject$6(this),r=lengthOfArrayLike$b(t),n=arguments.length,i=toAbsoluteIndex$1(n>1?arguments[1]:void 0,r),o=n>2?arguments[2]:void 0,a=void 0===o?r:toAbsoluteIndex$1(o,r);a>i;)t[i++]=e;return t},global$e=global$K,uncurryThis$i=functionUncurryThis,DESCRIPTORS$6=descriptors,NATIVE_ARRAY_BUFFER=arrayBufferBasicDetection,FunctionName=functionName,createNonEnumerableProperty$1=createNonEnumerableProperty$c,defineBuiltIns$3=defineBuiltIns$5,fails$d=fails$U,anInstance$4=anInstance$a,toIntegerOrInfinity$6=toIntegerOrInfinity$d,toLength$4=toLength$a,toIndex$1=toIndex$2,IEEE754=ieee754,getPrototypeOf$2=objectGetPrototypeOf,setPrototypeOf$1=objectSetPrototypeOf,getOwnPropertyNames$1=objectGetOwnPropertyNames.f,defineProperty$3=objectDefineProperty.f,arrayFill=arrayFill$1,arraySlice$4=arraySliceSimple,setToStringTag$4=setToStringTag$a,InternalStateModule$5=internalState,PROPER_FUNCTION_NAME=FunctionName.PROPER,CONFIGURABLE_FUNCTION_NAME=FunctionName.CONFIGURABLE,getInternalState$2=InternalStateModule$5.get,setInternalState$5=InternalStateModule$5.set,ARRAY_BUFFER="ArrayBuffer",DATA_VIEW="DataView",PROTOTYPE$1="prototype",WRONG_LENGTH$1="Wrong length",WRONG_INDEX="Wrong index",NativeArrayBuffer=global$e[ARRAY_BUFFER],$ArrayBuffer=NativeArrayBuffer,ArrayBufferPrototype$1=$ArrayBuffer&&$ArrayBuffer[PROTOTYPE$1],$DataView=global$e[DATA_VIEW],DataViewPrototype=$DataView&&$DataView[PROTOTYPE$1],ObjectPrototype$1=Object.prototype,Array$1=global$e.Array,RangeError$3=global$e.RangeError,fill=uncurryThis$i(arrayFill),reverse=uncurryThis$i([].reverse),packIEEE754=IEEE754.pack,unpackIEEE754=IEEE754.unpack,packInt8=function(e){return[255&e]},packInt16=function(e){return[255&e,e>>8&255]},packInt32=function(e){return[255&e,e>>8&255,e>>16&255,e>>24&255]},unpackInt32=function(e){return e[3]<<24|e[2]<<16|e[1]<<8|e[0]},packFloat32=function(e){return packIEEE754(e,23,4)},packFloat64=function(e){return packIEEE754(e,52,8)},addGetter$1=function(e,t){defineProperty$3(e[PROTOTYPE$1],t,{get:function(){return getInternalState$2(this)[t]}})},get$1=function(e,t,r,n){var i=toIndex$1(r),o=getInternalState$2(e);if(i+t>o.byteLength)throw RangeError$3(WRONG_INDEX);var a=getInternalState$2(o.buffer).bytes,s=i+o.byteOffset,c=arraySlice$4(a,s,s+t);return n?c:reverse(c)},set$1=function(e,t,r,n,i,o){var a=toIndex$1(r),s=getInternalState$2(e);if(a+t>s.byteLength)throw RangeError$3(WRONG_INDEX);for(var c=getInternalState$2(s.buffer).bytes,u=a+s.byteOffset,l=n(+i),d=0;d<t;d++)c[u+d]=l[o?d:t-d-1]};if(NATIVE_ARRAY_BUFFER){var INCORRECT_ARRAY_BUFFER_NAME=PROPER_FUNCTION_NAME&&NativeArrayBuffer.name!==ARRAY_BUFFER;if(fails$d((function(){NativeArrayBuffer(1)}))&&fails$d((function(){new NativeArrayBuffer(-1)}))&&!fails$d((function(){return new NativeArrayBuffer,new NativeArrayBuffer(1.5),new NativeArrayBuffer(NaN),1!=NativeArrayBuffer.length||INCORRECT_ARRAY_BUFFER_NAME&&!CONFIGURABLE_FUNCTION_NAME})))INCORRECT_ARRAY_BUFFER_NAME&&CONFIGURABLE_FUNCTION_NAME&&createNonEnumerableProperty$1(NativeArrayBuffer,"name",ARRAY_BUFFER);else{($ArrayBuffer=function(e){return anInstance$4(this,ArrayBufferPrototype$1),new NativeArrayBuffer(toIndex$1(e))})[PROTOTYPE$1]=ArrayBufferPrototype$1;for(var key,keys$1=getOwnPropertyNames$1(NativeArrayBuffer),j=0;keys$1.length>j;)(key=keys$1[j++])in $ArrayBuffer||createNonEnumerableProperty$1($ArrayBuffer,key,NativeArrayBuffer[key]);ArrayBufferPrototype$1.constructor=$ArrayBuffer}setPrototypeOf$1&&getPrototypeOf$2(DataViewPrototype)!==ObjectPrototype$1&&setPrototypeOf$1(DataViewPrototype,ObjectPrototype$1);var testView=new $DataView(new $ArrayBuffer(2)),$setInt8=uncurryThis$i(DataViewPrototype.setInt8);testView.setInt8(0,2147483648),testView.setInt8(1,2147483649),!testView.getInt8(0)&&testView.getInt8(1)||defineBuiltIns$3(DataViewPrototype,{setInt8:function(e,t){$setInt8(this,e,t<<24>>24)},setUint8:function(e,t){$setInt8(this,e,t<<24>>24)}},{unsafe:!0})}else ArrayBufferPrototype$1=($ArrayBuffer=function(e){anInstance$4(this,ArrayBufferPrototype$1);var t=toIndex$1(e);setInternalState$5(this,{bytes:fill(Array$1(t),0),byteLength:t}),DESCRIPTORS$6||(this.byteLength=t)})[PROTOTYPE$1],DataViewPrototype=($DataView=function(e,t,r){anInstance$4(this,DataViewPrototype),anInstance$4(e,ArrayBufferPrototype$1);var n=getInternalState$2(e).byteLength,i=toIntegerOrInfinity$6(t);if(i<0||i>n)throw RangeError$3("Wrong offset");if(i+(r=void 0===r?n-i:toLength$4(r))>n)throw RangeError$3(WRONG_LENGTH$1);setInternalState$5(this,{buffer:e,byteLength:r,byteOffset:i}),DESCRIPTORS$6||(this.buffer=e,this.byteLength=r,this.byteOffset=i)})[PROTOTYPE$1],DESCRIPTORS$6&&(addGetter$1($ArrayBuffer,"byteLength"),addGetter$1($DataView,"buffer"),addGetter$1($DataView,"byteLength"),addGetter$1($DataView,"byteOffset")),defineBuiltIns$3(DataViewPrototype,{getInt8:function(e){return get$1(this,1,e)[0]<<24>>24},getUint8:function(e){return get$1(this,1,e)[0]},getInt16:function(e){var t=get$1(this,2,e,arguments.length>1?arguments[1]:void 0);return(t[1]<<8|t[0])<<16>>16},getUint16:function(e){var t=get$1(this,2,e,arguments.length>1?arguments[1]:void 0);return t[1]<<8|t[0]},getInt32:function(e){return unpackInt32(get$1(this,4,e,arguments.length>1?arguments[1]:void 0))},getUint32:function(e){return unpackInt32(get$1(this,4,e,arguments.length>1?arguments[1]:void 0))>>>0},getFloat32:function(e){return unpackIEEE754(get$1(this,4,e,arguments.length>1?arguments[1]:void 0),23)},getFloat64:function(e){return unpackIEEE754(get$1(this,8,e,arguments.length>1?arguments[1]:void 0),52)},setInt8:function(e,t){set$1(this,1,e,packInt8,t)},setUint8:function(e,t){set$1(this,1,e,packInt8,t)},setInt16:function(e,t){set$1(this,2,e,packInt16,t,arguments.length>2?arguments[2]:void 0)},setUint16:function(e,t){set$1(this,2,e,packInt16,t,arguments.length>2?arguments[2]:void 0)},setInt32:function(e,t){set$1(this,4,e,packInt32,t,arguments.length>2?arguments[2]:void 0)},setUint32:function(e,t){set$1(this,4,e,packInt32,t,arguments.length>2?arguments[2]:void 0)},setFloat32:function(e,t){set$1(this,4,e,packFloat32,t,arguments.length>2?arguments[2]:void 0)},setFloat64:function(e,t){set$1(this,8,e,packFloat64,t,arguments.length>2?arguments[2]:void 0)}});setToStringTag$4($ArrayBuffer,ARRAY_BUFFER),setToStringTag$4($DataView,DATA_VIEW);var arrayBuffer={ArrayBuffer:$ArrayBuffer,DataView:$DataView},isObject$7=isObject$s,floor$3=Math.floor,isIntegralNumber$1=Number.isInteger||function(e){return!isObject$7(e)&&isFinite(e)&&floor$3(e)===e},toIntegerOrInfinity$5=toIntegerOrInfinity$d,$RangeError$4=RangeError,toPositiveInteger$1=function(e){var t=toIntegerOrInfinity$5(e);if(t<0)throw $RangeError$4("The argument can't be less than 0");return t},toPositiveInteger=toPositiveInteger$1,$RangeError$3=RangeError,toOffset$2=function(e,t){var r=toPositiveInteger(e);if(r%t)throw $RangeError$3("Wrong offset");return r},classof$3=classof$i,uncurryThis$h=functionUncurryThis,slice$1=uncurryThis$h("".slice),isBigIntArray$2=function(e){return"Big"===slice$1(classof$3(e),0,3)},toPrimitive=toPrimitive$3,$TypeError=TypeError,toBigInt$3=function(e){var t=toPrimitive(e,"number");if("number"==typeof t)throw $TypeError("Can't convert number to bigint");return BigInt(t)},bind$4=functionBindContext,call$a=functionCall,aConstructor=aConstructor$2,toObject$5=toObject$i,lengthOfArrayLike$a=lengthOfArrayLike$m,getIterator$2=getIterator$4,getIteratorMethod$2=getIteratorMethod$5,isArrayIteratorMethod$1=isArrayIteratorMethod$3,isBigIntArray$1=isBigIntArray$2,aTypedArrayConstructor$2=arrayBufferViewCore.aTypedArrayConstructor,toBigInt$2=toBigInt$3,typedArrayFrom$1=function(e){var t,r,n,i,o,a,s,c,u=aConstructor(this),l=toObject$5(e),d=arguments.length,p=d>1?arguments[1]:void 0,_=void 0!==p,f=getIteratorMethod$2(l);if(f&&!isArrayIteratorMethod$1(f))for(c=(s=getIterator$2(l,f)).next,l=[];!(a=call$a(c,s)).done;)l.push(a.value);for(_&&d>2&&(p=bind$4(p,arguments[2])),r=lengthOfArrayLike$a(l),n=new(aTypedArrayConstructor$2(u))(r),i=isBigIntArray$1(n),t=0;r>t;t++)o=_?p(l[t],t):l[t],n[t]=i?toBigInt$2(o):+o;return n},$$h=_export,global$d=global$K,call$9=functionCall,DESCRIPTORS$5=descriptors,TYPED_ARRAYS_CONSTRUCTORS_REQUIRES_WRAPPERS=typedArrayConstructorsRequireWrappers,ArrayBufferViewCore$s=arrayBufferViewCore,ArrayBufferModule=arrayBuffer,anInstance$3=anInstance$a,createPropertyDescriptor$3=createPropertyDescriptor$b,createNonEnumerableProperty=createNonEnumerableProperty$c,isIntegralNumber=isIntegralNumber$1,toLength$3=toLength$a,toIndex=toIndex$2,toOffset$1=toOffset$2,toPropertyKey$1=toPropertyKey$5,hasOwn$8=hasOwnProperty_1,classof$2=classof$i,isObject$6=isObject$s,isSymbol$1=isSymbol$6,create$1=objectCreate,isPrototypeOf$1=objectIsPrototypeOf,setPrototypeOf=objectSetPrototypeOf,getOwnPropertyNames=objectGetOwnPropertyNames.f,typedArrayFrom=typedArrayFrom$1,forEach=arrayIteration.forEach,setSpecies=setSpecies$4,definePropertyModule$2=objectDefineProperty,getOwnPropertyDescriptorModule$3=objectGetOwnPropertyDescriptor,InternalStateModule$4=internalState,inheritIfRequired=inheritIfRequired$6,getInternalState$1=InternalStateModule$4.get,setInternalState$4=InternalStateModule$4.set,enforceInternalState$1=InternalStateModule$4.enforce,nativeDefineProperty$1=definePropertyModule$2.f,nativeGetOwnPropertyDescriptor$1=getOwnPropertyDescriptorModule$3.f,round=Math.round,RangeError$2=global$d.RangeError,ArrayBuffer$1=ArrayBufferModule.ArrayBuffer,ArrayBufferPrototype=ArrayBuffer$1.prototype,DataView$1=ArrayBufferModule.DataView,NATIVE_ARRAY_BUFFER_VIEWS=ArrayBufferViewCore$s.NATIVE_ARRAY_BUFFER_VIEWS,TYPED_ARRAY_TAG=ArrayBufferViewCore$s.TYPED_ARRAY_TAG,TypedArray=ArrayBufferViewCore$s.TypedArray,TypedArrayPrototype$1=ArrayBufferViewCore$s.TypedArrayPrototype,aTypedArrayConstructor$1=ArrayBufferViewCore$s.aTypedArrayConstructor,isTypedArray$2=ArrayBufferViewCore$s.isTypedArray,BYTES_PER_ELEMENT="BYTES_PER_ELEMENT",WRONG_LENGTH="Wrong length",fromList=function(e,t){aTypedArrayConstructor$1(e);for(var r=0,n=t.length,i=new e(n);n>r;)i[r]=t[r++];return i},addGetter=function(e,t){nativeDefineProperty$1(e,t,{get:function(){return getInternalState$1(this)[t]}})},isArrayBuffer=function(e){var t;return isPrototypeOf$1(ArrayBufferPrototype,e)||"ArrayBuffer"==(t=classof$2(e))||"SharedArrayBuffer"==t},isTypedArrayIndex=function(e,t){return isTypedArray$2(e)&&!isSymbol$1(t)&&t in e&&isIntegralNumber(+t)&&t>=0},wrappedGetOwnPropertyDescriptor=function(e,t){return t=toPropertyKey$1(t),isTypedArrayIndex(e,t)?createPropertyDescriptor$3(2,e[t]):nativeGetOwnPropertyDescriptor$1(e,t)},wrappedDefineProperty=function(e,t,r){return t=toPropertyKey$1(t),!(isTypedArrayIndex(e,t)&&isObject$6(r)&&hasOwn$8(r,"value"))||hasOwn$8(r,"get")||hasOwn$8(r,"set")||r.configurable||hasOwn$8(r,"writable")&&!r.writable||hasOwn$8(r,"enumerable")&&!r.enumerable?nativeDefineProperty$1(e,t,r):(e[t]=r.value,e)};DESCRIPTORS$5?(NATIVE_ARRAY_BUFFER_VIEWS||(getOwnPropertyDescriptorModule$3.f=wrappedGetOwnPropertyDescriptor,definePropertyModule$2.f=wrappedDefineProperty,addGetter(TypedArrayPrototype$1,"buffer"),addGetter(TypedArrayPrototype$1,"byteOffset"),addGetter(TypedArrayPrototype$1,"byteLength"),addGetter(TypedArrayPrototype$1,"length")),$$h({target:"Object",stat:!0,forced:!NATIVE_ARRAY_BUFFER_VIEWS},{getOwnPropertyDescriptor:wrappedGetOwnPropertyDescriptor,defineProperty:wrappedDefineProperty}),typedArrayConstructor.exports=function(e,t,r){var n=e.match(/\d+$/)[0]/8,i=e+(r?"Clamped":"")+"Array",o="get"+e,a="set"+e,s=global$d[i],c=s,u=c&&c.prototype,l={},d=function(e,t){nativeDefineProperty$1(e,t,{get:function(){return function(e,t){var r=getInternalState$1(e);return r.view[o](t*n+r.byteOffset,!0)}(this,t)},set:function(e){return function(e,t,i){var o=getInternalState$1(e);r&&(i=(i=round(i))<0?0:i>255?255:255&i),o.view[a](t*n+o.byteOffset,i,!0)}(this,t,e)},enumerable:!0})};NATIVE_ARRAY_BUFFER_VIEWS?TYPED_ARRAYS_CONSTRUCTORS_REQUIRES_WRAPPERS&&(c=t((function(e,t,r,i){return anInstance$3(e,u),inheritIfRequired(isObject$6(t)?isArrayBuffer(t)?void 0!==i?new s(t,toOffset$1(r,n),i):void 0!==r?new s(t,toOffset$1(r,n)):new s(t):isTypedArray$2(t)?fromList(c,t):call$9(typedArrayFrom,c,t):new s(toIndex(t)),e,c)})),setPrototypeOf&&setPrototypeOf(c,TypedArray),forEach(getOwnPropertyNames(s),(function(e){e in c||createNonEnumerableProperty(c,e,s[e])})),c.prototype=u):(c=t((function(e,t,r,i){anInstance$3(e,u);var o,a,s,l=0,p=0;if(isObject$6(t)){if(!isArrayBuffer(t))return isTypedArray$2(t)?fromList(c,t):call$9(typedArrayFrom,c,t);o=t,p=toOffset$1(r,n);var _=t.byteLength;if(void 0===i){if(_%n)throw RangeError$2(WRONG_LENGTH);if((a=_-p)<0)throw RangeError$2(WRONG_LENGTH)}else if((a=toLength$3(i)*n)+p>_)throw RangeError$2(WRONG_LENGTH);s=a/n}else s=toIndex(t),o=new ArrayBuffer$1(a=s*n);for(setInternalState$4(e,{buffer:o,byteOffset:p,byteLength:a,length:s,view:new DataView$1(o)});l<s;)d(e,l++)})),setPrototypeOf&&setPrototypeOf(c,TypedArray),u=c.prototype=create$1(TypedArrayPrototype$1)),u.constructor!==c&&createNonEnumerableProperty(u,"constructor",c),enforceInternalState$1(u).TypedArrayConstructor=c,TYPED_ARRAY_TAG&&createNonEnumerableProperty(u,TYPED_ARRAY_TAG,i);var p=c!=s;l[i]=c,$$h({global:!0,constructor:!0,forced:p,sham:!NATIVE_ARRAY_BUFFER_VIEWS},l),BYTES_PER_ELEMENT in c||createNonEnumerableProperty(c,BYTES_PER_ELEMENT,n),BYTES_PER_ELEMENT in u||createNonEnumerableProperty(u,BYTES_PER_ELEMENT,n),setSpecies(i)}):typedArrayConstructor.exports=function(){};var createTypedArrayConstructor$2=typedArrayConstructor.exports;createTypedArrayConstructor$2("Uint8",(function(e){return function(t,r,n){return e(this,t,r,n)}}));var ArrayBufferViewCore$r=arrayBufferViewCore,lengthOfArrayLike$9=lengthOfArrayLike$m,toIntegerOrInfinity$4=toIntegerOrInfinity$d,aTypedArray$q=ArrayBufferViewCore$r.aTypedArray,exportTypedArrayMethod$r=ArrayBufferViewCore$r.exportTypedArrayMethod;exportTypedArrayMethod$r("at",(function(e){var t=aTypedArray$q(this),r=lengthOfArrayLike$9(t),n=toIntegerOrInfinity$4(e),i=n>=0?n:r+n;return i<0||i>=r?void 0:t[i]}));var toObject$4=toObject$i,toAbsoluteIndex=toAbsoluteIndex$6,lengthOfArrayLike$8=lengthOfArrayLike$m,deletePropertyOrThrow$1=deletePropertyOrThrow$4,min$3=Math.min,arrayCopyWithin=[].copyWithin||function(e,t){var r=toObject$4(this),n=lengthOfArrayLike$8(r),i=toAbsoluteIndex(e,n),o=toAbsoluteIndex(t,n),a=arguments.length>2?arguments[2]:void 0,s=min$3((void 0===a?n:toAbsoluteIndex(a,n))-o,n-i),c=1;for(o<i&&i<o+s&&(c=-1,o+=s-1,i+=s-1);s-- >0;)o in r?r[i]=r[o]:deletePropertyOrThrow$1(r,i),i+=c,o+=c;return r},uncurryThis$g=functionUncurryThis,ArrayBufferViewCore$q=arrayBufferViewCore,$ArrayCopyWithin=arrayCopyWithin,u$ArrayCopyWithin=uncurryThis$g($ArrayCopyWithin),aTypedArray$p=ArrayBufferViewCore$q.aTypedArray,exportTypedArrayMethod$q=ArrayBufferViewCore$q.exportTypedArrayMethod;exportTypedArrayMethod$q("copyWithin",(function(e,t){return u$ArrayCopyWithin(aTypedArray$p(this),e,t,arguments.length>2?arguments[2]:void 0)}));var ArrayBufferViewCore$p=arrayBufferViewCore,$every=arrayIteration.every,aTypedArray$o=ArrayBufferViewCore$p.aTypedArray,exportTypedArrayMethod$p=ArrayBufferViewCore$p.exportTypedArrayMethod;exportTypedArrayMethod$p("every",(function(e){return $every(aTypedArray$o(this),e,arguments.length>1?arguments[1]:void 0)}));var ArrayBufferViewCore$o=arrayBufferViewCore,$fill=arrayFill$1,toBigInt$1=toBigInt$3,classof$1=classof$i,call$8=functionCall,uncurryThis$f=functionUncurryThis,fails$c=fails$U,aTypedArray$n=ArrayBufferViewCore$o.aTypedArray,exportTypedArrayMethod$o=ArrayBufferViewCore$o.exportTypedArrayMethod,slice=uncurryThis$f("".slice),CONVERSION_BUG=fails$c((function(){var e=0;return new Int8Array(2).fill({valueOf:function(){return e++}}),1!==e}));exportTypedArrayMethod$o("fill",(function(e){var t=arguments.length;aTypedArray$n(this);var r="Big"===slice(classof$1(this),0,3)?toBigInt$1(e):+e;return call$8($fill,this,r,t>1?arguments[1]:void 0,t>2?arguments[2]:void 0)}),CONVERSION_BUG);var lengthOfArrayLike$7=lengthOfArrayLike$m,arrayFromConstructorAndList$2=function(e,t){for(var r=0,n=lengthOfArrayLike$7(t),i=new e(n);n>r;)i[r]=t[r++];return i},ArrayBufferViewCore$n=arrayBufferViewCore,speciesConstructor$1=speciesConstructor$4,aTypedArrayConstructor=ArrayBufferViewCore$n.aTypedArrayConstructor,getTypedArrayConstructor$3=ArrayBufferViewCore$n.getTypedArrayConstructor,typedArraySpeciesConstructor$3=function(e){return aTypedArrayConstructor(speciesConstructor$1(e,getTypedArrayConstructor$3(e)))},arrayFromConstructorAndList$1=arrayFromConstructorAndList$2,typedArraySpeciesConstructor$2=typedArraySpeciesConstructor$3,typedArrayFromSpeciesAndList=function(e,t){return arrayFromConstructorAndList$1(typedArraySpeciesConstructor$2(e),t)},ArrayBufferViewCore$m=arrayBufferViewCore,$filter=arrayIteration.filter,fromSpeciesAndList=typedArrayFromSpeciesAndList,aTypedArray$m=ArrayBufferViewCore$m.aTypedArray,exportTypedArrayMethod$n=ArrayBufferViewCore$m.exportTypedArrayMethod;exportTypedArrayMethod$n("filter",(function(e){var t=$filter(aTypedArray$m(this),e,arguments.length>1?arguments[1]:void 0);return fromSpeciesAndList(this,t)}));var ArrayBufferViewCore$l=arrayBufferViewCore,$find=arrayIteration.find,aTypedArray$l=ArrayBufferViewCore$l.aTypedArray,exportTypedArrayMethod$m=ArrayBufferViewCore$l.exportTypedArrayMethod;exportTypedArrayMethod$m("find",(function(e){return $find(aTypedArray$l(this),e,arguments.length>1?arguments[1]:void 0)}));var ArrayBufferViewCore$k=arrayBufferViewCore,$findIndex$1=arrayIteration.findIndex,aTypedArray$k=ArrayBufferViewCore$k.aTypedArray,exportTypedArrayMethod$l=ArrayBufferViewCore$k.exportTypedArrayMethod;exportTypedArrayMethod$l("findIndex",(function(e){return $findIndex$1(aTypedArray$k(this),e,arguments.length>1?arguments[1]:void 0)}));var bind$3=functionBindContext,IndexedObject=indexedObject,toObject$3=toObject$i,lengthOfArrayLike$6=lengthOfArrayLike$m,createMethod$2=function(e){var t=1==e;return function(r,n,i){for(var o,a=toObject$3(r),s=IndexedObject(a),c=bind$3(n,i),u=lengthOfArrayLike$6(s);u-- >0;)if(c(o=s[u],u,a))switch(e){case 0:return o;case 1:return u}return t?-1:void 0}},arrayIterationFromLast={findLast:createMethod$2(0),findLastIndex:createMethod$2(1)},ArrayBufferViewCore$j=arrayBufferViewCore,$findLast=arrayIterationFromLast.findLast,aTypedArray$j=ArrayBufferViewCore$j.aTypedArray,exportTypedArrayMethod$k=ArrayBufferViewCore$j.exportTypedArrayMethod;exportTypedArrayMethod$k("findLast",(function(e){return $findLast(aTypedArray$j(this),e,arguments.length>1?arguments[1]:void 0)}));var ArrayBufferViewCore$i=arrayBufferViewCore,$findLastIndex=arrayIterationFromLast.findLastIndex,aTypedArray$i=ArrayBufferViewCore$i.aTypedArray,exportTypedArrayMethod$j=ArrayBufferViewCore$i.exportTypedArrayMethod;exportTypedArrayMethod$j("findLastIndex",(function(e){return $findLastIndex(aTypedArray$i(this),e,arguments.length>1?arguments[1]:void 0)}));var ArrayBufferViewCore$h=arrayBufferViewCore,$forEach$1=arrayIteration.forEach,aTypedArray$h=ArrayBufferViewCore$h.aTypedArray,exportTypedArrayMethod$i=ArrayBufferViewCore$h.exportTypedArrayMethod;exportTypedArrayMethod$i("forEach",(function(e){$forEach$1(aTypedArray$h(this),e,arguments.length>1?arguments[1]:void 0)}));var ArrayBufferViewCore$g=arrayBufferViewCore,$includes=arrayIncludes.includes,aTypedArray$g=ArrayBufferViewCore$g.aTypedArray,exportTypedArrayMethod$h=ArrayBufferViewCore$g.exportTypedArrayMethod;exportTypedArrayMethod$h("includes",(function(e){return $includes(aTypedArray$g(this),e,arguments.length>1?arguments[1]:void 0)}));var ArrayBufferViewCore$f=arrayBufferViewCore,$indexOf=arrayIncludes.indexOf,aTypedArray$f=ArrayBufferViewCore$f.aTypedArray,exportTypedArrayMethod$g=ArrayBufferViewCore$f.exportTypedArrayMethod;exportTypedArrayMethod$g("indexOf",(function(e){return $indexOf(aTypedArray$f(this),e,arguments.length>1?arguments[1]:void 0)}));var global$c=global$K,fails$b=fails$U,uncurryThis$e=functionUncurryThis,ArrayBufferViewCore$e=arrayBufferViewCore,ArrayIterators=es_array_iterator,wellKnownSymbol$5=wellKnownSymbol$u,ITERATOR$2=wellKnownSymbol$5("iterator"),Uint8Array$2=global$c.Uint8Array,arrayValues=uncurryThis$e(ArrayIterators.values),arrayKeys=uncurryThis$e(ArrayIterators.keys),arrayEntries=uncurryThis$e(ArrayIterators.entries),aTypedArray$e=ArrayBufferViewCore$e.aTypedArray,exportTypedArrayMethod$f=ArrayBufferViewCore$e.exportTypedArrayMethod,TypedArrayPrototype=Uint8Array$2&&Uint8Array$2.prototype,GENERIC=!fails$b((function(){TypedArrayPrototype[ITERATOR$2].call([1])})),ITERATOR_IS_VALUES=!!TypedArrayPrototype&&TypedArrayPrototype.values&&TypedArrayPrototype[ITERATOR$2]===TypedArrayPrototype.values&&"values"===TypedArrayPrototype.values.name,typedArrayValues=function(){return arrayValues(aTypedArray$e(this))};exportTypedArrayMethod$f("entries",(function(){return arrayEntries(aTypedArray$e(this))}),GENERIC),exportTypedArrayMethod$f("keys",(function(){return arrayKeys(aTypedArray$e(this))}),GENERIC),exportTypedArrayMethod$f("values",typedArrayValues,GENERIC||!ITERATOR_IS_VALUES,{name:"values"}),exportTypedArrayMethod$f(ITERATOR$2,typedArrayValues,GENERIC||!ITERATOR_IS_VALUES,{name:"values"});var ArrayBufferViewCore$d=arrayBufferViewCore,uncurryThis$d=functionUncurryThis,aTypedArray$d=ArrayBufferViewCore$d.aTypedArray,exportTypedArrayMethod$e=ArrayBufferViewCore$d.exportTypedArrayMethod,$join=uncurryThis$d([].join);exportTypedArrayMethod$e("join",(function(e){return $join(aTypedArray$d(this),e)}));var apply$4=functionApply,toIndexedObject$3=toIndexedObject$c,toIntegerOrInfinity$3=toIntegerOrInfinity$d,lengthOfArrayLike$5=lengthOfArrayLike$m,arrayMethodIsStrict=arrayMethodIsStrict$5,min$2=Math.min,$lastIndexOf$1=[].lastIndexOf,NEGATIVE_ZERO=!!$lastIndexOf$1&&1/[1].lastIndexOf(1,-0)<0,STRICT_METHOD=arrayMethodIsStrict("lastIndexOf"),FORCED$4=NEGATIVE_ZERO||!STRICT_METHOD,arrayLastIndexOf=FORCED$4?function(e){if(NEGATIVE_ZERO)return apply$4($lastIndexOf$1,this,arguments)||0;var t=toIndexedObject$3(this),r=lengthOfArrayLike$5(t),n=r-1;for(arguments.length>1&&(n=min$2(n,toIntegerOrInfinity$3(arguments[1]))),n<0&&(n=r+n);n>=0;n--)if(n in t&&t[n]===e)return n||0;return-1}:$lastIndexOf$1,ArrayBufferViewCore$c=arrayBufferViewCore,apply$3=functionApply,$lastIndexOf=arrayLastIndexOf,aTypedArray$c=ArrayBufferViewCore$c.aTypedArray,exportTypedArrayMethod$d=ArrayBufferViewCore$c.exportTypedArrayMethod;exportTypedArrayMethod$d("lastIndexOf",(function(e){var t=arguments.length;return apply$3($lastIndexOf,aTypedArray$c(this),t>1?[e,arguments[1]]:[e])}));var ArrayBufferViewCore$b=arrayBufferViewCore,$map=arrayIteration.map,typedArraySpeciesConstructor$1=typedArraySpeciesConstructor$3,aTypedArray$b=ArrayBufferViewCore$b.aTypedArray,exportTypedArrayMethod$c=ArrayBufferViewCore$b.exportTypedArrayMethod;exportTypedArrayMethod$c("map",(function(e){return $map(aTypedArray$b(this),e,arguments.length>1?arguments[1]:void 0,(function(e,t){return new(typedArraySpeciesConstructor$1(e))(t)}))}));var ArrayBufferViewCore$a=arrayBufferViewCore,$reduce=arrayReduce.left,aTypedArray$a=ArrayBufferViewCore$a.aTypedArray,exportTypedArrayMethod$b=ArrayBufferViewCore$a.exportTypedArrayMethod;exportTypedArrayMethod$b("reduce",(function(e){var t=arguments.length;return $reduce(aTypedArray$a(this),e,t,t>1?arguments[1]:void 0)}));var ArrayBufferViewCore$9=arrayBufferViewCore,$reduceRight=arrayReduce.right,aTypedArray$9=ArrayBufferViewCore$9.aTypedArray,exportTypedArrayMethod$a=ArrayBufferViewCore$9.exportTypedArrayMethod;exportTypedArrayMethod$a("reduceRight",(function(e){var t=arguments.length;return $reduceRight(aTypedArray$9(this),e,t,t>1?arguments[1]:void 0)}));var ArrayBufferViewCore$8=arrayBufferViewCore,aTypedArray$8=ArrayBufferViewCore$8.aTypedArray,exportTypedArrayMethod$9=ArrayBufferViewCore$8.exportTypedArrayMethod,floor$2=Math.floor;exportTypedArrayMethod$9("reverse",(function(){for(var e,t=this,r=aTypedArray$8(t).length,n=floor$2(r/2),i=0;i<n;)e=t[i],t[i++]=t[--r],t[r]=e;return t}));var global$b=global$K,call$7=functionCall,ArrayBufferViewCore$7=arrayBufferViewCore,lengthOfArrayLike$4=lengthOfArrayLike$m,toOffset=toOffset$2,toIndexedObject$2=toObject$i,fails$a=fails$U,RangeError$1=global$b.RangeError,Int8Array$2=global$b.Int8Array,Int8ArrayPrototype=Int8Array$2&&Int8Array$2.prototype,$set=Int8ArrayPrototype&&Int8ArrayPrototype.set,aTypedArray$7=ArrayBufferViewCore$7.aTypedArray,exportTypedArrayMethod$8=ArrayBufferViewCore$7.exportTypedArrayMethod,WORKS_WITH_OBJECTS_AND_GEERIC_ON_TYPED_ARRAYS=!fails$a((function(){var e=new Uint8ClampedArray(2);return call$7($set,e,{length:1,0:3},1),3!==e[1]})),TO_OBJECT_BUG=WORKS_WITH_OBJECTS_AND_GEERIC_ON_TYPED_ARRAYS&&ArrayBufferViewCore$7.NATIVE_ARRAY_BUFFER_VIEWS&&fails$a((function(){var e=new Int8Array$2(2);return e.set(1),e.set("2",1),0!==e[0]||2!==e[1]}));exportTypedArrayMethod$8("set",(function(e){aTypedArray$7(this);var t=toOffset(arguments.length>1?arguments[1]:void 0,1),r=toIndexedObject$2(e);if(WORKS_WITH_OBJECTS_AND_GEERIC_ON_TYPED_ARRAYS)return call$7($set,this,r,t);var n=this.length,i=lengthOfArrayLike$4(r),o=0;if(i+t>n)throw RangeError$1("Wrong length");for(;o<i;)this[t+o]=r[o++]}),!WORKS_WITH_OBJECTS_AND_GEERIC_ON_TYPED_ARRAYS||TO_OBJECT_BUG);var ArrayBufferViewCore$6=arrayBufferViewCore,typedArraySpeciesConstructor=typedArraySpeciesConstructor$3,fails$9=fails$U,arraySlice$3=arraySlice$9,aTypedArray$6=ArrayBufferViewCore$6.aTypedArray,exportTypedArrayMethod$7=ArrayBufferViewCore$6.exportTypedArrayMethod,FORCED$3=fails$9((function(){new Int8Array(1).slice()}));exportTypedArrayMethod$7("slice",(function(e,t){for(var r=arraySlice$3(aTypedArray$6(this),e,t),n=typedArraySpeciesConstructor(this),i=0,o=r.length,a=new n(o);o>i;)a[i]=r[i++];return a}),FORCED$3);var ArrayBufferViewCore$5=arrayBufferViewCore,$some=arrayIteration.some,aTypedArray$5=ArrayBufferViewCore$5.aTypedArray,exportTypedArrayMethod$6=ArrayBufferViewCore$5.exportTypedArrayMethod;exportTypedArrayMethod$6("some",(function(e){return $some(aTypedArray$5(this),e,arguments.length>1?arguments[1]:void 0)}));var global$a=global$K,uncurryThis$c=functionUncurryThisClause,fails$8=fails$U,aCallable$1=aCallable$b,internalSort=arraySort$1,ArrayBufferViewCore$4=arrayBufferViewCore,FF=engineFfVersion,IE_OR_EDGE=engineIsIeOrEdge,V8=engineV8Version,WEBKIT=engineWebkitVersion,aTypedArray$4=ArrayBufferViewCore$4.aTypedArray,exportTypedArrayMethod$5=ArrayBufferViewCore$4.exportTypedArrayMethod,Uint16Array$1=global$a.Uint16Array,nativeSort=Uint16Array$1&&uncurryThis$c(Uint16Array$1.prototype.sort),ACCEPT_INCORRECT_ARGUMENTS=!(!nativeSort||fails$8((function(){nativeSort(new Uint16Array$1(2),null)}))&&fails$8((function(){nativeSort(new Uint16Array$1(2),{})}))),STABLE_SORT=!!nativeSort&&!fails$8((function(){if(V8)return V8<74;if(FF)return FF<67;if(IE_OR_EDGE)return!0;if(WEBKIT)return WEBKIT<602;var e,t,r=new Uint16Array$1(516),n=Array(516);for(e=0;e<516;e++)t=e%4,r[e]=515-e,n[e]=e-2*t+3;for(nativeSort(r,(function(e,t){return(e/4|0)-(t/4|0)})),e=0;e<516;e++)if(r[e]!==n[e])return!0})),getSortCompare=function(e){return function(t,r){return void 0!==e?+e(t,r)||0:r!=r?-1:t!=t?1:0===t&&0===r?1/t>0&&1/r<0?1:-1:t>r}};exportTypedArrayMethod$5("sort",(function(e){return void 0!==e&&aCallable$1(e),STABLE_SORT?nativeSort(this,e):internalSort(aTypedArray$4(this),getSortCompare(e))}),!STABLE_SORT||ACCEPT_INCORRECT_ARGUMENTS);var global$9=global$K,apply$2=functionApply,ArrayBufferViewCore$3=arrayBufferViewCore,fails$7=fails$U,arraySlice$2=arraySlice$9,Int8Array$1=global$9.Int8Array,aTypedArray$3=ArrayBufferViewCore$3.aTypedArray,exportTypedArrayMethod$4=ArrayBufferViewCore$3.exportTypedArrayMethod,$toLocaleString=[].toLocaleString,TO_LOCALE_STRING_BUG=!!Int8Array$1&&fails$7((function(){$toLocaleString.call(new Int8Array$1(1))})),FORCED$2=fails$7((function(){return[1,2].toLocaleString()!=new Int8Array$1([1,2]).toLocaleString()}))||!fails$7((function(){Int8Array$1.prototype.toLocaleString.call([1,2])}));exportTypedArrayMethod$4("toLocaleString",(function(){return apply$2($toLocaleString,TO_LOCALE_STRING_BUG?arraySlice$2(aTypedArray$3(this)):aTypedArray$3(this),arraySlice$2(arguments))}),FORCED$2);var exportTypedArrayMethod$3=arrayBufferViewCore.exportTypedArrayMethod,fails$6=fails$U,global$8=global$K,uncurryThis$b=functionUncurryThis,Uint8Array$1=global$8.Uint8Array,Uint8ArrayPrototype=Uint8Array$1&&Uint8Array$1.prototype||{},arrayToString=[].toString,join$3=uncurryThis$b([].join);fails$6((function(){arrayToString.call({})}))&&(arrayToString=function(){return join$3(this)});var IS_NOT_ARRAY_METHOD=Uint8ArrayPrototype.toString!=arrayToString;exportTypedArrayMethod$3("toString",arrayToString,IS_NOT_ARRAY_METHOD);var lengthOfArrayLike$3=lengthOfArrayLike$m,arrayToReversed$1=function(e,t){for(var r=lengthOfArrayLike$3(e),n=new t(r),i=0;i<r;i++)n[i]=e[r-i-1];return n},arrayToReversed=arrayToReversed$1,ArrayBufferViewCore$2=arrayBufferViewCore,aTypedArray$2=ArrayBufferViewCore$2.aTypedArray,exportTypedArrayMethod$2=ArrayBufferViewCore$2.exportTypedArrayMethod,getTypedArrayConstructor$2=ArrayBufferViewCore$2.getTypedArrayConstructor;exportTypedArrayMethod$2("toReversed",(function(){return arrayToReversed(aTypedArray$2(this),getTypedArrayConstructor$2(this))}));var ArrayBufferViewCore$1=arrayBufferViewCore,uncurryThis$a=functionUncurryThis,aCallable=aCallable$b,arrayFromConstructorAndList=arrayFromConstructorAndList$2,aTypedArray$1=ArrayBufferViewCore$1.aTypedArray,getTypedArrayConstructor$1=ArrayBufferViewCore$1.getTypedArrayConstructor,exportTypedArrayMethod$1=ArrayBufferViewCore$1.exportTypedArrayMethod,sort=uncurryThis$a(ArrayBufferViewCore$1.TypedArrayPrototype.sort);exportTypedArrayMethod$1("toSorted",(function(e){void 0!==e&&aCallable(e);var t=aTypedArray$1(this),r=arrayFromConstructorAndList(getTypedArrayConstructor$1(t),t);return sort(r,e)}));var lengthOfArrayLike$2=lengthOfArrayLike$m,toIntegerOrInfinity$2=toIntegerOrInfinity$d,$RangeError$2=RangeError,arrayWith$1=function(e,t,r,n){var i=lengthOfArrayLike$2(e),o=toIntegerOrInfinity$2(r),a=o<0?i+o:o;if(a>=i||a<0)throw $RangeError$2("Incorrect index");for(var s=new t(i),c=0;c<i;c++)s[c]=c===a?n:e[c];return s},arrayWith=arrayWith$1,ArrayBufferViewCore=arrayBufferViewCore,isBigIntArray=isBigIntArray$2,toIntegerOrInfinity$1=toIntegerOrInfinity$d,toBigInt=toBigInt$3,aTypedArray=ArrayBufferViewCore.aTypedArray,getTypedArrayConstructor=ArrayBufferViewCore.getTypedArrayConstructor,exportTypedArrayMethod=ArrayBufferViewCore.exportTypedArrayMethod,PROPER_ORDER=!!function(){try{new Int8Array(1).with(2,{valueOf:function(){throw 8}})}catch(e){return 8===e}}();exportTypedArrayMethod("with",{with:function(e,t){var r=aTypedArray(this),n=toIntegerOrInfinity$1(e),i=isBigIntArray(r)?toBigInt(t):+t;return arrayWith(r,getTypedArrayConstructor(r),n,i)}}.with,!PROPER_ORDER);var $$g=_export,$findIndex=arrayIteration.findIndex,addToUnscopables=addToUnscopables$4,FIND_INDEX="findIndex",SKIPS_HOLES=!0;FIND_INDEX in[]&&Array(1)[FIND_INDEX]((function(){SKIPS_HOLES=!1})),$$g({target:"Array",proto:!0,forced:SKIPS_HOLES},{findIndex:function(e){return $findIndex(this,e,arguments.length>1?arguments[1]:void 0)}}),addToUnscopables(FIND_INDEX);var ErrorCode=function(e){return e.INVALID_ENGINE="INVALID_ENGINE",e.INVALID_PARAMS="INVALID_PARAMS",e.INVOKED_BEFORE_JOIN_ROOM="INVOKED_BEFORE_JOIN_ROOM",e.INVALID_TOKEN="INVALID_TOKEN",e.EXPIRED_TOKEN="EXPIRED_TOKEN",e.JOIN_ROOM_FAILED="JOIN_ROOM_FAILED",e.UPDATE_TOKEN_WITH_INVALID_TOKEN="UPDATE_TOKEN_WITH_INVALID_TOKEN",e.UPDATE_TOKEN_BEFORE_JOIN="UPDATE_TOKEN_BEFORE_JOIN",e.REPEAT_JOIN="REPEAT_JOIN",e.REPEAT_PUBLISH="REPEAT_PUBLISH",e.REPEAT_PUSH="REPEAT_PUSH",e.REPEAT_PLAY="REPEAT_PLAY",e.PUBLISH_BEFORE_JOIN="PUBLISH_BEFORE_JOIN",e.UNPUBLISH_BEFORE_JOIN="UNPUBLISH_BEFORE_JOIN",e.SUBSCRIBE_BEFORE_JOIN="SUBSCRIBE_BEFORE_JOIN",e.UNSUBSCRIBE_BEFORE_JOIN="UNSUBSCRIBE_BEFORE_JOIN",e.NO_PUBLISH_PERMISSION="NO_PUBLISH_PERMISSION",e.STREAM_NOT_EXIST="STREAM_NOT_EXIST",e.EMPTY_STREAM="EMPTY_STREAM",e.NOT_CONNECTED_YET="NOT_CONNECTED_YET",e.IM_BEFORE_JOIN="IM_BEFORE_JOIN",e.USER_NOT_EXIST="USER_NOT_EXIST",e.ALREADY_IN_ROOM="ALREADY_IN_ROOM",e.KICKED_OUT="KICKED_OUT",e.ROOM_DISMISS="ROOM_DISMISS",e.TOKEN_EXPIRED="TOKEN_EXPIRED",e.DUPLICATE_LOGIN="DUPLICATE_LOGIN",e.INVOKED_BEFORE_CAPTURE="INVOKED_BEFORE_CAPTURE",e.REPEAT_CAPTURE="REPEAT_CAPTURE",e.GET_VIDEO_TRACK_FAILED="GET_VIDEO_TRACK_FAILED",e.GET_AUDIO_TRACK_FAILED="GET_AUDIO_TRACK_FAILED",e.GET_SCREEN_TRACK_FAILED="GET_SCREEN_TRACK_FAILED",e.STREAM_TYPE_NOT_MATCH="STREAM_TYPE_NOT_MATCH",e.CANT_FIND_DOM="CANT_FIND_DOM",e.INVALID_DEVICE_ID="INVALID_DEVICE_ID",e.NO_PERMISSION="NO_PERMISSION",e.NOT_SUPPORTED="NOT_SUPPORTED",e.INTERRUPT="INTERRUPT",e.ICE_SERVER_WRONG="ICE_SERVER_WRONG",e.ESTABLISH_DATACHANNEL_FAILED="ESTABLISH_DATACHANNEL_FAILED",e.LOAD_RESOURCES_FAILED="LOAD_RESOURCES_FAILED",e.SIGNALING_CHANNEL_NOT_OPEN="SIGNALING_CHANNEL_NOT_OPEN",e.TIME_OUT="TIME_OUT",e.REFUSE_OPERATION_IN_DISCONNECT="REFUSE_OPERATION_IN_DISCONNECT",e.ADD_TRANSCEIVER_FAILED="ADD_TRANSCEIVER_FAILED",e.UPDATE_TRACK_FAILED="UPDATE_TRACK_FAILED",e.PUBLISH_FAILED="PUBLISH_FAILED",e.UNPUBLISH_FAILED="UNPUBLISH_FAILED",e.SUBSCRIBE_FAILED="SUBSCRIBE_FAILED",e.UNSUBSCRIBE_FAILED="UNSUBSCRIBE_FAILED",e.OPERATION_CANCEL="OPERATION_CANCEL",e.START_CLOUD_PROXY_AFTER_JOIN="START_CLOUD_PROXY_AFTER_JOIN",e.STOP_CLOUD_PROXY_BEFORE_LEAVE="STOP_CLOUD_PROXY_BEFORE_LEAVE",e.UNEXPECTED_ERROR="UNEXPECTED_ERROR",e.REPEAT_DEVICE_TEST="REPEAT_DEVICE_TEST",e.AUDIO_DEVICE_TEST_FAILED="AUDIO_DEVICE_RECORD_FAILED",e.ALREADY_LOGIN="ALREADY_LOGIN",e.LOGIN_FAILED="LOGIN_FAILED",e.NOT_LOGIN="NOT_LOGIN",e.RTM_DUPLICATE_LOGIN="RTM_DUPLICATE_LOGIN",e.RTM_TOKEN_ERROR="RTM_TOKEN_ERROR",e.USER_MESSAGE_TIMEOUT="USER_MESSAGE_TIMEOUT",e.USER_MESSAGE_BROKEN="USER_MESSAGE_BROKEN",e.USER_MESSAGE_NO_RECEIVER="USER_MESSAGE_NO_RECEIVER",e.USER_MESSAGE_NO_RELAYPATH="USER_MESSAGE_NO_RELAYPATH",e.USER_MESSAGE_SEND_TO_SERVER_ERROR="USER_MESSAGE_SEND_TO_SERVER_ERROR",e.USER_MESSAGE_SERVER_RESPONSE_ERROR="USER_MESSAGE_SERVER_RESPONSE_ERROR",e.USER_MESSAGE_NOT_JOIN="USER_MESSAGE_NOT_JOIN",e.USER_MESSAGE_INIT="USER_MESSAGE_INIT",e.USER_MESSAGE_NO_CONNECTION="USER_MESSAGE_NO_CONNECTION",e.USER_MESSAGE_NOT_LOGIN="USER_MESSAGE_NOT_LOGIN",e.USER_MESSAGE_SERVER_PARAMS_NOTSET="USER_MESSAGE_SERVER_PARAMS_NOTSET",e.USER_MESSAGE_UNKNOWN="USER_MESSAGE_UNKNOWN",e.START_PUBLIC_STREAM_BEFORE_JOIN="START_PUBLIC_STREAM_BEFORE_JOIN",e.RECONNECT_FAILED="RECONNECT_FAILED",e}(ErrorCode||{}),AudioMixingError=function(e){return e[e.AUDIO_MIXING_ERROR_OK=0]="AUDIO_MIXING_ERROR_OK",e[e.AUDIO_MIXING_ERROR_PRELOAD_FAILED=1]="AUDIO_MIXING_ERROR_PRELOAD_FAILED",e[e.AUDIO_MIXING_ERROR_START_FAILED=2]="AUDIO_MIXING_ERROR_START_FAILED",e[e.AUDIO_MIXING_ERROR_ID_NOT_FOUND=3]="AUDIO_MIXING_ERROR_ID_NOT_FOUND",e[e.AUDIO_MIXING_ERROR_SET_POSITION_FAILED=4]="AUDIO_MIXING_ERROR_SET_POSITION_FAILED",e[e.AUDIO_MIXING_ERROR_INVALID_VOLUME=5]="AUDIO_MIXING_ERROR_INVALID_VOLUME",e[e.AUDIO_MIXING_ERROR_LOAD_CONFLICT=6]="AUDIO_MIXING_ERROR_LOAD_CONFLICT",e[e.AUDIO_MIXING_ERROR_ID_TYPE_NOT_MATCH=7]="AUDIO_MIXING_ERROR_ID_TYPE_NOT_MATCH",e[e.AUDIO_MIXING_ERROR_ID_TYPE_INVALID_PITCH=8]="AUDIO_MIXING_ERROR_ID_TYPE_INVALID_PITCH",e[e.AUDIO_MIXING_ERROR_INVALID_AUDIO_TRACK=9]="AUDIO_MIXING_ERROR_INVALID_AUDIO_TRACK",e}(AudioMixingError||{}),SDKError=_createClass((function e(t,r,n){_classCallCheck(this,e),_defineProperty(this,"code",void 0),_defineProperty(this,"message",void 0),_defineProperty(this,"error",void 0),this.code=t,this.message=r,this.error=n})),DESCRIPTORS$4=descriptors,uncurryThis$9=functionUncurryThis,objectKeys$1=objectKeys$4,toIndexedObject$1=toIndexedObject$c,$propertyIsEnumerable$1=objectPropertyIsEnumerable.f,propertyIsEnumerable$1=uncurryThis$9($propertyIsEnumerable$1),push$5=uncurryThis$9([].push),createMethod$1=function(e){return function(t){for(var r,n=toIndexedObject$1(t),i=objectKeys$1(n),o=i.length,a=0,s=[];o>a;)r=i[a++],DESCRIPTORS$4&&!propertyIsEnumerable$1(n,r)||push$5(s,e?[r,n[r]]:n[r]);return s}},objectToArray={entries:createMethod$1(!0),values:createMethod$1(!1)},$$f=_export,$entries=objectToArray.entries;$$f({target:"Object",stat:!0},{entries:function(e){return $entries(e)}});var toIntegerOrInfinity=toIntegerOrInfinity$d,toString$6=toString$m,requireObjectCoercible$3=requireObjectCoercible$d,$RangeError$1=RangeError,stringRepeat=function(e){var t=toString$6(requireObjectCoercible$3(this)),r="",n=toIntegerOrInfinity(e);if(n<0||n==1/0)throw $RangeError$1("Wrong number of repetitions");for(;n>0;(n>>>=1)&&(t+=t))1&n&&(r+=t);return r},uncurryThis$8=functionUncurryThis,toLength$2=toLength$a,toString$5=toString$m,$repeat=stringRepeat,requireObjectCoercible$2=requireObjectCoercible$d,repeat=uncurryThis$8($repeat),stringSlice$4=uncurryThis$8("".slice),ceil=Math.ceil,createMethod=function(e){return function(t,r,n){var i,o,a=toString$5(requireObjectCoercible$2(t)),s=toLength$2(r),c=a.length,u=void 0===n?" ":toString$5(n);return s<=c||""==u?a:((o=repeat(u,ceil((i=s-c)/u.length))).length>i&&(o=stringSlice$4(o,0,i)),e?a+o:o+a)}},stringPad={start:createMethod(!1),end:createMethod(!0)},userAgent=engineUserAgent,stringPadWebkitBug=/Version\/10(?:\.\d+){1,2}(?: [\w./]+)?(?: Mobile\/\w+)? Safari\//.test(userAgent),$$e=_export,$padEnd=stringPad.end,WEBKIT_BUG=stringPadWebkitBug;$$e({target:"String",proto:!0,forced:WEBKIT_BUG},{padEnd:function(e){return $padEnd(this,e,arguments.length>1?arguments[1]:void 0)}});var $$d=_export,parseInt$2=numberParseInt;$$d({target:"Number",stat:!0,forced:Number.parseInt!=parseInt$2},{parseInt:parseInt$2});var anObject$6=anObject$q,iteratorClose=iteratorClose$2,callWithSafeIterationClosing$1=function(e,t,r,n){try{return n?t(anObject$6(r)[0],r[1]):t(r)}catch(t){iteratorClose(e,"throw",t)}},bind$2=functionBindContext,call$6=functionCall,toObject$2=toObject$i,callWithSafeIterationClosing=callWithSafeIterationClosing$1,isArrayIteratorMethod=isArrayIteratorMethod$3,isConstructor=isConstructor$4,lengthOfArrayLike$1=lengthOfArrayLike$m,createProperty=createProperty$5,getIterator$1=getIterator$4,getIteratorMethod$1=getIteratorMethod$5,$Array=Array,arrayFrom$1=function(e){var t=toObject$2(e),r=isConstructor(this),n=arguments.length,i=n>1?arguments[1]:void 0,o=void 0!==i;o&&(i=bind$2(i,n>2?arguments[2]:void 0));var a,s,c,u,l,d,p=getIteratorMethod$1(t),_=0;if(!p||this===$Array&&isArrayIteratorMethod(p))for(a=lengthOfArrayLike$1(t),s=r?new this(a):$Array(a);a>_;_++)d=o?i(t[_],_):t[_],createProperty(s,_,d);else for(l=(u=getIterator$1(t,p)).next,s=r?new this:[];!(c=call$6(l,u)).done;_++)d=o?callWithSafeIterationClosing(u,i,[c.value,_],!0):c.value,createProperty(s,_,d);return s.length=_,s},$$c=_export,from=arrayFrom$1,checkCorrectnessOfIteration=checkCorrectnessOfIteration$4,INCORRECT_ITERATION=!checkCorrectnessOfIteration((function(e){Array.from(e)}));$$c({target:"Array",stat:!0,forced:INCORRECT_ITERATION},{from:from});var log=Math.log,LOG10E=Math.LOG10E,mathLog10=Math.log10||function(e){return log(e)*LOG10E},$$b=_export,log10=mathLog10;$$b({target:"Math",stat:!0},{log10:log10});var $$a=_export,uncurryThis$7=functionUncurryThisClause,getOwnPropertyDescriptor$1=objectGetOwnPropertyDescriptor.f,toLength$1=toLength$a,toString$4=toString$m,notARegExp=notARegexp,requireObjectCoercible$1=requireObjectCoercible$d,correctIsRegExpLogic=correctIsRegexpLogic,nativeStartsWith=uncurryThis$7("".startsWith),stringSlice$3=uncurryThis$7("".slice),min$1=Math.min,CORRECT_IS_REGEXP_LOGIC=correctIsRegExpLogic("startsWith"),MDN_POLYFILL_BUG=!CORRECT_IS_REGEXP_LOGIC&&!!function(){var e=getOwnPropertyDescriptor$1(String.prototype,"startsWith");return e&&!e.writable}();$$a({target:"String",proto:!0,forced:!MDN_POLYFILL_BUG&&!CORRECT_IS_REGEXP_LOGIC},{startsWith:function(e){var t=toString$4(requireObjectCoercible$1(this));notARegExp(e);var r=toLength$1(min$1(arguments.length>1?arguments[1]:void 0,t.length)),n=toString$4(e);return nativeStartsWith?nativeStartsWith(t,n,r):stringSlice$3(t,r,r+n.length)===n}});var getRandomValues,VideoSourceType=function(e){return e[e.VIDEO_SOURCE_TYPE_EXTERNAL=0]="VIDEO_SOURCE_TYPE_EXTERNAL",e[e.VIDEO_SOURCE_TYPE_INTERNAL=1]="VIDEO_SOURCE_TYPE_INTERNAL",e}(VideoSourceType||{}),AudioSourceType=function(e){return e[e.AUDIO_SOURCE_TYPE_EXTERNAL=0]="AUDIO_SOURCE_TYPE_EXTERNAL",e[e.AUDIO_SOURCE_TYPE_INTERNAL=1]="AUDIO_SOURCE_TYPE_INTERNAL",e}(AudioSourceType||{}),UserOfflineReason=function(e){return e[e.QUIT=0]="QUIT",e[e.DROPPED=1]="DROPPED",e[e.SWITCH_TO_INVISIBLE=2]="SWITCH_TO_INVISIBLE",e[e.KICKED_BY_ADMIN=3]="KICKED_BY_ADMIN",e}(UserOfflineReason||{}),ChannelProfile=function(e){return e[e.CHANNEL_PROFILE_COMMUNICATION=0]="CHANNEL_PROFILE_COMMUNICATION",e[e.CHANNEL_PROFILE_LIVE_BROADCASTING=1]="CHANNEL_PROFILE_LIVE_BROADCASTING",e}(ChannelProfile||{}),SubscribeMode=function(e){return e[e.AUTO_SUBSCRIBE_MODE=0]="AUTO_SUBSCRIBE_MODE",e[e.MANUAL_SUBSCRIBE_MODE=1]="MANUAL_SUBSCRIBE_MODE",e}(SubscribeMode||{}),SubscribeState=function(e){return e[e.SUBSCRIBE_SUCC=0]="SUBSCRIBE_SUCC",e[e.SUBSCRIBE_FAIL=1]="SUBSCRIBE_FAIL",e}(SubscribeState||{}),PublishState=function(e){return e[e.PUBLISH_SUCC=0]="PUBLISH_SUCC",e[e.PUBLISH_FAIL=1]="PUBLISH_FAIL",e}(PublishState||{}),MirrorMode=function(e){return e[e.MIRROR_MODE_OFF=0]="MIRROR_MODE_OFF",e[e.MIRROR_MODE_ON=1]="MIRROR_MODE_ON",e}(MirrorMode||{}),VideoRenderMode=function(e){return e[e.RENDER_MODE_HIDDEN=0]="RENDER_MODE_HIDDEN",e[e.RENDER_MODE_FIT=1]="RENDER_MODE_FIT",e}(VideoRenderMode||{}),StreamIndex=function(e){return e[e.STREAM_INDEX_MAIN=0]="STREAM_INDEX_MAIN",e[e.STREAM_INDEX_SCREEN=1]="STREAM_INDEX_SCREEN",e}(StreamIndex||{}),MediaType=function(e){return e[e.AUDIO=1]="AUDIO",e[e.VIDEO=2]="VIDEO",e[e.AUDIO_AND_VIDEO=3]="AUDIO_AND_VIDEO",e}(MediaType||{}),StreamRemoveReason=function(e){return e[e.STREAM_REMOVE_REASON_UNPUBLISH=0]="STREAM_REMOVE_REASON_UNPUBLISH",e[e.STREAM_REMOVE_REASON_PUBLISH_FAILED=1]="STREAM_REMOVE_REASON_PUBLISH_FAILED",e[e.STREAM_REMOVE_REASON_KEEP_LIVE_FAILED=2]="STREAM_REMOVE_REASON_KEEP_LIVE_FAILED",e[e.STREAM_REMOVE_REASON_CLIENT_DISCONNECTED=3]="STREAM_REMOVE_REASON_CLIENT_DISCONNECTED",e[e.STREAM_REMOVE_REASON_REPUBLISH=4]="STREAM_REMOVE_REASON_REPUBLISH",e[e.STREAM_REMOVE_REASON_OTHER=5]="STREAM_REMOVE_REASON_OTHER",e}(StreamRemoveReason||{}),ConnectionState=function(e){return e[e.CONNECTION_START=0]="CONNECTION_START",e[e.CONNECTION_STATE_DISCONNECTED=1]="CONNECTION_STATE_DISCONNECTED",e[e.CONNECTION_STATE_CONNECTING=2]="CONNECTION_STATE_CONNECTING",e[e.CONNECTION_STATE_CONNECTED=3]="CONNECTION_STATE_CONNECTED",e[e.CONNECTION_STATE_RECONNECTING=4]="CONNECTION_STATE_RECONNECTING",e[e.CONNECTION_STATE_RECONNECTED=5]="CONNECTION_STATE_RECONNECTED",e[e.CONNECTION_STATE_LOST=6]="CONNECTION_STATE_LOST",e}(ConnectionState||{}),MirrorType=function(e){return e[e.MIRROR_TYPE_NONE=0]="MIRROR_TYPE_NONE",e[e.MIRROR_TYPE_RENDER=1]="MIRROR_TYPE_RENDER",e}(MirrorType||{}),LogChannel=function(e){return e[e.domestic=0]="domestic",e[e.overseas=1]="overseas",e}(LogChannel||{}),USER_ONLINE_STATUS=function(e){return e[e.OFFLINE=0]="OFFLINE",e[e.ONLINE=1]="ONLINE",e[e.UNREACHABLE=2]="UNREACHABLE",e}(USER_ONLINE_STATUS||{}),PublicStreamType=function(e){return e[e.AUDIO_AND_VIDEO=0]="AUDIO_AND_VIDEO",e[e.AUDIO_ONLY=1]="AUDIO_ONLY",e[e.VIDEO_ONLY=2]="VIDEO_ONLY",e}(PublicStreamType||{}),PublicInterpolationMode=function(e){return e[e.PREV_FRAME=0]="PREV_FRAME",e[e.OTHER_FRAME=1]="OTHER_FRAME",e}(PublicInterpolationMode||{}),SubscribeFallbackOption=function(e){return e[e.DISABLE=0]="DISABLE",e[e.VIDEO_STREAM_LOW=1]="VIDEO_STREAM_LOW",e[e.AUDIO_ONLY=2]="AUDIO_ONLY",e}(SubscribeFallbackOption||{}),RemoteUserPriority=function(e){return e[e.LOW=0]="LOW",e[e.MEDIUM=100]="MEDIUM",e[e.HIGH=200]="HIGH",e}(RemoteUserPriority||{}),NetworkQuality=function(e){return e[e.UNKNOWN=0]="UNKNOWN",e[e.EXCELLENT=1]="EXCELLENT",e[e.GOOD=2]="GOOD",e[e.POOR=3]="POOR",e[e.BAD=4]="BAD",e[e.VBAD=5]="VBAD",e}(NetworkQuality||{}),FallbackOrRecoverReason=function(e){return e[e.Unknown=-1]="Unknown",e[e.SubscribeFallbackByBandwidth=0]="SubscribeFallbackByBandwidth",e[e.SubscribeRecoverByBandwidth=2]="SubscribeRecoverByBandwidth",e}(FallbackOrRecoverReason||{}),RoomProfileType=function(e){return e[e.communication=0]="communication",e[e.chat=5]="chat",e[e.chatRoom=6]="chatRoom",e[e.coHost=9]="coHost",e[e.meeting=16]="meeting",e[e.classRoom=18]="classRoom",e}(RoomProfileType||{}),AudioProfileType=function(e){return e[e.default=0]="default",e[e.fluent=1]="fluent",e[e.standard=2]="standard",e[e.hd=3]="hd",e[e.standardStereo=4]="standardStereo",e[e.hdMono=5]="hdMono",e}(AudioProfileType||{}),RTCAutoPlayPolicy=function(e){return e[e.AUTO_PLAY=0]="AUTO_PLAY",e[e.VIDEO_ONLY=1]="VIDEO_ONLY",e[e.PLAY_MANUALLY=2]="PLAY_MANUALLY",e}(RTCAutoPlayPolicy||{}),rnds8=new Uint8Array(16);function rng(){if(!getRandomValues&&!(getRandomValues="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto)))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return getRandomValues(rnds8)}var REGEX=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;function validate(e){return"string"==typeof e&®EX.test(e)}for(var byteToHex=[],i=0;i<256;++i)byteToHex.push((i+256).toString(16).substr(1));function stringify(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=(byteToHex[e[t+0]]+byteToHex[e[t+1]]+byteToHex[e[t+2]]+byteToHex[e[t+3]]+"-"+byteToHex[e[t+4]]+byteToHex[e[t+5]]+"-"+byteToHex[e[t+6]]+byteToHex[e[t+7]]+"-"+byteToHex[e[t+8]]+byteToHex[e[t+9]]+"-"+byteToHex[e[t+10]]+byteToHex[e[t+11]]+byteToHex[e[t+12]]+byteToHex[e[t+13]]+byteToHex[e[t+14]]+byteToHex[e[t+15]]).toLowerCase();if(!validate(r))throw TypeError("Stringified UUID is invalid");return r}function v4(e,t,r){var n=(e=e||{}).random||(e.rng||rng)();if(n[6]=15&n[6]|64,n[8]=63&n[8]|128,t){r=r||0;for(var i=0;i<16;++i)t[r+i]=n[i];return t}return stringify(n)}var textDecoder=new TextDecoder,textEncoder=new TextEncoder,genUuid=function(){return v4()},getServerNow=function(){return Date.now()};function concatenate(e){for(var t=0,r=arguments.length,n=new Array(r>1?r-1:0),i=1;i<r;i++)n[i-1]=arguments[i];for(var o=0,a=n;o<a.length;o++){var s=a[o];t+=s.length}for(var c=new e(t),u=0,l=0,d=n;l<d.length;l++){var p=d[l];c.set(p,u),u+=p.length}return c}var isSSR=function(){return"undefined"==typeof window},Utils=function(){function e(){_classCallCheck(this,e)}var t,r;return _createClass(e,null,[{key:"token2auth",value:function(t,r,n,i){return i?"Bearer ".concat(i):"Basic ".concat(e.createUnsafeToken(t,r,n))}},{key:"createUnsafeToken",value:function(e,t,r){return window.btoa([e,t,r].filter((function(e){return null!==e})).join(":"))}},{key:"merge",value:function(){for(var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=0,i=Object.entries(t);n<i.length;n++){var o=_slicedToArray(i[n],2),a=o[0],s=o[1];null!==s&&"object"===_typeof(s)?e.merge(t[a],r[a]):void 0!==r[a]&&(t[a]=r[a])}}},{key:"ab2str",value:function(e){return textDecoder.decode(e)}},{key:"ab2obj",value:function(t){try{var r=e.ab2str(t);return JSON.parse(r)}catch(e){return{}}}},{key:"str2ab",value:function(e){return textEncoder.encode(e).buffer}},{key:"ab2b64str",value:(r=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){var r;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,new Promise((function(e){var r=new FileReader;r.onload=function(){return e(r.result)},r.readAsDataURL(new Blob([t]))}));case 2:return r=e.sent,e.abrupt("return",r.split(",",2)[1]);case 4:case"end":return e.stop()}}),e)}))),function(e){return r.apply(this,arguments)})},{key:"b64str2ab",value:(t=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",fetch("data:application/octet;base64,"+t).then((function(e){return e.arrayBuffer()})));case 1:case"end":return e.stop()}}),e)}))),function(e){return t.apply(this,arguments)})}]),e}();function wait(e){return new Promise((function(t){window.setTimeout(t,e)}))}function getBrowser(){var e="none";return isSSR()||(null!==window.navigator.userAgent.match("Firefox")?e="mozilla":null!==window.navigator.userAgent.match("Chrome")?(e="chrome-stable",null!==window.navigator.userAgent.match("Electron")&&(e="electron")):(null!==window.navigator.userAgent.match("Safari")||null!==window.navigator.userAgent.match("AppleWebKit"))&&(e="safari")),e}var isFirefox="mozilla"===getBrowser(),isSafari="safari"===getBrowser(),isMobile=!isSSR()&&navigator.userAgent.toLowerCase().includes("mobile");function createRandomId(){for(var e=(+"".concat(Math.random()).slice(-7).padEnd(7,"0")).toString(2).padEnd(28,"1").split(""),t=[];e.length;)t.push(e.splice(0,7));return t.map((function(e,r){var n=r===t.length-1?"0":"1";return Number.parseInt(n+e.join(""),2)}))}var genEventSessionId=function(){return Math.floor(65535*Math.random())};function isByteId(e){return 128==(128&e)}function isRttMessage(e){return"string"==typeof e&&e.indexOf("__web__rtc__rtt__")>-1}var maxBinaryLength=10;function reportParamsCheck(e){return e.map((function e(t){if(t instanceof HTMLElement)return t.toString();if(t instanceof ArrayBuffer||ArrayBuffer.isView(t)){var r=ArrayBuffer.isView(t)?t.buffer:t,n=r.byteLength,i=[];if(n>maxBinaryLength){var o=new DataView(r),a=Array.from({length:maxBinaryLength/2}).map((function(e,t){return o.getUint8(t)})),s=Array.from({length:maxBinaryLength/2}).map((function(e,t){return n-1-t})).reverse().map((function(e){return o.getUint8(e)}));i=[].concat(_toConsumableArray(a),["..."],_toConsumableArray(s))}else i=Array.from(new Uint8Array(r));return"".concat(t.constructor.name,"(").concat(n,") [").concat(i.join(", "),"]")}if(t instanceof ImageData)return"ImageData";if(Array.isArray(t))return t.map(e);if("[object Object]"===Object.prototype.toString.call(t)){var c={};for(var u in t)c[u]=e(t[u]);return c}return t}))}var createDefaultSdp=function(){var e=_asyncToGenerator(_regeneratorRuntime().mark((function e(){var t,r,n,i=arguments;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=i.length>0&&void 0!==i[0]&&i[0],e.prev=1,(r=new RTCPeerConnection({iceServers:[],iceTransportPolicy:"all",bundlePolicy:"max-bundle",rtcpMuxPolicy:"require",sdpSemantics:"unified-plan"})).createDataChannel("default"),r.addTransceiver("audio",{direction:"recvonly"}),r.addTransceiver("video",{direction:"recvonly"}),t&&(r.addTransceiver("audio",{direction:"sendonly"}),r.addTransceiver("video",{direction:"sendonly"})),e.next=9,r.createOffer();case 9:return n=e.sent,r.close(),e.abrupt("return",n.sdp);case 14:e.prev=14,e.t0=e.catch(1);case 16:case"end":return e.stop()}}),e,null,[[1,14]])})));return function(){return e.apply(this,arguments)}}(),promiseAny=function(e){return new Promise((function(t,r){var n=(e=Array.isArray(e)?e:[]).length,i=[];0===n?r([]):e.forEach((function(e){e.then((function(e){t(e)}),(function(e){n--,i.push(e),0===n&&r(i)}))}))}))};function getNonlinearVolume(e){return+Math.max(-127,10*Math.log10(Math.pow(e/255,2))).toFixed(2)}function audioInMediaType(e){return(e&MediaType.AUDIO)===MediaType.AUDIO}function videoInMediaType(e){return(e&MediaType.VIDEO)===MediaType.VIDEO}function getPublicStats(e){var t={};return Object.keys(e).forEach((function(r){"object"===_typeof(e[r])?t[r]=getPublicStats(e[r]):r.startsWith("_")||(t[r]=e[r])})),t}function splitPublicStreamSei(e){var t=new DataView(e.buffer);if(t.byteLength<=4||65535!==t.getUint16(0))return{seiCount:1,seis:[e]};for(var r={seiCount:0,seis:[]},n=!1,i=2;i<t.byteLength;){var o=t.getUint16(i);if(i+=2,t.byteLength-i<o){n=!0;break}var a=new Uint8Array(e.buffer,i,o);if(i+=o,t.byteLength-i>0&&t.byteLength-i<=2){n=!0;break}r.seiCount++,r.seis.push(a)}return n&&(r.seiCount=1,r.seis=[e]),r}var EngineEventsTypes=function(e){return e.onTrackEnded="onTrackEnded",e.onPlayerEvent="onPlayerEvent",e.onAutoplayFailed="onAutoplayFailed",e.onUserJoined="onUserJoined",e.onUserLeave="onUserLeave",e.onConnectionStateChanged="onConnectionStateChanged",e.onUserPublishStream="onUserPublishStream",e.onUserUnpublishStream="onUserUnpublishStream",e.onUserPublishScreen="onUserPublishScreen",e.onUserUnpublishScreen="onUserUnpublishScreen",e.onRoomMessageReceived="onRoomMessageReceived",e.onRoomBinaryMessageReceived="onRoomBinaryMessageReceived",e.onUserMessageReceived="onUserMessageReceived",e.onUserBinaryMessageReceived="onUserBinaryMessageReceived",e.onVideoFirstFrameRendered="onVideoFirstFrameRendered",e.onVideoFirstFrameDecoded="onVideoFirstFrameDecoded",e.onAudioFirstFrameDecoded="onAudioFirstFrameDecoded",e.onFirstPublicStreamVideoFrameRendered="onFirstPublicStreamVideoFrameRendered",e.onFirstPublicStreamVideoFrameDecoded="onFirstPublicStreamVideoFrameDecoded",e.onFirstPublicStreamAudioFrameDecoded="onFirstPublicStreamAudioFrameDecoded",e.onVideoDeviceStateChanged="onVideoDeviceStateChanged",e.onAudioDeviceStateChanged="onAudioDeviceStateChanged",e.onRemoteStreamStats="onRemoteStreamStats",e.onPublicStreamStats="onPublicStreamStats",e.onLocalStreamStats="onLocalStreamStats",e.onAudioVolumeIndication="onAudioVolumeIndication",e.onLocalAudioPropertiesReport="onLocalAudioPropertiesReport",e.onRemoteAudioPropertiesReport="onRemoteAudioPropertiesReport",e.onActiveSpeaker="onActiveSpeaker",e.onAudioPlaybackDeviceChanged="onAudioPlaybackDeviceChanged",e.onUserStartVideoCapture="onUserStartVideoCapture",e.onUserStopVideoCapture="onUserStopVideoCapture",e.onUserStartAudioCapture="onUserStartAudioCapture",e.onUserStopAudioCapture="onUserStopAudioCapture",e.onAutoPublishResult="onAutoPublishResult",e.onAutoSubscribeResult="onAutoSubscribeResult",e.onLiveTranscodingResult="onLiveTranscodingResult",e.onStreamMixingEvent="onStreamMixingEvent",e.onAudioPlaybackDeviceTestVolume="onAudioPlaybackDeviceTestVolume",e.onSEIMessageReceived="onSEIMessageReceived",e.onError="onError",e.onAudioMixingStateChanged="onAudioMixingStateChanged",e.onUserMessageReceivedOutsideRoom="onUserMessageReceivedOutsideRoom",e.onUserBinaryMessageReceivedOutsideRoom="onUserBinaryMessageReceivedOutsideRoom",e.onTokenWillExpire="onTokenWillExpire",e.onCloudProxyConnected="onCloudProxyConnected",e.onPushPublicStreamResult="onPushPublicStreamResult",e.onPublicStreamSEIMessageReceived="onPublicStreamSEIMessageReceived",e.onNetworkQuality="onNetworkQuality",e.onSimulcastSubscribeFallback="onSimulcastSubscribeFallback",e.onRemoteVideoSizeChanged="onRemoteVideoSizeChanged",e.onVideoStreamBanned="onVideoStreamBanned",e.onAudioStreamBanned="onAudioStreamBanned",e.onLocalVideoSizeChanged="onLocalVideoSizeChanged",e.onServerParamsSetResult="onServerParamsSetResult",e}(EngineEventsTypes||{});function checkBoolean(e,t){if("boolean"!=typeof e)throw new SDKError(ErrorCode.INVALID_PARAMS,"Invalid ".concat(t,": The value should be boolean type."))}function checkNumber(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:Number.POSITIVE_INFINITY;if(e<r||e>n||"number"!=typeof e){var i=new SDKError(ErrorCode.INVALID_PARAMS,"Invalid ".concat(t,": the value range is [").concat(r,", ").concat(n,"]. integer only"));throw i}}function checkString(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:Number.POSITIVE_INFINITY;if(null==e)throw new SDKError(ErrorCode.INVALID_PARAMS,"".concat(t," cannot be empty"));if(!isValidString(e,r,n))throw new SDKError(ErrorCode.INVALID_PARAMS,"Invalid ".concat(t,": The value should be string type. Length of the string: [").concat(r,",").concat(n,"]"))}function checkEnum(e,t,r){if(!r.includes(e))throw new SDKError(ErrorCode.INVALID_PARAMS,"Invalid ".concat(t,": The value can only be set as ").concat(JSON.stringify(r)))}function checkEmpty(e,t){if(isEmpty(e))throw new SDKError(ErrorCode.INVALID_PARAMS,"Invalid ".concat(t,", should not be empty"))}function checkArrayBuffer(e,t){if(!(e instanceof ArrayBuffer))throw new SDKError(ErrorCode.INVALID_PARAMS,"Invalid ".concat(t,", should be ArrayBuffer"))}function checkSupportedConstraints(e){try{for(var t=navigator.mediaDevices.getSupportedConstraints(),r=0,n=Object.keys(e);r<n.length;r++){var i=n[r];t[i]||delete e[i]}}catch(e){}}function isValidString(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:Number.POSITIVE_INFINITY;return"string"==typeof e&&e.length<=r&&e.length>=t}function isEmpty(e){return null==e}function checkRoomId(e){if("string"!=typeof e||!/^[a-zA-Z0-9@._\-]{1,128}$/.test(e))throw new SDKError(ErrorCode.INVALID_PARAMS,"The RoomId must be within 128 bytes. The supported characters: a-z,A-Z,0-9,@,-,_,.")}function checkUserId(e){if("string"!=typeof e||!/^[a-zA-Z0-9@._\-]{1,128}$/.test(e))throw new SDKError(ErrorCode.INVALID_PARAMS,"The userId must be within 128 bytes. The supported characters: a-z,A-Z,0-9,@,-,_,.")}function checkPublicStreamId(e){if("string"!=typeof e||!/^[a-zA-Z0-9@._\-]{1,128}$/.test(e))throw new SDKError(ErrorCode.INVALID_PARAMS,"The publicStreamId must be within 128 bytes. The supported characters: a-z,A-Z,0-9,@,-,_,.")}function illegalBusinessId(e){return"string"!=typeof e}function checkUserInfo(e){checkEmpty(e,"userInfo"),checkUserId(e.userId),isEmpty(e.extraInfo)||checkString(e.extraInfo,"userInfo.extraInfo",1,200)}function checkRoomConfig(e){checkEmpty(e,"roomConfig"),checkBoolean(e.isAutoPublish,"roomConfig.isAutoPublish"),checkBoolean(e.isAutoSubscribeAudio,"roomConfig.isAutoSubscribeAudio"),checkBoolean(e.isAutoSubscribeVideo,"roomConfig.isAutoSubscribeVideo")}function checkVideoPlayerOption(e){checkEmpty(e,"videoPlayerOption")}function checkBufferSize(e){var t,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:64;if(!e||0===(null==e?void 0:e.byteLength))throw new SDKError(ErrorCode.INVALID_PARAMS,"The message cannot be empty");if((null===(t=e instanceof ArrayBuffer?e:Utils.str2ab(JSON.stringify(e)))||void 0===t?void 0:t.byteLength)>1e3*r)throw new SDKError(ErrorCode.INVALID_PARAMS,"The message length must be less than ".concat(r,"K"))}function isReportCallback(e){return![EngineEventsTypes.onRemoteStreamStats,EngineEventsTypes.onLocalStreamStats,EngineEventsTypes.onAudioVolumeIndication,EngineEventsTypes.onLocalAudioPropertiesReport,EngineEventsTypes.onRemoteAudioPropertiesReport].includes(e)}function checkRemoteConfig(e){if("number"!=typeof(null==e?void 0:e.width)||"number"!=typeof(null==e?void 0:e.height))throw new SDKError(ErrorCode.INVALID_PARAMS,"remoteVideoConfig must contain width, height, frameRate")}var wellKnownSymbolWrapped={},wellKnownSymbol$4=wellKnownSymbol$u;wellKnownSymbolWrapped.f=wellKnownSymbol$4;var global$7=global$K,path$1=global$7,path=path$1,hasOwn$7=hasOwnProperty_1,wrappedWellKnownSymbolModule$1=wellKnownSymbolWrapped,defineProperty$2=objectDefineProperty.f,wellKnownSymbolDefine=function(e){var t=path.Symbol||(path.Symbol={});hasOwn$7(t,e)||defineProperty$2(t,e,{value:wrappedWellKnownSymbolModule$1.f(e)})},call$5=functionCall,getBuiltIn$1=getBuiltIn$g,wellKnownSymbol$3=wellKnownSymbol$u,defineBuiltIn$3=defineBuiltIn$j,symbolDefineToPrimitive=function(){var e=getBuiltIn$1("Symbol"),t=e&&e.prototype,r=t&&t.valueOf,n=wellKnownSymbol$3("toPrimitive");t&&!t[n]&&defineBuiltIn$3(t,n,(function(e){return call$5(r,this)}),{arity:1})},$$9=_export,global$6=global$K,call$4=functionCall,uncurryThis$6=functionUncurryThis,DESCRIPTORS$3=descriptors,NATIVE_SYMBOL$2=symbolConstructorDetection,fails$5=fails$U,hasOwn$6=hasOwnProperty_1,isPrototypeOf=objectIsPrototypeOf,anObject$5=anObject$q,toIndexedObject=toIndexedObject$c,toPropertyKey=toPropertyKey$5,$toString$2=toString$m,createPropertyDescriptor$2=createPropertyDescriptor$b,nativeObjectCreate=objectCreate,objectKeys=objectKeys$4,getOwnPropertyNamesModule=objectGetOwnPropertyNames,getOwnPropertyNamesExternal=objectGetOwnPropertyNamesExternal,getOwnPropertySymbolsModule$1=objectGetOwnPropertySymbols,getOwnPropertyDescriptorModule$2=objectGetOwnPropertyDescriptor,definePropertyModule$1=objectDefineProperty,definePropertiesModule=objectDefineProperties,propertyIsEnumerableModule=objectPropertyIsEnumerable,defineBuiltIn$2=defineBuiltIn$j,shared$2=shared$7.exports,sharedKey=sharedKey$4,hiddenKeys=hiddenKeys$6,uid=uid$5,wellKnownSymbol$2=wellKnownSymbol$u,wrappedWellKnownSymbolModule=wellKnownSymbolWrapped,defineWellKnownSymbol=wellKnownSymbolDefine,defineSymbolToPrimitive=symbolDefineToPrimitive,setToStringTag$3=setToStringTag$a,InternalStateModule$3=internalState,$forEach=arrayIteration.forEach,HIDDEN=sharedKey("hidden"),SYMBOL="Symbol",PROTOTYPE="prototype",setInternalState$3=InternalStateModule$3.set,getInternalState=InternalStateModule$3.getterFor(SYMBOL),ObjectPrototype=Object[PROTOTYPE],$Symbol=global$6.Symbol,SymbolPrototype=$Symbol&&$Symbol[PROTOTYPE],TypeError$3=global$6.TypeError,QObject=global$6.QObject,nativeGetOwnPropertyDescriptor=getOwnPropertyDescriptorModule$2.f,nativeDefineProperty=definePropertyModule$1.f,nativeGetOwnPropertyNames=getOwnPropertyNamesExternal.f,nativePropertyIsEnumerable=propertyIsEnumerableModule.f,push$4=uncurryThis$6([].push),AllSymbols=shared$2("symbols"),ObjectPrototypeSymbols=shared$2("op-symbols"),WellKnownSymbolsStore=shared$2("wks"),USE_SETTER=!QObject||!QObject[PROTOTYPE]||!QObject[PROTOTYPE].findChild,setSymbolDescriptor=DESCRIPTORS$3&&fails$5((function(){return 7!=nativeObjectCreate(nativeDefineProperty({},"a",{get:function(){return nativeDefineProperty(this,"a",{value:7}).a}})).a}))?function(e,t,r){var n=nativeGetOwnPropertyDescriptor(ObjectPrototype,t);n&&delete ObjectPrototype[t],nativeDefineProperty(e,t,r),n&&e!==ObjectPrototype&&nativeDefineProperty(ObjectPrototype,t,n)}:nativeDefineProperty,wrap=function(e,t){var r=AllSymbols[e]=nativeObjectCreate(SymbolPrototype);return setInternalState$3(r,{type:SYMBOL,tag:e,description:t}),DESCRIPTORS$3||(r.description=t),r},$defineProperty=function(e,t,r){e===ObjectPrototype&&$defineProperty(ObjectPrototypeSymbols,t,r),anObject$5(e);var n=toPropertyKey(t);return anObject$5(r),hasOwn$6(AllSymbols,n)?(r.enumerable?(hasOwn$6(e,HIDDEN)&&e[HIDDEN][n]&&(e[HIDDEN][n]=!1),r=nativeObjectCreate(r,{enumerable:createPropertyDescriptor$2(0,!1)})):(hasOwn$6(e,HIDDEN)||nativeDefineProperty(e,HIDDEN,createPropertyDescriptor$2(1,{})),e[HIDDEN][n]=!0),setSymbolDescriptor(e,n,r)):nativeDefineProperty(e,n,r)},$defineProperties=function(e,t){anObject$5(e);var r=toIndexedObject(t),n=objectKeys(r).concat($getOwnPropertySymbols(r));return $forEach(n,(function(t){DESCRIPTORS$3&&!call$4($propertyIsEnumerable,r,t)||$defineProperty(e,t,r[t])})),e},$create=function(e,t){return void 0===t?nativeObjectCreate(e):$defineProperties(nativeObjectCreate(e),t)},$propertyIsEnumerable=function(e){var t=toPropertyKey(e),r=call$4(nativePropertyIsEnumerable,this,t);return!(this===ObjectPrototype&&hasOwn$6(AllSymbols,t)&&!hasOwn$6(ObjectPrototypeSymbols,t))&&(!(r||!hasOwn$6(this,t)||!hasOwn$6(AllSymbols,t)||hasOwn$6(this,HIDDEN)&&this[HIDDEN][t])||r)},$getOwnPropertyDescriptor=function(e,t){var r=toIndexedObject(e),n=toPropertyKey(t);if(r!==ObjectPrototype||!hasOwn$6(AllSymbols,n)||hasOwn$6(ObjectPrototypeSymbols,n)){var i=nativeGetOwnPropertyDescriptor(r,n);return!i||!hasOwn$6(AllSymbols,n)||hasOwn$6(r,HIDDEN)&&r[HIDDEN][n]||(i.enumerable=!0),i}},$getOwnPropertyNames=function(e){var t=nativeGetOwnPropertyNames(toIndexedObject(e)),r=[];return $forEach(t,(function(e){hasOwn$6(AllSymbols,e)||hasOwn$6(hiddenKeys,e)||push$4(r,e)})),r},$getOwnPropertySymbols=function(e){var t=e===ObjectPrototype,r=nativeGetOwnPropertyNames(t?ObjectPrototypeSymbols:toIndexedObject(e)),n=[];return $forEach(r,(function(e){!hasOwn$6(AllSymbols,e)||t&&!hasOwn$6(ObjectPrototype,e)||push$4(n,AllSymbols[e])})),n};NATIVE_SYMBOL$2||(defineBuiltIn$2(SymbolPrototype=($Symbol=function(){if(isPrototypeOf(SymbolPrototype,this))throw TypeError$3("Symbol is not a constructor");var e=arguments.length&&void 0!==arguments[0]?$toString$2(arguments[0]):void 0,t=uid(e),r=function(e){this===ObjectPrototype&&call$4(r,ObjectPrototypeSymbols,e),hasOwn$6(this,HIDDEN)&&hasOwn$6(this[HIDDEN],t)&&(this[HIDDEN][t]=!1),setSymbolDescriptor(this,t,createPropertyDescriptor$2(1,e))};return DESCRIPTORS$3&&USE_SETTER&&setSymbolDescriptor(ObjectPrototype,t,{configurable:!0,set:r}),wrap(t,e)})[PROTOTYPE],"toString",(function(){return getInternalState(this).tag})),defineBuiltIn$2($Symbol,"withoutSetter",(function(e){return wrap(uid(e),e)})),propertyIsEnumerableModule.f=$propertyIsEnumerable,definePropertyModule$1.f=$defineProperty,definePropertiesModule.f=$defineProperties,getOwnPropertyDescriptorModule$2.f=$getOwnPropertyDescriptor,getOwnPropertyNamesModule.f=getOwnPropertyNamesExternal.f=$getOwnPropertyNames,getOwnPropertySymbolsModule$1.f=$getOwnPropertySymbols,wrappedWellKnownSymbolModule.f=function(e){return wrap(wellKnownSymbol$2(e),e)},DESCRIPTORS$3&&(nativeDefineProperty(SymbolPrototype,"description",{configurable:!0,get:function(){return getInternalState(this).description}}),defineBuiltIn$2(ObjectPrototype,"propertyIsEnumerable",$propertyIsEnumerable,{unsafe:!0}))),$$9({global:!0,constructor:!0,wrap:!0,forced:!NATIVE_SYMBOL$2,sham:!NATIVE_SYMBOL$2},{Symbol:$Symbol}),$forEach(objectKeys(WellKnownSymbolsStore),(function(e){defineWellKnownSymbol(e)})),$$9({target:SYMBOL,stat:!0,forced:!NATIVE_SYMBOL$2},{useSetter:function(){USE_SETTER=!0},useSimple:function(){USE_SETTER=!1}}),$$9({target:"Object",stat:!0,forced:!NATIVE_SYMBOL$2,sham:!DESCRIPTORS$3},{create:$create,defineProperty:$defineProperty,defineProperties:$defineProperties,getOwnPropertyDescriptor:$getOwnPropertyDescriptor}),$$9({target:"Object",stat:!0,forced:!NATIVE_SYMBOL$2},{getOwnPropertyNames:$getOwnPropertyNames}),defineSymbolToPrimitive(),setToStringTag$3($Symbol,SYMBOL),hiddenKeys[HIDDEN]=!0;var NATIVE_SYMBOL$1=symbolConstructorDetection,symbolRegistryDetection=NATIVE_SYMBOL$1&&!!Symbol.for&&!!Symbol.keyFor,$$8=_export,getBuiltIn=getBuiltIn$g,hasOwn$5=hasOwnProperty_1,toString$3=toString$m,shared$1=shared$7.exports,NATIVE_SYMBOL_REGISTRY$1=symbolRegistryDetection,StringToSymbolRegistry=shared$1("string-to-symbol-registry"),SymbolToStringRegistry$1=shared$1("symbol-to-string-registry");$$8({target:"Symbol",stat:!0,forced:!NATIVE_SYMBOL_REGISTRY$1},{for:function(e){var t=toString$3(e);if(hasOwn$5(StringToSymbolRegistry,t))return StringToSymbolRegistry[t];var r=getBuiltIn("Symbol")(t);return StringToSymbolRegistry[t]=r,SymbolToStringRegistry$1[r]=t,r}});var $$7=_export,hasOwn$4=hasOwnProperty_1,isSymbol=isSymbol$6,tryToString=tryToString$7,shared=shared$7.exports,NATIVE_SYMBOL_REGISTRY=symbolRegistryDetection,SymbolToStringRegistry=shared("symbol-to-string-registry");$$7({target:"Symbol",stat:!0,forced:!NATIVE_SYMBOL_REGISTRY},{keyFor:function(e){if(!isSymbol(e))throw TypeError(tryToString(e)+" is not a symbol");if(hasOwn$4(SymbolToStringRegistry,e))return SymbolToStringRegistry[e]}});var $$6=_export,NATIVE_SYMBOL=symbolConstructorDetection,fails$4=fails$U,getOwnPropertySymbolsModule=objectGetOwnPropertySymbols,toObject$1=toObject$i,FORCED$1=!NATIVE_SYMBOL||fails$4((function(){getOwnPropertySymbolsModule.f(1)}));$$6({target:"Object",stat:!0,forced:FORCED$1},{getOwnPropertySymbols:function(e){var t=getOwnPropertySymbolsModule.f;return t?t(toObject$1(e)):[]}});var eventemitter3={exports:{}};!function(e){var t=Object.prototype.hasOwnProperty,r="~";function n(){}function i(e,t,r){this.fn=e,this.context=t,this.once=r||!1}function o(e,t,n,o,a){if("function"!=typeof n)throw new TypeError("The listener must be a function");var s=new i(n,o||e,a),c=r?r+t:t;return e._events[c]?e._events[c].fn?e._events[c]=[e._events[c],s]:e._events[c].push(s):(e._events[c]=s,e._eventsCount++),e}function a(e,t){0==--e._eventsCount?e._events=new n:delete e._events[t]}function s(){this._events=new n,this._eventsCount=0}Object.create&&(n.prototype=Object.create(null),(new n).__proto__||(r=!1)),s.prototype.eventNames=function(){var e,n,i=[];if(0===this._eventsCount)return i;for(n in e=this._events)t.call(e,n)&&i.push(r?n.slice(1):n);return Object.getOwnPropertySymbols?i.concat(Object.getOwnPropertySymbols(e)):i},s.prototype.listeners=function(e){var t=r?r+e:e,n=this._events[t];if(!n)return[];if(n.fn)return[n.fn];for(var i=0,o=n.length,a=new Array(o);i<o;i++)a[i]=n[i].fn;return a},s.prototype.listenerCount=function(e){var t=r?r+e:e,n=this._events[t];return n?n.fn?1:n.length:0},s.prototype.emit=function(e,t,n,i,o,a){var s=r?r+e:e;if(!this._events[s])return!1;var c,u,l=this._events[s],d=arguments.length;if(l.fn){switch(l.once&&this.removeListener(e,l.fn,void 0,!0),d){case 1:return l.fn.call(l.context),!0;case 2:return l.fn.call(l.context,t),!0;case 3:return l.fn.call(l.context,t,n),!0;case 4:return l.fn.call(l.context,t,n,i),!0;case 5:return l.fn.call(l.context,t,n,i,o),!0;case 6:return l.fn.call(l.context,t,n,i,o,a),!0}for(u=1,c=new Array(d-1);u<d;u++)c[u-1]=arguments[u];l.fn.apply(l.context,c)}else{var p,_=l.length;for(u=0;u<_;u++)switch(l[u].once&&this.removeListener(e,l[u].fn,void 0,!0),d){case 1:l[u].fn.call(l[u].context);break;case 2:l[u].fn.call(l[u].context,t);break;case 3:l[u].fn.call(l[u].context,t,n);break;case 4:l[u].fn.call(l[u].context,t,n,i);break;default:if(!c)for(p=1,c=new Array(d-1);p<d;p++)c[p-1]=arguments[p];l[u].fn.apply(l[u].context,c)}}return!0},s.prototype.on=function(e,t,r){return o(this,e,t,r,!1)},s.prototype.once=function(e,t,r){return o(this,e,t,r,!0)},s.prototype.removeListener=function(e,t,n,i){var o=r?r+e:e;if(!this._events[o])return this;if(!t)return a(this,o),this;var s=this._events[o];if(s.fn)s.fn!==t||i&&!s.once||n&&s.context!==n||a(this,o);else{for(var c=0,u=[],l=s.length;c<l;c++)(s[c].fn!==t||i&&!s[c].once||n&&s[c].context!==n)&&u.push(s[c]);u.length?this._events[o]=1===u.length?u[0]:u:a(this,o)}return this},s.prototype.removeAllListeners=function(e){var t;return e?(t=r?r+e:e,this._events[t]&&a(this,t)):(this._events=new n,this._eventsCount=0),this},s.prototype.off=s.prototype.removeListener,s.prototype.addListener=s.prototype.on,s.prefixed=r,s.EventEmitter=s,e.exports=s}(eventemitter3);var EventEmitter=eventemitter3.exports,HEAD_TEXT="[VERTC]",colorMap=["#0050b3","#0050b3","#0050b3","#0050b3","#0050b3"],enable_log=!isSSR()&&window.location.search.includes("_rtc_debug_"),Logger=function(){function e(t,r,n){_classCallCheck(this,e),_defineProperty(this,"_indent",void 0),_defineProperty(this,"_module",void 0),_defineProperty(this,"_id",void 0),this._module=t,this._indent=r}return _createClass(e,[{key:"print",value:function(e){var t;if(enable_log){for(var r="",n=0;n<this._indent;n++)r+=" ";for(var i=arguments.length,o=new Array(i>1?i-1:0),a=1;a<i;a++)o[a-1]=arguments[a];(t=console).log.apply(t,["%c".concat(HEAD_TEXT).concat(r,"[").concat(this._module,".").concat(e,"] ").concat(o.shift()),"color:".concat(colorMap[this._indent],";")].concat(o))}}}]),e}(),logger$i=new Logger("VERTC",0),EnhancedEventEmitter=function(e){_inherits(n,eventemitter3.exports.EventEmitter);var t,r=_createSuper(n);function n(){return _classCallCheck(this,n),r.apply(this,arguments)}return _createClass(n,[{key:"safeEmit",value:function(e){var t=this.listenerCount(e);try{for(var r,i=arguments.length,o=new Array(i>1?i-1:0),a=1;a<i;a++)o[a-1]=arguments[a];return(r=_get(_getPrototypeOf(n.prototype),"emit",this)).call.apply(r,[this,e].concat(o))}catch(r){return logger$i.print("safaEmit","safeEmit() | event listener threw an error [event:%s]:%o",e,r),Boolean(t)}}},{key:"safeEmitAsPromise",value:(t=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){var r,n,i,o=this,a=arguments;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:for(r=a.length,n=new Array(r>1?r-1:0),i=1;i<r;i++)n[i-1]=a[i];return e.abrupt("return",new Promise((function(e,r){try{o.emit.apply(o,[t].concat(n,[e,r]))}catch(e){logger$i.print("safeEmitAsPromise","safeEmitAsPromise() | event listener threw an error [event:%s]:%o",t,e),r(e)}})));case 2:case"end":return e.stop()}}),e)}))),function(e){return t.apply(this,arguments)})}]),n}(),hasOwn$3=hasOwnProperty_1,isDataDescriptor$2=function(e){return void 0!==e&&(hasOwn$3(e,"value")||hasOwn$3(e,"writable"))},$$5=_export,call$3=functionCall,isObject$5=isObject$s,anObject$4=anObject$q,isDataDescriptor$1=isDataDescriptor$2,getOwnPropertyDescriptorModule$1=objectGetOwnPropertyDescriptor,getPrototypeOf$1=objectGetPrototypeOf;function get(e,t){var r,n,i=arguments.length<3?e:arguments[2];return anObject$4(e)===i?e[t]:(r=getOwnPropertyDescriptorModule$1.f(e,t))?isDataDescriptor$1(r)?r.value:void 0===r.get?void 0:call$3(r.get,i):isObject$5(n=getPrototypeOf$1(e))?get(n,t,i):void 0}$$5({target:"Reflect",stat:!0},{get:get});var $$4=_export,global$5=global$K,setToStringTag$2=setToStringTag$a;$$4({global:!0},{Reflect:{}}),setToStringTag$2(global$5.Reflect,"Reflect",!0);var $$3=_export,call$2=functionCall,anObject$3=anObject$q,isObject$4=isObject$s,isDataDescriptor=isDataDescriptor$2,fails$3=fails$U,definePropertyModule=objectDefineProperty,getOwnPropertyDescriptorModule=objectGetOwnPropertyDescriptor,getPrototypeOf=objectGetPrototypeOf,createPropertyDescriptor$1=createPropertyDescriptor$b;function set(e,t,r){var n,i,o,a=arguments.length<4?e:arguments[3],s=getOwnPropertyDescriptorModule.f(anObject$3(e),t);if(!s){if(isObject$4(i=getPrototypeOf(e)))return set(i,t,r,a);s=createPropertyDescriptor$1(0)}if(isDataDescriptor(s)){if(!1===s.writable||!isObject$4(a))return!1;if(n=getOwnPropertyDescriptorModule.f(a,t)){if(n.get||n.set||!1===n.writable)return!1;n.value=r,definePropertyModule.f(a,t,n)}else definePropertyModule.f(a,t,createPropertyDescriptor$1(0,r))}else{if(void 0===(o=s.set))return!1;call$2(o,a,r)}return!0}var MS_EDGE_BUG=fails$3((function(){var e=function(){},t=definePropertyModule.f(new e,"a",{configurable:!0});return!1!==Reflect.set(e.prototype,"a",1,t)}));$$3({target:"Reflect",stat:!0,forced:MS_EDGE_BUG},{set:set});var $$2=_export,toObject=toObject$i,lengthOfArrayLike=lengthOfArrayLike$m,setArrayLength=arraySetLength,deletePropertyOrThrow=deletePropertyOrThrow$4,doesNotExceedSafeInteger=doesNotExceedSafeInteger$4,INCORRECT_RESULT=1!==[].unshift(0),SILENT_ON_NON_WRITABLE_LENGTH=!function(){try{Object.defineProperty([],"length",{writable:!1}).unshift()}catch(e){return e instanceof TypeError}}();$$2({target:"Array",proto:!0,arity:1,forced:INCORRECT_RESULT||SILENT_ON_NON_WRITABLE_LENGTH},{unshift:function(e){var t=toObject(this),r=lengthOfArrayLike(t),n=arguments.length;if(n){doesNotExceedSafeInteger(r+n);for(var i=r;i--;){var o=i+n;i in t?t[o]=t[i]:deletePropertyOrThrow(t,o)}for(var a=0;a<n;a++)t[a]=arguments[a]}return setArrayLength(t,r+n)}});var createTypedArrayConstructor$1=typedArrayConstructor.exports;createTypedArrayConstructor$1("Uint16",(function(e){return function(t,r,n){return e(this,t,r,n)}}));var createTypedArrayConstructor=typedArrayConstructor.exports;createTypedArrayConstructor("Int32",(function(e){return function(t,r,n){return e(this,t,r,n)}}));var common={};!function(e){var t="undefined"!=typeof Uint8Array&&"undefined"!=typeof Uint16Array&&"undefined"!=typeof Int32Array;function r(e,t){return Object.prototype.hasOwnProperty.call(e,t)}e.assign=function(e){for(var t=Array.prototype.slice.call(arguments,1);t.length;){var n=t.shift();if(n){if("object"!==_typeof(n))throw new TypeError(n+"must be non-object");for(var i in n)r(n,i)&&(e[i]=n[i])}}return e},e.shrinkBuf=function(e,t){return e.length===t?e:e.subarray?e.subarray(0,t):(e.length=t,e)};var n={arraySet:function(e,t,r,n,i){if(t.subarray&&e.subarray)e.set(t.subarray(r,r+n),i);else for(var o=0;o<n;o++)e[i+o]=t[r+o]},flattenChunks:function(e){var t,r,n,i,o,a;for(n=0,t=0,r=e.length;t<r;t++)n+=e[t].length;for(a=new Uint8Array(n),i=0,t=0,r=e.length;t<r;t++)o=e[t],a.set(o,i),i+=o.length;return a}},i={arraySet:function(e,t,r,n,i){for(var o=0;o<n;o++)e[i+o]=t[r+o]},flattenChunks:function(e){return[].concat.apply([],e)}};e.setTyped=function(t){t?(e.Buf8=Uint8Array,e.Buf16=Uint16Array,e.Buf32=Int32Array,e.assign(e,n)):(e.Buf8=Array,e.Buf16=Array,e.Buf32=Array,e.assign(e,i))},e.setTyped(t)}(common);var deflate$4={},deflate$3={},trees$1={},utils$6=common,Z_FIXED$1=4,Z_BINARY=0,Z_TEXT=1,Z_UNKNOWN$1=2;function zero$1(e){for(var t=e.length;--t>=0;)e[t]=0}var STORED_BLOCK=0,STATIC_TREES=1,DYN_TREES=2,MIN_MATCH$1=3,MAX_MATCH$1=258,LENGTH_CODES$1=29,LITERALS$1=256,L_CODES$1=LITERALS$1+1+LENGTH_CODES$1,D_CODES$1=30,BL_CODES$1=19,HEAP_SIZE$1=2*L_CODES$1+1,MAX_BITS$1=15,Buf_size=16,MAX_BL_BITS=7,END_BLOCK=256,REP_3_6=16,REPZ_3_10=17,REPZ_11_138=18,extra_lbits=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0],extra_dbits=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13],extra_blbits=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],bl_order=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],DIST_CODE_LEN=512,static_ltree=new Array(2*(L_CODES$1+2));zero$1(static_ltree);var static_dtree=new Array(2*D_CODES$1);zero$1(static_dtree);var _dist_code=new Array(DIST_CODE_LEN);zero$1(_dist_code);var _length_code=new Array(MAX_MATCH$1-MIN_MATCH$1+1);zero$1(_length_code);var base_length=new Array(LENGTH_CODES$1);zero$1(base_length);var static_l_desc,static_d_desc,static_bl_desc,base_dist=new Array(D_CODES$1);function StaticTreeDesc(e,t,r,n,i){this.static_tree=e,this.extra_bits=t,this.extra_base=r,this.elems=n,this.max_length=i,this.has_stree=e&&e.length}function TreeDesc(e,t){this.dyn_tree=e,this.max_code=0,this.stat_desc=t}function d_code(e){return e<256?_dist_code[e]:_dist_code[256+(e>>>7)]}function put_short(e,t){e.pending_buf[e.pending++]=255&t,e.pending_buf[e.pending++]=t>>>8&255}function send_bits(e,t,r){e.bi_valid>Buf_size-r?(e.bi_buf|=t<<e.bi_valid&65535,put_short(e,e.bi_buf),e.bi_buf=t>>Buf_size-e.bi_valid,e.bi_valid+=r-Buf_size):(e.bi_buf|=t<<e.bi_valid&65535,e.bi_valid+=r)}function send_code(e,t,r){send_bits(e,r[2*t],r[2*t+1])}function bi_reverse(e,t){var r=0;do{r|=1&e,e>>>=1,r<<=1}while(--t>0);return r>>>1}function bi_flush(e){16===e.bi_valid?(put_short(e,e.bi_buf),e.bi_buf=0,e.bi_valid=0):e.bi_valid>=8&&(e.pending_buf[e.pending++]=255&e.bi_buf,e.bi_buf>>=8,e.bi_valid-=8)}function gen_bitlen(e,t){var r,n,i,o,a,s,c=t.dyn_tree,u=t.max_code,l=t.stat_desc.static_tree,d=t.stat_desc.has_stree,p=t.stat_desc.extra_bits,_=t.stat_desc.extra_base,f=t.stat_desc.max_length,h=0;for(o=0;o<=MAX_BITS$1;o++)e.bl_count[o]=0;for(c[2*e.heap[e.heap_max]+1]=0,r=e.heap_max+1;r<HEAP_SIZE$1;r++)(o=c[2*c[2*(n=e.heap[r])+1]+1]+1)>f&&(o=f,h++),c[2*n+1]=o,n>u||(e.bl_count[o]++,a=0,n>=_&&(a=p[n-_]),s=c[2*n],e.opt_len+=s*(o+a),d&&(e.static_len+=s*(l[2*n+1]+a)));if(0!==h){do{for(o=f-1;0===e.bl_count[o];)o--;e.bl_count[o]--,e.bl_count[o+1]+=2,e.bl_count[f]--,h-=2}while(h>0);for(o=f;0!==o;o--)for(n=e.bl_count[o];0!==n;)(i=e.heap[--r])>u||(c[2*i+1]!==o&&(e.opt_len+=(o-c[2*i+1])*c[2*i],c[2*i+1]=o),n--)}}function gen_codes(e,t,r){var n,i,o=new Array(MAX_BITS$1+1),a=0;for(n=1;n<=MAX_BITS$1;n++)o[n]=a=a+r[n-1]<<1;for(i=0;i<=t;i++){var s=e[2*i+1];0!==s&&(e[2*i]=bi_reverse(o[s]++,s))}}function tr_static_init(){var e,t,r,n,i,o=new Array(MAX_BITS$1+1);for(r=0,n=0;n<LENGTH_CODES$1-1;n++)for(base_length[n]=r,e=0;e<1<<extra_lbits[n];e++)_length_code[r++]=n;for(_length_code[r-1]=n,i=0,n=0;n<16;n++)for(base_dist[n]=i,e=0;e<1<<extra_dbits[n];e++)_dist_code[i++]=n;for(i>>=7;n<D_CODES$1;n++)for(base_dist[n]=i<<7,e=0;e<1<<extra_dbits[n]-7;e++)_dist_code[256+i++]=n;for(t=0;t<=MAX_BITS$1;t++)o[t]=0;for(e=0;e<=143;)static_ltree[2*e+1]=8,e++,o[8]++;for(;e<=255;)static_ltree[2*e+1]=9,e++,o[9]++;for(;e<=279;)static_ltree[2*e+1]=7,e++,o[7]++;for(;e<=287;)static_ltree[2*e+1]=8,e++,o[8]++;for(gen_codes(static_ltree,L_CODES$1+1,o),e=0;e<D_CODES$1;e++)static_dtree[2*e+1]=5,static_dtree[2*e]=bi_reverse(e,5);static_l_desc=new StaticTreeDesc(static_ltree,extra_lbits,LITERALS$1+1,L_CODES$1,MAX_BITS$1),static_d_desc=new StaticTreeDesc(static_dtree,extra_dbits,0,D_CODES$1,MAX_BITS$1),static_bl_desc=new StaticTreeDesc(new Array(0),extra_blbits,0,BL_CODES$1,MAX_BL_BITS)}function init_block(e){var t;for(t=0;t<L_CODES$1;t++)e.dyn_ltree[2*t]=0;for(t=0;t<D_CODES$1;t++)e.dyn_dtree[2*t]=0;for(t=0;t<BL_CODES$1;t++)e.bl_tree[2*t]=0;e.dyn_ltree[2*END_BLOCK]=1,e.opt_len=e.static_len=0,e.last_lit=e.matches=0}function bi_windup(e){e.bi_valid>8?put_short(e,e.bi_buf):e.bi_valid>0&&(e.pending_buf[e.pending++]=e.bi_buf),e.bi_buf=0,e.bi_valid=0}function copy_block(e,t,r,n){bi_windup(e),n&&(put_short(e,r),put_short(e,~r)),utils$6.arraySet(e.pending_buf,e.window,t,r,e.pending),e.pending+=r}function smaller(e,t,r,n){var i=2*t,o=2*r;return e[i]<e[o]||e[i]===e[o]&&n[t]<=n[r]}function pqdownheap(e,t,r){for(var n=e.heap[r],i=r<<1;i<=e.heap_len&&(i<e.heap_len&&smaller(t,e.heap[i+1],e.heap[i],e.depth)&&i++,!smaller(t,n,e.heap[i],e.depth));)e.heap[r]=e.heap[i],r=i,i<<=1;e.heap[r]=n}function compress_block(e,t,r){var n,i,o,a,s=0;if(0!==e.last_lit)do{n=e.pending_buf[e.d_buf+2*s]<<8|e.pending_buf[e.d_buf+2*s+1],i=e.pending_buf[e.l_buf+s],s++,0===n?send_code(e,i,t):(send_code(e,(o=_length_code[i])+LITERALS$1+1,t),0!==(a=extra_lbits[o])&&send_bits(e,i-=base_length[o],a),send_code(e,o=d_code(--n),r),0!==(a=extra_dbits[o])&&send_bits(e,n-=base_dist[o],a))}while(s<e.last_lit);send_code(e,END_BLOCK,t)}function build_tree(e,t){var r,n,i,o=t.dyn_tree,a=t.stat_desc.static_tree,s=t.stat_desc.has_stree,c=t.stat_desc.elems,u=-1;for(e.heap_len=0,e.heap_max=HEAP_SIZE$1,r=0;r<c;r++)0!==o[2*r]?(e.heap[++e.heap_len]=u=r,e.depth[r]=0):o[2*r+1]=0;for(;e.heap_len<2;)o[2*(i=e.heap[++e.heap_len]=u<2?++u:0)]=1,e.depth[i]=0,e.opt_len--,s&&(e.static_len-=a[2*i+1]);for(t.max_code=u,r=e.heap_len>>1;r>=1;r--)pqdownheap(e,o,r);i=c;do{r=e.heap[1],e.heap[1]=e.heap[e.heap_len--],pqdownheap(e,o,1),n=e.heap[1],e.heap[--e.heap_max]=r,e.heap[--e.heap_max]=n,o[2*i]=o[2*r]+o[2*n],e.depth[i]=(e.depth[r]>=e.depth[n]?e.depth[r]:e.depth[n])+1,o[2*r+1]=o[2*n+1]=i,e.heap[1]=i++,pqdownheap(e,o,1)}while(e.heap_len>=2);e.heap[--e.heap_max]=e.heap[1],gen_bitlen(e,t),gen_codes(o,u,e.bl_count)}function scan_tree(e,t,r){var n,i,o=-1,a=t[1],s=0,c=7,u=4;for(0===a&&(c=138,u=3),t[2*(r+1)+1]=65535,n=0;n<=r;n++)i=a,a=t[2*(n+1)+1],++s<c&&i===a||(s<u?e.bl_tree[2*i]+=s:0!==i?(i!==o&&e.bl_tree[2*i]++,e.bl_tree[2*REP_3_6]++):s<=10?e.bl_tree[2*REPZ_3_10]++:e.bl_tree[2*REPZ_11_138]++,s=0,o=i,0===a?(c=138,u=3):i===a?(c=6,u=3):(c=7,u=4))}function send_tree(e,t,r){var n,i,o=-1,a=t[1],s=0,c=7,u=4;for(0===a&&(c=138,u=3),n=0;n<=r;n++)if(i=a,a=t[2*(n+1)+1],!(++s<c&&i===a)){if(s<u)do{send_code(e,i,e.bl_tree)}while(0!=--s);else 0!==i?(i!==o&&(send_code(e,i,e.bl_tree),s--),send_code(e,REP_3_6,e.bl_tree),send_bits(e,s-3,2)):s<=10?(send_code(e,REPZ_3_10,e.bl_tree),send_bits(e,s-3,3)):(send_code(e,REPZ_11_138,e.bl_tree),send_bits(e,s-11,7));s=0,o=i,0===a?(c=138,u=3):i===a?(c=6,u=3):(c=7,u=4)}}function build_bl_tree(e){var t;for(scan_tree(e,e.dyn_ltree,e.l_desc.max_code),scan_tree(e,e.dyn_dtree,e.d_desc.max_code),build_tree(e,e.bl_desc),t=BL_CODES$1-1;t>=3&&0===e.bl_tree[2*bl_order[t]+1];t--);return e.opt_len+=3*(t+1)+5+5+4,t}function send_all_trees(e,t,r,n){var i;for(send_bits(e,t-257,5),send_bits(e,r-1,5),send_bits(e,n-4,4),i=0;i<n;i++)send_bits(e,e.bl_tree[2*bl_order[i]+1],3);send_tree(e,e.dyn_ltree,t-1),send_tree(e,e.dyn_dtree,r-1)}function detect_data_type(e){var t,r=4093624447;for(t=0;t<=31;t++,r>>>=1)if(1&r&&0!==e.dyn_ltree[2*t])return Z_BINARY;if(0!==e.dyn_ltree[18]||0!==e.dyn_ltree[20]||0!==e.dyn_ltree[26])return Z_TEXT;for(t=32;t<LITERALS$1;t++)if(0!==e.dyn_ltree[2*t])return Z_TEXT;return Z_BINARY}zero$1(base_dist);var static_init_done=!1;function _tr_init(e){static_init_done||(tr_static_init(),static_init_done=!0),e.l_desc=new TreeDesc(e.dyn_ltree,static_l_desc),e.d_desc=new TreeDesc(e.dyn_dtree,static_d_desc),e.bl_desc=new TreeDesc(e.bl_tree,static_bl_desc),e.bi_buf=0,e.bi_valid=0,init_block(e)}function _tr_stored_block(e,t,r,n){send_bits(e,(STORED_BLOCK<<1)+(n?1:0),3),copy_block(e,t,r,!0)}function _tr_align(e){send_bits(e,STATIC_TREES<<1,3),send_code(e,END_BLOCK,static_ltree),bi_flush(e)}function _tr_flush_block(e,t,r,n){var i,o,a=0;e.level>0?(e.strm.data_type===Z_UNKNOWN$1&&(e.strm.data_type=detect_data_type(e)),build_tree(e,e.l_desc),build_tree(e,e.d_desc),a=build_bl_tree(e),i=e.opt_len+3+7>>>3,(o=e.static_len+3+7>>>3)<=i&&(i=o)):i=o=r+5,r+4<=i&&-1!==t?_tr_stored_block(e,t,r,n):e.strategy===Z_FIXED$1||o===i?(send_bits(e,(STATIC_TREES<<1)+(n?1:0),3),compress_block(e,static_ltree,static_dtree)):(send_bits(e,(DYN_TREES<<1)+(n?1:0),3),send_all_trees(e,e.l_desc.max_code+1,e.d_desc.max_code+1,a+1),compress_block(e,e.dyn_ltree,e.dyn_dtree)),init_block(e),n&&bi_windup(e)}function _tr_tally(e,t,r){return e.pending_buf[e.d_buf+2*e.last_lit]=t>>>8&255,e.pending_buf[e.d_buf+2*e.last_lit+1]=255&t,e.pending_buf[e.l_buf+e.last_lit]=255&r,e.last_lit++,0===t?e.dyn_ltree[2*r]++:(e.matches++,t--,e.dyn_ltree[2*(_length_code[r]+LITERALS$1+1)]++,e.dyn_dtree[2*d_code(t)]++),e.last_lit===e.lit_bufsize-1}function adler32$2(e,t,r,n){for(var i=65535&e|0,o=e>>>16&65535|0,a=0;0!==r;){r-=a=r>2e3?2e3:r;do{o=o+(i=i+t[n++]|0)|0}while(--a);i%=65521,o%=65521}return i|o<<16|0}trees$1._tr_init=_tr_init,trees$1._tr_stored_block=_tr_stored_block,trees$1._tr_flush_block=_tr_flush_block,trees$1._tr_tally=_tr_tally,trees$1._tr_align=_tr_align;var adler32_1=adler32$2;function makeTable(){for(var e,t=[],r=0;r<256;r++){e=r;for(var n=0;n<8;n++)e=1&e?3988292384^e>>>1:e>>>1;t[r]=e}return t}var crcTable=makeTable();function crc32$2(e,t,r,n){var i=crcTable,o=n+r;e^=-1;for(var a=n;a<o;a++)e=e>>>8^i[255&(e^t[a])];return-1^e}var configuration_table,crc32_1=crc32$2,messages={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"},utils$5=common,trees=trees$1,adler32$1=adler32_1,crc32$1=crc32_1,msg$2=messages,Z_NO_FLUSH$1=0,Z_PARTIAL_FLUSH=1,Z_FULL_FLUSH=3,Z_FINISH$2=4,Z_BLOCK$1=5,Z_OK$2=0,Z_STREAM_END$2=1,Z_STREAM_ERROR$1=-2,Z_DATA_ERROR$1=-3,Z_BUF_ERROR$1=-5,Z_DEFAULT_COMPRESSION$1=-1,Z_FILTERED=1,Z_HUFFMAN_ONLY=2,Z_RLE=3,Z_FIXED=4,Z_DEFAULT_STRATEGY$1=0,Z_UNKNOWN=2,Z_DEFLATED$2=8,MAX_MEM_LEVEL=9,MAX_WBITS$1=15,DEF_MEM_LEVEL=8,LENGTH_CODES=29,LITERALS=256,L_CODES=LITERALS+1+LENGTH_CODES,D_CODES=30,BL_CODES=19,HEAP_SIZE=2*L_CODES+1,MAX_BITS=15,MIN_MATCH=3,MAX_MATCH=258,MIN_LOOKAHEAD=MAX_MATCH+MIN_MATCH+1,PRESET_DICT=32,INIT_STATE=42,EXTRA_STATE=69,NAME_STATE=73,COMMENT_STATE=91,HCRC_STATE=103,BUSY_STATE=113,FINISH_STATE=666,BS_NEED_MORE=1,BS_BLOCK_DONE=2,BS_FINISH_STARTED=3,BS_FINISH_DONE=4,OS_CODE=3;function err(e,t){return e.msg=msg$2[t],t}function rank(e){return(e<<1)-(e>4?9:0)}function zero(e){for(var t=e.length;--t>=0;)e[t]=0}function flush_pending(e){var t=e.state,r=t.pending;r>e.avail_out&&(r=e.avail_out),0!==r&&(utils$5.arraySet(e.output,t.pending_buf,t.pending_out,r,e.next_out),e.next_out+=r,t.pending_out+=r,e.total_out+=r,e.avail_out-=r,t.pending-=r,0===t.pending&&(t.pending_out=0))}function flush_block_only(e,t){trees._tr_flush_block(e,e.block_start>=0?e.block_start:-1,e.strstart-e.block_start,t),e.block_start=e.strstart,flush_pending(e.strm)}function put_byte(e,t){e.pending_buf[e.pending++]=t}function putShortMSB(e,t){e.pending_buf[e.pending++]=t>>>8&255,e.pending_buf[e.pending++]=255&t}function read_buf(e,t,r,n){var i=e.avail_in;return i>n&&(i=n),0===i?0:(e.avail_in-=i,utils$5.arraySet(t,e.input,e.next_in,i,r),1===e.state.wrap?e.adler=adler32$1(e.adler,t,i,r):2===e.state.wrap&&(e.adler=crc32$1(e.adler,t,i,r)),e.next_in+=i,e.total_in+=i,i)}function longest_match(e,t){var r,n,i=e.max_chain_length,o=e.strstart,a=e.prev_length,s=e.nice_match,c=e.strstart>e.w_size-MIN_LOOKAHEAD?e.strstart-(e.w_size-MIN_LOOKAHEAD):0,u=e.window,l=e.w_mask,d=e.prev,p=e.strstart+MAX_MATCH,_=u[o+a-1],f=u[o+a];e.prev_length>=e.good_match&&(i>>=2),s>e.lookahead&&(s=e.lookahead);do{if(u[(r=t)+a]===f&&u[r+a-1]===_&&u[r]===u[o]&&u[++r]===u[o+1]){o+=2,r++;do{}while(u[++o]===u[++r]&&u[++o]===u[++r]&&u[++o]===u[++r]&&u[++o]===u[++r]&&u[++o]===u[++r]&&u[++o]===u[++r]&&u[++o]===u[++r]&&u[++o]===u[++r]&&o<p);if(n=MAX_MATCH-(p-o),o=p-MAX_MATCH,n>a){if(e.match_start=t,a=n,n>=s)break;_=u[o+a-1],f=u[o+a]}}}while((t=d[t&l])>c&&0!=--i);return a<=e.lookahead?a:e.lookahead}function fill_window(e){var t,r,n,i,o,a=e.w_size;do{if(i=e.window_size-e.lookahead-e.strstart,e.strstart>=a+(a-MIN_LOOKAHEAD)){utils$5.arraySet(e.window,e.window,a,a,0),e.match_start-=a,e.strstart-=a,e.block_start-=a,t=r=e.hash_size;do{n=e.head[--t],e.head[t]=n>=a?n-a:0}while(--r);t=r=a;do{n=e.prev[--t],e.prev[t]=n>=a?n-a:0}while(--r);i+=a}if(0===e.strm.avail_in)break;if(r=read_buf(e.strm,e.window,e.strstart+e.lookahead,i),e.lookahead+=r,e.lookahead+e.insert>=MIN_MATCH)for(o=e.strstart-e.insert,e.ins_h=e.window[o],e.ins_h=(e.ins_h<<e.hash_shift^e.window[o+1])&e.hash_mask;e.insert&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[o+MIN_MATCH-1])&e.hash_mask,e.prev[o&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=o,o++,e.insert--,!(e.lookahead+e.insert<MIN_MATCH)););}while(e.lookahead<MIN_LOOKAHEAD&&0!==e.strm.avail_in)}function deflate_stored(e,t){var r=65535;for(r>e.pending_buf_size-5&&(r=e.pending_buf_size-5);;){if(e.lookahead<=1){if(fill_window(e),0===e.lookahead&&t===Z_NO_FLUSH$1)return BS_NEED_MORE;if(0===e.lookahead)break}e.strstart+=e.lookahead,e.lookahead=0;var n=e.block_start+r;if((0===e.strstart||e.strstart>=n)&&(e.lookahead=e.strstart-n,e.strstart=n,flush_block_only(e,!1),0===e.strm.avail_out))return BS_NEED_MORE;if(e.strstart-e.block_start>=e.w_size-MIN_LOOKAHEAD&&(flush_block_only(e,!1),0===e.strm.avail_out))return BS_NEED_MORE}return e.insert=0,t===Z_FINISH$2?(flush_block_only(e,!0),0===e.strm.avail_out?BS_FINISH_STARTED:BS_FINISH_DONE):(e.strstart>e.block_start&&(flush_block_only(e,!1),e.strm.avail_out),BS_NEED_MORE)}function deflate_fast(e,t){for(var r,n;;){if(e.lookahead<MIN_LOOKAHEAD){if(fill_window(e),e.lookahead<MIN_LOOKAHEAD&&t===Z_NO_FLUSH$1)return BS_NEED_MORE;if(0===e.lookahead)break}if(r=0,e.lookahead>=MIN_MATCH&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+MIN_MATCH-1])&e.hash_mask,r=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),0!==r&&e.strstart-r<=e.w_size-MIN_LOOKAHEAD&&(e.match_length=longest_match(e,r)),e.match_length>=MIN_MATCH)if(n=trees._tr_tally(e,e.strstart-e.match_start,e.match_length-MIN_MATCH),e.lookahead-=e.match_length,e.match_length<=e.max_lazy_match&&e.lookahead>=MIN_MATCH){e.match_length--;do{e.strstart++,e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+MIN_MATCH-1])&e.hash_mask,r=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart}while(0!=--e.match_length);e.strstart++}else e.strstart+=e.match_length,e.match_length=0,e.ins_h=e.window[e.strstart],e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+1])&e.hash_mask;else n=trees._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++;if(n&&(flush_block_only(e,!1),0===e.strm.avail_out))return BS_NEED_MORE}return e.insert=e.strstart<MIN_MATCH-1?e.strstart:MIN_MATCH-1,t===Z_FINISH$2?(flush_block_only(e,!0),0===e.strm.avail_out?BS_FINISH_STARTED:BS_FINISH_DONE):e.last_lit&&(flush_block_only(e,!1),0===e.strm.avail_out)?BS_NEED_MORE:BS_BLOCK_DONE}function deflate_slow(e,t){for(var r,n,i;;){if(e.lookahead<MIN_LOOKAHEAD){if(fill_window(e),e.lookahead<MIN_LOOKAHEAD&&t===Z_NO_FLUSH$1)return BS_NEED_MORE;if(0===e.lookahead)break}if(r=0,e.lookahead>=MIN_MATCH&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+MIN_MATCH-1])&e.hash_mask,r=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),e.prev_length=e.match_length,e.prev_match=e.match_start,e.match_length=MIN_MATCH-1,0!==r&&e.prev_length<e.max_lazy_match&&e.strstart-r<=e.w_size-MIN_LOOKAHEAD&&(e.match_length=longest_match(e,r),e.match_length<=5&&(e.strategy===Z_FILTERED||e.match_length===MIN_MATCH&&e.strstart-e.match_start>4096)&&(e.match_length=MIN_MATCH-1)),e.prev_length>=MIN_MATCH&&e.match_length<=e.prev_length){i=e.strstart+e.lookahead-MIN_MATCH,n=trees._tr_tally(e,e.strstart-1-e.prev_match,e.prev_length-MIN_MATCH),e.lookahead-=e.prev_length-1,e.prev_length-=2;do{++e.strstart<=i&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+MIN_MATCH-1])&e.hash_mask,r=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart)}while(0!=--e.prev_length);if(e.match_available=0,e.match_length=MIN_MATCH-1,e.strstart++,n&&(flush_block_only(e,!1),0===e.strm.avail_out))return BS_NEED_MORE}else if(e.match_available){if((n=trees._tr_tally(e,0,e.window[e.strstart-1]))&&flush_block_only(e,!1),e.strstart++,e.lookahead--,0===e.strm.avail_out)return BS_NEED_MORE}else e.match_available=1,e.strstart++,e.lookahead--}return e.match_available&&(n=trees._tr_tally(e,0,e.window[e.strstart-1]),e.match_available=0),e.insert=e.strstart<MIN_MATCH-1?e.strstart:MIN_MATCH-1,t===Z_FINISH$2?(flush_block_only(e,!0),0===e.strm.avail_out?BS_FINISH_STARTED:BS_FINISH_DONE):e.last_lit&&(flush_block_only(e,!1),0===e.strm.avail_out)?BS_NEED_MORE:BS_BLOCK_DONE}function deflate_rle(e,t){for(var r,n,i,o,a=e.window;;){if(e.lookahead<=MAX_MATCH){if(fill_window(e),e.lookahead<=MAX_MATCH&&t===Z_NO_FLUSH$1)return BS_NEED_MORE;if(0===e.lookahead)break}if(e.match_length=0,e.lookahead>=MIN_MATCH&&e.strstart>0&&(n=a[i=e.strstart-1])===a[++i]&&n===a[++i]&&n===a[++i]){o=e.strstart+MAX_MATCH;do{}while(n===a[++i]&&n===a[++i]&&n===a[++i]&&n===a[++i]&&n===a[++i]&&n===a[++i]&&n===a[++i]&&n===a[++i]&&i<o);e.match_length=MAX_MATCH-(o-i),e.match_length>e.lookahead&&(e.match_length=e.lookahead)}if(e.match_length>=MIN_MATCH?(r=trees._tr_tally(e,1,e.match_length-MIN_MATCH),e.lookahead-=e.match_length,e.strstart+=e.match_length,e.match_length=0):(r=trees._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++),r&&(flush_block_only(e,!1),0===e.strm.avail_out))return BS_NEED_MORE}return e.insert=0,t===Z_FINISH$2?(flush_block_only(e,!0),0===e.strm.avail_out?BS_FINISH_STARTED:BS_FINISH_DONE):e.last_lit&&(flush_block_only(e,!1),0===e.strm.avail_out)?BS_NEED_MORE:BS_BLOCK_DONE}function deflate_huff(e,t){for(var r;;){if(0===e.lookahead&&(fill_window(e),0===e.lookahead)){if(t===Z_NO_FLUSH$1)return BS_NEED_MORE;break}if(e.match_length=0,r=trees._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++,r&&(flush_block_only(e,!1),0===e.strm.avail_out))return BS_NEED_MORE}return e.insert=0,t===Z_FINISH$2?(flush_block_only(e,!0),0===e.strm.avail_out?BS_FINISH_STARTED:BS_FINISH_DONE):e.last_lit&&(flush_block_only(e,!1),0===e.strm.avail_out)?BS_NEED_MORE:BS_BLOCK_DONE}function Config$1(e,t,r,n,i){this.good_length=e,this.max_lazy=t,this.nice_length=r,this.max_chain=n,this.func=i}function lm_init(e){e.window_size=2*e.w_size,zero(e.head),e.max_lazy_match=configuration_table[e.level].max_lazy,e.good_match=configuration_table[e.level].good_length,e.nice_match=configuration_table[e.level].nice_length,e.max_chain_length=configuration_table[e.level].max_chain,e.strstart=0,e.block_start=0,e.lookahead=0,e.insert=0,e.match_length=e.prev_length=MIN_MATCH-1,e.match_available=0,e.ins_h=0}function DeflateState(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=Z_DEFLATED$2,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new utils$5.Buf16(2*HEAP_SIZE),this.dyn_dtree=new utils$5.Buf16(2*(2*D_CODES+1)),this.bl_tree=new utils$5.Buf16(2*(2*BL_CODES+1)),zero(this.dyn_ltree),zero(this.dyn_dtree),zero(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new utils$5.Buf16(MAX_BITS+1),this.heap=new utils$5.Buf16(2*L_CODES+1),zero(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new utils$5.Buf16(2*L_CODES+1),zero(this.depth),this.l_buf=0,this.lit_bufsize=0,this.last_lit=0,this.d_buf=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}function deflateResetKeep(e){var t;return e&&e.state?(e.total_in=e.total_out=0,e.data_type=Z_UNKNOWN,(t=e.state).pending=0,t.pending_out=0,t.wrap<0&&(t.wrap=-t.wrap),t.status=t.wrap?INIT_STATE:BUSY_STATE,e.adler=2===t.wrap?0:1,t.last_flush=Z_NO_FLUSH$1,trees._tr_init(t),Z_OK$2):err(e,Z_STREAM_ERROR$1)}function deflateReset(e){var t=deflateResetKeep(e);return t===Z_OK$2&&lm_init(e.state),t}function deflateSetHeader(e,t){return e&&e.state?2!==e.state.wrap?Z_STREAM_ERROR$1:(e.state.gzhead=t,Z_OK$2):Z_STREAM_ERROR$1}function deflateInit2(e,t,r,n,i,o){if(!e)return Z_STREAM_ERROR$1;var a=1;if(t===Z_DEFAULT_COMPRESSION$1&&(t=6),n<0?(a=0,n=-n):n>15&&(a=2,n-=16),i<1||i>MAX_MEM_LEVEL||r!==Z_DEFLATED$2||n<8||n>15||t<0||t>9||o<0||o>Z_FIXED)return err(e,Z_STREAM_ERROR$1);8===n&&(n=9);var s=new DeflateState;return e.state=s,s.strm=e,s.wrap=a,s.gzhead=null,s.w_bits=n,s.w_size=1<<s.w_bits,s.w_mask=s.w_size-1,s.hash_bits=i+7,s.hash_size=1<<s.hash_bits,s.hash_mask=s.hash_size-1,s.hash_shift=~~((s.hash_bits+MIN_MATCH-1)/MIN_MATCH),s.window=new utils$5.Buf8(2*s.w_size),s.head=new utils$5.Buf16(s.hash_size),s.prev=new utils$5.Buf16(s.w_size),s.lit_bufsize=1<<i+6,s.pending_buf_size=4*s.lit_bufsize,s.pending_buf=new utils$5.Buf8(s.pending_buf_size),s.d_buf=1*s.lit_bufsize,s.l_buf=3*s.lit_bufsize,s.level=t,s.strategy=o,s.method=r,deflateReset(e)}function deflateInit(e,t){return deflateInit2(e,t,Z_DEFLATED$2,MAX_WBITS$1,DEF_MEM_LEVEL,Z_DEFAULT_STRATEGY$1)}function deflate$2(e,t){var r,n,i,o;if(!e||!e.state||t>Z_BLOCK$1||t<0)return e?err(e,Z_STREAM_ERROR$1):Z_STREAM_ERROR$1;if(n=e.state,!e.output||!e.input&&0!==e.avail_in||n.status===FINISH_STATE&&t!==Z_FINISH$2)return err(e,0===e.avail_out?Z_BUF_ERROR$1:Z_STREAM_ERROR$1);if(n.strm=e,r=n.last_flush,n.last_flush=t,n.status===INIT_STATE)if(2===n.wrap)e.adler=0,put_byte(n,31),put_byte(n,139),put_byte(n,8),n.gzhead?(put_byte(n,(n.gzhead.text?1:0)+(n.gzhead.hcrc?2:0)+(n.gzhead.extra?4:0)+(n.gzhead.name?8:0)+(n.gzhead.comment?16:0)),put_byte(n,255&n.gzhead.time),put_byte(n,n.gzhead.time>>8&255),put_byte(n,n.gzhead.time>>16&255),put_byte(n,n.gzhead.time>>24&255),put_byte(n,9===n.level?2:n.strategy>=Z_HUFFMAN_ONLY||n.level<2?4:0),put_byte(n,255&n.gzhead.os),n.gzhead.extra&&n.gzhead.extra.length&&(put_byte(n,255&n.gzhead.extra.length),put_byte(n,n.gzhead.extra.length>>8&255)),n.gzhead.hcrc&&(e.adler=crc32$1(e.adler,n.pending_buf,n.pending,0)),n.gzindex=0,n.status=EXTRA_STATE):(put_byte(n,0),put_byte(n,0),put_byte(n,0),put_byte(n,0),put_byte(n,0),put_byte(n,9===n.level?2:n.strategy>=Z_HUFFMAN_ONLY||n.level<2?4:0),put_byte(n,OS_CODE),n.status=BUSY_STATE);else{var a=Z_DEFLATED$2+(n.w_bits-8<<4)<<8;a|=(n.strategy>=Z_HUFFMAN_ONLY||n.level<2?0:n.level<6?1:6===n.level?2:3)<<6,0!==n.strstart&&(a|=PRESET_DICT),a+=31-a%31,n.status=BUSY_STATE,putShortMSB(n,a),0!==n.strstart&&(putShortMSB(n,e.adler>>>16),putShortMSB(n,65535&e.adler)),e.adler=1}if(n.status===EXTRA_STATE)if(n.gzhead.extra){for(i=n.pending;n.gzindex<(65535&n.gzhead.extra.length)&&(n.pending!==n.pending_buf_size||(n.gzhead.hcrc&&n.pending>i&&(e.adler=crc32$1(e.adler,n.pending_buf,n.pending-i,i)),flush_pending(e),i=n.pending,n.pending!==n.pending_buf_size));)put_byte(n,255&n.gzhead.extra[n.gzindex]),n.gzindex++;n.gzhead.hcrc&&n.pending>i&&(e.adler=crc32$1(e.adler,n.pending_buf,n.pending-i,i)),n.gzindex===n.gzhead.extra.length&&(n.gzindex=0,n.status=NAME_STATE)}else n.status=NAME_STATE;if(n.status===NAME_STATE)if(n.gzhead.name){i=n.pending;do{if(n.pending===n.pending_buf_size&&(n.gzhead.hcrc&&n.pending>i&&(e.adler=crc32$1(e.adler,n.pending_buf,n.pending-i,i)),flush_pending(e),i=n.pending,n.pending===n.pending_buf_size)){o=1;break}o=n.gzindex<n.gzhead.name.length?255&n.gzhead.name.charCodeAt(n.gzindex++):0,put_byte(n,o)}while(0!==o);n.gzhead.hcrc&&n.pending>i&&(e.adler=crc32$1(e.adler,n.pending_buf,n.pending-i,i)),0===o&&(n.gzindex=0,n.status=COMMENT_STATE)}else n.status=COMMENT_STATE;if(n.status===COMMENT_STATE)if(n.gzhead.comment){i=n.pending;do{if(n.pending===n.pending_buf_size&&(n.gzhead.hcrc&&n.pending>i&&(e.adler=crc32$1(e.adler,n.pending_buf,n.pending-i,i)),flush_pending(e),i=n.pending,n.pending===n.pending_buf_size)){o=1;break}o=n.gzindex<n.gzhead.comment.length?255&n.gzhead.comment.charCodeAt(n.gzindex++):0,put_byte(n,o)}while(0!==o);n.gzhead.hcrc&&n.pending>i&&(e.adler=crc32$1(e.adler,n.pending_buf,n.pending-i,i)),0===o&&(n.status=HCRC_STATE)}else n.status=HCRC_STATE;if(n.status===HCRC_STATE&&(n.gzhead.hcrc?(n.pending+2>n.pending_buf_size&&flush_pending(e),n.pending+2<=n.pending_buf_size&&(put_byte(n,255&e.adler),put_byte(n,e.adler>>8&255),e.adler=0,n.status=BUSY_STATE)):n.status=BUSY_STATE),0!==n.pending){if(flush_pending(e),0===e.avail_out)return n.last_flush=-1,Z_OK$2}else if(0===e.avail_in&&rank(t)<=rank(r)&&t!==Z_FINISH$2)return err(e,Z_BUF_ERROR$1);if(n.status===FINISH_STATE&&0!==e.avail_in)return err(e,Z_BUF_ERROR$1);if(0!==e.avail_in||0!==n.lookahead||t!==Z_NO_FLUSH$1&&n.status!==FINISH_STATE){var s=n.strategy===Z_HUFFMAN_ONLY?deflate_huff(n,t):n.strategy===Z_RLE?deflate_rle(n,t):configuration_table[n.level].func(n,t);if(s!==BS_FINISH_STARTED&&s!==BS_FINISH_DONE||(n.status=FINISH_STATE),s===BS_NEED_MORE||s===BS_FINISH_STARTED)return 0===e.avail_out&&(n.last_flush=-1),Z_OK$2;if(s===BS_BLOCK_DONE&&(t===Z_PARTIAL_FLUSH?trees._tr_align(n):t!==Z_BLOCK$1&&(trees._tr_stored_block(n,0,0,!1),t===Z_FULL_FLUSH&&(zero(n.head),0===n.lookahead&&(n.strstart=0,n.block_start=0,n.insert=0))),flush_pending(e),0===e.avail_out))return n.last_flush=-1,Z_OK$2}return t!==Z_FINISH$2?Z_OK$2:n.wrap<=0?Z_STREAM_END$2:(2===n.wrap?(put_byte(n,255&e.adler),put_byte(n,e.adler>>8&255),put_byte(n,e.adler>>16&255),put_byte(n,e.adler>>24&255),put_byte(n,255&e.total_in),put_byte(n,e.total_in>>8&255),put_byte(n,e.total_in>>16&255),put_byte(n,e.total_in>>24&255)):(putShortMSB(n,e.adler>>>16),putShortMSB(n,65535&e.adler)),flush_pending(e),n.wrap>0&&(n.wrap=-n.wrap),0!==n.pending?Z_OK$2:Z_STREAM_END$2)}function deflateEnd(e){var t;return e&&e.state?(t=e.state.status)!==INIT_STATE&&t!==EXTRA_STATE&&t!==NAME_STATE&&t!==COMMENT_STATE&&t!==HCRC_STATE&&t!==BUSY_STATE&&t!==FINISH_STATE?err(e,Z_STREAM_ERROR$1):(e.state=null,t===BUSY_STATE?err(e,Z_DATA_ERROR$1):Z_OK$2):Z_STREAM_ERROR$1}function deflateSetDictionary(e,t){var r,n,i,o,a,s,c,u,l=t.length;if(!e||!e.state)return Z_STREAM_ERROR$1;if(2===(o=(r=e.state).wrap)||1===o&&r.status!==INIT_STATE||r.lookahead)return Z_STREAM_ERROR$1;for(1===o&&(e.adler=adler32$1(e.adler,t,l,0)),r.wrap=0,l>=r.w_size&&(0===o&&(zero(r.head),r.strstart=0,r.block_start=0,r.insert=0),u=new utils$5.Buf8(r.w_size),utils$5.arraySet(u,t,l-r.w_size,r.w_size,0),t=u,l=r.w_size),a=e.avail_in,s=e.next_in,c=e.input,e.avail_in=l,e.next_in=0,e.input=t,fill_window(r);r.lookahead>=MIN_MATCH;){n=r.strstart,i=r.lookahead-(MIN_MATCH-1);do{r.ins_h=(r.ins_h<<r.hash_shift^r.window[n+MIN_MATCH-1])&r.hash_mask,r.prev[n&r.w_mask]=r.head[r.ins_h],r.head[r.ins_h]=n,n++}while(--i);r.strstart=n,r.lookahead=MIN_MATCH-1,fill_window(r)}return r.strstart+=r.lookahead,r.block_start=r.strstart,r.insert=r.lookahead,r.lookahead=0,r.match_length=r.prev_length=MIN_MATCH-1,r.match_available=0,e.next_in=s,e.input=c,e.avail_in=a,r.wrap=o,Z_OK$2}configuration_table=[new Config$1(0,0,0,0,deflate_stored),new Config$1(4,4,8,4,deflate_fast),new Config$1(4,5,16,8,deflate_fast),new Config$1(4,6,32,32,deflate_fast),new Config$1(4,4,16,16,deflate_slow),new Config$1(8,16,32,32,deflate_slow),new Config$1(8,16,128,128,deflate_slow),new Config$1(8,32,128,256,deflate_slow),new Config$1(32,128,258,1024,deflate_slow),new Config$1(32,258,258,4096,deflate_slow)],deflate$3.deflateInit=deflateInit,deflate$3.deflateInit2=deflateInit2,deflate$3.deflateReset=deflateReset,deflate$3.deflateResetKeep=deflateResetKeep,deflate$3.deflateSetHeader=deflateSetHeader,deflate$3.deflate=deflate$2,deflate$3.deflateEnd=deflateEnd,deflate$3.deflateSetDictionary=deflateSetDictionary,deflate$3.deflateInfo="pako deflate (from Nodeca project)";var strings$2={},utils$4=common,STR_APPLY_OK=!0,STR_APPLY_UIA_OK=!0;try{String.fromCharCode.apply(null,[0])}catch(e){STR_APPLY_OK=!1}try{String.fromCharCode.apply(null,new Uint8Array(1))}catch(e){STR_APPLY_UIA_OK=!1}for(var _utf8len=new utils$4.Buf8(256),q=0;q<256;q++)_utf8len[q]=q>=252?6:q>=248?5:q>=240?4:q>=224?3:q>=192?2:1;function buf2binstring(e,t){if(t<65534&&(e.subarray&&STR_APPLY_UIA_OK||!e.subarray&&STR_APPLY_OK))return String.fromCharCode.apply(null,utils$4.shrinkBuf(e,t));for(var r="",n=0;n<t;n++)r+=String.fromCharCode(e[n]);return r}function ZStream$2(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}_utf8len[254]=_utf8len[254]=1,strings$2.string2buf=function(e){var t,r,n,i,o,a=e.length,s=0;for(i=0;i<a;i++)55296==(64512&(r=e.charCodeAt(i)))&&i+1<a&&56320==(64512&(n=e.charCodeAt(i+1)))&&(r=65536+(r-55296<<10)+(n-56320),i++),s+=r<128?1:r<2048?2:r<65536?3:4;for(t=new utils$4.Buf8(s),o=0,i=0;o<s;i++)55296==(64512&(r=e.charCodeAt(i)))&&i+1<a&&56320==(64512&(n=e.charCodeAt(i+1)))&&(r=65536+(r-55296<<10)+(n-56320),i++),r<128?t[o++]=r:r<2048?(t[o++]=192|r>>>6,t[o++]=128|63&r):r<65536?(t[o++]=224|r>>>12,t[o++]=128|r>>>6&63,t[o++]=128|63&r):(t[o++]=240|r>>>18,t[o++]=128|r>>>12&63,t[o++]=128|r>>>6&63,t[o++]=128|63&r);return t},strings$2.buf2binstring=function(e){return buf2binstring(e,e.length)},strings$2.binstring2buf=function(e){for(var t=new utils$4.Buf8(e.length),r=0,n=t.length;r<n;r++)t[r]=e.charCodeAt(r);return t},strings$2.buf2string=function(e,t){var r,n,i,o,a=t||e.length,s=new Array(2*a);for(n=0,r=0;r<a;)if((i=e[r++])<128)s[n++]=i;else if((o=_utf8len[i])>4)s[n++]=65533,r+=o-1;else{for(i&=2===o?31:3===o?15:7;o>1&&r<a;)i=i<<6|63&e[r++],o--;o>1?s[n++]=65533:i<65536?s[n++]=i:(i-=65536,s[n++]=55296|i>>10&1023,s[n++]=56320|1023&i)}return buf2binstring(s,n)},strings$2.utf8border=function(e,t){var r;for((t=t||e.length)>e.length&&(t=e.length),r=t-1;r>=0&&128==(192&e[r]);)r--;return r<0||0===r?t:r+_utf8len[e[r]]>t?r:t};var zstream=ZStream$2,zlib_deflate=deflate$3,utils$3=common,strings$1=strings$2,msg$1=messages,ZStream$1=zstream,toString$2=Object.prototype.toString,Z_NO_FLUSH=0,Z_FINISH$1=4,Z_OK$1=0,Z_STREAM_END$1=1,Z_SYNC_FLUSH=2,Z_DEFAULT_COMPRESSION=-1,Z_DEFAULT_STRATEGY=0,Z_DEFLATED$1=8;function Deflate(e){if(!(this instanceof Deflate))return new Deflate(e);this.options=utils$3.assign({level:Z_DEFAULT_COMPRESSION,method:Z_DEFLATED$1,chunkSize:16384,windowBits:15,memLevel:8,strategy:Z_DEFAULT_STRATEGY,to:""},e||{});var t=this.options;t.raw&&t.windowBits>0?t.windowBits=-t.windowBits:t.gzip&&t.windowBits>0&&t.windowBits<16&&(t.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new ZStream$1,this.strm.avail_out=0;var r=zlib_deflate.deflateInit2(this.strm,t.level,t.method,t.windowBits,t.memLevel,t.strategy);if(r!==Z_OK$1)throw new Error(msg$1[r]);if(t.header&&zlib_deflate.deflateSetHeader(this.strm,t.header),t.dictionary){var n;if(n="string"==typeof t.dictionary?strings$1.string2buf(t.dictionary):"[object ArrayBuffer]"===toString$2.call(t.dictionary)?new Uint8Array(t.dictionary):t.dictionary,(r=zlib_deflate.deflateSetDictionary(this.strm,n))!==Z_OK$1)throw new Error(msg$1[r]);this._dict_set=!0}}function deflate$1(e,t){var r=new Deflate(t);if(r.push(e,!0),r.err)throw r.msg||msg$1[r.err];return r.result}function deflateRaw(e,t){return(t=t||{}).raw=!0,deflate$1(e,t)}function gzip(e,t){return(t=t||{}).gzip=!0,deflate$1(e,t)}Deflate.prototype.push=function(e,t){var r,n,i=this.strm,o=this.options.chunkSize;if(this.ended)return!1;n=t===~~t?t:!0===t?Z_FINISH$1:Z_NO_FLUSH,"string"==typeof e?i.input=strings$1.string2buf(e):"[object ArrayBuffer]"===toString$2.call(e)?i.input=new Uint8Array(e):i.input=e,i.next_in=0,i.avail_in=i.input.length;do{if(0===i.avail_out&&(i.output=new utils$3.Buf8(o),i.next_out=0,i.avail_out=o),(r=zlib_deflate.deflate(i,n))!==Z_STREAM_END$1&&r!==Z_OK$1)return this.onEnd(r),this.ended=!0,!1;0!==i.avail_out&&(0!==i.avail_in||n!==Z_FINISH$1&&n!==Z_SYNC_FLUSH)||("string"===this.options.to?this.onData(strings$1.buf2binstring(utils$3.shrinkBuf(i.output,i.next_out))):this.onData(utils$3.shrinkBuf(i.output,i.next_out)))}while((i.avail_in>0||0===i.avail_out)&&r!==Z_STREAM_END$1);return n===Z_FINISH$1?(r=zlib_deflate.deflateEnd(this.strm),this.onEnd(r),this.ended=!0,r===Z_OK$1):n!==Z_SYNC_FLUSH||(this.onEnd(Z_OK$1),i.avail_out=0,!0)},Deflate.prototype.onData=function(e){this.chunks.push(e)},Deflate.prototype.onEnd=function(e){e===Z_OK$1&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=utils$3.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg},deflate$4.Deflate=Deflate,deflate$4.deflate=deflate$1,deflate$4.deflateRaw=deflateRaw,deflate$4.gzip=gzip;var inflate$4={},global$4=global$K,DESCRIPTORS$2=descriptors,defineBuiltInAccessor$1=defineBuiltInAccessor$5,regExpFlags=regexpFlags$1,fails$2=fails$U,RegExp$2=global$4.RegExp,RegExpPrototype=RegExp$2.prototype,FORCED=DESCRIPTORS$2&&fails$2((function(){var e=!0;try{RegExp$2(".","d")}catch(t){e=!1}var t={},r="",n=e?"dgimsy":"gimsy",i=function(e,n){Object.defineProperty(t,e,{get:function(){return r+=n,!0}})},o={dotAll:"s",global:"g",ignoreCase:"i",multiline:"m",sticky:"y"};for(var a in e&&(o.hasIndices="d"),o)i(a,o[a]);return Object.getOwnPropertyDescriptor(RegExpPrototype,"flags").get.call(t)!==n||r!==n}));FORCED&&defineBuiltInAccessor$1(RegExpPrototype,"flags",{configurable:!0,get:regExpFlags});var inflate$3={},BAD$1=30,TYPE$1=12,inffast=function(e,t){var r,n,i,o,a,s,c,u,l,d,p,_,f,h,m,y,v,S,g,E,T,b,R,I,$;r=e.state,n=e.next_in,I=e.input,i=n+(e.avail_in-5),o=e.next_out,$=e.output,a=o-(t-e.avail_out),s=o+(e.avail_out-257),c=r.dmax,u=r.wsize,l=r.whave,d=r.wnext,p=r.window,_=r.hold,f=r.bits,h=r.lencode,m=r.distcode,y=(1<<r.lenbits)-1,v=(1<<r.distbits)-1;e:do{f<15&&(_+=I[n++]<<f,f+=8,_+=I[n++]<<f,f+=8),S=h[_&y];t:for(;;){if(_>>>=g=S>>>24,f-=g,0===(g=S>>>16&255))$[o++]=65535&S;else{if(!(16&g)){if(0==(64&g)){S=h[(65535&S)+(_&(1<<g)-1)];continue t}if(32&g){r.mode=TYPE$1;break e}e.msg="invalid literal/length code",r.mode=BAD$1;break e}E=65535&S,(g&=15)&&(f<g&&(_+=I[n++]<<f,f+=8),E+=_&(1<<g)-1,_>>>=g,f-=g),f<15&&(_+=I[n++]<<f,f+=8,_+=I[n++]<<f,f+=8),S=m[_&v];r:for(;;){if(_>>>=g=S>>>24,f-=g,!(16&(g=S>>>16&255))){if(0==(64&g)){S=m[(65535&S)+(_&(1<<g)-1)];continue r}e.msg="invalid distance code",r.mode=BAD$1;break e}if(T=65535&S,f<(g&=15)&&(_+=I[n++]<<f,(f+=8)<g&&(_+=I[n++]<<f,f+=8)),(T+=_&(1<<g)-1)>c){e.msg="invalid distance too far back",r.mode=BAD$1;break e}if(_>>>=g,f-=g,T>(g=o-a)){if((g=T-g)>l&&r.sane){e.msg="invalid distance too far back",r.mode=BAD$1;break e}if(b=0,R=p,0===d){if(b+=u-g,g<E){E-=g;do{$[o++]=p[b++]}while(--g);b=o-T,R=$}}else if(d<g){if(b+=u+d-g,(g-=d)<E){E-=g;do{$[o++]=p[b++]}while(--g);if(b=0,d<E){E-=g=d;do{$[o++]=p[b++]}while(--g);b=o-T,R=$}}}else if(b+=d-g,g<E){E-=g;do{$[o++]=p[b++]}while(--g);b=o-T,R=$}for(;E>2;)$[o++]=R[b++],$[o++]=R[b++],$[o++]=R[b++],E-=3;E&&($[o++]=R[b++],E>1&&($[o++]=R[b++]))}else{b=o-T;do{$[o++]=$[b++],$[o++]=$[b++],$[o++]=$[b++],E-=3}while(E>2);E&&($[o++]=$[b++],E>1&&($[o++]=$[b++]))}break}}break}}while(n<i&&o<s);n-=E=f>>3,_&=(1<<(f-=E<<3))-1,e.next_in=n,e.next_out=o,e.avail_in=n<i?i-n+5:5-(n-i),e.avail_out=o<s?s-o+257:257-(o-s),r.hold=_,r.bits=f},utils$2=common,MAXBITS=15,ENOUGH_LENS$1=852,ENOUGH_DISTS$1=592,CODES$1=0,LENS$1=1,DISTS$1=2,lbase=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0],lext=[16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78],dbase=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0],dext=[16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64],inftrees=function(e,t,r,n,i,o,a,s){var c,u,l,d,p,_,f,h,m,y=s.bits,v=0,S=0,g=0,E=0,T=0,b=0,R=0,I=0,$=0,A=0,C=null,O=0,P=new utils$2.Buf16(MAXBITS+1),k=new utils$2.Buf16(MAXBITS+1),w=null,N=0;for(v=0;v<=MAXBITS;v++)P[v]=0;for(S=0;S<n;S++)P[t[r+S]]++;for(T=y,E=MAXBITS;E>=1&&0===P[E];E--);if(T>E&&(T=E),0===E)return i[o++]=20971520,i[o++]=20971520,s.bits=1,0;for(g=1;g<E&&0===P[g];g++);for(T<g&&(T=g),I=1,v=1;v<=MAXBITS;v++)if(I<<=1,(I-=P[v])<0)return-1;if(I>0&&(e===CODES$1||1!==E))return-1;for(k[1]=0,v=1;v<MAXBITS;v++)k[v+1]=k[v]+P[v];for(S=0;S<n;S++)0!==t[r+S]&&(a[k[t[r+S]]++]=S);if(e===CODES$1?(C=w=a,_=19):e===LENS$1?(C=lbase,O-=257,w=lext,N-=257,_=256):(C=dbase,w=dext,_=-1),A=0,S=0,v=g,p=o,b=T,R=0,l=-1,d=($=1<<T)-1,e===LENS$1&&$>ENOUGH_LENS$1||e===DISTS$1&&$>ENOUGH_DISTS$1)return 1;for(;;){f=v-R,a[S]<_?(h=0,m=a[S]):a[S]>_?(h=w[N+a[S]],m=C[O+a[S]]):(h=96,m=0),c=1<<v-R,g=u=1<<b;do{i[p+(A>>R)+(u-=c)]=f<<24|h<<16|m|0}while(0!==u);for(c=1<<v-1;A&c;)c>>=1;if(0!==c?(A&=c-1,A+=c):A=0,S++,0==--P[v]){if(v===E)break;v=t[r+a[S]]}if(v>T&&(A&d)!==l){for(0===R&&(R=T),p+=g,I=1<<(b=v-R);b+R<E&&!((I-=P[b+R])<=0);)b++,I<<=1;if($+=1<<b,e===LENS$1&&$>ENOUGH_LENS$1||e===DISTS$1&&$>ENOUGH_DISTS$1)return 1;i[l=A&d]=T<<24|b<<16|p-o|0}}return 0!==A&&(i[p+A]=v-R<<24|64<<16|0),s.bits=T,0},utils$1=common,adler32=adler32_1,crc32=crc32_1,inflate_fast=inffast,inflate_table=inftrees,CODES=0,LENS=1,DISTS=2,Z_FINISH=4,Z_BLOCK=5,Z_TREES=6,Z_OK=0,Z_STREAM_END=1,Z_NEED_DICT=2,Z_STREAM_ERROR=-2,Z_DATA_ERROR=-3,Z_MEM_ERROR=-4,Z_BUF_ERROR=-5,Z_DEFLATED=8,HEAD=1,FLAGS=2,TIME=3,OS=4,EXLEN=5,EXTRA=6,NAME=7,COMMENT=8,HCRC=9,DICTID=10,DICT=11,TYPE=12,TYPEDO=13,STORED=14,COPY_=15,COPY=16,TABLE=17,LENLENS=18,CODELENS=19,LEN_=20,LEN=21,LENEXT=22,DIST=23,DISTEXT=24,MATCH=25,LIT=26,CHECK=27,LENGTH=28,DONE=29,BAD=30,MEM=31,SYNC=32,ENOUGH_LENS=852,ENOUGH_DISTS=592,MAX_WBITS=15,DEF_WBITS=MAX_WBITS;function zswap32(e){return(e>>>24&255)+(e>>>8&65280)+((65280&e)<<8)+((255&e)<<24)}function InflateState(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new utils$1.Buf16(320),this.work=new utils$1.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function inflateResetKeep(e){var t;return e&&e.state?(t=e.state,e.total_in=e.total_out=t.total=0,e.msg="",t.wrap&&(e.adler=1&t.wrap),t.mode=HEAD,t.last=0,t.havedict=0,t.dmax=32768,t.head=null,t.hold=0,t.bits=0,t.lencode=t.lendyn=new utils$1.Buf32(ENOUGH_LENS),t.distcode=t.distdyn=new utils$1.Buf32(ENOUGH_DISTS),t.sane=1,t.back=-1,Z_OK):Z_STREAM_ERROR}function inflateReset(e){var t;return e&&e.state?((t=e.state).wsize=0,t.whave=0,t.wnext=0,inflateResetKeep(e)):Z_STREAM_ERROR}function inflateReset2(e,t){var r,n;return e&&e.state?(n=e.state,t<0?(r=0,t=-t):(r=1+(t>>4),t<48&&(t&=15)),t&&(t<8||t>15)?Z_STREAM_ERROR:(null!==n.window&&n.wbits!==t&&(n.window=null),n.wrap=r,n.wbits=t,inflateReset(e))):Z_STREAM_ERROR}function inflateInit2(e,t){var r,n;return e?(n=new InflateState,e.state=n,n.window=null,(r=inflateReset2(e,t))!==Z_OK&&(e.state=null),r):Z_STREAM_ERROR}function inflateInit(e){return inflateInit2(e,DEF_WBITS)}var lenfix,distfix,virgin=!0;function fixedtables(e){if(virgin){var t;for(lenfix=new utils$1.Buf32(512),distfix=new utils$1.Buf32(32),t=0;t<144;)e.lens[t++]=8;for(;t<256;)e.lens[t++]=9;for(;t<280;)e.lens[t++]=7;for(;t<288;)e.lens[t++]=8;for(inflate_table(LENS,e.lens,0,288,lenfix,0,e.work,{bits:9}),t=0;t<32;)e.lens[t++]=5;inflate_table(DISTS,e.lens,0,32,distfix,0,e.work,{bits:5}),virgin=!1}e.lencode=lenfix,e.lenbits=9,e.distcode=distfix,e.distbits=5}function updatewindow(e,t,r,n){var i,o=e.state;return null===o.window&&(o.wsize=1<<o.wbits,o.wnext=0,o.whave=0,o.window=new utils$1.Buf8(o.wsize)),n>=o.wsize?(utils$1.arraySet(o.window,t,r-o.wsize,o.wsize,0),o.wnext=0,o.whave=o.wsize):((i=o.wsize-o.wnext)>n&&(i=n),utils$1.arraySet(o.window,t,r-n,i,o.wnext),(n-=i)?(utils$1.arraySet(o.window,t,r-n,n,0),o.wnext=n,o.whave=o.wsize):(o.wnext+=i,o.wnext===o.wsize&&(o.wnext=0),o.whave<o.wsize&&(o.whave+=i))),0}function inflate$2(e,t){var r,n,i,o,a,s,c,u,l,d,p,_,f,h,m,y,v,S,g,E,T,b,R,I,$=0,A=new utils$1.Buf8(4),C=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];if(!e||!e.state||!e.output||!e.input&&0!==e.avail_in)return Z_STREAM_ERROR;(r=e.state).mode===TYPE&&(r.mode=TYPEDO),a=e.next_out,i=e.output,c=e.avail_out,o=e.next_in,n=e.input,s=e.avail_in,u=r.hold,l=r.bits,d=s,p=c,b=Z_OK;e:for(;;)switch(r.mode){case HEAD:if(0===r.wrap){r.mode=TYPEDO;break}for(;l<16;){if(0===s)break e;s--,u+=n[o++]<<l,l+=8}if(2&r.wrap&&35615===u){r.check=0,A[0]=255&u,A[1]=u>>>8&255,r.check=crc32(r.check,A,2,0),u=0,l=0,r.mode=FLAGS;break}if(r.flags=0,r.head&&(r.head.done=!1),!(1&r.wrap)||(((255&u)<<8)+(u>>8))%31){e.msg="incorrect header check",r.mode=BAD;break}if((15&u)!==Z_DEFLATED){e.msg="unknown compression method",r.mode=BAD;break}if(l-=4,T=8+(15&(u>>>=4)),0===r.wbits)r.wbits=T;else if(T>r.wbits){e.msg="invalid window size",r.mode=BAD;break}r.dmax=1<<T,e.adler=r.check=1,r.mode=512&u?DICTID:TYPE,u=0,l=0;break;case FLAGS:for(;l<16;){if(0===s)break e;s--,u+=n[o++]<<l,l+=8}if(r.flags=u,(255&r.flags)!==Z_DEFLATED){e.msg="unknown compression method",r.mode=BAD;break}if(57344&r.flags){e.msg="unknown header flags set",r.mode=BAD;break}r.head&&(r.head.text=u>>8&1),512&r.flags&&(A[0]=255&u,A[1]=u>>>8&255,r.check=crc32(r.check,A,2,0)),u=0,l=0,r.mode=TIME;case TIME:for(;l<32;){if(0===s)break e;s--,u+=n[o++]<<l,l+=8}r.head&&(r.head.time=u),512&r.flags&&(A[0]=255&u,A[1]=u>>>8&255,A[2]=u>>>16&255,A[3]=u>>>24&255,r.check=crc32(r.check,A,4,0)),u=0,l=0,r.mode=OS;case OS:for(;l<16;){if(0===s)break e;s--,u+=n[o++]<<l,l+=8}r.head&&(r.head.xflags=255&u,r.head.os=u>>8),512&r.flags&&(A[0]=255&u,A[1]=u>>>8&255,r.check=crc32(r.check,A,2,0)),u=0,l=0,r.mode=EXLEN;case EXLEN:if(1024&r.flags){for(;l<16;){if(0===s)break e;s--,u+=n[o++]<<l,l+=8}r.length=u,r.head&&(r.head.extra_len=u),512&r.flags&&(A[0]=255&u,A[1]=u>>>8&255,r.check=crc32(r.check,A,2,0)),u=0,l=0}else r.head&&(r.head.extra=null);r.mode=EXTRA;case EXTRA:if(1024&r.flags&&((_=r.length)>s&&(_=s),_&&(r.head&&(T=r.head.extra_len-r.length,r.head.extra||(r.head.extra=new Array(r.head.extra_len)),utils$1.arraySet(r.head.extra,n,o,_,T)),512&r.flags&&(r.check=crc32(r.check,n,_,o)),s-=_,o+=_,r.length-=_),r.length))break e;r.length=0,r.mode=NAME;case NAME:if(2048&r.flags){if(0===s)break e;_=0;do{T=n[o+_++],r.head&&T&&r.length<65536&&(r.head.name+=String.fromCharCode(T))}while(T&&_<s);if(512&r.flags&&(r.check=crc32(r.check,n,_,o)),s-=_,o+=_,T)break e}else r.head&&(r.head.name=null);r.length=0,r.mode=COMMENT;case COMMENT:if(4096&r.flags){if(0===s)break e;_=0;do{T=n[o+_++],r.head&&T&&r.length<65536&&(r.head.comment+=String.fromCharCode(T))}while(T&&_<s);if(512&r.flags&&(r.check=crc32(r.check,n,_,o)),s-=_,o+=_,T)break e}else r.head&&(r.head.comment=null);r.mode=HCRC;case HCRC:if(512&r.flags){for(;l<16;){if(0===s)break e;s--,u+=n[o++]<<l,l+=8}if(u!==(65535&r.check)){e.msg="header crc mismatch",r.mode=BAD;break}u=0,l=0}r.head&&(r.head.hcrc=r.flags>>9&1,r.head.done=!0),e.adler=r.check=0,r.mode=TYPE;break;case DICTID:for(;l<32;){if(0===s)break e;s--,u+=n[o++]<<l,l+=8}e.adler=r.check=zswap32(u),u=0,l=0,r.mode=DICT;case DICT:if(0===r.havedict)return e.next_out=a,e.avail_out=c,e.next_in=o,e.avail_in=s,r.hold=u,r.bits=l,Z_NEED_DICT;e.adler=r.check=1,r.mode=TYPE;case TYPE:if(t===Z_BLOCK||t===Z_TREES)break e;case TYPEDO:if(r.last){u>>>=7&l,l-=7&l,r.mode=CHECK;break}for(;l<3;){if(0===s)break e;s--,u+=n[o++]<<l,l+=8}switch(r.last=1&u,l-=1,3&(u>>>=1)){case 0:r.mode=STORED;break;case 1:if(fixedtables(r),r.mode=LEN_,t===Z_TREES){u>>>=2,l-=2;break e}break;case 2:r.mode=TABLE;break;case 3:e.msg="invalid block type",r.mode=BAD}u>>>=2,l-=2;break;case STORED:for(u>>>=7&l,l-=7&l;l<32;){if(0===s)break e;s--,u+=n[o++]<<l,l+=8}if((65535&u)!=(u>>>16^65535)){e.msg="invalid stored block lengths",r.mode=BAD;break}if(r.length=65535&u,u=0,l=0,r.mode=COPY_,t===Z_TREES)break e;case COPY_:r.mode=COPY;case COPY:if(_=r.length){if(_>s&&(_=s),_>c&&(_=c),0===_)break e;utils$1.arraySet(i,n,o,_,a),s-=_,o+=_,c-=_,a+=_,r.length-=_;break}r.mode=TYPE;break;case TABLE:for(;l<14;){if(0===s)break e;s--,u+=n[o++]<<l,l+=8}if(r.nlen=257+(31&u),u>>>=5,l-=5,r.ndist=1+(31&u),u>>>=5,l-=5,r.ncode=4+(15&u),u>>>=4,l-=4,r.nlen>286||r.ndist>30){e.msg="too many length or distance symbols",r.mode=BAD;break}r.have=0,r.mode=LENLENS;case LENLENS:for(;r.have<r.ncode;){for(;l<3;){if(0===s)break e;s--,u+=n[o++]<<l,l+=8}r.lens[C[r.have++]]=7&u,u>>>=3,l-=3}for(;r.have<19;)r.lens[C[r.have++]]=0;if(r.lencode=r.lendyn,r.lenbits=7,R={bits:r.lenbits},b=inflate_table(CODES,r.lens,0,19,r.lencode,0,r.work,R),r.lenbits=R.bits,b){e.msg="invalid code lengths set",r.mode=BAD;break}r.have=0,r.mode=CODELENS;case CODELENS:for(;r.have<r.nlen+r.ndist;){for(;y=($=r.lencode[u&(1<<r.lenbits)-1])>>>16&255,v=65535&$,!((m=$>>>24)<=l);){if(0===s)break e;s--,u+=n[o++]<<l,l+=8}if(v<16)u>>>=m,l-=m,r.lens[r.have++]=v;else{if(16===v){for(I=m+2;l<I;){if(0===s)break e;s--,u+=n[o++]<<l,l+=8}if(u>>>=m,l-=m,0===r.have){e.msg="invalid bit length repeat",r.mode=BAD;break}T=r.lens[r.have-1],_=3+(3&u),u>>>=2,l-=2}else if(17===v){for(I=m+3;l<I;){if(0===s)break e;s--,u+=n[o++]<<l,l+=8}l-=m,T=0,_=3+(7&(u>>>=m)),u>>>=3,l-=3}else{for(I=m+7;l<I;){if(0===s)break e;s--,u+=n[o++]<<l,l+=8}l-=m,T=0,_=11+(127&(u>>>=m)),u>>>=7,l-=7}if(r.have+_>r.nlen+r.ndist){e.msg="invalid bit length repeat",r.mode=BAD;break}for(;_--;)r.lens[r.have++]=T}}if(r.mode===BAD)break;if(0===r.lens[256]){e.msg="invalid code -- missing end-of-block",r.mode=BAD;break}if(r.lenbits=9,R={bits:r.lenbits},b=inflate_table(LENS,r.lens,0,r.nlen,r.lencode,0,r.work,R),r.lenbits=R.bits,b){e.msg="invalid literal/lengths set",r.mode=BAD;break}if(r.distbits=6,r.distcode=r.distdyn,R={bits:r.distbits},b=inflate_table(DISTS,r.lens,r.nlen,r.ndist,r.distcode,0,r.work,R),r.distbits=R.bits,b){e.msg="invalid distances set",r.mode=BAD;break}if(r.mode=LEN_,t===Z_TREES)break e;case LEN_:r.mode=LEN;case LEN:if(s>=6&&c>=258){e.next_out=a,e.avail_out=c,e.next_in=o,e.avail_in=s,r.hold=u,r.bits=l,inflate_fast(e,p),a=e.next_out,i=e.output,c=e.avail_out,o=e.next_in,n=e.input,s=e.avail_in,u=r.hold,l=r.bits,r.mode===TYPE&&(r.back=-1);break}for(r.back=0;y=($=r.lencode[u&(1<<r.lenbits)-1])>>>16&255,v=65535&$,!((m=$>>>24)<=l);){if(0===s)break e;s--,u+=n[o++]<<l,l+=8}if(y&&0==(240&y)){for(S=m,g=y,E=v;y=($=r.lencode[E+((u&(1<<S+g)-1)>>S)])>>>16&255,v=65535&$,!(S+(m=$>>>24)<=l);){if(0===s)break e;s--,u+=n[o++]<<l,l+=8}u>>>=S,l-=S,r.back+=S}if(u>>>=m,l-=m,r.back+=m,r.length=v,0===y){r.mode=LIT;break}if(32&y){r.back=-1,r.mode=TYPE;break}if(64&y){e.msg="invalid literal/length code",r.mode=BAD;break}r.extra=15&y,r.mode=LENEXT;case LENEXT:if(r.extra){for(I=r.extra;l<I;){if(0===s)break e;s--,u+=n[o++]<<l,l+=8}r.length+=u&(1<<r.extra)-1,u>>>=r.extra,l-=r.extra,r.back+=r.extra}r.was=r.length,r.mode=DIST;case DIST:for(;y=($=r.distcode[u&(1<<r.distbits)-1])>>>16&255,v=65535&$,!((m=$>>>24)<=l);){if(0===s)break e;s--,u+=n[o++]<<l,l+=8}if(0==(240&y)){for(S=m,g=y,E=v;y=($=r.distcode[E+((u&(1<<S+g)-1)>>S)])>>>16&255,v=65535&$,!(S+(m=$>>>24)<=l);){if(0===s)break e;s--,u+=n[o++]<<l,l+=8}u>>>=S,l-=S,r.back+=S}if(u>>>=m,l-=m,r.back+=m,64&y){e.msg="invalid distance code",r.mode=BAD;break}r.offset=v,r.extra=15&y,r.mode=DISTEXT;case DISTEXT:if(r.extra){for(I=r.extra;l<I;){if(0===s)break e;s--,u+=n[o++]<<l,l+=8}r.offset+=u&(1<<r.extra)-1,u>>>=r.extra,l-=r.extra,r.back+=r.extra}if(r.offset>r.dmax){e.msg="invalid distance too far back",r.mode=BAD;break}r.mode=MATCH;case MATCH:if(0===c)break e;if(_=p-c,r.offset>_){if((_=r.offset-_)>r.whave&&r.sane){e.msg="invalid distance too far back",r.mode=BAD;break}_>r.wnext?(_-=r.wnext,f=r.wsize-_):f=r.wnext-_,_>r.length&&(_=r.length),h=r.window}else h=i,f=a-r.offset,_=r.length;_>c&&(_=c),c-=_,r.length-=_;do{i[a++]=h[f++]}while(--_);0===r.length&&(r.mode=LEN);break;case LIT:if(0===c)break e;i[a++]=r.length,c--,r.mode=LEN;break;case CHECK:if(r.wrap){for(;l<32;){if(0===s)break e;s--,u|=n[o++]<<l,l+=8}if(p-=c,e.total_out+=p,r.total+=p,p&&(e.adler=r.check=r.flags?crc32(r.check,i,p,a-p):adler32(r.check,i,p,a-p)),p=c,(r.flags?u:zswap32(u))!==r.check){e.msg="incorrect data check",r.mode=BAD;break}u=0,l=0}r.mode=LENGTH;case LENGTH:if(r.wrap&&r.flags){for(;l<32;){if(0===s)break e;s--,u+=n[o++]<<l,l+=8}if(u!==(4294967295&r.total)){e.msg="incorrect length check",r.mode=BAD;break}u=0,l=0}r.mode=DONE;case DONE:b=Z_STREAM_END;break e;case BAD:b=Z_DATA_ERROR;break e;case MEM:return Z_MEM_ERROR;default:return Z_STREAM_ERROR}return e.next_out=a,e.avail_out=c,e.next_in=o,e.avail_in=s,r.hold=u,r.bits=l,(r.wsize||p!==e.avail_out&&r.mode<BAD&&(r.mode<CHECK||t!==Z_FINISH))&&updatewindow(e,e.output,e.next_out,p-e.avail_out),d-=e.avail_in,p-=e.avail_out,e.total_in+=d,e.total_out+=p,r.total+=p,r.wrap&&p&&(e.adler=r.check=r.flags?crc32(r.check,i,p,e.next_out-p):adler32(r.check,i,p,e.next_out-p)),e.data_type=r.bits+(r.last?64:0)+(r.mode===TYPE?128:0)+(r.mode===LEN_||r.mode===COPY_?256:0),(0===d&&0===p||t===Z_FINISH)&&b===Z_OK&&(b=Z_BUF_ERROR),b}function inflateEnd(e){if(!e||!e.state)return Z_STREAM_ERROR;var t=e.state;return t.window&&(t.window=null),e.state=null,Z_OK}function inflateGetHeader(e,t){var r;return e&&e.state?0==(2&(r=e.state).wrap)?Z_STREAM_ERROR:(r.head=t,t.done=!1,Z_OK):Z_STREAM_ERROR}function inflateSetDictionary(e,t){var r,n=t.length;return e&&e.state?0!==(r=e.state).wrap&&r.mode!==DICT?Z_STREAM_ERROR:r.mode===DICT&&adler32(1,t,n,0)!==r.check?Z_DATA_ERROR:updatewindow(e,t,n,n)?(r.mode=MEM,Z_MEM_ERROR):(r.havedict=1,Z_OK):Z_STREAM_ERROR}inflate$3.inflateReset=inflateReset,inflate$3.inflateReset2=inflateReset2,inflate$3.inflateResetKeep=inflateResetKeep,inflate$3.inflateInit=inflateInit,inflate$3.inflateInit2=inflateInit2,inflate$3.inflate=inflate$2,inflate$3.inflateEnd=inflateEnd,inflate$3.inflateGetHeader=inflateGetHeader,inflate$3.inflateSetDictionary=inflateSetDictionary,inflate$3.inflateInfo="pako inflate (from Nodeca project)";var constants$1={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8};function GZheader$1(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1}var gzheader=GZheader$1,zlib_inflate=inflate$3,utils=common,strings=strings$2,c=constants$1,msg=messages,ZStream=zstream,GZheader=gzheader,toString$1=Object.prototype.toString;function Inflate(e){if(!(this instanceof Inflate))return new Inflate(e);this.options=utils.assign({chunkSize:16384,windowBits:0,to:""},e||{});var t=this.options;t.raw&&t.windowBits>=0&&t.windowBits<16&&(t.windowBits=-t.windowBits,0===t.windowBits&&(t.windowBits=-15)),!(t.windowBits>=0&&t.windowBits<16)||e&&e.windowBits||(t.windowBits+=32),t.windowBits>15&&t.windowBits<48&&0==(15&t.windowBits)&&(t.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new ZStream,this.strm.avail_out=0;var r=zlib_inflate.inflateInit2(this.strm,t.windowBits);if(r!==c.Z_OK)throw new Error(msg[r]);if(this.header=new GZheader,zlib_inflate.inflateGetHeader(this.strm,this.header),t.dictionary&&("string"==typeof t.dictionary?t.dictionary=strings.string2buf(t.dictionary):"[object ArrayBuffer]"===toString$1.call(t.dictionary)&&(t.dictionary=new Uint8Array(t.dictionary)),t.raw&&(r=zlib_inflate.inflateSetDictionary(this.strm,t.dictionary))!==c.Z_OK))throw new Error(msg[r])}function inflate$1(e,t){var r=new Inflate(t);if(r.push(e,!0),r.err)throw r.msg||msg[r.err];return r.result}function inflateRaw(e,t){return(t=t||{}).raw=!0,inflate$1(e,t)}Inflate.prototype.push=function(e,t){var r,n,i,o,a,s=this.strm,u=this.options.chunkSize,l=this.options.dictionary,d=!1;if(this.ended)return!1;n=t===~~t?t:!0===t?c.Z_FINISH:c.Z_NO_FLUSH,"string"==typeof e?s.input=strings.binstring2buf(e):"[object ArrayBuffer]"===toString$1.call(e)?s.input=new Uint8Array(e):s.input=e,s.next_in=0,s.avail_in=s.input.length;do{if(0===s.avail_out&&(s.output=new utils.Buf8(u),s.next_out=0,s.avail_out=u),(r=zlib_inflate.inflate(s,c.Z_NO_FLUSH))===c.Z_NEED_DICT&&l&&(r=zlib_inflate.inflateSetDictionary(this.strm,l)),r===c.Z_BUF_ERROR&&!0===d&&(r=c.Z_OK,d=!1),r!==c.Z_STREAM_END&&r!==c.Z_OK)return this.onEnd(r),this.ended=!0,!1;s.next_out&&(0!==s.avail_out&&r!==c.Z_STREAM_END&&(0!==s.avail_in||n!==c.Z_FINISH&&n!==c.Z_SYNC_FLUSH)||("string"===this.options.to?(i=strings.utf8border(s.output,s.next_out),o=s.next_out-i,a=strings.buf2string(s.output,i),s.next_out=o,s.avail_out=u-o,o&&utils.arraySet(s.output,s.output,i,o,0),this.onData(a)):this.onData(utils.shrinkBuf(s.output,s.next_out)))),0===s.avail_in&&0===s.avail_out&&(d=!0)}while((s.avail_in>0||0===s.avail_out)&&r!==c.Z_STREAM_END);return r===c.Z_STREAM_END&&(n=c.Z_FINISH),n===c.Z_FINISH?(r=zlib_inflate.inflateEnd(this.strm),this.onEnd(r),this.ended=!0,r===c.Z_OK):n!==c.Z_SYNC_FLUSH||(this.onEnd(c.Z_OK),s.avail_out=0,!0)},Inflate.prototype.onData=function(e){this.chunks.push(e)},Inflate.prototype.onEnd=function(e){e===c.Z_OK&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=utils.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg},inflate$4.Inflate=Inflate,inflate$4.inflate=inflate$1,inflate$4.inflateRaw=inflateRaw,inflate$4.ungzip=inflate$1;var assign$1=common.assign,deflate=deflate$4,inflate=inflate$4,constants=constants$1,pako={};assign$1(pako,deflate,inflate,constants);var pako_1=pako,CommonProductLine=function(e){return e.RTC="rtc",e}(CommonProductLine||{}),CommonReportVersion=function(e){return e.W_5="5",e}(CommonReportVersion||{}),CommonOs=function(e){return e.IOS="ios",e.ANDROID="android",e.WEB="web",e.WINDOWS="windows",e.MAC="mac",e.LINUX="linux",e}(CommonOs||{}),RtcgetconfigType=function(e){return e.REQUEST="request",e.RESPONSE="response",e}(RtcgetconfigType||{}),RtcreconnectMessage=function(e){return e.WEBSOCKET_RECONNECTING="websocket reconnecting",e.PEERCONNECTION_RECONNECTING="peerconnection reconnecting",e.DISCONNECTED="DISCONNECTED",e.LAN="LAN",e.WIFI="WIFI",e.W_2="2G",e.W_3="3G",e.W_4="4G",e.W_5="5G",e.UNKNOWN="UNKNOWN",e}(RtcreconnectMessage||{}),RtcreconnectReconnectType=function(e){return e.WEBSOCKET="websocket",e.NETWORKCHANGED="networkChanged",e.PEERCONNECTION="peerconnection",e}(RtcreconnectReconnectType||{}),RtcreconnectedMessage=function(e){return e.WEBSOCKET_RECONNECTED="websocket reconnected",e.PEERCONNECTION_RECONNECTED="peerconnection reconnected",e}(RtcreconnectedMessage||{}),RtcreconnectedReconnectType=function(e){return e.WEBSOCKET="websocket",e.NETWORKCHANGED="networkChanged",e.PEERCONNECTION="peerconnection",e}(RtcreconnectedReconnectType||{}),RtcgetaccessType=function(e){return e.REQUEST="request",e.RESPONSE="response",e.KCP_REQUEST="kcp request",e.KCP_RESPONSE="kcp response",e.QUIC_REQUEST="quic request",e.QUIC_RESPONSE="quic response",e}(RtcgetaccessType||{}),RtcpreicestateIceState=function(e){return e.NEW="NEW",e.CHECKING="CHECKING",e.CONNECTED="CONNECTED",e.COMPLETED="COMPLETED",e.FAILED="FAILED",e.DISCONNECTED="DISCONNECTED",e.CLOSED="CLOSED",e.DATACHANNEL_CONNECTING="DATACHANNEL_CONNECTING",e.DATACHANNEL_OPEN="DATACHANNEL_OPEN",e.DATACHANNEL_CLOSING="DATACHANNEL_CLOSING",e.DATACHANNEL_CLOSED="DATACHANNEL_CLOSED",e}(RtcpreicestateIceState||{}),RtcsignalingmsgerrorReason=function(e){return e.SUCCEED="succeed",e.MESSAGE_ID_ERROR="message id error",e.ZIP_FAILED="zip failed",e.UNZIP_FAILED="unzip failed",e.MESSAGE_KEY_EMPTY="message key empty",e.MESSAGE_KEY_PARSE_FAILED="message key parse failed",e.MESSAGE_KEY_INVALID="message key invalid",e.ENCRYPT_FAILED="encrypt failed",e.DECRYPT_FAILED="decrypt failed",e.MESSAGE_TOO_BIG="message too big",e.INVALID_DATA="invalid data",e.MESSAGE_PARSE_FAILED="message parse failed",e}(RtcsignalingmsgerrorReason||{}),RtcsignalingDirection=function(e){return e.UP="up",e.DOWN="down",e.DIRECT="direct",e}(RtcsignalingDirection||{}),RtcbegincreateofferDirection=function(e){return e.UP="up",e.DOWN="down",e.PRE="pre",e}(RtcbegincreateofferDirection||{}),RtccreateofferDirection=function(e){return e.UP="up",e.DOWN="down",e.PRE="pre",e}(RtccreateofferDirection||{}),RtcsetdescriptionIsLocal=function(e){return e.W_0="0",e.W_1="1",e}(RtcsetdescriptionIsLocal||{}),RtcsetdescriptionDirection=function(e){return e.UP="up",e.DOWN="down",e}(RtcsetdescriptionDirection||{}),RtcrecvanswerAnswerType=function(e){return e.ANSWER="answer",e.INCRANSWER="incranswer",e}(RtcrecvanswerAnswerType||{}),RtcrecvanswerDirection=function(e){return e.UP="up",e.DOWN="down",e}(RtcrecvanswerDirection||{}),RtcpublishstatResult=function(e){return e.SUCCESS="success",e.FAIL="fail",e}(RtcpublishstatResult||{}),RtcpublishstatIsScreen=function(e){return e.W_0="0",e.W_1="1",e}(RtcpublishstatIsScreen||{}),RtcpublishstatMessage=function(e){return e.LEAVE_ROOM="leave room",e.ACK_FAILED="ack failed",e.SET_ANSWER_SDP_FAILED="set answer sdp failed",e.ICE_FAILED="ice failed",e.STREAM_FAILED="stream failed",e.NETWORK_RECONNECTED="network reconnected",e.JOIN_ROOM_ACK_FAILED="join room ack failed",e.UNKNOWN="unknown",e}(RtcpublishstatMessage||{}),RtcsubscribestatResult=function(e){return e.SUCCESS="success",e.FAIL="fail",e.IGNORE="ignore",e}(RtcsubscribestatResult||{}),RtcsubscribestatMessage=function(e){return e.LEAVE_ROOM="leave room",e.ACK_FAILED="ack failed",e.SET_ANSWER_SDP_FAILED="set answer sdp failed",e.ICE_FAILED="ice failed",e.STREAM_FAILED="stream failed",e.NETWORK_RECONNECTED="network reconnected",e.ON_STREAM_REMOVE="on stream remove",e.PUBLISH_MUTE="publish mute",e.UNKNOWN="unknown",e.ON_STREAM_REMOVE_CLIENT_UNPUBLISHED="on stream remove:client unpublished",e.ON_STREAM_REMOVE_PUBLISH_FAILED="on stream remove:publish failed",e.ON_STREAM_REMOVE_STREAM_REMOVED="on stream remove:stream removed",e.ON_STREAM_REMOVE_CLIENT_DISCONNECTED="on stream remove:client disconnected",e.ON_STREAM_REMOVE_CLIENT_REPUBLISH="on stream remove:client republish",e}(RtcsubscribestatMessage||{}),RtcaudiodeviceAudioEvent=function(e){return e.PLAYOUT_DEVICE_SWITCH="playout_device_switch",e.RECORD_DEVICE_SWITCH="record_device_switch",e.UNKNOWN="unknown",e}(RtcaudiodeviceAudioEvent||{}),FirstframeinfoEventType=function(e){return e.BEGIN_SEND="begin_send",e.SENT_END="sent_end",e.BEGIN_RECV="begin_recv",e.RECV_END="recv_end",e}(FirstframeinfoEventType||{}),FirstframeinfoMediaType=function(e){return e.AUDIO="audio",e.VIDEO="video",e.SCREEN_VIDEO="screen_video",e.SCREEN_AUDIO="screen_audio",e}(FirstframeinfoMediaType||{}),FirstframeinfoType=function(e){return e.LOGIN="login",e.PUBLISHER="publisher",e.UNMUTE="unmute",e.ENABLE="enable",e.PUSH="push",e.PUBLISH="publish",e.ONDEMAND="ondemand",e.SUBSCRIBE="subscribe",e.PUSH_TRACK="push_track",e.REMOTE_UNMUTE="remote_unmute",e.P2P="p2p",e}(FirstframeinfoType||{}),FirstframeinfoReason=function(e){return e.TIMEOUT="timeout",e.AUDIENCE="audience",e.MUTE="mute",e.DISABLE="disable",e.STOP_PUSH="stop_push",e.UNPUBLISH="unpublish",e.NO_DEMAND="no_demand",e.LEAVE_ROOM="leave_room",e.UNSUBSCRIBE="unsubscribe",e.REMOVE_TRACK="remove_track",e.REMOTE_MUTE="remote_mute",e.USER_LEAVE="user_leave",e}(FirstframeinfoReason||{}),SdkinitengineType=function(e){return e.BEGIN="begin",e.END="end",e}(SdkinitengineType||{}),JoinroomType=function(e){return e.BEGIN="begin",e.END="end",e}(JoinroomType||{}),JoinroomReason=function(e){return e.LEAVE_ROOM="leave_room",e.ACK_FAILED="ack_failed",e.TOKEN_ERROR="token_error",e.SIGNALING_ERROR="signaling_error",e.TIMEOUT_10="timeout_10",e.TIMEOUT_60="timeout_60",e}(JoinroomReason||{}),DcusermessageDcMessageType=function(e){return e.P2P="p2p",e.P2P_OUTSIDE_ROOM="p2p_outside_room",e.P2SERVER="p2server",e}(DcusermessageDcMessageType||{}),CaptureeventinfoEventType=function(e){return e.START="start",e.START_CAPTURE_RESULT="start_capture_result",e.STARTED="started",e.RUNNING_FAILED="running_failed",e.STOP="stop",e.STOPPED="stopped",e}(CaptureeventinfoEventType||{}),CaptureeventinfoReason=function(e){return e.SUCCESS="success",e.CAMERA_DEVICE_NO_PERMISSION="camera_device_no_permission",e.CAMERA_DEVICE_BUSY="camera_device_busy",e.CAMERA_DEVICE_FAILURE="camera_device_failure",e.CAMERA_DEVICE_NOT_FOUND="camera_device_not_found",e.CAMERA_DEVICE_DISCONNECTED="camera_device_disconnected",e.TIMEOUT="timeout",e.ABORT="abort",e}(CaptureeventinfoReason||{}),Stats$1=function(){function e(t){_classCallCheck(this,e),_defineProperty(this,"_event_key",void 0),_defineProperty(this,"_device_id",void 0),_defineProperty(this,"_rtc_app_id",void 0),_defineProperty(this,"_product_line",void 0),_defineProperty(this,"_report_version",void 0),_defineProperty(this,"_os",void 0),_defineProperty(this,"_rtc_sdk_version",void 0),_defineProperty(this,"_rtc_timestamp",void 0),_defineProperty(this,"_rtc_sdk_git_commit",void 0),_defineProperty(this,"_report_id",void 0),_defineProperty(this,"_connection_id",void 0),_defineProperty(this,"_rtc_sid",void 0),_defineProperty(this,"_engine_session_id",void 0),_defineProperty(this,"_rtc_business_id",void 0),_defineProperty(this,"_project_key",void 0),_defineProperty(this,"_network_type",void 0),_defineProperty(this,"_app_version",void 0),_defineProperty(this,"_aid",void 0),_defineProperty(this,"_device_model",void 0),_defineProperty(this,"_device_brand",void 0),_defineProperty(this,"_common_extra_info",void 0),_defineProperty(this,"_had_selected_p2p",void 0),_defineProperty(this,"_rtc_env_type",void 0),_defineProperty(this,"_room_id",void 0),_defineProperty(this,"_user_id",void 0),_defineProperty(this,"_rtc_session_id",void 0),_defineProperty(this,"_user_agent",void 0),_defineProperty(this,"_auto_play_policy",void 0),this.monitor=t}return _createClass(e,[{key:"setStats",value:function(e){var t=this;Object.keys(e).forEach((function(r){t["_"+r]=e[r]})),this.monitor.StartUp()}},{key:"event_key",get:function(){return this._event_key}},{key:"device_id",get:function(){return this._device_id}},{key:"rtc_app_id",get:function(){return this._rtc_app_id}},{key:"product_line",get:function(){return this._product_line}},{key:"report_version",get:function(){return this._report_version}},{key:"os",get:function(){return this._os}},{key:"rtc_sdk_version",get:function(){return this._rtc_sdk_version}},{key:"rtc_timestamp",get:function(){return this._rtc_timestamp}},{key:"rtc_sdk_git_commit",get:function(){return this._rtc_sdk_git_commit}},{key:"report_id",get:function(){return this._report_id}},{key:"connection_id",get:function(){return this._connection_id}},{key:"rtc_sid",get:function(){return this._rtc_sid}},{key:"engine_session_id",get:function(){return this._engine_session_id}},{key:"rtc_business_id",get:function(){return this._rtc_business_id}},{key:"project_key",get:function(){return this._project_key}},{key:"network_type",get:function(){return this._network_type}},{key:"app_version",get:function(){return this._app_version}},{key:"aid",get:function(){return this._aid}},{key:"device_model",get:function(){return this._device_model}},{key:"device_brand",get:function(){return this._device_brand}},{key:"common_extra_info",get:function(){return this._common_extra_info}},{key:"had_selected_p2p",get:function(){return this._had_selected_p2p}},{key:"rtc_env_type",get:function(){return this._rtc_env_type}},{key:"room_id",get:function(){return this._room_id}},{key:"user_id",get:function(){return this._user_id}},{key:"rtc_session_id",get:function(){return this._rtc_session_id}},{key:"user_agent",get:function(){return this._user_agent}},{key:"auto_play_policy",get:function(){return this._auto_play_policy}}]),e}(),ReportLimit=4e3,XMLHttpRequestTimeout=1e4,Monitor=function(e){_inherits(r,EnhancedEventEmitter);var t=_createSuper(r);function r(){var e;return _classCallCheck(this,r),_defineProperty(_assertThisInitialized(e=t.call(this)),"report_id",void 0),_defineProperty(_assertThisInitialized(e),"report_common",void 0),_defineProperty(_assertThisInitialized(e),"modify_ids",void 0),_defineProperty(_assertThisInitialized(e),"dataBuffer",void 0),_defineProperty(_assertThisInitialized(e),"posting",void 0),_defineProperty(_assertThisInitialized(e),"sucSendTimer",void 0),_defineProperty(_assertThisInitialized(e),"preSucTime",void 0),_defineProperty(_assertThisInitialized(e),"errSendTimer",void 0),_defineProperty(_assertThisInitialized(e),"errSendDelay",void 0),_defineProperty(_assertThisInitialized(e),"commonStats",void 0),e.report_id=0,e.dataBuffer=[],e.posting=!1,e.report_common={},e.modify_ids={},e.preSucTime=0,e.errSendDelay=100,e.commonStats=new Stats$1(_assertThisInitialized(e)),isSSR()||window.addEventListener("beforeunload",(function(){clearTimeout(e.errSendTimer),clearTimeout(e.sucSendTimer),e.send(null,!0)})),e}return _createClass(r,[{key:"push",value:function(e,t){t?this.send(e):(this.dataBuffer.push(e),!this.posting&&!this.errSendTimer&&Date.now()-this.preSucTime>2e3&&(clearTimeout(this.sucSendTimer),this.send()))}},{key:"unshift",value:function(e){this.dataBuffer=e.concat(this.dataBuffer)}},{key:"send",value:function(e,t){var r=this;if(e||this.dataBuffer.length){var n={data:e||this.dataBuffer.splice(0,ReportLimit),header:this.report_common,from:"web",os:"web",version:"1"},i=new XMLHttpRequest;i.timeout=XMLHttpRequestTimeout,i.onreadystatechange=function(){if(4===i.readyState){var o;if(e||(r.posting=!1),200===i.status||304===i.status)try{o=JSON.parse(i.responseText)}catch(e){}o&&0===o.StatusCode?e||t||r.sucSend():e?r.send(e):(r.unshift(n.data),t?r.send():r.errSend())}};var o=Config.LOG_SERVER_URL;if(i.open("POST",o,!0),e||(this.posting=!0),!isSSR()&&location.search.includes("_rtc_autotest_"))this.safeEmit("report_event",n),0!==this.dataBuffer.length?this.sucSend():this.posting=!1;else if(!isSSR()&&location.search.includes("_rtc_debug_"))i.send(JSON.stringify(n));else{var a=pako_1.gzip(JSON.stringify(n));i.setRequestHeader("Content-Encoding","gzip"),i.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=UTF-8"),i.send(a)}}}},{key:"sucSend",value:function(){this.errSendDelay=100,this.preSucTime=Date.now(),this.sucSendTimer=setTimeout(this.send.bind(this),2e3)}},{key:"errSend",value:function(){var e=this;this.errSendTimer=setTimeout((function(){e.send(),e.errSendTimer=null}),this.errSendDelay),this.errSendDelay*=2}},{key:"StartUp",value:function(){var e=this.report_common,t=this.commonStats,r=t.event_key,n=t.device_id,i=t.rtc_app_id,o=t.product_line,a=t.report_version,s=t.os,c=t.rtc_sdk_version,u=t.rtc_timestamp,l=t.rtc_sdk_git_commit,d=t.report_id,p=t.rtc_sid,_=t.engine_session_id,f=t.rtc_business_id,h=t.project_key,m=t.network_type,y=t.app_version,v=t.aid,S=t.device_model,g=t.device_brand,E=t.common_extra_info,T=t.had_selected_p2p,b=t.rtc_env_type,R=t.user_agent,I=t.auto_play_policy;Object.assign(e,{event_key:r,device_id:n,rtc_app_id:i,product_line:o,report_version:a,os:s,rtc_sdk_version:c,rtc_timestamp:u,rtc_sdk_git_commit:l,report_id:d,rtc_sid:p,engine_session_id:_,rtc_business_id:f,project_key:h,network_type:m,app_version:y,aid:v,device_model:S,device_brand:g,common_extra_info:E,had_selected_p2p:T,rtc_env_type:b,user_agent:R,auto_play_policy:I}),this.commonStats.room_id&&(this.modify_ids.room_id=this.commonStats.room_id),this.commonStats.user_id&&(this.modify_ids.user_id=this.commonStats.user_id),this.commonStats.rtc_session_id&&(this.modify_ids.rtc_session_id=this.commonStats.rtc_session_id),this.commonStats.connection_id&&(this.modify_ids.connection_id=this.commonStats.connection_id)}},{key:"rtcSdkApiCall",value:function(e,t,r){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},i=_objectSpread2(_objectSpread2({event_key:"rtc_sdk_api_call",report_id:this.report_id++,rtc_timestamp:Date.now(),sdk_api_name:e,error_code:t,message:r},this.modify_ids),{},{common_extra_info:JSON.stringify(n)});this.push(i)}},{key:"rtcSdkCallback",value:function(e,t,r){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},i=_objectSpread2(_objectSpread2({event_key:"rtc_sdk_callback",report_id:this.report_id++,rtc_timestamp:Date.now(),sdk_callback_name:e,error_code:t,message:r},this.modify_ids),{},{common_extra_info:JSON.stringify(n)});this.push(i)}},{key:"rtcGetConfig",value:function(e,t,r,n,i,o,a){var s=arguments.length>7&&void 0!==arguments[7]?arguments[7]:{},c=_objectSpread2(_objectSpread2({event_key:"rtc_get_config",report_id:this.report_id++,rtc_timestamp:Date.now(),error_code:e,message:t,elapse:r,host:n,type:i,config_id:o,enable_cloud_proxy:a},this.modify_ids),{},{common_extra_info:JSON.stringify(s)});this.push(c)}},{key:"rtcReconnect",value:function(e,t,r,n){var i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{},o=_objectSpread2(_objectSpread2({event_key:"rtc_reconnect",report_id:this.report_id++,rtc_timestamp:Date.now(),error_code:e,message:t,reconnect_id:r,reconnect_type:n},this.modify_ids),{},{common_extra_info:JSON.stringify(i)});this.push(o)}},{key:"rtcReconnected",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n=_objectSpread2(_objectSpread2({event_key:"rtc_reconnected",report_id:this.report_id++,rtc_timestamp:Date.now(),message:e,reconnect_type:t},this.modify_ids),{},{common_extra_info:JSON.stringify(r)});this.push(n)}},{key:"rtcGetAccess",value:function(e,t,r,n,i,o){var a=arguments.length>6&&void 0!==arguments[6]?arguments[6]:{},s=_objectSpread2(_objectSpread2({event_key:"rtc_get_access",report_id:this.report_id++,rtc_timestamp:Date.now(),error_code:e,message:t,elapse:r,type:n,host:i,connect_session_id:o},this.modify_ids),{},{common_extra_info:JSON.stringify(a)});this.push(s)}},{key:"rtcPreIceState",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n=_objectSpread2(_objectSpread2({event_key:"rtc_pre_ice_state",report_id:this.report_id++,rtc_timestamp:Date.now(),message:e,ice_state:t},this.modify_ids),{},{common_extra_info:JSON.stringify(r)});this.push(n)}},{key:"rtcNodeChange",value:function(e,t,r){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},i=_objectSpread2(_objectSpread2({event_key:"rtc_node_change",report_id:this.report_id++,rtc_timestamp:Date.now(),error_code:e,message:t,reason:r},this.modify_ids),{},{common_extra_info:JSON.stringify(n)});this.push(i)}},{key:"rtcSignalingMsgError",value:function(e,t,r){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},i=_objectSpread2(_objectSpread2({event_key:"rtc_signaling_msg_error",report_id:this.report_id++,rtc_timestamp:Date.now(),error_code:e,message:t,reason:r},this.modify_ids),{},{common_extra_info:JSON.stringify(n)});this.push(i)}},{key:"rtcSignaling",value:function(e,t,r,n,i){var o=arguments.length>5&&void 0!==arguments[5]?arguments[5]:{},a=_objectSpread2(_objectSpread2({event_key:"rtc_signaling",report_id:this.report_id++,rtc_timestamp:Date.now(),error_code:e,message:t,signaling_event:r,signaling_type:n,direction:i},this.modify_ids),{},{common_extra_info:JSON.stringify(o)});this.push(a)}},{key:"rtcJoinRoom",value:function(e,t,r,n){var i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{},o=_objectSpread2(_objectSpread2({event_key:"rtc_join_room",report_id:this.report_id++,rtc_timestamp:Date.now(),error_code:e,deviceModel:t,deviceManufacturer:r,elapse:n},this.modify_ids),{},{common_extra_info:JSON.stringify(i)});this.push(o)}},{key:"rtcLeaveRoom",value:function(e,t,r){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},i=_objectSpread2(_objectSpread2({event_key:"rtc_leave_room",report_id:this.report_id++,rtc_timestamp:Date.now(),error_code:e,message:t,elapse:r},this.modify_ids),{},{common_extra_info:JSON.stringify(n)});this.push(i)}},{key:"rtcBeginCreateOffer",value:function(e,t,r){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},i=_objectSpread2(_objectSpread2({event_key:"rtc_begin_create_offer",report_id:this.report_id++,rtc_timestamp:Date.now(),direction:e,stream_id:t,stream_user_id:r},this.modify_ids),{},{common_extra_info:JSON.stringify(n)});this.push(i)}},{key:"rtcCreateOffer",value:function(e,t,r,n,i){var o=arguments.length>5&&void 0!==arguments[5]?arguments[5]:{},a=_objectSpread2(_objectSpread2({event_key:"rtc_create_offer",report_id:this.report_id++,rtc_timestamp:Date.now(),error_code:e,direction:t,stream_id:r,stream_user_id:n,elapse:i},this.modify_ids),{},{common_extra_info:JSON.stringify(o)});this.push(a)}},{key:"rtcSetDescription",value:function(e,t,r,n,i,o,a){var s=arguments.length>7&&void 0!==arguments[7]?arguments[7]:{},c=_objectSpread2(_objectSpread2({event_key:"rtc_set_description",report_id:this.report_id++,rtc_timestamp:Date.now(),error_code:e,message:t,is_local:r,direction:n,stream_id:i,stream_user_id:o,elapse:a},this.modify_ids),{},{common_extra_info:JSON.stringify(s)});this.push(c)}},{key:"rtcRecvAnswer",value:function(e,t,r,n,i,o,a){var s=arguments.length>7&&void 0!==arguments[7]?arguments[7]:{},c=_objectSpread2(_objectSpread2({event_key:"rtc_recv_answer",report_id:this.report_id++,rtc_timestamp:Date.now(),error_code:e,answer_type:t,sequence_id:r,message:n,direction:i,stream_id:o,stream_user_id:a},this.modify_ids),{},{common_extra_info:JSON.stringify(s)});this.push(c)}},{key:"firstRemoteAudioRender",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n=_objectSpread2(_objectSpread2({event_key:"first_remote_audio_render",report_id:this.report_id++,rtc_timestamp:Date.now(),stream_id:e,stream_user_id:t},this.modify_ids),{},{common_extra_info:JSON.stringify(r)});this.push(n)}},{key:"firstRemoteVideoRender",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n=_objectSpread2(_objectSpread2({event_key:"first_remote_video_render",report_id:this.report_id++,rtc_timestamp:Date.now(),stream_id:e,stream_user_id:t},this.modify_ids),{},{common_extra_info:JSON.stringify(r)});this.push(n)}},{key:"rtcPublishStat",value:function(e,t,r,n){var i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{},o=_objectSpread2(_objectSpread2({event_key:"rtc_publish_stat",report_id:this.report_id++,rtc_timestamp:Date.now(),result:e,is_screen:t,start:r,message:n},this.modify_ids),{},{common_extra_info:JSON.stringify(i)});this.push(o)}},{key:"rtcSubscribeStat",value:function(e,t,r,n){var i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{},o=_objectSpread2(_objectSpread2({event_key:"rtc_subscribe_stat",report_id:this.report_id++,rtc_timestamp:Date.now(),result:e,start:t,message:r,stream_user_id:n},this.modify_ids),{},{common_extra_info:JSON.stringify(i)});this.push(o)}},{key:"rtcAudioDevice",value:function(e,t,r){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},i=_objectSpread2(_objectSpread2({event_key:"rtc_audio_device",report_id:this.report_id++,rtc_timestamp:Date.now(),audio_event:e,message:t,error_code:r},this.modify_ids),{},{common_extra_info:JSON.stringify(n)});this.push(i)}},{key:"rtcMediaStatistics",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n=_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2({event_key:"rtc_media_statistics",report_id:this.report_id++,rtc_timestamp:Date.now()},e),t),this.modify_ids),{},{common_extra_info:JSON.stringify(r)});this.push(n)}},{key:"rtcMessageStatistics",value:function(e,t,r){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},i=_objectSpread2(_objectSpread2({event_key:"rtc_message_statistics",report_id:this.report_id++,rtc_timestamp:Date.now(),dc_user_message:e,dc_room_message:t,media_server_ip:r},this.modify_ids),{},{common_extra_info:JSON.stringify(n)});this.push(i)}},{key:"rtcError",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n=_objectSpread2(_objectSpread2({event_key:"rtc_error",report_id:this.report_id++,rtc_timestamp:Date.now(),message:e,error_code:t},this.modify_ids),{},{common_extra_info:JSON.stringify(r)});this.push(n)}},{key:"rtcInvokeStatus",value:function(e,t,r,n,i){var o=arguments.length>5&&void 0!==arguments[5]?arguments[5]:{},a=_objectSpread2(_objectSpread2({event_key:"rtc_invoke_status",report_id:this.report_id++,rtc_timestamp:Date.now(),message:e,error_code:t,sdk_api_name:r,stream_id:n,elapse:i},this.modify_ids),{},{common_extra_info:JSON.stringify(o)});this.push(a)}},{key:"rtcFirstFrame",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=_objectSpread2(_objectSpread2(_objectSpread2({event_key:"rtc_first_frame",report_id:this.report_id++,rtc_timestamp:Date.now()},e),this.modify_ids),{},{common_extra_info:JSON.stringify(t)});this.push(r)}},{key:"rtcMuteRemote",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n=_objectSpread2(_objectSpread2({event_key:"rtc_mute_remote",report_id:this.report_id++,rtc_timestamp:Date.now(),mute_info:e,media_type:t},this.modify_ids),{},{common_extra_info:JSON.stringify(r)});this.push(n)}},{key:"sdkInitEngine",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n=_objectSpread2(_objectSpread2({event_key:"sdk_init_engine",report_id:this.report_id++,rtc_timestamp:Date.now(),start:e,type:t},this.modify_ids),{},{common_extra_info:JSON.stringify(r)});this.push(n)}},{key:"joinRoom",value:function(e,t,r,n){var i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{},o=_objectSpread2(_objectSpread2({event_key:"join_room",report_id:this.report_id++,rtc_timestamp:Date.now(),type:e,start:t,result:r,reason:n},this.modify_ids),{},{common_extra_info:JSON.stringify(i)});this.push(o)}},{key:"p2pConnectionStatus",value:function(e,t,r,n,i){var o=arguments.length>5&&void 0!==arguments[5]?arguments[5]:{},a=_objectSpread2(_objectSpread2({event_key:"p2p_connection_status",report_id:this.report_id++,rtc_timestamp:Date.now(),room_id:e,user_id:t,peer_user_id:r,status:n,elapse:i},this.modify_ids),{},{common_extra_info:JSON.stringify(o)});this.push(a)}},{key:"p2pConnectClosed",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=_objectSpread2(_objectSpread2({event_key:"p2p_connect_closed",report_id:this.report_id++,rtc_timestamp:Date.now(),p2p_selected:e},this.modify_ids),{},{common_extra_info:JSON.stringify(t)});this.push(r)}},{key:"rtcDeviceError",value:function(e,t,r,n,i,o,a,s,c,u,l,d,p,_,f,h){var m=arguments.length>16&&void 0!==arguments[16]?arguments[16]:{},y=_objectSpread2(_objectSpread2({event_key:"rtc_device_error",report_id:this.report_id++,rtc_timestamp:Date.now(),device_type:e,device_stage:t,error_code:r,system_error_code:n,system_api:i,call_parameters:o,location:a,message:s,media_device_id:c,media_device_name:u,elapse:l,scenario:d,event_session_id:p,device_pid:_,device_vid:f,media_mode:h},this.modify_ids),{},{common_extra_info:JSON.stringify(m)});this.push(y)}},{key:"rtcVideoDevice",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n=_objectSpread2(_objectSpread2({event_key:"rtc_video_device",report_id:this.report_id++,rtc_timestamp:Date.now(),media_device_id:e,media_device_name:t},this.modify_ids),{},{common_extra_info:JSON.stringify(r)});this.push(n)}},{key:"rtcVideoCaptureEvent",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=_objectSpread2(_objectSpread2(_objectSpread2({event_key:"rtc_video_capture_event",report_id:this.report_id++,rtc_timestamp:Date.now()},e),this.modify_ids),{},{common_extra_info:JSON.stringify(t)});this.push(r)}},{key:"rtcEncodeFirstFrame",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n=_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2({event_key:"rtc_encode_first_frame",report_id:this.report_id++,rtc_timestamp:Date.now()},e),t),this.modify_ids),{},{common_extra_info:JSON.stringify(r)});this.push(n)}},{key:"rtcFirstFrameEncoded",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n=_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2({event_key:"rtc_first_frame_encoded",report_id:this.report_id++,rtc_timestamp:Date.now()},e),t),this.modify_ids),{},{common_extra_info:JSON.stringify(r)});this.push(n)}},{key:"rtcSendFirstPacket",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n=_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2({event_key:"rtc_send_first_packet",report_id:this.report_id++,rtc_timestamp:Date.now()},e),t),this.modify_ids),{},{common_extra_info:JSON.stringify(r)});this.push(n)}},{key:"rtcRecvFirstPacket",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n=_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2({event_key:"rtc_recv_first_packet",report_id:this.report_id++,rtc_timestamp:Date.now()},e),t),this.modify_ids),{},{common_extra_info:JSON.stringify(r)});this.push(n)}},{key:"rtcRecvFirstFrame",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n=_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2({event_key:"rtc_recv_first_frame",report_id:this.report_id++,rtc_timestamp:Date.now()},e),t),this.modify_ids),{},{common_extra_info:JSON.stringify(r)});this.push(n)}},{key:"rtcDecodeFirstFrame",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n=_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2({event_key:"rtc_decode_first_frame",report_id:this.report_id++,rtc_timestamp:Date.now()},e),t),this.modify_ids),{},{common_extra_info:JSON.stringify(r)});this.push(n)}}]),r}(),monitor=new Monitor,rtmMonitor=new Monitor,outsideRoomMonitor=new Monitor,commonStats=monitor.commonStats,rtmCommonStats=rtmMonitor.commonStats,outsideRoomCommonStats=outsideRoomMonitor.commonStats,monitorMap={default:monitor,rtm:rtmMonitor,outsideRoom:outsideRoomMonitor};function reportRtcSdkApiCall(){for(var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"default",t=arguments.length,r=new Array(t>1?t-1:0),n=1;n<t;n++)r[n-1]=arguments[n];return function(t,n,i){if("function"==typeof i.value){var o=i.value;i.value=function(){for(var t=arguments.length,i=new Array(t),a=0;a<t;a++)i[a]=arguments[a];var s={};r.forEach((function(e,t){s[e]=i[t]})),"joinRoom"===n&&commonStats.setStats({room_id:i[1]}),monitorMap[e].rtcSdkApiCall(n,0,JSON.stringify(reportParamsCheck(i)),s);var c=o.apply(this,i);return"function"==typeof(null==c?void 0:c.then)?c.then((function(t){return monitorMap[e].rtcSdkCallback(n,0,JSON.stringify(reportParamsCheck([t||{}]))),t})).catch((function(t){throw monitorMap[e].rtcSdkCallback(n,t.code,JSON.stringify(t.message)),t})):(monitorMap[e].rtcSdkCallback(n,0,JSON.stringify(reportParamsCheck([c||{}]))),c)}}}}function reportRtcSdkCallback(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,n=e===EngineEventsTypes.onUserMessageReceivedOutsideRoom||e===EngineEventsTypes.onUserBinaryMessageReceivedOutsideRoom;(n?rtmMonitor:monitor).rtcSdkCallback(e,r,JSON.stringify(t))}function reportRtcInvokeStatus(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,n=arguments.length>3&&void 0!==arguments[3]&&arguments[3];(n?rtmMonitor:monitor).rtcInvokeStatus(JSON.stringify(t),r,e,"",0)}var PLATFORM_KEY="BytePlus",RTC_DEVICE_ID="RTC_DEVICE_ID",RTC_ACCESS_NODE="RTC_ACCESS_NODE",RTC_ACCESS_URLS="RTC_ACCESS_URLS",RTC_H264_BLACK_LIST="RTC_H264_BLACK_LIST",RTC_AUDIO_PROFILE="engine_BAC",Cache=function(){function e(){_classCallCheck(this,e)}return _createClass(e,[{key:"get",value:function(e){var t=localStorage.getItem(e);if(!t)return null;try{var r=JSON.parse(t);return r.ttl>0&&Date.now()-r.saveTime>r.ttl?(this.delete(e),null):r.message}catch(e){return null}}},{key:"set",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:-1,n={ttl:r,saveTime:Date.now(),message:t};try{return localStorage.setItem(e,JSON.stringify(n)),!0}catch(e){return!1}}},{key:"delete",value:function(e){try{return localStorage.removeItem(e),!0}catch(e){return!1}}}]),e}(),SDKCache=function(e){_inherits(r,Cache);var t=_createSuper(r);function r(){return _classCallCheck(this,r),t.apply(this,arguments)}return _createClass(r,[{key:"getDeviceId",value:function(){if(isSSR())return"";var e=this.get(RTC_DEVICE_ID);return e||(e=v4()),this.set(RTC_DEVICE_ID,e),e}},{key:"setDeviceId",value:function(e){return[commonStats,rtmCommonStats,outsideRoomCommonStats].forEach((function(t){return t.setStats({device_id:e})})),this.set(RTC_DEVICE_ID,e),e}},{key:"getAccessNode",value:function(e){return this.get("".concat(RTC_ACCESS_NODE,"_").concat(e,"-").concat(PLATFORM_KEY))}},{key:"setAccessNode",value:function(e,t,r){return this.set("".concat(RTC_ACCESS_NODE,"_").concat(e,"-").concat(PLATFORM_KEY),t,1e3*r)}},{key:"clearAccessNode",value:function(e){this.delete("".concat(RTC_ACCESS_NODE,"_").concat(e,"-").concat(PLATFORM_KEY))}},{key:"getAccessUrls",value:function(){return this.get("".concat(RTC_ACCESS_URLS,"-").concat(PLATFORM_KEY))}},{key:"setAccessUrls",value:function(e){var t=e.map((function(e){var t=e.host,r=e.path;return"https://".concat(t).concat(r)}));return this.set("".concat(RTC_ACCESS_URLS,"-").concat(PLATFORM_KEY),t)}},{key:"clearAccessUrls",value:function(){this.delete("".concat(RTC_ACCESS_URLS,"-").concat(PLATFORM_KEY))}},{key:"getH264BlackList",value:function(){return this.get(RTC_H264_BLACK_LIST)}},{key:"setH264BlackList",value:function(e){return this.set(RTC_H264_BLACK_LIST,e)}},{key:"getAudioProfile",value:function(){return this.get(RTC_AUDIO_PROFILE)}},{key:"setAudioProfile",value:function(e){return this.set(RTC_AUDIO_PROFILE,e)}}]),r}(),sdkCache=new SDKCache,internalAccessDomains="rtc-access.rtcplus.com,rtc-access-sg.rtcplus.com,rtc-access-va.rtcplus.com,rtc-access-fr.rtcplus.com".split(",");function getFullAccessUrl(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return/^https?:\/\/.+/.test(e)||(e="https://"+e),"".concat(e,"/dispatch/v1/AccessInfo?Action=GetAccessInfo")}function getFullLogServerUrl(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return/^https?:\/\/.+/.test(e)||(e="https://"+e),"".concat(e,"/video/v1/webrtc_log/")}var domesticLogServerUrl="https://web-log-report.rtcplus.com/video/v1/webrtc_log/",overseasLogServerUrl="https://web-log-report.rtcplus.com/video/v1/webrtc_log/",configDomains="rtc.rtcplus.com".split(","),Config={VERSION:"4.46.13",ICE_CONFIG_REQUEST_URLS_INTERNAL:internalAccessDomains.map(getFullAccessUrl),ICE_CONFIG_REQUEST_URLS:[],EXPECTED_ADDR:"",LOG_SERVER_URL:domesticLogServerUrl,CONFIG_REQUEST_DOMAINS:configDomains,DEVICE_ID:"",OVERSEA:!1};function setParameter(e,t){if("VERSION"!==e)return"ICE_CONFIG_REQUEST_URLS"===e?("string"==typeof t&&(t=[t]),void(Config.ICE_CONFIG_REQUEST_URLS=t.map(getFullAccessUrl))):void("LOG_SERVER_URL"!==e||t!==LogChannel.overseas?"LOG_SERVER_URL"!==e||t!==LogChannel.domestic?"LOG_SERVER_URL"!==e||"string"!=typeof t?"OVERSEA"!==e?("DEVICE_ID"===e&&sdkCache.setDeviceId(t),Config[e]=t):Config.OVERSEA=t:Config.LOG_SERVER_URL=t:Config.LOG_SERVER_URL=domesticLogServerUrl:Config.LOG_SERVER_URL=overseasLogServerUrl)}function getParameter(e){return"DEVICE_ID"===e?sdkCache.getDeviceId():Config[e]}function getTranscodeControlMessage(e,t){var r,n,i,o,a,s,c,u,l,d,p,_,f,h,m,y,v;return{type:"transcode",action:e,transcodeMeta:{transcode:{url:t.url},control:{protocol:"2.0"},audio:{codec:(null===(r=t.audio)||void 0===r?void 0:r.codec)||defaultTranscoding.audio.codec,bitRate:1e3*((null===(n=t.audio)||void 0===n?void 0:n.kBitRate)||defaultTranscoding.audio.kBitRate),sampleRate:1e3*((null===(i=t.audio)||void 0===i?void 0:i.sampleRate)||defaultTranscoding.audio.sampleRate),channels:(null===(o=t.audio)||void 0===o?void 0:o.channels)||defaultTranscoding.audio.channels,profile:(null===(a=t.audio)||void 0===a?void 0:a.AACProfile)||defaultTranscoding.audio.AACProfile},video:{codec:(null===(s=t.video)||void 0===s?void 0:s.codec)||defaultTranscoding.video.codec,fps:(null===(c=t.video)||void 0===c?void 0:c.fps)||defaultTranscoding.video.fps,gop:(null===(u=t.video)||void 0===u?void 0:u.gop)||defaultTranscoding.video.gop,lowLatency:null!==(l=null===(d=t.video)||void 0===d?void 0:d.lowLatency)&&void 0!==l?l:defaultTranscoding.video.lowLatency,bitRate:1e3*((null===(p=t.video)||void 0===p?void 0:p.kBitRate)||defaultTranscoding.video.kBitRate),width:(null===(_=t.video)||void 0===_?void 0:_.width)||defaultTranscoding.video.width,height:(null===(f=t.video)||void 0===f?void 0:f.height)||defaultTranscoding.video.height},layout:{canvas:{bgnd:(null===(h=t.layout)||void 0===h?void 0:h.backgroundColor)||defaultTranscoding.layout.backgroundColor},regions:(null===(m=t.layout)||void 0===m||null===(y=m.regions)||void 0===y?void 0:y.map((function(e){return{alpha:Math.min(Math.max(+e.alpha,0),1),uid:e.userId,zorder:e.zorder,x:Math.min(Math.max(+e.x,0),1),y:Math.min(Math.max(+e.y,0),1),w:Math.min(Math.max(+e.w,0),1),h:Math.min(Math.max(+e.h,0),1),renderMode:e.renderMode||1,contentControl:e.contentControl||0,screen:e.isScreenStream,local_user:e.isLocalUser}})))||[],app_data:(null===(v=t.layout)||void 0===v?void 0:v.appData)||defaultTranscoding.layout.appData}}}}function getPublicStreamControlMessage(e,t,r){var n,i,o,a,s,c,u,l,d;return{type:"publicstream",action:t,publicStreamID:e,publicStreamMeta:{audio:{},video:{fps:(null===(n=r.video)||void 0===n?void 0:n.fps)||15,bitrate:1e3*((null===(i=r.video)||void 0===i?void 0:i.kBitRate)||40),width:(null===(o=r.video)||void 0===o?void 0:o.width)||640,height:(null===(a=r.video)||void 0===a?void 0:a.height)||360},layout:{layoutMode:2,interpolationMode:(null===(s=r.layout)||void 0===s?void 0:s.interpolationMode)||PublicInterpolationMode.PREV_FRAME,canvas:{bgColor:(null===(c=r.layout)||void 0===c?void 0:c.backgroundColor)||"#000000",bgImage:(null===(u=r.layout)||void 0===u?void 0:u.backgroundImage)||""},regions:(null===(l=r.layout)||void 0===l||null===(d=l.regions)||void 0===d?void 0:d.map((function(e){return{roomId:e.roomId,userId:e.userId,alterImage:e.alertImage||"",alpha:e.alpha,x:Math.min(Math.max(+e.x,0),1),y:Math.min(Math.max(+e.y,0),1),w:Math.min(Math.max(+e.w,0),1),h:Math.min(Math.max(+e.h,0),1),zorder:e.zorder,renderMode:void 0===e.renderMode?1:e.renderMode,streamType:e.isScreenStream?1:0,mediaType:e.mediaType||0,sourceCrop:e.sourceCrop}})))||[]}}}}var _USER_MESSAGE_SEND_RE,defaultTranscoding={url:"",video:{codec:"H264",width:640,height:360,fps:30,gop:60,kBitRate:600,lowLatency:!0},audio:{codec:"AAC",kBitRate:64,sampleRate:48,channels:2,AACProfile:"LC"},layout:{regions:[],appData:"",backgroundColor:"#000000"}},defaultVideoEncoderConfig={width:640,height:360,frameRate:30,maxKbps:600},defaultScreenEncoderConfig={width:1920,height:1080,frameRate:15,maxKbps:3e3},RemoveStreamMessage=function(e){return e.streamRemovedBySchedule308="stream removed",e.clientRePublish="client republish",e.publishStreamFaied="publish failed",e.clientUnPublish="client unpublished",e.clientDisconnected="client disconnected",e.videoMuted="video muted",e}(RemoveStreamMessage||{}),StreamControlType=function(e){return e.PushLimitWarn="PushLimitWarn",e}(StreamControlType||{}),SignalEvent=function(e){return e.ON_ADD_STREAM="onAddStream",e.ON_REMOVE_STREAM="onRemoveStream",e.USER_DISCONNECTION="userDisconnection",e.USER_CONNECTION="userConnection",e.ON_UPDATE_STREAM_ATTRIBUTES="onUpdateStreamAttributes",e.ON_UPDATE_ROOM_ATTRIBUTES="onUpdateRoomAttributes",e.ON_UPDATE_USER_ATTRIBUTES="onUpdateUserAttributes",e.ON_PUSH_TRACK="onPushTrack",e.ON_REMOVE_TRACK="onRemoveTrack",e.ON_CUSTOM_MESSAGE="onCustomMessage",e.NODE_CHANGE="nodeChange",e.USER_MESSAGE_RECEIVED="userMessageReceived",e.USER_BINARY_MESSAGE_RECEIVED="userBinaryMessageReceived",e.USER_MESSAGE_RECEIVED_OUTSIDE_ROOM="userMessageReceivedOutsideRoom",e.USER_BINARY_MESSAGE_RECEIVED_OUTSIDE_ROOM="userBinaryMessageReceivedOutsideRoom",e.POST_PROCESSING_MESSAGE="postProcessingMessage",e.ON_USER_TOKEN_WILL_EXPIRE="onUserTokenWillExpire",e.STREAM_CONTROL_MESSAGE="streamControlMessage",e.ON_SCENE_CONFIG="onSceneConfig",e.ON_STREAM_FAILED="streamFailed",e}(SignalEvent||{}),MediaServerSignalEvent=function(e){return e.RSCP="RSCP",e}(MediaServerSignalEvent||{}),StateEvent=function(e){return e.ON_CONNECTION_STATE_CHANGE="onConnectionStateChange",e.ABNORMAL_DISCONNECTION="normalConnection",e}(StateEvent||{}),UserDisconnectionTag=function(e){return e.userLeave="userLeave",e.connectionLost="connectionLost",e.userDuplicateLogin="userDuplicateLogin",e.kickedByAdmin="kickedByAdmin",e.roleChanged="roleChanged",e.onUserTokenDidExpire="onUserTokenDidExpire",e}(UserDisconnectionTag||{}),UserDisconnectionCode=function(e){return e[e.roomDismissByAdmin=2]="roomDismissByAdmin",e}(UserDisconnectionCode||{}),DC_MESSAGE_DIRECTION=function(e){return e[e.SEND=0]="SEND",e[e.FEEDBACK=1]="FEEDBACK",e}(DC_MESSAGE_DIRECTION||{}),DC_MESSAGE_FUNCTION_TYPE=function(e){return e[e.P2P=0]="P2P",e[e.SIGNAL=1]="SIGNAL",e[e.BROADCAST=2]="BROADCAST",e[e.BUSINESS_SERVER=3]="BUSINESS_SERVER",e}(DC_MESSAGE_FUNCTION_TYPE||{}),USER_MESSAGE_SEND_RESULT=function(e){return e[e.SUCCESS=0]="SUCCESS",e[e.TIMEOUT=1]="TIMEOUT",e[e.BROKEN=2]="BROKEN",e[e.NO_RECEIVER=3]="NO_RECEIVER",e[e.NO_RELAYPATH=4]="NO_RELAYPATH",e[e.SEND_TO_SERVER_ERROR=17]="SEND_TO_SERVER_ERROR",e[e.SERVER_RESPONSE_ERROR=18]="SERVER_RESPONSE_ERROR",e[e.NOT_JOIN=100]="NOT_JOIN",e[e.INIT=101]="INIT",e[e.NO_CONNECTION=102]="NO_CONNECTION",e[e.NOT_LOGIN=105]="NOT_LOGIN",e[e.SERVER_PARAMS_NOTSET=106]="SERVER_PARAMS_NOTSET",e[e.UNKNOWN=1e3]="UNKNOWN",e}(USER_MESSAGE_SEND_RESULT||{}),USER_MESSAGE_SEND_RESULT_EXPLAIN=(_defineProperty(_USER_MESSAGE_SEND_RE={},0,[0,"success"]),_defineProperty(_USER_MESSAGE_SEND_RE,1,[ErrorCode.USER_MESSAGE_TIMEOUT,"timeout, failed to send."]),_defineProperty(_USER_MESSAGE_SEND_RE,2,[ErrorCode.USER_MESSAGE_BROKEN,"dataChannel broken, failed to send."]),_defineProperty(_USER_MESSAGE_SEND_RE,3,[ErrorCode.USER_MESSAGE_NO_RECEIVER,"cannot find the receiver."]),_defineProperty(_USER_MESSAGE_SEND_RE,4,[ErrorCode.USER_MESSAGE_NO_RELAYPATH,"cannot find relay path."]),_defineProperty(_USER_MESSAGE_SEND_RE,17,[ErrorCode.USER_MESSAGE_SEND_TO_SERVER_ERROR,"failed to send to business server."]),_defineProperty(_USER_MESSAGE_SEND_RE,18,[ErrorCode.USER_MESSAGE_SERVER_RESPONSE_ERROR,"business server response error."]),_defineProperty(_USER_MESSAGE_SEND_RE,100,[ErrorCode.USER_MESSAGE_NOT_JOIN,"not join room"]),_defineProperty(_USER_MESSAGE_SEND_RE,101,[ErrorCode.USER_MESSAGE_INIT,"not init."]),_defineProperty(_USER_MESSAGE_SEND_RE,102,[ErrorCode.USER_MESSAGE_NO_CONNECTION,"no connection."]),_defineProperty(_USER_MESSAGE_SEND_RE,105,[ErrorCode.USER_MESSAGE_NOT_LOGIN,"not login."]),_defineProperty(_USER_MESSAGE_SEND_RE,106,[ErrorCode.USER_MESSAGE_SERVER_PARAMS_NOTSET,"server param is not set."]),_defineProperty(_USER_MESSAGE_SEND_RE,1e3,[ErrorCode.USER_MESSAGE_UNKNOWN,"unknown."]),_USER_MESSAGE_SEND_RE),_excluded=["msg"],logger$h=new Logger("DataChannelSignaling",3),SIGNALING_FUNCTION_TYPE=function(e){return e[e.C2S=0]="C2S",e[e.C2C=1]="C2C",e[e.C2GW=2]="C2GW",e[e.C2CDirect=3]="C2CDirect",e[e.C2RTM=4]="C2RTM",e}(SIGNALING_FUNCTION_TYPE||{}),DATA_CHANNEL_MESSAGE_TIMEOUT=6e4,DataChannelSignaling=function(e){_inherits(i,eventemitter3.exports.EventEmitter);var t,r,n=_createSuper(i);function i(e){var t;return _classCallCheck(this,i),_defineProperty(_assertThisInitialized(t=n.call(this)),"_singlingCache",new Map),_defineProperty(_assertThisInitialized(t),"_p2pCache",new Map),_defineProperty(_assertThisInitialized(t),"_rttIds",{}),_defineProperty(_assertThisInitialized(t),"_p2pMessageId",0),_defineProperty(_assertThisInitialized(t),"_clearDataChannelListener",void 0),t._dataChannel=e,t._clearDataChannelListener=t._handleHandler(),window.__rtc_mock_signaling__=t.emit.bind(_assertThisInitialized(t)),t}return _createClass(i,[{key:"destroy",value:function(){this._dataChannel&&(this._clearDataChannelListener(),this._dataChannel.close()),this._singlingCache.clear(),this._p2pCache.clear(),this._p2pMessageId=0,this._rttIds={}}},{key:"sendSignaling",value:function(e,t,r){var n=this;return monitor.rtcSignaling(0,JSON.stringify(t),"call-".concat(e),"Send",RtcsignalingDirection.UP),new Promise((function(i,o){var a=n._genHeader(r);a.id=createRandomId();var s=a.id.join("-"),c=setTimeout((function(){n._singlingCache.delete(s),o(new SDKError(ErrorCode.TIME_OUT,"".concat(e," message time out")))}),DATA_CHANNEL_MESSAGE_TIMEOUT);n._singlingCache.set(s,{signalingType:e,success:function(e){clearTimeout(c),i(e)},error:function(e){clearTimeout(c),o(e)}}),logger$h.print("Signal",">>>>>> [".concat(e,"][").concat(s,"]"),t),n._sendMessage(e,a,t)}))}},{key:"sendPingSignaling",value:function(){return this.sendSignaling("CheckConnectivity",{ts:Date.now()},{functionType:2})}},{key:"sendP2PMessage",value:(r=_asyncToGenerator(_regeneratorRuntime().mark((function e(t,r){var n,i,o;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=t.msg,i=_objectWithoutProperties(t,_excluded),o=n instanceof ArrayBuffer,e.t0=this,e.t1=_objectSpread2,e.t2=_objectSpread2({ver:1,id:this._p2pMessageId++,time:Date.now(),dir:DC_MESSAGE_DIRECTION.SEND,type:DC_MESSAGE_FUNCTION_TYPE.P2P,err:USER_MESSAGE_SEND_RESULT.SUCCESS},i),e.t3={},e.t4=o,!o){e.next=13;break}return e.next=10,Utils.ab2b64str(n);case 10:e.t5=e.sent,e.next=14;break;case 13:e.t5=n;case 14:return e.t6=e.t5,e.t7={binary:e.t4,msg:e.t6},e.t8=(0,e.t1)(e.t2,e.t3,e.t7),e.t9=r,e.abrupt("return",e.t0._sendP2PMessage.call(e.t0,e.t8,e.t9));case 19:case"end":return e.stop()}}),e,this)}))),function(e,t){return r.apply(this,arguments)})},{key:"_sendP2PMessage",value:function(e){var t=this,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return isRttMessage(e.msg)?this._rttIds[e.id]=e.id:e.dir===DC_MESSAGE_DIRECTION.SEND&&logger$h.print("_sendP2PMessage [DC Signaling p2p >>]",JSON.stringify(e)),new Promise((function(n,i){var o=t._genHeader(_objectSpread2(_objectSpread2({needAck:!0,functionType:1},r),{},{id:createRandomId()}));if(e.dir===DC_MESSAGE_DIRECTION.SEND){var a=setTimeout((function(){t._p2pCache.delete(e.id),i(new SDKError(ErrorCode.TIME_OUT,"P2P message timeout"))}),DATA_CHANNEL_MESSAGE_TIMEOUT);t._p2pCache.set(e.id,{success:function(e,t){clearTimeout(a),n(t)},error:function(e){clearTimeout(a);var t=_slicedToArray(USER_MESSAGE_SEND_RESULT_EXPLAIN[e.err]||[ErrorCode.USER_MESSAGE_UNKNOWN,"err: ".concat(e.err,", msg: ").concat(e.msg)],2),r=t[0],n=t[1];i({code:r,message:e.msg||n})}})}t._sendMessage("p2p",o,e)}))}},{key:"_sendMessage",value:function(e,t,r){if(!this._dataChannel||"open"!==this._dataChannel.readyState)throw new SDKError(ErrorCode.SIGNALING_CHANNEL_NOT_OPEN,"DataChannel not open");var n=t.version+(+t.zip<<5)+(+t.encrypt<<6),i=+t.needAck+(+t.direction<<1)+(+t.functionType<<2)+(+t.binary<<6),o=Utils.str2ab(JSON.stringify([e,r])),a=concatenate(Uint8Array,[n,i].concat(_toConsumableArray(t.id||[])),new Uint8Array(o));this._dataChannel.send(a.buffer)}},{key:"_dispartData",value:function(e){var t=new Uint8Array(e),r=0,n=t[r++],i=t[r++],o={version:15&n,zip:16==(16&n),encrypt:32==(32&n),needAck:1==(1&i),direction:(2&i)>>1,functionType:(60&i)>>2,binary:64==(64&i)};if(o.needAck||1===o.direction){for(;r<=6;r++)if(!isByteId(t[r])){r++;break}o.id=Array.from(t.slice(2,r))}return{header:o,data:t.slice(r)}}},{key:"_feedbackSignaling",value:function(e,t,r){var n=this._genHeader({needAck:!0,direction:1,id:e.split("-").map((function(e){return+e}))});logger$h.print("Signal",">>>>>> [".concat(t,"-res][").concat(e,"]")),this._sendMessage("".concat(t,"-res"),n,r)}},{key:"_handleMessage",value:(t=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){var r,n,i,o,a,s,c,u,l,d,p,_,f,h,m,y,v,S,g,E,T,b,R,I,$,A,C,O,P,k,w;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:s=this._dispartData(t),c=s.data,(u=s.header).zip&&((l=new pako_1.Inflate).push(c,!0),c=l.result),d=Utils.ab2str(c),p=[],e.prev=6,p=JSON.parse(d),e.next=14;break;case 10:return e.prev=10,e.t0=e.catch(6),e.t0 instanceof Error&&monitor.rtcSignalingMsgError(-1,e.t0.message,RtcsignalingmsgerrorReason.MESSAGE_PARSE_FAILED),e.abrupt("return");case 14:e.t1=u.functionType,e.next=0===e.t1?17:1===e.t1?34:2===e.t1?83:99;break;case 17:if(_=(null===(r=u.id)||void 0===r?void 0:r.join("-"))||"",1!==u.direction){e.next=22;break}this._handleAckMessage(_,p[0]||{},d),e.next=33;break;case 22:if(!Array.isArray(p)){e.next=33;break}if(f=p[0],p=p[1],logger$h.print("Signal","<<<<<< ".concat(f),p,_),this._feedbackSignaling(_,f,f===SignalEvent.ON_CUSTOM_MESSAGE?_objectSpread2(_objectSpread2({},p),{},{message:""}):""),!p.binary||"string"!=typeof p.message){e.next=31;break}return e.next=30,Utils.b64str2ab(p.message);case 30:p.message=e.sent;case 31:this.emit(f,_objectSpread2({},p)),monitor.rtcSignaling(0,d,"on-".concat(f),"Recv",RtcsignalingDirection.DOWN);case 33:return e.abrupt("break",100);case 34:Array.isArray(p)&&(p=p[1]),h=null===(n=p)||void 0===n?void 0:n.id,this._rttIds[h]||(null===(i=p)||void 0===i?void 0:i.dir)===DC_MESSAGE_DIRECTION.FEEDBACK||isRttMessage(null===(o=p)||void 0===o?void 0:o.msg)?delete this._rttIds[h]:logger$h.print("Signal","<<<<<< p2p response",p),e.t2=p.dir,e.next=e.t2===DC_MESSAGE_DIRECTION.SEND?40:e.t2===DC_MESSAGE_DIRECTION.FEEDBACK?78:81;break;case 40:if(isRttMessage(null===(a=p)||void 0===a?void 0:a.msg)){e.next=76;break}if(y=(m=p).binary,v=m.msg,S=m.room,g=m.to,E=m.from,T=""===S?y?SignalEvent.USER_BINARY_MESSAGE_RECEIVED_OUTSIDE_ROOM:SignalEvent.USER_MESSAGE_RECEIVED_OUTSIDE_ROOM:y?SignalEvent.USER_BINARY_MESSAGE_RECEIVED:SignalEvent.USER_MESSAGE_RECEIVED,g){e.next=60;break}if(e.t3=this,e.t4=SignalEvent.ON_CUSTOM_MESSAGE,e.t5=E,e.t6=y,!y){e.next=54;break}return e.next=51,Utils.b64str2ab(v);case 51:e.t7=e.sent,e.next=55;break;case 54:e.t7=v;case 55:e.t8=e.t7,e.t9={clientId:e.t5,binary:e.t6,message:e.t8},e.t3.emit.call(e.t3,e.t4,e.t9),e.next=76;break;case 60:if(e.t10=this,e.t11=T,e.t12=_objectSpread2,e.t13=_objectSpread2({},p),e.t14={},!y){e.next=71;break}return e.next=68,Utils.b64str2ab(v);case 68:e.t15=e.sent,e.next=72;break;case 71:e.t15=v;case 72:e.t16=e.t15,e.t17={msg:e.t16},e.t18=(0,e.t12)(e.t13,e.t14,e.t17),e.t10.emit.call(e.t10,e.t11,e.t18);case 76:return this._sendP2PMessage(_objectSpread2(_objectSpread2({},p),{},{dir:DC_MESSAGE_DIRECTION.FEEDBACK,msg:""})),e.abrupt("break",82);case 78:return(b=this._p2pCache.get(p.id))&&(this._p2pCache.delete(p.id),p.err===USER_MESSAGE_SEND_RESULT.SUCCESS?b.success(p.id,p):b.error(p)),e.abrupt("break",82);case 81:return e.abrupt("break",82);case 82:return e.abrupt("break",100);case 83:if(1!==u.direction){e.next=88;break}I=(null===(R=u.id)||void 0===R?void 0:R.join("-"))||"",this._handleAckMessage(I,p[0]||{},d),e.next=98;break;case 88:if($=_slicedToArray(p,2),A=$[0],C=$[1],O=void 0===C?{}:C,"RXMediaMsg"!==A){e.next=98;break}P=O.type,k=O.data,monitor.rtcSignaling(0,d,"on-".concat(P),"Recv",RtcsignalingDirection.DOWN),e.t19=P,e.next="RSCP"===e.t19?95:97;break;case 95:try{w=JSON.parse(k),Array.isArray(w)&&this.emit(P,w)}catch(e){}return e.abrupt("break",98);case 97:return e.abrupt("break",98);case 98:case 99:return e.abrupt("break",100);case 100:case"end":return e.stop()}}),e,this,[[6,10]])}))),function(e){return t.apply(this,arguments)})},{key:"_handleHandler",value:function(){var e=this,t=function(t){logger$h.print("_handleHandler","dataChannel close",t),e.emit("close",t)},r=function(t){logger$h.print("_handleHandler","dataChannel error",t),e.emit("close",t)},n=function(t){e._handleMessage(t.data)};return this._dataChannel.addEventListener("close",t),this._dataChannel.addEventListener("error",r),this._dataChannel.addEventListener("message",n),function(){e._dataChannel.removeEventListener("close",t),e._dataChannel.removeEventListener("error",r),e._dataChannel.removeEventListener("message",n)}}},{key:"_genHeader",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return _objectSpread2({version:2,zip:!1,encrypt:!1,needAck:!0,direction:0,functionType:0,binary:!1},e)}},{key:"_handleAckMessage",value:function(e,t,r){var n=this._singlingCache.get(e);n&&(this._singlingCache.delete(e),200===t.code?n.success(t):n.error(t),logger$h.print("Signal","<<<<<< [".concat(n.signalingType,"-ack]"),t)),monitor.rtcSignaling(0,r,null==n?void 0:n.signalingType,"Ack",RtcsignalingDirection.DOWN)}}]),i}(),HttpRequest=function(){function e(){_classCallCheck(this,e),_defineProperty(this,"xhr",void 0),_defineProperty(this,"isSending",void 0),_defineProperty(this,"timeout",void 0),this.isSending=!1}return _createClass(e,[{key:"ajax",value:function(e){var t=this,r=e.method,n=e.url,i=e.body,o=void 0===i?{}:i,a=e.headers,s=void 0===a?{}:a,c=e.stringify,u=void 0===c||c;return new Promise((function(e,i){t.isSending=!0;var a=new XMLHttpRequest;a.open(r,n,!0);for(var c=0,l=Object.entries(s);c<l.length;c++){var d=_slicedToArray(l[c],2),p=d[0],_=d[1];a.setRequestHeader(p,_)}a.onreadystatechange=function(){4===a.readyState&&(t.isSending=!1,200===a.status?e(JSON.parse(a.responseText)):i({message:a.statusText,code:a.status})),0===a.status&&i({code:0,message:"Request abort"})},a.onerror=function(e){t.isSending=!1,i({code:-1,message:a.responseText||"unknown"})},t.timeout&&(a.timeout=t.timeout),u&&(o=JSON.stringify(o)),a.send(o),t.xhr=a}))}},{key:"get",value:function(e,t){return this.ajax({method:"GET",url:e,headers:t})}},{key:"post",value:function(e,t,r,n){return this.ajax({method:"POST",url:e,body:t,headers:r,stringify:n})}},{key:"abort",value:function(){var e;null===(e=this.xhr)||void 0===e||e.abort()}}]),e}(),logger$g=new Logger("ICE Request",3),IceConfigRequestManager=function(){function e(){_classCallCheck(this,e),_defineProperty(this,"_request",void 0),this._request=new HttpRequest}var t,r,n;return _createClass(e,[{key:"getAccessNode",value:(n=_asyncToGenerator(_regeneratorRuntime().mark((function e(t,r,n,i,o,a,s){var c;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(c=sdkCache.getAccessNode(t))){e.next=9;break}if(this.getAccessNodeFromServer(t,r,n,i,o,a,s),reportRtcInvokeStatus("es.R.node.cache",c),!Array.isArray(c)){e.next=8;break}return e.abrupt("return",Promise.resolve(c));case 8:return e.abrupt("return",Promise.resolve([c]));case 9:return e.abrupt("return",this.getAccessNodeFromServer(t,r,n,i,o,a,s));case 10:case"end":return e.stop()}}),e,this)}))),function(e,t,r,i,o,a,s){return n.apply(this,arguments)})},{key:"getAccessNodeFromServer",value:(r=_asyncToGenerator(_regeneratorRuntime().mark((function e(t,r,n,i,o,a,s){var c,u,l,d,p=this;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return l=sdkCache.getAccessUrls(),d=!0,reportRtcInvokeStatus("es.R.req.cache.urls",l),(null===(c=l)||void 0===c?void 0:c.length)>0||(l=Config.ICE_CONFIG_REQUEST_URLS,d=!1,reportRtcInvokeStatus("es.R.req.external.urls",l)),(null===(u=l)||void 0===u?void 0:u.length)>0||(l=Config.ICE_CONFIG_REQUEST_URLS_INTERNAL,d=!1,reportRtcInvokeStatus("es.R.req.internal.urls",l)),e.abrupt("return",this.getICEConfigFromServer(l,t,r,n,i,o,a,s).then((function(e){var r=e.nodes;return sdkCache.setAccessNode(t,r,e.ttl||11200),e.dispatchDomains&&sdkCache.setAccessUrls(e.dispatchDomains),r})).catch((function(e){if(d)return reportRtcInvokeStatus("es.R.req.fallback",""),sdkCache.clearAccessUrls(),p.getAccessNodeFromServer(t,r,n,i,o,a,s);throw e})));case 6:case"end":return e.stop()}}),e,this)}))),function(e,t,n,i,o,a,s){return r.apply(this,arguments)})},{key:"getICEConfigFromServer",value:(t=_asyncToGenerator(_regeneratorRuntime().mark((function e(t,r,n,i,o,a,s,c){var u,l,d,p,_=this;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return u={appID:r,userID:i,deviceID:o,connectSessionID:genUuid(),os:"web",sdkVersion:Config.VERSION,isOversea:Config.OVERSEA,expectedAddr:getParameter("EXPECTED_ADDR"),productPlatform:"BytePlus",enableCloudProxy:c},a&&s&&(u.feedbackInfo=[{feedbackIP:null===(l=s.publicIPs[0])||void 0===l?void 0:l.ip,feedbackReason:{type:"NODE_CHANGED",reason:a}}],delete u.expectedAddr),d=Date.now(),monitor.rtcGetAccess(0,JSON.stringify(u),0,RtcgetaccessType.REQUEST,t.join(","),u.connectSessionID),p=t.map(function(){var e=_asyncToGenerator(_regeneratorRuntime().mark((function e(t,r){var n,i;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,_._request.post(t,u);case 3:n=e.sent,e.next=9;break;case 6:throw e.prev=6,e.t0=e.catch(0),new SDKError(ErrorCode.ICE_SERVER_WRONG,"get ICE config failed",e.t0);case 9:if(200===n.code){e.next=11;break}throw new SDKError(ErrorCode.ICE_SERVER_WRONG,"get ICE config failed",{server_code:n.code,message:JSON.stringify(n)});case 11:if(i=n.nodes[0]){e.next=14;break}throw new SDKError(ErrorCode.ICE_SERVER_WRONG,"ICE config server return empty nodes",{code:n.code,message:JSON.stringify(n)});case 14:return e.abrupt("return",{result:n,firstNode:i,index:r});case 15:case"end":return e.stop()}}),e,null,[[0,6]])})));return function(t,r){return e.apply(this,arguments)}}()),e.abrupt("return",promiseAny(p).then((function(e){var r=e.result;e.firstNode;var n=e.index;return monitor.rtcGetAccess(200,JSON.stringify(r),Date.now()-d,RtcgetaccessType.RESPONSE,t[n],u.connectSessionID),r})).catch((function(e){var r,n,i=null===(r=e[0])||void 0===r?void 0:r.error;throw monitor.rtcGetAccess(+((null==i?void 0:i.code)||(null==i?void 0:i.server_code)),null===(n=e[0])||void 0===n?void 0:n.message,Date.now()-d,RtcgetaccessType.RESPONSE,t.join(","),u.connectSessionID,{error:JSON.stringify(i)}),i})));case 6:case"end":return e.stop()}}),e)}))),function(e,r,n,i,o,a,s,c){return t.apply(this,arguments)})},{key:"abort",value:function(){this._request.isSending&&(logger$g.print("abort","HTTP Request of [getICEConfigFromServer] abort"),this._request.abort())}}]),e}(),MultiConfigRequestManager=function(){function e(){_classCallCheck(this,e),_defineProperty(this,"_request",void 0),this._request=new HttpRequest}return _createClass(e,[{key:"getH264BlackList",value:function(){var e=this,t={keys:["web_h264_black_list"],labelSelector:"",sdkVersion:"4.46.13",deviceType:"web"};this._request.timeout=800;var r=Config.CONFIG_REQUEST_DOMAINS.map((function(e){return"https://".concat(e,"/decision/v1/multi")}));monitor.rtcGetConfig(0,JSON.stringify(t),0,r.join(","),RtcgetconfigType.REQUEST,"",!1);var n=r.map(function(){var r=_asyncToGenerator(_regeneratorRuntime().mark((function r(n,i){var o,a;return _regeneratorRuntime().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return r.prev=0,r.next=3,e._request.post(n,t);case 3:a=r.sent,r.next=9;break;case 6:throw r.prev=6,r.t0=r.catch(0),new SDKError(ErrorCode.ICE_SERVER_WRONG,"get config failed");case 9:if(Array.isArray(null===(o=a)||void 0===o?void 0:o.web_h264_black_list)){r.next=11;break}throw new SDKError(ErrorCode.ICE_SERVER_WRONG,"get config failed");case 11:return r.abrupt("return",{result:a,index:i});case 12:case"end":return r.stop()}}),r,null,[[0,6]])})));return function(e,t){return r.apply(this,arguments)}}());return new Promise((function(e){promiseAny(n).then((function(t){var n=t.result,i=t.index;sdkCache.setH264BlackList(n.web_h264_black_list),monitor.rtcGetConfig(200,JSON.stringify(n),0,r[i],RtcgetconfigType.RESPONSE,"",!1),e(n.web_h264_black_list)})).catch((function(t){monitor.rtcGetConfig(500,t.message,0,"",RtcgetconfigType.RESPONSE,"",!1),e(sdkCache.getH264BlackList()||[])}))}))}},{key:"getAudioProfile",value:function(){var e=this,t={keys:["engine_BAC"],labelSelector:"",sdkVersion:"4.46.13",deviceType:"web"},r=Config.CONFIG_REQUEST_DOMAINS.map((function(e){return"https://".concat(e,"/decision/v1/multi")}));monitor.rtcGetConfig(0,JSON.stringify(t),0,r.join(","),RtcgetconfigType.REQUEST,"",!1);var n=r.map(function(){var r=_asyncToGenerator(_regeneratorRuntime().mark((function r(n,i){var o,a;return _regeneratorRuntime().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return r.prev=0,r.next=3,e._request.post(n,t);case 3:a=r.sent,r.next=9;break;case 6:throw r.prev=6,r.t0=r.catch(0),new SDKError(ErrorCode.ICE_SERVER_WRONG,"get config failed");case 9:if(Array.isArray(null===(o=a)||void 0===o?void 0:o.engine_BAC)){r.next=11;break}throw new SDKError(ErrorCode.ICE_SERVER_WRONG,"get config failed");case 11:return r.abrupt("return",{result:a,index:i});case 12:case"end":return r.stop()}}),r,null,[[0,6]])})));return function(e,t){return r.apply(this,arguments)}}());return new Promise((function(e){promiseAny(n).then((function(t){var n=t.result,i=t.index;sdkCache.setAudioProfile(n.engine_BAC),monitor.rtcGetConfig(200,JSON.stringify(n),0,r[i],RtcgetconfigType.RESPONSE,"",!1),e(n.engine_BAC)})).catch((function(t){monitor.rtcGetConfig(500,t.message,0,"",RtcgetconfigType.RESPONSE,"",!1),e(sdkCache.getAudioProfile()||[])}))}))}}]),e}();function getBaseEncoderConfig(e,t){var r=1,n=e;(e.width>t.width||e.height>t.height)&&(r=e.width/e.height>t.width/t.height?e.width/t.width:e.height/t.height,n={width:Math.floor(e.width/r),height:Math.floor(e.height/r)});return _objectSpread2(_objectSpread2({},n),{},{scaleResolutionDownBy:r})}var subVideoDescriptions=[{sub_index:0,video_index:0,framerate:30,height:1080,maxkbps:3e3,width:1920},{sub_index:1,video_index:0,framerate:30,height:720,maxkbps:1200,width:1280},{sub_index:2,video_index:0,framerate:30,height:630,maxkbps:1100,width:1120},{sub_index:3,video_index:0,framerate:30,height:540,maxkbps:1e3,width:960},{sub_index:4,video_index:1,framerate:30,height:450,maxkbps:800,width:800},{sub_index:5,video_index:1,framerate:30,height:360,maxkbps:600,width:640},{sub_index:6,video_index:1,framerate:30,height:270,maxkbps:400,width:480},{sub_index:7,video_index:2,framerate:15,height:180,maxkbps:300,width:320},{sub_index:8,video_index:2,framerate:15,height:144,maxkbps:200,width:256},{sub_index:9,video_index:3,framerate:15,height:90,maxkbps:100,width:160}],simulcastFormats=[{width:1920,height:1080,maxLayers:3,totalPixels:2073600},{width:1280,height:720,maxLayers:3,totalPixels:921600},{width:960,height:540,maxLayers:3,totalPixels:518400},{width:640,height:360,maxLayers:2,totalPixels:230400},{width:480,height:270,maxLayers:2,totalPixels:129600},{width:320,height:180,maxLayers:1,totalPixels:57600},{width:0,height:0,maxLayers:1,totalPixels:0}];function getSimulcastLayers(e){for(var t=0,r=e.width*e.height,n=0;n<simulcastFormats.length;n++)if(r>=simulcastFormats[n].totalPixels){t=n;break}if(0===t)return simulcastFormats[t].maxLayers;var i=simulcastFormats[t-1].totalPixels;return(i-r)/(i-simulcastFormats[t].totalPixels)<.1?simulcastFormats[t-1].maxLayers:simulcastFormats[t].maxLayers}var defaultEncoderConfig={"90p":{width:160,height:90,frameRate:15,maxkbps:100},"270p":{width:480,height:270,frameRate:15,maxkbps:400}};function fillSimulcastLayers(e,t){var r=[];if(t<=1)return r;var n=1,i=1;return e.width/e.height>16/9?(n=e.width/defaultEncoderConfig["90p"].width,i=e.width/defaultEncoderConfig["270p"].width):(n=e.height/defaultEncoderConfig["90p"].height,i=e.height/defaultEncoderConfig["270p"].height),r.push({maxkbps:defaultEncoderConfig["90p"].maxkbps,scaleResolutionDownBy:n,frameRate:defaultEncoderConfig["90p"].frameRate,width:Math.floor(e.width/n),height:Math.floor(e.height/n)}),t<=2||n>2&&r.unshift({maxkbps:defaultEncoderConfig["270p"].maxkbps,scaleResolutionDownBy:i,frameRate:defaultEncoderConfig["270p"].frameRate,width:Math.floor(e.width/i),height:Math.floor(e.height/i)}),r}function getSubVideoDescriptions(e){if(!e.length)return[];var t=e.shift(),r=t.width/t.height,n=0,i=0,o=_objectSpread2(_objectSpread2({},t),{},{video_index:i,sub_index:n++});delete o.rid;for(var a=[o],s=0,c=0;c<subVideoDescriptions.length;c++)if(subVideoDescriptions[c].height<t.height){s=c;break}for(var u=e.shift(),l=s;l<subVideoDescriptions.length;l++){var d,p=subVideoDescriptions[l];if(u&&p.height<=(null===(d=u)||void 0===d?void 0:d.height)){var _,f=p.height===(null===(_=u)||void 0===_?void 0:_.height),h=_objectSpread2(_objectSpread2({},u),{},{video_index:++i,sub_index:n++});if(delete h.rid,a.push(h),u=e.shift(),f)continue}a.push(_objectSpread2(_objectSpread2({},p),{},{width:Math.floor(p.height*r),video_index:i,sub_index:n++}))}return a}var cachedSupportedCodecs,isMobileChrome,isChrome="chrome-stable"===getBrowser(),StatProcess=function(){function e(t){_classCallCheck(this,e),_defineProperty(this,"peer",void 0),_defineProperty(this,"stats",void 0),this.peer=t,this.stats=[]}var t,r;return _createClass(e,[{key:"handleCodec",value:function(e){return e}},{key:"handleInboundRtp",value:function(e){return e}},{key:"handleOutboundRtp",value:function(e){var t=e.ssrc;return t&&(e.rtxSsrc=t),e}},{key:"handleRemoteInboundRtp",value:function(e){return e}},{key:"handleRemoteOutboundRtp",value:function(e){return e}},{key:"handleMediaSource",value:function(e){return e}},{key:"handleCsrc",value:function(e){return e}},{key:"handlePeerConnection",value:function(e){return e}},{key:"handleDataChannel",value:function(e){return e}},{key:"handleStream",value:function(e){return e}},{key:"handleTrack",value:function(e){return e}},{key:"handleTransceiver",value:function(e){return e}},{key:"handleSender",value:function(e){return e}},{key:"handleReceiver",value:function(e){return e}},{key:"handleTransport",value:function(e){return e}},{key:"handleSctpTransport",value:function(e){return e}},{key:"handleCandidatePair",value:function(e){return e}},{key:"handleLocalCandidate",value:function(e){return e}},{key:"handleRemoteCandidate",value:function(e){return e}},{key:"handleCertificate",value:function(e){return e}},{key:"handleIceServer",value:function(e){return e}},{key:"processStats",value:function(e){var t=this;e.forEach((function(e){var r;switch(e.type){case"candidate-pair":r=t.handleCandidatePair;break;case"certificate":r=t.handleCertificate;break;case"remote-candidate":r=t.handleRemoteCandidate;break;case"remote-inbound-rtp":case"inbound-rtp":r=t.handleInboundRtp;break;case"remote-outbound-rtp":case"outbound-rtp":r=t.handleOutboundRtp;break;case"sctp-transport":r=t.handleSctpTransport;break;case"sender":r=t.handleSender;break;case"stream":r=t.handleStream;break;case"track":r=t.handleTrack;break;case"transceiver":r=t.handleTransceiver;break;case"transport":r=t.handleTransport;break;case"codec":r=t.handleCodec;break;case"csrc":r=t.handleCsrc;break;case"data-channel":r=t.handleDataChannel;break;case"ice-server":r=t.handleIceServer;break;case"media-source":r=t.handleMediaSource;break;case"peer-connection":r=t.handlePeerConnection;break;case"receiver":r=t.handleReceiver;break;case"local-candidate":r=t.handleLocalCandidate;break;default:r=function(e){return e}}r=r.bind(t),t.stats.push(r(e))}))}},{key:"getExtraStats",value:(r=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){var r=this;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",new Promise((function(e,n){if(!isChrome||void 0!==window.InstallTrigger)return e(r.stats);try{r.peer.getStats((function(n){n.result().forEach((function(e){if(!stasType.includes(e.type)){var n={};e.names().forEach((function(t){n[t]=e.stat(t)})),n.id=e.id,n.type=e.type,n.timestamp=e.timestamp,"ssrc"===n.type&&t&&t.id?t.id===n.googTrackId&&r.stats.push(n):r.stats.push(n)}})),e(r.stats)}))}catch(e){n(e)}})));case 1:case"end":return e.stop()}}),e)}))),function(e){return r.apply(this,arguments)})},{key:"getStats",value:(t=_asyncToGenerator(_regeneratorRuntime().mark((function e(t,r){var n;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,this.peer.getStats(t);case 3:if(n=e.sent,this.processStats(n),e.prev=5,r){e.next=9;break}return e.next=9,this.getExtraStats(t);case 9:e.next=13;break;case 11:e.prev=11,e.t0=e.catch(5);case 13:e.next=17;break;case 15:e.prev=15,e.t1=e.catch(0);case 17:return e.abrupt("return",this.stats);case 18:case"end":return e.stop()}}),e,this,[[0,15],[5,11]])}))),function(e,r){return t.apply(this,arguments)})}]),e}(),stasType=["codec","inbound-rtp","outbound-rtp","remote-inbound-rtp","remote-outbound-rtp","media-source","csrc","peer-connection","data-channel","stream","track","transceiver","sender","receiver","transport","sctp-transport","candidate-pair","local-candidate","remote-candidate","certificate","ice-server"],getStats=function(){var e=_asyncToGenerator(_regeneratorRuntime().mark((function e(t,r,n){var i,o;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(i=[],t instanceof RTCPeerConnection){e.next=3;break}return e.abrupt("return",i);case 3:return o=new StatProcess(t),e.next=6,o.getStats(r,n);case 6:return i=e.sent,e.abrupt("return",i);case 8:case"end":return e.stop()}}),e)})));return function(t,r,n){return e.apply(this,arguments)}}(),AudioMixingDualMonoMode=function(e){return e[e.AUTO=0]="AUTO",e[e.MODE_L=1]="MODE_L",e[e.MODE_R=2]="MODE_R",e[e.MODE_MIX=3]="MODE_MIX",e}(AudioMixingDualMonoMode||{}),AudioMixingType=function(e){return e[e.PLAYOUT=0]="PLAYOUT",e[e.PUBLISH=1]="PUBLISH",e[e.PLAYOUT_AND_PUBLISH=2]="PLAYOUT_AND_PUBLISH",e}(AudioMixingType||{}),AudioMixingState=function(e){return e[e.AUDIO_MIXING_STATE_PRELOADED=0]="AUDIO_MIXING_STATE_PRELOADED",e[e.AUDIO_MIXING_STATE_PLAYING=1]="AUDIO_MIXING_STATE_PLAYING",e[e.AUDIO_MIXING_STATE_PAUSED=2]="AUDIO_MIXING_STATE_PAUSED",e[e.AUDIO_MIXING_STATE_STOPPED=3]="AUDIO_MIXING_STATE_STOPPED",e[e.AUDIO_MIXING_STATE_FAILED=4]="AUDIO_MIXING_STATE_FAILED",e[e.AUDIO_MIXING_STATE_FINISHED=5]="AUDIO_MIXING_STATE_FINISHED",e[e.AUDIO_MIXING_STATE_PCM_ENABLED=6]="AUDIO_MIXING_STATE_PCM_ENABLED",e[e.AUDIO_MIXING_STATE_PCM_DISABLED=7]="AUDIO_MIXING_STATE_PCM_DISABLED",e}(AudioMixingState||{}),isSupported=function(){var e=_asyncToGenerator(_regeneratorRuntime().mark((function e(){var t;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(e.prev=0,!isSSR()&&window.RTCPeerConnection&&window.RTCPeerConnection.prototype.addTransceiver&&window.RTCPeerConnection.prototype.createDataChannel){e.next=3;break}return e.abrupt("return",!1);case 3:return e.next=5,internalGetSupportedCodecs();case 5:return t=e.sent,e.abrupt("return",null==t?void 0:t.includes("H264"));case 9:return e.prev=9,e.t0=e.catch(0),e.abrupt("return",!1);case 12:case"end":return e.stop()}}),e,null,[[0,9]])})));return function(){return e.apply(this,arguments)}}(),internalGetSupportedCodecs=function(){var e=_asyncToGenerator(_regeneratorRuntime().mark((function e(){var t,r,n,i,o,a,s,c;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!cachedSupportedCodecs){e.next=2;break}return e.abrupt("return",cachedSupportedCodecs);case 2:return t=[],e.prev=3,e.next=6,createDefaultSdp();case 6:if(r=e.sent){e.next=9;break}return e.abrupt("return",t);case 9:if(!(null!=r&&r.includes("level-asymmetry-allowed=1;packetization-mode=1;profile-level-id=42e01f")||null!=r&&r.includes("profile-level-id=42e01f;level-asymmetry-allowed=1;packetization-mode=1")||null!=r&&r.includes("packetization-mode=1;profile-level-id=42e01f;level-asymmetry-allowed=1"))){e.next=20;break}return n=navigator.userAgent.toLowerCase(),i=!1,o=["heytapbrowser","mqqbrowser","miuibrowser"],a=new MultiConfigRequestManager,e.next=16,a.getH264BlackList();case 16:for(s=e.sent,o.push.apply(o,_toConsumableArray(s)),c=0;c<o.length;c++)n.includes(o[c])&&(i=!0);!i&&t.push("H264");case 20:return null!=r&&r.includes("VP8")&&t.push("vp8"),cachedSupportedCodecs=t,e.abrupt("return",t);case 25:return e.prev=25,e.t0=e.catch(3),e.abrupt("return",t);case 28:case"end":return e.stop()}}),e,null,[[3,25]])})));return function(){return e.apply(this,arguments)}}(),getSupportedCodecs=function(){var e=_asyncToGenerator(_regeneratorRuntime().mark((function e(){var t;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,internalGetSupportedCodecs();case 2:return t=e.sent,e.abrupt("return",t.map((function(e){return e.toUpperCase()})));case 4:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),isEncodedTransformSupported=function(){return"undefined"!=typeof TransformStream&&"undefined"!=typeof RTCRtpSender&&"undefined"!=typeof RTCRtpReceiver&&void 0!==RTCRtpSender.prototype.createEncodedStreams&&void 0!==RTCRtpReceiver.prototype.createEncodedStreams},logger$f=new Logger("BasicHandler",3),encodedTransformSupported$1=isEncodedTransformSupported(),peerConnectionConfiguration={iceServers:[],iceTransportPolicy:"all",bundlePolicy:"max-bundle",rtcpMuxPolicy:"require",sdpSemantics:"unified-plan",encodedInsertableStreams:!!encodedTransformSupported$1||void 0};function ensureScaleResolutionDownByBeInt(e){if(void 0===isMobileChrome){var t=navigator.userAgent.toLowerCase();isMobileChrome=t.includes("chrome")&&t.includes("mobile")}return isMobileChrome?Math.ceil(e):e}var BasicHandler=function(e){_inherits(a,eventemitter3.exports.EventEmitter);var t,r,n,i,o=_createSuper(a);function a(e,t){var r;return _classCallCheck(this,a),_defineProperty(_assertThisInitialized(r=o.call(this)),"_peerConnection",void 0),_defineProperty(_assertThisInitialized(r),"_dataChannel",void 0),_defineProperty(_assertThisInitialized(r),"_context",void 0),_defineProperty(_assertThisInitialized(r),"monitor",void 0),_defineProperty(_assertThisInitialized(r),"_offerIce",{}),_defineProperty(_assertThisInitialized(r),"_answerIce",{}),_defineProperty(_assertThisInitialized(r),"_initSctpEvents",!1),r.monitor=e,r._peerConnection=new RTCPeerConnection(peerConnectionConfiguration),r._dataChannel=r._peerConnection.createDataChannel("signaling",{negotiated:!0,id:100}),r._context=t,r._dataChannel.binaryType="arraybuffer",r._peerConnection.ontrack=function(e){var t,n;logger$f.print("constructor","pc.ontrack ".concat(e.track.kind," ").concat(e.track.id," ").concat(null===(t=e.streams)||void 0===t||null===(n=t[0])||void 0===n?void 0:n.id)),r.emit("ontrack",e)},r._peerConnection.onconnectionstatechange=function(e){logger$f.print("constructor","onconnectionstatechange ".concat(r._peerConnection.iceConnectionState," -> ").concat(r._peerConnection.connectionState)),"failed"!==r._peerConnection.iceConnectionState&&"closed"!==r._peerConnection.iceConnectionState&&"failed"!==r._peerConnection.connectionState||r.emit("disconnect")},r._peerConnection.oniceconnectionstatechange=function(){var t=r._peerConnection.iceConnectionState;e.rtcPreIceState(t,RtcpreicestateIceState["".concat(t.toUpperCase())])},r}return _createClass(a,[{key:"disconnect",value:function(){this._peerConnection.close(),this._dataChannel.close(),this._peerConnection.ontrack=null}},{key:"destroy",value:function(){logger$f.print("destroy"),this.disconnect(),this._context=void 0}},{key:"_simulcast",value:function(e,t,r,n,i){var o=[],a=getSimulcastLayers(t);logger$f.print("simulcast() ","maxLayers: %o",a),1===e.videoEncodeConfig.length?(o=fillSimulcastLayers(r,a),logger$f.print("simulcast() ","simulcastLayers: %o",o)):(o=e.videoEncodeConfig.slice(1).slice(1-a).map((function(e){return _objectSpread2({frameRate:e.frameRate||15,maxkbps:e.maxKbps||600},getBaseEncoderConfig(r,e))})),logger$f.print("simulcast() ","simulcastLayers2: %o",o)),o.forEach((function(e,t){var r,o={maxBitrate:1e3*e.maxkbps,scaleResolutionDownBy:ensureScaleResolutionDownByBeInt(e.scaleResolutionDownBy),rid:"".concat(t+1),maxFramerate:e.frameRate};null===(r=n.sendEncodings)||void 0===r||r.unshift(o),i.push({width:e.width,height:e.height,framerate:e.frameRate,maxkbps:e.maxkbps,rid:"".concat(t+1)})}))}},{key:"internalPublish",value:function(e,t){var r=e.stream,n=e.videoTrack,i=e.audioTrack,o=e.enableSimulcast,a=e.pubAudio,s=e.pubVideo,c={direction:"sendonly",streams:[r]},u={direction:"sendonly",streams:[r]},l=[],d=[];if(Array.isArray(null==e?void 0:e.videoEncodeConfig)&&e.videoEncodeConfig.length){var p=null==n?void 0:n.getTrack(),_={width:640,height:360,frameRate:30};if(p){var f=null==p?void 0:p.getSettings();_={width:Math.floor(f.width),height:Math.floor(f.height),frameRate:Math.floor(f.frameRate)}}var h=null==e?void 0:e.videoEncodeConfig[0],m=getBaseEncoderConfig(_,h);e.prevScaleResolutionDownBy=m.scaleResolutionDownBy,e.videoInputConfig=_;var y={maxBitrate:1e3*h.maxKbps,scaleResolutionDownBy:ensureScaleResolutionDownByBeInt(m.scaleResolutionDownBy),rid:"0",maxFramerate:h.frameRate||15};u.sendEncodings=[y],l.push({width:m.width,height:m.height,framerate:h.frameRate,maxkbps:h.maxKbps,rid:"0"}),o&&(this._simulcast(e,m,_,u,l),null!=t&&t.simulcastOnDemand&&(d=getSubVideoDescriptions([].concat(l))),logger$f.print("subVideoDesc","desc: %o ",d))}logger$f.print("publish videoTransceiverInit videoDescriptions","",u,l);var v=null==i?void 0:i.getTrack();(null==i?void 0:i.mixType)!==AudioMixingType.PLAYOUT&&null!=i&&i.mixedAudioTrack&&(v=null==i?void 0:i.mixedAudioTrack),v=a&&v?v:"audio";var S=null==n?void 0:n.getTrack();return{semantics:"unified-plan",videoDescriptions:l,subVideoDescriptions:d,transceiverInit:{aTrack:v,vTrack:S=s&&S?S:"video",audioTransceiverInit:c,videoTransceiverInit:u}}}},{key:"updateScaleResolutionDownBy",value:(i=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){var r,n,i,o,a,s,c,u,l,d;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(logger$f.print("updateScaleResolutionDownBy()"),i=null===(r=t.videoTrack)||void 0===r?void 0:r.getTrack(),o=t.videoTransceiver,i&&t.pubVideo&&o){e.next=6;break}return logger$f.print("updateScaleResolutionDownBy()","no pub"),e.abrupt("return");case 6:a=null==i?void 0:i.getSettings(),s={width:Math.floor(a.width),height:Math.floor(a.height),frameRate:Math.floor(a.frameRate)},(c=getBaseEncoderConfig(s,t.videoEncodeConfig[0])).scaleResolutionDownBy===t.prevScaleResolutionDownBy&&logger$f.print("updateScaleResolutionDownBy()","no change %o",t.prevScaleResolutionDownBy),(u=null===(n=o.sender)||void 0===n?void 0:n.getParameters())&&(d=c.scaleResolutionDownBy/t.prevScaleResolutionDownBy,u.encodings=null==u||null===(l=u.encodings)||void 0===l?void 0:l.map((function(e){var r,n;Math.max(e.scaleResolutionDownBy=(e.scaleResolutionDownBy||1)*d,1);var i=+e.rid||0;e.maxFramerate=(null===(r=t.videoEncodeConfig[i])||void 0===r?void 0:r.frameRate)||e.maxFramerate;var o=null===(n=t.videoEncodeConfig[i])||void 0===n?void 0:n.maxKbps;return"number"==typeof o&&(e.maxBitrate=1e3*o),e})),t.prevScaleResolutionDownBy=c.scaleResolutionDownBy,t.videoInputConfig=s,null==o||o.sender.setParameters(u));case 12:case"end":return e.stop()}}),e)}))),function(e){return i.apply(this,arguments)})},{key:"getStats",value:function(e,t){return getStats(this._peerConnection,e,t)}},{key:"setLocalDescription",value:(n=_asyncToGenerator(_regeneratorRuntime().mark((function e(t,r){var n,i,o,a=this;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=getServerNow(),e.prev=1,e.next=4,this._peerConnection.setLocalDescription(new RTCSessionDescription({type:"offer",sdp:t}));case 4:this.monitor.rtcSetDescription(0,t,RtcsetdescriptionIsLocal.W_1,"local"===(null==r?void 0:r.streamUserId)?RtcsetdescriptionDirection.UP:RtcsetdescriptionDirection.DOWN,(null==r?void 0:r.streamId)||"",(null==r?void 0:r.streamUserId)||"",getServerNow()-n,{type:"offer"}),this._initSctpEvents||(this._initSctpEvents=!0,(o=null===(i=this._peerConnection)||void 0===i?void 0:i.sctp)&&(o.onstatechange=function(){a.monitor.rtcInvokeStatus("sctp state change TO: ".concat(o.state),0,"sctp","",0)},o.transport&&(o.transport.onstatechange=function(){var e;a.monitor.rtcInvokeStatus("dtls state change TO: ".concat(null==o||null===(e=o.transport)||void 0===e?void 0:e.state),0,"dtls","",0)}))),e.next=12;break;case 8:e.prev=8,e.t0=e.catch(1),console.error("setLocal",e.t0),this.monitor.rtcSetDescription(-1,e.t0.message+t,RtcsetdescriptionIsLocal.W_1,"local"===(null==r?void 0:r.streamUserId)?RtcsetdescriptionDirection.UP:RtcsetdescriptionDirection.DOWN,"","",getServerNow()-n,{type:"offer"});case 12:case"end":return e.stop()}}),e,this,[[1,8]])}))),function(e,t){return n.apply(this,arguments)})},{key:"setRemoteDescription",value:(r=_asyncToGenerator(_regeneratorRuntime().mark((function e(t,r){var n;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=getServerNow(),e.prev=1,e.next=4,this._peerConnection.setRemoteDescription(new RTCSessionDescription({type:"answer",sdp:t}));case 4:this.monitor.rtcSetDescription(0,t,RtcsetdescriptionIsLocal.W_0,"local"===(null==r?void 0:r.streamUserId)?RtcsetdescriptionDirection.UP:RtcsetdescriptionDirection.DOWN,(null==r?void 0:r.streamId)||"",(null==r?void 0:r.streamUserId)||"",getServerNow()-n,{type:"answer"}),e.next=11;break;case 7:e.prev=7,e.t0=e.catch(1),console.error("setRemote",e.t0),this.monitor.rtcSetDescription(-1,e.t0.message+t,RtcsetdescriptionIsLocal.W_1,"local"===(null==r?void 0:r.streamUserId)?RtcsetdescriptionDirection.UP:RtcsetdescriptionDirection.DOWN,(null==r?void 0:r.streamId)||"",(null==r?void 0:r.streamUserId)||"",getServerNow()-n,{type:"answer"});case 11:case"end":return e.stop()}}),e,this,[[1,7]])}))),function(e,t){return r.apply(this,arguments)})},{key:"setCurrentDescription",value:(t=_asyncToGenerator(_regeneratorRuntime().mark((function e(){return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:case"end":return e.stop()}}),e)}))),function(){return t.apply(this,arguments)})},{key:"pc",get:function(){return this._peerConnection}},{key:"addBitrateLimit",value:function(e,t){null==e||e.rtp.forEach((function(r){var n=r.codec,i=r.payload;if(["vp8","h264"].includes(n.toLocaleLowerCase())){var o=e.fmtp.find((function(e){return e.payload===i}));o&&(o.config=[].concat(_toConsumableArray(o.config.split(";")),["x-google-min-bitrate=100","x-google-start-bitrate=".concat(t)]).join(";"))}}))}}]),a}(),lib={},apply$1=functionApply,call$1=functionCall,uncurryThis$5=functionUncurryThis,fixRegExpWellKnownSymbolLogic=fixRegexpWellKnownSymbolLogic,anObject$2=anObject$q,isNullOrUndefined$1=isNullOrUndefined$b,isRegExp=isRegexp,requireObjectCoercible=requireObjectCoercible$d,speciesConstructor=speciesConstructor$4,advanceStringIndex=advanceStringIndex$3,toLength=toLength$a,toString=toString$m,getMethod=getMethod$7,arraySlice$1=arraySliceSimple,callRegExpExec=regexpExecAbstract,regexpExec=regexpExec$3,stickyHelpers=regexpStickyHelpers,fails$1=fails$U,UNSUPPORTED_Y=stickyHelpers.UNSUPPORTED_Y,MAX_UINT32=4294967295,min=Math.min,$push=[].push,exec$2=uncurryThis$5(/./.exec),push$3=uncurryThis$5($push),stringSlice$2=uncurryThis$5("".slice),SPLIT_WORKS_WITH_OVERWRITTEN_EXEC=!fails$1((function(){var e=/(?:)/,t=e.exec;e.exec=function(){return t.apply(this,arguments)};var r="ab".split(e);return 2!==r.length||"a"!==r[0]||"b"!==r[1]}));fixRegExpWellKnownSymbolLogic("split",(function(e,t,r){var n;return n="c"=="abbc".split(/(b)*/)[1]||4!="test".split(/(?:)/,-1).length||2!="ab".split(/(?:ab)*/).length||4!=".".split(/(.?)(.?)/).length||".".split(/()()/).length>1||"".split(/.?/).length?function(e,r){var n=toString(requireObjectCoercible(this)),i=void 0===r?MAX_UINT32:r>>>0;if(0===i)return[];if(void 0===e)return[n];if(!isRegExp(e))return call$1(t,n,e,i);for(var o,a,s,c=[],u=(e.ignoreCase?"i":"")+(e.multiline?"m":"")+(e.unicode?"u":"")+(e.sticky?"y":""),l=0,d=new RegExp(e.source,u+"g");(o=call$1(regexpExec,d,n))&&!((a=d.lastIndex)>l&&(push$3(c,stringSlice$2(n,l,o.index)),o.length>1&&o.index<n.length&&apply$1($push,c,arraySlice$1(o,1)),s=o[0].length,l=a,c.length>=i));)d.lastIndex===o.index&&d.lastIndex++;return l===n.length?!s&&exec$2(d,"")||push$3(c,""):push$3(c,stringSlice$2(n,l)),c.length>i?arraySlice$1(c,0,i):c}:"0".split(void 0,0).length?function(e,r){return void 0===e&&0===r?[]:call$1(t,this,e,r)}:t,[function(t,r){var i=requireObjectCoercible(this),o=isNullOrUndefined$1(t)?void 0:getMethod(t,e);return o?call$1(o,t,i,r):call$1(n,toString(i),t,r)},function(e,i){var o=anObject$2(this),a=toString(e),s=r(n,o,a,i,n!==t);if(s.done)return s.value;var c=speciesConstructor(o,RegExp),u=o.unicode,l=(o.ignoreCase?"i":"")+(o.multiline?"m":"")+(o.unicode?"u":"")+(UNSUPPORTED_Y?"g":"y"),d=new c(UNSUPPORTED_Y?"^(?:"+o.source+")":o,l),p=void 0===i?MAX_UINT32:i>>>0;if(0===p)return[];if(0===a.length)return null===callRegExpExec(d,a)?[a]:[];for(var _=0,f=0,h=[];f<a.length;){d.lastIndex=UNSUPPORTED_Y?0:f;var m,y=callRegExpExec(d,UNSUPPORTED_Y?stringSlice$2(a,f):a);if(null===y||(m=min(toLength(d.lastIndex+(UNSUPPORTED_Y?f:0)),a.length))===_)f=advanceStringIndex(a,f,u);else{if(push$3(h,stringSlice$2(a,_,f)),h.length===p)return h;for(var v=1;v<=y.length-1;v++)if(push$3(h,y[v]),h.length===p)return h;f=_=m}}return push$3(h,stringSlice$2(a,_)),h}]}),!SPLIT_WORKS_WITH_OVERWRITTEN_EXEC,UNSUPPORTED_Y);var parser$1={},grammar$2={exports:{}},grammar$1=grammar$2.exports={v:[{name:"version",reg:/^(\d*)$/}],o:[{name:"origin",reg:/^(\S*) (\d*) (\d*) (\S*) IP(\d) (\S*)/,names:["username","sessionId","sessionVersion","netType","ipVer","address"],format:"%s %s %d %s IP%d %s"}],s:[{name:"name"}],i:[{name:"description"}],u:[{name:"uri"}],e:[{name:"email"}],p:[{name:"phone"}],z:[{name:"timezones"}],r:[{name:"repeats"}],t:[{name:"timing",reg:/^(\d*) (\d*)/,names:["start","stop"],format:"%d %d"}],c:[{name:"connection",reg:/^IN IP(\d) (\S*)/,names:["version","ip"],format:"IN IP%d %s"}],b:[{push:"bandwidth",reg:/^(TIAS|AS|CT|RR|RS):(\d*)/,names:["type","limit"],format:"%s:%s"}],m:[{reg:/^(\w*) (\d*) ([\w/]*)(?: (.*))?/,names:["type","port","protocol","payloads"],format:"%s %d %s %s"}],a:[{push:"rtp",reg:/^rtpmap:(\d*) ([\w\-.]*)(?:\s*\/(\d*)(?:\s*\/(\S*))?)?/,names:["payload","codec","rate","encoding"],format:function(e){return e.encoding?"rtpmap:%d %s/%s/%s":e.rate?"rtpmap:%d %s/%s":"rtpmap:%d %s"}},{push:"fmtp",reg:/^fmtp:(\d*) ([\S| ]*)/,names:["payload","config"],format:"fmtp:%d %s"},{name:"control",reg:/^control:(.*)/,format:"control:%s"},{name:"rtcp",reg:/^rtcp:(\d*)(?: (\S*) IP(\d) (\S*))?/,names:["port","netType","ipVer","address"],format:function(e){return null!=e.address?"rtcp:%d %s IP%d %s":"rtcp:%d"}},{push:"rtcpFbTrrInt",reg:/^rtcp-fb:(\*|\d*) trr-int (\d*)/,names:["payload","value"],format:"rtcp-fb:%s trr-int %d"},{push:"rtcpFb",reg:/^rtcp-fb:(\*|\d*) ([\w-_]*)(?: ([\w-_]*))?/,names:["payload","type","subtype"],format:function(e){return null!=e.subtype?"rtcp-fb:%s %s %s":"rtcp-fb:%s %s"}},{push:"ext",reg:/^extmap:(\d+)(?:\/(\w+))?(?: (urn:ietf:params:rtp-hdrext:encrypt))? (\S*)(?: (\S*))?/,names:["value","direction","encrypt-uri","uri","config"],format:function(e){return"extmap:%d"+(e.direction?"/%s":"%v")+(e["encrypt-uri"]?" %s":"%v")+" %s"+(e.config?" %s":"")}},{name:"extmapAllowMixed",reg:/^(extmap-allow-mixed)/},{push:"crypto",reg:/^crypto:(\d*) ([\w_]*) (\S*)(?: (\S*))?/,names:["id","suite","config","sessionConfig"],format:function(e){return null!=e.sessionConfig?"crypto:%d %s %s %s":"crypto:%d %s %s"}},{name:"setup",reg:/^setup:(\w*)/,format:"setup:%s"},{name:"connectionType",reg:/^connection:(new|existing)/,format:"connection:%s"},{name:"mid",reg:/^mid:([^\s]*)/,format:"mid:%s"},{name:"msid",reg:/^msid:(.*)/,format:"msid:%s"},{name:"ptime",reg:/^ptime:(\d*(?:\.\d*)*)/,format:"ptime:%d"},{name:"maxptime",reg:/^maxptime:(\d*(?:\.\d*)*)/,format:"maxptime:%d"},{name:"direction",reg:/^(sendrecv|recvonly|sendonly|inactive)/},{name:"icelite",reg:/^(ice-lite)/},{name:"iceUfrag",reg:/^ice-ufrag:(\S*)/,format:"ice-ufrag:%s"},{name:"icePwd",reg:/^ice-pwd:(\S*)/,format:"ice-pwd:%s"},{name:"fingerprint",reg:/^fingerprint:(\S*) (\S*)/,names:["type","hash"],format:"fingerprint:%s %s"},{push:"candidates",reg:/^candidate:(\S*) (\d*) (\S*) (\d*) (\S*) (\d*) typ (\S*)(?: raddr (\S*) rport (\d*))?(?: tcptype (\S*))?(?: generation (\d*))?(?: network-id (\d*))?(?: network-cost (\d*))?/,names:["foundation","component","transport","priority","ip","port","type","raddr","rport","tcptype","generation","network-id","network-cost"],format:function(e){var t="candidate:%s %d %s %d %s %d typ %s";return t+=null!=e.raddr?" raddr %s rport %d":"%v%v",t+=null!=e.tcptype?" tcptype %s":"%v",null!=e.generation&&(t+=" generation %d"),t+=null!=e["network-id"]?" network-id %d":"%v",t+=null!=e["network-cost"]?" network-cost %d":"%v"}},{name:"endOfCandidates",reg:/^(end-of-candidates)/},{name:"remoteCandidates",reg:/^remote-candidates:(.*)/,format:"remote-candidates:%s"},{name:"iceOptions",reg:/^ice-options:(\S*)/,format:"ice-options:%s"},{push:"ssrcs",reg:/^ssrc:(\d*) ([\w_-]*)(?::(.*))?/,names:["id","attribute","value"],format:function(e){var t="ssrc:%d";return null!=e.attribute&&(t+=" %s",null!=e.value&&(t+=":%s")),t}},{push:"ssrcGroups",reg:/^ssrc-group:([\x21\x23\x24\x25\x26\x27\x2A\x2B\x2D\x2E\w]*) (.*)/,names:["semantics","ssrcs"],format:"ssrc-group:%s %s"},{name:"msidSemantic",reg:/^msid-semantic:\s?(\w*) (\S*)/,names:["semantic","token"],format:"msid-semantic: %s %s"},{push:"groups",reg:/^group:(\w*) (.*)/,names:["type","mids"],format:"group:%s %s"},{name:"rtcpMux",reg:/^(rtcp-mux)/},{name:"rtcpRsize",reg:/^(rtcp-rsize)/},{name:"sctpmap",reg:/^sctpmap:([\w_/]*) (\S*)(?: (\S*))?/,names:["sctpmapNumber","app","maxMessageSize"],format:function(e){return null!=e.maxMessageSize?"sctpmap:%s %s %s":"sctpmap:%s %s"}},{name:"xGoogleFlag",reg:/^x-google-flag:([^\s]*)/,format:"x-google-flag:%s"},{push:"rids",reg:/^rid:([\d\w]+) (\w+)(?: ([\S| ]*))?/,names:["id","direction","params"],format:function(e){return e.params?"rid:%s %s %s":"rid:%s %s"}},{push:"imageattrs",reg:new RegExp("^imageattr:(\\d+|\\*)[\\s\\t]+(send|recv)[\\s\\t]+(\\*|\\[\\S+\\](?:[\\s\\t]+\\[\\S+\\])*)(?:[\\s\\t]+(recv|send)[\\s\\t]+(\\*|\\[\\S+\\](?:[\\s\\t]+\\[\\S+\\])*))?"),names:["pt","dir1","attrs1","dir2","attrs2"],format:function(e){return"imageattr:%s %s %s"+(e.dir2?" %s %s":"")}},{name:"simulcast",reg:new RegExp("^simulcast:(send|recv) ([a-zA-Z0-9\\-_~;,]+)(?:\\s?(send|recv) ([a-zA-Z0-9\\-_~;,]+))?$"),names:["dir1","list1","dir2","list2"],format:function(e){return"simulcast:%s %s"+(e.dir2?" %s %s":"")}},{name:"simulcast_03",reg:/^simulcast:[\s\t]+([\S+\s\t]+)$/,names:["value"],format:"simulcast: %s"},{name:"framerate",reg:/^framerate:(\d+(?:$|\.\d+))/,format:"framerate:%s"},{name:"sourceFilter",reg:/^source-filter: *(excl|incl) (\S*) (IP4|IP6|\*) (\S*) (.*)/,names:["filterMode","netType","addressTypes","destAddress","srcList"],format:"source-filter: %s %s %s %s %s"},{name:"bundleOnly",reg:/^(bundle-only)/},{name:"label",reg:/^label:(.+)/,format:"label:%s"},{name:"sctpPort",reg:/^sctp-port:(\d+)$/,format:"sctp-port:%s"},{name:"maxMessageSize",reg:/^max-message-size:(\d+)$/,format:"max-message-size:%s"},{push:"tsRefClocks",reg:/^ts-refclk:([^\s=]*)(?:=(\S*))?/,names:["clksrc","clksrcExt"],format:function(e){return"ts-refclk:%s"+(null!=e.clksrcExt?"=%s":"")}},{name:"mediaClk",reg:/^mediaclk:(?:id=(\S*))? *([^\s=]*)(?:=(\S*))?(?: *rate=(\d+)\/(\d+))?/,names:["id","mediaClockName","mediaClockValue","rateNumerator","rateDenominator"],format:function(e){var t="mediaclk:";return t+=null!=e.id?"id=%s %s":"%v%s",t+=null!=e.mediaClockValue?"=%s":"",t+=null!=e.rateNumerator?" rate=%s":"",t+=null!=e.rateDenominator?"/%s":""}},{name:"keywords",reg:/^keywds:(.+)$/,format:"keywds:%s"},{name:"content",reg:/^content:(.+)/,format:"content:%s"},{name:"bfcpFloorCtrl",reg:/^floorctrl:(c-only|s-only|c-s)/,format:"floorctrl:%s"},{name:"bfcpConfId",reg:/^confid:(\d+)/,format:"confid:%s"},{name:"bfcpUserId",reg:/^userid:(\d+)/,format:"userid:%s"},{name:"bfcpFloorId",reg:/^floorid:(.+) (?:m-stream|mstrm):(.+)/,names:["id","mStream"],format:"floorid:%s mstrm:%s"},{push:"invalid",names:["value"]}]};Object.keys(grammar$1).forEach((function(e){grammar$1[e].forEach((function(e){e.reg||(e.reg=/(.*)/),e.format||(e.format="%s")}))})),function(e){var t=function(e){return String(Number(e))===e?Number(e):e},r=function(e,r,n){var i=e.name&&e.names;e.push&&!r[e.push]?r[e.push]=[]:i&&!r[e.name]&&(r[e.name]={});var o=e.push?{}:i?r[e.name]:r;!function(e,r,n,i){if(i&&!n)r[i]=t(e[1]);else for(var o=0;o<n.length;o+=1)null!=e[o+1]&&(r[n[o]]=t(e[o+1]))}(n.match(e.reg),o,e.names,e.name),e.push&&r[e.push].push(o)},n=grammar$2.exports,i=RegExp.prototype.test.bind(/^([a-z])=(.*)/);e.parse=function(e){var t={},o=[],a=t;return e.split(/(\r\n|\r|\n)/).filter(i).forEach((function(e){var t=e[0],i=e.slice(2);"m"===t&&(o.push({rtp:[],fmtp:[]}),a=o[o.length-1]);for(var s=0;s<(n[t]||[]).length;s+=1){var c=n[t][s];if(c.reg.test(i))return r(c,a,i)}})),t.media=o,t};var o=function(e,r){var n=r.split(/=(.+)/,2);return 2===n.length?e[n[0]]=t(n[1]):1===n.length&&r.length>1&&(e[n[0]]=void 0),e};e.parseParams=function(e){return e.split(/;\s?/).reduce(o,{})},e.parseFmtpConfig=e.parseParams,e.parsePayloads=function(e){return e.toString().split(" ").map(Number)},e.parseRemoteCandidates=function(e){for(var r=[],n=e.split(" ").map(t),i=0;i<n.length;i+=3)r.push({component:n[i],ip:n[i+1],port:n[i+2]});return r},e.parseImageAttributes=function(e){return e.split(" ").map((function(e){return e.substring(1,e.length-1).split(",").reduce(o,{})}))},e.parseSimulcastStreamList=function(e){return e.split(";").map((function(e){return e.split(",").map((function(e){var r,n=!1;return"~"!==e[0]?r=t(e):(r=t(e.substring(1,e.length)),n=!0),{scid:r,paused:n}}))}))}}(parser$1);var grammar=grammar$2.exports,formatRegExp=/%[sdv%]/g,format=function(e){var t=1,r=arguments,n=r.length;return e.replace(formatRegExp,(function(e){if(t>=n)return e;var i=r[t];switch(t+=1,e){case"%%":return"%";case"%s":return String(i);case"%d":return Number(i);case"%v":return""}}))},makeLine=function(e,t,r){var n=[e+"="+(t.format instanceof Function?t.format(t.push?r:r[t.name]):t.format)];if(t.names)for(var i=0;i<t.names.length;i+=1){var o=t.names[i];t.name?n.push(r[t.name][o]):n.push(r[t.names[i]])}else n.push(r[t.name]);return format.apply(null,n)},defaultOuterOrder=["v","o","s","i","u","e","p","c","b","t","r","z","a"],defaultInnerOrder=["i","c","b","a"],writer$1=function(e,t){t=t||{},null==e.version&&(e.version=0),null==e.name&&(e.name=" "),e.media.forEach((function(e){null==e.payloads&&(e.payloads="")}));var r=t.outerOrder||defaultOuterOrder,n=t.innerOrder||defaultInnerOrder,i=[];return r.forEach((function(t){grammar[t].forEach((function(r){r.name in e&&null!=e[r.name]?i.push(makeLine(t,r,e)):r.push in e&&null!=e[r.push]&&e[r.push].forEach((function(e){i.push(makeLine(t,r,e))}))}))})),e.media.forEach((function(e){i.push(makeLine("m",grammar.m[0],e)),n.forEach((function(t){grammar[t].forEach((function(r){r.name in e&&null!=e[r.name]?i.push(makeLine(t,r,e)):r.push in e&&null!=e[r.push]&&e[r.push].forEach((function(e){i.push(makeLine(t,r,e))}))}))}))})),i.join("\r\n")+"\r\n"},parser=parser$1,writer=writer$1;lib.write=writer,lib.parse=parser.parse,lib.parseParams=parser.parseParams,lib.parseFmtpConfig=parser.parseFmtpConfig,lib.parsePayloads=parser.parsePayloads,lib.parseRemoteCandidates=parser.parseRemoteCandidates,lib.parseImageAttributes=parser.parseImageAttributes,lib.parseSimulcastStreamList=parser.parseSimulcastStreamList;var SSRC_MAX=Math.pow(2,32),SSRC_MIN=1e3,generateSsrcId=function(){return Math.floor(Math.random()*SSRC_MAX+SSRC_MIN)},generateSsrc=function(e,t,r){return r||(r=generateSsrcId()),[{id:r,attribute:"cname",value:"kp34Za0H+aVf862l"},{id:r,attribute:"msid",value:"".concat(e.id," ").concat(e.id,"-").concat(t)},{id:r,attribute:"mslabel",value:"".concat(e.id)},{id:r,attribute:"label",value:"".concat(e.id,"-").concat(t)}]},generateSsrcs=function(e,t){var r=generateSsrcId(),n=generateSsrcId();return{ssrcs:[r,n].reduce((function(r,n){return r.concat(generateSsrc(e,t,n))}),[]),ssrcGroups:[{semantics:"FID",ssrcs:"".concat(r," ").concat(n)}]}};function closeMline(e){return e.direction="inactive",e.port=0,delete e.ext,delete e.ssrcs,delete e.ssrcGroups,delete e.simulcast,delete e.simulcast_03,delete e.rids,delete e.extmapAllowMixed,delete e.bundleOnly,e}var getLocalPartialSdp=function(e,t,r){var n=_objectSpread2(_objectSpread2({},e),{},{invalid:[{value:"realx-exts:rscp"}],media:[t,r]});return delete n.groups,delete n.msidSemantic,lib.write(n)};function parseAnswerIceParams(e){return _parseAnswerIceParams.apply(this,arguments)}function _parseAnswerIceParams(){return(_parseAnswerIceParams=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){var r,n,i,o;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r={},n=t.publicIPs,i=t.certFingerprint,o=t.iceParams,r.fingerprint={type:"sha-256",hash:i},r.icePwd=o.serverIcePwd,e.next=6,getServerUfrag(o.serverIceUfrag);case 6:return r.iceUfrag=e.sent,commonStats.setStats({connection_id:r.iceUfrag}),r.candidates=genCandidates(n),r.setup="active",r.iceOptions="renomination",e.abrupt("return",r);case 12:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function genCandidates(e){if(!Array.isArray(e))return[];var t=0,r=2130706431,n=[];return e.forEach((function(e){var i={component:1,ip:e.ip,type:"host",generation:e.generation};e.udpPorts&&e.udpPorts.forEach((function(e){n.push(_objectSpread2(_objectSpread2({},i),{},{foundation:t++,transport:"udp",port:e,priority:r}))})),e.tcpPorts&&e.tcpPorts.forEach((function(e){n.push(_objectSpread2(_objectSpread2({},i),{},{foundation:t++,transport:"tcp",port:e,tcptype:"passive",priority:2130705431}))}))})),n}var getServerUfrag=function(){var e=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){var r,n,i,o,a,s,c;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=new TextEncoder,n=r.encode("PREC"),e.t0=Uint8Array,e.next=5,Utils.b64str2ab(t);case 5:return e.t1=e.sent,i=new e.t0(e.t1),o=r.encode(Date.now().toString()).slice(-4),(a=new Uint8Array(2))[0]=0,a[1]=1,s=concatenate(Uint8Array,n,i,o,a),e.next=14,Utils.ab2b64str(s.buffer);case 14:return c=e.sent,e.abrupt("return",c);case 16:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),uncurryThis$4=functionUncurryThis,defineBuiltIns$2=defineBuiltIns$5,getWeakData=internalMetadata.exports.getWeakData,anInstance$2=anInstance$a,anObject$1=anObject$q,isNullOrUndefined=isNullOrUndefined$b,isObject$3=isObject$s,iterate=iterate$5,ArrayIterationModule=arrayIteration,hasOwn$2=hasOwnProperty_1,InternalStateModule$2=internalState,setInternalState$2=InternalStateModule$2.set,internalStateGetterFor=InternalStateModule$2.getterFor,find$1=ArrayIterationModule.find,findIndex=ArrayIterationModule.findIndex,splice$1=uncurryThis$4([].splice),id=0,uncaughtFrozenStore=function(e){return e.frozen||(e.frozen=new UncaughtFrozenStore)},UncaughtFrozenStore=function(){this.entries=[]},findUncaughtFrozen=function(e,t){return find$1(e.entries,(function(e){return e[0]===t}))};UncaughtFrozenStore.prototype={get:function(e){var t=findUncaughtFrozen(this,e);if(t)return t[1]},has:function(e){return!!findUncaughtFrozen(this,e)},set:function(e,t){var r=findUncaughtFrozen(this,e);r?r[1]=t:this.entries.push([e,t])},delete:function(e){var t=findIndex(this.entries,(function(t){return t[0]===e}));return~t&&splice$1(this.entries,t,1),!!~t}};var InternalWeakMap,collectionWeak$1={getConstructor:function(e,t,r,n){var i=e((function(e,i){anInstance$2(e,o),setInternalState$2(e,{type:t,id:id++,frozen:void 0}),isNullOrUndefined(i)||iterate(i,e[n],{that:e,AS_ENTRIES:r})})),o=i.prototype,a=internalStateGetterFor(t),s=function(e,t,r){var n=a(e),i=getWeakData(anObject$1(t),!0);return!0===i?uncaughtFrozenStore(n).set(t,r):i[n.id]=r,e};return defineBuiltIns$2(o,{delete:function(e){var t=a(this);if(!isObject$3(e))return!1;var r=getWeakData(e);return!0===r?uncaughtFrozenStore(t).delete(e):r&&hasOwn$2(r,t.id)&&delete r[t.id]},has:function(e){var t=a(this);if(!isObject$3(e))return!1;var r=getWeakData(e);return!0===r?uncaughtFrozenStore(t).has(e):r&&hasOwn$2(r,t.id)}}),defineBuiltIns$2(o,r?{get:function(e){var t=a(this);if(isObject$3(e)){var r=getWeakData(e);return!0===r?uncaughtFrozenStore(t).get(e):r?r[t.id]:void 0}},set:function(e,t){return s(this,e,t)}}:{add:function(e){return s(this,e,!0)}}),i}},global$3=global$K,uncurryThis$3=functionUncurryThis,defineBuiltIns$1=defineBuiltIns$5,InternalMetadataModule=internalMetadata.exports,collection=collection$2,collectionWeak=collectionWeak$1,isObject$2=isObject$s,isExtensible=objectIsExtensible,enforceInternalState=internalState.enforce,NATIVE_WEAK_MAP=weakMapBasicDetection,IS_IE11=!global$3.ActiveXObject&&"ActiveXObject"in global$3,wrapper=function(e){return function(){return e(this,arguments.length?arguments[0]:void 0)}},$WeakMap=collection("WeakMap",wrapper,collectionWeak);if(NATIVE_WEAK_MAP&&IS_IE11){InternalWeakMap=collectionWeak.getConstructor(wrapper,"WeakMap",!0),InternalMetadataModule.enable();var WeakMapPrototype=$WeakMap.prototype,nativeDelete=uncurryThis$3(WeakMapPrototype.delete),nativeHas=uncurryThis$3(WeakMapPrototype.has),nativeGet=uncurryThis$3(WeakMapPrototype.get),nativeSet=uncurryThis$3(WeakMapPrototype.set);defineBuiltIns$1(WeakMapPrototype,{delete:function(e){if(isObject$2(e)&&!isExtensible(e)){var t=enforceInternalState(this);return t.frozen||(t.frozen=new InternalWeakMap),nativeDelete(this,e)||t.frozen.delete(e)}return nativeDelete(this,e)},has:function(e){if(isObject$2(e)&&!isExtensible(e)){var t=enforceInternalState(this);return t.frozen||(t.frozen=new InternalWeakMap),nativeHas(this,e)||t.frozen.has(e)}return nativeHas(this,e)},get:function(e){if(isObject$2(e)&&!isExtensible(e)){var t=enforceInternalState(this);return t.frozen||(t.frozen=new InternalWeakMap),nativeHas(this,e)?nativeGet(this,e):t.frozen.get(e)}return nativeGet(this,e)},set:function(e,t){if(isObject$2(e)&&!isExtensible(e)){var r=enforceInternalState(this);r.frozen||(r.frozen=new InternalWeakMap),nativeHas(this,e)?nativeSet(this,e,t):r.frozen.set(e,t)}else nativeSet(this,e,t);return this}})}var DeviceDetector=function(e){_inherits(h,EnhancedEventEmitter);var t,r,n,i,o,a,s,c,u,l,d,p,_,f=_createSuper(h);function h(){var e;return _classCallCheck(this,h),_defineProperty(_assertThisInitialized(e=f.call(this)),"inited",!1),_defineProperty(_assertThisInitialized(e),"deviceMap",{audioinput:new Map,audiooutput:new Map,videoinput:new Map}),e._handleDeviceChange=e._handleDeviceChange.bind(_assertThisInitialized(e)),!isSSR()&&e.refreshDevices(),e}return _createClass(h,[{key:"refreshDevices",value:(_=_asyncToGenerator(_regeneratorRuntime().mark((function e(){var t,r,n=this;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(navigator.mediaDevices){e.next=2;break}return e.abrupt("return");case 2:if(t=void 0,!isFirefox){e.next=7;break}return e.next=6,navigator.mediaDevices.getUserMedia({audio:!0});case 6:t=e.sent;case 7:return e.next=9,navigator.mediaDevices.enumerateDevices();case 9:r=e.sent,t&&t.getTracks().forEach((function(e){return e.stop()})),r.forEach((function(e){var t;e.deviceId&&(null===(t=n.deviceMap[e.kind])||void 0===t||t.set(e.deviceId,e))})),this.inited||this.initListener(),this.inited=!0;case 14:case"end":return e.stop()}}),e,this)}))),function(){return _.apply(this,arguments)})},{key:"initListener",value:(p=_asyncToGenerator(_regeneratorRuntime().mark((function e(){var t,r=this;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:"function"==typeof(null===(t=navigator.mediaDevices)||void 0===t?void 0:t.addEventListener)&&navigator.mediaDevices.addEventListener("devicechange",(function(){r._handleDeviceChange(),setTimeout((function(){r._handleDeviceChange()}),300)}));case 1:case"end":return e.stop()}}),e)}))),function(){return p.apply(this,arguments)})},{key:"_handleDeviceChange",value:(d=_asyncToGenerator(_regeneratorRuntime().mark((function e(){var t,r,n,i=this;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=void 0,!isFirefox){e.next=5;break}return e.next=4,navigator.mediaDevices.getUserMedia({audio:!0});case 4:t=e.sent;case 5:return e.next=7,navigator.mediaDevices.enumerateDevices();case 7:r=e.sent,t&&t.getTracks().forEach((function(e){return e.stop()})),n=Array.from([].concat(_toConsumableArray(this.deviceMap.audioinput.values()),_toConsumableArray(this.deviceMap.videoinput.values()),_toConsumableArray(this.deviceMap.audiooutput.values()))),r.forEach((function(e){var t=i.deviceMap[e.kind].get(e.deviceId);i.deviceMap[e.kind].set(e.deviceId,e),t||(e.kind.includes("video")?i.emit(EngineEventsTypes.onVideoDeviceStateChanged,{mediaDeviceInfo:e,deviceState:"active"}):e.kind.includes("audio")&&i.emit(EngineEventsTypes.onAudioDeviceStateChanged,{mediaDeviceInfo:e,deviceState:"active"}))})),n.forEach((function(e){r.find((function(t){return t.deviceId===e.deviceId&&t.kind===e.kind}))||(i.deviceMap[e.kind].delete(e.deviceId),e.kind.includes("video")?i.emit(EngineEventsTypes.onVideoDeviceStateChanged,{mediaDeviceInfo:e,deviceState:"inactive"}):e.kind.includes("audio")&&i.emit(EngineEventsTypes.onAudioDeviceStateChanged,{mediaDeviceInfo:e,deviceState:"inactive"}))}));case 12:case"end":return e.stop()}}),e,this)}))),function(){return d.apply(this,arguments)})},{key:"getVideoPermission",value:(l=_asyncToGenerator(_regeneratorRuntime().mark((function e(){var t;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=this._getVideoPermission(),e.next=3,this.refreshDevices();case 3:return e.abrupt("return",t);case 4:case"end":return e.stop()}}),e,this)}))),function(){return l.apply(this,arguments)})},{key:"_getVideoPermission",value:(u=_asyncToGenerator(_regeneratorRuntime().mark((function e(){var t,r;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._getNavigatorPermission("camera");case 2:if(!e.sent){e.next=4;break}return e.abrupt("return",!0);case 4:if(r=!1,null===(t=navigator.mediaDevices)||void 0===t||!t.getUserMedia){e.next=8;break}return e.next=8,navigator.mediaDevices.getUserMedia({audio:!1,video:!0}).then((function(e){e&&(e.getTracks().forEach((function(e){return e.stop()})),r=!0)})).catch((function(){}));case 8:return e.abrupt("return",r);case 9:case"end":return e.stop()}}),e,this)}))),function(){return u.apply(this,arguments)})},{key:"getAudioPermission",value:(c=_asyncToGenerator(_regeneratorRuntime().mark((function e(){var t;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=this._getAudioPermission(),e.next=3,this.refreshDevices();case 3:return e.abrupt("return",t);case 4:case"end":return e.stop()}}),e,this)}))),function(){return c.apply(this,arguments)})},{key:"_getAudioPermission",value:(s=_asyncToGenerator(_regeneratorRuntime().mark((function e(){var t,r;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._getNavigatorPermission("microphone");case 2:if(!e.sent){e.next=4;break}return e.abrupt("return",!0);case 4:if(r=!1,null===(t=navigator.mediaDevices)||void 0===t||!t.getUserMedia){e.next=8;break}return e.next=8,navigator.mediaDevices.getUserMedia({audio:!0,video:!1}).then((function(e){e&&(e.getTracks().forEach((function(e){return e.stop()})),r=!0)})).catch((function(){}));case 8:return e.abrupt("return",r);case 9:case"end":return e.stop()}}),e,this)}))),function(){return s.apply(this,arguments)})},{key:"enumerateDevices",value:(a=_asyncToGenerator(_regeneratorRuntime().mark((function e(){return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._getVideoPermission();case 2:return e.next=4,this._getAudioPermission();case 4:return e.abrupt("return",Array.from([].concat(_toConsumableArray(this.deviceMap.audioinput.values()),_toConsumableArray(this.deviceMap.videoinput.values()),_toConsumableArray(this.deviceMap.audiooutput.values()))));case 5:case"end":return e.stop()}}),e,this)}))),function(){return a.apply(this,arguments)})},{key:"enumerateAudioCaptureDevices",value:(o=_asyncToGenerator(_regeneratorRuntime().mark((function e(){return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._getAudioPermission();case 2:return e.abrupt("return",Array.from(this.deviceMap.audioinput.values()));case 3:case"end":return e.stop()}}),e,this)}))),function(){return o.apply(this,arguments)})},{key:"enumerateVideoCaptureDevices",value:(i=_asyncToGenerator(_regeneratorRuntime().mark((function e(){return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._getVideoPermission();case 2:return e.abrupt("return",Array.from(this.deviceMap.videoinput.values()));case 3:case"end":return e.stop()}}),e,this)}))),function(){return i.apply(this,arguments)})},{key:"enumerateAudioPlaybackDevices",value:(n=_asyncToGenerator(_regeneratorRuntime().mark((function e(){return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._getAudioPermission();case 2:return e.abrupt("return",Array.from(this.deviceMap.audiooutput.values()));case 3:case"end":return e.stop()}}),e,this)}))),function(){return n.apply(this,arguments)})},{key:"getDeviceById",value:(r=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){var r;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.enumerateDevices();case 2:return r=e.sent,e.abrupt("return",r.find((function(e){return e.deviceId===t})));case 4:case"end":return e.stop()}}),e,this)}))),function(e){return r.apply(this,arguments)})},{key:"_getNavigatorPermission",value:(t=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){var r,n,i,o;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=!1,null===(r=navigator.permissions)||void 0===r||!r.query){e.next=12;break}return e.prev=2,e.next=5,navigator.permissions.query({name:t});case 5:i=e.sent,o=i.state,n="granted"===o,e.next=12;break;case 10:e.prev=10,e.t0=e.catch(2);case 12:return e.abrupt("return",n);case 13:case"end":return e.stop()}}),e,null,[[2,10]])}))),function(e){return t.apply(this,arguments)})}]),h}(),detector=new DeviceDetector,WebAudioManager=function(){function e(){_classCallCheck(this,e),_defineProperty(this,"_audioContextInstance",void 0)}return _createClass(e,[{key:"getAudioContextInstance",value:function(){if(!this._audioContextInstance){var e=window.AudioContext||window.webkitAudioContext;this._audioContextInstance=new e}return this._audioContextInstance}}]),e}(),AudioLevelFetcher=function(){function e(t){_classCallCheck(this,e),_defineProperty(this,"_ctx",void 0),_defineProperty(this,"_analyserNode",void 0),_defineProperty(this,"_audioSource",void 0);var r=audioContextManager.getAudioContextInstance();if(t instanceof MediaStreamTrack){var n=new MediaStream;n.addTrack(t),this._audioSource=r.createMediaStreamSource(n)}else t instanceof AudioNode?this._audioSource=t:(this._audioSource=r.createMediaElementSource(t),this._audioSource.connect(r.destination));var i=r.createAnalyser();this._audioSource.connect(i),this._analyserNode=i,this._ctx=r}return _createClass(e,[{key:"getAudioLevel",value:function(){var e;"suspended"===(null===(e=this._ctx)||void 0===e?void 0:e.state)&&this._ctx.resume();var t=new Uint8Array(2048);this._analyserNode.getByteTimeDomainData(t);var r=0;return t.forEach((function(e){return r=Math.max(r,Math.abs(e-128))})),r/128*255}},{key:"destroy",value:function(){this._audioSource.disconnect(),this._analyserNode.disconnect()}}]),e}(),AudioVolumeGain=function(){function e(t){_classCallCheck(this,e),_defineProperty(this,"_gainNode",void 0),_defineProperty(this,"_audioDestination",void 0),_defineProperty(this,"_audioSource",void 0);var r=audioContextManager.getAudioContextInstance();this._audioDestination=r.createMediaStreamDestination();var n=new MediaStream;n.addTrack(t),this._audioSource=r.createMediaStreamSource(n),this._gainNode=r.createGain(),this._audioSource.connect(this._gainNode).connect(this._audioDestination)}return _createClass(e,[{key:"setVolumeGain",value:function(e){this._gainNode.gain.value=e}},{key:"getAudioTrack",value:function(){return this._audioDestination.stream.getAudioTracks()[0]}},{key:"destroy",value:function(){this._audioSource.disconnect(),this._gainNode.disconnect()}}]),e}(),audioContextManager=new WebAudioManager,logger$e=new Logger("VERTC",0),trackStreamMap=new WeakMap,getMediaStreamByTrack=function(e){return trackStreamMap.get(e)},Track=function(e){_inherits(r,EnhancedEventEmitter);var t=_createSuper(r);function r(e,n){var i;return _classCallCheck(this,r),_defineProperty(_assertThisInitialized(i=t.call(this)),"mediaType",void 0),_defineProperty(_assertThisInitialized(i),"_trackId",void 0),i._trackId=e,i.mediaType=n,i}return _createClass(r,[{key:"getId",value:function(){return this._trackId}}]),r}(),LocalTrack=function(e){_inherits(r,Track);var t=_createSuper(r);function r(e,n,i){var o;return _classCallCheck(this,r),_defineProperty(_assertThisInitialized(o=t.call(this,n,i)),"_mediaTrack",void 0),o._mediaTrack=e,o._initListeners(),o}return _createClass(r,[{key:"getTrack",value:function(){return this._mediaTrack}},{key:"setTrack",value:function(e){this._mediaTrack=e}},{key:"close",value:function(){var e;return null===(e=this._mediaTrack)||void 0===e?void 0:e.stop()}},{key:"_initListeners",value:function(){var e=this;this._mediaTrack instanceof MediaStreamTrack&&this._mediaTrack.addEventListener("ended",(function(){monitor.rtcError("track-ended mediaType: ".concat(e._mediaTrack.kind),-1001),e.emit("track-ended",e)}))}}]),r}(),RemoteTrack=function(e){_inherits(r,Track);var t=_createSuper(r);function r(e,n,i){var o;return _classCallCheck(this,r),_defineProperty(_assertThisInitialized(o=t.call(this,n,i)),"_mediaTrack",void 0),o._mediaTrack=e,o}return _createClass(r,[{key:"getTrack",value:function(){return this._mediaTrack}}]),r}(),LocalVideoTrack=function(e){_inherits(n,LocalTrack);var t,r=_createSuper(n);function n(e,t){var i;return _classCallCheck(this,n),_defineProperty(_assertThisInitialized(i=r.call(this,e,t,"video")),"resolution",void 0),_defineProperty(_assertThisInitialized(i),"videoCaptureConfig",void 0),_defineProperty(_assertThisInitialized(i),"dummy",!1),i.resolution={width:0,height:0},i}return _createClass(n,[{key:"updateVideoCaptureConfig",value:(t=_asyncToGenerator(_regeneratorRuntime().mark((function e(){var t;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.videoCaptureConfig&&this.getTrack()){e.next=2;break}return e.abrupt("return");case 2:return logger$e.print("updateVideoEncoderConfig","update localVideoTrack: ",this.videoCaptureConfig),delete _objectSpread2({},this.videoCaptureConfig).contentHint,e.next=7,this.getTrack().applyConstraints(this.videoCaptureConfig);case 7:((t=this.getTrack().getSettings()).width&&t.width!==this.resolution.width||t.height&&t.height!==this.resolution.height)&&(this.resolution={width:t.width,height:t.height},this.emit("resolution-change",this.resolution));case 9:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})},{key:"replaceTrack",value:function(e){this.setTrack(e)}},{key:"setContentHint",value:function(e){this._mediaTrack&&"contentHint"in this._mediaTrack&&["text","motion","detail"].includes(e)&&(this._mediaTrack.contentHint=e)}}]),n}(),LocalAudioTrack=function(e){_inherits(n,LocalTrack);var t,r=_createSuper(n);function n(e,t){var i;return _classCallCheck(this,n),_defineProperty(_assertThisInitialized(i=r.call(this,e,t,"audio")),"audioCaptureConfig",void 0),_defineProperty(_assertThisInitialized(i),"_audioLevelFetcher",void 0),_defineProperty(_assertThisInitialized(i),"mixedAudioTrack",void 0),_defineProperty(_assertThisInitialized(i),"mixType",AudioMixingType.PLAYOUT_AND_PUBLISH),_defineProperty(_assertThisInitialized(i),"_audioVolumeGain",void 0),_defineProperty(_assertThisInitialized(i),"gainAudioTrack",void 0),i}return _createClass(n,[{key:"getPublishTrack",value:function(){var e=null==this?void 0:this.getTrack();return(null==this?void 0:this.mixType)!==AudioMixingType.PLAYOUT&&null!=this&&this.mixedAudioTrack?e=null==this?void 0:this.mixedAudioTrack:null!=this&&this.gainAudioTrack&&(e=this.gainAudioTrack),e}},{key:"setCaptureVolume",value:function(e){this._audioVolumeGain||(this._audioVolumeGain=new AudioVolumeGain(this.getTrack()),this.gainAudioTrack=this._audioVolumeGain.getAudioTrack()),this._audioVolumeGain.setVolumeGain(e/100)}},{key:"getAudioLevel",value:function(){return this._audioLevelFetcher||(this._audioLevelFetcher=new AudioLevelFetcher(this.getTrack())),this._audioLevelFetcher.getAudioLevel()}},{key:"updateAudioCaptureConfig",value:(t=_asyncToGenerator(_regeneratorRuntime().mark((function e(){var t;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.audioCaptureConfig){e.next=2;break}return e.abrupt("return");case 2:return logger$e.print("updateAudioCaptureConfig","update localAudioTrack: ",this.audioCaptureConfig),e.next=5,null===(t=this.getTrack())||void 0===t?void 0:t.applyConstraints(this.audioCaptureConfig);case 5:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})}]),n}(),RemoteVideoTrack=function(e){_inherits(r,RemoteTrack);var t=_createSuper(r);function r(e,n){return _classCallCheck(this,r),t.call(this,e,n,"video")}return _createClass(r)}(),RemoteAudioTrack=function(e){_inherits(r,RemoteTrack);var t=_createSuper(r);function r(e,n){var i;return _classCallCheck(this,r),_defineProperty(_assertThisInitialized(i=t.call(this,e,n,"audio")),"_audioLevelFetcher",void 0),i}return _createClass(r,[{key:"getAudioLevel",value:function(){return this._audioLevelFetcher||(this._audioLevelFetcher=new AudioLevelFetcher(this.getTrack())),this._audioLevelFetcher.getAudioLevel()}}]),r}(),MicrophoneAudioTrack=function(e){_inherits(r,LocalAudioTrack);var t=_createSuper(r);function r(){return _classCallCheck(this,r),t.apply(this,arguments)}return _createClass(r)}(),CameraVideoTrack=function(e){_inherits(r,LocalVideoTrack);var t=_createSuper(r);function r(){return _classCallCheck(this,r),t.apply(this,arguments)}return _createClass(r)}(),ScreenVideoTrack=function(e){_inherits(r,LocalVideoTrack);var t=_createSuper(r);function r(){return _classCallCheck(this,r),t.apply(this,arguments)}return _createClass(r)}(),ScreenAudioTrack=function(e){_inherits(r,LocalAudioTrack);var t=_createSuper(r);function r(){return _classCallCheck(this,r),t.apply(this,arguments)}return _createClass(r)}(),CustomVideoLocalTrack=function(e){_inherits(r,LocalVideoTrack);var t=_createSuper(r);function r(){return _classCallCheck(this,r),t.apply(this,arguments)}return _createClass(r)}(),CustomAudioLocalTrack=function(e){_inherits(r,LocalAudioTrack);var t=_createSuper(r);function r(){return _classCallCheck(this,r),t.apply(this,arguments)}return _createClass(r)}();function createDummyVideoLocalTrack(e){return new CameraVideoTrack(e,genUuid())}function createDummyScreenVideoLocalTrack(e){return new ScreenVideoTrack(e,genUuid())}function createCameraVideoTrack(e){return _createCameraVideoTrack.apply(this,arguments)}function _createCameraVideoTrack(){return(_createCameraVideoTrack=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){var r,n,i,o,a,s;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=(null==t||null===(r=t.deviceId)||void 0===r?void 0:r.exact)||"default",e.prev=1,logger$e.print("createCameraVideoTrack","constraints:",t),monitor.rtcVideoCaptureEvent({event_type:CaptureeventinfoEventType.START,media_device_id:i}),o=getServerNow(),e.next=7,navigator.mediaDevices.getUserMedia({video:t});case 7:n=e.sent,monitor.rtcVideoCaptureEvent({event_type:CaptureeventinfoEventType.START_CAPTURE_RESULT,media_device_id:i,reason:CaptureeventinfoReason.SUCCESS,elapse:getServerNow()-o}),detector.refreshDevices(),e.next=16;break;case 12:throw e.prev=12,e.t0=e.catch(1),monitor.rtcVideoCaptureEvent({event_type:CaptureeventinfoEventType.RUNNING_FAILED,media_device_id:i,error_code:e.t0.code,reason:e.t0.name+e.t0.message}),new SDKError(ErrorCode.GET_VIDEO_TRACK_FAILED,"throw error from getUserMedia",e.t0);case 16:return a=n.getVideoTracks()[0],trackStreamMap.set(a,n),(s=new CameraVideoTrack(a,genUuid())).videoCaptureConfig=t,e.abrupt("return",s);case 21:case"end":return e.stop()}}),e,null,[[1,12]])})))).apply(this,arguments)}function createMicrophoneAudioTrack(e,t){return _createMicrophoneAudioTrack.apply(this,arguments)}function _createMicrophoneAudioTrack(){return _createMicrophoneAudioTrack=_asyncToGenerator(_regeneratorRuntime().mark((function e(t,r){var n,i,o,a,s,c,u,l,d,p,_;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return logger$e.print("createCameraVideoTrack","constraints:",t),o=(null==t||null===(n=t.deviceId)||void 0===n?void 0:n.exact)||"default",s=(a=r||{}).sampleRate,c=a.channel,u=a.agc,l=a.ans,d=a.aec,void 0===t.sampleRate&&(t.sampleRate=s),void 0===t.channelCount&&(t.channelCount=c),void 0===t.autoGainControl&&(t.autoGainControl=u),void 0===t.noiseSuppression&&(t.noiseSuppression=l),void 0===t.echoCancellation&&(t.echoCancellation=d),e.prev=8,monitor.rtcVideoCaptureEvent({event_type:CaptureeventinfoEventType.START,media_device_id:o}),p=getServerNow(),e.next=13,navigator.mediaDevices.getUserMedia({audio:t});case 13:i=e.sent,monitor.rtcVideoCaptureEvent({event_type:CaptureeventinfoEventType.START_CAPTURE_RESULT,media_device_id:o,reason:CaptureeventinfoReason.SUCCESS,elapse:getServerNow()-p}),detector.refreshDevices(),e.next=22;break;case 18:throw e.prev=18,e.t0=e.catch(8),monitor.rtcVideoCaptureEvent({event_type:CaptureeventinfoEventType.RUNNING_FAILED,media_device_id:o,error_code:e.t0.code,reason:e.t0.name+e.t0.message}),new SDKError(ErrorCode.GET_AUDIO_TRACK_FAILED,"throw error from getUserMedia",e.t0);case 22:return _=i.getAudioTracks()[0],trackStreamMap.set(_,i),e.abrupt("return",new MicrophoneAudioTrack(_,genUuid()));case 25:case"end":return e.stop()}}),e,null,[[8,18]])}))),_createMicrophoneAudioTrack.apply(this,arguments)}function createScreenStream(){return _createScreenStream.apply(this,arguments)}function _createScreenStream(){return _createScreenStream=_asyncToGenerator(_regeneratorRuntime().mark((function e(){var t,r,n,i,o=arguments;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=o.length>0&&void 0!==o[0]&&o[0],r=o.length>1?o[1]:void 0,logger$e.print("createScreenTracks","withAudio: %o, constraints: %o",t,r),e.prev=3,monitor.rtcVideoCaptureEvent({event_type:CaptureeventinfoEventType.START,media_device_id:"screen"}),i=getServerNow(),e.next=8,navigator.mediaDevices.getDisplayMedia({video:!(r&&!isSafari)||r,audio:!!t&&{channelCount:2,noiseSuppression:!1,echoCancellation:!1,autoGainControl:!1}});case 8:n=e.sent,monitor.rtcVideoCaptureEvent({event_type:CaptureeventinfoEventType.START_CAPTURE_RESULT,media_device_id:"screen",reason:CaptureeventinfoReason.SUCCESS,elapse:getServerNow()-i}),e.next=16;break;case 12:throw e.prev=12,e.t0=e.catch(3),monitor.rtcVideoCaptureEvent({event_type:CaptureeventinfoEventType.RUNNING_FAILED,media_device_id:"screen",error_code:e.t0.code,reason:e.t0.name+e.t0.message}),new SDKError(ErrorCode.GET_SCREEN_TRACK_FAILED,"throw error from getDisplayMedia",e.t0);case 16:return e.abrupt("return",n);case 17:case"end":return e.stop()}}),e,null,[[3,12]])}))),_createScreenStream.apply(this,arguments)}var ExtendMediaType=function(e){return e[e.NONE=0]="NONE",e}(ExtendMediaType||{}),Nalunit=function(){function e(){_classCallCheck(this,e)}return _createClass(e,null,[{key:"getNalunits",value:function(t){if(t.length-t.position<4)return[];var r=t.position;return 1===t.getInt32(r)||0===t.getInt16(r)&&1===t.getInt8(r+2)?e.getAnnexbNals(t):e.getAvccNals(t)}},{key:"getAnnexbNals",value:function(t){for(var r=[],n=e.getHeaderPositionAnnexB(t),i=n.pos,o=i;i<t.length-4;){var a=new Uint8Array(t.buffer.slice(i,i+n.headerLength));n.pos===t.position&&t.skip(n.headerLength),o=(n=e.getHeaderPositionAnnexB(t)).pos;var s={header:a,body:new Uint8Array(t.buffer.slice(i+a.byteLength,o)),type:-1};e.analyseNal(s),s.type<=9&&0!==s.type&&r.push(s),t.skip(o-t.position),i=o}return r}},{key:"getAvccNals",value:function(t){for(var r=[];t.position<t.length-4;){var n=t.getInt32(t.position);if(!(t.length-t.position>=n))break;var i=new Uint8Array(t.buffer.slice(t.position,t.position+4));t.skip(4);var o=new Uint8Array(t.buffer.slice(t.position,t.position+n));t.skip(n);var a={header:i,body:o,type:-1};e.analyseNal(a),a.type<=9&&0!==a.type&&r.push(a)}return r}},{key:"analyseNal",value:function(e){var t=31&e.body[0];switch(e.type=t,t){case 1:e.ndr=!0;break;case 5:e.idr=!0;break;case 6:e.sei=!0;break;case 7:e.sps=!0;break;case 8:e.pps=!0}}},{key:"getHeaderPositionAnnexB",value:function(e){for(var t=e.position,r=0,n=e.length;3!==r&&4!==r&&t<n-4;)0===e.getInt16(t)?1===e.getInt16(t+2)?r=4:1===e.getInt8(t+2)?r=3:t++:t++;return t===n-4&&(0===e.getInt16(t)?1===e.getInt16(t+2)?r=4:t=n:(t++,0===e.getInt16(t)&&1===e.getInt8(t)?r=3:t=n)),{pos:t,headerLength:r}}},{key:"getAvcc",value:function(e,t){var r=new Uint8Array(e.byteLength+t.byteLength+11);r[0]=1,r[1]=e[1],r[2]=e[2],r[3]=e[3],r[4]=255,r[5]=225;var n=6;return r.set(new Uint8Array([e.byteLength>>>8&255,255&e.byteLength]),n),n+=2,r.set(e,n),r[n+=e.byteLength]=1,n++,r.set(new Uint8Array([t.byteLength>>>8&255,255&t.byteLength]),n),n+=2,r.set(t,n),r}}]),e}(),RTCDataView=function(){function e(t){_classCallCheck(this,e),_defineProperty(this,"_position",0),_defineProperty(this,"_dataview",void 0),this._dataview=new DataView(t)}return _createClass(e,[{key:"length",get:function(){return this.buffer.byteLength}},{key:"buffer",get:function(){return this._dataview.buffer}},{key:"position",get:function(){return this._position},set:function(e){this._position=e}},{key:"back",value:function(e){this.position-=e}},{key:"getUint8",value:function(e){return this._dataview.getUint8(e)}},{key:"getInt8",value:function(e){return this._dataview.getInt8(e)}},{key:"getInt16",value:function(e){return this._dataview.getInt16(e)}},{key:"getUint16",value:function(e){return this._dataview.getUint16(e)}},{key:"getUint32",value:function(e){return this._dataview.getUint32(e)}},{key:"getInt32",value:function(e){return this._dataview.getInt32(e)}},{key:"skip",value:function(t){for(var r=Math.floor(t/4),n=t%4,i=0;i<r;i++)e.readByte(this,4);n>0&&e.readByte(this,n)}},{key:"readUint8",value:function(){return e.readByte(this,1)}},{key:"readUint16",value:function(){return e.readByte(this,2)}},{key:"readUint24",value:function(){return e.readByte(this,3)}},{key:"readUint32",value:function(){return e.readByte(this,4)}},{key:"readUint64",value:function(){return e.readByte(this,8)}},{key:"readInt8",value:function(){return e.readByte(this,1,!0)}},{key:"readInt16",value:function(){return e.readByte(this,2,!0)}},{key:"readInt32",value:function(){return e.readByte(this,4,!0)}},{key:"writeUint32",value:function(e){return new Uint8Array([e>>>24&255,e>>>16&255,e>>>8&255,255&e])}}],[{key:"readByte",value:function(e,t,r){var n;switch(t){case 1:n=r?e.getInt8(e.position):e.getUint8(e.position);break;case 2:n=r?e.getInt16(e.position):e.getUint16(e.position);break;case 3:if(r)throw new Error("not supported for readByte 3");n=e.getUint8(e.position)<<16,n|=e.getUint8(e.position+1)<<8,n|=e.getUint8(e.position+2);break;case 4:n=r?e.getInt32(e.position):e.getUint32(e.position);break;case 8:if(r)throw new Error("not supported for readBody 8");n=e.getUint32(e.position)<<32,n|=e.getUint32(e.position+4);break;default:n=""}return e.position+=t,n}}]),e}(),RTC_SEI_TYPE=function(e){return e[e.internal=0]="internal",e[e.external=1]="external",e[e.bypass=2]="bypass",e}(RTC_SEI_TYPE||{}),UUID_INTERNAL=new Uint8Array([109,167,53,190,103,90,72,1,170,89,63,164,194,199,19,85]),UUID_EXTERNAL=new Uint8Array([109,167,53,190,103,90,72,1,170,89,63,164,194,199,19,84]),rbsp2ebsp=function(e){for(var t=[],r=0;r<e.length;r++)e[r]<=3&&0===e[r-1]&&0===e[r-2]&&t.push(3),t.push(e[r]);return new Uint8Array(t)},ebsp2rbsp=function(e){for(var t=[],r=0;r<e.length;r++)e[r]<=3&&0===e[r-1]&&0===e[r-2]||t.push(e[r]);return new Uint8Array(t)};function serializeData(e){for(var t=[];e>=255;)e-=255,t.push(255);return t.push(e),new Uint8Array(t)}function deserializeData(e){for(var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=0;255===e[t]&&t<e.byteLength;)t++,r+=255;return t<e.byteLength&&(r+=e[t++]),[r,t]}var SEIHelper=function(){function e(){_classCallCheck(this,e)}return _createClass(e,null,[{key:"generateSEI",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=new Uint8Array([0,0,0,1]),n=new Uint8Array([6]),i=new Uint8Array([5]),o=t?UUID_INTERNAL:UUID_EXTERNAL,a=serializeData(e.byteLength+o.byteLength),s=rbsp2ebsp(e);return new Uint8Array([].concat(_toConsumableArray(r),_toConsumableArray(n),_toConsumableArray(i),_toConsumableArray(a),_toConsumableArray(o),_toConsumableArray(s),[128]))}},{key:"decodeSeiBody",value:function(e){e=e.slice(0,e.length-1);var t=ebsp2rbsp(e);if(!(t.byteLength<2)){var r=0;if(5===t[1]||100===t[1]){var n=_slicedToArray(deserializeData(t,r+=2),2),i=n[0],o=2,a=(r=n[1])+i;return t.byteLength>=UUID_EXTERNAL.byteLength&&i>=UUID_EXTERNAL.byteLength&&t.slice(r,r+UUID_EXTERNAL.byteLength).toString()===UUID_EXTERNAL.toString()?(r+=UUID_EXTERNAL.byteLength,o=1):t.byteLength>=UUID_EXTERNAL.byteLength&&i>=UUID_EXTERNAL.byteLength&&t.slice(r,r+UUID_INTERNAL.byteLength).toString()===UUID_INTERNAL.toString()&&(r+=UUID_INTERNAL.byteLength,o=0),{type:o,payload:t.slice(r,a)}}}}},{key:"parseInternalSEI",value:function(e){var t=new Map,r=0;if(0===e.type){for(;e.payload.byteLength-r>=2;){var n=_slicedToArray(deserializeData(e.payload,r),2),i=n[0];r=n[1];var o=_slicedToArray(deserializeData(e.payload,r),2),a=o[0];if(r=o[1],t.get(i)||!(a<e.payload.byteLength-r))break;t.set(i,e.payload.slice(r,r+a))}return t}}},{key:"makeInternalSei",value:function(e){var t,r=[],n=_createForOfIteratorHelper(e);try{for(n.s();!(t=n.n()).done;){var i=_slicedToArray(t.value,2),o=i[0],a=i[1],s=serializeData(o),c=serializeData(a.byteLength);r.push(s,c,a)}}catch(e){n.e(e)}finally{n.f()}var u=r.reduce((function(e,t){return e+t.byteLength}),0),l=new Uint8Array(u);return r.reduce((function(e,t){return l.set(t,e),e+t.byteLength}),0),l}}]),e}(),Stats=function(){function e(t){_classCallCheck(this,e),_defineProperty(this,"_stream",void 0),_defineProperty(this,"_timer",void 0),_defineProperty(this,"client",void 0),_defineProperty(this,"handler",void 0),_defineProperty(this,"monitor",void 0),this._stream=t}return _createClass(e,[{key:"setVar",value:function(e,t,r){this.client=e,this.handler=t,this.monitor=r}},{key:"delStatsEvtInterval",value:function(){clearTimeout(this._timer),this._timer=void 0}},{key:"destroy",value:function(){this.delStatsEvtInterval()}}]),e}(),LocalStatsReport=function(e){_inherits(i,Stats);var t,r,n=_createSuper(i);function i(e){var t;return _classCallCheck(this,i),(t=n.call(this,e))._stream=e,t}return _createClass(i,[{key:"setLocalStreamStatsEvtInterval",value:function(e,t,r){var n,i,o,a=this;if(!this._timer){this.setVar(e,t,r),e.once(StateEvent.ABNORMAL_DISCONNECTION,(function(){a.destroy()}));var s={audio:{},video:{}},c=this._stream,u=null===(n=c.audioTrack)||void 0===n?void 0:n.getPublishTrack(),l=null===(i=c.videoTrack)||void 0===i?void 0:i.getTrack();this.getAudioStats(u,s,null===(o=c.audioTrack)||void 0===o?void 0:o.getAudioLevel()),this.getVideoStats(l,s),this.delStatsEvtInterval();var d=function(){var e=_asyncToGenerator(_regeneratorRuntime().mark((function e(){var t,r,n,i,o,u,l;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=null===(t=c.audioTrack)||void 0===t?void 0:t.getPublishTrack(),o=null===(r=c.videoTrack)||void 0===r?void 0:r.getTrack(),e.next=4,a.getAudioStats(i,s,null===(n=c.audioTrack)||void 0===n?void 0:n.getAudioLevel());case 4:return u=e.sent,e.next=7,a.getVideoStats(o,s);case 7:return l=e.sent,e.abrupt("return",{audioStats:u,videoStats:l,isScreen:c.isScreen});case 9:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),p=function(){var e=_asyncToGenerator(_regeneratorRuntime().mark((function e(){var t,r;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,d();case 2:r=e.sent,null===(t=a.client)||void 0===t||t.emit("onLocalStreamStats",r),a._timer=setTimeout(p,2e3);case 5:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}();this._timer=setTimeout(p,2e3)}}},{key:"unpublish",value:function(){this.delStatsEvtInterval()}},{key:"getAudioStats",value:(r=_asyncToGenerator(_regeneratorRuntime().mark((function e(t,r,n){var i,o,a,s,c,u,l,d,p,_;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(i={},o={timestamp:Date.now()},a=this._stream,s=a.streamId,c=a.audioMid,u=a.isScreen,l=a.pubAttributes,d={media_type:"audio",is_screen:!!u,direction:"up",stream_id:s,vid:c,connection_status:navigator.onLine,capture_state:l.localaudio?"capture_state_on":"capture_state_off"},t&&this.handler){e.next=6;break}return e.abrupt("return",i);case 6:return e.next=8,this.handler.getStats(t);case 8:if((p=e.sent).length){e.next=11;break}return e.abrupt("return",i);case 11:if(p.forEach((function(e){var t=e.type,r=e.packetsSent,n=e.packetsLost,a=e.bytesSent,s=e.clockRate,c=e.roundTripTime,u=e.channels,l=e.audioLevel,p=e.googRtt,_=e.mimeType,f=e.availableIncomingBitrate,h=e.availableOutgoingBitrate,m=e.bytesReceived,y=e.nominated,v=e.id,S=e.currentRoundTripTime,g=e.state,E=e.writable,T=e.requestsReceived,b=e.responsesReceived,R=e.requestsSent,I=e.consentRequestsSent,$=e.responsesSent,A=e.jitter,C=e.candidateType,O=e.ip,P=e.address,k=e.networkType,w=e.port,N=e.protocol,D=e.nackCount,M=e.retransmittedBytesSent,x=e.retransmittedPacketsSent,L=e.roundTripTimeMeasurements,U=e.audioInputLevel,F=e.ssrc,B=e.totalAudioEnergy,V=e.totalSamplesDuration,j=e.mediaType,G=e.fractionLost;"outbound-rtp"===t?(o.packetsSent=r,o.bytesSent=a,d.bytes=a,d.packetsSent=r,d.nackCount=D,d.ssrc=F,d.retransmitted_bytes_sent=M,d.retransmitted_packets_sent=x,o.retransmittedPacketsSent=x):"remote-inbound-rtp"===t?(o.packetsLost=n,d.packetsLost=n,d.jitter=1e3*A,i.rtt=1e3*c,d.rtt=i.rtt,d.round_trip_time_measurements=L,i._fractionLost=G||0):"codec"===t?(i.recordSampleRate=s,i.numChannels=u,d.codecName=_):"media-source"===t&&void 0!==l?(d.audio_level=l?-10*Math.log10(Math.pow(l,2)):l,d.volume=255*l,d.total_audio_energy=B,d.total_samples_duration=V):"ssrc"===t&&"audio"===j?(d.audio_network_elapse=p,d.send_level=U):"candidate-pair"===t?(d.ice_available_incoming_bitrate=f,d.ice_available_outgoing_bitrate=h,d.ice_bytes_received=m,d.ice_bytes_sent=a,d.ice_nominated=+y,d.ice_pair_id=v,d.ice_pair_rtt=S,d.ice_pair_state=g,d.ice_pair_writable=E,d.recv_ping_requests=T,d.recv_ping_responses=b,d.sent_ping_requests_before_first_response=R,d.sent_ping_requests_total=R+(I||0),d.sent_ping_responses=$):"local-candidate"===t?(d.local_candidate_type=C,d.local_ip=O||P,d.local_network_type=k,d.local_port=w,d.protocol=N):"remote-candidate"===t&&(d.remote_candidate_type=C,d.remote_ip=O||P,d.remote_port=w)})),void 0===d.volume&&void 0!==n&&(d.volume=n,d.audio_level=n?-10*Math.log10(Math.pow(n/255,2)):n),(_=r.audio).timestamp){e.next=17;break}return r.audio=o,e.abrupt("return",i);case 17:return void 0!==o.packetsLost&&(i.audioLossRate=(o.packetsLost-_.packetsLost)/(o.packetsSent-_.packetsSent),i.audioLossRate=Number.isNaN(i.audioLossRate)?0:i.audioLossRate,d.fraction_lost=i.audioLossRate),i.statsInterval=o.timestamp-_.timestamp,d.stats_interval=i.statsInterval,i.sendKBitrate=(o.bytesSent-_.bytesSent||0)/i.statsInterval*8,d.bitrate=Math.round(1e3*i.sendKBitrate),d.bandwidth=Math.round(d.bitrate/1024),r.audio=o,this.monitor.rtcMediaStatistics(d,{}),i._retransmittedRate=(o.retransmittedPacketsSent-_.retransmittedPacketsSent)/(o.packetsSent-_.packetsSent),i._fractionLost=Math.max(i._fractionLost,i.audioLossRate),e.abrupt("return",i);case 28:case"end":return e.stop()}}),e,this)}))),function(e,t,n){return r.apply(this,arguments)})},{key:"getVideoStats",value:(t=_asyncToGenerator(_regeneratorRuntime().mark((function e(t,r){var n,i,o,a,s,c,u,l,d,p,_,f,h,m;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n={},i={timestamp:Date.now(),simulcast:{}},o=this._stream,a=o.streamId,s=o.videoMid,c=o.isScreen,u=o.pubAttributes,l=o.enableSimulcast,d={media_type:"video",is_screen:!!c,direction:"up",stream_id:a,vid:s,connection_status:navigator.onLine,capture_state:u.localvideo?"capture_state_on":"capture_state_off"},t&&this.handler){e.next=6;break}return e.abrupt("return",n);case 6:return n.isScreen=c,e.next=9,this.handler.getStats(t);case 9:if((p=e.sent).length){e.next=12;break}return e.abrupt("return",n);case 12:if(_=0,p.forEach((function(e){var t=e.type,r=e.framesEncoded,o=e.packetsLost,a=e.bytesSent,s=e.framesSent,c=e.roundTripTime,u=e.mimeType,p=e.frameWidth,f=e.frameHeight,h=e.packetsSent,m=e.googActualEncBitrate,y=e.googAvailableReceiveBandwidth,v=e.googAvailableSendBandwidth,S=e.googAvgEncodeMs,g=e.googBucketDelay,E=e.googEncodeUsagePercent,T=e.googFrameRateInput,b=e.availableIncomingBitrate,R=e.availableOutgoingBitrate,I=e.bytesReceived,$=e.nominated,A=e.id,C=e.currentRoundTripTime,O=e.state,P=e.writable,k=e.candidateType,w=e.ip,N=e.address,D=e.networkType,M=e.port,x=e.nackCount,L=e.pliCount,U=e.protocol,F=e.qpSum,B=e.requestsReceived,V=e.responsesReceived,j=e.googRetransmitBitrate,G=e.requestsSent,H=e.consentRequestsSent,K=e.responsesSent,z=e.ssrc,Y=e.googTargetEncBitrate,W=e.googTransmitBitrate,q=e.googRtt,X=e.retransmittedPacketsSent,Z=e.encoderImplementation,J=e.jitter,Q=e.rid,ee=e.fractionLost;"outbound-rtp"===t?(l&&(Q?i.simulcast[Q]=e:i.simulcast[_]=e,_++),i.framesEncoded=r,i.bytesSent=a,i.framesSent=s,d.bytes=a,i.packetsSent=h,d.packetsSent=h,d.nackCount=x,d.pli_count=L,d.qp_sum=F,d.ssrc=z,d.retransmitted_packets_sent=X,i.retransmittedPacketsSent=X,d.encoder_implementation=Z,void 0!==p&&(n.encodedFrameWidth=p,n.encodedFrameHeight=f,d.frame_size_height=f,d.frame_size_width=p)):"track"===t?(n.encodedFrameWidth=p,n.encodedFrameHeight=f,d.frame_size_height=f,d.frame_size_width=p):"remote-inbound-rtp"===t?(i.packetsLost=o,n.rtt=1e3*c,d.rtt=n.rtt,d.jitter=J,d.packetsLost=o,n._fractionLost=ee||0):"codec"===t?(n.codecType=u,d.codecName=u):"candidate-pair"===t?(d.ice_available_incoming_bitrate=b,d.ice_available_outgoing_bitrate=R,d.ice_bytes_received=I,d.ice_bytes_sent=a,d.ice_nominated=+$,d.ice_pair_id=A,d.ice_pair_rtt=C,d.ice_pair_state=O,d.ice_pair_writable=P,d.recv_ping_requests=B,d.recv_ping_responses=V,d.sent_ping_requests_before_first_response=G,d.sent_ping_requests_total=G+H,d.sent_ping_responses=K):"local-candidate"===t?(d.local_candidate_type=k,d.local_ip=w||N,d.local_network_type=D,d.local_port=M,d.protocol=U):"remote-candidate"===t?(d.remote_candidate_type=k,d.remote_ip=w||N,d.remote_port=M):"VideoBwe"===t?(d.encBitratebps=m,d.available_receive_bandwidth=y,d.available_send_bandwidth=v,d.bucket_delay=g,d.retransmitBitratebps=j,d.targetEncBitratebps=Y,d.transmit_bitrate=W,n._sendBandWidth=+v):"ssrc"===t&&(d.video_network_elapse=q,d.avg_encode_ms=S,d.encodeUsage=E,d.frame_rate_input=T,d.orignal_input_Framerate=+T)})),(f=r.video).timestamp){e.next=18;break}return r.video=i,e.abrupt("return",n);case 18:return n.statsInterval=i.timestamp-f.timestamp,d.stats_interval=n.statsInterval,h=Object.keys(i.simulcast),l?(d.sim_enc_width=[],d.sim_enc_height=[],d.sim_enc_bps=[],d.sim_enc_framerate=[],d.sim_rids=[],d.sim_enc_bandwidth=[],d.sim_sent_framerate=[],d.sim_fraction_lost=[],m=!1,h.sort((function(e,t){return+e-+t})).forEach((function(e){var t=i.simulcast[e],r=t.frameWidth,o=t.frameHeight,a=t.bytesSent,s=t.framesEncoded,c=t.framesSent,u=t.packetsLost,l=t.packetsSent,p=t.qualityLimitationReason,_=t.qualityLimitationDurations,h=t.qualityLimitationResolutionChanges,y=t.retransmittedPacketsSent;void 0!==p&&(d.sim_qualityLimitationReason||(d.sim_qualityLimitationReason=[],d.sim_qualityLimitationDurations=[],d.sim_qualityLimitationResolutionChanges=[]),d.sim_qualityLimitationReason.push(p),d.sim_qualityLimitationDurations.push(_),d.sim_qualityLimitationResolutionChanges.push(h));var v=f.simulcast[e];if(d.sim_enc_width.push(r||0),d.sim_enc_height.push(o||0),v){var S=(a-v.bytesSent||0)/n.statsInterval;d.sim_enc_bps.push(Math.round(8e3*S)),d.sim_enc_bandwidth.push(Math.round(8e3*S/1024));var g=1e3*(s-v.framesEncoded)/n.statsInterval;d.sim_enc_framerate.push(Math.round(g)),d.sim_rids.push(e);var E=void 0!==c?c-v.framesSent:s-v.framesEncoded,T=1e3*E/n.statsInterval;d.sim_sent_framerate.push(Math.round(T));var b=(u-v.packetsLost)/(l-v.packetsSent);n._retransmittedRate=(y-v.retransmittedPacketsSent)/(l-v.packetsSent),b=Number.isNaN(b)?0:b,d.sim_fraction_lost.push(b),r>0&&!m&&(n.sentKBitrate=8*S,n.encoderOutputFrameRate=g,n.encodedFrameCount=E,n.sentFrameRate=T,n.videoLossRate=b,m=!0)}})),this.monitor.rtcMediaStatistics(d,{})):(n.encodedFrameCount=void 0!==i.framesSent?i.framesSent-f.framesSent:i.framesEncoded-f.framesEncoded,n.sentKBitrate=(i.bytesSent-f.bytesSent||0)/n.statsInterval*8,d.bitrate=Math.round(1e3*n.sentKBitrate),d.bandwidth=Math.round(d.bitrate/1024),n.encoderOutputFrameRate=1e3*(i.framesEncoded-f.framesEncoded)/n.statsInterval,d.frame_rate_encoded=Math.round(n.encoderOutputFrameRate),n.sentFrameRate=1e3*n.encodedFrameCount/n.statsInterval,d.frame_rate_sent=Math.round(n.sentFrameRate),n.videoLossRate=(i.packetsLost-f.packetsLost)/(i.packetsSent-f.packetsSent),n.videoLossRate=Number.isNaN(n.videoLossRate)?0:n.videoLossRate,d.fraction_lost=n.videoLossRate,n._retransmittedRate=(i.retransmittedPacketsSent-f.retransmittedPacketsSent)/(i.packetsSent-f.packetsSent),this.monitor.rtcMediaStatistics(d,{})),r.video=i,n._fractionLost=Math.max(n._fractionLost,n.videoLossRate),e.abrupt("return",n);case 25:case"end":return e.stop()}}),e,this)}))),function(e,r){return t.apply(this,arguments)})}]),i}(),RemoteStatsReport=function(e){_inherits(o,Stats);var t,r,n,i=_createSuper(o);function o(e){var t;return _classCallCheck(this,o),_defineProperty(_assertThisInitialized(t=i.call(this,e)),"_audioStallCount",void 0),_defineProperty(_assertThisInitialized(t),"_setAudioStallCount",void 0),_defineProperty(_assertThisInitialized(t),"_audioStallTimer",void 0),_defineProperty(_assertThisInitialized(t),"_audioStallInterval",void 0),_defineProperty(_assertThisInitialized(t),"_audioStallRatio",void 0),_defineProperty(_assertThisInitialized(t),"_videoInWaiting",void 0),t._videoInWaiting=!1,t}return _createClass(o,[{key:"setRemoteStreamStatsEvtInterval",value:(n=_asyncToGenerator(_regeneratorRuntime().mark((function e(t,r,n){var i,a,s,c,u,l,d,p,_,f,h,m,y,v,S=this;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._timer){e.next=2;break}return e.abrupt("return");case 2:return this.setVar(t,r,n),t.once(StateEvent.ABNORMAL_DISCONNECTION,(function(){S.destroy()})),this._audioStallInterval=o.audioStallInterval||100,this._audioStallRatio=o.audioStallRatio||.6,s={audio:{},video:{}},c=this._stream,u=null===(i=c.audioTrack)||void 0===i?void 0:i.getTrack(),l=null===(a=c.videoTrack)||void 0===a?void 0:a.getTrack(),this.getRemoteVideoStats(l,s),e.next=13,this.getRemoteAudioStats(u,s);case 13:this.delStatsEvtInterval(),d=0,p=0,f=[],h=0,m=getServerNow(),this._setAudioStallCount=function(){if(S._audioStallInterval>0&&void 0!==s.audio.concealedSamples){var e=s.audio.concealedSamples,t=s.audio.totalSamplesReceived;m=getServerNow();var r={isStall:!1,counted:!1,diff:0},n=.5*S._audioStallInterval;S._audioStallCount=_asyncToGenerator(_regeneratorRuntime().mark((function i(){var o,a,s,u,l,_,y,v,g,E,T,b,R,I,$;return _regeneratorRuntime().wrap((function(i){for(;;)switch(i.prev=i.next){case 0:if(a=c.hasAudio,s=c.subAudio,a&&s){i.next=7;break}return r.isStall=!1,r.counted=!1,f.push({reason:"hasAudio: ".concat(a,", subAudio: ").concat(s)}),m=getServerNow(),i.abrupt("return",{stall_count:d,stall_duration:p,stall_list:f,stats_count:h});case 7:return u=null===(o=c.audioTrack)||void 0===o?void 0:o.getTrack(),l=Date.now(),i.next=11,S.handler.getStats(u,!0);case 11:if(_=i.sent,y=Date.now(),v=getServerNow(),!((g=v-m)<n)){i.next=18;break}return f.push({diff:g,start:m,end:v,get_stats_cost:y-l,get_stats_start:l,get_stats_end:y,reason:"diff(".concat(g,") < minInterval(").concat(n,")")}),i.abrupt("return",{stall_count:d,stall_duration:p,stall_list:f,stats_count:h});case 18:if(E=_.length,T=_.find((function(e){return"inbound-rtp"===e.type}))){i.next=23;break}return f.push({diff:g,start:m,end:v,get_stats_cost:y-l,get_stats_start:l,get_stats_end:y,reason:E?"no inbound-rtp":"no report"}),i.abrupt("return",{stall_count:d,stall_duration:p,stall_list:f,stats_count:h});case 23:return b=T.concealedSamples,R=T.totalSamplesReceived,$=R-t,(I=b-e)>=0&&$>=0&&I>=S._audioStallRatio*$?(f.push({concealed:I,received:$,diff:g,start:m,end:v,get_stats_cost:y-l,get_stats_start:l,get_stats_end:y,is_stall:!0}),r.isStall?(r.counted?p+=g:(p=p+r.diff+g,d++),r.counted=!0):g>=200?(p+=g,d++,r.counted=!0):(r.counted=!1,r.diff=g),r.isStall=!0):(f.push({concealed:I,received:$,diff:g,start:m,end:v,get_stats_cost:y-l,get_stats_start:l,get_stats_end:y}),r.isStall=!1,r.counted=!1),e=b,t=R,m=v,h++,i.abrupt("return",{stall_count:d,stall_duration:p,stall_list:f,stats_count:h});case 32:case"end":return i.stop()}}),i)}))),_=function(){var e=_asyncToGenerator(_regeneratorRuntime().mark((function e(){return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!S._audioStallCount&&S._setAudioStallCount&&S._setAudioStallCount(),!S._audioStallCount){e.next=5;break}return e.next=4,S._audioStallCount();case 4:S._audioStallTimer=setTimeout(_,S._audioStallInterval);case 5:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),S._audioStallTimer=setTimeout(_,S._audioStallInterval)}},this._setAudioStallCount(),y=function(){var e=_asyncToGenerator(_regeneratorRuntime().mark((function e(){var t,r,n,i,o,a;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=null===(t=c.audioTrack)||void 0===t?void 0:t.getTrack(),i=null===(r=c.videoTrack)||void 0===r?void 0:r.getTrack(),e.next=4,S.getRemoteAudioStats(n,s);case 4:return o=e.sent,d=0,p=0,f=[],h=0,e.next=11,S.getRemoteVideoStats(i,s);case 11:return a=e.sent,e.abrupt("return",{audioStats:o,videoStats:a,isScreen:c.isScreen,userId:c.userId});case 13:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),v=function(){var e=_asyncToGenerator(_regeneratorRuntime().mark((function e(){var t,r;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,y();case 2:r=e.sent,null===(t=S.client)||void 0===t||t.emit("onRemoteStreamStats",r),_&&(m=getServerNow(),S._audioStallTimer=setTimeout(_,S._audioStallInterval)),S._timer=setTimeout(v,2e3);case 6:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),this._timer=setTimeout(v,2e3);case 24:case"end":return e.stop()}}),e,this)}))),function(e,t,r){return n.apply(this,arguments)})},{key:"delStatsEvtInterval",value:function(){_get(_getPrototypeOf(o.prototype),"delStatsEvtInterval",this).call(this),clearTimeout(this._audioStallTimer),this._audioStallCount=void 0,this._setAudioStallCount=void 0}},{key:"unsubscribe",value:function(){this.delStatsEvtInterval(),this._videoInWaiting=!1}},{key:"getRemoteAudioStats",value:(r=_asyncToGenerator(_regeneratorRuntime().mark((function e(t,r){var n,i,o,a,s,c,u,l,d,p,_,f,h,m,y,v,S,g;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n={},i={},o=this._stream,a=o.streamId,s=o.userId,c=o.isScreen,u=o.audioMid,l=o.subMediaType,d=o._attributes,p={media_type:"audio",is_screen:!!c,direction:"down",stream_id:a,stream_user_id:s,vid:u,connection_status:navigator.onLine,mute_state:audioInMediaType(l)?"mute_state_off":"mute_state_on",remote_user_capture_state:d.localaudio?"capture_state_on":"capture_state_off",remote_user_mute_state:d.localaudio&&d.audiostream?"mute_state_off":"mute_state_on"},t&&this.handler){e.next=6;break}return e.abrupt("return",n);case 6:return e.next=8,this.handler.getStats(t);case 8:if((_=e.sent).length){e.next=11;break}return e.abrupt("return",n);case 11:if(_.forEach((function(e){var t=e.type,r=e.packetsLost,o=e.packetsReceived,a=e.bytesReceived,s=e.jitterBufferDelay,c=e.jitterBufferEmittedCount,u=e.clockRate,l=e.channels,d=e.totalSamplesReceived,_=e.concealedSamples,f=e.silentConcealedSamples,h=e.concealmentEvents,m=e.totalRoundTripTime,y=e.state,v=e.currentRoundTripTime,S=e.audioLevel,g=e.totalAudioEnergy,E=e.totalSamplesDuration,T=e.mimeType,b=e.googDecodingNormal,R=e.fecPacketsReceived,I=e.availableIncomingBitrate,$=e.availableOutgoingBitrate,A=e.bytesSent,C=e.nominated,O=e.id,P=e.writable,k=e.jitter,w=e.candidateType,N=e.ip,D=e.address,M=e.networkType,x=e.port,L=e.protocol,U=e.audioOutputLevel,F=e.requestsReceived,B=e.responsesReceived,V=e.requestsSent,j=e.consentRequestsSent,G=e.responsesSent,H=e.ssrc;e.kind,"inbound-rtp"===t?(i.packetsLost=r,i.packetsReceived=o,p.packetsReceived=o,i.bytesReceived=a,p.bytes=a,void 0!==s&&(n.jitterBufferDelay=s/c*1e3,p.average_jitter_buffer_delay_ms=n.jitterBufferDelay),void 0!==d&&(i.totalSamplesReceived=d,n.concealedSamples=_,i.concealedSamples=_,i.silentConcealedSamples=f,p.concealedSamples=_,n.concealmentEvents=h,p.totalSamplesReceived=d),void 0!==R&&(p.fec_packets_received=R),p.jitter=1e3*k,p.ssrc=H,void 0!==S&&(p.audio_level=S?-10*Math.log10(Math.pow(S,2)):S),void 0!==S&&(p.volume=255*S),void 0!==g&&(p.total_audio_energy=g),void 0!==E&&(p.totalAudioDuration=E)):"codec"===t?(n.recordSampleRate=u,l&&(n.numChannels=l),p.codecName=T):"candidate-pair"===t?(p.ice_available_incoming_bitrate=I,p.ice_available_outgoing_bitrate=$,p.ice_bytes_received=a,p.ice_bytes_sent=A,p.ice_nominated=+C,p.ice_pair_id=O,p.ice_pair_rtt=v,p.rtt=1e3*v,p.ice_pair_state=y,p.ice_pair_writable=P,p.recv_ping_requests=F,p.recv_ping_responses=B,p.sent_ping_requests_before_first_response=V,p.sent_ping_requests_total=V+(j||0),p.sent_ping_responses=G,"succeeded"===y&&(n.rtt=1e3*v,n.total_rtt=1e3*m)):"track"===t&&void 0!==S?(p.audio_level=S?-10*Math.log10(Math.pow(S,2)):S,p.volume=255*S,p.total_audio_energy=g,p.totalAudioDuration=E):"ssrc"===t?(p.decodingNormal=b,p.recvAudioLevel=U):"local-candidate"===t?(p.local_candidate_type=w,p.local_ip=N||D,p.local_network_type=M,p.local_port=x,p.protocol=L):"remote-candidate"===t&&(p.remote_candidate_type=w,p.remote_ip=N||D,p.remote_port=x)})),(f=r.audio).timestamp){e.next=17;break}return i.timestamp=Date.now(),r.audio=i,e.abrupt("return",n);case 17:if(h={},void 0!==i.concealedSamples&&(p.interval_concealed_samples=i.concealedSamples-f.concealedSamples,p.interval_samples_received=i.totalSamplesReceived-f.totalSamplesReceived,p.interval_silent_concealed_samples=i.silentConcealedSamples-f.silentConcealedSamples),!(this._audioStallInterval>0&&void 0!==f.concealedSamples)){e.next=35;break}if(!this._audioStallCount&&this._setAudioStallCount&&this._setAudioStallCount(),clearTimeout(this._audioStallTimer),!this._audioStallCount){e.next=35;break}return e.next=25,this._audioStallCount();case 25:m=e.sent,y=m.stall_count,v=m.stall_duration,S=m.stall_list,g=m.stats_count,h.stall_list=S,h.stats_count=g,p.concealedSamples===p.interval_concealed_samples&&p.totalSamplesReceived===p.interval_samples_received?(p.stall_count=0,p.stall_duration=0):(p.stall_count=y,p.stall_duration=v),n.stallCount=p.stall_count,n.stallDuration=p.stall_duration;case 35:return i.timestamp=Date.now(),n.audioLossRate=(i.packetsLost-f.packetsLost)/(i.packetsReceived-f.packetsReceived+(i.packetsLost-f.packetsLost)),n.audioLossRate=Number.isNaN(n.audioLossRate)?0:n.audioLossRate,p.packetsLost=Math.round(i.packetsLost-f.packetsLost),p.fraction_lost=n.audioLossRate,p.packets_lost_rate=n.audioLossRate,n.statsInterval=i.timestamp-f.timestamp,p.stats_interval=n.statsInterval,n.receivedKBitrate=(i.bytesReceived-f.bytesReceived||0)/n.statsInterval*8,p.bitrate=Math.round(1e3*n.receivedKBitrate),p.bandwidth=Math.round(p.bitrate/1024),void 0!==i.concealedSamples&&(n.receivedSampleRate=1e3*p.interval_samples_received/n.statsInterval),r.audio=i,this.monitor.rtcMediaStatistics(p,{},h),e.abrupt("return",n);case 50:case"end":return e.stop()}}),e,this)}))),function(e,t){return r.apply(this,arguments)})},{key:"getRemoteVideoStats",value:(t=_asyncToGenerator(_regeneratorRuntime().mark((function e(t,r){var n,i,o,a,s,c,u,l,d,p,_;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n={},i={timestamp:Date.now()},o=this._stream,a=o.streamId,s=o.userId,c=o.isScreen,u=o.subMediaType,l=o._attributes,d={media_type:"video",is_screen:!!c,direction:"down",stream_id:a,stream_user_id:s,vid:this._stream.videoMid,connection_status:navigator.onLine,mute_state:videoInMediaType(u)?"mute_state_off":"mute_state_on",remote_user_capture_state:l.localvideo?"capture_state_on":"capture_state_off",remote_user_mute_state:l.localvideo&&l.videostream?"mute_state_off":"mute_state_on"},t&&this.handler){e.next=6;break}return e.abrupt("return",n);case 6:return n.isScreen=c,e.next=9,this.handler.getStats(t);case 9:if((p=e.sent).length){e.next=12;break}return e.abrupt("return",n);case 12:if(p.forEach((function(e){var t=e.type,r=e.frameHeight,o=e.frameWidth,a=e.packetsLost,s=e.packetsReceived,c=e.bytesReceived,u=e.framesDecoded,l=e.jitterBufferDelay,p=e.jitterBufferEmittedCount,_=e.mimeType,f=e.firCount,h=e.availableIncomingBitrate,m=e.availableOutgoingBitrate,y=e.bytesSent,v=e.nominated,S=e.id,g=e.currentRoundTripTime,E=e.state,T=e.writable,b=e.candidateType,R=e.ip,I=e.address,$=e.networkType,A=e.port,C=e.nackCount,O=e.pliCount,P=e.protocol,k=e.requestsReceived,w=e.responsesReceived,N=e.requestsSent,D=e.consentRequestsSent,M=e.responsesSent,x=e.ssrc;e.kind;var L=e.jitter,U=e.framesReceived,F=e.keyFramesDecoded,B=e.totalDecodeTime,V=e.decoderImplementation,j=e.lastPacketReceivedTimestamp;"inbound-rtp"===t?(i.packetsLost=a,d.packetsLost=a,i.packetsReceived=s,d.packetsReceived=s,i.bytesReceived=c,d.bytes=c,i.framesDecoded=u,void 0!==l&&(i.jitterBufferDelay=l/p*1e3,d.average_jitter_buffer_delay_ms=i.jitterBufferDelay),d.fir_count=f,d.nackCount=C,i.nackCount=C,d.pli_count=O,d.ssrc=x,d.jitter=L,d.framesReceived=U,i.framesReceived=U,d.framesDecoded=u,d.key_frames_decoded=F,d.total_decode_time=B,d.decoder_name=V,d.last_packet_received_timestamp=j,void 0!==o&&(n.width=o,d.frame_size_width=o,n.height=r,d.frame_size_height=r)):"track"===t&&void 0!==o?(n.width=o,d.frame_size_width=o,n.height=r,d.frame_size_height=r,void 0!==U&&(d.framesReceived=U,i.framesReceived=U)):"codec"===t?d.codecName=_:"candidate-pair"===t?(d.ice_available_incoming_bitrate=h,d.ice_available_outgoing_bitrate=m,d.ice_bytes_received=c,d.ice_bytes_sent=y,d.ice_nominated=+v,d.ice_pair_id=S,d.ice_pair_rtt=g,d.rtt=1e3*g,n.rtt=d.rtt,d.ice_pair_state=E,d.ice_pair_writable=T,d.recv_ping_requests=k,d.recv_ping_responses=w,d.sent_ping_requests_before_first_response=N,d.sent_ping_requests_total=N+(D||0),d.sent_ping_responses=M):"local-candidate"===t?(d.local_candidate_type=b,d.local_ip=R||I,d.local_network_type=$,d.local_port=A,d.protocol=P):"remote-candidate"===t&&(d.remote_candidate_type=b,d.remote_ip=R||I,d.remote_port=A)})),(_=r.video).timestamp){e.next=17;break}return r.video=i,e.abrupt("return",n);case 17:return n.videoLossRate=(i.packetsLost-_.packetsLost)/(i.packetsReceived-_.packetsReceived+(i.packetsLost-_.packetsLost)),n._retransmittedRate=(i.nackCount-_.nackCount)/(i.packetsReceived-_.packetsReceived+(i.packetsLost-_.packetsLost)),n.videoLossRate=Number.isNaN(n.videoLossRate)?0:n.videoLossRate,d.fraction_lost=n.videoLossRate,d.packets_lost_rate=n.videoLossRate,n.statsInterval=i.timestamp-_.timestamp,d.stats_interval=n.statsInterval,n.receivedKBitrate=(i.bytesReceived-_.bytesReceived||0)/n.statsInterval*8,d.bitrate=Math.round(1e3*n.receivedKBitrate),d.bandwidth=Math.round(d.bitrate/1024),n.decoderOutputFrameRate=1e3*(i.framesDecoded-_.framesDecoded)/n.statsInterval,n.receivedFrameRate=1e3*(i.framesReceived-_.framesReceived)/n.statsInterval,d.frame_rate_decoded=Math.round(n.decoderOutputFrameRate),d.frame_rate_received=d.frame_rate_decoded,r.video=i,this.processStall(this._stream,d,n,c),this.monitor.rtcMediaStatistics(d,{}),e.abrupt("return",n);case 35:case"end":return e.stop()}}),e,this)}))),function(e,r){return t.apply(this,arguments)})},{key:"processStall",value:function(e,t,r,n){var i=0,o=0,a=0;if(e.recordedVideoFrames){e.recordedVideoFrames.forEach((function(e){e.isStall&&(i+=e.stallCount,o+=e.stallDuration),a=e.playTime})),e.recordedVideoFrames.length||(o=2e3,i=this._videoInWaiting?0:1,this._videoInWaiting=!0);var s=e.recordedVideoFrames.pop();s&&(s.isStall?this._videoInWaiting=!0:this._videoInWaiting=!1),e.recordedVideoFrames=[]}t.stall_count=i,n?(t.stuck_length=o,t.stall_duration=void 0):(t.stall_duration=o,t.stuck_length=void 0),t.play_time=a,r.stallCount=i,r.stallDuration=o}},{key:"destroy",value:function(){_get(_getPrototypeOf(o.prototype),"destroy",this).call(this),this.delStatsEvtInterval(),this._videoInWaiting=!1}}],[{key:"audioStallConfig",set:function(e){o.audioStallInterval=((null==e?void 0:e.audio_stall_interval)||200)/2,o.audioStallRatio=null==e?void 0:e.audio_stall_ratio}}]),o}();_defineProperty(RemoteStatsReport,"audioStallInterval",void 0),_defineProperty(RemoteStatsReport,"audioStallRatio",void 0);var _negativedAction,_aggregationSdpStrate,_RoomProfileMap,RoomEvent=function(e){return e.RESUBSCRIBE="resubscribe",e.STREAM_FAILED="stream_failed",e.SUBSCRIBE_PUSH_TRACK="subscribe_push_track",e.REMOVE_PUSH_TRACK="remove_push_track",e.VIDEO_FIRST_FRAME="video_first_frame",e.ON_USER_PUBLISH_STATE_CHANGE="on_user_publish_state_change",e.ON_USER_START_AUDIO_CAPTURE="on_user_start_audio_capture",e.ON_USER_STOP_AUDIO_CAPTURE="on_user_stop_audio_capture",e.ON_USER_START_VIDEO_CAPTURE="on_user_start_video_capture",e.ON_USER_STOP_VIDEO_CAPTURE="on_user_stop_video_capture",e.ON_SEI_MESSAGED_RECEIVED="on_sei_messaged_received",e.ON_PUBLISH_RESULT="on_publish_result",e.ON_UPDATE_TOKEN_SUCCESS="on_update_token_success",e.ON_REMOTE_STREAM_STATS="ON_REMOTE_STREAM_STATS",e.ON_LOCAL_STREAM_STATS="ON_LOCAL_STREAM_STATS",e.ON_USER_LEAVE="on_user_leave",e.ON_ROOM_ERROR="on_room_error",e.ON_NETWORK_QUALITY="on_network_quality",e.ON_SIMULCAST_SUBSCRIBE_FALLBACK="on_simulcast_subscribe_fallback",e.ON_REMOTE_VIDEO_SIZE_CHANGED="on_remote_video_size_changed",e.RECONNECT_FAILED="reconnect_failed",e.ON_VIDEO_STREAM_BANNED="ON_VIDEO_STREAM_BANNED",e.ON_AUDIO_STREAM_BANNED="ON_AUDIO_STREAM_BANNED",e}(RoomEvent||{}),StreamMixingEventType=function(e){return e[e.START=1]="START",e[e.START_SUCCESS=2]="START_SUCCESS",e[e.START_FAILED=3]="START_FAILED",e[e.UPDATE=4]="UPDATE",e[e.UPDATE_SUCCESS=5]="UPDATE_SUCCESS",e[e.UPDATE_FAILED=6]="UPDATE_FAILED",e[e.STOP=7]="STOP",e[e.STOP_SUCCESS=8]="STOP_SUCCESS",e[e.STOP_FAILED=9]="STOP_FAILED",e}(StreamMixingEventType||{}),PubState=function(e){return e[e.PUB=0]="PUB",e[e.UNPUB=1]="UNPUB",e}(PubState||{}),SubState=function(e){return e[e.SUB=0]="SUB",e[e.UNSUB=1]="UNSUB",e}(SubState||{}),logger$d=new Logger("Stream",0),StreamState=function(e){return e[e.INIT=0]="INIT",e[e.SUB_ING=1]="SUB_ING",e[e.SUB_ED=2]="SUB_ED",e}(StreamState||{}),LocalStream=function(){function e(){_classCallCheck(this,e),_defineProperty(this,"isScreen",!1),_defineProperty(this,"stream",void 0),_defineProperty(this,"streamId",void 0),_defineProperty(this,"audioMid",void 0),_defineProperty(this,"videoMid",void 0),_defineProperty(this,"seiList",[]),_defineProperty(this,"videoTrack",void 0),_defineProperty(this,"audioTrack",void 0),_defineProperty(this,"videoTransceiver",void 0),_defineProperty(this,"audioTransceiver",void 0),_defineProperty(this,"videoInputConfig",void 0),_defineProperty(this,"videoEncodeConfig",[defaultVideoEncoderConfig]),_defineProperty(this,"subVideoDescriptions",[]),_defineProperty(this,"enableSimulcast",!1),_defineProperty(this,"observer",void 0),_defineProperty(this,"statsReport",void 0),_defineProperty(this,"prevScaleResolutionDownBy",1),_defineProperty(this,"pubAudio",!1),_defineProperty(this,"pubVideo",!1),_defineProperty(this,"pubAttributes",void 0),this.stream=new MediaStream,this.videoInputConfig={width:640,height:360,frameRate:30},this.pubAttributes={localaudio:!1,localvideo:!1,videostream:!1,audiostream:!1,extvideo:!1,extaudio:!1},this.statsReport=new LocalStatsReport(this)}return _createClass(e,[{key:"hasPublished",get:function(){return this.videoTransceiver&&this.audioTransceiver}},{key:"isEmptyStream",get:function(){return!this.audioTrack&&!this.videoTrack}},{key:"initStreamId",get:function(){return this.stream.id}},{key:"initVideoEncodedTransform",value:function(){var e=this;if(this.videoTransceiver&&this.videoTransceiver.sender){var t=this.videoTransceiver.sender;if(isEncodedTransformSupported()){var r=t.createEncodedStreams(),n=r.readable,i=r.writable,o=new TransformStream({transform:function(t,r){var n=e.seiList[0];if(n){var i=SEIHelper.generateSEI(n.content),o=new Uint8Array(i.byteLength+t.data.byteLength);0===n.repeatCount&&e.seiList.splice(0,1),n.repeatCount--,o.set(new Uint8Array(t.data)),o.set(i,t.data.byteLength),t.data=o.buffer,r.enqueue(t)}else r.enqueue(t)}});n.pipeThrough(o).pipeTo(i)}}else logger$d.print("no sender found when trying to bind encodedTransform")}},{key:"initAudioEncodedTransform",value:function(){if(this.audioTransceiver&&this.audioTransceiver.sender){var e=this.audioTransceiver.sender.createEncodedStreams(),t=e.readable,r=e.writable;t.pipeThrough(new TransformStream({transform:function(e,t){t.enqueue(e)}})).pipeTo(r)}else logger$d.print("no sender found when trying to bind encodedTransform")}},{key:"clean",value:function(){var e;this.audioMid=void 0,this.videoMid=void 0,this.videoTransceiver=void 0,this.audioTransceiver=void 0,null===(e=this.observer)||void 0===e||e.reset(),this.statsReport.destroy(),this.prevScaleResolutionDownBy=1,this.subVideoDescriptions=[]}},{key:"switchTrackEnableState",value:function(e,t){var r,n;"audio"===e?n=this.audioTrack:"video"===e&&(n=this.videoTrack);var i=null===(r=n)||void 0===r?void 0:r.getTrack();return!(!i||(null==i?void 0:i.enabled)===t)&&(i.enabled=t,!0)}}]),e}(),RemoteStream=function(e){_inherits(r,EnhancedEventEmitter);var t=_createSuper(r);function r(e,n,i,o){var a,s=arguments.length>4&&void 0!==arguments[4]?arguments[4]:RemoteUserPriority.LOW;return _classCallCheck(this,r),_defineProperty(_assertThisInitialized(a=t.call(this)),"streamId",void 0),_defineProperty(_assertThisInitialized(a),"userId",void 0),_defineProperty(_assertThisInitialized(a),"isScreen",void 0),_defineProperty(_assertThisInitialized(a),"hasVideo",void 0),_defineProperty(_assertThisInitialized(a),"hasAudio",void 0),_defineProperty(_assertThisInitialized(a),"_attributes",void 0),_defineProperty(_assertThisInitialized(a),"streamState",void 0),_defineProperty(_assertThisInitialized(a),"observer",void 0),_defineProperty(_assertThisInitialized(a),"statsReport",void 0),_defineProperty(_assertThisInitialized(a),"subVideo",void 0),_defineProperty(_assertThisInitialized(a),"subAudio",void 0),_defineProperty(_assertThisInitialized(a),"subMediaType",void 0),_defineProperty(_assertThisInitialized(a),"subLayer",void 0),_defineProperty(_assertThisInitialized(a),"audioMid",void 0),_defineProperty(_assertThisInitialized(a),"videoMid",void 0),_defineProperty(_assertThisInitialized(a),"autosubAudioMid",void 0),_defineProperty(_assertThisInitialized(a),"autosubVideoMid",void 0),_defineProperty(_assertThisInitialized(a),"_sequenceId",void 0),_defineProperty(_assertThisInitialized(a),"stream",void 0),_defineProperty(_assertThisInitialized(a),"videoTrack",void 0),_defineProperty(_assertThisInitialized(a),"audioTrack",void 0),_defineProperty(_assertThisInitialized(a),"videoTransceiver",void 0),_defineProperty(_assertThisInitialized(a),"audioTransceiver",void 0),_defineProperty(_assertThisInitialized(a),"recordedVideoFrames",void 0),_defineProperty(_assertThisInitialized(a),"stillExist",void 0),_defineProperty(_assertThisInitialized(a),"_workaround_1_",void 0),_defineProperty(_assertThisInitialized(a),"paused",void 0),_defineProperty(_assertThisInitialized(a),"originalMediaType",void 0),_defineProperty(_assertThisInitialized(a),"originalStreamIndex",0),a.userPriority=s,a.userId=e,a.isScreen=i,a.streamId=n,a.hasAudio=o.audiostream&&o.localaudio,a.hasVideo=o.videostream&&o.localvideo,a._attributes=o,a.subVideo=!1,a.subAudio=!1,a._sequenceId=0,a.subMediaType=ExtendMediaType.NONE,a.subLayer={spatialLayer:0,spatialSubLayer:-1},a.streamState=0,a.statsReport=new RemoteStatsReport(_assertThisInitialized(a)),a}return _createClass(r,[{key:"sequenceId",get:function(){return this._sequenceId||-1},set:function(e){"number"==typeof e&&(this._sequenceId=e)}},{key:"hasSubscribed",get:function(){return 2===this.streamState}},{key:"attributes",get:function(){return this._attributes},set:function(e){this.hasVideo=e.localvideo&&e.videostream,this.hasAudio=e.localaudio&&e.audiostream,this._attributes=e}},{key:"initVideoEncodedTransform",value:function(){var e=this;if(this.videoTransceiver&&this.videoTransceiver.receiver){var t=this.videoTransceiver.receiver.createEncodedStreams(),r=t.readable,n=t.writable;r.pipeThrough(new TransformStream({transform:function(t,r){Nalunit.getNalunits(new RTCDataView(t.data)).forEach((function(t){if(t.sei){var r=SEIHelper.decodeSeiBody(t.body);r&&r.type!==RTC_SEI_TYPE.internal&&e.safeEmit("onSEIMessage",r.payload)}})),r.enqueue(t)}})).pipeTo(n)}else logger$d.print("no receiver found when trying to bind encodedTransform")}},{key:"initAudioEncodedTransform",value:function(){if(this.audioTransceiver&&this.audioTransceiver.receiver){var e=this.audioTransceiver.receiver.createEncodedStreams(),t=e.readable,r=e.writable;t.pipeThrough(new TransformStream({transform:function(e,t){t.enqueue(e)}})).pipeTo(r)}else logger$d.print("no receiver found when trying to bind encodedTransform")}},{key:"ontrack",value:function(e){var t,r;if((null===(t=e.streams)||void 0===t||null===(r=t[0])||void 0===r?void 0:r.id)===this.streamId){var n,i=e.track;"video"===(null==i?void 0:i.kind)?this._setVideoTrack(i):"audio"===(null===(n=e.track)||void 0===n?void 0:n.kind)&&this._setAudioTrack(i),this._setStream(e.streams[0])}this.safeEmit("ontrack",e)}},{key:"clean",value:function(){var e;logger$d.print("clean","exec stream.clean ".concat(this.streamId," ").concat(this.userId)),this.subAudio=!1,this.subVideo=!1,this.audioMid=void 0,this.videoMid=void 0,this.sequenceId=0,this.videoTrack=void 0,this.audioTrack=void 0,this.stream=void 0,this.videoTransceiver=void 0,this.audioTransceiver=void 0,this.recordedVideoFrames=void 0,this.paused=!1,this._workaround_1_=!1,null===(e=this.observer)||void 0===e||e.reset(),this.statsReport.destroy()}},{key:"resetHasSubscribed",value:function(){this.streamState=0}},{key:"setRemoteUserPriority",value:function(e){this.userPriority=e}},{key:"getStreamPriority",value:function(){var e=this.isScreen?20:this.hasAudio||this.hasVideo?this.attributes.videoDescriptions.length>1?10-this.subLayer.spatialLayer:9:0;return 1e4*this.userPriority+100*e}},{key:"getSubscribeFallbackParams",value:function(e){if(e!==SubscribeFallbackOption.DISABLE&&this.subVideo){if(this.attributes.videoDescriptions.length-1>this.subLayer.spatialLayer)return[this.originalMediaType,SubState.SUB,this._getSubLayerBySpatialLayer(this.subLayer.spatialLayer+1)];if(e===SubscribeFallbackOption.AUDIO_ONLY)return[MediaType.VIDEO,SubState.UNSUB]}return null}},{key:"getSubscribeRecoverParams",value:function(){if(this.originalMediaType&&videoInMediaType(this.originalMediaType)){if(!1===this.subVideo)return[this.originalMediaType,SubState.SUB,this.subLayer];if("number"==typeof this.originalStreamIndex&&this.subLayer.spatialLayer>this.originalStreamIndex)return[this.originalMediaType,SubState.SUB,this._getSubLayerBySpatialLayer(this.subLayer.spatialLayer-1)]}return null}},{key:"_setStream",value:function(e){var t=this;this.stream=e,e.onaddtrack=function(e){"video"===e.track.kind?t._setVideoTrack(e.track):"audio"===e.track.kind&&t._setAudioTrack(e.track)}}},{key:"_setAudioTrack",value:function(e){var t,r;(null===(t=this.audioTrack)||void 0===t||null===(r=t.getTrack())||void 0===r?void 0:r.id)!==(null==e?void 0:e.id)&&(this.audioTrack=new RemoteAudioTrack(e,genUuid()),this.emit("ontrack",this.audioTrack))}},{key:"_setVideoTrack",value:function(e){var t,r;(null===(t=this.videoTrack)||void 0===t||null===(r=t.getTrack())||void 0===r?void 0:r.id)!==(null==e?void 0:e.id)&&(this.videoTrack=new RemoteVideoTrack(e,genUuid()),this.emit("ontrack",this.videoTrack))}},{key:"_getSubLayerBySpatialLayer",value:function(e){var t=this._attributes,r=t.videoDescriptions,n=t.subVideoDescriptions,i=void 0===n?[]:n,o=r[e],a=o.width,s=o.height,c=i.find((function(e){return e.width===a&&e.height===s}));return{spatialLayer:e,spatialSubLayer:(null==c?void 0:c.sub_index)||-1}}}]),r}(),logger$c=new Logger("queue",4),SdpStrategy=function(e){return e[e.ADD=0]="ADD",e[e.CLOSE=1]="CLOSE",e}(SdpStrategy||{}),SdpAction=function(e){return e.publish="publish",e.unpublish="unpublish",e.subscribe="subscribe",e.unsubscribe="unsubscribe",e.pushtrack="pushtrack",e.removetrack="removetrack",e}(SdpAction||{}),negativedAction=(_defineProperty(_negativedAction={},"publish","unpublish"),_defineProperty(_negativedAction,"subscribe","unsubscribe"),_defineProperty(_negativedAction,"pushtrack","removetrack"),_negativedAction),aggregationSdpStrategy=(_defineProperty(_aggregationSdpStrate={},"publish",0),_defineProperty(_aggregationSdpStrate,"subscribe",0),_defineProperty(_aggregationSdpStrate,"pushtrack",0),_defineProperty(_aggregationSdpStrate,"unpublish",1),_defineProperty(_aggregationSdpStrate,"unsubscribe",1),_defineProperty(_aggregationSdpStrate,"removetrack",1),_aggregationSdpStrate),SdpQueue=function(e){_inherits(r,EventEmitter);var t=_createSuper(r);function r(){var e;return _classCallCheck(this,r),_defineProperty(_assertThisInitialized(e=t.call(this)),"_queue",void 0),e._queue=[],e}return _createClass(r,[{key:"queue",get:function(){return this._queue}},{key:"enqueue",value:function(e){var t=this._queue.length,r="";return this._queue=this._queue.filter((function(t){return t.streamId!==e.streamId||e.action!==negativedAction[t.action]||(r=t.streamId,logger$c.print("offsetStreamId",r),!1)})),this._queue.length===t&&this._queue.push(e),this.emit("start"),r}},{key:"dequeue",value:function(){if(!this._queue.length)return null;for(var e=aggregationSdpStrategy[this._queue[0].action],t=1;t<this._queue.length;t++)if(aggregationSdpStrategy[this._queue[t].action]!==e)return{sdpStrategy:e,items:this._queue.splice(0,t)};return{sdpStrategy:e,items:this._queue.splice(0,this._queue.length)}}}]),r}(),logger$b=new Logger("ChromeHandler",3),encodedTransformSupported=isEncodedTransformSupported(),ChromeHandler=function(e){_inherits(l,BasicHandler);var t,r,n,i,o,a,s,c,u=_createSuper(l);function l(e,t){var r;return _classCallCheck(this,l),_defineProperty(_assertThisInitialized(r=u.call(this,e,t)),"name","chrome"),_defineProperty(_assertThisInitialized(r),"_queueBusy",!1),_defineProperty(_assertThisInitialized(r),"_sdpQueue",void 0),_defineProperty(_assertThisInitialized(r),"_aSendonlyOfferTpl",void 0),_defineProperty(_assertThisInitialized(r),"_vSendonlyOfferTpl",void 0),_defineProperty(_assertThisInitialized(r),"_aRecvonlyOfferTpl",void 0),_defineProperty(_assertThisInitialized(r),"_vRecvonlyOfferTpl",void 0),_defineProperty(_assertThisInitialized(r),"_mid",0),_defineProperty(_assertThisInitialized(r),"_offerSession",void 0),_defineProperty(_assertThisInitialized(r),"_answerSession",void 0),_defineProperty(_assertThisInitialized(r),"_offerMlines",[]),_defineProperty(_assertThisInitialized(r),"_answerMlines",[]),_defineProperty(_assertThisInitialized(r),"_inactiveMlineIndex",[]),_defineProperty(_assertThisInitialized(r),"_msidIndexMap",{}),_defineProperty(_assertThisInitialized(r),"_mlinesCache",{}),r._sdpQueue=new SdpQueue,r._sdpQueue.on("start",(function(){r._queueBusy||"stable"!==r._peerConnection.signalingState||(logger$b.print("dequeue start"),r.dequeue())})),r}return _createClass(l,[{key:"connect",value:(c=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){var r,n,i,o,a,s,c,u=this;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return logger$b.print("connect","invoke connect"),this._offerIce={iceUfrag:null===(r=t.iceParams)||void 0===r?void 0:r.clientIceUfrag,icePwd:null===(n=t.iceParams)||void 0===n?void 0:n.clientIcePwd,iceOptions:"renomination"},e.next=4,parseAnswerIceParams(t);case 4:return this._answerIce=e.sent,e.next=7,this._peerConnection.createOffer();case 7:return i=e.sent,o=lib.parse(i.sdp),a=_slicedToArray(o.media,1),s=a[0],this._offerIce.fingerprint=o.fingerprint||s.fingerprint,delete o.media,this._offerSession=_objectSpread2({},o),this._answerSession=_objectSpread2({},o),this._answerSession.fingerprint&&(this._answerSession.fingerprint=this._answerIce.fingerprint),c=this._mid++,this._offerMlines=[_objectSpread2(_objectSpread2(_objectSpread2({},s),this._offerIce),{},{mid:"".concat(c)})],this._answerMlines=[_objectSpread2(_objectSpread2(_objectSpread2({},s),this._answerIce),{},{sctpmap:{sctpmapNumber:5e3,app:"webrtc-datachannel",maxMessageSize:262144},mid:"".concat(c)})],this.setDescription(),e.next=21,new Promise((function(e,t){u._dataChannel.onopen=function(){logger$b.print("connect","dataChannel open"),reportRtcInvokeStatus("es.dc.open",""),e("")},u._dataChannel.onerror=function(e){monitor.rtcSignalingMsgError(e.error.sdpLineNumber,e.error.errorDetail,RtcsignalingmsgerrorReason.INVALID_DATA),reportRtcInvokeStatus("es.dc.error",""),t(e)},u._dataChannel.onclose=function(e){reportRtcInvokeStatus("es.dc.close",""),t(e)},u._peerConnection.addEventListener("connectionstatechange",(function(e){"failed"!==u._peerConnection.iceConnectionState&&"closed"!==u._peerConnection.iceConnectionState&&"failed"!==u._peerConnection.connectionState||t(e)}))}));case 21:return logger$b.print("connect","dataChannel establish success"),e.abrupt("return",this._dataChannel);case 23:case"end":return e.stop()}}),e,this)}))),function(e){return c.apply(this,arguments)})},{key:"disconnect",value:function(){this._peerConnection.close(),this._dataChannel.close(),this._peerConnection.ontrack=null}},{key:"destroy",value:function(){_get(_getPrototypeOf(l.prototype),"destroy",this).call(this),this._mlinesCache={}}},{key:"publish",value:(s=_asyncToGenerator(_regeneratorRuntime().mark((function e(t,r){var n,i,o,a,s,c,u,d,p,_,f,h,m,y,v,S,g,E,T,b;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=t.stream,i=t.enableSimulcast,o=_get(_getPrototypeOf(l.prototype),"internalPublish",this).call(this,t,r),a=o.videoDescriptions,s=o.subVideoDescriptions,c=o.transceiverInit,u="".concat(this._mid++),d="".concat(this._mid++),p=_objectSpread2(_objectSpread2(_objectSpread2({},this._aSendonlyOfferTpl),this._offerIce),{},{mid:u,msid:"".concat(n.id," ").concat(n.id,"-audio"),ssrcs:generateSsrc(n,"audio")}),_=_objectSpread2(_objectSpread2(_objectSpread2({},this._vSendonlyOfferTpl),this._offerIce),{},{mid:d,msid:"".concat(n.id," ").concat(n.id,"-video")}),i?(logger$b.print("subVideoDesc","desc: %o ",s),delete _.ssrcGroups,delete _.ssrcs,f=[],_.rids=a.map((function(e){var t=e.rid;return f.unshift(t),{id:t,direction:"send"}})),_.simulcast={dir1:"send",list1:f.join(";")}):(h=generateSsrcs(n,"video"),m=h.ssrcs,y=h.ssrcGroups,_.ssrcs=m,_.ssrcGroups=y),isSafari&&isMobile&&Array.isArray(_.ext)&&(_.ext=_.ext.filter((function(e){var t;return!(null!=e&&null!==(t=e.uri)&&void 0!==t&&t.includes("video-orientation"))}))),null!=r&&r.audioRed&&Array.isArray(p.rtp)&&-1!==(v=p.rtp.findIndex((function(e){return"red"===e.codec})))&&(S=p.rtp.splice(v,1),g=_slicedToArray(S,1),E=g[0],p.rtp.unshift(E)),(T=null==p?void 0:p.rtp.find((function(e){return"opus"===e.codec})))&&p.fmtp&&(b=p.fmtp.find((function(e){return e.payload===T.payload})))&&this._context&&(b.config+=this._context.audioProfileManager.getOpusConfigStr()),this.addBitrateLimit(_,t.videoEncodeConfig[0].maxKbps),this._mlinesCache[t.stream.id]=[p,_],e.abrupt("return",{partialSdp:getLocalPartialSdp(this._offerSession,p,_),audioMid:u,videoMid:d,type:"incroffer",semantics:"unified-plan",videoDescriptions:a,subVideoDescriptions:s,transceiverInit:c});case 14:case"end":return e.stop()}}),e,this)}))),function(e,t){return s.apply(this,arguments)})},{key:"subscribe",value:(a=_asyncToGenerator(_regeneratorRuntime().mark((function e(t,r){var n,i,o,a,s,c,u,l,d,p;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(logger$b.print("subscribe","mids: ",r),n="incroffer",i="unified-plan",this._aRecvonlyOfferTpl&&this._vRecvonlyOfferTpl){e.next=11;break}return e.next=6,createDefaultSdp(!0);case 6:if(o=e.sent){e.next=9;break}throw new SDKError(ErrorCode.NOT_SUPPORTED,"Get offer Error");case 9:return e.next=11,this.createAVMlineOfferTpl(o);case 11:if(!this._mlinesCache[t.streamId]){e.next=16;break}return a=_slicedToArray(this._mlinesCache[t.streamId],2),s=a[0],c=a[1],s.mid=t.audioMid,c.mid=t.videoMid,e.abrupt("return",{partialSdp:getLocalPartialSdp(this._offerSession,s,c),audioMid:s.mid,videoMid:c.mid,type:n,semantics:i});case 16:return u="".concat(this._mid++),l="".concat(this._mid++),d=_objectSpread2(_objectSpread2(_objectSpread2({},this._aRecvonlyOfferTpl),this._offerIce),{},{mid:u}),p=_objectSpread2(_objectSpread2(_objectSpread2({},this._vRecvonlyOfferTpl),this._offerIce),{},{mid:l}),this._mlinesCache[t.streamId]=[d,p],e.abrupt("return",{partialSdp:getLocalPartialSdp(this._offerSession,d,p),audioMid:u,videoMid:l,type:n,semantics:i,transceiverInit:{aTrack:"audio",vTrack:"video",audioTransceiverInit:{direction:"recvonly"},videoTransceiverInit:{direction:"recvonly"}}});case 22:case"end":return e.stop()}}),e,this)}))),function(e,t){return a.apply(this,arguments)})},{key:"handleAck",value:(o=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return logger$b.print("handleAck()","item: %o",t),e.abrupt("return",this._sdpQueue.enqueue(t));case 2:case"end":return e.stop()}}),e,this)}))),function(e){return o.apply(this,arguments)})},{key:"dequeue",value:(i=_asyncToGenerator(_regeneratorRuntime().mark((function e(){var t,r,n,i,o,a,s,c,u,l,d,p=this;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._queueBusy=!0,t=this._sdpQueue.dequeue(),logger$b.print("dequeue()","ret: %o",t),t){e.next=6;break}return this._queueBusy=!1,e.abrupt("return");case 6:if(e.prev=6,r=t.items,n=t.sdpStrategy,i=[],o=[],n!==SdpStrategy.ADD){e.next=14;break}return e.delegateYield(_regeneratorRuntime().mark((function e(){var t,n;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:delete(t=_objectSpread2({},p._answerIce)).candidates,a=!1,s=!1,e.prev=4,u=_asyncIterator(r);case 6:return e.next=8,u.next();case 8:if(!(a=!(l=e.sent).done)){e.next=17;break}return n=l.value,e.delegateYield(_regeneratorRuntime().mark((function e(){var r,a,s,c,u,l,d,_,f,h,m,y,v,S,g,E,T,b,R,I,$;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=n.action,a=n.transceiverInit,s=n.signalingAck,c=n.stream,!((u=c instanceof RemoteStream)&&(null==s?void 0:s.sequenceId)<c.sequenceId)){e.next=4;break}return e.abrupt("return","break");case 4:if(l={},d={},_=lib.parse(s.sdp),Array.isArray(_.media)&&(f="",_.media.sort((function(e,t){var r;return null==e||null===(r=e.type)||void 0===r?void 0:r.localeCompare(null==t?void 0:t.type)})).forEach((function(e){"audio"===(e=_objectSpread2(_objectSpread2({},e),t)).type?(l=e,logger$b.print("audioMsid",e.msid),e.msid&&(f=e.msid.replace("audio","video"))):(d=e,logger$b.print("videoMsid",f),f&&(d.msid=f,f=""))}))),h=c.streamId,r===SdpAction.publish&&(h=null===(m=c.stream)||void 0===m?void 0:m.id),p._mlinesCache[h]){e.next=12;break}return e.abrupt("return","break");case 12:if(y=_slicedToArray(p._mlinesCache[h],2),v=y[0],S=y[1],!a){e.next=30;break}c.audioTransceiver=p._peerConnection.addTransceiver(a.aTrack,a.audioTransceiverInit),c.videoTransceiver=p._peerConnection.addTransceiver(a.vTrack,a.videoTransceiverInit),(g=p._inactiveMlineIndex.shift())||(g=p._offerMlines.length),p._offerMlines[g]=_objectSpread2(_objectSpread2({},v),{},{mid:l.mid}),p._answerMlines[g]=l,(E=p._inactiveMlineIndex.shift())||(E=p._offerMlines.length),p._offerMlines[E]=_objectSpread2(_objectSpread2({},S),{},{mid:d.mid}),p._answerMlines[E]=d,p._msidIndexMap[c.streamId]=[g,E],encodedTransformSupported&&(c.initAudioEncodedTransform(),c.initVideoEncodedTransform()),i.push(c.streamId||""),o.push(u?c.userId:"local"),e.next=48;break;case 30:if(!u){e.next=48;break}if(T=p._msidIndexMap[c.streamId]||[],b=_slicedToArray(T,2),R=b[0],I=b[1],!R||!I){e.next=47;break}if((null===($=p._offerMlines[R])||void 0===$?void 0:$.mid)===l.mid){e.next=43;break}return p._offerMlines[R]=closeMline(p._offerMlines[R]),p._offerMlines[I]=closeMline(p._offerMlines[I]),p._answerMlines[R]=closeMline(p._answerMlines[R]),p._answerMlines[I]=closeMline(p._answerMlines[I]),e.next=40,p.setDescription();case 40:p._offerMlines[R]=_objectSpread2(_objectSpread2({},p._aRecvonlyOfferTpl),{},{mid:l.mid}),p._offerMlines[I]=_objectSpread2(_objectSpread2({},p._vRecvonlyOfferTpl),{},{mid:d.mid}),logger$b.print("enqueue","hack: %o",c.streamId);case 43:p._answerMlines[R]=l,p._answerMlines[I]=d,e.next=48;break;case 47:logger$b.print("dequeue","pushtrack before subscribe: %o",c.userId);case 48:u&&(c.sequenceId=null==s?void 0:s.sequenceId);case 49:case"end":return e.stop()}}),e)}))(),"t0",11);case 11:if("break"!==e.t0){e.next=14;break}return e.abrupt("break",17);case 14:a=!1,e.next=6;break;case 17:e.next=23;break;case 19:e.prev=19,e.t1=e.catch(4),s=!0,c=e.t1;case 23:if(e.prev=23,e.prev=24,!a||null==u.return){e.next=28;break}return e.next=28,u.return();case 28:if(e.prev=28,!s){e.next=31;break}throw c;case 31:return e.finish(28);case 32:return e.finish(23);case 33:case"end":return e.stop()}}),e,null,[[4,19,23,33],[24,,28,32]])}))(),"t0",12);case 12:e.next=19;break;case 14:d={},r.forEach((function(e){var t,r,n=e.audioMid,i=e.videoMid,o=e.stream;d[n]=n,d[i]=i,delete p._msidIndexMap[null===(t=e.stream)||void 0===t?void 0:t.streamId],o instanceof LocalStream?delete p._mlinesCache[null==o||null===(r=o.stream)||void 0===r?void 0:r.id]:delete p._mlinesCache[null==o?void 0:o.streamId]})),this._offerMlines=this._offerMlines.map((function(e,t){return d[e.mid]&&(e=closeMline(e),p._inactiveMlineIndex.push(t)),e})),this._inactiveMlineIndex.sort((function(e,t){return e-t})),this._answerMlines=this._answerMlines.map((function(e){return d[e.mid]&&(e=closeMline(e)),e}));case 19:return e.next=21,this.setDescription(i.length?{streamId:i.join(","),streamUserId:o.join(",")}:void 0);case 21:logger$b.print("dequeue","loop"),e.next=27;break;case 24:e.prev=24,e.t1=e.catch(6),logger$b.print("dequeue","unknown error: %o",e.t1);case 27:return e.prev=27,this.dequeue(),e.finish(27);case 30:case"end":return e.stop()}}),e,this,[[6,24,27,30]])}))),function(){return i.apply(this,arguments)})},{key:"setDescription",value:(n=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){var r,n;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return logger$b.print("setDescription","_offerMlines: %o, _answerMlines: %o",this._offerMlines,this._answerMlines),this._offerSession.media=this._offerMlines,this._answerSession.media=this._answerMlines,r=[],this._offerMlines.forEach((function(e){"inactive"!==e.direction&&r.push(e.mid)})),this._offerSession.groups&&this._answerSession.groups&&(this._offerSession.groups[0].mids=r.join(" "),this._answerSession.groups[0].mids=r.join(" ")),n=getServerNow(),t&&monitor.rtcBeginCreateOffer("local"===t.streamUserId?RtcbegincreateofferDirection.UP:RtcbegincreateofferDirection.DOWN,t.streamId,t.streamUserId),e.next=10,this._peerConnection.createOffer();case 10:return t&&monitor.rtcCreateOffer(0,"local"===t.streamUserId?RtccreateofferDirection.UP:RtccreateofferDirection.DOWN,t.streamId,t.streamUserId,getServerNow()-n),e.next=13,this.setLocalDescription(lib.write(this._offerSession),t);case 13:return e.next=15,this.setRemoteDescription(lib.write(this._answerSession),t);case 15:case"end":return e.stop()}}),e,this)}))),function(e){return n.apply(this,arguments)})},{key:"getDefaultSdp",value:(r=_asyncToGenerator(_regeneratorRuntime().mark((function e(){var t,r,n;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,createDefaultSdp(!0);case 2:if(t=e.sent){e.next=5;break}throw new SDKError(ErrorCode.NOT_SUPPORTED,"Get offer Error");case 5:return this.createAVMlineOfferTpl(t),r=lib.parse(t),n=[],r.media=r.media.filter((function(e){return"recvonly"===e.direction&&(n.push(e.mid+""),!0)})),r.groups=[{mids:n.join(" "),type:"BUNDLE"}],e.abrupt("return",{sdp:lib.write(r),semantics:"unified-plan",type:"offer"});case 11:case"end":return e.stop()}}),e,this)}))),function(){return r.apply(this,arguments)})},{key:"rollback",value:(t=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:delete this._mlinesCache[t];case 1:case"end":return e.stop()}}),e,this)}))),function(e){return t.apply(this,arguments)})},{key:"createAVMlineOfferTpl",value:function(e){var t=this;lib.parse(e).media.forEach((function(e){"audio"===e.type?"sendonly"===e.direction?t._aSendonlyOfferTpl=e:t._aRecvonlyOfferTpl=e:"video"===e.type&&("sendonly"===e.direction?t._vSendonlyOfferTpl=e:t._vRecvonlyOfferTpl=e)}))}}]),l}(),logger$a=new Logger("FirefoxHandler",3),FirefoxHandler=function(e){_inherits(l,BasicHandler);var t,r,n,i,o,a,s,c,u=_createSuper(l);function l(){var e;_classCallCheck(this,l);for(var t=arguments.length,r=new Array(t),n=0;n<t;n++)r[n]=arguments[n];return _defineProperty(_assertThisInitialized(e=u.call.apply(u,[this].concat(r))),"name","firefox"),e}return _createClass(l,[{key:"connect",value:(c=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){var r,n,i,o,a,s,c,u=this;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return logger$a.print("connect","invoke connect"),this._offerIce={iceUfrag:null===(r=t.iceParams)||void 0===r?void 0:r.clientIceUfrag,icePwd:null===(n=t.iceParams)||void 0===n?void 0:n.clientIcePwd,iceOptions:"renomination"},e.next=4,parseAnswerIceParams(t);case 4:return this._answerIce=e.sent,this._peerConnection.addTransceiver("audio",{direction:"recvonly"}),this._peerConnection.addTransceiver("video",{direction:"recvonly"}),e.next=9,this._peerConnection.createOffer();case 9:return i=e.sent,o=lib.parse(i.sdp),a=_slicedToArray(o.media,1),s=a[0],this._offerIce.fingerprint=o.fingerprint||s.fingerprint,o.media=o.media.map((function(e){return _objectSpread2(_objectSpread2({},e),u._offerIce)})),(c=_objectSpread2({},o)).fingerprint=this._answerIce.fingerprint,c.media=c.media.map((function(e){return delete(e=_objectSpread2(_objectSpread2({},e),u._answerIce)).bundleOnly,e.port=9,"application"===e.type?e.sctpmap={sctpmapNumber:5e3,app:"webrtc-datachannel",maxMessageSize:262144}:e.direction="sendonly",e})),e.next=19,this.setLocalDescription(lib.write(o));case 19:return e.next=21,this.setRemoteDescription(lib.write(c));case 21:return e.next=23,new Promise((function(e,t){u._dataChannel.onopen=function(){logger$a.print("connect","dataChannel open"),reportRtcInvokeStatus("es.dc.open",""),e("")},u._dataChannel.onerror=function(e){monitor.rtcSignalingMsgError(e.error.sdpLineNumber,e.error.errorDetail,RtcsignalingmsgerrorReason.INVALID_DATA),reportRtcInvokeStatus("es.dc.error",""),t(e)},u._dataChannel.onclose=function(e){reportRtcInvokeStatus("es.dc.close",""),t(e)},u._peerConnection.addEventListener("connectionstatechange",(function(e){"failed"!==u._peerConnection.iceConnectionState&&"closed"!==u._peerConnection.iceConnectionState&&"failed"!==u._peerConnection.connectionState||t(e)}))}));case 23:return logger$a.print("connect","dataChannel establish success"),e.abrupt("return",this._dataChannel);case 25:case"end":return e.stop()}}),e,this)}))),function(e){return c.apply(this,arguments)})},{key:"publish",value:(s=_asyncToGenerator(_regeneratorRuntime().mark((function e(t,r){var n,i,o,a,s,c,u,d,p,_,f,h,m,y=this;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return o=_get(_getPrototypeOf(l.prototype),"internalPublish",this).call(this,t,r),a=o.videoDescriptions,s=o.subVideoDescriptions,c=o.transceiverInit,t.audioTransceiver=this._peerConnection.addTransceiver(c.aTrack,c.audioTransceiverInit),t.videoTransceiver=this._peerConnection.addTransceiver(c.vTrack,c.videoTransceiverInit),u=getServerNow(),monitor.rtcBeginCreateOffer(RtcbegincreateofferDirection.UP,"",""),e.next=7,this._peerConnection.createOffer();case 7:return d=e.sent,monitor.rtcCreateOffer(0,RtccreateofferDirection.UP,"","",getServerNow()-u),(p=lib.parse(d.sdp)).media=null===(n=p.media)||void 0===n?void 0:n.map((function(e){return _objectSpread2(_objectSpread2({},e),y._offerIce)})),e.next=13,this.setLocalDescription(lib.write(p));case 13:return _=t.audioTransceiver.mid,f=t.videoTransceiver.mid,h=null,m=null,p.media=null===(i=p.media)||void 0===i?void 0:i.map((function(e){if("".concat(e.mid)===_){var t,r=null===(t=h=e)||void 0===t?void 0:t.rtp.find((function(e){return"opus"===e.codec}));if(r&&h.fmtp){var n=h.fmtp.find((function(e){return e.payload===r.payload}));n&&y._context&&(n.config+=y._context.audioProfileManager.getOpusConfigStr())}}else"".concat(e.mid)===f&&(m=e);return e})),this.addBitrateLimit(m,t.videoEncodeConfig[0].maxKbps),e.next=21,this.setLocalDescription(lib.write(p));case 21:return e.abrupt("return",{partialSdp:getLocalPartialSdp(p,h,m),audioMid:_,videoMid:f,type:"incroffer",semantics:"unified-plan",videoDescriptions:a,subVideoDescriptions:s,transceiverInit:c});case 22:case"end":return e.stop()}}),e,this)}))),function(e,t){return s.apply(this,arguments)})},{key:"subscribe",value:(a=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){var r,n,i,o,a,s,c,u,l,d,p,_,f,h,m=this;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(logger$a.print("subscribe()"),!t.audioMid||!t.videoMid){e.next=11;break}return a=lib.parse(null===(i=this._peerConnection.localDescription)||void 0===i?void 0:i.sdp),s=null,c=null,a.media.forEach((function(e){"".concat(e.mid)===t.audioMid?(s=e,t.autosubAudioMid&&(s.mid=t.autosubAudioMid)):"".concat(e.mid)===t.videoMid&&(c=e,t.autosubVideoMid&&(c.mid=t.autosubVideoMid))})),e.next=8,this._peerConnection.createOffer();case 8:return e.next=10,this.setLocalDescription(null===(o=this._peerConnection.localDescription)||void 0===o?void 0:o.sdp,{streamId:t.streamId||"",streamUserId:t.userId});case 10:return e.abrupt("return",{partialSdp:getLocalPartialSdp(a,s,c),audioMid:t.audioMid,videoMid:t.videoMid,autosubAudioMid:t.autosubAudioMid,autosubVideoMid:t.autosubVideoMid,type:"incroffer",semantics:"unified-plan"});case 11:return t.audioTransceiver=this._peerConnection.addTransceiver("audio",{direction:"recvonly"}),t.videoTransceiver=this._peerConnection.addTransceiver("video",{direction:"recvonly"}),u=getServerNow(),monitor.rtcBeginCreateOffer(RtcbegincreateofferDirection.UP,t.streamId,t.userId),e.next=17,this._peerConnection.createOffer();case 17:return l=e.sent,monitor.rtcCreateOffer(0,RtccreateofferDirection.UP,t.streamId,t.userId,getServerNow()-u),(d=lib.parse(l.sdp)).media=null===(r=d.media)||void 0===r?void 0:r.map((function(e){return _objectSpread2(_objectSpread2({},e),m._offerIce)})),e.next=23,this.setLocalDescription(lib.write(d),{streamId:t.streamId||"",streamUserId:t.userId});case 23:return p=t.audioTransceiver.mid,_=t.videoTransceiver.mid,f=null,h=null,null===(n=d.media)||void 0===n||n.forEach((function(e){"".concat(e.mid)===p?f=e:"".concat(e.mid)===_&&(h=e)})),e.abrupt("return",{partialSdp:getLocalPartialSdp(d,f,h),audioMid:p,videoMid:_,type:"incroffer",semantics:"unified-plan"});case 29:case"end":return e.stop()}}),e,this)}))),function(e){return a.apply(this,arguments)})},{key:"handleAck",value:(o=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){var r,n,i,o,a,s,c,u,l,d=this;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(i=t.signalingAck,o=t.stream,(a=t.action)!==SdpAction.unpublish&&a!==SdpAction.unsubscribe&&a!==SdpAction.removetrack){e.next=5;break}return e.next=4,this.close(o.streamId,o);case 4:return e.abrupt("return",o.streamId);case 5:return s={},(c=lib.parse(null===(r=this._peerConnection.remoteDescription)||void 0===r?void 0:r.sdp)).media.forEach((function(e){void 0!==e.mid&&(s[e.mid]=e)})),lib.parse(null==i?void 0:i.sdp).media.forEach((function(e){"audio"===(e=_objectSpread2(_objectSpread2({},e),d._answerIce)).type&&(o.audioMid?(e.mid=o.audioMid,s[o.audioMid]=e):s[e.mid]=e),"video"===e.type&&(o.videoMid?(e.mid=o.videoMid,s[o.videoMid]=e):s[e.mid]=e)})),u=lib.parse(null===(n=this._peerConnection.localDescription)||void 0===n?void 0:n.sdp),l=u.media.map((function(e){var t=s[e.mid];return"inactive"===e.direction?e:t})),c.groups=u.groups,c.media=l,this.setRemoteDescription(lib.write(c)),e.abrupt("return","");case 16:case"end":return e.stop()}}),e,this)}))),function(e){return o.apply(this,arguments)})},{key:"getDefaultSdp",value:(i=_asyncToGenerator(_regeneratorRuntime().mark((function e(){var t,r,n;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=lib.parse(null===(t=this._peerConnection.localDescription)||void 0===t?void 0:t.sdp),n=[],r.media=r.media.filter((function(e){return"recvonly"===e.direction&&(n.push(e.mid+""),!0)})),r.groups=[{mids:n.join(" "),type:"BUNDLE"}],e.abrupt("return",{sdp:lib.write(r),semantics:"unified-plan",type:"offer"});case 5:case"end":return e.stop()}}),e,this)}))),function(){return i.apply(this,arguments)})},{key:"rollback",value:(n=_asyncToGenerator(_regeneratorRuntime().mark((function e(t,r){return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.close(t,r));case 1:case"end":return e.stop()}}),e,this)}))),function(e,t){return n.apply(this,arguments)})},{key:"close",value:(r=_asyncToGenerator(_regeneratorRuntime().mark((function e(t,r){var n,i,o,a,s,c,u=this;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(logger$a.print("close()"),!r.audioTransceiver||!r.videoTransceiver){e.next=19;break}return r.audioTransceiver.stop(),r.videoTransceiver.stop(),i=[],e.next=7,this._peerConnection.createOffer();case 7:return o=e.sent,(a=lib.parse(null==o?void 0:o.sdp)).media=a.media.map((function(e){return"".concat(e.mid)!==r.audioMid&&"".concat(e.mid)!==r.videoMid||(e=closeMline(e)),"inactive"!==e.direction&&i.push(e.mid),_objectSpread2(_objectSpread2({},e),u._offerIce)})),s=lib.parse(null===(n=this._peerConnection.remoteDescription)||void 0===n?void 0:n.sdp),c={},s.media.forEach((function(e){c[e.mid]=e})),s.media=a.media.map((function(e){return"inactive"===e.direction?e:c[e.mid]})),a.groups&&s.groups&&(a.groups[0].mids=i.join(" "),s.groups[0].mids=i.join(" ")),e.next=17,this.setLocalDescription(lib.write(a));case 17:return e.next=19,this.setRemoteDescription(lib.write(s));case 19:case"end":return e.stop()}}),e,this)}))),function(e,t){return r.apply(this,arguments)})},{key:"setCurrentDescription",value:(t=_asyncToGenerator(_regeneratorRuntime().mark((function e(){return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._peerConnection.createOffer();case 2:if(!this._peerConnection.localDescription||!this._peerConnection.remoteDescription){e.next=7;break}return e.next=5,this._peerConnection.setLocalDescription(this._peerConnection.localDescription);case 5:return e.next=7,this._peerConnection.setRemoteDescription(this._peerConnection.remoteDescription);case 7:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})}]),l}(),createHandler=function(e,t){return isFirefox?new FirefoxHandler(e,t):new ChromeHandler(e,t)},logger$9=new Logger("Locker",2),lockId=1,PromiseLock=function(){function e(t){_classCallCheck(this,e),_defineProperty(this,"lockingPromise",Promise.resolve()),_defineProperty(this,"locks",0),_defineProperty(this,"name",""),_defineProperty(this,"lockId",void 0),this.lockId=lockId++,t&&(this.name=t),logger$9.print("[lock-".concat(this.name,"-").concat(this.lockId,"] is created."))}return _createClass(e,[{key:"isLocked",get:function(){return this.locks>0}},{key:"lock",value:function(){var e,t=this;this.locks+=1,logger$9.print("[lock-".concat(this.name,"-").concat(this.lockId,"] locked, current queue ").concat(this.locks,"."));var r=new Promise((function(r){e=function(){t.locks-=1,logger$9.print("[lock-".concat(t.name,"-").concat(t.lockId,"] unlocked, current queue ").concat(t.locks,".")),r()}})),n=this.lockingPromise.then((function(){return e}));return this.lockingPromise=this.lockingPromise.then((function(){return r})),n}}]),e}(),RoomProfileMap=(_defineProperty(_RoomProfileMap={},RoomProfileType.communication,[0]),_defineProperty(_RoomProfileMap,RoomProfileType.chat,[0]),_defineProperty(_RoomProfileMap,RoomProfileType.chatRoom,[1,"IES_chatroom"]),_defineProperty(_RoomProfileMap,RoomProfileType.coHost,[1,"IES_PK"]),_defineProperty(_RoomProfileMap,RoomProfileType.meeting,[16]),_defineProperty(_RoomProfileMap,RoomProfileType.classRoom,[0]),_RoomProfileMap),__defProp$2=Object.defineProperty,__getOwnPropDesc$2=Object.getOwnPropertyDescriptor,__decorateClass$2=function(e,t,r,n){for(var i,o=n>1?void 0:n?__getOwnPropDesc$2(t,r):t,a=e.length-1;a>=0;a--)(i=e[a])&&(o=(n?i(t,r,o):i(o))||o);return n&&o&&__defProp$2(t,r,o),o},logger$8=new Logger("MediaServerClient",2),WAIT_TRACK_TIMEOUT=6e4,MediaConnectionState=function(e){return e.DISCONNECTED="disconnected",e.DISCONNECTING="disconnecting",e.CONNECTED="connected",e.CONNECTING="connecting",e}(MediaConnectionState||{}),logRemoteStream=function(e,t){logger$8.print(e,"userId: %o, subAudio: %o, subVideo: %o, paused: %o, audioMid: %o, videoMid: %o, workaround_1_: %o, sequenceId: %o",t.userId,t.subAudio,t.subVideo,t.paused,t.audioMid,t.videoMid,t._workaround_1_,t.sequenceId)},MediaServerClient=function(e){_inherits(g,EnhancedEventEmitter);var t,r,n,i,o,a,s,c,u,l,d,p,_,f,h,m,y,v,S=_createSuper(g);function g(e){var t,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:monitor;return _classCallCheck(this,g),_defineProperty(_assertThisInitialized(t=S.call(this)),"_token",void 0),_defineProperty(_assertThisInitialized(t),"_appId",void 0),_defineProperty(_assertThisInitialized(t),"_roomId",void 0),_defineProperty(_assertThisInitialized(t),"_roomAttributes",void 0),_defineProperty(_assertThisInitialized(t),"_clientId",void 0),_defineProperty(_assertThisInitialized(t),"_businessId",void 0),_defineProperty(_assertThisInitialized(t),"_userInfo",void 0),_defineProperty(_assertThisInitialized(t),"_useCloudProxy",void 0),_defineProperty(_assertThisInitialized(t),"_authorization",void 0),_defineProperty(_assertThisInitialized(t),"_sessionId",void 0),_defineProperty(_assertThisInitialized(t),"_iceConfigRequestManager",void 0),_defineProperty(_assertThisInitialized(t),"_ontrackCallbackMap",new Map),_defineProperty(_assertThisInitialized(t),"_subResolves",{}),_defineProperty(_assertThisInitialized(t),"supportConcurrent",!1),_defineProperty(_assertThisInitialized(t),"_handler",void 0),_defineProperty(_assertThisInitialized(t),"_pubSubLock",void 0),_defineProperty(_assertThisInitialized(t),"_joinLeaveLock",void 0),_defineProperty(_assertThisInitialized(t),"_state",void 0),_defineProperty(_assertThisInitialized(t),"_dataChannelSignal",void 0),_defineProperty(_assertThisInitialized(t),"_pubConfig",{}),_defineProperty(_assertThisInitialized(t),"_subConfig",{}),_defineProperty(_assertThisInitialized(t),"monitor",void 0),_defineProperty(_assertThisInitialized(t),"_roomProfile",RoomProfileType.communication),_defineProperty(_assertThisInitialized(t),"_context",void 0),_defineProperty(_assertThisInitialized(t),"_subStreamQueue",{}),t.monitor=r,t._pubSubLock=new PromiseLock("pubSubLock"),t._joinLeaveLock=new PromiseLock("joinLeaveLock"),t._state="disconnected",t._roomAttributes={multiChatMode:!1,bigRoomMode:!1},t._context=e,t.on("SUB_END",(function(e){return t._handleSubStreamQueue(e)})),t}return _createClass(g,[{key:"_addHandlerEvents",value:function(){var e,t=this;null===(e=this._handler)||void 0===e||e.once("disconnect",(function(){logger$8.print("emit ABNORMAL_DISCONNECTION ice"),t.safeEmit(StateEvent.ABNORMAL_DISCONNECTION)}))}},{key:"_addSignalEventHandler",value:function(){var e,t=this;[SignalEvent.ON_ADD_STREAM,SignalEvent.ON_REMOVE_STREAM,SignalEvent.USER_CONNECTION,SignalEvent.USER_DISCONNECTION,SignalEvent.ON_UPDATE_STREAM_ATTRIBUTES,SignalEvent.ON_UPDATE_ROOM_ATTRIBUTES,SignalEvent.ON_PUSH_TRACK,SignalEvent.ON_REMOVE_TRACK,SignalEvent.NODE_CHANGE,SignalEvent.ON_CUSTOM_MESSAGE,SignalEvent.USER_MESSAGE_RECEIVED,SignalEvent.USER_BINARY_MESSAGE_RECEIVED,SignalEvent.POST_PROCESSING_MESSAGE,SignalEvent.ON_USER_TOKEN_WILL_EXPIRE,SignalEvent.STREAM_CONTROL_MESSAGE,SignalEvent.ON_SCENE_CONFIG,SignalEvent.ON_UPDATE_USER_ATTRIBUTES,MediaServerSignalEvent.RSCP,SignalEvent.ON_STREAM_FAILED].forEach((function(e){var r;null===(r=t._dataChannelSignal)||void 0===r||r.on(e,(function(r){t.safeEmit(e,r)}))})),null===(e=this._dataChannelSignal)||void 0===e||e.once("close",(function(){logger$8.print("emit ABNORMAL_DISCONNECTION datachannel"),t.safeEmit(StateEvent.ABNORMAL_DISCONNECTION)}))}},{key:"_removeSignalEventHandler",value:function(){var e,t;null===(e=this._dataChannelSignal)||void 0===e||e.removeAllListeners(),null===(t=this._handler)||void 0===t||t.removeAllListeners()}},{key:"connectionState",get:function(){return this._state},set:function(e){this._state!==e&&(this.safeEmit(StateEvent.ON_CONNECTION_STATE_CHANGE,{prev:this._state,next:e}),this._state=e)}},{key:"connect",value:(v=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){var r,n,i,o,a,s,c,u,l=this,d=arguments;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=d.length>1&&void 0!==d[1]?d[1]:"",n=d.length>2&&void 0!==d[2]?d[2]:"",i=d.length>3&&void 0!==d[3]?d[3]:{},this.connectionState="connecting",this._appId=t,this._handler&&(this._removeSignalEventHandler(),this._handler.destroy()),!i.node){e.next=11;break}o=[i.node],reportRtcInvokeStatus("es.join.nodeChange",i),e.next=20;break;case 11:return Promise.resolve().then((function(){return l.emit("onGetIceConfigHook")})),this._iceConfigRequestManager=new IceConfigRequestManager,e.next=15,null===(a=this._iceConfigRequestManager)||void 0===a?void 0:a.getAccessNode(t,r,n,sdkCache.getDeviceId(),null==i?void 0:i.reason,null==i?void 0:i.feedbackNode,this._useCloudProxy);case 15:if(o=e.sent){e.next=19;break}throw reportRtcInvokeStatus("es.join.getNodeFailed",""),new SDKError(ErrorCode.ICE_SERVER_WRONG,"get ICE config failed");case 19:reportRtcInvokeStatus("es.join.getNodeSuccess",o);case 20:return this._addHandlerEvents(),Promise.resolve().then((function(){return l.emit("onEstablishConnectionHook")})),e.prev=22,c=!1,u=o.map((function(e){var t=createHandler(l.monitor,l._context);return t.connect(e).then((function(r){c?t.destroy():(c=!0,s=r,l.safeEmit("prevIceNode",e),l._handler=t,l.supportConcurrent="chrome"===t.name,l._addHandlerEvents())})).catch((function(){t.destroy()}))})),e.next=27,promiseAny(u);case 27:logger$8.print("join","establish peerConnection success"),e.next=34;break;case 30:throw e.prev=30,e.t0=e.catch(22),this.connectionState="disconnected",new SDKError(ErrorCode.ESTABLISH_DATACHANNEL_FAILED,"establish dataChannel failed",e.t0);case 34:if(!s){e.next=40;break}this._dataChannelSignal=new DataChannelSignaling(s),this._addSignalEventHandler(),this._dataChannelSignal.sendPingSignaling(),e.next=42;break;case 40:throw this.connectionState="disconnected",new SDKError(ErrorCode.ESTABLISH_DATACHANNEL_FAILED,"establish dataChannel failed");case 42:case"end":return e.stop()}}),e,this,[[22,30]])}))),function(e){return v.apply(this,arguments)})},{key:"join",value:(y=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){var r,n,i,o,a,s,c,u,l,d,p,_,f,h,m,y,v=this,S=arguments;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=S.length>1&&void 0!==S[1]?S[1]:{},i=S.length>2&&void 0!==S[2]&&S[2],o=S.length>3?S[3]:void 0,logger$8.print("join()","info: %o, params: %o, reconnect: %o, controlMessage: %o",t,n,i,o),this._appId=t.appId,this._token=t.token,this._roomId=t.roomId,this._clientId=t.userInfo.userId,this._businessId=t.userInfo.businessId,this._userInfo=t.userInfo,this._useCloudProxy=t.useCloudProxy,this._roomProfile=t.roomProfile,this._sessionId=n.sessionId,e.next=15,this.connect(this._appId,this._roomId,this._clientId,n);case 15:return e.t0=Utils.token2auth(this._appId,this._roomId,this._clientId,this._token),e.t1=this._sessionId||"",e.t2=Date.now(),e.t3=o,e.t4={extra_info:this._userInfo.extraInfo,role:this._userInfo.role},e.next=22,null===(r=this._handler)||void 0===r?void 0:r.getDefaultSdp();case 22:return e.t5=e.sent,e.next=25,internalGetSupportedCodecs();case 25:return e.t6=e.sent,e.t7=window.navigator.userAgent,e.t8=Config.VERSION,e.t9=sdkCache.getDeviceId(),e.t10=this._appId,e.t11=this._roomId,e.t12=this._clientId,e.t13=this._businessId,e.t14=this._useCloudProxy,e.t15=RoomProfileMap[this._roomProfile]?RoomProfileMap[this._roomProfile][0]+"":"0",e.t16={supportedCodecs:e.t6,deviceType:"web",userAgent:e.t7,sdkVersion:e.t8,deviceId:e.t9,appId:e.t10,roomId:e.t11,userId:e.t12,businessId:e.t13,enable_cloud_proxy:e.t14,channelProfile:e.t15},e.t17={supportTokenExpireCallBack:!0,enableSceneConfigV2:!0,enableUnBundleMode:!0},a={Authorization:e.t0,sessionId:e.t1,timestamp:e.t2,controlMessage:e.t3,userAttributes:e.t4,sdpInfo:e.t5,params:e.t16,options:e.t17},Promise.resolve().then((function(){return v.emit("onSendingJoinMessageHook")})),e.prev=39,m=i?"reconnected":"joinRoom",e.next=43,this._dataChannelSignal.sendSignaling(m,a);case 43:return y=e.sent,logger$8.print("join","send join message success"),this._authorization=a.Authorization,this.connectionState="connected",RemoteStatsReport.audioStallConfig=null===(s=y.config)||void 0===s?void 0:s.engine_WEB,this._pubConfig.audioRed=!(null===(c=y.config)||void 0===c||null===(u=c.engine_WEB)||void 0===u||!u.pub_audio_red),this._subConfig.muteReplaceUnsub=!(null===(l=y.config)||void 0===l||!l.mute_replace_unsub),this._pubConfig.simulcastOnDemand=!(!1===(null===(d=y.config)||void 0===d||null===(p=d.engine_VPM)||void 0===p||null===(_=p.ondemand)||void 0===_?void 0:_.enable)),null===(f=this._context)||void 0===f||f.audioProfileManager.updateEngineBAC(null===(h=y.config)||void 0===h?void 0:h.engine_BAC),e.abrupt("return",y);case 55:if(e.prev=55,e.t18=e.catch(39),this.connectionState="disconnected",!((null===e.t18||void 0===e.t18?void 0:e.t18.code)>=700&&(null===e.t18||void 0===e.t18?void 0:e.t18.code)<800)){e.next=60;break}throw new SDKError(ErrorCode.INVALID_TOKEN,(null===e.t18||void 0===e.t18?void 0:e.t18.message)||"Invalid token");case 60:if(200===(null===e.t18||void 0===e.t18?void 0:e.t18.code)){e.next=62;break}throw new SDKError(ErrorCode.JOIN_ROOM_FAILED,(null===e.t18||void 0===e.t18?void 0:e.t18.message)||"Join room failed");case 62:case"end":return e.stop()}}),e,this,[[39,55]])}))),function(e){return y.apply(this,arguments)})},{key:"publish",value:(m=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){var r,n,i,o,a,s,c,u,l,d,p,_,f,h,m,y,v,S;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return logger$8.print("publish()","localStream: %o",t),r=t.videoTrack,n=t.audioTrack,i=getServerNow(),o="",a="",e.prev=6,e.next=9,null===(s=this._handler)||void 0===s?void 0:s.publish(t,this._pubConfig);case 9:if(m=e.sent){e.next=12;break}throw new SDKError(ErrorCode.ADD_TRANSCEIVER_FAILED,"add transceiver failed");case 12:return o=m.audioMid,a=m.videoMid,t.pubAttributes={localaudio:!!n,localvideo:!!r,videostream:t.pubVideo,audiostream:t.pubAudio,extvideo:!!(r instanceof CustomVideoLocalTrack),extaudio:!!(n instanceof CustomAudioLocalTrack)},y={attributes:_objectSpread2({videoDescriptions:m.videoDescriptions},t.pubAttributes),audio:!0,video:!0,screen:t.isScreen,audioMid:o,videoMid:a,sdpInfo:{msid:t.stream.id,type:m.type,sdp:m.partialSdp,semantics:m.semantics}},t.enableSimulcast&&this._pubConfig.simulcastOnDemand&&(y.attributes.subVideoDescriptions=m.subVideoDescriptions),e.next=19,null===(c=this._dataChannelSignal)||void 0===c?void 0:c.sendSignaling("publish",y);case 19:if(200===(null==(v=e.sent)?void 0:v.code)){e.next=22;break}throw new SDKError(ErrorCode.PUBLISH_FAILED,(null==v?void 0:v.message)||"publish failed");case 22:return monitor.rtcRecvAnswer(0,RtcrecvanswerAnswerType.INCRANSWER,(null==v||null===(u=v.relayMessage)||void 0===u?void 0:u.sequenceId)||0,null==v||null===(l=v.relayMessage)||void 0===l?void 0:l.sdp,RtcrecvanswerDirection.UP,"",""),e.next=25,null===(d=this._handler)||void 0===d?void 0:d.handleAck({action:SdpAction.publish,streamId:v.streamId,audioMid:o,videoMid:a,transceiverInit:m.transceiverInit,signalingAck:{audioMid:null==v||null===(p=v.relayMessage)||void 0===p?void 0:p.audioMid,videoMid:null==v||null===(_=v.relayMessage)||void 0===_?void 0:_.videoMid,sdp:null==v||null===(f=v.relayMessage)||void 0===f?void 0:f.sdp,sequenceId:null==v||null===(h=v.relayMessage)||void 0===h?void 0:h.sequenceId},stream:t});case 25:return t.streamId=v.streamId,t.videoMid=a,t.audioMid=o,t.subVideoDescriptions=m.subVideoDescriptions,this.monitor.rtcPublishStat(RtcpublishstatResult.SUCCESS,RtcpublishstatIsScreen.W_0,i,RtcpublishstatMessage.UNKNOWN),t.statsReport.setLocalStreamStatsEvtInterval(this,this._handler,this.monitor),e.abrupt("return");case 34:return e.prev=34,e.t0=e.catch(6),e.t0 instanceof Error&&this.monitor.rtcPublishStat(RtcpublishstatResult.FAIL,RtcpublishstatIsScreen.W_0,i,e.t0.message),e.next=39,null===(S=this._handler)||void 0===S?void 0:S.rollback(t.stream.id,t);case 39:throw e.t0;case 40:case"end":return e.stop()}}),e,this,[[6,34]])}))),function(e){return m.apply(this,arguments)})},{key:"updatePubTrack",value:(h=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){var r,n,i,o,a,s,c,u,l,d,p,_,f,h,m,y,v,S,g,E,T,b,R,I,$,A,C,O,P,k,w,N;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:for(logger$8.print("updatePubTrack()","localStream: %o",t),i=t.videoTrack,o=t.audioTrack,a=t.pubAudio,s=t.pubVideo,c=null==o?void 0:o.getTrack(),u=null==i?void 0:i.getTrack(),s&&u?null===(l=t.videoTransceiver)||void 0===l||l.sender.replaceTrack(u):null===(d=t.videoTransceiver)||void 0===d||d.sender.replaceTrack(null),null===(r=this._handler)||void 0===r||r.updateScaleResolutionDownBy(t),a&&c?(_=o.mixType,f=o.mixedAudioTrack,h=o.gainAudioTrack,f&&_!==AudioMixingType.PLAYOUT&&!0===c.enabled?c=f:h&&"safari"!==getBrowser()&&(c=h),null===(p=t.audioTransceiver)||void 0===p||p.sender.replaceTrack(c)):null===(m=t.audioTransceiver)||void 0===m||m.sender.replaceTrack(null),y={localaudio:!!o,localvideo:!!i,videostream:s,audiostream:a,extvideo:!!(i instanceof CustomVideoLocalTrack),extaudio:!!(o instanceof CustomAudioLocalTrack)},v={},S=0,g=Object.entries(y);S<g.length;S++)E=_slicedToArray(g[S],2),T=E[0],(b=E[1])!==Reflect.get(t.pubAttributes,T)&&Reflect.set(v,T,b);if(Object.keys(v).length){e.next=12;break}return e.abrupt("return");case 12:return t.observer&&(R=t.observer,I=v.audiostream,$=v.videostream,A=v.localaudio,C=v.localvideo,O=v.extaudio,P=v.extvideo,void 0!==C?void 0!==P?R.setPushVideo(P):R.setEnableVideo(C):void 0!==$&&R.setUnmuteVideo($),void 0!==A?void 0!==O?R.setPushAudio(O):R.setEnableAudio(A):void 0!==I&&R.setUnmuteAudio(I)),t.pubAttributes=y,k={roomId:this._roomId,streamId:t.streamId,attributes:v},e.next=17,null===(n=this._dataChannelSignal)||void 0===n?void 0:n.sendSignaling("updateStreamAttributes",k);case 17:if(200===(null==(w=e.sent)?void 0:w.code)){e.next=20;break}throw new SDKError(ErrorCode.UPDATE_TRACK_FAILED,(null==w?void 0:w.message)||"update track failed");case 20:if(!isFirefox){e.next=23;break}return e.next=23,null===(N=this._handler)||void 0===N?void 0:N.setCurrentDescription();case 23:case"end":return e.stop()}}),e,this)}))),function(e){return h.apply(this,arguments)})},{key:"updateToken",value:(f=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){var r,n,i,o,a;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(logger$8.print("updateToken()","newToken: %o",t),this._token=t,this._appId&&null!==(r=this._userInfo)&&void 0!==r&&r.userId&&this._roomId){e.next=4;break}return e.abrupt("return");case 4:return i={roomId:this._roomId,userId:null===(n=this._userInfo)||void 0===n?void 0:n.userId,appId:this._appId,token:"Bearer ".concat(t)},e.prev=5,e.next=8,null===(o=this._dataChannelSignal)||void 0===o?void 0:o.sendSignaling("updateToken",i);case 8:if(200===(null==(a=e.sent)?void 0:a.code)){e.next=11;break}throw new SDKError(ErrorCode.UPDATE_TOKEN_WITH_INVALID_TOKEN,"invoke updateToken with an invalid token");case 11:e.next=16;break;case 13:throw e.prev=13,e.t0=e.catch(5),new SDKError(ErrorCode.UPDATE_TOKEN_WITH_INVALID_TOKEN,"invoke updateToken with an invalid token");case 16:case"end":return e.stop()}}),e,this,[[5,13]])}))),function(e){return f.apply(this,arguments)})},{key:"unpublish",value:(_=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){var r,n,i;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return logger$8.print("unpublish()","localStream: %o",t),i={roomId:this._roomId,initStreamId:t.initStreamId,streamId:t.streamId},null===(r=this._dataChannelSignal)||void 0===r||r.sendSignaling("unpublish",i),e.next=5,null===(n=this._handler)||void 0===n?void 0:n.handleAck({action:SdpAction.unpublish,audioMid:t.audioMid,videoMid:t.videoMid,stream:t,streamId:t.streamId});case 5:t.statsReport.unpublish();case 6:case"end":return e.stop()}}),e,this)}))),function(e){return _.apply(this,arguments)})},{key:"subscribe",value:(p=_asyncToGenerator(_regeneratorRuntime().mark((function e(t,r,n){var i=this;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",new Promise(function(){var e=_asyncToGenerator(_regeneratorRuntime().mark((function e(o,a){var s,c,u,l,d,p,_,f,h,m,y,v,S,g,E,T,b,R,I,$,A,C,O,P,k,w,N,D,M,x,L,U,F,B,V,j,G,H;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t.streamState!==StreamState.SUB_ED){e.next=2;break}return e.abrupt("return",i._updateSubTrack(t,r,SubState.SUB,n).then(o,a));case 2:if(t.streamState!==StreamState.SUB_ING){e.next=7;break}return i._subStreamQueue[t.streamId]||(i._subStreamQueue[t.streamId]=[]),logger$8.print("_subStreamQueue","streamId: %o, enqueue",t.streamId),i._subStreamQueue[t.streamId].push({fn:i.subscribe,args:[t,r,n],resolve:o,reject:a}),e.abrupt("return");case 7:if(logger$8.print("subscribe()","mediaType: %o",r),logRemoteStream("subscribe()",t),t.streamState=StreamState.SUB_ING,s=!1,c=!1,audioInMediaType(r)&&(c=!0),videoInMediaType(r)&&(s=!0),s||!i._multiChatMode()){e.next=17;break}return t.streamState=StreamState.INIT,i.emit("SUB_END",t.streamId),e.abrupt("return",o(null));case 17:if(u=getServerNow(),l=t.audioMid,d=t.videoMid,_=t.paused,f=t.subVideo,e.prev=22,!l||!d){e.next=29;break}return e.next=26,null===(k=i._handler)||void 0===k?void 0:k.subscribe(t,{audioMid:l,videoMid:d});case 26:p=e.sent,e.next=36;break;case 29:return e.next=31,null===(w=i._handler)||void 0===w?void 0:w.subscribe(t);case 31:if(p=e.sent){e.next=34;break}throw new SDKError(ErrorCode.ADD_TRANSCEIVER_FAILED,"add transceiver failed");case 34:l=p.audioMid,d=p.videoMid;case 36:return t.paused=!s,t.subVideo=s,N={spatialLayer:(null==n?void 0:n.spatialLayer)||0,temporalLayer:0,spatialSubLayer:(null==n?void 0:n.spatialSubLayer)||-1},D={audio:!i._multiChatMode(),video:!0,data:!0,screen:t.isScreen,browser:"chrome-stable",videoMid:(null===(h=p)||void 0===h?void 0:h.autosubVideoMid)||d,audioMid:(null===(m=p)||void 0===m?void 0:m.autosubAudioMid)||l,sdpInfo:{sdp:null===(y=p)||void 0===y?void 0:y.partialSdp,semantics:null===(v=p)||void 0===v?void 0:v.semantics,type:null===(S=p)||void 0===S?void 0:S.type},streamUserId:t.userId,streamId:t.streamId,config:{enableMediaType:{audio:!!i._multiChatMode()||c,video:s},qualityLayer:N}},e.next=42,null===(g=i._dataChannelSignal)||void 0===g?void 0:g.sendSignaling("subscribe",D);case 42:if(200===(null==(M=e.sent)?void 0:M.code)){e.next=45;break}throw new SDKError(ErrorCode.SUBSCRIBE_FAILED,(null==M?void 0:M.message)||"subscribe failed");case 45:return x=[],L=!i._multiChatMode(),U=!t.videoTrack,i._subResolves[t.streamId]||(i._subResolves[t.streamId]=[]),U&&x.push(new Promise((function(e,r){i._subResolves[t.streamId].push(e);var n=setTimeout((function(){return r(new SDKError(ErrorCode.TIME_OUT,"wait video timeout for userId: ".concat(t.userId)))}),WAIT_TRACK_TIMEOUT);t.on("ontrack",(function r(i){"video"===i.mediaType&&(logger$8.print("remoteStream ".concat(t.userId," received video track")),t.off("ontrack",r),clearTimeout(n),e(0))}))}))),L&&x.push(new Promise((function(e,r){i._subResolves[t.streamId].push(e);var n=setTimeout((function(){return r(new SDKError(ErrorCode.TIME_OUT,"wait audio timeout for userId: ".concat(t.userId)))}),WAIT_TRACK_TIMEOUT);t.on("ontrack",(function r(i){"audio"===i.mediaType&&(logger$8.print("remoteStream ".concat(t.userId," received audio track")),t.off("ontrack",r),clearTimeout(n),e(0))}))}))),F=function(e){t.ontrack(e)},null===(E=i._handler)||void 0===E||E.on("ontrack",F),i._ontrackCallbackMap.set(t,F),B=null==M?void 0:M.relayMessage,V=B.audioMid,j=B.videoMid,_defineProperty(T={},l,V),_defineProperty(T,d,j),G=T,logger$8.print("sub midmap",t.userId,G),isFirefox?(t.videoMid=d,t.audioMid=l):(t.videoMid=j,t.audioMid=V),t._workaround_1_=!1,t.subMediaType=r,t.streamState=StreamState.SUB_ED,t.subLayer=N,monitor.rtcRecvAnswer(0,RtcrecvanswerAnswerType.INCRANSWER,(null==M||null===(b=M.relayMessage)||void 0===b?void 0:b.sequenceId)||0,null==M||null===(R=M.relayMessage)||void 0===R?void 0:R.sdp,RtcrecvanswerDirection.DOWN,t.streamId,t.userId),e.next=65,null===(I=i._handler)||void 0===I?void 0:I.handleAck({action:SdpAction.subscribe,streamId:t.streamId,audioMid:l,videoMid:d,transceiverInit:null===($=p)||void 0===$?void 0:$.transceiverInit,signalingAck:{audioMid:null==M||null===(A=M.relayMessage)||void 0===A?void 0:A.audioMid,videoMid:null==M||null===(C=M.relayMessage)||void 0===C?void 0:C.videoMid,sdp:null==M||null===(O=M.relayMessage)||void 0===O?void 0:O.sdp,sequenceId:null==M||null===(P=M.relayMessage)||void 0===P?void 0:P.sequenceId},stream:t});case 65:return e.next=67,Promise.all(x);case 67:i._multiChatMode()||(t.subAudio=c),i.monitor.rtcSubscribeStat(RtcsubscribestatResult.SUCCESS,u,RtcsubscribestatMessage.UNKNOWN,t.userId),t.statsReport.setRemoteStreamStatsEvtInterval(i,i._handler,i.monitor),o(null),i.emit("SUB_END",t.streamId),e.next=84;break;case 74:return e.prev=74,e.t0=e.catch(22),e.t0 instanceof Error&&i.monitor.rtcSubscribeStat(RtcsubscribestatResult.FAIL,u,e.t0.message,t.userId),t.paused=_,t.subVideo=f,t.streamState=StreamState.INIT,e.next=82,null===(H=i._handler)||void 0===H?void 0:H.rollback(t.streamId,t);case 82:a(e.t0),i.emit("SUB_END",t.streamId);case 84:case"end":return e.stop()}}),e,null,[[22,74]])})));return function(t,r){return e.apply(this,arguments)}}()));case 1:case"end":return e.stop()}}),e)}))),function(e,t,r){return p.apply(this,arguments)})},{key:"_handleSubStreamQueue",value:function(e){var t,r=this;if(null!==(t=this._subStreamQueue[e])&&void 0!==t&&t.length){logger$8.print("_subStreamQueue","streamId: %o, exec",e);var n=this._subStreamQueue[e].shift(),i=n.fn,o=n.args,a=n.resolve,s=n.reject;i.apply(this,o).then(a,s).finally((function(){return r._handleSubStreamQueue(e)}))}else logger$8.print("_subStreamQueue","streamId: %o, END",e)}},{key:"controlMessage",value:(d=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){var r,n;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return logger$8.print("controlMessage()","params: %o",t),n=t,"transcode"===t.type&&(n.roomId=this._roomId),e.next=5,null===(r=this._dataChannelSignal)||void 0===r?void 0:r.sendSignaling("controlMessage",n);case 5:case"end":return e.stop()}}),e,this)}))),function(e){return d.apply(this,arguments)})},{key:"updateUserAttributes",value:(l=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){var r;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return logger$8.print("updateUserAttributes()","attributes: %o",t),e.next=3,null===(r=this._dataChannelSignal)||void 0===r?void 0:r.sendSignaling("updateUserAttributes",{roomId:this._roomId,sessionId:this._sessionId,attributes:t});case 3:case"end":return e.stop()}}),e,this)}))),function(e){return l.apply(this,arguments)})},{key:"updateSubTrack",value:(u=_asyncToGenerator(_regeneratorRuntime().mark((function e(t,r,n,i){return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this._updateSubTrack(t,r,n,i||t.subLayer));case 1:case"end":return e.stop()}}),e,this)}))),function(e,t,r,n){return u.apply(this,arguments)})},{key:"_updateSubTrack",value:(c=_asyncToGenerator(_regeneratorRuntime().mark((function e(t,r,n,i){var o,a,s,c,u,l,d,p,_;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return logger$8.print("updateSubTrack()","mediaType: %o, subLayer: %o",r,i),logRemoteStream("updateSubTrack()",t),s=0,s=n===SubState.SUB?t.subMediaType|r:t.subMediaType-(t.subMediaType&r),logger$8.print("updateSubTrack","prev: %o, direction: %o, mediaType: %o, newMediaType: %o",t.subMediaType,n,r,s),t.subMediaType===s&&logger$8.print("updateSubTrack","mediaType no change"),c=!1,u=!1,audioInMediaType(s)&&(u=!0),videoInMediaType(s)&&(c=!0),l=i||t.subLayer,d={roomId:this._roomId,streamList:[t.streamId],config:{enableMediaType:{video:c,audio:!!this._multiChatMode()||u},qualityLayer:l}},e.next=13,null===(o=this._dataChannelSignal)||void 0===o?void 0:o.sendSignaling("updateSubscribe",d);case 13:if(200===(null==(p=e.sent)?void 0:p.code)){e.next=16;break}throw new SDKError(ErrorCode.UPDATE_TRACK_FAILED,(null==p?void 0:p.message)||"update track failed");case 16:return t.paused=!c,this._multiChatMode()||(null===(_=t.observer)||void 0===_||_.setUnmuteAudio(u),t.subAudio=u),null===(a=t.observer)||void 0===a||a.setUnmuteVideo(c),t.subVideo=c,t.subMediaType=s,t.subLayer=l,e.abrupt("return",t);case 23:case"end":return e.stop()}}),e,this)}))),function(e,t,r,n){return c.apply(this,arguments)})},{key:"subscribe4pushTrack",value:(s=_asyncToGenerator(_regeneratorRuntime().mark((function e(t,r){var n,i,o,a,s,c,u,l,d,p,_,f,h,m,y,v,S,g=this;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(logger$8.print("subscribe4pushTrack()","streamInfo: %o",r),logRemoteStream("subscribe4pushTrack()",t),c=null==r?void 0:r.message,u=c.audioMid,l=c.videoMid,d=c.sequenceId,t.subAudio=!0,!(d<t.sequenceId)){e.next=7;break}return logger$8.print("subscribe4pushTrack","sequenceId return",d,t.sequenceId),e.abrupt("return");case 7:if(p=t.audioMid,_=t.videoMid,null===(n=t.observer)||void 0===n||n.setPushTrack(!0),!p||!_){e.next=16;break}return e.next=13,null===(h=this._handler)||void 0===h?void 0:h.subscribe(t,{audioMid:p,videoMid:_});case 13:f=e.sent,e.next=23;break;case 16:return e.next=18,null===(m=this._handler)||void 0===m?void 0:m.subscribe(t);case 18:if(f=e.sent){e.next=21;break}throw new SDKError(ErrorCode.ADD_TRANSCEIVER_FAILED,"add transceiver failed");case 21:p=f.audioMid,_=f.videoMid;case 23:return _defineProperty(i={},p,u),_defineProperty(i,_,l),y=i,logger$8.print("onpushtrack midmap",t.userId,y),isFirefox?(t.audioMid=p,t.videoMid=_):(t.audioMid=u,t.videoMid=l),t.autosubAudioMid=u,t.autosubVideoMid=l,t.sequenceId=d,this._subResolves[t.streamId]||(this._subResolves[t.streamId]=[]),v=[],t.audioTrack||v.push(new Promise((function(e,r){g._subResolves[t.streamId].push(e);var n=setTimeout((function(){return r(new SDKError(ErrorCode.TIME_OUT,"wait audio timeout for userId: ".concat(t.userId)))}),WAIT_TRACK_TIMEOUT);t.on("ontrack",(function r(i){"audio"===i.mediaType&&(logger$8.print("remoteStream ".concat(t.userId," received audio track")),t.off("ontrack",r),clearTimeout(n),e(0))}))}))),S=function(e){t.ontrack(e)},null===(o=this._handler)||void 0===o||o.on("ontrack",S),this._ontrackCallbackMap.set(t,S),e.next=37,null===(a=this._handler)||void 0===a?void 0:a.handleAck({action:SdpAction.pushtrack,streamId:t.streamId,audioMid:p,videoMid:_,stream:t,transceiverInit:null===(s=f)||void 0===s?void 0:s.transceiverInit,signalingAck:null==r?void 0:r.message});case 37:return e.next=39,Promise.all(v);case 39:t.statsReport.setRemoteStreamStatsEvtInterval(this,this._handler,this.monitor);case 40:case"end":return e.stop()}}),e,this)}))),function(e,t){return s.apply(this,arguments)})},{key:"unsubscribe4removeTrack",value:(a=_asyncToGenerator(_regeneratorRuntime().mark((function e(t,r){var n,i;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(logRemoteStream("unsubscribe4removeTrack()",t),logger$8.print("unsubscribe4removeTrack()","sequenceId: ",r.sequenceId),!(r.sequenceId<t.sequenceId)){e.next=5;break}return logger$8.print("unsubscribe4removeTrack()","sequenceId return"),e.abrupt("return");case 5:if(t.subAudio=!1,!t.subVideo&&!t.paused){e.next=10;break}return t.sequenceId=r.sequenceId,logger$8.print("unsubscribe4removeTrack()","foo %o",t.userId),e.abrupt("return");case 10:return null===(n=t.observer)||void 0===n||n.setPushTrack(!1),e.next=13,null===(i=this._handler)||void 0===i?void 0:i.handleAck({action:SdpAction.removetrack,streamId:t.streamId,audioMid:t.audioMid,videoMid:t.videoMid,stream:t});case 13:this._subResolves[t.streamId]&&this._subResolves[t.streamId].forEach((function(e){return e(0)})),logger$8.print("clean unsubscribe4removeTrack"),t.clean(),t.resetHasSubscribed(),t.statsReport.unsubscribe();case 18:case"end":return e.stop()}}),e,this)}))),function(e,t){return a.apply(this,arguments)})},{key:"unsubscribe",value:(o=_asyncToGenerator(_regeneratorRuntime().mark((function e(t,r){var n,i,o,a,s,c,u,l,d=arguments;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(o=d.length>2&&void 0!==d[2]&&d[2],logRemoteStream("unsubscribe()",t),a=t.subMediaType-(t.subMediaType&r),o||!this._subConfig.muteReplaceUnsub&&a===ExtendMediaType.NONE){e.next=5;break}return e.abrupt("return",this._updateSubTrack(t,r,SubState.UNSUB));case 5:if(s={roomId:this._roomId,streamId:t.streamId,userId:t.userId},null===(n=this._dataChannelSignal)||void 0===n||n.sendSignaling("unsubscribe",s).catch((function(){})),t.streamState=StreamState.INIT,this._subStreamQueue[t.streamId]&&(this._subStreamQueue[t.streamId].forEach((function(e){return(0,e.resolve)(null)})),delete this._subStreamQueue[t.streamId]),t.subVideo=!1,t.paused=!1,t._workaround_1_||(t.subAudio=!1),null===(i=t.observer)||void 0===i||i.setSubscribeVideo(!1),t.subAudio){e.next=23;break}return null===(c=t.observer)||void 0===c||c.setSubscribeAudio(!1),e.next=17,null===(u=this._handler)||void 0===u?void 0:u.handleAck({action:SdpAction.unsubscribe,streamId:t.streamId,audioMid:t.audioMid,videoMid:t.videoMid,stream:t});case 17:l=e.sent,this._subResolves[l]&&this._subResolves[l].forEach((function(e){return e(0)})),logger$8.print("unsubscribe","clean unsub ".concat(t.userId)),t.clean(),this.removeOnTrackListener(t),t.statsReport.unsubscribe();case 23:case"end":return e.stop()}}),e,this)}))),function(e,t){return o.apply(this,arguments)})},{key:"removeOnTrackListener",value:function(e){var t,r=this._ontrackCallbackMap.get(e);r&&(null===(t=this._handler)||void 0===t||t.off("ontrack",r),this._ontrackCallbackMap.delete(e))}},{key:"handleRemoveStream",value:(i=_asyncToGenerator(_regeneratorRuntime().mark((function e(t,r){return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(logRemoteStream("handleRemoveStream()",t),t.subVideo=!1,r.message&&r.message!==RemoveStreamMessage.videoMuted?t._workaround_1_=!1:t._workaround_1_=!0,t.hasSubscribed){e.next=5;break}return e.abrupt("return");case 5:this.unsubscribe(t,MediaType.AUDIO_AND_VIDEO,!0);case 6:case"end":return e.stop()}}),e,this)}))),function(e,t){return i.apply(this,arguments)})},{key:"leave",value:(n=_asyncToGenerator(_regeneratorRuntime().mark((function e(){var t,r,n;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(logger$8.print("leave()"),"connected"!==this.connectionState){e.next=22;break}return this.connectionState="disconnecting",t={Authorization:this._authorization,roomId:this._roomId,sessionId:this._sessionId},e.next=6,this._joinLeaveLock.lock();case 6:return r=e.sent,e.prev=7,e.next=10,null===(n=this._dataChannelSignal)||void 0===n?void 0:n.sendSignaling("leaveRoom",t);case 10:this.connectionState="disconnected",e.next=17;break;case 13:throw e.prev=13,e.t0=e.catch(7),this.connectionState="connected",e.t0;case 17:return e.prev=17,r(),e.finish(17);case 20:e.next=23;break;case 22:return e.abrupt("return",Promise.reject(new SDKError(ErrorCode.NOT_CONNECTED_YET,"server not connected")));case 23:case"end":return e.stop()}}),e,this,[[7,13,17,20]])}))),function(){return n.apply(this,arguments)})},{key:"subscribePublicStream",value:(r=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){var r,n,i,o,a,s,c,u,l,d,p,_,f,h,m,y,v,S=this;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,null===(r=this._handler)||void 0===r?void 0:r.subscribe(t);case 2:if(a=e.sent){e.next=5;break}throw new SDKError(ErrorCode.ADD_TRANSCEIVER_FAILED,"add transceiver failed");case 5:return s=getServerNow(),c=a.audioMid,u=a.videoMid,l={appId:this._appId,streamId:t.streamId,audio:!0,video:!0,data:!0,audioMid:c,videoMid:u,sdpInfo:{sdp:null==a?void 0:a.partialSdp,semantics:null==a?void 0:a.semantics,type:null==a?void 0:a.type},config:{enableMediaType:{audio:!0,video:!0},qualityLayer:{spatialLayer:0,temporalLayer:0}},params:{appId:this._appId}},e.next=11,null===(n=this._dataChannelSignal)||void 0===n?void 0:n.sendSignaling("startPullStream",l);case 11:return d=e.sent,p=[],this._subResolves[t.streamId]=[],p.push(new Promise((function(e,r){S._subResolves[t.streamId].push(e);var n=setTimeout((function(){return r(new SDKError(ErrorCode.TIME_OUT,"wait video timeout for streamId: ".concat(t.streamId)))}),WAIT_TRACK_TIMEOUT);t.on("ontrack",(function r(i){"video"===i.mediaType&&(logger$8.print("remoteStream ".concat(t.userId," received video track")),t.off("ontrack",r),clearTimeout(n),e(0))}))}))),p.push(new Promise((function(e,r){S._subResolves[t.streamId].push(e);var n=setTimeout((function(){return r(new SDKError(ErrorCode.TIME_OUT,"wait audio timeout for streamId: ".concat(t.streamId)))}),WAIT_TRACK_TIMEOUT);t.on("ontrack",(function r(i){"audio"===i.mediaType&&(logger$8.print("remoteStream ".concat(t.userId," received audio track")),t.off("ontrack",r),clearTimeout(n),e(0))}))}))),_=function(e){t.ontrack(e)},null===(i=this._handler)||void 0===i||i.on("ontrack",_),this._ontrackCallbackMap.set(t,_),f=null==d?void 0:d.relayMessage,h=f.audioMid,m=f.videoMid,y=f.sequenceId,v=f.sdp,t.videoMid=m,t.audioMid=h,t.sequenceId=y,t._workaround_1_=!1,t.paused=!1,t.streamState=StreamState.SUB_ED,t.subAudio=!0,t.subVideo=!0,e.next=30,null===(o=this._handler)||void 0===o?void 0:o.handleAck({action:SdpAction.subscribe,streamId:t.streamId,audioMid:c,videoMid:u,transceiverInit:null==a?void 0:a.transceiverInit,signalingAck:{audioMid:h,videoMid:m,sdp:v,sequenceId:y},stream:t});case 30:return e.next=32,Promise.all(p);case 32:this.monitor.rtcSubscribeStat(RtcsubscribestatResult.SUCCESS,s,RtcsubscribestatMessage.UNKNOWN,t.userId),t.statsReport.setRemoteStreamStatsEvtInterval(this,this._handler,this.monitor);case 34:case"end":return e.stop()}}),e,this)}))),function(e){return r.apply(this,arguments)})},{key:"unsubscribePublicStream",value:(t=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){var r,n,i;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return logRemoteStream("unsubscribePublicStream()",t),n={appId:this._appId,streamId:t.streamId},e.prev=2,e.next=5,null===(i=this._dataChannelSignal)||void 0===i?void 0:i.sendSignaling("stopPullStream",n);case 5:e.next=9;break;case 7:e.prev=7,e.t0=e.catch(2);case 9:return t.streamState=StreamState.INIT,t.subVideo=!1,t.subAudio=!1,e.next=14,null===(r=this._handler)||void 0===r?void 0:r.handleAck({action:SdpAction.unsubscribe,streamId:t.streamId,audioMid:t.audioMid,videoMid:t.videoMid,stream:t});case 14:t.clean(),this.removeOnTrackListener(t),t.statsReport.unsubscribe();case 17:case"end":return e.stop()}}),e,this,[[2,7]])}))),function(e){return t.apply(this,arguments)})},{key:"destroy",value:function(){var e,t,r;logger$8.print("destroy()"),this._token=void 0,this._appId=void 0,this._roomId=void 0,this._clientId=void 0,this._authorization=void 0,this._sessionId=void 0,this._context=void 0,null===(e=this._handler)||void 0===e||e.destroy(),null===(t=this._dataChannelSignal)||void 0===t||t.destroy(),null===(r=this._iceConfigRequestManager)||void 0===r||r.abort(),this._handler=void 0,this._dataChannelSignal=void 0,this._iceConfigRequestManager=void 0,this._removeSignalEventHandler(),this.connectionState="disconnected",this.emit("INTERRUPT")}},{key:"sendUserMessage",value:function(e,t){var r;return null===(r=this._dataChannelSignal)||void 0===r?void 0:r.sendP2PMessage({to:e,from:this._userInfo.userId,room:this._roomId,app:this._appId,msg:t})}},{key:"sendRoomMessage",value:function(e){var t;return null===(t=this._dataChannelSignal)||void 0===t?void 0:t.sendSignaling("customMessage",e)}},{key:"_multiChatMode",value:function(){var e;return null===(e=this._roomAttributes)||void 0===e?void 0:e.multiChatMode}},{key:"handler",get:function(){return this._handler}},{key:"roomAttributes",get:function(){return this._roomAttributes},set:function(e){this._roomAttributes=e}}]),g}();function checkConnection(e,t,r){var n=r.value;return r.value=_asyncToGenerator(_regeneratorRuntime().mark((function e(){var r,i,o,a=arguments;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._handler||"connected"!==this._state){e.next=6;break}for(r=a.length,i=new Array(r),o=0;o<r;o++)i[o]=a[o];return e.next=4,n.apply(this,i);case 4:e.next=7;break;case 6:throw new SDKError(ErrorCode.NOT_CONNECTED_YET,"error in ".concat(t,": try again after joined"));case 7:case"end":return e.stop()}}),e,this)}))),r}function pubSubLock(e,t,r){var n=r.value;return r.value=_asyncToGenerator(_regeneratorRuntime().mark((function e(){var t,r,i,o,a=arguments;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._pubSubLock.lock();case 2:for(t=e.sent,this.supportConcurrent&&t(),e.prev=4,r=a.length,i=new Array(r),o=0;o<r;o++)i[o]=a[o];return e.next=8,n.apply(this,i);case 8:return e.abrupt("return",e.sent);case 9:return e.prev=9,this.supportConcurrent||t(),e.finish(9);case 12:case"end":return e.stop()}}),e,this,[[4,,9,12]])}))),r}function interrupt(e,t,r){var n=r.value;return r.value=_asyncToGenerator(_regeneratorRuntime().mark((function e(){var t,r,i,o,a=this,s=arguments;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:for(t=s.length,r=new Array(t),i=0;i<t;i++)r[i]=s[i];return o=!1,e.abrupt("return",new Promise(function(){var e=_asyncToGenerator(_regeneratorRuntime().mark((function e(t,i){var s;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return a.on("INTERRUPT",(function(){o=!0,i(new SDKError(ErrorCode.OPERATION_CANCEL,"operation not finish when leave"))})),e.prev=1,e.next=4,n.apply(a,r);case 4:s=e.sent,t(s),e.next=11;break;case 8:e.prev=8,e.t0=e.catch(1),o||i(e.t0);case 11:case"end":return e.stop()}}),e,null,[[1,8]])})));return function(t,r){return e.apply(this,arguments)}}()));case 3:case"end":return e.stop()}}),e)}))),r}__decorateClass$2([interrupt],MediaServerClient.prototype,"join",1),__decorateClass$2([pubSubLock,checkConnection],MediaServerClient.prototype,"publish",1),__decorateClass$2([pubSubLock,checkConnection],MediaServerClient.prototype,"updatePubTrack",1),__decorateClass$2([pubSubLock,checkConnection],MediaServerClient.prototype,"unpublish",1),__decorateClass$2([pubSubLock,checkConnection],MediaServerClient.prototype,"subscribe",1),__decorateClass$2([checkConnection],MediaServerClient.prototype,"controlMessage",1),__decorateClass$2([checkConnection],MediaServerClient.prototype,"updateUserAttributes",1),__decorateClass$2([checkConnection],MediaServerClient.prototype,"updateSubTrack",1),__decorateClass$2([pubSubLock,checkConnection],MediaServerClient.prototype,"subscribe4pushTrack",1),__decorateClass$2([pubSubLock,checkConnection],MediaServerClient.prototype,"unsubscribe4removeTrack",1),__decorateClass$2([pubSubLock,checkConnection],MediaServerClient.prototype,"unsubscribe",1),__decorateClass$2([checkConnection],MediaServerClient.prototype,"handleRemoveStream",1),__decorateClass$2([pubSubLock],MediaServerClient.prototype,"subscribePublicStream",1),__decorateClass$2([pubSubLock],MediaServerClient.prototype,"unsubscribePublicStream",1);var _CONFIG,RecvFrameObserver=function(){function e(t,r){_classCallCheck(this,e),_defineProperty(this,"_audioEventSessionId",genEventSessionId()),_defineProperty(this,"_videoEventSessionId",genEventSessionId()),_defineProperty(this,"_handler",void 0),_defineProperty(this,"_stream",void 0),_defineProperty(this,"_firstAudioFrameTimer",void 0),_defineProperty(this,"_firstVideoFrameTimer",void 0),_defineProperty(this,"_transportDelayInterval",void 0),_defineProperty(this,"_transportDelay",void 0),_defineProperty(this,"_firstVideoFrameInterval",void 0),_defineProperty(this,"_firstAudioFrameInterval",void 0),_defineProperty(this,"_isScreen",!1),_defineProperty(this,"_audioFirstFrameState",0),_defineProperty(this,"_videoFirstFrameState",0),_defineProperty(this,"_timeout",1e4),_defineProperty(this,"_currentAudioRecv",{startTime:0,eventSessionId:0,type:FirstframeinfoType.LOGIN}),_defineProperty(this,"_currentVideoRecv",{startTime:0,eventSessionId:0,type:FirstframeinfoType.LOGIN}),_defineProperty(this,"_login",!1),_defineProperty(this,"_unMuteAudio",!1),_defineProperty(this,"_enableAudio",!1),_defineProperty(this,"_unMuteVideo",!1),_defineProperty(this,"_enableVideo",!1),_defineProperty(this,"_remoteUnmuteAudio",!1),_defineProperty(this,"_remoteUnmuteVideo",!1),_defineProperty(this,"_audioExternal",!1),_defineProperty(this,"_pushAudio",!1),_defineProperty(this,"_videoExternal",!1),_defineProperty(this,"_pushVideo",!1),_defineProperty(this,"_autoSubscribeVideo",!1),_defineProperty(this,"_autoSubscribeAudio",!1),_defineProperty(this,"_autoSubscribe",!1),_defineProperty(this,"_publishVideo",!1),_defineProperty(this,"_publishAudio",!1),_defineProperty(this,"_subscribeAudio",!1),_defineProperty(this,"_subscribeVideo",!1),_defineProperty(this,"_subscribe",!1),_defineProperty(this,"_pushTrack",!1),_defineProperty(this,"_multiChatMode",!1),this._stream=t,this._handler=r,this.getTransportDelay()}var t,r,n,i;return _createClass(e,[{key:"beginRecvFrame",value:(i=_asyncToGenerator(_regeneratorRuntime().mark((function e(t,r){var n,i,o,a,s,c,u,l,d,p,_,f,h,m=this;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.getTransportDelay();case 2:n=this._transportDelay,i=!0,o=FirstframeinfoType.LOGIN,a=FirstframeinfoType.UNMUTE,s=FirstframeinfoType.SUBSCRIBE,c=FirstframeinfoType.PUSH_TRACK,[o,a,s,c].indexOf(r)>=0&&(n=0,i=!1),t===FirstframeinfoMediaType.AUDIO?(i||this._audioEventSessionId++,this._currentAudioRecv={startTime:Date.now(),eventSessionId:this._audioEventSessionId,type:r},d={media_type:t,event_type:FirstframeinfoEventType.BEGIN_RECV,type:r,start:null===(u=this._currentAudioRecv)||void 0===u?void 0:u.startTime,event_session_id:this._audioEventSessionId,stream_user_id:null===(l=this._stream)||void 0===l?void 0:l.userId,transport_delay:n},this._firstAudioFrameTimer&&window.clearTimeout(this._firstAudioFrameTimer),this._firstAudioFrameTimer=window.setTimeout((function(){m.stopRecvFrame(FirstframeinfoMediaType.AUDIO,FirstframeinfoReason.TIMEOUT),m._firstAudioFrameInterval&&window.clearInterval(m._firstAudioFrameInterval)}),this._timeout),monitor.rtcFirstFrame(d),this._watchForFirstAudioFrameRecv(),this._audioFirstFrameState=1,this._login=!0,this._unMuteAudio=!0,this._enableAudio=!0,this._remoteUnmuteAudio=!0):t===FirstframeinfoMediaType.VIDEO&&(i||this._videoEventSessionId++,this._currentVideoRecv={startTime:Date.now(),eventSessionId:this._videoEventSessionId,type:r},h={media_type:null!==(p=this._stream)&&void 0!==p&&p.isScreen?FirstframeinfoMediaType.SCREEN_VIDEO:t,event_type:FirstframeinfoEventType.BEGIN_RECV,type:r,start:null===(_=this._currentVideoRecv)||void 0===_?void 0:_.startTime,event_session_id:this._videoEventSessionId,stream_user_id:null===(f=this._stream)||void 0===f?void 0:f.userId,transport_delay:n},this._firstVideoFrameTimer&&window.clearTimeout(this._firstVideoFrameTimer),this._firstVideoFrameTimer=window.setTimeout((function(){m.stopRecvFrame(FirstframeinfoMediaType.VIDEO,FirstframeinfoReason.TIMEOUT),m._firstVideoFrameInterval&&window.clearInterval(m._firstVideoFrameInterval)}),this._timeout),this._watchForFirstVideoFrameRecv(),monitor.rtcFirstFrame(h),this._videoFirstFrameState=1,this._login=!0,this._unMuteVideo=!0,this._enableVideo=!0,this._remoteUnmuteVideo=!0);case 7:case"end":return e.stop()}}),e,this)}))),function(e,t){return i.apply(this,arguments)})},{key:"stopRecvFrame",value:function(e,t){if(e===FirstframeinfoMediaType.AUDIO){var r,n,i;if(1!==this._audioFirstFrameState)return;var o={event_type:FirstframeinfoEventType.RECV_END,media_type:e,start:null===(r=this._currentAudioRecv)||void 0===r?void 0:r.startTime,reason:t,result:!1,stream_user_id:null===(n=this._stream)||void 0===n?void 0:n.userId,event_session_id:this._audioEventSessionId,type:null===(i=this._currentAudioRecv)||void 0===i?void 0:i.type};this._firstAudioFrameTimer&&window.clearTimeout(this._firstAudioFrameTimer),delete this._currentAudioRecv,monitor.rtcFirstFrame(o),this._audioFirstFrameState=2}else if(e===FirstframeinfoMediaType.VIDEO){var a,s,c,u;if(1!==this._videoFirstFrameState)return;var l={event_type:FirstframeinfoEventType.RECV_END,media_type:null!==(a=this._stream)&&void 0!==a&&a.isScreen?FirstframeinfoMediaType.SCREEN_VIDEO:e,start:null===(s=this._currentVideoRecv)||void 0===s?void 0:s.startTime,reason:t,result:!1,stream_user_id:null===(c=this._stream)||void 0===c?void 0:c.userId,event_session_id:this._videoEventSessionId,type:null===(u=this._currentVideoRecv)||void 0===u?void 0:u.type};this._firstVideoFrameTimer&&window.clearTimeout(this._firstVideoFrameTimer),delete this._currentVideoRecv,monitor.rtcFirstFrame(l),this._videoFirstFrameState=2}}},{key:"recvFrameFinish",value:(n=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){var r,n,i,o,a,s,c,u,l,d,p,_,f,h,m,y;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.getTransportDelay();case 2:if(r=this._transportDelay,n=FirstframeinfoType.LOGIN,i=FirstframeinfoType.UNMUTE,o=FirstframeinfoType.SUBSCRIBE,a=FirstframeinfoType.PUSH_TRACK,t!==FirstframeinfoMediaType.AUDIO){e.next=18;break}if(1===this._audioFirstFrameState){e.next=7;break}return e.abrupt("return");case 7:if(this._currentAudioRecv){e.next=9;break}return e.abrupt("return");case 9:c=this._currentAudioRecv,u=c.type,l=c.startTime,[n,i,o,a].indexOf(u)>=0&&(r=0),d={event_type:FirstframeinfoEventType.RECV_END,media_type:t,start:l,result:!0,stream_user_id:null===(s=this._stream)||void 0===s?void 0:s.userId,event_session_id:this._audioEventSessionId,type:u,transport_delay:r},delete this._currentAudioRecv,this._firstAudioFrameTimer&&window.clearTimeout(this._firstAudioFrameTimer),monitor.rtcFirstFrame(d),this._audioFirstFrameState=3,e.next=30;break;case 18:if(t!==FirstframeinfoMediaType.VIDEO){e.next=30;break}if(1===this._videoFirstFrameState){e.next=21;break}return e.abrupt("return");case 21:if(this._currentVideoRecv){e.next=23;break}return e.abrupt("return");case 23:f=this._currentVideoRecv,h=f.type,m=f.startTime,[n,i,o,a].indexOf(h)>=0&&(r=0),y={event_type:FirstframeinfoEventType.RECV_END,media_type:null!==(p=this._stream)&&void 0!==p&&p.isScreen?FirstframeinfoMediaType.SCREEN_VIDEO:t,start:m,result:!0,stream_user_id:null===(_=this._stream)||void 0===_?void 0:_.userId,event_session_id:this._videoEventSessionId,type:h,transport_delay:r},delete this._currentVideoRecv,this._firstVideoFrameTimer&&window.clearTimeout(this._firstVideoFrameTimer),monitor.rtcFirstFrame(y),this._videoFirstFrameState=3;case 30:case"end":return e.stop()}}),e,this)}))),function(e){return n.apply(this,arguments)})},{key:"setLogin",value:function(e){var t,r,n,i,o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{audio:!0,video:!0};this._login!==e&&(this._login=e,e&&null!==(t=this._stream)&&void 0!==t&&t.hasAudio&&o.audio&&this.beginRecvFrame(FirstframeinfoMediaType.AUDIO,FirstframeinfoType.LOGIN),e&&null!==(r=this._stream)&&void 0!==r&&r.hasVideo&&o.video&&this.beginRecvFrame(FirstframeinfoMediaType.VIDEO,FirstframeinfoType.LOGIN),!e&&null!==(n=this._stream)&&void 0!==n&&n.hasAudio&&this.stopRecvFrame(FirstframeinfoMediaType.AUDIO,FirstframeinfoReason.LEAVE_ROOM),!e&&null!==(i=this._stream)&&void 0!==i&&i.hasVideo&&this.stopRecvFrame(FirstframeinfoMediaType.VIDEO,FirstframeinfoReason.LEAVE_ROOM))}},{key:"setUnmuteAudio",value:function(e){var t;this._unMuteAudio!==e&&(this._unMuteAudio=e,this._unMuteAudio?this.beginRecvFrame(FirstframeinfoMediaType.AUDIO,FirstframeinfoType.UNMUTE):null!==(t=this._stream)&&void 0!==t&&t.hasAudio&&this.stopRecvFrame(FirstframeinfoMediaType.AUDIO,FirstframeinfoReason.MUTE))}},{key:"setRemoteUnmuteAudio",value:function(e){var t;this._remoteUnmuteAudio!==e&&(this._remoteUnmuteAudio=e,this._remoteUnmuteAudio?this.beginRecvFrame(FirstframeinfoMediaType.AUDIO,FirstframeinfoType.REMOTE_UNMUTE):null!==(t=this._stream)&&void 0!==t&&t.hasAudio&&this.stopRecvFrame(FirstframeinfoMediaType.AUDIO,FirstframeinfoReason.REMOTE_MUTE))}},{key:"setEnableAudio",value:function(e){var t;this._enableAudio!==e&&(this._enableAudio=e,this._enableAudio?this.beginRecvFrame(FirstframeinfoMediaType.AUDIO,FirstframeinfoType.ENABLE):null!==(t=this._stream)&&void 0!==t&&t.hasAudio&&this.stopRecvFrame(FirstframeinfoMediaType.AUDIO,FirstframeinfoReason.DISABLE))}},{key:"setUnmuteVideo",value:function(e){var t;this._unMuteVideo!==e&&(this._unMuteVideo=e,this._unMuteVideo?this.beginRecvFrame(FirstframeinfoMediaType.VIDEO,FirstframeinfoType.UNMUTE):null!==(t=this._stream)&&void 0!==t&&t.hasVideo&&this.stopRecvFrame(FirstframeinfoMediaType.VIDEO,FirstframeinfoReason.MUTE))}},{key:"setRemoteUnmuteVideo",value:function(e){var t;this._remoteUnmuteVideo!==e&&(this._remoteUnmuteVideo=e,this._remoteUnmuteVideo?this.beginRecvFrame(FirstframeinfoMediaType.VIDEO,FirstframeinfoType.REMOTE_UNMUTE):null!==(t=this._stream)&&void 0!==t&&t.hasAudio&&this.stopRecvFrame(FirstframeinfoMediaType.VIDEO,FirstframeinfoReason.REMOTE_MUTE))}},{key:"setEnableVideo",value:function(e){this._enableVideo!==e&&(this._enableVideo=e,this._enableVideo?this.beginRecvFrame(FirstframeinfoMediaType.VIDEO,FirstframeinfoType.ENABLE):this.stopRecvFrame(FirstframeinfoMediaType.VIDEO,FirstframeinfoReason.DISABLE))}},{key:"setExternalAudioSource",value:function(e){this._audioExternal=e}},{key:"setPushAudio",value:function(e){var t;this._audioExternal&&this._pushAudio!==e&&(this._pushAudio=e),this._pushAudio&&this.beginRecvFrame(FirstframeinfoMediaType.AUDIO,FirstframeinfoType.PUSH),!e&&null!==(t=this._stream)&&void 0!==t&&t.hasAudio&&this.beginRecvFrame(FirstframeinfoMediaType.AUDIO,FirstframeinfoType.PUSH)}},{key:"setExternalVideoSource",value:function(e){this._videoExternal=e}},{key:"setPushVideo",value:function(e){var t;this._videoExternal&&this._pushVideo!==e&&(this._pushVideo=e),this._pushVideo&&this.beginRecvFrame(FirstframeinfoMediaType.VIDEO,FirstframeinfoType.PUSH),!e&&null!==(t=this._stream)&&void 0!==t&&t.hasVideo&&this.beginRecvFrame(FirstframeinfoMediaType.VIDEO,FirstframeinfoType.PUSH)}},{key:"setPublishVideo",value:function(e){var t;this._publishVideo!==e&&(this._publishVideo=e),this._publishVideo&&this.beginRecvFrame(FirstframeinfoMediaType.VIDEO,FirstframeinfoType.PUBLISH),!e&&null!==(t=this._stream)&&void 0!==t&&t.hasVideo&&this.stopRecvFrame(FirstframeinfoMediaType.VIDEO,FirstframeinfoReason.UNPUBLISH)}},{key:"setPublishAudio",value:function(e){var t;this._publishAudio!==e&&(this._publishAudio=e),this._publishAudio&&this.beginRecvFrame(FirstframeinfoMediaType.AUDIO,FirstframeinfoType.PUBLISH),!e&&null!==(t=this._stream)&&void 0!==t&&t.hasAudio&&this.stopRecvFrame(FirstframeinfoMediaType.AUDIO,FirstframeinfoReason.UNPUBLISH)}},{key:"setAutoSubscribe",value:function(e){this._autoSubscribe=e}},{key:"setAutoSubscribeVideo",value:function(e){this._autoSubscribeVideo=e}},{key:"setAutoSubscribeAudio",value:function(e){this._autoSubscribeAudio=e}},{key:"setSubscribeAudio",value:function(e){var t,r;this._autoSubscribeAudio||this._subscribeAudio===e||(this._subscribe=e,e&&null!==(r=this._stream)&&void 0!==r&&r.hasAudio&&this.beginRecvFrame(FirstframeinfoMediaType.AUDIO,FirstframeinfoType.SUBSCRIBE));!e&&null!==(t=this._stream)&&void 0!==t&&t.hasAudio&&this.stopRecvFrame(FirstframeinfoMediaType.AUDIO,FirstframeinfoReason.UNSUBSCRIBE)}},{key:"setSubscribeVideo",value:function(e){var t,r;this._autoSubscribeVideo||this._subscribeVideo===e||(this._subscribeVideo=e,e&&null!==(r=this._stream)&&void 0!==r&&r.hasVideo&&this.beginRecvFrame(FirstframeinfoMediaType.VIDEO,FirstframeinfoType.SUBSCRIBE));!e&&null!==(t=this._stream)&&void 0!==t&&t.hasVideo&&this.stopRecvFrame(FirstframeinfoMediaType.VIDEO,FirstframeinfoReason.UNSUBSCRIBE)}},{key:"setPushTrack",value:function(e){var t;this._pushTrack!==e&&(e&&!this._isScreen&&this.beginRecvFrame(FirstframeinfoMediaType.AUDIO,FirstframeinfoType.PUSH_TRACK),!e&&null!==(t=this._stream)&&void 0!==t&&t.hasAudio&&this.stopRecvFrame(FirstframeinfoMediaType.AUDIO,FirstframeinfoReason.REMOVE_TRACK))}},{key:"setMultiChatMode",value:function(e){this._multiChatMode=e}},{key:"setTimeout",value:function(e){this._timeout=e}},{key:"_watchForFirstVideoFrameRecv",value:function(){var e=this,t=-1,r=-1;this._firstVideoFrameInterval=window.setInterval(_asyncToGenerator(_regeneratorRuntime().mark((function n(){var i,o,a,s,c,u,l,d;return _regeneratorRuntime().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(null===(i=e._handler)||void 0===i||!i.pc||null===(o=e._stream)||void 0===o||null===(a=o.videoTrack)||void 0===a||!a.getTrack()){n.next=12;break}return n.next=3,getStats(null===(s=e._handler)||void 0===s?void 0:s.pc,null===(c=e._stream)||void 0===c||null===(u=c.videoTrack)||void 0===u?void 0:u.getTrack());case 3:if(l=n.sent,!(d=l.find((function(e){return"inbound-rtp"===e.type})))||!(d.framesReceived>t||d.packetsReceived>r)){n.next=12;break}if(-1!==t||-1!==r){n.next=10;break}return t=d.framesReceived,r=d.packetsReceived,n.abrupt("return");case 10:e.recvFrameFinish(FirstframeinfoMediaType.VIDEO),window.clearInterval(e._firstVideoFrameInterval);case 12:case"end":return n.stop()}}),n)}))),200)}},{key:"_watchForFirstAudioFrameRecv",value:function(){var e=this,t=-1,r=-1;this._firstAudioFrameInterval=window.setInterval(_asyncToGenerator(_regeneratorRuntime().mark((function n(){var i,o,a,s,c,u,l,d;return _regeneratorRuntime().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(null===(i=e._handler)||void 0===i||!i.pc||null===(o=e._stream)||void 0===o||null===(a=o.audioTrack)||void 0===a||!a.getTrack()){n.next=12;break}return n.next=3,getStats(null===(s=e._handler)||void 0===s?void 0:s.pc,null===(c=e._stream)||void 0===c||null===(u=c.audioTrack)||void 0===u?void 0:u.getTrack());case 3:if(l=n.sent,!(d=l.find((function(e){return"inbound-rtp"===e.type})))||!(d.totalSamplesReceived>t||d.packetsReceived>r)){n.next=12;break}if(-1!==t||-1!==r){n.next=10;break}return t=d.totalSamplesReceived,r=d.packetsReceived,n.abrupt("return");case 10:e.recvFrameFinish(FirstframeinfoMediaType.AUDIO),window.clearInterval(e._firstAudioFrameInterval);case 12:case"end":return n.stop()}}),n)}))),200)}},{key:"getTransportDelay",value:(r=_asyncToGenerator(_regeneratorRuntime().mark((function e(){var t=this;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.getTransportDelayIntl();case 2:window.clearInterval(this._transportDelayInterval),this._transportDelayInterval=window.setInterval(_asyncToGenerator(_regeneratorRuntime().mark((function e(){return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,t.getTransportDelayIntl();case 2:case"end":return e.stop()}}),e)}))),2e3);case 4:case"end":return e.stop()}}),e,this)}))),function(){return r.apply(this,arguments)})},{key:"getTransportDelayIntl",value:(t=_asyncToGenerator(_regeneratorRuntime().mark((function e(){var t,r,n,i,o;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(null===(t=this._handler)||void 0===t||!t.pc){e.next=7;break}return e.next=3,getStats(null===(r=this._handler)||void 0===r?void 0:r.pc);case 3:n=e.sent,i=n.find((function(e){return"transport"===e.type&&"connected"===e.dtlsState})),(o=n.find((function(e){return"candidate-pair"===e.type&&"succeeded"===e.state&&e.id===(null==i?void 0:i.selectedCandidatePairId)})))&&(this._transportDelay=Math.round(1e3*o.currentRoundTripTime/2));case 7:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})},{key:"reset",value:function(){this._currentAudioRecv={startTime:0,eventSessionId:0,type:FirstframeinfoType.LOGIN},this._currentVideoRecv={startTime:0,eventSessionId:0,type:FirstframeinfoType.LOGIN},this._login=!1,this._unMuteAudio=!1,this._enableAudio=!1,this._unMuteVideo=!1,this._remoteUnmuteAudio=!1,this._remoteUnmuteVideo=!1,this._enableVideo=!1,this._audioExternal=!1,this._pushAudio=!1,this._videoExternal=!1,this._pushVideo=!1,this._autoSubscribeVideo=!1,this._autoSubscribeAudio=!1,this._autoSubscribe=!1,this._subscribeAudio=!1,this._subscribeVideo=!1,this._subscribe=!1,this._pushTrack=!1,this._multiChatMode=!1,this._firstAudioFrameTimer&&window.clearTimeout(this._firstAudioFrameTimer),this._firstVideoFrameTimer&&window.clearTimeout(this._firstVideoFrameTimer),this._firstAudioFrameInterval&&window.clearInterval(this._firstAudioFrameInterval),this._firstVideoFrameInterval&&window.clearInterval(this._firstVideoFrameInterval),this._transportDelayInterval&&window.clearInterval(this._transportDelayInterval)}}]),e}(),SendFrameObserver=function(){function e(t,r){_classCallCheck(this,e),_defineProperty(this,"_audioEventSessionId",genEventSessionId()),_defineProperty(this,"_videoEventSessionId",genEventSessionId()),_defineProperty(this,"_pcSessionId",void 0),_defineProperty(this,"_handler",void 0),_defineProperty(this,"_firstAudioFrameTimer",void 0),_defineProperty(this,"_firstVideoFrameTimer",void 0),_defineProperty(this,"_stream",void 0),_defineProperty(this,"_firstVideoFrameInterval",void 0),_defineProperty(this,"_firstAudioFrameInterval",void 0),_defineProperty(this,"_currentAudioSend",{startTime:0,eventSessionId:0,type:FirstframeinfoType.LOGIN}),_defineProperty(this,"_currentVideoSend",{startTime:0,eventSessionId:0,type:FirstframeinfoType.LOGIN}),_defineProperty(this,"_login",!1),_defineProperty(this,"_publisher",!1),_defineProperty(this,"_unMuteAudio",!1),_defineProperty(this,"_enableAudio",!1),_defineProperty(this,"_unMuteVideo",!1),_defineProperty(this,"_enableVideo",!1),_defineProperty(this,"_audioExternal",!1),_defineProperty(this,"_pushAudio",!1),_defineProperty(this,"_videoExternal",!1),_defineProperty(this,"_pushVideo",!1),_defineProperty(this,"_autoPublish",!1),_defineProperty(this,"_publish",!1),_defineProperty(this,"_timeout",1e4),_defineProperty(this,"_audioFirstFrameState",0),_defineProperty(this,"_videoFirstFrameState",0),this._stream=t,this._handler=r}var t,r;return _createClass(e,[{key:"beginSendFrame",value:function(e,t){var r=this;if(e===FirstframeinfoMediaType.AUDIO){var n;this._audioEventSessionId++,this._currentAudioSend={startTime:Date.now(),eventSessionId:this._audioEventSessionId,type:t};var i={media_type:e,event_type:FirstframeinfoEventType.BEGIN_SEND,type:t,start:null===(n=this._currentAudioSend)||void 0===n?void 0:n.startTime,event_session_id:this._audioEventSessionId};this._firstAudioFrameTimer&&window.clearTimeout(this._firstAudioFrameTimer),this._firstAudioFrameTimer=window.setTimeout((function(){r.stopSendFrame(FirstframeinfoMediaType.AUDIO,FirstframeinfoReason.TIMEOUT),r._firstAudioFrameInterval&&window.clearInterval(r._firstAudioFrameInterval)}),this._timeout),monitor.rtcFirstFrame(i),this._watchForFirstAudioFrameSend(),this._audioFirstFrameState=1,this._login=!0,this._publisher=!0,this._publish=!0,this._unMuteAudio=!0,this._pushAudio||(this._enableAudio=!0)}else if(e===FirstframeinfoMediaType.VIDEO){var o,a;this._videoEventSessionId++,this._currentVideoSend={startTime:Date.now(),eventSessionId:this._videoEventSessionId,type:t};var s={media_type:null!==(o=this._stream)&&void 0!==o&&o.isScreen?FirstframeinfoMediaType.SCREEN_VIDEO:e,event_type:FirstframeinfoEventType.BEGIN_SEND,type:t,start:null===(a=this._currentVideoSend)||void 0===a?void 0:a.startTime,event_session_id:this._videoEventSessionId};this._firstVideoFrameTimer&&window.clearTimeout(this._firstVideoFrameTimer),this._firstVideoFrameTimer=window.setTimeout((function(){r.stopSendFrame(FirstframeinfoMediaType.VIDEO,FirstframeinfoReason.TIMEOUT),r._firstVideoFrameInterval&&window.clearInterval(r._firstVideoFrameInterval)}),this._timeout),this._watchForFirstVideoFrameSend(),monitor.rtcFirstFrame(s),this._videoFirstFrameState=1,this._login=!0,this._publisher=!0,this._publish=!0,this._unMuteVideo=!0,this._pushVideo||(this._enableVideo=!0)}}},{key:"stopSendFrame",value:function(e,t){if(e===FirstframeinfoMediaType.AUDIO){var r,n;if(1!==this._audioFirstFrameState)return;var i={event_type:FirstframeinfoEventType.SENT_END,media_type:e,start:null===(r=this._currentAudioSend)||void 0===r?void 0:r.startTime,reason:t,result:!1,event_session_id:this._audioEventSessionId,type:null===(n=this._currentAudioSend)||void 0===n?void 0:n.type};this._firstAudioFrameTimer&&window.clearTimeout(this._firstAudioFrameTimer),delete this._currentAudioSend,monitor.rtcFirstFrame(i),this._audioFirstFrameState=2}else if(e===FirstframeinfoMediaType.VIDEO){var o,a,s;if(1!==this._videoFirstFrameState)return;var c={event_type:FirstframeinfoEventType.SENT_END,media_type:null!==(o=this._stream)&&void 0!==o&&o.isScreen?FirstframeinfoMediaType.SCREEN_VIDEO:e,start:null===(a=this._currentVideoSend)||void 0===a?void 0:a.startTime,reason:t,result:!1,event_session_id:this._videoEventSessionId,type:null===(s=this._currentVideoSend)||void 0===s?void 0:s.type};this._firstVideoFrameTimer&&window.clearTimeout(this._firstVideoFrameTimer),delete this._currentVideoSend,monitor.rtcFirstFrame(c),this._videoFirstFrameState=2}}},{key:"sendFrameFinish",value:function(e){if(e===FirstframeinfoMediaType.AUDIO){if(1!==this._audioFirstFrameState)return;if(!this._currentAudioSend)return;var t=this._currentAudioSend,r=t.type,n=t.startTime,i={event_type:FirstframeinfoEventType.SENT_END,media_type:e,start:n,result:!0,event_session_id:this._audioEventSessionId,type:r};delete this._currentAudioSend,this._firstAudioFrameTimer&&window.clearTimeout(this._firstAudioFrameTimer),monitor.rtcFirstFrame(i),this._audioFirstFrameState=3}else if(e===FirstframeinfoMediaType.VIDEO){var o;if(1!==this._videoFirstFrameState)return;if(!this._currentVideoSend)return;var a=this._currentVideoSend,s=a.type,c=a.startTime,u={event_type:FirstframeinfoEventType.SENT_END,media_type:null!==(o=this._stream)&&void 0!==o&&o.isScreen?FirstframeinfoMediaType.SCREEN_VIDEO:e,start:c,result:!0,event_session_id:this._videoEventSessionId,type:s};delete this._currentVideoSend,this._firstVideoFrameTimer&&window.clearTimeout(this._firstVideoFrameTimer),monitor.rtcFirstFrame(u),this._videoFirstFrameState=3}}},{key:"setLogin",value:function(e){if(this._login!==e){var t,r;if(this._login=e,e)null!==(t=this._stream)&&void 0!==t&&t.videoTrack&&this.beginSendFrame(FirstframeinfoMediaType.VIDEO,FirstframeinfoType.LOGIN),null!==(r=this._stream)&&void 0!==r&&r.audioTrack&&this.beginSendFrame(FirstframeinfoMediaType.AUDIO,FirstframeinfoType.LOGIN);!e&&this._audioSending&&this.stopSendFrame(FirstframeinfoMediaType.AUDIO,FirstframeinfoReason.LEAVE_ROOM),!e&&this._videoSending&&this.stopSendFrame(FirstframeinfoMediaType.VIDEO,FirstframeinfoReason.LEAVE_ROOM)}}},{key:"setPublish",value:function(e){if(this._publish!==e){var t,r;if(this._publish=e,e)(null===(t=this._stream)||void 0===t?void 0:t.videoTrack)&&this.beginSendFrame(FirstframeinfoMediaType.VIDEO,FirstframeinfoType.PUBLISH),(null===(r=this._stream)||void 0===r?void 0:r.audioTrack)&&this.beginSendFrame(FirstframeinfoMediaType.AUDIO,FirstframeinfoType.PUBLISH);!e&&this._audioSending&&this.stopSendFrame(FirstframeinfoMediaType.AUDIO,FirstframeinfoReason.UNPUBLISH),!e&&this._videoSending&&this.stopSendFrame(FirstframeinfoMediaType.VIDEO,FirstframeinfoReason.UNPUBLISH)}}},{key:"setUnmuteAudio",value:function(e){this._unMuteAudio!==e&&(this._unMuteAudio=e,e&&this.beginSendFrame(FirstframeinfoMediaType.AUDIO,FirstframeinfoType.UNMUTE),!e&&this._audioSending&&this.stopSendFrame(FirstframeinfoMediaType.AUDIO,FirstframeinfoReason.MUTE))}},{key:"setEnableAudio",value:function(e){this._enableAudio!==e&&(this._enableAudio=e,e&&this.beginSendFrame(FirstframeinfoMediaType.AUDIO,FirstframeinfoType.ENABLE),!e&&this._audioSending&&this.stopSendFrame(FirstframeinfoMediaType.AUDIO,FirstframeinfoReason.DISABLE))}},{key:"setUnmuteVideo",value:function(e){this._unMuteVideo!==e&&(this._unMuteVideo=e,e&&this.beginSendFrame(FirstframeinfoMediaType.VIDEO,FirstframeinfoType.UNMUTE),!e&&this._videoSending&&this.stopSendFrame(FirstframeinfoMediaType.VIDEO,FirstframeinfoReason.MUTE))}},{key:"setEnableVideo",value:function(e){this._enableVideo!==e&&(this._enableVideo=e,e&&this.beginSendFrame(FirstframeinfoMediaType.VIDEO,FirstframeinfoType.ENABLE),!e&&this._videoSending&&this.stopSendFrame(FirstframeinfoMediaType.VIDEO,FirstframeinfoReason.DISABLE))}},{key:"setExternalAudioSource",value:function(e){this._audioExternal!==e&&(this._audioExternal=e,e&&(this._audioSending&&this.stopSendFrame(FirstframeinfoMediaType.AUDIO,FirstframeinfoReason.DISABLE),this._enableAudio=!1),e||(this._audioSending&&this.stopSendFrame(FirstframeinfoMediaType.AUDIO,FirstframeinfoReason.STOP_PUSH),this._pushAudio=!1))}},{key:"setPushAudio",value:function(e){this._pushAudio!==e&&(this._pushAudio=e,e&&this.beginSendFrame(FirstframeinfoMediaType.AUDIO,FirstframeinfoType.PUSH),!e&&this._audioSending&&this.stopSendFrame(FirstframeinfoMediaType.AUDIO,FirstframeinfoReason.STOP_PUSH))}},{key:"setExternalVideoSource",value:function(e){this._videoExternal!==e&&(this._videoExternal=e,e&&(this._videoSending&&this.stopSendFrame(FirstframeinfoMediaType.VIDEO,FirstframeinfoReason.DISABLE),this._enableVideo=!1),e||(this._videoSending&&this.stopSendFrame(FirstframeinfoMediaType.VIDEO,FirstframeinfoReason.STOP_PUSH),this._pushVideo=!1))}},{key:"setPushVideo",value:function(e){this._pushVideo!==e&&(this._pushVideo=e,e&&this.beginSendFrame(FirstframeinfoMediaType.VIDEO,FirstframeinfoType.PUSH),!e&&this._videoSending&&this.stopSendFrame(FirstframeinfoMediaType.VIDEO,FirstframeinfoReason.STOP_PUSH))}},{key:"setAutoPublish",value:function(e){this._autoPublish=e}},{key:"setPublisher",value:function(e){this._publisher!==e&&(this._publisher=e,!e&&this._audioSending&&this.stopSendFrame(FirstframeinfoMediaType.AUDIO,FirstframeinfoReason.AUDIENCE),!e&&this._videoSending&&this.stopSendFrame(FirstframeinfoMediaType.VIDEO,FirstframeinfoReason.AUDIENCE))}},{key:"setTimeout",value:function(e){this._timeout=e}},{key:"setPCSessionId",value:function(e){this._pcSessionId=e}},{key:"setHandler",value:function(e){this._handler=e}},{key:"_getFirstVideoFrameStats",value:(r=_asyncToGenerator(_regeneratorRuntime().mark((function e(){var t,r,n,i,o,a,s,c;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(null===(t=this._handler)||void 0===t||!t.pc||null===(r=this._stream)||void 0===r||null===(n=r.videoTrack)||void 0===n||!n.getTrack()){e.next=6;break}return e.next=3,getStats(null===(i=this._handler)||void 0===i?void 0:i.pc,null===(o=this._stream)||void 0===o||null===(a=o.videoTrack)||void 0===a?void 0:a.getTrack());case 3:return s=e.sent,c=s.find((function(e){return"outbound-rtp"===e.type})),e.abrupt("return",c);case 6:case"end":return e.stop()}}),e,this)}))),function(){return r.apply(this,arguments)})},{key:"_getFirstAudioFrameStats",value:(t=_asyncToGenerator(_regeneratorRuntime().mark((function e(){var t,r,n,i,o,a,s,c;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(null===(t=this._handler)||void 0===t||!t.pc||null===(r=this._stream)||void 0===r||null===(n=r.audioTrack)||void 0===n||!n.getPublishTrack()){e.next=6;break}return e.next=3,getStats(null===(i=this._handler)||void 0===i?void 0:i.pc,null===(o=this._stream)||void 0===o||null===(a=o.audioTrack)||void 0===a?void 0:a.getPublishTrack());case 3:return s=e.sent,c=s.find((function(e){return"outbound-rtp"===e.type})),e.abrupt("return",c);case 6:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})},{key:"_watchForFirstVideoFrameSend",value:function(){var e=this,t=-1,r=-1;this._firstVideoFrameInterval=window.setInterval(_asyncToGenerator(_regeneratorRuntime().mark((function n(){var i;return _regeneratorRuntime().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,e._getFirstVideoFrameStats();case 2:if(!(i=n.sent)||!(i.framesSent>t||i.packetsSent>r)){n.next=10;break}if(-1!==t||-1!==r){n.next=8;break}return t=i.framesSent,r=i.packetsSent,n.abrupt("return");case 8:e.sendFrameFinish(FirstframeinfoMediaType.VIDEO),window.clearInterval(e._firstVideoFrameInterval);case 10:case"end":return n.stop()}}),n)}))),100)}},{key:"_watchForFirstAudioFrameSend",value:function(){var e=this,t=-1;this._firstAudioFrameInterval=window.setInterval(_asyncToGenerator(_regeneratorRuntime().mark((function r(){var n;return _regeneratorRuntime().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,e._getFirstAudioFrameStats();case 2:if(!((n=r.sent)&&n.packetsSent>t)){r.next=9;break}if(-1!==t){r.next=7;break}return t=n.packetsSent,r.abrupt("return");case 7:e.sendFrameFinish(FirstframeinfoMediaType.AUDIO),window.clearInterval(e._firstAudioFrameInterval);case 9:case"end":return r.stop()}}),r)}))),100)}},{key:"reset",value:function(){this._login=!1,this._publisher=!1,this._unMuteAudio=!1,this._enableAudio=!1,this._unMuteVideo=!1,this._enableVideo=!1,this._audioExternal=!1,this._pushAudio=!1,this._videoExternal=!1,this._pushVideo=!1,this._autoPublish=!1,this._publish=!1,this._audioFirstFrameState=0,this._videoFirstFrameState=0,this._currentAudioSend={startTime:0,eventSessionId:0,type:FirstframeinfoType.LOGIN},this._currentVideoSend={startTime:0,eventSessionId:0,type:FirstframeinfoType.LOGIN},window.clearTimeout(this._firstAudioFrameTimer),window.clearTimeout(this._firstVideoFrameTimer),window.clearInterval(this._firstAudioFrameInterval),window.clearInterval(this._firstVideoFrameInterval)}},{key:"destroy",value:function(){this.reset(),delete this._stream,delete this._handler}},{key:"_audioSending",get:function(){return 1===this._audioFirstFrameState}},{key:"_videoSending",get:function(){return 1===this._videoFirstFrameState}}]),e}(),CONFIG=(_defineProperty(_CONFIG={},"audio",{delay:1200,stallRadio:.3}),_defineProperty(_CONFIG,"video",{delay:1200,stallRadio:.6}),_defineProperty(_CONFIG,"screen_audio",{delay:1600,stallRadio:.8}),_defineProperty(_CONFIG,"screen_video",{delay:1600,stallRadio:.8}),_CONFIG),NetworkQualityManager=function(){function e(){_classCallCheck(this,e),_defineProperty(this,"_preUplinkStats",new Map),_defineProperty(this,"_preDownlinkStats",new Map),_defineProperty(this,"_timer",void 0),_defineProperty(this,"_delayTimer",void 0),_defineProperty(this,"_connectionState",MediaConnectionState.CONNECTED),_defineProperty(this,"reportor",void 0)}return _createClass(e,[{key:"updateUplinkStats",value:function(e){var t=e.audioStats,r=e.videoStats,n=e.isScreen;if(t.sendKBitrate>0&&t.rtt){var i=n?"screen_audio":"audio",o=t.rtt,a=t._fractionLost,s=t._retransmittedRate,c=this._getQosLevel(o,a||0,s||0),u=this._preUplinkStats.get(i)||[c];this._preUplinkStats.set(i,[].concat(_toConsumableArray(u),[c]).slice(-2))}if(r.sentKBitrate>0&&r.rtt){var l=n?"screen_video":"video",d=r._fractionLost,p=r.rtt,_=r._sendBandWidth,f=r._retransmittedRate;0===_&&(d=Math.max(.65,d));var h=this._getQosLevel(p,d||0,f||0),m=this._preUplinkStats.get(l)||[h];this._preUplinkStats.set(l,[].concat(_toConsumableArray(m),[h]).slice(-2))}this._startNetworkQualityReport()}},{key:"updateDownlinkStats",value:function(e,t){if(t){var r,n,i=this._getStreamActiveState(t),o=i.audioActive,a=i.videoActive,s=e.audioStats,c=e.videoStats,u=e.isScreen,l=e.userId;if(o&&s.rtt)if(0===s.receivedKBitrate)r=NetworkQuality.VBAD;else{var d=s.rtt,p=s.audioLossRate,_=s.stallDuration,f=s.statsInterval,h=s.e2eDelay,m=_/f,y=u?"screen_audio":"audio",v=this._getQosLevel(d,p||0,c._retransmittedRate||0),S=this._getDownlinkQoE(y,m,h);r=this._getNetworkQuality(v,S)}if(a)if(0===c.receivedKBitrate||0===c.rtt)n=NetworkQuality.VBAD;else{var g=c.rtt,E=c.videoLossRate,T=c.stallDuration,b=c.statsInterval,R=c.e2eDelay,I=c._retransmittedRate,$=T/b,A=u?"screen_video":"video",C=this._getQosLevel(g,E||0,I||0),O=this._getDownlinkQoE(A,$,R);n=this._getNetworkQuality(C,O)}var P=r&&n?Math.ceil((r+n)/2):r||n;if(P){var k="".concat(l).concat(u?"_screen":""),w=this._preDownlinkStats.get(k)||[P];this._preDownlinkStats.set(k,[].concat(_toConsumableArray(w),[P]).slice(-2)),this._startNetworkQualityReport()}}}},{key:"setConnectionState",value:function(e){this._connectionState=e}},{key:"destroy",value:function(){this._timer&&(window.clearInterval(this._timer),delete this._timer),this._delayTimer&&(window.clearTimeout(this._delayTimer),delete this._delayTimer),this._preUplinkStats.clear(),this._preDownlinkStats.clear()}},{key:"_startNetworkQualityReport",value:function(){var e=this;this._delayTimer||this._timer||(this._preUplinkStats.size>0||this._preDownlinkStats.size>0)&&(this._delayTimer=window.setTimeout((function(){delete e._delayTimer,e._reportNetworkQuality(),e._timer=window.setInterval((function(){e._reportNetworkQuality()}),2e3)}),300))}},{key:"_reportNetworkQuality",value:function(){var e,t,r=this;if(this._connectionState!==MediaConnectionState.CONNECTED)e=t=NetworkQuality.VBAD;else{var n=this._getBetterQualityAndRemoveOldest("audio","up"),i=this._getBetterQualityAndRemoveOldest("video","up");e=n&&i?Math.ceil((n+i)/2):n||i||this._getBetterQualityAndRemoveOldest("screen_video","up")||this._getBetterQualityAndRemoveOldest("screen_audio","up")||NetworkQuality.UNKNOWN;var o=Array.from(this._preDownlinkStats.keys()).map((function(e){return r._getBetterQualityAndRemoveOldest(e,"down")})).filter((function(e){return e}));t=Math.ceil(o.reduce((function(e,t){return t+e}),0)/o.length)||NetworkQuality.UNKNOWN}this.reportor&&this.reportor(e,t)}},{key:"_getNetworkQuality",value:function(e,t){return 1===t?Math.max(e-2,1):2===t?e:Math.min(e+1,5)}},{key:"_getQosLevel",value:function(e,t,r){var n;return n=e<=250&&t<=.15?1:e<=500&&t<=.3?2:e<=750&&t<=.45?3:e<=1e3&&t<=.6?4:5,r>.5?n=Math.max(n,4):r>.35?n=Math.max(n,3):r>.15&&(n=Math.max(n,2)),n}},{key:"_getUplinkQoE",value:function(e,t){var r=0;switch(e){case"audio":case"video":r=t<.05?1:t<.1?2:3;break;case"screen_video":case"screen_audio":r=t<.04?1:t<.08?2:3}return r}},{key:"_getDownlinkQoE",value:function(e,t,r){var n=CONFIG[e];return t>n.stallRadio||r>n.delay||t>n.stallRadio/2&&r>n.delay/2?3:(t>n.stallRadio/2||n.delay,2)}},{key:"_getBetterQualityAndRemoveOldest",value:function(e,t){var r=NetworkQuality.UNKNOWN,n="up"===t?this._preUplinkStats:this._preDownlinkStats,i=n.get(e);if(i){var o=i.filter((function(e){return e}));o.length>0&&(r=Math.min.apply(Math,_toConsumableArray(o))),i.shift(),0===i.length&&n.delete(e)}return r}},{key:"_getStreamActiveState",value:function(e){var t=e.subMediaType,r=e._attributes,n=e.subVideo;return{audioActive:e.subAudio&&audioInMediaType(t)&&r.localaudio&&r.audiostream,videoActive:n&&videoInMediaType(t)&&r.localvideo&&r.videostream}}}]),e}(),VideoSizeObserver=function(){function e(t){_classCallCheck(this,e),_defineProperty(this,"_timer",void 0),_defineProperty(this,"_remoteVideoSizeCache",{}),_defineProperty(this,"_remoteScreenSizeCache",{}),_defineProperty(this,"onchange",void 0),this._room=t,this._start()}return _createClass(e,[{key:"destroy",value:function(){this._timer&&(window.clearInterval(this._timer),delete this._timer),this._remoteVideoSizeCache={},this._remoteScreenSizeCache={}}},{key:"_start",value:function(){var e=this;this._timer||(this._timer=window.setInterval((function(){var t={},r={};e._room.remoteStreams.forEach((function(n,i){n.forEach((function(n){var o,a=null===(o=n.videoTrack)||void 0===o?void 0:o.getTrack();if(a){var s=n.isScreen?e._remoteScreenSizeCache:e._remoteVideoSizeCache,c=s[i]||{},u=c.width,l=void 0===u?0:u,d=c.height,p=void 0===d?0:d,_=a.getSettings(),f=_.width,h=void 0===f?0:f,m=_.height,y=void 0===m?0:m;p===y&&l===h||e.onchange&&e.onchange(i,n.isScreen,h,y),delete s[i],(n.isScreen?r:t)[i]={width:h,height:y}}}))})),Object.keys(e._remoteVideoSizeCache).forEach((function(t){e.onchange&&e.onchange(t,!1,0,0)})),Object.keys(e._remoteScreenSizeCache).forEach((function(t){e.onchange&&e.onchange(t,!0,0,0)})),e._remoteVideoSizeCache=t,e._remoteScreenSizeCache=r}),1e3))}}]),e}(),logger$7=new Logger("SubscribeFallbackManager",2),SubscribeRecoverCheckDuration=1e4,SubscribeFallbackManager=function(){function e(t){_classCallCheck(this,e),_defineProperty(this,"_preDownlinkNetworkQuality",[]),_defineProperty(this,"_isSubscribeFallbackOrRecover",!1),_defineProperty(this,"_inSubscribeRecoverChecking",!1),_defineProperty(this,"_subRecoverCheckTimer",void 0),_defineProperty(this,"_forbidSubRecover",!1),_defineProperty(this,"_forbidSubRecoverTimer",void 0),_defineProperty(this,"_forbidSubRecoverDuration",SubscribeRecoverCheckDuration),_defineProperty(this,"onSubscribeFallback",void 0),this._room=t}var t;return _createClass(e,[{key:"updateNetworkQuality",value:function(e,t){this._preDownlinkNetworkQuality.push(t),this._preDownlinkNetworkQuality=this._preDownlinkNetworkQuality.slice(-10),this._inSubscribeRecoverChecking&&this._preDownlinkNetworkQuality.find((function(e){return e===NetworkQuality.BAD||e===NetworkQuality.VBAD}))&&this._startForbidSubRecover(),this._preDownlinkNetworkQuality.slice(-3).reduce((function(e,t){return e+t}),0)>3*NetworkQuality.POOR&&this._subscribeFallbackOrRecover("fallback"),!this._forbidSubRecover&&10===this._preDownlinkNetworkQuality.length&&this._preDownlinkNetworkQuality.every((function(e){return e===NetworkQuality.EXCELLENT}))&&this._subscribeFallbackOrRecover("recover")}},{key:"destroy",value:function(){this._stopSubscribeRecoverCheck(),this._stopForbidSubRecover(),delete this.onSubscribeFallback}},{key:"_subscribeFallbackOrRecover",value:(t=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){var r,n,i,o,a,s,c,u,l,d,p=this;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._isSubscribeFallbackOrRecover&&this._room.connectionState===MediaConnectionState.CONNECTED){e.next=2;break}return e.abrupt("return");case 2:if(this._room.subscribeFallbackOption!==SubscribeFallbackOption.AUDIO_ONLY&&this._room.subscribeFallbackOption!==SubscribeFallbackOption.VIDEO_STREAM_LOW){e.next=24;break}if(r=new Map,this._room.remoteStreams.forEach((function(e){e.forEach((function(e){if(e.hasSubscribed){var n="fallback"===t?e.getSubscribeFallbackParams(p._room.subscribeFallbackOption):e.getSubscribeRecoverParams();if(n){var i=e.getStreamPriority(),o=r.get(i)||[];o.push({stream:e,fallbackOrRecoverOption:n}),r.set(i,o)}}}))})),!(r.size>0)){e.next=24;break}if(logger$7.print("_subscribeFallbackOrRecover()","start subscribe ".concat(t,".")),n=Array.from(r.keys()).sort((function(e,t){return e-t}))["fallback"===t?0:r.size-1],i=r.get(n)||[],o=_slicedToArray(i,1),!(a=o[0])){e.next=24;break}return s=a.stream,c=a.fallbackOrRecoverOption,this._isSubscribeFallbackOrRecover=!0,u=s.subLayer.spatialLayer,l=s.subVideo,logger$7.print("_subscribeFallbackOrRecover()","".concat(s.userId,"'s stream will be ").concat(t," to: MediaType=").concat(c[0]," subState=").concat(c[1]," subLayer=").concat(c[2])),e.prev=15,e.next=18,promiseAny([(d=this._room).updateSubTrack.apply(d,[s].concat(_toConsumableArray(c))).then((function(){"recover"===t?p._startSubscribeRecoverCheck():logger$7.print("_subscribeFallbackOrRecover()","fallback success."),p.onSubscribeFallback&&p.onSubscribeFallback({userId:s.userId,isScreen:s.isScreen,beforeEnable:l,beforeVideoIndex:u,afterEnable:s.subVideo,afterVideoIndex:s.subLayer.spatialLayer,reason:"fallback"===t?FallbackOrRecoverReason.SubscribeFallbackByBandwidth:FallbackOrRecoverReason.SubscribeRecoverByBandwidth})})),wait(2e3)]);case 18:e.next=22;break;case 20:e.prev=20,e.t0=e.catch(15);case 22:this._preDownlinkNetworkQuality=[],this._isSubscribeFallbackOrRecover=!1;case 24:case"end":return e.stop()}}),e,this,[[15,20]])}))),function(e){return t.apply(this,arguments)})},{key:"_startSubscribeRecoverCheck",value:function(){var e=this;this._stopSubscribeRecoverCheck(),this._inSubscribeRecoverChecking=!0,this._subRecoverCheckTimer=window.setTimeout((function(){e._inSubscribeRecoverChecking=!1,e._forbidSubRecoverDuration=SubscribeRecoverCheckDuration,delete e._subRecoverCheckTimer,logger$7.print("_subscribeFallbackOrRecover()","recover success.")}),2*SubscribeRecoverCheckDuration)}},{key:"_stopSubscribeRecoverCheck",value:function(){this._subRecoverCheckTimer&&(window.clearTimeout(this._subRecoverCheckTimer),delete this._subRecoverCheckTimer),this._inSubscribeRecoverChecking=!1}},{key:"_startForbidSubRecover",value:function(){var e=this;this._stopSubscribeRecoverCheck(),this._stopForbidSubRecover(),this._forbidSubRecoverDuration=Math.min(this._forbidSubRecoverDuration+2*SubscribeRecoverCheckDuration,12e4),logger$7.print("_subscribeFallbackOrRecover()","subscribe-recover failed, and subscribe-recover not allowed within ".concat(this._forbidSubRecoverDuration/1e3,"s")),this._forbidSubRecover=!0,this._forbidSubRecoverTimer=window.setTimeout((function(){e._forbidSubRecover=!1,delete e._forbidSubRecoverTimer}),this._forbidSubRecoverDuration)}},{key:"_stopForbidSubRecover",value:function(){this._forbidSubRecoverTimer&&(window.clearTimeout(this._forbidSubRecoverTimer),delete this._forbidSubRecoverTimer)}}]),e}(),logger$6=new Logger("Room",1),Room=function(e){_inherits(b,EnhancedEventEmitter);var t,r,n,i,o,a,s,c,u,l,d,p,_,f,h,m,y,v,S,g,E,T=_createSuper(b);function b(e,t){var r;return _classCallCheck(this,b),_defineProperty(_assertThisInitialized(r=T.call(this)),"_mediaServerClient",void 0),_defineProperty(_assertThisInitialized(r),"_localStream",void 0),_defineProperty(_assertThisInitialized(r),"_localScreenStream",void 0),_defineProperty(_assertThisInitialized(r),"_remoteUsers",new Map),_defineProperty(_assertThisInitialized(r),"_remoteStreams",new Map),_defineProperty(_assertThisInitialized(r),"_remoteStreamStreamIdUserIdMap",{}),_defineProperty(_assertThisInitialized(r),"_joinResolveCallback",void 0),_defineProperty(_assertThisInitialized(r),"_joinRejectCallback",void 0),_defineProperty(_assertThisInitialized(r),"_getAccessNode",void 0),_defineProperty(_assertThisInitialized(r),"_getAccessFeedback",void 0),_defineProperty(_assertThisInitialized(r),"_getAccessFeedbackIceNode",void 0),_defineProperty(_assertThisInitialized(r),"_reconnectTimer",void 0),_defineProperty(_assertThisInitialized(r),"_isReconnecting",void 0),_defineProperty(_assertThisInitialized(r),"_context",void 0),_defineProperty(_assertThisInitialized(r),"_sessionId",void 0),_defineProperty(_assertThisInitialized(r),"_reconnectRecord",void 0),_defineProperty(_assertThisInitialized(r),"_connectionLostTimer",void 0),_defineProperty(_assertThisInitialized(r),"_liveControlMessage",void 0),_defineProperty(_assertThisInitialized(r),"_serverConfig",void 0),_defineProperty(_assertThisInitialized(r),"_roomConfig",void 0),_defineProperty(_assertThisInitialized(r),"_roomInfo",void 0),_defineProperty(_assertThisInitialized(r),"_waitForNewToken",!1),_defineProperty(_assertThisInitialized(r),"_userDuplicateLoginTimerMap",new Map),_defineProperty(_assertThisInitialized(r),"_networkQualityManager",void 0),_defineProperty(_assertThisInitialized(r),"userPriorityMap",void 0),_defineProperty(_assertThisInitialized(r),"subscribeFallbackOption",void 0),_defineProperty(_assertThisInitialized(r),"_videoSizeObserver",void 0),_defineProperty(_assertThisInitialized(r),"_subFallbackManager",void 0),_defineProperty(_assertThisInitialized(r),"_hasPublished",!1),r._roomConfig=e,r._mediaServerClient=new MediaServerClient(t),r._reconnectRecord=new ReconnectRecord,r._addHandlerEventHandler(),r._isReconnecting=!1,r._networkQualityManager=new NetworkQualityManager,r._networkQualityManager.reportor=r._reportNetworkQuality.bind(_assertThisInitialized(r)),r._videoSizeObserver=new VideoSizeObserver(_assertThisInitialized(r)),r._videoSizeObserver.onchange=r._emitVideoSizeChange.bind(_assertThisInitialized(r)),r._subFallbackManager=new SubscribeFallbackManager(_assertThisInitialized(r)),r._subFallbackManager.onSubscribeFallback=r._emitSubscribeFallback.bind(_assertThisInitialized(r)),r._context=t,r}return _createClass(b,[{key:"hasScreenPublished",get:function(){var e;return null===(e=this._localScreenStream)||void 0===e?void 0:e.hasPublished}},{key:"hasPublished",get:function(){var e;return null===(e=this._localStream)||void 0===e?void 0:e.hasPublished}},{key:"connectionState",get:function(){return this._mediaServerClient.connectionState}},{key:"remoteUsers",get:function(){return this._remoteUsers}},{key:"remoteStreams",get:function(){return this._remoteStreams}},{key:"localStream",get:function(){return this._localStream}},{key:"localScreenStream",get:function(){return this._localScreenStream}},{key:"roomInfo",get:function(){return this._roomInfo}},{key:"_addHandlerEventHandler",value:function(){var e,t,r,n,i,o,a,s,c,u,l,d,p,_,f,h,m,y,v,S,g,E,T,b,R,I=this;null===(e=this._mediaServerClient)||void 0===e||e.on(SignalEvent.ON_ADD_STREAM,this._onAddStream.bind(this)),null===(t=this._mediaServerClient)||void 0===t||t.on(SignalEvent.ON_REMOVE_STREAM,this._onRemoveStream.bind(this)),null===(r=this._mediaServerClient)||void 0===r||r.on(SignalEvent.USER_CONNECTION,this._onUserConnection.bind(this)),null===(n=this._mediaServerClient)||void 0===n||n.on(SignalEvent.USER_DISCONNECTION,this._onUserDisconnection.bind(this)),null===(i=this._mediaServerClient)||void 0===i||i.on(SignalEvent.ON_UPDATE_ROOM_ATTRIBUTES,this._onUpdateRoomAttributes.bind(this)),null===(o=this._mediaServerClient)||void 0===o||o.on(SignalEvent.ON_UPDATE_USER_ATTRIBUTES,this._onUpdateUserAttributes.bind(this)),null===(a=this._mediaServerClient)||void 0===a||a.on(SignalEvent.ON_UPDATE_STREAM_ATTRIBUTES,this._onUpdateStreamAttributes.bind(this)),null===(s=this._mediaServerClient)||void 0===s||s.on(SignalEvent.ON_PUSH_TRACK,this._onPushTrack.bind(this)),null===(c=this._mediaServerClient)||void 0===c||c.on(SignalEvent.ON_REMOVE_TRACK,this._onRemoveTrack.bind(this)),null===(u=this._mediaServerClient)||void 0===u||u.on(SignalEvent.NODE_CHANGE,this._nodeChange.bind(this)),null===(l=this._mediaServerClient)||void 0===l||l.on(SignalEvent.ON_CUSTOM_MESSAGE,this._onCustomMessage.bind(this)),null===(d=this._mediaServerClient)||void 0===d||d.on(SignalEvent.USER_MESSAGE_RECEIVED,this._onUserMessageReceived.bind(this)),null===(p=this._mediaServerClient)||void 0===p||p.on(SignalEvent.USER_BINARY_MESSAGE_RECEIVED,this._onUserBinaryMessageReceived.bind(this)),null===(_=this._mediaServerClient)||void 0===_||_.on(SignalEvent.POST_PROCESSING_MESSAGE,this._onPostProcessingMessage.bind(this)),null===(f=this._mediaServerClient)||void 0===f||f.on(SignalEvent.ON_USER_TOKEN_WILL_EXPIRE,this._onUserTokenWillExpire.bind(this)),null===(h=this._mediaServerClient)||void 0===h||h.on(SignalEvent.STREAM_CONTROL_MESSAGE,this._onStreamControlMessage.bind(this)),null===(m=this._mediaServerClient)||void 0===m||m.on(SignalEvent.ON_SCENE_CONFIG,this._onSceneConfig.bind(this)),null===(y=this._mediaServerClient)||void 0===y||y.on(SignalEvent.ON_STREAM_FAILED,this._onStreamFailed.bind(this)),null===(v=this._mediaServerClient)||void 0===v||v.on(MediaServerSignalEvent.RSCP,this._onPublishOnDemand.bind(this)),null===(S=this._mediaServerClient)||void 0===S||S.on(StateEvent.ON_CONNECTION_STATE_CHANGE,this._onConnectionStateChange.bind(this)),null===(g=this._mediaServerClient)||void 0===g||g.on(StateEvent.ABNORMAL_DISCONNECTION,this._handleAbnormalDisconnection.bind(this)),null===(E=this._mediaServerClient)||void 0===E||E.on("onRemoteStreamStats",(function(e){I._networkQualityManager.updateDownlinkStats(e,I._findRemoteStreamByScreen(e.userId,e.isScreen)),I.emit(RoomEvent.ON_REMOTE_STREAM_STATS,getPublicStats(e))})),null===(T=this._mediaServerClient)||void 0===T||T.on("onLocalStreamStats",(function(e){I._networkQualityManager.updateUplinkStats(e),I.emit(RoomEvent.ON_LOCAL_STREAM_STATS,getPublicStats(e))})),null===(b=this._mediaServerClient)||void 0===b||b.on("prevIceNode",(function(e){I._getAccessFeedbackIceNode=e})),null===(R=this._mediaServerClient)||void 0===R||R.on("prevIceNode",(function(e){I._getAccessFeedbackIceNode=e}))}},{key:"_removeHandlerEventHandler",value:function(){var e;null===(e=this._mediaServerClient)||void 0===e||e.removeAllListeners()}},{key:"join",value:(E=_asyncToGenerator(_regeneratorRuntime().mark((function e(t,r,n,i,o,a){var s=this;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return commonStats.setStats({rtc_app_id:t,room_id:r,user_id:i.userId}),logger$6.print("join()"),e.abrupt("return",new Promise((function(e,c){var u;s._joinResolveCallback=function(t){var r;monitor.joinRoom(JoinroomType.END,l,!0,"",{enable_cloud_proxy:null===(r=s._roomInfo)||void 0===r?void 0:r.useCloudProxy}),e(t)},s._joinRejectCallback=function(e){var t;monitor.joinRoom(JoinroomType.END,l,!1,e.message,{enable_cloud_proxy:null===(t=s._roomInfo)||void 0===t?void 0:t.useCloudProxy}),c(e)},s._liveControlMessage=o,s._roomInfo={appId:t,roomId:r,token:n,userInfo:i,useCloudProxy:a,roomProfile:s._roomConfig.roomProfileType};var l=getServerNow();s.setSessionId(),monitor.joinRoom(JoinroomType.BEGIN,l,!1,"",{enable_cloud_proxy:null===(u=s._roomInfo)||void 0===u?void 0:u.useCloudProxy}),s._join(s._joinResolveCallback,s._joinRejectCallback,!1)})));case 3:case"end":return e.stop()}}),e)}))),function(e,t,r,n,i,o){return E.apply(this,arguments)})},{key:"_join",value:(g=_asyncToGenerator(_regeneratorRuntime().mark((function e(t,r){var n,i,o,a=arguments;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=a.length>2&&void 0!==a[2]&&a[2],i=getServerNow(),logger$6.print("_join()"),e.prev=3,e.next=6,this._mediaServerClient.join(this._roomInfo,{node:this._getAccessNode,reason:this._getAccessFeedback,sessionId:this._sessionId,feedbackNode:this._getAccessFeedbackIceNode},n,this._liveControlMessage);case 6:o=e.sent,this._mediaServerClient.roomAttributes=o.roomAttributes,this._reconnectRecord.clear(),this._joinResolveCallback=void 0,this._joinRejectCallback=void 0,this._getAccessFeedback=void 0,this._getAccessNode=void 0,"function"==typeof t&&t({users:o.clients,streams:o.streams}),this._isReconnecting=!1,monitor.rtcJoinRoom(0,"web","web",getServerNow()-i),this._onJoinSucc(o,n),e.next=23;break;case 19:if(e.prev=19,e.t0=e.catch(3),e.t0.code===ErrorCode.OPERATION_CANCEL||"function"!=typeof r){e.next=23;break}return e.abrupt("return",r(e.t0));case 23:case"end":return e.stop()}}),e,this,[[3,19]])}))),function(e,t){return g.apply(this,arguments)})},{key:"publishScreen",value:(S=_asyncToGenerator(_regeneratorRuntime().mark((function e(t,r,n,i,o){var a,s,c,u,l,d,p,_,f,h;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(logger$6.print("publishScreen()"),this._localScreenStream||(this._localScreenStream=new LocalStream,this._localScreenStream.isScreen=!0,this._mediaServerClient.handler&&(this._localScreenStream.observer=new SendFrameObserver(this._localScreenStream,this._mediaServerClient.handler))),a=!1,s=!1,c=!1,u=!1,!this._localScreenStream.videoTrack&&r?(r instanceof CustomVideoLocalTrack&&(s=!0),a=!0):this._localScreenStream.videoTrack&&!r&&(a=!1),!this._localScreenStream.audioTrack&&n?(n instanceof CustomAudioLocalTrack&&(u=!0),c=!0):this._localScreenStream.audioTrack&&!n&&(c=!1),this._localScreenStream.videoTrack=r,this._localScreenStream.audioTrack=n,this._localScreenStream.videoEncodeConfig=t,i&&(audioInMediaType(i)&&(this._localScreenStream.pubAudio=o===PubState.PUB),videoInMediaType(i)&&(this._localScreenStream.pubVideo=o===PubState.PUB),logger$6.print("publishScreen mediaType","pubAudio: %o, pubVideo: %o",this._localScreenStream.pubAudio,this._localScreenStream.pubVideo)),this._localScreenStream.pubAudio||this._localScreenStream.pubVideo){e.next=18;break}if(null===(l=this._localScreenStream)||void 0===l||!l.hasPublished){e.next=17;break}return e.abrupt("return",this.unpublishScreen());case 17:return e.abrupt("return");case 18:if(this._localScreenStream.hasPublished){e.next=24;break}return null===(d=this._localScreenStream.observer)||void 0===d||d.setPublish(!0),e.next=22,this._mediaServerClient.publish(this._localScreenStream);case 22:e.next=28;break;case 24:return s?null===(p=this._localScreenStream.observer)||void 0===p||p.setPushVideo(a):null===(_=this._localScreenStream.observer)||void 0===_||_.setEnableVideo(a),u?null===(f=this._localScreenStream.observer)||void 0===f||f.setPushAudio(c):null===(h=this._localScreenStream.observer)||void 0===h||h.setEnableAudio(c),e.next=28,this.updatePubScreenTrack();case 28:case"end":return e.stop()}}),e,this)}))),function(e,t,r,n,i){return S.apply(this,arguments)})},{key:"updatePubScreenTrack",value:(v=_asyncToGenerator(_regeneratorRuntime().mark((function e(){return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(logger$6.print("updatePubScreenTrack","Invoke updatePubScreenTrack"),!this._localScreenStream){e.next=4;break}return e.next=4,this._mediaServerClient.updatePubTrack(this._localScreenStream);case 4:case"end":return e.stop()}}),e,this)}))),function(){return v.apply(this,arguments)})},{key:"unpublishScreen",value:(y=_asyncToGenerator(_regeneratorRuntime().mark((function e(){var t;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(logger$6.print("unpublish","Invoke unpublishScreen"),!this._localScreenStream){e.next=7;break}return null===(t=this._localScreenStream.observer)||void 0===t||t.setPublish(!1),e.next=5,this._mediaServerClient.unpublish(this._localScreenStream);case 5:this._localScreenStream.clean(),this._localScreenStream=void 0;case 7:case"end":return e.stop()}}),e,this)}))),function(){return y.apply(this,arguments)})},{key:"liveControlMessage",value:(m=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){var r,n=this;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return logger$6.print("controlMessage","Invoke controlMessage"),null===(r=t.transcodeMeta)||void 0===r||r.layout.regions.forEach((function(e){n.roomInfo&&(e.roomID=n.roomInfo.roomId)})),this._liveControlMessage=t,e.next=5,this._mediaServerClient.controlMessage(t);case 5:"stopped"===t.action&&delete this._liveControlMessage;case 6:case"end":return e.stop()}}),e,this)}))),function(e){return m.apply(this,arguments)})},{key:"publicStreamControlMessage",value:(h=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return"stopped"===t.action&&delete t.publicStreamMeta,e.next=3,this._mediaServerClient.controlMessage(t);case 3:case"end":return e.stop()}}),e,this)}))),function(e){return h.apply(this,arguments)})},{key:"updateUserAttributes",value:(f=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return logger$6.print("updateUserAttributes","Invoke updateUserAttributes"),t.role&&this._roomInfo&&(this._roomInfo.userInfo.role=t.role),e.next=4,this._mediaServerClient.updateUserAttributes(t);case 4:case"end":return e.stop()}}),e,this)}))),function(e){return f.apply(this,arguments)})},{key:"publish",value:(_=_asyncToGenerator(_regeneratorRuntime().mark((function e(t,r,n,i,o,a){var s,c,u,l,d,p,_,f,h,m,y,v,S=arguments;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(s=S.length>6&&void 0!==S[6]&&S[6],logger$6.print("publish","Invoke publish"),c=!1,this._localStream||(this._localStream=new LocalStream,this._mediaServerClient.handler&&(this._localStream.observer=new SendFrameObserver(this._localStream,this._mediaServerClient.handler)),c=!0),this._localStream.videoTrack=n,this._localStream.audioTrack=i,this._localStream.videoEncodeConfig=t,this._localStream.enableSimulcast=r,o&&(audioInMediaType(o)&&(this._localStream.pubAudio=a===PubState.PUB),videoInMediaType(o)&&(this._localStream.pubVideo=a===PubState.PUB),logger$6.print("publish mediaType","pubAudio: %o, pubVideo: %o",this._localStream.pubAudio,this._localStream.pubVideo)),this._localStream.hasPublished){e.next=26;break}if(this._localStream.pubAudio||this._localStream.pubVideo){e.next=12;break}return e.abrupt("return");case 12:return e.prev=12,s?null===(u=this._localStream.observer)||void 0===u||u.setLogin(!0):c&&(l=!!this._localStream.videoTrack,d=!!this._localStream.audioTrack,p=this._localStream.videoTrack instanceof CustomVideoLocalTrack,_=this._localStream.audioTrack instanceof CustomAudioLocalTrack,this._roomConfig.isAutoPublish&&!this._hasPublished?(l&&(p?null===(f=this._localStream.observer)||void 0===f||f.setPushVideo(!0):null===(h=this._localStream.observer)||void 0===h||h.setEnableVideo(!0)),d&&(_?null===(m=this._localStream.observer)||void 0===m||m.setPushAudio(!0):null===(y=this._localStream.observer)||void 0===y||y.setEnableAudio(!0))):null===(v=this._localStream.observer)||void 0===v||v.setPublish(!0)),e.next=16,this._mediaServerClient.publish(this._localStream);case 16:this._hasPublished=!0,this.emit(RoomEvent.ON_PUBLISH_RESULT,{isScreen:!1,state:PublishState.PUBLISH_SUCC}),e.next=24;break;case 20:throw e.prev=20,e.t0=e.catch(12),this.emit(RoomEvent.ON_PUBLISH_RESULT,{isScreen:!1,state:PublishState.PUBLISH_FAIL}),e.t0;case 24:e.next=28;break;case 26:return e.next=28,this.updatePubTrack();case 28:case"end":return e.stop()}}),e,this,[[12,20]])}))),function(e,t,r,n,i,o){return _.apply(this,arguments)})},{key:"updatePubTrack",value:(p=_asyncToGenerator(_regeneratorRuntime().mark((function e(){return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(logger$6.print("updatePubTrack","Invoke updatePubTrack"),!this._localStream){e.next=4;break}return e.next=4,this._mediaServerClient.updatePubTrack(this._localStream);case 4:case"end":return e.stop()}}),e,this)}))),function(){return p.apply(this,arguments)})},{key:"unpublish",value:(d=_asyncToGenerator(_regeneratorRuntime().mark((function e(){return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(logger$6.print("unpublish","Invoke unpublish"),!this._localStream){e.next=6;break}return e.next=4,this._mediaServerClient.unpublish(this._localStream);case 4:this._localStream.clean(),this._localStream=void 0;case 6:case"end":return e.stop()}}),e,this)}))),function(){return d.apply(this,arguments)})},{key:"subscribe",value:(l=_asyncToGenerator(_regeneratorRuntime().mark((function e(t,r,n){var i;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return logger$6.print("subscribe","remoteStream %o",t),i=void 0,n&&(i=this._getSubLayer(n,t)),e.next=5,this._mediaServerClient.subscribe(t,r,i);case 5:case"end":return e.stop()}}),e,this)}))),function(e,t,r){return l.apply(this,arguments)})},{key:"updateSubTrack",value:(u=_asyncToGenerator(_regeneratorRuntime().mark((function e(t,r,n,i){var o;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return logger$6.print("updateSubTrack","Invoke updateSubTrack"),e.abrupt("return",null===(o=this._mediaServerClient)||void 0===o?void 0:o.updateSubTrack(t,r,n,i));case 2:case"end":return e.stop()}}),e,this)}))),function(e,t,r,n){return u.apply(this,arguments)})},{key:"updateSubVideoConfig",value:(c=_asyncToGenerator(_regeneratorRuntime().mark((function e(t,r){var n,i,o,a,s;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if((a=this._findRemoteStreamByScreen(t,!1))&&a.hasSubscribed&&!((null==a||null===(n=a.attributes)||void 0===n||null===(i=n.videoDescriptions)||void 0===i?void 0:i.length)<=1)){e.next=3;break}return e.abrupt("return");case 3:return s=this._getSubLayer(r,a),a.originalStreamIndex=s.spatialLayer,e.abrupt("return",null===(o=this._mediaServerClient)||void 0===o?void 0:o.updateSubTrack(a,a.subMediaType,SubState.SUB,s));case 6:case"end":return e.stop()}}),e,this)}))),function(e,t){return c.apply(this,arguments)})},{key:"_getSubLayer",value:function(e,t){for(var r,n,i,o,a,s=null==t?void 0:t.attributes,c=s.videoDescriptions,u=s.subVideoDescriptions,l=Array.isArray(u)?u:c,d=-1,p=e.width*e.height,_=0;_<(null==l?void 0:l.length);_++){var f,h;if(p>=(null===(f=l[_])||void 0===f?void 0:f.width)*(null===(h=l[_])||void 0===h?void 0:h.height)){d=_;break}}var m=l[0];if(-1===d)m=l[d=l.length-1];else if(0!==d){var y=l[d-1].width*l[d-1].height,v=(y-p)/(y-l[d].width*l[d].height);m=v<.1?l[d-1]:l[d],d=v<.1?d-1:d}return a=null!==(r=null===(n=m)||void 0===n?void 0:n.sub_index)&&void 0!==r?r:-1,{spatialLayer:null!==(i=null===(o=m)||void 0===o?void 0:o.video_index)&&void 0!==i?i:d,spatialSubLayer:a}}},{key:"unsubscribe",value:(s=_asyncToGenerator(_regeneratorRuntime().mark((function e(t,r){return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return logger$6.print("unsubscribe","Invoke unsubscribe"),e.next=3,this._mediaServerClient.unsubscribe(t,r);case 3:case"end":return e.stop()}}),e,this)}))),function(e,t){return s.apply(this,arguments)})},{key:"leave",value:(a=_asyncToGenerator(_regeneratorRuntime().mark((function e(){var t,r,n,i,o,a,s=arguments;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=s.length>0&&void 0!==s[0]&&s[0],logger$6.print("leave","Invoke leave"),r=getServerNow(),e.prev=3,clearTimeout(this._reconnectTimer),n=_createForOfIteratorHelper(this._remoteStreams.values());try{for(n.s();!(i=n.n()).done;)o=i.value,Array.isArray(o)&&o.forEach((function(e){var t;null===(t=e.observer)||void 0===t||t.setLogin(!1)}))}catch(e){n.e(e)}finally{n.f()}return this._localStream&&(null===(a=this._localStream.observer)||void 0===a||a.setLogin(!1)),e.next=10,this._mediaServerClient.leave();case 10:this.destroy(),monitor.rtcLeaveRoom(0,"",getServerNow()-r),e.next=23;break;case 14:if(e.prev=14,e.t0=e.catch(3),e.t0 instanceof SDKError&&e.t0.code===ErrorCode.NOT_CONNECTED_YET&&this._joinRejectCallback&&this._joinRejectCallback(new Error(JoinroomReason.LEAVE_ROOM)),!t){e.next=21;break}throw e.t0;case 21:this.destroy();case 22:e.t0 instanceof Error&&monitor.rtcLeaveRoom(-1,e.t0.message,getServerNow()-r);case 23:case"end":return e.stop()}}),e,this,[[3,14]])}))),function(){return a.apply(this,arguments)})},{key:"setRemoteUserPriority",value:function(e,t){var r,n;null===(r=this.remoteStreams.get(e))||void 0===r||r.forEach((function(e){return e.setRemoteUserPriority(t)})),null===(n=this.userPriorityMap)||void 0===n||n.set(e,t)}},{key:"destroy",value:function(){logger$6.print("destroy","Invoke destroy"),this._destroyAndInitMediaServerClient(),this._roomInfo=void 0,this._remoteUsers=new Map;var e,t,r,n=_createForOfIteratorHelper(this._remoteStreams);try{for(n.s();!(e=n.n()).done;){var i=_slicedToArray(e.value,2)[1];Array.isArray(i)&&i.forEach((function(e){e&&e.clean()}))}}catch(e){n.e(e)}finally{n.f()}(this._remoteStreams=new Map,this._localStream)&&(null===(t=this._localStream)||void 0===t||t.clean(),this._localStream=void 0);this._localScreenStream&&(null===(r=this._localScreenStream)||void 0===r||r.clean(),this._localScreenStream=void 0);this._context=void 0,this._reconnectRecord=new ReconnectRecord,this._removeHandlerEventHandler(),clearTimeout(this._connectionLostTimer),this._userDuplicateLoginTimerMap.forEach((function(e){clearTimeout(e)})),this._userDuplicateLoginTimerMap.clear(),this._networkQualityManager.destroy(),this._videoSizeObserver.destroy(),this._subFallbackManager.destroy(),this._remoteStreamStreamIdUserIdMap={}}},{key:"updateToken",value:(o=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return logger$6.print("updateToken","Invoke updateToken"),this._roomInfo&&(this._roomInfo.token=t),e.next=4,this._mediaServerClient.updateToken(t);case 4:case"end":return e.stop()}}),e,this)}))),function(e){return o.apply(this,arguments)})},{key:"pauseAllSubscribedStream",value:(i=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){var r,n,i,o,a=this;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:r=[],n=_createForOfIteratorHelper(this._remoteStreams.values());try{for(n.s();!(i=n.n()).done;)o=i.value,Array.isArray(o)&&o.forEach((function(e){if(e.hasSubscribed){var n=a.updateSubTrack(e,t,SubState.UNSUB);n&&r.push(n)}}))}catch(e){n.e(e)}finally{n.f()}return e.abrupt("return",Promise.all(r));case 4:case"end":return e.stop()}}),e,this)}))),function(e){return i.apply(this,arguments)})},{key:"resumeAllSubscribedStream",value:(n=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){var r,n,i,o,a=this;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:r=[],n=_createForOfIteratorHelper(this._remoteStreams.values());try{for(n.s();!(i=n.n()).done;)o=i.value,Array.isArray(o)&&o.forEach((function(e){if(e.hasSubscribed&&e.hasSubscribed){var n=a.updateSubTrack(e,t,SubState.SUB);n&&r.push(n)}}))}catch(e){n.e(e)}finally{n.f()}return e.abrupt("return",Promise.all(r));case 4:case"end":return e.stop()}}),e,this)}))),function(e){return n.apply(this,arguments)})},{key:"sendUserMessage",value:function(e,t){var r;return null===(r=this._mediaServerClient)||void 0===r?void 0:r.sendUserMessage(e,t)}},{key:"setSessionId",value:function(){this._sessionId=v4(),commonStats.setStats({rtc_session_id:this._sessionId})}},{key:"sendRoomMessage",value:(r=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){var r,n,i,o,a=arguments;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(i=a.length>1&&void 0!==a[1]&&a[1],o={clientId:null===(r=this._roomInfo)||void 0===r?void 0:r.userInfo.userId,binary:i,message:""},!i){e.next=8;break}return e.next=5,Utils.ab2b64str(t);case 5:o.message=e.sent,e.next=9;break;case 8:o.message=t;case 9:return e.abrupt("return",null===(n=this._mediaServerClient)||void 0===n?void 0:n.sendRoomMessage(o));case 10:case"end":return e.stop()}}),e,this)}))),function(e){return r.apply(this,arguments)})},{key:"_destroyAndInitMediaServerClient",value:function(){logger$6.print("_destroyAndInitMediaServerClient()"),this._mediaServerClient&&(this._mediaServerClient.destroy(),this._removeHandlerEventHandler()),this._mediaServerClient=new MediaServerClient(this._context),this._addHandlerEventHandler()}},{key:"_onJoinSucc",value:function(e,t){var r,n=this;logger$6.print("JoinSuccess()"),this._serverConfig=e.config;var i=[],o=[],a=[],s=[];null===(r=e.clientsDetail)||void 0===r||r.forEach((function(t){if(t.attributes&&(t.attributes.serverMuteVideo&&n.safeEmit(RoomEvent.ON_VIDEO_STREAM_BANNED,{uid:t.clientId,banned:1===t.attributes.serverMuteVideo}),t.attributes.serverMuteAudio&&n.safeEmit(RoomEvent.ON_AUDIO_STREAM_BANNED,{uid:t.clientId,banned:1===t.attributes.serverMuteAudio})),t.clientId!==e.clientId){var r=n._remoteUsers.get(t.clientId);r?r._stillExist=!0:i.push(t)}}));var c,u=_createForOfIteratorHelper(this._remoteUsers.values());try{for(u.s();!(c=u.n()).done;){var l=c.value;l._stillExist||o.push({clientId:l.userId}),delete l._stillExist}}catch(e){u.e(e)}finally{u.f()}e.streams.forEach((function(e){var t=n._findRemoteStreamByScreen(e.clientId,e.screen);t?(t.stillExist=!0,t.streamId=e.streamId):s.push(e)}));var d,p=_createForOfIteratorHelper(this._remoteStreams.values());try{for(p.s();!(d=p.n()).done;){var _=d.value;Array.isArray(_)&&_.forEach((function(e){e.stillExist?delete e.stillExist:a.push({clientId:e.userId,streamId:e.streamId,message:RemoveStreamMessage.clientDisconnected})}))}}catch(e){p.e(e)}finally{p.f()}setTimeout((function(){o.forEach((function(e){return n._onUserDisconnection(e)})),i.forEach((function(e){return n._onUserConnection(e)})),a.forEach((function(e){return n._onRemoveStream(e)})),s.forEach((function(e){return n._onAddStream(e,!0,!1)})),t&&n._handleSendOrRecvStreamAfterReconnect()}))}},{key:"_handleSendOrRecvStreamAfterReconnect",value:function(){var e=this;this._localStream&&(this._localStream.clean(),this._mediaServerClient.publish(this._localStream).catch((function(e){}))),this._localScreenStream&&(this._localScreenStream.clean(),this._mediaServerClient.publish(this._localScreenStream).catch((function(e){})));var t,r=_createForOfIteratorHelper(this._remoteStreams.values());try{for(r.s();!(t=r.n()).done;){var n=t.value;Array.isArray(n)&&n.forEach(function(){var t=_asyncToGenerator(_regeneratorRuntime().mark((function t(r){return _regeneratorRuntime().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!r.hasSubscribed){t.next=15;break}return r.resetHasSubscribed(),t.prev=2,logger$6.print("start resubscribe ".concat(r.userId," with ").concat(r.subMediaType)),t.next=6,e._mediaServerClient.subscribe(r,r.subMediaType);case 6:logger$6.print("success resubscribe ".concat(r.userId," with ").concat(r.subMediaType)),e.safeEmit(RoomEvent.RESUBSCRIBE,{stream:r}),t.next=15;break;case 10:t.prev=10,t.t0=t.catch(2),logger$6.print("failed resubscribe ".concat(r.userId," with ").concat(r.subMediaType,", error:").concat(t.t0)),r.clean(),null==r||r.resetHasSubscribed();case 15:case"end":return t.stop()}}),t,null,[[2,10]])})));return function(e){return t.apply(this,arguments)}}())}}catch(e){r.e(e)}finally{r.f()}}},{key:"_findRemoteStream",value:function(e,t){var r=this._remoteStreams.get(e);return Array.isArray(r)?r.find((function(e){return e.streamId===t})):null}},{key:"_findRemoteStreamByScreen",value:function(e,t){var r=this._remoteStreams.get(e);return Array.isArray(r)?r.find((function(e){return e.isScreen===t})):null}},{key:"_onAddStream",value:function(e){var t,r=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];if(e.clientId!==(null===(t=this._roomInfo)||void 0===t?void 0:t.userInfo.userId)){var i=this._roomConfig,o=i.isAutoSubscribeAudio,a=i.isAutoSubscribeVideo,s=this._findRemoteStreamByScreen(e.clientId,e.screen);if(s&&s.streamId!==e.streamId){var c,u=null===(c=this._remoteStreams.get(e.clientId))||void 0===c?void 0:c.filter((function(e){return e.streamId!==s.streamId}));s.clean(),this._remoteStreams.set(e.clientId,u||[])}var l=this._findRemoteStream(e.clientId,e.streamId);if(this._remoteStreamStreamIdUserIdMap[e.streamId]=e.clientId,l)l.attributes=e.attributes;else{var d;l=new RemoteStream(e.clientId,e.streamId,e.screen,e.attributes,null===(d=this.userPriorityMap)||void 0===d?void 0:d.get(e.clientId)),this._initStreamListeners(l);var p=this._remoteStreams.get(e.clientId);p?p.push(l):this._remoteStreams.set(e.clientId,[l])}if(this._mediaServerClient.handler&&(l.observer=new RecvFrameObserver(l,this._mediaServerClient.handler)),!l.isScreen&&a){var _,f,h,m,y,v,S,g;if(n&&l.hasVideo)if(l.attributes.extvideo)null===(_=l.observer)||void 0===_||_.setExternalVideoSource(!0),null===(f=l.observer)||void 0===f||f.setPushVideo(!0);else null===(h=l.observer)||void 0===h||h.setExternalVideoSource(!1),null===(m=l.observer)||void 0===m||m.setPublishVideo(!0);if(n&&l.hasAudio&&o&&!this._mediaServerClient.roomAttributes.multiChatMode)if(l.attributes.extaudio)null===(y=l.observer)||void 0===y||y.setExternalAudioSource(!0),null===(v=l.observer)||void 0===v||v.setPushAudio(!0);else null===(S=l.observer)||void 0===S||S.setExternalAudioSource(!1),null===(g=l.observer)||void 0===g||g.setPublishAudio(!0);if(!0===r&&!1===n){var E,T=this._roomConfig,b=T.isAutoSubscribeAudio,R=T.isAutoSubscribeVideo;null===(E=l.observer)||void 0===E||E.setLogin(!0,{audio:!!b,video:!!R})}}return r&&this.safeEmit(SignalEvent.ON_ADD_STREAM,{stream:l}),l}}},{key:"_onUserConnection",value:function(e){var t;if(e.clientId!==(null===(t=this._roomInfo)||void 0===t?void 0:t.userInfo.userId)){var r=this._userDuplicateLoginTimerMap.get(e.clientId);if("number"==typeof r)return this._userDuplicateLoginTimerMap.delete(e.clientId),void self.clearTimeout(r);var n={userId:e.clientId,extraInfo:e.attributes.extra_info};this._remoteUsers.set(e.clientId,_objectSpread2({},n)),this.safeEmit(SignalEvent.USER_CONNECTION,{userInfo:n}),e.attributes&&(e.attributes.serverMuteVideo&&this.safeEmit(RoomEvent.ON_VIDEO_STREAM_BANNED,{uid:e.clientId,banned:1===e.attributes.serverMuteVideo}),e.attributes.serverMuteAudio&&this.safeEmit(RoomEvent.ON_AUDIO_STREAM_BANNED,{uid:e.clientId,banned:1===e.attributes.serverMuteAudio}))}}},{key:"_onUserDisconnection",value:function(e){var t,r=this,n=e.clientId,i=e.tag,o=e.code;if(n)if(n===(null===(t=this.roomInfo)||void 0===t?void 0:t.userInfo.userId)){var a=null;i===UserDisconnectionTag.kickedByAdmin?a=ErrorCode.KICKED_OUT:i===UserDisconnectionTag.onUserTokenDidExpire?a=ErrorCode.TOKEN_EXPIRED:i===UserDisconnectionTag.userDuplicateLogin&&(a=ErrorCode.DUPLICATE_LOGIN),o===UserDisconnectionCode.roomDismissByAdmin&&(a=ErrorCode.ROOM_DISMISS),a&&this.safeEmit(RoomEvent.ON_ROOM_ERROR,{errorCode:a})}else{var s=UserOfflineReason.DROPPED;i===UserDisconnectionTag.userLeave?s=UserOfflineReason.QUIT:i===UserDisconnectionTag.kickedByAdmin?s=UserOfflineReason.KICKED_BY_ADMIN:i===UserDisconnectionTag.roleChanged&&(s=UserOfflineReason.SWITCH_TO_INVISIBLE);var c=function(){var e;r._remoteUsers.delete(n),null===(e=r._remoteStreams.get(n))||void 0===e||e.forEach((function(e){r._onRemoveStream({clientId:e.userId,streamId:e.streamId,message:"client disconnected"})})),r._remoteStreams.delete(n),r.safeEmit(RoomEvent.ON_USER_LEAVE,{userInfo:{userId:n},reason:s})};if(i===UserDisconnectionTag.userDuplicateLogin){var u=this._userDuplicateLoginTimerMap.get(n);u&&self.clearTimeout(u);var l=self.setTimeout(c,5e3);this._userDuplicateLoginTimerMap.set(n,l)}else c()}}},{key:"_onRemoveStream",value:function(e){var t,r=this;if(e.clientId!==(null===(t=this._roomInfo)||void 0===t?void 0:t.userInfo.userId)){var n=this._remoteStreams.get(e.clientId);if(n){var i=n.find((function(t){return t.streamId===e.streamId}));if(i){var o,a,s;if(null===(o=this._mediaServerClient)||void 0===o||o.handleRemoveStream(i,e).then((function(){if(null==i||!i._workaround_1_){var t=r._remoteStreams.get(e.clientId);if(!t)return;t=t.filter((function(t){return t.streamId!==e.streamId})),r._remoteStreams.set(e.clientId,t)}})).finally((function(){r.safeEmit(SignalEvent.ON_REMOVE_STREAM,{stream:i,reason:e.message})})),i.hasVideo)null===(a=i.observer)||void 0===a||a.setPublishVideo(!1);if(i.hasAudio&&!this._mediaServerClient.roomAttributes.multiChatMode)null===(s=i.observer)||void 0===s||s.setPublishAudio(!1)}}}}},{key:"_onUpdateUserAttributes",value:function(e){e.attributes&&(e.attributes.serverMuteVideo&&this.safeEmit(RoomEvent.ON_VIDEO_STREAM_BANNED,{uid:e.clientId,banned:1===e.attributes.serverMuteVideo}),e.attributes.serverMuteAudio&&this.safeEmit(RoomEvent.ON_AUDIO_STREAM_BANNED,{uid:e.clientId,banned:1===e.attributes.serverMuteAudio}))}},{key:"_onUpdateRoomAttributes",value:function(e){e.roomAttributes&&(this._mediaServerClient.roomAttributes=_objectSpread2(_objectSpread2({},this._mediaServerClient.roomAttributes),e.roomAttributes))}},{key:"_onUpdateStreamAttributes",value:function(e){var t=this._roomConfig,r=t.isAutoSubscribeAudio,n=t.isAutoSubscribeVideo,i=e.clientId,o=e.streamId,a=e.attributes,s=this._findRemoteStream(i,o);if(s){var c,u,l=s.attributes,d=_objectSpread2(_objectSpread2({},l),a),p=!1,_=d.localaudio!==l.localaudio,f=!1,h=!1,m=d.localvideo!==l.localvideo,y=!1,v=ExtendMediaType.NONE,S=ExtendMediaType.NONE;if(d.audiostream!==l.audiostream&&(p=d.localaudio,f=!!d.audiostream,d.audiostream?v|=MediaType.AUDIO:S|=MediaType.AUDIO),d.videostream!==l.videostream&&(h=d.localvideo,y=!!d.videostream,d.videostream?v|=MediaType.VIDEO:S|=MediaType.VIDEO),v&&this.safeEmit(RoomEvent.ON_USER_PUBLISH_STATE_CHANGE,{userId:i,mediaType:v,isScreen:s.isScreen,pubState:PubState.PUB,remoteStream:s}),S&&this.safeEmit(RoomEvent.ON_USER_PUBLISH_STATE_CHANGE,{userId:i,mediaType:S,isScreen:s.isScreen,pubState:PubState.UNPUB,remoteStream:s}),d.localaudio!==l.localaudio)if(d.localaudio&&r){var g,E,T,b;if(d.extaudio)null===(g=s.observer)||void 0===g||g.setExternalAudioSource(!0),null===(E=s.observer)||void 0===E||E.setPushAudio(!0);else null===(T=s.observer)||void 0===T||T.setExternalAudioSource(!1),null===(b=s.observer)||void 0===b||b.setEnableAudio(!0);this.safeEmit(RoomEvent.ON_USER_START_AUDIO_CAPTURE,{userId:i})}else{var R,I,$,A;if(d.extaudio)null===(R=s.observer)||void 0===R||R.setExternalAudioSource(!0),null===(I=s.observer)||void 0===I||I.setPushAudio(!1);else null===($=s.observer)||void 0===$||$.setExternalAudioSource(!1),null===(A=s.observer)||void 0===A||A.setEnableAudio(!1);!s.isScreen&&this.safeEmit(RoomEvent.ON_USER_STOP_AUDIO_CAPTURE,{userId:i})}if(d.localvideo!==l.localvideo)if(d.localvideo&&n){var C,O,P,k;if(d.extvideo)null===(C=s.observer)||void 0===C||C.setExternalVideoSource(!0),null===(O=s.observer)||void 0===O||O.setPushVideo(!0);else null===(P=s.observer)||void 0===P||P.setExternalVideoSource(!1),null===(k=s.observer)||void 0===k||k.setEnableVideo(!0);this.safeEmit(RoomEvent.ON_USER_START_VIDEO_CAPTURE,{userId:i})}else{var w,N,D,M;if(d.extvideo)null===(w=s.observer)||void 0===w||w.setExternalVideoSource(!0),null===(N=s.observer)||void 0===N||N.setPushVideo(!1);else null===(D=s.observer)||void 0===D||D.setExternalVideoSource(!1),null===(M=s.observer)||void 0===M||M.setEnableVideo(!1);!s.isScreen&&this.safeEmit(RoomEvent.ON_USER_STOP_VIDEO_CAPTURE,{userId:i})}if(p&&!_)null===(c=s.observer)||void 0===c||c.setRemoteUnmuteAudio(f);if(h&&!m)null===(u=s.observer)||void 0===u||u.setRemoteUnmuteVideo(y);s.attributes=d}}},{key:"_onPushTrack",value:function(e){var t=this,r=e.clientId,n=e.streamId,i=this._findRemoteStream(r,n);i||(i=this._onAddStream(e,!1,!1)),this._mediaServerClient.subscribe4pushTrack(i,e).then((function(){return t.safeEmit(RoomEvent.SUBSCRIBE_PUSH_TRACK,{stream:i})})).catch((function(e){logger$6.print("subscribe push track failed: ".concat(e))}))}},{key:"_onRemoveTrack",value:function(e){var t=this,r=e.clientId,n=e.streamId,i=e.message,o=this._findRemoteStream(r,n);o&&this._mediaServerClient.unsubscribe4removeTrack(o,i).then((function(){if(o._workaround_1_){var e,i=null===(e=t._remoteStreams.get(r))||void 0===e?void 0:e.filter((function(e){return e.streamId!==n}));t._remoteStreams.set(r,i||[])}t.safeEmit(RoomEvent.REMOVE_PUSH_TRACK,{stream:o})})).catch((function(e){logger$6.print("remove push track failed: ".concat(e))}))}},{key:"_nodeChange",value:function(e){var t,r=e.nodes,n=e.reason;sdkCache.clearAccessNode(null===(t=this._roomInfo)||void 0===t?void 0:t.appId),this._destroyAndInitMediaServerClient(),Array.isArray(r)&&r.length?this._getAccessNode=r[0]:this._getAccessFeedback=n,monitor.rtcNodeChange(0,JSON.stringify(e),JSON.stringify(n)),this._joinResolveCallback&&this._joinRejectCallback?this._join(this._joinResolveCallback,this._joinRejectCallback):this._reconnect()}},{key:"_reconnect",value:function(){var e=this;this._isReconnecting=!0;var t,r=_createForOfIteratorHelper(this._remoteStreams.values());try{for(r.s();!(t=r.n()).done;){var n=t.value;Array.isArray(n)&&n.forEach((function(e){return e.clean()}))}}catch(e){r.e(e)}finally{r.f()}monitor.rtcReconnect(1002,RtcreconnectMessage.PEERCONNECTION_RECONNECTING,this._roomInfo.userInfo.userId,RtcreconnectReconnectType.PEERCONNECTION),this._join((function(){monitor.rtcReconnected(RtcreconnectedMessage.PEERCONNECTION_RECONNECTED,RtcreconnectedReconnectType.PEERCONNECTION)}),(function(t){e._reconnectRecord.record(t),e._reconnectRecord.shouldReconnect?(logger$6.print("Reconnecting error, will reconnect after 3s",t),e._reconnectTimer=window.setTimeout(e._reconnect.bind(e),3e3)):(e.safeEmit(RoomEvent.RECONNECT_FAILED),e.destroy())}),!0)}},{key:"_handleAbnormalDisconnection",value:function(){logger$6.print("on ABNORMAL_DISCONNECTION"),this._destroyAndInitMediaServerClient(),navigator.onLine?this._reconnect():this._reconnectTimer=window.setTimeout(this._reconnect.bind(this),3e3)}},{key:"_onConnectionStateChange",value:function(e){var t,r=this;if(e.next===MediaConnectionState.DISCONNECTED)t=ConnectionState.CONNECTION_STATE_DISCONNECTED;else if(e.next===MediaConnectionState.CONNECTED)clearTimeout(this._connectionLostTimer),t=this._isReconnecting?ConnectionState.CONNECTION_STATE_RECONNECTED:ConnectionState.CONNECTION_STATE_CONNECTED;else{if(e.next!==MediaConnectionState.CONNECTING)return;t=this._isReconnecting?ConnectionState.CONNECTION_STATE_RECONNECTING:ConnectionState.CONNECTION_STATE_CONNECTING}e.prev===MediaConnectionState.CONNECTED&&e.next===MediaConnectionState.DISCONNECTED&&(this._connectionLostTimer=window.setTimeout((function(){r.safeEmit(StateEvent.ON_CONNECTION_STATE_CHANGE,{state:ConnectionState.CONNECTION_STATE_LOST})}),1e4)),this._networkQualityManager.setConnectionState(e.next),this.safeEmit(StateEvent.ON_CONNECTION_STATE_CHANGE,{state:t})}},{key:"_initStreamListeners",value:function(e){var t=this;e.on("ontrack",(function(e){e.track})),e.on("onSEIMessage",(function(r){var n;t.emit(RoomEvent.ON_SEI_MESSAGED_RECEIVED,{sei:r,remoteStreamKey:{userId:e.userId,roomId:null===(n=t._roomInfo)||void 0===n?void 0:n.roomId,streamIndex:e.isScreen?StreamIndex.STREAM_INDEX_SCREEN:StreamIndex.STREAM_INDEX_MAIN}})}))}},{key:"_onCustomMessage",value:function(e){this.safeEmit(SignalEvent.ON_CUSTOM_MESSAGE,e)}},{key:"_onUserMessageReceived",value:function(e){this.safeEmit(SignalEvent.USER_MESSAGE_RECEIVED,{userId:e.from,message:e.msg})}},{key:"_onUserBinaryMessageReceived",value:function(e){this.safeEmit(SignalEvent.USER_BINARY_MESSAGE_RECEIVED,{userId:e.from,message:e.msg})}},{key:"_onPostProcessingMessage",value:function(e){if(e.body){var t=e.body,r=t.error||0,n=StreamMixingEventType.START,i=["success","parameter error","subscription timeout","ffmpeg error","cdn error","publish error"];if("2.0"===t.protocol){switch(t.eventType){case"TranscodeStarted":0!==t.error&&(n=StreamMixingEventType.START_FAILED);break;case"TranscodeStateChanged":n=0!==t.error?StreamMixingEventType.START_FAILED:StreamMixingEventType.START_SUCCESS;break;case"TranscodeStopped":n=0!==t.error?StreamMixingEventType.STOP_FAILED:StreamMixingEventType.STOP_SUCCESS;break;case"TranscodeUpdated":n=0!==t.error?StreamMixingEventType.UPDATE_FAILED:StreamMixingEventType.UPDATE_SUCCESS}this.safeEmit(SignalEvent.POST_PROCESSING_MESSAGE,{code:r,protocol:t.protocol,error:t.error,eventType:n,message:i[r]})}this.safeEmit(SignalEvent.POST_PROCESSING_MESSAGE,{code:r,message:i[r],type:e.type})}}},{key:"_onUserTokenWillExpire",value:function(){this.safeEmit(SignalEvent.ON_USER_TOKEN_WILL_EXPIRE,null)}},{key:"_onSceneConfig",value:function(e){var t=e.multiSceneConfig,r=RoomProfileMap[this._roomConfig.roomProfileType][1];if(t){var n,i,o=t[r];if(o&&o.engine_BAC)null===(n=this._context)||void 0===n||n.audioProfileManager.updateEngineBAC(o.engine_BAC);if(o&&o.engine_ANM)null===(i=this._context)||void 0===i||i.audioProfileManager.updateEngineANM(o.engine_ANM)}}},{key:"_onStreamFailed",value:(t=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){var r,n,i,o,a,s,c,u,l,d;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if("publish"!==t.type){e.next=11;break}if(s=void 0,(null===(r=this.localStream)||void 0===r?void 0:r.streamId)===t.streamId?s=this.localStream:(null===(n=this.localScreenStream)||void 0===n?void 0:n.streamId)===t.streamId&&(s=this.localScreenStream),s){e.next=5;break}return e.abrupt("return");case 5:return null===(i=s)||void 0===i||i.clean(),e.next=8,null===(o=this._mediaServerClient)||void 0===o?void 0:o.unpublish(s).catch((function(){}));case 8:null===(a=this._mediaServerClient)||void 0===a||a.publish(s).catch((function(){})),e.next=20;break;case 11:if("subscribe"!==t.type){e.next=20;break}if(c=this._remoteStreamStreamIdUserIdMap[t.streamId],!(u=this._findRemoteStream(c,t.streamId))){e.next=20;break}return e.next=17,null===(l=this._mediaServerClient)||void 0===l?void 0:l.unsubscribe(u,MediaType.AUDIO_AND_VIDEO);case 17:return e.next=19,null===(d=this._mediaServerClient)||void 0===d?void 0:d.subscribe(u,u.subMediaType,u.subLayer);case 19:this.safeEmit(RoomEvent.RESUBSCRIBE,{stream:u});case 20:case"end":return e.stop()}}),e,this)}))),function(e){return t.apply(this,arguments)})},{key:"_onStreamControlMessage",value:function(e){var t,r;e.type===StreamControlType.PushLimitWarn&&(null!==(t=this._localStream)&&void 0!==t&&t.pubAudio||null!==(r=this._localStream)&&void 0!==r&&r.pubVideo||this.unpublish())}},{key:"_onPublishOnDemand",value:function(e){var t,r,n,i,o;if(!1!==(null===(t=this._serverConfig)||void 0===t||null===(r=t.engine_VPM)||void 0===r||null===(n=r.ondemand)||void 0===n?void 0:n.enable)&&null!==(i=this._localStream)&&void 0!==i&&i.enableSimulcast&&null!==(o=this._localStream)&&void 0!==o&&o.videoTransceiver){var a,s,c=null===(a=this._localStream)||void 0===a?void 0:a.stream.id,u=null===(s=this._localStream)||void 0===s?void 0:s.videoTransceiver.sender,l=u.getParameters();if(Array.isArray(l.encodings)&&Array.isArray(e)){var d,p,_,f,h={};logger$6.print("_onPublishOnDemand","usedDescriptions: %o",e),e.forEach((function(e){var t;if(null!=e&&null!==(t=e.StreamIds)&&void 0!==t&&t.includes(c)){var r=null==e?void 0:e.Metadata.SubvideoIndex;h[r]=r}}));var m={};null===(d=this._localStream)||void 0===d||null===(p=d.subVideoDescriptions)||void 0===p||p.forEach((function(e){void 0!==h[e.sub_index]&&(m[e.video_index]=e)}));var y=(null===(_=u.track)||void 0===_||null===(f=_.getSettings())||void 0===f?void 0:f.height)||720,v=[];l.encodings=l.encodings.map((function(e){return e.rid&&(m[e.rid]?(e.active=!0,e.scaleResolutionDownBy=Math.max(y/m[e.rid].height,1),v.push({type:1,rid:e.rid,downBy:e.scaleResolutionDownBy})):(v.push({type:0,rid:e.rid}),e.active=!1)),e})),monitor.rtcInvokeStatus(JSON.stringify(v),0,"rscp",c,0)}u.setParameters(l)}}},{key:"_reportNetworkQuality",value:function(e,t){this._subFallbackManager.updateNetworkQuality(e,t),this.emit(RoomEvent.ON_NETWORK_QUALITY,e,t)}},{key:"_emitVideoSizeChange",value:function(e,t,r,n){var i;this.emit(RoomEvent.ON_REMOTE_VIDEO_SIZE_CHANGED,{roomId:null===(i=this.roomInfo)||void 0===i?void 0:i.roomId,userId:e,streamIndex:t?StreamIndex.STREAM_INDEX_SCREEN:StreamIndex.STREAM_INDEX_MAIN},{width:r,height:n})}},{key:"_emitSubscribeFallback",value:function(e){this.emit(RoomEvent.ON_SIMULCAST_SUBSCRIBE_FALLBACK,e)}}]),b}(),ReconnectRecord=function(){function e(){_classCallCheck(this,e),_defineProperty(this,"_all_201_count",void 0),_defineProperty(this,"_has_4xx",void 0),this._all_201_count=0,this._has_4xx=!1}return _createClass(e,[{key:"shouldReconnect",get:function(){return!(this._all_201_count>=3||this._has_4xx)}},{key:"record",value:function(e){var t=!1,r=!1;if(Array.isArray(e)){var n=0;e.map((function(e){var t,i,o;400<=(null===(t=e.error)||void 0===t?void 0:t.code)&&(null===(i=e.error)||void 0===i?void 0:i.code)<500&&(r=!0),201===(null===(o=e.error)||void 0===o?void 0:o.code)&&n++})),n===e.length&&(t=!0),t&&this._all_201_count++,r&&(this._has_4xx=!0)}}},{key:"clear",value:function(){this._all_201_count=0,this._has_4xx=!1}}]),e}(),createElement=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=document.createElement(e);return t.id&&(r.id=t.id),t.classList&&t.classList.forEach((function(e){r.classList.add(e)})),t.style&&Object.assign(r.style,t.style),t.attributes&&Object.entries(t.attributes).forEach((function(e){var t=_slicedToArray(e,2),n=t[0],i=t[1];"muted"===n?r.muted=!0:r.setAttribute(n,i)})),r},decorateElement=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return t.id&&(e.id=t.id),t.classList&&t.classList.forEach((function(t){e.classList.add(t)})),t.style&&Object.assign(e.style,t.style),t.attributes&&Object.entries(t.attributes).forEach((function(t){var r=_slicedToArray(t,2),n=r[0],i=r[1];e.setAttribute(n,i)})),e},logger$5=new Logger("Player",0),MEDIA_EVENTS=["play","playing","pause","ended","error","seeking","seeked","waiting","canplay","canplaythrough","durationchange","volumechange","loadedmetadata","loadeddata","loadstart","timeupdate"],AUDIO_ATTRIBUTES={playsinline:"","webkit-playsinline":""},VIDEO_ATTRIBUTES={playsinline:"","webkit-playsinline":"","x5-playsinline":"","x5-video-player-type":"h5","x-webkit-airplay":"allow",preload:"",muted:""},RecycleMedia=function(){function e(){_classCallCheck(this,e),_defineProperty(this,"videoCache",[]),_defineProperty(this,"audioCache",[])}return _createClass(e,[{key:"getOrCreate",value:function(e,t){var r="audio"===e?AUDIO_ATTRIBUTES:VIDEO_ATTRIBUTES;if("video"===e&&this.videoCache.length>0){var n=this.videoCache.pop();if(n)return decorateElement(n,{style:t,attributes:r}),n}else if("audio"===e&&this.audioCache.length>0){var i=this.audioCache.pop();if(i)return decorateElement(i,{style:t,attributes:r}),i}return createElement(e,{style:t,attributes:r})}},{key:"recycle",value:function(e){for(;e.attributes.length>0;)e.removeAttribute(e.attributes[0].name);e instanceof HTMLVideoElement?this.videoCache.push(e):this.audioCache.push(e)}}]),e}(),recycle=new RecycleMedia,VideoPlayer=function(e){_inherits(n,eventemitter3.exports.EventEmitter);var t,r=_createSuper(n);function n(e){var t;_classCallCheck(this,n),_defineProperty(_assertThisInitialized(t=r.call(this)),"_containerDom",void 0),_defineProperty(_assertThisInitialized(t),"_videoDom",void 0),_defineProperty(_assertThisInitialized(t),"__cumulativeTime",void 0),_defineProperty(_assertThisInitialized(t),"userId",void 0),_defineProperty(_assertThisInitialized(t),"renderMode",void 0),_defineProperty(_assertThisInitialized(t),"mirrorType",MirrorType.MIRROR_TYPE_NONE),_defineProperty(_assertThisInitialized(t),"isScreen",void 0),_defineProperty(_assertThisInitialized(t),"played",!1),_defineProperty(_assertThisInitialized(t),"_emitPlayFailed",!1),_defineProperty(_assertThisInitialized(t),"emitVideoEvent",(function(e){var r,n,i={type:"video",rawEvent:e,readyState:(null===(r=t._videoDom)||void 0===r?void 0:r.readyState)||0,userId:t.userId,eventName:e.type,currentTime:(null===(n=t._videoDom)||void 0===n?void 0:n.currentTime)||0,isScreen:t.isScreen};t.emit("playback_event",i)})),_defineProperty(_assertThisInitialized(t),"_internalPlay",(function(){var e;if(null!==(e=t._videoDom)&&void 0!==e&&e.paused){var r=t._videoDom.play();null!=r&&r.then&&r.catch((function(e){var r,n;t._emitPlayFailed||(t._emitPlayFailed=!0,monitor.rtcError("video autoplay failed, userId: ".concat(t.userId),-1e3),t.emit("playback_event",{type:"video",rawEvent:e,readyState:(null===(r=t._videoDom)||void 0===r?void 0:r.readyState)||0,userId:t.userId,eventName:"autoplay-error",currentTime:(null===(n=t._videoDom)||void 0===n?void 0:n.currentTime)||0}))}))}}));var i=e.renderDom,o=e.userId;t.renderMode=void 0!==e.renderMode?e.renderMode:VideoRenderMode.RENDER_MODE_FIT;var a="string"==typeof i?document.getElementById(i):i;if(!a)throw new SDKError(ErrorCode.CANT_FIND_DOM,"can't find dom");return t._containerDom=a,t.userId=o,t.isScreen=!!e.isScreen,t._initVideo(),t}return _createClass(n,[{key:"_initVideo",value:function(){this._videoDom||(this._videoDom=recycle.getOrCreate("video",{width:"100%",height:"100%"}),this._videoDom.id="".concat(this.userId,"_").concat(genUuid()),this.renderMode===VideoRenderMode.RENDER_MODE_FIT?this._videoDom.style.objectFit="contain":this._videoDom.style.objectFit="cover",this.mirror(this.mirrorType===MirrorType.MIRROR_TYPE_RENDER)),this._containerDom.appendChild(this._videoDom),this._initListeners()}},{key:"_initListeners",value:function(){var e=this;this._videoDom&&MEDIA_EVENTS.forEach((function(t){var r;null===(r=e._videoDom)||void 0===r||r.addEventListener(t,e.emitVideoEvent)}))}},{key:"_removeListeners",value:function(){var e=this;this._videoDom&&(MEDIA_EVENTS.forEach((function(t){var r;null===(r=e._videoDom)||void 0===r||r.removeEventListener(t,e.emitVideoEvent)})),this._videoDom.addEventListener("canplay",this._internalPlay),this._videoDom.addEventListener("loadeddata",this._internalPlay))}},{key:"_recordFrame",value:function(e){var t=this;this.on("playback_event",(function(r){var n,i=e.isScreen?1.5:.5;if("timeupdate"===r.eventName){if(e.isScreen,0===(null===(n=t._videoDom)||void 0===n?void 0:n.currentTime))return;if(void 0===t.__cumulativeTime)return void(t.__cumulativeTime=t._videoDom.currentTime);if(e.recordedVideoFrames||(e.recordedVideoFrames=[]),t._videoDom.currentTime>t.__cumulativeTime){var o=Math.floor(1e3*(t._videoDom.currentTime-t.__cumulativeTime)),a=t._videoDom.currentTime-t.__cumulativeTime>i;e.recordedVideoFrames.push({playTime:t._videoDom.currentTime,isStall:a,stallCount:a?1:0,stallDuration:o%2e3})}t.__cumulativeTime=t._videoDom.currentTime}}))}},{key:"playVideo",value:(t=_asyncToGenerator(_regeneratorRuntime().mark((function e(t,r){var n,i,o,a,s=this;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(o=this._videoDom,logger$5.print("playVideo","play video track: ".concat(this.userId)),!(o&&o.srcObject instanceof MediaStream&&o.srcObject.getTrackById(null===(n=t.getTrack())||void 0===n?void 0:n.id))){e.next=4;break}return e.abrupt("return");case 4:o||(this._initVideo(),o=this._videoDom),logger$5.print("playVideo","play video by dom: ".concat(null===(i=o)||void 0===i?void 0:i.id)),(a=new MediaStream).addTrack(t.getTrack()),o.srcObject=a,o&&!this._containerDom.contains(o)&&this._containerDom.appendChild(o),o.addEventListener("canplay",this._internalPlay),o.addEventListener("loadeddata",this._internalPlay),setTimeout((function(){return s._internalPlay()})),r&&this._recordFrame(r),this.played=!0;case 15:case"end":return e.stop()}}),e,this)}))),function(e,r){return t.apply(this,arguments)})},{key:"updateSrcObject",value:function(e){var t=e.getTrack();if(t&&this._videoDom){var r=new MediaStream;r.addTrack(t),this._videoDom.srcObject=r}}},{key:"manuallyPlay",value:function(){if(logger$5.print("Invoke VideoPlayer.manuallyPlay"),this._emitPlayFailed=!1,!this._videoDom)throw new SDKError(ErrorCode.INVALID_PARAMS,"Player not found");return this._videoDom.play()}},{key:"mirror",value:function(e){logger$5.print("mirror","".concat(this.userId," set mirror: ").concat(e)),this.mirrorType=e?MirrorType.MIRROR_TYPE_RENDER:MirrorType.MIRROR_TYPE_NONE,this._videoDom&&(this._videoDom.style.transform=e?"rotateY(180deg)":"")}},{key:"stop",value:function(){var e=this._containerDom;logger$5.print("stop","stop video track: ".concat(this.userId)),this._videoDom&&(this._videoDom.srcObject=null,e&&e.contains(this._videoDom)&&e.removeChild(this._videoDom)),this.__cumulativeTime=void 0,this.played=!1}},{key:"destroy",value:function(){logger$5.print("destroy","video player: ".concat(this.userId)),this.stop(),_get(_getPrototypeOf(n.prototype),"removeAllListeners",this).call(this),this._removeListeners(),this._videoDom&&(recycle.recycle(this._videoDom),delete this._videoDom)}},{key:"domElement",get:function(){return this._videoDom}}]),n}(),AudioPlayer=function(e){_inherits(i,eventemitter3.exports.EventEmitter);var t,r,n=_createSuper(i);function i(e){var t,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{divId:void 0,muted:!1},o=r.divId,a=r.muted;if(_classCallCheck(this,i),_defineProperty(_assertThisInitialized(t=n.call(this)),"_containerDom",void 0),_defineProperty(_assertThisInitialized(t),"_audioDom",void 0),_defineProperty(_assertThisInitialized(t),"_fakeAudioDom",void 0),_defineProperty(_assertThisInitialized(t),"userId",void 0),_defineProperty(_assertThisInitialized(t),"muted",!1),_defineProperty(_assertThisInitialized(t),"_emitPlayFailed",!1),_defineProperty(_assertThisInitialized(t),"played",!1),_defineProperty(_assertThisInitialized(t),"emitAudioEvent",(function(e){var r,n,i={type:"audio",rawEvent:e,readyState:(null===(r=t._audioDom)||void 0===r?void 0:r.readyState)||0,userId:t.userId,eventName:e.type,currentTime:(null===(n=t._audioDom)||void 0===n?void 0:n.currentTime)||0};t.emit("playback_event",i)})),_defineProperty(_assertThisInitialized(t),"_internalPlay",(function(){var e,r;if(reportRtcInvokeStatus("_internalPlay",{paused:null===(e=t._audioDom)||void 0===e?void 0:e.paused}),null!==(r=t._audioDom)&&void 0!==r&&r.paused)try{var n=t._audioDom.play();null!=n&&n.then&&n.catch((function(e){t._autoPlayError(e)})).then((function(){reportRtcInvokeStatus("_internalPlay successfully",{userId:t.userId})}))}catch(e){t._autoPlayError(e)}})),o){var s=document.getElementById(o);if(!s)throw new SDKError(ErrorCode.CANT_FIND_DOM,"can't find dom");t._containerDom=s}else t._containerDom=document.body;return t.userId=e,t.muted=a,t._initAudio(),t}return _createClass(i,[{key:"_initAudio",value:function(){this._audioDom||(this._audioDom=recycle.getOrCreate("audio",{display:"none"}),this._audioDom.volume=this.muted?0:1,this._audioDom.id="".concat(this.userId,"_").concat(genUuid()),this._containerDom.appendChild(this._audioDom)),this._initListeners()}},{key:"_initListeners",value:function(){var e=this;this._audioDom&&MEDIA_EVENTS.forEach((function(t){var r;null===(r=e._audioDom)||void 0===r||r.addEventListener(t,e.emitAudioEvent)}))}},{key:"_removeListeners",value:function(){var e=this;this._audioDom&&(MEDIA_EVENTS.forEach((function(t){var r;null===(r=e._audioDom)||void 0===r||r.removeEventListener(t,e.emitAudioEvent)})),this._audioDom.removeEventListener("canplay",this._internalPlay),this._audioDom.removeEventListener("loadeddata",this._internalPlay))}},{key:"playAudio",value:(r=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){var r,n,i,o,a,s=this;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(logger$5.print("playAudio","play audio track: ".concat(this.userId)),!((o=this._audioDom)&&o.srcObject instanceof MediaStream&&o.srcObject.getTrackById(null===(r=t.getTrack())||void 0===r?void 0:r.id))){e.next=4;break}return e.abrupt("return");case 4:o||(this._initAudio(),o=this._audioDom),(a=new MediaStream).addTrack(t.getTrack()),o.srcObject=a,null===(n=o)||void 0===n||n.addEventListener("canplay",this._internalPlay),null===(i=o)||void 0===i||i.addEventListener("loadeddata",this._internalPlay),setTimeout((function(){return s._internalPlay()})),this.played=!0;case 12:case"end":return e.stop()}}),e,this)}))),function(e){return r.apply(this,arguments)})},{key:"_autoPlayError",value:function(e){var t,r;this._emitPlayFailed||(this._emitPlayFailed=!0,monitor.rtcError("audio autoplay failed, userId: ".concat(this.userId,": ").concat(e.message),-1e3),this.emit("playback_event",{type:"audio",rawEvent:e,readyState:(null===(t=this._audioDom)||void 0===t?void 0:t.readyState)||0,userId:this.userId,eventName:"autoplay-error",currentTime:(null===(r=this._audioDom)||void 0===r?void 0:r.currentTime)||0}))}},{key:"manuallyPlay",value:function(){var e;if(logger$5.print("Invoke AudioPlayer.manuallyPlay"),this._emitPlayFailed=!1,!this._audioDom)throw new SDKError(ErrorCode.INVALID_PARAMS,"Player not found");this._audioDom.volume=1,null===(e=this._fakeAudioDom)||void 0===e||e.play();var t=this._audioDom.play();return null!=t&&t.then?t:Promise.resolve(t)}},{key:"setPlaybackDevice",value:(t=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return logger$5.print("setPlaybackDevice","setPlaybackDevice: ".concat(t)),e.next=3,detector.enumerateAudioPlaybackDevices();case 3:if(e.sent.map((function(e){return e.deviceId})).includes(t)&&this._audioDom&&this._audioDom.setSinkId){e.next=7;break}return e.abrupt("return");case 7:return e.next=9,this._audioDom.setSinkId(t);case 9:case"end":return e.stop()}}),e,this)}))),function(e){return t.apply(this,arguments)})},{key:"stop",value:function(){var e=this._containerDom;logger$5.print("stopAudio","stop audio track: ".concat(this.userId)),this._audioDom&&(this._audioDom.srcObject=null,e&&e.contains(this._audioDom)&&e.removeChild(this._audioDom)),this._fakeAudioDom&&(this._fakeAudioDom.srcObject=null,this._fakeAudioDom=void 0)}},{key:"domElement",get:function(){return this._audioDom}},{key:"destroy",value:function(){logger$5.print("destroy","audio player: ".concat(this.userId)),this.stop(),_get(_getPrototypeOf(i.prototype),"removeAllListeners",this).call(this),this._removeListeners(),this._audioDom&&(recycle.recycle(this._audioDom),delete this._audioDom)}}]),i}(),MessageStatisticsObserver=function(){function e(){_classCallCheck(this,e),_defineProperty(this,"_timer",void 0),_defineProperty(this,"userMessage",void 0),_defineProperty(this,"roomMessage",void 0),this.userMessage={},this.roomMessage={},this._setTimer()}return _createClass(e,[{key:"_setTimer",value:function(){var e=this;!function t(){e._reportAndgReset(),clearTimeout(e._timer),e._timer=setTimeout(t,1e4)}()}},{key:"_reportAndgReset",value:function(){this._report(),this._reset()}},{key:"_report",value:function(){var e=this;monitor.rtcMessageStatistics(Object.keys(this.userMessage).map((function(t){return e.userMessage[t]})),Object.keys(this.roomMessage).map((function(t){return e.roomMessage[t]})),"")}},{key:"_reset",value:function(){this.userMessage={},this.roomMessage={}}},{key:"_checkInitUserMessage",value:function(e,t){this.userMessage["".concat(t,"-").concat(e)]||(this.userMessage["".concat(t,"-").concat(e)]={dc_peer_user_id:e,dc_send_total:0,dc_recv_total:0,dc_send_ack:0,dc_send_fail:0,dc_cost_time:0,dc_cost_e2s:0,dc_cost_s2s:0,dc_least_time:1/0,dc_most_time:0,dc_cost_peer_s2e:0,dc_send_ack_100:0,dc_send_ack_200:0,dc_send_ack_400:0,dc_send_ack_1s:0,dc_message_type:t,dc_send_binary:0})}},{key:"_sendUserMessage",value:function(e,t,r){this._checkInitUserMessage(e,t),this.userMessage["".concat(t,"-").concat(e)].dc_send_total++,r&&this.userMessage["".concat(t,"-").concat(e)].dc_send_binary++}},{key:"_recvUserMessage",value:function(e,t){this._checkInitUserMessage(e,t),this.userMessage["".concat(t,"-").concat(e)].dc_recv_total++}},{key:"_sendUserFail",value:function(e,t){var r=this.userMessage["".concat(t,"-").concat(e)];r&&r.dc_send_fail++}},{key:"_sendUserAck",value:function(e,t,r,n,i){var o=this.userMessage["".concat(t,"-").concat(e)];o&&(o.dc_send_ack++,o.dc_cost_time+=r,o.dc_cost_s2s+=n||0,o.dc_cost_peer_s2e+=i,o.dc_cost_e2s+=r-(n||0)-i,r<=100?(o.dc_send_ack_100++,o.dc_send_ack_200++,o.dc_send_ack_400++,o.dc_send_ack_1s++):r<=200?(o.dc_send_ack_200++,o.dc_send_ack_400++,o.dc_send_ack_1s++):r<=400?(o.dc_send_ack_400++,o.dc_send_ack_1s++):r<=1e3&&o.dc_send_ack_1s++,r<o.dc_least_time&&(o.dc_least_time=r),r>o.dc_most_time&&(o.dc_most_time=r))}},{key:"sendRoomMessage",value:function(e,t){this.roomMessage[e]||(this.roomMessage[e]={dc_room_id:e,dc_send_total:0,dc_send_ack:0,dc_cost_time:0,dc_least_time:1/0,dc_most_time:0,dc_send_fail:0,dc_send_ack_100:0,dc_send_ack_200:0,dc_send_ack_400:0,dc_send_ack_1s:0,dc_send_binary:0}),this.roomMessage[e].dc_send_total++,t&&this.roomMessage[e].dc_send_binary++}},{key:"sendRoomFail",value:function(e){var t=this.roomMessage[e];t&&t.dc_send_fail++}},{key:"sendRoomAck",value:function(e,t){var r=this.roomMessage[e];r&&(r.dc_send_ack++,r.dc_cost_time+=t,t<r.dc_least_time&&(r.dc_least_time=t),t>r.dc_most_time&&(r.dc_most_time=t),t<=100?(r.dc_send_ack_100++,r.dc_send_ack_200++,r.dc_send_ack_400++,r.dc_send_ack_1s++):t<=200?(r.dc_send_ack_200++,r.dc_send_ack_400++,r.dc_send_ack_1s++):t<=400?(r.dc_send_ack_400++,r.dc_send_ack_1s++):t<=1e3&&r.dc_send_ack_1s++)}},{key:"sendP2PMessage",value:function(e,t){this._sendUserMessage(e,DcusermessageDcMessageType.P2P,t)}},{key:"recvP2PMessage",value:function(e){this._recvUserMessage(e,DcusermessageDcMessageType.P2P)}},{key:"sendP2PFail",value:function(e){this._sendUserFail(e,DcusermessageDcMessageType.P2P)}},{key:"sendP2PAck",value:function(e,t,r,n){this._sendUserAck(e,DcusermessageDcMessageType.P2P,t,r,n)}},{key:"sendP2POutRoomMessage",value:function(e,t){this._sendUserMessage(e,DcusermessageDcMessageType.P2P_OUTSIDE_ROOM,t)}},{key:"recvP2POutRoomMessage",value:function(e){this._recvUserMessage(e,DcusermessageDcMessageType.P2P_OUTSIDE_ROOM)}},{key:"sendP2POutRoomFail",value:function(e){this._sendUserFail(e,DcusermessageDcMessageType.P2P_OUTSIDE_ROOM)}},{key:"sendP2POutRoomAck",value:function(e,t,r,n){this._sendUserAck(e,DcusermessageDcMessageType.P2P_OUTSIDE_ROOM,t,r,n)}},{key:"sendP2serverMessage",value:function(e){this._sendUserMessage("",DcusermessageDcMessageType.P2SERVER,e)}},{key:"sendP2serverFail",value:function(){this._sendUserFail("",DcusermessageDcMessageType.P2SERVER)}},{key:"sendP2serveAck",value:function(e){this._sendUserAck("",DcusermessageDcMessageType.P2SERVER,e,0,0)}},{key:"countP2PMessage",value:function(e,t,r,n,i){this.sendP2PMessage(t,r),e?this.sendP2PAck(t,Date.now()-n,i.s2s_time,i.s2e_time):this.sendP2PFail(t)}},{key:"countRoomMessage",value:function(e,t,r,n){this.sendRoomMessage(t,r),e?this.sendRoomAck(t,Date.now()-n):this.sendRoomFail(t)}},{key:"countUserMessageOutsideRoom",value:function(e,t,r,n,i){this.sendP2POutRoomMessage(t,r),e?this.sendP2POutRoomAck(t,Date.now()-n,i.s2s_time,i.s2e_time):this.sendP2POutRoomFail(t)}},{key:"countServerMessage",value:function(e,t,r){this.sendP2serverMessage(t),e?this.sendP2serveAck(Date.now()-r):this.sendP2serverFail()}},{key:"destroy",value:function(){this._reset(),clearTimeout(this._timer)}}]),e}(),freeGlobal="object"==typeof global&&global&&global.Object===Object&&global,freeGlobal$1=freeGlobal,freeSelf="object"==typeof self&&self&&self.Object===Object&&self,root=freeGlobal$1||freeSelf||Function("return this")(),root$1=root,Symbol$1=root$1.Symbol,Symbol$2=Symbol$1,objectProto$8=Object.prototype,hasOwnProperty$6=objectProto$8.hasOwnProperty,nativeObjectToString$1=objectProto$8.toString,symToStringTag$1=Symbol$2?Symbol$2.toStringTag:void 0;function getRawTag(e){var t=hasOwnProperty$6.call(e,symToStringTag$1),r=e[symToStringTag$1];try{e[symToStringTag$1]=void 0;var n=!0}catch(e){}var i=nativeObjectToString$1.call(e);return n&&(t?e[symToStringTag$1]=r:delete e[symToStringTag$1]),i}var objectProto$7=Object.prototype,nativeObjectToString=objectProto$7.toString;function objectToString(e){return nativeObjectToString.call(e)}var nullTag="[object Null]",undefinedTag="[object Undefined]",symToStringTag=Symbol$2?Symbol$2.toStringTag:void 0;function baseGetTag(e){return null==e?void 0===e?undefinedTag:nullTag:symToStringTag&&symToStringTag in Object(e)?getRawTag(e):objectToString(e)}function isObjectLike(e){return null!=e&&"object"==typeof e}function arrayMap(e,t){for(var r=-1,n=null==e?0:e.length,i=Array(n);++r<n;)i[r]=t(e[r],r,e);return i}var isArray=Array.isArray,isArray$1=isArray;function isObject$1(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)}function identity(e){return e}var asyncTag="[object AsyncFunction]",funcTag$1="[object Function]",genTag="[object GeneratorFunction]",proxyTag="[object Proxy]";function isFunction(e){if(!isObject$1(e))return!1;var t=baseGetTag(e);return t==funcTag$1||t==genTag||t==asyncTag||t==proxyTag}var coreJsData=root$1["__core-js_shared__"],coreJsData$1=coreJsData,maskSrcKey=function(){var e=/[^.]+$/.exec(coreJsData$1&&coreJsData$1.keys&&coreJsData$1.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""}();function isMasked(e){return!!maskSrcKey&&maskSrcKey in e}var funcProto$1=Function.prototype,funcToString$1=funcProto$1.toString;function toSource(e){if(null!=e){try{return funcToString$1.call(e)}catch(e){}try{return e+""}catch(e){}}return""}var reRegExpChar=/[\\^$.*+?()[\]{}|]/g,reIsHostCtor=/^\[object .+?Constructor\]$/,funcProto=Function.prototype,objectProto$6=Object.prototype,funcToString=funcProto.toString,hasOwnProperty$5=objectProto$6.hasOwnProperty,reIsNative=RegExp("^"+funcToString.call(hasOwnProperty$5).replace(reRegExpChar,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function baseIsNative(e){return!(!isObject$1(e)||isMasked(e))&&(isFunction(e)?reIsNative:reIsHostCtor).test(toSource(e))}function getValue(e,t){return null==e?void 0:e[t]}function getNative(e,t){var r=getValue(e,t);return baseIsNative(r)?r:void 0}function apply(e,t,r){switch(r.length){case 0:return e.call(t);case 1:return e.call(t,r[0]);case 2:return e.call(t,r[0],r[1]);case 3:return e.call(t,r[0],r[1],r[2])}return e.apply(t,r)}var HOT_COUNT=800,HOT_SPAN=16,nativeNow=Date.now;function shortOut(e){var t=0,r=0;return function(){var n=nativeNow(),i=HOT_SPAN-(n-r);if(r=n,i>0){if(++t>=HOT_COUNT)return arguments[0]}else t=0;return e.apply(void 0,arguments)}}function constant(e){return function(){return e}}var defineProperty=function(){try{var e=getNative(Object,"defineProperty");return e({},"",{}),e}catch(e){}}(),defineProperty$1=defineProperty,baseSetToString=defineProperty$1?function(e,t){return defineProperty$1(e,"toString",{configurable:!0,enumerable:!1,value:constant(t),writable:!0})}:identity,baseSetToString$1=baseSetToString,setToString=shortOut(baseSetToString$1),setToString$1=setToString,MAX_SAFE_INTEGER$1=9007199254740991,reIsUint=/^(?:0|[1-9]\d*)$/;function isIndex(e,t){var r=typeof e;return!!(t=null==t?MAX_SAFE_INTEGER$1:t)&&("number"==r||"symbol"!=r&&reIsUint.test(e))&&e>-1&&e%1==0&&e<t}function baseAssignValue(e,t,r){"__proto__"==t&&defineProperty$1?defineProperty$1(e,t,{configurable:!0,enumerable:!0,value:r,writable:!0}):e[t]=r}function eq(e,t){return e===t||e!=e&&t!=t}var objectProto$5=Object.prototype,hasOwnProperty$4=objectProto$5.hasOwnProperty;function assignValue(e,t,r){var n=e[t];hasOwnProperty$4.call(e,t)&&eq(n,r)&&(void 0!==r||t in e)||baseAssignValue(e,t,r)}function copyObject(e,t,r,n){var i=!r;r||(r={});for(var o=-1,a=t.length;++o<a;){var s=t[o],c=n?n(r[s],e[s],s,r,e):void 0;void 0===c&&(c=e[s]),i?baseAssignValue(r,s,c):assignValue(r,s,c)}return r}var nativeMax=Math.max;function overRest(e,t,r){return t=nativeMax(void 0===t?e.length-1:t,0),function(){for(var n=arguments,i=-1,o=nativeMax(n.length-t,0),a=Array(o);++i<o;)a[i]=n[t+i];i=-1;for(var s=Array(t+1);++i<t;)s[i]=n[i];return s[t]=r(a),apply(e,this,s)}}function baseRest(e,t){return setToString$1(overRest(e,t,identity),e+"")}var MAX_SAFE_INTEGER=9007199254740991;function isLength(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=MAX_SAFE_INTEGER}function isArrayLike(e){return null!=e&&isLength(e.length)&&!isFunction(e)}function isIterateeCall(e,t,r){if(!isObject$1(r))return!1;var n=typeof t;return!!("number"==n?isArrayLike(r)&&isIndex(t,r.length):"string"==n&&t in r)&&eq(r[t],e)}function createAssigner(e){return baseRest((function(t,r){var n=-1,i=r.length,o=i>1?r[i-1]:void 0,a=i>2?r[2]:void 0;for(o=e.length>3&&"function"==typeof o?(i--,o):void 0,a&&isIterateeCall(r[0],r[1],a)&&(o=i<3?void 0:o,i=1),t=Object(t);++n<i;){var s=r[n];s&&e(t,s,n,o)}return t}))}var objectProto$4=Object.prototype;function isPrototype(e){var t=e&&e.constructor;return e===("function"==typeof t&&t.prototype||objectProto$4)}function baseTimes(e,t){for(var r=-1,n=Array(e);++r<e;)n[r]=t(r);return n}var argsTag$1="[object Arguments]";function baseIsArguments(e){return isObjectLike(e)&&baseGetTag(e)==argsTag$1}var objectProto$3=Object.prototype,hasOwnProperty$3=objectProto$3.hasOwnProperty,propertyIsEnumerable=objectProto$3.propertyIsEnumerable,isArguments=baseIsArguments(function(){return arguments}())?baseIsArguments:function(e){return isObjectLike(e)&&hasOwnProperty$3.call(e,"callee")&&!propertyIsEnumerable.call(e,"callee")},isArguments$1=isArguments;function stubFalse(){return!1}var freeExports$1="object"==typeof exports&&exports&&!exports.nodeType&&exports,freeModule$1=freeExports$1&&"object"==typeof module&&module&&!module.nodeType&&module,moduleExports$1=freeModule$1&&freeModule$1.exports===freeExports$1,Buffer=moduleExports$1?root$1.Buffer:void 0,nativeIsBuffer=Buffer?Buffer.isBuffer:void 0,isBuffer=nativeIsBuffer||stubFalse,isBuffer$1=isBuffer,argsTag="[object Arguments]",arrayTag="[object Array]",boolTag="[object Boolean]",dateTag="[object Date]",errorTag="[object Error]",funcTag="[object Function]",mapTag="[object Map]",numberTag="[object Number]",objectTag="[object Object]",regexpTag="[object RegExp]",setTag="[object Set]",stringTag="[object String]",weakMapTag="[object WeakMap]",arrayBufferTag="[object ArrayBuffer]",dataViewTag="[object DataView]",float32Tag="[object Float32Array]",float64Tag="[object Float64Array]",int8Tag="[object Int8Array]",int16Tag="[object Int16Array]",int32Tag="[object Int32Array]",uint8Tag="[object Uint8Array]",uint8ClampedTag="[object Uint8ClampedArray]",uint16Tag="[object Uint16Array]",uint32Tag="[object Uint32Array]",typedArrayTags={};function baseIsTypedArray(e){return isObjectLike(e)&&isLength(e.length)&&!!typedArrayTags[baseGetTag(e)]}function baseUnary(e){return function(t){return e(t)}}typedArrayTags[float32Tag]=typedArrayTags[float64Tag]=typedArrayTags[int8Tag]=typedArrayTags[int16Tag]=typedArrayTags[int32Tag]=typedArrayTags[uint8Tag]=typedArrayTags[uint8ClampedTag]=typedArrayTags[uint16Tag]=typedArrayTags[uint32Tag]=!0,typedArrayTags[argsTag]=typedArrayTags[arrayTag]=typedArrayTags[arrayBufferTag]=typedArrayTags[boolTag]=typedArrayTags[dataViewTag]=typedArrayTags[dateTag]=typedArrayTags[errorTag]=typedArrayTags[funcTag]=typedArrayTags[mapTag]=typedArrayTags[numberTag]=typedArrayTags[objectTag]=typedArrayTags[regexpTag]=typedArrayTags[setTag]=typedArrayTags[stringTag]=typedArrayTags[weakMapTag]=!1;var freeExports="object"==typeof exports&&exports&&!exports.nodeType&&exports,freeModule=freeExports&&"object"==typeof module&&module&&!module.nodeType&&module,moduleExports=freeModule&&freeModule.exports===freeExports,freeProcess=moduleExports&&freeGlobal$1.process,nodeUtil=function(){try{var e=freeModule&&freeModule.require&&freeModule.require("util").types;return e||freeProcess&&freeProcess.binding&&freeProcess.binding("util")}catch(e){}}(),nodeUtil$1=nodeUtil,nodeIsTypedArray=nodeUtil&&nodeUtil.isTypedArray,isTypedArray=nodeIsTypedArray?baseUnary(nodeIsTypedArray):baseIsTypedArray,isTypedArray$1=isTypedArray,objectProto$2=Object.prototype,hasOwnProperty$2=objectProto$2.hasOwnProperty;function arrayLikeKeys(e,t){var r=isArray$1(e),n=!r&&isArguments$1(e),i=!r&&!n&&isBuffer$1(e),o=!r&&!n&&!i&&isTypedArray$1(e),a=r||n||i||o,s=a?baseTimes(e.length,String):[],c=s.length;for(var u in e)!t&&!hasOwnProperty$2.call(e,u)||a&&("length"==u||i&&("offset"==u||"parent"==u)||o&&("buffer"==u||"byteLength"==u||"byteOffset"==u)||isIndex(u,c))||s.push(u);return s}function overArg(e,t){return function(r){return e(t(r))}}var nativeKeys=overArg(Object.keys,Object),nativeKeys$1=nativeKeys,objectProto$1=Object.prototype,hasOwnProperty$1=objectProto$1.hasOwnProperty;function baseKeys(e){if(!isPrototype(e))return nativeKeys$1(e);var t=[];for(var r in Object(e))hasOwnProperty$1.call(e,r)&&"constructor"!=r&&t.push(r);return t}function keys(e){return isArrayLike(e)?arrayLikeKeys(e):baseKeys(e)}function nativeKeysIn(e){var t=[];if(null!=e)for(var r in Object(e))t.push(r);return t}var objectProto=Object.prototype,hasOwnProperty=objectProto.hasOwnProperty;function baseKeysIn(e){if(!isObject$1(e))return nativeKeysIn(e);var t=isPrototype(e),r=[];for(var n in e)("constructor"!=n||!t&&hasOwnProperty.call(e,n))&&r.push(n);return r}function keysIn(e){return isArrayLike(e)?arrayLikeKeys(e,!0):baseKeysIn(e)}var assignIn=createAssigner((function(e,t){copyObject(t,keysIn(t),e)})),assignIn$1=assignIn;function baseValues(e,t){return arrayMap(t,(function(t){return e[t]}))}function values(e){return null==e?[]:baseValues(e,keys(e))}var fails=fails$U,wellKnownSymbol$1=wellKnownSymbol$u,IS_PURE=isPure,ITERATOR$1=wellKnownSymbol$1("iterator"),urlConstructorDetection=!fails((function(){var e=new URL("b?a=1&b=2&c=3","http://a"),t=e.searchParams,r="";return e.pathname="c%20d",t.forEach((function(e,n){t.delete("b"),r+=n+e})),IS_PURE&&!e.toJSON||!t.sort||"http://a/c%20d?a=1&c=3"!==e.href||"3"!==t.get("c")||"a=1"!==String(new URLSearchParams("?a=1"))||!t[ITERATOR$1]||"a"!==new URL("https://a@b").username||"b"!==new URLSearchParams(new URLSearchParams("a=b")).get("a")||"xn--e1aybc"!==new URL("http://тест").host||"#%D0%B1"!==new URL("http://a#б").hash||"a1c3"!==r||"x"!==new URL("http://x",void 0).host})),uncurryThis$2=functionUncurryThis,maxInt=2147483647,base=36,tMin=1,tMax=26,skew=38,damp=700,initialBias=72,initialN=128,delimiter="-",regexNonASCII=/[^\0-\u007E]/,regexSeparators=/[.\u3002\uFF0E\uFF61]/g,OVERFLOW_ERROR="Overflow: input needs wider integers to process",baseMinusTMin=base-tMin,$RangeError=RangeError,exec$1=uncurryThis$2(regexSeparators.exec),floor$1=Math.floor,fromCharCode=String.fromCharCode,charCodeAt=uncurryThis$2("".charCodeAt),join$2=uncurryThis$2([].join),push$2=uncurryThis$2([].push),replace$2=uncurryThis$2("".replace),split$2=uncurryThis$2("".split),toLowerCase$1=uncurryThis$2("".toLowerCase),ucs2decode=function(e){for(var t=[],r=0,n=e.length;r<n;){var i=charCodeAt(e,r++);if(i>=55296&&i<=56319&&r<n){var o=charCodeAt(e,r++);56320==(64512&o)?push$2(t,((1023&i)<<10)+(1023&o)+65536):(push$2(t,i),r--)}else push$2(t,i)}return t},digitToBasic=function(e){return e+22+75*(e<26)},adapt=function(e,t,r){var n=0;for(e=r?floor$1(e/damp):e>>1,e+=floor$1(e/t);e>baseMinusTMin*tMax>>1;)e=floor$1(e/baseMinusTMin),n+=base;return floor$1(n+(baseMinusTMin+1)*e/(e+skew))},encode=function(e){var t,r,n=[],i=(e=ucs2decode(e)).length,o=initialN,a=0,s=initialBias;for(t=0;t<e.length;t++)(r=e[t])<128&&push$2(n,fromCharCode(r));var c=n.length,u=c;for(c&&push$2(n,delimiter);u<i;){var l=maxInt;for(t=0;t<e.length;t++)(r=e[t])>=o&&r<l&&(l=r);var d=u+1;if(l-o>floor$1((maxInt-a)/d))throw $RangeError(OVERFLOW_ERROR);for(a+=(l-o)*d,o=l,t=0;t<e.length;t++){if((r=e[t])<o&&++a>maxInt)throw $RangeError(OVERFLOW_ERROR);if(r==o){for(var p=a,_=base;;){var f=_<=s?tMin:_>=s+tMax?tMax:_-s;if(p<f)break;var h=p-f,m=base-f;push$2(n,fromCharCode(digitToBasic(f+h%m))),p=floor$1(h/m),_+=base}push$2(n,fromCharCode(digitToBasic(p))),s=adapt(a,d,u==c),a=0,u++}}a++,o++}return join$2(n,"")},stringPunycodeToAscii=function(e){var t,r,n=[],i=split$2(replace$2(toLowerCase$1(e),regexSeparators,"."),".");for(t=0;t<i.length;t++)r=i[t],push$2(n,exec$1(regexNonASCII,r)?"xn--"+encode(r):r);return join$2(n,".")},$$1=_export,global$2=global$K,call=functionCall,uncurryThis$1=functionUncurryThis,DESCRIPTORS$1=descriptors,USE_NATIVE_URL$1=urlConstructorDetection,defineBuiltIn$1=defineBuiltIn$j,defineBuiltIns=defineBuiltIns$5,setToStringTag$1=setToStringTag$a,createIteratorConstructor=iteratorCreateConstructor,InternalStateModule$1=internalState,anInstance$1=anInstance$a,isCallable=isCallable$t,hasOwn$1=hasOwnProperty_1,bind$1=functionBindContext,classof=classof$i,anObject=anObject$q,isObject=isObject$s,$toString$1=toString$m,create=objectCreate,createPropertyDescriptor=createPropertyDescriptor$b,getIterator=getIterator$4,getIteratorMethod=getIteratorMethod$5,validateArgumentsLength$1=validateArgumentsLength$3,wellKnownSymbol=wellKnownSymbol$u,arraySort=arraySort$1,ITERATOR=wellKnownSymbol("iterator"),URL_SEARCH_PARAMS="URLSearchParams",URL_SEARCH_PARAMS_ITERATOR=URL_SEARCH_PARAMS+"Iterator",setInternalState$1=InternalStateModule$1.set,getInternalParamsState=InternalStateModule$1.getterFor(URL_SEARCH_PARAMS),getInternalIteratorState=InternalStateModule$1.getterFor(URL_SEARCH_PARAMS_ITERATOR),getOwnPropertyDescriptor=Object.getOwnPropertyDescriptor,safeGetBuiltIn=function(e){if(!DESCRIPTORS$1)return global$2[e];var t=getOwnPropertyDescriptor(global$2,e);return t&&t.value},nativeFetch=safeGetBuiltIn("fetch"),NativeRequest=safeGetBuiltIn("Request"),Headers=safeGetBuiltIn("Headers"),RequestPrototype=NativeRequest&&NativeRequest.prototype,HeadersPrototype=Headers&&Headers.prototype,RegExp$1=global$2.RegExp,TypeError$2=global$2.TypeError,decodeURIComponent=global$2.decodeURIComponent,encodeURIComponent$1=global$2.encodeURIComponent,charAt$1=uncurryThis$1("".charAt),join$1=uncurryThis$1([].join),push$1=uncurryThis$1([].push),replace$1=uncurryThis$1("".replace),shift$1=uncurryThis$1([].shift),splice=uncurryThis$1([].splice),split$1=uncurryThis$1("".split),stringSlice$1=uncurryThis$1("".slice),plus=/\+/g,sequences=Array(4),percentSequence=function(e){return sequences[e-1]||(sequences[e-1]=RegExp$1("((?:%[\\da-f]{2}){"+e+"})","gi"))},percentDecode=function(e){try{return decodeURIComponent(e)}catch(t){return e}},deserialize=function(e){var t=replace$1(e,plus," "),r=4;try{return decodeURIComponent(t)}catch(e){for(;r;)t=replace$1(t,percentSequence(r--),percentDecode);return t}},find=/[!'()~]|%20/g,replacements={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+"},replacer=function(e){return replacements[e]},serialize=function(e){return replace$1(encodeURIComponent$1(e),find,replacer)},URLSearchParamsIterator=createIteratorConstructor((function(e,t){setInternalState$1(this,{type:URL_SEARCH_PARAMS_ITERATOR,iterator:getIterator(getInternalParamsState(e).entries),kind:t})}),"Iterator",(function(){var e=getInternalIteratorState(this),t=e.kind,r=e.iterator.next(),n=r.value;return r.done||(r.value="keys"===t?n.key:"values"===t?n.value:[n.key,n.value]),r}),!0),URLSearchParamsState=function(e){this.entries=[],this.url=null,void 0!==e&&(isObject(e)?this.parseObject(e):this.parseQuery("string"==typeof e?"?"===charAt$1(e,0)?stringSlice$1(e,1):e:$toString$1(e)))};URLSearchParamsState.prototype={type:URL_SEARCH_PARAMS,bindURL:function(e){this.url=e,this.update()},parseObject:function(e){var t,r,n,i,o,a,s,c=getIteratorMethod(e);if(c)for(r=(t=getIterator(e,c)).next;!(n=call(r,t)).done;){if(o=(i=getIterator(anObject(n.value))).next,(a=call(o,i)).done||(s=call(o,i)).done||!call(o,i).done)throw TypeError$2("Expected sequence with length 2");push$1(this.entries,{key:$toString$1(a.value),value:$toString$1(s.value)})}else for(var u in e)hasOwn$1(e,u)&&push$1(this.entries,{key:u,value:$toString$1(e[u])})},parseQuery:function(e){if(e)for(var t,r,n=split$1(e,"&"),i=0;i<n.length;)(t=n[i++]).length&&(r=split$1(t,"="),push$1(this.entries,{key:deserialize(shift$1(r)),value:deserialize(join$1(r,"="))}))},serialize:function(){for(var e,t=this.entries,r=[],n=0;n<t.length;)e=t[n++],push$1(r,serialize(e.key)+"="+serialize(e.value));return join$1(r,"&")},update:function(){this.entries.length=0,this.parseQuery(this.url.query)},updateURL:function(){this.url&&this.url.update()}};var URLSearchParamsConstructor=function(){anInstance$1(this,URLSearchParamsPrototype);var e=arguments.length>0?arguments[0]:void 0;setInternalState$1(this,new URLSearchParamsState(e))},URLSearchParamsPrototype=URLSearchParamsConstructor.prototype;if(defineBuiltIns(URLSearchParamsPrototype,{append:function(e,t){validateArgumentsLength$1(arguments.length,2);var r=getInternalParamsState(this);push$1(r.entries,{key:$toString$1(e),value:$toString$1(t)}),r.updateURL()},delete:function(e){validateArgumentsLength$1(arguments.length,1);for(var t=getInternalParamsState(this),r=t.entries,n=$toString$1(e),i=0;i<r.length;)r[i].key===n?splice(r,i,1):i++;t.updateURL()},get:function(e){validateArgumentsLength$1(arguments.length,1);for(var t=getInternalParamsState(this).entries,r=$toString$1(e),n=0;n<t.length;n++)if(t[n].key===r)return t[n].value;return null},getAll:function(e){validateArgumentsLength$1(arguments.length,1);for(var t=getInternalParamsState(this).entries,r=$toString$1(e),n=[],i=0;i<t.length;i++)t[i].key===r&&push$1(n,t[i].value);return n},has:function(e){validateArgumentsLength$1(arguments.length,1);for(var t=getInternalParamsState(this).entries,r=$toString$1(e),n=0;n<t.length;)if(t[n++].key===r)return!0;return!1},set:function(e,t){validateArgumentsLength$1(arguments.length,1);for(var r,n=getInternalParamsState(this),i=n.entries,o=!1,a=$toString$1(e),s=$toString$1(t),c=0;c<i.length;c++)(r=i[c]).key===a&&(o?splice(i,c--,1):(o=!0,r.value=s));o||push$1(i,{key:a,value:s}),n.updateURL()},sort:function(){var e=getInternalParamsState(this);arraySort(e.entries,(function(e,t){return e.key>t.key?1:-1})),e.updateURL()},forEach:function(e){for(var t,r=getInternalParamsState(this).entries,n=bind$1(e,arguments.length>1?arguments[1]:void 0),i=0;i<r.length;)n((t=r[i++]).value,t.key,this)},keys:function(){return new URLSearchParamsIterator(this,"keys")},values:function(){return new URLSearchParamsIterator(this,"values")},entries:function(){return new URLSearchParamsIterator(this,"entries")}},{enumerable:!0}),defineBuiltIn$1(URLSearchParamsPrototype,ITERATOR,URLSearchParamsPrototype.entries,{name:"entries"}),defineBuiltIn$1(URLSearchParamsPrototype,"toString",(function(){return getInternalParamsState(this).serialize()}),{enumerable:!0}),setToStringTag$1(URLSearchParamsConstructor,URL_SEARCH_PARAMS),$$1({global:!0,constructor:!0,forced:!USE_NATIVE_URL$1},{URLSearchParams:URLSearchParamsConstructor}),!USE_NATIVE_URL$1&&isCallable(Headers)){var headersHas=uncurryThis$1(HeadersPrototype.has),headersSet=uncurryThis$1(HeadersPrototype.set),wrapRequestOptions=function(e){if(isObject(e)){var t,r=e.body;if(classof(r)===URL_SEARCH_PARAMS)return t=e.headers?new Headers(e.headers):new Headers,headersHas(t,"content-type")||headersSet(t,"content-type","application/x-www-form-urlencoded;charset=UTF-8"),create(e,{body:createPropertyDescriptor(0,$toString$1(r)),headers:createPropertyDescriptor(0,t)})}return e};if(isCallable(nativeFetch)&&$$1({global:!0,enumerable:!0,dontCallGetSet:!0,forced:!0},{fetch:function(e){return nativeFetch(e,arguments.length>1?wrapRequestOptions(arguments[1]):{})}}),isCallable(NativeRequest)){var RequestConstructor=function(e){return anInstance$1(this,RequestPrototype),new NativeRequest(e,arguments.length>1?wrapRequestOptions(arguments[1]):{})};RequestPrototype.constructor=RequestConstructor,RequestConstructor.prototype=RequestPrototype,$$1({global:!0,constructor:!0,dontCallGetSet:!0,forced:!0},{Request:RequestConstructor})}}var EOF,web_urlSearchParams_constructor={URLSearchParams:URLSearchParamsConstructor,getState:getInternalParamsState},$=_export,DESCRIPTORS=descriptors,USE_NATIVE_URL=urlConstructorDetection,global$1=global$K,bind=functionBindContext,uncurryThis=functionUncurryThis,defineBuiltIn=defineBuiltIn$j,defineBuiltInAccessor=defineBuiltInAccessor$5,anInstance=anInstance$a,hasOwn=hasOwnProperty_1,assign=objectAssign,arrayFrom=arrayFrom$1,arraySlice=arraySliceSimple,codeAt=stringMultibyte.codeAt,toASCII=stringPunycodeToAscii,$toString=toString$m,setToStringTag=setToStringTag$a,validateArgumentsLength=validateArgumentsLength$3,URLSearchParamsModule=web_urlSearchParams_constructor,InternalStateModule=internalState,setInternalState=InternalStateModule.set,getInternalURLState=InternalStateModule.getterFor("URL"),URLSearchParams$1=URLSearchParamsModule.URLSearchParams,getInternalSearchParamsState=URLSearchParamsModule.getState,NativeURL=global$1.URL,TypeError$1=global$1.TypeError,parseInt$1=global$1.parseInt,floor=Math.floor,pow=Math.pow,charAt=uncurryThis("".charAt),exec=uncurryThis(/./.exec),join=uncurryThis([].join),numberToString=uncurryThis(1..toString),pop=uncurryThis([].pop),push=uncurryThis([].push),replace=uncurryThis("".replace),shift=uncurryThis([].shift),split=uncurryThis("".split),stringSlice=uncurryThis("".slice),toLowerCase=uncurryThis("".toLowerCase),unshift=uncurryThis([].unshift),INVALID_AUTHORITY="Invalid authority",INVALID_SCHEME="Invalid scheme",INVALID_HOST="Invalid host",INVALID_PORT="Invalid port",ALPHA=/[a-z]/i,ALPHANUMERIC=/[\d+-.a-z]/i,DIGIT=/\d/,HEX_START=/^0x/i,OCT=/^[0-7]+$/,DEC=/^\d+$/,HEX=/^[\da-f]+$/i,FORBIDDEN_HOST_CODE_POINT=/[\0\t\n\r #%/:<>?@[\\\]^|]/,FORBIDDEN_HOST_CODE_POINT_EXCLUDING_PERCENT=/[\0\t\n\r #/:<>?@[\\\]^|]/,LEADING_AND_TRAILING_C0_CONTROL_OR_SPACE=/^[\u0000-\u0020]+|[\u0000-\u0020]+$/g,TAB_AND_NEW_LINE=/[\t\n\r]/g,parseIPv4=function(e){var t,r,n,i,o,a,s,c=split(e,".");if(c.length&&""==c[c.length-1]&&c.length--,(t=c.length)>4)return e;for(r=[],n=0;n<t;n++){if(""==(i=c[n]))return e;if(o=10,i.length>1&&"0"==charAt(i,0)&&(o=exec(HEX_START,i)?16:8,i=stringSlice(i,8==o?1:2)),""===i)a=0;else{if(!exec(10==o?DEC:8==o?OCT:HEX,i))return e;a=parseInt$1(i,o)}push(r,a)}for(n=0;n<t;n++)if(a=r[n],n==t-1){if(a>=pow(256,5-t))return null}else if(a>255)return null;for(s=pop(r),n=0;n<r.length;n++)s+=r[n]*pow(256,3-n);return s},parseIPv6=function(e){var t,r,n,i,o,a,s,c=[0,0,0,0,0,0,0,0],u=0,l=null,d=0,p=function(){return charAt(e,d)};if(":"==p()){if(":"!=charAt(e,1))return;d+=2,l=++u}for(;p();){if(8==u)return;if(":"!=p()){for(t=r=0;r<4&&exec(HEX,p());)t=16*t+parseInt$1(p(),16),d++,r++;if("."==p()){if(0==r)return;if(d-=r,u>6)return;for(n=0;p();){if(i=null,n>0){if(!("."==p()&&n<4))return;d++}if(!exec(DIGIT,p()))return;for(;exec(DIGIT,p());){if(o=parseInt$1(p(),10),null===i)i=o;else{if(0==i)return;i=10*i+o}if(i>255)return;d++}c[u]=256*c[u]+i,2!=++n&&4!=n||u++}if(4!=n)return;break}if(":"==p()){if(d++,!p())return}else if(p())return;c[u++]=t}else{if(null!==l)return;d++,l=++u}}if(null!==l)for(a=u-l,u=7;0!=u&&a>0;)s=c[u],c[u--]=c[l+a-1],c[l+--a]=s;else if(8!=u)return;return c},findLongestZeroSequence=function(e){for(var t=null,r=1,n=null,i=0,o=0;o<8;o++)0!==e[o]?(i>r&&(t=n,r=i),n=null,i=0):(null===n&&(n=o),++i);return i>r&&(t=n,r=i),t},serializeHost=function(e){var t,r,n,i;if("number"==typeof e){for(t=[],r=0;r<4;r++)unshift(t,e%256),e=floor(e/256);return join(t,".")}if("object"==typeof e){for(t="",n=findLongestZeroSequence(e),r=0;r<8;r++)i&&0===e[r]||(i&&(i=!1),n===r?(t+=r?":":"::",i=!0):(t+=numberToString(e[r],16),r<7&&(t+=":")));return"["+t+"]"}return e},C0ControlPercentEncodeSet={},fragmentPercentEncodeSet=assign({},C0ControlPercentEncodeSet,{" ":1,'"':1,"<":1,">":1,"`":1}),pathPercentEncodeSet=assign({},fragmentPercentEncodeSet,{"#":1,"?":1,"{":1,"}":1}),userinfoPercentEncodeSet=assign({},pathPercentEncodeSet,{"/":1,":":1,";":1,"=":1,"@":1,"[":1,"\\":1,"]":1,"^":1,"|":1}),percentEncode=function(e,t){var r=codeAt(e,0);return r>32&&r<127&&!hasOwn(t,e)?e:encodeURIComponent(e)},specialSchemes={ftp:21,file:null,http:80,https:443,ws:80,wss:443},isWindowsDriveLetter=function(e,t){var r;return 2==e.length&&exec(ALPHA,charAt(e,0))&&(":"==(r=charAt(e,1))||!t&&"|"==r)},startsWithWindowsDriveLetter=function(e){var t;return e.length>1&&isWindowsDriveLetter(stringSlice(e,0,2))&&(2==e.length||"/"===(t=charAt(e,2))||"\\"===t||"?"===t||"#"===t)},isSingleDot=function(e){return"."===e||"%2e"===toLowerCase(e)},isDoubleDot=function(e){return".."===(e=toLowerCase(e))||"%2e."===e||".%2e"===e||"%2e%2e"===e},SCHEME_START={},SCHEME={},NO_SCHEME={},SPECIAL_RELATIVE_OR_AUTHORITY={},PATH_OR_AUTHORITY={},RELATIVE={},RELATIVE_SLASH={},SPECIAL_AUTHORITY_SLASHES={},SPECIAL_AUTHORITY_IGNORE_SLASHES={},AUTHORITY={},HOST={},HOSTNAME={},PORT={},FILE={},FILE_SLASH={},FILE_HOST={},PATH_START={},PATH={},CANNOT_BE_A_BASE_URL_PATH={},QUERY={},FRAGMENT={},URLState=function(e,t,r){var n,i,o,a=$toString(e);if(t){if(i=this.parse(a))throw TypeError$1(i);this.searchParams=null}else{if(void 0!==r&&(n=new URLState(r,!0)),i=this.parse(a,null,n))throw TypeError$1(i);(o=getInternalSearchParamsState(new URLSearchParams$1)).bindURL(this),this.searchParams=o}};URLState.prototype={type:"URL",parse:function(e,t,r){var n,i,o,a,s=this,c=t||SCHEME_START,u=0,l="",d=!1,p=!1,_=!1;for(e=$toString(e),t||(s.scheme="",s.username="",s.password="",s.host=null,s.port=null,s.path=[],s.query=null,s.fragment=null,s.cannotBeABaseURL=!1,e=replace(e,LEADING_AND_TRAILING_C0_CONTROL_OR_SPACE,"")),e=replace(e,TAB_AND_NEW_LINE,""),n=arrayFrom(e);u<=n.length;){switch(i=n[u],c){case SCHEME_START:if(!i||!exec(ALPHA,i)){if(t)return INVALID_SCHEME;c=NO_SCHEME;continue}l+=toLowerCase(i),c=SCHEME;break;case SCHEME:if(i&&(exec(ALPHANUMERIC,i)||"+"==i||"-"==i||"."==i))l+=toLowerCase(i);else{if(":"!=i){if(t)return INVALID_SCHEME;l="",c=NO_SCHEME,u=0;continue}if(t&&(s.isSpecial()!=hasOwn(specialSchemes,l)||"file"==l&&(s.includesCredentials()||null!==s.port)||"file"==s.scheme&&!s.host))return;if(s.scheme=l,t)return void(s.isSpecial()&&specialSchemes[s.scheme]==s.port&&(s.port=null));l="","file"==s.scheme?c=FILE:s.isSpecial()&&r&&r.scheme==s.scheme?c=SPECIAL_RELATIVE_OR_AUTHORITY:s.isSpecial()?c=SPECIAL_AUTHORITY_SLASHES:"/"==n[u+1]?(c=PATH_OR_AUTHORITY,u++):(s.cannotBeABaseURL=!0,push(s.path,""),c=CANNOT_BE_A_BASE_URL_PATH)}break;case NO_SCHEME:if(!r||r.cannotBeABaseURL&&"#"!=i)return INVALID_SCHEME;if(r.cannotBeABaseURL&&"#"==i){s.scheme=r.scheme,s.path=arraySlice(r.path),s.query=r.query,s.fragment="",s.cannotBeABaseURL=!0,c=FRAGMENT;break}c="file"==r.scheme?FILE:RELATIVE;continue;case SPECIAL_RELATIVE_OR_AUTHORITY:if("/"!=i||"/"!=n[u+1]){c=RELATIVE;continue}c=SPECIAL_AUTHORITY_IGNORE_SLASHES,u++;break;case PATH_OR_AUTHORITY:if("/"==i){c=AUTHORITY;break}c=PATH;continue;case RELATIVE:if(s.scheme=r.scheme,i==EOF)s.username=r.username,s.password=r.password,s.host=r.host,s.port=r.port,s.path=arraySlice(r.path),s.query=r.query;else if("/"==i||"\\"==i&&s.isSpecial())c=RELATIVE_SLASH;else if("?"==i)s.username=r.username,s.password=r.password,s.host=r.host,s.port=r.port,s.path=arraySlice(r.path),s.query="",c=QUERY;else{if("#"!=i){s.username=r.username,s.password=r.password,s.host=r.host,s.port=r.port,s.path=arraySlice(r.path),s.path.length--,c=PATH;continue}s.username=r.username,s.password=r.password,s.host=r.host,s.port=r.port,s.path=arraySlice(r.path),s.query=r.query,s.fragment="",c=FRAGMENT}break;case RELATIVE_SLASH:if(!s.isSpecial()||"/"!=i&&"\\"!=i){if("/"!=i){s.username=r.username,s.password=r.password,s.host=r.host,s.port=r.port,c=PATH;continue}c=AUTHORITY}else c=SPECIAL_AUTHORITY_IGNORE_SLASHES;break;case SPECIAL_AUTHORITY_SLASHES:if(c=SPECIAL_AUTHORITY_IGNORE_SLASHES,"/"!=i||"/"!=charAt(l,u+1))continue;u++;break;case SPECIAL_AUTHORITY_IGNORE_SLASHES:if("/"!=i&&"\\"!=i){c=AUTHORITY;continue}break;case AUTHORITY:if("@"==i){d&&(l="%40"+l),d=!0,o=arrayFrom(l);for(var f=0;f<o.length;f++){var h=o[f];if(":"!=h||_){var m=percentEncode(h,userinfoPercentEncodeSet);_?s.password+=m:s.username+=m}else _=!0}l=""}else if(i==EOF||"/"==i||"?"==i||"#"==i||"\\"==i&&s.isSpecial()){if(d&&""==l)return INVALID_AUTHORITY;u-=arrayFrom(l).length+1,l="",c=HOST}else l+=i;break;case HOST:case HOSTNAME:if(t&&"file"==s.scheme){c=FILE_HOST;continue}if(":"!=i||p){if(i==EOF||"/"==i||"?"==i||"#"==i||"\\"==i&&s.isSpecial()){if(s.isSpecial()&&""==l)return INVALID_HOST;if(t&&""==l&&(s.includesCredentials()||null!==s.port))return;if(a=s.parseHost(l))return a;if(l="",c=PATH_START,t)return;continue}"["==i?p=!0:"]"==i&&(p=!1),l+=i}else{if(""==l)return INVALID_HOST;if(a=s.parseHost(l))return a;if(l="",c=PORT,t==HOSTNAME)return}break;case PORT:if(!exec(DIGIT,i)){if(i==EOF||"/"==i||"?"==i||"#"==i||"\\"==i&&s.isSpecial()||t){if(""!=l){var y=parseInt$1(l,10);if(y>65535)return INVALID_PORT;s.port=s.isSpecial()&&y===specialSchemes[s.scheme]?null:y,l=""}if(t)return;c=PATH_START;continue}return INVALID_PORT}l+=i;break;case FILE:if(s.scheme="file","/"==i||"\\"==i)c=FILE_SLASH;else{if(!r||"file"!=r.scheme){c=PATH;continue}if(i==EOF)s.host=r.host,s.path=arraySlice(r.path),s.query=r.query;else if("?"==i)s.host=r.host,s.path=arraySlice(r.path),s.query="",c=QUERY;else{if("#"!=i){startsWithWindowsDriveLetter(join(arraySlice(n,u),""))||(s.host=r.host,s.path=arraySlice(r.path),s.shortenPath()),c=PATH;continue}s.host=r.host,s.path=arraySlice(r.path),s.query=r.query,s.fragment="",c=FRAGMENT}}break;case FILE_SLASH:if("/"==i||"\\"==i){c=FILE_HOST;break}r&&"file"==r.scheme&&!startsWithWindowsDriveLetter(join(arraySlice(n,u),""))&&(isWindowsDriveLetter(r.path[0],!0)?push(s.path,r.path[0]):s.host=r.host),c=PATH;continue;case FILE_HOST:if(i==EOF||"/"==i||"\\"==i||"?"==i||"#"==i){if(!t&&isWindowsDriveLetter(l))c=PATH;else if(""==l){if(s.host="",t)return;c=PATH_START}else{if(a=s.parseHost(l))return a;if("localhost"==s.host&&(s.host=""),t)return;l="",c=PATH_START}continue}l+=i;break;case PATH_START:if(s.isSpecial()){if(c=PATH,"/"!=i&&"\\"!=i)continue}else if(t||"?"!=i)if(t||"#"!=i){if(i!=EOF&&(c=PATH,"/"!=i))continue}else s.fragment="",c=FRAGMENT;else s.query="",c=QUERY;break;case PATH:if(i==EOF||"/"==i||"\\"==i&&s.isSpecial()||!t&&("?"==i||"#"==i)){if(isDoubleDot(l)?(s.shortenPath(),"/"==i||"\\"==i&&s.isSpecial()||push(s.path,"")):isSingleDot(l)?"/"==i||"\\"==i&&s.isSpecial()||push(s.path,""):("file"==s.scheme&&!s.path.length&&isWindowsDriveLetter(l)&&(s.host&&(s.host=""),l=charAt(l,0)+":"),push(s.path,l)),l="","file"==s.scheme&&(i==EOF||"?"==i||"#"==i))for(;s.path.length>1&&""===s.path[0];)shift(s.path);"?"==i?(s.query="",c=QUERY):"#"==i&&(s.fragment="",c=FRAGMENT)}else l+=percentEncode(i,pathPercentEncodeSet);break;case CANNOT_BE_A_BASE_URL_PATH:"?"==i?(s.query="",c=QUERY):"#"==i?(s.fragment="",c=FRAGMENT):i!=EOF&&(s.path[0]+=percentEncode(i,C0ControlPercentEncodeSet));break;case QUERY:t||"#"!=i?i!=EOF&&("'"==i&&s.isSpecial()?s.query+="%27":s.query+="#"==i?"%23":percentEncode(i,C0ControlPercentEncodeSet)):(s.fragment="",c=FRAGMENT);break;case FRAGMENT:i!=EOF&&(s.fragment+=percentEncode(i,fragmentPercentEncodeSet))}u++}},parseHost:function(e){var t,r,n;if("["==charAt(e,0)){if("]"!=charAt(e,e.length-1))return INVALID_HOST;if(!(t=parseIPv6(stringSlice(e,1,-1))))return INVALID_HOST;this.host=t}else if(this.isSpecial()){if(e=toASCII(e),exec(FORBIDDEN_HOST_CODE_POINT,e))return INVALID_HOST;if(null===(t=parseIPv4(e)))return INVALID_HOST;this.host=t}else{if(exec(FORBIDDEN_HOST_CODE_POINT_EXCLUDING_PERCENT,e))return INVALID_HOST;for(t="",r=arrayFrom(e),n=0;n<r.length;n++)t+=percentEncode(r[n],C0ControlPercentEncodeSet);this.host=t}},cannotHaveUsernamePasswordPort:function(){return!this.host||this.cannotBeABaseURL||"file"==this.scheme},includesCredentials:function(){return""!=this.username||""!=this.password},isSpecial:function(){return hasOwn(specialSchemes,this.scheme)},shortenPath:function(){var e=this.path,t=e.length;!t||"file"==this.scheme&&1==t&&isWindowsDriveLetter(e[0],!0)||e.length--},serialize:function(){var e=this,t=e.scheme,r=e.username,n=e.password,i=e.host,o=e.port,a=e.path,s=e.query,c=e.fragment,u=t+":";return null!==i?(u+="//",e.includesCredentials()&&(u+=r+(n?":"+n:"")+"@"),u+=serializeHost(i),null!==o&&(u+=":"+o)):"file"==t&&(u+="//"),u+=e.cannotBeABaseURL?a[0]:a.length?"/"+join(a,"/"):"",null!==s&&(u+="?"+s),null!==c&&(u+="#"+c),u},setHref:function(e){var t=this.parse(e);if(t)throw TypeError$1(t);this.searchParams.update()},getOrigin:function(){var e=this.scheme,t=this.port;if("blob"==e)try{return new URLConstructor(e.path[0]).origin}catch(e){return"null"}return"file"!=e&&this.isSpecial()?e+"://"+serializeHost(this.host)+(null!==t?":"+t:""):"null"},getProtocol:function(){return this.scheme+":"},setProtocol:function(e){this.parse($toString(e)+":",SCHEME_START)},getUsername:function(){return this.username},setUsername:function(e){var t=arrayFrom($toString(e));if(!this.cannotHaveUsernamePasswordPort()){this.username="";for(var r=0;r<t.length;r++)this.username+=percentEncode(t[r],userinfoPercentEncodeSet)}},getPassword:function(){return this.password},setPassword:function(e){var t=arrayFrom($toString(e));if(!this.cannotHaveUsernamePasswordPort()){this.password="";for(var r=0;r<t.length;r++)this.password+=percentEncode(t[r],userinfoPercentEncodeSet)}},getHost:function(){var e=this.host,t=this.port;return null===e?"":null===t?serializeHost(e):serializeHost(e)+":"+t},setHost:function(e){this.cannotBeABaseURL||this.parse(e,HOST)},getHostname:function(){var e=this.host;return null===e?"":serializeHost(e)},setHostname:function(e){this.cannotBeABaseURL||this.parse(e,HOSTNAME)},getPort:function(){var e=this.port;return null===e?"":$toString(e)},setPort:function(e){this.cannotHaveUsernamePasswordPort()||(""==(e=$toString(e))?this.port=null:this.parse(e,PORT))},getPathname:function(){var e=this.path;return this.cannotBeABaseURL?e[0]:e.length?"/"+join(e,"/"):""},setPathname:function(e){this.cannotBeABaseURL||(this.path=[],this.parse(e,PATH_START))},getSearch:function(){var e=this.query;return e?"?"+e:""},setSearch:function(e){""==(e=$toString(e))?this.query=null:("?"==charAt(e,0)&&(e=stringSlice(e,1)),this.query="",this.parse(e,QUERY)),this.searchParams.update()},getSearchParams:function(){return this.searchParams.facade},getHash:function(){var e=this.fragment;return e?"#"+e:""},setHash:function(e){""!=(e=$toString(e))?("#"==charAt(e,0)&&(e=stringSlice(e,1)),this.fragment="",this.parse(e,FRAGMENT)):this.fragment=null},update:function(){this.query=this.searchParams.serialize()||null}};var URLConstructor=function(e){var t=anInstance(this,URLPrototype),r=validateArgumentsLength(arguments.length,1)>1?arguments[1]:void 0,n=setInternalState(t,new URLState(e,!1,r));DESCRIPTORS||(t.href=n.serialize(),t.origin=n.getOrigin(),t.protocol=n.getProtocol(),t.username=n.getUsername(),t.password=n.getPassword(),t.host=n.getHost(),t.hostname=n.getHostname(),t.port=n.getPort(),t.pathname=n.getPathname(),t.search=n.getSearch(),t.searchParams=n.getSearchParams(),t.hash=n.getHash())},URLPrototype=URLConstructor.prototype,accessorDescriptor=function(e,t){return{get:function(){return getInternalURLState(this)[e]()},set:t&&function(e){return getInternalURLState(this)[t](e)},configurable:!0,enumerable:!0}};if(DESCRIPTORS&&(defineBuiltInAccessor(URLPrototype,"href",accessorDescriptor("serialize","setHref")),defineBuiltInAccessor(URLPrototype,"origin",accessorDescriptor("getOrigin")),defineBuiltInAccessor(URLPrototype,"protocol",accessorDescriptor("getProtocol","setProtocol")),defineBuiltInAccessor(URLPrototype,"username",accessorDescriptor("getUsername","setUsername")),defineBuiltInAccessor(URLPrototype,"password",accessorDescriptor("getPassword","setPassword")),defineBuiltInAccessor(URLPrototype,"host",accessorDescriptor("getHost","setHost")),defineBuiltInAccessor(URLPrototype,"hostname",accessorDescriptor("getHostname","setHostname")),defineBuiltInAccessor(URLPrototype,"port",accessorDescriptor("getPort","setPort")),defineBuiltInAccessor(URLPrototype,"pathname",accessorDescriptor("getPathname","setPathname")),defineBuiltInAccessor(URLPrototype,"search",accessorDescriptor("getSearch","setSearch")),defineBuiltInAccessor(URLPrototype,"searchParams",accessorDescriptor("getSearchParams")),defineBuiltInAccessor(URLPrototype,"hash",accessorDescriptor("getHash","setHash"))),defineBuiltIn(URLPrototype,"toJSON",(function(){return getInternalURLState(this).serialize()}),{enumerable:!0}),defineBuiltIn(URLPrototype,"toString",(function(){return getInternalURLState(this).serialize()}),{enumerable:!0}),NativeURL){var nativeCreateObjectURL=NativeURL.createObjectURL,nativeRevokeObjectURL=NativeURL.revokeObjectURL;nativeCreateObjectURL&&defineBuiltIn(URLConstructor,"createObjectURL",bind(nativeCreateObjectURL,NativeURL)),nativeRevokeObjectURL&&defineBuiltIn(URLConstructor,"revokeObjectURL",bind(nativeRevokeObjectURL,NativeURL))}setToStringTag(URLConstructor,"URL"),$({global:!0,constructor:!0,forced:!USE_NATIVE_URL,sham:!DESCRIPTORS},{URL:URLConstructor});var isValidAudioFile=function(){var e=_asyncToGenerator(_regeneratorRuntime().mark((function e(t,r){var n;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=new Audio(URL.createObjectURL(new Blob([t],r))),e.prev=1,n.muted=!0,e.next=5,n.play();case 5:return n.pause(),e.abrupt("return",!0);case 9:return e.prev=9,e.t0=e.catch(1),e.abrupt("return",!1);case 12:case"end":return e.stop()}}),e,null,[[1,9]])})));return function(t,r){return e.apply(this,arguments)}}(),__defProp$1=Object.defineProperty,__getOwnPropDesc$1=Object.getOwnPropertyDescriptor,__decorateClass$1=function(e,t,r,n){for(var i,o=n>1?void 0:n?__getOwnPropDesc$1(t,r):t,a=e.length-1;a>=0;a--)(i=e[a])&&(o=(n?i(t,r,o):i(o))||o);return n&&o&&__defProp$1(t,r,o),o},AudioMixingManager=function(){function e(t){_classCallCheck(this,e),_defineProperty(this,"_sharedAudioContext",new AudioContext),_defineProperty(this,"_audioDestination",this._sharedAudioContext.createMediaStreamDestination()),_defineProperty(this,"_localGainNode",this._sharedAudioContext.createGain()),_defineProperty(this,"_bufferGainNode",this._sharedAudioContext.createGain()),_defineProperty(this,"_audioBufferSource",void 0),_defineProperty(this,"_localSource",void 0),_defineProperty(this,"_context",void 0),_defineProperty(this,"_failedAudioList",[]),_defineProperty(this,"mixingMap",new Map),_defineProperty(this,"resourcesCache",new Map),_defineProperty(this,"volumeConfig",new Map),_defineProperty(this,"cachedBuffer",[]),this._context=t,this._localGainNode.gain.value=1}var t,r,n;return _createClass(e,[{key:"mixMediaStream",value:function(e){this._localSource&&this._localSource.disconnect(this._localGainNode),this._localSource=this._sharedAudioContext.createMediaStreamSource(e),this._localSource.connect(this._localGainNode).connect(this._audioDestination)}},{key:"startAudioMixing",value:(n=_asyncToGenerator(_regeneratorRuntime().mark((function e(t,r,n){var i,o,a,s,c,u,l,d,p,_,f,h,m,y=this;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(i=n.playCount,checkEnum(o=n.type,"mixingType",values(AudioMixingType)),a=this._context.getLocalAudioTrack()){e.next=5;break}return e.abrupt("return");case 5:if(a.gainAudioTrack?(s=new MediaStream).addTrack(a.gainAudioTrack):s=getMediaStreamByTrack(a.getTrack()),s&&this.mixMediaStream(s),(c=this.mixingMap.get(t))&&c.audioNode){c.audioNode.pause(),this._context.emitMessage({mixId:t,state:AudioMixingState.AUDIO_MIXING_STATE_STOPPED,error:AudioMixingError.AUDIO_MIXING_ERROR_OK});try{c.gainNode.disconnect(this._audioDestination),c.audioSource.disconnect(c.gainNode)}catch(e){}}if(!(l=this.resourcesCache.get(t))||l.filePath!==r){e.next=14;break}u=l.getAudioNode(),e.next=28;break;case 14:return e.next=16,fetch(r,{mode:"cors",credentials:"include"}).then((function(e){if(e.ok)return e.arrayBuffer();throw y._context.emitMessage({mixId:t,state:AudioMixingState.AUDIO_MIXING_STATE_FAILED,error:AudioMixingError.AUDIO_MIXING_ERROR_START_FAILED}),new SDKError(ErrorCode.LOAD_RESOURCES_FAILED,e.statusText)}));case 16:return d=e.sent,r.endsWith("mp3")?p={type:"audio/mpeg"}:r.endsWith("aac")&&(p={type:"audio/aac"}),e.next=20,isValidAudioFile(d,p);case 20:if(e.sent){e.next=25;break}throw this._context.emitMessage({mixId:t,state:AudioMixingState.AUDIO_MIXING_STATE_FAILED,error:AudioMixingError.AUDIO_MIXING_ERROR_START_FAILED}),new SDKError(ErrorCode.LOAD_RESOURCES_FAILED,"invalid audio resource");case 25:(u=new Audio).crossOrigin="anonymous",u.src=URL.createObjectURL(new Blob([d],p));case 28:return i<=0?u.loop=!0:i>0&&(_=i,u.onended=function(){--_>0?u.play():(y.mixingMap.delete(t),y._context.emitMessage({mixId:t,state:AudioMixingState.AUDIO_MIXING_STATE_FINISHED,error:AudioMixingError.AUDIO_MIXING_ERROR_OK}))}),e.prev=29,e.next=32,u.play();case 32:e.next=39;break;case 34:e.prev=34,e.t0=e.catch(29),console.error(e.t0),this._failedAudioList.push(u),this._context.onAutoPlayFailed();case 39:if(f=this._sharedAudioContext.createMediaElementSource(u),h=this._sharedAudioContext.createGain(),m=this.volumeConfig.get(t),h.gain.value=m?m/100:1,f.connect(h).connect(this._audioDestination),this.mixingMap.set(t,{audioSource:f,audioNode:u,gainNode:h,type:"file"}),o===AudioMixingType.PUBLISH)try{h.disconnect(this._sharedAudioContext.destination)}catch(e){}else h.connect(this._sharedAudioContext.destination);this._context.updateLocalAudioTrack(this._audioDestination.stream.getAudioTracks()[0],n.type),this._context.emitMessage({mixId:t,state:AudioMixingState.AUDIO_MIXING_STATE_PLAYING,error:AudioMixingError.AUDIO_MIXING_ERROR_OK});case 48:case"end":return e.stop()}}),e,this,[[29,34]])}))),function(e,t,r){return n.apply(this,arguments)})},{key:"stopAudioMixing",value:function(e){var t=this.mixingMap.get(e);t&&"file"===t.type&&(this.mixingMap.delete(e),t.audioNode.pause(),t.audioSource.disconnect(t.gainNode),t.gainNode.disconnect(this._audioDestination),this._context.emitMessage({mixId:e,state:AudioMixingState.AUDIO_MIXING_STATE_STOPPED,error:AudioMixingError.AUDIO_MIXING_ERROR_OK}))}},{key:"pauseAudioMixing",value:function(e){var t=this.mixingMap.get(e);t&&(this._context.emitMessage({mixId:e,state:AudioMixingState.AUDIO_MIXING_STATE_PAUSED,error:AudioMixingError.AUDIO_MIXING_ERROR_OK}),t.audioNode.pause())}},{key:"resumeAudioMixing",value:function(e){var t=this.mixingMap.get(e);t&&(this._context.emitMessage({mixId:e,state:AudioMixingState.AUDIO_MIXING_STATE_PLAYING,error:AudioMixingError.AUDIO_MIXING_ERROR_OK}),t.audioNode.play())}},{key:"preloadAudioMixing",value:(r=_asyncToGenerator(_regeneratorRuntime().mark((function e(t,r){var n,i=this;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.stopAudioMixing(t),e.next=3,fetch(r,{mode:"cors",credentials:"include"}).then((function(e){if(e.ok)return e.arrayBuffer();throw i._context.emitMessage({mixId:t,state:AudioMixingState.AUDIO_MIXING_STATE_FAILED,error:AudioMixingError.AUDIO_MIXING_ERROR_PRELOAD_FAILED}),new SDKError(ErrorCode.LOAD_RESOURCES_FAILED,e.statusText)})).catch((function(e){throw i._context.emitMessage({mixId:t,state:AudioMixingState.AUDIO_MIXING_STATE_FAILED,error:AudioMixingError.AUDIO_MIXING_ERROR_PRELOAD_FAILED}),new SDKError(ErrorCode.LOAD_RESOURCES_FAILED,"Load resources failed",e)}));case 3:return n=e.sent,e.next=6,isValidAudioFile(n);case 6:if(e.sent){e.next=10;break}throw this._context.emitMessage({mixId:t,state:AudioMixingState.AUDIO_MIXING_STATE_FAILED,error:AudioMixingError.AUDIO_MIXING_ERROR_PRELOAD_FAILED}),new SDKError(ErrorCode.LOAD_RESOURCES_FAILED,"Load resources failed");case 10:this._context.emitMessage({mixId:t,state:AudioMixingState.AUDIO_MIXING_STATE_PRELOADED,error:AudioMixingError.AUDIO_MIXING_ERROR_OK}),this.resourcesCache.set(t,{getAudioNode:function(){return new Audio(URL.createObjectURL(new Blob([n])))},filePath:r});case 12:case"end":return e.stop()}}),e,this)}))),function(e,t){return r.apply(this,arguments)})},{key:"unloadAudioMixing",value:function(e){this.resourcesCache.has(e)&&this.resourcesCache.delete(e)}},{key:"getAudioMixingVolume",value:function(e){var t=this.mixingMap.get(e);return t?100*t.gainNode.gain.value:0}},{key:"setAudioMixingVolume",value:function(e,t){t<0?t=0:t>400&&(t=400),this.volumeConfig.set(e,t);var r=this.mixingMap.get(e);r&&(r.gainNode.gain.value=Number(t)/100)}},{key:"getAudioMixingDuration",value:function(e){var t=this.mixingMap.get(e),r=this.mixingMap.get(e);return t||r?t?1e3*t.audioNode.duration:r?1e3*r.audioNode.duration:0:0}},{key:"getAudioMixingCurrentPosition",value:function(e){var t=this.mixingMap.get(e);return t?1e3*t.audioNode.currentTime:0}},{key:"setAudioMixingPosition",value:function(e,t){var r=this.mixingMap.get(e);r&&(r.audioNode.currentTime=t/1e3,r.audioNode.play())}},{key:"enableAudioMixingBuffer",value:function(e){checkEnum(e,"type",values(AudioMixingType));var t=this._context.getLocalAudioTrack();if(t){var r=getMediaStreamByTrack(t.getTrack());if(r&&this.mixMediaStream(r),e===AudioMixingType.PUBLISH)try{this._bufferGainNode.disconnect(this._sharedAudioContext.destination)}catch(e){}else this._bufferGainNode.connect(this._sharedAudioContext.destination);this._context.updateLocalAudioTrack(this._audioDestination.stream.getAudioTracks()[0],e),this._bufferGainNode.connect(this._audioDestination),this._context.emitMessage({mixId:-1,state:AudioMixingState.AUDIO_MIXING_STATE_PCM_ENABLED,error:AudioMixingError.AUDIO_MIXING_ERROR_OK})}}},{key:"disableAudioMixingBuffer",value:function(){if(this.cachedBuffer=[],this._audioBufferSource){try{this._audioBufferSource.disconnect(this._bufferGainNode),this._bufferGainNode.disconnect(this._audioDestination),this._bufferGainNode.disconnect(this._sharedAudioContext.destination)}catch(e){}finally{this._audioBufferSource=void 0}this._context.updateLocalAudioTrack(),this._context.emitMessage({mixId:-1,state:AudioMixingState.AUDIO_MIXING_STATE_PCM_DISABLED,error:AudioMixingError.AUDIO_MIXING_ERROR_OK})}}},{key:"pushAudioMixingBuffer",value:function(e){var t=this;if(!(this._audioBufferSource&&(this.cachedBuffer.push(e),this.cachedBuffer.length>0))){this._audioBufferSource=this._sharedAudioContext.createBufferSource(),this._audioBufferSource.buffer=e,this._audioBufferSource.connect(this._bufferGainNode);try{this._audioBufferSource.start()}catch(e){this._failedAudioList.push(this._audioBufferSource)}this._audioBufferSource.onended=function(){var e;if(null===(e=t._audioBufferSource)||void 0===e||e.disconnect(t._bufferGainNode),t._audioBufferSource=void 0,t.cachedBuffer.length){var r=t.cachedBuffer.shift();r&&t.pushAudioMixingBuffer(r)}}}}},{key:"stopAll",value:function(){var e=this;if(this._localSource)try{this._localSource.disconnect(this._localGainNode),delete this._localSource}catch(e){}this.mixingMap.forEach((function(t,r){e.stopAudioMixing(r)}))}},{key:"mixTrack",get:function(){return this._audioDestination.stream.getAudioTracks()[0]}},{key:"sharedAudioContext",get:function(){return this._sharedAudioContext}},{key:"resumeLocalPlay",value:(t=_asyncToGenerator(_regeneratorRuntime().mark((function e(){var t,r,n,i;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=[],r=_createForOfIteratorHelper(this._failedAudioList),e.prev=2,r.s();case 4:if((n=r.n()).done){e.next=24;break}if(i=n.value,e.prev=6,!(i instanceof HTMLAudioElement)){e.next=13;break}return i.muted=!1,e.next=11,i.play();case 11:e.next=14;break;case 13:i.start();case 14:e.next=22;break;case 16:return e.prev=16,e.t0=e.catch(6),t.push(i),console.error(e.t0),this._context.onAutoPlayFailed(),e.abrupt("break",24);case 22:e.next=4;break;case 24:e.next=29;break;case 26:e.prev=26,e.t1=e.catch(2),r.e(e.t1);case 29:return e.prev=29,r.f(),e.finish(29);case 32:this._failedAudioList=t;case 33:case"end":return e.stop()}}),e,this,[[2,26,29,32],[6,16]])}))),function(){return t.apply(this,arguments)})},{key:"destroy",value:function(){var e=this._sharedAudioContext;"closed"!==e.state&&"function"==typeof e.close&&e.close(),this.cachedBuffer=[],this.mixingMap.clear(),this.resourcesCache.clear(),this.volumeConfig.clear()}}]),e}();__decorateClass$1([reportRtcSdkApiCall("default","id","filePath","options")],AudioMixingManager.prototype,"startAudioMixing",1),__decorateClass$1([reportRtcSdkApiCall("default","id")],AudioMixingManager.prototype,"stopAudioMixing",1),__decorateClass$1([reportRtcSdkApiCall("default","id")],AudioMixingManager.prototype,"pauseAudioMixing",1),__decorateClass$1([reportRtcSdkApiCall("default","id")],AudioMixingManager.prototype,"resumeAudioMixing",1),__decorateClass$1([reportRtcSdkApiCall("default","id")],AudioMixingManager.prototype,"preloadAudioMixing",1),__decorateClass$1([reportRtcSdkApiCall("default","id")],AudioMixingManager.prototype,"unloadAudioMixing",1),__decorateClass$1([reportRtcSdkApiCall("default","id")],AudioMixingManager.prototype,"getAudioMixingVolume",1),__decorateClass$1([reportRtcSdkApiCall("default","id","volume")],AudioMixingManager.prototype,"setAudioMixingVolume",1),__decorateClass$1([reportRtcSdkApiCall("default","id")],AudioMixingManager.prototype,"getAudioMixingDuration",1),__decorateClass$1([reportRtcSdkApiCall("default","id")],AudioMixingManager.prototype,"getAudioMixingCurrentPosition",1),__decorateClass$1([reportRtcSdkApiCall("default","id","position")],AudioMixingManager.prototype,"setAudioMixingPosition",1),__decorateClass$1([reportRtcSdkApiCall("default","type")],AudioMixingManager.prototype,"enableAudioMixingBuffer",1),__decorateClass$1([reportRtcSdkApiCall()],AudioMixingManager.prototype,"disableAudioMixingBuffer",1),__decorateClass$1([reportRtcSdkApiCall("default","buffer")],AudioMixingManager.prototype,"pushAudioMixingBuffer",1);var UserRole=function(e){return e.NORMAL_USER="normalUser",e.SILENT_USER="silentUser",e}(UserRole||{}),logger$4=new Logger("RTMClient",1),RTMClient=function(e){_inherits(u,eventemitter3.exports.EventEmitter);var t,r,n,i,o,a,s,c=_createSuper(u);function u(e){var t;return _classCallCheck(this,u),_defineProperty(_assertThisInitialized(t=c.call(this)),"_dataChannelSignal",null),_defineProperty(_assertThisInitialized(t),"_handler",null),_defineProperty(_assertThisInitialized(t),"_dataChannelSignalState",MediaConnectionState.DISCONNECTED),_defineProperty(_assertThisInitialized(t),"_loginSessionId",null),_defineProperty(_assertThisInitialized(t),"_userId",null),_defineProperty(_assertThisInitialized(t),"_token",null),_defineProperty(_assertThisInitialized(t),"_isReconnecting",!1),_defineProperty(_assertThisInitialized(t),"_reconnectTimer",null),_defineProperty(_assertThisInitialized(t),"_loginResolveCallback",null),_defineProperty(_assertThisInitialized(t),"_loginRejectCallback",null),_defineProperty(_assertThisInitialized(t),"_iceConfigNode",null),_defineProperty(_assertThisInitialized(t),"_wait_login_token",!1),_defineProperty(_assertThisInitialized(t),"_serverParamsCache",void 0),t._appId=e,t}return _createClass(u,[{key:"login",value:function(e,t){var r=this;return new Promise((function(n,i){if(logger$4.print("login","invoke login, token: %o, userId: %o",e,t),r._loginSessionId)throw new SDKError(ErrorCode.ALREADY_LOGIN,"Already logined");if(r._loginResolveCallback)throw new SDKError(ErrorCode.LOGIN_FAILED,"Is logging in, please try again later.");r._userId=t,r._token=e,rtmCommonStats.setStats({rtc_app_id:r._appId,user_id:t}),r._loginResolveCallback=n,r._loginRejectCallback=i,r._dataChannelSignal?r._login():(logger$4.print("login","init dataChannelSingling"),r._dataChannelSignalState=MediaConnectionState.CONNECTING,r._createDataChannelSignaling(t).then((function(e){r._dataChannelSignal=e,r._login()})).catch((function(){r._onDisconnect()})))}))}},{key:"logout",value:(s=_asyncToGenerator(_regeneratorRuntime().mark((function e(){var t;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._loginSessionId&&this._userId){e.next=2;break}throw new SDKError(ErrorCode.NOT_LOGIN,"login first");case 2:return e.next=4,null===(t=this._dataChannelSignal)||void 0===t?void 0:t.sendSignaling("logout",{loginSessionId:this._loginSessionId,userId:this._userId,appId:this._appId},{functionType:SIGNALING_FUNCTION_TYPE.C2RTM}).catch((function(){}));case 4:this._closeDataChannelSignaling(),this._clearState();case 6:case"end":return e.stop()}}),e,this)}))),function(){return s.apply(this,arguments)})},{key:"updateLoginToken",value:(a=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){var r=this;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this._token=t,e.abrupt("return",new Promise((function(e,t){r._wait_login_token?(r._loginResolveCallback=e,r._loginRejectCallback=t,r._login()):e()})));case 2:case"end":return e.stop()}}),e,this)}))),function(e){return a.apply(this,arguments)})},{key:"getPeerOnlineStatus",value:(o=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){var r;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._loginSessionId&&this._userId){e.next=2;break}throw new SDKError(ErrorCode.NOT_LOGIN,"login first");case 2:return this._checkDataChannelSignal(),e.next=5,this._dataChannelSignal.sendSignaling("getPeerOnlineStatus",{loginSessionId:this._loginSessionId,userId:this._userId,appId:this._appId,peerUserId:t},{functionType:SIGNALING_FUNCTION_TYPE.C2RTM});case 5:return r=e.sent,e.abrupt("return",null==r?void 0:r.status);case 7:case"end":return e.stop()}}),e,this)}))),function(e){return o.apply(this,arguments)})},{key:"sendUserMessageOutsideRoom",value:(i=_asyncToGenerator(_regeneratorRuntime().mark((function e(t,r){return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._loginSessionId&&this._userId){e.next=2;break}throw new SDKError(ErrorCode.NOT_LOGIN,"login first");case 2:return this._checkDataChannelSignal(),e.abrupt("return",this._dataChannelSignal.sendP2PMessage({from:this._userId,app:this._appId,to:t,room:"",msg:r}));case 4:case"end":return e.stop()}}),e,this)}))),function(e,t){return i.apply(this,arguments)})},{key:"setServerParams",value:(n=_asyncToGenerator(_regeneratorRuntime().mark((function e(t,r){return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(e.prev=0,checkString(t,"signature"),checkString(r,"url"),this._loginSessionId&&this._userId){e.next=5;break}throw new SDKError(ErrorCode.NOT_LOGIN,"login first");case 5:return this._checkDataChannelSignal(),e.next=8,this._dataChannelSignal.sendSignaling("setServerParams",{loginSessionId:this._loginSessionId,userId:this._userId,appId:this._appId,signature:t,url:r},{functionType:SIGNALING_FUNCTION_TYPE.C2RTM}).catch((function(e){throw new SDKError(ErrorCode.UNEXPECTED_ERROR,e.msg)}));case 8:this._serverParamsCache={signature:t,url:r},this.emit("onServerParamsSetResult"),e.next=16;break;case 12:throw e.prev=12,e.t0=e.catch(0),this.emit("onServerParamsSetResult",e.t0),e.t0;case 16:case"end":return e.stop()}}),e,this,[[0,12]])}))),function(e,t){return n.apply(this,arguments)})},{key:"sendServerMessage",value:(r=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._loginSessionId&&this._userId){e.next=2;break}throw new SDKError(ErrorCode.NOT_LOGIN,"login first");case 2:return this._checkDataChannelSignal(),e.abrupt("return",this._dataChannelSignal.sendP2PMessage({from:this._userId,app:this._appId,to:"",room:"",type:DC_MESSAGE_FUNCTION_TYPE.BUSINESS_SERVER,msg:t}));case 4:case"end":return e.stop()}}),e,this)}))),function(e){return r.apply(this,arguments)})},{key:"destroy",value:function(){this._clearState(),this._closeDataChannelSignaling(),_get(_getPrototypeOf(u.prototype),"removeAllListeners",this).call(this),delete this._serverParamsCache}},{key:"_login",value:function(){var e=this;if(this._userId){var t=genUuid();this._checkDataChannelSignal(),this._dataChannelSignal.sendSignaling("login",{Token:Utils.token2auth(this._appId,null,this._userId,this._token),timestamp:Date.now(),loginSessionId:t,params:{deviceType:"web",userAgent:window.navigator.userAgent,sdkVersion:Config.VERSION,deviceId:sdkCache.getDeviceId(),appId:this._appId,userId:this._userId}},{functionType:SIGNALING_FUNCTION_TYPE.C2RTM}).then((function(){e._loginResolveCallback&&e._loginResolveCallback(),e._loginSessionId=t,e._wait_login_token=!1,e._serverParamsCache&&e.setServerParams(e._serverParamsCache.signature,e._serverParamsCache.url)})).catch((function(t){var r,n,i=t||{},o=i.code,a=i.message;e._wait_login_token=!1,o>=700&&o<800?708===o?(r=ErrorCode.INVALID_PARAMS,n="Invalid userId"):(r=ErrorCode.INVALID_TOKEN,n="Invalid token",e._wait_login_token=!0,e._loginRejectCallback||e.emit("onRTMTokenError")):(r=ErrorCode.LOGIN_FAILED,n="login failed"),e._loginRejectCallback&&e._loginRejectCallback(new SDKError(r,a||n))})).finally((function(){e._loginResolveCallback=null,e._loginRejectCallback=null}))}}},{key:"_createDataChannelSignaling",value:(t=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){var r,n,i,o,a,s,c,u=this;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=new IceConfigRequestManager,i=this._iceConfigNode){e.next=16;break}return e.prev=3,e.next=6,null==n?void 0:n.getAccessNode(this._appId,"",t,sdkCache.getDeviceId(),"");case 6:if(o=e.sent,i=o[0]){e.next=10;break}throw new Error;case 10:e.next=16;break;case 12:throw e.prev=12,e.t0=e.catch(3),reportRtcInvokeStatus("rtm.login.getNodeFailed","",0,!0),new SDKError(ErrorCode.ICE_SERVER_WRONG,"get ICE config failed");case 16:return reportRtcInvokeStatus("rtm.login.getNodeSuccess",i,0,!0),logger$4.print("_createDataChannelSignaling()","get node success",i),this._handler=createHandler(rtmMonitor),null===(r=this._handler)||void 0===r||r.once("disconnect",(function(){logger$4.print("_createDataChannelSignaling()","recv BasicHandler event: disconnect"),u._onDisconnect()})),e.prev=20,e.next=23,null===(s=this._handler)||void 0===s?void 0:s.connect(i);case 23:a=e.sent,logger$4.print("_createDataChannelSignaling()","establish peerConnection success"),this._dataChannelSignalState=MediaConnectionState.CONNECTED,e.next=33;break;case 28:throw e.prev=28,e.t1=e.catch(20),this._iceConfigNode=null,this._dataChannelSignalState=MediaConnectionState.DISCONNECTED,new SDKError(ErrorCode.ESTABLISH_DATACHANNEL_FAILED,"establish dataChannel failed",e.t1);case 33:return c=new DataChannelSignaling(a),logger$4.print("_createDataChannelSignaling()","send ping"),c.sendPingSignaling(),c.once("close",(function(){logger$4.print("_createDataChannelSignaling()","recv DataChannelSignaling event: close"),u._onDisconnect()})),c.on(SignalEvent.USER_MESSAGE_RECEIVED_OUTSIDE_ROOM,(function(e){u.emit("onUserMessageReceivedOutsideRoom",{userId:e.from,message:e.msg})})),c.on(SignalEvent.USER_BINARY_MESSAGE_RECEIVED_OUTSIDE_ROOM,(function(e){u.emit("onUserBinaryMessageReceivedOutsideRoom",{userId:e.from,message:e.msg})})),c.on(SignalEvent.USER_DISCONNECTION,(function(){u.emit("onUserDisconnection"),u._clearState()})),c.on(SignalEvent.NODE_CHANGE,(function(e){reportRtcInvokeStatus("rtm.nodeChange",JSON.stringify(e),0,!0),Array.isArray(e.nodes)&&e.nodes.length&&(u._iceConfigNode=e.nodes[0]),u._loginResolveCallback&&u._loginRejectCallback?u._login():u._reconnect()})),e.abrupt("return",c);case 42:case"end":return e.stop()}}),e,this,[[3,12],[20,28]])}))),function(e){return t.apply(this,arguments)})},{key:"_closeDataChannelSignaling",value:function(){var e,t;null===(e=this._dataChannelSignal)||void 0===e||e.destroy(),this._dataChannelSignal=null,null===(t=this._handler)||void 0===t||t.destroy(),this._handler=null}},{key:"_checkDataChannelSignal",value:function(){if(!this._dataChannelSignal||this._dataChannelSignalState!==MediaConnectionState.CONNECTED)throw new SDKError(ErrorCode.NOT_CONNECTED_YET,"datachannel not connect")}},{key:"_onDisconnect",value:function(){this._dataChannelSignalState=MediaConnectionState.DISCONNECTED,this._closeDataChannelSignaling(),navigator.onLine?this._reconnect():this._reconnectTimer=self.setTimeout(this._reconnect.bind(this),3e3)}},{key:"_reconnect",value:function(){var e=this;!this._isReconnecting&&this._userId&&(logger$4.print("_reconnect()","start reconnect..."),this._isReconnecting=!0,this._createDataChannelSignaling(this._userId).then((function(t){logger$4.print("_reconnect()","reconnect success!"),e._dataChannelSignal=t,e._login(),e._reconnectTimer=null})).catch((function(t){logger$4.print("_reconnect()","Reconnecting error, will reconnect after 3s",t),e._reconnectTimer=self.setTimeout(e._reconnect.bind(e),3e3)})).finally((function(){e._isReconnecting=!1})))}},{key:"_clearState",value:function(){this._userId=null,this._token=null,this._loginSessionId=null,null!==this._reconnectTimer&&(self.clearTimeout(this._reconnectTimer),this._reconnectTimer=null)}}]),u}(),OutsideRoom=function(e){_inherits(o,EnhancedEventEmitter);var t,r,n,i=_createSuper(o);function o(e){var t;return _classCallCheck(this,o),_defineProperty(_assertThisInitialized(t=i.call(this)),"_mediaServerClient",void 0),_defineProperty(_assertThisInitialized(t),"_appId",void 0),_defineProperty(_assertThisInitialized(t),"_reconnectTimer",void 0),_defineProperty(_assertThisInitialized(t),"remoteStreams",void 0),t._appId=e,t.remoteStreams=new Map,t}return _createClass(o,[{key:"connect",value:(n=_asyncToGenerator(_regeneratorRuntime().mark((function e(){return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this._mediaServerClient=new MediaServerClient,this._bindEvents(),e.next=4,this._mediaServerClient.connect(this._appId);case 4:case"end":return e.stop()}}),e,this)}))),function(){return n.apply(this,arguments)})},{key:"startPlayPublicStream",value:(r=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){var r,n=this;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.remoteStreams.get(t)){e.next=2;break}throw new SDKError(ErrorCode.REPEAT_PLAY,"repeat play public media stream");case 2:return(r=new RemoteStream(t,t,!1,{audiostream:!0,localaudio:!0,videostream:!0,localvideo:!0,extaudio:!1,extvideo:!1,videoDescriptions:[]})).on("onSEIMessage",(function(e){if(e instanceof Uint8Array)for(var t=splitPublicStreamSei(e),i=0;i<t.seiCount;i++)n.emit(RoomEvent.ON_SEI_MESSAGED_RECEIVED,{sei:t.seis[i],publicStreamId:r.streamId})})),e.next=6,this._mediaServerClient.subscribePublicStream(r);case 6:return this.remoteStreams.set(t,r),e.abrupt("return",r);case 8:case"end":return e.stop()}}),e,this)}))),function(e){return r.apply(this,arguments)})},{key:"stopPlayPublicStream",value:function(e){var t=this.remoteStreams.get(e);if(t)return this.remoteStreams.delete(e),this._mediaServerClient.unsubscribePublicStream(t)}},{key:"destroy",value:function(){this.remoteStreams=new Map,this._mediaServerClient&&this._mediaServerClient.destroy()}},{key:"_handleReconnected",value:(t=_asyncToGenerator(_regeneratorRuntime().mark((function e(){var t,r,n,i=this;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:clearTimeout(this._reconnectTimer),t=_createForOfIteratorHelper(this.remoteStreams);try{for(n=function(){var e=_slicedToArray(r.value,1)[0];i.remoteStreams.delete(e),i.startPlayPublicStream(e).then((function(){var t=i.remoteStreams.get(e);i.safeEmit(RoomEvent.RESUBSCRIBE,{stream:t})}))},t.s();!(r=t.n()).done;)n()}catch(e){t.e(e)}finally{t.f()}case 3:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})},{key:"_reconnect",value:function(){var e=this;this._mediaServerClient.removeAllListeners(),this._mediaServerClient.destroy(),navigator.onLine?this.connect().then(this._handleReconnected.bind(this)):this._reconnectTimer=setTimeout((function(){return e.connect().then(e._handleReconnected.bind(e))}),3e3)}},{key:"_bindEvents",value:function(){var e,t,r=this;null===(e=this._mediaServerClient)||void 0===e||e.on(StateEvent.ABNORMAL_DISCONNECTION,this._reconnect.bind(this)),null===(t=this._mediaServerClient)||void 0===t||t.on("onRemoteStreamStats",(function(e){r.emit("onRemoteStreamStats",e)}))}}]),o}(),MAX_RECORDER_DURATION=3e4,logger$3=new Logger("AudioDeviceManager",1),AudioDeviceManager=function(e){_inherits(o,eventemitter3.exports.EventEmitter);var t,r,n,i=_createSuper(o);function o(){var e;_classCallCheck(this,o);for(var t=arguments.length,r=new Array(t),n=0;n<t;n++)r[n]=arguments[n];return _defineProperty(_assertThisInitialized(e=i.call.apply(i,[this].concat(r))),"_audioLevelFetcher",void 0),_defineProperty(_assertThisInitialized(e),"_playbackDeviceTestTimer",void 0),_defineProperty(_assertThisInitialized(e),"_audioElement",void 0),_defineProperty(_assertThisInitialized(e),"_audioTrack",void 0),_defineProperty(_assertThisInitialized(e),"_mediaRecorder",void 0),_defineProperty(_assertThisInitialized(e),"_recoderTimer",void 0),_defineProperty(_assertThisInitialized(e),"_isAudioPlaybackDeviceTesting",!1),_defineProperty(_assertThisInitialized(e),"_isAudioDeviceRecordTesting",!1),_defineProperty(_assertThisInitialized(e),"_audioCaptureAndRecoderResolve",void 0),e}return _createClass(o,[{key:"startAudioPlaybackDeviceTest",value:(n=_asyncToGenerator(_regeneratorRuntime().mark((function e(t,r){return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._isAudioPlaybackDeviceTesting&&!this._isAudioDeviceRecordTesting){e.next=2;break}throw new SDKError(ErrorCode.REPEAT_DEVICE_TEST,"device test cannot be called repeatedly at the same time.");case 2:return this._isAudioPlaybackDeviceTesting=!0,logger$3.print("startAudioPlaybackDeviceTest()","Invoke"),e.prev=4,e.next=7,this._playAudioFile(t,{loop:!0});case 7:e.next=13;break;case 9:throw e.prev=9,e.t0=e.catch(4),this.stopAudioPlaybackDeviceTest(),e.t0;case 13:this._startEmitAudioPlaybackDeviceTestVolume(r);case 14:case"end":return e.stop()}}),e,this,[[4,9]])}))),function(e,t){return n.apply(this,arguments)})},{key:"stopAudioPlaybackDeviceTest",value:function(){this._isAudioPlaybackDeviceTesting&&(logger$3.print("stopAudioPlaybackDeviceTest()","Invoke"),this._isAudioPlaybackDeviceTesting=!1,this._stopEmitAudioPlaybackDeviceTestVolume(),this._destroyAudioElement())}},{key:"startAudioDeviceRecordTest",value:(r=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){var r=this;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._isAudioDeviceRecordTesting){e.next=2;break}throw new SDKError(ErrorCode.REPEAT_DEVICE_TEST,"device test cannot be called repeatedly at the same time.");case 2:return this._isAudioDeviceRecordTesting=!0,logger$3.print("startAudioDeviceRecordTest()","Invoke"),this._recoderTimer=window.setTimeout((function(){logger$3.print("startAudioDeviceRecordTest()","".concat(MAX_RECORDER_DURATION,'ms automatic call method "stopAudioDeviceRecordAndPlayTest"')),r._stopAudioCaptureAndRecoder()}),MAX_RECORDER_DURATION),e.next=7,this._startAudioCaptureAndRecoder(t);case 7:delete this._audioCaptureAndRecoderResolve;case 8:case"end":return e.stop()}}),e,this)}))),function(e){return r.apply(this,arguments)})},{key:"stopAudioDeviceRecordAndPlayTest",value:function(){logger$3.print("stopAudioDeviceRecordAndPlayTest()","Invoke"),void 0!==this._recoderTimer&&(clearTimeout(this._recoderTimer),delete this._recoderTimer),this._stopAudioCaptureAndRecoder()}},{key:"stopAudioDevicePlayTest",value:function(){this._isAudioDeviceRecordTesting&&(logger$3.print("stopAudioDevicePlayTest()","Invoke"),this._isAudioDeviceRecordTesting=!1,this.stopAudioDeviceRecordAndPlayTest(),this._stopEmitAudioPlaybackDeviceTestVolume(),this._destroyAudioElement())}},{key:"getRecordTrack",value:function(){return this._audioTrack}},{key:"destroy",value:function(){logger$3.print("destroy()","Invoke"),_get(_getPrototypeOf(o.prototype),"removeAllListeners",this).call(this),this.stopAudioPlaybackDeviceTest(),this.stopAudioDevicePlayTest()}},{key:"_playAudioFile",value:function(e,t){var r=this;return new Promise((function(n,i){r._audioElement=createElement("audio",{attributes:{src:e,crossOrigin:"",autoplay:"true"}}),r._audioElement.loop=t.loop,logger$3.print("_playAudioFile()","url=".concat(e,";loop=").concat(t.loop)),r._audioElement.oncanplay=function(){logger$3.print("_playAudioFile()","oncanplay"),n()},r._audioElement.onerror=function(e){var t,n;i(new SDKError(ErrorCode.LOAD_RESOURCES_FAILED,"audio error: ".concat(e.message||(null===(t=r._audioElement)||void 0===t||null===(n=t.error)||void 0===n?void 0:n.message))))}}))}},{key:"_destroyAudioElement",value:function(){this._audioElement&&(logger$3.print("_destroyAudioElement()","Invoke"),this._audioElement.src="",delete this._audioElement,this._audioCaptureAndRecoderResolve&&this._audioCaptureAndRecoderResolve())}},{key:"_startEmitAudioPlaybackDeviceTestVolume",value:function(e){var t=this;e=Math.max(e,100),this._audioElement&&(logger$3.print("_startEmitAudioPlaybackDeviceTestVolume()","start timer(".concat(e,"ms)")),this._audioLevelFetcher=new AudioLevelFetcher(this._audioElement),this._playbackDeviceTestTimer=self.setInterval((function(){t._audioLevelFetcher&&t.emit("onAudioPlaybackDeviceTestVolume",t._audioLevelFetcher.getAudioLevel())}),e))}},{key:"_stopEmitAudioPlaybackDeviceTestVolume",value:function(){var e;void 0!==this._playbackDeviceTestTimer&&(logger$3.print("_stopEmitAudioPlaybackDeviceTestVolume()","stop timer"),self.clearInterval(this._playbackDeviceTestTimer),delete this._playbackDeviceTestTimer),null===(e=this._audioLevelFetcher)||void 0===e||e.destroy(),delete this._audioLevelFetcher}},{key:"_startAudioCaptureAndRecoder",value:(t=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){var r,n=this;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,createMicrophoneAudioTrack({});case 2:return this._audioTrack=e.sent,r=getMediaStreamByTrack(this._audioTrack.getTrack()),logger$3.print("startAudioDeviceRecordTest()","create microphone track success!"),e.abrupt("return",new Promise((function(e,i){n._mediaRecorder=new MediaRecorder(r),n._mediaRecorder.ondataavailable=function(){var r=_asyncToGenerator(_regeneratorRuntime().mark((function r(o){var a,s;return _regeneratorRuntime().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(!n._isAudioDeviceRecordTesting){r.next=16;break}return logger$3.print("startAudioDeviceRecordTest()","get recorded file."),s=new Blob([o.data]),r.prev=3,r.next=6,n._playAudioFile(URL.createObjectURL(s),{loop:!1});case 6:r.next=11;break;case 8:return r.prev=8,r.t0=r.catch(3),r.abrupt("return",i(r.t0));case 11:n._startEmitAudioPlaybackDeviceTestVolume(t),null===(a=n._audioElement)||void 0===a||a.addEventListener("ended",(function(){n.stopAudioDevicePlayTest(),e()})),n._audioCaptureAndRecoderResolve=e,r.next=17;break;case 16:e();case 17:case"end":return r.stop()}}),r,null,[[3,8]])})));return function(e){return r.apply(this,arguments)}}(),n._mediaRecorder.onerror=function(e){i(new SDKError(ErrorCode.AUDIO_DEVICE_TEST_FAILED,e.message||"mediaRecorder error"))},n._mediaRecorder.start()})));case 6:case"end":return e.stop()}}),e,this)}))),function(e){return t.apply(this,arguments)})},{key:"_stopAudioCaptureAndRecoder",value:function(){var e;this._mediaRecorder&&("recording"===this._mediaRecorder.state&&this._mediaRecorder.stop(),delete this._mediaRecorder),null===(e=this._audioTrack)||void 0===e||e.close(),delete this._audioTrack}}]),o}(),AudioProfileManager=function(){function e(){_classCallCheck(this,e),_defineProperty(this,"engineBAC",{adm:{},agc:{},ans:{}}),_defineProperty(this,"engineANM",{}),_defineProperty(this,"bitrate",void 0),_defineProperty(this,"sampleRate",void 0),_defineProperty(this,"channel",void 0),_defineProperty(this,"aec",void 0),_defineProperty(this,"agc",void 0),_defineProperty(this,"ans",void 0),this._init()}var t;return _createClass(e,[{key:"_init",value:(t=_asyncToGenerator(_regeneratorRuntime().mark((function e(){var t;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=new MultiConfigRequestManager,e.next=3,t.getAudioProfile();case 3:this.engineBAC=e.sent;case 4:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})},{key:"updateEngineBAC",value:function(e){e&&(this.engineBAC={codec:this.engineBAC.codec,adm:_objectSpread2(_objectSpread2({},this.engineBAC.adm),e.adm)},this.setAEC(!!e.aec),this.setAGC(!!e.agc))}},{key:"updateEngineANM",value:function(e){e&&(this.engineANM=e)}},{key:"setAudioProfile",value:function(e){var t,r,n;switch(e){case AudioProfileType.fluent:r=16e3,t=24e3;break;case AudioProfileType.standard:r=48e3,t=48e3;break;case AudioProfileType.hd:r=48e3,t=128e3,n=2;break;case AudioProfileType.standardStereo:r=48e3,t=8e4,n=2;break;case AudioProfileType.hdMono:r=48e3,t=128e3}t&&(this.bitrate=t),n&&(this.channel=n),r&&(this.sampleRate=r)}},{key:"setBitrate",value:function(e){e>128e3&&(e=128e3),this.bitrate=e}},{key:"setAEC",value:function(e){this.aec=e}},{key:"setAGC",value:function(e){this.agc=e}},{key:"setANS",value:function(e){this.ans=e}},{key:"getOpusConfigStr",value:function(){var e=";",t=this.config;return t.bitrate&&(e+="maxaveragebitrate=".concat(t.bitrate,";")),t.sampleRate&&(e+="sprop-maxcapturerate=".concat(t.sampleRate,";")),t.playbackRate&&(e+="maxplaybackrate=".concat(t.playbackRate,";")),t.channel&&t.channel>1&&(e+="sprop-stereo=1;"),t.playChannel&&t.playChannel>1&&(e+="stereo=1;"),e.slice(0,-1)}},{key:"config",get:function(){var e,t,r,n,i,o,a,s,c,u,l,d,p;return{bitrate:this.bitrate||(null===(e=this.engineANM.enc_param)||void 0===e?void 0:e.bitrate)||0,playChannel:(null===(t=this.engineBAC.adm)||void 0===t||null===(r=t.play)||void 0===r?void 0:r.chn)||1,channel:this.channel||(null===(n=this.engineBAC.adm)||void 0===n||null===(i=n.record)||void 0===i?void 0:i.chn)||(null===(o=this.engineANM)||void 0===o||null===(a=o.enc_param)||void 0===a?void 0:a.chn),aec:this.aec,agc:this.agc,ans:this.ans,sampleRate:this.sampleRate||(null===(s=this.engineBAC.adm)||void 0===s||null===(c=s.record)||void 0===c?void 0:c.sr)||(null===(u=this.engineBAC.codec)||void 0===u?void 0:u.enc_fs)||(null===(l=this.engineANM.enc_param)||void 0===l?void 0:l.sr),playbackRate:null===(d=this.engineBAC.adm)||void 0===d||null===(p=d.play)||void 0===p?void 0:p.sr}}}]),e}(),logger$2=new Logger("VideoSnapshot",1),getPlayingVideoDom=function(e){var t=null==e?void 0:e.domElement;if(t&&!t.paused&&4===t.readyState)return t},takeSnapshot=function(){var e=_asyncToGenerator(_regeneratorRuntime().mark((function e(t,r,n){var i,o,a,s,c,u,l,d;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(i=document.createElement("canvas"),o=i.getContext("2d")){e.next=4;break}throw new Error("canvas.getContext error");case 4:if(a=function(e,t,n){return t=t||e.width,n=n||e.height,i.width=t,i.height=n,r?o.setTransform(-1,0,0,1,t,0):o.setTransform(1,0,0,1,0,0),o.drawImage(e,0,0,t,n),o.getImageData(0,0,t,n)},s=Date.now(),!(c=getPlayingVideoDom(n))){e.next=16;break}return logger$2.print("takeSnapshot","VideoPlayer already set."),e.next=11,a(c,c.videoWidth,c.videoHeight);case 11:return u=e.sent,logger$2.print("takeSnapshot","success, cost ".concat(Date.now()-s,"ms")),e.abrupt("return",u);case 16:if(!window.ImageCapture){e.next=29;break}if("live"!==(l=new window.ImageCapture(t)).track.readyState||!l.track.enabled||l.track.muted){e.next=29;break}return logger$2.print("takeSnapshot","use ImageCapture"),e.t0=a,e.next=23,l.grabFrame();case 23:return e.t1=e.sent,e.next=26,(0,e.t0)(e.t1);case 26:return d=e.sent,logger$2.print("takeSnapshot","success, cost ".concat(Date.now()-s,"ms")),e.abrupt("return",d);case 29:return logger$2.print("takeSnapshot","use temp video"),e.abrupt("return",new Promise((function(e,r){var n=new MediaStream([t]),i=document.createElement("video");i.setAttribute("playsinline",""),i.muted=!0,document.body.appendChild(i),i.onplaying=function(){var r=a(i,i.videoWidth,i.videoHeight);logger$2.print("takeSnapshot","success, cost ".concat(Date.now()-s,"ms")),e(r),n.removeTrack(t),i.srcObject=null,i.load()},i.onerror=r,i.srcObject=n,i.play()})));case 31:case"end":return e.stop()}}),e)})));return function(t,r,n){return e.apply(this,arguments)}}(),__defProp=Object.defineProperty,__getOwnPropDesc=Object.getOwnPropertyDescriptor,__decorateClass=function(e,t,r,n){for(var i,o=n>1?void 0:n?__getOwnPropDesc(t,r):t,a=e.length-1;a>=0;a--)(i=e[a])&&(o=(n?i(t,r,o):i(o))||o);return n&&o&&__defProp(t,r,o),o},logger$1=new Logger("Engine",0),RTCEngine=function(e){_inherits(de,EnhancedEventEmitter);var t,r,n,i,o,a,s,c,u,l,d,p,_,f,h,m,y,v,S,g,E,T,b,R,I,$,A,C,O,P,k,w,N,D,M,x,L,U,F,B,V,j,G,H,K,z,Y,W,q,X,Z,J,Q,ee,te,re,ne,ie,oe,ae,se,ce,ue,le=_createSuper(de);function de(e,t){var r;return _classCallCheck(this,de),_defineProperty(_assertThisInitialized(r=le.call(this)),"_room",void 0),_defineProperty(_assertThisInitialized(r),"_outsideRoom",void 0),_defineProperty(_assertThisInitialized(r),"_appId",void 0),_defineProperty(_assertThisInitialized(r),"_businessId",void 0),_defineProperty(_assertThisInitialized(r),"_visibility",!0),_defineProperty(_assertThisInitialized(r),"_localVideoTrack",void 0),_defineProperty(_assertThisInitialized(r),"_localAudioTrack",void 0),_defineProperty(_assertThisInitialized(r),"_localImgVideoTrack",void 0),_defineProperty(_assertThisInitialized(r),"_localImgScreenTrack",void 0),_defineProperty(_assertThisInitialized(r),"_localScreenVideoTrack",void 0),_defineProperty(_assertThisInitialized(r),"_localScreenAudioTrack",void 0),_defineProperty(_assertThisInitialized(r),"_tempMixingAudioTrack",void 0),_defineProperty(_assertThisInitialized(r),"_localAudioTrackVolume",void 0),_defineProperty(_assertThisInitialized(r),"_localScreenAudioTrackVolume",void 0),_defineProperty(_assertThisInitialized(r),"_remoteAudioTrackVolumeMap",new Map),_defineProperty(_assertThisInitialized(r),"_remoteScreenAudioTrackVolumeMap",new Map),_defineProperty(_assertThisInitialized(r),"_remotePublicAudioTrackVolumeMap",new Map),_defineProperty(_assertThisInitialized(r),"_audioPlaybackDeviceId",void 0),_defineProperty(_assertThisInitialized(r),"_videoPlayer",void 0),_defineProperty(_assertThisInitialized(r),"_screenPlayer",void 0),_defineProperty(_assertThisInitialized(r),"_remoteVideoPlayer",new Map),_defineProperty(_assertThisInitialized(r),"_remoteScreenPlayer",new Map),_defineProperty(_assertThisInitialized(r),"_remoteAudioPlayer",new Map),_defineProperty(_assertThisInitialized(r),"_publicStreamAudioPlayer",new Map),_defineProperty(_assertThisInitialized(r),"_publicStreamVideoPlayer",new Map),_defineProperty(_assertThisInitialized(r),"_publicStreamIds",new Map),_defineProperty(_assertThisInitialized(r),"_roomConfig",void 0),_defineProperty(_assertThisInitialized(r),"_videoStreamConstraints",{}),_defineProperty(_assertThisInitialized(r),"_audioStreamConstraints",{}),_defineProperty(_assertThisInitialized(r),"_enableSimulcast",!1),_defineProperty(_assertThisInitialized(r),"_videoStreamEncodeConfig",[defaultVideoEncoderConfig]),_defineProperty(_assertThisInitialized(r),"_screenStreamEncodeConfig",[defaultScreenEncoderConfig]),_defineProperty(_assertThisInitialized(r),"_trackSourceType",void 0),_defineProperty(_assertThisInitialized(r),"_liveTranscodeConfig",void 0),_defineProperty(_assertThisInitialized(r),"_useCloudProxy",void 0),_defineProperty(_assertThisInitialized(r),"_startCloudProxyTimestamp",void 0),_defineProperty(_assertThisInitialized(r),"_localVideoDeviceId",void 0),_defineProperty(_assertThisInitialized(r),"_localAudioDeviceId",void 0),_defineProperty(_assertThisInitialized(r),"_pauseAllSubscribeState",{audio:!1,video:!1}),_defineProperty(_assertThisInitialized(r),"_audioVolumeIndicationTimer",void 0),_defineProperty(_assertThisInitialized(r),"_dummyTimer",void 0),_defineProperty(_assertThisInitialized(r),"_audioPropertiesReportTimer",null),_defineProperty(_assertThisInitialized(r),"_mirrorType",MirrorType.MIRROR_TYPE_RENDER),_defineProperty(_assertThisInitialized(r),"_audioMixingManager",void 0),_defineProperty(_assertThisInitialized(r),"_pubLock",void 0),_defineProperty(_assertThisInitialized(r),"_rtmClient",void 0),_defineProperty(_assertThisInitialized(r),"_messageStatisticsObserver",void 0),_defineProperty(_assertThisInitialized(r),"_tempRoomConfig",void 0),_defineProperty(_assertThisInitialized(r),"_originIceConfigRequestUrls",void 0),_defineProperty(_assertThisInitialized(r),"_originConfigServerUrls",void 0),_defineProperty(_assertThisInitialized(r),"_originLogServerUrl",void 0),_defineProperty(_assertThisInitialized(r),"_audioDeviceManager",new AudioDeviceManager),_defineProperty(_assertThisInitialized(r),"_audioProfileManager",new AudioProfileManager),_defineProperty(_assertThisInitialized(r),"_remoteVideoConfig",new Map),_defineProperty(_assertThisInitialized(r),"_userPriorityMap",new Map),_defineProperty(_assertThisInitialized(r),"_subscribeFallbackOption",SubscribeFallbackOption.DISABLE),_defineProperty(_assertThisInitialized(r),"_cameraCapturing",!1),_defineProperty(_assertThisInitialized(r),"_interruptCameraCapture",!1),_defineProperty(_assertThisInitialized(r),"_micCapturing",!1),_defineProperty(_assertThisInitialized(r),"_interruptMicCapture",!1),_defineProperty(_assertThisInitialized(r),"_config",void 0),_defineProperty(_assertThisInitialized(r),"_updateMixAudioTrack",function(){var e=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){var n,i,o=arguments;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(i=o.length>1&&void 0!==o[1]?o[1]:AudioMixingType.PLAYOUT_AND_PUBLISH,logger$1.print("_updateMixAudioTrack()"),r._localAudioTrack){e.next=5;break}return t&&(r._tempMixingAudioTrack={track:t,type:i}),e.abrupt("return");case 5:if(t?(r._localAudioTrack.mixType=i,r._localAudioTrack.mixedAudioTrack=t):(delete r._localAudioTrack.mixType,delete r._localAudioTrack.mixedAudioTrack),null===(n=r._room)||void 0===n||!n.hasPublished){e.next=9;break}return e.next=9,r._updatePublish();case 9:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}()),_defineProperty(_assertThisInitialized(r),"_onAudioMixingMessage",(function(e){r.safeEmit(EngineEventsTypes.onAudioMixingStateChanged,e)})),_defineProperty(_assertThisInitialized(r),"_onAudioMixingAutoplayFailed",(function(){r.safeEmit(EngineEventsTypes.onAutoplayFailed,{})})),r._appId=e,r._pubLock=new PromiseLock("pubLock"),r._addDeviceEventHandler(),r._audioMixingManager=new AudioMixingManager({getLocalAudioTrack:function(){return r._localAudioTrack},updateLocalAudioTrack:r._updateMixAudioTrack,emitMessage:r._onAudioMixingMessage,onAutoPlayFailed:r._onAudioMixingAutoplayFailed}),window.__rtc_engine__=_assertThisInitialized(r),window["__rtc_engine__".concat(Math.floor(100*Math.random()+1))]=_assertThisInitialized(r),r._trackSourceType={video:VideoSourceType.VIDEO_SOURCE_TYPE_INTERNAL,screenVideo:VideoSourceType.VIDEO_SOURCE_TYPE_INTERNAL,audio:AudioSourceType.AUDIO_SOURCE_TYPE_INTERNAL,screenAudio:AudioSourceType.AUDIO_SOURCE_TYPE_INTERNAL},r._config=t,r._rtmClient=new RTMClient(e),r._handleRTMClient(r._rtmClient),r._useCloudProxy=!1,r._handleAudioDeviceManager(),r._messageStatisticsObserver=new MessageStatisticsObserver,r}return _createClass(de,[{key:"appId",get:function(){return this._appId},set:function(e){this._appId=e}},{key:"updateToken",value:(ue=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){var r,n,i,o,a,s,c;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(logger$1.print("updateToken()","token: %s",t),checkString(t,"token"),!(this.waitForNewToken&&null!==(r=this._room)&&void 0!==r&&r._roomInfo&&this._tempRoomConfig)){e.next=9;break}return o=null===(i=this._room)||void 0===i?void 0:i._roomInfo,a=o.roomId,s=o.userInfo,c=this._tempRoomConfig,delete this._tempRoomConfig,e.next=8,this.joinRoom(t,a,s,c);case 8:return e.abrupt("return",e.sent);case 9:if(this._room){e.next=11;break}throw new SDKError(ErrorCode.UPDATE_TOKEN_BEFORE_JOIN,"update token before join room");case 11:return e.next=13,null===(n=this._room)||void 0===n?void 0:n.updateToken(t);case 13:case"end":return e.stop()}}),e,this)}))),function(e){return ue.apply(this,arguments)})},{key:"setVideoCaptureDevice",value:(ce=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){var r,n;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(logger$1.print("setVideoCaptureDevice()","deviceId: %s",t),checkString(t,"deviceId"),this._localVideoDeviceId=t,this._localVideoTrack){e.next=5;break}return e.abrupt("return");case 5:return r=this._videoStreamConstraints,"user"===t||"environment"===t||"left"===t||"right"===t?(delete r.deviceId,r.facingMode=t):r.deviceId={exact:t},this._videoStreamConstraints=r,e.next=10,createCameraVideoTrack(r);case 10:if(n=e.sent,this._initLocalTrackEvents(n),this._localVideoTrack.close(),this._localVideoTrack=n,this._videoPlayer&&this._videoPlayer.played&&(this._videoPlayer.stop(),this._videoPlayer.playVideo(n),this._videoPlayer.mirror(!!this._mirrorType)),this._room){e.next=17;break}return e.abrupt("return");case 17:if(!this._room.hasPublished){e.next=20;break}return e.next=20,this._updatePublish();case 20:case"end":return e.stop()}}),e,this)}))),function(e){return ce.apply(this,arguments)})},{key:"setAudioCaptureDevice",value:(se=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){var r,n;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(logger$1.print("setAudioCaptureDevice()","deviceId: %s",t),checkString(t,"deviceId"),this._localAudioDeviceId=t,this._localAudioTrack){e.next=5;break}return e.abrupt("return");case 5:return(r=this._audioStreamConstraints).deviceId={exact:t},this._audioStreamConstraints=r,this._localAudioTrack.close(),e.next=11,createMicrophoneAudioTrack(r,this._audioProfileManager);case 11:if(n=e.sent,void 0!==this._localAudioTrackVolume&&n.setCaptureVolume(this._localAudioTrackVolume),this._initLocalTrackEvents(n),this._localAudioTrack=n,this._room){e.next=17;break}return e.abrupt("return");case 17:if(!this._room.hasPublished){e.next=20;break}return e.next=20,this._updatePublish();case 20:case"end":return e.stop()}}),e,this)}))),function(e){return se.apply(this,arguments)})},{key:"_addDeviceEventHandler",value:function(){detector.on(EngineEventsTypes.onVideoDeviceStateChanged,this._onVideoDeviceStateChange.bind(this)),detector.on(EngineEventsTypes.onAudioDeviceStateChanged,this._onAudioDeviceStateChange.bind(this))}},{key:"_addHandlerEventHandler",value:function(){var e,t,r,n,i,o,a,s,c,u,l,d,p,_,f,h,m,y,v,S,g,E,T,b,R,I,$,A,C,O,P=this;null===(e=this._room)||void 0===e||e.on(SignalEvent.ON_ADD_STREAM,this._onAddStream.bind(this)),null===(t=this._room)||void 0===t||t.on(SignalEvent.ON_REMOVE_STREAM,this._onRemoveStream.bind(this)),null===(r=this._room)||void 0===r||r.on(SignalEvent.USER_CONNECTION,this._onUserConnection.bind(this)),null===(n=this._room)||void 0===n||n.on(RoomEvent.ON_USER_LEAVE,this._onUserLeave.bind(this)),null===(i=this._room)||void 0===i||i.on(RoomEvent.ON_ROOM_ERROR,this._onRoomError.bind(this)),null===(o=this._room)||void 0===o||o.on(RoomEvent.ON_NETWORK_QUALITY,this._onNetworkQuality.bind(this)),null===(a=this._room)||void 0===a||a.on(SignalEvent.ON_CUSTOM_MESSAGE,this._onCustomMessage.bind(this)),null===(s=this._room)||void 0===s||s.on(SignalEvent.USER_MESSAGE_RECEIVED,this._onUserMessageReceived.bind(this)),null===(c=this._room)||void 0===c||c.on(SignalEvent.USER_BINARY_MESSAGE_RECEIVED,this._onUserBinaryMessageReceived.bind(this)),null===(u=this._room)||void 0===u||u.on(SignalEvent.ON_USER_TOKEN_WILL_EXPIRE,this._onUserTokenWillExpire.bind(this)),null===(l=this._room)||void 0===l||l.on(SignalEvent.POST_PROCESSING_MESSAGE,(function(e){"2.0"===e.protocol?P._onStreamMixingEvent({error:e.error,event:e.eventType,message:e.message}):"publicStreamCallback"===e.type?P._onPushPublicStreamResult(e):"transcodeStatusCallback"===e.type&&P._onLiveTranscodingResult(e)})),null===(d=this._room)||void 0===d||d.on(StateEvent.ON_CONNECTION_STATE_CHANGE,this._onConnectionStateChange.bind(this)),null===(p=this._room)||void 0===p||p.on(RoomEvent.RESUBSCRIBE,this._onResubscribe.bind(this)),null===(_=this._room)||void 0===_||_.on(RoomEvent.SUBSCRIBE_PUSH_TRACK,this._onSubscribePushTrack.bind(this)),null===(f=this._room)||void 0===f||f.on(RoomEvent.REMOVE_PUSH_TRACK,this._onRemovePushTrack.bind(this)),null===(h=this._room)||void 0===h||h.on(RoomEvent.VIDEO_FIRST_FRAME,this._onVideoFirstFrameDecoded.bind(this)),null===(m=this._room)||void 0===m||m.on(RoomEvent.ON_PUBLISH_RESULT,(function(e){var t;null!==(t=P._room)&&void 0!==t&&t._roomConfig.isAutoPublish&&P.safeEmit(EngineEventsTypes.onAutoPublishResult,e)})),null===(y=this._room)||void 0===y||y.on(RoomEvent.ON_REMOTE_STREAM_STATS,(function(e){P.safeEmit(EngineEventsTypes.onRemoteStreamStats,e)})),null===(v=this._room)||void 0===v||v.on(RoomEvent.ON_LOCAL_STREAM_STATS,(function(e){P.safeEmit(EngineEventsTypes.onLocalStreamStats,e)})),null===(S=this._room)||void 0===S||S.on(RoomEvent.ON_USER_PUBLISH_STATE_CHANGE,this._onUserPublishStateChange.bind(this)),null===(g=this._room)||void 0===g||g.on(RoomEvent.ON_USER_START_AUDIO_CAPTURE,(function(e){var t=e.userId;P.safeEmit(EngineEventsTypes.onUserStartAudioCapture,{userId:t})})),null===(E=this._room)||void 0===E||E.on(RoomEvent.ON_USER_STOP_AUDIO_CAPTURE,(function(e){var t=e.userId;P.safeEmit(EngineEventsTypes.onUserStopAudioCapture,{userId:t})})),null===(T=this._room)||void 0===T||T.on(RoomEvent.ON_USER_START_VIDEO_CAPTURE,(function(e){var t=e.userId;P.safeEmit(EngineEventsTypes.onUserStartVideoCapture,{userId:t})})),null===(b=this._room)||void 0===b||b.on(RoomEvent.ON_USER_STOP_VIDEO_CAPTURE,(function(e){var t=e.userId;P.safeEmit(EngineEventsTypes.onUserStopVideoCapture,{userId:t})})),null===(R=this._room)||void 0===R||R.on(RoomEvent.ON_SEI_MESSAGED_RECEIVED,(function(e){P.safeEmit(EngineEventsTypes.onSEIMessageReceived,e)})),null===(I=this._room)||void 0===I||I.on(RoomEvent.ON_REMOTE_VIDEO_SIZE_CHANGED,(function(e,t){P.safeEmit(EngineEventsTypes.onRemoteVideoSizeChanged,e,t)})),null===($=this._room)||void 0===$||$.on(RoomEvent.ON_SIMULCAST_SUBSCRIBE_FALLBACK,(function(e){return P.safeEmit(EngineEventsTypes.onSimulcastSubscribeFallback,e)})),null===(A=this._room)||void 0===A||A.on(RoomEvent.RECONNECT_FAILED,(function(){P.safeEmit(EngineEventsTypes.onError,{errorCode:ErrorCode.RECONNECT_FAILED})})),null===(C=this._room)||void 0===C||C.on(RoomEvent.ON_VIDEO_STREAM_BANNED,(function(e){P.safeEmit(EngineEventsTypes.onVideoStreamBanned,{uid:e.uid,banned:e.banned})})),null===(O=this._room)||void 0===O||O.on(RoomEvent.ON_AUDIO_STREAM_BANNED,(function(e){P.safeEmit(EngineEventsTypes.onAudioStreamBanned,{uid:e.uid,banned:e.banned})}))}},{key:"safeEmit",value:function(e){for(var t,r=arguments.length,n=new Array(r>1?r-1:0),i=1;i<r;i++)n[i-1]=arguments[i];return isReportCallback(e)&&reportRtcSdkCallback(e,reportParamsCheck(n)),(t=_get(_getPrototypeOf(de.prototype),"safeEmit",this)).call.apply(t,[this,e].concat(n))}},{key:"_removeHandlerEventHandler",value:function(){var e;null===(e=this._room)||void 0===e||e.removeAllListeners()}},{key:"joinRoom",value:(ae=_asyncToGenerator(_regeneratorRuntime().mark((function e(t,r,n,i){var o,a,s;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(logger$1.print("joinRoom()","token: %o roomId: %o, userInfo: %o, roomConfig: %o",t,r,n,i),isEmpty(t)||checkString(t,"token"),checkRoomId(r),checkUserInfo(n),o={isAutoPublish:!0,isAutoSubscribeAudio:!0,isAutoSubscribeVideo:!0,roomProfileType:RoomProfileType.communication},assignIn$1(o,i),checkRoomConfig(o),!this._room||this._room.connectionState===MediaConnectionState.DISCONNECTED){e.next=11;break}throw new SDKError(ErrorCode.REPEAT_JOIN,"Already joined");case 11:return this._room=new Room(i,{audioProfileManager:this._audioProfileManager}),this._room.userPriorityMap=this._userPriorityMap,this._room.subscribeFallbackOption=this._subscribeFallbackOption,this._addHandlerEventHandler(),a=this._liveTranscodeConfig&&getTranscodeControlMessage("started",this._liveTranscodeConfig),e.prev=16,this._useCloudProxy&&(this._startCloudProxyTimestamp=Date.now()),e.next=20,this._room.join(this._appId,r,t,_objectSpread2(_objectSpread2({},n),{},{businessId:this._businessId,role:this._visibility?UserRole.NORMAL_USER:UserRole.SILENT_USER}),a,this._useCloudProxy);case 20:return s=e.sent,this._roomConfig=i,this._tempRoomConfig&&delete this._tempRoomConfig,null!=i&&i.isAutoPublish&&(this._visibility?this._updatePublish({invokeByJoinRoom:!0,mediaType:MediaType.AUDIO_AND_VIDEO}):this.safeEmit(EngineEventsTypes.onAutoPublishResult,{isScreen:!1,state:PublishState.PUBLISH_FAIL})),e.abrupt("return",s);case 27:throw e.prev=27,e.t0=e.catch(16),e.t0.code===ErrorCode.INVALID_TOKEN&&(this._tempRoomConfig=i),e.t0;case 31:case"end":return e.stop()}}),e,this,[[16,27]])}))),function(e,t,r,n){return ae.apply(this,arguments)})},{key:"leaveRoom",value:(oe=_asyncToGenerator(_regeneratorRuntime().mark((function e(){var t,r,n,i=arguments;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=i.length>0&&void 0!==i[0]&&i[0],logger$1.print("leaveRoom()"),!t){e.next=7;break}return e.next=5,null===(r=this._room)||void 0===r?void 0:r.leave(t);case 5:e.next=8;break;case 7:null===(n=this._room)||void 0===n||n.leave(t).catch();case 8:this._removeHandlerEventHandler(),this._liveTranscodeConfig&&this.stopLiveTranscoding(),this._room=void 0,this._remoteAudioPlayer.forEach((function(e){return e.destroy()})),this._remoteAudioPlayer=new Map,this._remoteScreenPlayer.forEach((function(e){return e.destroy()})),this._remoteScreenPlayer=new Map,this._remoteVideoPlayer.forEach((function(e){return e.destroy()})),this._remoteVideoPlayer=new Map,this._roomConfig=void 0,this._publicStreamIds=new Map;case 19:case"end":return e.stop()}}),e,this)}))),function(){return oe.apply(this,arguments)})},{key:"destroy",value:function(){var e,t,r,n,i,o;logger$1.print("destroy()"),this.removeAllListeners(),this._removeHandlerEventHandler(),null===(e=this._room)||void 0===e||e.destroy(),this._room=void 0,null===(t=this._videoPlayer)||void 0===t||t.destroy(),this._videoPlayer=void 0,this._screenPlayer=void 0,this._videoStreamConstraints={},this._audioStreamConstraints={},this._videoStreamEncodeConfig=[defaultVideoEncoderConfig],this._screenStreamEncodeConfig=[defaultScreenEncoderConfig],this._pauseAllSubscribeState={audio:!1,video:!1},this._messageStatisticsObserver.destroy(),clearInterval(this._audioVolumeIndicationTimer),clearInterval(this._dummyTimer),this._audioVolumeIndicationTimer=void 0,this._stopAudioPropertiesReport(),this._localAudioTrack&&(this._localAudioTrack.close(),this._localAudioTrack=void 0),this._localVideoTrack&&(this._localVideoTrack.close(),this._localVideoTrack=void 0),this._localScreenAudioTrack&&(this._localScreenAudioTrack.close(),this._localScreenAudioTrack=void 0),this._localScreenVideoTrack&&(this._localScreenVideoTrack.close(),this._localScreenVideoTrack=void 0),this._localImgVideoTrack&&(this._localImgVideoTrack.stop(),this._localImgVideoTrack=void 0),this._localImgScreenTrack&&(this._localImgScreenTrack.stop(),this._localImgScreenTrack=void 0),this._remoteAudioPlayer.forEach((function(e){return e.destroy()})),this._remoteAudioPlayer=new Map,this._remoteScreenPlayer.forEach((function(e){return e.destroy()})),this._remoteScreenPlayer=new Map,this._remoteVideoPlayer.forEach((function(e){return e.destroy()})),this._remoteVideoPlayer=new Map,this._publicStreamAudioPlayer.forEach((function(e){return e.destroy()})),this._publicStreamAudioPlayer=new Map,this._publicStreamVideoPlayer.forEach((function(e){return e.destroy()})),this._publicStreamVideoPlayer=new Map,this._roomConfig=void 0,this._audioMixingManager.destroy(),this._rtmClient.destroy(),null===(r=this._outsideRoom)||void 0===r||r.destroy(),this._publicStreamIds=new Map,this._audioDeviceManager.destroy(),this._remoteVideoConfig=new Map,this._userPriorityMap.clear(),this._localAudioTrackVolume=100,this._localScreenAudioTrackVolume=100,null===(n=this._remoteAudioTrackVolumeMap)||void 0===n||n.clear(),null===(i=this._remoteScreenAudioTrackVolumeMap)||void 0===i||i.clear(),null===(o=this._remotePublicAudioTrackVolumeMap)||void 0===o||o.clear(),this._cameraCapturing=!1,this._micCapturing=!1,this._interruptCameraCapture=!1,this._interruptMicCapture=!1}},{key:"publishStream",value:(ie=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return logger$1.print("publishStream()","mediaType: %o",t),this._checkMediaType(t),this._assertNotInRoom(),videoInMediaType(t)&&!this._localVideoTrack&&this._localImgVideoTrack&&(this._localVideoTrack=createDummyVideoLocalTrack(this._localImgVideoTrack),this._localVideoTrack.dummy=!0),e.next=6,this._updatePublish({mediaType:t});case 6:case"end":return e.stop()}}),e,this)}))),function(e){return ie.apply(this,arguments)})},{key:"unpublishStream",value:(ne=_asyncToGenerator(_regeneratorRuntime().mark((function e(t,r){var n;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(logger$1.print("unpublishStream()","mediaType: %o",t),this._checkMediaType(t),this._assertNotInRoom(),!r){e.next=5;break}return e.abrupt("return",null===(n=this._room)||void 0===n?void 0:n.unpublish());case 5:return e.next=7,this._updatePublish({mediaType:t,pubState:PubState.UNPUB});case 7:case"end":return e.stop()}}),e,this)}))),function(e,t){return ne.apply(this,arguments)})},{key:"publishScreen",value:(re=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return logger$1.print("publishScreen()","mediaType: %o",t),this._checkMediaType(t),this._assertNotInRoom(),e.prev=3,videoInMediaType(t)&&!this._localScreenVideoTrack&&this._localImgScreenTrack&&(this._localScreenVideoTrack=createDummyScreenVideoLocalTrack(this._localImgScreenTrack),this._localScreenVideoTrack.dummy=!0),e.next=7,this._updateScreenPublish({mediaType:t,pubState:PubState.PUB});case 7:e.next=16;break;case 9:if(e.prev=9,e.t0=e.catch(3),!(e.t0 instanceof SDKError)){e.next=15;break}throw e.t0;case 15:throw new SDKError(ErrorCode.UNEXPECTED_ERROR,"unexpected error",e.t0);case 16:case"end":return e.stop()}}),e,this,[[3,9]])}))),function(e){return re.apply(this,arguments)})},{key:"unpublishScreen",value:(te=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return logger$1.print("unpublishScreen()","mediaType: %o",t),this._checkMediaType(t),this._assertNotInRoom(),e.next=5,this._updateScreenPublish({mediaType:t,pubState:PubState.UNPUB});case 5:case"end":return e.stop()}}),e,this)}))),function(e){return te.apply(this,arguments)})},{key:"subscribeStream",value:(ee=_asyncToGenerator(_regeneratorRuntime().mark((function e(t,r){return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return logger$1.print("subscribeStream()","userId: %o, mediaType: %o",t,r),e.abrupt("return",this._subscribe(!1,t,r));case 2:case"end":return e.stop()}}),e,this)}))),function(e,t){return ee.apply(this,arguments)})},{key:"_subscribe",value:(Q=_asyncToGenerator(_regeneratorRuntime().mark((function e(t,r,n){var i,o,a,s,c,u,l,d,p,_;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._checkMediaType(n),this._assertNotInRoom(),s=this._room.remoteStreams.get(r),c=null==s?void 0:s.find((function(e){return e.isScreen===t}))){e.next=6;break}throw new SDKError(ErrorCode.STREAM_NOT_EXIST,"stream not exist");case 6:return this._pauseAllSubscribeState.audio&&(n-=n&MediaType.AUDIO),this._pauseAllSubscribeState.video&&(n-=n&MediaType.VIDEO),logger$1.print("subscribeStream()","due to pauseAll mediaType: %o",n),u=c.hasSubscribed,l=this._remoteVideoConfig.get(r)||(null===(i=this._roomConfig)||void 0===i?void 0:i.remoteVideoConfig),c.originalMediaType=n,e.next=14,this._room.subscribe(c,n,l);case 14:audioInMediaType(n)&&this._updateAudioPlayerState(c),videoInMediaType(n)&&this._updateVideoPlayerState(c),!t&&(null!==(o=this._roomConfig)&&void 0!==o&&o.isAutoSubscribeAudio||null!==(a=this._roomConfig)&&void 0!==a&&a.isAutoSubscribeVideo)&&(c.audioTrack||c.videoTrack)&&(d={userId:r,isScreen:!1,state:SubscribeState.SUBSCRIBE_SUCC},this.safeEmit(EngineEventsTypes.onAutoSubscribeResult,d)),!u&&audioInMediaType(n)&&c.hasAudio&&(null===(p=c.observer)||void 0===p||p.setSubscribeAudio(!0)),!u&&videoInMediaType(n)&&c.hasVideo&&(null===(_=c.observer)||void 0===_||_.setSubscribeVideo(!0));case 19:case"end":return e.stop()}}),e,this)}))),function(e,t,r){return Q.apply(this,arguments)})},{key:"unsubscribeStream",value:(J=_asyncToGenerator(_regeneratorRuntime().mark((function e(t,r){var n,i;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(logger$1.print("unsubscribeStream()","userId: %o, mediaType: %o",t,r),this._checkMediaType(r),this._assertNotInRoom(),n=this._room.remoteStreams.get(t),null!=(i=null==n?void 0:n.find((function(e){return!e.isScreen})))&&i.hasSubscribed){e.next=7;break}throw new SDKError(ErrorCode.STREAM_NOT_EXIST,"stream not exist");case 7:this._room.unsubscribe(i,r);case 8:case"end":return e.stop()}}),e,this)}))),function(e,t){return J.apply(this,arguments)})},{key:"subscribeScreen",value:(Z=_asyncToGenerator(_regeneratorRuntime().mark((function e(t,r){return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return logger$1.print("subscribeScreen() userId: %o, mediaType: %o",t,r),e.abrupt("return",this._subscribe(!0,t,r));case 2:case"end":return e.stop()}}),e,this)}))),function(e,t){return Z.apply(this,arguments)})},{key:"unsubscribeScreen",value:(X=_asyncToGenerator(_regeneratorRuntime().mark((function e(t,r){var n,i;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(logger$1.print("unsubscribeScreen() userId: %o, mediaType: %o",t,r),this._checkMediaType(r),this._assertNotInRoom(),n=this._room.remoteStreams.get(t),null!=(i=null==n?void 0:n.find((function(e){return e.isScreen})))&&i.hasSubscribed){e.next=7;break}throw new SDKError(ErrorCode.STREAM_NOT_EXIST,"stream not exist");case 7:this._room.unsubscribe(i,r);case 8:case"end":return e.stop()}}),e,this)}))),function(e,t){return X.apply(this,arguments)})},{key:"setRemoteVideoConfig",value:(q=_asyncToGenerator(_regeneratorRuntime().mark((function e(t,r){var n;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return logger$1.print("setRemoteVideoConfig() userId: %o, remoteVideoConfig: %o",t,r),checkUserId(t),checkRemoteConfig(r),this._remoteVideoConfig.set(t,r),e.abrupt("return",null===(n=this._room)||void 0===n?void 0:n.updateSubVideoConfig(t,r).then((function(){})));case 5:case"end":return e.stop()}}),e,this)}))),function(e,t){return q.apply(this,arguments)})},{key:"startVideoCapture",value:(W=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){var r,n,i,o,a,s,c,u,l,d=this;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(logger$1.print("startVideoCapture()","deviceId: %s",t),isEmpty(t)||checkString(t,"deviceId"),t=t||this._localVideoDeviceId,this._localVideoDeviceId=t,!(this._cameraCapturing||this._localVideoTrack&&!this._localVideoTrack.dummy)){e.next=6;break}throw new SDKError(ErrorCode.REPEAT_CAPTURE,"Has already capture");case 6:return i=this._videoStreamConstraints,t&&("user"===t||"environment"===t||"left"===t||"right"===t?i.facingMode=t:i.deviceId={exact:t},this._videoStreamConstraints=i),o={},e.prev=9,this._cameraCapturing=!0,e.next=13,createCameraVideoTrack(i);case 13:if(s=e.sent,!this._interruptCameraCapture){e.next=18;break}throw this._interruptCameraCapture=!1,s.close(),new SDKError(ErrorCode.INTERRUPT,"interrupt by stopVideoCapture");case 18:this._initLocalTrackEvents(s),this._localVideoTrack=s,null===(a=this._videoPlayer)||void 0===a||a.playVideo(s),(c=null==s?void 0:s.getTrack())&&(o=c.getSettings(),u={width:o.width,height:o.height},this._localVideoTrack.resolution=u,setTimeout((function(){return d.safeEmit(EngineEventsTypes.onLocalVideoSizeChanged,{streamIndex:StreamIndex.STREAM_INDEX_MAIN,info:u})})));case 23:return e.prev=23,this._cameraCapturing=!1,e.finish(23);case 26:if(this._room){e.next=28;break}return e.abrupt("return",o);case 28:return l=this._room._roomConfig.isAutoPublish,(this._room.hasPublished||l)&&(this._visibility?this._updatePublish():this.safeEmit(EngineEventsTypes.onAutoPublishResult,{isScreen:!1,state:PublishState.PUBLISH_FAIL})),null===(r=this._room.localStream)||void 0===r||null===(n=r.observer)||void 0===n||n.setEnableVideo(!0),e.abrupt("return",o);case 32:case"end":return e.stop()}}),e,this,[[9,,23,26]])}))),function(e){return W.apply(this,arguments)})},{key:"stopVideoCapture",value:(Y=_asyncToGenerator(_regeneratorRuntime().mark((function e(){var t,r,n,i,o;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(logger$1.print("stopVideoCapture()"),!this._cameraCapturing){e.next=5;break}return this._interruptCameraCapture=!0,logger$1.print("stopVideoCapture()","capturing"),e.abrupt("return");case 5:if(this._trackSourceType.video!==VideoSourceType.VIDEO_SOURCE_TYPE_EXTERNAL){e.next=7;break}throw new SDKError(ErrorCode.STREAM_TYPE_NOT_MATCH,"setVideoSourceType as internal first");case 7:if(null===(t=this._videoPlayer)||void 0===t||t.stop(),null===(r=this._localVideoTrack)||void 0===r||r.close(),this._localImgVideoTrack&&this._localVideoTrack?(null===(o=this._localVideoTrack)||void 0===o||o.setTrack(this._localImgVideoTrack),this._localVideoTrack.dummy=!0):this._localVideoTrack=void 0,this._room){e.next=12;break}return e.abrupt("return");case 12:if(!this._room.hasPublished){e.next=15;break}return e.next=15,this._updatePublish();case 15:null===(n=this._room.localStream)||void 0===n||null===(i=n.observer)||void 0===i||i.setEnableVideo(!1);case 16:case"end":return e.stop()}}),e,this)}))),function(){return Y.apply(this,arguments)})},{key:"startAudioCapture",value:(z=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){var r,n,i,o,a;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(logger$1.print("startAudioCapture()","deviceId: $o",t),isEmpty(t)||checkString(t,"deviceId"),t=t||this._localAudioDeviceId,this._localAudioDeviceId=t,!this._micCapturing&&!this._localAudioTrack){e.next=6;break}throw new SDKError(ErrorCode.REPEAT_CAPTURE,"Has already capture");case 6:return i=this._audioStreamConstraints,t&&(i.deviceId={exact:t},this._audioStreamConstraints=i),e.prev=8,this._micCapturing=!0,e.next=12,createMicrophoneAudioTrack(i,this._audioProfileManager);case 12:if(o=e.sent,!this._interruptMicCapture){e.next=17;break}throw this._interruptMicCapture=!1,o.close(),new SDKError(ErrorCode.INTERRUPT,"interrupt by stopAudioCapture");case 17:this._initLocalTrackEvents(o),this._localAudioTrack=o,this._tempMixingAudioTrack&&(this._localAudioTrack.mixType=this._tempMixingAudioTrack.type,this._localAudioTrack.mixedAudioTrack=this._tempMixingAudioTrack.track,delete this._tempMixingAudioTrack),void 0!==this._localAudioTrackVolume&&this._localAudioTrack.setCaptureVolume(this._localAudioTrackVolume);case 21:return e.prev=21,this._micCapturing=!1,e.finish(21);case 24:if(this._room){e.next=26;break}return e.abrupt("return");case 26:a=this._room._roomConfig.isAutoPublish,(this._room.hasPublished||a)&&(this._visibility?this._updatePublish():this.safeEmit(EngineEventsTypes.onAutoPublishResult,{isScreen:!1,state:PublishState.PUBLISH_FAIL})),null===(r=this._room.localStream)||void 0===r||null===(n=r.observer)||void 0===n||n.setEnableAudio(!0);case 29:case"end":return e.stop()}}),e,this,[[8,,21,24]])}))),function(e){return z.apply(this,arguments)})},{key:"stopAudioCapture",value:(K=_asyncToGenerator(_regeneratorRuntime().mark((function e(){var t,r,n;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(logger$1.print("stopAudioCapture()"),!this._micCapturing){e.next=5;break}return this._interruptMicCapture=!0,logger$1.print("stopAudioCapture()","capturing"),e.abrupt("return");case 5:if(null===(t=this._localAudioTrack)||void 0===t||t.close(),this._localAudioTrack=void 0,this._audioMixingManager.stopAll(),this._trackSourceType.audio!==AudioSourceType.AUDIO_SOURCE_TYPE_EXTERNAL){e.next=10;break}throw new SDKError(ErrorCode.STREAM_TYPE_NOT_MATCH,"setAudioSourceType as internal first");case 10:if(this._room){e.next=12;break}return e.abrupt("return");case 12:if(!this._room.hasPublished){e.next=15;break}return e.next=15,this._updatePublish();case 15:null===(r=this._room.localStream)||void 0===r||null===(n=r.observer)||void 0===n||n.setEnableAudio(!1);case 16:case"end":return e.stop()}}),e,this)}))),function(){return K.apply(this,arguments)})},{key:"getAudioMixingManager",value:function(){return logger$1.print("getAudioMixingManager()"),this._audioMixingManager}},{key:"startScreenCapture",value:(H=_asyncToGenerator(_regeneratorRuntime().mark((function e(){var t,r,n,i,o,a,s,c,u,l,d,p,_,f,h,m,y,v=this,S=arguments;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(c=S.length>0&&void 0!==S[0]?S[0]:{},logger$1.print("startScreenCapture()","config: %o",c),!this._localScreenVideoTrack||null!==(t=this._localScreenVideoTrack)&&void 0!==t&&t.dummy||(u=this._localScreenVideoTrack),l=c.enableAudio,d=void 0!==l&&l,this._trackSourceType.screenVideo!==VideoSourceType.VIDEO_SOURCE_TYPE_EXTERNAL){e.next=6;break}throw new SDKError(ErrorCode.STREAM_TYPE_NOT_MATCH,"setVideoSourceType as internal first");case 6:if(this._trackSourceType.screenAudio!==AudioSourceType.AUDIO_SOURCE_TYPE_EXTERNAL){e.next=8;break}throw new SDKError(ErrorCode.STREAM_TYPE_NOT_MATCH,"setAudioSourceType as internal first");case 8:return e.next=10,createScreenStream(d,this._screenStreamEncodeConfig[0]);case 10:if(p=e.sent,this._localScreenVideoTrack=new ScreenVideoTrack(p.getVideoTracks()[0],genUuid()),null===(r=u)||void 0===r||r.close(),null===(n=this.localScreenAudioTrack)||void 0===n||n.close(),this._localScreenAudioTrack=void 0,null!==(i=this._screenStreamEncodeConfig[0])&&void 0!==i&&i.contentHint&&this._localScreenVideoTrack.setContentHint(null===(_=this._screenStreamEncodeConfig[0])||void 0===_?void 0:_.contentHint),(f=null===(o=this._localScreenVideoTrack)||void 0===o?void 0:o.getTrack())&&(h=f.getSettings(),m={width:h.width,height:h.height},this._localScreenVideoTrack.resolution=m,setTimeout((function(){return v.safeEmit(EngineEventsTypes.onLocalVideoSizeChanged,{streamIndex:StreamIndex.STREAM_INDEX_SCREEN,info:{width:h.width,height:h.height}})}))),(y=p.getAudioTracks()).length&&(this._localScreenAudioTrack=new ScreenAudioTrack(y[0],genUuid()),this._initLocalTrackEvents(this._localScreenAudioTrack),void 0!==this._localScreenAudioTrackVolume&&this._localScreenAudioTrack.setCaptureVolume(this._localScreenAudioTrackVolume)),null===(a=this._screenPlayer)||void 0===a||a.playVideo(this._localScreenVideoTrack),this._initLocalTrackEvents(this._localScreenVideoTrack,!0),null===(s=this._room)||void 0===s||!s.hasScreenPublished){e.next=25;break}return e.next=25,this._updateScreenPublish();case 25:case"end":return e.stop()}}),e,this)}))),function(){return H.apply(this,arguments)})},{key:"stopScreenCapture",value:(G=_asyncToGenerator(_regeneratorRuntime().mark((function e(){var t,r,n,i;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(logger$1.print("stopScreenCapture()"),null===(t=this._screenPlayer)||void 0===t||t.stop(),null===(r=this._localScreenVideoTrack)||void 0===r||r.close(),this._localImgScreenTrack&&this._localScreenVideoTrack?(this._localScreenVideoTrack.setTrack(this._localImgScreenTrack),this._localScreenVideoTrack.dummy=!0):this._localScreenVideoTrack=void 0,null===(n=this._localScreenAudioTrack)||void 0===n||n.close(),this._localScreenAudioTrack=void 0,null===(i=this._room)||void 0===i||!i.hasScreenPublished){e.next=9;break}return e.next=9,this._updateScreenPublish();case 9:case"end":return e.stop()}}),e,this)}))),function(){return G.apply(this,arguments)})},{key:"setLocalVideoPlayer",value:function(e,t){if(logger$1.print("setLocalVideoPlayer()","streamIndex: %o, videoPlayerOption: %o",e,t),checkEnum(e,"streamIndex",[StreamIndex.STREAM_INDEX_MAIN,StreamIndex.STREAM_INDEX_SCREEN]),t&&t.renderDom){var r,n,i=_objectSpread2({userId:this._getUserId()},t);if(checkVideoPlayerOption(i),e===StreamIndex.STREAM_INDEX_MAIN&&!this._videoPlayer)return this._videoPlayer=new VideoPlayer(i),this._initPlayerEvents(this._videoPlayer),this._videoPlayer.mirror(!!this._mirrorType),this._localVideoTrack&&!this._localVideoTrack.dummy&&(null===(r=this._config)||void 0===r?void 0:r.autoPlayPolicy)!==RTCAutoPlayPolicy.PLAY_MANUALLY&&this._videoPlayer.playVideo(this._localVideoTrack),this._videoPlayer.domElement;if(e===StreamIndex.STREAM_INDEX_SCREEN&&!this._screenPlayer)return this._screenPlayer=new VideoPlayer(_objectSpread2(_objectSpread2({},i),{},{isScreen:!0})),this._initPlayerEvents(this._screenPlayer),this._localScreenVideoTrack&&!this._localScreenVideoTrack.dummy&&(null===(n=this._config)||void 0===n?void 0:n.autoPlayPolicy)!==RTCAutoPlayPolicy.PLAY_MANUALLY&&this._screenPlayer.playVideo(this._localScreenVideoTrack),this._screenPlayer.domElement}else{var o,a;e===StreamIndex.STREAM_INDEX_MAIN?(null===(o=this._videoPlayer)||void 0===o||o.destroy(),delete this._videoPlayer):(null===(a=this._screenPlayer)||void 0===a||a.destroy(),delete this._screenPlayer)}}},{key:"startLiveTranscoding",value:(j=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){var r;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return logger$1.print("startLiveTranscoding()","transcode: %o",t),checkString(t.url,"liveTranscode.url"),this._liveTranscodeConfig=t,e.prev=3,this.safeEmit(EngineEventsTypes.onStreamMixingEvent,{event:StreamMixingEventType.START,error:0,message:""}),e.next=7,null===(r=this._room)||void 0===r?void 0:r.liveControlMessage(getTranscodeControlMessage("started",this._liveTranscodeConfig));case 7:e.next=16;break;case 9:if(e.prev=9,e.t0=e.catch(3),!(e.t0 instanceof SDKError)){e.next=15;break}throw e.t0;case 15:throw new SDKError(ErrorCode.UNEXPECTED_ERROR,"unexpected error",e.t0);case 16:case"end":return e.stop()}}),e,this,[[3,9]])}))),function(e){return j.apply(this,arguments)})},{key:"updateLiveTranscoding",value:(V=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){var r;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(logger$1.print("updateLiveTranscoding()","transcode: %o",t),this._liveTranscodeConfig){e.next=3;break}return e.abrupt("return");case 3:return this._liveTranscodeConfig=assignIn$1(this._liveTranscodeConfig,t),e.prev=4,this.safeEmit(EngineEventsTypes.onStreamMixingEvent,{event:StreamMixingEventType.UPDATE,error:0,message:""}),e.next=8,null===(r=this._room)||void 0===r?void 0:r.liveControlMessage(getTranscodeControlMessage("layoutChanged",this._liveTranscodeConfig));case 8:e.next=17;break;case 10:if(e.prev=10,e.t0=e.catch(4),!(e.t0 instanceof SDKError)){e.next=16;break}throw e.t0;case 16:throw new SDKError(ErrorCode.UNEXPECTED_ERROR,"unexpected error",e.t0);case 17:case"end":return e.stop()}}),e,this,[[4,10]])}))),function(e){return V.apply(this,arguments)})},{key:"stopLiveTranscoding",value:(B=_asyncToGenerator(_regeneratorRuntime().mark((function e(){var t;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(logger$1.print("stopLiveTranscoding()"),this._liveTranscodeConfig){e.next=3;break}return e.abrupt("return");case 3:return delete this._liveTranscodeConfig,e.prev=4,this.safeEmit(EngineEventsTypes.onStreamMixingEvent,{event:StreamMixingEventType.STOP,error:0,message:""}),e.next=8,null===(t=this._room)||void 0===t?void 0:t.liveControlMessage({action:"stopped",type:"transcode"});case 8:e.next=17;break;case 10:if(e.prev=10,e.t0=e.catch(4),!(e.t0 instanceof SDKError)){e.next=16;break}throw e.t0;case 16:throw new SDKError(ErrorCode.UNEXPECTED_ERROR,"unexpected error",e.t0);case 17:case"end":return e.stop()}}),e,this,[[4,10]])}))),function(){return B.apply(this,arguments)})},{key:"setBusinessId",value:function(e){return logger$1.print("setBusinessId()","businessId: %s",e),!illegalBusinessId(e)&&!this._room&&(commonStats.setStats({rtc_business_id:e}),this._businessId=e,!0)}},{key:"setUserVisibility",value:(F=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){var r,n;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(logger$1.print("setUserVisibility()","enable: %o",t),t=!!t,this._visibility!==t){e.next=4;break}return e.abrupt("return");case 4:if(this._room){e.next=7;break}return this._visibility=t,e.abrupt("return");case 7:if(this._room.connectionState===MediaConnectionState.CONNECTED){e.next=9;break}throw new SDKError(ErrorCode.NOT_CONNECTED_YET,"server not connected");case 9:if(this._room.localStream&&(null===(n=this._room.localStream.observer)||void 0===n||n.setPublisher(t)),e.t0=!t,!e.t0){e.next=14;break}return e.next=14,this._room.unpublish();case 14:return e.next=16,this._room.updateUserAttributes({role:t?UserRole.NORMAL_USER:UserRole.SILENT_USER});case 16:this._visibility=t,t&&null!==(r=this._roomConfig)&&void 0!==r&&r.isAutoPublish&&this._updatePublish({mediaType:MediaType.AUDIO_AND_VIDEO});case 18:case"end":return e.stop()}}),e,this)}))),function(e){return F.apply(this,arguments)})},{key:"_initPlayerEvents",value:function(e){var t=this,r=arguments.length>1&&void 0!==arguments[1]&&arguments[1];e.on("playback_event",(function(n){switch(n.eventName){case"timeupdate":return;case"loadeddata":if("audio"===n.type)r?t.safeEmit(EngineEventsTypes.onFirstPublicStreamAudioFrameDecoded,{publicStreamId:e.userId}):t.safeEmit(EngineEventsTypes.onAudioFirstFrameDecoded,{userId:e.userId}),monitor.firstRemoteAudioRender("",n.userId||"");else{var i,o,a={userId:e.userId,height:(null===(i=e.domElement)||void 0===i?void 0:i.videoHeight)||0,width:(null===(o=e.domElement)||void 0===o?void 0:o.videoWidth)||0};r?(a.publicStreamId=a.userId,delete a.userId,t.safeEmit(EngineEventsTypes.onFirstPublicStreamVideoFrameDecoded,a),t.safeEmit(EngineEventsTypes.onFirstPublicStreamVideoFrameRendered,a)):(t.safeEmit(EngineEventsTypes.onVideoFirstFrameDecoded,a),t.safeEmit(EngineEventsTypes.onVideoFirstFrameRendered,a)),monitor.firstRemoteVideoRender("",n.userId||"")}break;case"autoplay-error":return r&&(n.publicStreamId=n.userId),void t.safeEmit(EngineEventsTypes.onAutoplayFailed,{userId:n.userId||n.publicStreamId,kind:e instanceof VideoPlayer?"video":"audio"})}t.safeEmit(EngineEventsTypes.onPlayerEvent,n)}))}},{key:"_initLocalTrackEvents",value:function(e){var t=this,r=arguments.length>1&&void 0!==arguments[1]&&arguments[1];e.on("track-ended",(function(e){var r=!1;e!==t._localScreenAudioTrack&&e!==t._localScreenVideoTrack||(r=!0),t.safeEmit(EngineEventsTypes.onTrackEnded,{kind:e.getTrack().kind,isScreen:r})})),e.on("resolution-change",(function(e){t.safeEmit(EngineEventsTypes.onLocalVideoSizeChanged,{streamIndex:r?StreamIndex.STREAM_INDEX_SCREEN:StreamIndex.STREAM_INDEX_MAIN,info:e})}))}},{key:"setRemoteVideoPlayer",value:function(e,t){logger$1.print("setRemoteVideoPlayer()","streamIndex: %o, videoPlayerOption: %o",e,t),checkEnum(e,"streamIndex",[StreamIndex.STREAM_INDEX_MAIN,StreamIndex.STREAM_INDEX_SCREEN]),checkVideoPlayerOption(t);var r,n,i,o=t.userId;if(e===StreamIndex.STREAM_INDEX_MAIN){var a,s,c;if(null===(a=this._remoteVideoPlayer.get(o))||void 0===a||a.destroy(),!t.renderDom)return;var u=new VideoPlayer(t);this._initPlayerEvents(u),this._remoteVideoPlayer.set(o,u);var l=null===(s=this._room)||void 0===s||null===(c=s.remoteStreams.get(o))||void 0===c?void 0:c.find((function(e){return!e.isScreen}));return l&&this._updateVideoPlayerState(l),u.domElement}if(null===(r=this._remoteScreenPlayer.get(o))||void 0===r||r.destroy(),t.renderDom){var d=new VideoPlayer(_objectSpread2(_objectSpread2({},t),{},{isScreen:!0}));this._remoteScreenPlayer.set(o,d),this._initPlayerEvents(d);var p=null===(n=this._room)||void 0===n||null===(i=n.remoteStreams.get(o))||void 0===i?void 0:i.find((function(e){return e.isScreen}));return p&&this._updateVideoPlayerState(p),d.domElement}}},{key:"setLocalVideoMirrorType",value:function(e){logger$1.print("setLocalVideoMirrorType()","mirrorType: %o",e),checkEnum(e,"mirrorType",[MirrorType.MIRROR_TYPE_NONE,MirrorType.MIRROR_TYPE_RENDER]),this._mirrorType=e,this._videoPlayer&&this._videoPlayer.mirror(!!e)}},{key:"setAudioPlaybackDevice",value:(U=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){var r,n;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(logger$1.print("setAudioPlaybackDevice()","deviceId: %s",t),checkString(t,"deviceId"),void 0!==HTMLAudioElement.prototype.setSinkId){e.next=5;break}return logger$1.print("setAudioPlaybackDevice failed","setSinkId not supported by current browser"),e.abrupt("return");case 5:return e.next=7,detector.enumerateAudioPlaybackDevices();case 7:if(r=e.sent,n=r.find((function(e){return e.deviceId===t}))){e.next=11;break}throw new SDKError(ErrorCode.INVALID_DEVICE_ID,"audio playback device id ".concat(t," is invalid"));case 11:this._remoteAudioPlayer.forEach((function(e){e.setPlaybackDevice(t)})),this._audioPlaybackDeviceId=t,n&&this.safeEmit(EngineEventsTypes.onAudioPlaybackDeviceChanged,n),monitor.rtcAudioDevice(RtcaudiodeviceAudioEvent.PLAYOUT_DEVICE_SWITCH,t,0);case 15:case"end":return e.stop()}}),e,this)}))),function(e){return U.apply(this,arguments)})},{key:"play",value:(L=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){var r,n,i,o,a,s,c,u,l;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(logger$1.print("play()","userId | publicStreamId: %s",t),a=null===(r=this._room)||void 0===r||null===(n=r.remoteStreams.get(t||""))||void 0===n?void 0:n.find((function(e){return!e.isScreen})),i=this._remoteAudioPlayer.get(t||""),o=this._remoteVideoPlayer.get(t||""),i||(i=this._publicStreamAudioPlayer.get(t||"")),o||(o=this._publicStreamVideoPlayer.get(t||"")),!t&&this._videoPlayer&&(o=this._videoPlayer),o&&(o.played?o.manuallyPlay():a&&a.videoTrack?o.playVideo(a.videoTrack,a):!t&&this._localVideoTrack&&(o.mirror(!!this._mirrorType),o.playVideo(this._localVideoTrack))),i&&(i.played?i.manuallyPlay():null!=a&&a.audioTrack&&(i.playAudio(a.audioTrack),(c=null==a||null===(s=a.audioTrack._audioLevelFetcher)||void 0===s?void 0:s._ctx)&&c.resume())),null!=a&&a.audioTrack&&(l=null==a||null===(u=a.audioTrack._audioLevelFetcher)||void 0===u?void 0:u._ctx)&&"suspended"===l.state&&l.resume(),t||!this._audioMixingManager){e.next=13;break}return e.next=13,this._audioMixingManager.resumeLocalPlay();case 13:case"end":return e.stop()}}),e,this)}))),function(e){return L.apply(this,arguments)})},{key:"pauseAllSubscribedStream",value:(x=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){var r,n=this;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(logger$1.print("pauseAllSubscribedStream()","mediaType: %o",t),this._checkMediaType(t),!this._pauseAllSubscribeState.audio||!this._pauseAllSubscribeState.video){e.next=4;break}return e.abrupt("return",Promise.resolve());case 4:if(r=function(){audioInMediaType(t)&&(n._pauseAllSubscribeState.audio=!0),videoInMediaType(t)&&(n._pauseAllSubscribeState.video=!0)},this._room){e.next=8;break}return r(),e.abrupt("return",Promise.resolve());case 8:return e.abrupt("return",this._room.pauseAllSubscribedStream(t).then((function(){r()})));case 9:case"end":return e.stop()}}),e,this)}))),function(e){return x.apply(this,arguments)})},{key:"resumeAllSubscribedStream",value:(M=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){var r,n=this;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(logger$1.print("resumeAllSubscribedStream()","mediaType: %o",t),this._checkMediaType(t),this._pauseAllSubscribeState.audio||this._pauseAllSubscribeState.video){e.next=4;break}return e.abrupt("return",Promise.resolve());case 4:if(r=function(){audioInMediaType(t)&&(n._pauseAllSubscribeState.audio=!1),videoInMediaType(t)&&(n._pauseAllSubscribeState.video=!1)},this._room){e.next=8;break}return r(),e.abrupt("return",Promise.resolve());case 8:return e.abrupt("return",this._room.resumeAllSubscribedStream(t).then((function(){var e,t;r(),null===(e=n._room)||void 0===e||null===(t=e.remoteStreams)||void 0===t||t.forEach((function(e){Array.isArray(e)&&e.forEach((function(e){n._updateAudioPlayerState(e),n._updateVideoPlayerState(e)}))}))})));case 9:case"end":return e.stop()}}),e,this)}))),function(e){return M.apply(this,arguments)})},{key:"sendUserMessage",value:(D=_asyncToGenerator(_regeneratorRuntime().mark((function e(t,r){var n,i,o=this;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(checkUserId(t),checkBufferSize(r),this._room&&this._room.connectionState===MediaConnectionState.CONNECTED){e.next=4;break}throw new SDKError(ErrorCode.IM_BEFORE_JOIN,"join first");case 4:return i=Date.now(),e.abrupt("return",null===(n=this._room.sendUserMessage(t,r))||void 0===n?void 0:n.then((function(e){return o._messageStatisticsObserver.countP2PMessage(!0,t,!1,i,e),e.id})).catch((function(e){throw o._messageStatisticsObserver.countP2PMessage(!1,t,!1,i),e})));case 6:case"end":return e.stop()}}),e,this)}))),function(e,t){return D.apply(this,arguments)})},{key:"sendUserBinaryMessage",value:(N=_asyncToGenerator(_regeneratorRuntime().mark((function e(t,r){var n,i,o=this;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(checkUserId(t),checkArrayBuffer(r,"message"),checkBufferSize(r),this._room&&this._room.connectionState===MediaConnectionState.CONNECTED){e.next=5;break}throw new SDKError(ErrorCode.IM_BEFORE_JOIN,"join first");case 5:return i=Date.now(),e.abrupt("return",null===(n=this._room.sendUserMessage(t,r))||void 0===n?void 0:n.then((function(e){return o._messageStatisticsObserver.countP2PMessage(!0,t,!0,i,e),e.id})).catch((function(e){throw o._messageStatisticsObserver.countP2PMessage(!1,t,!0,i),e})));case 7:case"end":return e.stop()}}),e,this)}))),function(e,t){return N.apply(this,arguments)})},{key:"sendRoomMessage",value:(w=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){var r,n=this;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(checkBufferSize(t),this._room&&this._room.connectionState===MediaConnectionState.CONNECTED){e.next=3;break}throw new SDKError(ErrorCode.IM_BEFORE_JOIN,"join first");case 3:return r=Date.now(),e.abrupt("return",this._room.sendRoomMessage(t).then((function(e){var t,i;return n._messageStatisticsObserver.countRoomMessage(!0,null===(t=n._room)||void 0===t||null===(i=t.roomInfo)||void 0===i?void 0:i.roomId,!1,r),e})).catch((function(e){var t,i;throw n._messageStatisticsObserver.countRoomMessage(!1,null===(t=n._room)||void 0===t||null===(i=t.roomInfo)||void 0===i?void 0:i.roomId,!1,r),e})));case 5:case"end":return e.stop()}}),e,this)}))),function(e){return w.apply(this,arguments)})},{key:"sendRoomBinaryMessage",value:(k=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){var r,n=this;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(checkBufferSize(t),this._room&&this._room.connectionState===MediaConnectionState.CONNECTED){e.next=3;break}throw new SDKError(ErrorCode.IM_BEFORE_JOIN,"join first");case 3:return r=Date.now(),e.abrupt("return",this._room.sendRoomMessage(t,!0).then((function(e){var t,i;return n._messageStatisticsObserver.countRoomMessage(!0,null===(t=n._room)||void 0===t||null===(i=t.roomInfo)||void 0===i?void 0:i.roomId,!0,r),e})).catch((function(e){var t,i;throw n._messageStatisticsObserver.countRoomMessage(!1,null===(t=n._room)||void 0===t||null===(i=t.roomInfo)||void 0===i?void 0:i.roomId,!0,r),e})));case 5:case"end":return e.stop()}}),e,this)}))),function(e){return k.apply(this,arguments)})},{key:"setAudioCaptureConfig",value:(P=_asyncToGenerator(_regeneratorRuntime().mark((function e(){var t,r,n,i=arguments;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=i.length>0&&void 0!==i[0]?i[0]:{},logger$1.print("setAudioCaptureConfig()","config: %o",t),delete t.deviceId,checkSupportedConstraints(t),r=this._audioStreamConstraints.deviceId,this._audioStreamConstraints=t,r&&(this._audioStreamConstraints.deviceId=r),!this._localAudioTrack){e.next=11;break}return this._localAudioTrack.audioCaptureConfig=this._audioStreamConstraints,e.next=11,null===(n=this._localAudioTrack)||void 0===n?void 0:n.updateAudioCaptureConfig();case 11:case"end":return e.stop()}}),e,this)}))),function(){return P.apply(this,arguments)})},{key:"setVideoCaptureConfig",value:(O=_asyncToGenerator(_regeneratorRuntime().mark((function e(){var t,r,n,i=arguments;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=i.length>0&&void 0!==i[0]?i[0]:{},logger$1.print("setVideoCaptureConfig()","config: %o",t),delete t.deviceId,checkSupportedConstraints(t),r=this._videoStreamConstraints.deviceId,this._videoStreamConstraints=t,r&&(this._videoStreamConstraints.deviceId=r),!this._localVideoTrack){e.next=12;break}return this._localVideoTrack.videoCaptureConfig=this._videoStreamConstraints,e.next=11,null===(n=this._localVideoTrack)||void 0===n?void 0:n.updateVideoCaptureConfig();case 11:this._updatePublish();case 12:case"end":return e.stop()}}),e,this)}))),function(){return O.apply(this,arguments)})},{key:"enableSimulcastMode",value:function(e){return logger$1.print("enableSimulcastMode()","enabled: %o",e),this._enableSimulcast=e,!0}},{key:"setVideoEncoderConfig",value:(C=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){var r;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:logger$1.print("setVideoEncoderConfig()"," descriptions: %o",t),Array.isArray(t)||(t=[t]),t.length>3&&(t=t.slice(0,3)),t.sort((function(e,t){return t.maxKbps-e.maxKbps})),this._videoStreamEncodeConfig=t,null!==(r=this._room)&&void 0!==r&&r.hasPublished&&this._updatePublish();case 6:case"end":return e.stop()}}),e,this)}))),function(e){return C.apply(this,arguments)})},{key:"setScreenEncoderConfig",value:(A=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){var r;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:logger$1.print("setScreenEncoderConfig()","description: %o",t),this._screenStreamEncodeConfig=[t],this._localScreenVideoTrack&&(this._localScreenVideoTrack.videoCaptureConfig=t,this._localScreenVideoTrack.updateVideoCaptureConfig(),t.contentHint&&this._localScreenVideoTrack.setContentHint(t.contentHint)),null!==(r=this._room)&&void 0!==r&&r.hasScreenPublished&&this._updateScreenPublish();case 4:case"end":return e.stop()}}),e,this)}))),function(e){return A.apply(this,arguments)})},{key:"sendSEIMessage",value:function(e,t,r){logger$1.print("sendSEIMessage()","streamIdex: %o, message: %o, repeatCount: %o",e,t,r),checkEnum(e,"streamIndex",[StreamIndex.STREAM_INDEX_MAIN,StreamIndex.STREAM_INDEX_SCREEN]),checkNumber(r,"repeatCount",0,30);var n="string"==typeof t?new Uint8Array(Utils.str2ab(t)):t;if(t.length){var i;if(e===StreamIndex.STREAM_INDEX_MAIN){var o,a,s;if(null===(o=this._room)||void 0===o||null===(a=o.localStream)||void 0===a||!a.hasPublished)return;i=null===(s=this._room)||void 0===s?void 0:s.localStream}else{var c,u,l;if(null===(c=this._room)||void 0===c||null===(u=c.localScreenStream)||void 0===u||!u.hasPublished)return;i=null===(l=this._room)||void 0===l?void 0:l.localScreenStream}if(n.byteLength>4096)logger$1.print("sei size must not bigger than 4KB");else{var d=genUuid();i.seiList.push({content:n,uuid:d,repeatCount:r}),setTimeout((function(){if(i){var e=i.seiList.findIndex((function(e){return e.uuid===d}));e&&i.seiList.splice(e,1)}}),2e3)}}else logger$1.print("sei message must not be empty")}},{key:"setAudioVolumeIndicationInterval",value:function(e){var t=this;logger$1.print("setAudioVolumeIndicationInterval()","interval %o: ",e),("number"!=typeof e||e<200)&&(e=200);var r=[];this._audioVolumeIndicationTimer&&clearInterval(this._audioVolumeIndicationTimer),this._audioVolumeIndicationTimer=setInterval((function(){var e,n;r=[],null===(e=t._room)||void 0===e||e.remoteStreams.forEach((function(e,t){var n;if(0!==e.length){var i=e.find((function(e){return!1===e.isScreen})),o=null==i||null===(n=i.audioTrack)||void 0===n?void 0:n.getAudioLevel();r.push({userId:t,volume:o||0})}}));var i=null===(n=t._localAudioTrack)||void 0===n?void 0:n.getAudioLevel();r.push({userId:t._getUserId(),volume:i||0}),t.safeEmit(EngineEventsTypes.onAudioVolumeIndication,{speakers:r})}),e)}},{key:"_sendActiveSpeaker",value:function(e,t){if(this._room&&this._room.remoteUsers.size>=1){var r,n=e[0],i=t.reduce((function(e,t){return e&&e.audioPropertiesInfo.nonlinearVolume>t.audioPropertiesInfo.nonlinearVolume?e:t}),void 0);if((r=n?i?n.audioPropertiesInfo.nonlinearVolume>i.audioPropertiesInfo.nonlinearVolume?n:i:n:i)&&r.audioPropertiesInfo.nonlinearVolume>-60){var o,a;if(r.streamKey)o=this._room.remoteUsers.get(r.streamKey.userId);else o=null===(a=this._room._roomInfo)||void 0===a?void 0:a.userInfo;o&&this.safeEmit(EngineEventsTypes.onActiveSpeaker,{userId:o.userId,extraInfo:o.extraInfo})}}}},{key:"enableAudioPropertiesReport",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};logger$1.print("enableAudioPropertiesReport()","config %o: ",t);var r=t.enableInBackground,n=void 0===r||r,i=t.interval,o=void 0===i?100:i;this._stopAudioPropertiesReport(),o<=0||(o=Math.max(100,o),this._audioPropertiesReportTimer=self.setInterval((function(){if(n||"hidden"!==document.visibilityState){var t=[],r=e._audioDeviceManager.getRecordTrack()||e._localAudioTrack;if(r){var i=r.getAudioLevel();t.push({streamIndex:StreamIndex.STREAM_INDEX_MAIN,audioPropertiesInfo:{linearVolume:i,nonlinearVolume:getNonlinearVolume(i)}})}if(e._localScreenAudioTrack){var o=e._localScreenAudioTrack.getAudioLevel();t.push({streamIndex:StreamIndex.STREAM_INDEX_SCREEN,audioPropertiesInfo:{linearVolume:o,nonlinearVolume:getNonlinearVolume(o)}})}if(e.safeEmit(EngineEventsTypes.onLocalAudioPropertiesReport,t),e._room){var a=[];e._room.remoteStreams.forEach((function(t,r){t.forEach((function(t){if(t.audioTrack){var n,i,o=t.audioTrack.getAudioLevel();a.push({streamKey:{userId:r,streamIndex:t.isScreen?StreamIndex.STREAM_INDEX_SCREEN:StreamIndex.STREAM_INDEX_MAIN,roomId:null===(n=e._room)||void 0===n||null===(i=n.roomInfo)||void 0===i?void 0:i.roomId},audioPropertiesInfo:{linearVolume:o,nonlinearVolume:getNonlinearVolume(o)}})}}))})),e._sendActiveSpeaker(t,a.filter((function(e){return e.streamKey.streamIndex!==StreamIndex.STREAM_INDEX_SCREEN}))),e.safeEmit(EngineEventsTypes.onRemoteAudioPropertiesReport,a)}}}),o))}},{key:"setVideoSourceType",value:($=_asyncToGenerator(_regeneratorRuntime().mark((function e(t,r){var n,i,o,a,s,c,u,l,d,p,_,f,h,m,y,v,S,g,E,T,b;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(logger$1.print("setVideoSourceType()","index: %o, videoSourceType: %o",t,r),checkEnum(t,"streamIndex",[StreamIndex.STREAM_INDEX_MAIN,StreamIndex.STREAM_INDEX_SCREEN]),checkEnum(r,"VideoSourceType",[VideoSourceType.VIDEO_SOURCE_TYPE_EXTERNAL,VideoSourceType.VIDEO_SOURCE_TYPE_INTERNAL]),n=t===StreamIndex.STREAM_INDEX_MAIN?"video":"screenVideo",this._trackSourceType[n]===r){e.next=26;break}if(this._trackSourceType[n]=r,logger$1.print("setVideoSourceType","set ".concat(n," source type to ").concat(r)),!this._localVideoTrack||t!==StreamIndex.STREAM_INDEX_MAIN){e.next=17;break}if(s=!1,r===VideoSourceType.VIDEO_SOURCE_TYPE_EXTERNAL&&(s=!0,this._localVideoTrack.close()),null===(i=this._videoPlayer)||void 0===i||i.stop(),this._localVideoTrack=void 0,c=null===(o=this._room)||void 0===o?void 0:o._roomConfig.isAutoPublish,s?null===(u=this._room)||void 0===u||null===(l=u.localStream)||void 0===l||null===(d=l.observer)||void 0===d||d.setEnableVideo(!1):null===(p=this._room)||void 0===p||null===(_=p.localStream)||void 0===_||null===(f=_.observer)||void 0===f||f.setPushVideo(!1),!(null!==(a=this._room)&&void 0!==a&&a.hasPublished||c)){e.next=17;break}return e.next=17,this._updatePublish();case 17:if(!this._localScreenVideoTrack||t!==StreamIndex.STREAM_INDEX_SCREEN){e.next=26;break}if(y=!1,r===VideoSourceType.VIDEO_SOURCE_TYPE_EXTERNAL&&(y=!0,this._localScreenVideoTrack.close()),null===(h=this._screenPlayer)||void 0===h||h.stop(),this._localScreenVideoTrack=void 0,y?null===(v=this._room)||void 0===v||null===(S=v.localScreenStream)||void 0===S||null===(g=S.observer)||void 0===g||g.setEnableVideo(!1):null===(E=this._room)||void 0===E||null===(T=E.localScreenStream)||void 0===T||null===(b=T.observer)||void 0===b||b.setPushVideo(!1),null===(m=this._room)||void 0===m||!m.hasScreenPublished){e.next=26;break}return e.next=26,this._updateScreenPublish();case 26:case"end":return e.stop()}}),e,this)}))),function(e,t){return $.apply(this,arguments)})},{key:"setExternalVideoTrack",value:(I=_asyncToGenerator(_regeneratorRuntime().mark((function e(t,r){var n,i,o,a,s,c,u,l,d;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(logger$1.print("setExternalVideoTrack()","index: %o, track: %o",t,r),checkEnum(t,"streamIndex",[StreamIndex.STREAM_INDEX_MAIN,StreamIndex.STREAM_INDEX_SCREEN]),t!==StreamIndex.STREAM_INDEX_MAIN){e.next=12;break}if(this._trackSourceType.video===VideoSourceType.VIDEO_SOURCE_TYPE_EXTERNAL){e.next=5;break}throw new SDKError(ErrorCode.STREAM_TYPE_NOT_MATCH,"setVideoSourceType as external first");case 5:if(this._localVideoTrack=new CustomVideoLocalTrack(r,genUuid()),this._initLocalTrackEvents(this._localVideoTrack),null===(n=this._videoPlayer)||void 0===n||n.playVideo(this._localVideoTrack),a=null===(i=this._room)||void 0===i?void 0:i._roomConfig.isAutoPublish,!(null!==(o=this._room)&&void 0!==o&&o.hasPublished||a)){e.next=12;break}return e.next=12,this._updatePublish();case 12:if(t!==StreamIndex.STREAM_INDEX_SCREEN){e.next=22;break}if(this._trackSourceType.screenVideo===VideoSourceType.VIDEO_SOURCE_TYPE_EXTERNAL){e.next=15;break}throw new SDKError(ErrorCode.STREAM_TYPE_NOT_MATCH,"setVideoSourceType as external first");case 15:if(this._localScreenVideoTrack=new CustomVideoLocalTrack(r,genUuid()),this._initLocalTrackEvents(this._localScreenVideoTrack,!0),null===(s=this._screenPlayer)||void 0===s||s.playVideo(this._localScreenVideoTrack),null===(c=this._room)||void 0===c||null===(u=c.localScreenStream)||void 0===u||null===(l=u.observer)||void 0===l||l.setPushVideo(!0),null===(d=this._room)||void 0===d||!d.hasScreenPublished){e.next=22;break}return e.next=22,this._updateScreenPublish();case 22:case"end":return e.stop()}}),e,this)}))),function(e,t){return I.apply(this,arguments)})},{key:"setAudioSourceType",value:(R=_asyncToGenerator(_regeneratorRuntime().mark((function e(t,r){var n,i,o,a,s,c,u,l,d,p,_,f,h,m,y,v,S,g,E;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(logger$1.print("setAudioSourceType()","index: %o, audioSourceType: %o",t,r),checkEnum(t,"streamIndex",[StreamIndex.STREAM_INDEX_MAIN,StreamIndex.STREAM_INDEX_SCREEN]),checkEnum(r,"audioSourceType",[AudioSourceType.AUDIO_SOURCE_TYPE_EXTERNAL,AudioSourceType.AUDIO_SOURCE_TYPE_INTERNAL]),n=t===StreamIndex.STREAM_INDEX_MAIN?"audio":"screenAudio",this._trackSourceType[n]===r){e.next=24;break}if(this._trackSourceType[n]=r,logger$1.print("setVideoSourceType","set ".concat(n," source type to ").concat(r)),!this._localAudioTrack||t!==StreamIndex.STREAM_INDEX_MAIN){e.next=16;break}if(a=!1,this._trackSourceType.audio===AudioSourceType.AUDIO_SOURCE_TYPE_EXTERNAL&&(a=!0,this._localAudioTrack.close()),this._localAudioTrack=void 0,s=null===(i=this._room)||void 0===i?void 0:i._roomConfig.isAutoPublish,a?null===(c=this._room)||void 0===c||null===(u=c.localStream)||void 0===u||null===(l=u.observer)||void 0===l||l.setEnableAudio(!1):null===(d=this._room)||void 0===d||null===(p=d.localStream)||void 0===p||null===(_=p.observer)||void 0===_||_.setPushAudio(!1),!(null!==(o=this._room)&&void 0!==o&&o.hasPublished||s)){e.next=16;break}return e.next=16,this._updatePublish();case 16:if(!this._localScreenAudioTrack||t!==StreamIndex.STREAM_INDEX_SCREEN){e.next=24;break}if(h=!1,this._trackSourceType.audio===AudioSourceType.AUDIO_SOURCE_TYPE_EXTERNAL&&(h=!0,this._localScreenAudioTrack.close()),this._localScreenAudioTrack=void 0,h?null===(m=this._room)||void 0===m||null===(y=m.localScreenStream)||void 0===y||null===(v=y.observer)||void 0===v||v.setEnableAudio(!1):null===(S=this._room)||void 0===S||null===(g=S.localScreenStream)||void 0===g||null===(E=g.observer)||void 0===E||E.setPushAudio(!1),null===(f=this._room)||void 0===f||!f.hasScreenPublished){e.next=24;break}return e.next=24,this._updateScreenPublish();case 24:case"end":return e.stop()}}),e,this)}))),function(e,t){return R.apply(this,arguments)})},{key:"setExternalAudioTrack",value:(b=_asyncToGenerator(_regeneratorRuntime().mark((function e(t,r){var n,i,o,a,s,c,u,l,d,p;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(logger$1.print("setExternalAudioTrack()","index: %o, track: %o",t,r),checkEnum(t,"streamIndex",[StreamIndex.STREAM_INDEX_MAIN,StreamIndex.STREAM_INDEX_SCREEN]),t!==StreamIndex.STREAM_INDEX_MAIN){e.next=12;break}if(this._trackSourceType.audio===AudioSourceType.AUDIO_SOURCE_TYPE_EXTERNAL){e.next=5;break}throw new SDKError(ErrorCode.STREAM_TYPE_NOT_MATCH,"setAudioSourceType as external first");case 5:if(this._localAudioTrack=new CustomAudioLocalTrack(r,genUuid()),this._initLocalTrackEvents(this._localAudioTrack),c=null===(n=this._room)||void 0===n?void 0:n._roomConfig.isAutoPublish,null===(i=this._room)||void 0===i||null===(o=i.localStream)||void 0===o||null===(a=o.observer)||void 0===a||a.setPushAudio(!0),!(null!==(s=this._room)&&void 0!==s&&s.hasPublished||c)){e.next=12;break}return e.next=12,this._updatePublish();case 12:if(t!==StreamIndex.STREAM_INDEX_SCREEN){e.next=21;break}if(this._trackSourceType.screenAudio===AudioSourceType.AUDIO_SOURCE_TYPE_EXTERNAL){e.next=15;break}throw new SDKError(ErrorCode.STREAM_TYPE_NOT_MATCH,"setAudioSourceType as external first");case 15:if(this._localScreenAudioTrack=new CustomAudioLocalTrack(r,genUuid()),this._initLocalTrackEvents(this._localScreenAudioTrack),null===(u=this._room)||void 0===u||null===(l=u.localScreenStream)||void 0===l||null===(d=l.observer)||void 0===d||d.setPushAudio(!0),null===(p=this._room)||void 0===p||!p.hasScreenPublished){e.next=21;break}return e.next=21,this._updateScreenPublish();case 21:case"end":return e.stop()}}),e,this)}))),function(e,t){return b.apply(this,arguments)})},{key:"login",value:(T=_asyncToGenerator(_regeneratorRuntime().mark((function e(t,r){return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return logger$1.print("login()","token: %o, userInfo: %o",t,r),isEmpty(t)||checkString(t,"token"),checkUserId(r),e.abrupt("return",this._rtmClient.login(t,r));case 4:case"end":return e.stop()}}),e,this)}))),function(e,t){return T.apply(this,arguments)})},{key:"logout",value:(E=_asyncToGenerator(_regeneratorRuntime().mark((function e(){return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return logger$1.print("logout()"),e.abrupt("return",this._rtmClient.logout());case 2:case"end":return e.stop()}}),e,this)}))),function(){return E.apply(this,arguments)})},{key:"updateLoginToken",value:(g=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return logger$1.print("updateLoginToken()","token: %o",t),isEmpty(t)||checkString(t,"token"),e.abrupt("return",this._rtmClient.updateLoginToken(t));case 3:case"end":return e.stop()}}),e,this)}))),function(e){return g.apply(this,arguments)})},{key:"getPeerOnlineStatus",value:(S=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return logger$1.print("getPeerOnlineStatus()","userId: %o",t),checkUserId(t),e.abrupt("return",this._rtmClient.getPeerOnlineStatus(t));case 3:case"end":return e.stop()}}),e,this)}))),function(e){return S.apply(this,arguments)})},{key:"sendUserMessageOutsideRoom",value:(v=_asyncToGenerator(_regeneratorRuntime().mark((function e(t,r){var n,i=this;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return checkUserId(t),checkBufferSize(r),n=Date.now(),e.prev=3,e.abrupt("return",this._rtmClient.sendUserMessageOutsideRoom(t,r).then((function(e){return i._messageStatisticsObserver.countUserMessageOutsideRoom(!0,t,!1,n,e),e.id})).catch((function(e){throw i._messageStatisticsObserver.countUserMessageOutsideRoom(!1,t,!1,n),e})));case 7:throw e.prev=7,e.t0=e.catch(3),this._messageStatisticsObserver.countUserMessageOutsideRoom(!1,t,!1,n),e.t0;case 11:case"end":return e.stop()}}),e,this,[[3,7]])}))),function(e,t){return v.apply(this,arguments)})},{key:"sendUserBinaryMessageOutsideRoom",value:(y=_asyncToGenerator(_regeneratorRuntime().mark((function e(t,r){var n,i=this;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return checkUserId(t),checkArrayBuffer(r,"message"),checkBufferSize(r),n=Date.now(),e.prev=4,e.abrupt("return",this._rtmClient.sendUserMessageOutsideRoom(t,r).then((function(e){return i._messageStatisticsObserver.countUserMessageOutsideRoom(!0,t,!0,n,e),e.id})).catch((function(e){throw i._messageStatisticsObserver.countUserMessageOutsideRoom(!1,t,!0,n),e})));case 8:throw e.prev=8,e.t0=e.catch(4),this._messageStatisticsObserver.countUserMessageOutsideRoom(!1,t,!0,n),e.t0;case 12:case"end":return e.stop()}}),e,this,[[4,8]])}))),function(e,t){return y.apply(this,arguments)})},{key:"setServerParams",value:(m=_asyncToGenerator(_regeneratorRuntime().mark((function e(t,r){return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return logger$1.print("setServerParams()","signature: %o, url: %0",t,r),e.abrupt("return",this._rtmClient.setServerParams(t,r));case 2:case"end":return e.stop()}}),e,this)}))),function(e,t){return m.apply(this,arguments)})},{key:"sendServerMessage",value:(h=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){var r,n=this;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return checkString(t,"message"),checkBufferSize(t),r=Date.now(),e.prev=3,e.abrupt("return",this._rtmClient.sendServerMessage(t).then((function(){n._messageStatisticsObserver.countServerMessage(!0,!1,r)})).catch((function(e){throw n._messageStatisticsObserver.countServerMessage(!1,!1,r),e})));case 7:throw e.prev=7,e.t0=e.catch(3),this._messageStatisticsObserver.countServerMessage(!1,!1,r),e.t0;case 11:case"end":return e.stop()}}),e,this,[[3,7]])}))),function(e){return h.apply(this,arguments)})},{key:"sendServerBinaryMessage",value:(f=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){var r,n=this;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return checkArrayBuffer(t,"message"),checkBufferSize(t),r=Date.now(),e.prev=3,e.abrupt("return",this._rtmClient.sendServerMessage(t).then((function(){n._messageStatisticsObserver.countServerMessage(!0,!0,r)})).catch((function(e){throw n._messageStatisticsObserver.countServerMessage(!1,!0,r),e})));case 7:throw e.prev=7,e.t0=e.catch(3),this._messageStatisticsObserver.countServerMessage(!1,!0,r),e.t0;case 11:case"end":return e.stop()}}),e,this,[[3,7]])}))),function(e){return f.apply(this,arguments)})},{key:"startCloudProxy",value:function(e){if(this._room)throw new SDKError(ErrorCode.START_CLOUD_PROXY_AFTER_JOIN,"[startCloudProxy] should be invoke before join room ");logger$1.print("startCloudProxy()",e),checkString(e.logProxy,"logProxy"),checkString(e.accessProxy,"accessProxy"),checkString(e.configProxy,"configProxy"),this._originIceConfigRequestUrls=getParameter("ICE_CONFIG_REQUEST_URLS"),this._originLogServerUrl=getParameter("LOG_SERVER_URL"),this._originConfigServerUrls=getParameter("CONFIG_REQUEST_DOMAINS"),setParameter("ICE_CONFIG_REQUEST_URLS",e.accessProxy),setParameter("LOG_SERVER_URL",getFullLogServerUrl(e.logProxy)),setParameter("CONFIG_REQUEST_DOMAINS",[e.configProxy]),this._useCloudProxy=!0}},{key:"stopCloudProxy",value:function(){if(this._room)throw new SDKError(ErrorCode.STOP_CLOUD_PROXY_BEFORE_LEAVE,"[stopCloudProxy] should be invoke after leave room ");logger$1.print("stopCloudProxy()"),setParameter("ICE_CONFIG_REQUEST_URLS",[]),setParameter("LOG_SERVER_URL",this._originLogServerUrl),setParameter("CONFIG_REQUEST_DOMAINS",this._originConfigServerUrls),this._useCloudProxy=!1,this._startCloudProxyTimestamp=void 0}},{key:"startPushPublicStream",value:(_=_asyncToGenerator(_regeneratorRuntime().mark((function e(t,r){var n,i=this;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(logger$1.print("startPushPublicStream()","publicStreamId: %o, publicStreamParam: %o",t,r),checkPublicStreamId(t),this._room&&this._room.connectionState===MediaConnectionState.CONNECTED){e.next=4;break}throw new SDKError(ErrorCode.START_PUBLIC_STREAM_BEFORE_JOIN,"join first");case 4:if(!this._publicStreamIds.get(t)){e.next=6;break}throw new SDKError(ErrorCode.REPEAT_PUSH,"repeat push public media stream");case 6:return n=getPublicStreamControlMessage(t,"started",r),e.abrupt("return",this._room.publicStreamControlMessage(n).then((function(){i._publicStreamIds.set(t,t)})));case 8:case"end":return e.stop()}}),e,this)}))),function(e,t){return _.apply(this,arguments)})},{key:"updatePublicStreamParam",value:(p=_asyncToGenerator(_regeneratorRuntime().mark((function e(t,r){var n;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(logger$1.print("startPushPublicStream()","publicStreamId: %o, publicStreamParam: %o",t,r),checkPublicStreamId(t),this._room&&this._room.connectionState===MediaConnectionState.CONNECTED){e.next=4;break}throw new SDKError(ErrorCode.START_PUBLIC_STREAM_BEFORE_JOIN,"join first");case 4:return n=getPublicStreamControlMessage(t,"layoutChanged",r),e.abrupt("return",this._room.publicStreamControlMessage(n));case 6:case"end":return e.stop()}}),e,this)}))),function(e,t){return p.apply(this,arguments)})},{key:"stopPushPublicStream",value:(d=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){var r=this;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(logger$1.print("startPushPublicStream()","publicStreamId: %o",t),checkPublicStreamId(t),this._room&&this._room.connectionState===MediaConnectionState.CONNECTED){e.next=4;break}throw new SDKError(ErrorCode.START_PUBLIC_STREAM_BEFORE_JOIN,"join first");case 4:return e.abrupt("return",this._room.publicStreamControlMessage({type:"publicstream",action:"stopped",publicStreamID:t}).then((function(){r._publicStreamIds.delete(t)})));case 5:case"end":return e.stop()}}),e,this)}))),function(e){return d.apply(this,arguments)})},{key:"startPlayPublicStream",value:(l=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){var r,n,i,o,a,s,c=this;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(checkPublicStreamId(t),this._outsideRoom){e.next=8;break}return this._outsideRoom=new OutsideRoom(this._appId),this._outsideRoom.on(RoomEvent.RESUBSCRIBE,(function(e){var t=e.stream;if(t){var r,n=c._publicStreamAudioPlayer.get(t.streamId);n&&t.audioTrack&&(n.stop(),n.playAudio(null===(r=e.stream)||void 0===r?void 0:r.audioTrack));var i,o=c._publicStreamVideoPlayer.get(t.streamId);o&&t.videoTrack&&o.playVideo(null===(i=e.stream)||void 0===i?void 0:i.videoTrack)}})),null===(r=this._outsideRoom)||void 0===r||r.on("onRemoteStreamStats",(function(e){e.publicStreamId=e.userId,delete e.userId,delete e.isScreen,c.safeEmit(EngineEventsTypes.onPublicStreamStats,e)})),null===(n=this._outsideRoom)||void 0===n||n.on(RoomEvent.ON_SEI_MESSAGED_RECEIVED,(function(e){c.safeEmit(EngineEventsTypes.onPublicStreamSEIMessageReceived,e)})),e.next=8,this._outsideRoom.connect();case 8:return e.next=10,this._outsideRoom.startPlayPublicStream(t);case 10:i=e.sent,(o=this._publicStreamVideoPlayer.get(t))&&null!=i&&i.videoTrack&&o.playVideo(i.videoTrack,i),!(a=this._publicStreamAudioPlayer.get(t))&&null!=i&&i.audioTrack&&(a=new AudioPlayer(t,{muted:(null===(s=this._config)||void 0===s?void 0:s.autoPlayPolicy)===RTCAutoPlayPolicy.VIDEO_ONLY}),this._initPlayerEvents(a,!0),a.playAudio(i.audioTrack),this._publicStreamAudioPlayer.set(t,a));case 15:case"end":return e.stop()}}),e,this)}))),function(e){return l.apply(this,arguments)})},{key:"stopPlayPublicStream",value:(u=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){var r;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._outsideRoom){e.next=2;break}return e.abrupt("return");case 2:this._outsideRoom.stopPlayPublicStream(t),(r=this._publicStreamAudioPlayer.get(t))&&(r.destroy(),this._publicStreamAudioPlayer.delete(t));case 5:case"end":return e.stop()}}),e,this)}))),function(e){return u.apply(this,arguments)})},{key:"setAudioProfile",value:(c=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._audioProfileManager.setAudioProfile(t);case 1:case"end":return e.stop()}}),e,this)}))),function(e){return c.apply(this,arguments)})},{key:"setPublicStreamVideoPlayer",value:function(e,t){var r,n,i,o;logger$1.print("setPublicStreamVideoPlayer()","publicStreamId: %o, videoPlayerOption: %o",e,t);var a=this._publicStreamVideoPlayer.get(e);if(null===(r=a)||void 0===r||r.destroy(),null!=t&&t.renderDom){a=new VideoPlayer(_objectSpread2(_objectSpread2({},t),{},{userId:e})),this._initPlayerEvents(a,!0),this._publicStreamVideoPlayer.set(e,a);var s=null===(n=this._outsideRoom)||void 0===n||null===(i=n.remoteStreams)||void 0===i?void 0:i.get(e);null!=s&&s.videoTrack&&(null===(o=this._config)||void 0===o?void 0:o.autoPlayPolicy)!==RTCAutoPlayPolicy.PLAY_MANUALLY&&a.playVideo(s.videoTrack,s)}else this._publicStreamVideoPlayer.delete(e)}},{key:"setDummyCaptureImagePath",value:(s=_asyncToGenerator(_regeneratorRuntime().mark((function e(t,r){var n=this;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",new Promise((function(e,i){checkString(r,"filePath");var o=new Image;o.crossOrigin="anonymous",o.src=r,o.onload=function(){try{var r=document.createElement("canvas"),a=r.getContext("2d");if(!a)return i(new SDKError(ErrorCode.UNEXPECTED_ERROR,"Not support canvas"));r.width=o.width,r.height=o.height,a.drawImage(o,0,0,o.width,o.height),clearInterval(n._dummyTimer),n._dummyTimer=window.setInterval((function(){a.drawImage(o,0,0,o.width,o.height)}),200);var s=r.captureStream(5).getVideoTracks()[0];t===StreamIndex.STREAM_INDEX_MAIN?n._localImgVideoTrack=s:n._localImgScreenTrack=s,e()}catch(e){i(new SDKError(ErrorCode.UNEXPECTED_ERROR,e.message))}},o.onerror=function(){i(new SDKError(ErrorCode.UNEXPECTED_ERROR,"Load image error"))}})));case 1:case"end":return e.stop()}}),e)}))),function(e,t){return s.apply(this,arguments)})},{key:"defaultTranscoding",value:function(){return JSON.parse(JSON.stringify(defaultTranscoding))}},{key:"_updatePublish",value:(a=_asyncToGenerator(_regeneratorRuntime().mark((function e(){var t,r,n,i=arguments;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=i.length>0&&void 0!==i[0]?i[0]:{},logger$1.print("_updatePublish()","config: %o",t),r={mediaType:void 0,invokeByJoinRoom:!1,pubState:PubState.PUB},t=_objectSpread2(_objectSpread2({},r),t),this._visibility){e.next=6;break}throw new SDKError(ErrorCode.NO_PUBLISH_PERMISSION,"no publish permission");case 6:return e.next=8,this._pubLock.lock();case 8:if(n=e.sent,this._room&&this._room.connectionState===MediaConnectionState.CONNECTED){e.next=12;break}return n(),e.abrupt("return");case 12:return e.prev=12,e.next=15,this._room.publish(this._videoStreamEncodeConfig,this._enableSimulcast,this._localVideoTrack,this._localAudioTrack,t.mediaType,t.pubState,t.invokeByJoinRoom);case 15:e.next=24;break;case 17:if(e.prev=17,e.t0=e.catch(12),!(e.t0 instanceof SDKError)){e.next=23;break}throw e.t0;case 23:throw new SDKError(ErrorCode.UNEXPECTED_ERROR,"unexpected error",e.t0);case 24:return e.prev=24,n(),e.finish(24);case 27:case"end":return e.stop()}}),e,this,[[12,17,24,27]])}))),function(){return a.apply(this,arguments)})},{key:"startAudioPlaybackDeviceTest",value:(o=_asyncToGenerator(_regeneratorRuntime().mark((function e(t,r){return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return logger$1.print("startAudioPlaybackDeviceTest()","filePath: %o, indicationInterval: %o",t,r),checkString(t,"filePath"),checkNumber(r,"indicationInterval"),e.next=5,this._audioDeviceManager.startAudioPlaybackDeviceTest(t,r);case 5:return e.abrupt("return",e.sent);case 6:case"end":return e.stop()}}),e,this)}))),function(e,t){return o.apply(this,arguments)})},{key:"stopAudioPlaybackDeviceTest",value:function(){logger$1.print("stopAudioPlaybackDeviceTest()"),this._audioDeviceManager.stopAudioPlaybackDeviceTest()}},{key:"startAudioDeviceRecordTest",value:(i=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return logger$1.print("startAudioDeviceRecordTest()","indicationInterval: %o",t),checkNumber(t,"indicationInterval"),e.next=4,this._audioDeviceManager.startAudioDeviceRecordTest(t);case 4:case"end":return e.stop()}}),e,this)}))),function(e){return i.apply(this,arguments)})},{key:"stopAudioDeviceRecordAndPlayTest",value:function(){logger$1.print("stopAudioDeviceRecordAndPlayTest()"),this._audioDeviceManager.stopAudioDeviceRecordAndPlayTest()}},{key:"stopAudioDevicePlayTest",value:function(){logger$1.print("stopAudioDevicePlayTest()"),this._audioDeviceManager.stopAudioDevicePlayTest()}},{key:"setRemoteUserPriority",value:function(e,t){var r;logger$1.print("setRemoteUserPriority()","userId: %o, priority: %o",e,t);try{checkUserId(e),checkEnum(t,"priority",[RemoteUserPriority.HIGH,RemoteUserPriority.MEDIUM,RemoteUserPriority.LOW])}catch(e){return console.warn(e),!1}return this._userPriorityMap.set(e,t),null===(r=this._room)||void 0===r||r.setRemoteUserPriority(e,t),!0}},{key:"takeLocalSnapshot",value:(n=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){var r,n;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(logger$1.print("takeLocalSnapshot()","streamIndex: %o",t),checkEnum(t,"streamIndex",[StreamIndex.STREAM_INDEX_MAIN,StreamIndex.STREAM_INDEX_SCREEN]),r=t===StreamIndex.STREAM_INDEX_MAIN?this.localVideoTrack:this.localScreenVideoTrack){e.next=5;break}throw new SDKError(ErrorCode.INVOKED_BEFORE_CAPTURE,"capture first");case 5:return n=t===StreamIndex.STREAM_INDEX_MAIN?this._videoPlayer:this._screenPlayer,e.abrupt("return",takeSnapshot(r.getTrack(),(null==n?void 0:n.mirrorType)===MirrorType.MIRROR_TYPE_RENDER,n));case 7:case"end":return e.stop()}}),e,this)}))),function(e){return n.apply(this,arguments)})},{key:"takeRemoteSnapshot",value:(r=_asyncToGenerator(_regeneratorRuntime().mark((function e(t,r){var n,i,o,a,s,c;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(logger$1.print("takeRemoteSnapshot()","id: %o, streamIndex: %o",t,r),checkString(t,"id"),checkEnum(r,"streamIndex",[StreamIndex.STREAM_INDEX_MAIN,StreamIndex.STREAM_INDEX_SCREEN]),c=(null===(n=this._room)||void 0===n||null===(i=n.remoteStreams.get(t))||void 0===i||null===(o=i.find((function(e){return e.isScreen===(r===StreamIndex.STREAM_INDEX_SCREEN)})))||void 0===o?void 0:o.videoTrack)||(null===(a=this._outsideRoom)||void 0===a||null===(s=a.remoteStreams.get(t))||void 0===s?void 0:s.videoTrack)){e.next=6;break}throw new SDKError(ErrorCode.STREAM_NOT_EXIST,"stream not exist");case 6:return e.abrupt("return",takeSnapshot(c.getTrack(),!1,r===StreamIndex.STREAM_INDEX_MAIN?this._remoteVideoPlayer.get(t):this._remoteScreenPlayer.get(t)));case 7:case"end":return e.stop()}}),e,this)}))),function(e,t){return r.apply(this,arguments)})},{key:"setSubscribeFallbackOption",value:function(e){logger$1.print("setSubscribeFallbackOption()","option: %o",e);try{checkEnum(e,"option",[SubscribeFallbackOption.DISABLE,SubscribeFallbackOption.VIDEO_STREAM_LOW,SubscribeFallbackOption.AUDIO_ONLY])}catch(e){return console.warn(e),!1}return!this._room&&(this._subscribeFallbackOption=e,!0)}},{key:"_updateScreenPublish",value:(t=_asyncToGenerator(_regeneratorRuntime().mark((function e(){var t,r,n,i=arguments;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=i.length>0&&void 0!==i[0]?i[0]:{},logger$1.print("_updateScreenPublish()"),r={mediaType:void 0,pubState:PubState.PUB},t=_objectSpread2(_objectSpread2({},r),t),e.next=6,this._pubLock.lock();case 6:if(n=e.sent,this._room&&this._room.connectionState===MediaConnectionState.CONNECTED){e.next=10;break}return n(),e.abrupt("return");case 10:return e.prev=10,e.next=13,this._room.publishScreen(this._screenStreamEncodeConfig,this._localScreenVideoTrack,this._localScreenAudioTrack,t.mediaType,t.pubState);case 13:e.next=22;break;case 15:if(e.prev=15,e.t0=e.catch(10),!(e.t0 instanceof SDKError)){e.next=21;break}throw e.t0;case 21:throw new SDKError(ErrorCode.UNEXPECTED_ERROR,"unexpected error",e.t0);case 22:return e.prev=22,n(),e.finish(22);case 25:case"end":return e.stop()}}),e,this,[[10,15,22,25]])}))),function(){return t.apply(this,arguments)})},{key:"_setCaptureVolume",value:function(e,t){var r;0===t&&logger$1.print("setCaptureVolume: ",t),checkEnum(e,"streamType",[StreamIndex.STREAM_INDEX_MAIN,StreamIndex.STREAM_INDEX_SCREEN]),checkNumber(t,"volume",0,400);var n=!1;e===StreamIndex.STREAM_INDEX_MAIN?(this._localAudioTrack&&(n=!!this._localAudioTrack.gainAudioTrack,this._localAudioTrack.setCaptureVolume(t)),this._localAudioTrackVolume=t):e===StreamIndex.STREAM_INDEX_SCREEN&&(this._localScreenAudioTrack&&(n=!!this._localScreenAudioTrack.gainAudioTrack,this._localScreenAudioTrack.setCaptureVolume(t)),this._localScreenAudioTrackVolume=t),null!==(r=this._room)&&void 0!==r&&r.hasPublished&&!n&&this._updatePublish()}},{key:"_updateAudioPlayerState",value:function(e){logger$1.print("_updateAudioPlayerState()");var t,r=e.userId,n=e.isScreen;if(t=n?this._remoteAudioPlayer.get("".concat(r,"_screen")):this._remoteAudioPlayer.get(r),e.audioTrack&&(e.attributes.audiostream&&e.subAudio||this.multiChatMode)){var i;if(!t){var o,a=n?"".concat(r,"_screen"):r;t=new AudioPlayer(a,{muted:(null===(o=this._config)||void 0===o?void 0:o.autoPlayPolicy)===RTCAutoPlayPolicy.VIDEO_ONLY}),this._initPlayerEvents(t),this._remoteAudioPlayer.set(a,t),this._audioPlaybackDeviceId&&t.setPlaybackDevice(this._audioPlaybackDeviceId)}(null===(i=this._config)||void 0===i?void 0:i.autoPlayPolicy)!==RTCAutoPlayPolicy.PLAY_MANUALLY&&t.playAudio(e.audioTrack)}else{var s;null===(s=t)||void 0===s||s.stop()}}},{key:"_updateVideoPlayerState",value:function(e){var t;logger$1.print("_updateVideoPlayerState()");var r,n,i=e.userId;if(r=e.isScreen?this._remoteScreenPlayer.get(i):this._remoteVideoPlayer.get(i),e.videoTrack)r&&(null===(n=this._config)||void 0===n?void 0:n.autoPlayPolicy)!==RTCAutoPlayPolicy.PLAY_MANUALLY&&r.playVideo(e.videoTrack,e);else if(null!==(t=r)&&void 0!==t&&t.played){var o;null===(o=r)||void 0===o||o.stop()}}},{key:"_onAddStream",value:function(e){var t=e.stream,r=null==t?void 0:t.attributes,n=r.localaudio,i=r.audiostream,o=r.localvideo,a=r.videostream,s=ExtendMediaType.NONE;if(i&&(s|=MediaType.AUDIO),a&&(s|=MediaType.VIDEO),s){var c;if(null!=t&&t.isScreen)this.safeEmit(EngineEventsTypes.onUserPublishScreen,{userId:t.userId,mediaType:s});else this.safeEmit(EngineEventsTypes.onUserPublishStream,{userId:t.userId,mediaType:s,videoStreamDescriptions:null==t||null===(c=t.attributes)||void 0===c?void 0:c.videoDescriptions}),this._handleAutoSubscribe(t,!0);this.safeEmit("onAddStream",{userId:t.userId,mediaType:s,isScreen:!(null==t||!t.isScreen)}),null!=t&&t.isScreen||(n&&this.safeEmit(EngineEventsTypes.onUserStartAudioCapture,{userId:t.userId}),o&&this.safeEmit(EngineEventsTypes.onUserStartVideoCapture,{userId:t.userId}))}}},{key:"_handleAutoSubscribe",value:function(e,t){var r,n,i=ExtendMediaType.NONE;if(null!==(r=this._roomConfig)&&void 0!==r&&r.isAutoSubscribeAudio&&(i|=MediaType.AUDIO),null!==(n=this._roomConfig)&&void 0!==n&&n.isAutoSubscribeVideo&&(i|=MediaType.VIDEO),logger$1.print("_onAddStream","autoSubType: ".concat(i)),i){var o,a;if(t&&audioInMediaType(i))null===(o=e.observer)||void 0===o||o.setAutoSubscribeAudio(!0);if(t&&videoInMediaType(i))null===(a=e.observer)||void 0===a||a.setAutoSubscribeVideo(!0);this._subscribe(!1,e.userId,i)}}},{key:"_onRemoveStream",value:function(e){var t,r=this,n=e.stream,i=null!==(t=StreamRemoveReasonMap[e.reason])&&void 0!==t?t:StreamRemoveReason.STREAM_REMOVE_REASON_OTHER,o=n.isScreen?EngineEventsTypes.onUserUnpublishScreen:EngineEventsTypes.onUserUnpublishStream,a=ExtendMediaType.NONE;n.attributes.audiostream&&(a|=MediaType.AUDIO),n.attributes.videostream&&(a|=MediaType.VIDEO),null!=n&&n._workaround_1_&&(a=MediaType.VIDEO),a!==ExtendMediaType.NONE&&(this.safeEmit(o,{userId:n.userId,mediaType:a,reason:i}),this.safeEmit("onRemoveStream",{userId:n.userId,isScreen:n.isScreen})),this._getRemotePlayer(n.userId,n.isScreen).forEach((function(e){if(null==n||!n._workaround_1_){var t=n.isScreen?"".concat(n.userId,"_screen"):n.userId;r._remoteAudioPlayer.delete(t),n.isScreen?r._remoteScreenPlayer.delete(n.userId):r._remoteVideoPlayer.delete(n.userId),null==e||e.destroy()}}))}},{key:"_onUserConnection",value:function(e){this.safeEmit(EngineEventsTypes.onUserJoined,e)}},{key:"_onUserLeave",value:function(e){this.safeEmit(EngineEventsTypes.onUserLeave,e)}},{key:"_onRoomError",value:function(e){var t;this.safeEmit(EngineEventsTypes.onError,e),null===(t=this._room)||void 0===t||t.destroy(),this._room=void 0}},{key:"_onNetworkQuality",value:function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];this.safeEmit.apply(this,[EngineEventsTypes.onNetworkQuality].concat(t))}},{key:"_onConnectionStateChange",value:function(e){void 0!==this._startCloudProxyTimestamp&&this._useCloudProxy&&e.state===ConnectionState.CONNECTION_STATE_CONNECTED&&this.safeEmit(EngineEventsTypes.onCloudProxyConnected,{interval:Date.now()-this._startCloudProxyTimestamp}),this.safeEmit(EngineEventsTypes.onConnectionStateChanged,e)}},{key:"_getRemotePlayer",value:function(e,t){return[this._remoteAudioPlayer.get(t?"".concat(e,"_screen"):e),(t?this._remoteScreenPlayer:this._remoteVideoPlayer).get(e)]}},{key:"_stopAudioPropertiesReport",value:function(){null!==this._audioPropertiesReportTimer&&(clearInterval(this._audioPropertiesReportTimer),this._audioPropertiesReportTimer=null)}},{key:"_onResubscribe",value:function(e){e.stream&&(this._getRemotePlayer(e.stream.userId,e.stream.isScreen).forEach((function(e){return null==e?void 0:e.stop()})),this._updateAudioPlayerState(e.stream),this._updateVideoPlayerState(e.stream))}},{key:"_onSubscribePushTrack",value:function(e){e.stream&&this._updateAudioPlayerState(e.stream)}},{key:"_onRemovePushTrack",value:function(e){e.stream&&this._updateAudioPlayerState(e.stream)}},{key:"_onVideoFirstFrameDecoded",value:function(e){this.safeEmit(EngineEventsTypes.onVideoFirstFrameDecoded,e)}},{key:"_onVideoDeviceStateChange",value:function(e){this.safeEmit(EngineEventsTypes.onVideoDeviceStateChanged,e)}},{key:"_onAudioDeviceStateChange",value:function(e){this.safeEmit(EngineEventsTypes.onAudioDeviceStateChanged,e)}},{key:"_onUserPublishStateChange",value:function(e){var t,r=e.userId,n=e.isScreen,i=e.mediaType,o=e.pubState,a=e.remoteStream,s={userId:r,mediaType:i};n?o===PubState.PUB?this.safeEmit(EngineEventsTypes.onUserPublishScreen,s):this.safeEmit(EngineEventsTypes.onUserUnpublishScreen,_objectSpread2(_objectSpread2({},s),{},{reason:StreamRemoveReason.STREAM_REMOVE_REASON_UNPUBLISH})):o===PubState.PUB?(s.videoStreamDescriptions=null==a||null===(t=a.attributes)||void 0===t?void 0:t.videoDescriptions,this.safeEmit(EngineEventsTypes.onUserPublishStream,s),this._handleAutoSubscribe(a,!0)):this.safeEmit(EngineEventsTypes.onUserUnpublishStream,_objectSpread2(_objectSpread2({},s),{},{reason:StreamRemoveReason.STREAM_REMOVE_REASON_UNPUBLISH}))}},{key:"_onCustomMessage",value:function(e){var t=e.message;e.binary?this.safeEmit(EngineEventsTypes.onRoomBinaryMessageReceived,{userId:e.clientId,message:t}):this.safeEmit(EngineEventsTypes.onRoomMessageReceived,{userId:e.clientId,message:t})}},{key:"_onUserMessageReceived",value:function(e){this._messageStatisticsObserver.recvP2PMessage(e.userId),this.safeEmit(EngineEventsTypes.onUserMessageReceived,e)}},{key:"_onUserBinaryMessageReceived",value:function(e){this._messageStatisticsObserver.recvP2PMessage(e.userId),this.safeEmit(EngineEventsTypes.onUserBinaryMessageReceived,e)}},{key:"_onLiveTranscodingResult",value:function(e){this.safeEmit(EngineEventsTypes.onLiveTranscodingResult,e)}},{key:"_onStreamMixingEvent",value:function(e){this.safeEmit(EngineEventsTypes.onStreamMixingEvent,e)}},{key:"_onUserTokenWillExpire",value:function(){this.safeEmit(EngineEventsTypes.onTokenWillExpire)}},{key:"_onPushPublicStreamResult",value:function(e){this.safeEmit(EngineEventsTypes.onPushPublicStreamResult,e)}},{key:"_handleRTMClient",value:function(e){var t=this;e.on("onUserMessageReceivedOutsideRoom",(function(e){t._messageStatisticsObserver.recvP2POutRoomMessage(e.userId),t.safeEmit(EngineEventsTypes.onUserMessageReceivedOutsideRoom,e)})),e.on("onUserBinaryMessageReceivedOutsideRoom",(function(e){t._messageStatisticsObserver.recvP2POutRoomMessage(e.userId),t.safeEmit(EngineEventsTypes.onUserBinaryMessageReceivedOutsideRoom,e)})),e.on("onUserDisconnection",(function(){t.safeEmit(EngineEventsTypes.onError,{errorCode:ErrorCode.RTM_DUPLICATE_LOGIN})})),e.on("onRTMTokenError",(function(){t.safeEmit(EngineEventsTypes.onError,{errorCode:ErrorCode.RTM_TOKEN_ERROR})})),e.on("onServerParamsSetResult",(function(e){t.safeEmit(EngineEventsTypes.onServerParamsSetResult,null==e?void 0:e.code)}))}},{key:"waitForNewToken",get:function(){return!!this._tempRoomConfig}},{key:"localAudioTrack",get:function(){return this._localAudioTrack}},{key:"localVideoTrack",get:function(){return this._localVideoTrack}},{key:"localScreenAudioTrack",get:function(){return this._localScreenAudioTrack}},{key:"localScreenVideoTrack",get:function(){return this._localScreenVideoTrack}},{key:"remoteStreams",get:function(){var e,t,r=[];null!==(e=this._room)&&void 0!==e&&e.remoteStreams&&(null===(t=this._room)||void 0===t||t.remoteStreams.forEach((function(e){Array.isArray(e)&&e.forEach((function(e){r.push({userId:e.userId,isScreen:e.isScreen,hasVideo:e.hasVideo,hasAudio:e.hasAudio,videoStreamDescriptions:e.attributes.videoDescriptions})}))})));return r}},{key:"remoteUsers",get:function(){var e,t,r=[];null!==(e=this._room)&&void 0!==e&&e.remoteUsers&&(null===(t=this._room)||void 0===t||t.remoteUsers.forEach((function(e){r.push({userId:e.userId})})));return r}},{key:"multiChatMode",get:function(){var e,t;return!(null===(e=this._room)||void 0===e||null===(t=e._mediaServerClient)||void 0===t||!t.roomAttributes.multiChatMode)}},{key:"_handleAudioDeviceManager",value:function(){var e=this;this._audioDeviceManager.on("onAudioPlaybackDeviceTestVolume",(function(t){e.safeEmit(EngineEventsTypes.onAudioPlaybackDeviceTestVolume,t)}))}},{key:"_assertNotInRoom",value:function(){if(!this._room||this._room.connectionState!==MediaConnectionState.CONNECTED)throw new SDKError(ErrorCode.INVOKED_BEFORE_JOIN_ROOM,"join first")}},{key:"_checkMediaType",value:function(e){checkEnum(e,"mediaType",[MediaType.AUDIO,MediaType.VIDEO,MediaType.AUDIO_AND_VIDEO])}},{key:"_getUserId",value:function(){var e,t;return(null===(e=this._room)||void 0===e||null===(t=e.roomInfo)||void 0===t?void 0:t.userInfo.userId)||"local_user"}}]),de}();__decorateClass([reportRtcSdkApiCall()],RTCEngine.prototype,"updateToken",1),__decorateClass([reportRtcSdkApiCall()],RTCEngine.prototype,"setVideoCaptureDevice",1),__decorateClass([reportRtcSdkApiCall()],RTCEngine.prototype,"setAudioCaptureDevice",1),__decorateClass([reportRtcSdkApiCall()],RTCEngine.prototype,"joinRoom",1),__decorateClass([reportRtcSdkApiCall()],RTCEngine.prototype,"leaveRoom",1),__decorateClass([reportRtcSdkApiCall()],RTCEngine.prototype,"destroy",1),__decorateClass([reportRtcSdkApiCall()],RTCEngine.prototype,"publishStream",1),__decorateClass([reportRtcSdkApiCall()],RTCEngine.prototype,"unpublishStream",1),__decorateClass([reportRtcSdkApiCall()],RTCEngine.prototype,"publishScreen",1),__decorateClass([reportRtcSdkApiCall()],RTCEngine.prototype,"unpublishScreen",1),__decorateClass([reportRtcSdkApiCall()],RTCEngine.prototype,"subscribeStream",1),__decorateClass([reportRtcSdkApiCall()],RTCEngine.prototype,"unsubscribeStream",1),__decorateClass([reportRtcSdkApiCall()],RTCEngine.prototype,"subscribeScreen",1),__decorateClass([reportRtcSdkApiCall()],RTCEngine.prototype,"unsubscribeScreen",1),__decorateClass([reportRtcSdkApiCall()],RTCEngine.prototype,"setRemoteVideoConfig",1),__decorateClass([reportRtcSdkApiCall()],RTCEngine.prototype,"startVideoCapture",1),__decorateClass([reportRtcSdkApiCall()],RTCEngine.prototype,"stopVideoCapture",1),__decorateClass([reportRtcSdkApiCall()],RTCEngine.prototype,"startAudioCapture",1),__decorateClass([reportRtcSdkApiCall()],RTCEngine.prototype,"stopAudioCapture",1),__decorateClass([reportRtcSdkApiCall()],RTCEngine.prototype,"getAudioMixingManager",1),__decorateClass([reportRtcSdkApiCall()],RTCEngine.prototype,"startScreenCapture",1),__decorateClass([reportRtcSdkApiCall()],RTCEngine.prototype,"stopScreenCapture",1),__decorateClass([reportRtcSdkApiCall()],RTCEngine.prototype,"setLocalVideoPlayer",1),__decorateClass([reportRtcSdkApiCall()],RTCEngine.prototype,"startLiveTranscoding",1),__decorateClass([reportRtcSdkApiCall()],RTCEngine.prototype,"updateLiveTranscoding",1),__decorateClass([reportRtcSdkApiCall()],RTCEngine.prototype,"stopLiveTranscoding",1),__decorateClass([reportRtcSdkApiCall()],RTCEngine.prototype,"setBusinessId",1),__decorateClass([reportRtcSdkApiCall()],RTCEngine.prototype,"setUserVisibility",1),__decorateClass([reportRtcSdkApiCall()],RTCEngine.prototype,"setRemoteVideoPlayer",1),__decorateClass([reportRtcSdkApiCall()],RTCEngine.prototype,"setLocalVideoMirrorType",1),__decorateClass([reportRtcSdkApiCall()],RTCEngine.prototype,"setAudioPlaybackDevice",1),__decorateClass([reportRtcSdkApiCall()],RTCEngine.prototype,"play",1),__decorateClass([reportRtcSdkApiCall()],RTCEngine.prototype,"pauseAllSubscribedStream",1),__decorateClass([reportRtcSdkApiCall()],RTCEngine.prototype,"resumeAllSubscribedStream",1),__decorateClass([reportRtcSdkApiCall()],RTCEngine.prototype,"sendUserMessage",1),__decorateClass([reportRtcSdkApiCall()],RTCEngine.prototype,"sendUserBinaryMessage",1),__decorateClass([reportRtcSdkApiCall()],RTCEngine.prototype,"sendRoomMessage",1),__decorateClass([reportRtcSdkApiCall()],RTCEngine.prototype,"sendRoomBinaryMessage",1),__decorateClass([reportRtcSdkApiCall()],RTCEngine.prototype,"setAudioCaptureConfig",1),__decorateClass([reportRtcSdkApiCall()],RTCEngine.prototype,"setVideoCaptureConfig",1),__decorateClass([reportRtcSdkApiCall()],RTCEngine.prototype,"enableSimulcastMode",1),__decorateClass([reportRtcSdkApiCall()],RTCEngine.prototype,"setVideoEncoderConfig",1),__decorateClass([reportRtcSdkApiCall()],RTCEngine.prototype,"setScreenEncoderConfig",1),__decorateClass([reportRtcSdkApiCall()],RTCEngine.prototype,"sendSEIMessage",1),__decorateClass([reportRtcSdkApiCall()],RTCEngine.prototype,"setAudioVolumeIndicationInterval",1),__decorateClass([reportRtcSdkApiCall()],RTCEngine.prototype,"enableAudioPropertiesReport",1),__decorateClass([reportRtcSdkApiCall()],RTCEngine.prototype,"setVideoSourceType",1),__decorateClass([reportRtcSdkApiCall()],RTCEngine.prototype,"setExternalVideoTrack",1),__decorateClass([reportRtcSdkApiCall()],RTCEngine.prototype,"setAudioSourceType",1),__decorateClass([reportRtcSdkApiCall()],RTCEngine.prototype,"setExternalAudioTrack",1),__decorateClass([reportRtcSdkApiCall("rtm")],RTCEngine.prototype,"login",1),__decorateClass([reportRtcSdkApiCall("rtm")],RTCEngine.prototype,"logout",1),__decorateClass([reportRtcSdkApiCall("rtm")],RTCEngine.prototype,"updateLoginToken",1),__decorateClass([reportRtcSdkApiCall("rtm")],RTCEngine.prototype,"getPeerOnlineStatus",1),__decorateClass([reportRtcSdkApiCall("rtm")],RTCEngine.prototype,"sendUserMessageOutsideRoom",1),__decorateClass([reportRtcSdkApiCall("rtm")],RTCEngine.prototype,"sendUserBinaryMessageOutsideRoom",1),__decorateClass([reportRtcSdkApiCall("rtm")],RTCEngine.prototype,"setServerParams",1),__decorateClass([reportRtcSdkApiCall("rtm")],RTCEngine.prototype,"sendServerMessage",1),__decorateClass([reportRtcSdkApiCall("rtm")],RTCEngine.prototype,"sendServerBinaryMessage",1),__decorateClass([reportRtcSdkApiCall()],RTCEngine.prototype,"startCloudProxy",1),__decorateClass([reportRtcSdkApiCall()],RTCEngine.prototype,"stopCloudProxy",1),__decorateClass([reportRtcSdkApiCall()],RTCEngine.prototype,"startPushPublicStream",1),__decorateClass([reportRtcSdkApiCall()],RTCEngine.prototype,"updatePublicStreamParam",1),__decorateClass([reportRtcSdkApiCall()],RTCEngine.prototype,"stopPushPublicStream",1),__decorateClass([reportRtcSdkApiCall("outsideRoom")],RTCEngine.prototype,"startPlayPublicStream",1),__decorateClass([reportRtcSdkApiCall("outsideRoom")],RTCEngine.prototype,"stopPlayPublicStream",1),__decorateClass([reportRtcSdkApiCall()],RTCEngine.prototype,"setAudioProfile",1),__decorateClass([reportRtcSdkApiCall("outsideRoom")],RTCEngine.prototype,"setPublicStreamVideoPlayer",1),__decorateClass([reportRtcSdkApiCall()],RTCEngine.prototype,"setDummyCaptureImagePath",1),__decorateClass([reportRtcSdkApiCall()],RTCEngine.prototype,"startAudioPlaybackDeviceTest",1),__decorateClass([reportRtcSdkApiCall()],RTCEngine.prototype,"stopAudioPlaybackDeviceTest",1),__decorateClass([reportRtcSdkApiCall()],RTCEngine.prototype,"startAudioDeviceRecordTest",1),__decorateClass([reportRtcSdkApiCall()],RTCEngine.prototype,"stopAudioDeviceRecordAndPlayTest",1),__decorateClass([reportRtcSdkApiCall()],RTCEngine.prototype,"stopAudioDevicePlayTest",1),__decorateClass([reportRtcSdkApiCall()],RTCEngine.prototype,"setRemoteUserPriority",1),__decorateClass([reportRtcSdkApiCall()],RTCEngine.prototype,"takeLocalSnapshot",1),__decorateClass([reportRtcSdkApiCall()],RTCEngine.prototype,"takeRemoteSnapshot",1),__decorateClass([reportRtcSdkApiCall()],RTCEngine.prototype,"setSubscribeFallbackOption",1),__decorateClass([reportRtcSdkApiCall()],RTCEngine.prototype,"_setCaptureVolume",1);var StreamRemoveReasonMap={"client unpublished":StreamRemoveReason.STREAM_REMOVE_REASON_UNPUBLISH,"publish failed":StreamRemoveReason.STREAM_REMOVE_REASON_PUBLISH_FAILED,"stream removed":StreamRemoveReason.STREAM_REMOVE_REASON_KEEP_LIVE_FAILED,"client disconnected":StreamRemoveReason.STREAM_REMOVE_REASON_CLIENT_DISCONNECTED,"client republish":StreamRemoveReason.STREAM_REMOVE_REASON_REPUBLISH},logger=new Logger("VERTC",0);[commonStats,rtmCommonStats,outsideRoomCommonStats].forEach((function(e){var t;return e.setStats({rtc_sdk_version:Config.VERSION,product_line:CommonProductLine.RTC,report_version:CommonReportVersion.W_5,os:CommonOs.WEB,device_id:sdkCache.getDeviceId(),user_agent:isSSR()?"":null===(t=navigator)||void 0===t?void 0:t.userAgent})}));var createEngine=function(e,t){return logger.print("createEngine","Invoke VERTC.createEngine"),checkString(e,"appId"),[commonStats,rtmCommonStats,outsideRoomCommonStats].forEach((function(r){return r.setStats({rtc_app_id:e,auto_play_policy:null==t?void 0:t.autoPlayPolicy})})),monitor.sdkInitEngine(Date.now(),SdkinitengineType.BEGIN),new RTCEngine(e,t)},destroyEngine=function(e){if(logger.print("destroyEngine","Invoke VERTC.destroyEngine"),!(e instanceof RTCEngine))throw new SDKError(ErrorCode.INVALID_ENGINE,"Invalid engine object");e.destroy(),monitor.sdkInitEngine(Date.now(),SdkinitengineType.END)},enumerateDevices=function(){var e=_asyncToGenerator(_regeneratorRuntime().mark((function e(){return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",detector.enumerateDevices());case 1:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),enableDevices=function(){var e=_asyncToGenerator(_regeneratorRuntime().mark((function e(){var t,r,n,i,o=arguments;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=o.length>0&&void 0!==o[0]?o[0]:{video:!0,audio:!0},r=t.video,n=t.audio,i={video:!1,audio:!1},!r){e.next=12;break}return e.prev=4,e.next=7,detector.getVideoPermission();case 7:i.video=e.sent,e.next=12;break;case 10:e.prev=10,e.t0=e.catch(4);case 12:if(!n){e.next=21;break}return e.prev=13,e.next=16,detector.getAudioPermission();case 16:i.audio=e.sent,e.next=21;break;case 19:e.prev=19,e.t1=e.catch(13);case 21:return e.abrupt("return",i);case 22:case"end":return e.stop()}}),e,null,[[4,10],[13,19]])})));return function(){return e.apply(this,arguments)}}(),enumerateAudioCaptureDevices=function(){var e=_asyncToGenerator(_regeneratorRuntime().mark((function e(){return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",detector.enumerateAudioCaptureDevices());case 1:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),enumerateVideoCaptureDevices=function(){var e=_asyncToGenerator(_regeneratorRuntime().mark((function e(){return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",detector.enumerateVideoCaptureDevices());case 1:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),enumerateAudioPlaybackDevices=function(){var e=_asyncToGenerator(_regeneratorRuntime().mark((function e(){return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",detector.enumerateAudioPlaybackDevices());case 1:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),getSdkVersion=function(){return Config.VERSION},isSupported2=function(){return monitor.rtcSdkApiCall("isSupported",0,""),isSupported()},getSupportedCodecs2=function(){return monitor.rtcSdkApiCall("getSupportedCodecs",0,""),getSupportedCodecs()};!isSSR()&&location.search.includes("_rtc_autotest_");var VERTC=_createClass((function e(){_classCallCheck(this,e),_defineProperty(this,"getSdkVersion",getSdkVersion),_defineProperty(this,"createEngine",createEngine),_defineProperty(this,"destroyEngine",destroyEngine),_defineProperty(this,"enumerateDevices",enumerateDevices),_defineProperty(this,"enableDevices",enableDevices),_defineProperty(this,"enumerateAudioCaptureDevices",enumerateAudioCaptureDevices),_defineProperty(this,"enumerateVideoCaptureDevices",enumerateVideoCaptureDevices),_defineProperty(this,"enumerateAudioPlaybackDevices",enumerateAudioPlaybackDevices),_defineProperty(this,"getParameter",getParameter),_defineProperty(this,"setParameter",setParameter),_defineProperty(this,"isSupported",isSupported2),_defineProperty(this,"getSupportedCodecs",getSupportedCodecs2),_defineProperty(this,"events",EngineEventsTypes),_defineProperty(this,"ErrorCode",ErrorCode),_defineProperty(this,"platform","".concat({}.PRODUCT_PLATFORM)),_defineProperty(this,"_monitor",monitor)})),index=new VERTC;export{AudioMixingDualMonoMode,AudioMixingType,AudioProfileType,AudioSourceType,ChannelProfile,ConnectionState,FallbackOrRecoverReason,LogChannel,MediaType,MirrorMode,MirrorType,NetworkQuality,PublicInterpolationMode,PublicStreamType,PublishState,RTCAutoPlayPolicy,RemoteUserPriority,RoomProfileType,StreamIndex,StreamRemoveReason,SubscribeFallbackOption,SubscribeMode,SubscribeState,USER_ONLINE_STATUS,UserOfflineReason,VideoRenderMode,VideoSourceType,index as default};
|