@byteplus/rtc 4.52.8 → 4.52.10

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 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.52.8
4
+ * version: 4.52.10
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"}))}var commonjsGlobal="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function commonjsRequire(e){throw new Error('Could not dynamically require "'+e+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var defineProperty$i={exports:{}},check=function(e){return e&&e.Math==Math&&e},global$s=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")(),fails$z=function(e){try{return!!e()}catch(e){return!0}},fails$y=fails$z,functionBindNative=!fails$y((function(){var e=function(){}.bind();return"function"!=typeof e||e.hasOwnProperty("prototype")})),NATIVE_BIND$4=functionBindNative,FunctionPrototype$3=Function.prototype,apply$6=FunctionPrototype$3.apply,call$H=FunctionPrototype$3.call,functionApply="object"==typeof Reflect&&Reflect.apply||(NATIVE_BIND$4?call$H.bind(apply$6):function(){return call$H.apply(apply$6,arguments)}),NATIVE_BIND$3=functionBindNative,FunctionPrototype$2=Function.prototype,call$G=FunctionPrototype$2.call,uncurryThisWithBind=NATIVE_BIND$3&&FunctionPrototype$2.bind.bind(call$G,call$G),functionUncurryThisRaw=NATIVE_BIND$3?uncurryThisWithBind:function(e){return function(){return call$G.apply(e,arguments)}},uncurryThisRaw$1=functionUncurryThisRaw,toString$j=uncurryThisRaw$1({}.toString),stringSlice$5=uncurryThisRaw$1("".slice),classofRaw$2=function(e){return stringSlice$5(toString$j(e),8,-1)},classofRaw$1=classofRaw$2,uncurryThisRaw=functionUncurryThisRaw,functionUncurryThis=function(e){if("Function"===classofRaw$1(e))return uncurryThisRaw(e)},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$n=$documentAll$1.IS_HTMLDDA?function(e){return"function"==typeof e||e===documentAll$1}:function(e){return"function"==typeof e},objectGetOwnPropertyDescriptor={},fails$x=fails$z,descriptors=!fails$x((function(){return 7!=Object.defineProperty({},1,{get:function(){return 7}})[1]})),NATIVE_BIND$2=functionBindNative,call$F=Function.prototype.call,functionCall=NATIVE_BIND$2?call$F.bind(call$F):function(){return call$F.apply(call$F,arguments)},objectPropertyIsEnumerable={},$propertyIsEnumerable$2={}.propertyIsEnumerable,getOwnPropertyDescriptor$b=Object.getOwnPropertyDescriptor,NASHORN_BUG=getOwnPropertyDescriptor$b&&!$propertyIsEnumerable$2.call({1:2},1);objectPropertyIsEnumerable.f=NASHORN_BUG?function(e){var t=getOwnPropertyDescriptor$b(this,e);return!!t&&t.enumerable}:$propertyIsEnumerable$2;var match,version,createPropertyDescriptor$9=function(e,t){return{enumerable:!(1&e),configurable:!(2&e),writable:!(4&e),value:t}},uncurryThis$B=functionUncurryThis,fails$w=fails$z,classof$f=classofRaw$2,$Object$4=Object,split$3=uncurryThis$B("".split),indexedObject=fails$w((function(){return!$Object$4("z").propertyIsEnumerable(0)}))?function(e){return"String"==classof$f(e)?split$3(e,""):$Object$4(e)}:$Object$4,isNullOrUndefined$7=function(e){return null==e},isNullOrUndefined$6=isNullOrUndefined$7,$TypeError$l=TypeError,requireObjectCoercible$9=function(e){if(isNullOrUndefined$6(e))throw $TypeError$l("Can't call method on "+e);return e},IndexedObject$3=indexedObject,requireObjectCoercible$8=requireObjectCoercible$9,toIndexedObject$b=function(e){return IndexedObject$3(requireObjectCoercible$8(e))},isCallable$m=isCallable$n,$documentAll=documentAll_1,documentAll=$documentAll.all,isObject$q=$documentAll.IS_HTMLDDA?function(e){return"object"==typeof e?null!==e:isCallable$m(e)||e===documentAll}:function(e){return"object"==typeof e?null!==e:isCallable$m(e)},path$v={},path$u=path$v,global$r=global$s,isCallable$l=isCallable$n,aFunction=function(e){return isCallable$l(e)?e:void 0},getBuiltIn$o=function(e,t){return arguments.length<2?aFunction(path$u[e])||aFunction(global$r[e]):path$u[e]&&path$u[e][t]||global$r[e]&&global$r[e][t]},uncurryThis$A=functionUncurryThis,objectIsPrototypeOf=uncurryThis$A({}.isPrototypeOf),getBuiltIn$n=getBuiltIn$o,engineUserAgent=getBuiltIn$n("navigator","userAgent")||"",global$q=global$s,userAgent$6=engineUserAgent,process$3=global$q.process,Deno$1=global$q.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$v=fails$z,symbolConstructorDetection=!!Object.getOwnPropertySymbols&&!fails$v((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,getBuiltIn$m=getBuiltIn$o,isCallable$k=isCallable$n,isPrototypeOf$r=objectIsPrototypeOf,USE_SYMBOL_AS_UID$1=useSymbolAsUid,$Object$3=Object,isSymbol$4=USE_SYMBOL_AS_UID$1?function(e){return"symbol"==typeof e}:function(e){var t=getBuiltIn$m("Symbol");return isCallable$k(t)&&isPrototypeOf$r(t.prototype,$Object$3(e))},$String$3=String,tryToString$6=function(e){try{return $String$3(e)}catch(e){return"Object"}},isCallable$j=isCallable$n,tryToString$5=tryToString$6,$TypeError$k=TypeError,aCallable$z=function(e){if(isCallable$j(e))return e;throw $TypeError$k(tryToString$5(e)+" is not a function")},aCallable$y=aCallable$z,isNullOrUndefined$5=isNullOrUndefined$7,getMethod$3=function(e,t){var r=e[t];return isNullOrUndefined$5(r)?void 0:aCallable$y(r)},call$E=functionCall,isCallable$i=isCallable$n,isObject$p=isObject$q,$TypeError$j=TypeError,ordinaryToPrimitive$1=function(e,t){var r,n;if("string"===t&&isCallable$i(r=e.toString)&&!isObject$p(n=call$E(r,e)))return n;if(isCallable$i(r=e.valueOf)&&!isObject$p(n=call$E(r,e)))return n;if("string"!==t&&isCallable$i(r=e.toString)&&!isObject$p(n=call$E(r,e)))return n;throw $TypeError$j("Can't convert object to primitive value")},shared$6={exports:{}},isPure=!0,global$p=global$s,defineProperty$h=Object.defineProperty,defineGlobalProperty$1=function(e,t){try{defineProperty$h(global$p,e,{value:t,configurable:!0,writable:!0})}catch(r){global$p[e]=t}return t},global$o=global$s,defineGlobalProperty=defineGlobalProperty$1,SHARED="__core-js_shared__",store$3=global$o[SHARED]||defineGlobalProperty(SHARED,{}),sharedStore=store$3,IS_PURE$3=isPure,store$2=sharedStore;(shared$6.exports=function(e,t){return store$2[e]||(store$2[e]=void 0!==t?t:{})})("versions",[]).push({version:"3.26.0",mode:IS_PURE$3?"pure":"global",copyright:"© 2014-2022 Denis Pushkarev (zloirock.ru)",license:"https://github.com/zloirock/core-js/blob/v3.26.0/LICENSE",source:"https://github.com/zloirock/core-js"});var requireObjectCoercible$7=requireObjectCoercible$9,$Object$2=Object,toObject$d=function(e){return $Object$2(requireObjectCoercible$7(e))},uncurryThis$z=functionUncurryThis,toObject$c=toObject$d,hasOwnProperty$a=uncurryThis$z({}.hasOwnProperty),hasOwnProperty_1=Object.hasOwn||function(e,t){return hasOwnProperty$a(toObject$c(e),t)},uncurryThis$y=functionUncurryThis,id$2=0,postfix=Math.random(),toString$i=uncurryThis$y(1..toString),uid$4=function(e){return"Symbol("+(void 0===e?"":e)+")_"+toString$i(++id$2+postfix,36)},global$n=global$s,shared$5=shared$6.exports,hasOwn$n=hasOwnProperty_1,uid$3=uid$4,NATIVE_SYMBOL$4=symbolConstructorDetection,USE_SYMBOL_AS_UID=useSymbolAsUid,WellKnownSymbolsStore$1=shared$5("wks"),Symbol$5=global$n.Symbol,symbolFor=Symbol$5&&Symbol$5.for,createWellKnownSymbol=USE_SYMBOL_AS_UID?Symbol$5:Symbol$5&&Symbol$5.withoutSetter||uid$3,wellKnownSymbol$p=function(e){if(!hasOwn$n(WellKnownSymbolsStore$1,e)||!NATIVE_SYMBOL$4&&"string"!=typeof WellKnownSymbolsStore$1[e]){var t="Symbol."+e;NATIVE_SYMBOL$4&&hasOwn$n(Symbol$5,e)?WellKnownSymbolsStore$1[e]=Symbol$5[e]:WellKnownSymbolsStore$1[e]=USE_SYMBOL_AS_UID&&symbolFor?symbolFor(t):createWellKnownSymbol(t)}return WellKnownSymbolsStore$1[e]},call$D=functionCall,isObject$o=isObject$q,isSymbol$3=isSymbol$4,getMethod$2=getMethod$3,ordinaryToPrimitive=ordinaryToPrimitive$1,wellKnownSymbol$o=wellKnownSymbol$p,$TypeError$i=TypeError,TO_PRIMITIVE=wellKnownSymbol$o("toPrimitive"),toPrimitive$7=function(e,t){if(!isObject$o(e)||isSymbol$3(e))return e;var r,n=getMethod$2(e,TO_PRIMITIVE);if(n){if(void 0===t&&(t="default"),r=call$D(n,e,t),!isObject$o(r)||isSymbol$3(r))return r;throw $TypeError$i("Can't convert object to primitive value")}return void 0===t&&(t="number"),ordinaryToPrimitive(e,t)},toPrimitive$6=toPrimitive$7,isSymbol$2=isSymbol$4,toPropertyKey$4=function(e){var t=toPrimitive$6(e,"string");return isSymbol$2(t)?t:t+""},global$m=global$s,isObject$n=isObject$q,document$3=global$m.document,EXISTS$1=isObject$n(document$3)&&isObject$n(document$3.createElement),documentCreateElement$1=function(e){return EXISTS$1?document$3.createElement(e):{}},DESCRIPTORS$l=descriptors,fails$u=fails$z,createElement$2=documentCreateElement$1,ie8DomDefine=!DESCRIPTORS$l&&!fails$u((function(){return 7!=Object.defineProperty(createElement$2("div"),"a",{get:function(){return 7}}).a})),DESCRIPTORS$k=descriptors,call$C=functionCall,propertyIsEnumerableModule$2=objectPropertyIsEnumerable,createPropertyDescriptor$8=createPropertyDescriptor$9,toIndexedObject$a=toIndexedObject$b,toPropertyKey$3=toPropertyKey$4,hasOwn$m=hasOwnProperty_1,IE8_DOM_DEFINE$1=ie8DomDefine,$getOwnPropertyDescriptor$2=Object.getOwnPropertyDescriptor;objectGetOwnPropertyDescriptor.f=DESCRIPTORS$k?$getOwnPropertyDescriptor$2:function(e,t){if(e=toIndexedObject$a(e),t=toPropertyKey$3(t),IE8_DOM_DEFINE$1)try{return $getOwnPropertyDescriptor$2(e,t)}catch(e){}if(hasOwn$m(e,t))return createPropertyDescriptor$8(!call$C(propertyIsEnumerableModule$2.f,e,t),e[t])};var fails$t=fails$z,isCallable$h=isCallable$n,replacement=/#|\.prototype\./,isForced$2=function(e,t){var r=data[normalize(e)];return r==POLYFILL||r!=NATIVE&&(isCallable$h(t)?fails$t(t):!!t)},normalize=isForced$2.normalize=function(e){return String(e).replace(replacement,".").toLowerCase()},data=isForced$2.data={},NATIVE=isForced$2.NATIVE="N",POLYFILL=isForced$2.POLYFILL="P",isForced_1=isForced$2,uncurryThis$x=functionUncurryThis,aCallable$x=aCallable$z,NATIVE_BIND$1=functionBindNative,bind$w=functionUncurryThis(functionUncurryThis.bind),functionBindContext=function(e,t){return aCallable$x(e),void 0===t?e:NATIVE_BIND$1?bind$w(e,t):function(){return e.apply(t,arguments)}},objectDefineProperty={},DESCRIPTORS$j=descriptors,fails$s=fails$z,v8PrototypeDefineBug=DESCRIPTORS$j&&fails$s((function(){return 42!=Object.defineProperty((function(){}),"prototype",{value:42,writable:!1}).prototype})),isObject$m=isObject$q,$String$2=String,$TypeError$h=TypeError,anObject$M=function(e){if(isObject$m(e))return e;throw $TypeError$h($String$2(e)+" is not an object")},DESCRIPTORS$i=descriptors,IE8_DOM_DEFINE=ie8DomDefine,V8_PROTOTYPE_DEFINE_BUG$1=v8PrototypeDefineBug,anObject$L=anObject$M,toPropertyKey$2=toPropertyKey$4,$TypeError$g=TypeError,$defineProperty$1=Object.defineProperty,$getOwnPropertyDescriptor$1=Object.getOwnPropertyDescriptor,ENUMERABLE="enumerable",CONFIGURABLE$1="configurable",WRITABLE="writable";objectDefineProperty.f=DESCRIPTORS$i?V8_PROTOTYPE_DEFINE_BUG$1?function(e,t,r){if(anObject$L(e),t=toPropertyKey$2(t),anObject$L(r),"function"==typeof e&&"prototype"===t&&"value"in r&&WRITABLE in r&&!r[WRITABLE]){var n=$getOwnPropertyDescriptor$1(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$L(e),t=toPropertyKey$2(t),anObject$L(r),IE8_DOM_DEFINE)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 DESCRIPTORS$h=descriptors,definePropertyModule$6=objectDefineProperty,createPropertyDescriptor$7=createPropertyDescriptor$9,createNonEnumerableProperty$8=DESCRIPTORS$h?function(e,t,r){return definePropertyModule$6.f(e,t,createPropertyDescriptor$7(1,r))}:function(e,t,r){return e[t]=r,e},global$l=global$s,apply$5=functionApply,uncurryThis$w=functionUncurryThis,isCallable$g=isCallable$n,getOwnPropertyDescriptor$a=objectGetOwnPropertyDescriptor.f,isForced$1=isForced_1,path$t=path$v,bind$v=functionBindContext,createNonEnumerableProperty$7=createNonEnumerableProperty$8,hasOwn$l=hasOwnProperty_1,wrapConstructor=function(e){var t=function(r,n,i){if(this instanceof t){switch(arguments.length){case 0:return new e;case 1:return new e(r);case 2:return new e(r,n)}return new e(r,n,i)}return apply$5(e,this,arguments)};return t.prototype=e.prototype,t},_export=function(e,t){var r,n,i,o,a,s,c,l,u=e.target,d=e.global,p=e.stat,_=e.proto,h=d?global$l:p?global$l[u]:(global$l[u]||{}).prototype,f=d?path$t:path$t[u]||createNonEnumerableProperty$7(path$t,u,{})[u],m=f.prototype;for(i in t)r=!isForced$1(d?i:u+(p?".":"#")+i,e.forced)&&h&&hasOwn$l(h,i),a=f[i],r&&(s=e.dontCallGetSet?(l=getOwnPropertyDescriptor$a(h,i))&&l.value:h[i]),o=r&&s?s:t[i],r&&typeof a==typeof o||(c=e.bind&&r?bind$v(o,global$l):e.wrap&&r?wrapConstructor(o):_&&isCallable$g(o)?uncurryThis$w(o):o,(e.sham||o&&o.sham||a&&a.sham)&&createNonEnumerableProperty$7(c,"sham",!0),createNonEnumerableProperty$7(f,i,c),_&&(hasOwn$l(path$t,n=u+"Prototype")||createNonEnumerableProperty$7(path$t,n,{}),createNonEnumerableProperty$7(path$t[n],i,o),e.real&&m&&!m[i]&&createNonEnumerableProperty$7(m,i,o)))},$$1D=_export,DESCRIPTORS$g=descriptors,defineProperty$g=objectDefineProperty.f;$$1D({target:"Object",stat:!0,forced:Object.defineProperty!==defineProperty$g,sham:!DESCRIPTORS$g},{defineProperty:defineProperty$g});var path$s=path$v,Object$4=path$s.Object,defineProperty$f=defineProperty$i.exports=function(e,t,r){return Object$4.defineProperty(e,t,r)};Object$4.defineProperty.sham&&(defineProperty$f.sham=!0);var parent$2x=defineProperty$i.exports,defineProperty$e=parent$2x,parent$2w=defineProperty$e,defineProperty$d=parent$2w,parent$2v=defineProperty$d,defineProperty$c=parent$2v,defineProperty$b=defineProperty$c,defineProperty$a=defineProperty$b,classof$e=classofRaw$2,isArray$f=Array.isArray||function(e){return"Array"==classof$e(e)},ceil$1=Math.ceil,floor$3=Math.floor,mathTrunc=Math.trunc||function(e){var t=+e;return(t>0?floor$3:ceil$1)(t)},trunc2=mathTrunc,toIntegerOrInfinity$5=function(e){var t=+e;return t!=t||0===t?0:trunc2(t)},toIntegerOrInfinity$4=toIntegerOrInfinity$5,min$4=Math.min,toLength$4=function(e){return e>0?min$4(toIntegerOrInfinity$4(e),9007199254740991):0},toLength$3=toLength$4,lengthOfArrayLike$b=function(e){return toLength$3(e.length)},$TypeError$f=TypeError,MAX_SAFE_INTEGER$2=9007199254740991,doesNotExceedSafeInteger$2=function(e){if(e>MAX_SAFE_INTEGER$2)throw $TypeError$f("Maximum allowed index exceeded");return e},toPropertyKey$1=toPropertyKey$4,definePropertyModule$5=objectDefineProperty,createPropertyDescriptor$6=createPropertyDescriptor$9,createProperty$6=function(e,t,r){var n=toPropertyKey$1(t);n in e?definePropertyModule$5.f(e,n,createPropertyDescriptor$6(0,r)):e[n]=r},wellKnownSymbol$n=wellKnownSymbol$p,TO_STRING_TAG$4=wellKnownSymbol$n("toStringTag"),test$2={};test$2[TO_STRING_TAG$4]="z";var toStringTagSupport="[object z]"===String(test$2),TO_STRING_TAG_SUPPORT$2=toStringTagSupport,isCallable$f=isCallable$n,classofRaw=classofRaw$2,wellKnownSymbol$m=wellKnownSymbol$p,TO_STRING_TAG$3=wellKnownSymbol$m("toStringTag"),$Object$1=Object,CORRECT_ARGUMENTS="Arguments"==classofRaw(function(){return arguments}()),tryGet=function(e,t){try{return e[t]}catch(e){}},classof$d=TO_STRING_TAG_SUPPORT$2?classofRaw:function(e){var t,r,n;return void 0===e?"Undefined":null===e?"Null":"string"==typeof(r=tryGet(t=$Object$1(e),TO_STRING_TAG$3))?r:CORRECT_ARGUMENTS?classofRaw(t):"Object"==(n=classofRaw(t))&&isCallable$f(t.callee)?"Arguments":n},uncurryThis$v=functionUncurryThis,isCallable$e=isCallable$n,store$1=sharedStore,functionToString=uncurryThis$v(Function.toString);isCallable$e(store$1.inspectSource)||(store$1.inspectSource=function(e){return functionToString(e)});var inspectSource$2=store$1.inspectSource,uncurryThis$u=functionUncurryThis,fails$r=fails$z,isCallable$d=isCallable$n,classof$c=classof$d,getBuiltIn$l=getBuiltIn$o,inspectSource$1=inspectSource$2,noop=function(){},empty=[],construct$7=getBuiltIn$l("Reflect","construct"),constructorRegExp=/^\s*(?:class|function)\b/,exec$4=uncurryThis$u(constructorRegExp.exec),INCORRECT_TO_STRING=!constructorRegExp.exec(noop),isConstructorModern=function(e){if(!isCallable$d(e))return!1;try{return construct$7(noop,empty,e),!0}catch(e){return!1}},isConstructorLegacy=function(e){if(!isCallable$d(e))return!1;switch(classof$c(e)){case"AsyncFunction":case"GeneratorFunction":case"AsyncGeneratorFunction":return!1}try{return INCORRECT_TO_STRING||!!exec$4(constructorRegExp,inspectSource$1(e))}catch(e){return!0}};isConstructorLegacy.sham=!0;var isConstructor$4=!construct$7||fails$r((function(){var e;return isConstructorModern(isConstructorModern.call)||!isConstructorModern(Object)||!isConstructorModern((function(){e=!0}))||e}))?isConstructorLegacy:isConstructorModern,isArray$e=isArray$f,isConstructor$3=isConstructor$4,isObject$l=isObject$q,wellKnownSymbol$l=wellKnownSymbol$p,SPECIES$5=wellKnownSymbol$l("species"),$Array$3=Array,arraySpeciesConstructor$1=function(e){var t;return isArray$e(e)&&(t=e.constructor,(isConstructor$3(t)&&(t===$Array$3||isArray$e(t.prototype))||isObject$l(t)&&null===(t=t[SPECIES$5]))&&(t=void 0)),void 0===t?$Array$3:t},arraySpeciesConstructor=arraySpeciesConstructor$1,arraySpeciesCreate$3=function(e,t){return new(arraySpeciesConstructor(e))(0===t?0:t)},fails$q=fails$z,wellKnownSymbol$k=wellKnownSymbol$p,V8_VERSION$2=engineV8Version,SPECIES$4=wellKnownSymbol$k("species"),arrayMethodHasSpeciesSupport$5=function(e){return V8_VERSION$2>=51||!fails$q((function(){var t=[];return(t.constructor={})[SPECIES$4]=function(){return{foo:1}},1!==t[e](Boolean).foo}))},$$1C=_export,fails$p=fails$z,isArray$d=isArray$f,isObject$k=isObject$q,toObject$b=toObject$d,lengthOfArrayLike$a=lengthOfArrayLike$b,doesNotExceedSafeInteger$1=doesNotExceedSafeInteger$2,createProperty$5=createProperty$6,arraySpeciesCreate$2=arraySpeciesCreate$3,arrayMethodHasSpeciesSupport$4=arrayMethodHasSpeciesSupport$5,wellKnownSymbol$j=wellKnownSymbol$p,V8_VERSION$1=engineV8Version,IS_CONCAT_SPREADABLE=wellKnownSymbol$j("isConcatSpreadable"),IS_CONCAT_SPREADABLE_SUPPORT=V8_VERSION$1>=51||!fails$p((function(){var e=[];return e[IS_CONCAT_SPREADABLE]=!1,e.concat()[0]!==e})),SPECIES_SUPPORT=arrayMethodHasSpeciesSupport$4("concat"),isConcatSpreadable=function(e){if(!isObject$k(e))return!1;var t=e[IS_CONCAT_SPREADABLE];return void 0!==t?!!t:isArray$d(e)},FORCED$6=!IS_CONCAT_SPREADABLE_SUPPORT||!SPECIES_SUPPORT;$$1C({target:"Array",proto:!0,arity:1,forced:FORCED$6},{concat:function(e){var t,r,n,i,o,a=toObject$b(this),s=arraySpeciesCreate$2(a,0),c=0;for(t=-1,n=arguments.length;t<n;t++)if(isConcatSpreadable(o=-1===t?a:arguments[t]))for(i=lengthOfArrayLike$a(o),doesNotExceedSafeInteger$1(c+i),r=0;r<i;r++,c++)r in o&&createProperty$5(s,c,o[r]);else doesNotExceedSafeInteger$1(c+1),createProperty$5(s,c++,o);return s.length=c,s}});var classof$b=classof$d,$String$1=String,toString$h=function(e){if("Symbol"===classof$b(e))throw TypeError("Cannot convert a Symbol value to a string");return $String$1(e)},objectDefineProperties={},toIntegerOrInfinity$3=toIntegerOrInfinity$5,max$3=Math.max,min$3=Math.min,toAbsoluteIndex$5=function(e,t){var r=toIntegerOrInfinity$3(e);return r<0?max$3(r+t,0):min$3(r,t)},toIndexedObject$9=toIndexedObject$b,toAbsoluteIndex$4=toAbsoluteIndex$5,lengthOfArrayLike$9=lengthOfArrayLike$b,createMethod$6=function(e){return function(t,r,n){var i,o=toIndexedObject$9(t),a=lengthOfArrayLike$9(o),s=toAbsoluteIndex$4(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)},hiddenKeys$6={},uncurryThis$t=functionUncurryThis,hasOwn$k=hasOwnProperty_1,toIndexedObject$8=toIndexedObject$b,indexOf$7=arrayIncludes.indexOf,hiddenKeys$5=hiddenKeys$6,push$c=uncurryThis$t([].push),objectKeysInternal=function(e,t){var r,n=toIndexedObject$8(e),i=0,o=[];for(r in n)!hasOwn$k(hiddenKeys$5,r)&&hasOwn$k(n,r)&&push$c(o,r);for(;t.length>i;)hasOwn$k(n,r=t[i++])&&(~indexOf$7(o,r)||push$c(o,r));return o},enumBugKeys$3=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"],internalObjectKeys$1=objectKeysInternal,enumBugKeys$2=enumBugKeys$3,objectKeys$4=Object.keys||function(e){return internalObjectKeys$1(e,enumBugKeys$2)},DESCRIPTORS$f=descriptors,V8_PROTOTYPE_DEFINE_BUG=v8PrototypeDefineBug,definePropertyModule$4=objectDefineProperty,anObject$K=anObject$M,toIndexedObject$7=toIndexedObject$b,objectKeys$3=objectKeys$4;objectDefineProperties.f=DESCRIPTORS$f&&!V8_PROTOTYPE_DEFINE_BUG?Object.defineProperties:function(e,t){anObject$K(e);for(var r,n=toIndexedObject$7(t),i=objectKeys$3(t),o=i.length,a=0;o>a;)definePropertyModule$4.f(e,r=i[a++],n[r]);return e};var activeXDocument,getBuiltIn$k=getBuiltIn$o,html$2=getBuiltIn$k("document","documentElement"),shared$4=shared$6.exports,uid$2=uid$4,keys$e=shared$4("keys"),sharedKey$4=function(e){return keys$e[e]||(keys$e[e]=uid$2(e))},anObject$J=anObject$M,definePropertiesModule$1=objectDefineProperties,enumBugKeys$1=enumBugKeys$3,hiddenKeys$4=hiddenKeys$6,html$1=html$2,documentCreateElement=documentCreateElement$1,sharedKey$3=sharedKey$4,GT=">",LT="<",PROTOTYPE$1="prototype",SCRIPT="script",IE_PROTO$1=sharedKey$3("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$1.length;e--;)delete NullProtoObject[PROTOTYPE$1][enumBugKeys$1[e]];return NullProtoObject()};hiddenKeys$4[IE_PROTO$1]=!0;var objectCreate$1=Object.create||function(e,t){var r;return null!==e?(EmptyConstructor[PROTOTYPE$1]=anObject$J(e),r=new EmptyConstructor,EmptyConstructor[PROTOTYPE$1]=null,r[IE_PROTO$1]=e):r=NullProtoObject(),void 0===t?r:definePropertiesModule$1.f(r,t)},objectGetOwnPropertyNames={},internalObjectKeys=objectKeysInternal,enumBugKeys=enumBugKeys$3,hiddenKeys$3=enumBugKeys.concat("length","prototype");objectGetOwnPropertyNames.f=Object.getOwnPropertyNames||function(e){return internalObjectKeys(e,hiddenKeys$3)};var objectGetOwnPropertyNamesExternal={},toAbsoluteIndex$3=toAbsoluteIndex$5,lengthOfArrayLike$8=lengthOfArrayLike$b,createProperty$4=createProperty$6,$Array$2=Array,max$2=Math.max,arraySliceSimple=function(e,t,r){for(var n=lengthOfArrayLike$8(e),i=toAbsoluteIndex$3(t,n),o=toAbsoluteIndex$3(void 0===r?n:r,n),a=$Array$2(max$2(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$b,$getOwnPropertyNames$1=objectGetOwnPropertyNames.f,arraySlice$7=arraySliceSimple,windowNames="object"==typeof window&&window&&Object.getOwnPropertyNames?Object.getOwnPropertyNames(window):[],getWindowNames=function(e){try{return $getOwnPropertyNames$1(e)}catch(e){return arraySlice$7(windowNames)}};objectGetOwnPropertyNamesExternal.f=function(e){return windowNames&&"Window"==classof$a(e)?getWindowNames(e):$getOwnPropertyNames$1(toIndexedObject$6(e))};var objectGetOwnPropertySymbols={};objectGetOwnPropertySymbols.f=Object.getOwnPropertySymbols;var createNonEnumerableProperty$6=createNonEnumerableProperty$8,defineBuiltIn$8=function(e,t,r,n){return n&&n.enumerable?e[t]=r:createNonEnumerableProperty$6(e,t,r),e},wellKnownSymbolWrapped={},wellKnownSymbol$i=wellKnownSymbol$p;wellKnownSymbolWrapped.f=wellKnownSymbol$i;var set$e,get$7,has,path$r=path$v,hasOwn$j=hasOwnProperty_1,wrappedWellKnownSymbolModule$1=wellKnownSymbolWrapped,defineProperty$9=objectDefineProperty.f,wellKnownSymbolDefine=function(e){var t=path$r.Symbol||(path$r.Symbol={});hasOwn$j(t,e)||defineProperty$9(t,e,{value:wrappedWellKnownSymbolModule$1.f(e)})},call$B=functionCall,getBuiltIn$j=getBuiltIn$o,wellKnownSymbol$h=wellKnownSymbol$p,defineBuiltIn$7=defineBuiltIn$8,symbolDefineToPrimitive=function(){var e=getBuiltIn$j("Symbol"),t=e&&e.prototype,r=t&&t.valueOf,n=wellKnownSymbol$h("toPrimitive");t&&!t[n]&&defineBuiltIn$7(t,n,(function(e){return call$B(r,this)}),{arity:1})},TO_STRING_TAG_SUPPORT$1=toStringTagSupport,classof$9=classof$d,objectToString$1=TO_STRING_TAG_SUPPORT$1?{}.toString:function(){return"[object "+classof$9(this)+"]"},TO_STRING_TAG_SUPPORT=toStringTagSupport,defineProperty$8=objectDefineProperty.f,createNonEnumerableProperty$5=createNonEnumerableProperty$8,hasOwn$i=hasOwnProperty_1,toString$g=objectToString$1,wellKnownSymbol$g=wellKnownSymbol$p,TO_STRING_TAG$2=wellKnownSymbol$g("toStringTag"),setToStringTag$9=function(e,t,r,n){if(e){var i=r?e:e.prototype;hasOwn$i(i,TO_STRING_TAG$2)||defineProperty$8(i,TO_STRING_TAG$2,{configurable:!0,value:t}),n&&!TO_STRING_TAG_SUPPORT&&createNonEnumerableProperty$5(i,"toString",toString$g)}},global$k=global$s,isCallable$c=isCallable$n,WeakMap$3=global$k.WeakMap,weakMapBasicDetection=isCallable$c(WeakMap$3)&&/native code/.test(String(WeakMap$3)),NATIVE_WEAK_MAP$1=weakMapBasicDetection,global$j=global$s,isObject$j=isObject$q,createNonEnumerableProperty$4=createNonEnumerableProperty$8,hasOwn$h=hasOwnProperty_1,shared$3=sharedStore,sharedKey$2=sharedKey$4,hiddenKeys$2=hiddenKeys$6,OBJECT_ALREADY_INITIALIZED="Object already initialized",TypeError$5=global$j.TypeError,WeakMap$2=global$j.WeakMap,enforce=function(e){return has(e)?get$7(e):set$e(e,{})},getterFor=function(e){return function(t){var r;if(!isObject$j(t)||(r=get$7(t)).type!==e)throw TypeError$5("Incompatible receiver, "+e+" required");return r}};if(NATIVE_WEAK_MAP$1||shared$3.state){var store=shared$3.state||(shared$3.state=new WeakMap$2);store.get=store.get,store.has=store.has,store.set=store.set,set$e=function(e,t){if(store.has(e))throw TypeError$5(OBJECT_ALREADY_INITIALIZED);return t.facade=e,store.set(e,t),t},get$7=function(e){return store.get(e)||{}},has=function(e){return store.has(e)}}else{var STATE=sharedKey$2("state");hiddenKeys$2[STATE]=!0,set$e=function(e,t){if(hasOwn$h(e,STATE))throw TypeError$5(OBJECT_ALREADY_INITIALIZED);return t.facade=e,createNonEnumerableProperty$4(e,STATE,t),t},get$7=function(e){return hasOwn$h(e,STATE)?e[STATE]:{}},has=function(e){return hasOwn$h(e,STATE)}}var internalState={set:set$e,get:get$7,has:has,enforce:enforce,getterFor:getterFor},bind$u=functionBindContext,uncurryThis$s=functionUncurryThis,IndexedObject$2=indexedObject,toObject$a=toObject$d,lengthOfArrayLike$7=lengthOfArrayLike$b,arraySpeciesCreate$1=arraySpeciesCreate$3,push$b=uncurryThis$s([].push),createMethod$5=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,l,u,d){for(var p,_,h=toObject$a(c),f=IndexedObject$2(h),m=bind$u(l,u),v=lengthOfArrayLike$7(f),g=0,y=d||arraySpeciesCreate$1,S=t?y(c,v):r||a?y(c,0):void 0;v>g;g++)if((s||g in f)&&(_=m(p=f[g],g,h),e))if(t)S[g]=_;else if(_)switch(e){case 3:return!0;case 5:return p;case 6:return g;case 2:push$b(S,p)}else switch(e){case 4:return!1;case 7:push$b(S,p)}return o?-1:n||i?i:S}},arrayIteration={forEach:createMethod$5(0),map:createMethod$5(1),filter:createMethod$5(2),some:createMethod$5(3),every:createMethod$5(4),find:createMethod$5(5),findIndex:createMethod$5(6),filterReject:createMethod$5(7)},$$1B=_export,global$i=global$s,call$A=functionCall,uncurryThis$r=functionUncurryThis,DESCRIPTORS$e=descriptors,NATIVE_SYMBOL$3=symbolConstructorDetection,fails$o=fails$z,hasOwn$g=hasOwnProperty_1,isPrototypeOf$q=objectIsPrototypeOf,anObject$I=anObject$M,toIndexedObject$5=toIndexedObject$b,toPropertyKey=toPropertyKey$4,$toString$2=toString$h,createPropertyDescriptor$5=createPropertyDescriptor$9,nativeObjectCreate=objectCreate$1,objectKeys$2=objectKeys$4,getOwnPropertyNamesModule$2=objectGetOwnPropertyNames,getOwnPropertyNamesExternal=objectGetOwnPropertyNamesExternal,getOwnPropertySymbolsModule$3=objectGetOwnPropertySymbols,getOwnPropertyDescriptorModule$4=objectGetOwnPropertyDescriptor,definePropertyModule$3=objectDefineProperty,definePropertiesModule=objectDefineProperties,propertyIsEnumerableModule$1=objectPropertyIsEnumerable,defineBuiltIn$6=defineBuiltIn$8,shared$2=shared$6.exports,sharedKey$1=sharedKey$4,hiddenKeys$1=hiddenKeys$6,uid$1=uid$4,wellKnownSymbol$f=wellKnownSymbol$p,wrappedWellKnownSymbolModule=wellKnownSymbolWrapped,defineWellKnownSymbol$l=wellKnownSymbolDefine,defineSymbolToPrimitive$1=symbolDefineToPrimitive,setToStringTag$8=setToStringTag$9,InternalStateModule$8=internalState,$forEach$1=arrayIteration.forEach,HIDDEN=sharedKey$1("hidden"),SYMBOL="Symbol",PROTOTYPE="prototype",setInternalState$8=InternalStateModule$8.set,getInternalState$2=InternalStateModule$8.getterFor(SYMBOL),ObjectPrototype$2=Object[PROTOTYPE],$Symbol=global$i.Symbol,SymbolPrototype=$Symbol&&$Symbol[PROTOTYPE],TypeError$4=global$i.TypeError,QObject=global$i.QObject,nativeGetOwnPropertyDescriptor$1=getOwnPropertyDescriptorModule$4.f,nativeDefineProperty=definePropertyModule$3.f,nativeGetOwnPropertyNames=getOwnPropertyNamesExternal.f,nativePropertyIsEnumerable=propertyIsEnumerableModule$1.f,push$a=uncurryThis$r([].push),AllSymbols=shared$2("symbols"),ObjectPrototypeSymbols=shared$2("op-symbols"),WellKnownSymbolsStore=shared$2("wks"),USE_SETTER=!QObject||!QObject[PROTOTYPE]||!QObject[PROTOTYPE].findChild,setSymbolDescriptor=DESCRIPTORS$e&&fails$o((function(){return 7!=nativeObjectCreate(nativeDefineProperty({},"a",{get:function(){return nativeDefineProperty(this,"a",{value:7}).a}})).a}))?function(e,t,r){var n=nativeGetOwnPropertyDescriptor$1(ObjectPrototype$2,t);n&&delete ObjectPrototype$2[t],nativeDefineProperty(e,t,r),n&&e!==ObjectPrototype$2&&nativeDefineProperty(ObjectPrototype$2,t,n)}:nativeDefineProperty,wrap=function(e,t){var r=AllSymbols[e]=nativeObjectCreate(SymbolPrototype);return setInternalState$8(r,{type:SYMBOL,tag:e,description:t}),DESCRIPTORS$e||(r.description=t),r},$defineProperty=function(e,t,r){e===ObjectPrototype$2&&$defineProperty(ObjectPrototypeSymbols,t,r),anObject$I(e);var n=toPropertyKey(t);return anObject$I(r),hasOwn$g(AllSymbols,n)?(r.enumerable?(hasOwn$g(e,HIDDEN)&&e[HIDDEN][n]&&(e[HIDDEN][n]=!1),r=nativeObjectCreate(r,{enumerable:createPropertyDescriptor$5(0,!1)})):(hasOwn$g(e,HIDDEN)||nativeDefineProperty(e,HIDDEN,createPropertyDescriptor$5(1,{})),e[HIDDEN][n]=!0),setSymbolDescriptor(e,n,r)):nativeDefineProperty(e,n,r)},$defineProperties=function(e,t){anObject$I(e);var r=toIndexedObject$5(t),n=objectKeys$2(r).concat($getOwnPropertySymbols(r));return $forEach$1(n,(function(t){DESCRIPTORS$e&&!call$A($propertyIsEnumerable$1,r,t)||$defineProperty(e,t,r[t])})),e},$create=function(e,t){return void 0===t?nativeObjectCreate(e):$defineProperties(nativeObjectCreate(e),t)},$propertyIsEnumerable$1=function(e){var t=toPropertyKey(e),r=call$A(nativePropertyIsEnumerable,this,t);return!(this===ObjectPrototype$2&&hasOwn$g(AllSymbols,t)&&!hasOwn$g(ObjectPrototypeSymbols,t))&&(!(r||!hasOwn$g(this,t)||!hasOwn$g(AllSymbols,t)||hasOwn$g(this,HIDDEN)&&this[HIDDEN][t])||r)},$getOwnPropertyDescriptor=function(e,t){var r=toIndexedObject$5(e),n=toPropertyKey(t);if(r!==ObjectPrototype$2||!hasOwn$g(AllSymbols,n)||hasOwn$g(ObjectPrototypeSymbols,n)){var i=nativeGetOwnPropertyDescriptor$1(r,n);return!i||!hasOwn$g(AllSymbols,n)||hasOwn$g(r,HIDDEN)&&r[HIDDEN][n]||(i.enumerable=!0),i}},$getOwnPropertyNames=function(e){var t=nativeGetOwnPropertyNames(toIndexedObject$5(e)),r=[];return $forEach$1(t,(function(e){hasOwn$g(AllSymbols,e)||hasOwn$g(hiddenKeys$1,e)||push$a(r,e)})),r},$getOwnPropertySymbols=function(e){var t=e===ObjectPrototype$2,r=nativeGetOwnPropertyNames(t?ObjectPrototypeSymbols:toIndexedObject$5(e)),n=[];return $forEach$1(r,(function(e){!hasOwn$g(AllSymbols,e)||t&&!hasOwn$g(ObjectPrototype$2,e)||push$a(n,AllSymbols[e])})),n};NATIVE_SYMBOL$3||(defineBuiltIn$6(SymbolPrototype=($Symbol=function(){if(isPrototypeOf$q(SymbolPrototype,this))throw TypeError$4("Symbol is not a constructor");var e=arguments.length&&void 0!==arguments[0]?$toString$2(arguments[0]):void 0,t=uid$1(e),r=function(e){this===ObjectPrototype$2&&call$A(r,ObjectPrototypeSymbols,e),hasOwn$g(this,HIDDEN)&&hasOwn$g(this[HIDDEN],t)&&(this[HIDDEN][t]=!1),setSymbolDescriptor(this,t,createPropertyDescriptor$5(1,e))};return DESCRIPTORS$e&&USE_SETTER&&setSymbolDescriptor(ObjectPrototype$2,t,{configurable:!0,set:r}),wrap(t,e)})[PROTOTYPE],"toString",(function(){return getInternalState$2(this).tag})),defineBuiltIn$6($Symbol,"withoutSetter",(function(e){return wrap(uid$1(e),e)})),propertyIsEnumerableModule$1.f=$propertyIsEnumerable$1,definePropertyModule$3.f=$defineProperty,definePropertiesModule.f=$defineProperties,getOwnPropertyDescriptorModule$4.f=$getOwnPropertyDescriptor,getOwnPropertyNamesModule$2.f=getOwnPropertyNamesExternal.f=$getOwnPropertyNames,getOwnPropertySymbolsModule$3.f=$getOwnPropertySymbols,wrappedWellKnownSymbolModule.f=function(e){return wrap(wellKnownSymbol$f(e),e)},DESCRIPTORS$e&&nativeDefineProperty(SymbolPrototype,"description",{configurable:!0,get:function(){return getInternalState$2(this).description}})),$$1B({global:!0,constructor:!0,wrap:!0,forced:!NATIVE_SYMBOL$3,sham:!NATIVE_SYMBOL$3},{Symbol:$Symbol}),$forEach$1(objectKeys$2(WellKnownSymbolsStore),(function(e){defineWellKnownSymbol$l(e)})),$$1B({target:SYMBOL,stat:!0,forced:!NATIVE_SYMBOL$3},{useSetter:function(){USE_SETTER=!0},useSimple:function(){USE_SETTER=!1}}),$$1B({target:"Object",stat:!0,forced:!NATIVE_SYMBOL$3,sham:!DESCRIPTORS$e},{create:$create,defineProperty:$defineProperty,defineProperties:$defineProperties,getOwnPropertyDescriptor:$getOwnPropertyDescriptor}),$$1B({target:"Object",stat:!0,forced:!NATIVE_SYMBOL$3},{getOwnPropertyNames:$getOwnPropertyNames}),defineSymbolToPrimitive$1(),setToStringTag$8($Symbol,SYMBOL),hiddenKeys$1[HIDDEN]=!0;var NATIVE_SYMBOL$2=symbolConstructorDetection,symbolRegistryDetection=NATIVE_SYMBOL$2&&!!Symbol.for&&!!Symbol.keyFor,$$1A=_export,getBuiltIn$i=getBuiltIn$o,hasOwn$f=hasOwnProperty_1,toString$f=toString$h,shared$1=shared$6.exports,NATIVE_SYMBOL_REGISTRY$1=symbolRegistryDetection,StringToSymbolRegistry=shared$1("string-to-symbol-registry"),SymbolToStringRegistry$1=shared$1("symbol-to-string-registry");$$1A({target:"Symbol",stat:!0,forced:!NATIVE_SYMBOL_REGISTRY$1},{for:function(e){var t=toString$f(e);if(hasOwn$f(StringToSymbolRegistry,t))return StringToSymbolRegistry[t];var r=getBuiltIn$i("Symbol")(t);return StringToSymbolRegistry[t]=r,SymbolToStringRegistry$1[r]=t,r}});var $$1z=_export,hasOwn$e=hasOwnProperty_1,isSymbol$1=isSymbol$4,tryToString$4=tryToString$6,shared=shared$6.exports,NATIVE_SYMBOL_REGISTRY=symbolRegistryDetection,SymbolToStringRegistry=shared("symbol-to-string-registry");$$1z({target:"Symbol",stat:!0,forced:!NATIVE_SYMBOL_REGISTRY},{keyFor:function(e){if(!isSymbol$1(e))throw TypeError(tryToString$4(e)+" is not a symbol");if(hasOwn$e(SymbolToStringRegistry,e))return SymbolToStringRegistry[e]}});var uncurryThis$q=functionUncurryThis,arraySlice$6=uncurryThis$q([].slice),$$1y=_export,getBuiltIn$h=getBuiltIn$o,apply$4=functionApply,call$z=functionCall,uncurryThis$p=functionUncurryThis,fails$n=fails$z,isArray$c=isArray$f,isCallable$b=isCallable$n,isObject$i=isObject$q,isSymbol=isSymbol$4,arraySlice$5=arraySlice$6,NATIVE_SYMBOL$1=symbolConstructorDetection,$stringify=getBuiltIn$h("JSON","stringify"),exec$3=uncurryThis$p(/./.exec),charAt$5=uncurryThis$p("".charAt),charCodeAt$2=uncurryThis$p("".charCodeAt),replace$5=uncurryThis$p("".replace),numberToString$1=uncurryThis$p(1..toString),tester=/[\uD800-\uDFFF]/g,low=/^[\uD800-\uDBFF]$/,hi=/^[\uDC00-\uDFFF]$/,WRONG_SYMBOLS_CONVERSION=!NATIVE_SYMBOL$1||fails$n((function(){var e=getBuiltIn$h("Symbol")();return"[null]"!=$stringify([e])||"{}"!=$stringify({a:e})||"{}"!=$stringify(Object(e))})),ILL_FORMED_UNICODE=fails$n((function(){return'"\\udf06\\ud834"'!==$stringify("\udf06\ud834")||'"\\udead"'!==$stringify("\udead")})),stringifyWithSymbolsFix=function(e,t){var r=arraySlice$5(arguments),n=t;if((isObject$i(t)||void 0!==e)&&!isSymbol(e))return isArray$c(t)||(t=function(e,t){if(isCallable$b(n)&&(t=call$z(n,this,e,t)),!isSymbol(t))return t}),r[1]=t,apply$4($stringify,null,r)},fixIllFormed=function(e,t,r){var n=charAt$5(r,t-1),i=charAt$5(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&&$$1y({target:"JSON",stat:!0,arity:3,forced:WRONG_SYMBOLS_CONVERSION||ILL_FORMED_UNICODE},{stringify:function(e,t,r){var n=arraySlice$5(arguments),i=apply$4(WRONG_SYMBOLS_CONVERSION?stringifyWithSymbolsFix:$stringify,null,n);return ILL_FORMED_UNICODE&&"string"==typeof i?replace$5(i,tester,fixIllFormed):i}});var $$1x=_export,NATIVE_SYMBOL=symbolConstructorDetection,fails$m=fails$z,getOwnPropertySymbolsModule$2=objectGetOwnPropertySymbols,toObject$9=toObject$d,FORCED$5=!NATIVE_SYMBOL||fails$m((function(){getOwnPropertySymbolsModule$2.f(1)}));$$1x({target:"Object",stat:!0,forced:FORCED$5},{getOwnPropertySymbols:function(e){var t=getOwnPropertySymbolsModule$2.f;return t?t(toObject$9(e)):[]}});var defineWellKnownSymbol$k=wellKnownSymbolDefine;defineWellKnownSymbol$k("asyncIterator");var defineWellKnownSymbol$j=wellKnownSymbolDefine;defineWellKnownSymbol$j("hasInstance");var defineWellKnownSymbol$i=wellKnownSymbolDefine;defineWellKnownSymbol$i("isConcatSpreadable");var defineWellKnownSymbol$h=wellKnownSymbolDefine;defineWellKnownSymbol$h("iterator");var defineWellKnownSymbol$g=wellKnownSymbolDefine;defineWellKnownSymbol$g("match");var defineWellKnownSymbol$f=wellKnownSymbolDefine;defineWellKnownSymbol$f("matchAll");var defineWellKnownSymbol$e=wellKnownSymbolDefine;defineWellKnownSymbol$e("replace");var defineWellKnownSymbol$d=wellKnownSymbolDefine;defineWellKnownSymbol$d("search");var defineWellKnownSymbol$c=wellKnownSymbolDefine;defineWellKnownSymbol$c("species");var defineWellKnownSymbol$b=wellKnownSymbolDefine;defineWellKnownSymbol$b("split");var defineWellKnownSymbol$a=wellKnownSymbolDefine,defineSymbolToPrimitive=symbolDefineToPrimitive;defineWellKnownSymbol$a("toPrimitive"),defineSymbolToPrimitive();var getBuiltIn$g=getBuiltIn$o,defineWellKnownSymbol$9=wellKnownSymbolDefine,setToStringTag$7=setToStringTag$9;defineWellKnownSymbol$9("toStringTag"),setToStringTag$7(getBuiltIn$g("Symbol"),"Symbol");var defineWellKnownSymbol$8=wellKnownSymbolDefine;defineWellKnownSymbol$8("unscopables");var global$h=global$s,setToStringTag$6=setToStringTag$9;setToStringTag$6(global$h.JSON,"JSON",!0);var IteratorPrototype$1,PrototypeOfArrayIteratorPrototype,arrayIterator,path$q=path$v,symbol$5=path$q.Symbol,addToUnscopables$1=function(){},iterators={},DESCRIPTORS$d=descriptors,hasOwn$d=hasOwnProperty_1,FunctionPrototype$1=Function.prototype,getDescriptor=DESCRIPTORS$d&&Object.getOwnPropertyDescriptor,EXISTS=hasOwn$d(FunctionPrototype$1,"name"),PROPER=EXISTS&&"something"===function(){}.name,CONFIGURABLE=EXISTS&&(!DESCRIPTORS$d||DESCRIPTORS$d&&getDescriptor(FunctionPrototype$1,"name").configurable),functionName={EXISTS:EXISTS,PROPER:PROPER,CONFIGURABLE:CONFIGURABLE},fails$l=fails$z,correctPrototypeGetter=!fails$l((function(){function e(){}return e.prototype.constructor=null,Object.getPrototypeOf(new e)!==e.prototype})),hasOwn$c=hasOwnProperty_1,isCallable$a=isCallable$n,toObject$8=toObject$d,sharedKey=sharedKey$4,CORRECT_PROTOTYPE_GETTER$1=correctPrototypeGetter,IE_PROTO=sharedKey("IE_PROTO"),$Object=Object,ObjectPrototype$1=$Object.prototype,objectGetPrototypeOf=CORRECT_PROTOTYPE_GETTER$1?$Object.getPrototypeOf:function(e){var t=toObject$8(e);if(hasOwn$c(t,IE_PROTO))return t[IE_PROTO];var r=t.constructor;return isCallable$a(r)&&t instanceof r?r.prototype:t instanceof $Object?ObjectPrototype$1:null},fails$k=fails$z,isCallable$9=isCallable$n,isObject$h=isObject$q,create$c=objectCreate$1,getPrototypeOf$a=objectGetPrototypeOf,defineBuiltIn$5=defineBuiltIn$8,wellKnownSymbol$e=wellKnownSymbol$p,ITERATOR$8=wellKnownSymbol$e("iterator"),BUGGY_SAFARI_ITERATORS$1=!1;[].keys&&("next"in(arrayIterator=[].keys())?(PrototypeOfArrayIteratorPrototype=getPrototypeOf$a(getPrototypeOf$a(arrayIterator)))!==Object.prototype&&(IteratorPrototype$1=PrototypeOfArrayIteratorPrototype):BUGGY_SAFARI_ITERATORS$1=!0);var NEW_ITERATOR_PROTOTYPE=!isObject$h(IteratorPrototype$1)||fails$k((function(){var e={};return IteratorPrototype$1[ITERATOR$8].call(e)!==e}));isCallable$9((IteratorPrototype$1=NEW_ITERATOR_PROTOTYPE?{}:create$c(IteratorPrototype$1))[ITERATOR$8])||defineBuiltIn$5(IteratorPrototype$1,ITERATOR$8,(function(){return this}));var iteratorsCore={IteratorPrototype:IteratorPrototype$1,BUGGY_SAFARI_ITERATORS:BUGGY_SAFARI_ITERATORS$1},IteratorPrototype=iteratorsCore.IteratorPrototype,create$b=objectCreate$1,createPropertyDescriptor$4=createPropertyDescriptor$9,setToStringTag$5=setToStringTag$9,Iterators$5=iterators,returnThis$1=function(){return this},iteratorCreateConstructor=function(e,t,r,n){var i=t+" Iterator";return e.prototype=create$b(IteratorPrototype,{next:createPropertyDescriptor$4(+!n,r)}),setToStringTag$5(e,i,!1,!0),Iterators$5[i]=returnThis$1,e},isCallable$8=isCallable$n,$String=String,$TypeError$e=TypeError,aPossiblePrototype$1=function(e){if("object"==typeof e||isCallable$8(e))return e;throw $TypeError$e("Can't set "+$String(e)+" as a prototype")},uncurryThis$o=functionUncurryThis,anObject$H=anObject$M,aPossiblePrototype=aPossiblePrototype$1,objectSetPrototypeOf=Object.setPrototypeOf||("__proto__"in{}?function(){var e,t=!1,r={};try{(e=uncurryThis$o(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),$$1w=_export,call$y=functionCall,FunctionName=functionName,createIteratorConstructor$1=iteratorCreateConstructor,getPrototypeOf$9=objectGetPrototypeOf,setToStringTag$4=setToStringTag$9,defineBuiltIn$4=defineBuiltIn$8,wellKnownSymbol$d=wellKnownSymbol$p,Iterators$4=iterators,IteratorsCore=iteratorsCore,PROPER_FUNCTION_NAME$1=FunctionName.PROPER;FunctionName.CONFIGURABLE,IteratorsCore.IteratorPrototype;var BUGGY_SAFARI_ITERATORS=IteratorsCore.BUGGY_SAFARI_ITERATORS,ITERATOR$7=wellKnownSymbol$d("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,l,u=function(e){if(e===i&&f)return f;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,h=_[ITERATOR$7]||_["@@iterator"]||i&&_[i],f=!BUGGY_SAFARI_ITERATORS&&h||u(i),m="Array"==t&&_.entries||h;if(m&&(s=getPrototypeOf$9(m.call(new e)))!==Object.prototype&&s.next&&(setToStringTag$4(s,d,!0,!0),Iterators$4[d]=returnThis),PROPER_FUNCTION_NAME$1&&i==VALUES&&h&&h.name!==VALUES&&(p=!0,f=function(){return call$y(h,this)}),i)if(c={values:u(VALUES),keys:o?f:u(KEYS),entries:u(ENTRIES)},a)for(l in c)(BUGGY_SAFARI_ITERATORS||p||!(l in _))&&defineBuiltIn$4(_,l,c[l]);else $$1w({target:t,proto:!0,forced:BUGGY_SAFARI_ITERATORS||p},c);return a&&_[ITERATOR$7]!==f&&defineBuiltIn$4(_,ITERATOR$7,f,{name:i}),Iterators$4[t]=f,c},createIterResultObject$3=function(e,t){return{value:e,done:t}},toIndexedObject$4=toIndexedObject$b,addToUnscopables=addToUnscopables$1,Iterators$3=iterators,InternalStateModule$7=internalState,defineProperty$7=objectDefineProperty.f,defineIterator$2=iteratorDefine,createIterResultObject$2=createIterResultObject$3,IS_PURE$2=isPure,DESCRIPTORS$c=descriptors,ARRAY_ITERATOR="Array Iterator",setInternalState$7=InternalStateModule$7.set,getInternalState$1=InternalStateModule$7.getterFor(ARRAY_ITERATOR);defineIterator$2(Array,"Array",(function(e,t){setInternalState$7(this,{type:ARRAY_ITERATOR,target:toIndexedObject$4(e),index:0,kind:t})}),(function(){var e=getInternalState$1(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");var values$8=Iterators$3.Arguments=Iterators$3.Array;if(addToUnscopables(),addToUnscopables(),addToUnscopables(),!IS_PURE$2&&DESCRIPTORS$c&&"values"!==values$8.name)try{defineProperty$7(values$8,"name",{value:"values"})}catch(e){}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},DOMIterables$3=domIterables,global$g=global$s,classof$8=classof$d,createNonEnumerableProperty$3=createNonEnumerableProperty$8,Iterators$2=iterators,wellKnownSymbol$c=wellKnownSymbol$p,TO_STRING_TAG$1=wellKnownSymbol$c("toStringTag");for(var COLLECTION_NAME in DOMIterables$3){var Collection=global$g[COLLECTION_NAME],CollectionPrototype=Collection&&Collection.prototype;CollectionPrototype&&classof$8(CollectionPrototype)!==TO_STRING_TAG$1&&createNonEnumerableProperty$3(CollectionPrototype,TO_STRING_TAG$1,COLLECTION_NAME),Iterators$2[COLLECTION_NAME]=Iterators$2.Array}var parent$2u=symbol$5,symbol$4=parent$2u,parent$2t=symbol$4,symbol$3=parent$2t,defineWellKnownSymbol$7=wellKnownSymbolDefine;defineWellKnownSymbol$7("asyncDispose");var defineWellKnownSymbol$6=wellKnownSymbolDefine;defineWellKnownSymbol$6("dispose");var defineWellKnownSymbol$5=wellKnownSymbolDefine;defineWellKnownSymbol$5("matcher");var defineWellKnownSymbol$4=wellKnownSymbolDefine;defineWellKnownSymbol$4("metadataKey");var defineWellKnownSymbol$3=wellKnownSymbolDefine;defineWellKnownSymbol$3("observable");var defineWellKnownSymbol$2=wellKnownSymbolDefine;defineWellKnownSymbol$2("metadata");var defineWellKnownSymbol$1=wellKnownSymbolDefine;defineWellKnownSymbol$1("patternMatch");var defineWellKnownSymbol=wellKnownSymbolDefine;defineWellKnownSymbol("replaceAll");var parent$2s=symbol$3,symbol$2=parent$2s,symbol$1=symbol$2,symbol=symbol$1,uncurryThis$n=functionUncurryThis,toIntegerOrInfinity$2=toIntegerOrInfinity$5,toString$e=toString$h,requireObjectCoercible$6=requireObjectCoercible$9,charAt$4=uncurryThis$n("".charAt),charCodeAt$1=uncurryThis$n("".charCodeAt),stringSlice$4=uncurryThis$n("".slice),createMethod$4=function(e){return function(t,r){var n,i,o=toString$e(requireObjectCoercible$6(t)),a=toIntegerOrInfinity$2(r),s=o.length;return a<0||a>=s?e?"":void 0:(n=charCodeAt$1(o,a))<55296||n>56319||a+1===s||(i=charCodeAt$1(o,a+1))<56320||i>57343?e?charAt$4(o,a):n:e?stringSlice$4(o,a,a+2):i-56320+(n-55296<<10)+65536}},stringMultibyte={codeAt:createMethod$4(!1),charAt:createMethod$4(!0)},charAt$3=stringMultibyte.charAt,toString$d=toString$h,InternalStateModule$6=internalState,defineIterator$1=iteratorDefine,createIterResultObject$1=createIterResultObject$3,STRING_ITERATOR="String Iterator",setInternalState$6=InternalStateModule$6.set,getInternalState=InternalStateModule$6.getterFor(STRING_ITERATOR);defineIterator$1(String,"String",(function(e){setInternalState$6(this,{type:STRING_ITERATOR,string:toString$d(e),index:0})}),(function(){var e,t=getInternalState(this),r=t.string,n=t.index;return n>=r.length?createIterResultObject$1(void 0,!0):(e=charAt$3(r,n),t.index+=e.length,createIterResultObject$1(e,!1))}));var WrappedWellKnownSymbolModule$2=wellKnownSymbolWrapped,iterator$5=WrappedWellKnownSymbolModule$2.f("iterator"),parent$2r=iterator$5,iterator$4=parent$2r,parent$2q=iterator$4,iterator$3=parent$2q,parent$2p=iterator$3,iterator$2=parent$2p,iterator$1=iterator$2,iterator=iterator$1;function _typeof(e){return(_typeof="function"==typeof symbol&&"symbol"==typeof iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof symbol&&e.constructor===symbol&&e!==symbol.prototype?"symbol":typeof e})(e)}var WrappedWellKnownSymbolModule$1=wellKnownSymbolWrapped,toPrimitive$5=WrappedWellKnownSymbolModule$1.f("toPrimitive"),parent$2o=toPrimitive$5,toPrimitive$4=parent$2o,parent$2n=toPrimitive$4,toPrimitive$3=parent$2n,parent$2m=toPrimitive$3,toPrimitive$2=parent$2m,toPrimitive$1=toPrimitive$2,toPrimitive=toPrimitive$1;function _toPrimitive(e,t){if("object"!==_typeof(e)||null===e)return e;var r=e[toPrimitive];if(void 0!==r){var n=r.call(e,t||"default");if("object"!==_typeof(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}function _toPropertyKey(e){var t=_toPrimitive(e,"string");return"symbol"===_typeof(t)?t:String(t)}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),defineProperty$a(e,_toPropertyKey(n.key),n)}}function _createClass(e,t,r){return t&&_defineProperties(e.prototype,t),r&&_defineProperties(e,r),defineProperty$a(e,"prototype",{writable:!1}),e}function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function _defineProperty(e,t,r){return(t=_toPropertyKey(t))in e?defineProperty$a(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var $$1v=_export,DESCRIPTORS$b=descriptors,create$a=objectCreate$1;$$1v({target:"Object",stat:!0,sham:!DESCRIPTORS$b},{create:create$a});var path$p=path$v,Object$3=path$p.Object,create$9=function(e,t){return Object$3.create(e,t)},parent$2l=create$9,create$8=parent$2l,parent$2k=create$8,create$7=parent$2k,parent$2j=create$7,create$6=parent$2j,create$5=create$6,create$4=create$5,$$1u=_export,fails$j=fails$z,toObject$7=toObject$d,nativeGetPrototypeOf=objectGetPrototypeOf,CORRECT_PROTOTYPE_GETTER=correctPrototypeGetter,FAILS_ON_PRIMITIVES$3=fails$j((function(){nativeGetPrototypeOf(1)}));$$1u({target:"Object",stat:!0,forced:FAILS_ON_PRIMITIVES$3,sham:!CORRECT_PROTOTYPE_GETTER},{getPrototypeOf:function(e){return nativeGetPrototypeOf(toObject$7(e))}});var path$o=path$v,getPrototypeOf$8=path$o.Object.getPrototypeOf,parent$2i=getPrototypeOf$8,getPrototypeOf$7=parent$2i,parent$2h=getPrototypeOf$7,getPrototypeOf$6=parent$2h,parent$2g=getPrototypeOf$6,getPrototypeOf$5=parent$2g,getPrototypeOf$4=getPrototypeOf$5,getPrototypeOf$3=getPrototypeOf$4,fails$i=fails$z,arrayMethodIsStrict$4=function(e,t){var r=[][e];return!!r&&fails$i((function(){r.call(null,t||function(){return 1},1)}))},$forEach=arrayIteration.forEach,arrayMethodIsStrict$3=arrayMethodIsStrict$4,STRICT_METHOD$3=arrayMethodIsStrict$3("forEach"),arrayForEach=STRICT_METHOD$3?[].forEach:function(e){return $forEach(this,e,arguments.length>1?arguments[1]:void 0)},$$1t=_export,forEach$8=arrayForEach;$$1t({target:"Array",proto:!0,forced:[].forEach!=arrayForEach},{forEach:arrayForEach});var path$n=path$v,entryVirtual$m=function(e){return path$n[e+"Prototype"]},entryVirtual$l=entryVirtual$m,forEach$7=entryVirtual$l("Array").forEach,parent$2f=forEach$7,forEach$6=parent$2f,classof$7=classof$d,hasOwn$b=hasOwnProperty_1,isPrototypeOf$p=objectIsPrototypeOf,method$j=forEach$6,ArrayPrototype$g=Array.prototype,DOMIterables$2={DOMTokenList:!0,NodeList:!0},forEach$5=function(e){var t=e.forEach;return e===ArrayPrototype$g||isPrototypeOf$p(ArrayPrototype$g,e)&&t===ArrayPrototype$g.forEach||hasOwn$b(DOMIterables$2,classof$7(e))?method$j:t},parent$2e=forEach$5,forEach$4=parent$2e,parent$2d=forEach$4,forEach$3=parent$2d,forEach$2=forEach$3,forEach$1=forEach$2,$$1s=_export,setPrototypeOf$7=objectSetPrototypeOf;$$1s({target:"Object",stat:!0},{setPrototypeOf:setPrototypeOf$7});var path$m=path$v,setPrototypeOf$6=path$m.Object.setPrototypeOf,parent$2c=setPrototypeOf$6,setPrototypeOf$5=parent$2c,parent$2b=setPrototypeOf$5,setPrototypeOf$4=parent$2b,parent$2a=setPrototypeOf$4,setPrototypeOf$3=parent$2a,setPrototypeOf$2=setPrototypeOf$3,setPrototypeOf$1=setPrototypeOf$2,getBuiltIn$f=getBuiltIn$o,uncurryThis$m=functionUncurryThis,getOwnPropertyNamesModule$1=objectGetOwnPropertyNames,getOwnPropertySymbolsModule$1=objectGetOwnPropertySymbols,anObject$G=anObject$M,concat$9=uncurryThis$m([].concat),ownKeys$3=getBuiltIn$f("Reflect","ownKeys")||function(e){var t=getOwnPropertyNamesModule$1.f(anObject$G(e)),r=getOwnPropertySymbolsModule$1.f;return r?concat$9(t,r(e)):t},hasOwn$a=hasOwnProperty_1,ownKeys$2=ownKeys$3,getOwnPropertyDescriptorModule$3=objectGetOwnPropertyDescriptor,definePropertyModule$2=objectDefineProperty,copyConstructorProperties$1=function(e,t,r){for(var n=ownKeys$2(t),i=definePropertyModule$2.f,o=getOwnPropertyDescriptorModule$3.f,a=0;a<n.length;a++){var s=n[a];hasOwn$a(e,s)||r&&hasOwn$a(r,s)||i(e,s,o(t,s))}},uncurryThis$l=functionUncurryThis,$Error$1=Error,replace$4=uncurryThis$l("".replace),TEST=String($Error$1("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$1.prepareStackTrace)for(;t--;)e=replace$4(e,V8_OR_CHAKRA_STACK_ENTRY,"");return e},isObject$g=isObject$q,createNonEnumerableProperty$2=createNonEnumerableProperty$8,installErrorCause$1=function(e,t){isObject$g(t)&&"cause"in t&&createNonEnumerableProperty$2(e,"cause",t.cause)},wellKnownSymbol$b=wellKnownSymbol$p,Iterators$1=iterators,ITERATOR$6=wellKnownSymbol$b("iterator"),ArrayPrototype$f=Array.prototype,isArrayIteratorMethod$2=function(e){return void 0!==e&&(Iterators$1.Array===e||ArrayPrototype$f[ITERATOR$6]===e)},classof$6=classof$d,getMethod$1=getMethod$3,isNullOrUndefined$4=isNullOrUndefined$7,Iterators=iterators,wellKnownSymbol$a=wellKnownSymbol$p,ITERATOR$5=wellKnownSymbol$a("iterator"),getIteratorMethod$a=function(e){if(!isNullOrUndefined$4(e))return getMethod$1(e,ITERATOR$5)||getMethod$1(e,"@@iterator")||Iterators[classof$6(e)]},call$x=functionCall,aCallable$w=aCallable$z,anObject$F=anObject$M,tryToString$3=tryToString$6,getIteratorMethod$9=getIteratorMethod$a,$TypeError$d=TypeError,getIterator$7=function(e,t){var r=arguments.length<2?getIteratorMethod$9(e):t;if(aCallable$w(r))return anObject$F(call$x(r,e));throw $TypeError$d(tryToString$3(e)+" is not iterable")},call$w=functionCall,anObject$E=anObject$M,getMethod=getMethod$3,iteratorClose$2=function(e,t,r){var n,i;anObject$E(e);try{if(!(n=getMethod(e,"return"))){if("throw"===t)throw r;return r}n=call$w(n,e)}catch(e){i=!0,n=e}if("throw"===t)throw r;if(i)throw n;return anObject$E(n),r},bind$t=functionBindContext,call$v=functionCall,anObject$D=anObject$M,tryToString$2=tryToString$6,isArrayIteratorMethod$1=isArrayIteratorMethod$2,lengthOfArrayLike$6=lengthOfArrayLike$b,isPrototypeOf$o=objectIsPrototypeOf,getIterator$6=getIterator$7,getIteratorMethod$8=getIteratorMethod$a,iteratorClose$1=iteratorClose$2,$TypeError$c=TypeError,Result=function(e,t){this.stopped=e,this.result=t},ResultPrototype=Result.prototype,iterate$A=function(e,t,r){var n,i,o,a,s,c,l,u=r&&r.that,d=!(!r||!r.AS_ENTRIES),p=!(!r||!r.IS_RECORD),_=!(!r||!r.IS_ITERATOR),h=!(!r||!r.INTERRUPTED),f=bind$t(t,u),m=function(e){return n&&iteratorClose$1(n,"normal",e),new Result(!0,e)},v=function(e){return d?(anObject$D(e),h?f(e[0],e[1],m):f(e[0],e[1])):h?f(e,m):f(e)};if(p)n=e.iterator;else if(_)n=e;else{if(!(i=getIteratorMethod$8(e)))throw $TypeError$c(tryToString$2(e)+" is not iterable");if(isArrayIteratorMethod$1(i)){for(o=0,a=lengthOfArrayLike$6(e);a>o;o++)if((s=v(e[o]))&&isPrototypeOf$o(ResultPrototype,s))return s;return new Result(!1)}n=getIterator$6(e,i)}for(c=p?e.next:n.next;!(l=call$v(c,n)).done;){try{s=v(l.value)}catch(e){iteratorClose$1(n,"throw",e)}if("object"==typeof s&&s&&isPrototypeOf$o(ResultPrototype,s))return s}return new Result(!1)},toString$c=toString$h,normalizeStringArgument$1=function(e,t){return void 0===e?arguments.length<2?"":t:toString$c(e)},fails$h=fails$z,createPropertyDescriptor$3=createPropertyDescriptor$9,errorStackInstallable=!fails$h((function(){var e=Error("a");return!("stack"in e)||(Object.defineProperty(e,"stack",createPropertyDescriptor$3(1,7)),7!==e.stack)})),$$1r=_export,isPrototypeOf$n=objectIsPrototypeOf,getPrototypeOf$2=objectGetPrototypeOf,setPrototypeOf=objectSetPrototypeOf,copyConstructorProperties=copyConstructorProperties$1,create$3=objectCreate$1,createNonEnumerableProperty$1=createNonEnumerableProperty$8,createPropertyDescriptor$2=createPropertyDescriptor$9,clearErrorStack=errorStackClear,installErrorCause=installErrorCause$1,iterate$z=iterate$A,normalizeStringArgument=normalizeStringArgument$1,wellKnownSymbol$9=wellKnownSymbol$p,ERROR_STACK_INSTALLABLE=errorStackInstallable,TO_STRING_TAG=wellKnownSymbol$9("toStringTag"),$Error=Error,push$9=[].push,$AggregateError=function(e,t){var r,n=arguments.length>2?arguments[2]:void 0,i=isPrototypeOf$n(AggregateErrorPrototype,this);setPrototypeOf?r=setPrototypeOf($Error(),i?getPrototypeOf$2(this):AggregateErrorPrototype):(r=i?this:create$3(AggregateErrorPrototype),createNonEnumerableProperty$1(r,TO_STRING_TAG,"Error")),void 0!==t&&createNonEnumerableProperty$1(r,"message",normalizeStringArgument(t)),ERROR_STACK_INSTALLABLE&&createNonEnumerableProperty$1(r,"stack",clearErrorStack(r.stack,1)),installErrorCause(r,n);var o=[];return iterate$z(e,push$9,{that:o}),createNonEnumerableProperty$1(r,"errors",o),r};setPrototypeOf?setPrototypeOf($AggregateError,$Error):copyConstructorProperties($AggregateError,$Error,{name:!0});var AggregateErrorPrototype=$AggregateError.prototype=create$3($Error.prototype,{constructor:createPropertyDescriptor$2(1,$AggregateError),message:createPropertyDescriptor$2(1,""),name:createPropertyDescriptor$2(1,"AggregateError")});$$1r({global:!0,constructor:!0,arity:2},{AggregateError:$AggregateError});var $location,defer,channel,port,classof$5=classofRaw$2,global$f=global$s,engineIsNode="process"==classof$5(global$f.process),getBuiltIn$e=getBuiltIn$o,definePropertyModule$1=objectDefineProperty,wellKnownSymbol$8=wellKnownSymbol$p,DESCRIPTORS$a=descriptors,SPECIES$3=wellKnownSymbol$8("species"),setSpecies$2=function(e){var t=getBuiltIn$e(e),r=definePropertyModule$1.f;DESCRIPTORS$a&&t&&!t[SPECIES$3]&&r(t,SPECIES$3,{configurable:!0,get:function(){return this}})},isPrototypeOf$m=objectIsPrototypeOf,$TypeError$b=TypeError,anInstance$6=function(e,t){if(isPrototypeOf$m(t,e))return e;throw $TypeError$b("Incorrect invocation")},isConstructor$2=isConstructor$4,tryToString$1=tryToString$6,$TypeError$a=TypeError,aConstructor$3=function(e){if(isConstructor$2(e))return e;throw $TypeError$a(tryToString$1(e)+" is not a constructor")},anObject$C=anObject$M,aConstructor$2=aConstructor$3,isNullOrUndefined$3=isNullOrUndefined$7,wellKnownSymbol$7=wellKnownSymbol$p,SPECIES$2=wellKnownSymbol$7("species"),speciesConstructor$b=function(e,t){var r,n=anObject$C(e).constructor;return void 0===n||isNullOrUndefined$3(r=anObject$C(n)[SPECIES$2])?t:aConstructor$2(r)},$TypeError$9=TypeError,validateArgumentsLength$3=function(e,t){if(e<t)throw $TypeError$9("Not enough arguments");return e},userAgent$5=engineUserAgent,engineIsIos=/(?:ipad|iphone|ipod).*applewebkit/i.test(userAgent$5),global$e=global$s,apply$3=functionApply,bind$s=functionBindContext,isCallable$7=isCallable$n,hasOwn$9=hasOwnProperty_1,fails$g=fails$z,html=html$2,arraySlice$4=arraySlice$6,createElement$1=documentCreateElement$1,validateArgumentsLength$2=validateArgumentsLength$3,IS_IOS$1=engineIsIos,IS_NODE$4=engineIsNode,set$d=global$e.setImmediate,clear=global$e.clearImmediate,process$2=global$e.process,Dispatch=global$e.Dispatch,Function$1=global$e.Function,MessageChannel=global$e.MessageChannel,String$1=global$e.String,counter=0,queue$1={},ONREADYSTATECHANGE="onreadystatechange";try{$location=global$e.location}catch(e){}var run=function(e){if(hasOwn$9(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$e.postMessage(String$1(e),$location.protocol+"//"+$location.host)};set$d&&clear||(set$d=function(e){validateArgumentsLength$2(arguments.length,1);var t=isCallable$7(e)?e:Function$1(e),r=arraySlice$4(arguments,1);return queue$1[++counter]=function(){apply$3(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$s(port.postMessage,port)):global$e.addEventListener&&isCallable$7(global$e.postMessage)&&!global$e.importScripts&&$location&&"file:"!==$location.protocol&&!fails$g(post)?(defer=post,global$e.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$6,then,task$1={set:set$d,clear:clear},userAgent$4=engineUserAgent,global$d=global$s,engineIsIosPebble=/ipad|iphone|ipod/i.test(userAgent$4)&&void 0!==global$d.Pebble,userAgent$3=engineUserAgent,engineIsWebosWebkit=/web0s(?!.*chrome)/i.test(userAgent$3),global$c=global$s,bind$r=functionBindContext,getOwnPropertyDescriptor$9=objectGetOwnPropertyDescriptor.f,macrotask=task$1.set,IS_IOS=engineIsIos,IS_IOS_PEBBLE=engineIsIosPebble,IS_WEBOS_WEBKIT=engineIsWebosWebkit,IS_NODE$3=engineIsNode,MutationObserver=global$c.MutationObserver||global$c.WebKitMutationObserver,document$2=global$c.document,process$1=global$c.process,Promise$3=global$c.Promise,queueMicrotaskDescriptor=getOwnPropertyDescriptor$9(global$c,"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$3&&Promise$3.resolve?((promise$6=Promise$3.resolve(void 0)).constructor=Promise$3,then=bind$r(promise$6.then,promise$6),notify$1=function(){then(flush)}):IS_NODE$3?notify$1=function(){process$1.nextTick(flush)}:(macrotask=bind$r(macrotask,global$c),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$b=global$s,hostReportErrors$1=function(e,t){var r=global$b.console;r&&r.error&&(1==arguments.length?r.error(e):r.error(e,t))},perform$6=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$a=global$s,promiseNativeConstructor=global$a.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$9=global$s,NativePromiseConstructor$5=promiseNativeConstructor,isCallable$6=isCallable$n,isForced=isForced_1,inspectSource=inspectSource$2,wellKnownSymbol$6=wellKnownSymbol$p,IS_BROWSER=engineIsBrowser,IS_DENO=engineIsDeno,V8_VERSION=engineV8Version,NativePromisePrototype$2=NativePromiseConstructor$5&&NativePromiseConstructor$5.prototype,SPECIES$1=wellKnownSymbol$6("species"),SUBCLASSING=!1,NATIVE_PROMISE_REJECTION_EVENT$1=isCallable$6(global$9.PromiseRejectionEvent),FORCED_PROMISE_CONSTRUCTOR$5=isForced("Promise",(function(){var e=inspectSource(NativePromiseConstructor$5),t=e!==String(NativePromiseConstructor$5);if(!t&&66===V8_VERSION)return!0;if(!NativePromisePrototype$2.catch||!NativePromisePrototype$2.finally)return!0;if(!V8_VERSION||V8_VERSION<51||!/native code/.test(e)){var r=new NativePromiseConstructor$5((function(e){e(1)})),n=function(e){e((function(){}),(function(){}))};if((r.constructor={})[SPECIES$1]=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$v=aCallable$z,$TypeError$8=TypeError,PromiseCapability=function(e){var t,r;this.promise=new e((function(e,n){if(void 0!==t||void 0!==r)throw $TypeError$8("Bad Promise constructor");t=e,r=n})),this.resolve=aCallable$v(t),this.reject=aCallable$v(r)};newPromiseCapability$2.f=function(e){return new PromiseCapability(e)};var $$1q=_export,IS_NODE$1=engineIsNode,global$8=global$s,call$u=functionCall,defineBuiltIn$3=defineBuiltIn$8,setToStringTag$3=setToStringTag$9,setSpecies$1=setSpecies$2,aCallable$u=aCallable$z,isCallable$5=isCallable$n,isObject$f=isObject$q,anInstance$5=anInstance$6,speciesConstructor$a=speciesConstructor$b,task=task$1.set,microtask=microtask$1,hostReportErrors=hostReportErrors$1,perform$5=perform$6,Queue=queue,InternalStateModule$5=internalState,NativePromiseConstructor$4=promiseNativeConstructor,PromiseConstructorDetection=promiseConstructorDetection,newPromiseCapabilityModule$6=newPromiseCapability$2,PROMISE="Promise",FORCED_PROMISE_CONSTRUCTOR$4=PromiseConstructorDetection.CONSTRUCTOR,NATIVE_PROMISE_REJECTION_EVENT=PromiseConstructorDetection.REJECTION_EVENT;PromiseConstructorDetection.SUBCLASSING;var Internal,OwnPromiseCapability,PromiseWrapper,getInternalPromiseState=InternalStateModule$5.getterFor(PROMISE),setInternalState$5=InternalStateModule$5.set,NativePromisePrototype$1=NativePromiseConstructor$4&&NativePromiseConstructor$4.prototype,PromiseConstructor=NativePromiseConstructor$4,PromisePrototype=NativePromisePrototype$1,TypeError$3=global$8.TypeError,document$1=global$8.document,process=global$8.process,newPromiseCapability$1=newPromiseCapabilityModule$6.f,newGenericPromiseCapability=newPromiseCapability$1,DISPATCH_EVENT=!!(document$1&&document$1.createEvent&&global$8.dispatchEvent),UNHANDLED_REJECTION="unhandledrejection",REJECTION_HANDLED="rejectionhandled",PENDING=0,FULFILLED=1,REJECTED=2,HANDLED=1,UNHANDLED=2,isThenable=function(e){var t;return!(!isObject$f(e)||!isCallable$5(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,l=e.reject,u=e.domain;try{s?(a||(t.rejection===UNHANDLED&&onHandleUnhandled(t),t.rejection=HANDLED),!0===s?r=o:(u&&u.enter(),r=s(o),u&&(u.exit(),i=!0)),r===e.promise?l(TypeError$3("Promise-chain cycle")):(n=isThenable(r))?call$u(n,r,c,l):c(r)):l(o)}catch(e){u&&!i&&u.exit(),l(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$8.dispatchEvent(n)):n={promise:t,reason:r},!NATIVE_PROMISE_REJECTION_EVENT&&(i=global$8["on"+e])?i(n):e===UNHANDLED_REJECTION&&hostReportErrors("Unhandled promise rejection",r)},onUnhandled=function(e){call$u(task,global$8,(function(){var t,r=e.facade,n=e.value;if(isUnhandled(e)&&(t=perform$5((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$u(task,global$8,(function(){var t=e.facade;IS_NODE$1?process.emit("rejectionHandled",t):dispatchEvent(REJECTION_HANDLED,t,e.value)}))},bind$q=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$3("Promise can't be resolved itself");var n=isThenable(t);n?microtask((function(){var r={done:!1};try{call$u(n,t,bind$q(internalResolve,r,e),bind$q(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)}}};FORCED_PROMISE_CONSTRUCTOR$4&&(PromisePrototype=(PromiseConstructor=function(e){anInstance$5(this,PromisePrototype),aCallable$u(e),call$u(Internal,this);var t=getInternalPromiseState(this);try{e(bind$q(internalResolve,t),bind$q(internalReject,t))}catch(e){internalReject(t,e)}}).prototype,(Internal=function(e){setInternalState$5(this,{type:PROMISE,done:!1,notified:!1,parent:!1,reactions:new Queue,rejection:!1,state:PENDING,value:void 0})}).prototype=defineBuiltIn$3(PromisePrototype,"then",(function(e,t){var r=getInternalPromiseState(this),n=newPromiseCapability$1(speciesConstructor$a(this,PromiseConstructor));return r.parent=!0,n.ok=!isCallable$5(e)||e,n.fail=isCallable$5(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$q(internalResolve,t),this.reject=bind$q(internalReject,t)},newPromiseCapabilityModule$6.f=newPromiseCapability$1=function(e){return e===PromiseConstructor||e===PromiseWrapper?new OwnPromiseCapability(e):newGenericPromiseCapability(e)}),$$1q({global:!0,constructor:!0,wrap:!0,forced:FORCED_PROMISE_CONSTRUCTOR$4},{Promise:PromiseConstructor}),setToStringTag$3(PromiseConstructor,PROMISE,!1,!0),setSpecies$1(PROMISE);var wellKnownSymbol$5=wellKnownSymbol$p,ITERATOR$4=wellKnownSymbol$5("iterator"),SAFE_CLOSING=!1;try{var called=0,iteratorWithReturn={next:function(){return{done:!!called++}},return:function(){SAFE_CLOSING=!0}};iteratorWithReturn[ITERATOR$4]=function(){return this},Array.from(iteratorWithReturn,(function(){throw 2}))}catch(e){}var checkCorrectnessOfIteration$2=function(e,t){if(!t&&!SAFE_CLOSING)return!1;var r=!1;try{var n={};n[ITERATOR$4]=function(){return{next:function(){return{done:r=!0}}}},e(n)}catch(e){}return r},NativePromiseConstructor$3=promiseNativeConstructor,checkCorrectnessOfIteration$1=checkCorrectnessOfIteration$2,FORCED_PROMISE_CONSTRUCTOR$3=promiseConstructorDetection.CONSTRUCTOR,promiseStaticsIncorrectIteration=FORCED_PROMISE_CONSTRUCTOR$3||!checkCorrectnessOfIteration$1((function(e){NativePromiseConstructor$3.all(e).then(void 0,(function(){}))})),$$1p=_export,call$t=functionCall,aCallable$t=aCallable$z,newPromiseCapabilityModule$5=newPromiseCapability$2,perform$4=perform$6,iterate$y=iterate$A,PROMISE_STATICS_INCORRECT_ITERATION$1=promiseStaticsIncorrectIteration;$$1p({target:"Promise",stat:!0,forced:PROMISE_STATICS_INCORRECT_ITERATION$1},{all:function(e){var t=this,r=newPromiseCapabilityModule$5.f(t),n=r.resolve,i=r.reject,o=perform$4((function(){var r=aCallable$t(t.resolve),o=[],a=0,s=1;iterate$y(e,(function(e){var c=a++,l=!1;s++,call$t(r,t,e).then((function(e){l||(l=!0,o[c]=e,--s||n(o))}),i)})),--s||n(o)}));return o.error&&i(o.value),r.promise}});var $$1o=_export,FORCED_PROMISE_CONSTRUCTOR$2=promiseConstructorDetection.CONSTRUCTOR,NativePromiseConstructor$2=promiseNativeConstructor;promiseNativeConstructor&&promiseNativeConstructor.prototype,$$1o({target:"Promise",proto:!0,forced:FORCED_PROMISE_CONSTRUCTOR$2,real:!0},{catch:function(e){return this.then(void 0,e)}});var $$1n=_export,call$s=functionCall,aCallable$s=aCallable$z,newPromiseCapabilityModule$4=newPromiseCapability$2,perform$3=perform$6,iterate$x=iterate$A,PROMISE_STATICS_INCORRECT_ITERATION=promiseStaticsIncorrectIteration;$$1n({target:"Promise",stat:!0,forced:PROMISE_STATICS_INCORRECT_ITERATION},{race:function(e){var t=this,r=newPromiseCapabilityModule$4.f(t),n=r.reject,i=perform$3((function(){var i=aCallable$s(t.resolve);iterate$x(e,(function(e){call$s(i,t,e).then(r.resolve,n)}))}));return i.error&&n(i.value),r.promise}});var $$1m=_export,call$r=functionCall,newPromiseCapabilityModule$3=newPromiseCapability$2,FORCED_PROMISE_CONSTRUCTOR$1=promiseConstructorDetection.CONSTRUCTOR;$$1m({target:"Promise",stat:!0,forced:FORCED_PROMISE_CONSTRUCTOR$1},{reject:function(e){var t=newPromiseCapabilityModule$3.f(this);return call$r(t.reject,void 0,e),t.promise}});var anObject$B=anObject$M,isObject$e=isObject$q,newPromiseCapability=newPromiseCapability$2,promiseResolve$2=function(e,t){if(anObject$B(e),isObject$e(t)&&t.constructor===e)return t;var r=newPromiseCapability.f(e);return(0,r.resolve)(t),r.promise},$$1l=_export,getBuiltIn$d=getBuiltIn$o,IS_PURE$1=isPure,NativePromiseConstructor$1=promiseNativeConstructor,FORCED_PROMISE_CONSTRUCTOR=promiseConstructorDetection.CONSTRUCTOR,promiseResolve$1=promiseResolve$2,PromiseConstructorWrapper=getBuiltIn$d("Promise"),CHECK_WRAPPER=!FORCED_PROMISE_CONSTRUCTOR;$$1l({target:"Promise",stat:!0,forced:IS_PURE$1},{resolve:function(e){return promiseResolve$1(CHECK_WRAPPER&&this===PromiseConstructorWrapper?NativePromiseConstructor$1:this,e)}});var $$1k=_export,call$q=functionCall,aCallable$r=aCallable$z,newPromiseCapabilityModule$2=newPromiseCapability$2,perform$2=perform$6,iterate$w=iterate$A;$$1k({target:"Promise",stat:!0},{allSettled:function(e){var t=this,r=newPromiseCapabilityModule$2.f(t),n=r.resolve,i=r.reject,o=perform$2((function(){var r=aCallable$r(t.resolve),i=[],o=0,a=1;iterate$w(e,(function(e){var s=o++,c=!1;a++,call$q(r,t,e).then((function(e){c||(c=!0,i[s]={status:"fulfilled",value:e},--a||n(i))}),(function(e){c||(c=!0,i[s]={status:"rejected",reason:e},--a||n(i))}))})),--a||n(i)}));return o.error&&i(o.value),r.promise}});var $$1j=_export,call$p=functionCall,aCallable$q=aCallable$z,getBuiltIn$c=getBuiltIn$o,newPromiseCapabilityModule$1=newPromiseCapability$2,perform$1=perform$6,iterate$v=iterate$A,PROMISE_ANY_ERROR="No one promise resolved";$$1j({target:"Promise",stat:!0},{any:function(e){var t=this,r=getBuiltIn$c("AggregateError"),n=newPromiseCapabilityModule$1.f(t),i=n.resolve,o=n.reject,a=perform$1((function(){var n=aCallable$q(t.resolve),a=[],s=0,c=1,l=!1;iterate$v(e,(function(e){var u=s++,d=!1;c++,call$p(n,t,e).then((function(e){d||l||(l=!0,i(e))}),(function(e){d||l||(d=!0,a[u]=e,--c||o(new r(a,PROMISE_ANY_ERROR)))}))})),--c||o(new r(a,PROMISE_ANY_ERROR))}));return a.error&&o(a.value),n.promise}});var $$1i=_export,NativePromiseConstructor=promiseNativeConstructor,fails$f=fails$z,getBuiltIn$b=getBuiltIn$o,isCallable$4=isCallable$n,speciesConstructor$9=speciesConstructor$b,promiseResolve=promiseResolve$2,NativePromisePrototype=NativePromiseConstructor&&NativePromiseConstructor.prototype,NON_GENERIC=!!NativePromiseConstructor&&fails$f((function(){NativePromisePrototype.finally.call({then:function(){}},(function(){}))}));$$1i({target:"Promise",proto:!0,real:!0,forced:NON_GENERIC},{finally:function(e){var t=speciesConstructor$9(this,getBuiltIn$b("Promise")),r=isCallable$4(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)}});var path$l=path$v,promise$5=path$l.Promise,parent$29=promise$5,promise$4=parent$29,parent$28=promise$4,promise$3=parent$28,$$1h=_export,newPromiseCapabilityModule=newPromiseCapability$2,perform=perform$6;$$1h({target:"Promise",stat:!0,forced:!0},{try:function(e){var t=newPromiseCapabilityModule.f(this),r=perform(e);return(r.error?t.reject:t.resolve)(r.value),t.promise}});var parent$27=promise$3,promise$2=parent$27,promise$1=promise$2,promise=promise$1,$$1g=_export,uncurryThis$k=functionUncurryThis,isArray$b=isArray$f,nativeReverse=uncurryThis$k([].reverse),test$1=[1,2];$$1g({target:"Array",proto:!0,forced:String(test$1)===String(test$1.reverse())},{reverse:function(){return isArray$b(this)&&(this.length=this.length),nativeReverse(this)}});var entryVirtual$k=entryVirtual$m,reverse$6=entryVirtual$k("Array").reverse,isPrototypeOf$l=objectIsPrototypeOf,method$i=reverse$6,ArrayPrototype$e=Array.prototype,reverse$5=function(e){var t=e.reverse;return e===ArrayPrototype$e||isPrototypeOf$l(ArrayPrototype$e,e)&&t===ArrayPrototype$e.reverse?method$i:t},parent$26=reverse$5,reverse$4=parent$26,parent$25=reverse$4,reverse$3=parent$25,parent$24=reverse$3,reverse$2=parent$24,reverse$1=reverse$2,reverse2=reverse$1,$$1f=_export,isArray$a=isArray$f,isConstructor$1=isConstructor$4,isObject$d=isObject$q,toAbsoluteIndex$2=toAbsoluteIndex$5,lengthOfArrayLike$5=lengthOfArrayLike$b,toIndexedObject$3=toIndexedObject$b,createProperty$3=createProperty$6,wellKnownSymbol$4=wellKnownSymbol$p,arrayMethodHasSpeciesSupport$3=arrayMethodHasSpeciesSupport$5,nativeSlice=arraySlice$6,HAS_SPECIES_SUPPORT$3=arrayMethodHasSpeciesSupport$3("slice"),SPECIES=wellKnownSymbol$4("species"),$Array$1=Array,max$1=Math.max;$$1f({target:"Array",proto:!0,forced:!HAS_SPECIES_SUPPORT$3},{slice:function(e,t){var r,n,i,o=toIndexedObject$3(this),a=lengthOfArrayLike$5(o),s=toAbsoluteIndex$2(e,a),c=toAbsoluteIndex$2(void 0===t?a:t,a);if(isArray$a(o)&&(r=o.constructor,(isConstructor$1(r)&&(r===$Array$1||isArray$a(r.prototype))||isObject$d(r)&&null===(r=r[SPECIES]))&&(r=void 0),r===$Array$1||void 0===r))return nativeSlice(o,s,c);for(n=new(void 0===r?$Array$1:r)(max$1(c-s,0)),i=0;s<c;s++,i++)s in o&&createProperty$3(n,i,o[s]);return n.length=i,n}});var entryVirtual$j=entryVirtual$m,slice$7=entryVirtual$j("Array").slice,isPrototypeOf$k=objectIsPrototypeOf,method$h=slice$7,ArrayPrototype$d=Array.prototype,slice$6=function(e){var t=e.slice;return e===ArrayPrototype$d||isPrototypeOf$k(ArrayPrototype$d,e)&&t===ArrayPrototype$d.slice?method$h:t},parent$23=slice$6,slice$5=parent$23,parent$22=slice$5,slice$4=parent$22,parent$21=slice$4,slice$3=parent$21,slice$2=slice$3,slice$1=slice$2;function _regeneratorRuntime(){_regeneratorRuntime=function(){return e};var e={},t=Object.prototype,r=t.hasOwnProperty,n=defineProperty$a||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 defineProperty$a(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 l(e,t,r,i){var o=t&&t.prototype instanceof p?t:p,a=create$4(o.prototype),s=new b(i||[]);return n(a,"_invoke",{value:S(e,r,s)}),a}function u(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}e.wrap=l;var d={};function p(){}function _(){}function h(){}var f={};c(f,o,(function(){return this}));var m=getPrototypeOf$3&&getPrototypeOf$3(getPrototypeOf$3(I([])));m&&m!==t&&r.call(m,o)&&(f=m);var v=h.prototype=p.prototype=create$4(f);function g(e){var t;forEach$1(t=["next","throw","return"]).call(t,(function(t){c(e,t,(function(e){return this._invoke(t,e)}))}))}function y(e,t){function i(n,o,a,s){var c=u(e[n],e,o);if("throw"!==c.type){var l=c.arg,d=l.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){l.value=e,a(l)}),(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 S(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{value:void 0,done:!0}}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=u(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=t.method,n=e.iterator[r];if(void 0===n)return t.delegate=null,"throw"===r&&e.iterator.return&&(t.method="return",t.arg=void 0,T(e,t),"throw"===t.method)||"return"!==r&&(t.method="throw",t.arg=new TypeError("The iterator does not provide a '"+r+"' method")),d;var i=u(n,e.iterator,t.arg);if("throw"===i.type)return t.method="throw",t.arg=i.arg,t.delegate=null,d;var o=i.arg;return o?o.done?(t[e.resultName]=o.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,d):o:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,d)}function $(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 E(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function b(e){this.tryEntries=[{tryLoc:"root"}],forEach$1(e).call(e,$,this),this.reset(!0)}function I(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:R}}function R(){return{value:void 0,done:!0}}return _.prototype=h,n(v,"constructor",{value:h,configurable:!0}),n(h,"constructor",{value:_,configurable:!0}),_.displayName=c(h,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 setPrototypeOf$1?setPrototypeOf$1(e,h):(e.__proto__=h,c(e,s,"GeneratorFunction")),e.prototype=create$4(v),e},e.awrap=function(e){return{__await:e}},g(y.prototype),c(y.prototype,a,(function(){return this})),e.AsyncIterator=y,e.async=function(t,r,n,i,o){void 0===o&&(o=promise);var a=new y(l(t,r,n,i),o);return e.isGeneratorFunction(r)?a:a.next().then((function(e){return e.done?e.value:a.next()}))},g(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 reverse2(r).call(r),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,b.prototype={constructor:b,reset:function(e){var t;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,forEach$1(t=this.tryEntries).call(t,E),!e)for(var n in this)"t"===n.charAt(0)&&r.call(this,n)&&!isNaN(+slice$1(n).call(n,1))&&(this[n]=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),E(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;E(r)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,r){return this.delegate={iterator:I(e),resultName:t,nextLoc:r},"next"===this.method&&(this.arg=void 0),d}},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)}))}}var entryVirtual$i=entryVirtual$m,concat$8=entryVirtual$i("Array").concat,isPrototypeOf$j=objectIsPrototypeOf,method$g=concat$8,ArrayPrototype$c=Array.prototype,concat$7=function(e){var t=e.concat;return e===ArrayPrototype$c||isPrototypeOf$j(ArrayPrototype$c,e)&&t===ArrayPrototype$c.concat?method$g:t},parent$20=concat$7,concat$6=parent$20,parent$1$=concat$6,concat$5=parent$1$,parent$1_=concat$5,concat$4=parent$1_,concat$3=concat$4,concat$2=concat$3,path$k=path$v,apply$2=functionApply;path$k.JSON||(path$k.JSON={stringify:JSON.stringify});var stringify$6=function(e,t,r){return apply$2(path$k.JSON.stringify,null,arguments)},parent$1Z=stringify$6,stringify$5=parent$1Z,parent$1Y=stringify$5,stringify$4=parent$1Y,parent$1X=stringify$4,stringify$3=parent$1X,stringify$2=stringify$3,stringify$1=stringify$2,$$1e=_export,$map=arrayIteration.map,arrayMethodHasSpeciesSupport$2=arrayMethodHasSpeciesSupport$5,HAS_SPECIES_SUPPORT$2=arrayMethodHasSpeciesSupport$2("map");$$1e({target:"Array",proto:!0,forced:!HAS_SPECIES_SUPPORT$2},{map:function(e){return $map(this,e,arguments.length>1?arguments[1]:void 0)}});var entryVirtual$h=entryVirtual$m,map$c=entryVirtual$h("Array").map,isPrototypeOf$i=objectIsPrototypeOf,method$f=map$c,ArrayPrototype$b=Array.prototype,map$b=function(e){var t=e.map;return e===ArrayPrototype$b||isPrototypeOf$i(ArrayPrototype$b,e)&&t===ArrayPrototype$b.map?method$f:t},parent$1W=map$b,map$a=parent$1W,parent$1V=map$a,map$9=parent$1V,parent$1U=map$9,map$8=parent$1U,map$7=map$8,map$6=map$7,whitespaces$4="\t\n\v\f\r                 \u2028\u2029\ufeff",uncurryThis$j=functionUncurryThis,requireObjectCoercible$5=requireObjectCoercible$9,toString$b=toString$h,whitespaces$3=whitespaces$4,replace$3=uncurryThis$j("".replace),whitespace="["+whitespaces$3+"]",ltrim=RegExp("^"+whitespace+whitespace+"*"),rtrim=RegExp(whitespace+whitespace+"*$"),createMethod$3=function(e){return function(t){var r=toString$b(requireObjectCoercible$5(t));return 1&e&&(r=replace$3(r,ltrim,"")),2&e&&(r=replace$3(r,rtrim,"")),r}},stringTrim={start:createMethod$3(1),end:createMethod$3(2),trim:createMethod$3(3)},global$7=global$s,fails$e=fails$z,uncurryThis$i=functionUncurryThis,toString$a=toString$h,trim$8=stringTrim.trim,whitespaces$2=whitespaces$4,$parseInt$1=global$7.parseInt,Symbol$4=global$7.Symbol,ITERATOR$3=Symbol$4&&Symbol$4.iterator,hex=/^[+-]?0x/i,exec$2=uncurryThis$i(hex.exec),FORCED$4=8!==$parseInt$1(whitespaces$2+"08")||22!==$parseInt$1(whitespaces$2+"0x16")||ITERATOR$3&&!fails$e((function(){$parseInt$1(Object(ITERATOR$3))})),numberParseInt=FORCED$4?function(e,t){var r=trim$8(toString$a(e));return $parseInt$1(r,t>>>0||(exec$2(hex,r)?16:10))}:$parseInt$1,$$1d=_export,$parseInt=numberParseInt;$$1d({global:!0,forced:parseInt!=numberParseInt},{parseInt:numberParseInt});var path$j=path$v,_parseInt$b=path$j.parseInt,parent$1T=_parseInt$b,_parseInt$a=parent$1T,parent$1S=_parseInt$a,_parseInt$9=parent$1S,parent$1R=_parseInt$9,_parseInt$8=parent$1R,_parseInt$7=_parseInt$8,_parseInt$6=_parseInt$7,internalMetadata={exports:{}},fails$d=fails$z,arrayBufferNonExtensible=fails$d((function(){if("function"==typeof ArrayBuffer){var e=new ArrayBuffer(8);Object.isExtensible(e)&&Object.defineProperty(e,"a",{value:8})}})),fails$c=fails$z,isObject$c=isObject$q,classof$4=classofRaw$2,ARRAY_BUFFER_NON_EXTENSIBLE=arrayBufferNonExtensible,$isExtensible=Object.isExtensible,FAILS_ON_PRIMITIVES$2=fails$c((function(){$isExtensible(1)})),objectIsExtensible=FAILS_ON_PRIMITIVES$2||ARRAY_BUFFER_NON_EXTENSIBLE?function(e){return!!isObject$c(e)&&((!ARRAY_BUFFER_NON_EXTENSIBLE||"ArrayBuffer"!=classof$4(e))&&(!$isExtensible||$isExtensible(e)))}:$isExtensible,fails$b=fails$z,freezing=!fails$b((function(){return Object.isExtensible(Object.preventExtensions({}))})),$$1c=_export,uncurryThis$h=functionUncurryThis,hiddenKeys=hiddenKeys$6,isObject$b=isObject$q,hasOwn$8=hasOwnProperty_1,defineProperty$6=objectDefineProperty.f,getOwnPropertyNamesModule=objectGetOwnPropertyNames,getOwnPropertyNamesExternalModule=objectGetOwnPropertyNamesExternal,isExtensible$1=objectIsExtensible,uid=uid$4,FREEZING=freezing,REQUIRED=!1,METADATA=uid("meta"),id$1=0,setMetadata=function(e){defineProperty$6(e,METADATA,{value:{objectID:"O"+id$1++,weakData:{}}})},fastKey$1=function(e,t){if(!isObject$b(e))return"symbol"==typeof e?e:("string"==typeof e?"S":"P")+e;if(!hasOwn$8(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$8(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$8(e,METADATA)&&setMetadata(e),e},enable=function(){meta.enable=function(){},REQUIRED=!0;var e=getOwnPropertyNamesModule.f,t=uncurryThis$h([].splice),r={};r[METADATA]=1,e(r).length&&(getOwnPropertyNamesModule.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},$$1c({target:"Object",stat:!0,forced:!0},{getOwnPropertyNames:getOwnPropertyNamesExternalModule.f}))},meta=internalMetadata.exports={enable:enable,fastKey:fastKey$1,getWeakData:getWeakData$1,onFreeze:onFreeze};hiddenKeys[METADATA]=!0;var $$1b=_export,global$6=global$s,InternalMetadataModule$1=internalMetadata.exports,fails$a=fails$z,createNonEnumerableProperty=createNonEnumerableProperty$8,iterate$u=iterate$A,anInstance$4=anInstance$6,isCallable$3=isCallable$n,isObject$a=isObject$q,setToStringTag$2=setToStringTag$9,defineProperty$5=objectDefineProperty.f,forEach2=arrayIteration.forEach,DESCRIPTORS$9=descriptors,InternalStateModule$4=internalState,setInternalState$4=InternalStateModule$4.set,internalStateGetterFor$2=InternalStateModule$4.getterFor,collection$3=function(e,t,r){var n,i=-1!==e.indexOf("Map"),o=-1!==e.indexOf("Weak"),a=i?"set":"add",s=global$6[e],c=s&&s.prototype,l={};if(DESCRIPTORS$9&&isCallable$3(s)&&(o||c.forEach&&!fails$a((function(){(new s).entries().next()})))){var u=(n=t((function(t,r){setInternalState$4(anInstance$4(t,u),{type:e,collection:new s}),null!=r&&iterate$u(r,t[a],{that:t,AS_ENTRIES:i})}))).prototype,d=internalStateGetterFor$2(e);forEach2(["add","clear","delete","forEach","get","has","set","keys","values","entries"],(function(e){var t="add"==e||"set"==e;!(e in c)||o&&"clear"==e||createNonEnumerableProperty(u,e,(function(r,n){var i=d(this).collection;if(!t&&o&&!isObject$a(r))return"get"==e&&void 0;var a=i[e](0===r?0:r,n);return t?this:a}))})),o||defineProperty$5(u,"size",{configurable:!0,get:function(){return d(this).collection.size}})}else n=r.getConstructor(t,e,i,a),InternalMetadataModule$1.enable();return setToStringTag$2(n,e,!1,!0),l[e]=n,$$1b({global:!0,forced:!0},l),o||r.setStrong(n,e,i),n},defineBuiltIn$2=defineBuiltIn$8,defineBuiltIns$4=function(e,t,r){for(var n in t)r&&r.unsafe&&e[n]?e[n]=t[n]:defineBuiltIn$2(e,n,t[n],r);return e},defineProperty$4=objectDefineProperty.f,create$2=objectCreate$1,defineBuiltIns$3=defineBuiltIns$4,bind$p=functionBindContext,anInstance$3=anInstance$6,isNullOrUndefined$2=isNullOrUndefined$7,iterate$t=iterate$A,defineIterator=iteratorDefine,createIterResultObject=createIterResultObject$3,setSpecies=setSpecies$2,DESCRIPTORS$8=descriptors,fastKey=internalMetadata.exports.fastKey,InternalStateModule$3=internalState,setInternalState$3=InternalStateModule$3.set,internalStateGetterFor$1=InternalStateModule$3.getterFor,collectionStrong$2={getConstructor:function(e,t,r,n){var i=e((function(e,i){anInstance$3(e,o),setInternalState$3(e,{type:t,index:create$2(null),first:void 0,last:void 0,size:0}),DESCRIPTORS$8||(e.size=0),isNullOrUndefined$2(i)||iterate$t(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$8?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$3(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$8?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$8?r.size--:t.size--}return!!n},forEach:function(e){for(var t,r=a(this),n=bind$p(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$3(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$8&&defineProperty$4(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(e,t,(function(e,t){setInternalState$3(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("keys"==t?r.key:"values"==t?r.value:[r.key,r.value],!1):(e.target=void 0,createIterResultObject(void 0,!0))}),r?"entries":"values",!r,!0),setSpecies(t)}},collection$2=collection$3,collectionStrong$1=collectionStrong$2;collection$2("Map",(function(e){return function(){return e(this,arguments.length?arguments[0]:void 0)}}),collectionStrong$1);var path$i=path$v,map$5=path$i.Map,parent$1Q=map$5,map$4=parent$1Q,parent$1P=map$4,map$3=parent$1P,bind$o=functionBindContext,call$o=functionCall,aCallable$p=aCallable$z,aConstructor$1=aConstructor$3,isNullOrUndefined$1=isNullOrUndefined$7,iterate$s=iterate$A,push$8=[].push,collectionFrom=function(e){var t,r,n,i,o=arguments.length,a=o>1?arguments[1]:void 0;return aConstructor$1(this),(t=void 0!==a)&&aCallable$p(a),isNullOrUndefined$1(e)?new this:(r=[],t?(n=0,i=bind$o(a,o>2?arguments[2]:void 0),iterate$s(e,(function(e){call$o(push$8,r,i(e,n++))}))):iterate$s(e,push$8,{that:r}),new this(r))},$$1a=_export,from$9=collectionFrom;$$1a({target:"Map",stat:!0,forced:!0},{from:from$9});var arraySlice$3=arraySlice$6,collectionOf=function(){return new this(arraySlice$3(arguments))},$$19=_export,of$2=collectionOf;$$19({target:"Map",stat:!0,forced:!0},{of:of$2});var call$n=functionCall,aCallable$o=aCallable$z,anObject$A=anObject$M,collectionDeleteAll=function(){for(var e,t=anObject$A(this),r=aCallable$o(t.delete),n=!0,i=0,o=arguments.length;i<o;i++)e=call$n(r,t,arguments[i]),n=n&&e;return!!n},$$18=_export,deleteAll$2=collectionDeleteAll;$$18({target:"Map",proto:!0,real:!0,forced:!0},{deleteAll:deleteAll$2});var call$m=functionCall,aCallable$n=aCallable$z,anObject$z=anObject$M,mapEmplace=function(e,t){var r,n,i=anObject$z(this),o=aCallable$n(i.get),a=aCallable$n(i.has),s=aCallable$n(i.set);return call$m(a,i,e)?(r=call$m(o,i,e),"update"in t&&(r=t.update(r,e,i),call$m(s,i,e,r)),r):(n=t.insert(e,i),call$m(s,i,e,n),n)},$$17=_export,emplace$1=mapEmplace;$$17({target:"Map",proto:!0,real:!0,forced:!0},{emplace:emplace$1});var getIterator$5=getIterator$7,getMapIterator$a=getIterator$5,$$16=_export,anObject$y=anObject$M,bind$n=functionBindContext,getMapIterator$9=getMapIterator$a,iterate$r=iterate$A;$$16({target:"Map",proto:!0,real:!0,forced:!0},{every:function(e){var t=anObject$y(this),r=getMapIterator$9(t),n=bind$n(e,arguments.length>1?arguments[1]:void 0);return!iterate$r(r,(function(e,r,i){if(!n(r,e,t))return i()}),{AS_ENTRIES:!0,IS_ITERATOR:!0,INTERRUPTED:!0}).stopped}});var $$15=_export,getBuiltIn$a=getBuiltIn$o,bind$m=functionBindContext,call$l=functionCall,aCallable$m=aCallable$z,anObject$x=anObject$M,speciesConstructor$8=speciesConstructor$b,getMapIterator$8=getMapIterator$a,iterate$q=iterate$A;$$15({target:"Map",proto:!0,real:!0,forced:!0},{filter:function(e){var t=anObject$x(this),r=getMapIterator$8(t),n=bind$m(e,arguments.length>1?arguments[1]:void 0),i=new(speciesConstructor$8(t,getBuiltIn$a("Map"))),o=aCallable$m(i.set);return iterate$q(r,(function(e,r){n(r,e,t)&&call$l(o,i,e,r)}),{AS_ENTRIES:!0,IS_ITERATOR:!0}),i}});var $$14=_export,anObject$w=anObject$M,bind$l=functionBindContext,getMapIterator$7=getMapIterator$a,iterate$p=iterate$A;$$14({target:"Map",proto:!0,real:!0,forced:!0},{find:function(e){var t=anObject$w(this),r=getMapIterator$7(t),n=bind$l(e,arguments.length>1?arguments[1]:void 0);return iterate$p(r,(function(e,r,i){if(n(r,e,t))return i(r)}),{AS_ENTRIES:!0,IS_ITERATOR:!0,INTERRUPTED:!0}).result}});var $$13=_export,anObject$v=anObject$M,bind$k=functionBindContext,getMapIterator$6=getMapIterator$a,iterate$o=iterate$A;$$13({target:"Map",proto:!0,real:!0,forced:!0},{findKey:function(e){var t=anObject$v(this),r=getMapIterator$6(t),n=bind$k(e,arguments.length>1?arguments[1]:void 0);return iterate$o(r,(function(e,r,i){if(n(r,e,t))return i(e)}),{AS_ENTRIES:!0,IS_ITERATOR:!0,INTERRUPTED:!0}).result}});var $$12=_export,call$k=functionCall,uncurryThis$g=functionUncurryThis,aCallable$l=aCallable$z,getIterator$4=getIterator$7,iterate$n=iterate$A,push$7=uncurryThis$g([].push);$$12({target:"Map",stat:!0,forced:!0},{groupBy:function(e,t){aCallable$l(t);var r=getIterator$4(e),n=new this,i=aCallable$l(n.has),o=aCallable$l(n.get),a=aCallable$l(n.set);return iterate$n(r,(function(e){var r=t(e);call$k(i,n,r)?push$7(call$k(o,n,r),e):call$k(a,n,r,[e])}),{IS_ITERATOR:!0}),n}});var sameValueZero$1=function(e,t){return e===t||e!=e&&t!=t},$$11=_export,anObject$u=anObject$M,getMapIterator$5=getMapIterator$a,sameValueZero=sameValueZero$1,iterate$m=iterate$A;$$11({target:"Map",proto:!0,real:!0,forced:!0},{includes:function(e){return iterate$m(getMapIterator$5(anObject$u(this)),(function(t,r,n){if(sameValueZero(r,e))return n()}),{AS_ENTRIES:!0,IS_ITERATOR:!0,INTERRUPTED:!0}).stopped}});var $$10=_export,call$j=functionCall,iterate$l=iterate$A,aCallable$k=aCallable$z;$$10({target:"Map",stat:!0,forced:!0},{keyBy:function(e,t){var r=new this;aCallable$k(t);var n=aCallable$k(r.set);return iterate$l(e,(function(e){call$j(n,r,t(e),e)})),r}});var $$$=_export,anObject$t=anObject$M,getMapIterator$4=getMapIterator$a,iterate$k=iterate$A;$$$({target:"Map",proto:!0,real:!0,forced:!0},{keyOf:function(e){return iterate$k(getMapIterator$4(anObject$t(this)),(function(t,r,n){if(r===e)return n(t)}),{AS_ENTRIES:!0,IS_ITERATOR:!0,INTERRUPTED:!0}).result}});var $$_=_export,getBuiltIn$9=getBuiltIn$o,bind$j=functionBindContext,call$i=functionCall,aCallable$j=aCallable$z,anObject$s=anObject$M,speciesConstructor$7=speciesConstructor$b,getMapIterator$3=getMapIterator$a,iterate$j=iterate$A;$$_({target:"Map",proto:!0,real:!0,forced:!0},{mapKeys:function(e){var t=anObject$s(this),r=getMapIterator$3(t),n=bind$j(e,arguments.length>1?arguments[1]:void 0),i=new(speciesConstructor$7(t,getBuiltIn$9("Map"))),o=aCallable$j(i.set);return iterate$j(r,(function(e,r){call$i(o,i,n(r,e,t),r)}),{AS_ENTRIES:!0,IS_ITERATOR:!0}),i}});var $$Z=_export,getBuiltIn$8=getBuiltIn$o,bind$i=functionBindContext,call$h=functionCall,aCallable$i=aCallable$z,anObject$r=anObject$M,speciesConstructor$6=speciesConstructor$b,getMapIterator$2=getMapIterator$a,iterate$i=iterate$A;$$Z({target:"Map",proto:!0,real:!0,forced:!0},{mapValues:function(e){var t=anObject$r(this),r=getMapIterator$2(t),n=bind$i(e,arguments.length>1?arguments[1]:void 0),i=new(speciesConstructor$6(t,getBuiltIn$8("Map"))),o=aCallable$i(i.set);return iterate$i(r,(function(e,r){call$h(o,i,e,n(r,e,t))}),{AS_ENTRIES:!0,IS_ITERATOR:!0}),i}});var $$Y=_export,aCallable$h=aCallable$z,anObject$q=anObject$M,iterate$h=iterate$A;$$Y({target:"Map",proto:!0,real:!0,arity:1,forced:!0},{merge:function(e){for(var t=anObject$q(this),r=aCallable$h(t.set),n=arguments.length,i=0;i<n;)iterate$h(arguments[i++],r,{that:t,AS_ENTRIES:!0});return t}});var $$X=_export,anObject$p=anObject$M,aCallable$g=aCallable$z,getMapIterator$1=getMapIterator$a,iterate$g=iterate$A,$TypeError$7=TypeError;$$X({target:"Map",proto:!0,real:!0,forced:!0},{reduce:function(e){var t=anObject$p(this),r=getMapIterator$1(t),n=arguments.length<2,i=n?void 0:arguments[1];if(aCallable$g(e),iterate$g(r,(function(r,o){n?(n=!1,i=o):i=e(i,o,r,t)}),{AS_ENTRIES:!0,IS_ITERATOR:!0}),n)throw $TypeError$7("Reduce of empty map with no initial value");return i}});var $$W=_export,anObject$o=anObject$M,bind$h=functionBindContext,getMapIterator=getMapIterator$a,iterate$f=iterate$A;$$W({target:"Map",proto:!0,real:!0,forced:!0},{some:function(e){var t=anObject$o(this),r=getMapIterator(t),n=bind$h(e,arguments.length>1?arguments[1]:void 0);return iterate$f(r,(function(e,r,i){if(n(r,e,t))return i()}),{AS_ENTRIES:!0,IS_ITERATOR:!0,INTERRUPTED:!0}).stopped}});var $$V=_export,call$g=functionCall,anObject$n=anObject$M,aCallable$f=aCallable$z,$TypeError$6=TypeError;$$V({target:"Map",proto:!0,real:!0,forced:!0},{update:function(e,t){var r=anObject$n(this),n=aCallable$f(r.get),i=aCallable$f(r.has),o=aCallable$f(r.set),a=arguments.length;aCallable$f(t);var s=call$g(i,r,e);if(!s&&a<3)throw $TypeError$6("Updating absent value");var c=s?call$g(n,r,e):aCallable$f(a>2?arguments[2]:void 0)(e,r);return call$g(o,r,e,t(c,e,r)),r}});var call$f=functionCall,aCallable$e=aCallable$z,isCallable$2=isCallable$n,anObject$m=anObject$M,$TypeError$5=TypeError,mapUpsert=function(e,t){var r,n=anObject$m(this),i=aCallable$e(n.get),o=aCallable$e(n.has),a=aCallable$e(n.set),s=arguments.length>2?arguments[2]:void 0;if(!isCallable$2(t)&&!isCallable$2(s))throw $TypeError$5("At least one callback required");return call$f(o,n,e)?(r=call$f(i,n,e),isCallable$2(t)&&(r=t(r),call$f(a,n,e,r))):isCallable$2(s)&&(r=s(),call$f(a,n,e,r)),r},$$U=_export,upsert$2=mapUpsert;$$U({target:"Map",proto:!0,real:!0,forced:!0},{upsert:upsert$2});var $$T=_export,upsert$1=mapUpsert;$$T({target:"Map",proto:!0,real:!0,name:"upsert",forced:!0},{updateOrInsert:upsert$1});var parent$1O=map$3,map$2=parent$1O,map$1=map$2,map2=map$1,$$S=_export,toObject$6=toObject$d,nativeKeys$2=objectKeys$4,fails$9=fails$z,FAILS_ON_PRIMITIVES$1=fails$9((function(){nativeKeys$2(1)}));$$S({target:"Object",stat:!0,forced:FAILS_ON_PRIMITIVES$1},{keys:function(e){return nativeKeys$2(toObject$6(e))}});var path$h=path$v,keys$d=path$h.Object.keys,parent$1N=keys$d,keys$c=parent$1N,parent$1M=keys$c,keys$b=parent$1M,parent$1L=keys$b,keys$a=parent$1L,keys$9=keys$a,keys$8=keys$9,aCallable$d=aCallable$z,toObject$5=toObject$d,IndexedObject$1=indexedObject,lengthOfArrayLike$4=lengthOfArrayLike$b,$TypeError$4=TypeError,createMethod$2=function(e){return function(t,r,n,i){aCallable$d(r);var o=toObject$5(t),a=IndexedObject$1(o),s=lengthOfArrayLike$4(o),c=e?s-1:0,l=e?-1:1;if(n<2)for(;;){if(c in a){i=a[c],c+=l;break}if(c+=l,e?c<0:s<=c)throw $TypeError$4("Reduce of empty array with no initial value")}for(;e?c>=0:s>c;c+=l)c in a&&(i=r(i,a[c],c,o));return i}},arrayReduce={left:createMethod$2(!1),right:createMethod$2(!0)},$$R=_export,$reduce=arrayReduce.left,arrayMethodIsStrict$2=arrayMethodIsStrict$4,CHROME_VERSION=engineV8Version,IS_NODE=engineIsNode,STRICT_METHOD$2=arrayMethodIsStrict$2("reduce"),CHROME_BUG=!IS_NODE&&CHROME_VERSION>79&&CHROME_VERSION<83;$$R({target:"Array",proto:!0,forced:!STRICT_METHOD$2||CHROME_BUG},{reduce:function(e){var t=arguments.length;return $reduce(this,e,t,t>1?arguments[1]:void 0)}});var entryVirtual$g=entryVirtual$m,reduce$6=entryVirtual$g("Array").reduce,isPrototypeOf$h=objectIsPrototypeOf,method$e=reduce$6,ArrayPrototype$a=Array.prototype,reduce$5=function(e){var t=e.reduce;return e===ArrayPrototype$a||isPrototypeOf$h(ArrayPrototype$a,e)&&t===ArrayPrototype$a.reduce?method$e:t},parent$1K=reduce$5,reduce$4=parent$1K,parent$1J=reduce$4,reduce$3=parent$1J,parent$1I=reduce$3,reduce$2=parent$1I,reduce$1=reduce$2,reduce3=reduce$1,DESCRIPTORS$7=descriptors,uncurryThis$f=functionUncurryThis,call$e=functionCall,fails$8=fails$z,objectKeys$1=objectKeys$4,getOwnPropertySymbolsModule=objectGetOwnPropertySymbols,propertyIsEnumerableModule=objectPropertyIsEnumerable,toObject$4=toObject$d,IndexedObject=indexedObject,$assign=Object.assign,defineProperty$3=Object.defineProperty,concat$1=uncurryThis$f([].concat),objectAssign=!$assign||fails$8((function(){if(DESCRIPTORS$7&&1!==$assign({b:1},$assign(defineProperty$3({},"a",{enumerable:!0,get:function(){defineProperty$3(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$1($assign({},t)).join("")!=n}))?function(e,t){for(var r=toObject$4(e),n=arguments.length,i=1,o=getOwnPropertySymbolsModule.f,a=propertyIsEnumerableModule.f;n>i;)for(var s,c=IndexedObject(arguments[i++]),l=o?concat$1(objectKeys$1(c),o(c)):objectKeys$1(c),u=l.length,d=0;u>d;)s=l[d++],DESCRIPTORS$7&&!call$e(a,c,s)||(r[s]=c[s]);return r}:$assign,$$Q=_export,assign$8=objectAssign;$$Q({target:"Object",stat:!0,arity:2,forced:Object.assign!==assign$8},{assign:assign$8});var path$g=path$v,assign$7=path$g.Object.assign,parent$1H=assign$7,assign$6=parent$1H,parent$1G=assign$6,assign$5=parent$1G,parent$1F=assign$5,assign$4=parent$1F,assign$3=assign$4,assign$2=assign$3,isObject$9=isObject$q,classof$3=classofRaw$2,wellKnownSymbol$3=wellKnownSymbol$p,MATCH$2=wellKnownSymbol$3("match"),isRegexp=function(e){var t;return isObject$9(e)&&(void 0!==(t=e[MATCH$2])?!!t:"RegExp"==classof$3(e))},isRegExp=isRegexp,$TypeError$3=TypeError,notARegexp=function(e){if(isRegExp(e))throw $TypeError$3("The method doesn't accept regular expressions");return e},wellKnownSymbol$2=wellKnownSymbol$p,MATCH$1=wellKnownSymbol$2("match"),correctIsRegexpLogic=function(e){var t=/./;try{"/./"[e](t)}catch(r){try{return t[MATCH$1]=!1,"/./"[e](t)}catch(e){}}return!1},$$P=_export,uncurryThis$e=functionUncurryThis;objectGetOwnPropertyDescriptor.f;var toLength$2=toLength$4,toString$9=toString$h,notARegExp$2=notARegexp,requireObjectCoercible$4=requireObjectCoercible$9,correctIsRegExpLogic$2=correctIsRegexpLogic,nativeEndsWith=uncurryThis$e("".endsWith),slice2=uncurryThis$e("".slice),min$2=Math.min,CORRECT_IS_REGEXP_LOGIC$1=correctIsRegExpLogic$2("endsWith");$$P({target:"String",proto:!0,forced:!CORRECT_IS_REGEXP_LOGIC$1},{endsWith:function(e){var t=toString$9(requireObjectCoercible$4(this));notARegExp$2(e);var r=arguments.length>1?arguments[1]:void 0,n=t.length,i=void 0===r?n:min$2(toLength$2(r),n),o=toString$9(e);return nativeEndsWith?nativeEndsWith(t,o,i):slice2(t,i-o.length,i)===o}});var entryVirtual$f=entryVirtual$m,endsWith$6=entryVirtual$f("String").endsWith,isPrototypeOf$g=objectIsPrototypeOf,method$d=endsWith$6,StringPrototype$4=String.prototype,endsWith$5=function(e){var t=e.endsWith;return"string"==typeof e||e===StringPrototype$4||isPrototypeOf$g(StringPrototype$4,e)&&t===StringPrototype$4.endsWith?method$d:t},parent$1E=endsWith$5,endsWith$4=parent$1E,parent$1D=endsWith$4,endsWith$3=parent$1D,parent$1C=endsWith$3,endsWith$2=parent$1C,endsWith$1=endsWith$2,endsWith2=endsWith$1,logDisabled_=!0,deprecationWarnings_=!0;function extractVersion(e,t,r){var n=e.match(t);return n&&n.length>=r&&_parseInt$6(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 map2),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===keys$8(this._eventMap).length&&delete this._eventMap,o.apply(this,[e,n])},defineProperty$a(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$1(){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$8(e){return"[object Object]"===Object.prototype.toString.call(e)}function compactObject(e){var t;return isObject$8(e)?reduce3(t=keys$8(e)).call(t,(function(t,r){var n=isObject$8(e[r]),i=n?compactObject(e[r]):e[r],o=n&&!keys$8(i).length;return void 0===i||o?t:assign$2(t,_defineProperty({},r,i))}),{}):e}function walkStats(e,t,r){t&&!r.has(t.id)&&(r.set(t.id,t),keys$8(t).forEach((function(n){endsWith2(n).call(n,"Id")?walkStats(e,e.get(t[n]),r):endsWith2(n).call(n,"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 map2;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 $$O=_export,$find=arrayIteration.find,FIND="find",SKIPS_HOLES$1=!0;FIND in[]&&Array(1)[FIND]((function(){SKIPS_HOLES$1=!1})),$$O({target:"Array",proto:!0,forced:SKIPS_HOLES$1},{find:function(e){return $find(this,e,arguments.length>1?arguments[1]:void 0)}});var entryVirtual$e=entryVirtual$m,find$8=entryVirtual$e("Array").find,isPrototypeOf$f=objectIsPrototypeOf,method$c=find$8,ArrayPrototype$9=Array.prototype,find$7=function(e){var t=e.find;return e===ArrayPrototype$9||isPrototypeOf$f(ArrayPrototype$9,e)&&t===ArrayPrototype$9.find?method$c:t},parent$1B=find$7,find$6=parent$1B,parent$1A=find$6,find$5=parent$1A,parent$1z=find$5,find$4=parent$1z,find$3=find$4,find$2=find$3,$$N=_export,uncurryThis$d=functionUncurryThis,$indexOf=arrayIncludes.indexOf,arrayMethodIsStrict$1=arrayMethodIsStrict$4,nativeIndexOf=uncurryThis$d([].indexOf),NEGATIVE_ZERO=!!nativeIndexOf&&1/nativeIndexOf([1],1,-0)<0,STRICT_METHOD$1=arrayMethodIsStrict$1("indexOf");$$N({target:"Array",proto:!0,forced:NEGATIVE_ZERO||!STRICT_METHOD$1},{indexOf:function(e){var t=arguments.length>1?arguments[1]:void 0;return NEGATIVE_ZERO?nativeIndexOf(this,e,t)||0:$indexOf(this,e,t)}});var entryVirtual$d=entryVirtual$m,indexOf$6=entryVirtual$d("Array").indexOf,isPrototypeOf$e=objectIsPrototypeOf,method$b=indexOf$6,ArrayPrototype$8=Array.prototype,indexOf$5=function(e){var t=e.indexOf;return e===ArrayPrototype$8||isPrototypeOf$e(ArrayPrototype$8,e)&&t===ArrayPrototype$8.indexOf?method$b:t},parent$1y=indexOf$5,indexOf$4=parent$1y,parent$1x=indexOf$4,indexOf$3=parent$1x,parent$1w=indexOf$3,indexOf$2=parent$1w,indexOf$1=indexOf$2,indexOf2=indexOf$1,DESCRIPTORS$6=descriptors,isArray$9=isArray$f,$TypeError$2=TypeError,getOwnPropertyDescriptor$8=Object.getOwnPropertyDescriptor,SILENT_ON_NON_WRITABLE_LENGTH_SET=DESCRIPTORS$6&&!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$9(e)&&!getOwnPropertyDescriptor$8(e,"length").writable)throw $TypeError$2("Cannot set read only .length");return e.length=t}:function(e,t){return e.length=t},tryToString=tryToString$6,$TypeError$1=TypeError,deletePropertyOrThrow$2=function(e,t){if(!delete e[t])throw $TypeError$1("Cannot delete property "+tryToString(t)+" of "+tryToString(e))},$$M=_export,toObject$3=toObject$d,toAbsoluteIndex$1=toAbsoluteIndex$5,toIntegerOrInfinity$1=toIntegerOrInfinity$5,lengthOfArrayLike$3=lengthOfArrayLike$b,setArrayLength=arraySetLength,doesNotExceedSafeInteger=doesNotExceedSafeInteger$2,arraySpeciesCreate=arraySpeciesCreate$3,createProperty$2=createProperty$6,deletePropertyOrThrow$1=deletePropertyOrThrow$2,arrayMethodHasSpeciesSupport$1=arrayMethodHasSpeciesSupport$5,HAS_SPECIES_SUPPORT$1=arrayMethodHasSpeciesSupport$1("splice"),max=Math.max,min$1=Math.min;$$M({target:"Array",proto:!0,forced:!HAS_SPECIES_SUPPORT$1},{splice:function(e,t){var r,n,i,o,a,s,c=toObject$3(this),l=lengthOfArrayLike$3(c),u=toAbsoluteIndex$1(e,l),d=arguments.length;for(0===d?r=n=0:1===d?(r=0,n=l-u):(r=d-2,n=min$1(max(toIntegerOrInfinity$1(t),0),l-u)),doesNotExceedSafeInteger(l+r-n),i=arraySpeciesCreate(c,n),o=0;o<n;o++)(a=u+o)in c&&createProperty$2(i,o,c[a]);if(i.length=n,r<n){for(o=u;o<l-n;o++)s=o+r,(a=o+n)in c?c[s]=c[a]:deletePropertyOrThrow$1(c,s);for(o=l;o>l-n+r;o--)deletePropertyOrThrow$1(c,o-1)}else if(r>n)for(o=l-n;o>u;o--)s=o+r-1,(a=o+n-1)in c?c[s]=c[a]:deletePropertyOrThrow$1(c,s);for(o=0;o<r;o++)c[o+u]=arguments[o+2];return setArrayLength(c,l-n+r),i}});var entryVirtual$c=entryVirtual$m,splice$9=entryVirtual$c("Array").splice,isPrototypeOf$d=objectIsPrototypeOf,method$a=splice$9,ArrayPrototype$7=Array.prototype,splice$8=function(e){var t=e.splice;return e===ArrayPrototype$7||isPrototypeOf$d(ArrayPrototype$7,e)&&t===ArrayPrototype$7.splice?method$a:t},parent$1v=splice$8,splice$7=parent$1v,parent$1u=splice$7,splice$6=parent$1u,parent$1t=splice$6,splice$5=parent$1t,splice$4=splice$5,splice$3=splice$4,$$L=_export,$filter=arrayIteration.filter,arrayMethodHasSpeciesSupport=arrayMethodHasSpeciesSupport$5,HAS_SPECIES_SUPPORT=arrayMethodHasSpeciesSupport("filter");$$L({target:"Array",proto:!0,forced:!HAS_SPECIES_SUPPORT},{filter:function(e){return $filter(this,e,arguments.length>1?arguments[1]:void 0)}});var entryVirtual$b=entryVirtual$m,filter$6=entryVirtual$b("Array").filter,isPrototypeOf$c=objectIsPrototypeOf,method$9=filter$6,ArrayPrototype$6=Array.prototype,filter$5=function(e){var t=e.filter;return e===ArrayPrototype$6||isPrototypeOf$c(ArrayPrototype$6,e)&&t===ArrayPrototype$6.filter?method$9:t},parent$1s=filter$5,filter$4=parent$1s,parent$1r=filter$4,filter$3=parent$1r,parent$1q=filter$3,filter$2=parent$1q,filter$1=filter$2,filter3=filter$1,getOwnPropertyDescriptor$7={exports:{}},$$K=_export,fails$7=fails$z,toIndexedObject$2=toIndexedObject$b,nativeGetOwnPropertyDescriptor=objectGetOwnPropertyDescriptor.f,DESCRIPTORS$5=descriptors,FAILS_ON_PRIMITIVES=fails$7((function(){nativeGetOwnPropertyDescriptor(1)})),FORCED$3=!DESCRIPTORS$5||FAILS_ON_PRIMITIVES;$$K({target:"Object",stat:!0,forced:FORCED$3,sham:!DESCRIPTORS$5},{getOwnPropertyDescriptor:function(e,t){return nativeGetOwnPropertyDescriptor(toIndexedObject$2(e),t)}});var path$f=path$v,Object$2=path$f.Object,getOwnPropertyDescriptor$6=getOwnPropertyDescriptor$7.exports=function(e,t){return Object$2.getOwnPropertyDescriptor(e,t)};Object$2.getOwnPropertyDescriptor.sham&&(getOwnPropertyDescriptor$6.sham=!0);var parent$1p=getOwnPropertyDescriptor$7.exports,getOwnPropertyDescriptor$5=parent$1p,parent$1o=getOwnPropertyDescriptor$5,getOwnPropertyDescriptor$4=parent$1o,parent$1n=getOwnPropertyDescriptor$4,getOwnPropertyDescriptor$3=parent$1n,getOwnPropertyDescriptor$2=getOwnPropertyDescriptor$3,getOwnPropertyDescriptor$1=getOwnPropertyDescriptor$2,$$J=_export,$includes=arrayIncludes.includes,fails$6=fails$z,BROKEN_ON_SPARSE=fails$6((function(){return!Array(1).includes()}));$$J({target:"Array",proto:!0,forced:BROKEN_ON_SPARSE},{includes:function(e){return $includes(this,e,arguments.length>1?arguments[1]:void 0)}});var entryVirtual$a=entryVirtual$m,includes$7=entryVirtual$a("Array").includes,$$I=_export,uncurryThis$c=functionUncurryThis,notARegExp$1=notARegexp,requireObjectCoercible$3=requireObjectCoercible$9,toString$8=toString$h,correctIsRegExpLogic$1=correctIsRegexpLogic,stringIndexOf=uncurryThis$c("".indexOf);$$I({target:"String",proto:!0,forced:!correctIsRegExpLogic$1("includes")},{includes:function(e){return!!~stringIndexOf(toString$8(requireObjectCoercible$3(this)),toString$8(notARegExp$1(e)),arguments.length>1?arguments[1]:void 0)}});var entryVirtual$9=entryVirtual$m,includes$6=entryVirtual$9("String").includes,isPrototypeOf$b=objectIsPrototypeOf,arrayMethod=includes$7,stringMethod=includes$6,ArrayPrototype$5=Array.prototype,StringPrototype$3=String.prototype,includes$5=function(e){var t=e.includes;return e===ArrayPrototype$5||isPrototypeOf$b(ArrayPrototype$5,e)&&t===ArrayPrototype$5.includes?arrayMethod:"string"==typeof e||e===StringPrototype$3||isPrototypeOf$b(StringPrototype$3,e)&&t===StringPrototype$3.includes?stringMethod:t},parent$1m=includes$5,includes$4=parent$1m,parent$1l=includes$4,includes$3=parent$1l,parent$1k=includes$3,includes$2=parent$1k,includes$1=includes$2,includes4=includes$1,logging=log$1;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,r={};(keys$8(e).forEach((function(t){if("require"!==t&&"advanced"!==t&&"mediaSource"!==t){var n="object"===_typeof(e[t])?e[t]:{ideal:e[t]};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()+slice$1(t).call(t,1):"deviceId"===t?"sourceId":t};if(void 0!==n.ideal){r.optional=r.optional||[];var o={};"number"==typeof n.ideal?(o[i("min",t)]=n.ideal,r.optional.push(o),(o={})[i("max",t)]=n.ideal,r.optional.push(o)):(o[i("",t)]=n.ideal,r.optional.push(o))}void 0!==n.exact&&"number"!=typeof n.exact?(r.mandatory=r.mandatory||{},r.mandatory[i("",t)]=n.exact):["min","max"].forEach((function(e){void 0!==n[e]&&(r.mandatory=r.mandatory||{},r.mandatory[i(e,t)]=n[e])}))}})),e.advanced)&&(r.optional=concat$2(t=r.optional||[]).call(t,e.advanced));return r},i=function(e,i){if(t.version>=61)return i(e);if((e=JSON.parse(stringify$1(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(stringify$1(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){t=filter3(t).call(t,(function(e){return"videoinput"===e.kind}));var r=find$2(t).call(t,(function(e){return s.some((function(t){var r;return includes4(r=e.label.toLowerCase()).call(r,t)}))}));return!r&&t.length&&includes4(s).call(s,"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: "+stringify$1(e)),i(e)}));e.video=n(e.video)}return logging("chrome: "+stringify$1(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)){defineProperty$a(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,o;e.RTCPeerConnection.prototype.getReceivers?i=find$2(o=r.getReceivers()).call(o,(function(e){return e.track&&e.track.id===n.track.id})):i={track:n.track};var a=new Event("track");a.track=n.track,a.receiver=i,a.transceiver={receiver:i},a.streams=[t.stream],r.dispatchEvent(a)})),t.stream.getTracks().forEach((function(n){var i,o;e.RTCPeerConnection.prototype.getReceivers?i=find$2(o=r.getReceivers()).call(o,(function(e){return e.track&&e.track.id===n.id})):i={track:n};var a=new Event("track");a.track=n,a.receiver=i,a.transceiver={receiver:i},a.streams=[t.stream],r.dispatchEvent(a)}))},this.addEventListener("addstream",this._ontrackpoly)),t.apply(this,arguments)}}else wrapPeerConnectionEvent(e,"track",(function(e){return e.transceiver||defineProperty$a(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(){var e;return this._senders=this._senders||[],slice$1(e=this._senders).call(e)};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){var t;n.apply(this,arguments);var r,i=indexOf2(t=this._senders).call(t,e);-1!==i&&splice$3(r=this._senders).call(r,i,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,n,i,o=find$2(r=t._senders).call(r,(function(t){return t.track===e}));o&&splice$3(n=t._senders).call(n,indexOf2(i=t._senders).call(i,o),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},defineProperty$a(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=slice$1(Array.prototype).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){var t;return new map2(map$6(t=keys$8(e)).call(t,(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,t=this;return this._shimmedLocalStreams=this._shimmedLocalStreams||{},map$6(e=keys$8(this._shimmedLocalStreams)).call(e,(function(e){return t._shimmedLocalStreams[e][0]}))};var t=e.RTCPeerConnection.prototype.addTrack;e.RTCPeerConnection.prototype.addTrack=function(e,r){var n;if(!r)return t.apply(this,arguments);this._shimmedLocalStreams=this._shimmedLocalStreams||{};var i=t.apply(this,arguments);return this._shimmedLocalStreams[r.id]?-1===indexOf2(n=this._shimmedLocalStreams[r.id]).call(n,i)&&this._shimmedLocalStreams[r.id].push(i):this._shimmedLocalStreams[r.id]=[r,i],i};var r=e.RTCPeerConnection.prototype.addStream;e.RTCPeerConnection.prototype.addStream=function(e){var t,n,i=this;this._shimmedLocalStreams=this._shimmedLocalStreams||{},e.getTracks().forEach((function(e){var t;if(find$2(t=i.getSenders()).call(t,(function(t){return t.track===e})))throw new DOMException("Track already exists.","InvalidAccessError")}));var o=this.getSenders();r.apply(this,arguments);var a=filter3(t=this.getSenders()).call(t,(function(e){return-1===indexOf2(o).call(o,e)}));this._shimmedLocalStreams[e.id]=concat$2(n=[e]).call(n,a)};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&&keys$8(this._shimmedLocalStreams).forEach((function(r){var n,i,o=indexOf2(n=t._shimmedLocalStreams[r]).call(n,e);-1!==o&&splice$3(i=t._shimmedLocalStreams[r]).call(i,o,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||{},map$6(t).call(t,(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){var t;if(find$2(t=r.getSenders()).call(t,(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,i,o,a=this;if("closed"===this.signalingState)throw new DOMException("The RTCPeerConnection's signalingState is 'closed'.","InvalidStateError");var s=slice$1([]).call(arguments,1);if(1!==s.length||!find$2(n=s[0].getTracks()).call(n,(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 c=find$2(i=this.getSenders()).call(i,(function(e){return e.track===t}));if(c)throw new DOMException("Track already exists.","InvalidAccessError");this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{};var l=this._streams[r.id];if(l)l.addTrack(t),promise.resolve().then((function(){a.dispatchEvent(new Event("negotiationneeded"))}));else{var u=new e.MediaStream([t]);this._streams[r.id]=u,this._reverseStreams[u.id]=r,this.addStream(u)}return find$2(o=this.getSenders()).call(o,(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=getOwnPropertyDescriptor$1(e.RTCPeerConnection.prototype,"localDescription");defineProperty$a(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||{},keys$8(this._streams).forEach((function(n){var i;find$2(i=r._streams[n].getTracks()).call(i,(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 keys$8(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 keys$8(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"})),$$H=_export,isArray$8=isArray$f;$$H({target:"Array",stat:!0},{isArray:isArray$8});var path$e=path$v,isArray$7=path$e.Array.isArray,parent$1j=isArray$7,isArray$6=parent$1j,parent$1i=isArray$6,isArray$5=parent$1i,parent$1h=isArray$5,isArray$4=parent$1h,isArray$3=isArray$4,isArray$2=isArray$3;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 _arrayWithoutHoles(e){if(isArray$2(e))return _arrayLikeToArray(e)}var getIteratorMethod$7=getIteratorMethod$a,getIteratorMethod_1=getIteratorMethod$7,parent$1g=getIteratorMethod_1,getIteratorMethod$6=parent$1g,parent$1f=getIteratorMethod$6,getIteratorMethod$5=parent$1f,parent$1e=getIteratorMethod$5,getIteratorMethod$4=parent$1e,getIteratorMethod$3=getIteratorMethod$4,getIteratorMethod$2=getIteratorMethod$3,anObject$l=anObject$M,iteratorClose=iteratorClose$2,callWithSafeIterationClosing$1=function(e,t,r,n){try{return n?t(anObject$l(r)[0],r[1]):t(r)}catch(t){iteratorClose(e,"throw",t)}},bind$g=functionBindContext,call$d=functionCall,toObject$2=toObject$d,callWithSafeIterationClosing=callWithSafeIterationClosing$1,isArrayIteratorMethod=isArrayIteratorMethod$2,isConstructor3=isConstructor$4,lengthOfArrayLike$2=lengthOfArrayLike$b,createProperty$1=createProperty$6,getIterator$3=getIterator$7,getIteratorMethod$1=getIteratorMethod$a,$Array=Array,arrayFrom$1=function(e){var t=toObject$2(e),r=isConstructor3(this),n=arguments.length,i=n>1?arguments[1]:void 0,o=void 0!==i;o&&(i=bind$g(i,n>2?arguments[2]:void 0));var a,s,c,l,u,d,p=getIteratorMethod$1(t),_=0;if(!p||this===$Array&&isArrayIteratorMethod(p))for(a=lengthOfArrayLike$2(t),s=r?new this(a):$Array(a);a>_;_++)d=o?i(t[_],_):t[_],createProperty$1(s,_,d);else for(u=(l=getIterator$3(t,p)).next,s=r?new this:[];!(c=call$d(u,l)).done;_++)d=o?callWithSafeIterationClosing(l,i,[c.value,_],!0):c.value,createProperty$1(s,_,d);return s.length=_,s},$$G=_export,from$8=arrayFrom$1,checkCorrectnessOfIteration=checkCorrectnessOfIteration$2,INCORRECT_ITERATION=!checkCorrectnessOfIteration((function(e){Array.from(e)}));$$G({target:"Array",stat:!0,forced:INCORRECT_ITERATION},{from:from$8});var path$d=path$v,from$7=path$d.Array.from,parent$1d=from$7,from$6=parent$1d,parent$1c=from$6,from$5=parent$1c,parent$1b=from$5,from$4=parent$1b,from$3=from$4,from$2=from$3;function _iterableToArray(e){if(void 0!==symbol&&null!=getIteratorMethod$2(e)||null!=e["@@iterator"])return from$2(e)}function _unsupportedIterableToArray(e,t){var r;if(e){if("string"==typeof e)return _arrayLikeToArray(e,t);var n=slice$1(r=Object.prototype.toString.call(e)).call(r,8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?from$2(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?_arrayLikeToArray(e,t):void 0}}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 _toConsumableArray(e){return _arrayWithoutHoles(e)||_iterableToArray(e)||_unsupportedIterableToArray(e)||_nonIterableSpread()}var global$5=global$s,fails$5=fails$z,uncurryThis$b=functionUncurryThis,toString$7=toString$h,trim$7=stringTrim.trim,whitespaces$1=whitespaces$4,charAt$2=uncurryThis$b("".charAt),$parseFloat$1=global$5.parseFloat,Symbol$3=global$5.Symbol,ITERATOR$2=Symbol$3&&Symbol$3.iterator,FORCED$2=1/$parseFloat$1(whitespaces$1+"-0")!=-1/0||ITERATOR$2&&!fails$5((function(){$parseFloat$1(Object(ITERATOR$2))})),numberParseFloat=FORCED$2?function(e){var t=trim$7(toString$7(e)),r=$parseFloat$1(t);return 0===r&&"-"==charAt$2(t,0)?-0:r}:$parseFloat$1,$$F=_export,$parseFloat=numberParseFloat;$$F({global:!0,forced:parseFloat!=numberParseFloat},{parseFloat:numberParseFloat});var path$c=path$v,_parseFloat$5=path$c.parseFloat,parent$1a=_parseFloat$5,_parseFloat$4=parent$1a,parent$19=_parseFloat$4,_parseFloat$3=parent$19,parent$18=_parseFloat$3,_parseFloat$2=parent$18,_parseFloat$1=_parseFloat$2,_parseFloat=_parseFloat$1;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(stringify$1(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(stringify$1(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)&&defineProperty$a(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=slice$1(Array.prototype).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,assign$2({},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 map2)}}}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){var n;r.track&&includes4(n=e.getTracks()).call(n,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===keys$8(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,r=t.apply(this,arguments);"encodings"in r||(r.encodings=concat$2(e=[]).call(e,this.sendEncodings||[{}]));return r})}}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,n=this;this._localStreams||(this._localStreams=[]),includes4(r=this._localStreams).call(r,e)||this._localStreams.push(e),e.getAudioTracks().forEach((function(r){return t.call(n,r,e)})),e.getVideoTracks().forEach((function(r){return t.call(n,r,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){var t;r._localStreams?includes4(t=r._localStreams).call(t,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,r,n=this;this._localStreams||(this._localStreams=[]);var i=indexOf2(t=this._localStreams).call(t,e);if(-1!==i){splice$3(r=this._localStreams).call(r,i,1);var o=e.getTracks();this.getSenders().forEach((function(e){includes4(o).call(o,e.track)&&n.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))){defineProperty$a(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){var r;if(t._remoteStreams||(t._remoteStreams=[]),!includes4(r=t._remoteStreams).call(r,e)){t._remoteStreams.push(e);var n=new Event("addstream");n.stream=e,t.dispatchEvent(n)}}))})}});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){var r;if(e._remoteStreams||(e._remoteStreams=[]),!(indexOf2(r=e._remoteStreams).call(r,t)>=0)){e._remoteStreams.push(t);var n=new Event("addstream");n.stream=t,e.dispatchEvent(n)}}))}),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?assign$2({},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(stringify$1(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&&defineProperty$a(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)&&defineProperty$a(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){var r,n;void 0!==e.offerToReceiveAudio&&(e.offerToReceiveAudio=!!e.offerToReceiveAudio);var i=find$2(r=this.getTransceivers()).call(r,(function(e){return"audio"===e.receiver.track.kind}));!1===e.offerToReceiveAudio&&i?"sendrecv"===i.direction?i.setDirection?i.setDirection("sendonly"):i.direction="sendonly":"recvonly"===i.direction&&(i.setDirection?i.setDirection("inactive"):i.direction="inactive"):!0!==e.offerToReceiveAudio||i||this.addTransceiver("audio",{direction:"recvonly"}),void 0!==e.offerToReceiveVideo&&(e.offerToReceiveVideo=!!e.offerToReceiveVideo);var o=find$2(n=this.getTransceivers()).call(n,(function(e){return"video"===e.receiver.track.kind}));!1===e.offerToReceiveVideo&&o?"sendrecv"===o.direction?o.setDirection?o.setDirection("sendonly"):o.direction="sendonly":"recvonly"===o.direction&&(o.setDirection?o.setDirection("inactive"):o.direction="inactive"):!0!==e.offerToReceiveVideo||o||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"})),PROPER_FUNCTION_NAME=functionName.PROPER,fails$4=fails$z,whitespaces=whitespaces$4,non="​…᠎",stringTrimForced=function(e){return fails$4((function(){return!!whitespaces[e]()||non[e]()!==non||PROPER_FUNCTION_NAME&&whitespaces[e].name!==e}))},$$E=_export,$trim=stringTrim.trim,forcedStringTrimMethod=stringTrimForced;$$E({target:"String",proto:!0,forced:forcedStringTrimMethod("trim")},{trim:function(){return $trim(this)}});var entryVirtual$8=entryVirtual$m,trim$6=entryVirtual$8("String").trim,isPrototypeOf$a=objectIsPrototypeOf,method$8=trim$6,StringPrototype$2=String.prototype,trim$5=function(e){var t=e.trim;return"string"==typeof e||e===StringPrototype$2||isPrototypeOf$a(StringPrototype$2,e)&&t===StringPrototype$2.trim?method$8:t},parent$17=trim$5,trim$4=parent$17,parent$16=trim$4,trim$3=parent$16,parent$15=trim$3,trim$2=parent$15,trim$1=trim$2,trim2=trim$1,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){var t;return map$6(t=trim2(e).call(e).split("\n")).call(t,(function(e){return trim2(e).call(e)}))},t.splitSections=function(e){var t=e.split("\nm=");return map$6(t).call(t,(function(e,t){var r;return trim2(r=t>0?"m="+e:e).call(r)+"\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){var n;return filter3(n=t.splitLines(e)).call(n,(function(e){return 0===indexOf2(e).call(e,r)}))},t.parseCandidate=function(e){for(var t,r={foundation:(t=0===indexOf2(e).call(e,"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$6(t[3],10),ip:t[4],address:t[4],port:_parseInt$6(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$6(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$6(t.shift(),10)};return t=t[0].split("/"),r.name=t[0],r.clockRate=_parseInt$6(t[1],10),r.channels=3===t.length?_parseInt$6(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,r=e.substr(9).split(" ");return{id:_parseInt$6(r[0],10),direction:indexOf2(t=r[0]).call(t,"/")>0?r[0].split("/")[1]:"sendrecv",uri:r[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(indexOf2(e).call(e," ")+1).split(";"),i=0;i<n.length;i++){var o,a;t=trim2(o=n[i]).call(o).split("="),r[trim2(a=t[0]).call(a)]=t[1]}return r},t.writeFmtp=function(e){var t="",r=e.payloadType;if(void 0!==e.preferredPayloadType&&(r=e.preferredPayloadType),e.parameters&&keys$8(e.parameters).length){var n=[];keys$8(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(indexOf2(e).call(e," ")+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=indexOf2(e).call(e," "),r={ssrc:_parseInt$6(e.substr(7,t-7),10)},n=indexOf2(e).call(e,":",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:map$6(t).call(t,(function(e){return _parseInt$6(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){var n=t.matchPrefix(e+r,"a=fingerprint:");return{role:"auto",fingerprints:map$6(n).call(n,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$6(t[0],10),cryptoSuite:t[1],keyParams:t[2],sessionParams:slice$1(t).call(t,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!==indexOf2(e).call(e,"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){var n=t.matchPrefix(e+r,"a=crypto:");return map$6(n).call(n,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,c=t.parseRtpMap(a),l=t.matchPrefix(e,"a=fmtp:"+o+" ");switch(c.parameters=l.length?t.parseFmtp(l[0]):{},c.rtcpFeedback=map$6(s=t.matchPrefix(e,"a=rtcp-fb:"+o+" ")).call(s,t.parseRtcpFb),r.codecs.push(c),c.name.toUpperCase()){case"RED":case"ULPFEC":r.fecMechanisms.push(c.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,i="";i+="m="+e+" ",i+=r.codecs.length>0?"9":"0",i+=" UDP/TLS/RTP/SAVPF ",i+=map$6(n=r.codecs).call(n,(function(e){return void 0!==e.preferredPayloadType?e.preferredPayloadType:e.payloadType})).join(" ")+"\r\n",i+="c=IN IP4 0.0.0.0\r\n",i+="a=rtcp:9 IN IP4 0.0.0.0\r\n",r.codecs.forEach((function(e){i+=t.writeRtpMap(e),i+=t.writeFmtp(e),i+=t.writeRtcpFb(e)}));var o=0;return r.codecs.forEach((function(e){e.maxptime>o&&(o=e.maxptime)})),o>0&&(i+="a=maxptime:"+o+"\r\n"),r.headerExtensions&&r.headerExtensions.forEach((function(e){i+=t.writeExtmap(e)})),i},t.parseRtpEncodingParameters=function(e){var r,n,i,o,a,s,c=[],l=t.parseRtpParameters(e),u=-1!==indexOf2(r=l.fecMechanisms).call(r,"RED"),d=-1!==indexOf2(n=l.fecMechanisms).call(n,"ULPFEC"),p=filter3(i=map$6(o=t.matchPrefix(e,"a=ssrc:")).call(o,(function(e){return t.parseSsrcMedia(e)}))).call(i,(function(e){return"cname"===e.attribute})),_=p.length>0&&p[0].ssrc,h=map$6(a=t.matchPrefix(e,"a=ssrc-group:FID")).call(a,(function(e){var t=e.substr(17).split(" ");return map$6(t).call(t,(function(e){return _parseInt$6(e,10)}))}));h.length>0&&h[0].length>1&&h[0][0]===_&&(s=h[0][1]),l.codecs.forEach((function(e){if("RTX"===e.name.toUpperCase()&&e.parameters.apt){var t={ssrc:_,codecPayloadType:_parseInt$6(e.parameters.apt,10)};_&&s&&(t.rtx={ssrc:s}),c.push(t),u&&((t=JSON.parse(stringify$1(t))).fec={ssrc:_,mechanism:d?"red+ulpfec":"red"},c.push(t))}})),0===c.length&&_&&c.push({ssrc:_});var f,m,v=t.matchPrefix(e,"b=");v.length&&(v=0===indexOf2(f=v[0]).call(f,"b=TIAS:")?_parseInt$6(v[0].substr(7),10):0===indexOf2(m=v[0]).call(m,"b=AS:")?1e3*_parseInt$6(v[0].substr(5),10)*.95-16e3:void 0,c.forEach((function(e){e.maxBitrate=v})));return c},t.parseRtcpParameters=function(e){var r,n,i={},o=filter3(r=map$6(n=t.matchPrefix(e,"a=ssrc:")).call(n,(function(e){return t.parseSsrcMedia(e)}))).call(r,(function(e){return"cname"===e.attribute}))[0];o&&(i.cname=o.value,i.ssrc=o.ssrc);var a=t.matchPrefix(e,"a=rtcp-rsize");i.reducedSize=a.length>0,i.compound=0===a.length;var s=t.matchPrefix(e,"a=rtcp-mux");return i.mux=s.length>0,i},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,i,o=t.matchPrefix(e,"a=msid:");if(1===o.length)return{stream:(i=o[0].substr(7).split(" "))[0],track:i[1]};var a=filter3(r=map$6(n=t.matchPrefix(e,"a=ssrc:")).call(n,(function(e){return t.parseSsrcMedia(e)}))).call(r,(function(e){return"msid"===e.attribute}));return a.length>0?{stream:(i=a[0].value.split(" "))[0],track:i[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$6(i[0].substr(19),10)),isNaN(r)&&(r=65536);var o=t.matchPrefix(e,"a=sctp-port:");if(o.length>0)return{port:_parseInt$6(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$6(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$6(r[1],10),protocol:r[2],fmt:slice$1(r).call(r,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$6(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){var r;if("object"===_typeof(e)&&e.candidate&&0===indexOf2(r=e.candidate).call(r,"a=")&&((e=JSON.parse(stringify$1(e))).candidate=e.candidate.substr(2)),e.candidate&&e.candidate.length){var n=new t(e),i=SDPUtils.parseCandidate(e.candidate),o=assign$2(n,i);return o.toJSON=function(){return{candidate:o.candidate,sdpMid:o.sdpMid,sdpMLineIndex:o.sdpMLineIndex,usernameFragment:o.usernameFragment}},o}return new t(e)},e.RTCIceCandidate.prototype=t.prototype,wrapPeerConnectionEvent(e,"icecandidate",(function(t){return t.candidate&&defineProperty$a(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||defineProperty$a(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,r=SDPUtils.parseMLine(e);return r&&"application"===r.kind&&-1!==indexOf2(t=r.protocol).call(t,"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$6(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$6(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&&defineProperty$a(this,"sctp",{get:function(){return void 0===this._sctp?null:this._sctp},enumerable:!0,configurable:!0})}if(r(arguments[0])){var c,l=n(arguments[0]),u=i(l),d=o(arguments[0],l);c=0===u&&0===d?Number.POSITIVE_INFINITY:0===u||0===d?Math.max(u,d):Math.min(u,d);var p={};defineProperty$a(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;defineProperty$a(t,"connectionState",{get:function(){return{completed:"connected",checking:"connecting"}[this.iceConnectionState]||this.iceConnectionState},enumerable:!0,configurable:!0}),defineProperty$a(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){var n;if(t&&t.sdp&&-1!==indexOf2(n=t.sdp).call(n,"\na=extmap-allow-mixed")){var i,o=filter3(i=t.sdp.split("\n")).call(i,(function(e){return"a=extmap-allow-mixed"!==trim2(e).call(e)})).join("\n");e.RTCSessionDescription&&t instanceof e.RTCSessionDescription?arguments[0]=new e.RTCSessionDescription({type:t.type,sdp:o}):t.sdp=o}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$1,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}if(adapterFactory({window:"undefined"==typeof window?void 0:window}),"undefined"!=typeof MediaStreamTrack){var originGetSettings=MediaStreamTrack.prototype.getSettings;MediaStreamTrack.prototype.getSettings=function(){var e=originGetSettings.call(this);return e.width&&(e.width=Math.floor(e.width)),e.height&&(e.height=Math.floor(e.height)),e.frameRate&&(e.frameRate=Math.floor(e.frameRate)),e}}function _createForOfIteratorHelper(e,t){var r=void 0!==symbol&&getIteratorMethod$2(e)||e["@@iterator"];if(!r){if(isArray$2(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}}}}function _arrayWithHoles(e){if(isArray$2(e))return e}function _iterableToArrayLimit(e,t){var r=null==e?null:void 0!==symbol&&getIteratorMethod$2(e)||e["@@iterator"];if(null!=r){var n,i,o,a,s=[],c=!0,l=!1;try{if(o=(r=r.call(e)).next,0===t){if(Object(r)!==r)return;c=!1}else for(;!(c=(n=o.call(r)).done)&&(s.push(n.value),s.length!==t);c=!0);}catch(e){l=!0,i=e}finally{try{if(!c&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(l)throw i}}return s}}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 _slicedToArray(e,t){return _arrayWithHoles(e)||_iterableToArrayLimit(e,t)||_unsupportedIterableToArray(e,t)||_nonIterableRest()}var path$b=path$v,getOwnPropertySymbols$5=path$b.Object.getOwnPropertySymbols,parent$14=getOwnPropertySymbols$5,getOwnPropertySymbols$4=parent$14,parent$13=getOwnPropertySymbols$4,getOwnPropertySymbols$3=parent$13,parent$12=getOwnPropertySymbols$3,getOwnPropertySymbols$2=parent$12,getOwnPropertySymbols$1=getOwnPropertySymbols$2,getOwnPropertySymbols2=getOwnPropertySymbols$1,$$D=_export,DESCRIPTORS$4=descriptors,ownKeys$1=ownKeys$3,toIndexedObject$1=toIndexedObject$b,getOwnPropertyDescriptorModule$2=objectGetOwnPropertyDescriptor,createProperty=createProperty$6;$$D({target:"Object",stat:!0,sham:!DESCRIPTORS$4},{getOwnPropertyDescriptors:function(e){for(var t,r,n=toIndexedObject$1(e),i=getOwnPropertyDescriptorModule$2.f,o=ownKeys$1(n),a={},s=0;o.length>s;)void 0!==(r=i(n,t=o[s++]))&&createProperty(a,t,r);return a}});var path$a=path$v,getOwnPropertyDescriptors$5=path$a.Object.getOwnPropertyDescriptors,parent$11=getOwnPropertyDescriptors$5,getOwnPropertyDescriptors$4=parent$11,parent$10=getOwnPropertyDescriptors$4,getOwnPropertyDescriptors$3=parent$10,parent$$=getOwnPropertyDescriptors$3,getOwnPropertyDescriptors$2=parent$$,getOwnPropertyDescriptors$1=getOwnPropertyDescriptors$2,getOwnPropertyDescriptors2=getOwnPropertyDescriptors$1,defineProperties$7={exports:{}},$$C=_export,DESCRIPTORS$3=descriptors,defineProperties$6=objectDefineProperties.f;$$C({target:"Object",stat:!0,forced:Object.defineProperties!==defineProperties$6,sham:!DESCRIPTORS$3},{defineProperties:defineProperties$6});var path$9=path$v,Object$1=path$9.Object,defineProperties$5=defineProperties$7.exports=function(e,t){return Object$1.defineProperties(e,t)};Object$1.defineProperties.sham&&(defineProperties$5.sham=!0);var parent$_=defineProperties$7.exports,defineProperties$4=parent$_,parent$Z=defineProperties$4,defineProperties$3=parent$Z,parent$Y=defineProperties$3,defineProperties$2=parent$Y,defineProperties$1=defineProperties$2,defineProperties4=defineProperties$1;function ownKeys2(e,t){var r=keys$8(e);if(getOwnPropertySymbols2){var n=getOwnPropertySymbols2(e);t&&(n=filter3(n).call(n,(function(t){return getOwnPropertyDescriptor$1(e,t).enumerable}))),r.push.apply(r,n)}return r}function _objectSpread2(e){for(var t=1;t<arguments.length;t++){var r,n,i=null!=arguments[t]?arguments[t]:{};t%2?forEach$1(r=ownKeys2(Object(i),!0)).call(r,(function(t){_defineProperty(e,t,i[t])})):getOwnPropertyDescriptors2?defineProperties4(e,getOwnPropertyDescriptors2(i)):forEach$1(n=ownKeys2(Object(i))).call(n,(function(t){defineProperty$a(e,t,getOwnPropertyDescriptor$1(i,t))}))}return e}function _assertThisInitialized(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}var hasOwn$7=hasOwnProperty_1,isDataDescriptor$2=function(e){return void 0!==e&&(hasOwn$7(e,"value")||hasOwn$7(e,"writable"))},$$B=_export,call$c=functionCall,isObject$7=isObject$q,anObject$k=anObject$M,isDataDescriptor$1=isDataDescriptor$2,getOwnPropertyDescriptorModule$1=objectGetOwnPropertyDescriptor,getPrototypeOf$1=objectGetPrototypeOf;function get$6(e,t){var r,n,i=arguments.length<3?e:arguments[2];return anObject$k(e)===i?e[t]:(r=getOwnPropertyDescriptorModule$1.f(e,t))?isDataDescriptor$1(r)?r.value:void 0===r.get?void 0:call$c(r.get,i):isObject$7(n=getPrototypeOf$1(e))?get$6(n,t,i):void 0}$$B({target:"Reflect",stat:!0},{get:get$6});var path$8=path$v,get$5=path$8.Reflect.get,parent$X=get$5,get$4=parent$X,parent$W=get$4,get$3=parent$W,parent$V=get$3,get$2=parent$V,get$1=get$2,get=get$1,uncurryThis$a=functionUncurryThis,aCallable$c=aCallable$z,isObject$6=isObject$q,hasOwn$6=hasOwnProperty_1,arraySlice$2=arraySlice$6,NATIVE_BIND=functionBindNative,$Function=Function,concat2=uncurryThis$a([].concat),join$3=uncurryThis$a([].join),factories={},construct$6=function(e,t,r){if(!hasOwn$6(factories,t)){for(var n=[],i=0;i<t;i++)n[i]="a["+i+"]";factories[t]=$Function("C,a","return new C("+join$3(n,",")+")")}return factories[t](e,r)},functionBind=NATIVE_BIND?$Function.bind:function(e){var t=aCallable$c(this),r=t.prototype,n=arraySlice$2(arguments,1),i=function(){var r=concat2(n,arraySlice$2(arguments));return this instanceof i?construct$6(t,r.length,r):t.apply(e,r)};return isObject$6(r)&&(i.prototype=r),i},$$A=_export,bind$f=functionBind;$$A({target:"Function",proto:!0,forced:Function.bind!==bind$f},{bind:bind$f});var entryVirtual$7=entryVirtual$m,bind$e=entryVirtual$7("Function").bind,isPrototypeOf$9=objectIsPrototypeOf,method$7=bind$e,FunctionPrototype=Function.prototype,bind$d=function(e){var t=e.bind;return e===FunctionPrototype||isPrototypeOf$9(FunctionPrototype,e)&&t===FunctionPrototype.bind?method$7:t},parent$U=bind$d,bind$c=parent$U,parent$T=bind$c,bind$b=parent$T,parent$S=bind$b,bind$a=parent$S,bind$9=bind$a,bind$8=bind$9;function _getPrototypeOf(e){var t;return(_getPrototypeOf=setPrototypeOf$1?bind$8(t=getPrototypeOf$3).call(t):function(e){return e.__proto__||getPrototypeOf$3(e)})(e)}function _superPropBase(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=_getPrototypeOf(e)););return e}function _get(){var e;"undefined"!=typeof Reflect&&get?_get=bind$8(e=get).call(e):_get=function(e,t,r){var n=_superPropBase(e,t);if(n){var i=getOwnPropertyDescriptor$1(n,t);return i.get?i.get.call(arguments.length<3?e:r):i.value}};return _get.apply(this,arguments)}function _setPrototypeOf(e,t){var r;return(_setPrototypeOf=setPrototypeOf$1?bind$8(r=setPrototypeOf$1).call(r):function(e,t){return e.__proto__=t,e})(e,t)}function _inherits(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=create$4(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),defineProperty$a(e,"prototype",{writable:!1}),t&&_setPrototypeOf(e,t)}var $$z=_export,getBuiltIn$7=getBuiltIn$o,apply$1=functionApply,bind$7=functionBind,aConstructor=aConstructor$3,anObject$j=anObject$M,isObject$5=isObject$q,create$1=objectCreate$1,fails$3=fails$z,nativeConstruct=getBuiltIn$7("Reflect","construct"),ObjectPrototype=Object.prototype,push$6=[].push,NEW_TARGET_BUG=fails$3((function(){function e(){}return!(nativeConstruct((function(){}),[],e)instanceof e)})),ARGS_BUG=!fails$3((function(){nativeConstruct((function(){}))})),FORCED$1=NEW_TARGET_BUG||ARGS_BUG;$$z({target:"Reflect",stat:!0,forced:FORCED$1,sham:FORCED$1},{construct:function(e,t){aConstructor(e),anObject$j(t);var r=arguments.length<3?e:aConstructor(arguments[2]);if(ARGS_BUG&&!NEW_TARGET_BUG)return nativeConstruct(e,t,r);if(e==r){switch(t.length){case 0:return new e;case 1:return new e(t[0]);case 2:return new e(t[0],t[1]);case 3:return new e(t[0],t[1],t[2]);case 4:return new e(t[0],t[1],t[2],t[3])}var n=[null];return apply$1(push$6,n,t),new(apply$1(bind$7,e,n))}var i=r.prototype,o=create$1(isObject$5(i)?i:ObjectPrototype),a=apply$1(e,o,t);return isObject$5(a)?a:o}});var path$7=path$v,construct$5=path$7.Reflect.construct,parent$R=construct$5,construct$4=parent$R,parent$Q=construct$4,construct$3=parent$Q,parent$P=construct$3,construct$2=parent$P,construct$1=construct$2,construct2=construct$1;function _isNativeReflectConstruct(){if("undefined"==typeof Reflect||!construct2)return!1;if(construct2.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(construct2(Boolean,[],(function(){}))),!0}catch(e){return!1}}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=construct2(n,arguments,i)}else r=n.apply(this,arguments);return _possibleConstructorReturn(this,r)}}var entryVirtual$6=entryVirtual$m,values$7=entryVirtual$6("Array").values,parent$O=values$7,values$6=parent$O,classof$2=classof$d,hasOwn$5=hasOwnProperty_1,isPrototypeOf$8=objectIsPrototypeOf,method$6=values$6,ArrayPrototype$4=Array.prototype,DOMIterables$1={DOMTokenList:!0,NodeList:!0},values$5=function(e){var t=e.values;return e===ArrayPrototype$4||isPrototypeOf$8(ArrayPrototype$4,e)&&t===ArrayPrototype$4.values||hasOwn$5(DOMIterables$1,classof$2(e))?method$6:t},parent$N=values$5,values$4=parent$N,parent$M=values$4,values$3=parent$M,values$2=values$3,values$1=values$2,arraySlice$1=arraySliceSimple,floor$2=Math.floor,mergeSort=function(e,t){var r=e.length,n=floor$2(r/2);return r<8?insertionSort(e,t):merge2(e,mergeSort(arraySlice$1(e,0,n),t),mergeSort(arraySlice$1(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},merge2=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],$$y=_export,uncurryThis$9=functionUncurryThis,aCallable$b=aCallable$z,toObject$1=toObject$d,lengthOfArrayLike$1=lengthOfArrayLike$b,deletePropertyOrThrow=deletePropertyOrThrow$2,toString$6=toString$h,fails$2=fails$z,internalSort=arraySort$1,arrayMethodIsStrict=arrayMethodIsStrict$4,FF=engineFfVersion,IE_OR_EDGE=engineIsIeOrEdge,V8=engineV8Version,WEBKIT=engineWebkitVersion,test=[],nativeSort=uncurryThis$9(test.sort),push$5=uncurryThis$9(test.push),FAILS_ON_UNDEFINED=fails$2((function(){test.sort(void 0)})),FAILS_ON_NULL=fails$2((function(){test.sort(null)})),STRICT_METHOD=arrayMethodIsStrict("sort"),STABLE_SORT=!fails$2((function(){if(V8)return V8<70;if(!(FF&&FF>3)){if(IE_OR_EDGE)return!0;if(WEBKIT)return WEBKIT<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=FAILS_ON_UNDEFINED||!FAILS_ON_NULL||!STRICT_METHOD||!STABLE_SORT,getSortCompare=function(e){return function(t,r){return void 0===r?-1:void 0===t?1:void 0!==e?+e(t,r)||0:toString$6(t)>toString$6(r)?1:-1}};$$y({target:"Array",proto:!0,forced:FORCED},{sort:function(e){void 0!==e&&aCallable$b(e);var t=toObject$1(this);if(STABLE_SORT)return void 0===e?nativeSort(t):nativeSort(t,e);var r,n,i=[],o=lengthOfArrayLike$1(t);for(n=0;n<o;n++)n in t&&push$5(i,t[n]);for(internalSort(i,getSortCompare(e)),r=lengthOfArrayLike$1(i),n=0;n<r;)t[n]=i[n++];for(;n<o;)deletePropertyOrThrow(t,n++);return t}});var entryVirtual$5=entryVirtual$m,sort$6=entryVirtual$5("Array").sort,isPrototypeOf$7=objectIsPrototypeOf,method$5=sort$6,ArrayPrototype$3=Array.prototype,sort$5=function(e){var t=e.sort;return e===ArrayPrototype$3||isPrototypeOf$7(ArrayPrototype$3,e)&&t===ArrayPrototype$3.sort?method$5:t},parent$L=sort$5,sort$4=parent$L,parent$K=sort$4,sort$3=parent$K,parent$J=sort$3,sort$2=parent$J,sort$1=sort$2,sort2=sort$1,$$x=_export,$findIndex=arrayIteration.findIndex,FIND_INDEX="findIndex",SKIPS_HOLES=!0;FIND_INDEX in[]&&Array(1)[FIND_INDEX]((function(){SKIPS_HOLES=!1})),$$x({target:"Array",proto:!0,forced:SKIPS_HOLES},{findIndex:function(e){return $findIndex(this,e,arguments.length>1?arguments[1]:void 0)}});var entryVirtual$4=entryVirtual$m,findIndex$7=entryVirtual$4("Array").findIndex,isPrototypeOf$6=objectIsPrototypeOf,method$4=findIndex$7,ArrayPrototype$2=Array.prototype,findIndex$6=function(e){var t=e.findIndex;return e===ArrayPrototype$2||isPrototypeOf$6(ArrayPrototype$2,e)&&t===ArrayPrototype$2.findIndex?method$4:t},parent$I=findIndex$6,findIndex$5=parent$I,parent$H=findIndex$5,findIndex$4=parent$H,parent$G=findIndex$4,findIndex$3=parent$G,findIndex$2=findIndex$3,findIndex$1=findIndex$2,$$w=_export,uncurryThis$8=functionUncurryThis;objectGetOwnPropertyDescriptor.f;var toLength$1=toLength$4,toString$5=toString$h,notARegExp=notARegexp,requireObjectCoercible$2=requireObjectCoercible$9,correctIsRegExpLogic=correctIsRegexpLogic,nativeStartsWith=uncurryThis$8("".startsWith),stringSlice$3=uncurryThis$8("".slice),min=Math.min,CORRECT_IS_REGEXP_LOGIC=correctIsRegExpLogic("startsWith");$$w({target:"String",proto:!0,forced:!CORRECT_IS_REGEXP_LOGIC},{startsWith:function(e){var t=toString$5(requireObjectCoercible$2(this));notARegExp(e);var r=toLength$1(min(arguments.length>1?arguments[1]:void 0,t.length)),n=toString$5(e);return nativeStartsWith?nativeStartsWith(t,n,r):stringSlice$3(t,r,r+n.length)===n}});var entryVirtual$3=entryVirtual$m,startsWith$6=entryVirtual$3("String").startsWith,isPrototypeOf$5=objectIsPrototypeOf,method$3=startsWith$6,StringPrototype$1=String.prototype,startsWith$5=function(e){var t=e.startsWith;return"string"==typeof e||e===StringPrototype$1||isPrototypeOf$5(StringPrototype$1,e)&&t===StringPrototype$1.startsWith?method$3:t},parent$F=startsWith$5,startsWith$4=parent$F,parent$E=startsWith$4,startsWith$3=parent$E,parent$D=startsWith$3,startsWith$2=parent$D,startsWith$1=startsWith$2,startsWith2=startsWith$1,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.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_EXCEED_QPS="USER_MESSAGE_EXCEED_QPS",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.SUBTITLE_ALREADY_ON="SUBTITLE_ALREADY_ON",e.SUBTITLE_NOT_TURNED_ON="SUBTITLE_NOT_TURNED_ON",e.SUBTITLE_ERR_POSTPROCESS="SUBTITLE_ERR_POSTPROCESS",e.SUBTITLE_ERR_CONNECTION_ERROR="SUBTITLE_ERR_CONNECTION_ERROR",e.SUBTITLE_ERR_PROCESS_ERROR="SUBTITLE_ERR_PROCESS_ERROR",e.SUBTITLE_ERR_UNKNOWN="SUBTITLE_ERR_UNKNOWN",e.ROOM_FORBIDDEN="ROOM_FORBIDDEN",e.USER_FORBIDDEN="USER_FORBIDDEN",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||{}),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||{}),AAC_PROFILE=function(e){return e.LC="LC",e.HEv1="HEv1",e.HEv2="HEv2",e}(AAC_PROFILE||{}),TRANSCODING_VIDEO_CODEC=function(e){return e.H264="H264",e.H265="H265",e}(TRANSCODING_VIDEO_CODEC||{}),SUBTITLE_MODE=function(e){return e[e.ASR_ONLY=0]="ASR_ONLY",e[e.ASR_AND_TRANSLATION=1]="ASR_AND_TRANSLATION",e}(SUBTITLE_MODE||{}),SubtitleEventType=function(e){return e[e.STARTED=0]="STARTED",e[e.STOPPED=1]="STOPPED",e[e.ERROR=2]="ERROR",e}(SubtitleEventType||{}),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$2=descriptors,uncurryThis$7=functionUncurryThis,objectKeys=objectKeys$4,toIndexedObject=toIndexedObject$b,$propertyIsEnumerable=objectPropertyIsEnumerable.f,propertyIsEnumerable$2=uncurryThis$7($propertyIsEnumerable),push$4=uncurryThis$7([].push),createMethod$1=function(e){return function(t){for(var r,n=toIndexedObject(t),i=objectKeys(n),o=i.length,a=0,s=[];o>a;)r=i[a++],DESCRIPTORS$2&&!propertyIsEnumerable$2(n,r)||push$4(s,e?[r,n[r]]:n[r]);return s}},objectToArray={entries:createMethod$1(!0),values:createMethod$1(!1)},$$v=_export,$entries=objectToArray.entries;$$v({target:"Object",stat:!0},{entries:function(e){return $entries(e)}});var path$6=path$v,entries$5=path$6.Object.entries,parent$C=entries$5,entries$4=parent$C,parent$B=entries$4,entries$3=parent$B,parent$A=entries$3,entries$2=parent$A,entries$1=entries$2,entries2=entries$1,toIntegerOrInfinity=toIntegerOrInfinity$5,toString$4=toString$h,requireObjectCoercible$1=requireObjectCoercible$9,$RangeError$1=RangeError,stringRepeat=function(e){var t=toString$4(requireObjectCoercible$1(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$6=functionUncurryThis,toLength=toLength$4,toString$3=toString$h,$repeat=stringRepeat,requireObjectCoercible=requireObjectCoercible$9,repeat2=uncurryThis$6($repeat),stringSlice$2=uncurryThis$6("".slice),ceil=Math.ceil,createMethod=function(e){return function(t,r,n){var i,o,a=toString$3(requireObjectCoercible(t)),s=toLength(r),c=a.length,l=void 0===n?" ":toString$3(n);return s<=c||""==l?a:((o=repeat2(l,ceil((i=s-c)/l.length))).length>i&&(o=stringSlice$2(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),$$u=_export,$padEnd=stringPad.end,WEBKIT_BUG=stringPadWebkitBug;$$u({target:"String",proto:!0,forced:WEBKIT_BUG},{padEnd:function(e){return $padEnd(this,e,arguments.length>1?arguments[1]:void 0)}});var entryVirtual$2=entryVirtual$m,padEnd$6=entryVirtual$2("String").padEnd,isPrototypeOf$4=objectIsPrototypeOf,method$2=padEnd$6,StringPrototype=String.prototype,padEnd$5=function(e){var t=e.padEnd;return"string"==typeof e||e===StringPrototype||isPrototypeOf$4(StringPrototype,e)&&t===StringPrototype.padEnd?method$2:t},parent$z=padEnd$5,padEnd$4=parent$z,parent$y=padEnd$4,padEnd$3=parent$y,parent$x=padEnd$3,padEnd$2=parent$x,padEnd$1=padEnd$2,padEnd2=padEnd$1,$$t=_export,parseInt$2=numberParseInt;$$t({target:"Number",stat:!0,forced:Number.parseInt!=parseInt$2},{parseInt:parseInt$2});var path$5=path$v,_parseInt$5=path$5.Number.parseInt,parent$w=_parseInt$5,_parseInt$4=parent$w,parent$v=_parseInt$4,_parseInt$3=parent$v,parent$u=_parseInt$3,_parseInt$2=parent$u,_parseInt$1=_parseInt$2,_parseInt=_parseInt$1,log=Math.log,LOG10E=Math.LOG10E,mathLog10=Math.log10||function(e){return log(e)*LOG10E},$$s=_export,log10$6=mathLog10;$$s({target:"Math",stat:!0},{log10:log10$6});var getRandomValues,path$4=path$v,log10$5=path$4.Math.log10,parent$t=log10$5,log10$4=parent$t,parent$s=log10$4,log10$3=parent$s,parent$r=log10$3,log10$2=parent$r,log10$1=log10$2,log102=log10$1,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&&REGEX.test(e)}for(var byteToHex=[],i=0;i<256;++i)byteToHex.push((i+256).toString(16).substr(1));function stringify2(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 stringify2(n)}var isSSR$1=function(){return"undefined"==typeof window},genUuid$1=function(){return v4()},promiseAny$1=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)}))}))}))},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=slice$1(Array.prototype).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$2([]).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,l=t.max_code,u=t.stat_desc.static_tree,d=t.stat_desc.has_stree,p=t.stat_desc.extra_bits,_=t.stat_desc.extra_base,h=t.stat_desc.max_length,f=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)>h&&(o=h,f++),c[2*n+1]=o,n>l||(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*(u[2*n+1]+a)));if(0!==f){do{for(o=h-1;0===e.bl_count[o];)o--;e.bl_count[o]--,e.bl_count[o+1]+=2,e.bl_count[h]--,f-=2}while(f>0);for(o=h;0!==o;o--)for(n=e.bl_count[o];0!==n;)(i=e.heap[--r])>l||(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,l=-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]=l=r,e.depth[r]=0):o[2*r+1]=0;for(;e.heap_len<2;)o[2*(i=e.heap[++e.heap_len]=l<2?++l:0)]=1,e.depth[i]=0,e.opt_len--,s&&(e.static_len-=a[2*i+1]);for(t.max_code=l,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,l,e.bl_count)}function scan_tree(e,t,r){var n,i,o=-1,a=t[1],s=0,c=7,l=4;for(0===a&&(c=138,l=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<l?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,l=3):i===a?(c=6,l=3):(c=7,l=4))}function send_tree(e,t,r){var n,i,o=-1,a=t[1],s=0,c=7,l=4;for(0===a&&(c=138,l=3),n=0;n<=r;n++)if(i=a,a=t[2*(n+1)+1],!(++s<c&&i===a)){if(s<l)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,l=3):i===a?(c=6,l=3):(c=7,l=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,l=e.window,u=e.w_mask,d=e.prev,p=e.strstart+MAX_MATCH,_=l[o+a-1],h=l[o+a];e.prev_length>=e.good_match&&(i>>=2),s>e.lookahead&&(s=e.lookahead);do{if(l[(r=t)+a]===h&&l[r+a-1]===_&&l[r]===l[o]&&l[++r]===l[o+1]){o+=2,r++;do{}while(l[++o]===l[++r]&&l[++o]===l[++r]&&l[++o]===l[++r]&&l[++o]===l[++r]&&l[++o]===l[++r]&&l[++o]===l[++r]&&l[++o]===l[++r]&&l[++o]===l[++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;_=l[o+a-1],h=l[o+a]}}}while((t=d[t&u])>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,l,u=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,u,0)),r.wrap=0,u>=r.w_size&&(0===o&&(zero(r.head),r.strstart=0,r.block_start=0,r.insert=0),l=new utils$5.Buf8(r.w_size),utils$5.arraySet(l,t,u-r.w_size,r.w_size,0),t=l,u=r.w_size),a=e.avail_in,s=e.next_in,c=e.input,e.avail_in=u,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={},anObject$i=anObject$M,regexpFlags=function(){var e=anObject$i(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},call$b=functionCall,hasOwn$4=hasOwnProperty_1,isPrototypeOf$3=objectIsPrototypeOf,regExpFlags=regexpFlags,RegExpPrototype$1=RegExp.prototype,regexpGetFlags=function(e){var t=e.flags;return void 0!==t||"flags"in RegExpPrototype$1||hasOwn$4(e,"flags")||!isPrototypeOf$3(RegExpPrototype$1,e)?t:call$b(regExpFlags,e)},getRegExpFlags=regexpGetFlags,flags$6=getRegExpFlags,isPrototypeOf$2=objectIsPrototypeOf,flags$5=flags$6,RegExpPrototype=RegExp.prototype,flags_1=function(e){return e===RegExpPrototype||isPrototypeOf$2(RegExpPrototype,e)?flags$5(e):e.flags},parent$q=flags_1,flags$4=parent$q,parent$p=flags$4,flags$3=parent$p,parent$o=flags$3,flags$2=parent$o,flags$1=flags$2,flags=flags$1,inflate$3={},BAD$1=30,TYPE$1=12,inffast=function(e,t){var r,n,i,o,a,s,c,l,u,d,p,_,h,f,m,v,g,y,S,T,$,E,b,I,R;r=e.state,n=e.next_in,I=e.input,i=n+(e.avail_in-5),o=e.next_out,R=e.output,a=o-(t-e.avail_out),s=o+(e.avail_out-257),c=r.dmax,l=r.wsize,u=r.whave,d=r.wnext,p=r.window,_=r.hold,h=r.bits,f=r.lencode,m=r.distcode,v=(1<<r.lenbits)-1,g=(1<<r.distbits)-1;e:do{h<15&&(_+=I[n++]<<h,h+=8,_+=I[n++]<<h,h+=8),y=f[_&v];t:for(;;){if(_>>>=S=y>>>24,h-=S,0===(S=y>>>16&255))R[o++]=65535&y;else{if(!(16&S)){if(0==(64&S)){y=f[(65535&y)+(_&(1<<S)-1)];continue t}if(32&S){r.mode=TYPE$1;break e}e.msg="invalid literal/length code",r.mode=BAD$1;break e}T=65535&y,(S&=15)&&(h<S&&(_+=I[n++]<<h,h+=8),T+=_&(1<<S)-1,_>>>=S,h-=S),h<15&&(_+=I[n++]<<h,h+=8,_+=I[n++]<<h,h+=8),y=m[_&g];r:for(;;){if(_>>>=S=y>>>24,h-=S,!(16&(S=y>>>16&255))){if(0==(64&S)){y=m[(65535&y)+(_&(1<<S)-1)];continue r}e.msg="invalid distance code",r.mode=BAD$1;break e}if($=65535&y,h<(S&=15)&&(_+=I[n++]<<h,(h+=8)<S&&(_+=I[n++]<<h,h+=8)),($+=_&(1<<S)-1)>c){e.msg="invalid distance too far back",r.mode=BAD$1;break e}if(_>>>=S,h-=S,$>(S=o-a)){if((S=$-S)>u&&r.sane){e.msg="invalid distance too far back",r.mode=BAD$1;break e}if(E=0,b=p,0===d){if(E+=l-S,S<T){T-=S;do{R[o++]=p[E++]}while(--S);E=o-$,b=R}}else if(d<S){if(E+=l+d-S,(S-=d)<T){T-=S;do{R[o++]=p[E++]}while(--S);if(E=0,d<T){T-=S=d;do{R[o++]=p[E++]}while(--S);E=o-$,b=R}}}else if(E+=d-S,S<T){T-=S;do{R[o++]=p[E++]}while(--S);E=o-$,b=R}for(;T>2;)R[o++]=b[E++],R[o++]=b[E++],R[o++]=b[E++],T-=3;T&&(R[o++]=b[E++],T>1&&(R[o++]=b[E++]))}else{E=o-$;do{R[o++]=R[E++],R[o++]=R[E++],R[o++]=R[E++],T-=3}while(T>2);T&&(R[o++]=R[E++],T>1&&(R[o++]=R[E++]))}break}}break}}while(n<i&&o<s);n-=T=h>>3,_&=(1<<(h-=T<<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=h},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,l,u,d,p,_,h,f,m,v=s.bits,g=0,y=0,S=0,T=0,$=0,E=0,b=0,I=0,R=0,C=0,A=null,k=0,P=new utils$2.Buf16(MAXBITS+1),O=new utils$2.Buf16(MAXBITS+1),w=null,M=0;for(g=0;g<=MAXBITS;g++)P[g]=0;for(y=0;y<n;y++)P[t[r+y]]++;for($=v,T=MAXBITS;T>=1&&0===P[T];T--);if($>T&&($=T),0===T)return i[o++]=20971520,i[o++]=20971520,s.bits=1,0;for(S=1;S<T&&0===P[S];S++);for($<S&&($=S),I=1,g=1;g<=MAXBITS;g++)if(I<<=1,(I-=P[g])<0)return-1;if(I>0&&(e===CODES$1||1!==T))return-1;for(O[1]=0,g=1;g<MAXBITS;g++)O[g+1]=O[g]+P[g];for(y=0;y<n;y++)0!==t[r+y]&&(a[O[t[r+y]]++]=y);if(e===CODES$1?(A=w=a,_=19):e===LENS$1?(A=lbase,k-=257,w=lext,M-=257,_=256):(A=dbase,w=dext,_=-1),C=0,y=0,g=S,p=o,E=$,b=0,u=-1,d=(R=1<<$)-1,e===LENS$1&&R>ENOUGH_LENS$1||e===DISTS$1&&R>ENOUGH_DISTS$1)return 1;for(;;){h=g-b,a[y]<_?(f=0,m=a[y]):a[y]>_?(f=w[M+a[y]],m=A[k+a[y]]):(f=96,m=0),c=1<<g-b,S=l=1<<E;do{i[p+(C>>b)+(l-=c)]=h<<24|f<<16|m|0}while(0!==l);for(c=1<<g-1;C&c;)c>>=1;if(0!==c?(C&=c-1,C+=c):C=0,y++,0==--P[g]){if(g===T)break;g=t[r+a[y]]}if(g>$&&(C&d)!==u){for(0===b&&(b=$),p+=S,I=1<<(E=g-b);E+b<T&&!((I-=P[E+b])<=0);)E++,I<<=1;if(R+=1<<E,e===LENS$1&&R>ENOUGH_LENS$1||e===DISTS$1&&R>ENOUGH_DISTS$1)return 1;i[u=C&d]=$<<24|E<<16|p-o|0}}return 0!==C&&(i[p+C]=g-b<<24|64<<16|0),s.bits=$,0},utils$1=common,adler32=adler32_1,crc32=crc32_1,inflate_fast2=inffast,inflate_table2=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_table2(LENS,e.lens,0,288,lenfix,0,e.work,{bits:9}),t=0;t<32;)e.lens[t++]=5;inflate_table2(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,l,u,d,p,_,h,f,m,v,g,y,S,T,$,E,b,I,R=0,C=new utils$1.Buf8(4),A=[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,l=r.hold,u=r.bits,d=s,p=c,E=Z_OK;e:for(;;)switch(r.mode){case HEAD:if(0===r.wrap){r.mode=TYPEDO;break}for(;u<16;){if(0===s)break e;s--,l+=n[o++]<<u,u+=8}if(2&r.wrap&&35615===l){r.check=0,C[0]=255&l,C[1]=l>>>8&255,r.check=crc32(r.check,C,2,0),l=0,u=0,r.mode=FLAGS;break}if(r.flags=0,r.head&&(r.head.done=!1),!(1&r.wrap)||(((255&l)<<8)+(l>>8))%31){e.msg="incorrect header check",r.mode=BAD;break}if((15&l)!==Z_DEFLATED){e.msg="unknown compression method",r.mode=BAD;break}if(u-=4,$=8+(15&(l>>>=4)),0===r.wbits)r.wbits=$;else if($>r.wbits){e.msg="invalid window size",r.mode=BAD;break}r.dmax=1<<$,e.adler=r.check=1,r.mode=512&l?DICTID:TYPE,l=0,u=0;break;case FLAGS:for(;u<16;){if(0===s)break e;s--,l+=n[o++]<<u,u+=8}if(r.flags=l,(255&flags(r))!==Z_DEFLATED){e.msg="unknown compression method",r.mode=BAD;break}if(57344&flags(r)){e.msg="unknown header flags set",r.mode=BAD;break}r.head&&(r.head.text=l>>8&1),512&flags(r)&&(C[0]=255&l,C[1]=l>>>8&255,r.check=crc32(r.check,C,2,0)),l=0,u=0,r.mode=TIME;case TIME:for(;u<32;){if(0===s)break e;s--,l+=n[o++]<<u,u+=8}r.head&&(r.head.time=l),512&flags(r)&&(C[0]=255&l,C[1]=l>>>8&255,C[2]=l>>>16&255,C[3]=l>>>24&255,r.check=crc32(r.check,C,4,0)),l=0,u=0,r.mode=OS;case OS:for(;u<16;){if(0===s)break e;s--,l+=n[o++]<<u,u+=8}r.head&&(r.head.xflags=255&l,r.head.os=l>>8),512&flags(r)&&(C[0]=255&l,C[1]=l>>>8&255,r.check=crc32(r.check,C,2,0)),l=0,u=0,r.mode=EXLEN;case EXLEN:if(1024&flags(r)){for(;u<16;){if(0===s)break e;s--,l+=n[o++]<<u,u+=8}r.length=l,r.head&&(r.head.extra_len=l),512&flags(r)&&(C[0]=255&l,C[1]=l>>>8&255,r.check=crc32(r.check,C,2,0)),l=0,u=0}else r.head&&(r.head.extra=null);r.mode=EXTRA;case EXTRA:if(1024&flags(r)&&((_=r.length)>s&&(_=s),_&&(r.head&&($=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,_,$)),512&flags(r)&&(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&flags(r)){if(0===s)break e;_=0;do{$=n[o+_++],r.head&&$&&r.length<65536&&(r.head.name+=String.fromCharCode($))}while($&&_<s);if(512&flags(r)&&(r.check=crc32(r.check,n,_,o)),s-=_,o+=_,$)break e}else r.head&&(r.head.name=null);r.length=0,r.mode=COMMENT;case COMMENT:if(4096&flags(r)){if(0===s)break e;_=0;do{$=n[o+_++],r.head&&$&&r.length<65536&&(r.head.comment+=String.fromCharCode($))}while($&&_<s);if(512&flags(r)&&(r.check=crc32(r.check,n,_,o)),s-=_,o+=_,$)break e}else r.head&&(r.head.comment=null);r.mode=HCRC;case HCRC:if(512&flags(r)){for(;u<16;){if(0===s)break e;s--,l+=n[o++]<<u,u+=8}if(l!==(65535&r.check)){e.msg="header crc mismatch",r.mode=BAD;break}l=0,u=0}r.head&&(r.head.hcrc=flags(r)>>9&1,r.head.done=!0),e.adler=r.check=0,r.mode=TYPE;break;case DICTID:for(;u<32;){if(0===s)break e;s--,l+=n[o++]<<u,u+=8}e.adler=r.check=zswap32(l),l=0,u=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=l,r.bits=u,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){l>>>=7&u,u-=7&u,r.mode=CHECK;break}for(;u<3;){if(0===s)break e;s--,l+=n[o++]<<u,u+=8}switch(r.last=1&l,u-=1,3&(l>>>=1)){case 0:r.mode=STORED;break;case 1:if(fixedtables(r),r.mode=LEN_,t===Z_TREES){l>>>=2,u-=2;break e}break;case 2:r.mode=TABLE;break;case 3:e.msg="invalid block type",r.mode=BAD}l>>>=2,u-=2;break;case STORED:for(l>>>=7&u,u-=7&u;u<32;){if(0===s)break e;s--,l+=n[o++]<<u,u+=8}if((65535&l)!=(l>>>16^65535)){e.msg="invalid stored block lengths",r.mode=BAD;break}if(r.length=65535&l,l=0,u=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(;u<14;){if(0===s)break e;s--,l+=n[o++]<<u,u+=8}if(r.nlen=257+(31&l),l>>>=5,u-=5,r.ndist=1+(31&l),l>>>=5,u-=5,r.ncode=4+(15&l),l>>>=4,u-=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(;u<3;){if(0===s)break e;s--,l+=n[o++]<<u,u+=8}r.lens[A[r.have++]]=7&l,l>>>=3,u-=3}for(;r.have<19;)r.lens[A[r.have++]]=0;if(r.lencode=r.lendyn,r.lenbits=7,b={bits:r.lenbits},E=inflate_table2(CODES,r.lens,0,19,r.lencode,0,r.work,b),r.lenbits=b.bits,E){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(;v=(R=r.lencode[l&(1<<r.lenbits)-1])>>>16&255,g=65535&R,!((m=R>>>24)<=u);){if(0===s)break e;s--,l+=n[o++]<<u,u+=8}if(g<16)l>>>=m,u-=m,r.lens[r.have++]=g;else{if(16===g){for(I=m+2;u<I;){if(0===s)break e;s--,l+=n[o++]<<u,u+=8}if(l>>>=m,u-=m,0===r.have){e.msg="invalid bit length repeat",r.mode=BAD;break}$=r.lens[r.have-1],_=3+(3&l),l>>>=2,u-=2}else if(17===g){for(I=m+3;u<I;){if(0===s)break e;s--,l+=n[o++]<<u,u+=8}u-=m,$=0,_=3+(7&(l>>>=m)),l>>>=3,u-=3}else{for(I=m+7;u<I;){if(0===s)break e;s--,l+=n[o++]<<u,u+=8}u-=m,$=0,_=11+(127&(l>>>=m)),l>>>=7,u-=7}if(r.have+_>r.nlen+r.ndist){e.msg="invalid bit length repeat",r.mode=BAD;break}for(;_--;)r.lens[r.have++]=$}}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,b={bits:r.lenbits},E=inflate_table2(LENS,r.lens,0,r.nlen,r.lencode,0,r.work,b),r.lenbits=b.bits,E){e.msg="invalid literal/lengths set",r.mode=BAD;break}if(r.distbits=6,r.distcode=r.distdyn,b={bits:r.distbits},E=inflate_table2(DISTS,r.lens,r.nlen,r.ndist,r.distcode,0,r.work,b),r.distbits=b.bits,E){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=l,r.bits=u,inflate_fast2(e,p),a=e.next_out,i=e.output,c=e.avail_out,o=e.next_in,n=e.input,s=e.avail_in,l=r.hold,u=r.bits,r.mode===TYPE&&(r.back=-1);break}for(r.back=0;v=(R=r.lencode[l&(1<<r.lenbits)-1])>>>16&255,g=65535&R,!((m=R>>>24)<=u);){if(0===s)break e;s--,l+=n[o++]<<u,u+=8}if(v&&0==(240&v)){for(y=m,S=v,T=g;v=(R=r.lencode[T+((l&(1<<y+S)-1)>>y)])>>>16&255,g=65535&R,!(y+(m=R>>>24)<=u);){if(0===s)break e;s--,l+=n[o++]<<u,u+=8}l>>>=y,u-=y,r.back+=y}if(l>>>=m,u-=m,r.back+=m,r.length=g,0===v){r.mode=LIT;break}if(32&v){r.back=-1,r.mode=TYPE;break}if(64&v){e.msg="invalid literal/length code",r.mode=BAD;break}r.extra=15&v,r.mode=LENEXT;case LENEXT:if(r.extra){for(I=r.extra;u<I;){if(0===s)break e;s--,l+=n[o++]<<u,u+=8}r.length+=l&(1<<r.extra)-1,l>>>=r.extra,u-=r.extra,r.back+=r.extra}r.was=r.length,r.mode=DIST;case DIST:for(;v=(R=r.distcode[l&(1<<r.distbits)-1])>>>16&255,g=65535&R,!((m=R>>>24)<=u);){if(0===s)break e;s--,l+=n[o++]<<u,u+=8}if(0==(240&v)){for(y=m,S=v,T=g;v=(R=r.distcode[T+((l&(1<<y+S)-1)>>y)])>>>16&255,g=65535&R,!(y+(m=R>>>24)<=u);){if(0===s)break e;s--,l+=n[o++]<<u,u+=8}l>>>=y,u-=y,r.back+=y}if(l>>>=m,u-=m,r.back+=m,64&v){e.msg="invalid distance code",r.mode=BAD;break}r.offset=g,r.extra=15&v,r.mode=DISTEXT;case DISTEXT:if(r.extra){for(I=r.extra;u<I;){if(0===s)break e;s--,l+=n[o++]<<u,u+=8}r.offset+=l&(1<<r.extra)-1,l>>>=r.extra,u-=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,h=r.wsize-_):h=r.wnext-_,_>r.length&&(_=r.length),f=r.window}else f=i,h=a-r.offset,_=r.length;_>c&&(_=c),c-=_,r.length-=_;do{i[a++]=f[h++]}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(;u<32;){if(0===s)break e;s--,l|=n[o++]<<u,u+=8}if(p-=c,e.total_out+=p,r.total+=p,p&&(e.adler=r.check=flags(r)?crc32(r.check,i,p,a-p):adler32(r.check,i,p,a-p)),p=c,(flags(r)?l:zswap32(l))!==r.check){e.msg="incorrect data check",r.mode=BAD;break}l=0,u=0}r.mode=LENGTH;case LENGTH:if(r.wrap&&flags(r)){for(;u<32;){if(0===s)break e;s--,l+=n[o++]<<u,u+=8}if(l!==(4294967295&r.total)){e.msg="incorrect length check",r.mode=BAD;break}l=0,u=0}r.mode=DONE;case DONE:E=Z_STREAM_END;break e;case BAD:E=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=l,r.bits=u,(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=flags(r)?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)&&E===Z_OK&&(E=Z_BUF_ERROR),E}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,l=this.options.chunkSize,u=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(l),s.next_out=0,s.avail_out=l),(r=zlib_inflate.inflate(s,c.Z_NO_FLUSH))===c.Z_NEED_DICT&&u&&(r=zlib_inflate.inflateSetDictionary(this.strm,u)),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=l-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 _navigator,pako_1=pako,DB_NAME$1="BytePlusRTC",indexedDB$1=function(){return window.indexedDB||window.mozIndexedDB||window.webkitIndexedDB||window.msIndexedDB},IndexedDBInterface=function(){function e(t){_classCallCheck(this,e),_defineProperty(this,"storeName",void 0),_defineProperty(this,"pendingList",[]),this.storeName=t,!isSSR$1()&&indexedDB$1()&&this._checkAndCreateStore(t)}var t,r;return _createClass(e,[{key:"_checkAndCreateStore",value:function(t,r){var n=this;e.db&&e.db.close();var i=r?indexedDB$1().open(DB_NAME$1,r):indexedDB$1().open(DB_NAME$1);i.onupgradeneeded=function(){i.result.createObjectStore(t)},i.onerror=function(e){console.error("IndexedDBInterface error",i.error)},i.onsuccess=function(){var r=i.result;e.db=r;try{e.db.transaction(n.storeName,"readonly"),n.pendingList.forEach(function(){var e=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){var r,i,o,a;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=t.txMode,i=t.resolve,o=t.reject,e.prev=1,e.next=4,n._getStore(r);case 4:a=e.sent,i(a),e.next=11;break;case 8:e.prev=8,e.t0=e.catch(1),o();case 11:case"end":return e.stop()}}),e,null,[[1,8]])})));return function(t){return e.apply(this,arguments)}}())}catch(e){n._checkAndCreateStore(t,r.version+1)}}}},{key:"_getStore",value:function(t){var r=this;return new promise((function(n,i){e.db?n(e.db.transaction(r.storeName,t).objectStore(r.storeName)):r.pendingList.push({txMode:t,resolve:n,reject:i})}))}},{key:"put",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 e.next=2,this._getStore("readwrite");case 2:return n=e.sent,e.abrupt("return",new promise((function(e,i){var o=n.put(t,r);o.onsuccess=function(){e()},o.onerror=function(e){i(e)}})));case 4:case"end":return e.stop()}}),e,this)}))),function(e,t){return r.apply(this,arguments)})},{key:"get",value:(t=_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._getStore("readonly");case 2:return r=e.sent,e.abrupt("return",new promise((function(e,n){var i=r.get(t);i.onsuccess=function(){e(i.result)},i.onerror=function(e){n(e)}})));case 4:case"end":return e.stop()}}),e,this)}))),function(e){return t.apply(this,arguments)})}]),e}();_defineProperty(IndexedDBInterface,"db",void 0),_defineProperty(IndexedDBInterface,"state","init");var _context$1,ReportLimit=4e3,XMLHttpRequestTimeout=1e4,defaultCommonStats={product_line:"rtc",report_version:"5",os:"web",user_agent:isSSR$1()?"":null===(_navigator=navigator)||void 0===_navigator?void 0:_navigator.userAgent,platform:"web",product:"webrtc",app_state:"active"},REPROT_ERROR_BUFFER_KEY="ReportErrorBuffer",ReportorErrorBuffer=function(){function e(){_classCallCheck(this,e),_defineProperty(this,"_buffer",new IndexedDBInterface(REPROT_ERROR_BUFFER_KEY))}var t,r;return _createClass(e,[{key:"set",value:(r=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._buffer.put(t,REPROT_ERROR_BUFFER_KEY);case 2:case"end":return e.stop()}}),e,this)}))),function(e){return r.apply(this,arguments)})},{key:"get",value:(t=_asyncToGenerator(_regeneratorRuntime().mark((function e(){var t;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=[],e.prev=1,e.next=4,this._buffer.get(REPROT_ERROR_BUFFER_KEY);case 4:t=e.sent,e.next=9;break;case 7:e.prev=7,e.t0=e.catch(1);case 9:return e.abrupt("return",t);case 10:case"end":return e.stop()}}),e,this,[[1,7]])}))),function(){return t.apply(this,arguments)})}]),e}(),Reportor=function(){function e(){var t=this;_classCallCheck(this,e),_defineProperty(this,"report_common",defaultCommonStats),_defineProperty(this,"dataBuffer",[]),_defineProperty(this,"posting",!1),_defineProperty(this,"sucSendTimer",void 0),_defineProperty(this,"preSucTime",0),_defineProperty(this,"errSendTimer",void 0),_defineProperty(this,"errSendDelay",100),_defineProperty(this,"errSendBuffer",void 0),_defineProperty(this,"_logServerUrl",void 0),_defineProperty(this,"_retryCount",0),isSSR$1()||(window.addEventListener("beforeunload",(function(){clearTimeout(t.errSendTimer),clearTimeout(t.sucSendTimer),t._send(void 0,!0)})),document.addEventListener("visibilitychange",(function(){"visible"===document.visibilityState?t.setCommonStats({app_state:"active"}):"hidden"===document.visibilityState&&t.setCommonStats({app_state:"background"})})))}var t;return _createClass(e,[{key:"setUrl",value:function(e){this._logServerUrl=e}},{key:"setCommonStats",value:function(e){this.report_common=assign$2(this.report_common,e)}},{key:"enableErrorBuffer",value:function(){this.errSendBuffer=new ReportorErrorBuffer,this.loadErrorBuffer()}},{key:"push",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];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=concat$2(e).call(e,this.dataBuffer)}},{key:"_send",value:function(e,t){var r,n,i=this;if((e||this.dataBuffer.length)&&this._logServerUrl){var o={data:e||splice$3(r=this.dataBuffer).call(r,0,ReportLimit),header:_objectSpread2(_objectSpread2({},this.report_common),{},{http_retry_count:this._retryCount}),from:"web",os:"web",version:"1"},a=new XMLHttpRequest;if(a.timeout=XMLHttpRequestTimeout,a.onreadystatechange=function(){if(4===a.readyState){var r,n,s,c;if(e||(i.posting=!1),200===a.status||304===a.status)try{r=JSON.parse(a.responseText)}catch(e){n=e}if(r&&0===r.StatusCode){if(!e&&!t)null===(s=i.errSendBuffer)||void 0===s||s.set([]),i._sucSend()}else if(setTimeout((function(){var e,t;reportGlobalError(concat$2(e="reportor error, res:".concat(null===(t=r)||void 0===t?void 0:t.toString()," err:")).call(e,n),a.status,n)}),0),e)i._send(e);else i._unshift(o.data),null===(c=i.errSendBuffer)||void 0===c||c.set(_toConsumableArray(i.dataBuffer)),t?i._send():i._errSend()}},a.open("POST",this._logServerUrl,!0),e||(this.posting=!0),!isSSR$1()&&includes4(n=location.search).call(n,"_rtc_debug_"))a.send(stringify$1(o));else{var s=pako_1.gzip(stringify$1(o));a.setRequestHeader("Content-Encoding","gzip"),a.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=UTF-8"),a.send(s)}}}},{key:"_sucSend",value:function(){this.errSendDelay=100,this._retryCount=0,this.preSucTime=Date.now(),this.sucSendTimer=window.setTimeout(this._send.bind(this),2e3)}},{key:"_errSend",value:function(){var e=this;this.errSendTimer=window.setTimeout((function(){e._send(),delete e.errSendTimer}),this.errSendDelay),this.errSendDelay*=2,this._retryCount++}},{key:"loadErrorBuffer",value:(t=_asyncToGenerator(_regeneratorRuntime().mark((function e(){var t,r,n=this;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,null===(r=this.errSendBuffer)||void 0===r?void 0:r.get();case 2:if(e.t1=t=e.sent,e.t0=null!==e.t1,!e.t0){e.next=6;break}e.t0=void 0!==t;case 6:if(!e.t0){e.next=10;break}e.t2=t,e.next=11;break;case 10:e.t2=[];case 11:e.t2.forEach((function(e){n.push(e)}));case 13:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})}]),e}(),commonReportor=new Reportor,Monitor=function(){function e(t){_classCallCheck(this,e),_defineProperty(this,"report_id",0),_defineProperty(this,"modify_ids",{}),this.id=t}return _createClass(e,[{key:"report",value:function(e,t){var r,n,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},o=_objectSpread2(_objectSpread2(_objectSpread2({event_key:e,report_id:this.report_id++,rtc_timestamp:Date.now()},this.modify_ids),t),{},{common_extra_info:stringify$1(i)});(commonReportor.push(o),isSSR$1())||(null===(r=(n=window).__onRTCReport)||void 0===r||r.call(n,this.id,o))}},{key:"set",value:function(e){this.modify_ids=assign$2(this.modify_ids,e)}},{key:"destroy",value:function(){}}]),e}(),entryVirtual$1=entryVirtual$m,keys$7=entryVirtual$1("Array").keys,parent$n=keys$7,keys$6=parent$n,classof$1=classof$d,hasOwn$3=hasOwnProperty_1,isPrototypeOf$1=objectIsPrototypeOf,method$1=keys$6,ArrayPrototype$1=Array.prototype,DOMIterables={DOMTokenList:!0,NodeList:!0},keys$5=function(e){var t=e.keys;return e===ArrayPrototype$1||isPrototypeOf$1(ArrayPrototype$1,e)&&t===ArrayPrototype$1.keys||hasOwn$3(DOMIterables,classof$1(e))?method$1:t},parent$m=keys$5,keys$4=parent$m,parent$l=keys$4,keys$3=parent$l,keys$2=keys$3,keys$1=keys$2,DB_NAME="@byted/ve-rtc",STORE_NAME="@byted/ve-rtc",STORE_CACHED_SIZE_KEY="@byted/ve-rtc-cache-size",IDB=function(){function e(){_classCallCheck(this,e),_defineProperty(this,"storeKey",void 0),_defineProperty(this,"logLevel",void 0),_defineProperty(this,"LogfileSize",void 0),_defineProperty(this,"db",void 0),_defineProperty(this,"logId",void 0),_defineProperty(this,"cacheLog",void 0),_defineProperty(this,"cachedSize",void 0),_defineProperty(this,"preCacheTime",void 0),_defineProperty(this,"timer",void 0),_defineProperty(this,"_getSize",(function(e){return new Blob(e).size/1048576})),this.storeKey="",this.logId=1,this.cacheLog="",this.logLevel="none",this.LogfileSize=100,this._createStore()}return _createClass(e,[{key:"_createStore",value:function(){var e=this;if(!isSSR$1()&&window.indexedDB){var t=indexedDB.open(DB_NAME);t.onupgradeneeded=function(){t.result.createObjectStore(STORE_NAME);try{localStorage.removeItem(STORE_CACHED_SIZE_KEY)}catch(e){}},t.onerror=function(e){},t.onsuccess=function(){e.db=t.result,e._getCachedSize()}}}},{key:"_getCachedSize",value:function(){var e=this;try{var t=localStorage.getItem(STORE_CACHED_SIZE_KEY);if(t)this.cachedSize=+t;else values$1(this).call(this).then((function(t){e.cachedSize=e._getSize(t),e._setCachedSize()}))}catch(e){}}},{key:"_setCachedSize",value:function(){try{localStorage.setItem(STORE_CACHED_SIZE_KEY,"".concat(this.cachedSize))}catch(e){}}},{key:"_getStore",value:function(e){if(this.db)return this.db.transaction(STORE_NAME,e).objectStore(STORE_NAME)}},{key:"set",value:function(e){var t=this;return new promise((function(r,n){if("none"===t.logLevel)return r();var i;if(e&&t.preCacheTime&&t.preCacheTime-Date.now()<1e3)return t.cacheLog+=concat$2(i="\n\n".concat(t.logId,": ")).call(i,e),t.logId++,t.timer||(t.timer=setTimeout((function(){t.set("")}),1e3-(t.preCacheTime-Date.now()))),r();clearTimeout(t.timer),t.timer=null;var o=t._getStore("readwrite");if(!o)return n("get store fail");t.cachedSize&&t.cachedSize>t.LogfileSize&&t.keyEarliest().then((function(e){t.get(e).then((function(r){t.del(e).then((function(){t.cachedSize=t.cachedSize-t._getSize(["".concat(r)]),t._setCachedSize()}))}))}));var a=o.get(t.storeKey);a.onsuccess=function(){try{var i,s,c,l,u,d=concat$2(i="".concat(a.result||"")).call(i,t.cacheLog),p=e?concat$2(s=concat$2(c="".concat(d?"\n\n":"")).call(c,t.logId,": ")).call(s,e):"";o.put(concat$2(l="".concat(d)).call(l,p),t.storeKey),e&&t.logId++,t.cacheLog="",t.cachedSize=(t.cachedSize||0)+t._getSize([concat$2(u="".concat(t.cacheLog)).call(u,p)]),t._setCachedSize(),t.preCacheTime=Date.now(),r()}catch(r){var _;if(!e)return n(r);t.cacheLog+=concat$2(_="\n\n".concat(t.logId,": ")).call(_,e),t.logId++,n(r)}},a.onerror=function(r){var i;if(!e)return n(r);t.cacheLog+=concat$2(i="\n\n".concat(t.logId,": ")).call(i,e),t.logId++,n(r)}}))}},{key:"get",value:function(e){var t=this;return new promise((function(r,n){var i=t._getStore("readonly");if(!i)return n();var o=i.get(e);o.onsuccess=function(){r(o.result)},o.onerror=function(e){n(e)}}))}},{key:"del",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.storeKey;return new promise((function(r,n){var i=e._getStore("readwrite");if(!i)return n();var o=i.delete(t);o.onsuccess=function(){return r(o.result)},o.onerror=function(e){return n(e)}}))}},{key:"keyEarliest",value:function(){return keys$1(this).call(this).then((function(e){var t,r=Date.now();return e.forEach((function(e){if(e&&e.length){var n=e.split("-")[0];Number(n)<r&&(r=Number(n),t=e)}})),t}))}},{key:"keys",value:function(){var e=this;return new promise((function(t,r){var n=e._getStore("readonly");if(!n)return r();if(n.getAllKeys){var i=n.getAllKeys();return i.onsuccess=function(){t(i.result)},void(i.onerror=function(){r()})}var o=[];n.openCursor().onsuccess=function(){this.result&&(o.push(this.result.key),this.result.continue())},n.transaction.oncomplete=function(){return t(o)}}))}},{key:"values",value:function(){var e=this;return new promise((function(t,r){var n=e._getStore("readonly");if(!n)return r();if(n.getAll){var i=n.getAll();return i.onsuccess=function(){t(i.result)},void(i.onerror=function(){r()})}var o=[];n.openCursor().onsuccess=function(){this.result&&(o.push(this.result.value),this.result.continue())},n.transaction.oncomplete=function(){return t(o)}}))}},{key:"download",value:function(e){e=e||this.storeKey,this.get(e).then((function(t){var r=document.createElement("a");r.download="".concat(e,".txt"),r.href="data:text/paint;utf-8,"+(t||""),r.click()}))}}]),e}(),iDB=new IDB,HEAD_TEXT="[VERTC]",colorMap=["#0050b3","#0050b3","#0050b3","#0050b3","#0050b3"],enable_log="undefined"!=typeof window&&includes4(_context$1=window.location.search).call(_context$1,"_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){for(var t,r,n,i,o,a,s,c=arguments.length,l=new Array(c>1?c-1:0),u=1;u<c;u++)l[u-1]=arguments[u];var d=l.shift();try{var p,_,h,f,m=concat$2(p=[]).call(p,l),v="".concat(d).replace(/\%o/gi,(function(){var e=m.shift();return stringify$1(e)}));iDB.set(concat$2(_=concat$2(h=concat$2(f="".concat(HEAD_TEXT,"[").concat(this._module,".")).call(f,e,"] ")).call(h,v," ")).call(_,map$6(m).call(m,(function(e){return stringify$1(e)})).join(", ")))}catch(e){}if(enable_log){for(var g="",y=0;y<this._indent;y++)g+=" ";(t=console).log.apply(t,concat$2(r=[concat$2(n=concat$2(i=concat$2(o=concat$2(a=concat$2(s="%c".concat(getTimestamp(),"-")).call(s,HEAD_TEXT)).call(a,g,"[")).call(o,this._module,".")).call(i,e,"] ")).call(n,d),"color:".concat(colorMap[this._indent],";")]).call(r,l))}}}]),e}(),getTimestamp=function(){var e=new Date;return e.toTimeString().split(" ")[0]+":"+e.getMilliseconds()},logger$n=new Logger("MessageReportor",1),RESET_DURATION=36e5,MessageReportor=function(){function e(t){_classCallCheck(this,e),_defineProperty(this,"_preTime",Date.now()),_defineProperty(this,"_one2oneNum",0),_defineProperty(this,"_one2manyNum",0),_defineProperty(this,"_one2oneMsgCache",new map2),_defineProperty(this,"_one2manyMsgCache",new map2),_defineProperty(this,"roomId",""),_defineProperty(this,"userId",""),_defineProperty(this,"rtsSessionId",""),this.id=t}return _createClass(e,[{key:"needReport",value:function(t){return!!e.config&&(Date.now()-this._preTime>=RESET_DURATION&&(this._preTime=Date.now(),this._one2oneNum=0,this._one2manyNum=0),"one2one"===t&&this._one2oneNum<e.config.max_one2one_fpt_per_hour&&Math.random()<=e.config.one2one_fpt_ratio/100||"one2many"===t&&this._one2manyNum<e.config.max_one2many_fpt_per_hour&&Math.random()<=e.config.one2many_fpt_ratio/100)}},{key:"cacheP2PMsg",value:function(t){var r;this._one2oneMsgCache.set(t.msg_id,_objectSpread2({config_version:(null===(r=e.config)||void 0===r?void 0:r.version)||""},t))}},{key:"updateP2PMsg",value:function(e,t){var r=this._one2oneMsgCache.get(e);r&&this._one2oneMsgCache.set(e,_objectSpread2(_objectSpread2({},r),t))}},{key:"cacheCustomMsg",value:function(t){var r;this._one2manyMsgCache.set(t.msg_id,_objectSpread2({config_version:(null===(r=e.config)||void 0===r?void 0:r.version)||""},t))}},{key:"updateOne2ManyMsg",value:function(e,t){var r=this._one2manyMsgCache.get(e);r&&this._one2manyMsgCache.set(e,_objectSpread2(_objectSpread2({},r),t))}},{key:"reportP2PMsg",value:function(e){var t,r=this._one2oneMsgCache.get(e);r&&(logger$n.print("reportP2PMsg",r.type,stringify$1(r)),null===(t=getMonitor(this.id))||void 0===t||t.report("rts_message",r))}},{key:"reportOne2ManyMsg",value:function(e){var t,r=this._one2manyMsgCache.get(e);r&&(logger$n.print("reportOne2ManyMsg",r.type,stringify$1(r)),null===(t=getMonitor(this.id))||void 0===t||t.report("rts_message",r))}},{key:"reportMsgRecv",value:function(t){var r,n;t.config_version=(null===(r=e.config)||void 0===r?void 0:r.version)||"",logger$n.print("reportMsgRecv",t.type,stringify$1(t)),null===(n=getMonitor(this.id))||void 0===n||n.report("rts_message",t)}},{key:"destroy",value:function(){this._one2manyNum=0,this._one2oneNum=0,this._one2manyMsgCache.clear(),this._one2oneMsgCache.clear(),this._preTime=Date.now(),this.roomId="",this.userId="",this.rtsSessionId=""}}]),e}();_defineProperty(MessageReportor,"config",void 0);var _cache=new map2,setConfig=function(e){logger$n.print("setConfig","get config: "+stringify$1(e)),MessageReportor.config=e},createRTSMsgReportor=function(e){var t=_cache.get(e)||new MessageReportor(e);return _cache.set(e,t),t},destroyRTSMsgReportor=function(e){var t=_cache.get(e);t&&(t.destroy(),_cache.delete(e))},setRoomId=function(e,t){var r=_cache.get(e);r&&(r.roomId=t||"")},setUserId=function(e,t){var r=_cache.get(e);r&&(r.userId=t||"")},setRtsSessionId=function(e,t){var r=_cache.get(e);r&&(r.rtsSessionId=t)},samplingP2PMsg=function(e,t){var r=_cache.get(e);if(null!=r&&r.needReport("one2one")){var n,i=concat$2(n="".concat(t.from)).call(n,t.id),o=t.to?"one2one":"one2server";t.enable_report=!0,t.report_msg_id=t.id,r.cacheP2PMsg({rts_session_id:r.rtsSessionId,msg_id:i,node_role:"src_sdk",from:t.from,to:t.to||"server",type:o,rts_room_id:t.room,req_ts:Date.now(),send_ts:Date.now(),ack_ts:Date.now(),msg_size:0,error_code:0,recv_msg_ts:0,fwd_msg_ts:0,reply_ack_ts:0,cur_dst_uid:""})}return t},updateP2PMsgReq=function(e,t,r){var n,i;t.enable_report&&t.report_msg_id&&(null===(n=_cache.get(e))||void 0===n||n.updateP2PMsg(concat$2(i="".concat(t.from)).call(i,t.report_msg_id),{send_ts:Date.now(),msg_size:r}))},updateP2PMsgAck=function(e,t,r){if(t.enable_report&&t.report_msg_id){var n,i,o=_cache.get(e);null==o||o.updateP2PMsg(concat$2(n="".concat(t.from)).call(n,t.report_msg_id),{ack_ts:Date.now(),error_code:r}),null==o||o.reportP2PMsg(concat$2(i="".concat(t.from)).call(i,t.report_msg_id))}},samplingOne2ManyMsg=function(e,t,r){var n,i=_cache.get(e);null!=i&&i.needReport("one2many")&&(r.enable_report=!0,r.report_msg_id=t,i.cacheCustomMsg({rts_session_id:i.rtsSessionId,msg_id:concat$2(n="".concat(r.clientId)).call(n,t),node_role:"src_sdk",from:r.clientId,to:i.roomId,type:"one2many",rts_room_id:i.roomId,req_ts:Date.now(),send_ts:Date.now(),ack_ts:Date.now(),msg_size:0,error_code:0,recv_msg_ts:0,fwd_msg_ts:0,reply_ack_ts:0,cur_dst_uid:""}));return r},updateOne2ManyMsgReq=function(e,t,r){if(t.enable_report&&t.report_msg_id){var n,i=_cache.get(e);if(i)i.updateOne2ManyMsg(concat$2(n="".concat(t.clientId)).call(n,t.report_msg_id),{send_ts:Date.now(),msg_size:r})}},updateOne2ManyMsgAck=function(e,t,r){if(t.enable_report&&t.report_msg_id){var n,i,o=_cache.get(e);if(o)null==o||o.updateOne2ManyMsg(concat$2(n="".concat(t.clientId)).call(n,t.report_msg_id),{ack_ts:Date.now(),error_code:r}),null==o||o.reportOne2ManyMsg(concat$2(i="".concat(t.clientId)).call(i,t.report_msg_id))}},reportP2PMsgRecv=function(e,t,r){if(t.enable_report&&t.report_msg_id){var n,i=_cache.get(e),o=t.to?"one2one":"one2many";null==i||i.reportMsgRecv({rts_session_id:i.rtsSessionId,msg_id:concat$2(n="".concat(t.from)).call(n,t.report_msg_id),msg_size:r.msg_size,node_role:"dst_sdk",type:o,rts_room_id:t.room,from:t.from,to:t.to||t.room,error_code:0,recv_msg_ts:r.recv_msg_ts,fwd_msg_ts:r.fwd_msg_ts,reply_ack_ts:Date.now(),cur_dst_uid:t.to?"":i.userId,config_version:"",req_ts:0,send_ts:0,ack_ts:0})}},reportOne2ManyMsgRecv=function(e,t,r){if(t.enable_report&&t.report_msg_id){var n,i=_cache.get(e);null==i||i.reportMsgRecv({rts_session_id:i.rtsSessionId,msg_id:concat$2(n="".concat(t.clientId)).call(n,t.report_msg_id),msg_size:r.msg_size,node_role:"dst_sdk",type:"one2many",rts_room_id:t.roomId,from:t.clientId,to:t.roomId,error_code:0,recv_msg_ts:r.recv_msg_ts,fwd_msg_ts:r.fwd_msg_ts,reply_ack_ts:Date.now(),cur_dst_uid:i.userId,config_version:"",req_ts:0,send_ts:0,ack_ts:0})}},RTSMsgReportor={_cache:_cache,setConfig:setConfig,setRtsSessionId:setRtsSessionId,createRTSMsgReportor:createRTSMsgReportor,destroyRTSMsgReportor:destroyRTSMsgReportor,setRoomId:setRoomId,setUserId:setUserId,samplingP2PMsg:samplingP2PMsg,updateP2PMsgReq:updateP2PMsgReq,updateP2PMsgAck:updateP2PMsgAck,samplingOne2ManyMsg:samplingOne2ManyMsg,reportP2PMsgRecv:reportP2PMsgRecv,updateOne2ManyMsgAck:updateOne2ManyMsgAck,updateOne2ManyMsgReq:updateOne2ManyMsgReq,reportOne2ManyMsgRecv:reportOne2ManyMsgRecv},MessageStatisticsObserver=function(){function e(t){_classCallCheck(this,e),_defineProperty(this,"_timer",void 0),_defineProperty(this,"userMessage",{}),_defineProperty(this,"roomMessage",{}),this.id=t,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(){(keys$8(this.userMessage).length||keys$8(this.roomMessage).length)&&(this._report(),this._reset())}},{key:"_report",value:function(){var e,t,r,n=this;null===(e=getMonitor(this.id))||void 0===e||e.report("rtc_message_statistics",{dc_user_message:map$6(t=keys$8(this.userMessage)).call(t,(function(e){return n.userMessage[e]})),dc_room_message:map$6(r=keys$8(this.roomMessage)).call(r,(function(e){return n.roomMessage[e]})),media_server_ip:""})}},{key:"_reset",value:function(){this.userMessage={},this.roomMessage={}}},{key:"_checkInitUserMessage",value:function(e,t){var r,n;this.userMessage[concat$2(r="".concat(t,"-")).call(r,e)]||(this.userMessage[concat$2(n="".concat(t,"-")).call(n,e)]={dc_peer_user_id:e,dc_send_total:0,dc_recv_total:0,dc_send_ack:0,dc_send_fail:0,dc_fail_timeout:0,dc_fail_no_receiver:0,dc_fail_no_relay_path: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){var n,i;(this._checkInitUserMessage(e,t),this.userMessage[concat$2(n="".concat(t,"-")).call(n,e)].dc_send_total++,r)&&this.userMessage[concat$2(i="".concat(t,"-")).call(i,e)].dc_send_binary++}},{key:"_recvUserMessage",value:function(e,t){var r;this._checkInitUserMessage(e,t),this.userMessage[concat$2(r="".concat(t,"-")).call(r,e)].dc_recv_total++}},{key:"_sendUserFail",value:function(e,t,r){var n,i=this.userMessage[concat$2(n="".concat(t,"-")).call(n,e)];i&&(i.dc_send_fail++,this._handleUserFail(i,r))}},{key:"_handleUserFail",value:function(e,t){var r;t&&(t.code||t.err)&&(includes4(r=["TIME_OUT","USER_MESSAGE_TIMEOUT"]).call(r,t.code)?e.dc_fail_timeout++:3===t.err?e.dc_fail_no_receiver++:4===t.err?e.dc_fail_no_relay_path++:1===t.err&&e.dc_fail_timeout++)}},{key:"_sendUserAck",value:function(e,t,r,n,i){var o,a=this.userMessage[concat$2(o="".concat(t,"-")).call(o,e)];a&&(a.dc_send_ack++,a.dc_cost_time+=r,a.dc_cost_s2s+=n||0,a.dc_cost_peer_s2e+=i,a.dc_cost_e2s+=r-(n||0)-i,r<=100?(a.dc_send_ack_100++,a.dc_send_ack_200++,a.dc_send_ack_400++,a.dc_send_ack_1s++):r<=200?(a.dc_send_ack_200++,a.dc_send_ack_400++,a.dc_send_ack_1s++):r<=400?(a.dc_send_ack_400++,a.dc_send_ack_1s++):r<=1e3&&a.dc_send_ack_1s++,r<a.dc_least_time&&(a.dc_least_time=r),r>a.dc_most_time&&(a.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,"p2p",t)}},{key:"recvP2PMessage",value:function(e){this._recvUserMessage(e,"p2p")}},{key:"sendP2PFail",value:function(e,t){this._sendUserFail(e,"p2p",t)}},{key:"sendP2PAck",value:function(e,t,r,n){this._sendUserAck(e,"p2p",t,r,n)}},{key:"sendP2POutRoomMessage",value:function(e,t){this._sendUserMessage(e,"p2p_outside_room",t)}},{key:"recvP2POutRoomMessage",value:function(e){this._recvUserMessage(e,"p2p_outside_room")}},{key:"sendP2POutRoomFail",value:function(e,t){this._sendUserFail(e,"p2p_outside_room",t)}},{key:"sendP2POutRoomAck",value:function(e,t,r,n){this._sendUserAck(e,"p2p_outside_room",t,r,n)}},{key:"sendP2serverMessage",value:function(e){this._sendUserMessage("","p2server",e)}},{key:"sendP2serverFail",value:function(e){this._sendUserFail("","p2server",e)}},{key:"sendP2serveAck",value:function(e,t,r){this._sendUserAck("","p2server",e,t,r)}},{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,i)}},{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,i)}},{key:"countServerMessage",value:function(e,t,r,n){this.sendP2serverMessage(t),e?(n=n||{},this.sendP2serveAck(Date.now()-r,n.s2s_time||0,n.s2e_time||0)):this.sendP2serverFail(n)}},{key:"destroy",value:function(){this._reset(),clearTimeout(this._timer)}}]),e}(),setGlobalStats=function(e){commonReportor.setCommonStats(e)},setReportUrl=function(e){commonReportor.setUrl(e)},enableErrorBuffer=function(){commonReportor.enableErrorBuffer()},globalMonitor=new Monitor("global"),reportGlobalApiCall=function(e,t,r){globalMonitor.report("rtc_sdk_api_call",{sdk_api_name:e,error_code:t,message:r})},reportGlobalCallback=function(e,t,r){globalMonitor.report("rtc_sdk_callback",{sdk_callback_name:e,error_code:t,message:r})},reportGlobalError=function(e,t,r){globalMonitor.report("rtc_error",{message:e,error_code:t},r)},reportGlobalInvokeStatus=function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"",i=arguments.length>4?arguments[4]:void 0;globalMonitor.report("rtc_invoke_status",{sdk_api_name:e,message:t,error_code:r,stream_id:n,elapse:0},i)},monitorMap=new map2,getMonitor=function(e){return monitorMap.get(e)},createMonitor=function(e,t){var r=new Monitor(e);return r.set(_objectSpread2(_objectSpread2({},t),{},{engine_session_id:genUuid$1()})),r.report("sdk_init_engine",{start:Date.now(),type:"begin"}),monitorMap.set(e,r),r},destroyMonitor=function(e){e.report("sdk_init_engine",{start:Date.now(),type:"end"}),monitorMap.delete(e.id)};function reportRtcSdkApiCall(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return function(e,r,n){if("function"==typeof n.value){var i=n.value;n.value=function(){for(var e,n=arguments.length,o=new Array(n),a=0;a<n;a++)o[a]=arguments[a];var s,c,l=this.engineId||this.id,u={};(t.forEach((function(e,t){u[e]=o[t]})),"joinRoom"===r)&&(null===(s=getMonitor(l))||void 0===s||s.set({room_id:o[1],user_id:null===(c=o[2])||void 0===c?void 0:c.userId}));null===(e=getMonitor(l))||void 0===e||e.report("rtc_sdk_api_call",{sdk_api_name:r,message:stringify$1(reportParamsCheck(o)),error_code:0},u);var d=i.apply(this,o);return"function"==typeof(null==d?void 0:d.then)?d.then((function(e){return reportRtcSdkCallback(l,r,[e||{}]),e})).catch((function(e){throw reportRtcSdkCallback(l,r,e.message,e.code),e})):(reportRtcSdkCallback(l,r,[d||{}]),d)}}}}var reportRtcSdkCallback=function(e,t,r){var n,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,o=arguments.length>4?arguments[4]:void 0,a={sdk_callback_name:t,error_code:i,message:stringify$1(Array.isArray(r)?reportParamsCheck(r):r)};o&&(a.room_id=o),null===(n=getMonitor(e))||void 0===n||n.report("rtc_sdk_callback",a)},reportRtcInvokeStatus=function(e,t,r){var n,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:"",a=arguments.length>5?arguments[5]:void 0;null===(n=getMonitor(e))||void 0===n||n.report("rtc_invoke_status",{sdk_api_name:t,message:r,error_code:i,stream_id:o,elapse:0},a)},maxBinaryLength=10;function reportParamsCheck(e){return map$6(e).call(e,(function e(t){var r;if(null!=t&&t._reportName)return t._reportName;if(t instanceof HTMLElement)return t.toString();if(t instanceof ArrayBuffer||ArrayBuffer.isView(t)){var n,i,o=ArrayBuffer.isView(t)?t.buffer:t,a=o.byteLength,s=[];if(a>maxBinaryLength){var c,l,u,d,p=new DataView(o),_=map$6(c=from$2({length:maxBinaryLength/2})).call(c,(function(e,t){return p.getUint8(t)})),h=map$6(l=map$6(u=from$2({length:maxBinaryLength/2})).call(u,(function(e,t){return a-1-t})).reverse()).call(l,(function(e){return p.getUint8(e)}));s=concat$2(d=[]).call(d,_toConsumableArray(_),["..."],_toConsumableArray(h))}else s=from$2(new Uint8Array(o));return concat$2(n=concat$2(i="".concat(t.constructor.name,"(")).call(i,a,") [")).call(n,s.join(", "),"]")}if(t instanceof ImageData)return"ImageData";if(Array.isArray(t))return map$6(t).call(t,e);if(includes4(r=["[object Object]","[object MediaStreamTrack]"]).call(r,Object.prototype.toString.call(t))){var f={};for(var m in t)f[m]=e(t[m]);return f}return t}))}var getServerConfig=function(e){var t,r=getMonitor(e.engineId),n={keys:keys$1(e),labelSelector:"",sdkVersion:e.sdkVersion,deviceType:"web",appId:e.appId},i=map$6(t=e.requestDomains).call(t,(function(e){return"https://".concat(e,"/decision/v1/multi")}));null==r||r.report("rtc_get_config",{error_code:0,message:stringify$1(n),elapse:0,host:i.join(","),type:"request",config_id:"",enable_cloud_proxy:!1});var o=map$6(i).call(i,function(){var e=_asyncToGenerator(_regeneratorRuntime().mark((function e(t,r){var i;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,fetch(t,{method:"POST",body:stringify$1(n)}).then((function(e){return e.json()}));case 2:return i=e.sent,e.abrupt("return",{result:i,index:r});case 4:case"end":return e.stop()}}),e)})));return function(t,r){return e.apply(this,arguments)}}());return new promise((function(e){promiseAny$1(o).then((function(t){var n=t.result,o=t.index;null==r||r.report("rtc_get_config",{error_code:200,message:stringify$1(n),elapse:0,host:i[o],type:"response",config_id:"",enable_cloud_proxy:!1}),e(n)})).catch((function(e){var t;null==r||r.report("rtc_get_config",{error_code:500,message:null===(t=e[0])||void 0===t?void 0:t.message,elapse:0,host:"",type:"response",config_id:"",enable_cloud_proxy:!1})}))}))},libTypedarrays={exports:{}},$$r=_export,global$4=global$s;$$r({global:!0,forced:global$4.globalThis!==global$4},{globalThis:global$4});var globalThis$6=global$s,parent$k=globalThis$6,globalThis$5=parent$k,parent$j=globalThis$5,globalThis$4=parent$j,parent$i=globalThis$4,globalThis$3=parent$i,globalThis$2=globalThis$3,globalThis$1=globalThis$2,core={exports:{}};!function(e,t){var r;core.exports=(r=r||function(e,t){var r;if("undefined"!=typeof window&&window.crypto&&(r=window.crypto),"undefined"!=typeof self&&self.crypto&&(r=self.crypto),void 0!==globalThis$1&&globalThis$1.crypto&&(r=globalThis$1.crypto),!r&&"undefined"!=typeof window&&window.msCrypto&&(r=window.msCrypto),!r&&void 0!==commonjsGlobal&&commonjsGlobal.crypto&&(r=commonjsGlobal.crypto),!r&&"function"==typeof commonjsRequire)try{r=require("crypto")}catch(e){}var n=function(){if(r){if("function"==typeof r.getRandomValues)try{return r.getRandomValues(new Uint32Array(1))[0]}catch(e){}if("function"==typeof r.randomBytes)try{return r.randomBytes(4).readInt32LE()}catch(e){}}throw new Error("Native crypto module could not be used to get secure random number.")},i=Object.create||function(){function e(){}return function(t){var r;return e.prototype=t,r=new e,e.prototype=null,r}}(),o={},a=o.lib={},s=a.Base={extend:function(e){var t=i(this);return e&&t.mixIn(e),t.hasOwnProperty("init")&&this.init!==t.init||(t.init=function(){t.$super.init.apply(this,arguments)}),t.init.prototype=t,t.$super=this,t},create:function(){var e=this.extend();return e.init.apply(e,arguments),e},init:function(){},mixIn:function(e){for(var t in e)e.hasOwnProperty(t)&&(this[t]=e[t]);e.hasOwnProperty("toString")&&(this.toString=e.toString)},clone:function(){return this.init.prototype.extend(this)}},c=a.WordArray=s.extend({init:function(e,r){e=this.words=e||[],this.sigBytes=r!=t?r:4*e.length},toString:function(e){return(e||u).stringify(this)},concat:function(e){var t=this.words,r=e.words,n=this.sigBytes,i=e.sigBytes;if(this.clamp(),n%4)for(var o=0;o<i;o++){var a=r[o>>>2]>>>24-o%4*8&255;t[n+o>>>2]|=a<<24-(n+o)%4*8}else for(var s=0;s<i;s+=4)t[n+s>>>2]=r[s>>>2];return this.sigBytes+=i,this},clamp:function(){var t=this.words,r=this.sigBytes;t[r>>>2]&=4294967295<<32-r%4*8,t.length=e.ceil(r/4)},clone:function(){var e,t=s.clone.call(this);return t.words=slice$1(e=this.words).call(e,0),t},random:function(e){for(var t=[],r=0;r<e;r+=4)t.push(n());return new c.init(t,e)}}),l=o.enc={},u=l.Hex={stringify:function(e){for(var t=e.words,r=e.sigBytes,n=[],i=0;i<r;i++){var o=t[i>>>2]>>>24-i%4*8&255;n.push((o>>>4).toString(16)),n.push((15&o).toString(16))}return n.join("")},parse:function(e){for(var t=e.length,r=[],n=0;n<t;n+=2)r[n>>>3]|=_parseInt$6(e.substr(n,2),16)<<24-n%8*4;return new c.init(r,t/2)}},d=l.Latin1={stringify:function(e){for(var t=e.words,r=e.sigBytes,n=[],i=0;i<r;i++){var o=t[i>>>2]>>>24-i%4*8&255;n.push(String.fromCharCode(o))}return n.join("")},parse:function(e){for(var t=e.length,r=[],n=0;n<t;n++)r[n>>>2]|=(255&e.charCodeAt(n))<<24-n%4*8;return new c.init(r,t)}},p=l.Utf8={stringify:function(e){try{return decodeURIComponent(escape(d.stringify(e)))}catch(e){throw new Error("Malformed UTF-8 data")}},parse:function(e){return d.parse(unescape(encodeURIComponent(e)))}},_=a.BufferedBlockAlgorithm=s.extend({reset:function(){this._data=new c.init,this._nDataBytes=0},_append:function(e){var t;"string"==typeof e&&(e=p.parse(e)),concat$2(t=this._data).call(t,e),this._nDataBytes+=e.sigBytes},_process:function(t){var r,n=this._data,i=n.words,o=n.sigBytes,a=this.blockSize,s=o/(4*a),l=(s=t?e.ceil(s):e.max((0|s)-this._minBufferSize,0))*a,u=e.min(4*l,o);if(l){for(var d=0;d<l;d+=a)this._doProcessBlock(i,d);r=splice$3(i).call(i,0,l),n.sigBytes-=u}return new c.init(r,u)},clone:function(){var e=s.clone.call(this);return e._data=this._data.clone(),e},_minBufferSize:0});a.Hasher=_.extend({cfg:s.extend(),init:function(e){this.cfg=this.cfg.extend(e),this.reset()},reset:function(){_.reset.call(this),this._doReset()},update:function(e){return this._append(e),this._process(),this},finalize:function(e){return e&&this._append(e),this._doFinalize()},blockSize:16,_createHelper:function(e){return function(t,r){return new e.init(r).finalize(t)}},_createHmacHelper:function(e){return function(t,r){return new h.HMAC.init(e,r).finalize(t)}}});var h=o.algo={};return o}(Math),r)}(),function(e,t){var r;libTypedarrays.exports=(r=core.exports,function(){if("function"==typeof ArrayBuffer){var e=r.lib.WordArray,t=e.init,n=e.init=function(e){if(e instanceof ArrayBuffer&&(e=new Uint8Array(e)),(e instanceof Int8Array||"undefined"!=typeof Uint8ClampedArray&&e instanceof Uint8ClampedArray||e instanceof Int16Array||e instanceof Uint16Array||e instanceof Int32Array||e instanceof Uint32Array||e instanceof Float32Array||e instanceof Float64Array)&&(e=new Uint8Array(e.buffer,e.byteOffset,e.byteLength)),e instanceof Uint8Array){for(var r=e.byteLength,n=[],i=0;i<r;i++)n[i>>>2]|=e[i]<<24-i%4*8;t.call(this,n,r)}else t.apply(this,arguments)};n.prototype=e}}(),r.lib.WordArray)}();var WordArray=libTypedarrays.exports,aes={exports:{}},encBase64={exports:{}};!function(e,t){var r;encBase64.exports=(r=core.exports,function(){var e=r,t=e.lib.WordArray;function n(e,r,n){for(var i=[],o=0,a=0;a<r;a++)if(a%4){var s=n[e.charCodeAt(a-1)]<<a%4*2|n[e.charCodeAt(a)]>>>6-a%4*2;i[o>>>2]|=s<<24-o%4*8,o++}return t.create(i,o)}e.enc.Base64={stringify:function(e){var t=e.words,r=e.sigBytes,n=this._map;e.clamp();for(var i=[],o=0;o<r;o+=3)for(var a=(t[o>>>2]>>>24-o%4*8&255)<<16|(t[o+1>>>2]>>>24-(o+1)%4*8&255)<<8|t[o+2>>>2]>>>24-(o+2)%4*8&255,s=0;s<4&&o+.75*s<r;s++)i.push(n.charAt(a>>>6*(3-s)&63));var c=n.charAt(64);if(c)for(;i.length%4;)i.push(c);return i.join("")},parse:function(e){var t=e.length,r=this._map,i=this._reverseMap;if(!i){i=this._reverseMap=[];for(var o=0;o<r.length;o++)i[r.charCodeAt(o)]=o}var a=r.charAt(64);if(a){var s=indexOf2(e).call(e,a);-1!==s&&(t=s)}return n(e,t,i)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="}}(),r.enc.Base64)}();var md5={exports:{}};!function(e,t){var r;md5.exports=(r=core.exports,function(e){var t=r,n=t.lib,i=n.WordArray,o=n.Hasher,a=t.algo,s=[];!function(){for(var t=0;t<64;t++)s[t]=4294967296*e.abs(e.sin(t+1))|0}();var c=a.MD5=o.extend({_doReset:function(){this._hash=new i.init([1732584193,4023233417,2562383102,271733878])},_doProcessBlock:function(e,t){for(var r=0;r<16;r++){var n=t+r,i=e[n];e[n]=16711935&(i<<8|i>>>24)|4278255360&(i<<24|i>>>8)}var o=this._hash.words,a=e[t+0],c=e[t+1],_=e[t+2],h=e[t+3],f=e[t+4],m=e[t+5],v=e[t+6],g=e[t+7],y=e[t+8],S=e[t+9],T=e[t+10],$=e[t+11],E=e[t+12],b=e[t+13],I=e[t+14],R=e[t+15],C=o[0],A=o[1],k=o[2],P=o[3];C=l(C,A,k,P,a,7,s[0]),P=l(P,C,A,k,c,12,s[1]),k=l(k,P,C,A,_,17,s[2]),A=l(A,k,P,C,h,22,s[3]),C=l(C,A,k,P,f,7,s[4]),P=l(P,C,A,k,m,12,s[5]),k=l(k,P,C,A,v,17,s[6]),A=l(A,k,P,C,g,22,s[7]),C=l(C,A,k,P,y,7,s[8]),P=l(P,C,A,k,S,12,s[9]),k=l(k,P,C,A,T,17,s[10]),A=l(A,k,P,C,$,22,s[11]),C=l(C,A,k,P,E,7,s[12]),P=l(P,C,A,k,b,12,s[13]),k=l(k,P,C,A,I,17,s[14]),C=u(C,A=l(A,k,P,C,R,22,s[15]),k,P,c,5,s[16]),P=u(P,C,A,k,v,9,s[17]),k=u(k,P,C,A,$,14,s[18]),A=u(A,k,P,C,a,20,s[19]),C=u(C,A,k,P,m,5,s[20]),P=u(P,C,A,k,T,9,s[21]),k=u(k,P,C,A,R,14,s[22]),A=u(A,k,P,C,f,20,s[23]),C=u(C,A,k,P,S,5,s[24]),P=u(P,C,A,k,I,9,s[25]),k=u(k,P,C,A,h,14,s[26]),A=u(A,k,P,C,y,20,s[27]),C=u(C,A,k,P,b,5,s[28]),P=u(P,C,A,k,_,9,s[29]),k=u(k,P,C,A,g,14,s[30]),C=d(C,A=u(A,k,P,C,E,20,s[31]),k,P,m,4,s[32]),P=d(P,C,A,k,y,11,s[33]),k=d(k,P,C,A,$,16,s[34]),A=d(A,k,P,C,I,23,s[35]),C=d(C,A,k,P,c,4,s[36]),P=d(P,C,A,k,f,11,s[37]),k=d(k,P,C,A,g,16,s[38]),A=d(A,k,P,C,T,23,s[39]),C=d(C,A,k,P,b,4,s[40]),P=d(P,C,A,k,a,11,s[41]),k=d(k,P,C,A,h,16,s[42]),A=d(A,k,P,C,v,23,s[43]),C=d(C,A,k,P,S,4,s[44]),P=d(P,C,A,k,E,11,s[45]),k=d(k,P,C,A,R,16,s[46]),C=p(C,A=d(A,k,P,C,_,23,s[47]),k,P,a,6,s[48]),P=p(P,C,A,k,g,10,s[49]),k=p(k,P,C,A,I,15,s[50]),A=p(A,k,P,C,m,21,s[51]),C=p(C,A,k,P,E,6,s[52]),P=p(P,C,A,k,h,10,s[53]),k=p(k,P,C,A,T,15,s[54]),A=p(A,k,P,C,c,21,s[55]),C=p(C,A,k,P,y,6,s[56]),P=p(P,C,A,k,R,10,s[57]),k=p(k,P,C,A,v,15,s[58]),A=p(A,k,P,C,b,21,s[59]),C=p(C,A,k,P,f,6,s[60]),P=p(P,C,A,k,$,10,s[61]),k=p(k,P,C,A,_,15,s[62]),A=p(A,k,P,C,S,21,s[63]),o[0]=o[0]+C|0,o[1]=o[1]+A|0,o[2]=o[2]+k|0,o[3]=o[3]+P|0},_doFinalize:function(){var t=this._data,r=t.words,n=8*this._nDataBytes,i=8*t.sigBytes;r[i>>>5]|=128<<24-i%32;var o=e.floor(n/4294967296),a=n;r[15+(i+64>>>9<<4)]=16711935&(o<<8|o>>>24)|4278255360&(o<<24|o>>>8),r[14+(i+64>>>9<<4)]=16711935&(a<<8|a>>>24)|4278255360&(a<<24|a>>>8),t.sigBytes=4*(r.length+1),this._process();for(var s=this._hash,c=s.words,l=0;l<4;l++){var u=c[l];c[l]=16711935&(u<<8|u>>>24)|4278255360&(u<<24|u>>>8)}return s},clone:function(){var e=o.clone.call(this);return e._hash=this._hash.clone(),e}});function l(e,t,r,n,i,o,a){var s=e+(t&r|~t&n)+i+a;return(s<<o|s>>>32-o)+t}function u(e,t,r,n,i,o,a){var s=e+(t&n|r&~n)+i+a;return(s<<o|s>>>32-o)+t}function d(e,t,r,n,i,o,a){var s=e+(t^r^n)+i+a;return(s<<o|s>>>32-o)+t}function p(e,t,r,n,i,o,a){var s=e+(r^(t|~n))+i+a;return(s<<o|s>>>32-o)+t}t.MD5=o._createHelper(c),t.HmacMD5=o._createHmacHelper(c)}(Math),r.MD5)}();var evpkdf={exports:{}},sha1={exports:{}};!function(e,t){var r,n,i,o,a,s,c,l;sha1.exports=(l=core.exports,n=(r=l).lib,i=n.WordArray,o=n.Hasher,a=r.algo,s=[],c=a.SHA1=o.extend({_doReset:function(){this._hash=new i.init([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(e,t){for(var r=this._hash.words,n=r[0],i=r[1],o=r[2],a=r[3],c=r[4],l=0;l<80;l++){if(l<16)s[l]=0|e[t+l];else{var u=s[l-3]^s[l-8]^s[l-14]^s[l-16];s[l]=u<<1|u>>>31}var d=(n<<5|n>>>27)+c+s[l];d+=l<20?1518500249+(i&o|~i&a):l<40?1859775393+(i^o^a):l<60?(i&o|i&a|o&a)-1894007588:(i^o^a)-899497514,c=a,a=o,o=i<<30|i>>>2,i=n,n=d}r[0]=r[0]+n|0,r[1]=r[1]+i|0,r[2]=r[2]+o|0,r[3]=r[3]+a|0,r[4]=r[4]+c|0},_doFinalize:function(){var e=this._data,t=e.words,r=8*this._nDataBytes,n=8*e.sigBytes;return t[n>>>5]|=128<<24-n%32,t[14+(n+64>>>9<<4)]=Math.floor(r/4294967296),t[15+(n+64>>>9<<4)]=r,e.sigBytes=4*t.length,this._process(),this._hash},clone:function(){var e=o.clone.call(this);return e._hash=this._hash.clone(),e}}),r.SHA1=o._createHelper(c),r.HmacSHA1=o._createHmacHelper(c),l.SHA1)}();var hmac={exports:{}};!function(e,t){var r,n,i,o;hmac.exports=(r=core.exports,i=(n=r).lib.Base,o=n.enc.Utf8,void(n.algo.HMAC=i.extend({init:function(e,t){e=this._hasher=new e.init,"string"==typeof t&&(t=o.parse(t));var r=e.blockSize,n=4*r;t.sigBytes>n&&(t=e.finalize(t)),t.clamp();for(var i=this._oKey=t.clone(),a=this._iKey=t.clone(),s=i.words,c=a.words,l=0;l<r;l++)s[l]^=1549556828,c[l]^=909522486;i.sigBytes=a.sigBytes=n,this.reset()},reset:function(){var e=this._hasher;e.reset(),e.update(this._iKey)},update:function(e){return this._hasher.update(e),this},finalize:function(e){var t,r=this._hasher,n=r.finalize(e);return r.reset(),r.finalize(concat$2(t=this._oKey.clone()).call(t,n))}})))}(),function(e,t){var r,n,i,o,a,s,c,l;evpkdf.exports=(l=core.exports,sha1.exports,hmac.exports,n=(r=l).lib,i=n.Base,o=n.WordArray,a=r.algo,s=a.MD5,c=a.EvpKDF=i.extend({cfg:i.extend({keySize:4,hasher:s,iterations:1}),init:function(e){this.cfg=this.cfg.extend(e)},compute:function(e,t){for(var r,n=this.cfg,i=n.hasher.create(),a=o.create(),s=a.words,c=n.keySize,l=n.iterations;s.length<c;){r&&i.update(r),r=i.update(e).finalize(t),i.reset();for(var u=1;u<l;u++)r=i.finalize(r),i.reset();concat$2(a).call(a,r)}return a.sigBytes=4*c,a}}),r.EvpKDF=function(e,t,r){return c.create(r).compute(e,t)},l.EvpKDF)}();var cipherCore={exports:{}};!function(e,t){var r;cipherCore.exports=(r=core.exports,evpkdf.exports,void(r.lib.Cipher||function(e){var t=r,n=t.lib,i=n.Base,o=n.WordArray,a=n.BufferedBlockAlgorithm,s=t.enc;s.Utf8;var c=s.Base64,l=t.algo.EvpKDF,u=n.Cipher=a.extend({cfg:i.extend(),createEncryptor:function(e,t){return this.create(this._ENC_XFORM_MODE,e,t)},createDecryptor:function(e,t){return this.create(this._DEC_XFORM_MODE,e,t)},init:function(e,t,r){this.cfg=this.cfg.extend(r),this._xformMode=e,this._key=t,this.reset()},reset:function(){a.reset.call(this),this._doReset()},process:function(e){return this._append(e),this._process()},finalize:function(e){return e&&this._append(e),this._doFinalize()},keySize:4,ivSize:4,_ENC_XFORM_MODE:1,_DEC_XFORM_MODE:2,_createHelper:function(){function e(e){return"string"==typeof e?y:v}return function(t){return{encrypt:function(r,n,i){return e(n).encrypt(t,r,n,i)},decrypt:function(r,n,i){return e(n).decrypt(t,r,n,i)}}}}()});n.StreamCipher=u.extend({_doFinalize:function(){return this._process(!0)},blockSize:1});var d=t.mode={},p=n.BlockCipherMode=i.extend({createEncryptor:function(e,t){return this.Encryptor.create(e,t)},createDecryptor:function(e,t){return this.Decryptor.create(e,t)},init:function(e,t){this._cipher=e,this._iv=t}}),_=d.CBC=function(){var t=p.extend();function r(t,r,n){var i,o=this._iv;o?(i=o,this._iv=e):i=this._prevBlock;for(var a=0;a<n;a++)t[r+a]^=i[a]}return t.Encryptor=t.extend({processBlock:function(e,t){var n=this._cipher,i=n.blockSize;r.call(this,e,t,i),n.encryptBlock(e,t),this._prevBlock=slice$1(e).call(e,t,t+i)}}),t.Decryptor=t.extend({processBlock:function(e,t){var n=this._cipher,i=n.blockSize,o=slice$1(e).call(e,t,t+i);n.decryptBlock(e,t),r.call(this,e,t,i),this._prevBlock=o}}),t}(),h=(t.pad={}).Pkcs7={pad:function(e,t){for(var r=4*t,n=r-e.sigBytes%r,i=n<<24|n<<16|n<<8|n,a=[],s=0;s<n;s+=4)a.push(i);var c=o.create(a,n);concat$2(e).call(e,c)},unpad:function(e){var t=255&e.words[e.sigBytes-1>>>2];e.sigBytes-=t}};n.BlockCipher=u.extend({cfg:u.cfg.extend({mode:_,padding:h}),reset:function(){var e;u.reset.call(this);var t=this.cfg,r=t.iv,n=t.mode;this._xformMode==this._ENC_XFORM_MODE?e=n.createEncryptor:(e=n.createDecryptor,this._minBufferSize=1),this._mode&&this._mode.__creator==e?this._mode.init(this,r&&r.words):(this._mode=e.call(n,this,r&&r.words),this._mode.__creator=e)},_doProcessBlock:function(e,t){this._mode.processBlock(e,t)},_doFinalize:function(){var e,t=this.cfg.padding;return this._xformMode==this._ENC_XFORM_MODE?(t.pad(this._data,this.blockSize),e=this._process(!0)):(e=this._process(!0),t.unpad(e)),e},blockSize:4});var f=n.CipherParams=i.extend({init:function(e){this.mixIn(e)},toString:function(e){return(e||this.formatter).stringify(this)}}),m=(t.format={}).OpenSSL={stringify:function(e){var t,r,n=e.ciphertext,i=e.salt;return(i?concat$2(t=concat$2(r=o.create([1398893684,1701076831])).call(r,i)).call(t,n):n).toString(c)},parse:function(e){var t,r=c.parse(e),n=r.words;return 1398893684==n[0]&&1701076831==n[1]&&(t=o.create(slice$1(n).call(n,2,4)),splice$3(n).call(n,0,4),r.sigBytes-=16),f.create({ciphertext:r,salt:t})}},v=n.SerializableCipher=i.extend({cfg:i.extend({format:m}),encrypt:function(e,t,r,n){n=this.cfg.extend(n);var i=e.createEncryptor(r,n),o=i.finalize(t),a=i.cfg;return f.create({ciphertext:o,key:r,iv:a.iv,algorithm:e,mode:a.mode,padding:a.padding,blockSize:e.blockSize,formatter:n.format})},decrypt:function(e,t,r,n){return n=this.cfg.extend(n),t=this._parse(t,n.format),e.createDecryptor(r,n).finalize(t.ciphertext)},_parse:function(e,t){return"string"==typeof e?t.parse(e,this):e}}),g=(t.kdf={}).OpenSSL={execute:function(e,t,r,n,i){var a;if(n||(n=o.random(8)),i)s=l.create({keySize:t+r,hasher:i}).compute(e,n);else var s=l.create({keySize:t+r}).compute(e,n);var c=o.create(slice$1(a=s.words).call(a,t),4*r);return s.sigBytes=4*t,f.create({key:s,iv:c,salt:n})}},y=n.PasswordBasedCipher=v.extend({cfg:v.cfg.extend({kdf:g}),encrypt:function(e,t,r,n){var i=(n=this.cfg.extend(n)).kdf.execute(r,e.keySize,e.ivSize,n.salt,n.hasher);n.iv=i.iv;var o=v.encrypt.call(this,e,t,i.key,n);return o.mixIn(i),o},decrypt:function(e,t,r,n){n=this.cfg.extend(n),t=this._parse(t,n.format);var i=n.kdf.execute(r,e.keySize,e.ivSize,t.salt,n.hasher);return n.iv=i.iv,v.decrypt.call(this,e,t,i.key,n)}})}()))}(),function(e,t){var r;aes.exports=(r=core.exports,encBase64.exports,md5.exports,evpkdf.exports,cipherCore.exports,function(){var e=r,t=e.lib.BlockCipher,n=e.algo,i=[],o=[],a=[],s=[],c=[],l=[],u=[],d=[],p=[],_=[];!function(){for(var e=[],t=0;t<256;t++)e[t]=t<128?t<<1:t<<1^283;var r=0,n=0;for(t=0;t<256;t++){var h=n^n<<1^n<<2^n<<3^n<<4;h=h>>>8^255&h^99,i[r]=h,o[h]=r;var f=e[r],m=e[f],v=e[m],g=257*e[h]^16843008*h;a[r]=g<<24|g>>>8,s[r]=g<<16|g>>>16,c[r]=g<<8|g>>>24,l[r]=g,g=16843009*v^65537*m^257*f^16843008*r,u[h]=g<<24|g>>>8,d[h]=g<<16|g>>>16,p[h]=g<<8|g>>>24,_[h]=g,r?(r=f^e[e[e[v^f]]],n^=e[e[n]]):r=n=1}}();var h=[0,1,2,4,8,16,32,64,128,27,54],f=n.AES=t.extend({_doReset:function(){if(!this._nRounds||this._keyPriorReset!==this._key){for(var e=this._keyPriorReset=this._key,t=e.words,r=e.sigBytes/4,n=4*((this._nRounds=r+6)+1),o=this._keySchedule=[],a=0;a<n;a++)a<r?o[a]=t[a]:(l=o[a-1],a%r?r>6&&a%r==4&&(l=i[l>>>24]<<24|i[l>>>16&255]<<16|i[l>>>8&255]<<8|i[255&l]):(l=i[(l=l<<8|l>>>24)>>>24]<<24|i[l>>>16&255]<<16|i[l>>>8&255]<<8|i[255&l],l^=h[a/r|0]<<24),o[a]=o[a-r]^l);for(var s=this._invKeySchedule=[],c=0;c<n;c++){if(a=n-c,c%4)var l=o[a];else l=o[a-4];s[c]=c<4||a<=4?l:u[i[l>>>24]]^d[i[l>>>16&255]]^p[i[l>>>8&255]]^_[i[255&l]]}}},encryptBlock:function(e,t){this._doCryptBlock(e,t,this._keySchedule,a,s,c,l,i)},decryptBlock:function(e,t){var r=e[t+1];e[t+1]=e[t+3],e[t+3]=r,this._doCryptBlock(e,t,this._invKeySchedule,u,d,p,_,o),r=e[t+1],e[t+1]=e[t+3],e[t+3]=r},_doCryptBlock:function(e,t,r,n,i,o,a,s){for(var c=this._nRounds,l=e[t]^r[0],u=e[t+1]^r[1],d=e[t+2]^r[2],p=e[t+3]^r[3],_=4,h=1;h<c;h++){var f=n[l>>>24]^i[u>>>16&255]^o[d>>>8&255]^a[255&p]^r[_++],m=n[u>>>24]^i[d>>>16&255]^o[p>>>8&255]^a[255&l]^r[_++],v=n[d>>>24]^i[p>>>16&255]^o[l>>>8&255]^a[255&u]^r[_++],g=n[p>>>24]^i[l>>>16&255]^o[u>>>8&255]^a[255&d]^r[_++];l=f,u=m,d=v,p=g}f=(s[l>>>24]<<24|s[u>>>16&255]<<16|s[d>>>8&255]<<8|s[255&p])^r[_++],m=(s[u>>>24]<<24|s[d>>>16&255]<<16|s[p>>>8&255]<<8|s[255&l])^r[_++],v=(s[d>>>24]<<24|s[p>>>16&255]<<16|s[l>>>8&255]<<8|s[255&u])^r[_++],g=(s[p>>>24]<<24|s[l>>>16&255]<<16|s[u>>>8&255]<<8|s[255&d])^r[_++],e[t]=f,e[t+1]=m,e[t+2]=v,e[t+3]=g},keySize:8});e.AES=t._createHelper(f)}(),r.AES)}();var encHex$1={exports:{}};encHex$1.exports=core.exports.enc.Hex;var encHex=encHex$1.exports,modeCtr={exports:{}};!function(e,t){var r,n,i;modeCtr.exports=(i=core.exports,cipherCore.exports,i.mode.CTR=(r=i.lib.BlockCipherMode.extend(),n=r.Encryptor=r.extend({processBlock:function(e,t){var r=this._cipher,n=r.blockSize,i=this._iv,o=this._counter;i&&(o=this._counter=slice$1(i).call(i,0),this._iv=void 0);var a=slice$1(o).call(o,0);r.encryptBlock(a,0),o[n-1]=o[n-1]+1|0;for(var s=0;s<n;s++)e[t+s]^=a[s]}}),r.Decryptor=n,r),i.mode.CTR)}();var ModeCTR=modeCtr.exports,padNopadding={exports:{}};!function(e,t){var r;padNopadding.exports=(r=core.exports,cipherCore.exports,r.pad.NoPadding={pad:function(){},unpad:function(){}},r.pad.NoPadding)}();var _navigator$userAgent$,_navigator$userAgent$2,_context4,_navigator$userAgent$3,_ref,_navigator$userAgent$4,_navigator$userAgent$5,_context5,PadNoPadding=padNopadding.exports,textDecoder=new TextDecoder,textEncoder=new TextEncoder,genUuid2=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),l=0,u=0,d=n;u<d.length;u++){var p=d[u];c.set(p,l),l+=p.length}return c}var isSSR2=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){var n;return window.btoa(filter3(n=[e,t,r]).call(n,(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=entries2(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 getBrowser(){var e="none";return isSSR2()||(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}function getStatsCallbackSupport(){if("chrome-stable"===getBrowser()){var e=window.navigator.userAgent.match(/Chrome\/([\d.]+)/);if(e&&e.length>1)if(Number(e[1].split(".")[0])<114)return!0}return!1}var isStatsCallbackSupport=getStatsCallbackSupport(),isFirefox="mozilla"===getBrowser(),isSafari="safari"===getBrowser(),sv=0,v=!isSSR2()&&(null===(_navigator$userAgent$=navigator.userAgent.match(/version\/(\d+)/i))||void 0===_navigator$userAgent$?void 0:_navigator$userAgent$[1]);isSafari&&v&&(sv=+v);var v2=!isSSR2()&&(null===(_navigator$userAgent$2=navigator.userAgent.match(/Firefox\/(\d+)/i))||void 0===_navigator$userAgent$2?void 0:_navigator$userAgent$2[1]);isFirefox&&v2&&(sv=+v2);var safariVersion=sv,firefoxVersion=sv,isIOS=!isSSR2()&&!!/(iPhone|iPad|iPod)/i.exec(navigator.userAgent);!isSSR2()&&/(iPhone|iPod)/i.exec(navigator.userAgent);var isIPad=!isSSR2()&&(!!/(iPad)/i.exec(navigator.userAgent)||/Macintosh/i.test(navigator.userAgent)&&"ontouchend"in document),isWeChat=!isSSR2()&&/MicroMessenger/i.test(navigator.userAgent),isAndroid=!isSSR2()&&/Android/i.test(navigator.userAgent),isMobile=!isSSR2()&&includes4(_context4=navigator.userAgent.toLowerCase()).call(_context4,"mobile"),cv=0,cvs=!isSSR2()&&(null===(_navigator$userAgent$3=navigator.userAgent.match(/chrome\/(\d+)/i))||void 0===_navigator$userAgent$3?void 0:_navigator$userAgent$3[1]);cvs&&(cv=+cvs);var chromeVersion=cv,iOSVersion=null!==(_ref=!isSSR2()&&(null===(_navigator$userAgent$4=navigator.userAgent.match(/ ([\d_]+) like Mac OS X/i))||void 0===_navigator$userAgent$4||null===(_navigator$userAgent$5=_navigator$userAgent$4[1])||void 0===_navigator$userAgent$5?void 0:map$6(_context5=_navigator$userAgent$5.split("_")).call(_context5,(function(e){return _parseInt$6(e)}))))&&void 0!==_ref?_ref:[],isCriOS=!isSSR2()&&/CriOS/i.test(navigator.userAgent);function createRandomId(){for(var e,t,r=(+padEnd2(e=slice$1(t="".concat(Math.random())).call(t,-7)).call(e,7,"0")).toString(2),n=padEnd2(r).call(r,28,"1").split(""),i=[];n.length;)i.push(splice$3(n).call(n,0,7));return map$6(i).call(i,(function(e,t){var r=t===i.length-1?"0":"1";return _parseInt(r+e.join(""),2)}))}!isSSR2()&&/SM-\w+/i.test(navigator.userAgent);var genEventSessionId=function(){return Math.floor(65535*Math.random())};function isByteId(e){return 128==(128&e)}function isRttMessage(e){return"string"==typeof e&&indexOf2(e).call(e,"__web__rtc__rtt__")>-1}function randomNum(e){for(var t="",r=0;r<e;r++)t+=Math.floor(10*Math.random());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],(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=8,r.createOffer();case 8:return n=e.sent,r.close(),e.abrupt("return",n.sdp);case 11:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),promiseAny2=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*log102(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 keys$8(e).forEach((function(r){"object"===_typeof(e[r])?t[r]=getPublicStats(e[r]):startsWith2(r).call(r,"_")||(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}function MediaTrackStringify(e){return null==e?"undefined | null":"string"==typeof e?e:stringify$1({contentHint:e.contentHint,enabled:e.enabled,id:e.id,kind:e.kind,label:e.label,muted:e.muted,readyState:e.readyState})}function MediaStreamStringify(e){return null==e?"undefined | null":"string"==typeof e?e:stringify$1({id:e.id,active:e.active})}function MediaSenderStringify(e){return null==e?"undefined | null":"string"==typeof e?e:stringify$1({track:MediaTrackStringify(e.track)})}function MediaReceiverStringify(e){return null==e?"undefined | null":"string"==typeof e?e:stringify$1({track:MediaTrackStringify(e.track)})}function MediaTransceiverStringify(e){return null==e?"undefined | null":"string"==typeof e?e:stringify$1({currentDirection:e.currentDirection,direction:e.direction,mid:e.mid,stopped:e.stopped,receiver:MediaReceiverStringify(e.receiver),sender:MediaSenderStringify(e.sender)})}function isUndefined(e){return void 0===e}function warnDeprecatedApi(e){return function(t,r,n){var i=n.value;n.value=function(){var t;console.warn(concat$2(t="[RTC WebSDK]: Api: ".concat(r," has been abandoned from version ")).call(t,e));for(var n=arguments.length,o=new Array(n),a=0;a<n;a++)o[a]=arguments[a];return i.apply(this,o)}}}function warnDevelopers(e){console.warn("[RTC WebSDK]: "+e)}function constraints2number(e){return"number"==typeof e?e:"number"==typeof(null==e?void 0:e.exact)?e.exact:"number"==typeof(null==e?void 0:e.ideal)?e.ideal:"number"==typeof(null==e?void 0:e.max)?e.max:"number"==typeof(null==e?void 0:e.min)?e.min:1}function setJoinRoomInfo(e,t,r){if("function"==typeof r.value){var n=r.value;r.value=function(){for(var e,t=getMonitor(this.id),r=arguments.length,i=new Array(r),o=0;o<r;o++)i[o]=arguments[o];return null==t||t.set({room_id:i[1],user_id:null===(e=i[2])||void 0===e?void 0:e.userId}),n.apply(this,i)}}}function base64ToUint8(e){for(var t=atob(e),r=t.length,n=new Uint8Array(r),i=0;i<r;i++)n[i]=t.charCodeAt(i);return n}function uint8ToBase64(e){for(var t="",r=e.byteLength,n=0;n<r;n++)t+=String.fromCharCode(e[n]);return btoa(t)}function aesCtrEncrypt(e,t,r){var n=uint8ArrayToWordArray(e),i=uint8ArrayToWordArray(t),o=uint8ArrayToWordArray(r);return wordArrayToUint8Array(aes.exports.encrypt(n,i,{iv:o,mode:ModeCTR,padding:PadNoPadding}).ciphertext)}function wordArrayToUint8Array(e){for(var t=e.toString(encHex),r=new Uint8Array(t.length/2),n=0;n<t.length;n+=2)r[n/2]=_parseInt$6(t.substr(n,2),16);return r}function uint8ArrayToWordArray(e){for(var t=[],r=0;r<e.length;r+=4)t.push(e[r]<<24|(e[r+1]||0)<<16|(e[r+2]||0)<<8|(e[r+3]||0));return WordArray.create(t,e.length)}var EngineEventsTypes=function(e){return e.onTrackEnded="onTrackEnded",e.onTrackMute="onTrackMute",e.onTrackUnmute="onTrackUnmute",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.onRemoteVideoFirstFrame="onRemoteVideoFirstFrame",e.onAudioFirstFrameDecoded="onAudioFirstFrameDecoded",e.onRemoteAudioFirstFrame="onRemoteAudioFirstFrame",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.onSubtitleStateChanged="onSubtitleStateChanged",e.onSubtitleMessageReceived="onSubtitleMessageReceived",e.onServerParamsSetResult="onServerParamsSetResult",e}(EngineEventsTypes||{}),PLATFORM_KEY="BytePlus",RTC_DEVICE_ID="RTC_DEVICE_ID",RTC_ACCESS_NODE="RTC_ACCESS_NODE",RTC_ACCESS_URLS="RTC_ACCESS_URLS",ENGINE_WEB_CONFIG="ENGINE_WEB_CONFIG",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,stringify$1(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(){var e,n;_classCallCheck(this,r);for(var i=arguments.length,o=new Array(i),a=0;a<i;a++)o[a]=arguments[a];return _defineProperty(_assertThisInitialized(n=t.call.apply(t,concat$2(e=[this]).call(e,o))),"_accessVersion","v2"),n}return _createClass(r,[{key:"getDeviceId",value:function(){if(isSSR2())return"";var e=this.get(RTC_DEVICE_ID);return e&&!/^[0-9a-f]{8}(-[0-9a-f]{4}){3}-[0-9a-f]{12}$/.test(e)||(e=randomNum(30)),this.setDeviceId(e),e}},{key:"setDeviceId",value:function(e){return setGlobalStats({device_id:e}),this.set(RTC_DEVICE_ID,e),e}},{key:"getAccessNode",value:function(e){var t,r;return this.get(concat$2(t=concat$2(r="".concat(RTC_ACCESS_NODE,"_").concat(e,"-")).call(r,PLATFORM_KEY,"-")).call(t,this._accessVersion))}},{key:"setAccessNode",value:function(e,t,r){var n,i;return this.set(concat$2(n=concat$2(i="".concat(RTC_ACCESS_NODE,"_").concat(e,"-")).call(i,PLATFORM_KEY,"-")).call(n,this._accessVersion),t,1e3*r)}},{key:"clearAccessNode",value:function(e){var t;this.delete(concat$2(t="".concat(RTC_ACCESS_NODE,"_").concat(e,"-")).call(t,PLATFORM_KEY))}},{key:"getAccessUrls",value:function(){return this.get("".concat(RTC_ACCESS_URLS,"-").concat(PLATFORM_KEY))}},{key:"setAccessUrls",value:function(e){var t=map$6(e).call(e,(function(e){var t,r=e.host,n=e.path;return concat$2(t="https://".concat(r)).call(t,n)}));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:"getEngineWebConfig",value:function(e,t){var r,n,i,o=concat$2(r=concat$2(n="".concat(e,"_")).call(n,t,"_")).call(r,this.getDeviceId()),a=this.get(ENGINE_WEB_CONFIG);return(null==a||null===(i=find$2(a).call(a,(function(e){return e.key===o})))||void 0===i?void 0:i.config)||{}}},{key:"setEngineWebConfig",value:function(e,t,r){var n,i;if(r){var o=concat$2(n=concat$2(i="".concat(e,"_")).call(i,t,"_")).call(n,this.getDeviceId()),a=this.get(ENGINE_WEB_CONFIG)||[];return(a=filter3(a).call(a,(function(e){return e.key!==o}))).push({key:o,config:r}),this.set(ENGINE_WEB_CONFIG,slice$1(a).call(a,-5))}}}]),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.52.8",ICE_CONFIG_REQUEST_URLS_INTERNAL:map$6(internalAccessDomains).call(internalAccessDomains,getFullAccessUrl),ICE_CONFIG_REQUEST_URLS:[],EXPECTED_ADDR:"",LOG_SERVER_URL:domesticLogServerUrl,CONFIG_REQUEST_DOMAINS:configDomains,DEVICE_ID:"",OVERSEA:!1,PLATFORM:"",PRODUCT:"",FORCE_ENABLED_REPORT_CALLBACKS:[],SKIP_WEB_AUDIO_IN_TRACK:!1,AUDIO_STALL:!0,VIDEO_STALL:!0,STATS_SCALLBACK_SUPPORT:!0,ENABLE_REPORT_ERROR_BUFFER:!1,PUB_SUB_MODE:"recv_and_send"};function setParameter(e,t){var r;if(reportGlobalApiCall("setParameter",0,concat$2(r="key: ".concat(e,", value: ")).call(r,t)),"VERSION"!==e){if("ICE_CONFIG_REQUEST_URLS"===e)return"string"==typeof t&&(t=[t]),void(Config.ICE_CONFIG_REQUEST_URLS=map$6(t).call(t,getFullAccessUrl));if("PLATFORM"!==e||"string"!=typeof t)if("PRODUCT"!==e||"string"!=typeof t){if("FORCE_ENABLED_REPORT_CALLBACKS"===e)return"string"==typeof t&&(t=[t]),void(Config.FORCE_ENABLED_REPORT_CALLBACKS=t);if("LOG_SERVER_URL"===e){var n=t===LogChannel.overseas?overseasLogServerUrl:t===LogChannel.domestic?domesticLogServerUrl:"string"==typeof t?t:void 0;n&&(Config.LOG_SERVER_URL=n,setReportUrl(n))}else if("OVERSEA"===e)return setGlobalStats({extra_is_oversea:t?"1":"0"}),void(Config.OVERSEA=t);"DEVICE_ID"===e&&sdkCache.setDeviceId(t),"ENABLE_REPORT_ERROR_BUFFER"===e&&t&&enableErrorBuffer(),Config[e]=t}else setGlobalStats({product:t});else setGlobalStats({platform:t})}}function getParameter(e){return"DEVICE_ID"===e?sdkCache.getDeviceId():Config[e]}function getPublicStreamControlMessage(e,t,r){var n,i,o,a,s,c,l,u,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===(l=r.layout)||void 0===l?void 0:l.backgroundImage)||""},regions:(null===(u=r.layout)||void 0===u||null===(d=u.regions)||void 0===d?void 0:map$6(d).call(d,(function(e){return{roomId:e.roomId,userId:e.userId,alterImage:e.alertImage||"",alpha:!e.alpha||+e.alpha>1||+e.alpha<=0?1:+e.alpha,x:!e.x||+e.x>=1||+e.x<0?0:+e.x,y:!e.y||+e.y>=1||+e.y<0?0:+e.y,w:!e.w||+e.w>1||+e.w<=0?1:+e.w,h:!e.h||+e.h>1||+e.h<=0?1:+e.h,zorder:!e.zorder||+e.zorder<0||+e.zorder>100?0:+e.zorder,renderMode:void 0===e.renderMode?1:e.renderMode,streamType:e.isScreenStream?1:0,mediaType:e.mediaType||0,sourceCrop:e.sourceCrop}})))||[]}}}}var defaultVideoEncoderConfig={width:640,height:480,frameRate:15,maxKbps:600},defaultScreenEncoderConfig={width:1920,height:1080,frameRate:15,maxKbps:3e3};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,o,a=new SDKError(ErrorCode.INVALID_PARAMS,concat$2(i=concat$2(o="Invalid ".concat(t,": the value range is [")).call(o,r,", ")).call(i,n,"]. integer only"));throw a}}function checkString(e,t){var r,n,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,o=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,i,o))throw new SDKError(ErrorCode.INVALID_PARAMS,concat$2(r=concat$2(n="Invalid ".concat(t,": The value should be string type. Length of the string: [")).call(n,i,",")).call(r,o,"]"))}function checkEnum(e,t,r){var n;if(!includes4(r).call(r,e))throw new SDKError(ErrorCode.INVALID_PARAMS,concat$2(n="Invalid ".concat(t,": The value can only be set as ")).call(n,stringify$1(r)))}function checkMediaStreamTrack(e){if(!(e instanceof MediaStreamTrack))throw new SDKError(ErrorCode.INVALID_PARAMS,"Invalid track, The value should be MediaStreamTrack type.")}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=keys$8(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"),isEmpty(e.roomProfileType)||checkEnum(e.roomProfileType,"roomConfig",[RoomProfileType.communication,RoomProfileType.chat,RoomProfileType.chatRoom,RoomProfileType.coHost,RoomProfileType.meeting,RoomProfileType.classRoom])}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(stringify$1(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){var t,r=getParameter("FORCE_ENABLED_REPORT_CALLBACKS");return!(null==r||!includes4(r).call(r,e))||!includes4(t=[EngineEventsTypes.onRemoteStreamStats,EngineEventsTypes.onLocalStreamStats,EngineEventsTypes.onAudioVolumeIndication,EngineEventsTypes.onLocalAudioPropertiesReport,EngineEventsTypes.onRemoteAudioPropertiesReport]).call(t,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")}function checkConstrainULongg(e,t){if("number"!=typeof e||Number.isNaN(e)||!(e>=1)){var r=e;if(!(null!=r&&r.min||null!=r&&r.max||null!=r&&r.exact||null!=r&&r.ideal))throw new SDKError(ErrorCode.INVALID_PARAMS,"".concat(t," is not a valid ConstrainULong"))}}function checkVideoEncoderConfig(e){var t,r=_createForOfIteratorHelper(e);try{for(r.s();!(t=r.n()).done;){var n=t.value;checkNumber(null==n?void 0:n.maxKbps,"maxKbps"),checkConstrainULongg(null==n?void 0:n.width,"width"),checkConstrainULongg(null==n?void 0:n.height,"height"),checkConstrainULongg(null==n?void 0:n.frameRate,"frameRate")}}catch(e){r.e(e)}finally{r.f()}}function numberRangeGuide(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:Number.NEGATIVE_INFINITY,n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:Number.POSITIVE_INFINITY;return checkNumber(e,t,Number.NEGATIVE_INFINITY,Number.POSITIVE_INFINITY),e=(e=e>r?e:r)<n?e:n}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?slice$1(n).call(n,1):n);return getOwnPropertySymbols2?concat$2(i).call(i,getOwnPropertySymbols2(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,l,u=this._events[s],d=arguments.length;if(u.fn){switch(u.once&&this.removeListener(e,u.fn,void 0,!0),d){case 1:return u.fn.call(u.context),!0;case 2:return u.fn.call(u.context,t),!0;case 3:return u.fn.call(u.context,t,n),!0;case 4:return u.fn.call(u.context,t,n,i),!0;case 5:return u.fn.call(u.context,t,n,i,o),!0;case 6:return u.fn.call(u.context,t,n,i,o,a),!0}for(l=1,c=new Array(d-1);l<d;l++)c[l-1]=arguments[l];u.fn.apply(u.context,c)}else{var p,_=u.length;for(l=0;l<_;l++)switch(u[l].once&&this.removeListener(e,u[l].fn,void 0,!0),d){case 1:u[l].fn.call(u[l].context);break;case 2:u[l].fn.call(u[l].context,t);break;case 3:u[l].fn.call(u[l].context,t,n);break;case 4:u[l].fn.call(u[l].context,t,n,i);break;default:if(!c)for(p=1,c=new Array(d-1);p<d;p++)c[p-1]=arguments[p];u[l].fn.apply(u[l].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,l=[],u=s.length;c<u;c++)(s[c].fn!==t||i&&!s[c].once||n&&s[c].context!==n)&&l.push(s[c]);l.length?this._events[o]=1===l.length?l[0]:l: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,logger$m=new Logger("VERTC",0),EnhancedEventEmitter=function(e){_inherits(r,eventemitter3.exports.EventEmitter);var t=_createSuper(r);function r(){return _classCallCheck(this,r),t.apply(this,arguments)}return _createClass(r,[{key:"safeEmit",value:function(e){var t=this.listenerCount(e);try{for(var n,i,o=arguments.length,a=new Array(o>1?o-1:0),s=1;s<o;s++)a[s-1]=arguments[s];return(n=_get(_getPrototypeOf(r.prototype),"emit",this)).call.apply(n,concat$2(i=[this,e]).call(i,a))}catch(r){return logger$m.print("safeEmit","safeEmit() | event listener threw an error [event:%s]:%o",e,r),console.error(r),Boolean(t)}}}]),r}(),$$q=_export,call$a=functionCall,anObject$h=anObject$M,isObject$4=isObject$q,isDataDescriptor=isDataDescriptor$2,fails$1=fails$z,definePropertyModule=objectDefineProperty,getOwnPropertyDescriptorModule=objectGetOwnPropertyDescriptor,getPrototypeOf2=objectGetPrototypeOf,createPropertyDescriptor$1=createPropertyDescriptor$9;function set$c(e,t,r){var n,i,o,a=arguments.length<4?e:arguments[3],s=getOwnPropertyDescriptorModule.f(anObject$h(e),t);if(!s){if(isObject$4(i=getPrototypeOf2(e)))return set$c(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$a(o,a,r)}return!0}var MS_EDGE_BUG=fails$1((function(){var e=function(){},t=definePropertyModule.f(new e,"a",{configurable:!0});return!1!==Reflect.set(e.prototype,"a",1,t)}));$$q({target:"Reflect",stat:!0,forced:MS_EDGE_BUG},{set:set$c});var path$3=path$v,set$b=path$3.Reflect.set,parent$h=set$b,set$a=parent$h,parent$g=set$a,set$9=parent$g,parent$f=set$9,set$8=parent$f,set$7=set$8,set$6=set$7;function _objectWithoutPropertiesLoose(e,t){if(null==e)return{};var r,n,i={},o=keys$8(e);for(n=0;n<o.length;n++)r=o[n],indexOf2(t).call(t,r)>=0||(i[r]=e[r]);return i}function _objectWithoutProperties(e,t){if(null==e)return{};var r,n,i=_objectWithoutPropertiesLoose(e,t);if(getOwnPropertySymbols2){var o=getOwnPropertySymbols2(e);for(n=0;n<o.length;n++)r=o[n],indexOf2(t).call(t,r)>=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(i[r]=e[r])}return i}var _USER_MESSAGE_SEND_RE,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_ADD_STREAM_LIST="onAddStreamList",e.ON_REMOVE_STREAM="onRemoveStream",e.ON_REMOVE_STREAM_LIST="onRemoveStreamList",e.USER_DISCONNECTION="userDisconnection",e.USER_DISCONNECTION_LIST="userDisconnectionList",e.USER_CONNECTION="userConnection",e.USER_CONNECTION_LIST="userConnectionList",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_SPEAKER_CHANGE="onSpeakerChange",e.ON_STREAM_FAILED="streamFailed",e}(SignalEvent||{}),MediaServerSignalEvent=function(e){return e.RSCP="RSCP",e.RTT="RTT",e.SSC="SSC",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.EXCEED_QPS=5]="EXCEED_QPS",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.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_RECEIVER,"cannot find relay path."]),_defineProperty(_USER_MESSAGE_SEND_RE,5,[ErrorCode.USER_MESSAGE_EXCEED_QPS,"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,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$l=new Logger("DataChannelSignaling",3),noPrintSignaling=["onSpeakerChange"],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,P2P_MESSAGE_TIMEOUT=12e3,DataChannelSignaling=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)),"_singlingCache",new map2),_defineProperty(_assertThisInitialized(r),"_p2pCache",new map2),_defineProperty(_assertThisInitialized(r),"_rttIds",{}),_defineProperty(_assertThisInitialized(r),"_p2pMessageId",0),_defineProperty(_assertThisInitialized(r),"_clearDataChannelListener",void 0),_defineProperty(_assertThisInitialized(r),"_monitor",void 0),r.id=e,r._dataChannel=t,r._clearDataChannelListener=r._handleHandler(),r._monitor=getMonitor(e),window.__rtc_mock_signaling__=r.emit.bind(_assertThisInitialized(r)),r}return _createClass(a,[{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,i=this;return null===(n=this._monitor)||void 0===n||n.report("rtc_signaling",{error_code:0,message:stringify$1(t),signaling_event:"call-".concat(e),signaling_type:"Send",stream_id:t.streamId,stream_user_id:t.streamUserId,direction:"up"}),new promise((function(n,o){var a,s=i._genHeader(r);s.id=createRandomId();var c=s.id.join("-"),l="customMessage"===e;l&&RTSMsgReportor.samplingOne2ManyMsg(i.id,+s.id.join(""),t);var u=setTimeout((function(){i._singlingCache.delete(c),o(new SDKError(ErrorCode.TIME_OUT,"".concat(e," message time out"))),l&&RTSMsgReportor.updateOne2ManyMsgAck(i.id,t,999)}),DATA_CHANNEL_MESSAGE_TIMEOUT);i._singlingCache.set(c,{signalingType:e,success:function(e){clearTimeout(u),n(e),l&&RTSMsgReportor.updateOne2ManyMsgAck(i.id,t,0)},error:function(e){clearTimeout(u),o(e),l&&RTSMsgReportor.updateOne2ManyMsgAck(i.id,t,e.code)}}),logger$l.print("Signal",concat$2(a=">>>>>> [".concat(e,"][")).call(a,c,"]"),t),i._sendMessage(e,s,t)}))}},{key:"sendPingSignaling",value:function(){return this.sendSignaling("CheckConnectivity",{ts:Date.now()},{functionType:2})}},{key:"sendP2PMessage",value:(i=_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=RTSMsgReportor,e.t2=this.id,e.t3=_objectSpread2,e.t4=_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.t5={},e.t6=o,!o){e.next=15;break}return e.next=12,Utils.ab2b64str(n);case 12:e.t7=e.sent,e.next=16;break;case 15:e.t7=n;case 16:return e.t8=e.t7,e.t9={binary:e.t6,msg:e.t8},e.t10=(0,e.t3)(e.t4,e.t5,e.t9),e.t11=e.t1.samplingP2PMsg.call(e.t1,e.t2,e.t10),e.t12=r,e.abrupt("return",e.t0._sendP2PMessage.call(e.t0,e.t11,e.t12));case 22:case"end":return e.stop()}}),e,this)}))),function(e,t){return i.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$l.print("_sendP2PMessage [DC Signaling p2p >>]",stringify$1(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.USER_MESSAGE_TIMEOUT,"P2P message timeout")),RTSMsgReportor.updateP2PMsgAck(t.id,e,999)}),P2P_MESSAGE_TIMEOUT);t._p2pCache.set(e.id,{success:function(r,i){clearTimeout(a),n(i),RTSMsgReportor.updateP2PMsgAck(t.id,e,0)},error:function(r){var n;clearTimeout(a),RTSMsgReportor.updateP2PMsgAck(t.id,e,r.err);var o=_slicedToArray(USER_MESSAGE_SEND_RESULT_EXPLAIN[r.err]||[ErrorCode.USER_MESSAGE_UNKNOWN,concat$2(n="err: ".concat(r.err,", msg: ")).call(n,r.msg)],2),s=o[0],c=o[1];i({err:r.err,code:s,message:r.msg||c})}})}try{t._sendMessage("p2p",o,e)}catch(e){throw e.code===ErrorCode.SIGNALING_CHANNEL_NOT_OPEN&&(e.code=ErrorCode.USER_MESSAGE_BROKEN),e}}))}},{key:"_sendMessage",value:function(e,t,r){var n;if(!this._dataChannel||"open"!==this._dataChannel.readyState)throw new SDKError(ErrorCode.SIGNALING_CHANNEL_NOT_OPEN,"DataChannel not open");var i=t.version+(+t.zip<<5)+(+t.encrypt<<6),o=+t.needAck+(+t.direction<<1)+(+t.functionType<<2)+(+t.binary<<6),a=Utils.str2ab(stringify$1([e,r])),s=concatenate(Uint8Array,concat$2(n=[i,o]).call(n,_toConsumableArray(t.id||[])),new Uint8Array(a));this._dataChannel.send(s.buffer),"p2p"===e?RTSMsgReportor.updateP2PMsgReq(this.id,r,s.buffer.byteLength):"customMessage"===e&&RTSMsgReportor.updateOne2ManyMsgReq(this.id,r,s.buffer.byteLength)}},{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=from$2(slice$1(t).call(t,2,r))}return{header:o,data:slice$1(t).call(t,r)}}},{key:"_feedbackSignaling",value:function(e,t,r){var n,i,o=this._genHeader({needAck:!0,direction:1,id:map$6(n=e.split("-")).call(n,(function(e){return+e}))});includes4(noPrintSignaling).call(noPrintSignaling,t)||logger$l.print("Signal",concat$2(i=">>>>>> [".concat(t,"-res][")).call(i,e,"]"));this._sendMessage("".concat(t,"-res"),o,r)}},{key:"_handleMessage",value:(n=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){var r,n,i,o,a,s,c,l,u;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:r=Date.now(),n=t.byteLength,i=this._dispartData(t),o=i.data,(a=i.header).zip&&((s=new pako_1.Inflate).push(o,!0),o=s.result),c=Utils.ab2str(o),l=[],e.prev=8,l=JSON.parse(c),e.next=16;break;case 12:return e.prev=12,e.t0=e.catch(8),e.t0 instanceof Error&&(null===(u=this._monitor)||void 0===u||u.report("rtc_signaling_msg_error",{error_code:-1,message:e.t0.message,reason:"message parse failed"})),e.abrupt("return");case 16:e.t1=a.functionType,e.next=0===e.t1?19:1===e.t1?21:2===e.t1?23:25;break;case 19:return this.C2S(a,l,c,n,r),e.abrupt("break",26);case 21:return this.C2C(l,n,r),e.abrupt("break",26);case 23:return this.C2GW(a,l,c),e.abrupt("break",26);case 25:return e.abrupt("break",26);case 26:case"end":return e.stop()}}),e,this,[[8,12]])}))),function(e){return n.apply(this,arguments)})},{key:"C2S",value:(r=_asyncToGenerator(_regeneratorRuntime().mark((function e(t,r,n,i,o){var a,s,c,l,u;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(s=(null===(a=t.id)||void 0===a?void 0:a.join("-"))||"",1!==t.direction){e.next=5;break}this._handleAckMessage(s,r[0]||{},n),e.next=18;break;case 5:if(!Array.isArray(r)){e.next=18;break}if(l=r[0],r=r[1],includes4(noPrintSignaling).call(noPrintSignaling,l)||logger$l.print("Signal","<<<<<< ".concat(l),r,s),this._feedbackSignaling(s,l,l===SignalEvent.ON_CUSTOM_MESSAGE?_objectSpread2(_objectSpread2({},r),{},{message:""}):""),!r.binary||"string"!=typeof r.message){e.next=14;break}return e.next=13,Utils.b64str2ab(r.message);case 13:r.message=e.sent;case 14:u=Date.now(),this.emit(l,_objectSpread2({},r)),l===SignalEvent.ON_CUSTOM_MESSAGE&&RTSMsgReportor.reportOne2ManyMsgRecv(this.id,r,{msg_size:i,recv_msg_ts:o,fwd_msg_ts:u}),null===(c=this._monitor)||void 0===c||c.report("rtc_signaling",{error_code:0,message:n,signaling_event:"on-".concat(l),signaling_type:"Recv",stream_id:r.streamId,stream_user_id:r.clientId,direction:"down"});case 18:case"end":return e.stop()}}),e,this)}))),function(e,t,n,i,o){return r.apply(this,arguments)})},{key:"C2C",value:(t=_asyncToGenerator(_regeneratorRuntime().mark((function e(t,r,n){var i,o,a,s,c,l,u,d,p,_,h,f,m;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:Array.isArray(t)&&(t=t[1]),c=null===(i=t)||void 0===i?void 0:i.id,this._rttIds[c]||(null===(o=t)||void 0===o?void 0:o.dir)===DC_MESSAGE_DIRECTION.FEEDBACK||isRttMessage(null===(a=t)||void 0===a?void 0:a.msg)?delete this._rttIds[c]:logger$l.print("Signal","<<<<<< p2p response",t),e.t0=t.dir,e.next=e.t0===DC_MESSAGE_DIRECTION.SEND?6:e.t0===DC_MESSAGE_DIRECTION.FEEDBACK?46:48;break;case 6:if(l=Date.now(),isRttMessage(null===(s=t)||void 0===s?void 0:s.msg)){e.next=43;break}if(d=(u=t).binary,p=u.msg,_=u.room,h=u.to,f=u.from,m=""===_?d?SignalEvent.USER_BINARY_MESSAGE_RECEIVED_OUTSIDE_ROOM:SignalEvent.USER_MESSAGE_RECEIVED_OUTSIDE_ROOM:d?SignalEvent.USER_BINARY_MESSAGE_RECEIVED:SignalEvent.USER_MESSAGE_RECEIVED,h){e.next=27;break}if(e.t1=this,e.t2=SignalEvent.ON_CUSTOM_MESSAGE,e.t3=f,e.t4=d,!d){e.next=21;break}return e.next=18,Utils.b64str2ab(p);case 18:e.t5=e.sent,e.next=22;break;case 21:e.t5=p;case 22:e.t6=e.t5,e.t7={clientId:e.t3,binary:e.t4,message:e.t6},e.t1.emit.call(e.t1,e.t2,e.t7),e.next=43;break;case 27:if(e.t8=this,e.t9=m,e.t10=_objectSpread2,e.t11=_objectSpread2({},t),e.t12={},!d){e.next=38;break}return e.next=35,Utils.b64str2ab(p);case 35:e.t13=e.sent,e.next=39;break;case 38:e.t13=p;case 39:e.t14=e.t13,e.t15={msg:e.t14},e.t16=(0,e.t10)(e.t11,e.t12,e.t15),e.t8.emit.call(e.t8,e.t9,e.t16);case 43:return this._sendP2PMessage(_objectSpread2(_objectSpread2({},t),{},{dir:DC_MESSAGE_DIRECTION.FEEDBACK,msg:""})),RTSMsgReportor.reportP2PMsgRecv(this.id,t,{msg_size:r,recv_msg_ts:n,fwd_msg_ts:l}),e.abrupt("break",49);case 46:return this._handleP2PMsgFeedback(t),e.abrupt("break",49);case 48:return e.abrupt("break",49);case 49:case"end":return e.stop()}}),e,this)}))),function(e,r,n){return t.apply(this,arguments)})},{key:"C2GW",value:function(e,t,r){if(1===e.direction){var n,i=(null===(n=e.id)||void 0===n?void 0:n.join("-"))||"";this._handleAckMessage(i,t[0]||{},r)}else{var o=_slicedToArray(t,2),a=o[0],s=o[1],c=void 0===s?{}:s;if("RXMediaMsg"===a){var l,u=c.type,d=c.data;switch(null===(l=this._monitor)||void 0===l||l.report("rtc_signaling",{error_code:0,message:r,signaling_event:"on-".concat(u),signaling_type:"Recv",stream_id:"",stream_user_id:"",direction:"down"}),u){case"RSCP":try{var p=JSON.parse(d);Array.isArray(p)&&this.emit(u,p)}catch(e){}break;case"RTT":try{var _=JSON.parse(d);_.length&&this.emit(u,_[0])}catch(e){}break;case"SSC":try{var h=JSON.parse(d);h.length&&this.emit(u,h[0])}catch(e){}}}}}},{key:"_handleHandler",value:function(){var e=this,t=function(t){logger$l.print("_handleHandler","dataChannel close",t),e.emit("close",t)},r=function(t){logger$l.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,i,o=this._singlingCache.get(e);o&&(this._singlingCache.delete(e),200===t.code?o.success(t):o.error(t),logger$l.print("Signal",concat$2(i="<<<<<< [".concat(o.signalingType,"-ack] ")).call(i,e),t));null===(n=this._monitor)||void 0===n||n.report("rtc_signaling",{error_code:0,message:r,signaling_event:null==o?void 0:o.signalingType,signaling_type:"Ack",stream_id:"",stream_user_id:"",direction:"down"})}},{key:"_handleP2PMsgFeedback",value:function(e){var t=this._p2pCache.get(e.id);t&&(this._p2pCache.delete(e.id),e.err===USER_MESSAGE_SEND_RESULT.SUCCESS?t.success(e.id,e):t.error(e))}}]),a}(),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,l=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,u=entries2(s);c<u.length;c++){var d=_slicedToArray(u[c],2),p=d[0],_=d[1];a.setRequestHeader(p,_)}a.onreadystatechange=function(){if(4===a.readyState)if(t.isSending=!1,200===a.status)e(JSON.parse(a.responseText));else{var r=a.statusText,n=a.status;if(a.responseText)try{var o=JSON.parse(a.responseText);o.errMessage&&(r=o.errMessage),o.code&&(n=o.code)}catch(e){}i({message:r,code:n})}},a.onabort=function(){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),l&&(o=stringify$1(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$k=new Logger("ICE Request",3),IceConfigRequestManager=function(){function e(t){_classCallCheck(this,e),_defineProperty(this,"_request",void 0),_defineProperty(this,"_monitor",void 0),this.id=t,this._request=new HttpRequest,this._monitor=getMonitor(this.id)}var t,r,n;return _createClass(e,[{key:"getAccessNode",value:(n=_asyncToGenerator(_regeneratorRuntime().mark((function e(t,r,n,i,o){var a;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(a=sdkCache.getAccessNode(t))){e.next=9;break}if(this.getAccessNodeFromServer(t,r,n,i,o),reportRtcInvokeStatus(this.id,"es.R.node.cache",a),!Array.isArray(a)){e.next=8;break}return e.abrupt("return",promise.resolve(a));case 8:return e.abrupt("return",promise.resolve([a]));case 9:return e.abrupt("return",this.getAccessNodeFromServer(t,r,n,i,o));case 10:case"end":return e.stop()}}),e,this)}))),function(e,t,r,i,o){return n.apply(this,arguments)})},{key:"getAccessNodeFromServer",value:(r=_asyncToGenerator(_regeneratorRuntime().mark((function e(t,r,n,i,o){var a,s,c,l,u=this;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return c=sdkCache.getAccessUrls(),l=!0,reportRtcInvokeStatus(this.id,"es.R.req.cache.urls",c),(null===(a=c)||void 0===a?void 0:a.length)>0||(c=Config.ICE_CONFIG_REQUEST_URLS,l=!1,reportRtcInvokeStatus(this.id,"es.R.req.external.urls",c)),(null===(s=c)||void 0===s?void 0:s.length)>0||(c=Config.ICE_CONFIG_REQUEST_URLS_INTERNAL,l=!1,reportRtcInvokeStatus(this.id,"es.R.req.internal.urls",c)),e.abrupt("return",this.getICEConfigFromServer(c,t,r,n,i,o).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(l)return reportRtcInvokeStatus(u.id,"es.R.req.fallback",""),sdkCache.clearAccessUrls(),u.getAccessNodeFromServer(t,r,n,i);throw e})));case 6:case"end":return e.stop()}}),e,this)}))),function(e,t,n,i,o){return r.apply(this,arguments)})},{key:"getICEConfigFromServer",value:(t=_asyncToGenerator(_regeneratorRuntime().mark((function e(t,r,n,i,o,a){var s,c,l,u,d,p=this;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return c={appID:r,deviceID:sdkCache.getDeviceId(),connectSessionID:genUuid2(),os:"web",sdkVersion:Config.VERSION,isOversea:Config.OVERSEA,expectedAddr:getParameter("EXPECTED_ADDR"),productPlatform:"BytePlus",accessParams:stringify$1({requireICEUfragV2:!0})},n&&i&&(c.feedbackInfo=[{feedbackIP:null===(l=i.publicIPs[0])||void 0===l?void 0:l.ip,feedbackReason:{type:"NODE_CHANGED",reason:n}}],delete c.expectedAddr),u=Date.now(),null===(s=this._monitor)||void 0===s||s.report("rtc_get_access",{error_code:0,message:stringify$1(c),elapse:0,type:"request",host:t.join(","),connect_session_id:c.connectSessionID}),d=map$6(t).call(t,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,p._request.post(t,c);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:stringify$1(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:stringify$1(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",promiseAny2(d).then((function(e){var r,n=e.result;e.firstNode;var i=e.index;return null===(r=p._monitor)||void 0===r||r.report("rtc_get_access",{error_code:200,message:stringify$1(n),elapse:Date.now()-u,type:"response",host:t[i],connect_session_id:c.connectSessionID}),n})).catch((function(e){var r,n,i,o=null===(r=e[0])||void 0===r?void 0:r.error;throw null===(n=p._monitor)||void 0===n||n.report("rtc_get_access",{error_code:+((null==o?void 0:o.code)||(null==o?void 0:o.server_code)),message:null===(i=e[0])||void 0===i?void 0:i.message,elapse:Date.now()-u,type:"response",host:t.join(","),connect_session_id:c.connectSessionID},{error:stringify$1(o)}),e})));case 6:case"end":return e.stop()}}),e,this)}))),function(e,r,n,i,o,a){return t.apply(this,arguments)})},{key:"abort",value:function(){this._request.isSending&&(logger$k.print("abort","HTTP Request of [getICEConfigFromServer] abort"),this._request.abort())}}]),e}(),WrappedWellKnownSymbolModule=wellKnownSymbolWrapped,asyncIterator$5=WrappedWellKnownSymbolModule.f("asyncIterator"),parent$e=asyncIterator$5,asyncIterator$4=parent$e,parent$d=asyncIterator$4,asyncIterator$3=parent$d,parent$c=asyncIterator$3,asyncIterator$2=parent$c,asyncIterator$1=asyncIterator$2,asyncIterator=asyncIterator$1;function _asyncIterator(e){var t,r,n,i=2;for(void 0!==symbol&&(r=asyncIterator,n=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}).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)}var simulcastFormats=[{maxLayers:3,totalPixels:2073600},{maxLayers:3,totalPixels:921600},{maxLayers:3,totalPixels:518400},{maxLayers:2,totalPixels:230400},{maxLayers:2,totalPixels:129600},{maxLayers:1,totalPixels:57600},{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}function fillSimulcastLayers(e,t){var r=[];if(t<=1)return r;var n=Math.min(e.width,e.height)/90;return r.push({scaleResolutionDownBy:n,width:Math.floor(e.width/n),height:Math.floor(e.height/n),maxkbps:100,frameRate:10}),t<=2||r.unshift({scaleResolutionDownBy:2,width:Math.floor(e.width/2),height:Math.floor(e.height/2),maxkbps:Math.floor(e.maxKbps/2),frameRate:e.frameRate>=30?Math.floor(e.frameRate/2):e.frameRate}),r}var collection$1=collection$3,collectionStrong=collectionStrong$2;collection$1("Set",(function(e){return function(){return e(this,arguments.length?arguments[0]:void 0)}}),collectionStrong);var path$2=path$v,set$5=path$2.Set,parent$b=set$5,set$4=parent$b,parent$a=set$4,set$3=parent$a,$$p=_export,from$1=collectionFrom;$$p({target:"Set",stat:!0,forced:!0},{from:from$1});var $$o=_export,of$1=collectionOf;$$o({target:"Set",stat:!0,forced:!0},{of:of$1});var call$9=functionCall,aCallable$a=aCallable$z,anObject$g=anObject$M,collectionAddAll=function(){for(var e=anObject$g(this),t=aCallable$a(e.add),r=0,n=arguments.length;r<n;r++)call$9(t,e,arguments[r]);return e},$$n=_export,addAll2=collectionAddAll;$$n({target:"Set",proto:!0,real:!0,forced:!0},{addAll:addAll2});var $$m=_export,deleteAll$1=collectionDeleteAll;$$m({target:"Set",proto:!0,real:!0,forced:!0},{deleteAll:deleteAll$1});var getIterator$2=getIterator$7,getSetIterator$7=getIterator$2,$$l=_export,anObject$f=anObject$M,bind$6=functionBindContext,getSetIterator$6=getSetIterator$7,iterate$e=iterate$A;$$l({target:"Set",proto:!0,real:!0,forced:!0},{every:function(e){var t=anObject$f(this),r=getSetIterator$6(t),n=bind$6(e,arguments.length>1?arguments[1]:void 0);return!iterate$e(r,(function(e,r){if(!n(e,e,t))return r()}),{IS_ITERATOR:!0,INTERRUPTED:!0}).stopped}});var $$k=_export,getBuiltIn$6=getBuiltIn$o,call$8=functionCall,aCallable$9=aCallable$z,anObject$e=anObject$M,speciesConstructor$5=speciesConstructor$b,iterate$d=iterate$A;$$k({target:"Set",proto:!0,real:!0,forced:!0},{difference:function(e){var t=anObject$e(this),r=new(speciesConstructor$5(t,getBuiltIn$6("Set")))(t),n=aCallable$9(r.delete);return iterate$d(e,(function(e){call$8(n,r,e)})),r}});var $$j=_export,getBuiltIn$5=getBuiltIn$o,call$7=functionCall,aCallable$8=aCallable$z,anObject$d=anObject$M,bind$5=functionBindContext,speciesConstructor$4=speciesConstructor$b,getSetIterator$5=getSetIterator$7,iterate$c=iterate$A;$$j({target:"Set",proto:!0,real:!0,forced:!0},{filter:function(e){var t=anObject$d(this),r=getSetIterator$5(t),n=bind$5(e,arguments.length>1?arguments[1]:void 0),i=new(speciesConstructor$4(t,getBuiltIn$5("Set"))),o=aCallable$8(i.add);return iterate$c(r,(function(e){n(e,e,t)&&call$7(o,i,e)}),{IS_ITERATOR:!0}),i}});var $$i=_export,anObject$c=anObject$M,bind$4=functionBindContext,getSetIterator$4=getSetIterator$7,iterate$b=iterate$A;$$i({target:"Set",proto:!0,real:!0,forced:!0},{find:function(e){var t=anObject$c(this),r=getSetIterator$4(t),n=bind$4(e,arguments.length>1?arguments[1]:void 0);return iterate$b(r,(function(e,r){if(n(e,e,t))return r(e)}),{IS_ITERATOR:!0,INTERRUPTED:!0}).result}});var $$h=_export,getBuiltIn$4=getBuiltIn$o,call$6=functionCall,aCallable$7=aCallable$z,anObject$b=anObject$M,speciesConstructor$3=speciesConstructor$b,iterate$a=iterate$A;$$h({target:"Set",proto:!0,real:!0,forced:!0},{intersection:function(e){var t=anObject$b(this),r=new(speciesConstructor$3(t,getBuiltIn$4("Set"))),n=aCallable$7(t.has),i=aCallable$7(r.add);return iterate$a(e,(function(e){call$6(n,t,e)&&call$6(i,r,e)})),r}});var $$g=_export,call$5=functionCall,aCallable$6=aCallable$z,anObject$a=anObject$M,iterate$9=iterate$A;$$g({target:"Set",proto:!0,real:!0,forced:!0},{isDisjointFrom:function(e){var t=anObject$a(this),r=aCallable$6(t.has);return!iterate$9(e,(function(e,n){if(!0===call$5(r,t,e))return n()}),{INTERRUPTED:!0}).stopped}});var $$f=_export,getBuiltIn$3=getBuiltIn$o,call$4=functionCall,aCallable$5=aCallable$z,isCallable$1=isCallable$n,anObject$9=anObject$M,getIterator$1=getIterator$7,iterate$8=iterate$A;$$f({target:"Set",proto:!0,real:!0,forced:!0},{isSubsetOf:function(e){var t=getIterator$1(this),r=anObject$9(e),n=r.has;return isCallable$1(n)||(r=new(getBuiltIn$3("Set"))(e),n=aCallable$5(r.has)),!iterate$8(t,(function(e,t){if(!1===call$4(n,r,e))return t()}),{IS_ITERATOR:!0,INTERRUPTED:!0}).stopped}});var $$e=_export,call$3=functionCall,aCallable$4=aCallable$z,anObject$8=anObject$M,iterate$7=iterate$A;$$e({target:"Set",proto:!0,real:!0,forced:!0},{isSupersetOf:function(e){var t=anObject$8(this),r=aCallable$4(t.has);return!iterate$7(e,(function(e,n){if(!1===call$3(r,t,e))return n()}),{INTERRUPTED:!0}).stopped}});var $$d=_export,uncurryThis$5=functionUncurryThis,anObject$7=anObject$M,toString2=toString$h,getSetIterator$3=getSetIterator$7,iterate$6=iterate$A,arrayJoin=uncurryThis$5([].join),push$3=[].push;$$d({target:"Set",proto:!0,real:!0,forced:!0},{join:function(e){var t=anObject$7(this),r=getSetIterator$3(t),n=void 0===e?",":toString2(e),i=[];return iterate$6(r,push$3,{that:i,IS_ITERATOR:!0}),arrayJoin(i,n)}});var $$c=_export,getBuiltIn$2=getBuiltIn$o,bind$3=functionBindContext,call$2=functionCall,aCallable$3=aCallable$z,anObject$6=anObject$M,speciesConstructor$2=speciesConstructor$b,getSetIterator$2=getSetIterator$7,iterate$5=iterate$A;$$c({target:"Set",proto:!0,real:!0,forced:!0},{map:function(e){var t=anObject$6(this),r=getSetIterator$2(t),n=bind$3(e,arguments.length>1?arguments[1]:void 0),i=new(speciesConstructor$2(t,getBuiltIn$2("Set"))),o=aCallable$3(i.add);return iterate$5(r,(function(e){call$2(o,i,n(e,e,t))}),{IS_ITERATOR:!0}),i}});var $$b=_export,aCallable$2=aCallable$z,anObject$5=anObject$M,getSetIterator$1=getSetIterator$7,iterate$4=iterate$A,$TypeError=TypeError;$$b({target:"Set",proto:!0,real:!0,forced:!0},{reduce:function(e){var t=anObject$5(this),r=getSetIterator$1(t),n=arguments.length<2,i=n?void 0:arguments[1];if(aCallable$2(e),iterate$4(r,(function(r){n?(n=!1,i=r):i=e(i,r,r,t)}),{IS_ITERATOR:!0}),n)throw $TypeError("Reduce of empty set with no initial value");return i}});var $$a=_export,anObject$4=anObject$M,bind$2=functionBindContext,getSetIterator=getSetIterator$7,iterate$3=iterate$A;$$a({target:"Set",proto:!0,real:!0,forced:!0},{some:function(e){var t=anObject$4(this),r=getSetIterator(t),n=bind$2(e,arguments.length>1?arguments[1]:void 0);return iterate$3(r,(function(e,r){if(n(e,e,t))return r()}),{IS_ITERATOR:!0,INTERRUPTED:!0}).stopped}});var $$9=_export,getBuiltIn$1=getBuiltIn$o,call$1=functionCall,aCallable$1=aCallable$z,anObject$3=anObject$M,speciesConstructor$1=speciesConstructor$b,iterate$2=iterate$A;$$9({target:"Set",proto:!0,real:!0,forced:!0},{symmetricDifference:function(e){var t=anObject$3(this),r=new(speciesConstructor$1(t,getBuiltIn$1("Set")))(t),n=aCallable$1(r.delete),i=aCallable$1(r.add);return iterate$2(e,(function(e){call$1(n,r,e)||call$1(i,r,e)})),r}});var $$8=_export,getBuiltIn=getBuiltIn$o,aCallable=aCallable$z,anObject$2=anObject$M,speciesConstructor=speciesConstructor$b,iterate$1=iterate$A;$$8({target:"Set",proto:!0,real:!0,forced:!0},{union:function(e){var t=anObject$2(this),r=new(speciesConstructor(t,getBuiltIn("Set")))(t);return iterate$1(e,aCallable(r.add),{that:r}),r}});var parent$9=set$3,set$2=parent$9,set$1=set$2,set=set$1,THROTTLE_DURATION=150,STATS_CACHE=new map2,getExtraChromeStatsReport=function(){var e=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",new promise((function(e,r){var n=getParameter("STATS_SCALLBACK_SUPPORT");if("chrome-stable"===getBrowser()&&void 0===window.InstallTrigger&&isStatsCallbackSupport&&n)try{t.getStats((function(t){var r=[];t.result().forEach((function(e){if(!includes4(stasType).call(stasType,e.type)){var t={};e.names().forEach((function(r){t[r]=e.stat(r)})),r.push(_objectSpread2(_objectSpread2({},t),{},{id:e.id,type:e.type,timestamp:e.timestamp}))}})),e({all:r,getTrackStats:function(e){return filter3(r).call(r,(function(t){return"ssrc"!==t.type||t.googTrackId===e}))}})}))}catch(e){r(e)}else e({all:[],getTrackStats:function(){return[]}})})));case 1:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),getAllStatsReport=function(){var e=_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 e.next=2,t.getStats();case 2:return i=e.sent,o={all:[]},a=new map2,i.forEach((function(e){var t=a.get(e.type)||new map2;t.set(e.id,e),a.set(e.type,t),o.all.push(e)})),s=function(e,t){e.forEach((function(e){var r,n,i,o,s,c,l=e.codecId,u=e.transportId,d=e.trackId,p=e.playoutId;if(null===(r=a.get(RTCStatsType.codec))||void 0===r||r.forEach((function(e){e.id===l&&t.add(e)})),null===(n=a.get(RTCStatsType.transport))||void 0===n||n.forEach((function(e){e.id===u&&(s=e,t.add(e))})),null===(i=a.get(RTCStatsType.track))||void 0===i||i.forEach((function(e){e.id===d&&t.add(e)})),null===(o=a.get(RTCStatsType.mediaPlayout))||void 0===o||o.forEach((function(e){e.id===p&&t.add(e)})),s){var _,h,f=s,m=f.localCertificateId,v=f.remoteCertificateId,g=f.selectedCandidatePairId;null===(_=a.get(RTCStatsType.certificate))||void 0===_||_.forEach((function(e){(e.id===m||e.id===v)&&t.add(e)})),null===(h=a.get(RTCStatsType.candidatePair))||void 0===h||h.forEach((function(e){e.id===g&&(c=e,t.add(e))}))}if(c){var y,S,T=c,$=T.localCandidateId,E=T.remoteCandidateId;null===(y=a.get(RTCStatsType.localCandidate))||void 0===y||y.forEach((function(e){e.id===$&&t.add(e)})),null===(S=a.get(RTCStatsType.remoteCandidate))||void 0===S||S.forEach((function(e){e.id===E&&t.add(e)}))}}))},null===(r=a.get(RTCStatsType.mediaSource))||void 0===r||r.forEach((function(e){var t,r=new set;r.add(e);var n=[];null===(t=a.get(RTCStatsType.outboundRtp))||void 0===t||t.forEach((function(t){var i;t.mediaSourceId===e.id&&(r.add(t),n.push(t),null===(i=a.get(RTCStatsType.remoteInboundRtp))||void 0===i||i.forEach((function(e){e.localId===t.id&&r.add(e)})))})),s(n,r),o[e.trackIdentifier]=from$2(r)})),null===(n=a.get(RTCStatsType.inboundRtp))||void 0===n||n.forEach((function(e){var t,r=new set;r.add(e),null===(t=a.get(RTCStatsType.remoteOutboundRtp))||void 0===t||t.forEach((function(t){t.localId===e.id&&r.add(t)})),s([e],r);var n,i=e.trackIdentifier;i||(null===(n=a.get(RTCStatsType.track))||void 0===n||n.forEach((function(t){t.id===e.trackId&&(i=t.trackIdentifier)})));o[i]=from$2(r)})),e.abrupt("return",o);case 10:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),getStats=function(){var e=_asyncToGenerator(_regeneratorRuntime().mark((function e(t,r,n){var i,o,a,s,c,l;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(i=null==r?void 0:r.id,t instanceof RTCPeerConnection){e.next=3;break}return e.abrupt("return",[]);case 3:if(!isFirefox&&!isSafari){e.next=10;break}return o=[],e.next=7,t.getStats(r);case 7:return e.sent.forEach((function(e){o.push(e)})),e.abrupt("return",o);case 10:return(!(a=STATS_CACHE.get(t))||Date.now()-a.timestamp>THROTTLE_DURATION)&&(a={timestamp:Date.now(),statsPromise:getAllStatsReport(t),extraStatsPromise:getExtraChromeStatsReport(t)},STATS_CACHE.set(t,a)),e.next=14,a.statsPromise;case 14:if(s=e.sent,c=(i?s[i]:s.all)||[],n){e.next=21;break}return e.next=19,a.extraStatsPromise;case 19:l=e.sent,c=concat$2(c).call(c,(i?l.getTrackStats(i):l.all)||[]);case 21:return e.abrupt("return",c);case 22:case"end":return e.stop()}}),e)})));return function(t,r,n){return e.apply(this,arguments)}}();getBrowser();var RTCStatsType=function(e){return e.codec="codec",e.inboundRtp="inbound-rtp",e.outboundRtp="outbound-rtp",e.remoteInboundRtp="remote-inbound-rtp",e.remoteOutboundRtp="remote-outbound-rtp",e.mediaSource="media-source",e.csrc="csrc",e.peerConnection="peer-connection",e.dataChannel="data-channel",e.stream="stream",e.track="track",e.transceiver="transceiver",e.sender="sender",e.receiver="receiver",e.transport="transport",e.sctpTransport="sctp-transport",e.candidatePair="candidate-pair",e.localCandidate="local-candidate",e.remoteCandidate="remote-candidate",e.certificate="certificate",e.iceServer="ice-server",e.mediaPlayout="media-playout",e}(RTCStatsType||{}),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"],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(){return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(e.prev=0,!isSSR2()&&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,isH264DecodeSupported();case 5:if(e.t0=e.sent,!e.t0){e.next=10;break}return e.next=9,isH264EncodeSupported();case 9:e.t0=e.sent;case 10:return e.abrupt("return",e.t0);case 13:return e.prev=13,e.t1=e.catch(0),e.abrupt("return",!1);case 16:case"end":return e.stop()}}),e,null,[[0,13]])})));return function(){return e.apply(this,arguments)}}(),internalGetSupportedCodecs=function(){var e=_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 r=t||"recv_and_send",n=[],e.next=4,isH264DecodeSupported();case 4:return i=e.sent,e.next=7,isH264EncodeSupported();case 7:return o=e.sent,e.next=10,isVP8DecodeSupported();case 10:return a=e.sent,e.next=13,isVP8EncodeSupported();case 13:return s=e.sent,"send_only"===r&&(o&&n.push("H264"),s&&n.push("vp8")),"recv_only"===r&&(i&&n.push("H264"),a&&n.push("vp8")),"recv_and_send"===r&&(o&&i&&n.push("H264"),s&&a&&n.push("vp8")),e.abrupt("return",n);case 18:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),internalGetSupportedCodecsSdpOffer=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",stringify$1(codecsSupportMapSdpOffer));case 1:case"end":return e.stop()}}),e)})));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",map$6(t).call(t,(function(e){return e.toUpperCase()})));case 4:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),codecsSupportMap={},codecsSupportMapSdpOffer={};function supportH264(e){var t,r=!1,n=_createForOfIteratorHelper(e.split("\n"));try{for(n.s();!(t=n.n()).done;){var i=t.value;if(includes4(i).call(i,"level-asymmetry-allowed=1")&&includes4(i).call(i,"packetization-mode=1")&&includes4(i).call(i,"profile-level-id=42e0")){r=!0;break}}}catch(e){n.e(e)}finally{n.f()}if(r){for(var o=navigator.userAgent.toLowerCase(),a=!1,s=0,c=["miuibrowser"];s<c.length;s++){var l=c[s];includes4(o).call(o,l)&&(a=!0)}return!a}return!1}var createOfferSdp=function(){var e=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){var r,n;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return(r=new RTCPeerConnection({sdpSemantics:"unified-plan"})).addTransceiver("video",{direction:t}),e.next=4,r.createOffer();case 4:return n=e.sent,r.close(),e.abrupt("return",n.sdp.toLowerCase());case 7:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),checkCodecsEncodeSupport=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,createOfferSdp("sendonly");case 2:if(r=e.sent,!includes4(t=navigator.userAgent).call(t,"VivoBrowser")){e.next=7;break}return e.next=6,createOfferSdp("sendonly");case 6:r=e.sent;case 7:return codecsSupportMap.h264encode=supportH264(r),codecsSupportMapSdpOffer.h264encode=r,codecsSupportMap.vp8encode=indexOf2(r).call(r,"vp8")>-1,codecsSupportMapSdpOffer.vp8encode="same as h264encode",e.abrupt("return",codecsSupportMap);case 12:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),checkCodecsDecodeSupport=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,createOfferSdp("recvonly");case 2:if(r=e.sent,!includes4(t=navigator.userAgent).call(t,"VivoBrowser")){e.next=7;break}return e.next=6,createOfferSdp("recvonly");case 6:r=e.sent;case 7:return codecsSupportMap.h264decode=supportH264(r),codecsSupportMapSdpOffer.h264decode=r,codecsSupportMap.vp8decode=indexOf2(r).call(r,"vp8")>-1,codecsSupportMapSdpOffer.vp8decode="same as h264decode",e.abrupt("return",codecsSupportMap);case 12:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),isH264EncodeSupported=function(){var e=_asyncToGenerator(_regeneratorRuntime().mark((function e(){return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(void 0!==codecsSupportMap.h264encode){e.next=10;break}return e.prev=1,e.next=4,checkCodecsEncodeSupport();case 4:e.next=10;break;case 6:return e.prev=6,e.t0=e.catch(1),codecsSupportMapSdpOffer.h264encode="meet error:"+e.t0,e.abrupt("return",!1);case 10:return e.abrupt("return",codecsSupportMap.h264encode||!1);case 11:case"end":return e.stop()}}),e,null,[[1,6]])})));return function(){return e.apply(this,arguments)}}(),isH264DecodeSupported=function(){var e=_asyncToGenerator(_regeneratorRuntime().mark((function e(){return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(void 0!==codecsSupportMap.h264decode){e.next=10;break}return e.prev=1,e.next=4,checkCodecsDecodeSupport();case 4:e.next=10;break;case 6:return e.prev=6,e.t0=e.catch(1),codecsSupportMapSdpOffer.h264decode="meet error:"+e.t0,e.abrupt("return",!1);case 10:return e.abrupt("return",codecsSupportMap.h264decode||!1);case 11:case"end":return e.stop()}}),e,null,[[1,6]])})));return function(){return e.apply(this,arguments)}}(),isVP8EncodeSupported=function(){var e=_asyncToGenerator(_regeneratorRuntime().mark((function e(){return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(void 0!==codecsSupportMap.vp8encode){e.next=10;break}return e.prev=1,e.next=4,checkCodecsEncodeSupport();case 4:e.next=10;break;case 6:return e.prev=6,e.t0=e.catch(1),codecsSupportMapSdpOffer.vp8encode="meet error:"+e.t0,e.abrupt("return",!1);case 10:return e.abrupt("return",codecsSupportMap.vp8encode||!1);case 11:case"end":return e.stop()}}),e,null,[[1,6]])})));return function(){return e.apply(this,arguments)}}(),isVP8DecodeSupported=function(){var e=_asyncToGenerator(_regeneratorRuntime().mark((function e(){return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(void 0!==codecsSupportMap.vp8decode){e.next=10;break}return e.prev=1,e.next=4,checkCodecsDecodeSupport();case 4:e.next=10;break;case 6:return e.prev=6,e.t0=e.catch(1),codecsSupportMapSdpOffer.vp8decode="meet error:"+e.t0,e.abrupt("return",!1);case 10:return e.abrupt("return",codecsSupportMap.vp8decode||!1);case 11:case"end":return e.stop()}}),e,null,[[1,6]])})));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},isWebAudioSupported=function(){return 12!==safariVersion},lib={},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"]}]};keys$8(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=[],s=o;return filter3(t=e.split(/(\r\n|\r|\n)/)).call(t,i).forEach((function(e){var t=e[0],i=slice$1(e).call(e,2);"m"===t&&(a.push({rtp:[],fmtp:[]}),s=a[a.length-1]);for(var o=0;o<(n[t]||[]).length;o+=1){var c=n[t][o];if(c.reg.test(i))return r(c,s,i)}})),o.media=a,o};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){var t;return reduce3(t=e.split(/;\s?/)).call(t,o,{})},e.parseFmtpConfig=e.parseParams,e.parsePayloads=function(e){var t;return map$6(t=e.toString().split(" ")).call(t,Number)},e.parseRemoteCandidates=function(e){for(var r,n=[],i=map$6(r=e.split(" ")).call(r,t),o=0;o<i.length;o+=3)n.push({component:i[o],ip:i[o+1],port:i[o+2]});return n},e.parseImageAttributes=function(e){var t;return map$6(t=e.split(" ")).call(t,(function(e){var t;return reduce3(t=e.substring(1,e.length-1).split(",")).call(t,o,{})}))},e.parseSimulcastStreamList=function(e){var r;return map$6(r=e.split(";")).call(r,(function(e){var r;return map$6(r=e.split(",")).call(r,(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,format14=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 format14.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,writer2=writer$1;lib.write=writer2,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 toObject=toObject$d,toAbsoluteIndex=toAbsoluteIndex$5,lengthOfArrayLike=lengthOfArrayLike$b,arrayFill=function(e){for(var t=toObject(this),r=lengthOfArrayLike(t),n=arguments.length,i=toAbsoluteIndex(n>1?arguments[1]:void 0,r),o=n>2?arguments[2]:void 0,a=void 0===o?r:toAbsoluteIndex(o,r);a>i;)t[i++]=e;return t},$$7=_export,fill$7=arrayFill;$$7({target:"Array",proto:!0},{fill:fill$7});var entryVirtual=entryVirtual$m,fill$6=entryVirtual("Array").fill,isPrototypeOf=objectIsPrototypeOf,method=fill$6,ArrayPrototype=Array.prototype,fill$5=function(e){var t=e.fill;return e===ArrayPrototype||isPrototypeOf(ArrayPrototype,e)&&t===ArrayPrototype.fill?method:t},parent$8=fill$5,fill$4=parent$8,parent$7=fill$4,fill$3=parent$7,parent$6=fill$3,fill$2=parent$6,fill$1=fill$2,fill2=fill$1,logger$j=new Logger("FirefoxHandler",3),SSRC_MAX=Math.pow(2,32),SSRC_MIN=1e4,clientCname="kp34Za0H+aVf862l",serverCname="o/i14u9pJrxRKAsu",generateRandomSsrc=function(){return Math.floor(Math.random()*SSRC_MAX+SSRC_MIN)};function generateAllSsrc(e){return e>SSRC_MAX-18?(logger$j.print("generateAllSsrc","reset start id",e),generateAllSsrc(e=e-SSRC_MAX+SSRC_MIN+18)):{audio:e,audioFec:e+1,audioRtx:e+2,video:e+3,videoFec:e+4,videoRtx:e+5,next:e+18}}var generateSsrc=function(e,t,r){var n,i,o,a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:serverCname;return[{id:r,attribute:"cname",value:a},{id:r,attribute:"msid",value:concat$2(n=concat$2(i="".concat(e," ")).call(i,e,"-")).call(n,t)},{id:r,attribute:"mslabel",value:"".concat(e)},{id:r,attribute:"label",value:concat$2(o="".concat(e,"-")).call(o,t)}]},generateSsrcs=function(e,t){var r,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},i=t.video,o=t.videoRtx,a=t.videoFec,s=[i,o],c=n.cname,l=n.flexfec;l&&s.push(a);var u,d=reduce3(s).call(s,(function(t,r){return concat$2(t).call(t,generateSsrc(e,"video",r,c))}),[]),p=[{semantics:"FID",ssrcs:concat$2(r="".concat(i," ")).call(r,o)}];l&&p.push({semantics:"FEC-FR",ssrcs:concat$2(u="".concat(i," ")).call(u,a)});return{ssrcs:d,ssrcGroups:p}};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=!(arguments.length>3&&void 0!==arguments[3])||arguments[3],i=_objectSpread2(_objectSpread2({},e),{},{media:[]});return n&&(i.invalid=[{value:"realx-exts:rscp"}]),t&&i.media.push(t),r&&i.media.push(r),delete i.groups,delete i.msidSemantic,lib.write(i)};function parseAnswerIceParams(e,t){return _parseAnswerIceParams.apply(this,arguments)}function _parseAnswerIceParams(){return(_parseAnswerIceParams=_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:return n={},i=r.publicIPs,o=r.certFingerprint,a=r.iceParams,s=r.iceConfig,n.fingerprint={type:"sha-256",hash:o},n.icePwd=a.serverIcePwd,e.next=6,getServerUfrag(a.serverIceUfrag);case 6:return n.iceUfrag=e.sent,n.candidates=genCandidates(i,s),n.setup="active",n.iceOptions="renomination",e.abrupt("return",n);case 11:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function genCandidates(e,t){if(!Array.isArray(e))return[];var r=0,n=2130706431,i=[];return e.forEach((function(e){var o={component:1,ip:e.ip,type:"host",generation:e.generation};e.udpPorts&&!t.tcpOnly&&e.udpPorts.forEach((function(e){i.push(_objectSpread2(_objectSpread2({},o),{},{foundation:r++,transport:"udp",port:e,priority:n}))})),e.tcpPorts&&e.tcpPorts.forEach((function(e){i.push(_objectSpread2(_objectSpread2({},o),{},{foundation:r++,transport:"tcp",port:e,tcptype:"passive",priority:2130705431}))}))})),i}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=new Uint8Array(4),crypto.getRandomValues(o),(a=new Uint8Array(2))[0]=0,a[1]=1,s=concatenate(Uint8Array,n,i,o,a),e.next=15,Utils.ab2b64str(s.buffer);case 15:return c=e.sent,e.abrupt("return",c);case 17:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),ICEConfigType=function(e){return e[e.kICEConfigTypeSrtpDtlsType=0]="kICEConfigTypeSrtpDtlsType",e[e.kICEConfigTypeRenominationType=1]="kICEConfigTypeRenominationType",e[e.kICEConfigTypeTcpType=2]="kICEConfigTypeTcpType",e[e.kICEConfigTypeMultiSendType=3]="kICEConfigTypeMultiSendType",e[e.kICEConfigTypeKcpType=4]="kICEConfigTypeKcpType",e[e.kICEConfigTypeSrtpSdesType=5]="kICEConfigTypeSrtpSdesType",e}(ICEConfigType||{});function getServerUfragV2(e){return _getServerUfragV.apply(this,arguments)}function _getServerUfragV(){return(_getServerUfragV=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){var r,n,i,o,a,s,c,l,u,d,p,_,h,f,m,v,g;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=t.random,i=t.serverUfrag,o=t.serverPwd,a=t.clientPwd,s=t.options,0,c=new TextEncoder,l=c.encode("WPRE"),4,n||(n=new Uint8Array(4),crypto.getRandomValues(n)),4,u=base64ToUint8(i),d=u.byteLength,1,d,p=aesCtrEncrypt(base64ToUint8(a),base64ToUint8(o).subarray(0,16),base64ToUint8(i).subarray(0,16)),_=p.byteLength,1,_,h=new Uint8Array(reduce3(r=keys$8(s)).call(r,(function(e,t){var r=Number(t);return e.push(r),e.push(s[r]?1:0),e}),[])),h.byteLength,(f=concatenate(Uint8Array,l,n,[u.byteLength],u,[p.byteLength],p,h)).byteLength%3!=0&&(f=concatenate(Uint8Array,f,fill2(m=new Uint8Array(3-f.byteLength%3)).call(m,255))),v=uint8ToBase64(f),g=uint8ToBase64(concatenate(Uint8Array,n,u.subarray(0,20))),e.abrupt("return",[v,g]);case 22:case"end":return e.stop()}}),e)})))).apply(this,arguments)}var setCodecPreferences=function(e,t){var r=0;if(Array.isArray(e.fmtp)&&Array.isArray(e.rtp)){var n,i=_createForOfIteratorHelper(e.fmtp);try{for(i.s();!(n=i.n()).done;){var o,a,s,c=n.value;if(includes4(o=c.config).call(o,"level-asymmetry-allowed=1")&&includes4(a=c.config).call(a,"packetization-mode=1")&&includes4(s=c.config).call(s,"profile-level-id=42e0")){r=c.payload;break}}}catch(e){i.e(e)}finally{i.f()}for(var l=0;l<e.rtp.length;l++){var u=e.rtp[l];if("H264"===t){if(u.payload===r){var d;e.rtp.unshift(splice$3(d=e.rtp).call(d,l,1)[0]);break}}else if(u.codec===t){var p;e.rtp.unshift(splice$3(p=e.rtp).call(p,l,1)[0]);break}}var _=[];e.rtp.forEach((function(e){return _.push(e.payload)})),e.payloads=_.join(" ")}},logger$i=new Logger("BasicHandler",3),encodedTransformSupported$1=isEncodedTransformSupported(),peerConnectionConfiguration={iceServers:[],iceTransportPolicy:"all",bundlePolicy:"max-bundle",rtcpMuxPolicy:"require",sdpSemantics:"unified-plan",encodedInsertableStreams:!!encodedTransformSupported$1||void 0},BasicHandler=function(e){_inherits(o,eventemitter3.exports.EventEmitter);var t,r,n,i=_createSuper(o);function o(e){var t;return _classCallCheck(this,o),_defineProperty(_assertThisInitialized(t=i.call(this)),"_peerConnection",void 0),_defineProperty(_assertThisInitialized(t),"_dataChannel",void 0),_defineProperty(_assertThisInitialized(t),"_context",void 0),_defineProperty(_assertThisInitialized(t),"id",void 0),_defineProperty(_assertThisInitialized(t),"_monitor",void 0),_defineProperty(_assertThisInitialized(t),"_offerIce",{}),_defineProperty(_assertThisInitialized(t),"_answerIce",{}),_defineProperty(_assertThisInitialized(t),"_initSctpEvents",!1),_defineProperty(_assertThisInitialized(t),"_nextSsrc",generateRandomSsrc()),_defineProperty(_assertThisInitialized(t),"_aSendonlyAnswerTpl",void 0),_defineProperty(_assertThisInitialized(t),"_vSendonlyAnswerTpl",void 0),_defineProperty(_assertThisInitialized(t),"_enableSubFlexfec",!1),_defineProperty(_assertThisInitialized(t),"audioTrack4ff",void 0),_defineProperty(_assertThisInitialized(t),"_connectionId",void 0),t.id=e.id,t._monitor=getMonitor(t.id),t._peerConnection=new RTCPeerConnection(peerConnectionConfiguration),t._dataChannel=t._peerConnection.createDataChannel("signaling",{negotiated:!0,id:100}),t._context=e,t._dataChannel.binaryType="arraybuffer",t._peerConnection.ontrack=function(e){var r,n,i,o,a=null===(r=e.streams)||void 0===r||null===(n=r[0])||void 0===n?void 0:n.id;logger$i.print("constructor",concat$2(i=concat$2(o="pc.ontrack ".concat(e.track.kind," ")).call(o,e.track.id," ")).call(i,a)),"ff-stream"===a&&(t.audioTrack4ff=e.track),t.emit("ontrack",e)},t._peerConnection.onconnectionstatechange=function(e){var r;logger$i.print("constructor",concat$2(r="onconnectionstatechange ".concat(t._peerConnection.iceConnectionState," -> ")).call(r,t._peerConnection.connectionState)),"failed"!==t._peerConnection.iceConnectionState&&"closed"!==t._peerConnection.iceConnectionState&&"failed"!==t._peerConnection.connectionState||t.emit("disconnect")},t._peerConnection.oniceconnectionstatechange=function(){var e=t._peerConnection.iceConnectionState;t._report("rtc_pre_ice_state",{message:e,ice_state:e.toUpperCase()})},t}return _createClass(o,[{key:"getConnectionId",value:function(){return this._connectionId}},{key:"disconnect",value:function(){this._peerConnection.close(),this._dataChannel.close(),this._peerConnection.ontrack=null}},{key:"destroy",value:function(){logger$i.print("destroy"),this.disconnect(),this._context=void 0}},{key:"getTransceivers",value:function(){return this._peerConnection.getTransceivers()}},{key:"_simulcast",value:function(e,t,r,n,i){var o,a,s,c=[];1===e.videoEncodeConfig.length?(c=fillSimulcastLayers(t,i),logger$i.print("simulcast() ","simulcastLayers: %o",c)):(c=map$6(o=slice$1(a=slice$1(s=e.videoEncodeConfig).call(s,1)).call(a,1-i)).call(o,(function(e){var r=constraints2number(e.width),n=t.width/r;return{width:r,height:Math.floor(t.height/n),scaleResolutionDownBy:n,frameRate:constraints2number(e.frameRate)||15,maxkbps:e.maxKbps||600}})),logger$i.print("simulcast() ","simulcastLayers2: %o",c));var l=[!0];c.forEach((function(e,t){var i,o={maxBitrate:1e3*e.maxkbps,scaleResolutionDownBy:e.scaleResolutionDownBy,rid:"".concat(t+1),maxFramerate:e.frameRate};null===(i=r.sendEncodings)||void 0===i||i.unshift(o),n.push({width:e.width,height:e.height,framerate:e.frameRate,maxkbps:e.maxkbps,rid:"".concat(t+1)}),l.push(!0)})),this._context&&(this._context.activeSimStreams=l)}},{key:"internalPublish",value:function(e){var t=e.stream,r=e.videoTrack,n=e.audioTrack,i=e.enableSimulcast,o=e.pubAudio,a=e.pubVideo,s={direction:"sendonly",streams:[t]},c={direction:"sendonly",streams:[t]},l=[],u=[];if(Array.isArray(null==e?void 0:e.videoEncodeConfig)&&e.videoEncodeConfig.length){var d=null==r?void 0:r.getTrack(),p=_objectSpread2({},defaultVideoEncoderConfig);if(d){var _=null==d?void 0:d.getSettings();p={width:Math.floor(_.width),height:Math.floor(_.height),frameRate:Math.floor(_.frameRate)}}"number"!=typeof p.frameRate&&(p.frameRate=30);var h=null==e?void 0:e.videoEncodeConfig[0],f={maxBitrate:1e3*h.maxKbps,rid:"0"};if(e.prevBitrate=h.maxKbps,c.sendEncodings=[f],l.push({width:p.width,height:p.height,framerate:p.frameRate,maxkbps:h.maxKbps,rid:"0"}),!isFirefox&&i){var m,v,g=getSimulcastLayers(p);if(logger$i.print("simulcast() ","maxLayers: %o",g),g>1)this._simulcast(e,_objectSpread2(_objectSpread2({},p),{},{maxKbps:h.maxKbps}),c,l,g),null!==(m=this._context)&&void 0!==m&&null!==(v=m.serverConfig)&&void 0!==v&&v.simulcastOnDemand&&(u=map$6(l).call(l,(function(e,t){return _objectSpread2(_objectSpread2({},e),{},{video_index:t,sub_index:t})})))}}logger$i.print("publish videoTransceiverInit videoDescriptions","",c,l);var y=null==n?void 0:n.getTrack("preprocessing");(null==n?void 0:n.mixType)!==AudioMixingType.PLAYOUT&&null!=n&&n.mixedAudioTrack&&(y=null==n?void 0:n.mixedAudioTrack),y=o&&y?y:"audio";var S=null==r?void 0:r.getTrack("preprocessing");S=a&&S?S:"video";try{this._reportRtcInvokeStatus("Handler.internalPublish",stringify$1({aTrack:MediaTrackStringify(y),vTrack:MediaTrackStringify(S),audioTransceiverInit:s,videoTransceiverInit:c}))}catch(e){}return{semantics:"unified-plan",videoDescriptions:l,subVideoDescriptions:u,audioTransceiverInit:{track:y,init:s},videoTransceiverInit:{track:S,init:c}}}},{key:"updateMaxBitrate",value:function(e){var t,r,n,i;logger$i.print("updateMaxBitrate()");var o=null===(t=e.videoTrack)||void 0===t?void 0:t.getTrack(),a=e.videoTransceiver;if(o&&e.pubVideo&&a){var s=null===(r=e.videoEncodeConfig)||void 0===r||null===(n=r[0])||void 0===n?void 0:n.maxKbps;if(s){if(s===e.prevBitrate)return void logger$i.print("updateMaxBitrate()","no change");e.prevBitrate=s}var c=null===(i=a.sender)||void 0===i?void 0:i.getParameters();if(c){var l;c.encodings=null==c||null===(l=c.encodings)||void 0===l?void 0:map$6(l).call(l,(function(t){var r,n=+t.rid||0,i=null===(r=e.videoEncodeConfig[n])||void 0===r?void 0:r.maxKbps;return"number"==typeof i&&(t.maxBitrate=1e3*i),t})),null==a||a.sender.setParameters(c);try{this._reportRtcInvokeStatus("Handler.updateScaleResolutionDownBy",stringify$1(c.encodings))}catch(e){}}}else logger$i.print("updateMaxBitrate()","no pub")}},{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._report("rtc_set_description",{error_code:0,message:t,is_local:"1",direction:"local"===(null==r?void 0:r.streamUserId)?"up":"down",stream_id:(null==r?void 0:r.streamId)||"",stream_user_id:(null==r?void 0:r.streamUserId)||"",elapse: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._reportRtcInvokeStatus("sctp","sctp state change TO: ".concat(o.state))},o.transport&&(o.transport.onstatechange=function(){var e;a._reportRtcInvokeStatus("dtls","dtls state change TO: ".concat(null==o||null===(e=o.transport)||void 0===e?void 0:e.state))}))),e.next=12;break;case 8:e.prev=8,e.t0=e.catch(1),console.error("setLocal",e.t0),this._report("rtc_set_description",{error_code:-1,message:e.t0.message+t,is_local:"1",direction:"local"===(null==r?void 0:r.streamUserId)?"up":"down",stream_id:"",stream_user_id:"",elapse: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._report("rtc_set_description",{error_code:0,message:t,is_local:"0",direction:"local"===(null==r?void 0:r.streamUserId)?"up":"down",stream_id:(null==r?void 0:r.streamId)||"",stream_user_id:(null==r?void 0:r.streamUserId)||"",elapse:getServerNow()-n},{type:"answer"}),e.next=11;break;case 7:e.prev=7,e.t0=e.catch(1),console.error("setRemote",e.t0),this._report("rtc_set_description",{error_code:-1,message:e.t0.message+t,is_local:"0",direction:"local"===(null==r?void 0:r.streamUserId)?"up":"down",stream_id:(null==r?void 0:r.streamId)||"",stream_user_id:(null==r?void 0:r.streamUserId)||"",elapse: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:"createAVMlineAnswerTpl",value:function(e){var t=this;lib.parse(e).media.forEach((function(e){if("audio"===e.type){if("sendonly"===e.direction){var r,n=null==e?void 0:find$2(r=e.rtp).call(r,(function(e){return"opus"===e.codec}));if(n&&null!=e&&e.fmtp){var i,o=null==e?void 0:find$2(i=e.fmtp).call(i,(function(e){return e.payload===n.payload}));o&&t._context&&(o.config+=";stereo=1;sprop-stereo=1")}t._aSendonlyAnswerTpl=e}}else"video"===e.type&&("sendonly"===e.direction&&(t._vSendonlyAnswerTpl=e),Array.isArray(e.rtp)&&e.rtp.forEach((function(e){var r;null!==(r=e.codec)&&void 0!==r&&includes4(r).call(r,"flexfec")&&(t._enableSubFlexfec=!0)})))}))}},{key:"pc",get:function(){return this._peerConnection}},{key:"addBitrateLimit",value:function(e,t){null==e||e.rtp.forEach((function(r){var n,i=r.codec,o=r.payload;if(includes4(n=["vp8","h264"]).call(n,i.toLocaleLowerCase())){var a,s,c=find$2(a=e.fmtp).call(a,(function(e){return e.payload===o}));if(c)c.config=concat$2(s=[]).call(s,_toConsumableArray(c.config.split(";")),["x-google-min-bitrate=100","x-google-start-bitrate=".concat(t)]).join(";");else e.fmtp.push({payload:o,config:"x-google-min-bitrate=100;x-google-start-bitrate=".concat(t)})}}))}},{key:"_report",value:function(e,t,r){var n;null===(n=this._monitor)||void 0===n||n.report(e,_objectSpread2(_objectSpread2({},t),{},{connection_id:this._connectionId}),r)}},{key:"_reportRtcInvokeStatus",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"",i=arguments.length>4?arguments[4]:void 0;this._report("rtc_invoke_status",{sdk_api_name:e,message:t,error_code:r,stream_id:n,elapse:0},i)}}]),o}(),uncurryThis$4=functionUncurryThis,defineBuiltIns$2=defineBuiltIns$4,getWeakData=internalMetadata.exports.getWeakData,anInstance$2=anInstance$6,anObject$1=anObject$M,isNullOrUndefined=isNullOrUndefined$7,isObject$3=isObject$q,iterate=iterate$A,ArrayIterationModule=arrayIteration,hasOwn$2=hasOwnProperty_1,InternalStateModule$2=internalState,setInternalState$2=InternalStateModule$2.set,internalStateGetterFor=InternalStateModule$2.getterFor,find$1=ArrayIterationModule.find,findIndex2=ArrayIterationModule.findIndex,splice$2=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=findIndex2(this.entries,(function(t){return t[0]===e}));return~t&&splice$2(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$s,uncurryThis$3=functionUncurryThis,defineBuiltIns$1=defineBuiltIns$4,InternalMetadataModule=internalMetadata.exports,collection=collection$3,collectionWeak=collectionWeak$1,isObject$2=isObject$q,isExtensible2=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)&&!isExtensible2(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)&&!isExtensible2(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)&&!isExtensible2(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)&&!isExtensible2(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 path$1=path$v,weakMap$5=path$1.WeakMap,parent$5=weakMap$5,weakMap$4=parent$5,parent$4=weakMap$4,weakMap$3=parent$4,$$6=_export,emplace2=mapEmplace;$$6({target:"WeakMap",proto:!0,real:!0,forced:!0},{emplace:emplace2});var $$5=_export,from3=collectionFrom;$$5({target:"WeakMap",stat:!0,forced:!0},{from:from3});var $$4=_export,of2=collectionOf;$$4({target:"WeakMap",stat:!0,forced:!0},{of:of2});var $$3=_export,deleteAll2=collectionDeleteAll;$$3({target:"WeakMap",proto:!0,real:!0,forced:!0},{deleteAll:deleteAll2});var $$2=_export,upsert2=mapUpsert;$$2({target:"WeakMap",proto:!0,real:!0,forced:!0},{upsert:upsert2});var parent$3=weakMap$3,weakMap$2=parent$3,weakMap$1=weakMap$2,weakMap=weakMap$1,DeviceDetector=function(e){_inherits(_,EnhancedEventEmitter);var t,r,n,i,o,a,s,c,l,u,d,p=_createSuper(_);function _(){var e,t,r;return _classCallCheck(this,_),_defineProperty(_assertThisInitialized(r=p.call(this)),"inited",!1),_defineProperty(_assertThisInitialized(r),"deviceMap",{audioinput:new map2,audiooutput:new map2,videoinput:new map2}),_defineProperty(_assertThisInitialized(r),"checkDeviceChangeTimer",null),_defineProperty(_assertThisInitialized(r),"isSupportedPermissionsQuery",!1),_defineProperty(_assertThisInitialized(r),"isGrantedMicrophonePermission",!1),_defineProperty(_assertThisInitialized(r),"isGrantedCameraPermission",!1),r.isSupportedPermissionsQuery=!isSSR2()&&!(null===(e=navigator)||void 0===e||null===(t=e.permissions)||void 0===t||!t.query),r._handleDeviceChange=r._handleDeviceChange.bind(_assertThisInitialized(r)),!isSSR2()&&r.refreshDevices(),r}return _createClass(_,[{key:"refreshDevices",value:(d=_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=12;break}return e.prev=4,e.next=7,navigator.mediaDevices.getUserMedia({audio:!0});case 7:t=e.sent,e.next=12;break;case 10:e.prev=10,e.t0=e.catch(4);case 12:return e.next=14,navigator.mediaDevices.enumerateDevices();case 14: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 19:case"end":return e.stop()}}),e,this,[[4,10]])}))),function(){return d.apply(this,arguments)})},{key:"initListener",value:(u=_asyncToGenerator(_regeneratorRuntime().mark((function e(){var t,r,n,i,o=this;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(void 0!==(null===(t=navigator.mediaDevices)||void 0===t?void 0:t.ondevicechange)&&"function"==typeof(null===(r=navigator.mediaDevices)||void 0===r?void 0:r.addEventListener)?navigator.mediaDevices.addEventListener("devicechange",(function(){o._handleDeviceChange(),setTimeout((function(){o._handleDeviceChange()}),300)})):this.checkDeviceChangeTimer=window.setInterval((function(){o._handleDeviceChange()}),3e3),!this.isSupportedPermissionsQuery){e.next=22;break}return e.prev=2,e.next=5,navigator.permissions.query({name:"microphone"});case 5:n=e.sent,this.isGrantedMicrophonePermission="granted"===n.state,n.addEventListener("change",(function(){o.isGrantedMicrophonePermission="granted"===n.state})),e.next=12;break;case 10:e.prev=10,e.t0=e.catch(2);case 12:return e.prev=12,e.next=15,navigator.permissions.query({name:"camera"});case 15:i=e.sent,this.isGrantedCameraPermission="granted"===i.state,i.addEventListener("change",(function(){o.isGrantedCameraPermission="granted"===i.state})),e.next=22;break;case 20:e.prev=20,e.t1=e.catch(12);case 22:case"end":return e.stop()}}),e,this,[[2,10],[12,20]])}))),function(){return u.apply(this,arguments)})},{key:"_handleDeviceChange",value:(l=_asyncToGenerator(_regeneratorRuntime().mark((function e(){var t,r,n,i,o,a,s,c=this;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(o=void 0,!isFirefox){e.next=5;break}return e.next=4,navigator.mediaDevices.getUserMedia({audio:!0});case 4:o=e.sent;case 5:return e.next=7,navigator.mediaDevices.enumerateDevices();case 7:a=e.sent,a=filter3(a).call(a,(function(e){return!!e.deviceId})),o&&o.getTracks().forEach((function(e){return e.stop()})),s=from$2(concat$2(t=[]).call(t,_toConsumableArray(values$1(r=this.deviceMap.audioinput).call(r)),_toConsumableArray(values$1(n=this.deviceMap.videoinput).call(n)),_toConsumableArray(values$1(i=this.deviceMap.audiooutput).call(i)))),a.forEach((function(e){var t,r,n=c.deviceMap[e.kind].get(e.deviceId);c.deviceMap[e.kind].set(e.deviceId,e),n||(includes4(t=e.kind).call(t,"video")?c.emit(EngineEventsTypes.onVideoDeviceStateChanged,{mediaDeviceInfo:e,deviceState:"active"}):includes4(r=e.kind).call(r,"audio")&&c.emit(EngineEventsTypes.onAudioDeviceStateChanged,{mediaDeviceInfo:e,deviceState:"active"}))})),s.forEach((function(e){var t,r;find$2(a).call(a,(function(t){return t.deviceId===e.deviceId&&t.kind===e.kind}))||(c.deviceMap[e.kind].delete(e.deviceId),includes4(t=e.kind).call(t,"video")?c.emit(EngineEventsTypes.onVideoDeviceStateChanged,{mediaDeviceInfo:e,deviceState:"inactive"}):includes4(r=e.kind).call(r,"audio")&&c.emit(EngineEventsTypes.onAudioDeviceStateChanged,{mediaDeviceInfo:e,deviceState:"inactive"}))}));case 13:case"end":return e.stop()}}),e,this)}))),function(){return l.apply(this,arguments)})},{key:"getUserMedia",value:(c=_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,navigator.mediaDevices.getUserMedia(t);case 2:return r=e.sent,null!=t&&t.audio&&(this.isGrantedMicrophonePermission=!0),null!=t&&t.video&&(this.isGrantedCameraPermission=!0),this.refreshDevices(),e.abrupt("return",r);case 7:case"end":return e.stop()}}),e,this)}))),function(e){return c.apply(this,arguments)})},{key:"checkPermissionsByDevices",value:(s=_asyncToGenerator(_regeneratorRuntime().mark((function e(){var t,r;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t={audio:!1,video:!1},navigator.mediaDevices){e.next=3;break}return e.abrupt("return",t);case 3:return e.next=5,navigator.mediaDevices.enumerateDevices();case 5:return r=e.sent,t.audio=filter3(r).call(r,(function(e){return"audioinput"===e.kind&&e.label&&e.deviceId})).length>0,t.video=filter3(r).call(r,(function(e){return"videoinput"===e.kind&&e.label&&e.deviceId})).length>0,e.abrupt("return",t);case 9:case"end":return e.stop()}}),e)}))),function(){return s.apply(this,arguments)})},{key:"getPermissions",value:(a=_asyncToGenerator(_regeneratorRuntime().mark((function e(){var t,r,n,i,o,a,s,c=this,l=arguments;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=l.length>0&&void 0!==l[0]?l[0]:{},n=r.audio,i=r.video,o=r.force,n||i||(n=!0,i=!0),a={audio:!1,video:!1},o){e.next=30;break}if(!this.isSupportedPermissionsQuery){e.next=20;break}if(!n||!i){e.next=14;break}if(!this.isGrantedMicrophonePermission||!this.isGrantedCameraPermission){e.next=12;break}return a.audio=!0,a.video=!0,e.abrupt("return",a);case 12:e.next=18;break;case 14:if(!(n&&this.isGrantedMicrophonePermission||i&&this.isGrantedCameraPermission)){e.next=18;break}return a.audio=this.isGrantedMicrophonePermission,a.video=this.isGrantedCameraPermission,e.abrupt("return",a);case 18:case 26:e.next=30;break;case 20:return e.next=22,this.checkPermissionsByDevices();case 22:if(s=e.sent,!n||!i){e.next=28;break}if(!s.audio||!s.video){e.next=26;break}return e.abrupt("return",s);case 28:if(!(n&&s.audio||i&&s.video)){e.next=30;break}return e.abrupt("return",s);case 30:if(null===(t=navigator.mediaDevices)||void 0===t||!t.getUserMedia){e.next=33;break}return e.next=33,navigator.mediaDevices.getUserMedia({audio:n,video:i}).then((function(e){e&&(e.getTracks().forEach((function(e){return e.stop()})),n&&(a.audio=!0,c.isGrantedMicrophonePermission=!0),i&&(a.video=!0,c.isGrantedCameraPermission=!0))})).catch((function(){}));case 33:return e.next=35,this.refreshDevices();case 35:return e.abrupt("return",a);case 36:case"end":return e.stop()}}),e,this)}))),function(){return a.apply(this,arguments)})},{key:"enumerateDevices",value:(o=_asyncToGenerator(_regeneratorRuntime().mark((function e(){var t,r,n,i;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.getPermissions();case 2:return e.next=4,this.refreshDevices();case 4:return e.abrupt("return",from$2(concat$2(t=[]).call(t,_toConsumableArray(values$1(r=this.deviceMap.audioinput).call(r)),_toConsumableArray(values$1(n=this.deviceMap.videoinput).call(n)),_toConsumableArray(values$1(i=this.deviceMap.audiooutput).call(i)))));case 5:case"end":return e.stop()}}),e,this)}))),function(){return o.apply(this,arguments)})},{key:"enumerateAudioCaptureDevices",value:(i=_asyncToGenerator(_regeneratorRuntime().mark((function e(){var t;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.getPermissions({audio:!0});case 2:return e.next=4,this.refreshDevices();case 4:return e.abrupt("return",from$2(values$1(t=this.deviceMap.audioinput).call(t)));case 5:case"end":return e.stop()}}),e,this)}))),function(){return i.apply(this,arguments)})},{key:"enumerateVideoCaptureDevices",value:(n=_asyncToGenerator(_regeneratorRuntime().mark((function e(){var t;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.getPermissions({video:!0});case 2:return e.next=4,this.refreshDevices();case 4:return e.abrupt("return",from$2(values$1(t=this.deviceMap.videoinput).call(t)));case 5:case"end":return e.stop()}}),e,this)}))),function(){return n.apply(this,arguments)})},{key:"enumerateAudioPlaybackDevices",value:(r=_asyncToGenerator(_regeneratorRuntime().mark((function e(){var t;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.getPermissions({audio:!0});case 2:return e.next=4,this.refreshDevices();case 4:return e.abrupt("return",from$2(values$1(t=this.deviceMap.audiooutput).call(t)));case 5:case"end":return e.stop()}}),e,this)}))),function(){return r.apply(this,arguments)})},{key:"getDeviceById",value:(t=_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",find$2(r).call(r,(function(e){return e.deviceId===t})));case 4:case"end":return e.stop()}}),e,this)}))),function(e){return t.apply(this,arguments)})}]),_}(),dd=new DeviceDetector;!isSSR2()&&(window.__rtc_dd__=dd);var logger$h=new Logger("AudioContext",1),WebAudioManager=function(){function e(){var t=this;_classCallCheck(this,e),_defineProperty(this,"_audioContextInstance",void 0),_defineProperty(this,"_contextStuckAt",0);var r=0;isSSR2()||setInterval((function(){if(t._audioContextInstance){var e=t._audioContextInstance.currentTime;t._contextStuckAt?t._contextStuckAt!==e&&(t._contextStuckAt=0,logger$h.print("currentTime resume"),reportGlobalInvokeStatus("currentTime resume","")):e&&r===e&&(t._contextStuckAt=e,logger$h.print("currentTime stuck",t._contextStuckAt),t._audioContextInstance.suspend(),t._audioContextInstance.resume(),reportGlobalInvokeStatus("AudioContext currentTime stuck",t._contextStuckAt)),r=e}}),3e3)}return _createClass(e,[{key:"getAudioContextInstance",value:function(){var e=this;if(!this._audioContextInstance){var t=window.AudioContext||window.webkitAudioContext;this._audioContextInstance=new t,this._audioContextInstance.onstatechange=function(){var t,r;logger$h.print("state change",null===(t=e._audioContextInstance)||void 0===t?void 0:t.state),"interrupted"===(null===(r=e._audioContextInstance)||void 0===r?void 0:r.state)&&e._audioContextInstance.resume()}}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 this._audioSource=r.createMediaElementSource(t),this._audioSource.connect(r.destination);var i=r.createAnalyser();this._audioSource.connect(i),this._analyserNode=i,this._ctx=r}var t;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;t.forEach((function(e){return r=Math.max(r,Math.abs(e-128))}));var n=r/128*255;return n>2?n:0}},{key:"resume",value:(t=_asyncToGenerator(_regeneratorRuntime().mark((function e(){var t;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,null===(t=this._ctx)||void 0===t?void 0:t.resume();case 2:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})},{key:"destroy",value:function(){this._audioSource.disconnect(),this._analyserNode.disconnect()}}]),e}(),audioContextManager=new WebAudioManager,RTCExtensionType=function(e){return e[e.CAPTURE=0]="CAPTURE",e[e.PRE_PROCESSING=1]="PRE_PROCESSING",e[e.ENCODE=2]="ENCODE",e[e.TRANSFER=3]="TRANSFER",e[e.POST_PROCESSING=4]="POST_PROCESSING",e[e.DECODE=5]="DECODE",e[e.RENDERING=6]="RENDERING",e}(RTCExtensionType||{}),ExtensionManager=function(){function e(t){_classCallCheck(this,e),_defineProperty(this,"_plugins",new map2),this.id=t}var t;return _createClass(e,[{key:"register",value:function(e){var t=this._plugins.get(e.type)||[];if(findIndex$1(t).call(t,(function(t){return t.name===e.name}))>-1)throw new Error("Failed to register ".concat(e.name,": name is repeated."));t.push(e),this._plugins.set(e.type,t)}},{key:"getPluginsByType",value:function(e){return this._plugins.get(e)||[]}},{key:"getPluginByName",value:function(e,t){var r;return find$2(r=this._plugins.get(e)||[]).call(r,(function(e){return e.name===t}))}},{key:"getPreProcessingTrack",value:(t=_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:r=this._plugins.get(1)||[],n=t.getTrack(),i=_createForOfIteratorHelper(r),e.prev=3,i.s();case 5:if((o=i.n()).done){e.next=12;break}return a=o.value,e.next=9,a.effect(t,n);case 9:n=e.sent;case 10:e.next=5;break;case 12:e.next=17;break;case 14:e.prev=14,e.t0=e.catch(3),i.e(e.t0);case 17:return e.prev=17,i.f(),e.finish(17);case 20:return e.abrupt("return",n);case 21:case"end":return e.stop()}}),e,this,[[3,14,17,20]])}))),function(e){return t.apply(this,arguments)})},{key:"destroy",value:function(){this._plugins.forEach((function(e){e.forEach((function(e){return e.destroy()}))})),this._plugins.clear()}}]),e}(),SourceType=function(e){return e[e.EXTERNAL=0]="EXTERNAL",e[e.INTERNAL=1]="INTERNAL",e}(SourceType||{}),logger$g=new Logger("VERTC",0),trackStreamMap=new weakMap,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)),"sourceType",1),_defineProperty(_assertThisInitialized(i),"mediaType",void 0),_defineProperty(_assertThisInitialized(i),"_trackId",void 0),_defineProperty(_assertThisInitialized(i),"_ac",void 0),_defineProperty(_assertThisInitialized(i),"_sourceNode",void 0),_defineProperty(_assertThisInitialized(i),"_gainNode",void 0),_defineProperty(_assertThisInitialized(i),"_destNode",void 0),_defineProperty(_assertThisInitialized(i),"_channelCount",void 0),i._trackId=e,i.mediaType=n,"audio"===n&&isWebAudioSupported()&&!getParameter("SKIP_WEB_AUDIO_IN_TRACK")&&(i._ac=audioContextManager.getAudioContextInstance(),i._gainNode=i._ac.createGain(),i._destNode=i._ac.createMediaStreamDestination(),i._gainNode.connect(i._destNode)),i}return _createClass(r,[{key:"getId",value:function(){return this._trackId}},{key:"setVolume",value:function(e){this._gainNode&&(this._gainNode.gain.value=e/100)}},{key:"getVolume",value:function(){return this._gainNode?Math.round(100*this._gainNode.gain.value):-1}},{key:"channelCount",get:function(){var e;return null!==(e=this._channelCount)&&void 0!==e?e:0}},{key:"connectAudioTrack",value:function(e){var t;if(this._channelCount=e.getSettings().channelCount,!isWebAudioSupported()||getParameter("SKIP_WEB_AUDIO_IN_TRACK"))return e;this._sourceNode&&(this._sourceNode.mediaStream.getTracks().forEach((function(e){e.stop()})),delete this._sourceNode);var r,n=new MediaStream;(n.addTrack(e),this._sourceNode=null===(t=this._ac)||void 0===t?void 0:t.createMediaStreamSource(n),this._gainNode)&&(null===(r=this._sourceNode)||void 0===r||r.connect(this._gainNode));return this._destNode.stream.getTracks()[0]}},{key:"destory",value:function(){var e,t,r,n;null===(e=this._sourceNode)||void 0===e||e.mediaStream.getTracks().forEach((function(e){e.stop()})),null===(t=this._destNode)||void 0===t||t.stream.getTracks().forEach((function(e){e.stop()})),null===(r=this._sourceNode)||void 0===r||r.disconnect(),null===(n=this._gainNode)||void 0===n||n.disconnect(),delete this._sourceNode,delete this._gainNode,delete this._destNode}}]),r}(),LocalTrack=function(e){_inherits(n,Track);var t,r=_createSuper(n);function n(e,t,i){var o;return _classCallCheck(this,n),_defineProperty(_assertThisInitialized(o=r.call(this,t,i)),"_mediaTrack",void 0),_defineProperty(_assertThisInitialized(o),"_preProcessingTrack",void 0),_defineProperty(_assertThisInitialized(o),"_originTrack",void 0),_defineProperty(_assertThisInitialized(o),"handleTrackEnded",(function(){o.emit("track-ended",_assertThisInitialized(o)),o.close()})),_defineProperty(_assertThisInitialized(o),"handleMute",(function(){o.emit("track-mute",_assertThisInitialized(o))})),_defineProperty(_assertThisInitialized(o),"handleUnmute",(function(){o.emit("track-unmute",_assertThisInitialized(o))})),o._mediaTrack="audio"===o.mediaType?o.connectAudioTrack(e):e,o._originTrack=e,o._initListeners(),o}return _createClass(n,[{key:"getTrack",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"origin";return"origin"===e?this._mediaTrack:this._preProcessingTrack||this._mediaTrack}},{key:"setTrack",value:function(e,t){this._mediaTrack="audio"===this.mediaType?this.connectAudioTrack(e):e,this._originTrack=e,t&&this.generatePreProcessingTrack(t)}},{key:"generatePreProcessingTrack",value:(t=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){var r;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this._preProcessingTrack=void 0,e.prev=1,e.next=4,t.getPreProcessingTrack(this);case 4:(r=e.sent)instanceof MediaStreamTrack&&(this._preProcessingTrack=r),e.next=11;break;case 8:e.prev=8,e.t0=e.catch(1),console.error(e.t0);case 11:case"end":return e.stop()}}),e,this,[[1,8]])}))),function(e){return t.apply(this,arguments)})},{key:"getOrgTrack",value:function(){return this._originTrack}},{key:"close",value:function(){var e,t,r,n,i;return this._mediaTrack.onended=null,this._mediaTrack.onmute=null,this._mediaTrack.onunmute=null,null===(e=this._originTrack)||void 0===e||e.removeEventListener("ended",this.handleTrackEnded),null===(t=this._originTrack)||void 0===t||t.removeEventListener("mute",this.handleMute),null===(r=this._originTrack)||void 0===r||r.removeEventListener("unmute",this.handleUnmute),null===(n=this._preProcessingTrack)||void 0===n||n.stop(),"audio"===this.mediaType?this.destory():null===(i=this._mediaTrack)||void 0===i?void 0:i.stop()}},{key:"_initListeners",value:function(){this._originTrack instanceof MediaStreamTrack&&(this._originTrack.addEventListener("ended",this.handleTrackEnded),this._originTrack.addEventListener("mute",this.handleMute),this._originTrack.addEventListener("unmute",this.handleUnmute))}}]),n}(),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),_defineProperty(_assertThisInitialized(o),"_originTrack",void 0),o._mediaTrack="audio"===o.mediaType?o.connectAudioTrack(e):e,o._originTrack=e,o}return _createClass(r,[{key:"getTrack",value:function(){return this._mediaTrack}},{key:"getOrgTrack",value:function(){return this._originTrack}},{key:"close",value:function(){return this.destory()}}]),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),"dummy",!1),i.resolution={width:0,height:0},i}return _createClass(n,[{key:"updateVideoCaptureConfig",value:(t=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){var r,n;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.getTrack()){e.next=2;break}return e.abrupt("return");case 2:return logger$g.print("updateVideoEncoderConfig","update localVideoTrack: ",t),delete(r=_objectSpread2({},t)).contentHint,isFirefox&&(r.frameRate={ideal:30,max:30}),e.next=8,this.getTrack().applyConstraints(r);case 8:((n=this.getTrack().getSettings()).width&&n.width!==this.resolution.width||n.height&&n.height!==this.resolution.height)&&(this.resolution={width:n.width,height:n.height},this.emit("resolution-change",this.resolution));case 10:case"end":return e.stop()}}),e,this)}))),function(e){return t.apply(this,arguments)})},{key:"replaceTrack",value:function(e){this.setTrack(e)}},{key:"setContentHint",value:function(e){var t;this._mediaTrack&&"contentHint"in this._mediaTrack&&includes4(t=["text","motion","detail"]).call(t,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),i}return _createClass(n,[{key:"getAudioLevel",value:function(){return this._audioLevelFetcher||(this._audioLevelFetcher=new AudioLevelFetcher(this.getTrack("preprocessing"))),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$g.print("updateAudioCaptureConfig","update localAudioTrack: ",this.audioCaptureConfig),e.next=5,null===(t=this.getOrgTrack())||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.getOrgTrack())),this._audioLevelFetcher.getAudioLevel()}}]),r}(),MicrophoneAudioTrack=function(e){_inherits(r,LocalAudioTrack);var t=_createSuper(r);function r(){var e,n;_classCallCheck(this,r);for(var i=arguments.length,o=new Array(i),a=0;a<i;a++)o[a]=arguments[a];return _defineProperty(_assertThisInitialized(n=t.call.apply(t,concat$2(e=[this]).call(e,o))),"streamIndex",StreamIndex.STREAM_INDEX_MAIN),n}return _createClass(r)}(),CameraVideoTrack=function(e){_inherits(r,LocalVideoTrack);var t=_createSuper(r);function r(){var e,n;_classCallCheck(this,r);for(var i=arguments.length,o=new Array(i),a=0;a<i;a++)o[a]=arguments[a];return _defineProperty(_assertThisInitialized(n=t.call.apply(t,concat$2(e=[this]).call(e,o))),"streamIndex",StreamIndex.STREAM_INDEX_MAIN),n}return _createClass(r)}(),CustomVideoLocalTrack=function(e){_inherits(r,LocalVideoTrack);var t=_createSuper(r);function r(){var e,n;_classCallCheck(this,r);for(var i=arguments.length,o=new Array(i),a=0;a<i;a++)o[a]=arguments[a];return _defineProperty(_assertThisInitialized(n=t.call.apply(t,concat$2(e=[this]).call(e,o))),"streamIndex",StreamIndex.STREAM_INDEX_MAIN),_defineProperty(_assertThisInitialized(n),"sourceType",0),n}return _createClass(r)}(),CustomAudioLocalTrack=function(e){_inherits(r,LocalAudioTrack);var t=_createSuper(r);function r(){var e,n;_classCallCheck(this,r);for(var i=arguments.length,o=new Array(i),a=0;a<i;a++)o[a]=arguments[a];return _defineProperty(_assertThisInitialized(n=t.call.apply(t,concat$2(e=[this]).call(e,o))),"streamIndex",StreamIndex.STREAM_INDEX_MAIN),_defineProperty(_assertThisInitialized(n),"sourceType",0),n}return _createClass(r)}(),ScreenVideoTrack=function(e){_inherits(r,LocalVideoTrack);var t=_createSuper(r);function r(){var e,n;_classCallCheck(this,r);for(var i=arguments.length,o=new Array(i),a=0;a<i;a++)o[a]=arguments[a];return _defineProperty(_assertThisInitialized(n=t.call.apply(t,concat$2(e=[this]).call(e,o))),"streamIndex",StreamIndex.STREAM_INDEX_SCREEN),n}return _createClass(r)}(),ScreenAudioTrack=function(e){_inherits(r,LocalAudioTrack);var t=_createSuper(r);function r(){var e,n;_classCallCheck(this,r);for(var i=arguments.length,o=new Array(i),a=0;a<i;a++)o[a]=arguments[a];return _defineProperty(_assertThisInitialized(n=t.call.apply(t,concat$2(e=[this]).call(e,o))),"streamIndex",StreamIndex.STREAM_INDEX_SCREEN),n}return _createClass(r)}(),CustomScreenVideoLocalTrack=function(e){_inherits(r,LocalVideoTrack);var t=_createSuper(r);function r(){var e,n;_classCallCheck(this,r);for(var i=arguments.length,o=new Array(i),a=0;a<i;a++)o[a]=arguments[a];return _defineProperty(_assertThisInitialized(n=t.call.apply(t,concat$2(e=[this]).call(e,o))),"streamIndex",StreamIndex.STREAM_INDEX_SCREEN),_defineProperty(_assertThisInitialized(n),"sourceType",0),n}return _createClass(r)}(),CustomScreenAudioLocalTrack=function(e){_inherits(r,LocalAudioTrack);var t=_createSuper(r);function r(){var e,n;_classCallCheck(this,r);for(var i=arguments.length,o=new Array(i),a=0;a<i;a++)o[a]=arguments[a];return _defineProperty(_assertThisInitialized(n=t.call.apply(t,concat$2(e=[this]).call(e,o))),"streamIndex",StreamIndex.STREAM_INDEX_SCREEN),_defineProperty(_assertThisInitialized(n),"sourceType",0),n}return _createClass(r)}();function createDummyVideoLocalTrack(e,t){return _createDummyVideoLocalTrack.apply(this,arguments)}function _createDummyVideoLocalTrack(){return(_createDummyVideoLocalTrack=_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 CameraVideoTrack(t,genUuid2())).dummy=!0,e.next=4,n.generatePreProcessingTrack(r);case 4:return e.abrupt("return",n);case 5:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function createDummyScreenVideoLocalTrack(e,t){return _createDummyScreenVideoLocalTrack.apply(this,arguments)}function _createDummyScreenVideoLocalTrack(){return(_createDummyScreenVideoLocalTrack=_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 ScreenVideoTrack(t,genUuid2())).dummy=!0,e.next=4,n.generatePreProcessingTrack(r);case 4:return e.abrupt("return",n);case 5:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function createCameraVideoTrack(e,t){return _createCameraVideoTrack.apply(this,arguments)}function _createCameraVideoTrack(){return(_createCameraVideoTrack=_asyncToGenerator(_regeneratorRuntime().mark((function e(t,r){var n,i,o,a,s,c,l,u;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return o=(null==t||null===(n=t.deviceId)||void 0===n?void 0:n.exact)||"default",a=getMonitor(r.id),e.prev=2,logger$g.print("createCameraVideoTrack","constraints:",t),null==a||a.report("rtc_video_capture_event",{event_type:"start",media_device_id:o}),s=getServerNow(),isFirefox&&(t.frameRate={ideal:30,max:30}),e.next=9,dd.getUserMedia({video:t});case 9:i=e.sent,null==a||a.report("rtc_video_capture_event",{event_type:"start_capture_result",media_device_id:o,reason:"success",elapse:getServerNow()-s}),e.next=17;break;case 13:throw e.prev=13,e.t0=e.catch(2),null==a||a.report("rtc_video_capture_event",{event_type:"running_failed",media_device_id:o,error_code:e.t0.code,reason:e.t0.name+e.t0.message}),new SDKError(ErrorCode.GET_VIDEO_TRACK_FAILED,concat$2(c="throw error from getUserMedia. [".concat(e.t0.name||"unknown name","]: ")).call(c,e.t0.message||"unknown message","."),e.t0);case 17:return l=i.getVideoTracks()[0],trackStreamMap.set(l,i),u=new CameraVideoTrack(l,genUuid2()),e.next=22,u.generatePreProcessingTrack(r);case 22:return e.abrupt("return",u);case 23:case"end":return e.stop()}}),e,null,[[2,13]])})))).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,l,u,d;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return logger$g.print("createMicrophoneAudioTrack","constraints:",t),o=(null==t||null===(n=t.deviceId)||void 0===n?void 0:n.exact)||"default",a=getMonitor(r.id),e.prev=3,null==a||a.report("rtc_video_capture_event",{event_type:"start",media_device_id:o}),s=getServerNow(),(c=r.getPluginByName(RTCExtensionType.PRE_PROCESSING,"RTCAIAnsExtension"))&&(c.isOpen()?(t.autoGainControl=!0,t.noiseSuppression=!1):t.noiseSuppression=!0),e.next=10,dd.getUserMedia({audio:t});case 10:i=e.sent,null==a||a.report("rtc_video_capture_event",{event_type:"start_capture_result",media_device_id:o,reason:"success",elapse:getServerNow()-s}),e.next=18;break;case 14:throw e.prev=14,e.t0=e.catch(3),null==a||a.report("rtc_video_capture_event",{event_type:"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,concat$2(l="throw error from getUserMedia. [".concat(e.t0.name||"unknown name","]: ")).call(l,e.t0.message||"unknown message","."),e.t0);case 18:return u=i.getAudioTracks()[0],trackStreamMap.set(u,i),d=new MicrophoneAudioTrack(u,genUuid2()),e.next=23,d.generatePreProcessingTrack(r);case 23:return e.abrupt("return",d);case 24:case"end":return e.stop()}}),e,null,[[3,14]])})))).apply(this,arguments)}function createScreenTracks(){return _createScreenTracks.apply(this,arguments)}function _createScreenTracks(){return _createScreenTracks=_asyncToGenerator(_regeneratorRuntime().mark((function e(){var t,r,n,i,o,a,s,c,l,u,d=arguments;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=d.length>0&&void 0!==d[0]&&d[0],r=d.length>1?d[1]:void 0,n=d.length>2?d[2]:void 0,logger$g.print("createScreenTracks","withAudio: %o, constraints: %o",t,n),o=getMonitor(r.id),e.prev=5,null==o||o.report("rtc_video_capture_event",{event_type:"start",media_device_id:"screen"}),a=getServerNow(),e.next=10,navigator.mediaDevices.getDisplayMedia({video:!(n&&(!isSafari||16!==safariVersion))||n,audio:!!t&&{channelCount:2,noiseSuppression:!1,echoCancellation:!1,autoGainControl:!1}});case 10:i=e.sent,null==o||o.report("rtc_video_capture_event",{event_type:"start_capture_result",media_device_id:"screen",reason:"success",elapse:getServerNow()-a}),e.next=18;break;case 14:throw e.prev=14,e.t0=e.catch(5),null==o||o.report("rtc_video_capture_event",{event_type:"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 18:return s=i.getVideoTracks()[0],c=new ScreenVideoTrack(s,genUuid2()),e.next=22,c.generatePreProcessingTrack(r);case 22:if(!(l=i.getAudioTracks()[0])){e.next=28;break}return u=new ScreenAudioTrack(l,genUuid2()),e.next=27,u.generatePreProcessingTrack(r);case 27:return e.abrupt("return",[c,u]);case 28:return e.abrupt("return",[c,void 0]);case 29:case"end":return e.stop()}}),e,null,[[5,14]])}))),_createScreenTracks.apply(this,arguments)}function createRemoteVideoTrack(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:genUuid2();return new RemoteVideoTrack(e,t)}function createRemoteAudioTrack(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:genUuid2();return new RemoteAudioTrack(e,t)}function createCustomVideoLocalTrack(e,t){return _createCustomVideoLocalTrack.apply(this,arguments)}function _createCustomVideoLocalTrack(){return(_createCustomVideoLocalTrack=_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 CustomVideoLocalTrack(t,genUuid2()),e.next=3,n.generatePreProcessingTrack(r);case 3:return e.abrupt("return",n);case 4:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function createCustomAudioLocalTrack(e,t){return _createCustomAudioLocalTrack.apply(this,arguments)}function _createCustomAudioLocalTrack(){return(_createCustomAudioLocalTrack=_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 CustomAudioLocalTrack(t,genUuid2()),e.next=3,n.generatePreProcessingTrack(r);case 3:return e.abrupt("return",n);case 4:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function createCustomScreenVideoLocalTrack(e,t){return _createCustomScreenVideoLocalTrack.apply(this,arguments)}function _createCustomScreenVideoLocalTrack(){return(_createCustomScreenVideoLocalTrack=_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 CustomScreenVideoLocalTrack(t,genUuid2()),e.next=3,n.generatePreProcessingTrack(r);case 3:return e.abrupt("return",n);case 4:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function createCustomScreenAudioLocalTrack(e,t){return _createCustomScreenAudioLocalTrack.apply(this,arguments)}function _createCustomScreenAudioLocalTrack(){return(_createCustomScreenAudioLocalTrack=_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 CustomScreenAudioLocalTrack(t,genUuid2()),e.next=3,n.generatePreProcessingTrack(r);case 3:return e.abrupt("return",n);case 4:case"end":return e.stop()}}),e)})))).apply(this,arguments)}var runtimeTrackCls={LocalVideoTrack:LocalVideoTrack,LocalAudioTrack:LocalAudioTrack,RemoteVideoTrack:RemoteVideoTrack,RemoteAudioTrack:RemoteAudioTrack},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,s,c=new Uint8Array(slice$1(a=t.buffer).call(a,i,i+n.headerLength));n.pos===t.position&&t.skip(n.headerLength),o=(n=e.getHeaderPositionAnnexB(t)).pos;var l={header:c,body:new Uint8Array(slice$1(s=t.buffer).call(s,i+c.byteLength,o)),type:-1};e.analyseNal(l),l.type<=9&&0!==l.type&&r.push(l),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,o,a=new Uint8Array(slice$1(i=t.buffer).call(i,t.position,t.position+4));t.skip(4);var s=new Uint8Array(slice$1(o=t.buffer).call(o,t.position,t.position+n));t.skip(n);var c={header:a,body:s,type:-1};e.analyseNal(c),c.type<=9&&0!==c.type&&r.push(c)}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}}}]),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,r=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=new Uint8Array([0,0,0,1]),i=new Uint8Array([6]),o=new Uint8Array([5]),a=r?UUID_INTERNAL:UUID_EXTERNAL,s=serializeData(e.byteLength+a.byteLength),c=rbsp2ebsp(e);return new Uint8Array(concat$2(t=[]).call(t,_toConsumableArray(n),_toConsumableArray(i),_toConsumableArray(o),_toConsumableArray(s),_toConsumableArray(a),_toConsumableArray(c),[128]))}},{key:"decodeSeiBody",value:function(e){e=slice$1(e).call(e,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&&slice$1(t).call(t,r,r+UUID_EXTERNAL.byteLength).toString()===UUID_EXTERNAL.toString()?(r+=UUID_EXTERNAL.byteLength,o=1):t.byteLength>=UUID_EXTERNAL.byteLength&&i>=UUID_EXTERNAL.byteLength&&slice$1(t).call(t,r,r+UUID_INTERNAL.byteLength).toString()===UUID_INTERNAL.toString()&&(r+=UUID_INTERNAL.byteLength,o=0),{type:o,payload:slice$1(t).call(t,r,a)}}}}},{key:"parseInternalSEI",value:function(e){var t=new map2,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,a=_slicedToArray(deserializeData(e.payload,r),2),s=a[0];if(r=a[1],t.get(i)||!(s<=e.payload.byteLength-r))break;t.set(i,slice$1(o=e.payload).call(o,r,r+s)),r+=s}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 l=reduce3(r).call(r,(function(e,t){return e+t.byteLength}),0),u=new Uint8Array(l);return reduce3(r).call(r,(function(e,t){return u.set(t,e),e+t.byteLength}),0),u}}]),e}(),Stats=function(){function e(t){_classCallCheck(this,e),_defineProperty(this,"player",void 0),_defineProperty(this,"_timer",void 0),_defineProperty(this,"handler",void 0),_defineProperty(this,"_monitor",void 0),this.id=t,this._monitor=getMonitor(t)}return _createClass(e,[{key:"setVar",value:function(e){this.handler=e}},{key:"clearTimer",value:function(){this._timer&&(clearTimeout(this._timer),delete this._timer,reportRtcInvokeStatus(this.id,"del_media_statistics_timer","".concat((new Error).stack),0,this._stream.streamId||""))}},{key:"filterIllegal",value:function(e){var t={};return keys$8(e).forEach((function(r){null===e[r]||void 0===e[r]||Number.isNaN(e[r])||(t[r]=e[r])})),t}},{key:"destroy",value:function(){reportRtcInvokeStatus(this.id,"media_statistics_destroy","".concat((new Error).stack),0,"".concat(this._stream.streamId)),this.clearTimer()}}]),e}(),LocalStatsReport=function(e){_inherits(i,Stats);var t,r,n=_createSuper(i);function i(e,t){var r;return _classCallCheck(this,i),_defineProperty(_assertThisInitialized(r=n.call(this,e)),"_context",void 0),r._stream=t,r}return _createClass(i,[{key:"setLocalStreamStatsEvtInterval",value:function(e,t,r){var n,i,o,a=this;if(!this._timer){this.setVar(t),this._context=r;var s={audio:{},video:{}},c=this._stream,l=null===(n=c.audioTrack)||void 0===n?void 0:n.getTrack("preprocessing"),u=null===(i=c.videoTrack)||void 0===i?void 0:i.getTrack("preprocessing");this.getAudioStats(l,s,null===(o=c.audioTrack)||void 0===o?void 0:o.getAudioLevel()),this.getVideoStats(u,s);var d=function(){var e=_asyncToGenerator(_regeneratorRuntime().mark((function e(){var t,r,n,i,o,l,u;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.getTrack("preprocessing"),o=null===(r=c.videoTrack)||void 0===r?void 0:r.getTrack("preprocessing"),e.next=4,a.getAudioStats(i,s,null===(n=c.audioTrack)||void 0===n?void 0:n.getAudioLevel());case 4:return l=e.sent,e.next=7,a.getVideoStats(o,s);case 7:return u=e.sent,e.abrupt("return",{audioStats:l,videoStats:u,isScreen:c.isScreen});case 9:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),p=function(){var t=_asyncToGenerator(_regeneratorRuntime().mark((function t(){var r;return _regeneratorRuntime().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,d();case 2:r=t.sent,e(r),a._timer=setTimeout(p,2e3);case 5:case"end":return t.stop()}}),t)})));return function(){return t.apply(this,arguments)}}();this._timer=setTimeout(p,2e3)}}},{key:"unpublish",value:function(){this.clearTimer()}},{key:"getAudioStats",value:(r=_asyncToGenerator(_regeneratorRuntime().mark((function e(t,r,n){var i,o,a,s,c,l,u,d,p,_,h,f,m;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(o={},a={timestamp:Date.now()},s=this._stream,c=s.streamId,l=s.audioMid,u=s.isScreen,d=s.pubAttributes,p=s.pubAudio,_=s.audioTrack,h={media_type:"audio",is_screen:!!u,direction:"up",stream_id:c,vid:l,connection_status:navigator.onLine,track_enabled:null==t?void 0:t.enabled,capture_state:d.localaudio?"capture_state_on":"capture_state_off",mute_state:p?"mute_state_off":"mute_state_on"},_&&(h.playback_volume=_.getVolume()),t&&this.handler){e.next=7;break}return e.abrupt("return",o);case 7:return e.next=9,this.handler.getStats(t);case 9:if((f=e.sent).length){e.next=12;break}return e.abrupt("return",o);case 12:if(f.forEach((function(e){var t=e.type,r=e.packetsSent,n=e.packetsLost,i=e.bytesSent,s=e.clockRate,c=e.roundTripTime,l=e.channels,u=e.audioLevel;e.googRtt;var d=e.mimeType,p=e.availableIncomingBitrate,_=e.availableOutgoingBitrate,f=e.bytesReceived,m=e.nominated,v=e.id,g=e.currentRoundTripTime,y=e.state,S=e.writable,T=e.requestsReceived,$=e.responsesReceived,E=e.requestsSent,b=e.consentRequestsSent,I=e.responsesSent,R=e.jitter,C=e.candidateType,A=e.ip,k=e.address,P=e.networkType,O=e.port,w=e.protocol,M=e.nackCount,D=e.retransmittedBytesSent,x=e.retransmittedPacketsSent,N=e.audioInputLevel,L=e.ssrc,U=e.totalAudioEnergy,V=e.totalSamplesDuration,B=e.mediaType,F=e.fractionLost;"outbound-rtp"===t?(a.packetsSent=r,a.bytesSent=i,h.bytes=i,h.packetsSent=r,h.nackCount=M,h.ssrc=L,h.retransmitted_bytes_sent=D,h.retransmitted_packets_sent=x,a.retransmittedBytesSent=D,a.retransmittedPacketsSent=x):"remote-inbound-rtp"===t?(a.packetsLost=n,h.packetsLost=n,h.net_jitter=1e3*R,o.rtt=1e3*c,h.rtt=o.rtt,o._fractionLost=F||0):"codec"===t?(o.recordSampleRate=s,o.numChannels=l,h.codecName=d):"media-source"===t&&void 0!==u?(h.audio_level=u?-10*log102(Math.pow(u,2)):u,h.volume=255*u,h.total_audio_energy=U,h.totalInputDuration=V):"ssrc"===t&&"audio"===B?h.send_level=N:"candidate-pair"===t?(h.ice_available_incoming_bitrate=p,h.ice_available_outgoing_bitrate=_,h.ice_bytes_received=f,h.ice_bytes_sent=i,h.ice_nominated=+m,h.ice_pair_id=v,h.ice_pair_rtt=g,h.ice_pair_state=y,h.ice_pair_writable=S,h.recv_ping_requests=T,h.recv_ping_responses=$,h.sent_ping_requests_before_first_response=E,h.sent_ping_requests_total=E+(b||0),h.sent_ping_responses=I):"local-candidate"===t?(h.local_candidate_type=C,h.local_ip=A||k,h.local_network_type=P,h.local_port=O,h.protocol=w):"remote-candidate"===t&&(h.remote_candidate_type=C,h.remote_ip=A||k,h.remote_port=O);var j=getParameter("STATS_SCALLBACK_SUPPORT");isStatsCallbackSupport&&j||"media-source"===t&&(h.send_level=u)})),void 0===h.volume&&void 0!==n&&(h.volume=n,h.audio_level=n?-10*log102(Math.pow(n/255,2)):n),(m=r.audio).timestamp){e.next=18;break}return r.audio=a,e.abrupt("return",this.filterIllegal(o));case 18:return void 0!==a.packetsLost&&(o.audioLossRate=(a.packetsLost-m.packetsLost)/(a.packetsSent-m.packetsSent),o.audioLossRate=Number.isNaN(o.audioLossRate)?0:o.audioLossRate,h.fraction_lost=o.audioLossRate),o.statsInterval=a.timestamp-m.timestamp,h.stats_interval=o.statsInterval,o.sendKBitrate=(a.bytesSent-m.bytesSent||0)/o.statsInterval*8,h.mediaBitratebps=Math.round(1e3*o.sendKBitrate),h.bandwidth=Math.round(h.mediaBitratebps/1024),void 0!==a.retransmittedBytesSent&&(h.retransmitBitratebps=(a.retransmittedBytesSent-m.retransmittedBytesSent||0)/o.statsInterval),r.audio=a,null===(i=this._monitor)||void 0===i||i.report("rtc_media_statistics",h),o._retransmittedRate=(a.retransmittedPacketsSent-m.retransmittedPacketsSent)/(a.packetsSent-m.packetsSent),void 0===o.audioLossRate&&(o.audioLossRate=o._retransmittedRate,h.fraction_lost=o.audioLossRate),o._fractionLost=Math.max(o._fractionLost,o.audioLossRate),e.abrupt("return",this.filterIllegal(o));case 31: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,l,u,d,p,_,h,f,m,v,g,y,S;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n={},i={timestamp:Date.now(),simulcast:{}},o=this._stream,a=o.streamId,s=o.videoMid,c=o.isScreen,l=o.pubAttributes,u=o.enableSimulcast,d=o.pubVideo,e.t0=_objectSpread2,e.t1={media_type:"video",is_screen:!!c,direction:"up",stream_id:a,vid:s,connection_status:navigator.onLine,track_enabled:null==t?void 0:t.enabled,capture_state:l.localvideo?"capture_state_on":"capture_state_off",mute_state:d?"mute_state_off":"mute_state_on"},e.next=7,this._stream.requestVideoFrameCallback();case 7:if(e.t2=e.sent,p=(0,e.t0)(e.t1,e.t2),t&&this.handler){e.next=11;break}return e.abrupt("return",n);case 11:return p.cap_frame_width=t.getSettings().width,p.cap_frame_height=t.getSettings().height,n.isScreen=c,e.next=16,this.handler.getStats(t);case 16:if((_=e.sent).length){e.next=19;break}return e.abrupt("return",n);case 19:if(h=0,_.forEach((function(e){var o=e.type,a=e.framesEncoded,s=e.packetsLost,c=e.bytesSent,l=e.framesSent,d=e.retransmittedBytesSent,_=e.totalPacketSendDelay,f=e.totalEncodeTime,m=e.firCount,v=e.targetBitrate,g=e.roundTripTime,y=e.mimeType,S=e.frameWidth,T=e.frameHeight,$=e.packetsSent,E=e.googActualEncBitrate,b=e.googAvailableReceiveBandwidth,I=e.googAvailableSendBandwidth,R=e.googAvgEncodeMs,C=e.googBucketDelay,A=e.googEncodeUsagePercent,k=e.googFrameRateInput,P=e.availableIncomingBitrate,O=e.availableOutgoingBitrate,w=e.bytesReceived,M=e.nominated,D=e.id,x=e.currentRoundTripTime,N=e.state,L=e.writable,U=e.candidateType,V=e.ip,B=e.address,F=e.networkType,j=e.port,G=e.nackCount,z=e.pliCount,H=e.protocol,K=e.qpSum,W=e.requestsReceived,Y=e.responsesReceived,q=e.googRetransmitBitrate,X=e.requestsSent,Z=e.consentRequestsSent,Q=e.responsesSent,J=e.ssrc,ee=e.googTargetEncBitrate,te=e.googTransmitBitrate,re=e.retransmittedPacketsSent,ne=e.encoderImplementation,ie=e.jitter,oe=e.rid,ae=e.fractionLost,se=e.googAdaptationChanges,ce=e.qualityLimitationReason,le=e.qualityLimitationDurations,ue=e.googFirsReceived,de=e.googFrameRateSent,pe=e.keyFramesEncoded;"outbound-rtp"===o?(u&&(oe?i.simulcast[oe]=e:i.simulcast[h]=e,h++),i.framesEncoded=a||i.framesEncoded||0,p.key_frames_encoded=pe||0,i.bytesSent=c||i.bytesSent||0,i.framesSent=l||i.framesSent||0,p.bytes=c||p.bytes||0,i.packetsSent=$||i.packetsSent||0,p.packetsSent=$||p.packetsSent||0,p.nackCount=G||p.nackCount||0,p.pli_count=z||p.pli_count||0,p.qp_sum=K||p.qp_sum||0,p.ssrc=J||p.ssrc||0,p.retransmitted_packets_sent=re,i.retransmittedPacketsSent=re,i.retransmittedBytesSent=d,p.encoder_implementation=ne,p.qualityLimitationReason=ce,p.qualityLimitationDurations=le,void 0!==S&&((!n.encodedFrameWidth||S>n.encodedFrameWidth)&&(n.encodedFrameWidth=S),(!n.encodedFrameHeight||T>n.encodedFrameHeight)&&(n.encodedFrameHeight=T),p.frame_size_height=T,p.frame_size_width=S)):"track"===o?(n.encodedFrameWidth=S,n.encodedFrameHeight=T,p.frame_size_height=T,p.frame_size_width=S):"remote-inbound-rtp"===o?(i.packetsLost=s,n.rtt=1e3*g,p.rtt=n.rtt,p.jitter=ie,p.packetsLost=s,n._fractionLost=ae||0):"codec"===o?(n.codecType=y,p.codecName=y):"candidate-pair"===o?(p.ice_available_incoming_bitrate=P,p.ice_available_outgoing_bitrate=O,p.ice_bytes_received=w,p.ice_bytes_sent=c,p.ice_nominated=+M,p.ice_pair_id=D,p.ice_pair_rtt=x,p.ice_pair_state=N,p.ice_pair_writable=L,p.recv_ping_requests=W,p.recv_ping_responses=Y,p.sent_ping_requests_before_first_response=X,p.sent_ping_requests_total=X+Z,p.sent_ping_responses=Q):"local-candidate"===o?(p.local_candidate_type=U,p.local_ip=V||B,p.local_network_type=F,p.local_port=j,p.protocol=H):"remote-candidate"===o?(p.remote_candidate_type=U,p.remote_ip=V||B,p.remote_port=j):"VideoBwe"===o?(p.encBitratebps=E,p.available_receive_bandwidth=b,p.available_send_bandwidth=I,p.bucket_delay=C,p.retransmitBitratebps=q,p.targetEncBitratebps=ee,p.transmit_bitrate=te,n._sendBandWidth=+I):"ssrc"===o&&(p.avg_encode_ms=R,p.encodeUsage=A,p.frame_rate_input=k,p.orignal_input_Framerate=+k,p.ddaptationChanges=se,p.firsReceived=ue,p.frameRateSent=de);var _e=getParameter("STATS_SCALLBACK_SUPPORT");if(!isStatsCallbackSupport||!_e){var he=r.video,fe=i.timestamp-he.timestamp;if("outbound-rtp"===o){var me=c-he.bytesSent,ve=d-he.retransmittedBytesSent;p.encBitratebps=Math.round(8e3*(me-ve)/fe),p.bucket_delay=_/$,p.retransmitBitratebps=Math.round(8e3*ve/fe),p.targetEncBitratebps=v,p.transmit_bitrate=Math.round(1e3*(c-he.bytesSent)*8/fe),p.avg_encode_ms=1e3*f/a,p.firsReceived=m+z}else"candidate-pair"===o&&(p.available_send_bandwidth=O,n._sendBandWidth=O);if(t){var ge=null==t?void 0:t.getSettings().frameRate;p.orignal_input_Framerate=ge,p.frameRateSent=t.getSettings().frameRate}}})),(f=r.video).timestamp){e.next=25;break}return r.video=i,e.abrupt("return",this.filterIllegal(n));case 25:return n.statsInterval=i.timestamp-f.timestamp,p.stats_interval=n.statsInterval,m=keys$8(i.simulcast),u?(p.sim_enc_width=[],p.sim_enc_height=[],p.sim_enc_bps=[],p.sim_enc_framerate=[],p.sim_enc_key_frames=[],p.sim_rids=[],p.sim_enc_bandwidth=[],p.sim_sent_framerate=[],p.sim_fraction_lost=[],p.sim_keyencoded=[],p.active_sim_streams=(null===(v=this._context)||void 0===v?void 0:v.activeSimStreams)||[],p.sim_retransmittedRate=[],y=!1,sort2(m).call(m,(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,l=t.packetsLost,u=t.packetsSent,d=t.qualityLimitationReason,_=t.qualityLimitationDurations,h=t.qualityLimitationResolutionChanges,m=t.retransmittedPacketsSent,v=t.pliCount,g=t.keyFramesEncoded;void 0!==d&&(p.sim_qualityLimitationReason||(p.sim_qualityLimitationReason=[],p.sim_qualityLimitationDurations=[],p.sim_qualityLimitationResolutionChanges=[]),p.sim_qualityLimitationReason.push(d),p.sim_qualityLimitationDurations.push(_),p.sim_qualityLimitationResolutionChanges.push(h));var S=f.simulcast[e];if(p.sim_enc_width.push(r||0),p.sim_enc_height.push(o||0),p.sim_enc_key_frames.push(g||0),S){var T=(a-S.bytesSent||0)/n.statsInterval;p.sim_enc_bps.push(Math.round(8e3*T)),p.sim_enc_bandwidth.push(Math.round(8e3*T/1024));var $=1e3*(s-S.framesEncoded)/n.statsInterval;p.sim_enc_framerate.push(Math.round($)),p.sim_rids.push(e);var E=void 0!==c?c-S.framesSent:s-S.framesEncoded,b=1e3*E/n.statsInterval;p.sim_sent_framerate.push(Math.round(b));var I=(l-S.packetsLost)/(u-S.packetsSent);n._retransmittedRate=(m-S.retransmittedPacketsSent)/(u-S.packetsSent),I=Number.isNaN(I)?0:I,p.sim_fraction_lost.push(I),p.sim_keyencoded.push(v-S.pliCount>0),p.sim_retransmittedRate.push(n._retransmittedRate),r>0&&!y&&(n.sentKBitrate=8*T,n.encoderOutputFrameRate=$,n.encodedFrameCount=E,n.sentFrameRate=b,n.videoLossRate=I,y=!0)}})),null===(g=this._monitor)||void 0===g||g.report("rtc_media_statistics",p)):(n.encodedFrameCount=void 0!==i.framesSent?i.framesSent-f.framesSent:i.framesEncoded-f.framesEncoded,n.sentKBitrate=(i.bytesSent-f.bytesSent||0)/n.statsInterval*8,p.bitrate=Math.round(1e3*n.sentKBitrate),p.bandwidth=Math.round(p.bitrate/1024),n.encoderOutputFrameRate=1e3*(i.framesEncoded-f.framesEncoded)/n.statsInterval,p.frame_rate_encoded=Math.round(n.encoderOutputFrameRate),n.sentFrameRate=1e3*n.encodedFrameCount/n.statsInterval,p.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,p.fraction_lost=n.videoLossRate,n._retransmittedRate=(i.retransmittedPacketsSent-f.retransmittedPacketsSent)/(i.packetsSent-f.packetsSent),null===(S=this._monitor)||void 0===S||S.report("rtc_media_statistics",p)),r.video=i,n._fractionLost=Math.max(n._fractionLost,n.videoLossRate),e.abrupt("return",this.filterIllegal(n));case 32: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,t){var r;return _classCallCheck(this,o),_defineProperty(_assertThisInitialized(r=i.call(this,e)),"isPaused",void 0),_defineProperty(_assertThisInitialized(r),"pauseStart",void 0),_defineProperty(_assertThisInitialized(r),"pauseDuration",void 0),_defineProperty(_assertThisInitialized(r),"_audioStallCount",void 0),_defineProperty(_assertThisInitialized(r),"_setAudioStallCount",void 0),_defineProperty(_assertThisInitialized(r),"_audioStallTimer",void 0),_defineProperty(_assertThisInitialized(r),"_audioStallInterval",void 0),_defineProperty(_assertThisInitialized(r),"_audioStallRatio",void 0),_defineProperty(_assertThisInitialized(r),"_videoInWaiting",void 0),_defineProperty(_assertThisInitialized(r),"_context",void 0),r._stream=t,r._videoInWaiting=!1,r.pauseDuration=0,r}return _createClass(o,[{key:"setRemoteStreamStatsEvtInterval",value:(n=_asyncToGenerator(_regeneratorRuntime().mark((function e(t,r,n){var i,a,s,c,l,u,d,p,_,h,f,m,v,g,y,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(r),this._context=n,this._audioStallInterval=o.audioStallInterval||100,this._audioStallRatio=o.audioStallRatio||.6,c={audio:{},video:{}},l=this._stream,u=null===(i=l.audioTrack)||void 0===i?void 0:i.getOrgTrack(),d=null===(a=l.videoTrack)||void 0===a?void 0:a.getTrack(),this.getRemoteVideoStats(d,c),e.next=13,this.getRemoteAudioStats(u,c,null===(s=this._stream.audioTrack)||void 0===s?void 0:s.getAudioLevel());case 13:this.delStatsEvtInterval(),p=0,_=0,f=[],m=0,v=getServerNow(),this._setAudioStallCount=function(){if(Config.AUDIO_STALL&&S._audioStallInterval>0&&void 0!==c.audio.concealedSamples){var e=c.audio.concealedSamples,t=c.audio.totalSamplesReceived;v=getServerNow();var r={isStall:!1,counted:!1,diff:0},n=.5*S._audioStallInterval;S._audioStallCount=_asyncToGenerator(_regeneratorRuntime().mark((function i(){var o,a,s,c,u,d,h,g,y,T,$,E,b,I,R,C,A;return _regeneratorRuntime().wrap((function(i){for(;;)switch(i.prev=i.next){case 0:if(a=l.hasAudio,s=l.subAudio,a&&s){i.next=7;break}return r.isStall=!1,r.counted=!1,f.push({reason:concat$2(c="hasAudio: ".concat(a,", subAudio: ")).call(c,s)}),v=getServerNow(),i.abrupt("return",{stall_count:p,stall_duration:_,stall_list:f,stats_count:m});case 7:return u=null===(o=l.audioTrack)||void 0===o?void 0:o.getOrgTrack(),d=Date.now(),i.next=11,S.handler.getStats(u,!0);case 11:if(h=i.sent,g=Date.now(),y=getServerNow(),!((T=y-v)<n)){i.next=18;break}return f.push({diff:T,start:v,end:y,get_stats_cost:g-d,get_stats_start:d,get_stats_end:g,reason:concat$2($="diff(".concat(T,") < minInterval(")).call($,n,")")}),i.abrupt("return",{stall_count:p,stall_duration:_,stall_list:f,stats_count:m});case 18:if(E=h.length,b=find$2(h).call(h,(function(e){return"inbound-rtp"===e.type}))){i.next=23;break}return f.push({diff:T,start:v,end:y,get_stats_cost:g-d,get_stats_start:d,get_stats_end:g,reason:E?"no inbound-rtp":"no report"}),i.abrupt("return",{stall_count:p,stall_duration:_,stall_list:f,stats_count:m});case 23:return I=b.concealedSamples,R=b.totalSamplesReceived,A=R-t,(C=I-e)>=0&&A>=0&&C>=S._audioStallRatio*A?(f.push({concealed:C,received:A,diff:T,start:v,end:y,get_stats_cost:g-d,get_stats_start:d,get_stats_end:g,is_stall:!0}),r.isStall?(r.counted?_+=T:(_=_+r.diff+T,p++),r.counted=!0):T>=200?(_+=T,p++,r.counted=!0):(r.counted=!1,r.diff=T),r.isStall=!0):(f.push({concealed:C,received:A,diff:T,start:v,end:y,get_stats_cost:g-d,get_stats_start:d,get_stats_end:g}),r.isStall=!1,r.counted=!1),e=I,t=R,v=y,m++,i.abrupt("return",{stall_count:p,stall_duration:_,stall_list:f,stats_count:m});case 32:case"end":return i.stop()}}),i)}))),h=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=6;break}return e.next=4,S._audioStallCount();case 4:S._audioStallTimer&&clearTimeout(S._audioStallTimer),S._audioStallTimer=setTimeout(h,S._audioStallInterval);case 6:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),S._audioStallTimer&&clearTimeout(S._audioStallTimer),S._audioStallTimer=setTimeout(h,S._audioStallInterval)}},this._setAudioStallCount(),g=function(){var e=_asyncToGenerator(_regeneratorRuntime().mark((function e(){var t,r,n,i,o,a,s;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=null===(t=l.audioTrack)||void 0===t?void 0:t.getOrgTrack(),o=null===(r=l.videoTrack)||void 0===r?void 0:r.getTrack(),e.next=4,S.getRemoteAudioStats(i,c,null===(n=S._stream.audioTrack)||void 0===n?void 0:n.getAudioLevel());case 4:return a=e.sent,p=0,_=0,f=[],m=0,e.next=11,S.getRemoteVideoStats(o,c);case 11:return s=e.sent,e.abrupt("return",{audioStats:a,videoStats:s,isScreen:l.isScreen,userId:l.userId});case 13:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),y=function(){var e=_asyncToGenerator(_regeneratorRuntime().mark((function e(){var r;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,g();case 2:r=e.sent,t(r),h&&(v=getServerNow(),S._audioStallTimer&&clearTimeout(S._audioStallTimer),S._audioStallTimer=setTimeout(h,S._audioStallInterval)),S._timer&&clearTimeout(S._timer),S._timer=setTimeout(y,2e3);case 7:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),this._timer&&clearTimeout(this._timer),this._timer=setTimeout(y,2e3);case 25:case"end":return e.stop()}}),e,this)}))),function(e,t,r){return n.apply(this,arguments)})},{key:"delStatsEvtInterval",value:function(){_get(_getPrototypeOf(o.prototype),"clearTimer",this).call(this),clearTimeout(this._audioStallTimer),this._audioStallCount=void 0,this._setAudioStallCount=void 0,this.pauseDuration=0}},{key:"unsubscribe",value:function(){this.delStatsEvtInterval(),this._videoInWaiting=!1}},{key:"getRemoteAudioStats",value:(r=_asyncToGenerator(_regeneratorRuntime().mark((function e(t,r,n){var i,o,a,s,c,l,u,d,p,_,h,f,m,v,g,y,S,T,$,E,b,I=this;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(o={},a={},s=this._stream,c=s.streamId,l=s.userId,u=s.isScreen,d=s.audioMid,p=s.subMediaType,_=s._attributes,h=s.virtual,f=s.audioTrack,m={media_type:"audio",is_screen:!!u,direction:"down",stream_id:c,stream_user_id:l,vid:d,audio_mux:h,connection_status:navigator.onLine,track_enabled:null==t?void 0:t.enabled,mute_state:audioInMediaType(p)?"mute_state_off":"mute_state_on",remote_user_capture_state:_.localaudio?"capture_state_on":"capture_state_off",remote_user_mute_state:_.localaudio&&_.audiostream?"mute_state_off":"mute_state_on"},f&&(m.playback_volume=f.getVolume()),t&&this.handler){e.next=7;break}return e.abrupt("return",o);case 7:return e.next=9,this.handler.getStats(t);case 9:if((v=e.sent).length){e.next=12;break}return e.abrupt("return",o);case 12:if(v.forEach((function(e){var t=e.type,r=e.packetsLost,i=e.packetsReceived,s=e.bytesReceived,l=e.jitterBufferDelay,u=e.jitterBufferEmittedCount,d=e.clockRate,p=e.channels,_=e.totalSamplesReceived,h=e.concealedSamples,f=e.silentConcealedSamples,v=e.concealmentEvents,g=e.totalRoundTripTime,y=e.packetsDiscarded,S=e.state,T=e.currentRoundTripTime,$=e.audioLevel,E=e.totalAudioEnergy,b=e.totalSamplesDuration,R=e.mimeType,C=e.googDecodingNormal,A=e.googDecodingMuted,k=e.availableIncomingBitrate,P=e.availableOutgoingBitrate,O=e.bytesSent,w=e.nominated,M=e.id,D=e.writable,x=e.jitter,N=e.candidateType,L=e.ip,U=e.address,V=e.networkType,B=e.port,F=e.protocol,j=e.audioOutputLevel,G=e.requestsReceived,z=e.responsesReceived,H=e.requestsSent,K=e.consentRequestsSent,W=e.responsesSent,Y=e.ssrc;e.kind;var q=e.nackCount,X=e.lastPacketReceivedTimestamp,Z=e.concealmentevents,Q=e.fecPacketsReceived;if("inbound-rtp"===t)a.packetsLost=r,a.packetsReceived=i,m.packetsReceived=i,m.packetsDiscarded=y,m.nackCount=q,m.lastPacketReceivedTimestamp=X,m.concealmentevents=Z,a.bytesReceived=s,void 0!==l&&(o.jitterBufferDelay=l/u*1e3,m.average_jitter_buffer_delay_ms=o.jitterBufferDelay),void 0!==_&&(a.totalSamplesReceived=_,o.concealedSamples=h,a.concealedSamples=h,a.silentConcealedSamples=f,m.concealedSamples=h,o.concealmentEvents=v,m.totalSamplesReceived=_),void 0!==Q&&(m.fec_packets_received=Q,a.fecPacketsReceived=Q),m.jitter=1e3*x,m.ssrc=Y,void 0!==$&&0!==$?(m.audio_level=$?-10*log102(Math.pow($,2)):$,m.volume=255*$):(m.volume=null!=n?n:255*$,m.audio_level=n?-10*log102(Math.pow(n/255,2)):n),void 0!==E&&(m.total_audio_energy=E),void 0!==b&&(m.totalAudioDuration=b);else if("codec"===t)o.recordSampleRate=d,p&&(o.numChannels=p),m.codecName=R;else if("candidate-pair"===t){var J,ee,te;m.ice_available_incoming_bitrate=k,m.ice_available_outgoing_bitrate=P,m.ice_bytes_received=s,m.ice_bytes_sent=O,m.ice_nominated=+w,m.ice_pair_id=M,m.ice_pair_rtt=T,m.rtt=1e3*T,m.rtt&&null!==(J=I._context)&&void 0!==J&&null!==(ee=J.streamRTT)&&void 0!==ee&&null!==(te=ee[c])&&void 0!==te&&te.audio&&(m.total_rtt_ms=m.rtt+I._context.streamRTT[c].audio),m.ice_pair_state=S,m.ice_pair_writable=D,m.recv_ping_requests=G,m.recv_ping_responses=z,m.sent_ping_requests_before_first_response=H,m.sent_ping_requests_total=H+(K||0),m.sent_ping_responses=W,"succeeded"===S&&(o.rtt=1e3*T,o.total_rtt=1e3*g)}else"track"===t&&void 0!==$?(0===$&&0!==n?(m.volume=n,m.audio_level=n?-10*log102(Math.pow(n/255,2)):n):(m.audio_level=$?-10*log102(Math.pow($,2)):$,m.volume=255*$),m.total_audio_energy=E,m.totalAudioDuration=b):"ssrc"===t?(m.decodingNormal=C,m.recvAudioLevel=j,m.decodingMuted=A):"local-candidate"===t?(m.local_candidate_type=N,m.local_ip=L||U,m.local_network_type=V,m.local_port=B,m.protocol=F):"remote-candidate"===t&&(m.remote_candidate_type=N,m.remote_ip=L||U,m.remote_port=B)})),(g=r.audio).timestamp){e.next=18;break}return a.timestamp=Date.now(),r.audio=a,e.abrupt("return",this.filterIllegal(o));case 18:if(y={},void 0!==a.concealedSamples&&(m.interval_concealed_samples=a.concealedSamples-g.concealedSamples,m.interval_samples_received=a.totalSamplesReceived-g.totalSamplesReceived,m.interval_silent_concealed_samples=a.silentConcealedSamples-g.silentConcealedSamples),!(this._audioStallInterval>0&&void 0!==g.concealedSamples)){e.next=36;break}if(!this._audioStallCount&&this._setAudioStallCount&&this._setAudioStallCount(),clearTimeout(this._audioStallTimer),!this._audioStallCount){e.next=36;break}return e.next=26,this._audioStallCount();case 26:S=e.sent,T=S.stall_count,$=S.stall_duration,E=S.stall_list,b=S.stats_count,y.stall_list=E,y.stats_count=b,m.concealedSamples===m.interval_concealed_samples&&m.totalSamplesReceived===m.interval_samples_received?(m.stall_count=0,m.stall_duration=0):(m.stall_count=T,m.stall_duration=$),o.stallCount=m.stall_count,o.stallDuration=m.stall_duration;case 36:return a.timestamp=Date.now(),o.audioLossRate=(a.packetsLost-g.packetsLost)/(a.packetsReceived-g.packetsReceived+(a.packetsLost-g.packetsLost)),o.audioLossRate=Number.isNaN(o.audioLossRate)?0:o.audioLossRate,m.packetsLost=Math.round(a.packetsLost-g.packetsLost),m.fraction_lost=o.audioLossRate,o.statsInterval=a.timestamp-g.timestamp,m.stats_interval=o.statsInterval,o.receivedKBitrate=(a.bytesReceived-g.bytesReceived||0)/o.statsInterval*8,m.bandwidth=Math.round(1e3*o.receivedKBitrate/1024),void 0!==a.concealedSamples&&(o.receivedSampleRate=1e3*m.interval_samples_received/o.statsInterval),void 0!==a.fecPacketsReceived&&(m.fecBitratebps=(a.fecPacketsReceived-g.fecPacketsReceived||0)/o.statsInterval),m.average_jitter_buffer_delay_ms&&m.total_rtt_ms&&(o.e2eDelay=m.average_jitter_buffer_delay_ms+m.total_rtt_ms),r.audio=a,null===(i=this._monitor)||void 0===i||i.report("rtc_media_statistics",m,y),e.abrupt("return",this.filterIllegal(o));case 51:case"end":return e.stop()}}),e,this)}))),function(e,t,n){return r.apply(this,arguments)})},{key:"getRemoteVideoStats",value:(t=_asyncToGenerator(_regeneratorRuntime().mark((function e(t,r){var n,i,o,a,s,c,l,u,d,p,_,h,f,m=this;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i={},o={timestamp:Date.now()},a=this._stream,s=a.streamId,c=a.userId,l=a.isScreen,u=a.subMediaType,d=a._attributes,e.t0=_objectSpread2,e.t1={media_type:"video",is_screen:!!l,direction:"down",stream_id:s,stream_user_id:c,vid:this._stream.videoMid,connection_status:navigator.onLine,track_enabled:null==t?void 0:t.enabled,mute_state:videoInMediaType(u)?"mute_state_off":"mute_state_on",remote_user_capture_state:d.localvideo?"capture_state_on":"capture_state_off",remote_user_mute_state:d.localvideo&&d.videostream?"mute_state_off":"mute_state_on"},e.next=7,this._stream.requestVideoFrameCallback();case 7:if(e.t2=e.sent,p=(0,e.t0)(e.t1,e.t2),t&&this.handler){e.next=11;break}return e.abrupt("return",i);case 11:return i.isScreen=l,e.next=14,this.handler.getStats(t);case 14:if((_=e.sent).length){e.next=17;break}return e.abrupt("return",i);case 17:if(_.forEach((function(e){var t=e.type,r=e.frameHeight,n=e.frameWidth,a=e.packetsLost,c=e.packetsReceived,l=e.bytesReceived,u=e.framesDecoded,d=e.jitterBufferDelay,_=e.jitterBufferEmittedCount,h=e.mimeType,f=e.firCount,v=e.availableIncomingBitrate,g=e.availableOutgoingBitrate,y=e.bytesSent,S=e.nominated,T=e.id,$=e.currentRoundTripTime,E=e.state,b=e.writable,I=e.candidateType,R=e.ip,C=e.address,A=e.networkType,k=e.port,P=e.nackCount,O=e.pliCount,w=e.protocol,M=e.requestsReceived,D=e.responsesReceived,x=e.requestsSent,N=e.consentRequestsSent,L=e.responsesSent,U=e.ssrc,V=e.jitter,B=e.framesReceived,F=e.keyFramesDecoded,j=e.totalDecodeTime,G=e.decoderImplementation,z=e.lastPacketReceivedTimestamp;if("inbound-rtp"===t)o.packetsLost=a,p.packetsLost=a,o.packetsReceived=c,p.packetsReceived=c,o.bytesReceived=l,p.bytes=l,o.framesDecoded=u,o.totalDecodeTime=j,void 0!==d&&(o.jitterBufferDelay=d/_*1e3,p.average_jitter_buffer_delay_ms=o.jitterBufferDelay),p.fir_count=f,p.nackCount=P,o.nackCount=P,p.pli_count=O,p.ssrc=U,p.jitter=V,p.framesReceived=B,o.framesReceived=B,p.framesDecoded=u,p.key_frames_decoded=F,p.decoder_name=G,p.last_packet_received_timestamp=z,void 0!==n&&(i.width=n,p.frame_size_width=n,i.height=r,p.frame_size_height=r);else if("track"===t&&void 0!==n)i.width=n,p.frame_size_width=n,i.height=r,p.frame_size_height=r,void 0!==B&&(p.framesReceived=B,o.framesReceived=B);else if("codec"===t)p.codecName=h;else if("candidate-pair"===t){var H,K,W;p.ice_available_incoming_bitrate=v,p.ice_available_outgoing_bitrate=g,p.ice_bytes_received=l,p.ice_bytes_sent=y,p.ice_nominated=+S,p.ice_pair_id=T,p.ice_pair_rtt=$,p.rtt=1e3*$,p.rtt&&null!==(H=m._context)&&void 0!==H&&null!==(K=H.streamRTT)&&void 0!==K&&null!==(W=K[s])&&void 0!==W&&W.video&&(p.total_rtt_ms=p.rtt+m._context.streamRTT[s].video),i.rtt=p.rtt,p.ice_pair_state=E,p.ice_pair_writable=b,p.recv_ping_requests=M,p.recv_ping_responses=D,p.sent_ping_requests_before_first_response=x,p.sent_ping_requests_total=x+(N||0),p.sent_ping_responses=L}else"local-candidate"===t?(p.local_candidate_type=I,p.local_ip=R||C,p.local_network_type=A,p.local_port=k,p.protocol=w):"remote-candidate"===t&&(p.remote_candidate_type=I,p.remote_ip=R||C,p.remote_port=k)})),(h=r.video).timestamp){e.next=22;break}return r.video=o,e.abrupt("return",this.filterIllegal(i));case 22:return i.videoLossRate=(o.packetsLost-h.packetsLost)/(o.packetsReceived-h.packetsReceived+(o.packetsLost-h.packetsLost)),h.totalDecodeTime&&h.framesDecoded&&o.framesDecoded!==h.framesDecoded&&(p.decode_elapse_per_frame=+((o.totalDecodeTime-h.totalDecodeTime)/(o.framesDecoded-h.framesDecoded)*1e3).toFixed(2)),i._retransmittedRate=(o.nackCount-h.nackCount)/(o.packetsReceived-h.packetsReceived+(o.packetsLost-h.packetsLost)),i.videoLossRate=Number.isNaN(i.videoLossRate)?0:i.videoLossRate,p.fraction_lost=i.videoLossRate,i.statsInterval=o.timestamp-h.timestamp,p.stats_interval=i.statsInterval,i.receivedKBitrate=(o.bytesReceived-h.bytesReceived||0)/i.statsInterval*8,p.bitrate=Math.round(1e3*i.receivedKBitrate),p.bandwidth=Math.round(p.bitrate/1024),i.decoderOutputFrameRate=1e3*(o.framesDecoded-h.framesDecoded)/i.statsInterval,i.receivedFrameRate=1e3*(o.framesReceived-h.framesReceived)/i.statsInterval,p.frame_rate_decoded=Math.round(i.decoderOutputFrameRate),p.frame_rate_received=Math.round(i.receivedFrameRate),p.average_jitter_buffer_delay_ms&&p.total_rtt_ms&&(i.e2eDelay=p.average_jitter_buffer_delay_ms+p.total_rtt_ms),r.video=o,this.processStall(this._stream,p,i,l),this.isPaused?(f=o.timestamp-(this.pauseStart||0),p.pause_duration=this.pauseDuration+(f>500?f:0),this.pauseStart=o.timestamp):p.pause_duration=this.pauseDuration,p.pause_duration=Math.min(p.stall_duration||p.stuck_length||0,p.pause_duration),this.pauseDuration=0,null===(n=this._monitor)||void 0===n||n.report("rtc_media_statistics",p),e.abrupt("return",this.filterIllegal(i));case 44: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&&this.player&&this.player.played){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=Math.min(o,t.stats_interval),t.stall_duration=void 0):(t.stall_duration=Math.min(o,t.stats_interval),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,logger$f=new Logger("Stream",0),StreamBase=function(e){_inherits(r,EnhancedEventEmitter);var t=_createSuper(r);function r(){var e,n;_classCallCheck(this,r);for(var i=arguments.length,o=new Array(i),a=0;a<i;a++)o[a]=arguments[a];return _defineProperty(_assertThisInitialized(n=t.call.apply(t,concat$2(e=[this]).call(e,o))),"videoDom",void 0),n}return _createClass(r,[{key:"requestVideoFrameCallback",value:function(){var e=this;return new promise((function(t){var r,n=null===(r=e.videoDom)||void 0===r?void 0:r.requestVideoFrameCallback;if("function"==typeof n){var i=function(e,r){var n={};keys$8(r).forEach((function(e){var t=e.replace(/[a-z]{1}[A-Z]{1}/g,(function(e){var t;return concat$2(t="".concat(e[0],"_")).call(t,e[1].toLowerCase())}));n["video_".concat(t)]=r[e]})),clearInterval(o),t(n)};n.call(e.videoDom,i);var o=setTimeout((function(){var r;null===(r=e.videoDom)||void 0===r||r.cancelVideoFrameCallback(i),t({})}),500)}else t({})}))}},{key:"stopReport",value:function(){this.statsReport.destroy()}}]),r}(),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(e){_inherits(r,StreamBase);var t=_createSuper(r);function r(e){var n;return _classCallCheck(this,r),_defineProperty(_assertThisInitialized(n=t.call(this)),"isScreen",!1),_defineProperty(_assertThisInitialized(n),"stream",void 0),_defineProperty(_assertThisInitialized(n),"streamId",void 0),_defineProperty(_assertThisInitialized(n),"audioMid",void 0),_defineProperty(_assertThisInitialized(n),"videoMid",void 0),_defineProperty(_assertThisInitialized(n),"seiList",[]),_defineProperty(_assertThisInitialized(n),"videoTrack",void 0),_defineProperty(_assertThisInitialized(n),"audioTrack",void 0),_defineProperty(_assertThisInitialized(n),"videoTransceiver",void 0),_defineProperty(_assertThisInitialized(n),"audioTransceiver",void 0),_defineProperty(_assertThisInitialized(n),"videoEncodeConfig",[defaultVideoEncoderConfig]),_defineProperty(_assertThisInitialized(n),"subVideoDescriptions",[]),_defineProperty(_assertThisInitialized(n),"enableSimulcast",!1),_defineProperty(_assertThisInitialized(n),"observer",void 0),_defineProperty(_assertThisInitialized(n),"statsReport",void 0),_defineProperty(_assertThisInitialized(n),"prevBitrate",0),_defineProperty(_assertThisInitialized(n),"pubAudio",!1),_defineProperty(_assertThisInitialized(n),"pubVideo",!1),_defineProperty(_assertThisInitialized(n),"pubAttributes",void 0),n.engineId=e,n.stream=new MediaStream,n.pubAttributes={localaudio:!1,localvideo:!1,videostream:!1,audiostream:!1,extvideo:!1,extaudio:!1},n.statsReport=new LocalStatsReport(e,_assertThisInitialized(n)),n}return _createClass(r,[{key:"audioHasCapture",get:function(){return this.pubAttributes.localaudio}},{key:"audioHasPublish",get:function(){return this.pubAttributes.audiostream}},{key:"videoHasCapture",get:function(){return this.pubAttributes.localvideo}},{key:"videoHasPublish",get:function(){return this.pubAttributes.videostream}},{key:"hasPublished",get:function(){return this.audioMid&&this.videoMid}},{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,o=SEIHelper.generateSEI(n.content),a=new Uint8Array(o.byteLength+t.data.byteLength);if(0===n.repeatCount)splice$3(i=e.seiList).call(i,0,1);n.repeatCount--,a.set(new Uint8Array(t.data)),a.set(o,t.data.byteLength),t.data=a.buffer,r.enqueue(t)}else r.enqueue(t)}});n.pipeThrough(o).pipeTo(i)}}else logger$f.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$f.print("no sender found when trying to bind encodedTransform")}},{key:"clean",value:function(){var e;reportRtcInvokeStatus(this.engineId,"localstream_clean","".concat((new Error).stack),0,this.streamId||""),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.stopReport(),this.prevBitrate=0,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)}}]),r}(),RemoteStream=function(e){_inherits(r,StreamBase);var t=_createSuper(r);function r(e,n,i,o,a){var s;return _classCallCheck(this,r),_defineProperty(_assertThisInitialized(s=t.call(this)),"streamId",void 0),_defineProperty(_assertThisInitialized(s),"userId",void 0),_defineProperty(_assertThisInitialized(s),"isScreen",void 0),_defineProperty(_assertThisInitialized(s),"hasVideo",void 0),_defineProperty(_assertThisInitialized(s),"hasAudio",void 0),_defineProperty(_assertThisInitialized(s),"_attributes",void 0),_defineProperty(_assertThisInitialized(s),"streamState",void 0),_defineProperty(_assertThisInitialized(s),"observer",void 0),_defineProperty(_assertThisInitialized(s),"statsReport",void 0),_defineProperty(_assertThisInitialized(s),"subVideo",void 0),_defineProperty(_assertThisInitialized(s),"subAudio",void 0),_defineProperty(_assertThisInitialized(s),"subMediaType",void 0),_defineProperty(_assertThisInitialized(s),"subLayer",void 0),_defineProperty(_assertThisInitialized(s),"audioMid",void 0),_defineProperty(_assertThisInitialized(s),"videoMid",void 0),_defineProperty(_assertThisInitialized(s),"_sequenceId",void 0),_defineProperty(_assertThisInitialized(s),"stream",void 0),_defineProperty(_assertThisInitialized(s),"videoTrack",void 0),_defineProperty(_assertThisInitialized(s),"audioTrack",void 0),_defineProperty(_assertThisInitialized(s),"videoTransceiver",void 0),_defineProperty(_assertThisInitialized(s),"audioTransceiver",void 0),_defineProperty(_assertThisInitialized(s),"recordedVideoFrames",void 0),_defineProperty(_assertThisInitialized(s),"stillExist",void 0),_defineProperty(_assertThisInitialized(s),"originalMediaType",void 0),_defineProperty(_assertThisInitialized(s),"priority",void 0),_defineProperty(_assertThisInitialized(s),"originalStreamIndex",0),_defineProperty(_assertThisInitialized(s),"virtual",void 0),s.engineId=e,s.virtual=!1,s.userId=n,s.isScreen=o,s.streamId=i,s.hasAudio=a.audiostream&&a.localaudio,s.hasVideo=a.videostream&&a.localvideo,s._attributes=a,s.subVideo=!1,s.subAudio=!1,s._sequenceId=0,s.subMediaType=ExtendMediaType.NONE,s.subLayer={spatialLayer:0,spatialSubLayer:-1},s.streamState=0,s.statsReport=new RemoteStatsReport(e,_assertThisInitialized(s)),s}return _createClass(r,[{key:"audioHasCapture",get:function(){return this._attributes.localaudio}},{key:"audioHasPublish",get:function(){return this._attributes.audiostream}},{key:"videoHasCapture",get:function(){return this._attributes.localvideo}},{key:"videoHasPublish",get:function(){return this._attributes.videostream}},{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$f.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$f.print("no receiver found when trying to bind encodedTransform")}},{key:"ontrack",value:function(e){var t,r,n;try{var i;reportRtcInvokeStatus(this.engineId,"Stream.ontrack",stringify$1({uid:this.userId,streamId:this.streamId,streams:reduce3(i=e.streams).call(i,(function(e,t){return e+MediaStreamStringify(t)}),""),transceiver:MediaTransceiverStringify(e.transceiver),track:MediaTrackStringify(e.track)}),0,this.streamId||"")}catch(e){}if(null!==(t=e.streams)&&void 0!==t&&null!==(r=t[0])&&void 0!==r&&null!==(n=r.id)&&void 0!==n&&includes4(n).call(n,this.streamId)){var o,a=e.track;"video"===(null==a?void 0:a.kind)?this._setVideoTrack(a):"audio"===(null===(o=e.track)||void 0===o?void 0:o.kind)&&this._setAudioTrack(a),this._setStream(e.streams[0])}this.safeEmit("ontrack",e)}},{key:"clean",value:function(){var e,t,r;logger$f.print("clean",concat$2(e="exec stream.clean ".concat(this.streamId," ")).call(e,this.userId)),reportRtcInvokeStatus(this.engineId,"remotestream_clean","".concat((new Error).stack),0,this.streamId),this.subAudio=!1,this.subVideo=!1,this.audioMid=void 0,this.videoMid=void 0,this.sequenceId=0,this.videoTrack=void 0,null===(t=this.audioTrack)||void 0===t||t.close(),this.audioTrack=void 0,this.stream=void 0,this.videoTransceiver=void 0,this.audioTransceiver=void 0,this.recordedVideoFrames=void 0,null===(r=this.observer)||void 0===r||r.reset(),this.stopReport(),delete this.priority}},{key:"resetHasSubscribed",value:function(){this.streamState=0}},{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=createRemoteAudioTrack(e),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=createRemoteVideoTrack(e),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=find$2(i).call(i,(function(e){return e.width===a&&e.height===s}));return{spatialLayer:e,spatialSubLayer:(null==c?void 0:c.sub_index)||-1}}}]),r}(),logger$e=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,r=this._queue.length,n="";return this._queue=filter3(t=this._queue).call(t,(function(t){return t.streamId!==e.streamId||e.action!==negativedAction[t.action]||(n=t.streamId,logger$e.print("offsetStreamId",n),!1)})),this._queue.length===r&&this._queue.push(e),this.emit("start"),n}},{key:"dequeue",value:function(){var e;if(!this._queue.length)return null;var t=this._queue.length;chromeVersion&&chromeVersion>=86&&chromeVersion<=92&&(t=Math.min(this._queue.length,5));for(var r=aggregationSdpStrategy[this._queue[0].action],n=1;n<t;n++){var i;if(aggregationSdpStrategy[this._queue[n].action]!==r)return{sdpStrategy:r,items:splice$3(i=this._queue).call(i,0,n)}}return{sdpStrategy:r,items:splice$3(e=this._queue).call(e,0,t)}}}]),r}(),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$c=Object.prototype,hasOwnProperty$9=objectProto$c.hasOwnProperty,nativeObjectToString$1=objectProto$c.toString,symToStringTag$1=Symbol$2?Symbol$2.toStringTag:void 0;function getRawTag(e){var t=hasOwnProperty$9.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$b=Object.prototype,nativeObjectToString=objectProto$b.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 isArray2=Array.isArray,isArray$1=isArray2;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$2="[object Function]",genTag$1="[object GeneratorFunction]",proxyTag="[object Proxy]";function isFunction(e){if(!isObject$1(e))return!1;var t=baseGetTag(e);return t==funcTag$2||t==genTag$1||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$a=Object.prototype,funcToString=funcProto.toString,hasOwnProperty$8=objectProto$a.hasOwnProperty,reIsNative=RegExp("^"+funcToString.call(hasOwnProperty$8).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}var WeakMap=getNative(root$1,"WeakMap"),WeakMap$1=WeakMap,objectCreate=Object.create,baseCreate=function(){function e(){}return function(t){if(!isObject$1(t))return{};if(objectCreate)return objectCreate(t);e.prototype=t;var r=new e;return e.prototype=void 0,r}}(),baseCreate$1=baseCreate;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)}function copyArray(e,t){var r=-1,n=e.length;for(t||(t=Array(n));++r<n;)t[r]=e[r];return t}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$1=function(){try{var e=getNative(Object,"defineProperty");return e({},"",{}),e}catch(e){}}(),defineProperty$2=defineProperty$1,baseSetToString=defineProperty$2?function(e,t){return defineProperty$2(e,"toString",{configurable:!0,enumerable:!1,value:constant(t),writable:!0})}:identity,baseSetToString$1=baseSetToString,setToString=shortOut(baseSetToString$1),setToString$1=setToString;function arrayEach(e,t){for(var r=-1,n=null==e?0:e.length;++r<n&&!1!==t(e[r],r,e););return e}var 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$2?defineProperty$2(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$9=Object.prototype,hasOwnProperty$7=objectProto$9.hasOwnProperty;function assignValue(e,t,r){var n=e[t];hasOwnProperty$7.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$8=Object.prototype;function isPrototype(e){var t=e&&e.constructor;return e===("function"==typeof t&&t.prototype||objectProto$8)}function baseTimes(e,t){for(var r=-1,n=Array(e);++r<e;)n[r]=t(r);return n}var argsTag$2="[object Arguments]";function baseIsArguments(e){return isObjectLike(e)&&baseGetTag(e)==argsTag$2}var objectProto$7=Object.prototype,hasOwnProperty$6=objectProto$7.hasOwnProperty,propertyIsEnumerable$1=objectProto$7.propertyIsEnumerable,isArguments=baseIsArguments(function(){return arguments}())?baseIsArguments:function(e){return isObjectLike(e)&&hasOwnProperty$6.call(e,"callee")&&!propertyIsEnumerable$1.call(e,"callee")},isArguments$1=isArguments;function stubFalse(){return!1}var freeExports$2="object"==typeof exports&&exports&&!exports.nodeType&&exports,freeModule$2=freeExports$2&&"object"==typeof module&&module&&!module.nodeType&&module,moduleExports$2=freeModule$2&&freeModule$2.exports===freeExports$2,Buffer$1=moduleExports$2?root$1.Buffer:void 0,nativeIsBuffer=Buffer$1?Buffer$1.isBuffer:void 0,isBuffer=nativeIsBuffer||stubFalse,isBuffer$1=isBuffer,argsTag$1="[object Arguments]",arrayTag$1="[object Array]",boolTag$2="[object Boolean]",dateTag$2="[object Date]",errorTag$1="[object Error]",funcTag$1="[object Function]",mapTag$4="[object Map]",numberTag$2="[object Number]",objectTag$2="[object Object]",regexpTag$2="[object RegExp]",setTag$4="[object Set]",stringTag$2="[object String]",weakMapTag$2="[object WeakMap]",arrayBufferTag$2="[object ArrayBuffer]",dataViewTag$3="[object DataView]",float32Tag$2="[object Float32Array]",float64Tag$2="[object Float64Array]",int8Tag$2="[object Int8Array]",int16Tag$2="[object Int16Array]",int32Tag$2="[object Int32Array]",uint8Tag$2="[object Uint8Array]",uint8ClampedTag$2="[object Uint8ClampedArray]",uint16Tag$2="[object Uint16Array]",uint32Tag$2="[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$2]=typedArrayTags[float64Tag$2]=typedArrayTags[int8Tag$2]=typedArrayTags[int16Tag$2]=typedArrayTags[int32Tag$2]=typedArrayTags[uint8Tag$2]=typedArrayTags[uint8ClampedTag$2]=typedArrayTags[uint16Tag$2]=typedArrayTags[uint32Tag$2]=!0,typedArrayTags[argsTag$1]=typedArrayTags[arrayTag$1]=typedArrayTags[arrayBufferTag$2]=typedArrayTags[boolTag$2]=typedArrayTags[dataViewTag$3]=typedArrayTags[dateTag$2]=typedArrayTags[errorTag$1]=typedArrayTags[funcTag$1]=typedArrayTags[mapTag$4]=typedArrayTags[numberTag$2]=typedArrayTags[objectTag$2]=typedArrayTags[regexpTag$2]=typedArrayTags[setTag$4]=typedArrayTags[stringTag$2]=typedArrayTags[weakMapTag$2]=!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,freeProcess=moduleExports$1&&freeGlobal$1.process,nodeUtil=function(){try{var e=freeModule$1&&freeModule$1.require&&freeModule$1.require("util").types;return e||freeProcess&&freeProcess.binding&&freeProcess.binding("util")}catch(e){}}(),nodeUtil$1=nodeUtil,nodeIsTypedArray=nodeUtil$1&&nodeUtil$1.isTypedArray,isTypedArray=nodeIsTypedArray?baseUnary(nodeIsTypedArray):baseIsTypedArray,isTypedArray$1=isTypedArray,objectProto$6=Object.prototype,hasOwnProperty$5=objectProto$6.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 l in e)!t&&!hasOwnProperty$5.call(e,l)||a&&("length"==l||i&&("offset"==l||"parent"==l)||o&&("buffer"==l||"byteLength"==l||"byteOffset"==l)||isIndex(l,c))||s.push(l);return s}function overArg(e,t){return function(r){return e(t(r))}}var nativeKeys=overArg(Object.keys,Object),nativeKeys$1=nativeKeys,objectProto$5=Object.prototype,hasOwnProperty$4=objectProto$5.hasOwnProperty;function baseKeys(e){if(!isPrototype(e))return nativeKeys$1(e);var t=[];for(var r in Object(e))hasOwnProperty$4.call(e,r)&&"constructor"!=r&&t.push(r);return t}function keys3(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$4=Object.prototype,hasOwnProperty$3=objectProto$4.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$3.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,nativeCreate=getNative(Object,"create"),nativeCreate$1=nativeCreate;function hashClear(){this.__data__=nativeCreate$1?nativeCreate$1(null):{},this.size=0}function hashDelete(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t}var HASH_UNDEFINED$1="__lodash_hash_undefined__",objectProto$3=Object.prototype,hasOwnProperty$2=objectProto$3.hasOwnProperty;function hashGet(e){var t=this.__data__;if(nativeCreate$1){var r=t[e];return r===HASH_UNDEFINED$1?void 0:r}return hasOwnProperty$2.call(t,e)?t[e]:void 0}var objectProto$2=Object.prototype,hasOwnProperty$1=objectProto$2.hasOwnProperty;function hashHas(e){var t=this.__data__;return nativeCreate$1?void 0!==t[e]:hasOwnProperty$1.call(t,e)}var HASH_UNDEFINED="__lodash_hash_undefined__";function hashSet(e,t){var r=this.__data__;return this.size+=this.has(e)?0:1,r[e]=nativeCreate$1&&void 0===t?HASH_UNDEFINED:t,this}function Hash(e){var t=-1,r=null==e?0:e.length;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}function listCacheClear(){this.__data__=[],this.size=0}function assocIndexOf(e,t){for(var r=e.length;r--;)if(eq(e[r][0],t))return r;return-1}Hash.prototype.clear=hashClear,Hash.prototype.delete=hashDelete,Hash.prototype.get=hashGet,Hash.prototype.has=hashHas,Hash.prototype.set=hashSet;var arrayProto=Array.prototype,splice$1=arrayProto.splice;function listCacheDelete(e){var t=this.__data__,r=assocIndexOf(t,e);return!(r<0)&&(r==t.length-1?t.pop():splice$1.call(t,r,1),--this.size,!0)}function listCacheGet(e){var t=this.__data__,r=assocIndexOf(t,e);return r<0?void 0:t[r][1]}function listCacheHas(e){return assocIndexOf(this.__data__,e)>-1}function listCacheSet(e,t){var r=this.__data__,n=assocIndexOf(r,e);return n<0?(++this.size,r.push([e,t])):r[n][1]=t,this}function ListCache(e){var t=-1,r=null==e?0:e.length;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}ListCache.prototype.clear=listCacheClear,ListCache.prototype.delete=listCacheDelete,ListCache.prototype.get=listCacheGet,ListCache.prototype.has=listCacheHas,ListCache.prototype.set=listCacheSet;var Map=getNative(root$1,"Map"),Map$1=Map;function mapCacheClear(){this.size=0,this.__data__={hash:new Hash,map:new(Map$1||ListCache),string:new Hash}}function isKeyable(e){var t=typeof e;return"string"==t||"number"==t||"symbol"==t||"boolean"==t?"__proto__"!==e:null===e}function getMapData(e,t){var r=e.__data__;return isKeyable(t)?r["string"==typeof t?"string":"hash"]:r.map}function mapCacheDelete(e){var t=getMapData(this,e).delete(e);return this.size-=t?1:0,t}function mapCacheGet(e){return getMapData(this,e).get(e)}function mapCacheHas(e){return getMapData(this,e).has(e)}function mapCacheSet(e,t){var r=getMapData(this,e),n=r.size;return r.set(e,t),this.size+=r.size==n?0:1,this}function MapCache(e){var t=-1,r=null==e?0:e.length;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}function arrayPush(e,t){for(var r=-1,n=t.length,i=e.length;++r<n;)e[i+r]=t[r];return e}MapCache.prototype.clear=mapCacheClear,MapCache.prototype.delete=mapCacheDelete,MapCache.prototype.get=mapCacheGet,MapCache.prototype.has=mapCacheHas,MapCache.prototype.set=mapCacheSet;var getPrototype=overArg(Object.getPrototypeOf,Object),getPrototype$1=getPrototype;function stackClear(){this.__data__=new ListCache,this.size=0}function stackDelete(e){var t=this.__data__,r=t.delete(e);return this.size=t.size,r}function stackGet(e){return this.__data__.get(e)}function stackHas(e){return this.__data__.has(e)}var LARGE_ARRAY_SIZE=200;function stackSet(e,t){var r=this.__data__;if(r instanceof ListCache){var n=r.__data__;if(!Map$1||n.length<LARGE_ARRAY_SIZE-1)return n.push([e,t]),this.size=++r.size,this;r=this.__data__=new MapCache(n)}return r.set(e,t),this.size=r.size,this}function Stack(e){var t=this.__data__=new ListCache(e);this.size=t.size}function baseAssign(e,t){return e&&copyObject(t,keys3(t),e)}function baseAssignIn(e,t){return e&&copyObject(t,keysIn(t),e)}Stack.prototype.clear=stackClear,Stack.prototype.delete=stackDelete,Stack.prototype.get=stackGet,Stack.prototype.has=stackHas,Stack.prototype.set=stackSet;var freeExports="object"==typeof exports&&exports&&!exports.nodeType&&exports,freeModule=freeExports&&"object"==typeof module&&module&&!module.nodeType&&module,moduleExports=freeModule&&freeModule.exports===freeExports,Buffer=moduleExports?root$1.Buffer:void 0,allocUnsafe=Buffer?Buffer.allocUnsafe:void 0;function cloneBuffer(e,t){if(t)return e.slice();var r=e.length,n=allocUnsafe?allocUnsafe(r):new e.constructor(r);return e.copy(n),n}function arrayFilter(e,t){for(var r=-1,n=null==e?0:e.length,i=0,o=[];++r<n;){var a=e[r];t(a,r,e)&&(o[i++]=a)}return o}function stubArray(){return[]}var objectProto$1=Object.prototype,propertyIsEnumerable3=objectProto$1.propertyIsEnumerable,nativeGetSymbols$1=Object.getOwnPropertySymbols,getSymbols=nativeGetSymbols$1?function(e){return null==e?[]:(e=Object(e),arrayFilter(nativeGetSymbols$1(e),(function(t){return propertyIsEnumerable3.call(e,t)})))}:stubArray,getSymbols$1=getSymbols;function copySymbols(e,t){return copyObject(e,getSymbols$1(e),t)}var nativeGetSymbols=Object.getOwnPropertySymbols,getSymbolsIn=nativeGetSymbols?function(e){for(var t=[];e;)arrayPush(t,getSymbols$1(e)),e=getPrototype$1(e);return t}:stubArray,getSymbolsIn$1=getSymbolsIn;function copySymbolsIn(e,t){return copyObject(e,getSymbolsIn$1(e),t)}function baseGetAllKeys(e,t,r){var n=t(e);return isArray$1(e)?n:arrayPush(n,r(e))}function getAllKeys(e){return baseGetAllKeys(e,keys3,getSymbols$1)}function getAllKeysIn(e){return baseGetAllKeys(e,keysIn,getSymbolsIn$1)}var DataView$1=getNative(root$1,"DataView"),DataView$2=DataView$1,Promise$1=getNative(root$1,"Promise"),Promise$2=Promise$1,Set=getNative(root$1,"Set"),Set$1=Set,mapTag$3="[object Map]",objectTag$1="[object Object]",promiseTag="[object Promise]",setTag$3="[object Set]",weakMapTag$1="[object WeakMap]",dataViewTag$2="[object DataView]",dataViewCtorString=toSource(DataView$2),mapCtorString=toSource(Map$1),promiseCtorString=toSource(Promise$2),setCtorString=toSource(Set$1),weakMapCtorString=toSource(WeakMap$1),getTag=baseGetTag;(DataView$2&&getTag(new DataView$2(new ArrayBuffer(1)))!=dataViewTag$2||Map$1&&getTag(new Map$1)!=mapTag$3||Promise$2&&getTag(Promise$2.resolve())!=promiseTag||Set$1&&getTag(new Set$1)!=setTag$3||WeakMap$1&&getTag(new WeakMap$1)!=weakMapTag$1)&&(getTag=function(e){var t=baseGetTag(e),r=t==objectTag$1?e.constructor:void 0,n=r?toSource(r):"";if(n)switch(n){case dataViewCtorString:return dataViewTag$2;case mapCtorString:return mapTag$3;case promiseCtorString:return promiseTag;case setCtorString:return setTag$3;case weakMapCtorString:return weakMapTag$1}return t});var getTag$1=getTag,objectProto=Object.prototype,hasOwnProperty=objectProto.hasOwnProperty;function initCloneArray(e){var t=e.length,r=new e.constructor(t);return t&&"string"==typeof e[0]&&hasOwnProperty.call(e,"index")&&(r.index=e.index,r.input=e.input),r}var Uint8Array$1=root$1.Uint8Array,Uint8Array$2=Uint8Array$1;function cloneArrayBuffer(e){var t=new e.constructor(e.byteLength);return new Uint8Array$2(t).set(new Uint8Array$2(e)),t}function cloneDataView(e,t){var r=t?cloneArrayBuffer(e.buffer):e.buffer;return new e.constructor(r,e.byteOffset,e.byteLength)}var reFlags=/\w*$/;function cloneRegExp(e){var t=new e.constructor(e.source,reFlags.exec(e));return t.lastIndex=e.lastIndex,t}var symbolProto=Symbol$2?Symbol$2.prototype:void 0,symbolValueOf=symbolProto?symbolProto.valueOf:void 0;function cloneSymbol(e){return symbolValueOf?Object(symbolValueOf.call(e)):{}}function cloneTypedArray(e,t){var r=t?cloneArrayBuffer(e.buffer):e.buffer;return new e.constructor(r,e.byteOffset,e.length)}var boolTag$1="[object Boolean]",dateTag$1="[object Date]",mapTag$2="[object Map]",numberTag$1="[object Number]",regexpTag$1="[object RegExp]",setTag$2="[object Set]",stringTag$1="[object String]",symbolTag$1="[object Symbol]",arrayBufferTag$1="[object ArrayBuffer]",dataViewTag$1="[object DataView]",float32Tag$1="[object Float32Array]",float64Tag$1="[object Float64Array]",int8Tag$1="[object Int8Array]",int16Tag$1="[object Int16Array]",int32Tag$1="[object Int32Array]",uint8Tag$1="[object Uint8Array]",uint8ClampedTag$1="[object Uint8ClampedArray]",uint16Tag$1="[object Uint16Array]",uint32Tag$1="[object Uint32Array]";function initCloneByTag(e,t,r){var n=e.constructor;switch(t){case arrayBufferTag$1:return cloneArrayBuffer(e);case boolTag$1:case dateTag$1:return new n(+e);case dataViewTag$1:return cloneDataView(e,r);case float32Tag$1:case float64Tag$1:case int8Tag$1:case int16Tag$1:case int32Tag$1:case uint8Tag$1:case uint8ClampedTag$1:case uint16Tag$1:case uint32Tag$1:return cloneTypedArray(e,r);case mapTag$2:return new n;case numberTag$1:case stringTag$1:return new n(e);case regexpTag$1:return cloneRegExp(e);case setTag$2:return new n;case symbolTag$1:return cloneSymbol(e)}}function initCloneObject(e){return"function"!=typeof e.constructor||isPrototype(e)?{}:baseCreate$1(getPrototype$1(e))}var mapTag$1="[object Map]";function baseIsMap(e){return isObjectLike(e)&&getTag$1(e)==mapTag$1}var nodeIsMap=nodeUtil$1&&nodeUtil$1.isMap,isMap=nodeIsMap?baseUnary(nodeIsMap):baseIsMap,isMap$1=isMap,setTag$1="[object Set]";function baseIsSet(e){return isObjectLike(e)&&getTag$1(e)==setTag$1}var nodeIsSet=nodeUtil$1&&nodeUtil$1.isSet,isSet=nodeIsSet?baseUnary(nodeIsSet):baseIsSet,isSet$1=isSet,CLONE_DEEP_FLAG$1=1,CLONE_FLAT_FLAG=2,CLONE_SYMBOLS_FLAG$1=4,argsTag="[object Arguments]",arrayTag="[object Array]",boolTag="[object Boolean]",dateTag="[object Date]",errorTag="[object Error]",funcTag="[object Function]",genTag="[object GeneratorFunction]",mapTag="[object Map]",numberTag="[object Number]",objectTag="[object Object]",regexpTag="[object RegExp]",setTag="[object Set]",stringTag="[object String]",symbolTag="[object Symbol]",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]",cloneableTags={};function baseClone(e,t,r,n,i,o){var a,s=t&CLONE_DEEP_FLAG$1,c=t&CLONE_FLAT_FLAG,l=t&CLONE_SYMBOLS_FLAG$1;if(r&&(a=i?r(e,n,i,o):r(e)),void 0!==a)return a;if(!isObject$1(e))return e;var u=isArray$1(e);if(u){if(a=initCloneArray(e),!s)return copyArray(e,a)}else{var d=getTag$1(e),p=d==funcTag||d==genTag;if(isBuffer$1(e))return cloneBuffer(e,s);if(d==objectTag||d==argsTag||p&&!i){if(a=c||p?{}:initCloneObject(e),!s)return c?copySymbolsIn(e,baseAssignIn(a,e)):copySymbols(e,baseAssign(a,e))}else{if(!cloneableTags[d])return i?e:{};a=initCloneByTag(e,d,s)}}o||(o=new Stack);var _=o.get(e);if(_)return _;o.set(e,a),isSet$1(e)?e.forEach((function(n){a.add(baseClone(n,t,r,n,e,o))})):isMap$1(e)&&e.forEach((function(n,i){a.set(i,baseClone(n,t,r,i,e,o))}));var h=u?void 0:(l?c?getAllKeysIn:getAllKeys:c?keysIn:keys3)(e);return arrayEach(h||e,(function(n,i){h&&(n=e[i=n]),assignValue(a,i,baseClone(n,t,r,i,e,o))})),a}cloneableTags[argsTag]=cloneableTags[arrayTag]=cloneableTags[arrayBufferTag]=cloneableTags[dataViewTag]=cloneableTags[boolTag]=cloneableTags[dateTag]=cloneableTags[float32Tag]=cloneableTags[float64Tag]=cloneableTags[int8Tag]=cloneableTags[int16Tag]=cloneableTags[int32Tag]=cloneableTags[mapTag]=cloneableTags[numberTag]=cloneableTags[objectTag]=cloneableTags[regexpTag]=cloneableTags[setTag]=cloneableTags[stringTag]=cloneableTags[symbolTag]=cloneableTags[uint8Tag]=cloneableTags[uint8ClampedTag]=cloneableTags[uint16Tag]=cloneableTags[uint32Tag]=!0,cloneableTags[errorTag]=cloneableTags[funcTag]=cloneableTags[weakMapTag]=!1;var CLONE_DEEP_FLAG=1,CLONE_SYMBOLS_FLAG=4;function cloneDeep(e){return baseClone(e,CLONE_DEEP_FLAG|CLONE_SYMBOLS_FLAG)}function baseValues(e,t){return arrayMap(t,(function(t){return e[t]}))}function values(e){return null==e?[]:baseValues(e,keys3(e))}var _RoomProfileMap,logger$d=new Logger("ChromeHandler",3),encodedTransformSupported=isEncodedTransformSupported(),ChromeHandler=function(e){_inherits(d,BasicHandler);var t,r,n,i,o,a,s,c,l,u=_createSuper(d);function d(e){var t;return _classCallCheck(this,d),_defineProperty(_assertThisInitialized(t=u.call(this,e)),"name","chrome"),_defineProperty(_assertThisInitialized(t),"_queueBusy",!1),_defineProperty(_assertThisInitialized(t),"_sdpQueue",void 0),_defineProperty(_assertThisInitialized(t),"_aSendonlyOfferTpl",void 0),_defineProperty(_assertThisInitialized(t),"_vSendonlyOfferTpl",void 0),_defineProperty(_assertThisInitialized(t),"_aRecvonlyOfferTpl",void 0),_defineProperty(_assertThisInitialized(t),"_vRecvonlyOfferTpl",void 0),_defineProperty(_assertThisInitialized(t),"_mid",10),_defineProperty(_assertThisInitialized(t),"_offerSession",void 0),_defineProperty(_assertThisInitialized(t),"_answerSession",void 0),_defineProperty(_assertThisInitialized(t),"_offerMlines",[]),_defineProperty(_assertThisInitialized(t),"_answerMlines",[]),_defineProperty(_assertThisInitialized(t),"_inactiveMlineIndex",[]),_defineProperty(_assertThisInitialized(t),"_mlinesCache",{}),t._sdpQueue=new SdpQueue,t._sdpQueue.on("start",(function(){t._queueBusy||"stable"!==t._peerConnection.signalingState||(logger$d.print("dequeue start"),t.dequeue())})),t}return _createClass(d,[{key:"connect",value:(l=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){var r,n,i,o,a,s,c,l,u,d,p,_,h,f=this;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return logger$d.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(this.id,t);case 4:return this._answerIce=e.sent,this._connectionId=this._answerIce.iceUfrag,e.next=8,this._peerConnection.createOffer();case 8:if(i=e.sent,o=lib.parse(i.sdp),this._offerIce.iceUfrag||this._offerIce.icePwd){e.next=24;break}return(l="renomination"===(null===(a=o.media[0])||void 0===a?void 0:a.iceOptions))||(delete this._offerIce.iceOptions,delete this._answerIce.iceOptions),delete this._offerIce.iceUfrag,delete this._offerIce.icePwd,e.next=18,getServerUfragV2({serverUfrag:t.iceParams.serverIceUfrag,serverPwd:t.iceParams.serverIcePwd,clientPwd:null===(s=o.media[0])||void 0===s?void 0:s.icePwd,options:(c={},_defineProperty(c,ICEConfigType.kICEConfigTypeSrtpDtlsType,!0),_defineProperty(c,ICEConfigType.kICEConfigTypeRenominationType,l),c)});case 18:u=e.sent,d=_slicedToArray(u,2),p=d[0],d[1],this._answerIce.iceUfrag=p,logger$d.print("use serverUfrag v2",stringify$1({dtls:!0,renomination:l}));case 24:return _=_slicedToArray(o.media,1),h=_[0],this._offerIce.fingerprint=o.fingerprint||h.fingerprint,delete o.media,this._offerSession=_objectSpread2({},o),this._answerSession=_objectSpread2({},o),this._answerSession.fingerprint&&(this._answerSession.fingerprint=this._answerIce.fingerprint),this._offerMlines=[_objectSpread2(_objectSpread2(_objectSpread2({},h),this._offerIce),{},{mid:"".concat(0)})],this._answerMlines=[_objectSpread2(_objectSpread2(_objectSpread2({},h),this._answerIce),{},{sctpmap:{sctpmapNumber:5e3,app:"webrtc-datachannel",maxMessageSize:262144},mid:"".concat(0)})],this.setDescription(),e.next=36,new promise((function(e,t){f._dataChannel.onopen=function(){logger$d.print("connect","dataChannel open"),f._reportRtcInvokeStatus("es.dc.open",""),e("")},f._dataChannel.onerror=function(e){f._report("rtc_signaling_msg_error",{error_code:e.error.sdpLineNumber,message:e.error.errorDetail,reason:"invalid data"}),f._reportRtcInvokeStatus("es.dc.error",""),t(e)},f._dataChannel.onclose=function(e){f._reportRtcInvokeStatus("es.dc.close",""),t(e)},f._peerConnection.addEventListener("connectionstatechange",(function(e){"failed"!==f._peerConnection.iceConnectionState&&"closed"!==f._peerConnection.iceConnectionState&&"failed"!==f._peerConnection.connectionState||t(e)}))}));case 36:return logger$d.print("connect","dataChannel establish success"),e.abrupt("return",this._dataChannel);case 38:case"end":return e.stop()}}),e,this)}))),function(e){return l.apply(this,arguments)})},{key:"disconnect",value:function(){this._peerConnection.close(),this._dataChannel.close(),this._peerConnection.ontrack=null}},{key:"destroy",value:function(){_get(_getPrototypeOf(d.prototype),"destroy",this).call(this),this._mlinesCache={}}},{key:"publish",value:(c=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){var r,n,i,o,a,s,c,l,u,p,_,h,f,m,v,g,y,S,T,$,E,b,I,R,C,A,k,P,O,w,M,D,x,N,L,U,V;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return l=t.stream,u=t.enableSimulcast,p=_get(_getPrototypeOf(d.prototype),"internalPublish",this).call(this,t),_=p.videoDescriptions,h=p.subVideoDescriptions,f=p.audioTransceiverInit,m=p.videoTransceiverInit,v=generateAllSsrc(this._nextSsrc),this._nextSsrc=v.next,g="".concat(this._mid++),y="".concat(this._mid++),S=_objectSpread2(_objectSpread2(_objectSpread2({},this._aSendonlyOfferTpl),this._offerIce),{},{mid:g,msid:concat$2(r="".concat(l.id," ")).call(r,l.id,"-audio"),ssrcs:generateSsrc(l.id,"audio",v.audio,clientCname)}),T=_objectSpread2(_objectSpread2(_objectSpread2({},this._vSendonlyOfferTpl),this._offerIce),{},{mid:y,msid:concat$2(n="".concat(l.id," ")).call(n,l.id,"-video")}),u?(logger$d.print("subVideoDesc","desc: %o ",h),delete T.ssrcGroups,delete T.ssrcs,$=[],T.rids=map$6(_).call(_,(function(e){var t=e.rid;return $.unshift(t),{id:t,direction:"send"}})),T.simulcast={dir1:"send",list1:$.join(";")}):(E=generateSsrcs(l.id,v,{cname:clientCname}),b=E.ssrcs,I=E.ssrcGroups,T.ssrcs=b,T.ssrcGroups=I),null!==(i=this._context)&&void 0!==i&&null!==(o=i.serverConfig)&&void 0!==o&&o.audioRed&&Array.isArray(S.rtp)&&(-1!==(C=findIndex$1(R=S.rtp).call(R,(function(e){return"red"===e.codec})))&&(k=splice$3(A=S.rtp).call(A,C,1),P=_slicedToArray(k,1),O=P[0],S.rtp.unshift(O)),w=[],S.rtp.forEach((function(e){return w.push(e.payload)})),S.payloads=w.join(" ")),null!==(a=this._context)&&void 0!==a&&null!==(s=a.serverConfig)&&void 0!==s&&s.videoCodec&&setCodecPreferences(T,null===(M=this._context)||void 0===M||null===(D=M.serverConfig)||void 0===D?void 0:D.videoCodec),(isSafari||isIOS)&&Array.isArray(T.ext)&&(T.ext=filter3(x=T.ext).call(x,(function(e){var t;return!(null!=e&&null!==(t=e.uri)&&void 0!==t&&includes4(t).call(t,"video-orientation"))}))),(N=null==S?void 0:find$2(c=S.rtp).call(c,(function(e){return"opus"===e.codec})))&&S.fmtp&&(V=find$2(L=S.fmtp).call(L,(function(e){return e.payload===N.payload})))&&null!==(U=this._context)&&void 0!==U&&U.audioProfileManager&&(V.config=this._context.audioProfileManager.getOpusConfigStr(V.config)),u||isSafari||this.addBitrateLimit(T,t.videoEncodeConfig[0].maxKbps),this._mlinesCache[t.stream.id]=[S,T],e.abrupt("return",{partialSdp:getLocalPartialSdp(this._offerSession,S,T),audioMid:g,videoMid:y,type:"incroffer",semantics:"unified-plan",videoDescriptions:_,subVideoDescriptions:h,audioTransceiverInit:f,videoTransceiverInit:m});case 17:case"end":return e.stop()}}),e,this)}))),function(e){return c.apply(this,arguments)})},{key:"subscribe",value:(s=_asyncToGenerator(_regeneratorRuntime().mark((function e(t,r){var n,i,o,a,s,c,l,u,d,p,_,h,f,m,v,g,y,S,T,$,E,b,I,R,C,A,k,P,O,w,M=this;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(logger$d.print("subscribe"),a="incroffer",s="unified-plan",this._aRecvonlyOfferTpl&&this._vRecvonlyOfferTpl){e.next=9;break}return e.next=6,this._genOfferSdp();case 6:return c=e.sent,e.next=9,this.createAVMlineOfferTpl(c);case 9:if(l="",u="",d=!1,p=!1,_=void 0,h=void 0,this._mlinesCache[t.streamId]=[_,h],t.virtual?(l="".concat(this._mid++),d=!0):r.multiChatMode?(l="".concat(this._mid++),u="".concat(this._mid++),p=!0):(d=!0,p=!0,l="".concat(this._mid++),u="".concat(this._mid++)),l&&(_=_objectSpread2(_objectSpread2({},cloneDeep(this._aRecvonlyOfferTpl)),{},{mid:l})),d&&(this._mlinesCache[t.streamId][0]=_,f={track:"audio",init:{direction:"recvonly"}}),u&&(h=_objectSpread2(_objectSpread2({},cloneDeep(this._vRecvonlyOfferTpl)),{},{mid:u})),p&&(this._mlinesCache[t.streamId][1]=h,m={track:"video",init:{direction:"recvonly"}}),v=getLocalPartialSdp(this._offerSession,_,h),g=void 0,r.multiChatMode||t.virtual||!this._aSendonlyAnswerTpl||!this._vSendonlyAnswerTpl){e.next=32;break}return g=generateAllSsrc(this._nextSsrc),this._nextSsrc=g.next,R=_objectSpread2(_objectSpread2(_objectSpread2({},this._aSendonlyAnswerTpl),this._answerIce),{},{mid:l,msid:concat$2(y=concat$2(S="".concat(t.streamId)).call(S,null!==(T=this._context)&&void 0!==T&&T.avSync?"":"-audio"," ")).call(y,t.streamId,"-audio"),ssrcs:generateSsrc(t.streamId,"audio",g.audio)}),C=_objectSpread2(_objectSpread2(_objectSpread2({},this._vSendonlyAnswerTpl),this._answerIce),{},{mid:u,msid:concat$2($=concat$2(E="".concat(t.streamId)).call(E,null!==(b=this._context)&&void 0!==b&&b.avSync?"":"-video"," ")).call($,t.streamId,"-video")},generateSsrcs(t.streamId,g,{flexfec:this._enableSubFlexfec})),A=new promise((function(e){M._sdpQueue.enqueue({action:SdpAction.subscribe,streamId:t.streamId,audioMid:l,videoMid:u,audioTransceiverInit:f,videoTransceiverInit:m,signalingAck:{sdp:lib.write(_objectSpread2(_objectSpread2({},M._answerSession),{},{media:[R,C]})),sequenceId:t.sequenceId?++t.sequenceId:0},stream:t,sdp:v,onSuccess:function(){logger$d.print("subscribe()","sub success"),e(0)}})})),e.next=31,A;case 31:null===(I=g)||void 0===I||delete I.next;case 32:return(k=null===(n=_)||void 0===n?void 0:find$2(i=n.rtp).call(i,(function(e){return"opus"===e.codec})))&&null!==(o=_)&&void 0!==o&&o.fmtp&&(w=null===(P=_)||void 0===P?void 0:find$2(O=P.fmtp).call(O,(function(e){return e.payload===k.payload})))&&this._context&&(w.config+=";stereo=1;sprop-stereo=1"),e.abrupt("return",{partialSdp:v,audioMid:l,videoMid:u,type:a,semantics:s,audioTransceiverInit:f,videoTransceiverInit:m,allSsrc:g});case 35:case"end":return e.stop()}}),e,this)}))),function(e,t){return s.apply(this,arguments)})},{key:"handleAck",value:(a=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(logger$d.print("handleAck()","item: %o",t),!t.generatorSsrc){e.next=4;break}return logger$d.print("already set remote"),e.abrupt("return","");case 4:return e.abrupt("return",this._sdpQueue.enqueue(t));case 5:case"end":return e.stop()}}),e,this)}))),function(e){return a.apply(this,arguments)})},{key:"dequeue",value:(o=_asyncToGenerator(_regeneratorRuntime().mark((function e(){var t,r,n,i,o,a,s,c,l,u,d,p,_,h,f,m=this;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._queueBusy=!0,t=this._sdpQueue.dequeue(),logger$d.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=[],a=[],n!==SdpStrategy.ADD){e.next=15;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({},m._answerIce)).candidates,s=!1,c=!1,e.prev=4,u=_asyncIterator(r);case 6:return e.next=8,u.next();case 8:if(!(s=!(d=e.sent).done)){e.next=16;break}if(n=d.value,"break"!==function(){var e=n.audioMid,r=n.videoMid,s=n.action,c=n.audioTransceiverInit,l=n.videoTransceiverInit,u=n.signalingAck,d=n.stream,p=d instanceof RemoteStream;if(n.onSuccess&&a.push(n.onSuccess),p&&(null==u?void 0:u.sequenceId)<d.sequenceId)return"break";var _,h={},f={},v=lib.parse(u.sdp);Array.isArray(v.media)&&sort2(_=v.media).call(_,(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(n){"audio"===(n=_objectSpread2(_objectSpread2({},n),t)).type?(h=n).mid=e:(f=n).mid=r}));var g,y=d.streamId;if(s===SdpAction.publish&&(y=null===(g=d.stream)||void 0===g?void 0:g.id),!m._mlinesCache[y])return"break";var S=_slicedToArray(m._mlinesCache[y],2),T=S[0],$=S[1];if(c&&T){d.audioTransceiver=m._peerConnection.addTransceiver(c.track,c.init),m._reportRtcInvokeStatus("chromeHandler.addTrack",stringify$1({audioStreamTrack:MediaTrackStringify(c.track)}));var E=m._inactiveMlineIndex.shift();E||(E=m._offerMlines.length),m._offerMlines[E]=_objectSpread2({},T),m._answerMlines[E]=h,encodedTransformSupported&&d.initAudioEncodedTransform()}if(l&&$){var b,I;d.videoTransceiver=m._peerConnection.addTransceiver(l.track,l.init),m._reportRtcInvokeStatus("chromeHandler.addTrack",stringify$1({videoStreamTrack:MediaTrackStringify(l.track)}));var R,C,A=m._inactiveMlineIndex.shift();A||(A=m._offerMlines.length),m._offerMlines[A]=_objectSpread2({},$),s===SdpAction.publish&&null!==(b=m._context)&&void 0!==b&&null!==(I=b.serverConfig)&&void 0!==I&&I.videoCodec&&setCodecPreferences(f,null===(R=m._context)||void 0===R||null===(C=R.serverConfig)||void 0===C?void 0:C.videoCodec),m._answerMlines[A]=f,encodedTransformSupported&&d.initVideoEncodedTransform()}i.push(d.streamId||""),o.push(p?d.userId:"local"),p&&(d.sequenceId=null==u?void 0:u.sequenceId),delete m._mlinesCache[y]}()){e.next=13;break}return e.abrupt("break",16);case 13:s=!1,e.next=6;break;case 16:e.next=22;break;case 18:e.prev=18,e.t0=e.catch(4),c=!0,l=e.t0;case 22:if(e.prev=22,e.prev=23,!s||null==u.return){e.next=27;break}return e.next=27,u.return();case 27:if(e.prev=27,!c){e.next=30;break}throw l;case 30:return e.finish(27);case 31:return e.finish(22);case 32:case"end":return e.stop()}}),e,null,[[4,18,22,32],[23,,27,31]])}))(),"t0",13);case 13:e.next=20;break;case 15:f={},r.forEach((function(e){var t=e.audioMid,r=e.videoMid,n=e.action;f[t]=t,n!==SdpAction.removetrack&&(f[r]=r),f[t]=t})),this._offerMlines=map$6(p=this._offerMlines).call(p,(function(e,t){return f[e.mid]&&(e=closeMline(e),m._inactiveMlineIndex.push(t)),e})),sort2(_=this._inactiveMlineIndex).call(_,(function(e,t){return e-t})),this._answerMlines=map$6(h=this._answerMlines).call(h,(function(e){return f[e.mid]&&(e=closeMline(e)),e}));case 20:return e.next=22,this.setDescription(i.length?{streamId:i.join(","),streamUserId:o.join(",")}:void 0);case 22:try{a.forEach((function(e){return e()}))}catch(e){}logger$d.print("dequeue","loop"),e.next=29;break;case 26:e.prev=26,e.t1=e.catch(6),logger$d.print("dequeue","unknown error: %o",e.t1);case 29:return e.prev=29,this.dequeue(),e.finish(29);case 32:case"end":return e.stop()}}),e,this,[[6,26,29,32]])}))),function(){return o.apply(this,arguments)})},{key:"setDescription",value:(i=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){var r,n;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return logger$d.print("setDescription"),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&&this._report("rtc_begin_create_offer",{direction:"local"===t.streamUserId?"up":"down",stream_id:t.streamId,stream_user_id:t.streamUserId}),e.next=10,this._peerConnection.createOffer();case 10:return t&&this._report("rtc_create_offer",{error_code:0,direction:"local"===t.streamUserId?"up":"down",stream_id:t.streamId,stream_user_id:t.streamUserId,elapse: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 i.apply(this,arguments)})},{key:"getDefaultSdp",value:(n=_asyncToGenerator(_regeneratorRuntime().mark((function e(){var t,r,n,i;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._genOfferSdp();case 2:return r=e.sent,this.createAVMlineOfferTpl(r),n=lib.parse(r),i=[],n.media=filter3(t=n.media).call(t,(function(e){var t;return"recvonly"===e.direction&&(Array.isArray(e.ext)&&(e.ext=filter3(t=e.ext).call(t,(function(e){return"urn:ietf:params:rtp-hdrext:sdes:rtp-stream-id"!==e.uri}))),i.push(e.mid+""),!0)})),n.groups=[{mids:i.join(" "),type:"BUNDLE"}],e.abrupt("return",{sdp:lib.write(n),semantics:"unified-plan",type:"incroffer"});case 9:case"end":return e.stop()}}),e,this)}))),function(){return n.apply(this,arguments)})},{key:"rollback",value:(r=_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 r.apply(this,arguments)})},{key:"createAVMlineOfferTpl",value:function(e){var t=this;lib.parse(e).media.forEach((function(e){if("audio"===e.type)if("sendonly"===e.direction)t._aSendonlyOfferTpl=e;else{var r;if(Array.isArray(e.ext))e.ext=filter3(r=e.ext).call(r,(function(e){return"urn:ietf:params:rtp-hdrext:sdes:rtp-stream-id"!==e.uri}));t._aRecvonlyOfferTpl=e}else if("video"===e.type)if("sendonly"===e.direction)t._vSendonlyOfferTpl=e;else{var n;if(Array.isArray(e.ext))e.ext=filter3(n=e.ext).call(n,(function(e){return"urn:ietf:params:rtp-hdrext:sdes:rtp-stream-id"!==e.uri}));t._vRecvonlyOfferTpl=e}}))}},{key:"_genOfferSdp",value:(t=_asyncToGenerator(_regeneratorRuntime().mark((function e(){var t,r;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,createDefaultSdp(!0);case 3:if(t=e.sent){e.next=6;break}throw"pc.createOffer() return empty.";case 6:e.next=12;break;case 8:throw e.prev=8,e.t0=e.catch(0),r="Get offer Error. ".concat(e.t0.message|e.t0),new SDKError(ErrorCode.NOT_SUPPORTED,r);case 12:return e.abrupt("return",t);case 13:case"end":return e.stop()}}),e,null,[[0,8]])}))),function(){return t.apply(this,arguments)})}]),d}(),logger$c=new Logger("FirefoxHandler",3),FirefoxHandler=function(e){_inherits(d,BasicHandler);var t,r,n,i,o,a,s,c,l,u=_createSuper(d);function d(){var e,t;_classCallCheck(this,d);for(var r=arguments.length,n=new Array(r),i=0;i<r;i++)n[i]=arguments[i];return _defineProperty(_assertThisInitialized(t=u.call.apply(u,concat$2(e=[this]).call(e,n))),"name","firefox"),_defineProperty(_assertThisInitialized(t),"_aRecvonlyOfferTpl",void 0),t}return _createClass(d,[{key:"connect",value:(l=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){var r,n,i,o,a,s,c,l,u,d,p,_,h,f,m,v,g,y=this;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return logger$c.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(this.id,t);case 4:return this._answerIce=e.sent,this._connectionId=this._answerIce.iceUfrag,this._peerConnection.addTransceiver("audio",{direction:"recvonly"}),this._peerConnection.addTransceiver("video",{direction:"recvonly"}),e.next=10,this._peerConnection.createOffer();case 10:if(s=e.sent,c=lib.parse(s.sdp),this._offerIce.iceUfrag||this._offerIce.icePwd){e.next=26;break}return(p="renomination"===(null===(l=c.media[0])||void 0===l?void 0:l.iceOptions))||(delete this._offerIce.iceOptions,delete this._answerIce.iceOptions),delete this._offerIce.iceUfrag,delete this._offerIce.icePwd,e.next=20,getServerUfragV2({serverUfrag:t.iceParams.serverIceUfrag,serverPwd:t.iceParams.serverIcePwd,clientPwd:null===(u=c.media[0])||void 0===u?void 0:u.icePwd,options:(d={},_defineProperty(d,ICEConfigType.kICEConfigTypeSrtpDtlsType,!0),_defineProperty(d,ICEConfigType.kICEConfigTypeRenominationType,p),d)});case 20:_=e.sent,h=_slicedToArray(_,2),f=h[0],h[1],this._answerIce.iceUfrag=f,logger$c.print("use serverUfrag v2",stringify$1({dtls:!0,renomination:p}));case 26:return m=_slicedToArray(c.media,1),v=m[0],this._offerIce.fingerprint=c.fingerprint||v.fingerprint,c.media=map$6(i=c.media).call(i,(function(e){return _objectSpread2(_objectSpread2({},e),y._offerIce)})),map$6(o=c.media).call(o,(function(e){var t,r;"video"===e.type&&(e.ext=null===(t=e.ext)||void 0===t?void 0:filter3(t).call(t,(function(e){var t;return-1===indexOf2(t=e.uri).call(t,"abs-send-time")})),e.rtcpFb=null===(r=e.rtcpFb)||void 0===r?void 0:filter3(r).call(r,(function(e){return"goog-remb"!==e.type})))})),(g=_objectSpread2({},c)).fingerprint=this._answerIce.fingerprint,g.media=map$6(a=g.media).call(a,(function(e){return delete(e=_objectSpread2(_objectSpread2({},e),y._answerIce)).bundleOnly,e.port=9,"application"===e.type?e.sctpmap={sctpmapNumber:5e3,app:"webrtc-datachannel",maxMessageSize:262144}:("audio"===e.type&&(e.msid="ff-stream ff-stream-audio"),e.direction="sendonly"),e})),e.next=35,this.setLocalDescription(lib.write(c));case 35:return e.next=37,this.setRemoteDescription(lib.write(g));case 37:return e.next=39,new promise((function(e,t){y._dataChannel.onopen=function(){logger$c.print("connect","dataChannel open"),y._reportRtcInvokeStatus("es.dc.open",""),e("")},y._dataChannel.onerror=function(e){y._report("rtc_signaling_msg_error",{error_code:e.error.sdpLineNumber,message:e.error.errorDetail,reason:"invalid data"}),y._reportRtcInvokeStatus("es.dc.error",""),t(e)},y._dataChannel.onclose=function(e){y._reportRtcInvokeStatus("es.dc.close",""),t(e)},y._peerConnection.addEventListener("connectionstatechange",(function(e){"failed"!==y._peerConnection.iceConnectionState&&"closed"!==y._peerConnection.iceConnectionState&&"failed"!==y._peerConnection.connectionState||t(e)}))}));case 39:return logger$c.print("connect","dataChannel establish success"),e.abrupt("return",this._dataChannel);case 41:case"end":return e.stop()}}),e,this)}))),function(e){return l.apply(this,arguments)})},{key:"publish",value:(c=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){var r,n,i,o,a,s,c,l,u,p,_,h,f,m,v=this;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=_get(_getPrototypeOf(d.prototype),"internalPublish",this).call(this,t),o=i.videoDescriptions,a=i.subVideoDescriptions,s=i.audioTransceiverInit,c=i.videoTransceiverInit,t.audioTransceiver=this._peerConnection.addTransceiver(s.track,s.init),t.videoTransceiver=this._peerConnection.addTransceiver(c.track,c.init),l=getServerNow(),this._report("rtc_begin_create_offer",{direction:"up",stream_id:"",stream_user_id:""}),e.next=7,this._peerConnection.createOffer();case 7:return u=e.sent,this._report("rtc_create_offer",{direction:"up",error_code:0,stream_id:"",stream_user_id:"",elapse:getServerNow()-l}),(p=lib.parse(u.sdp)).media=null===(r=p.media)||void 0===r?void 0:map$6(r).call(r,(function(e){return _objectSpread2(_objectSpread2({},e),v._offerIce)})),e.next=13,this.setLocalDescription(lib.write(p));case 13:return _=t.audioTransceiver.mid,h=t.videoTransceiver.mid,f=null,m=null,p.media=null===(n=p.media)||void 0===n?void 0:map$6(n).call(n,(function(e){if("".concat(e.mid)===_){var t,r,n=null===(t=f=e)||void 0===t?void 0:find$2(r=t.rtp).call(r,(function(e){return"opus"===e.codec}));if(n&&f.fmtp){var i,o,a=find$2(i=f.fmtp).call(i,(function(e){return e.payload===n.payload}));a&&null!==(o=v._context)&&void 0!==o&&o.audioProfileManager&&(a.config=v._context.audioProfileManager.getOpusConfigStr(a.config))}}else if("".concat(e.mid)===h){var s,c,l,u;null!==(s=v._context)&&void 0!==s&&null!==(c=s.serverConfig)&&void 0!==c&&c.videoCodec&&setCodecPreferences(e,null===(l=v._context)||void 0===l||null===(u=l.serverConfig)||void 0===u?void 0:u.videoCodec),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,f,m,!1),audioMid:_,videoMid:h,type:"incroffer",semantics:"unified-plan",videoDescriptions:o,subVideoDescriptions:a,audioTransceiverInit:s,videoTransceiverInit:c});case 22:case"end":return e.stop()}}),e,this)}))),function(e){return c.apply(this,arguments)})},{key:"subscribe",value:(s=_asyncToGenerator(_regeneratorRuntime().mark((function e(t,r){var n,i,o,a,s,c,l,u,d,p,_,h,f,m,v,g,y,S,T,$,E,b,I,R,C=this;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return logger$c.print("subscribe()"),c="",l="",u=!1,d=!1,p=void 0,_=void 0,t.virtual?u=!0:(r.multiChatMode||(u=!0),d=!0),u&&(t.audioTransceiver=this._peerConnection.addTransceiver("audio",{direction:"recvonly"})),d&&(t.videoTransceiver=this._peerConnection.addTransceiver("video",{direction:"recvonly"})),h=getServerNow(),this._report("rtc_begin_create_offer",{direction:"up",stream_id:t.streamId,stream_user_id:t.userId}),e.next=14,this._peerConnection.createOffer();case 14:return f=e.sent,this._report("rtc_create_offer",{error_code:0,direction:"up",stream_id:t.streamId,stream_user_id:t.userId,elapse:getServerNow()-h}),(m=lib.parse(f.sdp)).media=null===(n=m.media)||void 0===n?void 0:map$6(n).call(n,(function(e){return _objectSpread2(_objectSpread2({},e),C._offerIce)})),map$6(i=m.media).call(i,(function(e){var t,r;"video"===e.type&&(e.ext=null===(t=e.ext)||void 0===t?void 0:filter3(t).call(t,(function(e){var t;return-1===indexOf2(t=e.uri).call(t,"abs-send-time")})),e.rtcpFb=null===(r=e.rtcpFb)||void 0===r?void 0:filter3(r).call(r,(function(e){return"goog-remb"!==e.type})))})),e.next=21,this.setLocalDescription(lib.write(m),{streamId:t.streamId||"",streamUserId:t.userId});case 21:if(c=null===(o=t.audioTransceiver)||void 0===o?void 0:o.mid,l=null===(a=t.videoTransceiver)||void 0===a?void 0:a.mid,null===(s=m.media)||void 0===s||s.forEach((function(e){"".concat(e.mid)===c?p=e:"".concat(e.mid)===l&&(_=e)})),c&&p||(c="audio_".concat(l),p=_objectSpread2(_objectSpread2({},this._aRecvonlyOfferTpl),{},{mid:c})),t.audioMid=c,t.videoMid=l,v=void 0,r.multiChatMode||t.virtual||!this._aSendonlyAnswerTpl||!this._aSendonlyAnswerTpl){e.next=36;break}return v=generateAllSsrc(this._nextSsrc),this._nextSsrc=v.next,I=_objectSpread2(_objectSpread2(_objectSpread2({},this._aSendonlyAnswerTpl),this._answerIce),{},{mid:c,msid:concat$2(g=concat$2(y="".concat(t.streamId)).call(y,null!==(S=this._context)&&void 0!==S&&S.avSync?"":"-audio"," ")).call(g,t.streamId,"-audio"),ssrcs:generateSsrc(t.streamId,"audio",v.audio)}),R=_objectSpread2(_objectSpread2(_objectSpread2({},this._vSendonlyAnswerTpl),this._answerIce),{},{mid:l,msid:concat$2(T=concat$2($="".concat(t.streamId)).call($,null!==(E=this._context)&&void 0!==E&&E.avSync?"":"-video"," ")).call(T,t.streamId,"-video")},generateSsrcs(t.streamId,v,{flexfec:this._enableSubFlexfec})),e.next=35,this._internalSetRemoteDescription([I,R],t);case 35:null===(b=v)||void 0===b||delete b.next;case 36:return e.abrupt("return",{partialSdp:getLocalPartialSdp(m,p,_,!1),audioMid:c,videoMid:l,type:"incroffer",semantics:"unified-plan",audioTransceiverInit:t.audioTransceiver?{track:"audio",init:{direction:"recvonly"}}:void 0,videoTransceiverInit:t.videoTransceiver?{track:"video",init:{direction:"recvonly"}}:void 0,allSsrc:v});case 37:case"end":return e.stop()}}),e,this)}))),function(e,t){return s.apply(this,arguments)})},{key:"handleAck",value:(a=_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(r=t.signalingAck,n=t.stream,(i=t.action)!==SdpAction.unpublish&&i!==SdpAction.unsubscribe&&i!==SdpAction.removetrack){e.next=5;break}return e.next=4,this.close(n);case 4:return e.abrupt("return",n.streamId||"");case 5:if(!t.generatorSsrc){e.next=8;break}return logger$c.print("already set remote"),e.abrupt("return","");case 8:return o=lib.parse(null==r?void 0:r.sdp),e.next=11,this._internalSetRemoteDescription(o.media,n);case 11:return e.abrupt("return","");case 12:case"end":return e.stop()}}),e,this)}))),function(e){return a.apply(this,arguments)})},{key:"_internalSetRemoteDescription",value:(o=_asyncToGenerator(_regeneratorRuntime().mark((function e(t,r){var n,i,o,a,s,c,l,u,d=this;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return s={},(c=lib.parse(null===(n=this._peerConnection.remoteDescription)||void 0===n?void 0:n.sdp)).media.forEach((function(e){void 0!==e.mid&&(s[e.mid]=e)})),t.forEach((function(e){if("audio"===(e=_objectSpread2(_objectSpread2({},e),d._answerIce)).type&&(r.audioMid?(e.mid=r.audioMid,s[r.audioMid]=e):s[e.mid]=e),"video"===e.type){if(r instanceof LocalStream&&firefoxVersion<=87){var t,n,i,o,a={};Array.isArray(e.rtp)&&(e.rtp=filter3(t=e.rtp).call(t,(function(e){return"rtx"!==e.codec||(a[e.payload]=e.payload,!1)}))),"string"==typeof e.payloads&&(e.payloads=filter3(n=e.payloads.split(" ")).call(n,(function(e){return!a[e]})).join(" ")),Array.isArray(e.fmtp)&&(e.fmtp=filter3(i=e.fmtp).call(i,(function(e){return!a[e.payload]}))),Array.isArray(e.rtcpFb)&&(e.fmtp=filter3(o=e.fmtp).call(o,(function(e){return!a[e.payload]})))}r.videoMid?(e.mid=r.videoMid,s[r.videoMid]=e):s[e.mid]=e}})),l=lib.parse(null===(i=this._peerConnection.localDescription)||void 0===i?void 0:i.sdp),u=map$6(o=l.media).call(o,(function(e){var t=s[e.mid];return"inactive"===e.direction?e:t})),c.groups=l.groups,c.media=u,map$6(a=c.media).call(a,(function(e){var t,r;"video"===e.type&&(e.ext=null===(t=e.ext)||void 0===t?void 0:filter3(t).call(t,(function(e){var t;return-1===indexOf2(t=e.uri).call(t,"abs-send-time")})),e.rtcpFb=null===(r=e.rtcpFb)||void 0===r?void 0:filter3(r).call(r,(function(e){return"goog-remb"!==e.type})))})),e.next=11,this.setRemoteDescription(lib.write(c));case 11:case"end":return e.stop()}}),e,this)}))),function(e,t){return o.apply(this,arguments)})},{key:"getDefaultSdp",value:(i=_asyncToGenerator(_regeneratorRuntime().mark((function e(){var t,r,n,i,o;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=lib.parse(null===(t=this._peerConnection.localDescription)||void 0===t?void 0:t.sdp),this.createAVMlineOfferTpl(null===(r=this._peerConnection.localDescription)||void 0===r?void 0:r.sdp),o=[],i.media=filter3(n=i.media).call(n,(function(e){return"recvonly"===e.direction&&(e.mid=e.mid+1,o.push(e.mid+""),!0)})),i.groups=[{mids:o.join(" "),type:"BUNDLE"}],e.abrupt("return",{sdp:lib.write(i),semantics:"unified-plan",type:"incroffer"});case 6:case"end":return e.stop()}}),e,this)}))),function(){return i.apply(this,arguments)})},{key:"rollback",value:(n=_asyncToGenerator(_regeneratorRuntime().mark((function e(t,r,n){return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return logger$c.print("rollback()"),e.abrupt("return",this.close(r));case 2:case"end":return e.stop()}}),e,this)}))),function(e,t,r){return n.apply(this,arguments)})},{key:"close",value:(r=_asyncToGenerator(_regeneratorRuntime().mark((function e(t,r){var n,i,o,a,s,c,l,u,d,p=this;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return logger$c.print("close()"),a={},t.audioTransceiver&&t.audioMid&&(t.audioTransceiver.stop(),a[t.audioMid]=t.audioMid),t.videoTransceiver&&t.videoMid&&!r&&(t.videoTransceiver.stop(),a[t.videoMid]=t.videoMid),s=[],e.next=7,this._peerConnection.createOffer();case 7:return c=e.sent,(l=lib.parse(null==c?void 0:c.sdp)).media=map$6(n=l.media).call(n,(function(e){return a[e.mid]&&(e=closeMline(e)),"inactive"!==e.direction&&s.push(e.mid),_objectSpread2(_objectSpread2({},e),p._offerIce)})),u=lib.parse(null===(i=this._peerConnection.remoteDescription)||void 0===i?void 0:i.sdp),d={},u.media.forEach((function(e){void 0!==e.mid&&(d[e.mid]=e)})),u.media=map$6(o=l.media).call(o,(function(e){return"inactive"===e.direction?e:d[e.mid]})),l.groups&&u.groups&&(l.groups[0].mids=s.join(" "),u.groups[0].mids=s.join(" ")),e.next=17,this.setLocalDescription(lib.write(l));case 17:return e.next=19,this.setRemoteDescription(lib.write(u));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)})},{key:"createAVMlineOfferTpl",value:function(e){var t=this;lib.parse(e).media.forEach((function(e){"audio"===e.type&&(t._aRecvonlyOfferTpl=e)}))}}]),d}(),createHandler=function(e){return isFirefox?new FirefoxHandler(e):new ChromeHandler(e)},logger$b=new Logger("Locker",2),lockId=1,PromiseLock=function(){function e(t){var r;_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$b.print(concat$2(r="[lock-".concat(this.name,"-")).call(r,this.lockId,"] is created."))}return _createClass(e,[{key:"isLocked",get:function(){return this.locks>0}},{key:"lock",value:function(){var e,t,r,n=this;this.locks+=1,logger$b.print(concat$2(e=concat$2(t="[lock-".concat(this.name,"-")).call(t,this.lockId,"] locked, current queue ")).call(e,this.locks,"."));var i=new promise((function(e){r=function(){var t,r;n.locks-=1,logger$b.print(concat$2(t=concat$2(r="[lock-".concat(n.name,"-")).call(r,n.lockId,"] unlocked, current queue ")).call(t,n.locks,".")),e()}})),o=this.lockingPromise.then((function(){return r}));return this.lockingPromise=this.lockingPromise.then((function(){return i})),o}}]),e}(),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_SUBTITLE_STATE_CHANGED="ON_SUBTITLE_STATE_CHANGED",e.ON_SUBTITLE_MESSAGE_RECEIVED="ON_SUBTITLE_MESSAGE_RECEIVED",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||{}),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=defineProperty$a,__getOwnPropDesc$2=getOwnPropertyDescriptor$1,__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$a=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$a.print(e,"userId: %o, subAudio: %o, subVideo: %o, audioMid: %o, videoMid: %o, sequenceId: %o",t.userId,t.subAudio,t.subVideo,t.audioMid,t.videoMid,t.sequenceId)},MediaServerClient=function(e){_inherits(E,EnhancedEventEmitter);var t,r,n,i,o,a,s,c,l,u,d,p,_,h,f,m,v,g,y,S,T,$=_createSuper(E);function E(e){var t;return _classCallCheck(this,E),_defineProperty(_assertThisInitialized(t=$.call(this)),"id",void 0),_defineProperty(_assertThisInitialized(t),"_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),"_expectedIDC",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 map2),_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),"_subConfig",{}),_defineProperty(_assertThisInitialized(t),"_monitor",void 0),_defineProperty(_assertThisInitialized(t),"_roomProfile",RoomProfileType.communication),_defineProperty(_assertThisInitialized(t),"_context",void 0),_defineProperty(_assertThisInitialized(t),"_subStreamQueue",{}),t.id=e.id,t._monitor=getMonitor(t.id),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(E,[{key:"_addHandlerEvents",value:function(){var e,t=this;null===(e=this._handler)||void 0===e||e.once("disconnect",(function(){logger$a.print("emit ABNORMAL_DISCONNECTION ice"),t.safeEmit(StateEvent.ABNORMAL_DISCONNECTION)}))}},{key:"_addSignalEventHandler",value:function(){var e,t=this;[SignalEvent.ON_ADD_STREAM,SignalEvent.ON_ADD_STREAM_LIST,SignalEvent.ON_REMOVE_STREAM,SignalEvent.ON_REMOVE_STREAM_LIST,SignalEvent.USER_CONNECTION,SignalEvent.USER_CONNECTION_LIST,SignalEvent.USER_DISCONNECTION,SignalEvent.USER_DISCONNECTION_LIST,SignalEvent.ON_UPDATE_STREAM_ATTRIBUTES,SignalEvent.ON_UPDATE_ROOM_ATTRIBUTES,SignalEvent.ON_PUSH_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_UPDATE_USER_ATTRIBUTES,SignalEvent.ON_SPEAKER_CHANGE,MediaServerSignalEvent.RSCP,MediaServerSignalEvent.RTT,MediaServerSignalEvent.SSC,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$a.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:"businessId",set:function(e){this._businessId=e}},{key:"connect",value:(T=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){var r,n,i,o,a,s,c=this,l=arguments;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=l.length>1&&void 0!==l[1]?l[1]:{},this.connectionState="connecting",this._appId=t,this._handler&&(this._removeSignalEventHandler(),this._handler.destroy()),!r.node){e.next=9;break}n=[r.node],reportRtcInvokeStatus(this.id,"es.join.nodeChange",r),e.next=18;break;case 9:return promise.resolve().then((function(){return c.emit("onGetIceConfigHook")})),this._iceConfigRequestManager=new IceConfigRequestManager(this.id),e.next=13,null===(i=this._iceConfigRequestManager)||void 0===i?void 0:i.getAccessNode(t,null==r?void 0:r.reason,null==r?void 0:r.feedbackNode,this._useCloudProxy,this._expectedIDC);case 13:if(n=e.sent){e.next=17;break}throw reportRtcInvokeStatus(this.id,"es.join.getNodeFailed",""),new SDKError(ErrorCode.ICE_SERVER_WRONG,"get ICE config failed");case 17:reportRtcInvokeStatus(this.id,"es.join.getNodeSuccess",n);case 18:return promise.resolve().then((function(){return c.emit("onEstablishConnectionHook")})),e.prev=19,a=!1,s=map$6(n).call(n,(function(e){var t=createHandler(c._context);return t.connect(e).then((function(r){var i,s;c.emit("onConnectSuccessHook",null===(i=n)||void 0===i?void 0:i.length),a?t.destroy():(a=!0,o=r,c.safeEmit("prevIceNode",e),c._handler=t,c.supportConcurrent="chrome"===t.name,c._addHandlerEvents(),null===(s=c._monitor)||void 0===s||s.set({connection_id:t.getConnectionId()}))})).catch((function(e){throw t.destroy(),e}))})),e.next=24,promiseAny2(s);case 24:logger$a.print("connect","establish peerConnection success"),e.next=31;break;case 27:throw e.prev=27,e.t0=e.catch(19),this.connectionState="disconnected",new SDKError(ErrorCode.ESTABLISH_DATACHANNEL_FAILED,"establish dataChannel failed",e.t0);case 31:if(!o){e.next=37;break}this._dataChannelSignal=new DataChannelSignaling(this.id,o),this._addSignalEventHandler(),this._dataChannelSignal.sendPingSignaling(),e.next=39;break;case 37:throw this.connectionState="disconnected",new SDKError(ErrorCode.ESTABLISH_DATACHANNEL_FAILED,"establish dataChannel failed");case 39:case"end":return e.stop()}}),e,this,[[19,27]])}))),function(e){return T.apply(this,arguments)})},{key:"join",value:(S=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){var r,n,i,o,a,s,c,l,u,d,p,_,h,f,m,v,g=this,y=arguments;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=y.length>1&&void 0!==y[1]?y[1]:{},i=y.length>2&&void 0!==y[2]&&y[2],o=y.length>3?y[3]:void 0,logger$a.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._expectedIDC=t.expectedIDC,this._roomProfile=t.roomProfile,this._sessionId=n.sessionId,this._handler){e.next=17;break}return e.next=17,this.connect(this._appId,n);case 17: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=24,null===(r=this._handler)||void 0===r?void 0:r.getDefaultSdp();case 24:return e.t5=e.sent,e.next=27,internalGetSupportedCodecs(getParameter("PUB_SUB_MODE"));case 27: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,enableCloudProxy:e.t14,channelProfile:e.t15},e.t17={supportTokenExpireCallBack:!0,enableSceneConfigV2:!0,enableUnBundleMode:!0,enableAudioMux:!0,enableBigRoomMode:!0,needNegotiateSDP:!0},e.t18=stringify$1({requireICEUfragV2:!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,accessParams:e.t18},e.prev=41,e.t19=reportRtcInvokeStatus,e.t20=this.id,e.t21=stringify$1,e.next=47,internalGetSupportedCodecsSdpOffer();case 47:e.t22=e.sent,e.t23=getParameter("PUB_SUB_MODE")||"recv_and_send",e.t24={supportedCodecsSdpOffer:e.t22,pubSubMode:e.t23},e.t25=(0,e.t21)(e.t24),(0,e.t19)(e.t20,"MediaClient.internalGetSupportedCodecsSdpOffer",e.t25),e.next=56;break;case 54:e.prev=54,e.t26=e.catch(41);case 56:return promise.resolve().then((function(){return g.emit("onSendingJoinMessageHook")})),e.prev=57,c=i?"reconnected":"joinRoom",e.next=61,this._dataChannelSignal.sendSignaling(c,a);case 61:return l=e.sent,logger$a.print("join","send join message success"),u=l.config||{},d=u.engine_WEB,this._authorization=a.Authorization,this.connectionState="connected",sdkCache.setEngineWebConfig(this._appId,this._roomId,d),this._context&&(this._context.serverConfig={videoCodec:(null==d?void 0:d.video_codec)||"H264",audioRed:!(null==d||!d.pub_audio_red),muteReplaceUnsub:!(null===(p=l.config)||void 0===p||!p.mute_replace_unsub),simulcastOnDemand:!(isFirefox||!1===(null===(_=l.config)||void 0===_||null===(h=_.engine_VPM)||void 0===h||null===(f=h.ondemand)||void 0===f?void 0:f.enable))},"boolean"==typeof(null==d?void 0:d.av_sync)&&(this._context.avSync=d.av_sync)),RemoteStatsReport.audioStallConfig=d,null!=l&&null!==(s=l.relayMessage)&&void 0!==s&&s.sdp&&(null===(m=this._handler)||void 0===m||m.createAVMlineAnswerTpl(l.relayMessage.sdp)),e.abrupt("return",l);case 73:if(e.prev=73,e.t27=e.catch(57),this.connectionState="disconnected",v={461:ErrorCode.ROOM_FORBIDDEN,462:ErrorCode.USER_FORBIDDEN},!((null===e.t27||void 0===e.t27?void 0:e.t27.code)>=700&&(null===e.t27||void 0===e.t27?void 0:e.t27.code)<800)){e.next=81;break}throw new SDKError(ErrorCode.INVALID_TOKEN,(null===e.t27||void 0===e.t27?void 0:e.t27.message)||"Invalid token");case 81:if(!v[null===e.t27||void 0===e.t27?void 0:e.t27.code]){e.next=83;break}throw new SDKError(v[null===e.t27||void 0===e.t27?void 0:e.t27.code],(null===e.t27||void 0===e.t27?void 0:e.t27.message)||v[null===e.t27||void 0===e.t27?void 0:e.t27.code]);case 83:if(200===(null===e.t27||void 0===e.t27?void 0:e.t27.code)){e.next=85;break}throw new SDKError(ErrorCode.JOIN_ROOM_FAILED,(null===e.t27||void 0===e.t27?void 0:e.t27.message)||"Join room failed");case 85:case"end":return e.stop()}}),e,this,[[41,54],[57,73]])}))),function(e){return S.apply(this,arguments)})},{key:"publish",value:(y=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){var r,n,i,o,a,s,c,l,u,d,p,_,h,f,m,v,g,y,S,T,$,E,b,I=this;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return logger$a.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);case 9:if(g=e.sent){e.next=12;break}throw new SDKError(ErrorCode.ADD_TRANSCEIVER_FAILED,"add transceiver failed");case 12:if("H264"!==(null===(c=this._context)||void 0===c||null===(l=c.serverConfig)||void 0===l?void 0:l.videoCodec)){e.next=18;break}return e.next=15,isH264EncodeSupported();case 15:if(e.sent){e.next=18;break}throw new SDKError(ErrorCode.PUBLISH_FAILED,"h264 is not supported");case 18:return o=g.audioMid,a=g.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:g.videoDescriptions},t.pubAttributes),audio:!0,video:!0,screen:t.isScreen,audioMid:o,videoMid:a,sdpInfo:{msid:t.stream.id,type:g.type,sdp:g.partialSdp,semantics:g.semantics}},(S=t.enableSimulcast&&(null===(u=this._context)||void 0===u||null===(d=u.serverConfig)||void 0===d?void 0:d.simulcastOnDemand)&&(null===(p=g.subVideoDescriptions)||void 0===p?void 0:p.length))&&(y.attributes.subVideoDescriptions=g.subVideoDescriptions),e.next=26,null===(_=this._dataChannelSignal)||void 0===_?void 0:_.sendSignaling("publish",y);case 26:if(200===(null==(T=e.sent)?void 0:T.code)){e.next=29;break}throw new SDKError(ErrorCode.PUBLISH_FAILED,(null==T?void 0:T.message)||"publish failed");case 29:if(null===(h=this._monitor)||void 0===h||h.report("rtc_recv_answer",{error_code:0,answer_type:"incranswer",sequence_id:(null==T||null===(f=T.relayMessage)||void 0===f?void 0:f.sequenceId)||0,message:null==T||null===(m=T.relayMessage)||void 0===m?void 0:m.sdp,direction:"up",stream_id:"",stream_user_id:""}),$=new promise((function(e,r){var n,i,s;null===(n=I._handler)||void 0===n||n.handleAck({action:SdpAction.publish,streamId:T.streamId,audioMid:o,videoMid:a,audioTransceiverInit:null==g?void 0:g.audioTransceiverInit,videoTransceiverInit:null==g?void 0:g.videoTransceiverInit,signalingAck:{sdp:null==T||null===(i=T.relayMessage)||void 0===i?void 0:i.sdp,sequenceId:null==T||null===(s=T.relayMessage)||void 0===s?void 0:s.sequenceId},sdp:g.sdp,stream:t,onSuccess:function(){logger$a.print("publish()","publish success"),e(0)}})})),e.t0=!isFirefox,!e.t0){e.next=35;break}return e.next=35,$;case 35:return S&&this.emit(MediaServerSignalEvent.RSCP,[{StreamIds:[t.stream.id],Metadata:{VideoIndex:0}}]),t.streamId=T.streamId,t.videoMid=a,t.audioMid=o,t.subVideoDescriptions=g.subVideoDescriptions,null===(v=this._monitor)||void 0===v||v.report("rtc_publish_stat",{result:"success",is_screen:"0",start:i,message:"unknown"}),t.statsReport.setLocalStreamStatsEvtInterval((function(e){return I.emit("onLocalStreamStats",e)}),this._handler,this._context),e.abrupt("return");case 45:return e.prev=45,e.t1=e.catch(6),e.t1 instanceof Error&&(null===(b=this._monitor)||void 0===b||b.report("rtc_publish_stat",{result:"fail",is_screen:"0",start:i,message:e.t1.message})),e.next=50,null===(E=this._handler)||void 0===E?void 0:E.rollback(t.stream.id,t);case 50:throw e.t1;case 51:case"end":return e.stop()}}),e,this,[[6,45]])}))),function(e){return y.apply(this,arguments)})},{key:"updatePubTrack",value:(g=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){var r,n,i,o,a,s,c,l,u,d,p,_,h,f,m,v,g,y,S,T,$,E,b,I,R,C,A,k,P,O,w;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:logger$a.print("updatePubTrack()","localStream: %o",t),i=t.videoTrack,o=t.audioTrack,a=t.pubAudio,s=t.pubVideo,c=null==o?void 0:o.getTrack("preprocessing"),l=null==i?void 0:i.getTrack("preprocessing"),s&&l?null===(u=t.videoTransceiver)||void 0===u||u.sender.replaceTrack(l):null===(d=t.videoTransceiver)||void 0===d||d.sender.replaceTrack(null),null===(r=this._handler)||void 0===r||r.updateMaxBitrate(t),a&&c?(_=o.mixType,(h=o.mixedAudioTrack)&&_!==AudioMixingType.PLAYOUT&&!0===c.enabled&&(c=h),null===(p=t.audioTransceiver)||void 0===p||p.sender.replaceTrack(c)):(null===(f=t.audioTransceiver)||void 0===f||f.sender.replaceTrack(null),reportRtcInvokeStatus(this.id,"MediaClient.updatePubTrack(audio)","null"));try{reportRtcInvokeStatus(this.id,"MediaClient.updatePubTrack",stringify$1({audioStreamTrack:MediaTrackStringify(c),videoStreamTrack:MediaTrackStringify(l)}))}catch(e){}for(v={},g=0,y=entries2(m={localaudio:!!o,localvideo:!!i,videostream:s,audiostream:a,extvideo:!!(i instanceof CustomVideoLocalTrack),extaudio:!!(o instanceof CustomAudioLocalTrack)});g<y.length;g++)S=_slicedToArray(y[g],2),T=S[0],($=S[1])!==get(t.pubAttributes,T)&&set$6(v,T,$);if(keys$8(v).length){e.next=13;break}return e.abrupt("return");case 13:return t.observer&&(E=t.observer,b=v.audiostream,I=v.videostream,R=v.localaudio,C=v.localvideo,A=v.extaudio,k=v.extvideo,void 0!==C?void 0!==k?E.setPushVideo(k):E.setEnableVideo(C):void 0!==I&&E.setUnmuteVideo(I),void 0!==R?void 0!==A?E.setPushAudio(A):E.setEnableAudio(R):void 0!==b&&E.setUnmuteAudio(b)),t.pubAttributes=m,P={roomId:this._roomId,streamId:t.streamId,attributes:v},e.next=18,null===(n=this._dataChannelSignal)||void 0===n?void 0:n.sendSignaling("updateStreamAttributes",P);case 18:if(200===(null==(O=e.sent)?void 0:O.code)){e.next=21;break}throw new SDKError(ErrorCode.UPDATE_TRACK_FAILED,(null==O?void 0:O.message)||"update track failed");case 21:if(!isFirefox){e.next=24;break}return e.next=24,null===(w=this._handler)||void 0===w?void 0:w.setCurrentDescription();case 24:case"end":return e.stop()}}),e,this)}))),function(e){return g.apply(this,arguments)})},{key:"updateToken",value:(v=_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$a.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 v.apply(this,arguments)})},{key:"unpublish",value:(m=_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$a.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 m.apply(this,arguments)})},{key:"subscribe",value:(f=_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,l,u,d,p,_,h,f,m,v,g,y,S,T,$,E,b,I,R,C,A,k,P,O,w,M,D,x,N,L,U,V;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).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$a.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$a.print("subscribe()","mediaType: %o",r),logRemoteStream("subscribe()",t),t.streamState=StreamState.SUB_ING,c=!1,l=!1,audioInMediaType(r)&&(l=!0),videoInMediaType(r)&&(c=!0),c||!i.multiChatMode()){e.next=17;break}return t.streamState=StreamState.INIT,i.emit("SUB_END",t.streamId),e.abrupt("return",o(null));case 17:return u=getServerNow(),d=t.subVideo,p=[],_=!i.multiChatMode(),i._subResolves[t.streamId]||(i._subResolves[t.streamId]=[]),p.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$a.print("remoteStream ".concat(t.userId," received video track")),t.off("ontrack",r),clearTimeout(n),e(0))}))}))),_&&p.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$a.print("remoteStream ".concat(t.userId," received audio track")),t.off("ontrack",r),clearTimeout(n),e(0))}))}))),h=function(e){t.ontrack(e)},null===(s=i._handler)||void 0===s||s.on("ontrack",h),i._ontrackCallbackMap.set(t,h),e.prev=27,e.next=30,null===(f=i._handler)||void 0===f?void 0:f.subscribe(t,{multiChatMode:i.multiChatMode()});case 30:if(I=e.sent){e.next=33;break}throw new SDKError(ErrorCode.ADD_TRANSCEIVER_FAILED,"add transceiver failed");case 33:return R=I.audioMid,C=I.videoMid,t.subVideo=c,A={spatialLayer:(null==n?void 0:n.spatialLayer)||0,temporalLayer:0,spatialSubLayer:(null==n?void 0:n.spatialSubLayer)||-1},k={audio:!i.multiChatMode(),video:!0,data:!0,screen:t.isScreen,browser:"chrome-stable",videoMid:C,audioMid:R,sdpInfo:{sdp:null==I?void 0:I.partialSdp,semantics:null==I?void 0:I.semantics,type:null==I?void 0:I.type},streamUserId:t.userId,streamId:t.streamId,config:{enableMediaType:{audio:!!i.multiChatMode()||l,video:c},qualityLayer:A},extra:{enableSendRTT:!0}},P=i._context||{},O=P.subscribeFallbackOption,w=P.userPriority,"number"==typeof O&&(k.config.fallbackOption=O),null!=w&&w.has(t.userId)&&(k.config.priority=w.get(t.userId)),null!=I&&I.allSsrc&&(k.extra.subscribeSSRC=I.allSsrc),e.next=44,null===(m=i._dataChannelSignal)||void 0===m?void 0:m.sendSignaling("subscribe",k);case 44:if(200===(null==(M=e.sent)?void 0:M.code)){e.next=47;break}throw new SDKError(ErrorCode.SUBSCRIBE_FAILED,(null==M?void 0:M.message)||"subscribe failed");case 47:return D=null==M?void 0:M.relayMessage,x=D.audioMid,N=D.videoMid,_defineProperty(v={},R,x),_defineProperty(v,C,N),L=v,logger$a.print("sub midmap",t.userId,L),t.videoMid=C,t.audioMid=R,t.subMediaType=r,t.streamState=StreamState.SUB_ED,t.subLayer=A,null===(g=i._monitor)||void 0===g||g.report("rtc_recv_answer",{error_code:0,answer_type:"incranswer",sequence_id:(null==M||null===(y=M.relayMessage)||void 0===y?void 0:y.sequenceId)||0,message:null==M||null===(S=M.relayMessage)||void 0===S?void 0:S.sdp,direction:"down",stream_id:t.streamId,stream_user_id:t.userId}),e.next=58,null===(T=i._handler)||void 0===T?void 0:T.handleAck({action:SdpAction.subscribe,streamId:t.streamId,audioMid:R,videoMid:C,audioTransceiverInit:null==I?void 0:I.audioTransceiverInit,videoTransceiverInit:null==I?void 0:I.videoTransceiverInit,signalingAck:{sdp:null==M||null===($=M.relayMessage)||void 0===$?void 0:$.sdp,sequenceId:null==M||null===(E=M.relayMessage)||void 0===E?void 0:E.sequenceId},stream:t,sdp:I.sdp,generatorSsrc:!!I.allSsrc});case 58:return e.next=60,promise.all(p);case 60:i.multiChatMode()||(t.subAudio=l),null===(b=i._monitor)||void 0===b||b.report("rtc_subscribe_stat",{result:"success",start:u,message:"unknown",stream_user_id:t.userId}),i._context&&t.statsReport.setRemoteStreamStatsEvtInterval((function(e){return i.emit("onRemoteStreamStats",e)}),i._handler,i._context),o(null),i.emit("SUB_END",t.streamId),e.next=76;break;case 67:return e.prev=67,e.t0=e.catch(27),e.t0 instanceof Error&&(null===(V=i._monitor)||void 0===V||V.report("rtc_subscribe_stat",{result:"fail",start:u,message:e.t0.message,stream_user_id:t.userId})),t.subVideo=d,t.streamState=StreamState.INIT,e.next=74,null===(U=i._handler)||void 0===U?void 0:U.rollback(t.streamId,t);case 74:a(e.t0),i.emit("SUB_END",t.streamId);case 76:case"end":return e.stop()}}),e,null,[[27,67]])})));return function(t,r){return e.apply(this,arguments)}}()));case 1:case"end":return e.stop()}}),e)}))),function(e,t,r){return f.apply(this,arguments)})},{key:"_handleSubStreamQueue",value:function(e){var t,r=this;if(null!==(t=this._subStreamQueue[e])&&void 0!==t&&t.length){logger$a.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$a.print("_subStreamQueue","streamId: %o, END",e)}},{key:"controlMessage",value:(h=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){var r,n;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return logger$a.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 h.apply(this,arguments)})},{key:"updateUserAttributes",value:(_=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){var r;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return logger$a.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 _.apply(this,arguments)})},{key:"updateSubTrack",value:(p=_asyncToGenerator(_regeneratorRuntime().mark((function e(t,r,n){return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this._updateSubTrack(t,r,n));case 1:case"end":return e.stop()}}),e,this)}))),function(e,t,r){return p.apply(this,arguments)})},{key:"updateSubTrackLayer",value:(d=_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(logger$a.print("updateSubTrack()","subLayer: %o",r),t.subLayer.spatialLayer!==r.spatialLayer||t.subLayer.spatialSubLayer!==r.spatialSubLayer){e.next=4;break}return logger$a.print("updateSubTrack()","subLayer no change"),e.abrupt("return");case 4:return i={roomId:this._roomId,streamList:[t.streamId],streamId:t.streamId,streamUserId:t.userId,config:{qualityLayer:r}},e.next=7,null===(n=this._dataChannelSignal)||void 0===n?void 0:n.sendSignaling("updateSubscribe",i);case 7:if(200===(null==(o=e.sent)?void 0:o.code)){e.next=10;break}throw new SDKError(ErrorCode.UPDATE_TRACK_FAILED,(null==o?void 0:o.message)||"update track failed");case 10:return t.subLayer=r,e.abrupt("return",t);case 12:case"end":return e.stop()}}),e,this)}))),function(e,t){return d.apply(this,arguments)})},{key:"updateSubPriority",value:(u=_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(logger$a.print("updateSubPriority()","priority: %o",r),t.priority!==r){e.next=4;break}return logger$a.print("updateSubPriority()","priority no change"),e.abrupt("return",t);case 4:return i={roomId:this._roomId,streamList:[t.streamId],streamId:t.streamId,streamUserId:t.userId,config:{priority:r}},e.next=7,null===(n=this._dataChannelSignal)||void 0===n?void 0:n.sendSignaling("updateSubscribe",i);case 7:if(200===(null==(o=e.sent)?void 0:o.code)){e.next=10;break}throw new SDKError(ErrorCode.UPDATE_TRACK_FAILED,(null==o?void 0:o.message)||"update track failed");case 10:return t.priority=r,e.abrupt("return",t);case 12:case"end":return e.stop()}}),e,this)}))),function(e,t){return u.apply(this,arguments)})},{key:"_updateSubTrack",value:(l=_asyncToGenerator(_regeneratorRuntime().mark((function e(t,r,n){var i,o,a,s,c,l,u,d;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(logger$a.print("updateSubTrack()","mediaType: %o",r),logRemoteStream("updateSubTrack()",t),!this.multiChatMode()||r!==MediaType.AUDIO){e.next=5;break}return logger$a.print("updateSubTrack","multiChatMode mediaType only audio"),e.abrupt("return",t);case 5:return a=0,a=n===SubState.SUB?t.subMediaType|r:t.subMediaType-(t.subMediaType&r),logger$a.print("updateSubTrack","prev: %o, direction: %o, mediaType: %o, newMediaType: %o",t.subMediaType,n,r,a),t.subMediaType===a&&logger$a.print("updateSubTrack","mediaType no change"),s=!1,c=!1,audioInMediaType(a)&&(c=!0),videoInMediaType(a)&&(s=!0),l={roomId:this._roomId,streamList:[t.streamId],config:{enableMediaType:{video:s,audio:!!this.multiChatMode()||c}}},e.next=15,null===(i=this._dataChannelSignal)||void 0===i?void 0:i.sendSignaling("updateSubscribe",l);case 15:if(200===(null==(u=e.sent)?void 0:u.code)){e.next=18;break}throw new SDKError(ErrorCode.UPDATE_TRACK_FAILED,(null==u?void 0:u.message)||"update track failed");case 18:return this.multiChatMode()||(null===(d=t.observer)||void 0===d||d.setUnmuteAudio(c),t.subAudio=c),null===(o=t.observer)||void 0===o||o.setUnmuteVideo(s),t.subVideo=s,t.subMediaType=a,e.abrupt("return",t);case 23:case"end":return e.stop()}}),e,this)}))),function(e,t,r){return l.apply(this,arguments)})},{key:"subscribe4pushTrack",value:(c=_asyncToGenerator(_regeneratorRuntime().mark((function e(t,r){var n,i,o,a,s,c,l,u,d,p=this;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return logger$a.print("subscribe4pushTrack()","streamInfo: %o",r),logRemoteStream("subscribe4pushTrack()",t),t.subAudio=!0,null===(n=t.observer)||void 0===n||n.setPushTrack(!0),e.next=6,null===(i=this._handler)||void 0===i?void 0:i.subscribe(t,{multiChatMode:this.multiChatMode()});case 6:if(s=e.sent){e.next=9;break}throw new SDKError(ErrorCode.ADD_TRANSCEIVER_FAILED,"add transceiver failed");case 9:return c=s.audioMid,l=s.videoMid,(u=[]).push(new promise((function(e,r){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$a.print("remoteStream ".concat(t.userId," received audio track")),t.off("ontrack",r),clearTimeout(n),e(0))}))}))),d=function(e){t.ontrack(e)},null===(o=this._handler)||void 0===o||o.on("ontrack",d),this._ontrackCallbackMap.set(t,d),e.next=18,null===(a=this._handler)||void 0===a?void 0:a.handleAck({action:SdpAction.pushtrack,streamId:t.streamId,audioMid:c,videoMid:l,stream:t,audioTransceiverInit:null==s?void 0:s.audioTransceiverInit,videoTransceiverInit:null==s?void 0:s.videoTransceiverInit,signalingAck:null==r?void 0:r.message,sdp:s.sdp});case 18:return e.next=20,promise.all(u);case 20:this._context&&t.statsReport.setRemoteStreamStatsEvtInterval((function(e){return p.emit("onRemoteStreamStats",e)}),this._handler,this._context);case 21:case"end":return e.stop()}}),e,this)}))),function(e,t){return c.apply(this,arguments)})},{key:"unsubscribe4removeTrack",value:(s=_asyncToGenerator(_regeneratorRuntime().mark((function e(t,r){return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:logRemoteStream("unsubscribe4removeTrack()",t),logger$a.print("unsubscribe4removeTrack()","sequenceId: ",r.sequenceId);case 2:case"end":return e.stop()}}),e)}))),function(e,t){return s.apply(this,arguments)})},{key:"unsubscribe",value:(a=_asyncToGenerator(_regeneratorRuntime().mark((function e(t,r){var n,i,o=arguments;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=o.length>2&&void 0!==o[2]&&o[2],logRemoteStream("unsubscribe()",t),!n){e.next=4;break}return e.abrupt("return",this._unsubscribe(t,r));case 4:if(!this.multiChatMode()||!videoInMediaType(r)){e.next=6;break}return e.abrupt("return",this._unsubscribe(t,r));case 6:if(i=t.subMediaType-(t.subMediaType&r),this.multiChatMode()||i!==ExtendMediaType.NONE){e.next=9;break}return e.abrupt("return",this._unsubscribe(t,r));case 9:return e.abrupt("return",this._updateSubTrack(t,r,SubState.UNSUB));case 10: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;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._subConfig.muteReplaceUnsub){e.next=2;break}return e.abrupt("return",this._updateSubTrack(t,r,SubState.UNSUB));case 2:return 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,null===(i=t.observer)||void 0===i||i.setSubscribeVideo(!1),!this.multiChatMode()&&(null===(o=t.observer)||void 0===o||o.setSubscribeAudio(!1)),e.next=11,null===(a=this._handler)||void 0===a?void 0:a.handleAck({action:SdpAction.unsubscribe,streamId:t.streamId,audioMid:t.audioMid,videoMid:t.videoMid,stream:t});case 11:c=e.sent,this._subResolves[c]&&this._subResolves[c].forEach((function(e){return e(0)})),logger$a.print("unsubscribe","clean unsub ".concat(t.userId)),t.clean(),this.removeOnTrackListener(t),t.statsReport.unsubscribe();case 17: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,t.streamState!==StreamState.INIT){e.next=4;break}return e.abrupt("return");case 4:this.unsubscribe(t,MediaType.AUDIO_AND_VIDEO,!0);case 5: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$a.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,l,u,d,p,_,h,f,m,v,g=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,{multiChatMode:!1});case 2:if(s=e.sent){e.next=5;break}throw new SDKError(ErrorCode.ADD_TRANSCEIVER_FAILED,"add transceiver failed");case 5:return c=getServerNow(),l=s.audioMid,u=s.videoMid,e.t0=this._appId,e.t1=t.streamId,e.t2=l,e.t3=u,e.t4={sdp:null==s?void 0:s.partialSdp,semantics:null==s?void 0:s.semantics,type:null==s?void 0:s.type},e.next=15,internalGetSupportedCodecs();case 15:return e.t5=e.sent,e.t6=window.navigator.userAgent,e.t7=Config.VERSION,e.t8=sdkCache.getDeviceId(),e.t9=this._appId,e.t10=this._businessId,e.t11=this._useCloudProxy,e.t12={supportedCodecs:e.t5,deviceType:"web",userAgent:e.t6,sdkVersion:e.t7,deviceId:e.t8,appId:e.t9,businessId:e.t10,enableCloudProxy:e.t11},e.t13={enableMediaType:{audio:!0,video:!0},qualityLayer:{spatialLayer:0,temporalLayer:0}},d={appId:e.t0,streamId:e.t1,audio:!0,video:!0,data:!0,audioMid:e.t2,videoMid:e.t3,sdpInfo:e.t4,params:e.t12,config:e.t13},e.next=27,null===(n=this._dataChannelSignal)||void 0===n?void 0:n.sendSignaling("startPullStream",d);case 27:return p=e.sent,_=[],this._subResolves[t.streamId]=[],_.push(new promise((function(e,r){g._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$a.print("remoteStream ".concat(t.userId," received video track")),t.off("ontrack",r),clearTimeout(n),e(0))}))}))),_.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 streamId: ".concat(t.streamId)))}),WAIT_TRACK_TIMEOUT);t.on("ontrack",(function r(i){"audio"===i.mediaType&&(logger$a.print("remoteStream ".concat(t.userId," received audio track")),t.off("ontrack",r),clearTimeout(n),e(0))}))}))),h=function(e){t.ontrack(e)},null===(i=this._handler)||void 0===i||i.on("ontrack",h),this._ontrackCallbackMap.set(t,h),f=null==p?void 0:p.relayMessage,m=f.sequenceId,v=f.sdp,t.videoMid=u,t.audioMid=l,t.sequenceId=m,t.streamState=StreamState.SUB_ED,t.subAudio=!0,t.subVideo=!0,e.next=44,null===(o=this._handler)||void 0===o?void 0:o.handleAck({action:SdpAction.subscribe,streamId:t.streamId,audioMid:l,videoMid:u,audioTransceiverInit:null==s?void 0:s.audioTransceiverInit,videoTransceiverInit:null==s?void 0:s.videoTransceiverInit,signalingAck:{sdp:v,sequenceId:m},stream:t});case 44:return e.next=46,promise.all(_);case 46:null===(a=this._monitor)||void 0===a||a.report("rtc_subscribe_stat",{result:"success",start:c,message:"unknown",stream_user_id:t.userId}),this._context&&t.statsReport.setRemoteStreamStatsEvtInterval((function(e){return g.emit("onRemoteStreamStats",e)}),this._handler,this._context);case 48: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,n;logger$a.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,null===(e=this._handler)||void 0===e||e.destroy(),null===(t=this._monitor)||void 0===t||t.set({connection_id:""}),null===(r=this._dataChannelSignal)||void 0===r||r.destroy(),null===(n=this._iceConfigRequestManager)||void 0===n||n.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}}]),E}();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([checkConnection],MediaServerClient.prototype,"updateSubTrackLayer",1),__decorateClass$2([checkConnection],MediaServerClient.prototype,"updateSubPriority",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,logger$9=new Logger("RecvFrameObserver",0),RecvFrameObserver=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)),"_audioEventSessionId",genEventSessionId()),_defineProperty(_assertThisInitialized(r),"_videoEventSessionId",genEventSessionId()),_defineProperty(_assertThisInitialized(r),"_handler",void 0),_defineProperty(_assertThisInitialized(r),"_stream",void 0),_defineProperty(_assertThisInitialized(r),"_firstAudioFrameTimer",void 0),_defineProperty(_assertThisInitialized(r),"_firstVideoFrameTimer",void 0),_defineProperty(_assertThisInitialized(r),"_transportDelayInterval",void 0),_defineProperty(_assertThisInitialized(r),"_transportDelay",void 0),_defineProperty(_assertThisInitialized(r),"_firstVideoFrameInterval",void 0),_defineProperty(_assertThisInitialized(r),"_firstAudioFrameInterval",void 0),_defineProperty(_assertThisInitialized(r),"_isScreen",!1),_defineProperty(_assertThisInitialized(r),"_audioFirstFrameState",0),_defineProperty(_assertThisInitialized(r),"_videoFirstFrameState",0),_defineProperty(_assertThisInitialized(r),"_timeout",1e4),_defineProperty(_assertThisInitialized(r),"_currentAudioRecv",{startTime:0,eventSessionId:0,type:"login"}),_defineProperty(_assertThisInitialized(r),"_currentVideoRecv",{startTime:0,eventSessionId:0,type:"login"}),_defineProperty(_assertThisInitialized(r),"_login",!1),_defineProperty(_assertThisInitialized(r),"_unMuteAudio",!1),_defineProperty(_assertThisInitialized(r),"_enableAudio",!1),_defineProperty(_assertThisInitialized(r),"_unMuteVideo",!1),_defineProperty(_assertThisInitialized(r),"_enableVideo",!1),_defineProperty(_assertThisInitialized(r),"_remoteUnmuteAudio",!1),_defineProperty(_assertThisInitialized(r),"_remoteUnmuteVideo",!1),_defineProperty(_assertThisInitialized(r),"_audioExternal",!1),_defineProperty(_assertThisInitialized(r),"_pushAudio",!1),_defineProperty(_assertThisInitialized(r),"_videoExternal",!1),_defineProperty(_assertThisInitialized(r),"_pushVideo",!1),_defineProperty(_assertThisInitialized(r),"_autoSubscribeVideo",!1),_defineProperty(_assertThisInitialized(r),"_autoSubscribeAudio",!1),_defineProperty(_assertThisInitialized(r),"_autoSubscribe",!1),_defineProperty(_assertThisInitialized(r),"_publishVideo",!1),_defineProperty(_assertThisInitialized(r),"_publishAudio",!1),_defineProperty(_assertThisInitialized(r),"_subscribeAudio",!1),_defineProperty(_assertThisInitialized(r),"_subscribeVideo",!1),_defineProperty(_assertThisInitialized(r),"_subscribe",!1),_defineProperty(_assertThisInitialized(r),"_pushTrack",!1),_defineProperty(_assertThisInitialized(r),"_multiChatMode",!1),_defineProperty(_assertThisInitialized(r),"_monitor",void 0),r._stream=e,r._handler=t,r.getTransportDelay(),r._monitor=getMonitor(e.engineId),r}return _createClass(a,[{key:"beginRecvFrame",value:(i=_asyncToGenerator(_regeneratorRuntime().mark((function e(t,r){var n,i,o,a,s,c,l,u,d,p,_,h,f,m=this;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.getTransportDelay();case 2:i=this._transportDelay,o=!0,indexOf2(n=["login","unmute","subscribe","push_track"]).call(n,r)>=0&&(i=0,o=!1),"audio"===t?(o||this._audioEventSessionId++,this._currentAudioRecv={startTime:Date.now(),eventSessionId:this._audioEventSessionId,type:r},u={media_type:t,event_type:"begin_recv",type:r,is_screen:!(null===(a=this._stream)||void 0===a||!a.isScreen),start:null===(s=this._currentAudioRecv)||void 0===s?void 0:s.startTime,event_session_id:this._audioEventSessionId,stream_user_id:null===(c=this._stream)||void 0===c?void 0:c.userId,transport_delay:i},this._firstAudioFrameTimer&&window.clearTimeout(this._firstAudioFrameTimer),this._firstAudioFrameTimer=window.setTimeout((function(){m.stopRecvFrame("audio","timeout"),m._firstAudioFrameInterval&&window.clearInterval(m._firstAudioFrameInterval)}),this._timeout),logger$9.print("rtcFirstFrameRecv",stringify$1(u)),null===(l=this._monitor)||void 0===l||l.report("rtc_first_frame",u),this._watchForFirstAudioFrameRecv(),this._audioFirstFrameState=1,this._login=!0,this._unMuteAudio=!0,this._enableAudio=!0,this._remoteUnmuteAudio=!0):"video"===t&&(o||this._videoEventSessionId++,this._currentVideoRecv={startTime:Date.now(),eventSessionId:this._videoEventSessionId,type:r},f={media_type:t,event_type:"begin_recv",type:r,is_screen:!(null===(d=this._stream)||void 0===d||!d.isScreen),start:null===(p=this._currentVideoRecv)||void 0===p?void 0:p.startTime,event_session_id:this._videoEventSessionId,stream_user_id:null===(_=this._stream)||void 0===_?void 0:_.userId,transport_delay:i},this._firstVideoFrameTimer&&window.clearTimeout(this._firstVideoFrameTimer),this._firstVideoFrameTimer=window.setTimeout((function(){_asyncToGenerator(_regeneratorRuntime().mark((function e(){var t,r,n,i,o,a,s,c,l,u,d,p,_,h,f,v,g;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(e.t0=null===(t=m._handler)||void 0===t?void 0:t.pc,!e.t0){e.next=5;break}return e.next=4,getStats(null===(r=m._handler)||void 0===r?void 0:r.pc,null===(n=m._stream)||void 0===n||null===(i=n.videoTrack)||void 0===i?void 0:i.getTrack());case 4:e.t0=e.sent;case 5:return h=e.t0,f=find$2(o=h||[]).call(o,(function(e){return"inbound-rtp"===e.type})),e.next=9,null===(a=m._stream)||void 0===a||null===(s=a.videoTransceiver)||void 0===s?void 0:s.receiver.getStats();case 9:v=e.sent,g=[],null==v||v.forEach((function(e){return g.push(e.type)})),null===(c=m._monitor)||void 0===c||c.report("rtc_invoke_status",{sdk_api_name:"first_video_frame_timeout",error_code:-1,message:stringify$1({reports:map$6(h).call(h,(function(e){return e.type})),reports2:g,pc:(null===(l=m._handler)||void 0===l?void 0:l.pc)||null,track:(null===(u=m._stream)||void 0===u||null===(d=u.videoTrack)||void 0===d?void 0:d.getTrack().id)||null,framesReceived:null==f?void 0:f.framesReceived,packetsReceived:null==f?void 0:f.packetsReceived}),stream_id:(null===(p=m._stream)||void 0===p?void 0:p.streamId)||"",stream_user_id:null===(_=m._stream)||void 0===_?void 0:_.userId,elapse:0});case 13:case"end":return e.stop()}}),e)})))(),m.stopRecvFrame("video","timeout"),m._firstVideoFrameInterval&&window.clearInterval(m._firstVideoFrameInterval)}),this._timeout),this._watchForFirstVideoFrameRecv(),logger$9.print("rtcFirstFrameRecv",stringify$1(f)),null===(h=this._monitor)||void 0===h||h.report("rtc_first_frame",f),this._videoFirstFrameState=1,this._login=!0,this._unMuteVideo=!0,this._enableVideo=!0,this._remoteUnmuteVideo=!0);case 6:case"end":return e.stop()}}),e,this)}))),function(e,t){return i.apply(this,arguments)})},{key:"stopRecvFrame",value:function(e,t){if("audio"===e){var r,n,i,o,a;if(1!==this._audioFirstFrameState)return;var s={event_type:"recv_end",media_type:e,is_screen:!(null===(r=this._stream)||void 0===r||!r.isScreen),start:null===(n=this._currentAudioRecv)||void 0===n?void 0:n.startTime,reason:t,result:!1,stream_user_id:null===(i=this._stream)||void 0===i?void 0:i.userId,event_session_id:this._audioEventSessionId,type:null===(o=this._currentAudioRecv)||void 0===o?void 0:o.type};this._firstAudioFrameTimer&&window.clearTimeout(this._firstAudioFrameTimer),delete this._currentAudioRecv,logger$9.print("rtcFirstFrameRecv",stringify$1(s)),null===(a=this._monitor)||void 0===a||a.report("rtc_first_frame",s),this._audioFirstFrameState=2}else if("video"===e){var c,l,u,d,p;if(1!==this._videoFirstFrameState)return;var _={event_type:"recv_end",media_type:e,is_screen:!(null===(c=this._stream)||void 0===c||!c.isScreen),start:null===(l=this._currentVideoRecv)||void 0===l?void 0:l.startTime,reason:t,result:!1,stream_user_id:null===(u=this._stream)||void 0===u?void 0:u.userId,event_session_id:this._videoEventSessionId,type:null===(d=this._currentVideoRecv)||void 0===d?void 0:d.type};this._firstVideoFrameTimer&&window.clearTimeout(this._firstVideoFrameTimer),delete this._currentVideoRecv,logger$9.print("rtcFirstFrameRecv",stringify$1(_)),null===(p=this._monitor)||void 0===p||p.report("rtc_first_frame",_),this._videoFirstFrameState=2}}},{key:"recvFrameFinish",value:(n=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){var r,n,i,o,a,s,c,l,u,d,p,_,h,f,m,v,g;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,"audio"!==t){e.next=19;break}if(1===this._audioFirstFrameState){e.next=6;break}return e.abrupt("return");case 6:if(this._currentAudioRecv){e.next=8;break}return e.abrupt("return");case 8:s=this._currentAudioRecv,c=s.type,l=s.startTime,indexOf2(n=["login","unmute","subscribe","push_track"]).call(n,c)>=0&&(r=0),u={event_type:"recv_end",media_type:t,start:l,result:!0,is_screen:!(null===(i=this._stream)||void 0===i||!i.isScreen),stream_user_id:null===(o=this._stream)||void 0===o?void 0:o.userId,event_session_id:this._audioEventSessionId,type:c,transport_delay:r},delete this._currentAudioRecv,this._firstAudioFrameTimer&&window.clearTimeout(this._firstAudioFrameTimer),logger$9.print("rtcFirstFrameRecv",stringify$1(u)),null===(a=this._monitor)||void 0===a||a.report("rtc_first_frame",u),this.emit("recvAudioFirstFrame"),this._audioFirstFrameState=3,e.next=33;break;case 19:if("video"!==t){e.next=33;break}if(1===this._videoFirstFrameState){e.next=22;break}return e.abrupt("return");case 22:if(this._currentVideoRecv){e.next=24;break}return e.abrupt("return");case 24:f=this._currentVideoRecv,m=f.type,v=f.startTime,indexOf2(d=["login","unmute","subscribe","push_track"]).call(d,m)>=0&&(r=0),g={event_type:"recv_end",media_type:t,is_screen:!(null===(p=this._stream)||void 0===p||!p.isScreen),start:v,result:!0,stream_user_id:null===(_=this._stream)||void 0===_?void 0:_.userId,event_session_id:this._videoEventSessionId,type:m,transport_delay:r},delete this._currentVideoRecv,this._firstVideoFrameTimer&&window.clearTimeout(this._firstVideoFrameTimer),logger$9.print("rtcFirstFrameRecv",stringify$1(g)),null===(h=this._monitor)||void 0===h||h.report("rtc_first_frame",g),this.emit("recvVideoFirstFrame"),this._videoFirstFrameState=3;case 33: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("audio","login"),e&&null!==(r=this._stream)&&void 0!==r&&r.hasVideo&&o.video&&this.beginRecvFrame("video","login"),!e&&null!==(n=this._stream)&&void 0!==n&&n.hasAudio&&this.stopRecvFrame("audio","leave_room"),!e&&null!==(i=this._stream)&&void 0!==i&&i.hasVideo&&this.stopRecvFrame("video","leave_room"))}},{key:"setUnmuteAudio",value:function(e){var t,r,n;if(this._unMuteAudio!==e){this._unMuteAudio=e;var i=!(null===(t=this._stream)||void 0===t||!t.hasAudio);null!==(r=this._stream)&&void 0!==r&&r.audioHasCapture&&null!==(n=this._stream)&&void 0!==n&&n.audioHasPublish&&(this._unMuteAudio&&i?this.beginRecvFrame("audio","unmute"):i&&this.stopRecvFrame("audio","mute"))}}},{key:"setRemoteUnmuteAudio",value:function(e){this._remoteUnmuteAudio!==e&&(this._remoteUnmuteAudio=e,this._remoteUnmuteAudio?this.beginRecvFrame("audio","remote_unmute"):this.stopRecvFrame("audio","remote_mute"))}},{key:"setEnableAudio",value:function(e){var t;this._enableAudio!==e&&(this._enableAudio=e,this._enableAudio?this.beginRecvFrame("audio","enable"):null!==(t=this._stream)&&void 0!==t&&t.hasAudio&&this.stopRecvFrame("audio","disable"))}},{key:"setUnmuteVideo",value:function(e){var t,r,n;if(this._unMuteVideo!==e){this._unMuteVideo=e;var i=!(null===(t=this._stream)||void 0===t||!t.hasVideo);null!==(r=this._stream)&&void 0!==r&&r.videoHasCapture&&null!==(n=this._stream)&&void 0!==n&&n.videoHasPublish&&(this._unMuteVideo&&i?this.beginRecvFrame("video","unmute"):i&&this.stopRecvFrame("video","mute"))}}},{key:"setRemoteUnmuteVideo",value:function(e){this._remoteUnmuteVideo!==e&&(this._remoteUnmuteVideo=e,this._remoteUnmuteVideo?this.beginRecvFrame("video","remote_unmute"):this.stopRecvFrame("video","remote_mute"))}},{key:"setEnableVideo",value:function(e){this._enableVideo!==e&&(this._enableVideo=e,this._enableVideo?this.beginRecvFrame("video","enable"):this.stopRecvFrame("video","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("audio","push"),!e&&null!==(t=this._stream)&&void 0!==t&&t.hasAudio&&this.beginRecvFrame("audio","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("video","push"),!e&&null!==(t=this._stream)&&void 0!==t&&t.hasVideo&&this.beginRecvFrame("video","push")}},{key:"setPublishVideo",value:function(e){var t;this._publishVideo!==e&&(this._publishVideo=e),this._publishVideo&&this.beginRecvFrame("video","publish"),!e&&null!==(t=this._stream)&&void 0!==t&&t.hasVideo&&this.stopRecvFrame("video","unpublish")}},{key:"setPublishAudio",value:function(e){var t;this._publishAudio!==e&&(this._publishAudio=e),this._publishAudio&&this.beginRecvFrame("audio","publish"),!e&&null!==(t=this._stream)&&void 0!==t&&t.hasAudio&&this.stopRecvFrame("audio","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("audio","subscribe"));!e&&null!==(t=this._stream)&&void 0!==t&&t.hasAudio&&this.stopRecvFrame("audio","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("video","subscribe"));!e&&null!==(t=this._stream)&&void 0!==t&&t.hasVideo&&this.stopRecvFrame("video","unsubscribe")}},{key:"setPushTrack",value:function(e){var t;this._pushTrack!==e&&(e&&!this._isScreen&&this.beginRecvFrame("audio","push_track"),!e&&null!==(t=this._stream)&&void 0!==t&&t.hasAudio&&this.stopRecvFrame("audio","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.clearInterval(this._firstVideoFrameInterval),this._firstVideoFrameInterval=window.setInterval(_asyncToGenerator(_regeneratorRuntime().mark((function n(){var i,o,a,s,c,l,u,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===(l=c.videoTrack)||void 0===l?void 0:l.getTrack());case 3:if(u=n.sent,!(d=find$2(u).call(u,(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("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.clearInterval(this._firstAudioFrameInterval),this._firstAudioFrameInterval=window.setInterval(_asyncToGenerator(_regeneratorRuntime().mark((function n(){var i,o,a,s,c,l,u,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.getOrgTrack()){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===(l=c.audioTrack)||void 0===l?void 0:l.getOrgTrack());case 3:if(u=n.sent,!(d=find$2(u).call(u,(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("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=find$2(n).call(n,(function(e){return"transport"===e.type&&"connected"===e.dtlsState})),(o=find$2(n).call(n,(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:"login"},this._currentVideoRecv={startTime:0,eventSessionId:0,type:"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)}},{key:"audioFirstFrameReceived",get:function(){return 3===this._audioFirstFrameState}},{key:"FirstFrameReceived",get:function(){return 3===this._audioFirstFrameState}}]),a}(),logger$8=new Logger("SendFrameObserver",0),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:"login"}),_defineProperty(this,"_currentVideoSend",{startTime:0,eventSessionId:0,type:"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),_defineProperty(this,"_monitor",void 0),this._stream=t,this._handler=r,this._monitor=getMonitor(t.engineId)}var t,r;return _createClass(e,[{key:"beginSendFrame",value:function(e,t){var r=this;if("audio"===e){var n,i,o;this._audioEventSessionId++,this._currentAudioSend={startTime:Date.now(),eventSessionId:this._audioEventSessionId,type:t};var a={event_type:"begin_send",media_type:e,is_screen:!(null===(n=this._stream)||void 0===n||!n.isScreen),type:t,start:null===(i=this._currentAudioSend)||void 0===i?void 0:i.startTime,event_session_id:this._audioEventSessionId};this._firstAudioFrameTimer&&window.clearTimeout(this._firstAudioFrameTimer),this._firstAudioFrameTimer=window.setTimeout((function(){r.stopSendFrame("audio","timeout"),r._firstAudioFrameInterval&&window.clearInterval(r._firstAudioFrameInterval)}),this._timeout),logger$8.print("rtcFirstFrameSend",stringify$1(a)),null===(o=this._monitor)||void 0===o||o.report("rtc_first_frame",a),this._watchForFirstAudioFrameSend(),this._audioFirstFrameState=1,this._login=!0,this._publisher=!0,this._publish=!0,this._unMuteAudio=!0,this._pushAudio||(this._enableAudio=!0)}else if("video"===e){var s,c,l;this._videoEventSessionId++,this._currentVideoSend={startTime:Date.now(),eventSessionId:this._videoEventSessionId,type:t};var u={event_type:"begin_send",media_type:e,is_screen:!(null===(s=this._stream)||void 0===s||!s.isScreen),type:t,start:null===(c=this._currentVideoSend)||void 0===c?void 0:c.startTime,event_session_id:this._videoEventSessionId};this._firstVideoFrameTimer&&window.clearTimeout(this._firstVideoFrameTimer),this._firstVideoFrameTimer=window.setTimeout((function(){r.stopSendFrame("video","timeout"),r._firstVideoFrameInterval&&window.clearInterval(r._firstVideoFrameInterval)}),this._timeout),this._watchForFirstVideoFrameSend(),logger$8.print("rtcFirstFrameSend",stringify$1(u)),null===(l=this._monitor)||void 0===l||l.report("rtc_first_frame",u),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("audio"===e){var r,n,i,o;if(1!==this._audioFirstFrameState)return;var a={event_type:"sent_end",media_type:e,is_screen:!(null===(r=this._stream)||void 0===r||!r.isScreen),start:null===(n=this._currentAudioSend)||void 0===n?void 0:n.startTime,reason:t,result:!1,event_session_id:this._audioEventSessionId,type:null===(i=this._currentAudioSend)||void 0===i?void 0:i.type};this._firstAudioFrameTimer&&window.clearTimeout(this._firstAudioFrameTimer),delete this._currentAudioSend,logger$8.print("rtcFirstFrameSend",stringify$1(a)),null===(o=this._monitor)||void 0===o||o.report("rtc_first_frame",a),this._audioFirstFrameState=2}else if("video"===e){var s,c,l,u;if(1!==this._videoFirstFrameState)return;var d={event_type:"sent_end",media_type:e,start:null===(s=this._currentVideoSend)||void 0===s?void 0:s.startTime,is_screen:!(null===(c=this._stream)||void 0===c||!c.isScreen),reason:t,result:!1,event_session_id:this._videoEventSessionId,type:null===(l=this._currentVideoSend)||void 0===l?void 0:l.type};this._firstVideoFrameTimer&&window.clearTimeout(this._firstVideoFrameTimer),delete this._currentVideoSend,logger$8.print("rtcFirstFrameSend",stringify$1(d)),null===(u=this._monitor)||void 0===u||u.report("rtc_first_frame",d),this._videoFirstFrameState=2}}},{key:"sendFrameFinish",value:function(e){if("audio"===e){var t,r;if(1!==this._audioFirstFrameState)return;if(!this._currentAudioSend)return;var n=this._currentAudioSend,i=n.type,o=n.startTime,a={event_type:"sent_end",media_type:e,is_screen:!(null===(t=this._stream)||void 0===t||!t.isScreen),start:o,result:!0,event_session_id:this._audioEventSessionId,type:i};delete this._currentAudioSend,this._firstAudioFrameTimer&&window.clearTimeout(this._firstAudioFrameTimer),logger$8.print("rtcFirstFrameSend",stringify$1(a)),null===(r=this._monitor)||void 0===r||r.report("rtc_first_frame",a),this._audioFirstFrameState=3}else if("video"===e){var s,c;if(1!==this._videoFirstFrameState)return;if(!this._currentVideoSend)return;var l=this._currentVideoSend,u=l.type,d=l.startTime,p={event_type:"sent_end",media_type:e,is_screen:!(null===(s=this._stream)||void 0===s||!s.isScreen),start:d,result:!0,event_session_id:this._videoEventSessionId,type:u};delete this._currentVideoSend,this._firstVideoFrameTimer&&window.clearTimeout(this._firstVideoFrameTimer),logger$8.print("rtcFirstFrameSend",stringify$1(p)),null===(c=this._monitor)||void 0===c||c.report("rtc_first_frame",p),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("video","login"),null!==(r=this._stream)&&void 0!==r&&r.audioTrack&&this.beginSendFrame("audio","login");!e&&this._audioSending&&this.stopSendFrame("audio","leave_room"),!e&&this._videoSending&&this.stopSendFrame("video","leave_room")}}},{key:"setPublish",value:function(e){if(this._publish!==e){var t,r,n,i;if(this._publish=e,e)(null===(t=this._stream)||void 0===t?void 0:t.videoTrack)&&(null===(r=this._stream)||void 0===r?void 0:r.pubVideo)&&this.beginSendFrame("video","publish"),(null===(n=this._stream)||void 0===n?void 0:n.audioTrack)&&(null===(i=this._stream)||void 0===i?void 0:i.pubAudio)&&this.beginSendFrame("audio","publish");!e&&this._audioSending&&this.stopSendFrame("audio","unpublish"),!e&&this._videoSending&&this.stopSendFrame("video","unpublish")}}},{key:"setUnmuteAudio",value:function(e){var t;this._unMuteAudio!==e&&(this._unMuteAudio=e,null!==(t=this._stream)&&void 0!==t&&t.audioHasCapture&&(e&&this.beginSendFrame("audio","unmute"),!e&&this._audioSending&&this.stopSendFrame("audio","mute")))}},{key:"setEnableAudio",value:function(e){var t;this._enableAudio!==e&&null!==(t=this._stream)&&void 0!==t&&t.pubAudio&&(this._enableAudio=e,e&&this.beginSendFrame("audio","enable"),!e&&this._audioSending&&this.stopSendFrame("audio","disable"))}},{key:"setUnmuteVideo",value:function(e){var t;this._unMuteVideo!==e&&(this._unMuteVideo=e,null!==(t=this._stream)&&void 0!==t&&t.videoHasCapture&&(e&&this.beginSendFrame("video","unmute"),!e&&this._videoSending&&this.stopSendFrame("video","mute")))}},{key:"setEnableVideo",value:function(e){var t;this._enableVideo!==e&&null!==(t=this._stream)&&void 0!==t&&t.pubVideo&&(this._enableVideo=e,e&&this.beginSendFrame("video","enable"),!e&&this._videoSending&&this.stopSendFrame("video","disable"))}},{key:"setExternalAudioSource",value:function(e){this._audioExternal!==e&&(this._audioExternal=e,e&&(this._audioSending&&this.stopSendFrame("audio","disable"),this._enableAudio=!1),e||(this._audioSending&&this.stopSendFrame("audio","stop_push"),this._pushAudio=!1))}},{key:"setPushAudio",value:function(e){this._pushAudio!==e&&(this._pushAudio=e,e&&this.beginSendFrame("audio","push"),!e&&this._audioSending&&this.stopSendFrame("audio","stop_push"))}},{key:"setExternalVideoSource",value:function(e){this._videoExternal!==e&&(this._videoExternal=e,e&&(this._videoSending&&this.stopSendFrame("video","disable"),this._enableVideo=!1),e||(this._videoSending&&this.stopSendFrame("video","stop_push"),this._pushVideo=!1))}},{key:"setPushVideo",value:function(e){this._pushVideo!==e&&(this._pushVideo=e,e&&this.beginSendFrame("video","push"),!e&&this._videoSending&&this.stopSendFrame("video","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("audio","audience"),!e&&this._videoSending&&this.stopSendFrame("video","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("preprocessing")){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("preprocessing"));case 3:return s=e.sent,c=filter3(s).call(s,(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;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.getTrack("preprocessing")){e.next=5;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.getTrack("preprocessing"));case 3:return s=e.sent,e.abrupt("return",find$2(s).call(s,(function(e){return"outbound-rtp"===e.type})));case 5: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.clearInterval(this._firstVideoFrameInterval),this._firstVideoFrameInterval=window.setInterval(_asyncToGenerator(_regeneratorRuntime().mark((function n(){var i,o,a;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,o=0,a=0,null==i||map$6(i).call(i,(function(e){o+=e.framesSent,a+=e.packetsSent})),!(i&&i.length>0&&(o>t||a>r))){n.next=12;break}if(-1!==t||-1!==r){n.next=10;break}return t=o,r=a,n.abrupt("return");case 10:e.sendFrameFinish("video"),window.clearInterval(e._firstVideoFrameInterval);case 12:case"end":return n.stop()}}),n)}))),100)}},{key:"_watchForFirstAudioFrameSend",value:function(){var e=this,t=-1;this._firstAudioFrameInterval&&window.clearInterval(this._firstAudioFrameInterval),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("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:"login"},this._currentVideoSend={startTime:0,eventSessionId:0,type:"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 map2),_defineProperty(this,"_preDownlinkStats",new map2),_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,o,a=n?"screen_audio":"audio",s=t.rtt,c=t._fractionLost,l=t._retransmittedRate,u=this._getQosLevel(s,c||0,l||0),d=this._preUplinkStats.get(a)||[u];this._preUplinkStats.set(a,slice$1(i=concat$2(o=[]).call(o,_toConsumableArray(d),[u])).call(i,-2))}if(r.sentKBitrate>0&&r.rtt){var p,_,h=n?"screen_video":"video",f=r._fractionLost,m=r.rtt,v=r._sendBandWidth,g=r._retransmittedRate;0===v&&(f=Math.max(.65,f));var y=this._getQosLevel(m,f||0,g||0),S=this._preUplinkStats.get(h)||[y];this._preUplinkStats.set(h,slice$1(p=concat$2(_=[]).call(_,_toConsumableArray(S),[y])).call(p,-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,l=e.isScreen,u=e.userId;if(o)if(0===s.receivedKBitrate)r=NetworkQuality.VBAD;else{var d=s.rtt,p=s.audioLossRate,_=s.stallDuration,h=s.statsInterval,f=s.e2eDelay,m=_/h,v=l?"screen_audio":"audio",g=this._getQosLevel(d,p||0,c._retransmittedRate||0),y=this._getDownlinkQoE(v,m,f);r=this._getNetworkQuality(g,y)}if(a)if(0===c.receivedKBitrate||0===c.rtt)n=NetworkQuality.VBAD;else{var S=c.rtt,T=c.videoLossRate,$=c.stallDuration,E=c.statsInterval,b=c.e2eDelay,I=c._retransmittedRate,R=$/E,C=l?"screen_video":"video",A=this._getQosLevel(S,T||0,I||0),k=this._getDownlinkQoE(C,R,b);n=this._getNetworkQuality(A,k)}var P=r&&n?Math.ceil((r+n)/2):r||n;if(P){var O,w,M,D=concat$2(O="".concat(u)).call(O,l?"_screen":""),x=this._preDownlinkStats.get(D)||[P];this._preDownlinkStats.set(D,slice$1(w=concat$2(M=[]).call(M,_toConsumableArray(x),[P])).call(w,-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,i,o,a=this._getBetterQualityAndRemoveOldest("audio","up"),s=this._getBetterQualityAndRemoveOldest("video","up");e=a&&s?Math.ceil((a+s)/2):a||s||this._getBetterQualityAndRemoveOldest("screen_video","up")||this._getBetterQualityAndRemoveOldest("screen_audio","up")||NetworkQuality.EXCELLENT;var c=filter3(n=map$6(i=from$2(keys$1(o=this._preDownlinkStats).call(o))).call(i,(function(e){return r._getBetterQualityAndRemoveOldest(e,"down")}))).call(n,(function(e){return e}));t=Math.ceil(reduce3(c).call(c,(function(e,t){return t+e}),0)/c.length)||NetworkQuality.UNKNOWN}"function"==typeof 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||e<=250)&&t<=.15?1:(!e||e<=500)&&t<=.3?2:(!e||e<=750)&&t<=.45?3:(!e||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=filter3(i).call(i,(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]||{},l=c.width,u=void 0===l?0:l,d=c.height,p=void 0===d?0:d,_=a.getSettings(),h=_.width,f=void 0===h?0:h,m=_.height,v=void 0===m?0:m;p===v&&u===f||"function"==typeof e.onchange&&e.onchange(i,n.isScreen,f,v),delete s[i],(n.isScreen?r:t)[i]={width:f,height:v}}}))})),keys$8(e._remoteVideoSizeCache).forEach((function(t){"function"==typeof e.onchange&&e.onchange(t,!1,0,0)})),keys$8(e._remoteScreenSizeCache).forEach((function(t){"function"==typeof e.onchange&&e.onchange(t,!0,0,0)})),e._remoteVideoSizeCache=t,e._remoteScreenSizeCache=r}),1e3))}}]),e}(),SUBTITLE_PREFIX=from$2((new TextEncoder).encode("subt")),ERROR_CODE_MAP={1:ErrorCode.SUBTITLE_ERR_POSTPROCESS,2:ErrorCode.SUBTITLE_ERR_CONNECTION_ERROR,3:ErrorCode.SUBTITLE_ERR_PROCESS_ERROR},logger$7=new Logger("SubtitleTool",1),checkSourceLanguage=function(e){if(e.extraInfo)try{var t,r=JSON.parse(e.extraInfo);r.source_language&&indexOf2(t=["zh","en","ja"]).call(t,r.source_language)}catch(e){}else{var n,i,o=(null===(n=navigator.language)||void 0===n?void 0:n.substring(0,2))||"";indexOf2(i=["zh","en","ja"]).call(i,o)>-1&&(e.extraInfo=stringify$1({source_language:o}))}},SubtitleTool=function(){function e(t){var r,n,i;_classCallCheck(this,e),_defineProperty(this,"_taskId",void 0),_defineProperty(this,"_appId",void 0),_defineProperty(this,"_roomId",void 0),_defineProperty(this,"_userId",void 0),_defineProperty(this,"onEvent",void 0),_defineProperty(this,"onMessage",void 0),_defineProperty(this,"_preConfig",void 0),_defineProperty(this,"_timer",void 0),this._room=t,this._appId=null===(r=this._room._roomInfo)||void 0===r?void 0:r.appId,this._roomId=null===(n=this._room._roomInfo)||void 0===n?void 0:n.roomId,this._userId=null===(i=this._room._roomInfo)||void 0===i?void 0:i.userInfo.userId}var t,r,n;return _createClass(e,[{key:"start",value:(n=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){var r=this;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(logger$7.print("start","Invoke config: %o",t),checkEnum(t.mode,"mode",[SUBTITLE_MODE.ASR_ONLY,SUBTITLE_MODE.ASR_AND_TRANSLATION]),t.mode!==SUBTITLE_MODE.ASR_AND_TRANSLATION||-1!==indexOf2(SUPPORT_LANG).call(SUPPORT_LANG,t.targetLanguage||"")){e.next=4;break}throw new SDKError(ErrorCode.INVALID_PARAMS,"Invalid targetLanguage.");case 4:if(!this._taskId){e.next=6;break}throw new SDKError(ErrorCode.SUBTITLE_ALREADY_ON,"Already turned on subtitle");case 6:return this._preConfig=t,this._taskId=(Date.now().toString()+this._roomId+this._userId).substring(0,20),e.next=10,this._room.subtitleControlMessage(this._genSubtitleSignaling("started",t,this._taskId));case 10:this._preConfig=t,this._timer=self.setTimeout((function(){var e;null===(e=r.onEvent)||void 0===e||e.call(r,{event:SubtitleEventType.ERROR,errorCode:ErrorCode.TIME_OUT,errorMessage:"start subtitle timeout."}),delete r._timer,r.stop()}),3e4);case 12:case"end":return e.stop()}}),e,this)}))),function(e){return n.apply(this,arguments)})},{key:"update",value:(r=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){var r;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(checkEnum(t.mode,"mode",[SUBTITLE_MODE.ASR_ONLY,SUBTITLE_MODE.ASR_AND_TRANSLATION]),t.mode!==SUBTITLE_MODE.ASR_AND_TRANSLATION||-1!==indexOf2(SUPPORT_LANG).call(SUPPORT_LANG,t.targetLanguage||"")){e.next=3;break}throw new SDKError(ErrorCode.INVALID_PARAMS,"Invalid targetLanguage.");case 3:if(!this._taskId){e.next=5;break}throw new SDKError(ErrorCode.SUBTITLE_ALREADY_ON,"Already started subtitle");case 5:if(this._taskId){e.next=7;break}throw new SDKError(ErrorCode.SUBTITLE_NOT_TURNED_ON,"Start subtitle first.");case 7:if((null===(r=this._preConfig)||void 0===r?void 0:r.mode)===t.mode&&this._preConfig.targetLanguage===t.targetLanguage){e.next=11;break}return this._preConfig=t,e.next=11,this._room.subtitleControlMessage(this._genSubtitleSignaling("update",t,this._taskId));case 11:case"end":return e.stop()}}),e,this)}))),function(e){return r.apply(this,arguments)})},{key:"stop",value:function(){var e=this;logger$7.print("stop","Invoke"),this._taskId&&this._room.subtitleControlMessage({type:"subtitle",action:"stopped",appId:this._appId,roomId:this._roomId,userId:this._userId,taskId:this._taskId}).finally((function(){var t;delete e._taskId,null===(t=e.onEvent)||void 0===t||t.call(e,{event:SubtitleEventType.STOPPED}),e._clearTimer()}))}},{key:"reconnect",value:(t=_asyncToGenerator(_regeneratorRuntime().mark((function e(){return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._taskId||!this._preConfig){e.next=5;break}return e.next=3,this._room.subtitleControlMessage({type:"subtitle",action:"stopped",appId:this._appId,roomId:this._roomId,userId:this._userId,taskId:this._taskId});case 3:delete this._taskId,this.start(this._preConfig);case 5:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})},{key:"getConfig",value:function(){return this._preConfig}},{key:"destroy",value:function(){logger$7.print("destroy","Invoke"),this.stop(),delete this._preConfig,delete this._taskId}},{key:"onResult",value:function(e){var t=e.body,r=t.error,n=t.errorMessage,i=t.eventType;if(0!==r){var o,a=new SDKError(ERROR_CODE_MAP[r]||ErrorCode.SUBTITLE_ERR_UNKNOWN,n||"");null===(o=this.onEvent)||void 0===o||o.call(this,{event:SubtitleEventType.ERROR,errorCode:a.code,errorMessage:a.message}),this._clearTimer()}else if("SubtitleStarted"===i){var s;null===(s=this.onEvent)||void 0===s||s.call(this,{event:SubtitleEventType.STARTED}),this._clearTimer()}}},{key:"onMessageRecv",value:function(e){if(this._taskId&&this._preConfig){var t=parseSubtitleMessage(e);if(t&&t.length>0){var r,n=this._preConfig,i=n.mode,o=n.targetLanguage,a=[];if(t.forEach((function(e){i===SUBTITLE_MODE.ASR_ONLY?e.mode===i&&a.push(e):i===SUBTITLE_MODE.ASR_AND_TRANSLATION&&(e.language!==o&&e.mode!==SUBTITLE_MODE.ASR_ONLY||a.push(e),e.mode===SUBTITLE_MODE.ASR_ONLY&&e.language===o&&a.push(_objectSpread2(_objectSpread2({},e),{},{mode:SUBTITLE_MODE.ASR_AND_TRANSLATION})))})),a.length>0)null===(r=this.onMessage)||void 0===r||r.call(this,a)}return!!t}return!1}},{key:"_genSubtitleSignaling",value:function(e,t,r){return{taskId:r,type:"subtitle",action:e,roomId:this._roomId,appId:this._appId,userId:this._userId,subtitleMeta:{subtitleConfig:{mode:t.mode,usersConfig:[{userId:this._userId,targetLanguages:[t.targetLanguage||""]}]},vendorConfig:{type:0}}}}},{key:"_clearTimer",value:function(){this._timer&&(self.clearTimeout(this._timer),delete this._timer)}}]),e}(),parseSubtitleMessage=function(e){var t=e.message;if(t instanceof ArrayBuffer&&t.byteLength>8)try{var r=new DataView(t,0),n=0;if(SUBTITLE_PREFIX.every((function(e){return r.getUint8(n++)===e}))){var i=r.getUint32(n);if(n+=4,i===r.byteLength-8){var o=Utils.ab2str(slice$1(t).call(t,8)),a=JSON.parse(o),s=a.data;if("subtitle"===a.type)return s}}}catch(e){}return!1},SUPPORT_LANG=["zh","zh-Hant","tn","vi","iu","it","id","hi","en","ho","he","es","el","uk","ur","tk","tr","ti","ty","tl","to","th","ta","te","sl","sk","ss","eo","sm","sg","st","sv","ja","tw","qu","pt","pa","no","nb","nr","my","bn","mn","mh","mk","ml","mr","ms","lu","ro","lt","lv","lo","kj","hr","kn","ki","cs","ca","nl","ko","ht","gu","ka","kl","km","lg","kg","fi","fj","fr","ru","ng","de","tt","da","ts","cv","fa","bs","pl","bi","nd","ba","bg","az","ar","af","sq","ab","os","ee","et","ay","lzh","am","ckb","cy","gl","ha","hy","ig","kmr","ln","nso","ny","om","sn","so","sr","sw","xh","yo","zu"],logger$6=new Logger("Room",1),virtualStreamAttributes={audiostream:!0,extaudio:!1,extvideo:!1,localaudio:!0,localvideo:!1,videoDescriptions:[],videostream:!1,publishTime:0},Room=function(e){_inherits(R,EnhancedEventEmitter);var t,r,n,i,o,a,s,c,l,u,d,p,_,h,f,m,v,g,y,S,T,$,E,b,I=_createSuper(R);function R(e,t){var r;return _classCallCheck(this,R),_defineProperty(_assertThisInitialized(r=I.call(this)),"id",void 0),_defineProperty(_assertThisInitialized(r),"_mediaServerClient",void 0),_defineProperty(_assertThisInitialized(r),"_localStream",void 0),_defineProperty(_assertThisInitialized(r),"_localScreenStream",void 0),_defineProperty(_assertThisInitialized(r),"_remoteUsers",new map2),_defineProperty(_assertThisInitialized(r),"_remoteStreams",new map2),_defineProperty(_assertThisInitialized(r),"_remoteStreamStreamIdUserIdMap",{}),_defineProperty(_assertThisInitialized(r),"_virtualStreams",[]),_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),"_liveTranscodingOnceSucc",!1),_defineProperty(_assertThisInitialized(r),"_roomConfig",void 0),_defineProperty(_assertThisInitialized(r),"_roomInfo",void 0),_defineProperty(_assertThisInitialized(r),"_userDuplicateLoginTimerMap",new map2),_defineProperty(_assertThisInitialized(r),"_networkQualityManager",void 0),_defineProperty(_assertThisInitialized(r),"_videoSizeObserver",void 0),_defineProperty(_assertThisInitialized(r),"_hasPublished",!1),_defineProperty(_assertThisInitialized(r),"_subtitleTool",void 0),_defineProperty(_assertThisInitialized(r),"_csrcUserIdMap",void 0),_defineProperty(_assertThisInitialized(r),"_publishOnDemandItem",void 0),_defineProperty(_assertThisInitialized(r),"_publishOnDemandBusy",!1),_defineProperty(_assertThisInitialized(r),"_monitor",void 0),r.id=t.id,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._context=t,r._csrcUserIdMap={},r._monitor=getMonitor(r.id),r}return _createClass(R,[{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:"roomConfig",set:function(e){this._roomConfig=e}},{key:"_addHandlerEventHandler",value:function(){var e,t,r,n,i,o,a,s,c,l,u,d,p,_,h,f,m,v,g,y,S,T,$,E,b,I,R,C,A,k,P=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_ADD_STREAM_LIST,(function(e){Array.isArray(null==e?void 0:e.streamList)&&e.streamList.forEach((function(e){return P._onAddStream(e)}))})),null===(r=this._mediaServerClient)||void 0===r||r.on(SignalEvent.ON_REMOVE_STREAM,this._onRemoveStream.bind(this)),null===(n=this._mediaServerClient)||void 0===n||n.on(SignalEvent.ON_REMOVE_STREAM_LIST,(function(e){Array.isArray(null==e?void 0:e.streamList)&&e.streamList.forEach((function(e){return P._onRemoveStream(e)}))})),null===(i=this._mediaServerClient)||void 0===i||i.on(SignalEvent.USER_CONNECTION,this._onUserConnection.bind(this)),null===(o=this._mediaServerClient)||void 0===o||o.on(SignalEvent.USER_CONNECTION_LIST,(function(e){Array.isArray(null==e?void 0:e.userList)&&e.userList.forEach((function(e){return P._onUserConnection(e)}))})),null===(a=this._mediaServerClient)||void 0===a||a.on(SignalEvent.USER_DISCONNECTION,this._onUserDisconnection.bind(this)),null===(s=this._mediaServerClient)||void 0===s||s.on(SignalEvent.USER_DISCONNECTION_LIST,(function(e){Array.isArray(null==e?void 0:e.userList)&&e.userList.forEach((function(e){return P._onUserDisconnection(e)}))})),null===(c=this._mediaServerClient)||void 0===c||c.on(SignalEvent.ON_UPDATE_ROOM_ATTRIBUTES,this._onUpdateRoomAttributes.bind(this)),null===(l=this._mediaServerClient)||void 0===l||l.on(SignalEvent.ON_UPDATE_USER_ATTRIBUTES,this._onUpdateUserAttributes.bind(this)),null===(u=this._mediaServerClient)||void 0===u||u.on(SignalEvent.ON_UPDATE_STREAM_ATTRIBUTES,this._onUpdateStreamAttributes.bind(this)),null===(d=this._mediaServerClient)||void 0===d||d.on(SignalEvent.ON_PUSH_TRACK,this._onPushTrack.bind(this)),null===(p=this._mediaServerClient)||void 0===p||p.on(SignalEvent.ON_REMOVE_TRACK,this._onRemoveTrack.bind(this)),null===(_=this._mediaServerClient)||void 0===_||_.on(SignalEvent.NODE_CHANGE,this._nodeChange.bind(this)),null===(h=this._mediaServerClient)||void 0===h||h.on(SignalEvent.ON_CUSTOM_MESSAGE,this._onCustomMessage.bind(this)),null===(f=this._mediaServerClient)||void 0===f||f.on(SignalEvent.USER_MESSAGE_RECEIVED,this._onUserMessageReceived.bind(this)),null===(m=this._mediaServerClient)||void 0===m||m.on(SignalEvent.USER_BINARY_MESSAGE_RECEIVED,this._onUserBinaryMessageReceived.bind(this)),null===(v=this._mediaServerClient)||void 0===v||v.on(SignalEvent.POST_PROCESSING_MESSAGE,this._onPostProcessingMessage.bind(this)),null===(g=this._mediaServerClient)||void 0===g||g.on(SignalEvent.ON_USER_TOKEN_WILL_EXPIRE,this._onUserTokenWillExpire.bind(this)),null===(y=this._mediaServerClient)||void 0===y||y.on(SignalEvent.STREAM_CONTROL_MESSAGE,this._onStreamControlMessage.bind(this)),null===(S=this._mediaServerClient)||void 0===S||S.on(SignalEvent.ON_STREAM_FAILED,this._onStreamFailed.bind(this)),null===(T=this._mediaServerClient)||void 0===T||T.on(MediaServerSignalEvent.RSCP,(function(e){!!find$2(e).call(e,(function(e){var t,r,n;return null==e||null===(t=e.StreamIds)||void 0===t?void 0:includes4(t).call(t,null===(r=P._localStream)||void 0===r||null===(n=r.stream)||void 0===n?void 0:n.id)}))&&(P._publishOnDemandItem=e,P._onPublishOnDemand())})),null===($=this._mediaServerClient)||void 0===$||$.on(MediaServerSignalEvent.RTT,this._onRTT.bind(this)),null===(E=this._mediaServerClient)||void 0===E||E.on(MediaServerSignalEvent.SSC,this._onSSC.bind(this)),null===(b=this._mediaServerClient)||void 0===b||b.on(StateEvent.ON_CONNECTION_STATE_CHANGE,this._onConnectionStateChange.bind(this)),null===(I=this._mediaServerClient)||void 0===I||I.on(StateEvent.ABNORMAL_DISCONNECTION,this._handleAbnormalDisconnection.bind(this)),null===(R=this._mediaServerClient)||void 0===R||R.on(SignalEvent.ON_SPEAKER_CHANGE,this._onMeetingSpeakerChange.bind(this)),null===(C=this._mediaServerClient)||void 0===C||C.on("onRemoteStreamStats",(function(e){P._networkQualityManager.updateDownlinkStats(e,P._findRemoteStreamByScreen(e.userId,e.isScreen)),P.emit(RoomEvent.ON_REMOTE_STREAM_STATS,getPublicStats(e))})),null===(A=this._mediaServerClient)||void 0===A||A.on("onLocalStreamStats",(function(e){P._networkQualityManager.updateUplinkStats(e),P.emit(RoomEvent.ON_LOCAL_STREAM_STATS,getPublicStats(e))})),null===(k=this._mediaServerClient)||void 0===k||k.on("prevIceNode",(function(e){P._getAccessFeedbackIceNode=e}))}},{key:"_removeHandlerEventHandler",value:function(){var e;null===(e=this._mediaServerClient)||void 0===e||e.removeAllListeners()}},{key:"connect",value:(b=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._mediaServerClient.connect(t);case 2:case"end":return e.stop()}}),e,this)}))),function(e){return b.apply(this,arguments)})},{key:"join",value:(E=_asyncToGenerator(_regeneratorRuntime().mark((function e(t,r,n,i,o,a,s){var c,l=this;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return null===(c=this._monitor)||void 0===c||c.set({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,d,p,_=getServerNow();l._joinResolveCallback=function(t){var r,n;null===(r=l._monitor)||void 0===r||r.report("join_room",{type:"end",start:_,result:!0,reason:""},{enable_cloud_proxy:null===(n=l._roomInfo)||void 0===n?void 0:n.useCloudProxy}),l._initSubtitleTool(),e(t)},l._joinRejectCallback=function(e){var t,r;Array.isArray(e)&&e.length&&(e=e[0]),null===(t=l._monitor)||void 0===t||t.report("join_room",{type:"end",start:_,result:!1,reason:e.message},{enable_cloud_proxy:null===(r=l._roomInfo)||void 0===r?void 0:r.useCloudProxy}),c(e)},l._liveControlMessage=o,l._roomInfo={appId:t,roomId:r,token:n,userInfo:i,useCloudProxy:a,roomProfile:l._roomConfig.roomProfileType,expectedIDC:s},l.setSessionId(),null===(u=l._monitor)||void 0===u||u.report("join_room",{type:"begin",start:_,result:!1,reason:""},{enable_cloud_proxy:null===(d=l._roomInfo)||void 0===d?void 0:d.useCloudProxy,expectedIDC:null===(p=l._roomInfo)||void 0===p?void 0:p.expectedIDC}),l._join(l._joinResolveCallback,l._joinRejectCallback,!1)})));case 3:case"end":return e.stop()}}),e,this)}))),function(e,t,r,n,i,o,a){return E.apply(this,arguments)})},{key:"_join",value:($=_asyncToGenerator(_regeneratorRuntime().mark((function e(t,r){var n,i,o,a,s,c,l,u,d=arguments;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=d.length>2&&void 0!==d[2]&&d[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:u=e.sent,this._mediaServerClient.roomAttributes=u.roomAttributes,null!==(o=u.roomAttributes)&&void 0!==o&&o.multiChatMode&&this._handleFFAudioTrack(),this._reconnectRecord.clear(),this._joinResolveCallback=void 0,this._joinRejectCallback=void 0,this._getAccessFeedback=void 0,this._getAccessNode=void 0,"function"==typeof t&&t({users:u.clients,streams:u.streams}),this._isReconnecting=!1,null===(a=this._monitor)||void 0===a||a.set({rtc_vid:(null===(s=this._getAccessFeedbackIceNode)||void 0===s||null===(c=s.iceConfig)||void 0===c?void 0:c._abtest_vid)||""}),null===(l=this._monitor)||void 0===l||l.report("rtc_join_room",{error_code:0,deviceModel:"web",deviceManufacturer:"web",elapse:getServerNow()-i}),this._onJoinSucc(u,n),e.next=27;break;case 21:if(e.prev=21,e.t0=e.catch(3),this._getAccessFeedback=void 0,this._getAccessNode=void 0,e.t0.code===ErrorCode.OPERATION_CANCEL||"function"!=typeof r){e.next=27;break}return e.abrupt("return",r(e.t0));case 27:case"end":return e.stop()}}),e,this,[[3,21]])}))),function(e,t){return $.apply(this,arguments)})},{key:"publishScreen",value:(T=_asyncToGenerator(_regeneratorRuntime().mark((function e(t,r,n,i,o){var a,s,c,l,u,d,p,_,h,f;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.id),this._localScreenStream.isScreen=!0,this._mediaServerClient.handler&&(this._localScreenStream.observer=new SendFrameObserver(this._localScreenStream,this._mediaServerClient.handler))),a=!1,s=!1,c=!1,l=!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&&(l=!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===(u=this._localScreenStream)||void 0===u||!u.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),l?null===(h=this._localScreenStream.observer)||void 0===h||h.setPushAudio(c):null===(f=this._localScreenStream.observer)||void 0===f||f.setEnableAudio(c),e.next=28,this.updatePubScreenTrack();case 28:case"end":return e.stop()}}),e,this)}))),function(e,t,r,n,i){return T.apply(this,arguments)})},{key:"updatePubScreenTrack",value:(S=_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 S.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:(g=_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,this._liveTranscodingOnceSucc=!1),this._liveTranscodingOnceSucc=!0;case 7:case"end":return e.stop()}}),e,this)}))),function(e){return g.apply(this,arguments)})},{key:"publicStreamControlMessage",value:(v=_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 v.apply(this,arguments)})},{key:"subtitleControlMessage",value:(m=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._mediaServerClient.controlMessage(t);case 2:case"end":return e.stop()}}),e,this)}))),function(e){return m.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:(h=_asyncToGenerator(_regeneratorRuntime().mark((function e(t,r,n,i,o,a){var s,c,l,u,d,p,_,h,f,m,v,g,y=arguments;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(s=y.length>6&&void 0!==y[6]&&y[6],logger$6.print("publish","Invoke publish"),c=!1,this._localStream||(this._localStream=new LocalStream(this.id),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===(l=this._localStream.observer)||void 0===l||l.setLogin(!0):c&&(u=!!this._localStream.videoTrack,d=!!this._localStream.audioTrack,p=this._localStream.videoTrack instanceof CustomVideoLocalTrack,_=this._localStream.audioTrack instanceof CustomAudioLocalTrack,this._roomConfig.isAutoPublish&&!this._hasPublished?(u&&(p?null===(h=this._localStream.observer)||void 0===h||h.setPushVideo(!0):null===(f=this._localStream.observer)||void 0===f||f.setEnableVideo(!0)),d&&(_?null===(m=this._localStream.observer)||void 0===m||m.setPushAudio(!0):null===(v=this._localStream.observer)||void 0===v||v.setEnableAudio(!0))):null===(g=this._localStream.observer)||void 0===g||g.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 h.apply(this,arguments)})},{key:"updatePubTrack",value:(_=_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 _.apply(this,arguments)})},{key:"unpublish",value:(p=_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 p.apply(this,arguments)})},{key:"subscribe",value:(d=_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 d.apply(this,arguments)})},{key:"updateSubTrack",value:(u=_asyncToGenerator(_regeneratorRuntime().mark((function e(t,r,n,i){var o,a;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(logger$6.print("updateSubTrack","Invoke updateSubTrack"),!i){e.next=4;break}return e.next=4,null===(a=this._mediaServerClient)||void 0===a?void 0:a.updateSubTrackLayer(t,i);case 4:return e.abrupt("return",null===(o=this._mediaServerClient)||void 0===o?void 0:o.updateSubTrack(t,r,n));case 5:case"end":return e.stop()}}),e,this)}))),function(e,t,r,n){return u.apply(this,arguments)})},{key:"updateSubVideoConfig",value:(l=_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.updateSubTrackLayer(a,s));case 6:case"end":return e.stop()}}),e,this)}))),function(e,t){return l.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,l=s.subVideoDescriptions,u=Array.isArray(l)?l:c,d=-1,p=e.width*e.height,_=0;_<(null==u?void 0:u.length);_++){var h,f;if(p>=(null===(h=u[_])||void 0===h?void 0:h.width)*(null===(f=u[_])||void 0===f?void 0:f.height)){d=_;break}}var m=u[0];if(-1===d)m=u[d=u.length-1];else if(0!==d){var v=u[d-1].width*u[d-1].height,g=(v-p)/(v-u[d].width*u[d].height);m=g<.1?u[d-1]:u[d],d=g<.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:(c=_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 c.apply(this,arguments)})},{key:"startSubtitle",value:(s=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._subtitleTool){e.next=5;break}return e.next=3,this._subtitleTool.start(t);case 3:e.next=6;break;case 5:throw new SDKError(ErrorCode.INVOKED_BEFORE_JOIN_ROOM,"join first");case 6:case"end":return e.stop()}}),e,this)}))),function(e){return s.apply(this,arguments)})},{key:"stopSubtitle",value:(a=_asyncToGenerator(_regeneratorRuntime().mark((function e(){var t;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:null===(t=this._subtitleTool)||void 0===t||t.stop();case 1:case"end":return e.stop()}}),e,this)}))),function(){return a.apply(this,arguments)})},{key:"leave",value:(o=_asyncToGenerator(_regeneratorRuntime().mark((function e(){var t,r,n,i,o,a,s,c,l,u,d,p=arguments;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:r=p.length>0&&void 0!==p[0]&&p[0],logger$6.print("leave","Invoke leave"),n=getServerNow(),null===(t=this._subtitleTool)||void 0===t||t.destroy(),delete this._subtitleTool,e.prev=5,this._mediaServerClient.connectionState!==MediaConnectionState.CONNECTED&&this._joinRejectCallback&&this._joinRejectCallback(new Error("leave_room")),clearTimeout(this._reconnectTimer),s=_createForOfIteratorHelper(values$1(a=this._remoteStreams).call(a));try{for(s.s();!(c=s.n()).done;)l=c.value,Array.isArray(l)&&l.forEach((function(e){var t;null===(t=e.observer)||void 0===t||t.setLogin(!1)}))}catch(e){s.e(e)}finally{s.f()}return this._localStream&&(null===(u=this._localStream.observer)||void 0===u||u.setLogin(!1)),e.next=13,this._mediaServerClient.leave();case 13:this.destroy(),null===(i=this._monitor)||void 0===i||i.report("rtc_leave_room",{error_code:0,message:"",elapse:getServerNow()-n}),null===(o=this._monitor)||void 0===o||o.set({room_id:"",user_id:"",rtc_session_id:"",rtc_vid:""}),e.next=26;break;case 18:if(e.prev=18,e.t0=e.catch(5),!r){e.next=24;break}throw e.t0;case 24:this.destroy();case 25:e.t0 instanceof Error&&(null===(d=this._monitor)||void 0===d||d.report("rtc_leave_room",{error_code:-1,message:e.t0.message,elapse:getServerNow()-n}));case 26:case"end":return e.stop()}}),e,this,[[5,18]])}))),function(){return o.apply(this,arguments)})},{key:"updateRemoteUserPriority",value:function(e){var t,r=this;null===(t=this.remoteStreams.get(e))||void 0===t||t.forEach((function(t){var n=(r._context||{}).userPriority;t.hasSubscribed&&null!=n&&n.has(e)&&r._mediaServerClient.updateSubPriority(t,n.get(e))}))}},{key:"destroy",value:function(){var e;logger$6.print("destroy","Invoke destroy"),reportRtcInvokeStatus(this.id,"room_destroy","".concat((new Error).stack)),null===(e=this._subtitleTool)||void 0===e||e.destroy(),delete this._subtitleTool,this._destroyAndInitMediaServerClient(),this._roomInfo=void 0,this._remoteUsers=new map2;var t,r,n,i=_createForOfIteratorHelper(this._remoteStreams);try{for(i.s();!(t=i.n()).done;){var o=_slicedToArray(t.value,2)[1];Array.isArray(o)&&o.forEach((function(e){e&&e.clean()}))}}catch(e){i.e(e)}finally{i.f()}(this._virtualStreams.forEach((function(e){null==e||e.clean()})),this._remoteStreams=new map2,this._localStream)&&(null===(r=this._localStream)||void 0===r||r.clean(),this._localStream=void 0);this._localScreenStream&&(null===(n=this._localScreenStream)||void 0===n||n.clean(),this._localScreenStream=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._csrcUserIdMap={},this._virtualStreams=[],this._remoteStreamStreamIdUserIdMap={}}},{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.prev=2,e.next=5,this._mediaServerClient.updateToken(t);case 5:e.next=11;break;case 7:throw e.prev=7,e.t0=e.catch(2),this.safeEmit(RoomEvent.ON_ROOM_ERROR,{errorCode:ErrorCode.UPDATE_TOKEN_WITH_INVALID_TOKEN}),e.t0;case 11:case"end":return e.stop()}}),e,this,[[2,7]])}))),function(e){return i.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(){var e;this._sessionId=v4(),null===(e=this._monitor)||void 0===e||e.set({rtc_session_id:this._sessionId})}},{key:"sendRoomMessage",value:(n=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){var r,n,i,o,a,s=arguments;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(o=s.length>1&&void 0!==s[1]&&s[1],a={clientId:null===(r=this._roomInfo)||void 0===r?void 0:r.userInfo.userId,binary:o,message:"",roomId:null===(n=this._roomInfo)||void 0===n?void 0:n.roomId},!o){e.next=8;break}return e.next=5,Utils.ab2b64str(t);case 5:a.message=e.sent,e.next=9;break;case 8:a.message=t;case 9:return e.abrupt("return",null===(i=this._mediaServerClient)||void 0===i?void 0:i.sendRoomMessage(a));case 10:case"end":return e.stop()}}),e,this)}))),function(e){return n.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,i,o=this;logger$6.print("JoinSuccess()"),this._serverConfig=e.config;var a=[],s=[],c=[],l=[],u=[];null===(r=e.clientsDetail)||void 0===r||r.forEach((function(t){if(t.attributes&&(t.attributes.serverMuteVideo&&o.safeEmit(RoomEvent.ON_VIDEO_STREAM_BANNED,{uid:t.clientId,banned:1===t.attributes.serverMuteVideo}),t.attributes.serverMuteAudio&&o.safeEmit(RoomEvent.ON_AUDIO_STREAM_BANNED,{uid:t.clientId,banned:1===t.attributes.serverMuteAudio})),t.clientId!==e.clientId){var r=o._remoteUsers.get(t.clientId);r?r._stillExist=!0:a.push(t)}}));var d,p=_createForOfIteratorHelper(values$1(n=this._remoteUsers).call(n));try{for(p.s();!(d=p.n()).done;){var _=d.value;_._stillExist||s.push({clientId:_.userId}),delete _._stillExist}}catch(e){p.e(e)}finally{p.f()}e.streams.forEach((function(e){var t=o._findRemoteStreamByScreen(e.clientId,e.screen);t?(t.stillExist=!0,t.streamId=e.streamId,u.push(e)):l.push(e)}));var h,f=_createForOfIteratorHelper(values$1(i=this._remoteStreams).call(i));try{for(f.s();!(h=f.n()).done;){var m=h.value;Array.isArray(m)&&m.forEach((function(e){e.stillExist?delete e.stillExist:c.push({clientId:e.userId,streamId:e.streamId,message:RemoveStreamMessage.clientDisconnected})}))}}catch(e){f.e(e)}finally{f.f()}s.forEach((function(e){return o._onUserDisconnection(e)})),a.forEach((function(e){return o._onUserConnection(e)})),c.forEach((function(e){return o._onRemoveStream(e)})),l.forEach((function(e){return o._onAddStream(e,{fromSignal:!1})})),u.forEach((function(e){return o._onUpdateStreamAttributes(e)})),t&&this._handleSendOrRecvStreamAfterReconnect()}},{key:"_handleSendOrRecvStreamAfterReconnect",value:function(){var e,t,r=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 n,i=_createForOfIteratorHelper(values$1(t=this._remoteStreams).call(t));try{for(i.s();!(n=i.n()).done;){var o=n.value;Array.isArray(o)&&o.forEach(function(){var e=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){var n,i,o,a;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!t.hasSubscribed){e.next=15;break}return t.resetHasSubscribed(),e.prev=2,logger$6.print(concat$2(n="start resubscribe ".concat(t.userId," with ")).call(n,t.subMediaType)),e.next=6,r._mediaServerClient.subscribe(t,t.subMediaType);case 6:logger$6.print(concat$2(i="success resubscribe ".concat(t.userId," with ")).call(i,t.subMediaType)),r.safeEmit(RoomEvent.RESUBSCRIBE,{stream:t}),e.next=15;break;case 10:e.prev=10,e.t0=e.catch(2),logger$6.print(concat$2(o=concat$2(a="failed resubscribe ".concat(t.userId," with ")).call(a,t.subMediaType,", error:")).call(o,e.t0)),t.clean(),null==t||t.resetHasSubscribed();case 15:case"end":return e.stop()}}),e,null,[[2,10]])})));return function(t){return e.apply(this,arguments)}}())}}catch(e){i.e(e)}finally{i.f()}null===(e=this._subtitleTool)||void 0===e||e.reconnect()}},{key:"_handleFFAudioTrack",value:function(){var e,t,r,n,i=null===(e=this._mediaServerClient)||void 0===e||null===(t=e.handler)||void 0===t?void 0:t.audioTrack4ff,o=null===(r=this._mediaServerClient)||void 0===r||null===(n=r.handler)||void 0===n?void 0:n.getTransceivers();if(i&&Array.isArray(o)){var a=find$2(o).call(o,(function(e){var t;return(null==e||null===(t=e.receiver)||void 0===t?void 0:t.track)===i}));if(a){var s=new RemoteStream(this.id,"ff-stream","ff-stream",!1,virtualStreamAttributes);s.virtual=!0,s.audioTransceiver=a,s.audioMid="0",s.audioTrack=createRemoteAudioTrack(i),this._virtualStreams.push(s),this.safeEmit(RoomEvent.SUBSCRIBE_PUSH_TRACK,{stream:s})}}}},{key:"_findRemoteStream",value:function(e,t){var r=this._remoteStreams.get(e);return Array.isArray(r)?find$2(r).call(r,(function(e){return e.streamId===t})):null}},{key:"_findRemoteStreamByScreen",value:function(e,t){var r=this._remoteStreams.get(e);return Array.isArray(r)?find$2(r).call(r,(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=r.needEmit,i=void 0===n||n,o=r.fromSignal,a=void 0===o||o,s=r.virtual,c=void 0!==s&&s;if(e.clientId!==(null===(t=this._roomInfo)||void 0===t?void 0:t.userInfo.userId)){var l=this._roomConfig,u=l.isAutoSubscribeAudio,d=l.isAutoSubscribeVideo,p=this._findRemoteStreamByScreen(e.clientId,e.screen);if(p&&p.streamId!==e.streamId){var _,h=null===(_=this._remoteStreams.get(e.clientId))||void 0===_?void 0:filter3(_).call(_,(function(e){return e.streamId!==p.streamId}));p.clean(),this._remoteStreams.set(e.clientId,h||[])}var f=this._findRemoteStream(e.clientId,e.streamId);if(this._remoteStreamStreamIdUserIdMap[e.streamId]=e.clientId,f)f.attributes=e.attributes;else if((f=new RemoteStream(this.id,e.clientId,e.streamId,e.screen,e.attributes)).virtual=c,this._initStreamListeners(f),!c){var m=this._remoteStreams.get(e.clientId);m?m.push(f):this._remoteStreams.set(e.clientId,[f])}if(this._mediaServerClient.handler&&(f.observer=new RecvFrameObserver(f,this._mediaServerClient.handler)),!f.isScreen&&d){var v,g,y,S,T,$,E,b;if(a&&f.hasVideo)if(f.attributes.extvideo)null===(v=f.observer)||void 0===v||v.setExternalVideoSource(!0),null===(g=f.observer)||void 0===g||g.setPushVideo(!0);else null===(y=f.observer)||void 0===y||y.setExternalVideoSource(!1),null===(S=f.observer)||void 0===S||S.setPublishVideo(!0);if(a&&f.hasAudio&&u&&!this._mediaServerClient.roomAttributes.multiChatMode)if(f.attributes.extaudio)null===(T=f.observer)||void 0===T||T.setExternalAudioSource(!0),null===($=f.observer)||void 0===$||$.setPushAudio(!0);else null===(E=f.observer)||void 0===E||E.setExternalAudioSource(!1),null===(b=f.observer)||void 0===b||b.setPublishAudio(!0);if(!0===i&&!1===a){var I,R=this._roomConfig,C=R.isAutoSubscribeAudio,A=R.isAutoSubscribeVideo;null===(I=f.observer)||void 0===I||I.setLogin(!0,{audio:!!C,video:!!A})}}return i&&this.safeEmit(SignalEvent.ON_ADD_STREAM,{stream:f}),f}}},{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,a=e.forbiddenTime;if(n)if(n===(null===(t=this.roomInfo)||void 0===t?void 0:t.userInfo.userId)){var s=null;i===UserDisconnectionTag.kickedByAdmin?s=ErrorCode.KICKED_OUT:i===UserDisconnectionTag.onUserTokenDidExpire?s=ErrorCode.TOKEN_EXPIRED:i===UserDisconnectionTag.userDuplicateLogin&&(s=ErrorCode.DUPLICATE_LOGIN),o===UserDisconnectionCode.roomDismissByAdmin&&(s=ErrorCode.ROOM_DISMISS),s&&this.safeEmit(RoomEvent.ON_ROOM_ERROR,{errorCode:s,forbiddenTime:a})}else{var c=UserOfflineReason.DROPPED;i===UserDisconnectionTag.userLeave?c=UserOfflineReason.QUIT:i===UserDisconnectionTag.kickedByAdmin?c=UserOfflineReason.KICKED_BY_ADMIN:i===UserDisconnectionTag.roleChanged&&(c=UserOfflineReason.SWITCH_TO_INVISIBLE);var l=function(){var e;r._remoteUsers.delete(n),null===(e=r._remoteStreams.get(n))||void 0===e||e.forEach((function(e){e.clean(),r._onRemoveStream({clientId:e.userId,streamId:e.streamId,message:RemoveStreamMessage.clientDisconnected})})),r._remoteStreams.delete(n),r.safeEmit(RoomEvent.ON_USER_LEAVE,{userInfo:{userId:n},reason:c})};if(i===UserDisconnectionTag.userDuplicateLogin){var u=this._userDuplicateLoginTimerMap.get(n);u&&self.clearTimeout(u);var d=self.setTimeout(l,5e3);this._userDuplicateLoginTimerMap.set(n,d)}else l()}}},{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=find$2(n).call(n,(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(){var t=r._remoteStreams.get(e.clientId);t&&(t=filter3(t).call(t,(function(t){return t.streamId!==e.streamId||(t.clean(),!1)})),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){var t;e.roomAttributes&&(this._mediaServerClient.roomAttributes=_objectSpread2(_objectSpread2({},this._mediaServerClient.roomAttributes),e.roomAttributes)),null!==(t=e.roomAttributes)&&void 0!==t&&t.multiChatMode&&this._handleFFAudioTrack()}},{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,l,u=s.attributes,d=_objectSpread2(_objectSpread2({},u),a),p=!1,_=d.localaudio!==u.localaudio,h=!1,f=!1,m=d.localvideo!==u.localvideo,v=!1,g=ExtendMediaType.NONE,y=ExtendMediaType.NONE;if(d.audiostream!==u.audiostream&&(p=d.localaudio,h=!!d.audiostream,d.audiostream?g|=MediaType.AUDIO:y|=MediaType.AUDIO),d.videostream!==u.videostream&&(f=d.localvideo,v=!!d.videostream,d.videostream?g|=MediaType.VIDEO:y|=MediaType.VIDEO),g&&this.safeEmit(RoomEvent.ON_USER_PUBLISH_STATE_CHANGE,{userId:i,mediaType:g,isScreen:s.isScreen,pubState:PubState.PUB,remoteStream:s}),y&&this.safeEmit(RoomEvent.ON_USER_PUBLISH_STATE_CHANGE,{userId:i,mediaType:y,isScreen:s.isScreen,pubState:PubState.UNPUB,remoteStream:s}),s.attributes=d,d.localaudio!==u.localaudio)if(d.localaudio){var S,T,$,E;if(r&&d.audiostream)if(d.extaudio)null===(S=s.observer)||void 0===S||S.setExternalAudioSource(!0),null===(T=s.observer)||void 0===T||T.setPushAudio(!0);else null===($=s.observer)||void 0===$||$.setExternalAudioSource(!1),null===(E=s.observer)||void 0===E||E.setEnableAudio(!0);this.safeEmit(RoomEvent.ON_USER_START_AUDIO_CAPTURE,{userId:i},s)}else{var b,I,R,C;if(d.extaudio)null===(b=s.observer)||void 0===b||b.setExternalAudioSource(!0),null===(I=s.observer)||void 0===I||I.setPushAudio(!1);else null===(R=s.observer)||void 0===R||R.setExternalAudioSource(!1),null===(C=s.observer)||void 0===C||C.setEnableAudio(!1);!s.isScreen&&this.safeEmit(RoomEvent.ON_USER_STOP_AUDIO_CAPTURE,{userId:i})}if(d.localvideo!==u.localvideo)if(d.localvideo){var A,k,P,O;if(n&&d.videostream)if(d.extvideo)null===(A=s.observer)||void 0===A||A.setExternalVideoSource(!0),null===(k=s.observer)||void 0===k||k.setPushVideo(!0);else null===(P=s.observer)||void 0===P||P.setExternalVideoSource(!1),null===(O=s.observer)||void 0===O||O.setEnableVideo(!0);this.safeEmit(RoomEvent.ON_USER_START_VIDEO_CAPTURE,{userId:i})}else{var w,M,D,x;if(d.extvideo)null===(w=s.observer)||void 0===w||w.setExternalVideoSource(!0),null===(M=s.observer)||void 0===M||M.setPushVideo(!1);else null===(D=s.observer)||void 0===D||D.setExternalVideoSource(!1),null===(x=s.observer)||void 0===x||x.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(h);if(f&&!m)null===(l=s.observer)||void 0===l||l.setRemoteUnmuteVideo(v)}}},{key:"_onPushTrack",value:function(e){var t,r=this;if(null!==(t=e.streamId)&&void 0!==t&&startsWith2(t).call(t,"audio_mux")){var n=this._onAddStream(_objectSpread2(_objectSpread2({},e),{},{attributes:virtualStreamAttributes}),{needEmit:!1,fromSignal:!1,virtual:!0});n&&this._mediaServerClient.subscribe4pushTrack(n,e).then((function(){r.safeEmit(RoomEvent.SUBSCRIBE_PUSH_TRACK,{stream:n}),r._virtualStreams.push(n)})).catch((function(e){logger$6.print("subscribe","push track failed %o",e)}))}else{var i,o;null===(i=this._monitor)||void 0===i||i.report("rtc_error",{message:concat$2(o="onPushTrack, userId: ".concat(e.clientId,", ")).call(o,e.streamId),error_code:-1001})}}},{key:"_onRemoveTrack",value:function(e){var t,r=e.clientId,n=e.streamId,i=e.message;logger$6.print("_onRemoveTrack","remove track: %o",r);var o=this._findRemoteStream(r,n);o&&(null===(t=this._mediaServerClient)||void 0===t||t.unsubscribe4removeTrack(o,i))}},{key:"_onMeetingSpeakerChange",value:function(e){if(Array.isArray(null==e?void 0:e.speakerCsrcInfo)){var t={};null==e||e.speakerCsrcInfo.forEach((function(e){var r=e.csrc,n=e.userId;e.isScreen||(t[r]=n)})),this._csrcUserIdMap=t}}},{key:"getActiveSpeakerInMultiChatMode",value:function(){var e=this,t=[];return this._virtualStreams.forEach((function(r){var n,i=null===(n=r.audioTransceiver)||void 0===n?void 0:n.receiver;if(i){var o=_slicedToArray(i.getContributingSources()||[],1)[0];if(o){var a=o.audioLevel,s=o.source;e._csrcUserIdMap[s]&&t.push({userId:e._csrcUserIdMap[s],audioLevel:a})}}})),t.length&&sort2(t).call(t,(function(e,t){return e.audioLevel-t.audioLevel})),t}},{key:"_nodeChange",value:function(e){var t,r,n=e.nodes,i=e.reason;sdkCache.clearAccessNode(null===(t=this._roomInfo)||void 0===t?void 0:t.appId),this._destroyAndInitMediaServerClient(),Array.isArray(n)&&n.length?this._getAccessNode=n[0]:this._getAccessFeedback=i,null===(r=this._monitor)||void 0===r||r.report("rtc_node_change",{error_code:0,message:stringify$1(e),reason:stringify$1(i)}),this._joinResolveCallback&&this._joinRejectCallback?this._join(this._joinResolveCallback,this._joinRejectCallback):this._reconnect()}},{key:"_reconnect",value:function(){var e,t,r=this;this._isReconnecting=!0;var n,i=_createForOfIteratorHelper(values$1(t=this._remoteStreams).call(t));try{for(i.s();!(n=i.n()).done;){var o=n.value;Array.isArray(o)&&o.forEach((function(e){return e.clean()}))}}catch(e){i.e(e)}finally{i.f()}null===(e=this._monitor)||void 0===e||e.report("rtc_reconnect",{error_code:1002,message:"peerconnection reconnecting",reconnect_id:this._roomInfo.userInfo.userId,reconnect_type:"peerconnection"}),this._liveTranscodingOnceSucc||delete this._liveControlMessage,this._join((function(){var e;null===(e=r._monitor)||void 0===e||e.report("rtc_reconnected",{message:"peerconnection reconnected",reconnect_type:"peerconnection"})}),(function(e){r._reconnectRecord.record(e),r._reconnectRecord.shouldReconnect?(logger$6.print("Reconnecting error, will reconnect after 3s",e),r._reconnectTimer=window.setTimeout(r._reconnect.bind(r),3e3)):(r.safeEmit(RoomEvent.RECONNECT_FAILED),r.destroy())}),!0)}},{key:"_handleAbnormalDisconnection",value:function(){var e,t;logger$6.print("on ABNORMAL_DISCONNECTION"),null===(e=this.localStream)||void 0===e||e.stopReport(),null===(t=this.remoteStreams)||void 0===t||t.forEach((function(e){return null==e?void 0:e.forEach((function(e){return e.stopReport()}))})),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){var t,r={userId:e.from,message:e.msg};null!==(t=this._subtitleTool)&&void 0!==t&&t.onMessageRecv(r)||this.safeEmit(SignalEvent.USER_BINARY_MESSAGE_RECEIVED,r)}},{key:"_initSubtitleTool",value:function(){var e=this;this._subtitleTool=new SubtitleTool(this),this._subtitleTool.onEvent=function(t){e.emit(RoomEvent.ON_SUBTITLE_STATE_CHANGED,t)},this._subtitleTool.onMessage=function(t){e.emit(RoomEvent.ON_SUBTITLE_MESSAGE_RECEIVED,t)}}},{key:"_onPostProcessingMessage",value:function(e){if(e.body)if("subtitleCallback"!==e.type){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})}else{var o;null===(o=this._subtitleTool)||void 0===o||o.onResult(e)}}},{key:"_onUserTokenWillExpire",value:function(){this.safeEmit(SignalEvent.ON_USER_TOKEN_WILL_EXPIRE,null)}},{key:"_onStreamFailed",value:(r=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){var r,n,i,o,a,s,c,l,u,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],!(l=this._findRemoteStream(c,t.streamId))){e.next=20;break}return e.next=17,null===(u=this._mediaServerClient)||void 0===u?void 0:u.unsubscribe(l,MediaType.AUDIO_AND_VIDEO);case 17:return e.next=19,null===(d=this._mediaServerClient)||void 0===d?void 0:d.subscribe(l,l.subMediaType,l.subLayer);case 19:this.safeEmit(RoomEvent.RESUBSCRIBE,{stream:l});case 20:case"end":return e.stop()}}),e,this)}))),function(e){return r.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:(t=_asyncToGenerator(_regeneratorRuntime().mark((function e(){var t,r,n,i,o,a,s,c,l,u,d,p,_,h;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._publishOnDemandBusy&&!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)){e.next=2;break}return e.abrupt("return");case 2:if(a=this._publishOnDemandItem,this._publishOnDemandItem=void 0,a){e.next=6;break}return e.abrupt("return");case 6:if(null===(i=this._localStream)||void 0===i||!i.enableSimulcast||null===(o=this._localStream)||void 0===o||!o.videoTransceiver){e.next=16;break}return l=[],this._publishOnDemandBusy=!0,u=null===(s=this._localStream)||void 0===s?void 0:s.stream.id,d=null===(c=this._localStream)||void 0===c?void 0:c.videoTransceiver.sender,p=d.getParameters(),Array.isArray(p.encodings)&&Array.isArray(a)&&(h={},logger$6.print("_onPublishOnDemand exec","usedDescriptions: %o",a),a.forEach((function(e){var t;if(null!=e&&null!==(t=e.StreamIds)&&void 0!==t&&includes4(t).call(t,u)){var r=null==e?void 0:e.Metadata.VideoIndex;h[r]=!0}})),p.encodings=map$6(_=p.encodings).call(_,(function(e){if(e.rid){h[e.rid]?e.active=!0:e.active=!1;var t=+e.rid;l[t]=e.active}return e})),this._context&&(this._context.activeSimStreams=l)),e.next=15,d.setParameters(p);case 15:this._publishOnDemandBusy=!1;case 16:this._onPublishOnDemand();case 17:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})},{key:"_onRTT",value:function(e){var t=e.StreamIds,r=e.Metadata;if(t.length&&r){var n,i=t[0];null!==(n=this._context)&&void 0!==n&&n.streamRTT&&(this._context.streamRTT[i]={audio:r.audio_rtt,video:r.video_rtt})}}},{key:"_onSSC",value:function(e){var t=e.StreamIds,r=e.Metadata,n=t[0],i=this._remoteStreamStreamIdUserIdMap[n],o=this._findRemoteStream(i,n),a={userId:i,isScreen:!!o&&o.isScreen,beforeVideoIndex:r.ssc_items[0].prev_layer_id,afterVideoIndex:r.ssc_items[0].cur_layer_id,beforeEnable:0!==r.ssc_items[0].prev_video_open,afterEnable:0!==r.ssc_items[0].cur_video_open,reason:r.ssc_items[0].change_reason};this.emit(RoomEvent.ON_SIMULCAST_SUBSCRIBE_FALLBACK,a)}},{key:"_reportNetworkQuality",value:function(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:"multiChatMode",get:function(){var e;return null===(e=this._mediaServerClient)||void 0===e?void 0:e.multiChatMode()}}]),R}(),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;map$6(e).call(e,(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&&assign$2(r.style,t.style),t.attributes&&entries2(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},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:""},VideoPlayer=function(e){_inherits(n,eventemitter3.exports.EventEmitter);var t,r=_createSuper(n);function n(e,t){var i;_classCallCheck(this,n),_defineProperty(_assertThisInitialized(i=r.call(this)),"_containerDom",void 0),_defineProperty(_assertThisInitialized(i),"_videoDom",void 0),_defineProperty(_assertThisInitialized(i),"__cumulativeTime",void 0),_defineProperty(_assertThisInitialized(i),"userId",void 0),_defineProperty(_assertThisInitialized(i),"renderMode",void 0),_defineProperty(_assertThisInitialized(i),"mirrorType",MirrorType.MIRROR_TYPE_NONE),_defineProperty(_assertThisInitialized(i),"isScreen",void 0),_defineProperty(_assertThisInitialized(i),"isLocal",void 0),_defineProperty(_assertThisInitialized(i),"played",!1),_defineProperty(_assertThisInitialized(i),"_needLoad",!1),_defineProperty(_assertThisInitialized(i),"_emitPlayFailed",!1),_defineProperty(_assertThisInitialized(i),"_videoContainer",void 0),_defineProperty(_assertThisInitialized(i),"_safari15VideoTimer",void 0),_defineProperty(_assertThisInitialized(i),"_monitor",void 0),_defineProperty(_assertThisInitialized(i),"emitVideoEvent",(function(e){var t,r,n={type:"video",rawEvent:e,readyState:(null===(t=i._videoDom)||void 0===t?void 0:t.readyState)||0,userId:i.userId,eventName:e.type,currentTime:(null===(r=i._videoDom)||void 0===r?void 0:r.currentTime)||0,isScreen:i.isScreen};switch(i.emit("playback_event",n),e.type){case"canplay":case"loadeddata":i._internalPlay();break;case"playing":logger$5.print("VideoPlayerPlaying","[userId-".concat(i.userId,"] video element playing"))}})),_defineProperty(_assertThisInitialized(i),"_internalPlay",(function(){var e;if(null!==(e=i._videoDom)&&void 0!==e&&e.paused){var t=i._videoDom.play();null!=t&&t.then&&t.then((function(){var e;i.isLocal&&isCriOS&&!i._needLoad&&(null===(e=i._videoDom)||void 0===e||e.load(),i._needLoad=!0)})).catch((function(e){var t,r,n,o,a,s;i._emitPlayFailed||("AbortError"!==e.name?(i._emitPlayFailed=!0,null===(t=i._monitor)||void 0===t||t.report("rtc_error",{message:concat$2(r="video autoplay failed, userId: ".concat(i.userId,", ")).call(r,e.name),error_code:-1e3}),i.emit("playback_event",{type:"video",rawEvent:e,readyState:(null===(n=i._videoDom)||void 0===n?void 0:n.readyState)||0,userId:i.userId,eventName:"autoplay-error",currentTime:(null===(o=i._videoDom)||void 0===o?void 0:o.currentTime)||0,isScreen:i.isScreen})):null===(a=i._monitor)||void 0===a||a.report("rtc_error",{message:concat$2(s="video autoplay failed, userId: ".concat(i.userId,", ")).call(s,e.name),error_code:-1e3}))}))}})),i.engineId=e;var o=t.renderDom;i._monitor=getMonitor(e);var a=t.userId;i.renderMode=void 0!==t.renderMode?t.renderMode:VideoRenderMode.RENDER_MODE_FIT;var s="string"==typeof o?document.getElementById(o):o;if(!s)throw new SDKError(ErrorCode.CANT_FIND_DOM,"can't find dom");return i._videoContainer=document.createElement("div"),i._videoContainer.style.width="100%",i._videoContainer.style.height="100%",i._videoContainer.style.position="relative",i._videoContainer.style.overflow="hidden",i._containerDom=s,i.userId=a,i.isLocal=!!t.isLocal,i.isScreen=!!t.isScreen,i._initVideo(),i}return _createClass(n,[{key:"_initVideo",value:function(){var e;this._videoDom||(this._videoDom=createElement("video",{style:{width:"100%",height:"100%"},attributes:VIDEO_ATTRIBUTES}),this._videoDom.id=concat$2(e="".concat(this.userId,"_")).call(e,genUuid2()),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._videoContainer.appendChild(this._videoDom),this._containerDom.appendChild(this._videoContainer),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)}))}},{key:"_recordFrame",value:function(e){var t=this,r=e.isScreen?1.5:.55;if(isSafari){var n;if(null===(n=this._videoDom)||void 0===n||!n.requestVideoFrameCallback)return;this._videoDom.requestVideoFrameCallback((function n(i,o){var a=o.presentationTime;if(e.recordedVideoFrames||(e.recordedVideoFrames=[]),t.__cumulativeTime){var s,c=(a-t.__cumulativeTime)%2e3,l=c>1e3*r;null===(s=e.recordedVideoFrames)||void 0===s||s.push({playTime:a,isStall:l,stallCount:l?1:0,stallDuration:c})}t.__cumulativeTime=a,t._videoDom.requestVideoFrameCallback(n)}))}else this.on("playback_event",(function(n){var i;if("timeupdate"===n.eventName){if(0===(null===(i=t._videoDom)||void 0===i?void 0:i.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>r;e.recordedVideoFrames.push({playTime:t._videoDom.currentTime,isStall:a,stallCount:a?1:0,stallDuration:o%2e3})}t.__cumulativeTime=t._videoDom.currentTime}}))}},{key:"_recordPause",value:function(e){var t=this;void 0===e.statsReport.isPaused&&this.on("playback_event",(function(r){if("pause"===r.eventName)e.statsReport.isPaused=!0,e.statsReport.pauseStart=getServerNow();else if("timeupdate"===r.eventName){var n;if((null===(n=t._videoDom)||void 0===n||!n.paused)&&e.statsReport.isPaused){e.statsReport.isPaused=!1;var i=getServerNow()-(e.statsReport.pauseStart||0);i>500&&(e.statsReport.pauseDuration+=i)}}}))}},{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=5;break}try{reportRtcInvokeStatus(this.engineId,"playVideo","play video repeatedly",0,this.userId)}catch(e){}return e.abrupt("return");case 5: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("preprocessing")),o.srcObject=a,o&&!this._containerDom.contains(this._videoContainer)&&this._containerDom.appendChild(this._videoContainer),o&&!this._videoContainer.contains(o)&&this._videoContainer.appendChild(o),setTimeout((function(){return s._internalPlay()})),r&&Config.VIDEO_STALL&&(this._recordFrame(r),this._recordPause(r),r.statsReport.player=this),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:"removeTrack",value:function(){var e,t=null===(e=this._videoDom)||void 0===e?void 0:e.srcObject;if(t){var r=t.getVideoTracks();null!=r&&r.length&&r.forEach((function(e){t.removeTrack(e)}))}}},{key:"manuallyPlay",value:function(){if(logger$5.print("Invoke VideoPlayer.manuallyPlay",this.userId,this.isScreen),this._emitPlayFailed=!1,!this._videoDom)throw new SDKError(ErrorCode.INVALID_PARAMS,"Player not found");return 0!==this._videoDom.readyState||isWeChat?this._videoDom.play():promise.resolve()}},{key:"mirror",value:function(e){var t;logger$5.print("mirror",concat$2(t="".concat(this.userId," set mirror: ")).call(t,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,t=arguments.length>0&&void 0!==arguments[0]&&arguments[0],r=this._containerDom;(logger$5.print("stop","stop video track: ".concat(this.userId)),this._videoDom)&&(t||(this._videoDom.srcObject=null),null!=r&&r.contains(this._videoContainer)&&r.removeChild(this._videoContainer),null!==(e=this._videoContainer)&&void 0!==e&&e.contains(this._videoDom)&&this._videoContainer.removeChild(this._videoDom));this.__cumulativeTime=void 0,this.played=!1}},{key:"destroy",value:function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];logger$5.print("destroy","video player: ".concat(this.userId)),this.stop(e),_get(_getPrototypeOf(n.prototype),"removeAllListeners",this).call(this),this._removeListeners(),this._videoDom&&delete this._videoDom,this._safari15VideoTimer&&(window.clearInterval(this._safari15VideoTimer),this._safari15VideoTimer=void 0)}},{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,t){var r,o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{divId:void 0,muted:!1,isScreen:!1},a=o.divId,s=o.muted,c=o.isScreen;if(_classCallCheck(this,i),_defineProperty(_assertThisInitialized(r=n.call(this)),"_containerDom",void 0),_defineProperty(_assertThisInitialized(r),"_audioDom",void 0),_defineProperty(_assertThisInitialized(r),"_fakeAudioDom",void 0),_defineProperty(_assertThisInitialized(r),"userId",void 0),_defineProperty(_assertThisInitialized(r),"muted",!1),_defineProperty(_assertThisInitialized(r),"_emitPlayFailed",!1),_defineProperty(_assertThisInitialized(r),"played",!1),_defineProperty(_assertThisInitialized(r),"isScreen",void 0),_defineProperty(_assertThisInitialized(r),"_wechatTimer",void 0),_defineProperty(_assertThisInitialized(r),"_monitor",void 0),_defineProperty(_assertThisInitialized(r),"_pasued",!0),_defineProperty(_assertThisInitialized(r),"emitAudioEvent",(function(e){var t,n,i={type:"audio",rawEvent:e,readyState:(null===(t=r._audioDom)||void 0===t?void 0:t.readyState)||0,userId:r.userId,eventName:e.type,currentTime:(null===(n=r._audioDom)||void 0===n?void 0:n.currentTime)||0};"playing"===e.type&&logger$5.print("AudioPlayerPlaying","[userId-".concat(r.userId,"] audio element playing")),"pause"===e.type&&(logger$5.print("AudioPlayerPause","[userId-".concat(r.userId,"] audio element pause")),r._pasued||r._internalPlay()),isAndroid&&isWeChat&&("canplay"===e.type?(clearTimeout(r._wechatTimer),r._wechatTimer=window.setTimeout((function(){r._autoPlayError("wechat")}),500)):"playing"===e.type&&clearTimeout(r._wechatTimer)),r.emit("playback_event",i)})),_defineProperty(_assertThisInitialized(r),"_internalPlay",(function(){var e,t;if(reportRtcInvokeStatus(r.engineId,"_internalPlay",{paused:null===(e=r._audioDom)||void 0===e?void 0:e.paused}),null!==(t=r._audioDom)&&void 0!==t&&t.paused)try{var n,i=r._audioDom.play(),o=audioContextManager.getAudioContextInstance();if("suspended"===o.state){var a=o.resume(),s=setTimeout((function(){var e;"suspended"===o.state&&(r._autoPlayError("AudioContext cannot resume"),null===(e=r._monitor)||void 0===e||e.report("rtc_error",{message:"audio autoplay failed, userId: ".concat(r.userId,": Cannot resume the AudioContext - timeout"),error_code:-1e3}));clearTimeout(s)}));a.catch((function(e){var t,n,i;r._autoPlayError("AudioContext cannot resume"),null===(t=r._monitor)||void 0===t||t.report("rtc_error",{message:concat$2(n=concat$2(i="audio autoplay failed, userId: ".concat(r.userId,": Cannot resume the AudioContext - rejected by: [")).call(i,null==e?void 0:e.name,"]")).call(n,null==e?void 0:e.message),error_code:-1e3})})).finally((function(){clearTimeout(s)}))}null!==(n=i)&&void 0!==n&&n.then&&(isAndroid&&isMobile&&(i=i.then((function(){return new promise((function(e){setTimeout(_asyncToGenerator(_regeneratorRuntime().mark((function t(){var n;return _regeneratorRuntime().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return null===(n=r._audioDom)||void 0===n||n.pause(),r._audioDom.volume=1,t.next=4,r._audioDom.play();case 4:e();case 5:case"end":return t.stop()}}),t)}))),500)}))}))),i.then((function(){reportRtcInvokeStatus(r.engineId,"_internalPlay successfully",{userId:r.userId}),r._pasued=!1})).catch((function(e){var t,n,i;r._autoPlayError(e),null===(t=r._monitor)||void 0===t||t.report("rtc_error",{message:concat$2(n=concat$2(i="audio autoplay failed, userId: ".concat(r.userId,": ")).call(i,e.message," ")).call(n,e.name),error_code:-1e3})})))}catch(e){var c,l,u;r._autoPlayError(e),null===(c=r._monitor)||void 0===c||c.report("rtc_error",{message:concat$2(l=concat$2(u="audio autoplay failed, userId: ".concat(r.userId,": ")).call(u,e.message," ")).call(l,e.name),error_code:-1e3})}})),r.engineId=e,a){var l=document.getElementById(a);if(!l)throw new SDKError(ErrorCode.CANT_FIND_DOM,"can't find dom");r._containerDom=l}else r._containerDom=document.body;return r.userId=t,r.muted=s,r.isScreen=c,r._monitor=getMonitor(e),r._initAudio(),r}return _createClass(i,[{key:"_initAudio",value:function(){var e;this._audioDom||(this._audioDom=createElement("audio",{style:{display:"none"},attributes:AUDIO_ATTRIBUTES}),this._audioDom.volume=this.muted?0:1,this._audioDom.muted=this.muted,this._audioDom.id=concat$2(e="".concat(this.userId,"_")).call(e,genUuid2()),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,t instanceof runtimeTrackCls.RemoteAudioTrack?(this._fakeAudioDom=new Audio,this._fakeAudioDom.muted=!0,this._fakeAudioDom.srcObject=new MediaStream([t.getOrgTrack()]),a.addTrack(t.getTrack())):a.addTrack(t.getTrack("preprocessing")),isAndroid&&isMobile&&(this._audioDom.volume=0),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 13: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,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:"pause",value:function(){if(!this._audioDom)throw new SDKError(ErrorCode.INVALID_PARAMS,"Player not found");this._pasued=!0,this._audioDom.pause()}},{key:"manuallyPlay",value:function(){var e,t=this;if(logger$5.print("Invoke AudioPlayer.manuallyPlay"),this._emitPlayFailed=!1,!this._audioDom)throw new SDKError(ErrorCode.INVALID_PARAMS,"Player not found");if(!this.played)return promise.resolve();this._audioDom.volume=1,this._audioDom.muted=!1,null===(e=this._fakeAudioDom)||void 0===e||e.play();var r=[],n=this._audioDom.play();null!=n&&n.then&&r.push(n);var i=audioContextManager.getAudioContextInstance();if("suspended"===i.state){var o=i.resume();null!=o&&o.then&&r.push(o)}(r.length>0?promise.all(r):promise.resolve(n)).then((function(){t._pasued=!1}))}},{key:"setPlaybackDevice",value:(t=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){var r,n;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return logger$5.print("setPlaybackDevice","setPlaybackDevice: ".concat(t)),e.next=3,dd.enumerateAudioPlaybackDevices();case 3:if(r=e.sent,n=map$6(r).call(r,(function(e){return e.deviceId})),includes4(n).call(n,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,null!=e&&e.contains(this._audioDom)&&e.removeChild(this._audioDom)),this._fakeAudioDom&&(this._fakeAudioDom.srcObject=null,this._fakeAudioDom=void 0),this.played=!1}},{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&&(this._audioDom.srcObject=null,delete this._audioDom)}}]),i}();function playRemoteStream(e,t,r,n){var i=function(){var e=_asyncToGenerator(_regeneratorRuntime().mark((function e(t,i){var o,a;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(o=null==n?void 0:n.get(i),Array.isArray(o)&&(o=null===(a=o)||void 0===a?void 0:find$2(a).call(a,(function(e){return e.isScreen===r}))),!t){e.next=9;break}if(!t.played){e.next=8;break}return e.next=6,t.manuallyPlay();case 6:e.next=9;break;case 8:o&&(t instanceof VideoPlayer&&o.videoTrack&&t.playVideo(o.videoTrack,o),t instanceof AudioPlayer&&o.audioTrack&&t.playAudio(o.audioTrack));case 9:case"end":return e.stop()}}),e)})));return function(t,r){return e.apply(this,arguments)}}();if(t)return i(e.get(t),t);var o=[];return e.forEach((function(e,t){return o.push(i(e,t))})),promise.all(o)}var fails=fails$z,wellKnownSymbol$1=wellKnownSymbol$p,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})),defineProperty5=objectDefineProperty,defineBuiltInAccessor$1=function(e,t,r){return defineProperty5.f(e,t,r)},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,l=c;for(c&&push$2(n,delimiter);l<i;){var u=maxInt;for(t=0;t<e.length;t++)(r=e[t])>=o&&r<u&&(u=r);var d=l+1;if(u-o>floor$1((maxInt-a)/d))throw $RangeError(OVERFLOW_ERROR);for(a+=(u-o)*d,o=u,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 h=_<=s?tMin:_>=s+tMax?tMax:_-s;if(p<h)break;var f=p-h,m=base-h;push$2(n,fromCharCode(digitToBasic(h+f%m))),p=floor$1(f/m),_+=base}push$2(n,fromCharCode(digitToBasic(p))),s=adapt(a,d,l==c),a=0,l++}}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$s,call=functionCall,uncurryThis$1=functionUncurryThis,DESCRIPTORS$1=descriptors,USE_NATIVE_URL$1=urlConstructorDetection,defineBuiltIn$1=defineBuiltIn$8,defineBuiltIns=defineBuiltIns$4,setToStringTag$1=setToStringTag$9,createIteratorConstructor=iteratorCreateConstructor,InternalStateModule$1=internalState,anInstance$1=anInstance$6,isCallable=isCallable$n,hasOwn$1=hasOwnProperty_1,bind$1=functionBindContext,classof=classof$d,anObject=anObject$M,isObject=isObject$q,$toString$1=toString$h,create4=objectCreate$1,createPropertyDescriptor=createPropertyDescriptor$9,getIterator=getIterator$7,getIteratorMethod=getIteratorMethod$a,validateArgumentsLength$1=validateArgumentsLength$3,wellKnownSymbol=wellKnownSymbol$p,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),getOwnPropertyDescriptor5=Object.getOwnPropertyDescriptor,safeGetBuiltIn=function(e){if(!DESCRIPTORS$1)return global$2[e];var t=getOwnPropertyDescriptor5(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$1=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),splice2=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$1(e)}catch(t){return e}},deserialize=function(e){var t=replace$1(e,plus," "),r=4;try{return decodeURIComponent$1(t)}catch(e){for(;r;)t=replace$1(t,percentSequence(r--),percentDecode);return t}},find4=/[!'()~]|%20/g,replacements={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+"},replacer=function(e){return replacements[e]},serialize=function(e){return replace$1(encodeURIComponent$1(e),find4,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 l in e)hasOwn$1(e,l)&&push$1(this.entries,{key:l,value:$toString$1(e[l])})},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?splice2(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?splice2(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"),create4(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$s,bind2=functionBindContext,uncurryThis=functionUncurryThis,defineBuiltIn=defineBuiltIn$8,defineBuiltInAccessor=defineBuiltInAccessor$1,anInstance=anInstance$6,hasOwn2=hasOwnProperty_1,assign2=objectAssign,arrayFrom=arrayFrom$1,arraySlice=arraySliceSimple,codeAt=stringMultibyte.codeAt,toASCII=stringPunycodeToAscii,$toString=toString$h,setToStringTag=setToStringTag$9,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),join2=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],l=0,u=null,d=0,p=function(){return charAt(e,d)};if(":"==p()){if(":"!=charAt(e,1))return;d+=2,u=++l}for(;p();){if(8==l)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,l>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[l]=256*c[l]+i,2!=++n&&4!=n||l++}if(4!=n)return;break}if(":"==p()){if(d++,!p())return}else if(p())return;c[l++]=t}else{if(null!==u)return;d++,u=++l}}if(null!==u)for(a=l-u,l=7;0!=l&&a>0;)s=c[l],c[l--]=c[u+a-1],c[u+--a]=s;else if(8!=l)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 join2(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=assign2({},C0ControlPercentEncodeSet,{" ":1,'"':1,"<":1,">":1,"`":1}),pathPercentEncodeSet=assign2({},fragmentPercentEncodeSet,{"#":1,"?":1,"{":1,"}":1}),userinfoPercentEncodeSet=assign2({},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&&!hasOwn2(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,l=0,u="",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);l<=n.length;){switch(i=n[l],c){case SCHEME_START:if(!i||!exec(ALPHA,i)){if(t)return INVALID_SCHEME;c=NO_SCHEME;continue}u+=toLowerCase(i),c=SCHEME;break;case SCHEME:if(i&&(exec(ALPHANUMERIC,i)||"+"==i||"-"==i||"."==i))u+=toLowerCase(i);else{if(":"!=i){if(t)return INVALID_SCHEME;u="",c=NO_SCHEME,l=0;continue}if(t&&(s.isSpecial()!=hasOwn2(specialSchemes,u)||"file"==u&&(s.includesCredentials()||null!==s.port)||"file"==s.scheme&&!s.host))return;if(s.scheme=u,t)return void(s.isSpecial()&&specialSchemes[s.scheme]==s.port&&(s.port=null));u="","file"==s.scheme?c=FILE:s.isSpecial()&&r&&r.scheme==s.scheme?c=SPECIAL_RELATIVE_OR_AUTHORITY:s.isSpecial()?c=SPECIAL_AUTHORITY_SLASHES:"/"==n[l+1]?(c=PATH_OR_AUTHORITY,l++):(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[l+1]){c=RELATIVE;continue}c=SPECIAL_AUTHORITY_IGNORE_SLASHES,l++;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(u,l+1))continue;l++;break;case SPECIAL_AUTHORITY_IGNORE_SLASHES:if("/"!=i&&"\\"!=i){c=AUTHORITY;continue}break;case AUTHORITY:if("@"==i){d&&(u="%40"+u),d=!0,o=arrayFrom(u);for(var h=0;h<o.length;h++){var f=o[h];if(":"!=f||_){var m=percentEncode(f,userinfoPercentEncodeSet);_?s.password+=m:s.username+=m}else _=!0}u=""}else if(i==EOF||"/"==i||"?"==i||"#"==i||"\\"==i&&s.isSpecial()){if(d&&""==u)return INVALID_AUTHORITY;l-=arrayFrom(u).length+1,u="",c=HOST}else u+=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()&&""==u)return INVALID_HOST;if(t&&""==u&&(s.includesCredentials()||null!==s.port))return;if(a=s.parseHost(u))return a;if(u="",c=PATH_START,t)return;continue}"["==i?p=!0:"]"==i&&(p=!1),u+=i}else{if(""==u)return INVALID_HOST;if(a=s.parseHost(u))return a;if(u="",c=PORT,t==HOSTNAME)return}break;case PORT:if(!exec(DIGIT,i)){if(i==EOF||"/"==i||"?"==i||"#"==i||"\\"==i&&s.isSpecial()||t){if(""!=u){var v=parseInt$1(u,10);if(v>65535)return INVALID_PORT;s.port=s.isSpecial()&&v===specialSchemes[s.scheme]?null:v,u=""}if(t)return;c=PATH_START;continue}return INVALID_PORT}u+=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(join2(arraySlice(n,l),""))||(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(join2(arraySlice(n,l),""))&&(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(u))c=PATH;else if(""==u){if(s.host="",t)return;c=PATH_START}else{if(a=s.parseHost(u))return a;if("localhost"==s.host&&(s.host=""),t)return;u="",c=PATH_START}continue}u+=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(u)?(s.shortenPath(),"/"==i||"\\"==i&&s.isSpecial()||push(s.path,"")):isSingleDot(u)?"/"==i||"\\"==i&&s.isSpecial()||push(s.path,""):("file"==s.scheme&&!s.path.length&&isWindowsDriveLetter(u)&&(s.host&&(s.host=""),u=charAt(u,0)+":"),push(s.path,u)),u="","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 u+=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))}l++}},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 hasOwn2(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,l=t+":";return null!==i?(l+="//",e.includesCredentials()&&(l+=r+(n?":"+n:"")+"@"),l+=serializeHost(i),null!==o&&(l+=":"+o)):"file"==t&&(l+="//"),l+=e.cannotBeABaseURL?a[0]:a.length?"/"+join2(a,"/"):"",null!==s&&(l+="?"+s),null!==c&&(l+="#"+c),l},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?"/"+join2(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",bind2(nativeCreateObjectURL,NativeURL)),nativeRevokeObjectURL&&defineBuiltIn(URLConstructor,"revokeObjectURL",bind2(nativeRevokeObjectURL,NativeURL))}setToStringTag(URLConstructor,"URL"),$({global:!0,constructor:!0,forced:!USE_NATIVE_URL,sham:!DESCRIPTORS},{URL:URLConstructor});var path=path$v,url$5=path.URL,parent$2=url$5,url$4=parent$2,parent$1=url$4,url$3=parent$1,parent=url$3,url$2=parent,url$1=url$2,url=url$1,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=defineProperty$a,__getOwnPropDesc$1=getOwnPropertyDescriptor$1,__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,r){_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,"_startingIds",new map2),_defineProperty(this,"_revokeURLs",new set),_defineProperty(this,"mixingMap",new map2),_defineProperty(this,"resourcesCache",new map2),_defineProperty(this,"volumeConfig",new map2),_defineProperty(this,"cachedBuffer",[]),_defineProperty(this,"id","AudioMixingManager"),this.engineId=r,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,l,u,d,p,_,h,f,m,v=this;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(void 0===this._startingIds.get(t)){e.next=3;break}return console.warn("AudioMixing task id: ".concat(t," is starting")),e.abrupt("return");case 3:if(this._startingIds.set(t,t),i=n.playCount,checkEnum(o=n.type,"mixingType",values(AudioMixingType)),a=this._context.getLocalAudioTrack()){e.next=9;break}return e.abrupt("return");case 9:if((s=a.getTrack("preprocessing"))&&this.mixMediaStream(new MediaStream([s])),null!=(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(!(u=this.resourcesCache.get(t))||u.filePath!==r){e.next=18;break}l=u.getAudioNode(),e.next=31;break;case 18:return e.next=20,fetch(r,{mode:"cors",credentials:"include"}).then((function(e){if(e.ok)return e.arrayBuffer();throw v._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 20:return d=e.sent,endsWith2(r).call(r,"mp3")?p={type:"audio/mpeg"}:endsWith2(r).call(r,"aac")&&(p={type:"audio/aac"}),e.next=24,isValidAudioFile(d,p);case 24:if(e.sent){e.next=28;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 28:(l=new Audio).crossOrigin="anonymous",l.src=url.createObjectURL(new Blob([d],p));case 31:return i<=0?l.loop=!0:i>0&&(_=i,l.onended=function(){--_>0?l.play():(v.mixingMap.delete(t),v._context.emitMessage({mixId:t,state:AudioMixingState.AUDIO_MIXING_STATE_FINISHED,error:AudioMixingError.AUDIO_MIXING_ERROR_OK}))}),e.prev=32,e.next=35,l.play();case 35:e.next=42;break;case 37:e.prev=37,e.t0=e.catch(32),console.error(e.t0),this._failedAudioList.push(l),this._context.onAutoPlayFailed({userId:this.id,kind:"audio",streamIndex:StreamIndex.STREAM_INDEX_MAIN,mediaType:MediaType.AUDIO});case 42:if(this._startingIds.delete(t),h=this._sharedAudioContext.createMediaElementSource(l),f=this._sharedAudioContext.createGain(),m=this.volumeConfig.get(t),f.gain.value=m?m/100:1,h.connect(f).connect(this._audioDestination),this.mixingMap.set(t,{audioSource:h,audioNode:l,gainNode:f,type:"file"}),o===AudioMixingType.PUBLISH)try{f.disconnect(this._sharedAudioContext.destination)}catch(e){}else f.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 52:case"end":return e.stop()}}),e,this,[[32,37]])}))),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,o=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 new SDKError(ErrorCode.LOAD_RESOURCES_FAILED,e.statusText)})).catch((function(e){if(o._context.emitMessage({mixId:t,state:AudioMixingState.AUDIO_MIXING_STATE_FAILED,error:AudioMixingError.AUDIO_MIXING_ERROR_PRELOAD_FAILED}),e instanceof SDKError)throw e;throw new SDKError(ErrorCode.LOAD_RESOURCES_FAILED,"Load resources failed",e)}));case 3:return n=e.sent,endsWith2(r).call(r,"mp3")?i={type:"audio/mpeg"}:endsWith2(r).call(r,"aac")&&(i={type:"audio/aac"}),e.next=7,isValidAudioFile(n,i);case 7:if(e.sent){e.next=11;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 11:return this._context.emitMessage({mixId:t,state:AudioMixingState.AUDIO_MIXING_STATE_PRELOADED,error:AudioMixingError.AUDIO_MIXING_ERROR_OK}),this.resourcesCache.set(t,{getAudioNode:function(){var e=url.createObjectURL(new Blob([n],i));return o._revokeURLs.add(e),new Audio(e)},filePath:r,duration:0}),e.next=15,new promise((function(e){var r=url.createObjectURL(new Blob([n],i)),a=new Audio(r);a.addEventListener("durationchange",(function(){var n=o.resourcesCache.get(t);n&&(n.duration=a.duration,o.resourcesCache.set(t,n)),url.revokeObjectURL(r),e(null)}))}));case 15: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.resourcesCache.get(e);return t||r?t?1e3*t.audioNode.duration:r?1e3*r.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=t.getTrack("preprocessing");if(r&&this.mixMediaStream(new MediaStream([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({userId:this.id,kind:"audio",streamIndex:StreamIndex.STREAM_INDEX_MAIN,mediaType:MediaType.AUDIO}),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(),this._startingIds=new map2,this._revokeURLs.forEach((function(e){url.revokeObjectURL(e)}))}}]),e}();__decorateClass$1([reportRtcSdkApiCall("id","filePath","options")],AudioMixingManager.prototype,"startAudioMixing",1),__decorateClass$1([reportRtcSdkApiCall("id")],AudioMixingManager.prototype,"stopAudioMixing",1),__decorateClass$1([reportRtcSdkApiCall("id")],AudioMixingManager.prototype,"pauseAudioMixing",1),__decorateClass$1([reportRtcSdkApiCall("id")],AudioMixingManager.prototype,"resumeAudioMixing",1),__decorateClass$1([reportRtcSdkApiCall("id")],AudioMixingManager.prototype,"preloadAudioMixing",1),__decorateClass$1([reportRtcSdkApiCall("id")],AudioMixingManager.prototype,"unloadAudioMixing",1),__decorateClass$1([reportRtcSdkApiCall("id")],AudioMixingManager.prototype,"getAudioMixingVolume",1),__decorateClass$1([reportRtcSdkApiCall("id","volume")],AudioMixingManager.prototype,"setAudioMixingVolume",1),__decorateClass$1([reportRtcSdkApiCall("id")],AudioMixingManager.prototype,"getAudioMixingDuration",1),__decorateClass$1([reportRtcSdkApiCall("id")],AudioMixingManager.prototype,"getAudioMixingCurrentPosition",1),__decorateClass$1([reportRtcSdkApiCall("id","position")],AudioMixingManager.prototype,"setAudioMixingPosition",1),__decorateClass$1([reportRtcSdkApiCall("type")],AudioMixingManager.prototype,"enableAudioMixingBuffer",1),__decorateClass$1([reportRtcSdkApiCall()],AudioMixingManager.prototype,"disableAudioMixingBuffer",1),__decorateClass$1([reportRtcSdkApiCall("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(l,eventemitter3.exports.EventEmitter);var t,r,n,i,o,a,s,c=_createSuper(l);function l(e,t){var r;return _classCallCheck(this,l),_defineProperty(_assertThisInitialized(r=c.call(this)),"_dataChannelSignal",null),_defineProperty(_assertThisInitialized(r),"_handler",null),_defineProperty(_assertThisInitialized(r),"_dataChannelSignalState",MediaConnectionState.DISCONNECTED),_defineProperty(_assertThisInitialized(r),"_loginSessionId",null),_defineProperty(_assertThisInitialized(r),"_userId",null),_defineProperty(_assertThisInitialized(r),"_token",null),_defineProperty(_assertThisInitialized(r),"_isReconnecting",!1),_defineProperty(_assertThisInitialized(r),"_reconnectTimer",null),_defineProperty(_assertThisInitialized(r),"_loginResolveCallback",null),_defineProperty(_assertThisInitialized(r),"_loginRejectCallback",null),_defineProperty(_assertThisInitialized(r),"_iceConfigNode",null),_defineProperty(_assertThisInitialized(r),"_wait_login_token",!1),_defineProperty(_assertThisInitialized(r),"_serverParamsCache",void 0),r.id=e,r._appId=t,r}return _createClass(l,[{key:"login",value:function(e,t){var r=this;return new promise((function(n,i){var o;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,null===(o=getMonitor(r.id))||void 0===o||o.set({rtm_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(l.prototype),"removeAllListeners",this).call(this),delete this._serverParamsCache}},{key:"_login",value:function(){var e=this;if(this._userId){var t=genUuid2();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(){"function"==typeof e._loginResolveCallback&&e._loginResolveCallback(),e._loginSessionId=t,RTSMsgReportor.setRtsSessionId(e.id,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"),"function"==typeof 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,l=this;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=new IceConfigRequestManager(this.id),i=this._iceConfigNode){e.next=16;break}return e.prev=3,e.next=6,null==n?void 0:n.getAccessNode(this._appId,"");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(this.id,"rtm.login.getNodeFailed",null===e.t0||void 0===e.t0?void 0:e.t0.message),new SDKError(ErrorCode.ICE_SERVER_WRONG,"get ICE config failed");case 16:return reportRtcInvokeStatus(this.id,"rtm.login.getNodeSuccess",i),logger$4.print("_createDataChannelSignaling()","get node success",i),this._handler=createHandler({id:this.id,avSync:!0}),null===(r=this._handler)||void 0===r||r.once("disconnect",(function(){logger$4.print("_createDataChannelSignaling()","recv BasicHandler event: disconnect"),l._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(this.id,a),logger$4.print("_createDataChannelSignaling()","send ping"),c.sendPingSignaling(),c.once("close",(function(){logger$4.print("_createDataChannelSignaling()","recv DataChannelSignaling event: close"),l._onDisconnect()})),c.on(SignalEvent.USER_MESSAGE_RECEIVED_OUTSIDE_ROOM,(function(e){l.emit("onUserMessageReceivedOutsideRoom",{userId:e.from,message:e.msg})})),c.on(SignalEvent.USER_BINARY_MESSAGE_RECEIVED_OUTSIDE_ROOM,(function(e){l.emit("onUserBinaryMessageReceivedOutsideRoom",{userId:e.from,message:e.msg})})),c.on(SignalEvent.USER_DISCONNECTION,(function(){l.emit("onUserDisconnection"),l._clearState()})),c.on(SignalEvent.NODE_CHANGE,(function(e){reportRtcInvokeStatus(l.id,"rtm.nodeChange",stringify$1(e)),Array.isArray(e.nodes)&&e.nodes.length&&(l._iceConfigNode=e.nodes[0]),l._loginResolveCallback&&l._loginRejectCallback?l._login():l._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,RTSMsgReportor.setRtsSessionId(this.id,""),null!==this._reconnectTimer&&(self.clearTimeout(this._reconnectTimer),this._reconnectTimer=null)}}]),l}(),OutsideRoom=function(e){_inherits(o,EnhancedEventEmitter);var t,r,n,i=_createSuper(o);function o(e,t,r){var n,a=r.businessId;return _classCallCheck(this,o),_defineProperty(_assertThisInitialized(n=i.call(this)),"_mediaServerClient",void 0),_defineProperty(_assertThisInitialized(n),"_appId",void 0),_defineProperty(_assertThisInitialized(n),"_reconnectTimer",void 0),_defineProperty(_assertThisInitialized(n),"remoteStreams",void 0),_defineProperty(_assertThisInitialized(n),"_businessId",void 0),n.id=e,n._appId=t,n.remoteStreams=new map2,n._businessId=a,n}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({id:this.id,avSync:!0}),this._businessId&&(this._mediaServerClient.businessId=this._businessId),this._bindEvents(),e.next=5,this._mediaServerClient.connect(this._appId);case 5: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(this.id,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 map2,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=window.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(c,eventemitter3.exports.EventEmitter);var t,r,n,i,o,a,s=_createSuper(c);function c(e){var t;return _classCallCheck(this,c),_defineProperty(_assertThisInitialized(t=s.call(this)),"_audioLevelFetcher",void 0),_defineProperty(_assertThisInitialized(t),"_playbackDeviceTestTimer",void 0),_defineProperty(_assertThisInitialized(t),"_audioElement",void 0),_defineProperty(_assertThisInitialized(t),"_audioTrack",void 0),_defineProperty(_assertThisInitialized(t),"_mediaRecorder",void 0),_defineProperty(_assertThisInitialized(t),"_recoderTimer",void 0),_defineProperty(_assertThisInitialized(t),"_isAudioPlaybackDeviceTesting",!1),_defineProperty(_assertThisInitialized(t),"_isAudioDeviceRecordTesting",!1),_defineProperty(_assertThisInitialized(t),"_audioCaptureAndRecoderResolve",void 0),_defineProperty(_assertThisInitialized(t),"_onAutoplayFailed",void 0),_defineProperty(_assertThisInitialized(t),"_audioPlaybackDeviceId",void 0),t._extensionManager=e,t}return _createClass(c,[{key:"audioTrack",get:function(){return this._audioTrack}},{key:"startAudioPlaybackDeviceTest",value:(a=_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=14;break;case 9:throw e.prev=9,e.t0=e.catch(4),logger$3.print("startAudioPlaybackDeviceTest()","error",e.t0),this.stopAudioPlaybackDeviceTest(),e.t0;case 14:this._startEmitAudioPlaybackDeviceTestVolume(r);case 15:case"end":return e.stop()}}),e,this,[[4,9]])}))),function(e,t){return a.apply(this,arguments)})},{key:"stopAudioPlaybackDeviceTest",value:function(){this._isAudioPlaybackDeviceTesting&&(logger$3.print("stopAudioPlaybackDeviceTest()","Invoke"),this._isAudioPlaybackDeviceTesting=!1,this._stopEmitAudioPlaybackDeviceTestVolume(),this._destroyAudioElement())}},{key:"startAudioDeviceRecordTest",value:(o=_asyncToGenerator(_regeneratorRuntime().mark((function e(t,r,n){var i=this;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(window.MediaRecorder){e.next=2;break}throw new SDKError(ErrorCode.NOT_SUPPORTED,"Your browser does not support MediaRecorder.");case 2:if(!this._isAudioDeviceRecordTesting){e.next=4;break}throw new SDKError(ErrorCode.REPEAT_DEVICE_TEST,"device test cannot be called repeatedly at the same time.");case 4: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"')),i._stopAudioCaptureAndRecoder()}),MAX_RECORDER_DURATION),e.prev=7,this._onAutoplayFailed=r,e.next=11,this._startAudioCaptureAndRecoder(t,null!=n?n:100);case 11:e.next=18;break;case 13:throw e.prev=13,e.t0=e.catch(7),this._isAudioDeviceRecordTesting=!1,delete this._onAutoplayFailed,e.t0;case 18:delete this._audioCaptureAndRecoderResolve;case 19:case"end":return e.stop()}}),e,this,[[7,13]])}))),function(e,t,r){return o.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()),delete this._onAutoplayFailed}},{key:"getRecordTrack",value:function(){return this._audioTrack}},{key:"setSinkId",value:(i=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){var r;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(logger$3.print("setSinkId()","Invoke"),void 0!==HTMLAudioElement.prototype.setSinkId){e.next=3;break}throw new SDKError(ErrorCode.NOT_SUPPORTED,"setSinkId not supported by current browser");case 3:return e.next=5,dd.getDeviceById(t);case 5:if(r=e.sent){e.next=8;break}throw new SDKError(ErrorCode.INVALID_DEVICE_ID,"audio playback device id ".concat(t," is invalid"));case 8:return this._audioPlaybackDeviceId=t,this._setAudioCtxSinkId(),e.abrupt("return",r);case 11:case"end":return e.stop()}}),e,this)}))),function(e){return i.apply(this,arguments)})},{key:"getSinkId",value:function(){return this._audioPlaybackDeviceId}},{key:"destroy",value:function(){logger$3.print("destroy()","Invoke"),_get(_getPrototypeOf(c.prototype),"removeAllListeners",this).call(this),this.stopAudioPlaybackDeviceTest(),this.stopAudioDevicePlayTest()}},{key:"_playAudioFile",value:(n=_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 logger$3.print("_playAudioFile()",concat$2(n="Invoke url=".concat(t,"; loop=")).call(n,r.loop)),e.abrupt("return",new promise((function(e,n){var o=createElement("audio",{attributes:{src:t,crossOrigin:"anonymous"}});i._audioElement=o,o.loop=r.loop,i._audioLevelFetcher=new AudioLevelFetcher(o),o.onplaying=function(){o.onplaying=null,logger$3.print("_playAudioFile()","onplaying"),e()},o.onerror=function(){var e=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){var r,i;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:logger$3.print("_playAudioFile()","onerror",t),i=t.message||(null==o||null===(r=o.error)||void 0===r?void 0:r.message),n(new SDKError(ErrorCode.LOAD_RESOURCES_FAILED,"Failed to play recorded audio"+(i?", reason: ".concat(i):".")));case 3:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),i._setAudioCtxSinkId().then((function(){var e,t;return null===(e=o.play())||void 0===e||null===(t=e.catch)||void 0===t?void 0:t.call(e,(function(e){var t;logger$3.print("_playAudioFile()","autoplay error",e);var r=concat$2(t="Failed to play recorded audio, ".concat(e.name,": ")).call(t,e.message);"NotAllowedError"===e.name&&i._onAutoplayFailed?i._onAutoplayFailed((function(){var e;return promise.all([null===(e=i._audioLevelFetcher)||void 0===e?void 0:e.resume(),o.play()])})):n(new SDKError(ErrorCode.LOAD_RESOURCES_FAILED,r))}))}))})));case 2:case"end":return e.stop()}}),e)}))),function(e,t){return n.apply(this,arguments)})},{key:"_destroyAudioElement",value:function(){this._audioElement&&(logger$3.print("_destroyAudioElement()","Invoke"),this._audioElement.onplaying=null,this._audioElement.onerror=null,this._audioElement.src="",delete this._audioElement,"function"==typeof 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._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:(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 e.next=2,createMicrophoneAudioTrack({},this._extensionManager);case 2:return this._audioTrack=e.sent,this._audioTrack.setVolume(r),n=new MediaStream([this._audioTrack.getTrack("preprocessing")]),logger$3.print("startAudioDeviceRecordTest()","create microphone track success!"),e.abrupt("return",new promise((function(e,r){var o,a;"function"==typeof MediaRecorder.isTypeSupported&&(o=find$2(a=["audio/webm","audio/mp4"]).call(a,(function(e){return MediaRecorder.isTypeSupported(e)})),logger$3.print("startAudioDeviceRecordTest()","use mimeType: ".concat(o))),i._mediaRecorder=new MediaRecorder(n,o?{mimeType:o}:void 0);var s=i._mediaRecorder.mimeType;i._mediaRecorder.ondataavailable=function(){var n=_asyncToGenerator(_regeneratorRuntime().mark((function n(o){var a,c;return _regeneratorRuntime().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(!i._isAudioDeviceRecordTesting){n.next=16;break}return logger$3.print("startAudioDeviceRecordTest()","get recorded file(mimeType: ".concat(s,").")),c=new Blob([o.data],{type:s}),n.prev=3,n.next=6,i._playAudioFile(url.createObjectURL(c),{loop:!1});case 6:n.next=11;break;case 8:return n.prev=8,n.t0=n.catch(3),n.abrupt("return",r(n.t0));case 11:i._startEmitAudioPlaybackDeviceTestVolume(t),null===(a=i._audioElement)||void 0===a||a.addEventListener("ended",(function(){i.stopAudioDevicePlayTest(),e()})),i._audioCaptureAndRecoderResolve=e,n.next=17;break;case 16:e();case 17:case"end":return n.stop()}}),n,null,[[3,8]])})));return function(e){return n.apply(this,arguments)}}(),i._mediaRecorder.onerror=function(e){r(new SDKError(ErrorCode.AUDIO_DEVICE_TEST_FAILED,e.message||"mediaRecorder error"))},i._mediaRecorder.start()})));case 7:case"end":return e.stop()}}),e,this)}))),function(e,t){return r.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}},{key:"_setAudioCtxSinkId",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:if(t=this._audioPlaybackDeviceId){"default"===t&&(t="");try{null===(r=audioContextManager.getAudioContextInstance())||void 0===r||null===(n=r.setSinkId)||void 0===n||n.call(r,t),logger$3.print("setSinkId","ctx.sinkId=".concat(t))}catch(e){logger$3.print("setSinkId",concat$2(i="failed, ".concat(e.name," - ")).call(i,e.message))}}case 2:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})}]),c}(),AudioProfileManager=function(){function e(t){_classCallCheck(this,e),_defineProperty(this,"_roomId",void 0),_defineProperty(this,"_constraints",{}),_defineProperty(this,"_profile",void 0),this._appId=t}return _createClass(e,[{key:"setRoomId",value:function(e){this._roomId=e}},{key:"setAudioProfile",value:function(e){this._profile=e}},{key:"getOpusConfigStr",value:function(){var e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",r=sdkCache.getEngineWebConfig(this._appId,this._roomId||""),n=r.audio_encode,i=this.getConstraints(),o=i.sampleRate,a=i.channelCount,s="number"==typeof o?o:null==o?void 0:o.exact,c="number"==typeof a?a:null==a?void 0:a.exact,l={};t.split(";").forEach((function(e){var t=_slicedToArray(e.split("="),2),r=t[0],n=t[1];r&&n&&(l[r]=n)}));var u=(null==n?void 0:n.bitrate)||this._getConfigByAudioProfile().bitrate;u&&(l.maxaveragebitrate=u);var d=(null==n?void 0:n.enc_sample_rate)||s;d&&(l["sprop-maxcapturerate"]=d);var p=(null==n?void 0:n.playback_rate)||s;return p&&(l.maxplaybackrate=p),(c&&c>1||null!=n&&n.stereo)&&(l["sprop-stereo"]=1,l.stereo=1),null!=n&&n.dtx&&(l.usedtx=1),map$6(e=keys$8(l)).call(e,(function(e){var t;return concat$2(t="".concat(e,"=")).call(t,l[e])})).join(";")}},{key:"updateConstraints",value:function(e){this._constraints=_objectSpread2(_objectSpread2({},this._constraints),e)}},{key:"getConstraints",value:function(){var e=_objectSpread2({},this._constraints),t=sdkCache.getEngineWebConfig(this._appId,this._roomId||"").audio_capture;isUndefined(null==t?void 0:t.sample_rate)||(e.sampleRate=t.sample_rate),isUndefined(null==t?void 0:t.channel)||(e.channelCount=t.channel),isUndefined(null==t?void 0:t.agc)||(e.autoGainControl=t.agc),isUndefined(null==t?void 0:t.ans)||(e.noiseSuppression=t.ans),isUndefined(null==t?void 0:t.aec)||(e.echoCancellation=t.aec);var r=this._getConfigByAudioProfile(),n=r.sampleRate,i=r.channel;return isUndefined(e.sampleRate)&&!isUndefined(n)&&(e.sampleRate=n),isUndefined(e.channelCount)&&!isUndefined(i)&&(e.channelCount=i),e}},{key:"_getConfigByAudioProfile",value:function(){var e={};switch(this._profile){case AudioProfileType.fluent:e.sampleRate=16e3,e.bitrate=24e3;break;case AudioProfileType.standard:e.sampleRate=48e3,e.bitrate=48e3;break;case AudioProfileType.hd:e.sampleRate=48e3,e.bitrate=128e3,e.channel=2;break;case AudioProfileType.standardStereo:e.sampleRate=48e3,e.bitrate=8e4,e.channel=2;break;case AudioProfileType.hdMono:e.sampleRate=48e3,e.bitrate=128e3}return e}}]),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,l,u,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 l=e.sent,logger$2.print("takeSnapshot","success, cost ".concat(Date.now()-s,"ms")),e.abrupt("return",l);case 16:if(!window.ImageCapture){e.next=29;break}if("live"!==(u=new window.ImageCapture(t)).track.readyState||!u.track.enabled||u.track.muted){e.next=29;break}return logger$2.print("takeSnapshot","use ImageCapture"),e.t0=a,e.next=23,u.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)}}(),getDefaultValue=function(){return{url:"",video:{codec:TRANSCODING_VIDEO_CODEC.H264,width:640,height:360,fps:15,gop:2,kBitRate:getKBitRate(640,360,15)},audio:{codec:"AAC",kBitRate:64,sampleRate:48e3,channels:2,AACProfile:AAC_PROFILE.LC},layout:{regions:[],appData:"",backgroundColor:"#000000"}}};function getKBitRate(e,t,r){return e*t<=288e3?r<=15?800:1200:e*t<=864e3?r<=15?1200:1800:e*t<=1152e3?r<=15?1600:2400:e*t<=2592e3?r<=15?2500:3750:r<=15?3300:5e3}function checkRtmpUrl(e){if("string"!=typeof e||!/^rtmps?:\/\//.test(e))throw new SDKError(ErrorCode.INVALID_PARAMS,"Invalid rtmp address")}function checkTranscodeRegions(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];if(null==e||!e.length)throw new SDKError(ErrorCode.INVALID_PARAMS,"regions should not be empty.");var t,r=_createForOfIteratorHelper(e);try{for(r.s();!(t=r.n()).done;){var n=t.value;if("string"!=typeof n.userId)throw new SDKError(ErrorCode.INVALID_PARAMS,"region.userId(".concat(n.userId,") should be a string."));if("boolean"!=typeof n.isScreenStream)throw new SDKError(ErrorCode.INVALID_PARAMS,"region.isScreenStream(".concat(n.isScreenStream,") should be a boolean."))}}catch(e){r.e(e)}finally{r.f()}}function getTranscodeControlMessage(e,t){var r,n,i,o=function(e,r){var n=reduce3(e).call(e,(function(e,t){return null==e?void 0:e[t]}),t),i=reduce3(e).call(e,(function(e,t){return null==e?void 0:e[t]}),getDefaultValue());return n&&r(n)?n:i},a=function(e){return e%2==0?e:e+1},s=a(o(["video","width"],(function(e){return e>=2&&e<=1920}))),c=a(o(["video","height"],(function(e){return e>=2&&e<=1920}))),l=o(["video","fps"],(function(e){return e>=1&&e<=60})),u=(null===(r=t.video)||void 0===r?void 0:r.kBitRate)||0,d=o(["audio","sampleRate"],(function(e){var t;return!!find$2(t=[32e3,44100,48e3]).call(t,(function(t){return t===e||t/1e3===e}))}));return{type:"transcode",action:e,transcodeMeta:{transcode:{url:t.url},control:{protocol:"2.0"},audio:{codec:o(["audio","codec"],(function(e){return"AAC"===e})),bitRate:1e3*o(["audio","kBitRate"],(function(e){return e>=32&&e<=192})),sampleRate:d<100?1e3*d:d,channels:o(["audio","channels"],(function(e){var t;return includes4(t=[1,2]).call(t,e)})),profile:o(["audio","AACProfile"],(function(e){var t;return includes4(t=[AAC_PROFILE.LC,AAC_PROFILE.HEv1,AAC_PROFILE.HEv2]).call(t,e)}))},video:{codec:o(["video","codec"],(function(e){var t;return includes4(t=["H264","H265"]).call(t,e)})),fps:l,gop:o(["video","gop"],(function(e){return e>=1&&e<=5}))*l,bitRate:1e3*(u>=16&&u<=1e4?u:getKBitRate(s,c,l)),width:s,height:c},layout:{canvas:{bgnd:o(["layout","backgroundColor"],(function(e){return/^#([0-9a-fA-F]{6}|[0-9a-fA-F]{3})$/.test(e)}))},regions:(null===(n=t.layout)||void 0===n||null===(i=n.regions)||void 0===i?void 0:map$6(i).call(i,(function(e){var t,r;return{alpha:!e.alpha||+e.alpha>1||+e.alpha<=0?1:+e.alpha,uid:e.userId,zorder:!e.zorder||+e.zorder<0||+e.zorder>100?0:+e.zorder,x:!e.x||+e.x>=1||+e.x<0?0:+e.x,y:!e.y||+e.y>=1||+e.y<0?0:+e.y,w:!e.w||+e.w>1||+e.w<=0?1:+e.w,h:!e.h||+e.h>1||+e.h<=0?1:+e.h,renderMode:e.renderMode&&includes4(t=[1,2,3]).call(t,e.renderMode)?e.renderMode:1,contentControl:e.contentControl&&includes4(r=[0,1,2]).call(r,e.contentControl)?e.contentControl:0,screen:!!e.isScreenStream}})))||[],app_data:o(["layout","appData"],(function(e){return"string"==typeof e}))}}}}function checkStartParams(e){var t;checkRtmpUrl(e.url),checkTranscodeRegions(null===(t=e.layout)||void 0===t?void 0:t.regions)}function checckUpdateParams(e){var t;e.url&&checkRtmpUrl(e.url),checkTranscodeRegions(null===(t=e.layout)||void 0===t?void 0:t.regions)}function getStartParams(e){return getTranscodeControlMessage("started",e)}function getUpdateParams(e){return getTranscodeControlMessage("layoutChanged",e)}var remoteAudioReplayTimer,LiveTranscoding={getDefaultValue:getDefaultValue,checkStartParams:checkStartParams,checckUpdateParams:checckUpdateParams,getStartParams:getStartParams,getUpdateParams:getUpdateParams},replayRemoteAudioWorkaround=function(e){remoteAudioReplayTimer&&clearTimeout(remoteAudioReplayTimer),remoteAudioReplayTimer=setTimeout((function(){var t,r=_createForOfIteratorHelper(e);try{for(r.s();!(t=r.n()).done;){var n=_slicedToArray(t.value,2),i=n[0],o=n[1];null!=i&&startsWith2(i).call(i,"mux")&&o.pause()}}catch(e){r.e(e)}finally{r.f()}var a,s=_createForOfIteratorHelper(e);try{for(s.s();!(a=s.n()).done;){var c=_slicedToArray(a.value,2),l=c[0],u=c[1];null!=l&&startsWith2(l).call(l,"mux")&&u.manuallyPlay()}}catch(e){s.e(e)}finally{s.f()}}),2e3)},__defProp=defineProperty$a,__getOwnPropDesc=getOwnPropertyDescriptor$1,__decorateClass3=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(ve,EnhancedEventEmitter);var t,r,n,i,o,a,s,c,l,u,d,p,_,h,f,m,v,g,y,S,T,$,E,b,I,R,C,A,k,P,O,w,M,D,x,N,L,U,V,B,F,j,G,z,H,K,W,Y,q,X,Z,Q,J,ee,te,re,ne,ie,oe,ae,se,ce,le,ue,de,pe,_e,he,fe,me=_createSuper(ve);function ve(e,t,r){var n;return _classCallCheck(this,ve),_defineProperty(_assertThisInitialized(n=me.call(this)),"monitor",void 0),_defineProperty(_assertThisInitialized(n),"_room",void 0),_defineProperty(_assertThisInitialized(n),"_publicStreamManager",void 0),_defineProperty(_assertThisInitialized(n),"_appId",void 0),_defineProperty(_assertThisInitialized(n),"_businessId",void 0),_defineProperty(_assertThisInitialized(n),"_visibility",!0),_defineProperty(_assertThisInitialized(n),"_localVideoTrack",void 0),_defineProperty(_assertThisInitialized(n),"_localAudioTrack",void 0),_defineProperty(_assertThisInitialized(n),"_localImgVideoTrack",void 0),_defineProperty(_assertThisInitialized(n),"_localImgScreenTrack",void 0),_defineProperty(_assertThisInitialized(n),"_localScreenVideoTrack",void 0),_defineProperty(_assertThisInitialized(n),"_localScreenAudioTrack",void 0),_defineProperty(_assertThisInitialized(n),"_tempMixingAudioTrack",void 0),_defineProperty(_assertThisInitialized(n),"_localAudioVolume",100),_defineProperty(_assertThisInitialized(n),"_localScreenAudioVolume",100),_defineProperty(_assertThisInitialized(n),"_remoteAudioVolume",new map2),_defineProperty(_assertThisInitialized(n),"_remoteScreenAudioVolume",new map2),_defineProperty(_assertThisInitialized(n),"_publicAudioVolume",new map2),_defineProperty(_assertThisInitialized(n),"_videoPlayer",void 0),_defineProperty(_assertThisInitialized(n),"_screenPlayer",void 0),_defineProperty(_assertThisInitialized(n),"_remoteVideoPlayer",new map2),_defineProperty(_assertThisInitialized(n),"_remoteScreenPlayer",new map2),_defineProperty(_assertThisInitialized(n),"_remoteAudioPlayer",new map2),_defineProperty(_assertThisInitialized(n),"_remoteScreenAudioPlayer",new map2),_defineProperty(_assertThisInitialized(n),"_publicStreamAudioPlayer",new map2),_defineProperty(_assertThisInitialized(n),"_publicStreamVideoPlayer",new map2),_defineProperty(_assertThisInitialized(n),"_publicStreamIds",new map2),_defineProperty(_assertThisInitialized(n),"_roomConfig",void 0),_defineProperty(_assertThisInitialized(n),"_videoStreamConstraints",defaultVideoEncoderConfig),_defineProperty(_assertThisInitialized(n),"_audioStreamConstraints",{}),_defineProperty(_assertThisInitialized(n),"_enableSimulcast",!1),_defineProperty(_assertThisInitialized(n),"_videoStreamEncodeConfig",[defaultVideoEncoderConfig]),_defineProperty(_assertThisInitialized(n),"_screenStreamEncodeConfig",[defaultScreenEncoderConfig]),_defineProperty(_assertThisInitialized(n),"_dummyMainImage",void 0),_defineProperty(_assertThisInitialized(n),"_dummyScreenImage",void 0),_defineProperty(_assertThisInitialized(n),"_trackSourceType",void 0),_defineProperty(_assertThisInitialized(n),"_liveTranscodeConfig",void 0),_defineProperty(_assertThisInitialized(n),"_useCloudProxy",void 0),_defineProperty(_assertThisInitialized(n),"_startCloudProxyTimestamp",void 0),_defineProperty(_assertThisInitialized(n),"_localVideoDeviceId",void 0),_defineProperty(_assertThisInitialized(n),"_localAudioDeviceId",void 0),_defineProperty(_assertThisInitialized(n),"_pauseAllSubscribeState",{audio:void 0,video:void 0,resumeStreamIds:{}}),_defineProperty(_assertThisInitialized(n),"_audioVolumeIndicationTimer",void 0),_defineProperty(_assertThisInitialized(n),"_dummyMainTimer",void 0),_defineProperty(_assertThisInitialized(n),"_dummyScreenTimer",void 0),_defineProperty(_assertThisInitialized(n),"_audioPropertiesReportTimer",null),_defineProperty(_assertThisInitialized(n),"_mirrorType",MirrorType.MIRROR_TYPE_RENDER),_defineProperty(_assertThisInitialized(n),"_audioMixingManager",void 0),_defineProperty(_assertThisInitialized(n),"_pubLock",void 0),_defineProperty(_assertThisInitialized(n),"_rtmClient",void 0),_defineProperty(_assertThisInitialized(n),"_messageStatisticsObserver",void 0),_defineProperty(_assertThisInitialized(n),"_tempRoomInfo",void 0),_defineProperty(_assertThisInitialized(n),"_originIceConfigRequestUrls",void 0),_defineProperty(_assertThisInitialized(n),"_originConfigServerUrls",void 0),_defineProperty(_assertThisInitialized(n),"_originLogServerUrl",void 0),_defineProperty(_assertThisInitialized(n),"_extensionManager",void 0),_defineProperty(_assertThisInitialized(n),"_audioDeviceManager",void 0),_defineProperty(_assertThisInitialized(n),"_audioProfileManager",void 0),_defineProperty(_assertThisInitialized(n),"_remoteVideoConfig",new map2),_defineProperty(_assertThisInitialized(n),"_userPriorityMap",new map2),_defineProperty(_assertThisInitialized(n),"_subscribeFallbackOption",void 0),_defineProperty(_assertThisInitialized(n),"_cameraCapturing",!1),_defineProperty(_assertThisInitialized(n),"_interruptCameraCapture",!1),_defineProperty(_assertThisInitialized(n),"_micCapturing",!1),_defineProperty(_assertThisInitialized(n),"_interruptMicCapture",!1),_defineProperty(_assertThisInitialized(n),"_avSync",!0),_defineProperty(_assertThisInitialized(n),"_config",void 0),_defineProperty(_assertThisInitialized(n),"_needClosePreTrack",!1),_defineProperty(_assertThisInitialized(n),"_updateMixAudioTrack",function(){var e=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){var r,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()"),n._localAudioTrack){e.next=5;break}return t&&(n._tempMixingAudioTrack={track:t,type:i}),e.abrupt("return");case 5:if(t?(n._localAudioTrack.mixType=i,n._localAudioTrack.mixedAudioTrack=t):(delete n._localAudioTrack.mixType,delete n._localAudioTrack.mixedAudioTrack),null===(r=n._room)||void 0===r||!r.hasPublished){e.next=9;break}return e.next=9,n._updatePublish();case 9:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}()),_defineProperty(_assertThisInitialized(n),"_onAudioMixingMessage",(function(e){n.safeEmit(EngineEventsTypes.onAudioMixingStateChanged,e)})),_defineProperty(_assertThisInitialized(n),"_onAudioMixingAutoplayFailed",(function(e){n.safeEmit(EngineEventsTypes.onAutoplayFailed,e)})),n.id=t,n._appId=e,n._pubLock=new PromiseLock("pubLock"),n._addDeviceEventHandler(),n._extensionManager=new ExtensionManager(t),n._audioDeviceManager=new AudioDeviceManager(n._extensionManager),n._audioMixingManager=new AudioMixingManager({getLocalAudioTrack:function(){return n._localAudioTrack},updateLocalAudioTrack:n._updateMixAudioTrack,emitMessage:n._onAudioMixingMessage,onAutoPlayFailed:n._onAudioMixingAutoplayFailed},t),n._audioProfileManager=new AudioProfileManager(e),window.__rtc_engine__=_assertThisInitialized(n),window["__rtc_engine__".concat(Math.floor(100*Math.random()+1))]=_assertThisInitialized(n),n._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},n._config=r,n._rtmClient=new RTMClient(t,e),n._handleRTMClient(n._rtmClient),n._useCloudProxy=!1,n._handleAudioDeviceManager(),n._messageStatisticsObserver=new MessageStatisticsObserver(t),n.monitor=getMonitor(t),RTSMsgReportor.createRTSMsgReportor(n.id),n._getServerConfig(),n}return _createClass(ve,[{key:"appId",get:function(){return this._appId},set:function(e){this._appId=e}},{key:"updateToken",value:(fe=_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("updateToken()","token: %s",t),checkString(t,"token"),!this.waitForNewToken||!this._tempRoomInfo){e.next=8;break}return n=this._tempRoomInfo,i=n.config,o=n.userInfo,a=n.roomId,delete this._tempRoomInfo,e.next=7,this.joinRoom(t,a,o,i);case 7:return e.abrupt("return",e.sent);case 8:if(this._room){e.next=10;break}throw new SDKError(ErrorCode.UPDATE_TOKEN_BEFORE_JOIN,"update token before join room");case 10:return e.next=12,null===(r=this._room)||void 0===r?void 0:r.updateToken(t);case 12:case"end":return e.stop()}}),e,this)}))),function(e){return fe.apply(this,arguments)})},{key:"setVideoCaptureDevice",value:(he=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){var r,n,i,o=this;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=assignIn$1({},this._videoStreamConstraints),"user"===t||"environment"===t||"left"===t||"right"===t?(delete r.deviceId,r.facingMode=t):r.deviceId={exact:t},isAndroid&&chromeVersion&&chromeVersion>=85&&chromeVersion<=91&&(null===(n=this._videoPlayer)||void 0===n||n.removeTrack()),this._needClosePreTrack&&(this._removeLocalTrackEvents(this._localVideoTrack),this._localVideoTrack.close(),delete this._localVideoTrack),logger$1.print("setVideoCaptureDevice()","start createCameraVideoTrack..."),e.next=12,createCameraVideoTrack(r,this._extensionManager).catch((function(e){if(o._localVideoTrack&&!o._localVideoTrack.dummy)return logger$1.print("setVideoCaptureDevice()","createCameraVideoTrack failed, stop pre VideoTrack."),o._removeLocalTrackEvents(o._localVideoTrack),o._localVideoTrack.close(),delete o._localVideoTrack,createCameraVideoTrack(r,o._extensionManager).then((function(e){return o._needClosePreTrack=!0,e})).catch(_asyncToGenerator(_regeneratorRuntime().mark((function t(){var r;return _regeneratorRuntime().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return logger$1.print("setVideoCaptureDevice()","createCameraVideoTrack failed, rollback."),t.next=3,createCameraVideoTrack(o._videoStreamConstraints,o._extensionManager);case 3:throw r=t.sent,o._switchTrack(r),e;case 6:case"end":return t.stop()}}),t)}))));throw e}));case 12:return i=e.sent,logger$1.print("setVideoCaptureDevice()","createCameraVideoTrack success."),this._videoStreamConstraints=r,this._localVideoTrack&&(this._removeLocalTrackEvents(this._localVideoTrack),this._localVideoTrack.close()),e.next=18,this._switchTrack(i);case 18:case"end":return e.stop()}}),e,this)}))),function(e){return he.apply(this,arguments)})},{key:"setAudioCaptureDevice",value:(_e=_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 this._audioProfileManager.updateConstraints({deviceId:{exact:t}}),this._localAudioTrack.close(),this._removeLocalTrackEvents(this._localAudioTrack),e.prev=8,this._micCapturing=!0,e.next=12,createMicrophoneAudioTrack(this._audioProfileManager.getConstraints(),this._extensionManager);case 12:if(n=e.sent,!this._interruptMicCapture){e.next=17;break}return this._interruptMicCapture=!1,n.close(),e.abrupt("return");case 17:if(this._initLocalTrackEvents(n),this._localAudioTrack=n,this._localAudioTrack.setVolume(this._localAudioVolume),this._room){e.next=22;break}return e.abrupt("return");case 22:if(null===(r=this._room)||void 0===r||!r.hasPublished){e.next=25;break}return e.next=25,this._updatePublish();case 25:return e.prev=25,this._micCapturing=!1,e.finish(25);case 28:case"end":return e.stop()}}),e,this,[[8,,25,28]])}))),function(e){return _e.apply(this,arguments)})},{key:"_addDeviceEventHandler",value:function(){dd.on(EngineEventsTypes.onVideoDeviceStateChanged,this._onVideoDeviceStateChange.bind(this)),dd.on(EngineEventsTypes.onAudioDeviceStateChanged,this._onAudioDeviceStateChange.bind(this))}},{key:"_addHandlerEventHandler",value:function(){var e,t,r,n,i,o,a,s,c,l,u,d,p,_,h,f,m,v,g,y,S,T,$,E,b,I,R,C,A,k,P,O=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===(l=this._room)||void 0===l||l.on(SignalEvent.ON_USER_TOKEN_WILL_EXPIRE,this._onUserTokenWillExpire.bind(this)),null===(u=this._room)||void 0===u||u.on(SignalEvent.POST_PROCESSING_MESSAGE,(function(e){"2.0"===e.protocol?O._onStreamMixingEvent({error:e.error,event:e.eventType,message:e.message}):"publicStreamCallback"===e.type?O._onPushPublicStreamResult(e):"transcodeStatusCallback"===e.type&&O._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===(h=this._room)||void 0===h||h.on(RoomEvent.REMOVE_PUSH_TRACK,this._onRemovePushTrack.bind(this)),null===(f=this._room)||void 0===f||f.on(RoomEvent.ON_PUBLISH_RESULT,(function(e){var t;null!==(t=O._room)&&void 0!==t&&t._roomConfig.isAutoPublish&&O.safeEmit(EngineEventsTypes.onAutoPublishResult,e)})),null===(m=this._room)||void 0===m||m.on(RoomEvent.ON_REMOTE_STREAM_STATS,(function(e){O.safeEmit(EngineEventsTypes.onRemoteStreamStats,e)})),null===(v=this._room)||void 0===v||v.on(RoomEvent.ON_LOCAL_STREAM_STATS,(function(e){O.safeEmit(EngineEventsTypes.onLocalStreamStats,e)})),null===(g=this._room)||void 0===g||g.on(RoomEvent.ON_SUBTITLE_STATE_CHANGED,(function(e){O.safeEmit(EngineEventsTypes.onSubtitleStateChanged,e)})),null===(y=this._room)||void 0===y||y.on(RoomEvent.ON_SUBTITLE_MESSAGE_RECEIVED,(function(e){O.safeEmit(EngineEventsTypes.onSubtitleMessageReceived,e)})),null===(S=this._room)||void 0===S||S.on(RoomEvent.ON_USER_PUBLISH_STATE_CHANGE,this._onUserPublishStateChange.bind(this)),null===(T=this._room)||void 0===T||T.on(RoomEvent.ON_USER_START_AUDIO_CAPTURE,(function(e,t){var r=e.userId;O._updateAudioPlayerState(t),O.safeEmit(EngineEventsTypes.onUserStartAudioCapture,{userId:r})})),null===($=this._room)||void 0===$||$.on(RoomEvent.ON_USER_STOP_AUDIO_CAPTURE,(function(e){var t=e.userId;O.safeEmit(EngineEventsTypes.onUserStopAudioCapture,{userId:t})})),null===(E=this._room)||void 0===E||E.on(RoomEvent.ON_USER_START_VIDEO_CAPTURE,(function(e){var t=e.userId;O.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;O.safeEmit(EngineEventsTypes.onUserStopVideoCapture,{userId:t})})),null===(I=this._room)||void 0===I||I.on(RoomEvent.ON_SEI_MESSAGED_RECEIVED,(function(e){O.safeEmit(EngineEventsTypes.onSEIMessageReceived,e)})),null===(R=this._room)||void 0===R||R.on(RoomEvent.ON_REMOTE_VIDEO_SIZE_CHANGED,(function(e,t){O.safeEmit(EngineEventsTypes.onRemoteVideoSizeChanged,e,t)})),null===(C=this._room)||void 0===C||C.on(RoomEvent.ON_SIMULCAST_SUBSCRIBE_FALLBACK,(function(e){return O.safeEmit(EngineEventsTypes.onSimulcastSubscribeFallback,e)})),null===(A=this._room)||void 0===A||A.on(RoomEvent.RECONNECT_FAILED,(function(){O.safeEmit(EngineEventsTypes.onError,{errorCode:ErrorCode.RECONNECT_FAILED})})),null===(k=this._room)||void 0===k||k.on(RoomEvent.ON_VIDEO_STREAM_BANNED,(function(e){O.safeEmit(EngineEventsTypes.onVideoStreamBanned,{uid:e.uid,banned:e.banned})})),null===(P=this._room)||void 0===P||P.on(RoomEvent.ON_AUDIO_STREAM_BANNED,(function(e){O.safeEmit(EngineEventsTypes.onAudioStreamBanned,{uid:e.uid,banned:e.banned})}))}},{key:"safeEmit",value:function(e){for(var t,r,n=arguments.length,i=new Array(n>1?n-1:0),o=1;o<n;o++)i[o-1]=arguments[o];return isReportCallback(e)&&reportRtcSdkCallback(this.id,e,i),(t=_get(_getPrototypeOf(ve.prototype),"safeEmit",this)).call.apply(t,concat$2(r=[this,e]).call(r,i))}},{key:"_removeHandlerEventHandler",value:function(){var e;null===(e=this._room)||void 0===e||e.removeAllListeners()}},{key:"connect",value:(pe=_asyncToGenerator(_regeneratorRuntime().mark((function e(){return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._room){e.next=2;break}return e.abrupt("return",!1);case 2:return this._room=new Room({isAutoPublish:!0,isAutoSubscribeAudio:!0,isAutoSubscribeVideo:!0,roomProfileType:RoomProfileType.communication},{id:this.id,audioProfileManager:this._audioProfileManager,streamRTT:{},subscribeFallbackOption:this._subscribeFallbackOption,userPriority:this._userPriorityMap,avSync:this._avSync}),this._addHandlerEventHandler(),e.next=6,this._room.connect(this._appId);case 6:case"end":return e.stop()}}),e,this)}))),function(){return pe.apply(this,arguments)})},{key:"joinRoom",value:(de=_asyncToGenerator(_regeneratorRuntime().mark((function e(t,r,n,i){var o,a,s,c,l,u,d;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),checkRoomConfig(i=assignIn$1({isAutoPublish:!0,isAutoSubscribeAudio:!0,isAutoSubscribeVideo:!0,roomProfileType:RoomProfileType.communication},i)),(null===(o=this._room)||void 0===o?void 0:o.connectionState)!==MediaConnectionState.CONNECTED){e.next=8;break}throw new SDKError(ErrorCode.REPEAT_JOIN,"Already joined");case 8:return this._room||(this._room=new Room(i,{id:this.id,audioProfileManager:this._audioProfileManager,streamRTT:{},subscribeFallbackOption:this._subscribeFallbackOption,userPriority:this._userPriorityMap,avSync:this._avSync}),this._addHandlerEventHandler()),this._room.roomConfig=i,a=this._liveTranscodeConfig&&LiveTranscoding.getStartParams(this._liveTranscodeConfig),s=_objectSpread2(_objectSpread2({},n),{},{businessId:this._businessId,role:this._visibility?UserRole.NORMAL_USER:UserRole.SILENT_USER}),e.prev=12,this._useCloudProxy&&(this._startCloudProxyTimestamp=Date.now()),checkSourceLanguage(s),e.next=17,this._room.join(this._appId,r,t,s,a,this._useCloudProxy,null===(c=this._config)||void 0===c?void 0:c.expectedIDC);case 17:return u=e.sent,this._roomConfig=i,this._audioProfileManager.setRoomId(r),this._tempRoomInfo&&delete this._tempRoomInfo,null!==(l=i)&&void 0!==l&&l.isAutoPublish&&(this._visibility?this._updatePublish({invokeByJoinRoom:!0,mediaType:MediaType.AUDIO_AND_VIDEO}):this.safeEmit(EngineEventsTypes.onAutoPublishResult,{isScreen:!1,state:PublishState.PUBLISH_FAIL})),RTSMsgReportor.setRoomId(this.id,r),RTSMsgReportor.setUserId(this.id,n.userId),e.abrupt("return",u);case 27:throw e.prev=27,e.t0=e.catch(12),e.t0.code===ErrorCode.INVALID_TOKEN&&(this._tempRoomInfo={config:i,roomId:r,userInfo:s}),null===(d=this._room)||void 0===d||d.destroy(),e.t0;case 32:case"end":return e.stop()}}),e,this,[[12,27]])}))),function(e,t,r,n){return de.apply(this,arguments)})},{key:"leaveRoom",value:(ue=_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._audioProfileManager.setRoomId(),this._liveTranscodeConfig&&this.stopLiveTranscoding(),this._room=void 0,this._remoteAudioPlayer.forEach((function(e){return e.destroy()})),this._remoteAudioPlayer=new map2,this._remoteScreenAudioPlayer.forEach((function(e){return e.destroy()})),this._remoteScreenAudioPlayer=new map2,this._remoteScreenPlayer.forEach((function(e){return e.destroy()})),this._remoteScreenPlayer=new map2,this._remoteVideoPlayer.forEach((function(e){return e.destroy()})),this._remoteVideoPlayer=new map2,this._roomConfig=void 0,this._publicStreamIds=new map2,RTSMsgReportor.setRoomId(this.id,""),RTSMsgReportor.setUserId(this.id,"");case 24:case"end":return e.stop()}}),e,this)}))),function(){return ue.apply(this,arguments)})},{key:"destroy",value:function(){var e,t,r;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._videoStreamEncodeConfig=[defaultVideoEncoderConfig],this._screenStreamEncodeConfig=[defaultScreenEncoderConfig],this._pauseAllSubscribeState={audio:void 0,video:void 0,resumeStreamIds:{}},this._messageStatisticsObserver.destroy(),this.monitor.destroy(),RTSMsgReportor.destroyRTSMsgReportor(this.id),clearInterval(this._audioVolumeIndicationTimer),clearInterval(this._dummyMainTimer),clearInterval(this._dummyScreenTimer),this._audioVolumeIndicationTimer=void 0,this._stopAudioPropertiesReport(),this._localAudioTrack&&(this._removeLocalTrackEvents(this._localAudioTrack),this._localAudioTrack.close(),this._localAudioTrack=void 0),this._localVideoTrack&&(this._removeLocalTrackEvents(this._localVideoTrack),this._localVideoTrack.close(),this._localVideoTrack=void 0),this._localScreenAudioTrack&&(this._removeLocalTrackEvents(this._localScreenAudioTrack),this._localScreenAudioTrack.close(),this._localScreenAudioTrack=void 0),this._localScreenVideoTrack&&(this._removeLocalTrackEvents(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 map2,this._remoteScreenAudioPlayer.forEach((function(e){return e.destroy()})),this._remoteScreenAudioPlayer=new map2,this._remoteScreenPlayer.forEach((function(e){return e.destroy()})),this._remoteScreenPlayer=new map2,this._remoteVideoPlayer.forEach((function(e){return e.destroy()})),this._remoteVideoPlayer=new map2,this._publicStreamAudioPlayer.forEach((function(e){return e.destroy()})),this._publicStreamAudioPlayer=new map2,this._publicStreamVideoPlayer.forEach((function(e){return e.destroy()})),this._publicStreamVideoPlayer=new map2,this._roomConfig=void 0,this._audioMixingManager.destroy(),this._rtmClient.destroy(),null===(r=this._publicStreamManager)||void 0===r||r.destroy(),this._publicStreamIds=new map2,this._audioDeviceManager.destroy(),this._remoteVideoConfig=new map2,this._userPriorityMap.clear(),this._extensionManager.destroy(),this._cameraCapturing=!1,this._micCapturing=!1,this._interruptCameraCapture=!1,this._interruptMicCapture=!1,this._avSync=!0,this._localAudioVolume=100,this._localScreenAudioVolume=100,this._remoteAudioVolume.clear(),this._remoteScreenAudioVolume.clear(),this._publicAudioVolume.clear()}},{key:"publishStream",value:(le=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(logger$1.print("publishStream()","mediaType: %o",t),this._checkMediaType(t),this._assertNotInRoom(),!videoInMediaType(t)||this._localVideoTrack||!this._localImgVideoTrack){e.next=7;break}return e.next=6,createDummyVideoLocalTrack(this._localImgVideoTrack,this._extensionManager);case 6:this._localVideoTrack=e.sent;case 7:return e.next=9,this._updatePublish({mediaType:t});case 9:case"end":return e.stop()}}),e,this)}))),function(e){return le.apply(this,arguments)})},{key:"unpublishStream",value:(ce=_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 ce.apply(this,arguments)})},{key:"publishScreen",value:(se=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(logger$1.print("publishScreen()","mediaType: %o",t),this._checkMediaType(t),this._assertNotInRoom(),e.prev=3,!videoInMediaType(t)||this._localScreenVideoTrack||!this._localImgScreenTrack){e.next=8;break}return e.next=7,createDummyScreenVideoLocalTrack(this._localImgScreenTrack,this._extensionManager);case 7:this._localScreenVideoTrack=e.sent;case 8:return e.next=10,this._updateScreenPublish({mediaType:t,pubState:PubState.PUB});case 10:e.next=19;break;case 12:if(e.prev=12,e.t0=e.catch(3),!(e.t0 instanceof SDKError)){e.next=18;break}throw e.t0;case 18:throw new SDKError(ErrorCode.UNEXPECTED_ERROR,"unexpected error",e.t0);case 19:case"end":return e.stop()}}),e,this,[[3,12]])}))),function(e){return se.apply(this,arguments)})},{key:"unpublishScreen",value:(ae=_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 ae.apply(this,arguments)})},{key:"subscribeStream",value:(oe=_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 oe.apply(this,arguments)})},{key:"_subscribe",value:(ie=_asyncToGenerator(_regeneratorRuntime().mark((function e(t,r,n){var i,o,a,s,c,l,u,d,p,_,h,f,m,v,g,y;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._checkMediaType(n),this._assertNotInRoom(),n!==MediaType.AUDIO||null===(i=this._room)||void 0===i||!i.multiChatMode){e.next=5;break}return logger$1.print("subscribeStream()","due to multiChatMode return"),e.abrupt("return");case 5:if(l=this._room.remoteStreams.get(r),u=null==l?void 0:find$2(l).call(l,(function(e){return e.isScreen===t}))){e.next=9;break}throw new SDKError(ErrorCode.STREAM_NOT_EXIST,"stream not exist");case 9:return d=this._pauseAllSubscribeState.audio,p=this._pauseAllSubscribeState.video,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.hasSubscribed,h=this._remoteVideoConfig.get(r)||(null===(o=this._roomConfig)||void 0===o?void 0:o.remoteVideoConfig),u.originalMediaType=n,e.next=19,this._room.subscribe(u,n,h);case 19:audioInMediaType(n)&&this._updateAudioPlayerState(u),videoInMediaType(n)&&this._updateVideoPlayerState(u),f=0,m=0,d!==this._pauseAllSubscribeState.audio&&(this._pauseAllSubscribeState.audio?f|=MediaType.AUDIO:m|=MediaType.AUDIO),p!==this._pauseAllSubscribeState.video&&(this._pauseAllSubscribeState.video?f|=MediaType.VIDEO:m|=MediaType.VIDEO),f&&this.pauseAllSubscribedStream(f),m&&this.resumeAllSubscribedStream(m),this._pauseAllSubscribeState.resumeStreamIds[u.streamId]=u.streamId,!t&&(null!==(a=this._roomConfig)&&void 0!==a&&a.isAutoSubscribeAudio||null!==(s=this._roomConfig)&&void 0!==s&&s.isAutoSubscribeVideo)&&(u.audioTrack||u.videoTrack)&&(v={userId:r,isScreen:!1,state:SubscribeState.SUBSCRIBE_SUCC},this.safeEmit(EngineEventsTypes.onAutoSubscribeResult,v)),null!==(c=this._room)&&void 0!==c&&c.multiChatMode||_||!audioInMediaType(n)||!u.hasAudio||null===(g=u.observer)||void 0===g||g.setSubscribeAudio(!0),!_&&videoInMediaType(n)&&u.hasVideo&&(null===(y=u.observer)||void 0===y||y.setSubscribeVideo(!0));case 31:case"end":return e.stop()}}),e,this)}))),function(e,t,r){return ie.apply(this,arguments)})},{key:"unsubscribeStream",value:(ne=_asyncToGenerator(_regeneratorRuntime().mark((function e(t,r){return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:logger$1.print("unsubscribeStream()","userId: %o, mediaType: %o",t,r),this._unsubscribe(!1,t,r);case 2:case"end":return e.stop()}}),e,this)}))),function(e,t){return ne.apply(this,arguments)})},{key:"subscribeScreen",value:(re=_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 re.apply(this,arguments)})},{key:"unsubscribeScreen",value:(te=_asyncToGenerator(_regeneratorRuntime().mark((function e(t,r){return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:logger$1.print("unsubscribeScreen() userId: %o, mediaType: %o",t,r),this._unsubscribe(!0,t,r);case 2:case"end":return e.stop()}}),e,this)}))),function(e,t){return te.apply(this,arguments)})},{key:"_unsubscribe",value:function(e,t,r,n){var i,o=this;if(this._checkMediaType(r),this._assertNotInRoom(),r!==MediaType.AUDIO||null===(i=this._room)||void 0===i||!i.multiChatMode){var a=this._room.remoteStreams.get(t),s=null==a?void 0:find$2(a).call(a,(function(t){return t.isScreen===e}));if(null==s||!s.hasSubscribed)throw new SDKError(ErrorCode.STREAM_NOT_EXIST,"stream not exist");if(isAndroid&&chromeVersion&&chromeVersion>=85&&chromeVersion<=91&&r!==MediaType.AUDIO)(e?this._remoteScreenPlayer.get(t):this._remoteVideoPlayer.get(t)).stop();return this._room.unsubscribe(s,r).then((function(){n||delete o._pauseAllSubscribeState.resumeStreamIds[s.streamId]}))}logger$1.print("subscribeStream()","due to multiChatMode return")}},{key:"setRemoteVideoConfig",value:(ee=_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 ee.apply(this,arguments)})},{key:"startVideoCapture",value:(J=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){var r,n,i,o,a,s,c,l,u,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._trackSourceType.video!==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._cameraCapturing||this._localVideoTrack&&!this._localVideoTrack.dummy)){e.next=8;break}throw new SDKError(ErrorCode.REPEAT_CAPTURE,"Has already capture");case 8: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=11,this._cameraCapturing=!0,e.next=15,createCameraVideoTrack(i,this._extensionManager);case 15:if(s=e.sent,!this._interruptCameraCapture){e.next=21;break}throw this._interruptCameraCapture=!1,this._removeLocalTrackEvents(s),s.close(),new SDKError(ErrorCode.INTERRUPT,"interrupt by stopVideoCapture");case 21:if(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(),l={width:o.width,height:o.height},this._localVideoTrack.resolution=l,setTimeout((function(){return d.safeEmit(EngineEventsTypes.onLocalVideoSizeChanged,{streamIndex:StreamIndex.STREAM_INDEX_MAIN,info:l})}))),this._room){e.next=28;break}return e.abrupt("return",o);case 28:return e.prev=28,this._cameraCapturing=!1,e.finish(28);case 31:return u=this._room._roomConfig.isAutoPublish,(this._room.hasPublished||u)&&(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 35:case"end":return e.stop()}}),e,this,[[11,,28,31]])}))),function(e){return J.apply(this,arguments)})},{key:"stopVideoCapture",value:(Q=_asyncToGenerator(_regeneratorRuntime().mark((function e(){var t,r,n,i,o,a,s;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(),this._localVideoTrack&&(this._localVideoTrack.dummy||((a=this._extensionManager.getPluginByName(RTCExtensionType.PRE_PROCESSING,"RTCBeautyExtension"))&&a.emit("stop"),this._removeLocalTrackEvents(this._localVideoTrack),this._localVideoTrack.close(),this._localImgVideoTrack?(null===(s=this._localVideoTrack)||void 0===s||s.setTrack(this._localImgVideoTrack,this._extensionManager),this._localVideoTrack.dummy=!0):this._localVideoTrack=void 0)),this._room){e.next=11;break}return e.abrupt("return");case 11:if(null===(r=this._room)||void 0===r||!r.hasPublished){e.next=14;break}return e.next=14,this._updatePublish();case 14:null===(n=this._room)||void 0===n||null===(i=n.localStream)||void 0===i||null===(o=i.observer)||void 0===o||o.setEnableVideo(!1);case 15:case"end":return e.stop()}}),e,this)}))),function(){return Q.apply(this,arguments)})},{key:"startAudioCapture",value:(Z=_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(logger$1.print("startAudioCapture()","deviceId: $o",t),isEmpty(t)||checkString(t,"deviceId"),t=t||this._localAudioDeviceId,this._localAudioDeviceId=t,this._trackSourceType.audio!==AudioSourceType.AUDIO_SOURCE_TYPE_EXTERNAL){e.next=6;break}throw new SDKError(ErrorCode.STREAM_TYPE_NOT_MATCH,"setAudioSourceType as internal first");case 6:if(!this._micCapturing&&!this._localAudioTrack){e.next=8;break}throw new SDKError(ErrorCode.REPEAT_CAPTURE,"Has already capture");case 8:return t&&this._audioProfileManager.updateConstraints({deviceId:{exact:t}}),e.prev=9,this._micCapturing=!0,e.next=13,createMicrophoneAudioTrack(this._audioProfileManager.getConstraints(),this._extensionManager);case 13:if(i=e.sent,!this._interruptMicCapture){e.next=19;break}throw this._interruptMicCapture=!1,this._removeLocalTrackEvents(i),i.close(),new SDKError(ErrorCode.INTERRUPT,"interrupt by stopAudioCapture");case 19:if(this._initLocalTrackEvents(i),this._localAudioTrack=i,this._localAudioTrack.setVolume(this._localAudioVolume),this._tempMixingAudioTrack&&(this._localAudioTrack.mixType=this._tempMixingAudioTrack.type,this._localAudioTrack.mixedAudioTrack=this._tempMixingAudioTrack.track,delete this._tempMixingAudioTrack),this._room){e.next=25;break}return e.abrupt("return");case 25:return e.prev=25,this._micCapturing=!1,e.finish(25);case 28:o=this._room._roomConfig.isAutoPublish,(this._room.hasPublished||o)&&(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 31:case"end":return e.stop()}}),e,this,[[9,,25,28]])}))),function(e){return Z.apply(this,arguments)})},{key:"stopAudioCapture",value:(X=_asyncToGenerator(_regeneratorRuntime().mark((function e(){var t,r;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(this._trackSourceType.audio!==AudioSourceType.AUDIO_SOURCE_TYPE_EXTERNAL){e.next=7;break}throw new SDKError(ErrorCode.STREAM_TYPE_NOT_MATCH,"setAudioSourceType as internal first");case 7:if(this._localAudioTrack&&(this._removeLocalTrackEvents(this._localAudioTrack),this._localAudioTrack.close()),this._localAudioTrack=void 0,this._audioMixingManager.stopAll(),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===(t=this._room.localStream)||void 0===t||null===(r=t.observer)||void 0===r||r.setEnableAudio(!1);case 16:case"end":return e.stop()}}),e,this)}))),function(){return X.apply(this,arguments)})},{key:"getAudioMixingManager",value:function(){return logger$1.print("getAudioMixingManager()","invoke"),this._audioMixingManager}},{key:"startScreenCapture",value:(q=_asyncToGenerator(_regeneratorRuntime().mark((function e(){var t,r,n,i,o,a,s,c,l,u,d,p,_,h=this,f=arguments;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(o=f.length>0&&void 0!==f[0]?f[0]:{},logger$1.print("startScreenCapture()","config: %o",o),a=o.enableAudio,s=void 0!==a&&a,this._trackSourceType.screenVideo!==VideoSourceType.VIDEO_SOURCE_TYPE_EXTERNAL){e.next=5;break}throw new SDKError(ErrorCode.STREAM_TYPE_NOT_MATCH,"setVideoSourceType as internal first");case 5:if(this._trackSourceType.screenAudio!==AudioSourceType.AUDIO_SOURCE_TYPE_EXTERNAL){e.next=7;break}throw new SDKError(ErrorCode.STREAM_TYPE_NOT_MATCH,"setAudioSourceType as internal first");case 7:return e.next=9,createScreenTracks(s,this._extensionManager,this._screenStreamEncodeConfig[0]);case 9:if(c=e.sent,l=_slicedToArray(c,2),u=l[0],null==(d=l[1])||d.setVolume(this._localScreenAudioVolume),this._localScreenVideoTrack&&!this._localScreenVideoTrack.dummy&&(this._removeLocalTrackEvents(this._localScreenVideoTrack),this._localScreenVideoTrack.close()),null===(t=this._localScreenAudioTrack)||void 0===t||t.close(),delete this._localScreenAudioTrack,this._localScreenVideoTrack=u,null!==(r=this._screenStreamEncodeConfig[0])&&void 0!==r&&r.contentHint&&u.setContentHint(null===(p=this._screenStreamEncodeConfig[0])||void 0===p?void 0:p.contentHint),(_=null==u?void 0:u.getTrack())&&setTimeout((function(){var e=_.getSettings(),t={width:e.width,height:e.height};u.resolution=t,h.safeEmit(EngineEventsTypes.onLocalVideoSizeChanged,{streamIndex:StreamIndex.STREAM_INDEX_SCREEN,info:{width:e.width,height:e.height}})}),500),d&&(this._localScreenAudioTrack=d,this._initLocalTrackEvents(d)),null===(n=this._screenPlayer)||void 0===n||n.playVideo(this._localScreenVideoTrack),this._initLocalTrackEvents(this._localScreenVideoTrack,!0),null===(i=this._room)||void 0===i||!i.hasScreenPublished){e.next=27;break}return e.next=27,this._updateScreenPublish();case 27:case"end":return e.stop()}}),e,this)}))),function(){return q.apply(this,arguments)})},{key:"stopScreenCapture",value:(Y=_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("stopScreenCapture()"),null===(t=this._screenPlayer)||void 0===t||t.stop(),this._localScreenVideoTrack&&(this._localScreenVideoTrack.dummy||(this._removeLocalTrackEvents(this._localScreenVideoTrack),this._localScreenVideoTrack.close(),this._localImgScreenTrack&&(null===(n=this._localScreenVideoTrack)||void 0===n||n.setTrack(this._localImgScreenTrack,this._extensionManager),this._localScreenVideoTrack.dummy=!0))),this._localScreenAudioTrack&&(this._removeLocalTrackEvents(this._localScreenAudioTrack),this._localScreenAudioTrack.close()),this._localScreenAudioTrack=void 0,null===(r=this._room)||void 0===r||!r.hasScreenPublished){e.next=8;break}return e.next=8,this._updateScreenPublish();case 8:case"end":return e.stop()}}),e,this)}))),function(){return Y.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,o,a=_objectSpread2(_objectSpread2({userId:this._getUserId()},t),{},{isLocal:!0});if(checkVideoPlayerOption(a),e===StreamIndex.STREAM_INDEX_MAIN&&!this._videoPlayer)return this._videoPlayer=new VideoPlayer(this.id,a),this._initPlayerEvents(this._videoPlayer,!1,e),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),(null===(n=this._room)||void 0===n?void 0:n.localStream)&&(this._room.localStream.videoDom=this._videoPlayer.domElement),this._videoPlayer.domElement;if(e===StreamIndex.STREAM_INDEX_SCREEN&&!this._screenPlayer)return this._screenPlayer=new VideoPlayer(this.id,_objectSpread2(_objectSpread2({},a),{},{isScreen:!0,isLocal:!0})),this._initPlayerEvents(this._screenPlayer,!1,e),this._localScreenVideoTrack&&!this._localScreenVideoTrack.dummy&&(null===(i=this._config)||void 0===i?void 0:i.autoPlayPolicy)!==RTCAutoPlayPolicy.PLAY_MANUALLY&&this._screenPlayer.playVideo(this._localScreenVideoTrack),(null===(o=this._room)||void 0===o?void 0:o.localScreenStream)&&(this._room.localScreenStream.videoDom=this._screenPlayer.domElement),this._screenPlayer.domElement}else{var s,c;e===StreamIndex.STREAM_INDEX_MAIN?(null===(s=this._videoPlayer)||void 0===s||s.destroy(!0),delete this._videoPlayer):(null===(c=this._screenPlayer)||void 0===c||c.destroy(),delete this._screenPlayer)}}},{key:"startLiveTranscoding",value:(W=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){var r,n,i;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(logger$1.print("startLiveTranscoding()","transcode: %o",t),LiveTranscoding.checkStartParams(t),this._liveTranscodeConfig=t,!((n=null===(r=this._room)||void 0===r?void 0:r.roomInfo)&&n.roomId.length+n.userInfo.userId.length>126)){e.next=6;break}throw new SDKError(ErrorCode.INVALID_PARAMS,"The roomId+userId must be within 126 bytes");case 6:if(e.prev=6,this.safeEmit(EngineEventsTypes.onStreamMixingEvent,{event:StreamMixingEventType.START,error:0,message:""}),!this._room||this._room.connectionState!==MediaConnectionState.CONNECTED){e.next=11;break}return e.next=11,null===(i=this._room)||void 0===i?void 0:i.liveControlMessage(LiveTranscoding.getStartParams(this._liveTranscodeConfig));case 11:e.next=20;break;case 13:if(e.prev=13,e.t0=e.catch(6),!(e.t0 instanceof SDKError)){e.next=19;break}throw e.t0;case 19:throw new SDKError(ErrorCode.UNEXPECTED_ERROR,"unexpected error",e.t0);case 20:case"end":return e.stop()}}),e,this,[[6,13]])}))),function(e){return W.apply(this,arguments)})},{key:"updateLiveTranscoding",value:(K=_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(logger$1.print("updateLiveTranscoding()","transcode: %o",t),this._liveTranscodeConfig){e.next=3;break}return e.abrupt("return");case 3:return delete(i=assignIn$1({},t)).audio,null===(r=i.video)||void 0===r||delete r.codec,null===(n=i.video)||void 0===n||delete n.gop,LiveTranscoding.checckUpdateParams(i),this._liveTranscodeConfig=assignIn$1(this._liveTranscodeConfig,i),e.prev=9,this.safeEmit(EngineEventsTypes.onStreamMixingEvent,{event:StreamMixingEventType.UPDATE,error:0,message:""}),e.next=13,null===(o=this._room)||void 0===o?void 0:o.liveControlMessage(LiveTranscoding.getUpdateParams(this._liveTranscodeConfig));case 13:e.next=22;break;case 15:if(e.prev=15,e.t0=e.catch(9),!(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:case"end":return e.stop()}}),e,this,[[9,15]])}))),function(e){return K.apply(this,arguments)})},{key:"stopLiveTranscoding",value:(H=_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 H.apply(this,arguments)})},{key:"startSubtitle",value:(z=_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("startSubtitle()","config: %o",t),this._assertNotInRoom(),e.next=4,null===(r=this._room)||void 0===r?void 0:r.startSubtitle(t);case 4:case"end":return e.stop()}}),e,this)}))),function(e){return z.apply(this,arguments)})},{key:"stopSubtitle",value:function(){var e;logger$1.print("stopSubtitle()","invoke"),null===(e=this._room)||void 0===e||e.stopSubtitle()}},{key:"setBusinessId",value:function(e){return logger$1.print("setBusinessId()","businessId: %s",e),!illegalBusinessId(e)&&!this._room&&(this.monitor.set({rtc_business_id:e}),this._businessId=e,!0)}},{key:"setUserVisibility",value:(G=_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._assertNotInRoom(),this._room.localStream&&(null===(n=this._room.localStream.observer)||void 0===n||n.setPublisher(t)),e.t0=!t,!e.t0){e.next=13;break}return e.next=13,this._room.unpublish();case 13:return e.next=15,this._room.updateUserAttributes({role:t?UserRole.NORMAL_USER:UserRole.SILENT_USER});case 15:this._visibility=t,t&&null!==(r=this._roomConfig)&&void 0!==r&&r.isAutoPublish&&this._updatePublish({mediaType:MediaType.AUDIO_AND_VIDEO});case 17:case"end":return e.stop()}}),e,this)}))),function(e){return G.apply(this,arguments)})},{key:"_initPlayerEvents",value:function(e){var t=this,r=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:StreamIndex.STREAM_INDEX_MAIN,i=n===StreamIndex.STREAM_INDEX_SCREEN;e.on("playback_event",(function(n){switch(n.eventName){case"timeupdate":return;case"loadeddata":if("audio"===n.type){var o,a,s=e.userId.replace("_screen",""),c=null===(o=t._room)||void 0===o||null===(a=o.remoteStreams.get(s))||void 0===a?void 0:find$2(a).call(a,(function(e){return e.isScreen===i})),l=function(){r?t.safeEmit(EngineEventsTypes.onFirstPublicStreamAudioFrameDecoded,{publicStreamId:s}):(t.safeEmit(EngineEventsTypes.onAudioFirstFrameDecoded,{userId:s,isScreen:i}),t.safeEmit(EngineEventsTypes.onRemoteAudioFirstFrame,{userId:s,isScreen:i})),t.monitor.report("first_remote_audio_render",{stream_id:"",stream_user_id:s||""},{isScreen:i})};c&&c.observer&&!c.observer.audioFirstFrameReceived?c.observer.once("recvAudioFirstFrame",l):l()}else{var u,d,p={userId:e.userId,height:(null===(u=e.domElement)||void 0===u?void 0:u.videoHeight)||0,width:(null===(d=e.domElement)||void 0===d?void 0:d.videoWidth)||0,isScreen:i};r?(p.publicStreamId=p.userId,delete p.userId,delete p.isScreen,t.safeEmit(EngineEventsTypes.onFirstPublicStreamVideoFrameRendered,p),t.safeEmit(EngineEventsTypes.onFirstPublicStreamVideoFrameDecoded,p)):e.isLocal||(t.safeEmit(EngineEventsTypes.onVideoFirstFrameRendered,p),t.safeEmit(EngineEventsTypes.onVideoFirstFrameDecoded,p),t.safeEmit(EngineEventsTypes.onRemoteVideoFirstFrame,p)),t.monitor.report("first_remote_video_render",{stream_id:"",stream_user_id:n.userId||""},{isScreen:i})}break;case"autoplay-error":return r&&(n.publicStreamId=n.userId),reportRtcInvokeStatus(t.id,"autoplay-error",e instanceof VideoPlayer?"video":"audio",0,n.userId||""),void t.safeEmit(EngineEventsTypes.onAutoplayFailed,{userId:n.userId,kind:e instanceof VideoPlayer?"video":"audio",mediaType:e instanceof VideoPlayer?MediaType.VIDEO:MediaType.AUDIO,streamIndex:e.isScreen?StreamIndex.STREAM_INDEX_SCREEN:StreamIndex.STREAM_INDEX_MAIN})}t.safeEmit(EngineEventsTypes.onPlayerEvent,n)}))}},{key:"_initLocalTrackEvents",value:function(e){var t=this,r=arguments.length>1&&void 0!==arguments[1]&&arguments[1];["track-ended","track-mute","track-unmute"].forEach((function(r){e.on(r,function(){var e=_asyncToGenerator(_regeneratorRuntime().mark((function e(n){var i,o;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t.monitor.report("rtc_error",{message:concat$2(i="track-".concat(r," mediaType: ")).call(i,n.getTrack().kind),error_code:-1001}),o=!1,n!==t._localScreenAudioTrack&&n!==t._localScreenVideoTrack||(o=!0),t.safeEmit({"track-ended":EngineEventsTypes.onTrackEnded,"track-mute":EngineEventsTypes.onTrackMute,"track-unmute":EngineEventsTypes.onTrackUnmute}[r],{kind:n.getTrack().kind,isScreen:o});case 4:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}())})),e.on("resolution-change",(function(e){t._extensionManager.getPluginsByType(RTCExtensionType.PRE_PROCESSING).forEach((function(t){var r;null==t||null===(r=t.applyConstraints)||void 0===r||r.call(t,e)})),t.safeEmit(EngineEventsTypes.onLocalVideoSizeChanged,{streamIndex:r?StreamIndex.STREAM_INDEX_SCREEN:StreamIndex.STREAM_INDEX_MAIN,info:e})}))}},{key:"_removeLocalTrackEvents",value:function(e){e.removeAllListeners("track-ended"),e.removeAllListeners("track-mute"),e.removeAllListeners("track-unmute"),e.removeAllListeners("resolution-change")}},{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 l=new VideoPlayer(this.id,t);this._initPlayerEvents(l,!1,e),this._remoteVideoPlayer.set(o,l);var u=null===(s=this._room)||void 0===s||null===(c=s.remoteStreams.get(o))||void 0===c?void 0:find$2(c).call(c,(function(e){return!e.isScreen}));return u&&(this._updateVideoPlayerState(u),u.videoDom=l.domElement),l.domElement}if(null===(r=this._remoteScreenPlayer.get(o))||void 0===r||r.destroy(),t.renderDom){var d=new VideoPlayer(this.id,_objectSpread2(_objectSpread2({},t),{},{isScreen:!0}));this._remoteScreenPlayer.set(o,d),this._initPlayerEvents(d,!1,e);var p=null===(n=this._room)||void 0===n||null===(i=n.remoteStreams.get(o))||void 0===i?void 0:find$2(i).call(i,(function(e){return e.isScreen}));return p&&(this._updateVideoPlayerState(p),p.videoDom=d.domElement),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:(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("setAudioPlaybackDevice()","deviceId: %s",t),checkString(t,"deviceId"),e.next=4,this._audioDeviceManager.setSinkId(t);case 4:r=e.sent,this._remoteAudioPlayer.forEach((function(e){e.setPlaybackDevice(t)})),this._remoteScreenAudioPlayer.forEach((function(e){e.setPlaybackDevice(t)})),this.safeEmit(EngineEventsTypes.onAudioPlaybackDeviceChanged,r),this.monitor.report("rtc_audio_device",{audio_event:"playout_device_switch",message:stringify$1(r),error_code:0});case 9:case"end":return e.stop()}}),e,this)}))),function(e){return j.apply(this,arguments)})},{key:"play",value:(F=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){var r,n,i,o,a,s,c,l,u,d,p,_,h,f,m,v,g=arguments;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return o=g.length>1&&void 0!==g[1]?g[1]:MediaType.AUDIO_AND_VIDEO,a=g.length>2?g[2]:void 0,logger$1.print("play()","userId: %s, mediaType: %s, streamIndex: %s",t,o,a),s=!t||t===this._getUserId()||"local_user"===t,c=void 0===a||a===StreamIndex.STREAM_INDEX_MAIN,l=void 0===a||a===StreamIndex.STREAM_INDEX_SCREEN,u=o!==MediaType.VIDEO,d=o!==MediaType.AUDIO,p=[],s&&d&&(c&&this._localVideoTrack&&(null===(_=this._videoPlayer)||void 0===_||_.mirror(!!this._mirrorType),p.push(null===(h=this._videoPlayer)||void 0===h?void 0:h.playVideo(this._localVideoTrack))),l&&this._localScreenVideoTrack&&p.push(null===(f=this._screenPlayer)||void 0===f?void 0:f.playVideo(this._localScreenVideoTrack))),t===(null===(r=this._audioMixingManager)||void 0===r?void 0:r.id)&&p.push(this._audioMixingManager.resumeLocalPlay()),m=null===(n=this._room)||void 0===n?void 0:n.remoteStreams,d&&c&&p.push(playRemoteStream(this._remoteVideoPlayer,t,!1,m)),d&&l&&p.push(playRemoteStream(this._remoteScreenPlayer,t,!0,m)),u&&c&&p.push(playRemoteStream(this._remoteAudioPlayer,t,!1,m)),d&&l&&p.push(playRemoteStream(this._remoteScreenAudioPlayer,t,!0,m)),v=null===(i=this._publicStreamManager)||void 0===i?void 0:i.remoteStreams,u&&p.push(playRemoteStream(this._publicStreamVideoPlayer,t,!1,v)),d&&p.push(playRemoteStream(this._publicStreamAudioPlayer,t,!1,v)),e.abrupt("return",promise.all(p).then((function(){})));case 20:case"end":return e.stop()}}),e,this)}))),function(e){return F.apply(this,arguments)})},{key:"pauseAllSubscribedStream",value:(B=_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$1.print("pauseAllSubscribedStream()","mediaType: %o",t),this._checkMediaType(t),audioInMediaType(t)&&(s._pauseAllSubscribeState.audio=!0),videoInMediaType(t)&&(s._pauseAllSubscribeState.video=!0),this._room){e.next=6;break}return e.abrupt("return",promise.resolve());case 6:n=[],i=_createForOfIteratorHelper(values$1(r=this._room.remoteStreams).call(r));try{for(i.s();!(o=i.n()).done;)a=o.value,Array.isArray(a)&&a.forEach((function(e){if(e.hasSubscribed){s._pauseAllSubscribeState.resumeStreamIds[e.streamId]=e.streamId;var r=s._unsubscribe(e.isScreen,e.userId,t,!0);r&&n.push(r)}}))}catch(e){i.e(e)}finally{i.f()}return e.abrupt("return",promise.all(n).then((function(){})));case 10:case"end":return e.stop()}}),e,this)}))),function(e){return B.apply(this,arguments)})},{key:"resumeAllSubscribedStream",value:(V=_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$1.print("resumeAllSubscribedStream()","mediaType: %o",t),this._checkMediaType(t),audioInMediaType(t)&&(s._pauseAllSubscribeState.audio=!1),videoInMediaType(t)&&(s._pauseAllSubscribeState.video=!1),this._room){e.next=6;break}return e.abrupt("return",promise.resolve());case 6:n=[],i=_createForOfIteratorHelper(values$1(r=this._room.remoteStreams).call(r));try{for(i.s();!(o=i.n()).done;)a=o.value,Array.isArray(a)&&a.forEach((function(e){if(s._pauseAllSubscribeState.resumeStreamIds[e.streamId]){delete s._pauseAllSubscribeState.resumeStreamIds[e.streamId];var r=s._subscribe(e.isScreen,e.userId,t);r&&n.push(r)}}))}catch(e){i.e(e)}finally{i.f()}return e.abrupt("return",promise.all(n).then((function(){var e,t;null===(e=s._room)||void 0===e||null===(t=e.remoteStreams)||void 0===t||t.forEach((function(e){Array.isArray(e)&&e.forEach((function(e){s._updateAudioPlayerState(e),s._updateVideoPlayerState(e)}))}))})));case 10:case"end":return e.stop()}}),e,this)}))),function(e){return V.apply(this,arguments)})},{key:"sendUserMessage",value:(U=_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 checkUserId(t),checkBufferSize(r),this._assertNotInRoom(),o=Date.now(),e.abrupt("return",null===(n=this._room)||void 0===n||null===(i=n.sendUserMessage(t,r))||void 0===i?void 0:i.then((function(e){return a._messageStatisticsObserver.countP2PMessage(!0,t,!1,o,e),e.id})).catch((function(e){throw a._messageStatisticsObserver.countP2PMessage(!1,t,!1,o,e),e})));case 5:case"end":return e.stop()}}),e,this)}))),function(e,t){return U.apply(this,arguments)})},{key:"sendUserBinaryMessage",value:(L=_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 checkUserId(t),checkArrayBuffer(r,"message"),checkBufferSize(r),this._assertNotInRoom(),o=Date.now(),e.abrupt("return",null===(n=this._room)||void 0===n||null===(i=n.sendUserMessage(t,r))||void 0===i?void 0:i.then((function(e){return a._messageStatisticsObserver.countP2PMessage(!0,t,!0,o,e),e.id})).catch((function(e){throw a._messageStatisticsObserver.countP2PMessage(!1,t,!0,o,e),e})));case 6:case"end":return e.stop()}}),e,this)}))),function(e,t){return L.apply(this,arguments)})},{key:"sendRoomMessage",value:(N=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){var r,n,i,o=this;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return checkBufferSize(t),this._assertNotInRoom(),i=Date.now(),e.abrupt("return",null===(r=this._room)||void 0===r||null===(n=r.sendRoomMessage(t))||void 0===n?void 0:n.then((function(e){var t,r;return o._messageStatisticsObserver.countRoomMessage(!0,null===(t=o._room)||void 0===t||null===(r=t.roomInfo)||void 0===r?void 0:r.roomId,!1,i),e})).catch((function(e){var t,r;throw o._messageStatisticsObserver.countRoomMessage(!1,null===(t=o._room)||void 0===t||null===(r=t.roomInfo)||void 0===r?void 0:r.roomId,!1,i),e})));case 4:case"end":return e.stop()}}),e,this)}))),function(e){return N.apply(this,arguments)})},{key:"sendRoomBinaryMessage",value:(x=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){var r,n,i,o=this;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return checkBufferSize(t),this._assertNotInRoom(),i=Date.now(),e.abrupt("return",null===(r=this._room)||void 0===r||null===(n=r.sendRoomMessage(t,!0))||void 0===n?void 0:n.then((function(e){var t,r;return o._messageStatisticsObserver.countRoomMessage(!0,null===(t=o._room)||void 0===t||null===(r=t.roomInfo)||void 0===r?void 0:r.roomId,!0,i),e})).catch((function(e){var t,r;throw o._messageStatisticsObserver.countRoomMessage(!1,null===(t=o._room)||void 0===t||null===(r=t.roomInfo)||void 0===r?void 0:r.roomId,!0,i),e})));case 4:case"end":return e.stop()}}),e,this)}))),function(e){return x.apply(this,arguments)})},{key:"setAudioCaptureConfig",value:(D=_asyncToGenerator(_regeneratorRuntime().mark((function e(){var t,r=arguments;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=r.length>0&&void 0!==r[0]?r[0]:{},logger$1.print("setAudioCaptureConfig()","config: %o",t),delete t.deviceId,checkSupportedConstraints(t),this._shouldUpdateAudioConf("setAudioCaptureConfig")&&this._audioProfileManager.updateConstraints(t);case 5:case"end":return e.stop()}}),e,this)}))),function(){return D.apply(this,arguments)})},{key:"setVideoCaptureConfig",value:(M=_asyncToGenerator(_regeneratorRuntime().mark((function e(){var t,r=arguments;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=r.length>0&&void 0!==r[0]?r[0]:{},logger$1.print("setVideoCaptureConfig()","config: %o",t),e.abrupt("return",this._setVideoCaptureConfig(t));case 3:case"end":return e.stop()}}),e,this)}))),function(){return M.apply(this,arguments)})},{key:"_setVideoCaptureConfig",value:(w=_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(delete(r=i.length>0&&void 0!==i[0]?i[0]:{}).deviceId,checkSupportedConstraints(r),n=_objectSpread2(_objectSpread2({},r),{},{deviceId:this._videoStreamConstraints.deviceId}),!this._localVideoTrack){e.next=7;break}return e.next=7,this._localVideoTrack.updateVideoCaptureConfig(n);case 7:return this._videoStreamConstraints=n,e.abrupt("return",(null===(t=this._localVideoTrack)||void 0===t?void 0:t.getTrack().getSettings())||{});case 9:case"end":return e.stop()}}),e,this)}))),function(){return w.apply(this,arguments)})},{key:"enableSimulcastMode",value:function(e){var t;return logger$1.print("enableSimulcastMode()","enabled: %o",e),this._enableSimulcast=e,14!==(null==iOSVersion?void 0:iOSVersion[0])&&(null!==(t=this._room)&&void 0!==t&&t.hasPublished&&warnDevelopers("You must call this API before publishing the video streams"),!0)}},{key:"setVideoEncoderConfig",value:(O=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){var r,n,i;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:for(logger$1.print("setVideoEncoderConfig()"," descriptions: %o",t),Array.isArray(t)||(t=[t]),checkVideoEncoderConfig(t=filter3(t).call(t,(function(e){return!!e}))),t.length>3&&(warnDevelopers("setVideoEncoderConfig: You can set parameters for up to 3 streams"),t=slice$1(t).call(t,0,3)),n=1;n<t.length;n++)i=constraints2number(t[0].width)/constraints2number(t[n].width)||1,Math.floor(i)!==i&&warnDevelopers("setVideoEncoderConfig: The resolution setting needs to be an integer multiple");sort2(t).call(t,(function(e,t){return t.maxKbps-e.maxKbps})),this._setVideoCaptureConfig(_objectSpread2({},t[0])),this._videoStreamEncodeConfig=t,this._updateDummyCaptureImage(StreamIndex.STREAM_INDEX_MAIN),null!==(r=this._room)&&void 0!==r&&r.hasPublished&&this._updatePublish();case 11:case"end":return e.stop()}}),e,this)}))),function(e){return O.apply(this,arguments)})},{key:"setScreenEncoderConfig",value:(P=_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.updateVideoCaptureConfig(t),t.contentHint&&this._localScreenVideoTrack.setContentHint(t.contentHint)),this._updateDummyCaptureImage(StreamIndex.STREAM_INDEX_SCREEN),null!==(r=this._room)&&void 0!==r&&r.hasScreenPublished&&this._updateScreenPublish();case 5:case"end":return e.stop()}}),e,this)}))),function(e){return P.apply(this,arguments)})},{key:"sendSEIMessage",value:function(e,t,r){if(logger$1.print("sendSEIMessage()","streamIdex: %o, message: %o, repeatCount: %o",e,t,r),!isEncodedTransformSupported())throw new SDKError(ErrorCode.NOT_SUPPORTED,"Browser does not support sending SEI");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,l,u;if(null===(c=this._room)||void 0===c||null===(l=c.localScreenStream)||void 0===l||!l.hasPublished)return;i=null===(u=this._room)||void 0===u?void 0:u.localScreenStream}if(n.byteLength>4096)logger$1.print("sei size must not bigger than 4KB");else{var d=genUuid2();i.seiList.push({content:n,uuid:d,repeatCount:r}),setTimeout((function(){var e;if(i){var t,r=findIndex$1(e=i.seiList).call(e,(function(e){return e.uuid===d}));if(r)splice$3(t=i.seiList).call(t,r,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=find$2(e).call(e,(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=reduce3(t).call(t,(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>-35){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,s=[];if(null!==(a=e._room)&&void 0!==a&&a.multiChatMode)e._room.getActiveSpeakerInMultiChatMode().forEach((function(t){var r,n,i=255*t.audioLevel;s.push({streamKey:{userId:t.userId,streamIndex:StreamIndex.STREAM_INDEX_MAIN,roomId:null===(r=e._room)||void 0===r||null===(n=r._roomInfo)||void 0===n?void 0:n.roomId},audioPropertiesInfo:{linearVolume:i,nonlinearVolume:getNonlinearVolume(i)}})}));else e._room.remoteStreams.forEach((function(t,r){t.forEach((function(t){if(t.audioTrack){var n,i,o=t.audioTrack.getAudioLevel();s.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.safeEmit(EngineEventsTypes.onRemoteAudioPropertiesReport,s),e._sendActiveSpeaker(t,filter3(s).call(s,(function(e){return e.streamKey.streamIndex!==StreamIndex.STREAM_INDEX_SCREEN})))}}}),o))}},{key:"setVideoSourceType",value:(k=_asyncToGenerator(_regeneratorRuntime().mark((function e(t,r){var n,i,o,a,s,c,l,u,d,p,_,h,f,m,v,g,y,S,T,$,E,b,I;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",concat$2(i="set ".concat(n," source type to ")).call(i,r)),!this._localVideoTrack||t!==StreamIndex.STREAM_INDEX_MAIN){e.next=17;break}if(c=!1,r===VideoSourceType.VIDEO_SOURCE_TYPE_EXTERNAL&&(c=!0,(l=this._extensionManager.getPluginByName(RTCExtensionType.PRE_PROCESSING,"RTCBeautyExtension"))&&l.emit("stop"),this._removeLocalTrackEvents(this._localVideoTrack),this._localVideoTrack.close()),null===(o=this._videoPlayer)||void 0===o||o.stop(),this._localVideoTrack=void 0,u=null===(a=this._room)||void 0===a?void 0:a._roomConfig.isAutoPublish,c?null===(d=this._room)||void 0===d||null===(p=d.localStream)||void 0===p||null===(_=p.observer)||void 0===_||_.setEnableVideo(!1):null===(h=this._room)||void 0===h||null===(f=h.localStream)||void 0===f||null===(m=f.observer)||void 0===m||m.setPushVideo(!1),!(null!==(s=this._room)&&void 0!==s&&s.hasPublished||u)){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._removeLocalTrackEvents(this._localScreenVideoTrack),this._localScreenVideoTrack.close()),null===(v=this._screenPlayer)||void 0===v||v.stop(),this._localScreenVideoTrack=void 0,y?null===(S=this._room)||void 0===S||null===(T=S.localScreenStream)||void 0===T||null===($=T.observer)||void 0===$||$.setEnableVideo(!1):null===(E=this._room)||void 0===E||null===(b=E.localScreenStream)||void 0===b||null===(I=b.observer)||void 0===I||I.setPushVideo(!1),null===(g=this._room)||void 0===g||!g.hasScreenPublished){e.next=26;break}return e.next=26,this._updateScreenPublish();case 26:case"end":return e.stop()}}),e,this)}))),function(e,t){return k.apply(this,arguments)})},{key:"setExternalVideoTrack",value:(A=_asyncToGenerator(_regeneratorRuntime().mark((function e(t,r){var n,i,o,a,s,c,l,u,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]),checkMediaStreamTrack(r),t!==StreamIndex.STREAM_INDEX_MAIN){e.next=15;break}if(this._trackSourceType.video===VideoSourceType.VIDEO_SOURCE_TYPE_EXTERNAL){e.next=6;break}throw new SDKError(ErrorCode.STREAM_TYPE_NOT_MATCH,"setVideoSourceType as external first");case 6:return e.next=8,createCustomVideoLocalTrack(r,this._extensionManager);case 8:if(this._localVideoTrack=e.sent,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=15;break}return e.next=15,this._updatePublish();case 15:if(t!==StreamIndex.STREAM_INDEX_SCREEN){e.next=27;break}if(this._trackSourceType.screenVideo===VideoSourceType.VIDEO_SOURCE_TYPE_EXTERNAL){e.next=18;break}throw new SDKError(ErrorCode.STREAM_TYPE_NOT_MATCH,"setVideoSourceType as external first");case 18:return e.next=20,createCustomScreenVideoLocalTrack(r,this._extensionManager);case 20:if(this._localScreenVideoTrack=e.sent,this._initLocalTrackEvents(this._localScreenVideoTrack,!0),null===(s=this._screenPlayer)||void 0===s||s.playVideo(this._localScreenVideoTrack),null===(c=this._room)||void 0===c||null===(l=c.localScreenStream)||void 0===l||null===(u=l.observer)||void 0===u||u.setPushVideo(!0),null===(d=this._room)||void 0===d||!d.hasScreenPublished){e.next=27;break}return e.next=27,this._updateScreenPublish();case 27:case"end":return e.stop()}}),e,this)}))),function(e,t){return A.apply(this,arguments)})},{key:"setAudioSourceType",value:(C=_asyncToGenerator(_regeneratorRuntime().mark((function e(t,r){var n,i,o,a,s,c,l,u,d,p,_,h,f,m,v,g,y,S,T,$;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",concat$2(i="set ".concat(n," source type to ")).call(i,r)),!this._localAudioTrack||t!==StreamIndex.STREAM_INDEX_MAIN){e.next=16;break}if(s=!1,this._trackSourceType.audio===AudioSourceType.AUDIO_SOURCE_TYPE_EXTERNAL&&(s=!0,this._removeLocalTrackEvents(this._localAudioTrack),this._localAudioTrack.close()),this._localAudioTrack=void 0,c=null===(o=this._room)||void 0===o?void 0:o._roomConfig.isAutoPublish,s?null===(l=this._room)||void 0===l||null===(u=l.localStream)||void 0===u||null===(d=u.observer)||void 0===d||d.setEnableAudio(!1):null===(p=this._room)||void 0===p||null===(_=p.localStream)||void 0===_||null===(h=_.observer)||void 0===h||h.setPushAudio(!1),!(null!==(a=this._room)&&void 0!==a&&a.hasPublished||c)){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(m=!1,this._trackSourceType.audio===AudioSourceType.AUDIO_SOURCE_TYPE_EXTERNAL&&(m=!0,this._removeLocalTrackEvents(this._localScreenAudioTrack),this._localScreenAudioTrack.close()),this._localScreenAudioTrack=void 0,m?null===(v=this._room)||void 0===v||null===(g=v.localScreenStream)||void 0===g||null===(y=g.observer)||void 0===y||y.setEnableAudio(!1):null===(S=this._room)||void 0===S||null===(T=S.localScreenStream)||void 0===T||null===($=T.observer)||void 0===$||$.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 C.apply(this,arguments)})},{key:"setExternalAudioTrack",value:(R=_asyncToGenerator(_regeneratorRuntime().mark((function e(t,r){var n,i,o,a,s,c,l,u,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]),checkMediaStreamTrack(r),t!==StreamIndex.STREAM_INDEX_MAIN){e.next=16;break}if(this._trackSourceType.audio===AudioSourceType.AUDIO_SOURCE_TYPE_EXTERNAL){e.next=6;break}throw new SDKError(ErrorCode.STREAM_TYPE_NOT_MATCH,"setAudioSourceType as external first");case 6:return e.next=8,createCustomAudioLocalTrack(r,this._extensionManager);case 8:if(this._localAudioTrack=e.sent,this._localAudioTrack.setVolume(this._localAudioVolume),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=16;break}return e.next=16,this._updatePublish();case 16:if(t!==StreamIndex.STREAM_INDEX_SCREEN){e.next=28;break}if(this._trackSourceType.screenAudio===AudioSourceType.AUDIO_SOURCE_TYPE_EXTERNAL){e.next=19;break}throw new SDKError(ErrorCode.STREAM_TYPE_NOT_MATCH,"setAudioSourceType as external first");case 19:return e.next=21,createCustomScreenAudioLocalTrack(r,this._extensionManager);case 21:if(this._localScreenAudioTrack=e.sent,this._localScreenAudioTrack.setVolume(this._localScreenAudioVolume),this._initLocalTrackEvents(this._localScreenAudioTrack),null===(l=this._room)||void 0===l||null===(u=l.localScreenStream)||void 0===u||null===(d=u.observer)||void 0===d||d.setPushAudio(!0),null===(p=this._room)||void 0===p||!p.hasScreenPublished){e.next=28;break}return e.next=28,this._updateScreenPublish();case 28:case"end":return e.stop()}}),e,this)}))),function(e,t){return R.apply(this,arguments)})},{key:"login",value:(I=_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 I.apply(this,arguments)})},{key:"logout",value:(b=_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 b.apply(this,arguments)})},{key:"updateLoginToken",value:(E=_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 E.apply(this,arguments)})},{key:"getPeerOnlineStatus",value:($=_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 $.apply(this,arguments)})},{key:"sendUserMessageOutsideRoom",value:(T=_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.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),e})));case 4:case"end":return e.stop()}}),e,this)}))),function(e,t){return T.apply(this,arguments)})},{key:"sendUserBinaryMessageOutsideRoom",value:(S=_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.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),e})));case 5:case"end":return e.stop()}}),e,this)}))),function(e,t){return S.apply(this,arguments)})},{key:"setServerParams",value:(y=_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 y.apply(this,arguments)})},{key:"sendServerMessage",value:(g=_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.abrupt("return",this._rtmClient.sendServerMessage(t).then((function(e){n._messageStatisticsObserver.countServerMessage(!0,!1,r,e)})).catch((function(e){throw n._messageStatisticsObserver.countServerMessage(!1,!1,r,e),e})));case 4:case"end":return e.stop()}}),e,this)}))),function(e){return g.apply(this,arguments)})},{key:"sendServerBinaryMessage",value:(v=_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.abrupt("return",this._rtmClient.sendServerMessage(t).then((function(e){n._messageStatisticsObserver.countServerMessage(!0,!0,r,e)})).catch((function(e){throw n._messageStatisticsObserver.countServerMessage(!1,!0,r,e),e})));case 4:case"end":return e.stop()}}),e,this)}))),function(e){return v.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:(m=_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:if(logger$1.print("startPushPublicStream()","publicStreamId: %o, publicStreamParam: %o",t,r),checkPublicStreamId(t),this._assertNotInRoom(),!this._publicStreamIds.get(t)){e.next=5;break}throw new SDKError(ErrorCode.REPEAT_PUSH,"repeat push public media stream");case 5:return o=getPublicStreamControlMessage(t,"started",r),e.abrupt("return",null===(n=this._room)||void 0===n||null===(i=n.publicStreamControlMessage(o))||void 0===i?void 0:i.then((function(){a._publicStreamIds.set(t,t)})));case 7:case"end":return e.stop()}}),e,this)}))),function(e,t){return m.apply(this,arguments)})},{key:"updatePublicStreamParam",value:(f=_asyncToGenerator(_regeneratorRuntime().mark((function e(t,r){var n,i;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return logger$1.print("startPushPublicStream()","publicStreamId: %o, publicStreamParam: %o",t,r),checkPublicStreamId(t),this._assertNotInRoom(),i=getPublicStreamControlMessage(t,"layoutChanged",r),e.abrupt("return",null===(n=this._room)||void 0===n?void 0:n.publicStreamControlMessage(i));case 5:case"end":return e.stop()}}),e,this)}))),function(e,t){return f.apply(this,arguments)})},{key:"stopPushPublicStream",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$1.print("startPushPublicStream()","publicStreamId: %o",t),checkPublicStreamId(t),this._assertNotInRoom(),e.abrupt("return",null===(r=this._room)||void 0===r?void 0:r.publicStreamControlMessage({type:"publicstream",action:"stopped",publicStreamID:t}).then((function(){n._publicStreamIds.delete(t)})));case 4:case"end":return e.stop()}}),e,this)}))),function(e){return h.apply(this,arguments)})},{key:"startPlayPublicStream",value:(_=_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._publicStreamManager){e.next=8;break}return this._publicStreamManager=new OutsideRoom(this.id,this._appId,{businessId:this._businessId}),this._publicStreamManager.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._publicStreamManager)||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._publicStreamManager)||void 0===n||n.on(RoomEvent.ON_SEI_MESSAGED_RECEIVED,(function(e){c.safeEmit(EngineEventsTypes.onPublicStreamSEIMessageReceived,e)})),e.next=8,this._publicStreamManager.connect();case 8:return e.next=10,this._publicStreamManager.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(this.id,t,{muted:(null===(s=this._config)||void 0===s?void 0:s.autoPlayPolicy)===RTCAutoPlayPolicy.VIDEO_ONLY,isScreen:!1}),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 _.apply(this,arguments)})},{key:"stopPlayPublicStream",value:(p=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){var r;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._publicStreamManager){e.next=2;break}return e.abrupt("return");case 2:this._publicStreamManager.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 p.apply(this,arguments)})},{key:"setAudioProfile",value:(d=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:logger$1.print("setAudioProfile()","profile: %o",t),this._shouldUpdateAudioConf("setAudioProfile")&&this._audioProfileManager.setAudioProfile(t);case 2:case"end":return e.stop()}}),e,this)}))),function(e){return d.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(this.id,_objectSpread2(_objectSpread2({},t),{},{userId:e})),this._initPlayerEvents(a,!0),this._publicStreamVideoPlayer.set(e,a);var s=null===(n=this._publicStreamManager)||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:(u=_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(){t===StreamIndex.STREAM_INDEX_MAIN?n._dummyMainImage=o:n._dummyScreenImage=o;try{n._updateDummyCaptureImage(t),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 u.apply(this,arguments)})},{key:"_updateDummyCaptureImage",value:function(e){var t,r;if(e===StreamIndex.STREAM_INDEX_MAIN?(t=this._dummyMainImage,r=this._videoStreamEncodeConfig[0]):(t=this._dummyScreenImage,r=this._screenStreamEncodeConfig[0]),t){var n,i,o=document.createElement("canvas"),a=o.getContext("2d"),s=constraints2number(r.width),c=constraints2number(r.height);if(!a)throw new SDKError(ErrorCode.UNEXPECTED_ERROR,"Not support canvas");!s||!c||t.width<=s&&t.height<=c?(n=t.width,i=t.height):(n=Math.min(s,t.width*c/t.height),i=Math.min(c,t.height*s/t.width)),o.width=n,o.height=i,a.drawImage(t,0,0,t.width,t.height,0,0,n,i);var l=window.setInterval((function(){t&&a.drawImage(t,0,0,t.width,t.height,0,0,n,i)}),200);e===StreamIndex.STREAM_INDEX_MAIN?(clearInterval(this._dummyMainTimer),this._dummyMainTimer=l):(clearInterval(this._dummyScreenTimer),this._dummyScreenTimer=l);var u,d,p,_,h=o.captureStream(5).getVideoTracks()[0];if(e===StreamIndex.STREAM_INDEX_MAIN){if(this._localImgVideoTrack=h,null!==(u=this._localVideoTrack)&&void 0!==u&&u.dummy)null===(d=this._localVideoTrack)||void 0===d||d.setTrack(this._localImgVideoTrack,this._extensionManager)}else if(this._localImgScreenTrack=h,null!==(p=this._localScreenVideoTrack)&&void 0!==p&&p.dummy)null===(_=this._localScreenVideoTrack)||void 0===_||_.setTrack(this._localImgScreenTrack,this._extensionManager)}}},{key:"_addListenExtensionEvent",value:function(e){var t=this;e.on("re-capture-audio",(function(){t._localAudioTrack&&t.stopAudioCapture().then((function(){t.startAudioCapture()}))})),e.on("re-capture-video",(function(){t._localVideoTrack&&!t._localVideoTrack.dummy&&t.stopVideoCapture().then((function(){t.startVideoCapture()}))})),e.on("reset-video-effect",_asyncToGenerator(_regeneratorRuntime().mark((function e(){return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!t._localVideoTrack||t._localVideoTrack.dummy){e.next=6;break}return t._localVideoTrack&&t._removeLocalTrackEvents(t._localVideoTrack),e.next=4,t._localVideoTrack.generatePreProcessingTrack(t._extensionManager);case 4:return e.next=6,t._switchTrack(t._localVideoTrack);case 6:case"end":return e.stop()}}),e)}))))}},{key:"registerExtension",value:(l=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t.monitor=this.monitor,e.prev=1,e.next=4,t.isSupported();case 4:if(e.sent){e.next=7;break}throw new Error("This extension is not supported.");case 7:e.next=12;break;case 9:throw e.prev=9,e.t0=e.catch(1),new Error("This extension is not supported.");case 12:return e.next=14,t.init({videoCaptureConfig:this._videoStreamConstraints});case 14:this._extensionManager.register(t),this._addListenExtensionEvent(t);case 16:case"end":return e.stop()}}),e,this,[[1,9]])}))),function(e){return l.apply(this,arguments)})},{key:"defaultTranscoding",value:function(){return JSON.parse(stringify$1(LiveTranscoding.getDefaultValue()))}},{key:"_updatePublish",value:(c=_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:this._videoPlayer&&this._room.localStream&&(this._room.localStream.videoDom=this._videoPlayer.domElement),e.next=25;break;case 18:if(e.prev=18,e.t0=e.catch(12),!(e.t0 instanceof SDKError)){e.next=24;break}throw e.t0;case 24:throw new SDKError(ErrorCode.UNEXPECTED_ERROR,"unexpected error",e.t0);case 25:return e.prev=25,n(),e.finish(25);case 28:case"end":return e.stop()}}),e,this,[[12,18,25,28]])}))),function(){return c.apply(this,arguments)})},{key:"startAudioPlaybackDeviceTest",value:(s=_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 s.apply(this,arguments)})},{key:"stopAudioPlaybackDeviceTest",value:function(){logger$1.print("stopAudioPlaybackDeviceTest()"),this._audioDeviceManager.stopAudioPlaybackDeviceTest()}},{key:"startAudioDeviceRecordTest",value:(a=_asyncToGenerator(_regeneratorRuntime().mark((function e(t,r){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,r,this._localAudioVolume);case 4:case"end":return e.stop()}}),e,this)}))),function(e,t){return a.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.updateRemoteUserPriority(e),!0}},{key:"takeLocalSnapshot",value:(o=_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("preprocessing"),(null==n?void 0:n.mirrorType)===MirrorType.MIRROR_TYPE_RENDER,n));case 7:case"end":return e.stop()}}),e,this)}))),function(e){return o.apply(this,arguments)})},{key:"takeRemoteSnapshot",value:(i=_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=find$2(i).call(i,(function(e){return e.isScreen===(r===StreamIndex.STREAM_INDEX_SCREEN)})))||void 0===o?void 0:o.videoTrack)||(null===(a=this._publicStreamManager)||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 i.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:"getLocalStreamTrack",value:function(e,t){var r,n,i,o=this;if(e===StreamIndex.STREAM_INDEX_MAIN?(n="video"===t?this.localVideoTrack:this.localAudioTrack,i=function(){var e;return null===(e=o._room)||void 0===e?void 0:e.localStream}):(n="video"===t?this.localScreenVideoTrack:this.localScreenAudioTrack,i=function(){var e;return null===(e=o._room)||void 0===e?void 0:e.localScreenStream}),n){var a=n instanceof runtimeTrackCls.LocalAudioTrack&&n.mixedAudioTrack?n.mixedAudioTrack:n.getTrack("preprocessing");if(a){var s=i();return this._reportMsTrackEvent(a,(null==s||null===(r=s.stream)||void 0===r?void 0:r.id)||"local"),a}}}},{key:"getRemoteStreamTrack",value:function(e,t,r){var n,i,o=(null===(n=this._room)||void 0===n?void 0:n.remoteStreams.get(e))||[];if(o&&o.length){var a,s,c,l,u;if(t===StreamIndex.STREAM_INDEX_MAIN)a=find$2(o).call(o,(function(e){return!e.isScreen})),i="video"===r?null===(s=a)||void 0===s?void 0:s.videoTrack:null===(c=a)||void 0===c?void 0:c.audioTrack;else a=find$2(o).call(o,(function(e){return e.isScreen})),i="video"===r?null===(l=a)||void 0===l?void 0:l.videoTrack:null===(u=a)||void 0===u?void 0:u.audioTrack;if(i){var d=i.getTrack();if(d&&a){var p=a.streamId;return this._reportMsTrackEvent(d,p),d}}}}},{key:"getPublicStreamTrack",value:function(e,t){if(this._publicStreamManager&&this._publicStreamManager.remoteStreams){var r=this._publicStreamManager.remoteStreams.get(e);if(r){var n="video"===t?r.videoTrack:r.audioTrack;if(n){var i=n.getTrack();if(i){var o=r.streamId;return this._reportMsTrackEvent(i,o),i}}}}}},{key:"setRemoteStreamRenderSync",value:function(e){return!this._room&&(this._avSync=!!e,!0)}},{key:"setCaptureVolume",value:function(e,t){var r,n,i;(checkEnum(e,"streamIndex",[StreamIndex.STREAM_INDEX_MAIN,StreamIndex.STREAM_INDEX_SCREEN]),t=numberRangeGuide(t,"volume",0,400),e===StreamIndex.STREAM_INDEX_SCREEN)?(null===(r=this._localScreenAudioTrack)||void 0===r||r.setVolume(t),this._localScreenAudioVolume=t):(null===(n=this._localAudioTrack)||void 0===n||n.setVolume(t),null===(i=this._audioDeviceManager.audioTrack)||void 0===i||i.setVolume(t),this._localAudioVolume=t)}},{key:"setPlaybackVolume",value:function(e,t,r){var n,i,o;if(checkUserId(e),checkEnum(t,"streamIndex",[StreamIndex.STREAM_INDEX_MAIN,StreamIndex.STREAM_INDEX_SCREEN]),r=numberRangeGuide(r,"volume",0,400),null!==(n=this._room)&&void 0!==n&&n.multiChatMode)warnDevelopers("setPlaybackVolume is not supported in Conference mode");else{var a=t===StreamIndex.STREAM_INDEX_SCREEN;a?this._remoteScreenAudioVolume.set(e,r):this._remoteAudioVolume.set(e,r),null===(i=this._room)||void 0===i||null===(o=i.remoteStreams.get(e))||void 0===o||o.forEach((function(e){var t;e.isScreen===a&&(null===(t=e.audioTrack)||void 0===t||t.setVolume(r))}))}}},{key:"setPublicStreamVolume",value:function(e,t){var r,n,i;checkString(e,"publicStreamId"),t=numberRangeGuide(t,"volume",0,400),this._publicAudioVolume.set(e,t),null===(r=this._publicStreamManager)||void 0===r||null===(n=r.remoteStreams.get(e))||void 0===n||null===(i=n.audioTrack)||void 0===i||i.setVolume(t)}},{key:"_reportMsTrackEvent",value:function(e,t){var r=this;if(!e.hookStop){e.hookStop=!0;var n=e.stop;e.stop=function(){reportRtcInvokeStatus(r.id,"stop",t,0,t),n.call(e)}}}},{key:"_updateScreenPublish",value:(n=_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:this._screenPlayer&&this._room.localScreenStream&&(this._room.localScreenStream.videoDom=this._screenPlayer.domElement),e.next=23;break;case 16:if(e.prev=16,e.t0=e.catch(10),!(e.t0 instanceof SDKError)){e.next=22;break}throw e.t0;case 22:throw new SDKError(ErrorCode.UNEXPECTED_ERROR,"unexpected error",e.t0);case 23:return e.prev=23,n(),e.finish(23);case 26:case"end":return e.stop()}}),e,this,[[10,16,23,26]])}))),function(){return n.apply(this,arguments)})},{key:"_updateAudioPlayerState",value:function(e){logger$1.print("_updateAudioPlayerState()");var t=e.userId,r=e.isScreen,n=r?this._remoteScreenAudioPlayer:this._remoteAudioPlayer,i=n.get(t);if(e.audioTrack&&(e.attributes.audiostream&&e.subAudio||this.multiChatMode)){var o,a,s,c=r?null!==(o=this._remoteScreenAudioVolume.get(t))&&void 0!==o?o:100:null!==(a=this._remoteAudioVolume.get(t))&&void 0!==a?a:100;if(e.audioTrack.setVolume(c),!i){var l;i=new AudioPlayer(this.id,t,{muted:(null===(l=this._config)||void 0===l?void 0:l.autoPlayPolicy)===RTCAutoPlayPolicy.VIDEO_ONLY,isScreen:r}),this._initPlayerEvents(i,!1,r?StreamIndex.STREAM_INDEX_SCREEN:StreamIndex.STREAM_INDEX_MAIN),n.set(t,i);var u=this._audioDeviceManager.getSinkId();u&&i.setPlaybackDevice(u)}(null===(s=this._config)||void 0===s?void 0:s.autoPlayPolicy)!==RTCAutoPlayPolicy.PLAY_MANUALLY&&i.playAudio(e.audioTrack),isSafari&&isIPad&&replayRemoteAudioWorkaround(this._remoteAudioPlayer)}else{var d;null===(d=i)||void 0===d||d.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:(r=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){var r,n,i,o,a,s,c,l,u;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if((n=t.stream).videoDom=null===(r=this._remoteVideoPlayer.get(n.userId))||void 0===r?void 0:r.domElement,i=null==n?void 0:n.attributes,o=i.localaudio,a=i.audiostream,s=i.localvideo,c=i.videostream,l=ExtendMediaType.NONE,a&&(l|=MediaType.AUDIO),c&&(l|=MediaType.VIDEO),!l){e.next=12;break}return e.next=9,new promise((function(e){return setTimeout(e)}));case 9:null!=n&&n.isScreen?this.safeEmit(EngineEventsTypes.onUserPublishScreen,{userId:n.userId,mediaType:l}):(this.safeEmit(EngineEventsTypes.onUserPublishStream,{userId:n.userId,mediaType:l,videoStreamDescriptions:null==n||null===(u=n.attributes)||void 0===u?void 0:u.videoDescriptions}),this._handleAutoSubscribe(n,!0)),this.safeEmit("onAddStream",{userId:n.userId,mediaType:l,isScreen:!(null==n||!n.isScreen)}),null!=n&&n.isScreen||(o&&this.safeEmit(EngineEventsTypes.onUserStartAudioCapture,{userId:n.userId}),s&&this.safeEmit(EngineEventsTypes.onUserStartVideoCapture,{userId:n.userId}));case 12:case"end":return e.stop()}}),e,this)}))),function(e){return r.apply(this,arguments)})},{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),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),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){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){var t=this;setTimeout((function(){return t.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,t=arguments.length,r=new Array(t),n=0;n<t;n++)r[n]=arguments[n];this.safeEmit.apply(this,concat$2(e=[EngineEventsTypes.onNetworkQuality]).call(e,r))}},{key:"_onConnectionStateChange",value:function(e){if(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),e.state===ConnectionState.CONNECTION_STATE_RECONNECTING){var t,r=_createForOfIteratorHelper(this._remoteAudioPlayer);try{for(r.s();!(t=r.n()).done;){var n=_slicedToArray(t.value,2),i=n[0],o=n[1];null!=i&&startsWith2(i).call(i,"mux")&&o.stop()}}catch(e){r.e(e)}finally{r.f()}}}},{key:"_getRemotePlayer",value:function(e,t){return[(t?this._remoteScreenAudioPlayer:this._remoteAudioPlayer).get(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:"_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=this,n=e.userId,i=e.isScreen,o=e.mediaType,a=e.pubState,s=e.remoteStream,c={userId:n,mediaType:o};(o&MediaType.AUDIO&&setTimeout((function(){r._updateAudioPlayerState(s)})),i)?a===PubState.PUB?this.safeEmit(EngineEventsTypes.onUserPublishScreen,c):this.safeEmit(EngineEventsTypes.onUserUnpublishScreen,_objectSpread2(_objectSpread2({},c),{},{reason:StreamRemoveReason.STREAM_REMOVE_REASON_UNPUBLISH})):a===PubState.PUB?(c.videoStreamDescriptions=null==s||null===(t=s.attributes)||void 0===t?void 0:t.videoDescriptions,this.safeEmit(EngineEventsTypes.onUserPublishStream,c),this._handleAutoSubscribe(s,!0)):this.safeEmit(EngineEventsTypes.onUserUnpublishStream,_objectSpread2(_objectSpread2({},c),{},{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._tempRoomInfo}},{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:"iceState",get:function(){var e,t,r,n;return null===(e=this._room)||void 0===e||null===(t=e._mediaServerClient)||void 0===t||null===(r=t.handler)||void 0===r||null===(n=r._peerConnection)||void 0===n?void 0:n.iceConnectionState}},{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.NOT_CONNECTED_YET,"server not connected")}},{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"}},{key:"_switchTrack",value:(t=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){var r,n;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._initLocalTrackEvents(t),this._localVideoTrack=t,null!==(r=this._videoPlayer)&&void 0!==r&&r.played&&(this._videoPlayer.stop(),this._videoPlayer.playVideo(t),this._videoPlayer.mirror(!!this._mirrorType)),null===(n=this._room)||void 0===n||!n.hasPublished){e.next=6;break}return e.next=6,this._updatePublish();case 6:case"end":return e.stop()}}),e,this)}))),function(e){return t.apply(this,arguments)})},{key:"_shouldUpdateAudioConf",value:function(e){var t,r=(null===(t=this._room)||void 0===t?void 0:t.hasPublished)||this._localAudioTrack&&this._localAudioTrack.sourceType===SourceType.INTERNAL;if(r){var n="engine.".concat(e," should be called before publishing or capturing.");console.warn("[RTC WebSDK]: "+n),reportRtcInvokeStatus(this.id,e,n)}return!r}},{key:"_getServerConfig",value:function(){getServerConfig({engineId:this.id,appId:this.appId,sdkVersion:getParameter("VERSION"),requestDomains:getParameter("CONFIG_REQUEST_DOMAINS"),keys:["rts_report"]}).then((function(e){e.rts_report&&RTSMsgReportor.setConfig(e.rts_report)}))}}]),ve}();__decorateClass3([reportRtcSdkApiCall()],RTCEngine.prototype,"updateToken",1),__decorateClass3([reportRtcSdkApiCall()],RTCEngine.prototype,"setVideoCaptureDevice",1),__decorateClass3([reportRtcSdkApiCall()],RTCEngine.prototype,"setAudioCaptureDevice",1),__decorateClass3([setJoinRoomInfo,reportRtcSdkApiCall()],RTCEngine.prototype,"connect",1),__decorateClass3([reportRtcSdkApiCall()],RTCEngine.prototype,"joinRoom",1),__decorateClass3([reportRtcSdkApiCall()],RTCEngine.prototype,"leaveRoom",1),__decorateClass3([reportRtcSdkApiCall()],RTCEngine.prototype,"destroy",1),__decorateClass3([reportRtcSdkApiCall()],RTCEngine.prototype,"publishStream",1),__decorateClass3([reportRtcSdkApiCall()],RTCEngine.prototype,"unpublishStream",1),__decorateClass3([reportRtcSdkApiCall()],RTCEngine.prototype,"publishScreen",1),__decorateClass3([reportRtcSdkApiCall()],RTCEngine.prototype,"unpublishScreen",1),__decorateClass3([reportRtcSdkApiCall()],RTCEngine.prototype,"subscribeStream",1),__decorateClass3([reportRtcSdkApiCall()],RTCEngine.prototype,"unsubscribeStream",1),__decorateClass3([reportRtcSdkApiCall()],RTCEngine.prototype,"subscribeScreen",1),__decorateClass3([reportRtcSdkApiCall()],RTCEngine.prototype,"unsubscribeScreen",1),__decorateClass3([reportRtcSdkApiCall()],RTCEngine.prototype,"setRemoteVideoConfig",1),__decorateClass3([reportRtcSdkApiCall()],RTCEngine.prototype,"startVideoCapture",1),__decorateClass3([reportRtcSdkApiCall()],RTCEngine.prototype,"stopVideoCapture",1),__decorateClass3([reportRtcSdkApiCall()],RTCEngine.prototype,"startAudioCapture",1),__decorateClass3([reportRtcSdkApiCall()],RTCEngine.prototype,"stopAudioCapture",1),__decorateClass3([reportRtcSdkApiCall()],RTCEngine.prototype,"getAudioMixingManager",1),__decorateClass3([reportRtcSdkApiCall()],RTCEngine.prototype,"startScreenCapture",1),__decorateClass3([reportRtcSdkApiCall()],RTCEngine.prototype,"stopScreenCapture",1),__decorateClass3([reportRtcSdkApiCall()],RTCEngine.prototype,"setLocalVideoPlayer",1),__decorateClass3([reportRtcSdkApiCall()],RTCEngine.prototype,"startLiveTranscoding",1),__decorateClass3([reportRtcSdkApiCall()],RTCEngine.prototype,"updateLiveTranscoding",1),__decorateClass3([reportRtcSdkApiCall()],RTCEngine.prototype,"stopLiveTranscoding",1),__decorateClass3([reportRtcSdkApiCall()],RTCEngine.prototype,"startSubtitle",1),__decorateClass3([reportRtcSdkApiCall()],RTCEngine.prototype,"stopSubtitle",1),__decorateClass3([reportRtcSdkApiCall()],RTCEngine.prototype,"setBusinessId",1),__decorateClass3([reportRtcSdkApiCall()],RTCEngine.prototype,"setUserVisibility",1),__decorateClass3([reportRtcSdkApiCall()],RTCEngine.prototype,"setRemoteVideoPlayer",1),__decorateClass3([reportRtcSdkApiCall()],RTCEngine.prototype,"setLocalVideoMirrorType",1),__decorateClass3([reportRtcSdkApiCall()],RTCEngine.prototype,"setAudioPlaybackDevice",1),__decorateClass3([reportRtcSdkApiCall()],RTCEngine.prototype,"play",1),__decorateClass3([reportRtcSdkApiCall()],RTCEngine.prototype,"pauseAllSubscribedStream",1),__decorateClass3([reportRtcSdkApiCall()],RTCEngine.prototype,"resumeAllSubscribedStream",1),__decorateClass3([reportRtcSdkApiCall()],RTCEngine.prototype,"sendUserMessage",1),__decorateClass3([reportRtcSdkApiCall()],RTCEngine.prototype,"sendUserBinaryMessage",1),__decorateClass3([reportRtcSdkApiCall()],RTCEngine.prototype,"sendRoomMessage",1),__decorateClass3([reportRtcSdkApiCall()],RTCEngine.prototype,"sendRoomBinaryMessage",1),__decorateClass3([reportRtcSdkApiCall()],RTCEngine.prototype,"setAudioCaptureConfig",1),__decorateClass3([warnDeprecatedApi("4.51"),reportRtcSdkApiCall()],RTCEngine.prototype,"setVideoCaptureConfig",1),__decorateClass3([reportRtcSdkApiCall()],RTCEngine.prototype,"enableSimulcastMode",1),__decorateClass3([reportRtcSdkApiCall()],RTCEngine.prototype,"setVideoEncoderConfig",1),__decorateClass3([reportRtcSdkApiCall()],RTCEngine.prototype,"setScreenEncoderConfig",1),__decorateClass3([reportRtcSdkApiCall()],RTCEngine.prototype,"sendSEIMessage",1),__decorateClass3([warnDeprecatedApi("4.42"),reportRtcSdkApiCall()],RTCEngine.prototype,"setAudioVolumeIndicationInterval",1),__decorateClass3([reportRtcSdkApiCall()],RTCEngine.prototype,"enableAudioPropertiesReport",1),__decorateClass3([reportRtcSdkApiCall()],RTCEngine.prototype,"setVideoSourceType",1),__decorateClass3([reportRtcSdkApiCall()],RTCEngine.prototype,"setExternalVideoTrack",1),__decorateClass3([reportRtcSdkApiCall()],RTCEngine.prototype,"setAudioSourceType",1),__decorateClass3([reportRtcSdkApiCall()],RTCEngine.prototype,"setExternalAudioTrack",1),__decorateClass3([reportRtcSdkApiCall()],RTCEngine.prototype,"login",1),__decorateClass3([reportRtcSdkApiCall()],RTCEngine.prototype,"logout",1),__decorateClass3([reportRtcSdkApiCall()],RTCEngine.prototype,"updateLoginToken",1),__decorateClass3([reportRtcSdkApiCall()],RTCEngine.prototype,"getPeerOnlineStatus",1),__decorateClass3([reportRtcSdkApiCall()],RTCEngine.prototype,"sendUserMessageOutsideRoom",1),__decorateClass3([reportRtcSdkApiCall()],RTCEngine.prototype,"sendUserBinaryMessageOutsideRoom",1),__decorateClass3([reportRtcSdkApiCall()],RTCEngine.prototype,"setServerParams",1),__decorateClass3([reportRtcSdkApiCall()],RTCEngine.prototype,"sendServerMessage",1),__decorateClass3([reportRtcSdkApiCall()],RTCEngine.prototype,"sendServerBinaryMessage",1),__decorateClass3([reportRtcSdkApiCall()],RTCEngine.prototype,"startCloudProxy",1),__decorateClass3([reportRtcSdkApiCall()],RTCEngine.prototype,"stopCloudProxy",1),__decorateClass3([reportRtcSdkApiCall()],RTCEngine.prototype,"startPushPublicStream",1),__decorateClass3([reportRtcSdkApiCall()],RTCEngine.prototype,"updatePublicStreamParam",1),__decorateClass3([reportRtcSdkApiCall()],RTCEngine.prototype,"stopPushPublicStream",1),__decorateClass3([reportRtcSdkApiCall("streamId")],RTCEngine.prototype,"startPlayPublicStream",1),__decorateClass3([reportRtcSdkApiCall("streamId")],RTCEngine.prototype,"stopPlayPublicStream",1),__decorateClass3([reportRtcSdkApiCall()],RTCEngine.prototype,"setAudioProfile",1),__decorateClass3([reportRtcSdkApiCall()],RTCEngine.prototype,"setPublicStreamVideoPlayer",1),__decorateClass3([reportRtcSdkApiCall()],RTCEngine.prototype,"setDummyCaptureImagePath",1),__decorateClass3([reportRtcSdkApiCall()],RTCEngine.prototype,"registerExtension",1),__decorateClass3([reportRtcSdkApiCall()],RTCEngine.prototype,"startAudioPlaybackDeviceTest",1),__decorateClass3([reportRtcSdkApiCall()],RTCEngine.prototype,"stopAudioPlaybackDeviceTest",1),__decorateClass3([reportRtcSdkApiCall()],RTCEngine.prototype,"startAudioDeviceRecordTest",1),__decorateClass3([reportRtcSdkApiCall()],RTCEngine.prototype,"stopAudioDeviceRecordAndPlayTest",1),__decorateClass3([reportRtcSdkApiCall()],RTCEngine.prototype,"stopAudioDevicePlayTest",1),__decorateClass3([reportRtcSdkApiCall()],RTCEngine.prototype,"setRemoteUserPriority",1),__decorateClass3([reportRtcSdkApiCall()],RTCEngine.prototype,"takeLocalSnapshot",1),__decorateClass3([reportRtcSdkApiCall()],RTCEngine.prototype,"takeRemoteSnapshot",1),__decorateClass3([reportRtcSdkApiCall()],RTCEngine.prototype,"setSubscribeFallbackOption",1),__decorateClass3([reportRtcSdkApiCall()],RTCEngine.prototype,"getLocalStreamTrack",1),__decorateClass3([reportRtcSdkApiCall()],RTCEngine.prototype,"getRemoteStreamTrack",1),__decorateClass3([reportRtcSdkApiCall()],RTCEngine.prototype,"getPublicStreamTrack",1),__decorateClass3([reportRtcSdkApiCall()],RTCEngine.prototype,"setRemoteStreamRenderSync",1);var _context,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);iDB.storeKey=concat$2(_context="".concat(Date.now(),"-")).call(_context,sdkCache.getDeviceId()),setGlobalStats({rtc_sdk_version:Config.VERSION,device_id:sdkCache.getDeviceId(),log_cache_key:iDB.storeKey}),setReportUrl(Config.LOG_SERVER_URL);var ENGINE_GUID=1,createEngine=function(e,t){logger.print("createEngine","Invoke VERTC.createEngine"),checkString(e,"appId");var r=(ENGINE_GUID++).toString();return createMonitor(r,{rtc_app_id:e,auto_play_policy:null==t?void 0:t.autoPlayPolicy}),new RTCEngine(e,r,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(),destroyMonitor(e.monitor)},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",dd.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,a,s=arguments;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=s.length>0&&void 0!==s[0]?s[0]:{video:!0,audio:!0},r=t.video,n=t.audio,i={video:!1,audio:!1},!r){e.next=13;break}return e.prev=4,e.next=7,dd.getPermissions({video:!0,force:!0});case 7:o=e.sent,i.video=o.video,e.next=13;break;case 11:e.prev=11,e.t0=e.catch(4);case 13:if(!n){e.next=23;break}return e.prev=14,e.next=17,dd.getPermissions({audio:!0,force:!0});case 17:a=e.sent,i.audio=a.audio,e.next=23;break;case 21:e.prev=21,e.t1=e.catch(14);case 23:return e.abrupt("return",i);case 24:case"end":return e.stop()}}),e,null,[[4,11],[14,21]])})));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",dd.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",dd.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",dd.enumerateAudioPlaybackDevices());case 1:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),getSdkVersion=function(){return Config.VERSION},isSupported2=function(){return reportGlobalApiCall("isSupported",0,""),isSupported()},getSupportedCodecs2=function(){return reportGlobalApiCall("getSupportedCodecs",0,""),getSupportedCodecs()},setLogConfig=function(e){var t=e.logLevel,r=e.LogfileSize;t&&(iDB.logLevel=t),r&&(iDB.LogfileSize=r)},downloadLog=function(e){iDB.download(e)};function stringifyParams(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return stringify$1(map$6(t).call(t,(function(e){return e instanceof RTCEngine?"[ENGINE]":e})))}function reportVERTCApiCall(e,t){return function(){reportGlobalApiCall(t,0,stringifyParams.apply(void 0,arguments));var r=e.apply(void 0,arguments);return"function"==typeof(null==r?void 0:r.then)?r.then((function(e){return reportGlobalCallback(t,0,stringifyParams(e)),e})).catch((function(e){throw reportGlobalCallback(t,e.code,e.message),e})):(reportGlobalCallback(t,0,stringifyParams(r)),r)}}var VERTC=_createClass((function e(){_classCallCheck(this,e),_defineProperty(this,"getSdkVersion",reportVERTCApiCall(getSdkVersion,"getSdkVersion")),_defineProperty(this,"createEngine",reportVERTCApiCall(createEngine,"createEngine")),_defineProperty(this,"destroyEngine",reportVERTCApiCall(destroyEngine,"destroyEngine")),_defineProperty(this,"enumerateDevices",reportVERTCApiCall(enumerateDevices,"enumerateDevices")),_defineProperty(this,"enableDevices",reportVERTCApiCall(enableDevices,"enableDevices")),_defineProperty(this,"enumerateAudioCaptureDevices",reportVERTCApiCall(enumerateAudioCaptureDevices,"enumerateAudioCaptureDevices")),_defineProperty(this,"enumerateVideoCaptureDevices",reportVERTCApiCall(enumerateVideoCaptureDevices,"enumerateVideoCaptureDevices")),_defineProperty(this,"enumerateAudioPlaybackDevices",reportVERTCApiCall(enumerateAudioPlaybackDevices,"enumerateAudioPlaybackDevices")),_defineProperty(this,"getParameter",getParameter),_defineProperty(this,"setParameter",setParameter),_defineProperty(this,"isSupported",reportVERTCApiCall(isSupported2,"isSupported")),_defineProperty(this,"getSupportedCodecs",reportVERTCApiCall(getSupportedCodecs2,"getSupportedCodecs")),_defineProperty(this,"events",EngineEventsTypes),_defineProperty(this,"ErrorCode",ErrorCode),_defineProperty(this,"platform","BytePlus"),_defineProperty(this,"downloadLog",reportVERTCApiCall(downloadLog,"downloadLog")),_defineProperty(this,"setLogConfig",reportVERTCApiCall(setLogConfig,"setLogConfig"))})),index=new VERTC;export{AAC_PROFILE,AudioMixingDualMonoMode,AudioMixingType,AudioProfileType,AudioSourceType,ChannelProfile,ConnectionState,FallbackOrRecoverReason,LogChannel,MediaType,MirrorMode,MirrorType,NetworkQuality,PublicInterpolationMode,PublicStreamType,PublishState,RTCAutoPlayPolicy,RemoteUserPriority,RoomProfileType,SUBTITLE_MODE,StreamIndex,StreamRemoveReason,SubscribeFallbackOption,SubscribeMode,SubscribeState,SubtitleEventType,TRANSCODING_VIDEO_CODEC,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"}))}var commonjsGlobal="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function commonjsRequire(e){throw new Error('Could not dynamically require "'+e+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var defineProperty$i={exports:{}},check=function(e){return e&&e.Math==Math&&e},global$s=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")(),fails$z=function(e){try{return!!e()}catch(e){return!0}},fails$y=fails$z,functionBindNative=!fails$y((function(){var e=function(){}.bind();return"function"!=typeof e||e.hasOwnProperty("prototype")})),NATIVE_BIND$4=functionBindNative,FunctionPrototype$3=Function.prototype,apply$6=FunctionPrototype$3.apply,call$H=FunctionPrototype$3.call,functionApply="object"==typeof Reflect&&Reflect.apply||(NATIVE_BIND$4?call$H.bind(apply$6):function(){return call$H.apply(apply$6,arguments)}),NATIVE_BIND$3=functionBindNative,FunctionPrototype$2=Function.prototype,call$G=FunctionPrototype$2.call,uncurryThisWithBind=NATIVE_BIND$3&&FunctionPrototype$2.bind.bind(call$G,call$G),functionUncurryThisRaw=NATIVE_BIND$3?uncurryThisWithBind:function(e){return function(){return call$G.apply(e,arguments)}},uncurryThisRaw$1=functionUncurryThisRaw,toString$j=uncurryThisRaw$1({}.toString),stringSlice$5=uncurryThisRaw$1("".slice),classofRaw$2=function(e){return stringSlice$5(toString$j(e),8,-1)},classofRaw$1=classofRaw$2,uncurryThisRaw=functionUncurryThisRaw,functionUncurryThis=function(e){if("Function"===classofRaw$1(e))return uncurryThisRaw(e)},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$n=$documentAll$1.IS_HTMLDDA?function(e){return"function"==typeof e||e===documentAll$1}:function(e){return"function"==typeof e},objectGetOwnPropertyDescriptor={},fails$x=fails$z,descriptors=!fails$x((function(){return 7!=Object.defineProperty({},1,{get:function(){return 7}})[1]})),NATIVE_BIND$2=functionBindNative,call$F=Function.prototype.call,functionCall=NATIVE_BIND$2?call$F.bind(call$F):function(){return call$F.apply(call$F,arguments)},objectPropertyIsEnumerable={},$propertyIsEnumerable$2={}.propertyIsEnumerable,getOwnPropertyDescriptor$b=Object.getOwnPropertyDescriptor,NASHORN_BUG=getOwnPropertyDescriptor$b&&!$propertyIsEnumerable$2.call({1:2},1);objectPropertyIsEnumerable.f=NASHORN_BUG?function(e){var t=getOwnPropertyDescriptor$b(this,e);return!!t&&t.enumerable}:$propertyIsEnumerable$2;var match,version,createPropertyDescriptor$9=function(e,t){return{enumerable:!(1&e),configurable:!(2&e),writable:!(4&e),value:t}},uncurryThis$B=functionUncurryThis,fails$w=fails$z,classof$f=classofRaw$2,$Object$4=Object,split$3=uncurryThis$B("".split),indexedObject=fails$w((function(){return!$Object$4("z").propertyIsEnumerable(0)}))?function(e){return"String"==classof$f(e)?split$3(e,""):$Object$4(e)}:$Object$4,isNullOrUndefined$7=function(e){return null==e},isNullOrUndefined$6=isNullOrUndefined$7,$TypeError$l=TypeError,requireObjectCoercible$9=function(e){if(isNullOrUndefined$6(e))throw $TypeError$l("Can't call method on "+e);return e},IndexedObject$3=indexedObject,requireObjectCoercible$8=requireObjectCoercible$9,toIndexedObject$b=function(e){return IndexedObject$3(requireObjectCoercible$8(e))},isCallable$m=isCallable$n,$documentAll=documentAll_1,documentAll=$documentAll.all,isObject$q=$documentAll.IS_HTMLDDA?function(e){return"object"==typeof e?null!==e:isCallable$m(e)||e===documentAll}:function(e){return"object"==typeof e?null!==e:isCallable$m(e)},path$v={},path$u=path$v,global$r=global$s,isCallable$l=isCallable$n,aFunction=function(e){return isCallable$l(e)?e:void 0},getBuiltIn$o=function(e,t){return arguments.length<2?aFunction(path$u[e])||aFunction(global$r[e]):path$u[e]&&path$u[e][t]||global$r[e]&&global$r[e][t]},uncurryThis$A=functionUncurryThis,objectIsPrototypeOf=uncurryThis$A({}.isPrototypeOf),getBuiltIn$n=getBuiltIn$o,engineUserAgent=getBuiltIn$n("navigator","userAgent")||"",global$q=global$s,userAgent$6=engineUserAgent,process$3=global$q.process,Deno$1=global$q.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$v=fails$z,symbolConstructorDetection=!!Object.getOwnPropertySymbols&&!fails$v((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,getBuiltIn$m=getBuiltIn$o,isCallable$k=isCallable$n,isPrototypeOf$r=objectIsPrototypeOf,USE_SYMBOL_AS_UID$1=useSymbolAsUid,$Object$3=Object,isSymbol$4=USE_SYMBOL_AS_UID$1?function(e){return"symbol"==typeof e}:function(e){var t=getBuiltIn$m("Symbol");return isCallable$k(t)&&isPrototypeOf$r(t.prototype,$Object$3(e))},$String$3=String,tryToString$6=function(e){try{return $String$3(e)}catch(e){return"Object"}},isCallable$j=isCallable$n,tryToString$5=tryToString$6,$TypeError$k=TypeError,aCallable$z=function(e){if(isCallable$j(e))return e;throw $TypeError$k(tryToString$5(e)+" is not a function")},aCallable$y=aCallable$z,isNullOrUndefined$5=isNullOrUndefined$7,getMethod$3=function(e,t){var r=e[t];return isNullOrUndefined$5(r)?void 0:aCallable$y(r)},call$E=functionCall,isCallable$i=isCallable$n,isObject$p=isObject$q,$TypeError$j=TypeError,ordinaryToPrimitive$1=function(e,t){var r,n;if("string"===t&&isCallable$i(r=e.toString)&&!isObject$p(n=call$E(r,e)))return n;if(isCallable$i(r=e.valueOf)&&!isObject$p(n=call$E(r,e)))return n;if("string"!==t&&isCallable$i(r=e.toString)&&!isObject$p(n=call$E(r,e)))return n;throw $TypeError$j("Can't convert object to primitive value")},shared$6={exports:{}},isPure=!0,global$p=global$s,defineProperty$h=Object.defineProperty,defineGlobalProperty$1=function(e,t){try{defineProperty$h(global$p,e,{value:t,configurable:!0,writable:!0})}catch(r){global$p[e]=t}return t},global$o=global$s,defineGlobalProperty=defineGlobalProperty$1,SHARED="__core-js_shared__",store$3=global$o[SHARED]||defineGlobalProperty(SHARED,{}),sharedStore=store$3,IS_PURE$3=isPure,store$2=sharedStore;(shared$6.exports=function(e,t){return store$2[e]||(store$2[e]=void 0!==t?t:{})})("versions",[]).push({version:"3.26.0",mode:IS_PURE$3?"pure":"global",copyright:"© 2014-2022 Denis Pushkarev (zloirock.ru)",license:"https://github.com/zloirock/core-js/blob/v3.26.0/LICENSE",source:"https://github.com/zloirock/core-js"});var requireObjectCoercible$7=requireObjectCoercible$9,$Object$2=Object,toObject$d=function(e){return $Object$2(requireObjectCoercible$7(e))},uncurryThis$z=functionUncurryThis,toObject$c=toObject$d,hasOwnProperty$a=uncurryThis$z({}.hasOwnProperty),hasOwnProperty_1=Object.hasOwn||function(e,t){return hasOwnProperty$a(toObject$c(e),t)},uncurryThis$y=functionUncurryThis,id$2=0,postfix=Math.random(),toString$i=uncurryThis$y(1..toString),uid$4=function(e){return"Symbol("+(void 0===e?"":e)+")_"+toString$i(++id$2+postfix,36)},global$n=global$s,shared$5=shared$6.exports,hasOwn$n=hasOwnProperty_1,uid$3=uid$4,NATIVE_SYMBOL$4=symbolConstructorDetection,USE_SYMBOL_AS_UID=useSymbolAsUid,WellKnownSymbolsStore$1=shared$5("wks"),Symbol$5=global$n.Symbol,symbolFor=Symbol$5&&Symbol$5.for,createWellKnownSymbol=USE_SYMBOL_AS_UID?Symbol$5:Symbol$5&&Symbol$5.withoutSetter||uid$3,wellKnownSymbol$p=function(e){if(!hasOwn$n(WellKnownSymbolsStore$1,e)||!NATIVE_SYMBOL$4&&"string"!=typeof WellKnownSymbolsStore$1[e]){var t="Symbol."+e;NATIVE_SYMBOL$4&&hasOwn$n(Symbol$5,e)?WellKnownSymbolsStore$1[e]=Symbol$5[e]:WellKnownSymbolsStore$1[e]=USE_SYMBOL_AS_UID&&symbolFor?symbolFor(t):createWellKnownSymbol(t)}return WellKnownSymbolsStore$1[e]},call$D=functionCall,isObject$o=isObject$q,isSymbol$3=isSymbol$4,getMethod$2=getMethod$3,ordinaryToPrimitive=ordinaryToPrimitive$1,wellKnownSymbol$o=wellKnownSymbol$p,$TypeError$i=TypeError,TO_PRIMITIVE=wellKnownSymbol$o("toPrimitive"),toPrimitive$7=function(e,t){if(!isObject$o(e)||isSymbol$3(e))return e;var r,n=getMethod$2(e,TO_PRIMITIVE);if(n){if(void 0===t&&(t="default"),r=call$D(n,e,t),!isObject$o(r)||isSymbol$3(r))return r;throw $TypeError$i("Can't convert object to primitive value")}return void 0===t&&(t="number"),ordinaryToPrimitive(e,t)},toPrimitive$6=toPrimitive$7,isSymbol$2=isSymbol$4,toPropertyKey$4=function(e){var t=toPrimitive$6(e,"string");return isSymbol$2(t)?t:t+""},global$m=global$s,isObject$n=isObject$q,document$3=global$m.document,EXISTS$1=isObject$n(document$3)&&isObject$n(document$3.createElement),documentCreateElement$1=function(e){return EXISTS$1?document$3.createElement(e):{}},DESCRIPTORS$l=descriptors,fails$u=fails$z,createElement$2=documentCreateElement$1,ie8DomDefine=!DESCRIPTORS$l&&!fails$u((function(){return 7!=Object.defineProperty(createElement$2("div"),"a",{get:function(){return 7}}).a})),DESCRIPTORS$k=descriptors,call$C=functionCall,propertyIsEnumerableModule$2=objectPropertyIsEnumerable,createPropertyDescriptor$8=createPropertyDescriptor$9,toIndexedObject$a=toIndexedObject$b,toPropertyKey$3=toPropertyKey$4,hasOwn$m=hasOwnProperty_1,IE8_DOM_DEFINE$1=ie8DomDefine,$getOwnPropertyDescriptor$2=Object.getOwnPropertyDescriptor;objectGetOwnPropertyDescriptor.f=DESCRIPTORS$k?$getOwnPropertyDescriptor$2:function(e,t){if(e=toIndexedObject$a(e),t=toPropertyKey$3(t),IE8_DOM_DEFINE$1)try{return $getOwnPropertyDescriptor$2(e,t)}catch(e){}if(hasOwn$m(e,t))return createPropertyDescriptor$8(!call$C(propertyIsEnumerableModule$2.f,e,t),e[t])};var fails$t=fails$z,isCallable$h=isCallable$n,replacement=/#|\.prototype\./,isForced$2=function(e,t){var r=data[normalize(e)];return r==POLYFILL||r!=NATIVE&&(isCallable$h(t)?fails$t(t):!!t)},normalize=isForced$2.normalize=function(e){return String(e).replace(replacement,".").toLowerCase()},data=isForced$2.data={},NATIVE=isForced$2.NATIVE="N",POLYFILL=isForced$2.POLYFILL="P",isForced_1=isForced$2,uncurryThis$x=functionUncurryThis,aCallable$x=aCallable$z,NATIVE_BIND$1=functionBindNative,bind$w=functionUncurryThis(functionUncurryThis.bind),functionBindContext=function(e,t){return aCallable$x(e),void 0===t?e:NATIVE_BIND$1?bind$w(e,t):function(){return e.apply(t,arguments)}},objectDefineProperty={},DESCRIPTORS$j=descriptors,fails$s=fails$z,v8PrototypeDefineBug=DESCRIPTORS$j&&fails$s((function(){return 42!=Object.defineProperty((function(){}),"prototype",{value:42,writable:!1}).prototype})),isObject$m=isObject$q,$String$2=String,$TypeError$h=TypeError,anObject$M=function(e){if(isObject$m(e))return e;throw $TypeError$h($String$2(e)+" is not an object")},DESCRIPTORS$i=descriptors,IE8_DOM_DEFINE=ie8DomDefine,V8_PROTOTYPE_DEFINE_BUG$1=v8PrototypeDefineBug,anObject$L=anObject$M,toPropertyKey$2=toPropertyKey$4,$TypeError$g=TypeError,$defineProperty$1=Object.defineProperty,$getOwnPropertyDescriptor$1=Object.getOwnPropertyDescriptor,ENUMERABLE="enumerable",CONFIGURABLE$1="configurable",WRITABLE="writable";objectDefineProperty.f=DESCRIPTORS$i?V8_PROTOTYPE_DEFINE_BUG$1?function(e,t,r){if(anObject$L(e),t=toPropertyKey$2(t),anObject$L(r),"function"==typeof e&&"prototype"===t&&"value"in r&&WRITABLE in r&&!r[WRITABLE]){var n=$getOwnPropertyDescriptor$1(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$L(e),t=toPropertyKey$2(t),anObject$L(r),IE8_DOM_DEFINE)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 DESCRIPTORS$h=descriptors,definePropertyModule$6=objectDefineProperty,createPropertyDescriptor$7=createPropertyDescriptor$9,createNonEnumerableProperty$8=DESCRIPTORS$h?function(e,t,r){return definePropertyModule$6.f(e,t,createPropertyDescriptor$7(1,r))}:function(e,t,r){return e[t]=r,e},global$l=global$s,apply$5=functionApply,uncurryThis$w=functionUncurryThis,isCallable$g=isCallable$n,getOwnPropertyDescriptor$a=objectGetOwnPropertyDescriptor.f,isForced$1=isForced_1,path$t=path$v,bind$v=functionBindContext,createNonEnumerableProperty$7=createNonEnumerableProperty$8,hasOwn$l=hasOwnProperty_1,wrapConstructor=function(e){var t=function(r,n,i){if(this instanceof t){switch(arguments.length){case 0:return new e;case 1:return new e(r);case 2:return new e(r,n)}return new e(r,n,i)}return apply$5(e,this,arguments)};return t.prototype=e.prototype,t},_export=function(e,t){var r,n,i,o,a,s,c,l,u=e.target,d=e.global,p=e.stat,_=e.proto,h=d?global$l:p?global$l[u]:(global$l[u]||{}).prototype,f=d?path$t:path$t[u]||createNonEnumerableProperty$7(path$t,u,{})[u],m=f.prototype;for(i in t)r=!isForced$1(d?i:u+(p?".":"#")+i,e.forced)&&h&&hasOwn$l(h,i),a=f[i],r&&(s=e.dontCallGetSet?(l=getOwnPropertyDescriptor$a(h,i))&&l.value:h[i]),o=r&&s?s:t[i],r&&typeof a==typeof o||(c=e.bind&&r?bind$v(o,global$l):e.wrap&&r?wrapConstructor(o):_&&isCallable$g(o)?uncurryThis$w(o):o,(e.sham||o&&o.sham||a&&a.sham)&&createNonEnumerableProperty$7(c,"sham",!0),createNonEnumerableProperty$7(f,i,c),_&&(hasOwn$l(path$t,n=u+"Prototype")||createNonEnumerableProperty$7(path$t,n,{}),createNonEnumerableProperty$7(path$t[n],i,o),e.real&&m&&!m[i]&&createNonEnumerableProperty$7(m,i,o)))},$$1D=_export,DESCRIPTORS$g=descriptors,defineProperty$g=objectDefineProperty.f;$$1D({target:"Object",stat:!0,forced:Object.defineProperty!==defineProperty$g,sham:!DESCRIPTORS$g},{defineProperty:defineProperty$g});var path$s=path$v,Object$4=path$s.Object,defineProperty$f=defineProperty$i.exports=function(e,t,r){return Object$4.defineProperty(e,t,r)};Object$4.defineProperty.sham&&(defineProperty$f.sham=!0);var parent$2x=defineProperty$i.exports,defineProperty$e=parent$2x,parent$2w=defineProperty$e,defineProperty$d=parent$2w,parent$2v=defineProperty$d,defineProperty$c=parent$2v,defineProperty$b=defineProperty$c,defineProperty$a=defineProperty$b,classof$e=classofRaw$2,isArray$f=Array.isArray||function(e){return"Array"==classof$e(e)},ceil$1=Math.ceil,floor$3=Math.floor,mathTrunc=Math.trunc||function(e){var t=+e;return(t>0?floor$3:ceil$1)(t)},trunc2=mathTrunc,toIntegerOrInfinity$5=function(e){var t=+e;return t!=t||0===t?0:trunc2(t)},toIntegerOrInfinity$4=toIntegerOrInfinity$5,min$4=Math.min,toLength$4=function(e){return e>0?min$4(toIntegerOrInfinity$4(e),9007199254740991):0},toLength$3=toLength$4,lengthOfArrayLike$b=function(e){return toLength$3(e.length)},$TypeError$f=TypeError,MAX_SAFE_INTEGER$2=9007199254740991,doesNotExceedSafeInteger$2=function(e){if(e>MAX_SAFE_INTEGER$2)throw $TypeError$f("Maximum allowed index exceeded");return e},toPropertyKey$1=toPropertyKey$4,definePropertyModule$5=objectDefineProperty,createPropertyDescriptor$6=createPropertyDescriptor$9,createProperty$6=function(e,t,r){var n=toPropertyKey$1(t);n in e?definePropertyModule$5.f(e,n,createPropertyDescriptor$6(0,r)):e[n]=r},wellKnownSymbol$n=wellKnownSymbol$p,TO_STRING_TAG$4=wellKnownSymbol$n("toStringTag"),test$2={};test$2[TO_STRING_TAG$4]="z";var toStringTagSupport="[object z]"===String(test$2),TO_STRING_TAG_SUPPORT$2=toStringTagSupport,isCallable$f=isCallable$n,classofRaw=classofRaw$2,wellKnownSymbol$m=wellKnownSymbol$p,TO_STRING_TAG$3=wellKnownSymbol$m("toStringTag"),$Object$1=Object,CORRECT_ARGUMENTS="Arguments"==classofRaw(function(){return arguments}()),tryGet=function(e,t){try{return e[t]}catch(e){}},classof$d=TO_STRING_TAG_SUPPORT$2?classofRaw:function(e){var t,r,n;return void 0===e?"Undefined":null===e?"Null":"string"==typeof(r=tryGet(t=$Object$1(e),TO_STRING_TAG$3))?r:CORRECT_ARGUMENTS?classofRaw(t):"Object"==(n=classofRaw(t))&&isCallable$f(t.callee)?"Arguments":n},uncurryThis$v=functionUncurryThis,isCallable$e=isCallable$n,store$1=sharedStore,functionToString=uncurryThis$v(Function.toString);isCallable$e(store$1.inspectSource)||(store$1.inspectSource=function(e){return functionToString(e)});var inspectSource$2=store$1.inspectSource,uncurryThis$u=functionUncurryThis,fails$r=fails$z,isCallable$d=isCallable$n,classof$c=classof$d,getBuiltIn$l=getBuiltIn$o,inspectSource$1=inspectSource$2,noop=function(){},empty=[],construct$7=getBuiltIn$l("Reflect","construct"),constructorRegExp=/^\s*(?:class|function)\b/,exec$4=uncurryThis$u(constructorRegExp.exec),INCORRECT_TO_STRING=!constructorRegExp.exec(noop),isConstructorModern=function(e){if(!isCallable$d(e))return!1;try{return construct$7(noop,empty,e),!0}catch(e){return!1}},isConstructorLegacy=function(e){if(!isCallable$d(e))return!1;switch(classof$c(e)){case"AsyncFunction":case"GeneratorFunction":case"AsyncGeneratorFunction":return!1}try{return INCORRECT_TO_STRING||!!exec$4(constructorRegExp,inspectSource$1(e))}catch(e){return!0}};isConstructorLegacy.sham=!0;var isConstructor$4=!construct$7||fails$r((function(){var e;return isConstructorModern(isConstructorModern.call)||!isConstructorModern(Object)||!isConstructorModern((function(){e=!0}))||e}))?isConstructorLegacy:isConstructorModern,isArray$e=isArray$f,isConstructor$3=isConstructor$4,isObject$l=isObject$q,wellKnownSymbol$l=wellKnownSymbol$p,SPECIES$5=wellKnownSymbol$l("species"),$Array$3=Array,arraySpeciesConstructor$1=function(e){var t;return isArray$e(e)&&(t=e.constructor,(isConstructor$3(t)&&(t===$Array$3||isArray$e(t.prototype))||isObject$l(t)&&null===(t=t[SPECIES$5]))&&(t=void 0)),void 0===t?$Array$3:t},arraySpeciesConstructor=arraySpeciesConstructor$1,arraySpeciesCreate$3=function(e,t){return new(arraySpeciesConstructor(e))(0===t?0:t)},fails$q=fails$z,wellKnownSymbol$k=wellKnownSymbol$p,V8_VERSION$2=engineV8Version,SPECIES$4=wellKnownSymbol$k("species"),arrayMethodHasSpeciesSupport$5=function(e){return V8_VERSION$2>=51||!fails$q((function(){var t=[];return(t.constructor={})[SPECIES$4]=function(){return{foo:1}},1!==t[e](Boolean).foo}))},$$1C=_export,fails$p=fails$z,isArray$d=isArray$f,isObject$k=isObject$q,toObject$b=toObject$d,lengthOfArrayLike$a=lengthOfArrayLike$b,doesNotExceedSafeInteger$1=doesNotExceedSafeInteger$2,createProperty$5=createProperty$6,arraySpeciesCreate$2=arraySpeciesCreate$3,arrayMethodHasSpeciesSupport$4=arrayMethodHasSpeciesSupport$5,wellKnownSymbol$j=wellKnownSymbol$p,V8_VERSION$1=engineV8Version,IS_CONCAT_SPREADABLE=wellKnownSymbol$j("isConcatSpreadable"),IS_CONCAT_SPREADABLE_SUPPORT=V8_VERSION$1>=51||!fails$p((function(){var e=[];return e[IS_CONCAT_SPREADABLE]=!1,e.concat()[0]!==e})),SPECIES_SUPPORT=arrayMethodHasSpeciesSupport$4("concat"),isConcatSpreadable=function(e){if(!isObject$k(e))return!1;var t=e[IS_CONCAT_SPREADABLE];return void 0!==t?!!t:isArray$d(e)},FORCED$6=!IS_CONCAT_SPREADABLE_SUPPORT||!SPECIES_SUPPORT;$$1C({target:"Array",proto:!0,arity:1,forced:FORCED$6},{concat:function(e){var t,r,n,i,o,a=toObject$b(this),s=arraySpeciesCreate$2(a,0),c=0;for(t=-1,n=arguments.length;t<n;t++)if(isConcatSpreadable(o=-1===t?a:arguments[t]))for(i=lengthOfArrayLike$a(o),doesNotExceedSafeInteger$1(c+i),r=0;r<i;r++,c++)r in o&&createProperty$5(s,c,o[r]);else doesNotExceedSafeInteger$1(c+1),createProperty$5(s,c++,o);return s.length=c,s}});var classof$b=classof$d,$String$1=String,toString$h=function(e){if("Symbol"===classof$b(e))throw TypeError("Cannot convert a Symbol value to a string");return $String$1(e)},objectDefineProperties={},toIntegerOrInfinity$3=toIntegerOrInfinity$5,max$3=Math.max,min$3=Math.min,toAbsoluteIndex$5=function(e,t){var r=toIntegerOrInfinity$3(e);return r<0?max$3(r+t,0):min$3(r,t)},toIndexedObject$9=toIndexedObject$b,toAbsoluteIndex$4=toAbsoluteIndex$5,lengthOfArrayLike$9=lengthOfArrayLike$b,createMethod$6=function(e){return function(t,r,n){var i,o=toIndexedObject$9(t),a=lengthOfArrayLike$9(o),s=toAbsoluteIndex$4(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)},hiddenKeys$6={},uncurryThis$t=functionUncurryThis,hasOwn$k=hasOwnProperty_1,toIndexedObject$8=toIndexedObject$b,indexOf$7=arrayIncludes.indexOf,hiddenKeys$5=hiddenKeys$6,push$c=uncurryThis$t([].push),objectKeysInternal=function(e,t){var r,n=toIndexedObject$8(e),i=0,o=[];for(r in n)!hasOwn$k(hiddenKeys$5,r)&&hasOwn$k(n,r)&&push$c(o,r);for(;t.length>i;)hasOwn$k(n,r=t[i++])&&(~indexOf$7(o,r)||push$c(o,r));return o},enumBugKeys$3=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"],internalObjectKeys$1=objectKeysInternal,enumBugKeys$2=enumBugKeys$3,objectKeys$4=Object.keys||function(e){return internalObjectKeys$1(e,enumBugKeys$2)},DESCRIPTORS$f=descriptors,V8_PROTOTYPE_DEFINE_BUG=v8PrototypeDefineBug,definePropertyModule$4=objectDefineProperty,anObject$K=anObject$M,toIndexedObject$7=toIndexedObject$b,objectKeys$3=objectKeys$4;objectDefineProperties.f=DESCRIPTORS$f&&!V8_PROTOTYPE_DEFINE_BUG?Object.defineProperties:function(e,t){anObject$K(e);for(var r,n=toIndexedObject$7(t),i=objectKeys$3(t),o=i.length,a=0;o>a;)definePropertyModule$4.f(e,r=i[a++],n[r]);return e};var activeXDocument,getBuiltIn$k=getBuiltIn$o,html$2=getBuiltIn$k("document","documentElement"),shared$4=shared$6.exports,uid$2=uid$4,keys$e=shared$4("keys"),sharedKey$4=function(e){return keys$e[e]||(keys$e[e]=uid$2(e))},anObject$J=anObject$M,definePropertiesModule$1=objectDefineProperties,enumBugKeys$1=enumBugKeys$3,hiddenKeys$4=hiddenKeys$6,html$1=html$2,documentCreateElement=documentCreateElement$1,sharedKey$3=sharedKey$4,GT=">",LT="<",PROTOTYPE$1="prototype",SCRIPT="script",IE_PROTO$1=sharedKey$3("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$1.length;e--;)delete NullProtoObject[PROTOTYPE$1][enumBugKeys$1[e]];return NullProtoObject()};hiddenKeys$4[IE_PROTO$1]=!0;var objectCreate$1=Object.create||function(e,t){var r;return null!==e?(EmptyConstructor[PROTOTYPE$1]=anObject$J(e),r=new EmptyConstructor,EmptyConstructor[PROTOTYPE$1]=null,r[IE_PROTO$1]=e):r=NullProtoObject(),void 0===t?r:definePropertiesModule$1.f(r,t)},objectGetOwnPropertyNames={},internalObjectKeys=objectKeysInternal,enumBugKeys=enumBugKeys$3,hiddenKeys$3=enumBugKeys.concat("length","prototype");objectGetOwnPropertyNames.f=Object.getOwnPropertyNames||function(e){return internalObjectKeys(e,hiddenKeys$3)};var objectGetOwnPropertyNamesExternal={},toAbsoluteIndex$3=toAbsoluteIndex$5,lengthOfArrayLike$8=lengthOfArrayLike$b,createProperty$4=createProperty$6,$Array$2=Array,max$2=Math.max,arraySliceSimple=function(e,t,r){for(var n=lengthOfArrayLike$8(e),i=toAbsoluteIndex$3(t,n),o=toAbsoluteIndex$3(void 0===r?n:r,n),a=$Array$2(max$2(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$b,$getOwnPropertyNames$1=objectGetOwnPropertyNames.f,arraySlice$7=arraySliceSimple,windowNames="object"==typeof window&&window&&Object.getOwnPropertyNames?Object.getOwnPropertyNames(window):[],getWindowNames=function(e){try{return $getOwnPropertyNames$1(e)}catch(e){return arraySlice$7(windowNames)}};objectGetOwnPropertyNamesExternal.f=function(e){return windowNames&&"Window"==classof$a(e)?getWindowNames(e):$getOwnPropertyNames$1(toIndexedObject$6(e))};var objectGetOwnPropertySymbols={};objectGetOwnPropertySymbols.f=Object.getOwnPropertySymbols;var createNonEnumerableProperty$6=createNonEnumerableProperty$8,defineBuiltIn$8=function(e,t,r,n){return n&&n.enumerable?e[t]=r:createNonEnumerableProperty$6(e,t,r),e},wellKnownSymbolWrapped={},wellKnownSymbol$i=wellKnownSymbol$p;wellKnownSymbolWrapped.f=wellKnownSymbol$i;var set$e,get$7,has,path$r=path$v,hasOwn$j=hasOwnProperty_1,wrappedWellKnownSymbolModule$1=wellKnownSymbolWrapped,defineProperty$9=objectDefineProperty.f,wellKnownSymbolDefine=function(e){var t=path$r.Symbol||(path$r.Symbol={});hasOwn$j(t,e)||defineProperty$9(t,e,{value:wrappedWellKnownSymbolModule$1.f(e)})},call$B=functionCall,getBuiltIn$j=getBuiltIn$o,wellKnownSymbol$h=wellKnownSymbol$p,defineBuiltIn$7=defineBuiltIn$8,symbolDefineToPrimitive=function(){var e=getBuiltIn$j("Symbol"),t=e&&e.prototype,r=t&&t.valueOf,n=wellKnownSymbol$h("toPrimitive");t&&!t[n]&&defineBuiltIn$7(t,n,(function(e){return call$B(r,this)}),{arity:1})},TO_STRING_TAG_SUPPORT$1=toStringTagSupport,classof$9=classof$d,objectToString$1=TO_STRING_TAG_SUPPORT$1?{}.toString:function(){return"[object "+classof$9(this)+"]"},TO_STRING_TAG_SUPPORT=toStringTagSupport,defineProperty$8=objectDefineProperty.f,createNonEnumerableProperty$5=createNonEnumerableProperty$8,hasOwn$i=hasOwnProperty_1,toString$g=objectToString$1,wellKnownSymbol$g=wellKnownSymbol$p,TO_STRING_TAG$2=wellKnownSymbol$g("toStringTag"),setToStringTag$9=function(e,t,r,n){if(e){var i=r?e:e.prototype;hasOwn$i(i,TO_STRING_TAG$2)||defineProperty$8(i,TO_STRING_TAG$2,{configurable:!0,value:t}),n&&!TO_STRING_TAG_SUPPORT&&createNonEnumerableProperty$5(i,"toString",toString$g)}},global$k=global$s,isCallable$c=isCallable$n,WeakMap$3=global$k.WeakMap,weakMapBasicDetection=isCallable$c(WeakMap$3)&&/native code/.test(String(WeakMap$3)),NATIVE_WEAK_MAP$1=weakMapBasicDetection,global$j=global$s,isObject$j=isObject$q,createNonEnumerableProperty$4=createNonEnumerableProperty$8,hasOwn$h=hasOwnProperty_1,shared$3=sharedStore,sharedKey$2=sharedKey$4,hiddenKeys$2=hiddenKeys$6,OBJECT_ALREADY_INITIALIZED="Object already initialized",TypeError$5=global$j.TypeError,WeakMap$2=global$j.WeakMap,enforce=function(e){return has(e)?get$7(e):set$e(e,{})},getterFor=function(e){return function(t){var r;if(!isObject$j(t)||(r=get$7(t)).type!==e)throw TypeError$5("Incompatible receiver, "+e+" required");return r}};if(NATIVE_WEAK_MAP$1||shared$3.state){var store=shared$3.state||(shared$3.state=new WeakMap$2);store.get=store.get,store.has=store.has,store.set=store.set,set$e=function(e,t){if(store.has(e))throw TypeError$5(OBJECT_ALREADY_INITIALIZED);return t.facade=e,store.set(e,t),t},get$7=function(e){return store.get(e)||{}},has=function(e){return store.has(e)}}else{var STATE=sharedKey$2("state");hiddenKeys$2[STATE]=!0,set$e=function(e,t){if(hasOwn$h(e,STATE))throw TypeError$5(OBJECT_ALREADY_INITIALIZED);return t.facade=e,createNonEnumerableProperty$4(e,STATE,t),t},get$7=function(e){return hasOwn$h(e,STATE)?e[STATE]:{}},has=function(e){return hasOwn$h(e,STATE)}}var internalState={set:set$e,get:get$7,has:has,enforce:enforce,getterFor:getterFor},bind$u=functionBindContext,uncurryThis$s=functionUncurryThis,IndexedObject$2=indexedObject,toObject$a=toObject$d,lengthOfArrayLike$7=lengthOfArrayLike$b,arraySpeciesCreate$1=arraySpeciesCreate$3,push$b=uncurryThis$s([].push),createMethod$5=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,l,u,d){for(var p,_,h=toObject$a(c),f=IndexedObject$2(h),m=bind$u(l,u),v=lengthOfArrayLike$7(f),g=0,y=d||arraySpeciesCreate$1,S=t?y(c,v):r||a?y(c,0):void 0;v>g;g++)if((s||g in f)&&(_=m(p=f[g],g,h),e))if(t)S[g]=_;else if(_)switch(e){case 3:return!0;case 5:return p;case 6:return g;case 2:push$b(S,p)}else switch(e){case 4:return!1;case 7:push$b(S,p)}return o?-1:n||i?i:S}},arrayIteration={forEach:createMethod$5(0),map:createMethod$5(1),filter:createMethod$5(2),some:createMethod$5(3),every:createMethod$5(4),find:createMethod$5(5),findIndex:createMethod$5(6),filterReject:createMethod$5(7)},$$1B=_export,global$i=global$s,call$A=functionCall,uncurryThis$r=functionUncurryThis,DESCRIPTORS$e=descriptors,NATIVE_SYMBOL$3=symbolConstructorDetection,fails$o=fails$z,hasOwn$g=hasOwnProperty_1,isPrototypeOf$q=objectIsPrototypeOf,anObject$I=anObject$M,toIndexedObject$5=toIndexedObject$b,toPropertyKey=toPropertyKey$4,$toString$2=toString$h,createPropertyDescriptor$5=createPropertyDescriptor$9,nativeObjectCreate=objectCreate$1,objectKeys$2=objectKeys$4,getOwnPropertyNamesModule$2=objectGetOwnPropertyNames,getOwnPropertyNamesExternal=objectGetOwnPropertyNamesExternal,getOwnPropertySymbolsModule$3=objectGetOwnPropertySymbols,getOwnPropertyDescriptorModule$4=objectGetOwnPropertyDescriptor,definePropertyModule$3=objectDefineProperty,definePropertiesModule=objectDefineProperties,propertyIsEnumerableModule$1=objectPropertyIsEnumerable,defineBuiltIn$6=defineBuiltIn$8,shared$2=shared$6.exports,sharedKey$1=sharedKey$4,hiddenKeys$1=hiddenKeys$6,uid$1=uid$4,wellKnownSymbol$f=wellKnownSymbol$p,wrappedWellKnownSymbolModule=wellKnownSymbolWrapped,defineWellKnownSymbol$l=wellKnownSymbolDefine,defineSymbolToPrimitive$1=symbolDefineToPrimitive,setToStringTag$8=setToStringTag$9,InternalStateModule$8=internalState,$forEach$1=arrayIteration.forEach,HIDDEN=sharedKey$1("hidden"),SYMBOL="Symbol",PROTOTYPE="prototype",setInternalState$8=InternalStateModule$8.set,getInternalState$2=InternalStateModule$8.getterFor(SYMBOL),ObjectPrototype$2=Object[PROTOTYPE],$Symbol=global$i.Symbol,SymbolPrototype=$Symbol&&$Symbol[PROTOTYPE],TypeError$4=global$i.TypeError,QObject=global$i.QObject,nativeGetOwnPropertyDescriptor$1=getOwnPropertyDescriptorModule$4.f,nativeDefineProperty=definePropertyModule$3.f,nativeGetOwnPropertyNames=getOwnPropertyNamesExternal.f,nativePropertyIsEnumerable=propertyIsEnumerableModule$1.f,push$a=uncurryThis$r([].push),AllSymbols=shared$2("symbols"),ObjectPrototypeSymbols=shared$2("op-symbols"),WellKnownSymbolsStore=shared$2("wks"),USE_SETTER=!QObject||!QObject[PROTOTYPE]||!QObject[PROTOTYPE].findChild,setSymbolDescriptor=DESCRIPTORS$e&&fails$o((function(){return 7!=nativeObjectCreate(nativeDefineProperty({},"a",{get:function(){return nativeDefineProperty(this,"a",{value:7}).a}})).a}))?function(e,t,r){var n=nativeGetOwnPropertyDescriptor$1(ObjectPrototype$2,t);n&&delete ObjectPrototype$2[t],nativeDefineProperty(e,t,r),n&&e!==ObjectPrototype$2&&nativeDefineProperty(ObjectPrototype$2,t,n)}:nativeDefineProperty,wrap=function(e,t){var r=AllSymbols[e]=nativeObjectCreate(SymbolPrototype);return setInternalState$8(r,{type:SYMBOL,tag:e,description:t}),DESCRIPTORS$e||(r.description=t),r},$defineProperty=function(e,t,r){e===ObjectPrototype$2&&$defineProperty(ObjectPrototypeSymbols,t,r),anObject$I(e);var n=toPropertyKey(t);return anObject$I(r),hasOwn$g(AllSymbols,n)?(r.enumerable?(hasOwn$g(e,HIDDEN)&&e[HIDDEN][n]&&(e[HIDDEN][n]=!1),r=nativeObjectCreate(r,{enumerable:createPropertyDescriptor$5(0,!1)})):(hasOwn$g(e,HIDDEN)||nativeDefineProperty(e,HIDDEN,createPropertyDescriptor$5(1,{})),e[HIDDEN][n]=!0),setSymbolDescriptor(e,n,r)):nativeDefineProperty(e,n,r)},$defineProperties=function(e,t){anObject$I(e);var r=toIndexedObject$5(t),n=objectKeys$2(r).concat($getOwnPropertySymbols(r));return $forEach$1(n,(function(t){DESCRIPTORS$e&&!call$A($propertyIsEnumerable$1,r,t)||$defineProperty(e,t,r[t])})),e},$create=function(e,t){return void 0===t?nativeObjectCreate(e):$defineProperties(nativeObjectCreate(e),t)},$propertyIsEnumerable$1=function(e){var t=toPropertyKey(e),r=call$A(nativePropertyIsEnumerable,this,t);return!(this===ObjectPrototype$2&&hasOwn$g(AllSymbols,t)&&!hasOwn$g(ObjectPrototypeSymbols,t))&&(!(r||!hasOwn$g(this,t)||!hasOwn$g(AllSymbols,t)||hasOwn$g(this,HIDDEN)&&this[HIDDEN][t])||r)},$getOwnPropertyDescriptor=function(e,t){var r=toIndexedObject$5(e),n=toPropertyKey(t);if(r!==ObjectPrototype$2||!hasOwn$g(AllSymbols,n)||hasOwn$g(ObjectPrototypeSymbols,n)){var i=nativeGetOwnPropertyDescriptor$1(r,n);return!i||!hasOwn$g(AllSymbols,n)||hasOwn$g(r,HIDDEN)&&r[HIDDEN][n]||(i.enumerable=!0),i}},$getOwnPropertyNames=function(e){var t=nativeGetOwnPropertyNames(toIndexedObject$5(e)),r=[];return $forEach$1(t,(function(e){hasOwn$g(AllSymbols,e)||hasOwn$g(hiddenKeys$1,e)||push$a(r,e)})),r},$getOwnPropertySymbols=function(e){var t=e===ObjectPrototype$2,r=nativeGetOwnPropertyNames(t?ObjectPrototypeSymbols:toIndexedObject$5(e)),n=[];return $forEach$1(r,(function(e){!hasOwn$g(AllSymbols,e)||t&&!hasOwn$g(ObjectPrototype$2,e)||push$a(n,AllSymbols[e])})),n};NATIVE_SYMBOL$3||(defineBuiltIn$6(SymbolPrototype=($Symbol=function(){if(isPrototypeOf$q(SymbolPrototype,this))throw TypeError$4("Symbol is not a constructor");var e=arguments.length&&void 0!==arguments[0]?$toString$2(arguments[0]):void 0,t=uid$1(e),r=function(e){this===ObjectPrototype$2&&call$A(r,ObjectPrototypeSymbols,e),hasOwn$g(this,HIDDEN)&&hasOwn$g(this[HIDDEN],t)&&(this[HIDDEN][t]=!1),setSymbolDescriptor(this,t,createPropertyDescriptor$5(1,e))};return DESCRIPTORS$e&&USE_SETTER&&setSymbolDescriptor(ObjectPrototype$2,t,{configurable:!0,set:r}),wrap(t,e)})[PROTOTYPE],"toString",(function(){return getInternalState$2(this).tag})),defineBuiltIn$6($Symbol,"withoutSetter",(function(e){return wrap(uid$1(e),e)})),propertyIsEnumerableModule$1.f=$propertyIsEnumerable$1,definePropertyModule$3.f=$defineProperty,definePropertiesModule.f=$defineProperties,getOwnPropertyDescriptorModule$4.f=$getOwnPropertyDescriptor,getOwnPropertyNamesModule$2.f=getOwnPropertyNamesExternal.f=$getOwnPropertyNames,getOwnPropertySymbolsModule$3.f=$getOwnPropertySymbols,wrappedWellKnownSymbolModule.f=function(e){return wrap(wellKnownSymbol$f(e),e)},DESCRIPTORS$e&&nativeDefineProperty(SymbolPrototype,"description",{configurable:!0,get:function(){return getInternalState$2(this).description}})),$$1B({global:!0,constructor:!0,wrap:!0,forced:!NATIVE_SYMBOL$3,sham:!NATIVE_SYMBOL$3},{Symbol:$Symbol}),$forEach$1(objectKeys$2(WellKnownSymbolsStore),(function(e){defineWellKnownSymbol$l(e)})),$$1B({target:SYMBOL,stat:!0,forced:!NATIVE_SYMBOL$3},{useSetter:function(){USE_SETTER=!0},useSimple:function(){USE_SETTER=!1}}),$$1B({target:"Object",stat:!0,forced:!NATIVE_SYMBOL$3,sham:!DESCRIPTORS$e},{create:$create,defineProperty:$defineProperty,defineProperties:$defineProperties,getOwnPropertyDescriptor:$getOwnPropertyDescriptor}),$$1B({target:"Object",stat:!0,forced:!NATIVE_SYMBOL$3},{getOwnPropertyNames:$getOwnPropertyNames}),defineSymbolToPrimitive$1(),setToStringTag$8($Symbol,SYMBOL),hiddenKeys$1[HIDDEN]=!0;var NATIVE_SYMBOL$2=symbolConstructorDetection,symbolRegistryDetection=NATIVE_SYMBOL$2&&!!Symbol.for&&!!Symbol.keyFor,$$1A=_export,getBuiltIn$i=getBuiltIn$o,hasOwn$f=hasOwnProperty_1,toString$f=toString$h,shared$1=shared$6.exports,NATIVE_SYMBOL_REGISTRY$1=symbolRegistryDetection,StringToSymbolRegistry=shared$1("string-to-symbol-registry"),SymbolToStringRegistry$1=shared$1("symbol-to-string-registry");$$1A({target:"Symbol",stat:!0,forced:!NATIVE_SYMBOL_REGISTRY$1},{for:function(e){var t=toString$f(e);if(hasOwn$f(StringToSymbolRegistry,t))return StringToSymbolRegistry[t];var r=getBuiltIn$i("Symbol")(t);return StringToSymbolRegistry[t]=r,SymbolToStringRegistry$1[r]=t,r}});var $$1z=_export,hasOwn$e=hasOwnProperty_1,isSymbol$1=isSymbol$4,tryToString$4=tryToString$6,shared=shared$6.exports,NATIVE_SYMBOL_REGISTRY=symbolRegistryDetection,SymbolToStringRegistry=shared("symbol-to-string-registry");$$1z({target:"Symbol",stat:!0,forced:!NATIVE_SYMBOL_REGISTRY},{keyFor:function(e){if(!isSymbol$1(e))throw TypeError(tryToString$4(e)+" is not a symbol");if(hasOwn$e(SymbolToStringRegistry,e))return SymbolToStringRegistry[e]}});var uncurryThis$q=functionUncurryThis,arraySlice$6=uncurryThis$q([].slice),$$1y=_export,getBuiltIn$h=getBuiltIn$o,apply$4=functionApply,call$z=functionCall,uncurryThis$p=functionUncurryThis,fails$n=fails$z,isArray$c=isArray$f,isCallable$b=isCallable$n,isObject$i=isObject$q,isSymbol=isSymbol$4,arraySlice$5=arraySlice$6,NATIVE_SYMBOL$1=symbolConstructorDetection,$stringify=getBuiltIn$h("JSON","stringify"),exec$3=uncurryThis$p(/./.exec),charAt$5=uncurryThis$p("".charAt),charCodeAt$2=uncurryThis$p("".charCodeAt),replace$5=uncurryThis$p("".replace),numberToString$1=uncurryThis$p(1..toString),tester=/[\uD800-\uDFFF]/g,low=/^[\uD800-\uDBFF]$/,hi=/^[\uDC00-\uDFFF]$/,WRONG_SYMBOLS_CONVERSION=!NATIVE_SYMBOL$1||fails$n((function(){var e=getBuiltIn$h("Symbol")();return"[null]"!=$stringify([e])||"{}"!=$stringify({a:e})||"{}"!=$stringify(Object(e))})),ILL_FORMED_UNICODE=fails$n((function(){return'"\\udf06\\ud834"'!==$stringify("\udf06\ud834")||'"\\udead"'!==$stringify("\udead")})),stringifyWithSymbolsFix=function(e,t){var r=arraySlice$5(arguments),n=t;if((isObject$i(t)||void 0!==e)&&!isSymbol(e))return isArray$c(t)||(t=function(e,t){if(isCallable$b(n)&&(t=call$z(n,this,e,t)),!isSymbol(t))return t}),r[1]=t,apply$4($stringify,null,r)},fixIllFormed=function(e,t,r){var n=charAt$5(r,t-1),i=charAt$5(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&&$$1y({target:"JSON",stat:!0,arity:3,forced:WRONG_SYMBOLS_CONVERSION||ILL_FORMED_UNICODE},{stringify:function(e,t,r){var n=arraySlice$5(arguments),i=apply$4(WRONG_SYMBOLS_CONVERSION?stringifyWithSymbolsFix:$stringify,null,n);return ILL_FORMED_UNICODE&&"string"==typeof i?replace$5(i,tester,fixIllFormed):i}});var $$1x=_export,NATIVE_SYMBOL=symbolConstructorDetection,fails$m=fails$z,getOwnPropertySymbolsModule$2=objectGetOwnPropertySymbols,toObject$9=toObject$d,FORCED$5=!NATIVE_SYMBOL||fails$m((function(){getOwnPropertySymbolsModule$2.f(1)}));$$1x({target:"Object",stat:!0,forced:FORCED$5},{getOwnPropertySymbols:function(e){var t=getOwnPropertySymbolsModule$2.f;return t?t(toObject$9(e)):[]}});var defineWellKnownSymbol$k=wellKnownSymbolDefine;defineWellKnownSymbol$k("asyncIterator");var defineWellKnownSymbol$j=wellKnownSymbolDefine;defineWellKnownSymbol$j("hasInstance");var defineWellKnownSymbol$i=wellKnownSymbolDefine;defineWellKnownSymbol$i("isConcatSpreadable");var defineWellKnownSymbol$h=wellKnownSymbolDefine;defineWellKnownSymbol$h("iterator");var defineWellKnownSymbol$g=wellKnownSymbolDefine;defineWellKnownSymbol$g("match");var defineWellKnownSymbol$f=wellKnownSymbolDefine;defineWellKnownSymbol$f("matchAll");var defineWellKnownSymbol$e=wellKnownSymbolDefine;defineWellKnownSymbol$e("replace");var defineWellKnownSymbol$d=wellKnownSymbolDefine;defineWellKnownSymbol$d("search");var defineWellKnownSymbol$c=wellKnownSymbolDefine;defineWellKnownSymbol$c("species");var defineWellKnownSymbol$b=wellKnownSymbolDefine;defineWellKnownSymbol$b("split");var defineWellKnownSymbol$a=wellKnownSymbolDefine,defineSymbolToPrimitive=symbolDefineToPrimitive;defineWellKnownSymbol$a("toPrimitive"),defineSymbolToPrimitive();var getBuiltIn$g=getBuiltIn$o,defineWellKnownSymbol$9=wellKnownSymbolDefine,setToStringTag$7=setToStringTag$9;defineWellKnownSymbol$9("toStringTag"),setToStringTag$7(getBuiltIn$g("Symbol"),"Symbol");var defineWellKnownSymbol$8=wellKnownSymbolDefine;defineWellKnownSymbol$8("unscopables");var global$h=global$s,setToStringTag$6=setToStringTag$9;setToStringTag$6(global$h.JSON,"JSON",!0);var IteratorPrototype$1,PrototypeOfArrayIteratorPrototype,arrayIterator,path$q=path$v,symbol$5=path$q.Symbol,addToUnscopables$1=function(){},iterators={},DESCRIPTORS$d=descriptors,hasOwn$d=hasOwnProperty_1,FunctionPrototype$1=Function.prototype,getDescriptor=DESCRIPTORS$d&&Object.getOwnPropertyDescriptor,EXISTS=hasOwn$d(FunctionPrototype$1,"name"),PROPER=EXISTS&&"something"===function(){}.name,CONFIGURABLE=EXISTS&&(!DESCRIPTORS$d||DESCRIPTORS$d&&getDescriptor(FunctionPrototype$1,"name").configurable),functionName={EXISTS:EXISTS,PROPER:PROPER,CONFIGURABLE:CONFIGURABLE},fails$l=fails$z,correctPrototypeGetter=!fails$l((function(){function e(){}return e.prototype.constructor=null,Object.getPrototypeOf(new e)!==e.prototype})),hasOwn$c=hasOwnProperty_1,isCallable$a=isCallable$n,toObject$8=toObject$d,sharedKey=sharedKey$4,CORRECT_PROTOTYPE_GETTER$1=correctPrototypeGetter,IE_PROTO=sharedKey("IE_PROTO"),$Object=Object,ObjectPrototype$1=$Object.prototype,objectGetPrototypeOf=CORRECT_PROTOTYPE_GETTER$1?$Object.getPrototypeOf:function(e){var t=toObject$8(e);if(hasOwn$c(t,IE_PROTO))return t[IE_PROTO];var r=t.constructor;return isCallable$a(r)&&t instanceof r?r.prototype:t instanceof $Object?ObjectPrototype$1:null},fails$k=fails$z,isCallable$9=isCallable$n,isObject$h=isObject$q,create$c=objectCreate$1,getPrototypeOf$a=objectGetPrototypeOf,defineBuiltIn$5=defineBuiltIn$8,wellKnownSymbol$e=wellKnownSymbol$p,ITERATOR$8=wellKnownSymbol$e("iterator"),BUGGY_SAFARI_ITERATORS$1=!1;[].keys&&("next"in(arrayIterator=[].keys())?(PrototypeOfArrayIteratorPrototype=getPrototypeOf$a(getPrototypeOf$a(arrayIterator)))!==Object.prototype&&(IteratorPrototype$1=PrototypeOfArrayIteratorPrototype):BUGGY_SAFARI_ITERATORS$1=!0);var NEW_ITERATOR_PROTOTYPE=!isObject$h(IteratorPrototype$1)||fails$k((function(){var e={};return IteratorPrototype$1[ITERATOR$8].call(e)!==e}));isCallable$9((IteratorPrototype$1=NEW_ITERATOR_PROTOTYPE?{}:create$c(IteratorPrototype$1))[ITERATOR$8])||defineBuiltIn$5(IteratorPrototype$1,ITERATOR$8,(function(){return this}));var iteratorsCore={IteratorPrototype:IteratorPrototype$1,BUGGY_SAFARI_ITERATORS:BUGGY_SAFARI_ITERATORS$1},IteratorPrototype=iteratorsCore.IteratorPrototype,create$b=objectCreate$1,createPropertyDescriptor$4=createPropertyDescriptor$9,setToStringTag$5=setToStringTag$9,Iterators$5=iterators,returnThis$1=function(){return this},iteratorCreateConstructor=function(e,t,r,n){var i=t+" Iterator";return e.prototype=create$b(IteratorPrototype,{next:createPropertyDescriptor$4(+!n,r)}),setToStringTag$5(e,i,!1,!0),Iterators$5[i]=returnThis$1,e},isCallable$8=isCallable$n,$String=String,$TypeError$e=TypeError,aPossiblePrototype$1=function(e){if("object"==typeof e||isCallable$8(e))return e;throw $TypeError$e("Can't set "+$String(e)+" as a prototype")},uncurryThis$o=functionUncurryThis,anObject$H=anObject$M,aPossiblePrototype=aPossiblePrototype$1,objectSetPrototypeOf=Object.setPrototypeOf||("__proto__"in{}?function(){var e,t=!1,r={};try{(e=uncurryThis$o(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),$$1w=_export,call$y=functionCall,FunctionName=functionName,createIteratorConstructor$1=iteratorCreateConstructor,getPrototypeOf$9=objectGetPrototypeOf,setToStringTag$4=setToStringTag$9,defineBuiltIn$4=defineBuiltIn$8,wellKnownSymbol$d=wellKnownSymbol$p,Iterators$4=iterators,IteratorsCore=iteratorsCore,PROPER_FUNCTION_NAME$1=FunctionName.PROPER;FunctionName.CONFIGURABLE,IteratorsCore.IteratorPrototype;var BUGGY_SAFARI_ITERATORS=IteratorsCore.BUGGY_SAFARI_ITERATORS,ITERATOR$7=wellKnownSymbol$d("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,l,u=function(e){if(e===i&&f)return f;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,h=_[ITERATOR$7]||_["@@iterator"]||i&&_[i],f=!BUGGY_SAFARI_ITERATORS&&h||u(i),m="Array"==t&&_.entries||h;if(m&&(s=getPrototypeOf$9(m.call(new e)))!==Object.prototype&&s.next&&(setToStringTag$4(s,d,!0,!0),Iterators$4[d]=returnThis),PROPER_FUNCTION_NAME$1&&i==VALUES&&h&&h.name!==VALUES&&(p=!0,f=function(){return call$y(h,this)}),i)if(c={values:u(VALUES),keys:o?f:u(KEYS),entries:u(ENTRIES)},a)for(l in c)(BUGGY_SAFARI_ITERATORS||p||!(l in _))&&defineBuiltIn$4(_,l,c[l]);else $$1w({target:t,proto:!0,forced:BUGGY_SAFARI_ITERATORS||p},c);return a&&_[ITERATOR$7]!==f&&defineBuiltIn$4(_,ITERATOR$7,f,{name:i}),Iterators$4[t]=f,c},createIterResultObject$3=function(e,t){return{value:e,done:t}},toIndexedObject$4=toIndexedObject$b,addToUnscopables=addToUnscopables$1,Iterators$3=iterators,InternalStateModule$7=internalState,defineProperty$7=objectDefineProperty.f,defineIterator$2=iteratorDefine,createIterResultObject$2=createIterResultObject$3,IS_PURE$2=isPure,DESCRIPTORS$c=descriptors,ARRAY_ITERATOR="Array Iterator",setInternalState$7=InternalStateModule$7.set,getInternalState$1=InternalStateModule$7.getterFor(ARRAY_ITERATOR);defineIterator$2(Array,"Array",(function(e,t){setInternalState$7(this,{type:ARRAY_ITERATOR,target:toIndexedObject$4(e),index:0,kind:t})}),(function(){var e=getInternalState$1(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");var values$8=Iterators$3.Arguments=Iterators$3.Array;if(addToUnscopables(),addToUnscopables(),addToUnscopables(),!IS_PURE$2&&DESCRIPTORS$c&&"values"!==values$8.name)try{defineProperty$7(values$8,"name",{value:"values"})}catch(e){}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},DOMIterables$3=domIterables,global$g=global$s,classof$8=classof$d,createNonEnumerableProperty$3=createNonEnumerableProperty$8,Iterators$2=iterators,wellKnownSymbol$c=wellKnownSymbol$p,TO_STRING_TAG$1=wellKnownSymbol$c("toStringTag");for(var COLLECTION_NAME in DOMIterables$3){var Collection=global$g[COLLECTION_NAME],CollectionPrototype=Collection&&Collection.prototype;CollectionPrototype&&classof$8(CollectionPrototype)!==TO_STRING_TAG$1&&createNonEnumerableProperty$3(CollectionPrototype,TO_STRING_TAG$1,COLLECTION_NAME),Iterators$2[COLLECTION_NAME]=Iterators$2.Array}var parent$2u=symbol$5,symbol$4=parent$2u,parent$2t=symbol$4,symbol$3=parent$2t,defineWellKnownSymbol$7=wellKnownSymbolDefine;defineWellKnownSymbol$7("asyncDispose");var defineWellKnownSymbol$6=wellKnownSymbolDefine;defineWellKnownSymbol$6("dispose");var defineWellKnownSymbol$5=wellKnownSymbolDefine;defineWellKnownSymbol$5("matcher");var defineWellKnownSymbol$4=wellKnownSymbolDefine;defineWellKnownSymbol$4("metadataKey");var defineWellKnownSymbol$3=wellKnownSymbolDefine;defineWellKnownSymbol$3("observable");var defineWellKnownSymbol$2=wellKnownSymbolDefine;defineWellKnownSymbol$2("metadata");var defineWellKnownSymbol$1=wellKnownSymbolDefine;defineWellKnownSymbol$1("patternMatch");var defineWellKnownSymbol=wellKnownSymbolDefine;defineWellKnownSymbol("replaceAll");var parent$2s=symbol$3,symbol$2=parent$2s,symbol$1=symbol$2,symbol=symbol$1,uncurryThis$n=functionUncurryThis,toIntegerOrInfinity$2=toIntegerOrInfinity$5,toString$e=toString$h,requireObjectCoercible$6=requireObjectCoercible$9,charAt$4=uncurryThis$n("".charAt),charCodeAt$1=uncurryThis$n("".charCodeAt),stringSlice$4=uncurryThis$n("".slice),createMethod$4=function(e){return function(t,r){var n,i,o=toString$e(requireObjectCoercible$6(t)),a=toIntegerOrInfinity$2(r),s=o.length;return a<0||a>=s?e?"":void 0:(n=charCodeAt$1(o,a))<55296||n>56319||a+1===s||(i=charCodeAt$1(o,a+1))<56320||i>57343?e?charAt$4(o,a):n:e?stringSlice$4(o,a,a+2):i-56320+(n-55296<<10)+65536}},stringMultibyte={codeAt:createMethod$4(!1),charAt:createMethod$4(!0)},charAt$3=stringMultibyte.charAt,toString$d=toString$h,InternalStateModule$6=internalState,defineIterator$1=iteratorDefine,createIterResultObject$1=createIterResultObject$3,STRING_ITERATOR="String Iterator",setInternalState$6=InternalStateModule$6.set,getInternalState=InternalStateModule$6.getterFor(STRING_ITERATOR);defineIterator$1(String,"String",(function(e){setInternalState$6(this,{type:STRING_ITERATOR,string:toString$d(e),index:0})}),(function(){var e,t=getInternalState(this),r=t.string,n=t.index;return n>=r.length?createIterResultObject$1(void 0,!0):(e=charAt$3(r,n),t.index+=e.length,createIterResultObject$1(e,!1))}));var WrappedWellKnownSymbolModule$2=wellKnownSymbolWrapped,iterator$5=WrappedWellKnownSymbolModule$2.f("iterator"),parent$2r=iterator$5,iterator$4=parent$2r,parent$2q=iterator$4,iterator$3=parent$2q,parent$2p=iterator$3,iterator$2=parent$2p,iterator$1=iterator$2,iterator=iterator$1;function _typeof(e){return(_typeof="function"==typeof symbol&&"symbol"==typeof iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof symbol&&e.constructor===symbol&&e!==symbol.prototype?"symbol":typeof e})(e)}var WrappedWellKnownSymbolModule$1=wellKnownSymbolWrapped,toPrimitive$5=WrappedWellKnownSymbolModule$1.f("toPrimitive"),parent$2o=toPrimitive$5,toPrimitive$4=parent$2o,parent$2n=toPrimitive$4,toPrimitive$3=parent$2n,parent$2m=toPrimitive$3,toPrimitive$2=parent$2m,toPrimitive$1=toPrimitive$2,toPrimitive=toPrimitive$1;function _toPrimitive(e,t){if("object"!==_typeof(e)||null===e)return e;var r=e[toPrimitive];if(void 0!==r){var n=r.call(e,t||"default");if("object"!==_typeof(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}function _toPropertyKey(e){var t=_toPrimitive(e,"string");return"symbol"===_typeof(t)?t:String(t)}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),defineProperty$a(e,_toPropertyKey(n.key),n)}}function _createClass(e,t,r){return t&&_defineProperties(e.prototype,t),r&&_defineProperties(e,r),defineProperty$a(e,"prototype",{writable:!1}),e}function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function _defineProperty(e,t,r){return(t=_toPropertyKey(t))in e?defineProperty$a(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var $$1v=_export,DESCRIPTORS$b=descriptors,create$a=objectCreate$1;$$1v({target:"Object",stat:!0,sham:!DESCRIPTORS$b},{create:create$a});var path$p=path$v,Object$3=path$p.Object,create$9=function(e,t){return Object$3.create(e,t)},parent$2l=create$9,create$8=parent$2l,parent$2k=create$8,create$7=parent$2k,parent$2j=create$7,create$6=parent$2j,create$5=create$6,create$4=create$5,$$1u=_export,fails$j=fails$z,toObject$7=toObject$d,nativeGetPrototypeOf=objectGetPrototypeOf,CORRECT_PROTOTYPE_GETTER=correctPrototypeGetter,FAILS_ON_PRIMITIVES$3=fails$j((function(){nativeGetPrototypeOf(1)}));$$1u({target:"Object",stat:!0,forced:FAILS_ON_PRIMITIVES$3,sham:!CORRECT_PROTOTYPE_GETTER},{getPrototypeOf:function(e){return nativeGetPrototypeOf(toObject$7(e))}});var path$o=path$v,getPrototypeOf$8=path$o.Object.getPrototypeOf,parent$2i=getPrototypeOf$8,getPrototypeOf$7=parent$2i,parent$2h=getPrototypeOf$7,getPrototypeOf$6=parent$2h,parent$2g=getPrototypeOf$6,getPrototypeOf$5=parent$2g,getPrototypeOf$4=getPrototypeOf$5,getPrototypeOf$3=getPrototypeOf$4,fails$i=fails$z,arrayMethodIsStrict$4=function(e,t){var r=[][e];return!!r&&fails$i((function(){r.call(null,t||function(){return 1},1)}))},$forEach=arrayIteration.forEach,arrayMethodIsStrict$3=arrayMethodIsStrict$4,STRICT_METHOD$3=arrayMethodIsStrict$3("forEach"),arrayForEach=STRICT_METHOD$3?[].forEach:function(e){return $forEach(this,e,arguments.length>1?arguments[1]:void 0)},$$1t=_export,forEach$8=arrayForEach;$$1t({target:"Array",proto:!0,forced:[].forEach!=arrayForEach},{forEach:arrayForEach});var path$n=path$v,entryVirtual$m=function(e){return path$n[e+"Prototype"]},entryVirtual$l=entryVirtual$m,forEach$7=entryVirtual$l("Array").forEach,parent$2f=forEach$7,forEach$6=parent$2f,classof$7=classof$d,hasOwn$b=hasOwnProperty_1,isPrototypeOf$p=objectIsPrototypeOf,method$j=forEach$6,ArrayPrototype$g=Array.prototype,DOMIterables$2={DOMTokenList:!0,NodeList:!0},forEach$5=function(e){var t=e.forEach;return e===ArrayPrototype$g||isPrototypeOf$p(ArrayPrototype$g,e)&&t===ArrayPrototype$g.forEach||hasOwn$b(DOMIterables$2,classof$7(e))?method$j:t},parent$2e=forEach$5,forEach$4=parent$2e,parent$2d=forEach$4,forEach$3=parent$2d,forEach$2=forEach$3,forEach$1=forEach$2,$$1s=_export,setPrototypeOf$7=objectSetPrototypeOf;$$1s({target:"Object",stat:!0},{setPrototypeOf:setPrototypeOf$7});var path$m=path$v,setPrototypeOf$6=path$m.Object.setPrototypeOf,parent$2c=setPrototypeOf$6,setPrototypeOf$5=parent$2c,parent$2b=setPrototypeOf$5,setPrototypeOf$4=parent$2b,parent$2a=setPrototypeOf$4,setPrototypeOf$3=parent$2a,setPrototypeOf$2=setPrototypeOf$3,setPrototypeOf$1=setPrototypeOf$2,getBuiltIn$f=getBuiltIn$o,uncurryThis$m=functionUncurryThis,getOwnPropertyNamesModule$1=objectGetOwnPropertyNames,getOwnPropertySymbolsModule$1=objectGetOwnPropertySymbols,anObject$G=anObject$M,concat$9=uncurryThis$m([].concat),ownKeys$3=getBuiltIn$f("Reflect","ownKeys")||function(e){var t=getOwnPropertyNamesModule$1.f(anObject$G(e)),r=getOwnPropertySymbolsModule$1.f;return r?concat$9(t,r(e)):t},hasOwn$a=hasOwnProperty_1,ownKeys$2=ownKeys$3,getOwnPropertyDescriptorModule$3=objectGetOwnPropertyDescriptor,definePropertyModule$2=objectDefineProperty,copyConstructorProperties$1=function(e,t,r){for(var n=ownKeys$2(t),i=definePropertyModule$2.f,o=getOwnPropertyDescriptorModule$3.f,a=0;a<n.length;a++){var s=n[a];hasOwn$a(e,s)||r&&hasOwn$a(r,s)||i(e,s,o(t,s))}},uncurryThis$l=functionUncurryThis,$Error$1=Error,replace$4=uncurryThis$l("".replace),TEST=String($Error$1("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$1.prepareStackTrace)for(;t--;)e=replace$4(e,V8_OR_CHAKRA_STACK_ENTRY,"");return e},isObject$g=isObject$q,createNonEnumerableProperty$2=createNonEnumerableProperty$8,installErrorCause$1=function(e,t){isObject$g(t)&&"cause"in t&&createNonEnumerableProperty$2(e,"cause",t.cause)},wellKnownSymbol$b=wellKnownSymbol$p,Iterators$1=iterators,ITERATOR$6=wellKnownSymbol$b("iterator"),ArrayPrototype$f=Array.prototype,isArrayIteratorMethod$2=function(e){return void 0!==e&&(Iterators$1.Array===e||ArrayPrototype$f[ITERATOR$6]===e)},classof$6=classof$d,getMethod$1=getMethod$3,isNullOrUndefined$4=isNullOrUndefined$7,Iterators=iterators,wellKnownSymbol$a=wellKnownSymbol$p,ITERATOR$5=wellKnownSymbol$a("iterator"),getIteratorMethod$a=function(e){if(!isNullOrUndefined$4(e))return getMethod$1(e,ITERATOR$5)||getMethod$1(e,"@@iterator")||Iterators[classof$6(e)]},call$x=functionCall,aCallable$w=aCallable$z,anObject$F=anObject$M,tryToString$3=tryToString$6,getIteratorMethod$9=getIteratorMethod$a,$TypeError$d=TypeError,getIterator$7=function(e,t){var r=arguments.length<2?getIteratorMethod$9(e):t;if(aCallable$w(r))return anObject$F(call$x(r,e));throw $TypeError$d(tryToString$3(e)+" is not iterable")},call$w=functionCall,anObject$E=anObject$M,getMethod=getMethod$3,iteratorClose$2=function(e,t,r){var n,i;anObject$E(e);try{if(!(n=getMethod(e,"return"))){if("throw"===t)throw r;return r}n=call$w(n,e)}catch(e){i=!0,n=e}if("throw"===t)throw r;if(i)throw n;return anObject$E(n),r},bind$t=functionBindContext,call$v=functionCall,anObject$D=anObject$M,tryToString$2=tryToString$6,isArrayIteratorMethod$1=isArrayIteratorMethod$2,lengthOfArrayLike$6=lengthOfArrayLike$b,isPrototypeOf$o=objectIsPrototypeOf,getIterator$6=getIterator$7,getIteratorMethod$8=getIteratorMethod$a,iteratorClose$1=iteratorClose$2,$TypeError$c=TypeError,Result=function(e,t){this.stopped=e,this.result=t},ResultPrototype=Result.prototype,iterate$A=function(e,t,r){var n,i,o,a,s,c,l,u=r&&r.that,d=!(!r||!r.AS_ENTRIES),p=!(!r||!r.IS_RECORD),_=!(!r||!r.IS_ITERATOR),h=!(!r||!r.INTERRUPTED),f=bind$t(t,u),m=function(e){return n&&iteratorClose$1(n,"normal",e),new Result(!0,e)},v=function(e){return d?(anObject$D(e),h?f(e[0],e[1],m):f(e[0],e[1])):h?f(e,m):f(e)};if(p)n=e.iterator;else if(_)n=e;else{if(!(i=getIteratorMethod$8(e)))throw $TypeError$c(tryToString$2(e)+" is not iterable");if(isArrayIteratorMethod$1(i)){for(o=0,a=lengthOfArrayLike$6(e);a>o;o++)if((s=v(e[o]))&&isPrototypeOf$o(ResultPrototype,s))return s;return new Result(!1)}n=getIterator$6(e,i)}for(c=p?e.next:n.next;!(l=call$v(c,n)).done;){try{s=v(l.value)}catch(e){iteratorClose$1(n,"throw",e)}if("object"==typeof s&&s&&isPrototypeOf$o(ResultPrototype,s))return s}return new Result(!1)},toString$c=toString$h,normalizeStringArgument$1=function(e,t){return void 0===e?arguments.length<2?"":t:toString$c(e)},fails$h=fails$z,createPropertyDescriptor$3=createPropertyDescriptor$9,errorStackInstallable=!fails$h((function(){var e=Error("a");return!("stack"in e)||(Object.defineProperty(e,"stack",createPropertyDescriptor$3(1,7)),7!==e.stack)})),$$1r=_export,isPrototypeOf$n=objectIsPrototypeOf,getPrototypeOf$2=objectGetPrototypeOf,setPrototypeOf=objectSetPrototypeOf,copyConstructorProperties=copyConstructorProperties$1,create$3=objectCreate$1,createNonEnumerableProperty$1=createNonEnumerableProperty$8,createPropertyDescriptor$2=createPropertyDescriptor$9,clearErrorStack=errorStackClear,installErrorCause=installErrorCause$1,iterate$z=iterate$A,normalizeStringArgument=normalizeStringArgument$1,wellKnownSymbol$9=wellKnownSymbol$p,ERROR_STACK_INSTALLABLE=errorStackInstallable,TO_STRING_TAG=wellKnownSymbol$9("toStringTag"),$Error=Error,push$9=[].push,$AggregateError=function(e,t){var r,n=arguments.length>2?arguments[2]:void 0,i=isPrototypeOf$n(AggregateErrorPrototype,this);setPrototypeOf?r=setPrototypeOf($Error(),i?getPrototypeOf$2(this):AggregateErrorPrototype):(r=i?this:create$3(AggregateErrorPrototype),createNonEnumerableProperty$1(r,TO_STRING_TAG,"Error")),void 0!==t&&createNonEnumerableProperty$1(r,"message",normalizeStringArgument(t)),ERROR_STACK_INSTALLABLE&&createNonEnumerableProperty$1(r,"stack",clearErrorStack(r.stack,1)),installErrorCause(r,n);var o=[];return iterate$z(e,push$9,{that:o}),createNonEnumerableProperty$1(r,"errors",o),r};setPrototypeOf?setPrototypeOf($AggregateError,$Error):copyConstructorProperties($AggregateError,$Error,{name:!0});var AggregateErrorPrototype=$AggregateError.prototype=create$3($Error.prototype,{constructor:createPropertyDescriptor$2(1,$AggregateError),message:createPropertyDescriptor$2(1,""),name:createPropertyDescriptor$2(1,"AggregateError")});$$1r({global:!0,constructor:!0,arity:2},{AggregateError:$AggregateError});var $location,defer,channel,port,classof$5=classofRaw$2,global$f=global$s,engineIsNode="process"==classof$5(global$f.process),getBuiltIn$e=getBuiltIn$o,definePropertyModule$1=objectDefineProperty,wellKnownSymbol$8=wellKnownSymbol$p,DESCRIPTORS$a=descriptors,SPECIES$3=wellKnownSymbol$8("species"),setSpecies$2=function(e){var t=getBuiltIn$e(e),r=definePropertyModule$1.f;DESCRIPTORS$a&&t&&!t[SPECIES$3]&&r(t,SPECIES$3,{configurable:!0,get:function(){return this}})},isPrototypeOf$m=objectIsPrototypeOf,$TypeError$b=TypeError,anInstance$6=function(e,t){if(isPrototypeOf$m(t,e))return e;throw $TypeError$b("Incorrect invocation")},isConstructor$2=isConstructor$4,tryToString$1=tryToString$6,$TypeError$a=TypeError,aConstructor$3=function(e){if(isConstructor$2(e))return e;throw $TypeError$a(tryToString$1(e)+" is not a constructor")},anObject$C=anObject$M,aConstructor$2=aConstructor$3,isNullOrUndefined$3=isNullOrUndefined$7,wellKnownSymbol$7=wellKnownSymbol$p,SPECIES$2=wellKnownSymbol$7("species"),speciesConstructor$b=function(e,t){var r,n=anObject$C(e).constructor;return void 0===n||isNullOrUndefined$3(r=anObject$C(n)[SPECIES$2])?t:aConstructor$2(r)},$TypeError$9=TypeError,validateArgumentsLength$3=function(e,t){if(e<t)throw $TypeError$9("Not enough arguments");return e},userAgent$5=engineUserAgent,engineIsIos=/(?:ipad|iphone|ipod).*applewebkit/i.test(userAgent$5),global$e=global$s,apply$3=functionApply,bind$s=functionBindContext,isCallable$7=isCallable$n,hasOwn$9=hasOwnProperty_1,fails$g=fails$z,html=html$2,arraySlice$4=arraySlice$6,createElement$1=documentCreateElement$1,validateArgumentsLength$2=validateArgumentsLength$3,IS_IOS$1=engineIsIos,IS_NODE$4=engineIsNode,set$d=global$e.setImmediate,clear=global$e.clearImmediate,process$2=global$e.process,Dispatch=global$e.Dispatch,Function$1=global$e.Function,MessageChannel=global$e.MessageChannel,String$1=global$e.String,counter=0,queue$1={},ONREADYSTATECHANGE="onreadystatechange";try{$location=global$e.location}catch(e){}var run=function(e){if(hasOwn$9(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$e.postMessage(String$1(e),$location.protocol+"//"+$location.host)};set$d&&clear||(set$d=function(e){validateArgumentsLength$2(arguments.length,1);var t=isCallable$7(e)?e:Function$1(e),r=arraySlice$4(arguments,1);return queue$1[++counter]=function(){apply$3(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$s(port.postMessage,port)):global$e.addEventListener&&isCallable$7(global$e.postMessage)&&!global$e.importScripts&&$location&&"file:"!==$location.protocol&&!fails$g(post)?(defer=post,global$e.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$6,then,task$1={set:set$d,clear:clear},userAgent$4=engineUserAgent,global$d=global$s,engineIsIosPebble=/ipad|iphone|ipod/i.test(userAgent$4)&&void 0!==global$d.Pebble,userAgent$3=engineUserAgent,engineIsWebosWebkit=/web0s(?!.*chrome)/i.test(userAgent$3),global$c=global$s,bind$r=functionBindContext,getOwnPropertyDescriptor$9=objectGetOwnPropertyDescriptor.f,macrotask=task$1.set,IS_IOS=engineIsIos,IS_IOS_PEBBLE=engineIsIosPebble,IS_WEBOS_WEBKIT=engineIsWebosWebkit,IS_NODE$3=engineIsNode,MutationObserver=global$c.MutationObserver||global$c.WebKitMutationObserver,document$2=global$c.document,process$1=global$c.process,Promise$3=global$c.Promise,queueMicrotaskDescriptor=getOwnPropertyDescriptor$9(global$c,"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$3&&Promise$3.resolve?((promise$6=Promise$3.resolve(void 0)).constructor=Promise$3,then=bind$r(promise$6.then,promise$6),notify$1=function(){then(flush)}):IS_NODE$3?notify$1=function(){process$1.nextTick(flush)}:(macrotask=bind$r(macrotask,global$c),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$b=global$s,hostReportErrors$1=function(e,t){var r=global$b.console;r&&r.error&&(1==arguments.length?r.error(e):r.error(e,t))},perform$6=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$a=global$s,promiseNativeConstructor=global$a.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$9=global$s,NativePromiseConstructor$5=promiseNativeConstructor,isCallable$6=isCallable$n,isForced=isForced_1,inspectSource=inspectSource$2,wellKnownSymbol$6=wellKnownSymbol$p,IS_BROWSER=engineIsBrowser,IS_DENO=engineIsDeno,V8_VERSION=engineV8Version,NativePromisePrototype$2=NativePromiseConstructor$5&&NativePromiseConstructor$5.prototype,SPECIES$1=wellKnownSymbol$6("species"),SUBCLASSING=!1,NATIVE_PROMISE_REJECTION_EVENT$1=isCallable$6(global$9.PromiseRejectionEvent),FORCED_PROMISE_CONSTRUCTOR$5=isForced("Promise",(function(){var e=inspectSource(NativePromiseConstructor$5),t=e!==String(NativePromiseConstructor$5);if(!t&&66===V8_VERSION)return!0;if(!NativePromisePrototype$2.catch||!NativePromisePrototype$2.finally)return!0;if(!V8_VERSION||V8_VERSION<51||!/native code/.test(e)){var r=new NativePromiseConstructor$5((function(e){e(1)})),n=function(e){e((function(){}),(function(){}))};if((r.constructor={})[SPECIES$1]=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$v=aCallable$z,$TypeError$8=TypeError,PromiseCapability=function(e){var t,r;this.promise=new e((function(e,n){if(void 0!==t||void 0!==r)throw $TypeError$8("Bad Promise constructor");t=e,r=n})),this.resolve=aCallable$v(t),this.reject=aCallable$v(r)};newPromiseCapability$2.f=function(e){return new PromiseCapability(e)};var $$1q=_export,IS_NODE$1=engineIsNode,global$8=global$s,call$u=functionCall,defineBuiltIn$3=defineBuiltIn$8,setToStringTag$3=setToStringTag$9,setSpecies$1=setSpecies$2,aCallable$u=aCallable$z,isCallable$5=isCallable$n,isObject$f=isObject$q,anInstance$5=anInstance$6,speciesConstructor$a=speciesConstructor$b,task=task$1.set,microtask=microtask$1,hostReportErrors=hostReportErrors$1,perform$5=perform$6,Queue=queue,InternalStateModule$5=internalState,NativePromiseConstructor$4=promiseNativeConstructor,PromiseConstructorDetection=promiseConstructorDetection,newPromiseCapabilityModule$6=newPromiseCapability$2,PROMISE="Promise",FORCED_PROMISE_CONSTRUCTOR$4=PromiseConstructorDetection.CONSTRUCTOR,NATIVE_PROMISE_REJECTION_EVENT=PromiseConstructorDetection.REJECTION_EVENT;PromiseConstructorDetection.SUBCLASSING;var Internal,OwnPromiseCapability,PromiseWrapper,getInternalPromiseState=InternalStateModule$5.getterFor(PROMISE),setInternalState$5=InternalStateModule$5.set,NativePromisePrototype$1=NativePromiseConstructor$4&&NativePromiseConstructor$4.prototype,PromiseConstructor=NativePromiseConstructor$4,PromisePrototype=NativePromisePrototype$1,TypeError$3=global$8.TypeError,document$1=global$8.document,process=global$8.process,newPromiseCapability$1=newPromiseCapabilityModule$6.f,newGenericPromiseCapability=newPromiseCapability$1,DISPATCH_EVENT=!!(document$1&&document$1.createEvent&&global$8.dispatchEvent),UNHANDLED_REJECTION="unhandledrejection",REJECTION_HANDLED="rejectionhandled",PENDING=0,FULFILLED=1,REJECTED=2,HANDLED=1,UNHANDLED=2,isThenable=function(e){var t;return!(!isObject$f(e)||!isCallable$5(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,l=e.reject,u=e.domain;try{s?(a||(t.rejection===UNHANDLED&&onHandleUnhandled(t),t.rejection=HANDLED),!0===s?r=o:(u&&u.enter(),r=s(o),u&&(u.exit(),i=!0)),r===e.promise?l(TypeError$3("Promise-chain cycle")):(n=isThenable(r))?call$u(n,r,c,l):c(r)):l(o)}catch(e){u&&!i&&u.exit(),l(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$8.dispatchEvent(n)):n={promise:t,reason:r},!NATIVE_PROMISE_REJECTION_EVENT&&(i=global$8["on"+e])?i(n):e===UNHANDLED_REJECTION&&hostReportErrors("Unhandled promise rejection",r)},onUnhandled=function(e){call$u(task,global$8,(function(){var t,r=e.facade,n=e.value;if(isUnhandled(e)&&(t=perform$5((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$u(task,global$8,(function(){var t=e.facade;IS_NODE$1?process.emit("rejectionHandled",t):dispatchEvent(REJECTION_HANDLED,t,e.value)}))},bind$q=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$3("Promise can't be resolved itself");var n=isThenable(t);n?microtask((function(){var r={done:!1};try{call$u(n,t,bind$q(internalResolve,r,e),bind$q(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)}}};FORCED_PROMISE_CONSTRUCTOR$4&&(PromisePrototype=(PromiseConstructor=function(e){anInstance$5(this,PromisePrototype),aCallable$u(e),call$u(Internal,this);var t=getInternalPromiseState(this);try{e(bind$q(internalResolve,t),bind$q(internalReject,t))}catch(e){internalReject(t,e)}}).prototype,(Internal=function(e){setInternalState$5(this,{type:PROMISE,done:!1,notified:!1,parent:!1,reactions:new Queue,rejection:!1,state:PENDING,value:void 0})}).prototype=defineBuiltIn$3(PromisePrototype,"then",(function(e,t){var r=getInternalPromiseState(this),n=newPromiseCapability$1(speciesConstructor$a(this,PromiseConstructor));return r.parent=!0,n.ok=!isCallable$5(e)||e,n.fail=isCallable$5(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$q(internalResolve,t),this.reject=bind$q(internalReject,t)},newPromiseCapabilityModule$6.f=newPromiseCapability$1=function(e){return e===PromiseConstructor||e===PromiseWrapper?new OwnPromiseCapability(e):newGenericPromiseCapability(e)}),$$1q({global:!0,constructor:!0,wrap:!0,forced:FORCED_PROMISE_CONSTRUCTOR$4},{Promise:PromiseConstructor}),setToStringTag$3(PromiseConstructor,PROMISE,!1,!0),setSpecies$1(PROMISE);var wellKnownSymbol$5=wellKnownSymbol$p,ITERATOR$4=wellKnownSymbol$5("iterator"),SAFE_CLOSING=!1;try{var called=0,iteratorWithReturn={next:function(){return{done:!!called++}},return:function(){SAFE_CLOSING=!0}};iteratorWithReturn[ITERATOR$4]=function(){return this},Array.from(iteratorWithReturn,(function(){throw 2}))}catch(e){}var checkCorrectnessOfIteration$2=function(e,t){if(!t&&!SAFE_CLOSING)return!1;var r=!1;try{var n={};n[ITERATOR$4]=function(){return{next:function(){return{done:r=!0}}}},e(n)}catch(e){}return r},NativePromiseConstructor$3=promiseNativeConstructor,checkCorrectnessOfIteration$1=checkCorrectnessOfIteration$2,FORCED_PROMISE_CONSTRUCTOR$3=promiseConstructorDetection.CONSTRUCTOR,promiseStaticsIncorrectIteration=FORCED_PROMISE_CONSTRUCTOR$3||!checkCorrectnessOfIteration$1((function(e){NativePromiseConstructor$3.all(e).then(void 0,(function(){}))})),$$1p=_export,call$t=functionCall,aCallable$t=aCallable$z,newPromiseCapabilityModule$5=newPromiseCapability$2,perform$4=perform$6,iterate$y=iterate$A,PROMISE_STATICS_INCORRECT_ITERATION$1=promiseStaticsIncorrectIteration;$$1p({target:"Promise",stat:!0,forced:PROMISE_STATICS_INCORRECT_ITERATION$1},{all:function(e){var t=this,r=newPromiseCapabilityModule$5.f(t),n=r.resolve,i=r.reject,o=perform$4((function(){var r=aCallable$t(t.resolve),o=[],a=0,s=1;iterate$y(e,(function(e){var c=a++,l=!1;s++,call$t(r,t,e).then((function(e){l||(l=!0,o[c]=e,--s||n(o))}),i)})),--s||n(o)}));return o.error&&i(o.value),r.promise}});var $$1o=_export,FORCED_PROMISE_CONSTRUCTOR$2=promiseConstructorDetection.CONSTRUCTOR,NativePromiseConstructor$2=promiseNativeConstructor;promiseNativeConstructor&&promiseNativeConstructor.prototype,$$1o({target:"Promise",proto:!0,forced:FORCED_PROMISE_CONSTRUCTOR$2,real:!0},{catch:function(e){return this.then(void 0,e)}});var $$1n=_export,call$s=functionCall,aCallable$s=aCallable$z,newPromiseCapabilityModule$4=newPromiseCapability$2,perform$3=perform$6,iterate$x=iterate$A,PROMISE_STATICS_INCORRECT_ITERATION=promiseStaticsIncorrectIteration;$$1n({target:"Promise",stat:!0,forced:PROMISE_STATICS_INCORRECT_ITERATION},{race:function(e){var t=this,r=newPromiseCapabilityModule$4.f(t),n=r.reject,i=perform$3((function(){var i=aCallable$s(t.resolve);iterate$x(e,(function(e){call$s(i,t,e).then(r.resolve,n)}))}));return i.error&&n(i.value),r.promise}});var $$1m=_export,call$r=functionCall,newPromiseCapabilityModule$3=newPromiseCapability$2,FORCED_PROMISE_CONSTRUCTOR$1=promiseConstructorDetection.CONSTRUCTOR;$$1m({target:"Promise",stat:!0,forced:FORCED_PROMISE_CONSTRUCTOR$1},{reject:function(e){var t=newPromiseCapabilityModule$3.f(this);return call$r(t.reject,void 0,e),t.promise}});var anObject$B=anObject$M,isObject$e=isObject$q,newPromiseCapability=newPromiseCapability$2,promiseResolve$2=function(e,t){if(anObject$B(e),isObject$e(t)&&t.constructor===e)return t;var r=newPromiseCapability.f(e);return(0,r.resolve)(t),r.promise},$$1l=_export,getBuiltIn$d=getBuiltIn$o,IS_PURE$1=isPure,NativePromiseConstructor$1=promiseNativeConstructor,FORCED_PROMISE_CONSTRUCTOR=promiseConstructorDetection.CONSTRUCTOR,promiseResolve$1=promiseResolve$2,PromiseConstructorWrapper=getBuiltIn$d("Promise"),CHECK_WRAPPER=!FORCED_PROMISE_CONSTRUCTOR;$$1l({target:"Promise",stat:!0,forced:IS_PURE$1},{resolve:function(e){return promiseResolve$1(CHECK_WRAPPER&&this===PromiseConstructorWrapper?NativePromiseConstructor$1:this,e)}});var $$1k=_export,call$q=functionCall,aCallable$r=aCallable$z,newPromiseCapabilityModule$2=newPromiseCapability$2,perform$2=perform$6,iterate$w=iterate$A;$$1k({target:"Promise",stat:!0},{allSettled:function(e){var t=this,r=newPromiseCapabilityModule$2.f(t),n=r.resolve,i=r.reject,o=perform$2((function(){var r=aCallable$r(t.resolve),i=[],o=0,a=1;iterate$w(e,(function(e){var s=o++,c=!1;a++,call$q(r,t,e).then((function(e){c||(c=!0,i[s]={status:"fulfilled",value:e},--a||n(i))}),(function(e){c||(c=!0,i[s]={status:"rejected",reason:e},--a||n(i))}))})),--a||n(i)}));return o.error&&i(o.value),r.promise}});var $$1j=_export,call$p=functionCall,aCallable$q=aCallable$z,getBuiltIn$c=getBuiltIn$o,newPromiseCapabilityModule$1=newPromiseCapability$2,perform$1=perform$6,iterate$v=iterate$A,PROMISE_ANY_ERROR="No one promise resolved";$$1j({target:"Promise",stat:!0},{any:function(e){var t=this,r=getBuiltIn$c("AggregateError"),n=newPromiseCapabilityModule$1.f(t),i=n.resolve,o=n.reject,a=perform$1((function(){var n=aCallable$q(t.resolve),a=[],s=0,c=1,l=!1;iterate$v(e,(function(e){var u=s++,d=!1;c++,call$p(n,t,e).then((function(e){d||l||(l=!0,i(e))}),(function(e){d||l||(d=!0,a[u]=e,--c||o(new r(a,PROMISE_ANY_ERROR)))}))})),--c||o(new r(a,PROMISE_ANY_ERROR))}));return a.error&&o(a.value),n.promise}});var $$1i=_export,NativePromiseConstructor=promiseNativeConstructor,fails$f=fails$z,getBuiltIn$b=getBuiltIn$o,isCallable$4=isCallable$n,speciesConstructor$9=speciesConstructor$b,promiseResolve=promiseResolve$2,NativePromisePrototype=NativePromiseConstructor&&NativePromiseConstructor.prototype,NON_GENERIC=!!NativePromiseConstructor&&fails$f((function(){NativePromisePrototype.finally.call({then:function(){}},(function(){}))}));$$1i({target:"Promise",proto:!0,real:!0,forced:NON_GENERIC},{finally:function(e){var t=speciesConstructor$9(this,getBuiltIn$b("Promise")),r=isCallable$4(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)}});var path$l=path$v,promise$5=path$l.Promise,parent$29=promise$5,promise$4=parent$29,parent$28=promise$4,promise$3=parent$28,$$1h=_export,newPromiseCapabilityModule=newPromiseCapability$2,perform=perform$6;$$1h({target:"Promise",stat:!0,forced:!0},{try:function(e){var t=newPromiseCapabilityModule.f(this),r=perform(e);return(r.error?t.reject:t.resolve)(r.value),t.promise}});var parent$27=promise$3,promise$2=parent$27,promise$1=promise$2,promise=promise$1,$$1g=_export,uncurryThis$k=functionUncurryThis,isArray$b=isArray$f,nativeReverse=uncurryThis$k([].reverse),test$1=[1,2];$$1g({target:"Array",proto:!0,forced:String(test$1)===String(test$1.reverse())},{reverse:function(){return isArray$b(this)&&(this.length=this.length),nativeReverse(this)}});var entryVirtual$k=entryVirtual$m,reverse$6=entryVirtual$k("Array").reverse,isPrototypeOf$l=objectIsPrototypeOf,method$i=reverse$6,ArrayPrototype$e=Array.prototype,reverse$5=function(e){var t=e.reverse;return e===ArrayPrototype$e||isPrototypeOf$l(ArrayPrototype$e,e)&&t===ArrayPrototype$e.reverse?method$i:t},parent$26=reverse$5,reverse$4=parent$26,parent$25=reverse$4,reverse$3=parent$25,parent$24=reverse$3,reverse$2=parent$24,reverse$1=reverse$2,reverse2=reverse$1,$$1f=_export,isArray$a=isArray$f,isConstructor$1=isConstructor$4,isObject$d=isObject$q,toAbsoluteIndex$2=toAbsoluteIndex$5,lengthOfArrayLike$5=lengthOfArrayLike$b,toIndexedObject$3=toIndexedObject$b,createProperty$3=createProperty$6,wellKnownSymbol$4=wellKnownSymbol$p,arrayMethodHasSpeciesSupport$3=arrayMethodHasSpeciesSupport$5,nativeSlice=arraySlice$6,HAS_SPECIES_SUPPORT$3=arrayMethodHasSpeciesSupport$3("slice"),SPECIES=wellKnownSymbol$4("species"),$Array$1=Array,max$1=Math.max;$$1f({target:"Array",proto:!0,forced:!HAS_SPECIES_SUPPORT$3},{slice:function(e,t){var r,n,i,o=toIndexedObject$3(this),a=lengthOfArrayLike$5(o),s=toAbsoluteIndex$2(e,a),c=toAbsoluteIndex$2(void 0===t?a:t,a);if(isArray$a(o)&&(r=o.constructor,(isConstructor$1(r)&&(r===$Array$1||isArray$a(r.prototype))||isObject$d(r)&&null===(r=r[SPECIES]))&&(r=void 0),r===$Array$1||void 0===r))return nativeSlice(o,s,c);for(n=new(void 0===r?$Array$1:r)(max$1(c-s,0)),i=0;s<c;s++,i++)s in o&&createProperty$3(n,i,o[s]);return n.length=i,n}});var entryVirtual$j=entryVirtual$m,slice$7=entryVirtual$j("Array").slice,isPrototypeOf$k=objectIsPrototypeOf,method$h=slice$7,ArrayPrototype$d=Array.prototype,slice$6=function(e){var t=e.slice;return e===ArrayPrototype$d||isPrototypeOf$k(ArrayPrototype$d,e)&&t===ArrayPrototype$d.slice?method$h:t},parent$23=slice$6,slice$5=parent$23,parent$22=slice$5,slice$4=parent$22,parent$21=slice$4,slice$3=parent$21,slice$2=slice$3,slice$1=slice$2;function _regeneratorRuntime(){_regeneratorRuntime=function(){return e};var e={},t=Object.prototype,r=t.hasOwnProperty,n=defineProperty$a||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 defineProperty$a(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 l(e,t,r,i){var o=t&&t.prototype instanceof p?t:p,a=create$4(o.prototype),s=new b(i||[]);return n(a,"_invoke",{value:S(e,r,s)}),a}function u(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}e.wrap=l;var d={};function p(){}function _(){}function h(){}var f={};c(f,o,(function(){return this}));var m=getPrototypeOf$3&&getPrototypeOf$3(getPrototypeOf$3(I([])));m&&m!==t&&r.call(m,o)&&(f=m);var v=h.prototype=p.prototype=create$4(f);function g(e){var t;forEach$1(t=["next","throw","return"]).call(t,(function(t){c(e,t,(function(e){return this._invoke(t,e)}))}))}function y(e,t){function i(n,o,a,s){var c=u(e[n],e,o);if("throw"!==c.type){var l=c.arg,d=l.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){l.value=e,a(l)}),(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 S(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{value:void 0,done:!0}}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=u(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=t.method,n=e.iterator[r];if(void 0===n)return t.delegate=null,"throw"===r&&e.iterator.return&&(t.method="return",t.arg=void 0,T(e,t),"throw"===t.method)||"return"!==r&&(t.method="throw",t.arg=new TypeError("The iterator does not provide a '"+r+"' method")),d;var i=u(n,e.iterator,t.arg);if("throw"===i.type)return t.method="throw",t.arg=i.arg,t.delegate=null,d;var o=i.arg;return o?o.done?(t[e.resultName]=o.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,d):o:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,d)}function $(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 E(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function b(e){this.tryEntries=[{tryLoc:"root"}],forEach$1(e).call(e,$,this),this.reset(!0)}function I(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:R}}function R(){return{value:void 0,done:!0}}return _.prototype=h,n(v,"constructor",{value:h,configurable:!0}),n(h,"constructor",{value:_,configurable:!0}),_.displayName=c(h,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 setPrototypeOf$1?setPrototypeOf$1(e,h):(e.__proto__=h,c(e,s,"GeneratorFunction")),e.prototype=create$4(v),e},e.awrap=function(e){return{__await:e}},g(y.prototype),c(y.prototype,a,(function(){return this})),e.AsyncIterator=y,e.async=function(t,r,n,i,o){void 0===o&&(o=promise);var a=new y(l(t,r,n,i),o);return e.isGeneratorFunction(r)?a:a.next().then((function(e){return e.done?e.value:a.next()}))},g(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 reverse2(r).call(r),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,b.prototype={constructor:b,reset:function(e){var t;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,forEach$1(t=this.tryEntries).call(t,E),!e)for(var n in this)"t"===n.charAt(0)&&r.call(this,n)&&!isNaN(+slice$1(n).call(n,1))&&(this[n]=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),E(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;E(r)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,r){return this.delegate={iterator:I(e),resultName:t,nextLoc:r},"next"===this.method&&(this.arg=void 0),d}},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)}))}}var entryVirtual$i=entryVirtual$m,concat$8=entryVirtual$i("Array").concat,isPrototypeOf$j=objectIsPrototypeOf,method$g=concat$8,ArrayPrototype$c=Array.prototype,concat$7=function(e){var t=e.concat;return e===ArrayPrototype$c||isPrototypeOf$j(ArrayPrototype$c,e)&&t===ArrayPrototype$c.concat?method$g:t},parent$20=concat$7,concat$6=parent$20,parent$1$=concat$6,concat$5=parent$1$,parent$1_=concat$5,concat$4=parent$1_,concat$3=concat$4,concat$2=concat$3,path$k=path$v,apply$2=functionApply;path$k.JSON||(path$k.JSON={stringify:JSON.stringify});var stringify$6=function(e,t,r){return apply$2(path$k.JSON.stringify,null,arguments)},parent$1Z=stringify$6,stringify$5=parent$1Z,parent$1Y=stringify$5,stringify$4=parent$1Y,parent$1X=stringify$4,stringify$3=parent$1X,stringify$2=stringify$3,stringify$1=stringify$2,$$1e=_export,$map=arrayIteration.map,arrayMethodHasSpeciesSupport$2=arrayMethodHasSpeciesSupport$5,HAS_SPECIES_SUPPORT$2=arrayMethodHasSpeciesSupport$2("map");$$1e({target:"Array",proto:!0,forced:!HAS_SPECIES_SUPPORT$2},{map:function(e){return $map(this,e,arguments.length>1?arguments[1]:void 0)}});var entryVirtual$h=entryVirtual$m,map$c=entryVirtual$h("Array").map,isPrototypeOf$i=objectIsPrototypeOf,method$f=map$c,ArrayPrototype$b=Array.prototype,map$b=function(e){var t=e.map;return e===ArrayPrototype$b||isPrototypeOf$i(ArrayPrototype$b,e)&&t===ArrayPrototype$b.map?method$f:t},parent$1W=map$b,map$a=parent$1W,parent$1V=map$a,map$9=parent$1V,parent$1U=map$9,map$8=parent$1U,map$7=map$8,map$6=map$7,whitespaces$4="\t\n\v\f\r                 \u2028\u2029\ufeff",uncurryThis$j=functionUncurryThis,requireObjectCoercible$5=requireObjectCoercible$9,toString$b=toString$h,whitespaces$3=whitespaces$4,replace$3=uncurryThis$j("".replace),whitespace="["+whitespaces$3+"]",ltrim=RegExp("^"+whitespace+whitespace+"*"),rtrim=RegExp(whitespace+whitespace+"*$"),createMethod$3=function(e){return function(t){var r=toString$b(requireObjectCoercible$5(t));return 1&e&&(r=replace$3(r,ltrim,"")),2&e&&(r=replace$3(r,rtrim,"")),r}},stringTrim={start:createMethod$3(1),end:createMethod$3(2),trim:createMethod$3(3)},global$7=global$s,fails$e=fails$z,uncurryThis$i=functionUncurryThis,toString$a=toString$h,trim$8=stringTrim.trim,whitespaces$2=whitespaces$4,$parseInt$1=global$7.parseInt,Symbol$4=global$7.Symbol,ITERATOR$3=Symbol$4&&Symbol$4.iterator,hex=/^[+-]?0x/i,exec$2=uncurryThis$i(hex.exec),FORCED$4=8!==$parseInt$1(whitespaces$2+"08")||22!==$parseInt$1(whitespaces$2+"0x16")||ITERATOR$3&&!fails$e((function(){$parseInt$1(Object(ITERATOR$3))})),numberParseInt=FORCED$4?function(e,t){var r=trim$8(toString$a(e));return $parseInt$1(r,t>>>0||(exec$2(hex,r)?16:10))}:$parseInt$1,$$1d=_export,$parseInt=numberParseInt;$$1d({global:!0,forced:parseInt!=numberParseInt},{parseInt:numberParseInt});var path$j=path$v,_parseInt$b=path$j.parseInt,parent$1T=_parseInt$b,_parseInt$a=parent$1T,parent$1S=_parseInt$a,_parseInt$9=parent$1S,parent$1R=_parseInt$9,_parseInt$8=parent$1R,_parseInt$7=_parseInt$8,_parseInt$6=_parseInt$7,internalMetadata={exports:{}},fails$d=fails$z,arrayBufferNonExtensible=fails$d((function(){if("function"==typeof ArrayBuffer){var e=new ArrayBuffer(8);Object.isExtensible(e)&&Object.defineProperty(e,"a",{value:8})}})),fails$c=fails$z,isObject$c=isObject$q,classof$4=classofRaw$2,ARRAY_BUFFER_NON_EXTENSIBLE=arrayBufferNonExtensible,$isExtensible=Object.isExtensible,FAILS_ON_PRIMITIVES$2=fails$c((function(){$isExtensible(1)})),objectIsExtensible=FAILS_ON_PRIMITIVES$2||ARRAY_BUFFER_NON_EXTENSIBLE?function(e){return!!isObject$c(e)&&((!ARRAY_BUFFER_NON_EXTENSIBLE||"ArrayBuffer"!=classof$4(e))&&(!$isExtensible||$isExtensible(e)))}:$isExtensible,fails$b=fails$z,freezing=!fails$b((function(){return Object.isExtensible(Object.preventExtensions({}))})),$$1c=_export,uncurryThis$h=functionUncurryThis,hiddenKeys=hiddenKeys$6,isObject$b=isObject$q,hasOwn$8=hasOwnProperty_1,defineProperty$6=objectDefineProperty.f,getOwnPropertyNamesModule=objectGetOwnPropertyNames,getOwnPropertyNamesExternalModule=objectGetOwnPropertyNamesExternal,isExtensible$1=objectIsExtensible,uid=uid$4,FREEZING=freezing,REQUIRED=!1,METADATA=uid("meta"),id$1=0,setMetadata=function(e){defineProperty$6(e,METADATA,{value:{objectID:"O"+id$1++,weakData:{}}})},fastKey$1=function(e,t){if(!isObject$b(e))return"symbol"==typeof e?e:("string"==typeof e?"S":"P")+e;if(!hasOwn$8(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$8(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$8(e,METADATA)&&setMetadata(e),e},enable=function(){meta.enable=function(){},REQUIRED=!0;var e=getOwnPropertyNamesModule.f,t=uncurryThis$h([].splice),r={};r[METADATA]=1,e(r).length&&(getOwnPropertyNamesModule.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},$$1c({target:"Object",stat:!0,forced:!0},{getOwnPropertyNames:getOwnPropertyNamesExternalModule.f}))},meta=internalMetadata.exports={enable:enable,fastKey:fastKey$1,getWeakData:getWeakData$1,onFreeze:onFreeze};hiddenKeys[METADATA]=!0;var $$1b=_export,global$6=global$s,InternalMetadataModule$1=internalMetadata.exports,fails$a=fails$z,createNonEnumerableProperty=createNonEnumerableProperty$8,iterate$u=iterate$A,anInstance$4=anInstance$6,isCallable$3=isCallable$n,isObject$a=isObject$q,setToStringTag$2=setToStringTag$9,defineProperty$5=objectDefineProperty.f,forEach2=arrayIteration.forEach,DESCRIPTORS$9=descriptors,InternalStateModule$4=internalState,setInternalState$4=InternalStateModule$4.set,internalStateGetterFor$2=InternalStateModule$4.getterFor,collection$3=function(e,t,r){var n,i=-1!==e.indexOf("Map"),o=-1!==e.indexOf("Weak"),a=i?"set":"add",s=global$6[e],c=s&&s.prototype,l={};if(DESCRIPTORS$9&&isCallable$3(s)&&(o||c.forEach&&!fails$a((function(){(new s).entries().next()})))){var u=(n=t((function(t,r){setInternalState$4(anInstance$4(t,u),{type:e,collection:new s}),null!=r&&iterate$u(r,t[a],{that:t,AS_ENTRIES:i})}))).prototype,d=internalStateGetterFor$2(e);forEach2(["add","clear","delete","forEach","get","has","set","keys","values","entries"],(function(e){var t="add"==e||"set"==e;!(e in c)||o&&"clear"==e||createNonEnumerableProperty(u,e,(function(r,n){var i=d(this).collection;if(!t&&o&&!isObject$a(r))return"get"==e&&void 0;var a=i[e](0===r?0:r,n);return t?this:a}))})),o||defineProperty$5(u,"size",{configurable:!0,get:function(){return d(this).collection.size}})}else n=r.getConstructor(t,e,i,a),InternalMetadataModule$1.enable();return setToStringTag$2(n,e,!1,!0),l[e]=n,$$1b({global:!0,forced:!0},l),o||r.setStrong(n,e,i),n},defineBuiltIn$2=defineBuiltIn$8,defineBuiltIns$4=function(e,t,r){for(var n in t)r&&r.unsafe&&e[n]?e[n]=t[n]:defineBuiltIn$2(e,n,t[n],r);return e},defineProperty$4=objectDefineProperty.f,create$2=objectCreate$1,defineBuiltIns$3=defineBuiltIns$4,bind$p=functionBindContext,anInstance$3=anInstance$6,isNullOrUndefined$2=isNullOrUndefined$7,iterate$t=iterate$A,defineIterator=iteratorDefine,createIterResultObject=createIterResultObject$3,setSpecies=setSpecies$2,DESCRIPTORS$8=descriptors,fastKey=internalMetadata.exports.fastKey,InternalStateModule$3=internalState,setInternalState$3=InternalStateModule$3.set,internalStateGetterFor$1=InternalStateModule$3.getterFor,collectionStrong$2={getConstructor:function(e,t,r,n){var i=e((function(e,i){anInstance$3(e,o),setInternalState$3(e,{type:t,index:create$2(null),first:void 0,last:void 0,size:0}),DESCRIPTORS$8||(e.size=0),isNullOrUndefined$2(i)||iterate$t(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$8?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$3(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$8?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$8?r.size--:t.size--}return!!n},forEach:function(e){for(var t,r=a(this),n=bind$p(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$3(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$8&&defineProperty$4(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(e,t,(function(e,t){setInternalState$3(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("keys"==t?r.key:"values"==t?r.value:[r.key,r.value],!1):(e.target=void 0,createIterResultObject(void 0,!0))}),r?"entries":"values",!r,!0),setSpecies(t)}},collection$2=collection$3,collectionStrong$1=collectionStrong$2;collection$2("Map",(function(e){return function(){return e(this,arguments.length?arguments[0]:void 0)}}),collectionStrong$1);var path$i=path$v,map$5=path$i.Map,parent$1Q=map$5,map$4=parent$1Q,parent$1P=map$4,map$3=parent$1P,bind$o=functionBindContext,call$o=functionCall,aCallable$p=aCallable$z,aConstructor$1=aConstructor$3,isNullOrUndefined$1=isNullOrUndefined$7,iterate$s=iterate$A,push$8=[].push,collectionFrom=function(e){var t,r,n,i,o=arguments.length,a=o>1?arguments[1]:void 0;return aConstructor$1(this),(t=void 0!==a)&&aCallable$p(a),isNullOrUndefined$1(e)?new this:(r=[],t?(n=0,i=bind$o(a,o>2?arguments[2]:void 0),iterate$s(e,(function(e){call$o(push$8,r,i(e,n++))}))):iterate$s(e,push$8,{that:r}),new this(r))},$$1a=_export,from$9=collectionFrom;$$1a({target:"Map",stat:!0,forced:!0},{from:from$9});var arraySlice$3=arraySlice$6,collectionOf=function(){return new this(arraySlice$3(arguments))},$$19=_export,of$2=collectionOf;$$19({target:"Map",stat:!0,forced:!0},{of:of$2});var call$n=functionCall,aCallable$o=aCallable$z,anObject$A=anObject$M,collectionDeleteAll=function(){for(var e,t=anObject$A(this),r=aCallable$o(t.delete),n=!0,i=0,o=arguments.length;i<o;i++)e=call$n(r,t,arguments[i]),n=n&&e;return!!n},$$18=_export,deleteAll$2=collectionDeleteAll;$$18({target:"Map",proto:!0,real:!0,forced:!0},{deleteAll:deleteAll$2});var call$m=functionCall,aCallable$n=aCallable$z,anObject$z=anObject$M,mapEmplace=function(e,t){var r,n,i=anObject$z(this),o=aCallable$n(i.get),a=aCallable$n(i.has),s=aCallable$n(i.set);return call$m(a,i,e)?(r=call$m(o,i,e),"update"in t&&(r=t.update(r,e,i),call$m(s,i,e,r)),r):(n=t.insert(e,i),call$m(s,i,e,n),n)},$$17=_export,emplace$1=mapEmplace;$$17({target:"Map",proto:!0,real:!0,forced:!0},{emplace:emplace$1});var getIterator$5=getIterator$7,getMapIterator$a=getIterator$5,$$16=_export,anObject$y=anObject$M,bind$n=functionBindContext,getMapIterator$9=getMapIterator$a,iterate$r=iterate$A;$$16({target:"Map",proto:!0,real:!0,forced:!0},{every:function(e){var t=anObject$y(this),r=getMapIterator$9(t),n=bind$n(e,arguments.length>1?arguments[1]:void 0);return!iterate$r(r,(function(e,r,i){if(!n(r,e,t))return i()}),{AS_ENTRIES:!0,IS_ITERATOR:!0,INTERRUPTED:!0}).stopped}});var $$15=_export,getBuiltIn$a=getBuiltIn$o,bind$m=functionBindContext,call$l=functionCall,aCallable$m=aCallable$z,anObject$x=anObject$M,speciesConstructor$8=speciesConstructor$b,getMapIterator$8=getMapIterator$a,iterate$q=iterate$A;$$15({target:"Map",proto:!0,real:!0,forced:!0},{filter:function(e){var t=anObject$x(this),r=getMapIterator$8(t),n=bind$m(e,arguments.length>1?arguments[1]:void 0),i=new(speciesConstructor$8(t,getBuiltIn$a("Map"))),o=aCallable$m(i.set);return iterate$q(r,(function(e,r){n(r,e,t)&&call$l(o,i,e,r)}),{AS_ENTRIES:!0,IS_ITERATOR:!0}),i}});var $$14=_export,anObject$w=anObject$M,bind$l=functionBindContext,getMapIterator$7=getMapIterator$a,iterate$p=iterate$A;$$14({target:"Map",proto:!0,real:!0,forced:!0},{find:function(e){var t=anObject$w(this),r=getMapIterator$7(t),n=bind$l(e,arguments.length>1?arguments[1]:void 0);return iterate$p(r,(function(e,r,i){if(n(r,e,t))return i(r)}),{AS_ENTRIES:!0,IS_ITERATOR:!0,INTERRUPTED:!0}).result}});var $$13=_export,anObject$v=anObject$M,bind$k=functionBindContext,getMapIterator$6=getMapIterator$a,iterate$o=iterate$A;$$13({target:"Map",proto:!0,real:!0,forced:!0},{findKey:function(e){var t=anObject$v(this),r=getMapIterator$6(t),n=bind$k(e,arguments.length>1?arguments[1]:void 0);return iterate$o(r,(function(e,r,i){if(n(r,e,t))return i(e)}),{AS_ENTRIES:!0,IS_ITERATOR:!0,INTERRUPTED:!0}).result}});var $$12=_export,call$k=functionCall,uncurryThis$g=functionUncurryThis,aCallable$l=aCallable$z,getIterator$4=getIterator$7,iterate$n=iterate$A,push$7=uncurryThis$g([].push);$$12({target:"Map",stat:!0,forced:!0},{groupBy:function(e,t){aCallable$l(t);var r=getIterator$4(e),n=new this,i=aCallable$l(n.has),o=aCallable$l(n.get),a=aCallable$l(n.set);return iterate$n(r,(function(e){var r=t(e);call$k(i,n,r)?push$7(call$k(o,n,r),e):call$k(a,n,r,[e])}),{IS_ITERATOR:!0}),n}});var sameValueZero$1=function(e,t){return e===t||e!=e&&t!=t},$$11=_export,anObject$u=anObject$M,getMapIterator$5=getMapIterator$a,sameValueZero=sameValueZero$1,iterate$m=iterate$A;$$11({target:"Map",proto:!0,real:!0,forced:!0},{includes:function(e){return iterate$m(getMapIterator$5(anObject$u(this)),(function(t,r,n){if(sameValueZero(r,e))return n()}),{AS_ENTRIES:!0,IS_ITERATOR:!0,INTERRUPTED:!0}).stopped}});var $$10=_export,call$j=functionCall,iterate$l=iterate$A,aCallable$k=aCallable$z;$$10({target:"Map",stat:!0,forced:!0},{keyBy:function(e,t){var r=new this;aCallable$k(t);var n=aCallable$k(r.set);return iterate$l(e,(function(e){call$j(n,r,t(e),e)})),r}});var $$$=_export,anObject$t=anObject$M,getMapIterator$4=getMapIterator$a,iterate$k=iterate$A;$$$({target:"Map",proto:!0,real:!0,forced:!0},{keyOf:function(e){return iterate$k(getMapIterator$4(anObject$t(this)),(function(t,r,n){if(r===e)return n(t)}),{AS_ENTRIES:!0,IS_ITERATOR:!0,INTERRUPTED:!0}).result}});var $$_=_export,getBuiltIn$9=getBuiltIn$o,bind$j=functionBindContext,call$i=functionCall,aCallable$j=aCallable$z,anObject$s=anObject$M,speciesConstructor$7=speciesConstructor$b,getMapIterator$3=getMapIterator$a,iterate$j=iterate$A;$$_({target:"Map",proto:!0,real:!0,forced:!0},{mapKeys:function(e){var t=anObject$s(this),r=getMapIterator$3(t),n=bind$j(e,arguments.length>1?arguments[1]:void 0),i=new(speciesConstructor$7(t,getBuiltIn$9("Map"))),o=aCallable$j(i.set);return iterate$j(r,(function(e,r){call$i(o,i,n(r,e,t),r)}),{AS_ENTRIES:!0,IS_ITERATOR:!0}),i}});var $$Z=_export,getBuiltIn$8=getBuiltIn$o,bind$i=functionBindContext,call$h=functionCall,aCallable$i=aCallable$z,anObject$r=anObject$M,speciesConstructor$6=speciesConstructor$b,getMapIterator$2=getMapIterator$a,iterate$i=iterate$A;$$Z({target:"Map",proto:!0,real:!0,forced:!0},{mapValues:function(e){var t=anObject$r(this),r=getMapIterator$2(t),n=bind$i(e,arguments.length>1?arguments[1]:void 0),i=new(speciesConstructor$6(t,getBuiltIn$8("Map"))),o=aCallable$i(i.set);return iterate$i(r,(function(e,r){call$h(o,i,e,n(r,e,t))}),{AS_ENTRIES:!0,IS_ITERATOR:!0}),i}});var $$Y=_export,aCallable$h=aCallable$z,anObject$q=anObject$M,iterate$h=iterate$A;$$Y({target:"Map",proto:!0,real:!0,arity:1,forced:!0},{merge:function(e){for(var t=anObject$q(this),r=aCallable$h(t.set),n=arguments.length,i=0;i<n;)iterate$h(arguments[i++],r,{that:t,AS_ENTRIES:!0});return t}});var $$X=_export,anObject$p=anObject$M,aCallable$g=aCallable$z,getMapIterator$1=getMapIterator$a,iterate$g=iterate$A,$TypeError$7=TypeError;$$X({target:"Map",proto:!0,real:!0,forced:!0},{reduce:function(e){var t=anObject$p(this),r=getMapIterator$1(t),n=arguments.length<2,i=n?void 0:arguments[1];if(aCallable$g(e),iterate$g(r,(function(r,o){n?(n=!1,i=o):i=e(i,o,r,t)}),{AS_ENTRIES:!0,IS_ITERATOR:!0}),n)throw $TypeError$7("Reduce of empty map with no initial value");return i}});var $$W=_export,anObject$o=anObject$M,bind$h=functionBindContext,getMapIterator=getMapIterator$a,iterate$f=iterate$A;$$W({target:"Map",proto:!0,real:!0,forced:!0},{some:function(e){var t=anObject$o(this),r=getMapIterator(t),n=bind$h(e,arguments.length>1?arguments[1]:void 0);return iterate$f(r,(function(e,r,i){if(n(r,e,t))return i()}),{AS_ENTRIES:!0,IS_ITERATOR:!0,INTERRUPTED:!0}).stopped}});var $$V=_export,call$g=functionCall,anObject$n=anObject$M,aCallable$f=aCallable$z,$TypeError$6=TypeError;$$V({target:"Map",proto:!0,real:!0,forced:!0},{update:function(e,t){var r=anObject$n(this),n=aCallable$f(r.get),i=aCallable$f(r.has),o=aCallable$f(r.set),a=arguments.length;aCallable$f(t);var s=call$g(i,r,e);if(!s&&a<3)throw $TypeError$6("Updating absent value");var c=s?call$g(n,r,e):aCallable$f(a>2?arguments[2]:void 0)(e,r);return call$g(o,r,e,t(c,e,r)),r}});var call$f=functionCall,aCallable$e=aCallable$z,isCallable$2=isCallable$n,anObject$m=anObject$M,$TypeError$5=TypeError,mapUpsert=function(e,t){var r,n=anObject$m(this),i=aCallable$e(n.get),o=aCallable$e(n.has),a=aCallable$e(n.set),s=arguments.length>2?arguments[2]:void 0;if(!isCallable$2(t)&&!isCallable$2(s))throw $TypeError$5("At least one callback required");return call$f(o,n,e)?(r=call$f(i,n,e),isCallable$2(t)&&(r=t(r),call$f(a,n,e,r))):isCallable$2(s)&&(r=s(),call$f(a,n,e,r)),r},$$U=_export,upsert$2=mapUpsert;$$U({target:"Map",proto:!0,real:!0,forced:!0},{upsert:upsert$2});var $$T=_export,upsert$1=mapUpsert;$$T({target:"Map",proto:!0,real:!0,name:"upsert",forced:!0},{updateOrInsert:upsert$1});var parent$1O=map$3,map$2=parent$1O,map$1=map$2,map2=map$1,$$S=_export,toObject$6=toObject$d,nativeKeys$2=objectKeys$4,fails$9=fails$z,FAILS_ON_PRIMITIVES$1=fails$9((function(){nativeKeys$2(1)}));$$S({target:"Object",stat:!0,forced:FAILS_ON_PRIMITIVES$1},{keys:function(e){return nativeKeys$2(toObject$6(e))}});var path$h=path$v,keys$d=path$h.Object.keys,parent$1N=keys$d,keys$c=parent$1N,parent$1M=keys$c,keys$b=parent$1M,parent$1L=keys$b,keys$a=parent$1L,keys$9=keys$a,keys$8=keys$9,aCallable$d=aCallable$z,toObject$5=toObject$d,IndexedObject$1=indexedObject,lengthOfArrayLike$4=lengthOfArrayLike$b,$TypeError$4=TypeError,createMethod$2=function(e){return function(t,r,n,i){aCallable$d(r);var o=toObject$5(t),a=IndexedObject$1(o),s=lengthOfArrayLike$4(o),c=e?s-1:0,l=e?-1:1;if(n<2)for(;;){if(c in a){i=a[c],c+=l;break}if(c+=l,e?c<0:s<=c)throw $TypeError$4("Reduce of empty array with no initial value")}for(;e?c>=0:s>c;c+=l)c in a&&(i=r(i,a[c],c,o));return i}},arrayReduce={left:createMethod$2(!1),right:createMethod$2(!0)},$$R=_export,$reduce=arrayReduce.left,arrayMethodIsStrict$2=arrayMethodIsStrict$4,CHROME_VERSION=engineV8Version,IS_NODE=engineIsNode,STRICT_METHOD$2=arrayMethodIsStrict$2("reduce"),CHROME_BUG=!IS_NODE&&CHROME_VERSION>79&&CHROME_VERSION<83;$$R({target:"Array",proto:!0,forced:!STRICT_METHOD$2||CHROME_BUG},{reduce:function(e){var t=arguments.length;return $reduce(this,e,t,t>1?arguments[1]:void 0)}});var entryVirtual$g=entryVirtual$m,reduce$6=entryVirtual$g("Array").reduce,isPrototypeOf$h=objectIsPrototypeOf,method$e=reduce$6,ArrayPrototype$a=Array.prototype,reduce$5=function(e){var t=e.reduce;return e===ArrayPrototype$a||isPrototypeOf$h(ArrayPrototype$a,e)&&t===ArrayPrototype$a.reduce?method$e:t},parent$1K=reduce$5,reduce$4=parent$1K,parent$1J=reduce$4,reduce$3=parent$1J,parent$1I=reduce$3,reduce$2=parent$1I,reduce$1=reduce$2,reduce3=reduce$1,DESCRIPTORS$7=descriptors,uncurryThis$f=functionUncurryThis,call$e=functionCall,fails$8=fails$z,objectKeys$1=objectKeys$4,getOwnPropertySymbolsModule=objectGetOwnPropertySymbols,propertyIsEnumerableModule=objectPropertyIsEnumerable,toObject$4=toObject$d,IndexedObject=indexedObject,$assign=Object.assign,defineProperty$3=Object.defineProperty,concat$1=uncurryThis$f([].concat),objectAssign=!$assign||fails$8((function(){if(DESCRIPTORS$7&&1!==$assign({b:1},$assign(defineProperty$3({},"a",{enumerable:!0,get:function(){defineProperty$3(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$1($assign({},t)).join("")!=n}))?function(e,t){for(var r=toObject$4(e),n=arguments.length,i=1,o=getOwnPropertySymbolsModule.f,a=propertyIsEnumerableModule.f;n>i;)for(var s,c=IndexedObject(arguments[i++]),l=o?concat$1(objectKeys$1(c),o(c)):objectKeys$1(c),u=l.length,d=0;u>d;)s=l[d++],DESCRIPTORS$7&&!call$e(a,c,s)||(r[s]=c[s]);return r}:$assign,$$Q=_export,assign$8=objectAssign;$$Q({target:"Object",stat:!0,arity:2,forced:Object.assign!==assign$8},{assign:assign$8});var path$g=path$v,assign$7=path$g.Object.assign,parent$1H=assign$7,assign$6=parent$1H,parent$1G=assign$6,assign$5=parent$1G,parent$1F=assign$5,assign$4=parent$1F,assign$3=assign$4,assign$2=assign$3,isObject$9=isObject$q,classof$3=classofRaw$2,wellKnownSymbol$3=wellKnownSymbol$p,MATCH$2=wellKnownSymbol$3("match"),isRegexp=function(e){var t;return isObject$9(e)&&(void 0!==(t=e[MATCH$2])?!!t:"RegExp"==classof$3(e))},isRegExp=isRegexp,$TypeError$3=TypeError,notARegexp=function(e){if(isRegExp(e))throw $TypeError$3("The method doesn't accept regular expressions");return e},wellKnownSymbol$2=wellKnownSymbol$p,MATCH$1=wellKnownSymbol$2("match"),correctIsRegexpLogic=function(e){var t=/./;try{"/./"[e](t)}catch(r){try{return t[MATCH$1]=!1,"/./"[e](t)}catch(e){}}return!1},$$P=_export,uncurryThis$e=functionUncurryThis;objectGetOwnPropertyDescriptor.f;var toLength$2=toLength$4,toString$9=toString$h,notARegExp$2=notARegexp,requireObjectCoercible$4=requireObjectCoercible$9,correctIsRegExpLogic$2=correctIsRegexpLogic,nativeEndsWith=uncurryThis$e("".endsWith),slice2=uncurryThis$e("".slice),min$2=Math.min,CORRECT_IS_REGEXP_LOGIC$1=correctIsRegExpLogic$2("endsWith");$$P({target:"String",proto:!0,forced:!CORRECT_IS_REGEXP_LOGIC$1},{endsWith:function(e){var t=toString$9(requireObjectCoercible$4(this));notARegExp$2(e);var r=arguments.length>1?arguments[1]:void 0,n=t.length,i=void 0===r?n:min$2(toLength$2(r),n),o=toString$9(e);return nativeEndsWith?nativeEndsWith(t,o,i):slice2(t,i-o.length,i)===o}});var entryVirtual$f=entryVirtual$m,endsWith$6=entryVirtual$f("String").endsWith,isPrototypeOf$g=objectIsPrototypeOf,method$d=endsWith$6,StringPrototype$4=String.prototype,endsWith$5=function(e){var t=e.endsWith;return"string"==typeof e||e===StringPrototype$4||isPrototypeOf$g(StringPrototype$4,e)&&t===StringPrototype$4.endsWith?method$d:t},parent$1E=endsWith$5,endsWith$4=parent$1E,parent$1D=endsWith$4,endsWith$3=parent$1D,parent$1C=endsWith$3,endsWith$2=parent$1C,endsWith$1=endsWith$2,endsWith2=endsWith$1,logDisabled_=!0,deprecationWarnings_=!0;function extractVersion(e,t,r){var n=e.match(t);return n&&n.length>=r&&_parseInt$6(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 map2),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===keys$8(this._eventMap).length&&delete this._eventMap,o.apply(this,[e,n])},defineProperty$a(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$1(){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$8(e){return"[object Object]"===Object.prototype.toString.call(e)}function compactObject(e){var t;return isObject$8(e)?reduce3(t=keys$8(e)).call(t,(function(t,r){var n=isObject$8(e[r]),i=n?compactObject(e[r]):e[r],o=n&&!keys$8(i).length;return void 0===i||o?t:assign$2(t,_defineProperty({},r,i))}),{}):e}function walkStats(e,t,r){t&&!r.has(t.id)&&(r.set(t.id,t),keys$8(t).forEach((function(n){endsWith2(n).call(n,"Id")?walkStats(e,e.get(t[n]),r):endsWith2(n).call(n,"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 map2;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 $$O=_export,$find=arrayIteration.find,FIND="find",SKIPS_HOLES$1=!0;FIND in[]&&Array(1)[FIND]((function(){SKIPS_HOLES$1=!1})),$$O({target:"Array",proto:!0,forced:SKIPS_HOLES$1},{find:function(e){return $find(this,e,arguments.length>1?arguments[1]:void 0)}});var entryVirtual$e=entryVirtual$m,find$8=entryVirtual$e("Array").find,isPrototypeOf$f=objectIsPrototypeOf,method$c=find$8,ArrayPrototype$9=Array.prototype,find$7=function(e){var t=e.find;return e===ArrayPrototype$9||isPrototypeOf$f(ArrayPrototype$9,e)&&t===ArrayPrototype$9.find?method$c:t},parent$1B=find$7,find$6=parent$1B,parent$1A=find$6,find$5=parent$1A,parent$1z=find$5,find$4=parent$1z,find$3=find$4,find$2=find$3,$$N=_export,uncurryThis$d=functionUncurryThis,$indexOf=arrayIncludes.indexOf,arrayMethodIsStrict$1=arrayMethodIsStrict$4,nativeIndexOf=uncurryThis$d([].indexOf),NEGATIVE_ZERO=!!nativeIndexOf&&1/nativeIndexOf([1],1,-0)<0,STRICT_METHOD$1=arrayMethodIsStrict$1("indexOf");$$N({target:"Array",proto:!0,forced:NEGATIVE_ZERO||!STRICT_METHOD$1},{indexOf:function(e){var t=arguments.length>1?arguments[1]:void 0;return NEGATIVE_ZERO?nativeIndexOf(this,e,t)||0:$indexOf(this,e,t)}});var entryVirtual$d=entryVirtual$m,indexOf$6=entryVirtual$d("Array").indexOf,isPrototypeOf$e=objectIsPrototypeOf,method$b=indexOf$6,ArrayPrototype$8=Array.prototype,indexOf$5=function(e){var t=e.indexOf;return e===ArrayPrototype$8||isPrototypeOf$e(ArrayPrototype$8,e)&&t===ArrayPrototype$8.indexOf?method$b:t},parent$1y=indexOf$5,indexOf$4=parent$1y,parent$1x=indexOf$4,indexOf$3=parent$1x,parent$1w=indexOf$3,indexOf$2=parent$1w,indexOf$1=indexOf$2,indexOf2=indexOf$1,DESCRIPTORS$6=descriptors,isArray$9=isArray$f,$TypeError$2=TypeError,getOwnPropertyDescriptor$8=Object.getOwnPropertyDescriptor,SILENT_ON_NON_WRITABLE_LENGTH_SET=DESCRIPTORS$6&&!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$9(e)&&!getOwnPropertyDescriptor$8(e,"length").writable)throw $TypeError$2("Cannot set read only .length");return e.length=t}:function(e,t){return e.length=t},tryToString=tryToString$6,$TypeError$1=TypeError,deletePropertyOrThrow$2=function(e,t){if(!delete e[t])throw $TypeError$1("Cannot delete property "+tryToString(t)+" of "+tryToString(e))},$$M=_export,toObject$3=toObject$d,toAbsoluteIndex$1=toAbsoluteIndex$5,toIntegerOrInfinity$1=toIntegerOrInfinity$5,lengthOfArrayLike$3=lengthOfArrayLike$b,setArrayLength=arraySetLength,doesNotExceedSafeInteger=doesNotExceedSafeInteger$2,arraySpeciesCreate=arraySpeciesCreate$3,createProperty$2=createProperty$6,deletePropertyOrThrow$1=deletePropertyOrThrow$2,arrayMethodHasSpeciesSupport$1=arrayMethodHasSpeciesSupport$5,HAS_SPECIES_SUPPORT$1=arrayMethodHasSpeciesSupport$1("splice"),max=Math.max,min$1=Math.min;$$M({target:"Array",proto:!0,forced:!HAS_SPECIES_SUPPORT$1},{splice:function(e,t){var r,n,i,o,a,s,c=toObject$3(this),l=lengthOfArrayLike$3(c),u=toAbsoluteIndex$1(e,l),d=arguments.length;for(0===d?r=n=0:1===d?(r=0,n=l-u):(r=d-2,n=min$1(max(toIntegerOrInfinity$1(t),0),l-u)),doesNotExceedSafeInteger(l+r-n),i=arraySpeciesCreate(c,n),o=0;o<n;o++)(a=u+o)in c&&createProperty$2(i,o,c[a]);if(i.length=n,r<n){for(o=u;o<l-n;o++)s=o+r,(a=o+n)in c?c[s]=c[a]:deletePropertyOrThrow$1(c,s);for(o=l;o>l-n+r;o--)deletePropertyOrThrow$1(c,o-1)}else if(r>n)for(o=l-n;o>u;o--)s=o+r-1,(a=o+n-1)in c?c[s]=c[a]:deletePropertyOrThrow$1(c,s);for(o=0;o<r;o++)c[o+u]=arguments[o+2];return setArrayLength(c,l-n+r),i}});var entryVirtual$c=entryVirtual$m,splice$9=entryVirtual$c("Array").splice,isPrototypeOf$d=objectIsPrototypeOf,method$a=splice$9,ArrayPrototype$7=Array.prototype,splice$8=function(e){var t=e.splice;return e===ArrayPrototype$7||isPrototypeOf$d(ArrayPrototype$7,e)&&t===ArrayPrototype$7.splice?method$a:t},parent$1v=splice$8,splice$7=parent$1v,parent$1u=splice$7,splice$6=parent$1u,parent$1t=splice$6,splice$5=parent$1t,splice$4=splice$5,splice$3=splice$4,$$L=_export,$filter=arrayIteration.filter,arrayMethodHasSpeciesSupport=arrayMethodHasSpeciesSupport$5,HAS_SPECIES_SUPPORT=arrayMethodHasSpeciesSupport("filter");$$L({target:"Array",proto:!0,forced:!HAS_SPECIES_SUPPORT},{filter:function(e){return $filter(this,e,arguments.length>1?arguments[1]:void 0)}});var entryVirtual$b=entryVirtual$m,filter$6=entryVirtual$b("Array").filter,isPrototypeOf$c=objectIsPrototypeOf,method$9=filter$6,ArrayPrototype$6=Array.prototype,filter$5=function(e){var t=e.filter;return e===ArrayPrototype$6||isPrototypeOf$c(ArrayPrototype$6,e)&&t===ArrayPrototype$6.filter?method$9:t},parent$1s=filter$5,filter$4=parent$1s,parent$1r=filter$4,filter$3=parent$1r,parent$1q=filter$3,filter$2=parent$1q,filter$1=filter$2,filter3=filter$1,getOwnPropertyDescriptor$7={exports:{}},$$K=_export,fails$7=fails$z,toIndexedObject$2=toIndexedObject$b,nativeGetOwnPropertyDescriptor=objectGetOwnPropertyDescriptor.f,DESCRIPTORS$5=descriptors,FAILS_ON_PRIMITIVES=fails$7((function(){nativeGetOwnPropertyDescriptor(1)})),FORCED$3=!DESCRIPTORS$5||FAILS_ON_PRIMITIVES;$$K({target:"Object",stat:!0,forced:FORCED$3,sham:!DESCRIPTORS$5},{getOwnPropertyDescriptor:function(e,t){return nativeGetOwnPropertyDescriptor(toIndexedObject$2(e),t)}});var path$f=path$v,Object$2=path$f.Object,getOwnPropertyDescriptor$6=getOwnPropertyDescriptor$7.exports=function(e,t){return Object$2.getOwnPropertyDescriptor(e,t)};Object$2.getOwnPropertyDescriptor.sham&&(getOwnPropertyDescriptor$6.sham=!0);var parent$1p=getOwnPropertyDescriptor$7.exports,getOwnPropertyDescriptor$5=parent$1p,parent$1o=getOwnPropertyDescriptor$5,getOwnPropertyDescriptor$4=parent$1o,parent$1n=getOwnPropertyDescriptor$4,getOwnPropertyDescriptor$3=parent$1n,getOwnPropertyDescriptor$2=getOwnPropertyDescriptor$3,getOwnPropertyDescriptor$1=getOwnPropertyDescriptor$2,$$J=_export,$includes=arrayIncludes.includes,fails$6=fails$z,BROKEN_ON_SPARSE=fails$6((function(){return!Array(1).includes()}));$$J({target:"Array",proto:!0,forced:BROKEN_ON_SPARSE},{includes:function(e){return $includes(this,e,arguments.length>1?arguments[1]:void 0)}});var entryVirtual$a=entryVirtual$m,includes$7=entryVirtual$a("Array").includes,$$I=_export,uncurryThis$c=functionUncurryThis,notARegExp$1=notARegexp,requireObjectCoercible$3=requireObjectCoercible$9,toString$8=toString$h,correctIsRegExpLogic$1=correctIsRegexpLogic,stringIndexOf=uncurryThis$c("".indexOf);$$I({target:"String",proto:!0,forced:!correctIsRegExpLogic$1("includes")},{includes:function(e){return!!~stringIndexOf(toString$8(requireObjectCoercible$3(this)),toString$8(notARegExp$1(e)),arguments.length>1?arguments[1]:void 0)}});var entryVirtual$9=entryVirtual$m,includes$6=entryVirtual$9("String").includes,isPrototypeOf$b=objectIsPrototypeOf,arrayMethod=includes$7,stringMethod=includes$6,ArrayPrototype$5=Array.prototype,StringPrototype$3=String.prototype,includes$5=function(e){var t=e.includes;return e===ArrayPrototype$5||isPrototypeOf$b(ArrayPrototype$5,e)&&t===ArrayPrototype$5.includes?arrayMethod:"string"==typeof e||e===StringPrototype$3||isPrototypeOf$b(StringPrototype$3,e)&&t===StringPrototype$3.includes?stringMethod:t},parent$1m=includes$5,includes$4=parent$1m,parent$1l=includes$4,includes$3=parent$1l,parent$1k=includes$3,includes$2=parent$1k,includes$1=includes$2,includes4=includes$1,logging=log$1;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,r={};(keys$8(e).forEach((function(t){if("require"!==t&&"advanced"!==t&&"mediaSource"!==t){var n="object"===_typeof(e[t])?e[t]:{ideal:e[t]};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()+slice$1(t).call(t,1):"deviceId"===t?"sourceId":t};if(void 0!==n.ideal){r.optional=r.optional||[];var o={};"number"==typeof n.ideal?(o[i("min",t)]=n.ideal,r.optional.push(o),(o={})[i("max",t)]=n.ideal,r.optional.push(o)):(o[i("",t)]=n.ideal,r.optional.push(o))}void 0!==n.exact&&"number"!=typeof n.exact?(r.mandatory=r.mandatory||{},r.mandatory[i("",t)]=n.exact):["min","max"].forEach((function(e){void 0!==n[e]&&(r.mandatory=r.mandatory||{},r.mandatory[i(e,t)]=n[e])}))}})),e.advanced)&&(r.optional=concat$2(t=r.optional||[]).call(t,e.advanced));return r},i=function(e,i){if(t.version>=61)return i(e);if((e=JSON.parse(stringify$1(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(stringify$1(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){t=filter3(t).call(t,(function(e){return"videoinput"===e.kind}));var r=find$2(t).call(t,(function(e){return s.some((function(t){var r;return includes4(r=e.label.toLowerCase()).call(r,t)}))}));return!r&&t.length&&includes4(s).call(s,"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: "+stringify$1(e)),i(e)}));e.video=n(e.video)}return logging("chrome: "+stringify$1(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)){defineProperty$a(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,o;e.RTCPeerConnection.prototype.getReceivers?i=find$2(o=r.getReceivers()).call(o,(function(e){return e.track&&e.track.id===n.track.id})):i={track:n.track};var a=new Event("track");a.track=n.track,a.receiver=i,a.transceiver={receiver:i},a.streams=[t.stream],r.dispatchEvent(a)})),t.stream.getTracks().forEach((function(n){var i,o;e.RTCPeerConnection.prototype.getReceivers?i=find$2(o=r.getReceivers()).call(o,(function(e){return e.track&&e.track.id===n.id})):i={track:n};var a=new Event("track");a.track=n,a.receiver=i,a.transceiver={receiver:i},a.streams=[t.stream],r.dispatchEvent(a)}))},this.addEventListener("addstream",this._ontrackpoly)),t.apply(this,arguments)}}else wrapPeerConnectionEvent(e,"track",(function(e){return e.transceiver||defineProperty$a(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(){var e;return this._senders=this._senders||[],slice$1(e=this._senders).call(e)};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){var t;n.apply(this,arguments);var r,i=indexOf2(t=this._senders).call(t,e);-1!==i&&splice$3(r=this._senders).call(r,i,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,n,i,o=find$2(r=t._senders).call(r,(function(t){return t.track===e}));o&&splice$3(n=t._senders).call(n,indexOf2(i=t._senders).call(i,o),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},defineProperty$a(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=slice$1(Array.prototype).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){var t;return new map2(map$6(t=keys$8(e)).call(t,(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,t=this;return this._shimmedLocalStreams=this._shimmedLocalStreams||{},map$6(e=keys$8(this._shimmedLocalStreams)).call(e,(function(e){return t._shimmedLocalStreams[e][0]}))};var t=e.RTCPeerConnection.prototype.addTrack;e.RTCPeerConnection.prototype.addTrack=function(e,r){var n;if(!r)return t.apply(this,arguments);this._shimmedLocalStreams=this._shimmedLocalStreams||{};var i=t.apply(this,arguments);return this._shimmedLocalStreams[r.id]?-1===indexOf2(n=this._shimmedLocalStreams[r.id]).call(n,i)&&this._shimmedLocalStreams[r.id].push(i):this._shimmedLocalStreams[r.id]=[r,i],i};var r=e.RTCPeerConnection.prototype.addStream;e.RTCPeerConnection.prototype.addStream=function(e){var t,n,i=this;this._shimmedLocalStreams=this._shimmedLocalStreams||{},e.getTracks().forEach((function(e){var t;if(find$2(t=i.getSenders()).call(t,(function(t){return t.track===e})))throw new DOMException("Track already exists.","InvalidAccessError")}));var o=this.getSenders();r.apply(this,arguments);var a=filter3(t=this.getSenders()).call(t,(function(e){return-1===indexOf2(o).call(o,e)}));this._shimmedLocalStreams[e.id]=concat$2(n=[e]).call(n,a)};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&&keys$8(this._shimmedLocalStreams).forEach((function(r){var n,i,o=indexOf2(n=t._shimmedLocalStreams[r]).call(n,e);-1!==o&&splice$3(i=t._shimmedLocalStreams[r]).call(i,o,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||{},map$6(t).call(t,(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){var t;if(find$2(t=r.getSenders()).call(t,(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,i,o,a=this;if("closed"===this.signalingState)throw new DOMException("The RTCPeerConnection's signalingState is 'closed'.","InvalidStateError");var s=slice$1([]).call(arguments,1);if(1!==s.length||!find$2(n=s[0].getTracks()).call(n,(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 c=find$2(i=this.getSenders()).call(i,(function(e){return e.track===t}));if(c)throw new DOMException("Track already exists.","InvalidAccessError");this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{};var l=this._streams[r.id];if(l)l.addTrack(t),promise.resolve().then((function(){a.dispatchEvent(new Event("negotiationneeded"))}));else{var u=new e.MediaStream([t]);this._streams[r.id]=u,this._reverseStreams[u.id]=r,this.addStream(u)}return find$2(o=this.getSenders()).call(o,(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=getOwnPropertyDescriptor$1(e.RTCPeerConnection.prototype,"localDescription");defineProperty$a(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||{},keys$8(this._streams).forEach((function(n){var i;find$2(i=r._streams[n].getTracks()).call(i,(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 keys$8(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 keys$8(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"})),$$H=_export,isArray$8=isArray$f;$$H({target:"Array",stat:!0},{isArray:isArray$8});var path$e=path$v,isArray$7=path$e.Array.isArray,parent$1j=isArray$7,isArray$6=parent$1j,parent$1i=isArray$6,isArray$5=parent$1i,parent$1h=isArray$5,isArray$4=parent$1h,isArray$3=isArray$4,isArray$2=isArray$3;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 _arrayWithoutHoles(e){if(isArray$2(e))return _arrayLikeToArray(e)}var getIteratorMethod$7=getIteratorMethod$a,getIteratorMethod_1=getIteratorMethod$7,parent$1g=getIteratorMethod_1,getIteratorMethod$6=parent$1g,parent$1f=getIteratorMethod$6,getIteratorMethod$5=parent$1f,parent$1e=getIteratorMethod$5,getIteratorMethod$4=parent$1e,getIteratorMethod$3=getIteratorMethod$4,getIteratorMethod$2=getIteratorMethod$3,anObject$l=anObject$M,iteratorClose=iteratorClose$2,callWithSafeIterationClosing$1=function(e,t,r,n){try{return n?t(anObject$l(r)[0],r[1]):t(r)}catch(t){iteratorClose(e,"throw",t)}},bind$g=functionBindContext,call$d=functionCall,toObject$2=toObject$d,callWithSafeIterationClosing=callWithSafeIterationClosing$1,isArrayIteratorMethod=isArrayIteratorMethod$2,isConstructor3=isConstructor$4,lengthOfArrayLike$2=lengthOfArrayLike$b,createProperty$1=createProperty$6,getIterator$3=getIterator$7,getIteratorMethod$1=getIteratorMethod$a,$Array=Array,arrayFrom$1=function(e){var t=toObject$2(e),r=isConstructor3(this),n=arguments.length,i=n>1?arguments[1]:void 0,o=void 0!==i;o&&(i=bind$g(i,n>2?arguments[2]:void 0));var a,s,c,l,u,d,p=getIteratorMethod$1(t),_=0;if(!p||this===$Array&&isArrayIteratorMethod(p))for(a=lengthOfArrayLike$2(t),s=r?new this(a):$Array(a);a>_;_++)d=o?i(t[_],_):t[_],createProperty$1(s,_,d);else for(u=(l=getIterator$3(t,p)).next,s=r?new this:[];!(c=call$d(u,l)).done;_++)d=o?callWithSafeIterationClosing(l,i,[c.value,_],!0):c.value,createProperty$1(s,_,d);return s.length=_,s},$$G=_export,from$8=arrayFrom$1,checkCorrectnessOfIteration=checkCorrectnessOfIteration$2,INCORRECT_ITERATION=!checkCorrectnessOfIteration((function(e){Array.from(e)}));$$G({target:"Array",stat:!0,forced:INCORRECT_ITERATION},{from:from$8});var path$d=path$v,from$7=path$d.Array.from,parent$1d=from$7,from$6=parent$1d,parent$1c=from$6,from$5=parent$1c,parent$1b=from$5,from$4=parent$1b,from$3=from$4,from$2=from$3;function _iterableToArray(e){if(void 0!==symbol&&null!=getIteratorMethod$2(e)||null!=e["@@iterator"])return from$2(e)}function _unsupportedIterableToArray(e,t){var r;if(e){if("string"==typeof e)return _arrayLikeToArray(e,t);var n=slice$1(r=Object.prototype.toString.call(e)).call(r,8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?from$2(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?_arrayLikeToArray(e,t):void 0}}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 _toConsumableArray(e){return _arrayWithoutHoles(e)||_iterableToArray(e)||_unsupportedIterableToArray(e)||_nonIterableSpread()}var global$5=global$s,fails$5=fails$z,uncurryThis$b=functionUncurryThis,toString$7=toString$h,trim$7=stringTrim.trim,whitespaces$1=whitespaces$4,charAt$2=uncurryThis$b("".charAt),$parseFloat$1=global$5.parseFloat,Symbol$3=global$5.Symbol,ITERATOR$2=Symbol$3&&Symbol$3.iterator,FORCED$2=1/$parseFloat$1(whitespaces$1+"-0")!=-1/0||ITERATOR$2&&!fails$5((function(){$parseFloat$1(Object(ITERATOR$2))})),numberParseFloat=FORCED$2?function(e){var t=trim$7(toString$7(e)),r=$parseFloat$1(t);return 0===r&&"-"==charAt$2(t,0)?-0:r}:$parseFloat$1,$$F=_export,$parseFloat=numberParseFloat;$$F({global:!0,forced:parseFloat!=numberParseFloat},{parseFloat:numberParseFloat});var path$c=path$v,_parseFloat$5=path$c.parseFloat,parent$1a=_parseFloat$5,_parseFloat$4=parent$1a,parent$19=_parseFloat$4,_parseFloat$3=parent$19,parent$18=_parseFloat$3,_parseFloat$2=parent$18,_parseFloat$1=_parseFloat$2,_parseFloat=_parseFloat$1;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(stringify$1(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(stringify$1(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)&&defineProperty$a(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=slice$1(Array.prototype).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,assign$2({},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 map2)}}}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){var n;r.track&&includes4(n=e.getTracks()).call(n,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===keys$8(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,r=t.apply(this,arguments);"encodings"in r||(r.encodings=concat$2(e=[]).call(e,this.sendEncodings||[{}]));return r})}}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,n=this;this._localStreams||(this._localStreams=[]),includes4(r=this._localStreams).call(r,e)||this._localStreams.push(e),e.getAudioTracks().forEach((function(r){return t.call(n,r,e)})),e.getVideoTracks().forEach((function(r){return t.call(n,r,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){var t;r._localStreams?includes4(t=r._localStreams).call(t,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,r,n=this;this._localStreams||(this._localStreams=[]);var i=indexOf2(t=this._localStreams).call(t,e);if(-1!==i){splice$3(r=this._localStreams).call(r,i,1);var o=e.getTracks();this.getSenders().forEach((function(e){includes4(o).call(o,e.track)&&n.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))){defineProperty$a(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){var r;if(t._remoteStreams||(t._remoteStreams=[]),!includes4(r=t._remoteStreams).call(r,e)){t._remoteStreams.push(e);var n=new Event("addstream");n.stream=e,t.dispatchEvent(n)}}))})}});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){var r;if(e._remoteStreams||(e._remoteStreams=[]),!(indexOf2(r=e._remoteStreams).call(r,t)>=0)){e._remoteStreams.push(t);var n=new Event("addstream");n.stream=t,e.dispatchEvent(n)}}))}),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?assign$2({},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(stringify$1(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&&defineProperty$a(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)&&defineProperty$a(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){var r,n;void 0!==e.offerToReceiveAudio&&(e.offerToReceiveAudio=!!e.offerToReceiveAudio);var i=find$2(r=this.getTransceivers()).call(r,(function(e){return"audio"===e.receiver.track.kind}));!1===e.offerToReceiveAudio&&i?"sendrecv"===i.direction?i.setDirection?i.setDirection("sendonly"):i.direction="sendonly":"recvonly"===i.direction&&(i.setDirection?i.setDirection("inactive"):i.direction="inactive"):!0!==e.offerToReceiveAudio||i||this.addTransceiver("audio",{direction:"recvonly"}),void 0!==e.offerToReceiveVideo&&(e.offerToReceiveVideo=!!e.offerToReceiveVideo);var o=find$2(n=this.getTransceivers()).call(n,(function(e){return"video"===e.receiver.track.kind}));!1===e.offerToReceiveVideo&&o?"sendrecv"===o.direction?o.setDirection?o.setDirection("sendonly"):o.direction="sendonly":"recvonly"===o.direction&&(o.setDirection?o.setDirection("inactive"):o.direction="inactive"):!0!==e.offerToReceiveVideo||o||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"})),PROPER_FUNCTION_NAME=functionName.PROPER,fails$4=fails$z,whitespaces=whitespaces$4,non="​…᠎",stringTrimForced=function(e){return fails$4((function(){return!!whitespaces[e]()||non[e]()!==non||PROPER_FUNCTION_NAME&&whitespaces[e].name!==e}))},$$E=_export,$trim=stringTrim.trim,forcedStringTrimMethod=stringTrimForced;$$E({target:"String",proto:!0,forced:forcedStringTrimMethod("trim")},{trim:function(){return $trim(this)}});var entryVirtual$8=entryVirtual$m,trim$6=entryVirtual$8("String").trim,isPrototypeOf$a=objectIsPrototypeOf,method$8=trim$6,StringPrototype$2=String.prototype,trim$5=function(e){var t=e.trim;return"string"==typeof e||e===StringPrototype$2||isPrototypeOf$a(StringPrototype$2,e)&&t===StringPrototype$2.trim?method$8:t},parent$17=trim$5,trim$4=parent$17,parent$16=trim$4,trim$3=parent$16,parent$15=trim$3,trim$2=parent$15,trim$1=trim$2,trim2=trim$1,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){var t;return map$6(t=trim2(e).call(e).split("\n")).call(t,(function(e){return trim2(e).call(e)}))},t.splitSections=function(e){var t=e.split("\nm=");return map$6(t).call(t,(function(e,t){var r;return trim2(r=t>0?"m="+e:e).call(r)+"\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){var n;return filter3(n=t.splitLines(e)).call(n,(function(e){return 0===indexOf2(e).call(e,r)}))},t.parseCandidate=function(e){for(var t,r={foundation:(t=0===indexOf2(e).call(e,"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$6(t[3],10),ip:t[4],address:t[4],port:_parseInt$6(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$6(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$6(t.shift(),10)};return t=t[0].split("/"),r.name=t[0],r.clockRate=_parseInt$6(t[1],10),r.channels=3===t.length?_parseInt$6(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,r=e.substr(9).split(" ");return{id:_parseInt$6(r[0],10),direction:indexOf2(t=r[0]).call(t,"/")>0?r[0].split("/")[1]:"sendrecv",uri:r[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(indexOf2(e).call(e," ")+1).split(";"),i=0;i<n.length;i++){var o,a;t=trim2(o=n[i]).call(o).split("="),r[trim2(a=t[0]).call(a)]=t[1]}return r},t.writeFmtp=function(e){var t="",r=e.payloadType;if(void 0!==e.preferredPayloadType&&(r=e.preferredPayloadType),e.parameters&&keys$8(e.parameters).length){var n=[];keys$8(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(indexOf2(e).call(e," ")+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=indexOf2(e).call(e," "),r={ssrc:_parseInt$6(e.substr(7,t-7),10)},n=indexOf2(e).call(e,":",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:map$6(t).call(t,(function(e){return _parseInt$6(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){var n=t.matchPrefix(e+r,"a=fingerprint:");return{role:"auto",fingerprints:map$6(n).call(n,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$6(t[0],10),cryptoSuite:t[1],keyParams:t[2],sessionParams:slice$1(t).call(t,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!==indexOf2(e).call(e,"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){var n=t.matchPrefix(e+r,"a=crypto:");return map$6(n).call(n,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,c=t.parseRtpMap(a),l=t.matchPrefix(e,"a=fmtp:"+o+" ");switch(c.parameters=l.length?t.parseFmtp(l[0]):{},c.rtcpFeedback=map$6(s=t.matchPrefix(e,"a=rtcp-fb:"+o+" ")).call(s,t.parseRtcpFb),r.codecs.push(c),c.name.toUpperCase()){case"RED":case"ULPFEC":r.fecMechanisms.push(c.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,i="";i+="m="+e+" ",i+=r.codecs.length>0?"9":"0",i+=" UDP/TLS/RTP/SAVPF ",i+=map$6(n=r.codecs).call(n,(function(e){return void 0!==e.preferredPayloadType?e.preferredPayloadType:e.payloadType})).join(" ")+"\r\n",i+="c=IN IP4 0.0.0.0\r\n",i+="a=rtcp:9 IN IP4 0.0.0.0\r\n",r.codecs.forEach((function(e){i+=t.writeRtpMap(e),i+=t.writeFmtp(e),i+=t.writeRtcpFb(e)}));var o=0;return r.codecs.forEach((function(e){e.maxptime>o&&(o=e.maxptime)})),o>0&&(i+="a=maxptime:"+o+"\r\n"),r.headerExtensions&&r.headerExtensions.forEach((function(e){i+=t.writeExtmap(e)})),i},t.parseRtpEncodingParameters=function(e){var r,n,i,o,a,s,c=[],l=t.parseRtpParameters(e),u=-1!==indexOf2(r=l.fecMechanisms).call(r,"RED"),d=-1!==indexOf2(n=l.fecMechanisms).call(n,"ULPFEC"),p=filter3(i=map$6(o=t.matchPrefix(e,"a=ssrc:")).call(o,(function(e){return t.parseSsrcMedia(e)}))).call(i,(function(e){return"cname"===e.attribute})),_=p.length>0&&p[0].ssrc,h=map$6(a=t.matchPrefix(e,"a=ssrc-group:FID")).call(a,(function(e){var t=e.substr(17).split(" ");return map$6(t).call(t,(function(e){return _parseInt$6(e,10)}))}));h.length>0&&h[0].length>1&&h[0][0]===_&&(s=h[0][1]),l.codecs.forEach((function(e){if("RTX"===e.name.toUpperCase()&&e.parameters.apt){var t={ssrc:_,codecPayloadType:_parseInt$6(e.parameters.apt,10)};_&&s&&(t.rtx={ssrc:s}),c.push(t),u&&((t=JSON.parse(stringify$1(t))).fec={ssrc:_,mechanism:d?"red+ulpfec":"red"},c.push(t))}})),0===c.length&&_&&c.push({ssrc:_});var f,m,v=t.matchPrefix(e,"b=");v.length&&(v=0===indexOf2(f=v[0]).call(f,"b=TIAS:")?_parseInt$6(v[0].substr(7),10):0===indexOf2(m=v[0]).call(m,"b=AS:")?1e3*_parseInt$6(v[0].substr(5),10)*.95-16e3:void 0,c.forEach((function(e){e.maxBitrate=v})));return c},t.parseRtcpParameters=function(e){var r,n,i={},o=filter3(r=map$6(n=t.matchPrefix(e,"a=ssrc:")).call(n,(function(e){return t.parseSsrcMedia(e)}))).call(r,(function(e){return"cname"===e.attribute}))[0];o&&(i.cname=o.value,i.ssrc=o.ssrc);var a=t.matchPrefix(e,"a=rtcp-rsize");i.reducedSize=a.length>0,i.compound=0===a.length;var s=t.matchPrefix(e,"a=rtcp-mux");return i.mux=s.length>0,i},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,i,o=t.matchPrefix(e,"a=msid:");if(1===o.length)return{stream:(i=o[0].substr(7).split(" "))[0],track:i[1]};var a=filter3(r=map$6(n=t.matchPrefix(e,"a=ssrc:")).call(n,(function(e){return t.parseSsrcMedia(e)}))).call(r,(function(e){return"msid"===e.attribute}));return a.length>0?{stream:(i=a[0].value.split(" "))[0],track:i[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$6(i[0].substr(19),10)),isNaN(r)&&(r=65536);var o=t.matchPrefix(e,"a=sctp-port:");if(o.length>0)return{port:_parseInt$6(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$6(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$6(r[1],10),protocol:r[2],fmt:slice$1(r).call(r,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$6(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){var r;if("object"===_typeof(e)&&e.candidate&&0===indexOf2(r=e.candidate).call(r,"a=")&&((e=JSON.parse(stringify$1(e))).candidate=e.candidate.substr(2)),e.candidate&&e.candidate.length){var n=new t(e),i=SDPUtils.parseCandidate(e.candidate),o=assign$2(n,i);return o.toJSON=function(){return{candidate:o.candidate,sdpMid:o.sdpMid,sdpMLineIndex:o.sdpMLineIndex,usernameFragment:o.usernameFragment}},o}return new t(e)},e.RTCIceCandidate.prototype=t.prototype,wrapPeerConnectionEvent(e,"icecandidate",(function(t){return t.candidate&&defineProperty$a(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||defineProperty$a(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,r=SDPUtils.parseMLine(e);return r&&"application"===r.kind&&-1!==indexOf2(t=r.protocol).call(t,"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$6(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$6(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&&defineProperty$a(this,"sctp",{get:function(){return void 0===this._sctp?null:this._sctp},enumerable:!0,configurable:!0})}if(r(arguments[0])){var c,l=n(arguments[0]),u=i(l),d=o(arguments[0],l);c=0===u&&0===d?Number.POSITIVE_INFINITY:0===u||0===d?Math.max(u,d):Math.min(u,d);var p={};defineProperty$a(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;defineProperty$a(t,"connectionState",{get:function(){return{completed:"connected",checking:"connecting"}[this.iceConnectionState]||this.iceConnectionState},enumerable:!0,configurable:!0}),defineProperty$a(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){var n;if(t&&t.sdp&&-1!==indexOf2(n=t.sdp).call(n,"\na=extmap-allow-mixed")){var i,o=filter3(i=t.sdp.split("\n")).call(i,(function(e){return"a=extmap-allow-mixed"!==trim2(e).call(e)})).join("\n");e.RTCSessionDescription&&t instanceof e.RTCSessionDescription?arguments[0]=new e.RTCSessionDescription({type:t.type,sdp:o}):t.sdp=o}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$1,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}if(adapterFactory({window:"undefined"==typeof window?void 0:window}),"undefined"!=typeof MediaStreamTrack){var originGetSettings=MediaStreamTrack.prototype.getSettings;MediaStreamTrack.prototype.getSettings=function(){var e=originGetSettings.call(this);return e.width&&(e.width=Math.floor(e.width)),e.height&&(e.height=Math.floor(e.height)),e.frameRate&&(e.frameRate=Math.floor(e.frameRate)),e}}function _createForOfIteratorHelper(e,t){var r=void 0!==symbol&&getIteratorMethod$2(e)||e["@@iterator"];if(!r){if(isArray$2(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}}}}function _arrayWithHoles(e){if(isArray$2(e))return e}function _iterableToArrayLimit(e,t){var r=null==e?null:void 0!==symbol&&getIteratorMethod$2(e)||e["@@iterator"];if(null!=r){var n,i,o,a,s=[],c=!0,l=!1;try{if(o=(r=r.call(e)).next,0===t){if(Object(r)!==r)return;c=!1}else for(;!(c=(n=o.call(r)).done)&&(s.push(n.value),s.length!==t);c=!0);}catch(e){l=!0,i=e}finally{try{if(!c&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(l)throw i}}return s}}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 _slicedToArray(e,t){return _arrayWithHoles(e)||_iterableToArrayLimit(e,t)||_unsupportedIterableToArray(e,t)||_nonIterableRest()}var path$b=path$v,getOwnPropertySymbols$5=path$b.Object.getOwnPropertySymbols,parent$14=getOwnPropertySymbols$5,getOwnPropertySymbols$4=parent$14,parent$13=getOwnPropertySymbols$4,getOwnPropertySymbols$3=parent$13,parent$12=getOwnPropertySymbols$3,getOwnPropertySymbols$2=parent$12,getOwnPropertySymbols$1=getOwnPropertySymbols$2,getOwnPropertySymbols2=getOwnPropertySymbols$1,$$D=_export,DESCRIPTORS$4=descriptors,ownKeys$1=ownKeys$3,toIndexedObject$1=toIndexedObject$b,getOwnPropertyDescriptorModule$2=objectGetOwnPropertyDescriptor,createProperty=createProperty$6;$$D({target:"Object",stat:!0,sham:!DESCRIPTORS$4},{getOwnPropertyDescriptors:function(e){for(var t,r,n=toIndexedObject$1(e),i=getOwnPropertyDescriptorModule$2.f,o=ownKeys$1(n),a={},s=0;o.length>s;)void 0!==(r=i(n,t=o[s++]))&&createProperty(a,t,r);return a}});var path$a=path$v,getOwnPropertyDescriptors$5=path$a.Object.getOwnPropertyDescriptors,parent$11=getOwnPropertyDescriptors$5,getOwnPropertyDescriptors$4=parent$11,parent$10=getOwnPropertyDescriptors$4,getOwnPropertyDescriptors$3=parent$10,parent$$=getOwnPropertyDescriptors$3,getOwnPropertyDescriptors$2=parent$$,getOwnPropertyDescriptors$1=getOwnPropertyDescriptors$2,getOwnPropertyDescriptors2=getOwnPropertyDescriptors$1,defineProperties$7={exports:{}},$$C=_export,DESCRIPTORS$3=descriptors,defineProperties$6=objectDefineProperties.f;$$C({target:"Object",stat:!0,forced:Object.defineProperties!==defineProperties$6,sham:!DESCRIPTORS$3},{defineProperties:defineProperties$6});var path$9=path$v,Object$1=path$9.Object,defineProperties$5=defineProperties$7.exports=function(e,t){return Object$1.defineProperties(e,t)};Object$1.defineProperties.sham&&(defineProperties$5.sham=!0);var parent$_=defineProperties$7.exports,defineProperties$4=parent$_,parent$Z=defineProperties$4,defineProperties$3=parent$Z,parent$Y=defineProperties$3,defineProperties$2=parent$Y,defineProperties$1=defineProperties$2,defineProperties4=defineProperties$1;function ownKeys2(e,t){var r=keys$8(e);if(getOwnPropertySymbols2){var n=getOwnPropertySymbols2(e);t&&(n=filter3(n).call(n,(function(t){return getOwnPropertyDescriptor$1(e,t).enumerable}))),r.push.apply(r,n)}return r}function _objectSpread2(e){for(var t=1;t<arguments.length;t++){var r,n,i=null!=arguments[t]?arguments[t]:{};t%2?forEach$1(r=ownKeys2(Object(i),!0)).call(r,(function(t){_defineProperty(e,t,i[t])})):getOwnPropertyDescriptors2?defineProperties4(e,getOwnPropertyDescriptors2(i)):forEach$1(n=ownKeys2(Object(i))).call(n,(function(t){defineProperty$a(e,t,getOwnPropertyDescriptor$1(i,t))}))}return e}function _assertThisInitialized(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}var hasOwn$7=hasOwnProperty_1,isDataDescriptor$2=function(e){return void 0!==e&&(hasOwn$7(e,"value")||hasOwn$7(e,"writable"))},$$B=_export,call$c=functionCall,isObject$7=isObject$q,anObject$k=anObject$M,isDataDescriptor$1=isDataDescriptor$2,getOwnPropertyDescriptorModule$1=objectGetOwnPropertyDescriptor,getPrototypeOf$1=objectGetPrototypeOf;function get$6(e,t){var r,n,i=arguments.length<3?e:arguments[2];return anObject$k(e)===i?e[t]:(r=getOwnPropertyDescriptorModule$1.f(e,t))?isDataDescriptor$1(r)?r.value:void 0===r.get?void 0:call$c(r.get,i):isObject$7(n=getPrototypeOf$1(e))?get$6(n,t,i):void 0}$$B({target:"Reflect",stat:!0},{get:get$6});var path$8=path$v,get$5=path$8.Reflect.get,parent$X=get$5,get$4=parent$X,parent$W=get$4,get$3=parent$W,parent$V=get$3,get$2=parent$V,get$1=get$2,get=get$1,uncurryThis$a=functionUncurryThis,aCallable$c=aCallable$z,isObject$6=isObject$q,hasOwn$6=hasOwnProperty_1,arraySlice$2=arraySlice$6,NATIVE_BIND=functionBindNative,$Function=Function,concat2=uncurryThis$a([].concat),join$3=uncurryThis$a([].join),factories={},construct$6=function(e,t,r){if(!hasOwn$6(factories,t)){for(var n=[],i=0;i<t;i++)n[i]="a["+i+"]";factories[t]=$Function("C,a","return new C("+join$3(n,",")+")")}return factories[t](e,r)},functionBind=NATIVE_BIND?$Function.bind:function(e){var t=aCallable$c(this),r=t.prototype,n=arraySlice$2(arguments,1),i=function(){var r=concat2(n,arraySlice$2(arguments));return this instanceof i?construct$6(t,r.length,r):t.apply(e,r)};return isObject$6(r)&&(i.prototype=r),i},$$A=_export,bind$f=functionBind;$$A({target:"Function",proto:!0,forced:Function.bind!==bind$f},{bind:bind$f});var entryVirtual$7=entryVirtual$m,bind$e=entryVirtual$7("Function").bind,isPrototypeOf$9=objectIsPrototypeOf,method$7=bind$e,FunctionPrototype=Function.prototype,bind$d=function(e){var t=e.bind;return e===FunctionPrototype||isPrototypeOf$9(FunctionPrototype,e)&&t===FunctionPrototype.bind?method$7:t},parent$U=bind$d,bind$c=parent$U,parent$T=bind$c,bind$b=parent$T,parent$S=bind$b,bind$a=parent$S,bind$9=bind$a,bind$8=bind$9;function _getPrototypeOf(e){var t;return(_getPrototypeOf=setPrototypeOf$1?bind$8(t=getPrototypeOf$3).call(t):function(e){return e.__proto__||getPrototypeOf$3(e)})(e)}function _superPropBase(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=_getPrototypeOf(e)););return e}function _get(){var e;"undefined"!=typeof Reflect&&get?_get=bind$8(e=get).call(e):_get=function(e,t,r){var n=_superPropBase(e,t);if(n){var i=getOwnPropertyDescriptor$1(n,t);return i.get?i.get.call(arguments.length<3?e:r):i.value}};return _get.apply(this,arguments)}function _setPrototypeOf(e,t){var r;return(_setPrototypeOf=setPrototypeOf$1?bind$8(r=setPrototypeOf$1).call(r):function(e,t){return e.__proto__=t,e})(e,t)}function _inherits(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=create$4(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),defineProperty$a(e,"prototype",{writable:!1}),t&&_setPrototypeOf(e,t)}var $$z=_export,getBuiltIn$7=getBuiltIn$o,apply$1=functionApply,bind$7=functionBind,aConstructor=aConstructor$3,anObject$j=anObject$M,isObject$5=isObject$q,create$1=objectCreate$1,fails$3=fails$z,nativeConstruct=getBuiltIn$7("Reflect","construct"),ObjectPrototype=Object.prototype,push$6=[].push,NEW_TARGET_BUG=fails$3((function(){function e(){}return!(nativeConstruct((function(){}),[],e)instanceof e)})),ARGS_BUG=!fails$3((function(){nativeConstruct((function(){}))})),FORCED$1=NEW_TARGET_BUG||ARGS_BUG;$$z({target:"Reflect",stat:!0,forced:FORCED$1,sham:FORCED$1},{construct:function(e,t){aConstructor(e),anObject$j(t);var r=arguments.length<3?e:aConstructor(arguments[2]);if(ARGS_BUG&&!NEW_TARGET_BUG)return nativeConstruct(e,t,r);if(e==r){switch(t.length){case 0:return new e;case 1:return new e(t[0]);case 2:return new e(t[0],t[1]);case 3:return new e(t[0],t[1],t[2]);case 4:return new e(t[0],t[1],t[2],t[3])}var n=[null];return apply$1(push$6,n,t),new(apply$1(bind$7,e,n))}var i=r.prototype,o=create$1(isObject$5(i)?i:ObjectPrototype),a=apply$1(e,o,t);return isObject$5(a)?a:o}});var path$7=path$v,construct$5=path$7.Reflect.construct,parent$R=construct$5,construct$4=parent$R,parent$Q=construct$4,construct$3=parent$Q,parent$P=construct$3,construct$2=parent$P,construct$1=construct$2,construct2=construct$1;function _isNativeReflectConstruct(){if("undefined"==typeof Reflect||!construct2)return!1;if(construct2.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(construct2(Boolean,[],(function(){}))),!0}catch(e){return!1}}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=construct2(n,arguments,i)}else r=n.apply(this,arguments);return _possibleConstructorReturn(this,r)}}var entryVirtual$6=entryVirtual$m,values$7=entryVirtual$6("Array").values,parent$O=values$7,values$6=parent$O,classof$2=classof$d,hasOwn$5=hasOwnProperty_1,isPrototypeOf$8=objectIsPrototypeOf,method$6=values$6,ArrayPrototype$4=Array.prototype,DOMIterables$1={DOMTokenList:!0,NodeList:!0},values$5=function(e){var t=e.values;return e===ArrayPrototype$4||isPrototypeOf$8(ArrayPrototype$4,e)&&t===ArrayPrototype$4.values||hasOwn$5(DOMIterables$1,classof$2(e))?method$6:t},parent$N=values$5,values$4=parent$N,parent$M=values$4,values$3=parent$M,values$2=values$3,values$1=values$2,arraySlice$1=arraySliceSimple,floor$2=Math.floor,mergeSort=function(e,t){var r=e.length,n=floor$2(r/2);return r<8?insertionSort(e,t):merge2(e,mergeSort(arraySlice$1(e,0,n),t),mergeSort(arraySlice$1(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},merge2=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],$$y=_export,uncurryThis$9=functionUncurryThis,aCallable$b=aCallable$z,toObject$1=toObject$d,lengthOfArrayLike$1=lengthOfArrayLike$b,deletePropertyOrThrow=deletePropertyOrThrow$2,toString$6=toString$h,fails$2=fails$z,internalSort=arraySort$1,arrayMethodIsStrict=arrayMethodIsStrict$4,FF=engineFfVersion,IE_OR_EDGE=engineIsIeOrEdge,V8=engineV8Version,WEBKIT=engineWebkitVersion,test=[],nativeSort=uncurryThis$9(test.sort),push$5=uncurryThis$9(test.push),FAILS_ON_UNDEFINED=fails$2((function(){test.sort(void 0)})),FAILS_ON_NULL=fails$2((function(){test.sort(null)})),STRICT_METHOD=arrayMethodIsStrict("sort"),STABLE_SORT=!fails$2((function(){if(V8)return V8<70;if(!(FF&&FF>3)){if(IE_OR_EDGE)return!0;if(WEBKIT)return WEBKIT<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=FAILS_ON_UNDEFINED||!FAILS_ON_NULL||!STRICT_METHOD||!STABLE_SORT,getSortCompare=function(e){return function(t,r){return void 0===r?-1:void 0===t?1:void 0!==e?+e(t,r)||0:toString$6(t)>toString$6(r)?1:-1}};$$y({target:"Array",proto:!0,forced:FORCED},{sort:function(e){void 0!==e&&aCallable$b(e);var t=toObject$1(this);if(STABLE_SORT)return void 0===e?nativeSort(t):nativeSort(t,e);var r,n,i=[],o=lengthOfArrayLike$1(t);for(n=0;n<o;n++)n in t&&push$5(i,t[n]);for(internalSort(i,getSortCompare(e)),r=lengthOfArrayLike$1(i),n=0;n<r;)t[n]=i[n++];for(;n<o;)deletePropertyOrThrow(t,n++);return t}});var entryVirtual$5=entryVirtual$m,sort$6=entryVirtual$5("Array").sort,isPrototypeOf$7=objectIsPrototypeOf,method$5=sort$6,ArrayPrototype$3=Array.prototype,sort$5=function(e){var t=e.sort;return e===ArrayPrototype$3||isPrototypeOf$7(ArrayPrototype$3,e)&&t===ArrayPrototype$3.sort?method$5:t},parent$L=sort$5,sort$4=parent$L,parent$K=sort$4,sort$3=parent$K,parent$J=sort$3,sort$2=parent$J,sort$1=sort$2,sort2=sort$1,$$x=_export,$findIndex=arrayIteration.findIndex,FIND_INDEX="findIndex",SKIPS_HOLES=!0;FIND_INDEX in[]&&Array(1)[FIND_INDEX]((function(){SKIPS_HOLES=!1})),$$x({target:"Array",proto:!0,forced:SKIPS_HOLES},{findIndex:function(e){return $findIndex(this,e,arguments.length>1?arguments[1]:void 0)}});var entryVirtual$4=entryVirtual$m,findIndex$7=entryVirtual$4("Array").findIndex,isPrototypeOf$6=objectIsPrototypeOf,method$4=findIndex$7,ArrayPrototype$2=Array.prototype,findIndex$6=function(e){var t=e.findIndex;return e===ArrayPrototype$2||isPrototypeOf$6(ArrayPrototype$2,e)&&t===ArrayPrototype$2.findIndex?method$4:t},parent$I=findIndex$6,findIndex$5=parent$I,parent$H=findIndex$5,findIndex$4=parent$H,parent$G=findIndex$4,findIndex$3=parent$G,findIndex$2=findIndex$3,findIndex$1=findIndex$2,$$w=_export,uncurryThis$8=functionUncurryThis;objectGetOwnPropertyDescriptor.f;var toLength$1=toLength$4,toString$5=toString$h,notARegExp=notARegexp,requireObjectCoercible$2=requireObjectCoercible$9,correctIsRegExpLogic=correctIsRegexpLogic,nativeStartsWith=uncurryThis$8("".startsWith),stringSlice$3=uncurryThis$8("".slice),min=Math.min,CORRECT_IS_REGEXP_LOGIC=correctIsRegExpLogic("startsWith");$$w({target:"String",proto:!0,forced:!CORRECT_IS_REGEXP_LOGIC},{startsWith:function(e){var t=toString$5(requireObjectCoercible$2(this));notARegExp(e);var r=toLength$1(min(arguments.length>1?arguments[1]:void 0,t.length)),n=toString$5(e);return nativeStartsWith?nativeStartsWith(t,n,r):stringSlice$3(t,r,r+n.length)===n}});var entryVirtual$3=entryVirtual$m,startsWith$6=entryVirtual$3("String").startsWith,isPrototypeOf$5=objectIsPrototypeOf,method$3=startsWith$6,StringPrototype$1=String.prototype,startsWith$5=function(e){var t=e.startsWith;return"string"==typeof e||e===StringPrototype$1||isPrototypeOf$5(StringPrototype$1,e)&&t===StringPrototype$1.startsWith?method$3:t},parent$F=startsWith$5,startsWith$4=parent$F,parent$E=startsWith$4,startsWith$3=parent$E,parent$D=startsWith$3,startsWith$2=parent$D,startsWith$1=startsWith$2,startsWith2=startsWith$1,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.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_EXCEED_QPS="USER_MESSAGE_EXCEED_QPS",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.SUBTITLE_ALREADY_ON="SUBTITLE_ALREADY_ON",e.SUBTITLE_NOT_TURNED_ON="SUBTITLE_NOT_TURNED_ON",e.SUBTITLE_ERR_POSTPROCESS="SUBTITLE_ERR_POSTPROCESS",e.SUBTITLE_ERR_CONNECTION_ERROR="SUBTITLE_ERR_CONNECTION_ERROR",e.SUBTITLE_ERR_PROCESS_ERROR="SUBTITLE_ERR_PROCESS_ERROR",e.SUBTITLE_ERR_UNKNOWN="SUBTITLE_ERR_UNKNOWN",e.ROOM_FORBIDDEN="ROOM_FORBIDDEN",e.USER_FORBIDDEN="USER_FORBIDDEN",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||{}),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||{}),AAC_PROFILE=function(e){return e.LC="LC",e.HEv1="HEv1",e.HEv2="HEv2",e}(AAC_PROFILE||{}),TRANSCODING_VIDEO_CODEC=function(e){return e.H264="H264",e.H265="H265",e}(TRANSCODING_VIDEO_CODEC||{}),SUBTITLE_MODE=function(e){return e[e.ASR_ONLY=0]="ASR_ONLY",e[e.ASR_AND_TRANSLATION=1]="ASR_AND_TRANSLATION",e}(SUBTITLE_MODE||{}),SubtitleEventType=function(e){return e[e.STARTED=0]="STARTED",e[e.STOPPED=1]="STOPPED",e[e.ERROR=2]="ERROR",e}(SubtitleEventType||{}),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$2=descriptors,uncurryThis$7=functionUncurryThis,objectKeys=objectKeys$4,toIndexedObject=toIndexedObject$b,$propertyIsEnumerable=objectPropertyIsEnumerable.f,propertyIsEnumerable$2=uncurryThis$7($propertyIsEnumerable),push$4=uncurryThis$7([].push),createMethod$1=function(e){return function(t){for(var r,n=toIndexedObject(t),i=objectKeys(n),o=i.length,a=0,s=[];o>a;)r=i[a++],DESCRIPTORS$2&&!propertyIsEnumerable$2(n,r)||push$4(s,e?[r,n[r]]:n[r]);return s}},objectToArray={entries:createMethod$1(!0),values:createMethod$1(!1)},$$v=_export,$entries=objectToArray.entries;$$v({target:"Object",stat:!0},{entries:function(e){return $entries(e)}});var path$6=path$v,entries$5=path$6.Object.entries,parent$C=entries$5,entries$4=parent$C,parent$B=entries$4,entries$3=parent$B,parent$A=entries$3,entries$2=parent$A,entries$1=entries$2,entries2=entries$1,toIntegerOrInfinity=toIntegerOrInfinity$5,toString$4=toString$h,requireObjectCoercible$1=requireObjectCoercible$9,$RangeError$1=RangeError,stringRepeat=function(e){var t=toString$4(requireObjectCoercible$1(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$6=functionUncurryThis,toLength=toLength$4,toString$3=toString$h,$repeat=stringRepeat,requireObjectCoercible=requireObjectCoercible$9,repeat2=uncurryThis$6($repeat),stringSlice$2=uncurryThis$6("".slice),ceil=Math.ceil,createMethod=function(e){return function(t,r,n){var i,o,a=toString$3(requireObjectCoercible(t)),s=toLength(r),c=a.length,l=void 0===n?" ":toString$3(n);return s<=c||""==l?a:((o=repeat2(l,ceil((i=s-c)/l.length))).length>i&&(o=stringSlice$2(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),$$u=_export,$padEnd=stringPad.end,WEBKIT_BUG=stringPadWebkitBug;$$u({target:"String",proto:!0,forced:WEBKIT_BUG},{padEnd:function(e){return $padEnd(this,e,arguments.length>1?arguments[1]:void 0)}});var entryVirtual$2=entryVirtual$m,padEnd$6=entryVirtual$2("String").padEnd,isPrototypeOf$4=objectIsPrototypeOf,method$2=padEnd$6,StringPrototype=String.prototype,padEnd$5=function(e){var t=e.padEnd;return"string"==typeof e||e===StringPrototype||isPrototypeOf$4(StringPrototype,e)&&t===StringPrototype.padEnd?method$2:t},parent$z=padEnd$5,padEnd$4=parent$z,parent$y=padEnd$4,padEnd$3=parent$y,parent$x=padEnd$3,padEnd$2=parent$x,padEnd$1=padEnd$2,padEnd2=padEnd$1,$$t=_export,parseInt$2=numberParseInt;$$t({target:"Number",stat:!0,forced:Number.parseInt!=parseInt$2},{parseInt:parseInt$2});var path$5=path$v,_parseInt$5=path$5.Number.parseInt,parent$w=_parseInt$5,_parseInt$4=parent$w,parent$v=_parseInt$4,_parseInt$3=parent$v,parent$u=_parseInt$3,_parseInt$2=parent$u,_parseInt$1=_parseInt$2,_parseInt=_parseInt$1,log=Math.log,LOG10E=Math.LOG10E,mathLog10=Math.log10||function(e){return log(e)*LOG10E},$$s=_export,log10$6=mathLog10;$$s({target:"Math",stat:!0},{log10:log10$6});var getRandomValues,path$4=path$v,log10$5=path$4.Math.log10,parent$t=log10$5,log10$4=parent$t,parent$s=log10$4,log10$3=parent$s,parent$r=log10$3,log10$2=parent$r,log10$1=log10$2,log102=log10$1,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&&REGEX.test(e)}for(var byteToHex=[],i=0;i<256;++i)byteToHex.push((i+256).toString(16).substr(1));function stringify2(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 stringify2(n)}var isSSR$1=function(){return"undefined"==typeof window},genUuid$1=function(){return v4()},promiseAny$1=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)}))}))}))},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=slice$1(Array.prototype).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$2([]).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,l=t.max_code,u=t.stat_desc.static_tree,d=t.stat_desc.has_stree,p=t.stat_desc.extra_bits,_=t.stat_desc.extra_base,h=t.stat_desc.max_length,f=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)>h&&(o=h,f++),c[2*n+1]=o,n>l||(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*(u[2*n+1]+a)));if(0!==f){do{for(o=h-1;0===e.bl_count[o];)o--;e.bl_count[o]--,e.bl_count[o+1]+=2,e.bl_count[h]--,f-=2}while(f>0);for(o=h;0!==o;o--)for(n=e.bl_count[o];0!==n;)(i=e.heap[--r])>l||(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,l=-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]=l=r,e.depth[r]=0):o[2*r+1]=0;for(;e.heap_len<2;)o[2*(i=e.heap[++e.heap_len]=l<2?++l:0)]=1,e.depth[i]=0,e.opt_len--,s&&(e.static_len-=a[2*i+1]);for(t.max_code=l,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,l,e.bl_count)}function scan_tree(e,t,r){var n,i,o=-1,a=t[1],s=0,c=7,l=4;for(0===a&&(c=138,l=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<l?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,l=3):i===a?(c=6,l=3):(c=7,l=4))}function send_tree(e,t,r){var n,i,o=-1,a=t[1],s=0,c=7,l=4;for(0===a&&(c=138,l=3),n=0;n<=r;n++)if(i=a,a=t[2*(n+1)+1],!(++s<c&&i===a)){if(s<l)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,l=3):i===a?(c=6,l=3):(c=7,l=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,l=e.window,u=e.w_mask,d=e.prev,p=e.strstart+MAX_MATCH,_=l[o+a-1],h=l[o+a];e.prev_length>=e.good_match&&(i>>=2),s>e.lookahead&&(s=e.lookahead);do{if(l[(r=t)+a]===h&&l[r+a-1]===_&&l[r]===l[o]&&l[++r]===l[o+1]){o+=2,r++;do{}while(l[++o]===l[++r]&&l[++o]===l[++r]&&l[++o]===l[++r]&&l[++o]===l[++r]&&l[++o]===l[++r]&&l[++o]===l[++r]&&l[++o]===l[++r]&&l[++o]===l[++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;_=l[o+a-1],h=l[o+a]}}}while((t=d[t&u])>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,l,u=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,u,0)),r.wrap=0,u>=r.w_size&&(0===o&&(zero(r.head),r.strstart=0,r.block_start=0,r.insert=0),l=new utils$5.Buf8(r.w_size),utils$5.arraySet(l,t,u-r.w_size,r.w_size,0),t=l,u=r.w_size),a=e.avail_in,s=e.next_in,c=e.input,e.avail_in=u,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={},anObject$i=anObject$M,regexpFlags=function(){var e=anObject$i(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},call$b=functionCall,hasOwn$4=hasOwnProperty_1,isPrototypeOf$3=objectIsPrototypeOf,regExpFlags=regexpFlags,RegExpPrototype$1=RegExp.prototype,regexpGetFlags=function(e){var t=e.flags;return void 0!==t||"flags"in RegExpPrototype$1||hasOwn$4(e,"flags")||!isPrototypeOf$3(RegExpPrototype$1,e)?t:call$b(regExpFlags,e)},getRegExpFlags=regexpGetFlags,flags$6=getRegExpFlags,isPrototypeOf$2=objectIsPrototypeOf,flags$5=flags$6,RegExpPrototype=RegExp.prototype,flags_1=function(e){return e===RegExpPrototype||isPrototypeOf$2(RegExpPrototype,e)?flags$5(e):e.flags},parent$q=flags_1,flags$4=parent$q,parent$p=flags$4,flags$3=parent$p,parent$o=flags$3,flags$2=parent$o,flags$1=flags$2,flags=flags$1,inflate$3={},BAD$1=30,TYPE$1=12,inffast=function(e,t){var r,n,i,o,a,s,c,l,u,d,p,_,h,f,m,v,g,y,S,T,$,E,b,I,R;r=e.state,n=e.next_in,I=e.input,i=n+(e.avail_in-5),o=e.next_out,R=e.output,a=o-(t-e.avail_out),s=o+(e.avail_out-257),c=r.dmax,l=r.wsize,u=r.whave,d=r.wnext,p=r.window,_=r.hold,h=r.bits,f=r.lencode,m=r.distcode,v=(1<<r.lenbits)-1,g=(1<<r.distbits)-1;e:do{h<15&&(_+=I[n++]<<h,h+=8,_+=I[n++]<<h,h+=8),y=f[_&v];t:for(;;){if(_>>>=S=y>>>24,h-=S,0===(S=y>>>16&255))R[o++]=65535&y;else{if(!(16&S)){if(0==(64&S)){y=f[(65535&y)+(_&(1<<S)-1)];continue t}if(32&S){r.mode=TYPE$1;break e}e.msg="invalid literal/length code",r.mode=BAD$1;break e}T=65535&y,(S&=15)&&(h<S&&(_+=I[n++]<<h,h+=8),T+=_&(1<<S)-1,_>>>=S,h-=S),h<15&&(_+=I[n++]<<h,h+=8,_+=I[n++]<<h,h+=8),y=m[_&g];r:for(;;){if(_>>>=S=y>>>24,h-=S,!(16&(S=y>>>16&255))){if(0==(64&S)){y=m[(65535&y)+(_&(1<<S)-1)];continue r}e.msg="invalid distance code",r.mode=BAD$1;break e}if($=65535&y,h<(S&=15)&&(_+=I[n++]<<h,(h+=8)<S&&(_+=I[n++]<<h,h+=8)),($+=_&(1<<S)-1)>c){e.msg="invalid distance too far back",r.mode=BAD$1;break e}if(_>>>=S,h-=S,$>(S=o-a)){if((S=$-S)>u&&r.sane){e.msg="invalid distance too far back",r.mode=BAD$1;break e}if(E=0,b=p,0===d){if(E+=l-S,S<T){T-=S;do{R[o++]=p[E++]}while(--S);E=o-$,b=R}}else if(d<S){if(E+=l+d-S,(S-=d)<T){T-=S;do{R[o++]=p[E++]}while(--S);if(E=0,d<T){T-=S=d;do{R[o++]=p[E++]}while(--S);E=o-$,b=R}}}else if(E+=d-S,S<T){T-=S;do{R[o++]=p[E++]}while(--S);E=o-$,b=R}for(;T>2;)R[o++]=b[E++],R[o++]=b[E++],R[o++]=b[E++],T-=3;T&&(R[o++]=b[E++],T>1&&(R[o++]=b[E++]))}else{E=o-$;do{R[o++]=R[E++],R[o++]=R[E++],R[o++]=R[E++],T-=3}while(T>2);T&&(R[o++]=R[E++],T>1&&(R[o++]=R[E++]))}break}}break}}while(n<i&&o<s);n-=T=h>>3,_&=(1<<(h-=T<<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=h},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,l,u,d,p,_,h,f,m,v=s.bits,g=0,y=0,S=0,T=0,$=0,E=0,b=0,I=0,R=0,C=0,A=null,k=0,P=new utils$2.Buf16(MAXBITS+1),O=new utils$2.Buf16(MAXBITS+1),w=null,M=0;for(g=0;g<=MAXBITS;g++)P[g]=0;for(y=0;y<n;y++)P[t[r+y]]++;for($=v,T=MAXBITS;T>=1&&0===P[T];T--);if($>T&&($=T),0===T)return i[o++]=20971520,i[o++]=20971520,s.bits=1,0;for(S=1;S<T&&0===P[S];S++);for($<S&&($=S),I=1,g=1;g<=MAXBITS;g++)if(I<<=1,(I-=P[g])<0)return-1;if(I>0&&(e===CODES$1||1!==T))return-1;for(O[1]=0,g=1;g<MAXBITS;g++)O[g+1]=O[g]+P[g];for(y=0;y<n;y++)0!==t[r+y]&&(a[O[t[r+y]]++]=y);if(e===CODES$1?(A=w=a,_=19):e===LENS$1?(A=lbase,k-=257,w=lext,M-=257,_=256):(A=dbase,w=dext,_=-1),C=0,y=0,g=S,p=o,E=$,b=0,u=-1,d=(R=1<<$)-1,e===LENS$1&&R>ENOUGH_LENS$1||e===DISTS$1&&R>ENOUGH_DISTS$1)return 1;for(;;){h=g-b,a[y]<_?(f=0,m=a[y]):a[y]>_?(f=w[M+a[y]],m=A[k+a[y]]):(f=96,m=0),c=1<<g-b,S=l=1<<E;do{i[p+(C>>b)+(l-=c)]=h<<24|f<<16|m|0}while(0!==l);for(c=1<<g-1;C&c;)c>>=1;if(0!==c?(C&=c-1,C+=c):C=0,y++,0==--P[g]){if(g===T)break;g=t[r+a[y]]}if(g>$&&(C&d)!==u){for(0===b&&(b=$),p+=S,I=1<<(E=g-b);E+b<T&&!((I-=P[E+b])<=0);)E++,I<<=1;if(R+=1<<E,e===LENS$1&&R>ENOUGH_LENS$1||e===DISTS$1&&R>ENOUGH_DISTS$1)return 1;i[u=C&d]=$<<24|E<<16|p-o|0}}return 0!==C&&(i[p+C]=g-b<<24|64<<16|0),s.bits=$,0},utils$1=common,adler32=adler32_1,crc32=crc32_1,inflate_fast2=inffast,inflate_table2=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_table2(LENS,e.lens,0,288,lenfix,0,e.work,{bits:9}),t=0;t<32;)e.lens[t++]=5;inflate_table2(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,l,u,d,p,_,h,f,m,v,g,y,S,T,$,E,b,I,R=0,C=new utils$1.Buf8(4),A=[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,l=r.hold,u=r.bits,d=s,p=c,E=Z_OK;e:for(;;)switch(r.mode){case HEAD:if(0===r.wrap){r.mode=TYPEDO;break}for(;u<16;){if(0===s)break e;s--,l+=n[o++]<<u,u+=8}if(2&r.wrap&&35615===l){r.check=0,C[0]=255&l,C[1]=l>>>8&255,r.check=crc32(r.check,C,2,0),l=0,u=0,r.mode=FLAGS;break}if(r.flags=0,r.head&&(r.head.done=!1),!(1&r.wrap)||(((255&l)<<8)+(l>>8))%31){e.msg="incorrect header check",r.mode=BAD;break}if((15&l)!==Z_DEFLATED){e.msg="unknown compression method",r.mode=BAD;break}if(u-=4,$=8+(15&(l>>>=4)),0===r.wbits)r.wbits=$;else if($>r.wbits){e.msg="invalid window size",r.mode=BAD;break}r.dmax=1<<$,e.adler=r.check=1,r.mode=512&l?DICTID:TYPE,l=0,u=0;break;case FLAGS:for(;u<16;){if(0===s)break e;s--,l+=n[o++]<<u,u+=8}if(r.flags=l,(255&flags(r))!==Z_DEFLATED){e.msg="unknown compression method",r.mode=BAD;break}if(57344&flags(r)){e.msg="unknown header flags set",r.mode=BAD;break}r.head&&(r.head.text=l>>8&1),512&flags(r)&&(C[0]=255&l,C[1]=l>>>8&255,r.check=crc32(r.check,C,2,0)),l=0,u=0,r.mode=TIME;case TIME:for(;u<32;){if(0===s)break e;s--,l+=n[o++]<<u,u+=8}r.head&&(r.head.time=l),512&flags(r)&&(C[0]=255&l,C[1]=l>>>8&255,C[2]=l>>>16&255,C[3]=l>>>24&255,r.check=crc32(r.check,C,4,0)),l=0,u=0,r.mode=OS;case OS:for(;u<16;){if(0===s)break e;s--,l+=n[o++]<<u,u+=8}r.head&&(r.head.xflags=255&l,r.head.os=l>>8),512&flags(r)&&(C[0]=255&l,C[1]=l>>>8&255,r.check=crc32(r.check,C,2,0)),l=0,u=0,r.mode=EXLEN;case EXLEN:if(1024&flags(r)){for(;u<16;){if(0===s)break e;s--,l+=n[o++]<<u,u+=8}r.length=l,r.head&&(r.head.extra_len=l),512&flags(r)&&(C[0]=255&l,C[1]=l>>>8&255,r.check=crc32(r.check,C,2,0)),l=0,u=0}else r.head&&(r.head.extra=null);r.mode=EXTRA;case EXTRA:if(1024&flags(r)&&((_=r.length)>s&&(_=s),_&&(r.head&&($=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,_,$)),512&flags(r)&&(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&flags(r)){if(0===s)break e;_=0;do{$=n[o+_++],r.head&&$&&r.length<65536&&(r.head.name+=String.fromCharCode($))}while($&&_<s);if(512&flags(r)&&(r.check=crc32(r.check,n,_,o)),s-=_,o+=_,$)break e}else r.head&&(r.head.name=null);r.length=0,r.mode=COMMENT;case COMMENT:if(4096&flags(r)){if(0===s)break e;_=0;do{$=n[o+_++],r.head&&$&&r.length<65536&&(r.head.comment+=String.fromCharCode($))}while($&&_<s);if(512&flags(r)&&(r.check=crc32(r.check,n,_,o)),s-=_,o+=_,$)break e}else r.head&&(r.head.comment=null);r.mode=HCRC;case HCRC:if(512&flags(r)){for(;u<16;){if(0===s)break e;s--,l+=n[o++]<<u,u+=8}if(l!==(65535&r.check)){e.msg="header crc mismatch",r.mode=BAD;break}l=0,u=0}r.head&&(r.head.hcrc=flags(r)>>9&1,r.head.done=!0),e.adler=r.check=0,r.mode=TYPE;break;case DICTID:for(;u<32;){if(0===s)break e;s--,l+=n[o++]<<u,u+=8}e.adler=r.check=zswap32(l),l=0,u=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=l,r.bits=u,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){l>>>=7&u,u-=7&u,r.mode=CHECK;break}for(;u<3;){if(0===s)break e;s--,l+=n[o++]<<u,u+=8}switch(r.last=1&l,u-=1,3&(l>>>=1)){case 0:r.mode=STORED;break;case 1:if(fixedtables(r),r.mode=LEN_,t===Z_TREES){l>>>=2,u-=2;break e}break;case 2:r.mode=TABLE;break;case 3:e.msg="invalid block type",r.mode=BAD}l>>>=2,u-=2;break;case STORED:for(l>>>=7&u,u-=7&u;u<32;){if(0===s)break e;s--,l+=n[o++]<<u,u+=8}if((65535&l)!=(l>>>16^65535)){e.msg="invalid stored block lengths",r.mode=BAD;break}if(r.length=65535&l,l=0,u=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(;u<14;){if(0===s)break e;s--,l+=n[o++]<<u,u+=8}if(r.nlen=257+(31&l),l>>>=5,u-=5,r.ndist=1+(31&l),l>>>=5,u-=5,r.ncode=4+(15&l),l>>>=4,u-=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(;u<3;){if(0===s)break e;s--,l+=n[o++]<<u,u+=8}r.lens[A[r.have++]]=7&l,l>>>=3,u-=3}for(;r.have<19;)r.lens[A[r.have++]]=0;if(r.lencode=r.lendyn,r.lenbits=7,b={bits:r.lenbits},E=inflate_table2(CODES,r.lens,0,19,r.lencode,0,r.work,b),r.lenbits=b.bits,E){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(;v=(R=r.lencode[l&(1<<r.lenbits)-1])>>>16&255,g=65535&R,!((m=R>>>24)<=u);){if(0===s)break e;s--,l+=n[o++]<<u,u+=8}if(g<16)l>>>=m,u-=m,r.lens[r.have++]=g;else{if(16===g){for(I=m+2;u<I;){if(0===s)break e;s--,l+=n[o++]<<u,u+=8}if(l>>>=m,u-=m,0===r.have){e.msg="invalid bit length repeat",r.mode=BAD;break}$=r.lens[r.have-1],_=3+(3&l),l>>>=2,u-=2}else if(17===g){for(I=m+3;u<I;){if(0===s)break e;s--,l+=n[o++]<<u,u+=8}u-=m,$=0,_=3+(7&(l>>>=m)),l>>>=3,u-=3}else{for(I=m+7;u<I;){if(0===s)break e;s--,l+=n[o++]<<u,u+=8}u-=m,$=0,_=11+(127&(l>>>=m)),l>>>=7,u-=7}if(r.have+_>r.nlen+r.ndist){e.msg="invalid bit length repeat",r.mode=BAD;break}for(;_--;)r.lens[r.have++]=$}}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,b={bits:r.lenbits},E=inflate_table2(LENS,r.lens,0,r.nlen,r.lencode,0,r.work,b),r.lenbits=b.bits,E){e.msg="invalid literal/lengths set",r.mode=BAD;break}if(r.distbits=6,r.distcode=r.distdyn,b={bits:r.distbits},E=inflate_table2(DISTS,r.lens,r.nlen,r.ndist,r.distcode,0,r.work,b),r.distbits=b.bits,E){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=l,r.bits=u,inflate_fast2(e,p),a=e.next_out,i=e.output,c=e.avail_out,o=e.next_in,n=e.input,s=e.avail_in,l=r.hold,u=r.bits,r.mode===TYPE&&(r.back=-1);break}for(r.back=0;v=(R=r.lencode[l&(1<<r.lenbits)-1])>>>16&255,g=65535&R,!((m=R>>>24)<=u);){if(0===s)break e;s--,l+=n[o++]<<u,u+=8}if(v&&0==(240&v)){for(y=m,S=v,T=g;v=(R=r.lencode[T+((l&(1<<y+S)-1)>>y)])>>>16&255,g=65535&R,!(y+(m=R>>>24)<=u);){if(0===s)break e;s--,l+=n[o++]<<u,u+=8}l>>>=y,u-=y,r.back+=y}if(l>>>=m,u-=m,r.back+=m,r.length=g,0===v){r.mode=LIT;break}if(32&v){r.back=-1,r.mode=TYPE;break}if(64&v){e.msg="invalid literal/length code",r.mode=BAD;break}r.extra=15&v,r.mode=LENEXT;case LENEXT:if(r.extra){for(I=r.extra;u<I;){if(0===s)break e;s--,l+=n[o++]<<u,u+=8}r.length+=l&(1<<r.extra)-1,l>>>=r.extra,u-=r.extra,r.back+=r.extra}r.was=r.length,r.mode=DIST;case DIST:for(;v=(R=r.distcode[l&(1<<r.distbits)-1])>>>16&255,g=65535&R,!((m=R>>>24)<=u);){if(0===s)break e;s--,l+=n[o++]<<u,u+=8}if(0==(240&v)){for(y=m,S=v,T=g;v=(R=r.distcode[T+((l&(1<<y+S)-1)>>y)])>>>16&255,g=65535&R,!(y+(m=R>>>24)<=u);){if(0===s)break e;s--,l+=n[o++]<<u,u+=8}l>>>=y,u-=y,r.back+=y}if(l>>>=m,u-=m,r.back+=m,64&v){e.msg="invalid distance code",r.mode=BAD;break}r.offset=g,r.extra=15&v,r.mode=DISTEXT;case DISTEXT:if(r.extra){for(I=r.extra;u<I;){if(0===s)break e;s--,l+=n[o++]<<u,u+=8}r.offset+=l&(1<<r.extra)-1,l>>>=r.extra,u-=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,h=r.wsize-_):h=r.wnext-_,_>r.length&&(_=r.length),f=r.window}else f=i,h=a-r.offset,_=r.length;_>c&&(_=c),c-=_,r.length-=_;do{i[a++]=f[h++]}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(;u<32;){if(0===s)break e;s--,l|=n[o++]<<u,u+=8}if(p-=c,e.total_out+=p,r.total+=p,p&&(e.adler=r.check=flags(r)?crc32(r.check,i,p,a-p):adler32(r.check,i,p,a-p)),p=c,(flags(r)?l:zswap32(l))!==r.check){e.msg="incorrect data check",r.mode=BAD;break}l=0,u=0}r.mode=LENGTH;case LENGTH:if(r.wrap&&flags(r)){for(;u<32;){if(0===s)break e;s--,l+=n[o++]<<u,u+=8}if(l!==(4294967295&r.total)){e.msg="incorrect length check",r.mode=BAD;break}l=0,u=0}r.mode=DONE;case DONE:E=Z_STREAM_END;break e;case BAD:E=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=l,r.bits=u,(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=flags(r)?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)&&E===Z_OK&&(E=Z_BUF_ERROR),E}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,l=this.options.chunkSize,u=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(l),s.next_out=0,s.avail_out=l),(r=zlib_inflate.inflate(s,c.Z_NO_FLUSH))===c.Z_NEED_DICT&&u&&(r=zlib_inflate.inflateSetDictionary(this.strm,u)),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=l-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 _navigator,pako_1=pako,DB_NAME$1="BytePlusRTC",indexedDB$1=function(){return window.indexedDB||window.mozIndexedDB||window.webkitIndexedDB||window.msIndexedDB},IndexedDBInterface=function(){function e(t){_classCallCheck(this,e),_defineProperty(this,"storeName",void 0),_defineProperty(this,"pendingList",[]),this.storeName=t,!isSSR$1()&&indexedDB$1()&&this._checkAndCreateStore(t)}var t,r;return _createClass(e,[{key:"_checkAndCreateStore",value:function(t,r){var n=this;e.db&&e.db.close();var i=r?indexedDB$1().open(DB_NAME$1,r):indexedDB$1().open(DB_NAME$1);i.onupgradeneeded=function(){i.result.createObjectStore(t)},i.onerror=function(e){console.error("IndexedDBInterface error",i.error)},i.onsuccess=function(){var r=i.result;e.db=r;try{e.db.transaction(n.storeName,"readonly"),n.pendingList.forEach(function(){var e=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){var r,i,o,a;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=t.txMode,i=t.resolve,o=t.reject,e.prev=1,e.next=4,n._getStore(r);case 4:a=e.sent,i(a),e.next=11;break;case 8:e.prev=8,e.t0=e.catch(1),o();case 11:case"end":return e.stop()}}),e,null,[[1,8]])})));return function(t){return e.apply(this,arguments)}}())}catch(e){n._checkAndCreateStore(t,r.version+1)}}}},{key:"_getStore",value:function(t){var r=this;return new promise((function(n,i){e.db?n(e.db.transaction(r.storeName,t).objectStore(r.storeName)):r.pendingList.push({txMode:t,resolve:n,reject:i})}))}},{key:"put",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 e.next=2,this._getStore("readwrite");case 2:return n=e.sent,e.abrupt("return",new promise((function(e,i){var o=n.put(t,r);o.onsuccess=function(){e()},o.onerror=function(e){i(e)}})));case 4:case"end":return e.stop()}}),e,this)}))),function(e,t){return r.apply(this,arguments)})},{key:"get",value:(t=_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._getStore("readonly");case 2:return r=e.sent,e.abrupt("return",new promise((function(e,n){var i=r.get(t);i.onsuccess=function(){e(i.result)},i.onerror=function(e){n(e)}})));case 4:case"end":return e.stop()}}),e,this)}))),function(e){return t.apply(this,arguments)})}]),e}();_defineProperty(IndexedDBInterface,"db",void 0),_defineProperty(IndexedDBInterface,"state","init");var _context$1,ReportLimit=4e3,XMLHttpRequestTimeout=1e4,defaultCommonStats={product_line:"rtc",report_version:"5",os:"web",user_agent:isSSR$1()?"":null===(_navigator=navigator)||void 0===_navigator?void 0:_navigator.userAgent,platform:"web",product:"webrtc",app_state:"active"},REPROT_ERROR_BUFFER_KEY="ReportErrorBuffer",ReportorErrorBuffer=function(){function e(){_classCallCheck(this,e),_defineProperty(this,"_buffer",new IndexedDBInterface(REPROT_ERROR_BUFFER_KEY))}var t,r;return _createClass(e,[{key:"set",value:(r=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._buffer.put(t,REPROT_ERROR_BUFFER_KEY);case 2:case"end":return e.stop()}}),e,this)}))),function(e){return r.apply(this,arguments)})},{key:"get",value:(t=_asyncToGenerator(_regeneratorRuntime().mark((function e(){var t;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=[],e.prev=1,e.next=4,this._buffer.get(REPROT_ERROR_BUFFER_KEY);case 4:t=e.sent,e.next=9;break;case 7:e.prev=7,e.t0=e.catch(1);case 9:return e.abrupt("return",t);case 10:case"end":return e.stop()}}),e,this,[[1,7]])}))),function(){return t.apply(this,arguments)})}]),e}(),Reportor=function(){function e(){var t=this;_classCallCheck(this,e),_defineProperty(this,"report_common",defaultCommonStats),_defineProperty(this,"dataBuffer",[]),_defineProperty(this,"posting",!1),_defineProperty(this,"sucSendTimer",void 0),_defineProperty(this,"preSucTime",0),_defineProperty(this,"errSendTimer",void 0),_defineProperty(this,"errSendDelay",100),_defineProperty(this,"errSendBuffer",void 0),_defineProperty(this,"_logServerUrl",void 0),_defineProperty(this,"_retryCount",0),isSSR$1()||(window.addEventListener("beforeunload",(function(){clearTimeout(t.errSendTimer),clearTimeout(t.sucSendTimer),t._send(void 0,!0)})),document.addEventListener("visibilitychange",(function(){"visible"===document.visibilityState?t.setCommonStats({app_state:"active"}):"hidden"===document.visibilityState&&t.setCommonStats({app_state:"background"})})))}var t;return _createClass(e,[{key:"setUrl",value:function(e){this._logServerUrl=e}},{key:"setCommonStats",value:function(e){this.report_common=assign$2(this.report_common,e)}},{key:"enableErrorBuffer",value:function(){this.errSendBuffer=new ReportorErrorBuffer,this.loadErrorBuffer()}},{key:"push",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];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=concat$2(e).call(e,this.dataBuffer)}},{key:"_send",value:function(e,t){var r,n,i=this;if((e||this.dataBuffer.length)&&this._logServerUrl){var o={data:e||splice$3(r=this.dataBuffer).call(r,0,ReportLimit),header:_objectSpread2(_objectSpread2({},this.report_common),{},{http_retry_count:this._retryCount}),from:"web",os:"web",version:"1"},a=new XMLHttpRequest;if(a.timeout=XMLHttpRequestTimeout,a.onreadystatechange=function(){if(4===a.readyState){var r,n,s,c;if(e||(i.posting=!1),200===a.status||304===a.status)try{r=JSON.parse(a.responseText)}catch(e){n=e}if(r&&0===r.StatusCode){if(!e&&!t)null===(s=i.errSendBuffer)||void 0===s||s.set([]),i._sucSend()}else if(setTimeout((function(){var e,t;reportGlobalError(concat$2(e="reportor error, res:".concat(null===(t=r)||void 0===t?void 0:t.toString()," err:")).call(e,n),a.status,n)}),0),e)i._send(e);else i._unshift(o.data),null===(c=i.errSendBuffer)||void 0===c||c.set(_toConsumableArray(i.dataBuffer)),t?i._send():i._errSend()}},a.open("POST",this._logServerUrl,!0),e||(this.posting=!0),!isSSR$1()&&includes4(n=location.search).call(n,"_rtc_debug_"))a.send(stringify$1(o));else{var s=pako_1.gzip(stringify$1(o));a.setRequestHeader("Content-Encoding","gzip"),a.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=UTF-8"),a.send(s)}}}},{key:"_sucSend",value:function(){this.errSendDelay=100,this._retryCount=0,this.preSucTime=Date.now(),this.sucSendTimer=window.setTimeout(this._send.bind(this),2e3)}},{key:"_errSend",value:function(){var e=this;this.errSendTimer=window.setTimeout((function(){e._send(),delete e.errSendTimer}),this.errSendDelay),this.errSendDelay*=2,this._retryCount++}},{key:"loadErrorBuffer",value:(t=_asyncToGenerator(_regeneratorRuntime().mark((function e(){var t,r,n=this;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,null===(r=this.errSendBuffer)||void 0===r?void 0:r.get();case 2:if(e.t1=t=e.sent,e.t0=null!==e.t1,!e.t0){e.next=6;break}e.t0=void 0!==t;case 6:if(!e.t0){e.next=10;break}e.t2=t,e.next=11;break;case 10:e.t2=[];case 11:e.t2.forEach((function(e){n.push(e)}));case 13:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})}]),e}(),commonReportor=new Reportor,Monitor=function(){function e(t){_classCallCheck(this,e),_defineProperty(this,"report_id",0),_defineProperty(this,"modify_ids",{}),this.id=t}return _createClass(e,[{key:"report",value:function(e,t){var r,n,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},o=_objectSpread2(_objectSpread2(_objectSpread2({event_key:e,report_id:this.report_id++,rtc_timestamp:Date.now()},this.modify_ids),t),{},{common_extra_info:stringify$1(i)});(commonReportor.push(o),isSSR$1())||(null===(r=(n=window).__onRTCReport)||void 0===r||r.call(n,this.id,o))}},{key:"set",value:function(e){this.modify_ids=assign$2(this.modify_ids,e)}},{key:"destroy",value:function(){}}]),e}(),entryVirtual$1=entryVirtual$m,keys$7=entryVirtual$1("Array").keys,parent$n=keys$7,keys$6=parent$n,classof$1=classof$d,hasOwn$3=hasOwnProperty_1,isPrototypeOf$1=objectIsPrototypeOf,method$1=keys$6,ArrayPrototype$1=Array.prototype,DOMIterables={DOMTokenList:!0,NodeList:!0},keys$5=function(e){var t=e.keys;return e===ArrayPrototype$1||isPrototypeOf$1(ArrayPrototype$1,e)&&t===ArrayPrototype$1.keys||hasOwn$3(DOMIterables,classof$1(e))?method$1:t},parent$m=keys$5,keys$4=parent$m,parent$l=keys$4,keys$3=parent$l,keys$2=keys$3,keys$1=keys$2,DB_NAME="@byted/ve-rtc",STORE_NAME="@byted/ve-rtc",STORE_CACHED_SIZE_KEY="@byted/ve-rtc-cache-size",IDB=function(){function e(){_classCallCheck(this,e),_defineProperty(this,"storeKey",void 0),_defineProperty(this,"logLevel",void 0),_defineProperty(this,"LogfileSize",void 0),_defineProperty(this,"db",void 0),_defineProperty(this,"logId",void 0),_defineProperty(this,"cacheLog",void 0),_defineProperty(this,"cachedSize",void 0),_defineProperty(this,"preCacheTime",void 0),_defineProperty(this,"timer",void 0),_defineProperty(this,"_getSize",(function(e){return new Blob(e).size/1048576})),this.storeKey="",this.logId=1,this.cacheLog="",this.logLevel="none",this.LogfileSize=100,this._createStore()}return _createClass(e,[{key:"_createStore",value:function(){var e=this;if(!isSSR$1()&&window.indexedDB){var t=indexedDB.open(DB_NAME);t.onupgradeneeded=function(){t.result.createObjectStore(STORE_NAME);try{localStorage.removeItem(STORE_CACHED_SIZE_KEY)}catch(e){}},t.onerror=function(e){},t.onsuccess=function(){e.db=t.result,e._getCachedSize()}}}},{key:"_getCachedSize",value:function(){var e=this;try{var t=localStorage.getItem(STORE_CACHED_SIZE_KEY);if(t)this.cachedSize=+t;else values$1(this).call(this).then((function(t){e.cachedSize=e._getSize(t),e._setCachedSize()}))}catch(e){}}},{key:"_setCachedSize",value:function(){try{localStorage.setItem(STORE_CACHED_SIZE_KEY,"".concat(this.cachedSize))}catch(e){}}},{key:"_getStore",value:function(e){if(this.db)return this.db.transaction(STORE_NAME,e).objectStore(STORE_NAME)}},{key:"set",value:function(e){var t=this;return new promise((function(r,n){if("none"===t.logLevel)return r();var i;if(e&&t.preCacheTime&&t.preCacheTime-Date.now()<1e3)return t.cacheLog+=concat$2(i="\n\n".concat(t.logId,": ")).call(i,e),t.logId++,t.timer||(t.timer=setTimeout((function(){t.set("")}),1e3-(t.preCacheTime-Date.now()))),r();clearTimeout(t.timer),t.timer=null;var o=t._getStore("readwrite");if(!o)return n("get store fail");t.cachedSize&&t.cachedSize>t.LogfileSize&&t.keyEarliest().then((function(e){t.get(e).then((function(r){t.del(e).then((function(){t.cachedSize=t.cachedSize-t._getSize(["".concat(r)]),t._setCachedSize()}))}))}));var a=o.get(t.storeKey);a.onsuccess=function(){try{var i,s,c,l,u,d=concat$2(i="".concat(a.result||"")).call(i,t.cacheLog),p=e?concat$2(s=concat$2(c="".concat(d?"\n\n":"")).call(c,t.logId,": ")).call(s,e):"";o.put(concat$2(l="".concat(d)).call(l,p),t.storeKey),e&&t.logId++,t.cacheLog="",t.cachedSize=(t.cachedSize||0)+t._getSize([concat$2(u="".concat(t.cacheLog)).call(u,p)]),t._setCachedSize(),t.preCacheTime=Date.now(),r()}catch(r){var _;if(!e)return n(r);t.cacheLog+=concat$2(_="\n\n".concat(t.logId,": ")).call(_,e),t.logId++,n(r)}},a.onerror=function(r){var i;if(!e)return n(r);t.cacheLog+=concat$2(i="\n\n".concat(t.logId,": ")).call(i,e),t.logId++,n(r)}}))}},{key:"get",value:function(e){var t=this;return new promise((function(r,n){var i=t._getStore("readonly");if(!i)return n();var o=i.get(e);o.onsuccess=function(){r(o.result)},o.onerror=function(e){n(e)}}))}},{key:"del",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.storeKey;return new promise((function(r,n){var i=e._getStore("readwrite");if(!i)return n();var o=i.delete(t);o.onsuccess=function(){return r(o.result)},o.onerror=function(e){return n(e)}}))}},{key:"keyEarliest",value:function(){return keys$1(this).call(this).then((function(e){var t,r=Date.now();return e.forEach((function(e){if(e&&e.length){var n=e.split("-")[0];Number(n)<r&&(r=Number(n),t=e)}})),t}))}},{key:"keys",value:function(){var e=this;return new promise((function(t,r){var n=e._getStore("readonly");if(!n)return r();if(n.getAllKeys){var i=n.getAllKeys();return i.onsuccess=function(){t(i.result)},void(i.onerror=function(){r()})}var o=[];n.openCursor().onsuccess=function(){this.result&&(o.push(this.result.key),this.result.continue())},n.transaction.oncomplete=function(){return t(o)}}))}},{key:"values",value:function(){var e=this;return new promise((function(t,r){var n=e._getStore("readonly");if(!n)return r();if(n.getAll){var i=n.getAll();return i.onsuccess=function(){t(i.result)},void(i.onerror=function(){r()})}var o=[];n.openCursor().onsuccess=function(){this.result&&(o.push(this.result.value),this.result.continue())},n.transaction.oncomplete=function(){return t(o)}}))}},{key:"download",value:function(e){e=e||this.storeKey,this.get(e).then((function(t){var r=document.createElement("a");r.download="".concat(e,".txt"),r.href="data:text/paint;utf-8,"+(t||""),r.click()}))}}]),e}(),iDB=new IDB,HEAD_TEXT="[VERTC]",colorMap=["#0050b3","#0050b3","#0050b3","#0050b3","#0050b3"],enable_log="undefined"!=typeof window&&includes4(_context$1=window.location.search).call(_context$1,"_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){for(var t,r,n,i,o,a,s,c=arguments.length,l=new Array(c>1?c-1:0),u=1;u<c;u++)l[u-1]=arguments[u];var d=l.shift();try{var p,_,h,f,m=concat$2(p=[]).call(p,l),v="".concat(d).replace(/\%o/gi,(function(){var e=m.shift();return stringify$1(e)}));iDB.set(concat$2(_=concat$2(h=concat$2(f="".concat(HEAD_TEXT,"[").concat(this._module,".")).call(f,e,"] ")).call(h,v," ")).call(_,map$6(m).call(m,(function(e){return stringify$1(e)})).join(", ")))}catch(e){}if(enable_log){for(var g="",y=0;y<this._indent;y++)g+=" ";(t=console).log.apply(t,concat$2(r=[concat$2(n=concat$2(i=concat$2(o=concat$2(a=concat$2(s="%c".concat(getTimestamp(),"-")).call(s,HEAD_TEXT)).call(a,g,"[")).call(o,this._module,".")).call(i,e,"] ")).call(n,d),"color:".concat(colorMap[this._indent],";")]).call(r,l))}}}]),e}(),getTimestamp=function(){var e=new Date;return e.toTimeString().split(" ")[0]+":"+e.getMilliseconds()},logger$o=new Logger("MessageReportor",1),RESET_DURATION=36e5,MessageReportor=function(){function e(t){_classCallCheck(this,e),_defineProperty(this,"_preTime",Date.now()),_defineProperty(this,"_one2oneNum",0),_defineProperty(this,"_one2manyNum",0),_defineProperty(this,"_one2oneMsgCache",new map2),_defineProperty(this,"_one2manyMsgCache",new map2),_defineProperty(this,"roomId",""),_defineProperty(this,"userId",""),_defineProperty(this,"rtsSessionId",""),this.id=t}return _createClass(e,[{key:"needReport",value:function(t){return!!e.config&&(Date.now()-this._preTime>=RESET_DURATION&&(this._preTime=Date.now(),this._one2oneNum=0,this._one2manyNum=0),"one2one"===t&&this._one2oneNum<e.config.max_one2one_fpt_per_hour&&Math.random()<=e.config.one2one_fpt_ratio/100||"one2many"===t&&this._one2manyNum<e.config.max_one2many_fpt_per_hour&&Math.random()<=e.config.one2many_fpt_ratio/100)}},{key:"cacheP2PMsg",value:function(t){var r;this._one2oneMsgCache.set(t.msg_id,_objectSpread2({config_version:(null===(r=e.config)||void 0===r?void 0:r.version)||""},t))}},{key:"updateP2PMsg",value:function(e,t){var r=this._one2oneMsgCache.get(e);r&&this._one2oneMsgCache.set(e,_objectSpread2(_objectSpread2({},r),t))}},{key:"cacheCustomMsg",value:function(t){var r;this._one2manyMsgCache.set(t.msg_id,_objectSpread2({config_version:(null===(r=e.config)||void 0===r?void 0:r.version)||""},t))}},{key:"updateOne2ManyMsg",value:function(e,t){var r=this._one2manyMsgCache.get(e);r&&this._one2manyMsgCache.set(e,_objectSpread2(_objectSpread2({},r),t))}},{key:"reportP2PMsg",value:function(e){var t,r=this._one2oneMsgCache.get(e);r&&(logger$o.print("reportP2PMsg",r.type,stringify$1(r)),null===(t=getMonitor(this.id))||void 0===t||t.report("rts_message",r))}},{key:"reportOne2ManyMsg",value:function(e){var t,r=this._one2manyMsgCache.get(e);r&&(logger$o.print("reportOne2ManyMsg",r.type,stringify$1(r)),null===(t=getMonitor(this.id))||void 0===t||t.report("rts_message",r))}},{key:"reportMsgRecv",value:function(t){var r,n;t.config_version=(null===(r=e.config)||void 0===r?void 0:r.version)||"",logger$o.print("reportMsgRecv",t.type,stringify$1(t)),null===(n=getMonitor(this.id))||void 0===n||n.report("rts_message",t)}},{key:"destroy",value:function(){this._one2manyNum=0,this._one2oneNum=0,this._one2manyMsgCache.clear(),this._one2oneMsgCache.clear(),this._preTime=Date.now(),this.roomId="",this.userId="",this.rtsSessionId=""}}]),e}();_defineProperty(MessageReportor,"config",void 0);var _cache=new map2,setConfig=function(e){logger$o.print("setConfig","get config: "+stringify$1(e)),MessageReportor.config=e},createRTSMsgReportor=function(e){var t=_cache.get(e)||new MessageReportor(e);return _cache.set(e,t),t},destroyRTSMsgReportor=function(e){var t=_cache.get(e);t&&(t.destroy(),_cache.delete(e))},setRoomId=function(e,t){var r=_cache.get(e);r&&(r.roomId=t||"")},setUserId=function(e,t){var r=_cache.get(e);r&&(r.userId=t||"")},setRtsSessionId=function(e,t){var r=_cache.get(e);r&&(r.rtsSessionId=t)},samplingP2PMsg=function(e,t){var r=_cache.get(e);if(null!=r&&r.needReport("one2one")){var n,i=concat$2(n="".concat(t.from)).call(n,t.id),o=t.to?"one2one":"one2server";t.enable_report=!0,t.report_msg_id=t.id,r.cacheP2PMsg({rts_session_id:r.rtsSessionId,msg_id:i,node_role:"src_sdk",from:t.from,to:t.to||"server",type:o,rts_room_id:t.room,req_ts:Date.now(),send_ts:Date.now(),ack_ts:Date.now(),msg_size:0,error_code:0,recv_msg_ts:0,fwd_msg_ts:0,reply_ack_ts:0,cur_dst_uid:""})}return t},updateP2PMsgReq=function(e,t,r){var n,i;t.enable_report&&t.report_msg_id&&(null===(n=_cache.get(e))||void 0===n||n.updateP2PMsg(concat$2(i="".concat(t.from)).call(i,t.report_msg_id),{send_ts:Date.now(),msg_size:r}))},updateP2PMsgAck=function(e,t,r){if(t.enable_report&&t.report_msg_id){var n,i,o=_cache.get(e);null==o||o.updateP2PMsg(concat$2(n="".concat(t.from)).call(n,t.report_msg_id),{ack_ts:Date.now(),error_code:r}),null==o||o.reportP2PMsg(concat$2(i="".concat(t.from)).call(i,t.report_msg_id))}},samplingOne2ManyMsg=function(e,t,r){var n,i=_cache.get(e);null!=i&&i.needReport("one2many")&&(r.enable_report=!0,r.report_msg_id=t,i.cacheCustomMsg({rts_session_id:i.rtsSessionId,msg_id:concat$2(n="".concat(r.clientId)).call(n,t),node_role:"src_sdk",from:r.clientId,to:i.roomId,type:"one2many",rts_room_id:i.roomId,req_ts:Date.now(),send_ts:Date.now(),ack_ts:Date.now(),msg_size:0,error_code:0,recv_msg_ts:0,fwd_msg_ts:0,reply_ack_ts:0,cur_dst_uid:""}));return r},updateOne2ManyMsgReq=function(e,t,r){if(t.enable_report&&t.report_msg_id){var n,i=_cache.get(e);if(i)i.updateOne2ManyMsg(concat$2(n="".concat(t.clientId)).call(n,t.report_msg_id),{send_ts:Date.now(),msg_size:r})}},updateOne2ManyMsgAck=function(e,t,r){if(t.enable_report&&t.report_msg_id){var n,i,o=_cache.get(e);if(o)null==o||o.updateOne2ManyMsg(concat$2(n="".concat(t.clientId)).call(n,t.report_msg_id),{ack_ts:Date.now(),error_code:r}),null==o||o.reportOne2ManyMsg(concat$2(i="".concat(t.clientId)).call(i,t.report_msg_id))}},reportP2PMsgRecv=function(e,t,r){if(t.enable_report&&t.report_msg_id){var n,i=_cache.get(e),o=t.to?"one2one":"one2many";null==i||i.reportMsgRecv({rts_session_id:i.rtsSessionId,msg_id:concat$2(n="".concat(t.from)).call(n,t.report_msg_id),msg_size:r.msg_size,node_role:"dst_sdk",type:o,rts_room_id:t.room,from:t.from,to:t.to||t.room,error_code:0,recv_msg_ts:r.recv_msg_ts,fwd_msg_ts:r.fwd_msg_ts,reply_ack_ts:Date.now(),cur_dst_uid:t.to?"":i.userId,config_version:"",req_ts:0,send_ts:0,ack_ts:0})}},reportOne2ManyMsgRecv=function(e,t,r){if(t.enable_report&&t.report_msg_id){var n,i=_cache.get(e);null==i||i.reportMsgRecv({rts_session_id:i.rtsSessionId,msg_id:concat$2(n="".concat(t.clientId)).call(n,t.report_msg_id),msg_size:r.msg_size,node_role:"dst_sdk",type:"one2many",rts_room_id:t.roomId,from:t.clientId,to:t.roomId,error_code:0,recv_msg_ts:r.recv_msg_ts,fwd_msg_ts:r.fwd_msg_ts,reply_ack_ts:Date.now(),cur_dst_uid:i.userId,config_version:"",req_ts:0,send_ts:0,ack_ts:0})}},RTSMsgReportor={_cache:_cache,setConfig:setConfig,setRtsSessionId:setRtsSessionId,createRTSMsgReportor:createRTSMsgReportor,destroyRTSMsgReportor:destroyRTSMsgReportor,setRoomId:setRoomId,setUserId:setUserId,samplingP2PMsg:samplingP2PMsg,updateP2PMsgReq:updateP2PMsgReq,updateP2PMsgAck:updateP2PMsgAck,samplingOne2ManyMsg:samplingOne2ManyMsg,reportP2PMsgRecv:reportP2PMsgRecv,updateOne2ManyMsgAck:updateOne2ManyMsgAck,updateOne2ManyMsgReq:updateOne2ManyMsgReq,reportOne2ManyMsgRecv:reportOne2ManyMsgRecv},MessageStatisticsObserver=function(){function e(t){_classCallCheck(this,e),_defineProperty(this,"_timer",void 0),_defineProperty(this,"userMessage",{}),_defineProperty(this,"roomMessage",{}),this.id=t,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(){(keys$8(this.userMessage).length||keys$8(this.roomMessage).length)&&(this._report(),this._reset())}},{key:"_report",value:function(){var e,t,r,n=this;null===(e=getMonitor(this.id))||void 0===e||e.report("rtc_message_statistics",{dc_user_message:map$6(t=keys$8(this.userMessage)).call(t,(function(e){return n.userMessage[e]})),dc_room_message:map$6(r=keys$8(this.roomMessage)).call(r,(function(e){return n.roomMessage[e]})),media_server_ip:""})}},{key:"_reset",value:function(){this.userMessage={},this.roomMessage={}}},{key:"_checkInitUserMessage",value:function(e,t){var r,n;this.userMessage[concat$2(r="".concat(t,"-")).call(r,e)]||(this.userMessage[concat$2(n="".concat(t,"-")).call(n,e)]={dc_peer_user_id:e,dc_send_total:0,dc_recv_total:0,dc_send_ack:0,dc_send_fail:0,dc_fail_timeout:0,dc_fail_no_receiver:0,dc_fail_no_relay_path: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){var n,i;(this._checkInitUserMessage(e,t),this.userMessage[concat$2(n="".concat(t,"-")).call(n,e)].dc_send_total++,r)&&this.userMessage[concat$2(i="".concat(t,"-")).call(i,e)].dc_send_binary++}},{key:"_recvUserMessage",value:function(e,t){var r;this._checkInitUserMessage(e,t),this.userMessage[concat$2(r="".concat(t,"-")).call(r,e)].dc_recv_total++}},{key:"_sendUserFail",value:function(e,t,r){var n,i=this.userMessage[concat$2(n="".concat(t,"-")).call(n,e)];i&&(i.dc_send_fail++,this._handleUserFail(i,r))}},{key:"_handleUserFail",value:function(e,t){var r;t&&(t.code||t.err)&&(includes4(r=["TIME_OUT","USER_MESSAGE_TIMEOUT"]).call(r,t.code)?e.dc_fail_timeout++:3===t.err?e.dc_fail_no_receiver++:4===t.err?e.dc_fail_no_relay_path++:1===t.err&&e.dc_fail_timeout++)}},{key:"_sendUserAck",value:function(e,t,r,n,i){var o,a=this.userMessage[concat$2(o="".concat(t,"-")).call(o,e)];a&&(a.dc_send_ack++,a.dc_cost_time+=r,a.dc_cost_s2s+=n||0,a.dc_cost_peer_s2e+=i,a.dc_cost_e2s+=r-(n||0)-i,r<=100?(a.dc_send_ack_100++,a.dc_send_ack_200++,a.dc_send_ack_400++,a.dc_send_ack_1s++):r<=200?(a.dc_send_ack_200++,a.dc_send_ack_400++,a.dc_send_ack_1s++):r<=400?(a.dc_send_ack_400++,a.dc_send_ack_1s++):r<=1e3&&a.dc_send_ack_1s++,r<a.dc_least_time&&(a.dc_least_time=r),r>a.dc_most_time&&(a.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,"p2p",t)}},{key:"recvP2PMessage",value:function(e){this._recvUserMessage(e,"p2p")}},{key:"sendP2PFail",value:function(e,t){this._sendUserFail(e,"p2p",t)}},{key:"sendP2PAck",value:function(e,t,r,n){this._sendUserAck(e,"p2p",t,r,n)}},{key:"sendP2POutRoomMessage",value:function(e,t){this._sendUserMessage(e,"p2p_outside_room",t)}},{key:"recvP2POutRoomMessage",value:function(e){this._recvUserMessage(e,"p2p_outside_room")}},{key:"sendP2POutRoomFail",value:function(e,t){this._sendUserFail(e,"p2p_outside_room",t)}},{key:"sendP2POutRoomAck",value:function(e,t,r,n){this._sendUserAck(e,"p2p_outside_room",t,r,n)}},{key:"sendP2serverMessage",value:function(e){this._sendUserMessage("","p2server",e)}},{key:"sendP2serverFail",value:function(e){this._sendUserFail("","p2server",e)}},{key:"sendP2serveAck",value:function(e,t,r){this._sendUserAck("","p2server",e,t,r)}},{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,i)}},{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,i)}},{key:"countServerMessage",value:function(e,t,r,n){this.sendP2serverMessage(t),e?(n=n||{},this.sendP2serveAck(Date.now()-r,n.s2s_time||0,n.s2e_time||0)):this.sendP2serverFail(n)}},{key:"destroy",value:function(){this._reset(),clearTimeout(this._timer)}}]),e}(),setGlobalStats=function(e){commonReportor.setCommonStats(e)},setReportUrl=function(e){commonReportor.setUrl(e)},enableErrorBuffer=function(){commonReportor.enableErrorBuffer()},globalMonitor=new Monitor("global"),reportGlobalApiCall=function(e,t,r){globalMonitor.report("rtc_sdk_api_call",{sdk_api_name:e,error_code:t,message:r})},reportGlobalCallback=function(e,t,r){globalMonitor.report("rtc_sdk_callback",{sdk_callback_name:e,error_code:t,message:r})},reportGlobalError=function(e,t,r){globalMonitor.report("rtc_error",{message:e,error_code:t},r)},reportGlobalInvokeStatus=function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"",i=arguments.length>4?arguments[4]:void 0;globalMonitor.report("rtc_invoke_status",{sdk_api_name:e,message:t,error_code:r,stream_id:n,elapse:0},i)},monitorMap=new map2,getMonitor=function(e){return monitorMap.get(e)},createMonitor=function(e,t){var r=new Monitor(e);return r.set(_objectSpread2(_objectSpread2({},t),{},{engine_session_id:genUuid$1()})),r.report("sdk_init_engine",{start:Date.now(),type:"begin"}),monitorMap.set(e,r),r},destroyMonitor=function(e){e.report("sdk_init_engine",{start:Date.now(),type:"end"}),monitorMap.delete(e.id)};function reportRtcSdkApiCall(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return function(e,r,n){if("function"==typeof n.value){var i=n.value;n.value=function(){for(var e,n=arguments.length,o=new Array(n),a=0;a<n;a++)o[a]=arguments[a];var s,c,l=this.engineId||this.id,u={};(t.forEach((function(e,t){u[e]=o[t]})),"joinRoom"===r)&&(null===(s=getMonitor(l))||void 0===s||s.set({room_id:o[1],user_id:null===(c=o[2])||void 0===c?void 0:c.userId}));null===(e=getMonitor(l))||void 0===e||e.report("rtc_sdk_api_call",{sdk_api_name:r,message:stringify$1(reportParamsCheck(o)),error_code:0},u);var d=i.apply(this,o);return"function"==typeof(null==d?void 0:d.then)?d.then((function(e){return reportRtcSdkCallback(l,r,[e||{}]),e})).catch((function(e){throw reportRtcSdkCallback(l,r,e.message,e.code),e})):(reportRtcSdkCallback(l,r,[d||{}]),d)}}}}var reportRtcSdkCallback=function(e,t,r){var n,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,o=arguments.length>4?arguments[4]:void 0,a={sdk_callback_name:t,error_code:i,message:stringify$1(Array.isArray(r)?reportParamsCheck(r):r)};o&&(a.room_id=o),null===(n=getMonitor(e))||void 0===n||n.report("rtc_sdk_callback",a)},reportRtcInvokeStatus=function(e,t,r){var n,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:"",a=arguments.length>5?arguments[5]:void 0;null===(n=getMonitor(e))||void 0===n||n.report("rtc_invoke_status",{sdk_api_name:t,message:r,error_code:i,stream_id:o,elapse:0},a)},maxBinaryLength=10;function reportParamsCheck(e){return map$6(e).call(e,(function e(t){var r;if(null!=t&&t._reportName)return t._reportName;if(t instanceof HTMLElement)return t.toString();if(t instanceof ArrayBuffer||ArrayBuffer.isView(t)){var n,i,o=ArrayBuffer.isView(t)?t.buffer:t,a=o.byteLength,s=[];if(a>maxBinaryLength){var c,l,u,d,p=new DataView(o),_=map$6(c=from$2({length:maxBinaryLength/2})).call(c,(function(e,t){return p.getUint8(t)})),h=map$6(l=map$6(u=from$2({length:maxBinaryLength/2})).call(u,(function(e,t){return a-1-t})).reverse()).call(l,(function(e){return p.getUint8(e)}));s=concat$2(d=[]).call(d,_toConsumableArray(_),["..."],_toConsumableArray(h))}else s=from$2(new Uint8Array(o));return concat$2(n=concat$2(i="".concat(t.constructor.name,"(")).call(i,a,") [")).call(n,s.join(", "),"]")}if(t instanceof ImageData)return"ImageData";if(Array.isArray(t))return map$6(t).call(t,e);if(includes4(r=["[object Object]","[object MediaStreamTrack]"]).call(r,Object.prototype.toString.call(t))){var f={};for(var m in t)f[m]=e(t[m]);return f}return t}))}var getServerConfig=function(e){var t,r=getMonitor(e.engineId),n={keys:keys$1(e),labelSelector:"",sdkVersion:e.sdkVersion,deviceType:"web",appId:e.appId,deviceId:e.deviceId,userAgent:"undefined"!=typeof navigator?navigator.userAgent:void 0},i=map$6(t=e.requestDomains).call(t,(function(e){return"https://".concat(e,"/decision/v1/multi")}));null==r||r.report("rtc_get_config",{error_code:0,message:stringify$1(n),elapse:0,host:i.join(","),type:"request",config_id:"",enable_cloud_proxy:!1});var o=map$6(i).call(i,function(){var e=_asyncToGenerator(_regeneratorRuntime().mark((function e(t,r){var i;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,fetch(t,{method:"POST",body:stringify$1(n)}).then((function(e){return e.json()}));case 2:return i=e.sent,e.abrupt("return",{result:i,index:r});case 4:case"end":return e.stop()}}),e)})));return function(t,r){return e.apply(this,arguments)}}());return new promise((function(e){promiseAny$1(o).then((function(t){var n=t.result,o=t.index;null==r||r.report("rtc_get_config",{error_code:200,message:stringify$1(n),elapse:0,host:i[o],type:"response",config_id:"",enable_cloud_proxy:!1}),e(n)})).catch((function(e){var t;null==r||r.report("rtc_get_config",{error_code:500,message:null===(t=e[0])||void 0===t?void 0:t.message,elapse:0,host:"",type:"response",config_id:"",enable_cloud_proxy:!1})}))}))},libTypedarrays={exports:{}},$$r=_export,global$4=global$s;$$r({global:!0,forced:global$4.globalThis!==global$4},{globalThis:global$4});var globalThis$6=global$s,parent$k=globalThis$6,globalThis$5=parent$k,parent$j=globalThis$5,globalThis$4=parent$j,parent$i=globalThis$4,globalThis$3=parent$i,globalThis$2=globalThis$3,globalThis$1=globalThis$2,core={exports:{}};!function(e,t){var r;core.exports=(r=r||function(e,t){var r;if("undefined"!=typeof window&&window.crypto&&(r=window.crypto),"undefined"!=typeof self&&self.crypto&&(r=self.crypto),void 0!==globalThis$1&&globalThis$1.crypto&&(r=globalThis$1.crypto),!r&&"undefined"!=typeof window&&window.msCrypto&&(r=window.msCrypto),!r&&void 0!==commonjsGlobal&&commonjsGlobal.crypto&&(r=commonjsGlobal.crypto),!r&&"function"==typeof commonjsRequire)try{r=require("crypto")}catch(e){}var n=function(){if(r){if("function"==typeof r.getRandomValues)try{return r.getRandomValues(new Uint32Array(1))[0]}catch(e){}if("function"==typeof r.randomBytes)try{return r.randomBytes(4).readInt32LE()}catch(e){}}throw new Error("Native crypto module could not be used to get secure random number.")},i=Object.create||function(){function e(){}return function(t){var r;return e.prototype=t,r=new e,e.prototype=null,r}}(),o={},a=o.lib={},s=a.Base={extend:function(e){var t=i(this);return e&&t.mixIn(e),t.hasOwnProperty("init")&&this.init!==t.init||(t.init=function(){t.$super.init.apply(this,arguments)}),t.init.prototype=t,t.$super=this,t},create:function(){var e=this.extend();return e.init.apply(e,arguments),e},init:function(){},mixIn:function(e){for(var t in e)e.hasOwnProperty(t)&&(this[t]=e[t]);e.hasOwnProperty("toString")&&(this.toString=e.toString)},clone:function(){return this.init.prototype.extend(this)}},c=a.WordArray=s.extend({init:function(e,r){e=this.words=e||[],this.sigBytes=r!=t?r:4*e.length},toString:function(e){return(e||u).stringify(this)},concat:function(e){var t=this.words,r=e.words,n=this.sigBytes,i=e.sigBytes;if(this.clamp(),n%4)for(var o=0;o<i;o++){var a=r[o>>>2]>>>24-o%4*8&255;t[n+o>>>2]|=a<<24-(n+o)%4*8}else for(var s=0;s<i;s+=4)t[n+s>>>2]=r[s>>>2];return this.sigBytes+=i,this},clamp:function(){var t=this.words,r=this.sigBytes;t[r>>>2]&=4294967295<<32-r%4*8,t.length=e.ceil(r/4)},clone:function(){var e,t=s.clone.call(this);return t.words=slice$1(e=this.words).call(e,0),t},random:function(e){for(var t=[],r=0;r<e;r+=4)t.push(n());return new c.init(t,e)}}),l=o.enc={},u=l.Hex={stringify:function(e){for(var t=e.words,r=e.sigBytes,n=[],i=0;i<r;i++){var o=t[i>>>2]>>>24-i%4*8&255;n.push((o>>>4).toString(16)),n.push((15&o).toString(16))}return n.join("")},parse:function(e){for(var t=e.length,r=[],n=0;n<t;n+=2)r[n>>>3]|=_parseInt$6(e.substr(n,2),16)<<24-n%8*4;return new c.init(r,t/2)}},d=l.Latin1={stringify:function(e){for(var t=e.words,r=e.sigBytes,n=[],i=0;i<r;i++){var o=t[i>>>2]>>>24-i%4*8&255;n.push(String.fromCharCode(o))}return n.join("")},parse:function(e){for(var t=e.length,r=[],n=0;n<t;n++)r[n>>>2]|=(255&e.charCodeAt(n))<<24-n%4*8;return new c.init(r,t)}},p=l.Utf8={stringify:function(e){try{return decodeURIComponent(escape(d.stringify(e)))}catch(e){throw new Error("Malformed UTF-8 data")}},parse:function(e){return d.parse(unescape(encodeURIComponent(e)))}},_=a.BufferedBlockAlgorithm=s.extend({reset:function(){this._data=new c.init,this._nDataBytes=0},_append:function(e){var t;"string"==typeof e&&(e=p.parse(e)),concat$2(t=this._data).call(t,e),this._nDataBytes+=e.sigBytes},_process:function(t){var r,n=this._data,i=n.words,o=n.sigBytes,a=this.blockSize,s=o/(4*a),l=(s=t?e.ceil(s):e.max((0|s)-this._minBufferSize,0))*a,u=e.min(4*l,o);if(l){for(var d=0;d<l;d+=a)this._doProcessBlock(i,d);r=splice$3(i).call(i,0,l),n.sigBytes-=u}return new c.init(r,u)},clone:function(){var e=s.clone.call(this);return e._data=this._data.clone(),e},_minBufferSize:0});a.Hasher=_.extend({cfg:s.extend(),init:function(e){this.cfg=this.cfg.extend(e),this.reset()},reset:function(){_.reset.call(this),this._doReset()},update:function(e){return this._append(e),this._process(),this},finalize:function(e){return e&&this._append(e),this._doFinalize()},blockSize:16,_createHelper:function(e){return function(t,r){return new e.init(r).finalize(t)}},_createHmacHelper:function(e){return function(t,r){return new h.HMAC.init(e,r).finalize(t)}}});var h=o.algo={};return o}(Math),r)}(),function(e,t){var r;libTypedarrays.exports=(r=core.exports,function(){if("function"==typeof ArrayBuffer){var e=r.lib.WordArray,t=e.init,n=e.init=function(e){if(e instanceof ArrayBuffer&&(e=new Uint8Array(e)),(e instanceof Int8Array||"undefined"!=typeof Uint8ClampedArray&&e instanceof Uint8ClampedArray||e instanceof Int16Array||e instanceof Uint16Array||e instanceof Int32Array||e instanceof Uint32Array||e instanceof Float32Array||e instanceof Float64Array)&&(e=new Uint8Array(e.buffer,e.byteOffset,e.byteLength)),e instanceof Uint8Array){for(var r=e.byteLength,n=[],i=0;i<r;i++)n[i>>>2]|=e[i]<<24-i%4*8;t.call(this,n,r)}else t.apply(this,arguments)};n.prototype=e}}(),r.lib.WordArray)}();var WordArray=libTypedarrays.exports,aes={exports:{}},encBase64={exports:{}};!function(e,t){var r;encBase64.exports=(r=core.exports,function(){var e=r,t=e.lib.WordArray;function n(e,r,n){for(var i=[],o=0,a=0;a<r;a++)if(a%4){var s=n[e.charCodeAt(a-1)]<<a%4*2|n[e.charCodeAt(a)]>>>6-a%4*2;i[o>>>2]|=s<<24-o%4*8,o++}return t.create(i,o)}e.enc.Base64={stringify:function(e){var t=e.words,r=e.sigBytes,n=this._map;e.clamp();for(var i=[],o=0;o<r;o+=3)for(var a=(t[o>>>2]>>>24-o%4*8&255)<<16|(t[o+1>>>2]>>>24-(o+1)%4*8&255)<<8|t[o+2>>>2]>>>24-(o+2)%4*8&255,s=0;s<4&&o+.75*s<r;s++)i.push(n.charAt(a>>>6*(3-s)&63));var c=n.charAt(64);if(c)for(;i.length%4;)i.push(c);return i.join("")},parse:function(e){var t=e.length,r=this._map,i=this._reverseMap;if(!i){i=this._reverseMap=[];for(var o=0;o<r.length;o++)i[r.charCodeAt(o)]=o}var a=r.charAt(64);if(a){var s=indexOf2(e).call(e,a);-1!==s&&(t=s)}return n(e,t,i)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="}}(),r.enc.Base64)}();var md5={exports:{}};!function(e,t){var r;md5.exports=(r=core.exports,function(e){var t=r,n=t.lib,i=n.WordArray,o=n.Hasher,a=t.algo,s=[];!function(){for(var t=0;t<64;t++)s[t]=4294967296*e.abs(e.sin(t+1))|0}();var c=a.MD5=o.extend({_doReset:function(){this._hash=new i.init([1732584193,4023233417,2562383102,271733878])},_doProcessBlock:function(e,t){for(var r=0;r<16;r++){var n=t+r,i=e[n];e[n]=16711935&(i<<8|i>>>24)|4278255360&(i<<24|i>>>8)}var o=this._hash.words,a=e[t+0],c=e[t+1],_=e[t+2],h=e[t+3],f=e[t+4],m=e[t+5],v=e[t+6],g=e[t+7],y=e[t+8],S=e[t+9],T=e[t+10],$=e[t+11],E=e[t+12],b=e[t+13],I=e[t+14],R=e[t+15],C=o[0],A=o[1],k=o[2],P=o[3];C=l(C,A,k,P,a,7,s[0]),P=l(P,C,A,k,c,12,s[1]),k=l(k,P,C,A,_,17,s[2]),A=l(A,k,P,C,h,22,s[3]),C=l(C,A,k,P,f,7,s[4]),P=l(P,C,A,k,m,12,s[5]),k=l(k,P,C,A,v,17,s[6]),A=l(A,k,P,C,g,22,s[7]),C=l(C,A,k,P,y,7,s[8]),P=l(P,C,A,k,S,12,s[9]),k=l(k,P,C,A,T,17,s[10]),A=l(A,k,P,C,$,22,s[11]),C=l(C,A,k,P,E,7,s[12]),P=l(P,C,A,k,b,12,s[13]),k=l(k,P,C,A,I,17,s[14]),C=u(C,A=l(A,k,P,C,R,22,s[15]),k,P,c,5,s[16]),P=u(P,C,A,k,v,9,s[17]),k=u(k,P,C,A,$,14,s[18]),A=u(A,k,P,C,a,20,s[19]),C=u(C,A,k,P,m,5,s[20]),P=u(P,C,A,k,T,9,s[21]),k=u(k,P,C,A,R,14,s[22]),A=u(A,k,P,C,f,20,s[23]),C=u(C,A,k,P,S,5,s[24]),P=u(P,C,A,k,I,9,s[25]),k=u(k,P,C,A,h,14,s[26]),A=u(A,k,P,C,y,20,s[27]),C=u(C,A,k,P,b,5,s[28]),P=u(P,C,A,k,_,9,s[29]),k=u(k,P,C,A,g,14,s[30]),C=d(C,A=u(A,k,P,C,E,20,s[31]),k,P,m,4,s[32]),P=d(P,C,A,k,y,11,s[33]),k=d(k,P,C,A,$,16,s[34]),A=d(A,k,P,C,I,23,s[35]),C=d(C,A,k,P,c,4,s[36]),P=d(P,C,A,k,f,11,s[37]),k=d(k,P,C,A,g,16,s[38]),A=d(A,k,P,C,T,23,s[39]),C=d(C,A,k,P,b,4,s[40]),P=d(P,C,A,k,a,11,s[41]),k=d(k,P,C,A,h,16,s[42]),A=d(A,k,P,C,v,23,s[43]),C=d(C,A,k,P,S,4,s[44]),P=d(P,C,A,k,E,11,s[45]),k=d(k,P,C,A,R,16,s[46]),C=p(C,A=d(A,k,P,C,_,23,s[47]),k,P,a,6,s[48]),P=p(P,C,A,k,g,10,s[49]),k=p(k,P,C,A,I,15,s[50]),A=p(A,k,P,C,m,21,s[51]),C=p(C,A,k,P,E,6,s[52]),P=p(P,C,A,k,h,10,s[53]),k=p(k,P,C,A,T,15,s[54]),A=p(A,k,P,C,c,21,s[55]),C=p(C,A,k,P,y,6,s[56]),P=p(P,C,A,k,R,10,s[57]),k=p(k,P,C,A,v,15,s[58]),A=p(A,k,P,C,b,21,s[59]),C=p(C,A,k,P,f,6,s[60]),P=p(P,C,A,k,$,10,s[61]),k=p(k,P,C,A,_,15,s[62]),A=p(A,k,P,C,S,21,s[63]),o[0]=o[0]+C|0,o[1]=o[1]+A|0,o[2]=o[2]+k|0,o[3]=o[3]+P|0},_doFinalize:function(){var t=this._data,r=t.words,n=8*this._nDataBytes,i=8*t.sigBytes;r[i>>>5]|=128<<24-i%32;var o=e.floor(n/4294967296),a=n;r[15+(i+64>>>9<<4)]=16711935&(o<<8|o>>>24)|4278255360&(o<<24|o>>>8),r[14+(i+64>>>9<<4)]=16711935&(a<<8|a>>>24)|4278255360&(a<<24|a>>>8),t.sigBytes=4*(r.length+1),this._process();for(var s=this._hash,c=s.words,l=0;l<4;l++){var u=c[l];c[l]=16711935&(u<<8|u>>>24)|4278255360&(u<<24|u>>>8)}return s},clone:function(){var e=o.clone.call(this);return e._hash=this._hash.clone(),e}});function l(e,t,r,n,i,o,a){var s=e+(t&r|~t&n)+i+a;return(s<<o|s>>>32-o)+t}function u(e,t,r,n,i,o,a){var s=e+(t&n|r&~n)+i+a;return(s<<o|s>>>32-o)+t}function d(e,t,r,n,i,o,a){var s=e+(t^r^n)+i+a;return(s<<o|s>>>32-o)+t}function p(e,t,r,n,i,o,a){var s=e+(r^(t|~n))+i+a;return(s<<o|s>>>32-o)+t}t.MD5=o._createHelper(c),t.HmacMD5=o._createHmacHelper(c)}(Math),r.MD5)}();var evpkdf={exports:{}},sha1={exports:{}};!function(e,t){var r,n,i,o,a,s,c,l;sha1.exports=(l=core.exports,n=(r=l).lib,i=n.WordArray,o=n.Hasher,a=r.algo,s=[],c=a.SHA1=o.extend({_doReset:function(){this._hash=new i.init([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(e,t){for(var r=this._hash.words,n=r[0],i=r[1],o=r[2],a=r[3],c=r[4],l=0;l<80;l++){if(l<16)s[l]=0|e[t+l];else{var u=s[l-3]^s[l-8]^s[l-14]^s[l-16];s[l]=u<<1|u>>>31}var d=(n<<5|n>>>27)+c+s[l];d+=l<20?1518500249+(i&o|~i&a):l<40?1859775393+(i^o^a):l<60?(i&o|i&a|o&a)-1894007588:(i^o^a)-899497514,c=a,a=o,o=i<<30|i>>>2,i=n,n=d}r[0]=r[0]+n|0,r[1]=r[1]+i|0,r[2]=r[2]+o|0,r[3]=r[3]+a|0,r[4]=r[4]+c|0},_doFinalize:function(){var e=this._data,t=e.words,r=8*this._nDataBytes,n=8*e.sigBytes;return t[n>>>5]|=128<<24-n%32,t[14+(n+64>>>9<<4)]=Math.floor(r/4294967296),t[15+(n+64>>>9<<4)]=r,e.sigBytes=4*t.length,this._process(),this._hash},clone:function(){var e=o.clone.call(this);return e._hash=this._hash.clone(),e}}),r.SHA1=o._createHelper(c),r.HmacSHA1=o._createHmacHelper(c),l.SHA1)}();var hmac={exports:{}};!function(e,t){var r,n,i,o;hmac.exports=(r=core.exports,i=(n=r).lib.Base,o=n.enc.Utf8,void(n.algo.HMAC=i.extend({init:function(e,t){e=this._hasher=new e.init,"string"==typeof t&&(t=o.parse(t));var r=e.blockSize,n=4*r;t.sigBytes>n&&(t=e.finalize(t)),t.clamp();for(var i=this._oKey=t.clone(),a=this._iKey=t.clone(),s=i.words,c=a.words,l=0;l<r;l++)s[l]^=1549556828,c[l]^=909522486;i.sigBytes=a.sigBytes=n,this.reset()},reset:function(){var e=this._hasher;e.reset(),e.update(this._iKey)},update:function(e){return this._hasher.update(e),this},finalize:function(e){var t,r=this._hasher,n=r.finalize(e);return r.reset(),r.finalize(concat$2(t=this._oKey.clone()).call(t,n))}})))}(),function(e,t){var r,n,i,o,a,s,c,l;evpkdf.exports=(l=core.exports,sha1.exports,hmac.exports,n=(r=l).lib,i=n.Base,o=n.WordArray,a=r.algo,s=a.MD5,c=a.EvpKDF=i.extend({cfg:i.extend({keySize:4,hasher:s,iterations:1}),init:function(e){this.cfg=this.cfg.extend(e)},compute:function(e,t){for(var r,n=this.cfg,i=n.hasher.create(),a=o.create(),s=a.words,c=n.keySize,l=n.iterations;s.length<c;){r&&i.update(r),r=i.update(e).finalize(t),i.reset();for(var u=1;u<l;u++)r=i.finalize(r),i.reset();concat$2(a).call(a,r)}return a.sigBytes=4*c,a}}),r.EvpKDF=function(e,t,r){return c.create(r).compute(e,t)},l.EvpKDF)}();var cipherCore={exports:{}};!function(e,t){var r;cipherCore.exports=(r=core.exports,evpkdf.exports,void(r.lib.Cipher||function(e){var t=r,n=t.lib,i=n.Base,o=n.WordArray,a=n.BufferedBlockAlgorithm,s=t.enc;s.Utf8;var c=s.Base64,l=t.algo.EvpKDF,u=n.Cipher=a.extend({cfg:i.extend(),createEncryptor:function(e,t){return this.create(this._ENC_XFORM_MODE,e,t)},createDecryptor:function(e,t){return this.create(this._DEC_XFORM_MODE,e,t)},init:function(e,t,r){this.cfg=this.cfg.extend(r),this._xformMode=e,this._key=t,this.reset()},reset:function(){a.reset.call(this),this._doReset()},process:function(e){return this._append(e),this._process()},finalize:function(e){return e&&this._append(e),this._doFinalize()},keySize:4,ivSize:4,_ENC_XFORM_MODE:1,_DEC_XFORM_MODE:2,_createHelper:function(){function e(e){return"string"==typeof e?y:v}return function(t){return{encrypt:function(r,n,i){return e(n).encrypt(t,r,n,i)},decrypt:function(r,n,i){return e(n).decrypt(t,r,n,i)}}}}()});n.StreamCipher=u.extend({_doFinalize:function(){return this._process(!0)},blockSize:1});var d=t.mode={},p=n.BlockCipherMode=i.extend({createEncryptor:function(e,t){return this.Encryptor.create(e,t)},createDecryptor:function(e,t){return this.Decryptor.create(e,t)},init:function(e,t){this._cipher=e,this._iv=t}}),_=d.CBC=function(){var t=p.extend();function r(t,r,n){var i,o=this._iv;o?(i=o,this._iv=e):i=this._prevBlock;for(var a=0;a<n;a++)t[r+a]^=i[a]}return t.Encryptor=t.extend({processBlock:function(e,t){var n=this._cipher,i=n.blockSize;r.call(this,e,t,i),n.encryptBlock(e,t),this._prevBlock=slice$1(e).call(e,t,t+i)}}),t.Decryptor=t.extend({processBlock:function(e,t){var n=this._cipher,i=n.blockSize,o=slice$1(e).call(e,t,t+i);n.decryptBlock(e,t),r.call(this,e,t,i),this._prevBlock=o}}),t}(),h=(t.pad={}).Pkcs7={pad:function(e,t){for(var r=4*t,n=r-e.sigBytes%r,i=n<<24|n<<16|n<<8|n,a=[],s=0;s<n;s+=4)a.push(i);var c=o.create(a,n);concat$2(e).call(e,c)},unpad:function(e){var t=255&e.words[e.sigBytes-1>>>2];e.sigBytes-=t}};n.BlockCipher=u.extend({cfg:u.cfg.extend({mode:_,padding:h}),reset:function(){var e;u.reset.call(this);var t=this.cfg,r=t.iv,n=t.mode;this._xformMode==this._ENC_XFORM_MODE?e=n.createEncryptor:(e=n.createDecryptor,this._minBufferSize=1),this._mode&&this._mode.__creator==e?this._mode.init(this,r&&r.words):(this._mode=e.call(n,this,r&&r.words),this._mode.__creator=e)},_doProcessBlock:function(e,t){this._mode.processBlock(e,t)},_doFinalize:function(){var e,t=this.cfg.padding;return this._xformMode==this._ENC_XFORM_MODE?(t.pad(this._data,this.blockSize),e=this._process(!0)):(e=this._process(!0),t.unpad(e)),e},blockSize:4});var f=n.CipherParams=i.extend({init:function(e){this.mixIn(e)},toString:function(e){return(e||this.formatter).stringify(this)}}),m=(t.format={}).OpenSSL={stringify:function(e){var t,r,n=e.ciphertext,i=e.salt;return(i?concat$2(t=concat$2(r=o.create([1398893684,1701076831])).call(r,i)).call(t,n):n).toString(c)},parse:function(e){var t,r=c.parse(e),n=r.words;return 1398893684==n[0]&&1701076831==n[1]&&(t=o.create(slice$1(n).call(n,2,4)),splice$3(n).call(n,0,4),r.sigBytes-=16),f.create({ciphertext:r,salt:t})}},v=n.SerializableCipher=i.extend({cfg:i.extend({format:m}),encrypt:function(e,t,r,n){n=this.cfg.extend(n);var i=e.createEncryptor(r,n),o=i.finalize(t),a=i.cfg;return f.create({ciphertext:o,key:r,iv:a.iv,algorithm:e,mode:a.mode,padding:a.padding,blockSize:e.blockSize,formatter:n.format})},decrypt:function(e,t,r,n){return n=this.cfg.extend(n),t=this._parse(t,n.format),e.createDecryptor(r,n).finalize(t.ciphertext)},_parse:function(e,t){return"string"==typeof e?t.parse(e,this):e}}),g=(t.kdf={}).OpenSSL={execute:function(e,t,r,n,i){var a;if(n||(n=o.random(8)),i)s=l.create({keySize:t+r,hasher:i}).compute(e,n);else var s=l.create({keySize:t+r}).compute(e,n);var c=o.create(slice$1(a=s.words).call(a,t),4*r);return s.sigBytes=4*t,f.create({key:s,iv:c,salt:n})}},y=n.PasswordBasedCipher=v.extend({cfg:v.cfg.extend({kdf:g}),encrypt:function(e,t,r,n){var i=(n=this.cfg.extend(n)).kdf.execute(r,e.keySize,e.ivSize,n.salt,n.hasher);n.iv=i.iv;var o=v.encrypt.call(this,e,t,i.key,n);return o.mixIn(i),o},decrypt:function(e,t,r,n){n=this.cfg.extend(n),t=this._parse(t,n.format);var i=n.kdf.execute(r,e.keySize,e.ivSize,t.salt,n.hasher);return n.iv=i.iv,v.decrypt.call(this,e,t,i.key,n)}})}()))}(),function(e,t){var r;aes.exports=(r=core.exports,encBase64.exports,md5.exports,evpkdf.exports,cipherCore.exports,function(){var e=r,t=e.lib.BlockCipher,n=e.algo,i=[],o=[],a=[],s=[],c=[],l=[],u=[],d=[],p=[],_=[];!function(){for(var e=[],t=0;t<256;t++)e[t]=t<128?t<<1:t<<1^283;var r=0,n=0;for(t=0;t<256;t++){var h=n^n<<1^n<<2^n<<3^n<<4;h=h>>>8^255&h^99,i[r]=h,o[h]=r;var f=e[r],m=e[f],v=e[m],g=257*e[h]^16843008*h;a[r]=g<<24|g>>>8,s[r]=g<<16|g>>>16,c[r]=g<<8|g>>>24,l[r]=g,g=16843009*v^65537*m^257*f^16843008*r,u[h]=g<<24|g>>>8,d[h]=g<<16|g>>>16,p[h]=g<<8|g>>>24,_[h]=g,r?(r=f^e[e[e[v^f]]],n^=e[e[n]]):r=n=1}}();var h=[0,1,2,4,8,16,32,64,128,27,54],f=n.AES=t.extend({_doReset:function(){if(!this._nRounds||this._keyPriorReset!==this._key){for(var e=this._keyPriorReset=this._key,t=e.words,r=e.sigBytes/4,n=4*((this._nRounds=r+6)+1),o=this._keySchedule=[],a=0;a<n;a++)a<r?o[a]=t[a]:(l=o[a-1],a%r?r>6&&a%r==4&&(l=i[l>>>24]<<24|i[l>>>16&255]<<16|i[l>>>8&255]<<8|i[255&l]):(l=i[(l=l<<8|l>>>24)>>>24]<<24|i[l>>>16&255]<<16|i[l>>>8&255]<<8|i[255&l],l^=h[a/r|0]<<24),o[a]=o[a-r]^l);for(var s=this._invKeySchedule=[],c=0;c<n;c++){if(a=n-c,c%4)var l=o[a];else l=o[a-4];s[c]=c<4||a<=4?l:u[i[l>>>24]]^d[i[l>>>16&255]]^p[i[l>>>8&255]]^_[i[255&l]]}}},encryptBlock:function(e,t){this._doCryptBlock(e,t,this._keySchedule,a,s,c,l,i)},decryptBlock:function(e,t){var r=e[t+1];e[t+1]=e[t+3],e[t+3]=r,this._doCryptBlock(e,t,this._invKeySchedule,u,d,p,_,o),r=e[t+1],e[t+1]=e[t+3],e[t+3]=r},_doCryptBlock:function(e,t,r,n,i,o,a,s){for(var c=this._nRounds,l=e[t]^r[0],u=e[t+1]^r[1],d=e[t+2]^r[2],p=e[t+3]^r[3],_=4,h=1;h<c;h++){var f=n[l>>>24]^i[u>>>16&255]^o[d>>>8&255]^a[255&p]^r[_++],m=n[u>>>24]^i[d>>>16&255]^o[p>>>8&255]^a[255&l]^r[_++],v=n[d>>>24]^i[p>>>16&255]^o[l>>>8&255]^a[255&u]^r[_++],g=n[p>>>24]^i[l>>>16&255]^o[u>>>8&255]^a[255&d]^r[_++];l=f,u=m,d=v,p=g}f=(s[l>>>24]<<24|s[u>>>16&255]<<16|s[d>>>8&255]<<8|s[255&p])^r[_++],m=(s[u>>>24]<<24|s[d>>>16&255]<<16|s[p>>>8&255]<<8|s[255&l])^r[_++],v=(s[d>>>24]<<24|s[p>>>16&255]<<16|s[l>>>8&255]<<8|s[255&u])^r[_++],g=(s[p>>>24]<<24|s[l>>>16&255]<<16|s[u>>>8&255]<<8|s[255&d])^r[_++],e[t]=f,e[t+1]=m,e[t+2]=v,e[t+3]=g},keySize:8});e.AES=t._createHelper(f)}(),r.AES)}();var encHex$1={exports:{}};encHex$1.exports=core.exports.enc.Hex;var encHex=encHex$1.exports,modeCtr={exports:{}};!function(e,t){var r,n,i;modeCtr.exports=(i=core.exports,cipherCore.exports,i.mode.CTR=(r=i.lib.BlockCipherMode.extend(),n=r.Encryptor=r.extend({processBlock:function(e,t){var r=this._cipher,n=r.blockSize,i=this._iv,o=this._counter;i&&(o=this._counter=slice$1(i).call(i,0),this._iv=void 0);var a=slice$1(o).call(o,0);r.encryptBlock(a,0),o[n-1]=o[n-1]+1|0;for(var s=0;s<n;s++)e[t+s]^=a[s]}}),r.Decryptor=n,r),i.mode.CTR)}();var ModeCTR=modeCtr.exports,padNopadding={exports:{}};!function(e,t){var r;padNopadding.exports=(r=core.exports,cipherCore.exports,r.pad.NoPadding={pad:function(){},unpad:function(){}},r.pad.NoPadding)}();var _navigator$userAgent$,_navigator$userAgent$2,_context4,_navigator$userAgent$3,_ref,_navigator$userAgent$4,_navigator$userAgent$5,_context5,PadNoPadding=padNopadding.exports,textDecoder=new TextDecoder,textEncoder=new TextEncoder,genUuid2=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),l=0,u=0,d=n;u<d.length;u++){var p=d[u];c.set(p,l),l+=p.length}return c}var isSSR2=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){var n;return window.btoa(filter3(n=[e,t,r]).call(n,(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=entries2(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 getBrowser(){var e="none";return isSSR2()||(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}function getStatsCallbackSupport(){if("chrome-stable"===getBrowser()){var e=window.navigator.userAgent.match(/Chrome\/([\d.]+)/);if(e&&e.length>1)if(Number(e[1].split(".")[0])<114)return!0}return!1}var isStatsCallbackSupport=getStatsCallbackSupport(),isFirefox="mozilla"===getBrowser(),isSafari="safari"===getBrowser(),sv=0,v=!isSSR2()&&(null===(_navigator$userAgent$=navigator.userAgent.match(/version\/(\d+)/i))||void 0===_navigator$userAgent$?void 0:_navigator$userAgent$[1]);isSafari&&v&&(sv=+v);var v2=!isSSR2()&&(null===(_navigator$userAgent$2=navigator.userAgent.match(/Firefox\/(\d+)/i))||void 0===_navigator$userAgent$2?void 0:_navigator$userAgent$2[1]);isFirefox&&v2&&(sv=+v2);var safariVersion=sv,firefoxVersion=sv,isIOS=!isSSR2()&&!!/(iPhone|iPad|iPod)/i.exec(navigator.userAgent);!isSSR2()&&/(iPhone|iPod)/i.exec(navigator.userAgent);var isIPad=!isSSR2()&&(!!/(iPad)/i.exec(navigator.userAgent)||/Macintosh/i.test(navigator.userAgent)&&"ontouchend"in document),isWeChat=!isSSR2()&&/MicroMessenger/i.test(navigator.userAgent),isAndroid=!isSSR2()&&/Android/i.test(navigator.userAgent),isMobile=!isSSR2()&&includes4(_context4=navigator.userAgent.toLowerCase()).call(_context4,"mobile"),cv=0,cvs=!isSSR2()&&(null===(_navigator$userAgent$3=navigator.userAgent.match(/chrome\/(\d+)/i))||void 0===_navigator$userAgent$3?void 0:_navigator$userAgent$3[1]);cvs&&(cv=+cvs);var chromeVersion=cv,iOSVersion=null!==(_ref=!isSSR2()&&(null===(_navigator$userAgent$4=navigator.userAgent.match(/ ([\d_]+) like Mac OS X/i))||void 0===_navigator$userAgent$4||null===(_navigator$userAgent$5=_navigator$userAgent$4[1])||void 0===_navigator$userAgent$5?void 0:map$6(_context5=_navigator$userAgent$5.split("_")).call(_context5,(function(e){return _parseInt$6(e)}))))&&void 0!==_ref?_ref:[],isCriOS=!isSSR2()&&/CriOS/i.test(navigator.userAgent);function createRandomId(){for(var e,t,r=(+padEnd2(e=slice$1(t="".concat(Math.random())).call(t,-7)).call(e,7,"0")).toString(2),n=padEnd2(r).call(r,28,"1").split(""),i=[];n.length;)i.push(splice$3(n).call(n,0,7));return map$6(i).call(i,(function(e,t){var r=t===i.length-1?"0":"1";return _parseInt(r+e.join(""),2)}))}!isSSR2()&&/SM-\w+/i.test(navigator.userAgent);var genEventSessionId=function(){return Math.floor(65535*Math.random())};function isByteId(e){return 128==(128&e)}function isRttMessage(e){return"string"==typeof e&&indexOf2(e).call(e,"__web__rtc__rtt__")>-1}function randomNum(e){for(var t="",r=0;r<e;r++)t+=Math.floor(10*Math.random());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],(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=8,r.createOffer();case 8:return n=e.sent,r.close(),e.abrupt("return",n.sdp);case 11:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),promiseAny2=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*log102(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 keys$8(e).forEach((function(r){"object"===_typeof(e[r])?t[r]=getPublicStats(e[r]):startsWith2(r).call(r,"_")||(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}function MediaTrackStringify(e){return null==e?"undefined | null":"string"==typeof e?e:stringify$1({contentHint:e.contentHint,enabled:e.enabled,id:e.id,kind:e.kind,label:e.label,muted:e.muted,readyState:e.readyState})}function MediaStreamStringify(e){return null==e?"undefined | null":"string"==typeof e?e:stringify$1({id:e.id,active:e.active})}function MediaSenderStringify(e){return null==e?"undefined | null":"string"==typeof e?e:stringify$1({track:MediaTrackStringify(e.track)})}function MediaReceiverStringify(e){return null==e?"undefined | null":"string"==typeof e?e:stringify$1({track:MediaTrackStringify(e.track)})}function MediaTransceiverStringify(e){return null==e?"undefined | null":"string"==typeof e?e:stringify$1({currentDirection:e.currentDirection,direction:e.direction,mid:e.mid,stopped:e.stopped,receiver:MediaReceiverStringify(e.receiver),sender:MediaSenderStringify(e.sender)})}function isUndefined(e){return void 0===e}function warnDeprecatedApi(e){return function(t,r,n){var i=n.value;n.value=function(){var t;console.warn(concat$2(t="[RTC WebSDK]: Api: ".concat(r," has been abandoned from version ")).call(t,e));for(var n=arguments.length,o=new Array(n),a=0;a<n;a++)o[a]=arguments[a];return i.apply(this,o)}}}function warnDevelopers(e){console.warn("[RTC WebSDK]: "+e)}function constraints2number(e){return"number"==typeof e?e:"number"==typeof(null==e?void 0:e.exact)?e.exact:"number"==typeof(null==e?void 0:e.ideal)?e.ideal:"number"==typeof(null==e?void 0:e.max)?e.max:"number"==typeof(null==e?void 0:e.min)?e.min:1}function setJoinRoomInfo(e,t,r){if("function"==typeof r.value){var n=r.value;r.value=function(){for(var e,t=getMonitor(this.id),r=arguments.length,i=new Array(r),o=0;o<r;o++)i[o]=arguments[o];return null==t||t.set({room_id:i[1],user_id:null===(e=i[2])||void 0===e?void 0:e.userId}),n.apply(this,i)}}}function base64ToUint8(e){for(var t=atob(e),r=t.length,n=new Uint8Array(r),i=0;i<r;i++)n[i]=t.charCodeAt(i);return n}function uint8ToBase64(e){for(var t="",r=e.byteLength,n=0;n<r;n++)t+=String.fromCharCode(e[n]);return btoa(t)}function aesCtrEncrypt(e,t,r){var n=uint8ArrayToWordArray(e),i=uint8ArrayToWordArray(t),o=uint8ArrayToWordArray(r);return wordArrayToUint8Array(aes.exports.encrypt(n,i,{iv:o,mode:ModeCTR,padding:PadNoPadding}).ciphertext)}function wordArrayToUint8Array(e){for(var t=e.toString(encHex),r=new Uint8Array(t.length/2),n=0;n<t.length;n+=2)r[n/2]=_parseInt$6(t.substr(n,2),16);return r}function uint8ArrayToWordArray(e){for(var t=[],r=0;r<e.length;r+=4)t.push(e[r]<<24|(e[r+1]||0)<<16|(e[r+2]||0)<<8|(e[r+3]||0));return WordArray.create(t,e.length)}var EngineEventsTypes=function(e){return e.onTrackEnded="onTrackEnded",e.onTrackMute="onTrackMute",e.onTrackUnmute="onTrackUnmute",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.onRemoteVideoFirstFrame="onRemoteVideoFirstFrame",e.onAudioFirstFrameDecoded="onAudioFirstFrameDecoded",e.onRemoteAudioFirstFrame="onRemoteAudioFirstFrame",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.onSubtitleStateChanged="onSubtitleStateChanged",e.onSubtitleMessageReceived="onSubtitleMessageReceived",e.onServerParamsSetResult="onServerParamsSetResult",e}(EngineEventsTypes||{}),PLATFORM_KEY="BytePlus",RTC_DEVICE_ID="RTC_DEVICE_ID",RTC_ACCESS_NODE="RTC_ACCESS_NODE",RTC_ACCESS_URLS="RTC_ACCESS_URLS",ENGINE_WEB_CONFIG="ENGINE_WEB_CONFIG",SERVER_CONFIG="SERVER_CONFIG",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,stringify$1(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(){var e,n;_classCallCheck(this,r);for(var i=arguments.length,o=new Array(i),a=0;a<i;a++)o[a]=arguments[a];return _defineProperty(_assertThisInitialized(n=t.call.apply(t,concat$2(e=[this]).call(e,o))),"_accessVersion","v2"),n}return _createClass(r,[{key:"getDeviceId",value:function(){if(isSSR2())return"";var e=this.get(RTC_DEVICE_ID);return e&&!/^[0-9a-f]{8}(-[0-9a-f]{4}){3}-[0-9a-f]{12}$/.test(e)||(e=randomNum(30)),this.setDeviceId(e),e}},{key:"setDeviceId",value:function(e){return setGlobalStats({device_id:e}),this.set(RTC_DEVICE_ID,e),e}},{key:"getAccessNode",value:function(e){var t,r;return this.get(concat$2(t=concat$2(r="".concat(RTC_ACCESS_NODE,"_").concat(e,"-")).call(r,PLATFORM_KEY,"-")).call(t,this._accessVersion))}},{key:"setAccessNode",value:function(e,t,r){var n,i;return this.set(concat$2(n=concat$2(i="".concat(RTC_ACCESS_NODE,"_").concat(e,"-")).call(i,PLATFORM_KEY,"-")).call(n,this._accessVersion),t,1e3*r)}},{key:"clearAccessNode",value:function(e){var t;this.delete(concat$2(t="".concat(RTC_ACCESS_NODE,"_").concat(e,"-")).call(t,PLATFORM_KEY))}},{key:"getAccessUrls",value:function(){return this.get("".concat(RTC_ACCESS_URLS,"-").concat(PLATFORM_KEY))}},{key:"setAccessUrls",value:function(e){var t=map$6(e).call(e,(function(e){var t,r=e.host,n=e.path;return concat$2(t="https://".concat(r)).call(t,n)}));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:"getEngineWebConfig",value:function(e,t){var r,n,i,o=concat$2(r=concat$2(n="".concat(e,"_")).call(n,t,"_")).call(r,this.getDeviceId()),a=this.get(ENGINE_WEB_CONFIG);return(null==a||null===(i=find$2(a).call(a,(function(e){return e.key===o})))||void 0===i?void 0:i.config)||{}}},{key:"setEngineWebConfig",value:function(e,t,r){var n,i;if(r){var o=concat$2(n=concat$2(i="".concat(e,"_")).call(i,t,"_")).call(n,this.getDeviceId()),a=this.get(ENGINE_WEB_CONFIG)||[];return(a=filter3(a).call(a,(function(e){return e.key!==o}))).push({key:o,config:r}),this.set(ENGINE_WEB_CONFIG,slice$1(a).call(a,-5))}}},{key:"getServerConfig",value:function(e){var t,r="".concat(e),n=this.get(SERVER_CONFIG);return(null==n||null===(t=find$2(n).call(n,(function(e){return e.key===r})))||void 0===t?void 0:t.config)||{}}},{key:"setServerConfig",value:function(e,t){if(t){var r="".concat(e),n=this.get(SERVER_CONFIG)||[];return(n=filter3(n).call(n,(function(e){return e.key!==r}))).push({key:r,config:t}),this.set(SERVER_CONFIG,slice$1(n).call(n,-5))}}}]),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.52.10",ICE_CONFIG_REQUEST_URLS_INTERNAL:map$6(internalAccessDomains).call(internalAccessDomains,getFullAccessUrl),ICE_CONFIG_REQUEST_URLS:[],EXPECTED_ADDR:"",LOG_SERVER_URL:domesticLogServerUrl,CONFIG_REQUEST_DOMAINS:configDomains,DEVICE_ID:"",OVERSEA:!1,PLATFORM:"",PRODUCT:"",FORCE_ENABLED_REPORT_CALLBACKS:[],SKIP_WEB_AUDIO_IN_TRACK:!1,AUDIO_STALL:!0,VIDEO_STALL:!0,STATS_SCALLBACK_SUPPORT:!0,ENABLE_REPORT_ERROR_BUFFER:!1,PUB_SUB_MODE:"recv_and_send",ENABLE_FALLBACK_HANDLER:!1};function setParameter(e,t){var r;if(reportGlobalApiCall("setParameter",0,concat$2(r="key: ".concat(e,", value: ")).call(r,t)),"VERSION"!==e){if("ICE_CONFIG_REQUEST_URLS"===e)return"string"==typeof t&&(t=[t]),void(Config.ICE_CONFIG_REQUEST_URLS=map$6(t).call(t,getFullAccessUrl));if("PLATFORM"!==e||"string"!=typeof t)if("PRODUCT"!==e||"string"!=typeof t){if("FORCE_ENABLED_REPORT_CALLBACKS"===e)return"string"==typeof t&&(t=[t]),void(Config.FORCE_ENABLED_REPORT_CALLBACKS=t);if("LOG_SERVER_URL"===e){var n=t===LogChannel.overseas?overseasLogServerUrl:t===LogChannel.domestic?domesticLogServerUrl:"string"==typeof t?t:void 0;n&&(Config.LOG_SERVER_URL=n,setReportUrl(n))}else if("OVERSEA"===e)return setGlobalStats({extra_is_oversea:t?"1":"0"}),void(Config.OVERSEA=t);"DEVICE_ID"===e&&sdkCache.setDeviceId(t),"ENABLE_REPORT_ERROR_BUFFER"===e&&t&&enableErrorBuffer(),Config[e]=t}else setGlobalStats({product:t});else setGlobalStats({platform:t})}}function getParameter(e){return"DEVICE_ID"===e?sdkCache.getDeviceId():Config[e]}function getPublicStreamControlMessage(e,t,r){var n,i,o,a,s,c,l,u,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===(l=r.layout)||void 0===l?void 0:l.backgroundImage)||""},regions:(null===(u=r.layout)||void 0===u||null===(d=u.regions)||void 0===d?void 0:map$6(d).call(d,(function(e){return{roomId:e.roomId,userId:e.userId,alterImage:e.alertImage||"",alpha:!e.alpha||+e.alpha>1||+e.alpha<=0?1:+e.alpha,x:!e.x||+e.x>=1||+e.x<0?0:+e.x,y:!e.y||+e.y>=1||+e.y<0?0:+e.y,w:!e.w||+e.w>1||+e.w<=0?1:+e.w,h:!e.h||+e.h>1||+e.h<=0?1:+e.h,zorder:!e.zorder||+e.zorder<0||+e.zorder>100?0:+e.zorder,renderMode:void 0===e.renderMode?1:e.renderMode,streamType:e.isScreenStream?1:0,mediaType:e.mediaType||0,sourceCrop:e.sourceCrop}})))||[]}}}}var defaultVideoEncoderConfig={width:640,height:480,frameRate:15,maxKbps:600},defaultScreenEncoderConfig={width:1920,height:1080,frameRate:15,maxKbps:3e3};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,o,a=new SDKError(ErrorCode.INVALID_PARAMS,concat$2(i=concat$2(o="Invalid ".concat(t,": the value range is [")).call(o,r,", ")).call(i,n,"]. integer only"));throw a}}function checkString(e,t){var r,n,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,o=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,i,o))throw new SDKError(ErrorCode.INVALID_PARAMS,concat$2(r=concat$2(n="Invalid ".concat(t,": The value should be string type. Length of the string: [")).call(n,i,",")).call(r,o,"]"))}function checkEnum(e,t,r){var n;if(!includes4(r).call(r,e))throw new SDKError(ErrorCode.INVALID_PARAMS,concat$2(n="Invalid ".concat(t,": The value can only be set as ")).call(n,stringify$1(r)))}function checkMediaStreamTrack(e){if(!(e instanceof MediaStreamTrack))throw new SDKError(ErrorCode.INVALID_PARAMS,"Invalid track, The value should be MediaStreamTrack type.")}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=keys$8(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"),isEmpty(e.roomProfileType)||checkEnum(e.roomProfileType,"roomConfig",[RoomProfileType.communication,RoomProfileType.chat,RoomProfileType.chatRoom,RoomProfileType.coHost,RoomProfileType.meeting,RoomProfileType.classRoom])}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(stringify$1(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){var t,r=getParameter("FORCE_ENABLED_REPORT_CALLBACKS");return!(null==r||!includes4(r).call(r,e))||!includes4(t=[EngineEventsTypes.onRemoteStreamStats,EngineEventsTypes.onLocalStreamStats,EngineEventsTypes.onAudioVolumeIndication,EngineEventsTypes.onLocalAudioPropertiesReport,EngineEventsTypes.onRemoteAudioPropertiesReport]).call(t,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")}function checkConstrainULongg(e,t){if("number"!=typeof e||Number.isNaN(e)||!(e>=1)){var r=e;if(!(null!=r&&r.min||null!=r&&r.max||null!=r&&r.exact||null!=r&&r.ideal))throw new SDKError(ErrorCode.INVALID_PARAMS,"".concat(t," is not a valid ConstrainULong"))}}function checkVideoEncoderConfig(e){var t,r=_createForOfIteratorHelper(e);try{for(r.s();!(t=r.n()).done;){var n=t.value;checkNumber(null==n?void 0:n.maxKbps,"maxKbps"),checkConstrainULongg(null==n?void 0:n.width,"width"),checkConstrainULongg(null==n?void 0:n.height,"height"),checkConstrainULongg(null==n?void 0:n.frameRate,"frameRate")}}catch(e){r.e(e)}finally{r.f()}}function numberRangeGuide(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:Number.NEGATIVE_INFINITY,n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:Number.POSITIVE_INFINITY;return checkNumber(e,t,Number.NEGATIVE_INFINITY,Number.POSITIVE_INFINITY),e=(e=e>r?e:r)<n?e:n}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?slice$1(n).call(n,1):n);return getOwnPropertySymbols2?concat$2(i).call(i,getOwnPropertySymbols2(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,l,u=this._events[s],d=arguments.length;if(u.fn){switch(u.once&&this.removeListener(e,u.fn,void 0,!0),d){case 1:return u.fn.call(u.context),!0;case 2:return u.fn.call(u.context,t),!0;case 3:return u.fn.call(u.context,t,n),!0;case 4:return u.fn.call(u.context,t,n,i),!0;case 5:return u.fn.call(u.context,t,n,i,o),!0;case 6:return u.fn.call(u.context,t,n,i,o,a),!0}for(l=1,c=new Array(d-1);l<d;l++)c[l-1]=arguments[l];u.fn.apply(u.context,c)}else{var p,_=u.length;for(l=0;l<_;l++)switch(u[l].once&&this.removeListener(e,u[l].fn,void 0,!0),d){case 1:u[l].fn.call(u[l].context);break;case 2:u[l].fn.call(u[l].context,t);break;case 3:u[l].fn.call(u[l].context,t,n);break;case 4:u[l].fn.call(u[l].context,t,n,i);break;default:if(!c)for(p=1,c=new Array(d-1);p<d;p++)c[p-1]=arguments[p];u[l].fn.apply(u[l].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,l=[],u=s.length;c<u;c++)(s[c].fn!==t||i&&!s[c].once||n&&s[c].context!==n)&&l.push(s[c]);l.length?this._events[o]=1===l.length?l[0]:l: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,logger$n=new Logger("VERTC",0),EnhancedEventEmitter=function(e){_inherits(r,eventemitter3.exports.EventEmitter);var t=_createSuper(r);function r(){return _classCallCheck(this,r),t.apply(this,arguments)}return _createClass(r,[{key:"safeEmit",value:function(e){var t=this.listenerCount(e);try{for(var n,i,o=arguments.length,a=new Array(o>1?o-1:0),s=1;s<o;s++)a[s-1]=arguments[s];return(n=_get(_getPrototypeOf(r.prototype),"emit",this)).call.apply(n,concat$2(i=[this,e]).call(i,a))}catch(r){return logger$n.print("safeEmit","safeEmit() | event listener threw an error [event:%s]:%o",e,r),console.error(r),Boolean(t)}}}]),r}(),$$q=_export,call$a=functionCall,anObject$h=anObject$M,isObject$4=isObject$q,isDataDescriptor=isDataDescriptor$2,fails$1=fails$z,definePropertyModule=objectDefineProperty,getOwnPropertyDescriptorModule=objectGetOwnPropertyDescriptor,getPrototypeOf2=objectGetPrototypeOf,createPropertyDescriptor$1=createPropertyDescriptor$9;function set$c(e,t,r){var n,i,o,a=arguments.length<4?e:arguments[3],s=getOwnPropertyDescriptorModule.f(anObject$h(e),t);if(!s){if(isObject$4(i=getPrototypeOf2(e)))return set$c(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$a(o,a,r)}return!0}var MS_EDGE_BUG=fails$1((function(){var e=function(){},t=definePropertyModule.f(new e,"a",{configurable:!0});return!1!==Reflect.set(e.prototype,"a",1,t)}));$$q({target:"Reflect",stat:!0,forced:MS_EDGE_BUG},{set:set$c});var path$3=path$v,set$b=path$3.Reflect.set,parent$h=set$b,set$a=parent$h,parent$g=set$a,set$9=parent$g,parent$f=set$9,set$8=parent$f,set$7=set$8,set$6=set$7;function _objectWithoutPropertiesLoose(e,t){if(null==e)return{};var r,n,i={},o=keys$8(e);for(n=0;n<o.length;n++)r=o[n],indexOf2(t).call(t,r)>=0||(i[r]=e[r]);return i}function _objectWithoutProperties(e,t){if(null==e)return{};var r,n,i=_objectWithoutPropertiesLoose(e,t);if(getOwnPropertySymbols2){var o=getOwnPropertySymbols2(e);for(n=0;n<o.length;n++)r=o[n],indexOf2(t).call(t,r)>=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(i[r]=e[r])}return i}var _USER_MESSAGE_SEND_RE,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_ADD_STREAM_LIST="onAddStreamList",e.ON_REMOVE_STREAM="onRemoveStream",e.ON_REMOVE_STREAM_LIST="onRemoveStreamList",e.USER_DISCONNECTION="userDisconnection",e.USER_DISCONNECTION_LIST="userDisconnectionList",e.USER_CONNECTION="userConnection",e.USER_CONNECTION_LIST="userConnectionList",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_SPEAKER_CHANGE="onSpeakerChange",e.ON_STREAM_FAILED="streamFailed",e}(SignalEvent||{}),MediaServerSignalEvent=function(e){return e.RSCP="RSCP",e.RTT="RTT",e.SSC="SSC",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.EXCEED_QPS=5]="EXCEED_QPS",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.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_RECEIVER,"cannot find relay path."]),_defineProperty(_USER_MESSAGE_SEND_RE,5,[ErrorCode.USER_MESSAGE_EXCEED_QPS,"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,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$m=new Logger("DataChannelSignaling",3),noPrintSignaling=["onSpeakerChange"],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,P2P_MESSAGE_TIMEOUT=12e3,DataChannelSignaling=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)),"_singlingCache",new map2),_defineProperty(_assertThisInitialized(r),"_p2pCache",new map2),_defineProperty(_assertThisInitialized(r),"_rttIds",{}),_defineProperty(_assertThisInitialized(r),"_p2pMessageId",0),_defineProperty(_assertThisInitialized(r),"_clearDataChannelListener",void 0),_defineProperty(_assertThisInitialized(r),"_monitor",void 0),r.id=e,r._dataChannel=t,r._clearDataChannelListener=r._handleHandler(),r._monitor=getMonitor(e),window.__rtc_mock_signaling__=r.emit.bind(_assertThisInitialized(r)),r}return _createClass(a,[{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,i=this;return null===(n=this._monitor)||void 0===n||n.report("rtc_signaling",{error_code:0,message:stringify$1(t),signaling_event:"call-".concat(e),signaling_type:"Send",stream_id:t.streamId,stream_user_id:t.streamUserId,direction:"up"}),new promise((function(n,o){var a,s=i._genHeader(r);s.id=createRandomId();var c=s.id.join("-"),l="customMessage"===e;l&&RTSMsgReportor.samplingOne2ManyMsg(i.id,+s.id.join(""),t);var u=setTimeout((function(){i._singlingCache.delete(c),o(new SDKError(ErrorCode.TIME_OUT,"".concat(e," message time out"))),l&&RTSMsgReportor.updateOne2ManyMsgAck(i.id,t,999)}),DATA_CHANNEL_MESSAGE_TIMEOUT);i._singlingCache.set(c,{signalingType:e,success:function(e){clearTimeout(u),n(e),l&&RTSMsgReportor.updateOne2ManyMsgAck(i.id,t,0)},error:function(e){clearTimeout(u),o(e),l&&RTSMsgReportor.updateOne2ManyMsgAck(i.id,t,e.code)}}),logger$m.print("Signal",concat$2(a=">>>>>> [".concat(e,"][")).call(a,c,"]"),t),i._sendMessage(e,s,t)}))}},{key:"sendPingSignaling",value:function(){return this.sendSignaling("CheckConnectivity",{ts:Date.now()},{functionType:2})}},{key:"sendP2PMessage",value:(i=_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=RTSMsgReportor,e.t2=this.id,e.t3=_objectSpread2,e.t4=_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.t5={},e.t6=o,!o){e.next=15;break}return e.next=12,Utils.ab2b64str(n);case 12:e.t7=e.sent,e.next=16;break;case 15:e.t7=n;case 16:return e.t8=e.t7,e.t9={binary:e.t6,msg:e.t8},e.t10=(0,e.t3)(e.t4,e.t5,e.t9),e.t11=e.t1.samplingP2PMsg.call(e.t1,e.t2,e.t10),e.t12=r,e.abrupt("return",e.t0._sendP2PMessage.call(e.t0,e.t11,e.t12));case 22:case"end":return e.stop()}}),e,this)}))),function(e,t){return i.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$m.print("_sendP2PMessage [DC Signaling p2p >>]",stringify$1(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.USER_MESSAGE_TIMEOUT,"P2P message timeout")),RTSMsgReportor.updateP2PMsgAck(t.id,e,999)}),P2P_MESSAGE_TIMEOUT);t._p2pCache.set(e.id,{success:function(r,i){clearTimeout(a),n(i),RTSMsgReportor.updateP2PMsgAck(t.id,e,0)},error:function(r){var n;clearTimeout(a),RTSMsgReportor.updateP2PMsgAck(t.id,e,r.err);var o=_slicedToArray(USER_MESSAGE_SEND_RESULT_EXPLAIN[r.err]||[ErrorCode.USER_MESSAGE_UNKNOWN,concat$2(n="err: ".concat(r.err,", msg: ")).call(n,r.msg)],2),s=o[0],c=o[1];i({err:r.err,code:s,message:r.msg||c})}})}try{t._sendMessage("p2p",o,e)}catch(e){throw e.code===ErrorCode.SIGNALING_CHANNEL_NOT_OPEN&&(e.code=ErrorCode.USER_MESSAGE_BROKEN),e}}))}},{key:"_sendMessage",value:function(e,t,r){var n;if(!this._dataChannel||"open"!==this._dataChannel.readyState)throw new SDKError(ErrorCode.SIGNALING_CHANNEL_NOT_OPEN,"DataChannel not open");var i=t.version+(+t.zip<<5)+(+t.encrypt<<6),o=+t.needAck+(+t.direction<<1)+(+t.functionType<<2)+(+t.binary<<6),a=Utils.str2ab(stringify$1([e,r])),s=concatenate(Uint8Array,concat$2(n=[i,o]).call(n,_toConsumableArray(t.id||[])),new Uint8Array(a));this._dataChannel.send(s.buffer),"p2p"===e?RTSMsgReportor.updateP2PMsgReq(this.id,r,s.buffer.byteLength):"customMessage"===e&&RTSMsgReportor.updateOne2ManyMsgReq(this.id,r,s.buffer.byteLength)}},{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=from$2(slice$1(t).call(t,2,r))}return{header:o,data:slice$1(t).call(t,r)}}},{key:"_feedbackSignaling",value:function(e,t,r){var n,i,o=this._genHeader({needAck:!0,direction:1,id:map$6(n=e.split("-")).call(n,(function(e){return+e}))});includes4(noPrintSignaling).call(noPrintSignaling,t)||logger$m.print("Signal",concat$2(i=">>>>>> [".concat(t,"-res][")).call(i,e,"]"));this._sendMessage("".concat(t,"-res"),o,r)}},{key:"_handleMessage",value:(n=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){var r,n,i,o,a,s,c,l,u;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:r=Date.now(),n=t.byteLength,i=this._dispartData(t),o=i.data,(a=i.header).zip&&((s=new pako_1.Inflate).push(o,!0),o=s.result),c=Utils.ab2str(o),l=[],e.prev=8,l=JSON.parse(c),e.next=16;break;case 12:return e.prev=12,e.t0=e.catch(8),e.t0 instanceof Error&&(null===(u=this._monitor)||void 0===u||u.report("rtc_signaling_msg_error",{error_code:-1,message:e.t0.message,reason:"message parse failed"})),e.abrupt("return");case 16:e.t1=a.functionType,e.next=0===e.t1?19:1===e.t1?21:2===e.t1?23:25;break;case 19:return this.C2S(a,l,c,n,r),e.abrupt("break",26);case 21:return this.C2C(l,n,r),e.abrupt("break",26);case 23:return this.C2GW(a,l,c),e.abrupt("break",26);case 25:return e.abrupt("break",26);case 26:case"end":return e.stop()}}),e,this,[[8,12]])}))),function(e){return n.apply(this,arguments)})},{key:"C2S",value:(r=_asyncToGenerator(_regeneratorRuntime().mark((function e(t,r,n,i,o){var a,s,c,l,u;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(s=(null===(a=t.id)||void 0===a?void 0:a.join("-"))||"",1!==t.direction){e.next=5;break}this._handleAckMessage(s,r[0]||{},n),e.next=18;break;case 5:if(!Array.isArray(r)){e.next=18;break}if(l=r[0],r=r[1],includes4(noPrintSignaling).call(noPrintSignaling,l)||logger$m.print("Signal","<<<<<< ".concat(l),r,s),this._feedbackSignaling(s,l,l===SignalEvent.ON_CUSTOM_MESSAGE?_objectSpread2(_objectSpread2({},r),{},{message:""}):""),!r.binary||"string"!=typeof r.message){e.next=14;break}return e.next=13,Utils.b64str2ab(r.message);case 13:r.message=e.sent;case 14:u=Date.now(),this.emit(l,_objectSpread2({},r)),l===SignalEvent.ON_CUSTOM_MESSAGE&&RTSMsgReportor.reportOne2ManyMsgRecv(this.id,r,{msg_size:i,recv_msg_ts:o,fwd_msg_ts:u}),null===(c=this._monitor)||void 0===c||c.report("rtc_signaling",{error_code:0,message:n,signaling_event:"on-".concat(l),signaling_type:"Recv",stream_id:r.streamId,stream_user_id:r.clientId,direction:"down"});case 18:case"end":return e.stop()}}),e,this)}))),function(e,t,n,i,o){return r.apply(this,arguments)})},{key:"C2C",value:(t=_asyncToGenerator(_regeneratorRuntime().mark((function e(t,r,n){var i,o,a,s,c,l,u,d,p,_,h,f,m;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:Array.isArray(t)&&(t=t[1]),c=null===(i=t)||void 0===i?void 0:i.id,this._rttIds[c]||(null===(o=t)||void 0===o?void 0:o.dir)===DC_MESSAGE_DIRECTION.FEEDBACK||isRttMessage(null===(a=t)||void 0===a?void 0:a.msg)?delete this._rttIds[c]:logger$m.print("Signal","<<<<<< p2p response",t),e.t0=t.dir,e.next=e.t0===DC_MESSAGE_DIRECTION.SEND?6:e.t0===DC_MESSAGE_DIRECTION.FEEDBACK?46:48;break;case 6:if(l=Date.now(),isRttMessage(null===(s=t)||void 0===s?void 0:s.msg)){e.next=43;break}if(d=(u=t).binary,p=u.msg,_=u.room,h=u.to,f=u.from,m=""===_?d?SignalEvent.USER_BINARY_MESSAGE_RECEIVED_OUTSIDE_ROOM:SignalEvent.USER_MESSAGE_RECEIVED_OUTSIDE_ROOM:d?SignalEvent.USER_BINARY_MESSAGE_RECEIVED:SignalEvent.USER_MESSAGE_RECEIVED,h){e.next=27;break}if(e.t1=this,e.t2=SignalEvent.ON_CUSTOM_MESSAGE,e.t3=f,e.t4=d,!d){e.next=21;break}return e.next=18,Utils.b64str2ab(p);case 18:e.t5=e.sent,e.next=22;break;case 21:e.t5=p;case 22:e.t6=e.t5,e.t7={clientId:e.t3,binary:e.t4,message:e.t6},e.t1.emit.call(e.t1,e.t2,e.t7),e.next=43;break;case 27:if(e.t8=this,e.t9=m,e.t10=_objectSpread2,e.t11=_objectSpread2({},t),e.t12={},!d){e.next=38;break}return e.next=35,Utils.b64str2ab(p);case 35:e.t13=e.sent,e.next=39;break;case 38:e.t13=p;case 39:e.t14=e.t13,e.t15={msg:e.t14},e.t16=(0,e.t10)(e.t11,e.t12,e.t15),e.t8.emit.call(e.t8,e.t9,e.t16);case 43:return this._sendP2PMessage(_objectSpread2(_objectSpread2({},t),{},{dir:DC_MESSAGE_DIRECTION.FEEDBACK,msg:""})),RTSMsgReportor.reportP2PMsgRecv(this.id,t,{msg_size:r,recv_msg_ts:n,fwd_msg_ts:l}),e.abrupt("break",49);case 46:return this._handleP2PMsgFeedback(t),e.abrupt("break",49);case 48:return e.abrupt("break",49);case 49:case"end":return e.stop()}}),e,this)}))),function(e,r,n){return t.apply(this,arguments)})},{key:"C2GW",value:function(e,t,r){if(1===e.direction){var n,i=(null===(n=e.id)||void 0===n?void 0:n.join("-"))||"";this._handleAckMessage(i,t[0]||{},r)}else{var o=_slicedToArray(t,2),a=o[0],s=o[1],c=void 0===s?{}:s;if("RXMediaMsg"===a){var l,u=c.type,d=c.data;switch(null===(l=this._monitor)||void 0===l||l.report("rtc_signaling",{error_code:0,message:r,signaling_event:"on-".concat(u),signaling_type:"Recv",stream_id:"",stream_user_id:"",direction:"down"}),u){case"RSCP":try{var p=JSON.parse(d);Array.isArray(p)&&this.emit(u,p)}catch(e){}break;case"RTT":try{var _=JSON.parse(d);_.length&&this.emit(u,_[0])}catch(e){}break;case"SSC":try{var h=JSON.parse(d);h.length&&this.emit(u,h[0])}catch(e){}}}}}},{key:"_handleHandler",value:function(){var e=this,t=function(t){logger$m.print("_handleHandler","dataChannel close",t),e.emit("close",t)},r=function(t){logger$m.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,i,o=this._singlingCache.get(e);o&&(this._singlingCache.delete(e),200===t.code?o.success(t):o.error(t),logger$m.print("Signal",concat$2(i="<<<<<< [".concat(o.signalingType,"-ack] ")).call(i,e),t));null===(n=this._monitor)||void 0===n||n.report("rtc_signaling",{error_code:0,message:r,signaling_event:null==o?void 0:o.signalingType,signaling_type:"Ack",stream_id:"",stream_user_id:"",direction:"down"})}},{key:"_handleP2PMsgFeedback",value:function(e){var t=this._p2pCache.get(e.id);t&&(this._p2pCache.delete(e.id),e.err===USER_MESSAGE_SEND_RESULT.SUCCESS?t.success(e.id,e):t.error(e))}}]),a}(),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,l=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,u=entries2(s);c<u.length;c++){var d=_slicedToArray(u[c],2),p=d[0],_=d[1];a.setRequestHeader(p,_)}a.onreadystatechange=function(){if(4===a.readyState)if(t.isSending=!1,200===a.status)e(JSON.parse(a.responseText));else{var r=a.statusText,n=a.status;if(a.responseText)try{var o=JSON.parse(a.responseText);o.errMessage&&(r=o.errMessage),o.code&&(n=o.code)}catch(e){}i({message:r,code:n})}},a.onabort=function(){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),l&&(o=stringify$1(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$l=new Logger("ICE Request",3),IceConfigRequestManager=function(){function e(t){_classCallCheck(this,e),_defineProperty(this,"_request",void 0),_defineProperty(this,"_monitor",void 0),this.id=t,this._request=new HttpRequest,this._monitor=getMonitor(this.id)}var t,r,n;return _createClass(e,[{key:"getAccessNode",value:(n=_asyncToGenerator(_regeneratorRuntime().mark((function e(t,r,n,i,o){var a;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(a=sdkCache.getAccessNode(t))){e.next=9;break}if(this.getAccessNodeFromServer(t,r,n,i,o),reportRtcInvokeStatus(this.id,"es.R.node.cache",a),!Array.isArray(a)){e.next=8;break}return e.abrupt("return",promise.resolve(a));case 8:return e.abrupt("return",promise.resolve([a]));case 9:return e.abrupt("return",this.getAccessNodeFromServer(t,r,n,i,o));case 10:case"end":return e.stop()}}),e,this)}))),function(e,t,r,i,o){return n.apply(this,arguments)})},{key:"getAccessNodeFromServer",value:(r=_asyncToGenerator(_regeneratorRuntime().mark((function e(t,r,n,i,o){var a,s,c,l,u=this;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return c=sdkCache.getAccessUrls(),l=!0,reportRtcInvokeStatus(this.id,"es.R.req.cache.urls",c),(null===(a=c)||void 0===a?void 0:a.length)>0||(c=Config.ICE_CONFIG_REQUEST_URLS,l=!1,reportRtcInvokeStatus(this.id,"es.R.req.external.urls",c)),(null===(s=c)||void 0===s?void 0:s.length)>0||(c=Config.ICE_CONFIG_REQUEST_URLS_INTERNAL,l=!1,reportRtcInvokeStatus(this.id,"es.R.req.internal.urls",c)),e.abrupt("return",this.getICEConfigFromServer(c,t,r,n,i,o).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(l)return reportRtcInvokeStatus(u.id,"es.R.req.fallback",""),sdkCache.clearAccessUrls(),u.getAccessNodeFromServer(t,r,n,i);throw e})));case 6:case"end":return e.stop()}}),e,this)}))),function(e,t,n,i,o){return r.apply(this,arguments)})},{key:"getICEConfigFromServer",value:(t=_asyncToGenerator(_regeneratorRuntime().mark((function e(t,r,n,i,o,a){var s,c,l,u,d,p=this;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return c={appID:r,deviceID:sdkCache.getDeviceId(),connectSessionID:genUuid2(),os:"web",sdkVersion:Config.VERSION,isOversea:Config.OVERSEA,expectedAddr:getParameter("EXPECTED_ADDR"),productPlatform:"BytePlus",accessParams:stringify$1({requireICEUfragV2:!0})},n&&i&&(c.feedbackInfo=[{feedbackIP:null===(l=i.publicIPs[0])||void 0===l?void 0:l.ip,feedbackReason:{type:"NODE_CHANGED",reason:n}}],delete c.expectedAddr),u=Date.now(),null===(s=this._monitor)||void 0===s||s.report("rtc_get_access",{error_code:0,message:stringify$1(c),elapse:0,type:"request",host:t.join(","),connect_session_id:c.connectSessionID}),d=map$6(t).call(t,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,p._request.post(t,c);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:stringify$1(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:stringify$1(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",promiseAny2(d).then((function(e){var r,n=e.result;e.firstNode;var i=e.index;return null===(r=p._monitor)||void 0===r||r.report("rtc_get_access",{error_code:200,message:stringify$1(n),elapse:Date.now()-u,type:"response",host:t[i],connect_session_id:c.connectSessionID}),n})).catch((function(e){var r,n,i,o=null===(r=e[0])||void 0===r?void 0:r.error;throw null===(n=p._monitor)||void 0===n||n.report("rtc_get_access",{error_code:+((null==o?void 0:o.code)||(null==o?void 0:o.server_code)),message:null===(i=e[0])||void 0===i?void 0:i.message,elapse:Date.now()-u,type:"response",host:t.join(","),connect_session_id:c.connectSessionID},{error:stringify$1(o)}),e})));case 6:case"end":return e.stop()}}),e,this)}))),function(e,r,n,i,o,a){return t.apply(this,arguments)})},{key:"abort",value:function(){this._request.isSending&&(logger$l.print("abort","HTTP Request of [getICEConfigFromServer] abort"),this._request.abort())}}]),e}(),WrappedWellKnownSymbolModule=wellKnownSymbolWrapped,asyncIterator$5=WrappedWellKnownSymbolModule.f("asyncIterator"),parent$e=asyncIterator$5,asyncIterator$4=parent$e,parent$d=asyncIterator$4,asyncIterator$3=parent$d,parent$c=asyncIterator$3,asyncIterator$2=parent$c,asyncIterator$1=asyncIterator$2,asyncIterator=asyncIterator$1;function _asyncIterator(e){var t,r,n,i=2;for(void 0!==symbol&&(r=asyncIterator,n=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}).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)}var simulcastFormats=[{maxLayers:3,totalPixels:2073600},{maxLayers:3,totalPixels:921600},{maxLayers:3,totalPixels:518400},{maxLayers:2,totalPixels:230400},{maxLayers:2,totalPixels:129600},{maxLayers:1,totalPixels:57600},{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}function fillSimulcastLayers(e,t){var r=[];if(t<=1)return r;var n=Math.min(e.width,e.height)/90;return r.push({scaleResolutionDownBy:n,width:Math.floor(e.width/n),height:Math.floor(e.height/n),maxkbps:100,frameRate:10}),t<=2||r.unshift({scaleResolutionDownBy:2,width:Math.floor(e.width/2),height:Math.floor(e.height/2),maxkbps:Math.floor(e.maxKbps/2),frameRate:e.frameRate>=30?Math.floor(e.frameRate/2):e.frameRate}),r}var collection$1=collection$3,collectionStrong=collectionStrong$2;collection$1("Set",(function(e){return function(){return e(this,arguments.length?arguments[0]:void 0)}}),collectionStrong);var path$2=path$v,set$5=path$2.Set,parent$b=set$5,set$4=parent$b,parent$a=set$4,set$3=parent$a,$$p=_export,from$1=collectionFrom;$$p({target:"Set",stat:!0,forced:!0},{from:from$1});var $$o=_export,of$1=collectionOf;$$o({target:"Set",stat:!0,forced:!0},{of:of$1});var call$9=functionCall,aCallable$a=aCallable$z,anObject$g=anObject$M,collectionAddAll=function(){for(var e=anObject$g(this),t=aCallable$a(e.add),r=0,n=arguments.length;r<n;r++)call$9(t,e,arguments[r]);return e},$$n=_export,addAll2=collectionAddAll;$$n({target:"Set",proto:!0,real:!0,forced:!0},{addAll:addAll2});var $$m=_export,deleteAll$1=collectionDeleteAll;$$m({target:"Set",proto:!0,real:!0,forced:!0},{deleteAll:deleteAll$1});var getIterator$2=getIterator$7,getSetIterator$7=getIterator$2,$$l=_export,anObject$f=anObject$M,bind$6=functionBindContext,getSetIterator$6=getSetIterator$7,iterate$e=iterate$A;$$l({target:"Set",proto:!0,real:!0,forced:!0},{every:function(e){var t=anObject$f(this),r=getSetIterator$6(t),n=bind$6(e,arguments.length>1?arguments[1]:void 0);return!iterate$e(r,(function(e,r){if(!n(e,e,t))return r()}),{IS_ITERATOR:!0,INTERRUPTED:!0}).stopped}});var $$k=_export,getBuiltIn$6=getBuiltIn$o,call$8=functionCall,aCallable$9=aCallable$z,anObject$e=anObject$M,speciesConstructor$5=speciesConstructor$b,iterate$d=iterate$A;$$k({target:"Set",proto:!0,real:!0,forced:!0},{difference:function(e){var t=anObject$e(this),r=new(speciesConstructor$5(t,getBuiltIn$6("Set")))(t),n=aCallable$9(r.delete);return iterate$d(e,(function(e){call$8(n,r,e)})),r}});var $$j=_export,getBuiltIn$5=getBuiltIn$o,call$7=functionCall,aCallable$8=aCallable$z,anObject$d=anObject$M,bind$5=functionBindContext,speciesConstructor$4=speciesConstructor$b,getSetIterator$5=getSetIterator$7,iterate$c=iterate$A;$$j({target:"Set",proto:!0,real:!0,forced:!0},{filter:function(e){var t=anObject$d(this),r=getSetIterator$5(t),n=bind$5(e,arguments.length>1?arguments[1]:void 0),i=new(speciesConstructor$4(t,getBuiltIn$5("Set"))),o=aCallable$8(i.add);return iterate$c(r,(function(e){n(e,e,t)&&call$7(o,i,e)}),{IS_ITERATOR:!0}),i}});var $$i=_export,anObject$c=anObject$M,bind$4=functionBindContext,getSetIterator$4=getSetIterator$7,iterate$b=iterate$A;$$i({target:"Set",proto:!0,real:!0,forced:!0},{find:function(e){var t=anObject$c(this),r=getSetIterator$4(t),n=bind$4(e,arguments.length>1?arguments[1]:void 0);return iterate$b(r,(function(e,r){if(n(e,e,t))return r(e)}),{IS_ITERATOR:!0,INTERRUPTED:!0}).result}});var $$h=_export,getBuiltIn$4=getBuiltIn$o,call$6=functionCall,aCallable$7=aCallable$z,anObject$b=anObject$M,speciesConstructor$3=speciesConstructor$b,iterate$a=iterate$A;$$h({target:"Set",proto:!0,real:!0,forced:!0},{intersection:function(e){var t=anObject$b(this),r=new(speciesConstructor$3(t,getBuiltIn$4("Set"))),n=aCallable$7(t.has),i=aCallable$7(r.add);return iterate$a(e,(function(e){call$6(n,t,e)&&call$6(i,r,e)})),r}});var $$g=_export,call$5=functionCall,aCallable$6=aCallable$z,anObject$a=anObject$M,iterate$9=iterate$A;$$g({target:"Set",proto:!0,real:!0,forced:!0},{isDisjointFrom:function(e){var t=anObject$a(this),r=aCallable$6(t.has);return!iterate$9(e,(function(e,n){if(!0===call$5(r,t,e))return n()}),{INTERRUPTED:!0}).stopped}});var $$f=_export,getBuiltIn$3=getBuiltIn$o,call$4=functionCall,aCallable$5=aCallable$z,isCallable$1=isCallable$n,anObject$9=anObject$M,getIterator$1=getIterator$7,iterate$8=iterate$A;$$f({target:"Set",proto:!0,real:!0,forced:!0},{isSubsetOf:function(e){var t=getIterator$1(this),r=anObject$9(e),n=r.has;return isCallable$1(n)||(r=new(getBuiltIn$3("Set"))(e),n=aCallable$5(r.has)),!iterate$8(t,(function(e,t){if(!1===call$4(n,r,e))return t()}),{IS_ITERATOR:!0,INTERRUPTED:!0}).stopped}});var $$e=_export,call$3=functionCall,aCallable$4=aCallable$z,anObject$8=anObject$M,iterate$7=iterate$A;$$e({target:"Set",proto:!0,real:!0,forced:!0},{isSupersetOf:function(e){var t=anObject$8(this),r=aCallable$4(t.has);return!iterate$7(e,(function(e,n){if(!1===call$3(r,t,e))return n()}),{INTERRUPTED:!0}).stopped}});var $$d=_export,uncurryThis$5=functionUncurryThis,anObject$7=anObject$M,toString2=toString$h,getSetIterator$3=getSetIterator$7,iterate$6=iterate$A,arrayJoin=uncurryThis$5([].join),push$3=[].push;$$d({target:"Set",proto:!0,real:!0,forced:!0},{join:function(e){var t=anObject$7(this),r=getSetIterator$3(t),n=void 0===e?",":toString2(e),i=[];return iterate$6(r,push$3,{that:i,IS_ITERATOR:!0}),arrayJoin(i,n)}});var $$c=_export,getBuiltIn$2=getBuiltIn$o,bind$3=functionBindContext,call$2=functionCall,aCallable$3=aCallable$z,anObject$6=anObject$M,speciesConstructor$2=speciesConstructor$b,getSetIterator$2=getSetIterator$7,iterate$5=iterate$A;$$c({target:"Set",proto:!0,real:!0,forced:!0},{map:function(e){var t=anObject$6(this),r=getSetIterator$2(t),n=bind$3(e,arguments.length>1?arguments[1]:void 0),i=new(speciesConstructor$2(t,getBuiltIn$2("Set"))),o=aCallable$3(i.add);return iterate$5(r,(function(e){call$2(o,i,n(e,e,t))}),{IS_ITERATOR:!0}),i}});var $$b=_export,aCallable$2=aCallable$z,anObject$5=anObject$M,getSetIterator$1=getSetIterator$7,iterate$4=iterate$A,$TypeError=TypeError;$$b({target:"Set",proto:!0,real:!0,forced:!0},{reduce:function(e){var t=anObject$5(this),r=getSetIterator$1(t),n=arguments.length<2,i=n?void 0:arguments[1];if(aCallable$2(e),iterate$4(r,(function(r){n?(n=!1,i=r):i=e(i,r,r,t)}),{IS_ITERATOR:!0}),n)throw $TypeError("Reduce of empty set with no initial value");return i}});var $$a=_export,anObject$4=anObject$M,bind$2=functionBindContext,getSetIterator=getSetIterator$7,iterate$3=iterate$A;$$a({target:"Set",proto:!0,real:!0,forced:!0},{some:function(e){var t=anObject$4(this),r=getSetIterator(t),n=bind$2(e,arguments.length>1?arguments[1]:void 0);return iterate$3(r,(function(e,r){if(n(e,e,t))return r()}),{IS_ITERATOR:!0,INTERRUPTED:!0}).stopped}});var $$9=_export,getBuiltIn$1=getBuiltIn$o,call$1=functionCall,aCallable$1=aCallable$z,anObject$3=anObject$M,speciesConstructor$1=speciesConstructor$b,iterate$2=iterate$A;$$9({target:"Set",proto:!0,real:!0,forced:!0},{symmetricDifference:function(e){var t=anObject$3(this),r=new(speciesConstructor$1(t,getBuiltIn$1("Set")))(t),n=aCallable$1(r.delete),i=aCallable$1(r.add);return iterate$2(e,(function(e){call$1(n,r,e)||call$1(i,r,e)})),r}});var $$8=_export,getBuiltIn=getBuiltIn$o,aCallable=aCallable$z,anObject$2=anObject$M,speciesConstructor=speciesConstructor$b,iterate$1=iterate$A;$$8({target:"Set",proto:!0,real:!0,forced:!0},{union:function(e){var t=anObject$2(this),r=new(speciesConstructor(t,getBuiltIn("Set")))(t);return iterate$1(e,aCallable(r.add),{that:r}),r}});var parent$9=set$3,set$2=parent$9,set$1=set$2,set=set$1,THROTTLE_DURATION=150,STATS_CACHE=new map2,getExtraChromeStatsReport=function(){var e=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",new promise((function(e,r){var n=getParameter("STATS_SCALLBACK_SUPPORT");if("chrome-stable"===getBrowser()&&void 0===window.InstallTrigger&&isStatsCallbackSupport&&n)try{t.getStats((function(t){var r=[];t.result().forEach((function(e){if(!includes4(stasType).call(stasType,e.type)){var t={};e.names().forEach((function(r){t[r]=e.stat(r)})),r.push(_objectSpread2(_objectSpread2({},t),{},{id:e.id,type:e.type,timestamp:e.timestamp}))}})),e({all:r,getTrackStats:function(e){return filter3(r).call(r,(function(t){return"ssrc"!==t.type||t.googTrackId===e}))}})}))}catch(e){r(e)}else e({all:[],getTrackStats:function(){return[]}})})));case 1:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),getAllStatsReport=function(){var e=_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 e.next=2,t.getStats();case 2:return i=e.sent,o={all:[]},a=new map2,i.forEach((function(e){var t=a.get(e.type)||new map2;t.set(e.id,e),a.set(e.type,t),o.all.push(e)})),s=function(e,t){e.forEach((function(e){var r,n,i,o,s,c,l=e.codecId,u=e.transportId,d=e.trackId,p=e.playoutId;if(null===(r=a.get(RTCStatsType.codec))||void 0===r||r.forEach((function(e){e.id===l&&t.add(e)})),null===(n=a.get(RTCStatsType.transport))||void 0===n||n.forEach((function(e){e.id===u&&(s=e,t.add(e))})),null===(i=a.get(RTCStatsType.track))||void 0===i||i.forEach((function(e){e.id===d&&t.add(e)})),null===(o=a.get(RTCStatsType.mediaPlayout))||void 0===o||o.forEach((function(e){e.id===p&&t.add(e)})),s){var _,h,f=s,m=f.localCertificateId,v=f.remoteCertificateId,g=f.selectedCandidatePairId;null===(_=a.get(RTCStatsType.certificate))||void 0===_||_.forEach((function(e){(e.id===m||e.id===v)&&t.add(e)})),null===(h=a.get(RTCStatsType.candidatePair))||void 0===h||h.forEach((function(e){e.id===g&&(c=e,t.add(e))}))}if(c){var y,S,T=c,$=T.localCandidateId,E=T.remoteCandidateId;null===(y=a.get(RTCStatsType.localCandidate))||void 0===y||y.forEach((function(e){e.id===$&&t.add(e)})),null===(S=a.get(RTCStatsType.remoteCandidate))||void 0===S||S.forEach((function(e){e.id===E&&t.add(e)}))}}))},null===(r=a.get(RTCStatsType.mediaSource))||void 0===r||r.forEach((function(e){var t,r=new set;r.add(e);var n=[];null===(t=a.get(RTCStatsType.outboundRtp))||void 0===t||t.forEach((function(t){var i;t.mediaSourceId===e.id&&(r.add(t),n.push(t),null===(i=a.get(RTCStatsType.remoteInboundRtp))||void 0===i||i.forEach((function(e){e.localId===t.id&&r.add(e)})))})),s(n,r),o[e.trackIdentifier]=from$2(r)})),null===(n=a.get(RTCStatsType.inboundRtp))||void 0===n||n.forEach((function(e){var t,r=new set;r.add(e),null===(t=a.get(RTCStatsType.remoteOutboundRtp))||void 0===t||t.forEach((function(t){t.localId===e.id&&r.add(t)})),s([e],r);var n,i=e.trackIdentifier;i||(null===(n=a.get(RTCStatsType.track))||void 0===n||n.forEach((function(t){t.id===e.trackId&&(i=t.trackIdentifier)})));o[i]=from$2(r)})),e.abrupt("return",o);case 10:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),getStats=function(){var e=_asyncToGenerator(_regeneratorRuntime().mark((function e(t,r,n){var i,o,a,s,c,l;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(i=null==r?void 0:r.id,t instanceof RTCPeerConnection){e.next=3;break}return e.abrupt("return",[]);case 3:if(!isFirefox&&!isSafari){e.next=10;break}return o=[],e.next=7,t.getStats(r);case 7:return e.sent.forEach((function(e){o.push(e)})),e.abrupt("return",o);case 10:return(!(a=STATS_CACHE.get(t))||Date.now()-a.timestamp>THROTTLE_DURATION)&&(a={timestamp:Date.now(),statsPromise:getAllStatsReport(t),extraStatsPromise:getExtraChromeStatsReport(t)},STATS_CACHE.set(t,a)),e.next=14,a.statsPromise;case 14:if(s=e.sent,c=(i?s[i]:s.all)||[],n){e.next=21;break}return e.next=19,a.extraStatsPromise;case 19:l=e.sent,c=concat$2(c).call(c,(i?l.getTrackStats(i):l.all)||[]);case 21:return e.abrupt("return",c);case 22:case"end":return e.stop()}}),e)})));return function(t,r,n){return e.apply(this,arguments)}}();getBrowser();var RTCStatsType=function(e){return e.codec="codec",e.inboundRtp="inbound-rtp",e.outboundRtp="outbound-rtp",e.remoteInboundRtp="remote-inbound-rtp",e.remoteOutboundRtp="remote-outbound-rtp",e.mediaSource="media-source",e.csrc="csrc",e.peerConnection="peer-connection",e.dataChannel="data-channel",e.stream="stream",e.track="track",e.transceiver="transceiver",e.sender="sender",e.receiver="receiver",e.transport="transport",e.sctpTransport="sctp-transport",e.candidatePair="candidate-pair",e.localCandidate="local-candidate",e.remoteCandidate="remote-candidate",e.certificate="certificate",e.iceServer="ice-server",e.mediaPlayout="media-playout",e}(RTCStatsType||{}),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"],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(){return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(e.prev=0,!isSSR2()&&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,isH264DecodeSupported();case 5:if(e.t0=e.sent,!e.t0){e.next=10;break}return e.next=9,isH264EncodeSupported();case 9:e.t0=e.sent;case 10:return e.abrupt("return",e.t0);case 13:return e.prev=13,e.t1=e.catch(0),e.abrupt("return",!1);case 16:case"end":return e.stop()}}),e,null,[[0,13]])})));return function(){return e.apply(this,arguments)}}(),internalGetSupportedCodecs=function(){var e=_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 r=t||"recv_and_send",n=[],e.next=4,isH264DecodeSupported();case 4:return i=e.sent,e.next=7,isH264EncodeSupported();case 7:return o=e.sent,e.next=10,isVP8DecodeSupported();case 10:return a=e.sent,e.next=13,isVP8EncodeSupported();case 13:return s=e.sent,"send_only"===r&&(o&&n.push("H264"),s&&n.push("vp8")),"recv_only"===r&&(i&&n.push("H264"),a&&n.push("vp8")),"recv_and_send"===r&&(o&&i&&n.push("H264"),s&&a&&n.push("vp8")),e.abrupt("return",n);case 18:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),internalGetSupportedCodecsSdpOffer=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",stringify$1(codecsSupportMapSdpOffer));case 1:case"end":return e.stop()}}),e)})));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",map$6(t).call(t,(function(e){return e.toUpperCase()})));case 4:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),codecsSupportMap={},codecsSupportMapSdpOffer={};function supportH264(e){var t,r=!1,n=_createForOfIteratorHelper(e.split("\n"));try{for(n.s();!(t=n.n()).done;){var i=t.value;if(includes4(i).call(i,"level-asymmetry-allowed=1")&&includes4(i).call(i,"packetization-mode=1")&&includes4(i).call(i,"profile-level-id=42e0")){r=!0;break}}}catch(e){n.e(e)}finally{n.f()}if(r){for(var o=navigator.userAgent.toLowerCase(),a=!1,s=0,c=["miuibrowser"];s<c.length;s++){var l=c[s];includes4(o).call(o,l)&&(a=!0)}return!a}return!1}var createOfferSdp=function(){var e=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){var r,n;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return(r=new RTCPeerConnection({sdpSemantics:"unified-plan"})).addTransceiver("video",{direction:t}),e.next=4,r.createOffer();case 4:return n=e.sent,r.close(),e.abrupt("return",n.sdp.toLowerCase());case 7:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),checkCodecsEncodeSupport=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,createOfferSdp("sendonly");case 2:if(r=e.sent,!includes4(t=navigator.userAgent).call(t,"VivoBrowser")){e.next=7;break}return e.next=6,createOfferSdp("sendonly");case 6:r=e.sent;case 7:return codecsSupportMap.h264encode=supportH264(r),codecsSupportMapSdpOffer.h264encode=r,codecsSupportMap.vp8encode=indexOf2(r).call(r,"vp8")>-1,codecsSupportMapSdpOffer.vp8encode="same as h264encode",e.abrupt("return",codecsSupportMap);case 12:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),checkCodecsDecodeSupport=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,createOfferSdp("recvonly");case 2:if(r=e.sent,!includes4(t=navigator.userAgent).call(t,"VivoBrowser")){e.next=7;break}return e.next=6,createOfferSdp("recvonly");case 6:r=e.sent;case 7:return codecsSupportMap.h264decode=supportH264(r),codecsSupportMapSdpOffer.h264decode=r,codecsSupportMap.vp8decode=indexOf2(r).call(r,"vp8")>-1,codecsSupportMapSdpOffer.vp8decode="same as h264decode",e.abrupt("return",codecsSupportMap);case 12:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),isH264EncodeSupported=function(){var e=_asyncToGenerator(_regeneratorRuntime().mark((function e(){return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(void 0!==codecsSupportMap.h264encode){e.next=10;break}return e.prev=1,e.next=4,checkCodecsEncodeSupport();case 4:e.next=10;break;case 6:return e.prev=6,e.t0=e.catch(1),codecsSupportMapSdpOffer.h264encode="meet error:"+e.t0,e.abrupt("return",!1);case 10:return e.abrupt("return",codecsSupportMap.h264encode||!1);case 11:case"end":return e.stop()}}),e,null,[[1,6]])})));return function(){return e.apply(this,arguments)}}(),isH264DecodeSupported=function(){var e=_asyncToGenerator(_regeneratorRuntime().mark((function e(){return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(void 0!==codecsSupportMap.h264decode){e.next=10;break}return e.prev=1,e.next=4,checkCodecsDecodeSupport();case 4:e.next=10;break;case 6:return e.prev=6,e.t0=e.catch(1),codecsSupportMapSdpOffer.h264decode="meet error:"+e.t0,e.abrupt("return",!1);case 10:return e.abrupt("return",codecsSupportMap.h264decode||!1);case 11:case"end":return e.stop()}}),e,null,[[1,6]])})));return function(){return e.apply(this,arguments)}}(),isVP8EncodeSupported=function(){var e=_asyncToGenerator(_regeneratorRuntime().mark((function e(){return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(void 0!==codecsSupportMap.vp8encode){e.next=10;break}return e.prev=1,e.next=4,checkCodecsEncodeSupport();case 4:e.next=10;break;case 6:return e.prev=6,e.t0=e.catch(1),codecsSupportMapSdpOffer.vp8encode="meet error:"+e.t0,e.abrupt("return",!1);case 10:return e.abrupt("return",codecsSupportMap.vp8encode||!1);case 11:case"end":return e.stop()}}),e,null,[[1,6]])})));return function(){return e.apply(this,arguments)}}(),isVP8DecodeSupported=function(){var e=_asyncToGenerator(_regeneratorRuntime().mark((function e(){return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(void 0!==codecsSupportMap.vp8decode){e.next=10;break}return e.prev=1,e.next=4,checkCodecsDecodeSupport();case 4:e.next=10;break;case 6:return e.prev=6,e.t0=e.catch(1),codecsSupportMapSdpOffer.vp8decode="meet error:"+e.t0,e.abrupt("return",!1);case 10:return e.abrupt("return",codecsSupportMap.vp8decode||!1);case 11:case"end":return e.stop()}}),e,null,[[1,6]])})));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},isWebAudioSupported=function(){return 12!==safariVersion},lib={},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"]}]};keys$8(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=[],s=o;return filter3(t=e.split(/(\r\n|\r|\n)/)).call(t,i).forEach((function(e){var t=e[0],i=slice$1(e).call(e,2);"m"===t&&(a.push({rtp:[],fmtp:[]}),s=a[a.length-1]);for(var o=0;o<(n[t]||[]).length;o+=1){var c=n[t][o];if(c.reg.test(i))return r(c,s,i)}})),o.media=a,o};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){var t;return reduce3(t=e.split(/;\s?/)).call(t,o,{})},e.parseFmtpConfig=e.parseParams,e.parsePayloads=function(e){var t;return map$6(t=e.toString().split(" ")).call(t,Number)},e.parseRemoteCandidates=function(e){for(var r,n=[],i=map$6(r=e.split(" ")).call(r,t),o=0;o<i.length;o+=3)n.push({component:i[o],ip:i[o+1],port:i[o+2]});return n},e.parseImageAttributes=function(e){var t;return map$6(t=e.split(" ")).call(t,(function(e){var t;return reduce3(t=e.substring(1,e.length-1).split(",")).call(t,o,{})}))},e.parseSimulcastStreamList=function(e){var r;return map$6(r=e.split(";")).call(r,(function(e){var r;return map$6(r=e.split(",")).call(r,(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,format14=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 format14.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,writer2=writer$1;lib.write=writer2,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 toObject=toObject$d,toAbsoluteIndex=toAbsoluteIndex$5,lengthOfArrayLike=lengthOfArrayLike$b,arrayFill=function(e){for(var t=toObject(this),r=lengthOfArrayLike(t),n=arguments.length,i=toAbsoluteIndex(n>1?arguments[1]:void 0,r),o=n>2?arguments[2]:void 0,a=void 0===o?r:toAbsoluteIndex(o,r);a>i;)t[i++]=e;return t},$$7=_export,fill$7=arrayFill;$$7({target:"Array",proto:!0},{fill:fill$7});var entryVirtual=entryVirtual$m,fill$6=entryVirtual("Array").fill,isPrototypeOf=objectIsPrototypeOf,method=fill$6,ArrayPrototype=Array.prototype,fill$5=function(e){var t=e.fill;return e===ArrayPrototype||isPrototypeOf(ArrayPrototype,e)&&t===ArrayPrototype.fill?method:t},parent$8=fill$5,fill$4=parent$8,parent$7=fill$4,fill$3=parent$7,parent$6=fill$3,fill$2=parent$6,fill$1=fill$2,fill2=fill$1,logger$k=new Logger("FirefoxHandler",3),SSRC_MAX=Math.pow(2,32),SSRC_MIN=1e4,clientCname="kp34Za0H+aVf862l",serverCname="o/i14u9pJrxRKAsu",generateRandomSsrc=function(){return Math.floor(Math.random()*SSRC_MAX+SSRC_MIN)};function generateAllSsrc(e){return e>SSRC_MAX-18?(logger$k.print("generateAllSsrc","reset start id",e),generateAllSsrc(e=e-SSRC_MAX+SSRC_MIN+18)):{audio:e,audioFec:e+1,audioRtx:e+2,video:e+3,videoFec:e+4,videoRtx:e+5,next:e+18}}var generateSsrc=function(e,t,r){var n,i,o,a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:serverCname;return[{id:r,attribute:"cname",value:a},{id:r,attribute:"msid",value:concat$2(n=concat$2(i="".concat(e," ")).call(i,e,"-")).call(n,t)},{id:r,attribute:"mslabel",value:"".concat(e)},{id:r,attribute:"label",value:concat$2(o="".concat(e,"-")).call(o,t)}]},generateSsrcs=function(e,t){var r,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},i=t.video,o=t.videoRtx,a=t.videoFec,s=[i,o],c=n.cname,l=n.flexfec;l&&s.push(a);var u,d=reduce3(s).call(s,(function(t,r){return concat$2(t).call(t,generateSsrc(e,"video",r,c))}),[]),p=[{semantics:"FID",ssrcs:concat$2(r="".concat(i," ")).call(r,o)}];l&&p.push({semantics:"FEC-FR",ssrcs:concat$2(u="".concat(i," ")).call(u,a)});return{ssrcs:d,ssrcGroups:p}};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=!(arguments.length>3&&void 0!==arguments[3])||arguments[3],i=_objectSpread2(_objectSpread2({},e),{},{media:[]});return n&&(i.invalid=[{value:"realx-exts:rscp"}]),t&&i.media.push(t),r&&i.media.push(r),delete i.groups,delete i.msidSemantic,lib.write(i)};function parseAnswerIceParams(e,t){return _parseAnswerIceParams.apply(this,arguments)}function _parseAnswerIceParams(){return(_parseAnswerIceParams=_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:return n={},i=r.publicIPs,o=r.certFingerprint,a=r.iceParams,s=r.iceConfig,n.fingerprint={type:"sha-256",hash:o},n.icePwd=a.serverIcePwd,e.next=6,getServerUfrag(a.serverIceUfrag);case 6:return n.iceUfrag=e.sent,n.candidates=genCandidates(i,s),n.setup="active",n.iceOptions="renomination",e.abrupt("return",n);case 11:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function genCandidates(e,t){if(!Array.isArray(e))return[];var r=0,n=2130706431,i=[];return e.forEach((function(e){var o={component:1,ip:e.ip,type:"host",generation:e.generation};e.udpPorts&&!t.tcpOnly&&e.udpPorts.forEach((function(e){i.push(_objectSpread2(_objectSpread2({},o),{},{foundation:r++,transport:"udp",port:e,priority:n}))})),e.tcpPorts&&e.tcpPorts.forEach((function(e){i.push(_objectSpread2(_objectSpread2({},o),{},{foundation:r++,transport:"tcp",port:e,tcptype:"passive",priority:2130705431}))}))})),i}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=new Uint8Array(4),crypto.getRandomValues(o),(a=new Uint8Array(2))[0]=0,a[1]=1,s=concatenate(Uint8Array,n,i,o,a),e.next=15,Utils.ab2b64str(s.buffer);case 15:return c=e.sent,e.abrupt("return",c);case 17:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),ICEConfigType=function(e){return e[e.kICEConfigTypeSrtpDtlsType=0]="kICEConfigTypeSrtpDtlsType",e[e.kICEConfigTypeRenominationType=1]="kICEConfigTypeRenominationType",e[e.kICEConfigTypeTcpType=2]="kICEConfigTypeTcpType",e[e.kICEConfigTypeMultiSendType=3]="kICEConfigTypeMultiSendType",e[e.kICEConfigTypeKcpType=4]="kICEConfigTypeKcpType",e[e.kICEConfigTypeSrtpSdesType=5]="kICEConfigTypeSrtpSdesType",e}(ICEConfigType||{});function getServerUfragV2(e){var t,r=e.random,n=e.serverUfrag,i=e.serverPwd,o=e.clientPwd,a=e.options,s=(new TextEncoder).encode("WPRE");r||(r=new Uint8Array(4),crypto.getRandomValues(r));var c=base64ToUint8(n);c.byteLength;var l=aesCtrEncrypt(base64ToUint8(o),base64ToUint8(i).subarray(0,16),base64ToUint8(n).subarray(0,16));l.byteLength;var u=new Uint8Array(reduce3(t=keys$8(a)).call(t,(function(e,t){var r=Number(t);return e.push(r),e.push(a[r]?1:0),e}),[]));u.byteLength;var d,p=concatenate(Uint8Array,s,r,[c.byteLength],c,[l.byteLength],l,u);p.byteLength%3!=0&&(p=concatenate(Uint8Array,p,fill2(d=new Uint8Array(3-p.byteLength%3)).call(d,255)));return[uint8ToBase64(p),uint8ToBase64(concatenate(Uint8Array,r,c.subarray(0,20)))]}var setCodecPreferences=function(e,t){var r=0;if(Array.isArray(e.fmtp)&&Array.isArray(e.rtp)){var n,i=_createForOfIteratorHelper(e.fmtp);try{for(i.s();!(n=i.n()).done;){var o,a,s,c=n.value;if(includes4(o=c.config).call(o,"level-asymmetry-allowed=1")&&includes4(a=c.config).call(a,"packetization-mode=1")&&includes4(s=c.config).call(s,"profile-level-id=42e0")){r=c.payload;break}}}catch(e){i.e(e)}finally{i.f()}for(var l=0;l<e.rtp.length;l++){var u=e.rtp[l];if("H264"===t){if(u.payload===r){var d;e.rtp.unshift(splice$3(d=e.rtp).call(d,l,1)[0]);break}}else if(u.codec===t){var p;e.rtp.unshift(splice$3(p=e.rtp).call(p,l,1)[0]);break}}var _=[];e.rtp.forEach((function(e){return _.push(e.payload)})),e.payloads=_.join(" ")}},logger$j=new Logger("BasicHandler",3),encodedTransformSupported$1=isEncodedTransformSupported(),peerConnectionConfiguration={iceServers:[],iceTransportPolicy:"all",bundlePolicy:"max-bundle",rtcpMuxPolicy:"require",sdpSemantics:"unified-plan",encodedInsertableStreams:!!encodedTransformSupported$1||void 0},BasicHandler=function(e){_inherits(o,eventemitter3.exports.EventEmitter);var t,r,n,i=_createSuper(o);function o(e){var t;return _classCallCheck(this,o),_defineProperty(_assertThisInitialized(t=i.call(this)),"_peerConnection",void 0),_defineProperty(_assertThisInitialized(t),"_dataChannel",void 0),_defineProperty(_assertThisInitialized(t),"_context",void 0),_defineProperty(_assertThisInitialized(t),"id",void 0),_defineProperty(_assertThisInitialized(t),"_monitor",void 0),_defineProperty(_assertThisInitialized(t),"_offerIce",{}),_defineProperty(_assertThisInitialized(t),"_answerIce",{}),_defineProperty(_assertThisInitialized(t),"_initSctpEvents",!1),_defineProperty(_assertThisInitialized(t),"_nextSsrc",generateRandomSsrc()),_defineProperty(_assertThisInitialized(t),"_aSendonlyAnswerTpl",void 0),_defineProperty(_assertThisInitialized(t),"_vSendonlyAnswerTpl",void 0),_defineProperty(_assertThisInitialized(t),"_enableSubFlexfec",!1),_defineProperty(_assertThisInitialized(t),"audioTrack4ff",void 0),_defineProperty(_assertThisInitialized(t),"_connectionId",void 0),t.id=e.id,t._monitor=getMonitor(t.id),t._peerConnection=new RTCPeerConnection(peerConnectionConfiguration),t._dataChannel=t._peerConnection.createDataChannel("signaling",{negotiated:!0,id:100}),t._context=e,t._dataChannel.binaryType="arraybuffer",t._peerConnection.ontrack=function(e){var r,n,i,o,a=null===(r=e.streams)||void 0===r||null===(n=r[0])||void 0===n?void 0:n.id;logger$j.print("constructor",concat$2(i=concat$2(o="pc.ontrack ".concat(e.track.kind," ")).call(o,e.track.id," ")).call(i,a)),"ff-stream"===a&&(t.audioTrack4ff=e.track),t.emit("ontrack",e)},t._peerConnection.onconnectionstatechange=function(e){var r;logger$j.print("constructor",concat$2(r="onconnectionstatechange ".concat(t._peerConnection.iceConnectionState," -> ")).call(r,t._peerConnection.connectionState)),"failed"!==t._peerConnection.iceConnectionState&&"closed"!==t._peerConnection.iceConnectionState&&"failed"!==t._peerConnection.connectionState||t.emit("disconnect")},t._peerConnection.oniceconnectionstatechange=function(){var e=t._peerConnection.iceConnectionState;t._report("rtc_pre_ice_state",{message:e,ice_state:e.toUpperCase()})},t}return _createClass(o,[{key:"getConnectionId",value:function(){return this._connectionId}},{key:"disconnect",value:function(){this._peerConnection.close(),this._dataChannel.close(),this._peerConnection.ontrack=null}},{key:"destroy",value:function(){logger$j.print("destroy"),this.disconnect(),this._context=void 0}},{key:"getTransceivers",value:function(){return this._peerConnection.getTransceivers()}},{key:"_simulcast",value:function(e,t,r,n,i){var o,a,s,c=[];1===e.videoEncodeConfig.length?(c=fillSimulcastLayers(t,i),logger$j.print("simulcast() ","simulcastLayers: %o",c)):(c=map$6(o=slice$1(a=slice$1(s=e.videoEncodeConfig).call(s,1)).call(a,1-i)).call(o,(function(e){var r=constraints2number(e.width),n=t.width/r;return{width:r,height:Math.floor(t.height/n),scaleResolutionDownBy:n,frameRate:constraints2number(e.frameRate)||15,maxkbps:e.maxKbps||600}})),logger$j.print("simulcast() ","simulcastLayers2: %o",c));var l=[!0];c.forEach((function(e,t){var i,o={maxBitrate:1e3*e.maxkbps,scaleResolutionDownBy:e.scaleResolutionDownBy,rid:"".concat(t+1),maxFramerate:e.frameRate};null===(i=r.sendEncodings)||void 0===i||i.unshift(o),n.push({width:e.width,height:e.height,framerate:e.frameRate,maxkbps:e.maxkbps,rid:"".concat(t+1)}),l.push(!0)})),this._context&&(this._context.activeSimStreams=l)}},{key:"internalPublish",value:function(e){var t=e.stream,r=e.videoTrack,n=e.audioTrack,i=e.enableSimulcast,o=e.pubAudio,a=e.pubVideo,s={direction:"sendonly",streams:[t]},c={direction:"sendonly",streams:[t]},l=[],u=[];if(Array.isArray(null==e?void 0:e.videoEncodeConfig)&&e.videoEncodeConfig.length){var d=null==r?void 0:r.getTrack(),p=_objectSpread2({},defaultVideoEncoderConfig);if(d){var _=null==d?void 0:d.getSettings();p={width:Math.floor(_.width),height:Math.floor(_.height),frameRate:Math.floor(_.frameRate)}}"number"!=typeof p.frameRate&&(p.frameRate=30);var h=null==e?void 0:e.videoEncodeConfig[0],f={maxBitrate:1e3*h.maxKbps,rid:"0"};if(e.prevBitrate=h.maxKbps,c.sendEncodings=[f],l.push({width:p.width,height:p.height,framerate:p.frameRate,maxkbps:h.maxKbps,rid:"0"}),!isFirefox&&i){var m,v,g=getSimulcastLayers(p);if(logger$j.print("simulcast() ","maxLayers: %o",g),g>1)this._simulcast(e,_objectSpread2(_objectSpread2({},p),{},{maxKbps:h.maxKbps}),c,l,g),null!==(m=this._context)&&void 0!==m&&null!==(v=m.serverConfig)&&void 0!==v&&v.simulcastOnDemand&&(u=map$6(l).call(l,(function(e,t){return _objectSpread2(_objectSpread2({},e),{},{video_index:t,sub_index:t})})))}}logger$j.print("publish videoTransceiverInit videoDescriptions","",c,l);var y=null==n?void 0:n.getTrack("preprocessing");(null==n?void 0:n.mixType)!==AudioMixingType.PLAYOUT&&null!=n&&n.mixedAudioTrack&&(y=null==n?void 0:n.mixedAudioTrack),y=o&&y?y:"audio";var S=null==r?void 0:r.getTrack("preprocessing");S=a&&S?S:"video";try{this._reportRtcInvokeStatus("Handler.internalPublish",stringify$1({aTrack:MediaTrackStringify(y),vTrack:MediaTrackStringify(S),audioTransceiverInit:s,videoTransceiverInit:c}))}catch(e){}return{semantics:"unified-plan",videoDescriptions:l,subVideoDescriptions:u,audioTransceiverInit:{track:y,init:s},videoTransceiverInit:{track:S,init:c}}}},{key:"updateMaxBitrate",value:function(e){var t,r,n,i;logger$j.print("updateMaxBitrate()");var o=null===(t=e.videoTrack)||void 0===t?void 0:t.getTrack(),a=e.videoTransceiver;if(o&&e.pubVideo&&a){var s=null===(r=e.videoEncodeConfig)||void 0===r||null===(n=r[0])||void 0===n?void 0:n.maxKbps;if(s){if(s===e.prevBitrate)return void logger$j.print("updateMaxBitrate()","no change");e.prevBitrate=s}var c=null===(i=a.sender)||void 0===i?void 0:i.getParameters();if(c){var l;c.encodings=null==c||null===(l=c.encodings)||void 0===l?void 0:map$6(l).call(l,(function(t){var r,n=+t.rid||0,i=null===(r=e.videoEncodeConfig[n])||void 0===r?void 0:r.maxKbps;return"number"==typeof i&&(t.maxBitrate=1e3*i),t})),null==a||a.sender.setParameters(c);try{this._reportRtcInvokeStatus("Handler.updateScaleResolutionDownBy",stringify$1(c.encodings))}catch(e){}}}else logger$j.print("updateMaxBitrate()","no pub")}},{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._report("rtc_set_description",{error_code:0,message:t,is_local:"1",direction:"local"===(null==r?void 0:r.streamUserId)?"up":"down",stream_id:(null==r?void 0:r.streamId)||"",stream_user_id:(null==r?void 0:r.streamUserId)||"",elapse: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._reportRtcInvokeStatus("sctp","sctp state change TO: ".concat(o.state))},o.transport&&(o.transport.onstatechange=function(){var e;a._reportRtcInvokeStatus("dtls","dtls state change TO: ".concat(null==o||null===(e=o.transport)||void 0===e?void 0:e.state))}))),e.next=12;break;case 8:e.prev=8,e.t0=e.catch(1),console.error("setLocal",e.t0),this._report("rtc_set_description",{error_code:-1,message:e.t0.message+t,is_local:"1",direction:"local"===(null==r?void 0:r.streamUserId)?"up":"down",stream_id:"",stream_user_id:"",elapse: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._report("rtc_set_description",{error_code:0,message:t,is_local:"0",direction:"local"===(null==r?void 0:r.streamUserId)?"up":"down",stream_id:(null==r?void 0:r.streamId)||"",stream_user_id:(null==r?void 0:r.streamUserId)||"",elapse:getServerNow()-n},{type:"answer"}),e.next=11;break;case 7:e.prev=7,e.t0=e.catch(1),console.error("setRemote",e.t0),this._report("rtc_set_description",{error_code:-1,message:e.t0.message+t,is_local:"0",direction:"local"===(null==r?void 0:r.streamUserId)?"up":"down",stream_id:(null==r?void 0:r.streamId)||"",stream_user_id:(null==r?void 0:r.streamUserId)||"",elapse: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:"createAVMlineAnswerTpl",value:function(e){var t=this;lib.parse(e).media.forEach((function(e){if("audio"===e.type){if("sendonly"===e.direction){var r,n=null==e?void 0:find$2(r=e.rtp).call(r,(function(e){return"opus"===e.codec}));if(n&&null!=e&&e.fmtp){var i,o=null==e?void 0:find$2(i=e.fmtp).call(i,(function(e){return e.payload===n.payload}));o&&t._context&&(o.config+=";stereo=1;sprop-stereo=1")}t._aSendonlyAnswerTpl=e}}else"video"===e.type&&("sendonly"===e.direction&&(t._vSendonlyAnswerTpl=e),Array.isArray(e.rtp)&&e.rtp.forEach((function(e){var r;null!==(r=e.codec)&&void 0!==r&&includes4(r).call(r,"flexfec")&&(t._enableSubFlexfec=!0)})))}))}},{key:"pc",get:function(){return this._peerConnection}},{key:"addBitrateLimit",value:function(e,t){null==e||e.rtp.forEach((function(r){var n,i=r.codec,o=r.payload;if(includes4(n=["vp8","h264"]).call(n,i.toLocaleLowerCase())){var a,s,c=find$2(a=e.fmtp).call(a,(function(e){return e.payload===o}));if(c)c.config=concat$2(s=[]).call(s,_toConsumableArray(c.config.split(";")),["x-google-min-bitrate=100","x-google-start-bitrate=".concat(t)]).join(";");else e.fmtp.push({payload:o,config:"x-google-min-bitrate=100;x-google-start-bitrate=".concat(t)})}}))}},{key:"_report",value:function(e,t,r){var n;null===(n=this._monitor)||void 0===n||n.report(e,_objectSpread2(_objectSpread2({},t),{},{connection_id:this._connectionId}),r)}},{key:"_reportRtcInvokeStatus",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"",i=arguments.length>4?arguments[4]:void 0;this._report("rtc_invoke_status",{sdk_api_name:e,message:t,error_code:r,stream_id:n,elapse:0},i)}}]),o}(),uncurryThis$4=functionUncurryThis,defineBuiltIns$2=defineBuiltIns$4,getWeakData=internalMetadata.exports.getWeakData,anInstance$2=anInstance$6,anObject$1=anObject$M,isNullOrUndefined=isNullOrUndefined$7,isObject$3=isObject$q,iterate=iterate$A,ArrayIterationModule=arrayIteration,hasOwn$2=hasOwnProperty_1,InternalStateModule$2=internalState,setInternalState$2=InternalStateModule$2.set,internalStateGetterFor=InternalStateModule$2.getterFor,find$1=ArrayIterationModule.find,findIndex2=ArrayIterationModule.findIndex,splice$2=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=findIndex2(this.entries,(function(t){return t[0]===e}));return~t&&splice$2(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$s,uncurryThis$3=functionUncurryThis,defineBuiltIns$1=defineBuiltIns$4,InternalMetadataModule=internalMetadata.exports,collection=collection$3,collectionWeak=collectionWeak$1,isObject$2=isObject$q,isExtensible2=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)&&!isExtensible2(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)&&!isExtensible2(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)&&!isExtensible2(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)&&!isExtensible2(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 path$1=path$v,weakMap$5=path$1.WeakMap,parent$5=weakMap$5,weakMap$4=parent$5,parent$4=weakMap$4,weakMap$3=parent$4,$$6=_export,emplace2=mapEmplace;$$6({target:"WeakMap",proto:!0,real:!0,forced:!0},{emplace:emplace2});var $$5=_export,from3=collectionFrom;$$5({target:"WeakMap",stat:!0,forced:!0},{from:from3});var $$4=_export,of2=collectionOf;$$4({target:"WeakMap",stat:!0,forced:!0},{of:of2});var $$3=_export,deleteAll2=collectionDeleteAll;$$3({target:"WeakMap",proto:!0,real:!0,forced:!0},{deleteAll:deleteAll2});var $$2=_export,upsert2=mapUpsert;$$2({target:"WeakMap",proto:!0,real:!0,forced:!0},{upsert:upsert2});var parent$3=weakMap$3,weakMap$2=parent$3,weakMap$1=weakMap$2,weakMap=weakMap$1,DeviceDetector=function(e){_inherits(_,EnhancedEventEmitter);var t,r,n,i,o,a,s,c,l,u,d,p=_createSuper(_);function _(){var e,t,r;return _classCallCheck(this,_),_defineProperty(_assertThisInitialized(r=p.call(this)),"inited",!1),_defineProperty(_assertThisInitialized(r),"deviceMap",{audioinput:new map2,audiooutput:new map2,videoinput:new map2}),_defineProperty(_assertThisInitialized(r),"checkDeviceChangeTimer",null),_defineProperty(_assertThisInitialized(r),"isSupportedPermissionsQuery",!1),_defineProperty(_assertThisInitialized(r),"isGrantedMicrophonePermission",!1),_defineProperty(_assertThisInitialized(r),"isGrantedCameraPermission",!1),r.isSupportedPermissionsQuery=!isSSR2()&&!(null===(e=navigator)||void 0===e||null===(t=e.permissions)||void 0===t||!t.query),r._handleDeviceChange=r._handleDeviceChange.bind(_assertThisInitialized(r)),!isSSR2()&&r.refreshDevices(),r}return _createClass(_,[{key:"refreshDevices",value:(d=_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=12;break}return e.prev=4,e.next=7,navigator.mediaDevices.getUserMedia({audio:!0});case 7:t=e.sent,e.next=12;break;case 10:e.prev=10,e.t0=e.catch(4);case 12:return e.next=14,navigator.mediaDevices.enumerateDevices();case 14: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 19:case"end":return e.stop()}}),e,this,[[4,10]])}))),function(){return d.apply(this,arguments)})},{key:"initListener",value:(u=_asyncToGenerator(_regeneratorRuntime().mark((function e(){var t,r,n,i,o=this;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(void 0!==(null===(t=navigator.mediaDevices)||void 0===t?void 0:t.ondevicechange)&&"function"==typeof(null===(r=navigator.mediaDevices)||void 0===r?void 0:r.addEventListener)?navigator.mediaDevices.addEventListener("devicechange",(function(){o._handleDeviceChange(),setTimeout((function(){o._handleDeviceChange()}),300)})):this.checkDeviceChangeTimer=window.setInterval((function(){o._handleDeviceChange()}),3e3),!this.isSupportedPermissionsQuery){e.next=22;break}return e.prev=2,e.next=5,navigator.permissions.query({name:"microphone"});case 5:n=e.sent,this.isGrantedMicrophonePermission="granted"===n.state,n.addEventListener("change",(function(){o.isGrantedMicrophonePermission="granted"===n.state})),e.next=12;break;case 10:e.prev=10,e.t0=e.catch(2);case 12:return e.prev=12,e.next=15,navigator.permissions.query({name:"camera"});case 15:i=e.sent,this.isGrantedCameraPermission="granted"===i.state,i.addEventListener("change",(function(){o.isGrantedCameraPermission="granted"===i.state})),e.next=22;break;case 20:e.prev=20,e.t1=e.catch(12);case 22:case"end":return e.stop()}}),e,this,[[2,10],[12,20]])}))),function(){return u.apply(this,arguments)})},{key:"_handleDeviceChange",value:(l=_asyncToGenerator(_regeneratorRuntime().mark((function e(){var t,r,n,i,o,a,s,c=this;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(o=void 0,!isFirefox){e.next=5;break}return e.next=4,navigator.mediaDevices.getUserMedia({audio:!0});case 4:o=e.sent;case 5:return e.next=7,navigator.mediaDevices.enumerateDevices();case 7:a=e.sent,a=filter3(a).call(a,(function(e){return!!e.deviceId})),o&&o.getTracks().forEach((function(e){return e.stop()})),s=from$2(concat$2(t=[]).call(t,_toConsumableArray(values$1(r=this.deviceMap.audioinput).call(r)),_toConsumableArray(values$1(n=this.deviceMap.videoinput).call(n)),_toConsumableArray(values$1(i=this.deviceMap.audiooutput).call(i)))),a.forEach((function(e){var t,r,n=c.deviceMap[e.kind].get(e.deviceId);c.deviceMap[e.kind].set(e.deviceId,e),n||(includes4(t=e.kind).call(t,"video")?c.emit(EngineEventsTypes.onVideoDeviceStateChanged,{mediaDeviceInfo:e,deviceState:"active"}):includes4(r=e.kind).call(r,"audio")&&c.emit(EngineEventsTypes.onAudioDeviceStateChanged,{mediaDeviceInfo:e,deviceState:"active"}))})),s.forEach((function(e){var t,r;find$2(a).call(a,(function(t){return t.deviceId===e.deviceId&&t.kind===e.kind}))||(c.deviceMap[e.kind].delete(e.deviceId),includes4(t=e.kind).call(t,"video")?c.emit(EngineEventsTypes.onVideoDeviceStateChanged,{mediaDeviceInfo:e,deviceState:"inactive"}):includes4(r=e.kind).call(r,"audio")&&c.emit(EngineEventsTypes.onAudioDeviceStateChanged,{mediaDeviceInfo:e,deviceState:"inactive"}))}));case 13:case"end":return e.stop()}}),e,this)}))),function(){return l.apply(this,arguments)})},{key:"getUserMedia",value:(c=_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,navigator.mediaDevices.getUserMedia(t);case 2:return r=e.sent,null!=t&&t.audio&&(this.isGrantedMicrophonePermission=!0),null!=t&&t.video&&(this.isGrantedCameraPermission=!0),this.refreshDevices(),e.abrupt("return",r);case 7:case"end":return e.stop()}}),e,this)}))),function(e){return c.apply(this,arguments)})},{key:"checkPermissionsByDevices",value:(s=_asyncToGenerator(_regeneratorRuntime().mark((function e(){var t,r;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t={audio:!1,video:!1},navigator.mediaDevices){e.next=3;break}return e.abrupt("return",t);case 3:return e.next=5,navigator.mediaDevices.enumerateDevices();case 5:return r=e.sent,t.audio=filter3(r).call(r,(function(e){return"audioinput"===e.kind&&e.label&&e.deviceId})).length>0,t.video=filter3(r).call(r,(function(e){return"videoinput"===e.kind&&e.label&&e.deviceId})).length>0,e.abrupt("return",t);case 9:case"end":return e.stop()}}),e)}))),function(){return s.apply(this,arguments)})},{key:"getPermissions",value:(a=_asyncToGenerator(_regeneratorRuntime().mark((function e(){var t,r,n,i,o,a,s,c=this,l=arguments;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=l.length>0&&void 0!==l[0]?l[0]:{},n=r.audio,i=r.video,o=r.force,n||i||(n=!0,i=!0),a={audio:!1,video:!1},o){e.next=30;break}if(!this.isSupportedPermissionsQuery){e.next=20;break}if(!n||!i){e.next=14;break}if(!this.isGrantedMicrophonePermission||!this.isGrantedCameraPermission){e.next=12;break}return a.audio=!0,a.video=!0,e.abrupt("return",a);case 12:e.next=18;break;case 14:if(!(n&&this.isGrantedMicrophonePermission||i&&this.isGrantedCameraPermission)){e.next=18;break}return a.audio=this.isGrantedMicrophonePermission,a.video=this.isGrantedCameraPermission,e.abrupt("return",a);case 18:case 26:e.next=30;break;case 20:return e.next=22,this.checkPermissionsByDevices();case 22:if(s=e.sent,!n||!i){e.next=28;break}if(!s.audio||!s.video){e.next=26;break}return e.abrupt("return",s);case 28:if(!(n&&s.audio||i&&s.video)){e.next=30;break}return e.abrupt("return",s);case 30:if(null===(t=navigator.mediaDevices)||void 0===t||!t.getUserMedia){e.next=33;break}return e.next=33,navigator.mediaDevices.getUserMedia({audio:n,video:i}).then((function(e){e&&(e.getTracks().forEach((function(e){return e.stop()})),n&&(a.audio=!0,c.isGrantedMicrophonePermission=!0),i&&(a.video=!0,c.isGrantedCameraPermission=!0))})).catch((function(){}));case 33:return e.next=35,this.refreshDevices();case 35:return e.abrupt("return",a);case 36:case"end":return e.stop()}}),e,this)}))),function(){return a.apply(this,arguments)})},{key:"enumerateDevices",value:(o=_asyncToGenerator(_regeneratorRuntime().mark((function e(){var t,r,n,i;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.getPermissions();case 2:return e.next=4,this.refreshDevices();case 4:return e.abrupt("return",from$2(concat$2(t=[]).call(t,_toConsumableArray(values$1(r=this.deviceMap.audioinput).call(r)),_toConsumableArray(values$1(n=this.deviceMap.videoinput).call(n)),_toConsumableArray(values$1(i=this.deviceMap.audiooutput).call(i)))));case 5:case"end":return e.stop()}}),e,this)}))),function(){return o.apply(this,arguments)})},{key:"enumerateAudioCaptureDevices",value:(i=_asyncToGenerator(_regeneratorRuntime().mark((function e(){var t;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.getPermissions({audio:!0});case 2:return e.next=4,this.refreshDevices();case 4:return e.abrupt("return",from$2(values$1(t=this.deviceMap.audioinput).call(t)));case 5:case"end":return e.stop()}}),e,this)}))),function(){return i.apply(this,arguments)})},{key:"enumerateVideoCaptureDevices",value:(n=_asyncToGenerator(_regeneratorRuntime().mark((function e(){var t;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.getPermissions({video:!0});case 2:return e.next=4,this.refreshDevices();case 4:return e.abrupt("return",from$2(values$1(t=this.deviceMap.videoinput).call(t)));case 5:case"end":return e.stop()}}),e,this)}))),function(){return n.apply(this,arguments)})},{key:"enumerateAudioPlaybackDevices",value:(r=_asyncToGenerator(_regeneratorRuntime().mark((function e(){var t;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.getPermissions({audio:!0});case 2:return e.next=4,this.refreshDevices();case 4:return e.abrupt("return",from$2(values$1(t=this.deviceMap.audiooutput).call(t)));case 5:case"end":return e.stop()}}),e,this)}))),function(){return r.apply(this,arguments)})},{key:"getDeviceById",value:(t=_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",find$2(r).call(r,(function(e){return e.deviceId===t})));case 4:case"end":return e.stop()}}),e,this)}))),function(e){return t.apply(this,arguments)})}]),_}(),dd=new DeviceDetector;!isSSR2()&&(window.__rtc_dd__=dd);var logger$i=new Logger("AudioContext",1),WebAudioManager=function(){function e(){var t=this;_classCallCheck(this,e),_defineProperty(this,"_audioContextInstance",void 0),_defineProperty(this,"_contextStuckAt",0);var r=0;isSSR2()||setInterval((function(){if(t._audioContextInstance){var e=t._audioContextInstance.currentTime;t._contextStuckAt?t._contextStuckAt!==e&&(t._contextStuckAt=0,logger$i.print("currentTime resume"),reportGlobalInvokeStatus("currentTime resume","")):e&&r===e&&(t._contextStuckAt=e,logger$i.print("currentTime stuck",t._contextStuckAt),t._audioContextInstance.suspend(),t._audioContextInstance.resume(),reportGlobalInvokeStatus("AudioContext currentTime stuck",t._contextStuckAt)),r=e}}),3e3)}return _createClass(e,[{key:"getAudioContextInstance",value:function(){var e=this;if(!this._audioContextInstance){var t=window.AudioContext||window.webkitAudioContext;this._audioContextInstance=new t,this._audioContextInstance.onstatechange=function(){var t,r;logger$i.print("state change",null===(t=e._audioContextInstance)||void 0===t?void 0:t.state),"interrupted"===(null===(r=e._audioContextInstance)||void 0===r?void 0:r.state)&&e._audioContextInstance.resume()}}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 this._audioSource=r.createMediaElementSource(t),this._audioSource.connect(r.destination);var i=r.createAnalyser();this._audioSource.connect(i),this._analyserNode=i,this._ctx=r}var t;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;t.forEach((function(e){return r=Math.max(r,Math.abs(e-128))}));var n=r/128*255;return n>2?n:0}},{key:"resume",value:(t=_asyncToGenerator(_regeneratorRuntime().mark((function e(){var t;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,null===(t=this._ctx)||void 0===t?void 0:t.resume();case 2:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})},{key:"destroy",value:function(){this._audioSource.disconnect(),this._analyserNode.disconnect()}}]),e}(),audioContextManager=new WebAudioManager,RTCExtensionType=function(e){return e[e.CAPTURE=0]="CAPTURE",e[e.PRE_PROCESSING=1]="PRE_PROCESSING",e[e.ENCODE=2]="ENCODE",e[e.TRANSFER=3]="TRANSFER",e[e.POST_PROCESSING=4]="POST_PROCESSING",e[e.DECODE=5]="DECODE",e[e.RENDERING=6]="RENDERING",e}(RTCExtensionType||{}),ExtensionManager=function(){function e(t){_classCallCheck(this,e),_defineProperty(this,"_plugins",new map2),this.id=t}var t;return _createClass(e,[{key:"register",value:function(e){var t=this._plugins.get(e.type)||[];if(findIndex$1(t).call(t,(function(t){return t.name===e.name}))>-1)throw new Error("Failed to register ".concat(e.name,": name is repeated."));t.push(e),this._plugins.set(e.type,t)}},{key:"getPluginsByType",value:function(e){return this._plugins.get(e)||[]}},{key:"getPluginByName",value:function(e,t){var r;return find$2(r=this._plugins.get(e)||[]).call(r,(function(e){return e.name===t}))}},{key:"getPreProcessingTrack",value:(t=_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:r=this._plugins.get(1)||[],n=t.getTrack(),i=_createForOfIteratorHelper(r),e.prev=3,i.s();case 5:if((o=i.n()).done){e.next=12;break}return a=o.value,e.next=9,a.effect(t,n);case 9:n=e.sent;case 10:e.next=5;break;case 12:e.next=17;break;case 14:e.prev=14,e.t0=e.catch(3),i.e(e.t0);case 17:return e.prev=17,i.f(),e.finish(17);case 20:return e.abrupt("return",n);case 21:case"end":return e.stop()}}),e,this,[[3,14,17,20]])}))),function(e){return t.apply(this,arguments)})},{key:"destroy",value:function(){this._plugins.forEach((function(e){e.forEach((function(e){return e.destroy()}))})),this._plugins.clear()}}]),e}(),SourceType=function(e){return e[e.EXTERNAL=0]="EXTERNAL",e[e.INTERNAL=1]="INTERNAL",e}(SourceType||{}),logger$h=new Logger("VERTC",0),trackStreamMap=new weakMap,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)),"sourceType",1),_defineProperty(_assertThisInitialized(i),"mediaType",void 0),_defineProperty(_assertThisInitialized(i),"_trackId",void 0),_defineProperty(_assertThisInitialized(i),"_ac",void 0),_defineProperty(_assertThisInitialized(i),"_sourceNode",void 0),_defineProperty(_assertThisInitialized(i),"_gainNode",void 0),_defineProperty(_assertThisInitialized(i),"_destNode",void 0),_defineProperty(_assertThisInitialized(i),"_channelCount",void 0),i._trackId=e,i.mediaType=n,"audio"===n&&isWebAudioSupported()&&!getParameter("SKIP_WEB_AUDIO_IN_TRACK")&&(i._ac=audioContextManager.getAudioContextInstance(),i._gainNode=i._ac.createGain(),i._destNode=i._ac.createMediaStreamDestination(),i._gainNode.connect(i._destNode)),i}return _createClass(r,[{key:"getId",value:function(){return this._trackId}},{key:"setVolume",value:function(e){this._gainNode&&(this._gainNode.gain.value=e/100)}},{key:"getVolume",value:function(){return this._gainNode?Math.round(100*this._gainNode.gain.value):-1}},{key:"channelCount",get:function(){var e;return null!==(e=this._channelCount)&&void 0!==e?e:0}},{key:"connectAudioTrack",value:function(e){var t;if(this._channelCount=e.getSettings().channelCount,!isWebAudioSupported()||getParameter("SKIP_WEB_AUDIO_IN_TRACK"))return e;this._sourceNode&&(this._sourceNode.mediaStream.getTracks().forEach((function(e){e.stop()})),delete this._sourceNode);var r,n=new MediaStream;(n.addTrack(e),this._sourceNode=null===(t=this._ac)||void 0===t?void 0:t.createMediaStreamSource(n),this._gainNode)&&(null===(r=this._sourceNode)||void 0===r||r.connect(this._gainNode));return this._destNode.stream.getTracks()[0]}},{key:"destory",value:function(){var e,t,r,n;null===(e=this._sourceNode)||void 0===e||e.mediaStream.getTracks().forEach((function(e){e.stop()})),null===(t=this._destNode)||void 0===t||t.stream.getTracks().forEach((function(e){e.stop()})),null===(r=this._sourceNode)||void 0===r||r.disconnect(),null===(n=this._gainNode)||void 0===n||n.disconnect(),delete this._sourceNode,delete this._gainNode,delete this._destNode}}]),r}(),LocalTrack=function(e){_inherits(n,Track);var t,r=_createSuper(n);function n(e,t,i){var o;return _classCallCheck(this,n),_defineProperty(_assertThisInitialized(o=r.call(this,t,i)),"_mediaTrack",void 0),_defineProperty(_assertThisInitialized(o),"_preProcessingTrack",void 0),_defineProperty(_assertThisInitialized(o),"_originTrack",void 0),_defineProperty(_assertThisInitialized(o),"handleTrackEnded",(function(){o.emit("track-ended",_assertThisInitialized(o)),o.close()})),_defineProperty(_assertThisInitialized(o),"handleMute",(function(){o.emit("track-mute",_assertThisInitialized(o))})),_defineProperty(_assertThisInitialized(o),"handleUnmute",(function(){o.emit("track-unmute",_assertThisInitialized(o))})),o._mediaTrack="audio"===o.mediaType?o.connectAudioTrack(e):e,o._originTrack=e,o._initListeners(),o}return _createClass(n,[{key:"getTrack",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"origin";return"origin"===e?this._mediaTrack:this._preProcessingTrack||this._mediaTrack}},{key:"setTrack",value:function(e,t){this._mediaTrack="audio"===this.mediaType?this.connectAudioTrack(e):e,this._originTrack=e,t&&this.generatePreProcessingTrack(t)}},{key:"generatePreProcessingTrack",value:(t=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){var r;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this._preProcessingTrack=void 0,e.prev=1,e.next=4,t.getPreProcessingTrack(this);case 4:(r=e.sent)instanceof MediaStreamTrack&&(this._preProcessingTrack=r),e.next=11;break;case 8:e.prev=8,e.t0=e.catch(1),console.error(e.t0);case 11:case"end":return e.stop()}}),e,this,[[1,8]])}))),function(e){return t.apply(this,arguments)})},{key:"getOrgTrack",value:function(){return this._originTrack}},{key:"close",value:function(){var e,t,r,n,i;return this._mediaTrack.onended=null,this._mediaTrack.onmute=null,this._mediaTrack.onunmute=null,null===(e=this._originTrack)||void 0===e||e.removeEventListener("ended",this.handleTrackEnded),null===(t=this._originTrack)||void 0===t||t.removeEventListener("mute",this.handleMute),null===(r=this._originTrack)||void 0===r||r.removeEventListener("unmute",this.handleUnmute),null===(n=this._preProcessingTrack)||void 0===n||n.stop(),"audio"===this.mediaType?this.destory():null===(i=this._mediaTrack)||void 0===i?void 0:i.stop()}},{key:"_initListeners",value:function(){this._originTrack instanceof MediaStreamTrack&&(this._originTrack.addEventListener("ended",this.handleTrackEnded),this._originTrack.addEventListener("mute",this.handleMute),this._originTrack.addEventListener("unmute",this.handleUnmute))}}]),n}(),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),_defineProperty(_assertThisInitialized(o),"_originTrack",void 0),o._mediaTrack="audio"===o.mediaType?o.connectAudioTrack(e):e,o._originTrack=e,o}return _createClass(r,[{key:"getTrack",value:function(){return this._mediaTrack}},{key:"getOrgTrack",value:function(){return this._originTrack}},{key:"close",value:function(){return this.destory()}}]),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),"dummy",!1),i.resolution={width:0,height:0},i}return _createClass(n,[{key:"updateVideoCaptureConfig",value:(t=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){var r,n;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.getTrack()){e.next=2;break}return e.abrupt("return");case 2:return logger$h.print("updateVideoEncoderConfig","update localVideoTrack: ",t),delete(r=_objectSpread2({},t)).contentHint,isFirefox&&(r.frameRate={ideal:30,max:30}),e.next=8,this.getTrack().applyConstraints(r);case 8:((n=this.getTrack().getSettings()).width&&n.width!==this.resolution.width||n.height&&n.height!==this.resolution.height)&&(this.resolution={width:n.width,height:n.height},this.emit("resolution-change",this.resolution));case 10:case"end":return e.stop()}}),e,this)}))),function(e){return t.apply(this,arguments)})},{key:"replaceTrack",value:function(e){this.setTrack(e)}},{key:"setContentHint",value:function(e){var t;this._mediaTrack&&"contentHint"in this._mediaTrack&&includes4(t=["text","motion","detail"]).call(t,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),i}return _createClass(n,[{key:"getAudioLevel",value:function(){return this._audioLevelFetcher||(this._audioLevelFetcher=new AudioLevelFetcher(this.getTrack("preprocessing"))),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$h.print("updateAudioCaptureConfig","update localAudioTrack: ",this.audioCaptureConfig),e.next=5,null===(t=this.getOrgTrack())||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.getOrgTrack())),this._audioLevelFetcher.getAudioLevel()}}]),r}(),MicrophoneAudioTrack=function(e){_inherits(r,LocalAudioTrack);var t=_createSuper(r);function r(){var e,n;_classCallCheck(this,r);for(var i=arguments.length,o=new Array(i),a=0;a<i;a++)o[a]=arguments[a];return _defineProperty(_assertThisInitialized(n=t.call.apply(t,concat$2(e=[this]).call(e,o))),"streamIndex",StreamIndex.STREAM_INDEX_MAIN),n}return _createClass(r)}(),CameraVideoTrack=function(e){_inherits(r,LocalVideoTrack);var t=_createSuper(r);function r(){var e,n;_classCallCheck(this,r);for(var i=arguments.length,o=new Array(i),a=0;a<i;a++)o[a]=arguments[a];return _defineProperty(_assertThisInitialized(n=t.call.apply(t,concat$2(e=[this]).call(e,o))),"streamIndex",StreamIndex.STREAM_INDEX_MAIN),n}return _createClass(r)}(),CustomVideoLocalTrack=function(e){_inherits(r,LocalVideoTrack);var t=_createSuper(r);function r(){var e,n;_classCallCheck(this,r);for(var i=arguments.length,o=new Array(i),a=0;a<i;a++)o[a]=arguments[a];return _defineProperty(_assertThisInitialized(n=t.call.apply(t,concat$2(e=[this]).call(e,o))),"streamIndex",StreamIndex.STREAM_INDEX_MAIN),_defineProperty(_assertThisInitialized(n),"sourceType",0),n}return _createClass(r)}(),CustomAudioLocalTrack=function(e){_inherits(r,LocalAudioTrack);var t=_createSuper(r);function r(){var e,n;_classCallCheck(this,r);for(var i=arguments.length,o=new Array(i),a=0;a<i;a++)o[a]=arguments[a];return _defineProperty(_assertThisInitialized(n=t.call.apply(t,concat$2(e=[this]).call(e,o))),"streamIndex",StreamIndex.STREAM_INDEX_MAIN),_defineProperty(_assertThisInitialized(n),"sourceType",0),n}return _createClass(r)}(),ScreenVideoTrack=function(e){_inherits(r,LocalVideoTrack);var t=_createSuper(r);function r(){var e,n;_classCallCheck(this,r);for(var i=arguments.length,o=new Array(i),a=0;a<i;a++)o[a]=arguments[a];return _defineProperty(_assertThisInitialized(n=t.call.apply(t,concat$2(e=[this]).call(e,o))),"streamIndex",StreamIndex.STREAM_INDEX_SCREEN),n}return _createClass(r)}(),ScreenAudioTrack=function(e){_inherits(r,LocalAudioTrack);var t=_createSuper(r);function r(){var e,n;_classCallCheck(this,r);for(var i=arguments.length,o=new Array(i),a=0;a<i;a++)o[a]=arguments[a];return _defineProperty(_assertThisInitialized(n=t.call.apply(t,concat$2(e=[this]).call(e,o))),"streamIndex",StreamIndex.STREAM_INDEX_SCREEN),n}return _createClass(r)}(),CustomScreenVideoLocalTrack=function(e){_inherits(r,LocalVideoTrack);var t=_createSuper(r);function r(){var e,n;_classCallCheck(this,r);for(var i=arguments.length,o=new Array(i),a=0;a<i;a++)o[a]=arguments[a];return _defineProperty(_assertThisInitialized(n=t.call.apply(t,concat$2(e=[this]).call(e,o))),"streamIndex",StreamIndex.STREAM_INDEX_SCREEN),_defineProperty(_assertThisInitialized(n),"sourceType",0),n}return _createClass(r)}(),CustomScreenAudioLocalTrack=function(e){_inherits(r,LocalAudioTrack);var t=_createSuper(r);function r(){var e,n;_classCallCheck(this,r);for(var i=arguments.length,o=new Array(i),a=0;a<i;a++)o[a]=arguments[a];return _defineProperty(_assertThisInitialized(n=t.call.apply(t,concat$2(e=[this]).call(e,o))),"streamIndex",StreamIndex.STREAM_INDEX_SCREEN),_defineProperty(_assertThisInitialized(n),"sourceType",0),n}return _createClass(r)}();function createDummyVideoLocalTrack(e,t){return _createDummyVideoLocalTrack.apply(this,arguments)}function _createDummyVideoLocalTrack(){return(_createDummyVideoLocalTrack=_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 CameraVideoTrack(t,genUuid2())).dummy=!0,e.next=4,n.generatePreProcessingTrack(r);case 4:return e.abrupt("return",n);case 5:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function createDummyScreenVideoLocalTrack(e,t){return _createDummyScreenVideoLocalTrack.apply(this,arguments)}function _createDummyScreenVideoLocalTrack(){return(_createDummyScreenVideoLocalTrack=_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 ScreenVideoTrack(t,genUuid2())).dummy=!0,e.next=4,n.generatePreProcessingTrack(r);case 4:return e.abrupt("return",n);case 5:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function createCameraVideoTrack(e,t){return _createCameraVideoTrack.apply(this,arguments)}function _createCameraVideoTrack(){return(_createCameraVideoTrack=_asyncToGenerator(_regeneratorRuntime().mark((function e(t,r){var n,i,o,a,s,c,l,u;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return o=(null==t||null===(n=t.deviceId)||void 0===n?void 0:n.exact)||"default",a=getMonitor(r.id),e.prev=2,logger$h.print("createCameraVideoTrack","constraints:",t),null==a||a.report("rtc_video_capture_event",{event_type:"start",media_device_id:o}),s=getServerNow(),isFirefox&&(t.frameRate={ideal:30,max:30}),e.next=9,dd.getUserMedia({video:t});case 9:i=e.sent,null==a||a.report("rtc_video_capture_event",{event_type:"start_capture_result",media_device_id:o,reason:"success",elapse:getServerNow()-s}),e.next=17;break;case 13:throw e.prev=13,e.t0=e.catch(2),null==a||a.report("rtc_video_capture_event",{event_type:"running_failed",media_device_id:o,error_code:e.t0.code,reason:e.t0.name+e.t0.message}),new SDKError(ErrorCode.GET_VIDEO_TRACK_FAILED,concat$2(c="throw error from getUserMedia. [".concat(e.t0.name||"unknown name","]: ")).call(c,e.t0.message||"unknown message","."),e.t0);case 17:return l=i.getVideoTracks()[0],trackStreamMap.set(l,i),u=new CameraVideoTrack(l,genUuid2()),e.next=22,u.generatePreProcessingTrack(r);case 22:return e.abrupt("return",u);case 23:case"end":return e.stop()}}),e,null,[[2,13]])})))).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,l,u,d;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return logger$h.print("createMicrophoneAudioTrack","constraints:",t),o=(null==t||null===(n=t.deviceId)||void 0===n?void 0:n.exact)||"default",a=getMonitor(r.id),e.prev=3,null==a||a.report("rtc_video_capture_event",{event_type:"start",media_device_id:o}),s=getServerNow(),(c=r.getPluginByName(RTCExtensionType.PRE_PROCESSING,"RTCAIAnsExtension"))&&(c.isOpen()?(t.autoGainControl=!0,t.noiseSuppression=!1):t.noiseSuppression=!0),e.next=10,dd.getUserMedia({audio:t});case 10:i=e.sent,null==a||a.report("rtc_video_capture_event",{event_type:"start_capture_result",media_device_id:o,reason:"success",elapse:getServerNow()-s}),e.next=18;break;case 14:throw e.prev=14,e.t0=e.catch(3),null==a||a.report("rtc_video_capture_event",{event_type:"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,concat$2(l="throw error from getUserMedia. [".concat(e.t0.name||"unknown name","]: ")).call(l,e.t0.message||"unknown message","."),e.t0);case 18:return u=i.getAudioTracks()[0],trackStreamMap.set(u,i),d=new MicrophoneAudioTrack(u,genUuid2()),e.next=23,d.generatePreProcessingTrack(r);case 23:return e.abrupt("return",d);case 24:case"end":return e.stop()}}),e,null,[[3,14]])})))).apply(this,arguments)}function createScreenTracks(){return _createScreenTracks.apply(this,arguments)}function _createScreenTracks(){return _createScreenTracks=_asyncToGenerator(_regeneratorRuntime().mark((function e(){var t,r,n,i,o,a,s,c,l,u,d=arguments;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=d.length>0&&void 0!==d[0]&&d[0],r=d.length>1?d[1]:void 0,n=d.length>2?d[2]:void 0,logger$h.print("createScreenTracks","withAudio: %o, constraints: %o",t,n),o=getMonitor(r.id),e.prev=5,null==o||o.report("rtc_video_capture_event",{event_type:"start",media_device_id:"screen"}),a=getServerNow(),e.next=10,navigator.mediaDevices.getDisplayMedia({video:!(n&&(!isSafari||16!==safariVersion))||n,audio:!!t&&{channelCount:2,noiseSuppression:!1,echoCancellation:!1,autoGainControl:!1}});case 10:i=e.sent,null==o||o.report("rtc_video_capture_event",{event_type:"start_capture_result",media_device_id:"screen",reason:"success",elapse:getServerNow()-a}),e.next=18;break;case 14:throw e.prev=14,e.t0=e.catch(5),null==o||o.report("rtc_video_capture_event",{event_type:"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 18:return s=i.getVideoTracks()[0],c=new ScreenVideoTrack(s,genUuid2()),e.next=22,c.generatePreProcessingTrack(r);case 22:if(!(l=i.getAudioTracks()[0])){e.next=28;break}return u=new ScreenAudioTrack(l,genUuid2()),e.next=27,u.generatePreProcessingTrack(r);case 27:return e.abrupt("return",[c,u]);case 28:return e.abrupt("return",[c,void 0]);case 29:case"end":return e.stop()}}),e,null,[[5,14]])}))),_createScreenTracks.apply(this,arguments)}function createRemoteVideoTrack(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:genUuid2();return new RemoteVideoTrack(e,t)}function createRemoteAudioTrack(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:genUuid2();return new RemoteAudioTrack(e,t)}function createCustomVideoLocalTrack(e,t){return _createCustomVideoLocalTrack.apply(this,arguments)}function _createCustomVideoLocalTrack(){return(_createCustomVideoLocalTrack=_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 CustomVideoLocalTrack(t,genUuid2()),e.next=3,n.generatePreProcessingTrack(r);case 3:return e.abrupt("return",n);case 4:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function createCustomAudioLocalTrack(e,t){return _createCustomAudioLocalTrack.apply(this,arguments)}function _createCustomAudioLocalTrack(){return(_createCustomAudioLocalTrack=_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 CustomAudioLocalTrack(t,genUuid2()),e.next=3,n.generatePreProcessingTrack(r);case 3:return e.abrupt("return",n);case 4:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function createCustomScreenVideoLocalTrack(e,t){return _createCustomScreenVideoLocalTrack.apply(this,arguments)}function _createCustomScreenVideoLocalTrack(){return(_createCustomScreenVideoLocalTrack=_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 CustomScreenVideoLocalTrack(t,genUuid2()),e.next=3,n.generatePreProcessingTrack(r);case 3:return e.abrupt("return",n);case 4:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function createCustomScreenAudioLocalTrack(e,t){return _createCustomScreenAudioLocalTrack.apply(this,arguments)}function _createCustomScreenAudioLocalTrack(){return(_createCustomScreenAudioLocalTrack=_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 CustomScreenAudioLocalTrack(t,genUuid2()),e.next=3,n.generatePreProcessingTrack(r);case 3:return e.abrupt("return",n);case 4:case"end":return e.stop()}}),e)})))).apply(this,arguments)}var runtimeTrackCls={LocalVideoTrack:LocalVideoTrack,LocalAudioTrack:LocalAudioTrack,RemoteVideoTrack:RemoteVideoTrack,RemoteAudioTrack:RemoteAudioTrack},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,s,c=new Uint8Array(slice$1(a=t.buffer).call(a,i,i+n.headerLength));n.pos===t.position&&t.skip(n.headerLength),o=(n=e.getHeaderPositionAnnexB(t)).pos;var l={header:c,body:new Uint8Array(slice$1(s=t.buffer).call(s,i+c.byteLength,o)),type:-1};e.analyseNal(l),l.type<=9&&0!==l.type&&r.push(l),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,o,a=new Uint8Array(slice$1(i=t.buffer).call(i,t.position,t.position+4));t.skip(4);var s=new Uint8Array(slice$1(o=t.buffer).call(o,t.position,t.position+n));t.skip(n);var c={header:a,body:s,type:-1};e.analyseNal(c),c.type<=9&&0!==c.type&&r.push(c)}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}}}]),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,r=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=new Uint8Array([0,0,0,1]),i=new Uint8Array([6]),o=new Uint8Array([5]),a=r?UUID_INTERNAL:UUID_EXTERNAL,s=serializeData(e.byteLength+a.byteLength),c=rbsp2ebsp(e);return new Uint8Array(concat$2(t=[]).call(t,_toConsumableArray(n),_toConsumableArray(i),_toConsumableArray(o),_toConsumableArray(s),_toConsumableArray(a),_toConsumableArray(c),[128]))}},{key:"decodeSeiBody",value:function(e){e=slice$1(e).call(e,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&&slice$1(t).call(t,r,r+UUID_EXTERNAL.byteLength).toString()===UUID_EXTERNAL.toString()?(r+=UUID_EXTERNAL.byteLength,o=1):t.byteLength>=UUID_EXTERNAL.byteLength&&i>=UUID_EXTERNAL.byteLength&&slice$1(t).call(t,r,r+UUID_INTERNAL.byteLength).toString()===UUID_INTERNAL.toString()&&(r+=UUID_INTERNAL.byteLength,o=0),{type:o,payload:slice$1(t).call(t,r,a)}}}}},{key:"parseInternalSEI",value:function(e){var t=new map2,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,a=_slicedToArray(deserializeData(e.payload,r),2),s=a[0];if(r=a[1],t.get(i)||!(s<=e.payload.byteLength-r))break;t.set(i,slice$1(o=e.payload).call(o,r,r+s)),r+=s}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 l=reduce3(r).call(r,(function(e,t){return e+t.byteLength}),0),u=new Uint8Array(l);return reduce3(r).call(r,(function(e,t){return u.set(t,e),e+t.byteLength}),0),u}}]),e}(),Stats=function(){function e(t){_classCallCheck(this,e),_defineProperty(this,"player",void 0),_defineProperty(this,"_timer",void 0),_defineProperty(this,"handler",void 0),_defineProperty(this,"_monitor",void 0),this.id=t,this._monitor=getMonitor(t)}return _createClass(e,[{key:"setVar",value:function(e){this.handler=e}},{key:"clearTimer",value:function(){this._timer&&(clearTimeout(this._timer),delete this._timer,reportRtcInvokeStatus(this.id,"del_media_statistics_timer","".concat((new Error).stack),0,this._stream.streamId||""))}},{key:"filterIllegal",value:function(e){var t={};return keys$8(e).forEach((function(r){null===e[r]||void 0===e[r]||Number.isNaN(e[r])||(t[r]=e[r])})),t}},{key:"destroy",value:function(){reportRtcInvokeStatus(this.id,"media_statistics_destroy","".concat((new Error).stack),0,"".concat(this._stream.streamId)),this.clearTimer()}}]),e}(),LocalStatsReport=function(e){_inherits(i,Stats);var t,r,n=_createSuper(i);function i(e,t){var r;return _classCallCheck(this,i),_defineProperty(_assertThisInitialized(r=n.call(this,e)),"_context",void 0),r._stream=t,r}return _createClass(i,[{key:"setLocalStreamStatsEvtInterval",value:function(e,t,r){var n,i,o,a=this;if(!this._timer){this.setVar(t),this._context=r;var s={audio:{},video:{}},c=this._stream,l=null===(n=c.audioTrack)||void 0===n?void 0:n.getTrack("preprocessing"),u=null===(i=c.videoTrack)||void 0===i?void 0:i.getTrack("preprocessing");this.getAudioStats(l,s,null===(o=c.audioTrack)||void 0===o?void 0:o.getAudioLevel()),this.getVideoStats(u,s);var d=function(){var e=_asyncToGenerator(_regeneratorRuntime().mark((function e(){var t,r,n,i,o,l,u;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.getTrack("preprocessing"),o=null===(r=c.videoTrack)||void 0===r?void 0:r.getTrack("preprocessing"),e.next=4,a.getAudioStats(i,s,null===(n=c.audioTrack)||void 0===n?void 0:n.getAudioLevel());case 4:return l=e.sent,e.next=7,a.getVideoStats(o,s);case 7:return u=e.sent,e.abrupt("return",{audioStats:l,videoStats:u,isScreen:c.isScreen});case 9:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),p=function(){var t=_asyncToGenerator(_regeneratorRuntime().mark((function t(){var r;return _regeneratorRuntime().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,d();case 2:r=t.sent,e(r),a._timer=setTimeout(p,2e3);case 5:case"end":return t.stop()}}),t)})));return function(){return t.apply(this,arguments)}}();this._timer=setTimeout(p,2e3)}}},{key:"unpublish",value:function(){this.clearTimer()}},{key:"getAudioStats",value:(r=_asyncToGenerator(_regeneratorRuntime().mark((function e(t,r,n){var i,o,a,s,c,l,u,d,p,_,h,f,m;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(o={},a={timestamp:Date.now()},s=this._stream,c=s.streamId,l=s.audioMid,u=s.isScreen,d=s.pubAttributes,p=s.pubAudio,_=s.audioTrack,h={media_type:"audio",is_screen:!!u,direction:"up",stream_id:c,vid:l,connection_status:navigator.onLine,track_enabled:null==t?void 0:t.enabled,capture_state:d.localaudio?"capture_state_on":"capture_state_off",mute_state:p?"mute_state_off":"mute_state_on"},_&&(h.playback_volume=_.getVolume()),t&&this.handler){e.next=7;break}return e.abrupt("return",o);case 7:return e.next=9,this.handler.getStats(t);case 9:if((f=e.sent).length){e.next=12;break}return e.abrupt("return",o);case 12:if(f.forEach((function(e){var t=e.type,r=e.packetsSent,n=e.packetsLost,i=e.bytesSent,s=e.clockRate,c=e.roundTripTime,l=e.channels,u=e.audioLevel;e.googRtt;var d=e.mimeType,p=e.availableIncomingBitrate,_=e.availableOutgoingBitrate,f=e.bytesReceived,m=e.nominated,v=e.id,g=e.currentRoundTripTime,y=e.state,S=e.writable,T=e.requestsReceived,$=e.responsesReceived,E=e.requestsSent,b=e.consentRequestsSent,I=e.responsesSent,R=e.jitter,C=e.candidateType,A=e.ip,k=e.address,P=e.networkType,O=e.port,w=e.protocol,M=e.nackCount,D=e.retransmittedBytesSent,x=e.retransmittedPacketsSent,N=e.audioInputLevel,L=e.ssrc,U=e.totalAudioEnergy,V=e.totalSamplesDuration,F=e.mediaType,j=e.fractionLost;"outbound-rtp"===t?(a.packetsSent=r,a.bytesSent=i,h.bytes=i,h.packetsSent=r,h.nackCount=M,h.ssrc=L,h.retransmitted_bytes_sent=D,h.retransmitted_packets_sent=x,a.retransmittedBytesSent=D,a.retransmittedPacketsSent=x):"remote-inbound-rtp"===t?(a.packetsLost=n,h.packetsLost=n,h.net_jitter=1e3*R,o.rtt=1e3*c,h.rtt=o.rtt,o._fractionLost=j||0):"codec"===t?(o.recordSampleRate=s,o.numChannels=l,h.codecName=d):"media-source"===t&&void 0!==u?(h.audio_level=u?-10*log102(Math.pow(u,2)):u,h.volume=255*u,h.total_audio_energy=U,h.totalInputDuration=V):"ssrc"===t&&"audio"===F?h.send_level=N:"candidate-pair"===t?(h.ice_available_incoming_bitrate=p,h.ice_available_outgoing_bitrate=_,h.ice_bytes_received=f,h.ice_bytes_sent=i,h.ice_nominated=+m,h.ice_pair_id=v,h.ice_pair_rtt=g,h.ice_pair_state=y,h.ice_pair_writable=S,h.recv_ping_requests=T,h.recv_ping_responses=$,h.sent_ping_requests_before_first_response=E,h.sent_ping_requests_total=E+(b||0),h.sent_ping_responses=I):"local-candidate"===t?(h.local_candidate_type=C,h.local_ip=A||k,h.local_network_type=P,h.local_port=O,h.protocol=w):"remote-candidate"===t&&(h.remote_candidate_type=C,h.remote_ip=A||k,h.remote_port=O);var B=getParameter("STATS_SCALLBACK_SUPPORT");isStatsCallbackSupport&&B||"media-source"===t&&(h.send_level=u)})),void 0===h.volume&&void 0!==n&&(h.volume=n,h.audio_level=n?-10*log102(Math.pow(n/255,2)):n),(m=r.audio).timestamp){e.next=18;break}return r.audio=a,e.abrupt("return",this.filterIllegal(o));case 18:return void 0!==a.packetsLost&&(o.audioLossRate=(a.packetsLost-m.packetsLost)/(a.packetsSent-m.packetsSent),o.audioLossRate=Number.isNaN(o.audioLossRate)?0:o.audioLossRate,h.fraction_lost=o.audioLossRate),o.statsInterval=a.timestamp-m.timestamp,h.stats_interval=o.statsInterval,o.sendKBitrate=(a.bytesSent-m.bytesSent||0)/o.statsInterval*8,h.mediaBitratebps=Math.round(1e3*o.sendKBitrate),h.bandwidth=Math.round(h.mediaBitratebps/1024),void 0!==a.retransmittedBytesSent&&(h.retransmitBitratebps=(a.retransmittedBytesSent-m.retransmittedBytesSent||0)/o.statsInterval),r.audio=a,null===(i=this._monitor)||void 0===i||i.report("rtc_media_statistics",h),o._retransmittedRate=(a.retransmittedPacketsSent-m.retransmittedPacketsSent)/(a.packetsSent-m.packetsSent),void 0===o.audioLossRate&&(o.audioLossRate=o._retransmittedRate,h.fraction_lost=o.audioLossRate),o._fractionLost=Math.max(o._fractionLost,o.audioLossRate),e.abrupt("return",this.filterIllegal(o));case 31: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,l,u,d,p,_,h,f,m,v,g,y,S;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n={},i={timestamp:Date.now(),simulcast:{}},o=this._stream,a=o.streamId,s=o.videoMid,c=o.isScreen,l=o.pubAttributes,u=o.enableSimulcast,d=o.pubVideo,e.t0=_objectSpread2,e.t1={media_type:"video",is_screen:!!c,direction:"up",stream_id:a,vid:s,connection_status:navigator.onLine,track_enabled:null==t?void 0:t.enabled,capture_state:l.localvideo?"capture_state_on":"capture_state_off",mute_state:d?"mute_state_off":"mute_state_on"},e.next=7,this._stream.requestVideoFrameCallback();case 7:if(e.t2=e.sent,p=(0,e.t0)(e.t1,e.t2),t&&this.handler){e.next=11;break}return e.abrupt("return",n);case 11:return p.cap_frame_width=t.getSettings().width,p.cap_frame_height=t.getSettings().height,n.isScreen=c,e.next=16,this.handler.getStats(t);case 16:if((_=e.sent).length){e.next=19;break}return e.abrupt("return",n);case 19:if(h=0,_.forEach((function(e){var o=e.type,a=e.framesEncoded,s=e.packetsLost,c=e.bytesSent,l=e.framesSent,d=e.retransmittedBytesSent,_=e.totalPacketSendDelay,f=e.totalEncodeTime,m=e.firCount,v=e.targetBitrate,g=e.roundTripTime,y=e.mimeType,S=e.frameWidth,T=e.frameHeight,$=e.packetsSent,E=e.googActualEncBitrate,b=e.googAvailableReceiveBandwidth,I=e.googAvailableSendBandwidth,R=e.googAvgEncodeMs,C=e.googBucketDelay,A=e.googEncodeUsagePercent,k=e.googFrameRateInput,P=e.availableIncomingBitrate,O=e.availableOutgoingBitrate,w=e.bytesReceived,M=e.nominated,D=e.id,x=e.currentRoundTripTime,N=e.state,L=e.writable,U=e.candidateType,V=e.ip,F=e.address,j=e.networkType,B=e.port,G=e.nackCount,z=e.pliCount,H=e.protocol,K=e.qpSum,W=e.requestsReceived,Y=e.responsesReceived,q=e.googRetransmitBitrate,X=e.requestsSent,Z=e.consentRequestsSent,Q=e.responsesSent,J=e.ssrc,ee=e.googTargetEncBitrate,te=e.googTransmitBitrate,re=e.retransmittedPacketsSent,ne=e.encoderImplementation,ie=e.jitter,oe=e.rid,ae=e.fractionLost,se=e.googAdaptationChanges,ce=e.qualityLimitationReason,le=e.qualityLimitationDurations,ue=e.googFirsReceived,de=e.googFrameRateSent,pe=e.keyFramesEncoded;"outbound-rtp"===o?(u&&(oe?i.simulcast[oe]=e:i.simulcast[h]=e,h++),i.framesEncoded=a||i.framesEncoded||0,p.key_frames_encoded=pe||0,i.bytesSent=c||i.bytesSent||0,i.framesSent=l||i.framesSent||0,p.bytes=c||p.bytes||0,i.packetsSent=$||i.packetsSent||0,p.packetsSent=$||p.packetsSent||0,p.nackCount=G||p.nackCount||0,p.pli_count=z||p.pli_count||0,p.qp_sum=K||p.qp_sum||0,p.ssrc=J||p.ssrc||0,p.retransmitted_packets_sent=re,i.retransmittedPacketsSent=re,i.retransmittedBytesSent=d,p.encoder_implementation=ne,p.qualityLimitationReason=ce,p.qualityLimitationDurations=le,void 0!==S&&((!n.encodedFrameWidth||S>n.encodedFrameWidth)&&(n.encodedFrameWidth=S),(!n.encodedFrameHeight||T>n.encodedFrameHeight)&&(n.encodedFrameHeight=T),p.frame_size_height=T,p.frame_size_width=S)):"track"===o?(n.encodedFrameWidth=S,n.encodedFrameHeight=T,p.frame_size_height=T,p.frame_size_width=S):"remote-inbound-rtp"===o?(i.packetsLost=s,n.rtt=1e3*g,p.rtt=n.rtt,p.jitter=ie,p.packetsLost=s,n._fractionLost=ae||0):"codec"===o?(n.codecType=y,p.codecName=y):"candidate-pair"===o?(p.ice_available_incoming_bitrate=P,p.ice_available_outgoing_bitrate=O,p.ice_bytes_received=w,p.ice_bytes_sent=c,p.ice_nominated=+M,p.ice_pair_id=D,p.ice_pair_rtt=x,p.ice_pair_state=N,p.ice_pair_writable=L,p.recv_ping_requests=W,p.recv_ping_responses=Y,p.sent_ping_requests_before_first_response=X,p.sent_ping_requests_total=X+Z,p.sent_ping_responses=Q):"local-candidate"===o?(p.local_candidate_type=U,p.local_ip=V||F,p.local_network_type=j,p.local_port=B,p.protocol=H):"remote-candidate"===o?(p.remote_candidate_type=U,p.remote_ip=V||F,p.remote_port=B):"VideoBwe"===o?(p.encBitratebps=E,p.available_receive_bandwidth=b,p.available_send_bandwidth=I,p.bucket_delay=C,p.retransmitBitratebps=q,p.targetEncBitratebps=ee,p.transmit_bitrate=te,n._sendBandWidth=+I):"ssrc"===o&&(p.avg_encode_ms=R,p.encodeUsage=A,p.frame_rate_input=k,p.orignal_input_Framerate=+k,p.ddaptationChanges=se,p.firsReceived=ue,p.frameRateSent=de);var _e=getParameter("STATS_SCALLBACK_SUPPORT");if(!isStatsCallbackSupport||!_e){var he=r.video,fe=i.timestamp-he.timestamp;if("outbound-rtp"===o){var me=c-he.bytesSent,ve=d-he.retransmittedBytesSent;p.encBitratebps=Math.round(8e3*(me-ve)/fe),p.bucket_delay=_/$,p.retransmitBitratebps=Math.round(8e3*ve/fe),p.targetEncBitratebps=v,p.transmit_bitrate=Math.round(1e3*(c-he.bytesSent)*8/fe),p.avg_encode_ms=1e3*f/a,p.firsReceived=m+z}else"candidate-pair"===o&&(p.available_send_bandwidth=O,n._sendBandWidth=O);if(t){var ge=null==t?void 0:t.getSettings().frameRate;p.orignal_input_Framerate=ge,p.frameRateSent=t.getSettings().frameRate}}})),(f=r.video).timestamp){e.next=25;break}return r.video=i,e.abrupt("return",this.filterIllegal(n));case 25:return n.statsInterval=i.timestamp-f.timestamp,p.stats_interval=n.statsInterval,m=keys$8(i.simulcast),u?(p.sim_enc_width=[],p.sim_enc_height=[],p.sim_enc_bps=[],p.sim_enc_framerate=[],p.sim_enc_key_frames=[],p.sim_rids=[],p.sim_enc_bandwidth=[],p.sim_sent_framerate=[],p.sim_fraction_lost=[],p.sim_keyencoded=[],p.active_sim_streams=(null===(v=this._context)||void 0===v?void 0:v.activeSimStreams)||[],p.sim_retransmittedRate=[],y=!1,sort2(m).call(m,(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,l=t.packetsLost,u=t.packetsSent,d=t.qualityLimitationReason,_=t.qualityLimitationDurations,h=t.qualityLimitationResolutionChanges,m=t.retransmittedPacketsSent,v=t.pliCount,g=t.keyFramesEncoded;void 0!==d&&(p.sim_qualityLimitationReason||(p.sim_qualityLimitationReason=[],p.sim_qualityLimitationDurations=[],p.sim_qualityLimitationResolutionChanges=[]),p.sim_qualityLimitationReason.push(d),p.sim_qualityLimitationDurations.push(_),p.sim_qualityLimitationResolutionChanges.push(h));var S=f.simulcast[e];if(p.sim_enc_width.push(r||0),p.sim_enc_height.push(o||0),p.sim_enc_key_frames.push(g||0),S){var T=(a-S.bytesSent||0)/n.statsInterval;p.sim_enc_bps.push(Math.round(8e3*T)),p.sim_enc_bandwidth.push(Math.round(8e3*T/1024));var $=1e3*(s-S.framesEncoded)/n.statsInterval;p.sim_enc_framerate.push(Math.round($)),p.sim_rids.push(e);var E=void 0!==c?c-S.framesSent:s-S.framesEncoded,b=1e3*E/n.statsInterval;p.sim_sent_framerate.push(Math.round(b));var I=(l-S.packetsLost)/(u-S.packetsSent);n._retransmittedRate=(m-S.retransmittedPacketsSent)/(u-S.packetsSent),I=Number.isNaN(I)?0:I,p.sim_fraction_lost.push(I),p.sim_keyencoded.push(v-S.pliCount>0),p.sim_retransmittedRate.push(n._retransmittedRate),r>0&&!y&&(n.sentKBitrate=8*T,n.encoderOutputFrameRate=$,n.encodedFrameCount=E,n.sentFrameRate=b,n.videoLossRate=I,y=!0)}})),null===(g=this._monitor)||void 0===g||g.report("rtc_media_statistics",p)):(n.encodedFrameCount=void 0!==i.framesSent?i.framesSent-f.framesSent:i.framesEncoded-f.framesEncoded,n.sentKBitrate=(i.bytesSent-f.bytesSent||0)/n.statsInterval*8,p.bitrate=Math.round(1e3*n.sentKBitrate),p.bandwidth=Math.round(p.bitrate/1024),n.encoderOutputFrameRate=1e3*(i.framesEncoded-f.framesEncoded)/n.statsInterval,p.frame_rate_encoded=Math.round(n.encoderOutputFrameRate),n.sentFrameRate=1e3*n.encodedFrameCount/n.statsInterval,p.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,p.fraction_lost=n.videoLossRate,n._retransmittedRate=(i.retransmittedPacketsSent-f.retransmittedPacketsSent)/(i.packetsSent-f.packetsSent),null===(S=this._monitor)||void 0===S||S.report("rtc_media_statistics",p)),r.video=i,n._fractionLost=Math.max(n._fractionLost,n.videoLossRate),e.abrupt("return",this.filterIllegal(n));case 32: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,t){var r;return _classCallCheck(this,o),_defineProperty(_assertThisInitialized(r=i.call(this,e)),"isPaused",void 0),_defineProperty(_assertThisInitialized(r),"pauseStart",void 0),_defineProperty(_assertThisInitialized(r),"pauseDuration",void 0),_defineProperty(_assertThisInitialized(r),"_audioStallCount",void 0),_defineProperty(_assertThisInitialized(r),"_setAudioStallCount",void 0),_defineProperty(_assertThisInitialized(r),"_audioStallTimer",void 0),_defineProperty(_assertThisInitialized(r),"_audioStallInterval",void 0),_defineProperty(_assertThisInitialized(r),"_audioStallRatio",void 0),_defineProperty(_assertThisInitialized(r),"_videoInWaiting",void 0),_defineProperty(_assertThisInitialized(r),"_context",void 0),r._stream=t,r._videoInWaiting=!1,r.pauseDuration=0,r}return _createClass(o,[{key:"setRemoteStreamStatsEvtInterval",value:(n=_asyncToGenerator(_regeneratorRuntime().mark((function e(t,r,n){var i,a,s,c,l,u,d,p,_,h,f,m,v,g,y,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(r),this._context=n,this._audioStallInterval=o.audioStallInterval||100,this._audioStallRatio=o.audioStallRatio||.6,c={audio:{},video:{}},l=this._stream,u=null===(i=l.audioTrack)||void 0===i?void 0:i.getOrgTrack(),d=null===(a=l.videoTrack)||void 0===a?void 0:a.getTrack(),this.getRemoteVideoStats(d,c),e.next=13,this.getRemoteAudioStats(u,c,null===(s=this._stream.audioTrack)||void 0===s?void 0:s.getAudioLevel());case 13:this.delStatsEvtInterval(),p=0,_=0,f=[],m=0,v=getServerNow(),this._setAudioStallCount=function(){if(Config.AUDIO_STALL&&S._audioStallInterval>0&&void 0!==c.audio.concealedSamples){var e=c.audio.concealedSamples,t=c.audio.totalSamplesReceived;v=getServerNow();var r={isStall:!1,counted:!1,diff:0},n=.5*S._audioStallInterval;S._audioStallCount=_asyncToGenerator(_regeneratorRuntime().mark((function i(){var o,a,s,c,u,d,h,g,y,T,$,E,b,I,R,C,A;return _regeneratorRuntime().wrap((function(i){for(;;)switch(i.prev=i.next){case 0:if(a=l.hasAudio,s=l.subAudio,a&&s){i.next=7;break}return r.isStall=!1,r.counted=!1,f.push({reason:concat$2(c="hasAudio: ".concat(a,", subAudio: ")).call(c,s)}),v=getServerNow(),i.abrupt("return",{stall_count:p,stall_duration:_,stall_list:f,stats_count:m});case 7:return u=null===(o=l.audioTrack)||void 0===o?void 0:o.getOrgTrack(),d=Date.now(),i.next=11,S.handler.getStats(u,!0);case 11:if(h=i.sent,g=Date.now(),y=getServerNow(),!((T=y-v)<n)){i.next=18;break}return f.push({diff:T,start:v,end:y,get_stats_cost:g-d,get_stats_start:d,get_stats_end:g,reason:concat$2($="diff(".concat(T,") < minInterval(")).call($,n,")")}),i.abrupt("return",{stall_count:p,stall_duration:_,stall_list:f,stats_count:m});case 18:if(E=h.length,b=find$2(h).call(h,(function(e){return"inbound-rtp"===e.type}))){i.next=23;break}return f.push({diff:T,start:v,end:y,get_stats_cost:g-d,get_stats_start:d,get_stats_end:g,reason:E?"no inbound-rtp":"no report"}),i.abrupt("return",{stall_count:p,stall_duration:_,stall_list:f,stats_count:m});case 23:return I=b.concealedSamples,R=b.totalSamplesReceived,A=R-t,(C=I-e)>=0&&A>=0&&C>=S._audioStallRatio*A?(f.push({concealed:C,received:A,diff:T,start:v,end:y,get_stats_cost:g-d,get_stats_start:d,get_stats_end:g,is_stall:!0}),r.isStall?(r.counted?_+=T:(_=_+r.diff+T,p++),r.counted=!0):T>=200?(_+=T,p++,r.counted=!0):(r.counted=!1,r.diff=T),r.isStall=!0):(f.push({concealed:C,received:A,diff:T,start:v,end:y,get_stats_cost:g-d,get_stats_start:d,get_stats_end:g}),r.isStall=!1,r.counted=!1),e=I,t=R,v=y,m++,i.abrupt("return",{stall_count:p,stall_duration:_,stall_list:f,stats_count:m});case 32:case"end":return i.stop()}}),i)}))),h=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=6;break}return e.next=4,S._audioStallCount();case 4:S._audioStallTimer&&clearTimeout(S._audioStallTimer),S._audioStallTimer=setTimeout(h,S._audioStallInterval);case 6:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),S._audioStallTimer&&clearTimeout(S._audioStallTimer),S._audioStallTimer=setTimeout(h,S._audioStallInterval)}},this._setAudioStallCount(),g=function(){var e=_asyncToGenerator(_regeneratorRuntime().mark((function e(){var t,r,n,i,o,a,s;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=null===(t=l.audioTrack)||void 0===t?void 0:t.getOrgTrack(),o=null===(r=l.videoTrack)||void 0===r?void 0:r.getTrack(),e.next=4,S.getRemoteAudioStats(i,c,null===(n=S._stream.audioTrack)||void 0===n?void 0:n.getAudioLevel());case 4:return a=e.sent,p=0,_=0,f=[],m=0,e.next=11,S.getRemoteVideoStats(o,c);case 11:return s=e.sent,e.abrupt("return",{audioStats:a,videoStats:s,isScreen:l.isScreen,userId:l.userId});case 13:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),y=function(){var e=_asyncToGenerator(_regeneratorRuntime().mark((function e(){var r;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,g();case 2:r=e.sent,t(r),h&&(v=getServerNow(),S._audioStallTimer&&clearTimeout(S._audioStallTimer),S._audioStallTimer=setTimeout(h,S._audioStallInterval)),S._timer&&clearTimeout(S._timer),S._timer=setTimeout(y,2e3);case 7:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),this._timer&&clearTimeout(this._timer),this._timer=setTimeout(y,2e3);case 25:case"end":return e.stop()}}),e,this)}))),function(e,t,r){return n.apply(this,arguments)})},{key:"delStatsEvtInterval",value:function(){_get(_getPrototypeOf(o.prototype),"clearTimer",this).call(this),clearTimeout(this._audioStallTimer),this._audioStallCount=void 0,this._setAudioStallCount=void 0,this.pauseDuration=0}},{key:"unsubscribe",value:function(){this.delStatsEvtInterval(),this._videoInWaiting=!1}},{key:"getRemoteAudioStats",value:(r=_asyncToGenerator(_regeneratorRuntime().mark((function e(t,r,n){var i,o,a,s,c,l,u,d,p,_,h,f,m,v,g,y,S,T,$,E,b,I=this;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(o={},a={},s=this._stream,c=s.streamId,l=s.userId,u=s.isScreen,d=s.audioMid,p=s.subMediaType,_=s._attributes,h=s.virtual,f=s.audioTrack,m={media_type:"audio",is_screen:!!u,direction:"down",stream_id:c,stream_user_id:l,vid:d,audio_mux:h,connection_status:navigator.onLine,track_enabled:null==t?void 0:t.enabled,mute_state:audioInMediaType(p)?"mute_state_off":"mute_state_on",remote_user_capture_state:_.localaudio?"capture_state_on":"capture_state_off",remote_user_mute_state:_.localaudio&&_.audiostream?"mute_state_off":"mute_state_on"},f&&(m.playback_volume=f.getVolume()),t&&this.handler){e.next=7;break}return e.abrupt("return",o);case 7:return e.next=9,this.handler.getStats(t);case 9:if((v=e.sent).length){e.next=12;break}return e.abrupt("return",o);case 12:if(v.forEach((function(e){var t=e.type,r=e.packetsLost,i=e.packetsReceived,s=e.bytesReceived,l=e.jitterBufferDelay,u=e.jitterBufferEmittedCount,d=e.clockRate,p=e.channels,_=e.totalSamplesReceived,h=e.concealedSamples,f=e.silentConcealedSamples,v=e.concealmentEvents,g=e.totalRoundTripTime,y=e.packetsDiscarded,S=e.state,T=e.currentRoundTripTime,$=e.audioLevel,E=e.totalAudioEnergy,b=e.totalSamplesDuration,R=e.mimeType,C=e.googDecodingNormal,A=e.googDecodingMuted,k=e.availableIncomingBitrate,P=e.availableOutgoingBitrate,O=e.bytesSent,w=e.nominated,M=e.id,D=e.writable,x=e.jitter,N=e.candidateType,L=e.ip,U=e.address,V=e.networkType,F=e.port,j=e.protocol,B=e.audioOutputLevel,G=e.requestsReceived,z=e.responsesReceived,H=e.requestsSent,K=e.consentRequestsSent,W=e.responsesSent,Y=e.ssrc;e.kind;var q=e.nackCount,X=e.lastPacketReceivedTimestamp,Z=e.concealmentevents,Q=e.fecPacketsReceived;if("inbound-rtp"===t)a.packetsLost=r,a.packetsReceived=i,m.packetsReceived=i,m.packetsDiscarded=y,m.nackCount=q,m.lastPacketReceivedTimestamp=X,m.concealmentevents=Z,a.bytesReceived=s,void 0!==l&&(o.jitterBufferDelay=l/u*1e3,m.average_jitter_buffer_delay_ms=o.jitterBufferDelay),void 0!==_&&(a.totalSamplesReceived=_,o.concealedSamples=h,a.concealedSamples=h,a.silentConcealedSamples=f,m.concealedSamples=h,o.concealmentEvents=v,m.totalSamplesReceived=_),void 0!==Q&&(m.fec_packets_received=Q,a.fecPacketsReceived=Q),m.jitter=1e3*x,m.ssrc=Y,void 0!==$&&0!==$?(m.audio_level=$?-10*log102(Math.pow($,2)):$,m.volume=255*$):(m.volume=null!=n?n:255*$,m.audio_level=n?-10*log102(Math.pow(n/255,2)):n),void 0!==E&&(m.total_audio_energy=E),void 0!==b&&(m.totalAudioDuration=b);else if("codec"===t)o.recordSampleRate=d,p&&(o.numChannels=p),m.codecName=R;else if("candidate-pair"===t){var J,ee,te;m.ice_available_incoming_bitrate=k,m.ice_available_outgoing_bitrate=P,m.ice_bytes_received=s,m.ice_bytes_sent=O,m.ice_nominated=+w,m.ice_pair_id=M,m.ice_pair_rtt=T,m.rtt=1e3*T,m.rtt&&null!==(J=I._context)&&void 0!==J&&null!==(ee=J.streamRTT)&&void 0!==ee&&null!==(te=ee[c])&&void 0!==te&&te.audio&&(m.total_rtt_ms=m.rtt+I._context.streamRTT[c].audio),m.ice_pair_state=S,m.ice_pair_writable=D,m.recv_ping_requests=G,m.recv_ping_responses=z,m.sent_ping_requests_before_first_response=H,m.sent_ping_requests_total=H+(K||0),m.sent_ping_responses=W,"succeeded"===S&&(o.rtt=1e3*T,o.total_rtt=1e3*g)}else"track"===t&&void 0!==$?(0===$&&0!==n?(m.volume=n,m.audio_level=n?-10*log102(Math.pow(n/255,2)):n):(m.audio_level=$?-10*log102(Math.pow($,2)):$,m.volume=255*$),m.total_audio_energy=E,m.totalAudioDuration=b):"ssrc"===t?(m.decodingNormal=C,m.recvAudioLevel=B,m.decodingMuted=A):"local-candidate"===t?(m.local_candidate_type=N,m.local_ip=L||U,m.local_network_type=V,m.local_port=F,m.protocol=j):"remote-candidate"===t&&(m.remote_candidate_type=N,m.remote_ip=L||U,m.remote_port=F)})),(g=r.audio).timestamp){e.next=18;break}return a.timestamp=Date.now(),r.audio=a,e.abrupt("return",this.filterIllegal(o));case 18:if(y={},void 0!==a.concealedSamples&&(m.interval_concealed_samples=a.concealedSamples-g.concealedSamples,m.interval_samples_received=a.totalSamplesReceived-g.totalSamplesReceived,m.interval_silent_concealed_samples=a.silentConcealedSamples-g.silentConcealedSamples),!(this._audioStallInterval>0&&void 0!==g.concealedSamples)){e.next=36;break}if(!this._audioStallCount&&this._setAudioStallCount&&this._setAudioStallCount(),clearTimeout(this._audioStallTimer),!this._audioStallCount){e.next=36;break}return e.next=26,this._audioStallCount();case 26:S=e.sent,T=S.stall_count,$=S.stall_duration,E=S.stall_list,b=S.stats_count,y.stall_list=E,y.stats_count=b,m.concealedSamples===m.interval_concealed_samples&&m.totalSamplesReceived===m.interval_samples_received?(m.stall_count=0,m.stall_duration=0):(m.stall_count=T,m.stall_duration=$),o.stallCount=m.stall_count,o.stallDuration=m.stall_duration;case 36:return a.timestamp=Date.now(),o.audioLossRate=(a.packetsLost-g.packetsLost)/(a.packetsReceived-g.packetsReceived+(a.packetsLost-g.packetsLost)),o.audioLossRate=Number.isNaN(o.audioLossRate)?0:o.audioLossRate,m.packetsLost=Math.round(a.packetsLost-g.packetsLost),m.fraction_lost=o.audioLossRate,o.statsInterval=a.timestamp-g.timestamp,m.stats_interval=o.statsInterval,o.receivedKBitrate=(a.bytesReceived-g.bytesReceived||0)/o.statsInterval*8,m.bandwidth=Math.round(1e3*o.receivedKBitrate/1024),void 0!==a.concealedSamples&&(o.receivedSampleRate=1e3*m.interval_samples_received/o.statsInterval),void 0!==a.fecPacketsReceived&&(m.fecBitratebps=(a.fecPacketsReceived-g.fecPacketsReceived||0)/o.statsInterval),m.average_jitter_buffer_delay_ms&&m.total_rtt_ms&&(o.e2eDelay=m.average_jitter_buffer_delay_ms+m.total_rtt_ms),r.audio=a,null===(i=this._monitor)||void 0===i||i.report("rtc_media_statistics",m,y),e.abrupt("return",this.filterIllegal(o));case 51:case"end":return e.stop()}}),e,this)}))),function(e,t,n){return r.apply(this,arguments)})},{key:"getRemoteVideoStats",value:(t=_asyncToGenerator(_regeneratorRuntime().mark((function e(t,r){var n,i,o,a,s,c,l,u,d,p,_,h,f,m=this;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i={},o={timestamp:Date.now()},a=this._stream,s=a.streamId,c=a.userId,l=a.isScreen,u=a.subMediaType,d=a._attributes,e.t0=_objectSpread2,e.t1={media_type:"video",is_screen:!!l,direction:"down",stream_id:s,stream_user_id:c,vid:this._stream.videoMid,connection_status:navigator.onLine,track_enabled:null==t?void 0:t.enabled,mute_state:videoInMediaType(u)?"mute_state_off":"mute_state_on",remote_user_capture_state:d.localvideo?"capture_state_on":"capture_state_off",remote_user_mute_state:d.localvideo&&d.videostream?"mute_state_off":"mute_state_on"},e.next=7,this._stream.requestVideoFrameCallback();case 7:if(e.t2=e.sent,p=(0,e.t0)(e.t1,e.t2),t&&this.handler){e.next=11;break}return e.abrupt("return",i);case 11:return i.isScreen=l,e.next=14,this.handler.getStats(t);case 14:if((_=e.sent).length){e.next=17;break}return e.abrupt("return",i);case 17:if(_.forEach((function(e){var t=e.type,r=e.frameHeight,n=e.frameWidth,a=e.packetsLost,c=e.packetsReceived,l=e.bytesReceived,u=e.framesDecoded,d=e.jitterBufferDelay,_=e.jitterBufferEmittedCount,h=e.mimeType,f=e.firCount,v=e.availableIncomingBitrate,g=e.availableOutgoingBitrate,y=e.bytesSent,S=e.nominated,T=e.id,$=e.currentRoundTripTime,E=e.state,b=e.writable,I=e.candidateType,R=e.ip,C=e.address,A=e.networkType,k=e.port,P=e.nackCount,O=e.pliCount,w=e.protocol,M=e.requestsReceived,D=e.responsesReceived,x=e.requestsSent,N=e.consentRequestsSent,L=e.responsesSent,U=e.ssrc,V=e.jitter,F=e.framesReceived,j=e.keyFramesDecoded,B=e.totalDecodeTime,G=e.decoderImplementation,z=e.lastPacketReceivedTimestamp;if("inbound-rtp"===t)o.packetsLost=a,p.packetsLost=a,o.packetsReceived=c,p.packetsReceived=c,o.bytesReceived=l,p.bytes=l,o.framesDecoded=u,o.totalDecodeTime=B,void 0!==d&&(o.jitterBufferDelay=d/_*1e3,p.average_jitter_buffer_delay_ms=o.jitterBufferDelay),p.fir_count=f,p.nackCount=P,o.nackCount=P,p.pli_count=O,p.ssrc=U,p.jitter=V,p.framesReceived=F,o.framesReceived=F,p.framesDecoded=u,p.key_frames_decoded=j,p.decoder_name=G,p.last_packet_received_timestamp=z,void 0!==n&&(i.width=n,p.frame_size_width=n,i.height=r,p.frame_size_height=r);else if("track"===t&&void 0!==n)i.width=n,p.frame_size_width=n,i.height=r,p.frame_size_height=r,void 0!==F&&(p.framesReceived=F,o.framesReceived=F);else if("codec"===t)p.codecName=h;else if("candidate-pair"===t){var H,K,W;p.ice_available_incoming_bitrate=v,p.ice_available_outgoing_bitrate=g,p.ice_bytes_received=l,p.ice_bytes_sent=y,p.ice_nominated=+S,p.ice_pair_id=T,p.ice_pair_rtt=$,p.rtt=1e3*$,p.rtt&&null!==(H=m._context)&&void 0!==H&&null!==(K=H.streamRTT)&&void 0!==K&&null!==(W=K[s])&&void 0!==W&&W.video&&(p.total_rtt_ms=p.rtt+m._context.streamRTT[s].video),i.rtt=p.rtt,p.ice_pair_state=E,p.ice_pair_writable=b,p.recv_ping_requests=M,p.recv_ping_responses=D,p.sent_ping_requests_before_first_response=x,p.sent_ping_requests_total=x+(N||0),p.sent_ping_responses=L}else"local-candidate"===t?(p.local_candidate_type=I,p.local_ip=R||C,p.local_network_type=A,p.local_port=k,p.protocol=w):"remote-candidate"===t&&(p.remote_candidate_type=I,p.remote_ip=R||C,p.remote_port=k)})),(h=r.video).timestamp){e.next=22;break}return r.video=o,e.abrupt("return",this.filterIllegal(i));case 22:return i.videoLossRate=(o.packetsLost-h.packetsLost)/(o.packetsReceived-h.packetsReceived+(o.packetsLost-h.packetsLost)),h.totalDecodeTime&&h.framesDecoded&&o.framesDecoded!==h.framesDecoded&&(p.decode_elapse_per_frame=+((o.totalDecodeTime-h.totalDecodeTime)/(o.framesDecoded-h.framesDecoded)*1e3).toFixed(2)),i._retransmittedRate=(o.nackCount-h.nackCount)/(o.packetsReceived-h.packetsReceived+(o.packetsLost-h.packetsLost)),i.videoLossRate=Number.isNaN(i.videoLossRate)?0:i.videoLossRate,p.fraction_lost=i.videoLossRate,i.statsInterval=o.timestamp-h.timestamp,p.stats_interval=i.statsInterval,i.receivedKBitrate=(o.bytesReceived-h.bytesReceived||0)/i.statsInterval*8,p.bitrate=Math.round(1e3*i.receivedKBitrate),p.bandwidth=Math.round(p.bitrate/1024),i.decoderOutputFrameRate=1e3*(o.framesDecoded-h.framesDecoded)/i.statsInterval,i.receivedFrameRate=1e3*(o.framesReceived-h.framesReceived)/i.statsInterval,p.frame_rate_decoded=Math.round(i.decoderOutputFrameRate),p.frame_rate_received=Math.round(i.receivedFrameRate),p.average_jitter_buffer_delay_ms&&p.total_rtt_ms&&(i.e2eDelay=p.average_jitter_buffer_delay_ms+p.total_rtt_ms),r.video=o,this.processStall(this._stream,p,i,l),this.isPaused?(f=o.timestamp-(this.pauseStart||0),p.pause_duration=this.pauseDuration+(f>500?f:0),this.pauseStart=o.timestamp):p.pause_duration=this.pauseDuration,p.pause_duration=Math.min(p.stall_duration||p.stuck_length||0,p.pause_duration),this.pauseDuration=0,null===(n=this._monitor)||void 0===n||n.report("rtc_media_statistics",p),e.abrupt("return",this.filterIllegal(i));case 44: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&&this.player&&this.player.played){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=Math.min(o,t.stats_interval),t.stall_duration=void 0):(t.stall_duration=Math.min(o,t.stats_interval),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,logger$g=new Logger("Stream",0),StreamBase=function(e){_inherits(r,EnhancedEventEmitter);var t=_createSuper(r);function r(){var e,n;_classCallCheck(this,r);for(var i=arguments.length,o=new Array(i),a=0;a<i;a++)o[a]=arguments[a];return _defineProperty(_assertThisInitialized(n=t.call.apply(t,concat$2(e=[this]).call(e,o))),"videoDom",void 0),n}return _createClass(r,[{key:"requestVideoFrameCallback",value:function(){var e=this;return new promise((function(t){var r,n=null===(r=e.videoDom)||void 0===r?void 0:r.requestVideoFrameCallback;if("function"==typeof n){var i=function(e,r){var n={};keys$8(r).forEach((function(e){var t=e.replace(/[a-z]{1}[A-Z]{1}/g,(function(e){var t;return concat$2(t="".concat(e[0],"_")).call(t,e[1].toLowerCase())}));n["video_".concat(t)]=r[e]})),clearInterval(o),t(n)};n.call(e.videoDom,i);var o=setTimeout((function(){var r;null===(r=e.videoDom)||void 0===r||r.cancelVideoFrameCallback(i),t({})}),500)}else t({})}))}},{key:"stopReport",value:function(){this.statsReport.destroy()}}]),r}(),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(e){_inherits(r,StreamBase);var t=_createSuper(r);function r(e){var n;return _classCallCheck(this,r),_defineProperty(_assertThisInitialized(n=t.call(this)),"isScreen",!1),_defineProperty(_assertThisInitialized(n),"stream",void 0),_defineProperty(_assertThisInitialized(n),"streamId",void 0),_defineProperty(_assertThisInitialized(n),"audioMid",void 0),_defineProperty(_assertThisInitialized(n),"videoMid",void 0),_defineProperty(_assertThisInitialized(n),"seiList",[]),_defineProperty(_assertThisInitialized(n),"videoTrack",void 0),_defineProperty(_assertThisInitialized(n),"audioTrack",void 0),_defineProperty(_assertThisInitialized(n),"videoTransceiver",void 0),_defineProperty(_assertThisInitialized(n),"audioTransceiver",void 0),_defineProperty(_assertThisInitialized(n),"videoEncodeConfig",[defaultVideoEncoderConfig]),_defineProperty(_assertThisInitialized(n),"subVideoDescriptions",[]),_defineProperty(_assertThisInitialized(n),"enableSimulcast",!1),_defineProperty(_assertThisInitialized(n),"observer",void 0),_defineProperty(_assertThisInitialized(n),"statsReport",void 0),_defineProperty(_assertThisInitialized(n),"prevBitrate",0),_defineProperty(_assertThisInitialized(n),"pubAudio",!1),_defineProperty(_assertThisInitialized(n),"pubVideo",!1),_defineProperty(_assertThisInitialized(n),"pubAttributes",void 0),n.engineId=e,n.stream=new MediaStream,n.pubAttributes={localaudio:!1,localvideo:!1,videostream:!1,audiostream:!1,extvideo:!1,extaudio:!1},n.statsReport=new LocalStatsReport(e,_assertThisInitialized(n)),n}return _createClass(r,[{key:"audioHasCapture",get:function(){return this.pubAttributes.localaudio}},{key:"audioHasPublish",get:function(){return this.pubAttributes.audiostream}},{key:"videoHasCapture",get:function(){return this.pubAttributes.localvideo}},{key:"videoHasPublish",get:function(){return this.pubAttributes.videostream}},{key:"hasPublished",get:function(){return this.audioMid&&this.videoMid}},{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,o=SEIHelper.generateSEI(n.content),a=new Uint8Array(o.byteLength+t.data.byteLength);if(0===n.repeatCount)splice$3(i=e.seiList).call(i,0,1);n.repeatCount--,a.set(new Uint8Array(t.data)),a.set(o,t.data.byteLength),t.data=a.buffer,r.enqueue(t)}else r.enqueue(t)}});n.pipeThrough(o).pipeTo(i)}}else logger$g.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$g.print("no sender found when trying to bind encodedTransform")}},{key:"clean",value:function(){var e;reportRtcInvokeStatus(this.engineId,"localstream_clean","".concat((new Error).stack),0,this.streamId||""),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.stopReport(),this.prevBitrate=0,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)}}]),r}(),RemoteStream=function(e){_inherits(r,StreamBase);var t=_createSuper(r);function r(e,n,i,o,a){var s;return _classCallCheck(this,r),_defineProperty(_assertThisInitialized(s=t.call(this)),"streamId",void 0),_defineProperty(_assertThisInitialized(s),"userId",void 0),_defineProperty(_assertThisInitialized(s),"isScreen",void 0),_defineProperty(_assertThisInitialized(s),"hasVideo",void 0),_defineProperty(_assertThisInitialized(s),"hasAudio",void 0),_defineProperty(_assertThisInitialized(s),"_attributes",void 0),_defineProperty(_assertThisInitialized(s),"streamState",void 0),_defineProperty(_assertThisInitialized(s),"observer",void 0),_defineProperty(_assertThisInitialized(s),"statsReport",void 0),_defineProperty(_assertThisInitialized(s),"subVideo",void 0),_defineProperty(_assertThisInitialized(s),"subAudio",void 0),_defineProperty(_assertThisInitialized(s),"subMediaType",void 0),_defineProperty(_assertThisInitialized(s),"subLayer",void 0),_defineProperty(_assertThisInitialized(s),"audioMid",void 0),_defineProperty(_assertThisInitialized(s),"videoMid",void 0),_defineProperty(_assertThisInitialized(s),"_sequenceId",void 0),_defineProperty(_assertThisInitialized(s),"stream",void 0),_defineProperty(_assertThisInitialized(s),"videoTrack",void 0),_defineProperty(_assertThisInitialized(s),"audioTrack",void 0),_defineProperty(_assertThisInitialized(s),"videoTransceiver",void 0),_defineProperty(_assertThisInitialized(s),"audioTransceiver",void 0),_defineProperty(_assertThisInitialized(s),"recordedVideoFrames",void 0),_defineProperty(_assertThisInitialized(s),"stillExist",void 0),_defineProperty(_assertThisInitialized(s),"originalMediaType",void 0),_defineProperty(_assertThisInitialized(s),"priority",void 0),_defineProperty(_assertThisInitialized(s),"originalStreamIndex",0),_defineProperty(_assertThisInitialized(s),"virtual",void 0),s.engineId=e,s.virtual=!1,s.userId=n,s.isScreen=o,s.streamId=i,s.hasAudio=a.audiostream&&a.localaudio,s.hasVideo=a.videostream&&a.localvideo,s._attributes=a,s.subVideo=!1,s.subAudio=!1,s._sequenceId=0,s.subMediaType=ExtendMediaType.NONE,s.subLayer={spatialLayer:0,spatialSubLayer:-1},s.streamState=0,s.statsReport=new RemoteStatsReport(e,_assertThisInitialized(s)),s}return _createClass(r,[{key:"audioHasCapture",get:function(){return this._attributes.localaudio}},{key:"audioHasPublish",get:function(){return this._attributes.audiostream}},{key:"videoHasCapture",get:function(){return this._attributes.localvideo}},{key:"videoHasPublish",get:function(){return this._attributes.videostream}},{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$g.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$g.print("no receiver found when trying to bind encodedTransform")}},{key:"ontrack",value:function(e){var t,r,n;try{var i;reportRtcInvokeStatus(this.engineId,"Stream.ontrack",stringify$1({uid:this.userId,streamId:this.streamId,streams:reduce3(i=e.streams).call(i,(function(e,t){return e+MediaStreamStringify(t)}),""),transceiver:MediaTransceiverStringify(e.transceiver),track:MediaTrackStringify(e.track)}),0,this.streamId||"")}catch(e){}if(null!==(t=e.streams)&&void 0!==t&&null!==(r=t[0])&&void 0!==r&&null!==(n=r.id)&&void 0!==n&&includes4(n).call(n,this.streamId)){var o,a=e.track;"video"===(null==a?void 0:a.kind)?this._setVideoTrack(a):"audio"===(null===(o=e.track)||void 0===o?void 0:o.kind)&&this._setAudioTrack(a),this._setStream(e.streams[0])}this.safeEmit("ontrack",e)}},{key:"clean",value:function(){var e,t,r;logger$g.print("clean",concat$2(e="exec stream.clean ".concat(this.streamId," ")).call(e,this.userId)),reportRtcInvokeStatus(this.engineId,"remotestream_clean","".concat((new Error).stack),0,this.streamId),this.subAudio=!1,this.subVideo=!1,this.audioMid=void 0,this.videoMid=void 0,this.sequenceId=0,this.videoTrack=void 0,null===(t=this.audioTrack)||void 0===t||t.close(),this.audioTrack=void 0,this.stream=void 0,this.videoTransceiver=void 0,this.audioTransceiver=void 0,this.recordedVideoFrames=void 0,null===(r=this.observer)||void 0===r||r.reset(),this.stopReport(),delete this.priority}},{key:"resetHasSubscribed",value:function(){this.streamState=0}},{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=createRemoteAudioTrack(e),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=createRemoteVideoTrack(e),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=find$2(i).call(i,(function(e){return e.width===a&&e.height===s}));return{spatialLayer:e,spatialSubLayer:(null==c?void 0:c.sub_index)||-1}}}]),r}(),logger$f=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,r=this._queue.length,n="";return this._queue=filter3(t=this._queue).call(t,(function(t){return t.streamId!==e.streamId||e.action!==negativedAction[t.action]||(n=t.streamId,logger$f.print("offsetStreamId",n),!1)})),this._queue.length===r&&this._queue.push(e),this.emit("start"),n}},{key:"dequeue",value:function(){var e;if(!this._queue.length)return null;var t=this._queue.length;chromeVersion&&chromeVersion>=86&&chromeVersion<=92&&(t=Math.min(this._queue.length,5));for(var r=aggregationSdpStrategy[this._queue[0].action],n=1;n<t;n++){var i;if(aggregationSdpStrategy[this._queue[n].action]!==r)return{sdpStrategy:r,items:splice$3(i=this._queue).call(i,0,n)}}return{sdpStrategy:r,items:splice$3(e=this._queue).call(e,0,t)}}}]),r}(),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$c=Object.prototype,hasOwnProperty$9=objectProto$c.hasOwnProperty,nativeObjectToString$1=objectProto$c.toString,symToStringTag$1=Symbol$2?Symbol$2.toStringTag:void 0;function getRawTag(e){var t=hasOwnProperty$9.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$b=Object.prototype,nativeObjectToString=objectProto$b.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 isArray2=Array.isArray,isArray$1=isArray2;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$2="[object Function]",genTag$1="[object GeneratorFunction]",proxyTag="[object Proxy]";function isFunction(e){if(!isObject$1(e))return!1;var t=baseGetTag(e);return t==funcTag$2||t==genTag$1||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$a=Object.prototype,funcToString=funcProto.toString,hasOwnProperty$8=objectProto$a.hasOwnProperty,reIsNative=RegExp("^"+funcToString.call(hasOwnProperty$8).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}var WeakMap=getNative(root$1,"WeakMap"),WeakMap$1=WeakMap,objectCreate=Object.create,baseCreate=function(){function e(){}return function(t){if(!isObject$1(t))return{};if(objectCreate)return objectCreate(t);e.prototype=t;var r=new e;return e.prototype=void 0,r}}(),baseCreate$1=baseCreate;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)}function copyArray(e,t){var r=-1,n=e.length;for(t||(t=Array(n));++r<n;)t[r]=e[r];return t}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$1=function(){try{var e=getNative(Object,"defineProperty");return e({},"",{}),e}catch(e){}}(),defineProperty$2=defineProperty$1,baseSetToString=defineProperty$2?function(e,t){return defineProperty$2(e,"toString",{configurable:!0,enumerable:!1,value:constant(t),writable:!0})}:identity,baseSetToString$1=baseSetToString,setToString=shortOut(baseSetToString$1),setToString$1=setToString;function arrayEach(e,t){for(var r=-1,n=null==e?0:e.length;++r<n&&!1!==t(e[r],r,e););return e}var 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$2?defineProperty$2(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$9=Object.prototype,hasOwnProperty$7=objectProto$9.hasOwnProperty;function assignValue(e,t,r){var n=e[t];hasOwnProperty$7.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$8=Object.prototype;function isPrototype(e){var t=e&&e.constructor;return e===("function"==typeof t&&t.prototype||objectProto$8)}function baseTimes(e,t){for(var r=-1,n=Array(e);++r<e;)n[r]=t(r);return n}var argsTag$2="[object Arguments]";function baseIsArguments(e){return isObjectLike(e)&&baseGetTag(e)==argsTag$2}var objectProto$7=Object.prototype,hasOwnProperty$6=objectProto$7.hasOwnProperty,propertyIsEnumerable$1=objectProto$7.propertyIsEnumerable,isArguments=baseIsArguments(function(){return arguments}())?baseIsArguments:function(e){return isObjectLike(e)&&hasOwnProperty$6.call(e,"callee")&&!propertyIsEnumerable$1.call(e,"callee")},isArguments$1=isArguments;function stubFalse(){return!1}var freeExports$2="object"==typeof exports&&exports&&!exports.nodeType&&exports,freeModule$2=freeExports$2&&"object"==typeof module&&module&&!module.nodeType&&module,moduleExports$2=freeModule$2&&freeModule$2.exports===freeExports$2,Buffer$1=moduleExports$2?root$1.Buffer:void 0,nativeIsBuffer=Buffer$1?Buffer$1.isBuffer:void 0,isBuffer=nativeIsBuffer||stubFalse,isBuffer$1=isBuffer,argsTag$1="[object Arguments]",arrayTag$1="[object Array]",boolTag$2="[object Boolean]",dateTag$2="[object Date]",errorTag$1="[object Error]",funcTag$1="[object Function]",mapTag$4="[object Map]",numberTag$2="[object Number]",objectTag$2="[object Object]",regexpTag$2="[object RegExp]",setTag$4="[object Set]",stringTag$2="[object String]",weakMapTag$2="[object WeakMap]",arrayBufferTag$2="[object ArrayBuffer]",dataViewTag$3="[object DataView]",float32Tag$2="[object Float32Array]",float64Tag$2="[object Float64Array]",int8Tag$2="[object Int8Array]",int16Tag$2="[object Int16Array]",int32Tag$2="[object Int32Array]",uint8Tag$2="[object Uint8Array]",uint8ClampedTag$2="[object Uint8ClampedArray]",uint16Tag$2="[object Uint16Array]",uint32Tag$2="[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$2]=typedArrayTags[float64Tag$2]=typedArrayTags[int8Tag$2]=typedArrayTags[int16Tag$2]=typedArrayTags[int32Tag$2]=typedArrayTags[uint8Tag$2]=typedArrayTags[uint8ClampedTag$2]=typedArrayTags[uint16Tag$2]=typedArrayTags[uint32Tag$2]=!0,typedArrayTags[argsTag$1]=typedArrayTags[arrayTag$1]=typedArrayTags[arrayBufferTag$2]=typedArrayTags[boolTag$2]=typedArrayTags[dataViewTag$3]=typedArrayTags[dateTag$2]=typedArrayTags[errorTag$1]=typedArrayTags[funcTag$1]=typedArrayTags[mapTag$4]=typedArrayTags[numberTag$2]=typedArrayTags[objectTag$2]=typedArrayTags[regexpTag$2]=typedArrayTags[setTag$4]=typedArrayTags[stringTag$2]=typedArrayTags[weakMapTag$2]=!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,freeProcess=moduleExports$1&&freeGlobal$1.process,nodeUtil=function(){try{var e=freeModule$1&&freeModule$1.require&&freeModule$1.require("util").types;return e||freeProcess&&freeProcess.binding&&freeProcess.binding("util")}catch(e){}}(),nodeUtil$1=nodeUtil,nodeIsTypedArray=nodeUtil$1&&nodeUtil$1.isTypedArray,isTypedArray=nodeIsTypedArray?baseUnary(nodeIsTypedArray):baseIsTypedArray,isTypedArray$1=isTypedArray,objectProto$6=Object.prototype,hasOwnProperty$5=objectProto$6.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 l in e)!t&&!hasOwnProperty$5.call(e,l)||a&&("length"==l||i&&("offset"==l||"parent"==l)||o&&("buffer"==l||"byteLength"==l||"byteOffset"==l)||isIndex(l,c))||s.push(l);return s}function overArg(e,t){return function(r){return e(t(r))}}var nativeKeys=overArg(Object.keys,Object),nativeKeys$1=nativeKeys,objectProto$5=Object.prototype,hasOwnProperty$4=objectProto$5.hasOwnProperty;function baseKeys(e){if(!isPrototype(e))return nativeKeys$1(e);var t=[];for(var r in Object(e))hasOwnProperty$4.call(e,r)&&"constructor"!=r&&t.push(r);return t}function keys3(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$4=Object.prototype,hasOwnProperty$3=objectProto$4.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$3.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,nativeCreate=getNative(Object,"create"),nativeCreate$1=nativeCreate;function hashClear(){this.__data__=nativeCreate$1?nativeCreate$1(null):{},this.size=0}function hashDelete(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t}var HASH_UNDEFINED$1="__lodash_hash_undefined__",objectProto$3=Object.prototype,hasOwnProperty$2=objectProto$3.hasOwnProperty;function hashGet(e){var t=this.__data__;if(nativeCreate$1){var r=t[e];return r===HASH_UNDEFINED$1?void 0:r}return hasOwnProperty$2.call(t,e)?t[e]:void 0}var objectProto$2=Object.prototype,hasOwnProperty$1=objectProto$2.hasOwnProperty;function hashHas(e){var t=this.__data__;return nativeCreate$1?void 0!==t[e]:hasOwnProperty$1.call(t,e)}var HASH_UNDEFINED="__lodash_hash_undefined__";function hashSet(e,t){var r=this.__data__;return this.size+=this.has(e)?0:1,r[e]=nativeCreate$1&&void 0===t?HASH_UNDEFINED:t,this}function Hash(e){var t=-1,r=null==e?0:e.length;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}function listCacheClear(){this.__data__=[],this.size=0}function assocIndexOf(e,t){for(var r=e.length;r--;)if(eq(e[r][0],t))return r;return-1}Hash.prototype.clear=hashClear,Hash.prototype.delete=hashDelete,Hash.prototype.get=hashGet,Hash.prototype.has=hashHas,Hash.prototype.set=hashSet;var arrayProto=Array.prototype,splice$1=arrayProto.splice;function listCacheDelete(e){var t=this.__data__,r=assocIndexOf(t,e);return!(r<0)&&(r==t.length-1?t.pop():splice$1.call(t,r,1),--this.size,!0)}function listCacheGet(e){var t=this.__data__,r=assocIndexOf(t,e);return r<0?void 0:t[r][1]}function listCacheHas(e){return assocIndexOf(this.__data__,e)>-1}function listCacheSet(e,t){var r=this.__data__,n=assocIndexOf(r,e);return n<0?(++this.size,r.push([e,t])):r[n][1]=t,this}function ListCache(e){var t=-1,r=null==e?0:e.length;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}ListCache.prototype.clear=listCacheClear,ListCache.prototype.delete=listCacheDelete,ListCache.prototype.get=listCacheGet,ListCache.prototype.has=listCacheHas,ListCache.prototype.set=listCacheSet;var Map=getNative(root$1,"Map"),Map$1=Map;function mapCacheClear(){this.size=0,this.__data__={hash:new Hash,map:new(Map$1||ListCache),string:new Hash}}function isKeyable(e){var t=typeof e;return"string"==t||"number"==t||"symbol"==t||"boolean"==t?"__proto__"!==e:null===e}function getMapData(e,t){var r=e.__data__;return isKeyable(t)?r["string"==typeof t?"string":"hash"]:r.map}function mapCacheDelete(e){var t=getMapData(this,e).delete(e);return this.size-=t?1:0,t}function mapCacheGet(e){return getMapData(this,e).get(e)}function mapCacheHas(e){return getMapData(this,e).has(e)}function mapCacheSet(e,t){var r=getMapData(this,e),n=r.size;return r.set(e,t),this.size+=r.size==n?0:1,this}function MapCache(e){var t=-1,r=null==e?0:e.length;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}function arrayPush(e,t){for(var r=-1,n=t.length,i=e.length;++r<n;)e[i+r]=t[r];return e}MapCache.prototype.clear=mapCacheClear,MapCache.prototype.delete=mapCacheDelete,MapCache.prototype.get=mapCacheGet,MapCache.prototype.has=mapCacheHas,MapCache.prototype.set=mapCacheSet;var getPrototype=overArg(Object.getPrototypeOf,Object),getPrototype$1=getPrototype;function stackClear(){this.__data__=new ListCache,this.size=0}function stackDelete(e){var t=this.__data__,r=t.delete(e);return this.size=t.size,r}function stackGet(e){return this.__data__.get(e)}function stackHas(e){return this.__data__.has(e)}var LARGE_ARRAY_SIZE=200;function stackSet(e,t){var r=this.__data__;if(r instanceof ListCache){var n=r.__data__;if(!Map$1||n.length<LARGE_ARRAY_SIZE-1)return n.push([e,t]),this.size=++r.size,this;r=this.__data__=new MapCache(n)}return r.set(e,t),this.size=r.size,this}function Stack(e){var t=this.__data__=new ListCache(e);this.size=t.size}function baseAssign(e,t){return e&&copyObject(t,keys3(t),e)}function baseAssignIn(e,t){return e&&copyObject(t,keysIn(t),e)}Stack.prototype.clear=stackClear,Stack.prototype.delete=stackDelete,Stack.prototype.get=stackGet,Stack.prototype.has=stackHas,Stack.prototype.set=stackSet;var freeExports="object"==typeof exports&&exports&&!exports.nodeType&&exports,freeModule=freeExports&&"object"==typeof module&&module&&!module.nodeType&&module,moduleExports=freeModule&&freeModule.exports===freeExports,Buffer=moduleExports?root$1.Buffer:void 0,allocUnsafe=Buffer?Buffer.allocUnsafe:void 0;function cloneBuffer(e,t){if(t)return e.slice();var r=e.length,n=allocUnsafe?allocUnsafe(r):new e.constructor(r);return e.copy(n),n}function arrayFilter(e,t){for(var r=-1,n=null==e?0:e.length,i=0,o=[];++r<n;){var a=e[r];t(a,r,e)&&(o[i++]=a)}return o}function stubArray(){return[]}var objectProto$1=Object.prototype,propertyIsEnumerable3=objectProto$1.propertyIsEnumerable,nativeGetSymbols$1=Object.getOwnPropertySymbols,getSymbols=nativeGetSymbols$1?function(e){return null==e?[]:(e=Object(e),arrayFilter(nativeGetSymbols$1(e),(function(t){return propertyIsEnumerable3.call(e,t)})))}:stubArray,getSymbols$1=getSymbols;function copySymbols(e,t){return copyObject(e,getSymbols$1(e),t)}var nativeGetSymbols=Object.getOwnPropertySymbols,getSymbolsIn=nativeGetSymbols?function(e){for(var t=[];e;)arrayPush(t,getSymbols$1(e)),e=getPrototype$1(e);return t}:stubArray,getSymbolsIn$1=getSymbolsIn;function copySymbolsIn(e,t){return copyObject(e,getSymbolsIn$1(e),t)}function baseGetAllKeys(e,t,r){var n=t(e);return isArray$1(e)?n:arrayPush(n,r(e))}function getAllKeys(e){return baseGetAllKeys(e,keys3,getSymbols$1)}function getAllKeysIn(e){return baseGetAllKeys(e,keysIn,getSymbolsIn$1)}var DataView$1=getNative(root$1,"DataView"),DataView$2=DataView$1,Promise$1=getNative(root$1,"Promise"),Promise$2=Promise$1,Set=getNative(root$1,"Set"),Set$1=Set,mapTag$3="[object Map]",objectTag$1="[object Object]",promiseTag="[object Promise]",setTag$3="[object Set]",weakMapTag$1="[object WeakMap]",dataViewTag$2="[object DataView]",dataViewCtorString=toSource(DataView$2),mapCtorString=toSource(Map$1),promiseCtorString=toSource(Promise$2),setCtorString=toSource(Set$1),weakMapCtorString=toSource(WeakMap$1),getTag=baseGetTag;(DataView$2&&getTag(new DataView$2(new ArrayBuffer(1)))!=dataViewTag$2||Map$1&&getTag(new Map$1)!=mapTag$3||Promise$2&&getTag(Promise$2.resolve())!=promiseTag||Set$1&&getTag(new Set$1)!=setTag$3||WeakMap$1&&getTag(new WeakMap$1)!=weakMapTag$1)&&(getTag=function(e){var t=baseGetTag(e),r=t==objectTag$1?e.constructor:void 0,n=r?toSource(r):"";if(n)switch(n){case dataViewCtorString:return dataViewTag$2;case mapCtorString:return mapTag$3;case promiseCtorString:return promiseTag;case setCtorString:return setTag$3;case weakMapCtorString:return weakMapTag$1}return t});var getTag$1=getTag,objectProto=Object.prototype,hasOwnProperty=objectProto.hasOwnProperty;function initCloneArray(e){var t=e.length,r=new e.constructor(t);return t&&"string"==typeof e[0]&&hasOwnProperty.call(e,"index")&&(r.index=e.index,r.input=e.input),r}var Uint8Array$1=root$1.Uint8Array,Uint8Array$2=Uint8Array$1;function cloneArrayBuffer(e){var t=new e.constructor(e.byteLength);return new Uint8Array$2(t).set(new Uint8Array$2(e)),t}function cloneDataView(e,t){var r=t?cloneArrayBuffer(e.buffer):e.buffer;return new e.constructor(r,e.byteOffset,e.byteLength)}var reFlags=/\w*$/;function cloneRegExp(e){var t=new e.constructor(e.source,reFlags.exec(e));return t.lastIndex=e.lastIndex,t}var symbolProto=Symbol$2?Symbol$2.prototype:void 0,symbolValueOf=symbolProto?symbolProto.valueOf:void 0;function cloneSymbol(e){return symbolValueOf?Object(symbolValueOf.call(e)):{}}function cloneTypedArray(e,t){var r=t?cloneArrayBuffer(e.buffer):e.buffer;return new e.constructor(r,e.byteOffset,e.length)}var boolTag$1="[object Boolean]",dateTag$1="[object Date]",mapTag$2="[object Map]",numberTag$1="[object Number]",regexpTag$1="[object RegExp]",setTag$2="[object Set]",stringTag$1="[object String]",symbolTag$1="[object Symbol]",arrayBufferTag$1="[object ArrayBuffer]",dataViewTag$1="[object DataView]",float32Tag$1="[object Float32Array]",float64Tag$1="[object Float64Array]",int8Tag$1="[object Int8Array]",int16Tag$1="[object Int16Array]",int32Tag$1="[object Int32Array]",uint8Tag$1="[object Uint8Array]",uint8ClampedTag$1="[object Uint8ClampedArray]",uint16Tag$1="[object Uint16Array]",uint32Tag$1="[object Uint32Array]";function initCloneByTag(e,t,r){var n=e.constructor;switch(t){case arrayBufferTag$1:return cloneArrayBuffer(e);case boolTag$1:case dateTag$1:return new n(+e);case dataViewTag$1:return cloneDataView(e,r);case float32Tag$1:case float64Tag$1:case int8Tag$1:case int16Tag$1:case int32Tag$1:case uint8Tag$1:case uint8ClampedTag$1:case uint16Tag$1:case uint32Tag$1:return cloneTypedArray(e,r);case mapTag$2:return new n;case numberTag$1:case stringTag$1:return new n(e);case regexpTag$1:return cloneRegExp(e);case setTag$2:return new n;case symbolTag$1:return cloneSymbol(e)}}function initCloneObject(e){return"function"!=typeof e.constructor||isPrototype(e)?{}:baseCreate$1(getPrototype$1(e))}var mapTag$1="[object Map]";function baseIsMap(e){return isObjectLike(e)&&getTag$1(e)==mapTag$1}var nodeIsMap=nodeUtil$1&&nodeUtil$1.isMap,isMap=nodeIsMap?baseUnary(nodeIsMap):baseIsMap,isMap$1=isMap,setTag$1="[object Set]";function baseIsSet(e){return isObjectLike(e)&&getTag$1(e)==setTag$1}var nodeIsSet=nodeUtil$1&&nodeUtil$1.isSet,isSet=nodeIsSet?baseUnary(nodeIsSet):baseIsSet,isSet$1=isSet,CLONE_DEEP_FLAG$1=1,CLONE_FLAT_FLAG=2,CLONE_SYMBOLS_FLAG$1=4,argsTag="[object Arguments]",arrayTag="[object Array]",boolTag="[object Boolean]",dateTag="[object Date]",errorTag="[object Error]",funcTag="[object Function]",genTag="[object GeneratorFunction]",mapTag="[object Map]",numberTag="[object Number]",objectTag="[object Object]",regexpTag="[object RegExp]",setTag="[object Set]",stringTag="[object String]",symbolTag="[object Symbol]",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]",cloneableTags={};function baseClone(e,t,r,n,i,o){var a,s=t&CLONE_DEEP_FLAG$1,c=t&CLONE_FLAT_FLAG,l=t&CLONE_SYMBOLS_FLAG$1;if(r&&(a=i?r(e,n,i,o):r(e)),void 0!==a)return a;if(!isObject$1(e))return e;var u=isArray$1(e);if(u){if(a=initCloneArray(e),!s)return copyArray(e,a)}else{var d=getTag$1(e),p=d==funcTag||d==genTag;if(isBuffer$1(e))return cloneBuffer(e,s);if(d==objectTag||d==argsTag||p&&!i){if(a=c||p?{}:initCloneObject(e),!s)return c?copySymbolsIn(e,baseAssignIn(a,e)):copySymbols(e,baseAssign(a,e))}else{if(!cloneableTags[d])return i?e:{};a=initCloneByTag(e,d,s)}}o||(o=new Stack);var _=o.get(e);if(_)return _;o.set(e,a),isSet$1(e)?e.forEach((function(n){a.add(baseClone(n,t,r,n,e,o))})):isMap$1(e)&&e.forEach((function(n,i){a.set(i,baseClone(n,t,r,i,e,o))}));var h=u?void 0:(l?c?getAllKeysIn:getAllKeys:c?keysIn:keys3)(e);return arrayEach(h||e,(function(n,i){h&&(n=e[i=n]),assignValue(a,i,baseClone(n,t,r,i,e,o))})),a}cloneableTags[argsTag]=cloneableTags[arrayTag]=cloneableTags[arrayBufferTag]=cloneableTags[dataViewTag]=cloneableTags[boolTag]=cloneableTags[dateTag]=cloneableTags[float32Tag]=cloneableTags[float64Tag]=cloneableTags[int8Tag]=cloneableTags[int16Tag]=cloneableTags[int32Tag]=cloneableTags[mapTag]=cloneableTags[numberTag]=cloneableTags[objectTag]=cloneableTags[regexpTag]=cloneableTags[setTag]=cloneableTags[stringTag]=cloneableTags[symbolTag]=cloneableTags[uint8Tag]=cloneableTags[uint8ClampedTag]=cloneableTags[uint16Tag]=cloneableTags[uint32Tag]=!0,cloneableTags[errorTag]=cloneableTags[funcTag]=cloneableTags[weakMapTag]=!1;var CLONE_DEEP_FLAG=1,CLONE_SYMBOLS_FLAG=4;function cloneDeep(e){return baseClone(e,CLONE_DEEP_FLAG|CLONE_SYMBOLS_FLAG)}function baseValues(e,t){return arrayMap(t,(function(t){return e[t]}))}function values(e){return null==e?[]:baseValues(e,keys3(e))}var _RoomProfileMap,logger$e=new Logger("ChromeHandler",3),encodedTransformSupported=isEncodedTransformSupported(),ChromeHandler=function(e){_inherits(d,BasicHandler);var t,r,n,i,o,a,s,c,l,u=_createSuper(d);function d(e){var t;return _classCallCheck(this,d),_defineProperty(_assertThisInitialized(t=u.call(this,e)),"name","chrome"),_defineProperty(_assertThisInitialized(t),"_queueBusy",!1),_defineProperty(_assertThisInitialized(t),"_sdpQueue",void 0),_defineProperty(_assertThisInitialized(t),"_aSendonlyOfferTpl",void 0),_defineProperty(_assertThisInitialized(t),"_vSendonlyOfferTpl",void 0),_defineProperty(_assertThisInitialized(t),"_aRecvonlyOfferTpl",void 0),_defineProperty(_assertThisInitialized(t),"_vRecvonlyOfferTpl",void 0),_defineProperty(_assertThisInitialized(t),"_mid",10),_defineProperty(_assertThisInitialized(t),"_offerSession",void 0),_defineProperty(_assertThisInitialized(t),"_answerSession",void 0),_defineProperty(_assertThisInitialized(t),"_offerMlines",[]),_defineProperty(_assertThisInitialized(t),"_answerMlines",[]),_defineProperty(_assertThisInitialized(t),"_inactiveMlineIndex",[]),_defineProperty(_assertThisInitialized(t),"_mlinesCache",{}),t._sdpQueue=new SdpQueue,t._sdpQueue.on("start",(function(){t._queueBusy||"stable"!==t._peerConnection.signalingState||(logger$e.print("dequeue start"),t.dequeue())})),t}return _createClass(d,[{key:"connect",value:(l=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){var r,n,i,o,a,s,c,l,u,d,p,_,h,f=this;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return logger$e.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(this.id,t);case 4:return this._answerIce=e.sent,this._connectionId=this._answerIce.iceUfrag,e.next=8,this._peerConnection.createOffer();case 8:return i=e.sent,o=lib.parse(i.sdp),!this._offerIce.iceUfrag&&!this._offerIce.icePwd&&((l="renomination"===(null===(a=o.media[0])||void 0===a?void 0:a.iceOptions))||(delete this._offerIce.iceOptions,delete this._answerIce.iceOptions),delete this._offerIce.iceUfrag,delete this._offerIce.icePwd,u=getServerUfragV2({serverUfrag:t.iceParams.serverIceUfrag,serverPwd:t.iceParams.serverIcePwd,clientPwd:null===(s=o.media[0])||void 0===s?void 0:s.icePwd,options:(c={},_defineProperty(c,ICEConfigType.kICEConfigTypeSrtpDtlsType,!0),_defineProperty(c,ICEConfigType.kICEConfigTypeRenominationType,l),c)}),d=_slicedToArray(u,2),p=d[0],d[1],this._answerIce.iceUfrag=p,logger$e.print("use serverUfrag v2",stringify$1({dtls:!0,renomination:l}))),_=_slicedToArray(o.media,1),h=_[0],this._offerIce.fingerprint=o.fingerprint||h.fingerprint,delete o.media,this._offerSession=_objectSpread2({},o),this._answerSession=_objectSpread2({},o),this._answerSession.fingerprint&&(this._answerSession.fingerprint=this._answerIce.fingerprint),this._offerMlines=[_objectSpread2(_objectSpread2(_objectSpread2({},h),this._offerIce),{},{mid:"".concat(0)})],this._answerMlines=[_objectSpread2(_objectSpread2(_objectSpread2({},h),this._answerIce),{},{sctpmap:{sctpmapNumber:5e3,app:"webrtc-datachannel",maxMessageSize:262144},mid:"".concat(0)})],this.setDescription(),e.next=24,new promise((function(e,t){f._dataChannel.onopen=function(){logger$e.print("connect","dataChannel open"),f._reportRtcInvokeStatus("es.dc.open",""),e("")},f._dataChannel.onerror=function(e){f._report("rtc_signaling_msg_error",{error_code:e.error.sdpLineNumber,message:e.error.errorDetail,reason:"invalid data"}),f._reportRtcInvokeStatus("es.dc.error",""),t(e)},f._dataChannel.onclose=function(e){f._reportRtcInvokeStatus("es.dc.close",""),t(e)},f._peerConnection.addEventListener("connectionstatechange",(function(e){"failed"!==f._peerConnection.iceConnectionState&&"closed"!==f._peerConnection.iceConnectionState&&"failed"!==f._peerConnection.connectionState||t(e)}))}));case 24:return logger$e.print("connect","dataChannel establish success"),e.abrupt("return",this._dataChannel);case 26:case"end":return e.stop()}}),e,this)}))),function(e){return l.apply(this,arguments)})},{key:"disconnect",value:function(){this._peerConnection.close(),this._dataChannel.close(),this._peerConnection.ontrack=null}},{key:"destroy",value:function(){_get(_getPrototypeOf(d.prototype),"destroy",this).call(this),this._mlinesCache={}}},{key:"publish",value:(c=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){var r,n,i,o,a,s,c,l,u,p,_,h,f,m,v,g,y,S,T,$,E,b,I,R,C,A,k,P,O,w,M,D,x,N,L,U,V;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return l=t.stream,u=t.enableSimulcast,p=_get(_getPrototypeOf(d.prototype),"internalPublish",this).call(this,t),_=p.videoDescriptions,h=p.subVideoDescriptions,f=p.audioTransceiverInit,m=p.videoTransceiverInit,v=generateAllSsrc(this._nextSsrc),this._nextSsrc=v.next,g="".concat(this._mid++),y="".concat(this._mid++),S=_objectSpread2(_objectSpread2(_objectSpread2({},this._aSendonlyOfferTpl),this._offerIce),{},{mid:g,msid:concat$2(r="".concat(l.id," ")).call(r,l.id,"-audio"),ssrcs:generateSsrc(l.id,"audio",v.audio,clientCname)}),T=_objectSpread2(_objectSpread2(_objectSpread2({},this._vSendonlyOfferTpl),this._offerIce),{},{mid:y,msid:concat$2(n="".concat(l.id," ")).call(n,l.id,"-video")}),u?(logger$e.print("subVideoDesc","desc: %o ",h),delete T.ssrcGroups,delete T.ssrcs,$=[],T.rids=map$6(_).call(_,(function(e){var t=e.rid;return $.unshift(t),{id:t,direction:"send"}})),T.simulcast={dir1:"send",list1:$.join(";")}):(E=generateSsrcs(l.id,v,{cname:clientCname}),b=E.ssrcs,I=E.ssrcGroups,T.ssrcs=b,T.ssrcGroups=I),null!==(i=this._context)&&void 0!==i&&null!==(o=i.serverConfig)&&void 0!==o&&o.audioRed&&Array.isArray(S.rtp)&&(-1!==(C=findIndex$1(R=S.rtp).call(R,(function(e){return"red"===e.codec})))&&(k=splice$3(A=S.rtp).call(A,C,1),P=_slicedToArray(k,1),O=P[0],S.rtp.unshift(O)),w=[],S.rtp.forEach((function(e){return w.push(e.payload)})),S.payloads=w.join(" ")),null!==(a=this._context)&&void 0!==a&&null!==(s=a.serverConfig)&&void 0!==s&&s.videoCodec&&setCodecPreferences(T,null===(M=this._context)||void 0===M||null===(D=M.serverConfig)||void 0===D?void 0:D.videoCodec),(isSafari||isIOS)&&Array.isArray(T.ext)&&(T.ext=filter3(x=T.ext).call(x,(function(e){var t;return!(null!=e&&null!==(t=e.uri)&&void 0!==t&&includes4(t).call(t,"video-orientation"))}))),(N=null==S?void 0:find$2(c=S.rtp).call(c,(function(e){return"opus"===e.codec})))&&S.fmtp&&(V=find$2(L=S.fmtp).call(L,(function(e){return e.payload===N.payload})))&&null!==(U=this._context)&&void 0!==U&&U.audioProfileManager&&(V.config=this._context.audioProfileManager.getOpusConfigStr(V.config)),u||isSafari||this.addBitrateLimit(T,t.videoEncodeConfig[0].maxKbps),this._mlinesCache[t.stream.id]=[S,T],e.abrupt("return",{partialSdp:getLocalPartialSdp(this._offerSession,S,T),audioMid:g,videoMid:y,type:"incroffer",semantics:"unified-plan",videoDescriptions:_,subVideoDescriptions:h,audioTransceiverInit:f,videoTransceiverInit:m});case 17:case"end":return e.stop()}}),e,this)}))),function(e){return c.apply(this,arguments)})},{key:"subscribe",value:(s=_asyncToGenerator(_regeneratorRuntime().mark((function e(t,r){var n,i,o,a,s,c,l,u,d,p,_,h,f,m,v,g,y,S,T,$,E,b,I,R,C,A,k,P,O,w,M=this;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(logger$e.print("subscribe"),a="incroffer",s="unified-plan",this._aRecvonlyOfferTpl&&this._vRecvonlyOfferTpl){e.next=9;break}return e.next=6,this._genOfferSdp();case 6:return c=e.sent,e.next=9,this.createAVMlineOfferTpl(c);case 9:if(l="",u="",d=!1,p=!1,_=void 0,h=void 0,this._mlinesCache[t.streamId]=[_,h],t.virtual?(l="".concat(this._mid++),d=!0):r.multiChatMode?(l="".concat(this._mid++),u="".concat(this._mid++),p=!0):(d=!0,p=!0,l="".concat(this._mid++),u="".concat(this._mid++)),l&&(_=_objectSpread2(_objectSpread2({},cloneDeep(this._aRecvonlyOfferTpl)),{},{mid:l})),d&&(this._mlinesCache[t.streamId][0]=_,f={track:"audio",init:{direction:"recvonly"}}),u&&(h=_objectSpread2(_objectSpread2({},cloneDeep(this._vRecvonlyOfferTpl)),{},{mid:u})),p&&(this._mlinesCache[t.streamId][1]=h,m={track:"video",init:{direction:"recvonly"}}),v=getLocalPartialSdp(this._offerSession,_,h),g=void 0,r.multiChatMode||t.virtual||!this._aSendonlyAnswerTpl||!this._vSendonlyAnswerTpl){e.next=32;break}return g=generateAllSsrc(this._nextSsrc),this._nextSsrc=g.next,R=_objectSpread2(_objectSpread2(_objectSpread2({},this._aSendonlyAnswerTpl),this._answerIce),{},{mid:l,msid:concat$2(y=concat$2(S="".concat(t.streamId)).call(S,null!==(T=this._context)&&void 0!==T&&T.avSync?"":"-audio"," ")).call(y,t.streamId,"-audio"),ssrcs:generateSsrc(t.streamId,"audio",g.audio)}),C=_objectSpread2(_objectSpread2(_objectSpread2({},this._vSendonlyAnswerTpl),this._answerIce),{},{mid:u,msid:concat$2($=concat$2(E="".concat(t.streamId)).call(E,null!==(b=this._context)&&void 0!==b&&b.avSync?"":"-video"," ")).call($,t.streamId,"-video")},generateSsrcs(t.streamId,g,{flexfec:this._enableSubFlexfec})),A=new promise((function(e){M._sdpQueue.enqueue({action:SdpAction.subscribe,streamId:t.streamId,audioMid:l,videoMid:u,audioTransceiverInit:f,videoTransceiverInit:m,signalingAck:{sdp:lib.write(_objectSpread2(_objectSpread2({},M._answerSession),{},{media:[R,C]})),sequenceId:t.sequenceId?++t.sequenceId:0},stream:t,sdp:v,onSuccess:function(){logger$e.print("subscribe()","sub success"),e(0)}})})),e.next=31,A;case 31:null===(I=g)||void 0===I||delete I.next;case 32:return(k=null===(n=_)||void 0===n?void 0:find$2(i=n.rtp).call(i,(function(e){return"opus"===e.codec})))&&null!==(o=_)&&void 0!==o&&o.fmtp&&(w=null===(P=_)||void 0===P?void 0:find$2(O=P.fmtp).call(O,(function(e){return e.payload===k.payload})))&&this._context&&(w.config+=";stereo=1;sprop-stereo=1"),e.abrupt("return",{partialSdp:v,audioMid:l,videoMid:u,type:a,semantics:s,audioTransceiverInit:f,videoTransceiverInit:m,allSsrc:g});case 35:case"end":return e.stop()}}),e,this)}))),function(e,t){return s.apply(this,arguments)})},{key:"handleAck",value:(a=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(logger$e.print("handleAck()","item: %o",t),!t.generatorSsrc){e.next=4;break}return logger$e.print("already set remote"),e.abrupt("return","");case 4:return e.abrupt("return",this._sdpQueue.enqueue(t));case 5:case"end":return e.stop()}}),e,this)}))),function(e){return a.apply(this,arguments)})},{key:"dequeue",value:(o=_asyncToGenerator(_regeneratorRuntime().mark((function e(){var t,r,n,i,o,a,s,c,l,u,d,p,_,h,f,m=this;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._queueBusy=!0,t=this._sdpQueue.dequeue(),logger$e.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=[],a=[],n!==SdpStrategy.ADD){e.next=15;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({},m._answerIce)).candidates,s=!1,c=!1,e.prev=4,u=_asyncIterator(r);case 6:return e.next=8,u.next();case 8:if(!(s=!(d=e.sent).done)){e.next=16;break}if(n=d.value,"break"!==function(){var e=n.audioMid,r=n.videoMid,s=n.action,c=n.audioTransceiverInit,l=n.videoTransceiverInit,u=n.signalingAck,d=n.stream,p=d instanceof RemoteStream;if(n.onSuccess&&a.push(n.onSuccess),p&&(null==u?void 0:u.sequenceId)<d.sequenceId)return"break";var _,h={},f={},v=lib.parse(u.sdp);Array.isArray(v.media)&&sort2(_=v.media).call(_,(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(n){"audio"===(n=_objectSpread2(_objectSpread2({},n),t)).type?(h=n).mid=e:(f=n).mid=r}));var g,y=d.streamId;if(s===SdpAction.publish&&(y=null===(g=d.stream)||void 0===g?void 0:g.id),!m._mlinesCache[y])return"break";var S=_slicedToArray(m._mlinesCache[y],2),T=S[0],$=S[1];if(c&&T){d.audioTransceiver=m._peerConnection.addTransceiver(c.track,c.init),m._reportRtcInvokeStatus("chromeHandler.addTrack",stringify$1({audioStreamTrack:MediaTrackStringify(c.track)}));var E=m._inactiveMlineIndex.shift();E||(E=m._offerMlines.length),m._offerMlines[E]=_objectSpread2({},T),m._answerMlines[E]=h,encodedTransformSupported&&d.initAudioEncodedTransform()}if(l&&$){var b,I;d.videoTransceiver=m._peerConnection.addTransceiver(l.track,l.init),m._reportRtcInvokeStatus("chromeHandler.addTrack",stringify$1({videoStreamTrack:MediaTrackStringify(l.track)}));var R,C,A=m._inactiveMlineIndex.shift();A||(A=m._offerMlines.length),m._offerMlines[A]=_objectSpread2({},$),s===SdpAction.publish&&null!==(b=m._context)&&void 0!==b&&null!==(I=b.serverConfig)&&void 0!==I&&I.videoCodec&&setCodecPreferences(f,null===(R=m._context)||void 0===R||null===(C=R.serverConfig)||void 0===C?void 0:C.videoCodec),m._answerMlines[A]=f,encodedTransformSupported&&d.initVideoEncodedTransform()}i.push(d.streamId||""),o.push(p?d.userId:"local"),p&&(d.sequenceId=null==u?void 0:u.sequenceId),delete m._mlinesCache[y]}()){e.next=13;break}return e.abrupt("break",16);case 13:s=!1,e.next=6;break;case 16:e.next=22;break;case 18:e.prev=18,e.t0=e.catch(4),c=!0,l=e.t0;case 22:if(e.prev=22,e.prev=23,!s||null==u.return){e.next=27;break}return e.next=27,u.return();case 27:if(e.prev=27,!c){e.next=30;break}throw l;case 30:return e.finish(27);case 31:return e.finish(22);case 32:case"end":return e.stop()}}),e,null,[[4,18,22,32],[23,,27,31]])}))(),"t0",13);case 13:e.next=20;break;case 15:f={},r.forEach((function(e){var t=e.audioMid,r=e.videoMid,n=e.action;f[t]=t,n!==SdpAction.removetrack&&(f[r]=r),f[t]=t})),this._offerMlines=map$6(p=this._offerMlines).call(p,(function(e,t){return f[e.mid]&&(e=closeMline(e),m._inactiveMlineIndex.push(t)),e})),sort2(_=this._inactiveMlineIndex).call(_,(function(e,t){return e-t})),this._answerMlines=map$6(h=this._answerMlines).call(h,(function(e){return f[e.mid]&&(e=closeMline(e)),e}));case 20:return e.next=22,this.setDescription(i.length?{streamId:i.join(","),streamUserId:o.join(",")}:void 0);case 22:try{a.forEach((function(e){return e()}))}catch(e){}logger$e.print("dequeue","loop"),e.next=29;break;case 26:e.prev=26,e.t1=e.catch(6),logger$e.print("dequeue","unknown error: %o",e.t1);case 29:return e.prev=29,this.dequeue(),e.finish(29);case 32:case"end":return e.stop()}}),e,this,[[6,26,29,32]])}))),function(){return o.apply(this,arguments)})},{key:"setDescription",value:(i=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){var r,n;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return logger$e.print("setDescription"),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&&this._report("rtc_begin_create_offer",{direction:"local"===t.streamUserId?"up":"down",stream_id:t.streamId,stream_user_id:t.streamUserId}),e.next=10,this._peerConnection.createOffer();case 10:return t&&this._report("rtc_create_offer",{error_code:0,direction:"local"===t.streamUserId?"up":"down",stream_id:t.streamId,stream_user_id:t.streamUserId,elapse: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 i.apply(this,arguments)})},{key:"getDefaultSdp",value:(n=_asyncToGenerator(_regeneratorRuntime().mark((function e(){var t,r,n,i;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._genOfferSdp();case 2:return r=e.sent,this.createAVMlineOfferTpl(r),n=lib.parse(r),i=[],n.media=filter3(t=n.media).call(t,(function(e){var t;return"recvonly"===e.direction&&(Array.isArray(e.ext)&&(e.ext=filter3(t=e.ext).call(t,(function(e){return"urn:ietf:params:rtp-hdrext:sdes:rtp-stream-id"!==e.uri}))),i.push(e.mid+""),!0)})),n.groups=[{mids:i.join(" "),type:"BUNDLE"}],e.abrupt("return",{sdp:lib.write(n),semantics:"unified-plan",type:"incroffer"});case 9:case"end":return e.stop()}}),e,this)}))),function(){return n.apply(this,arguments)})},{key:"rollback",value:(r=_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 r.apply(this,arguments)})},{key:"createAVMlineOfferTpl",value:function(e){var t=this;lib.parse(e).media.forEach((function(e){if("audio"===e.type)if("sendonly"===e.direction)t._aSendonlyOfferTpl=e;else{var r;if(Array.isArray(e.ext))e.ext=filter3(r=e.ext).call(r,(function(e){return"urn:ietf:params:rtp-hdrext:sdes:rtp-stream-id"!==e.uri}));t._aRecvonlyOfferTpl=e}else if("video"===e.type)if("sendonly"===e.direction)t._vSendonlyOfferTpl=e;else{var n;if(Array.isArray(e.ext))e.ext=filter3(n=e.ext).call(n,(function(e){return"urn:ietf:params:rtp-hdrext:sdes:rtp-stream-id"!==e.uri}));t._vRecvonlyOfferTpl=e}}))}},{key:"_genOfferSdp",value:(t=_asyncToGenerator(_regeneratorRuntime().mark((function e(){var t,r;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,createDefaultSdp(!0);case 3:if(t=e.sent){e.next=6;break}throw"pc.createOffer() return empty.";case 6:e.next=12;break;case 8:throw e.prev=8,e.t0=e.catch(0),r="Get offer Error. ".concat(e.t0.message|e.t0),new SDKError(ErrorCode.NOT_SUPPORTED,r);case 12:return e.abrupt("return",t);case 13:case"end":return e.stop()}}),e,null,[[0,8]])}))),function(){return t.apply(this,arguments)})}]),d}(),logger$d=new Logger("FirefoxHandler",3),FirefoxHandler=function(e){_inherits(d,BasicHandler);var t,r,n,i,o,a,s,c,l,u=_createSuper(d);function d(){var e,t;_classCallCheck(this,d);for(var r=arguments.length,n=new Array(r),i=0;i<r;i++)n[i]=arguments[i];return _defineProperty(_assertThisInitialized(t=u.call.apply(u,concat$2(e=[this]).call(e,n))),"name","firefox"),_defineProperty(_assertThisInitialized(t),"_aRecvonlyOfferTpl",void 0),t}return _createClass(d,[{key:"connect",value:(l=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){var r,n,i,o,a,s,c,l,u,d,p,_,h,f,m,v,g,y=this;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return logger$d.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(this.id,t);case 4:return this._answerIce=e.sent,this._connectionId=this._answerIce.iceUfrag,firefoxVersion<138&&(this._peerConnection.addTransceiver("audio",{direction:"recvonly"}),this._peerConnection.addTransceiver("video",{direction:"recvonly"})),e.next=9,this._peerConnection.createOffer();case 9:return s=e.sent,c=lib.parse(s.sdp),!this._offerIce.iceUfrag&&!this._offerIce.icePwd&&((p="renomination"===(null===(l=c.media[0])||void 0===l?void 0:l.iceOptions))||(delete this._offerIce.iceOptions,delete this._answerIce.iceOptions),delete this._offerIce.iceUfrag,delete this._offerIce.icePwd,_=getServerUfragV2({serverUfrag:t.iceParams.serverIceUfrag,serverPwd:t.iceParams.serverIcePwd,clientPwd:null===(u=c.media[0])||void 0===u?void 0:u.icePwd,options:(d={},_defineProperty(d,ICEConfigType.kICEConfigTypeSrtpDtlsType,!0),_defineProperty(d,ICEConfigType.kICEConfigTypeRenominationType,p),d)}),h=_slicedToArray(_,2),f=h[0],h[1],this._answerIce.iceUfrag=f,logger$d.print("use serverUfrag v2",stringify$1({dtls:!0,renomination:p}))),m=_slicedToArray(c.media,1),v=m[0],this._offerIce.fingerprint=c.fingerprint||v.fingerprint,c.media=map$6(i=c.media).call(i,(function(e){return _objectSpread2(_objectSpread2({},e),y._offerIce)})),map$6(o=c.media).call(o,(function(e){var t,r;"video"===e.type&&(e.ext=null===(t=e.ext)||void 0===t?void 0:filter3(t).call(t,(function(e){var t;return-1===indexOf2(t=e.uri).call(t,"abs-send-time")})),e.rtcpFb=null===(r=e.rtcpFb)||void 0===r?void 0:filter3(r).call(r,(function(e){return"goog-remb"!==e.type})))})),(g=_objectSpread2({},c)).fingerprint=this._answerIce.fingerprint,g.media=map$6(a=g.media).call(a,(function(e){return delete(e=_objectSpread2(_objectSpread2({},e),y._answerIce)).bundleOnly,e.port=9,"application"===e.type?e.sctpmap={sctpmapNumber:5e3,app:"webrtc-datachannel",maxMessageSize:262144}:("audio"===e.type&&(e.msid="ff-stream ff-stream-audio"),e.direction="sendonly"),e})),e.next=22,this.setLocalDescription(lib.write(c));case 22:return e.next=24,this.setRemoteDescription(lib.write(g));case 24:return e.next=26,new promise((function(e,t){y._dataChannel.onopen=function(){logger$d.print("connect","dataChannel open"),y._reportRtcInvokeStatus("es.dc.open",""),e("")},y._dataChannel.onerror=function(e){y._report("rtc_signaling_msg_error",{error_code:e.error.sdpLineNumber,message:e.error.errorDetail,reason:"invalid data"}),y._reportRtcInvokeStatus("es.dc.error",""),t(e)},y._dataChannel.onclose=function(e){y._reportRtcInvokeStatus("es.dc.close",""),t(e)},y._peerConnection.addEventListener("connectionstatechange",(function(e){"failed"!==y._peerConnection.iceConnectionState&&"closed"!==y._peerConnection.iceConnectionState&&"failed"!==y._peerConnection.connectionState||t(e)}))}));case 26:return logger$d.print("connect","dataChannel establish success"),e.abrupt("return",this._dataChannel);case 28:case"end":return e.stop()}}),e,this)}))),function(e){return l.apply(this,arguments)})},{key:"publish",value:(c=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){var r,n,i,o,a,s,c,l,u,p,_,h,f,m,v=this;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=_get(_getPrototypeOf(d.prototype),"internalPublish",this).call(this,t),o=i.videoDescriptions,a=i.subVideoDescriptions,s=i.audioTransceiverInit,c=i.videoTransceiverInit,t.audioTransceiver=this._peerConnection.addTransceiver(s.track,s.init),t.videoTransceiver=this._peerConnection.addTransceiver(c.track,c.init),l=getServerNow(),this._report("rtc_begin_create_offer",{direction:"up",stream_id:"",stream_user_id:""}),e.next=7,this._peerConnection.createOffer();case 7:return u=e.sent,this._report("rtc_create_offer",{direction:"up",error_code:0,stream_id:"",stream_user_id:"",elapse:getServerNow()-l}),(p=lib.parse(u.sdp)).media=null===(r=p.media)||void 0===r?void 0:map$6(r).call(r,(function(e){return _objectSpread2(_objectSpread2({},e),v._offerIce)})),e.next=13,this.setLocalDescription(lib.write(p));case 13:return _=t.audioTransceiver.mid,h=t.videoTransceiver.mid,f=null,m=null,p.media=null===(n=p.media)||void 0===n?void 0:map$6(n).call(n,(function(e){if("".concat(e.mid)===_){var t,r,n=null===(t=f=e)||void 0===t?void 0:find$2(r=t.rtp).call(r,(function(e){return"opus"===e.codec}));if(n&&f.fmtp){var i,o,a=find$2(i=f.fmtp).call(i,(function(e){return e.payload===n.payload}));a&&null!==(o=v._context)&&void 0!==o&&o.audioProfileManager&&(a.config=v._context.audioProfileManager.getOpusConfigStr(a.config))}}else if("".concat(e.mid)===h){var s,c,l,u;null!==(s=v._context)&&void 0!==s&&null!==(c=s.serverConfig)&&void 0!==c&&c.videoCodec&&setCodecPreferences(e,null===(l=v._context)||void 0===l||null===(u=l.serverConfig)||void 0===u?void 0:u.videoCodec),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,f,m,!1),audioMid:_,videoMid:h,type:"incroffer",semantics:"unified-plan",videoDescriptions:o,subVideoDescriptions:a,audioTransceiverInit:s,videoTransceiverInit:c});case 22:case"end":return e.stop()}}),e,this)}))),function(e){return c.apply(this,arguments)})},{key:"subscribe",value:(s=_asyncToGenerator(_regeneratorRuntime().mark((function e(t,r){var n,i,o,a,s,c,l,u,d,p,_,h,f,m,v,g,y,S,T,$,E,b,I,R,C=this;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return logger$d.print("subscribe()"),c="",l="",u=!1,d=!1,p=void 0,_=void 0,t.virtual?u=!0:(r.multiChatMode||(u=!0),d=!0),u&&(t.audioTransceiver=this._peerConnection.addTransceiver("audio",{direction:"recvonly"})),d&&(t.videoTransceiver=this._peerConnection.addTransceiver("video",{direction:"recvonly"})),h=getServerNow(),this._report("rtc_begin_create_offer",{direction:"up",stream_id:t.streamId,stream_user_id:t.userId}),e.next=14,this._peerConnection.createOffer();case 14:return f=e.sent,this._report("rtc_create_offer",{error_code:0,direction:"up",stream_id:t.streamId,stream_user_id:t.userId,elapse:getServerNow()-h}),(m=lib.parse(f.sdp)).media=null===(n=m.media)||void 0===n?void 0:map$6(n).call(n,(function(e){return _objectSpread2(_objectSpread2({},e),C._offerIce)})),map$6(i=m.media).call(i,(function(e){var t,r;"video"===e.type&&(e.ext=null===(t=e.ext)||void 0===t?void 0:filter3(t).call(t,(function(e){var t;return-1===indexOf2(t=e.uri).call(t,"abs-send-time")})),e.rtcpFb=null===(r=e.rtcpFb)||void 0===r?void 0:filter3(r).call(r,(function(e){return"goog-remb"!==e.type})))})),e.next=21,this.setLocalDescription(lib.write(m),{streamId:t.streamId||"",streamUserId:t.userId});case 21:if(c=null===(o=t.audioTransceiver)||void 0===o?void 0:o.mid,l=null===(a=t.videoTransceiver)||void 0===a?void 0:a.mid,null===(s=m.media)||void 0===s||s.forEach((function(e){"".concat(e.mid)===c?p=e:"".concat(e.mid)===l&&(_=e)})),c&&p||(c="audio_".concat(l),p=_objectSpread2(_objectSpread2({},this._aRecvonlyOfferTpl),{},{mid:c})),t.audioMid=c,t.videoMid=l,v=void 0,r.multiChatMode||t.virtual||!this._aSendonlyAnswerTpl||!this._aSendonlyAnswerTpl){e.next=36;break}return v=generateAllSsrc(this._nextSsrc),this._nextSsrc=v.next,I=_objectSpread2(_objectSpread2(_objectSpread2({},this._aSendonlyAnswerTpl),this._answerIce),{},{mid:c,msid:concat$2(g=concat$2(y="".concat(t.streamId)).call(y,null!==(S=this._context)&&void 0!==S&&S.avSync?"":"-audio"," ")).call(g,t.streamId,"-audio"),ssrcs:generateSsrc(t.streamId,"audio",v.audio)}),R=_objectSpread2(_objectSpread2(_objectSpread2({},this._vSendonlyAnswerTpl),this._answerIce),{},{mid:l,msid:concat$2(T=concat$2($="".concat(t.streamId)).call($,null!==(E=this._context)&&void 0!==E&&E.avSync?"":"-video"," ")).call(T,t.streamId,"-video")},generateSsrcs(t.streamId,v,{flexfec:this._enableSubFlexfec})),e.next=35,this._internalSetRemoteDescription([I,R],t);case 35:null===(b=v)||void 0===b||delete b.next;case 36:return e.abrupt("return",{partialSdp:getLocalPartialSdp(m,p,_,!1),audioMid:c,videoMid:l,type:"incroffer",semantics:"unified-plan",audioTransceiverInit:t.audioTransceiver?{track:"audio",init:{direction:"recvonly"}}:void 0,videoTransceiverInit:t.videoTransceiver?{track:"video",init:{direction:"recvonly"}}:void 0,allSsrc:v});case 37:case"end":return e.stop()}}),e,this)}))),function(e,t){return s.apply(this,arguments)})},{key:"handleAck",value:(a=_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(r=t.signalingAck,n=t.stream,(i=t.action)!==SdpAction.unpublish&&i!==SdpAction.unsubscribe&&i!==SdpAction.removetrack){e.next=5;break}return e.next=4,this.close(n);case 4:return e.abrupt("return",n.streamId||"");case 5:if(!t.generatorSsrc){e.next=8;break}return logger$d.print("already set remote"),e.abrupt("return","");case 8:return o=lib.parse(null==r?void 0:r.sdp),e.next=11,this._internalSetRemoteDescription(o.media,n);case 11:return e.abrupt("return","");case 12:case"end":return e.stop()}}),e,this)}))),function(e){return a.apply(this,arguments)})},{key:"_internalSetRemoteDescription",value:(o=_asyncToGenerator(_regeneratorRuntime().mark((function e(t,r){var n,i,o,a,s,c,l,u,d=this;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return s={},(c=lib.parse(null===(n=this._peerConnection.remoteDescription)||void 0===n?void 0:n.sdp)).media.forEach((function(e){void 0!==e.mid&&(s[e.mid]=e)})),t.forEach((function(e){if("audio"===(e=_objectSpread2(_objectSpread2({},e),d._answerIce)).type&&(r.audioMid?(e.mid=r.audioMid,s[r.audioMid]=e):s[e.mid]=e),"video"===e.type){if(r instanceof LocalStream&&firefoxVersion<=87){var t,n,i,o,a={};Array.isArray(e.rtp)&&(e.rtp=filter3(t=e.rtp).call(t,(function(e){return"rtx"!==e.codec||(a[e.payload]=e.payload,!1)}))),"string"==typeof e.payloads&&(e.payloads=filter3(n=e.payloads.split(" ")).call(n,(function(e){return!a[e]})).join(" ")),Array.isArray(e.fmtp)&&(e.fmtp=filter3(i=e.fmtp).call(i,(function(e){return!a[e.payload]}))),Array.isArray(e.rtcpFb)&&(e.fmtp=filter3(o=e.fmtp).call(o,(function(e){return!a[e.payload]})))}r.videoMid?(e.mid=r.videoMid,s[r.videoMid]=e):s[e.mid]=e}})),l=lib.parse(null===(i=this._peerConnection.localDescription)||void 0===i?void 0:i.sdp),u=map$6(o=l.media).call(o,(function(e){var t=s[e.mid];return"inactive"===e.direction?e:t})),c.groups=l.groups,c.media=u,map$6(a=c.media).call(a,(function(e){var t,r,n;"video"===e.type&&(e.ext=null===(t=e.ext)||void 0===t?void 0:filter3(t).call(t,(function(e){var t;return-1===indexOf2(t=e.uri).call(t,"abs-send-time")})),e.rtcpFb=null===(r=e.rtcpFb)||void 0===r?void 0:filter3(r).call(r,(function(e){return"goog-remb"!==e.type})),firefoxVersion>=138&&(e.ext=null===(n=e.ext)||void 0===n?void 0:filter3(n).call(n,(function(e){var t;return!includes4(t=e.uri).call(t,"sdes:mid")}))))})),e.next=11,this.setRemoteDescription(lib.write(c));case 11:case"end":return e.stop()}}),e,this)}))),function(e,t){return o.apply(this,arguments)})},{key:"getDefaultSdp",value:(i=_asyncToGenerator(_regeneratorRuntime().mark((function e(){var t,r,n,i,o;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return(r=new RTCPeerConnection).addTransceiver("audio",{direction:"recvonly"}),r.addTransceiver("video",{direction:"recvonly"}),e.next=5,r.createOffer();case 5:return n=e.sent,i=lib.parse(n.sdp),this.createAVMlineOfferTpl(n.sdp),o=[],i.media=filter3(t=i.media).call(t,(function(e){if("recvonly"===e.direction){var t="template_".concat(e.type);return e.mid=t,o.push(t),!0}return!1})),i.groups=[{mids:o.join(" "),type:"BUNDLE"}],r.close(),e.abrupt("return",{sdp:lib.write(i),semantics:"unified-plan",type:"incroffer"});case 13:case"end":return e.stop()}}),e,this)}))),function(){return i.apply(this,arguments)})},{key:"rollback",value:(n=_asyncToGenerator(_regeneratorRuntime().mark((function e(t,r,n){return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return logger$d.print("rollback()"),e.abrupt("return",this.close(r));case 2:case"end":return e.stop()}}),e,this)}))),function(e,t,r){return n.apply(this,arguments)})},{key:"close",value:(r=_asyncToGenerator(_regeneratorRuntime().mark((function e(t,r){var n,i,o,a,s,c,l,u,d,p=this;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return logger$d.print("close()"),a={},t.audioTransceiver&&t.audioMid&&(t.audioTransceiver.stop(),a[t.audioMid]=t.audioMid),t.videoTransceiver&&t.videoMid&&!r&&(t.videoTransceiver.stop(),a[t.videoMid]=t.videoMid),s=[],e.next=7,this._peerConnection.createOffer();case 7:return c=e.sent,(l=lib.parse(null==c?void 0:c.sdp)).media=map$6(n=l.media).call(n,(function(e){return a[e.mid]&&(e=closeMline(e)),"inactive"!==e.direction&&s.push(e.mid),_objectSpread2(_objectSpread2({},e),p._offerIce)})),u=lib.parse(null===(i=this._peerConnection.remoteDescription)||void 0===i?void 0:i.sdp),d={},u.media.forEach((function(e){void 0!==e.mid&&(d[e.mid]=e)})),u.media=map$6(o=l.media).call(o,(function(e){return"inactive"===e.direction?e:d[e.mid]})),l.groups&&u.groups&&(l.groups[0].mids=s.join(" "),u.groups[0].mids=s.join(" ")),e.next=17,this.setLocalDescription(lib.write(l));case 17:return e.next=19,this.setRemoteDescription(lib.write(u));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)})},{key:"createAVMlineOfferTpl",value:function(e){var t=this;lib.parse(e).media.forEach((function(e){"audio"===e.type&&(t._aRecvonlyOfferTpl=e)}))}}]),d}(),logger$c=new Logger("FallbackHandler",3),FallbackHandler=function(e){_inherits(d,BasicHandler);var t,r,n,i,o,a,s,c,l,u=_createSuper(d);function d(e){var t;return _classCallCheck(this,d),_defineProperty(_assertThisInitialized(t=u.call(this,e)),"name","fallback"),_defineProperty(_assertThisInitialized(t),"_aRecvonlyOfferTpl",void 0),logger$c.print("ctor","using fallback handler"),t._report("rtc_error",{message:"using fallback handler",error_code:-1}),t}return _createClass(d,[{key:"connect",value:(l=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){var r,n,i,o,a,s,c,l,u,d,p,_,h,f,m,v,g,y=this;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return logger$c.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(this.id,t);case 4:return this._answerIce=e.sent,this._connectionId=this._answerIce.iceUfrag,this._peerConnection.addTransceiver("audio",{direction:"recvonly"}),this._peerConnection.addTransceiver("video",{direction:"recvonly"}),e.next=10,this._peerConnection.createOffer();case 10:return s=e.sent,c=lib.parse(s.sdp),!this._offerIce.iceUfrag&&!this._offerIce.icePwd&&((p="renomination"===(null===(l=c.media[0])||void 0===l?void 0:l.iceOptions))||(delete this._offerIce.iceOptions,delete this._answerIce.iceOptions),delete this._offerIce.iceUfrag,delete this._offerIce.icePwd,_=getServerUfragV2({serverUfrag:t.iceParams.serverIceUfrag,serverPwd:t.iceParams.serverIcePwd,clientPwd:null===(u=c.media[0])||void 0===u?void 0:u.icePwd,options:(d={},_defineProperty(d,ICEConfigType.kICEConfigTypeSrtpDtlsType,!0),_defineProperty(d,ICEConfigType.kICEConfigTypeRenominationType,p),d)}),h=_slicedToArray(_,2),f=h[0],h[1],this._answerIce.iceUfrag=f,logger$c.print("use serverUfrag v2",stringify$1({dtls:!0,renomination:p}))),m=_slicedToArray(c.media,1),v=m[0],this._offerIce.fingerprint=c.fingerprint||v.fingerprint,c.media=map$6(i=c.media).call(i,(function(e){return _objectSpread2(_objectSpread2({},e),y._offerIce)})),map$6(o=c.media).call(o,(function(e){var t,r;"video"===e.type&&(e.ext=null===(t=e.ext)||void 0===t?void 0:filter3(t).call(t,(function(e){var t;return-1===indexOf2(t=e.uri).call(t,"abs-send-time")})),e.rtcpFb=null===(r=e.rtcpFb)||void 0===r?void 0:filter3(r).call(r,(function(e){return"goog-remb"!==e.type})))})),(g=_objectSpread2({},c)).fingerprint=this._answerIce.fingerprint,g.media=map$6(a=g.media).call(a,(function(e){return delete(e=_objectSpread2(_objectSpread2({},e),y._answerIce)).bundleOnly,e.port=9,"application"===e.type?e.sctpmap={sctpmapNumber:5e3,app:"webrtc-datachannel",maxMessageSize:262144}:("audio"===e.type&&(e.msid="ff-stream ff-stream-audio"),e.direction="sendonly"),e})),e.next=23,this.setLocalDescription(s.sdp);case 23:return e.next=25,this.setRemoteDescription(lib.write(g));case 25:return e.next=27,new promise((function(e,t){y._dataChannel.onopen=function(){logger$c.print("connect","dataChannel open"),y._reportRtcInvokeStatus("es.dc.open",""),e("")},y._dataChannel.onerror=function(e){y._report("rtc_signaling_msg_error",{error_code:e.error.sdpLineNumber,message:e.error.errorDetail,reason:"invalid data"}),y._reportRtcInvokeStatus("es.dc.error",""),t(e)},y._dataChannel.onclose=function(e){y._reportRtcInvokeStatus("es.dc.close",""),t(e)},y._peerConnection.addEventListener("connectionstatechange",(function(e){"failed"!==y._peerConnection.iceConnectionState&&"closed"!==y._peerConnection.iceConnectionState&&"failed"!==y._peerConnection.connectionState||t(e)}))}));case 27:return logger$c.print("connect","dataChannel establish success"),e.abrupt("return",this._dataChannel);case 29:case"end":return e.stop()}}),e,this)}))),function(e){return l.apply(this,arguments)})},{key:"publish",value:(c=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){var r,n,i,o,a,s,c,l,u,p,_,h,f;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=_get(_getPrototypeOf(d.prototype),"internalPublish",this).call(this,t),i=n.videoDescriptions,o=n.subVideoDescriptions,a=n.audioTransceiverInit,s=n.videoTransceiverInit,t.audioTransceiver=this._peerConnection.addTransceiver(a.track,a.init),t.videoTransceiver=this._peerConnection.addTransceiver(s.track,s.init),c=getServerNow(),this._report("rtc_begin_create_offer",{direction:"up",stream_id:"",stream_user_id:""}),e.next=7,this._peerConnection.createOffer();case 7:return l=e.sent,this._report("rtc_create_offer",{direction:"up",error_code:0,stream_id:"",stream_user_id:"",elapse:getServerNow()-c}),u=lib.parse(l.sdp),e.next=12,this.setLocalDescription(l.sdp);case 12:return p=t.audioTransceiver.mid,_=t.videoTransceiver.mid,h=null,f=null,u.media=null===(r=u.media)||void 0===r?void 0:map$6(r).call(r,(function(e){return"".concat(e.mid)===p?h=e:"".concat(e.mid)===_&&(f=e),e})),isEncodedTransformSupported()&&(t.initVideoEncodedTransform(),t.initAudioEncodedTransform()),e.abrupt("return",{partialSdp:getLocalPartialSdp(u,h,f,!1),audioMid:p,videoMid:_,type:"incroffer",semantics:"unified-plan",videoDescriptions:i,subVideoDescriptions:o,audioTransceiverInit:a,videoTransceiverInit:s});case 19:case"end":return e.stop()}}),e,this)}))),function(e){return c.apply(this,arguments)})},{key:"subscribe",value:(s=_asyncToGenerator(_regeneratorRuntime().mark((function e(t,r){var n,i,o,a,s,c,l,u,d,p,_,h,f,m,v,g,y,S,T,$,E,b;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return logger$c.print("subscribe()"),a="",s="",c=!1,l=!1,u=void 0,d=void 0,t.virtual?c=!0:(r.multiChatMode||(c=!0),l=!0),c&&(t.audioTransceiver=this._peerConnection.addTransceiver("audio",{direction:"recvonly"})),l&&(t.videoTransceiver=this._peerConnection.addTransceiver("video",{direction:"recvonly"})),p=getServerNow(),this._report("rtc_begin_create_offer",{direction:"up",stream_id:t.streamId,stream_user_id:t.userId}),e.next=14,this._peerConnection.createOffer();case 14:return _=e.sent,this._report("rtc_create_offer",{error_code:0,direction:"up",stream_id:t.streamId,stream_user_id:t.userId,elapse:getServerNow()-p}),h=lib.parse(_.sdp),e.next=19,this.setLocalDescription(_.sdp,{streamId:t.streamId||"",streamUserId:t.userId});case 19:if(a=null===(n=t.audioTransceiver)||void 0===n?void 0:n.mid,s=null===(i=t.videoTransceiver)||void 0===i?void 0:i.mid,null===(o=h.media)||void 0===o||o.forEach((function(e){"".concat(e.mid)===a?u=e:"".concat(e.mid)===s&&(d=e)})),a&&u||(a="audio_".concat(s),u=_objectSpread2(_objectSpread2({},this._aRecvonlyOfferTpl),{},{mid:a})),t.audioMid=a,t.videoMid=s,f=void 0,r.multiChatMode||t.virtual||!this._aSendonlyAnswerTpl||!this._aSendonlyAnswerTpl){e.next=34;break}return f=generateAllSsrc(this._nextSsrc),this._nextSsrc=f.next,E=_objectSpread2(_objectSpread2(_objectSpread2({},this._aSendonlyAnswerTpl),this._answerIce),{},{mid:a,msid:concat$2(m=concat$2(v="".concat(t.streamId)).call(v,null!==(g=this._context)&&void 0!==g&&g.avSync?"":"-audio"," ")).call(m,t.streamId,"-audio"),ssrcs:generateSsrc(t.streamId,"audio",f.audio)}),b=_objectSpread2(_objectSpread2(_objectSpread2({},this._vSendonlyAnswerTpl),this._answerIce),{},{mid:s,msid:concat$2(y=concat$2(S="".concat(t.streamId)).call(S,null!==(T=this._context)&&void 0!==T&&T.avSync?"":"-video"," ")).call(y,t.streamId,"-video")},generateSsrcs(t.streamId,f,{flexfec:this._enableSubFlexfec})),e.next=33,this._internalSetRemoteDescription([E,b],t);case 33:null===($=f)||void 0===$||delete $.next;case 34:return isEncodedTransformSupported()&&(t.initVideoEncodedTransform(),t.initAudioEncodedTransform()),e.abrupt("return",{partialSdp:getLocalPartialSdp(h,u,d,!1),audioMid:a,videoMid:s,type:"incroffer",semantics:"unified-plan",audioTransceiverInit:t.audioTransceiver?{track:"audio",init:{direction:"recvonly"}}:void 0,videoTransceiverInit:t.videoTransceiver?{track:"video",init:{direction:"recvonly"}}:void 0,allSsrc:f});case 36:case"end":return e.stop()}}),e,this)}))),function(e,t){return s.apply(this,arguments)})},{key:"handleAck",value:(a=_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(r=t.signalingAck,n=t.stream,(i=t.action)!==SdpAction.unpublish&&i!==SdpAction.unsubscribe&&i!==SdpAction.removetrack){e.next=5;break}return e.next=4,this.close(n);case 4:return e.abrupt("return",n.streamId||"");case 5:if(!t.generatorSsrc){e.next=8;break}return logger$c.print("already set remote"),e.abrupt("return","");case 8:return o=lib.parse(null==r?void 0:r.sdp),e.next=11,this._internalSetRemoteDescription(o.media,n);case 11:return e.abrupt("return","");case 12:case"end":return e.stop()}}),e,this)}))),function(e){return a.apply(this,arguments)})},{key:"_internalSetRemoteDescription",value:(o=_asyncToGenerator(_regeneratorRuntime().mark((function e(t,r){var n,i,o,a,s,c,l,u,d=this;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return s={},(c=lib.parse(null===(n=this._peerConnection.remoteDescription)||void 0===n?void 0:n.sdp)).media.forEach((function(e){void 0!==e.mid&&(s[e.mid]=e)})),t.forEach((function(e){"audio"===(e=_objectSpread2(_objectSpread2({},e),d._answerIce)).type&&(r.audioMid?(e.mid=r.audioMid,s[r.audioMid]=e):s[e.mid]=e),"video"===e.type&&(r.videoMid?(e.mid=r.videoMid,s[r.videoMid]=e):s[e.mid]=e)})),l=lib.parse(null===(i=this._peerConnection.localDescription)||void 0===i?void 0:i.sdp),u=map$6(o=l.media).call(o,(function(e){var t=s[e.mid];return"inactive"===e.direction?e:t})),c.groups=l.groups,c.media=u,map$6(a=c.media).call(a,(function(e){var t,r;"video"===e.type&&(e.ext=null===(t=e.ext)||void 0===t?void 0:filter3(t).call(t,(function(e){var t;return-1===indexOf2(t=e.uri).call(t,"abs-send-time")})),e.rtcpFb=null===(r=e.rtcpFb)||void 0===r?void 0:filter3(r).call(r,(function(e){return"goog-remb"!==e.type})))})),e.next=11,this.setRemoteDescription(lib.write(c));case 11:case"end":return e.stop()}}),e,this)}))),function(e,t){return o.apply(this,arguments)})},{key:"getDefaultSdp",value:(i=_asyncToGenerator(_regeneratorRuntime().mark((function e(){var t,r,n,i,o;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=lib.parse(null===(t=this._peerConnection.localDescription)||void 0===t?void 0:t.sdp),this.createAVMlineOfferTpl(null===(r=this._peerConnection.localDescription)||void 0===r?void 0:r.sdp),o=[],i.media=filter3(n=i.media).call(n,(function(e){return"recvonly"===e.direction&&(e.mid=e.mid+1,o.push("".concat(e.mid)),!0)})),i.groups=[{mids:o.join(" "),type:"BUNDLE"}],e.abrupt("return",{sdp:lib.write(i),semantics:"unified-plan",type:"incroffer"});case 6:case"end":return e.stop()}}),e,this)}))),function(){return i.apply(this,arguments)})},{key:"rollback",value:(n=_asyncToGenerator(_regeneratorRuntime().mark((function e(t,r,n){return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return logger$c.print("rollback()"),e.abrupt("return",this.close(r));case 2:case"end":return e.stop()}}),e,this)}))),function(e,t,r){return n.apply(this,arguments)})},{key:"close",value:(r=_asyncToGenerator(_regeneratorRuntime().mark((function e(t,r){var n,i,o,a,s,c,l,u,d,p=this;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return logger$c.print("close()"),a={},t.audioTransceiver&&t.audioMid&&(t.audioTransceiver.stop(),a[t.audioMid]=t.audioMid),t.videoTransceiver&&t.videoMid&&!r&&(t.videoTransceiver.stop(),a[t.videoMid]=t.videoMid),s=[],e.next=7,this._peerConnection.createOffer();case 7:return c=e.sent,(l=lib.parse(null==c?void 0:c.sdp)).media=map$6(n=l.media).call(n,(function(e){return a[e.mid]&&(e=closeMline(e)),"inactive"!==e.direction&&s.push(e.mid),_objectSpread2(_objectSpread2({},e),p._offerIce)})),u=lib.parse(null===(i=this._peerConnection.remoteDescription)||void 0===i?void 0:i.sdp),d={},u.media.forEach((function(e){void 0!==e.mid&&(d[e.mid]=e)})),u.media=map$6(o=l.media).call(o,(function(e){return"inactive"===e.direction?e:d[e.mid]})),l.groups&&u.groups&&(l.groups[0].mids=s.join(" "),u.groups[0].mids=s.join(" ")),e.next=17,this.setLocalDescription(null==c?void 0:c.sdp);case 17:return e.next=19,this.setRemoteDescription(lib.write(u));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)})},{key:"createAVMlineOfferTpl",value:function(e){var t=this;lib.parse(e).media.forEach((function(e){"audio"===e.type&&(t._aRecvonlyOfferTpl=e)}))}}]),d}(),createHandler=function(e){return e.enableFallbackHandler?new FallbackHandler(e):isFirefox?new FirefoxHandler(e):new ChromeHandler(e)},logger$b=new Logger("Locker",2),lockId=1,PromiseLock=function(){function e(t){var r;_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$b.print(concat$2(r="[lock-".concat(this.name,"-")).call(r,this.lockId,"] is created."))}return _createClass(e,[{key:"isLocked",get:function(){return this.locks>0}},{key:"lock",value:function(){var e,t,r,n=this;this.locks+=1,logger$b.print(concat$2(e=concat$2(t="[lock-".concat(this.name,"-")).call(t,this.lockId,"] locked, current queue ")).call(e,this.locks,"."));var i=new promise((function(e){r=function(){var t,r;n.locks-=1,logger$b.print(concat$2(t=concat$2(r="[lock-".concat(n.name,"-")).call(r,n.lockId,"] unlocked, current queue ")).call(t,n.locks,".")),e()}})),o=this.lockingPromise.then((function(){return r}));return this.lockingPromise=this.lockingPromise.then((function(){return i})),o}}]),e}(),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_SUBTITLE_STATE_CHANGED="ON_SUBTITLE_STATE_CHANGED",e.ON_SUBTITLE_MESSAGE_RECEIVED="ON_SUBTITLE_MESSAGE_RECEIVED",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||{}),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=defineProperty$a,__getOwnPropDesc$2=getOwnPropertyDescriptor$1,__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$a=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$a.print(e,"userId: %o, subAudio: %o, subVideo: %o, audioMid: %o, videoMid: %o, sequenceId: %o",t.userId,t.subAudio,t.subVideo,t.audioMid,t.videoMid,t.sequenceId)},MediaServerClient=function(e){_inherits(E,EnhancedEventEmitter);var t,r,n,i,o,a,s,c,l,u,d,p,_,h,f,m,v,g,y,S,T,$=_createSuper(E);function E(e){var t;return _classCallCheck(this,E),_defineProperty(_assertThisInitialized(t=$.call(this)),"id",void 0),_defineProperty(_assertThisInitialized(t),"_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),"_expectedIDC",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 map2),_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),"_subConfig",{}),_defineProperty(_assertThisInitialized(t),"_monitor",void 0),_defineProperty(_assertThisInitialized(t),"_roomProfile",RoomProfileType.communication),_defineProperty(_assertThisInitialized(t),"_context",void 0),_defineProperty(_assertThisInitialized(t),"_subStreamQueue",{}),t.id=e.id,t._monitor=getMonitor(t.id),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(E,[{key:"_addHandlerEvents",value:function(){var e,t=this;null===(e=this._handler)||void 0===e||e.once("disconnect",(function(){logger$a.print("emit ABNORMAL_DISCONNECTION ice"),t.safeEmit(StateEvent.ABNORMAL_DISCONNECTION)}))}},{key:"_addSignalEventHandler",value:function(){var e,t=this;[SignalEvent.ON_ADD_STREAM,SignalEvent.ON_ADD_STREAM_LIST,SignalEvent.ON_REMOVE_STREAM,SignalEvent.ON_REMOVE_STREAM_LIST,SignalEvent.USER_CONNECTION,SignalEvent.USER_CONNECTION_LIST,SignalEvent.USER_DISCONNECTION,SignalEvent.USER_DISCONNECTION_LIST,SignalEvent.ON_UPDATE_STREAM_ATTRIBUTES,SignalEvent.ON_UPDATE_ROOM_ATTRIBUTES,SignalEvent.ON_PUSH_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_UPDATE_USER_ATTRIBUTES,SignalEvent.ON_SPEAKER_CHANGE,MediaServerSignalEvent.RSCP,MediaServerSignalEvent.RTT,MediaServerSignalEvent.SSC,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$a.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:"businessId",set:function(e){this._businessId=e}},{key:"connect",value:(T=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){var r,n,i,o,a,s,c=this,l=arguments;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=l.length>1&&void 0!==l[1]?l[1]:{},this.connectionState="connecting",this._appId=t,this._handler&&(this._removeSignalEventHandler(),this._handler.destroy()),!r.node){e.next=9;break}n=[r.node],reportRtcInvokeStatus(this.id,"es.join.nodeChange",r),e.next=18;break;case 9:return promise.resolve().then((function(){return c.emit("onGetIceConfigHook")})),this._iceConfigRequestManager=new IceConfigRequestManager(this.id),e.next=13,null===(i=this._iceConfigRequestManager)||void 0===i?void 0:i.getAccessNode(t,null==r?void 0:r.reason,null==r?void 0:r.feedbackNode,this._useCloudProxy,this._expectedIDC);case 13:if(n=e.sent){e.next=17;break}throw reportRtcInvokeStatus(this.id,"es.join.getNodeFailed",""),new SDKError(ErrorCode.ICE_SERVER_WRONG,"get ICE config failed");case 17:reportRtcInvokeStatus(this.id,"es.join.getNodeSuccess",n);case 18:return promise.resolve().then((function(){return c.emit("onEstablishConnectionHook")})),e.prev=19,a=!1,s=map$6(n).call(n,(function(e){var t=createHandler(c._context);return t.connect(e).then((function(r){var i,s;c.emit("onConnectSuccessHook",null===(i=n)||void 0===i?void 0:i.length),a?t.destroy():(a=!0,o=r,c.safeEmit("prevIceNode",e),c._handler=t,c.supportConcurrent="chrome"===t.name,c._addHandlerEvents(),null===(s=c._monitor)||void 0===s||s.set({connection_id:t.getConnectionId()}))})).catch((function(e){throw t.destroy(),e}))})),e.next=24,promiseAny2(s);case 24:logger$a.print("connect","establish peerConnection success"),e.next=31;break;case 27:throw e.prev=27,e.t0=e.catch(19),this.connectionState="disconnected",new SDKError(ErrorCode.ESTABLISH_DATACHANNEL_FAILED,"establish dataChannel failed",e.t0);case 31:if(!o){e.next=37;break}this._dataChannelSignal=new DataChannelSignaling(this.id,o),this._addSignalEventHandler(),this._dataChannelSignal.sendPingSignaling(),e.next=39;break;case 37:throw this.connectionState="disconnected",new SDKError(ErrorCode.ESTABLISH_DATACHANNEL_FAILED,"establish dataChannel failed");case 39:case"end":return e.stop()}}),e,this,[[19,27]])}))),function(e){return T.apply(this,arguments)})},{key:"join",value:(S=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){var r,n,i,o,a,s,c,l,u,d,p,_,h,f,m,v,g=this,y=arguments;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=y.length>1&&void 0!==y[1]?y[1]:{},i=y.length>2&&void 0!==y[2]&&y[2],o=y.length>3?y[3]:void 0,logger$a.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._expectedIDC=t.expectedIDC,this._roomProfile=t.roomProfile,this._sessionId=n.sessionId,this._handler){e.next=17;break}return e.next=17,this.connect(this._appId,n);case 17: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=24,null===(r=this._handler)||void 0===r?void 0:r.getDefaultSdp();case 24:return e.t5=e.sent,e.next=27,internalGetSupportedCodecs(getParameter("PUB_SUB_MODE"));case 27: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,enableCloudProxy:e.t14,channelProfile:e.t15},e.t17={supportTokenExpireCallBack:!0,enableSceneConfigV2:!0,enableUnBundleMode:!0,enableAudioMux:!0,enableBigRoomMode:!0,needNegotiateSDP:!0},e.t18=stringify$1({requireICEUfragV2:!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,accessParams:e.t18},e.prev=41,e.t19=reportRtcInvokeStatus,e.t20=this.id,e.t21=stringify$1,e.next=47,internalGetSupportedCodecsSdpOffer();case 47:e.t22=e.sent,e.t23=getParameter("PUB_SUB_MODE")||"recv_and_send",e.t24={supportedCodecsSdpOffer:e.t22,pubSubMode:e.t23},e.t25=(0,e.t21)(e.t24),(0,e.t19)(e.t20,"MediaClient.internalGetSupportedCodecsSdpOffer",e.t25),e.next=56;break;case 54:e.prev=54,e.t26=e.catch(41);case 56:return promise.resolve().then((function(){return g.emit("onSendingJoinMessageHook")})),e.prev=57,c=i?"reconnected":"joinRoom",e.next=61,this._dataChannelSignal.sendSignaling(c,a);case 61:return l=e.sent,logger$a.print("join","send join message success"),u=l.config||{},d=u.engine_WEB,this._authorization=a.Authorization,this.connectionState="connected",sdkCache.setEngineWebConfig(this._appId,this._roomId,d),this._context&&(this._context.serverConfig={videoCodec:(null==d?void 0:d.video_codec)||"H264",audioRed:!(null==d||!d.pub_audio_red),muteReplaceUnsub:!(null===(p=l.config)||void 0===p||!p.mute_replace_unsub),simulcastOnDemand:!(isFirefox||!1===(null===(_=l.config)||void 0===_||null===(h=_.engine_VPM)||void 0===h||null===(f=h.ondemand)||void 0===f?void 0:f.enable))},"boolean"==typeof(null==d?void 0:d.av_sync)&&(this._context.avSync=d.av_sync)),RemoteStatsReport.audioStallConfig=d,null!=l&&null!==(s=l.relayMessage)&&void 0!==s&&s.sdp&&(null===(m=this._handler)||void 0===m||m.createAVMlineAnswerTpl(l.relayMessage.sdp)),e.abrupt("return",l);case 73:if(e.prev=73,e.t27=e.catch(57),this.connectionState="disconnected",v={461:ErrorCode.ROOM_FORBIDDEN,462:ErrorCode.USER_FORBIDDEN},!((null===e.t27||void 0===e.t27?void 0:e.t27.code)>=700&&(null===e.t27||void 0===e.t27?void 0:e.t27.code)<800)){e.next=81;break}throw new SDKError(ErrorCode.INVALID_TOKEN,(null===e.t27||void 0===e.t27?void 0:e.t27.message)||"Invalid token");case 81:if(!v[null===e.t27||void 0===e.t27?void 0:e.t27.code]){e.next=83;break}throw new SDKError(v[null===e.t27||void 0===e.t27?void 0:e.t27.code],(null===e.t27||void 0===e.t27?void 0:e.t27.message)||v[null===e.t27||void 0===e.t27?void 0:e.t27.code]);case 83:if(200===(null===e.t27||void 0===e.t27?void 0:e.t27.code)){e.next=85;break}throw new SDKError(ErrorCode.JOIN_ROOM_FAILED,(null===e.t27||void 0===e.t27?void 0:e.t27.message)||"Join room failed");case 85:case"end":return e.stop()}}),e,this,[[41,54],[57,73]])}))),function(e){return S.apply(this,arguments)})},{key:"publish",value:(y=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){var r,n,i,o,a,s,c,l,u,d,p,_,h,f,m,v,g,y,S,T,$,E,b,I,R=this;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return logger$a.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);case 9:if(y=e.sent){e.next=12;break}throw new SDKError(ErrorCode.ADD_TRANSCEIVER_FAILED,"add transceiver failed");case 12:if("H264"!==(null===(c=this._context)||void 0===c||null===(l=c.serverConfig)||void 0===l?void 0:l.videoCodec)){e.next=18;break}return e.next=15,isH264EncodeSupported();case 15:if(e.sent){e.next=18;break}throw new SDKError(ErrorCode.PUBLISH_FAILED,"h264 is not supported");case 18:return o=y.audioMid,a=y.videoMid,t.pubAttributes={localaudio:!!n,localvideo:!!r,videostream:t.pubVideo,audiostream:t.pubAudio,extvideo:!!(r instanceof CustomVideoLocalTrack),extaudio:!!(n instanceof CustomAudioLocalTrack)},S={attributes:_objectSpread2({videoDescriptions:y.videoDescriptions},t.pubAttributes),audio:!0,video:!0,screen:t.isScreen,audioMid:o,videoMid:a,sdpInfo:{msid:t.stream.id,type:y.type,sdp:y.partialSdp,semantics:y.semantics}},(T=t.enableSimulcast&&(null===(u=this._context)||void 0===u||null===(d=u.serverConfig)||void 0===d?void 0:d.simulcastOnDemand)&&(null===(p=y.subVideoDescriptions)||void 0===p?void 0:p.length))&&(S.attributes.subVideoDescriptions=y.subVideoDescriptions),e.next=26,null===(_=this._dataChannelSignal)||void 0===_?void 0:_.sendSignaling("publish",S);case 26:if(200===(null==($=e.sent)?void 0:$.code)){e.next=29;break}throw new SDKError(ErrorCode.PUBLISH_FAILED,(null==$?void 0:$.message)||"publish failed");case 29:if(null===(h=this._monitor)||void 0===h||h.report("rtc_recv_answer",{error_code:0,answer_type:"incranswer",sequence_id:(null==$||null===(f=$.relayMessage)||void 0===f?void 0:f.sequenceId)||0,message:null==$||null===(m=$.relayMessage)||void 0===m?void 0:m.sdp,direction:"up",stream_id:"",stream_user_id:""}),E=new promise((function(e,r){var n,i,s;null===(n=R._handler)||void 0===n||n.handleAck({action:SdpAction.publish,streamId:$.streamId,audioMid:o,videoMid:a,audioTransceiverInit:null==y?void 0:y.audioTransceiverInit,videoTransceiverInit:null==y?void 0:y.videoTransceiverInit,signalingAck:{sdp:null==$||null===(i=$.relayMessage)||void 0===i?void 0:i.sdp,sequenceId:null==$||null===(s=$.relayMessage)||void 0===s?void 0:s.sequenceId},sdp:y.sdp,stream:t,onSuccess:function(){logger$a.print("publish()","publish success"),e(0)}})})),"chrome"!==(null===(v=this.handler)||void 0===v?void 0:v.name)){e.next=34;break}return e.next=34,E;case 34:return T&&this.emit(MediaServerSignalEvent.RSCP,[{StreamIds:[t.stream.id],Metadata:{VideoIndex:0}}]),t.streamId=$.streamId,t.videoMid=a,t.audioMid=o,t.subVideoDescriptions=y.subVideoDescriptions,null===(g=this._monitor)||void 0===g||g.report("rtc_publish_stat",{result:"success",is_screen:"0",start:i,message:"unknown"}),t.statsReport.setLocalStreamStatsEvtInterval((function(e){return R.emit("onLocalStreamStats",e)}),this._handler,this._context),e.abrupt("return");case 44:return e.prev=44,e.t0=e.catch(6),e.t0 instanceof Error&&(null===(I=this._monitor)||void 0===I||I.report("rtc_publish_stat",{result:"fail",is_screen:"0",start:i,message:e.t0.message})),e.next=49,null===(b=this._handler)||void 0===b?void 0:b.rollback(t.stream.id,t);case 49:throw e.t0;case 50:case"end":return e.stop()}}),e,this,[[6,44]])}))),function(e){return y.apply(this,arguments)})},{key:"updatePubTrack",value:(g=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){var r,n,i,o,a,s,c,l,u,d,p,_,h,f,m,v,g,y,S,T,$,E,b,I,R,C,A,k,P,O,w;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:logger$a.print("updatePubTrack()","localStream: %o",t),i=t.videoTrack,o=t.audioTrack,a=t.pubAudio,s=t.pubVideo,c=null==o?void 0:o.getTrack("preprocessing"),l=null==i?void 0:i.getTrack("preprocessing"),s&&l?null===(u=t.videoTransceiver)||void 0===u||u.sender.replaceTrack(l):null===(d=t.videoTransceiver)||void 0===d||d.sender.replaceTrack(null),null===(r=this._handler)||void 0===r||r.updateMaxBitrate(t),a&&c?(_=o.mixType,(h=o.mixedAudioTrack)&&_!==AudioMixingType.PLAYOUT&&!0===c.enabled&&(c=h),null===(p=t.audioTransceiver)||void 0===p||p.sender.replaceTrack(c)):(null===(f=t.audioTransceiver)||void 0===f||f.sender.replaceTrack(null),reportRtcInvokeStatus(this.id,"MediaClient.updatePubTrack(audio)","null"));try{reportRtcInvokeStatus(this.id,"MediaClient.updatePubTrack",stringify$1({audioStreamTrack:MediaTrackStringify(c),videoStreamTrack:MediaTrackStringify(l)}))}catch(e){}for(v={},g=0,y=entries2(m={localaudio:!!o,localvideo:!!i,videostream:s,audiostream:a,extvideo:!!(i instanceof CustomVideoLocalTrack),extaudio:!!(o instanceof CustomAudioLocalTrack)});g<y.length;g++)S=_slicedToArray(y[g],2),T=S[0],($=S[1])!==get(t.pubAttributes,T)&&set$6(v,T,$);if(keys$8(v).length){e.next=13;break}return e.abrupt("return");case 13:return t.observer&&(E=t.observer,b=v.audiostream,I=v.videostream,R=v.localaudio,C=v.localvideo,A=v.extaudio,k=v.extvideo,void 0!==C?void 0!==k?E.setPushVideo(k):E.setEnableVideo(C):void 0!==I&&E.setUnmuteVideo(I),void 0!==R?void 0!==A?E.setPushAudio(A):E.setEnableAudio(R):void 0!==b&&E.setUnmuteAudio(b)),t.pubAttributes=m,P={roomId:this._roomId,streamId:t.streamId,attributes:v},e.next=18,null===(n=this._dataChannelSignal)||void 0===n?void 0:n.sendSignaling("updateStreamAttributes",P);case 18:if(200===(null==(O=e.sent)?void 0:O.code)){e.next=21;break}throw new SDKError(ErrorCode.UPDATE_TRACK_FAILED,(null==O?void 0:O.message)||"update track failed");case 21:if(!isFirefox){e.next=24;break}return e.next=24,null===(w=this._handler)||void 0===w?void 0:w.setCurrentDescription();case 24:case"end":return e.stop()}}),e,this)}))),function(e){return g.apply(this,arguments)})},{key:"updateToken",value:(v=_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$a.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 v.apply(this,arguments)})},{key:"unpublish",value:(m=_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$a.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 m.apply(this,arguments)})},{key:"subscribe",value:(f=_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,l,u,d,p,_,h,f,m,v,g,y,S,T,$,E,b,I,R,C,A,k,P,O,w,M,D,x,N,L,U,V;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).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$a.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$a.print("subscribe()","mediaType: %o",r),logRemoteStream("subscribe()",t),t.streamState=StreamState.SUB_ING,c=!1,l=!1,audioInMediaType(r)&&(l=!0),videoInMediaType(r)&&(c=!0),c||!i.multiChatMode()){e.next=17;break}return t.streamState=StreamState.INIT,i.emit("SUB_END",t.streamId),e.abrupt("return",o(null));case 17:return u=getServerNow(),d=t.subVideo,p=[],_=!i.multiChatMode(),i._subResolves[t.streamId]||(i._subResolves[t.streamId]=[]),p.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$a.print("remoteStream ".concat(t.userId," received video track")),t.off("ontrack",r),clearTimeout(n),e(0))}))}))),_&&p.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$a.print("remoteStream ".concat(t.userId," received audio track")),t.off("ontrack",r),clearTimeout(n),e(0))}))}))),h=function(e){t.ontrack(e)},null===(s=i._handler)||void 0===s||s.on("ontrack",h),i._ontrackCallbackMap.set(t,h),e.prev=27,e.next=30,null===(f=i._handler)||void 0===f?void 0:f.subscribe(t,{multiChatMode:i.multiChatMode()});case 30:if(I=e.sent){e.next=33;break}throw new SDKError(ErrorCode.ADD_TRANSCEIVER_FAILED,"add transceiver failed");case 33:return R=I.audioMid,C=I.videoMid,t.subVideo=c,A={spatialLayer:(null==n?void 0:n.spatialLayer)||0,temporalLayer:0,spatialSubLayer:(null==n?void 0:n.spatialSubLayer)||-1},k={audio:!i.multiChatMode(),video:!0,data:!0,screen:t.isScreen,browser:"chrome-stable",videoMid:C,audioMid:R,sdpInfo:{sdp:null==I?void 0:I.partialSdp,semantics:null==I?void 0:I.semantics,type:null==I?void 0:I.type},streamUserId:t.userId,streamId:t.streamId,config:{enableMediaType:{audio:!!i.multiChatMode()||l,video:c},qualityLayer:A},extra:{enableSendRTT:!0}},P=i._context||{},O=P.subscribeFallbackOption,w=P.userPriority,"number"==typeof O&&(k.config.fallbackOption=O),null!=w&&w.has(t.userId)&&(k.config.priority=w.get(t.userId)),null!=I&&I.allSsrc&&(k.extra.subscribeSSRC=I.allSsrc),e.next=44,null===(m=i._dataChannelSignal)||void 0===m?void 0:m.sendSignaling("subscribe",k);case 44:if(200===(null==(M=e.sent)?void 0:M.code)){e.next=47;break}throw new SDKError(ErrorCode.SUBSCRIBE_FAILED,(null==M?void 0:M.message)||"subscribe failed");case 47:return D=null==M?void 0:M.relayMessage,x=D.audioMid,N=D.videoMid,_defineProperty(v={},R,x),_defineProperty(v,C,N),L=v,logger$a.print("sub midmap",t.userId,L),t.videoMid=C,t.audioMid=R,t.subMediaType=r,t.streamState=StreamState.SUB_ED,t.subLayer=A,null===(g=i._monitor)||void 0===g||g.report("rtc_recv_answer",{error_code:0,answer_type:"incranswer",sequence_id:(null==M||null===(y=M.relayMessage)||void 0===y?void 0:y.sequenceId)||0,message:null==M||null===(S=M.relayMessage)||void 0===S?void 0:S.sdp,direction:"down",stream_id:t.streamId,stream_user_id:t.userId}),e.next=58,null===(T=i._handler)||void 0===T?void 0:T.handleAck({action:SdpAction.subscribe,streamId:t.streamId,audioMid:R,videoMid:C,audioTransceiverInit:null==I?void 0:I.audioTransceiverInit,videoTransceiverInit:null==I?void 0:I.videoTransceiverInit,signalingAck:{sdp:null==M||null===($=M.relayMessage)||void 0===$?void 0:$.sdp,sequenceId:null==M||null===(E=M.relayMessage)||void 0===E?void 0:E.sequenceId},stream:t,sdp:I.sdp,generatorSsrc:!!I.allSsrc});case 58:return e.next=60,promise.all(p);case 60:i.multiChatMode()||(t.subAudio=l),null===(b=i._monitor)||void 0===b||b.report("rtc_subscribe_stat",{result:"success",start:u,message:"unknown",stream_user_id:t.userId}),i._context&&t.statsReport.setRemoteStreamStatsEvtInterval((function(e){return i.emit("onRemoteStreamStats",e)}),i._handler,i._context),o(null),i.emit("SUB_END",t.streamId),e.next=76;break;case 67:return e.prev=67,e.t0=e.catch(27),e.t0 instanceof Error&&(null===(V=i._monitor)||void 0===V||V.report("rtc_subscribe_stat",{result:"fail",start:u,message:e.t0.message,stream_user_id:t.userId})),t.subVideo=d,t.streamState=StreamState.INIT,e.next=74,null===(U=i._handler)||void 0===U?void 0:U.rollback(t.streamId,t);case 74:a(e.t0),i.emit("SUB_END",t.streamId);case 76:case"end":return e.stop()}}),e,null,[[27,67]])})));return function(t,r){return e.apply(this,arguments)}}()));case 1:case"end":return e.stop()}}),e)}))),function(e,t,r){return f.apply(this,arguments)})},{key:"_handleSubStreamQueue",value:function(e){var t,r=this;if(null!==(t=this._subStreamQueue[e])&&void 0!==t&&t.length){logger$a.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$a.print("_subStreamQueue","streamId: %o, END",e)}},{key:"controlMessage",value:(h=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){var r,n;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return logger$a.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 h.apply(this,arguments)})},{key:"updateUserAttributes",value:(_=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){var r;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return logger$a.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 _.apply(this,arguments)})},{key:"updateSubTrack",value:(p=_asyncToGenerator(_regeneratorRuntime().mark((function e(t,r,n){return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this._updateSubTrack(t,r,n));case 1:case"end":return e.stop()}}),e,this)}))),function(e,t,r){return p.apply(this,arguments)})},{key:"updateSubTrackLayer",value:(d=_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(logger$a.print("updateSubTrack()","subLayer: %o",r),t.subLayer.spatialLayer!==r.spatialLayer||t.subLayer.spatialSubLayer!==r.spatialSubLayer){e.next=4;break}return logger$a.print("updateSubTrack()","subLayer no change"),e.abrupt("return");case 4:return i={roomId:this._roomId,streamList:[t.streamId],streamId:t.streamId,streamUserId:t.userId,config:{qualityLayer:r}},e.next=7,null===(n=this._dataChannelSignal)||void 0===n?void 0:n.sendSignaling("updateSubscribe",i);case 7:if(200===(null==(o=e.sent)?void 0:o.code)){e.next=10;break}throw new SDKError(ErrorCode.UPDATE_TRACK_FAILED,(null==o?void 0:o.message)||"update track failed");case 10:return t.subLayer=r,e.abrupt("return",t);case 12:case"end":return e.stop()}}),e,this)}))),function(e,t){return d.apply(this,arguments)})},{key:"updateSubPriority",value:(u=_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(logger$a.print("updateSubPriority()","priority: %o",r),t.priority!==r){e.next=4;break}return logger$a.print("updateSubPriority()","priority no change"),e.abrupt("return",t);case 4:return i={roomId:this._roomId,streamList:[t.streamId],streamId:t.streamId,streamUserId:t.userId,config:{priority:r}},e.next=7,null===(n=this._dataChannelSignal)||void 0===n?void 0:n.sendSignaling("updateSubscribe",i);case 7:if(200===(null==(o=e.sent)?void 0:o.code)){e.next=10;break}throw new SDKError(ErrorCode.UPDATE_TRACK_FAILED,(null==o?void 0:o.message)||"update track failed");case 10:return t.priority=r,e.abrupt("return",t);case 12:case"end":return e.stop()}}),e,this)}))),function(e,t){return u.apply(this,arguments)})},{key:"_updateSubTrack",value:(l=_asyncToGenerator(_regeneratorRuntime().mark((function e(t,r,n){var i,o,a,s,c,l,u,d;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(logger$a.print("updateSubTrack()","mediaType: %o",r),logRemoteStream("updateSubTrack()",t),!this.multiChatMode()||r!==MediaType.AUDIO){e.next=5;break}return logger$a.print("updateSubTrack","multiChatMode mediaType only audio"),e.abrupt("return",t);case 5:return a=0,a=n===SubState.SUB?t.subMediaType|r:t.subMediaType-(t.subMediaType&r),logger$a.print("updateSubTrack","prev: %o, direction: %o, mediaType: %o, newMediaType: %o",t.subMediaType,n,r,a),t.subMediaType===a&&logger$a.print("updateSubTrack","mediaType no change"),s=!1,c=!1,audioInMediaType(a)&&(c=!0),videoInMediaType(a)&&(s=!0),l={roomId:this._roomId,streamList:[t.streamId],config:{enableMediaType:{video:s,audio:!!this.multiChatMode()||c}}},e.next=15,null===(i=this._dataChannelSignal)||void 0===i?void 0:i.sendSignaling("updateSubscribe",l);case 15:if(200===(null==(u=e.sent)?void 0:u.code)){e.next=18;break}throw new SDKError(ErrorCode.UPDATE_TRACK_FAILED,(null==u?void 0:u.message)||"update track failed");case 18:return this.multiChatMode()||(null===(d=t.observer)||void 0===d||d.setUnmuteAudio(c),t.subAudio=c),null===(o=t.observer)||void 0===o||o.setUnmuteVideo(s),t.subVideo=s,t.subMediaType=a,e.abrupt("return",t);case 23:case"end":return e.stop()}}),e,this)}))),function(e,t,r){return l.apply(this,arguments)})},{key:"subscribe4pushTrack",value:(c=_asyncToGenerator(_regeneratorRuntime().mark((function e(t,r){var n,i,o,a,s,c,l,u,d,p=this;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return logger$a.print("subscribe4pushTrack()","streamInfo: %o",r),logRemoteStream("subscribe4pushTrack()",t),t.subAudio=!0,null===(n=t.observer)||void 0===n||n.setPushTrack(!0),e.next=6,null===(i=this._handler)||void 0===i?void 0:i.subscribe(t,{multiChatMode:this.multiChatMode()});case 6:if(s=e.sent){e.next=9;break}throw new SDKError(ErrorCode.ADD_TRANSCEIVER_FAILED,"add transceiver failed");case 9:return c=s.audioMid,l=s.videoMid,(u=[]).push(new promise((function(e,r){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$a.print("remoteStream ".concat(t.userId," received audio track")),t.off("ontrack",r),clearTimeout(n),e(0))}))}))),d=function(e){t.ontrack(e)},null===(o=this._handler)||void 0===o||o.on("ontrack",d),this._ontrackCallbackMap.set(t,d),e.next=18,null===(a=this._handler)||void 0===a?void 0:a.handleAck({action:SdpAction.pushtrack,streamId:t.streamId,audioMid:c,videoMid:l,stream:t,audioTransceiverInit:null==s?void 0:s.audioTransceiverInit,videoTransceiverInit:null==s?void 0:s.videoTransceiverInit,signalingAck:null==r?void 0:r.message,sdp:s.sdp});case 18:return e.next=20,promise.all(u);case 20:this._context&&t.statsReport.setRemoteStreamStatsEvtInterval((function(e){return p.emit("onRemoteStreamStats",e)}),this._handler,this._context);case 21:case"end":return e.stop()}}),e,this)}))),function(e,t){return c.apply(this,arguments)})},{key:"unsubscribe4removeTrack",value:(s=_asyncToGenerator(_regeneratorRuntime().mark((function e(t,r){return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:logRemoteStream("unsubscribe4removeTrack()",t),logger$a.print("unsubscribe4removeTrack()","sequenceId: ",r.sequenceId);case 2:case"end":return e.stop()}}),e)}))),function(e,t){return s.apply(this,arguments)})},{key:"unsubscribe",value:(a=_asyncToGenerator(_regeneratorRuntime().mark((function e(t,r){var n,i,o=arguments;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=o.length>2&&void 0!==o[2]&&o[2],logRemoteStream("unsubscribe()",t),!n){e.next=4;break}return e.abrupt("return",this._unsubscribe(t,r));case 4:if(!this.multiChatMode()||!videoInMediaType(r)){e.next=6;break}return e.abrupt("return",this._unsubscribe(t,r));case 6:if(i=t.subMediaType-(t.subMediaType&r),this.multiChatMode()||i!==ExtendMediaType.NONE){e.next=9;break}return e.abrupt("return",this._unsubscribe(t,r));case 9:return e.abrupt("return",this._updateSubTrack(t,r,SubState.UNSUB));case 10: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;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._subConfig.muteReplaceUnsub){e.next=2;break}return e.abrupt("return",this._updateSubTrack(t,r,SubState.UNSUB));case 2:return 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,null===(i=t.observer)||void 0===i||i.setSubscribeVideo(!1),!this.multiChatMode()&&(null===(o=t.observer)||void 0===o||o.setSubscribeAudio(!1)),e.next=11,null===(a=this._handler)||void 0===a?void 0:a.handleAck({action:SdpAction.unsubscribe,streamId:t.streamId,audioMid:t.audioMid,videoMid:t.videoMid,stream:t});case 11:c=e.sent,this._subResolves[c]&&this._subResolves[c].forEach((function(e){return e(0)})),logger$a.print("unsubscribe","clean unsub ".concat(t.userId)),t.clean(),this.removeOnTrackListener(t),t.statsReport.unsubscribe();case 17: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,t.streamState!==StreamState.INIT){e.next=4;break}return e.abrupt("return");case 4:this.unsubscribe(t,MediaType.AUDIO_AND_VIDEO,!0);case 5: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$a.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,l,u,d,p,_,h,f,m,v,g=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,{multiChatMode:!1});case 2:if(s=e.sent){e.next=5;break}throw new SDKError(ErrorCode.ADD_TRANSCEIVER_FAILED,"add transceiver failed");case 5:return c=getServerNow(),l=s.audioMid,u=s.videoMid,e.t0=this._appId,e.t1=t.streamId,e.t2=l,e.t3=u,e.t4={sdp:null==s?void 0:s.partialSdp,semantics:null==s?void 0:s.semantics,type:null==s?void 0:s.type},e.next=15,internalGetSupportedCodecs();case 15:return e.t5=e.sent,e.t6=window.navigator.userAgent,e.t7=Config.VERSION,e.t8=sdkCache.getDeviceId(),e.t9=this._appId,e.t10=this._businessId,e.t11=this._useCloudProxy,e.t12={supportedCodecs:e.t5,deviceType:"web",userAgent:e.t6,sdkVersion:e.t7,deviceId:e.t8,appId:e.t9,businessId:e.t10,enableCloudProxy:e.t11},e.t13={enableMediaType:{audio:!0,video:!0},qualityLayer:{spatialLayer:0,temporalLayer:0}},d={appId:e.t0,streamId:e.t1,audio:!0,video:!0,data:!0,audioMid:e.t2,videoMid:e.t3,sdpInfo:e.t4,params:e.t12,config:e.t13},e.next=27,null===(n=this._dataChannelSignal)||void 0===n?void 0:n.sendSignaling("startPullStream",d);case 27:return p=e.sent,_=[],this._subResolves[t.streamId]=[],_.push(new promise((function(e,r){g._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$a.print("remoteStream ".concat(t.userId," received video track")),t.off("ontrack",r),clearTimeout(n),e(0))}))}))),_.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 streamId: ".concat(t.streamId)))}),WAIT_TRACK_TIMEOUT);t.on("ontrack",(function r(i){"audio"===i.mediaType&&(logger$a.print("remoteStream ".concat(t.userId," received audio track")),t.off("ontrack",r),clearTimeout(n),e(0))}))}))),h=function(e){t.ontrack(e)},null===(i=this._handler)||void 0===i||i.on("ontrack",h),this._ontrackCallbackMap.set(t,h),f=null==p?void 0:p.relayMessage,m=f.sequenceId,v=f.sdp,t.videoMid=u,t.audioMid=l,t.sequenceId=m,t.streamState=StreamState.SUB_ED,t.subAudio=!0,t.subVideo=!0,e.next=44,null===(o=this._handler)||void 0===o?void 0:o.handleAck({action:SdpAction.subscribe,streamId:t.streamId,audioMid:l,videoMid:u,audioTransceiverInit:null==s?void 0:s.audioTransceiverInit,videoTransceiverInit:null==s?void 0:s.videoTransceiverInit,signalingAck:{sdp:v,sequenceId:m},stream:t});case 44:return e.next=46,promise.all(_);case 46:null===(a=this._monitor)||void 0===a||a.report("rtc_subscribe_stat",{result:"success",start:c,message:"unknown",stream_user_id:t.userId}),this._context&&t.statsReport.setRemoteStreamStatsEvtInterval((function(e){return g.emit("onRemoteStreamStats",e)}),this._handler,this._context);case 48: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,n;logger$a.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,null===(e=this._handler)||void 0===e||e.destroy(),null===(t=this._monitor)||void 0===t||t.set({connection_id:""}),null===(r=this._dataChannelSignal)||void 0===r||r.destroy(),null===(n=this._iceConfigRequestManager)||void 0===n||n.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}}]),E}();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([checkConnection],MediaServerClient.prototype,"updateSubTrackLayer",1),__decorateClass$2([checkConnection],MediaServerClient.prototype,"updateSubPriority",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,logger$9=new Logger("RecvFrameObserver",0),RecvFrameObserver=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)),"_audioEventSessionId",genEventSessionId()),_defineProperty(_assertThisInitialized(r),"_videoEventSessionId",genEventSessionId()),_defineProperty(_assertThisInitialized(r),"_handler",void 0),_defineProperty(_assertThisInitialized(r),"_stream",void 0),_defineProperty(_assertThisInitialized(r),"_firstAudioFrameTimer",void 0),_defineProperty(_assertThisInitialized(r),"_firstVideoFrameTimer",void 0),_defineProperty(_assertThisInitialized(r),"_transportDelayInterval",void 0),_defineProperty(_assertThisInitialized(r),"_transportDelay",void 0),_defineProperty(_assertThisInitialized(r),"_firstVideoFrameInterval",void 0),_defineProperty(_assertThisInitialized(r),"_firstAudioFrameInterval",void 0),_defineProperty(_assertThisInitialized(r),"_isScreen",!1),_defineProperty(_assertThisInitialized(r),"_audioFirstFrameState",0),_defineProperty(_assertThisInitialized(r),"_videoFirstFrameState",0),_defineProperty(_assertThisInitialized(r),"_timeout",1e4),_defineProperty(_assertThisInitialized(r),"_currentAudioRecv",{startTime:0,eventSessionId:0,type:"login"}),_defineProperty(_assertThisInitialized(r),"_currentVideoRecv",{startTime:0,eventSessionId:0,type:"login"}),_defineProperty(_assertThisInitialized(r),"_login",!1),_defineProperty(_assertThisInitialized(r),"_unMuteAudio",!1),_defineProperty(_assertThisInitialized(r),"_enableAudio",!1),_defineProperty(_assertThisInitialized(r),"_unMuteVideo",!1),_defineProperty(_assertThisInitialized(r),"_enableVideo",!1),_defineProperty(_assertThisInitialized(r),"_remoteUnmuteAudio",!1),_defineProperty(_assertThisInitialized(r),"_remoteUnmuteVideo",!1),_defineProperty(_assertThisInitialized(r),"_audioExternal",!1),_defineProperty(_assertThisInitialized(r),"_pushAudio",!1),_defineProperty(_assertThisInitialized(r),"_videoExternal",!1),_defineProperty(_assertThisInitialized(r),"_pushVideo",!1),_defineProperty(_assertThisInitialized(r),"_autoSubscribeVideo",!1),_defineProperty(_assertThisInitialized(r),"_autoSubscribeAudio",!1),_defineProperty(_assertThisInitialized(r),"_autoSubscribe",!1),_defineProperty(_assertThisInitialized(r),"_publishVideo",!1),_defineProperty(_assertThisInitialized(r),"_publishAudio",!1),_defineProperty(_assertThisInitialized(r),"_subscribeAudio",!1),_defineProperty(_assertThisInitialized(r),"_subscribeVideo",!1),_defineProperty(_assertThisInitialized(r),"_subscribe",!1),_defineProperty(_assertThisInitialized(r),"_pushTrack",!1),_defineProperty(_assertThisInitialized(r),"_multiChatMode",!1),_defineProperty(_assertThisInitialized(r),"_monitor",void 0),r._stream=e,r._handler=t,r.getTransportDelay(),r._monitor=getMonitor(e.engineId),r}return _createClass(a,[{key:"beginRecvFrame",value:(i=_asyncToGenerator(_regeneratorRuntime().mark((function e(t,r){var n,i,o,a,s,c,l,u,d,p,_,h,f,m=this;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.getTransportDelay();case 2:i=this._transportDelay,o=!0,indexOf2(n=["login","unmute","subscribe","push_track"]).call(n,r)>=0&&(i=0,o=!1),"audio"===t?(o||this._audioEventSessionId++,this._currentAudioRecv={startTime:Date.now(),eventSessionId:this._audioEventSessionId,type:r},u={media_type:t,event_type:"begin_recv",type:r,is_screen:!(null===(a=this._stream)||void 0===a||!a.isScreen),start:null===(s=this._currentAudioRecv)||void 0===s?void 0:s.startTime,event_session_id:this._audioEventSessionId,stream_user_id:null===(c=this._stream)||void 0===c?void 0:c.userId,transport_delay:i},this._firstAudioFrameTimer&&window.clearTimeout(this._firstAudioFrameTimer),this._firstAudioFrameTimer=window.setTimeout((function(){m.stopRecvFrame("audio","timeout"),m._firstAudioFrameInterval&&window.clearInterval(m._firstAudioFrameInterval)}),this._timeout),logger$9.print("rtcFirstFrameRecv",stringify$1(u)),null===(l=this._monitor)||void 0===l||l.report("rtc_first_frame",u),this._watchForFirstAudioFrameRecv(),this._audioFirstFrameState=1,this._login=!0,this._unMuteAudio=!0,this._enableAudio=!0,this._remoteUnmuteAudio=!0):"video"===t&&(o||this._videoEventSessionId++,this._currentVideoRecv={startTime:Date.now(),eventSessionId:this._videoEventSessionId,type:r},f={media_type:t,event_type:"begin_recv",type:r,is_screen:!(null===(d=this._stream)||void 0===d||!d.isScreen),start:null===(p=this._currentVideoRecv)||void 0===p?void 0:p.startTime,event_session_id:this._videoEventSessionId,stream_user_id:null===(_=this._stream)||void 0===_?void 0:_.userId,transport_delay:i},this._firstVideoFrameTimer&&window.clearTimeout(this._firstVideoFrameTimer),this._firstVideoFrameTimer=window.setTimeout((function(){_asyncToGenerator(_regeneratorRuntime().mark((function e(){var t,r,n,i,o,a,s,c,l,u,d,p,_,h,f,v,g;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(e.t0=null===(t=m._handler)||void 0===t?void 0:t.pc,!e.t0){e.next=5;break}return e.next=4,getStats(null===(r=m._handler)||void 0===r?void 0:r.pc,null===(n=m._stream)||void 0===n||null===(i=n.videoTrack)||void 0===i?void 0:i.getTrack());case 4:e.t0=e.sent;case 5:return h=e.t0,f=find$2(o=h||[]).call(o,(function(e){return"inbound-rtp"===e.type})),e.next=9,null===(a=m._stream)||void 0===a||null===(s=a.videoTransceiver)||void 0===s?void 0:s.receiver.getStats();case 9:v=e.sent,g=[],null==v||v.forEach((function(e){return g.push(e.type)})),null===(c=m._monitor)||void 0===c||c.report("rtc_invoke_status",{sdk_api_name:"first_video_frame_timeout",error_code:-1,message:stringify$1({reports:map$6(h).call(h,(function(e){return e.type})),reports2:g,pc:(null===(l=m._handler)||void 0===l?void 0:l.pc)||null,track:(null===(u=m._stream)||void 0===u||null===(d=u.videoTrack)||void 0===d?void 0:d.getTrack().id)||null,framesReceived:null==f?void 0:f.framesReceived,packetsReceived:null==f?void 0:f.packetsReceived}),stream_id:(null===(p=m._stream)||void 0===p?void 0:p.streamId)||"",stream_user_id:null===(_=m._stream)||void 0===_?void 0:_.userId,elapse:0});case 13:case"end":return e.stop()}}),e)})))(),m.stopRecvFrame("video","timeout"),m._firstVideoFrameInterval&&window.clearInterval(m._firstVideoFrameInterval)}),this._timeout),this._watchForFirstVideoFrameRecv(),logger$9.print("rtcFirstFrameRecv",stringify$1(f)),null===(h=this._monitor)||void 0===h||h.report("rtc_first_frame",f),this._videoFirstFrameState=1,this._login=!0,this._unMuteVideo=!0,this._enableVideo=!0,this._remoteUnmuteVideo=!0);case 6:case"end":return e.stop()}}),e,this)}))),function(e,t){return i.apply(this,arguments)})},{key:"stopRecvFrame",value:function(e,t){if("audio"===e){var r,n,i,o,a;if(1!==this._audioFirstFrameState)return;var s={event_type:"recv_end",media_type:e,is_screen:!(null===(r=this._stream)||void 0===r||!r.isScreen),start:null===(n=this._currentAudioRecv)||void 0===n?void 0:n.startTime,reason:t,result:!1,stream_user_id:null===(i=this._stream)||void 0===i?void 0:i.userId,event_session_id:this._audioEventSessionId,type:null===(o=this._currentAudioRecv)||void 0===o?void 0:o.type};this._firstAudioFrameTimer&&window.clearTimeout(this._firstAudioFrameTimer),delete this._currentAudioRecv,logger$9.print("rtcFirstFrameRecv",stringify$1(s)),null===(a=this._monitor)||void 0===a||a.report("rtc_first_frame",s),this._audioFirstFrameState=2}else if("video"===e){var c,l,u,d,p;if(1!==this._videoFirstFrameState)return;var _={event_type:"recv_end",media_type:e,is_screen:!(null===(c=this._stream)||void 0===c||!c.isScreen),start:null===(l=this._currentVideoRecv)||void 0===l?void 0:l.startTime,reason:t,result:!1,stream_user_id:null===(u=this._stream)||void 0===u?void 0:u.userId,event_session_id:this._videoEventSessionId,type:null===(d=this._currentVideoRecv)||void 0===d?void 0:d.type};this._firstVideoFrameTimer&&window.clearTimeout(this._firstVideoFrameTimer),delete this._currentVideoRecv,logger$9.print("rtcFirstFrameRecv",stringify$1(_)),null===(p=this._monitor)||void 0===p||p.report("rtc_first_frame",_),this._videoFirstFrameState=2}}},{key:"recvFrameFinish",value:(n=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){var r,n,i,o,a,s,c,l,u,d,p,_,h,f,m,v,g;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,"audio"!==t){e.next=19;break}if(1===this._audioFirstFrameState){e.next=6;break}return e.abrupt("return");case 6:if(this._currentAudioRecv){e.next=8;break}return e.abrupt("return");case 8:s=this._currentAudioRecv,c=s.type,l=s.startTime,indexOf2(n=["login","unmute","subscribe","push_track"]).call(n,c)>=0&&(r=0),u={event_type:"recv_end",media_type:t,start:l,result:!0,is_screen:!(null===(i=this._stream)||void 0===i||!i.isScreen),stream_user_id:null===(o=this._stream)||void 0===o?void 0:o.userId,event_session_id:this._audioEventSessionId,type:c,transport_delay:r},delete this._currentAudioRecv,this._firstAudioFrameTimer&&window.clearTimeout(this._firstAudioFrameTimer),logger$9.print("rtcFirstFrameRecv",stringify$1(u)),null===(a=this._monitor)||void 0===a||a.report("rtc_first_frame",u),this.emit("recvAudioFirstFrame"),this._audioFirstFrameState=3,e.next=33;break;case 19:if("video"!==t){e.next=33;break}if(1===this._videoFirstFrameState){e.next=22;break}return e.abrupt("return");case 22:if(this._currentVideoRecv){e.next=24;break}return e.abrupt("return");case 24:f=this._currentVideoRecv,m=f.type,v=f.startTime,indexOf2(d=["login","unmute","subscribe","push_track"]).call(d,m)>=0&&(r=0),g={event_type:"recv_end",media_type:t,is_screen:!(null===(p=this._stream)||void 0===p||!p.isScreen),start:v,result:!0,stream_user_id:null===(_=this._stream)||void 0===_?void 0:_.userId,event_session_id:this._videoEventSessionId,type:m,transport_delay:r},delete this._currentVideoRecv,this._firstVideoFrameTimer&&window.clearTimeout(this._firstVideoFrameTimer),logger$9.print("rtcFirstFrameRecv",stringify$1(g)),null===(h=this._monitor)||void 0===h||h.report("rtc_first_frame",g),this.emit("recvVideoFirstFrame"),this._videoFirstFrameState=3;case 33: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("audio","login"),e&&null!==(r=this._stream)&&void 0!==r&&r.hasVideo&&o.video&&this.beginRecvFrame("video","login"),!e&&null!==(n=this._stream)&&void 0!==n&&n.hasAudio&&this.stopRecvFrame("audio","leave_room"),!e&&null!==(i=this._stream)&&void 0!==i&&i.hasVideo&&this.stopRecvFrame("video","leave_room"))}},{key:"setUnmuteAudio",value:function(e){var t,r,n;if(this._unMuteAudio!==e){this._unMuteAudio=e;var i=!(null===(t=this._stream)||void 0===t||!t.hasAudio);null!==(r=this._stream)&&void 0!==r&&r.audioHasCapture&&null!==(n=this._stream)&&void 0!==n&&n.audioHasPublish&&(this._unMuteAudio&&i?this.beginRecvFrame("audio","unmute"):i&&this.stopRecvFrame("audio","mute"))}}},{key:"setRemoteUnmuteAudio",value:function(e){this._remoteUnmuteAudio!==e&&(this._remoteUnmuteAudio=e,this._remoteUnmuteAudio?this.beginRecvFrame("audio","remote_unmute"):this.stopRecvFrame("audio","remote_mute"))}},{key:"setEnableAudio",value:function(e){var t;this._enableAudio!==e&&(this._enableAudio=e,this._enableAudio?this.beginRecvFrame("audio","enable"):null!==(t=this._stream)&&void 0!==t&&t.hasAudio&&this.stopRecvFrame("audio","disable"))}},{key:"setUnmuteVideo",value:function(e){var t,r,n;if(this._unMuteVideo!==e){this._unMuteVideo=e;var i=!(null===(t=this._stream)||void 0===t||!t.hasVideo);null!==(r=this._stream)&&void 0!==r&&r.videoHasCapture&&null!==(n=this._stream)&&void 0!==n&&n.videoHasPublish&&(this._unMuteVideo&&i?this.beginRecvFrame("video","unmute"):i&&this.stopRecvFrame("video","mute"))}}},{key:"setRemoteUnmuteVideo",value:function(e){this._remoteUnmuteVideo!==e&&(this._remoteUnmuteVideo=e,this._remoteUnmuteVideo?this.beginRecvFrame("video","remote_unmute"):this.stopRecvFrame("video","remote_mute"))}},{key:"setEnableVideo",value:function(e){this._enableVideo!==e&&(this._enableVideo=e,this._enableVideo?this.beginRecvFrame("video","enable"):this.stopRecvFrame("video","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("audio","push"),!e&&null!==(t=this._stream)&&void 0!==t&&t.hasAudio&&this.beginRecvFrame("audio","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("video","push"),!e&&null!==(t=this._stream)&&void 0!==t&&t.hasVideo&&this.beginRecvFrame("video","push")}},{key:"setPublishVideo",value:function(e){var t;this._publishVideo!==e&&(this._publishVideo=e),this._publishVideo&&this.beginRecvFrame("video","publish"),!e&&null!==(t=this._stream)&&void 0!==t&&t.hasVideo&&this.stopRecvFrame("video","unpublish")}},{key:"setPublishAudio",value:function(e){var t;this._publishAudio!==e&&(this._publishAudio=e),this._publishAudio&&this.beginRecvFrame("audio","publish"),!e&&null!==(t=this._stream)&&void 0!==t&&t.hasAudio&&this.stopRecvFrame("audio","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("audio","subscribe"));!e&&null!==(t=this._stream)&&void 0!==t&&t.hasAudio&&this.stopRecvFrame("audio","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("video","subscribe"));!e&&null!==(t=this._stream)&&void 0!==t&&t.hasVideo&&this.stopRecvFrame("video","unsubscribe")}},{key:"setPushTrack",value:function(e){var t;this._pushTrack!==e&&(e&&!this._isScreen&&this.beginRecvFrame("audio","push_track"),!e&&null!==(t=this._stream)&&void 0!==t&&t.hasAudio&&this.stopRecvFrame("audio","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.clearInterval(this._firstVideoFrameInterval),this._firstVideoFrameInterval=window.setInterval(_asyncToGenerator(_regeneratorRuntime().mark((function n(){var i,o,a,s,c,l,u,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===(l=c.videoTrack)||void 0===l?void 0:l.getTrack());case 3:if(u=n.sent,!(d=find$2(u).call(u,(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("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.clearInterval(this._firstAudioFrameInterval),this._firstAudioFrameInterval=window.setInterval(_asyncToGenerator(_regeneratorRuntime().mark((function n(){var i,o,a,s,c,l,u,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.getOrgTrack()){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===(l=c.audioTrack)||void 0===l?void 0:l.getOrgTrack());case 3:if(u=n.sent,!(d=find$2(u).call(u,(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("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=find$2(n).call(n,(function(e){return"transport"===e.type&&"connected"===e.dtlsState})),(o=find$2(n).call(n,(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:"login"},this._currentVideoRecv={startTime:0,eventSessionId:0,type:"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)}},{key:"audioFirstFrameReceived",get:function(){return 3===this._audioFirstFrameState}},{key:"FirstFrameReceived",get:function(){return 3===this._audioFirstFrameState}}]),a}(),logger$8=new Logger("SendFrameObserver",0),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:"login"}),_defineProperty(this,"_currentVideoSend",{startTime:0,eventSessionId:0,type:"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),_defineProperty(this,"_monitor",void 0),this._stream=t,this._handler=r,this._monitor=getMonitor(t.engineId)}var t,r;return _createClass(e,[{key:"beginSendFrame",value:function(e,t){var r=this;if("audio"===e){var n,i,o;this._audioEventSessionId++,this._currentAudioSend={startTime:Date.now(),eventSessionId:this._audioEventSessionId,type:t};var a={event_type:"begin_send",media_type:e,is_screen:!(null===(n=this._stream)||void 0===n||!n.isScreen),type:t,start:null===(i=this._currentAudioSend)||void 0===i?void 0:i.startTime,event_session_id:this._audioEventSessionId};this._firstAudioFrameTimer&&window.clearTimeout(this._firstAudioFrameTimer),this._firstAudioFrameTimer=window.setTimeout((function(){r.stopSendFrame("audio","timeout"),r._firstAudioFrameInterval&&window.clearInterval(r._firstAudioFrameInterval)}),this._timeout),logger$8.print("rtcFirstFrameSend",stringify$1(a)),null===(o=this._monitor)||void 0===o||o.report("rtc_first_frame",a),this._watchForFirstAudioFrameSend(),this._audioFirstFrameState=1,this._login=!0,this._publisher=!0,this._publish=!0,this._unMuteAudio=!0,this._pushAudio||(this._enableAudio=!0)}else if("video"===e){var s,c,l;this._videoEventSessionId++,this._currentVideoSend={startTime:Date.now(),eventSessionId:this._videoEventSessionId,type:t};var u={event_type:"begin_send",media_type:e,is_screen:!(null===(s=this._stream)||void 0===s||!s.isScreen),type:t,start:null===(c=this._currentVideoSend)||void 0===c?void 0:c.startTime,event_session_id:this._videoEventSessionId};this._firstVideoFrameTimer&&window.clearTimeout(this._firstVideoFrameTimer),this._firstVideoFrameTimer=window.setTimeout((function(){r.stopSendFrame("video","timeout"),r._firstVideoFrameInterval&&window.clearInterval(r._firstVideoFrameInterval)}),this._timeout),this._watchForFirstVideoFrameSend(),logger$8.print("rtcFirstFrameSend",stringify$1(u)),null===(l=this._monitor)||void 0===l||l.report("rtc_first_frame",u),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("audio"===e){var r,n,i,o;if(1!==this._audioFirstFrameState)return;var a={event_type:"sent_end",media_type:e,is_screen:!(null===(r=this._stream)||void 0===r||!r.isScreen),start:null===(n=this._currentAudioSend)||void 0===n?void 0:n.startTime,reason:t,result:!1,event_session_id:this._audioEventSessionId,type:null===(i=this._currentAudioSend)||void 0===i?void 0:i.type};this._firstAudioFrameTimer&&window.clearTimeout(this._firstAudioFrameTimer),delete this._currentAudioSend,logger$8.print("rtcFirstFrameSend",stringify$1(a)),null===(o=this._monitor)||void 0===o||o.report("rtc_first_frame",a),this._audioFirstFrameState=2}else if("video"===e){var s,c,l,u;if(1!==this._videoFirstFrameState)return;var d={event_type:"sent_end",media_type:e,start:null===(s=this._currentVideoSend)||void 0===s?void 0:s.startTime,is_screen:!(null===(c=this._stream)||void 0===c||!c.isScreen),reason:t,result:!1,event_session_id:this._videoEventSessionId,type:null===(l=this._currentVideoSend)||void 0===l?void 0:l.type};this._firstVideoFrameTimer&&window.clearTimeout(this._firstVideoFrameTimer),delete this._currentVideoSend,logger$8.print("rtcFirstFrameSend",stringify$1(d)),null===(u=this._monitor)||void 0===u||u.report("rtc_first_frame",d),this._videoFirstFrameState=2}}},{key:"sendFrameFinish",value:function(e){if("audio"===e){var t,r;if(1!==this._audioFirstFrameState)return;if(!this._currentAudioSend)return;var n=this._currentAudioSend,i=n.type,o=n.startTime,a={event_type:"sent_end",media_type:e,is_screen:!(null===(t=this._stream)||void 0===t||!t.isScreen),start:o,result:!0,event_session_id:this._audioEventSessionId,type:i};delete this._currentAudioSend,this._firstAudioFrameTimer&&window.clearTimeout(this._firstAudioFrameTimer),logger$8.print("rtcFirstFrameSend",stringify$1(a)),null===(r=this._monitor)||void 0===r||r.report("rtc_first_frame",a),this._audioFirstFrameState=3}else if("video"===e){var s,c;if(1!==this._videoFirstFrameState)return;if(!this._currentVideoSend)return;var l=this._currentVideoSend,u=l.type,d=l.startTime,p={event_type:"sent_end",media_type:e,is_screen:!(null===(s=this._stream)||void 0===s||!s.isScreen),start:d,result:!0,event_session_id:this._videoEventSessionId,type:u};delete this._currentVideoSend,this._firstVideoFrameTimer&&window.clearTimeout(this._firstVideoFrameTimer),logger$8.print("rtcFirstFrameSend",stringify$1(p)),null===(c=this._monitor)||void 0===c||c.report("rtc_first_frame",p),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("video","login"),null!==(r=this._stream)&&void 0!==r&&r.audioTrack&&this.beginSendFrame("audio","login");!e&&this._audioSending&&this.stopSendFrame("audio","leave_room"),!e&&this._videoSending&&this.stopSendFrame("video","leave_room")}}},{key:"setPublish",value:function(e){if(this._publish!==e){var t,r,n,i;if(this._publish=e,e)(null===(t=this._stream)||void 0===t?void 0:t.videoTrack)&&(null===(r=this._stream)||void 0===r?void 0:r.pubVideo)&&this.beginSendFrame("video","publish"),(null===(n=this._stream)||void 0===n?void 0:n.audioTrack)&&(null===(i=this._stream)||void 0===i?void 0:i.pubAudio)&&this.beginSendFrame("audio","publish");!e&&this._audioSending&&this.stopSendFrame("audio","unpublish"),!e&&this._videoSending&&this.stopSendFrame("video","unpublish")}}},{key:"setUnmuteAudio",value:function(e){var t;this._unMuteAudio!==e&&(this._unMuteAudio=e,null!==(t=this._stream)&&void 0!==t&&t.audioHasCapture&&(e&&this.beginSendFrame("audio","unmute"),!e&&this._audioSending&&this.stopSendFrame("audio","mute")))}},{key:"setEnableAudio",value:function(e){var t;this._enableAudio!==e&&null!==(t=this._stream)&&void 0!==t&&t.pubAudio&&(this._enableAudio=e,e&&this.beginSendFrame("audio","enable"),!e&&this._audioSending&&this.stopSendFrame("audio","disable"))}},{key:"setUnmuteVideo",value:function(e){var t;this._unMuteVideo!==e&&(this._unMuteVideo=e,null!==(t=this._stream)&&void 0!==t&&t.videoHasCapture&&(e&&this.beginSendFrame("video","unmute"),!e&&this._videoSending&&this.stopSendFrame("video","mute")))}},{key:"setEnableVideo",value:function(e){var t;this._enableVideo!==e&&null!==(t=this._stream)&&void 0!==t&&t.pubVideo&&(this._enableVideo=e,e&&this.beginSendFrame("video","enable"),!e&&this._videoSending&&this.stopSendFrame("video","disable"))}},{key:"setExternalAudioSource",value:function(e){this._audioExternal!==e&&(this._audioExternal=e,e&&(this._audioSending&&this.stopSendFrame("audio","disable"),this._enableAudio=!1),e||(this._audioSending&&this.stopSendFrame("audio","stop_push"),this._pushAudio=!1))}},{key:"setPushAudio",value:function(e){this._pushAudio!==e&&(this._pushAudio=e,e&&this.beginSendFrame("audio","push"),!e&&this._audioSending&&this.stopSendFrame("audio","stop_push"))}},{key:"setExternalVideoSource",value:function(e){this._videoExternal!==e&&(this._videoExternal=e,e&&(this._videoSending&&this.stopSendFrame("video","disable"),this._enableVideo=!1),e||(this._videoSending&&this.stopSendFrame("video","stop_push"),this._pushVideo=!1))}},{key:"setPushVideo",value:function(e){this._pushVideo!==e&&(this._pushVideo=e,e&&this.beginSendFrame("video","push"),!e&&this._videoSending&&this.stopSendFrame("video","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("audio","audience"),!e&&this._videoSending&&this.stopSendFrame("video","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("preprocessing")){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("preprocessing"));case 3:return s=e.sent,c=filter3(s).call(s,(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;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.getTrack("preprocessing")){e.next=5;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.getTrack("preprocessing"));case 3:return s=e.sent,e.abrupt("return",find$2(s).call(s,(function(e){return"outbound-rtp"===e.type})));case 5: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.clearInterval(this._firstVideoFrameInterval),this._firstVideoFrameInterval=window.setInterval(_asyncToGenerator(_regeneratorRuntime().mark((function n(){var i,o,a;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,o=0,a=0,null==i||map$6(i).call(i,(function(e){o+=e.framesSent,a+=e.packetsSent})),!(i&&i.length>0&&(o>t||a>r))){n.next=12;break}if(-1!==t||-1!==r){n.next=10;break}return t=o,r=a,n.abrupt("return");case 10:e.sendFrameFinish("video"),window.clearInterval(e._firstVideoFrameInterval);case 12:case"end":return n.stop()}}),n)}))),100)}},{key:"_watchForFirstAudioFrameSend",value:function(){var e=this,t=-1;this._firstAudioFrameInterval&&window.clearInterval(this._firstAudioFrameInterval),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("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:"login"},this._currentVideoSend={startTime:0,eventSessionId:0,type:"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 map2),_defineProperty(this,"_preDownlinkStats",new map2),_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,o,a=n?"screen_audio":"audio",s=t.rtt,c=t._fractionLost,l=t._retransmittedRate,u=this._getQosLevel(s,c||0,l||0),d=this._preUplinkStats.get(a)||[u];this._preUplinkStats.set(a,slice$1(i=concat$2(o=[]).call(o,_toConsumableArray(d),[u])).call(i,-2))}if(r.sentKBitrate>0&&r.rtt){var p,_,h=n?"screen_video":"video",f=r._fractionLost,m=r.rtt,v=r._sendBandWidth,g=r._retransmittedRate;0===v&&(f=Math.max(.65,f));var y=this._getQosLevel(m,f||0,g||0),S=this._preUplinkStats.get(h)||[y];this._preUplinkStats.set(h,slice$1(p=concat$2(_=[]).call(_,_toConsumableArray(S),[y])).call(p,-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,l=e.isScreen,u=e.userId;if(o)if(0===s.receivedKBitrate)r=NetworkQuality.VBAD;else{var d=s.rtt,p=s.audioLossRate,_=s.stallDuration,h=s.statsInterval,f=s.e2eDelay,m=_/h,v=l?"screen_audio":"audio",g=this._getQosLevel(d,p||0,c._retransmittedRate||0),y=this._getDownlinkQoE(v,m,f);r=this._getNetworkQuality(g,y)}if(a)if(0===c.receivedKBitrate||0===c.rtt)n=NetworkQuality.VBAD;else{var S=c.rtt,T=c.videoLossRate,$=c.stallDuration,E=c.statsInterval,b=c.e2eDelay,I=c._retransmittedRate,R=$/E,C=l?"screen_video":"video",A=this._getQosLevel(S,T||0,I||0),k=this._getDownlinkQoE(C,R,b);n=this._getNetworkQuality(A,k)}var P=r&&n?Math.ceil((r+n)/2):r||n;if(P){var O,w,M,D=concat$2(O="".concat(u)).call(O,l?"_screen":""),x=this._preDownlinkStats.get(D)||[P];this._preDownlinkStats.set(D,slice$1(w=concat$2(M=[]).call(M,_toConsumableArray(x),[P])).call(w,-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,i,o,a=this._getBetterQualityAndRemoveOldest("audio","up"),s=this._getBetterQualityAndRemoveOldest("video","up");e=a&&s?Math.ceil((a+s)/2):a||s||this._getBetterQualityAndRemoveOldest("screen_video","up")||this._getBetterQualityAndRemoveOldest("screen_audio","up")||NetworkQuality.EXCELLENT;var c=filter3(n=map$6(i=from$2(keys$1(o=this._preDownlinkStats).call(o))).call(i,(function(e){return r._getBetterQualityAndRemoveOldest(e,"down")}))).call(n,(function(e){return e}));t=Math.ceil(reduce3(c).call(c,(function(e,t){return t+e}),0)/c.length)||NetworkQuality.UNKNOWN}"function"==typeof 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||e<=250)&&t<=.15?1:(!e||e<=500)&&t<=.3?2:(!e||e<=750)&&t<=.45?3:(!e||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=filter3(i).call(i,(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]||{},l=c.width,u=void 0===l?0:l,d=c.height,p=void 0===d?0:d,_=a.getSettings(),h=_.width,f=void 0===h?0:h,m=_.height,v=void 0===m?0:m;p===v&&u===f||"function"==typeof e.onchange&&e.onchange(i,n.isScreen,f,v),delete s[i],(n.isScreen?r:t)[i]={width:f,height:v}}}))})),keys$8(e._remoteVideoSizeCache).forEach((function(t){"function"==typeof e.onchange&&e.onchange(t,!1,0,0)})),keys$8(e._remoteScreenSizeCache).forEach((function(t){"function"==typeof e.onchange&&e.onchange(t,!0,0,0)})),e._remoteVideoSizeCache=t,e._remoteScreenSizeCache=r}),1e3))}}]),e}(),SUBTITLE_PREFIX=from$2((new TextEncoder).encode("subt")),ERROR_CODE_MAP={1:ErrorCode.SUBTITLE_ERR_POSTPROCESS,2:ErrorCode.SUBTITLE_ERR_CONNECTION_ERROR,3:ErrorCode.SUBTITLE_ERR_PROCESS_ERROR},logger$7=new Logger("SubtitleTool",1),checkSourceLanguage=function(e){if(e.extraInfo)try{var t,r=JSON.parse(e.extraInfo);r.source_language&&indexOf2(t=["zh","en","ja"]).call(t,r.source_language)}catch(e){}else{var n,i,o=(null===(n=navigator.language)||void 0===n?void 0:n.substring(0,2))||"";indexOf2(i=["zh","en","ja"]).call(i,o)>-1&&(e.extraInfo=stringify$1({source_language:o}))}},SubtitleTool=function(){function e(t){var r,n,i;_classCallCheck(this,e),_defineProperty(this,"_taskId",void 0),_defineProperty(this,"_appId",void 0),_defineProperty(this,"_roomId",void 0),_defineProperty(this,"_userId",void 0),_defineProperty(this,"onEvent",void 0),_defineProperty(this,"onMessage",void 0),_defineProperty(this,"_preConfig",void 0),_defineProperty(this,"_timer",void 0),this._room=t,this._appId=null===(r=this._room._roomInfo)||void 0===r?void 0:r.appId,this._roomId=null===(n=this._room._roomInfo)||void 0===n?void 0:n.roomId,this._userId=null===(i=this._room._roomInfo)||void 0===i?void 0:i.userInfo.userId}var t,r,n;return _createClass(e,[{key:"start",value:(n=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){var r=this;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(logger$7.print("start","Invoke config: %o",t),checkEnum(t.mode,"mode",[SUBTITLE_MODE.ASR_ONLY,SUBTITLE_MODE.ASR_AND_TRANSLATION]),t.mode!==SUBTITLE_MODE.ASR_AND_TRANSLATION||-1!==indexOf2(SUPPORT_LANG).call(SUPPORT_LANG,t.targetLanguage||"")){e.next=4;break}throw new SDKError(ErrorCode.INVALID_PARAMS,"Invalid targetLanguage.");case 4:if(!this._taskId){e.next=6;break}throw new SDKError(ErrorCode.SUBTITLE_ALREADY_ON,"Already turned on subtitle");case 6:return this._preConfig=t,this._taskId=(Date.now().toString()+this._roomId+this._userId).substring(0,20),e.next=10,this._room.subtitleControlMessage(this._genSubtitleSignaling("started",t,this._taskId));case 10:this._preConfig=t,this._timer=self.setTimeout((function(){var e;null===(e=r.onEvent)||void 0===e||e.call(r,{event:SubtitleEventType.ERROR,errorCode:ErrorCode.TIME_OUT,errorMessage:"start subtitle timeout."}),delete r._timer,r.stop()}),3e4);case 12:case"end":return e.stop()}}),e,this)}))),function(e){return n.apply(this,arguments)})},{key:"update",value:(r=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){var r;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(checkEnum(t.mode,"mode",[SUBTITLE_MODE.ASR_ONLY,SUBTITLE_MODE.ASR_AND_TRANSLATION]),t.mode!==SUBTITLE_MODE.ASR_AND_TRANSLATION||-1!==indexOf2(SUPPORT_LANG).call(SUPPORT_LANG,t.targetLanguage||"")){e.next=3;break}throw new SDKError(ErrorCode.INVALID_PARAMS,"Invalid targetLanguage.");case 3:if(!this._taskId){e.next=5;break}throw new SDKError(ErrorCode.SUBTITLE_ALREADY_ON,"Already started subtitle");case 5:if(this._taskId){e.next=7;break}throw new SDKError(ErrorCode.SUBTITLE_NOT_TURNED_ON,"Start subtitle first.");case 7:if((null===(r=this._preConfig)||void 0===r?void 0:r.mode)===t.mode&&this._preConfig.targetLanguage===t.targetLanguage){e.next=11;break}return this._preConfig=t,e.next=11,this._room.subtitleControlMessage(this._genSubtitleSignaling("update",t,this._taskId));case 11:case"end":return e.stop()}}),e,this)}))),function(e){return r.apply(this,arguments)})},{key:"stop",value:function(){var e=this;logger$7.print("stop","Invoke"),this._taskId&&this._room.subtitleControlMessage({type:"subtitle",action:"stopped",appId:this._appId,roomId:this._roomId,userId:this._userId,taskId:this._taskId}).finally((function(){var t;delete e._taskId,null===(t=e.onEvent)||void 0===t||t.call(e,{event:SubtitleEventType.STOPPED}),e._clearTimer()}))}},{key:"reconnect",value:(t=_asyncToGenerator(_regeneratorRuntime().mark((function e(){return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._taskId||!this._preConfig){e.next=5;break}return e.next=3,this._room.subtitleControlMessage({type:"subtitle",action:"stopped",appId:this._appId,roomId:this._roomId,userId:this._userId,taskId:this._taskId});case 3:delete this._taskId,this.start(this._preConfig);case 5:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})},{key:"getConfig",value:function(){return this._preConfig}},{key:"destroy",value:function(){logger$7.print("destroy","Invoke"),this.stop(),delete this._preConfig,delete this._taskId}},{key:"onResult",value:function(e){var t=e.body,r=t.error,n=t.errorMessage,i=t.eventType;if(0!==r){var o,a=new SDKError(ERROR_CODE_MAP[r]||ErrorCode.SUBTITLE_ERR_UNKNOWN,n||"");null===(o=this.onEvent)||void 0===o||o.call(this,{event:SubtitleEventType.ERROR,errorCode:a.code,errorMessage:a.message}),this._clearTimer()}else if("SubtitleStarted"===i){var s;null===(s=this.onEvent)||void 0===s||s.call(this,{event:SubtitleEventType.STARTED}),this._clearTimer()}}},{key:"onMessageRecv",value:function(e){if(this._taskId&&this._preConfig){var t=parseSubtitleMessage(e);if(t&&t.length>0){var r,n=this._preConfig,i=n.mode,o=n.targetLanguage,a=[];if(t.forEach((function(e){i===SUBTITLE_MODE.ASR_ONLY?e.mode===i&&a.push(e):i===SUBTITLE_MODE.ASR_AND_TRANSLATION&&(e.language!==o&&e.mode!==SUBTITLE_MODE.ASR_ONLY||a.push(e),e.mode===SUBTITLE_MODE.ASR_ONLY&&e.language===o&&a.push(_objectSpread2(_objectSpread2({},e),{},{mode:SUBTITLE_MODE.ASR_AND_TRANSLATION})))})),a.length>0)null===(r=this.onMessage)||void 0===r||r.call(this,a)}return!!t}return!1}},{key:"_genSubtitleSignaling",value:function(e,t,r){return{taskId:r,type:"subtitle",action:e,roomId:this._roomId,appId:this._appId,userId:this._userId,subtitleMeta:{subtitleConfig:{mode:t.mode,usersConfig:[{userId:this._userId,targetLanguages:[t.targetLanguage||""]}]},vendorConfig:{type:0}}}}},{key:"_clearTimer",value:function(){this._timer&&(self.clearTimeout(this._timer),delete this._timer)}}]),e}(),parseSubtitleMessage=function(e){var t=e.message;if(t instanceof ArrayBuffer&&t.byteLength>8)try{var r=new DataView(t,0),n=0;if(SUBTITLE_PREFIX.every((function(e){return r.getUint8(n++)===e}))){var i=r.getUint32(n);if(n+=4,i===r.byteLength-8){var o=Utils.ab2str(slice$1(t).call(t,8)),a=JSON.parse(o),s=a.data;if("subtitle"===a.type)return s}}}catch(e){}return!1},SUPPORT_LANG=["zh","zh-Hant","tn","vi","iu","it","id","hi","en","ho","he","es","el","uk","ur","tk","tr","ti","ty","tl","to","th","ta","te","sl","sk","ss","eo","sm","sg","st","sv","ja","tw","qu","pt","pa","no","nb","nr","my","bn","mn","mh","mk","ml","mr","ms","lu","ro","lt","lv","lo","kj","hr","kn","ki","cs","ca","nl","ko","ht","gu","ka","kl","km","lg","kg","fi","fj","fr","ru","ng","de","tt","da","ts","cv","fa","bs","pl","bi","nd","ba","bg","az","ar","af","sq","ab","os","ee","et","ay","lzh","am","ckb","cy","gl","ha","hy","ig","kmr","ln","nso","ny","om","sn","so","sr","sw","xh","yo","zu"],logger$6=new Logger("Room",1),virtualStreamAttributes={audiostream:!0,extaudio:!1,extvideo:!1,localaudio:!0,localvideo:!1,videoDescriptions:[],videostream:!1,publishTime:0},Room=function(e){_inherits(R,EnhancedEventEmitter);var t,r,n,i,o,a,s,c,l,u,d,p,_,h,f,m,v,g,y,S,T,$,E,b,I=_createSuper(R);function R(e,t){var r;return _classCallCheck(this,R),_defineProperty(_assertThisInitialized(r=I.call(this)),"id",void 0),_defineProperty(_assertThisInitialized(r),"_mediaServerClient",void 0),_defineProperty(_assertThisInitialized(r),"_localStream",void 0),_defineProperty(_assertThisInitialized(r),"_localScreenStream",void 0),_defineProperty(_assertThisInitialized(r),"_remoteUsers",new map2),_defineProperty(_assertThisInitialized(r),"_remoteStreams",new map2),_defineProperty(_assertThisInitialized(r),"_remoteStreamStreamIdUserIdMap",{}),_defineProperty(_assertThisInitialized(r),"_virtualStreams",[]),_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),"_liveTranscodingOnceSucc",!1),_defineProperty(_assertThisInitialized(r),"_roomConfig",void 0),_defineProperty(_assertThisInitialized(r),"_roomInfo",void 0),_defineProperty(_assertThisInitialized(r),"_userDuplicateLoginTimerMap",new map2),_defineProperty(_assertThisInitialized(r),"_networkQualityManager",void 0),_defineProperty(_assertThisInitialized(r),"_videoSizeObserver",void 0),_defineProperty(_assertThisInitialized(r),"_hasPublished",!1),_defineProperty(_assertThisInitialized(r),"_subtitleTool",void 0),_defineProperty(_assertThisInitialized(r),"_csrcUserIdMap",void 0),_defineProperty(_assertThisInitialized(r),"_publishOnDemandItem",void 0),_defineProperty(_assertThisInitialized(r),"_publishOnDemandBusy",!1),_defineProperty(_assertThisInitialized(r),"_monitor",void 0),r.id=t.id,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._context=t,r._csrcUserIdMap={},r._monitor=getMonitor(r.id),r}return _createClass(R,[{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:"roomConfig",set:function(e){this._roomConfig=e}},{key:"_addHandlerEventHandler",value:function(){var e,t,r,n,i,o,a,s,c,l,u,d,p,_,h,f,m,v,g,y,S,T,$,E,b,I,R,C,A,k,P=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_ADD_STREAM_LIST,(function(e){Array.isArray(null==e?void 0:e.streamList)&&e.streamList.forEach((function(e){return P._onAddStream(e)}))})),null===(r=this._mediaServerClient)||void 0===r||r.on(SignalEvent.ON_REMOVE_STREAM,this._onRemoveStream.bind(this)),null===(n=this._mediaServerClient)||void 0===n||n.on(SignalEvent.ON_REMOVE_STREAM_LIST,(function(e){Array.isArray(null==e?void 0:e.streamList)&&e.streamList.forEach((function(e){return P._onRemoveStream(e)}))})),null===(i=this._mediaServerClient)||void 0===i||i.on(SignalEvent.USER_CONNECTION,this._onUserConnection.bind(this)),null===(o=this._mediaServerClient)||void 0===o||o.on(SignalEvent.USER_CONNECTION_LIST,(function(e){Array.isArray(null==e?void 0:e.userList)&&e.userList.forEach((function(e){return P._onUserConnection(e)}))})),null===(a=this._mediaServerClient)||void 0===a||a.on(SignalEvent.USER_DISCONNECTION,this._onUserDisconnection.bind(this)),null===(s=this._mediaServerClient)||void 0===s||s.on(SignalEvent.USER_DISCONNECTION_LIST,(function(e){Array.isArray(null==e?void 0:e.userList)&&e.userList.forEach((function(e){return P._onUserDisconnection(e)}))})),null===(c=this._mediaServerClient)||void 0===c||c.on(SignalEvent.ON_UPDATE_ROOM_ATTRIBUTES,this._onUpdateRoomAttributes.bind(this)),null===(l=this._mediaServerClient)||void 0===l||l.on(SignalEvent.ON_UPDATE_USER_ATTRIBUTES,this._onUpdateUserAttributes.bind(this)),null===(u=this._mediaServerClient)||void 0===u||u.on(SignalEvent.ON_UPDATE_STREAM_ATTRIBUTES,this._onUpdateStreamAttributes.bind(this)),null===(d=this._mediaServerClient)||void 0===d||d.on(SignalEvent.ON_PUSH_TRACK,this._onPushTrack.bind(this)),null===(p=this._mediaServerClient)||void 0===p||p.on(SignalEvent.ON_REMOVE_TRACK,this._onRemoveTrack.bind(this)),null===(_=this._mediaServerClient)||void 0===_||_.on(SignalEvent.NODE_CHANGE,this._nodeChange.bind(this)),null===(h=this._mediaServerClient)||void 0===h||h.on(SignalEvent.ON_CUSTOM_MESSAGE,this._onCustomMessage.bind(this)),null===(f=this._mediaServerClient)||void 0===f||f.on(SignalEvent.USER_MESSAGE_RECEIVED,this._onUserMessageReceived.bind(this)),null===(m=this._mediaServerClient)||void 0===m||m.on(SignalEvent.USER_BINARY_MESSAGE_RECEIVED,this._onUserBinaryMessageReceived.bind(this)),null===(v=this._mediaServerClient)||void 0===v||v.on(SignalEvent.POST_PROCESSING_MESSAGE,this._onPostProcessingMessage.bind(this)),null===(g=this._mediaServerClient)||void 0===g||g.on(SignalEvent.ON_USER_TOKEN_WILL_EXPIRE,this._onUserTokenWillExpire.bind(this)),null===(y=this._mediaServerClient)||void 0===y||y.on(SignalEvent.STREAM_CONTROL_MESSAGE,this._onStreamControlMessage.bind(this)),null===(S=this._mediaServerClient)||void 0===S||S.on(SignalEvent.ON_STREAM_FAILED,this._onStreamFailed.bind(this)),null===(T=this._mediaServerClient)||void 0===T||T.on(MediaServerSignalEvent.RSCP,(function(e){!!find$2(e).call(e,(function(e){var t,r,n;return null==e||null===(t=e.StreamIds)||void 0===t?void 0:includes4(t).call(t,null===(r=P._localStream)||void 0===r||null===(n=r.stream)||void 0===n?void 0:n.id)}))&&(P._publishOnDemandItem=e,P._onPublishOnDemand())})),null===($=this._mediaServerClient)||void 0===$||$.on(MediaServerSignalEvent.RTT,this._onRTT.bind(this)),null===(E=this._mediaServerClient)||void 0===E||E.on(MediaServerSignalEvent.SSC,this._onSSC.bind(this)),null===(b=this._mediaServerClient)||void 0===b||b.on(StateEvent.ON_CONNECTION_STATE_CHANGE,this._onConnectionStateChange.bind(this)),null===(I=this._mediaServerClient)||void 0===I||I.on(StateEvent.ABNORMAL_DISCONNECTION,this._handleAbnormalDisconnection.bind(this)),null===(R=this._mediaServerClient)||void 0===R||R.on(SignalEvent.ON_SPEAKER_CHANGE,this._onMeetingSpeakerChange.bind(this)),null===(C=this._mediaServerClient)||void 0===C||C.on("onRemoteStreamStats",(function(e){P._networkQualityManager.updateDownlinkStats(e,P._findRemoteStreamByScreen(e.userId,e.isScreen)),P.emit(RoomEvent.ON_REMOTE_STREAM_STATS,getPublicStats(e))})),null===(A=this._mediaServerClient)||void 0===A||A.on("onLocalStreamStats",(function(e){P._networkQualityManager.updateUplinkStats(e),P.emit(RoomEvent.ON_LOCAL_STREAM_STATS,getPublicStats(e))})),null===(k=this._mediaServerClient)||void 0===k||k.on("prevIceNode",(function(e){P._getAccessFeedbackIceNode=e}))}},{key:"_removeHandlerEventHandler",value:function(){var e;null===(e=this._mediaServerClient)||void 0===e||e.removeAllListeners()}},{key:"connect",value:(b=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._mediaServerClient.connect(t);case 2:case"end":return e.stop()}}),e,this)}))),function(e){return b.apply(this,arguments)})},{key:"join",value:(E=_asyncToGenerator(_regeneratorRuntime().mark((function e(t,r,n,i,o,a,s){var c,l=this;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return null===(c=this._monitor)||void 0===c||c.set({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,d,p,_=getServerNow();l._joinResolveCallback=function(t){var r,n;null===(r=l._monitor)||void 0===r||r.report("join_room",{type:"end",start:_,result:!0,reason:""},{enable_cloud_proxy:null===(n=l._roomInfo)||void 0===n?void 0:n.useCloudProxy}),l._initSubtitleTool(),e(t)},l._joinRejectCallback=function(e){var t,r;Array.isArray(e)&&e.length&&(e=e[0]),null===(t=l._monitor)||void 0===t||t.report("join_room",{type:"end",start:_,result:!1,reason:e.message},{enable_cloud_proxy:null===(r=l._roomInfo)||void 0===r?void 0:r.useCloudProxy}),c(e)},l._liveControlMessage=o,l._roomInfo={appId:t,roomId:r,token:n,userInfo:i,useCloudProxy:a,roomProfile:l._roomConfig.roomProfileType,expectedIDC:s},l.setSessionId(),null===(u=l._monitor)||void 0===u||u.report("join_room",{type:"begin",start:_,result:!1,reason:""},{enable_cloud_proxy:null===(d=l._roomInfo)||void 0===d?void 0:d.useCloudProxy,expectedIDC:null===(p=l._roomInfo)||void 0===p?void 0:p.expectedIDC}),l._join(l._joinResolveCallback,l._joinRejectCallback,!1)})));case 3:case"end":return e.stop()}}),e,this)}))),function(e,t,r,n,i,o,a){return E.apply(this,arguments)})},{key:"_join",value:($=_asyncToGenerator(_regeneratorRuntime().mark((function e(t,r){var n,i,o,a,s,c,l,u,d=arguments;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=d.length>2&&void 0!==d[2]&&d[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:u=e.sent,this._mediaServerClient.roomAttributes=u.roomAttributes,null!==(o=u.roomAttributes)&&void 0!==o&&o.multiChatMode&&this._handleFFAudioTrack(),this._reconnectRecord.clear(),this._joinResolveCallback=void 0,this._joinRejectCallback=void 0,this._getAccessFeedback=void 0,this._getAccessNode=void 0,"function"==typeof t&&t({users:u.clients,streams:u.streams}),this._isReconnecting=!1,null===(a=this._monitor)||void 0===a||a.set({rtc_vid:(null===(s=this._getAccessFeedbackIceNode)||void 0===s||null===(c=s.iceConfig)||void 0===c?void 0:c._abtest_vid)||""}),null===(l=this._monitor)||void 0===l||l.report("rtc_join_room",{error_code:0,deviceModel:"web",deviceManufacturer:"web",elapse:getServerNow()-i}),this._onJoinSucc(u,n),e.next=27;break;case 21:if(e.prev=21,e.t0=e.catch(3),this._getAccessFeedback=void 0,this._getAccessNode=void 0,e.t0.code===ErrorCode.OPERATION_CANCEL||"function"!=typeof r){e.next=27;break}return e.abrupt("return",r(e.t0));case 27:case"end":return e.stop()}}),e,this,[[3,21]])}))),function(e,t){return $.apply(this,arguments)})},{key:"publishScreen",value:(T=_asyncToGenerator(_regeneratorRuntime().mark((function e(t,r,n,i,o){var a,s,c,l,u,d,p,_,h,f;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.id),this._localScreenStream.isScreen=!0,this._mediaServerClient.handler&&(this._localScreenStream.observer=new SendFrameObserver(this._localScreenStream,this._mediaServerClient.handler))),a=!1,s=!1,c=!1,l=!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&&(l=!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===(u=this._localScreenStream)||void 0===u||!u.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),l?null===(h=this._localScreenStream.observer)||void 0===h||h.setPushAudio(c):null===(f=this._localScreenStream.observer)||void 0===f||f.setEnableAudio(c),e.next=28,this.updatePubScreenTrack();case 28:case"end":return e.stop()}}),e,this)}))),function(e,t,r,n,i){return T.apply(this,arguments)})},{key:"updatePubScreenTrack",value:(S=_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 S.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:(g=_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,this._liveTranscodingOnceSucc=!1),this._liveTranscodingOnceSucc=!0;case 7:case"end":return e.stop()}}),e,this)}))),function(e){return g.apply(this,arguments)})},{key:"publicStreamControlMessage",value:(v=_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 v.apply(this,arguments)})},{key:"subtitleControlMessage",value:(m=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._mediaServerClient.controlMessage(t);case 2:case"end":return e.stop()}}),e,this)}))),function(e){return m.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:(h=_asyncToGenerator(_regeneratorRuntime().mark((function e(t,r,n,i,o,a){var s,c,l,u,d,p,_,h,f,m,v,g,y=arguments;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(s=y.length>6&&void 0!==y[6]&&y[6],logger$6.print("publish","Invoke publish"),c=!1,this._localStream||(this._localStream=new LocalStream(this.id),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===(l=this._localStream.observer)||void 0===l||l.setLogin(!0):c&&(u=!!this._localStream.videoTrack,d=!!this._localStream.audioTrack,p=this._localStream.videoTrack instanceof CustomVideoLocalTrack,_=this._localStream.audioTrack instanceof CustomAudioLocalTrack,this._roomConfig.isAutoPublish&&!this._hasPublished?(u&&(p?null===(h=this._localStream.observer)||void 0===h||h.setPushVideo(!0):null===(f=this._localStream.observer)||void 0===f||f.setEnableVideo(!0)),d&&(_?null===(m=this._localStream.observer)||void 0===m||m.setPushAudio(!0):null===(v=this._localStream.observer)||void 0===v||v.setEnableAudio(!0))):null===(g=this._localStream.observer)||void 0===g||g.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 h.apply(this,arguments)})},{key:"updatePubTrack",value:(_=_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 _.apply(this,arguments)})},{key:"unpublish",value:(p=_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 p.apply(this,arguments)})},{key:"subscribe",value:(d=_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 d.apply(this,arguments)})},{key:"updateSubTrack",value:(u=_asyncToGenerator(_regeneratorRuntime().mark((function e(t,r,n,i){var o,a;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(logger$6.print("updateSubTrack","Invoke updateSubTrack"),!i){e.next=4;break}return e.next=4,null===(a=this._mediaServerClient)||void 0===a?void 0:a.updateSubTrackLayer(t,i);case 4:return e.abrupt("return",null===(o=this._mediaServerClient)||void 0===o?void 0:o.updateSubTrack(t,r,n));case 5:case"end":return e.stop()}}),e,this)}))),function(e,t,r,n){return u.apply(this,arguments)})},{key:"updateSubVideoConfig",value:(l=_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.updateSubTrackLayer(a,s));case 6:case"end":return e.stop()}}),e,this)}))),function(e,t){return l.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,l=s.subVideoDescriptions,u=Array.isArray(l)?l:c,d=-1,p=e.width*e.height,_=0;_<(null==u?void 0:u.length);_++){var h,f;if(p>=(null===(h=u[_])||void 0===h?void 0:h.width)*(null===(f=u[_])||void 0===f?void 0:f.height)){d=_;break}}var m=u[0];if(-1===d)m=u[d=u.length-1];else if(0!==d){var v=u[d-1].width*u[d-1].height,g=(v-p)/(v-u[d].width*u[d].height);m=g<.1?u[d-1]:u[d],d=g<.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:(c=_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 c.apply(this,arguments)})},{key:"startSubtitle",value:(s=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._subtitleTool){e.next=5;break}return e.next=3,this._subtitleTool.start(t);case 3:e.next=6;break;case 5:throw new SDKError(ErrorCode.INVOKED_BEFORE_JOIN_ROOM,"join first");case 6:case"end":return e.stop()}}),e,this)}))),function(e){return s.apply(this,arguments)})},{key:"stopSubtitle",value:(a=_asyncToGenerator(_regeneratorRuntime().mark((function e(){var t;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:null===(t=this._subtitleTool)||void 0===t||t.stop();case 1:case"end":return e.stop()}}),e,this)}))),function(){return a.apply(this,arguments)})},{key:"leave",value:(o=_asyncToGenerator(_regeneratorRuntime().mark((function e(){var t,r,n,i,o,a,s,c,l,u,d,p=arguments;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:r=p.length>0&&void 0!==p[0]&&p[0],logger$6.print("leave","Invoke leave"),n=getServerNow(),null===(t=this._subtitleTool)||void 0===t||t.destroy(),delete this._subtitleTool,e.prev=5,this._mediaServerClient.connectionState!==MediaConnectionState.CONNECTED&&this._joinRejectCallback&&this._joinRejectCallback(new Error("leave_room")),clearTimeout(this._reconnectTimer),s=_createForOfIteratorHelper(values$1(a=this._remoteStreams).call(a));try{for(s.s();!(c=s.n()).done;)l=c.value,Array.isArray(l)&&l.forEach((function(e){var t;null===(t=e.observer)||void 0===t||t.setLogin(!1)}))}catch(e){s.e(e)}finally{s.f()}return this._localStream&&(null===(u=this._localStream.observer)||void 0===u||u.setLogin(!1)),e.next=13,this._mediaServerClient.leave();case 13:this.destroy(),null===(i=this._monitor)||void 0===i||i.report("rtc_leave_room",{error_code:0,message:"",elapse:getServerNow()-n}),null===(o=this._monitor)||void 0===o||o.set({room_id:"",user_id:"",rtc_session_id:"",rtc_vid:""}),e.next=26;break;case 18:if(e.prev=18,e.t0=e.catch(5),!r){e.next=24;break}throw e.t0;case 24:this.destroy();case 25:e.t0 instanceof Error&&(null===(d=this._monitor)||void 0===d||d.report("rtc_leave_room",{error_code:-1,message:e.t0.message,elapse:getServerNow()-n}));case 26:case"end":return e.stop()}}),e,this,[[5,18]])}))),function(){return o.apply(this,arguments)})},{key:"updateRemoteUserPriority",value:function(e){var t,r=this;null===(t=this.remoteStreams.get(e))||void 0===t||t.forEach((function(t){var n=(r._context||{}).userPriority;t.hasSubscribed&&null!=n&&n.has(e)&&r._mediaServerClient.updateSubPriority(t,n.get(e))}))}},{key:"destroy",value:function(){var e;logger$6.print("destroy","Invoke destroy"),reportRtcInvokeStatus(this.id,"room_destroy","".concat((new Error).stack)),null===(e=this._subtitleTool)||void 0===e||e.destroy(),delete this._subtitleTool,this._destroyAndInitMediaServerClient(),this._roomInfo=void 0,this._remoteUsers=new map2;var t,r,n,i=_createForOfIteratorHelper(this._remoteStreams);try{for(i.s();!(t=i.n()).done;){var o=_slicedToArray(t.value,2)[1];Array.isArray(o)&&o.forEach((function(e){e&&e.clean()}))}}catch(e){i.e(e)}finally{i.f()}(this._virtualStreams.forEach((function(e){null==e||e.clean()})),this._remoteStreams=new map2,this._localStream)&&(null===(r=this._localStream)||void 0===r||r.clean(),this._localStream=void 0);this._localScreenStream&&(null===(n=this._localScreenStream)||void 0===n||n.clean(),this._localScreenStream=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._csrcUserIdMap={},this._virtualStreams=[],this._remoteStreamStreamIdUserIdMap={}}},{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.prev=2,e.next=5,this._mediaServerClient.updateToken(t);case 5:e.next=11;break;case 7:throw e.prev=7,e.t0=e.catch(2),this.safeEmit(RoomEvent.ON_ROOM_ERROR,{errorCode:ErrorCode.UPDATE_TOKEN_WITH_INVALID_TOKEN}),e.t0;case 11:case"end":return e.stop()}}),e,this,[[2,7]])}))),function(e){return i.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(){var e;this._sessionId=v4(),null===(e=this._monitor)||void 0===e||e.set({rtc_session_id:this._sessionId})}},{key:"sendRoomMessage",value:(n=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){var r,n,i,o,a,s=arguments;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(o=s.length>1&&void 0!==s[1]&&s[1],a={clientId:null===(r=this._roomInfo)||void 0===r?void 0:r.userInfo.userId,binary:o,message:"",roomId:null===(n=this._roomInfo)||void 0===n?void 0:n.roomId},!o){e.next=8;break}return e.next=5,Utils.ab2b64str(t);case 5:a.message=e.sent,e.next=9;break;case 8:a.message=t;case 9:return e.abrupt("return",null===(i=this._mediaServerClient)||void 0===i?void 0:i.sendRoomMessage(a));case 10:case"end":return e.stop()}}),e,this)}))),function(e){return n.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,i,o=this;logger$6.print("JoinSuccess()"),this._serverConfig=e.config;var a=[],s=[],c=[],l=[],u=[];null===(r=e.clientsDetail)||void 0===r||r.forEach((function(t){if(t.attributes&&(t.attributes.serverMuteVideo&&o.safeEmit(RoomEvent.ON_VIDEO_STREAM_BANNED,{uid:t.clientId,banned:1===t.attributes.serverMuteVideo}),t.attributes.serverMuteAudio&&o.safeEmit(RoomEvent.ON_AUDIO_STREAM_BANNED,{uid:t.clientId,banned:1===t.attributes.serverMuteAudio})),t.clientId!==e.clientId){var r=o._remoteUsers.get(t.clientId);r?r._stillExist=!0:a.push(t)}}));var d,p=_createForOfIteratorHelper(values$1(n=this._remoteUsers).call(n));try{for(p.s();!(d=p.n()).done;){var _=d.value;_._stillExist||s.push({clientId:_.userId}),delete _._stillExist}}catch(e){p.e(e)}finally{p.f()}e.streams.forEach((function(e){var t=o._findRemoteStreamByScreen(e.clientId,e.screen);t?(t.stillExist=!0,t.streamId=e.streamId,u.push(e)):l.push(e)}));var h,f=_createForOfIteratorHelper(values$1(i=this._remoteStreams).call(i));try{for(f.s();!(h=f.n()).done;){var m=h.value;Array.isArray(m)&&m.forEach((function(e){e.stillExist?delete e.stillExist:c.push({clientId:e.userId,streamId:e.streamId,message:RemoveStreamMessage.clientDisconnected})}))}}catch(e){f.e(e)}finally{f.f()}s.forEach((function(e){return o._onUserDisconnection(e)})),a.forEach((function(e){return o._onUserConnection(e)})),c.forEach((function(e){return o._onRemoveStream(e)})),l.forEach((function(e){return o._onAddStream(e,{fromSignal:!1})})),u.forEach((function(e){return o._onUpdateStreamAttributes(e)})),t&&this._handleSendOrRecvStreamAfterReconnect()}},{key:"_handleSendOrRecvStreamAfterReconnect",value:function(){var e,t,r=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 n,i=_createForOfIteratorHelper(values$1(t=this._remoteStreams).call(t));try{for(i.s();!(n=i.n()).done;){var o=n.value;Array.isArray(o)&&o.forEach(function(){var e=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){var n,i,o,a;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!t.hasSubscribed){e.next=15;break}return t.resetHasSubscribed(),e.prev=2,logger$6.print(concat$2(n="start resubscribe ".concat(t.userId," with ")).call(n,t.subMediaType)),e.next=6,r._mediaServerClient.subscribe(t,t.subMediaType);case 6:logger$6.print(concat$2(i="success resubscribe ".concat(t.userId," with ")).call(i,t.subMediaType)),r.safeEmit(RoomEvent.RESUBSCRIBE,{stream:t}),e.next=15;break;case 10:e.prev=10,e.t0=e.catch(2),logger$6.print(concat$2(o=concat$2(a="failed resubscribe ".concat(t.userId," with ")).call(a,t.subMediaType,", error:")).call(o,e.t0)),t.clean(),null==t||t.resetHasSubscribed();case 15:case"end":return e.stop()}}),e,null,[[2,10]])})));return function(t){return e.apply(this,arguments)}}())}}catch(e){i.e(e)}finally{i.f()}null===(e=this._subtitleTool)||void 0===e||e.reconnect()}},{key:"_handleFFAudioTrack",value:function(){var e,t,r,n,i=null===(e=this._mediaServerClient)||void 0===e||null===(t=e.handler)||void 0===t?void 0:t.audioTrack4ff,o=null===(r=this._mediaServerClient)||void 0===r||null===(n=r.handler)||void 0===n?void 0:n.getTransceivers();if(i&&Array.isArray(o)){var a=find$2(o).call(o,(function(e){var t;return(null==e||null===(t=e.receiver)||void 0===t?void 0:t.track)===i}));if(a){var s=new RemoteStream(this.id,"ff-stream","ff-stream",!1,virtualStreamAttributes);s.virtual=!0,s.audioTransceiver=a,s.audioMid="0",s.audioTrack=createRemoteAudioTrack(i),this._virtualStreams.push(s),this.safeEmit(RoomEvent.SUBSCRIBE_PUSH_TRACK,{stream:s})}}}},{key:"_findRemoteStream",value:function(e,t){var r=this._remoteStreams.get(e);return Array.isArray(r)?find$2(r).call(r,(function(e){return e.streamId===t})):null}},{key:"_findRemoteStreamByScreen",value:function(e,t){var r=this._remoteStreams.get(e);return Array.isArray(r)?find$2(r).call(r,(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=r.needEmit,i=void 0===n||n,o=r.fromSignal,a=void 0===o||o,s=r.virtual,c=void 0!==s&&s;if(e.clientId!==(null===(t=this._roomInfo)||void 0===t?void 0:t.userInfo.userId)){var l=this._roomConfig,u=l.isAutoSubscribeAudio,d=l.isAutoSubscribeVideo,p=this._findRemoteStreamByScreen(e.clientId,e.screen);if(p&&p.streamId!==e.streamId){var _,h=null===(_=this._remoteStreams.get(e.clientId))||void 0===_?void 0:filter3(_).call(_,(function(e){return e.streamId!==p.streamId}));p.clean(),this._remoteStreams.set(e.clientId,h||[])}var f=this._findRemoteStream(e.clientId,e.streamId);if(this._remoteStreamStreamIdUserIdMap[e.streamId]=e.clientId,f)f.attributes=e.attributes;else if((f=new RemoteStream(this.id,e.clientId,e.streamId,e.screen,e.attributes)).virtual=c,this._initStreamListeners(f),!c){var m=this._remoteStreams.get(e.clientId);m?m.push(f):this._remoteStreams.set(e.clientId,[f])}if(this._mediaServerClient.handler&&(f.observer=new RecvFrameObserver(f,this._mediaServerClient.handler)),!f.isScreen&&d){var v,g,y,S,T,$,E,b;if(a&&f.hasVideo)if(f.attributes.extvideo)null===(v=f.observer)||void 0===v||v.setExternalVideoSource(!0),null===(g=f.observer)||void 0===g||g.setPushVideo(!0);else null===(y=f.observer)||void 0===y||y.setExternalVideoSource(!1),null===(S=f.observer)||void 0===S||S.setPublishVideo(!0);if(a&&f.hasAudio&&u&&!this._mediaServerClient.roomAttributes.multiChatMode)if(f.attributes.extaudio)null===(T=f.observer)||void 0===T||T.setExternalAudioSource(!0),null===($=f.observer)||void 0===$||$.setPushAudio(!0);else null===(E=f.observer)||void 0===E||E.setExternalAudioSource(!1),null===(b=f.observer)||void 0===b||b.setPublishAudio(!0);if(!0===i&&!1===a){var I,R=this._roomConfig,C=R.isAutoSubscribeAudio,A=R.isAutoSubscribeVideo;null===(I=f.observer)||void 0===I||I.setLogin(!0,{audio:!!C,video:!!A})}}return i&&this.safeEmit(SignalEvent.ON_ADD_STREAM,{stream:f}),f}}},{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,a=e.forbiddenTime;if(n)if(n===(null===(t=this.roomInfo)||void 0===t?void 0:t.userInfo.userId)){var s=null;i===UserDisconnectionTag.kickedByAdmin?s=ErrorCode.KICKED_OUT:i===UserDisconnectionTag.onUserTokenDidExpire?s=ErrorCode.TOKEN_EXPIRED:i===UserDisconnectionTag.userDuplicateLogin&&(s=ErrorCode.DUPLICATE_LOGIN),o===UserDisconnectionCode.roomDismissByAdmin&&(s=ErrorCode.ROOM_DISMISS),s&&this.safeEmit(RoomEvent.ON_ROOM_ERROR,{errorCode:s,forbiddenTime:a})}else{var c=UserOfflineReason.DROPPED;i===UserDisconnectionTag.userLeave?c=UserOfflineReason.QUIT:i===UserDisconnectionTag.kickedByAdmin?c=UserOfflineReason.KICKED_BY_ADMIN:i===UserDisconnectionTag.roleChanged&&(c=UserOfflineReason.SWITCH_TO_INVISIBLE);var l=function(){var e;r._remoteUsers.delete(n),null===(e=r._remoteStreams.get(n))||void 0===e||e.forEach((function(e){e.clean(),r._onRemoveStream({clientId:e.userId,streamId:e.streamId,message:RemoveStreamMessage.clientDisconnected})})),r._remoteStreams.delete(n),r.safeEmit(RoomEvent.ON_USER_LEAVE,{userInfo:{userId:n},reason:c})};if(i===UserDisconnectionTag.userDuplicateLogin){var u=this._userDuplicateLoginTimerMap.get(n);u&&self.clearTimeout(u);var d=self.setTimeout(l,5e3);this._userDuplicateLoginTimerMap.set(n,d)}else l()}}},{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=find$2(n).call(n,(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(){var t=r._remoteStreams.get(e.clientId);t&&(t=filter3(t).call(t,(function(t){return t.streamId!==e.streamId||(t.clean(),!1)})),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){var t;e.roomAttributes&&(this._mediaServerClient.roomAttributes=_objectSpread2(_objectSpread2({},this._mediaServerClient.roomAttributes),e.roomAttributes)),null!==(t=e.roomAttributes)&&void 0!==t&&t.multiChatMode&&this._handleFFAudioTrack()}},{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,l,u=s.attributes,d=_objectSpread2(_objectSpread2({},u),a),p=!1,_=d.localaudio!==u.localaudio,h=!1,f=!1,m=d.localvideo!==u.localvideo,v=!1,g=ExtendMediaType.NONE,y=ExtendMediaType.NONE;if(d.audiostream!==u.audiostream&&(p=d.localaudio,h=!!d.audiostream,d.audiostream?g|=MediaType.AUDIO:y|=MediaType.AUDIO),d.videostream!==u.videostream&&(f=d.localvideo,v=!!d.videostream,d.videostream?g|=MediaType.VIDEO:y|=MediaType.VIDEO),g&&this.safeEmit(RoomEvent.ON_USER_PUBLISH_STATE_CHANGE,{userId:i,mediaType:g,isScreen:s.isScreen,pubState:PubState.PUB,remoteStream:s}),y&&this.safeEmit(RoomEvent.ON_USER_PUBLISH_STATE_CHANGE,{userId:i,mediaType:y,isScreen:s.isScreen,pubState:PubState.UNPUB,remoteStream:s}),s.attributes=d,d.localaudio!==u.localaudio)if(d.localaudio){var S,T,$,E;if(r&&d.audiostream)if(d.extaudio)null===(S=s.observer)||void 0===S||S.setExternalAudioSource(!0),null===(T=s.observer)||void 0===T||T.setPushAudio(!0);else null===($=s.observer)||void 0===$||$.setExternalAudioSource(!1),null===(E=s.observer)||void 0===E||E.setEnableAudio(!0);this.safeEmit(RoomEvent.ON_USER_START_AUDIO_CAPTURE,{userId:i},s)}else{var b,I,R,C;if(d.extaudio)null===(b=s.observer)||void 0===b||b.setExternalAudioSource(!0),null===(I=s.observer)||void 0===I||I.setPushAudio(!1);else null===(R=s.observer)||void 0===R||R.setExternalAudioSource(!1),null===(C=s.observer)||void 0===C||C.setEnableAudio(!1);!s.isScreen&&this.safeEmit(RoomEvent.ON_USER_STOP_AUDIO_CAPTURE,{userId:i})}if(d.localvideo!==u.localvideo)if(d.localvideo){var A,k,P,O;if(n&&d.videostream)if(d.extvideo)null===(A=s.observer)||void 0===A||A.setExternalVideoSource(!0),null===(k=s.observer)||void 0===k||k.setPushVideo(!0);else null===(P=s.observer)||void 0===P||P.setExternalVideoSource(!1),null===(O=s.observer)||void 0===O||O.setEnableVideo(!0);this.safeEmit(RoomEvent.ON_USER_START_VIDEO_CAPTURE,{userId:i})}else{var w,M,D,x;if(d.extvideo)null===(w=s.observer)||void 0===w||w.setExternalVideoSource(!0),null===(M=s.observer)||void 0===M||M.setPushVideo(!1);else null===(D=s.observer)||void 0===D||D.setExternalVideoSource(!1),null===(x=s.observer)||void 0===x||x.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(h);if(f&&!m)null===(l=s.observer)||void 0===l||l.setRemoteUnmuteVideo(v)}}},{key:"_onPushTrack",value:function(e){var t,r=this;if(null!==(t=e.streamId)&&void 0!==t&&startsWith2(t).call(t,"audio_mux")){var n=this._onAddStream(_objectSpread2(_objectSpread2({},e),{},{attributes:virtualStreamAttributes}),{needEmit:!1,fromSignal:!1,virtual:!0});n&&this._mediaServerClient.subscribe4pushTrack(n,e).then((function(){r.safeEmit(RoomEvent.SUBSCRIBE_PUSH_TRACK,{stream:n}),r._virtualStreams.push(n)})).catch((function(e){logger$6.print("subscribe","push track failed %o",e)}))}else{var i,o;null===(i=this._monitor)||void 0===i||i.report("rtc_error",{message:concat$2(o="onPushTrack, userId: ".concat(e.clientId,", ")).call(o,e.streamId),error_code:-1001})}}},{key:"_onRemoveTrack",value:function(e){var t,r=e.clientId,n=e.streamId,i=e.message;logger$6.print("_onRemoveTrack","remove track: %o",r);var o=this._findRemoteStream(r,n);o&&(null===(t=this._mediaServerClient)||void 0===t||t.unsubscribe4removeTrack(o,i))}},{key:"_onMeetingSpeakerChange",value:function(e){if(Array.isArray(null==e?void 0:e.speakerCsrcInfo)){var t={};null==e||e.speakerCsrcInfo.forEach((function(e){var r=e.csrc,n=e.userId;e.isScreen||(t[r]=n)})),this._csrcUserIdMap=t}}},{key:"getActiveSpeakerInMultiChatMode",value:function(){var e=this,t=[];return this._virtualStreams.forEach((function(r){var n,i=null===(n=r.audioTransceiver)||void 0===n?void 0:n.receiver;if(i){var o=_slicedToArray(i.getContributingSources()||[],1)[0];if(o){var a=o.audioLevel,s=o.source;e._csrcUserIdMap[s]&&t.push({userId:e._csrcUserIdMap[s],audioLevel:a})}}})),t.length&&sort2(t).call(t,(function(e,t){return e.audioLevel-t.audioLevel})),t}},{key:"_nodeChange",value:function(e){var t,r,n=e.nodes,i=e.reason;sdkCache.clearAccessNode(null===(t=this._roomInfo)||void 0===t?void 0:t.appId),this._destroyAndInitMediaServerClient(),Array.isArray(n)&&n.length?this._getAccessNode=n[0]:this._getAccessFeedback=i,null===(r=this._monitor)||void 0===r||r.report("rtc_node_change",{error_code:0,message:stringify$1(e),reason:stringify$1(i)}),this._joinResolveCallback&&this._joinRejectCallback?this._join(this._joinResolveCallback,this._joinRejectCallback):this._reconnect()}},{key:"_reconnect",value:function(){var e,t,r=this;this._isReconnecting=!0;var n,i=_createForOfIteratorHelper(values$1(t=this._remoteStreams).call(t));try{for(i.s();!(n=i.n()).done;){var o=n.value;Array.isArray(o)&&o.forEach((function(e){return e.clean()}))}}catch(e){i.e(e)}finally{i.f()}null===(e=this._monitor)||void 0===e||e.report("rtc_reconnect",{error_code:1002,message:"peerconnection reconnecting",reconnect_id:this._roomInfo.userInfo.userId,reconnect_type:"peerconnection"}),this._liveTranscodingOnceSucc||delete this._liveControlMessage,this._join((function(){var e;null===(e=r._monitor)||void 0===e||e.report("rtc_reconnected",{message:"peerconnection reconnected",reconnect_type:"peerconnection"})}),(function(e){r._reconnectRecord.record(e),r._reconnectRecord.shouldReconnect?(logger$6.print("Reconnecting error, will reconnect after 3s",e),r._reconnectTimer=window.setTimeout(r._reconnect.bind(r),3e3)):(r.safeEmit(RoomEvent.RECONNECT_FAILED),r.destroy())}),!0)}},{key:"_handleAbnormalDisconnection",value:function(){var e,t;logger$6.print("on ABNORMAL_DISCONNECTION"),null===(e=this.localStream)||void 0===e||e.stopReport(),null===(t=this.remoteStreams)||void 0===t||t.forEach((function(e){return null==e?void 0:e.forEach((function(e){return e.stopReport()}))})),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){var t,r={userId:e.from,message:e.msg};null!==(t=this._subtitleTool)&&void 0!==t&&t.onMessageRecv(r)||this.safeEmit(SignalEvent.USER_BINARY_MESSAGE_RECEIVED,r)}},{key:"_initSubtitleTool",value:function(){var e=this;this._subtitleTool=new SubtitleTool(this),this._subtitleTool.onEvent=function(t){e.emit(RoomEvent.ON_SUBTITLE_STATE_CHANGED,t)},this._subtitleTool.onMessage=function(t){e.emit(RoomEvent.ON_SUBTITLE_MESSAGE_RECEIVED,t)}}},{key:"_onPostProcessingMessage",value:function(e){if(e.body)if("subtitleCallback"!==e.type){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})}else{var o;null===(o=this._subtitleTool)||void 0===o||o.onResult(e)}}},{key:"_onUserTokenWillExpire",value:function(){this.safeEmit(SignalEvent.ON_USER_TOKEN_WILL_EXPIRE,null)}},{key:"_onStreamFailed",value:(r=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){var r,n,i,o,a,s,c,l,u,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],!(l=this._findRemoteStream(c,t.streamId))){e.next=20;break}return e.next=17,null===(u=this._mediaServerClient)||void 0===u?void 0:u.unsubscribe(l,MediaType.AUDIO_AND_VIDEO);case 17:return e.next=19,null===(d=this._mediaServerClient)||void 0===d?void 0:d.subscribe(l,l.subMediaType,l.subLayer);case 19:this.safeEmit(RoomEvent.RESUBSCRIBE,{stream:l});case 20:case"end":return e.stop()}}),e,this)}))),function(e){return r.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:(t=_asyncToGenerator(_regeneratorRuntime().mark((function e(){var t,r,n,i,o,a,s,c,l,u,d,p,_,h;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._publishOnDemandBusy&&!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)){e.next=2;break}return e.abrupt("return");case 2:if(a=this._publishOnDemandItem,this._publishOnDemandItem=void 0,a){e.next=6;break}return e.abrupt("return");case 6:if(null===(i=this._localStream)||void 0===i||!i.enableSimulcast||null===(o=this._localStream)||void 0===o||!o.videoTransceiver){e.next=16;break}return l=[],this._publishOnDemandBusy=!0,u=null===(s=this._localStream)||void 0===s?void 0:s.stream.id,d=null===(c=this._localStream)||void 0===c?void 0:c.videoTransceiver.sender,p=d.getParameters(),Array.isArray(p.encodings)&&Array.isArray(a)&&(h={},logger$6.print("_onPublishOnDemand exec","usedDescriptions: %o",a),a.forEach((function(e){var t;if(null!=e&&null!==(t=e.StreamIds)&&void 0!==t&&includes4(t).call(t,u)){var r=null==e?void 0:e.Metadata.VideoIndex;h[r]=!0}})),p.encodings=map$6(_=p.encodings).call(_,(function(e){if(e.rid){h[e.rid]?e.active=!0:e.active=!1;var t=+e.rid;l[t]=e.active}return e})),this._context&&(this._context.activeSimStreams=l)),e.next=15,d.setParameters(p);case 15:this._publishOnDemandBusy=!1;case 16:this._onPublishOnDemand();case 17:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})},{key:"_onRTT",value:function(e){var t=e.StreamIds,r=e.Metadata;if(t.length&&r){var n,i=t[0];null!==(n=this._context)&&void 0!==n&&n.streamRTT&&(this._context.streamRTT[i]={audio:r.audio_rtt,video:r.video_rtt})}}},{key:"_onSSC",value:function(e){var t=e.StreamIds,r=e.Metadata,n=t[0],i=this._remoteStreamStreamIdUserIdMap[n],o=this._findRemoteStream(i,n),a={userId:i,isScreen:!!o&&o.isScreen,beforeVideoIndex:r.ssc_items[0].prev_layer_id,afterVideoIndex:r.ssc_items[0].cur_layer_id,beforeEnable:0!==r.ssc_items[0].prev_video_open,afterEnable:0!==r.ssc_items[0].cur_video_open,reason:r.ssc_items[0].change_reason};this.emit(RoomEvent.ON_SIMULCAST_SUBSCRIBE_FALLBACK,a)}},{key:"_reportNetworkQuality",value:function(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:"multiChatMode",get:function(){var e;return null===(e=this._mediaServerClient)||void 0===e?void 0:e.multiChatMode()}}]),R}(),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;map$6(e).call(e,(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&&assign$2(r.style,t.style),t.attributes&&entries2(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},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:""},VideoPlayer=function(e){_inherits(n,eventemitter3.exports.EventEmitter);var t,r=_createSuper(n);function n(e,t){var i;_classCallCheck(this,n),_defineProperty(_assertThisInitialized(i=r.call(this)),"_containerDom",void 0),_defineProperty(_assertThisInitialized(i),"_videoDom",void 0),_defineProperty(_assertThisInitialized(i),"__cumulativeTime",void 0),_defineProperty(_assertThisInitialized(i),"userId",void 0),_defineProperty(_assertThisInitialized(i),"renderMode",void 0),_defineProperty(_assertThisInitialized(i),"mirrorType",MirrorType.MIRROR_TYPE_NONE),_defineProperty(_assertThisInitialized(i),"isScreen",void 0),_defineProperty(_assertThisInitialized(i),"isLocal",void 0),_defineProperty(_assertThisInitialized(i),"played",!1),_defineProperty(_assertThisInitialized(i),"_needLoad",!1),_defineProperty(_assertThisInitialized(i),"_emitPlayFailed",!1),_defineProperty(_assertThisInitialized(i),"_videoContainer",void 0),_defineProperty(_assertThisInitialized(i),"_safari15VideoTimer",void 0),_defineProperty(_assertThisInitialized(i),"_monitor",void 0),_defineProperty(_assertThisInitialized(i),"emitVideoEvent",(function(e){var t,r,n={type:"video",rawEvent:e,readyState:(null===(t=i._videoDom)||void 0===t?void 0:t.readyState)||0,userId:i.userId,eventName:e.type,currentTime:(null===(r=i._videoDom)||void 0===r?void 0:r.currentTime)||0,isScreen:i.isScreen};switch(i.emit("playback_event",n),e.type){case"canplay":case"loadeddata":i._internalPlay();break;case"playing":logger$5.print("VideoPlayerPlaying","[userId-".concat(i.userId,"] video element playing"))}})),_defineProperty(_assertThisInitialized(i),"_internalPlay",(function(){var e;if(null!==(e=i._videoDom)&&void 0!==e&&e.paused){var t=i._videoDom.play();null!=t&&t.then&&t.then((function(){var e;i.isLocal&&isCriOS&&!i._needLoad&&(null===(e=i._videoDom)||void 0===e||e.load(),i._needLoad=!0)})).catch((function(e){var t,r,n,o,a,s;i._emitPlayFailed||("AbortError"!==e.name?(i._emitPlayFailed=!0,null===(t=i._monitor)||void 0===t||t.report("rtc_error",{message:concat$2(r="video autoplay failed, userId: ".concat(i.userId,", ")).call(r,e.name),error_code:-1e3}),i.emit("playback_event",{type:"video",rawEvent:e,readyState:(null===(n=i._videoDom)||void 0===n?void 0:n.readyState)||0,userId:i.userId,eventName:"autoplay-error",currentTime:(null===(o=i._videoDom)||void 0===o?void 0:o.currentTime)||0,isScreen:i.isScreen})):null===(a=i._monitor)||void 0===a||a.report("rtc_error",{message:concat$2(s="video autoplay failed, userId: ".concat(i.userId,", ")).call(s,e.name),error_code:-1e3}))}))}})),i.engineId=e;var o=t.renderDom;i._monitor=getMonitor(e);var a=t.userId;i.renderMode=void 0!==t.renderMode?t.renderMode:VideoRenderMode.RENDER_MODE_FIT;var s="string"==typeof o?document.getElementById(o):o;if(!s)throw new SDKError(ErrorCode.CANT_FIND_DOM,"can't find dom");return i._videoContainer=document.createElement("div"),i._videoContainer.style.width="100%",i._videoContainer.style.height="100%",i._videoContainer.style.position="relative",i._videoContainer.style.overflow="hidden",i._containerDom=s,i.userId=a,i.isLocal=!!t.isLocal,i.isScreen=!!t.isScreen,i._initVideo(),i}return _createClass(n,[{key:"_initVideo",value:function(){var e;this._videoDom||(this._videoDom=createElement("video",{style:{width:"100%",height:"100%"},attributes:VIDEO_ATTRIBUTES}),this._videoDom.id=concat$2(e="".concat(this.userId,"_")).call(e,genUuid2()),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._videoContainer.appendChild(this._videoDom),this._containerDom.appendChild(this._videoContainer),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)}))}},{key:"_recordFrame",value:function(e){var t=this,r=e.isScreen?1.5:.55;if(isSafari){var n;if(null===(n=this._videoDom)||void 0===n||!n.requestVideoFrameCallback)return;this._videoDom.requestVideoFrameCallback((function n(i,o){var a=o.presentationTime;if(e.recordedVideoFrames||(e.recordedVideoFrames=[]),t.__cumulativeTime){var s,c=(a-t.__cumulativeTime)%2e3,l=c>1e3*r;null===(s=e.recordedVideoFrames)||void 0===s||s.push({playTime:a,isStall:l,stallCount:l?1:0,stallDuration:c})}t.__cumulativeTime=a,t._videoDom.requestVideoFrameCallback(n)}))}else this.on("playback_event",(function(n){var i;if("timeupdate"===n.eventName){if(0===(null===(i=t._videoDom)||void 0===i?void 0:i.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>r;e.recordedVideoFrames.push({playTime:t._videoDom.currentTime,isStall:a,stallCount:a?1:0,stallDuration:o%2e3})}t.__cumulativeTime=t._videoDom.currentTime}}))}},{key:"_recordPause",value:function(e){var t=this;void 0===e.statsReport.isPaused&&this.on("playback_event",(function(r){if("pause"===r.eventName)e.statsReport.isPaused=!0,e.statsReport.pauseStart=getServerNow();else if("timeupdate"===r.eventName){var n;if((null===(n=t._videoDom)||void 0===n||!n.paused)&&e.statsReport.isPaused){e.statsReport.isPaused=!1;var i=getServerNow()-(e.statsReport.pauseStart||0);i>500&&(e.statsReport.pauseDuration+=i)}}}))}},{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=5;break}try{reportRtcInvokeStatus(this.engineId,"playVideo","play video repeatedly",0,this.userId)}catch(e){}return e.abrupt("return");case 5: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("preprocessing")),o.srcObject=a,o&&!this._containerDom.contains(this._videoContainer)&&this._containerDom.appendChild(this._videoContainer),o&&!this._videoContainer.contains(o)&&this._videoContainer.appendChild(o),setTimeout((function(){return s._internalPlay()})),r&&Config.VIDEO_STALL&&(this._recordFrame(r),this._recordPause(r),r.statsReport.player=this),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:"removeTrack",value:function(){var e,t=null===(e=this._videoDom)||void 0===e?void 0:e.srcObject;if(t){var r=t.getVideoTracks();null!=r&&r.length&&r.forEach((function(e){t.removeTrack(e)}))}}},{key:"manuallyPlay",value:function(){if(logger$5.print("Invoke VideoPlayer.manuallyPlay",this.userId,this.isScreen),this._emitPlayFailed=!1,!this._videoDom)throw new SDKError(ErrorCode.INVALID_PARAMS,"Player not found");return 0!==this._videoDom.readyState||isWeChat?this._videoDom.play():promise.resolve()}},{key:"mirror",value:function(e){var t;logger$5.print("mirror",concat$2(t="".concat(this.userId," set mirror: ")).call(t,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,t=arguments.length>0&&void 0!==arguments[0]&&arguments[0],r=this._containerDom;(logger$5.print("stop","stop video track: ".concat(this.userId)),this._videoDom)&&(t||(this._videoDom.srcObject=null),null!=r&&r.contains(this._videoContainer)&&r.removeChild(this._videoContainer),null!==(e=this._videoContainer)&&void 0!==e&&e.contains(this._videoDom)&&this._videoContainer.removeChild(this._videoDom));this.__cumulativeTime=void 0,this.played=!1}},{key:"destroy",value:function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];logger$5.print("destroy","video player: ".concat(this.userId)),this.stop(e),_get(_getPrototypeOf(n.prototype),"removeAllListeners",this).call(this),this._removeListeners(),this._videoDom&&delete this._videoDom,this._safari15VideoTimer&&(window.clearInterval(this._safari15VideoTimer),this._safari15VideoTimer=void 0)}},{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,t){var r,o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{divId:void 0,muted:!1,isScreen:!1},a=o.divId,s=o.muted,c=o.isScreen;if(_classCallCheck(this,i),_defineProperty(_assertThisInitialized(r=n.call(this)),"_containerDom",void 0),_defineProperty(_assertThisInitialized(r),"_audioDom",void 0),_defineProperty(_assertThisInitialized(r),"_fakeAudioDom",void 0),_defineProperty(_assertThisInitialized(r),"userId",void 0),_defineProperty(_assertThisInitialized(r),"muted",!1),_defineProperty(_assertThisInitialized(r),"_emitPlayFailed",!1),_defineProperty(_assertThisInitialized(r),"played",!1),_defineProperty(_assertThisInitialized(r),"isScreen",void 0),_defineProperty(_assertThisInitialized(r),"_wechatTimer",void 0),_defineProperty(_assertThisInitialized(r),"_monitor",void 0),_defineProperty(_assertThisInitialized(r),"_pasued",!0),_defineProperty(_assertThisInitialized(r),"emitAudioEvent",(function(e){var t,n,i={type:"audio",rawEvent:e,readyState:(null===(t=r._audioDom)||void 0===t?void 0:t.readyState)||0,userId:r.userId,eventName:e.type,currentTime:(null===(n=r._audioDom)||void 0===n?void 0:n.currentTime)||0};"playing"===e.type&&logger$5.print("AudioPlayerPlaying","[userId-".concat(r.userId,"] audio element playing")),"pause"===e.type&&(logger$5.print("AudioPlayerPause","[userId-".concat(r.userId,"] audio element pause")),r._pasued||r._internalPlay()),isAndroid&&isWeChat&&("canplay"===e.type?(clearTimeout(r._wechatTimer),r._wechatTimer=window.setTimeout((function(){r._autoPlayError("wechat")}),500)):"playing"===e.type&&clearTimeout(r._wechatTimer)),r.emit("playback_event",i)})),_defineProperty(_assertThisInitialized(r),"_internalPlay",(function(){var e,t;if(reportRtcInvokeStatus(r.engineId,"_internalPlay",{paused:null===(e=r._audioDom)||void 0===e?void 0:e.paused}),null!==(t=r._audioDom)&&void 0!==t&&t.paused)try{var n,i=r._audioDom.play(),o=audioContextManager.getAudioContextInstance();if("suspended"===o.state){var a=o.resume(),s=setTimeout((function(){var e;"suspended"===o.state&&(r._autoPlayError("AudioContext cannot resume"),null===(e=r._monitor)||void 0===e||e.report("rtc_error",{message:"audio autoplay failed, userId: ".concat(r.userId,": Cannot resume the AudioContext - timeout"),error_code:-1e3}));clearTimeout(s)}));a.catch((function(e){var t,n,i;r._autoPlayError("AudioContext cannot resume"),null===(t=r._monitor)||void 0===t||t.report("rtc_error",{message:concat$2(n=concat$2(i="audio autoplay failed, userId: ".concat(r.userId,": Cannot resume the AudioContext - rejected by: [")).call(i,null==e?void 0:e.name,"]")).call(n,null==e?void 0:e.message),error_code:-1e3})})).finally((function(){clearTimeout(s)}))}null!==(n=i)&&void 0!==n&&n.then&&(isAndroid&&isMobile&&(i=i.then((function(){return new promise((function(e){setTimeout(_asyncToGenerator(_regeneratorRuntime().mark((function t(){var n;return _regeneratorRuntime().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return null===(n=r._audioDom)||void 0===n||n.pause(),r._audioDom.volume=1,t.next=4,r._audioDom.play();case 4:e();case 5:case"end":return t.stop()}}),t)}))),500)}))}))),i.then((function(){reportRtcInvokeStatus(r.engineId,"_internalPlay successfully",{userId:r.userId}),r._pasued=!1})).catch((function(e){var t,n,i;r._autoPlayError(e),null===(t=r._monitor)||void 0===t||t.report("rtc_error",{message:concat$2(n=concat$2(i="audio autoplay failed, userId: ".concat(r.userId,": ")).call(i,e.message," ")).call(n,e.name),error_code:-1e3})})))}catch(e){var c,l,u;r._autoPlayError(e),null===(c=r._monitor)||void 0===c||c.report("rtc_error",{message:concat$2(l=concat$2(u="audio autoplay failed, userId: ".concat(r.userId,": ")).call(u,e.message," ")).call(l,e.name),error_code:-1e3})}})),r.engineId=e,a){var l=document.getElementById(a);if(!l)throw new SDKError(ErrorCode.CANT_FIND_DOM,"can't find dom");r._containerDom=l}else r._containerDom=document.body;return r.userId=t,r.muted=s,r.isScreen=c,r._monitor=getMonitor(e),r._initAudio(),r}return _createClass(i,[{key:"_initAudio",value:function(){var e;this._audioDom||(this._audioDom=createElement("audio",{style:{display:"none"},attributes:AUDIO_ATTRIBUTES}),this._audioDom.volume=this.muted?0:1,this._audioDom.muted=this.muted,this._audioDom.id=concat$2(e="".concat(this.userId,"_")).call(e,genUuid2()),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,t instanceof runtimeTrackCls.RemoteAudioTrack?(this._fakeAudioDom=new Audio,this._fakeAudioDom.muted=!0,this._fakeAudioDom.srcObject=new MediaStream([t.getOrgTrack()]),a.addTrack(t.getTrack())):a.addTrack(t.getTrack("preprocessing")),isAndroid&&isMobile&&(this._audioDom.volume=0),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 13: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,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:"pause",value:function(){if(!this._audioDom)throw new SDKError(ErrorCode.INVALID_PARAMS,"Player not found");this._pasued=!0,this._audioDom.pause()}},{key:"manuallyPlay",value:function(){var e,t=this;if(logger$5.print("Invoke AudioPlayer.manuallyPlay"),this._emitPlayFailed=!1,!this._audioDom)throw new SDKError(ErrorCode.INVALID_PARAMS,"Player not found");if(!this.played)return promise.resolve();this._audioDom.volume=1,this._audioDom.muted=!1,null===(e=this._fakeAudioDom)||void 0===e||e.play();var r=[],n=this._audioDom.play();null!=n&&n.then&&r.push(n);var i=audioContextManager.getAudioContextInstance();if("suspended"===i.state){var o=i.resume();null!=o&&o.then&&r.push(o)}(r.length>0?promise.all(r):promise.resolve(n)).then((function(){t._pasued=!1}))}},{key:"setPlaybackDevice",value:(t=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){var r,n;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return logger$5.print("setPlaybackDevice","setPlaybackDevice: ".concat(t)),e.next=3,dd.enumerateAudioPlaybackDevices();case 3:if(r=e.sent,n=map$6(r).call(r,(function(e){return e.deviceId})),includes4(n).call(n,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,null!=e&&e.contains(this._audioDom)&&e.removeChild(this._audioDom)),this._fakeAudioDom&&(this._fakeAudioDom.srcObject=null,this._fakeAudioDom=void 0),this.played=!1}},{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&&(this._audioDom.srcObject=null,delete this._audioDom)}}]),i}();function playRemoteStream(e,t,r,n){var i=function(){var e=_asyncToGenerator(_regeneratorRuntime().mark((function e(t,i){var o,a;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(o=null==n?void 0:n.get(i),Array.isArray(o)&&(o=null===(a=o)||void 0===a?void 0:find$2(a).call(a,(function(e){return e.isScreen===r}))),!t){e.next=9;break}if(!t.played){e.next=8;break}return e.next=6,t.manuallyPlay();case 6:e.next=9;break;case 8:o&&(t instanceof VideoPlayer&&o.videoTrack&&t.playVideo(o.videoTrack,o),t instanceof AudioPlayer&&o.audioTrack&&t.playAudio(o.audioTrack));case 9:case"end":return e.stop()}}),e)})));return function(t,r){return e.apply(this,arguments)}}();if(t)return i(e.get(t),t);var o=[];return e.forEach((function(e,t){return o.push(i(e,t))})),promise.all(o)}var fails=fails$z,wellKnownSymbol$1=wellKnownSymbol$p,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})),defineProperty5=objectDefineProperty,defineBuiltInAccessor$1=function(e,t,r){return defineProperty5.f(e,t,r)},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,l=c;for(c&&push$2(n,delimiter);l<i;){var u=maxInt;for(t=0;t<e.length;t++)(r=e[t])>=o&&r<u&&(u=r);var d=l+1;if(u-o>floor$1((maxInt-a)/d))throw $RangeError(OVERFLOW_ERROR);for(a+=(u-o)*d,o=u,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 h=_<=s?tMin:_>=s+tMax?tMax:_-s;if(p<h)break;var f=p-h,m=base-h;push$2(n,fromCharCode(digitToBasic(h+f%m))),p=floor$1(f/m),_+=base}push$2(n,fromCharCode(digitToBasic(p))),s=adapt(a,d,l==c),a=0,l++}}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$s,call=functionCall,uncurryThis$1=functionUncurryThis,DESCRIPTORS$1=descriptors,USE_NATIVE_URL$1=urlConstructorDetection,defineBuiltIn$1=defineBuiltIn$8,defineBuiltIns=defineBuiltIns$4,setToStringTag$1=setToStringTag$9,createIteratorConstructor=iteratorCreateConstructor,InternalStateModule$1=internalState,anInstance$1=anInstance$6,isCallable=isCallable$n,hasOwn$1=hasOwnProperty_1,bind$1=functionBindContext,classof=classof$d,anObject=anObject$M,isObject=isObject$q,$toString$1=toString$h,create4=objectCreate$1,createPropertyDescriptor=createPropertyDescriptor$9,getIterator=getIterator$7,getIteratorMethod=getIteratorMethod$a,validateArgumentsLength$1=validateArgumentsLength$3,wellKnownSymbol=wellKnownSymbol$p,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),getOwnPropertyDescriptor5=Object.getOwnPropertyDescriptor,safeGetBuiltIn=function(e){if(!DESCRIPTORS$1)return global$2[e];var t=getOwnPropertyDescriptor5(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$1=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),splice2=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$1(e)}catch(t){return e}},deserialize=function(e){var t=replace$1(e,plus," "),r=4;try{return decodeURIComponent$1(t)}catch(e){for(;r;)t=replace$1(t,percentSequence(r--),percentDecode);return t}},find4=/[!'()~]|%20/g,replacements={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+"},replacer=function(e){return replacements[e]},serialize=function(e){return replace$1(encodeURIComponent$1(e),find4,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 l in e)hasOwn$1(e,l)&&push$1(this.entries,{key:l,value:$toString$1(e[l])})},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?splice2(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?splice2(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"),create4(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$s,bind2=functionBindContext,uncurryThis=functionUncurryThis,defineBuiltIn=defineBuiltIn$8,defineBuiltInAccessor=defineBuiltInAccessor$1,anInstance=anInstance$6,hasOwn2=hasOwnProperty_1,assign2=objectAssign,arrayFrom=arrayFrom$1,arraySlice=arraySliceSimple,codeAt=stringMultibyte.codeAt,toASCII=stringPunycodeToAscii,$toString=toString$h,setToStringTag=setToStringTag$9,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),join2=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],l=0,u=null,d=0,p=function(){return charAt(e,d)};if(":"==p()){if(":"!=charAt(e,1))return;d+=2,u=++l}for(;p();){if(8==l)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,l>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[l]=256*c[l]+i,2!=++n&&4!=n||l++}if(4!=n)return;break}if(":"==p()){if(d++,!p())return}else if(p())return;c[l++]=t}else{if(null!==u)return;d++,u=++l}}if(null!==u)for(a=l-u,l=7;0!=l&&a>0;)s=c[l],c[l--]=c[u+a-1],c[u+--a]=s;else if(8!=l)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 join2(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=assign2({},C0ControlPercentEncodeSet,{" ":1,'"':1,"<":1,">":1,"`":1}),pathPercentEncodeSet=assign2({},fragmentPercentEncodeSet,{"#":1,"?":1,"{":1,"}":1}),userinfoPercentEncodeSet=assign2({},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&&!hasOwn2(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,l=0,u="",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);l<=n.length;){switch(i=n[l],c){case SCHEME_START:if(!i||!exec(ALPHA,i)){if(t)return INVALID_SCHEME;c=NO_SCHEME;continue}u+=toLowerCase(i),c=SCHEME;break;case SCHEME:if(i&&(exec(ALPHANUMERIC,i)||"+"==i||"-"==i||"."==i))u+=toLowerCase(i);else{if(":"!=i){if(t)return INVALID_SCHEME;u="",c=NO_SCHEME,l=0;continue}if(t&&(s.isSpecial()!=hasOwn2(specialSchemes,u)||"file"==u&&(s.includesCredentials()||null!==s.port)||"file"==s.scheme&&!s.host))return;if(s.scheme=u,t)return void(s.isSpecial()&&specialSchemes[s.scheme]==s.port&&(s.port=null));u="","file"==s.scheme?c=FILE:s.isSpecial()&&r&&r.scheme==s.scheme?c=SPECIAL_RELATIVE_OR_AUTHORITY:s.isSpecial()?c=SPECIAL_AUTHORITY_SLASHES:"/"==n[l+1]?(c=PATH_OR_AUTHORITY,l++):(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[l+1]){c=RELATIVE;continue}c=SPECIAL_AUTHORITY_IGNORE_SLASHES,l++;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(u,l+1))continue;l++;break;case SPECIAL_AUTHORITY_IGNORE_SLASHES:if("/"!=i&&"\\"!=i){c=AUTHORITY;continue}break;case AUTHORITY:if("@"==i){d&&(u="%40"+u),d=!0,o=arrayFrom(u);for(var h=0;h<o.length;h++){var f=o[h];if(":"!=f||_){var m=percentEncode(f,userinfoPercentEncodeSet);_?s.password+=m:s.username+=m}else _=!0}u=""}else if(i==EOF||"/"==i||"?"==i||"#"==i||"\\"==i&&s.isSpecial()){if(d&&""==u)return INVALID_AUTHORITY;l-=arrayFrom(u).length+1,u="",c=HOST}else u+=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()&&""==u)return INVALID_HOST;if(t&&""==u&&(s.includesCredentials()||null!==s.port))return;if(a=s.parseHost(u))return a;if(u="",c=PATH_START,t)return;continue}"["==i?p=!0:"]"==i&&(p=!1),u+=i}else{if(""==u)return INVALID_HOST;if(a=s.parseHost(u))return a;if(u="",c=PORT,t==HOSTNAME)return}break;case PORT:if(!exec(DIGIT,i)){if(i==EOF||"/"==i||"?"==i||"#"==i||"\\"==i&&s.isSpecial()||t){if(""!=u){var v=parseInt$1(u,10);if(v>65535)return INVALID_PORT;s.port=s.isSpecial()&&v===specialSchemes[s.scheme]?null:v,u=""}if(t)return;c=PATH_START;continue}return INVALID_PORT}u+=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(join2(arraySlice(n,l),""))||(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(join2(arraySlice(n,l),""))&&(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(u))c=PATH;else if(""==u){if(s.host="",t)return;c=PATH_START}else{if(a=s.parseHost(u))return a;if("localhost"==s.host&&(s.host=""),t)return;u="",c=PATH_START}continue}u+=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(u)?(s.shortenPath(),"/"==i||"\\"==i&&s.isSpecial()||push(s.path,"")):isSingleDot(u)?"/"==i||"\\"==i&&s.isSpecial()||push(s.path,""):("file"==s.scheme&&!s.path.length&&isWindowsDriveLetter(u)&&(s.host&&(s.host=""),u=charAt(u,0)+":"),push(s.path,u)),u="","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 u+=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))}l++}},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 hasOwn2(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,l=t+":";return null!==i?(l+="//",e.includesCredentials()&&(l+=r+(n?":"+n:"")+"@"),l+=serializeHost(i),null!==o&&(l+=":"+o)):"file"==t&&(l+="//"),l+=e.cannotBeABaseURL?a[0]:a.length?"/"+join2(a,"/"):"",null!==s&&(l+="?"+s),null!==c&&(l+="#"+c),l},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?"/"+join2(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",bind2(nativeCreateObjectURL,NativeURL)),nativeRevokeObjectURL&&defineBuiltIn(URLConstructor,"revokeObjectURL",bind2(nativeRevokeObjectURL,NativeURL))}setToStringTag(URLConstructor,"URL"),$({global:!0,constructor:!0,forced:!USE_NATIVE_URL,sham:!DESCRIPTORS},{URL:URLConstructor});var path=path$v,url$5=path.URL,parent$2=url$5,url$4=parent$2,parent$1=url$4,url$3=parent$1,parent=url$3,url$2=parent,url$1=url$2,url=url$1,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=defineProperty$a,__getOwnPropDesc$1=getOwnPropertyDescriptor$1,__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,r){_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,"_startingIds",new map2),_defineProperty(this,"_revokeURLs",new set),_defineProperty(this,"mixingMap",new map2),_defineProperty(this,"resourcesCache",new map2),_defineProperty(this,"volumeConfig",new map2),_defineProperty(this,"cachedBuffer",[]),_defineProperty(this,"id","AudioMixingManager"),this.engineId=r,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,l,u,d,p,_,h,f,m,v=this;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(void 0===this._startingIds.get(t)){e.next=3;break}return console.warn("AudioMixing task id: ".concat(t," is starting")),e.abrupt("return");case 3:if(this._startingIds.set(t,t),i=n.playCount,checkEnum(o=n.type,"mixingType",values(AudioMixingType)),a=this._context.getLocalAudioTrack()){e.next=9;break}return e.abrupt("return");case 9:if((s=a.getTrack("preprocessing"))&&this.mixMediaStream(new MediaStream([s])),null!=(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(!(u=this.resourcesCache.get(t))||u.filePath!==r){e.next=18;break}l=u.getAudioNode(),e.next=31;break;case 18:return e.next=20,fetch(r,{mode:"cors",credentials:"include"}).then((function(e){if(e.ok)return e.arrayBuffer();throw v._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 20:return d=e.sent,endsWith2(r).call(r,"mp3")?p={type:"audio/mpeg"}:endsWith2(r).call(r,"aac")&&(p={type:"audio/aac"}),e.next=24,isValidAudioFile(d,p);case 24:if(e.sent){e.next=28;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 28:(l=new Audio).crossOrigin="anonymous",l.src=url.createObjectURL(new Blob([d],p));case 31:return i<=0?l.loop=!0:i>0&&(_=i,l.onended=function(){--_>0?l.play():(v.mixingMap.delete(t),v._context.emitMessage({mixId:t,state:AudioMixingState.AUDIO_MIXING_STATE_FINISHED,error:AudioMixingError.AUDIO_MIXING_ERROR_OK}))}),e.prev=32,e.next=35,l.play();case 35:e.next=42;break;case 37:e.prev=37,e.t0=e.catch(32),console.error(e.t0),this._failedAudioList.push(l),this._context.onAutoPlayFailed({userId:this.id,kind:"audio",streamIndex:StreamIndex.STREAM_INDEX_MAIN,mediaType:MediaType.AUDIO});case 42:if(this._startingIds.delete(t),h=this._sharedAudioContext.createMediaElementSource(l),f=this._sharedAudioContext.createGain(),m=this.volumeConfig.get(t),f.gain.value=m?m/100:1,h.connect(f).connect(this._audioDestination),this.mixingMap.set(t,{audioSource:h,audioNode:l,gainNode:f,type:"file"}),o===AudioMixingType.PUBLISH)try{f.disconnect(this._sharedAudioContext.destination)}catch(e){}else f.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 52:case"end":return e.stop()}}),e,this,[[32,37]])}))),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,o=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 new SDKError(ErrorCode.LOAD_RESOURCES_FAILED,e.statusText)})).catch((function(e){if(o._context.emitMessage({mixId:t,state:AudioMixingState.AUDIO_MIXING_STATE_FAILED,error:AudioMixingError.AUDIO_MIXING_ERROR_PRELOAD_FAILED}),e instanceof SDKError)throw e;throw new SDKError(ErrorCode.LOAD_RESOURCES_FAILED,"Load resources failed",e)}));case 3:return n=e.sent,endsWith2(r).call(r,"mp3")?i={type:"audio/mpeg"}:endsWith2(r).call(r,"aac")&&(i={type:"audio/aac"}),e.next=7,isValidAudioFile(n,i);case 7:if(e.sent){e.next=11;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 11:return this._context.emitMessage({mixId:t,state:AudioMixingState.AUDIO_MIXING_STATE_PRELOADED,error:AudioMixingError.AUDIO_MIXING_ERROR_OK}),this.resourcesCache.set(t,{getAudioNode:function(){var e=url.createObjectURL(new Blob([n],i));return o._revokeURLs.add(e),new Audio(e)},filePath:r,duration:0}),e.next=15,new promise((function(e){var r=url.createObjectURL(new Blob([n],i)),a=new Audio(r);a.addEventListener("durationchange",(function(){var n=o.resourcesCache.get(t);n&&(n.duration=a.duration,o.resourcesCache.set(t,n)),url.revokeObjectURL(r),e(null)}))}));case 15: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.resourcesCache.get(e);return t||r?t?1e3*t.audioNode.duration:r?1e3*r.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=t.getTrack("preprocessing");if(r&&this.mixMediaStream(new MediaStream([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({userId:this.id,kind:"audio",streamIndex:StreamIndex.STREAM_INDEX_MAIN,mediaType:MediaType.AUDIO}),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(),this._startingIds=new map2,this._revokeURLs.forEach((function(e){url.revokeObjectURL(e)}))}}]),e}();__decorateClass$1([reportRtcSdkApiCall("id","filePath","options")],AudioMixingManager.prototype,"startAudioMixing",1),__decorateClass$1([reportRtcSdkApiCall("id")],AudioMixingManager.prototype,"stopAudioMixing",1),__decorateClass$1([reportRtcSdkApiCall("id")],AudioMixingManager.prototype,"pauseAudioMixing",1),__decorateClass$1([reportRtcSdkApiCall("id")],AudioMixingManager.prototype,"resumeAudioMixing",1),__decorateClass$1([reportRtcSdkApiCall("id")],AudioMixingManager.prototype,"preloadAudioMixing",1),__decorateClass$1([reportRtcSdkApiCall("id")],AudioMixingManager.prototype,"unloadAudioMixing",1),__decorateClass$1([reportRtcSdkApiCall("id")],AudioMixingManager.prototype,"getAudioMixingVolume",1),__decorateClass$1([reportRtcSdkApiCall("id","volume")],AudioMixingManager.prototype,"setAudioMixingVolume",1),__decorateClass$1([reportRtcSdkApiCall("id")],AudioMixingManager.prototype,"getAudioMixingDuration",1),__decorateClass$1([reportRtcSdkApiCall("id")],AudioMixingManager.prototype,"getAudioMixingCurrentPosition",1),__decorateClass$1([reportRtcSdkApiCall("id","position")],AudioMixingManager.prototype,"setAudioMixingPosition",1),__decorateClass$1([reportRtcSdkApiCall("type")],AudioMixingManager.prototype,"enableAudioMixingBuffer",1),__decorateClass$1([reportRtcSdkApiCall()],AudioMixingManager.prototype,"disableAudioMixingBuffer",1),__decorateClass$1([reportRtcSdkApiCall("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(l,eventemitter3.exports.EventEmitter);var t,r,n,i,o,a,s,c=_createSuper(l);function l(e,t){var r;return _classCallCheck(this,l),_defineProperty(_assertThisInitialized(r=c.call(this)),"_dataChannelSignal",null),_defineProperty(_assertThisInitialized(r),"_handler",null),_defineProperty(_assertThisInitialized(r),"_dataChannelSignalState",MediaConnectionState.DISCONNECTED),_defineProperty(_assertThisInitialized(r),"_loginSessionId",null),_defineProperty(_assertThisInitialized(r),"_userId",null),_defineProperty(_assertThisInitialized(r),"_token",null),_defineProperty(_assertThisInitialized(r),"_isReconnecting",!1),_defineProperty(_assertThisInitialized(r),"_reconnectTimer",null),_defineProperty(_assertThisInitialized(r),"_loginResolveCallback",null),_defineProperty(_assertThisInitialized(r),"_loginRejectCallback",null),_defineProperty(_assertThisInitialized(r),"_iceConfigNode",null),_defineProperty(_assertThisInitialized(r),"_wait_login_token",!1),_defineProperty(_assertThisInitialized(r),"_serverParamsCache",void 0),r.id=e,r._appId=t,r}return _createClass(l,[{key:"login",value:function(e,t){var r=this;return new promise((function(n,i){var o;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,null===(o=getMonitor(r.id))||void 0===o||o.set({rtm_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(l.prototype),"removeAllListeners",this).call(this),delete this._serverParamsCache}},{key:"_login",value:function(){var e=this;if(this._userId){var t=genUuid2();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},accessParams:stringify$1({requireICEUfragV2:!0})},{functionType:SIGNALING_FUNCTION_TYPE.C2RTM}).then((function(){"function"==typeof e._loginResolveCallback&&e._loginResolveCallback(),e._loginSessionId=t,RTSMsgReportor.setRtsSessionId(e.id,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"),"function"==typeof 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,l=this;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=new IceConfigRequestManager(this.id),i=this._iceConfigNode){e.next=16;break}return e.prev=3,e.next=6,null==n?void 0:n.getAccessNode(this._appId,"");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(this.id,"rtm.login.getNodeFailed",null===e.t0||void 0===e.t0?void 0:e.t0.message),new SDKError(ErrorCode.ICE_SERVER_WRONG,"get ICE config failed");case 16:return reportRtcInvokeStatus(this.id,"rtm.login.getNodeSuccess",i),logger$4.print("_createDataChannelSignaling()","get node success",i),this._handler=createHandler({id:this.id,avSync:!0,enableFallbackHandler:isFallbackMode(this._appId)}),null===(r=this._handler)||void 0===r||r.once("disconnect",(function(){logger$4.print("_createDataChannelSignaling()","recv BasicHandler event: disconnect"),l._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(this.id,a),logger$4.print("_createDataChannelSignaling()","send ping"),c.sendPingSignaling(),c.once("close",(function(){logger$4.print("_createDataChannelSignaling()","recv DataChannelSignaling event: close"),l._onDisconnect()})),c.on(SignalEvent.USER_MESSAGE_RECEIVED_OUTSIDE_ROOM,(function(e){l.emit("onUserMessageReceivedOutsideRoom",{userId:e.from,message:e.msg})})),c.on(SignalEvent.USER_BINARY_MESSAGE_RECEIVED_OUTSIDE_ROOM,(function(e){l.emit("onUserBinaryMessageReceivedOutsideRoom",{userId:e.from,message:e.msg})})),c.on(SignalEvent.USER_DISCONNECTION,(function(){l.emit("onUserDisconnection"),l._clearState()})),c.on(SignalEvent.NODE_CHANGE,(function(e){reportRtcInvokeStatus(l.id,"rtm.nodeChange",stringify$1(e)),Array.isArray(e.nodes)&&e.nodes.length&&(l._iceConfigNode=e.nodes[0]),l._loginResolveCallback&&l._loginRejectCallback?l._login():l._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,RTSMsgReportor.setRtsSessionId(this.id,""),null!==this._reconnectTimer&&(self.clearTimeout(this._reconnectTimer),this._reconnectTimer=null)}}]),l}(),OutsideRoom=function(e){_inherits(o,EnhancedEventEmitter);var t,r,n,i=_createSuper(o);function o(e,t,r){var n,a=r.businessId;return _classCallCheck(this,o),_defineProperty(_assertThisInitialized(n=i.call(this)),"_mediaServerClient",void 0),_defineProperty(_assertThisInitialized(n),"_appId",void 0),_defineProperty(_assertThisInitialized(n),"_reconnectTimer",void 0),_defineProperty(_assertThisInitialized(n),"remoteStreams",void 0),_defineProperty(_assertThisInitialized(n),"_businessId",void 0),n.id=e,n._appId=t,n.remoteStreams=new map2,n._businessId=a,n}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({id:this.id,avSync:!0,enableFallbackHandler:isFallbackMode(this._appId)}),this._businessId&&(this._mediaServerClient.businessId=this._businessId),this._bindEvents(),e.next=5,this._mediaServerClient.connect(this._appId);case 5: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(this.id,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 map2,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=window.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(c,eventemitter3.exports.EventEmitter);var t,r,n,i,o,a,s=_createSuper(c);function c(e){var t;return _classCallCheck(this,c),_defineProperty(_assertThisInitialized(t=s.call(this)),"_audioLevelFetcher",void 0),_defineProperty(_assertThisInitialized(t),"_playbackDeviceTestTimer",void 0),_defineProperty(_assertThisInitialized(t),"_audioElement",void 0),_defineProperty(_assertThisInitialized(t),"_audioTrack",void 0),_defineProperty(_assertThisInitialized(t),"_mediaRecorder",void 0),_defineProperty(_assertThisInitialized(t),"_recoderTimer",void 0),_defineProperty(_assertThisInitialized(t),"_isAudioPlaybackDeviceTesting",!1),_defineProperty(_assertThisInitialized(t),"_isAudioDeviceRecordTesting",!1),_defineProperty(_assertThisInitialized(t),"_audioCaptureAndRecoderResolve",void 0),_defineProperty(_assertThisInitialized(t),"_onAutoplayFailed",void 0),_defineProperty(_assertThisInitialized(t),"_audioPlaybackDeviceId",void 0),t._extensionManager=e,t}return _createClass(c,[{key:"audioTrack",get:function(){return this._audioTrack}},{key:"startAudioPlaybackDeviceTest",value:(a=_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=14;break;case 9:throw e.prev=9,e.t0=e.catch(4),logger$3.print("startAudioPlaybackDeviceTest()","error",e.t0),this.stopAudioPlaybackDeviceTest(),e.t0;case 14:this._startEmitAudioPlaybackDeviceTestVolume(r);case 15:case"end":return e.stop()}}),e,this,[[4,9]])}))),function(e,t){return a.apply(this,arguments)})},{key:"stopAudioPlaybackDeviceTest",value:function(){this._isAudioPlaybackDeviceTesting&&(logger$3.print("stopAudioPlaybackDeviceTest()","Invoke"),this._isAudioPlaybackDeviceTesting=!1,this._stopEmitAudioPlaybackDeviceTestVolume(),this._destroyAudioElement())}},{key:"startAudioDeviceRecordTest",value:(o=_asyncToGenerator(_regeneratorRuntime().mark((function e(t,r,n){var i=this;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(window.MediaRecorder){e.next=2;break}throw new SDKError(ErrorCode.NOT_SUPPORTED,"Your browser does not support MediaRecorder.");case 2:if(!this._isAudioDeviceRecordTesting){e.next=4;break}throw new SDKError(ErrorCode.REPEAT_DEVICE_TEST,"device test cannot be called repeatedly at the same time.");case 4: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"')),i._stopAudioCaptureAndRecoder()}),MAX_RECORDER_DURATION),e.prev=7,this._onAutoplayFailed=r,e.next=11,this._startAudioCaptureAndRecoder(t,null!=n?n:100);case 11:e.next=18;break;case 13:throw e.prev=13,e.t0=e.catch(7),this._isAudioDeviceRecordTesting=!1,delete this._onAutoplayFailed,e.t0;case 18:delete this._audioCaptureAndRecoderResolve;case 19:case"end":return e.stop()}}),e,this,[[7,13]])}))),function(e,t,r){return o.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()),delete this._onAutoplayFailed}},{key:"getRecordTrack",value:function(){return this._audioTrack}},{key:"setSinkId",value:(i=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){var r;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(logger$3.print("setSinkId()","Invoke"),void 0!==HTMLAudioElement.prototype.setSinkId){e.next=3;break}throw new SDKError(ErrorCode.NOT_SUPPORTED,"setSinkId not supported by current browser");case 3:return e.next=5,dd.getDeviceById(t);case 5:if(r=e.sent){e.next=8;break}throw new SDKError(ErrorCode.INVALID_DEVICE_ID,"audio playback device id ".concat(t," is invalid"));case 8:return this._audioPlaybackDeviceId=t,this._setAudioCtxSinkId(),e.abrupt("return",r);case 11:case"end":return e.stop()}}),e,this)}))),function(e){return i.apply(this,arguments)})},{key:"getSinkId",value:function(){return this._audioPlaybackDeviceId}},{key:"destroy",value:function(){logger$3.print("destroy()","Invoke"),_get(_getPrototypeOf(c.prototype),"removeAllListeners",this).call(this),this.stopAudioPlaybackDeviceTest(),this.stopAudioDevicePlayTest()}},{key:"_playAudioFile",value:(n=_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 logger$3.print("_playAudioFile()",concat$2(n="Invoke url=".concat(t,"; loop=")).call(n,r.loop)),e.abrupt("return",new promise((function(e,n){var o=createElement("audio",{attributes:{src:t,crossOrigin:"anonymous"}});i._audioElement=o,o.loop=r.loop,i._audioLevelFetcher=new AudioLevelFetcher(o),o.onplaying=function(){o.onplaying=null,logger$3.print("_playAudioFile()","onplaying"),e()},o.onerror=function(){var e=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){var r,i;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:logger$3.print("_playAudioFile()","onerror",t),i=t.message||(null==o||null===(r=o.error)||void 0===r?void 0:r.message),n(new SDKError(ErrorCode.LOAD_RESOURCES_FAILED,"Failed to play recorded audio"+(i?", reason: ".concat(i):".")));case 3:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),i._setAudioCtxSinkId().then((function(){var e,t;return null===(e=o.play())||void 0===e||null===(t=e.catch)||void 0===t?void 0:t.call(e,(function(e){var t;logger$3.print("_playAudioFile()","autoplay error",e);var r=concat$2(t="Failed to play recorded audio, ".concat(e.name,": ")).call(t,e.message);"NotAllowedError"===e.name&&i._onAutoplayFailed?i._onAutoplayFailed((function(){var e;return promise.all([null===(e=i._audioLevelFetcher)||void 0===e?void 0:e.resume(),o.play()])})):n(new SDKError(ErrorCode.LOAD_RESOURCES_FAILED,r))}))}))})));case 2:case"end":return e.stop()}}),e)}))),function(e,t){return n.apply(this,arguments)})},{key:"_destroyAudioElement",value:function(){this._audioElement&&(logger$3.print("_destroyAudioElement()","Invoke"),this._audioElement.onplaying=null,this._audioElement.onerror=null,this._audioElement.src="",delete this._audioElement,"function"==typeof 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._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:(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 e.next=2,createMicrophoneAudioTrack({},this._extensionManager);case 2:return this._audioTrack=e.sent,this._audioTrack.setVolume(r),n=new MediaStream([this._audioTrack.getTrack("preprocessing")]),logger$3.print("startAudioDeviceRecordTest()","create microphone track success!"),e.abrupt("return",new promise((function(e,r){var o,a;"function"==typeof MediaRecorder.isTypeSupported&&(o=find$2(a=["audio/webm","audio/mp4"]).call(a,(function(e){return MediaRecorder.isTypeSupported(e)})),logger$3.print("startAudioDeviceRecordTest()","use mimeType: ".concat(o))),i._mediaRecorder=new MediaRecorder(n,o?{mimeType:o}:void 0);var s=i._mediaRecorder.mimeType;i._mediaRecorder.ondataavailable=function(){var n=_asyncToGenerator(_regeneratorRuntime().mark((function n(o){var a,c;return _regeneratorRuntime().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(!i._isAudioDeviceRecordTesting){n.next=16;break}return logger$3.print("startAudioDeviceRecordTest()","get recorded file(mimeType: ".concat(s,").")),c=new Blob([o.data],{type:s}),n.prev=3,n.next=6,i._playAudioFile(url.createObjectURL(c),{loop:!1});case 6:n.next=11;break;case 8:return n.prev=8,n.t0=n.catch(3),n.abrupt("return",r(n.t0));case 11:i._startEmitAudioPlaybackDeviceTestVolume(t),null===(a=i._audioElement)||void 0===a||a.addEventListener("ended",(function(){i.stopAudioDevicePlayTest(),e()})),i._audioCaptureAndRecoderResolve=e,n.next=17;break;case 16:e();case 17:case"end":return n.stop()}}),n,null,[[3,8]])})));return function(e){return n.apply(this,arguments)}}(),i._mediaRecorder.onerror=function(e){r(new SDKError(ErrorCode.AUDIO_DEVICE_TEST_FAILED,e.message||"mediaRecorder error"))},i._mediaRecorder.start()})));case 7:case"end":return e.stop()}}),e,this)}))),function(e,t){return r.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}},{key:"_setAudioCtxSinkId",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:if(t=this._audioPlaybackDeviceId){"default"===t&&(t="");try{null===(r=audioContextManager.getAudioContextInstance())||void 0===r||null===(n=r.setSinkId)||void 0===n||n.call(r,t),logger$3.print("setSinkId","ctx.sinkId=".concat(t))}catch(e){logger$3.print("setSinkId",concat$2(i="failed, ".concat(e.name," - ")).call(i,e.message))}}case 2:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})}]),c}(),AudioProfileManager=function(){function e(t){_classCallCheck(this,e),_defineProperty(this,"_roomId",void 0),_defineProperty(this,"_constraints",{}),_defineProperty(this,"_profile",void 0),this._appId=t}return _createClass(e,[{key:"setRoomId",value:function(e){this._roomId=e}},{key:"setAudioProfile",value:function(e){this._profile=e}},{key:"getOpusConfigStr",value:function(){var e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",r=sdkCache.getEngineWebConfig(this._appId,this._roomId||""),n=r.audio_encode,i=this.getConstraints(),o=i.sampleRate,a=i.channelCount,s="number"==typeof o?o:null==o?void 0:o.exact,c="number"==typeof a?a:null==a?void 0:a.exact,l={};t.split(";").forEach((function(e){var t=_slicedToArray(e.split("="),2),r=t[0],n=t[1];r&&n&&(l[r]=n)}));var u=(null==n?void 0:n.bitrate)||this._getConfigByAudioProfile().bitrate;u&&(l.maxaveragebitrate=u);var d=(null==n?void 0:n.enc_sample_rate)||s;d&&(l["sprop-maxcapturerate"]=d);var p=(null==n?void 0:n.playback_rate)||s;return p&&(l.maxplaybackrate=p),(c&&c>1||null!=n&&n.stereo)&&(l["sprop-stereo"]=1,l.stereo=1),null!=n&&n.dtx&&(l.usedtx=1),map$6(e=keys$8(l)).call(e,(function(e){var t;return concat$2(t="".concat(e,"=")).call(t,l[e])})).join(";")}},{key:"updateConstraints",value:function(e){this._constraints=_objectSpread2(_objectSpread2({},this._constraints),e)}},{key:"getConstraints",value:function(){var e=_objectSpread2({},this._constraints),t=sdkCache.getEngineWebConfig(this._appId,this._roomId||"").audio_capture;isUndefined(null==t?void 0:t.sample_rate)||(e.sampleRate=t.sample_rate),isUndefined(null==t?void 0:t.channel)||(e.channelCount=t.channel),isUndefined(null==t?void 0:t.agc)||(e.autoGainControl=t.agc),isUndefined(null==t?void 0:t.ans)||(e.noiseSuppression=t.ans),isUndefined(null==t?void 0:t.aec)||(e.echoCancellation=t.aec);var r=this._getConfigByAudioProfile(),n=r.sampleRate,i=r.channel;return isUndefined(e.sampleRate)&&!isUndefined(n)&&(e.sampleRate=n),isUndefined(e.channelCount)&&!isUndefined(i)&&(e.channelCount=i),e}},{key:"_getConfigByAudioProfile",value:function(){var e={};switch(this._profile){case AudioProfileType.fluent:e.sampleRate=16e3,e.bitrate=24e3;break;case AudioProfileType.standard:e.sampleRate=48e3,e.bitrate=48e3;break;case AudioProfileType.hd:e.sampleRate=48e3,e.bitrate=128e3,e.channel=2;break;case AudioProfileType.standardStereo:e.sampleRate=48e3,e.bitrate=8e4,e.channel=2;break;case AudioProfileType.hdMono:e.sampleRate=48e3,e.bitrate=128e3}return e}}]),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,l,u,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 l=e.sent,logger$2.print("takeSnapshot","success, cost ".concat(Date.now()-s,"ms")),e.abrupt("return",l);case 16:if(!window.ImageCapture){e.next=29;break}if("live"!==(u=new window.ImageCapture(t)).track.readyState||!u.track.enabled||u.track.muted){e.next=29;break}return logger$2.print("takeSnapshot","use ImageCapture"),e.t0=a,e.next=23,u.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)}}(),getDefaultValue=function(){return{url:"",video:{codec:TRANSCODING_VIDEO_CODEC.H264,width:640,height:360,fps:15,gop:2,kBitRate:getKBitRate(640,360,15)},audio:{codec:"AAC",kBitRate:64,sampleRate:48e3,channels:2,AACProfile:AAC_PROFILE.LC},layout:{regions:[],appData:"",backgroundColor:"#000000"}}};function getKBitRate(e,t,r){return e*t<=288e3?r<=15?800:1200:e*t<=864e3?r<=15?1200:1800:e*t<=1152e3?r<=15?1600:2400:e*t<=2592e3?r<=15?2500:3750:r<=15?3300:5e3}function checkRtmpUrl(e){if("string"!=typeof e||!/^rtmps?:\/\//.test(e))throw new SDKError(ErrorCode.INVALID_PARAMS,"Invalid rtmp address")}function checkTranscodeRegions(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];if(null==e||!e.length)throw new SDKError(ErrorCode.INVALID_PARAMS,"regions should not be empty.");var t,r=_createForOfIteratorHelper(e);try{for(r.s();!(t=r.n()).done;){var n=t.value;if("string"!=typeof n.userId)throw new SDKError(ErrorCode.INVALID_PARAMS,"region.userId(".concat(n.userId,") should be a string."));if("boolean"!=typeof n.isScreenStream)throw new SDKError(ErrorCode.INVALID_PARAMS,"region.isScreenStream(".concat(n.isScreenStream,") should be a boolean."))}}catch(e){r.e(e)}finally{r.f()}}function getTranscodeControlMessage(e,t){var r,n,i,o=function(e,r){var n=reduce3(e).call(e,(function(e,t){return null==e?void 0:e[t]}),t),i=reduce3(e).call(e,(function(e,t){return null==e?void 0:e[t]}),getDefaultValue());return n&&r(n)?n:i},a=function(e){return e%2==0?e:e+1},s=a(o(["video","width"],(function(e){return e>=2&&e<=1920}))),c=a(o(["video","height"],(function(e){return e>=2&&e<=1920}))),l=o(["video","fps"],(function(e){return e>=1&&e<=60})),u=(null===(r=t.video)||void 0===r?void 0:r.kBitRate)||0,d=o(["audio","sampleRate"],(function(e){var t;return!!find$2(t=[32e3,44100,48e3]).call(t,(function(t){return t===e||t/1e3===e}))}));return{type:"transcode",action:e,transcodeMeta:{transcode:{url:t.url},control:{protocol:"2.0"},audio:{codec:o(["audio","codec"],(function(e){return"AAC"===e})),bitRate:1e3*o(["audio","kBitRate"],(function(e){return e>=32&&e<=192})),sampleRate:d<100?1e3*d:d,channels:o(["audio","channels"],(function(e){var t;return includes4(t=[1,2]).call(t,e)})),profile:o(["audio","AACProfile"],(function(e){var t;return includes4(t=[AAC_PROFILE.LC,AAC_PROFILE.HEv1,AAC_PROFILE.HEv2]).call(t,e)}))},video:{codec:o(["video","codec"],(function(e){var t;return includes4(t=["H264","H265"]).call(t,e)})),fps:l,gop:o(["video","gop"],(function(e){return e>=1&&e<=5}))*l,bitRate:1e3*(u>=16&&u<=1e4?u:getKBitRate(s,c,l)),width:s,height:c},layout:{canvas:{bgnd:o(["layout","backgroundColor"],(function(e){return/^#([0-9a-fA-F]{6}|[0-9a-fA-F]{3})$/.test(e)}))},regions:(null===(n=t.layout)||void 0===n||null===(i=n.regions)||void 0===i?void 0:map$6(i).call(i,(function(e){var t,r;return{alpha:!e.alpha||+e.alpha>1||+e.alpha<=0?1:+e.alpha,uid:e.userId,zorder:!e.zorder||+e.zorder<0||+e.zorder>100?0:+e.zorder,x:!e.x||+e.x>=1||+e.x<0?0:+e.x,y:!e.y||+e.y>=1||+e.y<0?0:+e.y,w:!e.w||+e.w>1||+e.w<=0?1:+e.w,h:!e.h||+e.h>1||+e.h<=0?1:+e.h,renderMode:e.renderMode&&includes4(t=[1,2,3]).call(t,e.renderMode)?e.renderMode:1,contentControl:e.contentControl&&includes4(r=[0,1,2]).call(r,e.contentControl)?e.contentControl:0,screen:!!e.isScreenStream}})))||[],app_data:o(["layout","appData"],(function(e){return"string"==typeof e}))}}}}function checkStartParams(e){var t;checkRtmpUrl(e.url),checkTranscodeRegions(null===(t=e.layout)||void 0===t?void 0:t.regions)}function checckUpdateParams(e){var t;e.url&&checkRtmpUrl(e.url),checkTranscodeRegions(null===(t=e.layout)||void 0===t?void 0:t.regions)}function getStartParams(e){return getTranscodeControlMessage("started",e)}function getUpdateParams(e){return getTranscodeControlMessage("layoutChanged",e)}var remoteAudioReplayTimer,LiveTranscoding={getDefaultValue:getDefaultValue,checkStartParams:checkStartParams,checckUpdateParams:checckUpdateParams,getStartParams:getStartParams,getUpdateParams:getUpdateParams},replayRemoteAudioWorkaround=function(e){remoteAudioReplayTimer&&clearTimeout(remoteAudioReplayTimer),remoteAudioReplayTimer=setTimeout((function(){var t,r=_createForOfIteratorHelper(e);try{for(r.s();!(t=r.n()).done;){var n=_slicedToArray(t.value,2),i=n[0],o=n[1];null!=i&&startsWith2(i).call(i,"mux")&&o.pause()}}catch(e){r.e(e)}finally{r.f()}var a,s=_createForOfIteratorHelper(e);try{for(s.s();!(a=s.n()).done;){var c=_slicedToArray(a.value,2),l=c[0],u=c[1];null!=l&&startsWith2(l).call(l,"mux")&&u.manuallyPlay()}}catch(e){s.e(e)}finally{s.f()}}),2e3)},__defProp=defineProperty$a,__getOwnPropDesc=getOwnPropertyDescriptor$1,__decorateClass3=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(ve,EnhancedEventEmitter);var t,r,n,i,o,a,s,c,l,u,d,p,_,h,f,m,v,g,y,S,T,$,E,b,I,R,C,A,k,P,O,w,M,D,x,N,L,U,V,F,j,B,G,z,H,K,W,Y,q,X,Z,Q,J,ee,te,re,ne,ie,oe,ae,se,ce,le,ue,de,pe,_e,he,fe,me=_createSuper(ve);function ve(e,t,r){var n;return _classCallCheck(this,ve),_defineProperty(_assertThisInitialized(n=me.call(this)),"monitor",void 0),_defineProperty(_assertThisInitialized(n),"_room",void 0),_defineProperty(_assertThisInitialized(n),"_publicStreamManager",void 0),_defineProperty(_assertThisInitialized(n),"_appId",void 0),_defineProperty(_assertThisInitialized(n),"_businessId",void 0),_defineProperty(_assertThisInitialized(n),"_visibility",!0),_defineProperty(_assertThisInitialized(n),"_localVideoTrack",void 0),_defineProperty(_assertThisInitialized(n),"_localAudioTrack",void 0),_defineProperty(_assertThisInitialized(n),"_localImgVideoTrack",void 0),_defineProperty(_assertThisInitialized(n),"_localImgScreenTrack",void 0),_defineProperty(_assertThisInitialized(n),"_localScreenVideoTrack",void 0),_defineProperty(_assertThisInitialized(n),"_localScreenAudioTrack",void 0),_defineProperty(_assertThisInitialized(n),"_tempMixingAudioTrack",void 0),_defineProperty(_assertThisInitialized(n),"_localAudioVolume",100),_defineProperty(_assertThisInitialized(n),"_localScreenAudioVolume",100),_defineProperty(_assertThisInitialized(n),"_remoteAudioVolume",new map2),_defineProperty(_assertThisInitialized(n),"_remoteScreenAudioVolume",new map2),_defineProperty(_assertThisInitialized(n),"_publicAudioVolume",new map2),_defineProperty(_assertThisInitialized(n),"_videoPlayer",void 0),_defineProperty(_assertThisInitialized(n),"_screenPlayer",void 0),_defineProperty(_assertThisInitialized(n),"_remoteVideoPlayer",new map2),_defineProperty(_assertThisInitialized(n),"_remoteScreenPlayer",new map2),_defineProperty(_assertThisInitialized(n),"_remoteAudioPlayer",new map2),_defineProperty(_assertThisInitialized(n),"_remoteScreenAudioPlayer",new map2),_defineProperty(_assertThisInitialized(n),"_publicStreamAudioPlayer",new map2),_defineProperty(_assertThisInitialized(n),"_publicStreamVideoPlayer",new map2),_defineProperty(_assertThisInitialized(n),"_publicStreamIds",new map2),_defineProperty(_assertThisInitialized(n),"_roomConfig",void 0),_defineProperty(_assertThisInitialized(n),"_videoStreamConstraints",defaultVideoEncoderConfig),_defineProperty(_assertThisInitialized(n),"_audioStreamConstraints",{}),_defineProperty(_assertThisInitialized(n),"_enableSimulcast",!1),_defineProperty(_assertThisInitialized(n),"_videoStreamEncodeConfig",[defaultVideoEncoderConfig]),_defineProperty(_assertThisInitialized(n),"_screenStreamEncodeConfig",[defaultScreenEncoderConfig]),_defineProperty(_assertThisInitialized(n),"_dummyMainImage",void 0),_defineProperty(_assertThisInitialized(n),"_dummyScreenImage",void 0),_defineProperty(_assertThisInitialized(n),"_trackSourceType",void 0),_defineProperty(_assertThisInitialized(n),"_liveTranscodeConfig",void 0),_defineProperty(_assertThisInitialized(n),"_useCloudProxy",void 0),_defineProperty(_assertThisInitialized(n),"_startCloudProxyTimestamp",void 0),_defineProperty(_assertThisInitialized(n),"_localVideoDeviceId",void 0),_defineProperty(_assertThisInitialized(n),"_localAudioDeviceId",void 0),_defineProperty(_assertThisInitialized(n),"_pauseAllSubscribeState",{audio:void 0,video:void 0,resumeStreamIds:{}}),_defineProperty(_assertThisInitialized(n),"_audioVolumeIndicationTimer",void 0),_defineProperty(_assertThisInitialized(n),"_dummyMainTimer",void 0),_defineProperty(_assertThisInitialized(n),"_dummyScreenTimer",void 0),_defineProperty(_assertThisInitialized(n),"_audioPropertiesReportTimer",null),_defineProperty(_assertThisInitialized(n),"_mirrorType",MirrorType.MIRROR_TYPE_RENDER),_defineProperty(_assertThisInitialized(n),"_audioMixingManager",void 0),_defineProperty(_assertThisInitialized(n),"_pubLock",void 0),_defineProperty(_assertThisInitialized(n),"_rtmClient",void 0),_defineProperty(_assertThisInitialized(n),"_messageStatisticsObserver",void 0),_defineProperty(_assertThisInitialized(n),"_tempRoomInfo",void 0),_defineProperty(_assertThisInitialized(n),"_originIceConfigRequestUrls",void 0),_defineProperty(_assertThisInitialized(n),"_originConfigServerUrls",void 0),_defineProperty(_assertThisInitialized(n),"_originLogServerUrl",void 0),_defineProperty(_assertThisInitialized(n),"_extensionManager",void 0),_defineProperty(_assertThisInitialized(n),"_audioDeviceManager",void 0),_defineProperty(_assertThisInitialized(n),"_audioProfileManager",void 0),_defineProperty(_assertThisInitialized(n),"_remoteVideoConfig",new map2),_defineProperty(_assertThisInitialized(n),"_userPriorityMap",new map2),_defineProperty(_assertThisInitialized(n),"_subscribeFallbackOption",void 0),_defineProperty(_assertThisInitialized(n),"_cameraCapturing",!1),_defineProperty(_assertThisInitialized(n),"_interruptCameraCapture",!1),_defineProperty(_assertThisInitialized(n),"_micCapturing",!1),_defineProperty(_assertThisInitialized(n),"_interruptMicCapture",!1),_defineProperty(_assertThisInitialized(n),"_avSync",!0),_defineProperty(_assertThisInitialized(n),"_config",void 0),_defineProperty(_assertThisInitialized(n),"_needClosePreTrack",!1),_defineProperty(_assertThisInitialized(n),"_updateMixAudioTrack",function(){var e=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){var r,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()"),n._localAudioTrack){e.next=5;break}return t&&(n._tempMixingAudioTrack={track:t,type:i}),e.abrupt("return");case 5:if(t?(n._localAudioTrack.mixType=i,n._localAudioTrack.mixedAudioTrack=t):(delete n._localAudioTrack.mixType,delete n._localAudioTrack.mixedAudioTrack),null===(r=n._room)||void 0===r||!r.hasPublished){e.next=9;break}return e.next=9,n._updatePublish();case 9:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}()),_defineProperty(_assertThisInitialized(n),"_onAudioMixingMessage",(function(e){n.safeEmit(EngineEventsTypes.onAudioMixingStateChanged,e)})),_defineProperty(_assertThisInitialized(n),"_onAudioMixingAutoplayFailed",(function(e){n.safeEmit(EngineEventsTypes.onAutoplayFailed,e)})),n.id=t,n._appId=e,n._pubLock=new PromiseLock("pubLock"),n._addDeviceEventHandler(),n._extensionManager=new ExtensionManager(t),n._audioDeviceManager=new AudioDeviceManager(n._extensionManager),n._audioMixingManager=new AudioMixingManager({getLocalAudioTrack:function(){return n._localAudioTrack},updateLocalAudioTrack:n._updateMixAudioTrack,emitMessage:n._onAudioMixingMessage,onAutoPlayFailed:n._onAudioMixingAutoplayFailed},t),n._audioProfileManager=new AudioProfileManager(e),window.__rtc_engine__=_assertThisInitialized(n),window["__rtc_engine__".concat(Math.floor(100*Math.random()+1))]=_assertThisInitialized(n),n._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},n._config=r,n._rtmClient=new RTMClient(t,e),n._handleRTMClient(n._rtmClient),n._useCloudProxy=!1,n._handleAudioDeviceManager(),n._messageStatisticsObserver=new MessageStatisticsObserver(t),n.monitor=getMonitor(t),RTSMsgReportor.createRTSMsgReportor(n.id),n._getServerConfig(),n}return _createClass(ve,[{key:"appId",get:function(){return this._appId},set:function(e){this._appId=e}},{key:"updateToken",value:(fe=_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("updateToken()","token: %s",t),checkString(t,"token"),!this.waitForNewToken||!this._tempRoomInfo){e.next=8;break}return n=this._tempRoomInfo,i=n.config,o=n.userInfo,a=n.roomId,delete this._tempRoomInfo,e.next=7,this.joinRoom(t,a,o,i);case 7:return e.abrupt("return",e.sent);case 8:if(this._room){e.next=10;break}throw new SDKError(ErrorCode.UPDATE_TOKEN_BEFORE_JOIN,"update token before join room");case 10:return e.next=12,null===(r=this._room)||void 0===r?void 0:r.updateToken(t);case 12:case"end":return e.stop()}}),e,this)}))),function(e){return fe.apply(this,arguments)})},{key:"setVideoCaptureDevice",value:(he=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){var r,n,i,o=this;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=assignIn$1({},this._videoStreamConstraints),"user"===t||"environment"===t||"left"===t||"right"===t?(delete r.deviceId,r.facingMode=t):r.deviceId={exact:t},isAndroid&&chromeVersion&&chromeVersion>=85&&chromeVersion<=91&&(null===(n=this._videoPlayer)||void 0===n||n.removeTrack()),this._needClosePreTrack&&(this._removeLocalTrackEvents(this._localVideoTrack),this._localVideoTrack.close(),delete this._localVideoTrack),logger$1.print("setVideoCaptureDevice()","start createCameraVideoTrack..."),e.next=12,createCameraVideoTrack(r,this._extensionManager).catch((function(e){if(o._localVideoTrack&&!o._localVideoTrack.dummy)return logger$1.print("setVideoCaptureDevice()","createCameraVideoTrack failed, stop pre VideoTrack."),o._removeLocalTrackEvents(o._localVideoTrack),o._localVideoTrack.close(),delete o._localVideoTrack,createCameraVideoTrack(r,o._extensionManager).then((function(e){return o._needClosePreTrack=!0,e})).catch(_asyncToGenerator(_regeneratorRuntime().mark((function t(){var r;return _regeneratorRuntime().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return logger$1.print("setVideoCaptureDevice()","createCameraVideoTrack failed, rollback."),t.next=3,createCameraVideoTrack(o._videoStreamConstraints,o._extensionManager);case 3:throw r=t.sent,o._switchTrack(r),e;case 6:case"end":return t.stop()}}),t)}))));throw e}));case 12:return i=e.sent,logger$1.print("setVideoCaptureDevice()","createCameraVideoTrack success."),this._videoStreamConstraints=r,this._localVideoTrack&&(this._removeLocalTrackEvents(this._localVideoTrack),this._localVideoTrack.close()),e.next=18,this._switchTrack(i);case 18:case"end":return e.stop()}}),e,this)}))),function(e){return he.apply(this,arguments)})},{key:"setAudioCaptureDevice",value:(_e=_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 this._audioProfileManager.updateConstraints({deviceId:{exact:t}}),this._localAudioTrack.close(),this._removeLocalTrackEvents(this._localAudioTrack),e.prev=8,this._micCapturing=!0,e.next=12,createMicrophoneAudioTrack(this._audioProfileManager.getConstraints(),this._extensionManager);case 12:if(n=e.sent,!this._interruptMicCapture){e.next=17;break}return this._interruptMicCapture=!1,n.close(),e.abrupt("return");case 17:if(this._initLocalTrackEvents(n),this._localAudioTrack=n,this._localAudioTrack.setVolume(this._localAudioVolume),this._room){e.next=22;break}return e.abrupt("return");case 22:if(null===(r=this._room)||void 0===r||!r.hasPublished){e.next=25;break}return e.next=25,this._updatePublish();case 25:return e.prev=25,this._micCapturing=!1,e.finish(25);case 28:case"end":return e.stop()}}),e,this,[[8,,25,28]])}))),function(e){return _e.apply(this,arguments)})},{key:"_addDeviceEventHandler",value:function(){dd.on(EngineEventsTypes.onVideoDeviceStateChanged,this._onVideoDeviceStateChange.bind(this)),dd.on(EngineEventsTypes.onAudioDeviceStateChanged,this._onAudioDeviceStateChange.bind(this))}},{key:"_addHandlerEventHandler",value:function(){var e,t,r,n,i,o,a,s,c,l,u,d,p,_,h,f,m,v,g,y,S,T,$,E,b,I,R,C,A,k,P,O=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===(l=this._room)||void 0===l||l.on(SignalEvent.ON_USER_TOKEN_WILL_EXPIRE,this._onUserTokenWillExpire.bind(this)),null===(u=this._room)||void 0===u||u.on(SignalEvent.POST_PROCESSING_MESSAGE,(function(e){"2.0"===e.protocol?O._onStreamMixingEvent({error:e.error,event:e.eventType,message:e.message}):"publicStreamCallback"===e.type?O._onPushPublicStreamResult(e):"transcodeStatusCallback"===e.type&&O._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===(h=this._room)||void 0===h||h.on(RoomEvent.REMOVE_PUSH_TRACK,this._onRemovePushTrack.bind(this)),null===(f=this._room)||void 0===f||f.on(RoomEvent.ON_PUBLISH_RESULT,(function(e){var t;null!==(t=O._room)&&void 0!==t&&t._roomConfig.isAutoPublish&&O.safeEmit(EngineEventsTypes.onAutoPublishResult,e)})),null===(m=this._room)||void 0===m||m.on(RoomEvent.ON_REMOTE_STREAM_STATS,(function(e){O.safeEmit(EngineEventsTypes.onRemoteStreamStats,e)})),null===(v=this._room)||void 0===v||v.on(RoomEvent.ON_LOCAL_STREAM_STATS,(function(e){O.safeEmit(EngineEventsTypes.onLocalStreamStats,e)})),null===(g=this._room)||void 0===g||g.on(RoomEvent.ON_SUBTITLE_STATE_CHANGED,(function(e){O.safeEmit(EngineEventsTypes.onSubtitleStateChanged,e)})),null===(y=this._room)||void 0===y||y.on(RoomEvent.ON_SUBTITLE_MESSAGE_RECEIVED,(function(e){O.safeEmit(EngineEventsTypes.onSubtitleMessageReceived,e)})),null===(S=this._room)||void 0===S||S.on(RoomEvent.ON_USER_PUBLISH_STATE_CHANGE,this._onUserPublishStateChange.bind(this)),null===(T=this._room)||void 0===T||T.on(RoomEvent.ON_USER_START_AUDIO_CAPTURE,(function(e,t){var r=e.userId;O._updateAudioPlayerState(t),O.safeEmit(EngineEventsTypes.onUserStartAudioCapture,{userId:r})})),null===($=this._room)||void 0===$||$.on(RoomEvent.ON_USER_STOP_AUDIO_CAPTURE,(function(e){var t=e.userId;O.safeEmit(EngineEventsTypes.onUserStopAudioCapture,{userId:t})})),null===(E=this._room)||void 0===E||E.on(RoomEvent.ON_USER_START_VIDEO_CAPTURE,(function(e){var t=e.userId;O.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;O.safeEmit(EngineEventsTypes.onUserStopVideoCapture,{userId:t})})),null===(I=this._room)||void 0===I||I.on(RoomEvent.ON_SEI_MESSAGED_RECEIVED,(function(e){O.safeEmit(EngineEventsTypes.onSEIMessageReceived,e)})),null===(R=this._room)||void 0===R||R.on(RoomEvent.ON_REMOTE_VIDEO_SIZE_CHANGED,(function(e,t){O.safeEmit(EngineEventsTypes.onRemoteVideoSizeChanged,e,t)})),null===(C=this._room)||void 0===C||C.on(RoomEvent.ON_SIMULCAST_SUBSCRIBE_FALLBACK,(function(e){return O.safeEmit(EngineEventsTypes.onSimulcastSubscribeFallback,e)})),null===(A=this._room)||void 0===A||A.on(RoomEvent.RECONNECT_FAILED,(function(){O.safeEmit(EngineEventsTypes.onError,{errorCode:ErrorCode.RECONNECT_FAILED})})),null===(k=this._room)||void 0===k||k.on(RoomEvent.ON_VIDEO_STREAM_BANNED,(function(e){O.safeEmit(EngineEventsTypes.onVideoStreamBanned,{uid:e.uid,banned:e.banned})})),null===(P=this._room)||void 0===P||P.on(RoomEvent.ON_AUDIO_STREAM_BANNED,(function(e){O.safeEmit(EngineEventsTypes.onAudioStreamBanned,{uid:e.uid,banned:e.banned})}))}},{key:"safeEmit",value:function(e){for(var t,r,n=arguments.length,i=new Array(n>1?n-1:0),o=1;o<n;o++)i[o-1]=arguments[o];return isReportCallback(e)&&reportRtcSdkCallback(this.id,e,i),(t=_get(_getPrototypeOf(ve.prototype),"safeEmit",this)).call.apply(t,concat$2(r=[this,e]).call(r,i))}},{key:"_removeHandlerEventHandler",value:function(){var e;null===(e=this._room)||void 0===e||e.removeAllListeners()}},{key:"connect",value:(pe=_asyncToGenerator(_regeneratorRuntime().mark((function e(){return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._room){e.next=2;break}return e.abrupt("return",!1);case 2:return this._room=new Room({isAutoPublish:!0,isAutoSubscribeAudio:!0,isAutoSubscribeVideo:!0,roomProfileType:RoomProfileType.communication},{id:this.id,audioProfileManager:this._audioProfileManager,streamRTT:{},subscribeFallbackOption:this._subscribeFallbackOption,userPriority:this._userPriorityMap,avSync:this._avSync,enableFallbackHandler:isFallbackMode(this.appId)}),this._addHandlerEventHandler(),e.next=6,this._room.connect(this._appId);case 6:case"end":return e.stop()}}),e,this)}))),function(){return pe.apply(this,arguments)})},{key:"joinRoom",value:(de=_asyncToGenerator(_regeneratorRuntime().mark((function e(t,r,n,i){var o,a,s,c,l,u,d;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),checkRoomConfig(i=assignIn$1({isAutoPublish:!0,isAutoSubscribeAudio:!0,isAutoSubscribeVideo:!0,roomProfileType:RoomProfileType.communication},i)),(null===(o=this._room)||void 0===o?void 0:o.connectionState)!==MediaConnectionState.CONNECTED){e.next=8;break}throw new SDKError(ErrorCode.REPEAT_JOIN,"Already joined");case 8:return this._room||(this._room=new Room(i,{id:this.id,audioProfileManager:this._audioProfileManager,streamRTT:{},subscribeFallbackOption:this._subscribeFallbackOption,userPriority:this._userPriorityMap,avSync:this._avSync,enableFallbackHandler:isFallbackMode(this.appId)}),this._addHandlerEventHandler()),this._room.roomConfig=i,a=this._liveTranscodeConfig&&LiveTranscoding.getStartParams(this._liveTranscodeConfig),s=_objectSpread2(_objectSpread2({},n),{},{businessId:this._businessId,role:this._visibility?UserRole.NORMAL_USER:UserRole.SILENT_USER}),e.prev=12,this._useCloudProxy&&(this._startCloudProxyTimestamp=Date.now()),checkSourceLanguage(s),e.next=17,this._room.join(this._appId,r,t,s,a,this._useCloudProxy,null===(c=this._config)||void 0===c?void 0:c.expectedIDC);case 17:return u=e.sent,this._roomConfig=i,this._audioProfileManager.setRoomId(r),this._tempRoomInfo&&delete this._tempRoomInfo,null!==(l=i)&&void 0!==l&&l.isAutoPublish&&(this._visibility?this._updatePublish({invokeByJoinRoom:!0,mediaType:MediaType.AUDIO_AND_VIDEO}):this.safeEmit(EngineEventsTypes.onAutoPublishResult,{isScreen:!1,state:PublishState.PUBLISH_FAIL})),RTSMsgReportor.setRoomId(this.id,r),RTSMsgReportor.setUserId(this.id,n.userId),e.abrupt("return",u);case 27:throw e.prev=27,e.t0=e.catch(12),e.t0.code===ErrorCode.INVALID_TOKEN&&(this._tempRoomInfo={config:i,roomId:r,userInfo:s}),null===(d=this._room)||void 0===d||d.destroy(),e.t0;case 32:case"end":return e.stop()}}),e,this,[[12,27]])}))),function(e,t,r,n){return de.apply(this,arguments)})},{key:"leaveRoom",value:(ue=_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._audioProfileManager.setRoomId(),this._liveTranscodeConfig&&this.stopLiveTranscoding(),this._room=void 0,this._remoteAudioPlayer.forEach((function(e){return e.destroy()})),this._remoteAudioPlayer=new map2,this._remoteScreenAudioPlayer.forEach((function(e){return e.destroy()})),this._remoteScreenAudioPlayer=new map2,this._remoteScreenPlayer.forEach((function(e){return e.destroy()})),this._remoteScreenPlayer=new map2,this._remoteVideoPlayer.forEach((function(e){return e.destroy()})),this._remoteVideoPlayer=new map2,this._roomConfig=void 0,this._publicStreamIds=new map2,RTSMsgReportor.setRoomId(this.id,""),RTSMsgReportor.setUserId(this.id,"");case 24:case"end":return e.stop()}}),e,this)}))),function(){return ue.apply(this,arguments)})},{key:"destroy",value:function(){var e,t,r;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._videoStreamEncodeConfig=[defaultVideoEncoderConfig],this._screenStreamEncodeConfig=[defaultScreenEncoderConfig],this._pauseAllSubscribeState={audio:void 0,video:void 0,resumeStreamIds:{}},this._messageStatisticsObserver.destroy(),this.monitor.destroy(),RTSMsgReportor.destroyRTSMsgReportor(this.id),clearInterval(this._audioVolumeIndicationTimer),clearInterval(this._dummyMainTimer),clearInterval(this._dummyScreenTimer),this._audioVolumeIndicationTimer=void 0,this._stopAudioPropertiesReport(),this._localAudioTrack&&(this._removeLocalTrackEvents(this._localAudioTrack),this._localAudioTrack.close(),this._localAudioTrack=void 0),this._localVideoTrack&&(this._removeLocalTrackEvents(this._localVideoTrack),this._localVideoTrack.close(),this._localVideoTrack=void 0),this._localScreenAudioTrack&&(this._removeLocalTrackEvents(this._localScreenAudioTrack),this._localScreenAudioTrack.close(),this._localScreenAudioTrack=void 0),this._localScreenVideoTrack&&(this._removeLocalTrackEvents(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 map2,this._remoteScreenAudioPlayer.forEach((function(e){return e.destroy()})),this._remoteScreenAudioPlayer=new map2,this._remoteScreenPlayer.forEach((function(e){return e.destroy()})),this._remoteScreenPlayer=new map2,this._remoteVideoPlayer.forEach((function(e){return e.destroy()})),this._remoteVideoPlayer=new map2,this._publicStreamAudioPlayer.forEach((function(e){return e.destroy()})),this._publicStreamAudioPlayer=new map2,this._publicStreamVideoPlayer.forEach((function(e){return e.destroy()})),this._publicStreamVideoPlayer=new map2,this._roomConfig=void 0,this._audioMixingManager.destroy(),this._rtmClient.destroy(),null===(r=this._publicStreamManager)||void 0===r||r.destroy(),this._publicStreamIds=new map2,this._audioDeviceManager.destroy(),this._remoteVideoConfig=new map2,this._userPriorityMap.clear(),this._extensionManager.destroy(),this._cameraCapturing=!1,this._micCapturing=!1,this._interruptCameraCapture=!1,this._interruptMicCapture=!1,this._avSync=!0,this._localAudioVolume=100,this._localScreenAudioVolume=100,this._remoteAudioVolume.clear(),this._remoteScreenAudioVolume.clear(),this._publicAudioVolume.clear()}},{key:"publishStream",value:(le=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(logger$1.print("publishStream()","mediaType: %o",t),this._checkMediaType(t),this._assertNotInRoom(),!videoInMediaType(t)||this._localVideoTrack||!this._localImgVideoTrack){e.next=7;break}return e.next=6,createDummyVideoLocalTrack(this._localImgVideoTrack,this._extensionManager);case 6:this._localVideoTrack=e.sent;case 7:return e.next=9,this._updatePublish({mediaType:t});case 9:case"end":return e.stop()}}),e,this)}))),function(e){return le.apply(this,arguments)})},{key:"unpublishStream",value:(ce=_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 ce.apply(this,arguments)})},{key:"publishScreen",value:(se=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(logger$1.print("publishScreen()","mediaType: %o",t),this._checkMediaType(t),this._assertNotInRoom(),e.prev=3,!videoInMediaType(t)||this._localScreenVideoTrack||!this._localImgScreenTrack){e.next=8;break}return e.next=7,createDummyScreenVideoLocalTrack(this._localImgScreenTrack,this._extensionManager);case 7:this._localScreenVideoTrack=e.sent;case 8:return e.next=10,this._updateScreenPublish({mediaType:t,pubState:PubState.PUB});case 10:e.next=19;break;case 12:if(e.prev=12,e.t0=e.catch(3),!(e.t0 instanceof SDKError)){e.next=18;break}throw e.t0;case 18:throw new SDKError(ErrorCode.UNEXPECTED_ERROR,"unexpected error",e.t0);case 19:case"end":return e.stop()}}),e,this,[[3,12]])}))),function(e){return se.apply(this,arguments)})},{key:"unpublishScreen",value:(ae=_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 ae.apply(this,arguments)})},{key:"subscribeStream",value:(oe=_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 oe.apply(this,arguments)})},{key:"_subscribe",value:(ie=_asyncToGenerator(_regeneratorRuntime().mark((function e(t,r,n){var i,o,a,s,c,l,u,d,p,_,h,f,m,v,g,y;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._checkMediaType(n),this._assertNotInRoom(),n!==MediaType.AUDIO||null===(i=this._room)||void 0===i||!i.multiChatMode){e.next=5;break}return logger$1.print("subscribeStream()","due to multiChatMode return"),e.abrupt("return");case 5:if(l=this._room.remoteStreams.get(r),u=null==l?void 0:find$2(l).call(l,(function(e){return e.isScreen===t}))){e.next=9;break}throw new SDKError(ErrorCode.STREAM_NOT_EXIST,"stream not exist");case 9:return d=this._pauseAllSubscribeState.audio,p=this._pauseAllSubscribeState.video,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.hasSubscribed,h=this._remoteVideoConfig.get(r)||(null===(o=this._roomConfig)||void 0===o?void 0:o.remoteVideoConfig),u.originalMediaType=n,e.next=19,this._room.subscribe(u,n,h);case 19:audioInMediaType(n)&&this._updateAudioPlayerState(u),videoInMediaType(n)&&this._updateVideoPlayerState(u),f=0,m=0,d!==this._pauseAllSubscribeState.audio&&(this._pauseAllSubscribeState.audio?f|=MediaType.AUDIO:m|=MediaType.AUDIO),p!==this._pauseAllSubscribeState.video&&(this._pauseAllSubscribeState.video?f|=MediaType.VIDEO:m|=MediaType.VIDEO),f&&this.pauseAllSubscribedStream(f),m&&this.resumeAllSubscribedStream(m),this._pauseAllSubscribeState.resumeStreamIds[u.streamId]=u.streamId,!t&&(null!==(a=this._roomConfig)&&void 0!==a&&a.isAutoSubscribeAudio||null!==(s=this._roomConfig)&&void 0!==s&&s.isAutoSubscribeVideo)&&(u.audioTrack||u.videoTrack)&&(v={userId:r,isScreen:!1,state:SubscribeState.SUBSCRIBE_SUCC},this.safeEmit(EngineEventsTypes.onAutoSubscribeResult,v)),null!==(c=this._room)&&void 0!==c&&c.multiChatMode||_||!audioInMediaType(n)||!u.hasAudio||null===(g=u.observer)||void 0===g||g.setSubscribeAudio(!0),!_&&videoInMediaType(n)&&u.hasVideo&&(null===(y=u.observer)||void 0===y||y.setSubscribeVideo(!0));case 31:case"end":return e.stop()}}),e,this)}))),function(e,t,r){return ie.apply(this,arguments)})},{key:"unsubscribeStream",value:(ne=_asyncToGenerator(_regeneratorRuntime().mark((function e(t,r){return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:logger$1.print("unsubscribeStream()","userId: %o, mediaType: %o",t,r),this._unsubscribe(!1,t,r);case 2:case"end":return e.stop()}}),e,this)}))),function(e,t){return ne.apply(this,arguments)})},{key:"subscribeScreen",value:(re=_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 re.apply(this,arguments)})},{key:"unsubscribeScreen",value:(te=_asyncToGenerator(_regeneratorRuntime().mark((function e(t,r){return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:logger$1.print("unsubscribeScreen() userId: %o, mediaType: %o",t,r),this._unsubscribe(!0,t,r);case 2:case"end":return e.stop()}}),e,this)}))),function(e,t){return te.apply(this,arguments)})},{key:"_unsubscribe",value:function(e,t,r,n){var i,o=this;if(this._checkMediaType(r),this._assertNotInRoom(),r!==MediaType.AUDIO||null===(i=this._room)||void 0===i||!i.multiChatMode){var a=this._room.remoteStreams.get(t),s=null==a?void 0:find$2(a).call(a,(function(t){return t.isScreen===e}));if(null==s||!s.hasSubscribed)throw new SDKError(ErrorCode.STREAM_NOT_EXIST,"stream not exist");if(isAndroid&&chromeVersion&&chromeVersion>=85&&chromeVersion<=91&&r!==MediaType.AUDIO)(e?this._remoteScreenPlayer.get(t):this._remoteVideoPlayer.get(t)).stop();return this._room.unsubscribe(s,r).then((function(){n||delete o._pauseAllSubscribeState.resumeStreamIds[s.streamId]}))}logger$1.print("subscribeStream()","due to multiChatMode return")}},{key:"setRemoteVideoConfig",value:(ee=_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 ee.apply(this,arguments)})},{key:"startVideoCapture",value:(J=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){var r,n,i,o,a,s,c,l,u,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._trackSourceType.video!==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._cameraCapturing||this._localVideoTrack&&!this._localVideoTrack.dummy)){e.next=8;break}throw new SDKError(ErrorCode.REPEAT_CAPTURE,"Has already capture");case 8: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=11,this._cameraCapturing=!0,e.next=15,createCameraVideoTrack(i,this._extensionManager);case 15:if(s=e.sent,!this._interruptCameraCapture){e.next=21;break}throw this._interruptCameraCapture=!1,this._removeLocalTrackEvents(s),s.close(),new SDKError(ErrorCode.INTERRUPT,"interrupt by stopVideoCapture");case 21:if(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(),l={width:o.width,height:o.height},this._localVideoTrack.resolution=l,setTimeout((function(){return d.safeEmit(EngineEventsTypes.onLocalVideoSizeChanged,{streamIndex:StreamIndex.STREAM_INDEX_MAIN,info:l})}))),this._room){e.next=28;break}return e.abrupt("return",o);case 28:return e.prev=28,this._cameraCapturing=!1,e.finish(28);case 31:return u=this._room._roomConfig.isAutoPublish,(this._room.hasPublished||u)&&(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 35:case"end":return e.stop()}}),e,this,[[11,,28,31]])}))),function(e){return J.apply(this,arguments)})},{key:"stopVideoCapture",value:(Q=_asyncToGenerator(_regeneratorRuntime().mark((function e(){var t,r,n,i,o,a,s;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(),this._localVideoTrack&&(this._localVideoTrack.dummy||((a=this._extensionManager.getPluginByName(RTCExtensionType.PRE_PROCESSING,"RTCBeautyExtension"))&&a.emit("stop"),this._removeLocalTrackEvents(this._localVideoTrack),this._localVideoTrack.close(),this._localImgVideoTrack?(null===(s=this._localVideoTrack)||void 0===s||s.setTrack(this._localImgVideoTrack,this._extensionManager),this._localVideoTrack.dummy=!0):this._localVideoTrack=void 0)),this._room){e.next=11;break}return e.abrupt("return");case 11:if(null===(r=this._room)||void 0===r||!r.hasPublished){e.next=14;break}return e.next=14,this._updatePublish();case 14:null===(n=this._room)||void 0===n||null===(i=n.localStream)||void 0===i||null===(o=i.observer)||void 0===o||o.setEnableVideo(!1);case 15:case"end":return e.stop()}}),e,this)}))),function(){return Q.apply(this,arguments)})},{key:"startAudioCapture",value:(Z=_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(logger$1.print("startAudioCapture()","deviceId: $o",t),isEmpty(t)||checkString(t,"deviceId"),t=t||this._localAudioDeviceId,this._localAudioDeviceId=t,this._trackSourceType.audio!==AudioSourceType.AUDIO_SOURCE_TYPE_EXTERNAL){e.next=6;break}throw new SDKError(ErrorCode.STREAM_TYPE_NOT_MATCH,"setAudioSourceType as internal first");case 6:if(!this._micCapturing&&!this._localAudioTrack){e.next=8;break}throw new SDKError(ErrorCode.REPEAT_CAPTURE,"Has already capture");case 8:return t&&this._audioProfileManager.updateConstraints({deviceId:{exact:t}}),e.prev=9,this._micCapturing=!0,e.next=13,createMicrophoneAudioTrack(this._audioProfileManager.getConstraints(),this._extensionManager);case 13:if(i=e.sent,!this._interruptMicCapture){e.next=19;break}throw this._interruptMicCapture=!1,this._removeLocalTrackEvents(i),i.close(),new SDKError(ErrorCode.INTERRUPT,"interrupt by stopAudioCapture");case 19:if(this._initLocalTrackEvents(i),this._localAudioTrack=i,this._localAudioTrack.setVolume(this._localAudioVolume),this._tempMixingAudioTrack&&(this._localAudioTrack.mixType=this._tempMixingAudioTrack.type,this._localAudioTrack.mixedAudioTrack=this._tempMixingAudioTrack.track,delete this._tempMixingAudioTrack),this._room){e.next=25;break}return e.abrupt("return");case 25:return e.prev=25,this._micCapturing=!1,e.finish(25);case 28:o=this._room._roomConfig.isAutoPublish,(this._room.hasPublished||o)&&(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 31:case"end":return e.stop()}}),e,this,[[9,,25,28]])}))),function(e){return Z.apply(this,arguments)})},{key:"stopAudioCapture",value:(X=_asyncToGenerator(_regeneratorRuntime().mark((function e(){var t,r;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(this._trackSourceType.audio!==AudioSourceType.AUDIO_SOURCE_TYPE_EXTERNAL){e.next=7;break}throw new SDKError(ErrorCode.STREAM_TYPE_NOT_MATCH,"setAudioSourceType as internal first");case 7:if(this._localAudioTrack&&(this._removeLocalTrackEvents(this._localAudioTrack),this._localAudioTrack.close()),this._localAudioTrack=void 0,this._audioMixingManager.stopAll(),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===(t=this._room.localStream)||void 0===t||null===(r=t.observer)||void 0===r||r.setEnableAudio(!1);case 16:case"end":return e.stop()}}),e,this)}))),function(){return X.apply(this,arguments)})},{key:"getAudioMixingManager",value:function(){return logger$1.print("getAudioMixingManager()","invoke"),this._audioMixingManager}},{key:"startScreenCapture",value:(q=_asyncToGenerator(_regeneratorRuntime().mark((function e(){var t,r,n,i,o,a,s,c,l,u,d,p,_,h=this,f=arguments;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(o=f.length>0&&void 0!==f[0]?f[0]:{},logger$1.print("startScreenCapture()","config: %o",o),a=o.enableAudio,s=void 0!==a&&a,this._trackSourceType.screenVideo!==VideoSourceType.VIDEO_SOURCE_TYPE_EXTERNAL){e.next=5;break}throw new SDKError(ErrorCode.STREAM_TYPE_NOT_MATCH,"setVideoSourceType as internal first");case 5:if(this._trackSourceType.screenAudio!==AudioSourceType.AUDIO_SOURCE_TYPE_EXTERNAL){e.next=7;break}throw new SDKError(ErrorCode.STREAM_TYPE_NOT_MATCH,"setAudioSourceType as internal first");case 7:return e.next=9,createScreenTracks(s,this._extensionManager,this._screenStreamEncodeConfig[0]);case 9:if(c=e.sent,l=_slicedToArray(c,2),u=l[0],null==(d=l[1])||d.setVolume(this._localScreenAudioVolume),this._localScreenVideoTrack&&!this._localScreenVideoTrack.dummy&&(this._removeLocalTrackEvents(this._localScreenVideoTrack),this._localScreenVideoTrack.close()),null===(t=this._localScreenAudioTrack)||void 0===t||t.close(),delete this._localScreenAudioTrack,this._localScreenVideoTrack=u,null!==(r=this._screenStreamEncodeConfig[0])&&void 0!==r&&r.contentHint&&u.setContentHint(null===(p=this._screenStreamEncodeConfig[0])||void 0===p?void 0:p.contentHint),(_=null==u?void 0:u.getTrack())&&setTimeout((function(){var e=_.getSettings(),t={width:e.width,height:e.height};u.resolution=t,h.safeEmit(EngineEventsTypes.onLocalVideoSizeChanged,{streamIndex:StreamIndex.STREAM_INDEX_SCREEN,info:{width:e.width,height:e.height}})}),500),d&&(this._localScreenAudioTrack=d,this._initLocalTrackEvents(d)),null===(n=this._screenPlayer)||void 0===n||n.playVideo(this._localScreenVideoTrack),this._initLocalTrackEvents(this._localScreenVideoTrack,!0),null===(i=this._room)||void 0===i||!i.hasScreenPublished){e.next=27;break}return e.next=27,this._updateScreenPublish();case 27:case"end":return e.stop()}}),e,this)}))),function(){return q.apply(this,arguments)})},{key:"stopScreenCapture",value:(Y=_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("stopScreenCapture()"),null===(t=this._screenPlayer)||void 0===t||t.stop(),this._localScreenVideoTrack&&(this._localScreenVideoTrack.dummy||(this._removeLocalTrackEvents(this._localScreenVideoTrack),this._localScreenVideoTrack.close(),this._localImgScreenTrack&&(null===(n=this._localScreenVideoTrack)||void 0===n||n.setTrack(this._localImgScreenTrack,this._extensionManager),this._localScreenVideoTrack.dummy=!0))),this._localScreenAudioTrack&&(this._removeLocalTrackEvents(this._localScreenAudioTrack),this._localScreenAudioTrack.close()),this._localScreenAudioTrack=void 0,null===(r=this._room)||void 0===r||!r.hasScreenPublished){e.next=8;break}return e.next=8,this._updateScreenPublish();case 8:case"end":return e.stop()}}),e,this)}))),function(){return Y.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,o,a=_objectSpread2(_objectSpread2({userId:this._getUserId()},t),{},{isLocal:!0});if(checkVideoPlayerOption(a),e===StreamIndex.STREAM_INDEX_MAIN&&!this._videoPlayer)return this._videoPlayer=new VideoPlayer(this.id,a),this._initPlayerEvents(this._videoPlayer,!1,e),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),(null===(n=this._room)||void 0===n?void 0:n.localStream)&&(this._room.localStream.videoDom=this._videoPlayer.domElement),this._videoPlayer.domElement;if(e===StreamIndex.STREAM_INDEX_SCREEN&&!this._screenPlayer)return this._screenPlayer=new VideoPlayer(this.id,_objectSpread2(_objectSpread2({},a),{},{isScreen:!0,isLocal:!0})),this._initPlayerEvents(this._screenPlayer,!1,e),this._localScreenVideoTrack&&!this._localScreenVideoTrack.dummy&&(null===(i=this._config)||void 0===i?void 0:i.autoPlayPolicy)!==RTCAutoPlayPolicy.PLAY_MANUALLY&&this._screenPlayer.playVideo(this._localScreenVideoTrack),(null===(o=this._room)||void 0===o?void 0:o.localScreenStream)&&(this._room.localScreenStream.videoDom=this._screenPlayer.domElement),this._screenPlayer.domElement}else{var s,c;e===StreamIndex.STREAM_INDEX_MAIN?(null===(s=this._videoPlayer)||void 0===s||s.destroy(!0),delete this._videoPlayer):(null===(c=this._screenPlayer)||void 0===c||c.destroy(),delete this._screenPlayer)}}},{key:"startLiveTranscoding",value:(W=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){var r,n,i;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(logger$1.print("startLiveTranscoding()","transcode: %o",t),LiveTranscoding.checkStartParams(t),this._liveTranscodeConfig=t,!((n=null===(r=this._room)||void 0===r?void 0:r.roomInfo)&&n.roomId.length+n.userInfo.userId.length>126)){e.next=6;break}throw new SDKError(ErrorCode.INVALID_PARAMS,"The roomId+userId must be within 126 bytes");case 6:if(e.prev=6,this.safeEmit(EngineEventsTypes.onStreamMixingEvent,{event:StreamMixingEventType.START,error:0,message:""}),!this._room||this._room.connectionState!==MediaConnectionState.CONNECTED){e.next=11;break}return e.next=11,null===(i=this._room)||void 0===i?void 0:i.liveControlMessage(LiveTranscoding.getStartParams(this._liveTranscodeConfig));case 11:e.next=20;break;case 13:if(e.prev=13,e.t0=e.catch(6),!(e.t0 instanceof SDKError)){e.next=19;break}throw e.t0;case 19:throw new SDKError(ErrorCode.UNEXPECTED_ERROR,"unexpected error",e.t0);case 20:case"end":return e.stop()}}),e,this,[[6,13]])}))),function(e){return W.apply(this,arguments)})},{key:"updateLiveTranscoding",value:(K=_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(logger$1.print("updateLiveTranscoding()","transcode: %o",t),this._liveTranscodeConfig){e.next=3;break}return e.abrupt("return");case 3:return delete(i=assignIn$1({},t)).audio,null===(r=i.video)||void 0===r||delete r.codec,null===(n=i.video)||void 0===n||delete n.gop,LiveTranscoding.checckUpdateParams(i),this._liveTranscodeConfig=assignIn$1(this._liveTranscodeConfig,i),e.prev=9,this.safeEmit(EngineEventsTypes.onStreamMixingEvent,{event:StreamMixingEventType.UPDATE,error:0,message:""}),e.next=13,null===(o=this._room)||void 0===o?void 0:o.liveControlMessage(LiveTranscoding.getUpdateParams(this._liveTranscodeConfig));case 13:e.next=22;break;case 15:if(e.prev=15,e.t0=e.catch(9),!(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:case"end":return e.stop()}}),e,this,[[9,15]])}))),function(e){return K.apply(this,arguments)})},{key:"stopLiveTranscoding",value:(H=_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 H.apply(this,arguments)})},{key:"startSubtitle",value:(z=_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("startSubtitle()","config: %o",t),this._assertNotInRoom(),e.next=4,null===(r=this._room)||void 0===r?void 0:r.startSubtitle(t);case 4:case"end":return e.stop()}}),e,this)}))),function(e){return z.apply(this,arguments)})},{key:"stopSubtitle",value:function(){var e;logger$1.print("stopSubtitle()","invoke"),null===(e=this._room)||void 0===e||e.stopSubtitle()}},{key:"setBusinessId",value:function(e){return logger$1.print("setBusinessId()","businessId: %s",e),!illegalBusinessId(e)&&!this._room&&(this.monitor.set({rtc_business_id:e}),this._businessId=e,!0)}},{key:"setUserVisibility",value:(G=_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._assertNotInRoom(),this._room.localStream&&(null===(n=this._room.localStream.observer)||void 0===n||n.setPublisher(t)),e.t0=!t,!e.t0){e.next=13;break}return e.next=13,this._room.unpublish();case 13:return e.next=15,this._room.updateUserAttributes({role:t?UserRole.NORMAL_USER:UserRole.SILENT_USER});case 15:this._visibility=t,t&&null!==(r=this._roomConfig)&&void 0!==r&&r.isAutoPublish&&this._updatePublish({mediaType:MediaType.AUDIO_AND_VIDEO});case 17:case"end":return e.stop()}}),e,this)}))),function(e){return G.apply(this,arguments)})},{key:"_initPlayerEvents",value:function(e){var t=this,r=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:StreamIndex.STREAM_INDEX_MAIN,i=n===StreamIndex.STREAM_INDEX_SCREEN;e.on("playback_event",(function(n){switch(n.eventName){case"timeupdate":return;case"loadeddata":if("audio"===n.type){var o,a,s=e.userId.replace("_screen",""),c=null===(o=t._room)||void 0===o||null===(a=o.remoteStreams.get(s))||void 0===a?void 0:find$2(a).call(a,(function(e){return e.isScreen===i})),l=function(){r?t.safeEmit(EngineEventsTypes.onFirstPublicStreamAudioFrameDecoded,{publicStreamId:s}):(t.safeEmit(EngineEventsTypes.onAudioFirstFrameDecoded,{userId:s,isScreen:i}),t.safeEmit(EngineEventsTypes.onRemoteAudioFirstFrame,{userId:s,isScreen:i})),t.monitor.report("first_remote_audio_render",{stream_id:"",stream_user_id:s||""},{isScreen:i})};c&&c.observer&&!c.observer.audioFirstFrameReceived?c.observer.once("recvAudioFirstFrame",l):l()}else{var u,d,p={userId:e.userId,height:(null===(u=e.domElement)||void 0===u?void 0:u.videoHeight)||0,width:(null===(d=e.domElement)||void 0===d?void 0:d.videoWidth)||0,isScreen:i};r?(p.publicStreamId=p.userId,delete p.userId,delete p.isScreen,t.safeEmit(EngineEventsTypes.onFirstPublicStreamVideoFrameRendered,p),t.safeEmit(EngineEventsTypes.onFirstPublicStreamVideoFrameDecoded,p)):e.isLocal||(t.safeEmit(EngineEventsTypes.onVideoFirstFrameRendered,p),t.safeEmit(EngineEventsTypes.onVideoFirstFrameDecoded,p),t.safeEmit(EngineEventsTypes.onRemoteVideoFirstFrame,p)),t.monitor.report("first_remote_video_render",{stream_id:"",stream_user_id:n.userId||""},{isScreen:i})}break;case"autoplay-error":return r&&(n.publicStreamId=n.userId),reportRtcInvokeStatus(t.id,"autoplay-error",e instanceof VideoPlayer?"video":"audio",0,n.userId||""),void t.safeEmit(EngineEventsTypes.onAutoplayFailed,{userId:n.userId,kind:e instanceof VideoPlayer?"video":"audio",mediaType:e instanceof VideoPlayer?MediaType.VIDEO:MediaType.AUDIO,streamIndex:e.isScreen?StreamIndex.STREAM_INDEX_SCREEN:StreamIndex.STREAM_INDEX_MAIN})}t.safeEmit(EngineEventsTypes.onPlayerEvent,n)}))}},{key:"_initLocalTrackEvents",value:function(e){var t=this,r=arguments.length>1&&void 0!==arguments[1]&&arguments[1];["track-ended","track-mute","track-unmute"].forEach((function(r){e.on(r,function(){var e=_asyncToGenerator(_regeneratorRuntime().mark((function e(n){var i,o;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t.monitor.report("rtc_error",{message:concat$2(i="track-".concat(r," mediaType: ")).call(i,n.getTrack().kind),error_code:-1001}),o=!1,n!==t._localScreenAudioTrack&&n!==t._localScreenVideoTrack||(o=!0),t.safeEmit({"track-ended":EngineEventsTypes.onTrackEnded,"track-mute":EngineEventsTypes.onTrackMute,"track-unmute":EngineEventsTypes.onTrackUnmute}[r],{kind:n.getTrack().kind,isScreen:o});case 4:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}())})),e.on("resolution-change",(function(e){t._extensionManager.getPluginsByType(RTCExtensionType.PRE_PROCESSING).forEach((function(t){var r;null==t||null===(r=t.applyConstraints)||void 0===r||r.call(t,e)})),t.safeEmit(EngineEventsTypes.onLocalVideoSizeChanged,{streamIndex:r?StreamIndex.STREAM_INDEX_SCREEN:StreamIndex.STREAM_INDEX_MAIN,info:e})}))}},{key:"_removeLocalTrackEvents",value:function(e){e.removeAllListeners("track-ended"),e.removeAllListeners("track-mute"),e.removeAllListeners("track-unmute"),e.removeAllListeners("resolution-change")}},{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 l=new VideoPlayer(this.id,t);this._initPlayerEvents(l,!1,e),this._remoteVideoPlayer.set(o,l);var u=null===(s=this._room)||void 0===s||null===(c=s.remoteStreams.get(o))||void 0===c?void 0:find$2(c).call(c,(function(e){return!e.isScreen}));return u&&(this._updateVideoPlayerState(u),u.videoDom=l.domElement),l.domElement}if(null===(r=this._remoteScreenPlayer.get(o))||void 0===r||r.destroy(),t.renderDom){var d=new VideoPlayer(this.id,_objectSpread2(_objectSpread2({},t),{},{isScreen:!0}));this._remoteScreenPlayer.set(o,d),this._initPlayerEvents(d,!1,e);var p=null===(n=this._room)||void 0===n||null===(i=n.remoteStreams.get(o))||void 0===i?void 0:find$2(i).call(i,(function(e){return e.isScreen}));return p&&(this._updateVideoPlayerState(p),p.videoDom=d.domElement),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:(B=_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("setAudioPlaybackDevice()","deviceId: %s",t),checkString(t,"deviceId"),e.next=4,this._audioDeviceManager.setSinkId(t);case 4:r=e.sent,this._remoteAudioPlayer.forEach((function(e){e.setPlaybackDevice(t)})),this._remoteScreenAudioPlayer.forEach((function(e){e.setPlaybackDevice(t)})),this.safeEmit(EngineEventsTypes.onAudioPlaybackDeviceChanged,r),this.monitor.report("rtc_audio_device",{audio_event:"playout_device_switch",message:stringify$1(r),error_code:0});case 9:case"end":return e.stop()}}),e,this)}))),function(e){return B.apply(this,arguments)})},{key:"play",value:(j=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){var r,n,i,o,a,s,c,l,u,d,p,_,h,f,m,v,g=arguments;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return o=g.length>1&&void 0!==g[1]?g[1]:MediaType.AUDIO_AND_VIDEO,a=g.length>2?g[2]:void 0,logger$1.print("play()","userId: %s, mediaType: %s, streamIndex: %s",t,o,a),s=!t||t===this._getUserId()||"local_user"===t,c=void 0===a||a===StreamIndex.STREAM_INDEX_MAIN,l=void 0===a||a===StreamIndex.STREAM_INDEX_SCREEN,u=o!==MediaType.VIDEO,d=o!==MediaType.AUDIO,p=[],s&&d&&(c&&this._localVideoTrack&&(null===(_=this._videoPlayer)||void 0===_||_.mirror(!!this._mirrorType),p.push(null===(h=this._videoPlayer)||void 0===h?void 0:h.playVideo(this._localVideoTrack))),l&&this._localScreenVideoTrack&&p.push(null===(f=this._screenPlayer)||void 0===f?void 0:f.playVideo(this._localScreenVideoTrack))),t===(null===(r=this._audioMixingManager)||void 0===r?void 0:r.id)&&p.push(this._audioMixingManager.resumeLocalPlay()),m=null===(n=this._room)||void 0===n?void 0:n.remoteStreams,d&&c&&p.push(playRemoteStream(this._remoteVideoPlayer,t,!1,m)),d&&l&&p.push(playRemoteStream(this._remoteScreenPlayer,t,!0,m)),u&&c&&p.push(playRemoteStream(this._remoteAudioPlayer,t,!1,m)),d&&l&&p.push(playRemoteStream(this._remoteScreenAudioPlayer,t,!0,m)),v=null===(i=this._publicStreamManager)||void 0===i?void 0:i.remoteStreams,u&&p.push(playRemoteStream(this._publicStreamVideoPlayer,t,!1,v)),d&&p.push(playRemoteStream(this._publicStreamAudioPlayer,t,!1,v)),e.abrupt("return",promise.all(p).then((function(){})));case 20:case"end":return e.stop()}}),e,this)}))),function(e){return j.apply(this,arguments)})},{key:"pauseAllSubscribedStream",value:(F=_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$1.print("pauseAllSubscribedStream()","mediaType: %o",t),this._checkMediaType(t),audioInMediaType(t)&&(s._pauseAllSubscribeState.audio=!0),videoInMediaType(t)&&(s._pauseAllSubscribeState.video=!0),this._room){e.next=6;break}return e.abrupt("return",promise.resolve());case 6:n=[],i=_createForOfIteratorHelper(values$1(r=this._room.remoteStreams).call(r));try{for(i.s();!(o=i.n()).done;)a=o.value,Array.isArray(a)&&a.forEach((function(e){if(e.hasSubscribed){s._pauseAllSubscribeState.resumeStreamIds[e.streamId]=e.streamId;var r=s._unsubscribe(e.isScreen,e.userId,t,!0);r&&n.push(r)}}))}catch(e){i.e(e)}finally{i.f()}return e.abrupt("return",promise.all(n).then((function(){})));case 10:case"end":return e.stop()}}),e,this)}))),function(e){return F.apply(this,arguments)})},{key:"resumeAllSubscribedStream",value:(V=_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$1.print("resumeAllSubscribedStream()","mediaType: %o",t),this._checkMediaType(t),audioInMediaType(t)&&(s._pauseAllSubscribeState.audio=!1),videoInMediaType(t)&&(s._pauseAllSubscribeState.video=!1),this._room){e.next=6;break}return e.abrupt("return",promise.resolve());case 6:n=[],i=_createForOfIteratorHelper(values$1(r=this._room.remoteStreams).call(r));try{for(i.s();!(o=i.n()).done;)a=o.value,Array.isArray(a)&&a.forEach((function(e){if(s._pauseAllSubscribeState.resumeStreamIds[e.streamId]){delete s._pauseAllSubscribeState.resumeStreamIds[e.streamId];var r=s._subscribe(e.isScreen,e.userId,t);r&&n.push(r)}}))}catch(e){i.e(e)}finally{i.f()}return e.abrupt("return",promise.all(n).then((function(){var e,t;null===(e=s._room)||void 0===e||null===(t=e.remoteStreams)||void 0===t||t.forEach((function(e){Array.isArray(e)&&e.forEach((function(e){s._updateAudioPlayerState(e),s._updateVideoPlayerState(e)}))}))})));case 10:case"end":return e.stop()}}),e,this)}))),function(e){return V.apply(this,arguments)})},{key:"sendUserMessage",value:(U=_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 checkUserId(t),checkBufferSize(r),this._assertNotInRoom(),o=Date.now(),e.abrupt("return",null===(n=this._room)||void 0===n||null===(i=n.sendUserMessage(t,r))||void 0===i?void 0:i.then((function(e){return a._messageStatisticsObserver.countP2PMessage(!0,t,!1,o,e),e.id})).catch((function(e){throw a._messageStatisticsObserver.countP2PMessage(!1,t,!1,o,e),e})));case 5:case"end":return e.stop()}}),e,this)}))),function(e,t){return U.apply(this,arguments)})},{key:"sendUserBinaryMessage",value:(L=_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 checkUserId(t),checkArrayBuffer(r,"message"),checkBufferSize(r),this._assertNotInRoom(),o=Date.now(),e.abrupt("return",null===(n=this._room)||void 0===n||null===(i=n.sendUserMessage(t,r))||void 0===i?void 0:i.then((function(e){return a._messageStatisticsObserver.countP2PMessage(!0,t,!0,o,e),e.id})).catch((function(e){throw a._messageStatisticsObserver.countP2PMessage(!1,t,!0,o,e),e})));case 6:case"end":return e.stop()}}),e,this)}))),function(e,t){return L.apply(this,arguments)})},{key:"sendRoomMessage",value:(N=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){var r,n,i,o=this;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return checkBufferSize(t),this._assertNotInRoom(),i=Date.now(),e.abrupt("return",null===(r=this._room)||void 0===r||null===(n=r.sendRoomMessage(t))||void 0===n?void 0:n.then((function(e){var t,r;return o._messageStatisticsObserver.countRoomMessage(!0,null===(t=o._room)||void 0===t||null===(r=t.roomInfo)||void 0===r?void 0:r.roomId,!1,i),e})).catch((function(e){var t,r;throw o._messageStatisticsObserver.countRoomMessage(!1,null===(t=o._room)||void 0===t||null===(r=t.roomInfo)||void 0===r?void 0:r.roomId,!1,i),e})));case 4:case"end":return e.stop()}}),e,this)}))),function(e){return N.apply(this,arguments)})},{key:"sendRoomBinaryMessage",value:(x=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){var r,n,i,o=this;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return checkBufferSize(t),this._assertNotInRoom(),i=Date.now(),e.abrupt("return",null===(r=this._room)||void 0===r||null===(n=r.sendRoomMessage(t,!0))||void 0===n?void 0:n.then((function(e){var t,r;return o._messageStatisticsObserver.countRoomMessage(!0,null===(t=o._room)||void 0===t||null===(r=t.roomInfo)||void 0===r?void 0:r.roomId,!0,i),e})).catch((function(e){var t,r;throw o._messageStatisticsObserver.countRoomMessage(!1,null===(t=o._room)||void 0===t||null===(r=t.roomInfo)||void 0===r?void 0:r.roomId,!0,i),e})));case 4:case"end":return e.stop()}}),e,this)}))),function(e){return x.apply(this,arguments)})},{key:"setAudioCaptureConfig",value:(D=_asyncToGenerator(_regeneratorRuntime().mark((function e(){var t,r=arguments;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=r.length>0&&void 0!==r[0]?r[0]:{},logger$1.print("setAudioCaptureConfig()","config: %o",t),delete t.deviceId,checkSupportedConstraints(t),this._shouldUpdateAudioConf("setAudioCaptureConfig")&&this._audioProfileManager.updateConstraints(t);case 5:case"end":return e.stop()}}),e,this)}))),function(){return D.apply(this,arguments)})},{key:"setVideoCaptureConfig",value:(M=_asyncToGenerator(_regeneratorRuntime().mark((function e(){var t,r=arguments;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=r.length>0&&void 0!==r[0]?r[0]:{},logger$1.print("setVideoCaptureConfig()","config: %o",t),e.abrupt("return",this._setVideoCaptureConfig(t));case 3:case"end":return e.stop()}}),e,this)}))),function(){return M.apply(this,arguments)})},{key:"_setVideoCaptureConfig",value:(w=_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(delete(r=i.length>0&&void 0!==i[0]?i[0]:{}).deviceId,checkSupportedConstraints(r),n=_objectSpread2(_objectSpread2({},r),{},{deviceId:this._videoStreamConstraints.deviceId}),!this._localVideoTrack){e.next=7;break}return e.next=7,this._localVideoTrack.updateVideoCaptureConfig(n);case 7:return this._videoStreamConstraints=n,e.abrupt("return",(null===(t=this._localVideoTrack)||void 0===t?void 0:t.getTrack().getSettings())||{});case 9:case"end":return e.stop()}}),e,this)}))),function(){return w.apply(this,arguments)})},{key:"enableSimulcastMode",value:function(e){var t;return logger$1.print("enableSimulcastMode()","enabled: %o",e),this._enableSimulcast=e,14!==(null==iOSVersion?void 0:iOSVersion[0])&&(null!==(t=this._room)&&void 0!==t&&t.hasPublished&&warnDevelopers("You must call this API before publishing the video streams"),!0)}},{key:"setVideoEncoderConfig",value:(O=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){var r,n,i;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:for(logger$1.print("setVideoEncoderConfig()"," descriptions: %o",t),Array.isArray(t)||(t=[t]),checkVideoEncoderConfig(t=filter3(t).call(t,(function(e){return!!e}))),t.length>3&&(warnDevelopers("setVideoEncoderConfig: You can set parameters for up to 3 streams"),t=slice$1(t).call(t,0,3)),n=1;n<t.length;n++)i=constraints2number(t[0].width)/constraints2number(t[n].width)||1,Math.floor(i)!==i&&warnDevelopers("setVideoEncoderConfig: The resolution setting needs to be an integer multiple");sort2(t).call(t,(function(e,t){return t.maxKbps-e.maxKbps})),this._setVideoCaptureConfig(_objectSpread2({},t[0])),this._videoStreamEncodeConfig=t,this._updateDummyCaptureImage(StreamIndex.STREAM_INDEX_MAIN),null!==(r=this._room)&&void 0!==r&&r.hasPublished&&this._updatePublish();case 11:case"end":return e.stop()}}),e,this)}))),function(e){return O.apply(this,arguments)})},{key:"setScreenEncoderConfig",value:(P=_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.updateVideoCaptureConfig(t),t.contentHint&&this._localScreenVideoTrack.setContentHint(t.contentHint)),this._updateDummyCaptureImage(StreamIndex.STREAM_INDEX_SCREEN),null!==(r=this._room)&&void 0!==r&&r.hasScreenPublished&&this._updateScreenPublish();case 5:case"end":return e.stop()}}),e,this)}))),function(e){return P.apply(this,arguments)})},{key:"sendSEIMessage",value:function(e,t,r){if(logger$1.print("sendSEIMessage()","streamIdex: %o, message: %o, repeatCount: %o",e,t,r),!isEncodedTransformSupported())throw new SDKError(ErrorCode.NOT_SUPPORTED,"Browser does not support sending SEI");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,l,u;if(null===(c=this._room)||void 0===c||null===(l=c.localScreenStream)||void 0===l||!l.hasPublished)return;i=null===(u=this._room)||void 0===u?void 0:u.localScreenStream}if(n.byteLength>4096)logger$1.print("sei size must not bigger than 4KB");else{var d=genUuid2();i.seiList.push({content:n,uuid:d,repeatCount:r}),setTimeout((function(){var e;if(i){var t,r=findIndex$1(e=i.seiList).call(e,(function(e){return e.uuid===d}));if(r)splice$3(t=i.seiList).call(t,r,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=find$2(e).call(e,(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=reduce3(t).call(t,(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>-35){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,s=[];if(null!==(a=e._room)&&void 0!==a&&a.multiChatMode)e._room.getActiveSpeakerInMultiChatMode().forEach((function(t){var r,n,i=255*t.audioLevel;s.push({streamKey:{userId:t.userId,streamIndex:StreamIndex.STREAM_INDEX_MAIN,roomId:null===(r=e._room)||void 0===r||null===(n=r._roomInfo)||void 0===n?void 0:n.roomId},audioPropertiesInfo:{linearVolume:i,nonlinearVolume:getNonlinearVolume(i)}})}));else e._room.remoteStreams.forEach((function(t,r){t.forEach((function(t){if(t.audioTrack){var n,i,o=t.audioTrack.getAudioLevel();s.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.safeEmit(EngineEventsTypes.onRemoteAudioPropertiesReport,s),e._sendActiveSpeaker(t,filter3(s).call(s,(function(e){return e.streamKey.streamIndex!==StreamIndex.STREAM_INDEX_SCREEN})))}}}),o))}},{key:"setVideoSourceType",value:(k=_asyncToGenerator(_regeneratorRuntime().mark((function e(t,r){var n,i,o,a,s,c,l,u,d,p,_,h,f,m,v,g,y,S,T,$,E,b,I;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",concat$2(i="set ".concat(n," source type to ")).call(i,r)),!this._localVideoTrack||t!==StreamIndex.STREAM_INDEX_MAIN){e.next=17;break}if(c=!1,r===VideoSourceType.VIDEO_SOURCE_TYPE_EXTERNAL&&(c=!0,(l=this._extensionManager.getPluginByName(RTCExtensionType.PRE_PROCESSING,"RTCBeautyExtension"))&&l.emit("stop"),this._removeLocalTrackEvents(this._localVideoTrack),this._localVideoTrack.close()),null===(o=this._videoPlayer)||void 0===o||o.stop(),this._localVideoTrack=void 0,u=null===(a=this._room)||void 0===a?void 0:a._roomConfig.isAutoPublish,c?null===(d=this._room)||void 0===d||null===(p=d.localStream)||void 0===p||null===(_=p.observer)||void 0===_||_.setEnableVideo(!1):null===(h=this._room)||void 0===h||null===(f=h.localStream)||void 0===f||null===(m=f.observer)||void 0===m||m.setPushVideo(!1),!(null!==(s=this._room)&&void 0!==s&&s.hasPublished||u)){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._removeLocalTrackEvents(this._localScreenVideoTrack),this._localScreenVideoTrack.close()),null===(v=this._screenPlayer)||void 0===v||v.stop(),this._localScreenVideoTrack=void 0,y?null===(S=this._room)||void 0===S||null===(T=S.localScreenStream)||void 0===T||null===($=T.observer)||void 0===$||$.setEnableVideo(!1):null===(E=this._room)||void 0===E||null===(b=E.localScreenStream)||void 0===b||null===(I=b.observer)||void 0===I||I.setPushVideo(!1),null===(g=this._room)||void 0===g||!g.hasScreenPublished){e.next=26;break}return e.next=26,this._updateScreenPublish();case 26:case"end":return e.stop()}}),e,this)}))),function(e,t){return k.apply(this,arguments)})},{key:"setExternalVideoTrack",value:(A=_asyncToGenerator(_regeneratorRuntime().mark((function e(t,r){var n,i,o,a,s,c,l,u,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]),checkMediaStreamTrack(r),t!==StreamIndex.STREAM_INDEX_MAIN){e.next=15;break}if(this._trackSourceType.video===VideoSourceType.VIDEO_SOURCE_TYPE_EXTERNAL){e.next=6;break}throw new SDKError(ErrorCode.STREAM_TYPE_NOT_MATCH,"setVideoSourceType as external first");case 6:return e.next=8,createCustomVideoLocalTrack(r,this._extensionManager);case 8:if(this._localVideoTrack=e.sent,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=15;break}return e.next=15,this._updatePublish();case 15:if(t!==StreamIndex.STREAM_INDEX_SCREEN){e.next=27;break}if(this._trackSourceType.screenVideo===VideoSourceType.VIDEO_SOURCE_TYPE_EXTERNAL){e.next=18;break}throw new SDKError(ErrorCode.STREAM_TYPE_NOT_MATCH,"setVideoSourceType as external first");case 18:return e.next=20,createCustomScreenVideoLocalTrack(r,this._extensionManager);case 20:if(this._localScreenVideoTrack=e.sent,this._initLocalTrackEvents(this._localScreenVideoTrack,!0),null===(s=this._screenPlayer)||void 0===s||s.playVideo(this._localScreenVideoTrack),null===(c=this._room)||void 0===c||null===(l=c.localScreenStream)||void 0===l||null===(u=l.observer)||void 0===u||u.setPushVideo(!0),null===(d=this._room)||void 0===d||!d.hasScreenPublished){e.next=27;break}return e.next=27,this._updateScreenPublish();case 27:case"end":return e.stop()}}),e,this)}))),function(e,t){return A.apply(this,arguments)})},{key:"setAudioSourceType",value:(C=_asyncToGenerator(_regeneratorRuntime().mark((function e(t,r){var n,i,o,a,s,c,l,u,d,p,_,h,f,m,v,g,y,S,T,$;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",concat$2(i="set ".concat(n," source type to ")).call(i,r)),!this._localAudioTrack||t!==StreamIndex.STREAM_INDEX_MAIN){e.next=16;break}if(s=!1,this._trackSourceType.audio===AudioSourceType.AUDIO_SOURCE_TYPE_EXTERNAL&&(s=!0,this._removeLocalTrackEvents(this._localAudioTrack),this._localAudioTrack.close()),this._localAudioTrack=void 0,c=null===(o=this._room)||void 0===o?void 0:o._roomConfig.isAutoPublish,s?null===(l=this._room)||void 0===l||null===(u=l.localStream)||void 0===u||null===(d=u.observer)||void 0===d||d.setEnableAudio(!1):null===(p=this._room)||void 0===p||null===(_=p.localStream)||void 0===_||null===(h=_.observer)||void 0===h||h.setPushAudio(!1),!(null!==(a=this._room)&&void 0!==a&&a.hasPublished||c)){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(m=!1,this._trackSourceType.audio===AudioSourceType.AUDIO_SOURCE_TYPE_EXTERNAL&&(m=!0,this._removeLocalTrackEvents(this._localScreenAudioTrack),this._localScreenAudioTrack.close()),this._localScreenAudioTrack=void 0,m?null===(v=this._room)||void 0===v||null===(g=v.localScreenStream)||void 0===g||null===(y=g.observer)||void 0===y||y.setEnableAudio(!1):null===(S=this._room)||void 0===S||null===(T=S.localScreenStream)||void 0===T||null===($=T.observer)||void 0===$||$.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 C.apply(this,arguments)})},{key:"setExternalAudioTrack",value:(R=_asyncToGenerator(_regeneratorRuntime().mark((function e(t,r){var n,i,o,a,s,c,l,u,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]),checkMediaStreamTrack(r),t!==StreamIndex.STREAM_INDEX_MAIN){e.next=16;break}if(this._trackSourceType.audio===AudioSourceType.AUDIO_SOURCE_TYPE_EXTERNAL){e.next=6;break}throw new SDKError(ErrorCode.STREAM_TYPE_NOT_MATCH,"setAudioSourceType as external first");case 6:return e.next=8,createCustomAudioLocalTrack(r,this._extensionManager);case 8:if(this._localAudioTrack=e.sent,this._localAudioTrack.setVolume(this._localAudioVolume),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=16;break}return e.next=16,this._updatePublish();case 16:if(t!==StreamIndex.STREAM_INDEX_SCREEN){e.next=28;break}if(this._trackSourceType.screenAudio===AudioSourceType.AUDIO_SOURCE_TYPE_EXTERNAL){e.next=19;break}throw new SDKError(ErrorCode.STREAM_TYPE_NOT_MATCH,"setAudioSourceType as external first");case 19:return e.next=21,createCustomScreenAudioLocalTrack(r,this._extensionManager);case 21:if(this._localScreenAudioTrack=e.sent,this._localScreenAudioTrack.setVolume(this._localScreenAudioVolume),this._initLocalTrackEvents(this._localScreenAudioTrack),null===(l=this._room)||void 0===l||null===(u=l.localScreenStream)||void 0===u||null===(d=u.observer)||void 0===d||d.setPushAudio(!0),null===(p=this._room)||void 0===p||!p.hasScreenPublished){e.next=28;break}return e.next=28,this._updateScreenPublish();case 28:case"end":return e.stop()}}),e,this)}))),function(e,t){return R.apply(this,arguments)})},{key:"login",value:(I=_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 I.apply(this,arguments)})},{key:"logout",value:(b=_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 b.apply(this,arguments)})},{key:"updateLoginToken",value:(E=_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 E.apply(this,arguments)})},{key:"getPeerOnlineStatus",value:($=_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 $.apply(this,arguments)})},{key:"sendUserMessageOutsideRoom",value:(T=_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.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),e})));case 4:case"end":return e.stop()}}),e,this)}))),function(e,t){return T.apply(this,arguments)})},{key:"sendUserBinaryMessageOutsideRoom",value:(S=_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.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),e})));case 5:case"end":return e.stop()}}),e,this)}))),function(e,t){return S.apply(this,arguments)})},{key:"setServerParams",value:(y=_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 y.apply(this,arguments)})},{key:"sendServerMessage",value:(g=_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.abrupt("return",this._rtmClient.sendServerMessage(t).then((function(e){n._messageStatisticsObserver.countServerMessage(!0,!1,r,e)})).catch((function(e){throw n._messageStatisticsObserver.countServerMessage(!1,!1,r,e),e})));case 4:case"end":return e.stop()}}),e,this)}))),function(e){return g.apply(this,arguments)})},{key:"sendServerBinaryMessage",value:(v=_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.abrupt("return",this._rtmClient.sendServerMessage(t).then((function(e){n._messageStatisticsObserver.countServerMessage(!0,!0,r,e)})).catch((function(e){throw n._messageStatisticsObserver.countServerMessage(!1,!0,r,e),e})));case 4:case"end":return e.stop()}}),e,this)}))),function(e){return v.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:(m=_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:if(logger$1.print("startPushPublicStream()","publicStreamId: %o, publicStreamParam: %o",t,r),checkPublicStreamId(t),this._assertNotInRoom(),!this._publicStreamIds.get(t)){e.next=5;break}throw new SDKError(ErrorCode.REPEAT_PUSH,"repeat push public media stream");case 5:return o=getPublicStreamControlMessage(t,"started",r),e.abrupt("return",null===(n=this._room)||void 0===n||null===(i=n.publicStreamControlMessage(o))||void 0===i?void 0:i.then((function(){a._publicStreamIds.set(t,t)})));case 7:case"end":return e.stop()}}),e,this)}))),function(e,t){return m.apply(this,arguments)})},{key:"updatePublicStreamParam",value:(f=_asyncToGenerator(_regeneratorRuntime().mark((function e(t,r){var n,i;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return logger$1.print("startPushPublicStream()","publicStreamId: %o, publicStreamParam: %o",t,r),checkPublicStreamId(t),this._assertNotInRoom(),i=getPublicStreamControlMessage(t,"layoutChanged",r),e.abrupt("return",null===(n=this._room)||void 0===n?void 0:n.publicStreamControlMessage(i));case 5:case"end":return e.stop()}}),e,this)}))),function(e,t){return f.apply(this,arguments)})},{key:"stopPushPublicStream",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$1.print("startPushPublicStream()","publicStreamId: %o",t),checkPublicStreamId(t),this._assertNotInRoom(),e.abrupt("return",null===(r=this._room)||void 0===r?void 0:r.publicStreamControlMessage({type:"publicstream",action:"stopped",publicStreamID:t}).then((function(){n._publicStreamIds.delete(t)})));case 4:case"end":return e.stop()}}),e,this)}))),function(e){return h.apply(this,arguments)})},{key:"startPlayPublicStream",value:(_=_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._publicStreamManager){e.next=8;break}return this._publicStreamManager=new OutsideRoom(this.id,this._appId,{businessId:this._businessId}),this._publicStreamManager.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._publicStreamManager)||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._publicStreamManager)||void 0===n||n.on(RoomEvent.ON_SEI_MESSAGED_RECEIVED,(function(e){c.safeEmit(EngineEventsTypes.onPublicStreamSEIMessageReceived,e)})),e.next=8,this._publicStreamManager.connect();case 8:return e.next=10,this._publicStreamManager.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(this.id,t,{muted:(null===(s=this._config)||void 0===s?void 0:s.autoPlayPolicy)===RTCAutoPlayPolicy.VIDEO_ONLY,isScreen:!1}),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 _.apply(this,arguments)})},{key:"stopPlayPublicStream",value:(p=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){var r;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._publicStreamManager){e.next=2;break}return e.abrupt("return");case 2:this._publicStreamManager.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 p.apply(this,arguments)})},{key:"setAudioProfile",value:(d=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:logger$1.print("setAudioProfile()","profile: %o",t),this._shouldUpdateAudioConf("setAudioProfile")&&this._audioProfileManager.setAudioProfile(t);case 2:case"end":return e.stop()}}),e,this)}))),function(e){return d.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(this.id,_objectSpread2(_objectSpread2({},t),{},{userId:e})),this._initPlayerEvents(a,!0),this._publicStreamVideoPlayer.set(e,a);var s=null===(n=this._publicStreamManager)||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:(u=_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(){t===StreamIndex.STREAM_INDEX_MAIN?n._dummyMainImage=o:n._dummyScreenImage=o;try{n._updateDummyCaptureImage(t),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 u.apply(this,arguments)})},{key:"_updateDummyCaptureImage",value:function(e){var t,r;if(e===StreamIndex.STREAM_INDEX_MAIN?(t=this._dummyMainImage,r=this._videoStreamEncodeConfig[0]):(t=this._dummyScreenImage,r=this._screenStreamEncodeConfig[0]),t){var n,i,o=document.createElement("canvas"),a=o.getContext("2d"),s=constraints2number(r.width),c=constraints2number(r.height);if(!a)throw new SDKError(ErrorCode.UNEXPECTED_ERROR,"Not support canvas");!s||!c||t.width<=s&&t.height<=c?(n=t.width,i=t.height):(n=Math.min(s,t.width*c/t.height),i=Math.min(c,t.height*s/t.width)),o.width=n,o.height=i,a.drawImage(t,0,0,t.width,t.height,0,0,n,i);var l=window.setInterval((function(){t&&a.drawImage(t,0,0,t.width,t.height,0,0,n,i)}),200);e===StreamIndex.STREAM_INDEX_MAIN?(clearInterval(this._dummyMainTimer),this._dummyMainTimer=l):(clearInterval(this._dummyScreenTimer),this._dummyScreenTimer=l);var u,d,p,_,h=o.captureStream(5).getVideoTracks()[0];if(e===StreamIndex.STREAM_INDEX_MAIN){if(this._localImgVideoTrack=h,null!==(u=this._localVideoTrack)&&void 0!==u&&u.dummy)null===(d=this._localVideoTrack)||void 0===d||d.setTrack(this._localImgVideoTrack,this._extensionManager)}else if(this._localImgScreenTrack=h,null!==(p=this._localScreenVideoTrack)&&void 0!==p&&p.dummy)null===(_=this._localScreenVideoTrack)||void 0===_||_.setTrack(this._localImgScreenTrack,this._extensionManager)}}},{key:"_addListenExtensionEvent",value:function(e){var t=this;e.on("re-capture-audio",(function(){t._localAudioTrack&&t.stopAudioCapture().then((function(){t.startAudioCapture()}))})),e.on("re-capture-video",(function(){t._localVideoTrack&&!t._localVideoTrack.dummy&&t.stopVideoCapture().then((function(){t.startVideoCapture()}))})),e.on("reset-video-effect",_asyncToGenerator(_regeneratorRuntime().mark((function e(){return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!t._localVideoTrack||t._localVideoTrack.dummy){e.next=6;break}return t._localVideoTrack&&t._removeLocalTrackEvents(t._localVideoTrack),e.next=4,t._localVideoTrack.generatePreProcessingTrack(t._extensionManager);case 4:return e.next=6,t._switchTrack(t._localVideoTrack);case 6:case"end":return e.stop()}}),e)}))))}},{key:"registerExtension",value:(l=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t.monitor=this.monitor,e.prev=1,e.next=4,t.isSupported();case 4:if(e.sent){e.next=7;break}throw new Error("This extension is not supported.");case 7:e.next=12;break;case 9:throw e.prev=9,e.t0=e.catch(1),new Error("This extension is not supported.");case 12:return e.next=14,t.init({videoCaptureConfig:this._videoStreamConstraints});case 14:this._extensionManager.register(t),this._addListenExtensionEvent(t);case 16:case"end":return e.stop()}}),e,this,[[1,9]])}))),function(e){return l.apply(this,arguments)})},{key:"defaultTranscoding",value:function(){return JSON.parse(stringify$1(LiveTranscoding.getDefaultValue()))}},{key:"_updatePublish",value:(c=_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:this._videoPlayer&&this._room.localStream&&(this._room.localStream.videoDom=this._videoPlayer.domElement),e.next=25;break;case 18:if(e.prev=18,e.t0=e.catch(12),!(e.t0 instanceof SDKError)){e.next=24;break}throw e.t0;case 24:throw new SDKError(ErrorCode.UNEXPECTED_ERROR,"unexpected error",e.t0);case 25:return e.prev=25,n(),e.finish(25);case 28:case"end":return e.stop()}}),e,this,[[12,18,25,28]])}))),function(){return c.apply(this,arguments)})},{key:"startAudioPlaybackDeviceTest",value:(s=_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 s.apply(this,arguments)})},{key:"stopAudioPlaybackDeviceTest",value:function(){logger$1.print("stopAudioPlaybackDeviceTest()"),this._audioDeviceManager.stopAudioPlaybackDeviceTest()}},{key:"startAudioDeviceRecordTest",value:(a=_asyncToGenerator(_regeneratorRuntime().mark((function e(t,r){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,r,this._localAudioVolume);case 4:case"end":return e.stop()}}),e,this)}))),function(e,t){return a.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.updateRemoteUserPriority(e),!0}},{key:"takeLocalSnapshot",value:(o=_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("preprocessing"),(null==n?void 0:n.mirrorType)===MirrorType.MIRROR_TYPE_RENDER,n));case 7:case"end":return e.stop()}}),e,this)}))),function(e){return o.apply(this,arguments)})},{key:"takeRemoteSnapshot",value:(i=_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=find$2(i).call(i,(function(e){return e.isScreen===(r===StreamIndex.STREAM_INDEX_SCREEN)})))||void 0===o?void 0:o.videoTrack)||(null===(a=this._publicStreamManager)||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 i.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:"getLocalStreamTrack",value:function(e,t){var r,n,i,o=this;if(e===StreamIndex.STREAM_INDEX_MAIN?(n="video"===t?this.localVideoTrack:this.localAudioTrack,i=function(){var e;return null===(e=o._room)||void 0===e?void 0:e.localStream}):(n="video"===t?this.localScreenVideoTrack:this.localScreenAudioTrack,i=function(){var e;return null===(e=o._room)||void 0===e?void 0:e.localScreenStream}),n){var a=n instanceof runtimeTrackCls.LocalAudioTrack&&n.mixedAudioTrack?n.mixedAudioTrack:n.getTrack("preprocessing");if(a){var s=i();return this._reportMsTrackEvent(a,(null==s||null===(r=s.stream)||void 0===r?void 0:r.id)||"local"),a}}}},{key:"getRemoteStreamTrack",value:function(e,t,r){var n,i,o=(null===(n=this._room)||void 0===n?void 0:n.remoteStreams.get(e))||[];if(o&&o.length){var a,s,c,l,u;if(t===StreamIndex.STREAM_INDEX_MAIN)a=find$2(o).call(o,(function(e){return!e.isScreen})),i="video"===r?null===(s=a)||void 0===s?void 0:s.videoTrack:null===(c=a)||void 0===c?void 0:c.audioTrack;else a=find$2(o).call(o,(function(e){return e.isScreen})),i="video"===r?null===(l=a)||void 0===l?void 0:l.videoTrack:null===(u=a)||void 0===u?void 0:u.audioTrack;if(i){var d=i.getTrack();if(d&&a){var p=a.streamId;return this._reportMsTrackEvent(d,p),d}}}}},{key:"getPublicStreamTrack",value:function(e,t){if(this._publicStreamManager&&this._publicStreamManager.remoteStreams){var r=this._publicStreamManager.remoteStreams.get(e);if(r){var n="video"===t?r.videoTrack:r.audioTrack;if(n){var i=n.getTrack();if(i){var o=r.streamId;return this._reportMsTrackEvent(i,o),i}}}}}},{key:"setRemoteStreamRenderSync",value:function(e){return!this._room&&(this._avSync=!!e,!0)}},{key:"setCaptureVolume",value:function(e,t){var r,n,i;(checkEnum(e,"streamIndex",[StreamIndex.STREAM_INDEX_MAIN,StreamIndex.STREAM_INDEX_SCREEN]),t=numberRangeGuide(t,"volume",0,400),e===StreamIndex.STREAM_INDEX_SCREEN)?(null===(r=this._localScreenAudioTrack)||void 0===r||r.setVolume(t),this._localScreenAudioVolume=t):(null===(n=this._localAudioTrack)||void 0===n||n.setVolume(t),null===(i=this._audioDeviceManager.audioTrack)||void 0===i||i.setVolume(t),this._localAudioVolume=t)}},{key:"setPlaybackVolume",value:function(e,t,r){var n,i,o;if(checkUserId(e),checkEnum(t,"streamIndex",[StreamIndex.STREAM_INDEX_MAIN,StreamIndex.STREAM_INDEX_SCREEN]),r=numberRangeGuide(r,"volume",0,400),null!==(n=this._room)&&void 0!==n&&n.multiChatMode)warnDevelopers("setPlaybackVolume is not supported in Conference mode");else{var a=t===StreamIndex.STREAM_INDEX_SCREEN;a?this._remoteScreenAudioVolume.set(e,r):this._remoteAudioVolume.set(e,r),null===(i=this._room)||void 0===i||null===(o=i.remoteStreams.get(e))||void 0===o||o.forEach((function(e){var t;e.isScreen===a&&(null===(t=e.audioTrack)||void 0===t||t.setVolume(r))}))}}},{key:"setPublicStreamVolume",value:function(e,t){var r,n,i;checkString(e,"publicStreamId"),t=numberRangeGuide(t,"volume",0,400),this._publicAudioVolume.set(e,t),null===(r=this._publicStreamManager)||void 0===r||null===(n=r.remoteStreams.get(e))||void 0===n||null===(i=n.audioTrack)||void 0===i||i.setVolume(t)}},{key:"_reportMsTrackEvent",value:function(e,t){var r=this;if(!e.hookStop){e.hookStop=!0;var n=e.stop;e.stop=function(){reportRtcInvokeStatus(r.id,"stop",t,0,t),n.call(e)}}}},{key:"_updateScreenPublish",value:(n=_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:this._screenPlayer&&this._room.localScreenStream&&(this._room.localScreenStream.videoDom=this._screenPlayer.domElement),e.next=23;break;case 16:if(e.prev=16,e.t0=e.catch(10),!(e.t0 instanceof SDKError)){e.next=22;break}throw e.t0;case 22:throw new SDKError(ErrorCode.UNEXPECTED_ERROR,"unexpected error",e.t0);case 23:return e.prev=23,n(),e.finish(23);case 26:case"end":return e.stop()}}),e,this,[[10,16,23,26]])}))),function(){return n.apply(this,arguments)})},{key:"_updateAudioPlayerState",value:function(e){logger$1.print("_updateAudioPlayerState()");var t=e.userId,r=e.isScreen,n=r?this._remoteScreenAudioPlayer:this._remoteAudioPlayer,i=n.get(t);if(e.audioTrack&&(e.attributes.audiostream&&e.subAudio||this.multiChatMode)){var o,a,s,c=r?null!==(o=this._remoteScreenAudioVolume.get(t))&&void 0!==o?o:100:null!==(a=this._remoteAudioVolume.get(t))&&void 0!==a?a:100;if(e.audioTrack.setVolume(c),!i){var l;i=new AudioPlayer(this.id,t,{muted:(null===(l=this._config)||void 0===l?void 0:l.autoPlayPolicy)===RTCAutoPlayPolicy.VIDEO_ONLY,isScreen:r}),this._initPlayerEvents(i,!1,r?StreamIndex.STREAM_INDEX_SCREEN:StreamIndex.STREAM_INDEX_MAIN),n.set(t,i);var u=this._audioDeviceManager.getSinkId();u&&i.setPlaybackDevice(u)}(null===(s=this._config)||void 0===s?void 0:s.autoPlayPolicy)!==RTCAutoPlayPolicy.PLAY_MANUALLY&&i.playAudio(e.audioTrack),isSafari&&isIPad&&replayRemoteAudioWorkaround(this._remoteAudioPlayer)}else{var d;null===(d=i)||void 0===d||d.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:(r=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){var r,n,i,o,a,s,c,l,u;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if((n=t.stream).videoDom=null===(r=this._remoteVideoPlayer.get(n.userId))||void 0===r?void 0:r.domElement,i=null==n?void 0:n.attributes,o=i.localaudio,a=i.audiostream,s=i.localvideo,c=i.videostream,l=ExtendMediaType.NONE,a&&(l|=MediaType.AUDIO),c&&(l|=MediaType.VIDEO),!l){e.next=12;break}return e.next=9,new promise((function(e){return setTimeout(e)}));case 9:null!=n&&n.isScreen?this.safeEmit(EngineEventsTypes.onUserPublishScreen,{userId:n.userId,mediaType:l}):(this.safeEmit(EngineEventsTypes.onUserPublishStream,{userId:n.userId,mediaType:l,videoStreamDescriptions:null==n||null===(u=n.attributes)||void 0===u?void 0:u.videoDescriptions}),this._handleAutoSubscribe(n,!0)),this.safeEmit("onAddStream",{userId:n.userId,mediaType:l,isScreen:!(null==n||!n.isScreen)}),null!=n&&n.isScreen||(o&&this.safeEmit(EngineEventsTypes.onUserStartAudioCapture,{userId:n.userId}),s&&this.safeEmit(EngineEventsTypes.onUserStartVideoCapture,{userId:n.userId}));case 12:case"end":return e.stop()}}),e,this)}))),function(e){return r.apply(this,arguments)})},{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),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),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){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){var t=this;setTimeout((function(){return t.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,t=arguments.length,r=new Array(t),n=0;n<t;n++)r[n]=arguments[n];this.safeEmit.apply(this,concat$2(e=[EngineEventsTypes.onNetworkQuality]).call(e,r))}},{key:"_onConnectionStateChange",value:function(e){if(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),e.state===ConnectionState.CONNECTION_STATE_RECONNECTING){var t,r=_createForOfIteratorHelper(this._remoteAudioPlayer);try{for(r.s();!(t=r.n()).done;){var n=_slicedToArray(t.value,2),i=n[0],o=n[1];null!=i&&startsWith2(i).call(i,"mux")&&o.stop()}}catch(e){r.e(e)}finally{r.f()}}}},{key:"_getRemotePlayer",value:function(e,t){return[(t?this._remoteScreenAudioPlayer:this._remoteAudioPlayer).get(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:"_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=this,n=e.userId,i=e.isScreen,o=e.mediaType,a=e.pubState,s=e.remoteStream,c={userId:n,mediaType:o};(o&MediaType.AUDIO&&setTimeout((function(){r._updateAudioPlayerState(s)})),i)?a===PubState.PUB?this.safeEmit(EngineEventsTypes.onUserPublishScreen,c):this.safeEmit(EngineEventsTypes.onUserUnpublishScreen,_objectSpread2(_objectSpread2({},c),{},{reason:StreamRemoveReason.STREAM_REMOVE_REASON_UNPUBLISH})):a===PubState.PUB?(c.videoStreamDescriptions=null==s||null===(t=s.attributes)||void 0===t?void 0:t.videoDescriptions,this.safeEmit(EngineEventsTypes.onUserPublishStream,c),this._handleAutoSubscribe(s,!0)):this.safeEmit(EngineEventsTypes.onUserUnpublishStream,_objectSpread2(_objectSpread2({},c),{},{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._tempRoomInfo}},{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:"iceState",get:function(){var e,t,r,n;return null===(e=this._room)||void 0===e||null===(t=e._mediaServerClient)||void 0===t||null===(r=t.handler)||void 0===r||null===(n=r._peerConnection)||void 0===n?void 0:n.iceConnectionState}},{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.NOT_CONNECTED_YET,"server not connected")}},{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"}},{key:"_switchTrack",value:(t=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){var r,n;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._initLocalTrackEvents(t),this._localVideoTrack=t,null!==(r=this._videoPlayer)&&void 0!==r&&r.played&&(this._videoPlayer.stop(),this._videoPlayer.playVideo(t),this._videoPlayer.mirror(!!this._mirrorType)),null===(n=this._room)||void 0===n||!n.hasPublished){e.next=6;break}return e.next=6,this._updatePublish();case 6:case"end":return e.stop()}}),e,this)}))),function(e){return t.apply(this,arguments)})},{key:"_shouldUpdateAudioConf",value:function(e){var t,r=(null===(t=this._room)||void 0===t?void 0:t.hasPublished)||this._localAudioTrack&&this._localAudioTrack.sourceType===SourceType.INTERNAL;if(r){var n="engine.".concat(e," should be called before publishing or capturing.");console.warn("[RTC WebSDK]: "+n),reportRtcInvokeStatus(this.id,e,n)}return!r}},{key:"_getServerConfig",value:function(){var e=this,t=sdkCache.getServerConfig(this.appId);t.rts_report&&RTSMsgReportor.setConfig(t.rts_report),getServerConfig({engineId:this.id,appId:this.appId,sdkVersion:getParameter("VERSION"),requestDomains:getParameter("CONFIG_REQUEST_DOMAINS"),keys:["rts_report","web_rtc_config"],deviceId:getParameter("DEVICE_ID")}).then((function(t){sdkCache.setServerConfig(e.appId,t)}))}}]),ve}();__decorateClass3([reportRtcSdkApiCall()],RTCEngine.prototype,"updateToken",1),__decorateClass3([reportRtcSdkApiCall()],RTCEngine.prototype,"setVideoCaptureDevice",1),__decorateClass3([reportRtcSdkApiCall()],RTCEngine.prototype,"setAudioCaptureDevice",1),__decorateClass3([setJoinRoomInfo,reportRtcSdkApiCall()],RTCEngine.prototype,"connect",1),__decorateClass3([reportRtcSdkApiCall()],RTCEngine.prototype,"joinRoom",1),__decorateClass3([reportRtcSdkApiCall()],RTCEngine.prototype,"leaveRoom",1),__decorateClass3([reportRtcSdkApiCall()],RTCEngine.prototype,"destroy",1),__decorateClass3([reportRtcSdkApiCall()],RTCEngine.prototype,"publishStream",1),__decorateClass3([reportRtcSdkApiCall()],RTCEngine.prototype,"unpublishStream",1),__decorateClass3([reportRtcSdkApiCall()],RTCEngine.prototype,"publishScreen",1),__decorateClass3([reportRtcSdkApiCall()],RTCEngine.prototype,"unpublishScreen",1),__decorateClass3([reportRtcSdkApiCall()],RTCEngine.prototype,"subscribeStream",1),__decorateClass3([reportRtcSdkApiCall()],RTCEngine.prototype,"unsubscribeStream",1),__decorateClass3([reportRtcSdkApiCall()],RTCEngine.prototype,"subscribeScreen",1),__decorateClass3([reportRtcSdkApiCall()],RTCEngine.prototype,"unsubscribeScreen",1),__decorateClass3([reportRtcSdkApiCall()],RTCEngine.prototype,"setRemoteVideoConfig",1),__decorateClass3([reportRtcSdkApiCall()],RTCEngine.prototype,"startVideoCapture",1),__decorateClass3([reportRtcSdkApiCall()],RTCEngine.prototype,"stopVideoCapture",1),__decorateClass3([reportRtcSdkApiCall()],RTCEngine.prototype,"startAudioCapture",1),__decorateClass3([reportRtcSdkApiCall()],RTCEngine.prototype,"stopAudioCapture",1),__decorateClass3([reportRtcSdkApiCall()],RTCEngine.prototype,"getAudioMixingManager",1),__decorateClass3([reportRtcSdkApiCall()],RTCEngine.prototype,"startScreenCapture",1),__decorateClass3([reportRtcSdkApiCall()],RTCEngine.prototype,"stopScreenCapture",1),__decorateClass3([reportRtcSdkApiCall()],RTCEngine.prototype,"setLocalVideoPlayer",1),__decorateClass3([reportRtcSdkApiCall()],RTCEngine.prototype,"startLiveTranscoding",1),__decorateClass3([reportRtcSdkApiCall()],RTCEngine.prototype,"updateLiveTranscoding",1),__decorateClass3([reportRtcSdkApiCall()],RTCEngine.prototype,"stopLiveTranscoding",1),__decorateClass3([reportRtcSdkApiCall()],RTCEngine.prototype,"startSubtitle",1),__decorateClass3([reportRtcSdkApiCall()],RTCEngine.prototype,"stopSubtitle",1),__decorateClass3([reportRtcSdkApiCall()],RTCEngine.prototype,"setBusinessId",1),__decorateClass3([reportRtcSdkApiCall()],RTCEngine.prototype,"setUserVisibility",1),__decorateClass3([reportRtcSdkApiCall()],RTCEngine.prototype,"setRemoteVideoPlayer",1),__decorateClass3([reportRtcSdkApiCall()],RTCEngine.prototype,"setLocalVideoMirrorType",1),__decorateClass3([reportRtcSdkApiCall()],RTCEngine.prototype,"setAudioPlaybackDevice",1),__decorateClass3([reportRtcSdkApiCall()],RTCEngine.prototype,"play",1),__decorateClass3([reportRtcSdkApiCall()],RTCEngine.prototype,"pauseAllSubscribedStream",1),__decorateClass3([reportRtcSdkApiCall()],RTCEngine.prototype,"resumeAllSubscribedStream",1),__decorateClass3([reportRtcSdkApiCall()],RTCEngine.prototype,"sendUserMessage",1),__decorateClass3([reportRtcSdkApiCall()],RTCEngine.prototype,"sendUserBinaryMessage",1),__decorateClass3([reportRtcSdkApiCall()],RTCEngine.prototype,"sendRoomMessage",1),__decorateClass3([reportRtcSdkApiCall()],RTCEngine.prototype,"sendRoomBinaryMessage",1),__decorateClass3([reportRtcSdkApiCall()],RTCEngine.prototype,"setAudioCaptureConfig",1),__decorateClass3([warnDeprecatedApi("4.51"),reportRtcSdkApiCall()],RTCEngine.prototype,"setVideoCaptureConfig",1),__decorateClass3([reportRtcSdkApiCall()],RTCEngine.prototype,"enableSimulcastMode",1),__decorateClass3([reportRtcSdkApiCall()],RTCEngine.prototype,"setVideoEncoderConfig",1),__decorateClass3([reportRtcSdkApiCall()],RTCEngine.prototype,"setScreenEncoderConfig",1),__decorateClass3([reportRtcSdkApiCall()],RTCEngine.prototype,"sendSEIMessage",1),__decorateClass3([warnDeprecatedApi("4.42"),reportRtcSdkApiCall()],RTCEngine.prototype,"setAudioVolumeIndicationInterval",1),__decorateClass3([reportRtcSdkApiCall()],RTCEngine.prototype,"enableAudioPropertiesReport",1),__decorateClass3([reportRtcSdkApiCall()],RTCEngine.prototype,"setVideoSourceType",1),__decorateClass3([reportRtcSdkApiCall()],RTCEngine.prototype,"setExternalVideoTrack",1),__decorateClass3([reportRtcSdkApiCall()],RTCEngine.prototype,"setAudioSourceType",1),__decorateClass3([reportRtcSdkApiCall()],RTCEngine.prototype,"setExternalAudioTrack",1),__decorateClass3([reportRtcSdkApiCall()],RTCEngine.prototype,"login",1),__decorateClass3([reportRtcSdkApiCall()],RTCEngine.prototype,"logout",1),__decorateClass3([reportRtcSdkApiCall()],RTCEngine.prototype,"updateLoginToken",1),__decorateClass3([reportRtcSdkApiCall()],RTCEngine.prototype,"getPeerOnlineStatus",1),__decorateClass3([reportRtcSdkApiCall()],RTCEngine.prototype,"sendUserMessageOutsideRoom",1),__decorateClass3([reportRtcSdkApiCall()],RTCEngine.prototype,"sendUserBinaryMessageOutsideRoom",1),__decorateClass3([reportRtcSdkApiCall()],RTCEngine.prototype,"setServerParams",1),__decorateClass3([reportRtcSdkApiCall()],RTCEngine.prototype,"sendServerMessage",1),__decorateClass3([reportRtcSdkApiCall()],RTCEngine.prototype,"sendServerBinaryMessage",1),__decorateClass3([reportRtcSdkApiCall()],RTCEngine.prototype,"startCloudProxy",1),__decorateClass3([reportRtcSdkApiCall()],RTCEngine.prototype,"stopCloudProxy",1),__decorateClass3([reportRtcSdkApiCall()],RTCEngine.prototype,"startPushPublicStream",1),__decorateClass3([reportRtcSdkApiCall()],RTCEngine.prototype,"updatePublicStreamParam",1),__decorateClass3([reportRtcSdkApiCall()],RTCEngine.prototype,"stopPushPublicStream",1),__decorateClass3([reportRtcSdkApiCall("streamId")],RTCEngine.prototype,"startPlayPublicStream",1),__decorateClass3([reportRtcSdkApiCall("streamId")],RTCEngine.prototype,"stopPlayPublicStream",1),__decorateClass3([reportRtcSdkApiCall()],RTCEngine.prototype,"setAudioProfile",1),__decorateClass3([reportRtcSdkApiCall()],RTCEngine.prototype,"setPublicStreamVideoPlayer",1),__decorateClass3([reportRtcSdkApiCall()],RTCEngine.prototype,"setDummyCaptureImagePath",1),__decorateClass3([reportRtcSdkApiCall()],RTCEngine.prototype,"registerExtension",1),__decorateClass3([reportRtcSdkApiCall()],RTCEngine.prototype,"startAudioPlaybackDeviceTest",1),__decorateClass3([reportRtcSdkApiCall()],RTCEngine.prototype,"stopAudioPlaybackDeviceTest",1),__decorateClass3([reportRtcSdkApiCall()],RTCEngine.prototype,"startAudioDeviceRecordTest",1),__decorateClass3([reportRtcSdkApiCall()],RTCEngine.prototype,"stopAudioDeviceRecordAndPlayTest",1),__decorateClass3([reportRtcSdkApiCall()],RTCEngine.prototype,"stopAudioDevicePlayTest",1),__decorateClass3([reportRtcSdkApiCall()],RTCEngine.prototype,"setRemoteUserPriority",1),__decorateClass3([reportRtcSdkApiCall()],RTCEngine.prototype,"takeLocalSnapshot",1),__decorateClass3([reportRtcSdkApiCall()],RTCEngine.prototype,"takeRemoteSnapshot",1),__decorateClass3([reportRtcSdkApiCall()],RTCEngine.prototype,"setSubscribeFallbackOption",1),__decorateClass3([reportRtcSdkApiCall()],RTCEngine.prototype,"getLocalStreamTrack",1),__decorateClass3([reportRtcSdkApiCall()],RTCEngine.prototype,"getRemoteStreamTrack",1),__decorateClass3([reportRtcSdkApiCall()],RTCEngine.prototype,"getPublicStreamTrack",1),__decorateClass3([reportRtcSdkApiCall()],RTCEngine.prototype,"setRemoteStreamRenderSync",1);var _context,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};function isFallbackMode(e){var t=sdkCache.getServerConfig(e).web_rtc_config;return!(null==t||!t.fallback)||!!getParameter("ENABLE_FALLBACK_HANDLER")}var logger=new Logger("VERTC",0);iDB.storeKey=concat$2(_context="".concat(Date.now(),"-")).call(_context,sdkCache.getDeviceId()),setGlobalStats({rtc_sdk_version:Config.VERSION,device_id:sdkCache.getDeviceId(),log_cache_key:iDB.storeKey}),setReportUrl(Config.LOG_SERVER_URL);var ENGINE_GUID=1,createEngine=function(e,t){logger.print("createEngine","Invoke VERTC.createEngine"),checkString(e,"appId");var r=(ENGINE_GUID++).toString();return createMonitor(r,{rtc_app_id:e,auto_play_policy:null==t?void 0:t.autoPlayPolicy}),new RTCEngine(e,r,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(),destroyMonitor(e.monitor)},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",dd.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,a,s=arguments;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=s.length>0&&void 0!==s[0]?s[0]:{video:!0,audio:!0},r=t.video,n=t.audio,i={video:!1,audio:!1},!r){e.next=13;break}return e.prev=4,e.next=7,dd.getPermissions({video:!0,force:!0});case 7:o=e.sent,i.video=o.video,e.next=13;break;case 11:e.prev=11,e.t0=e.catch(4);case 13:if(!n){e.next=23;break}return e.prev=14,e.next=17,dd.getPermissions({audio:!0,force:!0});case 17:a=e.sent,i.audio=a.audio,e.next=23;break;case 21:e.prev=21,e.t1=e.catch(14);case 23:return e.abrupt("return",i);case 24:case"end":return e.stop()}}),e,null,[[4,11],[14,21]])})));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",dd.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",dd.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",dd.enumerateAudioPlaybackDevices());case 1:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),getSdkVersion=function(){return Config.VERSION},isSupported2=function(){return reportGlobalApiCall("isSupported",0,""),isSupported()},getSupportedCodecs2=function(){return reportGlobalApiCall("getSupportedCodecs",0,""),getSupportedCodecs()},setLogConfig=function(e){var t=e.logLevel,r=e.LogfileSize;t&&(iDB.logLevel=t),r&&(iDB.LogfileSize=r)},downloadLog=function(e){iDB.download(e)};function stringifyParams(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return stringify$1(map$6(t).call(t,(function(e){return e instanceof RTCEngine?"[ENGINE]":e})))}function reportVERTCApiCall(e,t){return function(){reportGlobalApiCall(t,0,stringifyParams.apply(void 0,arguments));var r=e.apply(void 0,arguments);return"function"==typeof(null==r?void 0:r.then)?r.then((function(e){return reportGlobalCallback(t,0,stringifyParams(e)),e})).catch((function(e){throw reportGlobalCallback(t,e.code,e.message),e})):(reportGlobalCallback(t,0,stringifyParams(r)),r)}}var VERTC=_createClass((function e(){_classCallCheck(this,e),_defineProperty(this,"getSdkVersion",reportVERTCApiCall(getSdkVersion,"getSdkVersion")),_defineProperty(this,"createEngine",reportVERTCApiCall(createEngine,"createEngine")),_defineProperty(this,"destroyEngine",reportVERTCApiCall(destroyEngine,"destroyEngine")),_defineProperty(this,"enumerateDevices",reportVERTCApiCall(enumerateDevices,"enumerateDevices")),_defineProperty(this,"enableDevices",reportVERTCApiCall(enableDevices,"enableDevices")),_defineProperty(this,"enumerateAudioCaptureDevices",reportVERTCApiCall(enumerateAudioCaptureDevices,"enumerateAudioCaptureDevices")),_defineProperty(this,"enumerateVideoCaptureDevices",reportVERTCApiCall(enumerateVideoCaptureDevices,"enumerateVideoCaptureDevices")),_defineProperty(this,"enumerateAudioPlaybackDevices",reportVERTCApiCall(enumerateAudioPlaybackDevices,"enumerateAudioPlaybackDevices")),_defineProperty(this,"getParameter",getParameter),_defineProperty(this,"setParameter",setParameter),_defineProperty(this,"isSupported",reportVERTCApiCall(isSupported2,"isSupported")),_defineProperty(this,"getSupportedCodecs",reportVERTCApiCall(getSupportedCodecs2,"getSupportedCodecs")),_defineProperty(this,"events",EngineEventsTypes),_defineProperty(this,"ErrorCode",ErrorCode),_defineProperty(this,"platform","BytePlus"),_defineProperty(this,"downloadLog",reportVERTCApiCall(downloadLog,"downloadLog")),_defineProperty(this,"setLogConfig",reportVERTCApiCall(setLogConfig,"setLogConfig"))})),index=new VERTC;export{AAC_PROFILE,AudioMixingDualMonoMode,AudioMixingType,AudioProfileType,AudioSourceType,ChannelProfile,ConnectionState,FallbackOrRecoverReason,LogChannel,MediaType,MirrorMode,MirrorType,NetworkQuality,PublicInterpolationMode,PublicStreamType,PublishState,RTCAutoPlayPolicy,RemoteUserPriority,RoomProfileType,SUBTITLE_MODE,StreamIndex,StreamRemoveReason,SubscribeFallbackOption,SubscribeMode,SubscribeState,SubtitleEventType,TRANSCODING_VIDEO_CODEC,USER_ONLINE_STATUS,UserOfflineReason,VideoRenderMode,VideoSourceType,index as default};