@lingoace/lingo-trtc-rtc 0.0.15 → 0.0.17
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/package.json +1 -1
- package/trtc-lingo.js +61 -96
package/trtc-lingo.js
CHANGED
|
@@ -1,111 +1,75 @@
|
|
|
1
|
-
var f7=Object.create;var fd=Object.defineProperty,m7=Object.defineProperties,nw=Object.getOwnPropertyDescriptor,v7=Object.getOwnPropertyDescriptors,g7=Object.getOwnPropertyNames,tw=Object.getOwnPropertySymbols,_7=Object.getPrototypeOf,rw=Object.prototype.hasOwnProperty,y7=Object.prototype.propertyIsEnumerable;var ng=(ne,q,m)=>q in ne?fd(ne,q,{enumerable:!0,configurable:!0,writable:!0,value:m}):ne[q]=m,ni=(ne,q)=>{for(var m in q||(q={}))rw.call(q,m)&&ng(ne,m,q[m]);if(tw)for(var m of tw(q))y7.call(q,m)&&ng(ne,m,q[m]);return ne},md=(ne,q)=>m7(ne,v7(q));var rg=(ne,q)=>()=>(q||ne((q={exports:{}}).exports,q),q.exports);var b7=(ne,q,m,H)=>{if(q&&typeof q=="object"||typeof q=="function")for(let Q of g7(q))!rw.call(ne,Q)&&Q!==m&&fd(ne,Q,{get:()=>q[Q],enumerable:!(H=nw(q,Q))||H.enumerable});return ne};var ur=(ne,q,m)=>(m=ne!=null?f7(_7(ne)):{},b7(q||!ne||!ne.__esModule?fd(m,"default",{value:ne,enumerable:!0}):m,ne));var Rn=(ne,q,m,H)=>{for(var Q=H>1?void 0:H?nw(q,m):q,G=ne.length-1,K;G>=0;G--)(K=ne[G])&&(Q=(H?K(q,m,Q):K(Q))||Q);return H&&Q&&fd(q,m,Q),Q};var Be=(ne,q,m)=>(ng(ne,typeof q!="symbol"?q+"":q,m),m);var Er=rg((ig,ag)=>{(function(ne,q){typeof ig=="object"&&typeof ag!="undefined"?ag.exports=q():typeof define=="function"&&define.amd?define(q):(ne=typeof globalThis!="undefined"?globalThis:ne||self).TRTC=q()})(ig,function(){function ne(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),n.push.apply(n,a)}return n}function q(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?ne(Object(n),!0).forEach(function(a){Ye(e,a,n[a])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):ne(Object(n)).forEach(function(a){Object.defineProperty(e,a,Object.getOwnPropertyDescriptor(n,a))})}return e}function m(){m=function(){return e};var e={},t=Object.prototype,n=t.hasOwnProperty,a=Object.defineProperty||function(x,h,E){x[h]=E.value},i=typeof Symbol=="function"?Symbol:{},r=i.iterator||"@@iterator",o=i.asyncIterator||"@@asyncIterator",s=i.toStringTag||"@@toStringTag";function c(x,h,E){return Object.defineProperty(x,h,{value:E,enumerable:!0,configurable:!0,writable:!0}),x[h]}try{c({},"")}catch(x){c=function(h,E,O){return h[E]=O}}function u(x,h,E,O){var N=h&&h.prototype instanceof I?h:I,j=Object.create(N.prototype),J=new C(O||[]);return a(j,"_invoke",{value:b(x,E,J)}),j}function d(x,h,E){try{return{type:"normal",arg:x.call(h,E)}}catch(O){return{type:"throw",arg:O}}}e.wrap=u;var g={};function I(){}function k(){}function w(){}var A={};c(A,r,function(){return this});var p=Object.getPrototypeOf,v=p&&p(p(D([])));v&&v!==t&&n.call(v,r)&&(A=v);var y=w.prototype=I.prototype=Object.create(A);function L(x){["next","throw","return"].forEach(function(h){c(x,h,function(E){return this._invoke(h,E)})})}function f(x,h){function E(N,j,J,$){var he=d(x[N],x,j);if(he.type!=="throw"){var ue=he.arg,Ee=ue.value;return Ee&&typeof Ee=="object"&&n.call(Ee,"__await")?h.resolve(Ee.__await).then(function(Ve){E("next",Ve,J,$)},function(Ve){E("throw",Ve,J,$)}):h.resolve(Ee).then(function(Ve){ue.value=Ve,J(ue)},function(Ve){return E("throw",Ve,J,$)})}$(he.arg)}var O;a(this,"_invoke",{value:function(N,j){function J(){return new h(function($,he){E(N,j,$,he)})}return O=O?O.then(J,J):J()}})}function b(x,h,E){var O="suspendedStart";return function(N,j){if(O==="executing")throw new Error("Generator is already running");if(O==="completed"){if(N==="throw")throw j;return B()}for(E.method=N,E.arg=j;;){var J=E.delegate;if(J){var $=P(J,E);if($){if($===g)continue;return $}}if(E.method==="next")E.sent=E._sent=E.arg;else if(E.method==="throw"){if(O==="suspendedStart")throw O="completed",E.arg;E.dispatchException(E.arg)}else E.method==="return"&&E.abrupt("return",E.arg);O="executing";var he=d(x,h,E);if(he.type==="normal"){if(O=E.done?"completed":"suspendedYield",he.arg===g)continue;return{value:he.arg,done:E.done}}he.type==="throw"&&(O="completed",E.method="throw",E.arg=he.arg)}}}function P(x,h){var E=h.method,O=x.iterator[E];if(O===void 0)return h.delegate=null,E==="throw"&&x.iterator.return&&(h.method="return",h.arg=void 0,P(x,h),h.method==="throw")||E!=="return"&&(h.method="throw",h.arg=new TypeError("The iterator does not provide a '"+E+"' method")),g;var N=d(O,x.iterator,h.arg);if(N.type==="throw")return h.method="throw",h.arg=N.arg,h.delegate=null,g;var j=N.arg;return j?j.done?(h[x.resultName]=j.value,h.next=x.nextLoc,h.method!=="return"&&(h.method="next",h.arg=void 0),h.delegate=null,g):j:(h.method="throw",h.arg=new TypeError("iterator result is not an object"),h.delegate=null,g)}function S(x){var h={tryLoc:x[0]};1 in x&&(h.catchLoc=x[1]),2 in x&&(h.finallyLoc=x[2],h.afterLoc=x[3]),this.tryEntries.push(h)}function T(x){var h=x.completion||{};h.type="normal",delete h.arg,x.completion=h}function C(x){this.tryEntries=[{tryLoc:"root"}],x.forEach(S,this),this.reset(!0)}function D(x){if(x){var h=x[r];if(h)return h.call(x);if(typeof x.next=="function")return x;if(!isNaN(x.length)){var E=-1,O=function N(){for(;++E<x.length;)if(n.call(x,E))return N.value=x[E],N.done=!1,N;return N.value=void 0,N.done=!0,N};return O.next=O}}return{next:B}}function B(){return{value:void 0,done:!0}}return k.prototype=w,a(y,"constructor",{value:w,configurable:!0}),a(w,"constructor",{value:k,configurable:!0}),k.displayName=c(w,s,"GeneratorFunction"),e.isGeneratorFunction=function(x){var h=typeof x=="function"&&x.constructor;return!!h&&(h===k||(h.displayName||h.name)==="GeneratorFunction")},e.mark=function(x){return Object.setPrototypeOf?Object.setPrototypeOf(x,w):(x.__proto__=w,c(x,s,"GeneratorFunction")),x.prototype=Object.create(y),x},e.awrap=function(x){return{__await:x}},L(f.prototype),c(f.prototype,o,function(){return this}),e.AsyncIterator=f,e.async=function(x,h,E,O,N){N===void 0&&(N=Promise);var j=new f(u(x,h,E,O),N);return e.isGeneratorFunction(h)?j:j.next().then(function(J){return J.done?J.value:j.next()})},L(y),c(y,s,"Generator"),c(y,r,function(){return this}),c(y,"toString",function(){return"[object Generator]"}),e.keys=function(x){var h=Object(x),E=[];for(var O in h)E.push(O);return E.reverse(),function N(){for(;E.length;){var j=E.pop();if(j in h)return N.value=j,N.done=!1,N}return N.done=!0,N}},e.values=D,C.prototype={constructor:C,reset:function(x){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(T),!x)for(var h in this)h.charAt(0)==="t"&&n.call(this,h)&&!isNaN(+h.slice(1))&&(this[h]=void 0)},stop:function(){this.done=!0;var x=this.tryEntries[0].completion;if(x.type==="throw")throw x.arg;return this.rval},dispatchException:function(x){if(this.done)throw x;var h=this;function E(he,ue){return j.type="throw",j.arg=x,h.next=he,ue&&(h.method="next",h.arg=void 0),!!ue}for(var O=this.tryEntries.length-1;O>=0;--O){var N=this.tryEntries[O],j=N.completion;if(N.tryLoc==="root")return E("end");if(N.tryLoc<=this.prev){var J=n.call(N,"catchLoc"),$=n.call(N,"finallyLoc");if(J&&$){if(this.prev<N.catchLoc)return E(N.catchLoc,!0);if(this.prev<N.finallyLoc)return E(N.finallyLoc)}else if(J){if(this.prev<N.catchLoc)return E(N.catchLoc,!0)}else{if(!$)throw new Error("try statement without catch or finally");if(this.prev<N.finallyLoc)return E(N.finallyLoc)}}}},abrupt:function(x,h){for(var E=this.tryEntries.length-1;E>=0;--E){var O=this.tryEntries[E];if(O.tryLoc<=this.prev&&n.call(O,"finallyLoc")&&this.prev<O.finallyLoc){var N=O;break}}N&&(x==="break"||x==="continue")&&N.tryLoc<=h&&h<=N.finallyLoc&&(N=null);var j=N?N.completion:{};return j.type=x,j.arg=h,N?(this.method="next",this.next=N.finallyLoc,g):this.complete(j)},complete:function(x,h){if(x.type==="throw")throw x.arg;return x.type==="break"||x.type==="continue"?this.next=x.arg:x.type==="return"?(this.rval=this.arg=x.arg,this.method="return",this.next="end"):x.type==="normal"&&h&&(this.next=h),g},finish:function(x){for(var h=this.tryEntries.length-1;h>=0;--h){var E=this.tryEntries[h];if(E.finallyLoc===x)return this.complete(E.completion,E.afterLoc),T(E),g}},catch:function(x){for(var h=this.tryEntries.length-1;h>=0;--h){var E=this.tryEntries[h];if(E.tryLoc===x){var O=E.completion;if(O.type==="throw"){var N=O.arg;T(E)}return N}}throw new Error("illegal catch attempt")},delegateYield:function(x,h,E){return this.delegate={iterator:D(x),resultName:h,nextLoc:E},this.method==="next"&&(this.arg=void 0),g}},e}function H(e){return H=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},H(e)}function Q(e,t,n,a,i,r,o){try{var s=e[r](o),c=s.value}catch(u){return void n(u)}s.done?t(c):Promise.resolve(c).then(a,i)}function G(e){return function(){var t=this,n=arguments;return new Promise(function(a,i){var r=e.apply(t,n);function o(c){Q(r,a,i,o,s,"next",c)}function s(c){Q(r,a,i,o,s,"throw",c)}o(void 0)})}}function K(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function Pe(e,t){for(var n=0;n<t.length;n++){var a=t[n];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(e,te(a.key),a)}}function we(e,t,n){return t&&Pe(e.prototype,t),n&&Pe(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function Ye(e,t,n){return(t=te(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Ct(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&lr(e,t)}function Xe(e){return Xe=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},Xe(e)}function lr(e,t){return lr=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(n,a){return n.__proto__=a,n},lr(e,t)}function Mc(){if(typeof Reflect=="undefined"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(e){return!1}}function Zo(e,t,n){return Zo=Mc()?Reflect.construct.bind():function(a,i,r){var o=[null];o.push.apply(o,i);var s=new(Function.bind.apply(a,o));return r&&lr(s,r.prototype),s},Zo.apply(null,arguments)}function es(e){var t=typeof Map=="function"?new Map:void 0;return es=function(n){if(n===null||(a=n,Function.toString.call(a).indexOf("[native code]")===-1))return n;var a;if(typeof n!="function")throw new TypeError("Super expression must either be null or a function");if(t!==void 0){if(t.has(n))return t.get(n);t.set(n,i)}function i(){return Zo(n,arguments,Xe(this).constructor)}return i.prototype=Object.create(n.prototype,{constructor:{value:i,enumerable:!1,writable:!0,configurable:!0}}),lr(i,n)},es(e)}function ts(e,t){if(t&&(typeof t=="object"||typeof t=="function"))return t;if(t!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return function(n){if(n===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return n}(e)}function Cr(e){var t=Mc();return function(){var n,a=Xe(e);if(t){var i=Xe(this).constructor;n=Reflect.construct(a,arguments,i)}else n=a.apply(this,arguments);return ts(this,n)}}function Nc(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&(e=Xe(e))!==null;);return e}function oe(){return oe=typeof Reflect!="undefined"&&Reflect.get?Reflect.get.bind():function(e,t,n){var a=Nc(e,t);if(a){var i=Object.getOwnPropertyDescriptor(a,t);return i.get?i.get.call(arguments.length<3?e:n):i.value}},oe.apply(this,arguments)}function Te(e,t){return function(n){if(Array.isArray(n))return n}(e)||function(n,a){var i=n==null?null:typeof Symbol!="undefined"&&n[Symbol.iterator]||n["@@iterator"];if(i!=null){var r,o,s,c,u=[],d=!0,g=!1;try{if(s=(i=i.call(n)).next,a===0){if(Object(i)!==i)return;d=!1}else for(;!(d=(r=s.call(i)).done)&&(u.push(r.value),u.length!==a);d=!0);}catch(I){g=!0,o=I}finally{try{if(!d&&i.return!=null&&(c=i.return(),Object(c)!==c))return}finally{if(g)throw o}}return u}}(e,t)||Fe(e,t)||function(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
2
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}()}function
|
|
3
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}()}function
|
|
4
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var r,o=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var c=n.next();return o=c.done,c},e:function(c){s=!0,r=c},f:function(){try{o||n.return==null||n.return()}finally{if(s)throw r}}}}function te(e){var t=function(n,a){if(typeof n!="object"||n===null)return n;var i=n[Symbol.toPrimitive];if(i!==void 0){var r=i.call(n,a||"default");if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(a==="string"?String:Number)(n)}(e,"string");return typeof t=="symbol"?t:String(t)}function Y(e,t,n,a,i){var r={};return Object.keys(a).forEach(function(o){r[o]=a[o]}),r.enumerable=!!r.enumerable,r.configurable=!!r.configurable,("value"in r||r.initializer)&&(r.writable=!0),r=n.slice().reverse().reduce(function(o,s){return s(e,t,o)||o},r),i&&r.initializer!==void 0&&(r.value=r.initializer?r.initializer.call(i):void 0,r.initializer=void 0),r.initializer===void 0&&(Object.defineProperty(e,t,r),r=null),r}var z=typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:{},le=function(e){return e&&e.Math==Math&&e},se=le(typeof globalThis=="object"&&globalThis)||le(typeof window=="object"&&window)||le(typeof self=="object"&&self)||le(typeof z=="object"&&z)||function(){return this}()||Function("return this")(),ye={},ce=function(e){try{return!!e()}catch(t){return!0}},Se=!ce(function(){return Object.defineProperty({},1,{get:function(){return 7}})[1]!=7}),Dt=!ce(function(){var e=function(){}.bind();return typeof e!="function"||e.hasOwnProperty("prototype")}),Tn=Dt,Gt=Function.prototype.call,Ke=Tn?Gt.bind(Gt):function(){return Gt.apply(Gt,arguments)},it={},Wn={}.propertyIsEnumerable,qn=Object.getOwnPropertyDescriptor,Jn=qn&&!Wn.call({1:2},1);it.f=Jn?function(e){var t=qn(this,e);return!!t&&t.enumerable}:Wn;var Xt,et,Rt=function(e,t){return{enumerable:!(1&e),configurable:!(2&e),writable:!(4&e),value:t}},Kn=Dt,fe=Function.prototype,de=fe.call,je=Kn&&fe.bind.bind(de,de),qe=function(e){return Kn?je(e):function(){return de.apply(e,arguments)}},Oe=qe,ut=Oe({}.toString),xt=Oe("".slice),ht=function(e){return xt(ut(e),8,-1)},Qt=ht,$e=qe,ke=function(e){if(Qt(e)==="Function")return $e(e)},Ht=ce,ri=ht,Rr=Object,Ar=ke("".split),zt=Ht(function(){return!Rr("z").propertyIsEnumerable(0)})?function(e){return ri(e)=="String"?Ar(e,""):Rr(e)}:Rr,Dn=function(e){return e==null},Ot=Dn,Wt=TypeError,en=function(e){if(Ot(e))throw Wt("Can't call method on "+e);return e},Uc=zt,Cd=en,pn=function(e){return Uc(Cd(e))},Ra=typeof document=="object"&&document.all,ji={all:Ra,IS_HTMLDDA:Ra===void 0&&Ra!==void 0},Vc=ji.all,tt=ji.IS_HTMLDDA?function(e){return typeof e=="function"||e===Vc}:function(e){return typeof e=="function"},ns=tt,Pr=ji.all,vt=ji.IS_HTMLDDA?function(e){return typeof e=="object"?e!==null:ns(e)||e===Pr}:function(e){return typeof e=="object"?e!==null:ns(e)},Bi=se,jc=tt,Bc=function(e){return jc(e)?e:void 0},fn=function(e,t){return arguments.length<2?Bc(Bi[e]):Bi[e]&&Bi[e][t]},dr=ke({}.isPrototypeOf),Xn=fn("navigator","userAgent")||"",rs=se,Dr=Xn,Aa=rs.process,is=rs.Deno,as=Aa&&Aa.versions||is&&is.version,Pa=as&&as.v8;Pa&&(et=(Xt=Pa.split("."))[0]>0&&Xt[0]<4?1:+(Xt[0]+Xt[1])),!et&&Dr&&(!(Xt=Dr.match(/Edge\/(\d+)/))||Xt[1]>=74)&&(Xt=Dr.match(/Chrome\/(\d+)/))&&(et=+Xt[1]);var mn=et,ii=mn,Fc=ce,os=!!Object.getOwnPropertySymbols&&!Fc(function(){var e=Symbol();return!String(e)||!(Object(e)instanceof Symbol)||!Symbol.sham&&ii&&ii<41}),Da=os&&!Symbol.sham&&typeof Symbol.iterator=="symbol",Gc=fn,Lr=tt,ss=dr,Hc=Object,Or=Da?function(e){return typeof e=="symbol"}:function(e){var t=Gc("Symbol");return Lr(t)&&ss(t.prototype,Hc(e))},La=String,ai=function(e){try{return La(e)}catch(t){return"Object"}},oi=tt,Qn=ai,Mr=TypeError,vn=function(e){if(oi(e))return e;throw Mr(Qn(e)+" is not a function")},It=vn,Ln=Dn,hr=function(e,t){var n=e[t];return Ln(n)?void 0:It(n)},cs=Ke,si=tt,Fi=vt,Oa=TypeError,pr={exports:{}},Gi=se,zc=Object.defineProperty,Hi=function(e,t){try{zc(Gi,e,{value:t,configurable:!0,writable:!0})}catch(n){Gi[e]=t}return t},us=Hi,ls="__core-js_shared__",tn=se[ls]||us(ls,{}),xn=tn;(pr.exports=function(e,t){return xn[e]||(xn[e]=t!==void 0?t:{})})("versions",[]).push({version:"3.25.5",mode:"global",copyright:"\xA9 2014-2022 Denis Pushkarev (zloirock.ru)",license:"https://github.com/zloirock/core-js/blob/v3.25.5/LICENSE",source:"https://github.com/zloirock/core-js"});var zi=en,ds=Object,Ut=function(e){return ds(zi(e))},Wc=Ut,hs=ke({}.hasOwnProperty),rt=Object.hasOwn||function(e,t){return hs(Wc(e),t)},qc=ke,Ma=0,On=Math.random(),Jc=qc(1 .toString),ci=function(e){return"Symbol("+(e===void 0?"":e)+")_"+Jc(++Ma+On,36)},Rd=se,Ad=pr.exports,ps=rt,Kc=ci,fs=os,ms=Da,Mt=Ad("wks"),fr=Rd.Symbol,vs=fr&&fr.for,Na=ms?fr:fr&&fr.withoutSetter||Kc,at=function(e){if(!ps(Mt,e)||!fs&&typeof Mt[e]!="string"){var t="Symbol."+e;fs&&ps(fr,e)?Mt[e]=fr[e]:Mt[e]=ms&&vs?vs(t):Na(t)}return Mt[e]},Xc=Ke,Qc=vt,gs=Or,Yc=hr,Ua=function(e,t){var n,a;if(t==="string"&&si(n=e.toString)&&!Fi(a=cs(n,e))||si(n=e.valueOf)&&!Fi(a=cs(n,e))||t!=="string"&&si(n=e.toString)&&!Fi(a=cs(n,e)))return a;throw Oa("Can't convert object to primitive value")},$c=TypeError,Zc=at("toPrimitive"),Nr=function(e,t){if(!Qc(e)||gs(e))return e;var n,a=Yc(e,Zc);if(a){if(t===void 0&&(t="default"),n=Xc(a,e,t),!Qc(n)||gs(n))return n;throw $c("Can't convert object to primitive value")}return t===void 0&&(t="number"),Ua(e,t)},Pd=Nr,Dd=Or,Va=function(e){var t=Pd(e,"string");return Dd(t)?t:t+""},eu=vt,Wi=se.document,qi=eu(Wi)&&eu(Wi.createElement),ja=function(e){return qi?Wi.createElement(e):{}},Ld=ja,tu=!Se&&!ce(function(){return Object.defineProperty(Ld("div"),"a",{get:function(){return 7}}).a!=7}),Od=Se,_s=Ke,nu=it,ru=Rt,Ji=pn,In=Va,Md=rt,Nd=tu,ys=Object.getOwnPropertyDescriptor;ye.f=Od?ys:function(e,t){if(e=Ji(e),t=In(t),Nd)try{return ys(e,t)}catch(n){}if(Md(e,t))return ru(!_s(nu.f,e,t),e[t])};var At={},Ba=Se&&ce(function(){return Object.defineProperty(function(){},"prototype",{value:42,writable:!1}).prototype!=42}),bs=vt,ui=String,iu=TypeError,yt=function(e){if(bs(e))return e;throw iu(ui(e)+" is not an object")},Ud=Se,Vd=tu,Ki=Ba,Xi=yt,Ss=Va,jd=TypeError,ks=Object.defineProperty,Fa=Object.getOwnPropertyDescriptor,au="enumerable",Bd="configurable",ou="writable";At.f=Ud?Ki?function(e,t,n){if(Xi(e),t=Ss(t),Xi(n),typeof e=="function"&&t==="prototype"&&"value"in n&&ou in n&&!n.writable){var a=Fa(e,t);a&&a.writable&&(e[t]=n.value,n={configurable:Bd in n?n.configurable:a.configurable,enumerable:au in n?n.enumerable:a.enumerable,writable:!1})}return ks(e,t,n)}:ks:function(e,t,n){if(Xi(e),t=Ss(t),Xi(n),Vd)try{return ks(e,t,n)}catch(a){}if("get"in n||"set"in n)throw jd("Accessors not supported");return"value"in n&&(e[t]=n.value),e};var Fd=At,Gd=Rt,gn=Se?function(e,t,n){return Fd.f(e,t,Gd(1,n))}:function(e,t,n){return e[t]=n,e},Ga={exports:{}},Ts=Se,Hd=rt,su=Function.prototype,cu=Ts&&Object.getOwnPropertyDescriptor,Qi=Hd(su,"name"),Ur={EXISTS:Qi,PROPER:Qi&&function(){}.name==="something",CONFIGURABLE:Qi&&(!Ts||Ts&&cu(su,"name").configurable)},Ha=tt,xs=tn,zd=ke(Function.toString);Ha(xs.inspectSource)||(xs.inspectSource=function(e){return zd(e)});var Yi,li,l,_=xs.inspectSource,R=tt,M=se.WeakMap,V=R(M)&&/native code/.test(String(M)),U=pr.exports,F=ci,W=U("keys"),Z=function(e){return W[e]||(W[e]=F(e))},pe={},me=V,Ce=se,De=vt,ve=gn,Me=rt,Ge=tn,ot=Z,lt=pe,Bt="Object already initialized",Yt=Ce.TypeError,$t=Ce.WeakMap;if(me||Ge.state){var Je=Ge.state||(Ge.state=new $t);Je.get=Je.get,Je.has=Je.has,Je.set=Je.set,Yi=function(e,t){if(Je.has(e))throw Yt(Bt);return t.facade=e,Je.set(e,t),t},li=function(e){return Je.get(e)||{}},l=function(e){return Je.has(e)}}else{var wt=ot("state");lt[wt]=!0,Yi=function(e,t){if(Me(e,wt))throw Yt(Bt);return t.facade=e,ve(e,wt,t),t},li=function(e){return Me(e,wt)?e[wt]:{}},l=function(e){return Me(e,wt)}}var st={set:Yi,get:li,has:l,enforce:function(e){return l(e)?li(e):Yi(e,{})},getterFor:function(e){return function(t){var n;if(!De(t)||(n=li(t)).type!==e)throw Yt("Incompatible receiver, "+e+" required");return n}}},za=ce,Vr=tt,$i=rt,mr=Se,Wa=Ur.CONFIGURABLE,Is=_,Tw=st.enforce,xw=st.get,uu=Object.defineProperty,Iw=mr&&!za(function(){return uu(function(){},"length",{value:8}).length!==8}),ww=String(String).split("String"),Ew=Ga.exports=function(e,t,n){String(t).slice(0,7)==="Symbol("&&(t="["+String(t).replace(/^Symbol\(([^)]*)\)/,"$1")+"]"),n&&n.getter&&(t="get "+t),n&&n.setter&&(t="set "+t),(!$i(e,"name")||Wa&&e.name!==t)&&(mr?uu(e,"name",{value:t,configurable:!0}):e.name=t),Iw&&n&&$i(n,"arity")&&e.length!==n.arity&&uu(e,"length",{value:n.arity});try{n&&$i(n,"constructor")&&n.constructor?mr&&uu(e,"prototype",{writable:!1}):e.prototype&&(e.prototype=void 0)}catch(i){}var a=Tw(e);return $i(a,"source")||(a.source=ww.join(typeof t=="string"?t:"")),e};Function.prototype.toString=Ew(function(){return Vr(this)&&xw(this).source||Is(this)},"toString");var Cw=tt,Rw=At,Aw=Ga.exports,Pw=Hi,qt=function(e,t,n,a){a||(a={});var i=a.enumerable,r=a.name!==void 0?a.name:t;if(Cw(n)&&Aw(n,r,a),a.global)i?e[t]=n:Pw(t,n);else{try{a.unsafe?e[t]&&(i=!0):delete e[t]}catch(o){}i?e[t]=n:Rw.f(e,t,{value:n,enumerable:!1,configurable:!a.nonConfigurable,writable:!a.nonWritable})}return e},di={},Dw=Math.ceil,Lw=Math.floor,Ow=Math.trunc||function(e){var t=+e;return(t>0?Lw:Dw)(t)},Yn=function(e){var t=+e;return t!=t||t===0?0:Ow(t)},Mw=Yn,Nw=Math.max,Uw=Math.min,hi=function(e,t){var n=Mw(e);return n<0?Nw(n+t,0):Uw(n,t)},Vw=Yn,jw=Math.min,vr=function(e){return e>0?jw(Vw(e),9007199254740991):0},Bw=vr,nn=function(e){return Bw(e.length)},Fw=pn,Gw=hi,Hw=nn,gg=function(e){return function(t,n,a){var i,r=Fw(t),o=Hw(r),s=Gw(a,o);if(e&&n!=n){for(;o>s;)if((i=r[s++])!=i)return!0}else for(;o>s;s++)if((e||s in r)&&r[s]===n)return e||s||0;return!e&&-1}},ws={includes:gg(!0),indexOf:gg(!1)},Wd=rt,zw=pn,Ww=ws.indexOf,qw=pe,_g=ke([].push),yg=function(e,t){var n,a=zw(e),i=0,r=[];for(n in a)!Wd(qw,n)&&Wd(a,n)&&_g(r,n);for(;t.length>i;)Wd(a,n=t[i++])&&(~Ww(r,n)||_g(r,n));return r},qd=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"],Jw=yg,Kw=qd.concat("length","prototype");di.f=Object.getOwnPropertyNames||function(e){return Jw(e,Kw)};var Jd={};Jd.f=Object.getOwnPropertySymbols;var Xw=fn,Qw=di,Yw=Jd,$w=yt,Zw=ke([].concat),eE=Xw("Reflect","ownKeys")||function(e){var t=Qw.f($w(e)),n=Yw.f;return n?Zw(t,n(e)):t},bg=rt,tE=eE,nE=ye,rE=At,iE=ce,aE=tt,oE=/#|\.prototype\./,Es=function(e,t){var n=cE[sE(e)];return n==lE||n!=uE&&(aE(t)?iE(t):!!t)},sE=Es.normalize=function(e){return String(e).replace(oE,".").toLowerCase()},cE=Es.data={},uE=Es.NATIVE="N",lE=Es.POLYFILL="P",Cs=Es,Kd=se,dE=ye.f,hE=gn,pE=qt,fE=Hi,mE=function(e,t,n){for(var a=tE(t),i=rE.f,r=nE.f,o=0;o<a.length;o++){var s=a[o];bg(e,s)||n&&bg(n,s)||i(e,s,r(t,s))}},vE=Cs,Ue=function(e,t){var n,a,i,r,o,s=e.target,c=e.global,u=e.stat;if(n=c?Kd:u?Kd[s]||fE(s,{}):(Kd[s]||{}).prototype)for(a in t){if(r=t[a],i=e.dontCallGetSet?(o=dE(n,a))&&o.value:n[a],!vE(c?a:s+(u?".":"#")+a,e.forced)&&i!==void 0){if(typeof r==typeof i)continue;mE(r,i)}(e.sham||i&&i.sham)&&hE(r,"sham",!0),pE(n,a,r,e)}},gE=Ue,_E=ce,yE=pn,Sg=ye.f,kg=Se,bE=_E(function(){Sg(1)});function Xd(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.')}gE({target:"Object",stat:!0,forced:!kg||bE,sham:!kg},{getOwnPropertyDescriptor:function(e,t){return Sg(yE(e),t)}}),function(e,t){e.exports=function(){function n(a,i,r){function o(u,d){if(!i[u]){if(!a[u]){if(!d&&Xd)return Xd(u);if(s)return s(u,!0);var g=new Error("Cannot find module '"+u+"'");throw g.code="MODULE_NOT_FOUND",g}var I=i[u]={exports:{}};a[u][0].call(I.exports,function(k){return o(a[u][1][k]||k)},I,I.exports,n,a,i,r)}return i[u].exports}for(var s=Xd,c=0;c<r.length;c++)o(r[c]);return o}return n}()({1:[function(n,a,i){var r=(0,n("./adapter_factory.js").adapterFactory)({window:typeof window=="undefined"?void 0:window});a.exports=r},{"./adapter_factory.js":2}],2:[function(n,a,i){Object.defineProperty(i,"__esModule",{value:!0}),i.adapterFactory=I;var r=g(n("./utils")),o=g(n("./chrome/chrome_shim")),s=g(n("./edge/edge_shim")),c=g(n("./firefox/firefox_shim")),u=g(n("./safari/safari_shim")),d=g(n("./common_shim"));function g(k){if(k&&k.__esModule)return k;var w={};if(k!=null)for(var A in k)Object.prototype.hasOwnProperty.call(k,A)&&(w[A]=k[A]);return w.default=k,w}function I(){var k=(arguments.length>0&&arguments[0]!==void 0?arguments[0]:{}).window,w=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{shimChrome:!0,shimFirefox:!0,shimEdge:!0,shimSafari:!0},A=r.log,p=r.detectBrowser(k),v={browserDetails:p,commonShim:d,extractVersion:r.extractVersion,disableLog:r.disableLog,disableWarnings:r.disableWarnings};switch(p.browser){case"chrome":if(!o||!o.shimPeerConnection||!w.shimChrome)return A("Chrome shim is not included in this adapter release."),v;if(p.version===null)return A("Chrome shim can not determine version, not shimming."),v;A("adapter.js shimming chrome."),v.browserShim=o,d.shimAddIceCandidateNullOrEmpty(k,p),o.shimGetUserMedia(k,p),o.shimMediaStream(k,p),o.shimPeerConnection(k,p),o.shimOnTrack(k,p),o.shimAddTrackRemoveTrack(k,p),o.shimGetSendersWithDtmf(k,p),o.shimGetStats(k,p),o.shimSenderReceiverGetStats(k,p),o.fixNegotiationNeeded(k,p),d.shimRTCIceCandidate(k,p),d.shimConnectionState(k,p),d.shimMaxMessageSize(k,p),d.shimSendThrowTypeError(k,p),d.removeExtmapAllowMixed(k,p);break;case"firefox":if(!c||!c.shimPeerConnection||!w.shimFirefox)return A("Firefox shim is not included in this adapter release."),v;A("adapter.js shimming firefox."),v.browserShim=c,d.shimAddIceCandidateNullOrEmpty(k,p),c.shimGetUserMedia(k,p),c.shimPeerConnection(k,p),c.shimOnTrack(k,p),c.shimRemoveStream(k,p),c.shimSenderGetStats(k,p),c.shimReceiverGetStats(k,p),c.shimRTCDataChannel(k,p),c.shimAddTransceiver(k,p),c.shimGetParameters(k,p),c.shimCreateOffer(k,p),c.shimCreateAnswer(k,p),d.shimRTCIceCandidate(k,p),d.shimConnectionState(k,p),d.shimMaxMessageSize(k,p),d.shimSendThrowTypeError(k,p);break;case"edge":if(!s||!s.shimPeerConnection||!w.shimEdge)return A("MS edge shim is not included in this adapter release."),v;A("adapter.js shimming edge."),v.browserShim=s,s.shimGetUserMedia(k,p),s.shimGetDisplayMedia(k,p),s.shimPeerConnection(k,p),s.shimReplaceTrack(k,p),d.shimMaxMessageSize(k,p),d.shimSendThrowTypeError(k,p);break;case"safari":if(!u||!w.shimSafari)return A("Safari shim is not included in this adapter release."),v;A("adapter.js shimming safari."),v.browserShim=u,d.shimAddIceCandidateNullOrEmpty(k,p),u.shimRTCIceServerUrls(k,p),u.shimCreateOfferLegacy(k,p),u.shimCallbacksAPI(k,p),u.shimLocalStreamsAPI(k,p),u.shimRemoteStreamsAPI(k,p),u.shimTrackEventTransceiver(k,p),u.shimGetUserMedia(k,p),u.shimAudioContext(k,p),d.shimRTCIceCandidate(k,p),d.shimMaxMessageSize(k,p),d.shimSendThrowTypeError(k,p),d.removeExtmapAllowMixed(k,p);break;default:A("Unsupported browser!")}return v}},{"./chrome/chrome_shim":3,"./common_shim":6,"./edge/edge_shim":7,"./firefox/firefox_shim":11,"./safari/safari_shim":14,"./utils":15}],3:[function(n,a,i){Object.defineProperty(i,"__esModule",{value:!0}),i.shimGetDisplayMedia=i.shimGetUserMedia=void 0;var r=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(f){return typeof f}:function(f){return f&&typeof Symbol=="function"&&f.constructor===Symbol&&f!==Symbol.prototype?"symbol":typeof f},o=n("./getusermedia");Object.defineProperty(i,"shimGetUserMedia",{enumerable:!0,get:function(){return o.shimGetUserMedia}});var s=n("./getdisplaymedia");Object.defineProperty(i,"shimGetDisplayMedia",{enumerable:!0,get:function(){return s.shimGetDisplayMedia}}),i.shimMediaStream=g,i.shimOnTrack=I,i.shimGetSendersWithDtmf=k,i.shimGetStats=w,i.shimSenderReceiverGetStats=A,i.shimAddTrackRemoveTrackWithNative=p,i.shimAddTrackRemoveTrack=v,i.shimPeerConnection=y,i.fixNegotiationNeeded=L;var c=u(n("../utils.js"));function u(f){if(f&&f.__esModule)return f;var b={};if(f!=null)for(var P in f)Object.prototype.hasOwnProperty.call(f,P)&&(b[P]=f[P]);return b.default=f,b}function d(f,b,P){return b in f?Object.defineProperty(f,b,{value:P,enumerable:!0,configurable:!0,writable:!0}):f[b]=P,f}function g(f){f.MediaStream=f.MediaStream||f.webkitMediaStream}function I(f){if((f===void 0?"undefined":r(f))==="object"&&f.RTCPeerConnection&&!("ontrack"in f.RTCPeerConnection.prototype)){Object.defineProperty(f.RTCPeerConnection.prototype,"ontrack",{get:function(){return this._ontrack},set:function(P){this._ontrack&&this.removeEventListener("track",this._ontrack),this.addEventListener("track",this._ontrack=P)},enumerable:!0,configurable:!0});var b=f.RTCPeerConnection.prototype.setRemoteDescription;f.RTCPeerConnection.prototype.setRemoteDescription=function(){var P=this;return this._ontrackpoly||(this._ontrackpoly=function(S){S.stream.addEventListener("addtrack",function(T){var C=void 0;C=f.RTCPeerConnection.prototype.getReceivers?P.getReceivers().find(function(B){return B.track&&B.track.id===T.track.id}):{track:T.track};var D=new Event("track");D.track=T.track,D.receiver=C,D.transceiver={receiver:C},D.streams=[S.stream],P.dispatchEvent(D)}),S.stream.getTracks().forEach(function(T){var C=void 0;C=f.RTCPeerConnection.prototype.getReceivers?P.getReceivers().find(function(B){return B.track&&B.track.id===T.id}):{track:T};var D=new Event("track");D.track=T,D.receiver=C,D.transceiver={receiver:C},D.streams=[S.stream],P.dispatchEvent(D)})},this.addEventListener("addstream",this._ontrackpoly)),b.apply(this,arguments)}}else c.wrapPeerConnectionEvent(f,"track",function(P){return P.transceiver||Object.defineProperty(P,"transceiver",{value:{receiver:P.receiver}}),P})}function k(f){if((f===void 0?"undefined":r(f))==="object"&&f.RTCPeerConnection&&!("getSenders"in f.RTCPeerConnection.prototype)&&"createDTMFSender"in f.RTCPeerConnection.prototype){var b=function(B,x){return{track:x,get dtmf(){return this._dtmf===void 0&&(x.kind==="audio"?this._dtmf=B.createDTMFSender(x):this._dtmf=null),this._dtmf},_pc:B}};if(!f.RTCPeerConnection.prototype.getSenders){f.RTCPeerConnection.prototype.getSenders=function(){return this._senders=this._senders||[],this._senders.slice()};var P=f.RTCPeerConnection.prototype.addTrack;f.RTCPeerConnection.prototype.addTrack=function(B,x){var h=P.apply(this,arguments);return h||(h=b(this,B),this._senders.push(h)),h};var S=f.RTCPeerConnection.prototype.removeTrack;f.RTCPeerConnection.prototype.removeTrack=function(B){S.apply(this,arguments);var x=this._senders.indexOf(B);x!==-1&&this._senders.splice(x,1)}}var T=f.RTCPeerConnection.prototype.addStream;f.RTCPeerConnection.prototype.addStream=function(B){var x=this;this._senders=this._senders||[],T.apply(this,[B]),B.getTracks().forEach(function(h){x._senders.push(b(x,h))})};var C=f.RTCPeerConnection.prototype.removeStream;f.RTCPeerConnection.prototype.removeStream=function(B){var x=this;this._senders=this._senders||[],C.apply(this,[B]),B.getTracks().forEach(function(h){var E=x._senders.find(function(O){return O.track===h});E&&x._senders.splice(x._senders.indexOf(E),1)})}}else if((f===void 0?"undefined":r(f))==="object"&&f.RTCPeerConnection&&"getSenders"in f.RTCPeerConnection.prototype&&"createDTMFSender"in f.RTCPeerConnection.prototype&&f.RTCRtpSender&&!("dtmf"in f.RTCRtpSender.prototype)){var D=f.RTCPeerConnection.prototype.getSenders;f.RTCPeerConnection.prototype.getSenders=function(){var B=this,x=D.apply(this,[]);return x.forEach(function(h){return h._pc=B}),x},Object.defineProperty(f.RTCRtpSender.prototype,"dtmf",{get:function(){return this._dtmf===void 0&&(this.track.kind==="audio"?this._dtmf=this._pc.createDTMFSender(this.track):this._dtmf=null),this._dtmf}})}}function w(f){if(f.RTCPeerConnection){var b=f.RTCPeerConnection.prototype.getStats;f.RTCPeerConnection.prototype.getStats=function(){var P=this,S=Array.prototype.slice.call(arguments),T=S[0],C=S[1],D=S[2];if(arguments.length>0&&typeof T=="function")return b.apply(this,arguments);if(b.length===0&&(arguments.length===0||typeof T!="function"))return b.apply(this,[]);var B=function(E){var O={};return E.result().forEach(function(N){var j={id:N.id,timestamp:N.timestamp,type:{localcandidate:"local-candidate",remotecandidate:"remote-candidate"}[N.type]||N.type};N.names().forEach(function(J){j[J]=N.stat(J)}),O[j.id]=j}),O},x=function(E){return new Map(Object.keys(E).map(function(O){return[O,E[O]]}))};if(arguments.length>=2){var h=function(E){C(x(B(E)))};return b.apply(this,[h,T])}return new Promise(function(E,O){b.apply(P,[function(N){E(x(B(N)))},O])}).then(C,D)}}}function A(f){if((f===void 0?"undefined":r(f))==="object"&&f.RTCPeerConnection&&f.RTCRtpSender&&f.RTCRtpReceiver){if(!("getStats"in f.RTCRtpSender.prototype)){var b=f.RTCPeerConnection.prototype.getSenders;b&&(f.RTCPeerConnection.prototype.getSenders=function(){var C=this,D=b.apply(this,[]);return D.forEach(function(B){return B._pc=C}),D});var P=f.RTCPeerConnection.prototype.addTrack;P&&(f.RTCPeerConnection.prototype.addTrack=function(){var C=P.apply(this,arguments);return C._pc=this,C}),f.RTCRtpSender.prototype.getStats=function(){var C=this;return this._pc.getStats().then(function(D){return c.filterStats(D,C.track,!0)})}}if(!("getStats"in f.RTCRtpReceiver.prototype)){var S=f.RTCPeerConnection.prototype.getReceivers;S&&(f.RTCPeerConnection.prototype.getReceivers=function(){var C=this,D=S.apply(this,[]);return D.forEach(function(B){return B._pc=C}),D}),c.wrapPeerConnectionEvent(f,"track",function(C){return C.receiver._pc=C.srcElement,C}),f.RTCRtpReceiver.prototype.getStats=function(){var C=this;return this._pc.getStats().then(function(D){return c.filterStats(D,C.track,!1)})}}if("getStats"in f.RTCRtpSender.prototype&&"getStats"in f.RTCRtpReceiver.prototype){var T=f.RTCPeerConnection.prototype.getStats;f.RTCPeerConnection.prototype.getStats=function(){if(arguments.length>0&&arguments[0]instanceof f.MediaStreamTrack){var C=arguments[0],D=void 0,B=void 0,x=void 0;return this.getSenders().forEach(function(h){h.track===C&&(D?x=!0:D=h)}),this.getReceivers().forEach(function(h){return h.track===C&&(B?x=!0:B=h),h.track===C}),x||D&&B?Promise.reject(new DOMException("There are more than one sender or receiver for the track.","InvalidAccessError")):D?D.getStats():B?B.getStats():Promise.reject(new DOMException("There is no sender or receiver for the track.","InvalidAccessError"))}return T.apply(this,arguments)}}}}function p(f){f.RTCPeerConnection.prototype.getLocalStreams=function(){var C=this;return this._shimmedLocalStreams=this._shimmedLocalStreams||{},Object.keys(this._shimmedLocalStreams).map(function(D){return C._shimmedLocalStreams[D][0]})};var b=f.RTCPeerConnection.prototype.addTrack;f.RTCPeerConnection.prototype.addTrack=function(C,D){if(!D)return b.apply(this,arguments);this._shimmedLocalStreams=this._shimmedLocalStreams||{};var B=b.apply(this,arguments);return this._shimmedLocalStreams[D.id]?this._shimmedLocalStreams[D.id].indexOf(B)===-1&&this._shimmedLocalStreams[D.id].push(B):this._shimmedLocalStreams[D.id]=[D,B],B};var P=f.RTCPeerConnection.prototype.addStream;f.RTCPeerConnection.prototype.addStream=function(C){var D=this;this._shimmedLocalStreams=this._shimmedLocalStreams||{},C.getTracks().forEach(function(h){if(D.getSenders().find(function(E){return E.track===h}))throw new DOMException("Track already exists.","InvalidAccessError")});var B=this.getSenders();P.apply(this,arguments);var x=this.getSenders().filter(function(h){return B.indexOf(h)===-1});this._shimmedLocalStreams[C.id]=[C].concat(x)};var S=f.RTCPeerConnection.prototype.removeStream;f.RTCPeerConnection.prototype.removeStream=function(C){return this._shimmedLocalStreams=this._shimmedLocalStreams||{},delete this._shimmedLocalStreams[C.id],S.apply(this,arguments)};var T=f.RTCPeerConnection.prototype.removeTrack;f.RTCPeerConnection.prototype.removeTrack=function(C){var D=this;return this._shimmedLocalStreams=this._shimmedLocalStreams||{},C&&Object.keys(this._shimmedLocalStreams).forEach(function(B){var x=D._shimmedLocalStreams[B].indexOf(C);x!==-1&&D._shimmedLocalStreams[B].splice(x,1),D._shimmedLocalStreams[B].length===1&&delete D._shimmedLocalStreams[B]}),T.apply(this,arguments)}}function v(f,b){if(f.RTCPeerConnection){if(f.RTCPeerConnection.prototype.addTrack&&b.version>=65)return p(f);var P=f.RTCPeerConnection.prototype.getLocalStreams;f.RTCPeerConnection.prototype.getLocalStreams=function(){var h=this,E=P.apply(this);return this._reverseStreams=this._reverseStreams||{},E.map(function(O){return h._reverseStreams[O.id]})};var S=f.RTCPeerConnection.prototype.addStream;f.RTCPeerConnection.prototype.addStream=function(h){var E=this;if(this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{},h.getTracks().forEach(function(N){if(E.getSenders().find(function(j){return j.track===N}))throw new DOMException("Track already exists.","InvalidAccessError")}),!this._reverseStreams[h.id]){var O=new f.MediaStream(h.getTracks());this._streams[h.id]=O,this._reverseStreams[O.id]=h,h=O}S.apply(this,[h])};var T=f.RTCPeerConnection.prototype.removeStream;f.RTCPeerConnection.prototype.removeStream=function(h){this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{},T.apply(this,[this._streams[h.id]||h]),delete this._reverseStreams[this._streams[h.id]?this._streams[h.id].id:h.id],delete this._streams[h.id]},f.RTCPeerConnection.prototype.addTrack=function(h,E){var O=this;if(this.signalingState==="closed")throw new DOMException("The RTCPeerConnection's signalingState is 'closed'.","InvalidStateError");var N=[].slice.call(arguments,1);if(N.length!==1||!N[0].getTracks().find(function($){return $===h}))throw new DOMException("The adapter.js addTrack polyfill only supports a single stream which is associated with the specified track.","NotSupportedError");if(this.getSenders().find(function($){return $.track===h}))throw new DOMException("Track already exists.","InvalidAccessError");this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{};var j=this._streams[E.id];if(j)j.addTrack(h),Promise.resolve().then(function(){O.dispatchEvent(new Event("negotiationneeded"))});else{var J=new f.MediaStream([h]);this._streams[E.id]=J,this._reverseStreams[J.id]=E,this.addStream(J)}return this.getSenders().find(function($){return $.track===h})},["createOffer","createAnswer"].forEach(function(h){var E=f.RTCPeerConnection.prototype[h],O=d({},h,function(){var N=this,j=arguments;return arguments.length&&typeof arguments[0]=="function"?E.apply(this,[function(J){var $=B(N,J);j[0].apply(null,[$])},function(J){j[1]&&j[1].apply(null,J)},arguments[2]]):E.apply(this,arguments).then(function(J){return B(N,J)})});f.RTCPeerConnection.prototype[h]=O[h]});var C=f.RTCPeerConnection.prototype.setLocalDescription;f.RTCPeerConnection.prototype.setLocalDescription=function(){return arguments.length&&arguments[0].type?(arguments[0]=x(this,arguments[0]),C.apply(this,arguments)):C.apply(this,arguments)};var D=Object.getOwnPropertyDescriptor(f.RTCPeerConnection.prototype,"localDescription");Object.defineProperty(f.RTCPeerConnection.prototype,"localDescription",{get:function(){var h=D.get.apply(this);return h.type===""?h:B(this,h)}}),f.RTCPeerConnection.prototype.removeTrack=function(h){var E=this;if(this.signalingState==="closed")throw new DOMException("The RTCPeerConnection's signalingState is 'closed'.","InvalidStateError");if(!h._pc)throw new DOMException("Argument 1 of RTCPeerConnection.removeTrack does not implement interface RTCRtpSender.","TypeError");if(h._pc!==this)throw new DOMException("Sender was not created by this connection.","InvalidAccessError");this._streams=this._streams||{};var O=void 0;Object.keys(this._streams).forEach(function(N){E._streams[N].getTracks().find(function(j){return h.track===j})&&(O=E._streams[N])}),O&&(O.getTracks().length===1?this.removeStream(this._reverseStreams[O.id]):O.removeTrack(h.track),this.dispatchEvent(new Event("negotiationneeded")))}}function B(h,E){var O=E.sdp;return Object.keys(h._reverseStreams||[]).forEach(function(N){var j=h._reverseStreams[N],J=h._streams[j.id];O=O.replace(new RegExp(J.id,"g"),j.id)}),new RTCSessionDescription({type:E.type,sdp:O})}function x(h,E){var O=E.sdp;return Object.keys(h._reverseStreams||[]).forEach(function(N){var j=h._reverseStreams[N],J=h._streams[j.id];O=O.replace(new RegExp(j.id,"g"),J.id)}),new RTCSessionDescription({type:E.type,sdp:O})}}function y(f,b){!f.RTCPeerConnection&&f.webkitRTCPeerConnection&&(f.RTCPeerConnection=f.webkitRTCPeerConnection),f.RTCPeerConnection&&b.version<53&&["setLocalDescription","setRemoteDescription","addIceCandidate"].forEach(function(P){var S=f.RTCPeerConnection.prototype[P],T=d({},P,function(){return arguments[0]=new(P==="addIceCandidate"?f.RTCIceCandidate:f.RTCSessionDescription)(arguments[0]),S.apply(this,arguments)});f.RTCPeerConnection.prototype[P]=T[P]})}function L(f,b){c.wrapPeerConnectionEvent(f,"negotiationneeded",function(P){var S=P.target;if(!(b.version<72||S.getConfiguration&&S.getConfiguration().sdpSemantics==="plan-b")||S.signalingState==="stable")return P})}},{"../utils.js":15,"./getdisplaymedia":4,"./getusermedia":5}],4:[function(n,a,i){function r(o,s){o.navigator.mediaDevices&&"getDisplayMedia"in o.navigator.mediaDevices||o.navigator.mediaDevices&&(typeof s=="function"?o.navigator.mediaDevices.getDisplayMedia=function(c){return s(c).then(function(u){var d=c.video&&c.video.width,g=c.video&&c.video.height,I=c.video&&c.video.frameRate;return c.video={mandatory:{chromeMediaSource:"desktop",chromeMediaSourceId:u,maxFrameRate:I||3}},d&&(c.video.mandatory.maxWidth=d),g&&(c.video.mandatory.maxHeight=g),o.navigator.mediaDevices.getUserMedia(c)})}:console.error("shimGetDisplayMedia: getSourceId argument is not a function"))}Object.defineProperty(i,"__esModule",{value:!0}),i.shimGetDisplayMedia=r},{}],5:[function(n,a,i){Object.defineProperty(i,"__esModule",{value:!0});var r=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(u){return typeof u}:function(u){return u&&typeof Symbol=="function"&&u.constructor===Symbol&&u!==Symbol.prototype?"symbol":typeof u};function o(u){if(u&&u.__esModule)return u;var d={};if(u!=null)for(var g in u)Object.prototype.hasOwnProperty.call(u,g)&&(d[g]=u[g]);return d.default=u,d}i.shimGetUserMedia=c;var s=o(n("../utils.js")).log;function c(u,d){var g=u&&u.navigator;if(g.mediaDevices){var I=function(v){if((v===void 0?"undefined":r(v))!=="object"||v.mandatory||v.optional)return v;var y={};return Object.keys(v).forEach(function(L){if(L!=="require"&&L!=="advanced"&&L!=="mediaSource"){var f=r(v[L])==="object"?v[L]:{ideal:v[L]};f.exact!==void 0&&typeof f.exact=="number"&&(f.min=f.max=f.exact);var b=function(S,T){return S?S+T.charAt(0).toUpperCase()+T.slice(1):T==="deviceId"?"sourceId":T};if(f.ideal!==void 0){y.optional=y.optional||[];var P={};typeof f.ideal=="number"?(P[b("min",L)]=f.ideal,y.optional.push(P),(P={})[b("max",L)]=f.ideal,y.optional.push(P)):(P[b("",L)]=f.ideal,y.optional.push(P))}f.exact!==void 0&&typeof f.exact!="number"?(y.mandatory=y.mandatory||{},y.mandatory[b("",L)]=f.exact):["min","max"].forEach(function(S){f[S]!==void 0&&(y.mandatory=y.mandatory||{},y.mandatory[b(S,L)]=f[S])})}}),v.advanced&&(y.optional=(y.optional||[]).concat(v.advanced)),y},k=function(v,y){if(d.version>=61)return y(v);if((v=JSON.parse(JSON.stringify(v)))&&r(v.audio)==="object"){var L=function(S,T,C){T in S&&!(C in S)&&(S[C]=S[T],delete S[T])};L((v=JSON.parse(JSON.stringify(v))).audio,"autoGainControl","googAutoGainControl"),L(v.audio,"noiseSuppression","googNoiseSuppression"),v.audio=I(v.audio)}if(v&&r(v.video)==="object"){var f=v.video.facingMode;f=f&&((f===void 0?"undefined":r(f))==="object"?f:{ideal:f});var b=d.version<66;if(f&&(f.exact==="user"||f.exact==="environment"||f.ideal==="user"||f.ideal==="environment")&&(!g.mediaDevices.getSupportedConstraints||!g.mediaDevices.getSupportedConstraints().facingMode||b)){delete v.video.facingMode;var P=void 0;if(f.exact==="environment"||f.ideal==="environment"?P=["back","rear"]:f.exact!=="user"&&f.ideal!=="user"||(P=["front"]),P)return g.mediaDevices.enumerateDevices().then(function(S){var T=(S=S.filter(function(C){return C.kind==="videoinput"})).find(function(C){return P.some(function(D){return C.label.toLowerCase().includes(D)})});return!T&&S.length&&P.includes("back")&&(T=S[S.length-1]),T&&(v.video.deviceId=f.exact?{exact:T.deviceId}:{ideal:T.deviceId}),v.video=I(v.video),s("chrome: "+JSON.stringify(v)),y(v)})}v.video=I(v.video)}return s("chrome: "+JSON.stringify(v)),y(v)},w=function(v){return d.version>=64?v:{name:{PermissionDeniedError:"NotAllowedError",PermissionDismissedError:"NotAllowedError",InvalidStateError:"NotAllowedError",DevicesNotFoundError:"NotFoundError",ConstraintNotSatisfiedError:"OverconstrainedError",TrackStartError:"NotReadableError",MediaDeviceFailedDueToShutdown:"NotAllowedError",MediaDeviceKillSwitchOn:"NotAllowedError",TabCaptureError:"AbortError",ScreenCaptureError:"AbortError",DeviceCaptureError:"AbortError"}[v.name]||v.name,message:v.message,constraint:v.constraint||v.constraintName,toString:function(){return this.name+(this.message&&": ")+this.message}}},A=function(v,y,L){k(v,function(f){g.webkitGetUserMedia(f,y,function(b){L&&L(w(b))})})};if(g.getUserMedia=A.bind(g),g.mediaDevices.getUserMedia){var p=g.mediaDevices.getUserMedia.bind(g.mediaDevices);g.mediaDevices.getUserMedia=function(v){return k(v,function(y){return p(y).then(function(L){if(y.audio&&!L.getAudioTracks().length||y.video&&!L.getVideoTracks().length)throw L.getTracks().forEach(function(f){f.stop()}),new DOMException("","NotFoundError");return L},function(L){return Promise.reject(w(L))})})}}}}},{"../utils.js":15}],6:[function(n,a,i){Object.defineProperty(i,"__esModule",{value:!0});var r=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(p){return typeof p}:function(p){return p&&typeof Symbol=="function"&&p.constructor===Symbol&&p!==Symbol.prototype?"symbol":typeof p};i.shimRTCIceCandidate=d,i.shimMaxMessageSize=g,i.shimSendThrowTypeError=I,i.shimConnectionState=k,i.removeExtmapAllowMixed=w,i.shimAddIceCandidateNullOrEmpty=A;var o=u(n("sdp")),s=c(n("./utils"));function c(p){if(p&&p.__esModule)return p;var v={};if(p!=null)for(var y in p)Object.prototype.hasOwnProperty.call(p,y)&&(v[y]=p[y]);return v.default=p,v}function u(p){return p&&p.__esModule?p:{default:p}}function d(p){if(!(!p.RTCIceCandidate||p.RTCIceCandidate&&"foundation"in p.RTCIceCandidate.prototype)){var v=p.RTCIceCandidate;p.RTCIceCandidate=function(y){if((y===void 0?"undefined":r(y))==="object"&&y.candidate&&y.candidate.indexOf("a=")===0&&((y=JSON.parse(JSON.stringify(y))).candidate=y.candidate.substr(2)),y.candidate&&y.candidate.length){var L=new v(y),f=o.default.parseCandidate(y.candidate),b=Object.assign(L,f);return b.toJSON=function(){return{candidate:b.candidate,sdpMid:b.sdpMid,sdpMLineIndex:b.sdpMLineIndex,usernameFragment:b.usernameFragment}},b}return new v(y)},p.RTCIceCandidate.prototype=v.prototype,s.wrapPeerConnectionEvent(p,"icecandidate",function(y){return y.candidate&&Object.defineProperty(y,"candidate",{value:new p.RTCIceCandidate(y.candidate),writable:"false"}),y})}}function g(p,v){if(p.RTCPeerConnection){"sctp"in p.RTCPeerConnection.prototype||Object.defineProperty(p.RTCPeerConnection.prototype,"sctp",{get:function(){return this._sctp===void 0?null:this._sctp}});var y=function(S){if(!S||!S.sdp)return!1;var T=o.default.splitSections(S.sdp);return T.shift(),T.some(function(C){var D=o.default.parseMLine(C);return D&&D.kind==="application"&&D.protocol.indexOf("SCTP")!==-1})},L=function(S){var T=S.sdp.match(/mozilla...THIS_IS_SDPARTA-(\d+)/);if(T===null||T.length<2)return-1;var C=parseInt(T[1],10);return C!=C?-1:C},f=function(S){var T=65536;return v.browser==="firefox"&&(T=v.version<57?S===-1?16384:2147483637:v.version<60?v.version===57?65535:65536:2147483637),T},b=function(S,T){var C=65536;v.browser==="firefox"&&v.version===57&&(C=65535);var D=o.default.matchPrefix(S.sdp,"a=max-message-size:");return D.length>0?C=parseInt(D[0].substr(19),10):v.browser==="firefox"&&T!==-1&&(C=2147483637),C},P=p.RTCPeerConnection.prototype.setRemoteDescription;p.RTCPeerConnection.prototype.setRemoteDescription=function(){if(this._sctp=null,v.browser==="chrome"&&v.version>=76&&this.getConfiguration().sdpSemantics==="plan-b"&&Object.defineProperty(this,"sctp",{get:function(){return this._sctp===void 0?null:this._sctp},enumerable:!0,configurable:!0}),y(arguments[0])){var S=L(arguments[0]),T=f(S),C=b(arguments[0],S),D=void 0;D=T===0&&C===0?Number.POSITIVE_INFINITY:T===0||C===0?Math.max(T,C):Math.min(T,C);var B={};Object.defineProperty(B,"maxMessageSize",{get:function(){return D}}),this._sctp=B}return P.apply(this,arguments)}}}function I(p){if(p.RTCPeerConnection&&"createDataChannel"in p.RTCPeerConnection.prototype){var v=p.RTCPeerConnection.prototype.createDataChannel;p.RTCPeerConnection.prototype.createDataChannel=function(){var L=v.apply(this,arguments);return y(L,this),L},s.wrapPeerConnectionEvent(p,"datachannel",function(L){return y(L.channel,L.target),L})}function y(L,f){var b=L.send;L.send=function(){var P=arguments[0],S=P.length||P.size||P.byteLength;if(L.readyState==="open"&&f.sctp&&S>f.sctp.maxMessageSize)throw new TypeError("Message too large (can send a maximum of "+f.sctp.maxMessageSize+" bytes)");return b.apply(L,arguments)}}}function k(p){if(p.RTCPeerConnection&&!("connectionState"in p.RTCPeerConnection.prototype)){var v=p.RTCPeerConnection.prototype;Object.defineProperty(v,"connectionState",{get:function(){return{completed:"connected",checking:"connecting"}[this.iceConnectionState]||this.iceConnectionState},enumerable:!0,configurable:!0}),Object.defineProperty(v,"onconnectionstatechange",{get:function(){return this._onconnectionstatechange||null},set:function(y){this._onconnectionstatechange&&(this.removeEventListener("connectionstatechange",this._onconnectionstatechange),delete this._onconnectionstatechange),y&&this.addEventListener("connectionstatechange",this._onconnectionstatechange=y)},enumerable:!0,configurable:!0}),["setLocalDescription","setRemoteDescription"].forEach(function(y){var L=v[y];v[y]=function(){return this._connectionstatechangepoly||(this._connectionstatechangepoly=function(f){var b=f.target;if(b._lastConnectionState!==b.connectionState){b._lastConnectionState=b.connectionState;var P=new Event("connectionstatechange",f);b.dispatchEvent(P)}return f},this.addEventListener("iceconnectionstatechange",this._connectionstatechangepoly)),L.apply(this,arguments)}})}}function w(p,v){if(p.RTCPeerConnection&&!(v.browser==="chrome"&&v.version>=71||v.browser==="safari"&&v.version>=605)){var y=p.RTCPeerConnection.prototype.setRemoteDescription;p.RTCPeerConnection.prototype.setRemoteDescription=function(L){if(L&&L.sdp&&L.sdp.indexOf(`
|
|
5
|
-
a=extmap-allow-mixed`)!==-1){var
|
|
1
|
+
var f7=Object.create;var fd=Object.defineProperty,p7=Object.defineProperties,$I=Object.getOwnPropertyDescriptor,m7=Object.getOwnPropertyDescriptors,v7=Object.getOwnPropertyNames,YI=Object.getOwnPropertySymbols,g7=Object.getPrototypeOf,ZI=Object.prototype.hasOwnProperty,_7=Object.prototype.propertyIsEnumerable;var Zv=(ne,q,p)=>q in ne?fd(ne,q,{enumerable:!0,configurable:!0,writable:!0,value:p}):ne[q]=p,Kr=(ne,q)=>{for(var p in q||(q={}))ZI.call(q,p)&&Zv(ne,p,q[p]);if(YI)for(var p of YI(q))_7.call(q,p)&&Zv(ne,p,q[p]);return ne},pd=(ne,q)=>p7(ne,m7(q));var eg=(ne,q)=>()=>(q||ne((q={exports:{}}).exports,q),q.exports);var y7=(ne,q,p,G)=>{if(q&&typeof q=="object"||typeof q=="function")for(let $ of v7(q))!ZI.call(ne,$)&&$!==p&&fd(ne,$,{get:()=>q[$],enumerable:!(G=$I(q,$))||G.enumerable});return ne};var lr=(ne,q,p)=>(p=ne!=null?f7(g7(ne)):{},y7(q||!ne||!ne.__esModule?fd(p,"default",{value:ne,enumerable:!0}):p,ne));var wn=(ne,q,p,G)=>{for(var $=G>1?void 0:G?$I(q,p):q,H=ne.length-1,Q;H>=0;H--)(Q=ne[H])&&($=(G?Q(q,p,$):Q($))||$);return G&&$&&fd(q,p,$),$};var Ve=(ne,q,p)=>(Zv(ne,typeof q!="symbol"?q+"":q,p),p);var Er=eg((tg,ng)=>{(function(ne,q){typeof tg=="object"&&typeof ng!="undefined"?ng.exports=q():typeof define=="function"&&define.amd?define(q):(ne=typeof globalThis!="undefined"?globalThis:ne||self).TRTC=q()})(tg,function(){function ne(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter(function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable})),n.push.apply(n,i)}return n}function q(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?ne(Object(n),!0).forEach(function(i){$e(e,i,n[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):ne(Object(n)).forEach(function(i){Object.defineProperty(e,i,Object.getOwnPropertyDescriptor(n,i))})}return e}function p(){p=function(){return e};var e={},t=Object.prototype,n=t.hasOwnProperty,i=typeof Symbol=="function"?Symbol:{},r=i.iterator||"@@iterator",o=i.asyncIterator||"@@asyncIterator",c=i.toStringTag||"@@toStringTag";function a(P,U,k){return Object.defineProperty(P,U,{value:k,enumerable:!0,configurable:!0,writable:!0}),P[U]}try{a({},"")}catch(P){a=function(U,k,h){return U[k]=h}}function s(P,U,k,h){var y=U&&U.prototype instanceof f?U:f,A=Object.create(y.prototype),D=new _(h||[]);return A._invoke=function(j,K,J){var se="suspendedStart";return function(ie,Je){if(se==="executing")throw new Error("Generator is already running");if(se==="completed"){if(ie==="throw")throw Je;return R()}for(J.method=ie,J.arg=Je;;){var Ue=J.delegate;if(Ue){var Fe=L(Ue,J);if(Fe){if(Fe===u)continue;return Fe}}if(J.method==="next")J.sent=J._sent=J.arg;else if(J.method==="throw"){if(se==="suspendedStart")throw se="completed",J.arg;J.dispatchException(J.arg)}else J.method==="return"&&J.abrupt("return",J.arg);se="executing";var ht=l(j,K,J);if(ht.type==="normal"){if(se=J.done?"completed":"suspendedYield",ht.arg===u)continue;return{value:ht.arg,done:J.done}}ht.type==="throw"&&(se="completed",J.method="throw",J.arg=ht.arg)}}}(P,k,D),A}function l(P,U,k){try{return{type:"normal",arg:P.call(U,k)}}catch(h){return{type:"throw",arg:h}}}e.wrap=s;var u={};function f(){}function S(){}function x(){}var E={};a(E,r,function(){return this});var I=Object.getPrototypeOf,m=I&&I(I(b([])));m&&m!==t&&n.call(m,r)&&(E=m);var T=x.prototype=f.prototype=Object.create(E);function v(P){["next","throw","return"].forEach(function(U){a(P,U,function(k){return this._invoke(U,k)})})}function w(P,U){function k(y,A,D,j){var K=l(P[y],P,A);if(K.type!=="throw"){var J=K.arg,se=J.value;return se&&typeof se=="object"&&n.call(se,"__await")?U.resolve(se.__await).then(function(ie){k("next",ie,D,j)},function(ie){k("throw",ie,D,j)}):U.resolve(se).then(function(ie){J.value=ie,D(J)},function(ie){return k("throw",ie,D,j)})}j(K.arg)}var h;this._invoke=function(y,A){function D(){return new U(function(j,K){k(y,A,j,K)})}return h=h?h.then(D,D):D()}}function L(P,U){var k=P.iterator[U.method];if(k===void 0){if(U.delegate=null,U.method==="throw"){if(P.iterator.return&&(U.method="return",U.arg=void 0,L(P,U),U.method==="throw"))return u;U.method="throw",U.arg=new TypeError("The iterator does not provide a 'throw' method")}return u}var h=l(k,P.iterator,U.arg);if(h.type==="throw")return U.method="throw",U.arg=h.arg,U.delegate=null,u;var y=h.arg;return y?y.done?(U[P.resultName]=y.value,U.next=P.nextLoc,U.method!=="return"&&(U.method="next",U.arg=void 0),U.delegate=null,u):y:(U.method="throw",U.arg=new TypeError("iterator result is not an object"),U.delegate=null,u)}function N(P){var U={tryLoc:P[0]};1 in P&&(U.catchLoc=P[1]),2 in P&&(U.finallyLoc=P[2],U.afterLoc=P[3]),this.tryEntries.push(U)}function V(P){var U=P.completion||{};U.type="normal",delete U.arg,P.completion=U}function _(P){this.tryEntries=[{tryLoc:"root"}],P.forEach(N,this),this.reset(!0)}function b(P){if(P){var U=P[r];if(U)return U.call(P);if(typeof P.next=="function")return P;if(!isNaN(P.length)){var k=-1,h=function y(){for(;++k<P.length;)if(n.call(P,k))return y.value=P[k],y.done=!1,y;return y.value=void 0,y.done=!0,y};return h.next=h}}return{next:R}}function R(){return{value:void 0,done:!0}}return S.prototype=x,a(T,"constructor",x),a(x,"constructor",S),S.displayName=a(x,c,"GeneratorFunction"),e.isGeneratorFunction=function(P){var U=typeof P=="function"&&P.constructor;return!!U&&(U===S||(U.displayName||U.name)==="GeneratorFunction")},e.mark=function(P){return Object.setPrototypeOf?Object.setPrototypeOf(P,x):(P.__proto__=x,a(P,c,"GeneratorFunction")),P.prototype=Object.create(T),P},e.awrap=function(P){return{__await:P}},v(w.prototype),a(w.prototype,o,function(){return this}),e.AsyncIterator=w,e.async=function(P,U,k,h,y){y===void 0&&(y=Promise);var A=new w(s(P,U,k,h),y);return e.isGeneratorFunction(U)?A:A.next().then(function(D){return D.done?D.value:A.next()})},v(T),a(T,c,"Generator"),a(T,r,function(){return this}),a(T,"toString",function(){return"[object Generator]"}),e.keys=function(P){var U=[];for(var k in P)U.push(k);return U.reverse(),function h(){for(;U.length;){var y=U.pop();if(y in P)return h.value=y,h.done=!1,h}return h.done=!0,h}},e.values=b,_.prototype={constructor:_,reset:function(P){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(V),!P)for(var U in this)U.charAt(0)==="t"&&n.call(this,U)&&!isNaN(+U.slice(1))&&(this[U]=void 0)},stop:function(){this.done=!0;var P=this.tryEntries[0].completion;if(P.type==="throw")throw P.arg;return this.rval},dispatchException:function(P){if(this.done)throw P;var U=this;function k(K,J){return A.type="throw",A.arg=P,U.next=K,J&&(U.method="next",U.arg=void 0),!!J}for(var h=this.tryEntries.length-1;h>=0;--h){var y=this.tryEntries[h],A=y.completion;if(y.tryLoc==="root")return k("end");if(y.tryLoc<=this.prev){var D=n.call(y,"catchLoc"),j=n.call(y,"finallyLoc");if(D&&j){if(this.prev<y.catchLoc)return k(y.catchLoc,!0);if(this.prev<y.finallyLoc)return k(y.finallyLoc)}else if(D){if(this.prev<y.catchLoc)return k(y.catchLoc,!0)}else{if(!j)throw new Error("try statement without catch or finally");if(this.prev<y.finallyLoc)return k(y.finallyLoc)}}}},abrupt:function(P,U){for(var k=this.tryEntries.length-1;k>=0;--k){var h=this.tryEntries[k];if(h.tryLoc<=this.prev&&n.call(h,"finallyLoc")&&this.prev<h.finallyLoc){var y=h;break}}y&&(P==="break"||P==="continue")&&y.tryLoc<=U&&U<=y.finallyLoc&&(y=null);var A=y?y.completion:{};return A.type=P,A.arg=U,y?(this.method="next",this.next=y.finallyLoc,u):this.complete(A)},complete:function(P,U){if(P.type==="throw")throw P.arg;return P.type==="break"||P.type==="continue"?this.next=P.arg:P.type==="return"?(this.rval=this.arg=P.arg,this.method="return",this.next="end"):P.type==="normal"&&U&&(this.next=U),u},finish:function(P){for(var U=this.tryEntries.length-1;U>=0;--U){var k=this.tryEntries[U];if(k.finallyLoc===P)return this.complete(k.completion,k.afterLoc),V(k),u}},catch:function(P){for(var U=this.tryEntries.length-1;U>=0;--U){var k=this.tryEntries[U];if(k.tryLoc===P){var h=k.completion;if(h.type==="throw"){var y=h.arg;V(k)}return y}}throw new Error("illegal catch attempt")},delegateYield:function(P,U,k){return this.delegate={iterator:b(P),resultName:U,nextLoc:k},this.method==="next"&&(this.arg=void 0),u}},e}function G(e){return G=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},G(e)}function $(e,t,n,i,r,o,c){try{var a=e[o](c),s=a.value}catch(l){return void n(l)}a.done?t(s):Promise.resolve(s).then(i,r)}function H(e){return function(){var t=this,n=arguments;return new Promise(function(i,r){var o=e.apply(t,n);function c(s){$(o,i,r,c,a,"next",s)}function a(s){$(o,i,r,c,a,"throw",s)}c(void 0)})}}function Q(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function Re(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}function Ie(e,t,n){return t&&Re(e.prototype,t),n&&Re(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function $e(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Et(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&dr(e,t)}function Ye(e){return Ye=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},Ye(e)}function dr(e,t){return dr=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(n,i){return n.__proto__=i,n},dr(e,t)}function Ac(){if(typeof Reflect=="undefined"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(e){return!1}}function zo(e,t,n){return zo=Ac()?Reflect.construct.bind():function(i,r,o){var c=[null];c.push.apply(c,r);var a=new(Function.bind.apply(i,c));return o&&dr(a,o.prototype),a},zo.apply(null,arguments)}function Wo(e){var t=typeof Map=="function"?new Map:void 0;return Wo=function(n){if(n===null||(i=n,Function.toString.call(i).indexOf("[native code]")===-1))return n;var i;if(typeof n!="function")throw new TypeError("Super expression must either be null or a function");if(t!==void 0){if(t.has(n))return t.get(n);t.set(n,r)}function r(){return zo(n,arguments,Ye(this).constructor)}return r.prototype=Object.create(n.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),dr(r,n)},Wo(e)}function Jo(e,t){if(t&&(typeof t=="object"||typeof t=="function"))return t;if(t!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return function(n){if(n===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return n}(e)}function Rr(e){var t=Ac();return function(){var n,i=Ye(e);if(t){var r=Ye(this).constructor;n=Reflect.construct(i,arguments,r)}else n=i.apply(this,arguments);return Jo(this,n)}}function Pc(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&(e=Ye(e))!==null;);return e}function le(){return le=typeof Reflect!="undefined"&&Reflect.get?Reflect.get.bind():function(e,t,n){var i=Pc(e,t);if(i){var r=Object.getOwnPropertyDescriptor(i,t);return r.get?r.get.call(arguments.length<3?e:n):r.value}},le.apply(this,arguments)}function Te(e,t){return function(n){if(Array.isArray(n))return n}(e)||function(n,i){var r=n==null?null:typeof Symbol!="undefined"&&n[Symbol.iterator]||n["@@iterator"];if(r!=null){var o,c,a=[],s=!0,l=!1;try{for(r=r.call(n);!(s=(o=r.next()).done)&&(a.push(o.value),!i||a.length!==i);s=!0);}catch(u){l=!0,c=u}finally{try{s||r.return==null||r.return()}finally{if(l)throw c}}return a}}(e,t)||je(e,t)||function(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
2
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}()}function Se(e){return function(t){if(Array.isArray(t))return He(t)}(e)||function(t){if(typeof Symbol!="undefined"&&t[Symbol.iterator]!=null||t["@@iterator"]!=null)return Array.from(t)}(e)||je(e)||function(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
|
|
3
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}()}function je(e,t){if(e){if(typeof e=="string")return He(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return n==="Object"&&e.constructor&&(n=e.constructor.name),n==="Map"||n==="Set"?Array.from(e):n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?He(e,t):void 0}}function He(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,i=new Array(t);n<t;n++)i[n]=e[n];return i}function oe(e,t){var n=typeof Symbol!="undefined"&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=je(e))||t&&e&&typeof e.length=="number"){n&&(e=n);var i=0,r=function(){};return{s:r,n:function(){return i>=e.length?{done:!0}:{done:!1,value:e[i++]}},e:function(s){throw s},f:r}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
|
|
4
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var o,c=!0,a=!1;return{s:function(){n=n.call(e)},n:function(){var s=n.next();return c=s.done,s},e:function(s){a=!0,o=s},f:function(){try{c||n.return==null||n.return()}finally{if(a)throw o}}}}function X(e,t,n,i,r){var o={};return Object.keys(i).forEach(function(c){o[c]=i[c]}),o.enumerable=!!o.enumerable,o.configurable=!!o.configurable,("value"in o||o.initializer)&&(o.writable=!0),o=n.slice().reverse().reduce(function(c,a){return a(e,t,c)||c},o),r&&o.initializer!==void 0&&(o.value=o.initializer?o.initializer.call(r):void 0,o.initializer=void 0),o.initializer===void 0&&(Object.defineProperty(e,t,o),o=null),o}var ce=typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:{},z=function(e){return e&&e.Math==Math&&e},re=z(typeof globalThis=="object"&&globalThis)||z(typeof window=="object"&&window)||z(typeof self=="object"&&self)||z(typeof ce=="object"&&ce)||function(){return this}()||Function("return this")(),be={},ue=function(e){try{return!!e()}catch(t){return!0}},ye=!ue(function(){return Object.defineProperty({},1,{get:function(){return 7}})[1]!=7}),Me=!ue(function(){var e=function(){}.bind();return typeof e!="function"||e.hasOwnProperty("prototype")}),Jt=Me,Zt=Function.prototype.call,Ke=Jt?Zt.bind(Zt):function(){return Zt.apply(Zt,arguments)},qt={},ft={}.propertyIsEnumerable,Jn=Object.getOwnPropertyDescriptor,hr=Jn&&!ft.call({1:2},1);qt.f=hr?function(e){var t=Jn(this,e);return!!t&&t.enumerable}:ft;var Ht,Rn,Ze=function(e,t){return{enumerable:!(1&e),configurable:!(2&e),writable:!(4&e),value:t}},Gt=Me,qn=Function.prototype,he=qn.call,de=Gt&&qn.bind.bind(he,he),Ne=function(e){return Gt?de(e):function(){return he.apply(e,arguments)}},We=Ne,De=We({}.toString),ut=We("".slice),rt=function(e){return ut(De(e),8,-1)},Ut=rt,en=Ne,pe=function(e){if(Ut(e)==="Function")return en(e)},Ot=ue,Kt=rt,fr=Object,Pi=pe("".split),yn=Ot(function(){return!fr("z").propertyIsEnumerable(0)})?function(e){return Kt(e)=="String"?Pi(e,""):fr(e)}:fr,Rt=function(e){return e==null},Cd=Rt,Lt=TypeError,pt=function(e){if(Cd(e))throw Lt("Can't call method on "+e);return e},Dc=yn,Oc=pt,bn=function(e){return Dc(Oc(e))},ba=typeof document=="object"&&document.all,Di={all:ba,IS_HTMLDDA:ba===void 0&&ba!==void 0},Lc=Di.all,it=Di.IS_HTMLDDA?function(e){return typeof e=="function"||e===Lc}:function(e){return typeof e=="function"},Sa=it,Mc=Di.all,at=Di.IS_HTMLDDA?function(e){return typeof e=="object"?e!==null:Sa(e)||e===Mc}:function(e){return typeof e=="object"?e!==null:Sa(e)},ka=re,qo=it,Nc=function(e){return qo(e)?e:void 0},An=function(e,t){return arguments.length<2?Nc(ka[e]):ka[e]&&ka[e][t]},Sn=pe({}.isPrototypeOf),Kn=An("navigator","userAgent")||"",Uc=re,Ta=Kn,Xr=Uc.process,xa=Uc.Deno,Ko=Xr&&Xr.versions||xa&&xa.version,Xo=Ko&&Ko.v8;Xo&&(Rn=(Ht=Xo.split("."))[0]>0&&Ht[0]<4?1:+(Ht[0]+Ht[1])),!Rn&&Ta&&(!(Ht=Ta.match(/Edge\/(\d+)/))||Ht[1]>=74)&&(Ht=Ta.match(/Chrome\/(\d+)/))&&(Rn=+Ht[1]);var pr=Rn,mr=pr,Oi=ue,Qo=!!Object.getOwnPropertySymbols&&!Oi(function(){var e=Symbol();return!String(e)||!(Object(e)instanceof Symbol)||!Symbol.sham&&mr&&mr<41}),Yo=Qo&&!Symbol.sham&&typeof Symbol.iterator=="symbol",$o=An,Vc=it,Ar=Sn,Zo=Object,Li=Yo?function(e){return typeof e=="symbol"}:function(e){var t=$o("Symbol");return Vc(t)&&Ar(t.prototype,Zo(e))},Ia=String,Xn=function(e){try{return Ia(e)}catch(t){return"Object"}},Ed=it,Qr=Xn,Qn=TypeError,Vt=function(e){if(Ed(e))return e;throw Qn(Qr(e)+" is not a function")},jc=Vt,It=Rt,Xt=function(e,t){var n=e[t];return It(n)?void 0:jc(n)},Mi=Ke,es=it,Yr=at,ts=TypeError,Pr={exports:{}},$r=re,wa=Object.defineProperty,Ca=function(e,t){try{wa($r,e,{value:t,configurable:!0,writable:!0})}catch(n){$r[e]=t}return t},ns=Ca,Ea="__core-js_shared__",Ra=re[Ea]||ns(Ea,{}),pn=Ra;(Pr.exports=function(e,t){return pn[e]||(pn[e]=t!==void 0?t:{})})("versions",[]).push({version:"3.25.5",mode:"global",copyright:"\xA9 2014-2022 Denis Pushkarev (zloirock.ru)",license:"https://github.com/zloirock/core-js/blob/v3.25.5/LICENSE",source:"https://github.com/zloirock/core-js"});var Pn=pt,Ni=Object,Mt=function(e){return Ni(Pn(e))},rs=Mt,Bc=pe({}.hasOwnProperty),kt=Object.hasOwn||function(e,t){return Bc(rs(e),t)},Dn=pe,Fc=0,Aa=Math.random(),On=Dn(1 .toString),Ui=function(e){return"Symbol("+(e===void 0?"":e)+")_"+On(++Fc+Aa,36)},is=re,Rd=Pr.exports,Hc=kt,Gc=Ui,as=Qo,os=Yo,Zr=Rd("wks"),At=is.Symbol,ss=At&&At.for,zc=os?At:At&&At.withoutSetter||Gc,tt=function(e){if(!Hc(Zr,e)||!as&&typeof Zr[e]!="string"){var t="Symbol."+e;as&&Hc(At,e)?Zr[e]=At[e]:Zr[e]=os&&ss?ss(t):zc(t)}return Zr[e]},Wc=Ke,cs=at,Jc=Li,qc=Xt,Kc=function(e,t){var n,i;if(t==="string"&&es(n=e.toString)&&!Yr(i=Mi(n,e))||es(n=e.valueOf)&&!Yr(i=Mi(n,e))||t!=="string"&&es(n=e.toString)&&!Yr(i=Mi(n,e)))return i;throw ts("Can't convert object to primitive value")},Pa=TypeError,Xc=tt("toPrimitive"),Vi=function(e,t){if(!cs(e)||Jc(e))return e;var n,i=qc(e,Xc);if(i){if(t===void 0&&(t="default"),n=Wc(i,e,t),!cs(n)||Jc(n))return n;throw Pa("Can't convert object to primitive value")}return t===void 0&&(t="number"),Kc(e,t)},ji=Vi,Ad=Li,Da=function(e){var t=ji(e,"string");return Ad(t)?t:t+""},Qc=at,us=re.document,ls=Qc(us)&&Qc(us.createElement),vr=function(e){return ls?us.createElement(e):{}},Pd=vr,Yc=!ye&&!ue(function(){return Object.defineProperty(Pd("div"),"a",{get:function(){return 7}}).a!=7}),Dd=ye,Od=Ke,ds=qt,$c=Ze,Zc=bn,Bi=Da,kn=kt,Ld=Yc,eu=Object.getOwnPropertyDescriptor;be.f=Dd?eu:function(e,t){if(e=Zc(e),t=Bi(t),Ld)try{return eu(e,t)}catch(n){}if(kn(e,t))return $c(!Od(ds.f,e,t),e[t])};var Pt={},hs=ye&&ue(function(){return Object.defineProperty(function(){},"prototype",{value:42,writable:!1}).prototype!=42}),fs=at,ps=String,ei=TypeError,Tt=function(e){if(fs(e))return e;throw ei(ps(e)+" is not an object")},ms=ye,Md=Yc,Nd=hs,gr=Tt,vs=Da,tu=TypeError,gs=Object.defineProperty,Ud=Object.getOwnPropertyDescriptor,Oa="enumerable",nu="configurable",Vd="writable";Pt.f=ms?Nd?function(e,t,n){if(gr(e),t=vs(t),gr(n),typeof e=="function"&&t==="prototype"&&"value"in n&&Vd in n&&!n.writable){var i=Ud(e,t);i&&i.writable&&(e[t]=n.value,n={configurable:nu in n?n.configurable:i.configurable,enumerable:Oa in n?n.enumerable:i.enumerable,writable:!1})}return gs(e,t,n)}:gs:function(e,t,n){if(gr(e),t=vs(t),gr(n),Md)try{return gs(e,t,n)}catch(i){}if("get"in n||"set"in n)throw tu("Accessors not supported");return"value"in n&&(e[t]=n.value),e};var ru=Pt,jd=Ze,Ln=ye?function(e,t,n){return ru.f(e,t,jd(1,n))}:function(e,t,n){return e[t]=n,e},Fi={exports:{}},La=ye,Bd=kt,iu=Function.prototype,Fd=La&&Object.getOwnPropertyDescriptor,Ma=Bd(iu,"name"),Yn={EXISTS:Ma,PROPER:Ma&&function(){}.name==="something",CONFIGURABLE:Ma&&(!La||La&&Fd(iu,"name").configurable)},Hd=it,ti=Ra,Gd=pe(Function.toString);Hd(ti.inspectSource)||(ti.inspectSource=function(e){return Gd(e)});var Na,ni,Hi,d=ti.inspectSource,g=it,C=re.WeakMap,O=g(C)&&/native code/.test(String(C)),B=Pr.exports,M=Ui,F=B("keys"),W=function(e){return F[e]||(F[e]=M(e))},ee={},fe=O,me=re,we=at,Ae=Ln,ve=kt,Oe=Ra,Be=W,ot=ee,lt="Object already initialized",jt=me.TypeError,mn=me.WeakMap;if(fe||Oe.state){var bt=Oe.state||(Oe.state=new mn);bt.get=bt.get,bt.has=bt.has,bt.set=bt.set,Na=function(e,t){if(bt.has(e))throw jt(lt);return t.facade=e,bt.set(e,t),t},ni=function(e){return bt.get(e)||{}},Hi=function(e){return bt.has(e)}}else{var qe=Be("state");ot[qe]=!0,Na=function(e,t){if(ve(e,qe))throw jt(lt);return t.facade=e,Ae(e,qe,t),t},ni=function(e){return ve(e,qe)?e[qe]:{}},Hi=function(e){return ve(e,qe)}}var Xe={set:Na,get:ni,has:Hi,enforce:function(e){return Hi(e)?ni(e):Na(e,{})},getterFor:function(e){return function(t){var n;if(!we(t)||(n=ni(t)).type!==e)throw jt("Incompatible receiver, "+e+" required");return n}}},_r=ue,Ua=it,Mn=kt,Va=ye,ri=Yn.CONFIGURABLE,ja=d,_s=Xe.enforce,yw=Xe.get,au=Object.defineProperty,bw=Va&&!_r(function(){return au(function(){},"length",{value:8}).length!==8}),Sw=String(String).split("String"),kw=Fi.exports=function(e,t,n){String(t).slice(0,7)==="Symbol("&&(t="["+String(t).replace(/^Symbol\(([^)]*)\)/,"$1")+"]"),n&&n.getter&&(t="get "+t),n&&n.setter&&(t="set "+t),(!Mn(e,"name")||ri&&e.name!==t)&&(Va?au(e,"name",{value:t,configurable:!0}):e.name=t),bw&&n&&Mn(n,"arity")&&e.length!==n.arity&&au(e,"length",{value:n.arity});try{n&&Mn(n,"constructor")&&n.constructor?Va&&au(e,"prototype",{writable:!1}):e.prototype&&(e.prototype=void 0)}catch(r){}var i=_s(e);return Mn(i,"source")||(i.source=Sw.join(typeof t=="string"?t:"")),e};Function.prototype.toString=kw(function(){return Ua(this)&&yw(this).source||ja(this)},"toString");var Tw=it,xw=Pt,Iw=Fi.exports,ww=Ca,Qt=function(e,t,n,i){i||(i={});var r=i.enumerable,o=i.name!==void 0?i.name:t;if(Tw(n)&&Iw(n,o,i),i.global)r?e[t]=n:ww(t,n);else{try{i.unsafe?e[t]&&(r=!0):delete e[t]}catch(c){}r?e[t]=n:xw.f(e,t,{value:n,enumerable:!1,configurable:!i.nonConfigurable,writable:!i.nonWritable})}return e},ii={},Cw=Math.ceil,Ew=Math.floor,Rw=Math.trunc||function(e){var t=+e;return(t>0?Ew:Cw)(t)},$n=function(e){var t=+e;return t!=t||t===0?0:Rw(t)},Aw=$n,Pw=Math.max,Dw=Math.min,ai=function(e,t){var n=Aw(e);return n<0?Pw(n+t,0):Dw(n,t)},Ow=$n,Lw=Math.min,yr=function(e){return e>0?Lw(Ow(e),9007199254740991):0},Mw=yr,nn=function(e){return Mw(e.length)},Nw=bn,Uw=ai,Vw=nn,pg=function(e){return function(t,n,i){var r,o=Nw(t),c=Vw(o),a=Uw(i,c);if(e&&n!=n){for(;c>a;)if((r=o[a++])!=r)return!0}else for(;c>a;a++)if((e||a in o)&&o[a]===n)return e||a||0;return!e&&-1}},ys={includes:pg(!0),indexOf:pg(!1)},zd=kt,jw=bn,Bw=ys.indexOf,Fw=ee,mg=pe([].push),vg=function(e,t){var n,i=jw(e),r=0,o=[];for(n in i)!zd(Fw,n)&&zd(i,n)&&mg(o,n);for(;t.length>r;)zd(i,n=t[r++])&&(~Bw(o,n)||mg(o,n));return o},Wd=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"],Hw=vg,Gw=Wd.concat("length","prototype");ii.f=Object.getOwnPropertyNames||function(e){return Hw(e,Gw)};var Jd={};Jd.f=Object.getOwnPropertySymbols;var zw=An,Ww=ii,Jw=Jd,qw=Tt,Kw=pe([].concat),Xw=zw("Reflect","ownKeys")||function(e){var t=Ww.f(qw(e)),n=Jw.f;return n?Kw(t,n(e)):t},gg=kt,Qw=Xw,Yw=be,$w=Pt,Zw=ue,eC=it,tC=/#|\.prototype\./,bs=function(e,t){var n=rC[nC(e)];return n==aC||n!=iC&&(eC(t)?Zw(t):!!t)},nC=bs.normalize=function(e){return String(e).replace(tC,".").toLowerCase()},rC=bs.data={},iC=bs.NATIVE="N",aC=bs.POLYFILL="P",Ss=bs,qd=re,oC=be.f,sC=Ln,cC=Qt,uC=Ca,lC=function(e,t,n){for(var i=Qw(t),r=$w.f,o=Yw.f,c=0;c<i.length;c++){var a=i[c];gg(e,a)||n&&gg(n,a)||r(e,a,o(t,a))}},dC=Ss,Le=function(e,t){var n,i,r,o,c,a=e.target,s=e.global,l=e.stat;if(n=s?qd:l?qd[a]||uC(a,{}):(qd[a]||{}).prototype)for(i in t){if(o=t[i],r=e.dontCallGetSet?(c=oC(n,i))&&c.value:n[i],!dC(s?i:a+(l?".":"#")+i,e.forced)&&r!==void 0){if(typeof o==typeof r)continue;lC(o,r)}(e.sham||r&&r.sham)&&sC(o,"sham",!0),cC(n,i,o,e)}},hC=Le,fC=ue,pC=bn,_g=be.f,yg=ye,mC=fC(function(){_g(1)});function Kd(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.')}hC({target:"Object",stat:!0,forced:!yg||mC,sham:!yg},{getOwnPropertyDescriptor:function(e,t){return _g(pC(e),t)}}),function(e,t){e.exports=function(){function n(i,r,o){function c(l,u){if(!r[l]){if(!i[l]){if(!u&&Kd)return Kd(l);if(a)return a(l,!0);var f=new Error("Cannot find module '"+l+"'");throw f.code="MODULE_NOT_FOUND",f}var S=r[l]={exports:{}};i[l][0].call(S.exports,function(x){return c(i[l][1][x]||x)},S,S.exports,n,i,r,o)}return r[l].exports}for(var a=Kd,s=0;s<o.length;s++)c(o[s]);return c}return n}()({1:[function(n,i,r){var o=(0,n("./adapter_factory.js").adapterFactory)({window:typeof window=="undefined"?void 0:window});i.exports=o},{"./adapter_factory.js":2}],2:[function(n,i,r){function o(I){return o=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(m){return typeof m}:function(m){return m&&typeof Symbol=="function"&&m.constructor===Symbol&&m!==Symbol.prototype?"symbol":typeof m},o(I)}Object.defineProperty(r,"__esModule",{value:!0}),r.adapterFactory=E;var c=x(n("./utils")),a=x(n("./chrome/chrome_shim")),s=x(n("./firefox/firefox_shim")),l=x(n("./safari/safari_shim")),u=x(n("./common_shim")),f=x(n("sdp"));function S(I){if(typeof WeakMap!="function")return null;var m=new WeakMap,T=new WeakMap;return(S=function(v){return v?T:m})(I)}function x(I,m){if(!m&&I&&I.__esModule)return I;if(I===null||o(I)!=="object"&&typeof I!="function")return{default:I};var T=S(m);if(T&&T.has(I))return T.get(I);var v={},w=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var L in I)if(L!=="default"&&Object.prototype.hasOwnProperty.call(I,L)){var N=w?Object.getOwnPropertyDescriptor(I,L):null;N&&(N.get||N.set)?Object.defineProperty(v,L,N):v[L]=I[L]}return v.default=I,T&&T.set(I,v),v}function E(){var I=(arguments.length>0&&arguments[0]!==void 0?arguments[0]:{}).window,m=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{shimChrome:!0,shimFirefox:!0,shimSafari:!0},T=c.log,v=c.detectBrowser(I),w={browserDetails:v,commonShim:u,extractVersion:c.extractVersion,disableLog:c.disableLog,disableWarnings:c.disableWarnings,sdp:f};switch(v.browser){case"chrome":if(!a||!a.shimPeerConnection||!m.shimChrome)return T("Chrome shim is not included in this adapter release."),w;if(v.version===null)return T("Chrome shim can not determine version, not shimming."),w;T("adapter.js shimming chrome."),w.browserShim=a,u.shimAddIceCandidateNullOrEmpty(I,v),u.shimParameterlessSetLocalDescription(I,v),a.shimGetUserMedia(I,v),a.shimMediaStream(I,v),a.shimPeerConnection(I,v),a.shimOnTrack(I,v),a.shimAddTrackRemoveTrack(I,v),a.shimGetSendersWithDtmf(I,v),a.shimGetStats(I,v),a.shimSenderReceiverGetStats(I,v),a.fixNegotiationNeeded(I,v),u.shimRTCIceCandidate(I,v),u.shimRTCIceCandidateRelayProtocol(I,v),u.shimConnectionState(I,v),u.shimMaxMessageSize(I,v),u.shimSendThrowTypeError(I,v),u.removeExtmapAllowMixed(I,v);break;case"firefox":if(!s||!s.shimPeerConnection||!m.shimFirefox)return T("Firefox shim is not included in this adapter release."),w;T("adapter.js shimming firefox."),w.browserShim=s,u.shimAddIceCandidateNullOrEmpty(I,v),u.shimParameterlessSetLocalDescription(I,v),s.shimGetUserMedia(I,v),s.shimPeerConnection(I,v),s.shimOnTrack(I,v),s.shimRemoveStream(I,v),s.shimSenderGetStats(I,v),s.shimReceiverGetStats(I,v),s.shimRTCDataChannel(I,v),s.shimAddTransceiver(I,v),s.shimGetParameters(I,v),s.shimCreateOffer(I,v),s.shimCreateAnswer(I,v),u.shimRTCIceCandidate(I,v),u.shimConnectionState(I,v),u.shimMaxMessageSize(I,v),u.shimSendThrowTypeError(I,v);break;case"safari":if(!l||!m.shimSafari)return T("Safari shim is not included in this adapter release."),w;T("adapter.js shimming safari."),w.browserShim=l,u.shimAddIceCandidateNullOrEmpty(I,v),u.shimParameterlessSetLocalDescription(I,v),l.shimRTCIceServerUrls(I,v),l.shimCreateOfferLegacy(I,v),l.shimCallbacksAPI(I,v),l.shimLocalStreamsAPI(I,v),l.shimRemoteStreamsAPI(I,v),l.shimTrackEventTransceiver(I,v),l.shimGetUserMedia(I,v),l.shimAudioContext(I,v),u.shimRTCIceCandidate(I,v),u.shimRTCIceCandidateRelayProtocol(I,v),u.shimMaxMessageSize(I,v),u.shimSendThrowTypeError(I,v),u.removeExtmapAllowMixed(I,v);break;default:T("Unsupported browser!")}return w}},{"./chrome/chrome_shim":3,"./common_shim":6,"./firefox/firefox_shim":7,"./safari/safari_shim":10,"./utils":11,sdp:12}],3:[function(n,i,r){Object.defineProperty(r,"__esModule",{value:!0}),r.fixNegotiationNeeded=V,r.shimAddTrackRemoveTrack=L,r.shimAddTrackRemoveTrackWithNative=w,Object.defineProperty(r,"shimGetDisplayMedia",{enumerable:!0,get:function(){return a.shimGetDisplayMedia}}),r.shimGetSendersWithDtmf=m,r.shimGetStats=T,Object.defineProperty(r,"shimGetUserMedia",{enumerable:!0,get:function(){return c.shimGetUserMedia}}),r.shimMediaStream=E,r.shimOnTrack=I,r.shimPeerConnection=N,r.shimSenderReceiverGetStats=v;var o=l(n("../utils.js")),c=n("./getusermedia"),a=n("./getdisplaymedia");function s(_){if(typeof WeakMap!="function")return null;var b=new WeakMap,R=new WeakMap;return(s=function(P){return P?R:b})(_)}function l(_,b){if(!b&&_&&_.__esModule)return _;if(_===null||x(_)!=="object"&&typeof _!="function")return{default:_};var R=s(b);if(R&&R.has(_))return R.get(_);var P={},U=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var k in _)if(k!=="default"&&Object.prototype.hasOwnProperty.call(_,k)){var h=U?Object.getOwnPropertyDescriptor(_,k):null;h&&(h.get||h.set)?Object.defineProperty(P,k,h):P[k]=_[k]}return P.default=_,R&&R.set(_,P),P}function u(_,b,R){return(b=f(b))in _?Object.defineProperty(_,b,{value:R,enumerable:!0,configurable:!0,writable:!0}):_[b]=R,_}function f(_){var b=S(_,"string");return x(b)==="symbol"?b:String(b)}function S(_,b){if(x(_)!=="object"||_===null)return _;var R=_[Symbol.toPrimitive];if(R!==void 0){var P=R.call(_,b||"default");if(x(P)!=="object")return P;throw new TypeError("@@toPrimitive must return a primitive value.")}return(b==="string"?String:Number)(_)}function x(_){return x=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(b){return typeof b}:function(b){return b&&typeof Symbol=="function"&&b.constructor===Symbol&&b!==Symbol.prototype?"symbol":typeof b},x(_)}function E(_){_.MediaStream=_.MediaStream||_.webkitMediaStream}function I(_){if(x(_)==="object"&&_.RTCPeerConnection&&!("ontrack"in _.RTCPeerConnection.prototype)){Object.defineProperty(_.RTCPeerConnection.prototype,"ontrack",{get:function(){return this._ontrack},set:function(R){this._ontrack&&this.removeEventListener("track",this._ontrack),this.addEventListener("track",this._ontrack=R)},enumerable:!0,configurable:!0});var b=_.RTCPeerConnection.prototype.setRemoteDescription;_.RTCPeerConnection.prototype.setRemoteDescription=function(){var R=this;return this._ontrackpoly||(this._ontrackpoly=function(P){P.stream.addEventListener("addtrack",function(U){var k;k=_.RTCPeerConnection.prototype.getReceivers?R.getReceivers().find(function(y){return y.track&&y.track.id===U.track.id}):{track:U.track};var h=new Event("track");h.track=U.track,h.receiver=k,h.transceiver={receiver:k},h.streams=[P.stream],R.dispatchEvent(h)}),P.stream.getTracks().forEach(function(U){var k;k=_.RTCPeerConnection.prototype.getReceivers?R.getReceivers().find(function(y){return y.track&&y.track.id===U.id}):{track:U};var h=new Event("track");h.track=U,h.receiver=k,h.transceiver={receiver:k},h.streams=[P.stream],R.dispatchEvent(h)})},this.addEventListener("addstream",this._ontrackpoly)),b.apply(this,arguments)}}else o.wrapPeerConnectionEvent(_,"track",function(R){return R.transceiver||Object.defineProperty(R,"transceiver",{value:{receiver:R.receiver}}),R})}function m(_){if(x(_)==="object"&&_.RTCPeerConnection&&!("getSenders"in _.RTCPeerConnection.prototype)&&"createDTMFSender"in _.RTCPeerConnection.prototype){var b=function(y,A){return{track:A,get dtmf(){return this._dtmf===void 0&&(A.kind==="audio"?this._dtmf=y.createDTMFSender(A):this._dtmf=null),this._dtmf},_pc:y}};if(!_.RTCPeerConnection.prototype.getSenders){_.RTCPeerConnection.prototype.getSenders=function(){return this._senders=this._senders||[],this._senders.slice()};var R=_.RTCPeerConnection.prototype.addTrack;_.RTCPeerConnection.prototype.addTrack=function(y,A){var D=R.apply(this,arguments);return D||(D=b(this,y),this._senders.push(D)),D};var P=_.RTCPeerConnection.prototype.removeTrack;_.RTCPeerConnection.prototype.removeTrack=function(y){P.apply(this,arguments);var A=this._senders.indexOf(y);A!==-1&&this._senders.splice(A,1)}}var U=_.RTCPeerConnection.prototype.addStream;_.RTCPeerConnection.prototype.addStream=function(y){var A=this;this._senders=this._senders||[],U.apply(this,[y]),y.getTracks().forEach(function(D){A._senders.push(b(A,D))})};var k=_.RTCPeerConnection.prototype.removeStream;_.RTCPeerConnection.prototype.removeStream=function(y){var A=this;this._senders=this._senders||[],k.apply(this,[y]),y.getTracks().forEach(function(D){var j=A._senders.find(function(K){return K.track===D});j&&A._senders.splice(A._senders.indexOf(j),1)})}}else if(x(_)==="object"&&_.RTCPeerConnection&&"getSenders"in _.RTCPeerConnection.prototype&&"createDTMFSender"in _.RTCPeerConnection.prototype&&_.RTCRtpSender&&!("dtmf"in _.RTCRtpSender.prototype)){var h=_.RTCPeerConnection.prototype.getSenders;_.RTCPeerConnection.prototype.getSenders=function(){var y=this,A=h.apply(this,[]);return A.forEach(function(D){return D._pc=y}),A},Object.defineProperty(_.RTCRtpSender.prototype,"dtmf",{get:function(){return this._dtmf===void 0&&(this.track.kind==="audio"?this._dtmf=this._pc.createDTMFSender(this.track):this._dtmf=null),this._dtmf}})}}function T(_){if(_.RTCPeerConnection){var b=_.RTCPeerConnection.prototype.getStats;_.RTCPeerConnection.prototype.getStats=function(){var R=this,P=Array.prototype.slice.call(arguments),U=P[0],k=P[1],h=P[2];if(arguments.length>0&&typeof U=="function")return b.apply(this,arguments);if(b.length===0&&(arguments.length===0||typeof U!="function"))return b.apply(this,[]);var y=function(j){var K={};return j.result().forEach(function(J){var se={id:J.id,timestamp:J.timestamp,type:{localcandidate:"local-candidate",remotecandidate:"remote-candidate"}[J.type]||J.type};J.names().forEach(function(ie){se[ie]=J.stat(ie)}),K[se.id]=se}),K},A=function(j){return new Map(Object.keys(j).map(function(K){return[K,j[K]]}))};if(arguments.length>=2){var D=function(j){k(A(y(j)))};return b.apply(this,[D,U])}return new Promise(function(j,K){b.apply(R,[function(J){j(A(y(J)))},K])}).then(k,h)}}}function v(_){if(x(_)==="object"&&_.RTCPeerConnection&&_.RTCRtpSender&&_.RTCRtpReceiver){if(!("getStats"in _.RTCRtpSender.prototype)){var b=_.RTCPeerConnection.prototype.getSenders;b&&(_.RTCPeerConnection.prototype.getSenders=function(){var k=this,h=b.apply(this,[]);return h.forEach(function(y){return y._pc=k}),h});var R=_.RTCPeerConnection.prototype.addTrack;R&&(_.RTCPeerConnection.prototype.addTrack=function(){var k=R.apply(this,arguments);return k._pc=this,k}),_.RTCRtpSender.prototype.getStats=function(){var k=this;return this._pc.getStats().then(function(h){return o.filterStats(h,k.track,!0)})}}if(!("getStats"in _.RTCRtpReceiver.prototype)){var P=_.RTCPeerConnection.prototype.getReceivers;P&&(_.RTCPeerConnection.prototype.getReceivers=function(){var k=this,h=P.apply(this,[]);return h.forEach(function(y){return y._pc=k}),h}),o.wrapPeerConnectionEvent(_,"track",function(k){return k.receiver._pc=k.srcElement,k}),_.RTCRtpReceiver.prototype.getStats=function(){var k=this;return this._pc.getStats().then(function(h){return o.filterStats(h,k.track,!1)})}}if("getStats"in _.RTCRtpSender.prototype&&"getStats"in _.RTCRtpReceiver.prototype){var U=_.RTCPeerConnection.prototype.getStats;_.RTCPeerConnection.prototype.getStats=function(){if(arguments.length>0&&arguments[0]instanceof _.MediaStreamTrack){var k,h,y,A=arguments[0];return this.getSenders().forEach(function(D){D.track===A&&(k?y=!0:k=D)}),this.getReceivers().forEach(function(D){return D.track===A&&(h?y=!0:h=D),D.track===A}),y||k&&h?Promise.reject(new DOMException("There are more than one sender or receiver for the track.","InvalidAccessError")):k?k.getStats():h?h.getStats():Promise.reject(new DOMException("There is no sender or receiver for the track.","InvalidAccessError"))}return U.apply(this,arguments)}}}}function w(_){_.RTCPeerConnection.prototype.getLocalStreams=function(){var k=this;return this._shimmedLocalStreams=this._shimmedLocalStreams||{},Object.keys(this._shimmedLocalStreams).map(function(h){return k._shimmedLocalStreams[h][0]})};var b=_.RTCPeerConnection.prototype.addTrack;_.RTCPeerConnection.prototype.addTrack=function(k,h){if(!h)return b.apply(this,arguments);this._shimmedLocalStreams=this._shimmedLocalStreams||{};var y=b.apply(this,arguments);return this._shimmedLocalStreams[h.id]?this._shimmedLocalStreams[h.id].indexOf(y)===-1&&this._shimmedLocalStreams[h.id].push(y):this._shimmedLocalStreams[h.id]=[h,y],y};var R=_.RTCPeerConnection.prototype.addStream;_.RTCPeerConnection.prototype.addStream=function(k){var h=this;this._shimmedLocalStreams=this._shimmedLocalStreams||{},k.getTracks().forEach(function(D){if(h.getSenders().find(function(j){return j.track===D}))throw new DOMException("Track already exists.","InvalidAccessError")});var y=this.getSenders();R.apply(this,arguments);var A=this.getSenders().filter(function(D){return y.indexOf(D)===-1});this._shimmedLocalStreams[k.id]=[k].concat(A)};var P=_.RTCPeerConnection.prototype.removeStream;_.RTCPeerConnection.prototype.removeStream=function(k){return this._shimmedLocalStreams=this._shimmedLocalStreams||{},delete this._shimmedLocalStreams[k.id],P.apply(this,arguments)};var U=_.RTCPeerConnection.prototype.removeTrack;_.RTCPeerConnection.prototype.removeTrack=function(k){var h=this;return this._shimmedLocalStreams=this._shimmedLocalStreams||{},k&&Object.keys(this._shimmedLocalStreams).forEach(function(y){var A=h._shimmedLocalStreams[y].indexOf(k);A!==-1&&h._shimmedLocalStreams[y].splice(A,1),h._shimmedLocalStreams[y].length===1&&delete h._shimmedLocalStreams[y]}),U.apply(this,arguments)}}function L(_,b){if(_.RTCPeerConnection){if(_.RTCPeerConnection.prototype.addTrack&&b.version>=65)return w(_);var R=_.RTCPeerConnection.prototype.getLocalStreams;_.RTCPeerConnection.prototype.getLocalStreams=function(){var D=this,j=R.apply(this);return this._reverseStreams=this._reverseStreams||{},j.map(function(K){return D._reverseStreams[K.id]})};var P=_.RTCPeerConnection.prototype.addStream;_.RTCPeerConnection.prototype.addStream=function(D){var j=this;if(this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{},D.getTracks().forEach(function(J){if(j.getSenders().find(function(se){return se.track===J}))throw new DOMException("Track already exists.","InvalidAccessError")}),!this._reverseStreams[D.id]){var K=new _.MediaStream(D.getTracks());this._streams[D.id]=K,this._reverseStreams[K.id]=D,D=K}P.apply(this,[D])};var U=_.RTCPeerConnection.prototype.removeStream;_.RTCPeerConnection.prototype.removeStream=function(D){this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{},U.apply(this,[this._streams[D.id]||D]),delete this._reverseStreams[this._streams[D.id]?this._streams[D.id].id:D.id],delete this._streams[D.id]},_.RTCPeerConnection.prototype.addTrack=function(D,j){var K=this;if(this.signalingState==="closed")throw new DOMException("The RTCPeerConnection's signalingState is 'closed'.","InvalidStateError");var J=[].slice.call(arguments,1);if(J.length!==1||!J[0].getTracks().find(function(Je){return Je===D}))throw new DOMException("The adapter.js addTrack polyfill only supports a single stream which is associated with the specified track.","NotSupportedError");if(this.getSenders().find(function(Je){return Je.track===D}))throw new DOMException("Track already exists.","InvalidAccessError");this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{};var se=this._streams[j.id];if(se)se.addTrack(D),Promise.resolve().then(function(){K.dispatchEvent(new Event("negotiationneeded"))});else{var ie=new _.MediaStream([D]);this._streams[j.id]=ie,this._reverseStreams[ie.id]=j,this.addStream(ie)}return this.getSenders().find(function(Je){return Je.track===D})},["createOffer","createAnswer"].forEach(function(D){var j=_.RTCPeerConnection.prototype[D],K=u({},D,function(){var J=this,se=arguments;return arguments.length&&typeof arguments[0]=="function"?j.apply(this,[function(ie){var Je=y(J,ie);se[0].apply(null,[Je])},function(ie){se[1]&&se[1].apply(null,ie)},arguments[2]]):j.apply(this,arguments).then(function(ie){return y(J,ie)})});_.RTCPeerConnection.prototype[D]=K[D]});var k=_.RTCPeerConnection.prototype.setLocalDescription;_.RTCPeerConnection.prototype.setLocalDescription=function(){return arguments.length&&arguments[0].type?(arguments[0]=A(this,arguments[0]),k.apply(this,arguments)):k.apply(this,arguments)};var h=Object.getOwnPropertyDescriptor(_.RTCPeerConnection.prototype,"localDescription");Object.defineProperty(_.RTCPeerConnection.prototype,"localDescription",{get:function(){var D=h.get.apply(this);return D.type===""?D:y(this,D)}}),_.RTCPeerConnection.prototype.removeTrack=function(D){var j,K=this;if(this.signalingState==="closed")throw new DOMException("The RTCPeerConnection's signalingState is 'closed'.","InvalidStateError");if(!D._pc)throw new DOMException("Argument 1 of RTCPeerConnection.removeTrack does not implement interface RTCRtpSender.","TypeError");if(D._pc!==this)throw new DOMException("Sender was not created by this connection.","InvalidAccessError");this._streams=this._streams||{},Object.keys(this._streams).forEach(function(J){K._streams[J].getTracks().find(function(se){return D.track===se})&&(j=K._streams[J])}),j&&(j.getTracks().length===1?this.removeStream(this._reverseStreams[j.id]):j.removeTrack(D.track),this.dispatchEvent(new Event("negotiationneeded")))}}function y(D,j){var K=j.sdp;return Object.keys(D._reverseStreams||[]).forEach(function(J){var se=D._reverseStreams[J],ie=D._streams[se.id];K=K.replace(new RegExp(ie.id,"g"),se.id)}),new RTCSessionDescription({type:j.type,sdp:K})}function A(D,j){var K=j.sdp;return Object.keys(D._reverseStreams||[]).forEach(function(J){var se=D._reverseStreams[J],ie=D._streams[se.id];K=K.replace(new RegExp(se.id,"g"),ie.id)}),new RTCSessionDescription({type:j.type,sdp:K})}}function N(_,b){!_.RTCPeerConnection&&_.webkitRTCPeerConnection&&(_.RTCPeerConnection=_.webkitRTCPeerConnection),_.RTCPeerConnection&&b.version<53&&["setLocalDescription","setRemoteDescription","addIceCandidate"].forEach(function(R){var P=_.RTCPeerConnection.prototype[R],U=u({},R,function(){return arguments[0]=new(R==="addIceCandidate"?_.RTCIceCandidate:_.RTCSessionDescription)(arguments[0]),P.apply(this,arguments)});_.RTCPeerConnection.prototype[R]=U[R]})}function V(_,b){o.wrapPeerConnectionEvent(_,"negotiationneeded",function(R){var P=R.target;if(!(b.version<72||P.getConfiguration&&P.getConfiguration().sdpSemantics==="plan-b")||P.signalingState==="stable")return R})}},{"../utils.js":11,"./getdisplaymedia":4,"./getusermedia":5}],4:[function(n,i,r){function o(c,a){c.navigator.mediaDevices&&"getDisplayMedia"in c.navigator.mediaDevices||c.navigator.mediaDevices&&(typeof a=="function"?c.navigator.mediaDevices.getDisplayMedia=function(s){return a(s).then(function(l){var u=s.video&&s.video.width,f=s.video&&s.video.height,S=s.video&&s.video.frameRate;return s.video={mandatory:{chromeMediaSource:"desktop",chromeMediaSourceId:l,maxFrameRate:S||3}},u&&(s.video.mandatory.maxWidth=u),f&&(s.video.mandatory.maxHeight=f),c.navigator.mediaDevices.getUserMedia(s)})}:console.error("shimGetDisplayMedia: getSourceId argument is not a function"))}Object.defineProperty(r,"__esModule",{value:!0}),r.shimGetDisplayMedia=o},{}],5:[function(n,i,r){function o(u){if(typeof WeakMap!="function")return null;var f=new WeakMap,S=new WeakMap;return(o=function(x){return x?S:f})(u)}function c(u,f){if(!f&&u&&u.__esModule)return u;if(u===null||a(u)!=="object"&&typeof u!="function")return{default:u};var S=o(f);if(S&&S.has(u))return S.get(u);var x={},E=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var I in u)if(I!=="default"&&Object.prototype.hasOwnProperty.call(u,I)){var m=E?Object.getOwnPropertyDescriptor(u,I):null;m&&(m.get||m.set)?Object.defineProperty(x,I,m):x[I]=u[I]}return x.default=u,S&&S.set(u,x),x}function a(u){return a=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(f){return typeof f}:function(f){return f&&typeof Symbol=="function"&&f.constructor===Symbol&&f!==Symbol.prototype?"symbol":typeof f},a(u)}Object.defineProperty(r,"__esModule",{value:!0}),r.shimGetUserMedia=l;var s=c(n("../utils.js")).log;function l(u,f){var S=u&&u.navigator;if(S.mediaDevices){var x=function(v){if(a(v)!=="object"||v.mandatory||v.optional)return v;var w={};return Object.keys(v).forEach(function(L){if(L!=="require"&&L!=="advanced"&&L!=="mediaSource"){var N=a(v[L])==="object"?v[L]:{ideal:v[L]};N.exact!==void 0&&typeof N.exact=="number"&&(N.min=N.max=N.exact);var V=function(b,R){return b?b+R.charAt(0).toUpperCase()+R.slice(1):R==="deviceId"?"sourceId":R};if(N.ideal!==void 0){w.optional=w.optional||[];var _={};typeof N.ideal=="number"?(_[V("min",L)]=N.ideal,w.optional.push(_),(_={})[V("max",L)]=N.ideal,w.optional.push(_)):(_[V("",L)]=N.ideal,w.optional.push(_))}N.exact!==void 0&&typeof N.exact!="number"?(w.mandatory=w.mandatory||{},w.mandatory[V("",L)]=N.exact):["min","max"].forEach(function(b){N[b]!==void 0&&(w.mandatory=w.mandatory||{},w.mandatory[V(b,L)]=N[b])})}}),v.advanced&&(w.optional=(w.optional||[]).concat(v.advanced)),w},E=function(v,w){if(f.version>=61)return w(v);if((v=JSON.parse(JSON.stringify(v)))&&a(v.audio)==="object"){var L=function(b,R,P){R in b&&!(P in b)&&(b[P]=b[R],delete b[R])};L((v=JSON.parse(JSON.stringify(v))).audio,"autoGainControl","googAutoGainControl"),L(v.audio,"noiseSuppression","googNoiseSuppression"),v.audio=x(v.audio)}if(v&&a(v.video)==="object"){var N=v.video.facingMode;N=N&&(a(N)==="object"?N:{ideal:N});var V,_=f.version<66;if(N&&(N.exact==="user"||N.exact==="environment"||N.ideal==="user"||N.ideal==="environment")&&(!S.mediaDevices.getSupportedConstraints||!S.mediaDevices.getSupportedConstraints().facingMode||_)&&(delete v.video.facingMode,N.exact==="environment"||N.ideal==="environment"?V=["back","rear"]:N.exact!=="user"&&N.ideal!=="user"||(V=["front"]),V))return S.mediaDevices.enumerateDevices().then(function(b){var R=(b=b.filter(function(P){return P.kind==="videoinput"})).find(function(P){return V.some(function(U){return P.label.toLowerCase().includes(U)})});return!R&&b.length&&V.includes("back")&&(R=b[b.length-1]),R&&(v.video.deviceId=N.exact?{exact:R.deviceId}:{ideal:R.deviceId}),v.video=x(v.video),s("chrome: "+JSON.stringify(v)),w(v)});v.video=x(v.video)}return s("chrome: "+JSON.stringify(v)),w(v)},I=function(v){return f.version>=64?v:{name:{PermissionDeniedError:"NotAllowedError",PermissionDismissedError:"NotAllowedError",InvalidStateError:"NotAllowedError",DevicesNotFoundError:"NotFoundError",ConstraintNotSatisfiedError:"OverconstrainedError",TrackStartError:"NotReadableError",MediaDeviceFailedDueToShutdown:"NotAllowedError",MediaDeviceKillSwitchOn:"NotAllowedError",TabCaptureError:"AbortError",ScreenCaptureError:"AbortError",DeviceCaptureError:"AbortError"}[v.name]||v.name,message:v.message,constraint:v.constraint||v.constraintName,toString:function(){return this.name+(this.message&&": ")+this.message}}},m=function(v,w,L){E(v,function(N){S.webkitGetUserMedia(N,w,function(V){L&&L(I(V))})})};if(S.getUserMedia=m.bind(S),S.mediaDevices.getUserMedia){var T=S.mediaDevices.getUserMedia.bind(S.mediaDevices);S.mediaDevices.getUserMedia=function(v){return E(v,function(w){return T(w).then(function(L){if(w.audio&&!L.getAudioTracks().length||w.video&&!L.getVideoTracks().length)throw L.getTracks().forEach(function(N){N.stop()}),new DOMException("","NotFoundError");return L},function(L){return Promise.reject(I(L))})})}}}}},{"../utils.js":11}],6:[function(n,i,r){Object.defineProperty(r,"__esModule",{value:!0}),r.removeExtmapAllowMixed=m,r.shimAddIceCandidateNullOrEmpty=T,r.shimConnectionState=I,r.shimMaxMessageSize=x,r.shimParameterlessSetLocalDescription=v,r.shimRTCIceCandidate=f,r.shimRTCIceCandidateRelayProtocol=S,r.shimSendThrowTypeError=E;var o=l(n("sdp")),c=s(n("./utils"));function a(w){if(typeof WeakMap!="function")return null;var L=new WeakMap,N=new WeakMap;return(a=function(V){return V?N:L})(w)}function s(w,L){if(!L&&w&&w.__esModule)return w;if(w===null||u(w)!=="object"&&typeof w!="function")return{default:w};var N=a(L);if(N&&N.has(w))return N.get(w);var V={},_=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var b in w)if(b!=="default"&&Object.prototype.hasOwnProperty.call(w,b)){var R=_?Object.getOwnPropertyDescriptor(w,b):null;R&&(R.get||R.set)?Object.defineProperty(V,b,R):V[b]=w[b]}return V.default=w,N&&N.set(w,V),V}function l(w){return w&&w.__esModule?w:{default:w}}function u(w){return u=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(L){return typeof L}:function(L){return L&&typeof Symbol=="function"&&L.constructor===Symbol&&L!==Symbol.prototype?"symbol":typeof L},u(w)}function f(w){if(!(!w.RTCIceCandidate||w.RTCIceCandidate&&"foundation"in w.RTCIceCandidate.prototype)){var L=w.RTCIceCandidate;w.RTCIceCandidate=function(N){if(u(N)==="object"&&N.candidate&&N.candidate.indexOf("a=")===0&&((N=JSON.parse(JSON.stringify(N))).candidate=N.candidate.substring(2)),N.candidate&&N.candidate.length){var V=new L(N),_=o.default.parseCandidate(N.candidate);for(var b in _)b in V||Object.defineProperty(V,b,{value:_[b]});return V.toJSON=function(){return{candidate:V.candidate,sdpMid:V.sdpMid,sdpMLineIndex:V.sdpMLineIndex,usernameFragment:V.usernameFragment}},V}return new L(N)},w.RTCIceCandidate.prototype=L.prototype,c.wrapPeerConnectionEvent(w,"icecandidate",function(N){return N.candidate&&Object.defineProperty(N,"candidate",{value:new w.RTCIceCandidate(N.candidate),writable:"false"}),N})}}function S(w){!w.RTCIceCandidate||w.RTCIceCandidate&&"relayProtocol"in w.RTCIceCandidate.prototype||c.wrapPeerConnectionEvent(w,"icecandidate",function(L){if(L.candidate){var N=o.default.parseCandidate(L.candidate.candidate);N.type==="relay"&&(L.candidate.relayProtocol={0:"tls",1:"tcp",2:"udp"}[N.priority>>24])}return L})}function x(w,L){if(w.RTCPeerConnection){"sctp"in w.RTCPeerConnection.prototype||Object.defineProperty(w.RTCPeerConnection.prototype,"sctp",{get:function(){return this._sctp===void 0?null:this._sctp}});var N=function(P){if(!P||!P.sdp)return!1;var U=o.default.splitSections(P.sdp);return U.shift(),U.some(function(k){var h=o.default.parseMLine(k);return h&&h.kind==="application"&&h.protocol.indexOf("SCTP")!==-1})},V=function(P){var U=P.sdp.match(/mozilla...THIS_IS_SDPARTA-(\d+)/);if(U===null||U.length<2)return-1;var k=parseInt(U[1],10);return k!=k?-1:k},_=function(P){var U=65536;return L.browser==="firefox"&&(U=L.version<57?P===-1?16384:2147483637:L.version<60?L.version===57?65535:65536:2147483637),U},b=function(P,U){var k=65536;L.browser==="firefox"&&L.version===57&&(k=65535);var h=o.default.matchPrefix(P.sdp,"a=max-message-size:");return h.length>0?k=parseInt(h[0].substring(19),10):L.browser==="firefox"&&U!==-1&&(k=2147483637),k},R=w.RTCPeerConnection.prototype.setRemoteDescription;w.RTCPeerConnection.prototype.setRemoteDescription=function(){if(this._sctp=null,L.browser==="chrome"&&L.version>=76&&this.getConfiguration().sdpSemantics==="plan-b"&&Object.defineProperty(this,"sctp",{get:function(){return this._sctp===void 0?null:this._sctp},enumerable:!0,configurable:!0}),N(arguments[0])){var P,U=V(arguments[0]),k=_(U),h=b(arguments[0],U);P=k===0&&h===0?Number.POSITIVE_INFINITY:k===0||h===0?Math.max(k,h):Math.min(k,h);var y={};Object.defineProperty(y,"maxMessageSize",{get:function(){return P}}),this._sctp=y}return R.apply(this,arguments)}}}function E(w){if(w.RTCPeerConnection&&"createDataChannel"in w.RTCPeerConnection.prototype){var L=w.RTCPeerConnection.prototype.createDataChannel;w.RTCPeerConnection.prototype.createDataChannel=function(){var V=L.apply(this,arguments);return N(V,this),V},c.wrapPeerConnectionEvent(w,"datachannel",function(V){return N(V.channel,V.target),V})}function N(V,_){var b=V.send;V.send=function(){var R=arguments[0],P=R.length||R.size||R.byteLength;if(V.readyState==="open"&&_.sctp&&P>_.sctp.maxMessageSize)throw new TypeError("Message too large (can send a maximum of "+_.sctp.maxMessageSize+" bytes)");return b.apply(V,arguments)}}}function I(w){if(w.RTCPeerConnection&&!("connectionState"in w.RTCPeerConnection.prototype)){var L=w.RTCPeerConnection.prototype;Object.defineProperty(L,"connectionState",{get:function(){return{completed:"connected",checking:"connecting"}[this.iceConnectionState]||this.iceConnectionState},enumerable:!0,configurable:!0}),Object.defineProperty(L,"onconnectionstatechange",{get:function(){return this._onconnectionstatechange||null},set:function(N){this._onconnectionstatechange&&(this.removeEventListener("connectionstatechange",this._onconnectionstatechange),delete this._onconnectionstatechange),N&&this.addEventListener("connectionstatechange",this._onconnectionstatechange=N)},enumerable:!0,configurable:!0}),["setLocalDescription","setRemoteDescription"].forEach(function(N){var V=L[N];L[N]=function(){return this._connectionstatechangepoly||(this._connectionstatechangepoly=function(_){var b=_.target;if(b._lastConnectionState!==b.connectionState){b._lastConnectionState=b.connectionState;var R=new Event("connectionstatechange",_);b.dispatchEvent(R)}return _},this.addEventListener("iceconnectionstatechange",this._connectionstatechangepoly)),V.apply(this,arguments)}})}}function m(w,L){if(w.RTCPeerConnection&&!(L.browser==="chrome"&&L.version>=71||L.browser==="safari"&&L.version>=605)){var N=w.RTCPeerConnection.prototype.setRemoteDescription;w.RTCPeerConnection.prototype.setRemoteDescription=function(V){if(V&&V.sdp&&V.sdp.indexOf(`
|
|
5
|
+
a=extmap-allow-mixed`)!==-1){var _=V.sdp.split(`
|
|
6
6
|
`).filter(function(b){return b.trim()!=="a=extmap-allow-mixed"}).join(`
|
|
7
|
-
`);p.RTCSessionDescription&&L instanceof p.RTCSessionDescription?arguments[0]=new p.RTCSessionDescription({type:L.type,sdp:f}):L.sdp=f}return y.apply(this,arguments)}}}function A(p,v){if(p.RTCPeerConnection&&p.RTCPeerConnection.prototype){var y=p.RTCPeerConnection.prototype.addIceCandidate;y&&y.length!==0&&(p.RTCPeerConnection.prototype.addIceCandidate=function(){return arguments[0]?(v.browser==="chrome"&&v.version<78||v.browser==="firefox"&&v.version<68||v.browser==="safari")&&arguments[0]&&arguments[0].candidate===""?Promise.resolve():y.apply(this,arguments):(arguments[1]&&arguments[1].apply(null),Promise.resolve())})}}},{"./utils":15,sdp:17}],7:[function(n,a,i){Object.defineProperty(i,"__esModule",{value:!0}),i.shimGetDisplayMedia=i.shimGetUserMedia=void 0;var r=n("./getusermedia");Object.defineProperty(i,"shimGetUserMedia",{enumerable:!0,get:function(){return r.shimGetUserMedia}});var o=n("./getdisplaymedia");Object.defineProperty(i,"shimGetDisplayMedia",{enumerable:!0,get:function(){return o.shimGetDisplayMedia}}),i.shimPeerConnection=I,i.shimReplaceTrack=k;var s=g(n("../utils")),c=n("./filtericeservers"),u=d(n("rtcpeerconnection-shim"));function d(w){return w&&w.__esModule?w:{default:w}}function g(w){if(w&&w.__esModule)return w;var A={};if(w!=null)for(var p in w)Object.prototype.hasOwnProperty.call(w,p)&&(A[p]=w[p]);return A.default=w,A}function I(w,A){if(w.RTCIceGatherer&&(w.RTCIceCandidate||(w.RTCIceCandidate=function(y){return y}),w.RTCSessionDescription||(w.RTCSessionDescription=function(y){return y}),A.version<15025)){var p=Object.getOwnPropertyDescriptor(w.MediaStreamTrack.prototype,"enabled");Object.defineProperty(w.MediaStreamTrack.prototype,"enabled",{set:function(y){p.set.call(this,y);var L=new Event("enabled");L.enabled=y,this.dispatchEvent(L)}})}w.RTCRtpSender&&!("dtmf"in w.RTCRtpSender.prototype)&&Object.defineProperty(w.RTCRtpSender.prototype,"dtmf",{get:function(){return this._dtmf===void 0&&(this.track.kind==="audio"?this._dtmf=new w.RTCDtmfSender(this):this.track.kind==="video"&&(this._dtmf=null)),this._dtmf}}),w.RTCDtmfSender&&!w.RTCDTMFSender&&(w.RTCDTMFSender=w.RTCDtmfSender);var v=(0,u.default)(w,A.version);w.RTCPeerConnection=function(y){return y&&y.iceServers&&(y.iceServers=(0,c.filterIceServers)(y.iceServers,A.version),s.log("ICE servers after filtering:",y.iceServers)),new v(y)},w.RTCPeerConnection.prototype=v.prototype}function k(w){w.RTCRtpSender&&!("replaceTrack"in w.RTCRtpSender.prototype)&&(w.RTCRtpSender.prototype.replaceTrack=w.RTCRtpSender.prototype.setTrack)}},{"../utils":15,"./filtericeservers":8,"./getdisplaymedia":9,"./getusermedia":10,"rtcpeerconnection-shim":16}],8:[function(n,a,i){Object.defineProperty(i,"__esModule",{value:!0}),i.filterIceServers=s;var r=o(n("../utils"));function o(c){if(c&&c.__esModule)return c;var u={};if(c!=null)for(var d in c)Object.prototype.hasOwnProperty.call(c,d)&&(u[d]=c[d]);return u.default=c,u}function s(c,u){var d=!1;return(c=JSON.parse(JSON.stringify(c))).filter(function(g){if(g&&(g.urls||g.url)){var I=g.urls||g.url;g.url&&!g.urls&&r.deprecated("RTCIceServer.url","RTCIceServer.urls");var k=typeof I=="string";return k&&(I=[I]),I=I.filter(function(w){if(w.indexOf("stun:")===0)return!1;var A=w.startsWith("turn")&&!w.startsWith("turn:[")&&w.includes("transport=udp");return A&&!d?(d=!0,!0):A&&!d}),delete g.url,g.urls=k?I[0]:I,!!I.length}})}},{"../utils":15}],9:[function(n,a,i){function r(o){"getDisplayMedia"in o.navigator&&o.navigator.mediaDevices&&(o.navigator.mediaDevices&&"getDisplayMedia"in o.navigator.mediaDevices||(o.navigator.mediaDevices.getDisplayMedia=o.navigator.getDisplayMedia.bind(o.navigator)))}Object.defineProperty(i,"__esModule",{value:!0}),i.shimGetDisplayMedia=r},{}],10:[function(n,a,i){function r(o){var s=o&&o.navigator,c=function(d){return{name:{PermissionDeniedError:"NotAllowedError"}[d.name]||d.name,message:d.message,constraint:d.constraint,toString:function(){return this.name}}},u=s.mediaDevices.getUserMedia.bind(s.mediaDevices);s.mediaDevices.getUserMedia=function(d){return u(d).catch(function(g){return Promise.reject(c(g))})}}Object.defineProperty(i,"__esModule",{value:!0}),i.shimGetUserMedia=r},{}],11:[function(n,a,i){Object.defineProperty(i,"__esModule",{value:!0}),i.shimGetDisplayMedia=i.shimGetUserMedia=void 0;var r=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(b){return typeof b}:function(b){return b&&typeof Symbol=="function"&&b.constructor===Symbol&&b!==Symbol.prototype?"symbol":typeof b},o=n("./getusermedia");Object.defineProperty(i,"shimGetUserMedia",{enumerable:!0,get:function(){return o.shimGetUserMedia}});var s=n("./getdisplaymedia");Object.defineProperty(i,"shimGetDisplayMedia",{enumerable:!0,get:function(){return s.shimGetDisplayMedia}}),i.shimOnTrack=g,i.shimPeerConnection=I,i.shimSenderGetStats=k,i.shimReceiverGetStats=w,i.shimRemoveStream=A,i.shimRTCDataChannel=p,i.shimAddTransceiver=v,i.shimGetParameters=y,i.shimCreateOffer=L,i.shimCreateAnswer=f;var c=u(n("../utils"));function u(b){if(b&&b.__esModule)return b;var P={};if(b!=null)for(var S in b)Object.prototype.hasOwnProperty.call(b,S)&&(P[S]=b[S]);return P.default=b,P}function d(b,P,S){return P in b?Object.defineProperty(b,P,{value:S,enumerable:!0,configurable:!0,writable:!0}):b[P]=S,b}function g(b){(b===void 0?"undefined":r(b))==="object"&&b.RTCTrackEvent&&"receiver"in b.RTCTrackEvent.prototype&&!("transceiver"in b.RTCTrackEvent.prototype)&&Object.defineProperty(b.RTCTrackEvent.prototype,"transceiver",{get:function(){return{receiver:this.receiver}}})}function I(b,P){if((b===void 0?"undefined":r(b))==="object"&&(b.RTCPeerConnection||b.mozRTCPeerConnection)){!b.RTCPeerConnection&&b.mozRTCPeerConnection&&(b.RTCPeerConnection=b.mozRTCPeerConnection),P.version<53&&["setLocalDescription","setRemoteDescription","addIceCandidate"].forEach(function(C){var D=b.RTCPeerConnection.prototype[C],B=d({},C,function(){return arguments[0]=new(C==="addIceCandidate"?b.RTCIceCandidate:b.RTCSessionDescription)(arguments[0]),D.apply(this,arguments)});b.RTCPeerConnection.prototype[C]=B[C]});var S={inboundrtp:"inbound-rtp",outboundrtp:"outbound-rtp",candidatepair:"candidate-pair",localcandidate:"local-candidate",remotecandidate:"remote-candidate"},T=b.RTCPeerConnection.prototype.getStats;b.RTCPeerConnection.prototype.getStats=function(){var C=Array.prototype.slice.call(arguments),D=C[0],B=C[1],x=C[2];return T.apply(this,[D||null]).then(function(h){if(P.version<53&&!B)try{h.forEach(function(E){E.type=S[E.type]||E.type})}catch(E){if(E.name!=="TypeError")throw E;h.forEach(function(O,N){h.set(N,Object.assign({},O,{type:S[O.type]||O.type}))})}return h}).then(B,x)}}}function k(b){if((b===void 0?"undefined":r(b))==="object"&&b.RTCPeerConnection&&b.RTCRtpSender&&(!b.RTCRtpSender||!("getStats"in b.RTCRtpSender.prototype))){var P=b.RTCPeerConnection.prototype.getSenders;P&&(b.RTCPeerConnection.prototype.getSenders=function(){var T=this,C=P.apply(this,[]);return C.forEach(function(D){return D._pc=T}),C});var S=b.RTCPeerConnection.prototype.addTrack;S&&(b.RTCPeerConnection.prototype.addTrack=function(){var T=S.apply(this,arguments);return T._pc=this,T}),b.RTCRtpSender.prototype.getStats=function(){return this.track?this._pc.getStats(this.track):Promise.resolve(new Map)}}}function w(b){if((b===void 0?"undefined":r(b))==="object"&&b.RTCPeerConnection&&b.RTCRtpSender&&(!b.RTCRtpSender||!("getStats"in b.RTCRtpReceiver.prototype))){var P=b.RTCPeerConnection.prototype.getReceivers;P&&(b.RTCPeerConnection.prototype.getReceivers=function(){var S=this,T=P.apply(this,[]);return T.forEach(function(C){return C._pc=S}),T}),c.wrapPeerConnectionEvent(b,"track",function(S){return S.receiver._pc=S.srcElement,S}),b.RTCRtpReceiver.prototype.getStats=function(){return this._pc.getStats(this.track)}}}function A(b){b.RTCPeerConnection&&!("removeStream"in b.RTCPeerConnection.prototype)&&(b.RTCPeerConnection.prototype.removeStream=function(P){var S=this;c.deprecated("removeStream","removeTrack"),this.getSenders().forEach(function(T){T.track&&P.getTracks().includes(T.track)&&S.removeTrack(T)})})}function p(b){b.DataChannel&&!b.RTCDataChannel&&(b.RTCDataChannel=b.DataChannel)}function v(b){if((b===void 0?"undefined":r(b))==="object"&&b.RTCPeerConnection){var P=b.RTCPeerConnection.prototype.addTransceiver;P&&(b.RTCPeerConnection.prototype.addTransceiver=function(){this.setParametersPromises=[];var S=arguments[1],T=S&&"sendEncodings"in S;T&&S.sendEncodings.forEach(function(x){if("rid"in x&&!/^[a-z0-9]{0,16}$/i.test(x.rid))throw new TypeError("Invalid RID value provided.");if("scaleResolutionDownBy"in x&&!(parseFloat(x.scaleResolutionDownBy)>=1))throw new RangeError("scale_resolution_down_by must be >= 1.0");if("maxFramerate"in x&&!(parseFloat(x.maxFramerate)>=0))throw new RangeError("max_framerate must be >= 0.0")});var C=P.apply(this,arguments);if(T){var D=C.sender,B=D.getParameters();(!("encodings"in B)||B.encodings.length===1&&Object.keys(B.encodings[0]).length===0)&&(B.encodings=S.sendEncodings,D.sendEncodings=S.sendEncodings,this.setParametersPromises.push(D.setParameters(B).then(function(){delete D.sendEncodings}).catch(function(){delete D.sendEncodings})))}return C})}}function y(b){if((b===void 0?"undefined":r(b))==="object"&&b.RTCRtpSender){var P=b.RTCRtpSender.prototype.getParameters;P&&(b.RTCRtpSender.prototype.getParameters=function(){var S=P.apply(this,arguments);return"encodings"in S||(S.encodings=[].concat(this.sendEncodings||[{}])),S})}}function L(b){if((b===void 0?"undefined":r(b))==="object"&&b.RTCPeerConnection){var P=b.RTCPeerConnection.prototype.createOffer;b.RTCPeerConnection.prototype.createOffer=function(){var S=this,T=arguments;return this.setParametersPromises&&this.setParametersPromises.length?Promise.all(this.setParametersPromises).then(function(){return P.apply(S,T)}).finally(function(){S.setParametersPromises=[]}):P.apply(this,arguments)}}}function f(b){if((b===void 0?"undefined":r(b))==="object"&&b.RTCPeerConnection){var P=b.RTCPeerConnection.prototype.createAnswer;b.RTCPeerConnection.prototype.createAnswer=function(){var S=this,T=arguments;return this.setParametersPromises&&this.setParametersPromises.length?Promise.all(this.setParametersPromises).then(function(){return P.apply(S,T)}).finally(function(){S.setParametersPromises=[]}):P.apply(this,arguments)}}}},{"../utils":15,"./getdisplaymedia":12,"./getusermedia":13}],12:[function(n,a,i){function r(o,s){o.navigator.mediaDevices&&"getDisplayMedia"in o.navigator.mediaDevices||o.navigator.mediaDevices&&(o.navigator.mediaDevices.getDisplayMedia=function(c){if(!c||!c.video){var u=new DOMException("getDisplayMedia without video constraints is undefined");return u.name="NotFoundError",u.code=8,Promise.reject(u)}return c.video===!0?c.video={mediaSource:s}:c.video.mediaSource=s,o.navigator.mediaDevices.getUserMedia(c)})}Object.defineProperty(i,"__esModule",{value:!0}),i.shimGetDisplayMedia=r},{}],13:[function(n,a,i){Object.defineProperty(i,"__esModule",{value:!0});var r=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(u){return typeof u}:function(u){return u&&typeof Symbol=="function"&&u.constructor===Symbol&&u!==Symbol.prototype?"symbol":typeof u};i.shimGetUserMedia=c;var o=s(n("../utils"));function s(u){if(u&&u.__esModule)return u;var d={};if(u!=null)for(var g in u)Object.prototype.hasOwnProperty.call(u,g)&&(d[g]=u[g]);return d.default=u,d}function c(u,d){var g=u&&u.navigator,I=u&&u.MediaStreamTrack;if(g.getUserMedia=function(v,y,L){o.deprecated("navigator.getUserMedia","navigator.mediaDevices.getUserMedia"),g.mediaDevices.getUserMedia(v).then(y,L)},!(d.version>55&&"autoGainControl"in g.mediaDevices.getSupportedConstraints())){var k=function(v,y,L){y in v&&!(L in v)&&(v[L]=v[y],delete v[y])},w=g.mediaDevices.getUserMedia.bind(g.mediaDevices);if(g.mediaDevices.getUserMedia=function(v){return(v===void 0?"undefined":r(v))==="object"&&r(v.audio)==="object"&&(v=JSON.parse(JSON.stringify(v)),k(v.audio,"autoGainControl","mozAutoGainControl"),k(v.audio,"noiseSuppression","mozNoiseSuppression")),w(v)},I&&I.prototype.getSettings){var A=I.prototype.getSettings;I.prototype.getSettings=function(){var v=A.apply(this,arguments);return k(v,"mozAutoGainControl","autoGainControl"),k(v,"mozNoiseSuppression","noiseSuppression"),v}}if(I&&I.prototype.applyConstraints){var p=I.prototype.applyConstraints;I.prototype.applyConstraints=function(v){return this.kind==="audio"&&(v===void 0?"undefined":r(v))==="object"&&(v=JSON.parse(JSON.stringify(v)),k(v,"autoGainControl","mozAutoGainControl"),k(v,"noiseSuppression","mozNoiseSuppression")),p.apply(this,[v])}}}}},{"../utils":15}],14:[function(n,a,i){Object.defineProperty(i,"__esModule",{value:!0});var r=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(v){return typeof v}:function(v){return v&&typeof Symbol=="function"&&v.constructor===Symbol&&v!==Symbol.prototype?"symbol":typeof v};i.shimLocalStreamsAPI=c,i.shimRemoteStreamsAPI=u,i.shimCallbacksAPI=d,i.shimGetUserMedia=g,i.shimConstraints=I,i.shimRTCIceServerUrls=k,i.shimTrackEventTransceiver=w,i.shimCreateOfferLegacy=A,i.shimAudioContext=p;var o=s(n("../utils"));function s(v){if(v&&v.__esModule)return v;var y={};if(v!=null)for(var L in v)Object.prototype.hasOwnProperty.call(v,L)&&(y[L]=v[L]);return y.default=v,y}function c(v){if((v===void 0?"undefined":r(v))==="object"&&v.RTCPeerConnection){if("getLocalStreams"in v.RTCPeerConnection.prototype||(v.RTCPeerConnection.prototype.getLocalStreams=function(){return this._localStreams||(this._localStreams=[]),this._localStreams}),!("addStream"in v.RTCPeerConnection.prototype)){var y=v.RTCPeerConnection.prototype.addTrack;v.RTCPeerConnection.prototype.addStream=function(L){var f=this;this._localStreams||(this._localStreams=[]),this._localStreams.includes(L)||this._localStreams.push(L),L.getAudioTracks().forEach(function(b){return y.call(f,b,L)}),L.getVideoTracks().forEach(function(b){return y.call(f,b,L)})},v.RTCPeerConnection.prototype.addTrack=function(L){for(var f=this,b=arguments.length,P=Array(b>1?b-1:0),S=1;S<b;S++)P[S-1]=arguments[S];return P&&P.forEach(function(T){f._localStreams?f._localStreams.includes(T)||f._localStreams.push(T):f._localStreams=[T]}),y.apply(this,arguments)}}"removeStream"in v.RTCPeerConnection.prototype||(v.RTCPeerConnection.prototype.removeStream=function(L){var f=this;this._localStreams||(this._localStreams=[]);var b=this._localStreams.indexOf(L);if(b!==-1){this._localStreams.splice(b,1);var P=L.getTracks();this.getSenders().forEach(function(S){P.includes(S.track)&&f.removeTrack(S)})}})}}function u(v){if((v===void 0?"undefined":r(v))==="object"&&v.RTCPeerConnection&&("getRemoteStreams"in v.RTCPeerConnection.prototype||(v.RTCPeerConnection.prototype.getRemoteStreams=function(){return this._remoteStreams?this._remoteStreams:[]}),!("onaddstream"in v.RTCPeerConnection.prototype))){Object.defineProperty(v.RTCPeerConnection.prototype,"onaddstream",{get:function(){return this._onaddstream},set:function(L){var f=this;this._onaddstream&&(this.removeEventListener("addstream",this._onaddstream),this.removeEventListener("track",this._onaddstreampoly)),this.addEventListener("addstream",this._onaddstream=L),this.addEventListener("track",this._onaddstreampoly=function(b){b.streams.forEach(function(P){if(f._remoteStreams||(f._remoteStreams=[]),!f._remoteStreams.includes(P)){f._remoteStreams.push(P);var S=new Event("addstream");S.stream=P,f.dispatchEvent(S)}})})}});var y=v.RTCPeerConnection.prototype.setRemoteDescription;v.RTCPeerConnection.prototype.setRemoteDescription=function(){var L=this;return this._onaddstreampoly||this.addEventListener("track",this._onaddstreampoly=function(f){f.streams.forEach(function(b){if(L._remoteStreams||(L._remoteStreams=[]),!(L._remoteStreams.indexOf(b)>=0)){L._remoteStreams.push(b);var P=new Event("addstream");P.stream=b,L.dispatchEvent(P)}})}),y.apply(L,arguments)}}}function d(v){if((v===void 0?"undefined":r(v))==="object"&&v.RTCPeerConnection){var y=v.RTCPeerConnection.prototype,L=y.createOffer,f=y.createAnswer,b=y.setLocalDescription,P=y.setRemoteDescription,S=y.addIceCandidate;y.createOffer=function(C,D){var B=arguments.length>=2?arguments[2]:arguments[0],x=L.apply(this,[B]);return D?(x.then(C,D),Promise.resolve()):x},y.createAnswer=function(C,D){var B=arguments.length>=2?arguments[2]:arguments[0],x=f.apply(this,[B]);return D?(x.then(C,D),Promise.resolve()):x};var T=function(C,D,B){var x=b.apply(this,[C]);return B?(x.then(D,B),Promise.resolve()):x};y.setLocalDescription=T,T=function(C,D,B){var x=P.apply(this,[C]);return B?(x.then(D,B),Promise.resolve()):x},y.setRemoteDescription=T,T=function(C,D,B){var x=S.apply(this,[C]);return B?(x.then(D,B),Promise.resolve()):x},y.addIceCandidate=T}}function g(v){var y=v&&v.navigator;if(y.mediaDevices&&y.mediaDevices.getUserMedia){var L=y.mediaDevices,f=L.getUserMedia.bind(L);y.mediaDevices.getUserMedia=function(b){return f(I(b))}}!y.getUserMedia&&y.mediaDevices&&y.mediaDevices.getUserMedia&&(y.getUserMedia=function(b,P,S){y.mediaDevices.getUserMedia(b).then(P,S)}.bind(y))}function I(v){return v&&v.video!==void 0?Object.assign({},v,{video:o.compactObject(v.video)}):v}function k(v){if(v.RTCPeerConnection){var y=v.RTCPeerConnection;v.RTCPeerConnection=function(L,f){if(L&&L.iceServers){for(var b=[],P=0;P<L.iceServers.length;P++){var S=L.iceServers[P];!S.hasOwnProperty("urls")&&S.hasOwnProperty("url")?(o.deprecated("RTCIceServer.url","RTCIceServer.urls"),(S=JSON.parse(JSON.stringify(S))).urls=S.url,delete S.url,b.push(S)):b.push(L.iceServers[P])}L.iceServers=b}return new y(L,f)},v.RTCPeerConnection.prototype=y.prototype,"generateCertificate"in y&&Object.defineProperty(v.RTCPeerConnection,"generateCertificate",{get:function(){return y.generateCertificate}})}}function w(v){(v===void 0?"undefined":r(v))==="object"&&v.RTCTrackEvent&&"receiver"in v.RTCTrackEvent.prototype&&!("transceiver"in v.RTCTrackEvent.prototype)&&Object.defineProperty(v.RTCTrackEvent.prototype,"transceiver",{get:function(){return{receiver:this.receiver}}})}function A(v){var y=v.RTCPeerConnection.prototype.createOffer;v.RTCPeerConnection.prototype.createOffer=function(L){if(L){L.offerToReceiveAudio!==void 0&&(L.offerToReceiveAudio=!!L.offerToReceiveAudio);var f=this.getTransceivers().find(function(P){return P.receiver.track.kind==="audio"});L.offerToReceiveAudio===!1&&f?f.direction==="sendrecv"?f.setDirection?f.setDirection("sendonly"):f.direction="sendonly":f.direction==="recvonly"&&(f.setDirection?f.setDirection("inactive"):f.direction="inactive"):L.offerToReceiveAudio!==!0||f||this.addTransceiver("audio"),L.offerToReceiveVideo!==void 0&&(L.offerToReceiveVideo=!!L.offerToReceiveVideo);var b=this.getTransceivers().find(function(P){return P.receiver.track.kind==="video"});L.offerToReceiveVideo===!1&&b?b.direction==="sendrecv"?b.setDirection?b.setDirection("sendonly"):b.direction="sendonly":b.direction==="recvonly"&&(b.setDirection?b.setDirection("inactive"):b.direction="inactive"):L.offerToReceiveVideo!==!0||b||this.addTransceiver("video")}return y.apply(this,arguments)}}function p(v){(v===void 0?"undefined":r(v))!=="object"||v.AudioContext||(v.AudioContext=v.webkitAudioContext)}},{"../utils":15}],15:[function(n,a,i){Object.defineProperty(i,"__esModule",{value:!0});var r=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(f){return typeof f}:function(f){return f&&typeof Symbol=="function"&&f.constructor===Symbol&&f!==Symbol.prototype?"symbol":typeof f};function o(f,b,P){return b in f?Object.defineProperty(f,b,{value:P,enumerable:!0,configurable:!0,writable:!0}):f[b]=P,f}i.extractVersion=u,i.wrapPeerConnectionEvent=d,i.disableLog=g,i.disableWarnings=I,i.log=k,i.deprecated=w,i.detectBrowser=A,i.compactObject=v,i.walkStats=y,i.filterStats=L;var s=!0,c=!0;function u(f,b,P){var S=f.match(b);return S&&S.length>=P&&parseInt(S[P],10)}function d(f,b,P){if(f.RTCPeerConnection){var S=f.RTCPeerConnection.prototype,T=S.addEventListener;S.addEventListener=function(D,B){if(D!==b)return T.apply(this,arguments);var x=function(h){var E=P(h);E&&(B.handleEvent?B.handleEvent(E):B(E))};return this._eventMap=this._eventMap||{},this._eventMap[b]||(this._eventMap[b]=new Map),this._eventMap[b].set(B,x),T.apply(this,[D,x])};var C=S.removeEventListener;S.removeEventListener=function(D,B){if(D!==b||!this._eventMap||!this._eventMap[b])return C.apply(this,arguments);if(!this._eventMap[b].has(B))return C.apply(this,arguments);var x=this._eventMap[b].get(B);return this._eventMap[b].delete(B),this._eventMap[b].size===0&&delete this._eventMap[b],Object.keys(this._eventMap).length===0&&delete this._eventMap,C.apply(this,[D,x])},Object.defineProperty(S,"on"+b,{get:function(){return this["_on"+b]},set:function(D){this["_on"+b]&&(this.removeEventListener(b,this["_on"+b]),delete this["_on"+b]),D&&this.addEventListener(b,this["_on"+b]=D)},enumerable:!0,configurable:!0})}}function g(f){return typeof f!="boolean"?new Error("Argument type: "+(f===void 0?"undefined":r(f))+". Please use a boolean."):(s=f,f?"adapter.js logging disabled":"adapter.js logging enabled")}function I(f){return typeof f!="boolean"?new Error("Argument type: "+(f===void 0?"undefined":r(f))+". Please use a boolean."):(c=!f,"adapter.js deprecation warnings "+(f?"disabled":"enabled"))}function k(){if((typeof window=="undefined"?"undefined":r(window))==="object"){if(s)return;typeof console!="undefined"&&typeof console.log=="function"&&console.log.apply(console,arguments)}}function w(f,b){c&&console.warn(f+" is deprecated, please use "+b+" instead.")}function A(f){var b={browser:null,version:null};if(f===void 0||!f.navigator)return b.browser="Not a browser.",b;var P=f.navigator;if(P.mozGetUserMedia)b.browser="firefox",b.version=u(P.userAgent,/Firefox\/(\d+)\./,1);else if(P.webkitGetUserMedia||f.isSecureContext===!1&&f.webkitRTCPeerConnection&&!f.RTCIceGatherer)b.browser="chrome",b.version=u(P.userAgent,/Chrom(e|ium)\/(\d+)\./,2);else if(P.mediaDevices&&P.userAgent.match(/Edge\/(\d+).(\d+)$/))b.browser="edge",b.version=u(P.userAgent,/Edge\/(\d+).(\d+)$/,2);else{if(!f.RTCPeerConnection||!P.userAgent.match(/AppleWebKit\/(\d+)\./))return b.browser="Not a supported browser.",b;b.browser="safari",b.version=u(P.userAgent,/AppleWebKit\/(\d+)\./,1),b.supportsUnifiedPlan=f.RTCRtpTransceiver&&"currentDirection"in f.RTCRtpTransceiver.prototype}return b}function p(f){return Object.prototype.toString.call(f)==="[object Object]"}function v(f){return p(f)?Object.keys(f).reduce(function(b,P){var S=p(f[P]),T=S?v(f[P]):f[P],C=S&&!Object.keys(T).length;return T===void 0||C?b:Object.assign(b,o({},P,T))},{}):f}function y(f,b,P){b&&!P.has(b.id)&&(P.set(b.id,b),Object.keys(b).forEach(function(S){S.endsWith("Id")?y(f,f.get(b[S]),P):S.endsWith("Ids")&&b[S].forEach(function(T){y(f,f.get(T),P)})}))}function L(f,b,P){var S=P?"outbound-rtp":"inbound-rtp",T=new Map;if(b===null)return T;var C=[];return f.forEach(function(D){D.type==="track"&&D.trackIdentifier===b.id&&C.push(D)}),C.forEach(function(D){f.forEach(function(B){B.type===S&&B.trackId===D.id&&y(f,B,T)})}),T}},{}],16:[function(n,a,i){var r=n("sdp");function o(k){return{inboundrtp:"inbound-rtp",outboundrtp:"outbound-rtp",candidatepair:"candidate-pair",localcandidate:"local-candidate",remotecandidate:"remote-candidate"}[k.type]||k.type}function s(k,w,A,p,v){var y=r.writeRtpDescription(k.kind,w);if(y+=r.writeIceParameters(k.iceGatherer.getLocalParameters()),y+=r.writeDtlsParameters(k.dtlsTransport.getLocalParameters(),A==="offer"?"actpass":v||"active"),y+="a=mid:"+k.mid+`\r
|
|
8
|
-
`,k.rtpSender&&k.rtpReceiver?y+=`a=sendrecv\r
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
`)}return
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
`,P._localDescription.sdp=r.getDescription(P._localDescription.sdp)+E.join("");var O=P.transceivers.every(function(N){return N.iceGatherer&&N.iceGatherer.state==="completed"});P.iceGatheringState!=="gathering"&&(P.iceGatheringState="gathering",P._emitGatheringStateChange()),x||P._dispatchEvent("icecandidate",D),O&&(P._dispatchEvent("icecandidate",new Event("icecandidate")),P.iceGatheringState="complete",P._emitGatheringStateChange())}},k.setTimeout(function(){T.forEach(function(C){S.onlocalcandidate(C)})},0)}},y.prototype._createIceAndDtlsTransports=function(){var f=this,b=new k.RTCIceTransport(null);b.onicestatechange=function(){f._updateIceConnectionState(),f._updateConnectionState()};var P=new k.RTCDtlsTransport(b);return P.ondtlsstatechange=function(){f._updateConnectionState()},P.onerror=function(){Object.defineProperty(P,"state",{value:"failed",writable:!0}),f._updateConnectionState()},{iceTransport:b,dtlsTransport:P}},y.prototype._disposeIceAndDtlsTransports=function(f){var b=this.transceivers[f].iceGatherer;b&&(delete b.onlocalcandidate,delete this.transceivers[f].iceGatherer);var P=this.transceivers[f].iceTransport;P&&(delete P.onicestatechange,delete this.transceivers[f].iceTransport);var S=this.transceivers[f].dtlsTransport;S&&(delete S.ondtlsstatechange,delete S.onerror,delete this.transceivers[f].dtlsTransport)},y.prototype._transceive=function(f,b,P){var S=u(f.localCapabilities,f.remoteCapabilities);b&&f.rtpSender&&(S.encodings=f.sendEncodingParameters,S.rtcp={cname:r.localCName,compound:f.rtcpParameters.compound},f.recvEncodingParameters.length&&(S.rtcp.ssrc=f.recvEncodingParameters[0].ssrc),f.rtpSender.send(S)),P&&f.rtpReceiver&&S.codecs.length>0&&(f.kind==="video"&&f.recvEncodingParameters&&w<15019&&f.recvEncodingParameters.forEach(function(T){delete T.rtx}),f.recvEncodingParameters.length?S.encodings=f.recvEncodingParameters:S.encodings=[{}],S.rtcp={compound:f.rtcpParameters.compound},f.rtcpParameters.cname&&(S.rtcp.cname=f.rtcpParameters.cname),f.sendEncodingParameters.length&&(S.rtcp.ssrc=f.sendEncodingParameters[0].ssrc),f.rtpReceiver.receive(S))},y.prototype.setLocalDescription=function(f){var b,P,S=this;if(["offer","answer"].indexOf(f.type)===-1)return Promise.reject(I("TypeError",'Unsupported type "'+f.type+'"'));if(!d("setLocalDescription",f.type,S.signalingState)||S._isClosed)return Promise.reject(I("InvalidStateError","Can not set local "+f.type+" in state "+S.signalingState));if(f.type==="offer")b=r.splitSections(f.sdp),P=b.shift(),b.forEach(function(C,D){var B=r.parseRtpParameters(C);S.transceivers[D].localCapabilities=B}),S.transceivers.forEach(function(C,D){S._gather(C.mid,D)});else if(f.type==="answer"){b=r.splitSections(S._remoteDescription.sdp),P=b.shift();var T=r.matchPrefix(P,"a=ice-lite").length>0;b.forEach(function(C,D){var B=S.transceivers[D],x=B.iceGatherer,h=B.iceTransport,E=B.dtlsTransport,O=B.localCapabilities,N=B.remoteCapabilities;if(!(r.isRejected(C)&&r.matchPrefix(C,"a=bundle-only").length===0||B.rejected)){var j=r.getIceParameters(C,P),J=r.getDtlsParameters(C,P);T&&(J.role="server"),S.usingBundle&&D!==0||(S._gather(B.mid,D),h.state==="new"&&h.start(x,j,T?"controlling":"controlled"),E.state==="new"&&E.start(J));var $=u(O,N);S._transceive(B,$.codecs.length>0,!1)}})}return S._localDescription={type:f.type,sdp:f.sdp},f.type==="offer"?S._updateSignalingState("have-local-offer"):S._updateSignalingState("stable"),Promise.resolve()},y.prototype.setRemoteDescription=function(f){var b=this;if(["offer","answer"].indexOf(f.type)===-1)return Promise.reject(I("TypeError",'Unsupported type "'+f.type+'"'));if(!d("setRemoteDescription",f.type,b.signalingState)||b._isClosed)return Promise.reject(I("InvalidStateError","Can not set remote "+f.type+" in state "+b.signalingState));var P={};b.remoteStreams.forEach(function(h){P[h.id]=h});var S=[],T=r.splitSections(f.sdp),C=T.shift(),D=r.matchPrefix(C,"a=ice-lite").length>0,B=r.matchPrefix(C,"a=group:BUNDLE ").length>0;b.usingBundle=B;var x=r.matchPrefix(C,"a=ice-options:")[0];return b.canTrickleIceCandidates=!!x&&x.substr(14).split(" ").indexOf("trickle")>=0,T.forEach(function(h,E){var O=r.splitLines(h),N=r.getKind(h),j=r.isRejected(h)&&r.matchPrefix(h,"a=bundle-only").length===0,J=O[0].substr(2).split(" ")[2],$=r.getDirection(h,C),he=r.parseMsid(h),ue=r.getMid(h)||r.generateIdentifier();if(j||N==="application"&&(J==="DTLS/SCTP"||J==="UDP/DTLS/SCTP"))b.transceivers[E]={mid:ue,kind:N,protocol:J,rejected:!0};else{var Ee,Ve,We,kt,Ne,ti,Vi,cr,zn;!j&&b.transceivers[E]&&b.transceivers[E].rejected&&(b.transceivers[E]=b._createTransceiver(N,!0));var XI,QI,YI=r.parseRtpParameters(h);j||(XI=r.getIceParameters(h,C),(QI=r.getDtlsParameters(h,C)).role="client"),Vi=r.parseRtpEncodingParameters(h);var $I=r.parseRtcpParameters(h),ZI=r.matchPrefix(h,"a=end-of-candidates",C).length>0,Ho=r.matchPrefix(h,"a=candidate:").map(function(kn){return r.parseCandidate(kn)}).filter(function(kn){return kn.component===1});if((f.type==="offer"||f.type==="answer")&&!j&&B&&E>0&&b.transceivers[E]&&(b._disposeIceAndDtlsTransports(E),b.transceivers[E].iceGatherer=b.transceivers[0].iceGatherer,b.transceivers[E].iceTransport=b.transceivers[0].iceTransport,b.transceivers[E].dtlsTransport=b.transceivers[0].dtlsTransport,b.transceivers[E].rtpSender&&b.transceivers[E].rtpSender.setTransport(b.transceivers[0].dtlsTransport),b.transceivers[E].rtpReceiver&&b.transceivers[E].rtpReceiver.setTransport(b.transceivers[0].dtlsTransport)),f.type!=="offer"||j)f.type!=="answer"||j||(Ve=(Ee=b.transceivers[E]).iceGatherer,We=Ee.iceTransport,kt=Ee.dtlsTransport,Ne=Ee.rtpReceiver,ti=Ee.sendEncodingParameters,cr=Ee.localCapabilities,b.transceivers[E].recvEncodingParameters=Vi,b.transceivers[E].remoteCapabilities=YI,b.transceivers[E].rtcpParameters=$I,Ho.length&&We.state==="new"&&(!D&&!ZI||B&&E!==0?Ho.forEach(function(kn){g(Ee.iceTransport,kn)}):We.setRemoteCandidates(Ho)),B&&E!==0||(We.state==="new"&&We.start(Ve,XI,"controlling"),kt.state==="new"&&kt.start(QI)),!u(Ee.localCapabilities,Ee.remoteCapabilities).codecs.filter(function(kn){return kn.name.toLowerCase()==="rtx"}).length&&Ee.sendEncodingParameters[0].rtx&&delete Ee.sendEncodingParameters[0].rtx,b._transceive(Ee,$==="sendrecv"||$==="recvonly",$==="sendrecv"||$==="sendonly"),!Ne||$!=="sendrecv"&&$!=="sendonly"?delete Ee.rtpReceiver:(zn=Ne.track,he?(P[he.stream]||(P[he.stream]=new k.MediaStream),A(zn,P[he.stream]),S.push([zn,Ne,P[he.stream]])):(P.default||(P.default=new k.MediaStream),A(zn,P.default),S.push([zn,Ne,P.default]))));else{(Ee=b.transceivers[E]||b._createTransceiver(N)).mid=ue,Ee.iceGatherer||(Ee.iceGatherer=b._createIceGatherer(E,B)),Ho.length&&Ee.iceTransport.state==="new"&&(!ZI||B&&E!==0?Ho.forEach(function(kn){g(Ee.iceTransport,kn)}):Ee.iceTransport.setRemoteCandidates(Ho)),cr=k.RTCRtpReceiver.getCapabilities(N),w<15019&&(cr.codecs=cr.codecs.filter(function(kn){return kn.name!=="rtx"})),ti=Ee.sendEncodingParameters||[{ssrc:1001*(2*E+2)}];var zo,tg=!1;$==="sendrecv"||$==="sendonly"?(tg=!Ee.rtpReceiver,Ne=Ee.rtpReceiver||new k.RTCRtpReceiver(Ee.dtlsTransport,N),tg&&(zn=Ne.track,he&&he.stream==="-"||(he?(P[he.stream]||(P[he.stream]=new k.MediaStream,Object.defineProperty(P[he.stream],"id",{get:function(){return he.stream}})),Object.defineProperty(zn,"id",{get:function(){return he.track}}),zo=P[he.stream]):(P.default||(P.default=new k.MediaStream),zo=P.default)),zo&&(A(zn,zo),Ee.associatedRemoteMediaStreams.push(zo)),S.push([zn,Ne,zo]))):Ee.rtpReceiver&&Ee.rtpReceiver.track&&(Ee.associatedRemoteMediaStreams.forEach(function(kn){var ew=kn.getTracks().find(function(p7){return p7.id===Ee.rtpReceiver.track.id});ew&&p(ew,kn)}),Ee.associatedRemoteMediaStreams=[]),Ee.localCapabilities=cr,Ee.remoteCapabilities=YI,Ee.rtpReceiver=Ne,Ee.rtcpParameters=$I,Ee.sendEncodingParameters=ti,Ee.recvEncodingParameters=Vi,b._transceive(b.transceivers[E],!1,tg)}}}),b._dtlsRole===void 0&&(b._dtlsRole=f.type==="offer"?"active":"passive"),b._remoteDescription={type:f.type,sdp:f.sdp},f.type==="offer"?b._updateSignalingState("have-remote-offer"):b._updateSignalingState("stable"),Object.keys(P).forEach(function(h){var E=P[h];if(E.getTracks().length){if(b.remoteStreams.indexOf(E)===-1){b.remoteStreams.push(E);var O=new Event("addstream");O.stream=E,k.setTimeout(function(){b._dispatchEvent("addstream",O)})}S.forEach(function(N){var j=N[0],J=N[1];E.id===N[2].id&&v(b,j,J,[E])})}}),S.forEach(function(h){h[2]||v(b,h[0],h[1],[])}),k.setTimeout(function(){b&&b.transceivers&&b.transceivers.forEach(function(h){h.iceTransport&&h.iceTransport.state==="new"&&h.iceTransport.getRemoteCandidates().length>0&&(console.warn("Timeout for addRemoteCandidate. Consider sending an end-of-candidates notification"),h.iceTransport.addRemoteCandidate({}))})},4e3),Promise.resolve()},y.prototype.close=function(){this.transceivers.forEach(function(f){f.iceTransport&&f.iceTransport.stop(),f.dtlsTransport&&f.dtlsTransport.stop(),f.rtpSender&&f.rtpSender.stop(),f.rtpReceiver&&f.rtpReceiver.stop()}),this._isClosed=!0,this._updateSignalingState("closed")},y.prototype._updateSignalingState=function(f){this.signalingState=f;var b=new Event("signalingstatechange");this._dispatchEvent("signalingstatechange",b)},y.prototype._maybeFireNegotiationNeeded=function(){var f=this;this.signalingState==="stable"&&this.needNegotiation!==!0&&(this.needNegotiation=!0,k.setTimeout(function(){if(f.needNegotiation){f.needNegotiation=!1;var b=new Event("negotiationneeded");f._dispatchEvent("negotiationneeded",b)}},0))},y.prototype._updateIceConnectionState=function(){var f,b={new:0,closed:0,checking:0,connected:0,completed:0,disconnected:0,failed:0};if(this.transceivers.forEach(function(S){S.iceTransport&&!S.rejected&&b[S.iceTransport.state]++}),f="new",b.failed>0?f="failed":b.checking>0?f="checking":b.disconnected>0?f="disconnected":b.new>0?f="new":b.connected>0?f="connected":b.completed>0&&(f="completed"),f!==this.iceConnectionState){this.iceConnectionState=f;var P=new Event("iceconnectionstatechange");this._dispatchEvent("iceconnectionstatechange",P)}},y.prototype._updateConnectionState=function(){var f,b={new:0,closed:0,connecting:0,connected:0,completed:0,disconnected:0,failed:0};if(this.transceivers.forEach(function(S){S.iceTransport&&S.dtlsTransport&&!S.rejected&&(b[S.iceTransport.state]++,b[S.dtlsTransport.state]++)}),b.connected+=b.completed,f="new",b.failed>0?f="failed":b.connecting>0?f="connecting":b.disconnected>0?f="disconnected":b.new>0?f="new":b.connected>0&&(f="connected"),f!==this.connectionState){this.connectionState=f;var P=new Event("connectionstatechange");this._dispatchEvent("connectionstatechange",P)}},y.prototype.createOffer=function(){var f=this;if(f._isClosed)return Promise.reject(I("InvalidStateError","Can not call createOffer after close"));var b=f.transceivers.filter(function(D){return D.kind==="audio"}).length,P=f.transceivers.filter(function(D){return D.kind==="video"}).length,S=arguments[0];if(S){if(S.mandatory||S.optional)throw new TypeError("Legacy mandatory/optional constraints not supported.");S.offerToReceiveAudio!==void 0&&(b=S.offerToReceiveAudio===!0?1:S.offerToReceiveAudio===!1?0:S.offerToReceiveAudio),S.offerToReceiveVideo!==void 0&&(P=S.offerToReceiveVideo===!0?1:S.offerToReceiveVideo===!1?0:S.offerToReceiveVideo)}for(f.transceivers.forEach(function(D){D.kind==="audio"?--b<0&&(D.wantReceive=!1):D.kind==="video"&&--P<0&&(D.wantReceive=!1)});b>0||P>0;)b>0&&(f._createTransceiver("audio"),b--),P>0&&(f._createTransceiver("video"),P--);var T=r.writeSessionBoilerplate(f._sdpSessionId,f._sdpSessionVersion++);f.transceivers.forEach(function(D,B){var x=D.track,h=D.kind,E=D.mid||r.generateIdentifier();D.mid=E,D.iceGatherer||(D.iceGatherer=f._createIceGatherer(B,f.usingBundle));var O=k.RTCRtpSender.getCapabilities(h);w<15019&&(O.codecs=O.codecs.filter(function(j){return j.name!=="rtx"})),O.codecs.forEach(function(j){j.name==="H264"&&j.parameters["level-asymmetry-allowed"]===void 0&&(j.parameters["level-asymmetry-allowed"]="1"),D.remoteCapabilities&&D.remoteCapabilities.codecs&&D.remoteCapabilities.codecs.forEach(function(J){j.name.toLowerCase()===J.name.toLowerCase()&&j.clockRate===J.clockRate&&(j.preferredPayloadType=J.payloadType)})}),O.headerExtensions.forEach(function(j){(D.remoteCapabilities&&D.remoteCapabilities.headerExtensions||[]).forEach(function(J){j.uri===J.uri&&(j.id=J.id)})});var N=D.sendEncodingParameters||[{ssrc:1001*(2*B+1)}];x&&w>=15019&&h==="video"&&!N[0].rtx&&(N[0].rtx={ssrc:N[0].ssrc+1}),D.wantReceive&&(D.rtpReceiver=new k.RTCRtpReceiver(D.dtlsTransport,h)),D.localCapabilities=O,D.sendEncodingParameters=N}),f._config.bundlePolicy!=="max-compat"&&(T+="a=group:BUNDLE "+f.transceivers.map(function(D){return D.mid}).join(" ")+`\r
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
a=
|
|
29
|
-
`:T.kind==="video"&&(b+=`m=video 0 UDP/TLS/RTP/SAVPF 120\r
|
|
30
|
-
a=rtpmap:120 VP8/90000\r
|
|
31
|
-
`),void(b+=`c=IN IP4 0.0.0.0\r
|
|
32
|
-
a=inactive\r
|
|
33
|
-
a=mid:`+T.mid+`\r
|
|
34
|
-
`);var D;T.stream&&(T.kind==="audio"?D=T.stream.getAudioTracks()[0]:T.kind==="video"&&(D=T.stream.getVideoTracks()[0]),D&&w>=15019&&T.kind==="video"&&!T.sendEncodingParameters[0].rtx&&(T.sendEncodingParameters[0].rtx={ssrc:T.sendEncodingParameters[0].ssrc+1}));var B=u(T.localCapabilities,T.remoteCapabilities);!B.codecs.filter(function(x){return x.name.toLowerCase()==="rtx"}).length&&T.sendEncodingParameters[0].rtx&&delete T.sendEncodingParameters[0].rtx,b+=s(T,B,"answer",T.stream,f._dtlsRole),T.rtcpParameters&&T.rtcpParameters.reducedSize&&(b+=`a=rtcp-rsize\r
|
|
35
|
-
`)}});var S=new k.RTCSessionDescription({type:"answer",sdp:b});return Promise.resolve(S)},y.prototype.addIceCandidate=function(f){var b,P=this;return f&&f.sdpMLineIndex===void 0&&!f.sdpMid?Promise.reject(new TypeError("sdpMLineIndex or sdpMid required")):new Promise(function(S,T){if(!P._remoteDescription)return T(I("InvalidStateError","Can not add ICE candidate without a remote description"));if(f&&f.candidate!==""){var C=f.sdpMLineIndex;if(f.sdpMid){for(var D=0;D<P.transceivers.length;D++)if(P.transceivers[D].mid===f.sdpMid){C=D;break}}var B=P.transceivers[C];if(!B)return T(I("OperationError","Can not add ICE candidate"));if(B.rejected)return S();var x=Object.keys(f.candidate).length>0?r.parseCandidate(f.candidate):{};if(x.protocol==="tcp"&&(x.port===0||x.port===9)||x.component&&x.component!==1)return S();if((C===0||C>0&&B.iceTransport!==P.transceivers[0].iceTransport)&&!g(B.iceTransport,x))return T(I("OperationError","Can not add ICE candidate"));var h=f.candidate.trim();h.indexOf("a=")===0&&(h=h.substr(2)),(b=r.getMediaSections(P._remoteDescription.sdp))[C]+="a="+(x.type?h:"end-of-candidates")+`\r
|
|
36
|
-
`,P._remoteDescription.sdp=r.getDescription(P._remoteDescription.sdp)+b.join("")}else for(var E=0;E<P.transceivers.length&&(P.transceivers[E].rejected||(P.transceivers[E].iceTransport.addRemoteCandidate({}),(b=r.getMediaSections(P._remoteDescription.sdp))[E]+=`a=end-of-candidates\r
|
|
37
|
-
`,P._remoteDescription.sdp=r.getDescription(P._remoteDescription.sdp)+b.join(""),!P.usingBundle));E++);S()})},y.prototype.getStats=function(f){if(f&&f instanceof k.MediaStreamTrack){var b=null;if(this.transceivers.forEach(function(S){S.rtpSender&&S.rtpSender.track===f?b=S.rtpSender:S.rtpReceiver&&S.rtpReceiver.track===f&&(b=S.rtpReceiver)}),!b)throw I("InvalidAccessError","Invalid selector.");return b.getStats()}var P=[];return this.transceivers.forEach(function(S){["rtpSender","rtpReceiver","iceGatherer","iceTransport","dtlsTransport"].forEach(function(T){S[T]&&P.push(S[T].getStats())})}),Promise.all(P).then(function(S){var T=new Map;return S.forEach(function(C){C.forEach(function(D){T.set(D.id,D)})}),T})},["RTCRtpSender","RTCRtpReceiver","RTCIceGatherer","RTCIceTransport","RTCDtlsTransport"].forEach(function(f){var b=k[f];if(b&&b.prototype&&b.prototype.getStats){var P=b.prototype.getStats;b.prototype.getStats=function(){return P.apply(this).then(function(S){var T=new Map;return Object.keys(S).forEach(function(C){S[C].type=o(S[C]),T.set(C,S[C])}),T})}}});var L=["createOffer","createAnswer"];return L.forEach(function(f){var b=y.prototype[f];y.prototype[f]=function(){var P=arguments;return typeof P[0]=="function"||typeof P[1]=="function"?b.apply(this,[arguments[2]]).then(function(S){typeof P[0]=="function"&&P[0].apply(null,[S])},function(S){typeof P[1]=="function"&&P[1].apply(null,[S])}):b.apply(this,arguments)}}),(L=["setLocalDescription","setRemoteDescription","addIceCandidate"]).forEach(function(f){var b=y.prototype[f];y.prototype[f]=function(){var P=arguments;return typeof P[1]=="function"||typeof P[2]=="function"?b.apply(this,arguments).then(function(){typeof P[1]=="function"&&P[1].apply(null)},function(S){typeof P[2]=="function"&&P[2].apply(null,[S])}):b.apply(this,arguments)}}),["getStats"].forEach(function(f){var b=y.prototype[f];y.prototype[f]=function(){var P=arguments;return typeof P[1]=="function"?b.apply(this,arguments).then(function(){typeof P[1]=="function"&&P[1].apply(null)}):b.apply(this,arguments)}}),y}},{sdp:17}],17:[function(n,a,i){var r={generateIdentifier:function(){return Math.random().toString(36).substr(2,10)}};r.localCName=r.generateIdentifier(),r.splitLines=function(o){return o.trim().split(`
|
|
38
|
-
`).map(function(s){return s.trim()})},r.splitSections=function(o){return o.split(`
|
|
39
|
-
m=`).map(function(s,c){return(c>0?"m="+s:s).trim()+`\r
|
|
40
|
-
`})},r.getDescription=function(o){var s=r.splitSections(o);return s&&s[0]},r.getMediaSections=function(o){var s=r.splitSections(o);return s.shift(),s},r.matchPrefix=function(o,s){return r.splitLines(o).filter(function(c){return c.indexOf(s)===0})},r.parseCandidate=function(o){for(var s,c={foundation:(s=o.indexOf("a=candidate:")===0?o.substring(12).split(" "):o.substring(10).split(" "))[0],component:parseInt(s[1],10),protocol:s[2].toLowerCase(),priority:parseInt(s[3],10),ip:s[4],address:s[4],port:parseInt(s[5],10),type:s[7]},u=8;u<s.length;u+=2)switch(s[u]){case"raddr":c.relatedAddress=s[u+1];break;case"rport":c.relatedPort=parseInt(s[u+1],10);break;case"tcptype":c.tcpType=s[u+1];break;case"ufrag":c.ufrag=s[u+1],c.usernameFragment=s[u+1];break;default:c[s[u]]=s[u+1]}return c},r.writeCandidate=function(o){var s=[];s.push(o.foundation),s.push(o.component),s.push(o.protocol.toUpperCase()),s.push(o.priority),s.push(o.address||o.ip),s.push(o.port);var c=o.type;return s.push("typ"),s.push(c),c!=="host"&&o.relatedAddress&&o.relatedPort&&(s.push("raddr"),s.push(o.relatedAddress),s.push("rport"),s.push(o.relatedPort)),o.tcpType&&o.protocol.toLowerCase()==="tcp"&&(s.push("tcptype"),s.push(o.tcpType)),(o.usernameFragment||o.ufrag)&&(s.push("ufrag"),s.push(o.usernameFragment||o.ufrag)),"candidate:"+s.join(" ")},r.parseIceOptions=function(o){return o.substr(14).split(" ")},r.parseRtpMap=function(o){var s=o.substr(9).split(" "),c={payloadType:parseInt(s.shift(),10)};return s=s[0].split("/"),c.name=s[0],c.clockRate=parseInt(s[1],10),c.channels=s.length===3?parseInt(s[2],10):1,c.numChannels=c.channels,c},r.writeRtpMap=function(o){var s=o.payloadType;o.preferredPayloadType!==void 0&&(s=o.preferredPayloadType);var c=o.channels||o.numChannels||1;return"a=rtpmap:"+s+" "+o.name+"/"+o.clockRate+(c!==1?"/"+c:"")+`\r
|
|
41
|
-
`},r.parseExtmap=function(o){var s=o.substr(9).split(" ");return{id:parseInt(s[0],10),direction:s[0].indexOf("/")>0?s[0].split("/")[1]:"sendrecv",uri:s[1]}},r.writeExtmap=function(o){return"a=extmap:"+(o.id||o.preferredId)+(o.direction&&o.direction!=="sendrecv"?"/"+o.direction:"")+" "+o.uri+`\r
|
|
42
|
-
`},r.parseFmtp=function(o){for(var s,c={},u=o.substr(o.indexOf(" ")+1).split(";"),d=0;d<u.length;d++)c[(s=u[d].trim().split("="))[0].trim()]=s[1];return c},r.writeFmtp=function(o){var s="",c=o.payloadType;if(o.preferredPayloadType!==void 0&&(c=o.preferredPayloadType),o.parameters&&Object.keys(o.parameters).length){var u=[];Object.keys(o.parameters).forEach(function(d){o.parameters[d]?u.push(d+"="+o.parameters[d]):u.push(d)}),s+="a=fmtp:"+c+" "+u.join(";")+`\r
|
|
43
|
-
`}return s},r.parseRtcpFb=function(o){var s=o.substr(o.indexOf(" ")+1).split(" ");return{type:s.shift(),parameter:s.join(" ")}},r.writeRtcpFb=function(o){var s="",c=o.payloadType;return o.preferredPayloadType!==void 0&&(c=o.preferredPayloadType),o.rtcpFeedback&&o.rtcpFeedback.length&&o.rtcpFeedback.forEach(function(u){s+="a=rtcp-fb:"+c+" "+u.type+(u.parameter&&u.parameter.length?" "+u.parameter:"")+`\r
|
|
44
|
-
`}),s},r.parseSsrcMedia=function(o){var s=o.indexOf(" "),c={ssrc:parseInt(o.substr(7,s-7),10)},u=o.indexOf(":",s);return u>-1?(c.attribute=o.substr(s+1,u-s-1),c.value=o.substr(u+1)):c.attribute=o.substr(s+1),c},r.parseSsrcGroup=function(o){var s=o.substr(13).split(" ");return{semantics:s.shift(),ssrcs:s.map(function(c){return parseInt(c,10)})}},r.getMid=function(o){var s=r.matchPrefix(o,"a=mid:")[0];if(s)return s.substr(6)},r.parseFingerprint=function(o){var s=o.substr(14).split(" ");return{algorithm:s[0].toLowerCase(),value:s[1]}},r.getDtlsParameters=function(o,s){return{role:"auto",fingerprints:r.matchPrefix(o+s,"a=fingerprint:").map(r.parseFingerprint)}},r.writeDtlsParameters=function(o,s){var c="a=setup:"+s+`\r
|
|
45
|
-
`;return o.fingerprints.forEach(function(u){c+="a=fingerprint:"+u.algorithm+" "+u.value+`\r
|
|
46
|
-
`}),c},r.parseCryptoLine=function(o){var s=o.substr(9).split(" ");return{tag:parseInt(s[0],10),cryptoSuite:s[1],keyParams:s[2],sessionParams:s.slice(3)}},r.writeCryptoLine=function(o){return"a=crypto:"+o.tag+" "+o.cryptoSuite+" "+(typeof o.keyParams=="object"?r.writeCryptoKeyParams(o.keyParams):o.keyParams)+(o.sessionParams?" "+o.sessionParams.join(" "):"")+`\r
|
|
47
|
-
`},r.parseCryptoKeyParams=function(o){if(o.indexOf("inline:")!==0)return null;var s=o.substr(7).split("|");return{keyMethod:"inline",keySalt:s[0],lifeTime:s[1],mkiValue:s[2]?s[2].split(":")[0]:void 0,mkiLength:s[2]?s[2].split(":")[1]:void 0}},r.writeCryptoKeyParams=function(o){return o.keyMethod+":"+o.keySalt+(o.lifeTime?"|"+o.lifeTime:"")+(o.mkiValue&&o.mkiLength?"|"+o.mkiValue+":"+o.mkiLength:"")},r.getCryptoParameters=function(o,s){return r.matchPrefix(o+s,"a=crypto:").map(r.parseCryptoLine)},r.getIceParameters=function(o,s){var c=r.matchPrefix(o+s,"a=ice-ufrag:")[0],u=r.matchPrefix(o+s,"a=ice-pwd:")[0];return c&&u?{usernameFragment:c.substr(12),password:u.substr(10)}:null},r.writeIceParameters=function(o){return"a=ice-ufrag:"+o.usernameFragment+`\r
|
|
48
|
-
a=ice-pwd:`+o.password+`\r
|
|
49
|
-
`},r.parseRtpParameters=function(o){for(var s={codecs:[],headerExtensions:[],fecMechanisms:[],rtcp:[]},c=r.splitLines(o)[0].split(" "),u=3;u<c.length;u++){var d=c[u],g=r.matchPrefix(o,"a=rtpmap:"+d+" ")[0];if(g){var I=r.parseRtpMap(g),k=r.matchPrefix(o,"a=fmtp:"+d+" ");switch(I.parameters=k.length?r.parseFmtp(k[0]):{},I.rtcpFeedback=r.matchPrefix(o,"a=rtcp-fb:"+d+" ").map(r.parseRtcpFb),s.codecs.push(I),I.name.toUpperCase()){case"RED":case"ULPFEC":s.fecMechanisms.push(I.name.toUpperCase())}}}return r.matchPrefix(o,"a=extmap:").forEach(function(w){s.headerExtensions.push(r.parseExtmap(w))}),s},r.writeRtpDescription=function(o,s){var c="";c+="m="+o+" ",c+=s.codecs.length>0?"9":"0",c+=" UDP/TLS/RTP/SAVPF ",c+=s.codecs.map(function(d){return d.preferredPayloadType!==void 0?d.preferredPayloadType:d.payloadType}).join(" ")+`\r
|
|
50
|
-
`,c+=`c=IN IP4 0.0.0.0\r
|
|
51
|
-
`,c+=`a=rtcp:9 IN IP4 0.0.0.0\r
|
|
52
|
-
`,s.codecs.forEach(function(d){c+=r.writeRtpMap(d),c+=r.writeFmtp(d),c+=r.writeRtcpFb(d)});var u=0;return s.codecs.forEach(function(d){d.maxptime>u&&(u=d.maxptime)}),u>0&&(c+="a=maxptime:"+u+`\r
|
|
53
|
-
`),c+=`a=rtcp-mux\r
|
|
54
|
-
`,s.headerExtensions&&s.headerExtensions.forEach(function(d){c+=r.writeExtmap(d)}),c},r.parseRtpEncodingParameters=function(o){var s,c=[],u=r.parseRtpParameters(o),d=u.fecMechanisms.indexOf("RED")!==-1,g=u.fecMechanisms.indexOf("ULPFEC")!==-1,I=r.matchPrefix(o,"a=ssrc:").map(function(p){return r.parseSsrcMedia(p)}).filter(function(p){return p.attribute==="cname"}),k=I.length>0&&I[0].ssrc,w=r.matchPrefix(o,"a=ssrc-group:FID").map(function(p){return p.substr(17).split(" ").map(function(v){return parseInt(v,10)})});w.length>0&&w[0].length>1&&w[0][0]===k&&(s=w[0][1]),u.codecs.forEach(function(p){if(p.name.toUpperCase()==="RTX"&&p.parameters.apt){var v={ssrc:k,codecPayloadType:parseInt(p.parameters.apt,10)};k&&s&&(v.rtx={ssrc:s}),c.push(v),d&&((v=JSON.parse(JSON.stringify(v))).fec={ssrc:k,mechanism:g?"red+ulpfec":"red"},c.push(v))}}),c.length===0&&k&&c.push({ssrc:k});var A=r.matchPrefix(o,"b=");return A.length&&(A=A[0].indexOf("b=TIAS:")===0?parseInt(A[0].substr(7),10):A[0].indexOf("b=AS:")===0?1e3*parseInt(A[0].substr(5),10)*.95-16e3:void 0,c.forEach(function(p){p.maxBitrate=A})),c},r.parseRtcpParameters=function(o){var s={},c=r.matchPrefix(o,"a=ssrc:").map(function(g){return r.parseSsrcMedia(g)}).filter(function(g){return g.attribute==="cname"})[0];c&&(s.cname=c.value,s.ssrc=c.ssrc);var u=r.matchPrefix(o,"a=rtcp-rsize");s.reducedSize=u.length>0,s.compound=u.length===0;var d=r.matchPrefix(o,"a=rtcp-mux");return s.mux=d.length>0,s},r.parseMsid=function(o){var s,c=r.matchPrefix(o,"a=msid:");if(c.length===1)return{stream:(s=c[0].substr(7).split(" "))[0],track:s[1]};var u=r.matchPrefix(o,"a=ssrc:").map(function(d){return r.parseSsrcMedia(d)}).filter(function(d){return d.attribute==="msid"});return u.length>0?{stream:(s=u[0].value.split(" "))[0],track:s[1]}:void 0},r.parseSctpDescription=function(o){var s,c=r.parseMLine(o),u=r.matchPrefix(o,"a=max-message-size:");u.length>0&&(s=parseInt(u[0].substr(19),10)),isNaN(s)&&(s=65536);var d=r.matchPrefix(o,"a=sctp-port:");if(d.length>0)return{port:parseInt(d[0].substr(12),10),protocol:c.fmt,maxMessageSize:s};if(r.matchPrefix(o,"a=sctpmap:").length>0){var g=r.matchPrefix(o,"a=sctpmap:")[0].substr(10).split(" ");return{port:parseInt(g[0],10),protocol:g[1],maxMessageSize:s}}},r.writeSctpDescription=function(o,s){var c=[];return c=o.protocol!=="DTLS/SCTP"?["m="+o.kind+" 9 "+o.protocol+" "+s.protocol+`\r
|
|
7
|
+
`);w.RTCSessionDescription&&V instanceof w.RTCSessionDescription?arguments[0]=new w.RTCSessionDescription({type:V.type,sdp:_}):V.sdp=_}return N.apply(this,arguments)}}}function T(w,L){if(w.RTCPeerConnection&&w.RTCPeerConnection.prototype){var N=w.RTCPeerConnection.prototype.addIceCandidate;N&&N.length!==0&&(w.RTCPeerConnection.prototype.addIceCandidate=function(){return arguments[0]?(L.browser==="chrome"&&L.version<78||L.browser==="firefox"&&L.version<68||L.browser==="safari")&&arguments[0]&&arguments[0].candidate===""?Promise.resolve():N.apply(this,arguments):(arguments[1]&&arguments[1].apply(null),Promise.resolve())})}}function v(w,L){if(w.RTCPeerConnection&&w.RTCPeerConnection.prototype){var N=w.RTCPeerConnection.prototype.setLocalDescription;N&&N.length!==0&&(w.RTCPeerConnection.prototype.setLocalDescription=function(){var V=this,_=arguments[0]||{};if(u(_)!=="object"||_.type&&_.sdp)return N.apply(this,arguments);if(!(_={type:_.type,sdp:_.sdp}).type)switch(this.signalingState){case"stable":case"have-local-offer":case"have-remote-pranswer":_.type="offer";break;default:_.type="answer"}return _.sdp||_.type!=="offer"&&_.type!=="answer"?N.apply(this,[_]):(_.type==="offer"?this.createOffer:this.createAnswer).apply(this).then(function(b){return N.apply(V,[b])})})}}},{"./utils":11,sdp:12}],7:[function(n,i,r){Object.defineProperty(r,"__esModule",{value:!0}),r.shimAddTransceiver=P,r.shimCreateAnswer=h,r.shimCreateOffer=k,Object.defineProperty(r,"shimGetDisplayMedia",{enumerable:!0,get:function(){return a.shimGetDisplayMedia}}),r.shimGetParameters=U,Object.defineProperty(r,"shimGetUserMedia",{enumerable:!0,get:function(){return c.shimGetUserMedia}}),r.shimOnTrack=L,r.shimPeerConnection=N,r.shimRTCDataChannel=R,r.shimReceiverGetStats=_,r.shimRemoveStream=b,r.shimSenderGetStats=V;var o=l(n("../utils")),c=n("./getusermedia"),a=n("./getdisplaymedia");function s(y){if(typeof WeakMap!="function")return null;var A=new WeakMap,D=new WeakMap;return(s=function(j){return j?D:A})(y)}function l(y,A){if(!A&&y&&y.__esModule)return y;if(y===null||w(y)!=="object"&&typeof y!="function")return{default:y};var D=s(A);if(D&&D.has(y))return D.get(y);var j={},K=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var J in y)if(J!=="default"&&Object.prototype.hasOwnProperty.call(y,J)){var se=K?Object.getOwnPropertyDescriptor(y,J):null;se&&(se.get||se.set)?Object.defineProperty(j,J,se):j[J]=y[J]}return j.default=y,D&&D.set(y,j),j}function u(y){return E(y)||x(y)||S(y)||f()}function f(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
|
|
8
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function S(y,A){if(y){if(typeof y=="string")return I(y,A);var D=Object.prototype.toString.call(y).slice(8,-1);return D==="Object"&&y.constructor&&(D=y.constructor.name),D==="Map"||D==="Set"?Array.from(y):D==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(D)?I(y,A):void 0}}function x(y){if(typeof Symbol!="undefined"&&y[Symbol.iterator]!=null||y["@@iterator"]!=null)return Array.from(y)}function E(y){if(Array.isArray(y))return I(y)}function I(y,A){(A==null||A>y.length)&&(A=y.length);for(var D=0,j=new Array(A);D<A;D++)j[D]=y[D];return j}function m(y,A,D){return(A=T(A))in y?Object.defineProperty(y,A,{value:D,enumerable:!0,configurable:!0,writable:!0}):y[A]=D,y}function T(y){var A=v(y,"string");return w(A)==="symbol"?A:String(A)}function v(y,A){if(w(y)!=="object"||y===null)return y;var D=y[Symbol.toPrimitive];if(D!==void 0){var j=D.call(y,A||"default");if(w(j)!=="object")return j;throw new TypeError("@@toPrimitive must return a primitive value.")}return(A==="string"?String:Number)(y)}function w(y){return w=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(A){return typeof A}:function(A){return A&&typeof Symbol=="function"&&A.constructor===Symbol&&A!==Symbol.prototype?"symbol":typeof A},w(y)}function L(y){w(y)==="object"&&y.RTCTrackEvent&&"receiver"in y.RTCTrackEvent.prototype&&!("transceiver"in y.RTCTrackEvent.prototype)&&Object.defineProperty(y.RTCTrackEvent.prototype,"transceiver",{get:function(){return{receiver:this.receiver}}})}function N(y,A){if(w(y)==="object"&&(y.RTCPeerConnection||y.mozRTCPeerConnection)){!y.RTCPeerConnection&&y.mozRTCPeerConnection&&(y.RTCPeerConnection=y.mozRTCPeerConnection),A.version<53&&["setLocalDescription","setRemoteDescription","addIceCandidate"].forEach(function(K){var J=y.RTCPeerConnection.prototype[K],se=m({},K,function(){return arguments[0]=new(K==="addIceCandidate"?y.RTCIceCandidate:y.RTCSessionDescription)(arguments[0]),J.apply(this,arguments)});y.RTCPeerConnection.prototype[K]=se[K]});var D={inboundrtp:"inbound-rtp",outboundrtp:"outbound-rtp",candidatepair:"candidate-pair",localcandidate:"local-candidate",remotecandidate:"remote-candidate"},j=y.RTCPeerConnection.prototype.getStats;y.RTCPeerConnection.prototype.getStats=function(){var K=Array.prototype.slice.call(arguments),J=K[0],se=K[1],ie=K[2];return j.apply(this,[J||null]).then(function(Je){if(A.version<53&&!se)try{Je.forEach(function(Ue){Ue.type=D[Ue.type]||Ue.type})}catch(Ue){if(Ue.name!=="TypeError")throw Ue;Je.forEach(function(Fe,ht){Je.set(ht,Object.assign({},Fe,{type:D[Fe.type]||Fe.type}))})}return Je}).then(se,ie)}}}function V(y){if(w(y)==="object"&&y.RTCPeerConnection&&y.RTCRtpSender&&(!y.RTCRtpSender||!("getStats"in y.RTCRtpSender.prototype))){var A=y.RTCPeerConnection.prototype.getSenders;A&&(y.RTCPeerConnection.prototype.getSenders=function(){var j=this,K=A.apply(this,[]);return K.forEach(function(J){return J._pc=j}),K});var D=y.RTCPeerConnection.prototype.addTrack;D&&(y.RTCPeerConnection.prototype.addTrack=function(){var j=D.apply(this,arguments);return j._pc=this,j}),y.RTCRtpSender.prototype.getStats=function(){return this.track?this._pc.getStats(this.track):Promise.resolve(new Map)}}}function _(y){if(w(y)==="object"&&y.RTCPeerConnection&&y.RTCRtpSender&&(!y.RTCRtpSender||!("getStats"in y.RTCRtpReceiver.prototype))){var A=y.RTCPeerConnection.prototype.getReceivers;A&&(y.RTCPeerConnection.prototype.getReceivers=function(){var D=this,j=A.apply(this,[]);return j.forEach(function(K){return K._pc=D}),j}),o.wrapPeerConnectionEvent(y,"track",function(D){return D.receiver._pc=D.srcElement,D}),y.RTCRtpReceiver.prototype.getStats=function(){return this._pc.getStats(this.track)}}}function b(y){y.RTCPeerConnection&&!("removeStream"in y.RTCPeerConnection.prototype)&&(y.RTCPeerConnection.prototype.removeStream=function(A){var D=this;o.deprecated("removeStream","removeTrack"),this.getSenders().forEach(function(j){j.track&&A.getTracks().includes(j.track)&&D.removeTrack(j)})})}function R(y){y.DataChannel&&!y.RTCDataChannel&&(y.RTCDataChannel=y.DataChannel)}function P(y){if(w(y)==="object"&&y.RTCPeerConnection){var A=y.RTCPeerConnection.prototype.addTransceiver;A&&(y.RTCPeerConnection.prototype.addTransceiver=function(){this.setParametersPromises=[];var D=arguments[1]&&arguments[1].sendEncodings;D===void 0&&(D=[]);var j=(D=u(D)).length>0;j&&D.forEach(function(ie){if("rid"in ie&&!/^[a-z0-9]{0,16}$/i.test(ie.rid))throw new TypeError("Invalid RID value provided.");if("scaleResolutionDownBy"in ie&&!(parseFloat(ie.scaleResolutionDownBy)>=1))throw new RangeError("scale_resolution_down_by must be >= 1.0");if("maxFramerate"in ie&&!(parseFloat(ie.maxFramerate)>=0))throw new RangeError("max_framerate must be >= 0.0")});var K=A.apply(this,arguments);if(j){var J=K.sender,se=J.getParameters();(!("encodings"in se)||se.encodings.length===1&&Object.keys(se.encodings[0]).length===0)&&(se.encodings=D,J.sendEncodings=D,this.setParametersPromises.push(J.setParameters(se).then(function(){delete J.sendEncodings}).catch(function(){delete J.sendEncodings})))}return K})}}function U(y){if(w(y)==="object"&&y.RTCRtpSender){var A=y.RTCRtpSender.prototype.getParameters;A&&(y.RTCRtpSender.prototype.getParameters=function(){var D=A.apply(this,arguments);return"encodings"in D||(D.encodings=[].concat(this.sendEncodings||[{}])),D})}}function k(y){if(w(y)==="object"&&y.RTCPeerConnection){var A=y.RTCPeerConnection.prototype.createOffer;y.RTCPeerConnection.prototype.createOffer=function(){var D=arguments,j=this;return this.setParametersPromises&&this.setParametersPromises.length?Promise.all(this.setParametersPromises).then(function(){return A.apply(j,D)}).finally(function(){j.setParametersPromises=[]}):A.apply(this,arguments)}}}function h(y){if(w(y)==="object"&&y.RTCPeerConnection){var A=y.RTCPeerConnection.prototype.createAnswer;y.RTCPeerConnection.prototype.createAnswer=function(){var D=arguments,j=this;return this.setParametersPromises&&this.setParametersPromises.length?Promise.all(this.setParametersPromises).then(function(){return A.apply(j,D)}).finally(function(){j.setParametersPromises=[]}):A.apply(this,arguments)}}}},{"../utils":11,"./getdisplaymedia":8,"./getusermedia":9}],8:[function(n,i,r){function o(c,a){c.navigator.mediaDevices&&"getDisplayMedia"in c.navigator.mediaDevices||c.navigator.mediaDevices&&(c.navigator.mediaDevices.getDisplayMedia=function(s){if(!s||!s.video){var l=new DOMException("getDisplayMedia without video constraints is undefined");return l.name="NotFoundError",l.code=8,Promise.reject(l)}return s.video===!0?s.video={mediaSource:a}:s.video.mediaSource=a,c.navigator.mediaDevices.getUserMedia(s)})}Object.defineProperty(r,"__esModule",{value:!0}),r.shimGetDisplayMedia=o},{}],9:[function(n,i,r){Object.defineProperty(r,"__esModule",{value:!0}),r.shimGetUserMedia=l;var o=a(n("../utils"));function c(u){if(typeof WeakMap!="function")return null;var f=new WeakMap,S=new WeakMap;return(c=function(x){return x?S:f})(u)}function a(u,f){if(!f&&u&&u.__esModule)return u;if(u===null||s(u)!=="object"&&typeof u!="function")return{default:u};var S=c(f);if(S&&S.has(u))return S.get(u);var x={},E=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var I in u)if(I!=="default"&&Object.prototype.hasOwnProperty.call(u,I)){var m=E?Object.getOwnPropertyDescriptor(u,I):null;m&&(m.get||m.set)?Object.defineProperty(x,I,m):x[I]=u[I]}return x.default=u,S&&S.set(u,x),x}function s(u){return s=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(f){return typeof f}:function(f){return f&&typeof Symbol=="function"&&f.constructor===Symbol&&f!==Symbol.prototype?"symbol":typeof f},s(u)}function l(u,f){var S=u&&u.navigator,x=u&&u.MediaStreamTrack;if(S.getUserMedia=function(v,w,L){o.deprecated("navigator.getUserMedia","navigator.mediaDevices.getUserMedia"),S.mediaDevices.getUserMedia(v).then(w,L)},!(f.version>55&&"autoGainControl"in S.mediaDevices.getSupportedConstraints())){var E=function(v,w,L){w in v&&!(L in v)&&(v[L]=v[w],delete v[w])},I=S.mediaDevices.getUserMedia.bind(S.mediaDevices);if(S.mediaDevices.getUserMedia=function(v){return s(v)==="object"&&s(v.audio)==="object"&&(v=JSON.parse(JSON.stringify(v)),E(v.audio,"autoGainControl","mozAutoGainControl"),E(v.audio,"noiseSuppression","mozNoiseSuppression")),I(v)},x&&x.prototype.getSettings){var m=x.prototype.getSettings;x.prototype.getSettings=function(){var v=m.apply(this,arguments);return E(v,"mozAutoGainControl","autoGainControl"),E(v,"mozNoiseSuppression","noiseSuppression"),v}}if(x&&x.prototype.applyConstraints){var T=x.prototype.applyConstraints;x.prototype.applyConstraints=function(v){return this.kind==="audio"&&s(v)==="object"&&(v=JSON.parse(JSON.stringify(v)),E(v,"autoGainControl","mozAutoGainControl"),E(v,"noiseSuppression","mozNoiseSuppression")),T.apply(this,[v])}}}}},{"../utils":11}],10:[function(n,i,r){Object.defineProperty(r,"__esModule",{value:!0}),r.shimAudioContext=T,r.shimCallbacksAPI=f,r.shimConstraints=x,r.shimCreateOfferLegacy=m,r.shimGetUserMedia=S,r.shimLocalStreamsAPI=l,r.shimRTCIceServerUrls=E,r.shimRemoteStreamsAPI=u,r.shimTrackEventTransceiver=I;var o=a(n("../utils"));function c(v){if(typeof WeakMap!="function")return null;var w=new WeakMap,L=new WeakMap;return(c=function(N){return N?L:w})(v)}function a(v,w){if(!w&&v&&v.__esModule)return v;if(v===null||s(v)!=="object"&&typeof v!="function")return{default:v};var L=c(w);if(L&&L.has(v))return L.get(v);var N={},V=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var _ in v)if(_!=="default"&&Object.prototype.hasOwnProperty.call(v,_)){var b=V?Object.getOwnPropertyDescriptor(v,_):null;b&&(b.get||b.set)?Object.defineProperty(N,_,b):N[_]=v[_]}return N.default=v,L&&L.set(v,N),N}function s(v){return s=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(w){return typeof w}:function(w){return w&&typeof Symbol=="function"&&w.constructor===Symbol&&w!==Symbol.prototype?"symbol":typeof w},s(v)}function l(v){if(s(v)==="object"&&v.RTCPeerConnection){if("getLocalStreams"in v.RTCPeerConnection.prototype||(v.RTCPeerConnection.prototype.getLocalStreams=function(){return this._localStreams||(this._localStreams=[]),this._localStreams}),!("addStream"in v.RTCPeerConnection.prototype)){var w=v.RTCPeerConnection.prototype.addTrack;v.RTCPeerConnection.prototype.addStream=function(L){var N=this;this._localStreams||(this._localStreams=[]),this._localStreams.includes(L)||this._localStreams.push(L),L.getAudioTracks().forEach(function(V){return w.call(N,V,L)}),L.getVideoTracks().forEach(function(V){return w.call(N,V,L)})},v.RTCPeerConnection.prototype.addTrack=function(L){for(var N=this,V=arguments.length,_=new Array(V>1?V-1:0),b=1;b<V;b++)_[b-1]=arguments[b];return _&&_.forEach(function(R){N._localStreams?N._localStreams.includes(R)||N._localStreams.push(R):N._localStreams=[R]}),w.apply(this,arguments)}}"removeStream"in v.RTCPeerConnection.prototype||(v.RTCPeerConnection.prototype.removeStream=function(L){var N=this;this._localStreams||(this._localStreams=[]);var V=this._localStreams.indexOf(L);if(V!==-1){this._localStreams.splice(V,1);var _=L.getTracks();this.getSenders().forEach(function(b){_.includes(b.track)&&N.removeTrack(b)})}})}}function u(v){if(s(v)==="object"&&v.RTCPeerConnection&&("getRemoteStreams"in v.RTCPeerConnection.prototype||(v.RTCPeerConnection.prototype.getRemoteStreams=function(){return this._remoteStreams?this._remoteStreams:[]}),!("onaddstream"in v.RTCPeerConnection.prototype))){Object.defineProperty(v.RTCPeerConnection.prototype,"onaddstream",{get:function(){return this._onaddstream},set:function(L){var N=this;this._onaddstream&&(this.removeEventListener("addstream",this._onaddstream),this.removeEventListener("track",this._onaddstreampoly)),this.addEventListener("addstream",this._onaddstream=L),this.addEventListener("track",this._onaddstreampoly=function(V){V.streams.forEach(function(_){if(N._remoteStreams||(N._remoteStreams=[]),!N._remoteStreams.includes(_)){N._remoteStreams.push(_);var b=new Event("addstream");b.stream=_,N.dispatchEvent(b)}})})}});var w=v.RTCPeerConnection.prototype.setRemoteDescription;v.RTCPeerConnection.prototype.setRemoteDescription=function(){var L=this;return this._onaddstreampoly||this.addEventListener("track",this._onaddstreampoly=function(N){N.streams.forEach(function(V){if(L._remoteStreams||(L._remoteStreams=[]),!(L._remoteStreams.indexOf(V)>=0)){L._remoteStreams.push(V);var _=new Event("addstream");_.stream=V,L.dispatchEvent(_)}})}),w.apply(L,arguments)}}}function f(v){if(s(v)==="object"&&v.RTCPeerConnection){var w=v.RTCPeerConnection.prototype,L=w.createOffer,N=w.createAnswer,V=w.setLocalDescription,_=w.setRemoteDescription,b=w.addIceCandidate;w.createOffer=function(P,U){var k=arguments.length>=2?arguments[2]:arguments[0],h=L.apply(this,[k]);return U?(h.then(P,U),Promise.resolve()):h},w.createAnswer=function(P,U){var k=arguments.length>=2?arguments[2]:arguments[0],h=N.apply(this,[k]);return U?(h.then(P,U),Promise.resolve()):h};var R=function(P,U,k){var h=V.apply(this,[P]);return k?(h.then(U,k),Promise.resolve()):h};w.setLocalDescription=R,R=function(P,U,k){var h=_.apply(this,[P]);return k?(h.then(U,k),Promise.resolve()):h},w.setRemoteDescription=R,R=function(P,U,k){var h=b.apply(this,[P]);return k?(h.then(U,k),Promise.resolve()):h},w.addIceCandidate=R}}function S(v){var w=v&&v.navigator;if(w.mediaDevices&&w.mediaDevices.getUserMedia){var L=w.mediaDevices,N=L.getUserMedia.bind(L);w.mediaDevices.getUserMedia=function(V){return N(x(V))}}!w.getUserMedia&&w.mediaDevices&&w.mediaDevices.getUserMedia&&(w.getUserMedia=function(V,_,b){w.mediaDevices.getUserMedia(V).then(_,b)}.bind(w))}function x(v){return v&&v.video!==void 0?Object.assign({},v,{video:o.compactObject(v.video)}):v}function E(v){if(v.RTCPeerConnection){var w=v.RTCPeerConnection;v.RTCPeerConnection=function(L,N){if(L&&L.iceServers){for(var V=[],_=0;_<L.iceServers.length;_++){var b=L.iceServers[_];b.urls===void 0&&b.url?(o.deprecated("RTCIceServer.url","RTCIceServer.urls"),(b=JSON.parse(JSON.stringify(b))).urls=b.url,delete b.url,V.push(b)):V.push(L.iceServers[_])}L.iceServers=V}return new w(L,N)},v.RTCPeerConnection.prototype=w.prototype,"generateCertificate"in w&&Object.defineProperty(v.RTCPeerConnection,"generateCertificate",{get:function(){return w.generateCertificate}})}}function I(v){s(v)==="object"&&v.RTCTrackEvent&&"receiver"in v.RTCTrackEvent.prototype&&!("transceiver"in v.RTCTrackEvent.prototype)&&Object.defineProperty(v.RTCTrackEvent.prototype,"transceiver",{get:function(){return{receiver:this.receiver}}})}function m(v){var w=v.RTCPeerConnection.prototype.createOffer;v.RTCPeerConnection.prototype.createOffer=function(L){if(L){L.offerToReceiveAudio!==void 0&&(L.offerToReceiveAudio=!!L.offerToReceiveAudio);var N=this.getTransceivers().find(function(_){return _.receiver.track.kind==="audio"});L.offerToReceiveAudio===!1&&N?N.direction==="sendrecv"?N.setDirection?N.setDirection("sendonly"):N.direction="sendonly":N.direction==="recvonly"&&(N.setDirection?N.setDirection("inactive"):N.direction="inactive"):L.offerToReceiveAudio!==!0||N||this.addTransceiver("audio",{direction:"recvonly"}),L.offerToReceiveVideo!==void 0&&(L.offerToReceiveVideo=!!L.offerToReceiveVideo);var V=this.getTransceivers().find(function(_){return _.receiver.track.kind==="video"});L.offerToReceiveVideo===!1&&V?V.direction==="sendrecv"?V.setDirection?V.setDirection("sendonly"):V.direction="sendonly":V.direction==="recvonly"&&(V.setDirection?V.setDirection("inactive"):V.direction="inactive"):L.offerToReceiveVideo!==!0||V||this.addTransceiver("video",{direction:"recvonly"})}return w.apply(this,arguments)}}function T(v){s(v)!=="object"||v.AudioContext||(v.AudioContext=v.webkitAudioContext)}},{"../utils":11}],11:[function(n,i,r){function o(V,_,b){return(_=c(_))in V?Object.defineProperty(V,_,{value:b,enumerable:!0,configurable:!0,writable:!0}):V[_]=b,V}function c(V){var _=a(V,"string");return s(_)==="symbol"?_:String(_)}function a(V,_){if(s(V)!=="object"||V===null)return V;var b=V[Symbol.toPrimitive];if(b!==void 0){var R=b.call(V,_||"default");if(s(R)!=="object")return R;throw new TypeError("@@toPrimitive must return a primitive value.")}return(_==="string"?String:Number)(V)}function s(V){return s=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(_){return typeof _}:function(_){return _&&typeof Symbol=="function"&&_.constructor===Symbol&&_!==Symbol.prototype?"symbol":typeof _},s(V)}Object.defineProperty(r,"__esModule",{value:!0}),r.compactObject=w,r.deprecated=m,r.detectBrowser=T,r.disableLog=x,r.disableWarnings=E,r.extractVersion=f,r.filterStats=N,r.log=I,r.walkStats=L,r.wrapPeerConnectionEvent=S;var l=!0,u=!0;function f(V,_,b){var R=V.match(_);return R&&R.length>=b&&parseInt(R[b],10)}function S(V,_,b){if(V.RTCPeerConnection){var R=V.RTCPeerConnection.prototype,P=R.addEventListener;R.addEventListener=function(k,h){if(k!==_)return P.apply(this,arguments);var y=function(A){var D=b(A);D&&(h.handleEvent?h.handleEvent(D):h(D))};return this._eventMap=this._eventMap||{},this._eventMap[_]||(this._eventMap[_]=new Map),this._eventMap[_].set(h,y),P.apply(this,[k,y])};var U=R.removeEventListener;R.removeEventListener=function(k,h){if(k!==_||!this._eventMap||!this._eventMap[_])return U.apply(this,arguments);if(!this._eventMap[_].has(h))return U.apply(this,arguments);var y=this._eventMap[_].get(h);return this._eventMap[_].delete(h),this._eventMap[_].size===0&&delete this._eventMap[_],Object.keys(this._eventMap).length===0&&delete this._eventMap,U.apply(this,[k,y])},Object.defineProperty(R,"on"+_,{get:function(){return this["_on"+_]},set:function(k){this["_on"+_]&&(this.removeEventListener(_,this["_on"+_]),delete this["_on"+_]),k&&this.addEventListener(_,this["_on"+_]=k)},enumerable:!0,configurable:!0})}}function x(V){return typeof V!="boolean"?new Error("Argument type: "+s(V)+". Please use a boolean."):(l=V,V?"adapter.js logging disabled":"adapter.js logging enabled")}function E(V){return typeof V!="boolean"?new Error("Argument type: "+s(V)+". Please use a boolean."):(u=!V,"adapter.js deprecation warnings "+(V?"disabled":"enabled"))}function I(){if((typeof window=="undefined"?"undefined":s(window))==="object"){if(l)return;typeof console!="undefined"&&typeof console.log=="function"&&console.log.apply(console,arguments)}}function m(V,_){u&&console.warn(V+" is deprecated, please use "+_+" instead.")}function T(V){var _={browser:null,version:null};if(V===void 0||!V.navigator||!V.navigator.userAgent)return _.browser="Not a browser.",_;var b=V.navigator;if(b.mozGetUserMedia)_.browser="firefox",_.version=f(b.userAgent,/Firefox\/(\d+)\./,1);else if(b.webkitGetUserMedia||V.isSecureContext===!1&&V.webkitRTCPeerConnection)_.browser="chrome",_.version=f(b.userAgent,/Chrom(e|ium)\/(\d+)\./,2);else{if(!V.RTCPeerConnection||!b.userAgent.match(/AppleWebKit\/(\d+)\./))return _.browser="Not a supported browser.",_;_.browser="safari",_.version=f(b.userAgent,/AppleWebKit\/(\d+)\./,1),_.supportsUnifiedPlan=V.RTCRtpTransceiver&&"currentDirection"in V.RTCRtpTransceiver.prototype}return _}function v(V){return Object.prototype.toString.call(V)==="[object Object]"}function w(V){return v(V)?Object.keys(V).reduce(function(_,b){var R=v(V[b]),P=R?w(V[b]):V[b],U=R&&!Object.keys(P).length;return P===void 0||U?_:Object.assign(_,o({},b,P))},{}):V}function L(V,_,b){_&&!b.has(_.id)&&(b.set(_.id,_),Object.keys(_).forEach(function(R){R.endsWith("Id")?L(V,V.get(_[R]),b):R.endsWith("Ids")&&_[R].forEach(function(P){L(V,V.get(P),b)})}))}function N(V,_,b){var R=b?"outbound-rtp":"inbound-rtp",P=new Map;if(_===null)return P;var U=[];return V.forEach(function(k){k.type==="track"&&k.trackIdentifier===_.id&&U.push(k)}),U.forEach(function(k){V.forEach(function(h){h.type===R&&h.trackId===k.id&&L(V,h,P)})}),P}},{}],12:[function(n,i,r){var o=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(a){return typeof a}:function(a){return a&&typeof Symbol=="function"&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a},c={generateIdentifier:function(){return Math.random().toString(36).substring(2,12)}};c.localCName=c.generateIdentifier(),c.splitLines=function(a){return a.trim().split(`
|
|
9
|
+
`).map(function(s){return s.trim()})},c.splitSections=function(a){return a.split(`
|
|
10
|
+
m=`).map(function(s,l){return(l>0?"m="+s:s).trim()+`\r
|
|
11
|
+
`})},c.getDescription=function(a){var s=c.splitSections(a);return s&&s[0]},c.getMediaSections=function(a){var s=c.splitSections(a);return s.shift(),s},c.matchPrefix=function(a,s){return c.splitLines(a).filter(function(l){return l.indexOf(s)===0})},c.parseCandidate=function(a){for(var s=void 0,l={foundation:(s=a.indexOf("a=candidate:")===0?a.substring(12).split(" "):a.substring(10).split(" "))[0],component:{1:"rtp",2:"rtcp"}[s[1]]||s[1],protocol:s[2].toLowerCase(),priority:parseInt(s[3],10),ip:s[4],address:s[4],port:parseInt(s[5],10),type:s[7]},u=8;u<s.length;u+=2)switch(s[u]){case"raddr":l.relatedAddress=s[u+1];break;case"rport":l.relatedPort=parseInt(s[u+1],10);break;case"tcptype":l.tcpType=s[u+1];break;case"ufrag":l.ufrag=s[u+1],l.usernameFragment=s[u+1];break;default:l[s[u]]===void 0&&(l[s[u]]=s[u+1])}return l},c.writeCandidate=function(a){var s=[];s.push(a.foundation);var l=a.component;l==="rtp"?s.push(1):l==="rtcp"?s.push(2):s.push(l),s.push(a.protocol.toUpperCase()),s.push(a.priority),s.push(a.address||a.ip),s.push(a.port);var u=a.type;return s.push("typ"),s.push(u),u!=="host"&&a.relatedAddress&&a.relatedPort&&(s.push("raddr"),s.push(a.relatedAddress),s.push("rport"),s.push(a.relatedPort)),a.tcpType&&a.protocol.toLowerCase()==="tcp"&&(s.push("tcptype"),s.push(a.tcpType)),(a.usernameFragment||a.ufrag)&&(s.push("ufrag"),s.push(a.usernameFragment||a.ufrag)),"candidate:"+s.join(" ")},c.parseIceOptions=function(a){return a.substring(14).split(" ")},c.parseRtpMap=function(a){var s=a.substring(9).split(" "),l={payloadType:parseInt(s.shift(),10)};return s=s[0].split("/"),l.name=s[0],l.clockRate=parseInt(s[1],10),l.channels=s.length===3?parseInt(s[2],10):1,l.numChannels=l.channels,l},c.writeRtpMap=function(a){var s=a.payloadType;a.preferredPayloadType!==void 0&&(s=a.preferredPayloadType);var l=a.channels||a.numChannels||1;return"a=rtpmap:"+s+" "+a.name+"/"+a.clockRate+(l!==1?"/"+l:"")+`\r
|
|
12
|
+
`},c.parseExtmap=function(a){var s=a.substring(9).split(" ");return{id:parseInt(s[0],10),direction:s[0].indexOf("/")>0?s[0].split("/")[1]:"sendrecv",uri:s[1],attributes:s.slice(2).join(" ")}},c.writeExtmap=function(a){return"a=extmap:"+(a.id||a.preferredId)+(a.direction&&a.direction!=="sendrecv"?"/"+a.direction:"")+" "+a.uri+(a.attributes?" "+a.attributes:"")+`\r
|
|
13
|
+
`},c.parseFmtp=function(a){for(var s={},l=void 0,u=a.substring(a.indexOf(" ")+1).split(";"),f=0;f<u.length;f++)s[(l=u[f].trim().split("="))[0].trim()]=l[1];return s},c.writeFmtp=function(a){var s="",l=a.payloadType;if(a.preferredPayloadType!==void 0&&(l=a.preferredPayloadType),a.parameters&&Object.keys(a.parameters).length){var u=[];Object.keys(a.parameters).forEach(function(f){a.parameters[f]!==void 0?u.push(f+"="+a.parameters[f]):u.push(f)}),s+="a=fmtp:"+l+" "+u.join(";")+`\r
|
|
14
|
+
`}return s},c.parseRtcpFb=function(a){var s=a.substring(a.indexOf(" ")+1).split(" ");return{type:s.shift(),parameter:s.join(" ")}},c.writeRtcpFb=function(a){var s="",l=a.payloadType;return a.preferredPayloadType!==void 0&&(l=a.preferredPayloadType),a.rtcpFeedback&&a.rtcpFeedback.length&&a.rtcpFeedback.forEach(function(u){s+="a=rtcp-fb:"+l+" "+u.type+(u.parameter&&u.parameter.length?" "+u.parameter:"")+`\r
|
|
15
|
+
`}),s},c.parseSsrcMedia=function(a){var s=a.indexOf(" "),l={ssrc:parseInt(a.substring(7,s),10)},u=a.indexOf(":",s);return u>-1?(l.attribute=a.substring(s+1,u),l.value=a.substring(u+1)):l.attribute=a.substring(s+1),l},c.parseSsrcGroup=function(a){var s=a.substring(13).split(" ");return{semantics:s.shift(),ssrcs:s.map(function(l){return parseInt(l,10)})}},c.getMid=function(a){var s=c.matchPrefix(a,"a=mid:")[0];if(s)return s.substring(6)},c.parseFingerprint=function(a){var s=a.substring(14).split(" ");return{algorithm:s[0].toLowerCase(),value:s[1].toUpperCase()}},c.getDtlsParameters=function(a,s){return{role:"auto",fingerprints:c.matchPrefix(a+s,"a=fingerprint:").map(c.parseFingerprint)}},c.writeDtlsParameters=function(a,s){var l="a=setup:"+s+`\r
|
|
16
|
+
`;return a.fingerprints.forEach(function(u){l+="a=fingerprint:"+u.algorithm+" "+u.value+`\r
|
|
17
|
+
`}),l},c.parseCryptoLine=function(a){var s=a.substring(9).split(" ");return{tag:parseInt(s[0],10),cryptoSuite:s[1],keyParams:s[2],sessionParams:s.slice(3)}},c.writeCryptoLine=function(a){return"a=crypto:"+a.tag+" "+a.cryptoSuite+" "+(o(a.keyParams)==="object"?c.writeCryptoKeyParams(a.keyParams):a.keyParams)+(a.sessionParams?" "+a.sessionParams.join(" "):"")+`\r
|
|
18
|
+
`},c.parseCryptoKeyParams=function(a){if(a.indexOf("inline:")!==0)return null;var s=a.substring(7).split("|");return{keyMethod:"inline",keySalt:s[0],lifeTime:s[1],mkiValue:s[2]?s[2].split(":")[0]:void 0,mkiLength:s[2]?s[2].split(":")[1]:void 0}},c.writeCryptoKeyParams=function(a){return a.keyMethod+":"+a.keySalt+(a.lifeTime?"|"+a.lifeTime:"")+(a.mkiValue&&a.mkiLength?"|"+a.mkiValue+":"+a.mkiLength:"")},c.getCryptoParameters=function(a,s){return c.matchPrefix(a+s,"a=crypto:").map(c.parseCryptoLine)},c.getIceParameters=function(a,s){var l=c.matchPrefix(a+s,"a=ice-ufrag:")[0],u=c.matchPrefix(a+s,"a=ice-pwd:")[0];return l&&u?{usernameFragment:l.substring(12),password:u.substring(10)}:null},c.writeIceParameters=function(a){var s="a=ice-ufrag:"+a.usernameFragment+`\r
|
|
19
|
+
a=ice-pwd:`+a.password+`\r
|
|
20
|
+
`;return a.iceLite&&(s+=`a=ice-lite\r
|
|
21
|
+
`),s},c.parseRtpParameters=function(a){var s={codecs:[],headerExtensions:[],fecMechanisms:[],rtcp:[]},l=c.splitLines(a)[0].split(" ");s.profile=l[2];for(var u=3;u<l.length;u++){var f=l[u],S=c.matchPrefix(a,"a=rtpmap:"+f+" ")[0];if(S){var x=c.parseRtpMap(S),E=c.matchPrefix(a,"a=fmtp:"+f+" ");switch(x.parameters=E.length?c.parseFmtp(E[0]):{},x.rtcpFeedback=c.matchPrefix(a,"a=rtcp-fb:"+f+" ").map(c.parseRtcpFb),s.codecs.push(x),x.name.toUpperCase()){case"RED":case"ULPFEC":s.fecMechanisms.push(x.name.toUpperCase())}}}c.matchPrefix(a,"a=extmap:").forEach(function(m){s.headerExtensions.push(c.parseExtmap(m))});var I=c.matchPrefix(a,"a=rtcp-fb:* ").map(c.parseRtcpFb);return s.codecs.forEach(function(m){I.forEach(function(T){m.rtcpFeedback.find(function(v){return v.type===T.type&&v.parameter===T.parameter})||m.rtcpFeedback.push(T)})}),s},c.writeRtpDescription=function(a,s){var l="";l+="m="+a+" ",l+=s.codecs.length>0?"9":"0",l+=" "+(s.profile||"UDP/TLS/RTP/SAVPF")+" ",l+=s.codecs.map(function(f){return f.preferredPayloadType!==void 0?f.preferredPayloadType:f.payloadType}).join(" ")+`\r
|
|
22
|
+
`,l+=`c=IN IP4 0.0.0.0\r
|
|
23
|
+
`,l+=`a=rtcp:9 IN IP4 0.0.0.0\r
|
|
24
|
+
`,s.codecs.forEach(function(f){l+=c.writeRtpMap(f),l+=c.writeFmtp(f),l+=c.writeRtcpFb(f)});var u=0;return s.codecs.forEach(function(f){f.maxptime>u&&(u=f.maxptime)}),u>0&&(l+="a=maxptime:"+u+`\r
|
|
25
|
+
`),s.headerExtensions&&s.headerExtensions.forEach(function(f){l+=c.writeExtmap(f)}),l},c.parseRtpEncodingParameters=function(a){var s=[],l=c.parseRtpParameters(a),u=l.fecMechanisms.indexOf("RED")!==-1,f=l.fecMechanisms.indexOf("ULPFEC")!==-1,S=c.matchPrefix(a,"a=ssrc:").map(function(T){return c.parseSsrcMedia(T)}).filter(function(T){return T.attribute==="cname"}),x=S.length>0&&S[0].ssrc,E=void 0,I=c.matchPrefix(a,"a=ssrc-group:FID").map(function(T){return T.substring(17).split(" ").map(function(v){return parseInt(v,10)})});I.length>0&&I[0].length>1&&I[0][0]===x&&(E=I[0][1]),l.codecs.forEach(function(T){if(T.name.toUpperCase()==="RTX"&&T.parameters.apt){var v={ssrc:x,codecPayloadType:parseInt(T.parameters.apt,10)};x&&E&&(v.rtx={ssrc:E}),s.push(v),u&&((v=JSON.parse(JSON.stringify(v))).fec={ssrc:x,mechanism:f?"red+ulpfec":"red"},s.push(v))}}),s.length===0&&x&&s.push({ssrc:x});var m=c.matchPrefix(a,"b=");return m.length&&(m=m[0].indexOf("b=TIAS:")===0?parseInt(m[0].substring(7),10):m[0].indexOf("b=AS:")===0?1e3*parseInt(m[0].substring(5),10)*.95-16e3:void 0,s.forEach(function(T){T.maxBitrate=m})),s},c.parseRtcpParameters=function(a){var s={},l=c.matchPrefix(a,"a=ssrc:").map(function(S){return c.parseSsrcMedia(S)}).filter(function(S){return S.attribute==="cname"})[0];l&&(s.cname=l.value,s.ssrc=l.ssrc);var u=c.matchPrefix(a,"a=rtcp-rsize");s.reducedSize=u.length>0,s.compound=u.length===0;var f=c.matchPrefix(a,"a=rtcp-mux");return s.mux=f.length>0,s},c.writeRtcpParameters=function(a){var s="";return a.reducedSize&&(s+=`a=rtcp-rsize\r
|
|
26
|
+
`),a.mux&&(s+=`a=rtcp-mux\r
|
|
27
|
+
`),a.ssrc!==void 0&&a.cname&&(s+="a=ssrc:"+a.ssrc+" cname:"+a.cname+`\r
|
|
28
|
+
`),s},c.parseMsid=function(a){var s=void 0,l=c.matchPrefix(a,"a=msid:");if(l.length===1)return{stream:(s=l[0].substring(7).split(" "))[0],track:s[1]};var u=c.matchPrefix(a,"a=ssrc:").map(function(f){return c.parseSsrcMedia(f)}).filter(function(f){return f.attribute==="msid"});return u.length>0?{stream:(s=u[0].value.split(" "))[0],track:s[1]}:void 0},c.parseSctpDescription=function(a){var s=c.parseMLine(a),l=c.matchPrefix(a,"a=max-message-size:"),u=void 0;l.length>0&&(u=parseInt(l[0].substring(19),10)),isNaN(u)&&(u=65536);var f=c.matchPrefix(a,"a=sctp-port:");if(f.length>0)return{port:parseInt(f[0].substring(12),10),protocol:s.fmt,maxMessageSize:u};var S=c.matchPrefix(a,"a=sctpmap:");if(S.length>0){var x=S[0].substring(10).split(" ");return{port:parseInt(x[0],10),protocol:x[1],maxMessageSize:u}}},c.writeSctpDescription=function(a,s){var l=[];return l=a.protocol!=="DTLS/SCTP"?["m="+a.kind+" 9 "+a.protocol+" "+s.protocol+`\r
|
|
55
29
|
`,`c=IN IP4 0.0.0.0\r
|
|
56
30
|
`,"a=sctp-port:"+s.port+`\r
|
|
57
|
-
`]:["m="+
|
|
31
|
+
`]:["m="+a.kind+" 9 "+a.protocol+" "+s.port+`\r
|
|
58
32
|
`,`c=IN IP4 0.0.0.0\r
|
|
59
33
|
`,"a=sctpmap:"+s.port+" "+s.protocol+` 65535\r
|
|
60
|
-
`],s.maxMessageSize!==void 0&&
|
|
61
|
-
`),
|
|
62
|
-
o=`+(
|
|
34
|
+
`],s.maxMessageSize!==void 0&&l.push("a=max-message-size:"+s.maxMessageSize+`\r
|
|
35
|
+
`),l.join("")},c.generateSessionId=function(){return Math.random().toString().substr(2,22)},c.writeSessionBoilerplate=function(a,s,l){var u=s!==void 0?s:2;return`v=0\r
|
|
36
|
+
o=`+(l||"thisisadapterortc")+" "+(a||c.generateSessionId())+" "+u+` IN IP4 127.0.0.1\r
|
|
63
37
|
s=-\r
|
|
64
38
|
t=0 0\r
|
|
65
|
-
`},r.writeMediaSection=function(o,s,c,u){var d=r.writeRtpDescription(o.kind,s);if(d+=r.writeIceParameters(o.iceGatherer.getLocalParameters()),d+=r.writeDtlsParameters(o.dtlsTransport.getLocalParameters(),c==="offer"?"actpass":"active"),d+="a=mid:"+o.mid+`\r
|
|
66
|
-
|
|
67
|
-
`:o.rtpSender&&o.rtpReceiver?d+=`a=sendrecv\r
|
|
68
|
-
|
|
69
|
-
`:o.rtpReceiver?d+=`a=recvonly\r
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
`;d+="a="+g,d+="a=ssrc:"+o.sendEncodingParameters[0].ssrc+" "+g,o.sendEncodingParameters[0].rtx&&(d+="a=ssrc:"+o.sendEncodingParameters[0].rtx.ssrc+" "+g,d+="a=ssrc-group:FID "+o.sendEncodingParameters[0].ssrc+" "+o.sendEncodingParameters[0].rtx.ssrc+`\r
|
|
73
|
-
`)}return d+="a=ssrc:"+o.sendEncodingParameters[0].ssrc+" cname:"+r.localCName+`\r
|
|
74
|
-
`,o.rtpSender&&o.sendEncodingParameters[0].rtx&&(d+="a=ssrc:"+o.sendEncodingParameters[0].rtx.ssrc+" cname:"+r.localCName+`\r
|
|
75
|
-
`),d},r.getDirection=function(o,s){for(var c=r.splitLines(o),u=0;u<c.length;u++)switch(c[u]){case"a=sendrecv":case"a=sendonly":case"a=recvonly":case"a=inactive":return c[u].substr(2)}return s?r.getDirection(s):"sendrecv"},r.getKind=function(o){return r.splitLines(o)[0].split(" ")[0].substr(2)},r.isRejected=function(o){return o.split(" ",2)[1]==="0"},r.parseMLine=function(o){var s=r.splitLines(o)[0].substr(2).split(" ");return{kind:s[0],port:parseInt(s[1],10),protocol:s[2],fmt:s.slice(3).join(" ")}},r.parseOLine=function(o){var s=r.matchPrefix(o,"o=")[0].substr(2).split(" ");return{username:s[0],sessionId:s[1],sessionVersion:parseInt(s[2],10),netType:s[3],addressType:s[4],address:s[5]}},r.isValidSDP=function(o){if(typeof o!="string"||o.length===0)return!1;for(var s=r.splitLines(o),c=0;c<s.length;c++)if(s[c].length<2||s[c].charAt(1)!=="=")return!1;return!0},typeof a=="object"&&(a.exports=r)},{}]},{},[1])(1)}({exports:{}});var pi="4.15.15-beta.1",Tg={},SE=yg,kE=qd,lu=Object.keys||function(e){return SE(e,kE)},TE=Se,xE=Ba,IE=At,wE=yt,EE=pn,CE=lu;Tg.f=TE&&!xE?Object.defineProperties:function(e,t){wE(e);for(var n,a=EE(t),i=CE(t),r=i.length,o=0;r>o;)IE.f(e,n=i[o++],a[n]);return e};var du,xg=fn("document","documentElement"),RE=yt,AE=Tg,Ig=qd,PE=pe,DE=xg,LE=ja,wg=Z("IE_PROTO"),Qd=function(){},Eg=function(e){return"<script>"+e+"<\/script>"},Cg=function(e){e.write(Eg("")),e.close();var t=e.parentWindow.Object;return e=null,t},hu=function(){try{du=new ActiveXObject("htmlfile")}catch(a){}var e,t;hu=typeof document!="undefined"?document.domain&&du?Cg(du):((t=LE("iframe")).style.display="none",DE.appendChild(t),t.src=String("javascript:"),(e=t.contentWindow.document).open(),e.write(Eg("document.F=Object")),e.close(),e.F):Cg(du);for(var n=Ig.length;n--;)delete hu.prototype[Ig[n]];return hu()};PE[wg]=!0;var qa=Object.create||function(e,t){var n;return e!==null?(Qd.prototype=RE(e),n=new Qd,Qd.prototype=null,n[wg]=e):n=hu(),t===void 0?n:AE.f(n,t)},OE=at,ME=qa,NE=At.f,Yd=OE("unscopables"),$d=Array.prototype;$d[Yd]==null&&NE($d,Yd,{configurable:!0,value:ME(null)});var Zi,Rg,Ag,pu=function(e){$d[Yd][e]=!0},Rs={},Pg=!ce(function(){function e(){}return e.prototype.constructor=null,Object.getPrototypeOf(new e)!==e.prototype}),UE=rt,VE=tt,jE=Ut,BE=Pg,Dg=Z("IE_PROTO"),Zd=Object,FE=Zd.prototype,As=BE?Zd.getPrototypeOf:function(e){var t=jE(e);if(UE(t,Dg))return t[Dg];var n=t.constructor;return VE(n)&&t instanceof n?n.prototype:t instanceof Zd?FE:null},GE=ce,HE=tt,zE=vt,Lg=As,WE=qt,eh=at("iterator"),Og=!1;[].keys&&("next"in(Ag=[].keys())?(Rg=Lg(Lg(Ag)))!==Object.prototype&&(Zi=Rg):Og=!0);var qE=!zE(Zi)||GE(function(){var e={};return Zi[eh].call(e)!==e});qE&&(Zi={}),HE(Zi[eh])||WE(Zi,eh,function(){return this});var th={IteratorPrototype:Zi,BUGGY_SAFARI_ITERATORS:Og},JE=At.f,KE=rt,Mg=at("toStringTag"),ea=function(e,t,n){e&&!n&&(e=e.prototype),e&&!KE(e,Mg)&&JE(e,Mg,{configurable:!0,value:t})},XE=th.IteratorPrototype,QE=qa,YE=Rt,$E=ea,ZE=Rs,eC=function(){return this},Ng=function(e,t,n,a){var i=t+" Iterator";return e.prototype=QE(XE,{next:YE(+!a,n)}),$E(e,i,!1),ZE[i]=eC,e},tC=tt,nC=String,rC=TypeError,iC=ke,aC=yt,oC=function(e){if(typeof e=="object"||tC(e))return e;throw rC("Can't set "+nC(e)+" as a prototype")},Ja=Object.setPrototypeOf||("__proto__"in{}?function(){var e,t=!1,n={};try{(e=iC(Object.getOwnPropertyDescriptor(Object.prototype,"__proto__").set))(n,[]),t=n instanceof Array}catch(a){}return function(a,i){return aC(a),oC(i),t?e(a,i):a.__proto__=i,a}}():void 0),sC=Ue,cC=Ke,uC=tt,lC=Ng,Ug=As,Vg=Ja,dC=ea,hC=gn,nh=qt,pC=Rs,fC=Ur.PROPER,mC=Ur.CONFIGURABLE,jg=th.IteratorPrototype,fu=th.BUGGY_SAFARI_ITERATORS,Ps=at("iterator"),Bg="keys",Ds="values",Fg="entries",vC=function(){return this},rh=function(e,t,n,a,i,r,o){lC(n,t,a);var s,c,u,d=function(v){if(v===i&&A)return A;if(!fu&&v in k)return k[v];switch(v){case Bg:case Ds:case Fg:return function(){return new n(this,v)}}return function(){return new n(this)}},g=t+" Iterator",I=!1,k=e.prototype,w=k[Ps]||k["@@iterator"]||i&&k[i],A=!fu&&w||d(i),p=t=="Array"&&k.entries||w;if(p&&(s=Ug(p.call(new e)))!==Object.prototype&&s.next&&(Ug(s)!==jg&&(Vg?Vg(s,jg):uC(s[Ps])||nh(s,Ps,vC)),dC(s,g,!0)),fC&&i==Ds&&w&&w.name!==Ds&&(mC?hC(k,"name",Ds):(I=!0,A=function(){return cC(w,this)})),i)if(c={values:d(Ds),keys:r?A:d(Bg),entries:d(Fg)},o)for(u in c)(fu||I||!(u in k))&&nh(k,u,c[u]);else sC({target:t,proto:!0,forced:fu||I},c);return k[Ps]!==A&&nh(k,Ps,A,{name:i}),pC[t]=A,c},ih=function(e,t){return{value:e,done:t}},gC=pn,ah=pu,Gg=Rs,Hg=st,_C=At.f,yC=rh,zg=ih,bC=Se,Wg="Array Iterator",SC=Hg.set,kC=Hg.getterFor(Wg),qg=yC(Array,"Array",function(e,t){SC(this,{type:Wg,target:gC(e),index:0,kind:t})},function(){var e=kC(this),t=e.target,n=e.kind,a=e.index++;return!t||a>=t.length?(e.target=void 0,zg(void 0,!0)):zg(n=="keys"?a:n=="values"?t[a]:[a,t[a]],!1)},"values"),Jg=Gg.Arguments=Gg.Array;if(ah("keys"),ah("values"),ah("entries"),bC&&Jg.name!=="values")try{_C(Jg,"name",{value:"values"})}catch(e){}var Kg={};Kg[at("toStringTag")]="z";var oh=String(Kg)==="[object z]",TC=oh,xC=tt,mu=ht,IC=at("toStringTag"),wC=Object,EC=mu(function(){return arguments}())=="Arguments",jr=TC?mu:function(e){var t,n,a;return e===void 0?"Undefined":e===null?"Null":typeof(n=function(i,r){try{return i[r]}catch(o){}}(t=wC(e),IC))=="string"?n:EC?mu(t):(a=mu(t))=="Object"&&xC(t.callee)?"Arguments":a},CC=jr,RC=oh?{}.toString:function(){return"[object "+CC(this)+"]"};oh||qt(Object.prototype,"toString",RC,{unsafe:!0});var Ls={exports:{}},sh={},AC=Va,PC=At,DC=Rt,Os=function(e,t,n){var a=AC(t);a in e?PC.f(e,a,DC(0,n)):e[a]=n},Xg=hi,LC=nn,OC=Os,MC=Array,NC=Math.max,vu=function(e,t,n){for(var a=LC(e),i=Xg(t,a),r=Xg(n===void 0?a:n,a),o=MC(NC(r-i,0)),s=0;i<r;i++,s++)OC(o,s,e[i]);return o.length=s,o},UC=ht,VC=pn,Qg=di.f,jC=vu,Yg=typeof window=="object"&&window&&Object.getOwnPropertyNames?Object.getOwnPropertyNames(window):[];sh.f=function(e){return Yg&&UC(e)=="Window"?function(t){try{return Qg(t)}catch(n){return jC(Yg)}}(e):Qg(VC(e))};var BC=ce(function(){if(typeof ArrayBuffer=="function"){var e=new ArrayBuffer(8);Object.isExtensible(e)&&Object.defineProperty(e,"a",{value:8})}}),FC=ce,GC=vt,HC=ht,$g=BC,gu=Object.isExtensible,Zg=FC(function(){gu(1)})||$g?function(e){return!!GC(e)&&(!$g||HC(e)!="ArrayBuffer")&&(!gu||gu(e))}:gu,zC=!ce(function(){return Object.isExtensible(Object.preventExtensions({}))}),WC=Ue,qC=ke,JC=pe,KC=vt,ch=rt,XC=At.f,e_=di,QC=sh,uh=Zg,YC=zC,t_=!1,Br=ci("meta"),$C=0,lh=function(e){XC(e,Br,{value:{objectID:"O"+$C++,weakData:{}}})},ZC=Ls.exports={enable:function(){ZC.enable=function(){},t_=!0;var e=e_.f,t=qC([].splice),n={};n[Br]=1,e(n).length&&(e_.f=function(a){for(var i=e(a),r=0,o=i.length;r<o;r++)if(i[r]===Br){t(i,r,1);break}return i},WC({target:"Object",stat:!0,forced:!0},{getOwnPropertyNames:QC.f}))},fastKey:function(e,t){if(!KC(e))return typeof e=="symbol"?e:(typeof e=="string"?"S":"P")+e;if(!ch(e,Br)){if(!uh(e))return"F";if(!t)return"E";lh(e)}return e[Br].objectID},getWeakData:function(e,t){if(!ch(e,Br)){if(!uh(e))return!0;if(!t)return!1;lh(e)}return e[Br].weakData},onFreeze:function(e){return YC&&t_&&uh(e)&&!ch(e,Br)&&lh(e),e}};JC[Br]=!0;var eR=vn,tR=Dt,nR=ke(ke.bind),Fr=function(e,t){return eR(e),t===void 0?e:tR?nR(e,t):function(){return e.apply(t,arguments)}},rR=Rs,iR=at("iterator"),aR=Array.prototype,dh=function(e){return e!==void 0&&(rR.Array===e||aR[iR]===e)},oR=jr,n_=hr,sR=Dn,cR=Rs,uR=at("iterator"),Ms=function(e){if(!sR(e))return n_(e,uR)||n_(e,"@@iterator")||cR[oR(e)]},lR=Ke,dR=vn,hR=yt,pR=ai,fR=Ms,mR=TypeError,_u=function(e,t){var n=arguments.length<2?fR(e):t;if(dR(n))return hR(lR(n,e));throw mR(pR(e)+" is not iterable")},vR=Ke,r_=yt,gR=hr,i_=function(e,t,n){var a,i;r_(e);try{if(!(a=gR(e,"return"))){if(t==="throw")throw n;return n}a=vR(a,e)}catch(r){i=!0,a=r}if(t==="throw")throw n;if(i)throw a;return r_(a),n},_R=Fr,yR=Ke,bR=yt,SR=ai,kR=dh,TR=nn,a_=dr,xR=_u,IR=Ms,o_=i_,wR=TypeError,yu=function(e,t){this.stopped=e,this.result=t},s_=yu.prototype,Ns=function(e,t,n){var a,i,r,o,s,c,u,d=n&&n.that,g=!(!n||!n.AS_ENTRIES),I=!(!n||!n.IS_RECORD),k=!(!n||!n.IS_ITERATOR),w=!(!n||!n.INTERRUPTED),A=_R(t,d),p=function(y){return a&&o_(a,"normal",y),new yu(!0,y)},v=function(y){return g?(bR(y),w?A(y[0],y[1],p):A(y[0],y[1])):w?A(y,p):A(y)};if(I)a=e.iterator;else if(k)a=e;else{if(!(i=IR(e)))throw wR(SR(e)+" is not iterable");if(kR(i)){for(r=0,o=TR(e);o>r;r++)if((s=v(e[r]))&&a_(s_,s))return s;return new yu(!1)}a=xR(e,i)}for(c=I?e.next:a.next;!(u=yR(c,a)).done;){try{s=v(u.value)}catch(y){o_(a,"throw",y)}if(typeof s=="object"&&s&&a_(s_,s))return s}return new yu(!1)},ER=dr,CR=TypeError,fi=function(e,t){if(ER(t,e))return e;throw CR("Incorrect invocation")},c_=at("iterator"),u_=!1;try{var RR=0,l_={next:function(){return{done:!!RR++}},return:function(){u_=!0}};l_[c_]=function(){return this},Array.from(l_,function(){throw 2})}catch(e){}var bu=function(e,t){if(!t&&!u_)return!1;var n=!1;try{var a={};a[c_]=function(){return{next:function(){return{done:n=!0}}}},e(a)}catch(i){}return n},AR=tt,PR=vt,d_=Ja,Su=function(e,t,n){var a,i;return d_&&AR(a=t.constructor)&&a!==n&&PR(i=a.prototype)&&i!==n.prototype&&d_(e,i),e},DR=Ue,LR=se,OR=ke,h_=Cs,MR=qt,NR=Ls.exports,UR=Ns,VR=fi,jR=tt,BR=Dn,hh=vt,ph=ce,FR=bu,GR=ea,HR=Su,fh=function(e,t,n){var a=e.indexOf("Map")!==-1,i=e.indexOf("Weak")!==-1,r=a?"set":"add",o=LR[e],s=o&&o.prototype,c=o,u={},d=function(p){var v=OR(s[p]);MR(s,p,p=="add"?function(y){return v(this,y===0?0:y),this}:p=="delete"?function(y){return!(i&&!hh(y))&&v(this,y===0?0:y)}:p=="get"?function(y){return i&&!hh(y)?void 0:v(this,y===0?0:y)}:p=="has"?function(y){return!(i&&!hh(y))&&v(this,y===0?0:y)}:function(y,L){return v(this,y===0?0:y,L),this})};if(h_(e,!jR(o)||!(i||s.forEach&&!ph(function(){new o().entries().next()}))))c=n.getConstructor(t,e,a,r),NR.enable();else if(h_(e,!0)){var g=new c,I=g[r](i?{}:-0,1)!=g,k=ph(function(){g.has(1)}),w=FR(function(p){new o(p)}),A=!i&&ph(function(){for(var p=new o,v=5;v--;)p[r](v,v);return!p.has(-0)});w||((c=t(function(p,v){VR(p,s);var y=HR(new o,p,c);return BR(v)||UR(v,y[r],{that:y,AS_ENTRIES:a}),y})).prototype=s,s.constructor=c),(k||A)&&(d("delete"),d("has"),a&&d("get")),(A||I)&&d(r),i&&s.clear&&delete s.clear}return u[e]=c,DR({global:!0,constructor:!0,forced:c!=o},u),GR(c,e),i||n.setStrong(c,e,a),c},zR=qt,Us=function(e,t,n){for(var a in t)zR(e,a,t[a],n);return e},WR=fn,qR=At,JR=Se,p_=at("species"),Vs=function(e){var t=WR(e),n=qR.f;JR&&t&&!t[p_]&&n(t,p_,{configurable:!0,get:function(){return this}})},KR=At.f,XR=qa,f_=Us,QR=Fr,YR=fi,$R=Dn,ZR=Ns,eA=rh,m_=ih,tA=Vs,js=Se,v_=Ls.exports.fastKey,g_=st.set,mh=st.getterFor,__={getConstructor:function(e,t,n,a){var i=e(function(u,d){YR(u,r),g_(u,{type:t,index:XR(null),first:void 0,last:void 0,size:0}),js||(u.size=0),$R(d)||ZR(d,u[a],{that:u,AS_ENTRIES:n})}),r=i.prototype,o=mh(t),s=function(u,d,g){var I,k,w=o(u),A=c(u,d);return A?A.value=g:(w.last=A={index:k=v_(d,!0),key:d,value:g,previous:I=w.last,next:void 0,removed:!1},w.first||(w.first=A),I&&(I.next=A),js?w.size++:u.size++,k!=="F"&&(w.index[k]=A)),u},c=function(u,d){var g,I=o(u),k=v_(d);if(k!=="F")return I.index[k];for(g=I.first;g;g=g.next)if(g.key==d)return g};return f_(r,{clear:function(){for(var u=o(this),d=u.index,g=u.first;g;)g.removed=!0,g.previous&&(g.previous=g.previous.next=void 0),delete d[g.index],g=g.next;u.first=u.last=void 0,js?u.size=0:this.size=0},delete:function(u){var d=this,g=o(d),I=c(d,u);if(I){var k=I.next,w=I.previous;delete g.index[I.index],I.removed=!0,w&&(w.next=k),k&&(k.previous=w),g.first==I&&(g.first=k),g.last==I&&(g.last=w),js?g.size--:d.size--}return!!I},forEach:function(u){for(var d,g=o(this),I=QR(u,arguments.length>1?arguments[1]:void 0);d=d?d.next:g.first;)for(I(d.value,d.key,this);d&&d.removed;)d=d.previous},has:function(u){return!!c(this,u)}}),f_(r,n?{get:function(u){var d=c(this,u);return d&&d.value},set:function(u,d){return s(this,u===0?0:u,d)}}:{add:function(u){return s(this,u=u===0?0:u,u)}}),js&&KR(r,"size",{get:function(){return o(this).size}}),i},setStrong:function(e,t,n){var a=t+" Iterator",i=mh(t),r=mh(a);eA(e,t,function(o,s){g_(this,{type:a,target:o,state:i(o),kind:s,last:void 0})},function(){for(var o=r(this),s=o.kind,c=o.last;c&&c.removed;)c=c.previous;return o.target&&(o.last=c=c?c.next:o.state.first)?m_(s=="keys"?c.key:s=="values"?c.value:[c.key,c.value],!1):(o.target=void 0,m_(void 0,!0))},n?"entries":"values",!n,!0),tA(t)}};fh("Set",function(e){return function(){return e(this,arguments.length?arguments[0]:void 0)}},__);var nA=jr,rA=String,Ft=function(e){if(nA(e)==="Symbol")throw TypeError("Cannot convert a Symbol value to a string");return rA(e)},vh=ke,iA=Yn,aA=Ft,oA=en,sA=vh("".charAt),y_=vh("".charCodeAt),cA=vh("".slice),b_=function(e){return function(t,n){var a,i,r=aA(oA(t)),o=iA(n),s=r.length;return o<0||o>=s?e?"":void 0:(a=y_(r,o))<55296||a>56319||o+1===s||(i=y_(r,o+1))<56320||i>57343?e?sA(r,o):a:e?cA(r,o,o+2):i-56320+(a-55296<<10)+65536}},gh={codeAt:b_(!1),charAt:b_(!0)},uA=gh.charAt,lA=Ft,S_=st,dA=rh,k_=ih,T_="String Iterator",hA=S_.set,pA=S_.getterFor(T_);dA(String,"String",function(e){hA(this,{type:T_,string:lA(e),index:0})},function(){var e,t=pA(this),n=t.string,a=t.index;return a>=n.length?k_(void 0,!0):(e=uA(n,a),t.index+=e.length,k_(e,!1))});var x_={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},_h=ja("span").classList,I_=_h&&_h.constructor&&_h.constructor.prototype,w_=I_===Object.prototype?void 0:I_,E_=se,C_=x_,fA=w_,Bs=qg,yh=gn,R_=at,bh=R_("iterator"),A_=R_("toStringTag"),Sh=Bs.values,P_=function(e,t){if(e){if(e[bh]!==Sh)try{yh(e,bh,Sh)}catch(a){e[bh]=Sh}if(e[A_]||yh(e,A_,t),C_[t]){for(var n in Bs)if(e[n]!==Bs[n])try{yh(e,n,Bs[n])}catch(a){e[n]=Bs[n]}}}};for(var kh in C_)P_(E_[kh]&&E_[kh].prototype,kh);P_(fA,"DOMTokenList");var mA=Dt,D_=Function.prototype,L_=D_.apply,O_=D_.call,ta=typeof Reflect=="object"&&Reflect.apply||(mA?O_.bind(L_):function(){return O_.apply(L_,arguments)}),Ka=ke([].slice),vA=TypeError,ku=function(e,t){if(e<t)throw vA("Not enough arguments");return e},Th=se,gA=ta,_A=tt,yA=Ka,bA=ku,SA=/MSIE .\./.test(Xn),kA=Th.Function,M_=function(e){return SA?function(t,n){var a=bA(arguments.length,1)>2,i=_A(t)?t:kA(t),r=a?yA(arguments,2):void 0;return e(a?function(){gA(i,this,r)}:i,n)}:e},N_={setTimeout:M_(Th.setTimeout),setInterval:M_(Th.setInterval)},U_=N_.setInterval;Ue({global:!0,bind:!0,forced:se.setInterval!==U_},{setInterval:U_});var V_=N_.setTimeout;Ue({global:!0,bind:!0,forced:se.setTimeout!==V_},{setTimeout:V_}),fh("Map",function(e){return function(){return e(this,arguments.length?arguments[0]:void 0)}},__);var TA=ht,Xa=Array.isArray||function(e){return TA(e)=="Array"},xA=ke,IA=ce,j_=tt,wA=jr,EA=_,B_=function(){},CA=[],F_=fn("Reflect","construct"),xh=/^\s*(?:class|function)\b/,RA=xA(xh.exec),AA=!xh.exec(B_),Fs=function(e){if(!j_(e))return!1;try{return F_(B_,CA,e),!0}catch(t){return!1}},G_=function(e){if(!j_(e))return!1;switch(wA(e)){case"AsyncFunction":case"GeneratorFunction":case"AsyncGeneratorFunction":return!1}try{return AA||!!RA(xh,EA(e))}catch(t){return!0}};G_.sham=!0;var Tu=!F_||IA(function(){var e;return Fs(Fs.call)||!Fs(Object)||!Fs(function(){e=!0})||e})?G_:Fs,H_=Xa,PA=Tu,DA=vt,LA=at("species"),z_=Array,OA=function(e){var t;return H_(e)&&(t=e.constructor,(PA(t)&&(t===z_||H_(t.prototype))||DA(t)&&(t=t[LA])===null)&&(t=void 0)),t===void 0?z_:t},Ih=function(e,t){return new(OA(e))(t===0?0:t)},MA=Fr,NA=zt,UA=Ut,VA=nn,jA=Ih,W_=ke([].push),mi=function(e){var t=e==1,n=e==2,a=e==3,i=e==4,r=e==6,o=e==7,s=e==5||r;return function(c,u,d,g){for(var I,k,w=UA(c),A=NA(w),p=MA(u,d),v=VA(A),y=0,L=g||jA,f=t?L(c,v):n||o?L(c,0):void 0;v>y;y++)if((s||y in A)&&(k=p(I=A[y],y,w),e))if(t)f[y]=k;else if(k)switch(e){case 3:return!0;case 5:return I;case 6:return y;case 2:W_(f,I)}else switch(e){case 4:return!1;case 7:W_(f,I)}return r?-1:a||i?i:f}},rn={forEach:mi(0),map:mi(1),filter:mi(2),some:mi(3),every:mi(4),find:mi(5),findIndex:mi(6),filterReject:mi(7)},BA=ce,FA=mn,GA=at("species"),Gs=function(e){return FA>=51||!BA(function(){var t=[];return(t.constructor={})[GA]=function(){return{foo:1}},t[e](Boolean).foo!==1})},HA=rn.map;Ue({target:"Array",proto:!0,forced:!Gs("map")},{map:function(e){return HA(this,e,arguments.length>1?arguments[1]:void 0)}});var zA=Se,WA=Xa,qA=TypeError,JA=Object.getOwnPropertyDescriptor,KA=zA&&!function(){if(this!==void 0)return!0;try{Object.defineProperty([],"length",{writable:!1}).length=1}catch(e){return e instanceof TypeError}}(),XA=TypeError,q_=function(e){if(e>9007199254740991)throw XA("Maximum allowed index exceeded");return e},J_=ai,QA=TypeError,K_=function(e,t){if(!delete e[t])throw QA("Cannot delete property "+J_(t)+" of "+J_(e))},YA=Ue,$A=Ut,ZA=hi,eP=Yn,tP=nn,nP=KA?function(e,t){if(WA(e)&&!JA(e,"length").writable)throw qA("Cannot set read only .length");return e.length=t}:function(e,t){return e.length=t},rP=q_,iP=Ih,aP=Os,wh=K_,oP=Gs("splice"),sP=Math.max,cP=Math.min;YA({target:"Array",proto:!0,forced:!oP},{splice:function(e,t){var n,a,i,r,o,s,c=$A(this),u=tP(c),d=ZA(e,u),g=arguments.length;for(g===0?n=a=0:g===1?(n=0,a=u-d):(n=g-2,a=cP(sP(eP(t),0),u-d)),rP(u+n-a),i=iP(c,a),r=0;r<a;r++)(o=d+r)in c&&aP(i,r,c[o]);if(i.length=a,n<a){for(r=d;r<u-a;r++)s=r+n,(o=r+a)in c?c[s]=c[o]:wh(c,s);for(r=u;r>u-a+n;r--)wh(c,r-1)}else if(n>a)for(r=u-a;r>d;r--)s=r+n-1,(o=r+a-1)in c?c[s]=c[o]:wh(c,s);for(r=0;r<n;r++)c[r+d]=arguments[r+2];return nP(c,u-a+n),i}});var uP=ce,Hs=function(e,t){var n=[][e];return!!n&&uP(function(){n.call(null,t||function(){return 1},1)})},lP=rn.forEach,Eh=Hs("forEach")?[].forEach:function(e){return lP(this,e,arguments.length>1?arguments[1]:void 0)};Ue({target:"Array",proto:!0,forced:[].forEach!=Eh},{forEach:Eh});var X_=se,Q_=x_,dP=w_,Ch=Eh,hP=gn,Y_=function(e){if(e&&e.forEach!==Ch)try{hP(e,"forEach",Ch)}catch(t){e.forEach=Ch}};for(var Rh in Q_)Q_[Rh]&&Y_(X_[Rh]&&X_[Rh].prototype);Y_(dP);var pP=Ue,fP=zt,mP=pn,vP=Hs,gP=ke([].join),_P=fP!=Object,yP=vP("join",",");pP({target:"Array",proto:!0,forced:_P||!yP},{join:function(e){return gP(mP(this),e===void 0?",":e)}});var bP=rn.filter;Ue({target:"Array",proto:!0,forced:!Gs("filter")},{filter:function(e){return bP(this,e,arguments.length>1?arguments[1]:void 0)}});var SP=Ue,kP=ce,TP=Xa,xP=vt,IP=Ut,wP=nn,$_=q_,Z_=Os,EP=Ih,CP=Gs,RP=mn,ey=at("isConcatSpreadable"),AP=RP>=51||!kP(function(){var e=[];return e[ey]=!1,e.concat()[0]!==e}),PP=CP("concat"),DP=function(e){if(!xP(e))return!1;var t=e[ey];return t!==void 0?!!t:TP(e)};SP({target:"Array",proto:!0,arity:1,forced:!AP||!PP},{concat:function(e){var t,n,a,i,r,o=IP(this),s=EP(o,0),c=0;for(t=-1,a=arguments.length;t<a;t++)if(DP(r=t===-1?o:arguments[t]))for(i=wP(r),$_(c+i),n=0;n<i;n++,c++)n in r&&Z_(s,c,r[n]);else $_(c+1),Z_(s,c++,r);return s.length=c,s}});var ty=ke,LP=qt,Ah=Date.prototype,ny="Invalid Date",OP="toString",MP=ty(Ah.toString),NP=ty(Ah.getTime);String(new Date(NaN))!=ny&&LP(Ah,OP,function(){var e=NP(this);return e==e?MP(this):ny});var UP=Yn,VP=Ft,jP=en,BP=RangeError,ry=function(e){var t=VP(jP(this)),n="",a=UP(e);if(a<0||a==1/0)throw BP("Wrong number of repetitions");for(;a>0;(a>>>=1)&&(t+=t))1&a&&(n+=t);return n},iy=ke,FP=vr,ay=Ft,GP=en,HP=iy(ry),zP=iy("".slice),WP=Math.ceil,oy=function(e){return function(t,n,a){var i,r,o=ay(GP(t)),s=FP(n),c=o.length,u=a===void 0?" ":ay(a);return s<=c||u==""?o:((r=HP(u,WP((i=s-c)/u.length))).length>i&&(r=zP(r,0,i)),e?o+r:r+o)}},qP={start:oy(!1),end:oy(!0)},JP=/Version\/10(?:\.\d+){1,2}(?: [\w./]+)?(?: Mobile\/\w+)? Safari\//.test(Xn),KP=qP.start;Ue({target:"String",proto:!0,forced:JP},{padStart:function(e){return KP(this,e,arguments.length>1?arguments[1]:void 0)}});var XP=yt,sy=function(){var e=XP(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},Ph=ce,Dh=se.RegExp,Lh=Ph(function(){var e=Dh("a","y");return e.lastIndex=2,e.exec("abcd")!=null}),QP=Lh||Ph(function(){return!Dh("a","y").sticky}),cy={BROKEN_CARET:Lh||Ph(function(){var e=Dh("^r","gy");return e.lastIndex=2,e.exec("str")!=null}),MISSED_STICKY:QP,UNSUPPORTED_Y:Lh},YP=ce,$P=se.RegExp,uy=YP(function(){var e=$P(".","s");return!(e.dotAll&&e.exec(`
|
|
76
|
-
`)&&e.flags==="s")}),ZP=ce,e2=se.RegExp,ly=ZP(function(){var e=e2("(?<a>b)","g");return e.exec("b").groups.a!=="b"||"b".replace(e,"$<a>c")!=="bc"}),Qa=Ke,xu=ke,t2=Ft,n2=sy,r2=cy,i2=pr.exports,a2=qa,o2=st.get,s2=uy,c2=ly,u2=i2("native-string-replace",String.prototype.replace),Iu=RegExp.prototype.exec,Oh=Iu,l2=xu("".charAt),d2=xu("".indexOf),h2=xu("".replace),Mh=xu("".slice),Nh=function(){var e=/a/,t=/b*/g;return Qa(Iu,e,"a"),Qa(Iu,t,"a"),e.lastIndex!==0||t.lastIndex!==0}(),dy=r2.BROKEN_CARET,Uh=/()??/.exec("")[1]!==void 0;(Nh||Uh||dy||s2||c2)&&(Oh=function(e){var t,n,a,i,r,o,s,c=this,u=o2(c),d=t2(e),g=u.raw;if(g)return g.lastIndex=c.lastIndex,t=Qa(Oh,g,d),c.lastIndex=g.lastIndex,t;var I=u.groups,k=dy&&c.sticky,w=Qa(n2,c),A=c.source,p=0,v=d;if(k&&(w=h2(w,"y",""),d2(w,"g")===-1&&(w+="g"),v=Mh(d,c.lastIndex),c.lastIndex>0&&(!c.multiline||c.multiline&&l2(d,c.lastIndex-1)!==`
|
|
77
|
-
`)&&(A="(?: "+A+")",v=" "+v,p++),n=new RegExp("^(?:"+A+")",w)),Uh&&(n=new RegExp("^"+A+"$(?!\\s)",w)),Nh&&(a=c.lastIndex),i=Qa(Iu,k?n:c,v),k?i?(i.input=Mh(i.input,p),i[0]=Mh(i[0],p),i.index=c.lastIndex,c.lastIndex+=i[0].length):c.lastIndex=0:Nh&&i&&(c.lastIndex=c.global?i.index+i[0].length:a),Uh&&i&&i.length>1&&Qa(u2,i[0],n,function(){for(r=1;r<arguments.length-2;r++)arguments[r]===void 0&&(i[r]=void 0)}),i&&I)for(i.groups=o=a2(null),r=0;r<I.length;r++)o[(s=I[r])[0]]=i[s[1]];return i});var wu=Oh;Ue({target:"RegExp",proto:!0,forced:/./.exec!==wu},{exec:wu});var hy=ke,py=qt,p2=wu,fy=ce,my=at,f2=gn,m2=my("species"),Vh=RegExp.prototype,jh=function(e,t,n,a){var i=my(e),r=!fy(function(){var u={};return u[i]=function(){return 7},""[e](u)!=7}),o=r&&!fy(function(){var u=!1,d=/a/;return e==="split"&&((d={}).constructor={},d.constructor[m2]=function(){return d},d.flags="",d[i]=/./[i]),d.exec=function(){return u=!0,null},d[i](""),!u});if(!r||!o||n){var s=hy(/./[i]),c=t(i,""[e],function(u,d,g,I,k){var w=hy(u),A=d.exec;return A===p2||A===Vh.exec?r&&!k?{done:!0,value:s(d,g,I)}:{done:!0,value:w(g,d,I)}:{done:!1}});py(String.prototype,e,c[0]),py(Vh,i,c[1])}a&&f2(Vh[i],"sham",!0)},v2=gh.charAt,vy=function(e,t,n){return t+(n?v2(e,t).length:1)},Bh=ke,g2=Ut,_2=Math.floor,Fh=Bh("".charAt),y2=Bh("".replace),Gh=Bh("".slice),b2=/\$([$&'`]|\d{1,2}|<[^>]*>)/g,S2=/\$([$&'`]|\d{1,2})/g,gy=Ke,k2=yt,T2=tt,x2=ht,I2=wu,w2=TypeError,Hh=function(e,t){var n=e.exec;if(T2(n)){var a=gy(n,e,t);return a!==null&&k2(a),a}if(x2(e)==="RegExp")return gy(I2,e,t);throw w2("RegExp#exec called on incompatible receiver")},E2=ta,_y=Ke,Eu=ke,C2=jh,R2=ce,A2=yt,P2=tt,D2=Dn,L2=Yn,O2=vr,Ya=Ft,M2=en,N2=vy,U2=hr,V2=function(e,t,n,a,i,r){var o=n+e.length,s=a.length,c=S2;return i!==void 0&&(i=g2(i),c=b2),y2(r,c,function(u,d){var g;switch(Fh(d,0)){case"$":return"$";case"&":return e;case"`":return Gh(t,0,n);case"'":return Gh(t,o);case"<":g=i[Gh(d,1,-1)];break;default:var I=+d;if(I===0)return u;if(I>s){var k=_2(I/10);return k===0?u:k<=s?a[k-1]===void 0?Fh(d,1):a[k-1]+Fh(d,1):u}g=a[I-1]}return g===void 0?"":g})},j2=Hh,zh=at("replace"),B2=Math.max,F2=Math.min,G2=Eu([].concat),Wh=Eu([].push),yy=Eu("".indexOf),by=Eu("".slice),H2="a".replace(/./,"$0")==="$0",Sy=!!/./[zh]&&/./[zh]("a","$0")==="",z2=!R2(function(){var e=/./;return e.exec=function(){var t=[];return t.groups={a:"7"},t},"".replace(e,"$<a>")!=="7"});C2("replace",function(e,t,n){var a=Sy?"$":"$0";return[function(i,r){var o=M2(this),s=D2(i)?void 0:U2(i,zh);return s?_y(s,i,o,r):_y(t,Ya(o),i,r)},function(i,r){var o=A2(this),s=Ya(i);if(typeof r=="string"&&yy(r,a)===-1&&yy(r,"$<")===-1){var c=n(t,o,s,r);if(c.done)return c.value}var u=P2(r);u||(r=Ya(r));var d=o.global;if(d){var g=o.unicode;o.lastIndex=0}for(var I=[];;){var k=j2(o,s);if(k===null||(Wh(I,k),!d))break;Ya(k[0])===""&&(o.lastIndex=N2(s,O2(o.lastIndex),g))}for(var w,A="",p=0,v=0;v<I.length;v++){for(var y=Ya((k=I[v])[0]),L=B2(F2(L2(k.index),s.length),0),f=[],b=1;b<k.length;b++)Wh(f,(w=k[b])===void 0?w:String(w));var P=k.groups;if(u){var S=G2([y],f,L,s);P!==void 0&&Wh(S,P);var T=Ya(E2(r,void 0,S))}else T=V2(y,s,L,f,P,r);L>=p&&(A+=by(s,p,L)+T,p=L+y.length)}return A+by(s,p)}]},!z2||!H2||Sy);var W2=Ke,q2=rt,J2=dr,K2=sy,ky=RegExp.prototype,Ty=function(e){var t=e.flags;return t!==void 0||"flags"in ky||q2(e,"flags")||!J2(ky,e)?t:W2(K2,e)},X2=Ur.PROPER,Q2=qt,Y2=yt,xy=Ft,$2=ce,Z2=Ty,Iy="toString",wy=RegExp.prototype.toString,eD=$2(function(){return wy.call({source:"a",flags:"b"})!="/a/b"}),tD=X2&&wy.name!=Iy;(eD||tD)&&Q2(RegExp.prototype,Iy,function(){var e=Y2(this);return"/"+xy(e.source)+"/"+xy(Z2(e))},{unsafe:!0});var nD=ce,rD=at("iterator"),Ey=!nD(function(){var e=new URL("b?a=1&b=2&c=3","http://a"),t=e.searchParams,n="";return e.pathname="c%20d",t.forEach(function(a,i){t.delete("b"),n+=i+a}),!t.sort||e.href!=="http://a/c%20d?a=1&c=3"||t.get("c")!=="3"||String(new URLSearchParams("?a=1"))!=="a=1"||!t[rD]||new URL("https://a@b").username!=="a"||new URLSearchParams(new URLSearchParams("a=b")).get("a")!=="b"||new URL("http://\u0442\u0435\u0441\u0442").host!=="xn--e1aybc"||new URL("http://a#\u0431").hash!=="#%D0%B1"||n!=="a1c3"||new URL("http://x",void 0).host!=="x"}),Cy=vu,iD=Math.floor,qh=function(e,t){var n=e.length,a=iD(n/2);return n<8?aD(e,t):oD(e,qh(Cy(e,0,a),t),qh(Cy(e,a),t),t)},aD=function(e,t){for(var n,a,i=e.length,r=1;r<i;){for(a=r,n=e[r];a&&t(e[a-1],n)>0;)e[a]=e[--a];a!==r++&&(e[a]=n)}return e},oD=function(e,t,n,a){for(var i=t.length,r=n.length,o=0,s=0;o<i||s<r;)e[o+s]=o<i&&s<r?a(t[o],n[s])<=0?t[o++]:n[s++]:o<i?t[o++]:n[s++];return e},Ry=qh,Jh=Ue,$a=se,Cu=Ke,gr=ke,sD=Se,Ay=Ey,Py=qt,cD=Us,uD=ea,lD=Ng,Kh=st,Dy=fi,Xh=tt,dD=rt,hD=Fr,pD=jr,fD=yt,Ly=vt,wn=Ft,mD=qa,Oy=Rt,Qh=_u,vD=Ms,Za=ku,gD=Ry,_D=at("iterator"),Ru="URLSearchParams",My="URLSearchParamsIterator",Ny=Kh.set,$n=Kh.getterFor(Ru),yD=Kh.getterFor(My),bD=Object.getOwnPropertyDescriptor,Yh=function(e){if(!sD)return $a[e];var t=bD($a,e);return t&&t.value},Uy=Yh("fetch"),Au=Yh("Request"),zs=Yh("Headers"),$h=Au&&Au.prototype,Vy=zs&&zs.prototype,SD=$a.RegExp,kD=$a.TypeError,jy=$a.decodeURIComponent,TD=$a.encodeURIComponent,xD=gr("".charAt),By=gr([].join),na=gr([].push),Zh=gr("".replace),ID=gr([].shift),Fy=gr([].splice),Gy=gr("".split),wD=gr("".slice),ED=/\+/g,Hy=Array(4),CD=function(e){return Hy[e-1]||(Hy[e-1]=SD("((?:%[\\da-f]{2}){"+e+"})","gi"))},RD=function(e){try{return jy(e)}catch(t){return e}},zy=function(e){var t=Zh(e,ED," "),n=4;try{return jy(t)}catch(a){for(;n;)t=Zh(t,CD(n--),RD);return t}},AD=/[!'()~]|%20/g,PD={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+"},DD=function(e){return PD[e]},Wy=function(e){return Zh(TD(e),AD,DD)},ep=lD(function(e,t){Ny(this,{type:My,iterator:Qh($n(e).entries),kind:t})},"Iterator",function(){var e=yD(this),t=e.kind,n=e.iterator.next(),a=n.value;return n.done||(n.value=t==="keys"?a.key:t==="values"?a.value:[a.key,a.value]),n},!0),qy=function(e){this.entries=[],this.url=null,e!==void 0&&(Ly(e)?this.parseObject(e):this.parseQuery(typeof e=="string"?xD(e,0)==="?"?wD(e,1):e:wn(e)))};qy.prototype={type:Ru,bindURL:function(e){this.url=e,this.update()},parseObject:function(e){var t,n,a,i,r,o,s,c=vD(e);if(c)for(n=(t=Qh(e,c)).next;!(a=Cu(n,t)).done;){if(r=(i=Qh(fD(a.value))).next,(o=Cu(r,i)).done||(s=Cu(r,i)).done||!Cu(r,i).done)throw kD("Expected sequence with length 2");na(this.entries,{key:wn(o.value),value:wn(s.value)})}else for(var u in e)dD(e,u)&&na(this.entries,{key:u,value:wn(e[u])})},parseQuery:function(e){if(e)for(var t,n,a=Gy(e,"&"),i=0;i<a.length;)(t=a[i++]).length&&(n=Gy(t,"="),na(this.entries,{key:zy(ID(n)),value:zy(By(n,"="))}))},serialize:function(){for(var e,t=this.entries,n=[],a=0;a<t.length;)e=t[a++],na(n,Wy(e.key)+"="+Wy(e.value));return By(n,"&")},update:function(){this.entries.length=0,this.parseQuery(this.url.query)},updateURL:function(){this.url&&this.url.update()}};var Pu=function(){Dy(this,Ws);var e=arguments.length>0?arguments[0]:void 0;Ny(this,new qy(e))},Ws=Pu.prototype;if(cD(Ws,{append:function(e,t){Za(arguments.length,2);var n=$n(this);na(n.entries,{key:wn(e),value:wn(t)}),n.updateURL()},delete:function(e){Za(arguments.length,1);for(var t=$n(this),n=t.entries,a=wn(e),i=0;i<n.length;)n[i].key===a?Fy(n,i,1):i++;t.updateURL()},get:function(e){Za(arguments.length,1);for(var t=$n(this).entries,n=wn(e),a=0;a<t.length;a++)if(t[a].key===n)return t[a].value;return null},getAll:function(e){Za(arguments.length,1);for(var t=$n(this).entries,n=wn(e),a=[],i=0;i<t.length;i++)t[i].key===n&&na(a,t[i].value);return a},has:function(e){Za(arguments.length,1);for(var t=$n(this).entries,n=wn(e),a=0;a<t.length;)if(t[a++].key===n)return!0;return!1},set:function(e,t){Za(arguments.length,1);for(var n,a=$n(this),i=a.entries,r=!1,o=wn(e),s=wn(t),c=0;c<i.length;c++)(n=i[c]).key===o&&(r?Fy(i,c--,1):(r=!0,n.value=s));r||na(i,{key:o,value:s}),a.updateURL()},sort:function(){var e=$n(this);gD(e.entries,function(t,n){return t.key>n.key?1:-1}),e.updateURL()},forEach:function(e){for(var t,n=$n(this).entries,a=hD(e,arguments.length>1?arguments[1]:void 0),i=0;i<n.length;)a((t=n[i++]).value,t.key,this)},keys:function(){return new ep(this,"keys")},values:function(){return new ep(this,"values")},entries:function(){return new ep(this,"entries")}},{enumerable:!0}),Py(Ws,_D,Ws.entries,{name:"entries"}),Py(Ws,"toString",function(){return $n(this).serialize()},{enumerable:!0}),uD(Pu,Ru),Jh({global:!0,constructor:!0,forced:!Ay},{URLSearchParams:Pu}),!Ay&&Xh(zs)){var LD=gr(Vy.has),OD=gr(Vy.set),Jy=function(e){if(Ly(e)){var t,n=e.body;if(pD(n)===Ru)return t=e.headers?new zs(e.headers):new zs,LD(t,"content-type")||OD(t,"content-type","application/x-www-form-urlencoded;charset=UTF-8"),mD(e,{body:Oy(0,wn(n)),headers:Oy(0,t)})}return e};if(Xh(Uy)&&Jh({global:!0,enumerable:!0,dontCallGetSet:!0,forced:!0},{fetch:function(e){return Uy(e,arguments.length>1?Jy(arguments[1]):{})}}),Xh(Au)){var tp=function(e){return Dy(this,$h),new Au(e,arguments.length>1?Jy(arguments[1]):{})};$h.constructor=tp,tp.prototype=$h,Jh({global:!0,constructor:!0,dontCallGetSet:!0,forced:!0},{Request:tp})}}var MD={URLSearchParams:Pu,getState:$n},ND=Object.is||function(e,t){return e===t?e!==0||1/e==1/t:e!=e&&t!=t},UD=Ke,VD=yt,jD=Dn,BD=en,Ky=ND,Xy=Ft,FD=hr,GD=Hh;jh("search",function(e,t,n){return[function(a){var i=BD(this),r=jD(a)?void 0:FD(a,e);return r?UD(r,a,i):new RegExp(a)[e](Xy(i))},function(a){var i=VD(this),r=Xy(a),o=n(t,i,r);if(o.done)return o.value;var s=i.lastIndex;Ky(s,0)||(i.lastIndex=0);var c=GD(i,r);return Ky(i.lastIndex,s)||(i.lastIndex=s),c===null?-1:c.index}]}),new Date().getTime();var np=0,an=function(){return new Date().getTime()+np},Qy=function(){var e=new Date;return e.setTime(an()),e.toLocaleString()},HD=Ke,zD=yt,WD=Dn,qD=vr,rp=Ft,JD=en,KD=hr,XD=vy,Yy=Hh;jh("match",function(e,t,n){return[function(a){var i=JD(this),r=WD(a)?void 0:KD(a,e);return r?HD(r,a,i):new RegExp(a)[e](rp(i))},function(a){var i=zD(this),r=rp(a),o=n(t,i,r);if(o.done)return o.value;if(!i.global)return Yy(i,r);var s=i.unicode;i.lastIndex=0;for(var c,u=[],d=0;(c=Yy(i,r))!==null;){var g=rp(c[0]);u[d]=g,g===""&&(i.lastIndex=XD(r,qD(i.lastIndex),s)),d++}return d===0?null:u}]});var QD=vt,YD=ht,$D=at("match"),$y=function(e){var t;return QD(e)&&((t=e[$D])!==void 0?!!t:YD(e)=="RegExp")},ZD=At.f,eL=Se,ip=se,qs=ke,tL=Cs,nL=Su,rL=gn,iL=di.f,Zy=dr,aL=$y,e0=Ft,oL=Ty,t0=cy,sL=function(e,t,n){n in e||ZD(e,n,{configurable:!0,get:function(){return t[n]},set:function(a){t[n]=a}})},cL=qt,uL=ce,lL=rt,dL=st.enforce,hL=Vs,n0=uy,r0=ly,pL=at("match"),vi=ip.RegExp,eo=vi.prototype,fL=ip.SyntaxError,mL=qs(eo.exec),Du=qs("".charAt),i0=qs("".replace),a0=qs("".indexOf),vL=qs("".slice),gL=/^\?<[^\s\d!#%&*+<=>@^][^\s!#%&*+<=>@^]*>/,ra=/a/g,ap=/a/g,_L=new vi(ra)!==ra,o0=t0.MISSED_STICKY,yL=t0.UNSUPPORTED_Y,bL=eL&&(!_L||o0||n0||r0||uL(function(){return ap[pL]=!1,vi(ra)!=ra||vi(ap)==ap||vi(ra,"i")!="/a/i"}));if(tL("RegExp",bL)){for(var ia=function(e,t){var n,a,i,r,o,s,c=Zy(eo,this),u=aL(e),d=t===void 0,g=[],I=e;if(!c&&u&&d&&e.constructor===ia)return e;if((u||Zy(eo,e))&&(e=e.source,d&&(t=oL(I))),e=e===void 0?"":e0(e),t=t===void 0?"":e0(t),I=e,n0&&"dotAll"in ra&&(a=!!t&&a0(t,"s")>-1)&&(t=i0(t,/s/g,"")),n=t,o0&&"sticky"in ra&&(i=!!t&&a0(t,"y")>-1)&&yL&&(t=i0(t,/y/g,"")),r0&&(r=function(k){for(var w,A=k.length,p=0,v="",y=[],L={},f=!1,b=!1,P=0,S="";p<=A;p++){if((w=Du(k,p))==="\\")w+=Du(k,++p);else if(w==="]")f=!1;else if(!f)switch(!0){case w==="[":f=!0;break;case w==="(":mL(gL,vL(k,p+1))&&(p+=2,b=!0),v+=w,P++;continue;case(w===">"&&b):if(S===""||lL(L,S))throw new fL("Invalid capture group name");L[S]=!0,y[y.length]=[S,P],b=!1,S="";continue}b?S+=w:v+=w}return[v,y]}(e),e=r[0],g=r[1]),o=nL(vi(e,t),c?this:eo,ia),(a||i||g.length)&&(s=dL(o),a&&(s.dotAll=!0,s.raw=ia(function(k){for(var w,A=k.length,p=0,v="",y=!1;p<=A;p++)(w=Du(k,p))!=="\\"?y||w!=="."?(w==="["?y=!0:w==="]"&&(y=!1),v+=w):v+="[\\s\\S]":v+=w+Du(k,++p);return v}(e),n)),i&&(s.sticky=!0),g.length&&(s.groups=g)),e!==I)try{rL(o,"source",I===""?"(?:)":I)}catch(k){}return o},s0=iL(vi),c0=0;s0.length>c0;)sL(ia,vi,s0[c0++]);eo.constructor=ia,ia.prototype=eo,cL(ip,"RegExp",ia,{constructor:!0})}hL("RegExp");var u0=ke(1 .valueOf),l0=`
|
|
78
|
-
\v\f\r \xA0\u1680\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028\u2029\uFEFF`,SL=en,kL=Ft,d0=ke("".replace),Lu=`[
|
|
79
|
-
\v\f\r \xA0\u1680\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028\u2029\uFEFF]`,TL=RegExp("^"+Lu+Lu+"*"),xL=RegExp(Lu+Lu+"*$"),op=function(e){return function(t){var n=kL(SL(t));return 1&e&&(n=d0(n,TL,"")),2&e&&(n=d0(n,xL,"")),n}},Ou={start:op(1),end:op(2),trim:op(3)},IL=Se,sp=se,h0=ke,wL=Cs,EL=qt,p0=rt,CL=Su,RL=dr,AL=Or,f0=Nr,PL=ce,DL=di.f,LL=ye.f,OL=At.f,ML=u0,NL=Ou.trim,m0="Number",gi=sp.Number,cp=gi.prototype,UL=sp.TypeError,VL=h0("".slice),Mu=h0("".charCodeAt),jL=function(e){var t=f0(e,"number");return typeof t=="bigint"?t:BL(t)},BL=function(e){var t,n,a,i,r,o,s,c,u=f0(e,"number");if(AL(u))throw UL("Cannot convert a Symbol value to a number");if(typeof u=="string"&&u.length>2){if(u=NL(u),(t=Mu(u,0))===43||t===45){if((n=Mu(u,2))===88||n===120)return NaN}else if(t===48){switch(Mu(u,1)){case 66:case 98:a=2,i=49;break;case 79:case 111:a=8,i=55;break;default:return+u}for(o=(r=VL(u,2)).length,s=0;s<o;s++)if((c=Mu(r,s))<48||c>i)return NaN;return parseInt(r,a)}}return+u};if(wL(m0,!gi(" 0o1")||!gi("0b1")||gi("+0x1"))){for(var Nu,to=function(e){var t=arguments.length<1?0:gi(jL(e)),n=this;return RL(cp,n)&&PL(function(){ML(n)})?CL(Object(t),n,to):t},v0=IL?DL(gi):"MAX_VALUE,MIN_VALUE,NaN,NEGATIVE_INFINITY,POSITIVE_INFINITY,EPSILON,MAX_SAFE_INTEGER,MIN_SAFE_INTEGER,isFinite,isInteger,isNaN,isSafeInteger,parseFloat,parseInt,fromString,range".split(","),up=0;v0.length>up;up++)p0(gi,Nu=v0[up])&&!p0(to,Nu)&&OL(to,Nu,LL(gi,Nu));to.prototype=cp,cp.constructor=to,EL(sp,m0,to,{constructor:!0})}var FL=ws.includes,GL=pu;Ue({target:"Array",proto:!0,forced:ce(function(){return!Array(1).includes()})},{includes:function(e){return FL(this,e,arguments.length>1?arguments[1]:void 0)}}),GL("includes");var HL=$y,zL=TypeError,g0=function(e){if(HL(e))throw zL("The method doesn't accept regular expressions");return e},WL=at("match"),_0=function(e){var t=/./;try{"/./"[e](t)}catch(n){try{return t[WL]=!1,"/./"[e](t)}catch(a){}}return!1},qL=Ue,JL=g0,KL=en,y0=Ft,XL=_0,QL=ke("".indexOf);qL({target:"String",proto:!0,forced:!XL("includes")},{includes:function(e){return!!~QL(y0(KL(this)),y0(JL(e)),arguments.length>1?arguments[1]:void 0)}});var YL=Ue,$L=ws.indexOf,ZL=Hs,lp=ke([].indexOf),b0=!!lp&&1/lp([1],1,-0)<0,eO=ZL("indexOf");YL({target:"Array",proto:!0,forced:b0||!eO},{indexOf:function(e){var t=arguments.length>1?arguments[1]:void 0;return b0?lp(this,e,t)||0:$L(this,e,t)}});var tO=Ut,S0=As,nO=Pg;Ue({target:"Object",stat:!0,forced:ce(function(){S0(1)}),sham:!nO},{getPrototypeOf:function(e){return S0(tO(e))}});var rO=ta,iO=vn,aO=yt;Ue({target:"Reflect",stat:!0,forced:!ce(function(){Reflect.apply(function(){})})},{apply:function(e,t,n){return rO(iO(e),t,aO(n))}});var oO=Se,sO=Ur.EXISTS,k0=ke,cO=At.f,T0=Function.prototype,uO=k0(T0.toString),x0=/function\b(?:\s|\/\*[\S\s]*?\*\/|\/\/[^\n\r]*[\n\r]+)*([^\s(/]*)/,lO=k0(x0.exec);oO&&!sO&&cO(T0,"name",{configurable:!0,get:function(){try{return lO(x0,uO(this))[1]}catch(e){return""}}});var dO=Ue,I0=Date,hO=ke(I0.prototype.getTime);dO({target:"Date",stat:!0},{now:function(){return hO(new I0)}});var Js,no,w0,dp,Ks=ht(se.process)=="process",pO=Tu,fO=ai,mO=TypeError,E0=function(e){if(pO(e))return e;throw mO(fO(e)+" is not a constructor")},C0=yt,vO=E0,gO=Dn,_O=at("species"),Uu=function(e,t){var n,a=C0(e).constructor;return a===void 0||gO(n=C0(a)[_O])?t:vO(n)},R0=/(?:ipad|iphone|ipod).*applewebkit/i.test(Xn),En=se,yO=ta,bO=Fr,A0=tt,SO=rt,kO=ce,P0=xg,TO=Ka,D0=ja,xO=ku,IO=R0,wO=Ks,hp=En.setImmediate,pp=En.clearImmediate,EO=En.process,fp=En.Dispatch,CO=En.Function,L0=En.MessageChannel,RO=En.String,mp=0,Xs={},AO="onreadystatechange";try{Js=En.location}catch(e){}var vp=function(e){if(SO(Xs,e)){var t=Xs[e];delete Xs[e],t()}},gp=function(e){return function(){vp(e)}},O0=function(e){vp(e.data)},M0=function(e){En.postMessage(RO(e),Js.protocol+"//"+Js.host)};hp&&pp||(hp=function(e){xO(arguments.length,1);var t=A0(e)?e:CO(e),n=TO(arguments,1);return Xs[++mp]=function(){yO(t,void 0,n)},no(mp),mp},pp=function(e){delete Xs[e]},wO?no=function(e){EO.nextTick(gp(e))}:fp&&fp.now?no=function(e){fp.now(gp(e))}:L0&&!IO?(dp=(w0=new L0).port2,w0.port1.onmessage=O0,no=bO(dp.postMessage,dp)):En.addEventListener&&A0(En.postMessage)&&!En.importScripts&&Js&&Js.protocol!=="file:"&&!kO(M0)?(no=M0,En.addEventListener("message",O0,!1)):no=AO in D0("script")?function(e){P0.appendChild(D0("script")).onreadystatechange=function(){P0.removeChild(this),vp(e)}}:function(e){setTimeout(gp(e),0)});var Qs,aa,Ys,ro,_p,yp,bp,N0,U0={set:hp,clear:pp},PO=se,DO=/ipad|iphone|ipod/i.test(Xn)&&PO.Pebble!==void 0,LO=/web0s(?!.*chrome)/i.test(Xn),oa=se,V0=Fr,OO=ye.f,Sp=U0.set,MO=R0,NO=DO,UO=LO,kp=Ks,j0=oa.MutationObserver||oa.WebKitMutationObserver,B0=oa.document,F0=oa.process,Vu=oa.Promise,G0=OO(oa,"queueMicrotask"),H0=G0&&G0.value;H0||(Qs=function(){var e,t;for(kp&&(e=F0.domain)&&e.exit();aa;){t=aa.fn,aa=aa.next;try{t()}catch(n){throw aa?ro():Ys=void 0,n}}Ys=void 0,e&&e.enter()},MO||kp||UO||!j0||!B0?!NO&&Vu&&Vu.resolve?((bp=Vu.resolve(void 0)).constructor=Vu,N0=V0(bp.then,bp),ro=function(){N0(Qs)}):kp?ro=function(){F0.nextTick(Qs)}:(Sp=V0(Sp,oa),ro=function(){Sp(Qs)}):(_p=!0,yp=B0.createTextNode(""),new j0(Qs).observe(yp,{characterData:!0}),ro=function(){yp.data=_p=!_p}));var VO=H0||function(e){var t={fn:e,next:void 0};Ys&&(Ys.next=t),aa||(aa=t,ro()),Ys=t},jO=se,Tp=function(e){try{return{error:!1,value:e()}}catch(t){return{error:!0,value:t}}},z0=function(){this.head=null,this.tail=null};z0.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 BO=z0,$s=se.Promise,W0=typeof Deno=="object"&&Deno&&typeof Deno.version=="object",FO=!W0&&!Ks&&typeof window=="object"&&typeof document=="object",GO=se,Zs=$s,HO=tt,zO=Cs,WO=_,qO=at,JO=FO,KO=W0,xp=mn;Zs&&Zs.prototype;var XO=qO("species"),q0=!1,J0=HO(GO.PromiseRejectionEvent),QO=zO("Promise",function(){var e=WO(Zs),t=e!==String(Zs);if(!t&&xp===66)return!0;if(!xp||xp<51||!/native code/.test(e)){var n=new Zs(function(i){i(1)}),a=function(i){i(function(){},function(){})};if((n.constructor={})[XO]=a,!(q0=n.then(function(){})instanceof a))return!0}return!t&&(JO||KO)&&!J0}),sa={CONSTRUCTOR:QO,REJECTION_EVENT:J0,SUBCLASSING:q0},io={},K0=vn,YO=TypeError,$O=function(e){var t,n;this.promise=new e(function(a,i){if(t!==void 0||n!==void 0)throw YO("Bad Promise constructor");t=a,n=i}),this.resolve=K0(t),this.reject=K0(n)};io.f=function(e){return new $O(e)};var Ip,X0,Q0,ZO=Ue,ju=Ks,_i=se,ao=Ke,Y0=qt,$0=Ja,eM=ea,tM=Vs,nM=vn,Bu=tt,rM=vt,iM=fi,aM=Uu,Z0=U0.set,wp=VO,oM=function(e,t){var n=jO.console;n&&n.error&&(arguments.length==1?n.error(e):n.error(e,t))},sM=Tp,cM=BO,eb=st,Fu=$s,tb=io,Gu="Promise",nb=sa.CONSTRUCTOR,uM=sa.REJECTION_EVENT,lM=sa.SUBCLASSING,Ep=eb.getterFor(Gu),dM=eb.set,oo=Fu&&Fu.prototype,so=Fu,Hu=oo,rb=_i.TypeError,Cp=_i.document,Rp=_i.process,Ap=tb.f,hM=Ap,pM=!!(Cp&&Cp.createEvent&&_i.dispatchEvent),ib="unhandledrejection",ab=function(e){var t;return!(!rM(e)||!Bu(t=e.then))&&t},ob=function(e,t){var n,a,i,r=t.value,o=t.state==1,s=o?e.ok:e.fail,c=e.resolve,u=e.reject,d=e.domain;try{s?(o||(t.rejection===2&&mM(t),t.rejection=1),s===!0?n=r:(d&&d.enter(),n=s(r),d&&(d.exit(),i=!0)),n===e.promise?u(rb("Promise-chain cycle")):(a=ab(n))?ao(a,n,c,u):c(n)):u(r)}catch(g){d&&!i&&d.exit(),u(g)}},sb=function(e,t){e.notified||(e.notified=!0,wp(function(){for(var n,a=e.reactions;n=a.get();)ob(n,e);e.notified=!1,t&&!e.rejection&&fM(e)}))},cb=function(e,t,n){var a,i;pM?((a=Cp.createEvent("Event")).promise=t,a.reason=n,a.initEvent(e,!1,!0),_i.dispatchEvent(a)):a={promise:t,reason:n},!uM&&(i=_i["on"+e])?i(a):e===ib&&oM("Unhandled promise rejection",n)},fM=function(e){ao(Z0,_i,function(){var t,n=e.facade,a=e.value;if(ub(e)&&(t=sM(function(){ju?Rp.emit("unhandledRejection",a,n):cb(ib,n,a)}),e.rejection=ju||ub(e)?2:1,t.error))throw t.value})},ub=function(e){return e.rejection!==1&&!e.parent},mM=function(e){ao(Z0,_i,function(){var t=e.facade;ju?Rp.emit("rejectionHandled",t):cb("rejectionhandled",t,e.value)})},co=function(e,t,n){return function(a){e(t,a,n)}},uo=function(e,t,n){e.done||(e.done=!0,n&&(e=n),e.value=t,e.state=2,sb(e,!0))},Pp=function(e,t,n){if(!e.done){e.done=!0,n&&(e=n);try{if(e.facade===t)throw rb("Promise can't be resolved itself");var a=ab(t);a?wp(function(){var i={done:!1};try{ao(a,t,co(Pp,i,e),co(uo,i,e))}catch(r){uo(i,r,e)}}):(e.value=t,e.state=1,sb(e,!1))}catch(i){uo({done:!1},i,e)}}};if(nb&&(Hu=(so=function(e){iM(this,Hu),nM(e),ao(Ip,this);var t=Ep(this);try{e(co(Pp,t),co(uo,t))}catch(n){uo(t,n)}}).prototype,(Ip=function(e){dM(this,{type:Gu,done:!1,notified:!1,parent:!1,reactions:new cM,rejection:!1,state:0,value:void 0})}).prototype=Y0(Hu,"then",function(e,t){var n=Ep(this),a=Ap(aM(this,so));return n.parent=!0,a.ok=!Bu(e)||e,a.fail=Bu(t)&&t,a.domain=ju?Rp.domain:void 0,n.state==0?n.reactions.add(a):wp(function(){ob(a,n)}),a.promise}),X0=function(){var e=new Ip,t=Ep(e);this.promise=e,this.resolve=co(Pp,t),this.reject=co(uo,t)},tb.f=Ap=function(e){return e===so||e===void 0?new X0(e):hM(e)},Bu(Fu)&&oo!==Object.prototype)){Q0=oo.then,lM||Y0(oo,"then",function(e,t){var n=this;return new so(function(a,i){ao(Q0,n,a,i)}).then(e,t)},{unsafe:!0});try{delete oo.constructor}catch(e){}$0&&$0(oo,Hu)}ZO({global:!0,constructor:!0,wrap:!0,forced:nb},{Promise:so}),eM(so,Gu,!1),tM(Gu);var vM=$s,lb=sa.CONSTRUCTOR||!bu(function(e){vM.all(e).then(void 0,function(){})}),gM=Ke,_M=vn,yM=io,bM=Tp,SM=Ns;Ue({target:"Promise",stat:!0,forced:lb},{all:function(e){var t=this,n=yM.f(t),a=n.resolve,i=n.reject,r=bM(function(){var o=_M(t.resolve),s=[],c=0,u=1;SM(e,function(d){var g=c++,I=!1;u++,gM(o,t,d).then(function(k){I||(I=!0,s[g]=k,--u||a(s))},i)}),--u||a(s)});return r.error&&i(r.value),n.promise}});var kM=Ue,TM=sa.CONSTRUCTOR,Dp=$s,xM=fn,IM=tt,wM=qt,db=Dp&&Dp.prototype;if(kM({target:"Promise",proto:!0,forced:TM,real:!0},{catch:function(e){return this.then(void 0,e)}}),IM(Dp)){var hb=xM("Promise").prototype.catch;db.catch!==hb&&wM(db,"catch",hb,{unsafe:!0})}var EM=Ke,CM=vn,RM=io,AM=Tp,PM=Ns;Ue({target:"Promise",stat:!0,forced:lb},{race:function(e){var t=this,n=RM.f(t),a=n.reject,i=AM(function(){var r=CM(t.resolve);PM(e,function(o){EM(r,t,o).then(n.resolve,a)})});return i.error&&a(i.value),n.promise}});var DM=Ke,LM=io;Ue({target:"Promise",stat:!0,forced:sa.CONSTRUCTOR},{reject:function(e){var t=LM.f(this);return DM(t.reject,void 0,e),t.promise}});var OM=yt,MM=vt,NM=io,pb=function(e,t){if(OM(e),MM(t)&&t.constructor===e)return t;var n=NM.f(e);return(0,n.resolve)(t),n.promise},UM=Ue,VM=sa.CONSTRUCTOR,jM=pb;fn("Promise"),UM({target:"Promise",stat:!0,forced:VM},{resolve:function(e){return jM(this,e)}});var BM=Ut,fb=lu;Ue({target:"Object",stat:!0,forced:ce(function(){fb(1)})},{keys:function(e){return fb(BM(e))}});var mb="canvas",Ae="audio",xe="video",Lp="screen",Gr="small",zu="big",pt="auxiliary",Mn="aux",Wu="smallVideo",vb="user",gb="environment",Zt="mute",_r="unmute",Nt="ended",yi="playing",bi="pause",lo="error",Op="loadeddata",ec="audioinput",qu="videoinput",_b="detail",FM="text",Qe="main",Hr="backup",GM="banned",HM="kick",zM="user_time_out",WM="room_disband",yb="sei-message",ho="PLAYING",yr="PAUSED",Si="STOPPED",po="inactive",ki="sendonly",Mp="recvonly",bb="add",Sb="remove",qM="replace",Np="track",JM="wss://trtc.rtc.qq.com",KM="wss://webrtc.qq.com",Ju="qcloud",XM="trtc",QM="webrtc",tc="",kb="jssdk_log",YM="jssdk_event",$M="jssdk_new_endreport",Up=function(e){return tc=e},ZM=1,eN=2,Ku="live",fo=20,Vp=21,br="anchor",ca="audience",Sr="5Y2wZK8nANNAoVw6dSAHVjNxrD1ObBM2kBPV",nc="224d130c-7b5c-415b-aaa2-79c2eb5a6df2",tN=2,gt=Qe,Lt=pt,Xu="unknown",on="DISCONNECTED",Tb="CONNECTING",jp="RECONNECTING",_n="CONNECTED",nN="new",Qu="connecting",xb="failed",Bp="closed",rN="disconnected",Ib="connected",iN="completed",Fp=30,wb="join",aN="delta-join",Eb="rejoin",oN="leave",sN="delta-leave",Cb="publish",cN="delta-publish",Rb="unpublish",Ab="subscribe",Pb="unsubscribe",Db="uplink-connection",Lb="uplink-reconnection",Ob="downlink-connection",Mb="downlink-reconnection",Yu="setLocalDescription",Nb="setRemoteDescription",Ub="iceConnectionState",rc="stream-initialize",Gp="websocketConnectionState",Vb="websocketReconnectionState",jb="update-stream",Bb="recover-subscription",Fb="start-mix-transcode",Gb="stop-mix-transcode",Hb="player-error",zb="schedule",Hp="unsubscribe",zp="subscribe_change",ic="unified-plan",Wp="plan-b",qp={MANUAL:"manual",PRESET_LAYOUT:"preset-layout"},Wb={REMOTE:"$PLACE_HOLDER_REMOTE$"},qb={IT_AUDIO_VIDEO:0,IT_PICTURE:2,IT_CANVAS:3,IT_PURE_AUDIO:4,IT_PURE_VIDEO:5},bt="string",Et="number",sn="boolean",uN="array",kr="object",cn={ADD:bb,REMOVE:Sb},Jp={unknown:0,wifi:1,"4g":2,"3g":3,"2g":4,wired:5},Jb=-1,ac=0,lN=1,Kb=zu,Xb=Gr,Qb=6048e5,dN="schedule.rtc.qq.com",hN="schedule.rtc.qcloud.com",pN="schedule.rtc.tencentcloud.com",fN="schedule-ecdn.rtc.tencentcloud.com",Kp="",Yb=function(e){return Kp=e},oc="TRTC",un="Client",Ti="LocalStream",Xp="RemoteStream",mN="Stream",Qp="web.sdk.qcloud.com",$b="web.sdk.tencent.cn",Zb="web.sdk.cloud.tencent.cn",eS="https://console.cloud.tencent.com/trtc",mo="https://".concat(Qp,"/trtc/webrtc/doc"),Yp="".concat(mo,"/zh-cn/"),$p="trtc_error_assistance",$u="default",tS="communications",Nn={TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,NONE:5},vN=1,nS=2,gN=1,rS=2,ua=Object.keys(Nn),_N=["normal leave","timeout leave","kick","role change"],Zu=2e3,vo="ric",el="raf",yN="interval",iS="timeout",aS="Resolution reset to 1080p, need to upgrade ability here https://cloud.tencent.com/document/product/647/85386",bN={"TRTC.checkSystemRequirements":40001,"TRTC.isScreenShareSupported":40002,"TRTC.isSmallStreamSupported":40003,"TRTC.createClient.rtc":40004,"TRTC.createClient.live":40005,"TRTC.createClient.intRoomId":40006,"TRTC.createClient.stringRoomId":40007,"TRTC.createClient.autoSubscribe":40008,"TRTC.createClient.manualSubscribe":40009,"TRTC.enableUploadLog":40010,"TRTC.disableUploadLog":40011,"Client.publish":40012,"Client.publish.isAuxiliary":40013,"Client.switchRole":40014,"Client.startPublishCDNStream":40015,"Client.stopPublishCDNStream":40016,"Client.startMixTranscode":40017,"Client.stopMixTranscode":40018,"Client.enableAudioVolumeEvaluation":40019,"Client.enableSmallStream":40020,"Client.disableSmallStream":40021,"Client.setSmallStreamProfile":40022,"Client.setRemoteVideoStreamType":40023,"Client.sendSEIMessage":40024,"Client.setProxyServer":40025,"Client.setTurnServer":40026,"LocalStream.setAudioProfile.standard":40027,"LocalStream.setAudioProfile.high":40028,"LocalStream.setAudioProfile.standard-stereo":40029,"LocalStream.setAudioProfile.high-stereo":40030,"LocalStream.setVideoProfile.120p":40031,"LocalStream.setVideoProfile.120p_2":40032,"LocalStream.setVideoProfile.180p":40033,"LocalStream.setVideoProfile.180p_2":40034,"LocalStream.setVideoProfile.240p":40035,"LocalStream.setVideoProfile.240p_2":40036,"LocalStream.setVideoProfile.360p":40037,"LocalStream.setVideoProfile.360p_2":40038,"LocalStream.setVideoProfile.480p":40039,"LocalStream.setVideoProfile.480p_2":40040,"LocalStream.setVideoProfile.720p":40041,"LocalStream.setVideoProfile.1080p":40042,"LocalStream.setVideoProfile.1440p":40043,"LocalStream.setVideoProfile.4K":40044,"LocalStream.setScreenProfile.480p":40045,"LocalStream.setScreenProfile.480p_2":40046,"LocalStream.setScreenProfile.720p":40047,"LocalStream.setScreenProfile.720p_2":40048,"LocalStream.setScreenProfile.1080p":40049,"LocalStream.setScreenProfile.1080p_2":40050,"LocalStream.setVideoContentHint.motion":40051,"LocalStream.setVideoContentHint.detail":40052,"LocalStream.setVideoContentHint.text":40053,"LocalStream.setAudioCaptureVolume":40054,"LocalStream.getVideoFrame":40055,"RemoteStream.setAudioOutput":40056,"RemoteStream.getVideoFrame":40057,AI_DENOISER:1700,SPATIAL_AUDIO:1701,"2K_4K":1704},Zp=["width","height","frameRate","facingMode","sampleRate","sampleSize","channelCount","deviceId"],SN=en,oS=Ft,kN=/"/g,TN=ke("".replace),sS=function(e,t,n,a){var i=oS(SN(e)),r="<"+t;return n!==""&&(r+=" "+n+'="'+TN(oS(a),kN,""")+'"'),r+">"+i+"</"+t+">"},xN=ce,cS=function(e){return xN(function(){var t=""[e]('"');return t!==t.toLowerCase()||t.split('"').length>3})},IN=sS;Ue({target:"String",proto:!0,forced:cS("link")},{link:function(e){return IN(this,"a","href",e)}}),Ue({target:"Array",stat:!0},{isArray:Xa});var wN="AVOID_REPEATED_CALL",EN="INVALID_PARAMETER_REQUIRED",uS="INVALID_PARAMETER_TYPE",CN="INVALID_PARAMETER_EMPTY",lS="INVALID_PARAMETER_INSTANCE",RN="INVALID_PARAMETER_RANGE",AN="API_CALL_TIMEOUT",PN="SIGNAL_CHANNEL_RECONNECTION_FAILED",DN="SIGNAL_CHANNEL_SETUP_FAILED",LN="ERROR_MESSAGE",ON="EXCHANGE_SDP_TIMEOUT",MN="DOWNLINK_RECONNECTION_FAILED",NN="EXCHANGE_SDP_FAILED",UN="UPLINK_RECONNECTION_FAILED",VN="INVALID_PURE_AUDIO",jN="INVALID_STREAMID",BN="INVALID_USER_DEFINE_RECORDID",FN="INVALID_USER_DEFINE_PUSH_ARGS",GN="INVALID_PROXY",HN="INVALID_JOIN",zN="INVALID_ROOMID_STRING",WN="INVALID_ROOMID_INTEGER",qN="JOIN_ROOM_TIMEOUT",dS="JOIN_ROOM_FAILED",JN="REJOIN_ROOM_FAILED",KN="INVALID_DESTROY",XN="INVALID_PUBLISH",QN="INVALID_UNPUBLISH",YN="INVALID_AUDIENCE",$N="INVALID_INITIALIZE",ZN="INVALID_DUPLICATE_PUBLISHING",ef="INVALID_REMOTE_STREAM",e3="SUBSCRIBE_FAILED",t3="INVALID_ROLE",n3="INVALID_OPERATION_SWITCH_ROLE",r3="SWITCH_ROLE_TIMEOUT",i3="SWITCH_ROLE_FAILED",a3="CLIENT_BANNED",hS="INVALID_OPERATION_START_PUBLISH_CDN",o3="INVALID_OPERATION_STOP_PUBLISH_CDN",s3="INVALID_STREAM_ID",pS="START_PUBLISH_CDN_FAILED",fS="STOP_PUBLISH_CDN_FAILED",c3="START_MIX_TRANSCODE",u3="STOP_MIX_TRANSCODE",l3="INVALID_AUDIO_VOLUME",d3="ENABLE_SMALL_STREAM_PUBLISHED",h3="DISABLE_SMALL_STREAM_PUBLISHED",p3="NOT_SUPPORTED_SMALL_STREAM",f3="INVALID_SMALL_STREAM_PROFILE",m3="INVALID_PARAMETER_REMOTE_STREAM",v3="INVALID_SWITCH_DEVICE",g3="INVALID_SWITCH_DEVICE_PUBLISHING",mS="INVALID_REPLACE_TRACK",_3="INVALID_INITIALIZE_LOCAL_STREAM",y3="INVALID_ADD_TRACK_REPETITIVE",b3="INVALID_ADD_TRACK_REMOVING",S3="INVALID_ADD_TRACK_PUBLISHING",vS="INVALID_STREAM_INITIALIZED",k3="INVALID_ADD_TRACK_NUMBER",T3="INVALID_REMOVE_AUDIO_TRACK",x3="INVALID_REMOVE_AUDIO_ADDING",I3="INVALID_REMOVE_AUDIO_ON",w3="INVALID_REMOVE_TRACK_PUBLISHING",E3="INVALID_REMOVE_TRACK_NOT_PUBLISHING",C3="INVALID_REMOVE_TRACK_NUMBER",R3="INVALID_REPLACE_TRACK_NO_TRACK",A3="REPEAT_JOIN",tf="CLIENT_DESTROYED",P3="START_MIX_TRANSCODE_FAILED",D3="STOP_MIX_TRANSCODE_FAILED",L3="MIX_TRANSCODE_NOT_STARTED",O3="CANNOT_LESS_THAN_ZERO",M3="MIX_PARAMS_VIDEO_FRAMERATE",N3="MIX_PARAMS_VIDEO_GOP",U3="MIX_PARAMS_AUDIO_BITRATE",V3="MIX_PARAMS_USER_Z_ORDER",j3="MIX_PARAMS_NOT_SELF",B3="MIX_PARAMS_USER_STREAM",F3="INVALID_ELEMENT_ID",G3="INVALID_ELEMENT_ID_TYPE",nf="PLAY_FAILED",H3="INVALID_CREATE_STREAM_SOURCE",z3="INVALID_CREATE_STREAM_SCREEN",W3="INVALID_CREATE_STREAM_AUDIO",q3="INVALID_CREATE_STREAM_SCREEN_AUDIO",gS="NOT_SUPPORTED_HTTP",_S="NOT_SUPPORTED_WEBRTC",J3="NOT_SUPPORTED_PROFILE",yS="NOT_SUPPORTED_H264ENCODE",bS="NOT_SUPPORTED_H264DECODE",rf="NOT_SUPPORTED_TRACK",K3="NOT_SUPPORTED_SWITCH_DEVICE",X3="NOT_SUPPORTED_CAPTURE",Q3="NOT_SUPPORTED_AUX",Y3="MICROPHONE_NOT_FOUND",$3="CAMERA_NOT_FOUND",SS="SIGNAL_RESPONSE_FAILED",Z3="CATCH_HANDLER_ERROR",e4="API_NOT_EXIST",t4="CONNECTION_CLOSED",n4="SUBSCRIBE_ALL_FALSE",kS="SEI_NOT_SUPPORT",r4="SEI_DISABLED",i4="SEI_EMPTY",a4="SEI_OVERSIZE",o4="SEI_BEFORE_PUBLISH",s4="SEI_NOT_VIDEO",c4="CALL_FREQUENCY_LIMIT",u4="CONNECTION_ABORTED",af="API_CALL_ABORTED",l4="DUPLICATE_AUX",xi={AVOID_REPEATED_CALL:function(e){return"previous ".concat(e.name,"() is ongoing, please avoid repeated calls.")},INVALID_PARAMETER_REQUIRED:function(e){var t=e.key,n=e.rule,a=e.fnName,i=e.value;return"'".concat(t||n.name,"' is a required param when calling ").concat(a,"(), received: ").concat(i,".")},INVALID_PARAMETER_TYPE:function(e){var t=e.key,n=e.rule,a=e.fnName,i=e.value,r="".concat(t||n.name),o="";return o=Array.isArray(n.type)?n.type.join("|"):n.type,"'".concat(r,"' must be type of ").concat(o," when calling ").concat(a,"(), received type: ").concat(Ci(i),".")},INVALID_PARAMETER_EMPTY:function(e){var t=e.key,n=e.rule,a=e.fnName,i=e.value;return"'".concat(t||n.name,"' cannot be '").concat(i,"' when calling ").concat(a,"().")},INVALID_PARAMETER_INSTANCE:function(e){var t=e.key,n=e.rule,a=e.fnName,i=e.value,r="".concat(t||n.name),o="".concat(n.instanceOf.name||n.instanceOf);return"'".concat(r,"' must be instanceof ").concat(o," when calling ").concat(a,"(), received type: ").concat(Ci(i),".")},INVALID_PARAMETER_RANGE:function(e){var t=e.key,n=e.rule,a=e.fnName,i=e.value;return"'".concat(t||n.name,"' must be one of ").concat(n.values.join("|")," when calling ").concat(a,"(), received: ").concat(i,".")},API_CALL_TIMEOUT:function(e){return"".concat(e.commandDesc||e.command," timeout observed.")},SIGNAL_CHANNEL_RECONNECTION_FAILED:"signal channel reconnection failed, please check your network.",SIGNAL_CHANNEL_SETUP_FAILED:function(e){return"SignalChannel setup failure: (errorCode: ".concat(e.errorCode,", errorMsg: ").concat(e.errorMsg," }).")},ERROR_MESSAGE:function(e){var t="".concat(e.type," failed");return e.message&&(t="".concat(t,": ").concat(e.message,".")),t},EXCHANGE_SDP_TIMEOUT:"exchange sdp timeout.",DOWNLINK_RECONNECTION_FAILED:"downlink reconnection failed, please check your network and re-join room.",EXCHANGE_SDP_FAILED:function(e){return"exchange sdp failed ".concat(e.errMsg,".")},UPDATE_OFFER_TIMEOUT:"update offer timeout observed.",UPLINK_RECONNECTION_FAILED:"uplink reconnection failed, please check your network and publish again.",INVALID_RECORDID:"recordId must be an integer number.",INVALID_PURE_AUDIO:"pureAudioPushMode must be 1 or 2.",INVALID_STREAMID:"streamId must be a sting literal within 64 bytes, and not be empty.",INVALID_USER_DEFINE_RECORDID:"userDefineRecordId must be a sting literal contains (a-zA-Z),(0-9), underline and hyphen, within 64 bytes, and not be empty.",INVALID_USER_DEFINE_PUSH_ARGS:"userDefinePushArgs must be a sting literal within 256 bytes, and not be empty.",INVALID_PROXY:'proxy server url must start with "wss://".',INVALID_JOIN:"duplicate join() called.",INVALID_ROOMID_STRING:function(e){return"'".concat(e,"' must be validate string when useStringRoomId is true.")},INVALID_ROOMID_INTEGER:function(e){return"'".concat(e,"' must be an integer between [1, 4294967294] when useStringRoomId is false.")},INVALID_SIGNAL_CHANNEL:"SignalChannel is not ready yet.",JOIN_ROOM_TIMEOUT:"join room timeout.",JOIN_ROOM_FAILED:function(e){var t=e.error,n=e.code;return"Failed to join room - ".concat(t," code: ").concat(n)},REJOIN_ROOM_FAILED:function(e){return"reJoin room: ".concat(e.roomId," failed, please check your network.")},INVALID_DESTROY:"please call leave() before destroy().",INVALID_PUBLISH:"please call join() before publish().",INVALID_UNPUBLISH:"stream has not been published yet.",INVALID_AUDIENCE:"no permission to publish() under live/".concat(ca,', please call switchRole("').concat(br,'") firstly before publish().'),INVALID_INITIALIZE:"cannot publish stream because stream is not initialized, is switching device, or has been closed.",INVALID_DUPLICATE_PUBLISHING:function(e){return"duplicate ".concat(e," stream publishing, please unpublish your prev ").concat(e," stream and then re-publish.")},INVALID_SUBSCRIBE_UNDEFINED:"stream is undefined or null.",INVALID_SUBSCRIBE_LOCAL:"stream cannot be LocalStream.",INVALID_REMOTE_STREAM:"remoteStream does not exist because it has been unpublished by remote peer.",SUBSCRIBE_FAILED:function(e){var t=e.message,n=e.stream;return"failed to subscribe ".concat(n.getUserId()," ").concat(n.getType()," stream, reason: ").concat(t,".")},INVALID_ROLE:"switchRole can only be called in live mode.",INVALID_PARAMETER_SWITCH_ROLE:"role could only be set to a value as ".concat(br," or ").concat(ca,"."),INVALID_OPERATION_SWITCH_ROLE:"please call join() before switchRole().",SWITCH_ROLE_TIMEOUT:"switchRole timeout.",SWITCH_ROLE_FAILED:function(e){return"switchRole failed, errCode: ".concat(e.code," errMsg: ").concat(e.message,".")},CLIENT_BANNED:function(e){return"client was banned because of "+e.message+"."},INVALID_OPERATION_START_PUBLISH_CDN:"please call startPublishCDNStream() before client join the room or after client join the room and successfully publish the local stream.",INVALID_OPERATION_STOP_PUBLISH_CDN:"please call startPublishCDNStream() before stopPublishCDNStream().",START_PUBLISH_CDN_FAILED:function(e){return"startPublishCDNStream failed, errMsg: ".concat(e.message,".")},STOP_PUBLISH_CDN_FAILED:function(e){return"stopPublishCDNStream failed, errMsg: ".concat(e.message,".")},INVALID_STREAM_ID:function(e){return"'".concat(e,"' can only consist of uppercase and lowercase english letters (a-zA-Z), numbers (0-9), hyphens and underscores.")},START_MIX_TRANSCODE:"please call startMixTranscode() after join().",STOP_MIX_TRANSCODE:"please call stopMixTranscode() after startMixTranscode().",INVALID_AUDIO_VOLUME:"interval must be a number.",ENABLE_SMALL_STREAM_PUBLISHED:"Cannot enable small stream after localStream published.",DISABLE_SMALL_STREAM_PUBLISHED:"Cannot disable small stream after localStream published.",NOT_SUPPORTED_SMALL_STREAM:"your browser does not support opening small stream.",INVALID_SMALL_STREAM_PROFILE:"small stream profile is invalid.",INVALID_PARAMETER_REMOTE_STREAM:"remoteStream is invalid.",INVALID_OPERATION_CHANGE_SMALL:"cannot switch to the small stream without subscribing to the video of remoteStream.",REMOTE_NOT_PUBLISH_SMALL_STREAM:"remote peer does not publish small stream.",INVALID_SWITCH_DEVICE:"cannot switch device on current stream.",INVALID_SWITCH_DEVICE_PUBLISHING:"cannot switch device when publishing localStream.",INVALID_REPLACE_TRACK:"cannot replace track when publishing localStream.",INVALID_INITIALIZE_LOCAL_STREAM:"local stream has not initialized yet.",INVALID_ADD_TRACK_REPETITIVE:"previous addTrack is ongoing, please avoid repetitive execution.",INVALID_ADD_TRACK_REMOVING:"cannot add track when a track is removing.",INVALID_ADD_TRACK_PUBLISHING:"cannot add track when publishing localStream.",INVALID_STREAM_INITIALIZED:"your local stream haven't been initialized yet.",INVALID_ADD_TRACK_NUMBER:"a Stream has at most one audio track and one video track.",INVALID_REMOVE_AUDIO_TRACK:"remove audio track is not supported on your browser.",INVALID_REMOVE_AUDIO_ADDING:"cannot remove track when a track is adding.",INVALID_REMOVE_AUDIO_ON:"previous removeTrack is ongoing, please avoid repetitive execution.",INVALID_REMOVE_TRACK_PUBLISHING:"cannot remove track when publishing localStream.",INVALID_REMOVE_TRACK_NOT_PUBLISHING:"the track to be removed is not being publishing.",INVALID_REMOVE_TRACK_NUMBER:"remove the only video track is not supported, please use replaceTrack or muteVideo.",INVALID_REPLACE_TRACK_NO_TRACK:function(e){return"cannot replace ".concat(e.kind," track because stream has not ").concat(e.kind," track")},START_MIX_TRANSCODE_FAILED:function(e){return"startMixTranscode failed, errMsg: ".concat(e.message,".")},STOP_MIX_TRANSCODE_FAILED:function(e){return"stopMixTranscode failed, errMsg: ".concat(e.message,".")},MIX_TRANSCODE_NOT_STARTED:"mixTranscode has not been started.",CANNOT_LESS_THAN_ZERO:function(e){var t=e.key,n=e.rule,a=e.fnName;return e.value,"'".concat(t||n.name,"' cannot be less than 0 when calling ").concat(a,"().")},MIX_PARAMS_VIDEO_FRAMERATE:"'config.videoFramerate' should be an integer between 0 and 30, excluding 0.",MIX_PARAMS_VIDEO_GOP:"'config.videoGOP' should be an integer between 1 and 8.",MIX_PARAMS_AUDIO_BITRATE:"'config.audioBitrate' should be an integer between 32 and 192.",MIX_PARAMS_USER_Z_ORDER:function(e){return"'".concat(e,"' is required and must be between 1 and 15.")},MIX_PARAMS_NOT_SELF:"'config.mixUsers' must contain self.",MIX_PARAMS_USER_STREAM:"'config.videoWidth' and 'config.videoHeight' of output stream should be contain all mix stream.",INVALID_PLAY:"duplicate play() call observed, please stop() firstly.",INVALID_ELEMENT_ID:function(e){var t=e.key,n=e.fnName;return"'".concat(t,"' is not found in the document object when calling ").concat(n,"().")},INVALID_ELEMENT_ID_TYPE:function(e){var t=e.key,n=e.fnName,a=e.type;return"the element corresponding to '".concat(t,"' must be instanceof HTMLDivElement when calling ").concat(n,"(), received: ").concat(a,".")},PLAY_FAILED:function(e){return"".concat(e.media," play failed\uFF0Cbrowser exception: ").concat(e.error.toString())},INVALID_USERID:"userId cannot be all spaces.",INVALID_CREATE_STREAM_SOURCE:"LocalStream must be created by createStream() with either audio/video or audioSource/videoSource, but can not be mixed with audio/video and audioSource/videoSource.",INVALID_CREATE_STREAM_SCREEN:"screen/video cannot be both true.",INVALID_CREATE_STREAM_AUDIO:"audio/screenAudio cannot be both true.",INVALID_CREATE_STREAM_SCREEN_AUDIO:"when screen is true, screenAudio can be configured.",NOT_SUPPORTED_HTTP:"http protocol does not support the ability to capture and publish streams, please use the https protocol.",NOT_SUPPORTED_WEBRTC:"your browser or environment does not support full WebRTC capabilities.",NOT_SUPPORTED_PROFILE:"your browser does not support setVideoProfile.",NOT_SUPPORTED_MEDIA:"your browser or environment does not support navigator.mediaDevices.",NOT_SUPPORTED_H264ENCODE:"your device does not support H.264 encoding.",NOT_SUPPORTED_H264DECODE:"your device does not support H.264 decoding.",NOT_SUPPORTED_TRACK:function(e){return"".concat(e,"Track is not supported on your browser.")},NOT_SUPPORTED_SWITCH_DEVICE:"switchDevice is not supported on your browser.",NOT_SUPPORTED_CAPTURE:"Your browser or environment does not support screen sharing, please check whether the browser version.",MICROPHONE_NOT_FOUND:"no microphone detected, please check your microphone and the configuration on TRTC.createStream.",CAMERA_NOT_FOUND:"no camera detected, please check your camera and the configuration on TRTC.createStream.",SIGNAL_RESPONSE_FAILED:function(e){return"".concat(e.signalResponse," failed, response code is ").concat(e.code," , errMsg: ").concat(e.message,".")},CATCH_HANDLER_ERROR:function(e){var t=e.name,n=e.event;return"an error was caught on ".concat(t,".on('").concat(n,"', handler), please check your code on 'handler'.")},API_NOT_EXIST:function(e){var t=e.name;return"experimental api ".concat(t," does not exist.")},REPEAT_JOIN:function(e){return"[".concat(e,"] is calling client.join api or has already joined room, please avoid repeated join.")},CONNECTION_CLOSED:"remoteStream has been unsubscribed or unpublished by remote user.",SUBSCRIBE_ALL_FALSE:"cannot subscribe when both audio & video are false, use client.unsubscribe() instead",CLIENT_DESTROYED:function(e){var t=e.funName;return"failed to call ".concat(t,"() because client was destroyed.")},SEI_NOT_SUPPORT:function(e){return"not support to sendSEIMessage".concat(e===!1?" without using h264 codec":"")},SEI_DISABLED:"SEI is disabled, to enable SEI: TRTC.createClient({ enableSEI: true })",SEI_EMPTY:"buffer cannot be empty",SEI_OVERSIZE:function(e){return"buffer size(".concat(e,") is over 1000 Bytes")},SEI_BEFORE_PUBLISH:"please call sendSEIMessage() after publish() success",SEI_NOT_VIDEO:"cannot send sei when localStream has not video.",CALL_FREQUENCY_LIMIT:function(e){var t=e.isSize,n=e.name,a=e.timesInSecond,i=e.maxSizeInSecond;return"api ".concat(n," call ").concat(t?"size":"times"," is over ").concat(t?i+" bytes":a," in a second.")},CONNECTION_ABORTED:function(e){return"connection aborted due to: "+e},API_CALL_ABORTED:function(e){return e.message.includes("REMOTE_STREAM_NOT_EXIST")?"Subscribe ".concat(e.stream.getUserId()," ").concat(e.stream.getType()," stream aborted, reason: remote user ").concat(e.stream.getUserId()," unpublished stream."):"API aborted, reason: ".concat(e.message)},DUPLICATE_AUX:"only one auxiliary stream can be published in a room.",NOT_SUPPORTED_AUX:"publish auxiliary stream is not supported on your browser."},TS=se,d4=ce,h4=Ft,p4=Ou.trim,f4=ke("".charAt),tl=TS.parseFloat,xS=TS.Symbol,IS=xS&&xS.iterator,wS=1/tl(`
|
|
80
|
-
\v\f\r \xA0\u1680\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028\u2029\uFEFF-0`)!=-1/0||IS&&!d4(function(){tl(Object(IS))})?function(e){var t=p4(h4(e)),n=tl(t);return n===0&&f4(t,0)=="-"?-0:n}:tl;Ue({global:!0,forced:parseFloat!=wS},{parseFloat:wS});var Re=window.navigator&&window.navigator.userAgent||"",ES=/AppleWebKit\/([\d.]+)/i.exec(Re);ES&&parseFloat(ES.pop());var of=/iPad/i.test(Re),CS=navigator.maxTouchPoints&&navigator.maxTouchPoints>2&&/Macintosh/.test(Re),sf=/iPhone/i.test(Re)&&!of,m4=/iPod/i.test(Re),Ii=sf||of||m4||CS,la=/Android/i.test(Re);la&&function(){var e=Re.match(/Android (\d+)(?:\.(\d+))?(?:\.(\d+))*/i);if(!e)return null;var t=e[1]&&parseFloat(e[1]),n=e[2]&&parseFloat(e[2]);t&&n&&parseFloat(e[1]+"."+e[2])}(),la&&/webkit/i.test(Re);var Tr=/Firefox/i.test(Re),RS=Tr&&function(){var e=Re.match(/Firefox\/(\d+)/);return e&&e[1]?parseFloat(e[1]):null}(),nl=/Edge\//i.test(Re),v4=nl&&function(){var e=Re.match(/Edge\/(\d+)/i);if(e&&e[1])return e[1]}(),rl=/Edg\//i.test(Re),AS=rl&&function(){var e=Re.match(/Edg\/(\d+)/);return e&&e[1]?parseFloat(e[1]):null}(),cf=/SogouMobileBrowser\//i.test(Re),g4=cf&&function(){var e=Re.match(/SogouMobileBrowser\/(\d+)/);return e&&e[1]?parseFloat(e[1]):null}(),uf=/MetaSr\s/i.test(Re),_4=uf&&function(){var e=Re.match(/MetaSr(\s\d+(\.\d+)+)/);return e&&e[1]?parseFloat(e[1]):null}(),zr=/TBS\/\d+/i.test(Re),y4=zr&&function(){var e=Re.match(/TBS\/(\d+)/i);if(e&&e[1])return e[1]}(),lf=/XWEB\/\d+/i.test(Re),b4=lf&&function(){var e=Re.match(/XWEB\/(\d+)/i);if(e&&e[1])return e[1]}();/MSIE\s8\.0/.test(Re),/MSIE\/\d+/i.test(Re)&&function(){var e=/MSIE\s(\d+)\.\d/.exec(Re),t=e&&parseFloat(e[1]);!t&&/Trident\/7.0/i.test(Re)&&/rv:11.0/.test(Re)&&(t=11)}();var df=/(micromessenger|webbrowser)/i.test(Re),S4=df&&function(){var e=Re.match(/MicroMessenger\/(\d+)/i);if(e&&e[1])return e[1]}(),hf=!zr&&/MQQBrowser\/\d+/i.test(Re)&&/COVC\/\d+/i.test(Re),pf=!zr&&/MQQBrowser\/\d+/i.test(Re)&&!/COVC\/\d+/i.test(Re),PS=(pf||hf)&&function(){var e=Re.match(/ MQQBrowser\/([\d.]+)/);return e&&e[1]?e[1]:null}(),ff=!zr&&/ QQBrowser\/\d+/i.test(Re),k4=ff&&function(){var e=Re.match(/ QQBrowser\/([\d.]+)/);return e&&e[1]?e[1]:null}(),mf=!zr&&/QQBrowserLite\/\d+/i.test(Re),T4=mf&&function(){var e=Re.match(/QQBrowserLite\/([\d.]+)/);return e&&e[1]?e[1]:null}(),vf=!zr&&/MQBHD\/\d+/i.test(Re),x4=vf&&function(){var e=Re.match(/MQBHD\/([\d.]+)/);return e&&e[1]?e[1]:null}(),DS=/Windows/i.test(Re),sc=!Ii&&/MAC OS X/i.test(Re),LS=!la&&/Linux/i.test(Re);/MicroMessenger/i.test(Re);var I4=/UCBrowser/i.test(Re);/Electron/i.test(Re);var OS,il,gf=/MiuiBrowser/i.test(Re),w4=gf&&function(){var e=Re.match(/MiuiBrowser\/([\d.]+)/);return e&&e[1]?e[1]:null}(),_f=/HuaweiBrowser/i.test(Re),yf=/Huawei/i.test(Re),E4=_f&&function(){var e=Re.match(/HuaweiBrowser\/([\d.]+)/);return e&&e[1]?e[1]:null}(),bf=/SamsungBrowser/i.test(Re),C4=bf&&function(){var e=Re.match(/SamsungBrowser\/([\d.]+)/);return e&&e[1]?e[1]:null}(),al=/HeyTapBrowser/i.test(Re),R4=al&&function(){var e=Re.match(/HeyTapBrowser\/([\d.]+)/);return e&&e[1]?e[1]:null}(),ol=/VivoBrowser/i.test(Re),A4=ol&&function(){var e=Re.match(/VivoBrowser\/([\d.]+)/);return e&&e[1]?e[1]:null}(),go=function(){var e=Re.match(/Chrome\/(\d+)/);return e&&e[1]?Number(e[1]):null},P4=/Chrome/i.test(Re),sl=!nl&&!uf&&!cf&&!zr&&!lf&&!rl&&!ff&&!gf&&!_f&&!bf&&!al&&!ol&&/Chrome/i.test(Re),Sf=sl&&go(),D4=sl&&function(){var e=Re.match(/Chrome\/([\d.]+)/);return e&&e[1]?e[1]:null}(),da=!P4&&!pf&&!hf&&!mf&&!vf&&/Safari/i.test(Re),kf=function(){if(da){var e=Re.match(/Version\/([\d.]+)/);if(e&&e[1])return e[1]}return""}(),L4=/Android.*(wv|.0.0.0)/.test(Re),wi=function(){if(CS)return kf;if(Ii){var e=Re.match(/OS (\d+)_(\d+)/i);if(e&&e[1]){var t=e[1];return e[2]&&(t+=".".concat(e[2])),t}}return""}(),O4=Number(wi.split(".")[0]),cl=kf==="15.1",ul=wi==="15.1",M4=(OS=Number(wi.split(".")[0]))===14||OS===13,ha=location.protocol==="file:"||location.hostname==="localhost"||location.hostname==="127.0.0.1",pa=function(){if(ge(il))try{il=window.localStorage}catch(e){_e.warn(e),il=!1}return il},Tf=new Map([[Tr,["Firefox",RS]],[rl,["Edg",AS]],[sl,["Chrome",D4]],[da,["Safari",kf]],[zr,["TBS",y4]],[lf,["XWEB",b4]],[df&&sf,["WeChat",S4]],[ff,["QQ(Win)",k4]],[pf,["QQ(Mobile)",PS]],[hf,["QQ(Mobile X5)",PS]],[mf,["QQ(Mac)",T4]],[vf,["QQ(iPad)",x4]],[gf,["MI",w4]],[_f,["HW",E4]],[bf,["Samsung",C4]],[al,["OPPO",R4]],[ol,["VIVO",A4]],[nl,["EDGE",v4]],[cf,["SogouMobile",g4]],[uf,["Sogou",_4]]]);function fa(){var e="unknown",t="unknown";return Tf.get(!0)&&(e=Tf.get(!0)[0],t=Tf.get(!0)[1]),{name:e,version:t}}var MS=function(e,t){return t?mo+"/"+e+"/"+t:mo+"/"+e+"/index.html"},N4=function(){if(!pa())return!1;var e=localStorage.getItem($p);e&&!function(t){var n=t.saveTime&&new Date().getTime()-t.saveTime>=Qb,a=!t.saveVersion||t.saveVersion!==pi;return n||a}(JSON.parse(e))||(_e.info("init debug info"),function(){var t=new XMLHttpRequest;if(t.open("GET","https://web.sdk.qcloud.com/trtc/webrtc/download/error-message/0.0.3/script.js",!1),t.send(null),t.readyState===4&&t.status===200){var n=document.createElement("script");n.type="text/javascript",n.text=t.responseText,document.body.appendChild(n),localStorage.setItem($p,JSON.stringify({message:t.responseText,saveTime:new Date().getTime(),saveVersion:pi})),document.body.removeChild(n)}}())};function ie(e){var t=e.key,n=e.data,a=e.link,i=e.addDocLink,r=i===void 0||i,o="",s="",c="";ln(xi[t])?o=xi[t](n):Vt(xi[t])&&(o=xi[t]);var u=function(){if(window.TRTC_ERROR_INFO&&window.TRTC_ERROR_LINK)return{TRTC_ERROR_INFO:window.TRTC_ERROR_INFO,TRTC_ERROR_LINK:window.TRTC_ERROR_LINK};var k=localStorage.getItem($p);if(k){k=JSON.parse(k);var w=document.createElement("script");w.type="text/javascript",w.text=k.message,document.body.appendChild(w);var A=window.TRTC_ERROR_INFO,p=window.TRTC_ERROR_LINK;return document.body.removeChild(w),{TRTC_ERROR_INFO:A,TRTC_ERROR_LINK:p}}return{}}(),d=u.TRTC_ERROR_INFO,g=u.TRTC_ERROR_LINK;a?c="".concat(a.className,".html#").concat(a.fnName):g&&g[t]&&(ln(g[t])?c=g[t](n):Vt(g[t])&&(c=g[t]));var I=o;return ma()&&(d&&d[t]&&(ln(d[t])?s=d[t](n):Vt(d[t])&&(s=d[t])),s&&(I=r?s+`
|
|
81
|
-
\u8BF7\u67E5\u770B\u6587\u6863: `+MS("zh-cn",c)+`
|
|
39
|
+
`},c.getDirection=function(a,s){for(var l=c.splitLines(a),u=0;u<l.length;u++)switch(l[u]){case"a=sendrecv":case"a=sendonly":case"a=recvonly":case"a=inactive":return l[u].substring(2)}return s?c.getDirection(s):"sendrecv"},c.getKind=function(a){return c.splitLines(a)[0].split(" ")[0].substring(2)},c.isRejected=function(a){return a.split(" ",2)[1]==="0"},c.parseMLine=function(a){var s=c.splitLines(a)[0].substring(2).split(" ");return{kind:s[0],port:parseInt(s[1],10),protocol:s[2],fmt:s.slice(3).join(" ")}},c.parseOLine=function(a){var s=c.matchPrefix(a,"o=")[0].substring(2).split(" ");return{username:s[0],sessionId:s[1],sessionVersion:parseInt(s[2],10),netType:s[3],addressType:s[4],address:s[5]}},c.isValidSDP=function(a){if(typeof a!="string"||a.length===0)return!1;for(var s=c.splitLines(a),l=0;l<s.length;l++)if(s[l].length<2||s[l].charAt(1)!=="=")return!1;return!0},(i===void 0?"undefined":o(i))==="object"&&(i.exports=c)},{}]},{},[1])(1)}({exports:{}});var Gi="4.15.21",bg={},vC=vg,gC=Wd,ou=Object.keys||function(e){return vC(e,gC)},_C=ye,yC=hs,bC=Pt,SC=Tt,kC=bn,TC=ou;bg.f=_C&&!yC?Object.defineProperties:function(e,t){SC(e);for(var n,i=kC(t),r=TC(t),o=r.length,c=0;o>c;)bC.f(e,n=r[c++],i[n]);return e};var su,Sg=An("document","documentElement"),xC=Tt,IC=bg,kg=Wd,wC=ee,CC=Sg,EC=vr,Tg=W("IE_PROTO"),Xd=function(){},xg=function(e){return"<script>"+e+"<\/script>"},Ig=function(e){e.write(xg("")),e.close();var t=e.parentWindow.Object;return e=null,t},cu=function(){try{su=new ActiveXObject("htmlfile")}catch(i){}var e,t;cu=typeof document!="undefined"?document.domain&&su?Ig(su):((t=EC("iframe")).style.display="none",CC.appendChild(t),t.src=String("javascript:"),(e=t.contentWindow.document).open(),e.write(xg("document.F=Object")),e.close(),e.F):Ig(su);for(var n=kg.length;n--;)delete cu.prototype[kg[n]];return cu()};wC[Tg]=!0;var Ba=Object.create||function(e,t){var n;return e!==null?(Xd.prototype=xC(e),n=new Xd,Xd.prototype=null,n[Tg]=e):n=cu(),t===void 0?n:IC.f(n,t)},RC=tt,AC=Ba,PC=Pt.f,Qd=RC("unscopables"),Yd=Array.prototype;Yd[Qd]==null&&PC(Yd,Qd,{configurable:!0,value:AC(null)});var zi,wg,Cg,uu=function(e){Yd[Qd][e]=!0},ks={},Eg=!ue(function(){function e(){}return e.prototype.constructor=null,Object.getPrototypeOf(new e)!==e.prototype}),DC=kt,OC=it,LC=Mt,MC=Eg,Rg=W("IE_PROTO"),$d=Object,NC=$d.prototype,Ts=MC?$d.getPrototypeOf:function(e){var t=LC(e);if(DC(t,Rg))return t[Rg];var n=t.constructor;return OC(n)&&t instanceof n?n.prototype:t instanceof $d?NC:null},UC=ue,VC=it,jC=at,Ag=Ts,BC=Qt,Zd=tt("iterator"),Pg=!1;[].keys&&("next"in(Cg=[].keys())?(wg=Ag(Ag(Cg)))!==Object.prototype&&(zi=wg):Pg=!0);var FC=!jC(zi)||UC(function(){var e={};return zi[Zd].call(e)!==e});FC&&(zi={}),VC(zi[Zd])||BC(zi,Zd,function(){return this});var eh={IteratorPrototype:zi,BUGGY_SAFARI_ITERATORS:Pg},HC=Pt.f,GC=kt,Dg=tt("toStringTag"),Wi=function(e,t,n){e&&!n&&(e=e.prototype),e&&!GC(e,Dg)&&HC(e,Dg,{configurable:!0,value:t})},zC=eh.IteratorPrototype,WC=Ba,JC=Ze,qC=Wi,KC=ks,XC=function(){return this},Og=function(e,t,n,i){var r=t+" Iterator";return e.prototype=WC(zC,{next:JC(+!i,n)}),qC(e,r,!1),KC[r]=XC,e},QC=it,YC=String,$C=TypeError,ZC=pe,eE=Tt,tE=function(e){if(typeof e=="object"||QC(e))return e;throw $C("Can't set "+YC(e)+" as a prototype")},Fa=Object.setPrototypeOf||("__proto__"in{}?function(){var e,t=!1,n={};try{(e=ZC(Object.getOwnPropertyDescriptor(Object.prototype,"__proto__").set))(n,[]),t=n instanceof Array}catch(i){}return function(i,r){return eE(i),tE(r),t?e(i,r):i.__proto__=r,i}}():void 0),nE=Le,rE=Ke,iE=it,aE=Og,Lg=Ts,Mg=Fa,oE=Wi,sE=Ln,th=Qt,cE=ks,uE=Yn.PROPER,lE=Yn.CONFIGURABLE,Ng=eh.IteratorPrototype,lu=eh.BUGGY_SAFARI_ITERATORS,xs=tt("iterator"),Ug="keys",Is="values",Vg="entries",dE=function(){return this},nh=function(e,t,n,i,r,o,c){aE(n,t,i);var a,s,l,u=function(T){if(T===r&&I)return I;if(!lu&&T in x)return x[T];switch(T){case Ug:case Is:case Vg:return function(){return new n(this,T)}}return function(){return new n(this)}},f=t+" Iterator",S=!1,x=e.prototype,E=x[xs]||x["@@iterator"]||r&&x[r],I=!lu&&E||u(r),m=t=="Array"&&x.entries||E;if(m&&(a=Lg(m.call(new e)))!==Object.prototype&&a.next&&(Lg(a)!==Ng&&(Mg?Mg(a,Ng):iE(a[xs])||th(a,xs,dE)),oE(a,f,!0)),uE&&r==Is&&E&&E.name!==Is&&(lE?sE(x,"name",Is):(S=!0,I=function(){return rE(E,this)})),r)if(s={values:u(Is),keys:o?I:u(Ug),entries:u(Vg)},c)for(l in s)(lu||S||!(l in x))&&th(x,l,s[l]);else nE({target:t,proto:!0,forced:lu||S},s);return x[xs]!==I&&th(x,xs,I,{name:r}),cE[t]=I,s},rh=function(e,t){return{value:e,done:t}},hE=bn,ih=uu,jg=ks,Bg=Xe,fE=Pt.f,pE=nh,Fg=rh,mE=ye,Hg="Array Iterator",vE=Bg.set,gE=Bg.getterFor(Hg),Gg=pE(Array,"Array",function(e,t){vE(this,{type:Hg,target:hE(e),index:0,kind:t})},function(){var e=gE(this),t=e.target,n=e.kind,i=e.index++;return!t||i>=t.length?(e.target=void 0,Fg(void 0,!0)):Fg(n=="keys"?i:n=="values"?t[i]:[i,t[i]],!1)},"values"),zg=jg.Arguments=jg.Array;if(ih("keys"),ih("values"),ih("entries"),mE&&zg.name!=="values")try{fE(zg,"name",{value:"values"})}catch(e){}var Wg={};Wg[tt("toStringTag")]="z";var ah=String(Wg)==="[object z]",_E=ah,yE=it,du=rt,bE=tt("toStringTag"),SE=Object,kE=du(function(){return arguments}())=="Arguments",Dr=_E?du:function(e){var t,n,i;return e===void 0?"Undefined":e===null?"Null":typeof(n=function(r,o){try{return r[o]}catch(c){}}(t=SE(e),bE))=="string"?n:kE?du(t):(i=du(t))=="Object"&&yE(t.callee)?"Arguments":i},TE=Dr,xE=ah?{}.toString:function(){return"[object "+TE(this)+"]"};ah||Qt(Object.prototype,"toString",xE,{unsafe:!0});var ws={exports:{}},oh={},IE=Da,wE=Pt,CE=Ze,Cs=function(e,t,n){var i=IE(t);i in e?wE.f(e,i,CE(0,n)):e[i]=n},Jg=ai,EE=nn,RE=Cs,AE=Array,PE=Math.max,hu=function(e,t,n){for(var i=EE(e),r=Jg(t,i),o=Jg(n===void 0?i:n,i),c=AE(PE(o-r,0)),a=0;r<o;r++,a++)RE(c,a,e[r]);return c.length=a,c},DE=rt,OE=bn,qg=ii.f,LE=hu,Kg=typeof window=="object"&&window&&Object.getOwnPropertyNames?Object.getOwnPropertyNames(window):[];oh.f=function(e){return Kg&&DE(e)=="Window"?function(t){try{return qg(t)}catch(n){return LE(Kg)}}(e):qg(OE(e))};var ME=ue(function(){if(typeof ArrayBuffer=="function"){var e=new ArrayBuffer(8);Object.isExtensible(e)&&Object.defineProperty(e,"a",{value:8})}}),NE=ue,UE=at,VE=rt,Xg=ME,fu=Object.isExtensible,Qg=NE(function(){fu(1)})||Xg?function(e){return!!UE(e)&&(!Xg||VE(e)!="ArrayBuffer")&&(!fu||fu(e))}:fu,jE=!ue(function(){return Object.isExtensible(Object.preventExtensions({}))}),BE=Le,FE=pe,HE=ee,GE=at,sh=kt,zE=Pt.f,Yg=ii,WE=oh,ch=Qg,JE=jE,$g=!1,Or=Ui("meta"),qE=0,uh=function(e){zE(e,Or,{value:{objectID:"O"+qE++,weakData:{}}})},KE=ws.exports={enable:function(){KE.enable=function(){},$g=!0;var e=Yg.f,t=FE([].splice),n={};n[Or]=1,e(n).length&&(Yg.f=function(i){for(var r=e(i),o=0,c=r.length;o<c;o++)if(r[o]===Or){t(r,o,1);break}return r},BE({target:"Object",stat:!0,forced:!0},{getOwnPropertyNames:WE.f}))},fastKey:function(e,t){if(!GE(e))return typeof e=="symbol"?e:(typeof e=="string"?"S":"P")+e;if(!sh(e,Or)){if(!ch(e))return"F";if(!t)return"E";uh(e)}return e[Or].objectID},getWeakData:function(e,t){if(!sh(e,Or)){if(!ch(e))return!0;if(!t)return!1;uh(e)}return e[Or].weakData},onFreeze:function(e){return JE&&$g&&ch(e)&&!sh(e,Or)&&uh(e),e}};HE[Or]=!0;var XE=Vt,QE=Me,YE=pe(pe.bind),Lr=function(e,t){return XE(e),t===void 0?e:QE?YE(e,t):function(){return e.apply(t,arguments)}},$E=ks,ZE=tt("iterator"),eR=Array.prototype,lh=function(e){return e!==void 0&&($E.Array===e||eR[ZE]===e)},tR=Dr,Zg=Xt,nR=Rt,rR=ks,iR=tt("iterator"),Es=function(e){if(!nR(e))return Zg(e,iR)||Zg(e,"@@iterator")||rR[tR(e)]},aR=Ke,oR=Vt,sR=Tt,cR=Xn,uR=Es,lR=TypeError,pu=function(e,t){var n=arguments.length<2?uR(e):t;if(oR(n))return sR(aR(n,e));throw lR(cR(e)+" is not iterable")},dR=Ke,e_=Tt,hR=Xt,t_=function(e,t,n){var i,r;e_(e);try{if(!(i=hR(e,"return"))){if(t==="throw")throw n;return n}i=dR(i,e)}catch(o){r=!0,i=o}if(t==="throw")throw n;if(r)throw i;return e_(i),n},fR=Lr,pR=Ke,mR=Tt,vR=Xn,gR=lh,_R=nn,n_=Sn,yR=pu,bR=Es,r_=t_,SR=TypeError,mu=function(e,t){this.stopped=e,this.result=t},i_=mu.prototype,Rs=function(e,t,n){var i,r,o,c,a,s,l,u=n&&n.that,f=!(!n||!n.AS_ENTRIES),S=!(!n||!n.IS_RECORD),x=!(!n||!n.IS_ITERATOR),E=!(!n||!n.INTERRUPTED),I=fR(t,u),m=function(v){return i&&r_(i,"normal",v),new mu(!0,v)},T=function(v){return f?(mR(v),E?I(v[0],v[1],m):I(v[0],v[1])):E?I(v,m):I(v)};if(S)i=e.iterator;else if(x)i=e;else{if(!(r=bR(e)))throw SR(vR(e)+" is not iterable");if(gR(r)){for(o=0,c=_R(e);c>o;o++)if((a=T(e[o]))&&n_(i_,a))return a;return new mu(!1)}i=yR(e,r)}for(s=S?e.next:i.next;!(l=pR(s,i)).done;){try{a=T(l.value)}catch(v){r_(i,"throw",v)}if(typeof a=="object"&&a&&n_(i_,a))return a}return new mu(!1)},kR=Sn,TR=TypeError,oi=function(e,t){if(kR(t,e))return e;throw TR("Incorrect invocation")},a_=tt("iterator"),o_=!1;try{var xR=0,s_={next:function(){return{done:!!xR++}},return:function(){o_=!0}};s_[a_]=function(){return this},Array.from(s_,function(){throw 2})}catch(e){}var vu=function(e,t){if(!t&&!o_)return!1;var n=!1;try{var i={};i[a_]=function(){return{next:function(){return{done:n=!0}}}},e(i)}catch(r){}return n},IR=it,wR=at,c_=Fa,gu=function(e,t,n){var i,r;return c_&&IR(i=t.constructor)&&i!==n&&wR(r=i.prototype)&&r!==n.prototype&&c_(e,r),e},CR=Le,ER=re,RR=pe,u_=Ss,AR=Qt,PR=ws.exports,DR=Rs,OR=oi,LR=it,MR=Rt,dh=at,hh=ue,NR=vu,UR=Wi,VR=gu,fh=function(e,t,n){var i=e.indexOf("Map")!==-1,r=e.indexOf("Weak")!==-1,o=i?"set":"add",c=ER[e],a=c&&c.prototype,s=c,l={},u=function(m){var T=RR(a[m]);AR(a,m,m=="add"?function(v){return T(this,v===0?0:v),this}:m=="delete"?function(v){return!(r&&!dh(v))&&T(this,v===0?0:v)}:m=="get"?function(v){return r&&!dh(v)?void 0:T(this,v===0?0:v)}:m=="has"?function(v){return!(r&&!dh(v))&&T(this,v===0?0:v)}:function(v,w){return T(this,v===0?0:v,w),this})};if(u_(e,!LR(c)||!(r||a.forEach&&!hh(function(){new c().entries().next()}))))s=n.getConstructor(t,e,i,o),PR.enable();else if(u_(e,!0)){var f=new s,S=f[o](r?{}:-0,1)!=f,x=hh(function(){f.has(1)}),E=NR(function(m){new c(m)}),I=!r&&hh(function(){for(var m=new c,T=5;T--;)m[o](T,T);return!m.has(-0)});E||((s=t(function(m,T){OR(m,a);var v=VR(new c,m,s);return MR(T)||DR(T,v[o],{that:v,AS_ENTRIES:i}),v})).prototype=a,a.constructor=s),(x||I)&&(u("delete"),u("has"),i&&u("get")),(I||S)&&u(o),r&&a.clear&&delete a.clear}return l[e]=s,CR({global:!0,constructor:!0,forced:s!=c},l),UR(s,e),r||n.setStrong(s,e,i),s},jR=Qt,As=function(e,t,n){for(var i in t)jR(e,i,t[i],n);return e},BR=An,FR=Pt,HR=ye,l_=tt("species"),Ps=function(e){var t=BR(e),n=FR.f;HR&&t&&!t[l_]&&n(t,l_,{configurable:!0,get:function(){return this}})},GR=Pt.f,zR=Ba,d_=As,WR=Lr,JR=oi,qR=Rt,KR=Rs,XR=nh,h_=rh,QR=Ps,Ds=ye,f_=ws.exports.fastKey,p_=Xe.set,ph=Xe.getterFor,m_={getConstructor:function(e,t,n,i){var r=e(function(l,u){JR(l,o),p_(l,{type:t,index:zR(null),first:void 0,last:void 0,size:0}),Ds||(l.size=0),qR(u)||KR(u,l[i],{that:l,AS_ENTRIES:n})}),o=r.prototype,c=ph(t),a=function(l,u,f){var S,x,E=c(l),I=s(l,u);return I?I.value=f:(E.last=I={index:x=f_(u,!0),key:u,value:f,previous:S=E.last,next:void 0,removed:!1},E.first||(E.first=I),S&&(S.next=I),Ds?E.size++:l.size++,x!=="F"&&(E.index[x]=I)),l},s=function(l,u){var f,S=c(l),x=f_(u);if(x!=="F")return S.index[x];for(f=S.first;f;f=f.next)if(f.key==u)return f};return d_(o,{clear:function(){for(var l=c(this),u=l.index,f=l.first;f;)f.removed=!0,f.previous&&(f.previous=f.previous.next=void 0),delete u[f.index],f=f.next;l.first=l.last=void 0,Ds?l.size=0:this.size=0},delete:function(l){var u=this,f=c(u),S=s(u,l);if(S){var x=S.next,E=S.previous;delete f.index[S.index],S.removed=!0,E&&(E.next=x),x&&(x.previous=E),f.first==S&&(f.first=x),f.last==S&&(f.last=E),Ds?f.size--:u.size--}return!!S},forEach:function(l){for(var u,f=c(this),S=WR(l,arguments.length>1?arguments[1]:void 0);u=u?u.next:f.first;)for(S(u.value,u.key,this);u&&u.removed;)u=u.previous},has:function(l){return!!s(this,l)}}),d_(o,n?{get:function(l){var u=s(this,l);return u&&u.value},set:function(l,u){return a(this,l===0?0:l,u)}}:{add:function(l){return a(this,l=l===0?0:l,l)}}),Ds&&GR(o,"size",{get:function(){return c(this).size}}),r},setStrong:function(e,t,n){var i=t+" Iterator",r=ph(t),o=ph(i);XR(e,t,function(c,a){p_(this,{type:i,target:c,state:r(c),kind:a,last:void 0})},function(){for(var c=o(this),a=c.kind,s=c.last;s&&s.removed;)s=s.previous;return c.target&&(c.last=s=s?s.next:c.state.first)?h_(a=="keys"?s.key:a=="values"?s.value:[s.key,s.value],!1):(c.target=void 0,h_(void 0,!0))},n?"entries":"values",!n,!0),QR(t)}};fh("Set",function(e){return function(){return e(this,arguments.length?arguments[0]:void 0)}},m_);var YR=Dr,$R=String,zt=function(e){if(YR(e)==="Symbol")throw TypeError("Cannot convert a Symbol value to a string");return $R(e)},mh=pe,ZR=$n,eA=zt,tA=pt,nA=mh("".charAt),v_=mh("".charCodeAt),rA=mh("".slice),g_=function(e){return function(t,n){var i,r,o=eA(tA(t)),c=ZR(n),a=o.length;return c<0||c>=a?e?"":void 0:(i=v_(o,c))<55296||i>56319||c+1===a||(r=v_(o,c+1))<56320||r>57343?e?nA(o,c):i:e?rA(o,c,c+2):r-56320+(i-55296<<10)+65536}},vh={codeAt:g_(!1),charAt:g_(!0)},iA=vh.charAt,aA=zt,__=Xe,oA=nh,y_=rh,b_="String Iterator",sA=__.set,cA=__.getterFor(b_);oA(String,"String",function(e){sA(this,{type:b_,string:aA(e),index:0})},function(){var e,t=cA(this),n=t.string,i=t.index;return i>=n.length?y_(void 0,!0):(e=iA(n,i),t.index+=e.length,y_(e,!1))});var S_={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},gh=vr("span").classList,k_=gh&&gh.constructor&&gh.constructor.prototype,T_=k_===Object.prototype?void 0:k_,x_=re,I_=S_,uA=T_,Os=Gg,_h=Ln,w_=tt,yh=w_("iterator"),C_=w_("toStringTag"),bh=Os.values,E_=function(e,t){if(e){if(e[yh]!==bh)try{_h(e,yh,bh)}catch(i){e[yh]=bh}if(e[C_]||_h(e,C_,t),I_[t]){for(var n in Os)if(e[n]!==Os[n])try{_h(e,n,Os[n])}catch(i){e[n]=Os[n]}}}};for(var Sh in I_)E_(x_[Sh]&&x_[Sh].prototype,Sh);E_(uA,"DOMTokenList");var lA=Me,R_=Function.prototype,A_=R_.apply,P_=R_.call,Ji=typeof Reflect=="object"&&Reflect.apply||(lA?P_.bind(A_):function(){return P_.apply(A_,arguments)}),Ha=pe([].slice),dA=TypeError,_u=function(e,t){if(e<t)throw dA("Not enough arguments");return e},kh=re,hA=Ji,fA=it,pA=Ha,mA=_u,vA=/MSIE .\./.test(Kn),gA=kh.Function,D_=function(e){return vA?function(t,n){var i=mA(arguments.length,1)>2,r=fA(t)?t:gA(t),o=i?pA(arguments,2):void 0;return e(i?function(){hA(r,this,o)}:r,n)}:e},O_={setTimeout:D_(kh.setTimeout),setInterval:D_(kh.setInterval)},L_=O_.setInterval;Le({global:!0,bind:!0,forced:re.setInterval!==L_},{setInterval:L_});var M_=O_.setTimeout;Le({global:!0,bind:!0,forced:re.setTimeout!==M_},{setTimeout:M_}),fh("Map",function(e){return function(){return e(this,arguments.length?arguments[0]:void 0)}},m_);var _A=rt,Ga=Array.isArray||function(e){return _A(e)=="Array"},yA=pe,bA=ue,N_=it,SA=Dr,kA=d,U_=function(){},TA=[],V_=An("Reflect","construct"),Th=/^\s*(?:class|function)\b/,xA=yA(Th.exec),IA=!Th.exec(U_),Ls=function(e){if(!N_(e))return!1;try{return V_(U_,TA,e),!0}catch(t){return!1}},j_=function(e){if(!N_(e))return!1;switch(SA(e)){case"AsyncFunction":case"GeneratorFunction":case"AsyncGeneratorFunction":return!1}try{return IA||!!xA(Th,kA(e))}catch(t){return!0}};j_.sham=!0;var yu=!V_||bA(function(){var e;return Ls(Ls.call)||!Ls(Object)||!Ls(function(){e=!0})||e})?j_:Ls,B_=Ga,wA=yu,CA=at,EA=tt("species"),F_=Array,RA=function(e){var t;return B_(e)&&(t=e.constructor,(wA(t)&&(t===F_||B_(t.prototype))||CA(t)&&(t=t[EA])===null)&&(t=void 0)),t===void 0?F_:t},xh=function(e,t){return new(RA(e))(t===0?0:t)},AA=Lr,PA=yn,DA=Mt,OA=nn,LA=xh,H_=pe([].push),si=function(e){var t=e==1,n=e==2,i=e==3,r=e==4,o=e==6,c=e==7,a=e==5||o;return function(s,l,u,f){for(var S,x,E=DA(s),I=PA(E),m=AA(l,u),T=OA(I),v=0,w=f||LA,L=t?w(s,T):n||c?w(s,0):void 0;T>v;v++)if((a||v in I)&&(x=m(S=I[v],v,E),e))if(t)L[v]=x;else if(x)switch(e){case 3:return!0;case 5:return S;case 6:return v;case 2:H_(L,S)}else switch(e){case 4:return!1;case 7:H_(L,S)}return o?-1:i||r?r:L}},rn={forEach:si(0),map:si(1),filter:si(2),some:si(3),every:si(4),find:si(5),findIndex:si(6),filterReject:si(7)},MA=ue,NA=pr,UA=tt("species"),Ms=function(e){return NA>=51||!MA(function(){var t=[];return(t.constructor={})[UA]=function(){return{foo:1}},t[e](Boolean).foo!==1})},VA=rn.map;Le({target:"Array",proto:!0,forced:!Ms("map")},{map:function(e){return VA(this,e,arguments.length>1?arguments[1]:void 0)}});var jA=ye,BA=Ga,FA=TypeError,HA=Object.getOwnPropertyDescriptor,GA=jA&&!function(){if(this!==void 0)return!0;try{Object.defineProperty([],"length",{writable:!1}).length=1}catch(e){return e instanceof TypeError}}(),zA=TypeError,G_=function(e){if(e>9007199254740991)throw zA("Maximum allowed index exceeded");return e},z_=Xn,WA=TypeError,W_=function(e,t){if(!delete e[t])throw WA("Cannot delete property "+z_(t)+" of "+z_(e))},JA=Le,qA=Mt,KA=ai,XA=$n,QA=nn,YA=GA?function(e,t){if(BA(e)&&!HA(e,"length").writable)throw FA("Cannot set read only .length");return e.length=t}:function(e,t){return e.length=t},$A=G_,ZA=xh,e2=Cs,Ih=W_,t2=Ms("splice"),n2=Math.max,r2=Math.min;JA({target:"Array",proto:!0,forced:!t2},{splice:function(e,t){var n,i,r,o,c,a,s=qA(this),l=QA(s),u=KA(e,l),f=arguments.length;for(f===0?n=i=0:f===1?(n=0,i=l-u):(n=f-2,i=r2(n2(XA(t),0),l-u)),$A(l+n-i),r=ZA(s,i),o=0;o<i;o++)(c=u+o)in s&&e2(r,o,s[c]);if(r.length=i,n<i){for(o=u;o<l-i;o++)a=o+n,(c=o+i)in s?s[a]=s[c]:Ih(s,a);for(o=l;o>l-i+n;o--)Ih(s,o-1)}else if(n>i)for(o=l-i;o>u;o--)a=o+n-1,(c=o+i-1)in s?s[a]=s[c]:Ih(s,a);for(o=0;o<n;o++)s[o+u]=arguments[o+2];return YA(s,l-i+n),r}});var i2=ue,Ns=function(e,t){var n=[][e];return!!n&&i2(function(){n.call(null,t||function(){return 1},1)})},a2=rn.forEach,wh=Ns("forEach")?[].forEach:function(e){return a2(this,e,arguments.length>1?arguments[1]:void 0)};Le({target:"Array",proto:!0,forced:[].forEach!=wh},{forEach:wh});var J_=re,q_=S_,o2=T_,Ch=wh,s2=Ln,K_=function(e){if(e&&e.forEach!==Ch)try{s2(e,"forEach",Ch)}catch(t){e.forEach=Ch}};for(var Eh in q_)q_[Eh]&&K_(J_[Eh]&&J_[Eh].prototype);K_(o2);var c2=Le,u2=ue,l2=Ga,d2=at,h2=Mt,f2=nn,X_=G_,Q_=Cs,p2=xh,m2=Ms,v2=pr,Y_=tt("isConcatSpreadable"),g2=v2>=51||!u2(function(){var e=[];return e[Y_]=!1,e.concat()[0]!==e}),_2=m2("concat"),y2=function(e){if(!d2(e))return!1;var t=e[Y_];return t!==void 0?!!t:l2(e)};c2({target:"Array",proto:!0,arity:1,forced:!g2||!_2},{concat:function(e){var t,n,i,r,o,c=h2(this),a=p2(c,0),s=0;for(t=-1,i=arguments.length;t<i;t++)if(y2(o=t===-1?c:arguments[t]))for(r=f2(o),X_(s+r),n=0;n<r;n++,s++)n in o&&Q_(a,s,o[n]);else X_(s+1),Q_(a,s++,o);return a.length=s,a}});var b2=Le,S2=yn,k2=bn,T2=Ns,x2=pe([].join),I2=S2!=Object,w2=T2("join",",");b2({target:"Array",proto:!0,forced:I2||!w2},{join:function(e){return x2(k2(this),e===void 0?",":e)}});var C2=rn.filter;Le({target:"Array",proto:!0,forced:!Ms("filter")},{filter:function(e){return C2(this,e,arguments.length>1?arguments[1]:void 0)}});var $_=pe,E2=Qt,Rh=Date.prototype,Z_="Invalid Date",R2="toString",A2=$_(Rh.toString),P2=$_(Rh.getTime);String(new Date(NaN))!=Z_&&E2(Rh,R2,function(){var e=P2(this);return e==e?A2(this):Z_});var D2=$n,O2=zt,L2=pt,M2=RangeError,ey=function(e){var t=O2(L2(this)),n="",i=D2(e);if(i<0||i==1/0)throw M2("Wrong number of repetitions");for(;i>0;(i>>>=1)&&(t+=t))1&i&&(n+=t);return n},ty=pe,N2=yr,ny=zt,U2=pt,V2=ty(ey),j2=ty("".slice),B2=Math.ceil,ry=function(e){return function(t,n,i){var r,o,c=ny(U2(t)),a=N2(n),s=c.length,l=i===void 0?" ":ny(i);return a<=s||l==""?c:((o=V2(l,B2((r=a-s)/l.length))).length>r&&(o=j2(o,0,r)),e?c+o:o+c)}},F2={start:ry(!1),end:ry(!0)},H2=/Version\/10(?:\.\d+){1,2}(?: [\w./]+)?(?: Mobile\/\w+)? Safari\//.test(Kn),G2=F2.start;Le({target:"String",proto:!0,forced:H2},{padStart:function(e){return G2(this,e,arguments.length>1?arguments[1]:void 0)}});var z2=Tt,iy=function(){var e=z2(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},Ah=ue,Ph=re.RegExp,Dh=Ah(function(){var e=Ph("a","y");return e.lastIndex=2,e.exec("abcd")!=null}),W2=Dh||Ah(function(){return!Ph("a","y").sticky}),ay={BROKEN_CARET:Dh||Ah(function(){var e=Ph("^r","gy");return e.lastIndex=2,e.exec("str")!=null}),MISSED_STICKY:W2,UNSUPPORTED_Y:Dh},J2=ue,q2=re.RegExp,oy=J2(function(){var e=q2(".","s");return!(e.dotAll&&e.exec(`
|
|
40
|
+
`)&&e.flags==="s")}),K2=ue,X2=re.RegExp,sy=K2(function(){var e=X2("(?<a>b)","g");return e.exec("b").groups.a!=="b"||"b".replace(e,"$<a>c")!=="bc"}),za=Ke,bu=pe,Q2=zt,Y2=iy,$2=ay,Z2=Pr.exports,eP=Ba,tP=Xe.get,nP=oy,rP=sy,iP=Z2("native-string-replace",String.prototype.replace),Su=RegExp.prototype.exec,Oh=Su,aP=bu("".charAt),oP=bu("".indexOf),sP=bu("".replace),Lh=bu("".slice),Mh=function(){var e=/a/,t=/b*/g;return za(Su,e,"a"),za(Su,t,"a"),e.lastIndex!==0||t.lastIndex!==0}(),cy=$2.BROKEN_CARET,Nh=/()??/.exec("")[1]!==void 0;(Mh||Nh||cy||nP||rP)&&(Oh=function(e){var t,n,i,r,o,c,a,s=this,l=tP(s),u=Q2(e),f=l.raw;if(f)return f.lastIndex=s.lastIndex,t=za(Oh,f,u),s.lastIndex=f.lastIndex,t;var S=l.groups,x=cy&&s.sticky,E=za(Y2,s),I=s.source,m=0,T=u;if(x&&(E=sP(E,"y",""),oP(E,"g")===-1&&(E+="g"),T=Lh(u,s.lastIndex),s.lastIndex>0&&(!s.multiline||s.multiline&&aP(u,s.lastIndex-1)!==`
|
|
41
|
+
`)&&(I="(?: "+I+")",T=" "+T,m++),n=new RegExp("^(?:"+I+")",E)),Nh&&(n=new RegExp("^"+I+"$(?!\\s)",E)),Mh&&(i=s.lastIndex),r=za(Su,x?n:s,T),x?r?(r.input=Lh(r.input,m),r[0]=Lh(r[0],m),r.index=s.lastIndex,s.lastIndex+=r[0].length):s.lastIndex=0:Mh&&r&&(s.lastIndex=s.global?r.index+r[0].length:i),Nh&&r&&r.length>1&&za(iP,r[0],n,function(){for(o=1;o<arguments.length-2;o++)arguments[o]===void 0&&(r[o]=void 0)}),r&&S)for(r.groups=c=eP(null),o=0;o<S.length;o++)c[(a=S[o])[0]]=r[a[1]];return r});var ku=Oh;Le({target:"RegExp",proto:!0,forced:/./.exec!==ku},{exec:ku});var uy=pe,ly=Qt,cP=ku,dy=ue,hy=tt,uP=Ln,lP=hy("species"),Uh=RegExp.prototype,Vh=function(e,t,n,i){var r=hy(e),o=!dy(function(){var l={};return l[r]=function(){return 7},""[e](l)!=7}),c=o&&!dy(function(){var l=!1,u=/a/;return e==="split"&&((u={}).constructor={},u.constructor[lP]=function(){return u},u.flags="",u[r]=/./[r]),u.exec=function(){return l=!0,null},u[r](""),!l});if(!o||!c||n){var a=uy(/./[r]),s=t(r,""[e],function(l,u,f,S,x){var E=uy(l),I=u.exec;return I===cP||I===Uh.exec?o&&!x?{done:!0,value:a(u,f,S)}:{done:!0,value:E(f,u,S)}:{done:!1}});ly(String.prototype,e,s[0]),ly(Uh,r,s[1])}i&&uP(Uh[r],"sham",!0)},dP=vh.charAt,fy=function(e,t,n){return t+(n?dP(e,t).length:1)},jh=pe,hP=Mt,fP=Math.floor,Bh=jh("".charAt),pP=jh("".replace),Fh=jh("".slice),mP=/\$([$&'`]|\d{1,2}|<[^>]*>)/g,vP=/\$([$&'`]|\d{1,2})/g,py=Ke,gP=Tt,_P=it,yP=rt,bP=ku,SP=TypeError,Hh=function(e,t){var n=e.exec;if(_P(n)){var i=py(n,e,t);return i!==null&&gP(i),i}if(yP(e)==="RegExp")return py(bP,e,t);throw SP("RegExp#exec called on incompatible receiver")},kP=Ji,my=Ke,Tu=pe,TP=Vh,xP=ue,IP=Tt,wP=it,CP=Rt,EP=$n,RP=yr,Wa=zt,AP=pt,PP=fy,DP=Xt,OP=function(e,t,n,i,r,o){var c=n+e.length,a=i.length,s=vP;return r!==void 0&&(r=hP(r),s=mP),pP(o,s,function(l,u){var f;switch(Bh(u,0)){case"$":return"$";case"&":return e;case"`":return Fh(t,0,n);case"'":return Fh(t,c);case"<":f=r[Fh(u,1,-1)];break;default:var S=+u;if(S===0)return l;if(S>a){var x=fP(S/10);return x===0?l:x<=a?i[x-1]===void 0?Bh(u,1):i[x-1]+Bh(u,1):l}f=i[S-1]}return f===void 0?"":f})},LP=Hh,Gh=tt("replace"),MP=Math.max,NP=Math.min,UP=Tu([].concat),zh=Tu([].push),vy=Tu("".indexOf),gy=Tu("".slice),VP="a".replace(/./,"$0")==="$0",_y=!!/./[Gh]&&/./[Gh]("a","$0")==="",jP=!xP(function(){var e=/./;return e.exec=function(){var t=[];return t.groups={a:"7"},t},"".replace(e,"$<a>")!=="7"});TP("replace",function(e,t,n){var i=_y?"$":"$0";return[function(r,o){var c=AP(this),a=CP(r)?void 0:DP(r,Gh);return a?my(a,r,c,o):my(t,Wa(c),r,o)},function(r,o){var c=IP(this),a=Wa(r);if(typeof o=="string"&&vy(o,i)===-1&&vy(o,"$<")===-1){var s=n(t,c,a,o);if(s.done)return s.value}var l=wP(o);l||(o=Wa(o));var u=c.global;if(u){var f=c.unicode;c.lastIndex=0}for(var S=[];;){var x=LP(c,a);if(x===null||(zh(S,x),!u))break;Wa(x[0])===""&&(c.lastIndex=PP(a,RP(c.lastIndex),f))}for(var E,I="",m=0,T=0;T<S.length;T++){for(var v=Wa((x=S[T])[0]),w=MP(NP(EP(x.index),a.length),0),L=[],N=1;N<x.length;N++)zh(L,(E=x[N])===void 0?E:String(E));var V=x.groups;if(l){var _=UP([v],L,w,a);V!==void 0&&zh(_,V);var b=Wa(kP(o,void 0,_))}else b=OP(v,a,w,L,V,o);w>=m&&(I+=gy(a,m,w)+b,m=w+v.length)}return I+gy(a,m)}]},!jP||!VP||_y);var BP=Ke,FP=kt,HP=Sn,GP=iy,yy=RegExp.prototype,by=function(e){var t=e.flags;return t!==void 0||"flags"in yy||FP(e,"flags")||!HP(yy,e)?t:BP(GP,e)},zP=Yn.PROPER,WP=Qt,JP=Tt,Sy=zt,qP=ue,KP=by,ky="toString",Ty=RegExp.prototype.toString,XP=qP(function(){return Ty.call({source:"a",flags:"b"})!="/a/b"}),QP=zP&&Ty.name!=ky;(XP||QP)&&WP(RegExp.prototype,ky,function(){var e=JP(this);return"/"+Sy(e.source)+"/"+Sy(KP(e))},{unsafe:!0});var YP=ue,$P=tt("iterator"),xy=!YP(function(){var e=new URL("b?a=1&b=2&c=3","http://a"),t=e.searchParams,n="";return e.pathname="c%20d",t.forEach(function(i,r){t.delete("b"),n+=r+i}),!t.sort||e.href!=="http://a/c%20d?a=1&c=3"||t.get("c")!=="3"||String(new URLSearchParams("?a=1"))!=="a=1"||!t[$P]||new URL("https://a@b").username!=="a"||new URLSearchParams(new URLSearchParams("a=b")).get("a")!=="b"||new URL("http://\u0442\u0435\u0441\u0442").host!=="xn--e1aybc"||new URL("http://a#\u0431").hash!=="#%D0%B1"||n!=="a1c3"||new URL("http://x",void 0).host!=="x"}),Iy=hu,ZP=Math.floor,Wh=function(e,t){var n=e.length,i=ZP(n/2);return n<8?eD(e,t):tD(e,Wh(Iy(e,0,i),t),Wh(Iy(e,i),t),t)},eD=function(e,t){for(var n,i,r=e.length,o=1;o<r;){for(i=o,n=e[o];i&&t(e[i-1],n)>0;)e[i]=e[--i];i!==o++&&(e[i]=n)}return e},tD=function(e,t,n,i){for(var r=t.length,o=n.length,c=0,a=0;c<r||a<o;)e[c+a]=c<r&&a<o?i(t[c],n[a])<=0?t[c++]:n[a++]:c<r?t[c++]:n[a++];return e},wy=Wh,Jh=Le,Ja=re,xu=Ke,br=pe,nD=ye,Cy=xy,Ey=Qt,rD=As,iD=Wi,aD=Og,qh=Xe,Ry=oi,Kh=it,oD=kt,sD=Lr,cD=Dr,uD=Tt,Ay=at,Tn=zt,lD=Ba,Py=Ze,Xh=pu,dD=Es,qa=_u,hD=wy,fD=tt("iterator"),Iu="URLSearchParams",Dy="URLSearchParamsIterator",Oy=qh.set,Zn=qh.getterFor(Iu),pD=qh.getterFor(Dy),mD=Object.getOwnPropertyDescriptor,Qh=function(e){if(!nD)return Ja[e];var t=mD(Ja,e);return t&&t.value},Ly=Qh("fetch"),wu=Qh("Request"),Us=Qh("Headers"),Yh=wu&&wu.prototype,My=Us&&Us.prototype,vD=Ja.RegExp,gD=Ja.TypeError,Ny=Ja.decodeURIComponent,_D=Ja.encodeURIComponent,yD=br("".charAt),Uy=br([].join),qi=br([].push),$h=br("".replace),bD=br([].shift),Vy=br([].splice),jy=br("".split),SD=br("".slice),kD=/\+/g,By=Array(4),TD=function(e){return By[e-1]||(By[e-1]=vD("((?:%[\\da-f]{2}){"+e+"})","gi"))},xD=function(e){try{return Ny(e)}catch(t){return e}},Fy=function(e){var t=$h(e,kD," "),n=4;try{return Ny(t)}catch(i){for(;n;)t=$h(t,TD(n--),xD);return t}},ID=/[!'()~]|%20/g,wD={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+"},CD=function(e){return wD[e]},Hy=function(e){return $h(_D(e),ID,CD)},Zh=aD(function(e,t){Oy(this,{type:Dy,iterator:Xh(Zn(e).entries),kind:t})},"Iterator",function(){var e=pD(this),t=e.kind,n=e.iterator.next(),i=n.value;return n.done||(n.value=t==="keys"?i.key:t==="values"?i.value:[i.key,i.value]),n},!0),Gy=function(e){this.entries=[],this.url=null,e!==void 0&&(Ay(e)?this.parseObject(e):this.parseQuery(typeof e=="string"?yD(e,0)==="?"?SD(e,1):e:Tn(e)))};Gy.prototype={type:Iu,bindURL:function(e){this.url=e,this.update()},parseObject:function(e){var t,n,i,r,o,c,a,s=dD(e);if(s)for(n=(t=Xh(e,s)).next;!(i=xu(n,t)).done;){if(o=(r=Xh(uD(i.value))).next,(c=xu(o,r)).done||(a=xu(o,r)).done||!xu(o,r).done)throw gD("Expected sequence with length 2");qi(this.entries,{key:Tn(c.value),value:Tn(a.value)})}else for(var l in e)oD(e,l)&&qi(this.entries,{key:l,value:Tn(e[l])})},parseQuery:function(e){if(e)for(var t,n,i=jy(e,"&"),r=0;r<i.length;)(t=i[r++]).length&&(n=jy(t,"="),qi(this.entries,{key:Fy(bD(n)),value:Fy(Uy(n,"="))}))},serialize:function(){for(var e,t=this.entries,n=[],i=0;i<t.length;)e=t[i++],qi(n,Hy(e.key)+"="+Hy(e.value));return Uy(n,"&")},update:function(){this.entries.length=0,this.parseQuery(this.url.query)},updateURL:function(){this.url&&this.url.update()}};var Cu=function(){Ry(this,Vs);var e=arguments.length>0?arguments[0]:void 0;Oy(this,new Gy(e))},Vs=Cu.prototype;if(rD(Vs,{append:function(e,t){qa(arguments.length,2);var n=Zn(this);qi(n.entries,{key:Tn(e),value:Tn(t)}),n.updateURL()},delete:function(e){qa(arguments.length,1);for(var t=Zn(this),n=t.entries,i=Tn(e),r=0;r<n.length;)n[r].key===i?Vy(n,r,1):r++;t.updateURL()},get:function(e){qa(arguments.length,1);for(var t=Zn(this).entries,n=Tn(e),i=0;i<t.length;i++)if(t[i].key===n)return t[i].value;return null},getAll:function(e){qa(arguments.length,1);for(var t=Zn(this).entries,n=Tn(e),i=[],r=0;r<t.length;r++)t[r].key===n&&qi(i,t[r].value);return i},has:function(e){qa(arguments.length,1);for(var t=Zn(this).entries,n=Tn(e),i=0;i<t.length;)if(t[i++].key===n)return!0;return!1},set:function(e,t){qa(arguments.length,1);for(var n,i=Zn(this),r=i.entries,o=!1,c=Tn(e),a=Tn(t),s=0;s<r.length;s++)(n=r[s]).key===c&&(o?Vy(r,s--,1):(o=!0,n.value=a));o||qi(r,{key:c,value:a}),i.updateURL()},sort:function(){var e=Zn(this);hD(e.entries,function(t,n){return t.key>n.key?1:-1}),e.updateURL()},forEach:function(e){for(var t,n=Zn(this).entries,i=sD(e,arguments.length>1?arguments[1]:void 0),r=0;r<n.length;)i((t=n[r++]).value,t.key,this)},keys:function(){return new Zh(this,"keys")},values:function(){return new Zh(this,"values")},entries:function(){return new Zh(this,"entries")}},{enumerable:!0}),Ey(Vs,fD,Vs.entries,{name:"entries"}),Ey(Vs,"toString",function(){return Zn(this).serialize()},{enumerable:!0}),iD(Cu,Iu),Jh({global:!0,constructor:!0,forced:!Cy},{URLSearchParams:Cu}),!Cy&&Kh(Us)){var ED=br(My.has),RD=br(My.set),zy=function(e){if(Ay(e)){var t,n=e.body;if(cD(n)===Iu)return t=e.headers?new Us(e.headers):new Us,ED(t,"content-type")||RD(t,"content-type","application/x-www-form-urlencoded;charset=UTF-8"),lD(e,{body:Py(0,Tn(n)),headers:Py(0,t)})}return e};if(Kh(Ly)&&Jh({global:!0,enumerable:!0,dontCallGetSet:!0,forced:!0},{fetch:function(e){return Ly(e,arguments.length>1?zy(arguments[1]):{})}}),Kh(wu)){var ef=function(e){return Ry(this,Yh),new wu(e,arguments.length>1?zy(arguments[1]):{})};Yh.constructor=ef,ef.prototype=Yh,Jh({global:!0,constructor:!0,dontCallGetSet:!0,forced:!0},{Request:ef})}}var AD={URLSearchParams:Cu,getState:Zn},PD=Object.is||function(e,t){return e===t?e!==0||1/e==1/t:e!=e&&t!=t},DD=Ke,OD=Tt,LD=Rt,MD=pt,Wy=PD,Jy=zt,ND=Xt,UD=Hh;Vh("search",function(e,t,n){return[function(i){var r=MD(this),o=LD(i)?void 0:ND(i,e);return o?DD(o,i,r):new RegExp(i)[e](Jy(r))},function(i){var r=OD(this),o=Jy(i),c=n(t,r,o);if(c.done)return c.value;var a=r.lastIndex;Wy(a,0)||(r.lastIndex=0);var s=UD(r,o);return Wy(r.lastIndex,a)||(r.lastIndex=a),s===null?-1:s.index}]}),new Date().getTime();var tf=0,an=function(){return new Date().getTime()+tf},qy=function(){var e=new Date;return e.setTime(an()),e.toLocaleString()},VD=Ke,jD=Tt,BD=Rt,FD=yr,nf=zt,HD=pt,GD=Xt,zD=fy,Ky=Hh;Vh("match",function(e,t,n){return[function(i){var r=HD(this),o=BD(i)?void 0:GD(i,e);return o?VD(o,i,r):new RegExp(i)[e](nf(r))},function(i){var r=jD(this),o=nf(i),c=n(t,r,o);if(c.done)return c.value;if(!r.global)return Ky(r,o);var a=r.unicode;r.lastIndex=0;for(var s,l=[],u=0;(s=Ky(r,o))!==null;){var f=nf(s[0]);l[u]=f,f===""&&(r.lastIndex=zD(o,FD(r.lastIndex),a)),u++}return u===0?null:l}]});var WD=at,JD=rt,qD=tt("match"),Xy=function(e){var t;return WD(e)&&((t=e[qD])!==void 0?!!t:JD(e)=="RegExp")},KD=Pt.f,XD=ye,rf=re,js=pe,QD=Ss,YD=gu,$D=Ln,ZD=ii.f,Qy=Sn,eO=Xy,Yy=zt,tO=by,$y=ay,nO=function(e,t,n){n in e||KD(e,n,{configurable:!0,get:function(){return t[n]},set:function(i){t[n]=i}})},rO=Qt,iO=ue,aO=kt,oO=Xe.enforce,sO=Ps,Zy=oy,e0=sy,cO=tt("match"),ci=rf.RegExp,Ka=ci.prototype,uO=rf.SyntaxError,lO=js(Ka.exec),Eu=js("".charAt),t0=js("".replace),n0=js("".indexOf),dO=js("".slice),hO=/^\?<[^\s\d!#%&*+<=>@^][^\s!#%&*+<=>@^]*>/,Ki=/a/g,af=/a/g,fO=new ci(Ki)!==Ki,r0=$y.MISSED_STICKY,pO=$y.UNSUPPORTED_Y,mO=XD&&(!fO||r0||Zy||e0||iO(function(){return af[cO]=!1,ci(Ki)!=Ki||ci(af)==af||ci(Ki,"i")!="/a/i"}));if(QD("RegExp",mO)){for(var Xi=function(e,t){var n,i,r,o,c,a,s=Qy(Ka,this),l=eO(e),u=t===void 0,f=[],S=e;if(!s&&l&&u&&e.constructor===Xi)return e;if((l||Qy(Ka,e))&&(e=e.source,u&&(t=tO(S))),e=e===void 0?"":Yy(e),t=t===void 0?"":Yy(t),S=e,Zy&&"dotAll"in Ki&&(i=!!t&&n0(t,"s")>-1)&&(t=t0(t,/s/g,"")),n=t,r0&&"sticky"in Ki&&(r=!!t&&n0(t,"y")>-1)&&pO&&(t=t0(t,/y/g,"")),e0&&(o=function(x){for(var E,I=x.length,m=0,T="",v=[],w={},L=!1,N=!1,V=0,_="";m<=I;m++){if((E=Eu(x,m))==="\\")E+=Eu(x,++m);else if(E==="]")L=!1;else if(!L)switch(!0){case E==="[":L=!0;break;case E==="(":lO(hO,dO(x,m+1))&&(m+=2,N=!0),T+=E,V++;continue;case(E===">"&&N):if(_===""||aO(w,_))throw new uO("Invalid capture group name");w[_]=!0,v[v.length]=[_,V],N=!1,_="";continue}N?_+=E:T+=E}return[T,v]}(e),e=o[0],f=o[1]),c=YD(ci(e,t),s?this:Ka,Xi),(i||r||f.length)&&(a=oO(c),i&&(a.dotAll=!0,a.raw=Xi(function(x){for(var E,I=x.length,m=0,T="",v=!1;m<=I;m++)(E=Eu(x,m))!=="\\"?v||E!=="."?(E==="["?v=!0:E==="]"&&(v=!1),T+=E):T+="[\\s\\S]":T+=E+Eu(x,++m);return T}(e),n)),r&&(a.sticky=!0),f.length&&(a.groups=f)),e!==S)try{$D(c,"source",S===""?"(?:)":S)}catch(x){}return c},i0=ZD(ci),a0=0;i0.length>a0;)nO(Xi,ci,i0[a0++]);Ka.constructor=Xi,Xi.prototype=Ka,rO(rf,"RegExp",Xi,{constructor:!0})}sO("RegExp");var o0=pe(1 .valueOf),s0=`
|
|
42
|
+
\v\f\r \xA0\u1680\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028\u2029\uFEFF`,vO=pt,gO=zt,c0=pe("".replace),Ru=`[
|
|
43
|
+
\v\f\r \xA0\u1680\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028\u2029\uFEFF]`,_O=RegExp("^"+Ru+Ru+"*"),yO=RegExp(Ru+Ru+"*$"),of=function(e){return function(t){var n=gO(vO(t));return 1&e&&(n=c0(n,_O,"")),2&e&&(n=c0(n,yO,"")),n}},Au={start:of(1),end:of(2),trim:of(3)},bO=ye,sf=re,u0=pe,SO=Ss,kO=Qt,l0=kt,TO=gu,xO=Sn,IO=Li,d0=Vi,wO=ue,CO=ii.f,EO=be.f,RO=Pt.f,AO=o0,PO=Au.trim,h0="Number",ui=sf.Number,cf=ui.prototype,DO=sf.TypeError,OO=u0("".slice),Pu=u0("".charCodeAt),LO=function(e){var t=d0(e,"number");return typeof t=="bigint"?t:MO(t)},MO=function(e){var t,n,i,r,o,c,a,s,l=d0(e,"number");if(IO(l))throw DO("Cannot convert a Symbol value to a number");if(typeof l=="string"&&l.length>2){if(l=PO(l),(t=Pu(l,0))===43||t===45){if((n=Pu(l,2))===88||n===120)return NaN}else if(t===48){switch(Pu(l,1)){case 66:case 98:i=2,r=49;break;case 79:case 111:i=8,r=55;break;default:return+l}for(c=(o=OO(l,2)).length,a=0;a<c;a++)if((s=Pu(o,a))<48||s>r)return NaN;return parseInt(o,i)}}return+l};if(SO(h0,!ui(" 0o1")||!ui("0b1")||ui("+0x1"))){for(var Du,Xa=function(e){var t=arguments.length<1?0:ui(LO(e)),n=this;return xO(cf,n)&&wO(function(){AO(n)})?TO(Object(t),n,Xa):t},f0=bO?CO(ui):"MAX_VALUE,MIN_VALUE,NaN,NEGATIVE_INFINITY,POSITIVE_INFINITY,EPSILON,MAX_SAFE_INTEGER,MIN_SAFE_INTEGER,isFinite,isInteger,isNaN,isSafeInteger,parseFloat,parseInt,fromString,range".split(","),uf=0;f0.length>uf;uf++)l0(ui,Du=f0[uf])&&!l0(Xa,Du)&&RO(Xa,Du,EO(ui,Du));Xa.prototype=cf,cf.constructor=Xa,kO(sf,h0,Xa,{constructor:!0})}var NO=ys.includes,UO=uu;Le({target:"Array",proto:!0,forced:ue(function(){return!Array(1).includes()})},{includes:function(e){return NO(this,e,arguments.length>1?arguments[1]:void 0)}}),UO("includes");var VO=Xy,jO=TypeError,p0=function(e){if(VO(e))throw jO("The method doesn't accept regular expressions");return e},BO=tt("match"),m0=function(e){var t=/./;try{"/./"[e](t)}catch(n){try{return t[BO]=!1,"/./"[e](t)}catch(i){}}return!1},FO=Le,HO=p0,GO=pt,v0=zt,zO=m0,WO=pe("".indexOf);FO({target:"String",proto:!0,forced:!zO("includes")},{includes:function(e){return!!~WO(v0(GO(this)),v0(HO(e)),arguments.length>1?arguments[1]:void 0)}});var JO=Le,qO=ys.indexOf,KO=Ns,lf=pe([].indexOf),g0=!!lf&&1/lf([1],1,-0)<0,XO=KO("indexOf");JO({target:"Array",proto:!0,forced:g0||!XO},{indexOf:function(e){var t=arguments.length>1?arguments[1]:void 0;return g0?lf(this,e,t)||0:qO(this,e,t)}});var QO=Mt,_0=Ts,YO=Eg;Le({target:"Object",stat:!0,forced:ue(function(){_0(1)}),sham:!YO},{getPrototypeOf:function(e){return _0(QO(e))}});var $O=Ji,ZO=Vt,eL=Tt;Le({target:"Reflect",stat:!0,forced:!ue(function(){Reflect.apply(function(){})})},{apply:function(e,t,n){return $O(ZO(e),t,eL(n))}});var tL=ye,nL=Yn.EXISTS,y0=pe,rL=Pt.f,b0=Function.prototype,iL=y0(b0.toString),S0=/function\b(?:\s|\/\*[\S\s]*?\*\/|\/\/[^\n\r]*[\n\r]+)*([^\s(/]*)/,aL=y0(S0.exec);tL&&!nL&&rL(b0,"name",{configurable:!0,get:function(){try{return aL(S0,iL(this))[1]}catch(e){return""}}});var oL=Le,k0=Date,sL=pe(k0.prototype.getTime);oL({target:"Date",stat:!0},{now:function(){return sL(new k0)}});var Bs,Qa,T0,df,Fs=rt(re.process)=="process",cL=yu,uL=Xn,lL=TypeError,x0=function(e){if(cL(e))return e;throw lL(uL(e)+" is not a constructor")},I0=Tt,dL=x0,hL=Rt,fL=tt("species"),Ou=function(e,t){var n,i=I0(e).constructor;return i===void 0||hL(n=I0(i)[fL])?t:dL(n)},w0=/(?:ipad|iphone|ipod).*applewebkit/i.test(Kn),xn=re,pL=Ji,mL=Lr,C0=it,vL=kt,gL=ue,E0=Sg,_L=Ha,R0=vr,yL=_u,bL=w0,SL=Fs,hf=xn.setImmediate,ff=xn.clearImmediate,kL=xn.process,pf=xn.Dispatch,TL=xn.Function,A0=xn.MessageChannel,xL=xn.String,mf=0,Hs={},IL="onreadystatechange";try{Bs=xn.location}catch(e){}var vf=function(e){if(vL(Hs,e)){var t=Hs[e];delete Hs[e],t()}},gf=function(e){return function(){vf(e)}},P0=function(e){vf(e.data)},D0=function(e){xn.postMessage(xL(e),Bs.protocol+"//"+Bs.host)};hf&&ff||(hf=function(e){yL(arguments.length,1);var t=C0(e)?e:TL(e),n=_L(arguments,1);return Hs[++mf]=function(){pL(t,void 0,n)},Qa(mf),mf},ff=function(e){delete Hs[e]},SL?Qa=function(e){kL.nextTick(gf(e))}:pf&&pf.now?Qa=function(e){pf.now(gf(e))}:A0&&!bL?(df=(T0=new A0).port2,T0.port1.onmessage=P0,Qa=mL(df.postMessage,df)):xn.addEventListener&&C0(xn.postMessage)&&!xn.importScripts&&Bs&&Bs.protocol!=="file:"&&!gL(D0)?(Qa=D0,xn.addEventListener("message",P0,!1)):Qa=IL in R0("script")?function(e){E0.appendChild(R0("script")).onreadystatechange=function(){E0.removeChild(this),vf(e)}}:function(e){setTimeout(gf(e),0)});var Gs,Qi,zs,Ya,_f,yf,bf,O0,L0={set:hf,clear:ff},wL=re,CL=/ipad|iphone|ipod/i.test(Kn)&&wL.Pebble!==void 0,EL=/web0s(?!.*chrome)/i.test(Kn),Yi=re,M0=Lr,RL=be.f,Sf=L0.set,AL=w0,PL=CL,DL=EL,kf=Fs,N0=Yi.MutationObserver||Yi.WebKitMutationObserver,U0=Yi.document,V0=Yi.process,Lu=Yi.Promise,j0=RL(Yi,"queueMicrotask"),B0=j0&&j0.value;B0||(Gs=function(){var e,t;for(kf&&(e=V0.domain)&&e.exit();Qi;){t=Qi.fn,Qi=Qi.next;try{t()}catch(n){throw Qi?Ya():zs=void 0,n}}zs=void 0,e&&e.enter()},AL||kf||DL||!N0||!U0?!PL&&Lu&&Lu.resolve?((bf=Lu.resolve(void 0)).constructor=Lu,O0=M0(bf.then,bf),Ya=function(){O0(Gs)}):kf?Ya=function(){V0.nextTick(Gs)}:(Sf=M0(Sf,Yi),Ya=function(){Sf(Gs)}):(_f=!0,yf=U0.createTextNode(""),new N0(Gs).observe(yf,{characterData:!0}),Ya=function(){yf.data=_f=!_f}));var OL=B0||function(e){var t={fn:e,next:void 0};zs&&(zs.next=t),Qi||(Qi=t,Ya()),zs=t},LL=re,Tf=function(e){try{return{error:!1,value:e()}}catch(t){return{error:!0,value:t}}},F0=function(){this.head=null,this.tail=null};F0.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 ML=F0,Ws=re.Promise,H0=typeof Deno=="object"&&Deno&&typeof Deno.version=="object",NL=!H0&&!Fs&&typeof window=="object"&&typeof document=="object",UL=re,Js=Ws,VL=it,jL=Ss,BL=d,FL=tt,HL=NL,GL=H0,xf=pr;Js&&Js.prototype;var zL=FL("species"),G0=!1,z0=VL(UL.PromiseRejectionEvent),WL=jL("Promise",function(){var e=BL(Js),t=e!==String(Js);if(!t&&xf===66)return!0;if(!xf||xf<51||!/native code/.test(e)){var n=new Js(function(r){r(1)}),i=function(r){r(function(){},function(){})};if((n.constructor={})[zL]=i,!(G0=n.then(function(){})instanceof i))return!0}return!t&&(HL||GL)&&!z0}),$i={CONSTRUCTOR:WL,REJECTION_EVENT:z0,SUBCLASSING:G0},$a={},W0=Vt,JL=TypeError,qL=function(e){var t,n;this.promise=new e(function(i,r){if(t!==void 0||n!==void 0)throw JL("Bad Promise constructor");t=i,n=r}),this.resolve=W0(t),this.reject=W0(n)};$a.f=function(e){return new qL(e)};var If,J0,q0,KL=Le,Mu=Fs,li=re,Za=Ke,K0=Qt,X0=Fa,XL=Wi,QL=Ps,YL=Vt,Nu=it,$L=at,ZL=oi,eM=Ou,Q0=L0.set,wf=OL,tM=function(e,t){var n=LL.console;n&&n.error&&(arguments.length==1?n.error(e):n.error(e,t))},nM=Tf,rM=ML,Y0=Xe,Uu=Ws,$0=$a,Vu="Promise",Z0=$i.CONSTRUCTOR,iM=$i.REJECTION_EVENT,aM=$i.SUBCLASSING,Cf=Y0.getterFor(Vu),oM=Y0.set,eo=Uu&&Uu.prototype,to=Uu,ju=eo,eb=li.TypeError,Ef=li.document,Rf=li.process,Af=$0.f,sM=Af,cM=!!(Ef&&Ef.createEvent&&li.dispatchEvent),tb="unhandledrejection",nb=function(e){var t;return!(!$L(e)||!Nu(t=e.then))&&t},rb=function(e,t){var n,i,r,o=t.value,c=t.state==1,a=c?e.ok:e.fail,s=e.resolve,l=e.reject,u=e.domain;try{a?(c||(t.rejection===2&&lM(t),t.rejection=1),a===!0?n=o:(u&&u.enter(),n=a(o),u&&(u.exit(),r=!0)),n===e.promise?l(eb("Promise-chain cycle")):(i=nb(n))?Za(i,n,s,l):s(n)):l(o)}catch(f){u&&!r&&u.exit(),l(f)}},ib=function(e,t){e.notified||(e.notified=!0,wf(function(){for(var n,i=e.reactions;n=i.get();)rb(n,e);e.notified=!1,t&&!e.rejection&&uM(e)}))},ab=function(e,t,n){var i,r;cM?((i=Ef.createEvent("Event")).promise=t,i.reason=n,i.initEvent(e,!1,!0),li.dispatchEvent(i)):i={promise:t,reason:n},!iM&&(r=li["on"+e])?r(i):e===tb&&tM("Unhandled promise rejection",n)},uM=function(e){Za(Q0,li,function(){var t,n=e.facade,i=e.value;if(ob(e)&&(t=nM(function(){Mu?Rf.emit("unhandledRejection",i,n):ab(tb,n,i)}),e.rejection=Mu||ob(e)?2:1,t.error))throw t.value})},ob=function(e){return e.rejection!==1&&!e.parent},lM=function(e){Za(Q0,li,function(){var t=e.facade;Mu?Rf.emit("rejectionHandled",t):ab("rejectionhandled",t,e.value)})},no=function(e,t,n){return function(i){e(t,i,n)}},ro=function(e,t,n){e.done||(e.done=!0,n&&(e=n),e.value=t,e.state=2,ib(e,!0))},Pf=function(e,t,n){if(!e.done){e.done=!0,n&&(e=n);try{if(e.facade===t)throw eb("Promise can't be resolved itself");var i=nb(t);i?wf(function(){var r={done:!1};try{Za(i,t,no(Pf,r,e),no(ro,r,e))}catch(o){ro(r,o,e)}}):(e.value=t,e.state=1,ib(e,!1))}catch(r){ro({done:!1},r,e)}}};if(Z0&&(ju=(to=function(e){ZL(this,ju),YL(e),Za(If,this);var t=Cf(this);try{e(no(Pf,t),no(ro,t))}catch(n){ro(t,n)}}).prototype,(If=function(e){oM(this,{type:Vu,done:!1,notified:!1,parent:!1,reactions:new rM,rejection:!1,state:0,value:void 0})}).prototype=K0(ju,"then",function(e,t){var n=Cf(this),i=Af(eM(this,to));return n.parent=!0,i.ok=!Nu(e)||e,i.fail=Nu(t)&&t,i.domain=Mu?Rf.domain:void 0,n.state==0?n.reactions.add(i):wf(function(){rb(i,n)}),i.promise}),J0=function(){var e=new If,t=Cf(e);this.promise=e,this.resolve=no(Pf,t),this.reject=no(ro,t)},$0.f=Af=function(e){return e===to||e===void 0?new J0(e):sM(e)},Nu(Uu)&&eo!==Object.prototype)){q0=eo.then,aM||K0(eo,"then",function(e,t){var n=this;return new to(function(i,r){Za(q0,n,i,r)}).then(e,t)},{unsafe:!0});try{delete eo.constructor}catch(e){}X0&&X0(eo,ju)}KL({global:!0,constructor:!0,wrap:!0,forced:Z0},{Promise:to}),XL(to,Vu,!1),QL(Vu);var dM=Ws,sb=$i.CONSTRUCTOR||!vu(function(e){dM.all(e).then(void 0,function(){})}),hM=Ke,fM=Vt,pM=$a,mM=Tf,vM=Rs;Le({target:"Promise",stat:!0,forced:sb},{all:function(e){var t=this,n=pM.f(t),i=n.resolve,r=n.reject,o=mM(function(){var c=fM(t.resolve),a=[],s=0,l=1;vM(e,function(u){var f=s++,S=!1;l++,hM(c,t,u).then(function(x){S||(S=!0,a[f]=x,--l||i(a))},r)}),--l||i(a)});return o.error&&r(o.value),n.promise}});var gM=Le,_M=$i.CONSTRUCTOR,Df=Ws,yM=An,bM=it,SM=Qt,cb=Df&&Df.prototype;if(gM({target:"Promise",proto:!0,forced:_M,real:!0},{catch:function(e){return this.then(void 0,e)}}),bM(Df)){var ub=yM("Promise").prototype.catch;cb.catch!==ub&&SM(cb,"catch",ub,{unsafe:!0})}var kM=Ke,TM=Vt,xM=$a,IM=Tf,wM=Rs;Le({target:"Promise",stat:!0,forced:sb},{race:function(e){var t=this,n=xM.f(t),i=n.reject,r=IM(function(){var o=TM(t.resolve);wM(e,function(c){kM(o,t,c).then(n.resolve,i)})});return r.error&&i(r.value),n.promise}});var CM=Ke,EM=$a;Le({target:"Promise",stat:!0,forced:$i.CONSTRUCTOR},{reject:function(e){var t=EM.f(this);return CM(t.reject,void 0,e),t.promise}});var RM=Tt,AM=at,PM=$a,lb=function(e,t){if(RM(e),AM(t)&&t.constructor===e)return t;var n=PM.f(e);return(0,n.resolve)(t),n.promise},DM=Le,OM=$i.CONSTRUCTOR,LM=lb;An("Promise"),DM({target:"Promise",stat:!0,forced:OM},{resolve:function(e){return LM(this,e)}});var MM=Mt,db=ou;Le({target:"Object",stat:!0,forced:ue(function(){db(1)})},{keys:function(e){return db(MM(e))}});var hb="canvas",Ee="audio",xe="video",Of="screen",Mr="small",Bu="big",gt="auxiliary",Nn="aux",Fu="smallVideo",fb="user",pb="environment",tn="mute",Sr="unmute",Nt="ended",di="playing",hi="pause",io="error",Lf="loadeddata",qs="audioinput",Hu="videoinput",mb="detail",NM="text",Qe="main",er="backup",UM="banned",VM="kick",jM="user_time_out",BM="room_disband",vb="sei-message",ao="PLAYING",kr="PAUSED",fi="STOPPED",oo="inactive",pi="sendonly",Mf="recvonly",gb="add",_b="remove",FM="replace",Nf="track",HM="wss://trtc.rtc.qq.com",GM="wss://webrtc.qq.com",Gu="qcloud",zM="trtc",WM="webrtc",Ks="",yb="jssdk_log",JM="jssdk_event",qM="jssdk_new_endreport",Uf=function(e){return Ks=e},KM=1,XM=2,zu="live",so=20,Vf=21,Tr="anchor",Zi="audience",xr="5Y2wZK8nANNAoVw6dSAHVjNxrD1ObBM2kBPV",Xs="224d130c-7b5c-415b-aaa2-79c2eb5a6df2",QM=2,yt=Qe,Dt=gt,Wu="unknown",on="DISCONNECTED",bb="CONNECTING",jf="RECONNECTING",sn="CONNECTED",YM="new",Ju="connecting",Sb="failed",Bf="closed",$M="disconnected",kb="connected",ZM="completed",Ff=30,Tb="join",eN="delta-join",xb="rejoin",tN="leave",nN="delta-leave",Ib="publish",rN="delta-publish",wb="unpublish",Cb="subscribe",Eb="unsubscribe",Rb="uplink-connection",Ab="uplink-reconnection",Pb="downlink-connection",Db="downlink-reconnection",qu="setLocalDescription",Ob="setRemoteDescription",Lb="iceConnectionState",Qs="stream-initialize",Hf="websocketConnectionState",Mb="websocketReconnectionState",Nb="update-stream",Ub="recover-subscription",Vb="start-mix-transcode",jb="stop-mix-transcode",Bb="player-error",Fb="schedule",Gf="unsubscribe",zf="subscribe_change",Ys="unified-plan",Wf="plan-b",Jf={MANUAL:"manual",PRESET_LAYOUT:"preset-layout"},Hb={REMOTE:"$PLACE_HOLDER_REMOTE$"},Gb={IT_AUDIO_VIDEO:0,IT_PICTURE:2,IT_CANVAS:3,IT_PURE_AUDIO:4,IT_PURE_VIDEO:5},dt="string",wt="number",Wt="boolean",zb="array",In="object",cn={ADD:gb,REMOVE:_b},qf={unknown:0,wifi:1,"4g":2,"3g":3,"2g":4,wired:5},Wb=-1,$s=0,iN=1,Jb=Bu,qb=Mr,Kb=6048e5,aN="schedule.cloud-rtc.com",oN="schedule.rtc.qcloud.com",sN="schedule.rtc.tencentcloud.com",cN="schedule-ecdn.rtc.tencentcloud.com",Kf="",Xb=function(e){return Kf=e},Zs="TRTC",un="Client",mi="LocalStream",Xf="RemoteStream",uN="Stream",Qf="web.sdk.qcloud.com",Qb="web.sdk.tencent.cn",Yb="web.sdk.cloud.tencent.cn",$b="https://console.cloud.tencent.com/trtc",co="https://".concat(Qf,"/trtc/webrtc/doc"),Yf="".concat(co,"/zh-cn/"),$f="trtc_error_assistance",Ku="default",Zb="communications",Un={TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,NONE:5},lN=1,eS=2,dN=1,tS=2,ea=Object.keys(Un),hN=["normal leave","timeout leave","kick","role change"],Xu=2e3,uo="ric",Qu="raf",fN="interval",nS="timeout",rS="Resolution reset to 1080p, need to upgrade ability here https://cloud.tencent.com/document/product/647/85386",pN={"TRTC.checkSystemRequirements":40001,"TRTC.isScreenShareSupported":40002,"TRTC.isSmallStreamSupported":40003,"TRTC.createClient.rtc":40004,"TRTC.createClient.live":40005,"TRTC.createClient.intRoomId":40006,"TRTC.createClient.stringRoomId":40007,"TRTC.createClient.autoSubscribe":40008,"TRTC.createClient.manualSubscribe":40009,"TRTC.enableUploadLog":40010,"TRTC.disableUploadLog":40011,"Client.publish":40012,"Client.publish.isAuxiliary":40013,"Client.switchRole":40014,"Client.startPublishCDNStream":40015,"Client.stopPublishCDNStream":40016,"Client.startMixTranscode":40017,"Client.stopMixTranscode":40018,"Client.enableAudioVolumeEvaluation":40019,"Client.enableSmallStream":40020,"Client.disableSmallStream":40021,"Client.setSmallStreamProfile":40022,"Client.setRemoteVideoStreamType":40023,"Client.sendSEIMessage":40024,"Client.setProxyServer":40025,"Client.setTurnServer":40026,"LocalStream.setAudioProfile.standard":40027,"LocalStream.setAudioProfile.high":40028,"LocalStream.setAudioProfile.standard-stereo":40029,"LocalStream.setAudioProfile.high-stereo":40030,"LocalStream.setVideoProfile.120p":40031,"LocalStream.setVideoProfile.120p_2":40032,"LocalStream.setVideoProfile.180p":40033,"LocalStream.setVideoProfile.180p_2":40034,"LocalStream.setVideoProfile.240p":40035,"LocalStream.setVideoProfile.240p_2":40036,"LocalStream.setVideoProfile.360p":40037,"LocalStream.setVideoProfile.360p_2":40038,"LocalStream.setVideoProfile.480p":40039,"LocalStream.setVideoProfile.480p_2":40040,"LocalStream.setVideoProfile.720p":40041,"LocalStream.setVideoProfile.1080p":40042,"LocalStream.setVideoProfile.1440p":40043,"LocalStream.setVideoProfile.4K":40044,"LocalStream.setScreenProfile.480p":40045,"LocalStream.setScreenProfile.480p_2":40046,"LocalStream.setScreenProfile.720p":40047,"LocalStream.setScreenProfile.720p_2":40048,"LocalStream.setScreenProfile.1080p":40049,"LocalStream.setScreenProfile.1080p_2":40050,"LocalStream.setVideoContentHint.motion":40051,"LocalStream.setVideoContentHint.detail":40052,"LocalStream.setVideoContentHint.text":40053,"LocalStream.setAudioCaptureVolume":40054,"LocalStream.getVideoFrame":40055,"RemoteStream.setAudioOutput":40056,"RemoteStream.getVideoFrame":40057,AI_DENOISER:1700,SPATIAL_AUDIO:1701,"2K_4K":1704},Zf=["width","height","frameRate","facingMode","sampleRate","sampleSize","channelCount","deviceId"],mN=pt,iS=zt,vN=/"/g,gN=pe("".replace),aS=function(e,t,n,i){var r=iS(mN(e)),o="<"+t;return n!==""&&(o+=" "+n+'="'+gN(iS(i),vN,""")+'"'),o+">"+r+"</"+t+">"},_N=ue,oS=function(e){return _N(function(){var t=""[e]('"');return t!==t.toLowerCase()||t.split('"').length>3})},yN=aS;Le({target:"String",proto:!0,forced:oS("link")},{link:function(e){return yN(this,"a","href",e)}}),Le({target:"Array",stat:!0},{isArray:Ga});var bN="AVOID_REPEATED_CALL",SN="INVALID_PARAMETER_REQUIRED",sS="INVALID_PARAMETER_TYPE",kN="INVALID_PARAMETER_EMPTY",cS="INVALID_PARAMETER_INSTANCE",TN="INVALID_PARAMETER_RANGE",xN="API_CALL_TIMEOUT",IN="SIGNAL_CHANNEL_RECONNECTION_FAILED",wN="SIGNAL_CHANNEL_SETUP_FAILED",CN="ERROR_MESSAGE",EN="EXCHANGE_SDP_TIMEOUT",RN="DOWNLINK_RECONNECTION_FAILED",AN="EXCHANGE_SDP_FAILED",PN="UPLINK_RECONNECTION_FAILED",DN="INVALID_PURE_AUDIO",ON="INVALID_STREAMID",LN="INVALID_USER_DEFINE_RECORDID",MN="INVALID_USER_DEFINE_PUSH_ARGS",NN="INVALID_PROXY",UN="INVALID_JOIN",VN="INVALID_ROOMID_STRING",jN="INVALID_ROOMID_INTEGER",BN="JOIN_ROOM_TIMEOUT",uS="JOIN_ROOM_FAILED",FN="REJOIN_ROOM_FAILED",HN="INVALID_DESTROY",GN="INVALID_PUBLISH",zN="INVALID_UNPUBLISH",WN="INVALID_AUDIENCE",JN="INVALID_INITIALIZE",qN="INVALID_DUPLICATE_PUBLISHING",ep="INVALID_REMOTE_STREAM",KN="SUBSCRIBE_FAILED",XN="INVALID_ROLE",QN="INVALID_OPERATION_SWITCH_ROLE",YN="SWITCH_ROLE_TIMEOUT",$N="SWITCH_ROLE_FAILED",ZN="CLIENT_BANNED",lS="INVALID_OPERATION_START_PUBLISH_CDN",e3="INVALID_OPERATION_STOP_PUBLISH_CDN",t3="INVALID_STREAM_ID",dS="START_PUBLISH_CDN_FAILED",hS="STOP_PUBLISH_CDN_FAILED",n3="START_MIX_TRANSCODE",r3="STOP_MIX_TRANSCODE",i3="INVALID_AUDIO_VOLUME",a3="ENABLE_SMALL_STREAM_PUBLISHED",o3="DISABLE_SMALL_STREAM_PUBLISHED",s3="NOT_SUPPORTED_SMALL_STREAM",c3="INVALID_SMALL_STREAM_PROFILE",u3="INVALID_PARAMETER_REMOTE_STREAM",l3="INVALID_SWITCH_DEVICE",d3="INVALID_SWITCH_DEVICE_PUBLISHING",fS="INVALID_REPLACE_TRACK",h3="INVALID_INITIALIZE_LOCAL_STREAM",f3="INVALID_ADD_TRACK_REPETITIVE",p3="INVALID_ADD_TRACK_REMOVING",m3="INVALID_ADD_TRACK_PUBLISHING",pS="INVALID_STREAM_INITIALIZED",v3="INVALID_ADD_TRACK_NUMBER",g3="INVALID_REMOVE_AUDIO_TRACK",_3="INVALID_REMOVE_AUDIO_ADDING",y3="INVALID_REMOVE_AUDIO_ON",b3="INVALID_REMOVE_TRACK_PUBLISHING",S3="INVALID_REMOVE_TRACK_NOT_PUBLISHING",k3="INVALID_REMOVE_TRACK_NUMBER",T3="INVALID_REPLACE_TRACK_NO_TRACK",x3="REPEAT_JOIN",tp="CLIENT_DESTROYED",I3="START_MIX_TRANSCODE_FAILED",w3="STOP_MIX_TRANSCODE_FAILED",C3="MIX_TRANSCODE_NOT_STARTED",E3="CANNOT_LESS_THAN_ZERO",R3="MIX_PARAMS_VIDEO_FRAMERATE",A3="MIX_PARAMS_VIDEO_GOP",P3="MIX_PARAMS_AUDIO_BITRATE",D3="MIX_PARAMS_USER_Z_ORDER",O3="MIX_PARAMS_NOT_SELF",L3="MIX_PARAMS_USER_STREAM",M3="INVALID_ELEMENT_ID",N3="INVALID_ELEMENT_ID_TYPE",np="PLAY_FAILED",U3="INVALID_CREATE_STREAM_SOURCE",V3="INVALID_CREATE_STREAM_SCREEN",j3="INVALID_CREATE_STREAM_AUDIO",B3="INVALID_CREATE_STREAM_SCREEN_AUDIO",mS="NOT_SUPPORTED_HTTP",vS="NOT_SUPPORTED_WEBRTC",F3="NOT_SUPPORTED_PROFILE",gS="NOT_SUPPORTED_H264ENCODE",_S="NOT_SUPPORTED_H264DECODE",rp="NOT_SUPPORTED_TRACK",H3="NOT_SUPPORTED_SWITCH_DEVICE",G3="NOT_SUPPORTED_CAPTURE",z3="NOT_SUPPORTED_AUX",W3="MICROPHONE_NOT_FOUND",J3="CAMERA_NOT_FOUND",yS="SIGNAL_RESPONSE_FAILED",q3="CATCH_HANDLER_ERROR",K3="API_NOT_EXIST",X3="CONNECTION_CLOSED",Q3="SUBSCRIBE_ALL_FALSE",bS="SEI_NOT_SUPPORT",Y3="SEI_DISABLED",$3="SEI_EMPTY",Z3="SEI_OVERSIZE",e4="SEI_BEFORE_PUBLISH",t4="SEI_NOT_VIDEO",n4="CALL_FREQUENCY_LIMIT",r4="CONNECTION_ABORTED",ip="API_CALL_ABORTED",i4="DUPLICATE_AUX",vi={AVOID_REPEATED_CALL:function(e){return"previous ".concat(e.name,"() is ongoing, please avoid repeated calls.")},INVALID_PARAMETER_REQUIRED:function(e){var t=e.key,n=e.rule,i=e.fnName,r=e.value;return"'".concat(t||n.name,"' is a required param when calling ").concat(i,"(), received: ").concat(r,".")},INVALID_PARAMETER_TYPE:function(e){var t=e.key,n=e.rule,i=e.fnName,r=e.value,o="".concat(t||n.name),c="";return c=Array.isArray(n.type)?n.type.join("|"):n.type,"'".concat(o,"' must be type of ").concat(c," when calling ").concat(i,"(), received type: ").concat(bi(r),".")},INVALID_PARAMETER_EMPTY:function(e){var t=e.key,n=e.rule,i=e.fnName,r=e.value;return"'".concat(t||n.name,"' cannot be '").concat(r,"' when calling ").concat(i,"().")},INVALID_PARAMETER_INSTANCE:function(e){var t=e.key,n=e.rule,i=e.fnName,r=e.value,o="".concat(t||n.name),c="".concat(n.instanceOf.name||n.instanceOf);return"'".concat(o,"' must be instanceof ").concat(c," when calling ").concat(i,"(), received type: ").concat(bi(r),".")},INVALID_PARAMETER_RANGE:function(e){var t=e.key,n=e.rule,i=e.fnName,r=e.value;return"'".concat(t||n.name,"' must be one of ").concat(n.values.join("|")," when calling ").concat(i,"(), received: ").concat(r,".")},API_CALL_TIMEOUT:function(e){return"".concat(e.commandDesc||e.command," timeout observed.")},SIGNAL_CHANNEL_RECONNECTION_FAILED:"signal channel reconnection failed, please check your network.",SIGNAL_CHANNEL_SETUP_FAILED:function(e){return"SignalChannel setup failure: (errorCode: ".concat(e.errorCode,", errorMsg: ").concat(e.errorMsg," }).")},ERROR_MESSAGE:function(e){var t="".concat(e.type," failed");return e.message&&(t="".concat(t,": ").concat(e.message,".")),t},EXCHANGE_SDP_TIMEOUT:"exchange sdp timeout.",DOWNLINK_RECONNECTION_FAILED:"downlink reconnection failed, please check your network and re-join room.",EXCHANGE_SDP_FAILED:function(e){return"exchange sdp failed ".concat(e.errMsg,".")},UPDATE_OFFER_TIMEOUT:"update offer timeout observed.",UPLINK_RECONNECTION_FAILED:"uplink reconnection failed, please check your network and publish again.",INVALID_RECORDID:"recordId must be an integer number.",INVALID_PURE_AUDIO:"pureAudioPushMode must be 1 or 2.",INVALID_STREAMID:"streamId must be a sting literal within 64 bytes, and not be empty.",INVALID_USER_DEFINE_RECORDID:"userDefineRecordId must be a sting literal contains (a-zA-Z),(0-9), underline and hyphen, within 64 bytes, and not be empty.",INVALID_USER_DEFINE_PUSH_ARGS:"userDefinePushArgs must be a sting literal within 256 bytes, and not be empty.",INVALID_PROXY:'proxy server url must start with "wss://".',INVALID_JOIN:"duplicate join() called.",INVALID_ROOMID_STRING:function(e){return"'".concat(e,"' must be validate string when useStringRoomId is true.")},INVALID_ROOMID_INTEGER:function(e){return"'".concat(e,"' must be an integer between [1, 4294967294] when useStringRoomId is false.")},INVALID_SIGNAL_CHANNEL:"SignalChannel is not ready yet.",JOIN_ROOM_TIMEOUT:"join room timeout.",JOIN_ROOM_FAILED:function(e){var t=e.error,n=e.code;return"Failed to join room - ".concat(t," code: ").concat(n)},REJOIN_ROOM_FAILED:function(e){return"reJoin room: ".concat(e.roomId," failed, please check your network.")},INVALID_DESTROY:"please call leave() before destroy().",INVALID_PUBLISH:"please call join() before publish().",INVALID_UNPUBLISH:"stream has not been published yet.",INVALID_AUDIENCE:"no permission to publish() under live/".concat(Zi,', please call switchRole("').concat(Tr,'") firstly before publish().'),INVALID_INITIALIZE:"cannot publish stream because stream is not initialized, is switching device, or has been closed.",INVALID_DUPLICATE_PUBLISHING:function(e){return"duplicate ".concat(e," stream publishing, please unpublish your prev ").concat(e," stream and then re-publish.")},INVALID_SUBSCRIBE_UNDEFINED:"stream is undefined or null.",INVALID_SUBSCRIBE_LOCAL:"stream cannot be LocalStream.",INVALID_REMOTE_STREAM:"remoteStream does not exist because it has been unpublished by remote peer.",SUBSCRIBE_FAILED:function(e){var t=e.message,n=e.stream;return"failed to subscribe ".concat(n.getUserId()," ").concat(n.getType()," stream, reason: ").concat(t,".")},INVALID_ROLE:"switchRole can only be called in live mode.",INVALID_PARAMETER_SWITCH_ROLE:"role could only be set to a value as ".concat(Tr," or ").concat(Zi,"."),INVALID_OPERATION_SWITCH_ROLE:"please call join() before switchRole().",SWITCH_ROLE_TIMEOUT:"switchRole timeout.",SWITCH_ROLE_FAILED:function(e){return"switchRole failed, errCode: ".concat(e.code," errMsg: ").concat(e.message,".")},CLIENT_BANNED:function(e){return"client was banned because of "+e.message+"."},INVALID_OPERATION_START_PUBLISH_CDN:"please call startPublishCDNStream() before client join the room or after client join the room and successfully publish the local stream.",INVALID_OPERATION_STOP_PUBLISH_CDN:"please call startPublishCDNStream() before stopPublishCDNStream().",START_PUBLISH_CDN_FAILED:function(e){return"startPublishCDNStream failed, errMsg: ".concat(e.message,".")},STOP_PUBLISH_CDN_FAILED:function(e){return"stopPublishCDNStream failed, errMsg: ".concat(e.message,".")},INVALID_STREAM_ID:function(e){return"'".concat(e,"' can only consist of uppercase and lowercase english letters (a-zA-Z), numbers (0-9), hyphens and underscores.")},START_MIX_TRANSCODE:"please call startMixTranscode() after join().",STOP_MIX_TRANSCODE:"please call stopMixTranscode() after startMixTranscode().",INVALID_AUDIO_VOLUME:"interval must be a number.",ENABLE_SMALL_STREAM_PUBLISHED:"Cannot enable small stream after localStream published.",DISABLE_SMALL_STREAM_PUBLISHED:"Cannot disable small stream after localStream published.",NOT_SUPPORTED_SMALL_STREAM:"your browser does not support opening small stream.",INVALID_SMALL_STREAM_PROFILE:"small stream profile is invalid.",INVALID_PARAMETER_REMOTE_STREAM:"remoteStream is invalid.",INVALID_OPERATION_CHANGE_SMALL:"cannot switch to the small stream without subscribing to the video of remoteStream.",REMOTE_NOT_PUBLISH_SMALL_STREAM:"remote peer does not publish small stream.",INVALID_SWITCH_DEVICE:"cannot switch device on current stream.",INVALID_SWITCH_DEVICE_PUBLISHING:"cannot switch device when publishing localStream.",INVALID_REPLACE_TRACK:"cannot replace track when publishing localStream.",INVALID_INITIALIZE_LOCAL_STREAM:"local stream has not initialized yet.",INVALID_ADD_TRACK_REPETITIVE:"previous addTrack is ongoing, please avoid repetitive execution.",INVALID_ADD_TRACK_REMOVING:"cannot add track when a track is removing.",INVALID_ADD_TRACK_PUBLISHING:"cannot add track when publishing localStream.",INVALID_STREAM_INITIALIZED:"your local stream haven't been initialized yet.",INVALID_ADD_TRACK_NUMBER:"a Stream has at most one audio track and one video track.",INVALID_REMOVE_AUDIO_TRACK:"remove audio track is not supported on your browser.",INVALID_REMOVE_AUDIO_ADDING:"cannot remove track when a track is adding.",INVALID_REMOVE_AUDIO_ON:"previous removeTrack is ongoing, please avoid repetitive execution.",INVALID_REMOVE_TRACK_PUBLISHING:"cannot remove track when publishing localStream.",INVALID_REMOVE_TRACK_NOT_PUBLISHING:"the track to be removed is not being publishing.",INVALID_REMOVE_TRACK_NUMBER:"remove the only video track is not supported, please use replaceTrack or muteVideo.",INVALID_REPLACE_TRACK_NO_TRACK:function(e){return"cannot replace ".concat(e.kind," track because stream has not ").concat(e.kind," track")},START_MIX_TRANSCODE_FAILED:function(e){return"startMixTranscode failed, errMsg: ".concat(e.message,".")},STOP_MIX_TRANSCODE_FAILED:function(e){return"stopMixTranscode failed, errMsg: ".concat(e.message,".")},MIX_TRANSCODE_NOT_STARTED:"mixTranscode has not been started.",CANNOT_LESS_THAN_ZERO:function(e){var t=e.key,n=e.rule,i=e.fnName;return e.value,"'".concat(t||n.name,"' cannot be less than 0 when calling ").concat(i,"().")},MIX_PARAMS_VIDEO_FRAMERATE:"'config.videoFramerate' should be an integer between 0 and 30, excluding 0.",MIX_PARAMS_VIDEO_GOP:"'config.videoGOP' should be an integer between 1 and 8.",MIX_PARAMS_AUDIO_BITRATE:"'config.audioBitrate' should be an integer between 32 and 192.",MIX_PARAMS_USER_Z_ORDER:function(e){return"'".concat(e,"' is required and must be between 1 and 15.")},MIX_PARAMS_NOT_SELF:"'config.mixUsers' must contain self.",MIX_PARAMS_USER_STREAM:"'config.videoWidth' and 'config.videoHeight' of output stream should be contain all mix stream.",INVALID_PLAY:"duplicate play() call observed, please stop() firstly.",INVALID_ELEMENT_ID:function(e){var t=e.key,n=e.fnName;return"'".concat(t,"' is not found in the document object when calling ").concat(n,"().")},INVALID_ELEMENT_ID_TYPE:function(e){var t=e.key,n=e.fnName,i=e.type;return"the element corresponding to '".concat(t,"' must be instanceof HTMLDivElement when calling ").concat(n,"(), received: ").concat(i,".")},PLAY_FAILED:function(e){return"".concat(e.media," play failed\uFF0Cbrowser exception: ").concat(e.error.toString())},INVALID_USERID:"userId cannot be all spaces.",INVALID_CREATE_STREAM_SOURCE:"LocalStream must be created by createStream() with either audio/video or audioSource/videoSource, but can not be mixed with audio/video and audioSource/videoSource.",INVALID_CREATE_STREAM_SCREEN:"screen/video cannot be both true.",INVALID_CREATE_STREAM_AUDIO:"audio/screenAudio cannot be both true.",INVALID_CREATE_STREAM_SCREEN_AUDIO:"when screen is true, screenAudio can be configured.",NOT_SUPPORTED_HTTP:"http protocol does not support the ability to capture and publish streams, please use the https protocol.",NOT_SUPPORTED_WEBRTC:"your browser or environment does not support full WebRTC capabilities.",NOT_SUPPORTED_PROFILE:"your browser does not support setVideoProfile.",NOT_SUPPORTED_MEDIA:"your browser or environment does not support navigator.mediaDevices.",NOT_SUPPORTED_H264ENCODE:"your device does not support H.264 encoding.",NOT_SUPPORTED_H264DECODE:"your device does not support H.264 decoding.",NOT_SUPPORTED_TRACK:function(e){return"".concat(e,"Track is not supported on your browser.")},NOT_SUPPORTED_SWITCH_DEVICE:"switchDevice is not supported on your browser.",NOT_SUPPORTED_CAPTURE:"Your browser or environment does not support screen sharing, please check whether the browser version.",MICROPHONE_NOT_FOUND:"no microphone detected, please check your microphone and the configuration on TRTC.createStream.",CAMERA_NOT_FOUND:"no camera detected, please check your camera and the configuration on TRTC.createStream.",SIGNAL_RESPONSE_FAILED:function(e){return"".concat(e.signalResponse," failed, response code is ").concat(e.code," , errMsg: ").concat(e.message,".")},CATCH_HANDLER_ERROR:function(e){var t=e.name,n=e.event;return"an error was caught on ".concat(t,".on('").concat(n,"', handler), please check your code on 'handler'.")},API_NOT_EXIST:function(e){var t=e.name;return"experimental api ".concat(t," does not exist.")},REPEAT_JOIN:function(e){return"[".concat(e,"] is calling client.join api or has already joined room, please avoid repeated join.")},CONNECTION_CLOSED:"remoteStream has been unsubscribed or unpublished by remote user.",SUBSCRIBE_ALL_FALSE:"cannot subscribe when both audio & video are false, use client.unsubscribe() instead",CLIENT_DESTROYED:function(e){var t=e.funName;return"failed to call ".concat(t,"() because client was destroyed.")},SEI_NOT_SUPPORT:function(e){return"not support to sendSEIMessage".concat(e===!1?" without using h264 codec":"")},SEI_DISABLED:"SEI is disabled, to enable SEI: TRTC.createClient({ enableSEI: true })",SEI_EMPTY:"buffer cannot be empty",SEI_OVERSIZE:function(e){return"buffer size(".concat(e,") is over 1000 Bytes")},SEI_BEFORE_PUBLISH:"please call sendSEIMessage() after publish() success",SEI_NOT_VIDEO:"cannot send sei when localStream has not video.",CALL_FREQUENCY_LIMIT:function(e){var t=e.isSize,n=e.name,i=e.timesInSecond,r=e.maxSizeInSecond;return"api ".concat(n," call ").concat(t?"size":"times"," is over ").concat(t?r+" bytes":i," in a second.")},CONNECTION_ABORTED:function(e){return"connection aborted due to: "+e},API_CALL_ABORTED:function(e){return e.message.includes("REMOTE_STREAM_NOT_EXIST")?"Subscribe ".concat(e.stream.getUserId()," ").concat(e.stream.getType()," stream aborted, reason: remote user ").concat(e.stream.getUserId()," unpublished stream."):"API aborted, reason: ".concat(e.message)},DUPLICATE_AUX:"only one auxiliary stream can be published in a room.",NOT_SUPPORTED_AUX:"publish auxiliary stream is not supported on your browser."},SS=re,a4=ue,o4=zt,s4=Au.trim,c4=pe("".charAt),Yu=SS.parseFloat,kS=SS.Symbol,TS=kS&&kS.iterator,xS=1/Yu(`
|
|
44
|
+
\v\f\r \xA0\u1680\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028\u2029\uFEFF-0`)!=-1/0||TS&&!a4(function(){Yu(Object(TS))})?function(e){var t=s4(o4(e)),n=Yu(t);return n===0&&c4(t,0)=="-"?-0:n}:Yu;Le({global:!0,forced:parseFloat!=xS},{parseFloat:xS});var Ce=window.navigator&&window.navigator.userAgent||"",IS=/AppleWebKit\/([\d.]+)/i.exec(Ce);IS&&parseFloat(IS.pop());var ap=/iPad/i.test(Ce),wS=navigator.maxTouchPoints&&navigator.maxTouchPoints>2&&/Macintosh/.test(Ce),op=/iPhone/i.test(Ce)&&!ap,u4=/iPod/i.test(Ce),gi=op||ap||u4||wS,ta=/Android/i.test(Ce);ta&&function(){var e=Ce.match(/Android (\d+)(?:\.(\d+))?(?:\.(\d+))*/i);if(!e)return null;var t=e[1]&&parseFloat(e[1]),n=e[2]&&parseFloat(e[2]);t&&n&&parseFloat(e[1]+"."+e[2])}(),ta&&/webkit/i.test(Ce);var Vn=/Firefox/i.test(Ce),CS=Vn&&function(){var e=Ce.match(/Firefox\/(\d+)/);return e&&e[1]?parseFloat(e[1]):null}(),$u=/Edge\//i.test(Ce),l4=$u&&function(){var e=Ce.match(/Edge\/(\d+)/i);if(e&&e[1])return e[1]}(),Zu=/Edg\//i.test(Ce),ES=Zu&&function(){var e=Ce.match(/Edg\/(\d+)/);return e&&e[1]?parseFloat(e[1]):null}(),sp=/SogouMobileBrowser\//i.test(Ce),d4=sp&&function(){var e=Ce.match(/SogouMobileBrowser\/(\d+)/);return e&&e[1]?parseFloat(e[1]):null}(),cp=/MetaSr\s/i.test(Ce),h4=cp&&function(){var e=Ce.match(/MetaSr(\s\d+(\.\d+)+)/);return e&&e[1]?parseFloat(e[1]):null}(),Nr=/TBS\/\d+/i.test(Ce),f4=Nr&&function(){var e=Ce.match(/TBS\/(\d+)/i);if(e&&e[1])return e[1]}(),up=/XWEB\/\d+/i.test(Ce),p4=up&&function(){var e=Ce.match(/XWEB\/(\d+)/i);if(e&&e[1])return e[1]}();/MSIE\s8\.0/.test(Ce),/MSIE\/\d+/i.test(Ce)&&function(){var e=/MSIE\s(\d+)\.\d/.exec(Ce),t=e&&parseFloat(e[1]);!t&&/Trident\/7.0/i.test(Ce)&&/rv:11.0/.test(Ce)&&(t=11)}();var lp=/(micromessenger|webbrowser)/i.test(Ce),m4=lp&&function(){var e=Ce.match(/MicroMessenger\/(\d+)/i);if(e&&e[1])return e[1]}(),dp=!Nr&&/MQQBrowser\/\d+/i.test(Ce)&&/COVC\/\d+/i.test(Ce),hp=!Nr&&/MQQBrowser\/\d+/i.test(Ce)&&!/COVC\/\d+/i.test(Ce),RS=(hp||dp)&&function(){var e=Ce.match(/ MQQBrowser\/([\d.]+)/);return e&&e[1]?e[1]:null}(),fp=!Nr&&/ QQBrowser\/\d+/i.test(Ce),v4=fp&&function(){var e=Ce.match(/ QQBrowser\/([\d.]+)/);return e&&e[1]?e[1]:null}(),pp=!Nr&&/QQBrowserLite\/\d+/i.test(Ce),g4=pp&&function(){var e=Ce.match(/QQBrowserLite\/([\d.]+)/);return e&&e[1]?e[1]:null}(),mp=!Nr&&/MQBHD\/\d+/i.test(Ce),_4=mp&&function(){var e=Ce.match(/MQBHD\/([\d.]+)/);return e&&e[1]?e[1]:null}(),AS=/Windows/i.test(Ce),ec=!gi&&/MAC OS X/i.test(Ce),PS=!ta&&/Linux/i.test(Ce);/MicroMessenger/i.test(Ce);var y4=/UCBrowser/i.test(Ce);/Electron/i.test(Ce);var DS,el,vp=/MiuiBrowser/i.test(Ce),b4=vp&&function(){var e=Ce.match(/MiuiBrowser\/([\d.]+)/);return e&&e[1]?e[1]:null}(),gp=/HuaweiBrowser/i.test(Ce),_p=/Huawei/i.test(Ce),S4=gp&&function(){var e=Ce.match(/HuaweiBrowser\/([\d.]+)/);return e&&e[1]?e[1]:null}(),yp=/SamsungBrowser/i.test(Ce),k4=yp&&function(){var e=Ce.match(/SamsungBrowser\/([\d.]+)/);return e&&e[1]?e[1]:null}(),tl=/HeyTapBrowser/i.test(Ce),T4=tl&&function(){var e=Ce.match(/HeyTapBrowser\/([\d.]+)/);return e&&e[1]?e[1]:null}(),nl=/VivoBrowser/i.test(Ce),x4=nl&&function(){var e=Ce.match(/VivoBrowser\/([\d.]+)/);return e&&e[1]?e[1]:null}(),lo=function(){var e=Ce.match(/Chrome\/(\d+)/);return e&&e[1]?Number(e[1]):null},I4=/Chrome/i.test(Ce),rl=!$u&&!cp&&!sp&&!Nr&&!up&&!Zu&&!fp&&!vp&&!gp&&!yp&&!tl&&!nl&&/Chrome/i.test(Ce),bp=rl&&lo(),w4=rl&&function(){var e=Ce.match(/Chrome\/([\d.]+)/);return e&&e[1]?e[1]:null}(),na=!I4&&!hp&&!dp&&!pp&&!mp&&/Safari/i.test(Ce),Sp=function(){if(na){var e=Ce.match(/Version\/([\d.]+)/);if(e&&e[1])return e[1]}return""}(),C4=/Android.*(wv|.0.0.0)/.test(Ce),_i=function(){if(wS)return Sp;if(gi){var e=Ce.match(/OS (\d+)_(\d+)/i);if(e&&e[1]){var t=e[1];return e[2]&&(t+=".".concat(e[2])),t}}return""}(),OS=Number(_i.split(".")[0]),il=Sp==="15.1",al=_i==="15.1",E4=(DS=Number(_i.split(".")[0]))===14||DS===13,ra=location.protocol==="file:"||location.hostname==="localhost"||location.hostname==="127.0.0.1",ia=function(){if(ge(el))try{el=window.localStorage}catch(e){_e.warn(e),el=!1}return el},kp=new Map([[Vn,["Firefox",CS]],[Zu,["Edg",ES]],[rl,["Chrome",w4]],[na,["Safari",Sp]],[Nr,["TBS",f4]],[up,["XWEB",p4]],[lp&&op,["WeChat",m4]],[fp,["QQ(Win)",v4]],[hp,["QQ(Mobile)",RS]],[dp,["QQ(Mobile X5)",RS]],[pp,["QQ(Mac)",g4]],[mp,["QQ(iPad)",_4]],[vp,["MI",b4]],[gp,["HW",S4]],[yp,["Samsung",k4]],[tl,["OPPO",T4]],[nl,["VIVO",x4]],[$u,["EDGE",l4]],[sp,["SogouMobile",d4]],[cp,["Sogou",h4]]]);function aa(){var e="unknown",t="unknown";return kp.get(!0)&&(e=kp.get(!0)[0],t=kp.get(!0)[1]),{name:e,version:t}}var LS=function(e,t){return t?co+"/"+e+"/"+t:co+"/"+e+"/index.html"},R4=function(){if(!ia())return!1;var e=localStorage.getItem($f);e&&!function(t){var n=t.saveTime&&new Date().getTime()-t.saveTime>=Kb,i=!t.saveVersion||t.saveVersion!==Gi;return n||i}(JSON.parse(e))||(_e.info("init debug info"),function(){var t=new XMLHttpRequest;if(t.open("GET","https://web.sdk.qcloud.com/trtc/webrtc/download/error-message/0.0.3/script.js",!1),t.send(null),t.readyState===4&&t.status===200){var n=document.createElement("script");n.type="text/javascript",n.text=t.responseText,document.body.appendChild(n),localStorage.setItem($f,JSON.stringify({message:t.responseText,saveTime:new Date().getTime(),saveVersion:Gi})),document.body.removeChild(n)}}())};function ae(e){var t=e.key,n=e.data,i=e.link,r=e.addDocLink,o=r===void 0||r,c="",a="",s="";ln(vi[t])?c=vi[t](n):Bt(vi[t])&&(c=vi[t]);var l=function(){if(window.TRTC_ERROR_INFO&&window.TRTC_ERROR_LINK)return{TRTC_ERROR_INFO:window.TRTC_ERROR_INFO,TRTC_ERROR_LINK:window.TRTC_ERROR_LINK};var x=localStorage.getItem($f);if(x){x=JSON.parse(x);var E=document.createElement("script");E.type="text/javascript",E.text=x.message,document.body.appendChild(E);var I=window.TRTC_ERROR_INFO,m=window.TRTC_ERROR_LINK;return document.body.removeChild(E),{TRTC_ERROR_INFO:I,TRTC_ERROR_LINK:m}}return{}}(),u=l.TRTC_ERROR_INFO,f=l.TRTC_ERROR_LINK;i?s="".concat(i.className,".html#").concat(i.fnName):f&&f[t]&&(ln(f[t])?s=f[t](n):Bt(f[t])&&(s=f[t]));var S=c;return oa()&&(u&&u[t]&&(ln(u[t])?a=u[t](n):Bt(u[t])&&(a=u[t])),a&&(S=o?a+`
|
|
45
|
+
\u8BF7\u67E5\u770B\u6587\u6863: `+LS("zh-cn",s)+`
|
|
82
46
|
|
|
83
|
-
`:
|
|
47
|
+
`:a+`
|
|
84
48
|
|
|
85
|
-
`,
|
|
86
|
-
Refer to: `+
|
|
87
|
-
`),
|
|
49
|
+
`,S+=c)),o&&(S+=`
|
|
50
|
+
Refer to: `+LS("en",s)+`
|
|
51
|
+
`),S}var MS=function(){return function(e){var t=window.location.search.match(new RegExp("(\\?|&)"+e+"=([^&]*)(&|$)"));return t?decodeURIComponent(t[2]):""}("trtc_env")},NS=function(e){return(e=Number(e))>0&&e<14e8},ol=function(e,t){var n;n=Ks?Ks.includes("http")?Ks:"https://"+Ks:NS(e)?"https://apisgp.my-imcloud.com":"https://yun.tim.qq.com";var i=Math.floor(Math.random()*Math.pow(2,31));return"".concat(n,"/v5/AVQualityReportSvc/C2S?random=").concat(i,"&sdkappid=").concat(e,"&cmdtype=").concat(t)};function Tp(){var e=navigator.userAgent,t=navigator.connection,n=e.match(/NetType\/\w+/)?e.match(/NetType\/\w+/)[0]:"";(n=n.toLowerCase().replace("nettype/",""))==="3gnet"&&(n="3g");var i=t&&t.type&&t.type.toLowerCase(),r=t&&t.effectiveType&&t.effectiveType.toLowerCase();r==="slow-2"&&(r="2g");var o=n||"unknown";if(i)switch(i){case"cellular":case"wimax":o=r||"unknown";break;case"wifi":o="wifi";break;case"ethernet":o="wired";break;case"none":case"other":case"unknown":o="unknown"}return o}var yi=function(e){if(!e||G(e)!=="object"||Object.prototype.toString.call(e)!="[object Object]")return!1;var t=Object.getPrototypeOf(e);if(t===null)return!0;var n=Object.prototype.hasOwnProperty.call(t,"constructor")&&t.constructor;return typeof n=="function"&&n instanceof n&&Function.prototype.toString.call(n)===Function.prototype.toString.call(Object)};function sl(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:1,n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:1;return e<=1?n:sl(e-1,n,t+n)}function xp(e){var t=Math.round(e/2)+1;return t>6?13e3:1e3*sl(t)}var ln=function(e){return typeof e=="function"},ge=function(e){return e===void 0},Bt=function(e){return typeof e=="string"},tr=function(e){return typeof e=="number"},nr=function(e){return typeof e=="boolean"},US=function(e){return bi(e)==="object"},ho=function(e){return bi(e)==="array"},VS=function(e){return bi(e)==="MediaStreamTrack".toLowerCase()};function bi(e){return Reflect.apply(Object.prototype.toString,e,[]).replace(/^\[object\s(\w+)\]$/,"$1").toLowerCase()}function jS(e){var t={};return t.urls="turn:".concat(e.url),ge(e.username)||ge(e.credential)||(t.username=e.username,t.credential=e.credential,t.credentialType="password",ge(e.credentialType)||(t.credentialType=e.credentialType)),t}function Ct(){return performance&&performance.now?Math.floor(performance.now()):Date.now()}function Ip(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"big";if(!Bt(e))return 0;var n=e.split(".");return t==="big"?(Number(n[0])<<24|Number(n[1])<<16|Number(n[2])<<8|Number(n[3]))>>>0:(Number(n[3])<<24|Number(n[2])<<16|Number(n[1])<<8|Number(n[0]))>>>0}var wp,Cp,oa=function(){var e=navigator.language||navigator.userLanguage;return(e=e.substr(0,2))==="zh"},BS=(wp=!1,Cp=document.visibilityState,function(){document.visibilityState!==Cp&&_e.info("visibility change: ".concat(document.visibilityState)),wp||(document.addEventListener("visibilitychange",function(){_e.info("visibility change: "+document.visibilityState),Cp=document.visibilityState}),wp=!0)});window.AudioContext=window.AudioContext||window.webkitAudioContext||window.mozAudioContext;var FS=function(){return new window.AudioContext},HS=function(){var e;return function(){return e||(e=new window.AudioContext,e.onstatechange=function(){_e.info("gain context state: ".concat(e.state)),e.state==="suspended"?(e.resume(),document.addEventListener("click",e.resume)):e.state==="interrupted"?e.resume():document.removeEventListener("click",e.resume)},e)}}(),A4=!!window.AudioWorkletNode,GS=function(e,t){var n=e.emit;return e.emit=function(){for(var i=arguments.length,r=new Array(i),o=0;o<i;o++)r[o]=arguments[o];try{n.apply(e,r)}catch(a){var c=ae({key:q3,data:{name:t,event:r[0]},addDocLink:!1});_e.warn(c+`
|
|
88
52
|
|
|
89
|
-
`+
|
|
90
|
-
`)}),g);case 12:I.forEach(function(A){return A.uploaded=!0});case 13:c++,w.next=8;break;case 16:w.next=20;break;case 18:w.prev=18,w.t0=w.catch(5);case 20:k=o.filter(function(A){return!A.uploaded}),k.length>0&&(this.queue_=k.concat(this.queue_));case 22:case"end":return w.stop()}},a,this,[[5,18]])})),function(){return t.apply(this,arguments)})},{key:"uploadLogWithRetry",value:function(a,i){return dc({retryFunction:function(){return hl({url:ll(i,kb),body:a,timeout:5e3})},settings:{retries:3,timeout:1e3},onError:function(r,o){o()}})()}},{key:"getPrefix",value:function(a){var i=new Date;return i.setTime(an()),String.prototype.padStart?"[".concat(i.toTimeString().replace(/.*(\d{2}:\d{2}:\d{2}).*/,"$1"),":").concat(i.getMilliseconds().toString().padStart(3,"0"),"] <").concat(ua[a],">"):"[".concat(i.toTimeString().replace(/.*(\d{2}:\d{2}:\d{2}).*/,"$1"),":").concat(i.getMilliseconds(),"] <").concat(ua[a],">")}},{key:"getLogLevel",value:function(){return this.logLevel_}},{key:"setLogLevel",value:function(a){ge(ua[a])||(this.logLevel_!==a&&this.info("setLogLevel ".concat(a)),this.logLevel_=a)}},{key:"enableUploadLog",value:function(){this.enableUploadLog_=!0}},{key:"disableUploadLog",value:function(){this.enableUploadLog_=!1}},{key:"log",value:function(a){var i=a.log,r=a.level,o=a.forAllJoinedClients,s=o===void 0||o,c=a.userId,u=a.sdkAppId;if(i="".concat(this.getPrefix(r)," ").concat(i),this.enableUploadLog_&&r>=this.logLevelToUpload_&&this.queue_.push(new z4({log:i,level:r,userId:c,sdkAppId:u,forAllJoinedClients:s})),!(r<this.logLevel_)){var d=ua[r]?ua[r].toLowerCase():"info";q4?console[d]("%cTRTC%c%s","padding: 1px 4px;border-radius: 3px;color: #fff;background: #1E88E5;","display: inline",i):console[d](i)}}},{key:"debug",value:function(a){this.log({log:a,level:Nn.DEBUG})}},{key:"info",value:function(a){this.log({log:a,level:Nn.INFO})}},{key:"warn",value:function(a){this.log({log:a,level:Nn.WARN})}},{key:"error",value:function(a){this.log({log:a,level:Nn.ERROR})}},{key:"createLogger",value:function(a){return new W4(a)}},{key:"checkURLParam",value:function(){var a=new URLSearchParams(location.search).get("logLevelToUpload");ua[a]&&(this.logLevelToUpload_=a)}}]),e}(),_e=new J4,YS=!0,K4=vt,X4=Math.floor,$S=Number.isInteger||function(e){return!K4(e)&&isFinite(e)&&X4(e)===e};Ue({target:"Number",stat:!0},{isInteger:$S});var tm,Q4=Ue,ZS=ke,Y4=ye.f,$4=vr,ek=Ft,Z4=g0,eU=en,tU=_0,tk=ZS("".startsWith),nU=ZS("".slice),rU=Math.min,nk=tU("startsWith");Q4({target:"String",proto:!0,forced:!!(nk||(tm=Y4(String.prototype,"startsWith"),!tm||tm.writable))&&!nk},{startsWith:function(e){var t=ek(eU(this));Z4(e);var n=$4(rU(arguments.length>1?arguments[1]:void 0,t.length)),a=ek(e);return tk?tk(t,a,n):nU(t,n,n+a.length)===a}});var rk=Se,iU=ke,aU=Ke,oU=ce,nm=lu,sU=Jd,cU=it,uU=Ut,lU=zt,ko=Object.assign,ik=Object.defineProperty,dU=iU([].concat),ak=!ko||oU(function(){if(rk&&ko({b:1},ko(ik({},"a",{enumerable:!0,get:function(){ik(this,"b",{value:3,enumerable:!1})}}),{b:2})).b!==1)return!0;var e={},t={},n=Symbol(),a="abcdefghijklmnopqrst";return e[n]=7,a.split("").forEach(function(i){t[i]=i}),ko({},e)[n]!=7||nm(ko({},t)).join("")!=a})?function(e,t){for(var n=uU(e),a=arguments.length,i=1,r=sU.f,o=cU.f;a>i;)for(var s,c=lU(arguments[i++]),u=r?dU(nm(c),r(c)):nm(c),d=u.length,g=0;d>g;)s=u[g++],rk&&!aU(o,c,s)||(n[s]=c[s]);return n}:ko,ok=ak;Ue({target:"Object",stat:!0,arity:2,forced:Object.assign!==ok},{assign:ok});var sk=ke,hU=vn,pU=vt,fU=rt,ck=Ka,mU=Dt,uk=Function,vU=sk([].concat),gU=sk([].join),rm={},_U=function(e,t,n){if(!fU(rm,t)){for(var a=[],i=0;i<t;i++)a[i]="a["+i+"]";rm[t]=uk("C,a","return new C("+gU(a,",")+")")}return rm[t](e,n)},yU=mU?uk.bind:function(e){var t=hU(this),n=t.prototype,a=ck(arguments,1),i=function(){var r=vU(a,ck(arguments));return this instanceof i?_U(t,r.length,r):t.apply(e,r)};return pU(n)&&(i.prototype=n),i},lk=yU;Ue({target:"Function",proto:!0,forced:Function.bind!==lk},{bind:lk});var bU=Ue,SU=rn.findIndex,kU=pu,dk="findIndex",hk=!0;dk in[]&&Array(1).findIndex(function(){hk=!1}),bU({target:"Array",proto:!0,forced:hk},{findIndex:function(e){return SU(this,e,arguments.length>1?arguments[1]:void 0)}}),kU(dk);var TU=Se,pk=ke,xU=lu,IU=pn,wU=pk(it.f),EU=pk([].push),fk=function(e){return function(t){for(var n,a=IU(t),i=xU(a),r=i.length,o=0,s=[];r>o;)n=i[o++],TU&&!wU(a,n)||EU(s,e?[n,a[n]]:a[n]);return s}},CU={entries:fk(!0),values:fk(!1)}.values;Ue({target:"Object",stat:!0},{values:function(e){return CU(e)}});var mk=1,vk=5,im=2,hc=3,am=4,gl="DISCONNECTED",gk="CONNECTING",om="RECONNECTING",pc="CONNECTED",Jr={CLIENT_BANNED:9,CHANNEL_SETUP_RESULT:19,CHANNEL_RECONNECT_RESULT:514,JOIN_ROOM_RESULT:20,PEER_JOIN:4134,PEER_LEAVE:4135,STREAM_ADDED:16,STREAM_REMOVED:18,UPLINK_NETWORK_STATS:22,UPDATE_REMOTE_MUTE_STAT:23,PUBLISH_RESULT:4098,PUBLISH_STATE_CHANGE_RESULT:4112,UNPUBLISH_RESULT:4100,SUBSCRIBE_RESULT:4102,UNSUBSCRIBE_RESULT:4104,SUBSCRIBE_CHANGE_RESULT:4106,MUTE_RESULT:4108,UPDATE_OFFER_RESULT:4128,START_PUBLISH_TENCENT_CDN_RES:1286,STOP_PUBLISH_TENCENT_CDN_RES:1288,START_PUBLISH_GIVEN_CDN_RES:777,STOP_PUBLISH_GIVEN_CDN_RES:779,START_MIX_TRANSCODE_RES:781,STOP_MIX_TRANSCODE_RES:783,USER_LIST_RES:4137,SWITCH_ROLE_RES:4110,UPDATE_CONSTRAINT_CONFIG_RES:772},RU=[Jr.UPDATE_REMOTE_MUTE_STAT,Jr.UPLINK_NETWORK_STATS,Jr.USER_LIST_RES,Jr.MUTE_RESULT],ft={CLIENT_BANNED:"client-banned",CHANNEL_SETUP_RESULT:"channel-setup-result",CHANNEL_RECONNECT_RESULT:"channel-reconnect-result",JOIN_ROOM_RESULT:"join-room-result",PEER_JOIN:"peer-join",PEER_LEAVE:"peer-leave",STREAM_ADDED:"stream-added",STREAM_REMOVED:"stream-removed",UPLINK_NETWORK_STATS:"uplink-network-stats",UPDATE_REMOTE_MUTE_STAT:"update-remote-mute-stat",PUBLISH_RESULT:"publish-result",PUBLISH_STATE_CHANGE_RESULT:"publish-state-change-result",UNPUBLISH_RESULT:"unpublish-result",SUBSCRIBE_RESULT:"subscribe-result",SUBSCRIBE_CHANGE_RESULT:"subscribe-change-result",UNSUBSCRIBE_RESULT:"unsubscribe-result",UPDATE_OFFER_RESULT:"update-offer-result",START_PUBLISH_TENCENT_CDN_RES:"start-publish-tencent-cdn-res",STOP_PUBLISH_TENCENT_CDN_RES:"stop-publish-tencent-cdn-res",START_PUBLISH_GIVEN_CDN_RES:"start-publish-given-cdn-res",STOP_PUBLISH_GIVEN_CDN_RES:"stop-publish-given-cdn-res",START_MIX_TRANSCODE_RES:"start-mix-transcode-res",STOP_MIX_TRANSCODE_RES:"stop-mix-transcode-res",USER_LIST_RES:"user-list-res",SWITCH_ROLE_RES:"switch_role_res",MUTE_RESULT:"mute-result",UPDATE_CONSTRAINT_CONFIG_RES:"update-contraint-config-res"},AU="publish_change",PU="publish_state_change",DU="join",LU="leave",OU="quality_report",MU="mute_uplink",NU="publish",_k="unpublish",UU="subscribe",VU="unsubscribe",jU="subscribe_change",BU="start_publishing",FU="stop_publishing",GU="start_push_user_cdn",HU="stop_push_user_cdn",zU="start_mcu_mix",WU="stop_mcu_mix",qU="get_user_list",JU="change_role",KU="update_constraint_config",ee={INVALID_PARAMETER:4096,INVALID_OPERATION:4097,NOT_SUPPORTED:4098,DEVICE_NOT_FOUND:4099,INITIALIZE_FAILED:4100,SIGNAL_CHANNEL_SETUP_FAILED:16385,SIGNAL_CHANNEL_ERROR:16386,ICE_TRANSPORT_ERROR:16387,JOIN_ROOM_FAILED:16388,CREATE_OFFER_FAILED:16389,SIGNAL_CHANNEL_RECONNECTION_FAILED:16390,UPLINK_RECONNECTION_FAILED:16391,DOWNLINK_RECONNECTION_FAILED:16392,REMOTE_STREAM_NOT_EXIST:16400,CLIENT_BANNED:16448,SERVER_TIMEOUT:16449,SUBSCRIPTION_TIMEOUT:16450,PLAY_NOT_ALLOWED:16451,DEVICE_AUTO_RECOVER_FAILED:16452,START_PUBLISH_CDN_FAILED:16453,STOP_PUBLISH_CDN_FAILED:16454,START_MIX_TRANSCODE_FAILED:16455,STOP_MIX_TRANSCODE_FAILED:16456,NOT_SUPPORTED_H264:16457,SWITCH_ROLE_FAILED:16458,API_CALL_TIMEOUT:16459,SCHEDULE_FAILED:16460,API_CALL_ABORTED:16461,UNKNOWN:65535},re=function(e){Ct(n,e);var t=Cr(n);function n(a){var i,r=a.name,o=r===void 0?"RtcError":r,s=a.message,c=a.code,u=c===void 0?ee.UNKNOWN:c,d=a.extraCode,g=d===void 0?0:d,I=a.constraint;K(this,n);var k="<".concat(function(w){for(var A in ee)if(ee[A]===w)return A;return"UNKNOWN"}(u)," 0x").concat(u.toString(16),">");return(i=t.call(this,s+"".concat(I?" constraint: ".concat(I):"")+"".concat(s!=null&&s.includes(k)?"":" "+k))).code_=u,i.extraCode_=g,i.name=o,i.message_=s,I&&(i.constraint=I),i}return we(n,[{key:"getCode",value:function(){return this.code_}},{key:"getExtraCode",value:function(){return this.extraCode_}}]),n}(es(Error)),yk=32768,bk=32769,Sk=32770,kk=32771,XU=32772,QU=32773,YU=32774,$U=32775,Tk=32777,ZU=32778,sm=32779,eV=32780,tV=32781,nV=32782,rV=32783,iV=32784,aV=32785,oV=32786,sV=32787,cV=32788,uV=32789,lV=32790,dV=32791,hV=32792,pV=32793,fV=32794,mV=32795,vV=32796,gV=32797,_V=32798,yV=32799,bV=32800,SV=32801,kV=32802,TV=32803,xV=32804,fc=new Map,yn=function(e,t){var n=fc.get(e);n||(fc.set(e,[]),n=fc.get(e)),n.push(t)},IV=function(e){var t=fc.get(e),n=[];return t?(fc.delete(e),n=t.map(function(a){return{uint32_event_id:a.eventId,uint64_date:a.timestamp,str_userid:a.remoteUserId,str_event_json:a.eventDesc}})):n=[],n},wV=Object.prototype.hasOwnProperty;function Ai(e){if(e==null)return!0;if(typeof e=="boolean")return!1;if(typeof e=="number")return e===0;if(typeof e=="string"||typeof e=="function"||Array.isArray(e))return e.length===0;if(e instanceof Error)return e.message==="";if(Ei(e))switch(Object.prototype.toString.call(e)){case"[object File]":case"[object Map]":case"[object Set]":return e.size===0;case"[object Object]":for(var t in e)if(wV.call(e,t))return!1;return!0}return!1}var EV=function(){function e(){K(this,e);var t=fa(),n=t.name,a=t.version;this.roomIdMap_=new Map,this.configs_={sdkAppId:"",userId:"",version:pi,env:Ju,browserVersion:n+a,ua:navigator.userAgent}}return we(e,[{key:"setConfig",value:function(t){var n=t.sdkAppId,a=t.env,i=t.userId,r=t.roomId;n!==this.configs_.sdkAppId&&(this.configs_.sdkAppId=String(n)),this.configs_.env=a,this.configs_.userId=i,this.roomIdMap_.set(i,String(r))}},{key:"logEvent",value:function(t){if(!ha){var n=q(q(q({},t),this.configs_),{},{userId:t.userId||this.configs_.userId});ge(n.code)&&(n.code=n.result==="failed"?ee.UNKNOWN:0),this.sendRequest(ll(this.configs_.sdkAppId,YM),n)}}},{key:"logSuccessEvent",value:function(t){ha||(this.logEvent(q(q({},t),{},{result:"success",roomId:this.roomIdMap_.get(t.userId)})),this.configs_.env===Ju&&this.uploadEventToKibana(q(q({},t),{},{result:"success"})))}},{key:"logFailedEvent",value:function(t){if(!ha){var n=t.eventType,a=t.code,i=t.error,r=t.userId,o={roomId:this.roomIdMap_.get(r),userId:r,eventType:n,result:"failed",code:a||(i instanceof re?i.getExtraCode()||i.getCode():ee.UNKNOWN)};this.logEvent(o),this.configs_.env===Ju&&this.uploadEventToKibana(q(q({},o),{},{error:i}))}}},{key:"uploadEventToKibana",value:function(t){var n="stat-".concat(t.eventType,"-").concat(t.result);t.eventType!=="delta-join"&&t.eventType!=="delta-leave"&&t.eventType!=="delta-publish"||(n="".concat(t.eventType,":").concat(t.delta)),this.uploadEvent({log:n,userId:t.userId}),t.result==="failed"&&(n="stat-".concat(t.eventType,"-").concat(t.result,"-").concat(t.code),this.uploadEvent({log:n,userId:t.userId,error:t.error}))}},{key:"uploadEvent",value:function(t){var n=t.log,a=t.userId,i=t.error,r={timestamp:Qy(),sdkAppId:this.configs_.sdkAppId,userId:a||this.configs_.userId,version:this.configs_.version,log:n};i&&(r.errorInfo=i.message),this.sendRequest(ll(this.configs_.sdkAppId,kb),r)}},{key:"sendRequest",value:function(t,n){var a=this;_e.getIsAbleToUpload()?hl({url:t,body:JSON.stringify(n)}).catch(function(){}):setTimeout(function(){a.sendRequest(t,n)},1e3)}}]),e}(),Ie=new EV,CV=function(){function e(t){K(this,e),this.client_=t.client,this.sdkAppId_=t.sdkAppId,this.userId_=t.userId,this.userSig_=t.userSig,this.url_=t.url,this.backupUrl_=t.backupUrl;var n="?sdkAppId=".concat(encodeURIComponent(this.sdkAppId_),"&userId=").concat(encodeURIComponent(this.userId_),"&userSig=").concat(encodeURIComponent(this.userSig_),"&roomId=").concat(encodeURIComponent(t.roomId)),a=this.client_.getSystemResult();if(a&&a.detail){var i=a.detail,r=i.isH264EncodeSupported,o=i.isVp8EncodeSupported,s=i.isH264DecodeSupported,c=i.isVp8DecodeSupported;n+="&enc264=".concat(Number(r),"&dec264=").concat(Number(s),"&encVp8=").concat(Number(o),"&decVp8=").concat(Number(c))}t.signalDomainWhenUnifiedProxy&&(n+="&signalDomain=".concat(encodeURIComponent(t.signalDomainWhenUnifiedProxy))),this.urlWithParam_="".concat(this.url_).concat(n),this.backupUrlWithParam_="".concat(this.backupUrl_).concat(n),this.isConnected_=!1,this.isConnecting_=!1,this.socketInUse_=null,this.socket_=null,this.backupSocket_=null,this.backupTimer_=-1,this.signalInfo_={},this.currentState_=gl,this.reconnectionCount_=0,this.reconnectionTimer_=-1,this.lastMessageTime_=-1,this.seq_=0,this.log_=_e.createLogger({id:"ws|"+this.userId_,userId:this.userId_,sdkAppId:this.sdkAppId_}),this.emitter_=new Ri}return we(e,[{key:"isOnline",get:function(){return this.currentState_===pc&&Date.now()-this.lastMessageTime_<12e3}},{key:"connect",value:function(){var t=this;return new Promise(function(n,a){t.log_.info("connect to url: ".concat(t.urlWithParam_)),t.emitConnectionStateChanged(gk),t.socket_=new WebSocket(t.urlWithParam_),t.bindSocket(t.socket_),t.backupTimer_=setTimeout(function(){t.isConnected_||(t.log_.info("trying to connect to backupUrl"),t.tryConnectBackup())},5e3);var i=setTimeout(function(){t.close(),a(new re({code:ee.JOIN_ROOM_FAILED,message:"join room timeout"}))},1e4);t.once(hc,function(){clearTimeout(i),n()}),t.once(am,function(r){clearTimeout(i),a(r)})})}},{key:"tryConnectBackup",value:function(){this.backupSocket_||(this.unbindAndCloseSocket(Qe),this.log_.debug("try to connect to url: ".concat(this.backupUrlWithParam_)),this.backupSocket_=new WebSocket(this.backupUrlWithParam_),this.bindSocket(this.backupSocket_))}},{key:"bindSocket",value:function(t){t.onopen=this.onopen.bind(this),t.onclose=this.onclose.bind(this),t.onerror=this.onerror.bind(this),t.onmessage=this.onmessage.bind(this)}},{key:"unbindSocket",value:function(t){t.onopen=function(){},t.onclose=function(){},t.onerror=function(){},t.onmessage=function(){}}},{key:"unbindAndCloseSocket",value:function(t){if(t===Qe){if(this.socket_){this.unbindSocket(this.socket_);try{this.socket_.close(1e3)}catch(n){}this.socket_=null}}else if(this.backupSocket_){this.unbindSocket(this.backupSocket_);try{this.backupSocket_.close(1e3)}catch(n){}this.backupSocket_=null}}},{key:"clearBackupTimer",value:function(){this.backupTimer_!==-1&&(clearTimeout(this.backupTimer_),this.backupTimer_=-1)}},{key:"clearReconnectionTimer",value:function(){this.reconnectionTimer_!==-1&&(clearTimeout(this.reconnectionTimer_),this.reconnectionTimer_=-1)}},{key:"onopen",value:function(t){if(!this.isConnected_){this.isConnected_=!0,this.isConnecting_=!1,this.isReconnecting_&&Ai(this.signalInfo_)&&this.stopReconnection(),this.clearBackupTimer(),t.target===this.socket_?(this.unbindAndCloseSocket(Hr),this.socketInUse_=this.socket_):(this.unbindAndCloseSocket(Qe),this.socketInUse_=this.backupSocket_);var n=t.target.url;this.log_.info("websocket[".concat(n,"] is connected")),this.currentState_===gk?this.addSignalEvent(dV,"signal channel is connected"):this.currentState_===om&&this.addSignalEvent(mV,"signal channel reconnect success"),this.emitConnectionStateChanged(pc),this.emitter_.emit(hc)}}},{key:"onclose",value:function(t){var n=t.target.url,a=t.target===this.socketInUse_;if(this.log_.info("websocket[".concat(n," InUse: ").concat(a,"] is closed with code: ").concat(t.code)),a&&(this.isConnected_=!1,this.emitConnectionStateChanged(gl),this.addSignalEvent(lV,"signal channel is disconnected"),!t.wasClean||t.code!==1e3)){this.log_.warn("onclose code:".concat(t.code," reason:").concat(t.reason)),this.log_.warn("close current websocket and schedule a reconnect timeout"),this.socketInUse_.onclose=function(){},this.socketInUse_.close(4011);var i=this.socketInUse_===this.socket_;this.socket_=this.backupSocket_=this.socketInUse_=null,this.reconnect(i?Hr:Qe)}}},{key:"onerror",value:function(t){var n=t.target.url;if(this.log_.error("websocket[".concat(n,"] error observed")),this.isConnected_){if(t.target===this.socketInUse_){this.isConnected_=!1,this.unbindAndCloseSocket(Qe),this.unbindAndCloseSocket(Hr);var a=this.socketInUse_===this.socket_;this.socketInUse_=null,this.reconnect(a?Hr:Qe)}}else this.isReconnecting_||Ie.logFailedEvent({userId:this.client_.getUserId(),eventType:Gp,code:ee.UNKNOWN}),t.target==this.socket_?(this.unbindAndCloseSocket(Qe),this.reconnect(Hr)):(this.unbindAndCloseSocket(Hr),this.reconnect(Qe));this.isConnecting_=!1,this.isConnected_=!1}},{key:"onmessage",value:function(t){if(this.isConnected_){this.lastMessageTime_=Date.now();var n=JSON.parse(t.data),a=n.cmd,i=n.data,r=Object.values(Jr),o=Object.keys(Jr)[r.indexOf(a)],s=ft[o];switch(RU.includes(a)||(this.log_.debug("received msg: ".concat(t.data)),this.log_.info("Received event: [ ".concat(s||"unknown cmd: "+a," ]"))),a){case Jr.CHANNEL_SETUP_RESULT:if(n.code===0)this.signalInfo_.clientIp=i.clientIp,this.signalInfo_.signalIp=i.signalInnerIp,this.signalInfo_.tinyId=n.tinyId,i.svrTime&&function(u){np=u-new Date().getTime();var d=new Date;d.setTime(u),_e.info("baseTime from server: "+d+" offset: "+np)}(i.svrTime),this.log_.info("ChannelSetup Success"),Ie.logSuccessEvent({userId:this.userId_,eventType:Gp}),this.emitter_.emit(mk,{signalInfo:this.signalInfo_});else{var c=new re({code:ee.SIGNAL_CHANNEL_SETUP_FAILED,extraCode:n.code,message:ie({key:DN,data:{errorCode:n.code,errorMsg:n.message}})});this.log_.error("".concat(n.code,", ").concat(n.message)),this.close(),Ie.logFailedEvent({userId:this.userId_,eventType:Gp,error:c}),this.emitter_.emit(vk,c)}break;case Jr.JOIN_ROOM_RESULT:n.code===0&&(this.signalInfo_.relayIp=i.relayOuterIp,this.signalInfo_.relayInnerIp=i.relayInnerIp,this.signalInfo_.relayPort=i.relayPort,this.log_.info("signalIp:".concat(this.signalInfo_.signalIp," clientIp:").concat(this.signalInfo_.clientIp," relayIp: ").concat(this.signalInfo_.relayIp))),this.emitter_.emit(s,{data:n});break;case Jr.CHANNEL_RECONNECT_RESULT:n.code===0?(this.log_.warn("reconnect success"),this.stopReconnection(),Ie.logSuccessEvent({userId:this.userId_,eventType:Vb}),this.client_.syncUserList(),this.client_.checkConnectionsToReconnect()):(this.log_.warn("reconnect failed, ".concat(n.code," ").concat(n.message)),this.client_.reJoin());break;default:this.emitter_.emit(s,{data:n})}}}},{key:"addSignalEvent",value:function(t,n){yn(this.userId_,{eventId:t,eventDesc:n,timestamp:an(),userId:this.userId_,tinyId:this.signalInfo_.tinyId})}},{key:"reconnect",value:function(){var t=this,n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:Qe;if(this.isConnecting_||this.reconnectionTimer_!==-1)this.log_.info("signal channel is reconnecting, ignoring current reconnection");else{if(X.emit(XS,this.client_),this.reconnectionCount_>=Fp){this.log_.warn("SDK has tried reconnect signal channel for ".concat(Fp," times, but all failed. please check your network"));var a=new re({code:ee.SIGNAL_CHANNEL_RECONNECTION_FAILED,message:ie({key:PN})});return Ie.logFailedEvent({userId:this.client_.getUserId(),eventType:Vb,error:a}),this.addSignalEvent(vV,"signal channel reconnect fail"),void this.emitter_.emit(am,a)}this.isConnecting_=!0,this.reconnectionCount_++,this.currentState_!==om&&(this.emitConnectionStateChanged(om),this.addSignalEvent(fV,"signal channel is reconnecting")),this.log_.warn("reconnecting to ".concat(n," signal channel [").concat(this.reconnectionCount_,"/").concat(Fp,"]"));var i=this.getReconnectionUrl(n);n===Qe?(this.socket_=new WebSocket(i),this.bindSocket(this.socket_)):(this.backupSocket_=new WebSocket(i),this.bindSocket(this.backupSocket_));var r=If(this.reconnectionCount_);this.reconnectionTimer_=setTimeout(function(){t.log_.warn("reconnect ".concat(n," signal channel timeout(").concat(r/1e3,"s), close and try again")),t.isConnecting_=!1,t.clearReconnectionTimer(),t.unbindAndCloseSocket(n),t.reconnect(n===Qe?Hr:Qe)},r)}}},{key:"isConnected",value:function(){return this.isConnected_}},{key:"isReconnecting_",get:function(){return this.reconnectionTimer_!==-1}},{key:"getReconnectionUrl",value:function(t){var n=t===Qe?this.urlWithParam_:this.backupUrlWithParam_;if(!Ai(this.signalInfo_)&&n.indexOf("&rc=1")===-1){var a=this.client_.getRoomId(),i=this.client_.getUseStringRoomId();n+="&rc=1&relayInnerIp=".concat(this.signalInfo_.relayInnerIp,"&relayOuterIp=").concat(this.signalInfo_.relayIp,"&relayPort=").concat(this.signalInfo_.relayPort,"&roomId=").concat(a,"&useStringRoomId=").concat(i)}return n}},{key:"send",value:function(t){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(this.isConnected_){var a={cmd:t,data:n,userId:this.userId_,tinyId:this.signalInfo_.tinyId,seq:++this.seq_};return this.socketInUse_.send(JSON.stringify(a)),a.seq}}},{key:"sendWaitForResponse",value:function(t){var n=this,a=t.command,i=t.data,r=t.timeout,o=r===void 0?5e3:r,s=t.responseCommand,c=t.commandDesc,u=t.enableLog,d=u===void 0||u;return new Promise(function(g,I){var k=setTimeout(function(){n.off(s,w);var p=new re({code:ee.API_CALL_TIMEOUT,message:ie({key:AN,data:{commandDesc:c,command:a}})});d&&n.log_.warn(p),I(p)},o),w=function p(v){v.data.seq===A&&(clearTimeout(k),n.off(s,p),g(v))};n.on(s,w);var A=n.send(a,i)})}},{key:"sendWaitForResponseWithRetry",value:function(){var t=this,n=arguments.length<=0?void 0:arguments[0],a=n.commandDesc,i=n.command,r=n.retries,o=r===void 0?0:r,s=n.retryTimeout,c=s===void 0?0:s;return dc({retryFunction:this.sendWaitForResponse,onRetrying:function(u){t.log_.warn("".concat(a||i," timeout observed, retrying [").concat(u,"/").concat(o,"]"))},settings:{retries:o,timeout:c},context:this}).apply(void 0,arguments)}},{key:"getCurrentState",value:function(){return this.currentState_}},{key:"getSignalInfo",value:function(){return this.signalInfo_}},{key:"stopReconnection",value:function(){this.isReconnecting_&&(this.reconnectionCount_=0,this.clearReconnectionTimer())}},{key:"close",value:function(){this.log_.info("close SignalChannel"),this.clearBackupTimer(),this.stopReconnection(),this.signalInfo_={},this.isConnecting_=!1,this.isConnected_=!1,this.socketInUse_=null,this.unbindAndCloseSocket(Qe),this.unbindAndCloseSocket(Hr),this.emitConnectionStateChanged(gl)}},{key:"on",value:function(t,n,a){this.emitter_.on(t,n,a)}},{key:"removeListener",value:function(t,n,a){this.emitter_.removeListener(t,n,a)}},{key:"once",value:function(t,n,a){this.emitter_.once(t,n,a)}},{key:"off",value:function(t,n,a){this.emitter_.off(t,n,a)}},{key:"emitConnectionStateChanged",value:function(t){t!==this.currentState_&&(this.emitter_.emit(im,{prevState:this.currentState_,state:t}),this.currentState_=t)}}]),e}(),RV=Ue,AV=rn.find,PV=pu,xk="find",Ik=!0;xk in[]&&Array(1).find(function(){Ik=!1}),RV({target:"Array",proto:!0,forced:Ik},{find:function(e){return AV(this,e,arguments.length>1?arguments[1]:void 0)}}),PV(xk);var tr={},wk={},cm={exports:{}},Ek=cm.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 e.address!=null?"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 e.subtype!=null?"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 e.sessionConfig!=null?"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+=e.raddr!=null?" raddr %s rport %d":"%v%v",t+=e.tcptype!=null?" tcptype %s":"%v",e.generation!=null&&(t+=" generation %d"),t+=e["network-id"]!=null?" network-id %d":"%v",t+=e["network-cost"]!=null?" 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 e.attribute!=null&&(t+=" %s",e.value!=null&&(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 e.maxMessageSize!=null?"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"+(e.clksrcExt!=null?"=%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+=e.id!=null?"id=%s %s":"%v%s",t+=e.mediaClockValue!=null?"=%s":"",t+=e.rateNumerator!=null?" rate=%s":"",t+=e.rateDenominator!=null?"/%s":""}},{name:"keywords",reg:/^keywds:(.+)$/,format:"keywds:%s"},{name:"content",reg:/^content:(.+)/,format:"content:%s"},{name:"bfcpFloorCtrl",reg:/^floorctrl:(c-only|s-only|c-s)/,format:"floorctrl:%s"},{name:"bfcpConfId",reg:/^confid:(\d+)/,format:"confid:%s"},{name:"bfcpUserId",reg:/^userid:(\d+)/,format:"userid:%s"},{name:"bfcpFloorId",reg:/^floorid:(.+) (?:m-stream|mstrm):(.+)/,names:["id","mStream"],format:"floorid:%s mstrm:%s"},{push:"invalid",names:["value"]}]};Object.keys(Ek).forEach(function(e){Ek[e].forEach(function(t){t.reg||(t.reg=/(.*)/),t.format||(t.format="%s")})}),function(e){var t=function(o){return String(Number(o))===o?Number(o):o},n=function(o,s,c){var u=o.name&&o.names;o.push&&!s[o.push]?s[o.push]=[]:u&&!s[o.name]&&(s[o.name]={});var d=o.push?{}:u?s[o.name]:s;(function(g,I,k,w){if(w&&!k)I[w]=t(g[1]);else for(var A=0;A<k.length;A+=1)g[A+1]!=null&&(I[k[A]]=t(g[A+1]))})(c.match(o.reg),d,o.names,o.name),o.push&&s[o.push].push(d)},a=cm.exports,i=RegExp.prototype.test.bind(/^([a-z])=(.*)/);e.parse=function(o){var s={},c=[],u=s;return o.split(/(\r\n|\r|\n)/).filter(i).forEach(function(d){var g=d[0],I=d.slice(2);g==="m"&&(c.push({rtp:[],fmtp:[]}),u=c[c.length-1]);for(var k=0;k<(a[g]||[]).length;k+=1){var w=a[g][k];if(w.reg.test(I))return n(w,u,I)}}),s.media=c,s};var r=function(o,s){var c=s.split(/=(.+)/,2);return c.length===2?o[c[0]]=t(c[1]):c.length===1&&s.length>1&&(o[c[0]]=void 0),o};e.parseParams=function(o){return o.split(/;\s?/).reduce(r,{})},e.parseFmtpConfig=e.parseParams,e.parsePayloads=function(o){return o.toString().split(" ").map(Number)},e.parseRemoteCandidates=function(o){for(var s=[],c=o.split(" ").map(t),u=0;u<c.length;u+=3)s.push({component:c[u],ip:c[u+1],port:c[u+2]});return s},e.parseImageAttributes=function(o){return o.split(" ").map(function(s){return s.substring(1,s.length-1).split(",").reduce(r,{})})},e.parseSimulcastStreamList=function(o){return o.split(";").map(function(s){return s.split(",").map(function(c){var u,d=!1;return c[0]!=="~"?u=t(c):(u=t(c.substring(1,c.length)),d=!0),{scid:u,paused:d}})})}}(wk);var um=cm.exports,DV=/%[sdv%]/g,LV=function(e){var t=1,n=arguments,a=n.length;return e.replace(DV,function(i){if(t>=a)return i;var r=n[t];switch(t+=1,i){case"%%":return"%";case"%s":return String(r);case"%d":return Number(r);case"%v":return""}})},mc=function(e,t,n){var a=[e+"="+(t.format instanceof Function?t.format(t.push?n:n[t.name]):t.format)];if(t.names)for(var i=0;i<t.names.length;i+=1){var r=t.names[i];t.name?a.push(n[t.name][r]):a.push(n[t.names[i]])}else a.push(n[t.name]);return LV.apply(null,a)},OV=["v","o","s","i","u","e","p","c","b","t","r","z","a"],MV=["i","c","b","a"],_a=wk,NV=function(e,t){t=t||{},e.version==null&&(e.version=0),e.name==null&&(e.name=" "),e.media.forEach(function(r){r.payloads==null&&(r.payloads="")});var n=t.outerOrder||OV,a=t.innerOrder||MV,i=[];return n.forEach(function(r){um[r].forEach(function(o){o.name in e&&e[o.name]!=null?i.push(mc(r,o,e)):o.push in e&&e[o.push]!=null&&e[o.push].forEach(function(s){i.push(mc(r,o,s))})})}),e.media.forEach(function(r){i.push(mc("m",um.m[0],r)),a.forEach(function(o){um[o].forEach(function(s){s.name in r&&r[s.name]!=null?i.push(mc(o,s,r)):s.push in r&&r[s.push]!=null&&r[s.push].forEach(function(c){i.push(mc(o,s,c))})})})}),i.join(`\r
|
|
53
|
+
`+a.stack)}},e},zS=function(e){return+e<10?"0".concat(e):e},P4=function(e){var t=e.match(/^\d+\.\d+\.\d+/)[0];if(!t)return e;var n=t.split("."),i=zS(n[1])+zS(n[2]);return n[1]-15>0&&(n[1]="15"),n[2]-15>0&&(n[2]="15"),n.join(".")+"."+i};function fo(e,t){try{if(ho(e))return"[".concat(e.map(function(r){return fo(r,t)}).join(","),"]");if(!yi(e)||!ho(t))return JSON.stringify(e);var n={},i=new Set(t);return Object.keys(e).forEach(function(r){i.has(r)&&(n[r]=e[r])}),JSON.stringify(n)}catch(r){return"{}"}}function cl(e){var t=e.url,n=e.body,i=e.method,r=e.timeout,o=new XMLHttpRequest;return new Promise(function(c,a){o.onload=function(l){if(o.status>=200&&o.status<300&&o.responseText.length>0)try{var u=JSON.parse(o.response);c({data:u})}catch(f){c({data:o.response})}else o.status>0&&a({code:o.status,message:"request failed, readyState:".concat(o.readyState," status:").concat(o.status," loaded size:").concat(l.loaded)})};var s=function(l){a({code:o.readyState,message:"request ".concat(l.type,", readyState:").concat(o.readyState," status:").concat(o.status," loaded size:").concat(l.loaded)})};o.onerror=s,o.onabort=s,o.ontimeout=s,o.timeout=r||5e3,o.open(i||"POST",t,!0),o.send(n)})}var WS={exports:{}};(function(e){var t=Object.prototype.hasOwnProperty,n="~";function i(){}function r(s,l,u){this.fn=s,this.context=l,this.once=u||!1}function o(s,l,u,f,S){if(typeof u!="function")throw new TypeError("The listener must be a function");var x=new r(u,f||s,S),E=n?n+l:l;return s._events[E]?s._events[E].fn?s._events[E]=[s._events[E],x]:s._events[E].push(x):(s._events[E]=x,s._eventsCount++),s}function c(s,l){--s._eventsCount==0?s._events=new i:delete s._events[l]}function a(){this._events=new i,this._eventsCount=0}Object.create&&(i.prototype=Object.create(null),new i().__proto__||(n=!1)),a.prototype.eventNames=function(){var s,l,u=[];if(this._eventsCount===0)return u;for(l in s=this._events)t.call(s,l)&&u.push(n?l.slice(1):l);return Object.getOwnPropertySymbols?u.concat(Object.getOwnPropertySymbols(s)):u},a.prototype.listeners=function(s){var l=n?n+s:s,u=this._events[l];if(!u)return[];if(u.fn)return[u.fn];for(var f=0,S=u.length,x=new Array(S);f<S;f++)x[f]=u[f].fn;return x},a.prototype.listenerCount=function(s){var l=n?n+s:s,u=this._events[l];return u?u.fn?1:u.length:0},a.prototype.emit=function(s,l,u,f,S,x){var E=n?n+s:s;if(!this._events[E])return!1;var I,m,T=this._events[E],v=arguments.length;if(T.fn){switch(T.once&&this.removeListener(s,T.fn,void 0,!0),v){case 1:return T.fn.call(T.context),!0;case 2:return T.fn.call(T.context,l),!0;case 3:return T.fn.call(T.context,l,u),!0;case 4:return T.fn.call(T.context,l,u,f),!0;case 5:return T.fn.call(T.context,l,u,f,S),!0;case 6:return T.fn.call(T.context,l,u,f,S,x),!0}for(m=1,I=new Array(v-1);m<v;m++)I[m-1]=arguments[m];T.fn.apply(T.context,I)}else{var w,L=T.length;for(m=0;m<L;m++)switch(T[m].once&&this.removeListener(s,T[m].fn,void 0,!0),v){case 1:T[m].fn.call(T[m].context);break;case 2:T[m].fn.call(T[m].context,l);break;case 3:T[m].fn.call(T[m].context,l,u);break;case 4:T[m].fn.call(T[m].context,l,u,f);break;default:if(!I)for(w=1,I=new Array(v-1);w<v;w++)I[w-1]=arguments[w];T[m].fn.apply(T[m].context,I)}}return!0},a.prototype.on=function(s,l,u){return o(this,s,l,u,!1)},a.prototype.once=function(s,l,u){return o(this,s,l,u,!0)},a.prototype.removeListener=function(s,l,u,f){var S=n?n+s:s;if(!this._events[S])return this;if(!l)return c(this,S),this;var x=this._events[S];if(x.fn)x.fn!==l||f&&!x.once||u&&x.context!==u||c(this,S);else{for(var E=0,I=[],m=x.length;E<m;E++)(x[E].fn!==l||f&&!x[E].once||u&&x[E].context!==u)&&I.push(x[E]);I.length?this._events[S]=I.length===1?I[0]:I:c(this,S)}return this},a.prototype.removeAllListeners=function(s){var l;return s?(l=n?n+s:s,this._events[l]&&c(this,l)):(this._events=new i,this._eventsCount=0),this},a.prototype.off=a.prototype.removeListener,a.prototype.addListener=a.prototype.on,a.prefixed=n,a.EventEmitter=a,e.exports=a})(WS);var Si=WS.exports,Y=new Si,ul=1,Ep=2,Rp=3,po=4,sa=5,Ap=20,Pp=21,mo=22,Dp=23,Op=24,Lp=27,Mp=28,ll=29,JS=30,qS=31,Np=32,Up=33,KS=40,D4=41,O4=52,L4=100,XS=101,tc=102,Vp=103,jn=110,dl=111,jp=112,Ur=113,Vr=114,M4=115,ca=116,N4=120,Bp=121,Fp=122,Hp=123,nc=130,Gp=131,zp=132,Wp=133,Jp=134,qp=135,Kp=136,Xp=137,hl=200,Qp=201,Yp=300,rc=301,$p=302,Zp=303;function ic(e){var t=e.retryFunction,n=e.settings,i=e.onError,r=e.onRetrying,o=e.onRetryFailed,c=e.onRetrySuccess,a=e.context;return function(){for(var s=this,l=arguments.length,u=new Array(l),f=0;f<l;f++)u[f]=arguments[f];var S=n.retries||5,x=0,E=-1,I=0,m=function(){var T=H(p().mark(function v(w,L){var N,V,_,b;return p().wrap(function(R){for(;;)switch(R.prev=R.next){case 0:return N=a||s,R.prev=1,R.next=4,t.apply(N,u);case 4:V=R.sent,x!==0&&ln(c)&&c.call(N,x),x=0,w(V),R.next=15;break;case 10:R.prev=10,R.t0=R.catch(1),_=function(){clearTimeout(E),x=0,I=2,L(R.t0)},b=function(){I!==2&&x<S?(x++,I=1,ln(r)&&r.call(N,x,_),E=setTimeout(function(){E=-1,m(w,L)},ge(n.timeout)?1e3:n.timeout)):(_(),ln(o)&&o.call(N,R.t0))},ln(i)?i.call(N,R.t0,b,L,u,x):b();case 15:case"end":return R.stop()}},v,null,[[1,10]])}));return function(v,w){return T.apply(this,arguments)}}();return new Promise(m)}}var U4=Ie(function e(t){Q(this,e),this.log=t.log,this.level=t.level,this.userId=t.userId,this.sdkAppId=t.sdkAppId,this.forAllJoinedClients=t.forAllJoinedClients,this.uploaded=!1}),V4=function(){function e(t){Q(this,e),this.id_=t.id,this.userId_=t.userId,this.sdkAppId_=t.sdkAppId,this.type_=t.type,this.isLocal_=!nr(t.isLocal)||t.isLocal}return Ie(e,[{key:"setUserId",value:function(t){this.userId_=t}},{key:"setSdkAppId",value:function(t){this.sdkAppId_=t}},{key:"log",value:function(t,n){_e.log({log:"[".concat(this.isLocal_?"\u2191":"\u2193").concat(this.id_,"] ").concat(this.type_?this.type_+" ":"").concat(n),level:t,forAllJoinedClients:ge(this.userId_),userId:this.userId_,sdkAppId:this.sdkAppId_})}},{key:"info",value:function(t){this.log(Un.INFO,t)}},{key:"debug",value:function(t){this.log(Un.DEBUG,t)}},{key:"warn",value:function(t){this.log(Un.WARN,t)}},{key:"error",value:function(t){this.log(Un.ERROR,t)}}]),e}(),j4=!(gi||ta),B4=function(){function e(){var i=this;Q(this,e),this.clients_=new Set,this.queue_=[],this.timeoutId_=-1,this.logLevel_=Un.DEBUG,this.logLevelToUpload_=Un.INFO,this.enableUploadLog_=!0,this.isAbleToUpload_=!1,this.checkURLParam(),Y.on(JS,function(r){var o=r.client;i.timeoutId_===-1&&i.startUpload(),i.clients_.add(o)}),Y.on(Up,function(r){var o=r.client;return i.clients_.delete(o)}),Y.on(qS,function(r){r&&yi(r.config)&&ea[r.config.logLevelToUpload]&&(i.logLevelToUpload_=r.config.logLevelToUpload)}),Y.on(po,this.setIsAbleToUpload,this),Y.on(sa,this.setIsAbleToUpload,this)}var t,n;return Ie(e,[{key:"getIsAbleToUpload",value:function(){return this.isAbleToUpload_}},{key:"setIsAbleToUpload",value:function(){this.isAbleToUpload_=!0,Y.off(po,this.setIsAbleToUpload,this),Y.off(sa,this.setIsAbleToUpload,this)}},{key:"startUpload",value:(n=H(p().mark(function i(){var r=this;return p().wrap(function(o){for(;;)switch(o.prev=o.next){case 0:return o.prev=0,o.next=3,this.upload();case 3:o.next=7;break;case 5:o.prev=5,o.t0=o.catch(0);case 7:this.timeoutId_=setTimeout(function(){return r.startUpload()},2e3);case 8:case"end":return o.stop()}},i,this,[[0,5]])})),function(){return n.apply(this,arguments)})},{key:"getLogsToUpload",value:function(){var i=this,r={map:new Map,splicedQueue:[]};if(this.queue_[0].forAllJoinedClients&&this.clients_.size===0)return r;for(var o=0,c=function(){if(o===50)return"break";var a=i.queue_[o];if(a.forAllJoinedClients){var s=new Set;i.clients_.forEach(function(l){if(l.getIsJoined()){var u=l.getUserId(),f=l.getSDKAppId();s.has("".concat(u,"-").concat(f))||(s.add("".concat(u,"-").concat(f)),r.map.has(u)?r.map.get(u).logs.push(a):r.map.set(u,{userId:u,sdkAppId:f,logs:[a]}))}})}else r.map.has(a.userId)?r.map.get(a.userId).logs.push(a):r.map.set(a.userId,{userId:a.userId,sdkAppId:a.sdkAppId,logs:[a]})};o<this.queue_.length&&c()!=="break";o++);return r.map.size>0&&(r.splicedQueue=this.queue_.splice(0,o)),r}},{key:"upload",value:(t=H(p().mark(function i(){var r,o,c,a,s,l,u,f,S,x;return p().wrap(function(E){for(;;)switch(E.prev=E.next){case 0:if(this.queue_.length!==0&&this.isAbleToUpload_){E.next=2;break}return E.abrupt("return");case 2:if(r=this.getLogsToUpload(),o=r.map,c=r.splicedQueue,o.size!==0){E.next=5;break}return E.abrupt("return");case 5:E.prev=5,a=Se(o.values()),s=0;case 8:if(!(s<a.length)){E.next=16;break}return l=a[s],u=l.userId,f=l.sdkAppId,S=l.logs,E.next=12,this.uploadLogWithRetry(JSON.stringify({timestamp:qy(),sdkAppId:String(f),userId:u,version:Gi,log:S.map(function(I){return I.log}).join(`
|
|
54
|
+
`)}),f);case 12:S.forEach(function(I){return I.uploaded=!0});case 13:s++,E.next=8;break;case 16:E.next=20;break;case 18:E.prev=18,E.t0=E.catch(5);case 20:x=c.filter(function(I){return!I.uploaded}),x.length>0&&(this.queue_=x.concat(this.queue_));case 22:case"end":return E.stop()}},i,this,[[5,18]])})),function(){return t.apply(this,arguments)})},{key:"uploadLogWithRetry",value:function(i,r){return ic({retryFunction:function(){return cl({url:ol(r,yb),body:i,timeout:5e3})},settings:{retries:3,timeout:1e3},onError:function(o,c){c()}})()}},{key:"getPrefix",value:function(i){var r=new Date;return r.setTime(an()),String.prototype.padStart?"[".concat(r.toTimeString().replace(/.*(\d{2}:\d{2}:\d{2}).*/,"$1"),":").concat(r.getMilliseconds().toString().padStart(3,"0"),"] <").concat(ea[i],">"):"[".concat(r.toTimeString().replace(/.*(\d{2}:\d{2}:\d{2}).*/,"$1"),":").concat(r.getMilliseconds(),"] <").concat(ea[i],">")}},{key:"getLogLevel",value:function(){return this.logLevel_}},{key:"setLogLevel",value:function(i){ge(ea[i])||(this.logLevel_!==i&&this.info("setLogLevel ".concat(i)),this.logLevel_=i)}},{key:"enableUploadLog",value:function(){this.enableUploadLog_=!0}},{key:"disableUploadLog",value:function(){this.enableUploadLog_=!1}},{key:"log",value:function(i){var r=i.log,o=i.level,c=i.forAllJoinedClients,a=c===void 0||c,s=i.userId,l=i.sdkAppId;if(r="".concat(this.getPrefix(o)," ").concat(r),this.enableUploadLog_&&o>=this.logLevelToUpload_&&this.queue_.push(new U4({log:r,level:o,userId:s,sdkAppId:l,forAllJoinedClients:a})),!(o<this.logLevel_)){var u=ea[o]?ea[o].toLowerCase():"info";j4?console[u]("%cTRTC%c%s","padding: 1px 4px;border-radius: 3px;color: #fff;background: #1E88E5;","display: inline",r):console[u](r)}}},{key:"debug",value:function(i){this.log({log:i,level:Un.DEBUG})}},{key:"info",value:function(i){this.log({log:i,level:Un.INFO})}},{key:"warn",value:function(i){this.log({log:i,level:Un.WARN})}},{key:"error",value:function(i){this.log({log:i,level:Un.ERROR})}},{key:"createLogger",value:function(i){return new V4(i)}},{key:"checkURLParam",value:function(){var i=new URLSearchParams(location.search).get("logLevelToUpload");ea[i]&&(this.logLevelToUpload_=i)}}]),e}(),_e=new B4,QS=!0,F4=at,H4=Math.floor,YS=Number.isInteger||function(e){return!F4(e)&&isFinite(e)&&H4(e)===e};Le({target:"Number",stat:!0},{isInteger:YS});var em,G4=Le,$S=pe,z4=be.f,W4=yr,ZS=zt,J4=p0,q4=pt,K4=m0,ek=$S("".startsWith),X4=$S("".slice),Q4=Math.min,tk=K4("startsWith");G4({target:"String",proto:!0,forced:!!(tk||(em=z4(String.prototype,"startsWith"),!em||em.writable))&&!tk},{startsWith:function(e){var t=ZS(q4(this));J4(e);var n=W4(Q4(arguments.length>1?arguments[1]:void 0,t.length)),i=ZS(e);return ek?ek(t,i,n):X4(t,n,n+i.length)===i}});var nk=ye,Y4=pe,$4=Ke,Z4=ue,tm=ou,eU=Jd,tU=qt,nU=Mt,rU=yn,vo=Object.assign,rk=Object.defineProperty,iU=Y4([].concat),ik=!vo||Z4(function(){if(nk&&vo({b:1},vo(rk({},"a",{enumerable:!0,get:function(){rk(this,"b",{value:3,enumerable:!1})}}),{b:2})).b!==1)return!0;var e={},t={},n=Symbol(),i="abcdefghijklmnopqrst";return e[n]=7,i.split("").forEach(function(r){t[r]=r}),vo({},e)[n]!=7||tm(vo({},t)).join("")!=i})?function(e,t){for(var n=nU(e),i=arguments.length,r=1,o=eU.f,c=tU.f;i>r;)for(var a,s=rU(arguments[r++]),l=o?iU(tm(s),o(s)):tm(s),u=l.length,f=0;u>f;)a=l[f++],nk&&!$4(c,s,a)||(n[a]=s[a]);return n}:vo,ak=ik;Le({target:"Object",stat:!0,arity:2,forced:Object.assign!==ak},{assign:ak});var ok=pe,aU=Vt,oU=at,sU=kt,sk=Ha,cU=Me,ck=Function,uU=ok([].concat),lU=ok([].join),nm={},dU=function(e,t,n){if(!sU(nm,t)){for(var i=[],r=0;r<t;r++)i[r]="a["+r+"]";nm[t]=ck("C,a","return new C("+lU(i,",")+")")}return nm[t](e,n)},hU=cU?ck.bind:function(e){var t=aU(this),n=t.prototype,i=sk(arguments,1),r=function(){var o=uU(i,sk(arguments));return this instanceof r?dU(t,o.length,o):t.apply(e,o)};return oU(n)&&(r.prototype=n),r},uk=hU;Le({target:"Function",proto:!0,forced:Function.bind!==uk},{bind:uk});var fU=Le,pU=rn.findIndex,mU=uu,lk="findIndex",dk=!0;lk in[]&&Array(1).findIndex(function(){dk=!1}),fU({target:"Array",proto:!0,forced:dk},{findIndex:function(e){return pU(this,e,arguments.length>1?arguments[1]:void 0)}}),mU(lk);var vU=ye,hk=pe,gU=ou,_U=bn,yU=hk(qt.f),bU=hk([].push),fk=function(e){return function(t){for(var n,i=_U(t),r=gU(i),o=r.length,c=0,a=[];o>c;)n=r[c++],vU&&!yU(i,n)||bU(a,e?[n,i[n]]:i[n]);return a}},SU={entries:fk(!0),values:fk(!1)}.values;Le({target:"Object",stat:!0},{values:function(e){return SU(e)}});var pk=1,mk=5,rm=2,ac=3,im=4,fl="DISCONNECTED",vk="CONNECTING",am="RECONNECTING",oc="CONNECTED",jr={CLIENT_BANNED:9,CHANNEL_SETUP_RESULT:19,CHANNEL_RECONNECT_RESULT:514,JOIN_ROOM_RESULT:20,PEER_JOIN:4134,PEER_LEAVE:4135,STREAM_ADDED:16,STREAM_REMOVED:18,UPLINK_NETWORK_STATS:22,UPDATE_REMOTE_MUTE_STAT:23,PUBLISH_RESULT:4098,PUBLISH_STATE_CHANGE_RESULT:4112,UNPUBLISH_RESULT:4100,SUBSCRIBE_RESULT:4102,UNSUBSCRIBE_RESULT:4104,SUBSCRIBE_CHANGE_RESULT:4106,MUTE_RESULT:4108,UPDATE_OFFER_RESULT:4128,START_PUBLISH_TENCENT_CDN_RES:1286,STOP_PUBLISH_TENCENT_CDN_RES:1288,START_PUBLISH_GIVEN_CDN_RES:777,STOP_PUBLISH_GIVEN_CDN_RES:779,START_MIX_TRANSCODE_RES:781,STOP_MIX_TRANSCODE_RES:783,USER_LIST_RES:4137,SWITCH_ROLE_RES:4110,UPDATE_CONSTRAINT_CONFIG_RES:772,CONNECT_OTHER_ROOM_RES:8209,DISCONNECT_OTHER_ROOM_RES:8211,UPDATE_OTHER_ROOM_FORWARD_MODE_RES:8213},kU=[jr.UPDATE_REMOTE_MUTE_STAT,jr.UPLINK_NETWORK_STATS,jr.USER_LIST_RES,jr.MUTE_RESULT],st={CLIENT_BANNED:"client-banned",CHANNEL_SETUP_RESULT:"channel-setup-result",CHANNEL_RECONNECT_RESULT:"channel-reconnect-result",JOIN_ROOM_RESULT:"join-room-result",PEER_JOIN:"peer-join",PEER_LEAVE:"peer-leave",STREAM_ADDED:"stream-added",STREAM_REMOVED:"stream-removed",UPLINK_NETWORK_STATS:"uplink-network-stats",UPDATE_REMOTE_MUTE_STAT:"update-remote-mute-stat",PUBLISH_RESULT:"publish-result",PUBLISH_STATE_CHANGE_RESULT:"publish-state-change-result",UNPUBLISH_RESULT:"unpublish-result",SUBSCRIBE_RESULT:"subscribe-result",SUBSCRIBE_CHANGE_RESULT:"subscribe-change-result",UNSUBSCRIBE_RESULT:"unsubscribe-result",UPDATE_OFFER_RESULT:"update-offer-result",START_PUBLISH_TENCENT_CDN_RES:"start-publish-tencent-cdn-res",STOP_PUBLISH_TENCENT_CDN_RES:"stop-publish-tencent-cdn-res",START_PUBLISH_GIVEN_CDN_RES:"start-publish-given-cdn-res",STOP_PUBLISH_GIVEN_CDN_RES:"stop-publish-given-cdn-res",START_MIX_TRANSCODE_RES:"start-mix-transcode-res",STOP_MIX_TRANSCODE_RES:"stop-mix-transcode-res",USER_LIST_RES:"user-list-res",SWITCH_ROLE_RES:"switch_role_res",MUTE_RESULT:"mute-result",UPDATE_CONSTRAINT_CONFIG_RES:"update-contraint-config-res",CONNECT_OTHER_ROOM_RES:"connect_other_room_res",UPDATE_OTHER_ROOM_FORWARD_MODE_RES:"update_other_room_forward_mode_res",DISCONNECT_OTHER_ROOM_RES:"disconnect_other_room_res"},TU="publish_change",xU="publish_state_change",IU="join",wU="leave",CU="quality_report",EU="mute_uplink",RU="publish",gk="unpublish",AU="subscribe",PU="unsubscribe",DU="subscribe_change",OU="start_publishing",LU="stop_publishing",MU="start_push_user_cdn",NU="stop_push_user_cdn",UU="start_mcu_mix",VU="stop_mcu_mix",jU="get_user_list",BU="change_role",FU="update_constraint_config",HU="connect_other_room",GU="update_other_room_forward_mode",zU="disconnect_other_room",Z={INVALID_PARAMETER:4096,INVALID_OPERATION:4097,NOT_SUPPORTED:4098,DEVICE_NOT_FOUND:4099,INITIALIZE_FAILED:4100,SIGNAL_CHANNEL_SETUP_FAILED:16385,SIGNAL_CHANNEL_ERROR:16386,ICE_TRANSPORT_ERROR:16387,JOIN_ROOM_FAILED:16388,CREATE_OFFER_FAILED:16389,SIGNAL_CHANNEL_RECONNECTION_FAILED:16390,UPLINK_RECONNECTION_FAILED:16391,DOWNLINK_RECONNECTION_FAILED:16392,REMOTE_STREAM_NOT_EXIST:16400,CLIENT_BANNED:16448,SERVER_TIMEOUT:16449,SUBSCRIPTION_TIMEOUT:16450,PLAY_NOT_ALLOWED:16451,DEVICE_AUTO_RECOVER_FAILED:16452,START_PUBLISH_CDN_FAILED:16453,STOP_PUBLISH_CDN_FAILED:16454,START_MIX_TRANSCODE_FAILED:16455,STOP_MIX_TRANSCODE_FAILED:16456,NOT_SUPPORTED_H264:16457,SWITCH_ROLE_FAILED:16458,API_CALL_TIMEOUT:16459,SCHEDULE_FAILED:16460,API_CALL_ABORTED:16461,UNKNOWN:65535},te=function(e){Et(n,e);var t=Rr(n);function n(i){var r,o=i.name,c=o===void 0?"RtcError":o,a=i.message,s=i.code,l=s===void 0?Z.UNKNOWN:s,u=i.extraCode,f=u===void 0?0:u,S=i.constraint;Q(this,n);var x="<".concat(function(E){for(var I in Z)if(Z[I]===E)return I;return"UNKNOWN"}(l)," 0x").concat(l.toString(16),">");return(r=t.call(this,a+"".concat(S?" constraint: ".concat(S):"")+"".concat(a!=null&&a.includes(x)?"":" "+x))).code_=l,r.extraCode_=f,r.name=c,r.message_=a,S&&(r.constraint=S),r}return Ie(n,[{key:"getCode",value:function(){return this.code_}},{key:"getExtraCode",value:function(){return this.extraCode_}}]),n}(Wo(Error)),_k=32768,yk=32769,bk=32770,Sk=32771,WU=32772,JU=32773,qU=32774,KU=32775,kk=32777,XU=32778,om=32779,QU=32780,YU=32781,$U=32782,ZU=32783,eV=32784,tV=32785,nV=32786,rV=32787,iV=32788,aV=32789,oV=32790,sV=32791,cV=32792,uV=32793,lV=32794,dV=32795,hV=32796,fV=32797,pV=32798,mV=32799,vV=32800,gV=32801,_V=32802,yV=32803,bV=32804,sc=new Map,vn=function(e,t){var n=sc.get(e);n||(sc.set(e,[]),n=sc.get(e)),n.push(t)},SV=function(e){var t=sc.get(e),n=[];return t?(sc.delete(e),n=t.map(function(i){return{uint32_event_id:i.eventId,uint64_date:i.timestamp,str_userid:i.remoteUserId,str_event_json:i.eventDesc}})):n=[],n},kV=Object.prototype.hasOwnProperty;function Br(e){if(e==null)return!0;if(typeof e=="boolean")return!1;if(typeof e=="number")return e===0;if(typeof e=="string"||typeof e=="function"||Array.isArray(e))return e.length===0;if(e instanceof Error)return e.message==="";if(yi(e))switch(Object.prototype.toString.call(e)){case"[object File]":case"[object Map]":case"[object Set]":return e.size===0;case"[object Object]":for(var t in e)if(kV.call(e,t))return!1;return!0}return!1}var TV=function(){function e(){Q(this,e);var t=aa(),n=t.name,i=t.version;this.roomIdMap_=new Map,this.configs_={sdkAppId:"",userId:"",version:Gi,env:Gu,browserVersion:n+i,ua:navigator.userAgent}}return Ie(e,[{key:"setConfig",value:function(t){var n=t.sdkAppId,i=t.env,r=t.userId,o=t.roomId;n!==this.configs_.sdkAppId&&(this.configs_.sdkAppId=String(n)),this.configs_.env=i,this.configs_.userId=r,this.roomIdMap_.set(r,String(o))}},{key:"logEvent",value:function(t){if(!ra){var n=q(q(q({},t),this.configs_),{},{userId:t.userId||this.configs_.userId});ge(n.code)&&(n.code=n.result==="failed"?Z.UNKNOWN:0),this.sendRequest(ol(this.configs_.sdkAppId,JM),n)}}},{key:"logSuccessEvent",value:function(t){ra||(this.logEvent(q(q({},t),{},{result:"success",roomId:this.roomIdMap_.get(t.userId)})),this.configs_.env===Gu&&this.uploadEventToKibana(q(q({},t),{},{result:"success"})))}},{key:"logFailedEvent",value:function(t){if(!ra){var n=t.eventType,i=t.code,r=t.error,o=t.userId,c={roomId:this.roomIdMap_.get(o),userId:o,eventType:n,result:"failed",code:i||(r instanceof te?r.getExtraCode()||r.getCode():Z.UNKNOWN)};this.logEvent(c),this.configs_.env===Gu&&this.uploadEventToKibana(q(q({},c),{},{error:r}))}}},{key:"uploadEventToKibana",value:function(t){var n="stat-".concat(t.eventType,"-").concat(t.result);t.eventType!=="delta-join"&&t.eventType!=="delta-leave"&&t.eventType!=="delta-publish"||(n="".concat(t.eventType,":").concat(t.delta)),this.uploadEvent({log:n,userId:t.userId}),t.result==="failed"&&(n="stat-".concat(t.eventType,"-").concat(t.result,"-").concat(t.code),this.uploadEvent({log:n,userId:t.userId,error:t.error}))}},{key:"uploadEvent",value:function(t){var n=t.log,i=t.userId,r=t.error,o={timestamp:qy(),sdkAppId:this.configs_.sdkAppId,userId:i||this.configs_.userId,version:this.configs_.version,log:n};r&&(o.errorInfo=r.message),this.sendRequest(ol(this.configs_.sdkAppId,yb),o)}},{key:"sendRequest",value:function(t,n){var i=this;_e.getIsAbleToUpload()?cl({url:t,body:JSON.stringify(n)}).catch(function(){}):setTimeout(function(){i.sendRequest(t,n)},1e3)}}]),e}(),ke=new TV,xV=Mt,IV=Vi;Le({target:"Date",proto:!0,arity:1,forced:ue(function(){return new Date(NaN).toJSON()!==null||Date.prototype.toJSON.call({toISOString:function(){return 1}})!==1})},{toJSON:function(e){var t=xV(this),n=IV(t,"number");return typeof n!="number"||isFinite(n)?t.toISOString():null}});var wV=Ke;Le({target:"URL",proto:!0,enumerable:!0},{toJSON:function(){return wV(URL.prototype.toString,this)}});var CV=Le,sm=pe,EV=$n,RV=o0,AV=ey,Tk=ue,PV=RangeError,xk=String,Ik=Math.floor,cm=sm(AV),wk=sm("".slice),cc=sm(1 .toFixed),go=function(e,t,n){return t===0?n:t%2==1?go(e,t-1,n*e):go(e*e,t/2,n)},_o=function(e,t,n){for(var i=-1,r=n;++i<6;)r+=t*e[i],e[i]=r%1e7,r=Ik(r/1e7)},um=function(e,t){for(var n=6,i=0;--n>=0;)i+=e[n],e[n]=Ik(i/t),i=i%t*1e7},Ck=function(e){for(var t=6,n="";--t>=0;)if(n!==""||t===0||e[t]!==0){var i=xk(e[t]);n=n===""?i:n+cm("0",7-i.length)+i}return n};CV({target:"Number",proto:!0,forced:Tk(function(){return cc(8e-5,3)!=="0.000"||cc(.9,0)!=="1"||cc(1.255,2)!=="1.25"||cc(0xde0b6b3a7640080,0)!=="1000000000000000128"})||!Tk(function(){cc({})})},{toFixed:function(e){var t,n,i,r,o=RV(this),c=EV(e),a=[0,0,0,0,0,0],s="",l="0";if(c<0||c>20)throw PV("Incorrect fraction digits");if(o!=o)return"NaN";if(o<=-1e21||o>=1e21)return xk(o);if(o<0&&(s="-",o=-o),o>1e-21)if(n=(t=function(u){for(var f=0,S=u;S>=4096;)f+=12,S/=4096;for(;S>=2;)f+=1,S/=2;return f}(o*go(2,69,1))-69)<0?o*go(2,-t,1):o/go(2,t,1),n*=4503599627370496,(t=52-t)>0){for(_o(a,0,n),i=c;i>=7;)_o(a,1e7,0),i-=7;for(_o(a,go(10,i,1),0),i=t-1;i>=23;)um(a,1<<23),i-=23;um(a,1<<i),_o(a,1,1),um(a,2),l=Ck(a)}else _o(a,0,n),_o(a,1<<-t,0),l=Ck(a)+cm("0",c);return l=c>0?s+((r=l.length)<=c?"0."+cm("0",c-r)+l:wk(l,0,r-c)+"."+wk(l,r-c)):s+l}});var lm=null,dm=!0;function ki(e){nr(e)&&e!==dm&&(dm=e,_e.info("setIsNeedToSchedule "+e))}function DV(e,t){try{if(PerformanceObserver){var n=Ct(),i=pl(e,Qe),r=pl(e,er),o=new PerformanceObserver(function(c){c.getEntries().forEach(function(a){if(a.startTime>=n&&(a.name===i||a.name===r)){var s=a.name===i?Qe:er;if(a.code&&a.code!==200)return void _e.warn("".concat(s," schedule with code ").concat(a.code,", ").concat(JSON.stringify(a.toJSON())));var l=a.responseEnd-a.startTime,u=[a.domainLookupStart-a.startTime,a.domainLookupEnd-a.domainLookupStart,a.requestStart-a.secureConnectionStart,a.secureConnectionStart-a.connectStart,a.responseStart-a.requestStart,a.responseEnd-a.responseStart].map(function(f){return f.toFixed(1)});o.disconnect(),ke.uploadEvent({log:"stat-schedule-net:".concat(l.toFixed(1),"(").concat(u.join("->"),") ").concat(s),userId:t})}})});o.observe({type:"resource",buffered:!0})}}catch(c){}}function OV(e){return hm.apply(this,arguments)}function hm(){return hm=H(p().mark(function e(t){var n,i,r,o,c,a,s,l,u,f,S,x,E;return p().wrap(function(I){for(;;)switch(I.prev=I.next){case 0:if(n=t.userId,i=t.sdkAppId,r=t.useStringRoomId,o=t.roomId,c=t.userSig,dm||!lm){I.next=3;break}return I.abrupt("return",{isCached:!0,result:lm});case 3:return a={delta:0,count:[1,1],msg:[]},I.prev=4,(s=new FormData).append("userId",String(n)),s.append("sdkAppId",String(i)),s.append("isStrGroupId",r),s.append("groupId",String(o)),s.append("sdkVersion",Gi),s.append("userSig",String(c)),Kf&&s.append("oversea",!0),DV(i,n),l=Ct(),I.next=17,MV(s,a,i);case 17:return(u=I.sent).config&&(u.config.loggerDomain&&Uf(u.config.loggerDomain),nr(u.config.scheduleCache)&&ki(!u.config.scheduleCache)),a.delta=Ct()-l,Ek({stat:a,userId:n}),lm=u,I.abrupt("return",{isCached:!1,result:u});case 25:throw I.prev=25,I.t0=I.catch(4),f=ho(I.t0)?I.t0[0]:I.t0,S=tr(f.code)?f.code:0,x="schedule failed".concat(f.message?": ".concat(f.message):""),E=new te({code:Z.SCHEDULE_FAILED,extraCode:S,message:ae({key:uS,data:{error:x,code:S}})}),_e.error(E),Ek({stat:a,userId:n,roomId:o,error:E}),E;case 34:case"end":return I.stop()}},e,null,[[4,25]])})),hm.apply(this,arguments)}function Ek(e){var t=e.stat,n=e.userId,i=e.error;i?ke.logFailedEvent({eventType:Fb,error:i,userId:n}):ke.logSuccessEvent({eventType:Fb,delta:t.delta,userId:n}),ke.uploadEvent({log:"stat-schedule:"+JSON.stringify(t),userId:n})}function pl(e){var t,n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:Qe;return t=Kf||(NS(e)?n===Qe?sN:cN:n===Qe?aN:oN),"https://".concat(t,"/api/v1/config")}function LV(e,t,n){return new Promise(function(i,r){cl({url:e,body:t,timeout:n.timeout}).then(function(o){o.data.code===0?i(o.data.data):r({code:o.data.code,message:o.data.msg})}).catch(r)})}Y.on(sa,function(){return ki(!0)}),Y.on(D4,function(){return ki(!0)}),Y.on(O4,function(){return ki(!0)}),Y.on(KS,function(){return ki(!0)}),Y.on(hl,function(e){e.state===jf&&ki(!0)});var Rk=function(e,t){return ic({retryFunction:LV,settings:{retries:3,timeout:0},onError:t,onRetrying:e})};function MV(e,t,n){return new Promise(function(i,r){var o,c=null;(o=[Rk(function(a){return t.count[0]=a+1},function(a,s){t.msg[0]=a.message,c||s()})(pl(n,Qe),e,{get timeout(){return 1e3*sl(2+t.count[0])}}),Rk(function(a){return t.count[1]=a+1},function(a,s){t.msg[1]=a.message,c||s()})(pl(n,er),e,{get timeout(){return 1e3*sl(2+t.count[1])}})],new Promise(function(a,s){var l=[];o.forEach(function(u){u.then(a).catch(function(f){l.push(f),l.length===o.length&&s(l)})})})).then(function(a){i(c=a)}).catch(r)})}var NV=function(){function e(i){Q(this,e),this.client_=i.client,this.sdkAppId_=i.sdkAppId,this.userId_=i.userId,this.userSig_=i.userSig,this.url_=i.url,this.backupUrl_=i.backupUrl;var r="?sdkAppId=".concat(encodeURIComponent(this.sdkAppId_),"&userId=").concat(encodeURIComponent(this.userId_),"&userSig=").concat(encodeURIComponent(this.userSig_),"&roomId=").concat(encodeURIComponent(i.roomId)),o=this.client_.getSystemResult();if(o&&o.detail){var c=o.detail,a=c.isH264EncodeSupported,s=c.isVp8EncodeSupported,l=c.isH264DecodeSupported,u=c.isVp8DecodeSupported;r+="&enc264=".concat(Number(a),"&dec264=").concat(Number(l),"&encVp8=").concat(Number(s),"&decVp8=").concat(Number(u))}i.signalDomainWhenUnifiedProxy&&(r+="&signalDomain=".concat(encodeURIComponent(i.signalDomainWhenUnifiedProxy))),this.urlParams=r,this.isConnected_=!1,this.isConnecting_=!1,this.socketInUse_=null,this.socket_=null,this.backupSocket_=null,this.backupTimer_=-1,this.signalInfo_={},this.currentState_=fl,this.reconnectionCount_=0,this.reconnectionTimer_=-1,this.lastMessageTime_=-1,this.seq_=0,this.log_=_e.createLogger({id:"ws|"+this.userId_,userId:this.userId_,sdkAppId:this.sdkAppId_}),this.emitter_=new Si}var t,n;return Ie(e,[{key:"urlWithParam_",get:function(){return"".concat(this.url_).concat(this.urlParams)}},{key:"backupUrlWithParam_",get:function(){return"".concat(this.backupUrl_).concat(this.urlParams)}},{key:"isOnline",get:function(){return this.currentState_===oc&&Date.now()-this.lastMessageTime_<12e3}},{key:"connect",value:function(){var i=this;return new Promise(function(r,o){i.log_.info("connect to url: ".concat(i.urlWithParam_)),i.emitConnectionStateChanged(vk),i.socket_=new WebSocket(i.urlWithParam_),i.bindSocket(i.socket_),i.backupTimer_=setTimeout(function(){i.isConnected_||(i.log_.info("trying to connect to backupUrl"),i.tryConnectBackup())},5e3);var c=setTimeout(function(){i.close(),o(new te({code:Z.JOIN_ROOM_FAILED,message:"join room timeout"}))},1e4);i.once(ac,function(){clearTimeout(c),r()}),i.once(im,function(a){clearTimeout(c),o(a)})})}},{key:"tryConnectBackup",value:function(){this.backupSocket_||(this.unbindAndCloseSocket(Qe),this.log_.debug("try to connect to url: ".concat(this.backupUrlWithParam_)),this.backupSocket_=new WebSocket(this.backupUrlWithParam_),this.bindSocket(this.backupSocket_))}},{key:"bindSocket",value:function(i){i.onopen=this.onopen.bind(this),i.onclose=this.onclose.bind(this),i.onerror=this.onerror.bind(this),i.onmessage=this.onmessage.bind(this)}},{key:"unbindSocket",value:function(i){i.onopen=function(){},i.onclose=function(){},i.onerror=function(){},i.onmessage=function(){}}},{key:"unbindAndCloseSocket",value:function(i){if(i===Qe){if(this.socket_){this.unbindSocket(this.socket_);try{this.socket_.close(1e3)}catch(r){}this.socket_=null}}else if(this.backupSocket_){this.unbindSocket(this.backupSocket_);try{this.backupSocket_.close(1e3)}catch(r){}this.backupSocket_=null}}},{key:"clearBackupTimer",value:function(){this.backupTimer_!==-1&&(clearTimeout(this.backupTimer_),this.backupTimer_=-1)}},{key:"clearReconnectionTimer",value:function(){this.reconnectionTimer_!==-1&&(clearTimeout(this.reconnectionTimer_),this.reconnectionTimer_=-1)}},{key:"onopen",value:function(i){if(!this.isConnected_){this.isConnected_=!0,this.isConnecting_=!1,this.isReconnecting_&&Br(this.signalInfo_)&&this.stopReconnection(),this.clearBackupTimer(),i.target===this.socket_?(this.unbindAndCloseSocket(er),this.socketInUse_=this.socket_):(this.unbindAndCloseSocket(Qe),this.socketInUse_=this.backupSocket_);var r=i.target.url;this.log_.info("websocket[".concat(r,"] is connected")),this.currentState_===vk?this.addSignalEvent(sV,"signal channel is connected"):this.currentState_===am&&this.addSignalEvent(dV,"signal channel reconnect success"),this.emitConnectionStateChanged(oc),this.emitter_.emit(ac)}}},{key:"onclose",value:function(i){var r=i.target.url,o=i.target===this.socketInUse_;if(this.log_.info("websocket[".concat(r," InUse: ").concat(o,"] is closed with code: ").concat(i.code)),o&&(this.isConnected_=!1,this.emitConnectionStateChanged(fl),this.addSignalEvent(oV,"signal channel is disconnected"),!i.wasClean||i.code!==1e3)){this.log_.warn("onclose code:".concat(i.code," reason:").concat(i.reason)),this.log_.warn("close current websocket and schedule a reconnect timeout"),this.socketInUse_.onclose=function(){},this.socketInUse_.close(4011);var c=this.socketInUse_===this.socket_;this.socket_=this.backupSocket_=this.socketInUse_=null,this.reconnect(c?er:Qe)}}},{key:"onerror",value:function(i){var r=i.target.url;if(this.log_.error("websocket[".concat(r,"] error observed")),this.isConnected_){if(i.target===this.socketInUse_){this.isConnected_=!1,this.unbindAndCloseSocket(Qe),this.unbindAndCloseSocket(er);var o=this.socketInUse_===this.socket_;this.socketInUse_=null,this.reconnect(o?er:Qe)}}else this.isReconnecting_||ke.logFailedEvent({userId:this.client_.getUserId(),eventType:Hf,code:Z.UNKNOWN}),i.target==this.socket_?(this.unbindAndCloseSocket(Qe),this.reconnect(er)):(this.unbindAndCloseSocket(er),this.reconnect(Qe));this.isConnecting_=!1,this.isConnected_=!1}},{key:"onmessage",value:function(i){if(this.isConnected_){this.lastMessageTime_=Date.now();var r=JSON.parse(i.data),o=r.cmd,c=r.data,a=Object.values(jr),s=Object.keys(jr)[a.indexOf(o)],l=st[s];switch(kU.includes(o)||(this.log_.debug("received msg: ".concat(i.data)),this.log_.info("Received event: [ ".concat(l||"unknown cmd: "+o," ]"))),o){case jr.CHANNEL_SETUP_RESULT:if(r.code===0)this.signalInfo_.clientIp=c.clientIp,this.signalInfo_.signalIp=c.signalInnerIp,this.signalInfo_.tinyId=r.tinyId,c.svrTime&&function(f){tf=f-new Date().getTime();var S=new Date;S.setTime(f),_e.info("baseTime from server: "+S+" offset: "+tf)}(c.svrTime),this.log_.info("ChannelSetup Success"),ke.logSuccessEvent({userId:this.userId_,eventType:Hf}),this.emitter_.emit(pk,{signalInfo:this.signalInfo_});else{var u=new te({code:Z.SIGNAL_CHANNEL_SETUP_FAILED,extraCode:r.code,message:ae({key:wN,data:{errorCode:r.code,errorMsg:r.message}})});this.log_.error("".concat(r.code,", ").concat(r.message)),this.close(),ke.logFailedEvent({userId:this.userId_,eventType:Hf,error:u}),this.emitter_.emit(mk,u)}break;case jr.JOIN_ROOM_RESULT:r.code===0&&(this.signalInfo_.relayIp=c.relayOuterIp,this.signalInfo_.relayInnerIp=c.relayInnerIp,this.signalInfo_.relayPort=c.relayPort,this.log_.info("signalIp:".concat(this.signalInfo_.signalIp," clientIp:").concat(this.signalInfo_.clientIp," relayIp: ").concat(this.signalInfo_.relayIp))),this.emitter_.emit(l,{data:r});break;case jr.CHANNEL_RECONNECT_RESULT:r.code===0?(this.log_.warn("reconnect success"),this.stopReconnection(),ke.logSuccessEvent({userId:this.userId_,eventType:Mb}),this.client_.syncUserList(),this.client_.checkConnectionsToReconnect()):(this.log_.warn("reconnect failed, ".concat(r.code," ").concat(r.message)),this.client_.reJoin());break;default:this.emitter_.emit(l,{data:r})}}}},{key:"addSignalEvent",value:function(i,r){vn(this.userId_,{eventId:i,eventDesc:r,timestamp:an(),userId:this.userId_,tinyId:this.signalInfo_.tinyId})}},{key:"reconnect",value:(n=H(p().mark(function i(){var r,o,c,a,s=this,l=arguments;return p().wrap(function(u){for(;;)switch(u.prev=u.next){case 0:if(r=l.length>0&&l[0]!==void 0?l[0]:Qe,!this.isConnecting_&&this.reconnectionTimer_===-1){u.next=4;break}return this.log_.info("signal channel is reconnecting, ignoring current reconnection"),u.abrupt("return");case 4:if(Y.emit(KS,this.client_),!(this.reconnectionCount_>=Ff)){u.next=12;break}return this.log_.warn("SDK has tried reconnect signal channel for ".concat(Ff," times, but all failed. please check your network")),o=new te({code:Z.SIGNAL_CHANNEL_RECONNECTION_FAILED,message:ae({key:IN})}),ke.logFailedEvent({userId:this.client_.getUserId(),eventType:Mb,error:o}),this.addSignalEvent(hV,"signal channel reconnect fail"),this.emitter_.emit(im,o),u.abrupt("return");case 12:if(this.isConnecting_=!0,this.reconnectionCount_++,this.currentState_!==am&&(this.emitConnectionStateChanged(am),this.addSignalEvent(lV,"signal channel is reconnecting")),this.log_.warn("reconnecting to ".concat(r," signal channel [").concat(this.reconnectionCount_,"/").concat(Ff,"]")),!(this.reconnectionCount_>=3&&this.reconnectionCount_%3==0)){u.next=20;break}return this.log_.warn("re-schedule to get new ws url"),u.next=20,this.reGetSignalChannelUrl();case 20:c=this.getReconnectionUrl(r),r===Qe?(this.socket_=new WebSocket(c),this.bindSocket(this.socket_)):(this.backupSocket_=new WebSocket(c),this.bindSocket(this.backupSocket_)),a=xp(this.reconnectionCount_),this.reconnectionTimer_=setTimeout(function(){s.log_.warn("reconnect ".concat(r," signal channel timeout(").concat(a/1e3,"s), close and try again")),s.isConnecting_=!1,s.clearReconnectionTimer(),s.unbindAndCloseSocket(r),s.reconnect(r===Qe?er:Qe)},a);case 24:case"end":return u.stop()}},i,this)})),function(){return n.apply(this,arguments)})},{key:"reGetSignalChannelUrl",value:(t=H(p().mark(function i(){var r,o,c,a;return p().wrap(function(s){for(;;)switch(s.prev=s.next){case 0:if(s.prev=0,!this.client_.getWSProxy()&&!this.client_.getUnifiedProxy()){s.next=3;break}return s.abrupt("return");case 3:return ki(!0),s.next=6,this.client_.schedule(this.client_.getRoomId());case 6:r=this.client_.getSignalChannelUrl(),o=r.mainUrl,c=r.backupUrl,this.url_=o,this.backupUrl_=c,(a=new URLSearchParams(this.urlParams)).has("signalDomain")&&(a.set("signalDomain",o),this.urlParams=a.toString()),s.next=15;break;case 13:s.prev=13,s.t0=s.catch(0);case 15:case"end":return s.stop()}},i,this,[[0,13]])})),function(){return t.apply(this,arguments)})},{key:"isConnected",value:function(){return this.isConnected_}},{key:"isReconnecting_",get:function(){return this.reconnectionTimer_!==-1}},{key:"getReconnectionUrl",value:function(i){var r=i===Qe?this.urlWithParam_:this.backupUrlWithParam_;if(!Br(this.signalInfo_)&&r.indexOf("&rc=1")===-1){var o=this.client_.getRoomId(),c=this.client_.getUseStringRoomId();r+="&rc=1&relayInnerIp=".concat(this.signalInfo_.relayInnerIp,"&relayOuterIp=").concat(this.signalInfo_.relayIp,"&relayPort=").concat(this.signalInfo_.relayPort,"&roomId=").concat(o,"&useStringRoomId=").concat(c)}return r}},{key:"send",value:function(i){var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(this.isConnected_){var o={cmd:i,data:r,userId:this.userId_,tinyId:this.signalInfo_.tinyId,seq:++this.seq_};return this.socketInUse_.send(JSON.stringify(o)),o.seq}}},{key:"sendWaitForResponse",value:function(i){var r=this,o=i.command,c=i.data,a=i.timeout,s=a===void 0?5e3:a,l=i.responseCommand,u=i.commandDesc,f=i.enableLog,S=f===void 0||f;return new Promise(function(x,E){var I=setTimeout(function(){r.off(l,m);var v=new te({code:Z.API_CALL_TIMEOUT,message:ae({key:xN,data:{commandDesc:u,command:o}})});S&&r.log_.warn(v),E(v)},s),m=function v(w){w.data.seq===T&&(clearTimeout(I),r.off(l,v),x(w))};r.on(l,m);var T=r.send(o,c)})}},{key:"sendWaitForResponseWithRetry",value:function(){var i=this,r=arguments.length<=0?void 0:arguments[0],o=r.commandDesc,c=r.command,a=r.retries,s=a===void 0?0:a,l=r.retryTimeout,u=l===void 0?0:l;return ic({retryFunction:this.sendWaitForResponse,onRetrying:function(f){i.log_.warn("".concat(o||c," timeout observed, retrying [").concat(f,"/").concat(s,"]"))},settings:{retries:s,timeout:u},context:this}).apply(void 0,arguments)}},{key:"getCurrentState",value:function(){return this.currentState_}},{key:"getSignalInfo",value:function(){return this.signalInfo_}},{key:"stopReconnection",value:function(){this.isReconnecting_&&(this.reconnectionCount_=0,this.clearReconnectionTimer())}},{key:"close",value:function(){this.log_.info("close SignalChannel"),this.clearBackupTimer(),this.stopReconnection(),this.signalInfo_={},this.isConnecting_=!1,this.isConnected_=!1,this.socketInUse_=null,this.unbindAndCloseSocket(Qe),this.unbindAndCloseSocket(er),this.emitConnectionStateChanged(fl)}},{key:"on",value:function(i,r,o){this.emitter_.on(i,r,o)}},{key:"removeListener",value:function(i,r,o){this.emitter_.removeListener(i,r,o)}},{key:"once",value:function(i,r,o){this.emitter_.once(i,r,o)}},{key:"off",value:function(i,r,o){this.emitter_.off(i,r,o)}},{key:"emitConnectionStateChanged",value:function(i){i!==this.currentState_&&(this.emitter_.emit(rm,{prevState:this.currentState_,state:i}),this.currentState_=i)}}]),e}(),UV=Le,VV=rn.find,jV=uu,Ak="find",Pk=!0;Ak in[]&&Array(1).find(function(){Pk=!1}),UV({target:"Array",proto:!0,forced:Pk},{find:function(e){return VV(this,e,arguments.length>1?arguments[1]:void 0)}}),jV(Ak);var rr={},Dk={},fm={exports:{}},Ok=fm.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 e.address!=null?"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 e.subtype!=null?"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 e.sessionConfig!=null?"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+=e.raddr!=null?" raddr %s rport %d":"%v%v",t+=e.tcptype!=null?" tcptype %s":"%v",e.generation!=null&&(t+=" generation %d"),t+=e["network-id"]!=null?" network-id %d":"%v",t+=e["network-cost"]!=null?" 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 e.attribute!=null&&(t+=" %s",e.value!=null&&(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 e.maxMessageSize!=null?"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"+(e.clksrcExt!=null?"=%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+=e.id!=null?"id=%s %s":"%v%s",t+=e.mediaClockValue!=null?"=%s":"",t+=e.rateNumerator!=null?" rate=%s":"",t+=e.rateDenominator!=null?"/%s":""}},{name:"keywords",reg:/^keywds:(.+)$/,format:"keywds:%s"},{name:"content",reg:/^content:(.+)/,format:"content:%s"},{name:"bfcpFloorCtrl",reg:/^floorctrl:(c-only|s-only|c-s)/,format:"floorctrl:%s"},{name:"bfcpConfId",reg:/^confid:(\d+)/,format:"confid:%s"},{name:"bfcpUserId",reg:/^userid:(\d+)/,format:"userid:%s"},{name:"bfcpFloorId",reg:/^floorid:(.+) (?:m-stream|mstrm):(.+)/,names:["id","mStream"],format:"floorid:%s mstrm:%s"},{push:"invalid",names:["value"]}]};Object.keys(Ok).forEach(function(e){Ok[e].forEach(function(t){t.reg||(t.reg=/(.*)/),t.format||(t.format="%s")})}),function(e){var t=function(c){return String(Number(c))===c?Number(c):c},n=function(c,a,s){var l=c.name&&c.names;c.push&&!a[c.push]?a[c.push]=[]:l&&!a[c.name]&&(a[c.name]={});var u=c.push?{}:l?a[c.name]:a;(function(f,S,x,E){if(E&&!x)S[E]=t(f[1]);else for(var I=0;I<x.length;I+=1)f[I+1]!=null&&(S[x[I]]=t(f[I+1]))})(s.match(c.reg),u,c.names,c.name),c.push&&a[c.push].push(u)},i=fm.exports,r=RegExp.prototype.test.bind(/^([a-z])=(.*)/);e.parse=function(c){var a={},s=[],l=a;return c.split(/(\r\n|\r|\n)/).filter(r).forEach(function(u){var f=u[0],S=u.slice(2);f==="m"&&(s.push({rtp:[],fmtp:[]}),l=s[s.length-1]);for(var x=0;x<(i[f]||[]).length;x+=1){var E=i[f][x];if(E.reg.test(S))return n(E,l,S)}}),a.media=s,a};var o=function(c,a){var s=a.split(/=(.+)/,2);return s.length===2?c[s[0]]=t(s[1]):s.length===1&&a.length>1&&(c[s[0]]=void 0),c};e.parseParams=function(c){return c.split(/;\s?/).reduce(o,{})},e.parseFmtpConfig=e.parseParams,e.parsePayloads=function(c){return c.toString().split(" ").map(Number)},e.parseRemoteCandidates=function(c){for(var a=[],s=c.split(" ").map(t),l=0;l<s.length;l+=3)a.push({component:s[l],ip:s[l+1],port:s[l+2]});return a},e.parseImageAttributes=function(c){return c.split(" ").map(function(a){return a.substring(1,a.length-1).split(",").reduce(o,{})})},e.parseSimulcastStreamList=function(c){return c.split(";").map(function(a){return a.split(",").map(function(s){var l,u=!1;return s[0]!=="~"?l=t(s):(l=t(s.substring(1,s.length)),u=!0),{scid:l,paused:u}})})}}(Dk);var pm=fm.exports,BV=/%[sdv%]/g,FV=function(e){var t=1,n=arguments,i=n.length;return e.replace(BV,function(r){if(t>=i)return r;var o=n[t];switch(t+=1,r){case"%%":return"%";case"%s":return String(o);case"%d":return Number(o);case"%v":return""}})},uc=function(e,t,n){var i=[e+"="+(t.format instanceof Function?t.format(t.push?n:n[t.name]):t.format)];if(t.names)for(var r=0;r<t.names.length;r+=1){var o=t.names[r];t.name?i.push(n[t.name][o]):i.push(n[t.names[r]])}else i.push(n[t.name]);return FV.apply(null,i)},HV=["v","o","s","i","u","e","p","c","b","t","r","z","a"],GV=["i","c","b","a"],ua=Dk,zV=function(e,t){t=t||{},e.version==null&&(e.version=0),e.name==null&&(e.name=" "),e.media.forEach(function(o){o.payloads==null&&(o.payloads="")});var n=t.outerOrder||HV,i=t.innerOrder||GV,r=[];return n.forEach(function(o){pm[o].forEach(function(c){c.name in e&&e[c.name]!=null?r.push(uc(o,c,e)):c.push in e&&e[c.push]!=null&&e[c.push].forEach(function(a){r.push(uc(o,c,a))})})}),e.media.forEach(function(o){r.push(uc("m",pm.m[0],o)),i.forEach(function(c){pm[c].forEach(function(a){a.name in o&&o[a.name]!=null?r.push(uc(c,a,o)):a.push in o&&o[a.push]!=null&&o[a.push].forEach(function(s){r.push(uc(c,a,s))})})})}),r.join(`\r
|
|
91
55
|
`)+`\r
|
|
92
|
-
`};tr.write=NV,tr.parse=_a.parse,tr.parseParams=_a.parseParams,tr.parseFmtpConfig=_a.parseFmtpConfig,tr.parsePayloads=_a.parsePayloads,tr.parseRemoteCandidates=_a.parseRemoteCandidates,tr.parseImageAttributes=_a.parseImageAttributes,tr.parseSimulcastStreamList=_a.parseSimulcastStreamList;var Kr=function(e){return tr.parse(e)},To=function(e){return tr.write(e)},UV=function(e){var t=Kr(e);return t.media.forEach(function(n){n.type===Ae&&n.fmtp.forEach(function(a){a.config+=";sprop-stereo=1;stereo=1"})}),To(t)},lm,dm,hm,pm,VV=Ue,fm=ke,jV=Yn,BV=u0,FV=ry,Ck=ce,GV=RangeError,Rk=String,Ak=Math.floor,mm=fm(FV),Pk=fm("".slice),vc=fm(1 .toFixed),xo=function(e,t,n){return t===0?n:t%2==1?xo(e,t-1,n*e):xo(e*e,t/2,n)},Io=function(e,t,n){for(var a=-1,i=n;++a<6;)i+=t*e[a],e[a]=i%1e7,i=Ak(i/1e7)},vm=function(e,t){for(var n=6,a=0;--n>=0;)a+=e[n],e[n]=Ak(a/t),a=a%t*1e7},Dk=function(e){for(var t=6,n="";--t>=0;)if(n!==""||t===0||e[t]!==0){var a=Rk(e[t]);n=n===""?a:n+mm("0",7-a.length)+a}return n};VV({target:"Number",proto:!0,forced:Ck(function(){return vc(8e-5,3)!=="0.000"||vc(.9,0)!=="1"||vc(1.255,2)!=="1.25"||vc(0xde0b6b3a7640080,0)!=="1000000000000000128"})||!Ck(function(){vc({})})},{toFixed:function(e){var t,n,a,i,r=BV(this),o=jV(e),s=[0,0,0,0,0,0],c="",u="0";if(o<0||o>20)throw GV("Incorrect fraction digits");if(r!=r)return"NaN";if(r<=-1e21||r>=1e21)return Rk(r);if(r<0&&(c="-",r=-r),r>1e-21)if(n=(t=function(d){for(var g=0,I=d;I>=4096;)g+=12,I/=4096;for(;I>=2;)g+=1,I/=2;return g}(r*xo(2,69,1))-69)<0?r*xo(2,-t,1):r/xo(2,t,1),n*=4503599627370496,(t=52-t)>0){for(Io(s,0,n),a=o;a>=7;)Io(s,1e7,0),a-=7;for(Io(s,xo(10,a,1),0),a=t-1;a>=23;)vm(s,1<<23),a-=23;vm(s,1<<a),Io(s,1,1),vm(s,2),u=Dk(s)}else Io(s,0,n),Io(s,1<<-t,0),u=Dk(s)+mm("0",o);return u=o>0?c+((i=u.length)<=o?"0."+mm("0",o-i)+u:Pk(u,0,i-o)+"."+Pk(u,i-o)):c+u}});var Lk=((lm=window)===null||lm===void 0?void 0:lm.requestIdleCallback)||function(e){var t=Date.now();return setTimeout(function(){e({didTimeout:!1,timeRemaining:function(){return Math.max(0,50-(Date.now()-t))}})},1e3)},HV=((dm=window)===null||dm===void 0?void 0:dm.cancelIdleCallback)||function(e){clearTimeout(e)},zV=((hm=window)===null||hm===void 0?void 0:hm.cancelAnimationFrame)||((pm=window)===null||pm===void 0?void 0:pm.mozCancelAnimationFrame),_t=function(){function e(){K(this,e)}return we(e,null,[{key:"generateTaskID",value:function(){return this.currentTaskID++}},{key:"run",value:function(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:iS,n=arguments.length>1?arguments[1]:void 0,a=arguments.length>2?arguments[2]:void 0;a=q(q({},t===yN?{delay:2e3,count:0,backgroundTask:!0}:t===vo?{delay:1e4,count:0}:t===el?{fps:60,delay:16.6,count:0,backgroundTask:!0}:{delay:2e3,count:0,backgroundTask:!0}),a),VS(n)&&(a=q(q({},a),n)),ln(t)&&(n=t,t=iS);var i=q({taskID:this.generateTaskID(),loopCount:0,intervalID:null,timeoutID:null,rafID:null,ricID:null,taskName:t,callback:n},a);return this.taskMap.set(i.taskID,i),this[t](i),i.taskID}},{key:"interval",value:function(t){var n=this;return t.intervalID=setInterval(function(){t.callback(),t.loopCount+=1,n.isBreakLoop(t)},t.delay)}},{key:"timeout",value:function(t){var n=this;return t.timeoutID=setTimeout(function a(){if(t.callback(),t.loopCount+=1,!n.isBreakLoop(t))return t.timeoutID=setTimeout(a,t.delay)},t.delay)}},{key:"ric",value:function(t){var n,a=this,i=Pt();return t.ricID=Lk(function r(){if((n=Pt()-i)>=t.delay&&(i=Pt()-Math.floor(n%t.delay),t.callback(),t.loopCount+=1),!a.isBreakLoop(t))return t.ricID=Lk(r,{timeout:t.delay})},{timeout:t.delay})}},{key:"raf",value:function(t){var n=this;t.delay=(1e3/t.fps).toFixed(2);var a,i=Pt(),r=function s(){if(document.hidden&&t.backgroundTask)return a=Pt()-i,i=Pt(),t.callback(),t.loopCount+=1,n.isBreakLoop(t)?void 0:t.timeoutID=setTimeout(s,t.delay-Math.floor(a%t.delay));if((a=Pt()-i)>=t.delay&&(i=Pt()-Math.floor(a%t.delay),t.callback(),t.loopCount+=1),!n.isBreakLoop(t))return t.rafID=requestAnimationFrame(s)};if(t.rafID=requestAnimationFrame(r),t.backgroundTask){var o=function(){if(document.hidden){var s=Pt()-i;s>=t.delay?r():t.timeoutID=setTimeout(r,t.delay-s)}};document.addEventListener("visibilitychange",o),t.onVisibilitychange=o,document.hidden&&o()}return t.taskID}},{key:"hasTask",value:function(t){return this.taskMap.has(t)}},{key:"clearTask",value:function(t){if(!this.taskMap.has(t))return!0;var n=this.taskMap.get(t),a=n.intervalID,i=n.timeoutID,r=n.rafID,o=n.ricID,s=n.onVisibilitychange;return a&&clearInterval(a),i&&clearTimeout(i),r&&zV(r),o&&HV(o),s&&document.removeEventListener("visibilitychange",s),this.taskMap.delete(t),!0}},{key:"isBreakLoop",value:function(t){return!this.taskMap.has(t.taskID)||t.count!==0&&t.loopCount>=t.count&&(this.clearTask(t.taskID),!0)}}]),e}();Ye(_t,"taskMap",new Map),Ye(_t,"currentTaskID",1);var WV=function(){function e(){K(this,e),this.prefix_="TRTC",this.queue_=new Map,this.checkStorage()}return we(e,[{key:"getRealKey",value:function(t){return"".concat(this.prefix_,"_").concat(t)}},{key:"checkStorage",value:function(){var t=this;if(pa()){var n=Object.keys(localStorage).filter(function(a){if(a.startsWith(t.prefix_)){var i=JSON.parse(localStorage.getItem(a));if(i&&i.expiresIn<Date.now())return!0}return!1});n.forEach(function(a){return localStorage.removeItem(a)})}}},{key:"doFlush",value:function(){if(pa())try{var t,n=ae(this.queue_);try{for(n.s();!(t=n.n()).done;){var a=Te(t.value,2),i=a[0],r=a[1];localStorage.setItem(i,JSON.stringify(r))}}catch(o){n.e(o)}finally{n.f()}}catch(o){_e.warn(o)}}},{key:"getItem",value:function(t){if(!pa())return null;try{var n=JSON.parse(localStorage.getItem(this.getRealKey(t)));return n&&n.expiresIn>=Date.now()?n.value:null}catch(a){_e.warn(a)}}},{key:"setItem",value:function(t,n){var a=arguments.length>2&&arguments[2]!==void 0&&arguments[2];if(pa())try{var i={expiresIn:Date.now()+Qb,value:n};a?localStorage.setItem(this.getRealKey(t),JSON.stringify(i)):(this.queue_.set(this.getRealKey(t),i),_t.hasTask(this.intervalId_)||(this.intervalId_=_t.run(vo,this.doFlush.bind(this),{count:1})))}catch(r){_e.warn(r)}}},{key:"deleteItem",value:function(t){if(!pa())return!1;try{return t=this.getRealKey(t),this.queue_.delete(t),localStorage.removeItem(t),!0}catch(n){return _e.warn(n),!1}}},{key:"clear",value:function(){if(pa())try{localStorage.clear()}catch(t){_e.warn(t)}}}]),e}(),wo=new WV,mt={result:!1,detail:{isBrowserSupported:!1,isWebRTCSupported:!1,isMediaDevicesSupported:!1,isH264EncodeSupported:!1,isVp8EncodeSupported:!1,isH264DecodeSupported:!1,isVp8DecodeSupported:!1}},Ok="checkResult",Mk=function(){return!I4&&!nl&&!(rl&&AS<80)&&!(Tr&&RS<56)},gm=function(){return["RTCPeerConnection","webkitRTCPeerConnection","RTCIceGatherer"].filter(function(e){return e in window}).length>0},qV=function(){if(!navigator.mediaDevices)return!1;var e=["getUserMedia","enumerateDevices"];return e.filter(function(t){return t in navigator.mediaDevices}).length===e.length},Nk=function(){var e=G(m().mark(function t(){var n,a,i,r,o,s;return m().wrap(function(c){for(;;)switch(c.prev=c.next){case 0:if(!mt.detail.isH264EncodeSupported||!mt.detail.isVp8EncodeSupported){c.next=2;break}return c.abrupt("return",{isH264EncodeSupported:mt.detail.isH264EncodeSupported,isVp8EncodeSupported:mt.detail.isVp8EncodeSupported});case 2:return n="",a=!1,i=!1,c.prev=5,r=new RTCPeerConnection,(o=document.createElement(mb)).getContext("2d"),s=o.captureStream(0),r.addTrack(s.getVideoTracks()[0],s),c.next=13,r.createOffer();case 13:return(n=c.sent).sdp.toLowerCase().indexOf("h264")!==-1&&(a=!0),n.sdp.toLowerCase().indexOf("vp8")!==-1&&(i=!0),r.close(),mt.detail.isH264EncodeSupported=a,mt.detail.isVp8EncodeSupported=i,c.abrupt("return",{isH264EncodeSupported:mt.detail.isH264EncodeSupported,isVp8EncodeSupported:mt.detail.isVp8EncodeSupported});case 22:return c.prev=22,c.t0=c.catch(5),c.abrupt("return",{isH264EncodeSupported:!1,isVp8EncodeSupported:!1});case 25:case"end":return c.stop()}},t,null,[[5,22]])}));return function(){return e.apply(this,arguments)}}();function JV(){return _m.apply(this,arguments)}function _m(){return _m=G(m().mark(function e(){return m().wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",new Promise(function(){var n=G(m().mark(function a(i){var r,o,s,c,u,d,g,I,k,w,A,p,v,y;return m().wrap(function(L){for(;;)switch(L.prev=L.next){case 0:return r={encode:!1,decode:!1},o=null,L.prev=2,s=document.createElement("canvas"),c=s.getContext("2d"),s.width=640,s.height=480,u=setInterval(function(){c.fillText("test",Math.floor(640*Math.random()),Math.floor(480*Math.random()))},33),d=-1,g=-1,o=function(){clearInterval(d),clearInterval(u),clearTimeout(g),k.close(),w.close(),I.getTracks().forEach(function(f){return f.stop()})},g=setTimeout(function(){o(),i(r)},3e3),I=s.captureStream(),k=new RTCPeerConnection({}),w=new RTCPeerConnection({offerToReceiveAudio:!0,offerToReceiveVideo:!0}),k.addEventListener("icecandidate",function(f){return w.addIceCandidate(f.candidate)}),w.addEventListener("icecandidate",function(f){return k.addIceCandidate(f.candidate)}),k.addTrack(I.getVideoTracks()[0],I),L.next=20,k.createOffer();case 20:return A=L.sent,L.next=23,k.setLocalDescription(A);case 23:return L.next=25,w.setRemoteDescription(A);case 25:return L.next=27,w.createAnswer();case 27:return p=L.sent,v=Kr(p.sdp),y=v.media[0].rtp.findIndex(function(f){return f.codec==="H264"}),v.media[0].rtp=[v.media[0].rtp[y]],v.media[0].fmtp=v.media[0].fmtp.filter(function(f){return f.payload===v.media[0].rtp[0].payload}),v.media[0].rtcpFb=v.media[0].rtcpFb.filter(function(f){return f.payload===v.media[0].rtp[0].payload}),p.sdp=To(v),L.next=36,w.setLocalDescription(p);case 36:return L.next=38,k.setRemoteDescription(p);case 38:d=setInterval(G(m().mark(function f(){var b,P;return m().wrap(function(S){for(;;)switch(S.prev=S.next){case 0:return r.encode&&r.decode&&(o(),i(r)),S.next=3,k.getStats();case 3:return b=S.sent,S.next=6,w.getStats();case 6:P=S.sent,r.encode||b.forEach(function(T){T.type==="outbound-rtp"&&T.mediaType===xe&&T.framesEncoded>0&&(r.encode=!0)}),r.decode||P.forEach(function(T){T.type==="inbound-rtp"&&T.mediaType===xe&&T.framesDecoded>0&&(r.decode=!0)});case 9:case"end":return S.stop()}},f)})),500),L.next=46;break;case 41:L.prev=41,L.t0=L.catch(2),o(),_e.warn(L.t0),i(r);case 46:case"end":return L.stop()}},a,null,[[2,41]])}));return function(a){return n.apply(this,arguments)}}()));case 1:case"end":return t.stop()}},e)})),_m.apply(this,arguments)}var Uk=function(){var e=G(m().mark(function t(){var n,a,i,r;return m().wrap(function(o){for(;;)switch(o.prev=o.next){case 0:if(!mt.detail.isH264DecodeSupported||!mt.detail.isVp8DecodeSupported){o.next=2;break}return o.abrupt("return",{isH264DecodeSupported:mt.detail.isH264DecodeSupported,isVp8DecodeSupported:mt.detail.isVp8DecodeSupported});case 2:return n="",a=!1,i=!1,o.prev=5,r=new RTCPeerConnection,o.next=9,r.createOffer({offerToReceiveAudio:1,offerToReceiveVideo:1});case 9:return(n=o.sent).sdp.toLowerCase().indexOf("h264")!==-1&&(a=!0),n.sdp.toLowerCase().indexOf("vp8")!==-1&&(i=!0),r.close(),o.abrupt("return",{isH264DecodeSupported:a,isVp8DecodeSupported:i});case 16:return o.prev=16,o.t0=o.catch(5),o.abrupt("return",{isH264DecodeSupported:!1,isVp8DecodeSupported:!1});case 19:case"end":return o.stop()}},t,null,[[5,16]])}));return function(){return e.apply(this,arguments)}}(),KV=function(){var e=G(m().mark(function t(){var n,a,i,r,o,s,c,u,d,g,I,k,w;return m().wrap(function(A){for(;;)switch(A.prev=A.next){case 0:if(Vk()){A.next=2;break}return A.abrupt("return",mt);case 2:return n=Mk(),a=gm(),i=qV(),A.next=7,Nk();case 7:return r=A.sent,o=r.isH264EncodeSupported,s=r.isVp8EncodeSupported,A.next=12,Uk();case 12:if(c=A.sent,u=c.isH264DecodeSupported,d=c.isVp8DecodeSupported,o&&s){A.next=21;break}return A.next=18,Nk();case 18:g=A.sent,o=g.isH264EncodeSupported,s=g.isVp8EncodeSupported;case 21:if(!(o&&u&&(al||ol||L4)&&!zr&&go()<79)){A.next=29;break}return A.next=24,JV();case 24:I=A.sent,k=I.encode,w=I.decode,o=k,u=w;case 29:return mt.result=n&&a&&i&&(o||s)&&(u||d),mt.detail.isBrowserSupported=n,mt.detail.isWebRTCSupported=a,mt.detail.isMediaDevicesSupported=i,mt.detail.isH264EncodeSupported=o,mt.detail.isVp8EncodeSupported=s,mt.detail.isH264DecodeSupported=u,mt.detail.isVp8DecodeSupported=d,XV(),wo.setItem(Ok,{ua:navigator.userAgent,checkResult:mt},!0),A.abrupt("return",mt);case 40:case"end":return A.stop()}},t)}));return function(){return e.apply(this,arguments)}}(),ym=function(e,t){var n=null;return function(){if(n)return n;for(var a=arguments.length,i=new Array(a),r=0;r<a;r++)i[r]=arguments[r];return(n=e.apply(t||this,i)).then(function(o){return n=null,o}).catch(function(o){throw n=null,o}),n}}(KV);function Vk(){return Object.keys(mt.detail).findIndex(function(e){return!mt.detail[e]})>=0}function XV(){Vk()&&(_e.warn(ie({key:_S})),_e.info("".concat(navigator.userAgent," ").concat(JSON.stringify(mt.detail))))}function jk(){return!(!navigator.mediaDevices||!navigator.mediaDevices.getDisplayMedia)}function Bk(){return"RTCPeerConnection"in window&&"getReceivers"in window.RTCPeerConnection.prototype}function _l(){return"RTCPeerConnection"in window&&"getSenders"in window.RTCPeerConnection.prototype}function Pi(){return"RTCPeerConnection"in window&&"getTransceivers"in window.RTCPeerConnection.prototype}function bm(){return"RTCPeerConnection"in window&&"addTransceiver"in window.RTCPeerConnection.prototype}function Sm(){return"RTCRtpSender"in window&&"replaceTrack"in window.RTCRtpSender.prototype}function Fk(){return"RTCRtpSender"in window&&"setParameters"in window.RTCRtpSender.prototype&&_l()}function yl(){return!!ge(navigator.mediaDevices)&&(_e.error(xi.NOT_SUPPORTED_MEDIA),!0)}function bl(){return location.protocol==="http:"&&!ha&&(_e.warn(ie({key:gS})),!0)}var km="RTCRtpSender"in window&&"createEncodedStreams"in window.RTCRtpSender.prototype&&go()>=86;function Tm(e){return!(e.type!=="candidate-pair"||!e.nominated||e.state!=="in-progress"&&e.state!=="succeeded")&&!(er(e.selected)&&!e.selected)}var Gk=new Map([[la,"Android"],[Ii,"iOS"],[DS,"Windows"],[sc,"MacOS"],[LS,"Linux"]]);function xm(){var e="unknown";return Gk.get(!0)&&(e=Gk.get(!0)),e}function QV(){var e="";return screen.width&&(e+=(screen.width?screen.width*window.devicePixelRatio:"")+" * "+(screen.height?screen.height*window.devicePixelRatio:"")),e}function YV(){var e=!1;return(navigator.getUserMedia||navigator.mediaDevices&&navigator.mediaDevices.getUserMedia)&&(e=!0),e}function $V(){for(var e={isSupported:!1},t=["AudioContext","webkitAudioContext","mozAudioContext","msAudioContext"],n=0;n<t.length;n++)if(t[n]in window){e.isSupported=!0;break}return e.isSupported}function Hk(){return!(df&&go()<86)&&!(Ii&&Zn(wi)&&wi<15)&&!(Sf&&Sf<63)&&!(!Mk()||!("captureStream"in HTMLCanvasElement.prototype))}var Eo=window.MediaStreamTrack&&"getSettings"in MediaStreamTrack.prototype,ZV=window.MediaStreamTrack&&"getCapabilities"in MediaStreamTrack.prototype,e6=function(){var e,t,n;return((e=window)===null||e===void 0?void 0:e.OffscreenCanvas)&&((t=window)===null||t===void 0?void 0:t.MediaStreamTrackProcessor)&&((n=window)===null||n===void 0?void 0:n.MediaStreamTrackGenerator)};(function(){bl();var e=wo.getItem(Ok);e&&e.ua===navigator.userAgent&&(mt=e.checkResult),ym()})();var Ze={STREAM_ADDED:"stream-added",STREAM_REMOVED:"stream-removed",STREAM_UPDATED:"stream-updated",STREAM_PUBLISHED:"stream-published",STREAM_SUBSCRIBED:"stream-subscribed",STREAM_UNSUBSCRIBED:"stream-unsubscribed",STATE_CHANGED:"state-changed",ERROR:"error",CONNECTION_STATE_CHANGED:"connection-state-changed",SEI_MESSAGE:yb},ct={STREAM_ADDED:"stream-added",STREAM_REMOVED:"stream-removed",STREAM_UPDATED:"stream-updated",STREAM_SUBSCRIBED:"stream-subscribed",CONNECTION_STATE_CHANGED:"connection-state-changed",PEER_JOIN:"peer-join",PEER_LEAVE:"peer-leave",MUTE_AUDIO:"mute-audio",MUTE_VIDEO:"mute-video",UNMUTE_AUDIO:"unmute-audio",UNMUTE_VIDEO:"unmute-video",CLIENT_BANNED:"client-banned",NETWORK_QUALITY:"network-quality",AUDIO_VOLUME:"audio-volume",SEI_MESSAGE:yb,ERROR:"error"},zk="player-state-changed",t6="screen-sharing-stopped",n6="connection-state-changed",r6="device-auto-recovered",Im="error",bn="player-state-changed",i6=sS;Ue({target:"String",proto:!0,forced:cS("small")},{small:function(){return i6(this,"small","","")}});var a6=function(){function e(r){K(this,e);var o=r.getUserId();this.log_=_e.createLogger({id:o,userId:o,sdkAppId:r.getSDKAppId()}),this.prevReportTime_=0,this.prevReport_={},this.prevEncoderImplementation_="",this.prevQualityLimitationReason_="",this.prevDecoderImplementationMap_=new Map}var t,n,a,i;return we(e,[{key:"statInterval",get:function(){return this.prevReportTime_===0?2:(Date.now()-this.prevReportTime_)/1e3}},{key:"getSenderStats",value:(i=G(m().mark(function r(o){var s,c,u,d,g=this;return m().wrap(function(I){for(;;)switch(I.prev=I.next){case 0:if(s={audio:{bytesSent:0,packetsSent:0,audioLevel:0,totalAudioEnergy:0},video:{bytesSent:0,packetsSent:0,framesEncoded:0,frameWidth:0,frameHeight:0,framesSent:0,fpsCapture:0},small:{bytesSent:0,packetsSent:0,framesEncoded:0,frameWidth:0,frameHeight:0,framesSent:0,fpsCapture:0},auxiliary:{bytesSent:0,packetsSent:0,framesEncoded:0,frameWidth:0,frameHeight:0,framesSent:0,fpsCapture:0},rtt:0},c=o.getPeerConnection(),u=o.getSSRC(),!c){I.next=15;break}return I.prev=4,I.next=7,c.getStats();case 7:I.sent.forEach(function(k){if(k.type==="outbound-rtp")if(k.mediaType===xe){if(!Tr&&k.bytesSent===0)return;k.ssrc!==u.video||ge(k.encoderImplementation)||g.prevEncoderImplementation_===k.encoderImplementation||(g.log_.info("encoderImplementation change to ".concat(k.encoderImplementation)),g.prevEncoderImplementation_=k.encoderImplementation),k.ssrc!==u.video||ge(k.qualityLimitationReason)||g.prevQualityLimitationReason_===k.qualityLimitationReason||(g.log_.info("qualityLimitationReason change to ".concat(k.qualityLimitationReason)),g.prevQualityLimitationReason_=k.qualityLimitationReason);var w=xe;k.ssrc===u.small?w=Gr:k.ssrc===u.auxiliary&&(w=pt),s[w].bytesSent=k.bytesSent,s[w].packetsSent=k.packetsSent,s[w].framesEncoded=k.framesEncoded}else k.mediaType===Ae&&(s.audio.bytesSent=k.bytesSent,s.audio.packetsSent=k.packetsSent);else k.type==="candidate-pair"?Tm(k)&&Zn(k.currentRoundTripTime)&&(s.rtt=Math.floor(1e3*k.currentRoundTripTime)):k.type==="media-source"&&(k.kind===Ae?(s.audio.audioLevel=k.audioLevel||0,s.audio.totalAudioEnergy=k.totalAudioEnergy||0):k.kind===xe&&(k.trackIdentifier===o.getVideoTrackId(xe)?s.video.fpsCapture=k.framesPerSecond:k.trackIdentifier===o.getVideoTrackId(pt)?s.auxiliary.fpsCapture=k.framesPerSecond:s.small.fpsCapture=k.framesPerSecond));var A;ge(k.audioLevel)||(s.audio.audioLevel=k.audioLevel||0,s.audio.totalAudioEnergy=k.totalAudioEnergy||0),ge(k.frameWidth)||(k.trackIdentifier===o.getVideoTrackId(xe)||k.ssrc===u.video?A=xe:k.trackIdentifier===o.getVideoTrackId(pt)||k.ssrc===u.auxiliary?A=pt:k.trackIdentifier!==o.getVideoTrackId(Gr)&&k.ssrc!==u.small||(A=Gr),A&&(s[A].frameWidth=k.frameWidth,s[A].frameHeight=k.frameHeight,s[A].framesSent=k.framesSent))}),s.audio.audioLevel===0&&(s.audio.audioLevel=((d=o.getLocalStream())===null||d===void 0?void 0:d.getInternalAudioLevel())||0),I.next=15;break;case 12:I.prev=12,I.t0=I.catch(4),this.log_.warn("failed to getStats on sender connection "+I.t0);case 15:return I.abrupt("return",s);case 16:case"end":return I.stop()}},r,this,[[4,12]])})),function(r){return i.apply(this,arguments)})},{key:"getReceiverStats",value:(a=G(m().mark(function r(o){var s,c,u,d,g,I=this;return m().wrap(function(k){for(;;)switch(k.prev=k.next){case 0:if(s={tinyId:o.getTinyId(),userId:o.getUserId(),rtt:0,hasAudio:!1,hasVideo:!1,hasAuxiliary:!1,audio:{bytesReceived:0,packetsReceived:0,packetsLost:0,jitter:0,audioLevel:0,totalAudioEnergy:0},video:{bytesReceived:0,packetsReceived:0,packetsLost:0,framesReceived:0,framesDecoded:0,frameWidth:0,frameHeight:0},auxiliary:{bytesReceived:0,packetsReceived:0,packetsLost:0,framesReceived:0,framesDecoded:0,frameWidth:0,frameHeight:0}},!(c=o.getPeerConnection())){k.next=16;break}return k.prev=3,u=o.getSSRC(),d=o.getTrackState(),k.next=8,c.getStats();case 8:k.sent.forEach(function(w){if(w.type==="inbound-rtp"){if(w.mediaType===Ae&&w.ssrc===u.audio&&d.audio)s.audio.packetsReceived=w.packetsReceived,s.audio.bytesReceived=w.bytesReceived,s.audio.packetsLost=w.packetsLost,s.audio.jitter=w.jitter,s.hasAudio=!0;else if(w.mediaType===xe){if(Tr&&w.bytesReceived===0)return;w.ssrc===u.video&&d.video&&(s.video.packetsReceived=w.packetsReceived,s.video.bytesReceived=w.bytesReceived,s.video.packetsLost=w.packetsLost,s.video.framesReceived=w.framesReceived,s.video.framesDecoded=w.framesDecoded,s.video.fpsDecoded=w.framesPerSecond,s.hasVideo=!0,!w.decoderImplementation||I.prevDecoderImplementationMap_.has(s.userId)&&I.prevDecoderImplementationMap_.get(s.userId)===w.decoderImplementation||(I.log_.info("".concat(s.userId," decoderImplementation change to ").concat(w.decoderImplementation)),I.prevDecoderImplementationMap_.set(s.userId,w.decoderImplementation))),w.ssrc===u.auxiliary&&d.auxiliary&&(s.auxiliary.packetsReceived=w.packetsReceived,s.auxiliary.bytesReceived=w.bytesReceived,s.auxiliary.packetsLost=w.packetsLost,s.auxiliary.framesReceived=w.framesReceived,s.auxiliary.framesDecoded=w.framesDecoded,s.auxiliary.fpsDecoded=w.framesPerSecond,s.hasAuxiliary=!0)}}else w.type==="candidate-pair"&&Tm(w)&&Zn(w.currentRoundTripTime)&&(s.rtt=Math.floor(1e3*w.currentRoundTripTime));ge(w.frameWidth)||(w.trackIdentifier!==o.getMainStreamVideoTrackId()&&w.ssrc!==u.video||(s.video.frameWidth=w.frameWidth,s.video.frameHeight=w.frameHeight),w.trackIdentifier!==o.getAuxStreamVideoTrackId()&&w.ssrc!==u.auxiliary||(s.auxiliary.frameWidth=w.frameWidth,s.auxiliary.frameHeight=w.frameHeight)),ge(w.audioLevel)||(s.audio.audioLevel=w.audioLevel||0,s.audio.totalAudioEnergy=w.totalAudioEnergy||0)}),s.audio.audioLevel===0&&(s.audio.audioLevel=((g=o.getMainStream())===null||g===void 0?void 0:g.getInternalAudioLevel())||0),k.next=16;break;case 13:k.prev=13,k.t0=k.catch(3),this.log_.warn("failed to getStats on receiver connection "+k.t0);case 16:return k.abrupt("return",s);case 17:case"end":return k.stop()}},r,this,[[3,13]])})),function(r){return a.apply(this,arguments)})},{key:"getStats",value:(n=G(m().mark(function r(o,s){var c,u,d,g,I,k,w;return m().wrap(function(A){for(;;)switch(A.prev=A.next){case 0:if(c={},!o){A.next=5;break}return A.next=4,this.getSenderStats(o);case 4:c=A.sent;case 5:u=[],d=ae(s),A.prev=7,d.s();case 9:if((g=d.n()).done){A.next=17;break}return(I=Te(g.value,2))[0],k=I[1],A.next=13,this.getReceiverStats(k);case 13:w=A.sent,u.push(w);case 15:A.next=9;break;case 17:A.next=22;break;case 19:A.prev=19,A.t0=A.catch(7),d.e(A.t0);case 22:return A.prev=22,d.f(),A.finish(22);case 25:return A.abrupt("return",{senderStats:c,receiverStats:u});case 26:case"end":return A.stop()}},r,this,[[7,19,22,25]])})),function(r,o){return n.apply(this,arguments)})},{key:"getDifferenceValue",value:function(r,o){if(Ai(r))return o;var s=o-r;return s<0?0:s}},{key:"prepareReport",value:function(r){var o=this,s=r.stats,c=r.report,u=r.freezeMap;if(!Ai(s.senderStats)){var d;d={uint32_audio_level:1e8*s.senderStats.audio.audioLevel,uint32_audio_energy:1e6*s.senderStats.audio.totalAudioEnergy,uint32_audio_codec_bitrate:s.senderStats.audio.bytesSent,audioLevel:s.senderStats.audio.audioLevel};var g=[],I={uint32_video_stream_type:2,uint32_video_codec_fps:s.senderStats.video.framesSent,uint32_video_capture_fps:s.senderStats.video.fpsCapture,uint32_video_width:s.senderStats.video.frameWidth,uint32_video_height:s.senderStats.video.frameHeight,uint32_video_codec_bitrate:s.senderStats.video.bytesSent,uint32_video_enc_fps:s.senderStats.video.framesEncoded};if(g.push(I),s.senderStats.small.bytesSent){var k={uint32_video_stream_type:3,uint32_video_codec_fps:s.senderStats.small.framesSent||0,uint32_video_capture_fps:s.senderStats.small.fpsCapture||0,uint32_video_width:s.senderStats.small.frameWidth||0,uint32_video_height:s.senderStats.small.frameHeight||0,uint32_video_codec_bitrate:s.senderStats.small.bytesSent,uint32_video_enc_fps:s.senderStats.small.framesEncoded||0};g.push(k)}if(s.senderStats.auxiliary.bytesSent){var w={uint32_video_stream_type:7,uint32_video_codec_fps:s.senderStats.auxiliary.framesSent||0,uint32_video_capture_fps:s.senderStats.auxiliary.fpsCapture||0,uint32_video_width:s.senderStats.auxiliary.frameWidth||0,uint32_video_height:s.senderStats.auxiliary.frameHeight||0,uint32_video_codec_bitrate:s.senderStats.auxiliary.bytesSent,uint32_video_enc_fps:s.senderStats.auxiliary.framesEncoded||0};g.push(w)}var A={uint32_bitrate:0,uint32_rtt:s.senderStats.rtt};c.msg_up_stream_info={msg_audio_status:d,msg_video_status:g,msg_network_status:A}}var p=this.statInterval;c.msg_down_stream_info=[],s.receiverStats.forEach(function(T){var C={};if(C.msg_user_info={str_identifier:T.userId,uint64_tinyid:T.tinyId},C.msg_network_status={uint32_rtt:T.rtt},C.msg_video_status={},T.hasAudio){var D={uint32_audio_codec_bitrate:T.audio.bytesReceived,uint32_audio_total_bitrate:T.audio.bytesReceived,uint32_audio_level:1e8*T.audio.audioLevel,uint32_audio_energy:1e6*T.audio.totalAudioEnergy,uint32_audio_receive:T.audio.packetsReceived,uint32_audio_origin_lost:T.audio.packetsLost,audioLevel:T.audio.audioLevel};C.msg_audio_status=D}if(C.msg_video_status=[],T.hasVideo){var B=u.get(T.userId+"_"+gt),x=B?B.duration:0,h={uint32_video_stream_type:2,uint32_video_receive_fps:T.video.framesReceived,uint32_video_width:T.video.frameWidth,uint32_video_height:T.video.frameHeight,uint32_video_codec_bitrate:T.video.bytesReceived,uint32_video_receive:T.video.packetsReceived,uint32_video_origin_lost:T.video.packetsLost,uint32_video_block_time:x,uint32_video_dec_fps:T.video.framesDecoded};C.msg_video_status.push(h)}if(T.hasAuxiliary){var E=u.get(T.userId+"_"+Lt),O=E?E.duration:0,N={uint32_video_stream_type:7,uint32_video_receive_fps:T.auxiliary.framesReceived,uint32_video_width:T.auxiliary.frameWidth,uint32_video_height:T.auxiliary.frameHeight,uint32_video_codec_bitrate:T.auxiliary.bytesReceived,uint32_video_receive:T.auxiliary.packetsReceived+T.auxiliary.packetsLost,uint32_video_origin_lost:T.auxiliary.packetsLost,uint32_video_block_time:O,uint32_video_dec_fps:T.auxiliary.framesDecoded};C.msg_video_status.push(N)}c.msg_down_stream_info.push(C)});var v=this.prevReport_;if(this.prevReport_=JSON.parse(JSON.stringify(c)),c.msg_up_stream_info.msg_audio_status&&v.msg_up_stream_info.msg_audio_status){var y=v.msg_up_stream_info.msg_audio_status,L=c.msg_up_stream_info.msg_audio_status,f=this.getDifferenceValue(y.uint32_audio_codec_bitrate,L.uint32_audio_codec_bitrate);L.uint32_audio_codec_bitrate=Math.round(8*f/p),c.msg_up_stream_info.msg_network_status.uint32_bitrate+=L.uint32_audio_codec_bitrate}var b=v.msg_up_stream_info.msg_video_status;c.msg_up_stream_info.msg_video_status.forEach(function(T){var C=b.find(function(E){return E.uint32_video_stream_type===T.uint32_video_stream_type});if(!C||C.uint32_video_codec_bitrate===0)return T.uint32_video_codec_bitrate=0,T.uint32_video_enc_fps=0,void(T.uint32_video_codec_fps=0);var D=C.uint32_video_codec_bitrate,B=C.uint32_video_enc_fps,x=C.uint32_video_codec_fps,h=o.getDifferenceValue(D,T.uint32_video_codec_bitrate);T.uint32_video_codec_bitrate=Math.round(8*h/p),c.msg_up_stream_info.msg_network_status.uint32_bitrate+=T.uint32_video_codec_bitrate,T.uint32_video_enc_fps=Math.round(o.getDifferenceValue(B,T.uint32_video_enc_fps)/p),T.uint32_video_codec_fps=Math.round(o.getDifferenceValue(x,T.uint32_video_codec_fps)/p)});var P=c.msg_down_stream_info,S=v.msg_down_stream_info;return P.forEach(function(T){var C=S.find(function(O){return O.msg_user_info.uint64_tinyid===T.msg_user_info.uint64_tinyid});if(C){if(T.msg_audio_status&&C.msg_audio_status){var D=T.msg_audio_status,B=C.msg_audio_status;D.uint32_audio_origin_lost=o.getDifferenceValue(B.uint32_audio_origin_lost,D.uint32_audio_origin_lost),D.uint32_audio_receive=o.getDifferenceValue(B.uint32_audio_receive,D.uint32_audio_receive),D.uint32_audio_receive+=D.uint32_audio_origin_lost;var x=o.getDifferenceValue(B.uint32_audio_codec_bitrate,D.uint32_audio_codec_bitrate);D.uint32_audio_codec_bitrate=Math.round(8*x/p),D.uint32_audio_total_bitrate=Math.round(8*x/p)}if(T.msg_video_status&&C.msg_video_status){var h=T.msg_video_status,E=C.msg_video_status;h.forEach(function(O){var N=E.find(function(We){return We.uint32_video_stream_type===O.uint32_video_stream_type});if(!N)return O.uint32_video_receive=0,O.uint32_video_origin_lost=0,O.uint32_video_codec_bitrate=0,O.uint32_video_receive_fps=0,void(O.uint32_video_dec_fps=0);var j=N.uint32_video_receive,J=N.uint32_video_origin_lost,$=N.uint32_video_codec_bitrate,he=N.uint32_video_receive_fps,ue=N.uint32_video_dec_fps;O.uint32_video_origin_lost=o.getDifferenceValue(J,O.uint32_video_origin_lost),O.uint32_video_receive=o.getDifferenceValue(j,O.uint32_video_receive)+O.uint32_video_origin_lost;var Ee=o.getDifferenceValue($,O.uint32_video_codec_bitrate);O.uint32_video_codec_bitrate=Math.round(8*Ee/p);var Ve=o.getDifferenceValue(he,O.uint32_video_receive_fps);O.uint32_video_receive_fps=Math.round(Ve/p),O.uint32_video_dec_fps=Math.round(o.getDifferenceValue(ue,O.uint32_video_dec_fps)/p)})}}}),c}},{key:"getStatsReport",value:(t=G(m().mark(function r(o){var s,c,u,d,g;return m().wrap(function(I){for(;;)switch(I.prev=I.next){case 0:return s=o.uplinkConnection,c=o.downlinkConnections,u=o.freezeMap,d={msg_up_stream_info:{msg_audio_status:{uint32_audio_format:0,uint32_audio_sample_rate:0,uint32_audio_codec_bitrate:0,uint32_audio_receive:0,uint32_audio_origin_lost:0,uint32_audio_level:0,uint32_audio_energy:0,audioLevel:0},msg_video_status:[{uint32_video_stream_type:0,uint32_video_codec_fps:0,uint32_video_capture_fps:0,uint32_video_width:0,uint32_video_height:0,uint32_video_codec_bitrate:0,uint32_video_receive:0,uint32_video_origin_lost:0,uint32_video_final_lost:0,uint32_video_enc_fps:0}],msg_network_status:{uint32_bitrate:0,uint32_rtt:0,uint32_lost:0}},msg_down_stream_info:[{msg_user_info:{str_identifier:"",uint64_tinyid:""},msg_audio_status:{uint32_audio_format:0,uint32_audio_sample_rate:0,uint32_audio_codec_bitrate:0,uint32_audio_total_bitrate:0,uint32_audio_level:0,uint32_audio_energy:0,uint32_audio_receive:0,uint32_audio_origin_lost:0,uint32_audio_final_lost:0,audioLevel:0},msg_video_status:[{uint32_video_stream_type:0,uint32_video_receive_fps:0,uint32_video_width:0,uint32_video_height:0,uint32_video_codec_bitrate:0,uint32_video_receive:0,uint32_video_origin_lost:0,uint32_video_block_time:0,uint32_video_dec_fps:0}],msg_network_status:{uint32_bitrate:0,uint32_rtt:0,uint32_lost:0,uint32_jitter:0}}]},I.next=4,this.getStats(s,c);case 4:return g=I.sent,JSON.stringify(this.prevReport_)==="{}"&&(this.prevReport_=JSON.parse(JSON.stringify(d))),this.prepareReport({stats:g,report:d,freezeMap:u,uplinkConnection:s,downlinkConnections:c}),this.prevReportTime_=Date.now(),I.abrupt("return",d);case 9:case"end":return I.stop()}},r,this)})),function(r){return t.apply(this,arguments)})},{key:"reset",value:function(){this.prevReportTime_=0,this.prevReport_={},this.prevEncoderImplementation_="",this.prevQualityLimitationReason_="",this.prevDecoderImplementationMap_=new Map}}]),e}(),o6=function(){function e(a){var i=a.signalChannel,r=a.connections,o=a.client;K(this,e),this.client_=o,this.signalChannel_=i,this.connections_=r,this.client_=o,this.log_=_e.createLogger({id:"q|"+this.client_.getUserId(),userId:this.client_.getUserId(),sdkAppId:this.client_.getSDKAppId()}),this.uplinkConnection_=null,this.uplinkNetworkQuality_=0,this.uplinkRTT_=0,this.uplinkLoss_=0,this.downlinkNetworkQuality_=0,this.downlinkRTT_=0,this.downlinkLoss_=0,this.downlinkPrevStatMap_=new Map,this.downlinkLossAndRTTMap_=new Map,this.interval_=-1,this.emitter_=new Ri,this.initialize()}var t,n;return we(e,[{key:"uplinkNetworkQuality",get:function(){return this.uplinkNetworkQuality_},set:function(a){a!==this.uplinkNetworkQuality_&&this.log_.info("uplink network quality change ".concat(this.uplinkNetworkQuality," -> ").concat(a,", rtt: ").concat(this.uplinkRTT_,", loss: ").concat(this.uplinkLoss_)),this.uplinkNetworkQuality_=a}},{key:"downlinkNetworkQuality",get:function(){return this.downlinkNetworkQuality_},set:function(a){if(a!==this.downlinkNetworkQuality_){var i=this.getAverageLossAndRTT(be(this.downlinkLossAndRTTMap_.values())),r=i.rtt,o=i.loss;this.log_.info("downlink network quality change ".concat(this.downlinkNetworkQuality," -> ").concat(a,", rtt: ").concat(r,", loss: ").concat(o))}this.downlinkNetworkQuality_=a}},{key:"initialize",value:function(){var a=this;this.signalChannel_.on(ft.UPLINK_NETWORK_STATS,function(i){a.handleUplinkNetworkQuality(i)}),this.signalChannel_.on(im,this.handleSignalConnectionStateChange.bind(this)),this.start()}},{key:"handleUplinkNetworkQuality",value:function(a){if(!this.uplinkConnection_)return this.uplinkNetworkQuality=0,this.uplinkLoss_=0,void(this.uplinkRTT_=0);var i=this.uplinkConnection_.getPeerConnection();if(i&&this.isPeerConnectionDisconnected(i))return this.uplinkNetworkQuality=6,this.uplinkLoss_=0,void(this.uplinkRTT_=0);if(a.data.code===0){var r=a.data.data,o=r.expectAudPkg+r.expectVidPkg,s=r.recvAudPkg+r.recvVidPkg,c=o-s,u=r.delay;if(u&&this.updateDelay(u),o===0&&s===0)return;this.uplinkLoss_=c<=0?0:Math.round(c/o*100),this.uplinkRTT_=r.rtt,this.uplinkNetworkQuality=this.getNetworkQuality(this.uplinkLoss_,this.uplinkRTT_)}}},{key:"handleDownlinkNetworkQuality",value:(n=G(m().mark(function a(){var i,r,o,s,c,u,d,g,I,k,w,A,p,v,y,L=this;return m().wrap(function(f){for(;;)switch(f.prev=f.next){case 0:if(this.connections_&&this.connections_.size!==0){f.next=3;break}return this.downlinkNetworkQuality=0,f.abrupt("return");case 3:if(i=be(this.connections_.values()),r=i.filter(function(b){return b.getPeerConnection()&&b.getPeerConnection().connectionState===Ib}),i.filter(function(b){return b.getPeerConnection()&&L.isPeerConnectionDisconnected(b.getPeerConnection())}).length!==i.length){f.next=9;break}return this.downlinkNetworkQuality=6,f.abrupt("return");case 9:o=0;case 10:if(!(o<r.length)){f.next=31;break}return s=r[o].getPeerConnection(),f.next=14,this.getStat(s);case 14:if(c=f.sent,u=c.rtt,d=c.totalPacketsLost,g=c.totalPacketsReceived,this.downlinkPrevStatMap_.has(s)){f.next=21;break}return this.downlinkPrevStatMap_.set(s,{totalPacketsLost:d,totalPacketsReceived:g}),f.abrupt("continue",28);case 21:I=0,k=this.downlinkPrevStatMap_.get(s),w=d-k.totalPacketsLost,A=g-k.totalPacketsReceived,I=w<=0||A<0?0:Math.round(w/(w+A)*100),this.downlinkPrevStatMap_.set(s,{totalPacketsLost:d,totalPacketsReceived:g}),this.downlinkLossAndRTTMap_.set(s,{rtt:u,loss:I,userId:r[o].getUserId()});case 28:o++,f.next=10;break;case 31:if(be(this.downlinkPrevStatMap_.keys()).forEach(function(b){L.isPeerConnectionDisconnected(b)&&(L.downlinkPrevStatMap_.delete(b),L.downlinkLossAndRTTMap_.delete(b))}),this.downlinkLossAndRTTMap_.size!==0){f.next=34;break}return f.abrupt("return");case 34:p=this.getAverageLossAndRTT(be(this.downlinkLossAndRTTMap_.values())),v=p.rtt,y=p.loss,this.downlinkRTT_=v,this.downlinkLoss_=y,this.downlinkNetworkQuality=this.getNetworkQuality(y,v);case 38:case"end":return f.stop()}},a,this)})),function(){return n.apply(this,arguments)})},{key:"getStat",value:(t=G(m().mark(function a(i){var r,o,s,c;return m().wrap(function(u){for(;;)switch(u.prev=u.next){case 0:if(r={rtt:0,totalPacketsLost:0,totalPacketsReceived:0},i&&Bk()){u.next=3;break}return u.abrupt("return",r);case 3:o=i.getReceivers(),u.prev=4,s=0;case 6:if(!(s<o.length)){u.next=15;break}return c=o[s],u.next=10,c.getStats();case 10:u.sent.forEach(function(d){d.type==="candidate-pair"&&Zn(d.currentRoundTripTime)&&(r.rtt=Math.round(1e3*d.currentRoundTripTime)),d.type!=="inbound-rtp"||d.mediaType!==Ae&&d.mediaType!==xe||(r.totalPacketsLost+=d.packetsLost,r.totalPacketsReceived+=d.packetsReceived)});case 12:s++,u.next=6;break;case 15:return u.abrupt("return",r);case 18:return u.prev=18,u.t0=u.catch(4),u.abrupt("return",r);case 21:case"end":return u.stop()}},a,null,[[4,18]])})),function(a){return t.apply(this,arguments)})},{key:"getAverageLossAndRTT",value:function(a){var i={rtt:0,loss:0};return Array.isArray(a)&&a.length>0&&(a.forEach(function(r){i.rtt+=r.rtt,i.loss+=r.loss}),Object.keys(i).forEach(function(r){i[r]=Math.round(i[r]/a.length)})),i}},{key:"getNetworkQuality",value:function(a,i){return a>50||i>500?5:a>30||i>350?4:a>20||i>200?3:a>10||i>100?2:a>=0||i>=0?1:0}},{key:"handleSignalConnectionStateChange",value:function(a){a.state===gl?(this.uplinkRTT_=0,this.uplinkLoss_=0,this.uplinkNetworkQuality=6):a.state===pc&&this.uplinkNetworkQuality===6&&(this.uplinkNetworkQuality=5)}},{key:"handleUplinkConnectionStateChange",value:function(a){var i=a.state;i===on?(this.uplinkLoss_=0,this.uplinkRTT_=0,this.uplinkNetworkQuality=6):i===_n&&this.uplinkNetworkQuality===6&&(this.uplinkNetworkQuality=5)}},{key:"isPeerConnectionDisconnected",value:function(a){return!(!a||a.connectionState!==rN&&a.connectionState!==xb&&a.connectionState!==Bp)}},{key:"setUplinkConnection",value:function(a){this.uplinkConnection_=a,this.uplinkConnection_?this.uplinkConnection_.on(Ze.CONNECTION_STATE_CHANGED,this.handleUplinkConnectionStateChange.bind(this)):(this.uplinkNetworkQuality=0,this.uplinkRTT_=0,this.uplinkLoss_=0)}},{key:"start",value:function(){var a=this;this.interval_===-1?(this.log_.info("start network quality calculating"),this.interval_=_t.run(vo,function(){a.handleDownlinkNetworkQuality(),X.emit($f,{client:a.client_,uplinkNetworkQuality:a.uplinkNetworkQuality,downlinkNetworkQuality:a.downlinkNetworkQuality,uplinkRTT:a.uplinkRTT_,uplinkLoss:a.uplinkLoss_,downlinkRTT:a.downlinkRTT_,downlinkLoss:a.downlinkLoss_,downlinkLossAndRTTMap:a.downlinkLossAndRTTMap_}),a.emitter_.emit(ct.NETWORK_QUALITY,{uplinkNetworkQuality:a.uplinkNetworkQuality,downlinkNetworkQuality:a.downlinkNetworkQuality,uplinkRTT:a.uplinkRTT_,uplinkLoss:a.uplinkLoss_,downlinkRTT:a.downlinkRTT_,downlinkLoss:a.downlinkLoss_})},{delay:2e3})):this.log_.info("network quality calculating is already started")}},{key:"stop",value:function(){this.log_.info("stop network quality calculating"),this.interval_!==-1&&(_t.clearTask(this.interval_),this.interval_=-1),this.downlinkLossAndRTTMap_.clear(),this.downlinkPrevStatMap_.clear()}},{key:"on",value:function(a,i){this.emitter_.on(a,i)}},{key:"updateDelay",value:function(a){var i=this;a.forEach(function(r){var o=r.srcTinyId,s=r.videoDelay,c=r.audioDelay,u=i.connections_.get(o);u&&u.setDelay({videoDelay:s,audioDelay:c})})}}]),e}(),s6=function(){function e(a){K(this,e),this.log_=_e.createLogger({id:a.client.getUserId(),userId:a.client.getUserId(),sdkAppId:a.client.getSDKAppId()}),this.localStream_=null,this.prevDevices_=[],this.initialize()}var t,n;return we(e,[{key:"initialize",value:function(){navigator.mediaDevices&&navigator.mediaDevices.addEventListener&&(this.onDeviceChange=this.onDeviceChange.bind(this),navigator.mediaDevices.addEventListener("devicechange",this.onDeviceChange))}},{key:"destroy",value:function(){navigator.mediaDevices&&navigator.mediaDevices.removeEventListener&&navigator.mediaDevices.removeEventListener("devicechange",this.onDeviceChange)}},{key:"onDeviceChange",value:(n=G(m().mark(function a(){var i,r,o,s=this;return m().wrap(function(c){for(;;)switch(c.prev=c.next){case 0:if(this.localStream_&&this.localStream_.getMediaStream()&&!this.localStream_.getScreen()){c.next=2;break}return c.abrupt("return");case 2:return c.next=4,Em();case 4:i=c.sent,r=i.filter(function(u){return s.prevDevices_.findIndex(function(d){var g=d.deviceId;return u.deviceId===g})<0}),o=this.prevDevices_.filter(function(u){return i.findIndex(function(d){var g=d.deviceId;return u.deviceId===g})<0}),r.length>0&&this.handleDeviceAdded(this.prevDevices_,r),o.length>0&&this.handleDeviceRemoved(i,o),this.prevDevices_=i;case 10:case"end":return c.stop()}},a,this)})),function(){return n.apply(this,arguments)})},{key:"setLocalStream",value:(t=G(m().mark(function a(i){return m().wrap(function(r){for(;;)switch(r.prev=r.next){case 0:if(!i){r.next=4;break}return r.next=3,Em();case 3:this.prevDevices_=r.sent;case 4:this.localStream_=i;case 5:case"end":return r.stop()}},a,this)})),function(a){return t.apply(this,arguments)})},{key:"handleDeviceAdded",value:function(a,i){var r,o;if(this.localStream_){this.log_.warn("devicesAdded: ".concat(JSON.stringify(i))),this.localStream_.updateDeviceIdInUse();var s=i.filter(function(k){return k.kind===qu}),c=i.filter(function(k){return k.kind===ec}),u=a.filter(function(k){return k.kind===qu}),d=a.filter(function(k){return k.kind===ec}),g=s.length>0&&u.length===0&&((r=this.localStream_.getVideoTrack())===null||r===void 0?void 0:r.readyState)!=="live",I=c.length>0&&d.length===0&&((o=this.localStream_.getAudioTrack())===null||o===void 0?void 0:o.readyState)!=="live";if(I&&g)return this.log_.info("new microphone and camera detected, but there was no device before."),void this.localStream_.recoverCapture({audio:!0,video:!0,cameraId:s[0].deviceId,microphoneId:c[0].deviceId});g&&(this.log_.info("new camera detected, but there was no camera before."),this.localStream_.recoverCapture({audio:!1,video:!0,cameraId:s[0].deviceId})),I&&(this.log_.info("new microphone detected, but there was no microphone before."),this.localStream_.recoverCapture({audio:!0,video:!1,microphoneId:c[0].deviceId}))}}},{key:"handleDeviceRemoved",value:function(a,i){if(this.localStream_){this.log_.warn("devicesRemoved: ".concat(JSON.stringify(i))),this.localStream_.updateDeviceIdInUse();var r=!1,o=!1,s=this.localStream_.getCameraId(),c=this.localStream_.getMicrophoneId();if(c===$u){var u=this.localStream_.getMicrophoneGroupId(),d=a.filter(function(g){return g.deviceId===$u&&g.kind===ec})[0];d&&d.groupId!==u&&(o=!0)}if(i.forEach(function(g){var I=g.deviceId;s.length>0&&I===s?r=!0:c.length>0&&I===c&&(o=!0)}),r&&o)return this.log_.warn("current camera and microphone in use is lost, cameraId: ".concat(s,", microphoneId: ").concat(c)),void((this.localStream_.getAudio()||this.localStream_.getVideo())&&this.localStream_.recoverCapture({video:!0,audio:!0}));r&&(this.log_.warn("current camera in use is lost, deviceId: ".concat(s)),this.localStream_.getVideo()&&this.localStream_.recoverCapture({video:!0,audio:!1})),o&&(this.log_.warn("current microphone in use is lost, deviceId: ".concat(c)),this.localStream_.getAudio()&&this.localStream_.recoverCapture({video:!1,audio:!0}))}}}]),e}();function wm(){return wm=G(m().mark(function e(){var t;return m().wrap(function(n){for(;;)switch(n.prev=n.next){case 0:if(!bl()&&!yl()){n.next=2;break}return n.abrupt("return",[]);case 2:return n.next=4,Sl();case 4:return t=n.sent,n.abrupt("return",t.filter(function(a){return a.kind===qu}).map(function(a,i){var r=a.label;a.label||(r="camera_"+i);var o={label:r,deviceId:a.deviceId,kind:a.kind};return a.groupId&&(o.groupId=a.groupId),a.getCapabilities&&(o.getCapabilities=function(){return a.getCapabilities()}),o}));case 6:case"end":return n.stop()}},e)})),wm.apply(this,arguments)}var Wk=new Set;function Sl(){return qk.apply(this,arguments)}function qk(){return(qk=G(m().mark(function e(){var t;return m().wrap(function(n){for(;;)switch(n.prev=n.next){case 0:if(!bl()&&!yl()){n.next=2;break}return n.abrupt("return",[]);case 2:return n.next=4,navigator.mediaDevices.enumerateDevices();case 4:return(t=n.sent).forEach(function(a){Wk.add("".concat(a.deviceId,"_").concat(a.kind))}),n.abrupt("return",t);case 7:case"end":return n.stop()}},e)}))).apply(this,arguments)}function Em(){return Cm.apply(this,arguments)}function Cm(){return Cm=G(m().mark(function e(){var t;return m().wrap(function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,Sl();case 2:return t=n.sent,n.abrupt("return",t.filter(function(a){return a.kind!==ec||a.deviceId!=tS}).map(function(a,i){var r=a.label;a.label||(r=a.kind+"_"+i);var o={label:r,deviceId:a.deviceId,kind:a.kind};return a.groupId&&(o.groupId=a.groupId),a.getCapabilities&&(o.getCapabilities=function(){return a.getCapabilities()}),o}));case 4:case"end":return n.stop()}},e)})),Cm.apply(this,arguments)}function Jk(){return Rm.apply(this,arguments)}function Rm(){return Rm=G(m().mark(function e(){var t;return m().wrap(function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,Sl();case 2:return t=n.sent,n.abrupt("return",t.filter(function(a){return a.kind===ec&&a.deviceId!==tS}).map(function(a,i){var r=a.label;a.label||(r="microphone_"+i);var o={label:r,deviceId:a.deviceId,kind:a.kind};return a.groupId&&(o.groupId=a.groupId),a.getCapabilities&&(o.getCapabilities=function(){return a.getCapabilities()}),o}));case 4:case"end":return n.stop()}},e)})),Rm.apply(this,arguments)}function Kk(){return Am.apply(this,arguments)}function Am(){return Am=G(m().mark(function e(){var t;return m().wrap(function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,Sl();case 2:return t=n.sent,n.abrupt("return",t.filter(function(a){return a.kind==="audiooutput"}).map(function(a,i){var r=a.label;a.label||(r="speaker_"+i);var o={label:r,deviceId:a.deviceId,kind:a.kind};return a.groupId&&(o.groupId=a.groupId),o}));case 4:case"end":return n.stop()}},e)})),Am.apply(this,arguments)}function c6(e){var t;if(e instanceof CanvasCaptureMediaStreamTrack||!(e instanceof window.MediaStreamTrack))return!1;var n=e.label.toLocaleLowerCase();if(n.includes("camera")||n.includes("webcam"))return!0;var a="".concat((t=e.getSettings())===null||t===void 0?void 0:t.deviceId,"_").concat(qu);return!!Wk.has(a)}function u6(e,t){return Xk.apply(this,arguments)}function Xk(){return(Xk=G(m().mark(function e(t,n){var a,i;return m().wrap(function(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,Jk();case 2:if(a=r.sent,((i=a.find(function(o){return o.deviceId===$u}))==null?void 0:i.groupId)!==t||i.label!==n){r.next=6;break}return r.abrupt("return",!0);case 6:return r.abrupt("return",!1);case 7:case"end":return r.stop()}},e)}))).apply(this,arguments)}var Vn,Qk=Ga.exports,l6=At,d6=yt,h6=i_,p6=Fr,f6=Ke,m6=Ut,v6=function(e,t,n,a){try{return a?t(d6(n)[0],n[1]):t(n)}catch(i){h6(e,"throw",i)}},g6=dh,_6=Tu,y6=nn,Yk=Os,b6=_u,S6=Ms,$k=Array,Zk=function(e){var t=m6(e),n=_6(this),a=arguments.length,i=a>1?arguments[1]:void 0,r=i!==void 0;r&&(i=p6(i,a>2?arguments[2]:void 0));var o,s,c,u,d,g,I=S6(t),k=0;if(!I||this===$k&&g6(I))for(o=y6(t),s=n?new this(o):$k(o);o>k;k++)g=r?i(t[k],k):t[k],Yk(s,k,g);else for(d=(u=b6(t,I)).next,s=n?new this:[];!(c=f6(d,u)).done;k++)g=r?v6(u,i,[c.value,k],!0):c.value,Yk(s,k,g);return s.length=k,s},ya=ke,Pm=2147483647,k6=/[^\0-\u007E]/,eT=/[.\u3002\uFF0E\uFF61]/g,tT="Overflow: input needs wider integers to process",nT=RangeError,T6=ya(eT.exec),Co=Math.floor,Dm=String.fromCharCode,rT=ya("".charCodeAt),iT=ya([].join),Di=ya([].push),x6=ya("".replace),I6=ya("".split),w6=ya("".toLowerCase),aT=function(e){return e+22+75*(e<26)},E6=function(e,t,n){var a=0;for(e=n?Co(e/700):e>>1,e+=Co(e/t);e>455;)e=Co(e/35),a+=36;return Co(a+36*e/(e+38))},C6=function(e){var t=[];e=function(v){for(var y=[],L=0,f=v.length;L<f;){var b=rT(v,L++);if(b>=55296&&b<=56319&&L<f){var P=rT(v,L++);(64512&P)==56320?Di(y,((1023&b)<<10)+(1023&P)+65536):(Di(y,b),L--)}else Di(y,b)}return y}(e);var n,a,i=e.length,r=128,o=0,s=72;for(n=0;n<e.length;n++)(a=e[n])<128&&Di(t,Dm(a));var c=t.length,u=c;for(c&&Di(t,"-");u<i;){var d=Pm;for(n=0;n<e.length;n++)(a=e[n])>=r&&a<d&&(d=a);var g=u+1;if(d-r>Co((Pm-o)/g))throw nT(tT);for(o+=(d-r)*g,r=d,n=0;n<e.length;n++){if((a=e[n])<r&&++o>Pm)throw nT(tT);if(a==r){for(var I=o,k=36;;){var w=k<=s?1:k>=s+26?26:k-s;if(I<w)break;var A=I-w,p=36-w;Di(t,Dm(aT(w+A%p))),I=Co(A/p),k+=36}Di(t,Dm(aT(I))),s=E6(o,g,u==c),o=0,u++}}o++,r++}return iT(t,"")},R6=Ue,Lm=Se,A6=Ey,Om=se,oT=Fr,jn=ke,kl=qt,Bn=function(e,t,n){return n.get&&Qk(n.get,t,{getter:!0}),n.set&&Qk(n.set,t,{setter:!0}),l6.f(e,t,n)},P6=fi,Mm=rt,Nm=ak,Ro=Zk,nr=vu,D6=gh.codeAt,L6=function(e){var t,n,a=[],i=I6(x6(w6(e),eT,"."),".");for(t=0;t<i.length;t++)n=i[t],Di(a,T6(k6,n)?"xn--"+C6(n):n);return iT(a,".")},Xr=Ft,O6=ea,M6=ku,sT=MD,cT=st,N6=cT.set,Tl=cT.getterFor("URL"),U6=sT.URLSearchParams,V6=sT.getState,gc=Om.URL,Um=Om.TypeError,xl=Om.parseInt,j6=Math.floor,uT=Math.pow,Fn=jn("".charAt),rr=jn(/./.exec),_c=jn([].join),B6=jn(1 .toString),F6=jn([].pop),Ao=jn([].push),lT=jn("".replace),G6=jn([].shift),H6=jn("".split),yc=jn("".slice),Il=jn("".toLowerCase),z6=jn([].unshift),Vm="Invalid scheme",ba="Invalid host",dT="Invalid port",hT=/[a-z]/i,W6=/[\d+-.a-z]/i,jm=/\d/,q6=/^0x/i,J6=/^[0-7]+$/,K6=/^\d+$/,pT=/^[\da-f]+$/i,X6=/[\0\t\n\r #%/:<>?@[\\\]^|]/,Q6=/[\0\t\n\r #/:<>?@[\\\]^|]/,Y6=/^[\u0000-\u0020]+|[\u0000-\u0020]+$/g,$6=/[\t\n\r]/g,bc=function(e){var t,n,a,i;if(typeof e=="number"){for(t=[],n=0;n<4;n++)z6(t,e%256),e=j6(e/256);return _c(t,".")}if(typeof e=="object"){for(t="",a=function(r){for(var o=null,s=1,c=null,u=0,d=0;d<8;d++)r[d]!==0?(u>s&&(o=c,s=u),c=null,u=0):(c===null&&(c=d),++u);return u>s&&(o=c,s=u),o}(e),n=0;n<8;n++)i&&e[n]===0||(i&&(i=!1),a===n?(t+=n?":":"::",i=!0):(t+=B6(e[n],16),n<7&&(t+=":")));return"["+t+"]"}return e},wl={},fT=Nm({},wl,{" ":1,'"':1,"<":1,">":1,"`":1}),mT=Nm({},fT,{"#":1,"?":1,"{":1,"}":1}),Bm=Nm({},mT,{"/":1,":":1,";":1,"=":1,"@":1,"[":1,"\\":1,"]":1,"^":1,"|":1}),Li=function(e,t){var n=D6(e,0);return n>32&&n<127&&!Mm(t,e)?e:encodeURIComponent(e)},El={ftp:21,file:null,http:80,https:443,ws:80,wss:443},Sc=function(e,t){var n;return e.length==2&&rr(hT,Fn(e,0))&&((n=Fn(e,1))==":"||!t&&n=="|")},vT=function(e){var t;return e.length>1&&Sc(yc(e,0,2))&&(e.length==2||(t=Fn(e,2))==="/"||t==="\\"||t==="?"||t==="#")},Z6=function(e){return e==="."||Il(e)==="%2e"},Fm={},gT={},Gm={},_T={},yT={},Hm={},bT={},ST={},Cl={},Rl={},zm={},Wm={},qm={},Jm={},kT={},Km={},Po={},xr={},TT={},Sa={},Qr={},Xm=function(e,t,n){var a,i,r,o=Xr(e);if(t){if(i=this.parse(o))throw Um(i);this.searchParams=null}else{if(n!==void 0&&(a=new Xm(n,!0)),i=this.parse(o,null,a))throw Um(i);(r=V6(new U6)).bindURL(this),this.searchParams=r}};Xm.prototype={type:"URL",parse:function(e,t,n){var a,i,r,o,s,c=this,u=t||Fm,d=0,g="",I=!1,k=!1,w=!1;for(e=Xr(e),t||(c.scheme="",c.username="",c.password="",c.host=null,c.port=null,c.path=[],c.query=null,c.fragment=null,c.cannotBeABaseURL=!1,e=lT(e,Y6,"")),e=lT(e,$6,""),a=Ro(e);d<=a.length;){switch(i=a[d],u){case Fm:if(!i||!rr(hT,i)){if(t)return Vm;u=Gm;continue}g+=Il(i),u=gT;break;case gT:if(i&&(rr(W6,i)||i=="+"||i=="-"||i=="."))g+=Il(i);else{if(i!=":"){if(t)return Vm;g="",u=Gm,d=0;continue}if(t&&(c.isSpecial()!=Mm(El,g)||g=="file"&&(c.includesCredentials()||c.port!==null)||c.scheme=="file"&&!c.host))return;if(c.scheme=g,t)return void(c.isSpecial()&&El[c.scheme]==c.port&&(c.port=null));g="",c.scheme=="file"?u=Jm:c.isSpecial()&&n&&n.scheme==c.scheme?u=_T:c.isSpecial()?u=ST:a[d+1]=="/"?(u=yT,d++):(c.cannotBeABaseURL=!0,Ao(c.path,""),u=TT)}break;case Gm:if(!n||n.cannotBeABaseURL&&i!="#")return Vm;if(n.cannotBeABaseURL&&i=="#"){c.scheme=n.scheme,c.path=nr(n.path),c.query=n.query,c.fragment="",c.cannotBeABaseURL=!0,u=Qr;break}u=n.scheme=="file"?Jm:Hm;continue;case _T:if(i!="/"||a[d+1]!="/"){u=Hm;continue}u=Cl,d++;break;case yT:if(i=="/"){u=Rl;break}u=xr;continue;case Hm:if(c.scheme=n.scheme,i==Vn)c.username=n.username,c.password=n.password,c.host=n.host,c.port=n.port,c.path=nr(n.path),c.query=n.query;else if(i=="/"||i=="\\"&&c.isSpecial())u=bT;else if(i=="?")c.username=n.username,c.password=n.password,c.host=n.host,c.port=n.port,c.path=nr(n.path),c.query="",u=Sa;else{if(i!="#"){c.username=n.username,c.password=n.password,c.host=n.host,c.port=n.port,c.path=nr(n.path),c.path.length--,u=xr;continue}c.username=n.username,c.password=n.password,c.host=n.host,c.port=n.port,c.path=nr(n.path),c.query=n.query,c.fragment="",u=Qr}break;case bT:if(!c.isSpecial()||i!="/"&&i!="\\"){if(i!="/"){c.username=n.username,c.password=n.password,c.host=n.host,c.port=n.port,u=xr;continue}u=Rl}else u=Cl;break;case ST:if(u=Cl,i!="/"||Fn(g,d+1)!="/")continue;d++;break;case Cl:if(i!="/"&&i!="\\"){u=Rl;continue}break;case Rl:if(i=="@"){I&&(g="%40"+g),I=!0,r=Ro(g);for(var A=0;A<r.length;A++){var p=r[A];if(p!=":"||w){var v=Li(p,Bm);w?c.password+=v:c.username+=v}else w=!0}g=""}else if(i==Vn||i=="/"||i=="?"||i=="#"||i=="\\"&&c.isSpecial()){if(I&&g=="")return"Invalid authority";d-=Ro(g).length+1,g="",u=zm}else g+=i;break;case zm:case Wm:if(t&&c.scheme=="file"){u=Km;continue}if(i!=":"||k){if(i==Vn||i=="/"||i=="?"||i=="#"||i=="\\"&&c.isSpecial()){if(c.isSpecial()&&g=="")return ba;if(t&&g==""&&(c.includesCredentials()||c.port!==null))return;if(o=c.parseHost(g))return o;if(g="",u=Po,t)return;continue}i=="["?k=!0:i=="]"&&(k=!1),g+=i}else{if(g=="")return ba;if(o=c.parseHost(g))return o;if(g="",u=qm,t==Wm)return}break;case qm:if(!rr(jm,i)){if(i==Vn||i=="/"||i=="?"||i=="#"||i=="\\"&&c.isSpecial()||t){if(g!=""){var y=xl(g,10);if(y>65535)return dT;c.port=c.isSpecial()&&y===El[c.scheme]?null:y,g=""}if(t)return;u=Po;continue}return dT}g+=i;break;case Jm:if(c.scheme="file",i=="/"||i=="\\")u=kT;else{if(!n||n.scheme!="file"){u=xr;continue}if(i==Vn)c.host=n.host,c.path=nr(n.path),c.query=n.query;else if(i=="?")c.host=n.host,c.path=nr(n.path),c.query="",u=Sa;else{if(i!="#"){vT(_c(nr(a,d),""))||(c.host=n.host,c.path=nr(n.path),c.shortenPath()),u=xr;continue}c.host=n.host,c.path=nr(n.path),c.query=n.query,c.fragment="",u=Qr}}break;case kT:if(i=="/"||i=="\\"){u=Km;break}n&&n.scheme=="file"&&!vT(_c(nr(a,d),""))&&(Sc(n.path[0],!0)?Ao(c.path,n.path[0]):c.host=n.host),u=xr;continue;case Km:if(i==Vn||i=="/"||i=="\\"||i=="?"||i=="#"){if(!t&&Sc(g))u=xr;else if(g==""){if(c.host="",t)return;u=Po}else{if(o=c.parseHost(g))return o;if(c.host=="localhost"&&(c.host=""),t)return;g="",u=Po}continue}g+=i;break;case Po:if(c.isSpecial()){if(u=xr,i!="/"&&i!="\\")continue}else if(t||i!="?")if(t||i!="#"){if(i!=Vn&&(u=xr,i!="/"))continue}else c.fragment="",u=Qr;else c.query="",u=Sa;break;case xr:if(i==Vn||i=="/"||i=="\\"&&c.isSpecial()||!t&&(i=="?"||i=="#")){if((s=Il(s=g))===".."||s==="%2e."||s===".%2e"||s==="%2e%2e"?(c.shortenPath(),i=="/"||i=="\\"&&c.isSpecial()||Ao(c.path,"")):Z6(g)?i=="/"||i=="\\"&&c.isSpecial()||Ao(c.path,""):(c.scheme=="file"&&!c.path.length&&Sc(g)&&(c.host&&(c.host=""),g=Fn(g,0)+":"),Ao(c.path,g)),g="",c.scheme=="file"&&(i==Vn||i=="?"||i=="#"))for(;c.path.length>1&&c.path[0]==="";)G6(c.path);i=="?"?(c.query="",u=Sa):i=="#"&&(c.fragment="",u=Qr)}else g+=Li(i,mT);break;case TT:i=="?"?(c.query="",u=Sa):i=="#"?(c.fragment="",u=Qr):i!=Vn&&(c.path[0]+=Li(i,wl));break;case Sa:t||i!="#"?i!=Vn&&(i=="'"&&c.isSpecial()?c.query+="%27":c.query+=i=="#"?"%23":Li(i,wl)):(c.fragment="",u=Qr);break;case Qr:i!=Vn&&(c.fragment+=Li(i,fT))}d++}},parseHost:function(e){var t,n,a;if(Fn(e,0)=="["){if(Fn(e,e.length-1)!="]"||(t=function(i){var r,o,s,c,u,d,g,I=[0,0,0,0,0,0,0,0],k=0,w=null,A=0,p=function(){return Fn(i,A)};if(p()==":"){if(Fn(i,1)!=":")return;A+=2,w=++k}for(;p();){if(k==8)return;if(p()!=":"){for(r=o=0;o<4&&rr(pT,p());)r=16*r+xl(p(),16),A++,o++;if(p()=="."){if(o==0||(A-=o,k>6))return;for(s=0;p();){if(c=null,s>0){if(!(p()=="."&&s<4))return;A++}if(!rr(jm,p()))return;for(;rr(jm,p());){if(u=xl(p(),10),c===null)c=u;else{if(c==0)return;c=10*c+u}if(c>255)return;A++}I[k]=256*I[k]+c,++s!=2&&s!=4||k++}if(s!=4)return;break}if(p()==":"){if(A++,!p())return}else if(p())return;I[k++]=r}else{if(w!==null)return;A++,w=++k}}if(w!==null)for(d=k-w,k=7;k!=0&&d>0;)g=I[k],I[k--]=I[w+d-1],I[w+--d]=g;else if(k!=8)return;return I}(yc(e,1,-1)),!t))return ba;this.host=t}else if(this.isSpecial()){if(e=L6(e),rr(X6,e)||(t=function(i){var r,o,s,c,u,d,g,I=H6(i,".");if(I.length&&I[I.length-1]==""&&I.length--,(r=I.length)>4)return i;for(o=[],s=0;s<r;s++){if((c=I[s])=="")return i;if(u=10,c.length>1&&Fn(c,0)=="0"&&(u=rr(q6,c)?16:8,c=yc(c,u==8?1:2)),c==="")d=0;else{if(!rr(u==10?K6:u==8?J6:pT,c))return i;d=xl(c,u)}Ao(o,d)}for(s=0;s<r;s++)if(d=o[s],s==r-1){if(d>=uT(256,5-r))return null}else if(d>255)return null;for(g=F6(o),s=0;s<o.length;s++)g+=o[s]*uT(256,3-s);return g}(e),t===null))return ba;this.host=t}else{if(rr(Q6,e))return ba;for(t="",n=Ro(e),a=0;a<n.length;a++)t+=Li(n[a],wl);this.host=t}},cannotHaveUsernamePasswordPort:function(){return!this.host||this.cannotBeABaseURL||this.scheme=="file"},includesCredentials:function(){return this.username!=""||this.password!=""},isSpecial:function(){return Mm(El,this.scheme)},shortenPath:function(){var e=this.path,t=e.length;!t||this.scheme=="file"&&t==1&&Sc(e[0],!0)||e.length--},serialize:function(){var e=this,t=e.scheme,n=e.username,a=e.password,i=e.host,r=e.port,o=e.path,s=e.query,c=e.fragment,u=t+":";return i!==null?(u+="//",e.includesCredentials()&&(u+=n+(a?":"+a:"")+"@"),u+=bc(i),r!==null&&(u+=":"+r)):t=="file"&&(u+="//"),u+=e.cannotBeABaseURL?o[0]:o.length?"/"+_c(o,"/"):"",s!==null&&(u+="?"+s),c!==null&&(u+="#"+c),u},setHref:function(e){var t=this.parse(e);if(t)throw Um(t);this.searchParams.update()},getOrigin:function(){var e=this.scheme,t=this.port;if(e=="blob")try{return new Do(e.path[0]).origin}catch(n){return"null"}return e!="file"&&this.isSpecial()?e+"://"+bc(this.host)+(t!==null?":"+t:""):"null"},getProtocol:function(){return this.scheme+":"},setProtocol:function(e){this.parse(Xr(e)+":",Fm)},getUsername:function(){return this.username},setUsername:function(e){var t=Ro(Xr(e));if(!this.cannotHaveUsernamePasswordPort()){this.username="";for(var n=0;n<t.length;n++)this.username+=Li(t[n],Bm)}},getPassword:function(){return this.password},setPassword:function(e){var t=Ro(Xr(e));if(!this.cannotHaveUsernamePasswordPort()){this.password="";for(var n=0;n<t.length;n++)this.password+=Li(t[n],Bm)}},getHost:function(){var e=this.host,t=this.port;return e===null?"":t===null?bc(e):bc(e)+":"+t},setHost:function(e){this.cannotBeABaseURL||this.parse(e,zm)},getHostname:function(){var e=this.host;return e===null?"":bc(e)},setHostname:function(e){this.cannotBeABaseURL||this.parse(e,Wm)},getPort:function(){var e=this.port;return e===null?"":Xr(e)},setPort:function(e){this.cannotHaveUsernamePasswordPort()||((e=Xr(e))==""?this.port=null:this.parse(e,qm))},getPathname:function(){var e=this.path;return this.cannotBeABaseURL?e[0]:e.length?"/"+_c(e,"/"):""},setPathname:function(e){this.cannotBeABaseURL||(this.path=[],this.parse(e,Po))},getSearch:function(){var e=this.query;return e?"?"+e:""},setSearch:function(e){(e=Xr(e))==""?this.query=null:(Fn(e,0)=="?"&&(e=yc(e,1)),this.query="",this.parse(e,Sa)),this.searchParams.update()},getSearchParams:function(){return this.searchParams.facade},getHash:function(){var e=this.fragment;return e?"#"+e:""},setHash:function(e){(e=Xr(e))!=""?(Fn(e,0)=="#"&&(e=yc(e,1)),this.fragment="",this.parse(e,Qr)):this.fragment=null},update:function(){this.query=this.searchParams.serialize()||null}};var Do=function(e){var t=P6(this,dn),n=M6(arguments.length,1)>1?arguments[1]:void 0,a=N6(t,new Xm(e,!1,n));Lm||(t.href=a.serialize(),t.origin=a.getOrigin(),t.protocol=a.getProtocol(),t.username=a.getUsername(),t.password=a.getPassword(),t.host=a.getHost(),t.hostname=a.getHostname(),t.port=a.getPort(),t.pathname=a.getPathname(),t.search=a.getSearch(),t.searchParams=a.getSearchParams(),t.hash=a.getHash())},dn=Do.prototype,Gn=function(e,t){return{get:function(){return Tl(this)[e]()},set:t&&function(n){return Tl(this)[t](n)},configurable:!0,enumerable:!0}};if(Lm&&(Bn(dn,"href",Gn("serialize","setHref")),Bn(dn,"origin",Gn("getOrigin")),Bn(dn,"protocol",Gn("getProtocol","setProtocol")),Bn(dn,"username",Gn("getUsername","setUsername")),Bn(dn,"password",Gn("getPassword","setPassword")),Bn(dn,"host",Gn("getHost","setHost")),Bn(dn,"hostname",Gn("getHostname","setHostname")),Bn(dn,"port",Gn("getPort","setPort")),Bn(dn,"pathname",Gn("getPathname","setPathname")),Bn(dn,"search",Gn("getSearch","setSearch")),Bn(dn,"searchParams",Gn("getSearchParams")),Bn(dn,"hash",Gn("getHash","setHash"))),kl(dn,"toJSON",function(){return Tl(this).serialize()},{enumerable:!0}),kl(dn,"toString",function(){return Tl(this).serialize()},{enumerable:!0}),gc){var xT=gc.createObjectURL,IT=gc.revokeObjectURL;xT&&kl(Do,"createObjectURL",oT(xT,gc)),IT&&kl(Do,"revokeObjectURL",oT(IT,gc))}O6(Do,"URL"),R6({global:!0,constructor:!0,forced:!A6,sham:!Lm},{URL:Do});var ka,Al,e5=new Blob(["class VolumeMeter extends AudioWorkletProcessor{constructor(){super();this.volume=0;this.intervalTime=200;this.tick=this.intervalTime;this.isStop=false;this.port.onmessage=event=>{const{data}=event;switch(data.name){case'setIntervalTime':this.intervalTime=data.intervalTime;break;case'stop':this.isStop=true;break}}}process(inputs){const input=inputs[0];if(this.isStop){return false}if(input.length>0){const firstChannel=input[0];let sum=0;let rms;for(let i=0;i<firstChannel.length;++i){sum+=firstChannel[i]*firstChannel[i]}rms=Math.sqrt(sum/firstChannel.length);this.volume=Math.max(rms,this.volume*0.95);this.tick-=firstChannel.length;if(this.tick<0){this.tick+=(this.intervalTime/1000)*sampleRate;this.port.postMessage({volume:this.volume})}}return true}}registerProcessor('volume-meter',VolumeMeter);"],{type:"application/javascript"}),wT=!1,t5=function(){function e(n){K(this,e),this.context_=n.context,this.addModuleToContext()}var t;return we(e,[{key:"addModuleToContext",value:(t=G(m().mark(function n(){return m().wrap(function(a){for(;;)switch(a.prev=a.next){case 0:return a.prev=0,a.next=3,this.context_.audioWorklet.addModule(URL.createObjectURL(e5));case 3:_e.info("worklet addModule success"),X.emit(Zf),wT=!0,a.next=12;break;case 8:a.prev=8,a.t0=a.catch(0),_e.info("worklet addModule catch error. ".concat(a.t0.message)),X.emit(em);case 12:case"end":return a.stop()}},n,this,[[0,8]])})),function(){return t.apply(this,arguments)})},{key:"initWorkletSuccess",get:function(){return wT}}]),e}(),kc=0,n5=function(){function e(t){K(this,e);var n=t.track,a=t.log,i=t.stream;this.volume_=0,this.log_=a,this.track_=n,this.stream_=i,kc+=1,ka||(ka=GS()),this.audioCtx_=ka,this.destination_=this.audioCtx_.destination;var r=new MediaStream;r.addTrack(this.track_),this.streamSource_=this.audioCtx_.createMediaStreamSource(r),this.audioWorkletNode_=null,this.scriptProcessorNode_=null,this.interval_=200,X.on(lc,this.resume,this),X.on(Uf,this.handleAudioLevelInterval,this),U4?(X.on(Zf,this.initAudioWorklet,this),X.on(em,this.initScriptProcessor,this),this.preload()):this.initScriptProcessor()}return we(e,[{key:"preload",value:function(){Al?Al.initWorkletSuccess&&this.initAudioWorklet():Al=new t5({context:ka})}},{key:"initAudioWorklet",value:function(){var t=this;if(!this.audioWorkletNode_)try{this.audioWorkletNode_=new AudioWorkletNode(this.audioCtx_,"volume-meter"),this.audioWorkletNode_.port.onmessage=function(n){t.volume_=n.data.volume||0},this.streamSource_.connect(this.audioWorkletNode_).connect(this.destination_),this.handleAudioLevelInterval({interval:this.interval_})}catch(n){this.log_.warn("load volume meter failed, load again. error: "+n),this.initScriptProcessor()}}},{key:"initScriptProcessor",value:function(){var t=this;if(!this.scriptProcessorNode_)try{this.scriptProcessorNode_=this.audioCtx_.createScriptProcessor(2048,1,1),this.scriptProcessorNode_.onaudioprocess=function(n){for(var a=n.inputBuffer.getChannelData(0),i=0,r=0;r<a.length;++r)i+=a[r]*a[r];t.volume_=Math.sqrt(i/a.length)||0},this.streamSource_.connect(this.scriptProcessorNode_),this.scriptProcessorNode_.connect(this.destination_)}catch(n){this.log_.error("volumeMeter init script processor error: "+n),kc-=1}}},{key:"destroy",value:function(){var t;this.streamSource_&&this.streamSource_.disconnect(),this.scriptProcessorNode_&&(this.scriptProcessorNode_.onaudioprocess=null,this.scriptProcessorNode_.disconnect()),this.audioWorkletNode_&&(this.audioWorkletNode_.port.postMessage({name:"stop"}),this.audioWorkletNode_.port.onmessage=null,this.audioWorkletNode_.disconnect()),this.audioWorkletNode_=null,this.scriptProcessorNode_=null,this.audioCtx_=null,X.off(lc,this.resume,this),X.off(Uf,this.handleAudioLevelInterval,this),X.off(Zf,this.initAudioWorklet,this),X.off(em,this.initScriptProcessor,this),kc>0&&(kc-=1),kc===0&&((t=ka)===null||t===void 0||t.close(),ka=null,Al=null)}},{key:"resume",value:function(){var t;(t=ka)===null||t===void 0||t.resume()}},{key:"getInternalAudioLevel",value:function(){return this.volume_}},{key:"getCalculatedVolume",value:function(){return this.volume_.toFixed(2)}},{key:"handleAudioLevelInterval",value:function(t){var n,a=t.interval;this.interval_=a,(n=this.audioWorkletNode_)===null||n===void 0||n.port.postMessage({name:"setIntervalTime",intervalTime:a})}}]),e}(),r5=function(){function e(r){K(this,e),this.stream_=r.stream,this.userId_=r.stream.getUserId(),this.log_=this.stream_.getLogger(),this.track_=r.track,r.gainedTrack&&(this.gainedTrack_=r.gainedTrack),this.div_=r.div,this.muted_=r.muted,this.outputDeviceId_=r.outputDeviceId,this.volume_=r.volume,this.pausedRetryCount_=5,this.emitter_=new Ri,this.initializeElement(),this.state_="NONE",this.volumeMeter_=new n5({stream:this.stream_,track:this.gainedTrack_||this.track_,log:this.log_})}var t,n,a,i;return we(e,[{key:"isPlaying",get:function(){return this.state_===ho}},{key:"initializeElement",value:function(){if(this.isAudioElementInit()){var r=new MediaStream;r.addTrack(this.gainedTrack_||this.track_);var o=document.createElement(Ae);o.srcObject=r,o.muted=this.muted_,o.setAttribute("id","audio_".concat(this.stream_.getId())),o.setAttribute("autoplay","autoplay"),o.setAttribute("playsinline","playsinline"),this.div_.appendChild(o),this.element_=o}this.handleEvents()}},{key:"setMuted",value:function(r){this.element_&&(this.element_.muted=r,this.muted_=r)}},{key:"play",value:(i=G(m().mark(function r(){var o;return m().wrap(function(s){for(;;)switch(s.prev=s.next){case 0:if(!this.outputDeviceId_||!this.element_){s.next=3;break}return s.next=3,this.element_.setSinkId(this.outputDeviceId_);case 3:if(this.setVolume(this.volume_),s.prev=4,!this.element_){s.next=8;break}return s.next=8,this.element_.play();case 8:s.next=16;break;case 10:if(s.prev=10,s.t0=s.catch(4),o=ie({key:nf,data:{media:"Audio",error:s.t0}}),this.log_.warn(o),!o.includes("NotAllowedError")){s.next=16;break}throw new re({code:ee.PLAY_NOT_ALLOWED,message:o});case 16:case"end":return s.stop()}},r,this,[[4,10]])})),function(){return i.apply(this,arguments)})},{key:"handleEvents",value:function(){this.handleElementEvent=this.handleElementEvent.bind(this),this.handleTrackEvent=this.handleTrackEvent.bind(this),this.element_&&(this.element_.addEventListener(yi,this.handleElementEvent),this.element_.addEventListener(Nt,this.handleElementEvent),this.element_.addEventListener(bi,this.handleElementEvent),this.element_.addEventListener(lo,this.handleElementEvent)),this.track_.addEventListener(Nt,this.handleTrackEvent),this.track_.addEventListener(Zt,this.handleTrackEvent),this.track_.addEventListener(_r,this.handleTrackEvent),this.track_.readyState===Nt&&this.handleTrackEvent({type:Nt}),this.track_.muted&&this.handleTrackEvent({type:Zt})}},{key:"handleElementEvent",value:(a=G(m().mark(function r(o){var s,c,u,d,g,I,k,w=this;return m().wrap(function(A){for(;;)switch(A.prev=A.next){case 0:s=o.type,A.t0=s,A.next=A.t0===yi?4:A.t0===Nt?9:A.t0===bi?12:A.t0===lo?21:32;break;case 4:return this.log_.info("audio player is playing"),this.state_=ho,X.emit(jf,{stream:this.stream_}),this.emitter_.emit(bn,{state:this.state_,reason:yi}),A.abrupt("break",32);case 9:return this.log_.info("audio player is ended"),this.state_!==Si&&(this.state_=Si,this.emitter_.emit(bn,{state:this.state_,reason:Nt})),A.abrupt("break",32);case 12:return this.log_.info("audio player is paused"),this.state_=yr,this.emitter_.emit(bn,{state:this.state_,reason:bi}),(c=this.div_&&document.getElementById(this.div_.id))||this.log_.warn("audio player has been remove, element ID: ".concat(this.div_.id)),u=go(),this.pausedRetryCount_>0&&(Zn(u)&&u<=70||!c)&&(this.resume(),this.pausedRetryCount_--),Ii&&(this.interval_=_t.run(function(){w.element_&&w.state_===yr&&w.resume()},{delay:3e3})),A.abrupt("break",32);case 21:if(!this.element_||!this.element_.error){A.next=31;break}return d="".concat(xm(),"/").concat(fa().name,"/").concat(fa().version),A.next=25,Tt.getSpeakers();case 25:g=A.sent,I=g[0].label,(k=g.find(function(p){return p.deviceId===w.outputDeviceId_}))&&(I=k.label),this.log_.error("audio player error observed. code: ".concat(this.element_.error.code," message: ").concat(this.element_.error.message," deviceInfo: ").concat(d," speaker: ").concat(I)),Ie.uploadEvent({log:"stat-".concat(this.stream_.getType(),"-audio-").concat(Hb,"-").concat(this.element_.error.code,"-").concat(d,"-").concat(I),userId:this.userId_,error:this.element_.error});case 31:return A.abrupt("break",32);case 32:case"end":return A.stop()}},r,this)})),function(r){return a.apply(this,arguments)})},{key:"handleTrackEvent",value:function(r){var o=r.type;switch(o){case Nt:this.log_.info("audio track is ended"),this.state_!==Si&&(this.state_=Si,this.emitter_.emit(bn,{state:this.state_,reason:Nt})),X.emit(Qf,{stream:this.stream_,type:o});break;case Zt:this.log_.info("audio track is unable to provide media output"),this.stream_.isRemote()||FS(),this.state_!==yr&&(this.state_=yr,this.emitter_.emit(bn,{state:this.state_,reason:Zt})),X.emit(Xf,{stream:this.stream_,type:o});break;case _r:this.log_.info("audio track is able to provide media output"),this.state_===yr&&(this.state_=ho,this.emitter_.emit(bn,{state:this.state_,reason:_r}))}}},{key:"unbindEvents",value:function(){this.element_&&(this.element_.removeEventListener(yi,this.handleElementEvent),this.element_.removeEventListener(Nt,this.handleElementEvent),this.element_.removeEventListener(bi,this.handleElementEvent),this.element_.removeEventListener(lo,this.handleElementEvent)),this.track_&&(this.track_.removeEventListener(Nt,this.handleTrackEvent),this.track_.removeEventListener(Zt,this.handleTrackEvent),this.track_.removeEventListener(_r,this.handleTrackEvent))}},{key:"setSinkId",value:(n=G(m().mark(function r(o){return m().wrap(function(s){for(;;)switch(s.prev=s.next){case 0:if(this.outputDeviceId_===o){s.next=5;break}if(!this.element_){s.next=4;break}return s.next=4,this.element_.setSinkId(o);case 4:this.outputDeviceId_=o;case 5:case"end":return s.stop()}},r,this)})),function(r){return n.apply(this,arguments)})},{key:"setVolume",value:function(r){this.element_&&(this.log_.info("audioElement setVolume to : ".concat(r)),this.element_.volume=r)}},{key:"getAudioLevel",value:function(){return this.volumeMeter_.getCalculatedVolume()}},{key:"getInternalAudioLevel",value:function(){return this.volumeMeter_.getInternalAudioLevel()}},{key:"stop",value:function(){this.unbindEvents(),this.element_&&(this.div_.removeChild(this.element_),this.element_.srcObject=null,this.element_=null),this.volumeMeter_&&(this.volumeMeter_.destroy(),this.volumeMeter_=null),this.interval_>0&&_t.clearTask(this.interval_)}},{key:"resume",value:(t=G(m().mark(function r(){var o;return m().wrap(function(s){for(;;)switch(s.prev=s.next){case 0:if(s.prev=0,this.volumeMeter_&&this.volumeMeter_.resume(),!this.element_){s.next=5;break}return s.next=5,this.element_.play();case 5:s.next=13;break;case 7:if(s.prev=7,s.t0=s.catch(0),o=ie({key:nf,data:{media:"Audio",error:s.t0}}),this.log_.warn(o),!o.includes("NotAllowedError")){s.next=13;break}throw new re({code:ee.PLAY_NOT_ALLOWED,message:o});case 13:case"end":return s.stop()}},r,this,[[0,7]])})),function(){return t.apply(this,arguments)})},{key:"on",value:function(r,o){this.emitter_.on(r,o)}},{key:"isAudioElementInit",value:function(){return!(wi==="15.2"||wi==="15.3"||wi==="15.4")||this.stream_.getType()!=="local"||!this.muted_||(this.log_.info("audioElement is muted."),!1)}}]),e}(),i5=Ur.PROPER,a5=ce,ET=l0,o5=Ou.trim;Ue({target:"String",proto:!0,forced:function(e){return a5(function(){return!!ET[e]()||"\u200B\x85\u180E"[e]()!=="\u200B\x85\u180E"||i5&&ET[e].name!==e})}("trim")},{trim:function(){return o5(this)}});var Yr="trtc_autoplay",Qm="".concat(Yr,"_mask"),Lo="".concat(Yr,"_wrapper"),CT="".concat(Yr,"_header"),Ym="".concat(Yr,"_content"),Pl="".concat(Yr,"_action_wrapper"),$m="".concat(Yr,"_question"),Zm="".concat(Yr,"_collapse"),Dl="".concat(Yr,"_action_confirm"),RT="".concat(Yr,"_detail"),AT="#2473E8",ev="dialog",s5="".concat(ev,"-show"),c5="".concat(ev,"-1"),u5="".concat(ev,"-2"),PT=!1,DT=function(){return!!document.querySelector(".".concat(Lo))},LT="".concat(mo,"/").concat(ma()?"zh-cn":"en","/tutorial-21-advanced-auto-play-policy.html"),OT="<br><a href='".concat(LT,"' target='_blank'>").concat(ma()?"\u5176\u4ED6\u65B9\u6848\uFF1F":"Any other solution?","</a>"),l5="".concat(ma()?"\u6D4F\u89C8\u5668\u81EA\u52A8\u64AD\u653E\u7B56\u7565\uFF1A\u5728\u7528\u6237\u4E0E\u9875\u9762\u4EA7\u751F\u4EA4\u4E92\uFF08\u70B9\u51FB\u3001\u89E6\u6478\uFF09\u4E4B\u524D\uFF0C\u6D4F\u89C8\u5668\u7981\u6B62\u64AD\u653E\u6709\u58F0\u5A92\u4F53\u3002\u8BE5\u5F39\u7A97\u7528\u4E8E\u5E2E\u52A9\u7528\u6237\u6062\u590D\u97F3\u89C6\u9891\u64AD\u653E\u3002".concat(OT):"Autoplay Policy: Before user interacts with the web page (clicking, touching), page will not be allowed to play media with sound. This Dialog is used to help users resume playback. ".concat(OT)),MT=function(){function e(){if(K(this,e),this.dialogNode_=null,this.bodyPosition_="",this.content="\u97F3\u89C6\u9891\u64AD\u653E\u88AB\u6D4F\u89C8\u5668\u62E6\u622A\uFF0C\u8BF7\u70B9\u51FB\u201C\u6062\u590D\u64AD\u653E\u201D\u3002",ma()||(this.content='Media playback failed. Click the "Resume" to resume playback.'),!PT){var t=document.createElement("style");t.innerHTML=".".concat(Qm,"{position:fixed;top:0;left:0;right:0;bottom:0;width:100vw;height:100vh;display:flex;justify-content:center;align-items:center;background:rgba(0,0,0,0.5);z-index:1500;}.").concat(Qm," div:not(.").concat(Pl,"){display:block !important;}.").concat(Lo,"{padding:14px;background:#fff;border-radius:3px;box-shadow:0px 3px 15px #434343;border:1px solid #d1cfcf;max-width:500px;}.").concat(Lo," a{color:").concat(AT,";}.").concat(CT,"{overflow:hidden;text-overflow:ellipsis;font-size:16px;font-weight:600;}.").concat(Ym,"{margin:8px 0;}.").concat(Pl,"{width:100%;display:flex !important;align-items:center;justify-content:right;float:right;}.").concat(Zm,"{margin-right:auto;cursor:pointer}.").concat($m,"{height:100%;line-height:16px;cursor:pointer;}.").concat(Dl,"{margin-left:8px;color:#fff;background:").concat(AT,";padding:4px 12px;outline:none;border:1px solid;border-radius:3px;font-weight:bold;}.").concat(Dl,":hover{opacity:0.9;}.").concat(Zm,",.").concat(Dl,",.").concat(Ym,",.").concat($m,"{font-size:14px;}@media screen and (max-width:750px){.").concat(Lo,"{width:80vw;}}"),document.head.appendChild(t),PT=!0}this.showDetail_=!1,this.isCollapseClicked_=!1,this.isQuestionClicked_=!1,this.addDiaLog()}return we(e,[{key:"createDiaLog",value:function(){var t=document.createElement("template");t.innerHTML='<div class="'.concat(Qm,`"><div class='`).concat(Lo,"'><div class='").concat(CT,"'>").concat(location.host,"</div><div class='").concat(Ym,"'>").concat(this.content,"</div><div class='").concat(RT,`' style="visibility:hidden;width:100%;height:0;font-size:12px;color:gray;">`).concat(l5,"</div><div class='").concat(Pl,"'></div></div></div>").trim();var n=document.createElement("button");n.className=Dl,n.innerText=ma()?"\u6062\u590D\u64AD\u653E":"Resume",n.onclick=this.onConfirm.bind(this);var a=document.createElement("div");a.className=$m,a.innerHTML=`<?xml version="1.0" encoding="UTF-8"?>
|
|
56
|
+
`};rr.write=zV,rr.parse=ua.parse,rr.parseParams=ua.parseParams,rr.parseFmtpConfig=ua.parseFmtpConfig,rr.parsePayloads=ua.parsePayloads,rr.parseRemoteCandidates=ua.parseRemoteCandidates,rr.parseImageAttributes=ua.parseImageAttributes,rr.parseSimulcastStreamList=ua.parseSimulcastStreamList;var mm,vm,gm,_m,Fr=function(e){return rr.parse(e)},yo=function(e){return rr.write(e)},WV=function(e){var t=Fr(e);return t.media.forEach(function(n){n.type===Ee&&n.fmtp.forEach(function(i){i.config+=";sprop-stereo=1;stereo=1"})}),yo(t)},Lk=((mm=window)===null||mm===void 0?void 0:mm.requestIdleCallback)||function(e){var t=Date.now();return setTimeout(function(){e({didTimeout:!1,timeRemaining:function(){return Math.max(0,50-(Date.now()-t))}})},1e3)},JV=((vm=window)===null||vm===void 0?void 0:vm.cancelIdleCallback)||function(e){clearTimeout(e)},qV=((gm=window)===null||gm===void 0?void 0:gm.cancelAnimationFrame)||((_m=window)===null||_m===void 0?void 0:_m.mozCancelAnimationFrame),mt=function(){function e(){Q(this,e)}return Ie(e,null,[{key:"generateTaskID",value:function(){return this.currentTaskID++}},{key:"run",value:function(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:nS,n=arguments.length>1?arguments[1]:void 0,i=arguments.length>2?arguments[2]:void 0;i=q(q({},t===fN?{delay:2e3,count:0,backgroundTask:!0}:t===uo?{delay:1e4,count:0}:t===Qu?{fps:60,delay:16.6,count:0,backgroundTask:!0}:{delay:2e3,count:0,backgroundTask:!0}),i),US(n)&&(i=q(q({},i),n)),ln(t)&&(n=t,t=nS);var r=q({taskID:this.generateTaskID(),loopCount:0,intervalID:null,timeoutID:null,rafID:null,ricID:null,taskName:t,callback:n},i);return this.taskMap.set(r.taskID,r),this[t](r),r.taskID}},{key:"interval",value:function(t){var n=this;return t.intervalID=setInterval(function(){t.callback(),t.loopCount+=1,n.isBreakLoop(t)},t.delay)}},{key:"timeout",value:function(t){var n=this;return t.timeoutID=setTimeout(function i(){if(t.callback(),t.loopCount+=1,!n.isBreakLoop(t))return t.timeoutID=setTimeout(i,t.delay)},t.delay)}},{key:"ric",value:function(t){var n,i=this,r=Ct();return t.ricID=Lk(function o(){if((n=Ct()-r)>=t.delay&&(r=Ct()-Math.floor(n%t.delay),t.callback(),t.loopCount+=1),!i.isBreakLoop(t))return t.ricID=Lk(o,{timeout:t.delay})},{timeout:t.delay})}},{key:"raf",value:function(t){var n=this;t.delay=(1e3/t.fps).toFixed(2);var i,r=Ct(),o=function a(){if(document.hidden&&t.backgroundTask)return i=Ct()-r,r=Ct(),t.callback(),t.loopCount+=1,n.isBreakLoop(t)?void 0:t.timeoutID=setTimeout(a,t.delay-Math.floor(i%t.delay));if((i=Ct()-r)>=t.delay&&(r=Ct()-Math.floor(i%t.delay),t.callback(),t.loopCount+=1),!n.isBreakLoop(t))return t.rafID=requestAnimationFrame(a)};if(t.rafID=requestAnimationFrame(o),t.backgroundTask){var c=function(){if(document.hidden){var a=Ct()-r;a>=t.delay?o():t.timeoutID=setTimeout(o,t.delay-a)}};document.addEventListener("visibilitychange",c),t.onVisibilitychange=c,document.hidden&&c()}return t.taskID}},{key:"hasTask",value:function(t){return this.taskMap.has(t)}},{key:"clearTask",value:function(t){if(!this.taskMap.has(t))return!0;var n=this.taskMap.get(t),i=n.intervalID,r=n.timeoutID,o=n.rafID,c=n.ricID,a=n.onVisibilitychange;return i&&clearInterval(i),r&&clearTimeout(r),o&&qV(o),c&&JV(c),a&&document.removeEventListener("visibilitychange",a),this.taskMap.delete(t),!0}},{key:"isBreakLoop",value:function(t){return!this.taskMap.has(t.taskID)||t.count!==0&&t.loopCount>=t.count&&(this.clearTask(t.taskID),!0)}}]),e}();$e(mt,"taskMap",new Map),$e(mt,"currentTaskID",1);var KV=function(){function e(){Q(this,e),this.prefix_="TRTC",this.queue_=new Map,this.checkStorage()}return Ie(e,[{key:"getRealKey",value:function(t){return"".concat(this.prefix_,"_").concat(t)}},{key:"checkStorage",value:function(){var t=this;if(ia()){var n=Object.keys(localStorage).filter(function(i){if(i.startsWith(t.prefix_)){var r=JSON.parse(localStorage.getItem(i));if(r&&r.expiresIn<Date.now())return!0}return!1});n.forEach(function(i){return localStorage.removeItem(i)})}}},{key:"doFlush",value:function(){if(ia())try{var t,n=oe(this.queue_);try{for(n.s();!(t=n.n()).done;){var i=Te(t.value,2),r=i[0],o=i[1];localStorage.setItem(r,JSON.stringify(o))}}catch(c){n.e(c)}finally{n.f()}}catch(c){_e.warn(c)}}},{key:"getItem",value:function(t){if(!ia())return null;try{var n=JSON.parse(localStorage.getItem(this.getRealKey(t)));return n&&n.expiresIn>=Date.now()?n.value:null}catch(i){_e.warn(i)}}},{key:"setItem",value:function(t,n){var i=arguments.length>2&&arguments[2]!==void 0&&arguments[2];if(ia())try{var r={expiresIn:Date.now()+Kb,value:n};i?localStorage.setItem(this.getRealKey(t),JSON.stringify(r)):(this.queue_.set(this.getRealKey(t),r),mt.hasTask(this.intervalId_)||(this.intervalId_=mt.run(uo,this.doFlush.bind(this),{count:1})))}catch(o){_e.warn(o)}}},{key:"deleteItem",value:function(t){if(!ia())return!1;try{return t=this.getRealKey(t),this.queue_.delete(t),localStorage.removeItem(t),!0}catch(n){return _e.warn(n),!1}}},{key:"clear",value:function(){if(ia())try{localStorage.clear()}catch(t){_e.warn(t)}}}]),e}(),bo=new KV,_t={result:!1,detail:{isBrowserSupported:!1,isWebRTCSupported:!1,isMediaDevicesSupported:!1,isH264EncodeSupported:!1,isVp8EncodeSupported:!1,isH264DecodeSupported:!1,isVp8DecodeSupported:!1}},Mk="checkResult",Nk=function(){return!y4&&!$u&&!(Zu&&ES<80)&&!(Vn&&CS<56)},ym=function(){return["RTCPeerConnection","webkitRTCPeerConnection","RTCIceGatherer"].filter(function(e){return e in window}).length>0},XV=function(){if(!navigator.mediaDevices)return!1;var e=["getUserMedia","enumerateDevices"];return e.filter(function(t){return t in navigator.mediaDevices}).length===e.length},Uk=function(){var e=H(p().mark(function t(){var n,i,r,o,c,a;return p().wrap(function(s){for(;;)switch(s.prev=s.next){case 0:if(!_t.detail.isH264EncodeSupported||!_t.detail.isVp8EncodeSupported){s.next=2;break}return s.abrupt("return",{isH264EncodeSupported:_t.detail.isH264EncodeSupported,isVp8EncodeSupported:_t.detail.isVp8EncodeSupported});case 2:return n="",i=!1,r=!1,s.prev=5,o=new RTCPeerConnection,(c=document.createElement(hb)).getContext("2d"),a=c.captureStream(0),o.addTrack(a.getVideoTracks()[0],a),s.next=13,o.createOffer();case 13:return(n=s.sent).sdp.toLowerCase().indexOf("h264")!==-1&&(i=!0),n.sdp.toLowerCase().indexOf("vp8")!==-1&&(r=!0),o.close(),_t.detail.isH264EncodeSupported=i,_t.detail.isVp8EncodeSupported=r,s.abrupt("return",{isH264EncodeSupported:_t.detail.isH264EncodeSupported,isVp8EncodeSupported:_t.detail.isVp8EncodeSupported});case 22:return s.prev=22,s.t0=s.catch(5),s.abrupt("return",{isH264EncodeSupported:!1,isVp8EncodeSupported:!1});case 25:case"end":return s.stop()}},t,null,[[5,22]])}));return function(){return e.apply(this,arguments)}}();function QV(){return bm.apply(this,arguments)}function bm(){return bm=H(p().mark(function e(){return p().wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",new Promise(function(){var n=H(p().mark(function i(r){var o,c,a,s,l,u,f,S,x,E,I,m,T,v;return p().wrap(function(w){for(;;)switch(w.prev=w.next){case 0:return o={encode:!1,decode:!1},c=null,w.prev=2,a=document.createElement("canvas"),s=a.getContext("2d"),a.width=640,a.height=480,l=setInterval(function(){s.fillText("test",Math.floor(640*Math.random()),Math.floor(480*Math.random()))},33),u=-1,f=-1,c=function(){clearInterval(u),clearInterval(l),clearTimeout(f),x.close(),E.close(),S.getTracks().forEach(function(L){return L.stop()})},f=setTimeout(function(){c(),r(o)},3e3),S=a.captureStream(),x=new RTCPeerConnection({}),E=new RTCPeerConnection({offerToReceiveAudio:!0,offerToReceiveVideo:!0}),x.addEventListener("icecandidate",function(L){return E.addIceCandidate(L.candidate)}),E.addEventListener("icecandidate",function(L){return x.addIceCandidate(L.candidate)}),x.addTrack(S.getVideoTracks()[0],S),w.next=20,x.createOffer();case 20:return I=w.sent,w.next=23,x.setLocalDescription(I);case 23:return w.next=25,E.setRemoteDescription(I);case 25:return w.next=27,E.createAnswer();case 27:return m=w.sent,T=Fr(m.sdp),v=T.media[0].rtp.findIndex(function(L){return L.codec==="H264"}),T.media[0].rtp=[T.media[0].rtp[v]],T.media[0].fmtp=T.media[0].fmtp.filter(function(L){return L.payload===T.media[0].rtp[0].payload}),T.media[0].rtcpFb=T.media[0].rtcpFb.filter(function(L){return L.payload===T.media[0].rtp[0].payload}),m.sdp=yo(T),w.next=36,E.setLocalDescription(m);case 36:return w.next=38,x.setRemoteDescription(m);case 38:u=setInterval(H(p().mark(function L(){var N,V;return p().wrap(function(_){for(;;)switch(_.prev=_.next){case 0:return o.encode&&o.decode&&(c(),r(o)),_.next=3,x.getStats();case 3:return N=_.sent,_.next=6,E.getStats();case 6:V=_.sent,o.encode||N.forEach(function(b){b.type==="outbound-rtp"&&b.mediaType===xe&&b.framesEncoded>0&&(o.encode=!0)}),o.decode||V.forEach(function(b){b.type==="inbound-rtp"&&b.mediaType===xe&&b.framesDecoded>0&&(o.decode=!0)});case 9:case"end":return _.stop()}},L)})),500),w.next=46;break;case 41:w.prev=41,w.t0=w.catch(2),c(),_e.warn(w.t0),r(o);case 46:case"end":return w.stop()}},i,null,[[2,41]])}));return function(i){return n.apply(this,arguments)}}()));case 1:case"end":return t.stop()}},e)})),bm.apply(this,arguments)}var Vk=function(){var e=H(p().mark(function t(){var n,i,r,o;return p().wrap(function(c){for(;;)switch(c.prev=c.next){case 0:if(!_t.detail.isH264DecodeSupported||!_t.detail.isVp8DecodeSupported){c.next=2;break}return c.abrupt("return",{isH264DecodeSupported:_t.detail.isH264DecodeSupported,isVp8DecodeSupported:_t.detail.isVp8DecodeSupported});case 2:return n="",i=!1,r=!1,c.prev=5,o=new RTCPeerConnection,c.next=9,o.createOffer({offerToReceiveAudio:1,offerToReceiveVideo:1});case 9:return(n=c.sent).sdp.toLowerCase().indexOf("h264")!==-1&&(i=!0),n.sdp.toLowerCase().indexOf("vp8")!==-1&&(r=!0),o.close(),c.abrupt("return",{isH264DecodeSupported:i,isVp8DecodeSupported:r});case 16:return c.prev=16,c.t0=c.catch(5),c.abrupt("return",{isH264DecodeSupported:!1,isVp8DecodeSupported:!1});case 19:case"end":return c.stop()}},t,null,[[5,16]])}));return function(){return e.apply(this,arguments)}}(),YV=function(){var e=H(p().mark(function t(){var n,i,r,o,c,a,s,l,u,f,S,x,E;return p().wrap(function(I){for(;;)switch(I.prev=I.next){case 0:if(jk()){I.next=2;break}return I.abrupt("return",_t);case 2:return n=Nk(),i=ym(),r=XV(),I.next=7,Uk();case 7:return o=I.sent,c=o.isH264EncodeSupported,a=o.isVp8EncodeSupported,I.next=12,Vk();case 12:if(s=I.sent,l=s.isH264DecodeSupported,u=s.isVp8DecodeSupported,c&&a){I.next=21;break}return I.next=18,Uk();case 18:f=I.sent,c=f.isH264EncodeSupported,a=f.isVp8EncodeSupported;case 21:if(!(c&&l&&(tl||nl||C4)&&!Nr&&lo()<79)){I.next=29;break}return I.next=24,QV();case 24:S=I.sent,x=S.encode,E=S.decode,c=x,l=E;case 29:return _t.result=n&&i&&r&&(c||a)&&(l||u),_t.detail.isBrowserSupported=n,_t.detail.isWebRTCSupported=i,_t.detail.isMediaDevicesSupported=r,_t.detail.isH264EncodeSupported=c,_t.detail.isVp8EncodeSupported=a,_t.detail.isH264DecodeSupported=l,_t.detail.isVp8DecodeSupported=u,$V(),bo.setItem(Mk,{ua:navigator.userAgent,checkResult:_t},!0),I.abrupt("return",_t);case 40:case"end":return I.stop()}},t)}));return function(){return e.apply(this,arguments)}}(),Sm=function(e,t){var n=null;return function(){if(n)return n;for(var i=arguments.length,r=new Array(i),o=0;o<i;o++)r[o]=arguments[o];return(n=e.apply(t||this,r)).then(function(c){return n=null,c}).catch(function(c){throw n=null,c}),n}}(YV);function jk(){return Object.keys(_t.detail).findIndex(function(e){return!_t.detail[e]})>=0}function $V(){jk()&&(_e.warn(ae({key:vS})),_e.info("".concat(navigator.userAgent," ").concat(JSON.stringify(_t.detail))))}function Bk(){return!(!navigator.mediaDevices||!navigator.mediaDevices.getDisplayMedia)}function Fk(){return"RTCPeerConnection"in window&&"getReceivers"in window.RTCPeerConnection.prototype}function ml(){return"RTCPeerConnection"in window&&"getSenders"in window.RTCPeerConnection.prototype}function Ti(){return"RTCPeerConnection"in window&&"getTransceivers"in window.RTCPeerConnection.prototype}function vl(){return"RTCPeerConnection"in window&&"addTransceiver"in window.RTCPeerConnection.prototype}function km(){return"RTCRtpSender"in window&&"replaceTrack"in window.RTCRtpSender.prototype}function Hk(){return"RTCRtpSender"in window&&"setParameters"in window.RTCRtpSender.prototype&&ml()}function gl(){return!!ge(navigator.mediaDevices)&&(_e.error(vi.NOT_SUPPORTED_MEDIA),!0)}function _l(){return location.protocol==="http:"&&!ra&&(_e.warn(ae({key:mS})),!0)}var Tm="RTCRtpSender"in window&&"createEncodedStreams"in window.RTCRtpSender.prototype&&lo()>=86;function xm(e){return!(e.type!=="candidate-pair"||!e.nominated||e.state!=="in-progress"&&e.state!=="succeeded")&&!(nr(e.selected)&&!e.selected)}var Gk=new Map([[ta,"Android"],[gi,"iOS"],[AS,"Windows"],[ec,"MacOS"],[PS,"Linux"]]);function Im(){var e="unknown";return Gk.get(!0)&&(e=Gk.get(!0)),e}function ZV(){var e="";return screen.width&&(e+=(screen.width?screen.width*window.devicePixelRatio:"")+" * "+(screen.height?screen.height*window.devicePixelRatio:"")),e}function e6(){var e=!1;return(navigator.getUserMedia||navigator.mediaDevices&&navigator.mediaDevices.getUserMedia)&&(e=!0),e}function t6(){for(var e={isSupported:!1},t=["AudioContext","webkitAudioContext","mozAudioContext","msAudioContext"],n=0;n<t.length;n++)if(t[n]in window){e.isSupported=!0;break}return e.isSupported}function zk(){return!(lp&&lo()<86)&&!(gi&&tr(_i)&&_i<15)&&!(bp&&bp<63)&&!(!Nk()||!("captureStream"in HTMLCanvasElement.prototype))}var la=window.MediaStreamTrack&&"getSettings"in MediaStreamTrack.prototype,n6=window.MediaStreamTrack&&"getCapabilities"in MediaStreamTrack.prototype,r6=function(){var e,t,n;return((e=window)===null||e===void 0?void 0:e.OffscreenCanvas)&&((t=window)===null||t===void 0?void 0:t.MediaStreamTrackProcessor)&&((n=window)===null||n===void 0?void 0:n.MediaStreamTrackGenerator)};(function(){_l();var e=bo.getItem(Mk);e&&e.ua===navigator.userAgent&&(_t=e.checkResult),Sm()})();var et={STREAM_ADDED:"stream-added",STREAM_REMOVED:"stream-removed",STREAM_UPDATED:"stream-updated",STREAM_PUBLISHED:"stream-published",STREAM_SUBSCRIBED:"stream-subscribed",STREAM_UNSUBSCRIBED:"stream-unsubscribed",STATE_CHANGED:"state-changed",ERROR:"error",CONNECTION_STATE_CHANGED:"connection-state-changed",SEI_MESSAGE:vb},ct={STREAM_ADDED:"stream-added",STREAM_REMOVED:"stream-removed",STREAM_UPDATED:"stream-updated",STREAM_SUBSCRIBED:"stream-subscribed",CONNECTION_STATE_CHANGED:"connection-state-changed",PEER_JOIN:"peer-join",PEER_LEAVE:"peer-leave",MUTE_AUDIO:"mute-audio",MUTE_VIDEO:"mute-video",UNMUTE_AUDIO:"unmute-audio",UNMUTE_VIDEO:"unmute-video",CLIENT_BANNED:"client-banned",NETWORK_QUALITY:"network-quality",AUDIO_VOLUME:"audio-volume",SEI_MESSAGE:vb,ERROR:"error"},Wk="player-state-changed",i6="screen-sharing-stopped",a6="connection-state-changed",o6="device-auto-recovered",wm="error",gn="player-state-changed",Jk="error",s6=aS;Le({target:"String",proto:!0,forced:oS("small")},{small:function(){return s6(this,"small","","")}});var c6=function(){function e(o){Q(this,e);var c=o.getUserId();this.log_=_e.createLogger({id:c,userId:c,sdkAppId:o.getSDKAppId()}),this.prevReportTime_=0,this.prevReport_={},this.prevEncoderImplementation_="",this.prevQualityLimitationReason_="",this.prevDecoderImplementationMap_=new Map}var t,n,i,r;return Ie(e,[{key:"statInterval",get:function(){return this.prevReportTime_===0?2:(Date.now()-this.prevReportTime_)/1e3}},{key:"getSenderStats",value:(r=H(p().mark(function o(c){var a,s,l,u,f=this;return p().wrap(function(S){for(;;)switch(S.prev=S.next){case 0:if(a={audio:{bytesSent:0,packetsSent:0,audioLevel:0,totalAudioEnergy:0},video:{bytesSent:0,packetsSent:0,framesEncoded:0,frameWidth:0,frameHeight:0,framesSent:0,fpsCapture:0},small:{bytesSent:0,packetsSent:0,framesEncoded:0,frameWidth:0,frameHeight:0,framesSent:0,fpsCapture:0},auxiliary:{bytesSent:0,packetsSent:0,framesEncoded:0,frameWidth:0,frameHeight:0,framesSent:0,fpsCapture:0},rtt:0},s=c.getPeerConnection(),l=c.getSSRC(),!s){S.next=15;break}return S.prev=4,S.next=7,s.getStats();case 7:S.sent.forEach(function(x){var E;if(x.type==="outbound-rtp")if((x.mediaType||x.kind)===xe){if(!Vn&&x.bytesSent===0)return;x.ssrc!==l.video||ge(x.encoderImplementation)||f.prevEncoderImplementation_===x.encoderImplementation||(f.log_.info("encoderImplementation change to ".concat(x.encoderImplementation)),f.prevEncoderImplementation_=x.encoderImplementation),x.ssrc!==l.video||ge(x.qualityLimitationReason)||f.prevQualityLimitationReason_===x.qualityLimitationReason||(f.log_.info("qualityLimitationReason change to ".concat(x.qualityLimitationReason)),f.prevQualityLimitationReason_=x.qualityLimitationReason);var I=xe;x.ssrc===l.small?I=Mr:x.ssrc===l.auxiliary&&(I=gt),a[I].bytesSent=x.bytesSent,a[I].packetsSent=x.packetsSent,a[I].framesEncoded=x.framesEncoded}else a.audio.bytesSent=x.bytesSent,a.audio.packetsSent=x.packetsSent;else x.type==="candidate-pair"?xm(x)&&tr(x.currentRoundTripTime)&&(a.rtt=Math.floor(1e3*x.currentRoundTripTime)):x.type==="media-source"&&(x.kind===Ee?(a.audio.audioLevel=x.audioLevel||0,a.audio.totalAudioEnergy=x.totalAudioEnergy||0):x.kind===xe&&(x.trackIdentifier===c.getVideoTrackId(xe)?a.video.fpsCapture=x.framesPerSecond:x.trackIdentifier===c.getVideoTrackId(gt)?a.auxiliary.fpsCapture=x.framesPerSecond:a.small.fpsCapture=x.framesPerSecond));ge(x.audioLevel)||(a.audio.audioLevel=x.audioLevel||0,a.audio.totalAudioEnergy=x.totalAudioEnergy||0),ge(x.frameWidth)||(x.trackIdentifier===c.getVideoTrackId(xe)||x.ssrc===l.video?E=xe:x.trackIdentifier===c.getVideoTrackId(gt)||x.ssrc===l.auxiliary?E=gt:x.trackIdentifier!==c.getVideoTrackId(Mr)&&x.ssrc!==l.small||(E=Mr),E&&(a[E].frameWidth=x.frameWidth,a[E].frameHeight=x.frameHeight,a[E].framesSent=x.framesSent))}),a.audio.audioLevel===0&&(a.audio.audioLevel=((u=c.getLocalStream())===null||u===void 0?void 0:u.getInternalAudioLevel())||0),S.next=15;break;case 12:S.prev=12,S.t0=S.catch(4),this.log_.warn("failed to getStats on sender connection "+S.t0);case 15:return S.abrupt("return",a);case 16:case"end":return S.stop()}},o,this,[[4,12]])})),function(o){return r.apply(this,arguments)})},{key:"getReceiverStats",value:(i=H(p().mark(function o(c){var a,s,l,u,f,S=this;return p().wrap(function(x){for(;;)switch(x.prev=x.next){case 0:if(a={tinyId:c.getTinyId(),userId:c.getUserId(),rtt:0,hasAudio:!1,hasVideo:!1,hasAuxiliary:!1,audio:{bytesReceived:0,packetsReceived:0,packetsLost:0,jitter:0,audioLevel:0,totalAudioEnergy:0},video:{bytesReceived:0,packetsReceived:0,packetsLost:0,framesReceived:0,framesDecoded:0,frameWidth:0,frameHeight:0},auxiliary:{bytesReceived:0,packetsReceived:0,packetsLost:0,framesReceived:0,framesDecoded:0,frameWidth:0,frameHeight:0}},!(s=c.getPeerConnection())){x.next=16;break}return x.prev=3,l=c.getSSRC(),u=c.getTrackState(),x.next=8,s.getStats();case 8:x.sent.forEach(function(E){if(E.type==="inbound-rtp")if((E.mediaType||E.kind)===Ee){if(E.ssrc!==l.audio||!u.audio)return;a.audio.packetsReceived=E.packetsReceived,a.audio.bytesReceived=E.bytesReceived,a.audio.packetsLost=E.packetsLost,a.audio.jitter=E.jitter,a.hasAudio=!0}else{if(Vn&&E.bytesReceived===0)return;E.ssrc===l.video&&u.video&&(a.video.packetsReceived=E.packetsReceived,a.video.bytesReceived=E.bytesReceived,a.video.packetsLost=E.packetsLost,a.video.framesReceived=E.framesReceived,a.video.framesDecoded=E.framesDecoded,a.video.fpsDecoded=E.framesPerSecond,a.hasVideo=!0,!E.decoderImplementation||S.prevDecoderImplementationMap_.has(a.userId)&&S.prevDecoderImplementationMap_.get(a.userId)===E.decoderImplementation||(S.log_.info("".concat(a.userId," decoderImplementation change to ").concat(E.decoderImplementation)),S.prevDecoderImplementationMap_.set(a.userId,E.decoderImplementation))),E.ssrc===l.auxiliary&&u.auxiliary&&(a.auxiliary.packetsReceived=E.packetsReceived,a.auxiliary.bytesReceived=E.bytesReceived,a.auxiliary.packetsLost=E.packetsLost,a.auxiliary.framesReceived=E.framesReceived,a.auxiliary.framesDecoded=E.framesDecoded,a.auxiliary.fpsDecoded=E.framesPerSecond,a.hasAuxiliary=!0)}else E.type==="candidate-pair"&&xm(E)&&tr(E.currentRoundTripTime)&&(a.rtt=Math.floor(1e3*E.currentRoundTripTime));ge(E.frameWidth)||(E.trackIdentifier!==c.getMainStreamVideoTrackId()&&E.ssrc!==l.video||(a.video.frameWidth=E.frameWidth,a.video.frameHeight=E.frameHeight),E.trackIdentifier!==c.getAuxStreamVideoTrackId()&&E.ssrc!==l.auxiliary||(a.auxiliary.frameWidth=E.frameWidth,a.auxiliary.frameHeight=E.frameHeight)),ge(E.audioLevel)||(a.audio.audioLevel=E.audioLevel||0,a.audio.totalAudioEnergy=E.totalAudioEnergy||0)}),a.audio.audioLevel===0&&(a.audio.audioLevel=((f=c.getMainStream())===null||f===void 0?void 0:f.getInternalAudioLevel())||0),x.next=16;break;case 13:x.prev=13,x.t0=x.catch(3),this.log_.warn("failed to getStats on receiver connection "+x.t0);case 16:return x.abrupt("return",a);case 17:case"end":return x.stop()}},o,this,[[3,13]])})),function(o){return i.apply(this,arguments)})},{key:"getStats",value:(n=H(p().mark(function o(c,a){var s,l,u,f,S,x,E;return p().wrap(function(I){for(;;)switch(I.prev=I.next){case 0:if(s={},!c){I.next=5;break}return I.next=4,this.getSenderStats(c);case 4:s=I.sent;case 5:l=[],u=oe(a),I.prev=7,u.s();case 9:if((f=u.n()).done){I.next=17;break}return(S=Te(f.value,2))[0],x=S[1],I.next=13,this.getReceiverStats(x);case 13:E=I.sent,l.push(E);case 15:I.next=9;break;case 17:I.next=22;break;case 19:I.prev=19,I.t0=I.catch(7),u.e(I.t0);case 22:return I.prev=22,u.f(),I.finish(22);case 25:return I.abrupt("return",{senderStats:s,receiverStats:l});case 26:case"end":return I.stop()}},o,this,[[7,19,22,25]])})),function(o,c){return n.apply(this,arguments)})},{key:"getDifferenceValue",value:function(o,c){if(Br(o))return c;var a=c-o;return a<0?0:a}},{key:"prepareReport",value:function(o){var c=this,a=o.stats,s=o.report,l=o.freezeMap;if(!Br(a.senderStats)){var u;u={uint32_audio_level:1e8*a.senderStats.audio.audioLevel,uint32_audio_energy:1e6*a.senderStats.audio.totalAudioEnergy,uint32_audio_codec_bitrate:a.senderStats.audio.bytesSent,audioLevel:a.senderStats.audio.audioLevel};var f=[],S={uint32_video_stream_type:2,uint32_video_codec_fps:a.senderStats.video.framesSent,uint32_video_capture_fps:a.senderStats.video.fpsCapture,uint32_video_width:a.senderStats.video.frameWidth,uint32_video_height:a.senderStats.video.frameHeight,uint32_video_codec_bitrate:a.senderStats.video.bytesSent,uint32_video_enc_fps:a.senderStats.video.framesEncoded};if(f.push(S),a.senderStats.small.bytesSent){var x={uint32_video_stream_type:3,uint32_video_codec_fps:a.senderStats.small.framesSent||0,uint32_video_capture_fps:a.senderStats.small.fpsCapture||0,uint32_video_width:a.senderStats.small.frameWidth||0,uint32_video_height:a.senderStats.small.frameHeight||0,uint32_video_codec_bitrate:a.senderStats.small.bytesSent,uint32_video_enc_fps:a.senderStats.small.framesEncoded||0};f.push(x)}if(a.senderStats.auxiliary.bytesSent){var E={uint32_video_stream_type:7,uint32_video_codec_fps:a.senderStats.auxiliary.framesSent||0,uint32_video_capture_fps:a.senderStats.auxiliary.fpsCapture||0,uint32_video_width:a.senderStats.auxiliary.frameWidth||0,uint32_video_height:a.senderStats.auxiliary.frameHeight||0,uint32_video_codec_bitrate:a.senderStats.auxiliary.bytesSent,uint32_video_enc_fps:a.senderStats.auxiliary.framesEncoded||0};f.push(E)}var I={uint32_bitrate:0,uint32_rtt:a.senderStats.rtt};s.msg_up_stream_info={msg_audio_status:u,msg_video_status:f,msg_network_status:I}}var m=this.statInterval;s.msg_down_stream_info=[],a.receiverStats.forEach(function(b){var R={};if(R.msg_user_info={str_identifier:b.userId,uint64_tinyid:b.tinyId},R.msg_network_status={uint32_rtt:b.rtt},R.msg_video_status={},b.hasAudio){var P={uint32_audio_codec_bitrate:b.audio.bytesReceived,uint32_audio_total_bitrate:b.audio.bytesReceived,uint32_audio_level:1e8*b.audio.audioLevel,uint32_audio_energy:1e6*b.audio.totalAudioEnergy,uint32_audio_receive:b.audio.packetsReceived,uint32_audio_origin_lost:b.audio.packetsLost,audioLevel:b.audio.audioLevel};R.msg_audio_status=P}if(R.msg_video_status=[],b.hasVideo){var U=l.get(b.userId+"_"+yt),k=U?U.duration:0,h={uint32_video_stream_type:2,uint32_video_receive_fps:b.video.framesReceived,uint32_video_width:b.video.frameWidth,uint32_video_height:b.video.frameHeight,uint32_video_codec_bitrate:b.video.bytesReceived,uint32_video_receive:b.video.packetsReceived,uint32_video_origin_lost:b.video.packetsLost,uint32_video_block_time:k,uint32_video_dec_fps:b.video.framesDecoded};R.msg_video_status.push(h)}if(b.hasAuxiliary){var y=l.get(b.userId+"_"+Dt),A=y?y.duration:0,D={uint32_video_stream_type:7,uint32_video_receive_fps:b.auxiliary.framesReceived,uint32_video_width:b.auxiliary.frameWidth,uint32_video_height:b.auxiliary.frameHeight,uint32_video_codec_bitrate:b.auxiliary.bytesReceived,uint32_video_receive:b.auxiliary.packetsReceived+b.auxiliary.packetsLost,uint32_video_origin_lost:b.auxiliary.packetsLost,uint32_video_block_time:A,uint32_video_dec_fps:b.auxiliary.framesDecoded};R.msg_video_status.push(D)}s.msg_down_stream_info.push(R)});var T=this.prevReport_;if(this.prevReport_=JSON.parse(JSON.stringify(s)),s.msg_up_stream_info.msg_audio_status&&T.msg_up_stream_info.msg_audio_status){var v=T.msg_up_stream_info.msg_audio_status,w=s.msg_up_stream_info.msg_audio_status,L=this.getDifferenceValue(v.uint32_audio_codec_bitrate,w.uint32_audio_codec_bitrate);w.uint32_audio_codec_bitrate=Math.round(8*L/m),s.msg_up_stream_info.msg_network_status.uint32_bitrate+=w.uint32_audio_codec_bitrate}var N=T.msg_up_stream_info.msg_video_status;s.msg_up_stream_info.msg_video_status.forEach(function(b){var R=N.find(function(y){return y.uint32_video_stream_type===b.uint32_video_stream_type});if(!R||R.uint32_video_codec_bitrate===0)return b.uint32_video_codec_bitrate=0,b.uint32_video_enc_fps=0,void(b.uint32_video_codec_fps=0);var P=R.uint32_video_codec_bitrate,U=R.uint32_video_enc_fps,k=R.uint32_video_codec_fps,h=c.getDifferenceValue(P,b.uint32_video_codec_bitrate);b.uint32_video_codec_bitrate=Math.round(8*h/m),s.msg_up_stream_info.msg_network_status.uint32_bitrate+=b.uint32_video_codec_bitrate,b.uint32_video_enc_fps=Math.round(c.getDifferenceValue(U,b.uint32_video_enc_fps)/m),b.uint32_video_codec_fps=Math.round(c.getDifferenceValue(k,b.uint32_video_codec_fps)/m)});var V=s.msg_down_stream_info,_=T.msg_down_stream_info;return V.forEach(function(b){var R=_.find(function(A){return A.msg_user_info.uint64_tinyid===b.msg_user_info.uint64_tinyid});if(R){if(b.msg_audio_status&&R.msg_audio_status){var P=b.msg_audio_status,U=R.msg_audio_status;P.uint32_audio_origin_lost=c.getDifferenceValue(U.uint32_audio_origin_lost,P.uint32_audio_origin_lost),P.uint32_audio_receive=c.getDifferenceValue(U.uint32_audio_receive,P.uint32_audio_receive),P.uint32_audio_receive+=P.uint32_audio_origin_lost;var k=c.getDifferenceValue(U.uint32_audio_codec_bitrate,P.uint32_audio_codec_bitrate);P.uint32_audio_codec_bitrate=Math.round(8*k/m),P.uint32_audio_total_bitrate=Math.round(8*k/m)}if(b.msg_video_status&&R.msg_video_status){var h=b.msg_video_status,y=R.msg_video_status;h.forEach(function(A){var D=y.find(function(Fe){return Fe.uint32_video_stream_type===A.uint32_video_stream_type});if(!D)return A.uint32_video_receive=0,A.uint32_video_origin_lost=0,A.uint32_video_codec_bitrate=0,A.uint32_video_receive_fps=0,void(A.uint32_video_dec_fps=0);var j=D.uint32_video_receive,K=D.uint32_video_origin_lost,J=D.uint32_video_codec_bitrate,se=D.uint32_video_receive_fps,ie=D.uint32_video_dec_fps;A.uint32_video_origin_lost=c.getDifferenceValue(K,A.uint32_video_origin_lost),A.uint32_video_receive=c.getDifferenceValue(j,A.uint32_video_receive)+A.uint32_video_origin_lost;var Je=c.getDifferenceValue(J,A.uint32_video_codec_bitrate);A.uint32_video_codec_bitrate=Math.round(8*Je/m);var Ue=c.getDifferenceValue(se,A.uint32_video_receive_fps);A.uint32_video_receive_fps=Math.round(Ue/m),A.uint32_video_dec_fps=Math.round(c.getDifferenceValue(ie,A.uint32_video_dec_fps)/m)})}}}),s}},{key:"getStatsReport",value:(t=H(p().mark(function o(c){var a,s,l,u,f;return p().wrap(function(S){for(;;)switch(S.prev=S.next){case 0:return a=c.uplinkConnection,s=c.downlinkConnections,l=c.freezeMap,u={msg_up_stream_info:{msg_audio_status:{uint32_audio_format:0,uint32_audio_sample_rate:0,uint32_audio_codec_bitrate:0,uint32_audio_receive:0,uint32_audio_origin_lost:0,uint32_audio_level:0,uint32_audio_energy:0,audioLevel:0},msg_video_status:[{uint32_video_stream_type:0,uint32_video_codec_fps:0,uint32_video_capture_fps:0,uint32_video_width:0,uint32_video_height:0,uint32_video_codec_bitrate:0,uint32_video_receive:0,uint32_video_origin_lost:0,uint32_video_final_lost:0,uint32_video_enc_fps:0}],msg_network_status:{uint32_bitrate:0,uint32_rtt:0,uint32_lost:0}},msg_down_stream_info:[{msg_user_info:{str_identifier:"",uint64_tinyid:""},msg_audio_status:{uint32_audio_format:0,uint32_audio_sample_rate:0,uint32_audio_codec_bitrate:0,uint32_audio_total_bitrate:0,uint32_audio_level:0,uint32_audio_energy:0,uint32_audio_receive:0,uint32_audio_origin_lost:0,uint32_audio_final_lost:0,audioLevel:0},msg_video_status:[{uint32_video_stream_type:0,uint32_video_receive_fps:0,uint32_video_width:0,uint32_video_height:0,uint32_video_codec_bitrate:0,uint32_video_receive:0,uint32_video_origin_lost:0,uint32_video_block_time:0,uint32_video_dec_fps:0}],msg_network_status:{uint32_bitrate:0,uint32_rtt:0,uint32_lost:0,uint32_jitter:0}}]},S.next=4,this.getStats(a,s);case 4:return f=S.sent,JSON.stringify(this.prevReport_)==="{}"&&(this.prevReport_=JSON.parse(JSON.stringify(u))),this.prepareReport({stats:f,report:u,freezeMap:l,uplinkConnection:a,downlinkConnections:s}),this.prevReportTime_=Date.now(),S.abrupt("return",u);case 9:case"end":return S.stop()}},o,this)})),function(o){return t.apply(this,arguments)})},{key:"reset",value:function(){this.prevReportTime_=0,this.prevReport_={},this.prevEncoderImplementation_="",this.prevQualityLimitationReason_="",this.prevDecoderImplementationMap_=new Map}}]),e}(),u6=function(){function e(i){var r=i.signalChannel,o=i.connections,c=i.client;Q(this,e),this.client_=c,this.signalChannel_=r,this.connections_=o,this.client_=c,this.log_=_e.createLogger({id:"q|"+this.client_.getUserId(),userId:this.client_.getUserId(),sdkAppId:this.client_.getSDKAppId()}),this.uplinkConnection_=null,this.uplinkNetworkQuality_=0,this.uplinkRTT_=0,this.uplinkLoss_=0,this.downlinkNetworkQuality_=0,this.downlinkRTT_=0,this.downlinkLoss_=0,this.downlinkPrevStatMap_=new Map,this.downlinkLossAndRTTMap_=new Map,this.interval_=-1,this.emitter_=new Si,this.initialize()}var t,n;return Ie(e,[{key:"uplinkNetworkQuality",get:function(){return this.uplinkNetworkQuality_},set:function(i){i!==this.uplinkNetworkQuality_&&this.log_.info("uplink network quality change ".concat(this.uplinkNetworkQuality," -> ").concat(i,", rtt: ").concat(this.uplinkRTT_,", loss: ").concat(this.uplinkLoss_)),this.uplinkNetworkQuality_=i}},{key:"downlinkNetworkQuality",get:function(){return this.downlinkNetworkQuality_},set:function(i){if(i!==this.downlinkNetworkQuality_){var r=this.getAverageLossAndRTT(Se(this.downlinkLossAndRTTMap_.values())),o=r.rtt,c=r.loss;this.log_.info("downlink network quality change ".concat(this.downlinkNetworkQuality," -> ").concat(i,", rtt: ").concat(o,", loss: ").concat(c))}this.downlinkNetworkQuality_=i}},{key:"initialize",value:function(){var i=this;this.signalChannel_.on(st.UPLINK_NETWORK_STATS,function(r){i.handleUplinkNetworkQuality(r)}),this.signalChannel_.on(rm,this.handleSignalConnectionStateChange.bind(this)),this.start()}},{key:"handleUplinkNetworkQuality",value:function(i){if(!this.uplinkConnection_)return this.uplinkNetworkQuality=0,this.uplinkLoss_=0,void(this.uplinkRTT_=0);var r=this.uplinkConnection_.getPeerConnection();if(r&&this.isPeerConnectionDisconnected(r))return this.uplinkNetworkQuality=6,this.uplinkLoss_=0,void(this.uplinkRTT_=0);if(i.data.code===0){var o=i.data.data,c=o.expectAudPkg+o.expectVidPkg,a=o.recvAudPkg+o.recvVidPkg,s=c-a,l=o.delay;if(l&&this.updateDelay(l),c===0&&a===0)return;this.uplinkLoss_=s<=0?0:Math.round(s/c*100),this.uplinkRTT_=o.rtt,this.uplinkNetworkQuality=this.getNetworkQuality(this.uplinkLoss_,this.uplinkRTT_)}}},{key:"handleDownlinkNetworkQuality",value:(n=H(p().mark(function i(){var r,o,c,a,s,l,u,f,S,x,E,I,m,T,v,w=this;return p().wrap(function(L){for(;;)switch(L.prev=L.next){case 0:if(this.connections_&&this.connections_.size!==0){L.next=3;break}return this.downlinkNetworkQuality=0,L.abrupt("return");case 3:if(r=Se(this.connections_.values()),o=r.filter(function(N){return N.getPeerConnection()&&N.getPeerConnection().connectionState===kb}),r.filter(function(N){return N.getPeerConnection()&&w.isPeerConnectionDisconnected(N.getPeerConnection())}).length!==r.length){L.next=9;break}return this.downlinkNetworkQuality=6,L.abrupt("return");case 9:c=0;case 10:if(!(c<o.length)){L.next=31;break}return a=o[c].getPeerConnection(),L.next=14,this.getStat(a);case 14:if(s=L.sent,l=s.rtt,u=s.totalPacketsLost,f=s.totalPacketsReceived,this.downlinkPrevStatMap_.has(a)){L.next=21;break}return this.downlinkPrevStatMap_.set(a,{totalPacketsLost:u,totalPacketsReceived:f}),L.abrupt("continue",28);case 21:S=0,x=this.downlinkPrevStatMap_.get(a),E=u-x.totalPacketsLost,I=f-x.totalPacketsReceived,S=E<=0||I<0?0:Math.round(E/(E+I)*100),this.downlinkPrevStatMap_.set(a,{totalPacketsLost:u,totalPacketsReceived:f}),this.downlinkLossAndRTTMap_.set(a,{rtt:l,loss:S,userId:o[c].getUserId()});case 28:c++,L.next=10;break;case 31:if(Se(this.downlinkPrevStatMap_.keys()).forEach(function(N){w.isPeerConnectionDisconnected(N)&&(w.downlinkPrevStatMap_.delete(N),w.downlinkLossAndRTTMap_.delete(N))}),this.downlinkLossAndRTTMap_.size!==0){L.next=34;break}return L.abrupt("return");case 34:m=this.getAverageLossAndRTT(Se(this.downlinkLossAndRTTMap_.values())),T=m.rtt,v=m.loss,this.downlinkRTT_=T,this.downlinkLoss_=v,this.downlinkNetworkQuality=this.getNetworkQuality(v,T);case 38:case"end":return L.stop()}},i,this)})),function(){return n.apply(this,arguments)})},{key:"getStat",value:(t=H(p().mark(function i(r){var o,c,a,s;return p().wrap(function(l){for(;;)switch(l.prev=l.next){case 0:if(o={rtt:0,totalPacketsLost:0,totalPacketsReceived:0},r&&Fk()){l.next=3;break}return l.abrupt("return",o);case 3:c=r.getReceivers(),l.prev=4,a=0;case 6:if(!(a<c.length)){l.next=15;break}return s=c[a],l.next=10,s.getStats();case 10:l.sent.forEach(function(u){u.type==="candidate-pair"&&tr(u.currentRoundTripTime)&&(o.rtt=Math.round(1e3*u.currentRoundTripTime)),u.type!=="inbound-rtp"||u.mediaType!==Ee&&u.mediaType!==xe||(o.totalPacketsLost+=u.packetsLost,o.totalPacketsReceived+=u.packetsReceived)});case 12:a++,l.next=6;break;case 15:return l.abrupt("return",o);case 18:return l.prev=18,l.t0=l.catch(4),l.abrupt("return",o);case 21:case"end":return l.stop()}},i,null,[[4,18]])})),function(i){return t.apply(this,arguments)})},{key:"getAverageLossAndRTT",value:function(i){var r={rtt:0,loss:0};return Array.isArray(i)&&i.length>0&&(i.forEach(function(o){r.rtt+=o.rtt,r.loss+=o.loss}),Object.keys(r).forEach(function(o){r[o]=Math.round(r[o]/i.length)})),r}},{key:"getNetworkQuality",value:function(i,r){return i>50||r>500?5:i>30||r>350?4:i>20||r>200?3:i>10||r>100?2:i>=0||r>=0?1:0}},{key:"handleSignalConnectionStateChange",value:function(i){i.state===fl?(this.uplinkRTT_=0,this.uplinkLoss_=0,this.uplinkNetworkQuality=6):i.state===oc&&this.uplinkNetworkQuality===6&&(this.uplinkNetworkQuality=5)}},{key:"handleUplinkConnectionStateChange",value:function(i){var r=i.state;r===on?(this.uplinkLoss_=0,this.uplinkRTT_=0,this.uplinkNetworkQuality=6):r===sn&&this.uplinkNetworkQuality===6&&(this.uplinkNetworkQuality=5)}},{key:"isPeerConnectionDisconnected",value:function(i){return!(!i||i.connectionState!==$M&&i.connectionState!==Sb&&i.connectionState!==Bf)}},{key:"setUplinkConnection",value:function(i){this.uplinkConnection_=i,this.uplinkConnection_?this.uplinkConnection_.on(et.CONNECTION_STATE_CHANGED,this.handleUplinkConnectionStateChange.bind(this)):(this.uplinkNetworkQuality=0,this.uplinkRTT_=0,this.uplinkLoss_=0)}},{key:"start",value:function(){var i=this;this.interval_===-1?(this.log_.info("start network quality calculating"),this.interval_=mt.run(uo,function(){i.handleDownlinkNetworkQuality(),Y.emit(Yp,{client:i.client_,uplinkNetworkQuality:i.uplinkNetworkQuality,downlinkNetworkQuality:i.downlinkNetworkQuality,uplinkRTT:i.uplinkRTT_,uplinkLoss:i.uplinkLoss_,downlinkRTT:i.downlinkRTT_,downlinkLoss:i.downlinkLoss_,downlinkLossAndRTTMap:i.downlinkLossAndRTTMap_}),i.emitter_.emit(ct.NETWORK_QUALITY,{uplinkNetworkQuality:i.uplinkNetworkQuality,downlinkNetworkQuality:i.downlinkNetworkQuality,uplinkRTT:i.uplinkRTT_,uplinkLoss:i.uplinkLoss_,downlinkRTT:i.downlinkRTT_,downlinkLoss:i.downlinkLoss_})},{delay:2e3})):this.log_.info("network quality calculating is already started")}},{key:"stop",value:function(){this.log_.info("stop network quality calculating"),this.interval_!==-1&&(mt.clearTask(this.interval_),this.interval_=-1),this.downlinkLossAndRTTMap_.clear(),this.downlinkPrevStatMap_.clear()}},{key:"on",value:function(i,r){this.emitter_.on(i,r)}},{key:"updateDelay",value:function(i){var r=this;i.forEach(function(o){var c=o.srcTinyId,a=o.videoDelay,s=o.audioDelay,l=r.connections_.get(c);l&&l.setDelay({videoDelay:a,audioDelay:s})})}}]),e}(),l6=function(){function e(i){Q(this,e),this.log_=_e.createLogger({id:i.client.getUserId(),userId:i.client.getUserId(),sdkAppId:i.client.getSDKAppId()}),this.localStream_=null,this.prevDevices_=[],this.initialize()}var t,n;return Ie(e,[{key:"initialize",value:function(){navigator.mediaDevices&&navigator.mediaDevices.addEventListener&&(this.onDeviceChange=this.onDeviceChange.bind(this),navigator.mediaDevices.addEventListener("devicechange",this.onDeviceChange))}},{key:"destroy",value:function(){navigator.mediaDevices&&navigator.mediaDevices.removeEventListener&&navigator.mediaDevices.removeEventListener("devicechange",this.onDeviceChange)}},{key:"onDeviceChange",value:(n=H(p().mark(function i(){var r,o,c,a=this;return p().wrap(function(s){for(;;)switch(s.prev=s.next){case 0:if(this.localStream_&&this.localStream_.getMediaStream()&&!this.localStream_.getScreen()){s.next=2;break}return s.abrupt("return");case 2:return s.next=4,Em();case 4:r=s.sent,o=r.filter(function(l){return a.prevDevices_.findIndex(function(u){var f=u.deviceId;return l.deviceId===f})<0}),c=this.prevDevices_.filter(function(l){return r.findIndex(function(u){var f=u.deviceId;return l.deviceId===f})<0}),o.length>0&&this.handleDeviceAdded(this.prevDevices_,o),c.length>0&&this.handleDeviceRemoved(r,c),this.prevDevices_=r;case 10:case"end":return s.stop()}},i,this)})),function(){return n.apply(this,arguments)})},{key:"setLocalStream",value:(t=H(p().mark(function i(r){return p().wrap(function(o){for(;;)switch(o.prev=o.next){case 0:if(!r){o.next=4;break}return o.next=3,Em();case 3:this.prevDevices_=o.sent;case 4:this.localStream_=r;case 5:case"end":return o.stop()}},i,this)})),function(i){return t.apply(this,arguments)})},{key:"handleDeviceAdded",value:function(i,r){var o,c;if(this.localStream_){this.log_.warn("devicesAdded: ".concat(JSON.stringify(r))),this.localStream_.updateDeviceIdInUse();var a=r.filter(function(x){return x.kind===Hu}),s=r.filter(function(x){return x.kind===qs}),l=i.filter(function(x){return x.kind===Hu}),u=i.filter(function(x){return x.kind===qs}),f=a.length>0&&l.length===0&&((o=this.localStream_.getVideoTrack())===null||o===void 0?void 0:o.readyState)!=="live",S=s.length>0&&u.length===0&&((c=this.localStream_.getAudioTrack())===null||c===void 0?void 0:c.readyState)!=="live";if(S&&f)return this.log_.info("new microphone and camera detected, but there was no device before."),void this.localStream_.recoverCapture({audio:!0,video:!0,cameraId:a[0].deviceId,microphoneId:s[0].deviceId});f&&(this.log_.info("new camera detected, but there was no camera before."),this.localStream_.recoverCapture({audio:!1,video:!0,cameraId:a[0].deviceId})),S&&(this.log_.info("new microphone detected, but there was no microphone before."),this.localStream_.recoverCapture({audio:!0,video:!1,microphoneId:s[0].deviceId}))}}},{key:"handleDeviceRemoved",value:function(i,r){if(this.localStream_){this.log_.warn("devicesRemoved: ".concat(JSON.stringify(r))),this.localStream_.updateDeviceIdInUse();var o=!1,c=!1,a=this.localStream_.getCameraId(),s=this.localStream_.getMicrophoneId();if(s===Ku){var l=this.localStream_.getMicrophoneGroupId(),u=i.filter(function(f){return f.deviceId===Ku&&f.kind===qs})[0];u&&u.groupId!==l&&(c=!0)}if(r.forEach(function(f){var S=f.deviceId;a.length>0&&S===a?o=!0:s.length>0&&S===s&&(c=!0)}),o&&c)return this.log_.warn("current camera and microphone in use is lost, cameraId: ".concat(a,", microphoneId: ").concat(s)),void((this.localStream_.getAudio()||this.localStream_.getVideo())&&this.localStream_.recoverCapture({video:!0,audio:!0}));o&&(this.log_.warn("current camera in use is lost, deviceId: ".concat(a)),this.localStream_.getVideo()&&this.localStream_.recoverCapture({video:!0,audio:!1})),c&&(this.log_.warn("current microphone in use is lost, deviceId: ".concat(s)),this.localStream_.getAudio()&&this.localStream_.recoverCapture({video:!1,audio:!0}))}}}]),e}();function Cm(){return Cm=H(p().mark(function e(){var t;return p().wrap(function(n){for(;;)switch(n.prev=n.next){case 0:if(!_l()&&!gl()){n.next=2;break}return n.abrupt("return",[]);case 2:return n.next=4,yl();case 4:return t=n.sent,n.abrupt("return",t.filter(function(i){return i.kind===Hu}).map(function(i,r){var o=i.label;i.label||(o="camera_"+r);var c={label:o,deviceId:i.deviceId,kind:i.kind};return i.groupId&&(c.groupId=i.groupId),i.getCapabilities&&(c.getCapabilities=function(){return i.getCapabilities()}),c}));case 6:case"end":return n.stop()}},e)})),Cm.apply(this,arguments)}var qk=new Set;function yl(){return Kk.apply(this,arguments)}function Kk(){return(Kk=H(p().mark(function e(){var t;return p().wrap(function(n){for(;;)switch(n.prev=n.next){case 0:if(!_l()&&!gl()){n.next=2;break}return n.abrupt("return",[]);case 2:return n.next=4,navigator.mediaDevices.enumerateDevices();case 4:return(t=n.sent).forEach(function(i){qk.add("".concat(i.deviceId,"_").concat(i.kind))}),n.abrupt("return",t);case 7:case"end":return n.stop()}},e)}))).apply(this,arguments)}function Em(){return Rm.apply(this,arguments)}function Rm(){return Rm=H(p().mark(function e(){var t;return p().wrap(function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,yl();case 2:return t=n.sent,n.abrupt("return",t.filter(function(i){return i.kind!==qs||i.deviceId!=Zb}).map(function(i,r){var o=i.label;i.label||(o=i.kind+"_"+r);var c={label:o,deviceId:i.deviceId,kind:i.kind};return i.groupId&&(c.groupId=i.groupId),i.getCapabilities&&(c.getCapabilities=function(){return i.getCapabilities()}),c}));case 4:case"end":return n.stop()}},e)})),Rm.apply(this,arguments)}function Xk(){return Am.apply(this,arguments)}function Am(){return Am=H(p().mark(function e(){var t;return p().wrap(function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,yl();case 2:return t=n.sent,n.abrupt("return",t.filter(function(i){return i.kind===qs&&i.deviceId!==Zb}).map(function(i,r){var o=i.label;i.label||(o="microphone_"+r);var c={label:o,deviceId:i.deviceId,kind:i.kind};return i.groupId&&(c.groupId=i.groupId),i.getCapabilities&&(c.getCapabilities=function(){return i.getCapabilities()}),c}));case 4:case"end":return n.stop()}},e)})),Am.apply(this,arguments)}function Qk(){return Pm.apply(this,arguments)}function Pm(){return Pm=H(p().mark(function e(){var t;return p().wrap(function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,yl();case 2:return t=n.sent,n.abrupt("return",t.filter(function(i){return i.kind==="audiooutput"}).map(function(i,r){var o=i.label;i.label||(o="speaker_"+r);var c={label:o,deviceId:i.deviceId,kind:i.kind};return i.groupId&&(c.groupId=i.groupId),c}));case 4:case"end":return n.stop()}},e)})),Pm.apply(this,arguments)}function d6(e){var t;if(e instanceof CanvasCaptureMediaStreamTrack||!(e instanceof window.MediaStreamTrack))return!1;var n=e.label.toLocaleLowerCase();if(n.includes("camera")||n.includes("webcam"))return!0;var i="".concat((t=e.getSettings())===null||t===void 0?void 0:t.deviceId,"_").concat(Hu);return!!qk.has(i)}function h6(e,t){return Yk.apply(this,arguments)}function Yk(){return(Yk=H(p().mark(function e(t,n){var i,r;return p().wrap(function(o){for(;;)switch(o.prev=o.next){case 0:return o.next=2,Xk();case 2:if(i=o.sent,((r=i.find(function(c){return c.deviceId===Ku}))==null?void 0:r.groupId)!==t||r.label!==n){o.next=6;break}return o.abrupt("return",!0);case 6:return o.abrupt("return",!1);case 7:case"end":return o.stop()}},e)}))).apply(this,arguments)}var Bn,$k=Fi.exports,f6=Pt,p6=Tt,m6=t_,v6=Lr,g6=Ke,_6=Mt,y6=function(e,t,n,i){try{return i?t(p6(n)[0],n[1]):t(n)}catch(r){m6(e,"throw",r)}},b6=lh,S6=yu,k6=nn,Zk=Cs,T6=pu,x6=Es,eT=Array,tT=function(e){var t=_6(e),n=S6(this),i=arguments.length,r=i>1?arguments[1]:void 0,o=r!==void 0;o&&(r=v6(r,i>2?arguments[2]:void 0));var c,a,s,l,u,f,S=x6(t),x=0;if(!S||this===eT&&b6(S))for(c=k6(t),a=n?new this(c):eT(c);c>x;x++)f=o?r(t[x],x):t[x],Zk(a,x,f);else for(u=(l=T6(t,S)).next,a=n?new this:[];!(s=g6(u,l)).done;x++)f=o?y6(l,r,[s.value,x],!0):s.value,Zk(a,x,f);return a.length=x,a},da=pe,Dm=2147483647,I6=/[^\0-\u007E]/,nT=/[.\u3002\uFF0E\uFF61]/g,rT="Overflow: input needs wider integers to process",iT=RangeError,w6=da(nT.exec),So=Math.floor,Om=String.fromCharCode,aT=da("".charCodeAt),oT=da([].join),xi=da([].push),C6=da("".replace),E6=da("".split),R6=da("".toLowerCase),sT=function(e){return e+22+75*(e<26)},A6=function(e,t,n){var i=0;for(e=n?So(e/700):e>>1,e+=So(e/t);e>455;)e=So(e/35),i+=36;return So(i+36*e/(e+38))},P6=function(e){var t=[];e=function(T){for(var v=[],w=0,L=T.length;w<L;){var N=aT(T,w++);if(N>=55296&&N<=56319&&w<L){var V=aT(T,w++);(64512&V)==56320?xi(v,((1023&N)<<10)+(1023&V)+65536):(xi(v,N),w--)}else xi(v,N)}return v}(e);var n,i,r=e.length,o=128,c=0,a=72;for(n=0;n<e.length;n++)(i=e[n])<128&&xi(t,Om(i));var s=t.length,l=s;for(s&&xi(t,"-");l<r;){var u=Dm;for(n=0;n<e.length;n++)(i=e[n])>=o&&i<u&&(u=i);var f=l+1;if(u-o>So((Dm-c)/f))throw iT(rT);for(c+=(u-o)*f,o=u,n=0;n<e.length;n++){if((i=e[n])<o&&++c>Dm)throw iT(rT);if(i==o){for(var S=c,x=36;;){var E=x<=a?1:x>=a+26?26:x-a;if(S<E)break;var I=S-E,m=36-E;xi(t,Om(sT(E+I%m))),S=So(I/m),x+=36}xi(t,Om(sT(S))),a=A6(c,f,l==s),c=0,l++}}c++,o++}return oT(t,"")},D6=Le,Lm=ye,O6=xy,Mm=re,cT=Lr,Fn=pe,bl=Qt,Hn=function(e,t,n){return n.get&&$k(n.get,t,{getter:!0}),n.set&&$k(n.set,t,{setter:!0}),f6.f(e,t,n)},L6=oi,Nm=kt,Um=ik,ko=tT,ir=hu,M6=vh.codeAt,N6=function(e){var t,n,i=[],r=E6(C6(R6(e),nT,"."),".");for(t=0;t<r.length;t++)n=r[t],xi(i,w6(I6,n)?"xn--"+P6(n):n);return oT(i,".")},Hr=zt,U6=Wi,V6=_u,uT=AD,lT=Xe,j6=lT.set,Sl=lT.getterFor("URL"),B6=uT.URLSearchParams,F6=uT.getState,lc=Mm.URL,Vm=Mm.TypeError,kl=Mm.parseInt,H6=Math.floor,dT=Math.pow,Gn=Fn("".charAt),ar=Fn(/./.exec),dc=Fn([].join),G6=Fn(1 .toString),z6=Fn([].pop),To=Fn([].push),hT=Fn("".replace),W6=Fn([].shift),J6=Fn("".split),hc=Fn("".slice),Tl=Fn("".toLowerCase),q6=Fn([].unshift),jm="Invalid scheme",ha="Invalid host",fT="Invalid port",pT=/[a-z]/i,K6=/[\d+-.a-z]/i,Bm=/\d/,X6=/^0x/i,Q6=/^[0-7]+$/,Y6=/^\d+$/,mT=/^[\da-f]+$/i,$6=/[\0\t\n\r #%/:<>?@[\\\]^|]/,Z6=/[\0\t\n\r #/:<>?@[\\\]^|]/,e5=/^[\u0000-\u0020]+|[\u0000-\u0020]+$/g,t5=/[\t\n\r]/g,fc=function(e){var t,n,i,r;if(typeof e=="number"){for(t=[],n=0;n<4;n++)q6(t,e%256),e=H6(e/256);return dc(t,".")}if(typeof e=="object"){for(t="",i=function(o){for(var c=null,a=1,s=null,l=0,u=0;u<8;u++)o[u]!==0?(l>a&&(c=s,a=l),s=null,l=0):(s===null&&(s=u),++l);return l>a&&(c=s,a=l),c}(e),n=0;n<8;n++)r&&e[n]===0||(r&&(r=!1),i===n?(t+=n?":":"::",r=!0):(t+=G6(e[n],16),n<7&&(t+=":")));return"["+t+"]"}return e},xl={},vT=Um({},xl,{" ":1,'"':1,"<":1,">":1,"`":1}),gT=Um({},vT,{"#":1,"?":1,"{":1,"}":1}),Fm=Um({},gT,{"/":1,":":1,";":1,"=":1,"@":1,"[":1,"\\":1,"]":1,"^":1,"|":1}),Ii=function(e,t){var n=M6(e,0);return n>32&&n<127&&!Nm(t,e)?e:encodeURIComponent(e)},Il={ftp:21,file:null,http:80,https:443,ws:80,wss:443},pc=function(e,t){var n;return e.length==2&&ar(pT,Gn(e,0))&&((n=Gn(e,1))==":"||!t&&n=="|")},_T=function(e){var t;return e.length>1&&pc(hc(e,0,2))&&(e.length==2||(t=Gn(e,2))==="/"||t==="\\"||t==="?"||t==="#")},n5=function(e){return e==="."||Tl(e)==="%2e"},Hm={},yT={},Gm={},bT={},ST={},zm={},kT={},TT={},wl={},Cl={},Wm={},Jm={},qm={},Km={},xT={},Xm={},xo={},Ir={},IT={},fa={},Gr={},Qm=function(e,t,n){var i,r,o,c=Hr(e);if(t){if(r=this.parse(c))throw Vm(r);this.searchParams=null}else{if(n!==void 0&&(i=new Qm(n,!0)),r=this.parse(c,null,i))throw Vm(r);(o=F6(new B6)).bindURL(this),this.searchParams=o}};Qm.prototype={type:"URL",parse:function(e,t,n){var i,r,o,c,a,s=this,l=t||Hm,u=0,f="",S=!1,x=!1,E=!1;for(e=Hr(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=hT(e,e5,"")),e=hT(e,t5,""),i=ko(e);u<=i.length;){switch(r=i[u],l){case Hm:if(!r||!ar(pT,r)){if(t)return jm;l=Gm;continue}f+=Tl(r),l=yT;break;case yT:if(r&&(ar(K6,r)||r=="+"||r=="-"||r=="."))f+=Tl(r);else{if(r!=":"){if(t)return jm;f="",l=Gm,u=0;continue}if(t&&(s.isSpecial()!=Nm(Il,f)||f=="file"&&(s.includesCredentials()||s.port!==null)||s.scheme=="file"&&!s.host))return;if(s.scheme=f,t)return void(s.isSpecial()&&Il[s.scheme]==s.port&&(s.port=null));f="",s.scheme=="file"?l=Km:s.isSpecial()&&n&&n.scheme==s.scheme?l=bT:s.isSpecial()?l=TT:i[u+1]=="/"?(l=ST,u++):(s.cannotBeABaseURL=!0,To(s.path,""),l=IT)}break;case Gm:if(!n||n.cannotBeABaseURL&&r!="#")return jm;if(n.cannotBeABaseURL&&r=="#"){s.scheme=n.scheme,s.path=ir(n.path),s.query=n.query,s.fragment="",s.cannotBeABaseURL=!0,l=Gr;break}l=n.scheme=="file"?Km:zm;continue;case bT:if(r!="/"||i[u+1]!="/"){l=zm;continue}l=wl,u++;break;case ST:if(r=="/"){l=Cl;break}l=Ir;continue;case zm:if(s.scheme=n.scheme,r==Bn)s.username=n.username,s.password=n.password,s.host=n.host,s.port=n.port,s.path=ir(n.path),s.query=n.query;else if(r=="/"||r=="\\"&&s.isSpecial())l=kT;else if(r=="?")s.username=n.username,s.password=n.password,s.host=n.host,s.port=n.port,s.path=ir(n.path),s.query="",l=fa;else{if(r!="#"){s.username=n.username,s.password=n.password,s.host=n.host,s.port=n.port,s.path=ir(n.path),s.path.length--,l=Ir;continue}s.username=n.username,s.password=n.password,s.host=n.host,s.port=n.port,s.path=ir(n.path),s.query=n.query,s.fragment="",l=Gr}break;case kT:if(!s.isSpecial()||r!="/"&&r!="\\"){if(r!="/"){s.username=n.username,s.password=n.password,s.host=n.host,s.port=n.port,l=Ir;continue}l=Cl}else l=wl;break;case TT:if(l=wl,r!="/"||Gn(f,u+1)!="/")continue;u++;break;case wl:if(r!="/"&&r!="\\"){l=Cl;continue}break;case Cl:if(r=="@"){S&&(f="%40"+f),S=!0,o=ko(f);for(var I=0;I<o.length;I++){var m=o[I];if(m!=":"||E){var T=Ii(m,Fm);E?s.password+=T:s.username+=T}else E=!0}f=""}else if(r==Bn||r=="/"||r=="?"||r=="#"||r=="\\"&&s.isSpecial()){if(S&&f=="")return"Invalid authority";u-=ko(f).length+1,f="",l=Wm}else f+=r;break;case Wm:case Jm:if(t&&s.scheme=="file"){l=Xm;continue}if(r!=":"||x){if(r==Bn||r=="/"||r=="?"||r=="#"||r=="\\"&&s.isSpecial()){if(s.isSpecial()&&f=="")return ha;if(t&&f==""&&(s.includesCredentials()||s.port!==null))return;if(c=s.parseHost(f))return c;if(f="",l=xo,t)return;continue}r=="["?x=!0:r=="]"&&(x=!1),f+=r}else{if(f=="")return ha;if(c=s.parseHost(f))return c;if(f="",l=qm,t==Jm)return}break;case qm:if(!ar(Bm,r)){if(r==Bn||r=="/"||r=="?"||r=="#"||r=="\\"&&s.isSpecial()||t){if(f!=""){var v=kl(f,10);if(v>65535)return fT;s.port=s.isSpecial()&&v===Il[s.scheme]?null:v,f=""}if(t)return;l=xo;continue}return fT}f+=r;break;case Km:if(s.scheme="file",r=="/"||r=="\\")l=xT;else{if(!n||n.scheme!="file"){l=Ir;continue}if(r==Bn)s.host=n.host,s.path=ir(n.path),s.query=n.query;else if(r=="?")s.host=n.host,s.path=ir(n.path),s.query="",l=fa;else{if(r!="#"){_T(dc(ir(i,u),""))||(s.host=n.host,s.path=ir(n.path),s.shortenPath()),l=Ir;continue}s.host=n.host,s.path=ir(n.path),s.query=n.query,s.fragment="",l=Gr}}break;case xT:if(r=="/"||r=="\\"){l=Xm;break}n&&n.scheme=="file"&&!_T(dc(ir(i,u),""))&&(pc(n.path[0],!0)?To(s.path,n.path[0]):s.host=n.host),l=Ir;continue;case Xm:if(r==Bn||r=="/"||r=="\\"||r=="?"||r=="#"){if(!t&&pc(f))l=Ir;else if(f==""){if(s.host="",t)return;l=xo}else{if(c=s.parseHost(f))return c;if(s.host=="localhost"&&(s.host=""),t)return;f="",l=xo}continue}f+=r;break;case xo:if(s.isSpecial()){if(l=Ir,r!="/"&&r!="\\")continue}else if(t||r!="?")if(t||r!="#"){if(r!=Bn&&(l=Ir,r!="/"))continue}else s.fragment="",l=Gr;else s.query="",l=fa;break;case Ir:if(r==Bn||r=="/"||r=="\\"&&s.isSpecial()||!t&&(r=="?"||r=="#")){if((a=Tl(a=f))===".."||a==="%2e."||a===".%2e"||a==="%2e%2e"?(s.shortenPath(),r=="/"||r=="\\"&&s.isSpecial()||To(s.path,"")):n5(f)?r=="/"||r=="\\"&&s.isSpecial()||To(s.path,""):(s.scheme=="file"&&!s.path.length&&pc(f)&&(s.host&&(s.host=""),f=Gn(f,0)+":"),To(s.path,f)),f="",s.scheme=="file"&&(r==Bn||r=="?"||r=="#"))for(;s.path.length>1&&s.path[0]==="";)W6(s.path);r=="?"?(s.query="",l=fa):r=="#"&&(s.fragment="",l=Gr)}else f+=Ii(r,gT);break;case IT:r=="?"?(s.query="",l=fa):r=="#"?(s.fragment="",l=Gr):r!=Bn&&(s.path[0]+=Ii(r,xl));break;case fa:t||r!="#"?r!=Bn&&(r=="'"&&s.isSpecial()?s.query+="%27":s.query+=r=="#"?"%23":Ii(r,xl)):(s.fragment="",l=Gr);break;case Gr:r!=Bn&&(s.fragment+=Ii(r,vT))}u++}},parseHost:function(e){var t,n,i;if(Gn(e,0)=="["){if(Gn(e,e.length-1)!="]"||(t=function(r){var o,c,a,s,l,u,f,S=[0,0,0,0,0,0,0,0],x=0,E=null,I=0,m=function(){return Gn(r,I)};if(m()==":"){if(Gn(r,1)!=":")return;I+=2,E=++x}for(;m();){if(x==8)return;if(m()!=":"){for(o=c=0;c<4&&ar(mT,m());)o=16*o+kl(m(),16),I++,c++;if(m()=="."){if(c==0||(I-=c,x>6))return;for(a=0;m();){if(s=null,a>0){if(!(m()=="."&&a<4))return;I++}if(!ar(Bm,m()))return;for(;ar(Bm,m());){if(l=kl(m(),10),s===null)s=l;else{if(s==0)return;s=10*s+l}if(s>255)return;I++}S[x]=256*S[x]+s,++a!=2&&a!=4||x++}if(a!=4)return;break}if(m()==":"){if(I++,!m())return}else if(m())return;S[x++]=o}else{if(E!==null)return;I++,E=++x}}if(E!==null)for(u=x-E,x=7;x!=0&&u>0;)f=S[x],S[x--]=S[E+u-1],S[E+--u]=f;else if(x!=8)return;return S}(hc(e,1,-1)),!t))return ha;this.host=t}else if(this.isSpecial()){if(e=N6(e),ar($6,e)||(t=function(r){var o,c,a,s,l,u,f,S=J6(r,".");if(S.length&&S[S.length-1]==""&&S.length--,(o=S.length)>4)return r;for(c=[],a=0;a<o;a++){if((s=S[a])=="")return r;if(l=10,s.length>1&&Gn(s,0)=="0"&&(l=ar(X6,s)?16:8,s=hc(s,l==8?1:2)),s==="")u=0;else{if(!ar(l==10?Y6:l==8?Q6:mT,s))return r;u=kl(s,l)}To(c,u)}for(a=0;a<o;a++)if(u=c[a],a==o-1){if(u>=dT(256,5-o))return null}else if(u>255)return null;for(f=z6(c),a=0;a<c.length;a++)f+=c[a]*dT(256,3-a);return f}(e),t===null))return ha;this.host=t}else{if(ar(Z6,e))return ha;for(t="",n=ko(e),i=0;i<n.length;i++)t+=Ii(n[i],xl);this.host=t}},cannotHaveUsernamePasswordPort:function(){return!this.host||this.cannotBeABaseURL||this.scheme=="file"},includesCredentials:function(){return this.username!=""||this.password!=""},isSpecial:function(){return Nm(Il,this.scheme)},shortenPath:function(){var e=this.path,t=e.length;!t||this.scheme=="file"&&t==1&&pc(e[0],!0)||e.length--},serialize:function(){var e=this,t=e.scheme,n=e.username,i=e.password,r=e.host,o=e.port,c=e.path,a=e.query,s=e.fragment,l=t+":";return r!==null?(l+="//",e.includesCredentials()&&(l+=n+(i?":"+i:"")+"@"),l+=fc(r),o!==null&&(l+=":"+o)):t=="file"&&(l+="//"),l+=e.cannotBeABaseURL?c[0]:c.length?"/"+dc(c,"/"):"",a!==null&&(l+="?"+a),s!==null&&(l+="#"+s),l},setHref:function(e){var t=this.parse(e);if(t)throw Vm(t);this.searchParams.update()},getOrigin:function(){var e=this.scheme,t=this.port;if(e=="blob")try{return new Io(e.path[0]).origin}catch(n){return"null"}return e!="file"&&this.isSpecial()?e+"://"+fc(this.host)+(t!==null?":"+t:""):"null"},getProtocol:function(){return this.scheme+":"},setProtocol:function(e){this.parse(Hr(e)+":",Hm)},getUsername:function(){return this.username},setUsername:function(e){var t=ko(Hr(e));if(!this.cannotHaveUsernamePasswordPort()){this.username="";for(var n=0;n<t.length;n++)this.username+=Ii(t[n],Fm)}},getPassword:function(){return this.password},setPassword:function(e){var t=ko(Hr(e));if(!this.cannotHaveUsernamePasswordPort()){this.password="";for(var n=0;n<t.length;n++)this.password+=Ii(t[n],Fm)}},getHost:function(){var e=this.host,t=this.port;return e===null?"":t===null?fc(e):fc(e)+":"+t},setHost:function(e){this.cannotBeABaseURL||this.parse(e,Wm)},getHostname:function(){var e=this.host;return e===null?"":fc(e)},setHostname:function(e){this.cannotBeABaseURL||this.parse(e,Jm)},getPort:function(){var e=this.port;return e===null?"":Hr(e)},setPort:function(e){this.cannotHaveUsernamePasswordPort()||((e=Hr(e))==""?this.port=null:this.parse(e,qm))},getPathname:function(){var e=this.path;return this.cannotBeABaseURL?e[0]:e.length?"/"+dc(e,"/"):""},setPathname:function(e){this.cannotBeABaseURL||(this.path=[],this.parse(e,xo))},getSearch:function(){var e=this.query;return e?"?"+e:""},setSearch:function(e){(e=Hr(e))==""?this.query=null:(Gn(e,0)=="?"&&(e=hc(e,1)),this.query="",this.parse(e,fa)),this.searchParams.update()},getSearchParams:function(){return this.searchParams.facade},getHash:function(){var e=this.fragment;return e?"#"+e:""},setHash:function(e){(e=Hr(e))!=""?(Gn(e,0)=="#"&&(e=hc(e,1)),this.fragment="",this.parse(e,Gr)):this.fragment=null},update:function(){this.query=this.searchParams.serialize()||null}};var Io=function(e){var t=L6(this,dn),n=V6(arguments.length,1)>1?arguments[1]:void 0,i=j6(t,new Qm(e,!1,n));Lm||(t.href=i.serialize(),t.origin=i.getOrigin(),t.protocol=i.getProtocol(),t.username=i.getUsername(),t.password=i.getPassword(),t.host=i.getHost(),t.hostname=i.getHostname(),t.port=i.getPort(),t.pathname=i.getPathname(),t.search=i.getSearch(),t.searchParams=i.getSearchParams(),t.hash=i.getHash())},dn=Io.prototype,zn=function(e,t){return{get:function(){return Sl(this)[e]()},set:t&&function(n){return Sl(this)[t](n)},configurable:!0,enumerable:!0}};if(Lm&&(Hn(dn,"href",zn("serialize","setHref")),Hn(dn,"origin",zn("getOrigin")),Hn(dn,"protocol",zn("getProtocol","setProtocol")),Hn(dn,"username",zn("getUsername","setUsername")),Hn(dn,"password",zn("getPassword","setPassword")),Hn(dn,"host",zn("getHost","setHost")),Hn(dn,"hostname",zn("getHostname","setHostname")),Hn(dn,"port",zn("getPort","setPort")),Hn(dn,"pathname",zn("getPathname","setPathname")),Hn(dn,"search",zn("getSearch","setSearch")),Hn(dn,"searchParams",zn("getSearchParams")),Hn(dn,"hash",zn("getHash","setHash"))),bl(dn,"toJSON",function(){return Sl(this).serialize()},{enumerable:!0}),bl(dn,"toString",function(){return Sl(this).serialize()},{enumerable:!0}),lc){var wT=lc.createObjectURL,CT=lc.revokeObjectURL;wT&&bl(Io,"createObjectURL",cT(wT,lc)),CT&&bl(Io,"revokeObjectURL",cT(CT,lc))}U6(Io,"URL"),D6({global:!0,constructor:!0,forced:!O6,sham:!Lm},{URL:Io});var pa,El,r5=new Blob(["class VolumeMeter extends AudioWorkletProcessor{constructor(){super();this.volume=0;this.intervalTime=200;this.tick=this.intervalTime;this.isStop=false;this.port.onmessage=event=>{const{data}=event;switch(data.name){case'setIntervalTime':this.intervalTime=data.intervalTime;break;case'stop':this.isStop=true;break}}}process(inputs){const input=inputs[0];if(this.isStop){return false}if(input.length>0){const firstChannel=input[0];let sum=0;let rms;for(let i=0;i<firstChannel.length;++i){sum+=firstChannel[i]*firstChannel[i]}rms=Math.sqrt(sum/firstChannel.length);this.volume=Math.max(rms,this.volume*0.95);this.tick-=firstChannel.length;if(this.tick<0){this.tick+=(this.intervalTime/1000)*sampleRate;this.port.postMessage({volume:this.volume})}}return true}}registerProcessor('volume-meter',VolumeMeter);"],{type:"application/javascript"}),ET=!1,i5=function(){function e(n){Q(this,e),this.context_=n.context,this.addModuleToContext()}var t;return Ie(e,[{key:"addModuleToContext",value:(t=H(p().mark(function n(){return p().wrap(function(i){for(;;)switch(i.prev=i.next){case 0:return i.prev=0,i.next=3,this.context_.audioWorklet.addModule(URL.createObjectURL(r5));case 3:_e.info("worklet addModule success"),Y.emit($p),ET=!0,i.next=12;break;case 8:i.prev=8,i.t0=i.catch(0),_e.info("worklet addModule catch error. ".concat(i.t0.message)),Y.emit(Zp);case 12:case"end":return i.stop()}},n,this,[[0,8]])})),function(){return t.apply(this,arguments)})},{key:"initWorkletSuccess",get:function(){return ET}}]),e}(),mc=0,a5=function(){function e(t){Q(this,e);var n=t.track,i=t.log,r=t.stream;this.volume_=0,this.log_=i,this.track_=n,this.stream_=r,mc+=1,pa||(pa=FS()),this.audioCtx_=pa,this.destination_=this.audioCtx_.destination;var o=new MediaStream;o.addTrack(this.track_),this.streamSource_=this.audioCtx_.createMediaStreamSource(o),this.audioWorkletNode_=null,this.scriptProcessorNode_=null,this.interval_=200,Y.on(rc,this.resume,this),Y.on(Np,this.handleAudioLevelInterval,this),A4?(Y.on($p,this.initAudioWorklet,this),Y.on(Zp,this.initScriptProcessor,this),this.preload()):this.initScriptProcessor()}return Ie(e,[{key:"preload",value:function(){El?El.initWorkletSuccess&&this.initAudioWorklet():El=new i5({context:pa})}},{key:"initAudioWorklet",value:function(){var t=this;if(!this.audioWorkletNode_)try{this.audioWorkletNode_=new AudioWorkletNode(this.audioCtx_,"volume-meter"),this.audioWorkletNode_.port.onmessage=function(n){t.volume_=n.data.volume||0},this.streamSource_.connect(this.audioWorkletNode_).connect(this.destination_),this.handleAudioLevelInterval({interval:this.interval_})}catch(n){this.log_.warn("load volume meter failed, load again. error: "+n),this.initScriptProcessor()}}},{key:"initScriptProcessor",value:function(){var t=this;if(!this.scriptProcessorNode_)try{this.scriptProcessorNode_=this.audioCtx_.createScriptProcessor(2048,1,1),this.scriptProcessorNode_.onaudioprocess=function(n){for(var i=n.inputBuffer.getChannelData(0),r=0,o=0;o<i.length;++o)r+=i[o]*i[o];t.volume_=Math.sqrt(r/i.length)||0},this.streamSource_.connect(this.scriptProcessorNode_),this.scriptProcessorNode_.connect(this.destination_)}catch(n){this.log_.error("volumeMeter init script processor error: "+n),mc-=1}}},{key:"destroy",value:function(){var t;this.streamSource_&&this.streamSource_.disconnect(),this.scriptProcessorNode_&&(this.scriptProcessorNode_.onaudioprocess=null,this.scriptProcessorNode_.disconnect()),this.audioWorkletNode_&&(this.audioWorkletNode_.port.postMessage({name:"stop"}),this.audioWorkletNode_.port.onmessage=null,this.audioWorkletNode_.disconnect()),this.audioWorkletNode_=null,this.scriptProcessorNode_=null,this.audioCtx_=null,Y.off(rc,this.resume,this),Y.off(Np,this.handleAudioLevelInterval,this),Y.off($p,this.initAudioWorklet,this),Y.off(Zp,this.initScriptProcessor,this),mc>0&&(mc-=1),mc===0&&((t=pa)===null||t===void 0||t.close(),pa=null,El=null)}},{key:"resume",value:function(){var t;(t=pa)===null||t===void 0||t.resume()}},{key:"getInternalAudioLevel",value:function(){return this.volume_}},{key:"getCalculatedVolume",value:function(){return this.volume_.toFixed(2)}},{key:"handleAudioLevelInterval",value:function(t){var n,i=t.interval;this.interval_=i,(n=this.audioWorkletNode_)===null||n===void 0||n.port.postMessage({name:"setIntervalTime",intervalTime:i})}}]),e}(),o5=function(){function e(o){Q(this,e),this.stream_=o.stream,this.userId_=o.stream.getUserId(),this.log_=this.stream_.getLogger(),this.track_=o.track,o.gainedTrack&&(this.gainedTrack_=o.gainedTrack),this.div_=o.div,this.muted_=o.muted,this.outputDeviceId_=o.outputDeviceId,this.volume_=o.volume,this.pausedRetryCount_=5,this.emitter_=new Si,this.initializeElement(),this.state_="NONE",this.volumeMeter_=new a5({stream:this.stream_,track:this.gainedTrack_||this.track_,log:this.log_})}var t,n,i,r;return Ie(e,[{key:"isPlaying",get:function(){return this.state_===ao}},{key:"initializeElement",value:function(){if(this.isAudioElementInit()){var o=new MediaStream;o.addTrack(this.gainedTrack_||this.track_);var c=document.createElement(Ee);c.srcObject=o,c.muted=this.muted_,c.setAttribute("id","audio_".concat(this.stream_.getId())),c.setAttribute("autoplay","autoplay"),c.setAttribute("playsinline","playsinline"),this.div_.appendChild(c),this.element_=c}this.handleEvents()}},{key:"setMuted",value:function(o){this.element_&&(this.element_.muted=o,this.muted_=o)}},{key:"play",value:(r=H(p().mark(function o(){var c;return p().wrap(function(a){for(;;)switch(a.prev=a.next){case 0:if(!this.outputDeviceId_||!this.element_){a.next=3;break}return a.next=3,this.element_.setSinkId(this.outputDeviceId_);case 3:if(this.setVolume(this.volume_),a.prev=4,!this.element_){a.next=8;break}return a.next=8,this.element_.play();case 8:a.next=16;break;case 10:if(a.prev=10,a.t0=a.catch(4),c=ae({key:np,data:{media:"Audio",error:a.t0}}),this.log_.warn(c),!c.includes("NotAllowedError")){a.next=16;break}throw new te({code:Z.PLAY_NOT_ALLOWED,message:c});case 16:case"end":return a.stop()}},o,this,[[4,10]])})),function(){return r.apply(this,arguments)})},{key:"handleEvents",value:function(){this.handleElementEvent=this.handleElementEvent.bind(this),this.handleTrackEvent=this.handleTrackEvent.bind(this),this.element_&&(this.element_.addEventListener(di,this.handleElementEvent),this.element_.addEventListener(Nt,this.handleElementEvent),this.element_.addEventListener(hi,this.handleElementEvent),this.element_.addEventListener(io,this.handleElementEvent)),this.track_.addEventListener(Nt,this.handleTrackEvent),this.track_.addEventListener(tn,this.handleTrackEvent),this.track_.addEventListener(Sr,this.handleTrackEvent),this.track_.readyState===Nt&&this.handleTrackEvent({type:Nt}),this.track_.muted&&this.handleTrackEvent({type:tn})}},{key:"handleElementEvent",value:(i=H(p().mark(function o(c){var a,s,l,u,f,S,x,E=this;return p().wrap(function(I){for(;;)switch(I.prev=I.next){case 0:a=c.type,I.t0=a,I.next=I.t0===di?4:I.t0===Nt?9:I.t0===hi?12:I.t0===io?21:33;break;case 4:return this.log_.info("audio player is playing"),this.state_=ao,Y.emit(Vp,{stream:this.stream_}),this.emitter_.emit(gn,{state:this.state_,reason:di}),I.abrupt("break",33);case 9:return this.log_.info("audio player is ended"),this.state_!==fi&&(this.state_=fi,this.emitter_.emit(gn,{state:this.state_,reason:Nt})),I.abrupt("break",33);case 12:return this.log_.info("audio player is paused"),this.state_=kr,this.emitter_.emit(gn,{state:this.state_,reason:hi}),(s=this.div_&&document.getElementById(this.div_.id))||this.log_.warn("audio player has been remove, element ID: ".concat(this.div_.id)),l=lo(),this.pausedRetryCount_>0&&(tr(l)&&l<=70||!s)&&(this.resume(),this.pausedRetryCount_--),gi&&(this.interval_=mt.run(function(){E.element_&&E.state_===kr&&E.resume()},{delay:3e3})),I.abrupt("break",33);case 21:if(!this.element_||!this.element_.error){I.next=32;break}return u="".concat(Im(),"/").concat(aa().name,"/").concat(aa().version),I.next=25,xt.getSpeakers();case 25:f=I.sent,S=f[0].label,(x=f.find(function(m){return m.deviceId===E.outputDeviceId_}))&&(S=x.label),this.log_.error("audio player error observed. code: ".concat(this.element_.error.code," message: ").concat(this.element_.error.message," deviceInfo: ").concat(u," speaker: ").concat(S)),ke.uploadEvent({log:"stat-".concat(this.stream_.getType(),"-audio-").concat(Bb,"-").concat(this.element_.error.code,"-").concat(u,"-").concat(S),userId:this.userId_,error:this.element_.error}),this.emitter_.emit(Jk,this.element_.error);case 32:return I.abrupt("break",33);case 33:case"end":return I.stop()}},o,this)})),function(o){return i.apply(this,arguments)})},{key:"handleTrackEvent",value:function(o){var c=o.type;switch(c){case Nt:this.log_.info("audio track is ended"),this.state_!==fi&&(this.state_=fi,this.emitter_.emit(gn,{state:this.state_,reason:Nt})),Y.emit(Xp,{stream:this.stream_,type:c});break;case tn:this.log_.info("audio track is unable to provide media output"),this.stream_.isRemote()||BS(),this.state_!==kr&&(this.state_=kr,this.emitter_.emit(gn,{state:this.state_,reason:tn})),Y.emit(Kp,{stream:this.stream_,type:c});break;case Sr:this.log_.info("audio track is able to provide media output"),this.state_===kr&&(this.state_=ao,this.emitter_.emit(gn,{state:this.state_,reason:Sr}))}}},{key:"unbindEvents",value:function(){this.element_&&(this.element_.removeEventListener(di,this.handleElementEvent),this.element_.removeEventListener(Nt,this.handleElementEvent),this.element_.removeEventListener(hi,this.handleElementEvent),this.element_.removeEventListener(io,this.handleElementEvent)),this.track_&&(this.track_.removeEventListener(Nt,this.handleTrackEvent),this.track_.removeEventListener(tn,this.handleTrackEvent),this.track_.removeEventListener(Sr,this.handleTrackEvent))}},{key:"setSinkId",value:(n=H(p().mark(function o(c){return p().wrap(function(a){for(;;)switch(a.prev=a.next){case 0:if(this.outputDeviceId_===c){a.next=5;break}if(!this.element_){a.next=4;break}return a.next=4,this.element_.setSinkId(c);case 4:this.outputDeviceId_=c;case 5:case"end":return a.stop()}},o,this)})),function(o){return n.apply(this,arguments)})},{key:"setVolume",value:function(o){this.element_&&(this.log_.info("audioElement setVolume to : ".concat(o)),this.element_.volume=o)}},{key:"getAudioLevel",value:function(){return this.volumeMeter_.getCalculatedVolume()}},{key:"getInternalAudioLevel",value:function(){return this.volumeMeter_.getInternalAudioLevel()}},{key:"stop",value:function(){this.unbindEvents(),this.element_&&(this.div_.removeChild(this.element_),this.element_.srcObject=null,this.element_=null),this.volumeMeter_&&(this.volumeMeter_.destroy(),this.volumeMeter_=null),this.interval_>0&&mt.clearTask(this.interval_)}},{key:"resume",value:(t=H(p().mark(function o(){var c;return p().wrap(function(a){for(;;)switch(a.prev=a.next){case 0:if(a.prev=0,this.volumeMeter_&&this.volumeMeter_.resume(),!this.element_){a.next=5;break}return a.next=5,this.element_.play();case 5:a.next=13;break;case 7:if(a.prev=7,a.t0=a.catch(0),c=ae({key:np,data:{media:"Audio",error:a.t0}}),this.log_.warn(c),!c.includes("NotAllowedError")){a.next=13;break}throw new te({code:Z.PLAY_NOT_ALLOWED,message:c});case 13:case"end":return a.stop()}},o,this,[[0,7]])})),function(){return t.apply(this,arguments)})},{key:"on",value:function(o,c){this.emitter_.on(o,c)}},{key:"isAudioElementInit",value:function(){return!(_i==="15.2"||_i==="15.3"||_i==="15.4")||this.stream_.getType()!=="local"||!this.muted_||(this.log_.info("audioElement is muted."),!1)}},{key:"getTrack",value:function(){return this.track_}}]),e}(),s5=Yn.PROPER,c5=ue,RT=s0,u5=Au.trim;Le({target:"String",proto:!0,forced:function(e){return c5(function(){return!!RT[e]()||"\u200B\x85\u180E"[e]()!=="\u200B\x85\u180E"||s5&&RT[e].name!==e})}("trim")},{trim:function(){return u5(this)}});var zr="trtc_autoplay",Ym="".concat(zr,"_mask"),wo="".concat(zr,"_wrapper"),AT="".concat(zr,"_header"),$m="".concat(zr,"_content"),Rl="".concat(zr,"_action_wrapper"),Zm="".concat(zr,"_question"),ev="".concat(zr,"_collapse"),Al="".concat(zr,"_action_confirm"),PT="".concat(zr,"_detail"),DT="#2473E8",tv="dialog",l5="".concat(tv,"-show"),d5="".concat(tv,"-1"),h5="".concat(tv,"-2"),OT=!1,LT=function(){return!!document.querySelector(".".concat(wo))},MT="".concat(co,"/").concat(oa()?"zh-cn":"en","/tutorial-21-advanced-auto-play-policy.html"),NT="<br><a href='".concat(MT,"' target='_blank'>").concat(oa()?"\u5176\u4ED6\u65B9\u6848\uFF1F":"Any other solution?","</a>"),f5="".concat(oa()?"\u6D4F\u89C8\u5668\u81EA\u52A8\u64AD\u653E\u7B56\u7565\uFF1A\u5728\u7528\u6237\u4E0E\u9875\u9762\u4EA7\u751F\u4EA4\u4E92\uFF08\u70B9\u51FB\u3001\u89E6\u6478\uFF09\u4E4B\u524D\uFF0C\u6D4F\u89C8\u5668\u7981\u6B62\u64AD\u653E\u6709\u58F0\u5A92\u4F53\u3002\u8BE5\u5F39\u7A97\u7528\u4E8E\u5E2E\u52A9\u7528\u6237\u6062\u590D\u97F3\u89C6\u9891\u64AD\u653E\u3002".concat(NT):"Autoplay Policy: Before user interacts with the web page (clicking, touching), page will not be allowed to play media with sound. This Dialog is used to help users resume playback. ".concat(NT)),UT=function(){function e(){if(Q(this,e),this.dialogNode_=null,this.bodyPosition_="",this.content="\u97F3\u89C6\u9891\u64AD\u653E\u88AB\u6D4F\u89C8\u5668\u62E6\u622A\uFF0C\u8BF7\u70B9\u51FB\u201C\u6062\u590D\u64AD\u653E\u201D\u3002",oa()||(this.content='Media playback failed. Click the "Resume" to resume playback.'),!OT){var t=document.createElement("style");t.innerHTML=".".concat(Ym,"{position:fixed;top:0;left:0;right:0;bottom:0;width:100vw;height:100vh;display:flex;justify-content:center;align-items:center;background:rgba(0,0,0,0.5);z-index:1500;}.").concat(Ym," div:not(.").concat(Rl,"){display:block !important;}.").concat(wo,"{padding:14px;background:#fff;border-radius:3px;box-shadow:0px 3px 15px #434343;border:1px solid #d1cfcf;max-width:500px;}.").concat(wo," a{color:").concat(DT,";}.").concat(AT,"{overflow:hidden;text-overflow:ellipsis;font-size:16px;font-weight:600;}.").concat($m,"{margin:8px 0;}.").concat(Rl,"{width:100%;display:flex !important;align-items:center;justify-content:right;float:right;}.").concat(ev,"{margin-right:auto;cursor:pointer}.").concat(Zm,"{height:100%;line-height:16px;cursor:pointer;}.").concat(Al,"{margin-left:8px;color:#fff;background:").concat(DT,";padding:4px 12px;outline:none;border:1px solid;border-radius:3px;font-weight:bold;}.").concat(Al,":hover{opacity:0.9;}.").concat(ev,",.").concat(Al,",.").concat($m,",.").concat(Zm,"{font-size:14px;}@media screen and (max-width:750px){.").concat(wo,"{width:80vw;}}"),document.head.appendChild(t),OT=!0}this.showDetail_=!1,this.isCollapseClicked_=!1,this.isQuestionClicked_=!1,this.addDiaLog()}return Ie(e,[{key:"createDiaLog",value:function(){var t=document.createElement("template");t.innerHTML='<div class="'.concat(Ym,`"><div class='`).concat(wo,"'><div class='").concat(AT,"'>").concat(location.host,"</div><div class='").concat($m,"'>").concat(this.content,"</div><div class='").concat(PT,`' style="visibility:hidden;width:100%;height:0;font-size:12px;color:gray;">`).concat(f5,"</div><div class='").concat(Rl,"'></div></div></div>").trim();var n=document.createElement("button");n.className=Al,n.innerText=oa()?"\u6062\u590D\u64AD\u653E":"Resume",n.onclick=this.onConfirm.bind(this);var i=document.createElement("div");i.className=Zm,i.innerHTML=`<?xml version="1.0" encoding="UTF-8"?>
|
|
93
57
|
<svg class="icon" width="18" height="18" p-id="2030" t="1639646523624" version="1.1" viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg">
|
|
94
58
|
<path d="m464 784.35c0 26.51 21.49 48 48 48s48-21.49 48-48-21.49-48-48-48-48 21.49-48 48z" p-id="2031"/>
|
|
95
59
|
<path d="m512 960c-247.04 0-448-200.96-448-448s200.96-448 448-448 448 200.96 448 448-200.96 448-448 448zm0-831.71c-211.58 0-383.71 172.13-383.71 383.71 0 211.55 172.13 383.71 383.71 383.71 211.55 0 383.71-172.16 383.71-383.71 0-211.58-172.16-383.71-383.71-383.71z" p-id="2032"/>
|
|
96
60
|
<path d="m512 673.7c-17.665 0-32.001-14.336-32.001-31.999v-54.112c0-52.353 40-92.352 75.328-127.65 25.887-25.92 52.672-52.672 52.672-74.017 0-53.343-43.072-96.735-95.999-96.735-53.823 0-95.999 41.536-95.999 94.559 0 17.665-14.336 31.999-32.001 31.999s-32.001-14.336-32.001-31.999c0-87.424 71.775-158.56 160-158.56s160 72.095 160 160.74c0 47.904-36.32 84.192-71.424 119.3-27.84 27.776-56.576 56.512-56.576 82.336v54.112c0 17.665-14.336 32.032-32.001 32.032z" p-id="2033"/>
|
|
97
61
|
</svg>
|
|
98
|
-
`,a.onclick=this.onQuestionClick.bind(this);var i=document.createElement("div");i.className=Zm,i.innerText="".concat(ma()?"\u8BE6\u60C5 >":"Detail >"),i.onclick=this.onCollapseClick.bind(this);var r=t.content.firstChild,o=r.querySelector(".".concat(Pl));return o.appendChild(i),o.appendChild(a),o.appendChild(n),r}},{key:"addDiaLog",value:function(){DT()||(this.dialogNode_=this.createDiaLog(),document.body.appendChild(this.dialogNode_),this.dialogNode_.onclick=this.onConfirm.bind(this),this.dialogNode_.querySelector(".".concat(Lo)).onclick=function(t){return t.stopPropagation()},this.bodyPosition_=document.body.style.position,document.body.style.position="fixed",_e.info("show autoplay dialog"),Ie.uploadEvent({log:s5}))}},{key:"deleteDiaLog",value:function(){this.dialogNode_&&(document.body.removeChild(this.dialogNode_),document.body.style.position=this.bodyPosition_,this.dialogNode_=null)}},{key:"onConfirm",value:function(){_e.warn("confirm clicked, try resume stream"),X.emit(lc),this.deleteDiaLog()}},{key:"onCollapseClick",value:function(){var t=this.dialogNode_.querySelector(".".concat(RT));t.style.visibility="".concat(this.showDetail_?"hidden":"visible"),t.style.height="".concat(this.showDetail_?0:"fit-content"),this.showDetail_=!this.showDetail_,this.isCollapseClicked_||Ie.uploadEvent({log:c5}),this.isCollapseClicked_=!0}},{key:"onQuestionClick",value:function(){window.open(LT,"_blank"),this.isQuestionClicked_||Ie.uploadEvent({log:u5}),this.isQuestionClicked_=!0}}]),e}(),NT=function(){function e(n){K(this,e),this.stream_=n.stream,this.userId_=n.stream.getUserId(),this.log_=this.stream_.getLogger(),this.track_=n.track,this.div_=n.div,this.muted_=n.muted,this.objectFit_=n.objectFit,this.mirror_=n.mirror,this.emitter_=new Ri,this.initializeElement(),this.state_="NONE",this.pausedRetryCount_=5}var t;return we(e,[{key:"isPlaying",get:function(){return this.state_===ho}},{key:"initializeElement",value:function(){var n=new MediaStream;n.addTrack(this.track_);var a=document.createElement(xe);a.srcObject=n,a.muted=!0;var i="width: 100%; height: 100%; object-fit: ".concat(this.objectFit_,";");this.mirror_&&(i+="transform: scaleX(-1);"),a.setAttribute("id","video_".concat(this.stream_.getId())),a.setAttribute("style",i),a.setAttribute("autoplay","autoplay"),a.setAttribute("playsinline","playsinline"),this.div_&&this.div_.appendChild(a),this.element_=a,this.handleEvents()}},{key:"setRect",value:function(n){var a=n.width,i=n.height;this.element_&&(this.element_.style.width=a+"px",this.element_.style.height=i+"px")}},{key:"setMirror",value:function(n){this.element_&&(this.element_.style.transform=n?"scaleX(-1)":"",this.mirror_=n)}},{key:"setObjectFit",value:function(n){this.element_&&(this.element_.style.objectFit="".concat(n),this.objectFit_=n)}},{key:"play",value:(t=G(m().mark(function n(){var a;return m().wrap(function(i){for(;;)switch(i.prev=i.next){case 0:return i.prev=0,i.next=3,this.element_.play();case 3:i.next=11;break;case 5:if(i.prev=5,i.t0=i.catch(0),a=ie({key:nf,data:{media:"Video",error:i.t0}}),this.log_.warn(a),!a.includes("NotAllowedError")){i.next=11;break}throw new re({code:ee.PLAY_NOT_ALLOWED,message:a});case 11:case"end":return i.stop()}},n,this,[[0,5]])})),function(){return t.apply(this,arguments)})},{key:"handleEvents",value:function(){this.handleElementEvent=this.handleElementEvent.bind(this),this.handleTrackEvent=this.handleTrackEvent.bind(this),this.element_.addEventListener(yi,this.handleElementEvent),this.element_.addEventListener(Nt,this.handleElementEvent),this.element_.addEventListener(bi,this.handleElementEvent),this.element_.addEventListener(lo,this.handleElementEvent),this.element_.addEventListener(Op,this.handleElementEvent),this.track_.addEventListener(Nt,this.handleTrackEvent),this.track_.addEventListener(Zt,this.handleTrackEvent),this.track_.addEventListener(_r,this.handleTrackEvent),this.track_.readyState===Nt&&this.handleTrackEvent({type:Nt}),this.track_.muted&&this.handleTrackEvent({type:Zt})}},{key:"handleElementEvent",value:function(n){var a=this;switch(n.type){case yi:this.log_.info("video player is playing"),this.state_=ho,X.emit(cc,{stream:this.stream_}),this.emitter_.emit(bn,{state:this.state_,reason:yi}),this.interval_&&(_t.clearTask(this.interval_),this.interval_=null);break;case Nt:this.log_.info("video player is ended"),this.state_!==Si&&(this.state_=Si,this.emitter_.emit(bn,{state:this.state_,reason:Nt}));break;case bi:this.log_.info("video player is paused"),this.div_&&!document.getElementById(this.div_.id)&&this.log_.warn("video player has been remove, element ID: ".concat(this.div_.id)),this.state_=yr,this.emitter_.emit(bn,{state:this.state_,reason:bi}),this.pausedRetryCount_>0&&!DT()&&(this.log_.info("video player auto resume when video paused"),this.resume(),this.pausedRetryCount_--),Ii&&(this.interval_=_t.run(function(){a.element_&&a.state_===yr&&a.resume()},{delay:3e3}));break;case lo:if(this.element_&&this.element_.error){var i="".concat(xm(),"/").concat(fa().name,"/").concat(fa().version);this.log_.error("video player error observed. code: ".concat(this.element_.error.code," message: ").concat(this.element_.error.message," deviceInfo: ").concat(i)),Ie.uploadEvent({log:"stat-".concat(this.stream_.getType(),"-video-").concat(Hb,"-").concat(this.element_.error.code,"-").concat(i),userId:this.userId_,error:this.element_.error})}break;case Op:X.emit(qf,{stream:this.stream_})}}},{key:"handleTrackEvent",value:function(n){var a=n.type;switch(a){case Nt:this.log_.info("video track is ended"),X.emit(Kf,{stream:this.stream_,type:a}),this.state_!==Si&&(this.state_=Si,this.emitter_.emit(bn,{state:this.state_,reason:Nt}));break;case Zt:this.log_.info("video track is unable to provide media output"),this.stream_.isRemote()||FS(),X.emit(uc,{stream:this.stream_,type:a}),this.state_!==yr&&(this.state_=yr,this.emitter_.emit(bn,{state:this.state_,reason:Zt}));break;case _r:this.log_.info("video track is able to provide media output"),X.emit(zf,{stream:this.stream_}),this.state_===yr&&(this.state_=ho,this.emitter_.emit(bn,{state:this.state_,reason:_r}))}}},{key:"unbindEvents",value:function(){this.element_&&(this.element_.removeEventListener(yi,this.handleElementEvent),this.element_.removeEventListener(Nt,this.handleElementEvent),this.element_.removeEventListener(bi,this.handleElementEvent),this.element_.removeEventListener(lo,this.handleElementEvent),this.element_.removeEventListener(Op,this.handleElementEvent)),this.track_&&(this.track_.removeEventListener(Nt,this.handleTrackEvent),this.track_.removeEventListener(Zt,this.handleTrackEvent),this.track_.removeEventListener(_r,this.handleTrackEvent))}},{key:"stop",value:function(){this.unbindEvents(),this.div_&&this.div_.removeChild(this.element_),this.element_.srcObject=null,this.element_=null,this.interval_&&_t.clearTask(this.interval_)}},{key:"resume",value:function(){return this.play()}},{key:"getVideoFrame",value:function(){var n=document.createElement("canvas");return n.width=this.element_.videoWidth,n.height=this.element_.videoHeight,n.getContext("2d").drawImage(this.element_,0,0),n.toDataURL("image/png")}},{key:"on",value:function(n,a){this.emitter_.on(n,a)}},{key:"getElement",value:function(){return this.element_?this.element_:null}}]),e}(),tv=typeof ArrayBuffer!="undefined"&&typeof DataView!="undefined",d5=Yn,h5=vr,p5=RangeError,UT=function(e){if(e===void 0)return 0;var t=d5(e),n=h5(t);if(t!==n)throw p5("Wrong length or index");return n},f5=Array,m5=Math.abs,$r=Math.pow,v5=Math.floor,g5=Math.log,_5=Math.LN2,y5={pack:function(e,t,n){var a,i,r,o=f5(n),s=8*n-t-1,c=(1<<s)-1,u=c>>1,d=t===23?$r(2,-24)-$r(2,-77):0,g=e<0||e===0&&1/e<0?1:0,I=0;for((e=m5(e))!=e||e===1/0?(i=e!=e?1:0,a=c):(a=v5(g5(e)/_5),e*(r=$r(2,-a))<1&&(a--,r*=2),(e+=a+u>=1?d/r:d*$r(2,1-u))*r>=2&&(a++,r/=2),a+u>=c?(i=0,a=c):a+u>=1?(i=(e*r-1)*$r(2,t),a+=u):(i=e*$r(2,u-1)*$r(2,t),a=0));t>=8;)o[I++]=255&i,i/=256,t-=8;for(a=a<<t|i,s+=t;s>0;)o[I++]=255&a,a/=256,s-=8;return o[--I]|=128*g,o},unpack:function(e,t){var n,a=e.length,i=8*a-t-1,r=(1<<i)-1,o=r>>1,s=i-7,c=a-1,u=e[c--],d=127&u;for(u>>=7;s>0;)d=256*d+e[c--],s-=8;for(n=d&(1<<-s)-1,d>>=-s,s+=t;s>0;)n=256*n+e[c--],s-=8;if(d===0)d=1-o;else{if(d===r)return n?NaN:u?-1/0:1/0;n+=$r(2,t),d-=o}return(u?-1:1)*n*$r(2,d-t)}},b5=Ut,VT=hi,S5=nn,jT=function(e){for(var t=b5(this),n=S5(t),a=arguments.length,i=VT(a>1?arguments[1]:void 0,n),r=a>2?arguments[2]:void 0,o=r===void 0?n:VT(r,n);o>i;)t[i++]=e;return t},Ll=se,nv=ke,rv=Se,k5=tv,BT=Ur,FT=gn,GT=Us,iv=ce,Ol=fi,T5=Yn,x5=vr,Ml=UT,HT=y5,I5=As,zT=Ja,w5=di.f,E5=At.f,C5=jT,R5=vu,WT=ea,A5=BT.PROPER,qT=BT.CONFIGURABLE,Oo=st.get,JT=st.set,av="ArrayBuffer",P5="DataView",KT="Wrong index",Hn=Ll.ArrayBuffer,ir=Hn,Mo=ir&&ir.prototype,Ir=Ll.DataView,Ta=Ir&&Ir.prototype,XT=Object.prototype,D5=Ll.Array,Nl=Ll.RangeError,L5=nv(C5),O5=nv([].reverse),QT=HT.pack,YT=HT.unpack,$T=function(e){return[255&e]},ZT=function(e){return[255&e,e>>8&255]},e1=function(e){return[255&e,e>>8&255,e>>16&255,e>>24&255]},t1=function(e){return e[3]<<24|e[2]<<16|e[1]<<8|e[0]},M5=function(e){return QT(e,23,4)},N5=function(e){return QT(e,52,8)},Ul=function(e,t){E5(e.prototype,t,{get:function(){return Oo(this)[t]}})},Oi=function(e,t,n,a){var i=Ml(n),r=Oo(e);if(i+t>r.byteLength)throw Nl(KT);var o=Oo(r.buffer).bytes,s=i+r.byteOffset,c=R5(o,s,s+t);return a?c:O5(c)},Mi=function(e,t,n,a,i,r){var o=Ml(n),s=Oo(e);if(o+t>s.byteLength)throw Nl(KT);for(var c=Oo(s.buffer).bytes,u=o+s.byteOffset,d=a(+i),g=0;g<t;g++)c[u+g]=d[r?g:t-g-1]};if(k5){var n1=A5&&Hn.name!==av;if(iv(function(){Hn(1)})&&iv(function(){new Hn(-1)})&&!iv(function(){return new Hn,new Hn(1.5),new Hn(NaN),Hn.length!=1||n1&&!qT}))n1&&qT&&FT(Hn,"name",av);else{(ir=function(e){return Ol(this,Mo),new Hn(Ml(e))}).prototype=Mo;for(var ov,r1=w5(Hn),i1=0;r1.length>i1;)(ov=r1[i1++])in ir||FT(ir,ov,Hn[ov]);Mo.constructor=ir}zT&&I5(Ta)!==XT&&zT(Ta,XT);var Vl=new Ir(new ir(2)),a1=nv(Ta.setInt8);Vl.setInt8(0,2147483648),Vl.setInt8(1,2147483649),!Vl.getInt8(0)&&Vl.getInt8(1)||GT(Ta,{setInt8:function(e,t){a1(this,e,t<<24>>24)},setUint8:function(e,t){a1(this,e,t<<24>>24)}},{unsafe:!0})}else Mo=(ir=function(e){Ol(this,Mo);var t=Ml(e);JT(this,{bytes:L5(D5(t),0),byteLength:t}),rv||(this.byteLength=t)}).prototype,Ir=function(e,t,n){Ol(this,Ta),Ol(e,Mo);var a=Oo(e).byteLength,i=T5(t);if(i<0||i>a)throw Nl("Wrong offset");if(i+(n=n===void 0?a-i:x5(n))>a)throw Nl("Wrong length");JT(this,{buffer:e,byteLength:n,byteOffset:i}),rv||(this.buffer=e,this.byteLength=n,this.byteOffset=i)},Ta=Ir.prototype,rv&&(Ul(ir,"byteLength"),Ul(Ir,"buffer"),Ul(Ir,"byteLength"),Ul(Ir,"byteOffset")),GT(Ta,{getInt8:function(e){return Oi(this,1,e)[0]<<24>>24},getUint8:function(e){return Oi(this,1,e)[0]},getInt16:function(e){var t=Oi(this,2,e,arguments.length>1?arguments[1]:void 0);return(t[1]<<8|t[0])<<16>>16},getUint16:function(e){var t=Oi(this,2,e,arguments.length>1?arguments[1]:void 0);return t[1]<<8|t[0]},getInt32:function(e){return t1(Oi(this,4,e,arguments.length>1?arguments[1]:void 0))},getUint32:function(e){return t1(Oi(this,4,e,arguments.length>1?arguments[1]:void 0))>>>0},getFloat32:function(e){return YT(Oi(this,4,e,arguments.length>1?arguments[1]:void 0),23)},getFloat64:function(e){return YT(Oi(this,8,e,arguments.length>1?arguments[1]:void 0),52)},setInt8:function(e,t){Mi(this,1,e,$T,t)},setUint8:function(e,t){Mi(this,1,e,$T,t)},setInt16:function(e,t){Mi(this,2,e,ZT,t,arguments.length>2?arguments[2]:void 0)},setUint16:function(e,t){Mi(this,2,e,ZT,t,arguments.length>2?arguments[2]:void 0)},setInt32:function(e,t){Mi(this,4,e,e1,t,arguments.length>2?arguments[2]:void 0)},setUint32:function(e,t){Mi(this,4,e,e1,t,arguments.length>2?arguments[2]:void 0)},setFloat32:function(e,t){Mi(this,4,e,M5,t,arguments.length>2?arguments[2]:void 0)},setFloat64:function(e,t){Mi(this,8,e,N5,t,arguments.length>2?arguments[2]:void 0)}});WT(ir,av),WT(Ir,P5);var Tc={ArrayBuffer:ir,DataView:Ir},U5=Ue,sv=ke,V5=ce,o1=yt,s1=hi,j5=vr,B5=Uu,cv=Tc.ArrayBuffer,uv=Tc.DataView,c1=uv.prototype,u1=sv(cv.prototype.slice),F5=sv(c1.getUint8),G5=sv(c1.setUint8);U5({target:"ArrayBuffer",proto:!0,unsafe:!0,forced:V5(function(){return!new cv(2).slice(1,void 0).byteLength})},{slice:function(e,t){if(u1&&t===void 0)return u1(o1(this),e);for(var n=o1(this).byteLength,a=s1(e,n),i=s1(t===void 0?n:t,n),r=new(B5(this,cv))(j5(i-a)),o=new uv(this),s=new uv(r),c=0;a<i;)G5(s,c++,F5(o,a++));return r}}),Ue({global:!0,constructor:!0,forced:!tv},{DataView:Tc.DataView});var H5=Ue,z5=Xa,W5=ke([].reverse),l1=[1,2];H5({target:"Array",proto:!0,forced:String(l1)===String(l1.reverse())},{reverse:function(){return z5(this)&&(this.length=this.length),W5(this)}});var q5=vn,J5=Ut,K5=zt,X5=nn,Q5=TypeError,d1=function(e){return function(t,n,a,i){q5(n);var r=J5(t),o=K5(r),s=X5(r),c=e?s-1:0,u=e?-1:1;if(a<2)for(;;){if(c in o){i=o[c],c+=u;break}if(c+=u,e?c<0:s<=c)throw Q5("Reduce of empty array with no initial value")}for(;e?c>=0:s>c;c+=u)c in o&&(i=n(i,o[c],c,r));return i}},lv={left:d1(!1),right:d1(!0)},Y5=lv.left,h1=mn,$5=Ks;Ue({target:"Array",proto:!0,forced:!Hs("reduce")||!$5&&h1>79&&h1<83},{reduce:function(e){var t=arguments.length;return Y5(this,e,t,t>1?arguments[1]:void 0)}});var Z5=Vs,ej="ArrayBuffer",p1=Tc.ArrayBuffer;Ue({global:!0,constructor:!0,forced:se.ArrayBuffer!==p1},{ArrayBuffer:p1}),Z5(ej);var tj=Ue,f1=Xa,nj=Tu,rj=vt,m1=hi,ij=nn,aj=pn,oj=Os,sj=at,cj=Ka,uj=Gs("slice"),lj=sj("species"),dv=Array,dj=Math.max;tj({target:"Array",proto:!0,forced:!uj},{slice:function(e,t){var n,a,i,r=aj(this),o=ij(r),s=m1(e,o),c=m1(t===void 0?o:t,o);if(f1(r)&&(n=r.constructor,(nj(n)&&(n===dv||f1(n.prototype))||rj(n)&&(n=n[lj])===null)&&(n=void 0),n===dv||n===void 0))return cj(r,s,c);for(a=new(n===void 0?dv:n)(dj(c-s,0)),i=0;s<c;s++,i++)s in r&&oj(a,i,r[s]);return a.length=i,a}});var v1=se,hj=ce,pj=ke,fj=Ft,mj=Ou.trim,g1=l0,xc=v1.parseInt,_1=v1.Symbol,y1=_1&&_1.iterator,b1=/^[+-]?0x/i,vj=pj(b1.exec),S1=xc(g1+"08")!==8||xc(g1+"0x16")!==22||y1&&!hj(function(){xc(Object(y1))})?function(e,t){var n=mj(fj(e));return xc(n,t>>>0||(vj(b1,n)?16:10))}:xc;Ue({global:!0,forced:parseInt!=S1},{parseInt:S1});var Sn,No,jl,hv={exports:{}},gj=tv,pv=Se,hn=se,k1=tt,Bl=vt,Ni=rt,fv=jr,_j=ai,yj=gn,mv=qt,bj=At.f,Sj=dr,Fl=As,Uo=Ja,kj=at,Tj=ci,T1=st.enforce,xj=st.get,Gl=hn.Int8Array,vv=Gl&&Gl.prototype,x1=hn.Uint8ClampedArray,I1=x1&&x1.prototype,wr=Gl&&Fl(Gl),ar=vv&&Fl(vv),Ij=Object.prototype,gv=hn.TypeError,w1=kj("toStringTag"),_v=Tj("TYPED_ARRAY_TAG"),wj="TypedArrayConstructor",Zr=gj&&!!Uo&&fv(hn.opera)!=="Opera",E1=!1,ei={Int8Array:1,Uint8Array:1,Uint8ClampedArray:1,Int16Array:2,Uint16Array:2,Int32Array:4,Uint32Array:4,Float32Array:4,Float64Array:8},yv={BigInt64Array:8,BigUint64Array:8},C1=function(e){var t=Fl(e);if(Bl(t)){var n=xj(t);return n&&Ni(n,wj)?n.TypedArrayConstructor:C1(t)}},R1=function(e){if(!Bl(e))return!1;var t=fv(e);return Ni(ei,t)||Ni(yv,t)};for(Sn in ei)(jl=(No=hn[Sn])&&No.prototype)?T1(jl).TypedArrayConstructor=No:Zr=!1;for(Sn in yv)(jl=(No=hn[Sn])&&No.prototype)&&(T1(jl).TypedArrayConstructor=No);if((!Zr||!k1(wr)||wr===Function.prototype)&&(wr=function(){throw gv("Incorrect invocation")},Zr))for(Sn in ei)hn[Sn]&&Uo(hn[Sn],wr);if((!Zr||!ar||ar===Ij)&&(ar=wr.prototype,Zr))for(Sn in ei)hn[Sn]&&Uo(hn[Sn].prototype,ar);if(Zr&&Fl(I1)!==ar&&Uo(I1,ar),pv&&!Ni(ar,w1))for(Sn in E1=!0,bj(ar,w1,{get:function(){return Bl(this)?this[_v]:void 0}}),ei)hn[Sn]&&yj(hn[Sn],_v,Sn);var ze={NATIVE_ARRAY_BUFFER_VIEWS:Zr,TYPED_ARRAY_TAG:E1&&_v,aTypedArray:function(e){if(R1(e))return e;throw gv("Target is not a typed array")},aTypedArrayConstructor:function(e){if(k1(e)&&(!Uo||Sj(wr,e)))return e;throw gv(_j(e)+" is not a typed array constructor")},exportTypedArrayMethod:function(e,t,n,a){if(pv){if(n)for(var i in ei){var r=hn[i];if(r&&Ni(r.prototype,e))try{delete r.prototype[e]}catch(o){try{r.prototype[e]=t}catch(s){}}}ar[e]&&!n||mv(ar,e,n?t:Zr&&vv[e]||t,a)}},exportTypedArrayStaticMethod:function(e,t,n){var a,i;if(pv){if(Uo){if(n){for(a in ei)if((i=hn[a])&&Ni(i,e))try{delete i[e]}catch(r){}}if(wr[e]&&!n)return;try{return mv(wr,e,n?t:Zr&&wr[e]||t)}catch(r){}}for(a in ei)!(i=hn[a])||i[e]&&!n||mv(i,e,t)}},getTypedArrayConstructor:C1,isView:function(e){if(!Bl(e))return!1;var t=fv(e);return t==="DataView"||Ni(ei,t)||Ni(yv,t)},isTypedArray:R1,TypedArray:wr,TypedArrayPrototype:ar},A1=se,bv=ce,Ej=bu,Cj=ze.NATIVE_ARRAY_BUFFER_VIEWS,Rj=A1.ArrayBuffer,xa=A1.Int8Array,Aj=!Cj||!bv(function(){xa(1)})||!bv(function(){new xa(-1)})||!Ej(function(e){new xa,new xa(null),new xa(1.5),new xa(e)},!0)||bv(function(){return new xa(new Rj(2),1,void 0).length!==1}),Pj=Yn,Dj=RangeError,Lj=function(e){var t=Pj(e);if(t<0)throw Dj("The argument can't be less than 0");return t},Oj=RangeError,P1=function(e,t){var n=Lj(e);if(n%t)throw Oj("Wrong offset");return n},Mj=jr,Nj=ke("".slice),Uj=Nr,Vj=TypeError,D1=function(e){var t=Uj(e,"number");if(typeof t=="number")throw Vj("Can't convert number to bigint");return BigInt(t)},jj=Fr,Bj=Ke,Fj=E0,Gj=Ut,Hj=nn,zj=_u,Wj=Ms,qj=dh,Jj=function(e){return Nj(Mj(e),0,3)==="Big"},Kj=ze.aTypedArrayConstructor,Xj=D1,L1=Ue,O1=se,M1=Ke,Qj=Se,Yj=Aj,Vo=ze,N1=Tc,U1=fi,$j=Rt,Ic=gn,Zj=$S,e8=vr,V1=UT,Sv=P1,j1=Va,wc=rt,t8=jr,kv=vt,n8=Or,r8=qa,i8=dr,Hl=Ja,a8=di.f,B1=function(e){var t,n,a,i,r,o,s,c,u=Fj(this),d=Gj(e),g=arguments.length,I=g>1?arguments[1]:void 0,k=I!==void 0,w=Wj(d);if(w&&!qj(w))for(c=(s=zj(d,w)).next,d=[];!(o=Bj(c,s)).done;)d.push(o.value);for(k&&g>2&&(I=jj(I,arguments[2])),n=Hj(d),a=new(Kj(u))(n),i=Jj(a),t=0;n>t;t++)r=k?I(d[t],t):d[t],a[t]=i?Xj(r):+r;return a},o8=rn.forEach,s8=Vs,F1=At,G1=ye,c8=Su,Tv=st.get,u8=st.set,l8=st.enforce,xv=F1.f,d8=G1.f,h8=Math.round,Iv=O1.RangeError,H1=N1.ArrayBuffer,p8=H1.prototype,f8=N1.DataView,zl=Vo.NATIVE_ARRAY_BUFFER_VIEWS,z1=Vo.TYPED_ARRAY_TAG,W1=Vo.TypedArray,Ec=Vo.TypedArrayPrototype,m8=Vo.aTypedArrayConstructor,wv=Vo.isTypedArray,Wl="BYTES_PER_ELEMENT",Ev="Wrong length",q1=function(e,t){m8(e);for(var n=0,a=t.length,i=new e(a);a>n;)i[n]=t[n++];return i},ql=function(e,t){xv(e,t,{get:function(){return Tv(this)[t]}})},J1=function(e){var t;return i8(p8,e)||(t=t8(e))=="ArrayBuffer"||t=="SharedArrayBuffer"},K1=function(e,t){return wv(e)&&!n8(t)&&t in e&&Zj(+t)&&t>=0},X1=function(e,t){return t=j1(t),K1(e,t)?$j(2,e[t]):d8(e,t)},Q1=function(e,t,n){return t=j1(t),!(K1(e,t)&&kv(n)&&wc(n,"value"))||wc(n,"get")||wc(n,"set")||n.configurable||wc(n,"writable")&&!n.writable||wc(n,"enumerable")&&!n.enumerable?xv(e,t,n):(e[t]=n.value,e)};Qj?(zl||(G1.f=X1,F1.f=Q1,ql(Ec,"buffer"),ql(Ec,"byteOffset"),ql(Ec,"byteLength"),ql(Ec,"length")),L1({target:"Object",stat:!0,forced:!zl},{getOwnPropertyDescriptor:X1,defineProperty:Q1}),hv.exports=function(e,t,n){var a=e.match(/\d+$/)[0]/8,i=e+(n?"Clamped":"")+"Array",r="get"+e,o="set"+e,s=O1[i],c=s,u=c&&c.prototype,d={},g=function(k,w){xv(k,w,{get:function(){return function(A,p){var v=Tv(A);return v.view[r](p*a+v.byteOffset,!0)}(this,w)},set:function(A){return function(p,v,y){var L=Tv(p);n&&(y=(y=h8(y))<0?0:y>255?255:255&y),L.view[o](v*a+L.byteOffset,y,!0)}(this,w,A)},enumerable:!0})};zl?Yj&&(c=t(function(k,w,A,p){return U1(k,u),c8(kv(w)?J1(w)?p!==void 0?new s(w,Sv(A,a),p):A!==void 0?new s(w,Sv(A,a)):new s(w):wv(w)?q1(c,w):M1(B1,c,w):new s(V1(w)),k,c)}),Hl&&Hl(c,W1),o8(a8(s),function(k){k in c||Ic(c,k,s[k])}),c.prototype=u):(c=t(function(k,w,A,p){U1(k,u);var v,y,L,f=0,b=0;if(kv(w)){if(!J1(w))return wv(w)?q1(c,w):M1(B1,c,w);v=w,b=Sv(A,a);var P=w.byteLength;if(p===void 0){if(P%a||(y=P-b)<0)throw Iv(Ev)}else if((y=e8(p)*a)+b>P)throw Iv(Ev);L=y/a}else L=V1(w),v=new H1(y=L*a);for(u8(k,{buffer:v,byteOffset:b,byteLength:y,length:L,view:new f8(v)});f<L;)g(k,f++)}),Hl&&Hl(c,W1),u=c.prototype=r8(Ec)),u.constructor!==c&&Ic(u,"constructor",c),l8(u).TypedArrayConstructor=c,z1&&Ic(u,z1,i);var I=c!=s;d[i]=c,L1({global:!0,constructor:!0,forced:I,sham:!zl},d),Wl in c||Ic(c,Wl,a),Wl in u||Ic(u,Wl,a),s8(i)}):hv.exports=function(){},(0,hv.exports)("Uint8",function(e){return function(t,n,a){return e(this,t,n,a)}});var v8=Ut,Cv=hi,g8=nn,_8=K_,y8=Math.min,b8=[].copyWithin||function(e,t){var n=v8(this),a=g8(n),i=Cv(e,a),r=Cv(t,a),o=arguments.length>2?arguments[2]:void 0,s=y8((o===void 0?a:Cv(o,a))-r,a-i),c=1;for(r<i&&i<r+s&&(c=-1,r+=s-1,i+=s-1);s-- >0;)r in n?n[i]=n[r]:_8(n,i),i+=c,r+=c;return n},Y1=ze,S8=ke(b8),k8=Y1.aTypedArray;(0,Y1.exportTypedArrayMethod)("copyWithin",function(e,t){return S8(k8(this),e,t,arguments.length>2?arguments[2]:void 0)});var T8=rn.every,x8=ze.aTypedArray;(0,ze.exportTypedArrayMethod)("every",function(e){return T8(x8(this),e,arguments.length>1?arguments[1]:void 0)});var I8=jT,w8=D1,E8=jr,C8=Ke,R8=ce,A8=ze.aTypedArray,P8=ze.exportTypedArrayMethod,D8=ke("".slice);P8("fill",function(e){var t=arguments.length;A8(this);var n=D8(E8(this),0,3)==="Big"?w8(e):+e;return C8(I8,this,n,t>1?arguments[1]:void 0,t>2?arguments[2]:void 0)},R8(function(){var e=0;return new Int8Array(2).fill({valueOf:function(){return e++}}),e!==1}));var L8=nn,O8=Uu,M8=ze.aTypedArrayConstructor,N8=ze.getTypedArrayConstructor,Jl=function(e){return M8(O8(e,N8(e)))},U8=function(e,t){for(var n=0,a=L8(t),i=new e(a);a>n;)i[n]=t[n++];return i},V8=Jl,j8=rn.filter,B8=function(e,t){return U8(V8(e),t)},F8=ze.aTypedArray;(0,ze.exportTypedArrayMethod)("filter",function(e){var t=j8(F8(this),e,arguments.length>1?arguments[1]:void 0);return B8(this,t)});var G8=rn.find,H8=ze.aTypedArray;(0,ze.exportTypedArrayMethod)("find",function(e){return G8(H8(this),e,arguments.length>1?arguments[1]:void 0)});var z8=rn.findIndex,W8=ze.aTypedArray;(0,ze.exportTypedArrayMethod)("findIndex",function(e){return z8(W8(this),e,arguments.length>1?arguments[1]:void 0)});var q8=rn.forEach,J8=ze.aTypedArray;(0,ze.exportTypedArrayMethod)("forEach",function(e){q8(J8(this),e,arguments.length>1?arguments[1]:void 0)});var K8=ws.includes,X8=ze.aTypedArray;(0,ze.exportTypedArrayMethod)("includes",function(e){return K8(X8(this),e,arguments.length>1?arguments[1]:void 0)});var Q8=ws.indexOf,Y8=ze.aTypedArray;(0,ze.exportTypedArrayMethod)("indexOf",function(e){return Q8(Y8(this),e,arguments.length>1?arguments[1]:void 0)});var $8=se,Z8=ce,Rv=ke,$1=ze,Av=qg,Pv=at("iterator"),Z1=$8.Uint8Array,eB=Rv(Av.values),tB=Rv(Av.keys),nB=Rv(Av.entries),Dv=$1.aTypedArray,Kl=$1.exportTypedArrayMethod,jo=Z1&&Z1.prototype,Xl=!Z8(function(){jo[Pv].call([1])}),ex=!!jo&&jo.values&&jo[Pv]===jo.values&&jo.values.name==="values",tx=function(){return eB(Dv(this))};Kl("entries",function(){return nB(Dv(this))},Xl),Kl("keys",function(){return tB(Dv(this))},Xl),Kl("values",tx,Xl||!ex,{name:"values"}),Kl(Pv,tx,Xl||!ex,{name:"values"});var rB=ze.aTypedArray,iB=ze.exportTypedArrayMethod,aB=ke([].join);iB("join",function(e){return aB(rB(this),e)});var oB=ta,sB=pn,cB=Yn,uB=nn,lB=Hs,dB=Math.min,Lv=[].lastIndexOf,nx=!!Lv&&1/[1].lastIndexOf(1,-0)<0,hB=lB("lastIndexOf"),pB=nx||!hB?function(e){if(nx)return oB(Lv,this,arguments)||0;var t=sB(this),n=uB(t),a=n-1;for(arguments.length>1&&(a=dB(a,cB(arguments[1]))),a<0&&(a=n+a);a>=0;a--)if(a in t&&t[a]===e)return a||0;return-1}:Lv,fB=ta,mB=pB,vB=ze.aTypedArray;(0,ze.exportTypedArrayMethod)("lastIndexOf",function(e){var t=arguments.length;return fB(mB,vB(this),t>1?[e,arguments[1]]:[e])});var gB=rn.map,_B=Jl,yB=ze.aTypedArray;(0,ze.exportTypedArrayMethod)("map",function(e){return gB(yB(this),e,arguments.length>1?arguments[1]:void 0,function(t,n){return new(_B(t))(n)})});var bB=lv.left,SB=ze.aTypedArray;(0,ze.exportTypedArrayMethod)("reduce",function(e){var t=arguments.length;return bB(SB(this),e,t,t>1?arguments[1]:void 0)});var kB=lv.right,TB=ze.aTypedArray;(0,ze.exportTypedArrayMethod)("reduceRight",function(e){var t=arguments.length;return kB(TB(this),e,t,t>1?arguments[1]:void 0)});var xB=ze.aTypedArray,IB=ze.exportTypedArrayMethod,wB=Math.floor;IB("reverse",function(){for(var e,t=this,n=xB(t).length,a=wB(n/2),i=0;i<a;)e=t[i],t[i++]=t[--n],t[n]=e;return t});var rx=se,ix=Ke,Ov=ze,EB=nn,CB=P1,RB=Ut,ax=ce,AB=rx.RangeError,Mv=rx.Int8Array,ox=Mv&&Mv.prototype,sx=ox&&ox.set,PB=Ov.aTypedArray,DB=Ov.exportTypedArrayMethod,Nv=!ax(function(){var e=new Uint8ClampedArray(2);return ix(sx,e,{length:1,0:3},1),e[1]!==3}),LB=Nv&&Ov.NATIVE_ARRAY_BUFFER_VIEWS&&ax(function(){var e=new Mv(2);return e.set(1),e.set("2",1),e[0]!==0||e[1]!==2});DB("set",function(e){PB(this);var t=CB(arguments.length>1?arguments[1]:void 0,1),n=RB(e);if(Nv)return ix(sx,this,n,t);var a=this.length,i=EB(n),r=0;if(i+t>a)throw AB("Wrong length");for(;r<i;)this[t+r]=n[r++]},!Nv||LB);var OB=Jl,MB=Ka,NB=ze.aTypedArray;(0,ze.exportTypedArrayMethod)("slice",function(e,t){for(var n=MB(NB(this),e,t),a=OB(this),i=0,r=n.length,o=new a(r);r>i;)o[i]=n[i++];return o},ce(function(){new Int8Array(1).slice()}));var UB=rn.some,VB=ze.aTypedArray;(0,ze.exportTypedArrayMethod)("some",function(e){return UB(VB(this),e,arguments.length>1?arguments[1]:void 0)});var cx=Xn.match(/firefox\/(\d+)/i),jB=!!cx&&+cx[1],BB=/MSIE|Trident/.test(Xn),ux=Xn.match(/AppleWebKit\/(\d+)\./),FB=!!ux&&+ux[1],GB=ke,Uv=ce,HB=vn,zB=Ry,lx=jB,WB=BB,dx=mn,hx=FB,qB=ze.aTypedArray,JB=ze.exportTypedArrayMethod,Cc=se.Uint16Array,Bo=Cc&&GB(Cc.prototype.sort),KB=!(!Bo||Uv(function(){Bo(new Cc(2),null)})&&Uv(function(){Bo(new Cc(2),{})})),px=!!Bo&&!Uv(function(){if(dx)return dx<74;if(lx)return lx<67;if(WB)return!0;if(hx)return hx<602;var e,t,n=new Cc(516),a=Array(516);for(e=0;e<516;e++)t=e%4,n[e]=515-e,a[e]=e-2*t+3;for(Bo(n,function(i,r){return(i/4|0)-(r/4|0)}),e=0;e<516;e++)if(n[e]!==a[e])return!0});JB("sort",function(e){return e!==void 0&&HB(e),px?Bo(this,e):zB(qB(this),function(t){return function(n,a){return t!==void 0?+t(n,a)||0:a!=a?-1:n!=n?1:n===0&&a===0?1/n>0&&1/a<0?1:-1:n>a}}(e))},!px||KB);var XB=vr,fx=hi,QB=Jl,YB=ze.aTypedArray;(0,ze.exportTypedArrayMethod)("subarray",function(e,t){var n=YB(this),a=n.length,i=fx(e,a);return new(QB(n))(n.buffer,n.byteOffset+i*n.BYTES_PER_ELEMENT,XB((t===void 0?a:fx(t,a))-i))});var $B=ta,mx=ze,Vv=ce,vx=Ka,Ql=se.Int8Array,gx=mx.aTypedArray,ZB=mx.exportTypedArrayMethod,_x=[].toLocaleString,eF=!!Ql&&Vv(function(){_x.call(new Ql(1))});ZB("toLocaleString",function(){return $B(_x,eF?vx(gx(this)):gx(this),vx(arguments))},Vv(function(){return[1,2].toLocaleString()!=new Ql([1,2]).toLocaleString()})||!Vv(function(){Ql.prototype.toLocaleString.call([1,2])}));var tF=ze.exportTypedArrayMethod,nF=ce,rF=ke,yx=se.Uint8Array,iF=yx&&yx.prototype||{},Yl=[].toString,aF=rF([].join);nF(function(){Yl.call({})})&&(Yl=function(){return aF(this)});var oF=iF.toString!=Yl;tF("toString",Yl,oF);var sF=function(){function e(t,n,a){K(this,e),this.isUplink_=a,this.connection_=t,this.log_=n,this.seiMessageList_=[],this.smallVideoSeiMessageList_=[],this.seiPayloadType_=243,this.runningAbortMap_=new Map,this.abortMap_=new Map,this.onSEIMessage=null}return we(e,[{key:"isRunning",get:function(){return!!this.runningAbortMap_.size>0}},{key:"start",value:function(t){var n=this,a=arguments.length>1&&arguments[1]!==void 0?arguments[1]:this.seiMessageList_,i=t.createEncodedStreams(),r=i.readable,o=i.writable,s=new TransformStream({transform:this.isUplink_?function(u,d){return n.encodeVideoFrame(u,d,a)}:function(u,d){var g,I;return n.decodeVideoFrame(u,d,t===((g=n.connection_)===null||g===void 0||(I=g.getPeerConnection())===null||I===void 0?void 0:I.getReceivers()[rS]))}}),c=new AbortController;r.pipeThrough(s).pipeTo(o,{signal:c.signal}).catch(function(){}),this.runningAbortMap_.set(t,c)}},{key:"restart",value:function(t,n){this.stop(),this.start(t,n)}},{key:"stop",value:function(t){var n;(n=this.runningAbortMap_.get(t))===null||n===void 0||n.abort(),this.runningAbortMap_.delete(t)}},{key:"destroy",value:function(){this.stop(),this.runningAbortMap_.forEach(function(t){return t.abort()}),this.runningAbortMap_.clear(),this.abortMap_.forEach(function(t){return t.abort()}),this.abortMap_.clear(),this.log_=null,this.onSEIMessage=null,this.connection_=null}},{key:"handleEncodedStreams",value:function(){var t=this;try{var n=this.connection_.getPeerConnection();this.clearUnusedSenderOrReceiver(n),this.isUplink_?n.getSenders().forEach(function(a,i){if(!t.runningAbortMap_.has(a)&&!t.abortMap_.has(a))if(i===vN||i===nS){var r=i===nS?t.smallVideoSeiMessageList_:t.seiMessageList_;t.isRunning?t.restart(a,r):t.start(a,r)}else t.pipeSenderOrReceiver(a)}):n.getReceivers().forEach(function(a,i){var r;t.runningAbortMap_.has(a)||t.abortMap_.has(a)||(i!==gN&&i!==rS||((r=a.track)===null||r===void 0?void 0:r.kind)!==xe?t.pipeSenderOrReceiver(a):t.isRunning?t.restart(a):t.start(a))})}catch(a){this.log_.warn(a)}}},{key:"pipeSenderOrReceiver",value:function(t){var n=t.createEncodedStreams(),a=n.readable,i=n.writable,r=new AbortController;this.abortMap_.set(t,r),a.pipeTo(i,{signal:r.signal}).catch(function(){})}},{key:"clearUnusedSenderOrReceiver",value:function(t){var n=this;this.abortMap_.forEach(function(a,i){(n.isUplink_?t.getSenders():t.getReceivers()).find(function(r){return r===i})||(a.abort(),n.abortMap_.delete(i))})}},{key:"push",value:function(t,n){n&&n.seiPayloadType&&(this.seiPayloadType_=n.seiPayloadType),this.seiMessageList_.push(t),this.smallVideoSeiMessageList_.push(t)}},{key:"hasSEI",value:function(t){var n=new DataView(t);return n.getInt32(0)===1&&n.getInt8(4)===6}},{key:"isEmptyFrame",value:function(t){return t.type==="empty"||t.data.byteLength===0}},{key:"getNaluCount",value:function(t){for(var n=0,a=0,i=new DataView(t),r=0;r<t.byteLength;r++)switch(i.getUint8(r)){case 0:n++;break;case 1:n!==2&&n!==3||a++,n=0;break;default:n=0}return a}},{key:"encodeVideoFrame",value:function(t,n,a){try{if(this.connection_.isH264&&a.length>0&&!this.isEmptyFrame(t)){var i=9-this.getNaluCount(t.data);if(i<=0)return;for(var r=a.splice(0,i).reverse().map(this.encodeSEINalu.bind(this)),o=r.reduce(function(w,A){return w+A.dataView.byteLength},0),s=new ArrayBuffer(o+t.data.byteLength),c=new DataView(s),u=new DataView(t.data),d=0,g=0;g<r.length;g++)for(var I=0;I<r[g].dataView.byteLength;I++)c.setInt8(d++,r[g].dataView.getInt8(I));for(var k=0;k<t.data.byteLength;k++)c.setInt8(d++,u.getInt8(k));t.data=s,this.log_.debug("".concat(r.length," sei sent"))}}catch(w){this.log_.warn(w)}n.enqueue(t)}},{key:"decodeVideoFrame",value:function(t,n){var a=this,i=arguments.length>2&&arguments[2]!==void 0&&arguments[2];try{if(this.connection_.isH264&&!this.isEmptyFrame(t)&&this.hasSEI(t.data)){for(var r=[],o=new DataView(t.data),s=0,c=-1,u=-1,d=0;d<t.data.byteLength;d++){var g=o.getUint8(d);if(g===0)s++;else if(g===1){if(s===2||s===3){var I=d-s;c===-1?c=I:u===-1&&(u=I,r.push(new bx(new DataView(o.buffer.slice(c,u)))),c=I,u=-1);var k=o.getUint8(d+1)===6;if(!k){t.data=new DataView(o.buffer.slice(I)).buffer;break}}s=0}else s=0}this.log_.debug("".concat(r.length," sei received")),ln(this.onSEIMessage)&&r.reverse().forEach(function(w){a.onSEIMessage({seiPayloadType:w.seiPayloadType,data:w.seiPayload.buffer,isFromAuxiliary:i})})}}catch(w){this.log_.warn(w)}n.enqueue(t)}},{key:"encodeSEINalu",value:function(t){var n=t.byteLength,a=parseInt(n/255),i=n%255,r=[];r.push(0,0,0,1,6,this.seiPayloadType_);for(var o=0;o<a;o++)r.push(255);r.push(i);var s=new DataView(t);return r.push.apply(r,be(new Uint8Array(s.buffer))),r.push(128),new bx(new DataView(new Uint8Array(r).buffer),!0)}}]),e}(),bx=function(){function e(t){var n=arguments.length>1&&arguments[1]!==void 0&&arguments[1];K(this,e),this.dataView=t,this.isSEI&&(n?this.addPreventionByte():this.removePreventionByte())}return we(e,[{key:"addPreventionByte",value:function(){for(var t=this.seiPayloadStartIndex,n=this.dataView.byteLength-2,a=[],i=0,r=t;r<=n;r++){var o=this.dataView.getInt8(r);switch(o){case 0:case 1:case 2:case 3:i===2&&(a.push(3),i=0),o==0?i++:i=0,a.push(o);break;default:i=0,a.push(o)}}a.push(this.dataView.getInt8(this.dataView.byteLength-1));var s=new DataView(new Uint8Array([].concat(be(new Uint8Array(this.dataView.buffer).slice(0,t)),a)).buffer);this.dataView=s}},{key:"removePreventionByte",value:function(){for(var t=this.seiPayloadStartIndex,n=this.dataView.byteLength-1,a=[],i=0,r=t;r<=n;r++)switch(this.dataView.getInt8(r)){case 0:i++,a.push(this.dataView.getInt8(r));break;case 3:i!==2&&a.push(this.dataView.getInt8(r)),i=0;break;default:a.push(this.dataView.getInt8(r)),i=0}var o=new DataView(new Uint8Array([].concat(be(new Uint8Array(this.dataView.buffer).slice(0,t)),a)).buffer);this.dataView=o}},{key:"isSEI",get:function(){return this.dataView.getUint8(4)===6}},{key:"seiPayloadStartIndex",get:function(){for(var t=6,n=6;n<this.dataView.buffer.byteLength&&(t++,this.dataView.getUint8(n)===255);n++);return t}},{key:"seiPayloadType",get:function(){return this.isSEI?this.dataView.getUint8(5):null}},{key:"seiPayload",get:function(){if(!this.isSEI)return null;for(var t=0,n=6,a=6;a<this.dataView.buffer.byteLength;a++){var i=this.dataView.getUint8(a);if(n++,i!==255){t+=i;break}t+=255}for(var r=new ArrayBuffer(t),o=new DataView(r),s=0;s<r.byteLength;s++,n++)o.setInt8(s,this.dataView.getInt8(n));return o}}]),e}(),jv=function(){function e(n){K(this,e),this.userId_=n.userId,this.tinyId_=n.tinyId,this.client_=n.client,this.sdpSemantics_=n.client.getSdpSemantics(),this.isUplink_=n.isUplink,this.log_=_e.createLogger({id:"n|"+this.userId_,userId:this.client_.getUserId(),sdkAppId:this.client_.getSDKAppId(),isLocal:this.isUplink_}),this.signalChannel_=n.signalChannel,this.peerConnection_=null,this.isErrorObserved_=!1,this.emitter_=new Ri,this.currentState_=on,this.waitForPeerConnectionConnectedPromise_=null,this.isReconnecting_=!1,this.reconnectionCount_=0,this.reconnectionTimer_=-1,this.isFirstConnection_=!0,this.delay_={audioDelay:0,videoDelay:0},this.enableSEI_=n.enableSEI,this.enableSEI_&&km&&(this.sei_=new sF(this,this.log_,this.isUplink_))}var t;return we(e,[{key:"initialize",value:function(){var n={encodedInsertableStreams:this.enableSEI_&&km,iceServers:this.client_.getIceServers(),iceTransportPolicy:this.client_.getIceTransportPolicy(),sdpSemantics:this.sdpSemantics_,bundlePolicy:"max-bundle",rtcpMuxPolicy:"require",tcpCandidatePolicy:"disable",IceTransportsType:"nohost"};this.peerConnection_=new RTCPeerConnection(n),this.peerConnection_.onconnectionstatechange=this.onConnectionStateChange.bind(this)}},{key:"close",value:function(){this.log_.info("closing connection"),this.closePeerConnection(),this.sei_&&(this.sei_.destroy(),this.sei_=null)}},{key:"closePeerConnection",value:function(){var n=arguments.length>0&&arguments[0]!==void 0&&arguments[0];this.peerConnection_&&(this.peerConnection_.onconnectionstatechange=function(){},this.peerConnection_.close(),this.peerConnection_=null,n&&this.emitConnectionStateChangedEvent(on))}},{key:"getDTLSTransportState",value:function(){if(!this.peerConnection_)return Xu;var n=null;if(this.isUplink_){if(!_l()||this.peerConnection_.getSenders().length===0)return Xu;n=this.peerConnection_.getSenders()[0].transport}else{if(!Bk()||this.peerConnection_.getReceivers().length===0)return Xu;n=this.peerConnection_.getReceivers()[0].transport}return n?n.state:Xu}},{key:"onConnectionStateChange",value:function(n){var a=this.peerConnection_.iceConnectionState,i=this.getDTLSTransportState();if(this.log_.info("onConnectionStateChange() connectionState: "+n.target.connectionState),this.log_.info("ICE Transport state: ".concat(a,", DTLS Transport state: ").concat(i)),n.target.connectionState===Qu&&this.emitConnectionStateChangedEvent(Tb),n.target.connectionState===xb||n.target.connectionState===Bp){var r="".concat(this.isUplink_?"uplink":"downlink"," ICE/DTLS Transport connection ").concat(n.target.connectionState,". ICE Transport state: ").concat(a,", DTLS Transport state: ").concat(i),o=new re({message:r,code:ee.ICE_TRANSPORT_ERROR});Ie.logFailedEvent({userId:this.client_.getUserId(),eventType:Ub,error:o}),this.emitConnectionStateChangedEvent(on),this.isErrorObserved_||this.emitter_.emit(Ze.ERROR,o)}n.target.connectionState!==Ib&&n.target.connectionState!==iN||(this.logSelectedCandidate(),Ie.logSuccessEvent({userId:this.client_.getUserId(),eventType:Ub}),this.emitConnectionStateChangedEvent(_n))}},{key:"emitConnectionStateChangedEvent",value:function(n){n!==this.currentState_&&(this.currentState_===jp&&n===Tb||(X.emit(vl,{client:this.client_,connection:this,prevState:this.currentState_,state:n}),this.emitter_.emit(Ze.CONNECTION_STATE_CHANGED,{prevState:this.currentState_,state:n}),this.currentState_=n))}},{key:"hitTest",value:function(n){return(n===0||n==="0")&&this.isUplink_||n===this.tinyId_}},{key:"addEventInternal",value:function(n,a){var i=this.client_.getUserId(),r={eventId:n,eventDesc:a,timestamp:an(),userId:i,tinyId:this.client_.getTinyId()};this.isUplink_||(r.remoteUserId=this.userId_,r.remoteTinyId=this.tinyId_),yn(i,r)}},{key:"getPeerConnection",value:function(){return this.peerConnection_}},{key:"getClient",value:function(){return this.client_}},{key:"getUserId",value:function(){return this.userId_}},{key:"getTinyId",value:function(){return this.tinyId_}},{key:"logSelectedCandidate",value:(t=G(m().mark(function n(){var a,i,r,o,s,c,u;return m().wrap(function(d){for(;;)switch(d.prev=d.next){case 0:if(this.peerConnection_){d.next=2;break}return d.abrupt("return");case 2:return d.next=4,this.peerConnection_.getStats();case 4:a=d.sent,i=ae(a),d.prev=6,i.s();case 8:if((r=i.n()).done){d.next=18;break}if((o=Te(r.value,2))[0],!Tm(s=o[1])){d.next=16;break}return c=a.get(s.localCandidateId),u=a.get(s.remoteCandidateId),c&&this.log_.info("local candidate: ".concat(c.candidateType," ").concat(c.protocol,":").concat(c.ip||c.address,":").concat(c.port," ").concat(c.networkType||""," ").concat(c.candidateType==="relay"?"relayProtocol:"+c.relayProtocol:"")),u&&this.log_.info("remote candidate: ".concat(u.candidateType," ").concat(u.protocol,":").concat(u.ip||u.address,":").concat(u.port)),d.abrupt("break",18);case 16:d.next=8;break;case 18:d.next=23;break;case 20:d.prev=20,d.t0=d.catch(6),i.e(d.t0);case 23:return d.prev=23,i.f(),d.finish(23);case 26:case"end":return d.stop()}},n,this,[[6,20,23,26]])})),function(){return t.apply(this,arguments)})},{key:"getCurrentState",value:function(){return this.currentState_}},{key:"waitForPeerConnectionConnected",value:function(){var n=this;return this.waitForPeerConnectionConnectedPromise_||(this.waitForPeerConnectionConnectedPromise_=new Promise(function(a,i){if(n.currentState_===_n)return a();var r=-1,o=function(u){u.state===_n&&(clearTimeout(r),c(),a())},s=function(u){u.client===n.client_&&(clearTimeout(r),c(),i(new re({code:ee.API_CALL_ABORTED,message:ie({key:u4,data:"leave room"})})))},c=function(){X.off(So,s,n),n.emitter_.off(Ze.CONNECTION_STATE_CHANGED,o,n)};r=setTimeout(function(){c();var u=new re({code:ee.API_CALL_TIMEOUT,message:"connection timeout"});i(u)},1e4),X.on(So,s,n),n.emitter_.on(Ze.CONNECTION_STATE_CHANGED,o,n)}),this.waitForPeerConnectionConnectedPromise_=this.waitForPeerConnectionConnectedPromise_.then(function(a){return n.waitForPeerConnectionConnectedPromise_=null,a}).catch(function(a){throw n.waitForPeerConnectionConnectedPromise_=null,a})),this.waitForPeerConnectionConnectedPromise_}},{key:"getReconnectionCount",value:function(){return this.reconnectionCount_}},{key:"startReconnection",value:function(){this.isReconnecting_=!0,this.emitConnectionStateChangedEvent(jp),this.reconnect(),this.addEventInternal(this.isUplink_?gV:bV,"".concat(this.isUplink_?"uplink":"downlink","-connection is reconnecting"))}},{key:"stopReconnection",value:function(){this.log_.info("stop reconnection"),this.isReconnecting_=!1,this.reconnectionCount_=0,this.clearReconnectionTimer(),this.signalChannel_.off(hc,this.reconnect,this)}},{key:"on",value:function(n,a,i){this.emitter_.on(n,a,i)}},{key:"off",value:function(n,a,i){this.emitter_.off(n,a,i)}},{key:"setDelay",value:function(n){var a=n.audioDelay,i=n.videoDelay;this.delay_={audioDelay:a,videoDelay:i}}},{key:"getDelay",value:function(){return this.delay_}},{key:"isH264",get:function(){var n,a;return!((n=this.peerConnection_)===null||n===void 0||(a=n.remoteDescription)===null||a===void 0||!a.sdp.includes("H264"))}}]),e}(),cF=function(){function e(){K(this,e),this.set_=new Set,X.on(pl,this.add,this),X.on(bo,this.add,this),X.on(va,this.delete,this),X.on(So,this.delete,this)}return we(e,[{key:"add",value:function(t){var n=t.client,a=t.roomId;if(n.getMode()!=="rtc"){var i=this.getKey(n.getUserId(),a||n.getRoomId(),n.getSDKAppId(),n.getUseStringRoomId());this.set_.add(i)}}},{key:"delete",value:function(t){var n=t.client;if(n.getMode()!=="rtc"){var a=this.getKey(n.getUserId(),n.getRoomId(),n.getSDKAppId(),n.getUseStringRoomId());this.set_.delete(a)}}},{key:"getKey",value:function(t,n,a,i){return"".concat(a,"_").concat(n,"_").concat(t,"_").concat(i)}},{key:"isJoined",value:function(t){var n=t.userId,a=t.roomId,i=t.sdkAppId,r=t.client;return r.getMode()!=="rtc"&&this.set_.has(this.getKey(n,a,i,r.getUseStringRoomId()))}}]),e}(),uF=new cF;function Sx(e,t,n,a){if(this.useStringRoomId_){if(!(Vt(e)&&/^[A-Za-z\d\s!#$%&()+\-:;<=.>?@[\]^_{}|~,]{1,64}$/.test(e)))throw new re({code:ee.INVALID_PARAMETER,message:ie({key:zN,data:t,link:{className:a,fnName:n}})})}else if(!(Zn(e)&&/^[1-9]\d*$/.test(String(e))&&e<4294967295))throw new re({code:ee.INVALID_PARAMETER,message:ie({key:WN,data:t,link:{className:a,fnName:n}})})}function kx(e,t,n,a){if(!/^[A-Za-z\d_-]*$/.test(e))throw new re({code:ee.INVALID_PARAMETER,message:ie({key:s3,data:t,link:{className:a,fnName:n}})})}var lF={createClient:{name:"clientConfig",required:!0,type:kr,properties:{sdkAppId:{required:!0,type:Et,allowEmpty:!1},userId:{required:!0,type:bt,allowEmpty:!1},userSig:{required:!0,type:bt,allowEmpty:!1},mode:{required:!0,type:bt,values:["rtc",Ku]},useStringRoomId:{type:sn},autoSubscribe:{type:sn},enableAutoPlayDialog:{type:sn},streamId:{type:bt},userDefineRecordId:{type:bt},pureAudioPushMode:{type:Et,values:[1,2]},enableSEI:{type:sn}}},createStream:{name:"streamConfig",required:!0,type:kr,properties:{userId:{type:bt},audio:{type:sn},video:{type:sn},screen:{type:sn},screenAudio:{type:sn},microphoneId:{type:bt},cameraId:{type:bt},facingMode:{type:[bt,kr]},audioSource:{instanceOf:window.MediaStreamTrack},videoSource:{instanceOf:window.MediaStreamTrack}},validate:function(e){if(!ge(e.screen)&&e.screen&&ge(e.audio)&&(e.audio=!1),!(ge(e.audio)&&ge(e.video)||ge(e.audioSource)&&ge(e.videoSource)))throw new re({code:ee.INVALID_PARAMETER,message:ie({key:H3})});if(!ge(e.screen)&&e.screen===!0&&e.video===!0)throw new re({code:ee.INVALID_PARAMETER,message:ie({key:z3})});if(e.audio&&e.screenAudio)throw new re({code:ee.INVALID_PARAMETER,message:ie({key:W3})});if(e.screen!==!0&&e.screenAudio===!0)throw new re({code:ee.INVALID_PARAMETER,message:ie({key:q3})});if(!ge(e.screen)&&e.screen===!0&&!this.isScreenShareSupported())throw new re({code:ee.INVALID_OPERATION,message:ie({key:X3})})}}},dF={join:{name:"options",required:!0,type:kr,properties:{roomId:{required:!0,type:[Et,bt],allowEmpty:!1,validate:Sx},role:{type:[bt],values:[br,ca]},privateMapKey:{type:[bt]}},validate:function(e){if(this.isJoined_)throw new re({code:ee.INVALID_OPERATION,message:ie({key:HN})});if(this.checkDestroy(),uF.isJoined({userId:this.userId_,roomId:e.roomId,sdkAppId:this.sdkAppId_,client:this}))throw new re({code:ee.INVALID_OPERATION,message:ie({key:A3,data:this.userId_})})}},publish:[{name:"stream",required:!0,instanceOf:Ti,validate:function(e){if(!this.isJoined_)throw new re({code:ee.INVALID_OPERATION,message:ie({key:XN})});if(this.mode_===Ku&&this.role_===ca)throw new re({code:ee.INVALID_OPERATION,message:ie({key:YN})});if(!e.getIsReadyToPublish())throw new re({code:ee.INVALID_OPERATION,message:ie({key:$N})});if(this.notPublishWithoutH264Supported_)throw new re({code:ee.NOT_SUPPORTED_H264,message:ie({key:yS})})}},{name:"options",type:kr,defaultValue:{isAuxiliary:!1},properties:{isAuxiliary:{type:sn,defaultValue:!1,validate:function(){var e=arguments.length>0&&arguments[0]!==void 0&&arguments[0];if(e&&!bm())throw new re({code:ee.NOT_SUPPORTED,message:ie({key:Q3})});if(this.uplinkConnection_&&(e&&this.uplinkConnection_.isAuxStreamPublished||!e&&this.uplinkConnection_.isMainStreamPublished))throw new re({code:ee.INVALID_OPERATION,message:ie({key:ZN,data:e?pt:"local"})});var t=this.localScreenStream_||be(this.connections_.values()).findIndex(function(n){return n.getTrackState().auxiliary})>=0;if(!this.enableMultiAuxStream_&&e&&t)throw new re({code:ee.INVALID_OPERATION,message:ie({key:l4})})}}}}],unpublish:{name:"stream",required:!0,instanceOf:Ti,validate:function(e){if(e!==this.localStream_&&e!==this.localAuxStream_){if(this.localStream_||this.localAuxStream_)throw new re({code:ee.INVALID_PARAMETER,message:ie({key:QN})});this.log_.warn("Client currently has no published stream, please call publish() first.")}}},subscribe:[{name:"stream",required:!0,instanceOf:Xp,validate:function(e){if(!e.getConnection())throw new re({code:ee.INVALID_OPERATION,message:ie({key:ef})});if(this.notSubscribeWithoutH264Supported_)throw new re({code:ee.NOT_SUPPORTED_H264,message:ie({key:bS})})}},{name:"options",type:kr,properties:{audio:{type:sn},video:{type:sn},smallVideo:{type:sn}},validate:function(e){var t=e.audio,n=e.video,a=e.smallVideo;if(t===!1&&n===!1&&(ge(a)||a===!1))throw new re({code:ee.INVALID_OPERATION,message:ie({key:n4})})}}],unsubscribe:{name:"stream",required:!0,instanceOf:Xp,validate:function(e){if(!e.getConnection())throw new re({code:ee.INVALID_OPERATION,message:ie({key:ef})})}},switchRole:{name:"role",required:!0,values:[br,ca],validate:function(){if(this.mode_!==Ku)throw new re({code:ee.INVALID_PARAMETER,message:ie({key:t3})});if(!this.isJoined_)throw new re({code:ee.INVALID_OPERATION,message:ie({key:n3})})}},startPublishCDNStream:{name:"options",required:!1,properties:{streamId:{type:bt,validate:kx},streamType:{type:bt,values:["main","auxiliary"]},appId:{type:Et,allowEmpty:!1},bizId:{type:Et,allowEmpty:!1},url:{type:bt,allowEmpty:!1}},validate:function(){if(this.isDestroyed_)throw new re({code:ee.INVALID_OPERATION,message:ie({key:tf,data:{funName:"startPublishCDNStream"}})})}},startMixTranscode:{name:"config",required:!0,type:kr,properties:{mode:{type:bt,values:["preset-layout","manual"]},streamId:{type:bt,validate:kx},videoWidth:{type:Et,notLessThanZero:!0},videoHeight:{type:Et,notLessThanZero:!0},videoBitrate:{type:Et,notLessThanZero:!0,allowEmpty:!1},videoFramerate:{type:Et,validate:function(e,t,n,a){if(e<=0||e>30)throw new re({code:ee.INVALID_PARAMETER,message:ie({key:M3,link:{className:a,fnName:n}})})}},videoGOP:{type:Et,validate:function(e,t,n,a){if(e<1||e>8)throw new re({code:ee.INVALID_PARAMETER,message:ie({key:N3,link:{className:a,fnName:n}})})}},audioSampleRate:{type:Et,notLessThanZero:!0},audioBitrate:{type:Et,validate:function(e,t,n,a){if(e<32||e>192)throw new re({code:ee.INVALID_PARAMETER,message:ie({key:U3,link:{className:a,fnName:n}})})}},audioChannels:{type:Et,values:[1,2]},backgroundColor:{type:Et},backgroundImage:{type:bt},mixUsers:{required:!0,type:uN,arrayItem:{require:!0,type:kr,properties:{userId:{required:!0,type:bt},roomId:{type:[bt,Et],validate:Sx},pureAudio:{type:sn},width:{type:Et,notLessThanZero:!0},height:{type:Et,notLessThanZero:!0},locationX:{type:Et,notLessThanZero:!0},locationY:{type:Et,notLessThanZero:!0},zOrder:{type:Et},streamType:{type:bt,values:["main","auxiliary"]},renderMode:{type:Et,values:[0,1,2,4]}}}}},validate:function(e,t,n,a,i){var r=0,o=0,s=e.mixUsers,c=[];if(s.forEach(function(u,d){if(c.push(u.userId),!u.pureAudio){if(!u.zOrder||u.zOrder<1||u.zOrder>15)throw new re({code:ee.INVALID_PARAMETER,message:ie({key:V3,data:"config.mixUsers[".concat(d,"].zOrder"),link:{className:a,fnName:n}})});u.width+u.locationX>r&&(r=u.width+u.locationX),u.height+u.locationY>o&&(o=u.height+u.locationY)}}),c.indexOf(this.getUserId())<0)throw new re({code:ee.INVALID_PARAMETER,message:ie({key:j3,link:{className:a,fnName:n}})});if(e.videoWidth<r||e.videoHeight<o)throw new re({code:ee.INVALID_PARAMETER,message:ie({key:B3,link:{className:a,fnName:n}})})}},sendSEIMessage:[{name:"buffer",required:!0,instanceOf:ArrayBuffer,validate:function(e){if(!km)throw new re({code:ee.NOT_SUPPORTED,message:ie({key:kS})});if(!this.enableSEI_)throw new re({code:ee.INVALID_OPERATION,message:ie({key:r4})});if(e.byteLength>1e3)throw new re({code:ee.INVALID_PARAMETER,message:ie({key:a4,data:e.byteLength})});if(e.byteLength===0)throw new re({code:ee.INVALID_PARAMETER,message:ie({key:i4})});if(!this.uplinkConnection_||!this.localStream_)throw new re({code:ee.INVALID_PARAMETER,message:ie({key:o4})});if(!this.localStream_.hasVideo())throw new re({code:ee.INVALID_OPERATION,message:ie({key:s4})});var t=this.uplinkConnection_.isH264;if(!t)throw new re({code:ee.NOT_SUPPORTED,message:ie({key:kS,data:t})})}},{name:"options",type:kr,properties:{seiPayloadType:{type:Et,values:[5,243]}}}]},hF={switchDevice:[{name:"type",required:!0,type:bt,values:[Ae,xe]},{name:"deviceId",required:!0,type:bt,validate:function(){if(this.screen_&&!this.audio_||this.audioSource_||this.videoSource_)throw new re({code:ee.INVALID_OPERATION,message:ie({key:v3})});if(this.publishState_===ac)throw new re({code:ee.INVALID_OPERATION,message:ie({key:g3})});if(!Sm())throw new re({code:ee.NOT_SUPPORTED,message:ie({key:K3})})}}],setAudioCaptureVolume:{name:"volume",type:Et}},pF={play:[{name:"elementId",required:!0,type:[bt,"HTMLDivElement"],validate:function(e,t,n){if(Vt(e)){var a=document.getElementById(e);if(!a)throw new re({code:ee.INVALID_PARAMETER,message:ie({key:F3,data:{key:t,fnName:n}})});if(!(a instanceof HTMLDivElement))throw new re({code:ee.INVALID_PARAMETER,message:ie({key:G3,data:{key:t,fnName:n,type:Ci(a)}})})}}},{name:"options",type:kr,properties:{objectFit:{type:bt,values:["contain","cover","fill"]},muted:{type:sn},mirror:{type:sn}}}],addTrack:{name:Np,instanceOf:window.MediaStreamTrack,validate:function(e){if(this.isAddingTrack_)throw new re({code:ee.INVALID_OPERATION,message:ie({key:y3})});if(this.isRemovingTrack_)throw new re({code:ee.INVALID_OPERATION,message:ie({key:b3})});if(this.publishState_===ac)throw new re({code:ee.INVALID_OPERATION,message:ie({key:S3})});var t=this.getMediaStream();if(!t)throw new re({code:ee.INVALID_OPERATION,message:ie({key:vS})});if(e.kind===Ae&&t.getAudioTracks().length>0||e.kind===xe&&t.getVideoTracks().length>0)throw new re({code:ee.INVALID_OPERATION,message:ie({key:k3})});if(!Pi()&&!_l())throw new re({code:ee.NOT_SUPPORTED,message:ie({key:rf,data:bb})})}},removeTrack:{name:Np,instanceOf:window.MediaStreamTrack,validate:function(e){if(this.isAddingTrack_)throw new re({code:ee.INVALID_OPERATION,message:ie({key:x3})});if(this.isRemovingTrack_)throw new re({code:ee.INVALID_OPERATION,message:ie({key:I3})});if(this.publishState_===ac)throw new re({code:ee.INVALID_OPERATION,message:ie({key:w3})});var t=this.getMediaStream();if(!t)throw new re({code:ee.INVALID_OPERATION,message:ie({key:vS})});if(t.getTracks().indexOf(e)===-1)throw new re({code:ee.INVALID_PARAMETER,message:ie({key:E3})});if(!Pi()){if(t.getTracks().length===1)throw new re({code:ee.INVALID_OPERATION,message:ie({key:C3})});if(e.kind===Ae)throw new re({code:ee.INVALID_PARAMETER,message:ie({key:T3})});if(!_l())throw new re({code:ee.NOT_SUPPORTED,message:ie({key:rf,data:Sb})})}}},replaceTrack:{name:Np,instanceOf:window.MediaStreamTrack,validate:function(e){var t=this.getMediaStream();if(!t)throw new re({code:ee.INVALID_OPERATION,message:ie({key:_3})});if(this.publishState_===ac)throw new re({code:ee.INVALID_OPERATION,message:ie({key:mS})});if(e.kind===Ae&&t.getAudioTracks().length<=0||e.kind===xe&&t.getVideoTracks().length<=0)throw new re({code:ee.INVALID_PARAMETER,message:ie({key:R3,data:e})});if(!Sm())throw new re({code:ee.NOT_SUPPORTED,message:ie({key:rf,data:qM})})}}},Jt={TRTC:lF,CLIENT:dF,LOCAL_STREAM:hF,STREAM:pF};function $l(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return function(a,i,r){var o=r.value;return r.value=function(){for(var s=arguments.length,c=new Array(s),u=0;u<s;u++)c[u]=arguments[u];return Tx.call(this,t,c,i,this.name_),o.apply(this,c)},r}}function Cn(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return function(a,i,r){var o=r.value;return r.value=G(m().mark(function s(){var c,u,d,g=arguments;return m().wrap(function(I){for(;;)switch(I.prev=I.next){case 0:for(c=g.length,u=new Array(c),d=0;d<c;d++)u[d]=g[d];return Tx.call(this,t,u,i,this.name_),I.abrupt("return",o.apply(this,u));case 3:case"end":return I.stop()}},s,this)})),r}}function Tx(e,t,n,a){try{for(var i=0;i<e.length;i++)Bv.call(this,{rule:e[i],value:t[i],key:e[i].name,fnName:n,className:a})}catch(r){throw _e.error(r),r}}function Bv(e){var t=this,n=e.rule,a=e.value,i=e.key,r=e.fnName,o=e.className;if(ge(a)){if(n.required)throw new re({code:ee.INVALID_PARAMETER,message:ie({key:EN,data:{key:i,rule:n,fnName:r,value:a},link:{className:o,fnName:r}})});if(ge(n.defaultValue))return;a=n.defaultValue}if(Array.isArray(n.type)){if(!n.type.map(function(g){return g.toLowerCase()}).includes(Ci(a)))throw new re({code:ee.INVALID_PARAMETER,message:ie({key:uS,data:{key:i,rule:n,fnName:r,value:a},link:{className:o,fnName:r}})})}else if(!ge(n.type)&&Ci(a)!==n.type)throw new re({code:ee.INVALID_PARAMETER,message:ie({key:uS,data:{key:i,rule:n,fnName:r,value:a},link:{className:o,fnName:r}})});if(n.allowEmpty===!1){var s=Zn(a)&&(a===0||Number.isNaN(a)),c=Vt(a)&&a.trim()==="";if(s||c)throw new re({code:ee.INVALID_PARAMETER,message:ie({key:CN,data:{key:i,rule:n,fnName:r,value:a},link:{className:o,fnName:r}})})}if(n.notLessThanZero&&Zn(a)&&a<0)throw new re({code:ee.INVALID_PARAMETER,message:ie({key:O3,data:{key:i,rule:n,fnName:r,value:a},link:{className:o,fnName:r}})});if(Vt(n.instanceOf)){if(!a||a.name_!==n.instanceOf)throw new re({code:ee.INVALID_PARAMETER,message:ie({key:lS,data:{key:i,rule:n,fnName:r,value:a},link:{className:o,fnName:r}})})}else if(ln(n.instanceOf)&&!(a instanceof n.instanceOf))throw new re({code:ee.INVALID_PARAMETER,message:ie({key:lS,data:{key:i,rule:n,fnName:r,value:a},link:{className:o,fnName:r}})});if(n.values&&!n.values.includes(a))throw new re({code:ee.INVALID_PARAMETER,message:ie({key:RN,data:{key:i,rule:n,fnName:r,value:a},link:{className:o,fnName:r}})});var u=n.properties;Ei(u)&&VS(a)&&Object.keys(u).forEach(function(g){Bv.call(t,{rule:u[g],value:a&&a[g],key:"".concat(i,".").concat(g),fnName:r,className:o})});var d=n.arrayItem;Ei(d)&&_o(a)&&a.forEach(function(g,I){Bv.call(t,{rule:d,value:g,key:"".concat(i,"[").concat(I,"]"),fnName:r,className:o})}),ln(n.validate)&&n.validate.call(this,a,i,r,o,this)}Ue({target:"Number",stat:!0},{isNaN:function(e){return e!=e}});var fF=Ue,mF=ce,vF=sh.f;fF({target:"Object",stat:!0,forced:mF(function(){return!Object.getOwnPropertyNames(1)})},{getOwnPropertyNames:vF});var xx,Rc,gF=Zk;function Fo(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{retries:5,timeout:2e3};return function(t,n,a){var i=dc({retryFunction:a.value,settings:e,onError:e.onError,onRetrying:e.onRetrying,onRetryFailed:e.onRetryFailed});return a.value=function(){for(var r=arguments.length,o=new Array(r),s=0;s<r;s++)o[s]=arguments[s];return i.apply(this,o)},a}}Ue({target:"Array",stat:!0,forced:!bu(function(e){Array.from(e)})},{from:gF});var Ix,wx,Ex,or,Ia=5e3,_F={msg_user_info:0,uint32_video_avg_fps:0,uint32_video_width:0,uint32_video_height:0,uint32_video_avg_bitrate:0,uint32_video_block_time:0,uint32_video_play_time:0,uint32_audio_block_time:0,uint32_audio_play_time:0,uint32_audio_play_db:0,uint32_avg_down_loss:0,uint32_stream_type:0,uint32_video_render_first:0,uint32_video_block_count:0,uint32_audio_block_count:0,uint32_audio_bitrate:0,uint32_video_black_screen_subjective:0,uint32_audio_recv_bitrate:0,uint32_video_external_block_time:0},Fv=we(function e(t){K(this,e),this.str_identifier=String(t.userId),this.uint64_tinyid=Number(t.tinyId),this.uint32_role=t.role}),yF=(xx=Fo({timeout:500,retries:3}),Rc=function(){function e(i){var r=this;K(this,e),this.frameWorkType_=i.frameWorkType||30,this.component_=i.component||0,this.client_=i.client,this.keyPrefix_="key_point",this.storageKey_="".concat(this.keyPrefix_,"_").concat(this.client_.getUserId()),this.log_=_e.createLogger({id:"kpm|"+this.client_.getUserId(),userId:this.client_.getUserId(),sdkAppId:this.client_.getSDKAppId()}),Object.getOwnPropertyNames(this.__proto__).forEach(function(o){o.startsWith("handle")&&ln(r[o])&&(r[o]=function(s){var c=s.fn,u=s.context;return G(m().mark(function d(){var g,I,k,w=arguments;return m().wrap(function(A){for(;;)switch(A.prev=A.next){case 0:for(A.prev=0,g=w.length,I=new Array(g),k=0;k<g;k++)I[k]=w[k];return A.next=4,c.apply(u||this,I);case 4:return A.abrupt("return",A.sent);case 7:A.prev=7,A.t0=A.catch(0),_e.error("".concat(c.name,"() error observed ")+A.t0);case 10:case"end":return A.stop()}},d,this,[[0,7]])}))}({fn:r[o],context:r}))}),this.initData(),this.installEvents(),this.intervalId_=_t.run(vo,this.setStorage.bind(this),{delay:2e4})}var t,n,a;return we(e,[{key:"initData",value:function(){var i;this.firstPublishedUserList_=[],this.networkQuality_={totalUplinkRTT:0,totalUplinkLoss:0,count:0,totalDownlinkRTTAndLossMap:new Map},this.basicInfo={string_sdk_version:pi,uint32_os_type:15,string_device_name:"",string_http_user_agent:navigator.userAgent,string_os_version:"",string_domain:location.host,uint32_avg_rtt:0,uint32_avg_up_loss:0,uint32_scene:((i=this.client_)===null||i===void 0?void 0:i.getMode())==="live"?1:0,uint32_joining_duration:0,uint32_networkType:Jp[xf()],uint32_framework:this.frameWorkType_,uint32_component:this.component_},this.pathJoinRoom_={uint64_start_time:0,uint64_init_audio_start_time:0,uint64_init_audio_end_time:0,uint64_init_camera_start_time:0,uint64_init_camera_end_time:0,uint64_send_request_acc_ip_cmd_start_time:0,uint64_send_request_acc_ip_cmd_end_time:0,uint64_send_request_enter_room_cmd_start_time:0,uint64_send_request_enter_room_cmd_end_time:0,uint64_send_first_video_frame_time:0,uint64_recv_userlist_time:0,uint64_end_time:0,int32_init_audio_ret:0,int32_init_camera_ret:0,int32_send_request_acc_ip_cmd_ret:0,int32_send_request_enter_room_cmd_ret:0,int32_end_ret:0},this.pathLeaveRoom_={uint64_start_time:0,uint64_send_request_exit_room_cmd_start_time:0,uint64_send_request_exit_room_cmd_end_time:0,uint64_end_time:0,int32_send_request_exit_room_cmd_ret:0,int32_end_ret:0},this.pathMainVideoMap_=new Map,this.pathMainAudioMap_=new Map,this.pathAuxiliaryMap_=new Map,this.localStreamStats_={totalVideoBitrate:0,totalVideoFPS:0,totalVideoHeight:0,totalVideoWidth:0,totalAudioLevel:0,videoCount:0,audioLevelCount:0,publishStartTime:0,statsToReport:{uint32_audio_capture_db:0,uint32_video_big_capture_fps:0,uint32_video_big_bitrate:0,uint32_video_big_resolution:0}},this.remoteStreamStatsMap_=new Map}},{key:"installEvents",value:function(){X.on(pl,this.handleJoinStart,this),X.on(Nf,this.handleWSStart,this),X.on(fl,this.handleWSEnd,this),X.on(Rf,this.handleJoinSendCMD,this),X.on(Af,this.handleJoinReceivedCMDResponce,this),X.on(bo,this.handleJoinSuccess,this),X.on(va,this.handleJoinFailed,this),X.on(Of,this.handleReceivedPublishUserList,this),X.on(vl,this.handleConnectionStateChanged,this),X.on(Pf,this.handleLeaveStart,this),X.on(So,this.handleLeaveSuccess,this),X.on(Df,this.handleLeaveSendCMD,this),X.on(Yf,this.handleSendSubscribeCMD,this),X.on(cc,this.handleVideoPlaying,this),X.on(jf,this.handleAudioPlaying,this),X.on($f,this.handleNetworkQuality,this),X.on(Lf,this.handleHeartbeatStats,this),X.on(ml,this.handleRemoteStreamAdded,this),X.on(Bf,this.handleRemoteStreamSubscribeStart,this),X.on(Wr,this.handleRemoteStreamSubscribed,this),X.on(ga,this.handleRemoteStreamRemoved,this),X.on(qf,this.handleVideoLoadedData,this),X.on(Wf,this.handlePlayStream,this),X.on(Mf,this.handlePublishStart,this),X.on(Ff,this.handleLocalStreamInitStart,this),X.on(Gf,this.handleLocalStreamInitEnd,this),X.on(Hf,this.handleLocalStreamInitFailed,this)}},{key:"uninstallEvents",value:function(){X.off(pl,this.handleJoinStart,this),X.off(Nf,this.handleWSStart,this),X.off(fl,this.handleWSEnd,this),X.off(Rf,this.handleJoinSendCMD,this),X.off(Af,this.handleJoinReceivedCMDResponce,this),X.off(Of,this.handleReceivedPublishUserList,this),X.off(vl,this.handleConnectionStateChanged,this),X.off(Pf,this.handleLeaveStart,this),X.off(So,this.handleLeaveSuccess,this),X.off(bo,this.handleJoinSuccess,this),X.off(va,this.handleJoinFailed,this),X.off(Df,this.handleLeaveSendCMD,this),X.off(Yf,this.handleSendSubscribeCMD,this),X.off(cc,this.handleVideoPlaying,this),X.off(jf,this.handleAudioPlaying,this),X.off($f,this.handleNetworkQuality,this),X.off(Lf,this.handleHeartbeatStats,this),X.off(ml,this.handleRemoteStreamAdded,this),X.off(Bf,this.handleRemoteStreamSubscribeStart,this),X.off(Wr,this.handleRemoteStreamSubscribed,this),X.off(ga,this.handleRemoteStreamRemoved,this),X.off(qf,this.handleVideoLoadedData,this),X.off(Wf,this.handlePlayStream,this),X.off(Mf,this.handlePublishStart,this),X.off(Ff,this.handleLocalStreamInitStart,this),X.off(Gf,this.handleLocalStreamInitEnd,this),X.off(Hf,this.handleLocalStreamInitFailed,this)}},{key:"destroy",value:function(){this.uninstallEvents(),_t.clearTask(this.intervalId_),this.client_=null}},{key:"handleJoinStart",value:function(i){this.hitTest(i.client)&&this.pathJoinRoom_.uint64_start_time===0&&(this.pathJoinRoom_.uint64_start_time=Date.now(),this.checkStorage())}},{key:"handleWSStart",value:function(i){var r=i.client;this.hitTest(r)&&this.pathJoinRoom_.uint64_send_request_acc_ip_cmd_start_time===0&&(this.pathJoinRoom_.uint64_send_request_acc_ip_cmd_start_time=Date.now())}},{key:"handleWSEnd",value:function(i){var r=i.client,o=i.error;this.hitTest(r)&&this.pathJoinRoom_.uint64_send_request_acc_ip_cmd_end_time===0&&(this.pathJoinRoom_.uint64_send_request_acc_ip_cmd_end_time=Date.now(),o&&(this.pathJoinRoom_.int32_send_request_acc_ip_cmd_ret=o instanceof re?Number(o.getExtraCode()||o.getCode()):ee.UNKNOWN,this.pathJoinRoom_.int32_end_ret=2))}},{key:"handleJoinSendCMD",value:function(i){this.hitTest(i.client)&&this.pathJoinRoom_.uint64_send_request_enter_room_cmd_start_time===0&&(this.pathJoinRoom_.uint64_send_request_enter_room_cmd_start_time=Date.now())}},{key:"handleJoinReceivedCMDResponce",value:function(i){this.hitTest(i.client)&&this.pathJoinRoom_.uint64_send_request_enter_room_cmd_end_time===0&&(this.pathJoinRoom_.uint64_send_request_enter_room_cmd_end_time=Date.now(),this.pathJoinRoom_.int32_send_request_enter_room_cmd_ret=i.code,i.code!==0&&(this.pathJoinRoom_.int32_end_ret=3))}},{key:"handleJoinSuccess",value:function(i){this.hitTest(i.client)&&this.pathJoinRoom_.uint64_end_time===0&&(this.pathJoinRoom_.uint64_end_time=Date.now(),this.pathJoinRoom_.int32_end_ret=0)}},{key:"handleJoinFailed",value:function(i){var r=i.client;this.hitTest(r)&&(this.pathJoinRoom_.uint64_end_time=Date.now(),this.pathJoinRoom_.int32_end_ret===0&&(this.pathJoinRoom_.int32_end_ret=3),this.prepareReport(),this.report())}},{key:"handleReceivedPublishUserList",value:function(i){this.hitTest(i.client)&&this.pathJoinRoom_.uint64_recv_userlist_time===0&&(this.pathJoinRoom_.uint64_recv_userlist_time=Date.now(),this.firstPublishedUserList_=i.data.data&&i.data.data.userList||[])}},{key:"handleConnectionStateChanged",value:function(i){var r=i.client,o=i.state,s=i.connection;if(this.hitTest(r)&&o===_n){this.client_.getUplinkConnection()===s&&this.pathJoinRoom_.uint64_send_first_video_frame_time===0&&this.localStreamStats_.publishStartTime>this.pathJoinRoom_.uint64_end_time&&this.localStreamStats_.publishStartTime-this.pathJoinRoom_.uint64_end_time<=100&&(this.pathJoinRoom_.uint64_send_first_video_frame_time=Date.now());var c=this.pathMainVideoMap_.get("".concat(s.getUserId(),"_").concat(gt));c&&c.statsToReport.uint64_pc_connected_time===0&&(c.statsToReport.uint64_pc_connected_time=Date.now())}}},{key:"handleLeaveStart",value:function(i){this.hitTest(i.client)&&(this.pathLeaveRoom_.uint64_start_time=Date.now())}},{key:"handleLeaveSuccess",value:function(i){this.hitTest(i.client)&&this.pathLeaveRoom_.uint64_end_time===0&&(this.pathLeaveRoom_.uint64_end_time=Date.now(),this.pathJoinRoom_.uint64_end_time!==0?this.basicInfo.uint32_joining_duration=this.pathLeaveRoom_.uint64_end_time-this.pathJoinRoom_.uint64_end_time:this.log_.warn("pathJoinRoom endTime is 0"),this.report())}},{key:"handleLeaveSendCMD",value:function(i){this.hitTest(i.client)&&(this.pathLeaveRoom_.uint64_send_request_exit_room_cmd_start_time=Date.now(),this.pathLeaveRoom_.uint64_send_request_exit_room_cmd_end_time=Date.now())}},{key:"handleRemoteStreamAdded",value:function(i){var r=i.client,o=i.stream;if(this.hitTest(r)){var s=o.getUserId(),c=o.getType(),u="".concat(s,"_").concat(c),d=this.remoteStreamStatsMap_.get(u);if(d)d.stream=o;else{var g={userId:s,totalVideoFPS:0,totalVideoBitrate:0,totalAudioLevel:0,totalAudioBitrate:0,totalLoss:0,audioCount:0,audioLevelCount:0,videoCount:0,networkQualityCount:0,streamAddedTime:Date.now(),subscribeStartTime:0,subscribedTime:0,playStreamTime:0,statsToReport:q({},_F),stream:o};g.statsToReport.msg_user_info=new Fv({userId:s,tinyId:o.getTinyId(),role:fo}),g.statsToReport.uint32_stream_type=c===gt?2:7,this.remoteStreamStatsMap_.set(u,g)}}}},{key:"handleRemoteStreamSubscribeStart",value:function(i){var r=i.client,o=i.stream;if(this.hitTest(r)){var s=o.getUserId(),c=o.getType(),u="".concat(s,"_").concat(c),d=this.remoteStreamStatsMap_.get(u);d&&d.subscribeStartTime===0&&(d.subscribeStartTime=Date.now())}}},{key:"handleSendSubscribeCMD",value:function(i){if(this.hitTest(i.client)){var r=new Fv(i),o=Date.now(),s="".concat(i.userId,"_").concat(gt);i.trackState.video&&i.subscribeState.video&&!this.pathMainVideoMap_.has(s)&&this.pathMainVideoMap_.set(s,{statsToReport:{msg_user_info:r,uint64_start_enter_time:this.pathJoinRoom_.uint64_start_time,uint64_render_first_frame_time:0,uint64_combine_first_frame_time:0,uint64_pc_connected_time:0},userId:i.userId,sendSubscribeCMDTime:o}),i.trackState.audio&&i.subscribeState.audio&&!this.pathMainAudioMap_.has(s)&&this.pathMainAudioMap_.set(s,{statsToReport:{msg_user_info:r,uint64_start_enter_time:this.pathJoinRoom_.uint64_start_time,uint64_play_first_frame_time:0},userId:i.userId,sendSubscribeCMDTime:o});var c="".concat(i.userId,"_").concat(Lt);i.trackState.auxiliary&&i.subscribeState.auxiliary&&!this.pathAuxiliaryMap_.has(c)&&this.pathAuxiliaryMap_.set(c,{sendSubscribeCMDTime:o})}}},{key:"handleRemoteStreamSubscribed",value:function(i){var r=i.client,o=i.stream;if(this.hitTest(r)){var s=o.getUserId(),c=o.getType(),u="".concat(s,"_").concat(c),d=this.remoteStreamStatsMap_.get(u);d&&d.subscribedTime===0&&(d.subscribedTime=Date.now(),d.stream=o)}}},{key:"handleRemoteStreamRemoved",value:function(i){var r=i.client,o=i.stream;if(this.hitTest(r)){var s=o.getUserId(),c=o.getType(),u=this.remoteStreamStatsMap_.get("".concat(s,"_").concat(c));u&&(u.stream=null)}}},{key:"handlePlayStream",value:function(i){var r=i.stream;if(r.isRemote()&&r.getConnection()&&this.hitTest(r.getConnection().getClient())){var o=r.getConnection().getUserId(),s="".concat(o,"_").concat(r.getType());if(this.remoteStreamStatsMap_.has(s)){var c=this.remoteStreamStatsMap_.get(s);c.playStreamTime===0&&(c.playStreamTime=Date.now())}}}},{key:"handleVideoLoadedData",value:function(i){var r=i.stream;if(r.isRemote()&&r.getConnection()&&this.hitTest(r.getConnection().getClient())){var o=r.getConnection().getUserId(),s="".concat(o,"_").concat(r.getType());if(this.pathMainVideoMap_.has(s)){var c=this.pathMainVideoMap_.get(s);c.statsToReport.uint64_combine_first_frame_time===0&&(c.statsToReport.uint64_combine_first_frame_time=Date.now())}}}},{key:"handleVideoPlaying",value:function(i){var r=i.stream;if(r.isRemote()&&r.getConnection()&&this.hitTest(r.getConnection().getClient())){var o=r.getConnection().getUserId(),s="".concat(o,"_").concat(r.getType()),c=Date.now();if(this.pathMainVideoMap_.has(s)){var u=this.pathMainVideoMap_.get(s);if(u.statsToReport.uint64_render_first_frame_time===0&&(u.statsToReport.uint64_render_first_frame_time=c),this.remoteStreamStatsMap_.has(s)){var d=this.remoteStreamStatsMap_.get(s),g=d.statsToReport,I=d.playStreamTime,k=d.subscribedTime;g.uint32_video_render_first===0&&I-k<=100&&(g.uint32_video_render_first=c-u.sendSubscribeCMDTime)}}if(r.getType()===Lt&&this.pathAuxiliaryMap_.has(s)&&this.remoteStreamStatsMap_.has(s)){var w=this.remoteStreamStatsMap_.get(s),A=w.statsToReport,p=w.playStreamTime,v=w.subscribedTime;A.uint32_video_render_first===0&&p-v<=100&&(A.uint32_video_render_first=c-this.pathAuxiliaryMap_.get(s).sendSubscribeCMDTime)}}}},{key:"handleAudioPlaying",value:function(i){if(i.stream.isRemote()&&i.stream.getConnection()&&this.hitTest(i.stream.getConnection().getClient())){var r=i.stream.getConnection().getUserId(),o="".concat(r,"_").concat(i.stream.getType());if(this.pathMainAudioMap_.has(o)){var s=this.pathMainAudioMap_.get(o);s.statsToReport.uint64_play_first_frame_time===0&&(s.statsToReport.uint64_play_first_frame_time=Date.now())}}}},{key:"handleNetworkQuality",value:function(i){var r=this;this.hitTest(i.client)&&(this.networkQuality_.totalUplinkLoss+=i.uplinkLoss,this.networkQuality_.totalUplinkRTT+=i.uplinkRTT,this.networkQuality_.count++,i.downlinkLossAndRTTMap.forEach(function(o){var s=o.rtt,c=o.loss,u=o.userId,d=r.networkQuality_.totalDownlinkRTTAndLossMap.get(u);d?(d.totalRTT+=s,d.totalLoss+=c,d.count++):r.networkQuality_.totalDownlinkRTTAndLossMap.set(u,{totalRTT:s,totalLoss:c,count:1})}))}},{key:"handleHeartbeatStats",value:function(i){var r=this;if(this.hitTest(i.client)){var o=i.stats,s=o.msg_up_stream_info,c=o.msg_down_stream_info;if(s.msg_video_status[0]){var u=s.msg_video_status[0],d=u.uint32_video_codec_bitrate,g=u.uint32_video_enc_fps,I=u.uint32_video_width,k=u.uint32_video_height;this.localStreamStats_.totalVideoBitrate+=d,this.localStreamStats_.totalVideoFPS+=g,this.localStreamStats_.totalVideoWidth+=I,this.localStreamStats_.totalVideoHeight+=k,this.localStreamStats_.videoCount++}if(s.msg_audio_status){var w=s.msg_audio_status.audioLevel;Math.floor(100*w)>0&&(this.localStreamStats_.totalAudioLevel+=w,this.localStreamStats_.audioLevelCount++)}c.forEach(function(A){var p=A.msg_user_info,v=A.msg_audio_status,y=A.msg_video_status,L=p.str_identifier;if(y.forEach(function(S){var T=S.uint32_video_stream_type===2,C=S.uint32_video_stream_type===7,D="".concat(L,"_").concat(T?gt:Lt);if(r.remoteStreamStatsMap_.has(D)){var B,x,h=r.remoteStreamStatsMap_.get(D);(T&&(B=h.stream)!==null&&B!==void 0&&B.isMainVideoSubscribed||C&&(x=h.stream)!==null&&x!==void 0&&x.isAuxVideoSubscribed)&&(h.totalVideoFPS+=S.uint32_video_receive_fps,h.totalVideoBitrate+=S.uint32_video_codec_bitrate,h.videoCount++,h.statsToReport.uint32_video_width===0&&(h.statsToReport.uint32_video_width=S.uint32_video_width),h.statsToReport.uint32_video_height===0&&(h.statsToReport.uint32_video_height=S.uint32_video_height))}}),v){var f="".concat(L,"_").concat(gt);if(r.remoteStreamStatsMap_.has(f)){var b,P=r.remoteStreamStatsMap_.get(f);(b=P.stream)!==null&&b!==void 0&&b.isMainAudioSubscribed&&(P.totalAudioBitrate+=v.uint32_audio_codec_bitrate,P.audioCount++,Math.floor(100*v.audioLevel)>0&&(P.totalAudioLevel+=v.audioLevel,P.audioLevelCount++))}}})}}},{key:"handlePublishStart",value:function(i){var r=i.client;this.hitTest(r)&&this.localStreamStats_.publishStartTime===0&&(this.localStreamStats_.publishStartTime=Date.now())}},{key:"handleLocalStreamInitStart",value:function(i){var r=i.audio,o=i.video;r&&this.pathJoinRoom_.uint64_init_audio_start_time===0&&(this.pathJoinRoom_.uint64_init_audio_start_time=Date.now()),o&&this.pathJoinRoom_.uint64_init_camera_start_time===0&&(this.pathJoinRoom_.uint64_init_camera_start_time=Date.now())}},{key:"handleLocalStreamInitEnd",value:function(i){var r=i.audio,o=i.video;r&&this.pathJoinRoom_.uint64_init_audio_end_time===0&&(this.pathJoinRoom_.uint64_init_audio_end_time=Date.now()),o&&this.pathJoinRoom_.uint64_init_camera_end_time===0&&(this.pathJoinRoom_.uint64_init_camera_end_time=Date.now())}},{key:"handleLocalStreamInitFailed",value:function(i){var r=i.audio,o=i.video,s=i.error,c=s instanceof re?s.getExtraCode()||s.getCode():{NotFoundError:1,NotAllowedError:2,NotReadableError:3,OverConstrainedError:4,AbortError:5}[s.name]||ee.UNKNOWN;r&&this.pathJoinRoom_.uint64_init_audio_end_time===0&&(this.pathJoinRoom_.int32_init_audio_ret=c,this.pathJoinRoom_.uint64_init_audio_end_time=Date.now()),o&&this.pathJoinRoom_.uint64_init_camera_end_time===0&&(this.pathJoinRoom_.int32_init_camera_ret=c,this.pathJoinRoom_.uint64_init_camera_end_time=Date.now())}},{key:"hasVideoFlag",value:function(i){return this.firstPublishedUserList_.findIndex(function(r){return r.userId===i&&1&r.flag})>=0}},{key:"hasAudioFlag",value:function(i){return this.firstPublishedUserList_.findIndex(function(r){return r.userId===i&&8&r.flag})>=0}},{key:"hasAuxFlag",value:function(i){return this.firstPublishedUserList_.findIndex(function(r){return r.userId===i&&4&r.flag})>=0}},{key:"hitTest",value:function(i){return i===this.client_}},{key:"checkStorage",value:(a=G(m().mark(function i(){var r;return m().wrap(function(o){for(;;)switch(o.prev=o.next){case 0:if(o.prev=0,!(r=wo.getItem(this.storageKey_))){o.next=6;break}return o.next=5,this.upload(r);case 5:wo.deleteItem(this.storageKey_);case 6:o.next=11;break;case 8:o.prev=8,o.t0=o.catch(0),this.log_.warn(o.t0);case 11:case"end":return o.stop()}},i,this,[[0,8]])})),function(){return a.apply(this,arguments)})},{key:"setStorage",value:function(){this.prepareReport();var i=this.getReportData();i.msg_path_enter_room.uint64_start_time!==0&&wo.setItem(this.storageKey_,i)}},{key:"prepareReport",value:function(){var i=this;if(this.networkQuality_.count>0&&(this.basicInfo.uint32_avg_rtt=Math.floor(this.networkQuality_.totalUplinkRTT/this.networkQuality_.count),this.basicInfo.uint32_avg_up_loss=Math.floor(this.networkQuality_.totalUplinkLoss/this.networkQuality_.count)),this.localStreamStats_.videoCount>0){this.localStreamStats_.statsToReport.uint32_video_big_capture_fps=Math.floor(this.localStreamStats_.totalVideoFPS/this.localStreamStats_.videoCount),this.localStreamStats_.statsToReport.uint32_video_big_bitrate=Math.floor(this.localStreamStats_.totalVideoBitrate/this.localStreamStats_.videoCount);var r=Math.floor(this.localStreamStats_.totalVideoWidth/this.localStreamStats_.videoCount),o=Math.floor(this.localStreamStats_.totalVideoHeight/this.localStreamStats_.videoCount);this.localStreamStats_.statsToReport.uint32_video_big_resolution=r<<16|o}this.localStreamStats_.audioLevelCount>0&&(this.localStreamStats_.statsToReport.uint32_audio_capture_db=Math.floor(this.localStreamStats_.totalAudioLevel/this.localStreamStats_.audioLevelCount*100)),this.remoteStreamStatsMap_.forEach(function(s,c){var u=s.userId;if(i.networkQuality_.totalDownlinkRTTAndLossMap.has(u)){var d=i.networkQuality_.totalDownlinkRTTAndLossMap.get(u),g=d.totalLoss,I=d.count;s.statsToReport.uint32_avg_down_loss=Math.floor(g/I)}s.videoCount>0&&(s.statsToReport.uint32_video_avg_fps=Math.floor(s.totalVideoFPS/s.videoCount),s.statsToReport.uint32_video_avg_bitrate=Math.floor(s.totalVideoBitrate/s.videoCount)),s.audioCount>0&&(s.statsToReport.uint32_audio_recv_bitrate=s.statsToReport.uint32_audio_bitrate=Math.floor(s.totalAudioBitrate/s.audioCount)),s.audioLevelCount>0&&(s.statsToReport.uint32_audio_play_db=Math.floor(s.totalAudioLevel/s.audioLevelCount*100));var k=i.client_.getCallDurationCalculator();k&&(s.statsToReport.uint32_audio_play_time=k.getDuration(c,Ae),s.statsToReport.uint32_video_play_time=k.getDuration(c,xe)),s.statsToReport.uint32_video_render_first=Math.min(s.statsToReport.uint32_video_render_first,Ia);var w=i.client_.getBadCaseDetector();if(w){var A=w.getDataFreezeDuration(c),p=A.dataFreeze,v=A.count,y=w.getRenderFreezeDuration(c).renderFreeze;s.statsToReport.uint32_video_block_count=v,s.statsToReport.uint32_video_block_time=Math.min(p,s.statsToReport.uint32_video_play_time),s.statsToReport.uint32_video_external_block_time=Math.min(y,s.statsToReport.uint32_video_play_time),w.isBlackStream(c)&&s.statsToReport.uint32_video_avg_fps===0?s.statsToReport.uint32_video_black_screen_subjective=1:s.statsToReport.uint32_video_black_screen_subjective=0}(s.subscribeStartTime===0||s.subscribeStartTime-s.streamAddedTime>100||s.playStreamTime===0)&&(i.pathMainAudioMap_.delete(c),i.pathMainVideoMap_.delete(c),s.statsToReport.uint32_video_render_first=0)}),this.pathMainAudioMap_.forEach(function(s,c){i.hasAudioFlag(s.userId)?s.statsToReport.uint64_play_first_frame_time-s.statsToReport.uint64_start_enter_time>Ia&&(s.statsToReport.uint64_play_first_frame_time=s.statsToReport.uint64_start_enter_time+Ia):i.pathMainAudioMap_.delete(c)}),this.pathMainVideoMap_.forEach(function(s,c){i.hasVideoFlag(s.userId)?s.statsToReport.uint64_render_first_frame_time-s.statsToReport.uint64_start_enter_time>Ia&&(s.statsToReport.uint64_render_first_frame_time=s.statsToReport.uint64_start_enter_time+Ia):i.pathMainVideoMap_.delete(c)}),this.pathJoinRoom_.uint64_end_time-this.pathJoinRoom_.uint64_start_time>Ia&&(this.pathJoinRoom_.uint64_end_time=this.pathJoinRoom_.uint64_start_time+Ia)}},{key:"getReportData",value:function(){var i=this.client_.getSignalInfo();return{uint32_sdk_app_id:Number(this.client_.getSDKAppId()),msg_user_info:new Fv({userId:this.client_.getUserId(),tinyId:this.client_.getTinyId(),role:this.client_.getRole()===br?fo:Vp}),msg_basic_info:this.basicInfo,uint32_acc_ip:wf(i.relayIp),uint32_client_ip:wf(i.clientIp,"small"),uint32_acc_port:0,uint64_timestamp:Date.now(),uint32_seq:Math.floor(Math.random()*Math.pow(2,31)),msg_path_enter_room:this.pathJoinRoom_,msg_path_exit_room:this.pathLeaveRoom_,msg_path_recv_video:be(this.pathMainVideoMap_.values()).map(function(r){return r.statsToReport}),msg_quality_statistics:be(this.remoteStreamStatsMap_.values()).map(function(r){return r.statsToReport}),str_room_name:String(this.client_.getRoomId()),msg_path_recv_audio:be(this.pathMainAudioMap_.values()).map(function(r){return r.statsToReport}),uint32_info_client_ip:wf(i.clientIp,"small"),error_code:[],msg_local_statistics:this.localStreamStats_.statsToReport,msg_function_state:Ui.getStateArray()}}},{key:"report",value:(n=G(m().mark(function i(){var r;return m().wrap(function(o){for(;;)switch(o.prev=o.next){case 0:return o.prev=0,r=this.getReportData(),o.next=4,this.upload(r);case 4:wo.deleteItem(this.storageKey_),Ui.clearStateArray(),this.initData(),o.next=12;break;case 9:o.prev=9,o.t0=o.catch(0),this.log_.warn(o.t0);case 12:case"end":return o.stop()}},i,this,[[0,9]])})),function(){return n.apply(this,arguments)})},{key:"upload",value:(t=G(m().mark(function i(r){var o,s,c;return m().wrap(function(u){for(;;)switch(u.prev=u.next){case 0:if(!(ha||r.msg_path_enter_room.uint64_start_time===0||[Qp,$b,Zb].findIndex(function(d){return d===location.host})>=0)){u.next=2;break}return u.abrupt("return");case 2:return o=Number(this.client_.getSDKAppId()),s=ll(o,$M),u.next=6,hl({url:s,body:JSON.stringify(r)});case 6:if((c=u.sent).data==="ok"){u.next=9;break}throw"key point upload failed: ".concat(c.data);case 9:case"end":return u.stop()}},i,this)})),function(i){return t.apply(this,arguments)})}]),e}(),Y(Rc.prototype,"upload",[xx],Object.getOwnPropertyDescriptor(Rc.prototype,"upload"),Rc.prototype),Rc),Ui=function(){function e(){K(this,e)}return we(e,null,[{key:"handleFunctionState",value:function(t){var n,a,i,r,o=t.className,s=t.fnName,c=t.params;if(!(ha||[Qp,$b,Zb].findIndex(function(I){return I===location.host})>=0)){var u,d=[];if(o)switch(s){case"createClient":(n=c[0])!==null&&n!==void 0&&n.mode&&d.push("".concat(o,".").concat(s,".").concat(c[0].mode)),(a=c[0])!==null&&a!==void 0&&a.useStringRoomId?d.push("".concat(o,".").concat(s,".stringRoomId")):d.push("".concat(o,".").concat(s,".intRoomId")),(i=c[0])!==null&&i!==void 0&&i.autoSubscribe?d.push("".concat(o,".").concat(s,".autoSubscribe")):d.push("".concat(o,".").concat(s,".manualSubscribe"));break;case"publish":(r=c[1])!==null&&r!==void 0&&r.isAuxiliary?d.push("".concat(o,".").concat(s,".isAuxiliary")):d.push("".concat(o,".").concat(s));break;case"setAudioProfile":case"setVideoProfile":case"setScreenProfile":case"setVideoContentHint":Vt(c[0])&&d.push("".concat(o,".").concat(s,".").concat(c[0]));break;default:d.push("".concat(o,".").concat(s))}else d.push(s);for(var g=0;g<d.length;g++){if(!(u=bN[d[g]]))return;this.stateMap.has(u)?this.stateMap.get(u).int32_call_times+=1:this.stateMap.set(u,{int32_id:u,int32_call_times:1})}}}},{key:"getStateArray",value:function(){return Array.from(this.stateMap.values())}},{key:"clearStateArray",value:function(){this.stateMap.clear()}}]),e}();function St(e){return function(t,n,a){var i=a.value;return a.value=function(){for(var r=arguments.length,o=new Array(r),s=0;s<r;s++)o[s]=arguments[s];try{e||(e=this.name_),Ui.handleFunctionState({className:e,fnName:n,params:o}),e=void 0}catch(c){this.log_.info(c)}return i.apply(this,o)},a}}Ye(Ui,"stateMap",new Map);var Cx=(Ix=Cn.apply(void 0,be(Jt.STREAM.play)),wx=St(),Ex=St(),or=function(){function e(o){K(this,e),this.name_=mN,this.userId_=o.userId,this.isRemote_=o.isRemote,this.type_=o.type,this.log_=_e.createLogger({id:"s".concat(o.seq?o.seq:"","|").concat(this.userId_),userId:ge(o.client)?void 0:o.client.getUserId(),sdkAppId:ge(o.client)?void 0:o.client.getSDKAppId(),isLocal:!this.isRemote_,type:this.isRemote_?this.type_:""}),this.client_=null,ge(o.client)||(this.client_=o.client),this.mediaStream_=null,this.div_=null,this.isPlaying_=!1,this.connection_=null,this.audioPlayer_=null,this.videoPlayer_=null,this.muted_=!1,this.objectFit_="cover",this.mirror_=!1,this.id_="xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(s){var c=16*Math.random()|0;return(s=="x"?c:3&c|8).toString(16)}),this.audioOutputDeviceId_=0,this.audioVolume_=1,this.emitter_=zS(new Ri,this.name_),this.connectionState_=on,this.installEvents(),ge(o.mirror)||this.log_.warn('TRTC.createStream "mirror" option was deprecated since v4.12.1\uFF0Cplease use localStream.play to set up preview mirror. refer to '.concat(mo,"/en/LocalStream.html#play. TRTC.createStream \u63A5\u53E3\u7684 mirror \u9009\u9879\u4ECE v4.12.1 \u5F00\u59CB\u88AB\u5E9F\u5F03\uFF0C\u8BF7\u4F7F\u7528 localStream.play \u8BBE\u7F6E\u672C\u5730\u6D41\u9884\u89C8\u955C\u50CF\uFF0C\u53C2\u8003\u6587\u6863\uFF1A").concat(mo,"/zh-cn/LocalStream.html#play\u3002"))}var t,n,a,i,r;return we(e,[{key:"installEvents",value:function(){X.on(lc,this.restartPlayback,this)}},{key:"uninstallEvents",value:function(){X.off(lc,this.restartPlayback,this)}},{key:"getType",value:function(){return this.type_}},{key:"getLogger",value:function(){return this.log_}},{key:"isSubscribed",get:function(){return this.type_===gt&&this.connection_.isMainStreamSubscribed||this.type_===Lt&&this.connection_.isAuxStreamSubscribed}},{key:"isMainVideoSubscribed",get:function(){var o=this.getSubscribedState();return this.type_===gt&&o&&o.video}},{key:"isMainAudioSubscribed",get:function(){var o=this.getSubscribedState();return this.type_===gt&&o&&o.audio}},{key:"isAuxVideoSubscribed",get:function(){var o=this.getSubscribedState();return this.type_===Lt&&o&&o.auxiliary}},{key:"isSmallVideoSubscribed",get:function(){var o=this.getSubscribedState();return this.type_===gt&&o&&o.smallVideo}},{key:"emitConnectionStateChanged",value:function(o){o.state!==this.connectionState_&&(o.state!==on&&this.isRemote_&&!this.isSubscribed||(this.emitter_.emit(n6,o),this.connectionState_=o.state))}},{key:"setConnection",value:function(o){this.connection_!==o&&(o instanceof jv?(this.connection_!==null&&this.connection_.off(Ze.CONNECTION_STATE_CHANGED,this.emitConnectionStateChanged,this),o.on(Ze.CONNECTION_STATE_CHANGED,this.emitConnectionStateChanged,this)):o===null&&this.connection_.off(Ze.CONNECTION_STATE_CHANGED,this.emitConnectionStateChanged,this),this.connection_=o)}},{key:"getConnection",value:function(){return this.connection_}},{key:"play",value:(r=G(m().mark(function o(s,c){var u,d,g;return m().wrap(function(I){for(;;)switch(I.prev=I.next){case 0:if(this.log_.info("stream ".concat(this.isPlaying_?"update":"start to"," play with elementId: ").concat(s," and options: ").concat(JSON.stringify(c),".")),!this.isPlaying_){I.next=9;break}return c&&!ge(c.muted)&&(this.muted_=c.muted),c&&!ge(c.objectFit)&&(this.objectFit_=c.objectFit),this.isScreenShare()?this.mirror_=!1:c&&!ge(c.mirror)&&(this.mirror_=c.mirror),this.audioPlayer_&&this.audioPlayer_.setMuted(this.muted_),this.videoPlayer_&&(this.videoPlayer_.setObjectFit(this.objectFit_),this.videoPlayer_.setMirror(this.mirror_)),this.elementId_!==s&&(u=s,Vt(s)&&(u=document.getElementById(s)),u.appendChild(this.div_),this.elementId_=s),I.abrupt("return");case 9:return this.isPlaying_=!0,(d=document.createElement("div")).setAttribute("id","player_".concat(this.id_)),d.setAttribute("style","width: 100%; height: 100%; position: relative; background-color: black; overflow: hidden;"),g=s,Vt(s)&&(g=document.getElementById(s)),g.appendChild(d),this.elementId_=s,this.div_=d,this.isRemote_||(this.muted_=!0),c&&!ge(c.muted)&&(this.muted_=c.muted),this.isScreenShare()&&(this.objectFit_="contain"),c&&!ge(c.objectFit)&&(this.objectFit_=c.objectFit),this.isScreenShare()?this.mirror_=!1:(this.isRemote_||(this.mirror_=!0),c&&!ge(c.mirror)&&(this.mirror_=c.mirror)),X.emit(Wf,{stream:this}),I.next=26,Promise.all([this.playAudio(),this.playVideo()]);case 26:X.emit(F4,{stream:this});case 27:case"end":return I.stop()}},o,this)})),function(o,s){return r.apply(this,arguments)})},{key:"playAudio",value:(i=G(m().mark(function o(){var s,c,u=this;return m().wrap(function(d){for(;;)switch(d.prev=d.next){case 0:if(this.hasAudio()&&(!this.isRemote_||this.isMainAudioSubscribed)){d.next=2;break}return d.abrupt("return");case 2:if(s=this.getAudioTrack(),this.audioPlayer_||!s){d.next=17;break}return this.log_.info("create AudioPlayer and play"),this.audioPlayer_=new r5({stream:this,track:s,gainedTrack:(c=this.gain_)===null||c===void 0?void 0:c.audioTrack,div:this.div_,muted:this.muted_,outputDeviceId:this.audioOutputDeviceId_,volume:this.audioVolume_}),this.audioPlayer_.on(bn,function(g){var I={type:Ae,state:g.state,reason:g.reason};X.emit(QS,q({stream:u},I)),u.emitter_.emit(zk,I)}),d.prev=7,d.next=10,this.audioPlayer_.play();case 10:d.next=17;break;case 12:throw d.prev=12,d.t0=d.catch(7),this.client_&&this.client_.getEnableAutoPlayDialog()&&new MT,this.emitter_.emit(Im,d.t0),d.t0;case 17:case"end":return d.stop()}},o,this,[[7,12]])})),function(){return i.apply(this,arguments)})},{key:"playVideo",value:(a=G(m().mark(function o(){var s,c=this;return m().wrap(function(u){for(;;)switch(u.prev=u.next){case 0:if(this.hasVideo()&&(!this.isRemote_||this.isMainVideoSubscribed||this.isAuxVideoSubscribed||this.isSmallVideoSubscribed)){u.next=2;break}return u.abrupt("return");case 2:if(s=this.getVideoTrack(),this.videoPlayer_||!s){u.next=18;break}return X.emit(Jf,{stream:this}),this.log_.info("create VideoPlayer and play"),this.videoPlayer_=new NT({stream:this,track:s,div:this.div_,muted:this.muted_,objectFit:this.objectFit_,mirror:this.mirror_}),this.videoPlayer_.on(bn,function(d){var g={type:xe,state:d.state,reason:d.reason};X.emit(QS,q({stream:c},g)),c.emitter_.emit(zk,g)}),u.prev=8,u.next=11,this.videoPlayer_.play();case 11:u.next=18;break;case 13:throw u.prev=13,u.t0=u.catch(8),this.client_&&this.client_.getEnableAutoPlayDialog()&&new MT,this.emitter_.emit(Im,u.t0),u.t0;case 18:case"end":return u.stop()}},o,this,[[8,13]])})),function(){return a.apply(this,arguments)})},{key:"stopAudio",value:function(){this.audioPlayer_&&(this.log_.info("stop AudioPlayer"),this.audioPlayer_.stop(),this.audioPlayer_=null)}},{key:"stopVideo",value:function(){this.videoPlayer_&&(this.log_.info("stop VideoPlayer"),this.videoPlayer_.stop(),this.videoPlayer_=null)}},{key:"restartPlayback",value:function(){this.audioPlayer_&&!this.audioPlayer_.isPlaying&&this.restartAudio(),this.videoPlayer_&&!this.videoPlayer_.isPlaying&&this.restartVideo()}},{key:"restartAudio",value:function(){this.isPlaying_&&(this.stopAudio(),this.playAudio().catch(function(o){}))}},{key:"restartVideo",value:function(){this.isPlaying_&&(this.stopVideo(),this.playVideo().catch(function(o){}))}},{key:"stop",value:function(){this.isPlaying_&&(this.isPlaying_=!1,this.stopAudio(),this.stopVideo(),this.div_.parentNode.removeChild(this.div_))}},{key:"resume",value:(n=G(m().mark(function o(){return m().wrap(function(s){for(;;)switch(s.prev=s.next){case 0:if(this.isPlaying_){s.next=2;break}return s.abrupt("return");case 2:if(this.log_.info("resume"),!this.audioPlayer_){s.next=6;break}return s.next=6,this.audioPlayer_.resume();case 6:if(!this.videoPlayer_){s.next=9;break}return s.next=9,this.videoPlayer_.resume();case 9:case"end":return s.stop()}},o,this)})),function(){return n.apply(this,arguments)})},{key:"close",value:function(){this.log_.info("close stream"),this.isPlaying_&&this.stop(),this.isRemote_||(this.mediaStream_&&(this.mediaStream_.preventEvent=1,this.mediaStream_.getTracks().forEach(function(o){o.stop()}),this.mediaStream_=null),this.uninstallEvents())}},{key:"muteAudio",value:function(){return this.addRemoteEvent(!0,Ae),this.doEnableTrack(Ae,!1)}},{key:"muteVideo",value:function(){return this.addRemoteEvent(!0,xe),this.doEnableTrack(xe,!1)}},{key:"unmuteAudio",value:function(){return this.addRemoteEvent(!1,Ae),this.doEnableTrack(Ae,!0)}},{key:"unmuteVideo",value:function(){return this.addRemoteEvent(!1,xe),this.doEnableTrack(xe,!0)}},{key:"addRemoteEvent",value:function(o,s){if(this.isRemote_&&this.client_){var c=this.client_.getUserId(),u="".concat(o?Zt:_r," remote ").concat(s);yn(c,{eventId:s===Ae?o?aV:sV:o?iV:oV,eventDesc:u,timestamp:new Date().getTime(),userId:c,tinyId:this.client_.getTinyId(),remoteUserId:this.userId_,remoteTinyId:this.connection_.getTinyId()})}}},{key:"doEnableTrack",value:function(o,s){var c=!1;return o===Ae?this.mediaStream_.getAudioTracks().forEach(function(u){c=!0,u.enabled=s}):this.mediaStream_.getVideoTracks().forEach(function(u){c=!0,u.enabled=s}),c}},{key:"getId",value:function(){return this.id_}},{key:"getUserId",value:function(){return this.userId_}},{key:"getTinyId",value:function(){return this.connection_?this.connection_.getTinyId():""}},{key:"isPlaying",value:function(){return this.isPlaying_}},{key:"setAudioOutput",value:(t=G(m().mark(function o(s){var c;return m().wrap(function(u){for(;;)switch(u.prev=u.next){case 0:if(this.log_.info("setAudioOutput ".concat(s)),this.audioOutputDeviceId_=s,!this.audioPlayer_){u.next=5;break}return u.next=5,this.audioPlayer_.setSinkId(s);case 5:return u.next=7,Kk();case 7:c=u.sent,this.log_.info("speakers: ".concat(JSON.stringify(c)));case 9:case"end":return u.stop()}},o,this)})),function(o){return t.apply(this,arguments)})},{key:"setAudioVolume",value:function(o){this.audioVolume_=o,this.log_.info("setAudioVolume to ".concat(o)),this.audioPlayer_&&this.audioPlayer_.setVolume(o)}},{key:"getAudioLevel",value:function(){var o=0;return this.audioPlayer_&&(o=this.audioPlayer_.getAudioLevel()),o}},{key:"getInternalAudioLevel",value:function(){var o=0;return this.audioPlayer_&&(o=this.audioPlayer_.getInternalAudioLevel()),o}},{key:"hasAudio",value:function(){if(this.isRemote_){if(!this.connection_)return!1;var o=this.connection_.getTrackState();return this.type_===gt&&o.audio}return!!this.getAudioTrack()}},{key:"hasVideo",value:function(){if(this.isRemote_){if(!this.connection_)return!1;var o=this.connection_.getTrackState();return this.type_===Lt?o.auxiliary:o.video}return!!this.getVideoTrack()}},{key:"getSubscribedState",value:function(){return this.isRemote_&&this.connection_?this.connection_.getSubscribeState():null}},{key:"getAudioTrack",value:function(){var o=null;if(this.mediaStream_){var s=this.mediaStream_.getAudioTracks();s.length>0&&(o=s[0])}return o}},{key:"getVideoTrack",value:function(){var o=null;if(this.mediaStream_){var s=this.mediaStream_.getVideoTracks();s.length>0&&(o=s[0])}return o}},{key:"getVideoFrame",value:function(){return this.videoPlayer_?this.videoPlayer_.getVideoFrame():null}},{key:"getMediaStream",value:function(){return this.mediaStream_}},{key:"setMediaStream",value:function(o){o!==this.mediaStream_&&(this.mediaStream_&&this.mediaStream_.getTracks().forEach(function(s){return s.stop()}),this.mediaStream_=o)}},{key:"updateVideoPlayingState",value:function(o){this.isPlaying_&&(o?(this.log_.info("playing state updated, play video"),this.playVideo().catch(function(s){})):(this.log_.info("playing state updated, stop video"),this.stopVideo()))}},{key:"updateAudioPlayingState",value:function(o){this.isPlaying_&&(o?(this.log_.info("playing state updated, play audio"),this.playAudio().catch(function(s){})):(this.log_.info("playing state updated, stop audio"),this.stopAudio()))}},{key:"on",value:function(o,s,c){this.emitter_.on(o,s,c)}},{key:"off",value:function(o,s,c){o==="*"?this.emitter_.removeAllListeners():this.emitter_.off(o,s,c)}},{key:"isRemote",value:function(){return this.isRemote_}},{key:"isScreenShare",value:function(){return!this.isRemote_&&this.screen_||this.isRemote_&&this.getType()===pt}},{key:"getDiv",value:function(){return this.div_}},{key:"getObjectFit",value:function(){return this.objectFit_}},{key:"getMuted",value:function(){return this.muted_}},{key:"getClient",value:function(){return this.client_}}]),e}(),Y(or.prototype,"play",[Ix],Object.getOwnPropertyDescriptor(or.prototype,"play"),or.prototype),Y(or.prototype,"setAudioOutput",[wx],Object.getOwnPropertyDescriptor(or.prototype,"setAudioOutput"),or.prototype),Y(or.prototype,"getVideoFrame",[Ex],Object.getOwnPropertyDescriptor(or.prototype,"getVideoFrame"),or.prototype),or),Gv=function(e){Ct(n,e);var t=Cr(n);function n(a){var i;K(this,n);var r={isRemote:!0,type:a.type},o=q(q({},a),r);return(i=t.call(this,o)).name_=Xp,i.isStreamAddedEventEmitted_=!1,i.isAbleToCallSubscription_=!0,i}return we(n,[{key:"installEvents",value:function(){oe(Xe(n.prototype),"installEvents",this).call(this),X.on(Wr,this.handleStreamSubscribed,this),X.on(qr,this.handleStreamUnsubscribed,this)}},{key:"uninstallEvents",value:function(){oe(Xe(n.prototype),"uninstallEvents",this).call(this),X.off(Wr,this.handleStreamSubscribed,this),X.off(qr,this.handleStreamUnsubscribed,this)}},{key:"handleStreamSubscribed",value:function(a){a.client===this.client_&&a.stream===this&&this.connection_.getCurrentState()===_n&&this.emitConnectionStateChanged({prevState:on,state:_n})}},{key:"handleStreamUnsubscribed",value:function(a){a.client===this.client_&&a.stream===this&&this.emitConnectionStateChanged({prevState:_n,state:on})}},{key:"getType",value:function(){return oe(Xe(n.prototype),"getType",this).call(this)}},{key:"getIsAbleToCallSubscription",value:function(){return this.isAbleToCallSubscription_}},{key:"setIsAbleToCallSubscription",value:function(a){this.isAbleToCallSubscription_=a}},{key:"setIsStreamAddedEventEmitted",value:function(a){this.isStreamAddedEventEmitted_=a}},{key:"getIsStreamAddedEventEmitted",value:function(){return this.isStreamAddedEventEmitted_}},{key:"getAudioTrack",value:function(){return this.connection_&&this.connection_.getTrackState().audio?oe(Xe(n.prototype),"getAudioTrack",this).call(this):null}},{key:"getVideoTrack",value:function(){if(!this.connection_)return null;var a=this.connection_.getTrackState();return(this.type_!==gt||a.video)&&(this.type_!==Lt||a.auxiliary)?oe(Xe(n.prototype),"getVideoTrack",this).call(this):null}},{key:"close",value:function(){oe(Xe(n.prototype),"close",this).call(this)}}]),n}(Cx),bF=function(){function e(i){K(this,e),this.client_=i.client,this.subscribedStreams_=new Map,this.unsubscribedStreams_=new Map,this.subscriptedOptions_=new Map,this.autoRecoveryFlags_=new Map}var t,n,a;return we(e,[{key:"isEnabled",get:function(){return this.client_.getEnv()!=="webrtc"}},{key:"recover",value:(a=G(m().mark(function i(r){var o,s,c;return m().wrap(function(u){for(;;)switch(u.prev=u.next){case 0:if(o=r.getUserId(),s=r.getType(),this.hasAutoRecoveryFlag(o,s)){u.next=5;break}return u.abrupt("return");case 5:if(c=this.getUnsubscribedStream(o,s)?"unsubscribe":"subscribe",u.prev=6,_e.warn("recover() try to recover subscription [".concat(c,"][").concat(o,"][").concat(s,"]")),c!=="subscribe"){u.next=13;break}return u.next=11,this.recoverSubscription(o,r);case 11:u.next=15;break;case 13:return u.next=15,this.recoverUnsubscription(o,r);case 15:Ie.logSuccessEvent({userId:this.client_.getUserId(),eventType:Bb}),_e.warn("recover() recover successfully [".concat(c,"][").concat(o,"][").concat(s,"]")),u.next=23;break;case 19:u.prev=19,u.t0=u.catch(6),_e.error("recover() recover failed [".concat(c,"][").concat(o,"][").concat(s,"]"),u.t0),Ie.logFailedEvent({userId:this.client_.getUserId(),eventType:Bb,error:u.t0});case 23:this.deleteAutoRecoveryFlag(o,s);case 24:case"end":return u.stop()}},i,this,[[6,19]])})),function(i){return a.apply(this,arguments)})},{key:"recoverSubscription",value:(n=G(m().mark(function i(r,o){var s,c,u,d,g;return m().wrap(function(I){for(;;)switch(I.prev=I.next){case 0:if(s=this.getOptions(r,o.getType()),c=this.getSubscribedStream(r,o.getType()),s&&c){I.next=4;break}return I.abrupt("return");case 4:u=this.getStreamMuteState(c),d=u.isAudioMuted,g=u.isVideoMuted,this.mergeStream(c,o),this.recoverPlayingState(c),d&&c.doEnableTrack(Ae,!1),g&&c.doEnableTrack(xe,!1);case 9:case"end":return I.stop()}},i,this)})),function(i,r){return n.apply(this,arguments)})},{key:"recoverUnsubscription",value:(t=G(m().mark(function i(r,o){var s;return m().wrap(function(c){for(;;)switch(c.prev=c.next){case 0:if(s=this.getUnsubscribedStream(r,o.getType())){c.next=3;break}return c.abrupt("return");case 3:this.mergeStream(s,o);case 4:case"end":return c.stop()}},i,this)})),function(i,r){return t.apply(this,arguments)})},{key:"getStreamMuteState",value:function(i){var r={isAudioMuted:!1,isVideoMuted:!1},o=i.getMediaStream();return o&&(r.isAudioMuted=o.getAudioTracks().map(function(s){return s.enabled}).includes(!1),r.isVideoMuted=o.getVideoTracks().map(function(s){return s.enabled}).includes(!1)),r}},{key:"recoverPlayingState",value:function(i){var r=i.isPlaying(),o=i.getDiv();if(r&&o){var s=o.parentNode;i.stop(),i.play(s,{objectFit:i.getObjectFit(),muted:i.getMuted()})}}},{key:"mergeStream",value:function(i,r){var o=r.getConnection(),s=r.getMediaStream();i.setConnection(o),o.setRemoteStream(s.id,i),i.setMediaStream(s),i.updateAudioPlayingState(r.hasAudio()),i.updateVideoPlayingState(r.hasVideo())}},{key:"addSubscriptionRecord",value:function(i,r,o){var s=r.getType();if(this.subscribedStreams_.has(i))this.subscribedStreams_.get(i).set(s,r);else{var c=new Map;c.set(r.getType(),r),this.subscribedStreams_.set(i,c)}if(this.subscriptedOptions_.has(i))this.subscriptedOptions_.get(i).set(s,o);else{var u=new Map;u.set(r.getType(),o),this.subscriptedOptions_.set(i,u)}this.deleteUnsubscriptionRecord(i,s)}},{key:"addUnsubscriptionRecord",value:function(i,r){if(this.unsubscribedStreams_.has(i))this.unsubscribedStreams_.get(i).set(r.getType(),r);else{var o=new Map;o.set(r.getType(),r),this.unsubscribedStreams_.set(i,o)}this.deleteSubscriptionRecord(i,r.getType())}},{key:"getSubscribedStream",value:function(i,r){return this.subscribedStreams_.has(i)&&this.subscribedStreams_.get(i).has(r)?this.subscribedStreams_.get(i).get(r):null}},{key:"getOptions",value:function(i,r){return this.subscriptedOptions_.has(i)&&this.subscriptedOptions_.get(i).has(r)?this.subscriptedOptions_.get(i).get(r):null}},{key:"getUnsubscribedStream",value:function(i,r){return this.unsubscribedStreams_.has(i)&&this.unsubscribedStreams_.get(i).has(r)?this.unsubscribedStreams_.get(i).get(r):null}},{key:"deleteSubscriptionRecord",value:function(i,r){this.subscribedStreams_.has(i)&&this.subscribedStreams_.get(i).delete(r),this.subscriptedOptions_.has(i)&&this.subscriptedOptions_.get(i).delete(r)}},{key:"deleteUnsubscriptionRecord",value:function(i,r){this.unsubscribedStreams_.has(i)&&this.unsubscribedStreams_.get(i).delete(r)}},{key:"markAllStream",value:function(){for(var i=0,r=be(this.subscribedStreams_.entries());i<r.length;i++)for(var o=Te(r[i],2),s=o[0],c=0,u=be(o[1].entries());c<u.length;c++){var d=Te(u[c],1)[0];this.setAutoRecoveryFlag(s,d)}for(var g=0,I=be(this.unsubscribedStreams_.entries());g<I.length;g++)for(var k=Te(I[g],2),w=k[0],A=0,p=be(k[1].entries());A<p.length;A++){var v=Te(p[A],1)[0];this.setAutoRecoveryFlag(w,v)}}},{key:"setAutoRecoveryFlag",value:function(i,r){if(_e.info("setAutoRecoveryFlag() mark [".concat(i,"][").concat(r,"]")),this.autoRecoveryFlags_.has(i))this.autoRecoveryFlags_.get(i).set(r);else{var o=new Map;o.set(r),this.autoRecoveryFlags_.set(i,o)}}},{key:"hasAutoRecoveryFlag",value:function(i,r){return!!this.isEnabled&&this.autoRecoveryFlags_.has(i)&&this.autoRecoveryFlags_.get(i).has(r)}},{key:"deleteAutoRecoveryFlag",value:function(i,r){this.autoRecoveryFlags_.has(i)&&this.autoRecoveryFlags_.get(i).delete(r)}},{key:"delete",value:function(i){this.unsubscribedStreams_.delete(i),this.subscribedStreams_.delete(i),this.subscriptedOptions_.delete(i),this.autoRecoveryFlags_.delete(i)}}]),e}(),SF=function(){function e(t){K(this,e),this.player_=t,this.canvas_=document.createElement(mb),this.canvasCtx_=this.canvas_.getContext("2d")}return we(e,[{key:"setCanvasRect",value:function(t,n){this.canvas_.width=t,this.canvas_.height=n}},{key:"drawVideoToCanvas",value:function(){var t=this.player_.getElement(),n=t.videoHeight,a=t.videoWidth,i=a*this.canvas_.height/(n*this.canvas_.width);if(i>1.05||i<.95){var r=a*n/(this.canvas_.width*this.canvas_.height);this.setCanvasRect(a/Math.sqrt(r),n/Math.sqrt(r))}this.canvasCtx_.drawImage(t,0,0,this.canvas_.width,this.canvas_.height)}},{key:"generateVideoTrackFromCanvasCapture",value:function(t){return this.canvas_.captureStream(t).getVideoTracks()[0]}},{key:"generateStreamFromTrack",value:function(t){var n=new MediaStream;return n.addTrack(t),n}},{key:"destroy",value:function(){this.player_.stop(),this.canvas_.width=0,this.canvas_.height=0,this.canvas_=null,this.canvasCtx_=null}},{key:"canvas",get:function(){return this.canvas_}},{key:"canvasCtx",get:function(){return this.canvasCtx_}},{key:"canDrawVideoToCanvas",get:function(){if(this.player_){var t=this.player_.getElement();if(t)return t.readyState===t.HAVE_ENOUGH_DATA}return!1}}]),e}(),kF=new Blob(['let t,e,a,i;onmessage=function(n){const{action:h,data:s}=n.data;switch(h){case"render":a=s.canvas,t=a.width,e=a.height,i=a.getContext("2d"),function(t,e){const n=new TransformStream({async transform(t,e){const n=t.displayWidth,h=t.displayHeight,s=n*a.height/(h*a.width);if(s>1.05||s<.95){const t=n*h/(a.width*a.height);a.width=n/Math.sqrt(t),a.height=h/Math.sqrt(t)}i.drawImage(t,0,0,a.width,a.height);const o=new VideoFrame(a,{timestamp:t.timestamp});t.close(),e.enqueue(o)}});t.pipeThrough(n).pipeTo(e)}(s.readable,s.writable)}}'],{type:"application/javascript"}),TF=function(){function e(t){K(this,e);var n=t.videoTrack;this.width=void 0,this.height=void 0,this.canvas=document.createElement("canvas"),this.offscreen=null,this.smallGenerator=new MediaStreamTrackGenerator({kind:"video"}),this.smallWritable=this.smallGenerator.writable,this.bigProcessor=new MediaStreamTrackProcessor({track:n}),this.bigReadable=this.bigProcessor.readable,this.initWorker()}return we(e,[{key:"initWorker",value:function(){try{this.worker=new Worker(URL.createObjectURL(kF)),_e.info("init worker processor success")}catch(t){_e.warn("init worker processor failed. ".concat(t.error))}}},{key:"setCanvasRect",value:function(t,n){this.width=t,this.height=n,this.canvas.width=t,this.canvas.height=n,this.offscreen=this.canvas.transferControlToOffscreen(),this.worker.postMessage({action:"render",data:{canvas:this.offscreen,readable:this.bigReadable,writable:this.smallWritable}},[this.offscreen,this.bigReadable,this.smallWritable])}},{key:"generatorVideoTrack",value:function(){var t=new MediaStream([this.smallGenerator]);return t==null?void 0:t.getTracks()[0]}},{key:"destroy",value:function(){this.worker.terminate()}}]),e}(),Zl=function(){function e(n){K(this,e),this.localStream_=n,this.player_=null,this.processor_=null,this.initOffscreenSuccess_=!1}var t;return we(e,[{key:"initialize",value:(t=G(m().mark(function n(){var a;return m().wrap(function(i){for(;;)switch(i.prev=i.next){case 0:if(!(e6()&&((a=navigator)===null||a===void 0?void 0:a.hardwareConcurrency)>=6)){i.next=13;break}return i.prev=1,i.next=4,this.initOffscreen();case 4:this.initOffscreenSuccess_=!0,_e.info("Initialize VideoGenerator successfully!"),i.next=11;break;case 8:i.prev=8,i.t0=i.catch(1),this.initCanvas();case 11:i.next=14;break;case 13:this.initCanvas();case 14:case"end":return i.stop()}},n,this,[[1,8]])})),function(){return t.apply(this,arguments)})},{key:"generateSmallVideoTrack",value:function(n){var a,i=n.height,r=n.width,o=n.frameRate,s=this.getSmallVideoProfile(r,i);return this.initOffscreenSuccess_?(this.processor_.setCanvasRect(s.width,s.height),a=this.processor_.generatorVideoTrack()):(this.processor_.setCanvasRect(s.width,s.height),this.player_.setRect({width:s.width,height:s.height}),a=this.processor_.generateVideoTrackFromCanvasCapture(o),this.interval_=_t.run(el,this.render.bind(this),{fps:o})),a}},{key:"render",value:function(){this.processor_.canDrawVideoToCanvas&&this.processor_.drawVideoToCanvas()}},{key:"destroy",value:function(){_t.clearTask(this.interval_),this.processor_&&this.processor_.destroy()}},{key:"initOffscreen",value:function(){this.processor_=new TF({videoTrack:this.localStream_.getVideoTrack()})}},{key:"initCanvas",value:function(){this.player_=new NT({stream:this.localStream_,track:this.localStream_.getVideoTrack(),muted:!0,objectFit:"cover",mirror:!1}),this.player_.play().then(function(){_e.info("VideoGenerator: play local video success")}).catch(function(){_e.error("VideoGenerator: Failed to play local video")}),this.processor_=new SF(this.player_)}},{key:"getSmallVideoProfile",value:function(n,a){var i,r=this.localStream_.getVideoTrack(),o=this.localStream_.getVideoProfile();if(Eo){var s=r.getSettings();s&&s.width&&s.height&&(o.width=s.width,o.height=s.height)}var c=o.width*o.height,u=n*a;return _e.info("big stream resolution: ".concat(o.width,"*").concat(o.height," small stream resolution: ").concat(n,"*").concat(a," ")),i=c>u?c/u:c/19200,{width:parseInt(o.width/Math.sqrt(i)),height:parseInt(o.height/Math.sqrt(i))}}}]),e}(),ed=new Map,xF=function(){var e=G(m().mark(function t(n){var a,i,r,o,s,c,u;return m().wrap(function(d){for(;;)switch(d.prev=d.next){case 0:if(!yl()){d.next=2;break}return d.abrupt("return");case 2:return d.next=4,IF(n);case 4:if(a=d.sent,_e.info("getUserMedia with constraints: "+JSON.stringify(a)),!a.audio){d.next=11;break}return d.next=9,Tt.getMicrophones();case 9:i=d.sent,_e.info("microphones: ".concat(yo(i,["deviceId","label"])));case 11:if(!a.video){d.next=16;break}return d.next=14,Tt.getCameras();case 14:r=d.sent,_e.info("cameras: ".concat(yo(r,["deviceId","label"])));case 16:return d.prev=16,d.next=19,navigator.mediaDevices.getUserMedia(a);case 19:return d.abrupt("return",d.sent);case 22:if(d.prev=22,d.t0=d.catch(16),d.t0.name!=="NotFoundError"){d.next=29;break}if(!r||r.length!==0){d.next=27;break}throw new re({code:ee.DEVICE_NOT_FOUND,message:ie({key:$3})});case 27:if(!i||i.length!==0){d.next=29;break}throw new re({code:ee.DEVICE_NOT_FOUND,message:ie({key:Y3})});case 29:throw a.audio&&((o=i)===null||o===void 0?void 0:o.length)>0&&(c=i.find(function(g){return g.deviceId===n.microphoneId}))&&c.getCapabilities&&_e.warn(yo(c.getCapabilities(),Zp)),a.video&&((s=r)===null||s===void 0?void 0:s.length)>0&&(u=r.find(function(g){return g.deviceId===n.cameraId}))&&u.getCapabilities&&_e.warn(yo(u.getCapabilities(),Zp)),new re({code:ee.INITIALIZE_FAILED,name:d.t0.name,message:d.t0.message,constraint:d.t0.constraint});case 32:case"end":return d.stop()}},t,null,[[16,22]])}));return function(t){return e.apply(this,arguments)}}(),Hv=dc({retryFunction:xF,settings:{retries:3,timeout:500},onError:function(e,t,n,a,i){_e.warn("getUserMedia error: ".concat(e)),e.name==="NotReadableError"?(a[0].video&&(a[0].maxResoution=!1,a[0].frameRate=a[0].frameRate>10?10:5),i===2&&(a[0].useTrueAsConstraint=!0),t()):e.message.includes("deviceId")&&a[0].retryWhenExactFailed?(a[0].useExact=!1,t()):n(e)},onRetrying:function(e){_e.warn("getUserMedia retrying [".concat(e,"/3]"))},onRetrySuccess:function(e){Ie.uploadEvent({log:"stat-getUserMedia-retry-success-"+e})}});function IF(e){return{audio:wF(e),video:EF(e)}}function wF(e){if(!e.audio)return!1;if(e.useTrueAsConstraint)return!0;var t={};return Ai(e.microphoneId)||(t.deviceId=e.useExact?{exact:e.microphoneId}:e.microphoneId),Zn(e.channelCount)&&e.channelCount>1&&(t.channelCount=e.channelCount),er(e.echoCancellation)&&!e.echoCancellation&&(t.echoCancellation=!1),er(e.noiseSuppression)&&!e.noiseSuppression&&(t.noiseSuppression=!1),er(e.autoGainControl)&&!e.autoGainControl&&(t.autoGainControl=!1),!!Ai(t)||t}function EF(e){if(!e.video)return!1;if(e.useTrueAsConstraint)return!0;var t=e.maxResoution,n=t===void 0||t,a={};return e.cameraId?a.deviceId=e.useExact?{exact:e.cameraId}:e.cameraId:e.facingMode&&(a.facingMode=e.facingMode),e.width&&(a.width={ideal:e.width},n&&(a.width.max=e.width)),e.height&&(a.height={ideal:e.height},n&&(a.height.max=e.height)),Tr&&sc&&e.width&&e.height&&e.width*e.height<101376&&(a.width=e.width,a.height=e.height),e.frameRate&&(a.frameRate=e.frameRate),!!Ai(a)||a}var CF=function(){var e=G(m().mark(function t(n){var a,i,r,o,s,c,u,d,g;return m().wrap(function(I){for(;;)switch(I.prev=I.next){case 0:if(!yl()){I.next=2;break}return I.abrupt("return");case 2:if(a=null,!(sl&&Sf<74||da)){I.next=27;break}return i=zv(n),_e.info("getDisplayMedia with constraints: "+JSON.stringify(i)),I.next=8,navigator.mediaDevices.getDisplayMedia(i);case 8:if(r=I.sent,!n.screenAudio){I.next=14;break}return _e.warn("Your browser not support capture system audio"),I.abrupt("return",r);case 14:if(!n.audio){I.next=24;break}return o=Rx(n),_e.info("getUserMedia with constraints: "+JSON.stringify(o)),I.next=19,navigator.mediaDevices.getUserMedia(o);case 19:return a=I.sent,r.addTrack(a.getAudioTracks()[0]),I.abrupt("return",r);case 24:return I.abrupt("return",r);case 25:I.next=53;break;case 27:if(!n.screenAudio){I.next=37;break}return n.audioConstraints={echoCancellation:n.echoCancellation,autoGainControl:n.autoGainControl,noiseSuppression:n.noiseSuppression,sampleRate:44100},s=zv(n),_e.info("getDisplayMedia with constraints: "+JSON.stringify(s)),I.next=33,navigator.mediaDevices.getDisplayMedia(s);case 33:return c=I.sent,I.abrupt("return",c);case 37:return u=zv(n),_e.info("getDisplayMedia with constraints: "+JSON.stringify(u)),I.next=41,navigator.mediaDevices.getDisplayMedia(u);case 41:if(d=I.sent,!n.audio){I.next=52;break}return g=Rx(n),_e.info("getUserMedia with constraints: "+JSON.stringify(g)),I.next=47,navigator.mediaDevices.getUserMedia(g);case 47:return a=I.sent,d.addTrack(a.getAudioTracks()[0]),I.abrupt("return",d);case 52:return I.abrupt("return",d);case 53:case"end":return I.stop()}},t)}));return function(t){return e.apply(this,arguments)}}();function Rx(e){var t={echoCancellation:e.echoCancellation,autoGainControl:e.autoGainControl,noiseSuppression:e.noiseSuppression,sampleRate:e.sampleRate,channelCount:e.channelCount};return ge(e.microphoneId)||(t.deviceId=e.microphoneId),{audio:t,video:!1}}function zv(e){var t={systemAudio:"include",selfBrowserSurface:"include",surfaceSwitching:"include"},n={width:da?{max:e.width}:{ideal:e.width,max:e.width},height:da?{max:e.height}:{ideal:e.height,max:e.height},frameRate:e.frameRate,displaySurface:"monitor"};return t.video=n,ge(e.audioConstraints)||(t.audio=e.audioConstraints),t}var Ax,Px,Dx,Lx,Ox,Mx,Nx,Ux,Vx,jx,Bx,nt,Fx,Ac,Wv=new Map([["120p",{width:160,height:120,frameRate:15,bitrate:200}],["120p_2",{width:160,height:120,frameRate:15,bitrate:100}],["180p",{width:320,height:180,frameRate:15,bitrate:350}],["180p_2",{width:320,height:180,frameRate:15,bitrate:150}],["240p",{width:320,height:240,frameRate:15,bitrate:400}],["240p_2",{width:320,height:240,frameRate:15,bitrate:200}],["360p",{width:640,height:360,frameRate:15,bitrate:800}],["360p_2",{width:640,height:360,frameRate:15,bitrate:400}],["480p",{width:640,height:480,frameRate:15,bitrate:900}],["480p_2",{width:640,height:480,frameRate:15,bitrate:500}],["720p",{width:1280,height:720,frameRate:15,bitrate:1500}],["1080p",{width:1920,height:1080,frameRate:15,bitrate:2e3}],["1440p",{width:2560,height:1440,frameRate:30,bitrate:4860}],["4K",{width:3840,height:2160,frameRate:30,bitrate:9e3}]]),qv=new Map([["480p",{width:640,height:480,frameRate:5,bitrate:900}],["480p_2",{width:640,height:480,frameRate:30,bitrate:1e3}],["720p",{width:1280,height:720,frameRate:5,bitrate:1200}],["720p_2",{width:1280,height:720,frameRate:30,bitrate:3e3}],["1080p",{width:1920,height:1080,frameRate:5,bitrate:1600}],["1080p_2",{width:1920,height:1080,frameRate:30,bitrate:4e3}]]),Gx=new Map([["standard",{sampleRate:48e3,channelCount:1,bitrate:40}],["standard-stereo",{sampleRate:48e3,channelCount:2,bitrate:64}],["high",{sampleRate:48e3,channelCount:1,bitrate:128}],["high-stereo",{sampleRate:48e3,channelCount:2,bitrate:192}]]),wa=new Map,RF=(Ax=St(Ti),Px=St(Ti),Dx=St(Ti),Lx=St(Ti),Ox=Cn.apply(void 0,be(Jt.LOCAL_STREAM.switchDevice)),Mx=Cn(Jt.STREAM.addTrack),Nx=Cn(Jt.STREAM.removeTrack),Ux=Cn(Jt.STREAM.replaceTrack),Vx=Fo({retries:10,timeout:3e3,onRetryFailed:function(e){Ie.logFailedEvent({userId:this.client_?this.client_.getUserId():this.userId_,eventType:jb,error:e}),this.emitter_.emit(Im,new re({code:ee.DEVICE_AUTO_RECOVER_FAILED,message:e.message}))}}),jx=$l(Jt.LOCAL_STREAM.setAudioCaptureVolume),Bx=St(Ti),nt=function(e){Ct(A,e);var t,n,a,i,r,o,s,c,u,d,g,I,k,w=Cr(A);function A(p){var v;K(this,A);var y=q(q({},p),{isRemote:!1,type:"local"});return(v=w.call(this,y)).name_=Ti,v.client_=null,v.video_=p.video,v.audio_=p.audio,v.cameraId_=p.cameraId,v.cameraGroupId_="",v.facingMode_=p.facingMode,v.microphoneId_=p.microphoneId,v.microphoneGroupId_="",v.microphoneLabel_="",v.videoSource_=p.videoSource,v.audioSource_=p.audioSource,v.screen_=p.screen,v.screenAudio_=p.screenAudio,v.audioProfile_={echoCancellation:!0,autoGainControl:!0,noiseSuppression:!0,sampleRate:48e3,channelCount:1,bitrate:40},v.screenAudio_&&(v.audioProfile_.echoCancellation=!0,v.audioProfile_.autoGainControl=!1,v.audioProfile_.noiseSuppression=!1),er(p.echoCancellation)&&(v.audioProfile_.echoCancellation=p.echoCancellation),er(p.autoGainControl)&&(v.audioProfile_.autoGainControl=p.autoGainControl),er(p.noiseSuppression)&&(v.audioProfile_.noiseSuppression=p.noiseSuppression),v.videoProfile_=Wv.get("480p_2"),v.screenProfile_=qv.get("1080p"),v.videoSetting_=null,v.muteState_={video:!1,audio:!1,auxVideo:!1},v.beautyStatus_=!1,v.prevAudioRecoverTime_=0,v.prevVideoRecoverTime_=0,v.isAudioRecovering_=!1,v.isVideoRecovering_=!1,v.initState(),v.canvas_=null,v.canvasInterval_=null,v.canvasTrack_=null,v.gain_={audioTrack:null,source:null,gainNode:null},v.captureVolume_=100,v.enableAutoRecoverCapture_=!!ge(p.enableAutoRecoverCapture)||p.enableAutoRecoverCapture,v.enableAutoRecoverOther_=!er(p.enableAutoRecoverOther)||p.enableAutoRecoverOther,v.log_.info("stream created: ".concat(v.id_," autoRecover: ").concat(v.enableAutoRecoverCapture_)),v.isAIDenoiser=!1,v}return we(A,[{key:"initState",value:function(){this.isAddingTrack_=!1,this.isRemovingTrack_=!1,this.setIsReadyToPublish(!1),this.setPublishState(Jb)}},{key:"installEvents",value:function(){oe(Xe(A.prototype),"installEvents",this).call(this),X.on(Kf,this.onVideoTrackStopped,this),X.on(uc,this.onVideoTrackStopped,this),X.on(Qf,this.onAudioTrackStopped,this),X.on(Xf,this.onAudioTrackStopped,this)}},{key:"uninstallEvents",value:function(){oe(Xe(A.prototype),"uninstallEvents",this).call(this),X.off(Kf,this.onVideoTrackStopped,this),X.off(uc,this.onVideoTrackStopped,this),X.off(Qf,this.onAudioTrackStopped,this),X.off(Xf,this.onAudioTrackStopped,this)}},{key:"initialize",value:function(){var p=this;return new Promise(function(v,y){if(bl())y(new re({code:ee.INVALID_OPERATION,message:ie({key:gS})}));else{if(ge(p.audio_)){var L=new MediaStream;return ge(p.audioSource_)||(L.addTrack(p.audioSource_),p.updateAudioPlayingState(!0)),ge(p.videoSource_)||(L.addTrack(p.videoSource_),p.updateVideoPlayingState(!0)),p.setMediaStream(L),Ie.logSuccessEvent({userId:p.client_?p.client_.getUserId():p.userId_,eventType:rc,kind:"custom"}),p.setIsReadyToPublish(!0),v()}p.screen_?(p.log_.info("initialize stream audio: "+p.audio_+" screenAudio: "+p.screenAudio_+" screen: "+p.screen_),CF({audio:p.audio_,screenAudio:p.screenAudio_,microphoneId:p.microphoneId_,width:p.screenProfile_.width,height:p.screenProfile_.height,frameRate:p.screenProfile_.frameRate,sampleRate:p.audioProfile_.sampleRate,channelCount:p.audioProfile_.channelCount,autoGainControl:p.audioProfile_.autoGainControl,noiseSuppression:p.audioProfile_.noiseSuppression,echoCancellation:p.audioProfile_.echoCancellation}).then(function(f){p.setMediaStream(f),p.updateAudioPlayingState(p.audio_||p.screenAudio_),p.updateVideoPlayingState(!0);var b=p.getVideoTrack();return b.applyConstraints&&b.applyConstraints({frameRate:{min:p.screenProfile_.frameRate,ideal:p.screenProfile_.frameRate},width:p.screenProfile_.width,height:p.screenProfile_.height}).catch(function(P){p.warn("screen applyConstraints failed: ".concat(P))}),p.listenForScreenSharingStopped(b),p.setVideoContentHint(_b),p.updateDeviceIdInUse(),p.setIsReadyToPublish(!0),p.log_.info(JSON.stringify(b.getSettings())),Ie.logSuccessEvent({userId:p.client_?p.client_.getUserId():p.userId_,eventType:rc,kind:"getDisplayMedia"}),v()}).catch(function(f){Ie.logFailedEvent({userId:p.client_?p.client_.getUserId():p.userId_,eventType:rc,kind:"getDisplayMedia",error:f}),p.log_.error("getDisplayMedia error observed "+f),y(f instanceof re?f:new re({code:ee.INITIALIZE_FAILED,name:f.name,message:f.message}))})):(X.emit(Ff,{stream:p,audio:p.audio_,video:p.video_}),p.log_.info("initialize stream audio: "+p.audio_+" video: "+p.video_),Hv({audio:p.audio_,video:p.video_,facingMode:p.facingMode_,cameraId:p.cameraId_,microphoneId:p.microphoneId_,width:p.videoProfile_.width,height:p.videoProfile_.height,frameRate:p.videoProfile_.frameRate,sampleRate:p.audioProfile_.sampleRate,channelCount:p.audioProfile_.channelCount,autoGainControl:p.audioProfile_.autoGainControl,noiseSuppression:p.audioProfile_.noiseSuppression,echoCancellation:p.audioProfile_.echoCancellation,useExact:!0,retryWhenExactFailed:!0}).then(function(f){return X.emit(Gf,{stream:p,audio:p.audio_,video:p.video_}),p.setMediaStream(f),f.getTracks().forEach(function(b){if(Eo){var P=b.getSettings();p.log_.debug("".concat(b.kind," settings: ").concat(JSON.stringify(P))),b.kind===xe&&(p.videoSetting_=P)}ZV&&p.log_.info("".concat(b.kind," capabilities: ").concat(yo(b.getCapabilities(),Zp)))}),p.updateAudioPlayingState(p.audio_),p.updateVideoPlayingState(p.video_),p.updateDeviceIdInUse(),p.log_.info("gotStream hasAudio: "+p.hasAudio()+" hasVideo: "+p.hasVideo()),p.setIsReadyToPublish(!0),Ie.logSuccessEvent({userId:p.client_?p.client_.getUserId():p.userId_,eventType:rc,kind:"getUserMedia"}),v()}).catch(function(f){X.emit(Hf,{stream:p,audio:p.audio_,video:p.video_,error:f}),Ie.logFailedEvent({userId:p.client_?p.client_.getUserId():p.userId_,eventType:rc,kind:"getUserMedia",error:f}),p.log_.error("getUserMedia error observed "+f),y(f)}))}})}},{key:"listenForScreenSharingStopped",value:function(p){var v=this;p.addEventListener("ended",function(y){v.log_.info("screen sharing was stopped because the video track is ended"),v.emitter_.emit(t6)})}},{key:"muteAudio",value:function(){var p=oe(Xe(A.prototype),"muteAudio",this).call(this);return p&&(this.log_.info("localStream mute audio"),this.sendMutedFlag(Ae,!0)),p}},{key:"muteVideo",value:function(){var p=oe(Xe(A.prototype),"muteVideo",this).call(this);return p&&(this.log_.info("localStream mute video"),this.sendMutedFlag(xe,!0)),p}},{key:"unmuteAudio",value:function(){var p=oe(Xe(A.prototype),"unmuteAudio",this).call(this);return p&&(this.log_.info("localStream unmute audio"),this.sendMutedFlag(Ae,!1)),p}},{key:"unmuteVideo",value:function(){var p=oe(Xe(A.prototype),"unmuteVideo",this).call(this);return p&&(this.log_.info("localStream unmute video"),this.sendMutedFlag(xe,!1)),p}},{key:"sendMutedFlag",value:function(p,v){this.setMuteState(p,v);var y=this.getConnection();if(y){y.sendMutedFlag(this.muteState_,this);var L=y.getUserId(),f=y.getTinyId(),b="".concat(v?Zt:_r," local ").concat(p," track");yn(L,{eventId:p===Ae?v?XU:YU:v?QU:$U,eventDesc:b,timestamp:an(),userId:L,tinyId:f})}}},{key:"setMuteState",value:function(p,v){this.muteState_[p]=v,this.log_.info("set ".concat(p," muted state: [").concat(v?"mute":"unmute","]"))}},{key:"setAudioProfile",value:(k=G(m().mark(function p(v){var y,L,f;return m().wrap(function(b){for(;;)switch(b.prev=b.next){case 0:if(H(v)==="object"?y=v:(y=Gx.get(v))===void 0&&(y=Gx.get("standard")),this.log_.info("setAudioProfile: "+JSON.stringify(y)),!(L=this.getAudioTrack())){b.next=6;break}return b.next=6,L.applyConstraints(y);case 6:if(f=this.audioProfile_.bitrate!==y.bitrate,this.audioProfile_=q(q({},this.audioProfile_),y),!f||!this.connection_){b.next=12;break}return b.next=11,this.connection_.setBandwidth({bandwidth:this.audioProfile_.bitrate,type:Ae});case 11:this.connection_.sendMediaSettings(this);case 12:case"end":return b.stop()}},p,this)})),function(p){return k.apply(this,arguments)})},{key:"setVideoProfile",value:(I=G(m().mark(function p(v){var y,L,f,b;return m().wrap(function(P){for(;;)switch(P.prev=P.next){case 0:if(!this.connection_||Fk()){P.next=2;break}throw new re({code:ee.NOT_SUPPORTED,message:ie({key:J3})});case 2:if(Ei(v)?L=q(q({},this.videoProfile_),v):Vt(v)&&(L=Wv.get(v),ge(L)&&(L=Wv.get("480p_2"))),(y=this.client_)!==null&&y!==void 0&&y.get2k4kFlag()&&(this.client_.get2k4kFlag()!==1&&!this.screen_&&L.height*L.width>=3686400?(L.width=1920,L.height=1080,this.log_.warn(aS)):Ui.handleFunctionState({fnName:"2K_4K"})),L&&L.width*L.height>921600&&M4&&(L.width=1280,L.height=720,this.log_.warn("reset to 1280 * 720 on iOS 13~14")),this.log_.info("setVideoProfile "+JSON.stringify(L)),!(f=this.getVideoTrack())){P.next=10;break}return P.next=10,f.applyConstraints(L);case 10:if(b=this.videoProfile_.bitrate!==L.bitrate,this.videoProfile_=L,!b||!this.connection_){P.next=16;break}return P.next=15,this.connection_.setBandwidth({bandwidth:L.bitrate,type:xe,videoType:zu});case 15:this.connection_.sendMediaSettings(this);case 16:case"end":return P.stop()}},p,this)})),function(p){return I.apply(this,arguments)})},{key:"getVideoBitrate",value:function(){return this.screen_?this.screenProfile_.bitrate:this.videoProfile_.bitrate}},{key:"getAudioBitrate",value:function(){return this.audioProfile_.bitrate}},{key:"setScreenProfile",value:function(p){var v=p;Vt(p)&&(v=qv.get(p)||qv.get("1080p")),this.log_.info("setScreenProfile "+JSON.stringify(p)),this.screenProfile_=v}},{key:"getVideoProfile",value:function(){return this.screen_?this.screenProfile_:this.videoProfile_}},{key:"getAudioProfile",value:function(){return this.audioProfile_}},{key:"setVideoContentHint",value:function(p){var v=this.getVideoTrack();v&&"contentHint"in v&&(this.log_.info("set video track contentHint to: "+p),v.contentHint=p,v.contentHint!==p&&this.log_.warn("Invalid video track contentHint: "+p))}},{key:"switchDevice",value:(g=G(m().mark(function p(v,y){var L,f,b,P,S,T,C,D,B,x,h,E,O,N,j,J,$,he;return m().wrap(function(ue){for(;;)switch(ue.prev=ue.next){case 0:if(this.mediaStream_&&this.cameraId_!==y&&this.facingMode_!==y){ue.next=2;break}return ue.abrupt("return");case 2:if(f=v===xe,!(L=v===Ae)||y!==this.microphoneId_){ue.next=11;break}if(y===$u){ue.next=7;break}return ue.abrupt("return");case 7:return ue.next=9,u6(this.microphoneGroupId_,this.microphoneLabel_);case 9:if(!ue.sent){ue.next=11;break}return ue.abrupt("return");case 11:return this.setIsReadyToPublish(!1),this.log_.info("switchDevice "+v+" to: "+y),L&&(b=this.getAudioTrack(),P=this.getMicrophoneTrackMixed(),b&&b.stop(),P&&P.stop()),f&&((S=this.getVideoTrack())&&S.stop(),yf&&(T=this.getAudioTrack())&&(this.log_.info("stop audio track first in huawei env"),T.stop())),ue.prev=15,ue.next=18,Hv({audio:L||yf,video:f,facingMode:y===vb||y===gb?y:void 0,cameraId:f?y:this.cameraId_,microphoneId:L?y:this.microphoneId_,width:this.videoProfile_.width,height:this.videoProfile_.height,frameRate:this.videoProfile_.frameRate,sampleRate:this.audioProfile_.sampleRate,channelCount:this.audioProfile_.channelCount,useExact:!0,retryWhenExactFailed:!1});case 18:if(C=ue.sent,D=null,!L){ue.next=25;break}(B=C.getAudioTracks()[0])&&this.isAudioTrackMixed()?(x=this.getAudioTrack(),h=Tt.AudioMixerPlugin.getAudioTrackMap(),E=Tt.AudioMixerPlugin.mix({targetTrack:B,sourceList:h.get(x.id).sourceList,trackList:h.get(x.id).trackList}),D=E):D=B,ue.next=34;break;case 25:if(!(D=C.getVideoTracks()[0])||!this.isVideoTrackBeautified()){ue.next=30;break}return ue.next=29,this.generateBeautyTrack(D);case 29:D=ue.sent;case 30:if(!(O=C.getAudioTracks()[0])||!yf){ue.next=34;break}return ue.next=34,this.replaceTrack(O);case 34:return ue.next=36,this.replaceTrack(D);case 36:this.updateDeviceIdInUse(),(N=this.getConnection())&&(j=N.getUserId(),J=N.getTinyId(),$=eV,he="switch camera",L&&($=tV,he="switch microphone"),yn(j,{eventId:$,eventDesc:he,timestamp:an(),userId:j,tinyId:J})),this.log_.info("switch ".concat(L?"microphone":"camera"," success ")),L&&(this.audio_=!0),f&&(this.video_=!0,y!==gb&&y!==vb||(this.facingMode_=y)),this.setIsReadyToPublish(!0),ue.next=50;break;case 45:throw ue.prev=45,ue.t0=ue.catch(15),this.log_.error(ue.t0),L?this.recoverCapture({audio:!0,video:!1,microphoneId:this.microphoneId_}):this.recoverCapture({audio:!1,video:!0,cameraId:this.cameraId_,facingMode:this.facingMode_}),ue.t0;case 50:case"end":return ue.stop()}},p,this,[[15,45]])})),function(p,v){return g.apply(this,arguments)})},{key:"addTrack",value:(d=G(m().mark(function p(v){var y,L,f;return m().wrap(function(b){for(;;)switch(b.prev=b.next){case 0:if(b.prev=0,v.kind===xe&&Eo&&(y=v.getSettings(),!this.videoSetting_||y.width===this.videoSetting_.width&&y.height===this.videoSetting_.height||this.log_.warn("video resolution of the track (".concat(y.width," x ").concat(y.height,") shall be kept the same as the previous: ").concat(this.videoSetting_.width," x ").concat(this.videoSetting_.height,". It may cause abnormal Cloud Recording."))),this.isAddingTrack_=!0,this.keepMuteState(v),this.mediaStream_.addTrack(v),!(L=this.getConnection())){b.next=11;break}return f=null,v.kind===xe&&(ul||cl)&&jS(v)&&(f=this.getCanvasTrack()),b.next=11,L.addTrack(f||v,this);case 11:v.kind===Ae?(this.audio_=!0,this.updateAudioPlayingState(!0),this.captureVolume_!==100&&this.setAudioCaptureVolume(this.captureVolume_)):(this.video_=!0,this.updateVideoPlayingState(!0)),this.isAddingTrack_=!1,b.next=20;break;case 15:throw b.prev=15,b.t0=b.catch(0),this.mediaStream_.removeTrack(v),this.isAddingTrack_=!1,b.t0;case 20:case"end":return b.stop()}},p,this,[[0,15]])})),function(p){return d.apply(this,arguments)})},{key:"removeTrack",value:(u=G(m().mark(function p(v){var y;return m().wrap(function(L){for(;;)switch(L.prev=L.next){case 0:if(L.prev=0,this.isRemovingTrack_=!0,!(y=this.getConnection())){L.next=17;break}if(v.kind!==xe||!ul&&!cl||!this.canvasTrack_){L.next=10;break}return L.next=7,y.removeTrack(this.canvasTrack_,this);case 7:this.clearCanvas(),L.next=17;break;case 10:if(v.kind!==Ae||!this.gain_.audioTrack){L.next=15;break}return L.next=13,y.removeTrack(this.gain_.audioTrack,this);case 13:L.next=17;break;case 15:return L.next=17,y.removeTrack(v,this);case 17:this.mediaStream_.removeTrack(v),v.kind===Ae?(this.audio_=!1,this.updateAudioPlayingState(!1),this.stopGainNode()):(this.video_=!1,this.updateVideoPlayingState(!1)),this.isRemovingTrack_=!1,L.next=26;break;case 22:throw L.prev=22,L.t0=L.catch(0),this.isRemovingTrack_=!1,L.t0;case 26:case"end":return L.stop()}},p,this,[[0,22]])})),function(p){return u.apply(this,arguments)})},{key:"replaceTrack",value:(c=G(m().mark(function p(v){var y,L,f;return m().wrap(function(b){for(;;)switch(b.prev=b.next){case 0:if(v.kind===xe&&Eo&&(y=v.getSettings(),!this.videoSetting_||y.width===this.videoSetting_.width&&y.height===this.videoSetting_.height||this.log_.warn("video resolution of the track (".concat(y.width," x ").concat(y.height,") shall be kept the same as the previous: ").concat(this.videoSetting_.width," x ").concat(this.videoSetting_.height,". It may cause abnormal Cloud Recording."))),this.keepMuteState(v),L=this.mediaStream_,v.kind!==Ae){b.next=12;break}if(L.removeTrack(L.getAudioTracks()[0]),L.addTrack(v),oe(Xe(A.prototype),"restartAudio",this).call(this),!this.gain_.gainNode){b.next=10;break}return this.reconnectGainNode(v),b.abrupt("return");case 10:b.next=15;break;case 12:L.removeTrack(L.getVideoTracks()[0]),L.addTrack(v),oe(Xe(A.prototype),"restartVideo",this).call(this);case 15:if(!(f=this.getConnection())){b.next=21;break}if(v.kind!==xe||!ul&&!cl||!this.canvasTrack_){b.next=19;break}return b.abrupt("return");case 19:return b.next=21,f.replaceTrack(v,this);case 21:case"end":return b.stop()}},p,this)})),function(p){return c.apply(this,arguments)})},{key:"recoverCapture",value:(s=G(m().mark(function p(v){var y,L,f,b,P,S,T,C,D,B,x,h,E,O,N,j,J;return m().wrap(function($){for(;;)switch($.prev=$.next){case 0:if(!(!this.mediaStream_||!this.enableAutoRecoverCapture_||v.audio&&!v.video&&this.isAudioRecovering_||v.video&&!v.audio&&this.isVideoRecovering_)){$.next=2;break}return $.abrupt("return");case 2:return v.audio&&(this.isAudioRecovering_=!0),v.video&&(this.isVideoRecovering_=!0),this.log_.warn("recoverCapture() trying "+JSON.stringify(v)),y=this.audio_&&v.audio,L=this.video_&&v.video,$.prev=7,$.next=10,Tt.getCameras();case 10:return f=$.sent,$.next=13,Tt.getMicrophones();case 13:if(b=$.sent,L&&f.length===0&&(L=!1,this.log_.warn("recoverCapture() video flag is true, but no camera detected, set video to false")),y&&b.length===0&&(y=!1,this.log_.warn("recoverCapture() audio flag is true, but no microphone detected, set audio to false")),y||L){$.next=21;break}return v.audio&&(this.isAudioRecovering_=!1),v.video&&(this.isVideoRecovering_=!1),this.log_.warn("recoverCapture() both audio and video are false, aborted"),$.abrupt("return");case 21:return P=v&&f.findIndex(function(he){return he.deviceId===v.cameraId})>=0,S=v&&b.findIndex(function(he){return he.deviceId===v.microphoneId})>=0,y&&((T=this.getAudioTrack())===null||T===void 0||T.stop()),L&&((C=this.getVideoTrack())===null||C===void 0||C.stop()),$.next=27,Hv({audio:y,video:L,cameraId:P?v.cameraId:void 0,microphoneId:S?v.microphoneId:void 0,facingMode:this.facingMode_,width:this.videoProfile_.width,height:this.videoProfile_.height,frameRate:this.videoProfile_.frameRate,sampleRate:this.audioProfile_.sampleRate,channelCount:this.audioProfile_.channelCount});case 27:D=$.sent,B=D.getTracks(),x=0;case 30:if(!(x<B.length)){$.next=57;break}if((h=B[x]).kind!==Ae||!this.isAudioTrackMixed()){$.next=43;break}if(E=this.getAudioTrack(),O=Tt.AudioMixerPlugin.getAudioTrackMap(),(N=O.get(E.id)).hasMicrophone){$.next=39;break}return h.stop(),$.abrupt("continue",54);case 39:return j=Tt.AudioMixerPlugin.mix({targetTrack:h,sourceList:N.sourceList,trackList:N.trackList}),$.next=42,this.replaceTrack(j);case 42:return $.abrupt("continue",54);case 43:if(h.kind!==xe||!this.isVideoTrackBeautified()){$.next=50;break}return $.next=46,this.generateBeautyTrack(h);case 46:return J=$.sent,$.next=49,this.replaceTrack(J);case 49:return $.abrupt("continue",54);case 50:return $.next=52,this.replaceTrack(h);case 52:if(h.readyState!=="ended"){$.next=54;break}throw new Error("new track is failed, muted ".concat(h.muted," readyState ").concat(h.readyState));case 54:x++,$.next=30;break;case 57:this.updateDeviceIdInUse(),Ie.logSuccessEvent({userId:this.client_?this.client_.getUserId():this.userId_,eventType:jb}),v.audio&&(this.isAudioRecovering_=!1),v.video&&(this.isVideoRecovering_=!1),this.log_.warn("recoverCapture() successfully"),this.emitter_.emit(r6,{isCamera:v.video,isMicrophone:v.audio,cameraId:this.cameraId_,microphoneId:this.microphoneId_}),$.next=71;break;case 65:throw $.prev=65,$.t0=$.catch(7),v.audio&&(this.isAudioRecovering_=!1),v.video&&(this.isVideoRecovering_=!1),this.log_.warn("recoverCapture() failed, "+$.t0),$.t0;case 71:case"end":return $.stop()}},p,this,[[7,65]])})),function(p){return s.apply(this,arguments)})},{key:"updateDeviceIdInUse",value:function(){var p=this;if(!this.mediaStream_)return this.cameraId_="",this.cameraGroupId_="",this.microphoneId_="",void(this.microphoneGroupId_="");Eo&&this.mediaStream_.getTracks().forEach(function(L){if(L.kind===Ae&&p.isAudioTrackMixed()){var f=p.getMicrophoneTrackMixed();if(f){var b=f.getSettings(),P=b.deviceId,S=b.groupId;P&&(p.microphoneId_=P,p.microphoneGroupId_=S,p.microphoneLabel_=f.label)}}else if(L.kind===xe&&p.isVideoTrackBeautified()){var T=p.getBeautyOriginTrack();if(T){var C=T.getSettings(),D=C.deviceId,B=C.groupId;D&&(p.cameraId_=D,p.cameraGroupId_=B)}}else{var x=L.getSettings(),h=x.deviceId,E=x.groupId;h&&(L.kind===Ae?(p.microphoneId_=h,p.microphoneGroupId_=E,p.microphoneLabel_=L.label):L.kind!==xe||p.screen_||(p.cameraId_=h,p.cameraGroupId_=E))}});var v=this.mediaStream_.getAudioTracks(),y=this.mediaStream_.getVideoTracks();v&&v.length===0&&(this.microphoneId_="",this.microphoneGroupId_=""),y&&y.length===0&&(this.cameraId_="",this.cameraGroupId_="")}},{key:"isAudioTrackMixed",value:function(){if(Tt.AudioMixerPlugin){var p=Tt.AudioMixerPlugin.getAudioTrackMap(),v=this.getAudioTrack();if(p&&v&&p.has(v.id))return!0}return!1}},{key:"getMicrophoneTrackMixed",value:function(){if(Tt.AudioMixerPlugin){var p=Tt.AudioMixerPlugin.getAudioTrackMap(),v=this.getAudioTrack();if(p&&v&&p.has(v.id)){var y=p.get(v.id);return y.hasMicrophone?y.microphoneTrack:null}}return null}},{key:"isVideoTrackBeautified",value:function(){if(Tt.beautyTrackMap){var p=Tt.beautyTrackMap,v=this.getVideoTrack();if(v&&p.has(v.id))return!0}return!1}},{key:"getBeautyOriginTrack",value:function(){if(Tt.beautyTrackMap){var p=Tt.beautyTrackMap,v=this.getVideoTrack();if(v&&p.has(v.id)){var y=p.get(v.id);if(y.originTrack)return y.originTrack}}return null}},{key:"generateBeautyTrack",value:(o=G(m().mark(function p(v){var y,L,f,b;return m().wrap(function(P){for(;;)switch(P.prev=P.next){case 0:if(y=null,L=this.getVideoTrack(),f=Tt.beautyTrackMap.get(L.id),b=f.param,f.type){P.next=8;break}y=f.pluginInstance.generateBeautyTrack(v),P.next=22;break;case 8:P.t0=f.type,P.next=P.t0==="beauty"?11:P.t0==="virtual"?13:P.t0==="mixed"?17:21;break;case 11:return y=f.pluginInstance.generateBeautyTrack(v),P.abrupt("break",22);case 13:return P.next=15,f.pluginInstance.generateVirtualTrack({videoTrack:v,type:b.type,img:b.img});case 15:case 19:return y=P.sent,P.abrupt("break",22);case 17:return P.next=19,f.pluginInstance.generateMixedTrack({videoTrack:v,type:b.type,img:b.img});case 21:return P.abrupt("break",22);case 22:return f.pluginInstance.deleteSource(L.id),this.log_.info("regenerate beauty track, track id = ".concat(v.id)),P.abrupt("return",y);case 25:case"end":return P.stop()}},p,this)})),function(p){return o.apply(this,arguments)})},{key:"getScreen",value:function(){return this.screen_}},{key:"hasScreenTrack",value:function(){if(this.screen_)return!0;var p=this.getVideoTrack();return!!p&&(p.contentHint===_b||p.contentHint===FM)}},{key:"getVideo",value:function(){return this.video_}},{key:"getAudio",value:function(){return this.audio_}},{key:"getCameraId",value:function(){return this.cameraId_}},{key:"getMicrophoneId",value:function(){return this.microphoneId_}},{key:"getMicrophoneGroupId",value:function(){return this.microphoneGroupId_}},{key:"getIsReadyToPublish",value:function(){return this.isReadyToPublish_}},{key:"setIsReadyToPublish",value:function(p){this.isReadyToPublish_=p}},{key:"setPublishState",value:function(p){this.publishState_=p}},{key:"setBeautyStatus",value:function(p){this.beautyStatus_=!!p}},{key:"getBeautyStatus",value:function(){return this.beautyStatus_}},{key:"syncMuteState",value:function(){var p=this.getAudioTrack(),v=this.getVideoTrack();if(p){var y=!p.enabled;this.setMuteState(Ae,y)}if(v){var L=!v.enabled;this.setMuteState(xe,L)}this.connection_&&this.connection_.sendMutedFlag(this.muteState_,this)}},{key:"keepMuteState",value:function(p){p instanceof window.MediaStreamTrack&&this.muteState_[p.kind]&&(p.enabled=!1,this.log_.warn("prev ".concat(p.kind," track is muted, keep mute state")))}},{key:"onVideoTrackStopped",value:(r=G(m().mark(function p(v){var y,L,f=this;return m().wrap(function(b){for(;;)switch(b.prev=b.next){case 0:if(y=v.stream,L=v.type,y===this&&this.video_&&this.cameraId_&&c6(this.getVideoTrack())&&!this.isVideoRecovering_&&(L!==Zt||!sc||!da)){b.next=3;break}return b.abrupt("return");case 3:if(!(Date.now()-this.prevVideoRecoverTime_<Zu)){b.next=6;break}return setTimeout(function(){return f.onVideoTrackStopped({stream:y,type:L})},Zu),b.abrupt("return");case 6:L===Zt?setTimeout(function(){var P=f.getVideoTrack();P!=null&&P.muted&&document.visibilityState==="visible"&&f.recoverVideoCapture(L)},5e3):this.recoverVideoCapture(L);case 7:case"end":return b.stop()}},p,this)})),function(p){return r.apply(this,arguments)})},{key:"onAudioTrackStopped",value:(i=G(m().mark(function p(v){var y,L,f=this;return m().wrap(function(b){for(;;)switch(b.prev=b.next){case 0:if(y=v.stream,L=v.type,!(y!==this||!this.audio_||!this.microphoneId_||this.isAudioRecovering_||L===Zt&&sc&&da)){b.next=3;break}return b.abrupt("return");case 3:if(!(Date.now()-this.prevAudioRecoverTime_<Zu)){b.next=6;break}return setTimeout(function(){return f.onAudioTrackStopped({stream:y,type:L})},Zu),b.abrupt("return");case 6:L===Zt?setTimeout(function(){var P=f.getAudioTrack();P!=null&&P.muted&&document.visibilityState==="visible"&&f.recoverAudioCapture(L)},5e3):this.recoverAudioCapture(L);case 7:case"end":return b.stop()}},p,this)})),function(p){return i.apply(this,arguments)})},{key:"recoverAudioCapture",value:(a=G(m().mark(function p(v){return m().wrap(function(y){for(;;)switch(y.prev=y.next){case 0:return this.prevAudioRecoverTime_=Date.now(),Ie.uploadEvent({log:"stat-local-audio-".concat(v),userId:this.userId_}),y.t0=this,y.next=5,this.getRecoverCaptureDeviceId(!1);case 5:y.t1=y.sent,y.t2={audio:!0,video:!1,microphoneId:y.t1},y.t0.recoverCapture.call(y.t0,y.t2);case 8:case"end":return y.stop()}},p,this)})),function(p){return a.apply(this,arguments)})},{key:"recoverVideoCapture",value:(n=G(m().mark(function p(v){return m().wrap(function(y){for(;;)switch(y.prev=y.next){case 0:return this.prevVideoRecoverTime_=Date.now(),Ie.uploadEvent({log:"stat-local-video-".concat(v),userId:this.userId_}),y.t0=this,y.next=5,this.getRecoverCaptureDeviceId(!0);case 5:y.t1=y.sent,y.t2={audio:!1,video:!0,cameraId:y.t1},y.t0.recoverCapture.call(y.t0,y.t2);case 8:case"end":return y.stop()}},p,this)})),function(p){return n.apply(this,arguments)})},{key:"getRecoverCaptureDeviceId",value:(t=G(m().mark(function p(){var v,y,L,f,b=arguments;return m().wrap(function(P){for(;;)switch(P.prev=P.next){case 0:if(v=!(b.length>0&&b[0]!==void 0)||b[0],!(y=v?this.cameraId_:this.microphoneId_)||!this.enableAutoRecoverOther_){P.next=17;break}if(wa.has(y)?wa.set(y,wa.get(y)+1):wa.set(y,1),!((L=wa.get(y))>=3)){P.next=17;break}if(!v){P.next=12;break}return P.next=9,Tt.getCameras();case 9:P.t0=P.sent.find(function(S){return!wa.has(S.deviceId)}),P.next=15;break;case 12:return P.next=14,Tt.getMicrophones();case 14:P.t0=P.sent.find(function(S){return!wa.has(S.deviceId)});case 15:(f=P.t0)&&(this.log_.warn("".concat(v?"camera":"mic"," ").concat(y," capture fail ").concat(L," times, change new ").concat(f.deviceId)),y=f.deviceId);case 17:return P.abrupt("return",y);case 18:case"end":return P.stop()}},p,this)})),function(){return t.apply(this,arguments)})},{key:"setAudioVolume",value:function(p){oe(Xe(A.prototype),"setAudioVolume",this).call(this,p)}},{key:"clearCanvas",value:function(){this.canvasInterval_&&(_t.clearTask(this.canvasInterval_),this.canvasInterval_=null,this.canvas_=null,this.canvasTrack_=null)}},{key:"getCanvasTrack",value:function(){var p=this;if(this.canvasTrack_)return this.canvasTrack_;this.log_.info("gen canvas track");var v=this.getVideoTrack().getSettings(),y=v.width,L=v.height,f=v.frameRate;this.canvas_=document.createElement("canvas");var b=this.canvas_.getContext("2d");this.canvas_.width=y,this.canvas_.height=L,this.canvasInterval_=_t.run(el,function(){if(p.hasVideo()){var S=p.getVideoTrack().getSettings();S.width===p.canvas_.width&&S.height===p.canvas_.height||(p.canvas_.width=S.width,p.canvas_.height=S.height)}p.videoPlayer_&&p.videoPlayer_.element_&&b.drawImage(p.videoPlayer_.element_,0,0,p.canvas_.width,p.canvas_.height)},{fps:Math.max(15,f)});var P=this.canvas_.captureStream();return this.canvasTrack_=P.getVideoTracks()[0],this.canvasTrack_}},{key:"setClient",value:function(p,v){p&&(this.log_.setUserId(p.getUserId()),this.log_.setSdkAppId(p.getSDKAppId()),v||this.syncMuteState()),this.client_=p}},{key:"setAudioCaptureVolume",value:function(){var p=this,v=arguments.length>0&&arguments[0]!==void 0?arguments[0]:100;if(!this.hasAudio()||v<0||!Sm())return!1;if(this.captureVolume_===v)return!0;this.captureVolume_=v,this.log_.info("setCaptureVolume "+v),v/=100;var y=HS();if(this.gain_.gainNode)this.gain_.gainNode.gain.value=v;else{var L,f=new MediaStream;f.addTrack(this.getAudioTrack());var b=y.createMediaStreamDestination(),P=y.createMediaStreamSource(f),S=y.createGain();S.gain.value=v,P.connect(S),S.connect(b);var T=b.stream.getAudioTracks()[0],C=function(D){return p.log_.info("gained audio track ".concat(D))};T.onmute=function(){return C("muted")},T.onunmute=function(){return C("unmuted")},T.onended=function(){return C("ended")},this.gain_={source:P,audioTrack:T,gainNode:S},(L=this.connection_)===null||L===void 0||L.replaceTrack(T),oe(Xe(A.prototype),"restartAudio",this).call(this)}return!0}},{key:"getGainedTrack",value:function(){return this.gain_.audioTrack}},{key:"reconnectGainNode",value:function(p){this.log_.warn("reconnect gain node");var v=new MediaStream;v.addTrack(p);var y=HS().createMediaStreamSource(v);y.connect(this.gain_.gainNode),this.gain_.source.disconnect(),this.gain_.source=y}},{key:"stopGainNode",value:function(){var p=this.gain_,v=p.audioTrack,y=p.source,L=p.gainNode;L&&(y.disconnect(),L.disconnect(),v.onmute=null,v.onunmute=null,v.onended=null,v.stop(),this.gain_={source:null,gainNode:null,audioTrack:null}),this.captureVolume_=100}},{key:"close",value:function(){this.setIsReadyToPublish(!1),this.stopGainNode(),oe(Xe(A.prototype),"close",this).call(this)}},{key:"setIsAIDenoiser",value:function(p){this.isAIDenoiser=p}}]),A}(Cx),Y(nt.prototype,"setAudioProfile",[Ax],Object.getOwnPropertyDescriptor(nt.prototype,"setAudioProfile"),nt.prototype),Y(nt.prototype,"setVideoProfile",[Px],Object.getOwnPropertyDescriptor(nt.prototype,"setVideoProfile"),nt.prototype),Y(nt.prototype,"setScreenProfile",[Dx],Object.getOwnPropertyDescriptor(nt.prototype,"setScreenProfile"),nt.prototype),Y(nt.prototype,"setVideoContentHint",[Lx],Object.getOwnPropertyDescriptor(nt.prototype,"setVideoContentHint"),nt.prototype),Y(nt.prototype,"switchDevice",[Ox],Object.getOwnPropertyDescriptor(nt.prototype,"switchDevice"),nt.prototype),Y(nt.prototype,"addTrack",[Mx],Object.getOwnPropertyDescriptor(nt.prototype,"addTrack"),nt.prototype),Y(nt.prototype,"removeTrack",[Nx],Object.getOwnPropertyDescriptor(nt.prototype,"removeTrack"),nt.prototype),Y(nt.prototype,"replaceTrack",[Ux],Object.getOwnPropertyDescriptor(nt.prototype,"replaceTrack"),nt.prototype),Y(nt.prototype,"recoverCapture",[Vx],Object.getOwnPropertyDescriptor(nt.prototype,"recoverCapture"),nt.prototype),Y(nt.prototype,"setAudioCaptureVolume",[jx,Bx],Object.getOwnPropertyDescriptor(nt.prototype,"setAudioCaptureVolume"),nt.prototype),nt),Hx={voiceActivityDetection:!1},AF=(Fx=Fo({retries:1,timeout:0,onRetrying:function(e){this.log_.warn("connection timeout, retrying [".concat(e,"]"))},onError:function(e,t,n){e.message.includes("timeout")?(this.reset(),this.initialize(),t()):n(e)}}),Ac=function(e){Ct(P,e);var t,n,a,i,r,o,s,c,u,d,g,I,k,w,A,p,v,y,L,f,b=Cr(P);function P(S){var T;return K(this,P),(T=b.call(this,S)).localStream_=null,T.exchangeSDPTimeout_=-1,T.localAuxStream_=null,T.publishingStream_=null,T.isPublishingAuxStream_=!1,T.smallGenerator_=null,T.isSDPExchanging_=!1,T.ssrc_={audio:0,video:0,small:0,auxiliary:0},T.mediaSettings_={videoCodec:"",videoWidth:0,videoHeight:0,videoBps:0,videoFps:0,audioCodec:"opus",audioFs:0,audioChannel:0,audioBps:0,smallVideoWidth:0,smallVideoHeight:0,smallVideoFps:0,smallVideoBps:0,auxVideoWidth:0,auxVideoHeight:0,auxVideoFps:0,auxVideoBps:0},T.mixedAudioTrack_=null,T}return we(P,[{key:"isMainStreamPublished",get:function(){return!!this.localStream_}},{key:"isAuxStreamPublished",get:function(){return!!this.localAuxStream_}},{key:"publishState",get:function(){var S=this,T={audio:!1,bigVideo:!1,smallVideo:!1,auxVideo:!1};if(this.peerConnection_){var C,D,B,x,h=this.peerConnection_.getSenders();h&&(Pi()?(T.audio=!((C=h[0])===null||C===void 0||!C.track),T.bigVideo=!((D=h[1])===null||D===void 0||!D.track),T.smallVideo=!((B=h[2])===null||B===void 0||!B.track),T.auxVideo=!((x=h[3])===null||x===void 0||!x.track)):h.forEach(function(E){E.track&&(E.track.kind===Ae?T.audio=!0:(T.bigVideo=!0,S.smallGenerator_&&(T.smallVideo=!0)))}))}return T}},{key:"initialize",value:function(){oe(Xe(P.prototype),"initialize",this).call(this),this.installEvents()}},{key:"reset",value:function(){this.isReconnecting_&&this.stopReconnection(),this.closePeerConnection(),this.uninstallEvents(),this.clearExchangeSDPTimeout(),this.localStream_&&this.localStream_.clearCanvas()}},{key:"close",value:function(){oe(Xe(P.prototype),"close",this).call(this),this.reset(),this.emitConnectionStateChangedEvent(on),this.smallGenerator_&&(this.smallGenerator_.destroy(),this.smallGenerator_=null)}},{key:"installEvents",value:function(){this.emitter_.on(Ze.ERROR,this.handleError,this),this.emitter_.on(Ze.CONNECTION_STATE_CHANGED,this.handleConnectionStateChange,this)}},{key:"uninstallEvents",value:function(){this.emitter_.off(Ze.ERROR,this.handleError,this),this.emitter_.off(Ze.CONNECTION_STATE_CHANGED,this.handleConnectionStateChange,this)}},{key:"publish",value:(f=G(m().mark(function S(T,C){var D,B,x,h;return m().wrap(function(E){for(;;)switch(E.prev=E.next){case 0:if(this.publishingStream_=T,this.isPublishingAuxStream_=C,B=T.getVideoTrack(),x=null,!B||C||!this.client_.getIsEnableSmallStream()){E.next=9;break}return this.smallGenerator_=new Zl(T),E.next=8,this.smallGenerator_.initialize();case 8:x=this.smallGenerator_.generateSmallVideoTrack(this.client_.smallStreamConfig_);case 9:if(h=T.getVideoProfile(),!this.client_.get2k4kFlag()){E.next=18;break}if(this.client_.get2k4kFlag()===1||T.getScreen()||!(h.height*h.width>=3686400)){E.next=18;break}return h.width=1920,h.height=1080,this.log_.warn(aS),E.next=18,T.setVideoProfile(h);case 18:if(!(la&&go()===115&&h.width*h.height<=230400)){E.next=22;break}return this.log_.warn("fallback video to 480p"),E.next=22,T.setVideoProfile("480p_2");case 22:if(this.updateMediaSettings(T,C),!bm()){E.next=33;break}if(!Ii||O4!==11){E.next=29;break}return E.next=27,this.publishByAddTrack(T,x);case 27:E.next=31;break;case 29:return E.next=31,this.publishByTransceiver(T,x,C);case 31:E.next=35;break;case 33:return E.next=35,this.publishByAddTrack(T,x);case 35:return this.publishingStream_=null,this.isPublishingAuxStream_=!1,C?this.localAuxStream_=T:this.localStream_=T,(D=this.sei_)===null||D===void 0||D.handleEncodedStreams(),E.abrupt("return",T);case 40:case"end":return E.stop()}},S,this)})),function(S,T){return f.apply(this,arguments)})},{key:"publishByTransceiver",value:(L=G(m().mark(function S(T,C,D){var B,x,h,E,O,N,j;return m().wrap(function(J){for(;;)switch(J.prev=J.next){case 0:if(this.log_.info("publish by transceiver"),B=T.getMediaStream(),x=T.getAudioTrack(),h=T.getVideoTrack(),E=null,(ul||cl)&&jS(h)&&(E=T.getCanvasTrack()),(O=this.peerConnection_.getTransceivers()).length!==0){J.next=16;break}return this.peerConnection_.addTransceiver(x||Ae,{direction:ki,streams:[B]}),this.peerConnection_.addTransceiver(D?xe:E||h||xe,{direction:ki,streams:[B]}),this.peerConnection_.addTransceiver(C||xe,{direction:ki,streams:[B]}),this.peerConnection_.addTransceiver(D?E||h:xe,{direction:ki,streams:[B]}),J.next=14,this.connect();case 14:J.next=46;break;case 16:if(N=[],!x){J.next=29;break}if(!O[0].sender.track){J.next=24;break}return this.mixAudioTrack(O[0].sender.track,x),J.next=22,O[0].sender.replaceTrack(this.mixedAudioTrack_);case 22:J.next=27;break;case 24:return J.next=26,O[0].sender.replaceTrack(x);case 26:N.push(0);case 27:return J.next=29,this.setBandwidth({bandwidth:T.getAudioBitrate(),type:Ae});case 29:if(!h){J.next=42;break}return j=D?3:1,J.next=33,O[j].sender.replaceTrack(E||h);case 33:return J.next=35,this.setBandwidth({bandwidth:T.getVideoBitrate(),type:xe,videoType:D?pt:zu});case 35:if(N.push(j),!C){J.next=42;break}return J.next=39,O[2].sender.replaceTrack(C);case 39:return J.next=41,this.setBandwidth({bandwidth:this.client_.smallStreamConfig.bitrate,type:xe,videoType:Gr});case 41:N.push(2);case 42:return J.next=44,this.setTransceiverDirection(ki,N);case 44:return J.next=46,this.doPublishChange();case 46:case"end":return J.stop()}},S,this)})),function(S,T,C){return L.apply(this,arguments)})},{key:"publishByAddTrack",value:(y=G(m().mark(function S(T,C){var D,B,x,h;return m().wrap(function(E){for(;;)switch(E.prev=E.next){case 0:return this.log_.info("publish by addtrack"),D=T.getMediaStream(),B=T.getAudioTrack(),x=T.getVideoTrack(),B&&this.peerConnection_.addTrack(B,D),x&&(this.peerConnection_.addTrack(x,D),C&&((h=new MediaStream).addTrack(C),this.peerConnection_.addTrack(C,h))),E.next=8,this.connect();case 8:case"end":return E.stop()}},S,this)})),function(S,T){return y.apply(this,arguments)})},{key:"unpublish",value:(v=G(m().mark(function S(T){var C,D,B,x;return m().wrap(function(h){for(;;)switch(h.prev=h.next){case 0:if(Pi()){h.next=2;break}return h.abrupt("return",this.doUnpublish());case 2:if(C=T.getAudioTrack(),D=T===this.localAuxStream_,B=[],!this.peerConnection_){h.next=33;break}if(x=this.peerConnection_.getSenders(),!C){h.next=18;break}if(!this.mixedAudioTrack_){h.next=15;break}return this.log_.info("has mixed audioTrack, use another audioTrack"),h.next=12,x[0].replaceTrack(D?this.localStream_.getAudioTrack():this.localAuxStream_.getAudioTrack());case 12:this.destroyMixedAudioTrack(),h.next=18;break;case 15:return h.next=17,x[0].replaceTrack(null);case 17:B.push(0);case 18:if(!D){h.next=26;break}return h.next=21,x[3].replaceTrack(null);case 21:this.localAuxStream_=null,this.mediaSettings_=q(q({},this.mediaSettings_),{},{auxVideoBps:0,auxVideoFps:0,auxVideoWidth:0,auxVideoHeight:0}),B.push(3),h.next=33;break;case 26:return h.next=28,x[1].replaceTrack(null);case 28:return h.next=30,x[2].replaceTrack(null);case 30:this.localStream_=null,this.mediaSettings_=q(q({},this.mediaSettings_),{},{videoWidth:0,videoHeight:0,videoBps:0,videoFps:0,audioFs:0,audioChannel:0,audioBps:0,smallVideoWidth:0,smallVideoHeight:0,smallVideoFps:0,smallVideoBps:0}),B.push(1,2);case 33:if(!this.localStream_&&!this.localAuxStream_){h.next=40;break}return h.next=36,this.setTransceiverDirection(po,B);case 36:return h.next=38,this.doPublishChange();case 38:h.next=42;break;case 40:return h.next=42,this.doUnpublish();case 42:case"end":return h.stop()}},S,this)})),function(S){return v.apply(this,arguments)})},{key:"doPublishChange",value:(p=G(m().mark(function S(){var T,C;return m().wrap(function(D){for(;;)switch(D.prev=D.next){case 0:return T={state:this.publishState,constraintConfig:this.mediaSettings_},D.next=3,this.signalChannel_.sendWaitForResponse({command:PU,data:T,responseCommand:ft.PUBLISH_STATE_CHANGE_RESULT});case 3:C=D.sent,this.checkPublishResultCode(C.data.code,C.data.message);case 5:case"end":return D.stop()}},S,this)})),function(){return p.apply(this,arguments)})},{key:"doUnpublish",value:function(){var S=this;return this.signalChannel_.sendWaitForResponse({command:_k,commandDesc:"unpublish",responseCommand:ft.UNPUBLISH_RESULT}).then(function(){S.close()}).catch(function(){S.close()})}},{key:"updateMediaSettings",value:function(S,T){var C=this;this.localAuxStream_&&S===this.localAuxStream_&&(T=!0);var D=this.client_.getSystemResult().detail,B=D.isH264EncodeSupported,x=D.isVp8EncodeSupported;if(B?this.mediaSettings_.videoCodec="H264":x&&(this.mediaSettings_.videoCodec="VP8"),Eo){var h=S.getMediaStream();h==null||h.getTracks().forEach(function(E){var O=E.getSettings();if(E.kind===Ae){var N=1;O.channelCount&&(N=O.channelCount),C.mediaSettings_.audioChannel=N,C.mediaSettings_.audioBps=1e3*S.getAudioBitrate(),C.mediaSettings_.audioFs=O.sampleRate}else if(E.kind===xe){if(T)return C.mediaSettings_.auxVideoWidth=O.width,C.mediaSettings_.auxVideoHeight=O.height,C.mediaSettings_.auxVideoFps=O.frameRate,void(C.mediaSettings_.auxVideoBps=1e3*S.getVideoBitrate());C.client_.getIsEnableSmallStream()&&(C.mediaSettings_.smallVideoWidth=C.client_.smallStreamConfig.width,C.mediaSettings_.smallVideoHeight=C.client_.smallStreamConfig.height,C.mediaSettings_.smallVideoFps=C.client_.smallStreamConfig.frameRate,C.mediaSettings_.smallVideoBps=1e3*C.client_.smallStreamConfig.bitrate),C.mediaSettings_.videoWidth=O.width,C.mediaSettings_.videoHeight=O.height,C.mediaSettings_.videoFps=O.frameRate,C.mediaSettings_.videoBps=1e3*S.getVideoBitrate()}})}else this.updateMediaSettingsFromProfile(S);this.log_.info("updateMediaSettings: "+JSON.stringify(this.mediaSettings_))}},{key:"updateMediaSettingsFromProfile",value:function(S){if(S){if(S.hasAudio()){var T=S.getAudioProfile();this.mediaSettings_.audioChannel=T.channelCount,this.mediaSettings_.audioBps=1e3*T.bitrate,this.mediaSettings_.audioFs=T.sampleRate}if(S.hasVideo()){var C=S.getVideoProfile();this.mediaSettings_.videoWidth=C.width,this.mediaSettings_.videoHeight=C.height,this.mediaSettings_.videoFps=C.frameRate,this.mediaSettings_.videoBps=1e3*C.bitrate}}}},{key:"sendMediaSettings",value:function(S){var T=this;this.updateMediaSettings(S),this.signalChannel_.sendWaitForResponse({command:KU,data:this.mediaSettings_,responseCommand:ft.UPDATE_CONSTRAINT_CONFIG_RES}).then(function(C){C.data.code!==0&&T.log_.warn(C.data.message)}).catch(this.log_.warn)}},{key:"addTrack",value:(A=G(m().mark(function S(T,C){var D,B;return m().wrap(function(x){for(;;)switch(x.prev=x.next){case 0:if(this.peerConnection_){x.next=2;break}return x.abrupt("return");case 2:if(B=C===this.localAuxStream_,this.log_.info("is adding ".concat(T.kind," track to current published local ").concat(B?pt:Qe," stream")),(D=this.sei_)===null||D===void 0||D.handleEncodedStreams(),!Pi()){x.next=10;break}return x.next=8,this.addTrackByTransceiver(T,C);case 8:x.next=12;break;case 10:return x.next=12,this.addTrackBySender(T);case 12:yn(this.userId_,{eventId:T.kind===Ae?bk:yk,eventDesc:"add ".concat(T.kind," track to current published stream"),timestamp:an(),userId:this.userId_,tinyId:this.tinyId_});case 13:case"end":return x.stop()}},S,this)})),function(S,T){return A.apply(this,arguments)})},{key:"addTrackByTransceiver",value:(w=G(m().mark(function S(T,C){var D,B,x,h;return m().wrap(function(E){for(;;)switch(E.prev=E.next){case 0:if(D=C===this.localAuxStream_,B=this.peerConnection_.getTransceivers(),T.kind!==Ae){E.next=13;break}if(!B[0].sender.track){E.next=9;break}return this.mixAudioTrack(B[0].sender.track,T),E.next=7,B[0].sender.replaceTrack(this.mixedAudioTrack_);case 7:E.next=11;break;case 9:return E.next=11,B[0].sender.replaceTrack(T);case 11:E.next=26;break;case 13:return x=D?3:1,E.next=16,B[x].sender.replaceTrack(T);case 16:if(x!==1||!this.client_.getIsEnableSmallStream()){E.next=23;break}return this.smallGenerator_=new Zl(this.localStream_),E.next=20,this.smallGenerator_.initialize();case 20:return h=this.smallGenerator_.generateSmallVideoTrack(this.client_.smallStreamConfig_),E.next=23,B[2].sender.replaceTrack(h);case 23:if(B[x].direction!==po){E.next=26;break}return E.next=26,this.setTransceiverDirection(ki,[x]);case 26:return this.updateMediaSettings(C,D),E.next=29,this.doPublishChange();case 29:case"end":return E.stop()}},S,this)})),function(S,T){return w.apply(this,arguments)})},{key:"addTrackBySender",value:(k=G(m().mark(function S(T){var C,D,B,x,h;return m().wrap(function(E){for(;;)switch(E.prev=E.next){case 0:if(!(Pi()&&this.peerConnection_.getTransceivers().findIndex(function(O){return O.direction==="stopped"})>=0)){E.next=4;break}return this.log_.warn("transceiver is stopping, negotiate sdp first"),E.next=4,this.updateOffer(cn.REMOVE,T);case 4:if(!(C=this.peerConnection_.getSenders().find(function(O){return O.track&&O.track.kind===T.kind}))){E.next=11;break}return this.log_.warn("sender already exists, remove sender first"),D=C.track,this.removeSender(C),E.next=11,this.updateOffer(cn.REMOVE,D);case 11:if(B=this.localStream_.getMediaStream(),this.peerConnection_.addTrack(T,B),T.kind!==xe||!this.client_.getIsEnableSmallStream()){E.next=21;break}return this.smallGenerator_=new Zl(this.localStream_),E.next=17,this.smallGenerator_.initialize();case 17:x=this.smallGenerator_.generateSmallVideoTrack(this.client_.smallStreamConfig_),(h=new MediaStream).addTrack(x),this.peerConnection_.addTrack(x,h);case 21:return E.next=23,this.updateOffer(cn.ADD,T);case 23:case"end":return E.stop()}},S,this)})),function(S){return k.apply(this,arguments)})},{key:"isNeedToResetOfferOrder",value:function(){if(this.sdpSemantics_===Wp||!this.peerConnection_||!this.peerConnection_.localDescription)return!1;for(var S=this.peerConnection_.localDescription.sdp,T=Kr(S),C=0;C<T.media.length;C++)if(T.media[C].mid===0&&T.media[C].type===xe)return!0;return!1}},{key:"removeSender",value:function(S){var T=null;Pi()&&(T=this.peerConnection_.getTransceivers().find(function(C){return C.sender&&C.sender.track===S.track})),this.peerConnection_.removeTrack(S),T&&ln(T.stop)&&(this.log_.info("stop transceiver"),T.stop())}},{key:"removeTrack",value:(I=G(m().mark(function S(T,C){return m().wrap(function(D){for(;;)switch(D.prev=D.next){case 0:if(this.peerConnection_){D.next=2;break}return D.abrupt("return");case 2:if(this.log_.info("is removing ".concat(T.kind," track from current published local ").concat(C===this.localAuxStream_?pt:Qe," stream")),!Pi()){D.next=8;break}return D.next=6,this.removeTrackByTransceiver(T,C);case 6:D.next=10;break;case 8:return D.next=10,this.removeTrackBySender(T);case 10:yn(this.userId_,{eventId:T.kind===Ae?kk:Sk,eventDesc:"remove ".concat(T.kind," track from current published stream"),timestamp:an(),userId:this.userId_,tinyId:this.tinyId_});case 11:case"end":return D.stop()}},S,this)})),function(S,T){return I.apply(this,arguments)})},{key:"removeTrackByTransceiver",value:(g=G(m().mark(function S(T,C){var D,B,x;return m().wrap(function(h){for(;;)switch(h.prev=h.next){case 0:if(D=C===this.localAuxStream_,B=this.peerConnection_.getTransceivers(),T.kind!==Ae){h.next=13;break}if(!this.mixedAudioTrack_){h.next=9;break}return h.next=6,B[0].sender.replaceTrack(D?this.localStream_.getAudioTrack():this.localAuxStream_.getAudioTrack());case 6:this.destroyMixedAudioTrack(),h.next=11;break;case 9:return h.next=11,B[0].sender.replaceTrack(null);case 11:h.next=23;break;case 13:return x=D?3:1,h.next=16,B[x].sender.replaceTrack(null);case 16:if(x!==1||!this.smallGenerator_){h.next=21;break}return this.smallGenerator_.destroy(),this.smallGenerator_=null,h.next=21,B[2].sender.replaceTrack(null);case 21:return h.next=23,this.setTransceiverDirection(po,[x]);case 23:return this.updateMediaSettings(C,D),h.next=26,this.doPublishChange();case 26:case"end":return h.stop()}},S,this)})),function(S,T){return g.apply(this,arguments)})},{key:"setTransceiverDirection",value:(d=G(m().mark(function S(T,C){var D,B,x,h,E,O;return m().wrap(function(N){for(;;)switch(N.prev=N.next){case 0:if(Tr){N.next=2;break}return N.abrupt("return");case 2:if(D=!1,B=!1,this.log_.info("setting transceiver ".concat(C.join(",")," direction to ").concat(T)),x=this.peerConnection_.getTransceivers(),C.forEach(function(j){x[j].direction!==T&&(x[j].direction=T,D=!0)}),!D){N.next=14;break}return this.log_.info("updating offer"),N.next=11,this.peerConnection_.createOffer();case 11:return h=N.sent,N.next=14,this.peerConnection_.setLocalDescription(h);case 14:if(E=-1,O=this.peerConnection_.remoteDescription.sdp.split(`\r
|
|
99
|
-
`).map(function(j){if(j.match(new RegExp("a=(".concat(
|
|
100
|
-
`),!
|
|
101
|
-
`):h}),
|
|
62
|
+
`,i.onclick=this.onQuestionClick.bind(this);var r=document.createElement("div");r.className=ev,r.innerText="".concat(oa()?"\u8BE6\u60C5 >":"Detail >"),r.onclick=this.onCollapseClick.bind(this);var o=t.content.firstChild,c=o.querySelector(".".concat(Rl));return c.appendChild(r),c.appendChild(i),c.appendChild(n),o}},{key:"addDiaLog",value:function(){LT()||(this.dialogNode_=this.createDiaLog(),document.body.appendChild(this.dialogNode_),this.dialogNode_.onclick=this.onConfirm.bind(this),this.dialogNode_.querySelector(".".concat(wo)).onclick=function(t){return t.stopPropagation()},this.bodyPosition_=document.body.style.position,document.body.style.position="fixed",_e.info("show autoplay dialog"),ke.uploadEvent({log:l5}))}},{key:"deleteDiaLog",value:function(){this.dialogNode_&&(document.body.removeChild(this.dialogNode_),document.body.style.position=this.bodyPosition_,this.dialogNode_=null)}},{key:"onConfirm",value:function(){_e.warn("confirm clicked, try resume stream"),Y.emit(rc),this.deleteDiaLog()}},{key:"onCollapseClick",value:function(){var t=this.dialogNode_.querySelector(".".concat(PT));t.style.visibility="".concat(this.showDetail_?"hidden":"visible"),t.style.height="".concat(this.showDetail_?0:"fit-content"),this.showDetail_=!this.showDetail_,this.isCollapseClicked_||ke.uploadEvent({log:d5}),this.isCollapseClicked_=!0}},{key:"onQuestionClick",value:function(){window.open(MT,"_blank"),this.isQuestionClicked_||ke.uploadEvent({log:h5}),this.isQuestionClicked_=!0}}]),e}(),VT=function(){function e(n){Q(this,e),this.stream_=n.stream,this.userId_=n.stream.getUserId(),this.log_=this.stream_.getLogger(),this.track_=n.track,this.div_=n.div,this.muted_=n.muted,this.objectFit_=n.objectFit,this.mirror_=n.mirror,this.emitter_=new Si,this.initializeElement(),this.state_="NONE",this.pausedRetryCount_=5}var t;return Ie(e,[{key:"isPlaying",get:function(){return this.state_===ao}},{key:"initializeElement",value:function(){var n=new MediaStream;n.addTrack(this.track_);var i=document.createElement(xe);i.srcObject=n,i.muted=!0;var r="width: 100%; height: 100%; object-fit: ".concat(this.objectFit_,";");this.mirror_&&(r+="transform: scaleX(-1);"),i.setAttribute("id","video_".concat(this.stream_.getId())),i.setAttribute("style",r),i.setAttribute("autoplay","autoplay"),i.setAttribute("playsinline","playsinline"),this.element_=i,OS===17&&this.initCanvasElement(r),this.div_&&this.div_.appendChild(this.canvas_||i),this.handleEvents()}},{key:"initCanvasElement",value:function(n){var i=this;if(this.track_&&!this.stream_.isRemote()){var r=document.createElement("canvas"),o=function(){var a,s=(a=i.track_)===null||a===void 0?void 0:a.getSettings();s&&s.width&&s.height&&(r.width=s.width,r.height=s.height)};o(),r.setAttribute("style",n);var c=r.getContext("2d");this.canvasTimerId_=mt.run("raf",function(){i.element_&&c&&(o(),c.drawImage(i.element_,0,0,r.width,r.height))},{backgroundTask:!1}),this.log_.warn("use canvas for playback"),this.canvas_=r}}},{key:"setRect",value:function(n){var i=n.width,r=n.height;this.element_&&(this.element_.style.width=i+"px",this.element_.style.height=r+"px")}},{key:"setMirror",value:function(n){this.element_&&(this.element_.style.transform=n?"scaleX(-1)":"",this.mirror_=n)}},{key:"setObjectFit",value:function(n){this.element_&&(this.element_.style.objectFit="".concat(n),this.objectFit_=n)}},{key:"play",value:(t=H(p().mark(function n(){var i;return p().wrap(function(r){for(;;)switch(r.prev=r.next){case 0:return r.prev=0,r.next=3,this.element_.play();case 3:r.next=11;break;case 5:if(r.prev=5,r.t0=r.catch(0),i=ae({key:np,data:{media:"Video",error:r.t0}}),this.log_.warn(i),!i.includes("NotAllowedError")){r.next=11;break}throw new te({code:Z.PLAY_NOT_ALLOWED,message:i});case 11:case"end":return r.stop()}},n,this,[[0,5]])})),function(){return t.apply(this,arguments)})},{key:"handleEvents",value:function(){this.handleElementEvent=this.handleElementEvent.bind(this),this.handleTrackEvent=this.handleTrackEvent.bind(this),this.element_.addEventListener(di,this.handleElementEvent),this.element_.addEventListener(Nt,this.handleElementEvent),this.element_.addEventListener(hi,this.handleElementEvent),this.element_.addEventListener(io,this.handleElementEvent),this.element_.addEventListener(Lf,this.handleElementEvent),this.track_.addEventListener(Nt,this.handleTrackEvent),this.track_.addEventListener(tn,this.handleTrackEvent),this.track_.addEventListener(Sr,this.handleTrackEvent),this.track_.readyState===Nt&&this.handleTrackEvent({type:Nt}),this.track_.muted&&this.handleTrackEvent({type:tn})}},{key:"handleElementEvent",value:function(n){var i=this;switch(n.type){case di:this.log_.info("video player is playing"),this.state_=ao,Y.emit(tc,{stream:this.stream_}),this.emitter_.emit(gn,{state:this.state_,reason:di}),this.interval_&&(mt.clearTask(this.interval_),this.interval_=null);break;case Nt:this.log_.info("video player is ended"),this.state_!==fi&&(this.state_=fi,this.emitter_.emit(gn,{state:this.state_,reason:Nt}));break;case hi:this.log_.info("video player is paused"),this.div_&&!document.getElementById(this.div_.id)&&this.log_.warn("video player has been remove, element ID: ".concat(this.div_.id)),this.state_=kr,this.emitter_.emit(gn,{state:this.state_,reason:hi}),this.pausedRetryCount_>0&&!LT()&&(this.log_.info("video player auto resume when video paused"),this.resume(),this.pausedRetryCount_--),gi&&(this.interval_=mt.run(function(){i.element_&&i.state_===kr&&i.resume()},{delay:3e3}));break;case io:if(this.element_&&this.element_.error){var r="".concat(Im(),"/").concat(aa().name,"/").concat(aa().version);this.log_.error("video player error observed. code: ".concat(this.element_.error.code," message: ").concat(this.element_.error.message," deviceInfo: ").concat(r)),ke.uploadEvent({log:"stat-".concat(this.stream_.getType(),"-video-").concat(Bb,"-").concat(this.element_.error.code,"-").concat(r),userId:this.userId_,error:this.element_.error})}break;case Lf:Y.emit(Wp,{stream:this.stream_})}}},{key:"handleTrackEvent",value:function(n){var i=n.type;switch(i){case Nt:this.log_.info("video track is ended"),Y.emit(qp,{stream:this.stream_,type:i}),this.state_!==fi&&(this.state_=fi,this.emitter_.emit(gn,{state:this.state_,reason:Nt}));break;case tn:this.log_.info("video track is unable to provide media output"),this.stream_.isRemote()||BS(),Y.emit(nc,{stream:this.stream_,type:i}),this.state_!==kr&&(this.state_=kr,this.emitter_.emit(gn,{state:this.state_,reason:tn}));break;case Sr:this.log_.info("video track is able to provide media output"),Y.emit(Gp,{stream:this.stream_}),this.state_===kr&&(this.state_=ao,this.emitter_.emit(gn,{state:this.state_,reason:Sr}))}}},{key:"unbindEvents",value:function(){this.element_&&(this.element_.removeEventListener(di,this.handleElementEvent),this.element_.removeEventListener(Nt,this.handleElementEvent),this.element_.removeEventListener(hi,this.handleElementEvent),this.element_.removeEventListener(io,this.handleElementEvent),this.element_.removeEventListener(Lf,this.handleElementEvent)),this.track_&&(this.track_.removeEventListener(Nt,this.handleTrackEvent),this.track_.removeEventListener(tn,this.handleTrackEvent),this.track_.removeEventListener(Sr,this.handleTrackEvent))}},{key:"stop",value:function(){this.unbindEvents(),this.element_&&(this.element_.remove(),this.element_.srcObject=null,this.element_=null),this.interval_&&mt.clearTask(this.interval_),this.canvasTimerId_&&mt.clearTask(this.canvasTimerId_),this.canvas_&&(this.canvas_.remove(),this.canvas_=null)}},{key:"resume",value:function(){return this.play()}},{key:"getVideoFrame",value:function(){var n=document.createElement("canvas");return n.width=this.element_.videoWidth,n.height=this.element_.videoHeight,n.getContext("2d").drawImage(this.element_,0,0),n.toDataURL("image/png")}},{key:"on",value:function(n,i){this.emitter_.on(n,i)}},{key:"getElement",value:function(){return this.element_?this.element_:null}},{key:"getTrack",value:function(){return this.track_}}]),e}(),nv=typeof ArrayBuffer!="undefined"&&typeof DataView!="undefined",p5=$n,m5=yr,v5=RangeError,jT=function(e){if(e===void 0)return 0;var t=p5(e),n=m5(t);if(t!==n)throw v5("Wrong length or index");return n},g5=Array,_5=Math.abs,Wr=Math.pow,y5=Math.floor,b5=Math.log,S5=Math.LN2,k5={pack:function(e,t,n){var i,r,o,c=g5(n),a=8*n-t-1,s=(1<<a)-1,l=s>>1,u=t===23?Wr(2,-24)-Wr(2,-77):0,f=e<0||e===0&&1/e<0?1:0,S=0;for((e=_5(e))!=e||e===1/0?(r=e!=e?1:0,i=s):(i=y5(b5(e)/S5),e*(o=Wr(2,-i))<1&&(i--,o*=2),(e+=i+l>=1?u/o:u*Wr(2,1-l))*o>=2&&(i++,o/=2),i+l>=s?(r=0,i=s):i+l>=1?(r=(e*o-1)*Wr(2,t),i+=l):(r=e*Wr(2,l-1)*Wr(2,t),i=0));t>=8;)c[S++]=255&r,r/=256,t-=8;for(i=i<<t|r,a+=t;a>0;)c[S++]=255&i,i/=256,a-=8;return c[--S]|=128*f,c},unpack:function(e,t){var n,i=e.length,r=8*i-t-1,o=(1<<r)-1,c=o>>1,a=r-7,s=i-1,l=e[s--],u=127&l;for(l>>=7;a>0;)u=256*u+e[s--],a-=8;for(n=u&(1<<-a)-1,u>>=-a,a+=t;a>0;)n=256*n+e[s--],a-=8;if(u===0)u=1-c;else{if(u===o)return n?NaN:l?-1/0:1/0;n+=Wr(2,t),u-=c}return(l?-1:1)*n*Wr(2,u-t)}},T5=Mt,BT=ai,x5=nn,FT=function(e){for(var t=T5(this),n=x5(t),i=arguments.length,r=BT(i>1?arguments[1]:void 0,n),o=i>2?arguments[2]:void 0,c=o===void 0?n:BT(o,n);c>r;)t[r++]=e;return t},Pl=re,rv=pe,iv=ye,I5=nv,HT=Yn,GT=Ln,zT=As,av=ue,Dl=oi,w5=$n,C5=yr,Ol=jT,WT=k5,E5=Ts,JT=Fa,R5=ii.f,A5=Pt.f,P5=FT,D5=hu,qT=Wi,O5=HT.PROPER,KT=HT.CONFIGURABLE,Co=Xe.get,XT=Xe.set,ov="ArrayBuffer",L5="DataView",QT="Wrong index",Wn=Pl.ArrayBuffer,or=Wn,Eo=or&&or.prototype,wr=Pl.DataView,ma=wr&&wr.prototype,YT=Object.prototype,M5=Pl.Array,Ll=Pl.RangeError,N5=rv(P5),U5=rv([].reverse),$T=WT.pack,ZT=WT.unpack,e1=function(e){return[255&e]},t1=function(e){return[255&e,e>>8&255]},n1=function(e){return[255&e,e>>8&255,e>>16&255,e>>24&255]},r1=function(e){return e[3]<<24|e[2]<<16|e[1]<<8|e[0]},V5=function(e){return $T(e,23,4)},j5=function(e){return $T(e,52,8)},Ml=function(e,t){A5(e.prototype,t,{get:function(){return Co(this)[t]}})},wi=function(e,t,n,i){var r=Ol(n),o=Co(e);if(r+t>o.byteLength)throw Ll(QT);var c=Co(o.buffer).bytes,a=r+o.byteOffset,s=D5(c,a,a+t);return i?s:U5(s)},Ci=function(e,t,n,i,r,o){var c=Ol(n),a=Co(e);if(c+t>a.byteLength)throw Ll(QT);for(var s=Co(a.buffer).bytes,l=c+a.byteOffset,u=i(+r),f=0;f<t;f++)s[l+f]=u[o?f:t-f-1]};if(I5){var i1=O5&&Wn.name!==ov;if(av(function(){Wn(1)})&&av(function(){new Wn(-1)})&&!av(function(){return new Wn,new Wn(1.5),new Wn(NaN),Wn.length!=1||i1&&!KT}))i1&&KT&>(Wn,"name",ov);else{(or=function(e){return Dl(this,Eo),new Wn(Ol(e))}).prototype=Eo;for(var sv,a1=R5(Wn),o1=0;a1.length>o1;)(sv=a1[o1++])in or||GT(or,sv,Wn[sv]);Eo.constructor=or}JT&&E5(ma)!==YT&&JT(ma,YT);var Nl=new wr(new or(2)),s1=rv(ma.setInt8);Nl.setInt8(0,2147483648),Nl.setInt8(1,2147483649),!Nl.getInt8(0)&&Nl.getInt8(1)||zT(ma,{setInt8:function(e,t){s1(this,e,t<<24>>24)},setUint8:function(e,t){s1(this,e,t<<24>>24)}},{unsafe:!0})}else Eo=(or=function(e){Dl(this,Eo);var t=Ol(e);XT(this,{bytes:N5(M5(t),0),byteLength:t}),iv||(this.byteLength=t)}).prototype,wr=function(e,t,n){Dl(this,ma),Dl(e,Eo);var i=Co(e).byteLength,r=w5(t);if(r<0||r>i)throw Ll("Wrong offset");if(r+(n=n===void 0?i-r:C5(n))>i)throw Ll("Wrong length");XT(this,{buffer:e,byteLength:n,byteOffset:r}),iv||(this.buffer=e,this.byteLength=n,this.byteOffset=r)},ma=wr.prototype,iv&&(Ml(or,"byteLength"),Ml(wr,"buffer"),Ml(wr,"byteLength"),Ml(wr,"byteOffset")),zT(ma,{getInt8:function(e){return wi(this,1,e)[0]<<24>>24},getUint8:function(e){return wi(this,1,e)[0]},getInt16:function(e){var t=wi(this,2,e,arguments.length>1?arguments[1]:void 0);return(t[1]<<8|t[0])<<16>>16},getUint16:function(e){var t=wi(this,2,e,arguments.length>1?arguments[1]:void 0);return t[1]<<8|t[0]},getInt32:function(e){return r1(wi(this,4,e,arguments.length>1?arguments[1]:void 0))},getUint32:function(e){return r1(wi(this,4,e,arguments.length>1?arguments[1]:void 0))>>>0},getFloat32:function(e){return ZT(wi(this,4,e,arguments.length>1?arguments[1]:void 0),23)},getFloat64:function(e){return ZT(wi(this,8,e,arguments.length>1?arguments[1]:void 0),52)},setInt8:function(e,t){Ci(this,1,e,e1,t)},setUint8:function(e,t){Ci(this,1,e,e1,t)},setInt16:function(e,t){Ci(this,2,e,t1,t,arguments.length>2?arguments[2]:void 0)},setUint16:function(e,t){Ci(this,2,e,t1,t,arguments.length>2?arguments[2]:void 0)},setInt32:function(e,t){Ci(this,4,e,n1,t,arguments.length>2?arguments[2]:void 0)},setUint32:function(e,t){Ci(this,4,e,n1,t,arguments.length>2?arguments[2]:void 0)},setFloat32:function(e,t){Ci(this,4,e,V5,t,arguments.length>2?arguments[2]:void 0)},setFloat64:function(e,t){Ci(this,8,e,j5,t,arguments.length>2?arguments[2]:void 0)}});qT(or,ov),qT(wr,L5);var vc={ArrayBuffer:or,DataView:wr},B5=Le,cv=pe,F5=ue,c1=Tt,u1=ai,H5=yr,G5=Ou,uv=vc.ArrayBuffer,lv=vc.DataView,l1=lv.prototype,d1=cv(uv.prototype.slice),z5=cv(l1.getUint8),W5=cv(l1.setUint8);B5({target:"ArrayBuffer",proto:!0,unsafe:!0,forced:F5(function(){return!new uv(2).slice(1,void 0).byteLength})},{slice:function(e,t){if(d1&&t===void 0)return d1(c1(this),e);for(var n=c1(this).byteLength,i=u1(e,n),r=u1(t===void 0?n:t,n),o=new(G5(this,uv))(H5(r-i)),c=new lv(this),a=new lv(o),s=0;i<r;)W5(a,s++,z5(c,i++));return o}}),Le({global:!0,constructor:!0,forced:!nv},{DataView:vc.DataView});var J5=Le,q5=Ga,K5=pe([].reverse),h1=[1,2];J5({target:"Array",proto:!0,forced:String(h1)===String(h1.reverse())},{reverse:function(){return q5(this)&&(this.length=this.length),K5(this)}});var X5=Vt,Q5=Mt,Y5=yn,$5=nn,Z5=TypeError,f1=function(e){return function(t,n,i,r){X5(n);var o=Q5(t),c=Y5(o),a=$5(o),s=e?a-1:0,l=e?-1:1;if(i<2)for(;;){if(s in c){r=c[s],s+=l;break}if(s+=l,e?s<0:a<=s)throw Z5("Reduce of empty array with no initial value")}for(;e?s>=0:a>s;s+=l)s in c&&(r=n(r,c[s],s,o));return r}},dv={left:f1(!1),right:f1(!0)},ej=dv.left,p1=pr,tj=Fs;Le({target:"Array",proto:!0,forced:!Ns("reduce")||!tj&&p1>79&&p1<83},{reduce:function(e){var t=arguments.length;return ej(this,e,t,t>1?arguments[1]:void 0)}});var nj=Ps,rj="ArrayBuffer",m1=vc.ArrayBuffer;Le({global:!0,constructor:!0,forced:re.ArrayBuffer!==m1},{ArrayBuffer:m1}),nj(rj);var ij=Le,v1=Ga,aj=yu,oj=at,g1=ai,sj=nn,cj=bn,uj=Cs,lj=tt,dj=Ha,hj=Ms("slice"),fj=lj("species"),hv=Array,pj=Math.max;ij({target:"Array",proto:!0,forced:!hj},{slice:function(e,t){var n,i,r,o=cj(this),c=sj(o),a=g1(e,c),s=g1(t===void 0?c:t,c);if(v1(o)&&(n=o.constructor,(aj(n)&&(n===hv||v1(n.prototype))||oj(n)&&(n=n[fj])===null)&&(n=void 0),n===hv||n===void 0))return dj(o,a,s);for(i=new(n===void 0?hv:n)(pj(s-a,0)),r=0;a<s;a++,r++)a in o&&uj(i,r,o[a]);return i.length=r,i}});var _1=re,mj=ue,vj=pe,gj=zt,_j=Au.trim,y1=s0,gc=_1.parseInt,b1=_1.Symbol,S1=b1&&b1.iterator,k1=/^[+-]?0x/i,yj=vj(k1.exec),T1=gc(y1+"08")!==8||gc(y1+"0x16")!==22||S1&&!mj(function(){gc(Object(S1))})?function(e,t){var n=_j(gj(e));return gc(n,t>>>0||(yj(k1,n)?16:10))}:gc;Le({global:!0,forced:parseInt!=T1},{parseInt:T1});var _n,Ro,Ul,fv={exports:{}},bj=nv,pv=ye,hn=re,x1=it,Vl=at,Ei=kt,mv=Dr,Sj=Xn,kj=Ln,vv=Qt,Tj=Pt.f,xj=Sn,jl=Ts,Ao=Fa,Ij=tt,wj=Ui,I1=Xe.enforce,Cj=Xe.get,Bl=hn.Int8Array,gv=Bl&&Bl.prototype,w1=hn.Uint8ClampedArray,C1=w1&&w1.prototype,Cr=Bl&&jl(Bl),sr=gv&&jl(gv),Ej=Object.prototype,_v=hn.TypeError,E1=Ij("toStringTag"),yv=wj("TYPED_ARRAY_TAG"),Rj="TypedArrayConstructor",Jr=bj&&!!Ao&&mv(hn.opera)!=="Opera",R1=!1,qr={Int8Array:1,Uint8Array:1,Uint8ClampedArray:1,Int16Array:2,Uint16Array:2,Int32Array:4,Uint32Array:4,Float32Array:4,Float64Array:8},bv={BigInt64Array:8,BigUint64Array:8},A1=function(e){var t=jl(e);if(Vl(t)){var n=Cj(t);return n&&Ei(n,Rj)?n.TypedArrayConstructor:A1(t)}},P1=function(e){if(!Vl(e))return!1;var t=mv(e);return Ei(qr,t)||Ei(bv,t)};for(_n in qr)(Ul=(Ro=hn[_n])&&Ro.prototype)?I1(Ul).TypedArrayConstructor=Ro:Jr=!1;for(_n in bv)(Ul=(Ro=hn[_n])&&Ro.prototype)&&(I1(Ul).TypedArrayConstructor=Ro);if((!Jr||!x1(Cr)||Cr===Function.prototype)&&(Cr=function(){throw _v("Incorrect invocation")},Jr))for(_n in qr)hn[_n]&&Ao(hn[_n],Cr);if((!Jr||!sr||sr===Ej)&&(sr=Cr.prototype,Jr))for(_n in qr)hn[_n]&&Ao(hn[_n].prototype,sr);if(Jr&&jl(C1)!==sr&&Ao(C1,sr),pv&&!Ei(sr,E1))for(_n in R1=!0,Tj(sr,E1,{get:function(){return Vl(this)?this[yv]:void 0}}),qr)hn[_n]&&kj(hn[_n],yv,_n);var Ge={NATIVE_ARRAY_BUFFER_VIEWS:Jr,TYPED_ARRAY_TAG:R1&&yv,aTypedArray:function(e){if(P1(e))return e;throw _v("Target is not a typed array")},aTypedArrayConstructor:function(e){if(x1(e)&&(!Ao||xj(Cr,e)))return e;throw _v(Sj(e)+" is not a typed array constructor")},exportTypedArrayMethod:function(e,t,n,i){if(pv){if(n)for(var r in qr){var o=hn[r];if(o&&Ei(o.prototype,e))try{delete o.prototype[e]}catch(c){try{o.prototype[e]=t}catch(a){}}}sr[e]&&!n||vv(sr,e,n?t:Jr&&gv[e]||t,i)}},exportTypedArrayStaticMethod:function(e,t,n){var i,r;if(pv){if(Ao){if(n){for(i in qr)if((r=hn[i])&&Ei(r,e))try{delete r[e]}catch(o){}}if(Cr[e]&&!n)return;try{return vv(Cr,e,n?t:Jr&&Cr[e]||t)}catch(o){}}for(i in qr)!(r=hn[i])||r[e]&&!n||vv(r,e,t)}},getTypedArrayConstructor:A1,isView:function(e){if(!Vl(e))return!1;var t=mv(e);return t==="DataView"||Ei(qr,t)||Ei(bv,t)},isTypedArray:P1,TypedArray:Cr,TypedArrayPrototype:sr},D1=re,Sv=ue,Aj=vu,Pj=Ge.NATIVE_ARRAY_BUFFER_VIEWS,Dj=D1.ArrayBuffer,va=D1.Int8Array,Oj=!Pj||!Sv(function(){va(1)})||!Sv(function(){new va(-1)})||!Aj(function(e){new va,new va(null),new va(1.5),new va(e)},!0)||Sv(function(){return new va(new Dj(2),1,void 0).length!==1}),Lj=$n,Mj=RangeError,Nj=function(e){var t=Lj(e);if(t<0)throw Mj("The argument can't be less than 0");return t},Uj=RangeError,O1=function(e,t){var n=Nj(e);if(n%t)throw Uj("Wrong offset");return n},Vj=Dr,jj=pe("".slice),Bj=Vi,Fj=TypeError,L1=function(e){var t=Bj(e,"number");if(typeof t=="number")throw Fj("Can't convert number to bigint");return BigInt(t)},Hj=Lr,Gj=Ke,zj=x0,Wj=Mt,Jj=nn,qj=pu,Kj=Es,Xj=lh,Qj=function(e){return jj(Vj(e),0,3)==="Big"},Yj=Ge.aTypedArrayConstructor,$j=L1,M1=Le,N1=re,U1=Ke,Zj=ye,e8=Oj,Po=Ge,V1=vc,j1=oi,t8=Ze,_c=Ln,n8=YS,r8=yr,B1=jT,kv=O1,F1=Da,yc=kt,i8=Dr,Tv=at,a8=Li,o8=Ba,s8=Sn,Fl=Fa,c8=ii.f,H1=function(e){var t,n,i,r,o,c,a,s,l=zj(this),u=Wj(e),f=arguments.length,S=f>1?arguments[1]:void 0,x=S!==void 0,E=Kj(u);if(E&&!Xj(E))for(s=(a=qj(u,E)).next,u=[];!(c=Gj(s,a)).done;)u.push(c.value);for(x&&f>2&&(S=Hj(S,arguments[2])),n=Jj(u),i=new(Yj(l))(n),r=Qj(i),t=0;n>t;t++)o=x?S(u[t],t):u[t],i[t]=r?$j(o):+o;return i},u8=rn.forEach,l8=Ps,G1=Pt,z1=be,d8=gu,xv=Xe.get,h8=Xe.set,f8=Xe.enforce,Iv=G1.f,p8=z1.f,m8=Math.round,wv=N1.RangeError,W1=V1.ArrayBuffer,v8=W1.prototype,g8=V1.DataView,Hl=Po.NATIVE_ARRAY_BUFFER_VIEWS,J1=Po.TYPED_ARRAY_TAG,q1=Po.TypedArray,bc=Po.TypedArrayPrototype,_8=Po.aTypedArrayConstructor,Cv=Po.isTypedArray,Gl="BYTES_PER_ELEMENT",Ev="Wrong length",K1=function(e,t){_8(e);for(var n=0,i=t.length,r=new e(i);i>n;)r[n]=t[n++];return r},zl=function(e,t){Iv(e,t,{get:function(){return xv(this)[t]}})},X1=function(e){var t;return s8(v8,e)||(t=i8(e))=="ArrayBuffer"||t=="SharedArrayBuffer"},Q1=function(e,t){return Cv(e)&&!a8(t)&&t in e&&n8(+t)&&t>=0},Y1=function(e,t){return t=F1(t),Q1(e,t)?t8(2,e[t]):p8(e,t)},$1=function(e,t,n){return t=F1(t),!(Q1(e,t)&&Tv(n)&&yc(n,"value"))||yc(n,"get")||yc(n,"set")||n.configurable||yc(n,"writable")&&!n.writable||yc(n,"enumerable")&&!n.enumerable?Iv(e,t,n):(e[t]=n.value,e)};Zj?(Hl||(z1.f=Y1,G1.f=$1,zl(bc,"buffer"),zl(bc,"byteOffset"),zl(bc,"byteLength"),zl(bc,"length")),M1({target:"Object",stat:!0,forced:!Hl},{getOwnPropertyDescriptor:Y1,defineProperty:$1}),fv.exports=function(e,t,n){var i=e.match(/\d+$/)[0]/8,r=e+(n?"Clamped":"")+"Array",o="get"+e,c="set"+e,a=N1[r],s=a,l=s&&s.prototype,u={},f=function(x,E){Iv(x,E,{get:function(){return function(I,m){var T=xv(I);return T.view[o](m*i+T.byteOffset,!0)}(this,E)},set:function(I){return function(m,T,v){var w=xv(m);n&&(v=(v=m8(v))<0?0:v>255?255:255&v),w.view[c](T*i+w.byteOffset,v,!0)}(this,E,I)},enumerable:!0})};Hl?e8&&(s=t(function(x,E,I,m){return j1(x,l),d8(Tv(E)?X1(E)?m!==void 0?new a(E,kv(I,i),m):I!==void 0?new a(E,kv(I,i)):new a(E):Cv(E)?K1(s,E):U1(H1,s,E):new a(B1(E)),x,s)}),Fl&&Fl(s,q1),u8(c8(a),function(x){x in s||_c(s,x,a[x])}),s.prototype=l):(s=t(function(x,E,I,m){j1(x,l);var T,v,w,L=0,N=0;if(Tv(E)){if(!X1(E))return Cv(E)?K1(s,E):U1(H1,s,E);T=E,N=kv(I,i);var V=E.byteLength;if(m===void 0){if(V%i||(v=V-N)<0)throw wv(Ev)}else if((v=r8(m)*i)+N>V)throw wv(Ev);w=v/i}else w=B1(E),T=new W1(v=w*i);for(h8(x,{buffer:T,byteOffset:N,byteLength:v,length:w,view:new g8(T)});L<w;)f(x,L++)}),Fl&&Fl(s,q1),l=s.prototype=o8(bc)),l.constructor!==s&&_c(l,"constructor",s),f8(l).TypedArrayConstructor=s,J1&&_c(l,J1,r);var S=s!=a;u[r]=s,M1({global:!0,constructor:!0,forced:S,sham:!Hl},u),Gl in s||_c(s,Gl,i),Gl in l||_c(l,Gl,i),l8(r)}):fv.exports=function(){},(0,fv.exports)("Uint8",function(e){return function(t,n,i){return e(this,t,n,i)}});var y8=Mt,Rv=ai,b8=nn,S8=W_,k8=Math.min,T8=[].copyWithin||function(e,t){var n=y8(this),i=b8(n),r=Rv(e,i),o=Rv(t,i),c=arguments.length>2?arguments[2]:void 0,a=k8((c===void 0?i:Rv(c,i))-o,i-r),s=1;for(o<r&&r<o+a&&(s=-1,o+=a-1,r+=a-1);a-- >0;)o in n?n[r]=n[o]:S8(n,r),r+=s,o+=s;return n},Z1=Ge,x8=pe(T8),I8=Z1.aTypedArray;(0,Z1.exportTypedArrayMethod)("copyWithin",function(e,t){return x8(I8(this),e,t,arguments.length>2?arguments[2]:void 0)});var w8=rn.every,C8=Ge.aTypedArray;(0,Ge.exportTypedArrayMethod)("every",function(e){return w8(C8(this),e,arguments.length>1?arguments[1]:void 0)});var E8=FT,R8=L1,A8=Dr,P8=Ke,D8=ue,O8=Ge.aTypedArray,L8=Ge.exportTypedArrayMethod,M8=pe("".slice);L8("fill",function(e){var t=arguments.length;O8(this);var n=M8(A8(this),0,3)==="Big"?R8(e):+e;return P8(E8,this,n,t>1?arguments[1]:void 0,t>2?arguments[2]:void 0)},D8(function(){var e=0;return new Int8Array(2).fill({valueOf:function(){return e++}}),e!==1}));var N8=nn,U8=Ou,V8=Ge.aTypedArrayConstructor,j8=Ge.getTypedArrayConstructor,Wl=function(e){return V8(U8(e,j8(e)))},B8=function(e,t){for(var n=0,i=N8(t),r=new e(i);i>n;)r[n]=t[n++];return r},F8=Wl,H8=rn.filter,G8=function(e,t){return B8(F8(e),t)},z8=Ge.aTypedArray;(0,Ge.exportTypedArrayMethod)("filter",function(e){var t=H8(z8(this),e,arguments.length>1?arguments[1]:void 0);return G8(this,t)});var W8=rn.find,J8=Ge.aTypedArray;(0,Ge.exportTypedArrayMethod)("find",function(e){return W8(J8(this),e,arguments.length>1?arguments[1]:void 0)});var q8=rn.findIndex,K8=Ge.aTypedArray;(0,Ge.exportTypedArrayMethod)("findIndex",function(e){return q8(K8(this),e,arguments.length>1?arguments[1]:void 0)});var X8=rn.forEach,Q8=Ge.aTypedArray;(0,Ge.exportTypedArrayMethod)("forEach",function(e){X8(Q8(this),e,arguments.length>1?arguments[1]:void 0)});var Y8=ys.includes,$8=Ge.aTypedArray;(0,Ge.exportTypedArrayMethod)("includes",function(e){return Y8($8(this),e,arguments.length>1?arguments[1]:void 0)});var Z8=ys.indexOf,eB=Ge.aTypedArray;(0,Ge.exportTypedArrayMethod)("indexOf",function(e){return Z8(eB(this),e,arguments.length>1?arguments[1]:void 0)});var tB=re,nB=ue,Av=pe,ex=Ge,Pv=Gg,Dv=tt("iterator"),tx=tB.Uint8Array,rB=Av(Pv.values),iB=Av(Pv.keys),aB=Av(Pv.entries),Ov=ex.aTypedArray,Jl=ex.exportTypedArrayMethod,Do=tx&&tx.prototype,ql=!nB(function(){Do[Dv].call([1])}),nx=!!Do&&Do.values&&Do[Dv]===Do.values&&Do.values.name==="values",rx=function(){return rB(Ov(this))};Jl("entries",function(){return aB(Ov(this))},ql),Jl("keys",function(){return iB(Ov(this))},ql),Jl("values",rx,ql||!nx,{name:"values"}),Jl(Dv,rx,ql||!nx,{name:"values"});var oB=Ge.aTypedArray,sB=Ge.exportTypedArrayMethod,cB=pe([].join);sB("join",function(e){return cB(oB(this),e)});var uB=Ji,lB=bn,dB=$n,hB=nn,fB=Ns,pB=Math.min,Lv=[].lastIndexOf,ix=!!Lv&&1/[1].lastIndexOf(1,-0)<0,mB=fB("lastIndexOf"),vB=ix||!mB?function(e){if(ix)return uB(Lv,this,arguments)||0;var t=lB(this),n=hB(t),i=n-1;for(arguments.length>1&&(i=pB(i,dB(arguments[1]))),i<0&&(i=n+i);i>=0;i--)if(i in t&&t[i]===e)return i||0;return-1}:Lv,gB=Ji,_B=vB,yB=Ge.aTypedArray;(0,Ge.exportTypedArrayMethod)("lastIndexOf",function(e){var t=arguments.length;return gB(_B,yB(this),t>1?[e,arguments[1]]:[e])});var bB=rn.map,SB=Wl,kB=Ge.aTypedArray;(0,Ge.exportTypedArrayMethod)("map",function(e){return bB(kB(this),e,arguments.length>1?arguments[1]:void 0,function(t,n){return new(SB(t))(n)})});var TB=dv.left,xB=Ge.aTypedArray;(0,Ge.exportTypedArrayMethod)("reduce",function(e){var t=arguments.length;return TB(xB(this),e,t,t>1?arguments[1]:void 0)});var IB=dv.right,wB=Ge.aTypedArray;(0,Ge.exportTypedArrayMethod)("reduceRight",function(e){var t=arguments.length;return IB(wB(this),e,t,t>1?arguments[1]:void 0)});var CB=Ge.aTypedArray,EB=Ge.exportTypedArrayMethod,RB=Math.floor;EB("reverse",function(){for(var e,t=this,n=CB(t).length,i=RB(n/2),r=0;r<i;)e=t[r],t[r++]=t[--n],t[n]=e;return t});var ax=re,ox=Ke,Mv=Ge,AB=nn,PB=O1,DB=Mt,sx=ue,OB=ax.RangeError,Nv=ax.Int8Array,cx=Nv&&Nv.prototype,ux=cx&&cx.set,LB=Mv.aTypedArray,MB=Mv.exportTypedArrayMethod,Uv=!sx(function(){var e=new Uint8ClampedArray(2);return ox(ux,e,{length:1,0:3},1),e[1]!==3}),NB=Uv&&Mv.NATIVE_ARRAY_BUFFER_VIEWS&&sx(function(){var e=new Nv(2);return e.set(1),e.set("2",1),e[0]!==0||e[1]!==2});MB("set",function(e){LB(this);var t=PB(arguments.length>1?arguments[1]:void 0,1),n=DB(e);if(Uv)return ox(ux,this,n,t);var i=this.length,r=AB(n),o=0;if(r+t>i)throw OB("Wrong length");for(;o<r;)this[t+o]=n[o++]},!Uv||NB);var UB=Wl,VB=Ha,jB=Ge.aTypedArray;(0,Ge.exportTypedArrayMethod)("slice",function(e,t){for(var n=VB(jB(this),e,t),i=UB(this),r=0,o=n.length,c=new i(o);o>r;)c[r]=n[r++];return c},ue(function(){new Int8Array(1).slice()}));var BB=rn.some,FB=Ge.aTypedArray;(0,Ge.exportTypedArrayMethod)("some",function(e){return BB(FB(this),e,arguments.length>1?arguments[1]:void 0)});var lx=Kn.match(/firefox\/(\d+)/i),HB=!!lx&&+lx[1],GB=/MSIE|Trident/.test(Kn),dx=Kn.match(/AppleWebKit\/(\d+)\./),zB=!!dx&&+dx[1],WB=pe,Vv=ue,JB=Vt,qB=wy,hx=HB,KB=GB,fx=pr,px=zB,XB=Ge.aTypedArray,QB=Ge.exportTypedArrayMethod,Sc=re.Uint16Array,Oo=Sc&&WB(Sc.prototype.sort),YB=!(!Oo||Vv(function(){Oo(new Sc(2),null)})&&Vv(function(){Oo(new Sc(2),{})})),mx=!!Oo&&!Vv(function(){if(fx)return fx<74;if(hx)return hx<67;if(KB)return!0;if(px)return px<602;var e,t,n=new Sc(516),i=Array(516);for(e=0;e<516;e++)t=e%4,n[e]=515-e,i[e]=e-2*t+3;for(Oo(n,function(r,o){return(r/4|0)-(o/4|0)}),e=0;e<516;e++)if(n[e]!==i[e])return!0});QB("sort",function(e){return e!==void 0&&JB(e),mx?Oo(this,e):qB(XB(this),function(t){return function(n,i){return t!==void 0?+t(n,i)||0:i!=i?-1:n!=n?1:n===0&&i===0?1/n>0&&1/i<0?1:-1:n>i}}(e))},!mx||YB);var $B=yr,vx=ai,ZB=Wl,eF=Ge.aTypedArray;(0,Ge.exportTypedArrayMethod)("subarray",function(e,t){var n=eF(this),i=n.length,r=vx(e,i);return new(ZB(n))(n.buffer,n.byteOffset+r*n.BYTES_PER_ELEMENT,$B((t===void 0?i:vx(t,i))-r))});var tF=Ji,gx=Ge,jv=ue,_x=Ha,Kl=re.Int8Array,yx=gx.aTypedArray,nF=gx.exportTypedArrayMethod,bx=[].toLocaleString,rF=!!Kl&&jv(function(){bx.call(new Kl(1))});nF("toLocaleString",function(){return tF(bx,rF?_x(yx(this)):yx(this),_x(arguments))},jv(function(){return[1,2].toLocaleString()!=new Kl([1,2]).toLocaleString()})||!jv(function(){Kl.prototype.toLocaleString.call([1,2])}));var iF=Ge.exportTypedArrayMethod,aF=ue,oF=pe,Sx=re.Uint8Array,sF=Sx&&Sx.prototype||{},Xl=[].toString,cF=oF([].join);aF(function(){Xl.call({})})&&(Xl=function(){return cF(this)});var uF=sF.toString!=Xl;iF("toString",Xl,uF);var lF=function(){function e(t,n,i){Q(this,e),this.isUplink_=i,this.connection_=t,this.log_=n,this.seiMessageList_=[],this.smallVideoSeiMessageList_=[],this.seiPayloadType_=243,this.runningAbortMap_=new Map,this.abortMap_=new Map,this.onSEIMessage=null}return Ie(e,[{key:"isRunning",get:function(){return!!this.runningAbortMap_.size>0}},{key:"start",value:function(t){var n=this,i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:this.seiMessageList_,r=t.createEncodedStreams(),o=r.readable,c=r.writable,a=new TransformStream({transform:this.isUplink_?function(l,u){return n.encodeVideoFrame(l,u,i)}:function(l,u){var f,S;return n.decodeVideoFrame(l,u,t===((f=n.connection_)===null||f===void 0||(S=f.getPeerConnection())===null||S===void 0?void 0:S.getReceivers()[tS]))}}),s=new AbortController;o.pipeThrough(a).pipeTo(c,{signal:s.signal}).catch(function(){}),this.runningAbortMap_.set(t,s)}},{key:"restart",value:function(t,n){this.stop(),this.start(t,n)}},{key:"stop",value:function(t){var n;(n=this.runningAbortMap_.get(t))===null||n===void 0||n.abort(),this.runningAbortMap_.delete(t)}},{key:"destroy",value:function(){this.stop(),this.runningAbortMap_.forEach(function(t){return t.abort()}),this.runningAbortMap_.clear(),this.abortMap_.forEach(function(t){return t.abort()}),this.abortMap_.clear(),this.log_=null,this.onSEIMessage=null,this.connection_=null}},{key:"handleEncodedStreams",value:function(){var t=this;try{var n=this.connection_.getPeerConnection();this.clearUnusedSenderOrReceiver(n),this.isUplink_?n.getSenders().forEach(function(i,r){if(!t.runningAbortMap_.has(i)&&!t.abortMap_.has(i))if(r===lN||r===eS){var o=r===eS?t.smallVideoSeiMessageList_:t.seiMessageList_;t.isRunning?t.restart(i,o):t.start(i,o)}else t.pipeSenderOrReceiver(i)}):n.getReceivers().forEach(function(i,r){var o;t.runningAbortMap_.has(i)||t.abortMap_.has(i)||(r!==dN&&r!==tS||((o=i.track)===null||o===void 0?void 0:o.kind)!==xe?t.pipeSenderOrReceiver(i):t.isRunning?t.restart(i):t.start(i))})}catch(i){this.log_.warn(i)}}},{key:"pipeSenderOrReceiver",value:function(t){var n=t.createEncodedStreams(),i=n.readable,r=n.writable,o=new AbortController;this.abortMap_.set(t,o),i.pipeTo(r,{signal:o.signal}).catch(function(){})}},{key:"clearUnusedSenderOrReceiver",value:function(t){var n=this;this.abortMap_.forEach(function(i,r){(n.isUplink_?t.getSenders():t.getReceivers()).find(function(o){return o===r})||(i.abort(),n.abortMap_.delete(r))})}},{key:"push",value:function(t,n){n&&n.seiPayloadType&&(this.seiPayloadType_=n.seiPayloadType),this.seiMessageList_.push(t),this.smallVideoSeiMessageList_.push(t)}},{key:"hasSEI",value:function(t){var n=new DataView(t);return n.getInt32(0)===1&&n.getInt8(4)===6}},{key:"isEmptyFrame",value:function(t){return t.type==="empty"||t.data.byteLength===0}},{key:"getNaluCount",value:function(t){for(var n=0,i=0,r=new DataView(t),o=0;o<t.byteLength;o++)switch(r.getUint8(o)){case 0:n++;break;case 1:n!==2&&n!==3||i++,n=0;break;default:n=0}return i}},{key:"encodeVideoFrame",value:function(t,n,i){try{if(this.connection_.isH264&&i.length>0&&!this.isEmptyFrame(t)){var r=9-this.getNaluCount(t.data);if(r<=0)return;for(var o=i.splice(0,r).reverse().map(this.encodeSEINalu.bind(this)),c=o.reduce(function(E,I){return E+I.dataView.byteLength},0),a=new ArrayBuffer(c+t.data.byteLength),s=new DataView(a),l=new DataView(t.data),u=0,f=0;f<o.length;f++)for(var S=0;S<o[f].dataView.byteLength;S++)s.setInt8(u++,o[f].dataView.getInt8(S));for(var x=0;x<t.data.byteLength;x++)s.setInt8(u++,l.getInt8(x));t.data=a,this.log_.debug("".concat(o.length," sei sent"))}}catch(E){this.log_.warn(E)}n.enqueue(t)}},{key:"decodeVideoFrame",value:function(t,n){var i=this,r=arguments.length>2&&arguments[2]!==void 0&&arguments[2];try{if(this.connection_.isH264&&!this.isEmptyFrame(t)&&this.hasSEI(t.data)){for(var o=[],c=new DataView(t.data),a=0,s=-1,l=-1,u=0;u<t.data.byteLength;u++){var f=c.getUint8(u);if(f===0)a++;else if(f===1){if(a===2||a===3){var S=u-a;s===-1?s=S:l===-1&&(l=S,o.push(new kx(new DataView(c.buffer.slice(s,l)))),s=S,l=-1);var x=c.getUint8(u+1)===6;if(!x){t.data=new DataView(c.buffer.slice(S)).buffer;break}}a=0}else a=0}this.log_.debug("".concat(o.length," sei received")),ln(this.onSEIMessage)&&o.reverse().forEach(function(E){i.onSEIMessage({seiPayloadType:E.seiPayloadType,data:E.seiPayload.buffer,isFromAuxiliary:r})})}}catch(E){this.log_.warn(E)}n.enqueue(t)}},{key:"encodeSEINalu",value:function(t){var n=t.byteLength,i=parseInt(n/255),r=n%255,o=[];o.push(0,0,0,1,6,this.seiPayloadType_);for(var c=0;c<i;c++)o.push(255);o.push(r);var a=new DataView(t);return o.push.apply(o,Se(new Uint8Array(a.buffer))),o.push(128),new kx(new DataView(new Uint8Array(o).buffer),!0)}}]),e}(),kx=function(){function e(t){var n=arguments.length>1&&arguments[1]!==void 0&&arguments[1];Q(this,e),this.dataView=t,this.isSEI&&(n?this.addPreventionByte():this.removePreventionByte())}return Ie(e,[{key:"addPreventionByte",value:function(){for(var t=this.seiPayloadStartIndex,n=this.dataView.byteLength-2,i=[],r=0,o=t;o<=n;o++){var c=this.dataView.getInt8(o);switch(c){case 0:case 1:case 2:case 3:r===2&&(i.push(3),r=0),c==0?r++:r=0,i.push(c);break;default:r=0,i.push(c)}}i.push(this.dataView.getInt8(this.dataView.byteLength-1));var a=new DataView(new Uint8Array([].concat(Se(new Uint8Array(this.dataView.buffer).slice(0,t)),i)).buffer);this.dataView=a}},{key:"removePreventionByte",value:function(){for(var t=this.seiPayloadStartIndex,n=this.dataView.byteLength-1,i=[],r=0,o=t;o<=n;o++)switch(this.dataView.getInt8(o)){case 0:r++,i.push(this.dataView.getInt8(o));break;case 3:r!==2&&i.push(this.dataView.getInt8(o)),r=0;break;default:i.push(this.dataView.getInt8(o)),r=0}var c=new DataView(new Uint8Array([].concat(Se(new Uint8Array(this.dataView.buffer).slice(0,t)),i)).buffer);this.dataView=c}},{key:"isSEI",get:function(){return this.dataView.getUint8(4)===6}},{key:"seiPayloadStartIndex",get:function(){for(var t=6,n=6;n<this.dataView.buffer.byteLength&&(t++,this.dataView.getUint8(n)===255);n++);return t}},{key:"seiPayloadType",get:function(){return this.isSEI?this.dataView.getUint8(5):null}},{key:"seiPayload",get:function(){if(!this.isSEI)return null;for(var t=0,n=6,i=6;i<this.dataView.buffer.byteLength;i++){var r=this.dataView.getUint8(i);if(n++,r!==255){t+=r;break}t+=255}for(var o=new ArrayBuffer(t),c=new DataView(o),a=0;a<o.byteLength;a++,n++)c.setInt8(a,this.dataView.getInt8(n));return c}}]),e}(),Bv=function(){function e(n){Q(this,e),this.userId_=n.userId,this.tinyId_=n.tinyId,this.client_=n.client,this.sdpSemantics_=n.client.getSdpSemantics(),this.isUplink_=n.isUplink,this.log_=_e.createLogger({id:"n|"+this.userId_,userId:this.client_.getUserId(),sdkAppId:this.client_.getSDKAppId(),isLocal:this.isUplink_}),this.signalChannel_=n.signalChannel,this.peerConnection_=null,this.isErrorObserved_=!1,this.emitter_=new Si,this.currentState_=on,this.waitForPeerConnectionConnectedPromise_=null,this.isReconnecting_=!1,this.reconnectionCount_=0,this.reconnectionTimer_=-1,this.isFirstConnection_=!0,this.delay_={audioDelay:0,videoDelay:0},this.enableSEI_=n.enableSEI,this.enableSEI_&&Tm&&(this.sei_=new lF(this,this.log_,this.isUplink_))}var t;return Ie(e,[{key:"initialize",value:function(){var n={encodedInsertableStreams:this.enableSEI_&&Tm,iceServers:this.client_.getIceServers(),iceTransportPolicy:this.client_.getIceTransportPolicy(),sdpSemantics:this.sdpSemantics_,bundlePolicy:"max-bundle",rtcpMuxPolicy:"require",tcpCandidatePolicy:"disable",IceTransportsType:"nohost"};this.peerConnection_=new RTCPeerConnection(n),this.peerConnection_.onconnectionstatechange=this.onConnectionStateChange.bind(this)}},{key:"close",value:function(){this.log_.info("closing connection"),this.closePeerConnection(),this.sei_&&(this.sei_.destroy(),this.sei_=null)}},{key:"closePeerConnection",value:function(){var n=arguments.length>0&&arguments[0]!==void 0&&arguments[0];this.peerConnection_&&(this.peerConnection_.onconnectionstatechange=function(){},this.peerConnection_.close(),this.peerConnection_=null,n&&this.emitConnectionStateChangedEvent(on))}},{key:"getDTLSTransportState",value:function(){if(!this.peerConnection_)return Wu;var n=null;if(this.isUplink_){if(!ml()||this.peerConnection_.getSenders().length===0)return Wu;n=this.peerConnection_.getSenders()[0].transport}else{if(!Fk()||this.peerConnection_.getReceivers().length===0)return Wu;n=this.peerConnection_.getReceivers()[0].transport}return n?n.state:Wu}},{key:"onConnectionStateChange",value:function(n){var i=this.peerConnection_.iceConnectionState,r=this.getDTLSTransportState();if(this.log_.info("onConnectionStateChange() connectionState: "+n.target.connectionState),this.log_.info("ICE Transport state: ".concat(i,", DTLS Transport state: ").concat(r)),n.target.connectionState===Ju&&this.emitConnectionStateChangedEvent(bb),n.target.connectionState===Sb||n.target.connectionState===Bf){var o="".concat(this.isUplink_?"uplink":"downlink"," ICE/DTLS Transport connection ").concat(n.target.connectionState,". ICE Transport state: ").concat(i,", DTLS Transport state: ").concat(r),c=new te({message:o,code:Z.ICE_TRANSPORT_ERROR});ke.logFailedEvent({userId:this.client_.getUserId(),eventType:Lb,error:c}),this.emitConnectionStateChangedEvent(on),this.isErrorObserved_||this.emitter_.emit(et.ERROR,c)}n.target.connectionState!==kb&&n.target.connectionState!==ZM||(this.logSelectedCandidate(),ke.logSuccessEvent({userId:this.client_.getUserId(),eventType:Lb}),this.emitConnectionStateChangedEvent(sn))}},{key:"emitConnectionStateChangedEvent",value:function(n){n!==this.currentState_&&(this.currentState_===jf&&n===bb||(Y.emit(hl,{client:this.client_,connection:this,prevState:this.currentState_,state:n}),this.emitter_.emit(et.CONNECTION_STATE_CHANGED,{prevState:this.currentState_,state:n}),this.currentState_=n))}},{key:"hitTest",value:function(n){return(n===0||n==="0")&&this.isUplink_||n===this.tinyId_}},{key:"addEventInternal",value:function(n,i){var r=this.client_.getUserId(),o={eventId:n,eventDesc:i,timestamp:an(),userId:r,tinyId:this.client_.getTinyId()};this.isUplink_||(o.remoteUserId=this.userId_,o.remoteTinyId=this.tinyId_),vn(r,o)}},{key:"getPeerConnection",value:function(){return this.peerConnection_}},{key:"getClient",value:function(){return this.client_}},{key:"getUserId",value:function(){return this.userId_}},{key:"getTinyId",value:function(){return this.tinyId_}},{key:"logSelectedCandidate",value:(t=H(p().mark(function n(){var i,r,o,c,a,s,l;return p().wrap(function(u){for(;;)switch(u.prev=u.next){case 0:if(this.peerConnection_){u.next=2;break}return u.abrupt("return");case 2:return u.next=4,this.peerConnection_.getStats();case 4:i=u.sent,r=oe(i),u.prev=6,r.s();case 8:if((o=r.n()).done){u.next=18;break}if((c=Te(o.value,2))[0],!xm(a=c[1])){u.next=16;break}return s=i.get(a.localCandidateId),l=i.get(a.remoteCandidateId),s&&this.log_.info("local candidate: ".concat(s.candidateType," ").concat(s.protocol,":").concat(s.ip||s.address,":").concat(s.port," ").concat(s.networkType||""," ").concat(s.candidateType==="relay"?"relayProtocol:"+s.relayProtocol:"")),l&&this.log_.info("remote candidate: ".concat(l.candidateType," ").concat(l.protocol,":").concat(l.ip||l.address,":").concat(l.port)),u.abrupt("break",18);case 16:u.next=8;break;case 18:u.next=23;break;case 20:u.prev=20,u.t0=u.catch(6),r.e(u.t0);case 23:return u.prev=23,r.f(),u.finish(23);case 26:case"end":return u.stop()}},n,this,[[6,20,23,26]])})),function(){return t.apply(this,arguments)})},{key:"getCurrentState",value:function(){return this.currentState_}},{key:"waitForPeerConnectionConnected",value:function(){var n=this;return this.waitForPeerConnectionConnectedPromise_||(this.waitForPeerConnectionConnectedPromise_=new Promise(function(i,r){if(n.currentState_===sn)return i();var o=-1,c=function(l){l.state===sn&&(clearTimeout(o),s(),i())},a=function(l){l.client===n.client_&&(clearTimeout(o),s(),r(new te({code:Z.API_CALL_ABORTED,message:ae({key:r4,data:"leave room"})})))},s=function(){Y.off(mo,a,n),n.emitter_.off(et.CONNECTION_STATE_CHANGED,c,n)};o=setTimeout(function(){s();var l=new te({code:Z.API_CALL_TIMEOUT,message:"connection timeout"});r(l)},1e4),Y.on(mo,a,n),n.emitter_.on(et.CONNECTION_STATE_CHANGED,c,n)}),this.waitForPeerConnectionConnectedPromise_=this.waitForPeerConnectionConnectedPromise_.then(function(i){return n.waitForPeerConnectionConnectedPromise_=null,i}).catch(function(i){throw n.waitForPeerConnectionConnectedPromise_=null,i})),this.waitForPeerConnectionConnectedPromise_}},{key:"getReconnectionCount",value:function(){return this.reconnectionCount_}},{key:"startReconnection",value:function(){this.isReconnecting_=!0,this.emitConnectionStateChangedEvent(jf),this.reconnect(),this.addEventInternal(this.isUplink_?fV:vV,"".concat(this.isUplink_?"uplink":"downlink","-connection is reconnecting"))}},{key:"stopReconnection",value:function(){this.log_.info("stop reconnection"),this.isReconnecting_=!1,this.reconnectionCount_=0,this.clearReconnectionTimer(),this.signalChannel_.off(ac,this.reconnect,this)}},{key:"on",value:function(n,i,r){this.emitter_.on(n,i,r)}},{key:"off",value:function(n,i,r){this.emitter_.off(n,i,r)}},{key:"setDelay",value:function(n){var i=n.audioDelay,r=n.videoDelay;this.delay_={audioDelay:i,videoDelay:r}}},{key:"getDelay",value:function(){return this.delay_}},{key:"isH264",get:function(){var n,i;return!((n=this.peerConnection_)===null||n===void 0||(i=n.remoteDescription)===null||i===void 0||!i.sdp.includes("H264"))}}]),e}(),dF=function(){function e(){Q(this,e),this.set_=new Set,Y.on(ul,this.add,this),Y.on(po,this.add,this),Y.on(sa,this.delete,this),Y.on(mo,this.delete,this)}return Ie(e,[{key:"add",value:function(t){var n=t.client,i=t.roomId,r=this.getKey(n.getUserId(),i||n.getRoomId(),n.getSDKAppId(),n.getUseStringRoomId());this.set_.add(r)}},{key:"delete",value:function(t){var n=t.client,i=this.getKey(n.getUserId(),n.getRoomId(),n.getSDKAppId(),n.getUseStringRoomId());this.set_.delete(i)}},{key:"getKey",value:function(t,n,i,r){return"".concat(i,"_").concat(n,"_").concat(t,"_").concat(r)}},{key:"isJoined",value:function(t){var n=t.userId,i=t.roomId,r=t.sdkAppId,o=t.client;return this.set_.has(this.getKey(n,i,r,o.getUseStringRoomId()))}}]),e}(),hF=new dF;function Tx(e,t,n,i){if(this.useStringRoomId_){if(!(Bt(e)&&/^[A-Za-z\d\s!#$%&()+\-:;<=.>?@[\]^_{}|~,]{1,64}$/.test(e)))throw new te({code:Z.INVALID_PARAMETER,message:ae({key:VN,data:t,link:{className:i,fnName:n}})})}else if(!(tr(e)&&/^[1-9]\d*$/.test(String(e))&&e<4294967295))throw new te({code:Z.INVALID_PARAMETER,message:ae({key:jN,data:t,link:{className:i,fnName:n}})})}function xx(e,t,n,i){if(!/^[A-Za-z\d_-]*$/.test(e))throw new te({code:Z.INVALID_PARAMETER,message:ae({key:t3,data:t,link:{className:i,fnName:n}})})}var fF={createClient:{name:"clientConfig",required:!0,type:In,properties:{sdkAppId:{required:!0,type:wt,allowEmpty:!1},userId:{required:!0,type:dt,allowEmpty:!1},userSig:{required:!0,type:dt,allowEmpty:!1},mode:{required:!0,type:dt,values:["rtc",zu]},useStringRoomId:{type:Wt},autoSubscribe:{type:Wt},enableAutoPlayDialog:{type:Wt},streamId:{type:dt},userDefineRecordId:{type:dt},pureAudioPushMode:{type:wt,values:[1,2]},enableSEI:{type:Wt}}},createStream:{name:"streamConfig",required:!0,type:In,properties:{userId:{type:dt},audio:{type:Wt},video:{type:Wt},screen:{type:Wt},screenAudio:{type:Wt},microphoneId:{type:dt},cameraId:{type:dt},facingMode:{type:[dt,In]},audioSource:{instanceOf:window.MediaStreamTrack},videoSource:{instanceOf:window.MediaStreamTrack}},validate:function(e){if(!ge(e.screen)&&e.screen&&ge(e.audio)&&(e.audio=!1),!(ge(e.audio)&&ge(e.video)||ge(e.audioSource)&&ge(e.videoSource)))throw new te({code:Z.INVALID_PARAMETER,message:ae({key:U3})});if(!ge(e.screen)&&e.screen===!0&&e.video===!0)throw new te({code:Z.INVALID_PARAMETER,message:ae({key:V3})});if(e.audio&&e.screenAudio)throw new te({code:Z.INVALID_PARAMETER,message:ae({key:j3})});if(e.screen!==!0&&e.screenAudio===!0)throw new te({code:Z.INVALID_PARAMETER,message:ae({key:B3})});if(!ge(e.screen)&&e.screen===!0&&!this.isScreenShareSupported())throw new te({code:Z.INVALID_OPERATION,message:ae({key:G3})})}}},pF={join:{name:"options",required:!0,type:In,properties:{roomId:{required:!0,type:[wt,dt],allowEmpty:!1,validate:Tx},role:{type:[dt],values:[Tr,Zi]},privateMapKey:{type:[dt]}},validate:function(e){if(this.isJoined_)throw new te({code:Z.INVALID_OPERATION,message:ae({key:UN})});if(this.checkDestroy(),hF.isJoined({userId:this.userId_,roomId:e.roomId,sdkAppId:this.sdkAppId_,client:this}))throw new te({code:Z.INVALID_OPERATION,message:ae({key:x3,data:this.userId_})})}},publish:[{name:"stream",required:!0,instanceOf:mi,validate:function(e){if(!this.isJoined_)throw new te({code:Z.INVALID_OPERATION,message:ae({key:GN})});if(this.mode_===zu&&this.role_===Zi)throw new te({code:Z.INVALID_OPERATION,message:ae({key:WN})});if(!e.getIsReadyToPublish())throw new te({code:Z.INVALID_OPERATION,message:ae({key:JN})});if(this.notPublishWithoutH264Supported_)throw new te({code:Z.NOT_SUPPORTED_H264,message:ae({key:gS})})}},{name:"options",type:In,defaultValue:{isAuxiliary:!1},properties:{isAuxiliary:{type:Wt,defaultValue:!1,validate:function(){var e=arguments.length>0&&arguments[0]!==void 0&&arguments[0];if(e&&!vl())throw new te({code:Z.NOT_SUPPORTED,message:ae({key:z3})});if(this.uplinkConnection_&&(e&&this.uplinkConnection_.isAuxStreamPublished||!e&&this.uplinkConnection_.isMainStreamPublished))throw new te({code:Z.INVALID_OPERATION,message:ae({key:qN,data:e?gt:"local"})});var t=this.localScreenStream_||Se(this.connections_.values()).findIndex(function(n){return n.getTrackState().auxiliary})>=0;if(!this.enableMultiAuxStream_&&e&&t)throw new te({code:Z.INVALID_OPERATION,message:ae({key:i4})})}}}}],unpublish:{name:"stream",required:!0,instanceOf:mi,validate:function(e){if(e!==this.localStream_&&e!==this.localAuxStream_){if(this.localStream_||this.localAuxStream_)throw new te({code:Z.INVALID_PARAMETER,message:ae({key:zN})});this.log_.warn("Client currently has no published stream, please call publish() first.")}}},subscribe:[{name:"stream",required:!0,instanceOf:Xf,validate:function(e){if(!e.getConnection())throw new te({code:Z.INVALID_OPERATION,message:ae({key:ep})});if(this.notSubscribeWithoutH264Supported_)throw new te({code:Z.NOT_SUPPORTED_H264,message:ae({key:_S})})}},{name:"options",type:In,properties:{audio:{type:Wt},video:{type:Wt},smallVideo:{type:Wt}},validate:function(e){var t=e.audio,n=e.video,i=e.smallVideo;if(t===!1&&n===!1&&(ge(i)||i===!1))throw new te({code:Z.INVALID_OPERATION,message:ae({key:Q3})})}}],unsubscribe:{name:"stream",required:!0,instanceOf:Xf,validate:function(e){if(!e.getConnection())throw new te({code:Z.INVALID_OPERATION,message:ae({key:ep})})}},switchRole:{name:"role",required:!0,values:[Tr,Zi],validate:function(){if(this.mode_!==zu)throw new te({code:Z.INVALID_PARAMETER,message:ae({key:XN})});if(!this.isJoined_)throw new te({code:Z.INVALID_OPERATION,message:ae({key:QN})})}},startPublishCDNStream:{name:"options",required:!1,properties:{streamId:{type:dt,validate:xx},streamType:{type:dt,values:["main","auxiliary"]},appId:{type:wt,allowEmpty:!1},bizId:{type:wt,allowEmpty:!1},url:{type:dt,allowEmpty:!1}},validate:function(){if(this.isDestroyed_)throw new te({code:Z.INVALID_OPERATION,message:ae({key:tp,data:{funName:"startPublishCDNStream"}})})}},startMixTranscode:{name:"config",required:!0,type:In,properties:{mode:{type:dt,values:["preset-layout","manual"]},streamId:{type:dt,validate:xx},videoWidth:{type:wt,notLessThanZero:!0},videoHeight:{type:wt,notLessThanZero:!0},videoBitrate:{type:wt,notLessThanZero:!0,allowEmpty:!1},videoFramerate:{type:wt,validate:function(e,t,n,i){if(e<=0||e>30)throw new te({code:Z.INVALID_PARAMETER,message:ae({key:R3,link:{className:i,fnName:n}})})}},videoGOP:{type:wt,validate:function(e,t,n,i){if(e<1||e>8)throw new te({code:Z.INVALID_PARAMETER,message:ae({key:A3,link:{className:i,fnName:n}})})}},audioSampleRate:{type:wt,notLessThanZero:!0},audioBitrate:{type:wt,validate:function(e,t,n,i){if(e<32||e>192)throw new te({code:Z.INVALID_PARAMETER,message:ae({key:P3,link:{className:i,fnName:n}})})}},audioChannels:{type:wt,values:[1,2]},backgroundColor:{type:wt},backgroundImage:{type:dt},mixUsers:{required:!0,type:zb,arrayItem:{require:!0,type:In,properties:{userId:{required:!0,type:dt},roomId:{type:[dt,wt],validate:Tx},pureAudio:{type:Wt},width:{type:wt,notLessThanZero:!0},height:{type:wt,notLessThanZero:!0},locationX:{type:wt,notLessThanZero:!0},locationY:{type:wt,notLessThanZero:!0},zOrder:{type:wt},streamType:{type:dt,values:["main","auxiliary"]},renderMode:{type:wt,values:[0,1,2,4]}}}}},validate:function(e,t,n,i,r){var o=0,c=0,a=e.mixUsers,s=[];if(a.forEach(function(l,u){if(s.push(l.userId),!l.pureAudio){if(!l.zOrder||l.zOrder<1||l.zOrder>15)throw new te({code:Z.INVALID_PARAMETER,message:ae({key:D3,data:"config.mixUsers[".concat(u,"].zOrder"),link:{className:i,fnName:n}})});l.width+l.locationX>o&&(o=l.width+l.locationX),l.height+l.locationY>c&&(c=l.height+l.locationY)}}),s.indexOf(this.getUserId())<0)throw new te({code:Z.INVALID_PARAMETER,message:ae({key:O3,link:{className:i,fnName:n}})});if(e.videoWidth<o||e.videoHeight<c)throw new te({code:Z.INVALID_PARAMETER,message:ae({key:L3,link:{className:i,fnName:n}})})}},sendSEIMessage:[{name:"buffer",required:!0,instanceOf:ArrayBuffer,validate:function(e){if(!Tm)throw new te({code:Z.NOT_SUPPORTED,message:ae({key:bS})});if(!this.enableSEI_)throw new te({code:Z.INVALID_OPERATION,message:ae({key:Y3})});if(e.byteLength>1e3)throw new te({code:Z.INVALID_PARAMETER,message:ae({key:Z3,data:e.byteLength})});if(e.byteLength===0)throw new te({code:Z.INVALID_PARAMETER,message:ae({key:$3})});if(!this.uplinkConnection_||!this.localStream_)throw new te({code:Z.INVALID_PARAMETER,message:ae({key:e4})});if(!this.localStream_.hasVideo())throw new te({code:Z.INVALID_OPERATION,message:ae({key:t4})});var t=this.uplinkConnection_.isH264;if(!t)throw new te({code:Z.NOT_SUPPORTED,message:ae({key:bS,data:t})})}},{name:"options",type:In,properties:{seiPayloadType:{type:wt,values:[5,243]}}}]},mF={switchDevice:[{name:"type",required:!0,type:dt,values:[Ee,xe]},{name:"deviceId",required:!0,type:dt,validate:function(){if(this.screen_&&!this.audio_||this.audioSource_||this.videoSource_)throw new te({code:Z.INVALID_OPERATION,message:ae({key:l3})});if(this.publishState_===$s)throw new te({code:Z.INVALID_OPERATION,message:ae({key:d3})});if(!km())throw new te({code:Z.NOT_SUPPORTED,message:ae({key:H3})})}}],setAudioCaptureVolume:{name:"volume",type:wt}},vF={play:[{name:"elementId",required:!0,type:[dt,"HTMLDivElement"],validate:function(e,t,n){if(Bt(e)){var i=document.getElementById(e);if(!i)throw new te({code:Z.INVALID_PARAMETER,message:ae({key:M3,data:{key:t,fnName:n}})});if(!(i instanceof HTMLDivElement))throw new te({code:Z.INVALID_PARAMETER,message:ae({key:N3,data:{key:t,fnName:n,type:bi(i)}})})}}},{name:"options",type:In,properties:{objectFit:{type:dt,values:["contain","cover","fill"]},muted:{type:Wt},mirror:{type:Wt}}}],addTrack:{name:Nf,instanceOf:window.MediaStreamTrack,validate:function(e){if(this.isAddingTrack_)throw new te({code:Z.INVALID_OPERATION,message:ae({key:f3})});if(this.isRemovingTrack_)throw new te({code:Z.INVALID_OPERATION,message:ae({key:p3})});if(this.publishState_===$s)throw new te({code:Z.INVALID_OPERATION,message:ae({key:m3})});var t=this.getMediaStream();if(!t)throw new te({code:Z.INVALID_OPERATION,message:ae({key:pS})});if(e.kind===Ee&&t.getAudioTracks().length>0||e.kind===xe&&t.getVideoTracks().length>0)throw new te({code:Z.INVALID_OPERATION,message:ae({key:v3})});if(!Ti()&&!ml())throw new te({code:Z.NOT_SUPPORTED,message:ae({key:rp,data:gb})})}},removeTrack:{name:Nf,instanceOf:window.MediaStreamTrack,validate:function(e){if(this.isAddingTrack_)throw new te({code:Z.INVALID_OPERATION,message:ae({key:_3})});if(this.isRemovingTrack_)throw new te({code:Z.INVALID_OPERATION,message:ae({key:y3})});if(this.publishState_===$s)throw new te({code:Z.INVALID_OPERATION,message:ae({key:b3})});var t=this.getMediaStream();if(!t)throw new te({code:Z.INVALID_OPERATION,message:ae({key:pS})});if(t.getTracks().indexOf(e)===-1)throw new te({code:Z.INVALID_PARAMETER,message:ae({key:S3})});if(!Ti()){if(t.getTracks().length===1)throw new te({code:Z.INVALID_OPERATION,message:ae({key:k3})});if(e.kind===Ee)throw new te({code:Z.INVALID_PARAMETER,message:ae({key:g3})});if(!ml())throw new te({code:Z.NOT_SUPPORTED,message:ae({key:rp,data:_b})})}}},replaceTrack:{name:Nf,instanceOf:window.MediaStreamTrack,validate:function(e){var t=this.getMediaStream();if(!t)throw new te({code:Z.INVALID_OPERATION,message:ae({key:h3})});if(this.publishState_===$s)throw new te({code:Z.INVALID_OPERATION,message:ae({key:fS})});if(e.kind===Ee&&t.getAudioTracks().length<=0||e.kind===xe&&t.getVideoTracks().length<=0)throw new te({code:Z.INVALID_PARAMETER,message:ae({key:T3,data:e})});if(!km())throw new te({code:Z.NOT_SUPPORTED,message:ae({key:rp,data:FM})})}}},Yt={TRTC:fF,CLIENT:pF,LOCAL_STREAM:mF,STREAM:vF};function Ql(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return function(i,r,o){var c=o.value;return o.value=function(){for(var a=arguments.length,s=new Array(a),l=0;l<a;l++)s[l]=arguments[l];return Ix.call(this,t,s,r,this.name_),c.apply(this,s)},o}}function fn(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return function(i,r,o){var c=o.value;return o.value=H(p().mark(function a(){var s,l,u,f=arguments;return p().wrap(function(S){for(;;)switch(S.prev=S.next){case 0:for(s=f.length,l=new Array(s),u=0;u<s;u++)l[u]=f[u];return Ix.call(this,t,l,r,this.name_),S.abrupt("return",c.apply(this,l));case 3:case"end":return S.stop()}},a,this)})),o}}function Ix(e,t,n,i){try{for(var r=0;r<e.length;r++)Fv.call(this,{rule:e[r],value:t[r],key:e[r].name,fnName:n,className:i})}catch(o){throw _e.error(o),o}}function Fv(e){var t=this,n=e.rule,i=e.value,r=e.key,o=e.fnName,c=e.className;if(ge(i)){if(n.required)throw new te({code:Z.INVALID_PARAMETER,message:ae({key:SN,data:{key:r,rule:n,fnName:o,value:i},link:{className:c,fnName:o}})});if(ge(n.defaultValue))return;i=n.defaultValue}if(Array.isArray(n.type)){if(!n.type.map(function(f){return f.toLowerCase()}).includes(bi(i)))throw new te({code:Z.INVALID_PARAMETER,message:ae({key:sS,data:{key:r,rule:n,fnName:o,value:i},link:{className:c,fnName:o}})})}else if(!ge(n.type)&&bi(i)!==n.type)throw new te({code:Z.INVALID_PARAMETER,message:ae({key:sS,data:{key:r,rule:n,fnName:o,value:i},link:{className:c,fnName:o}})});if(n.allowEmpty===!1){var a=tr(i)&&(i===0||Number.isNaN(i)),s=Bt(i)&&i.trim()==="";if(a||s)throw new te({code:Z.INVALID_PARAMETER,message:ae({key:kN,data:{key:r,rule:n,fnName:o,value:i},link:{className:c,fnName:o}})})}if(n.notLessThanZero&&tr(i)&&i<0)throw new te({code:Z.INVALID_PARAMETER,message:ae({key:E3,data:{key:r,rule:n,fnName:o,value:i},link:{className:c,fnName:o}})});if(Bt(n.instanceOf)){if(!i||i.name_!==n.instanceOf)throw new te({code:Z.INVALID_PARAMETER,message:ae({key:cS,data:{key:r,rule:n,fnName:o,value:i},link:{className:c,fnName:o}})})}else if(ln(n.instanceOf)&&!(i instanceof n.instanceOf))throw new te({code:Z.INVALID_PARAMETER,message:ae({key:cS,data:{key:r,rule:n,fnName:o,value:i},link:{className:c,fnName:o}})});if(n.values&&!n.values.includes(i))throw new te({code:Z.INVALID_PARAMETER,message:ae({key:TN,data:{key:r,rule:n,fnName:o,value:i},link:{className:c,fnName:o}})});var l=n.properties;yi(l)&&US(i)&&Object.keys(l).forEach(function(f){Fv.call(t,{rule:l[f],value:i&&i[f],key:"".concat(r,".").concat(f),fnName:o,className:c})});var u=n.arrayItem;yi(u)&&ho(i)&&i.forEach(function(f,S){Fv.call(t,{rule:u,value:f,key:"".concat(r,"[").concat(S,"]"),fnName:o,className:c})}),ln(n.validate)&&n.validate.call(this,i,r,o,c,this)}Le({target:"Number",stat:!0},{isNaN:function(e){return e!=e}});var gF=Le,_F=ue,yF=oh.f;gF({target:"Object",stat:!0,forced:_F(function(){return!Object.getOwnPropertyNames(1)})},{getOwnPropertyNames:yF});var wx,kc,bF=tT;function Lo(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{retries:5,timeout:2e3};return function(t,n,i){var r=ic({retryFunction:i.value,settings:e,onError:e.onError,onRetrying:e.onRetrying,onRetryFailed:e.onRetryFailed});return i.value=function(){for(var o=arguments.length,c=new Array(o),a=0;a<o;a++)c[a]=arguments[a];return r.apply(this,c)},i}}Le({target:"Array",stat:!0,forced:!vu(function(e){Array.from(e)})},{from:bF});var Cx,Ex,Rx,cr,ga=5e3,SF={msg_user_info:0,uint32_video_avg_fps:0,uint32_video_width:0,uint32_video_height:0,uint32_video_avg_bitrate:0,uint32_video_block_time:0,uint32_video_play_time:0,uint32_audio_block_time:0,uint32_audio_play_time:0,uint32_audio_play_db:0,uint32_avg_down_loss:0,uint32_stream_type:0,uint32_video_render_first:0,uint32_video_block_count:0,uint32_audio_block_count:0,uint32_audio_bitrate:0,uint32_video_black_screen_subjective:0,uint32_audio_recv_bitrate:0,uint32_video_external_block_time:0},Hv=Ie(function e(t){Q(this,e),this.str_identifier=String(t.userId),this.uint64_tinyid=Number(t.tinyId),this.uint32_role=t.role}),kF=(wx=Lo({timeout:500,retries:3}),kc=function(){function e(r){var o=this;Q(this,e),this.frameWorkType_=r.frameWorkType||30,this.component_=r.component||0,this.client_=r.client,this.keyPrefix_="key_point",this.storageKey_="".concat(this.keyPrefix_,"_").concat(this.client_.getUserId()),this.log_=_e.createLogger({id:"kpm|"+this.client_.getUserId(),userId:this.client_.getUserId(),sdkAppId:this.client_.getSDKAppId()}),Object.getOwnPropertyNames(this.__proto__).forEach(function(c){c.startsWith("handle")&&ln(o[c])&&(o[c]=function(a){var s=a.fn,l=a.context;return H(p().mark(function u(){var f,S,x,E=arguments;return p().wrap(function(I){for(;;)switch(I.prev=I.next){case 0:for(I.prev=0,f=E.length,S=new Array(f),x=0;x<f;x++)S[x]=E[x];return I.next=4,s.apply(l||this,S);case 4:return I.abrupt("return",I.sent);case 7:I.prev=7,I.t0=I.catch(0),_e.error("".concat(s.name,"() error observed ")+I.t0);case 10:case"end":return I.stop()}},u,this,[[0,7]])}))}({fn:o[c],context:o}))}),this.initData(),this.installEvents(),this.intervalId_=mt.run(uo,this.setStorage.bind(this),{delay:2e4})}var t,n,i;return Ie(e,[{key:"initData",value:function(){var r;this.firstPublishedUserList_=[],this.networkQuality_={totalUplinkRTT:0,totalUplinkLoss:0,count:0,totalDownlinkRTTAndLossMap:new Map},this.basicInfo={string_sdk_version:Gi,uint32_os_type:15,string_device_name:"",string_http_user_agent:navigator.userAgent,string_os_version:"",string_domain:location.host,uint32_avg_rtt:0,uint32_avg_up_loss:0,uint32_scene:((r=this.client_)===null||r===void 0?void 0:r.getMode())==="live"?1:0,uint32_joining_duration:0,uint32_networkType:qf[Tp()],uint32_framework:this.frameWorkType_,uint32_component:this.component_},this.pathJoinRoom_={uint64_start_time:0,uint64_init_audio_start_time:0,uint64_init_audio_end_time:0,uint64_init_camera_start_time:0,uint64_init_camera_end_time:0,uint64_send_request_acc_ip_cmd_start_time:0,uint64_send_request_acc_ip_cmd_end_time:0,uint64_send_request_enter_room_cmd_start_time:0,uint64_send_request_enter_room_cmd_end_time:0,uint64_send_first_video_frame_time:0,uint64_recv_userlist_time:0,uint64_end_time:0,int32_init_audio_ret:0,int32_init_camera_ret:0,int32_send_request_acc_ip_cmd_ret:0,int32_send_request_enter_room_cmd_ret:0,int32_end_ret:0},this.pathLeaveRoom_={uint64_start_time:0,uint64_send_request_exit_room_cmd_start_time:0,uint64_send_request_exit_room_cmd_end_time:0,uint64_end_time:0,int32_send_request_exit_room_cmd_ret:0,int32_end_ret:0},this.pathMainVideoMap_=new Map,this.pathMainAudioMap_=new Map,this.pathAuxiliaryMap_=new Map,this.localStreamStats_={totalVideoBitrate:0,totalVideoFPS:0,totalVideoHeight:0,totalVideoWidth:0,totalAudioLevel:0,videoCount:0,audioLevelCount:0,publishStartTime:0,statsToReport:{uint32_audio_capture_db:0,uint32_video_big_capture_fps:0,uint32_video_big_bitrate:0,uint32_video_big_resolution:0}},this.remoteStreamStatsMap_=new Map}},{key:"installEvents",value:function(){Y.on(ul,this.handleJoinStart,this),Y.on(Mp,this.handleWSStart,this),Y.on(ll,this.handleWSEnd,this),Y.on(Ep,this.handleJoinSendCMD,this),Y.on(Rp,this.handleJoinReceivedCMDResponce,this),Y.on(po,this.handleJoinSuccess,this),Y.on(sa,this.handleJoinFailed,this),Y.on(Op,this.handleReceivedPublishUserList,this),Y.on(hl,this.handleConnectionStateChanged,this),Y.on(Ap,this.handleLeaveStart,this),Y.on(mo,this.handleLeaveSuccess,this),Y.on(Pp,this.handleLeaveSendCMD,this),Y.on(Qp,this.handleSendSubscribeCMD,this),Y.on(tc,this.handleVideoPlaying,this),Y.on(Vp,this.handleAudioPlaying,this),Y.on(Yp,this.handleNetworkQuality,this),Y.on(Dp,this.handleHeartbeatStats,this),Y.on(dl,this.handleRemoteStreamAdded,this),Y.on(jp,this.handleRemoteStreamSubscribeStart,this),Y.on(Ur,this.handleRemoteStreamSubscribed,this),Y.on(ca,this.handleRemoteStreamRemoved,this),Y.on(Wp,this.handleVideoLoadedData,this),Y.on(zp,this.handlePlayStream,this),Y.on(Lp,this.handlePublishStart,this),Y.on(Bp,this.handleLocalStreamInitStart,this),Y.on(Fp,this.handleLocalStreamInitEnd,this),Y.on(Hp,this.handleLocalStreamInitFailed,this)}},{key:"uninstallEvents",value:function(){Y.off(ul,this.handleJoinStart,this),Y.off(Mp,this.handleWSStart,this),Y.off(ll,this.handleWSEnd,this),Y.off(Ep,this.handleJoinSendCMD,this),Y.off(Rp,this.handleJoinReceivedCMDResponce,this),Y.off(Op,this.handleReceivedPublishUserList,this),Y.off(hl,this.handleConnectionStateChanged,this),Y.off(Ap,this.handleLeaveStart,this),Y.off(mo,this.handleLeaveSuccess,this),Y.off(po,this.handleJoinSuccess,this),Y.off(sa,this.handleJoinFailed,this),Y.off(Pp,this.handleLeaveSendCMD,this),Y.off(Qp,this.handleSendSubscribeCMD,this),Y.off(tc,this.handleVideoPlaying,this),Y.off(Vp,this.handleAudioPlaying,this),Y.off(Yp,this.handleNetworkQuality,this),Y.off(Dp,this.handleHeartbeatStats,this),Y.off(dl,this.handleRemoteStreamAdded,this),Y.off(jp,this.handleRemoteStreamSubscribeStart,this),Y.off(Ur,this.handleRemoteStreamSubscribed,this),Y.off(ca,this.handleRemoteStreamRemoved,this),Y.off(Wp,this.handleVideoLoadedData,this),Y.off(zp,this.handlePlayStream,this),Y.off(Lp,this.handlePublishStart,this),Y.off(Bp,this.handleLocalStreamInitStart,this),Y.off(Fp,this.handleLocalStreamInitEnd,this),Y.off(Hp,this.handleLocalStreamInitFailed,this)}},{key:"destroy",value:function(){this.uninstallEvents(),mt.clearTask(this.intervalId_),this.client_=null}},{key:"handleJoinStart",value:function(r){this.hitTest(r.client)&&this.pathJoinRoom_.uint64_start_time===0&&(this.pathJoinRoom_.uint64_start_time=Date.now(),this.checkStorage())}},{key:"handleWSStart",value:function(r){var o=r.client;this.hitTest(o)&&this.pathJoinRoom_.uint64_send_request_acc_ip_cmd_start_time===0&&(this.pathJoinRoom_.uint64_send_request_acc_ip_cmd_start_time=Date.now())}},{key:"handleWSEnd",value:function(r){var o=r.client,c=r.error;this.hitTest(o)&&this.pathJoinRoom_.uint64_send_request_acc_ip_cmd_end_time===0&&(this.pathJoinRoom_.uint64_send_request_acc_ip_cmd_end_time=Date.now(),c&&(this.pathJoinRoom_.int32_send_request_acc_ip_cmd_ret=c instanceof te?Number(c.getExtraCode()||c.getCode()):Z.UNKNOWN,this.pathJoinRoom_.int32_end_ret=2))}},{key:"handleJoinSendCMD",value:function(r){this.hitTest(r.client)&&this.pathJoinRoom_.uint64_send_request_enter_room_cmd_start_time===0&&(this.pathJoinRoom_.uint64_send_request_enter_room_cmd_start_time=Date.now())}},{key:"handleJoinReceivedCMDResponce",value:function(r){this.hitTest(r.client)&&this.pathJoinRoom_.uint64_send_request_enter_room_cmd_end_time===0&&(this.pathJoinRoom_.uint64_send_request_enter_room_cmd_end_time=Date.now(),this.pathJoinRoom_.int32_send_request_enter_room_cmd_ret=r.code,r.code!==0&&(this.pathJoinRoom_.int32_end_ret=3))}},{key:"handleJoinSuccess",value:function(r){this.hitTest(r.client)&&this.pathJoinRoom_.uint64_end_time===0&&(this.pathJoinRoom_.uint64_end_time=Date.now(),this.pathJoinRoom_.int32_end_ret=0)}},{key:"handleJoinFailed",value:function(r){var o=r.client;this.hitTest(o)&&(this.pathJoinRoom_.uint64_end_time=Date.now(),this.pathJoinRoom_.int32_end_ret===0&&(this.pathJoinRoom_.int32_end_ret=3),this.prepareReport(),this.report())}},{key:"handleReceivedPublishUserList",value:function(r){this.hitTest(r.client)&&this.pathJoinRoom_.uint64_recv_userlist_time===0&&(this.pathJoinRoom_.uint64_recv_userlist_time=Date.now(),this.firstPublishedUserList_=r.data.data&&r.data.data.userList||[])}},{key:"handleConnectionStateChanged",value:function(r){var o=r.client,c=r.state,a=r.connection;if(this.hitTest(o)&&c===sn){this.client_.getUplinkConnection()===a&&this.pathJoinRoom_.uint64_send_first_video_frame_time===0&&this.localStreamStats_.publishStartTime>this.pathJoinRoom_.uint64_end_time&&this.localStreamStats_.publishStartTime-this.pathJoinRoom_.uint64_end_time<=100&&(this.pathJoinRoom_.uint64_send_first_video_frame_time=Date.now());var s=this.pathMainVideoMap_.get("".concat(a.getUserId(),"_").concat(yt));s&&s.statsToReport.uint64_pc_connected_time===0&&(s.statsToReport.uint64_pc_connected_time=Date.now())}}},{key:"handleLeaveStart",value:function(r){this.hitTest(r.client)&&(this.pathLeaveRoom_.uint64_start_time=Date.now())}},{key:"handleLeaveSuccess",value:function(r){this.hitTest(r.client)&&this.pathLeaveRoom_.uint64_end_time===0&&(this.pathLeaveRoom_.uint64_end_time=Date.now(),this.pathJoinRoom_.uint64_end_time!==0?this.basicInfo.uint32_joining_duration=this.pathLeaveRoom_.uint64_end_time-this.pathJoinRoom_.uint64_end_time:this.log_.warn("pathJoinRoom endTime is 0"),this.report())}},{key:"handleLeaveSendCMD",value:function(r){this.hitTest(r.client)&&(this.pathLeaveRoom_.uint64_send_request_exit_room_cmd_start_time=Date.now(),this.pathLeaveRoom_.uint64_send_request_exit_room_cmd_end_time=Date.now())}},{key:"handleRemoteStreamAdded",value:function(r){var o=r.client,c=r.stream;if(this.hitTest(o)){var a=c.getUserId(),s=c.getType(),l="".concat(a,"_").concat(s),u=this.remoteStreamStatsMap_.get(l);if(u)u.stream=c;else{var f={userId:a,totalVideoFPS:0,totalVideoBitrate:0,totalAudioLevel:0,totalAudioBitrate:0,totalLoss:0,audioCount:0,audioLevelCount:0,videoCount:0,networkQualityCount:0,streamAddedTime:Date.now(),subscribeStartTime:0,subscribedTime:0,playStreamTime:0,statsToReport:q({},SF),stream:c};f.statsToReport.msg_user_info=new Hv({userId:a,tinyId:c.getTinyId(),role:so}),f.statsToReport.uint32_stream_type=s===yt?2:7,this.remoteStreamStatsMap_.set(l,f)}}}},{key:"handleRemoteStreamSubscribeStart",value:function(r){var o=r.client,c=r.stream;if(this.hitTest(o)){var a=c.getUserId(),s=c.getType(),l="".concat(a,"_").concat(s),u=this.remoteStreamStatsMap_.get(l);u&&u.subscribeStartTime===0&&(u.subscribeStartTime=Date.now())}}},{key:"handleSendSubscribeCMD",value:function(r){if(this.hitTest(r.client)){var o=new Hv(r),c=Date.now(),a="".concat(r.userId,"_").concat(yt);r.trackState.video&&r.subscribeState.video&&!this.pathMainVideoMap_.has(a)&&this.pathMainVideoMap_.set(a,{statsToReport:{msg_user_info:o,uint64_start_enter_time:this.pathJoinRoom_.uint64_start_time,uint64_render_first_frame_time:0,uint64_combine_first_frame_time:0,uint64_pc_connected_time:0},userId:r.userId,sendSubscribeCMDTime:c}),r.trackState.audio&&r.subscribeState.audio&&!this.pathMainAudioMap_.has(a)&&this.pathMainAudioMap_.set(a,{statsToReport:{msg_user_info:o,uint64_start_enter_time:this.pathJoinRoom_.uint64_start_time,uint64_play_first_frame_time:0},userId:r.userId,sendSubscribeCMDTime:c});var s="".concat(r.userId,"_").concat(Dt);r.trackState.auxiliary&&r.subscribeState.auxiliary&&!this.pathAuxiliaryMap_.has(s)&&this.pathAuxiliaryMap_.set(s,{sendSubscribeCMDTime:c})}}},{key:"handleRemoteStreamSubscribed",value:function(r){var o=r.client,c=r.stream;if(this.hitTest(o)){var a=c.getUserId(),s=c.getType(),l="".concat(a,"_").concat(s),u=this.remoteStreamStatsMap_.get(l);u&&u.subscribedTime===0&&(u.subscribedTime=Date.now(),u.stream=c)}}},{key:"handleRemoteStreamRemoved",value:function(r){var o=r.client,c=r.stream;if(this.hitTest(o)){var a=c.getUserId(),s=c.getType(),l=this.remoteStreamStatsMap_.get("".concat(a,"_").concat(s));l&&(l.stream=null)}}},{key:"handlePlayStream",value:function(r){var o=r.stream;if(o.isRemote()&&o.getConnection()&&this.hitTest(o.getConnection().getClient())){var c=o.getConnection().getUserId(),a="".concat(c,"_").concat(o.getType());if(this.remoteStreamStatsMap_.has(a)){var s=this.remoteStreamStatsMap_.get(a);s.playStreamTime===0&&(s.playStreamTime=Date.now())}}}},{key:"handleVideoLoadedData",value:function(r){var o=r.stream;if(o.isRemote()&&o.getConnection()&&this.hitTest(o.getConnection().getClient())){var c=o.getConnection().getUserId(),a="".concat(c,"_").concat(o.getType());if(this.pathMainVideoMap_.has(a)){var s=this.pathMainVideoMap_.get(a);s.statsToReport.uint64_combine_first_frame_time===0&&(s.statsToReport.uint64_combine_first_frame_time=Date.now())}}}},{key:"handleVideoPlaying",value:function(r){var o=r.stream;if(o.isRemote()&&o.getConnection()&&this.hitTest(o.getConnection().getClient())){var c=o.getConnection().getUserId(),a="".concat(c,"_").concat(o.getType()),s=Date.now();if(this.pathMainVideoMap_.has(a)){var l=this.pathMainVideoMap_.get(a);if(l.statsToReport.uint64_render_first_frame_time===0&&(l.statsToReport.uint64_render_first_frame_time=s),this.remoteStreamStatsMap_.has(a)){var u=this.remoteStreamStatsMap_.get(a),f=u.statsToReport,S=u.playStreamTime,x=u.subscribedTime;f.uint32_video_render_first===0&&S-x<=100&&(f.uint32_video_render_first=s-l.sendSubscribeCMDTime)}}if(o.getType()===Dt&&this.pathAuxiliaryMap_.has(a)&&this.remoteStreamStatsMap_.has(a)){var E=this.remoteStreamStatsMap_.get(a),I=E.statsToReport,m=E.playStreamTime,T=E.subscribedTime;I.uint32_video_render_first===0&&m-T<=100&&(I.uint32_video_render_first=s-this.pathAuxiliaryMap_.get(a).sendSubscribeCMDTime)}}}},{key:"handleAudioPlaying",value:function(r){if(r.stream.isRemote()&&r.stream.getConnection()&&this.hitTest(r.stream.getConnection().getClient())){var o=r.stream.getConnection().getUserId(),c="".concat(o,"_").concat(r.stream.getType());if(this.pathMainAudioMap_.has(c)){var a=this.pathMainAudioMap_.get(c);a.statsToReport.uint64_play_first_frame_time===0&&(a.statsToReport.uint64_play_first_frame_time=Date.now())}}}},{key:"handleNetworkQuality",value:function(r){var o=this;this.hitTest(r.client)&&(this.networkQuality_.totalUplinkLoss+=r.uplinkLoss,this.networkQuality_.totalUplinkRTT+=r.uplinkRTT,this.networkQuality_.count++,r.downlinkLossAndRTTMap.forEach(function(c){var a=c.rtt,s=c.loss,l=c.userId,u=o.networkQuality_.totalDownlinkRTTAndLossMap.get(l);u?(u.totalRTT+=a,u.totalLoss+=s,u.count++):o.networkQuality_.totalDownlinkRTTAndLossMap.set(l,{totalRTT:a,totalLoss:s,count:1})}))}},{key:"handleHeartbeatStats",value:function(r){var o=this;if(this.hitTest(r.client)){var c=r.stats,a=c.msg_up_stream_info,s=c.msg_down_stream_info;if(a.msg_video_status[0]){var l=a.msg_video_status[0],u=l.uint32_video_codec_bitrate,f=l.uint32_video_enc_fps,S=l.uint32_video_width,x=l.uint32_video_height;this.localStreamStats_.totalVideoBitrate+=u,this.localStreamStats_.totalVideoFPS+=f,this.localStreamStats_.totalVideoWidth+=S,this.localStreamStats_.totalVideoHeight+=x,this.localStreamStats_.videoCount++}if(a.msg_audio_status){var E=a.msg_audio_status.audioLevel;Math.floor(100*E)>0&&(this.localStreamStats_.totalAudioLevel+=E,this.localStreamStats_.audioLevelCount++)}s.forEach(function(I){var m=I.msg_user_info,T=I.msg_audio_status,v=I.msg_video_status,w=m.str_identifier;if(v.forEach(function(_){var b=_.uint32_video_stream_type===2,R=_.uint32_video_stream_type===7,P="".concat(w,"_").concat(b?yt:Dt);if(o.remoteStreamStatsMap_.has(P)){var U,k,h=o.remoteStreamStatsMap_.get(P);(b&&(U=h.stream)!==null&&U!==void 0&&U.isMainVideoSubscribed||R&&(k=h.stream)!==null&&k!==void 0&&k.isAuxVideoSubscribed)&&(h.totalVideoFPS+=_.uint32_video_receive_fps,h.totalVideoBitrate+=_.uint32_video_codec_bitrate,h.videoCount++,h.statsToReport.uint32_video_width===0&&(h.statsToReport.uint32_video_width=_.uint32_video_width),h.statsToReport.uint32_video_height===0&&(h.statsToReport.uint32_video_height=_.uint32_video_height))}}),T){var L="".concat(w,"_").concat(yt);if(o.remoteStreamStatsMap_.has(L)){var N,V=o.remoteStreamStatsMap_.get(L);(N=V.stream)!==null&&N!==void 0&&N.isMainAudioSubscribed&&(V.totalAudioBitrate+=T.uint32_audio_codec_bitrate,V.audioCount++,Math.floor(100*T.audioLevel)>0&&(V.totalAudioLevel+=T.audioLevel,V.audioLevelCount++))}}})}}},{key:"handlePublishStart",value:function(r){var o=r.client;this.hitTest(o)&&this.localStreamStats_.publishStartTime===0&&(this.localStreamStats_.publishStartTime=Date.now())}},{key:"handleLocalStreamInitStart",value:function(r){var o=r.audio,c=r.video;o&&this.pathJoinRoom_.uint64_init_audio_start_time===0&&(this.pathJoinRoom_.uint64_init_audio_start_time=Date.now()),c&&this.pathJoinRoom_.uint64_init_camera_start_time===0&&(this.pathJoinRoom_.uint64_init_camera_start_time=Date.now())}},{key:"handleLocalStreamInitEnd",value:function(r){var o=r.audio,c=r.video;o&&this.pathJoinRoom_.uint64_init_audio_end_time===0&&(this.pathJoinRoom_.uint64_init_audio_end_time=Date.now()),c&&this.pathJoinRoom_.uint64_init_camera_end_time===0&&(this.pathJoinRoom_.uint64_init_camera_end_time=Date.now())}},{key:"handleLocalStreamInitFailed",value:function(r){var o=r.audio,c=r.video,a=r.error,s=a instanceof te?a.getExtraCode()||a.getCode():{NotFoundError:1,NotAllowedError:2,NotReadableError:3,OverConstrainedError:4,AbortError:5}[a.name]||Z.UNKNOWN;o&&this.pathJoinRoom_.uint64_init_audio_end_time===0&&(this.pathJoinRoom_.int32_init_audio_ret=s,this.pathJoinRoom_.uint64_init_audio_end_time=Date.now()),c&&this.pathJoinRoom_.uint64_init_camera_end_time===0&&(this.pathJoinRoom_.int32_init_camera_ret=s,this.pathJoinRoom_.uint64_init_camera_end_time=Date.now())}},{key:"hasVideoFlag",value:function(r){return this.firstPublishedUserList_.findIndex(function(o){return o.userId===r&&1&o.flag})>=0}},{key:"hasAudioFlag",value:function(r){return this.firstPublishedUserList_.findIndex(function(o){return o.userId===r&&8&o.flag})>=0}},{key:"hasAuxFlag",value:function(r){return this.firstPublishedUserList_.findIndex(function(o){return o.userId===r&&4&o.flag})>=0}},{key:"hitTest",value:function(r){return r===this.client_}},{key:"checkStorage",value:(i=H(p().mark(function r(){var o;return p().wrap(function(c){for(;;)switch(c.prev=c.next){case 0:if(c.prev=0,!(o=bo.getItem(this.storageKey_))){c.next=6;break}return c.next=5,this.upload(o);case 5:bo.deleteItem(this.storageKey_);case 6:c.next=11;break;case 8:c.prev=8,c.t0=c.catch(0),this.log_.warn(c.t0);case 11:case"end":return c.stop()}},r,this,[[0,8]])})),function(){return i.apply(this,arguments)})},{key:"setStorage",value:function(){this.prepareReport();var r=this.getReportData();r.msg_path_enter_room.uint64_start_time!==0&&bo.setItem(this.storageKey_,r)}},{key:"prepareReport",value:function(){var r=this;if(this.networkQuality_.count>0&&(this.basicInfo.uint32_avg_rtt=Math.floor(this.networkQuality_.totalUplinkRTT/this.networkQuality_.count),this.basicInfo.uint32_avg_up_loss=Math.floor(this.networkQuality_.totalUplinkLoss/this.networkQuality_.count)),this.localStreamStats_.videoCount>0){this.localStreamStats_.statsToReport.uint32_video_big_capture_fps=Math.floor(this.localStreamStats_.totalVideoFPS/this.localStreamStats_.videoCount),this.localStreamStats_.statsToReport.uint32_video_big_bitrate=Math.floor(this.localStreamStats_.totalVideoBitrate/this.localStreamStats_.videoCount);var o=Math.floor(this.localStreamStats_.totalVideoWidth/this.localStreamStats_.videoCount),c=Math.floor(this.localStreamStats_.totalVideoHeight/this.localStreamStats_.videoCount);this.localStreamStats_.statsToReport.uint32_video_big_resolution=o<<16|c}this.localStreamStats_.audioLevelCount>0&&(this.localStreamStats_.statsToReport.uint32_audio_capture_db=Math.floor(this.localStreamStats_.totalAudioLevel/this.localStreamStats_.audioLevelCount*100)),this.remoteStreamStatsMap_.forEach(function(a,s){var l=a.userId;if(r.networkQuality_.totalDownlinkRTTAndLossMap.has(l)){var u=r.networkQuality_.totalDownlinkRTTAndLossMap.get(l),f=u.totalLoss,S=u.count;a.statsToReport.uint32_avg_down_loss=Math.floor(f/S)}a.videoCount>0&&(a.statsToReport.uint32_video_avg_fps=Math.floor(a.totalVideoFPS/a.videoCount),a.statsToReport.uint32_video_avg_bitrate=Math.floor(a.totalVideoBitrate/a.videoCount)),a.audioCount>0&&(a.statsToReport.uint32_audio_recv_bitrate=a.statsToReport.uint32_audio_bitrate=Math.floor(a.totalAudioBitrate/a.audioCount)),a.audioLevelCount>0&&(a.statsToReport.uint32_audio_play_db=Math.floor(a.totalAudioLevel/a.audioLevelCount*100));var x=r.client_.getCallDurationCalculator();x&&(a.statsToReport.uint32_audio_play_time=x.getDuration(s,Ee),a.statsToReport.uint32_video_play_time=x.getDuration(s,xe)),a.statsToReport.uint32_video_render_first=Math.min(a.statsToReport.uint32_video_render_first,ga);var E=r.client_.getBadCaseDetector();if(E){var I=E.getDataFreezeDuration(s),m=I.dataFreeze,T=I.count,v=E.getRenderFreezeDuration(s).renderFreeze;a.statsToReport.uint32_video_block_count=T,a.statsToReport.uint32_video_block_time=Math.min(m,a.statsToReport.uint32_video_play_time),a.statsToReport.uint32_video_external_block_time=Math.min(v,a.statsToReport.uint32_video_play_time),E.isBlackStream(s)&&a.statsToReport.uint32_video_avg_fps===0?a.statsToReport.uint32_video_black_screen_subjective=1:a.statsToReport.uint32_video_black_screen_subjective=0}(a.subscribeStartTime===0||a.subscribeStartTime-a.streamAddedTime>100||a.playStreamTime===0)&&(r.pathMainAudioMap_.delete(s),r.pathMainVideoMap_.delete(s),a.statsToReport.uint32_video_render_first=0)}),this.pathMainAudioMap_.forEach(function(a,s){r.hasAudioFlag(a.userId)?a.statsToReport.uint64_play_first_frame_time-a.statsToReport.uint64_start_enter_time>ga&&(a.statsToReport.uint64_play_first_frame_time=a.statsToReport.uint64_start_enter_time+ga):r.pathMainAudioMap_.delete(s)}),this.pathMainVideoMap_.forEach(function(a,s){r.hasVideoFlag(a.userId)?a.statsToReport.uint64_render_first_frame_time-a.statsToReport.uint64_start_enter_time>ga&&(a.statsToReport.uint64_render_first_frame_time=a.statsToReport.uint64_start_enter_time+ga):r.pathMainVideoMap_.delete(s)}),this.pathJoinRoom_.uint64_end_time-this.pathJoinRoom_.uint64_start_time>ga&&(this.pathJoinRoom_.uint64_end_time=this.pathJoinRoom_.uint64_start_time+ga)}},{key:"getReportData",value:function(){var r=this.client_.getSignalInfo();return{uint32_sdk_app_id:Number(this.client_.getSDKAppId()),msg_user_info:new Hv({userId:this.client_.getUserId(),tinyId:this.client_.getTinyId(),role:this.client_.getRole()===Tr?so:Vf}),msg_basic_info:this.basicInfo,uint32_acc_ip:Ip(r.relayIp),uint32_client_ip:Ip(r.clientIp,"small"),uint32_acc_port:0,uint64_timestamp:Date.now(),uint32_seq:Math.floor(Math.random()*Math.pow(2,31)),msg_path_enter_room:this.pathJoinRoom_,msg_path_exit_room:this.pathLeaveRoom_,msg_path_recv_video:Se(this.pathMainVideoMap_.values()).map(function(o){return o.statsToReport}),msg_quality_statistics:Se(this.remoteStreamStatsMap_.values()).map(function(o){return o.statsToReport}),str_room_name:String(this.client_.getRoomId()),msg_path_recv_audio:Se(this.pathMainAudioMap_.values()).map(function(o){return o.statsToReport}),uint32_info_client_ip:Ip(r.clientIp,"small"),error_code:[],msg_local_statistics:this.localStreamStats_.statsToReport,msg_function_state:Ri.getStateArray()}}},{key:"report",value:(n=H(p().mark(function r(){var o;return p().wrap(function(c){for(;;)switch(c.prev=c.next){case 0:return c.prev=0,o=this.getReportData(),c.next=4,this.upload(o);case 4:bo.deleteItem(this.storageKey_),Ri.clearStateArray(),this.initData(),c.next=12;break;case 9:c.prev=9,c.t0=c.catch(0),this.log_.warn(c.t0);case 12:case"end":return c.stop()}},r,this,[[0,9]])})),function(){return n.apply(this,arguments)})},{key:"upload",value:(t=H(p().mark(function r(o){var c,a,s;return p().wrap(function(l){for(;;)switch(l.prev=l.next){case 0:if(!(ra||o.msg_path_enter_room.uint64_start_time===0||[Qf,Qb,Yb].findIndex(function(u){return u===location.host})>=0)){l.next=2;break}return l.abrupt("return");case 2:return c=Number(this.client_.getSDKAppId()),a=ol(c,qM),l.next=6,cl({url:a,body:JSON.stringify(o)});case 6:if((s=l.sent).data==="ok"){l.next=9;break}throw"key point upload failed: ".concat(s.data);case 9:case"end":return l.stop()}},r,this)})),function(r){return t.apply(this,arguments)})}]),e}(),X(kc.prototype,"upload",[wx],Object.getOwnPropertyDescriptor(kc.prototype,"upload"),kc.prototype),kc),Ri=function(){function e(){Q(this,e)}return Ie(e,null,[{key:"handleFunctionState",value:function(t){var n,i,r,o,c=t.className,a=t.fnName,s=t.params;if(!(ra||[Qf,Qb,Yb].findIndex(function(S){return S===location.host})>=0)){var l,u=[];if(c)switch(a){case"createClient":(n=s[0])!==null&&n!==void 0&&n.mode&&u.push("".concat(c,".").concat(a,".").concat(s[0].mode)),(i=s[0])!==null&&i!==void 0&&i.useStringRoomId?u.push("".concat(c,".").concat(a,".stringRoomId")):u.push("".concat(c,".").concat(a,".intRoomId")),(r=s[0])!==null&&r!==void 0&&r.autoSubscribe?u.push("".concat(c,".").concat(a,".autoSubscribe")):u.push("".concat(c,".").concat(a,".manualSubscribe"));break;case"publish":(o=s[1])!==null&&o!==void 0&&o.isAuxiliary?u.push("".concat(c,".").concat(a,".isAuxiliary")):u.push("".concat(c,".").concat(a));break;case"setAudioProfile":case"setVideoProfile":case"setScreenProfile":case"setVideoContentHint":Bt(s[0])&&u.push("".concat(c,".").concat(a,".").concat(s[0]));break;default:u.push("".concat(c,".").concat(a))}else u.push(a);for(var f=0;f<u.length;f++){if(!(l=pN[u[f]]))return;this.stateMap.has(l)?this.stateMap.get(l).int32_call_times+=1:this.stateMap.set(l,{int32_id:l,int32_call_times:1})}}}},{key:"getStateArray",value:function(){return Array.from(this.stateMap.values())}},{key:"clearStateArray",value:function(){this.stateMap.clear()}}]),e}();function St(e){return function(t,n,i){var r=i.value;return i.value=function(){for(var o=arguments.length,c=new Array(o),a=0;a<o;a++)c[a]=arguments[a];try{e||(e=this.name_),Ri.handleFunctionState({className:e,fnName:n,params:c}),e=void 0}catch(s){this.log_.info(s)}return r.apply(this,c)},i}}$e(Ri,"stateMap",new Map);var Ax=(Cx=fn.apply(void 0,Se(Yt.STREAM.play)),Ex=St(),Rx=St(),cr=function(){function e(c){Q(this,e),this.name_=uN,this.userId_=c.userId,this.isRemote_=c.isRemote,this.type_=c.type,this.log_=_e.createLogger({id:"s".concat(c.seq?c.seq:"","|").concat(this.userId_),userId:ge(c.client)?void 0:c.client.getUserId(),sdkAppId:ge(c.client)?void 0:c.client.getSDKAppId(),isLocal:!this.isRemote_,type:this.isRemote_?this.type_:""}),this.client_=null,ge(c.client)||(this.client_=c.client),this.mediaStream_=null,this.div_=null,this.isPlaying_=!1,this.connection_=null,this.audioPlayer_=null,this.videoPlayer_=null,this.muted_=!1,this.objectFit_="cover",this.mirror_=!1,this.id_="xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(a){var s=16*Math.random()|0;return(a=="x"?s:3&s|8).toString(16)}),this.audioOutputDeviceId_=0,this.audioVolume_=1,this.emitter_=GS(new Si,this.name_),this.connectionState_=on,this.installEvents(),ge(c.mirror)||this.log_.warn('TRTC.createStream "mirror" option was deprecated since v4.12.1\uFF0Cplease use localStream.play to set up preview mirror. refer to '.concat(co,"/en/LocalStream.html#play. TRTC.createStream \u63A5\u53E3\u7684 mirror \u9009\u9879\u4ECE v4.12.1 \u5F00\u59CB\u88AB\u5E9F\u5F03\uFF0C\u8BF7\u4F7F\u7528 localStream.play \u8BBE\u7F6E\u672C\u5730\u6D41\u9884\u89C8\u955C\u50CF\uFF0C\u53C2\u8003\u6587\u6863\uFF1A").concat(co,"/zh-cn/LocalStream.html#play\u3002")),this.audioPlayerRetryCount_=3}var t,n,i,r,o;return Ie(e,[{key:"installEvents",value:function(){Y.on(rc,this.restartPlayback,this)}},{key:"uninstallEvents",value:function(){Y.off(rc,this.restartPlayback,this)}},{key:"getType",value:function(){return this.type_}},{key:"getLogger",value:function(){return this.log_}},{key:"isSubscribed",get:function(){return this.type_===yt&&this.connection_.isMainStreamSubscribed||this.type_===Dt&&this.connection_.isAuxStreamSubscribed}},{key:"isMainVideoSubscribed",get:function(){var c=this.getSubscribedState();return this.type_===yt&&c&&c.video}},{key:"isMainAudioSubscribed",get:function(){var c=this.getSubscribedState();return this.type_===yt&&c&&c.audio}},{key:"isAuxVideoSubscribed",get:function(){var c=this.getSubscribedState();return this.type_===Dt&&c&&c.auxiliary}},{key:"isSmallVideoSubscribed",get:function(){var c=this.getSubscribedState();return this.type_===yt&&c&&c.smallVideo}},{key:"emitConnectionStateChanged",value:function(c){c.state!==this.connectionState_&&(c.state!==on&&this.isRemote_&&!this.isSubscribed||(this.emitter_.emit(a6,c),this.connectionState_=c.state))}},{key:"setConnection",value:function(c){this.connection_!==c&&(c instanceof Bv?(this.connection_!==null&&this.connection_.off(et.CONNECTION_STATE_CHANGED,this.emitConnectionStateChanged,this),c.on(et.CONNECTION_STATE_CHANGED,this.emitConnectionStateChanged,this)):c===null&&this.connection_.off(et.CONNECTION_STATE_CHANGED,this.emitConnectionStateChanged,this),this.connection_=c)}},{key:"getConnection",value:function(){return this.connection_}},{key:"play",value:(o=H(p().mark(function c(a,s){var l,u,f;return p().wrap(function(S){for(;;)switch(S.prev=S.next){case 0:if(this.log_.info("stream ".concat(this.isPlaying_?"update":"start to"," play with elementId: ").concat(a," and options: ").concat(JSON.stringify(s),".")),!this.isPlaying_){S.next=9;break}return s&&!ge(s.muted)&&(this.muted_=s.muted),s&&!ge(s.objectFit)&&(this.objectFit_=s.objectFit),this.isScreenShare()?this.mirror_=!1:s&&!ge(s.mirror)&&(this.mirror_=s.mirror),this.audioPlayer_&&this.audioPlayer_.setMuted(this.muted_),this.videoPlayer_&&(this.videoPlayer_.setObjectFit(this.objectFit_),this.videoPlayer_.setMirror(this.mirror_)),this.elementId_!==a&&(l=a,Bt(a)&&(l=document.getElementById(a)),l.appendChild(this.div_),this.elementId_=a),S.abrupt("return");case 9:return this.isPlaying_=!0,(u=document.createElement("div")).setAttribute("id","player_".concat(this.id_)),u.setAttribute("style","width: 100%; height: 100%; position: relative; background-color: black; overflow: hidden;"),f=a,Bt(a)&&(f=document.getElementById(a)),f.appendChild(u),this.elementId_=a,this.div_=u,this.isRemote_||(this.muted_=!0),s&&!ge(s.muted)&&(this.muted_=s.muted),this.isScreenShare()&&(this.objectFit_="contain"),s&&!ge(s.objectFit)&&(this.objectFit_=s.objectFit),this.isScreenShare()?this.mirror_=!1:(this.isRemote_||(this.mirror_=!0),s&&!ge(s.mirror)&&(this.mirror_=s.mirror)),Y.emit(zp,{stream:this}),S.next=26,Promise.all([this.playAudio(),this.playVideo()]);case 26:Y.emit(L4,{stream:this});case 27:case"end":return S.stop()}},c,this)})),function(c,a){return o.apply(this,arguments)})},{key:"playAudio",value:(r=H(p().mark(function c(){var a,s,l=this;return p().wrap(function(u){for(;;)switch(u.prev=u.next){case 0:if(this.hasAudio()&&(!this.isRemote_||this.isMainAudioSubscribed)){u.next=2;break}return u.abrupt("return");case 2:if(a=this.getAudioTrack(),this.audioPlayer_||!a){u.next=18;break}return this.log_.info("create AudioPlayer and play"),this.audioPlayer_=new o5({stream:this,track:a,gainedTrack:(s=this.gain_)===null||s===void 0?void 0:s.audioTrack,div:this.div_,muted:this.muted_,outputDeviceId:this.audioOutputDeviceId_,volume:this.audioVolume_}),this.audioPlayer_.on(gn,function(f){var S={type:Ee,state:f.state,reason:f.reason};Y.emit(XS,q({stream:l},S)),l.emitter_.emit(Wk,S)}),this.audioPlayer_.on(Jk,function(f){l.audioPlayerRetryCount_>0&&(l.audioPlayerRetryCount_--,l.restartAudio())}),u.prev=8,u.next=11,this.audioPlayer_.play();case 11:u.next=18;break;case 13:throw u.prev=13,u.t0=u.catch(8),this.client_&&this.client_.getEnableAutoPlayDialog()&&new UT,this.emitter_.emit(wm,u.t0),u.t0;case 18:case"end":return u.stop()}},c,this,[[8,13]])})),function(){return r.apply(this,arguments)})},{key:"playVideo",value:(i=H(p().mark(function c(){var a,s=this;return p().wrap(function(l){for(;;)switch(l.prev=l.next){case 0:if(this.hasVideo()&&(!this.isRemote_||this.isMainVideoSubscribed||this.isAuxVideoSubscribed||this.isSmallVideoSubscribed)){l.next=2;break}return l.abrupt("return");case 2:if(a=this.getVideoTrack(),this.videoPlayer_||!a){l.next=18;break}return Y.emit(Jp,{stream:this}),this.log_.info("create VideoPlayer and play"),this.videoPlayer_=new VT({stream:this,track:a,div:this.div_,muted:this.muted_,objectFit:this.objectFit_,mirror:this.mirror_}),this.videoPlayer_.on(gn,function(u){var f={type:xe,state:u.state,reason:u.reason};Y.emit(XS,q({stream:s},f)),s.emitter_.emit(Wk,f)}),l.prev=8,l.next=11,this.videoPlayer_.play();case 11:l.next=18;break;case 13:throw l.prev=13,l.t0=l.catch(8),this.client_&&this.client_.getEnableAutoPlayDialog()&&new UT,this.emitter_.emit(wm,l.t0),l.t0;case 18:case"end":return l.stop()}},c,this,[[8,13]])})),function(){return i.apply(this,arguments)})},{key:"stopAudio",value:function(){this.audioPlayer_&&(this.log_.info("stop AudioPlayer"),this.audioPlayer_.stop(),this.audioPlayer_=null)}},{key:"stopVideo",value:function(){this.videoPlayer_&&(this.log_.info("stop VideoPlayer"),this.videoPlayer_.stop(),this.videoPlayer_=null)}},{key:"restartPlayback",value:function(){this.audioPlayer_&&!this.audioPlayer_.isPlaying&&this.restartAudio(),this.videoPlayer_&&!this.videoPlayer_.isPlaying&&this.restartVideo()}},{key:"restartAudio",value:function(){this.isPlaying_&&(this.stopAudio(),this.playAudio().catch(function(c){}))}},{key:"restartVideo",value:function(){this.isPlaying_&&(this.stopVideo(),this.playVideo().catch(function(c){}))}},{key:"stop",value:function(){this.isPlaying_&&(this.isPlaying_=!1,this.stopAudio(),this.stopVideo(),this.div_.parentNode.removeChild(this.div_))}},{key:"resume",value:(n=H(p().mark(function c(){return p().wrap(function(a){for(;;)switch(a.prev=a.next){case 0:if(this.isPlaying_){a.next=2;break}return a.abrupt("return");case 2:if(this.log_.info("resume"),!this.audioPlayer_){a.next=6;break}return a.next=6,this.audioPlayer_.resume();case 6:if(!this.videoPlayer_){a.next=9;break}return a.next=9,this.videoPlayer_.resume();case 9:case"end":return a.stop()}},c,this)})),function(){return n.apply(this,arguments)})},{key:"close",value:function(){this.log_.info("close stream"),this.isPlaying_&&this.stop(),this.isRemote_||(this.mediaStream_&&(this.mediaStream_.preventEvent=1,this.mediaStream_.getTracks().forEach(function(c){c.stop()}),this.mediaStream_=null),this.uninstallEvents())}},{key:"muteAudio",value:function(){return this.addRemoteEvent(!0,Ee),this.doEnableTrack(Ee,!1)}},{key:"muteVideo",value:function(){return this.addRemoteEvent(!0,xe),this.doEnableTrack(xe,!1)}},{key:"unmuteAudio",value:function(){return this.addRemoteEvent(!1,Ee),this.doEnableTrack(Ee,!0)}},{key:"unmuteVideo",value:function(){return this.addRemoteEvent(!1,xe),this.doEnableTrack(xe,!0)}},{key:"addRemoteEvent",value:function(c,a){if(this.isRemote_&&this.client_){var s=this.client_.getUserId(),l="".concat(c?tn:Sr," remote ").concat(a);vn(s,{eventId:a===Ee?c?tV:rV:c?eV:nV,eventDesc:l,timestamp:new Date().getTime(),userId:s,tinyId:this.client_.getTinyId(),remoteUserId:this.userId_,remoteTinyId:this.connection_.getTinyId()})}}},{key:"doEnableTrack",value:function(c,a){var s=!1;return c===Ee?this.mediaStream_.getAudioTracks().forEach(function(l){s=!0,l.enabled=a}):this.mediaStream_.getVideoTracks().forEach(function(l){s=!0,l.enabled=a}),s}},{key:"getId",value:function(){return this.id_}},{key:"getUserId",value:function(){return this.userId_}},{key:"getTinyId",value:function(){return this.connection_?this.connection_.getTinyId():""}},{key:"isPlaying",value:function(){return this.isPlaying_}},{key:"setAudioOutput",value:(t=H(p().mark(function c(a){var s;return p().wrap(function(l){for(;;)switch(l.prev=l.next){case 0:if(this.log_.info("setAudioOutput ".concat(a)),this.audioOutputDeviceId_=a,!this.audioPlayer_){l.next=5;break}return l.next=5,this.audioPlayer_.setSinkId(a);case 5:return l.next=7,Qk();case 7:s=l.sent,this.log_.info("speakers: ".concat(JSON.stringify(s)));case 9:case"end":return l.stop()}},c,this)})),function(c){return t.apply(this,arguments)})},{key:"setAudioVolume",value:function(c){this.audioVolume_=c,this.log_.info("setAudioVolume to ".concat(c)),this.audioPlayer_&&this.audioPlayer_.setVolume(c)}},{key:"getAudioLevel",value:function(){var c=0;return this.audioPlayer_&&(c=this.audioPlayer_.getAudioLevel()),c}},{key:"getInternalAudioLevel",value:function(){var c=0;return this.audioPlayer_&&(c=this.audioPlayer_.getInternalAudioLevel()),c}},{key:"hasAudio",value:function(){if(this.isRemote_){if(!this.connection_)return!1;var c=this.connection_.getTrackState();return this.type_===yt&&c.audio}return!!this.getAudioTrack()}},{key:"hasVideo",value:function(){if(this.isRemote_){if(!this.connection_)return!1;var c=this.connection_.getTrackState();return this.type_===Dt?c.auxiliary:c.video}return!!this.getVideoTrack()}},{key:"getSubscribedState",value:function(){return this.isRemote_&&this.connection_?this.connection_.getSubscribeState():null}},{key:"getAudioTrack",value:function(){var c=null;if(this.mediaStream_){var a=this.mediaStream_.getAudioTracks();a.length>0&&(c=a[0])}return c}},{key:"getVideoTrack",value:function(){var c=null;if(this.mediaStream_){var a=this.mediaStream_.getVideoTracks();a.length>0&&(c=a[0])}return c}},{key:"getVideoFrame",value:function(){return this.videoPlayer_?this.videoPlayer_.getVideoFrame():null}},{key:"getMediaStream",value:function(){return this.mediaStream_}},{key:"setMediaStream",value:function(c){c!==this.mediaStream_&&(this.mediaStream_&&this.mediaStream_.getTracks().forEach(function(a){return a.stop()}),this.mediaStream_=c)}},{key:"updateVideoPlayingState",value:function(c){if(this.isPlaying_)if(c){if(this.log_.info("playing state updated, play video"),this.videoPlayer_&&this.videoPlayer_.getTrack()!==this.getVideoTrack())return this.log_.warn("audio track changed, restart playback"),this.restartVideo();this.playVideo().catch(function(a){})}else this.log_.info("playing state updated, stop video"),this.stopVideo()}},{key:"updateAudioPlayingState",value:function(c){if(this.isPlaying_)if(c){if(this.log_.info("playing state updated, play audio"),this.audioPlayer_&&this.audioPlayer_.getTrack()!==this.getAudioTrack())return this.log_.warn("audio track changed, restart playback"),this.restartAudio();this.playAudio().catch(function(a){})}else this.log_.info("playing state updated, stop audio"),this.stopAudio()}},{key:"on",value:function(c,a,s){this.emitter_.on(c,a,s)}},{key:"off",value:function(c,a,s){c==="*"?this.emitter_.removeAllListeners():this.emitter_.off(c,a,s)}},{key:"isRemote",value:function(){return this.isRemote_}},{key:"isScreenShare",value:function(){return!this.isRemote_&&this.screen_||this.isRemote_&&this.getType()===gt}},{key:"getDiv",value:function(){return this.div_}},{key:"getObjectFit",value:function(){return this.objectFit_}},{key:"getMuted",value:function(){return this.muted_}},{key:"getClient",value:function(){return this.client_}}]),e}(),X(cr.prototype,"play",[Cx],Object.getOwnPropertyDescriptor(cr.prototype,"play"),cr.prototype),X(cr.prototype,"setAudioOutput",[Ex],Object.getOwnPropertyDescriptor(cr.prototype,"setAudioOutput"),cr.prototype),X(cr.prototype,"getVideoFrame",[Rx],Object.getOwnPropertyDescriptor(cr.prototype,"getVideoFrame"),cr.prototype),cr),Gv=function(e){Et(n,e);var t=Rr(n);function n(i){var r;Q(this,n);var o={isRemote:!0,type:i.type},c=q(q({},i),o);return(r=t.call(this,c)).name_=Xf,r.isStreamAddedEventEmitted_=!1,r.isAbleToCallSubscription_=!0,r}return Ie(n,[{key:"installEvents",value:function(){le(Ye(n.prototype),"installEvents",this).call(this),Y.on(Ur,this.handleStreamSubscribed,this),Y.on(Vr,this.handleStreamUnsubscribed,this)}},{key:"uninstallEvents",value:function(){le(Ye(n.prototype),"uninstallEvents",this).call(this),Y.off(Ur,this.handleStreamSubscribed,this),Y.off(Vr,this.handleStreamUnsubscribed,this)}},{key:"handleStreamSubscribed",value:function(i){i.client===this.client_&&i.stream===this&&this.connection_.getCurrentState()===sn&&this.emitConnectionStateChanged({prevState:on,state:sn})}},{key:"handleStreamUnsubscribed",value:function(i){i.client===this.client_&&i.stream===this&&this.emitConnectionStateChanged({prevState:sn,state:on})}},{key:"getType",value:function(){return le(Ye(n.prototype),"getType",this).call(this)}},{key:"getIsAbleToCallSubscription",value:function(){return this.isAbleToCallSubscription_}},{key:"setIsAbleToCallSubscription",value:function(i){this.isAbleToCallSubscription_=i}},{key:"setIsStreamAddedEventEmitted",value:function(i){this.isStreamAddedEventEmitted_=i}},{key:"getIsStreamAddedEventEmitted",value:function(){return this.isStreamAddedEventEmitted_}},{key:"getAudioTrack",value:function(){return this.connection_&&this.connection_.getTrackState().audio?le(Ye(n.prototype),"getAudioTrack",this).call(this):null}},{key:"getVideoTrack",value:function(){if(!this.connection_)return null;var i=this.connection_.getTrackState();return(this.type_!==yt||i.video)&&(this.type_!==Dt||i.auxiliary)?le(Ye(n.prototype),"getVideoTrack",this).call(this):null}},{key:"close",value:function(){le(Ye(n.prototype),"close",this).call(this)}}]),n}(Ax),TF=function(){function e(r){Q(this,e),this.client_=r.client,this.subscribedStreams_=new Map,this.unsubscribedStreams_=new Map,this.subscriptedOptions_=new Map,this.autoRecoveryFlags_=new Map}var t,n,i;return Ie(e,[{key:"isEnabled",get:function(){return this.client_.getEnv()!=="webrtc"}},{key:"recover",value:(i=H(p().mark(function r(o){var c,a,s;return p().wrap(function(l){for(;;)switch(l.prev=l.next){case 0:if(c=o.getUserId(),a=o.getType(),this.hasAutoRecoveryFlag(c,a)){l.next=5;break}return l.abrupt("return");case 5:if(s=this.getUnsubscribedStream(c,a)?"unsubscribe":"subscribe",l.prev=6,_e.warn("recover() try to recover subscription [".concat(s,"][").concat(c,"][").concat(a,"]")),s!=="subscribe"){l.next=13;break}return l.next=11,this.recoverSubscription(c,o);case 11:l.next=15;break;case 13:return l.next=15,this.recoverUnsubscription(c,o);case 15:ke.logSuccessEvent({userId:this.client_.getUserId(),eventType:Ub}),_e.warn("recover() recover successfully [".concat(s,"][").concat(c,"][").concat(a,"]")),l.next=23;break;case 19:l.prev=19,l.t0=l.catch(6),_e.error("recover() recover failed [".concat(s,"][").concat(c,"][").concat(a,"]"),l.t0),ke.logFailedEvent({userId:this.client_.getUserId(),eventType:Ub,error:l.t0});case 23:this.deleteAutoRecoveryFlag(c,a);case 24:case"end":return l.stop()}},r,this,[[6,19]])})),function(r){return i.apply(this,arguments)})},{key:"recoverSubscription",value:(n=H(p().mark(function r(o,c){var a,s,l,u,f;return p().wrap(function(S){for(;;)switch(S.prev=S.next){case 0:if(a=this.getOptions(o,c.getType()),s=this.getSubscribedStream(o,c.getType()),a&&s){S.next=4;break}return S.abrupt("return");case 4:l=this.getStreamMuteState(s),u=l.isAudioMuted,f=l.isVideoMuted,this.mergeStream(s,c),this.recoverPlayingState(s),u&&s.doEnableTrack(Ee,!1),f&&s.doEnableTrack(xe,!1);case 9:case"end":return S.stop()}},r,this)})),function(r,o){return n.apply(this,arguments)})},{key:"recoverUnsubscription",value:(t=H(p().mark(function r(o,c){var a;return p().wrap(function(s){for(;;)switch(s.prev=s.next){case 0:if(a=this.getUnsubscribedStream(o,c.getType())){s.next=3;break}return s.abrupt("return");case 3:this.mergeStream(a,c);case 4:case"end":return s.stop()}},r,this)})),function(r,o){return t.apply(this,arguments)})},{key:"getStreamMuteState",value:function(r){var o={isAudioMuted:!1,isVideoMuted:!1},c=r.getMediaStream();return c&&(o.isAudioMuted=c.getAudioTracks().map(function(a){return a.enabled}).includes(!1),o.isVideoMuted=c.getVideoTracks().map(function(a){return a.enabled}).includes(!1)),o}},{key:"recoverPlayingState",value:function(r){var o=r.isPlaying(),c=r.getDiv();if(o&&c){var a=c.parentNode;r.stop(),r.play(a,{objectFit:r.getObjectFit(),muted:r.getMuted()})}}},{key:"mergeStream",value:function(r,o){var c=o.getConnection(),a=o.getMediaStream();r.setConnection(c),c.setRemoteStream(a.id,r),r.setMediaStream(a),r.updateAudioPlayingState(o.hasAudio()),r.updateVideoPlayingState(o.hasVideo())}},{key:"addSubscriptionRecord",value:function(r,o,c){var a=o.getType();if(this.subscribedStreams_.has(r))this.subscribedStreams_.get(r).set(a,o);else{var s=new Map;s.set(o.getType(),o),this.subscribedStreams_.set(r,s)}if(this.subscriptedOptions_.has(r))this.subscriptedOptions_.get(r).set(a,c);else{var l=new Map;l.set(o.getType(),c),this.subscriptedOptions_.set(r,l)}this.deleteUnsubscriptionRecord(r,a)}},{key:"addUnsubscriptionRecord",value:function(r,o){if(this.unsubscribedStreams_.has(r))this.unsubscribedStreams_.get(r).set(o.getType(),o);else{var c=new Map;c.set(o.getType(),o),this.unsubscribedStreams_.set(r,c)}this.deleteSubscriptionRecord(r,o.getType())}},{key:"getSubscribedStream",value:function(r,o){return this.subscribedStreams_.has(r)&&this.subscribedStreams_.get(r).has(o)?this.subscribedStreams_.get(r).get(o):null}},{key:"getOptions",value:function(r,o){return this.subscriptedOptions_.has(r)&&this.subscriptedOptions_.get(r).has(o)?this.subscriptedOptions_.get(r).get(o):null}},{key:"getUnsubscribedStream",value:function(r,o){return this.unsubscribedStreams_.has(r)&&this.unsubscribedStreams_.get(r).has(o)?this.unsubscribedStreams_.get(r).get(o):null}},{key:"deleteSubscriptionRecord",value:function(r,o){this.subscribedStreams_.has(r)&&this.subscribedStreams_.get(r).delete(o),this.subscriptedOptions_.has(r)&&this.subscriptedOptions_.get(r).delete(o)}},{key:"deleteUnsubscriptionRecord",value:function(r,o){this.unsubscribedStreams_.has(r)&&this.unsubscribedStreams_.get(r).delete(o)}},{key:"markAllStream",value:function(){for(var r=0,o=Se(this.subscribedStreams_.entries());r<o.length;r++)for(var c=Te(o[r],2),a=c[0],s=0,l=Se(c[1].entries());s<l.length;s++){var u=Te(l[s],1)[0];this.setAutoRecoveryFlag(a,u)}for(var f=0,S=Se(this.unsubscribedStreams_.entries());f<S.length;f++)for(var x=Te(S[f],2),E=x[0],I=0,m=Se(x[1].entries());I<m.length;I++){var T=Te(m[I],1)[0];this.setAutoRecoveryFlag(E,T)}}},{key:"setAutoRecoveryFlag",value:function(r,o){if(_e.info("setAutoRecoveryFlag() mark [".concat(r,"][").concat(o,"]")),this.autoRecoveryFlags_.has(r))this.autoRecoveryFlags_.get(r).set(o);else{var c=new Map;c.set(o),this.autoRecoveryFlags_.set(r,c)}}},{key:"hasAutoRecoveryFlag",value:function(r,o){return!!this.isEnabled&&this.autoRecoveryFlags_.has(r)&&this.autoRecoveryFlags_.get(r).has(o)}},{key:"deleteAutoRecoveryFlag",value:function(r,o){this.autoRecoveryFlags_.has(r)&&this.autoRecoveryFlags_.get(r).delete(o)}},{key:"delete",value:function(r){this.unsubscribedStreams_.delete(r),this.subscribedStreams_.delete(r),this.subscriptedOptions_.delete(r),this.autoRecoveryFlags_.delete(r)}}]),e}(),xF=function(){function e(t){Q(this,e),this.player_=t,this.canvas_=document.createElement(hb),this.canvasCtx_=this.canvas_.getContext("2d")}return Ie(e,[{key:"setCanvasRect",value:function(t,n){this.canvas_.width=t,this.canvas_.height=n}},{key:"drawVideoToCanvas",value:function(){var t=this.player_.getElement(),n=t.videoHeight,i=t.videoWidth,r=i*this.canvas_.height/(n*this.canvas_.width);if(r>1.05||r<.95){var o=i*n/(this.canvas_.width*this.canvas_.height);this.setCanvasRect(i/Math.sqrt(o),n/Math.sqrt(o))}this.canvasCtx_.drawImage(t,0,0,this.canvas_.width,this.canvas_.height)}},{key:"generateVideoTrackFromCanvasCapture",value:function(t){return this.canvas_.captureStream(t).getVideoTracks()[0]}},{key:"generateStreamFromTrack",value:function(t){var n=new MediaStream;return n.addTrack(t),n}},{key:"destroy",value:function(){this.player_.stop(),this.canvas_.width=0,this.canvas_.height=0,this.canvas_=null,this.canvasCtx_=null}},{key:"canvas",get:function(){return this.canvas_}},{key:"canvasCtx",get:function(){return this.canvasCtx_}},{key:"canDrawVideoToCanvas",get:function(){if(this.player_){var t=this.player_.getElement();if(t)return t.readyState===t.HAVE_ENOUGH_DATA}return!1}}]),e}(),IF=new Blob(['let t,e,a,i;onmessage=function(n){const{action:h,data:s}=n.data;switch(h){case"render":a=s.canvas,t=a.width,e=a.height,i=a.getContext("2d"),function(t,e){const n=new TransformStream({async transform(t,e){const n=t.displayWidth,h=t.displayHeight,s=n*a.height/(h*a.width);if(s>1.05||s<.95){const t=n*h/(a.width*a.height);a.width=n/Math.sqrt(t),a.height=h/Math.sqrt(t)}i.drawImage(t,0,0,a.width,a.height);const o=new VideoFrame(a,{timestamp:t.timestamp});t.close(),e.enqueue(o)}});t.pipeThrough(n).pipeTo(e)}(s.readable,s.writable)}}'],{type:"application/javascript"}),wF=function(){function e(t){Q(this,e);var n=t.videoTrack;this.width=void 0,this.height=void 0,this.canvas=document.createElement("canvas"),this.offscreen=null,this.smallGenerator=new MediaStreamTrackGenerator({kind:"video"}),this.smallWritable=this.smallGenerator.writable,this.bigProcessor=new MediaStreamTrackProcessor({track:n}),this.bigReadable=this.bigProcessor.readable,this.initWorker()}return Ie(e,[{key:"initWorker",value:function(){try{this.worker=new Worker(URL.createObjectURL(IF)),_e.info("init worker processor success")}catch(t){_e.warn("init worker processor failed. ".concat(t.error))}}},{key:"setCanvasRect",value:function(t,n){this.width=t,this.height=n,this.canvas.width=t,this.canvas.height=n,this.offscreen=this.canvas.transferControlToOffscreen(),this.worker.postMessage({action:"render",data:{canvas:this.offscreen,readable:this.bigReadable,writable:this.smallWritable}},[this.offscreen,this.bigReadable,this.smallWritable])}},{key:"generatorVideoTrack",value:function(){var t=new MediaStream([this.smallGenerator]);return t==null?void 0:t.getTracks()[0]}},{key:"destroy",value:function(){this.worker.terminate()}}]),e}(),Yl=function(){function e(n){Q(this,e),this.localStream_=n,this.player_=null,this.processor_=null,this.initOffscreenSuccess_=!1}var t;return Ie(e,[{key:"initialize",value:(t=H(p().mark(function n(){var i;return p().wrap(function(r){for(;;)switch(r.prev=r.next){case 0:if(!(r6()&&((i=navigator)===null||i===void 0?void 0:i.hardwareConcurrency)>=6)){r.next=13;break}return r.prev=1,r.next=4,this.initOffscreen();case 4:this.initOffscreenSuccess_=!0,_e.info("Initialize VideoGenerator successfully!"),r.next=11;break;case 8:r.prev=8,r.t0=r.catch(1),this.initCanvas();case 11:r.next=14;break;case 13:this.initCanvas();case 14:case"end":return r.stop()}},n,this,[[1,8]])})),function(){return t.apply(this,arguments)})},{key:"generateSmallVideoTrack",value:function(n){var i,r=n.height,o=n.width,c=n.frameRate,a=this.getSmallVideoProfile(o,r);return this.initOffscreenSuccess_?(this.processor_.setCanvasRect(a.width,a.height),i=this.processor_.generatorVideoTrack()):(this.processor_.setCanvasRect(a.width,a.height),this.player_.setRect({width:a.width,height:a.height}),i=this.processor_.generateVideoTrackFromCanvasCapture(c),this.interval_=mt.run(Qu,this.render.bind(this),{fps:c})),i}},{key:"render",value:function(){this.processor_.canDrawVideoToCanvas&&this.processor_.drawVideoToCanvas()}},{key:"destroy",value:function(){mt.clearTask(this.interval_),this.processor_&&this.processor_.destroy()}},{key:"initOffscreen",value:function(){this.processor_=new wF({videoTrack:this.localStream_.getVideoTrack()})}},{key:"initCanvas",value:function(){this.player_=new VT({stream:this.localStream_,track:this.localStream_.getVideoTrack(),muted:!0,objectFit:"cover",mirror:!1}),this.player_.play().then(function(){_e.info("VideoGenerator: play local video success")}).catch(function(){_e.error("VideoGenerator: Failed to play local video")}),this.processor_=new xF(this.player_)}},{key:"getSmallVideoProfile",value:function(n,i){var r,o=this.localStream_.getVideoTrack(),c=this.localStream_.getVideoProfile();if(la){var a=o.getSettings();a&&a.width&&a.height&&(c.width=a.width,c.height=a.height)}var s=c.width*c.height,l=n*i;return _e.info("big stream resolution: ".concat(c.width,"*").concat(c.height," small stream resolution: ").concat(n,"*").concat(i," ")),r=s>l?s/l:s/19200,{width:parseInt(c.width/Math.sqrt(r)),height:parseInt(c.height/Math.sqrt(r))}}}]),e}(),$l=new Map,CF=function(){var e=H(p().mark(function t(n){var i,r,o,c,a,s,l;return p().wrap(function(u){for(;;)switch(u.prev=u.next){case 0:if(!gl()){u.next=2;break}return u.abrupt("return");case 2:return u.next=4,EF(n);case 4:if(i=u.sent,_e.info("getUserMedia with constraints: "+JSON.stringify(i)),!i.audio){u.next=11;break}return u.next=9,xt.getMicrophones();case 9:r=u.sent,_e.info("microphones: ".concat(fo(r,["deviceId","label"])));case 11:if(!i.video){u.next=16;break}return u.next=14,xt.getCameras();case 14:o=u.sent,_e.info("cameras: ".concat(fo(o,["deviceId","label"])));case 16:return u.prev=16,u.next=19,navigator.mediaDevices.getUserMedia(i);case 19:return u.abrupt("return",u.sent);case 22:if(u.prev=22,u.t0=u.catch(16),u.t0.name!=="NotFoundError"){u.next=29;break}if(!o||o.length!==0){u.next=27;break}throw new te({code:Z.DEVICE_NOT_FOUND,message:ae({key:J3})});case 27:if(!r||r.length!==0){u.next=29;break}throw new te({code:Z.DEVICE_NOT_FOUND,message:ae({key:W3})});case 29:throw i.audio&&((c=r)===null||c===void 0?void 0:c.length)>0&&(s=r.find(function(f){return f.deviceId===n.microphoneId}))&&s.getCapabilities&&_e.warn(fo(s.getCapabilities(),Zf)),i.video&&((a=o)===null||a===void 0?void 0:a.length)>0&&(l=o.find(function(f){return f.deviceId===n.cameraId}))&&l.getCapabilities&&_e.warn(fo(l.getCapabilities(),Zf)),new te({code:Z.INITIALIZE_FAILED,name:u.t0.name,message:u.t0.message,constraint:u.t0.constraint});case 32:case"end":return u.stop()}},t,null,[[16,22]])}));return function(t){return e.apply(this,arguments)}}(),zv=ic({retryFunction:CF,settings:{retries:3,timeout:500},onError:function(e,t,n,i,r){var o=r+1;_e.warn("getUserMedia error: ".concat(e)),e.name==="NotReadableError"||e.name==="OverconstrainedError"?(o===1&&i[0].video?(i[0].maxResoution=!1,i[0].frameRate=i[0].frameRate>10?10:5):o===2?i[0].useDeviceIdOnly=!0:o!==3||i[0].useExact&&!i[0].retryWhenExactFailed||(i[0].useTrueAsConstraint=!0),e.message.includes("deviceId")&&i[0].retryWhenExactFailed&&(i[0].useExact=!1),t()):n(e)},onRetrying:function(e){_e.warn("getUserMedia retrying [".concat(e,"/3]"))},onRetryFailed:function(){ke.uploadEvent({log:"stat-getUserMedia-retry-failed"})},onRetrySuccess:function(e){ke.uploadEvent({log:"stat-getUserMedia-retry-success-"+e})}});function EF(e){return{audio:RF(e),video:AF(e)}}function RF(e){if(!e.audio)return!1;if(e.useTrueAsConstraint)return!0;var t={};return!Br(e.microphoneId)&&(t.deviceId=e.useExact?{exact:e.microphoneId}:e.microphoneId,e.useDeviceIdOnly)?t:(t.echoCancellation=!0,t.noiseSuppression=!0,t.autoGainControl=!0,t.sampleRate=e.sampleRate,tr(e.channelCount)&&e.channelCount>1&&(t.channelCount=e.channelCount),nr(e.echoCancellation)&&!e.echoCancellation&&(t.echoCancellation=!1),nr(e.noiseSuppression)&&!e.noiseSuppression&&(t.noiseSuppression=!1),nr(e.autoGainControl)&&!e.autoGainControl&&(t.autoGainControl=!1),!!Br(t)||t)}function AF(e){if(!e.video)return!1;if(e.useTrueAsConstraint)return!0;var t=e.maxResoution,n=t===void 0||t,i={};return e.facingMode?i.facingMode=e.facingMode:e.cameraId&&(i.deviceId=e.useExact?{exact:e.cameraId}:e.cameraId),e.useDeviceIdOnly&&!Br(i)?i:(e.width&&(i.width={ideal:e.width},n&&!Vn&&(i.width.max=e.width)),e.height&&(i.height={ideal:e.height},n&&!Vn&&(i.height.max=e.height)),Vn&&ec&&e.width&&e.height&&e.width*e.height<101376&&(i.width=e.width,i.height=e.height),e.frameRate&&(i.frameRate=e.frameRate),!!Br(i)||i)}var PF=function(){var e=H(p().mark(function t(n){var i,r,o,c,a,s,l,u,f;return p().wrap(function(S){for(;;)switch(S.prev=S.next){case 0:if(!gl()){S.next=2;break}return S.abrupt("return");case 2:if(i=null,!(rl&&bp<74||na)){S.next=27;break}return r=Wv(n),_e.info("getDisplayMedia with constraints: "+JSON.stringify(r)),S.next=8,navigator.mediaDevices.getDisplayMedia(r);case 8:if(o=S.sent,!n.screenAudio){S.next=14;break}return _e.warn("Your browser not support capture system audio"),S.abrupt("return",o);case 14:if(!n.audio){S.next=24;break}return c=Px(n),_e.info("getUserMedia with constraints: "+JSON.stringify(c)),S.next=19,navigator.mediaDevices.getUserMedia(c);case 19:return i=S.sent,o.addTrack(i.getAudioTracks()[0]),S.abrupt("return",o);case 24:return S.abrupt("return",o);case 25:S.next=53;break;case 27:if(!n.screenAudio){S.next=37;break}return n.audioConstraints={echoCancellation:n.echoCancellation,autoGainControl:n.autoGainControl,noiseSuppression:n.noiseSuppression,sampleRate:44100},a=Wv(n),_e.info("getDisplayMedia with constraints: "+JSON.stringify(a)),S.next=33,navigator.mediaDevices.getDisplayMedia(a);case 33:return s=S.sent,S.abrupt("return",s);case 37:return l=Wv(n),_e.info("getDisplayMedia with constraints: "+JSON.stringify(l)),S.next=41,navigator.mediaDevices.getDisplayMedia(l);case 41:if(u=S.sent,!n.audio){S.next=52;break}return f=Px(n),_e.info("getUserMedia with constraints: "+JSON.stringify(f)),S.next=47,navigator.mediaDevices.getUserMedia(f);case 47:return i=S.sent,u.addTrack(i.getAudioTracks()[0]),S.abrupt("return",u);case 52:return S.abrupt("return",u);case 53:case"end":return S.stop()}},t)}));return function(t){return e.apply(this,arguments)}}();function Px(e){var t={echoCancellation:e.echoCancellation,autoGainControl:e.autoGainControl,noiseSuppression:e.noiseSuppression,sampleRate:e.sampleRate,channelCount:e.channelCount};return ge(e.microphoneId)||(t.deviceId=e.microphoneId),{audio:t,video:!1}}function Wv(e){var t={systemAudio:"include",selfBrowserSurface:"include",surfaceSwitching:"include"},n={width:na?{max:e.width}:{ideal:e.width,max:e.width},height:na?{max:e.height}:{ideal:e.height,max:e.height},frameRate:e.frameRate,displaySurface:"monitor"};return t.video=n,ge(e.audioConstraints)||(t.audio=e.audioConstraints),t}var Dx,Ox,Lx,Mx,Nx,Ux,Vx,jx,Bx,Fx,Hx,nt,Gx,Tc,Jv=new Map([["120p",{width:160,height:120,frameRate:15,bitrate:200}],["120p_2",{width:160,height:120,frameRate:15,bitrate:100}],["180p",{width:320,height:180,frameRate:15,bitrate:350}],["180p_2",{width:320,height:180,frameRate:15,bitrate:150}],["240p",{width:320,height:240,frameRate:15,bitrate:400}],["240p_2",{width:320,height:240,frameRate:15,bitrate:200}],["360p",{width:640,height:360,frameRate:15,bitrate:800}],["360p_2",{width:640,height:360,frameRate:15,bitrate:400}],["480p",{width:640,height:480,frameRate:15,bitrate:900}],["480p_2",{width:640,height:480,frameRate:15,bitrate:500}],["720p",{width:1280,height:720,frameRate:15,bitrate:1500}],["1080p",{width:1920,height:1080,frameRate:15,bitrate:2e3}],["1440p",{width:2560,height:1440,frameRate:30,bitrate:4860}],["4K",{width:3840,height:2160,frameRate:30,bitrate:9e3}]]),qv=new Map([["480p",{width:640,height:480,frameRate:5,bitrate:900}],["480p_2",{width:640,height:480,frameRate:30,bitrate:1e3}],["720p",{width:1280,height:720,frameRate:5,bitrate:1200}],["720p_2",{width:1280,height:720,frameRate:30,bitrate:3e3}],["1080p",{width:1920,height:1080,frameRate:5,bitrate:1600}],["1080p_2",{width:1920,height:1080,frameRate:30,bitrate:4e3}]]),zx=new Map([["standard",{sampleRate:48e3,channelCount:1,bitrate:40}],["standard-stereo",{sampleRate:48e3,channelCount:2,bitrate:64}],["high",{sampleRate:48e3,channelCount:1,bitrate:128}],["high-stereo",{sampleRate:48e3,channelCount:2,bitrate:192}]]),_a=new Map,DF=(Dx=St(mi),Ox=St(mi),Lx=St(mi),Mx=St(mi),Nx=fn.apply(void 0,Se(Yt.LOCAL_STREAM.switchDevice)),Ux=fn(Yt.STREAM.addTrack),Vx=fn(Yt.STREAM.removeTrack),jx=fn(Yt.STREAM.replaceTrack),Bx=Lo({retries:10,timeout:3e3,onRetryFailed:function(e){ke.logFailedEvent({userId:this.client_?this.client_.getUserId():this.userId_,eventType:Nb,error:e}),this.emitter_.emit(wm,new te({code:Z.DEVICE_AUTO_RECOVER_FAILED,message:e.message}))}}),Fx=Ql(Yt.LOCAL_STREAM.setAudioCaptureVolume),Hx=St(mi),nt=function(e){Et(I,e);var t,n,i,r,o,c,a,s,l,u,f,S,x,E=Rr(I);function I(m){var T;Q(this,I);var v=q(q({},m),{isRemote:!1,type:"local"});return(T=E.call(this,v)).name_=mi,T.client_=null,T.video_=m.video,T.audio_=m.audio,T.cameraId_=m.cameraId,T.cameraGroupId_="",T.facingMode_=m.facingMode,T.microphoneId_=m.microphoneId,T.microphoneGroupId_="",T.microphoneLabel_="",T.videoSource_=m.videoSource,T.audioSource_=m.audioSource,T.screen_=m.screen,T.screenAudio_=m.screenAudio,T.audioProfile_={echoCancellation:!0,autoGainControl:!0,noiseSuppression:!0,sampleRate:48e3,channelCount:1,bitrate:40},T.screenAudio_&&(T.audioProfile_.echoCancellation=!0,T.audioProfile_.autoGainControl=!1,T.audioProfile_.noiseSuppression=!1),nr(m.echoCancellation)&&(T.audioProfile_.echoCancellation=m.echoCancellation),nr(m.autoGainControl)&&(T.audioProfile_.autoGainControl=m.autoGainControl),nr(m.noiseSuppression)&&(T.audioProfile_.noiseSuppression=m.noiseSuppression),T.videoProfile_=Jv.get("480p_2"),T.screenProfile_=qv.get("1080p"),T.videoSetting_=null,T.muteState_={video:!1,audio:!1,auxVideo:!1},T.beautyStatus_=!1,T.prevAudioRecoverTime_=0,T.prevVideoRecoverTime_=0,T.isAudioRecovering_=!1,T.isVideoRecovering_=!1,T.initState(),T.canvas_=null,T.canvasInterval_=null,T.canvasTrack_=null,T.gain_={audioTrack:null,source:null,gainNode:null},T.captureVolume_=100,T.enableAutoRecoverCapture_=!!ge(m.enableAutoRecoverCapture)||m.enableAutoRecoverCapture,T.enableAutoRecoverOther_=!nr(m.enableAutoRecoverOther)||m.enableAutoRecoverOther,T.log_.info("stream created: ".concat(T.id_," autoRecover: ").concat(T.enableAutoRecoverCapture_)),T.isAIDenoiser=!1,T}return Ie(I,[{key:"scaleResolutionDownBy",get:function(){var m=this.getVideoTrack();if(!m||!la||this.isScreenShare())return 1;var T,v,w,L=m.getSettings();return L.width===this.videoProfile_.width&&L.height===this.videoProfile_.height?1:(T=window.screen)!==null&&T!==void 0&&(v=T.orientation)!==null&&v!==void 0&&(w=v.type)!==null&&w!==void 0&&w.includes("portrait")&&this.videoProfile_.width>this.videoProfile_.height&&L.height>L.width?Math.max(L.width/this.videoProfile_.height,L.height/this.videoProfile_.width,1):Math.max(L.width/this.videoProfile_.width,L.height/this.videoProfile_.height,1)}},{key:"initState",value:function(){this.isAddingTrack_=!1,this.isRemovingTrack_=!1,this.setIsReadyToPublish(!1),this.setPublishState(Wb)}},{key:"installEvents",value:function(){le(Ye(I.prototype),"installEvents",this).call(this),Y.on(qp,this.onVideoTrackStopped,this),Y.on(nc,this.onVideoTrackStopped,this),Y.on(Xp,this.onAudioTrackStopped,this),Y.on(Kp,this.onAudioTrackStopped,this)}},{key:"uninstallEvents",value:function(){le(Ye(I.prototype),"uninstallEvents",this).call(this),Y.off(qp,this.onVideoTrackStopped,this),Y.off(nc,this.onVideoTrackStopped,this),Y.off(Xp,this.onAudioTrackStopped,this),Y.off(Kp,this.onAudioTrackStopped,this)}},{key:"initialize",value:function(){var m=this;return new Promise(function(T,v){if(_l())v(new te({code:Z.INVALID_OPERATION,message:ae({key:mS})}));else{if(ge(m.audio_)){var w=new MediaStream;return ge(m.audioSource_)||(w.addTrack(m.audioSource_),m.updateAudioPlayingState(!0)),ge(m.videoSource_)||(w.addTrack(m.videoSource_),m.updateVideoPlayingState(!0)),m.setMediaStream(w),ke.logSuccessEvent({userId:m.client_?m.client_.getUserId():m.userId_,eventType:Qs,kind:"custom"}),m.setIsReadyToPublish(!0),T()}m.screen_?(m.log_.info("initialize stream audio: "+m.audio_+" screenAudio: "+m.screenAudio_+" screen: "+m.screen_),PF({audio:m.audio_,screenAudio:m.screenAudio_,microphoneId:m.microphoneId_,width:m.screenProfile_.width,height:m.screenProfile_.height,frameRate:m.screenProfile_.frameRate,sampleRate:m.audioProfile_.sampleRate,channelCount:m.audioProfile_.channelCount,autoGainControl:m.audioProfile_.autoGainControl,noiseSuppression:m.audioProfile_.noiseSuppression,echoCancellation:m.audioProfile_.echoCancellation}).then(function(L){m.setMediaStream(L),m.updateAudioPlayingState(m.audio_||m.screenAudio_),m.updateVideoPlayingState(!0);var N=m.getVideoTrack();return N.applyConstraints&&N.applyConstraints({frameRate:{min:m.screenProfile_.frameRate,ideal:m.screenProfile_.frameRate},width:m.screenProfile_.width,height:m.screenProfile_.height}).catch(function(V){m.warn("screen applyConstraints failed: ".concat(V))}),m.listenForScreenSharingStopped(N),m.setVideoContentHint(mb),m.updateDeviceIdInUse(),m.setIsReadyToPublish(!0),m.log_.info(JSON.stringify(N.getSettings())),ke.logSuccessEvent({userId:m.client_?m.client_.getUserId():m.userId_,eventType:Qs,kind:"getDisplayMedia"}),T()}).catch(function(L){ke.logFailedEvent({userId:m.client_?m.client_.getUserId():m.userId_,eventType:Qs,kind:"getDisplayMedia",error:L}),m.log_.error("getDisplayMedia error observed "+L),v(L instanceof te?L:new te({code:Z.INITIALIZE_FAILED,name:L.name,message:L.message}))})):(Y.emit(Bp,{stream:m,audio:m.audio_,video:m.video_}),m.log_.info("initialize stream audio: "+m.audio_+" video: "+m.video_),zv({audio:m.audio_,video:m.video_,facingMode:m.facingMode_,cameraId:m.cameraId_,microphoneId:m.microphoneId_,width:m.videoProfile_.width,height:m.videoProfile_.height,frameRate:m.videoProfile_.frameRate,sampleRate:m.audioProfile_.sampleRate,channelCount:m.audioProfile_.channelCount,autoGainControl:m.audioProfile_.autoGainControl,noiseSuppression:m.audioProfile_.noiseSuppression,echoCancellation:m.audioProfile_.echoCancellation,useExact:!0,retryWhenExactFailed:!0}).then(function(L){return Y.emit(Fp,{stream:m,audio:m.audio_,video:m.video_}),m.setMediaStream(L),L.getTracks().forEach(function(N){if(la){var V=N.getSettings();m.log_.debug("".concat(N.kind," settings: ").concat(JSON.stringify(V))),N.kind===xe&&(m.videoSetting_=V)}n6&&m.log_.info("".concat(N.kind," capabilities: ").concat(fo(N.getCapabilities(),Zf)))}),m.updateAudioPlayingState(m.audio_),m.updateVideoPlayingState(m.video_),m.updateDeviceIdInUse(),m.log_.info("gotStream hasAudio: "+m.hasAudio()+" hasVideo: "+m.hasVideo()),m.setIsReadyToPublish(!0),ke.logSuccessEvent({userId:m.client_?m.client_.getUserId():m.userId_,eventType:Qs,kind:"getUserMedia"}),T()}).catch(function(L){Y.emit(Hp,{stream:m,audio:m.audio_,video:m.video_,error:L}),ke.logFailedEvent({userId:m.client_?m.client_.getUserId():m.userId_,eventType:Qs,kind:"getUserMedia",error:L}),m.log_.error("getUserMedia error observed "+L),v(L)}))}})}},{key:"listenForScreenSharingStopped",value:function(m){var T=this;m.addEventListener("ended",function(v){T.log_.info("screen sharing was stopped because the video track is ended"),T.emitter_.emit(i6)})}},{key:"muteAudio",value:function(){var m=le(Ye(I.prototype),"muteAudio",this).call(this);return m&&(this.log_.info("localStream mute audio"),this.sendMutedFlag(Ee,!0)),m}},{key:"muteVideo",value:function(){var m=le(Ye(I.prototype),"muteVideo",this).call(this);return m&&(this.log_.info("localStream mute video"),this.sendMutedFlag(xe,!0)),m}},{key:"unmuteAudio",value:function(){var m=le(Ye(I.prototype),"unmuteAudio",this).call(this);return m&&(this.log_.info("localStream unmute audio"),this.sendMutedFlag(Ee,!1)),m}},{key:"unmuteVideo",value:function(){var m=le(Ye(I.prototype),"unmuteVideo",this).call(this);return m&&(this.log_.info("localStream unmute video"),this.sendMutedFlag(xe,!1)),m}},{key:"sendMutedFlag",value:function(m,T){this.setMuteState(m,T);var v=this.getConnection();if(v){v.sendMutedFlag(this.muteState_,this);var w=v.getUserId(),L=v.getTinyId(),N="".concat(T?tn:Sr," local ").concat(m," track");vn(w,{eventId:m===Ee?T?WU:qU:T?JU:KU,eventDesc:N,timestamp:an(),userId:w,tinyId:L})}}},{key:"setMuteState",value:function(m,T){this.muteState_[m]=T,this.log_.info("set ".concat(m," muted state: [").concat(T?"mute":"unmute","]"))}},{key:"setAudioProfile",value:(x=H(p().mark(function m(T){var v,w,L;return p().wrap(function(N){for(;;)switch(N.prev=N.next){case 0:if(G(T)==="object"?v=T:(v=zx.get(T))===void 0&&(v=zx.get("standard")),this.log_.info("setAudioProfile: "+JSON.stringify(v)),!(w=this.getAudioTrack())){N.next=6;break}return N.next=6,w.applyConstraints(v);case 6:if(L=this.audioProfile_.bitrate!==v.bitrate,this.audioProfile_=q(q({},this.audioProfile_),v),!L||!this.connection_){N.next=12;break}return N.next=11,this.connection_.setBandwidth({bandwidth:this.audioProfile_.bitrate,type:Ee});case 11:this.connection_.sendMediaSettings(this);case 12:case"end":return N.stop()}},m,this)})),function(m){return x.apply(this,arguments)})},{key:"setVideoProfile",value:(S=H(p().mark(function m(T){var v,w,L,N;return p().wrap(function(V){for(;;)switch(V.prev=V.next){case 0:if(!this.connection_||Hk()){V.next=2;break}throw new te({code:Z.NOT_SUPPORTED,message:ae({key:F3})});case 2:if(yi(T)?w=q(q({},this.videoProfile_),T):Bt(T)&&(w=Jv.get(T),ge(w)&&(w=Jv.get("480p_2"))),(v=this.client_)!==null&&v!==void 0&&v.get2k4kFlag()&&(this.client_.get2k4kFlag()!==1&&!this.screen_&&w.height*w.width>=3686400?(w.width=1920,w.height=1080,this.log_.warn(rS)):Ri.handleFunctionState({fnName:"2K_4K"})),w&&w.width*w.height>921600&&E4&&(w.width=1280,w.height=720,this.log_.warn("reset to 1280 * 720 on iOS 13~14")),this.log_.info("setVideoProfile "+JSON.stringify(w)),!(L=this.getVideoTrack())){V.next=10;break}return V.next=10,L.applyConstraints(w);case 10:if(N=this.videoProfile_.bitrate!==w.bitrate,this.videoProfile_=w,!N||!this.connection_){V.next=16;break}return V.next=15,this.connection_.setBandwidth({bandwidth:w.bitrate,type:xe,videoType:Bu});case 15:this.connection_.sendMediaSettings(this);case 16:case"end":return V.stop()}},m,this)})),function(m){return S.apply(this,arguments)})},{key:"getVideoBitrate",value:function(){return this.screen_?this.screenProfile_.bitrate:this.videoProfile_.bitrate}},{key:"getAudioBitrate",value:function(){return this.audioProfile_.bitrate}},{key:"setScreenProfile",value:function(m){var T=m;Bt(m)&&(T=qv.get(m)||qv.get("1080p")),this.log_.info("setScreenProfile "+JSON.stringify(m)),this.screenProfile_=T}},{key:"getVideoProfile",value:function(){return this.screen_?this.screenProfile_:this.videoProfile_}},{key:"getAudioProfile",value:function(){return this.audioProfile_}},{key:"setVideoContentHint",value:function(m){var T=this.getVideoTrack();T&&"contentHint"in T&&(this.log_.info("set video track contentHint to: "+m),T.contentHint=m,T.contentHint!==m&&this.log_.warn("Invalid video track contentHint: "+m))}},{key:"switchDevice",value:(f=H(p().mark(function m(T,v){var w,L,N,V,_,b,R,P,U,k,h,y,A,D,j,K,J,se;return p().wrap(function(ie){for(;;)switch(ie.prev=ie.next){case 0:if(this.mediaStream_&&this.cameraId_!==v&&this.facingMode_!==v){ie.next=2;break}return ie.abrupt("return");case 2:if(L=T===xe,!(w=T===Ee)||v!==this.microphoneId_){ie.next=11;break}if(v===Ku){ie.next=7;break}return ie.abrupt("return");case 7:return ie.next=9,h6(this.microphoneGroupId_,this.microphoneLabel_);case 9:if(!ie.sent){ie.next=11;break}return ie.abrupt("return");case 11:return this.setIsReadyToPublish(!1),this.log_.info("switchDevice "+T+" to: "+v),w&&(N=this.getAudioTrack(),V=this.getMicrophoneTrackMixed(),N&&N.stop(),V&&V.stop()),L&&((_=this.getVideoTrack())&&_.stop(),_p&&(b=this.getAudioTrack())&&(this.log_.info("stop audio track first in huawei env"),b.stop())),ie.prev=15,ie.next=18,zv({audio:w||_p,video:L,facingMode:v===fb||v===pb?v:void 0,cameraId:L?v:this.cameraId_,microphoneId:w?v:this.microphoneId_,width:this.videoProfile_.width,height:this.videoProfile_.height,frameRate:this.videoProfile_.frameRate,sampleRate:this.audioProfile_.sampleRate,channelCount:this.audioProfile_.channelCount,autoGainControl:this.audioProfile_.autoGainControl,noiseSuppression:this.audioProfile_.noiseSuppression,echoCancellation:this.audioProfile_.echoCancellation,useExact:!0,retryWhenExactFailed:!1});case 18:if(R=ie.sent,P=null,!w){ie.next=34;break}if(!(U=R.getAudioTracks()[0])||!this.isAudioTrackMixed()){ie.next=31;break}return k=this.getAudioTrack(),h=xt.AudioMixerPlugin.getAudioTrackMap(),ie.next=27,xt.AudioMixerPlugin.mix({targetTrack:U,sourceList:h.get(k.id).sourceList,trackList:h.get(k.id).trackList});case 27:y=ie.sent,P=y,ie.next=32;break;case 31:P=U;case 32:ie.next=43;break;case 34:if(!(P=R.getVideoTracks()[0])||!this.isVideoTrackBeautified()){ie.next=39;break}return ie.next=38,this.generateBeautyTrack(P);case 38:P=ie.sent;case 39:if(!(A=R.getAudioTracks()[0])||!_p){ie.next=43;break}return ie.next=43,this.replaceTrack(A);case 43:return ie.next=45,this.replaceTrack(P);case 45:(D=this.getConnection())&&(j=D.getUserId(),K=D.getTinyId(),J=QU,se="switch camera",w&&(J=YU,se="switch microphone"),vn(j,{eventId:J,eventDesc:se,timestamp:an(),userId:j,tinyId:K})),this.log_.info("switch ".concat(w?"microphone":"camera"," success ")),w&&(this.audio_=!0),L&&(this.video_=!0,this.facingMode_=v===pb||v===fb?v:""),this.updateDeviceIdInUse(),this.setIsReadyToPublish(!0),ie.next=59;break;case 54:throw ie.prev=54,ie.t0=ie.catch(15),this.log_.error(ie.t0),w?this.recoverCapture({audio:!0,video:!1,microphoneId:this.microphoneId_}):this.recoverCapture({audio:!1,video:!0,cameraId:this.cameraId_,facingMode:this.facingMode_}),ie.t0;case 59:case"end":return ie.stop()}},m,this,[[15,54]])})),function(m,T){return f.apply(this,arguments)})},{key:"addTrack",value:(u=H(p().mark(function m(T){var v,w,L;return p().wrap(function(N){for(;;)switch(N.prev=N.next){case 0:if(N.prev=0,T.kind===xe&&la&&(v=T.getSettings(),!this.videoSetting_||v.width===this.videoSetting_.width&&v.height===this.videoSetting_.height||this.log_.warn("video resolution of the track (".concat(v.width," x ").concat(v.height,") shall be kept the same as the previous: ").concat(this.videoSetting_.width," x ").concat(this.videoSetting_.height,". It may cause abnormal Cloud Recording."))),this.isAddingTrack_=!0,this.keepMuteState(T),this.mediaStream_.addTrack(T),!(w=this.getConnection())){N.next=11;break}return L=null,T.kind===xe&&(al||il)&&VS(T)&&(L=this.getCanvasTrack()),N.next=11,w.addTrack(L||T,this);case 11:T.kind===Ee?(this.audio_=!0,this.updateAudioPlayingState(!0),this.captureVolume_!==100&&this.setAudioCaptureVolume(this.captureVolume_)):(this.video_=!0,this.updateVideoPlayingState(!0)),this.isAddingTrack_=!1,N.next=20;break;case 15:throw N.prev=15,N.t0=N.catch(0),this.mediaStream_.removeTrack(T),this.isAddingTrack_=!1,N.t0;case 20:case"end":return N.stop()}},m,this,[[0,15]])})),function(m){return u.apply(this,arguments)})},{key:"removeTrack",value:(l=H(p().mark(function m(T){var v;return p().wrap(function(w){for(;;)switch(w.prev=w.next){case 0:if(w.prev=0,this.isRemovingTrack_=!0,!(v=this.getConnection())){w.next=17;break}if(T.kind!==xe||!al&&!il||!this.canvasTrack_){w.next=10;break}return w.next=7,v.removeTrack(this.canvasTrack_,this);case 7:this.clearCanvas(),w.next=17;break;case 10:if(T.kind!==Ee||!this.gain_.audioTrack){w.next=15;break}return w.next=13,v.removeTrack(this.gain_.audioTrack,this);case 13:w.next=17;break;case 15:return w.next=17,v.removeTrack(T,this);case 17:this.mediaStream_.removeTrack(T),T.kind===Ee?(this.audio_=!1,this.updateAudioPlayingState(!1),this.stopGainNode()):(this.video_=!1,this.updateVideoPlayingState(!1)),this.isRemovingTrack_=!1,w.next=26;break;case 22:throw w.prev=22,w.t0=w.catch(0),this.isRemovingTrack_=!1,w.t0;case 26:case"end":return w.stop()}},m,this,[[0,22]])})),function(m){return l.apply(this,arguments)})},{key:"replaceTrack",value:(s=H(p().mark(function m(T){var v,w,L;return p().wrap(function(N){for(;;)switch(N.prev=N.next){case 0:if(T.kind===xe&&la&&(v=T.getSettings(),!this.videoSetting_||v.width===this.videoSetting_.width&&v.height===this.videoSetting_.height||this.log_.warn("video resolution of the track (".concat(v.width," x ").concat(v.height,") shall be kept the same as the previous: ").concat(this.videoSetting_.width," x ").concat(this.videoSetting_.height,". It may cause abnormal Cloud Recording."))),this.keepMuteState(T),w=this.mediaStream_,T.kind!==Ee){N.next=12;break}if(w.removeTrack(w.getAudioTracks()[0]),w.addTrack(T),le(Ye(I.prototype),"restartAudio",this).call(this),!this.gain_.gainNode){N.next=10;break}return this.reconnectGainNode(T),N.abrupt("return");case 10:N.next=15;break;case 12:w.removeTrack(w.getVideoTracks()[0]),w.addTrack(T),le(Ye(I.prototype),"restartVideo",this).call(this);case 15:if(!(L=this.getConnection())){N.next=21;break}if(T.kind!==xe||!al&&!il||!this.canvasTrack_){N.next=19;break}return N.abrupt("return");case 19:return N.next=21,L.replaceTrack(T,this);case 21:case"end":return N.stop()}},m,this)})),function(m){return s.apply(this,arguments)})},{key:"recoverCapture",value:(a=H(p().mark(function m(T){var v,w,L,N,V,_,b,R,P,U,k,h,y,A,D,j,K;return p().wrap(function(J){for(;;)switch(J.prev=J.next){case 0:if(!(!this.mediaStream_||!this.enableAutoRecoverCapture_||T.audio&&!T.video&&this.isAudioRecovering_||T.video&&!T.audio&&this.isVideoRecovering_)){J.next=2;break}return J.abrupt("return");case 2:return T.audio&&(this.isAudioRecovering_=!0),T.video&&(this.isVideoRecovering_=!0),this.log_.warn("recoverCapture() trying "+JSON.stringify(T)),v=this.audio_&&T.audio,w=this.video_&&T.video,J.prev=7,J.next=10,xt.getCameras();case 10:return L=J.sent,J.next=13,xt.getMicrophones();case 13:if(N=J.sent,w&&L.length===0&&(w=!1,this.log_.warn("recoverCapture() video flag is true, but no camera detected, set video to false")),v&&N.length===0&&(v=!1,this.log_.warn("recoverCapture() audio flag is true, but no microphone detected, set audio to false")),v||w){J.next=21;break}return T.audio&&(this.isAudioRecovering_=!1),T.video&&(this.isVideoRecovering_=!1),this.log_.warn("recoverCapture() both audio and video are false, aborted"),J.abrupt("return");case 21:return V=T&&L.findIndex(function(se){return se.deviceId===T.cameraId})>=0,_=T&&N.findIndex(function(se){return se.deviceId===T.microphoneId})>=0,v&&((b=this.getAudioTrack())===null||b===void 0||b.stop()),w&&((R=this.getVideoTrack())===null||R===void 0||R.stop()),J.next=27,zv({audio:v,video:w,cameraId:V?T.cameraId:void 0,microphoneId:_?T.microphoneId:void 0,facingMode:this.facingMode_,width:this.videoProfile_.width,height:this.videoProfile_.height,frameRate:this.videoProfile_.frameRate,sampleRate:this.audioProfile_.sampleRate,channelCount:this.audioProfile_.channelCount,autoGainControl:this.audioProfile_.autoGainControl,noiseSuppression:this.audioProfile_.noiseSuppression,echoCancellation:this.audioProfile_.echoCancellation});case 27:P=J.sent,U=P.getTracks(),k=0;case 30:if(!(k<U.length)){J.next=59;break}if((h=U[k]).kind!==Ee||!this.isAudioTrackMixed()){J.next=45;break}if(y=this.getAudioTrack(),A=xt.AudioMixerPlugin.getAudioTrackMap(),(D=A.get(y.id)).hasMicrophone){J.next=39;break}return h.stop(),J.abrupt("continue",56);case 39:return J.next=41,xt.AudioMixerPlugin.mix({targetTrack:h,sourceList:D.sourceList,trackList:D.trackList});case 41:return j=J.sent,J.next=44,this.replaceTrack(j);case 44:return J.abrupt("continue",56);case 45:if(h.kind!==xe||!this.isVideoTrackBeautified()){J.next=52;break}return J.next=48,this.generateBeautyTrack(h);case 48:return K=J.sent,J.next=51,this.replaceTrack(K);case 51:return J.abrupt("continue",56);case 52:return J.next=54,this.replaceTrack(h);case 54:if(h.readyState!=="ended"){J.next=56;break}throw new Error("new track is failed, muted ".concat(h.muted," readyState ").concat(h.readyState));case 56:k++,J.next=30;break;case 59:this.updateDeviceIdInUse(),ke.logSuccessEvent({userId:this.client_?this.client_.getUserId():this.userId_,eventType:Nb}),T.audio&&(this.isAudioRecovering_=!1),T.video&&(this.isVideoRecovering_=!1),this.log_.warn("recoverCapture() successfully"),this.emitter_.emit(o6,{isCamera:T.video,isMicrophone:T.audio,cameraId:this.cameraId_,microphoneId:this.microphoneId_}),J.next=73;break;case 67:throw J.prev=67,J.t0=J.catch(7),T.audio&&(this.isAudioRecovering_=!1),T.video&&(this.isVideoRecovering_=!1),this.log_.warn("recoverCapture() failed, "+J.t0),J.t0;case 73:case"end":return J.stop()}},m,this,[[7,67]])})),function(m){return a.apply(this,arguments)})},{key:"updateDeviceIdInUse",value:function(){var m=this;if(!this.mediaStream_)return this.cameraId_="",this.cameraGroupId_="",this.microphoneId_="",void(this.microphoneGroupId_="");la&&this.mediaStream_.getTracks().forEach(function(w){if(w.kind===Ee&&m.isAudioTrackMixed()){var L=m.getMicrophoneTrackMixed();if(L){var N=L.getSettings(),V=N.deviceId,_=N.groupId;V&&(m.microphoneId_=V,m.microphoneGroupId_=_,m.microphoneLabel_=L.label)}}else if(w.kind===xe&&m.isVideoTrackBeautified()){var b=m.getBeautyOriginTrack();if(b){var R=b.getSettings(),P=R.deviceId,U=R.groupId,k=R.facingMode;P&&(m.cameraId_=P,m.cameraGroupId_=U),k&&(m.facingMode_=k)}}else{var h=w.getSettings(),y=h.deviceId,A=h.groupId,D=h.facingMode;y&&(w.kind===Ee?(m.microphoneId_=y,m.microphoneGroupId_=A,m.microphoneLabel_=w.label):w.kind!==xe||m.screen_||(m.cameraId_=y,m.cameraGroupId_=A,D&&(m.facingMode_=D)))}});var T=this.mediaStream_.getAudioTracks(),v=this.mediaStream_.getVideoTracks();T&&T.length===0&&(this.microphoneId_="",this.microphoneGroupId_=""),v&&v.length===0&&(this.cameraId_="",this.cameraGroupId_="")}},{key:"isAudioTrackMixed",value:function(){if(xt.AudioMixerPlugin){var m=xt.AudioMixerPlugin.getAudioTrackMap(),T=this.getAudioTrack();if(m&&T&&m.has(T.id))return!0}return!1}},{key:"getMicrophoneTrackMixed",value:function(){if(xt.AudioMixerPlugin){var m=xt.AudioMixerPlugin.getAudioTrackMap(),T=this.getAudioTrack();if(m&&T&&m.has(T.id)){var v=m.get(T.id);return v.hasMicrophone?v.microphoneTrack:null}}return null}},{key:"isVideoTrackBeautified",value:function(){if(xt.beautyTrackMap){var m=xt.beautyTrackMap,T=this.getVideoTrack();if(T&&m.has(T.id))return!0}return!1}},{key:"getBeautyOriginTrack",value:function(){if(xt.beautyTrackMap){var m=xt.beautyTrackMap,T=this.getVideoTrack();if(T&&m.has(T.id)){var v=m.get(T.id);if(v.originTrack)return v.originTrack}}return null}},{key:"generateBeautyTrack",value:(c=H(p().mark(function m(T){var v,w,L,N;return p().wrap(function(V){for(;;)switch(V.prev=V.next){case 0:if(v=null,w=this.getVideoTrack(),L=xt.beautyTrackMap.get(w.id),N=L.param,L.type){V.next=8;break}v=L.pluginInstance.generateBeautyTrack(T),V.next=22;break;case 8:V.t0=L.type,V.next=V.t0==="beauty"?11:V.t0==="virtual"?13:V.t0==="mixed"?17:21;break;case 11:return v=L.pluginInstance.generateBeautyTrack(T),V.abrupt("break",22);case 13:return V.next=15,L.pluginInstance.generateVirtualTrack({videoTrack:T,type:N.type,img:N.img});case 15:case 19:return v=V.sent,V.abrupt("break",22);case 17:return V.next=19,L.pluginInstance.generateMixedTrack({videoTrack:T,type:N.type,img:N.img});case 21:return V.abrupt("break",22);case 22:return L.pluginInstance.deleteSource(w.id),this.log_.info("regenerate beauty track, track id = ".concat(T.id)),V.abrupt("return",v);case 25:case"end":return V.stop()}},m,this)})),function(m){return c.apply(this,arguments)})},{key:"getScreen",value:function(){return this.screen_}},{key:"hasScreenTrack",value:function(){if(this.screen_)return!0;var m=this.getVideoTrack();return!!m&&(m.contentHint===mb||m.contentHint===NM)}},{key:"getVideo",value:function(){return this.video_}},{key:"getAudio",value:function(){return this.audio_}},{key:"getCameraId",value:function(){return this.cameraId_}},{key:"getMicrophoneId",value:function(){return this.microphoneId_}},{key:"getMicrophoneGroupId",value:function(){return this.microphoneGroupId_}},{key:"getIsReadyToPublish",value:function(){return this.isReadyToPublish_}},{key:"setIsReadyToPublish",value:function(m){this.isReadyToPublish_=m}},{key:"setPublishState",value:function(m){this.publishState_=m}},{key:"setBeautyStatus",value:function(m){this.beautyStatus_=!!m}},{key:"getBeautyStatus",value:function(){return this.beautyStatus_}},{key:"syncMuteState",value:function(){var m=this.getAudioTrack(),T=this.getVideoTrack();if(m){var v=!m.enabled;this.setMuteState(Ee,v)}if(T){var w=!T.enabled;this.setMuteState(xe,w)}this.connection_&&this.connection_.sendMutedFlag(this.muteState_,this)}},{key:"keepMuteState",value:function(m){m instanceof window.MediaStreamTrack&&this.muteState_[m.kind]&&(m.enabled=!1,this.log_.warn("prev ".concat(m.kind," track is muted, keep mute state")))}},{key:"onVideoTrackStopped",value:(o=H(p().mark(function m(T){var v,w,L=this;return p().wrap(function(N){for(;;)switch(N.prev=N.next){case 0:if(v=T.stream,w=T.type,v===this&&this.video_&&this.cameraId_&&d6(this.getVideoTrack())&&!this.isVideoRecovering_&&(w!==tn||!ec||!na)){N.next=3;break}return N.abrupt("return");case 3:if(!(Date.now()-this.prevVideoRecoverTime_<Xu)){N.next=6;break}return setTimeout(function(){return L.onVideoTrackStopped({stream:v,type:w})},Xu),N.abrupt("return");case 6:w===tn?setTimeout(function(){var V=L.getVideoTrack();V!=null&&V.muted&&document.visibilityState==="visible"&&L.recoverVideoCapture(w)},5e3):this.recoverVideoCapture(w);case 7:case"end":return N.stop()}},m,this)})),function(m){return o.apply(this,arguments)})},{key:"onAudioTrackStopped",value:(r=H(p().mark(function m(T){var v,w,L=this;return p().wrap(function(N){for(;;)switch(N.prev=N.next){case 0:if(v=T.stream,w=T.type,!(v!==this||!this.audio_||!this.microphoneId_||this.isAudioRecovering_||w===tn&&ec&&na)){N.next=3;break}return N.abrupt("return");case 3:if(!(Date.now()-this.prevAudioRecoverTime_<Xu)){N.next=6;break}return setTimeout(function(){return L.onAudioTrackStopped({stream:v,type:w})},Xu),N.abrupt("return");case 6:w===tn?setTimeout(function(){var V=L.getAudioTrack();V!=null&&V.muted&&document.visibilityState==="visible"&&L.recoverAudioCapture(w)},5e3):this.recoverAudioCapture(w);case 7:case"end":return N.stop()}},m,this)})),function(m){return r.apply(this,arguments)})},{key:"recoverAudioCapture",value:(i=H(p().mark(function m(T){return p().wrap(function(v){for(;;)switch(v.prev=v.next){case 0:return this.prevAudioRecoverTime_=Date.now(),ke.uploadEvent({log:"stat-local-audio-".concat(T),userId:this.userId_}),v.t0=this,v.next=5,this.getRecoverCaptureDeviceId(!1);case 5:v.t1=v.sent,v.t2={audio:!0,video:!1,microphoneId:v.t1},v.t0.recoverCapture.call(v.t0,v.t2);case 8:case"end":return v.stop()}},m,this)})),function(m){return i.apply(this,arguments)})},{key:"recoverVideoCapture",value:(n=H(p().mark(function m(T){return p().wrap(function(v){for(;;)switch(v.prev=v.next){case 0:return this.prevVideoRecoverTime_=Date.now(),ke.uploadEvent({log:"stat-local-video-".concat(T),userId:this.userId_}),v.t0=this,v.next=5,this.getRecoverCaptureDeviceId(!0);case 5:v.t1=v.sent,v.t2={audio:!1,video:!0,cameraId:v.t1},v.t0.recoverCapture.call(v.t0,v.t2);case 8:case"end":return v.stop()}},m,this)})),function(m){return n.apply(this,arguments)})},{key:"getRecoverCaptureDeviceId",value:(t=H(p().mark(function m(){var T,v,w,L,N=arguments;return p().wrap(function(V){for(;;)switch(V.prev=V.next){case 0:if(T=!(N.length>0&&N[0]!==void 0)||N[0],!(v=T?this.cameraId_:this.microphoneId_)||!this.enableAutoRecoverOther_){V.next=17;break}if(_a.has(v)?_a.set(v,_a.get(v)+1):_a.set(v,1),!((w=_a.get(v))>=3)){V.next=17;break}if(!T){V.next=12;break}return V.next=9,xt.getCameras();case 9:V.t0=V.sent.find(function(_){return!_a.has(_.deviceId)}),V.next=15;break;case 12:return V.next=14,xt.getMicrophones();case 14:V.t0=V.sent.find(function(_){return!_a.has(_.deviceId)});case 15:(L=V.t0)&&(this.log_.warn("".concat(T?"camera":"mic"," ").concat(v," capture fail ").concat(w," times, change new ").concat(L.deviceId)),v=L.deviceId);case 17:return V.abrupt("return",v);case 18:case"end":return V.stop()}},m,this)})),function(){return t.apply(this,arguments)})},{key:"setAudioVolume",value:function(m){le(Ye(I.prototype),"setAudioVolume",this).call(this,m)}},{key:"clearCanvas",value:function(){this.canvasInterval_&&(mt.clearTask(this.canvasInterval_),this.canvasInterval_=null,this.canvas_=null,this.canvasTrack_=null)}},{key:"getCanvasTrack",value:function(){var m=this;if(this.canvasTrack_)return this.canvasTrack_;this.log_.info("gen canvas track");var T=this.getVideoTrack().getSettings(),v=T.width,w=T.height,L=T.frameRate;this.canvas_=document.createElement("canvas");var N=this.canvas_.getContext("2d");this.canvas_.width=v,this.canvas_.height=w,this.canvasInterval_=mt.run(Qu,function(){if(m.hasVideo()){var _=m.getVideoTrack().getSettings();_.width===m.canvas_.width&&_.height===m.canvas_.height||(m.canvas_.width=_.width,m.canvas_.height=_.height)}m.videoPlayer_&&m.videoPlayer_.element_&&N.drawImage(m.videoPlayer_.element_,0,0,m.canvas_.width,m.canvas_.height)},{fps:Math.max(15,L)});var V=this.canvas_.captureStream();return this.canvasTrack_=V.getVideoTracks()[0],this.canvasTrack_}},{key:"setClient",value:function(m,T){m&&(this.log_.setUserId(m.getUserId()),this.log_.setSdkAppId(m.getSDKAppId()),T||this.syncMuteState()),this.client_=m}},{key:"setAudioCaptureVolume",value:function(){var m=this,T=arguments.length>0&&arguments[0]!==void 0?arguments[0]:100;if(!this.hasAudio()||T<0||!km())return!1;if(this.captureVolume_===T)return!0;this.captureVolume_=T,this.log_.info("setCaptureVolume "+T),T/=100;var v=HS();if(this.gain_.gainNode)this.gain_.gainNode.gain.value=T;else{var w,L=new MediaStream;L.addTrack(this.getAudioTrack());var N=v.createMediaStreamDestination(),V=v.createMediaStreamSource(L),_=v.createGain();_.gain.value=T,V.connect(_),_.connect(N);var b=N.stream.getAudioTracks()[0],R=function(P){return m.log_.info("gained audio track ".concat(P))};b.onmute=function(){return R("muted")},b.onunmute=function(){return R("unmuted")},b.onended=function(){return R("ended")},this.gain_={source:V,audioTrack:b,gainNode:_},(w=this.connection_)===null||w===void 0||w.replaceTrack(b),le(Ye(I.prototype),"restartAudio",this).call(this)}return!0}},{key:"getGainedTrack",value:function(){return this.gain_.audioTrack}},{key:"reconnectGainNode",value:function(m){this.log_.warn("reconnect gain node");var T=new MediaStream;T.addTrack(m);var v=HS().createMediaStreamSource(T);v.connect(this.gain_.gainNode),this.gain_.source.disconnect(),this.gain_.source=v}},{key:"stopGainNode",value:function(){var m=this.gain_,T=m.audioTrack,v=m.source,w=m.gainNode;w&&(v.disconnect(),w.disconnect(),T.onmute=null,T.onunmute=null,T.onended=null,T.stop(),this.gain_={source:null,gainNode:null,audioTrack:null}),this.captureVolume_=100}},{key:"close",value:function(){this.setIsReadyToPublish(!1),this.stopGainNode(),le(Ye(I.prototype),"close",this).call(this)}},{key:"setIsAIDenoiser",value:function(m){this.isAIDenoiser=m}}]),I}(Ax),X(nt.prototype,"setAudioProfile",[Dx],Object.getOwnPropertyDescriptor(nt.prototype,"setAudioProfile"),nt.prototype),X(nt.prototype,"setVideoProfile",[Ox],Object.getOwnPropertyDescriptor(nt.prototype,"setVideoProfile"),nt.prototype),X(nt.prototype,"setScreenProfile",[Lx],Object.getOwnPropertyDescriptor(nt.prototype,"setScreenProfile"),nt.prototype),X(nt.prototype,"setVideoContentHint",[Mx],Object.getOwnPropertyDescriptor(nt.prototype,"setVideoContentHint"),nt.prototype),X(nt.prototype,"switchDevice",[Nx],Object.getOwnPropertyDescriptor(nt.prototype,"switchDevice"),nt.prototype),X(nt.prototype,"addTrack",[Ux],Object.getOwnPropertyDescriptor(nt.prototype,"addTrack"),nt.prototype),X(nt.prototype,"removeTrack",[Vx],Object.getOwnPropertyDescriptor(nt.prototype,"removeTrack"),nt.prototype),X(nt.prototype,"replaceTrack",[jx],Object.getOwnPropertyDescriptor(nt.prototype,"replaceTrack"),nt.prototype),X(nt.prototype,"recoverCapture",[Bx],Object.getOwnPropertyDescriptor(nt.prototype,"recoverCapture"),nt.prototype),X(nt.prototype,"setAudioCaptureVolume",[Fx,Hx],Object.getOwnPropertyDescriptor(nt.prototype,"setAudioCaptureVolume"),nt.prototype),nt),Wx={voiceActivityDetection:!1},OF=(Gx=Lo({retries:1,timeout:0,onRetrying:function(e){this.log_.warn("connection timeout, retrying [".concat(e,"]"))},onError:function(e,t,n){e.message.includes("timeout")?(this.reset(),this.initialize(),t()):n(e)}}),Tc=function(e){Et(V,e);var t,n,i,r,o,c,a,s,l,u,f,S,x,E,I,m,T,v,w,L,N=Rr(V);function V(_){var b;return Q(this,V),(b=N.call(this,_)).localStream_=null,b.exchangeSDPTimeout_=-1,b.localAuxStream_=null,b.publishingStream_=null,b.isPublishingAuxStream_=!1,b.smallGenerator_=null,b.isSDPExchanging_=!1,b.ssrc_={audio:0,video:0,small:0,auxiliary:0},b.mediaSettings_={videoCodec:"",videoWidth:0,videoHeight:0,videoBps:0,videoFps:0,audioCodec:"opus",audioFs:0,audioChannel:0,audioBps:0,smallVideoWidth:0,smallVideoHeight:0,smallVideoFps:0,smallVideoBps:0,auxVideoWidth:0,auxVideoHeight:0,auxVideoFps:0,auxVideoBps:0},b.mixedAudioTrack_=null,b}return Ie(V,[{key:"isMainStreamPublished",get:function(){return!!this.localStream_}},{key:"isAuxStreamPublished",get:function(){return!!this.localAuxStream_}},{key:"publishState",get:function(){var _=this,b={audio:!1,bigVideo:!1,smallVideo:!1,auxVideo:!1};if(this.peerConnection_){var R,P,U,k,h=this.peerConnection_.getSenders();h&&(Ti()?(b.audio=!((R=h[0])===null||R===void 0||!R.track),b.bigVideo=!((P=h[1])===null||P===void 0||!P.track),b.smallVideo=!((U=h[2])===null||U===void 0||!U.track),b.auxVideo=!((k=h[3])===null||k===void 0||!k.track)):h.forEach(function(y){y.track&&(y.track.kind===Ee?b.audio=!0:(b.bigVideo=!0,_.smallGenerator_&&(b.smallVideo=!0)))}))}return b}},{key:"initialize",value:function(){le(Ye(V.prototype),"initialize",this).call(this),this.installEvents()}},{key:"reset",value:function(){this.isReconnecting_&&this.stopReconnection(),this.closePeerConnection(),this.uninstallEvents(),this.clearExchangeSDPTimeout(),this.localStream_&&this.localStream_.clearCanvas()}},{key:"close",value:function(){le(Ye(V.prototype),"close",this).call(this),this.reset(),this.emitConnectionStateChangedEvent(on),this.smallGenerator_&&(this.smallGenerator_.destroy(),this.smallGenerator_=null)}},{key:"installEvents",value:function(){this.emitter_.on(et.ERROR,this.handleError,this),this.emitter_.on(et.CONNECTION_STATE_CHANGED,this.handleConnectionStateChange,this)}},{key:"uninstallEvents",value:function(){this.emitter_.off(et.ERROR,this.handleError,this),this.emitter_.off(et.CONNECTION_STATE_CHANGED,this.handleConnectionStateChange,this)}},{key:"publish",value:(L=H(p().mark(function _(b,R){var P,U,k,h;return p().wrap(function(y){for(;;)switch(y.prev=y.next){case 0:if(this.publishingStream_=b,this.isPublishingAuxStream_=R,U=b.getVideoTrack(),k=null,!U||R||!this.client_.getIsEnableSmallStream()){y.next=9;break}return this.smallGenerator_=new Yl(b),y.next=8,this.smallGenerator_.initialize();case 8:k=this.smallGenerator_.generateSmallVideoTrack(this.client_.smallStreamConfig_);case 9:if(h=b.getVideoProfile(),!this.client_.get2k4kFlag()){y.next=18;break}if(this.client_.get2k4kFlag()===1||b.getScreen()||!(h.height*h.width>=3686400)){y.next=18;break}return h.width=1920,h.height=1080,this.log_.warn(rS),y.next=18,b.setVideoProfile(h);case 18:if(!(ta&&lo()===115&&h.width*h.height<=230400)){y.next=22;break}return this.log_.warn("fallback video to 480p"),y.next=22,b.setVideoProfile("480p_2");case 22:if(this.updateMediaSettings(b,R),!vl()){y.next=33;break}if(!gi||OS!==11){y.next=29;break}return y.next=27,this.publishByAddTrack(b,k);case 27:y.next=31;break;case 29:return y.next=31,this.publishByTransceiver(b,k,R);case 31:y.next=35;break;case 33:return y.next=35,this.publishByAddTrack(b,k);case 35:return this.publishingStream_=null,this.isPublishingAuxStream_=!1,R?this.localAuxStream_=b:this.localStream_=b,(P=this.sei_)===null||P===void 0||P.handleEncodedStreams(),y.abrupt("return",b);case 40:case"end":return y.stop()}},_,this)})),function(_,b){return L.apply(this,arguments)})},{key:"publishByTransceiver",value:(w=H(p().mark(function _(b,R,P){var U,k,h,y,A,D,j;return p().wrap(function(K){for(;;)switch(K.prev=K.next){case 0:if(this.log_.info("publish by transceiver"),U=b.getMediaStream(),k=b.getAudioTrack(),h=b.getVideoTrack(),y=null,(al||il)&&VS(h)&&(y=b.getCanvasTrack()),(A=this.peerConnection_.getTransceivers()).length!==0){K.next=16;break}return this.peerConnection_.addTransceiver(k||Ee,{direction:pi,streams:[U]}),this.peerConnection_.addTransceiver(P?xe:y||h||xe,{direction:pi,streams:[U]}),this.peerConnection_.addTransceiver(R||xe,{direction:pi,streams:[U]}),this.peerConnection_.addTransceiver(P?y||h:xe,{direction:pi,streams:[U]}),K.next=14,this.connect();case 14:K.next=46;break;case 16:if(D=[],!k){K.next=29;break}if(!A[0].sender.track){K.next=24;break}return this.mixAudioTrack(A[0].sender.track,k),K.next=22,A[0].sender.replaceTrack(this.mixedAudioTrack_);case 22:K.next=27;break;case 24:return K.next=26,A[0].sender.replaceTrack(k);case 26:D.push(0);case 27:return K.next=29,this.setBandwidth({bandwidth:b.getAudioBitrate(),type:Ee});case 29:if(!h){K.next=42;break}return j=P?3:1,K.next=33,A[j].sender.replaceTrack(y||h);case 33:return K.next=35,this.setBandwidth({bandwidth:b.getVideoBitrate(),type:xe,videoType:P?gt:Bu,scaleResolutionDownBy:b.scaleResolutionDownBy});case 35:if(D.push(j),!R){K.next=42;break}return K.next=39,A[2].sender.replaceTrack(R);case 39:return K.next=41,this.setBandwidth({bandwidth:this.client_.smallStreamConfig.bitrate,type:xe,videoType:Mr});case 41:D.push(2);case 42:return K.next=44,this.setTransceiverDirection(pi,D);case 44:return K.next=46,this.doPublishChange();case 46:case"end":return K.stop()}},_,this)})),function(_,b,R){return w.apply(this,arguments)})},{key:"publishByAddTrack",value:(v=H(p().mark(function _(b,R){var P,U,k,h;return p().wrap(function(y){for(;;)switch(y.prev=y.next){case 0:return this.log_.info("publish by addtrack"),P=b.getMediaStream(),U=b.getAudioTrack(),k=b.getVideoTrack(),U&&this.peerConnection_.addTrack(U,P),k&&(this.peerConnection_.addTrack(k,P),R&&((h=new MediaStream).addTrack(R),this.peerConnection_.addTrack(R,h))),y.next=8,this.connect();case 8:case"end":return y.stop()}},_,this)})),function(_,b){return v.apply(this,arguments)})},{key:"unpublish",value:(T=H(p().mark(function _(b){var R,P,U,k;return p().wrap(function(h){for(;;)switch(h.prev=h.next){case 0:if(Ti()){h.next=2;break}return h.abrupt("return",this.doUnpublish());case 2:if(R=b.getAudioTrack(),P=b===this.localAuxStream_,U=[],!this.peerConnection_){h.next=33;break}if(k=this.peerConnection_.getSenders(),!R){h.next=18;break}if(!this.mixedAudioTrack_){h.next=15;break}return this.log_.info("has mixed audioTrack, use another audioTrack"),h.next=12,k[0].replaceTrack(P?this.localStream_.getAudioTrack():this.localAuxStream_.getAudioTrack());case 12:this.destroyMixedAudioTrack(),h.next=18;break;case 15:return h.next=17,k[0].replaceTrack(null);case 17:U.push(0);case 18:if(!P){h.next=26;break}return h.next=21,k[3].replaceTrack(null);case 21:this.localAuxStream_=null,this.mediaSettings_=q(q({},this.mediaSettings_),{},{auxVideoBps:0,auxVideoFps:0,auxVideoWidth:0,auxVideoHeight:0}),U.push(3),h.next=33;break;case 26:return h.next=28,k[1].replaceTrack(null);case 28:return h.next=30,k[2].replaceTrack(null);case 30:this.localStream_=null,this.mediaSettings_=q(q({},this.mediaSettings_),{},{videoWidth:0,videoHeight:0,videoBps:0,videoFps:0,audioFs:0,audioChannel:0,audioBps:0,smallVideoWidth:0,smallVideoHeight:0,smallVideoFps:0,smallVideoBps:0}),U.push(1,2);case 33:if(!this.localStream_&&!this.localAuxStream_){h.next=40;break}return h.next=36,this.setTransceiverDirection(oo,U);case 36:return h.next=38,this.doPublishChange();case 38:h.next=42;break;case 40:return h.next=42,this.doUnpublish();case 42:case"end":return h.stop()}},_,this)})),function(_){return T.apply(this,arguments)})},{key:"doPublishChange",value:(m=H(p().mark(function _(){var b,R;return p().wrap(function(P){for(;;)switch(P.prev=P.next){case 0:return b={state:this.publishState,constraintConfig:this.mediaSettings_},P.next=3,this.signalChannel_.sendWaitForResponse({command:xU,data:b,responseCommand:st.PUBLISH_STATE_CHANGE_RESULT});case 3:R=P.sent,this.checkPublishResultCode(R.data.code,R.data.message);case 5:case"end":return P.stop()}},_,this)})),function(){return m.apply(this,arguments)})},{key:"doUnpublish",value:function(){var _=this;return this.signalChannel_.sendWaitForResponse({command:gk,commandDesc:"unpublish",responseCommand:st.UNPUBLISH_RESULT}).then(function(){_.close()}).catch(function(){_.close()})}},{key:"updateMediaSettings",value:function(_,b){var R=this;this.localAuxStream_&&_===this.localAuxStream_&&(b=!0);var P=this.client_.getSystemResult().detail,U=P.isH264EncodeSupported,k=P.isVp8EncodeSupported;if(U?this.mediaSettings_.videoCodec="H264":k&&(this.mediaSettings_.videoCodec="VP8"),la){var h=_.getMediaStream();h==null||h.getTracks().forEach(function(y){var A=y.getSettings();if(y.kind===Ee){var D=1;A.channelCount&&(D=A.channelCount),R.mediaSettings_.audioChannel=D,R.mediaSettings_.audioBps=1e3*_.getAudioBitrate(),R.mediaSettings_.audioFs=A.sampleRate}else if(y.kind===xe){if(b)return R.mediaSettings_.auxVideoWidth=A.width,R.mediaSettings_.auxVideoHeight=A.height,R.mediaSettings_.auxVideoFps=A.frameRate,void(R.mediaSettings_.auxVideoBps=1e3*_.getVideoBitrate());R.client_.getIsEnableSmallStream()&&(R.mediaSettings_.smallVideoWidth=R.client_.smallStreamConfig.width,R.mediaSettings_.smallVideoHeight=R.client_.smallStreamConfig.height,R.mediaSettings_.smallVideoFps=R.client_.smallStreamConfig.frameRate,R.mediaSettings_.smallVideoBps=1e3*R.client_.smallStreamConfig.bitrate),R.mediaSettings_.videoWidth=A.width,R.mediaSettings_.videoHeight=A.height,R.mediaSettings_.videoFps=A.frameRate,R.mediaSettings_.videoBps=1e3*_.getVideoBitrate()}})}else this.updateMediaSettingsFromProfile(_);this.log_.info("updateMediaSettings: "+JSON.stringify(this.mediaSettings_))}},{key:"updateMediaSettingsFromProfile",value:function(_){if(_){if(_.hasAudio()){var b=_.getAudioProfile();this.mediaSettings_.audioChannel=b.channelCount,this.mediaSettings_.audioBps=1e3*b.bitrate,this.mediaSettings_.audioFs=b.sampleRate}if(_.hasVideo()){var R=_.getVideoProfile();this.mediaSettings_.videoWidth=R.width,this.mediaSettings_.videoHeight=R.height,this.mediaSettings_.videoFps=R.frameRate,this.mediaSettings_.videoBps=1e3*R.bitrate}}}},{key:"sendMediaSettings",value:function(_){var b=this;this.updateMediaSettings(_),this.signalChannel_.sendWaitForResponse({command:FU,data:this.mediaSettings_,responseCommand:st.UPDATE_CONSTRAINT_CONFIG_RES}).then(function(R){R.data.code!==0&&b.log_.warn(R.data.message)}).catch(this.log_.warn)}},{key:"addTrack",value:(I=H(p().mark(function _(b,R){var P,U;return p().wrap(function(k){for(;;)switch(k.prev=k.next){case 0:if(this.peerConnection_){k.next=2;break}return k.abrupt("return");case 2:if(U=R===this.localAuxStream_,this.log_.info("is adding ".concat(b.kind," track to current published local ").concat(U?gt:Qe," stream")),(P=this.sei_)===null||P===void 0||P.handleEncodedStreams(),!Ti()){k.next=10;break}return k.next=8,this.addTrackByTransceiver(b,R);case 8:k.next=12;break;case 10:return k.next=12,this.addTrackBySender(b);case 12:vn(this.userId_,{eventId:b.kind===Ee?yk:_k,eventDesc:"add ".concat(b.kind," track to current published stream"),timestamp:an(),userId:this.userId_,tinyId:this.tinyId_});case 13:case"end":return k.stop()}},_,this)})),function(_,b){return I.apply(this,arguments)})},{key:"addTrackByTransceiver",value:(E=H(p().mark(function _(b,R){var P,U,k,h;return p().wrap(function(y){for(;;)switch(y.prev=y.next){case 0:if(P=R===this.localAuxStream_,U=this.peerConnection_.getTransceivers(),b.kind!==Ee){y.next=13;break}if(!U[0].sender.track){y.next=9;break}return this.mixAudioTrack(U[0].sender.track,b),y.next=7,U[0].sender.replaceTrack(this.mixedAudioTrack_);case 7:y.next=11;break;case 9:return y.next=11,U[0].sender.replaceTrack(b);case 11:y.next=26;break;case 13:return k=P?3:1,y.next=16,U[k].sender.replaceTrack(b);case 16:if(k!==1||!this.client_.getIsEnableSmallStream()){y.next=23;break}return this.smallGenerator_=new Yl(this.localStream_),y.next=20,this.smallGenerator_.initialize();case 20:return h=this.smallGenerator_.generateSmallVideoTrack(this.client_.smallStreamConfig_),y.next=23,U[2].sender.replaceTrack(h);case 23:if(U[k].direction!==oo){y.next=26;break}return y.next=26,this.setTransceiverDirection(pi,[k]);case 26:return this.updateMediaSettings(R,P),y.next=29,this.doPublishChange();case 29:case"end":return y.stop()}},_,this)})),function(_,b){return E.apply(this,arguments)})},{key:"addTrackBySender",value:(x=H(p().mark(function _(b){var R,P,U,k,h;return p().wrap(function(y){for(;;)switch(y.prev=y.next){case 0:if(!(Ti()&&this.peerConnection_.getTransceivers().findIndex(function(A){return A.direction==="stopped"})>=0)){y.next=4;break}return this.log_.warn("transceiver is stopping, negotiate sdp first"),y.next=4,this.updateOffer(cn.REMOVE,b);case 4:if(!(R=this.peerConnection_.getSenders().find(function(A){return A.track&&A.track.kind===b.kind}))){y.next=11;break}return this.log_.warn("sender already exists, remove sender first"),P=R.track,this.removeSender(R),y.next=11,this.updateOffer(cn.REMOVE,P);case 11:if(U=this.localStream_.getMediaStream(),this.peerConnection_.addTrack(b,U),b.kind!==xe||!this.client_.getIsEnableSmallStream()){y.next=21;break}return this.smallGenerator_=new Yl(this.localStream_),y.next=17,this.smallGenerator_.initialize();case 17:k=this.smallGenerator_.generateSmallVideoTrack(this.client_.smallStreamConfig_),(h=new MediaStream).addTrack(k),this.peerConnection_.addTrack(k,h);case 21:return y.next=23,this.updateOffer(cn.ADD,b);case 23:case"end":return y.stop()}},_,this)})),function(_){return x.apply(this,arguments)})},{key:"isNeedToResetOfferOrder",value:function(){if(this.sdpSemantics_===Wf||!this.peerConnection_||!this.peerConnection_.localDescription)return!1;for(var _=this.peerConnection_.localDescription.sdp,b=Fr(_),R=0;R<b.media.length;R++)if(b.media[R].mid===0&&b.media[R].type===xe)return!0;return!1}},{key:"removeSender",value:function(_){var b=null;Ti()&&(b=this.peerConnection_.getTransceivers().find(function(R){return R.sender&&R.sender.track===_.track})),this.peerConnection_.removeTrack(_),b&&ln(b.stop)&&(this.log_.info("stop transceiver"),b.stop())}},{key:"removeTrack",value:(S=H(p().mark(function _(b,R){return p().wrap(function(P){for(;;)switch(P.prev=P.next){case 0:if(this.peerConnection_){P.next=2;break}return P.abrupt("return");case 2:if(this.log_.info("is removing ".concat(b.kind," track from current published local ").concat(R===this.localAuxStream_?gt:Qe," stream")),!Ti()){P.next=8;break}return P.next=6,this.removeTrackByTransceiver(b,R);case 6:P.next=10;break;case 8:return P.next=10,this.removeTrackBySender(b);case 10:vn(this.userId_,{eventId:b.kind===Ee?Sk:bk,eventDesc:"remove ".concat(b.kind," track from current published stream"),timestamp:an(),userId:this.userId_,tinyId:this.tinyId_});case 11:case"end":return P.stop()}},_,this)})),function(_,b){return S.apply(this,arguments)})},{key:"removeTrackByTransceiver",value:(f=H(p().mark(function _(b,R){var P,U,k;return p().wrap(function(h){for(;;)switch(h.prev=h.next){case 0:if(P=R===this.localAuxStream_,U=this.peerConnection_.getTransceivers(),b.kind!==Ee){h.next=13;break}if(!this.mixedAudioTrack_){h.next=9;break}return h.next=6,U[0].sender.replaceTrack(P?this.localStream_.getAudioTrack():this.localAuxStream_.getAudioTrack());case 6:this.destroyMixedAudioTrack(),h.next=11;break;case 9:return h.next=11,U[0].sender.replaceTrack(null);case 11:h.next=23;break;case 13:return k=P?3:1,h.next=16,U[k].sender.replaceTrack(null);case 16:if(k!==1||!this.smallGenerator_){h.next=21;break}return this.smallGenerator_.destroy(),this.smallGenerator_=null,h.next=21,U[2].sender.replaceTrack(null);case 21:return h.next=23,this.setTransceiverDirection(oo,[k]);case 23:return this.updateMediaSettings(R,P),h.next=26,this.doPublishChange();case 26:case"end":return h.stop()}},_,this)})),function(_,b){return f.apply(this,arguments)})},{key:"setTransceiverDirection",value:(u=H(p().mark(function _(b,R){var P,U,k,h,y,A;return p().wrap(function(D){for(;;)switch(D.prev=D.next){case 0:if(Vn){D.next=2;break}return D.abrupt("return");case 2:if(P=!1,U=!1,this.log_.info("setting transceiver ".concat(R.join(",")," direction to ").concat(b)),k=this.peerConnection_.getTransceivers(),R.forEach(function(j){k[j].direction!==b&&(k[j].direction=b,P=!0)}),!P){D.next=14;break}return this.log_.info("updating offer"),D.next=11,this.peerConnection_.createOffer();case 11:return h=D.sent,D.next=14,this.peerConnection_.setLocalDescription(h);case 14:if(y=-1,A=this.peerConnection_.remoteDescription.sdp.split(`\r
|
|
63
|
+
`).map(function(j){if(j.match(new RegExp("a=(".concat(oo,"|").concat(Mf,"|").concat(pi,")")))&&y++,R.includes(y)){if(b===oo&&j.includes("a=".concat(Mf)))return U=!0,"a=".concat(b);if(b===pi&&j.includes("a=".concat(oo)))return U=!0,"a=".concat(Mf)}return j}).join(`\r
|
|
64
|
+
`),!U){D.next=20;break}return this.log_.info("updating answer"),D.next=20,this.peerConnection_.setRemoteDescription({type:"answer",sdp:A});case 20:case"end":return D.stop()}},_,this)})),function(_,b){return u.apply(this,arguments)})},{key:"removeTrackBySender",value:(l=H(p().mark(function _(b){var R,P,U=this;return p().wrap(function(k){for(;;)switch(k.prev=k.next){case 0:if(b.kind!==xe||!this.isNeedToResetOfferOrder()){k.next=7;break}return this.reset(),this.initialize(),(R=this.localStream_.getMediaStream())===null||R===void 0||R.removeTrack(b),k.next=6,this.publish(this.localStream_);case 6:return k.abrupt("return");case 7:return(P=this.peerConnection_.getSenders().find(function(h){return h.track===b}))&&(this.removeSender(P),b.kind===xe&&this.smallGenerator_&&(this.smallGenerator_.destroy(),this.smallGenerator_=null,this.peerConnection_.getSenders().forEach(function(h){h.track&&h.track.kind===xe&&U.removeSender(h)}))),k.next=11,this.updateOffer(cn.REMOVE,b);case 11:case"end":return k.stop()}},_,this)})),function(_){return l.apply(this,arguments)})},{key:"replaceTrack",value:(s=H(p().mark(function _(b,R){var P,U,k,h,y,A,D;return p().wrap(function(j){for(;;)switch(j.prev=j.next){case 0:if((U=(P=this.peerConnection_)===null||P===void 0?void 0:P.getSenders())&&U.length!==0){j.next=3;break}throw new te({code:Z.INVALID_OPERATION,message:ae({key:fS})});case 3:if(k=R===this.localAuxStream_,this.log_.info("is replacing ".concat(b.kind," track to current published local ").concat(k?gt:Qe," stream")),b.kind!==Ee||!U[0]){j.next=16;break}if(!(this.mixedAudioTrack_&&(h=this.localStream_)!==null&&h!==void 0&&h.hasAudio()&&(y=this.localAuxStream_)!==null&&y!==void 0&&y.hasAudio())){j.next=14;break}return this.destroyMixedAudioTrack(),A=k?this.localStream_.getAudioTrack():this.localAuxStream_.getAudioTrack(),this.mixAudioTrack(b,A),j.next=12,U[0].replaceTrack(this.mixedAudioTrack_);case 12:j.next=16;break;case 14:return j.next=16,U[0].replaceTrack(b);case 16:if(b.kind!==xe){j.next=32;break}if(R!==this.localStream_||!U[1]){j.next=29;break}return j.next=20,U[1].replaceTrack(b);case 20:if(!this.smallGenerator_||!U[2]){j.next=29;break}return this.log_.info("replacing smallVideo"),this.smallGenerator_.destroy(),this.smallGenerator_=new Yl(this.localStream_),j.next=26,this.smallGenerator_.initialize();case 26:return D=this.smallGenerator_.generateSmallVideoTrack(this.client_.smallStreamConfig_),j.next=29,U[2].replaceTrack(D);case 29:if(R!==this.localAuxStream_||!U[3]){j.next=32;break}return j.next=32,U[3].replaceTrack(b);case 32:vn(this.userId_,{eventId:b.kind===Ee?ZU:$U,eventDesc:"replace ".concat(b.kind," track from current published stream"),timestamp:an(),userId:this.userId_,tinyId:this.tinyId_});case 33:case"end":return j.stop()}},_,this)})),function(_,b){return s.apply(this,arguments)})},{key:"updateOffer",value:(a=H(p().mark(function _(b,R){var P,U,k,h,y,A,D;return p().wrap(function(j){for(;;)switch(j.prev=j.next){case 0:return j.prev=0,j.next=3,this.peerConnection_.createOffer(Wx);case 3:return P=j.sent,Vn&&(P.sdp=this.setSDPDirection(P.sdp,"sendrecv")),j.next=7,this.peerConnection_.setLocalDescription(P);case 7:return U=this.updateMediaSettings(this.localStream_||this.localAuxStream_),k={action:b,trackId:R.id,kind:R.kind===xe?"bigVideo":R.kind,type:"offer",sdp:this.peerConnection_.localDescription.sdp,constraintConfig:U,state:this.publishState},this.log_.info("createOffer success, sending updated offer to remote server"),this.log_.debug("updatedOffer: "+k.sdp),j.next=13,this.signalChannel_.sendWaitForResponse({command:TU,data:k,responseCommand:st.UPDATE_OFFER_RESULT,timeout:1e4,commandDesc:"update offer"});case 13:return h=j.sent,y=h.data,A=y.code,D=y.message,A!==0&&this.checkPublishResultCode(A,D),j.next=18,this.acceptAnswer(h.data.data);case 18:this.updateSSRC(P.sdp),ke.logSuccessEvent({userId:this.client_.getUserId(),eventType:qu,kind:"offer"}),j.next=27;break;case 22:throw j.prev=22,j.t0=j.catch(0),this.log_.error(j.t0),ke.logFailedEvent({userId:this.client_.getUserId(),eventType:qu,kind:"offer",error:j.t0}),j.t0;case 27:case"end":return j.stop()}},_,this,[[0,22]])})),function(_,b){return a.apply(this,arguments)})},{key:"setBandwidth",value:(c=H(p().mark(function _(b){var R,P,U,k,h,y,A,D,j,K;return p().wrap(function(J){for(;;)switch(J.prev=J.next){case 0:if(R=b.bandwidth,P=b.type,U=b.videoType,k=U===void 0?"":U,h=b.sdp,y=b.scaleResolutionDownBy,A=y===void 0?1:y,Hk()||!h){J.next=3;break}return J.abrupt("return",P===xe?this.updateVideoBandwidthRestriction(h,R,k):this.updateAudioBandwidthRestriction(h,R));case 3:if(D=null,vl()?(j=0,P===xe&&(j=k===Mr?2:k===gt?3:1),D=this.peerConnection_.getSenders()[j]):D=this.peerConnection_.getSenders().find(function(se){return se.track&&se.track.kind===P}),!D){J.next=22;break}return(K=D.getParameters()).encodings&&K.encodings.length!==0||(K.encodings=[{}]),R==="unlimited"?delete K.encodings[0].maxBitrate:K.encodings[0].maxBitrate=1e3*R,A>1&&(this.log_.warn("".concat(k," scaleResolutionDownBy ").concat(A)),K.encodings[0].scaleResolutionDownBy=A),J.prev=10,J.next=13,D.setParameters(K);case 13:return this.log_.info(k+P+" bandwidth was set to "+R+" kbps"),J.abrupt("return",h);case 17:if(J.prev=17,J.t0=J.catch(10),this.log_.info("failed to set bandwidth by setting maxBitrate: "+J.t0),!h){J.next=22;break}return J.abrupt("return",P===xe?this.updateVideoBandwidthRestriction(h,R,k):this.updateAudioBandwidthRestriction(h,R));case 22:return J.abrupt("return",h);case 23:case"end":return J.stop()}},_,this,[[10,17]])})),function(_){return c.apply(this,arguments)})},{key:"updateVideoBandwidthRestriction",value:function(_,b,R){var P="AS";Vn&&(P="TIAS",b*=1e3);var U=0,k=-1;return R===Mr?U=1:R===gt&&(U=2),_=_.replace(/m=video (.*)\r\nc=IN (.*)\r\n/g,function(h){return++k===U?"".concat(h,"b=").concat(P,":").concat(b,`\r
|
|
65
|
+
`):h}),_}},{key:"updateAudioBandwidthRestriction",value:function(_,b){var R="AS";return Vn&&(R="TIAS",b*=1e3),_=_.replace(/m=audio (.*)\r\nc=IN (.*)\r\n/,`m=audio $1\r
|
|
102
66
|
c=IN $2\r
|
|
103
|
-
b=`+
|
|
104
|
-
`)}},{key:"removeBandwidthRestriction",value:function(S){return S.replace(/b=AS:.*\r\n/,"").replace(/b=TIAS:.*\r\n/,"")}},{key:"removeVideoOrientation",value:function(S){return S.replace(/urn:3gpp:video-orientation/,"")}},{key:"connect",value:(r=G(m().mark(function S(){return m().wrap(function(T){for(;;)switch(T.prev=T.next){case 0:return T.prev=0,T.next=3,this.exchangeSDP();case 3:return T.next=5,this.waitForPeerConnectionConnected();case 5:T.next=11;break;case 7:throw T.prev=7,T.t0=T.catch(0),this.closePeerConnection(!0),T.t0;case 11:case"end":return T.stop()}},S,this,[[0,7]])})),function(){return r.apply(this,arguments)})},{key:"exchangeSDP",value:(i=G(m().mark(function S(){return m().wrap(function(T){for(;;)switch(T.prev=T.next){case 0:return T.prev=0,this.isSDPExchanging_=!0,T.next=4,this.createOffer();case 4:return this.log_.info("createOffer success, sending offer to remote server"),T.next=7,this.doExchangeSDP();case 7:this.isSDPExchanging_=!1,T.next=14;break;case 10:throw T.prev=10,T.t0=T.catch(0),this.isSDPExchanging_=!1,T.t0;case 14:case"end":return T.stop()}},S,this,[[0,10]])})),function(){return i.apply(this,arguments)})},{key:"createOffer",value:(a=G(m().mark(function S(){var T;return m().wrap(function(C){for(;;)switch(C.prev=C.next){case 0:return C.prev=0,C.next=3,this.peerConnection_.createOffer(Hx);case 3:return T=C.sent,C.next=6,this.peerConnection_.setLocalDescription(T);case 6:this.updateSSRC(T.sdp),Ie.logSuccessEvent({userId:this.client_.getUserId(),eventType:Yu,kind:"offer"}),C.next=14;break;case 10:throw C.prev=10,C.t0=C.catch(0),Ie.logFailedEvent({userId:this.client_.getUserId(),eventType:Yu,kind:"offer",error:C.t0}),C.t0;case 14:case"end":return C.stop()}},S,this,[[0,10]])})),function(){return a.apply(this,arguments)})},{key:"doExchangeSDP",value:function(){var S=this;return new Promise(function(T,C){S.exchangeSDPTimeout_=setTimeout(function(){S.signalChannel_.off(ft.PUBLISH_RESULT,D),S.clearExchangeSDPTimeout();var x=new re({code:ee.API_CALL_TIMEOUT,message:ie({key:ON})});C(x)},1e4);var D=function(){var x=G(m().mark(function h(E){var O,N,j;return m().wrap(function(J){for(;;)switch(J.prev=J.next){case 0:if(J.prev=0,S.clearExchangeSDPTimeout(),O=E.data,N=O.code,j=O.message,N!==0){J.next=9;break}return J.next=6,S.acceptAnswer(E.data.data);case 6:T(),J.next=10;break;case 9:S.checkPublishResultCode(N,j);case 10:J.next=15;break;case 12:J.prev=12,J.t0=J.catch(0),C(J.t0);case 15:case"end":return J.stop()}},h,null,[[0,12]])}));return function(h){return x.apply(this,arguments)}}(),B={type:S.peerConnection_.localDescription.type,sdp:S.removeVideoOrientation(S.peerConnection_.localDescription.sdp),screen:(S.publishingStream_||S.localStream_).hasScreenTrack(),state:S.publishState,constraintConfig:S.mediaSettings_};S.signalChannel_.once(ft.PUBLISH_RESULT,D),S.log_.debug("sending sdp offer: "+B.sdp),S.signalChannel_.send(NU,B)})}},{key:"setSDPDirection",value:function(S,T){var C=arguments.length>2&&arguments[2]!==void 0?arguments[2]:"all",D=Kr(S);return D.media.forEach(function(B){C!=="all"&&B.type!==C||(B.direction=T)}),To(D)}},{key:"acceptAnswer",value:(n=G(m().mark(function S(T){var C,D,B,x,h,E,O;return m().wrap(function(N){for(;;)switch(N.prev=N.next){case 0:if(N.prev=0,C=this.removeVideoOrientation(T.sdp),!(D=this.publishingStream_||this.localStream_)){N.next=15;break}if(B=D.getVideoBitrate(),x=D.getAudioBitrate(),!B){N.next=11;break}return h=this.isPublishingAuxStream_?pt:zu,N.next=10,this.setBandwidth({bandwidth:B,type:xe,sdp:C,videoType:h});case 10:C=N.sent;case 11:if(!x){N.next=15;break}return N.next=14,this.setBandwidth({bandwidth:x,type:Ae,sdp:C});case 14:C=N.sent;case 15:if(!this.client_.getIsEnableSmallStream()){N.next=20;break}return E=this.client_.smallStreamConfig,N.next=19,this.setBandwidth({bandwidth:E.bitrate,type:xe,videoType:Gr,sdp:C});case 19:C=N.sent;case 20:return O={type:T.type,sdp:C},N.next=23,this.peerConnection_.setRemoteDescription(O);case 23:this.log_.debug("accepted answer: "+C),Ie.logSuccessEvent({userId:this.client_.getUserId(),eventType:Nb,kind:"answer"}),N.next=32;break;case 27:throw N.prev=27,N.t0=N.catch(0),Ie.logFailedEvent({userId:this.client_.getUserId(),eventType:Nb,kind:"answer",error:N.t0}),this.log_.error("failed to accept remote answer "+N.t0),N.t0;case 32:case"end":return N.stop()}},S,this,[[0,27]])})),function(S){return n.apply(this,arguments)})},{key:"sendMutedFlag",value:function(S,T){if(T!==this.localAuxStream_){var C={audio:S.audio,bigVideo:S.video,auxVideo:S.auxVideo};this.log_.info("send muted state: ".concat(JSON.stringify(C))),this.signalChannel_.send(MU,C)}}},{key:"getIsReconnecting",value:function(){return this.isReconnecting_}},{key:"reconnect",value:(t=G(m().mark(function S(){var T,C,D=this;return m().wrap(function(B){for(;;)switch(B.prev=B.next){case 0:if(this.reconnectionTimer_===-1){B.next=3;break}return this.log_.warn("reconnect() uplink is reconnecting, ignore current reconnection"),B.abrupt("return");case 3:if(!(this.reconnectionCount_>=30)){B.next=12;break}return this.log_.warn("SDK has tried reconnect uplink for ".concat(30," times, but all failed, please check your network")),this.stopReconnection(),T=new re({code:ee.UPLINK_RECONNECTION_FAILED,message:ie({key:UN})}),Ie.logFailedEvent({userId:this.client_.getUserId(),eventType:Lb,error:T}),this.addEventInternal(yV,"uplink-connection reconnect fail"),this.emitConnectionStateChangedEvent(on),this.emitter_.emit(Ze.ERROR,T),B.abrupt("return");case 12:if(this.signalChannel_.getCurrentState()===pc){B.next=16;break}return this.log_.warn("reconnect() signal channel is not connected, suspend reconnection until signal is connected"),this.signalChannel_.once(hc,this.reconnect,this),B.abrupt("return");case 16:if(this.reconnectionCount_++,B.prev=17,this.log_.warn("reconnect() try to reconnect uplink [".concat(this.reconnectionCount_,"/").concat(30,"]")),C=If(this.reconnectionCount_),this.reconnectionTimer_=setTimeout(function(){D.log_.warn("reconnect() uplink reconnect timeout(".concat(C/1e3,"s), try again")),D.clearReconnectionTimer(),D.reconnect()},C),!(this.isSDPExchanging_||this.peerConnection_&&this.peerConnection_.connectionState===Qu)){B.next=23;break}return B.abrupt("return");case 23:return B.next=25,this.signalChannel_.sendWaitForResponse({command:_k,responseCommand:ft.UNPUBLISH_RESULT,enableLog:!1});case 25:if(this.reset(),this.initialize(),!this.localStream_){B.next=30;break}return B.next=30,this.publish(this.localStream_);case 30:if(!this.localAuxStream_){B.next=33;break}return B.next=33,this.publish(this.localAuxStream_,!0);case 33:Ie.logSuccessEvent({userId:this.client_.getUserId(),eventType:Lb}),this.log_.warn("reconnect() uplink reconnect successfully"),this.addEventInternal(_V,"uplink-connection reconnect success"),this.stopReconnection(),this.localStream_.syncMuteState(),B.next=42;break;case 40:B.prev=40,B.t0=B.catch(17);case 42:case"end":return B.stop()}},S,this,[[17,40]])})),function(){return t.apply(this,arguments)})},{key:"clearExchangeSDPTimeout",value:function(){this.exchangeSDPTimeout_!==-1&&(clearTimeout(this.exchangeSDPTimeout_),this.exchangeSDPTimeout_=-1)}},{key:"clearReconnectionTimer",value:function(){this.reconnectionTimer_!==-1&&(clearTimeout(this.reconnectionTimer_),this.reconnectionTimer_=-1)}},{key:"handleError",value:function(S){S.getCode()===ee.ICE_TRANSPORT_ERROR&&(this.isFirstConnection_&&(this.isFirstConnection_=!1,Ie.logFailedEvent({userId:this.client_.getUserId(),eventType:Db,error:S})),this.isReconnecting_||this.startReconnection())}},{key:"handleConnectionStateChange",value:function(S){S.state===_n&&this.isFirstConnection_&&(this.isFirstConnection_=!1,Ie.logSuccessEvent({userId:this.client_.getUserId(),eventType:Db}),this.addEventInternal(hV,"uplink-connection is connected"))}},{key:"updateSSRC",value:function(S){var T=this;try{Kr(S).media.forEach(function(C,D){if(C.type===Ae){var B=C.ssrcs[0];B&&(T.ssrc_.audio=B.id)}else{if(T.sdpSemantics_===Wp)return void C.ssrcGroups.forEach(function(h,E){var O=Number(h.ssrcs.split(" ")[0]);E===0?T.ssrc_.video=O:E===1&&(T.ssrc_.small=O)});var x=C.ssrcs[0];if(!x)return;switch(D){case 1:T.ssrc_.video=x.id;break;case 2:T.ssrc_.small=x.id;break;case 3:T.ssrc_.auxiliary=x.id}}})}catch(C){}}},{key:"getVideoTrackId",value:function(){var S=arguments.length>0&&arguments[0]!==void 0?arguments[0]:xe;if(this.peerConnection_){var T=this.peerConnection_.getSenders();if(S===xe&&T[1]&&T[1].track)return T[1].track.id;if(S===Gr&&T[2]&&T[2].track)return T[2].track.id;if(S===pt&&T[3]&&T[3].track)return T[3].track.id}if(this.localStream_&&S===xe){var C=this.localStream_.getVideoTrack();if(C)return C.id}if(this.localAuxStream_&&S===pt){var D=this.localAuxStream_.getVideoTrack();if(D)return D.id}return""}},{key:"getSSRC",value:function(){return this.ssrc_}},{key:"checkPublishResultCode",value:function(S,T){if(S!==0)throw S===1028?(this.log_.error(xi.NOT_SUPPORTED_H264ENCODE),new re({code:ee.NOT_SUPPORTED_H264,message:ie({key:yS})})):new re({code:ee.UNKNOWN,message:ie({key:SS,data:{signalResponse:ft.PUBLISH_RESULT,code:S,message:T}})})}},{key:"getLocalStream",value:function(){return this.localStream_}},{key:"sendSEI",value:function(S,T){this.sei_.push(S,T)}},{key:"mixAudioTrack",value:function(S,T){this.log_.info("mix audio track"),this.mixedAudioTrack_=function(C){var D=GS(),B=D.createMediaStreamDestination(),x=[];C.forEach(function(E){var O=new MediaStream;O.addTrack(E);var N=D.createMediaStreamSource(O);N.connect(B),x.push(N)});var h=B.stream.getAudioTracks()[0];return ed.set(h,{destination:B,track:h,mediaStreamSourceList:x}),h}([S,T])}},{key:"destroyMixedAudioTrack",value:function(){this.mixedAudioTrack_&&(this.log_.info("destroy audio track"),function(S){if(ed.has(S)){var T=ed.get(S),C=T.destination,D=T.track,B=T.mediaStreamSourceList;D.stop(),C.disconnect(),B.forEach(function(x){x.disconnect()}),ed.delete(S)}}(this.mixedAudioTrack_),this.mixedAudioTrack_=null)}}]),P}(jv),Y(Ac.prototype,"publish",[Fx],Object.getOwnPropertyDescriptor(Ac.prototype,"publish"),Ac.prototype),Ac),PF=ke,zx=Us,td=Ls.exports.getWeakData,DF=fi,LF=yt,OF=Dn,Jv=vt,MF=Ns,Wx=rt,NF=st.set,UF=st.getterFor,VF=rn.find,jF=rn.findIndex,BF=PF([].splice),FF=0,nd=function(e){return e.frozen||(e.frozen=new qx)},qx=function(){this.entries=[]},Kv=function(e,t){return VF(e.entries,function(n){return n[0]===t})};qx.prototype={get:function(e){var t=Kv(this,e);if(t)return t[1]},has:function(e){return!!Kv(this,e)},set:function(e,t){var n=Kv(this,e);n?n[1]=t:this.entries.push([e,t])},delete:function(e){var t=jF(this.entries,function(n){return n[0]===e});return~t&&BF(this.entries,t,1),!!~t}};var Pc,GF={getConstructor:function(e,t,n,a){var i=e(function(c,u){DF(c,r),NF(c,{type:t,id:FF++,frozen:void 0}),OF(u)||MF(u,c[a],{that:c,AS_ENTRIES:n})}),r=i.prototype,o=UF(t),s=function(c,u,d){var g=o(c),I=td(LF(u),!0);return I===!0?nd(g).set(u,d):I[g.id]=d,c};return zx(r,{delete:function(c){var u=o(this);if(!Jv(c))return!1;var d=td(c);return d===!0?nd(u).delete(c):d&&Wx(d,u.id)&&delete d[u.id]},has:function(c){var u=o(this);if(!Jv(c))return!1;var d=td(c);return d===!0?nd(u).has(c):d&&Wx(d,u.id)}}),zx(r,n?{get:function(c){var u=o(this);if(Jv(c)){var d=td(c);return d===!0?nd(u).get(c):d?d[u.id]:void 0}},set:function(c,u){return s(this,c,u)}}:{add:function(c){return s(this,c,!0)}}),i}},Jx=se,rd=ke,HF=Us,zF=Ls.exports,WF=fh,Kx=GF,id=vt,ad=Zg,od=st.enforce,qF=V,JF=!Jx.ActiveXObject&&"ActiveXObject"in Jx,Xx=function(e){return function(){return e(this,arguments.length?arguments[0]:void 0)}},KF=WF("WeakMap",Xx,Kx);if(qF&&JF){Pc=Kx.getConstructor(Xx,"WeakMap",!0),zF.enable();var Dc=KF.prototype,Qx=rd(Dc.delete),sd=rd(Dc.has),Yx=rd(Dc.get),$x=rd(Dc.set);HF(Dc,{delete:function(e){if(id(e)&&!ad(e)){var t=od(this);return t.frozen||(t.frozen=new Pc),Qx(this,e)||t.frozen.delete(e)}return Qx(this,e)},has:function(e){if(id(e)&&!ad(e)){var t=od(this);return t.frozen||(t.frozen=new Pc),sd(this,e)||t.frozen.has(e)}return sd(this,e)},get:function(e){if(id(e)&&!ad(e)){var t=od(this);return t.frozen||(t.frozen=new Pc),sd(this,e)?Yx(this,e):t.frozen.get(e)}return Yx(this,e)},set:function(e,t){if(id(e)&&!ad(e)){var n=od(this);n.frozen||(n.frozen=new Pc),sd(this,e)?$x(this,e,t):n.frozen.set(e,t)}else $x(this,e,t);return this}})}var XF=Ue,cd=$s,QF=ce,Zx=fn,eI=tt,YF=Uu,tI=pb,$F=qt,Xv=cd&&cd.prototype;if(XF({target:"Promise",proto:!0,real:!0,forced:!!cd&&QF(function(){Xv.finally.call({then:function(){}},function(){})})},{finally:function(e){var t=YF(this,Zx("Promise")),n=eI(e);return this.then(n?function(a){return tI(t,e()).then(function(){return a})}:e,n?function(a){return tI(t,e()).then(function(){throw a})}:e)}}),eI(cd)){var nI=Zx("Promise").prototype.finally;Xv.finally!==nI&&$F(Xv,"finally",nI,{unsafe:!0})}var rI,iI,aI,oI,sr,Go=new WeakMap;function sI(){return function(e,t,n){var a=n.value,i=function r(o){var s=o.fn,c=o.args,u=o.context,d=o.resolve,g=o.reject;s.apply(u,c).then(d,g).finally(function(){var I=Go.get(u);I&&(I.shift(),I[0]&&r(q({},I[0])))})};return n.value=function(){for(var r=this,o=arguments.length,s=new Array(o),c=0;c<o;c++)s[c]=arguments[c];return new Promise(function(u,d){if(Go.has(r)){var g=Go.get(r),I=g.length;g.push({fn:a,args:s,context:r,resolve:u,reject:d,name:t}),I===0&&i({fn:a,args:s,context:r,resolve:u,reject:d})}else Go.set(r,[{fn:a,args:s,context:r,resolve:u,reject:d,name:t}]),i({fn:a,args:s,context:r,resolve:u,reject:d})})},n}}var ZF=(rI=sI(),iI=Fo({retries:1,timeout:0,onRetrying:function(e){this.log_.warn("connection timeout, retrying [".concat(e,"]"))},onError:function(e,t,n){e.message.includes("timeout")?t():n(e)}}),aI=sI(),oI=function(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:1e4;return function(t,n,a){var i=a.value;return a.value=function(){for(var r=this,o=arguments.length,s=new Array(o),c=0;c<o;c++)s[c]=arguments[c];return new Promise(function(u,d){var g=setTimeout(function(){return d(new Error("".concat(n," timeout")))},e);i.apply(r,s).then(u,d).finally(function(){clearTimeout(g)})})},a}}(),sr=function(e){Ct(u,e);var t,n,a,i,r,o,s,c=Cr(u);function u(d){var g;return K(this,u),(g=c.call(this,d)).remoteStreams_=new Map,g.autoSubscribe=d.autoSubscribe,g.trackState_={audio:d.trackState.audio,video:d.trackState.video,auxiliary:d.trackState.auxiliary,smallVideo:d.trackState.smallVideo},g.ssrc_={audio:0,video:0,auxiliary:0},g.subscribeState_={audio:d.autoSubscribe,video:d.autoSubscribe,auxiliary:d.autoSubscribe,smallVideo:!1},g.isSDPExchanging_=!1,g.installEvents(),g}return we(u,[{key:"getMixUserList",value:function(){return this.mixUserList_?this.mixUserList_.map(function(d){var g=d.userId,I=d.flag;return{userId:g,hasAudio:!!(8&I),hasVideo:!!(1&I),hasAuxiliary:!!(4&I)}}):void 0}},{key:"setMixUserList",value:function(d){(!this.mixUserList_||_o(this.mixUserList_)&&!function(g,I){if(I.length===g.length){var k,w=ae(I);try{var A=function(){var v=k.value,y=g.find(function(L){return L.userId===v.userId});if(!y||y.flag!==v.flag)return{v:!1}};for(w.s();!(k=w.n()).done;){var p=A();if(H(p)==="object")return p.v}}catch(v){w.e(v)}finally{w.f()}return!0}return!1}(this.mixUserList_,d))&&(this.mixUserList_=d,this.emitter_.emit(Ze.STREAM_UPDATED,{stream:this.getMainStream()}))}},{key:"isMainStreamSubscribed",get:function(){return(this.subscribeState_.audio||this.subscribeState_.video||this.subscribeState_.smallVideo)&&(this.trackState_.audio||this.trackState_.video||this.trackState_.smallVideo)}},{key:"isAuxStreamSubscribed",get:function(){return this.subscribeState_.auxiliary&&this.trackState_.auxiliary}},{key:"isSmallStreamSubscribed",get:function(){return this.subscribeState_.smallVideo&&this.trackState_.smallVideo}},{key:"isBigStreamSubscribed",get:function(){return this.subscribeState_.video&&this.trackState_.video}},{key:"isStreamUnpublished",value:function(d){return d.getType()===Qe?!this.trackState_.audio&&!this.trackState_.video:!this.trackState_.auxiliary}},{key:"initialize",value:function(){oe(Xe(u.prototype),"initialize",this).call(this),this.peerConnection_.ontrack=this.onTrack.bind(this)}},{key:"close",value:function(){var d,g,I,k=this;oe(Xe(u.prototype),"close",this).call(this),this.trackState_.audio=!1,this.trackState_.video=!1,this.trackState_.smallVideo=!1,this.trackState_.auxiliary=!1,this.emitConnectionStateChangedEvent(on),d=this,g=function(w){w.fn;var A=w.args,p=w.resolve,v=w.reject,y=w.name;if(y==="subscribe"){if(!k.client_.getIsJoined())return v(new re({code:ee.API_CALL_ABORTED,message:ie({key:af,data:{message:"leave room",stream:A[0]}})}));if(k.isStreamUnpublished(A[0]))return v(new re({code:ee.API_CALL_ABORTED,message:ie({key:af,data:{message:"remote user ".concat(k.userId_," unpublished stream"),stream:A[0]}})}))}else if(y==="unsubscribe")return p();p()},(I=Go.get(d))===null||I===void 0||I.forEach(g),Go.delete(d),this.remoteStreams_.forEach(function(w){var A=w;A.setConnection(null),A.uninstallEvents(),A.getIsStreamAddedEventEmitted()&&k.emitter_.emit(Ze.STREAM_REMOVED,{stream:A})}),this.remoteStreams_.clear(),this.uninstallEvents()}},{key:"installEvents",value:function(){var d=this;X.on(Un,this.onRemoteStreamUpdate,this),this.emitter_.on(Ze.ERROR,function(g){g.getCode()===ee.ICE_TRANSPORT_ERROR&&(d.isFirstConnection_&&(d.isFirstConnection_=!1,Ie.logFailedEvent({userId:d.client_.getUserId(),eventType:Ob,error:g})),d.isReconnecting_||d.startReconnection())}),this.emitter_.on(Ze.CONNECTION_STATE_CHANGED,function(g){g.state===_n&&d.isFirstConnection_&&(d.isFirstConnection_=!1,Ie.logSuccessEvent({userId:d.client_.getUserId(),eventType:Ob}),d.addEventInternal(pV,"downlink-connection is connected"))})}},{key:"uninstallEvents",value:function(){X.removeListener(Un,this.onRemoteStreamUpdate,this)}},{key:"onRemoteStreamUpdate",value:function(d){if(this.hitTest(d.tinyId)&&d.client===this.client_){this.updateTrackState(d.action,d.kind);var g=d.kind===pt?nc:Sr,I=this.remoteStreams_.get(g);if(!I)return;d.action===cn.ADD?this.handleRemoteAddTrack(d.kind,I):this.handleRemoteRemoveTrack(d.kind,I)}}},{key:"handleRemoteAddTrack",value:function(d,g){this.log_.info("remote add ".concat(d," track")),d===Ae?g.updateAudioPlayingState(this.subscribeState_.audio):g.updateVideoPlayingState(d===pt?this.subscribeState_.auxiliary:this.subscribeState_.video||this.subscribeState_.smallVideo),g.getIsStreamAddedEventEmitted()?this.emitter_.emit(Ze.STREAM_UPDATED,{stream:g}):(this.emitter_.emit(Ze.STREAM_ADDED,{stream:g}),this.currentState_===_n&&g.emitConnectionStateChanged({prevState:on,state:_n}))}},{key:"handleRemoteRemoveTrack",value:function(d,g){g.getIsStreamAddedEventEmitted()&&(this.log_.info("remote remove ".concat(d," track")),d===pt||!this.trackState_.audio&&!this.trackState_.video?(this.log_.info("remote stream ".concat(g.getType()," removed")),this.currentState_===_n&&g.emitConnectionStateChanged({prevState:_n,state:on}),this.emitter_.emit(Ze.STREAM_REMOVED,{stream:g})):(d===Ae?g.updateAudioPlayingState(!1):(d!==Wu||this.isSmallStreamSubscribed)&&g.updateVideoPlayingState(!1),this.emitter_.emit(Ze.STREAM_UPDATED,{stream:g})))}},{key:"updateTrackState",value:function(d,g){var I=d===cn.ADD;switch(g){case Ae:this.trackState_.audio=I;break;case xe:this.trackState_.video=I;break;case pt:this.trackState_.auxiliary=I;break;case Wu:this.trackState_.smallVideo=I}this.log_.info("trackState updated: ".concat(JSON.stringify(this.trackState_)))}},{key:"onTrack",value:function(d){var g=d.streams[0],I=d.track;if(this.log_.info("ontrack() kind: ".concat(I.kind," id: ").concat(I.id," streamId: ").concat(g.id)),this.sdpSemantics_===ic){var k=function(y){var L=tr.parse(y),f={audio:[],video:[]};return L.media.forEach(function(b){if(b.ssrcs){var P=b.ssrcs[0].id>>16&255;if(b.type===Ae)f.audio.push(Sr);else if(b.type==xe){var S=P===tN?Sr:nc;f.video.push(S)}}}),f}(this.peerConnection_.remoteDescription.sdp);if(I.kind===Ae){if(k.audio.length===0||g.id!==Sr)return void this.log_.debug("skip this invalid audio track")}else if(k.video.indexOf(g.id)===-1)return void this.log_.debug("skip this invalid video track: ".concat(I.id," msid: ").concat(g.id))}Ie.logEvent({eventType:"ontrack",kind:I.kind});var w=!1,A=this.remoteStreams_.get(g.id),p=g.id===Sr?gt:Lt;if(ge(A)&&((A=new Gv({type:p,userId:this.userId_,client:this.client_})).setConnection(this),this.remoteStreams_.set(g.id,A),w=!0),A.setMediaStream(g),I.kind===Ae?A.updateAudioPlayingState(this.subscribeState_.audio):p===gt?A.updateVideoPlayingState(this.subscribeState_.video||this.subscribeState_.smallVideo):A.updateVideoPlayingState(this.subscribeState_.auxiliary),(p!==Lt||this.trackState_.auxiliary)&&(p!==gt||this.trackState_.audio||this.trackState_.video)){var v=this.client_.getSubscriptionManager();v&&v.hasAutoRecoveryFlag(this.userId_,p)||(w?this.emitter_.emit(Ze.STREAM_ADDED,{stream:A}):this.emitter_.emit(Ze.STREAM_UPDATED,{stream:A}))}}},{key:"addRRTRLine",value:function(d){var g=d.split(`\r
|
|
105
|
-
`),
|
|
106
|
-
`)}},{key:"addSPSDescription",value:function(d){var g=Kr(d);return g.media.forEach(function(I){I.type===xe&&I.fmtp.forEach(function(k){k.config+=";sps-pps-idr-in-keyframe=1"})}),To(g)}},{key:"removeSDESDescription",value:function(d){var g=["urn:ietf:params:rtp-hdrext:sdes:mid","urn:ietf:params:rtp-hdrext:sdes:rtp-stream-id","urn:ietf:params:rtp-hdrext:sdes:repaired-rtp-stream-id"],I=Kr(d);return I.media.forEach(function(k){k.ext=k.ext.filter(function(w){return!g.includes(w.uri)})}),To(I)}},{key:"isSubscriptionStateNotChanged",value:function(d,g){return d.getType()===gt?(g==null?void 0:g.audio)===this.subscribeState_.audio&&(g==null?void 0:g.video)===this.subscribeState_.video&&this.isSubscribeSmall(g):d.getType()===Lt?!ge(g.video)&&this.subscribeState_.auxiliary===g.video:void 0}},{key:"isSubscribeSmall",value:function(d){return ge(d.smallVideo)&&!this.subscribeState_.smallVideo}},{key:"subscribe",value:(s=G(m().mark(function d(g,I){var k,w,A,p,v,y;return m().wrap(function(L){for(;;)switch(L.prev=L.next){case 0:if(L.prev=0,A=I.emitEvent,p=A===void 0||A,v=g.getType(),((k=this.peerConnection_)===null||k===void 0?void 0:k.connectionState)!==nN&&((w=this.peerConnection_)===null||w===void 0?void 0:w.connectionState)!==Qu){L.next=6;break}return L.next=6,this.waitForPeerConnectionConnected();case 6:if(!this.isSubscriptionStateNotChanged(g,I)){L.next=13;break}if(this.peerConnection_){L.next=11;break}return this.initialize(),L.next=11,this.connect();case 11:return p&&ge(I.smallVideo)&&this.emitter_.emit(Ze.STREAM_SUBSCRIBED,{stream:g,result:!0}),L.abrupt("return",g);case 13:if(v===Qe?(ge(I.audio)||(this.subscribeState_.audio=I.audio),ge(I.video)||(this.subscribeState_.video=I.video),this.subscribeState_.smallVideo=(I==null?void 0:I.smallVideo)||!1,this.addEventInternal(this.subscribeState_.audio?Tk:sm,this.subscribeState_.audio?"subscribe audio":"unsubscribe audio"),this.addEventInternal(this.subscribeState_.video?Tk:sm,this.subscribeState_.video?"subscribe video":"unsubscribe video"),this.addEventInternal(this.subscribeState_.smallVideo?TV:xV,this.subscribeState_.smallVideo?"subscribe smallVideo":"unsubscribe smallVideo")):ge(I.video)||(this.subscribeState_.auxiliary=I.video),this.log_.info("subscribe ".concat(v," stream with options ").concat(JSON.stringify(I)," current state: ").concat(JSON.stringify(this.subscribeState_))),!this.peerConnection_&&!this.isSDPExchanging_){L.next=23;break}return y=zp,this.isMainStreamSubscribed||this.isAuxStreamSubscribed||(y=Hp),L.next=20,this.sendSubscription(y);case 20:v===Qe?(g.updateAudioPlayingState(this.subscribeState_.audio),g.updateVideoPlayingState(this.subscribeState_.video||this.subscribeState_.smallVideo)):g.updateVideoPlayingState(this.subscribeState_.auxiliary),L.next=26;break;case 23:return this.initialize(),L.next=26,this.connect();case 26:return p&&this.emitter_.emit(Ze.STREAM_SUBSCRIBED,{stream:g,result:!0}),L.abrupt("return",g);case 30:if(L.prev=30,L.t0=L.catch(0),!this.client_.getIsJoined()||!this.isStreamUnpublished(g)){L.next=35;break}throw this.log_.warn("".concat(L.t0.message," ").concat(JSON.stringify(this.trackState_))),new re({code:ee.REMOTE_STREAM_NOT_EXIST,message:"remote user ".concat(this.userId_," unpublished stream")});case 35:throw L.t0;case 36:case"end":return L.stop()}},d,this,[[0,30]])})),function(d,g){return s.apply(this,arguments)})},{key:"unsubscribe",value:(o=G(m().mark(function d(g){var I,k,w;return m().wrap(function(A){for(;;)switch(A.prev=A.next){case 0:if((I=g.getType())!==Qe){A.next=10;break}if(this.isMainStreamSubscribed){A.next=5;break}return this.log_.info("main stream already unsubscribed"),A.abrupt("return",g);case 5:this.subscribeState_.audio=!1,this.subscribeState_.video=!1,this.subscribeState_.smallVideo=!1,A.next=14;break;case 10:if(this.isAuxStreamSubscribed){A.next=13;break}return this.log_.info("auxiliary stream already unsubscribed"),A.abrupt("return",g);case 13:this.subscribeState_.auxiliary=!1;case 14:return k=Hp,(I===gt&&this.isAuxStreamSubscribed||I===Lt&&this.isMainStreamSubscribed)&&(k=zp),this.log_.info("unsubscribe ".concat(I," stream with ").concat(JSON.stringify(this.subscribeState_))),A.next=19,this.sendSubscription(k);case 19:return g.updateVideoPlayingState(!1),g.updateAudioPlayingState(!1),k===Hp&&((w=g.getMediaStream())&&w.getTracks().forEach(function(p){return w.removeTrack(p)}),this.closePeerConnection(),this.emitConnectionStateChangedEvent(on)),this.addEventInternal(sm,"unsubscribe audio"),this.addEventInternal(ZU,"unsubscribe video"),A.abrupt("return",g);case 25:case"end":return A.stop()}},d,this)})),function(d){return o.apply(this,arguments)})},{key:"sendSubscription",value:function(d){var g=this,I={srcTinyId:this.tinyId_,srcUserId:this.userId_},k=VU,w=ft.UNSUBSCRIBE_RESULT;return d===zp&&(I={audio:this.subscribeState_.audio,bigVideo:this.subscribeState_.video,auxVideo:this.subscribeState_.auxiliary,smallVideo:this.subscribeState_.smallVideo,srcTinyId:this.tinyId_},k=jU,w=ft.SUBSCRIBE_CHANGE_RESULT),this.signalChannel_.sendWaitForResponse({command:k,data:I,responseCommand:w,timeout:1e4}).then(function(A){var p=A.data;if(p.code!==0){var v=new re({code:p.code,message:ie({key:LN,data:{type:d,message:p.message}})});throw g.log_.error(v),v}})}},{key:"connect",value:(r=G(m().mark(function d(){return m().wrap(function(g){for(;;)switch(g.prev=g.next){case 0:return g.prev=0,g.next=3,this.exchangeSDP();case 3:return g.next=5,this.waitForPeerConnectionConnected();case 5:g.next=11;break;case 7:throw g.prev=7,g.t0=g.catch(0),this.closePeerConnection(!0),g.t0;case 11:case"end":return g.stop()}},d,this,[[0,7]])})),function(){return r.apply(this,arguments)})},{key:"exchangeSDP",value:(i=G(m().mark(function d(){var g,I,k,w,A,p;return m().wrap(function(v){for(;;)switch(v.prev=v.next){case 0:return v.prev=0,this.isSDPExchanging_=!0,v.next=4,this.createOffer();case 4:return this.log_.info("createOffer success, sending offer to remote server"),g=this.peerConnection_.localDescription,I=g.type,k=g.sdp,w={type:I,sdp:k,srcUserId:this.userId_,srcTinyId:this.tinyId_,audio:this.subscribeState_.audio,bigVideo:this.subscribeState_.video,auxVideo:this.subscribeState_.auxiliary,smallVideo:this.subscribeState_.smallVideo},X.emit(Yf,{client:this.client_,connection:this,userId:this.userId_,tinyId:this.tinyId_,role:fo,subscribeState:this.subscribeState_,trackState:this.trackState_}),v.next=10,this.signalChannel_.sendWaitForResponse({command:UU,commandDesc:"exchange sdp",data:w,responseCommand:ft.SUBSCRIBE_RESULT,timeout:1e4});case 10:if(A=v.sent,this.peerConnection_){v.next=15;break}throw p=new re({code:ee.INVALID_OPERATION,message:ie({key:t4})}),this.log_.warn(p),p;case 15:return v.next=17,this.onSubscribeResult(A);case 17:this.isSDPExchanging_=!1,v.next=24;break;case 20:throw v.prev=20,v.t0=v.catch(0),this.isSDPExchanging_=!1,v.t0;case 24:case"end":return v.stop()}},d,this,[[0,20]])})),function(){return i.apply(this,arguments)})},{key:"createOffer",value:(a=G(m().mark(function d(){var g,I;return m().wrap(function(k){for(;;)switch(k.prev=k.next){case 0:return g={voiceActivityDetection:!1},bm()&&this.sdpSemantics_===ic?(this.peerConnection_.addTransceiver(Ae,{direction:"recvonly"}),this.peerConnection_.addTransceiver(xe,{direction:"recvonly"}),this.peerConnection_.addTransceiver(xe,{direction:"recvonly"})):(g.offerToReceiveAudio=!0,g.offerToReceiveVideo=!0),k.next=4,this.peerConnection_.createOffer(g);case 4:return I=k.sent,k.next=7,Uk();case 7:return k.sent.isH264DecodeSupported||(this.log_.warn("remove h264 desc from sdp"),I.sdp=(w=I.sdp,A=void 0,(A=Kr(w)).media.forEach(function(p){if(p.type===xe){var v=new Set;p.rtp.forEach(function(L){var f=L.payload;return L.codec==="H264"&&v.add(f)}),p.fmtp.forEach(function(L){var f=L.payload,b=L.config.match(/apt=(\d+)/);b&&b[1]&&v.has(Number(b[1]))&&v.add(f)});var y=function(L){var f=L.payload;return!v.has(f)};p.rtp=p.rtp.filter(y),p.rtcpFb=p.rtcpFb.filter(y),p.fmtp=p.fmtp.filter(y),p.payloads=p.payloads.split(" ").filter(function(L){return!v.has(Number(L))}).join(" ")}}),To(A))),I.sdp=this.addRRTRLine(I.sdp),I.sdp=this.addSPSDescription(I.sdp),I.sdp=UV(I.sdp),this.sdpSemantics_===ic&&(I.sdp=this.removeSDESDescription(I.sdp)),k.next=16,this.peerConnection_.setLocalDescription(I);case 16:case"end":return k.stop()}var w,A},d,this)})),function(){return a.apply(this,arguments)})},{key:"onSubscribeResult",value:(n=G(m().mark(function d(g){var I,k,w,A,p,v,y,L=this;return m().wrap(function(f){for(;;)switch(f.prev=f.next){case 0:if(I=g&&g.data||{},k=I.code,w=I.message,A=w===void 0?"":w,p=g&&g.data&&g.data.data||{},v=p.type,y=p.sdp,k!==77393){f.next=5;break}throw this.log_.error(xi.NOT_SUPPORTED_H264DECODE),new re({code:ee.NOT_SUPPORTED_H264,message:ie({key:bS})});case 5:if(f.prev=5,k===0){f.next=8;break}throw new re({code:k,message:ie({key:NN,data:{errMsg:A}})});case 8:return this.log_.debug("accept remote answer: "+y),f.next=11,this.peerConnection_.setRemoteDescription({type:v,sdp:y});case 11:this.sei_&&(this.sei_.handleEncodedStreams(),this.sei_.onSEIMessage=function(b){L.emitter_.emit(Ze.SEI_MESSAGE,q(q({},b),{},{userId:L.userId_}))}),this.updateSSRC(y),f.next=19;break;case 15:throw f.prev=15,f.t0=f.catch(5),this.log_.error(f.t0),f.t0;case 19:case"end":return f.stop()}},d,this,[[5,15]])})),function(d){return n.apply(this,arguments)})},{key:"updateSSRC",value:function(d){var g=this;try{Kr(d).media.forEach(function(I){if(I.type===Ae){var k=I.ssrcs.find(function(p){return p.value.includes(Sr)});k&&(g.ssrc_.audio=k.id)}else{var w=I.ssrcs.find(function(p){return p.value.includes(Sr)}),A=I.ssrcs.find(function(p){return p.value.includes(nc)});w&&(g.ssrc_.video=w.id),A&&(g.ssrc_.auxiliary=A.id)}})}catch(I){}}},{key:"setRemoteStream",value:function(d,g){this.remoteStreams_.set(d,g)}},{key:"getSubscribeState",value:function(){return this.subscribeState_}},{key:"getTrackState",value:function(){return this.trackState_}},{key:"getSSRC",value:function(){return this.ssrc_}},{key:"getMainStream",value:function(){return this.remoteStreams_.get(Sr)}},{key:"getAuxStream",value:function(){return this.remoteStreams_.get(nc)}},{key:"getMainStreamVideoTrackId",value:function(){var d=this.getMainStream();if(d){var g=d.getVideoTrack();if(g)return g.id}return""}},{key:"getAuxStreamVideoTrackId",value:function(){var d=this.getAuxStream();if(d){var g=d.getVideoTrack();if(g)return g.id}return""}},{key:"reconnect",value:(t=G(m().mark(function d(){var g,I,k=this;return m().wrap(function(w){for(;;)switch(w.prev=w.next){case 0:if(this.reconnectionTimer_===-1){w.next=3;break}return this.log_.warn("reconnect() downlink is reconnecting, ignore current reconnection"),w.abrupt("return");case 3:if(!(this.reconnectionCount_>=30)){w.next=12;break}return this.log_.warn("SDK has tried reconnect downlink [".concat(this.userId_,"] for ").concat(30," times, but all failed, please check your network")),this.stopReconnection(),g=new re({code:ee.DOWNLINK_RECONNECTION_FAILED,message:ie({key:MN})}),Ie.logFailedEvent({userId:this.client_.getUserId(),eventType:Mb,error:g}),this.addEventInternal(kV,"downlink-connection reconnect fail"),this.emitConnectionStateChangedEvent(on),this.emitter_.emit(Ze.ERROR,g),w.abrupt("return");case 12:if(this.signalChannel_.getCurrentState()===pc){w.next=16;break}return this.log_.warn("reconnect() signal channel is not connected, suspend reconnection until signal is connected"),this.signalChannel_.once(hc,this.reconnect,this),w.abrupt("return");case 16:if(this.reconnectionCount_++,this.log_.warn("reconnect() try to reconnect downlink [".concat(this.reconnectionCount_,"/").concat(30,"]")),I=If(this.reconnectionCount_),this.reconnectionTimer_=setTimeout(function(){k.log_.warn("reconnect() downlink [".concat(k.userId_,"] reconnect timeout(").concat(I/1e3,"s), try again")),k.clearReconnectionTimer(),k.reconnect()},I),!(this.isSDPExchanging_||this.peerConnection_&&this.peerConnection_.connectionState===Qu)){w.next=22;break}return w.abrupt("return");case 22:return w.prev=22,this.closePeerConnection(),this.initialize(),w.next=27,this.connect();case 27:this.stopReconnection(),this.log_.warn("reconnect() downlink reconnect successfully"),Ie.logSuccessEvent({userId:this.client_.getUserId(),eventType:Mb}),this.addEventInternal(SV,"downlink-connection reconnect success"),this.recoverSubscription(),w.next=36;break;case 34:w.prev=34,w.t0=w.catch(22);case 36:case"end":return w.stop()}},d,this,[[22,34]])})),function(){return t.apply(this,arguments)})},{key:"recoverSubscription",value:function(){var d=this,g=this.client_.getSubscriptionManager();g&&be(this.remoteStreams_.values()).forEach(function(I){g.hasAutoRecoveryFlag(d.userId_,I.getType())&&g.recover(I)})}},{key:"getIsReconnecting",value:function(){return this.isReconnecting_}},{key:"getSubscribedMainStream",value:function(){var d=null;return this.isMainStreamSubscribed&&(d=this.remoteStreams_.get(Sr)),d}},{key:"clearReconnectionTimer",value:function(){this.reconnectionTimer_!==-1&&(clearTimeout(this.reconnectionTimer_),this.reconnectionTimer_=-1)}},{key:"startReconnection",value:function(){var d=this.client_.getSubscriptionManager();if(d){var g,I=ae(this.remoteStreams_.values());try{for(I.s();!(g=I.n()).done;){var k=g.value,w=k.getType();(w===gt&&(this.trackState_.audio||this.trackState_.video)||w===Lt&&this.trackState_.auxiliary)&&d.setAutoRecoveryFlag(this.userId_,k.getType())}}catch(A){I.e(A)}finally{I.f()}}oe(Xe(u.prototype),"startReconnection",this).call(this)}},{key:"getCurrentState",value:function(){return this.currentState_}},{key:"hasMainStream",value:function(){return this.trackState_.video||this.trackState_.audio||this.trackState_.smallVideo}},{key:"hasAuxStream",value:function(){return this.trackState_.auxiliary}}]),u}(jv),Y(sr.prototype,"subscribe",[rI,iI],Object.getOwnPropertyDescriptor(sr.prototype,"subscribe"),sr.prototype),Y(sr.prototype,"unsubscribe",[aI],Object.getOwnPropertyDescriptor(sr.prototype,"unsubscribe"),sr.prototype),Y(sr.prototype,"exchangeSDP",[oI],Object.getOwnPropertyDescriptor(sr.prototype,"exchangeSDP"),sr.prototype),sr),ud=function(){function e(){K(this,e),this.startTime=0,this.endTime=0,this.start()}return we(e,[{key:"start",value:function(){this.startTime===0&&(this.startTime=Pt())}},{key:"stop",value:function(){this.endTime===0&&(this.endTime=Pt())}},{key:"getDuration",value:function(){return this.endTime===0?Pt()-this.startTime:this.endTime-this.startTime}}]),e}(),e7=function(){function e(i){K(this,e),this.client_=i.client,this.intervalId_=-1,this.statsCalculator_=i.stats,this.prevStats_=null,this.renderFreezeMap_=new Map,this.remoteStreamMap_=new Map,this.dataFreezeMap_=new Map,this.monitorFreezeData_=new Map}var t,n,a;return we(e,[{key:"installEvents",value:function(){X.on(Jf,this.handlePlayVideoStart,this),X.on(uc,this.onVideoTrackMuted,this),X.on(zf,this.onVideoTrackUnmuted,this),X.on(ga,this.handleStreamStopped,this),X.on(qr,this.handleStreamStopped,this),X.on(cc,this.handleVideoPlaying,this)}},{key:"uninstallEvents",value:function(){X.off(Jf,this.handlePlayVideoStart,this),X.off(uc,this.onVideoTrackMuted,this),X.off(zf,this.onVideoTrackUnmuted,this),X.off(ga,this.handleStreamStopped,this),X.off(qr,this.handleStreamStopped,this),X.off(cc,this.handleVideoPlaying,this)}},{key:"start",value:function(){var i=this;this.intervalId_===-1&&(this.installEvents(),this.intervalId_=_t.run(G(m().mark(function r(){return m().wrap(function(o){for(;;)switch(o.prev=o.next){case 0:return o.prev=0,o.next=3,i.detectFPS();case 3:o.next=7;break;case 5:o.prev=5,o.t0=o.catch(0);case 7:case"end":return o.stop()}},r,null,[[0,5]])})),{delay:1e3}))}},{key:"stop",value:function(){this.intervalId_!==-1&&(this.uninstallEvents(),_t.clearTask(this.intervalId_),this.intervalId_=-1,this.renderFreezeMap_.clear(),this.dataFreezeMap_.clear(),this.remoteStreamMap_.clear())}},{key:"onVideoTrackMuted",value:function(i){var r=i.stream;if(r.getClient()===this.client_&&r.isRemote()){var o=r.userId_,s=r.type_,c="".concat(o,"_").concat(s),u=this.dataFreezeMap_.get(c),d=new ud;u?u.durationItemList.push(d):this.dataFreezeMap_.set(c,{userId:o,type:s,durationItemList:[d],isFreezing:function(){var g=this.durationItemList[this.durationItemList.length-1];return g&&g.endTime===0}})}}},{key:"onVideoTrackUnmuted",value:function(i){var r=i.stream;if(r.getClient()===this.client_&&r.isRemote()){var o=r.userId_,s=r.type_,c="".concat(o,"_").concat(s);this.stopDataFreeze({key:c,userId:o,type:s})}}},{key:"handleStreamStopped",value:function(i){var r=i.client,o=i.stream;if(r===this.client_){var s=o.getUserId(),c=o.getType(),u="".concat(s,"_").concat(c);this.stopDataFreeze({key:u,userId:s,type:c})}}},{key:"stopDataFreeze",value:function(i){var r=i.key,o=i.userId,s=i.type,c=this.dataFreezeMap_.get(r);if(c&&c.isFreezing()){var u=c.durationItemList[c.durationItemList.length-1];u.stop();var d=u.getDuration();d>500?(Ie.logEvent({eventType:"videoFrozenCount",delta:d}),this.monitorFreezeData_.set(r,{userId:o,type:s,duration:d})):c.durationItemList.pop()}}},{key:"getTotalDuration",value:function(i){return i.reduce(function(r,o){var s=o.getDuration();return r+Math.min(s,5e3)},0)}},{key:"getStats",value:(a=G(m().mark(function i(){var r,o,s,c,u,d,g,I,k,w,A;return m().wrap(function(p){for(;;)switch(p.prev=p.next){case 0:r=this.client_.getConnections(),o={},s=ae(r),p.prev=3,s.s();case 5:if((c=s.n()).done){p.next=20;break}if(u=Te(c.value,2),d=u[0],(g=u[1]).getPeerConnection()){p.next=9;break}return p.abrupt("continue",18);case 9:return I=g.getSubscribeState(),k=g.getTrackState(),p.next=13,this.statsCalculator_.getReceiverStats(g);case 13:w=p.sent,(A={userId:w.userId,tinyId:d,hasVideo:k.video&&I.video,hasAuxiliary:k.auxiliary&&I.auxiliary,video:{framesDecoded:0},auxiliary:{framesDecoded:0}}).hasVideo&&(A.video.framesDecoded=w.video.framesDecoded),A.hasAuxiliary&&(A.auxiliary.framesDecoded=w.auxiliary.framesDecoded),o[w.userId]=A;case 18:p.next=5;break;case 20:p.next=25;break;case 22:p.prev=22,p.t0=p.catch(3),s.e(p.t0);case 25:return p.prev=25,s.f(),p.finish(25);case 28:return p.abrupt("return",o);case 29:case"end":return p.stop()}},i,this,[[3,22,25,28]])})),function(){return a.apply(this,arguments)})},{key:"detectFPS",value:(n=G(m().mark(function i(){var r,o,s,c,u,d;return m().wrap(function(g){for(;;)switch(g.prev=g.next){case 0:return g.next=2,this.getStats();case 2:if(r=g.sent,this.prevStats_){g.next=6;break}return this.prevStats_=r,g.abrupt("return");case 6:g.t0=m().keys(r);case 7:if((g.t1=g.t0()).done){g.next=17;break}if(o=g.t1.value,this.prevStats_[o]){g.next=11;break}return g.abrupt("continue",7);case 11:s=r[o].tinyId,c=this.client_.getMutedStates(),r[o].hasVideo&&this.prevStats_[o].hasVideo&&c.has(s)&&!c.get(s).videoMuted&&(u=r[o].video.framesDecoded-this.prevStats_[o].video.framesDecoded,this.handleRenderFreeze({userId:o,type:gt,fps:u})),r[o].hasAuxiliary&&this.prevStats_[o].hasAuxiliary&&(d=r[o].auxiliary.framesDecoded-this.prevStats_[o].auxiliary.framesDecoded,this.handleRenderFreeze({userId:o,type:Lt,fps:d})),g.next=7;break;case 17:this.prevStats_=r;case 18:case"end":return g.stop()}},i,this)})),function(){return n.apply(this,arguments)})},{key:"handleRenderFreeze",value:(t=G(m().mark(function i(r){var o,s,c,u,d,g,I,k;return m().wrap(function(w){for(;;)switch(w.prev=w.next){case 0:o=r.userId,s=r.fps,c=r.type,u="".concat(o,"_").concat(c),d=this.renderFreezeMap_.get(u),s<=2?(g=Pt(),d&&!d.isFreeze&&(d.freezeTimeline.push({startTime:g,endTime:void 0}),d.isFreeze=!0),d||this.renderFreezeMap_.set(u,{userId:o,type:c,isFreeze:!0,freezeTimeline:[{startTime:g,endTime:void 0}],renderFreezeTotal:0})):d&&d.isFreeze&&(d.isFreeze=!1,(I=d.freezeTimeline.pop()).endTime=Pt(),k=I.endTime-I.startTime,d.freezeTimeline.push(I),d.renderFreezeTotal+=Math.min(5e3,k));case 4:case"end":return w.stop()}},i,this)})),function(i){return t.apply(this,arguments)})},{key:"handlePlayVideoStart",value:function(i){var r=i.stream;if(r.getClient()===this.client_&&r.isRemote()&&r.hasVideo()){var o="".concat(r.getUserId(),"_").concat(r.getType());this.remoteStreamMap_.has(o)||this.remoteStreamMap_.set(o,{isPlayingFired:!1})}}},{key:"handleVideoPlaying",value:function(i){var r=i.stream;if(r.isRemote()&&r.getClient()===this.client_){var o="".concat(r.getUserId(),"_").concat(r.getType());this.remoteStreamMap_.has(o)&&(this.remoteStreamMap_.get(o).isPlayingFired=!0)}}},{key:"getDataFreezeDuration",value:function(i){var r={dataFreeze:0,count:0},o=this.dataFreezeMap_.get(i);if(o){if(o.isFreezing()){var s=o.durationItemList[o.durationItemList.length-1];s.stop(),s.getDuration()<500&&o.durationItemList.pop()}r.dataFreeze=this.getTotalDuration(o.durationItemList),r.count=o.durationItemList.length}return r}},{key:"getRenderFreezeDuration",value:function(i){var r=this.renderFreezeMap_.get(i),o=0,s=0;if(r)if(r.isFreeze){var c=Pt()-r.freezeTimeline[r.freezeTimeline.length-1].startTime;o=r.renderFreezeTotal+Math.min(c,5e3),s=r.freezeTimeline.length}else o=r.renderFreezeTotal;return{renderFreeze:o,count:s}}},{key:"getMonitorFreeze",value:function(){return this.monitorFreezeData_}},{key:"isBlackStream",value:function(i){return!!this.remoteStreamMap_.has(i)&&!this.remoteStreamMap_.get(i).isPlayingFired}},{key:"resetMonitor",value:function(){this.monitorFreezeData_.clear()}}]),e}(),Qv=we(function e(t){K(this,e),this.userId=t.userId,this.tinyId=t.tinyId,this.role=t.role===fo?br:ca}),cI={exports:{}};(function(e){(function(t){function n(p,v){var y=(65535&p)+(65535&v);return(p>>16)+(v>>16)+(y>>16)<<16|65535&y}function a(p,v,y,L,f,b){return n((P=n(n(v,p),n(L,b)))<<(S=f)|P>>>32-S,y);var P,S}function i(p,v,y,L,f,b,P){return a(v&y|~v&L,p,v,f,b,P)}function r(p,v,y,L,f,b,P){return a(v&L|y&~L,p,v,f,b,P)}function o(p,v,y,L,f,b,P){return a(v^y^L,p,v,f,b,P)}function s(p,v,y,L,f,b,P){return a(y^(v|~L),p,v,f,b,P)}function c(p,v){var y,L,f,b,P;p[v>>5]|=128<<v%32,p[14+(v+64>>>9<<4)]=v;var S=1732584193,T=-271733879,C=-1732584194,D=271733878;for(y=0;y<p.length;y+=16)L=S,f=T,b=C,P=D,S=i(S,T,C,D,p[y],7,-680876936),D=i(D,S,T,C,p[y+1],12,-389564586),C=i(C,D,S,T,p[y+2],17,606105819),T=i(T,C,D,S,p[y+3],22,-1044525330),S=i(S,T,C,D,p[y+4],7,-176418897),D=i(D,S,T,C,p[y+5],12,1200080426),C=i(C,D,S,T,p[y+6],17,-1473231341),T=i(T,C,D,S,p[y+7],22,-45705983),S=i(S,T,C,D,p[y+8],7,1770035416),D=i(D,S,T,C,p[y+9],12,-1958414417),C=i(C,D,S,T,p[y+10],17,-42063),T=i(T,C,D,S,p[y+11],22,-1990404162),S=i(S,T,C,D,p[y+12],7,1804603682),D=i(D,S,T,C,p[y+13],12,-40341101),C=i(C,D,S,T,p[y+14],17,-1502002290),S=r(S,T=i(T,C,D,S,p[y+15],22,1236535329),C,D,p[y+1],5,-165796510),D=r(D,S,T,C,p[y+6],9,-1069501632),C=r(C,D,S,T,p[y+11],14,643717713),T=r(T,C,D,S,p[y],20,-373897302),S=r(S,T,C,D,p[y+5],5,-701558691),D=r(D,S,T,C,p[y+10],9,38016083),C=r(C,D,S,T,p[y+15],14,-660478335),T=r(T,C,D,S,p[y+4],20,-405537848),S=r(S,T,C,D,p[y+9],5,568446438),D=r(D,S,T,C,p[y+14],9,-1019803690),C=r(C,D,S,T,p[y+3],14,-187363961),T=r(T,C,D,S,p[y+8],20,1163531501),S=r(S,T,C,D,p[y+13],5,-1444681467),D=r(D,S,T,C,p[y+2],9,-51403784),C=r(C,D,S,T,p[y+7],14,1735328473),S=o(S,T=r(T,C,D,S,p[y+12],20,-1926607734),C,D,p[y+5],4,-378558),D=o(D,S,T,C,p[y+8],11,-2022574463),C=o(C,D,S,T,p[y+11],16,1839030562),T=o(T,C,D,S,p[y+14],23,-35309556),S=o(S,T,C,D,p[y+1],4,-1530992060),D=o(D,S,T,C,p[y+4],11,1272893353),C=o(C,D,S,T,p[y+7],16,-155497632),T=o(T,C,D,S,p[y+10],23,-1094730640),S=o(S,T,C,D,p[y+13],4,681279174),D=o(D,S,T,C,p[y],11,-358537222),C=o(C,D,S,T,p[y+3],16,-722521979),T=o(T,C,D,S,p[y+6],23,76029189),S=o(S,T,C,D,p[y+9],4,-640364487),D=o(D,S,T,C,p[y+12],11,-421815835),C=o(C,D,S,T,p[y+15],16,530742520),S=s(S,T=o(T,C,D,S,p[y+2],23,-995338651),C,D,p[y],6,-198630844),D=s(D,S,T,C,p[y+7],10,1126891415),C=s(C,D,S,T,p[y+14],15,-1416354905),T=s(T,C,D,S,p[y+5],21,-57434055),S=s(S,T,C,D,p[y+12],6,1700485571),D=s(D,S,T,C,p[y+3],10,-1894986606),C=s(C,D,S,T,p[y+10],15,-1051523),T=s(T,C,D,S,p[y+1],21,-2054922799),S=s(S,T,C,D,p[y+8],6,1873313359),D=s(D,S,T,C,p[y+15],10,-30611744),C=s(C,D,S,T,p[y+6],15,-1560198380),T=s(T,C,D,S,p[y+13],21,1309151649),S=s(S,T,C,D,p[y+4],6,-145523070),D=s(D,S,T,C,p[y+11],10,-1120210379),C=s(C,D,S,T,p[y+2],15,718787259),T=s(T,C,D,S,p[y+9],21,-343485551),S=n(S,L),T=n(T,f),C=n(C,b),D=n(D,P);return[S,T,C,D]}function u(p){var v,y="",L=32*p.length;for(v=0;v<L;v+=8)y+=String.fromCharCode(p[v>>5]>>>v%32&255);return y}function d(p){var v,y=[];for(y[(p.length>>2)-1]=void 0,v=0;v<y.length;v+=1)y[v]=0;var L=8*p.length;for(v=0;v<L;v+=8)y[v>>5]|=(255&p.charCodeAt(v/8))<<v%32;return y}function g(p){var v,y,L="0123456789abcdef",f="";for(y=0;y<p.length;y+=1)v=p.charCodeAt(y),f+=L.charAt(v>>>4&15)+L.charAt(15&v);return f}function I(p){return unescape(encodeURIComponent(p))}function k(p){return function(v){return u(c(d(v),8*v.length))}(I(p))}function w(p,v){return function(y,L){var f,b,P=d(y),S=[],T=[];for(S[15]=T[15]=void 0,P.length>16&&(P=c(P,8*y.length)),f=0;f<16;f+=1)S[f]=909522486^P[f],T[f]=1549556828^P[f];return b=c(S.concat(d(L)),512+8*L.length),u(c(T.concat(b),640))}(I(p),I(v))}function A(p,v,y){return v?y?w(v,p):g(w(v,p)):y?k(p):g(k(p))}e.exports?e.exports=A:t.md5=A})(z)})(cI);var ld=cI.exports,t7=function(){function e(r){K(this,e),this.client_=r.client,this.signalChannel_=r.signalChannel,this.log_=_e.createLogger({id:"mix|"+this.client_.getUserId(),userId:r.client.getUserId(),sdkAppId:r.client.getSDKAppId()}),this.isMixing_=!1,this.config_=null,this.data_=null,this.remoteStreamMap_=new Map,this.installEvents()}var t,n,a,i;return we(e,[{key:"isPresetLayoutMode",get:function(){return this.config_&&this.config_.mode===qp.PRESET_LAYOUT}},{key:"installEvents",value:function(){X.on(Wr,this.onStreamSubscribed,this),X.on(qr,this.onStreamUnsubscribed,this),this.client_.on("stream-removed",this.onStreamRemoved,this)}},{key:"uninstallEvents",value:function(){X.off(Wr,this.onStreamSubscribed,this),X.off(qr,this.onStreamUnsubscribed,this),this.client_.off("stream-removed",this.onStreamRemoved,this)}},{key:"reset",value:function(){this.uninstallEvents(),this.isMixing_=!1,this.config_=null}},{key:"onStreamSubscribed",value:function(r){var o=r.client,s=r.stream;o===this.client_&&(this.remoteStreamMap_.set(s.getId(),{remoteStream:s,isUsed:!1}),this.isMixing_&&this.hasAvailablePlaceHolder()&&this.startMixTranscode(this.config_))}},{key:"onStreamUnsubscribed",value:function(r){var o=r.client,s=r.stream;o===this.client_&&this.onStreamRemoved({stream:s})}},{key:"onStreamRemoved",value:function(r){var o=r.stream;if(this.remoteStreamMap_.has(o.getId())){var s=this.remoteStreamMap_.get(o.getId()).isUsed;this.remoteStreamMap_.delete(o.getId()),this.isMixing_&&this.isPresetLayoutMode&&s&&this.startMixTranscode(this.config_)}}},{key:"startMixTranscode",value:(i=G(m().mark(function r(o){var s,c,u;return m().wrap(function(d){for(;;)switch(d.prev=d.next){case 0:if(d.prev=0,this.resetIsUsedFlag(),this.config_=o,s=this.getInputParam(o,this.remoteStreamMap_),c=this.getOutputParam(o),u=this.getOutputSessionId({config:o,roomId:this.client_.getRoomId(),userId:this.client_.getUserId()}),!this.isMixing_||!this.data_||u===this.data_.outputSessionId){d.next=10;break}return this.log_.info("startMixTranscode() streamId changed, stop mixing before start"),d.next=10,this.doStopMixTranscode();case 10:return d.next=12,this.doStartMixTranscode({outputSessionId:u,inputParam:s,outputParam:c});case 12:d.next=18;break;case 14:throw d.prev=14,d.t0=d.catch(0),this.resetIsUsedFlag(),d.t0;case 18:case"end":return d.stop()}},r,this,[[0,14]])})),function(r){return i.apply(this,arguments)})},{key:"doStartMixTranscode",value:(a=G(m().mark(function r(o){var s,c,u,d,g,I,k,w;return m().wrap(function(A){for(;;)switch(A.prev=A.next){case 0:return s=o.outputSessionId,c=o.inputParam,u=o.outputParam,d={roomId:String(this.client_.getRoomId()),mcuRequestTime:Date.now(),outputSessionId:s,inputParam:c,outputParam:u},this.data_=d,this.log_.info("startMixTranscode: ".concat(JSON.stringify(d))),this.isMixing_=!0,A.prev=5,A.next=8,this.signalChannel_.sendWaitForResponse({command:zU,data:d,timeout:5e3,responseCommand:ft.START_MIX_TRANSCODE_RES,commandDesc:"startMixTranscode"});case 8:if(g=A.sent,I=g.data,k=I.code,w=I.message,k===0){A.next=15;break}throw k===-102083&&(w="Please enable relayed-push in ".concat(eS," and try later, refer to ").concat(Yp,"tutorial-26-advanced-publish-cdn-stream.html")),this.log_.error("startMixTranscode failed, errCode: ".concat(k," errMsg: ").concat(w)),this.isMixing_=!1,new re({code:ee.START_MIX_TRANSCODE_FAILED,message:ie({key:P3,data:{message:w},link:{className:"Client",fnName:"startMixTranscode"}})});case 15:A.next=21;break;case 17:throw A.prev=17,A.t0=A.catch(5),this.isMixing_=!1,A.t0;case 21:case"end":return A.stop()}},r,this,[[5,17]])})),function(r){return a.apply(this,arguments)})},{key:"reStartMixTranscode",value:function(){this.isMixing_&&this.startMixTranscode(this.config_)}},{key:"stopMixTranscode",value:(n=G(m().mark(function r(){return m().wrap(function(o){for(;;)switch(o.prev=o.next){case 0:if(this.isMixing_){o.next=2;break}throw new re({code:ee.INVALID_OPERATION,message:ie({key:L3})});case 2:return o.next=4,this.doStopMixTranscode();case 4:this.resetIsUsedFlag();case 5:case"end":return o.stop()}},r,this)})),function(){return n.apply(this,arguments)})},{key:"doStopMixTranscode",value:(t=G(m().mark(function r(){var o,s,c,u,d;return m().wrap(function(g){for(;;)switch(g.prev=g.next){case 0:return o={mcuRequestTime:Date.now(),outputSessionId:this.data_.outputSessionId,streamType:this.data_.outputParam.streamType},this.log_.info("stopMixTranscode: ".concat(JSON.stringify(o))),g.next=4,this.signalChannel_.sendWaitForResponse({command:WU,data:o,timeout:5e3,responseCommand:ft.STOP_MIX_TRANSCODE_RES,commandDesc:"stopMixTranscode"});case 4:if(s=g.sent,c=s.data,u=c.code,d=c.message,u!==0){g.next=10;break}this.isMixing_=!1,g.next=12;break;case 10:throw this.log_.error("stopMixTranscode failed, errCode: ".concat(u," errMsg: ").concat(d)),new re({code:ee.STOP_MIX_TRANSCODE_FAILED,message:ie({key:D3,data:{message:d},link:{className:"Client",fnName:"stopMixTranscode"}})});case 12:case"end":return g.stop()}},r,this)})),function(){return t.apply(this,arguments)})},{key:"getOutputSessionId",value:function(r){var o=r.config,s=r.userId,c=r.roomId;return Vt(o.streamId)&&o.streamId.length>0?o.streamId:ld("".concat(c,"_").concat(s,"_main"))}},{key:"getInputParam",value:function(r,o){var s=this,c=r.mixUsers.map(function(u){return{userId:u.userId,roomId:String(u.roomId||s.client_.getRoomId()),width:u.width||0,height:u.height||0,locationX:u.locationX||0,locationY:u.locationY||0,zOrder:u.zOrder,streamType:ge(u.streamType)||u.streamType!==Lt?0:1,inputType:u.pureAudio?qb.IT_PURE_AUDIO:qb.IT_AUDIO_VIDEO,renderMode:u.renderMode||0}});return r.mode===qp.PRESET_LAYOUT&&(c.forEach(function(u){if(u.userId===Wb.REMOTE){var d=be(o.values()).find(function(g){return!g.isUsed});d&&(u.userId=d.remoteStream.getUserId(),u.streamType=d.remoteStream.getType()===Lt?1:0,d.isUsed=!0)}}),c=c.filter(function(u){return u.userId!==Wb.REMOTE})),c}},{key:"getOutputParam",value:function(r){var o=r.streamId||"";return{streamId:o,streamType:o.length>0?1:0,width:ge(r.videoWidth)?640:r.videoWidth,height:ge(r.videoHeight)?480:r.videoHeight,videoBps:r.videoBitrate||0,fps:r.videoFramerate||15,gop:r.videoGOP||2,audioSampleRate:r.audioSampleRate||48e3,audioBps:r.audioBitrate||64,audioChannels:r.audioChannels||1,backgroundColor:r.backgroundColor||0,backgroundImg:r.backgroundImage||"",extraInfo:"",videoCodec:2,audioCodec:0}}},{key:"hasAvailablePlaceHolder",value:function(){return!!this.isPresetLayoutMode&&this.data_.inputParam.length!==this.config_.mixUsers.length}},{key:"resetIsUsedFlag",value:function(){this.remoteStreamMap_.forEach(function(r){return r.isUsed=!1})}}]),e}(),n7=function(){function e(s){K(this,e),this.client_=s.client,this.signalChannel_=s.signalChannel,this.publishTencentMainStreamObj_={params_:null,streamId_:void 0,isPublishing_:!1},this.publishTencentAuxStreamObj_={params_:null,streamId_:void 0,isPublishing_:!1},this.publishGivenCDNData_=null,this.isPublishingGivenCDN_=!1}var t,n,a,i,r,o;return we(e,[{key:"setSignalChannel",value:function(s){this.signalChannel_=s.signalChannel}},{key:"getIsPublishingTencentCDN",value:function(){return this.publishTencentMainStreamObj_.isPublishing_||this.publishTencentAuxStreamObj_.isPublishing_}},{key:"getIsPublishingGivenCDN",value:function(){return this.isPublishingGivenCDN_}},{key:"generatePublishCDNStreamId",value:function(s,c){if(!s){var u="".concat(this.client_.getRoomId(),"_").concat(this.client_.getUserId(),"_").concat(c);return/^[A-Za-z\d_-]*$/.test(u)||(u=ld(u)),"".concat(this.client_.getSDKAppId(),"_").concat(u)}return s}},{key:"generatePublishCDNSessionId",value:function(s){return ld("".concat(this.client_.getRoomId(),"_").concat(this.client_.getUserId(),"_").concat(s))}},{key:"startPublishTencentCDN",value:(o=G(m().mark(function s(c){var u,d,g,I;return m().wrap(function(k){for(;;)switch(k.prev=k.next){case 0:if(c.streamType===Mn?(this.publishTencentAuxStreamObj_.params_=c,this.publishTencentAuxStreamObj_.isPublishing_=!0):(this.publishTencentMainStreamObj_.params_=c,this.publishTencentMainStreamObj_.isPublishing_=!0),this.client_.isJoined_){k.next=3;break}return k.abrupt("return");case 3:return u=this.generatePublishCDNStreamId(c.streamId,c.streamType),d=this.generatePublishCDNSessionId(c.streamType),g=c.streamType===Mn?1:0,I={requestTime:Date.now(),sessionId:d,streamId:u,streamType:g},k.next=9,this.doStartPublishTencentCDN(I,c.streamType);case 9:case"end":return k.stop()}},s,this)})),function(s){return o.apply(this,arguments)})},{key:"doStartPublishTencentCDN",value:(r=G(m().mark(function s(c,u){var d,g,I,k;return m().wrap(function(w){for(;;)switch(w.prev=w.next){case 0:return w.prev=0,_e.info("startPublishTencentCDN: "+JSON.stringify(c)),w.next=4,this.signalChannel_.sendWaitForResponseWithRetry({command:BU,data:c,timeout:2e3,responseCommand:ft.START_PUBLISH_TENCENT_CDN_RES,commandDesc:"startPublishCDNStream",retries:2});case 4:if(d=w.sent,g=d.data,I=g.code,k=g.message,I!==0){w.next=10;break}u===Mn?this.publishTencentAuxStreamObj_.streamId_=c.streamId:this.publishTencentMainStreamObj_.streamId_=c.streamId,w.next=14;break;case 10:throw u===Mn?this.publishTencentAuxStreamObj_.isPublishing_=!1:this.publishTencentMainStreamObj_.isPublishing_=!1,I===-102083&&(k="Please enable relayed-push in ".concat(eS," and try later, refer to ").concat(Yp,"tutorial-26-advanced-publish-cdn-stream.html")),_e.error("startPublishTencentCDN failed, errCode: ".concat(I,", errMsg: ").concat(k)),new re({code:ee.START_PUBLISH_CDN_FAILED,message:ie({key:pS,data:{message:k},link:{className:"Client",fnName:"startPublishCDNStream"}})});case 14:w.next=20;break;case 16:throw w.prev=16,w.t0=w.catch(0),u===Mn?this.publishTencentAuxStreamObj_.isPublishing_=!1:this.publishTencentMainStreamObj_.isPublishing_=!1,w.t0;case 20:case"end":return w.stop()}},s,this,[[0,16]])})),function(s,c){return r.apply(this,arguments)})},{key:"resetPublishTencentParam",value:function(s){s===Qe&&(this.publishTencentMainStreamObj_={params_:null,streamId_:void 0,isPublishing_:!1}),s===Mn&&(this.publishTencentAuxStreamObj_={params_:null,streamId_:void 0,isPublishing_:!1})}},{key:"stopPublishTencentCDN",value:(i=G(m().mark(function s(){return m().wrap(function(c){for(;;)switch(c.prev=c.next){case 0:if(this.client_.isJoined_){c.next=4;break}return this.resetPublishTencentParam(Qe),this.resetPublishTencentParam(Mn),c.abrupt("return");case 4:if(!this.publishTencentMainStreamObj_.isPublishing_){c.next=7;break}return c.next=7,this.doStopPublishTencentCDN(Qe);case 7:if(!this.publishTencentAuxStreamObj_.isPublishing_){c.next=10;break}return c.next=10,this.doStopPublishTencentCDN(Mn);case 10:case"end":return c.stop()}},s,this)})),function(){return i.apply(this,arguments)})},{key:"doStopPublishTencentCDN",value:(a=G(m().mark(function s(c){var u,d,g,I,k;return m().wrap(function(w){for(;;)switch(w.prev=w.next){case 0:return u={requestTime:Date.now(),sessionId:ld("".concat(this.client_.getRoomId(),"_").concat(this.client_.getUserId(),"_").concat(c))},_e.info("stopPublishTencentCDN: "+JSON.stringify(u)),w.next=4,this.signalChannel_.sendWaitForResponse({command:FU,data:u,timeout:5e3,responseCommand:ft.STOP_PUBLISH_TENCENT_CDN_RES,commandDesc:"stopPublishCDNStream"});case 4:if(d=w.sent,g=d.data,I=g.code,k=g.message,I!==0){w.next=10;break}this.resetPublishTencentParam(c),w.next=17;break;case 10:if(I!==-102069){w.next=15;break}_e.warn("stopPublishTencentCDN failed, can not stopPublishTencentCDN in auto relayed-push mode"),this.resetPublishTencentParam(c),w.next=17;break;case 15:throw _e.error("stopPublishTencentCDN failed, errCode: ".concat(I," errMsg: ").concat(k)),new re({code:ee.STOP_PUBLISH_CDN_FAILED,message:ie({key:fS,data:{message:k},link:{className:"Client",fnName:"stopPublishCDNStream"}})});case 17:case"end":return w.stop()}},s,this)})),function(s){return a.apply(this,arguments)})},{key:"startPublishGivenCDN",value:(n=G(m().mark(function s(c){var u,d,g,I,k,w;return m().wrap(function(A){for(;;)switch(A.prev=A.next){case 0:if(u=c.streamType===Qe?this.publishTencentMainStreamObj_.streamId_:this.publishTencentAuxStreamObj_.streamId_,d={pushRequestTime:Date.now(),pushAppId:c.appId,pushBizId:c.bizId,pushCdnUrl:c.url,pushStreamType:c.streamType,pushStreamId:u},_e.info("startPublishGivenCDN: "+JSON.stringify(d)),this.publishGivenCDNData_=d,this.isPublishingGivenCDN_=!0,this.client_.isJoined_){A.next=7;break}return A.abrupt("return");case 7:return A.prev=7,A.next=10,this.signalChannel_.sendWaitForResponse({command:GU,data:d,timeout:5e3,responseCommand:ft.START_PUBLISH_GIVEN_CDN_RES,commandDesc:"startPublishCDNStream"});case 10:if(g=A.sent,I=g.data,k=I.code,w=I.message,k===0){A.next=17;break}throw _e.error("startPublishGivenCDN failed, errCode: ".concat(k,", errMsg: ").concat(w)),this.publishGivenCDNData_=null,this.isPublishingGivenCDN_=!1,new re({code:ee.START_PUBLISH_CDN_FAILED,message:ie({key:pS,data:{message:w},link:{className:"Client",fnName:"startPublishCDNStream"}})});case 17:A.next=24;break;case 19:throw A.prev=19,A.t0=A.catch(7),this.publishGivenCDNData_=null,this.isPublishingGivenCDN_=!1,A.t0;case 24:case"end":return A.stop()}},s,this,[[7,19]])})),function(s){return n.apply(this,arguments)})},{key:"stopPublishGivenCDN",value:(t=G(m().mark(function s(){var c,u,d,g,I,k,w,A,p,v;return m().wrap(function(y){for(;;)switch(y.prev=y.next){case 0:if(this.client_.isJoined_){y.next=4;break}return this.publishGivenCDNData_=null,this.isPublishingGivenCDN_=!1,y.abrupt("return");case 4:return c=this.publishGivenCDNData_,u=c.pushAppId,d=c.pushBizId,g=c.pushCdnUrl,I=c.pushStreamType,k={pushRequestTime:Date.now(),pushAppId:u,pushBizId:d,pushCdnUrl:g,pushStreamType:I},_e.info("stopPublishGivenCDN: "+JSON.stringify(k)),y.next=9,this.signalChannel_.sendWaitForResponse({command:HU,data:k,timeout:5e3,responseCommand:ft.STOP_PUBLISH_GIVEN_CDN_RES,commandDesc:"stopPublishCDNStream"});case 9:if(w=y.sent,A=w.data,p=A.code,v=A.message,p!==0){y.next=16;break}this.publishGivenCDNData_=null,this.isPublishingGivenCDN_=!1,y.next=18;break;case 16:throw _e.error("stopPublishGivenCDN failed, errCode: ".concat(p," errMsg: ").concat(v)),new re({code:ee.STOP_PUBLISH_CDN_FAILED,message:ie({key:fS,data:{message:v},link:{className:"Client",fnName:"stopPublishCDNStream"}})});case 18:case"end":return y.stop()}},s,this)})),function(){return t.apply(this,arguments)})},{key:"handleCDNConfigForJoinData",value:function(s){var c,u=s;if(this.publishTencentMainStreamObj_.isPublishing_||this.publishTencentAuxStreamObj_.isPublishing_){var d={};Vt(u)&&(d=JSON.parse(u)),d.Str_uc_params||(d.Str_uc_params={}),this.publishTencentMainStreamObj_.isPublishing_&&(this.publishTencentMainStreamObj_.streamId_?d.Str_uc_params.userdefine_streamid_main=this.publishTencentMainStreamObj_.streamId_:this.publishTencentMainStreamObj_.params_&&(d.Str_uc_params.userdefine_streamid_main=this.generatePublishCDNStreamId(this.publishTencentMainStreamObj_.params_.streamId,Qe))),this.publishTencentAuxStreamObj_.isPublishing_&&(this.publishTencentAuxStreamObj_.streamId_?d.Str_uc_params.userdefine_streamid_aux=this.publishTencentAuxStreamObj_.streamId_:this.publishTencentAuxStreamObj_.params_&&(d.Str_uc_params.userdefine_streamid_aux=this.generatePublishCDNStreamId(this.publishTencentAuxStreamObj_.params_.streamId,Mn))),u=JSON.stringify(d)}if(this.isPublishingGivenCDN_){var g=this.publishGivenCDNData_,I=g.pushAppId,k=g.pushBizId,w=g.pushCdnUrl,A=g.pushStreamType,p=g.pushStreamId;c={pushRequestTime:Date.now(),pushAppId:I,pushBizId:k,pushCdnUrl:w,pushStreamType:A,pushStreamId:p}}return{bussinessInfo:u,pushUserCdnInfo:c}}},{key:"reset",value:function(){this.resetPublishTencentParam(Qe),this.resetPublishTencentParam(Mn),this.publishGivenCDNData_=null,this.isPublishingGivenCDN_=!1}}]),e}(),r7=function(){function e(t){K(this,e),this.client_=t.client,this.durationMap_=new Map,this.installEvents()}return we(e,[{key:"installEvents",value:function(){X.on(Wr,this.handleSubscribed,this),X.on(Un,this.handleStreamTrackUpdated,this),X.on(qr,this.handleStreamStopped,this),X.on(ga,this.handleStreamStopped,this)}},{key:"uninstallEvents",value:function(){X.off(Wr,this.handleSubscribed,this),X.off(Un,this.handleStreamTrackUpdated,this),X.off(qr,this.handleStreamStopped,this),X.off(ga,this.handleStreamStopped,this)}},{key:"handleSubscribed",value:function(t){var n=t.client,a=t.stream;if(n===this.client_){var i=a.getUserId(),r=a.getType(),o="".concat(i,"_").concat(r);if(a.hasAudio())if(a.isMainAudioSubscribed){var s=new ud,c=this.durationMap_.get(o);c?this.isRecording(c.audio)||c.audio.push(s):this.durationMap_.set(o,{userId:i,type:r,audio:[s],video:[]})}else this.stopDurationItem(o,Ae);if(a.hasVideo())if(r===gt&&a.isMainVideoSubscribed||r===Lt&&a.isAuxVideoSubscribed){var u=new ud,d=this.durationMap_.get(o);d?this.isRecording(d.video)||d.video.push(u):this.durationMap_.set(o,{userId:i,type:r,audio:[],video:[u]})}else this.stopDurationItem(o,xe)}}},{key:"handleStreamStopped",value:function(t){var n=t.client,a=t.stream;if(this.clientHitTest(n)){var i=a.getUserId(),r=a.getType(),o="".concat(i,"_").concat(r);this.stopDurationItem(o,Ae),this.stopDurationItem(o,xe)}}},{key:"handleStreamTrackUpdated",value:function(t){var n=t.client,a=t.userId,i=t.tinyId,r=t.kind,o=t.action;if(this.clientHitTest(n)&&this.client_.getConnections().has(i)){var s=r===pt?r:gt,c="".concat(a,"_").concat(s);if(o===cn.ADD){var u=this.client_.getConnections().get(i).getSubscribeState();if(r===Ae&&!u.audio||r===xe&&!u.video||r===pt&&!u.auxiliary)return;var d=new ud,g=this.durationMap_.get(c);g?(r!==Ae||this.isRecording(g.audio)||g.audio.push(d),r===Ae||this.isRecording(g.video)||g.video.push(d)):this.durationMap_.set(c,{userId:a,type:s,audio:r===Ae?[d]:[],video:r===Ae?[]:[d]})}else this.stopDurationItem(c,r===Ae?Ae:xe)}}},{key:"isRecording",value:function(t){return t.findIndex(function(n){return n.endTime===0})>=0}},{key:"stopDurationItem",value:function(t,n){if(this.durationMap_.has(t)){var a=this.durationMap_.get(t)[n].find(function(i){return i.endTime===0});a&&a.stop()}}},{key:"clientHitTest",value:function(t){return this.client_===t}},{key:"getDuration",value:function(t,n){return this.durationMap_.has(t)?this.durationMap_.get(t)[n].reduce(function(a,i){return a+i.getDuration()},0):0}},{key:"getDurationMap",value:function(){return this.durationMap_}},{key:"reset",value:function(){this.durationMap_.clear()}},{key:"destroy",value:function(){this.client_=null,this.uninstallEvents()}}]),e}();function Lc(){return function(e,t,n){var a=n.value,i=new Set;return n.value=G(m().mark(function r(){var o,s,c,u,d=arguments;return m().wrap(function(g){for(;;)switch(g.prev=g.next){case 0:if(!i.has(this)){g.next=2;break}throw new re({code:ee.INVALID_OPERATION,message:ie({key:wN,data:{name:t}})});case 2:for(g.prev=2,i.add(this),o=d.length,s=new Array(o),c=0;c<o;c++)s[c]=d[c];return g.next=7,a.apply(this,s);case 7:return u=g.sent,i.delete(this),g.abrupt("return",u);case 12:throw g.prev=12,g.t0=g.catch(2),i.delete(this),g.t0;case 16:case"end":return g.stop()}},r,this,[[2,12]])})),n}}var Yv=null,$v=!0;function Ea(e){er(e)&&e!==$v&&($v=e,_e.info("setIsNeedToSchedule "+e))}function i7(e){return Zv.apply(this,arguments)}function Zv(){return Zv=G(m().mark(function e(t){var n,a,i,r,o,s,c,u,d,g,I,k,w;return m().wrap(function(A){for(;;)switch(A.prev=A.next){case 0:if(n=t.userId,a=t.sdkAppId,i=t.useStringRoomId,r=t.roomId,o=t.userSig,$v||!Yv){A.next=3;break}return A.abrupt("return",{isCached:!0,result:Yv});case 3:return s={delta:0,count:[1,1],msg:[]},A.prev=4,(c=new FormData).append("userId",String(n)),c.append("sdkAppId",String(a)),c.append("isStrGroupId",i),c.append("groupId",String(r)),c.append("sdkVersion",pi),c.append("userSig",String(o)),Kp&&c.append("oversea",!0),u=Pt(),A.next=16,o7(c,s,a);case 16:return(d=A.sent).config&&(d.config.loggerDomain&&Up(d.config.loggerDomain),er(d.config.scheduleCache)&&Ea(!d.config.scheduleCache)),s.delta=Pt()-u,uI({stat:s,userId:n}),Yv=d,A.abrupt("return",{isCached:!1,result:d});case 24:throw A.prev=24,A.t0=A.catch(4),g=_o(A.t0)?A.t0[0]:A.t0,I=Zn(g.code)?g.code:0,k="get websocket url failed: ".concat(g.message.includes("timeout")?"timeout":g.message),w=new re({code:ee.SCHEDULE_FAILED,extraCode:I,message:ie({key:dS,data:{error:k,code:I}})}),_e.error(w),uI({stat:s,userId:n,roomId:r,error:w}),w;case 33:case"end":return A.stop()}},e,null,[[4,24]])})),Zv.apply(this,arguments)}function uI(e){var t=e.stat,n=e.userId,a=e.error;a?Ie.logFailedEvent({eventType:zb,error:a,userId:n}):Ie.logSuccessEvent({eventType:zb,delta:t.delta,userId:n}),Ie.uploadEvent({log:"stat-schedule:"+JSON.stringify(t),userId:n})}function lI(e){var t,n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:Qe;return t=Kp||(US(e)?n===Qe?pN:fN:n===Qe?dN:hN),"https://".concat(t,"/api/v1/config")}function a7(e,t,n){return new Promise(function(a,i){hl({url:e,body:t,timeout:n.timeout}).then(function(r){r.data.code===0?a(r.data.data):i({code:r.data.code,message:r.data.msg})}).catch(i)})}X.on(va,function(){return Ea(!0)}),X.on(j4,function(){return Ea(!0)}),X.on(B4,function(){return Ea(!0)}),X.on(XS,function(){return Ea(!0)}),X.on(vl,function(e){e.state===jp&&Ea(!0)});var dI=function(e,t){return dc({retryFunction:a7,settings:{retries:3,timeout:0},onError:t,onRetrying:e})};function o7(e,t,n){return new Promise(function(a,i){var r,o=null;(r=[dI(function(s){return t.count[0]=s+1},function(s,c){t.msg[0]=s.message,o||c()})(lI(n,Qe),e,{get timeout(){return 1e3*dl(2+t.count[0])}}),dI(function(s){return t.count[1]=s+1},function(s,c){t.msg[1]=s.message,o||c()})(lI(n,Hr),e,{get timeout(){return 1e3*dl(2+t.count[1])}})],new Promise(function(s,c){var u=[];r.forEach(function(d){d.then(s).catch(function(g){u.push(g),u.length===r.length&&c(u)})})})).then(function(s){a(o=s)}).catch(i)})}var hI,pI,fI,mI,vI,gI,_I,yI,bI,SI,kI,TI,xI,II,wI,EI,CI,RI,AI,PI,DI,LI,OI,MI,NI,UI,VI,jI,BI,FI,GI,Le,s7=function(){function e(){K(this,e)}return we(e,[{key:"call",value:function(t,n){return ln(this[t])?this[t](n):Promise.reject(new re({code:ee.INVALID_PARAMETER,message:ie({key:e4,data:{name:t}})}))}},{key:"updatePrivateMapKey",value:function(t){var n=t.privateMapKey;return t.client.setProperty("privateMapKey",n),Promise.resolve()}}]),e}(),c7=new s7,dd,hd,pd,eg,HI,zI,WI,qI,JI,KI,Kt,u7=(hI=Lc(),pI=Cn(Jt.CLIENT.join),fI=Fo({retries:1,timeout:0,onError:function(e,t,n){this.isUsingCachedSchedule_?(this.log_.warn("is using cached schedule, retry join"),Ea(!0),this.reset(),t()):(X.emit(va,{client:this,error:e}),Ie.logFailedEvent({userId:this.userId_,eventType:wb,error:e}),this.reset(),this.log_.error(e),n(e))}}),mI=Lc(),vI=Fo({retries:3}),gI=Lc(),_I=Cn.apply(void 0,be(Jt.CLIENT.publish)),yI=St(un),bI=Lc(),SI=Cn(Jt.CLIENT.unpublish),kI=Cn.apply(void 0,be(Jt.CLIENT.subscribe)),TI=Cn(Jt.CLIENT.unsubscribe),xI=Lc(),II=Cn(Jt.CLIENT.switchRole),wI=St(un),EI=Cn(Jt.CLIENT.startPublishCDNStream),CI=St(un),RI=St(un),AI=Cn(Jt.CLIENT.startMixTranscode),PI=St(un),DI=St(un),LI=St(un),OI=St(un),MI=St(un),NI=St(un),UI=St(un),VI=$l.apply(void 0,be(Jt.CLIENT.sendSEIMessage)),jI=St(un),dd={timesInSecond:30,maxSizeInSecond:8e3,getSize:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return t[0].byteLength}},hd=dd.timesInSecond,pd=dd.maxSizeInSecond,eg=dd.getSize,BI=function(e,t,n){var a=n.value,i=new Map;return X.on(Vf,function(r){var o=r.client;return i.delete(o)}),n.value=function(){var r=i.get(this);r||(r={callCountInSecond:0,timestamp:0,totalSizeInSecond:0},i.set(this,r)),r.timestamp===0?r.timestamp=Date.now():Date.now()-r.timestamp>1e3&&(r.timestamp=Date.now(),r.callCountInSecond=0,r.totalSizeInSecond=0);for(var o=arguments.length,s=new Array(o),c=0;c<o;c++)s[c]=arguments[c];if(eg&&(r.totalSizeInSecond+=eg.apply(void 0,s)),r.timestamp!==0&&Date.now()-r.timestamp<1e3&&(r.callCountInSecond>=hd||r.totalSizeInSecond>pd))throw new re({code:ee.INVALID_OPERATION,message:ie({key:c4,data:{isTimes:r.callCountInSecond>=hd,isSize:r.totalSizeInSecond>pd,name:t,timesInSecond:hd,maxSizeInSecond:pd}})});return r.callCountInSecond++,a.apply(this,s)},n},FI=St(un),GI=St(un),Le=function(){function e(x){var h,E;K(this,e),this.name_=un,this.mode_=x.mode,this.sdpSemantics_=Wp,ge(x.sdpSemantics)?function(){var O;if(ge(window.RTCRtpTransceiver)||!("currentDirection"in RTCRtpTransceiver.prototype))return!1;var N=null,j=!1;try{(N=new RTCPeerConnection({sdpSemantics:ic})).addTransceiver(Ae),j=!0}catch(J){}return(O=N)===null||O===void 0||O.close(),j}()&&(this.sdpSemantics_=ic):this.sdpSemantics_=x.sdpSemantics,this.sdkAppId_=x.sdkAppId,this.userId_=x.userId,this.log_=_e.createLogger({id:"c".concat(x.seq,"|").concat(this.userId_),userId:this.userId_,sdkAppId:this.sdkAppId_}),this.userSig_=x.userSig,this.roomId_=0,this.useStringRoomId_=x.useStringRoomId||!1,this.pureAudioPushMode_=null,this.version_=x.version,this.log_.info("using sdpSemantics: "+this.sdpSemantics_),this.signalChannel_=null,this.role_=br,this.privateMapKey_="",this.tinyId_=0,this.env_="",this.proxy_=null,this.unifiedProxy_=null,this.connections_=new Map,this.mutedStates_=new Map,this.userMap_=new Map,this.syncUserListInterval_=-1,this.localStream_=null,this.localAuxStream_=null,this.uplinkConnection_=null,this.emitter_=zS(new Ri,this.name_),this.isJoined_=!1,this.heartbeat_=-1,this.lastHeartBeatTime_=-1,this.stats_=new a6(this),this.joinTimeout_=-1,this.changeBigSmallRecords_=new Map,this.networkQuality_=null,this.badCaseDetector_=null,this.networkType_=xf(),this.autoSubscribe_=!!ge(x.autoSubscribe)||x.autoSubscribe,this.joinedTimestamp_=0,this.joinOptions_={},this.basis_=(E={browser:fa().name+"/"+fa().version,os:xm(),displayResolution:QV(),isScreenShareSupported:jk(),isWebRTCSupported:gm(),isGetUserMediaSupported:YV(),isWebAudioSupported:$V(),isWebSocketsSupported:"WebSocket"in window&&window.WebSocket.CLOSING===2,isWebCodecSupported:(h={AudioDecoder:!1,AudioEncoder:!1,VideoDecoder:!1,VideoEncoder:!1,ImageDecoder:!1},ge(window.AudioDecoder)||(h.AudioDecoder=!0),ge(window.AudioEncoder)||(h.AudioEncoder=!0),ge(window.VideoDecoder)||(h.VideoDecoder=!0),ge(window.VideoEncoder)||(h.VideoEncoder=!0),ge(window.ImageDecoder)||(h.ImageDecoder=!0),h),isMediaSessionSupported:"mediaSession"in navigator&&!ge(navigator.mediaSession.setActionHandler),isWebTransportSupported:!ge(window.WebTransport)},navigator.userAgent.includes("miniProgram")&&(E.browser="mini/".concat(E.browser)),E),this.initBussinessInfo_(x),this.publishedCDN_=!1,this.publishCDNData_=null,this.mixedMCU_=!1,this.mixTranscodeData_=null,this.checkSystemResult_=null,this.enableAudioVolumeEvaluation_=!1,this.audioVolumeIntervalId_=null,this.mixTranscodeManager_=null,this.publishCDNManager_=new n7({client:this}),this.keyPointManager_=new yF({client:this,frameWorkType:x.frameWorkType,component:x.component}),this.isPublishing_=!1,this.isEnableSmallStream_=!1,this.smallStreamConfig_={bitrate:100,frameRate:15,height:120,width:160},this.turnServers_=[],this.iceTransportPolicy_=x.iceTransportPolicy,this.schedule_={domains:null,iceServers:null,iceTransportPolicy:null,trtcCapability:null},this.isUsingCachedSchedule_=!1,this.enableAutoPlayDialog_=!!ge(x.enableAutoPlayDialog)||x.enableAutoPlayDialog,this.enableMultiAuxStream_=!ge(x.enableMultiAuxStream)&&x.enableMultiAuxStream,this.signalInfo_={},this.enableSEI_=!ge(x.enableSEI)&&x.enableSEI,this.isDestroyed_=!1}var t,n,a,i,r,o,s,c,u,d,g,I,k,w,A,p,v,y,L,f,b,P,S,T,C,D,B;return we(e,[{key:"initBussinessInfo_",value:function(x){this.bussinessInfo_=x.bussinessInfo;var h={};if(Vt(x.bussinessInfo)&&(h=JSON.parse(x.bussinessInfo)),!ge(x.pureAudioPushMode)){if(!Number.isInteger(Number(x.pureAudioPushMode)))throw new re({code:ee.INVALID_PARAMETER,message:ie({key:VN})});this.pureAudioPushMode_=x.pureAudioPushMode,h.Str_uc_params||(h.Str_uc_params={}),h.Str_uc_params.pure_audio_push_mod=this.pureAudioPushMode_}if(!ge(x.streamId)){if(!(Vt(x.streamId)&&String(x.streamId)&&String(x.streamId).length<=64))throw new re({code:ee.INVALID_PARAMETER,message:ie({key:jN})});h.Str_uc_params||(h.Str_uc_params={}),h.Str_uc_params.userdefine_streamid_main=x.streamId}if(!ge(x.userDefineRecordId)){if(x.userDefineRecordId.match(/^[A-Za-z0-9_-]{1,64}$/gi)===null)throw new re({code:ee.INVALID_PARAMETER,message:ie({key:BN})});h.Str_uc_params||(h.Str_uc_params={}),h.Str_uc_params.userdefine_record_id=x.userDefineRecordId}if(!ge(x.userDefinePushArgs)){if(!(Vt(x.userDefinePushArgs)&&String(x.userDefinePushArgs)&&String(x.userDefinePushArgs).length<=256))throw new re({code:ee.INVALID_PARAMETER,message:ie({key:FN})});h.Str_uc_params||(h.Str_uc_params={}),h.Str_uc_params.userdefine_push_args=x.userDefinePushArgs}x.enableServerAudioMix&&(h.Str_uc_params||(h.Str_uc_params={}),h.Str_uc_params.enable_server_audio_mix=1,h.Str_uc_params.uc_biz_type=1e3),Ai(h)||(this.bussinessInfo_=JSON.stringify(h))}},{key:"schedule",value:(B=G(m().mark(function x(h){var E,O,N;return m().wrap(function(j){for(;;)switch(j.prev=j.next){case 0:return j.next=2,i7({userId:this.userId_,sdkAppId:this.sdkAppId_,roomId:h,useStringRoomId:this.useStringRoomId_,version:this.version_,userSig:this.userSig_});case 2:E=j.sent,O=E.result,N=E.isCached,this.isUsingCachedSchedule_=N,O&&(this.log_.info("schedule with cache:".concat(N," : ").concat(JSON.stringify(O))),O.trtcCapability=O==null?void 0:O.trtcAutoConf,this.schedule_=q(q({},this.schedule_),O),X.emit(KS,this.schedule_));case 7:case"end":return j.stop()}},x,this)})),function(x){return B.apply(this,arguments)})},{key:"getSignalChannelUrl",value:function(){var x={mainUrl:"",backupUrl:""},h=NS();return h?x.mainUrl=x.backupUrl="wss://".concat(h,".rtc.qq.com"):this.proxy_?x.mainUrl=x.backupUrl=this.proxy_:this.unifiedProxy_?x.mainUrl=x.backupUrl="wss://".concat(this.unifiedProxy_):Array.isArray(this.schedule_.domains)&&this.schedule_.domains.length>0&&(x.mainUrl=x.backupUrl="wss://".concat(this.schedule_.domains[0]),this.schedule_.domains[1]&&(x.backupUrl="wss://".concat(this.schedule_.domains[1]))),x}},{key:"getUserId",value:function(){return this.userId_}},{key:"getUserSig",value:function(){return this.userSig_}},{key:"getRole",value:function(){return this.role_}},{key:"getSignalInfo",value:function(){return this.signalInfo_}},{key:"getRoomId",value:function(){return this.roomId_}},{key:"getSDKAppId",value:function(){return this.sdkAppId_}},{key:"getTinyId",value:function(){return this.tinyId_}},{key:"getIceTransportPolicy",value:function(){return this.iceTransportPolicy_||this.schedule_.iceTransportPolicy||"all"}},{key:"initialize",value:function(x){var h=this;this.log_.info("setup signal channel");var E=this.getSignalChannelUrl(),O=E.mainUrl,N=E.backupUrl;return this.signalChannel_=new CV({sdkAppId:this.sdkAppId_,userId:this.userId_,userSig:this.userSig_,roomId:x.roomId,url:O,backupUrl:N,signalDomainWhenUnifiedProxy:this.unifiedProxy_?this.schedule_.domains[0]:void 0,client:this}),this.networkQuality_||(this.networkQuality_=new o6({connections:this.connections_,signalChannel:this.signalChannel_,userId:this.userId_,client:this}),this.networkQuality_.on(ct.NETWORK_QUALITY,function(j){h.emitter_.emit(ct.NETWORK_QUALITY,j)})),this.deviceDetector_||(this.deviceDetector_=new s6({client:this})),this.subscriptionManager_||(this.subscriptionManager_=new bF({client:this})),this.badCaseDetector_||(this.badCaseDetector_=new e7({client:this,stats:this.stats_})),this.callDurationCalculator_||(this.callDurationCalculator_=new r7({client:this})),this.mixTranscodeManager_||(this.mixTranscodeManager_=new t7({client:this,signalChannel:this.signalChannel_})),this.publishCDNManager_&&this.publishCDNManager_.setSignalChannel({signalChannel:this.signalChannel_}),this.signalChannel_.on(im,function(j){h.log_.info("SignalChannel state changed from ".concat(j.prevState," to ").concat(j.state)),h.emitter_.emit(ct.CONNECTION_STATE_CHANGED,j)}),this.signalChannel_.on(am,function(j){h.reset(),h.emitter_.emit(ct.ERROR,j)}),this.signalChannel_.once(mk,function(j){h.tinyId_=j.signalInfo.tinyId,X.emit(fl,{client:h})}),this.signalChannel_.on(ft.PEER_JOIN,this.onPeerJoin,this),this.signalChannel_.on(ft.PEER_LEAVE,this.onPeerLeave,this),this.signalChannel_.on(ft.UPDATE_REMOTE_MUTE_STAT,function(j){Date.now()-h.lastHeartBeatTime_>=1e4&&h.doHeartbeat(),X.emit(Of,{client:h,data:j.data}),h.onPublishedUserList(j.data),h.onUpdateRemoteMuteStat(j.data)}),this.signalChannel_.on(ft.CLIENT_BANNED,function(j){var J,$=j.data.data.reason;if(Ie.uploadEvent({log:"stat-banned:".concat($),userId:h.userId_}),$===GM)J="you got banned by the admin";else if($===HM)J="duplicated userId joining the room";else if($===WM)J="the room has been disbanded by the admin",$=$.replace("_","-");else if($===zM)return h.log_.warn("".concat($," last heart beat time: ").concat(h.lastHeartBeatTime_," interval: ").concat(Date.now()-h.lastHeartBeatTime_,", visibility: ").concat(document.visibilityState)),void h.reJoin();h.log_[$==="kick"?"error":"info"]("user was banned because of [".concat($,"]")),h.reset(),h.emitter_.emit(ct.CLIENT_BANNED,{reason:$,message:ie({key:a3,data:{message:J,reason:$}})||$})}),X.emit(Nf,{client:this}),this.signalChannel_.connect()}},{key:"preJoin",value:(D=G(m().mark(function x(h){var E,O,N,j;return m().wrap(function(J){for(;;)switch(J.prev=J.next){case 0:return this.joinOptions_=h,J.next=3,ym();case 3:if(this.checkSystemResult_=J.sent,this.checkDestroy(),(E=NS())||(E=Ju,this.proxy_&&(this.proxy_.startsWith(JM)?E=XM:this.proxy_.startsWith(KM)&&(E=QM))),this.env_=E,Ie.setConfig({env:E,sdkAppId:this.sdkAppId_,userId:this.userId_,roomId:h.roomId}),this.uploadTrtcStats(),O=this.checkSystemResult_.detail,N=O.isH264EncodeSupported,j=O.isVp8EncodeSupported,gm()&&(N||j)){J.next=13;break}throw new re({code:ee.NOT_SUPPORTED,message:ie({key:_S})});case 13:case"end":return J.stop()}},x,this)})),function(x){return D.apply(this,arguments)})},{key:"join",value:(C=G(m().mark(function x(h){var E,O=this;return m().wrap(function(N){for(;;)switch(N.prev=N.next){case 0:return this.roomId_=h.roomId,ge(h.role)||(this.role_=h.role),ge(h.privateMapKey)||(this.privateMapKey_=h.privateMapKey),E=Pt(),X.emit(pl,{client:this}),yn(this.userId_,{eventId:cV,eventDesc:"joining room",timestamp:an(),userId:this.userId_,tinyId:this.tinyId_}),N.next=8,this.preJoin(h);case 8:return N.abrupt("return",new Promise(function(){var j=G(m().mark(function J($,he){return m().wrap(function(ue){for(;;)switch(ue.prev=ue.next){case 0:if(O.joinReject_=he,ue.prev=1,O.proxy_||O.schedule_.domains){ue.next=5;break}return ue.next=5,O.schedule(h.roomId);case 5:return O.checkDestroy(),ue.next=8,O.initialize(h);case 8:return ue.next=10,O.doJoin(h);case 10:O.signalInfo_=O.signalChannel_.getSignalInfo(),X.emit(bo,{client:O}),O.joinedTimestamp_=Pt(),Ie.logSuccessEvent({userId:O.userId_,eventType:aN,delta:O.joinedTimestamp_-E}),Ie.logSuccessEvent({userId:O.userId_,eventType:wb}),Ie.uploadEvent({log:"stat-autoplay-dialog:".concat(O.enableAutoPlayDialog_),userId:O.userId_}),Ie.uploadEvent({log:"stat-conv-".concat(ha,"-").concat(location.hostname),userId:O.userId_}),$(),ue.next=23;break;case 20:ue.prev=20,ue.t0=ue.catch(1),he(ue.t0);case 23:O.joinReject_=null;case 24:case"end":return ue.stop()}},J,null,[[1,20]])}));return function(J,$){return j.apply(this,arguments)}}()));case 9:case"end":return N.stop()}},x,this)})),function(x){return C.apply(this,arguments)})},{key:"checkDestroy",value:function(){if(this.isDestroyed_)throw new re({code:ee.INVALID_OPERATION,message:ie({key:tf,data:{funName:"join"}})})}},{key:"uploadTrtcStats",value:(T=G(m().mark(function x(){var h,E,O,N,j,J,$,he,ue,Ee,Ve,We,kt;return m().wrap(function(Ne){for(;;)switch(Ne.prev=Ne.next){case 0:return Ne.prev=0,Ne.next=3,Tt.getMicrophones();case 3:O=Ne.sent,h=O&&O.length,Ne.next=9;break;case 7:Ne.prev=7,Ne.t0=Ne.catch(0);case 9:return Ne.prev=9,Ne.next=12,Tt.getCameras();case 12:N=Ne.sent,E=N&&N.length,Ne.next=18;break;case 16:Ne.prev=16,Ne.t1=Ne.catch(9);case 18:j={microphone:h,camera:E},J=this.checkSystemResult_.detail,$=J.isH264EncodeSupported,he=J.isVp8EncodeSupported,ue=J.isH264DecodeSupported,Ee=J.isVp8DecodeSupported,Ve={webRTC:this.basis_.isWebRTCSupported,getUserMedia:this.basis_.isGetUserMediaSupported,webSocket:this.basis_.isWebSocketsSupported,screenShare:this.basis_.isScreenShareSupported,webAudio:this.basis_.isWebAudioSupported,h264Encode:$,h264Decode:ue,vp8Encode:he,vp8Decode:Ee},We={browser:this.basis_.browser,os:this.basis_.os,trtc:Ve,devices:j},kt={isWebCodecSupported:this.basis_.isWebCodecSupported,isMediaSessionSupported:this.basis_.isMediaSessionSupported,isWebTransportSupported:this.basis_.isWebTransportSupported},Ie.uploadEvent({log:"trtcstats-"+JSON.stringify(We),userId:this.userId_}),this.log_.info("TrtcStats-"+JSON.stringify(We)),Ie.uploadEvent({log:"trtcadvancedstats-"+JSON.stringify(kt),userId:this.userId_});case 26:case"end":return Ne.stop()}},x,this,[[0,7],[9,16]])})),function(){return T.apply(this,arguments)})},{key:"doJoin",value:function(x){var h=this;return new Promise(function(E,O){h.log_.info("Join() => joining room: ".concat(h.roomId_," useStringRoomId: ").concat(h.useStringRoomId_," mode: ").concat(h.mode_," role: ").concat(h.role_));var N={roomId:String(h.roomId_),useStringRoomId:h.useStringRoomId_,privateMapKey:h.privateMapKey_,trtcRole:h.role_===br?fo:Vp,trtcScene:h.mode_===Ku?eN:ZM,sdpSemantics:h.sdpSemantics_,version:V4(h.version_),ua:navigator&&navigator.userAgent||"",autoSubscribe:h.autoSubscribe_,terminalType:la?4:sf?2:of?3:sc?12:DS?5:LS?13:1,netType:Jp[xf()],bussinessInfo:h.bussinessInfo_,receiveMix:!0};if(h.publishCDNManager_){var j=h.publishCDNManager_.handleCDNConfigForJoinData(h.bussinessInfo_),J=j.bussinessInfo,$=j.pushUserCdnInfo;Object.assign(N,{bussinessInfo:J,pushUserCdnInfo:$})}h.log_.debug("join room signal data: ".concat(JSON.stringify(N))),h.joinTimeout_=setTimeout(function(){O(new re({code:ee.JOIN_ROOM_FAILED,message:ie({key:qN})}))},5e3),X.emit(Rf,{client:h}),h.signalChannel_.once(vk,function(he){h.clearJoinTimeout(),X.emit(fl,{client:h,error:he}),O(he)}),h.signalChannel_.send(DU,N),h.signalChannel_.once(ft.JOIN_ROOM_RESULT,function(he){h.clearJoinTimeout();var ue=he.data,Ee=ue.code,Ve=ue.message,We=ue.data;h.onPublishedUserList({data:{userList:We.publishers}}),X.emit(Af,{client:h,code:Ee}),Ee===0?(h.isJoined_=!0,h.log_.info("Join room success, start heartbeat"),h.startHeartbeat(),h.badCaseDetector_&&h.badCaseDetector_.start(),h.syncUserList(),h.startSyncUserListInterval(),E()):(h.log_.error("Join room failed result: "+Ee+" error: "+Ve),O(new re({code:ee.JOIN_ROOM_FAILED,extraCode:Ee,message:ie({key:dS,data:{error:Ve,code:Ee}})})))})})}},{key:"reJoin",value:(S=G(m().mark(function x(){return m().wrap(function(h){for(;;)switch(h.prev=h.next){case 0:if(this.isJoined_){h.next=3;break}return this.log_.warn("reJoin abort"),h.abrupt("return");case 3:return this.isJoined_=!1,h.prev=4,this.log_.warn("reJoin pending: ".concat(this.joinOptions_.roomId)),this.subscriptionManager_&&this.subscriptionManager_.markAllStream(),this.signalChannel_.close(),h.next=10,this.signalChannel_.connect();case 10:return h.next=12,this.doJoin(q(q({},this.joinOptions_),{},{role:this.role_,privateMapKey:this.privateMapKey_}));case 12:this.log_.warn("reJoin success"),Ie.logSuccessEvent({userId:this.userId_,eventType:Eb}),this.checkConnectionsToReconnect(),this.uplinkConnection_&&!this.uplinkConnection_.getIsReconnecting()&&this.uplinkConnection_.startReconnection(),this.mixTranscodeManager_&&this.mixTranscodeManager_.reStartMixTranscode(),h.next=25;break;case 19:h.prev=19,h.t0=h.catch(4),this.log_.warn("reJoin fail "+h.t0),this.reset(),Ie.logFailedEvent({userId:this.userId_,eventType:Eb,error:h.t0}),this.emitter_.emit(ct.ERROR,new re({code:ee.JOIN_ROOM_FAILED,message:ie({key:JN,data:{roomId:this.joinOptions_.roomId}})}));case 25:case"end":return h.stop()}},x,this,[[4,19]])})),function(){return S.apply(this,arguments)})},{key:"leave",value:(P=G(m().mark(function x(){var h;return m().wrap(function(E){for(;;)switch(E.prev=E.next){case 0:return X.emit(Pf,{client:this}),yn(this.userId_,{eventId:uV,eventDesc:"leaving room",timestamp:an(),userId:this.userId_,tinyId:this.tinyId_}),E.prev=2,E.next=5,this.doHeartbeat();case 5:E.next=9;break;case 7:E.prev=7,E.t0=E.catch(2);case 9:this.doLeave(),X.emit(So,{client:this}),Ie.logSuccessEvent({userId:this.userId_,eventType:oN}),h=Math.floor((Pt()-this.joinedTimestamp_)/1e3),Ie.logSuccessEvent({userId:this.userId_,eventType:sN,delta:h});case 14:case"end":return E.stop()}},x,this,[[2,7]])})),function(){return P.apply(this,arguments)})},{key:"doLeave",value:function(){this.isJoined_&&(X.emit(Df,{client:this}),this.log_.info("leave() => leaving room"),this.signalChannel_.send(LU),this.reset())}},{key:"clearNetworkQuality",value:function(){this.networkQuality_&&(this.networkQuality_.stop(),this.networkQuality_=null)}},{key:"closeConnections",value:function(){var x=this;this.connections_.forEach(function(h){x.closeDownLink(h.getTinyId())})}},{key:"clearJoinTimeout",value:function(){clearTimeout(this.joinTimeout_),this.joinTimeout_=-1}},{key:"destroy",value:function(){var x,h,E;if(this.isJoined_)throw this.log_.warn(xi.INVALID_DESTROY),new re({code:ee.INVALID_OPERATION,message:ie({key:KN})});this.isDestroyed_||(this.log_.info("destroy client"),this.joinReject_&&(this.joinReject_(new re({code:ee.INVALID_OPERATION,message:ie({key:tf,data:{funName:"join"}})})),this.clearJoinTimeout(),this.reset()),this.off("*"),(x=this.callDurationCalculator_)===null||x===void 0||x.destroy(),(h=this.keyPointManager_)===null||h===void 0||h.destroy(),(E=this.deviceDetector_)===null||E===void 0||E.destroy(),this.callDurationCalculator_=null,this.keyPointManager_=null,this.deviceDetector_=null,this.badCaseDetector_=null,this.publishCDNManager_=null,this.isDestroyed_=!0,X.emit(Vf,{client:this}))}},{key:"reset",value:function(){this.isJoined_=!1,this.schedule_={domains:null,iceServers:null,iceTransportPolicy:null,trtcCapability:null},this.keyPointManager_&&this.keyPointManager_.prepareReport(),this.mixTranscodeManager_&&(this.mixTranscodeManager_.reset(),this.mixTranscodeManager_=null),this.publishCDNManager_&&this.publishCDNManager_.reset(),this.userMap_.clear(),this.stopSyncUserListInterval(),this.stopHeartbeat(),this.closeConnections(),this.mutedStates_.clear(),this.clearNetworkQuality(),this.badCaseDetector_&&this.callDurationCalculator_&&this.uploadAllCallStats(),this.closeUplink(),this.signalChannel_&&(this.log_.info("destroying SignalChannel"),this.signalChannel_.close(),this.signalChannel_=null),this.stats_.reset()}},{key:"startSyncUserListInterval",value:function(){this.syncUserListInterval_===-1&&(this.syncUserListInterval_=_t.run(vo,this.syncUserList.bind(this)))}},{key:"stopSyncUserListInterval",value:function(){_t.clearTask(this.syncUserListInterval_),this.syncUserListInterval_=-1}},{key:"syncUserList",value:(b=G(m().mark(function x(){var h,E=this;return m().wrap(function(O){for(;;)switch(O.prev=O.next){case 0:return O.prev=0,O.next=3,this.getUserList();case 3:h=O.sent,this.userMap_.size!==0&&this.userMap_.forEach(function(N){h.findIndex(function(j){return j.userId===N.userId})<0&&(E.log_.info("peer leave detected: ".concat(N.userId)),E.cleanUser({userId:N.userId,tinyId:N.tinyId}))}),h.forEach(function(N){var j=N.userId;E.userMap_.has(j)||j===E.userId_||(E.userMap_.set(j,N),E.emitter_.emit(ct.PEER_JOIN,{userId:j}))}),O.next=11;break;case 8:O.prev=8,O.t0=O.catch(0),this.log_.warn("sync user list failed: "+O.t0);case 11:case"end":return O.stop()}},x,this,[[0,8]])})),function(){return b.apply(this,arguments)})},{key:"getUserList",value:function(){return this.signalChannel_?this.signalChannel_.sendWaitForResponse({command:qU,responseCommand:ft.USER_LIST_RES,enableLog:!1,timeout:2e3}).then(function(x){var h=x.data,E=h.code,O=h.message;if(E===0)return(h.data&&h.data.userList||[]).map(function(N){var j=N.userId,J=N.srcTinyId,$=N.role;return new Qv({userId:j,tinyId:J,role:$})});throw ie({key:SS,data:{signalResponse:ft.USER_LIST_RES,code:E,message:O}})}):[]}},{key:"publish",value:(f=G(m().mark(function x(h){var E,O,N,j,J,$,he,ue,Ee=this,Ve=arguments;return m().wrap(function(We){for(;;)switch(We.prev=We.next){case 0:return E=Ve.length>1&&Ve[1]!==void 0?Ve[1]:{isAuxiliary:!1},h.setPublishState(ac),this.isPublishing_=!0,O=Pt(),X.emit(Mf,{client:this,stream:h}),N=E.isAuxiliary,j=N?pt:Qe,J=h.getScreen(),this.log_.info("publish() => publishing ".concat(J?Lp+" ":"").concat(j," stream ").concat(h.getId())),$=this.uplinkConnection_,We.prev=10,$||(($=new AF({userId:this.userId_,tinyId:this.tinyId_,client:this,isUplink:!0,signalChannel:this.signalChannel_,enableSEI:this.enableSEI_})).initialize(),$.on(Ze.ERROR,function(kt){var Ne=kt.getCode();Ne!==ee.ICE_TRANSPORT_ERROR&&(Ne===ee.UPLINK_RECONNECTION_FAILED&&Ee.closeUplink(),Ee.emitter_.emit(ct.ERROR,kt))})),h.setConnection($),We.next=15,$.publish(h,N);case 15:this.log_.info("local ".concat(J?Lp+" ":"").concat(j," stream is published")),this.isPublishing_=!1,N?this.localAuxStream_=h:(this.localStream_=h,this.deviceDetector_&&this.deviceDetector_.setLocalStream(this.localStream_),this.localStream_.getBeautyStatus()&&this.log_.info("beauty stream is published successfully")),h.setPublishState(lN),h.setClient(this,N),this.uplinkConnection_=$,he=Pt(),ue=he-O,Ie.logSuccessEvent({userId:this.userId_,eventType:Cb}),Ie.logSuccessEvent({userId:this.userId_,eventType:cN,delta:ue}),h.hasAudio()&&yn(this.userId_,{eventId:bk,eventDesc:"publish audio track",timestamp:an(),userId:this.userId_,tinyId:this.tinyId_}),h.hasVideo()&&yn(this.userId_,{eventId:yk,eventDesc:"publish video track",timestamp:an(),userId:this.userId_,tinyId:this.tinyId_}),this.networkQuality_&&this.networkQuality_.setUplinkConnection(this.uplinkConnection_),X.emit(H4,{localStream:h,isAuxiliary:N,client:this}),this.notPublishWithoutH264Supported_=!1,h.isAIDenoiser&&Ui.handleFunctionState({fnName:"AI_DENOISER"}),We.next=42;break;case 33:throw We.prev=33,We.t0=We.catch(10),We.t0 instanceof re&&We.t0.getCode()===ee.NOT_SUPPORTED_H264&&(this.notPublishWithoutH264Supported_=!0),h.setPublishState(Jb),$.close(),this.log_.error("failed to publish stream "+We.t0),this.isPublishing_=!1,Ie.logFailedEvent({userId:this.userId_,eventType:Cb,error:We.t0}),We.t0;case 42:case"end":return We.stop()}},x,this,[[10,33]])})),function(x){return f.apply(this,arguments)})},{key:"unpublish",value:(L=G(m().mark(function x(h){var E,O;return m().wrap(function(N){for(;;)switch(N.prev=N.next){case 0:if(this.uplinkConnection_){N.next=2;break}return N.abrupt("return");case 2:return E=h===this.localAuxStream_,O=h.getScreen(),this.log_.info("unpublish() => unpublishing local ".concat(O?Lp+" ":"").concat(E?pt:Qe," stream")),N.prev=5,N.next=8,this.uplinkConnection_.unpublish(h);case 8:h.setClient(null),h.setConnection(null),E?this.localAuxStream_=null:(this.localStream_=null,h.hasAudio()&&yn(this.userId_,{eventId:kk,eventDesc:"unpublish audio track",timestamp:an(),userId:this.userId_,tinyId:this.tinyId_}),h.hasVideo()&&yn(this.userId_,{eventId:Sk,eventDesc:"unpublish video track",timestamp:an(),userId:this.userId_,tinyId:this.tinyId_})),this.localStream_||this.localAuxStream_||this.closeUplink(),Ie.logSuccessEvent({userId:this.userId_,eventType:Rb}),N.next=19;break;case 15:throw N.prev=15,N.t0=N.catch(5),Ie.logFailedEvent({userId:this.userId_,eventType:Rb,error:N.t0}),N.t0;case 19:case"end":return N.stop()}},x,this,[[5,15]])})),function(x){return L.apply(this,arguments)})},{key:"closeUplink",value:function(){this.uplinkConnection_&&(this.uplinkConnection_.close(),this.uplinkConnection_=null,this.networkQuality_&&this.networkQuality_.setUplinkConnection(null),this.localStream_&&(this.localStream_.setClient(null),this.localStream_.setConnection(null),this.localStream_=null),this.localAuxStream_&&(this.localAuxStream_.setClient(null),this.localAuxStream_.setConnection(null),this.localAuxStream_=null),this.deviceDetector_&&this.deviceDetector_.setLocalStream(null))}},{key:"closeDownLink",value:function(x){var h=this.connections_.get(x);h&&(h.getIsReconnecting()&&h.stopReconnection(),this.subscriptionManager_&&this.subscriptionManager_.delete(h.getUserId()),h.close(),this.connections_.delete(x),this.mutedStates_.delete(x))}},{key:"subscribe",value:(y=G(m().mark(function x(h,E){var O,N,j;return m().wrap(function(J){for(;;)switch(J.prev=J.next){case 0:return this.log_.info("subscribe() => subscribe to [".concat(h.getUserId(),"] ").concat(h.getType()," stream with options: ").concat(JSON.stringify(E))),ge(E)&&(E={audio:!0,video:!0}),ge(E.audio)&&(E.audio=!0),ge(E.smallVideo)?ge(E.video)&&(E.video=!0):E.smallVideo?ge(E.video)?(E.video=!1,E.smallVideo=!0):E.video&&(E.video=!0,delete E.smallVideo,this.log_.warn("options.video and options.smallVideo can't be both true")):ge(E.video)&&(E.video=!0,delete E.smallVideo),E.video&&this.changeBigSmallRecords_.delete(h.getUserId()),O=h.getConnection(),E.smallVideo&&(O.getTrackState().smallVideo||(this.setRemoteVideoStreamType(h,"small"),E.video=!0,delete E.smallVideo)),J.prev=7,X.emit(Bf,{client:this,stream:h}),J.next=11,O.subscribe(h,E);case 11:this.subscriptionManager_&&this.subscriptionManager_.addSubscriptionRecord(h.getUserId(),h,E),this.notSubscribeWithoutH264Supported_=!1,Ie.logSuccessEvent({userId:this.userId_,eventType:Ab}),J.next=24;break;case 16:throw J.prev=16,J.t0=J.catch(7),(N=J.t0 instanceof re?J.t0.getCode():ee.UNKNOWN)===ee.NOT_SUPPORTED_H264&&(this.notSubscribeWithoutH264Supported_=!0),(j=new re(N===ee.REMOTE_STREAM_NOT_EXIST?{code:ee.API_CALL_ABORTED,message:ie({key:af,data:{message:J.t0.message,stream:h}})}:{code:N,message:ie({key:e3,data:{message:J.t0.message,stream:h}})})).getCode()===ee.API_CALL_ABORTED?this.log_.warn(j):this.log_.error(j),Ie.logFailedEvent({userId:this.userId_,eventType:Ab,error:j}),j;case 24:case"end":return J.stop()}},x,this,[[7,16]])})),function(x,h){return y.apply(this,arguments)})},{key:"unsubscribe",value:(v=G(m().mark(function x(h){var E;return m().wrap(function(O){for(;;)switch(O.prev=O.next){case 0:return this.log_.info("unsubscribe() => unsubscribe to [".concat(h.getUserId(),"] ").concat(h.getType()," stream")),O.prev=1,E=h.getConnection(),O.next=5,E.unsubscribe(h);case 5:this.subscriptionManager_&&this.subscriptionManager_.addUnsubscriptionRecord(h.getUserId(),h),X.emit(qr,{client:this,stream:h}),Ie.logSuccessEvent({userId:this.userId_,eventType:Pb}),O.next=14;break;case 10:throw O.prev=10,O.t0=O.catch(1),Ie.logFailedEvent({userId:this.userId_,eventType:Pb,error:O.t0}),O.t0;case 14:case"end":return O.stop()}},x,this,[[1,10]])})),function(x){return v.apply(this,arguments)})},{key:"switchRole",value:(p=G(m().mark(function x(h){return m().wrap(function(E){for(;;)switch(E.prev=E.next){case 0:if(this.role_!==h){E.next=2;break}return E.abrupt("return");case 2:return h===ca&&this.uplinkConnection_&&this.closeUplink(),this.log_.info("switchRole() => switch role to: "+h),E.next=6,this.doSwitchRole(h);case 6:case"end":return E.stop()}},x,this)})),function(x){return p.apply(this,arguments)})},{key:"doSwitchRole",value:function(x){var h,E,O=this,N={command:JU,data:{role:x===br?fo:Vp,privateMapKey:this.privateMapKey_},responseCommand:ft.SWITCH_ROLE_RES,retries:((h=this.schedule_.config)===null||h===void 0||(E=h.retries)===null||E===void 0?void 0:E.switchRole)||1};return this.log_.info("switchRole signal data: "+JSON.stringify(N.data)),this.signalChannel_.sendWaitForResponseWithRetry(N).then(function(j){var J=j.data,$=J.code,he=J.message;if($!==0)throw new re({code:ee.SWITCH_ROLE_FAILED,message:ie({key:i3,data:{errMsg:he,errCode:$}})});O.role_=x}).catch(function(j){throw j instanceof re&&j.getCode()===ee.API_CALL_TIMEOUT&&(j=new re({code:ee.SWITCH_ROLE_FAILED,message:ie({key:r3})})),O.log_.error(j),j})}},{key:"on",value:function(x,h,E){this.emitter_.on(x,h,E)}},{key:"off",value:function(x,h,E){x==="*"?this.emitter_.removeAllListeners():this.emitter_.off(x,h,E)}},{key:"getRemoteMutedState",value:function(){var x=this,h=[];return this.mutedStates_.forEach(function(E,O,N){var j=x.connections_.get(O);j&&h.push(q({userId:j.getUserId()},E))}),h}},{key:"getTransportStats",value:(A=G(m().mark(function x(){var h,E,O,N,j,J,$;return m().wrap(function(he){for(;;)switch(he.prev=he.next){case 0:if(h={rtt:0,downlinksRTT:{}},!this.uplinkConnection_){he.next=6;break}return he.next=4,this.stats_.getSenderStats(this.uplinkConnection_);case 4:E=he.sent,h.rtt=E.rtt;case 6:O=ae(this.connections_),he.prev=7,O.s();case 9:if((N=O.n()).done){he.next=17;break}return(j=Te(N.value,2))[0],J=j[1],he.next=13,this.stats_.getReceiverStats(J);case 13:$=he.sent,h.downlinksRTT[$.userId]=$.rtt;case 15:he.next=9;break;case 17:he.next=22;break;case 19:he.prev=19,he.t0=he.catch(7),O.e(he.t0);case 22:return he.prev=22,O.f(),he.finish(22);case 25:return he.abrupt("return",h);case 26:case"end":return he.stop()}},x,this,[[7,19,22,25]])})),function(){return A.apply(this,arguments)})},{key:"getLocalAudioStats",value:(w=G(m().mark(function x(){var h,E;return m().wrap(function(O){for(;;)switch(O.prev=O.next){case 0:if((h={})[this.userId_]={bytesSent:0,packetsSent:0},!this.uplinkConnection_){O.next=7;break}return O.next=5,this.stats_.getSenderStats(this.uplinkConnection_);case 5:E=O.sent,h[this.userId_]={bytesSent:E.audio.bytesSent,packetsSent:E.audio.packetsSent};case 7:return O.abrupt("return",h);case 8:case"end":return O.stop()}},x,this)})),function(){return w.apply(this,arguments)})},{key:"getLocalVideoStats",value:(k=G(m().mark(function x(){var h,E;return m().wrap(function(O){for(;;)switch(O.prev=O.next){case 0:if((h={})[this.userId_]={bytesSent:0,packetsSent:0,framesEncoded:0,framesSent:0,frameWidth:0,frameHeight:0},!this.uplinkConnection_){O.next=7;break}return O.next=5,this.stats_.getSenderStats(this.uplinkConnection_);case 5:E=O.sent,h[this.userId_]={bytesSent:E.video.bytesSent,packetsSent:E.video.packetsSent,framesEncoded:E.video.framesEncoded,framesSent:E.video.framesSent,frameWidth:E.video.frameWidth,frameHeight:E.video.frameHeight};case 7:return O.abrupt("return",h);case 8:case"end":return O.stop()}},x,this)})),function(){return k.apply(this,arguments)})},{key:"getRemoteAudioStats",value:(I=G(m().mark(function x(){var h,E,O,N,j,J,$,he;return m().wrap(function(ue){for(;;)switch(ue.prev=ue.next){case 0:h={},E=ae(this.connections_),ue.prev=2,E.s();case 4:if((O=E.n()).done){ue.next=13;break}return(N=Te(O.value,2))[0],j=N[1],J=j.getDelay(),$=J.audioDelay,ue.next=9,this.stats_.getReceiverStats(j);case 9:(he=ue.sent).hasAudio&&(h[he.userId]={bytesReceived:he.audio.bytesReceived,packetsReceived:he.audio.packetsReceived,packetsLost:he.audio.packetsLost,end2EndDelay:$});case 11:ue.next=4;break;case 13:ue.next=18;break;case 15:ue.prev=15,ue.t0=ue.catch(2),E.e(ue.t0);case 18:return ue.prev=18,E.f(),ue.finish(18);case 21:return ue.abrupt("return",h);case 22:case"end":return ue.stop()}},x,this,[[2,15,18,21]])})),function(){return I.apply(this,arguments)})},{key:"getRemoteVideoStats",value:(g=G(m().mark(function x(){var h,E,O,N,j,J,$,he,ue,Ee=arguments;return m().wrap(function(Ve){for(;;)switch(Ve.prev=Ve.next){case 0:h=Ee.length>0&&Ee[0]!==void 0?Ee[0]:gt,E={},O=ae(this.connections_),Ve.prev=3,O.s();case 5:if((N=O.n()).done){Ve.next=15;break}return(j=Te(N.value,2))[0],J=j[1],Ve.next=9,this.stats_.getReceiverStats(J);case 9:$=Ve.sent,he=J.getDelay(),ue=he.videoDelay,h===gt&&$.hasVideo&&(E[$.userId]={bytesReceived:$.video.bytesReceived,packetsReceived:$.video.packetsReceived,packetsLost:$.video.packetsLost,framesDecoded:$.video.framesDecoded,frameWidth:$.video.frameWidth,frameHeight:$.video.frameHeight,end2EndDelay:ue}),h===Lt&&$.hasAuxiliary&&(E[$.userId]={bytesReceived:$.auxiliary.bytesReceived,packetsReceived:$.auxiliary.packetsReceived,packetsLost:$.auxiliary.packetsLost,framesDecoded:$.auxiliary.framesDecoded,frameWidth:$.auxiliary.frameWidth,frameHeight:$.auxiliary.frameHeight,end2EndDelay:ue});case 13:Ve.next=5;break;case 15:Ve.next=20;break;case 17:Ve.prev=17,Ve.t0=Ve.catch(3),O.e(Ve.t0);case 20:return Ve.prev=20,O.f(),Ve.finish(20);case 23:return Ve.abrupt("return",E);case 24:case"end":return Ve.stop()}},x,this,[[3,17,20,23]])})),function(){return g.apply(this,arguments)})},{key:"getSdpSemantics",value:function(){return this.sdpSemantics_}},{key:"getIceServers",value:function(){return this.turnServers_.length===0&&this.schedule_.iceServers?this.schedule_.iceServers:this.turnServers_}},{key:"getConnections",value:function(){return this.connections_}},{key:"getMutedStates",value:function(){return this.mutedStates_}},{key:"startHeartbeat",value:function(){this.heartbeat_===-1&&(this.log_.info("startHeartbeat..."),this.heartbeat_=_t.run(vo,this.doHeartbeat.bind(this),{delay:2e3}))}},{key:"stopHeartbeat",value:function(){this.heartbeat_!==-1&&(this.log_.info("stopHeartbeat"),_t.clearTask(this.heartbeat_),this.heartbeat_=-1,this.lastHeartBeatTime_=-1)}},{key:"doHeartbeat",value:(d=G(m().mark(function x(){var h,E,O,N,j,J;return m().wrap(function($){for(;;)switch($.prev=$.next){case 0:return E=this.badCaseDetector_.getMonitorFreeze(),$.next=3,this.stats_.getStatsReport({uplinkConnection:this.uplinkConnection_,downlinkConnections:this.connections_,freezeMap:E});case 3:if(O=$.sent,X.emit(Lf,{client:this,stats:O}),(h=this.badCaseDetector_)===null||h===void 0||h.resetMonitor(),this.signalChannel_){$.next=8;break}return $.abrupt("return");case 8:N=this.signalChannel_.isConnected()?IV(this.userId_):[],j=q(q({str_sdk_version:this.version_,uint64_datetime:new Date().getTime(),msg_user_info:{str_identifier:this.userId_,uint64_tinyid:this.tinyId_},msg_device_info:{uint32_terminal_type:15,str_device_name:navigator.platform,str_os_version:"",uint32_net_type:Jp[this.networkType_]}},O),{},{msg_event_msg:N}),this.signalChannel_.send(OU,j),J=Date.now(),this.lastHeartBeatTime_>0&&J-this.lastHeartBeatTime_>1e4&&this.log_.warn("heartbeat took ".concat(J-this.lastHeartBeatTime_)),this.lastHeartBeatTime_=J,!this.isRelayChanged_&&this.isRelayMaybeFailed()&&(this.reJoin(),this.isRelayChanged_=!0);case 15:case"end":return $.stop()}},x,this)})),function(){return d.apply(this,arguments)})},{key:"onRemoteStreamAdded",value:function(x){var h=x.content,E=h.userId,O=h.tinyId,N=h.audio,j=h.bigVideo,J=h.auxVideo,$=h.smallVideo;if(E!==null){this.userMap_.has(E)||(this.userMap_.set(E,new Qv({userId:E,tinyId:O,role:br})),this.emitter_.emit(ct.PEER_JOIN,{userId:E}));var he=this.connections_.get(O);if(he){if(he.getIsReconnecting())return;this.log_.warn("duplicated stream-added observed, rebuild the connection"),he.close(),this.connections_.delete(O)}var ue={audio:N,video:j,auxiliary:J,smallVideo:$};this.log_.info("remote peer [".concat(E,"] published stream. trackState: ").concat(JSON.stringify(ue))),this.createDownlinkConnection({userId:E,tinyId:O,trackState:ue})}else this.log_.warn("received null userId on stream added")}},{key:"createDownlinkConnection",value:function(x){var h=this,E=x.userId,O=x.tinyId,N=x.trackState,j=new ZF({userId:E,tinyId:O,client:this,isUplink:!1,signalChannel:this.signalChannel_,autoSubscribe:this.autoSubscribe_,trackState:N,enableSEI:this.enableSEI_});this.connections_.set(O,j),this.installDownlinkEvents(j,E,O),this.autoSubscribe_?(j.initialize(),j.connect().catch(function(){!j.getMainStream()&&j.hasMainStream()&&h.initRemoteStream({type:gt,userId:E,downlinkConnection:j}),!j.getAuxStream()&&j.hasAuxStream()&&h.initRemoteStream({type:Lt,userId:E,downlinkConnection:j})})):(j.hasMainStream()&&this.initRemoteStream({type:gt,userId:E,downlinkConnection:j}),j.hasAuxStream()&&this.initRemoteStream({type:Lt,userId:E,downlinkConnection:j}))}},{key:"initRemoteStream",value:function(x){var h=x.type,E=x.userId,O=x.downlinkConnection,N=new Gv({type:h,userId:E,client:this});N.setConnection(O),O.setRemoteStream(h===gt?Sr:nc,N),N.setIsStreamAddedEventEmitted(!0),X.emit(ml,{client:this,stream:N}),this.emitter_.emit(ct.STREAM_ADDED,{stream:N})}},{key:"installDownlinkEvents",value:function(x,h,E){var O=this;x.on(Ze.SEI_MESSAGE,function(N){O.emitter_.emit(ct.SEI_MESSAGE,N)}),x.on(Ze.STREAM_ADDED,function(N){N.stream.setIsStreamAddedEventEmitted(!0),X.emit(ml,{client:O,stream:N.stream}),O.emitter_.emit(ct.STREAM_ADDED,{stream:N.stream})}),x.on(Ze.STREAM_REMOVED,function(N){O.changeBigSmallRecords_.delete(N.stream.getUserId()),N.stream.stop(),N.stream.setIsStreamAddedEventEmitted(!1),O.subscriptionManager_&&O.subscriptionManager_.deleteAutoRecoveryFlag(N.stream.getUserId(),N.stream.getType()),X.emit(ga,{client:O,stream:N.stream}),O.emitter_.emit(ct.STREAM_REMOVED,{stream:N.stream})}),x.on(Ze.STREAM_UPDATED,function(N){X.emit(G4,{client:O,stream:N.stream});var j=x.getMixUserList();j&&(N.mixUserList=j),O.emitter_.emit(ct.STREAM_UPDATED,N)}),x.on(Ze.STREAM_SUBSCRIBED,function(N){X.emit(Wr,{client:O,stream:N.stream}),O.emitter_.emit(ct.STREAM_SUBSCRIBED,{stream:N.stream})}),x.on(Ze.ERROR,function(N){var j=N.getCode();j!==ee.ICE_TRANSPORT_ERROR&&(j===ee.DOWNLINK_RECONNECTION_FAILED&&O.closeDownLink(E),O.emitter_.emit(ct.ERROR,N))})}},{key:"onPeerJoin",value:function(x){var h=x.data.data,E=h.srcTinyId,O=h.userId,N=h.role;this.userMap_.has(O)||(this.userMap_.set(O,new Qv({userId:O,tinyId:E,role:N})),this.emitter_.emit(ct.PEER_JOIN,{userId:O}))}},{key:"onPeerLeave",value:function(x){var h=x.data.data,E=h.srcTinyId,O=h.userId,N=h.reason,j=N===void 0?0:N;this.log_.info("peer leave [".concat(O,"]: ").concat(_N[j])),this.cleanUser({userId:O,tinyId:E})}},{key:"cleanUser",value:function(x){var h=x.userId,E=x.tinyId;this.userMap_.delete(h),this.closeDownLink(E),this.emitter_.emit(ct.PEER_LEAVE,{userId:h})}},{key:"onPublishedUserList",value:function(x){var h=this;try{var E=be(x.data.userList);x.data.mixRobotList&&E.push.apply(E,be(x.data.mixRobotList)),x.data.fakeMixUser&&E.push(x.data.fakeMixUser);var O=E.map(function(N){return N.userId});this.connections_.forEach(function(N){var j=N.getUserId(),J=N.getTinyId();O.findIndex(function($){return $===j})<0&&(h.log_.info("peer unpublished detected [".concat(j,"]")),h.closeDownLink(J))}),E.forEach(function(N){var j=N.userId,J=N.srcTinyId,$=N.flag,he=N.mixUserList;if(j!==h.userId_){var ue=!!(1&$),Ee=!!(8&$),Ve=!!(4&$),We=!!(2&$),kt=h.connections_.get(J);if((We||ue)&&h.checkSubscribeBigSmallVideo(kt,We),kt){var Ne=kt.getTrackState(),ti=Ne.audio,Vi=Ne.video,cr=Ne.auxiliary,zn=Ne.smallVideo;_o(he)&&kt.setMixUserList(he),!Vi&&ue&&X.emit(Un,{client:h,tinyId:J,userId:j,action:cn.ADD,kind:xe}),!ti&&Ee&&X.emit(Un,{client:h,tinyId:J,userId:j,action:cn.ADD,kind:Ae}),!cr&&Ve&&X.emit(Un,{client:h,tinyId:J,userId:j,action:cn.ADD,kind:pt}),!zn&&We&&X.emit(Un,{client:h,tinyId:J,userId:j,action:cn.ADD,kind:Wu}),Vi&&!ue&&X.emit(Un,{client:h,tinyId:J,userId:j,action:cn.REMOVE,kind:xe}),ti&&!Ee&&X.emit(Un,{client:h,tinyId:J,userId:j,action:cn.REMOVE,kind:Ae}),cr&&!Ve&&X.emit(Un,{client:h,tinyId:J,userId:j,action:cn.REMOVE,kind:pt}),zn&&!We&&X.emit(Un,{client:h,tinyId:J,userId:j,action:cn.REMOVE,kind:Wu})}else h.log_.info("peer published detected [".concat(j,"]")),h.onRemoteStreamAdded({content:{audio:Ee,bigVideo:ue,auxVideo:Ve,smallVideo:We,userId:j,tinyId:J}})}})}catch(N){}}},{key:"onUpdateRemoteMuteStat",value:function(x){var h=this,E=x.data;(E&&E.userList||[]).forEach(function(O){var N=O.srcTinyId,j=O.userId;if(N!==0&&N!==h.tinyId_){var J=h.connections_.get(N);if(J){var $=J.getMainStream();if($&&$.getIsStreamAddedEventEmitted()){var he=!!(1&O.flag),ue=!!(8&O.flag),Ee=!!(2&O.flag),Ve=!!(64&O.flag),We=!!(16&O.flag),kt=h.mutedStates_.get(N);if(kt===void 0)return h.mutedStates_.set(N,{hasAudio:ue,hasVideo:he,hasSmall:Ee,audioMuted:Ve,videoMuted:We}),he?We?h.emitter_.emit(ct.MUTE_VIDEO,{userId:j}):h.emitter_.emit(ct.UNMUTE_VIDEO,{userId:j}):h.emitter_.emit(ct.MUTE_VIDEO,{userId:j}),void(ue?Ve?h.emitter_.emit(ct.MUTE_AUDIO,{userId:j}):h.emitter_.emit(ct.UNMUTE_AUDIO,{userId:j}):h.emitter_.emit(ct.MUTE_AUDIO,{userId:j}));var Ne=!kt.audioMuted&&kt.hasAudio,ti=!Ve&&ue,Vi=!kt.videoMuted&&kt.hasVideo,cr=!We&&he;h.mutedStates_.set(N,{hasAudio:ue,hasVideo:he,hasSmall:Ee,audioMuted:Ve,videoMuted:We}),Ne!==ti&&(ti?h.emitter_.emit(ct.UNMUTE_AUDIO,{userId:j}):h.emitter_.emit(ct.MUTE_AUDIO,{userId:j})),Vi!==cr&&(cr?h.emitter_.emit(ct.UNMUTE_VIDEO,{userId:j}):h.emitter_.emit(ct.MUTE_VIDEO,{userId:j}))}}else h.mutedStates_.delete(N)}})}},{key:"getEnv",value:function(){return this.env_}},{key:"getSubscriptionManager",value:function(){return this.subscriptionManager_}},{key:"startPublishCDNStream",value:(u=G(m().mark(function x(){var h,E=arguments;return m().wrap(function(O){for(;;)switch(O.prev=O.next){case 0:if(h=E.length>0&&E[0]!==void 0?E[0]:{},this.log_.info("startPublishCDNStream with params: ".concat(JSON.stringify(h),"; isJoined: ").concat(this.isJoined_,"; hasMainStream: ").concat(!!this.localStream_,"; hasAuxStream: ").concat(!!this.localAuxStream_,";")),h.streamType=h.streamType||Qe,h.streamType===pt&&(h.streamType=Mn),h.streamId=h.streamId||"",!this.isJoined_){O.next=10;break}if(h.streamType!==Qe||this.localStream_){O.next=8;break}throw new re({code:ee.INVALID_OPERATION,message:ie({key:hS})});case 8:if(h.streamType!==Mn||this.localAuxStream_){O.next=10;break}throw new re({code:ee.INVALID_OPERATION,message:ie({key:hS})});case 10:return O.next=12,this.publishCDNManager_.startPublishTencentCDN(h);case 12:if(!(h.appId&&h.bizId&&h.url)){O.next=15;break}return O.next=15,this.publishCDNManager_.startPublishGivenCDN(h);case 15:case"end":return O.stop()}},x,this)})),function(){return u.apply(this,arguments)})},{key:"stopPublishCDNStream",value:(c=G(m().mark(function x(){return m().wrap(function(h){for(;;)switch(h.prev=h.next){case 0:if(this.publishCDNManager_.getIsPublishingTencentCDN()){h.next=2;break}throw new re({code:ee.INVALID_OPERATION,message:ie({key:o3})});case 2:return this.log_.info("stopPublishCDNStream"),h.next=5,this.publishCDNManager_.stopPublishTencentCDN();case 5:if(!this.publishCDNManager_.getIsPublishingGivenCDN()){h.next=8;break}return h.next=8,this.publishCDNManager_.stopPublishGivenCDN();case 8:case"end":return h.stop()}},x,this)})),function(){return c.apply(this,arguments)})},{key:"startMixTranscode",value:(s=G(m().mark(function x(h){return m().wrap(function(E){for(;;)switch(E.prev=E.next){case 0:if(this.isJoined_&&this.mixTranscodeManager_){E.next=2;break}throw new re({code:ee.INVALID_OPERATION,message:ie({key:c3})});case 2:return ge(h.mode)&&(h.mode=qp.MANUAL),E.prev=3,this.log_.info("startMixTranscode with config ".concat(JSON.stringify(h))),Ie.uploadEvent({log:"mix-transcode-mode:".concat(h.mode),userId:this.userId_}),E.next=8,this.mixTranscodeManager_.startMixTranscode(h);case 8:Ie.logSuccessEvent({userId:this.userId_,eventType:Fb}),E.next=15;break;case 11:throw E.prev=11,E.t0=E.catch(3),Ie.logFailedEvent({userId:this.userId_,eventType:Fb,error:E.t0}),E.t0;case 15:case"end":return E.stop()}},x,this,[[3,11]])})),function(x){return s.apply(this,arguments)})},{key:"stopMixTranscode",value:(o=G(m().mark(function x(){return m().wrap(function(h){for(;;)switch(h.prev=h.next){case 0:if(this.isJoined_&&this.mixTranscodeManager_){h.next=2;break}throw new re({code:ee.INVALID_OPERATION,message:ie({key:u3})});case 2:return h.prev=2,h.next=5,this.mixTranscodeManager_.stopMixTranscode();case 5:Ie.logSuccessEvent({userId:this.userId_,eventType:Gb}),h.next=12;break;case 8:throw h.prev=8,h.t0=h.catch(2),Ie.logFailedEvent({userId:this.userId_,eventType:Gb,error:h.t0}),h.t0;case 12:case"end":return h.stop()}},x,this,[[2,8]])})),function(){return o.apply(this,arguments)})},{key:"getSystemResult",value:function(){return this.checkSystemResult_}},{key:"enableAudioVolumeEvaluation",value:function(){var x=this,h=arguments.length>0&&arguments[0]!==void 0?arguments[0]:2e3,E=arguments.length>1&&arguments[1]!==void 0&&arguments[1];if(!Zn(h))throw new re({code:ee.INVALID_PARAMETER,message:ie({key:l3})});if(this.log_.info("enableAudioVolumeEvaluation with interval: "+h),h<=0)return this.enableAudioVolumeEvaluation_=!1,_t.clearTask(this.audioVolumeIntervalId_),void(this.audioVolumeIntervalId_=null);h=Math.floor(Math.max(h,16)),X.emit(Uf,{interval:h}),this.audioVolumeIntervalId_&&(_t.clearTask(this.audioVolumeIntervalId_),this.audioVolumeIntervalId_=null),this.enableAudioVolumeEvaluation_=!0,this.audioVolumeIntervalId_=_t.run(el,function(){var O=[];if(x.localStream_){var N=Math.floor(100*x.localStream_.getAudioLevel());O.push({userId:x.userId_,audioVolume:N,stream:x.localStream_})}x.connections_.forEach(function(j){var J=j.getSubscribedMainStream();if(J){var $=Math.floor(100*J.getAudioLevel());O.push({userId:j.getUserId(),audioVolume:$,stream:J})}}),x.emitter_.emit(ct.AUDIO_VOLUME,{result:O})},{fps:1e3/h,backgroundTask:E})}},{key:"callExperimentalAPI",value:function(x,h){return c7.call(x,q({client:this},h))}},{key:"setProperty",value:function(x,h){var E="".concat(x,"_");ge(this[E])||(this[E]=h)}},{key:"uploadAllCallStats",value:function(){var x=this;this.callDurationCalculator_.getDurationMap().forEach(function(h,E){var O={userId:h.userId,type:h.type,duration:x.callDurationCalculator_.getDuration(E,xe),dataFreeze:x.badCaseDetector_.getDataFreezeDuration(E).dataFreeze,renderFreeze:x.badCaseDetector_.getRenderFreezeDuration(E).renderFreeze};Ie.uploadEvent({log:"callStats-"+JSON.stringify(O),userId:x.userId_})}),this.badCaseDetector_.stop(),this.callDurationCalculator_.reset()}},{key:"enableSmallStream",value:(r=G(m().mark(function x(){return m().wrap(function(h){for(;;)switch(h.prev=h.next){case 0:if(!this.isPublished()&&!this.isPublishing_){h.next=2;break}throw new re({code:ee.INVALID_OPERATION,message:ie({key:d3})});case 2:if(!Hk()){h.next=7;break}this.setIsEnableSmallStream(!0),this.log_.info("SmallStream successfully enabled"),h.next=8;break;case 7:throw new re({code:ee.INVALID_OPERATION,message:ie({key:p3})});case 8:case"end":return h.stop()}},x,this)})),function(){return r.apply(this,arguments)})},{key:"disableSmallStream",value:(i=G(m().mark(function x(){return m().wrap(function(h){for(;;)switch(h.prev=h.next){case 0:if(!this.isPublished()&&!this.isPublishing_){h.next=2;break}throw new re({code:ee.INVALID_OPERATION,message:ie({key:h3})});case 2:this.setIsEnableSmallStream(!1),this.log_.info("SmallStream successfully disabled");case 4:case"end":return h.stop()}},x,this)})),function(){return i.apply(this,arguments)})},{key:"setSmallStreamProfile",value:function(x){var h=this;x&&x.framerate&&(x.frameRate=x.framerate),x.width*x.height>307200&&(x.width=320,x.height=240,this.log_.info("Small stream resolution is beyond limitation, which is invalid. Reset to 320 * 240")),Object.keys(this.smallStreamConfig_).forEach(function($){x[$]&&(h.smallStreamConfig_[$]=x[$])});var E=this.smallStreamConfig_,O=E.width,N=E.height,j=E.bitrate,J=E.frameRate;if(this.log_.info("setSmallStreamProfile: bitrate=".concat(j,", frameRate=").concat(J,", height=").concat(N,", width=").concat(O)),O<0||N<0||j<0||J<0)throw new re({code:ee.INVALID_PARAMETER,message:ie({key:f3})})}},{key:"setRemoteVideoStreamType",value:(a=G(m().mark(function x(h,E){return m().wrap(function(O){for(;;)switch(O.prev=O.next){case 0:if(h instanceof Gv){O.next=2;break}throw new re({code:ee.INVALID_PARAMETER,message:ie({key:m3})});case 2:if(h.getConnection()){O.next=4;break}throw new re({code:ee.INVALID_OPERATION,message:ie({key:ef})});case 4:if(h.getType()!==Lt){O.next=6;break}return O.abrupt("return");case 6:O.t0=E,O.next=O.t0===Kb||O.t0===Xb?9:12;break;case 9:return O.next=11,this.changeVideoType(h,E);case 11:case 12:return O.abrupt("break",13);case 13:case"end":return O.stop()}},x,this)})),function(x,h){return a.apply(this,arguments)})},{key:"changeVideoType",value:(n=G(m().mark(function x(h,E){var O,N;return m().wrap(function(j){for(;;)switch(j.prev=j.next){case 0:O=h.getUserId(),N={stream:h,options:{video:E===Kb,smallVideo:E===Xb},isSubscribing:!1,reSubscribeCount:10},this.changeBigSmallRecords_.set(O,N),this.log_.info("set [".concat(O,"] ").concat(h.getType()," stream video prefer type: ").concat(E));case 5:case"end":return j.stop()}},x,this)})),function(x,h){return n.apply(this,arguments)})},{key:"checkSubscribeBigSmallVideo",value:(t=G(m().mark(function x(h,E){var O,N,j,J,$,he,ue,Ee,Ve,We,kt;return m().wrap(function(Ne){for(;;)switch(Ne.prev=Ne.next){case 0:if(h!=null&&h.isBigStreamSubscribed||h!=null&&h.isSmallStreamSubscribed){Ne.next=2;break}return Ne.abrupt("return");case 2:if(O=h.getUserId(),this.changeBigSmallRecords_.has(O)){Ne.next=5;break}return Ne.abrupt("return");case 5:if(N=this.changeBigSmallRecords_.get(O),j=h.getSubscribeState(),J=j.video,$=j.smallVideo,he=N.stream,ue=N.options,Ee=N.isSubscribing,Ve=N.reSubscribeCount,!(ue.video&&J||ue.smallVideo&&$&&E)){Ne.next=10;break}return Ne.abrupt("return");case 10:if(We={video:ue.video,smallVideo:ue.smallVideo},!(E&&h.isBigStreamSubscribed||h.isSmallStreamSubscribed)){Ne.next=31;break}if(Ne.prev=12,!(ue&&he&&!Ee&&Ve>=1)){Ne.next=24;break}return N.isSubscribing=!0,N.reSubscribeCount=Ve-1,kt=he.getConnection(),!E&&kt.isSmallStreamSubscribed&&(We={video:!0,smallVideo:!1}),We.emitEvent=!1,Ne.next=21,kt==null?void 0:kt.subscribe(he,We);case 21:this.log_.info("change [".concat(O,"] to ").concat(We.smallVideo?"small":"big"," video successfully. count ").concat(10-N.reSubscribeCount,".")),N.isSubscribing=!1,N.reSubscribeCount=10;case 24:Ne.next=31;break;case 26:Ne.prev=26,Ne.t0=Ne.catch(12),this.log_.info("change [".concat(O,"] to ").concat(We.smallVideo?"small":"big"," video failed. count ").concat(10-N.reSubscribeCount,".")),N.isSubscribing=!1,Ve===0&&this.changeBigSmallRecords_.delete(O);case 31:case"end":return Ne.stop()}},x,this,[[12,26]])})),function(x,h){return t.apply(this,arguments)})},{key:"setIsEnableSmallStream",value:function(x){this.isEnableSmallStream_=x}},{key:"getIsEnableSmallStream",value:function(){return this.isEnableSmallStream_}},{key:"smallStreamConfig",get:function(){return this.smallStreamConfig_}},{key:"isPublished",value:function(){return!!this.localStream_}},{key:"getUplinkConnection",value:function(){return this.uplinkConnection_}},{key:"getLocalStream",value:function(){return this.localStream_}},{key:"getMode",value:function(){return this.mode_}},{key:"getBadCaseDetector",value:function(){return this.badCaseDetector_}},{key:"getCallDurationCalculator",value:function(){return this.callDurationCalculator_}},{key:"getIsJoined",value:function(){return this.isJoined_}},{key:"getAllConnections",value:function(){var x=be(this.connections_.values());return this.uplinkConnection_&&x.push(this.uplinkConnection_),x}},{key:"isRelayMaybeFailed",value:function(){if(!this.signalChannel_.isOnline)return!1;var x=this.getAllConnections();if(x.length===0)return!1;for(var h=0;h<x.length;h++)if(x[h].getReconnectionCount()<6)return!1;return!0}},{key:"getUseStringRoomId",value:function(){return this.useStringRoomId_}},{key:"checkConnectionsToReconnect",value:function(){var x=this;this.getAllConnections().forEach(function(h){if(!h.getIsReconnecting()){var E=h.getPeerConnection();E&&E.connectionState===Bp&&(x.log_.warn("[".concat(h.getUserId(),"] pc is closed but not reconnect")),h.startReconnection())}})}},{key:"getEnableAutoPlayDialog",value:function(){return this.enableAutoPlayDialog_}},{key:"sendSEIMessage",value:function(x,h){this.uplinkConnection_.sendSEI(x,h)}},{key:"setProxyServer",value:function(x){if(this.log_.info("set proxy server: ".concat(JSON.stringify(x))),Vt(x)){if(!x.startsWith("wss://"))throw new re({code:ee.INVALID_PARAMETER,message:ie({key:GN})});this.proxy_=x}else if(Ei(x)){var h=x.websocketProxy,E=x.loggerProxy,O=x.scheduleProxy,N=x.unifiedProxy;h&&(this.proxy_=h),E&&Up(E),O&&Yb(O),N&&(this.unifiedProxy_=N,Up("https://".concat(N)),Yb(N))}}},{key:"setTurnServer",value:function(x){this.log_.info("set turn server: "+JSON.stringify(x));var h=[];Array.isArray(x)?x.forEach(function(E){return h.push(BS(E))}):Ei(x)&&h.push(BS(x)),this.turnServers_=h}},{key:"get2k4kFlag",value:function(){var x,h;return((x=this.schedule_)===null||x===void 0||(h=x.trtcCapability)===null||h===void 0?void 0:h["2k4k"])||2}}]),e}(),Y(Le.prototype,"join",[hI,pI,fI],Object.getOwnPropertyDescriptor(Le.prototype,"join"),Le.prototype),Y(Le.prototype,"leave",[mI],Object.getOwnPropertyDescriptor(Le.prototype,"leave"),Le.prototype),Y(Le.prototype,"getUserList",[vI],Object.getOwnPropertyDescriptor(Le.prototype,"getUserList"),Le.prototype),Y(Le.prototype,"publish",[gI,_I,yI],Object.getOwnPropertyDescriptor(Le.prototype,"publish"),Le.prototype),Y(Le.prototype,"unpublish",[bI,SI],Object.getOwnPropertyDescriptor(Le.prototype,"unpublish"),Le.prototype),Y(Le.prototype,"subscribe",[kI],Object.getOwnPropertyDescriptor(Le.prototype,"subscribe"),Le.prototype),Y(Le.prototype,"unsubscribe",[TI],Object.getOwnPropertyDescriptor(Le.prototype,"unsubscribe"),Le.prototype),Y(Le.prototype,"switchRole",[xI,II,wI],Object.getOwnPropertyDescriptor(Le.prototype,"switchRole"),Le.prototype),Y(Le.prototype,"startPublishCDNStream",[EI,CI],Object.getOwnPropertyDescriptor(Le.prototype,"startPublishCDNStream"),Le.prototype),Y(Le.prototype,"stopPublishCDNStream",[RI],Object.getOwnPropertyDescriptor(Le.prototype,"stopPublishCDNStream"),Le.prototype),Y(Le.prototype,"startMixTranscode",[AI,PI],Object.getOwnPropertyDescriptor(Le.prototype,"startMixTranscode"),Le.prototype),Y(Le.prototype,"stopMixTranscode",[DI],Object.getOwnPropertyDescriptor(Le.prototype,"stopMixTranscode"),Le.prototype),Y(Le.prototype,"enableAudioVolumeEvaluation",[LI],Object.getOwnPropertyDescriptor(Le.prototype,"enableAudioVolumeEvaluation"),Le.prototype),Y(Le.prototype,"enableSmallStream",[OI],Object.getOwnPropertyDescriptor(Le.prototype,"enableSmallStream"),Le.prototype),Y(Le.prototype,"disableSmallStream",[MI],Object.getOwnPropertyDescriptor(Le.prototype,"disableSmallStream"),Le.prototype),Y(Le.prototype,"setSmallStreamProfile",[NI],Object.getOwnPropertyDescriptor(Le.prototype,"setSmallStreamProfile"),Le.prototype),Y(Le.prototype,"setRemoteVideoStreamType",[UI],Object.getOwnPropertyDescriptor(Le.prototype,"setRemoteVideoStreamType"),Le.prototype),Y(Le.prototype,"sendSEIMessage",[VI,jI,BI],Object.getOwnPropertyDescriptor(Le.prototype,"sendSEIMessage"),Le.prototype),Y(Le.prototype,"setProxyServer",[FI],Object.getOwnPropertyDescriptor(Le.prototype,"setProxyServer"),Le.prototype),Y(Le.prototype,"setTurnServer",[GI],Object.getOwnPropertyDescriptor(Le.prototype,"setTurnServer"),Le.prototype),Le),l7=0,d7=0,h7=(HI=St(oc),zI=St(oc),WI=St(oc),qI=$l(Jt.TRTC.createClient),JI=St(oc),KI=$l(Jt.TRTC.createStream),Kt=function(){function e(){K(this,e),this.name_=oc,this.VERSION=pi,this.Logger={loggerManager:_e,LogLevel:Nn,setLogLevel:function(n){_e.setLogLevel(n),n<=1&&N4()},enableUploadLog:function(){Ui.handleFunctionState({fnName:"TRTC.enableUploadLog"}),_e.enableUploadLog()},disableUploadLog:function(){_e.warn("disableUploadLog"),Ui.handleFunctionState({fnName:"TRTC.disableUploadLog"}),_e.disableUploadLog()}}}var t;return we(e,[{key:"checkSystemRequirements",value:(t=G(m().mark(function n(){return m().wrap(function(a){for(;;)switch(a.prev=a.next){case 0:return a.next=2,ym();case 2:return a.abrupt("return",a.sent);case 3:case"end":return a.stop()}},n)})),function(){return t.apply(this,arguments)})},{key:"isScreenShareSupported",value:function(){return jk()}},{key:"isSmallStreamSupported",value:function(){return Hk()}},{key:"getDevices",value:function(){return Em()}},{key:"getCameras",value:function(){return function(){return wm.apply(this,arguments)}()}},{key:"getMicrophones",value:function(){return Jk()}},{key:"getSpeakers",value:function(){return Kk()}},{key:"createClient",value:function(n){(function(){if(YS&&(YS=!1,_e.getLogLevel()!=Tt.Logger.LogLevel.NONE&&(console.info("******************************************************************************"),console.info("* TRTC Web SDK"),console.info("* API Document: "+"".concat(Yp,"index.html")),console.info("* Changelog: https://cloud.tencent.com/document/product/647/38958"),console.info("* Report issues: https://github.com/LiteAVSDK/TRTC_Web/issues"),console.info("******************************************************************************")),_e.info("TRTC Web SDK Version: "+pi),_e.info("UserAgent: "+navigator.userAgent),_e.info("URL of current page: "+location.href),navigator.userAgentData&&ln(navigator.userAgentData.getHighEntropyValues)))try{navigator.userAgentData.getHighEntropyValues(["architecture","bitness","model","platformVersion","fullVersionList"]).then(function(r){var o="UAData: ".concat(r.platform,"/").concat(r.platformVersion);r.architecture&&r.bitness&&(o+=" ".concat(r.architecture,"/").concat(r.bitness)),r.mobile&&(o+=" mobile"),r.model&&(o+=" model: ".concat(r.model)),r.fullVersionList&&(o+=" ".concat(r.fullVersionList.filter(function(s){return s.brand!=="Not/A)Brand"}).map(function(s){return"".concat(s.brand,"/").concat(s.version)}).join(","))),_e.info(o)}).catch(function(){})}catch(r){}})();var a={version:this.VERSION},i=new u7(q(q(q({},a),n),{},{seq:++l7}));return X.emit(JS,{client:i}),i}},{key:"createStream",value:function(n){return new RF(q(q({},n),{},{seq:++d7}))}}]),e}(),Y(Kt.prototype,"checkSystemRequirements",[HI],Object.getOwnPropertyDescriptor(Kt.prototype,"checkSystemRequirements"),Kt.prototype),Y(Kt.prototype,"isScreenShareSupported",[zI],Object.getOwnPropertyDescriptor(Kt.prototype,"isScreenShareSupported"),Kt.prototype),Y(Kt.prototype,"isSmallStreamSupported",[WI],Object.getOwnPropertyDescriptor(Kt.prototype,"isSmallStreamSupported"),Kt.prototype),Y(Kt.prototype,"createClient",[qI,JI],Object.getOwnPropertyDescriptor(Kt.prototype,"createClient"),Kt.prototype),Y(Kt.prototype,"createStream",[KI],Object.getOwnPropertyDescriptor(Kt.prototype,"createStream"),Kt.prototype),Kt),Tt=new h7;return Tt})});var sg=rg((M7,og)=>{"use strict";var Wo=typeof Reflect=="object"?Reflect:null,aw=Wo&&typeof Wo.apply=="function"?Wo.apply:function(q,m,H){return Function.prototype.apply.call(q,m,H)},vd;Wo&&typeof Wo.ownKeys=="function"?vd=Wo.ownKeys:Object.getOwnPropertySymbols?vd=function(q){return Object.getOwnPropertyNames(q).concat(Object.getOwnPropertySymbols(q))}:vd=function(q){return Object.getOwnPropertyNames(q)};function k7(ne){console&&console.warn&&console.warn(ne)}var sw=Number.isNaN||function(q){return q!==q};function dt(){dt.init.call(this)}og.exports=dt;og.exports.once=w7;dt.EventEmitter=dt;dt.prototype._events=void 0;dt.prototype._eventsCount=0;dt.prototype._maxListeners=void 0;var ow=10;function gd(ne){if(typeof ne!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof ne)}Object.defineProperty(dt,"defaultMaxListeners",{enumerable:!0,get:function(){return ow},set:function(ne){if(typeof ne!="number"||ne<0||sw(ne))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+ne+".");ow=ne}});dt.init=function(){(this._events===void 0||this._events===Object.getPrototypeOf(this)._events)&&(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0};dt.prototype.setMaxListeners=function(q){if(typeof q!="number"||q<0||sw(q))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+q+".");return this._maxListeners=q,this};function cw(ne){return ne._maxListeners===void 0?dt.defaultMaxListeners:ne._maxListeners}dt.prototype.getMaxListeners=function(){return cw(this)};dt.prototype.emit=function(q){for(var m=[],H=1;H<arguments.length;H++)m.push(arguments[H]);var Q=q==="error",G=this._events;if(G!==void 0)Q=Q&&G.error===void 0;else if(!Q)return!1;if(Q){var K;if(m.length>0&&(K=m[0]),K instanceof Error)throw K;var Pe=new Error("Unhandled error."+(K?" ("+K.message+")":""));throw Pe.context=K,Pe}var we=G[q];if(we===void 0)return!1;if(typeof we=="function")aw(we,this,m);else for(var Ye=we.length,Ct=pw(we,Ye),H=0;H<Ye;++H)aw(Ct[H],this,m);return!0};function uw(ne,q,m,H){var Q,G,K;if(gd(m),G=ne._events,G===void 0?(G=ne._events=Object.create(null),ne._eventsCount=0):(G.newListener!==void 0&&(ne.emit("newListener",q,m.listener?m.listener:m),G=ne._events),K=G[q]),K===void 0)K=G[q]=m,++ne._eventsCount;else if(typeof K=="function"?K=G[q]=H?[m,K]:[K,m]:H?K.unshift(m):K.push(m),Q=cw(ne),Q>0&&K.length>Q&&!K.warned){K.warned=!0;var Pe=new Error("Possible EventEmitter memory leak detected. "+K.length+" "+String(q)+" listeners added. Use emitter.setMaxListeners() to increase limit");Pe.name="MaxListenersExceededWarning",Pe.emitter=ne,Pe.type=q,Pe.count=K.length,k7(Pe)}return ne}dt.prototype.addListener=function(q,m){return uw(this,q,m,!1)};dt.prototype.on=dt.prototype.addListener;dt.prototype.prependListener=function(q,m){return uw(this,q,m,!0)};function T7(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function lw(ne,q,m){var H={fired:!1,wrapFn:void 0,target:ne,type:q,listener:m},Q=T7.bind(H);return Q.listener=m,H.wrapFn=Q,Q}dt.prototype.once=function(q,m){return gd(m),this.on(q,lw(this,q,m)),this};dt.prototype.prependOnceListener=function(q,m){return gd(m),this.prependListener(q,lw(this,q,m)),this};dt.prototype.removeListener=function(q,m){var H,Q,G,K,Pe;if(gd(m),Q=this._events,Q===void 0)return this;if(H=Q[q],H===void 0)return this;if(H===m||H.listener===m)--this._eventsCount===0?this._events=Object.create(null):(delete Q[q],Q.removeListener&&this.emit("removeListener",q,H.listener||m));else if(typeof H!="function"){for(G=-1,K=H.length-1;K>=0;K--)if(H[K]===m||H[K].listener===m){Pe=H[K].listener,G=K;break}if(G<0)return this;G===0?H.shift():x7(H,G),H.length===1&&(Q[q]=H[0]),Q.removeListener!==void 0&&this.emit("removeListener",q,Pe||m)}return this};dt.prototype.off=dt.prototype.removeListener;dt.prototype.removeAllListeners=function(q){var m,H,Q;if(H=this._events,H===void 0)return this;if(H.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):H[q]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete H[q]),this;if(arguments.length===0){var G=Object.keys(H),K;for(Q=0;Q<G.length;++Q)K=G[Q],K!=="removeListener"&&this.removeAllListeners(K);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(m=H[q],typeof m=="function")this.removeListener(q,m);else if(m!==void 0)for(Q=m.length-1;Q>=0;Q--)this.removeListener(q,m[Q]);return this};function dw(ne,q,m){var H=ne._events;if(H===void 0)return[];var Q=H[q];return Q===void 0?[]:typeof Q=="function"?m?[Q.listener||Q]:[Q]:m?I7(Q):pw(Q,Q.length)}dt.prototype.listeners=function(q){return dw(this,q,!0)};dt.prototype.rawListeners=function(q){return dw(this,q,!1)};dt.listenerCount=function(ne,q){return typeof ne.listenerCount=="function"?ne.listenerCount(q):hw.call(ne,q)};dt.prototype.listenerCount=hw;function hw(ne){var q=this._events;if(q!==void 0){var m=q[ne];if(typeof m=="function")return 1;if(m!==void 0)return m.length}return 0}dt.prototype.eventNames=function(){return this._eventsCount>0?vd(this._events):[]};function pw(ne,q){for(var m=new Array(q),H=0;H<q;++H)m[H]=ne[H];return m}function x7(ne,q){for(;q+1<ne.length;q++)ne[q]=ne[q+1];ne.pop()}function I7(ne){for(var q=new Array(ne.length),m=0;m<q.length;++m)q[m]=ne[m].listener||ne[m];return q}function w7(ne,q){return new Promise(function(m,H){function Q(K){ne.removeListener(q,G),H(K)}function G(){typeof ne.removeListener=="function"&&ne.removeListener("error",Q),m([].slice.call(arguments))}fw(ne,q,G,{once:!0}),q!=="error"&&E7(ne,Q,{once:!0})})}function E7(ne,q,m){typeof ne.on=="function"&&fw(ne,"error",q,m)}function fw(ne,q,m,H){if(typeof ne.on=="function")H.once?ne.once(q,m):ne.on(q,m);else if(typeof ne.addEventListener=="function")ne.addEventListener(q,function Q(G){H.once&&ne.removeEventListener(q,Q),m(G)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof ne)}});var vw=rg((cg,ug)=>{(function(ne,q){typeof cg=="object"&&typeof ug!="undefined"?ug.exports=q(Er()):typeof define=="function"&&define.amd?define(["trtc-js-sdk"],q):(ne=typeof globalThis!="undefined"?globalThis:ne||self).RTCBeautyPlugin=q(ne.TRTC)})(cg,function(ne){function q(oe){return oe&&typeof oe=="object"&&"default"in oe?oe:{default:oe}}var m=q(ne);function H(){H=function(){return oe};var oe={},Te=Object.prototype,be=Te.hasOwnProperty,Fe=typeof Symbol=="function"?Symbol:{},He=Fe.iterator||"@@iterator",ae=Fe.asyncIterator||"@@asyncIterator",te=Fe.toStringTag||"@@toStringTag";function Y(fe,de,je){return Object.defineProperty(fe,de,{value:je,enumerable:!0,configurable:!0,writable:!0}),fe[de]}try{Y({},"")}catch(fe){Y=function(de,je,qe){return de[je]=qe}}function z(fe,de,je,qe){var Oe=de&&de.prototype instanceof ye?de:ye,ut=Object.create(Oe.prototype),xt=new et(qe||[]);return ut._invoke=function(ht,Qt,$e){var ke="suspendedStart";return function(Ht,ri){if(ke==="executing")throw new Error("Generator is already running");if(ke==="completed"){if(Ht==="throw")throw ri;return Kn()}for($e.method=Ht,$e.arg=ri;;){var Rr=$e.delegate;if(Rr){var Ar=qn(Rr,$e);if(Ar){if(Ar===se)continue;return Ar}}if($e.method==="next")$e.sent=$e._sent=$e.arg;else if($e.method==="throw"){if(ke==="suspendedStart")throw ke="completed",$e.arg;$e.dispatchException($e.arg)}else $e.method==="return"&&$e.abrupt("return",$e.arg);ke="executing";var zt=le(ht,Qt,$e);if(zt.type==="normal"){if(ke=$e.done?"completed":"suspendedYield",zt.arg===se)continue;return{value:zt.arg,done:$e.done}}zt.type==="throw"&&(ke="completed",$e.method="throw",$e.arg=zt.arg)}}}(fe,je,xt),ut}function le(fe,de,je){try{return{type:"normal",arg:fe.call(de,je)}}catch(qe){return{type:"throw",arg:qe}}}oe.wrap=z;var se={};function ye(){}function ce(){}function Se(){}var Dt={};Y(Dt,He,function(){return this});var Tn=Object.getPrototypeOf,Gt=Tn&&Tn(Tn(Rt([])));Gt&&Gt!==Te&&be.call(Gt,He)&&(Dt=Gt);var Ke=Se.prototype=ye.prototype=Object.create(Dt);function it(fe){["next","throw","return"].forEach(function(de){Y(fe,de,function(je){return this._invoke(de,je)})})}function Wn(fe,de){function je(Oe,ut,xt,ht){var Qt=le(fe[Oe],fe,ut);if(Qt.type!=="throw"){var $e=Qt.arg,ke=$e.value;return ke&&typeof ke=="object"&&be.call(ke,"__await")?de.resolve(ke.__await).then(function(Ht){je("next",Ht,xt,ht)},function(Ht){je("throw",Ht,xt,ht)}):de.resolve(ke).then(function(Ht){$e.value=Ht,xt($e)},function(Ht){return je("throw",Ht,xt,ht)})}ht(Qt.arg)}var qe;this._invoke=function(Oe,ut){function xt(){return new de(function(ht,Qt){je(Oe,ut,ht,Qt)})}return qe=qe?qe.then(xt,xt):xt()}}function qn(fe,de){var je=fe.iterator[de.method];if(je===void 0){if(de.delegate=null,de.method==="throw"){if(fe.iterator.return&&(de.method="return",de.arg=void 0,qn(fe,de),de.method==="throw"))return se;de.method="throw",de.arg=new TypeError("The iterator does not provide a 'throw' method")}return se}var qe=le(je,fe.iterator,de.arg);if(qe.type==="throw")return de.method="throw",de.arg=qe.arg,de.delegate=null,se;var Oe=qe.arg;return Oe?Oe.done?(de[fe.resultName]=Oe.value,de.next=fe.nextLoc,de.method!=="return"&&(de.method="next",de.arg=void 0),de.delegate=null,se):Oe:(de.method="throw",de.arg=new TypeError("iterator result is not an object"),de.delegate=null,se)}function Jn(fe){var de={tryLoc:fe[0]};1 in fe&&(de.catchLoc=fe[1]),2 in fe&&(de.finallyLoc=fe[2],de.afterLoc=fe[3]),this.tryEntries.push(de)}function Xt(fe){var de=fe.completion||{};de.type="normal",delete de.arg,fe.completion=de}function et(fe){this.tryEntries=[{tryLoc:"root"}],fe.forEach(Jn,this),this.reset(!0)}function Rt(fe){if(fe){var de=fe[He];if(de)return de.call(fe);if(typeof fe.next=="function")return fe;if(!isNaN(fe.length)){var je=-1,qe=function Oe(){for(;++je<fe.length;)if(be.call(fe,je))return Oe.value=fe[je],Oe.done=!1,Oe;return Oe.value=void 0,Oe.done=!0,Oe};return qe.next=qe}}return{next:Kn}}function Kn(){return{value:void 0,done:!0}}return ce.prototype=Se,Y(Ke,"constructor",Se),Y(Se,"constructor",ce),ce.displayName=Y(Se,te,"GeneratorFunction"),oe.isGeneratorFunction=function(fe){var de=typeof fe=="function"&&fe.constructor;return!!de&&(de===ce||(de.displayName||de.name)==="GeneratorFunction")},oe.mark=function(fe){return Object.setPrototypeOf?Object.setPrototypeOf(fe,Se):(fe.__proto__=Se,Y(fe,te,"GeneratorFunction")),fe.prototype=Object.create(Ke),fe},oe.awrap=function(fe){return{__await:fe}},it(Wn.prototype),Y(Wn.prototype,ae,function(){return this}),oe.AsyncIterator=Wn,oe.async=function(fe,de,je,qe,Oe){Oe===void 0&&(Oe=Promise);var ut=new Wn(z(fe,de,je,qe),Oe);return oe.isGeneratorFunction(de)?ut:ut.next().then(function(xt){return xt.done?xt.value:ut.next()})},it(Ke),Y(Ke,te,"Generator"),Y(Ke,He,function(){return this}),Y(Ke,"toString",function(){return"[object Generator]"}),oe.keys=function(fe){var de=[];for(var je in fe)de.push(je);return de.reverse(),function qe(){for(;de.length;){var Oe=de.pop();if(Oe in fe)return qe.value=Oe,qe.done=!1,qe}return qe.done=!0,qe}},oe.values=Rt,et.prototype={constructor:et,reset:function(fe){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(Xt),!fe)for(var de in this)de.charAt(0)==="t"&&be.call(this,de)&&!isNaN(+de.slice(1))&&(this[de]=void 0)},stop:function(){this.done=!0;var fe=this.tryEntries[0].completion;if(fe.type==="throw")throw fe.arg;return this.rval},dispatchException:function(fe){if(this.done)throw fe;var de=this;function je(Qt,$e){return ut.type="throw",ut.arg=fe,de.next=Qt,$e&&(de.method="next",de.arg=void 0),!!$e}for(var qe=this.tryEntries.length-1;qe>=0;--qe){var Oe=this.tryEntries[qe],ut=Oe.completion;if(Oe.tryLoc==="root")return je("end");if(Oe.tryLoc<=this.prev){var xt=be.call(Oe,"catchLoc"),ht=be.call(Oe,"finallyLoc");if(xt&&ht){if(this.prev<Oe.catchLoc)return je(Oe.catchLoc,!0);if(this.prev<Oe.finallyLoc)return je(Oe.finallyLoc)}else if(xt){if(this.prev<Oe.catchLoc)return je(Oe.catchLoc,!0)}else{if(!ht)throw new Error("try statement without catch or finally");if(this.prev<Oe.finallyLoc)return je(Oe.finallyLoc)}}}},abrupt:function(fe,de){for(var je=this.tryEntries.length-1;je>=0;--je){var qe=this.tryEntries[je];if(qe.tryLoc<=this.prev&&be.call(qe,"finallyLoc")&&this.prev<qe.finallyLoc){var Oe=qe;break}}Oe&&(fe==="break"||fe==="continue")&&Oe.tryLoc<=de&&de<=Oe.finallyLoc&&(Oe=null);var ut=Oe?Oe.completion:{};return ut.type=fe,ut.arg=de,Oe?(this.method="next",this.next=Oe.finallyLoc,se):this.complete(ut)},complete:function(fe,de){if(fe.type==="throw")throw fe.arg;return fe.type==="break"||fe.type==="continue"?this.next=fe.arg:fe.type==="return"?(this.rval=this.arg=fe.arg,this.method="return",this.next="end"):fe.type==="normal"&&de&&(this.next=de),se},finish:function(fe){for(var de=this.tryEntries.length-1;de>=0;--de){var je=this.tryEntries[de];if(je.finallyLoc===fe)return this.complete(je.completion,je.afterLoc),Xt(je),se}},catch:function(fe){for(var de=this.tryEntries.length-1;de>=0;--de){var je=this.tryEntries[de];if(je.tryLoc===fe){var qe=je.completion;if(qe.type==="throw"){var Oe=qe.arg;Xt(je)}return Oe}}throw new Error("illegal catch attempt")},delegateYield:function(fe,de,je){return this.delegate={iterator:Rt(fe),resultName:de,nextLoc:je},this.method==="next"&&(this.arg=void 0),se}},oe}function Q(oe){return Q=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(Te){return typeof Te}:function(Te){return Te&&typeof Symbol=="function"&&Te.constructor===Symbol&&Te!==Symbol.prototype?"symbol":typeof Te},Q(oe)}function G(oe,Te,be,Fe,He,ae,te){try{var Y=oe[ae](te),z=Y.value}catch(le){return void be(le)}Y.done?Te(z):Promise.resolve(z).then(Fe,He)}function K(oe){return function(){var Te=this,be=arguments;return new Promise(function(Fe,He){var ae=oe.apply(Te,be);function te(z){G(ae,Fe,He,te,Y,"next",z)}function Y(z){G(ae,Fe,He,te,Y,"throw",z)}te(void 0)})}}function Pe(oe,Te){if(!(oe instanceof Te))throw new TypeError("Cannot call a class as a function")}function we(oe,Te){for(var be=0;be<Te.length;be++){var Fe=Te[be];Fe.enumerable=Fe.enumerable||!1,Fe.configurable=!0,"value"in Fe&&(Fe.writable=!0),Object.defineProperty(oe,Fe.key,Fe)}}function Ye(oe,Te,be){return Te&&we(oe.prototype,Te),be&&we(oe,be),Object.defineProperty(oe,"prototype",{writable:!1}),oe}function Ct(oe,Te,be){var Fe=function(le,se,ye){var ce=new RegExp("\\b".concat(se," \\w+ (\\w+)"),"ig");le.replace(ce,function(Se,Dt){return ye[Dt]=0,Se})},He=function(le,se,ye){var ce=le.createShader(ye);return le.shaderSource(ce,se),le.compileShader(ce),le.getShaderParameter(ce,le.COMPILE_STATUS)?ce:(console.log(le.getShaderInfoLog(ce)),null)};this.uniform={},this.attribute={};var ae=He(oe,Te,oe.VERTEX_SHADER),te=He(oe,be,oe.FRAGMENT_SHADER);for(var Y in this.id=oe.createProgram(),oe.attachShader(this.id,ae),oe.attachShader(this.id,te),oe.linkProgram(this.id),oe.getProgramParameter(this.id,oe.LINK_STATUS)||console.log(oe.getProgramInfoLog(this.id)),oe.useProgram(this.id),Fe(Te,"attribute",this.attribute),this.attribute)this.attribute[Y]=oe.getAttribLocation(this.id,Y);for(var z in Fe(Te,"uniform",this.uniform),Fe(be,"uniform",this.uniform),this.uniform)this.uniform[z]=oe.getUniformLocation(this.id,z)}function Xe(oe,Te,be,Fe){for(var He=[],ae=0;ae<Te.length;++ae)He.push(Mc(oe,Te[ae],oe[lr[ae]]));return function(te,Y,z,le){var se=te.createProgram();return Y.forEach(function(ye){te.attachShader(se,ye)}),z&&z.forEach(function(ye,ce){te.bindAttribLocation(se,le?le[ce]:ce,ye)}),te.linkProgram(se),te.getProgramParameter(se,te.LINK_STATUS)?se:(te.deleteProgram(se),null)}(oe,He,be,Fe)}var lr=["VERTEX_SHADER","FRAGMENT_SHADER"];function Mc(oe,Te,be){var Fe=oe.createShader(be);return oe.shaderSource(Fe,Te),oe.compileShader(Fe),oe.getShaderParameter(Fe,oe.COMPILE_STATUS)?Fe:(oe.deleteShader(Fe),null)}var Zo=function(){function oe(Te){Pe(this,oe),this.canvas=Te.canvas,this.video=Te.video,this.width=Te.width||640,this.height=Te.height||480,this.vertexBuffer=null,this.currentProgram=null,this.applied=!1,this.beautyParams={beauty:.5,brightness:.5,ruddy:.5},this.gl=this.createGL(Te.canvas),this.sourceTexture=this.gl.createTexture()}return Ye(oe,[{key:"setRect",value:function(Te,be){this.width=Te,this.height=be}},{key:"apply",value:function(Te){if(!this.vertexBuffer){var be=new Float32Array([-1,-1,0,1,1,-1,1,1,-1,1,0,0,-1,1,0,0,1,-1,1,1,1,1,1,0]);this.vertexBuffer=this.gl.createBuffer(),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this.vertexBuffer),this.gl.bufferData(this.gl.ARRAY_BUFFER,be,this.gl.STATIC_DRAW),this.gl.pixelStorei(this.gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!0)}this.gl.viewport(0,0,this.width,this.height),this.gl.bindTexture(this.gl.TEXTURE_2D,this.sourceTexture),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_WRAP_S,this.gl.CLAMP_TO_EDGE),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_WRAP_T,this.gl.CLAMP_TO_EDGE),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_MIN_FILTER,this.gl.NEAREST),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_MAG_FILTER,this.gl.NEAREST),this.applied?this.gl.texSubImage2D(this.gl.TEXTURE_2D,0,0,0,this.gl.RGB,this.gl.UNSIGNED_BYTE,Te):(this.gl.texImage2D(this.gl.TEXTURE_2D,0,this.gl.RGB,this.gl.RGB,this.gl.UNSIGNED_BYTE,Te),this.applied=!0);var Fe=this.beautyParams,He=Fe.beauty,ae=Fe.brightness,te=Fe.ruddy,Y=2/this.width,z=2/this.height,le=this.compileBeautyShader();this.gl.uniform2f(le.uniform.singleStepOffset,Y,z);var se=new Float32Array([1-.8*He,1-.6*He,.1+.45*te,.1+.45*te]);this.gl.uniform4fv(le.uniform.params,se),this.gl.uniform1f(le.uniform.brightness,.12*ae),this.gl.bindTexture(this.gl.TEXTURE_2D,this.sourceTexture),this.gl.bindFramebuffer(this.gl.FRAMEBUFFER,null),this.gl.uniform1f(this.currentProgram.uniform.flipY,1),this.gl.drawArrays(this.gl.TRIANGLES,0,6)}},{key:"compileBeautyShader",value:function(){if(this.currentProgram)return this.currentProgram;this.currentProgram=new Ct(this.gl,["precision highp float;","attribute vec2 pos;","attribute vec2 uv;","varying vec2 vUv;","uniform float flipY;","void main(void) {","vUv = uv;","gl_Position = vec4(pos.x, pos.y*flipY, 0.0, 1.);","}"].join(`
|
|
67
|
+
b=`+R+":"+b+`\r
|
|
68
|
+
`)}},{key:"removeBandwidthRestriction",value:function(_){return _.replace(/b=AS:.*\r\n/,"").replace(/b=TIAS:.*\r\n/,"")}},{key:"removeVideoOrientation",value:function(_){return _.replace(/urn:3gpp:video-orientation/,"")}},{key:"connect",value:(o=H(p().mark(function _(){return p().wrap(function(b){for(;;)switch(b.prev=b.next){case 0:return b.prev=0,b.next=3,this.exchangeSDP();case 3:return b.next=5,this.waitForPeerConnectionConnected();case 5:b.next=11;break;case 7:throw b.prev=7,b.t0=b.catch(0),this.closePeerConnection(!0),b.t0;case 11:case"end":return b.stop()}},_,this,[[0,7]])})),function(){return o.apply(this,arguments)})},{key:"exchangeSDP",value:(r=H(p().mark(function _(){return p().wrap(function(b){for(;;)switch(b.prev=b.next){case 0:return b.prev=0,this.isSDPExchanging_=!0,b.next=4,this.createOffer();case 4:return this.log_.info("createOffer success, sending offer to remote server"),b.next=7,this.doExchangeSDP();case 7:this.isSDPExchanging_=!1,b.next=14;break;case 10:throw b.prev=10,b.t0=b.catch(0),this.isSDPExchanging_=!1,b.t0;case 14:case"end":return b.stop()}},_,this,[[0,10]])})),function(){return r.apply(this,arguments)})},{key:"createOffer",value:(i=H(p().mark(function _(){var b;return p().wrap(function(R){for(;;)switch(R.prev=R.next){case 0:return R.prev=0,R.next=3,this.peerConnection_.createOffer(Wx);case 3:return b=R.sent,R.next=6,this.peerConnection_.setLocalDescription(b);case 6:this.updateSSRC(b.sdp),ke.logSuccessEvent({userId:this.client_.getUserId(),eventType:qu,kind:"offer"}),R.next=14;break;case 10:throw R.prev=10,R.t0=R.catch(0),ke.logFailedEvent({userId:this.client_.getUserId(),eventType:qu,kind:"offer",error:R.t0}),R.t0;case 14:case"end":return R.stop()}},_,this,[[0,10]])})),function(){return i.apply(this,arguments)})},{key:"doExchangeSDP",value:function(){var _=this;return new Promise(function(b,R){_.exchangeSDPTimeout_=setTimeout(function(){_.signalChannel_.off(st.PUBLISH_RESULT,P),_.clearExchangeSDPTimeout();var k=new te({code:Z.API_CALL_TIMEOUT,message:ae({key:EN})});R(k)},1e4);var P=function(){var k=H(p().mark(function h(y){var A,D,j;return p().wrap(function(K){for(;;)switch(K.prev=K.next){case 0:if(K.prev=0,_.clearExchangeSDPTimeout(),A=y.data,D=A.code,j=A.message,D!==0){K.next=9;break}return K.next=6,_.acceptAnswer(y.data.data);case 6:b(),K.next=10;break;case 9:_.checkPublishResultCode(D,j);case 10:K.next=15;break;case 12:K.prev=12,K.t0=K.catch(0),R(K.t0);case 15:case"end":return K.stop()}},h,null,[[0,12]])}));return function(h){return k.apply(this,arguments)}}(),U={type:_.peerConnection_.localDescription.type,sdp:_.removeVideoOrientation(_.peerConnection_.localDescription.sdp),screen:(_.publishingStream_||_.localStream_).hasScreenTrack(),state:_.publishState,constraintConfig:_.mediaSettings_};_.signalChannel_.once(st.PUBLISH_RESULT,P),_.log_.debug("sending sdp offer: "+U.sdp),_.signalChannel_.send(RU,U)})}},{key:"setSDPDirection",value:function(_,b){var R=arguments.length>2&&arguments[2]!==void 0?arguments[2]:"all",P=Fr(_);return P.media.forEach(function(U){R!=="all"&&U.type!==R||(U.direction=b)}),yo(P)}},{key:"acceptAnswer",value:(n=H(p().mark(function _(b){var R,P,U,k,h,y,A;return p().wrap(function(D){for(;;)switch(D.prev=D.next){case 0:if(D.prev=0,R=this.removeVideoOrientation(b.sdp),!(P=this.publishingStream_||this.localStream_)){D.next=15;break}if(U=P.getVideoBitrate(),k=P.getAudioBitrate(),!U){D.next=11;break}return h=this.isPublishingAuxStream_?gt:Bu,D.next=10,this.setBandwidth({sdp:R,videoType:h,type:xe,bandwidth:U,scaleResolutionDownBy:P.scaleResolutionDownBy});case 10:R=D.sent;case 11:if(!k){D.next=15;break}return D.next=14,this.setBandwidth({bandwidth:k,type:Ee,sdp:R});case 14:R=D.sent;case 15:if(!this.client_.getIsEnableSmallStream()){D.next=20;break}return y=this.client_.smallStreamConfig,D.next=19,this.setBandwidth({bandwidth:y.bitrate,type:xe,videoType:Mr,sdp:R});case 19:R=D.sent;case 20:return A={type:b.type,sdp:R},D.next=23,this.peerConnection_.setRemoteDescription(A);case 23:this.log_.debug("accepted answer: "+R),ke.logSuccessEvent({userId:this.client_.getUserId(),eventType:Ob,kind:"answer"}),D.next=32;break;case 27:throw D.prev=27,D.t0=D.catch(0),ke.logFailedEvent({userId:this.client_.getUserId(),eventType:Ob,kind:"answer",error:D.t0}),this.log_.error("failed to accept remote answer "+D.t0),D.t0;case 32:case"end":return D.stop()}},_,this,[[0,27]])})),function(_){return n.apply(this,arguments)})},{key:"sendMutedFlag",value:function(_,b){if(b!==this.localAuxStream_){var R={audio:_.audio,bigVideo:_.video,auxVideo:_.auxVideo};this.log_.info("send muted state: ".concat(JSON.stringify(R))),this.signalChannel_.send(EU,R)}}},{key:"getIsReconnecting",value:function(){return this.isReconnecting_}},{key:"reconnect",value:(t=H(p().mark(function _(){var b,R,P=this;return p().wrap(function(U){for(;;)switch(U.prev=U.next){case 0:if(this.reconnectionTimer_===-1){U.next=3;break}return this.log_.warn("reconnect() uplink is reconnecting, ignore current reconnection"),U.abrupt("return");case 3:if(!(this.reconnectionCount_>=30)){U.next=12;break}return this.log_.warn("SDK has tried reconnect uplink for ".concat(30," times, but all failed, please check your network")),this.stopReconnection(),b=new te({code:Z.UPLINK_RECONNECTION_FAILED,message:ae({key:PN})}),ke.logFailedEvent({userId:this.client_.getUserId(),eventType:Ab,error:b}),this.addEventInternal(mV,"uplink-connection reconnect fail"),this.emitConnectionStateChangedEvent(on),this.emitter_.emit(et.ERROR,b),U.abrupt("return");case 12:if(this.signalChannel_.getCurrentState()===oc){U.next=16;break}return this.log_.warn("reconnect() signal channel is not connected, suspend reconnection until signal is connected"),this.signalChannel_.once(ac,this.reconnect,this),U.abrupt("return");case 16:if(this.reconnectionCount_++,U.prev=17,this.log_.warn("reconnect() try to reconnect uplink [".concat(this.reconnectionCount_,"/").concat(30,"]")),R=xp(this.reconnectionCount_),this.reconnectionTimer_=setTimeout(function(){P.log_.warn("reconnect() uplink reconnect timeout(".concat(R/1e3,"s), try again")),P.clearReconnectionTimer(),P.reconnect()},R),!(this.isSDPExchanging_||this.peerConnection_&&this.peerConnection_.connectionState===Ju)){U.next=23;break}return U.abrupt("return");case 23:return U.next=25,this.signalChannel_.sendWaitForResponse({command:gk,responseCommand:st.UNPUBLISH_RESULT,enableLog:!1});case 25:if(this.reset(),this.initialize(),!this.localStream_){U.next=30;break}return U.next=30,this.publish(this.localStream_);case 30:if(!this.localAuxStream_){U.next=33;break}return U.next=33,this.publish(this.localAuxStream_,!0);case 33:ke.logSuccessEvent({userId:this.client_.getUserId(),eventType:Ab}),this.log_.warn("reconnect() uplink reconnect successfully"),this.addEventInternal(pV,"uplink-connection reconnect success"),this.stopReconnection(),this.localStream_.syncMuteState(),U.next=42;break;case 40:U.prev=40,U.t0=U.catch(17);case 42:case"end":return U.stop()}},_,this,[[17,40]])})),function(){return t.apply(this,arguments)})},{key:"clearExchangeSDPTimeout",value:function(){this.exchangeSDPTimeout_!==-1&&(clearTimeout(this.exchangeSDPTimeout_),this.exchangeSDPTimeout_=-1)}},{key:"clearReconnectionTimer",value:function(){this.reconnectionTimer_!==-1&&(clearTimeout(this.reconnectionTimer_),this.reconnectionTimer_=-1)}},{key:"handleError",value:function(_){_.getCode()===Z.ICE_TRANSPORT_ERROR&&(this.isFirstConnection_&&(this.isFirstConnection_=!1,ke.logFailedEvent({userId:this.client_.getUserId(),eventType:Rb,error:_})),this.isReconnecting_||this.startReconnection())}},{key:"handleConnectionStateChange",value:function(_){_.state===sn&&this.isFirstConnection_&&(this.isFirstConnection_=!1,ke.logSuccessEvent({userId:this.client_.getUserId(),eventType:Rb}),this.addEventInternal(cV,"uplink-connection is connected"))}},{key:"updateSSRC",value:function(_){var b=this;try{Fr(_).media.forEach(function(R,P){if(R.type===Ee){var U=R.ssrcs[0];U&&(b.ssrc_.audio=U.id)}else{if(b.sdpSemantics_===Wf)return void R.ssrcGroups.forEach(function(h,y){var A=Number(h.ssrcs.split(" ")[0]);y===0?b.ssrc_.video=A:y===1&&(b.ssrc_.small=A)});var k=R.ssrcs[0];if(!k)return;switch(P){case 1:b.ssrc_.video=k.id;break;case 2:b.ssrc_.small=k.id;break;case 3:b.ssrc_.auxiliary=k.id}}})}catch(R){}}},{key:"getVideoTrackId",value:function(){var _=arguments.length>0&&arguments[0]!==void 0?arguments[0]:xe;if(this.peerConnection_){var b=this.peerConnection_.getSenders();if(_===xe&&b[1]&&b[1].track)return b[1].track.id;if(_===Mr&&b[2]&&b[2].track)return b[2].track.id;if(_===gt&&b[3]&&b[3].track)return b[3].track.id}if(this.localStream_&&_===xe){var R=this.localStream_.getVideoTrack();if(R)return R.id}if(this.localAuxStream_&&_===gt){var P=this.localAuxStream_.getVideoTrack();if(P)return P.id}return""}},{key:"getSSRC",value:function(){return this.ssrc_}},{key:"checkPublishResultCode",value:function(_,b){if(_!==0)throw _===1028?(this.log_.error(vi.NOT_SUPPORTED_H264ENCODE),new te({code:Z.NOT_SUPPORTED_H264,message:ae({key:gS})})):new te({code:Z.UNKNOWN,message:ae({key:yS,data:{signalResponse:st.PUBLISH_RESULT,code:_,message:b}})})}},{key:"getLocalStream",value:function(){return this.localStream_}},{key:"sendSEI",value:function(_,b){this.sei_.push(_,b)}},{key:"mixAudioTrack",value:function(_,b){this.log_.info("mix audio track"),this.mixedAudioTrack_=function(R){var P=FS(),U=P.createMediaStreamDestination(),k=[];R.forEach(function(y){var A=new MediaStream;A.addTrack(y);var D=P.createMediaStreamSource(A);D.connect(U),k.push(D)});var h=U.stream.getAudioTracks()[0];return $l.set(h,{destination:U,track:h,mediaStreamSourceList:k}),h}([_,b])}},{key:"destroyMixedAudioTrack",value:function(){this.mixedAudioTrack_&&(this.log_.info("destroy audio track"),function(_){if($l.has(_)){var b=$l.get(_),R=b.destination,P=b.track,U=b.mediaStreamSourceList;P.stop(),R.disconnect(),U.forEach(function(k){k.disconnect()}),$l.delete(_)}}(this.mixedAudioTrack_),this.mixedAudioTrack_=null)}}]),V}(Bv),X(Tc.prototype,"publish",[Gx],Object.getOwnPropertyDescriptor(Tc.prototype,"publish"),Tc.prototype),Tc),LF=pe,Jx=As,Zl=ws.exports.getWeakData,MF=oi,NF=Tt,UF=Rt,Kv=at,VF=Rs,qx=kt,jF=Xe.set,BF=Xe.getterFor,FF=rn.find,HF=rn.findIndex,GF=LF([].splice),zF=0,ed=function(e){return e.frozen||(e.frozen=new Kx)},Kx=function(){this.entries=[]},Xv=function(e,t){return FF(e.entries,function(n){return n[0]===t})};Kx.prototype={get:function(e){var t=Xv(this,e);if(t)return t[1]},has:function(e){return!!Xv(this,e)},set:function(e,t){var n=Xv(this,e);n?n[1]=t:this.entries.push([e,t])},delete:function(e){var t=HF(this.entries,function(n){return n[0]===e});return~t&&GF(this.entries,t,1),!!~t}};var xc,WF={getConstructor:function(e,t,n,i){var r=e(function(s,l){MF(s,o),jF(s,{type:t,id:zF++,frozen:void 0}),UF(l)||VF(l,s[i],{that:s,AS_ENTRIES:n})}),o=r.prototype,c=BF(t),a=function(s,l,u){var f=c(s),S=Zl(NF(l),!0);return S===!0?ed(f).set(l,u):S[f.id]=u,s};return Jx(o,{delete:function(s){var l=c(this);if(!Kv(s))return!1;var u=Zl(s);return u===!0?ed(l).delete(s):u&&qx(u,l.id)&&delete u[l.id]},has:function(s){var l=c(this);if(!Kv(s))return!1;var u=Zl(s);return u===!0?ed(l).has(s):u&&qx(u,l.id)}}),Jx(o,n?{get:function(s){var l=c(this);if(Kv(s)){var u=Zl(s);return u===!0?ed(l).get(s):u?u[l.id]:void 0}},set:function(s,l){return a(this,s,l)}}:{add:function(s){return a(this,s,!0)}}),r}},Xx=re,td=pe,JF=As,qF=ws.exports,KF=fh,Qx=WF,nd=at,rd=Qg,id=Xe.enforce,XF=O,QF=!Xx.ActiveXObject&&"ActiveXObject"in Xx,Yx=function(e){return function(){return e(this,arguments.length?arguments[0]:void 0)}},YF=KF("WeakMap",Yx,Qx);if(XF&&QF){xc=Qx.getConstructor(Yx,"WeakMap",!0),qF.enable();var Ic=YF.prototype,$x=td(Ic.delete),ad=td(Ic.has),Zx=td(Ic.get),eI=td(Ic.set);JF(Ic,{delete:function(e){if(nd(e)&&!rd(e)){var t=id(this);return t.frozen||(t.frozen=new xc),$x(this,e)||t.frozen.delete(e)}return $x(this,e)},has:function(e){if(nd(e)&&!rd(e)){var t=id(this);return t.frozen||(t.frozen=new xc),ad(this,e)||t.frozen.has(e)}return ad(this,e)},get:function(e){if(nd(e)&&!rd(e)){var t=id(this);return t.frozen||(t.frozen=new xc),ad(this,e)?Zx(this,e):t.frozen.get(e)}return Zx(this,e)},set:function(e,t){if(nd(e)&&!rd(e)){var n=id(this);n.frozen||(n.frozen=new xc),ad(this,e)?eI(this,e,t):n.frozen.set(e,t)}else eI(this,e,t);return this}})}var $F=Le,od=Ws,ZF=ue,tI=An,nI=it,e7=Ou,rI=lb,t7=Qt,Qv=od&&od.prototype;if($F({target:"Promise",proto:!0,real:!0,forced:!!od&&ZF(function(){Qv.finally.call({then:function(){}},function(){})})},{finally:function(e){var t=e7(this,tI("Promise")),n=nI(e);return this.then(n?function(i){return rI(t,e()).then(function(){return i})}:e,n?function(i){return rI(t,e()).then(function(){throw i})}:e)}}),nI(od)){var iI=tI("Promise").prototype.finally;Qv.finally!==iI&&t7(Qv,"finally",iI,{unsafe:!0})}var aI,oI,sI,cI,ur,Mo=new WeakMap;function uI(){return function(e,t,n){var i=n.value,r=function o(c){var a=c.fn,s=c.args,l=c.context,u=c.resolve,f=c.reject;a.apply(l,s).then(u,f).finally(function(){var S=Mo.get(l);S&&(S.shift(),S[0]&&o(q({},S[0])))})};return n.value=function(){for(var o=this,c=arguments.length,a=new Array(c),s=0;s<c;s++)a[s]=arguments[s];return new Promise(function(l,u){if(Mo.has(o)){var f=Mo.get(o),S=f.length;f.push({fn:i,args:a,context:o,resolve:l,reject:u,name:t}),S===0&&r({fn:i,args:a,context:o,resolve:l,reject:u})}else Mo.set(o,[{fn:i,args:a,context:o,resolve:l,reject:u,name:t}]),r({fn:i,args:a,context:o,resolve:l,reject:u})})},n}}var n7=(aI=uI(),oI=Lo({retries:1,timeout:0,onRetrying:function(e){this.log_.warn("connection timeout, retrying [".concat(e,"]"))},onError:function(e,t,n){e.message.includes("timeout")?t():n(e)}}),sI=uI(),cI=function(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:1e4;return function(t,n,i){var r=i.value;return i.value=function(){for(var o=this,c=arguments.length,a=new Array(c),s=0;s<c;s++)a[s]=arguments[s];return new Promise(function(l,u){var f=setTimeout(function(){return u(new Error("".concat(n," timeout")))},e);r.apply(o,a).then(l,u).finally(function(){clearTimeout(f)})})},i}}(),ur=function(e){Et(l,e);var t,n,i,r,o,c,a,s=Rr(l);function l(u){var f;return Q(this,l),(f=s.call(this,u)).remoteStreams_=new Map,f.autoSubscribe=u.autoSubscribe,f.trackState_={audio:u.trackState.audio,video:u.trackState.video,auxiliary:u.trackState.auxiliary,smallVideo:u.trackState.smallVideo},f.ssrc_={audio:0,video:0,auxiliary:0},f.subscribeState_={audio:u.autoSubscribe,video:u.autoSubscribe,auxiliary:u.autoSubscribe,smallVideo:!1},f.isSDPExchanging_=!1,f.installEvents(),f}return Ie(l,[{key:"getMixUserList",value:function(){return this.mixUserList_?this.mixUserList_.map(function(u){var f=u.userId,S=u.flag;return{userId:f,hasAudio:!!(8&S),hasVideo:!!(1&S),hasAuxiliary:!!(4&S)}}):void 0}},{key:"setMixUserList",value:function(u){(!this.mixUserList_||ho(this.mixUserList_)&&!function(f,S){if(S.length===f.length){var x,E=oe(S);try{var I=function(){var T=x.value,v=f.find(function(w){return w.userId===T.userId});if(!v||v.flag!==T.flag)return{v:!1}};for(E.s();!(x=E.n()).done;){var m=I();if(G(m)==="object")return m.v}}catch(T){E.e(T)}finally{E.f()}return!0}return!1}(this.mixUserList_,u))&&(this.mixUserList_=u,this.emitter_.emit(et.STREAM_UPDATED,{stream:this.getMainStream()}))}},{key:"isMainStreamSubscribed",get:function(){return(this.subscribeState_.audio||this.subscribeState_.video||this.subscribeState_.smallVideo)&&(this.trackState_.audio||this.trackState_.video||this.trackState_.smallVideo)}},{key:"isAuxStreamSubscribed",get:function(){return this.subscribeState_.auxiliary&&this.trackState_.auxiliary}},{key:"isSmallStreamSubscribed",get:function(){return this.subscribeState_.smallVideo&&this.trackState_.smallVideo}},{key:"isBigStreamSubscribed",get:function(){return this.subscribeState_.video&&this.trackState_.video}},{key:"isStreamUnpublished",value:function(u){return u.getType()===Qe?!this.trackState_.audio&&!this.trackState_.video:!this.trackState_.auxiliary}},{key:"initialize",value:function(){le(Ye(l.prototype),"initialize",this).call(this),this.peerConnection_.ontrack=this.onTrack.bind(this)}},{key:"close",value:function(){var u,f,S,x=this;le(Ye(l.prototype),"close",this).call(this),this.trackState_.audio=!1,this.trackState_.video=!1,this.trackState_.smallVideo=!1,this.trackState_.auxiliary=!1,this.emitConnectionStateChangedEvent(on),u=this,f=function(E){E.fn;var I=E.args,m=E.resolve,T=E.reject,v=E.name;if(v==="subscribe"){if(!x.client_.getIsJoined())return T(new te({code:Z.API_CALL_ABORTED,message:ae({key:ip,data:{message:"leave room",stream:I[0]}})}));if(x.isStreamUnpublished(I[0]))return T(new te({code:Z.API_CALL_ABORTED,message:ae({key:ip,data:{message:"remote user ".concat(x.userId_," unpublished stream"),stream:I[0]}})}))}else if(v==="unsubscribe")return m();m()},(S=Mo.get(u))===null||S===void 0||S.forEach(f),Mo.delete(u),this.remoteStreams_.forEach(function(E){var I=E;I.setConnection(null),I.uninstallEvents(),I.getIsStreamAddedEventEmitted()&&x.emitter_.emit(et.STREAM_REMOVED,{stream:I})}),this.remoteStreams_.clear(),this.uninstallEvents()}},{key:"installEvents",value:function(){var u=this;Y.on(jn,this.onRemoteStreamUpdate,this),this.emitter_.on(et.ERROR,function(f){f.getCode()===Z.ICE_TRANSPORT_ERROR&&(u.isFirstConnection_&&(u.isFirstConnection_=!1,ke.logFailedEvent({userId:u.client_.getUserId(),eventType:Pb,error:f})),u.isReconnecting_||u.startReconnection())}),this.emitter_.on(et.CONNECTION_STATE_CHANGED,function(f){f.state===sn&&u.isFirstConnection_&&(u.isFirstConnection_=!1,ke.logSuccessEvent({userId:u.client_.getUserId(),eventType:Pb}),u.addEventInternal(uV,"downlink-connection is connected"))})}},{key:"uninstallEvents",value:function(){Y.removeListener(jn,this.onRemoteStreamUpdate,this)}},{key:"onRemoteStreamUpdate",value:function(u){if(this.hitTest(u.tinyId)&&u.client===this.client_){this.updateTrackState(u.action,u.kind);var f=u.kind===gt?Xs:xr,S=this.remoteStreams_.get(f);if(!S)return;u.action===cn.ADD?this.handleRemoteAddTrack(u.kind,S):this.handleRemoteRemoveTrack(u.kind,S)}}},{key:"handleRemoteAddTrack",value:function(u,f){this.log_.info("remote add ".concat(u," track")),u===Ee?f.updateAudioPlayingState(this.subscribeState_.audio):f.updateVideoPlayingState(u===gt?this.subscribeState_.auxiliary:this.subscribeState_.video||this.subscribeState_.smallVideo),f.getIsStreamAddedEventEmitted()?this.emitter_.emit(et.STREAM_UPDATED,{stream:f}):(this.emitter_.emit(et.STREAM_ADDED,{stream:f}),this.currentState_===sn&&f.emitConnectionStateChanged({prevState:on,state:sn}))}},{key:"handleRemoteRemoveTrack",value:function(u,f){f.getIsStreamAddedEventEmitted()&&(this.log_.info("remote remove ".concat(u," track")),u===gt||!this.trackState_.audio&&!this.trackState_.video?(this.log_.info("remote stream ".concat(f.getType()," removed")),this.currentState_===sn&&f.emitConnectionStateChanged({prevState:sn,state:on}),this.emitter_.emit(et.STREAM_REMOVED,{stream:f})):(u===Ee?f.updateAudioPlayingState(!1):(u!==Fu||this.isSmallStreamSubscribed)&&f.updateVideoPlayingState(!1),this.emitter_.emit(et.STREAM_UPDATED,{stream:f})))}},{key:"updateTrackState",value:function(u,f){var S=u===cn.ADD;switch(f){case Ee:this.trackState_.audio=S;break;case xe:this.trackState_.video=S;break;case gt:this.trackState_.auxiliary=S;break;case Fu:this.trackState_.smallVideo=S}this.log_.info("trackState updated: ".concat(JSON.stringify(this.trackState_)))}},{key:"onTrack",value:function(u){var f=u.streams[0],S=u.track;if(this.log_.info("ontrack() kind: ".concat(S.kind," id: ").concat(S.id," streamId: ").concat(f.id)),this.sdpSemantics_===Ys){var x=function(v){var w=rr.parse(v),L={audio:[],video:[]};return w.media.forEach(function(N){if(N.ssrcs){var V=N.ssrcs[0].id>>16&255;if(N.type===Ee)L.audio.push(xr);else if(N.type==xe){var _=V===QM?xr:Xs;L.video.push(_)}}}),L}(this.peerConnection_.remoteDescription.sdp);if(S.kind===Ee){if(x.audio.length===0||f.id!==xr)return void this.log_.debug("skip this invalid audio track")}else if(x.video.indexOf(f.id)===-1)return void this.log_.debug("skip this invalid video track: ".concat(S.id," msid: ").concat(f.id))}ke.logEvent({eventType:"ontrack",kind:S.kind});var E=!1,I=this.remoteStreams_.get(f.id),m=f.id===xr?yt:Dt;if(ge(I)&&((I=new Gv({type:m,userId:this.userId_,client:this.client_})).setConnection(this),this.remoteStreams_.set(f.id,I),E=!0),I.setMediaStream(f),S.kind===Ee?I.updateAudioPlayingState(this.subscribeState_.audio):m===yt?I.updateVideoPlayingState(this.subscribeState_.video||this.subscribeState_.smallVideo):I.updateVideoPlayingState(this.subscribeState_.auxiliary),(m!==Dt||this.trackState_.auxiliary)&&(m!==yt||this.trackState_.audio||this.trackState_.video)){var T=this.client_.getSubscriptionManager();T&&T.hasAutoRecoveryFlag(this.userId_,m)||(E?this.emitter_.emit(et.STREAM_ADDED,{stream:I}):this.emitter_.emit(et.STREAM_UPDATED,{stream:I}))}}},{key:"addRRTRLine",value:function(u){var f=u.split(`\r
|
|
69
|
+
`),S=new Map;f.forEach(function(v,w){/^a=rtcp-fb:/.test(v)&&f[w+1]&&!/^a=rtcp-fb:/.test(f[w+1])&&v.match(/^a=rtcp-fb:\d+/)&&S.set(w+1,v.match(/^a=rtcp-fb:\d+/)[0]+" rrtr")});for(var x=Se(S),E=0;E<x.length;E++){var I=Te(x[E],2),m=I[0],T=I[1];f.splice(m+E,0,T)}return f.join(`\r
|
|
70
|
+
`)}},{key:"addSPSDescription",value:function(u){var f=Fr(u);return f.media.forEach(function(S){S.type===xe&&S.fmtp.forEach(function(x){x.config+=";sps-pps-idr-in-keyframe=1"})}),yo(f)}},{key:"removeSDESDescription",value:function(u){var f=["urn:ietf:params:rtp-hdrext:sdes:mid","urn:ietf:params:rtp-hdrext:sdes:rtp-stream-id","urn:ietf:params:rtp-hdrext:sdes:repaired-rtp-stream-id"],S=Fr(u);return S.media.forEach(function(x){x.ext=x.ext.filter(function(E){return!f.includes(E.uri)})}),yo(S)}},{key:"isSubscriptionStateNotChanged",value:function(u,f){return u.getType()===yt?(f==null?void 0:f.audio)===this.subscribeState_.audio&&(f==null?void 0:f.video)===this.subscribeState_.video&&this.isSubscribeSmall(f):u.getType()===Dt?!ge(f.video)&&this.subscribeState_.auxiliary===f.video:void 0}},{key:"isSubscribeSmall",value:function(u){return ge(u.smallVideo)&&!this.subscribeState_.smallVideo}},{key:"subscribe",value:(a=H(p().mark(function u(f,S){var x,E,I,m,T,v;return p().wrap(function(w){for(;;)switch(w.prev=w.next){case 0:if(w.prev=0,I=S.emitEvent,m=I===void 0||I,T=f.getType(),((x=this.peerConnection_)===null||x===void 0?void 0:x.connectionState)!==YM&&((E=this.peerConnection_)===null||E===void 0?void 0:E.connectionState)!==Ju){w.next=6;break}return w.next=6,this.waitForPeerConnectionConnected();case 6:if(!this.isSubscriptionStateNotChanged(f,S)){w.next=13;break}if(this.peerConnection_){w.next=11;break}return this.initialize(),w.next=11,this.connect();case 11:return m&&ge(S.smallVideo)&&this.emitter_.emit(et.STREAM_SUBSCRIBED,{stream:f,result:!0}),w.abrupt("return",f);case 13:if(T===Qe?(ge(S.audio)||(this.subscribeState_.audio=S.audio),ge(S.video)||(this.subscribeState_.video=S.video),this.subscribeState_.smallVideo=(S==null?void 0:S.smallVideo)||!1,this.addEventInternal(this.subscribeState_.audio?kk:om,this.subscribeState_.audio?"subscribe audio":"unsubscribe audio"),this.addEventInternal(this.subscribeState_.video?kk:om,this.subscribeState_.video?"subscribe video":"unsubscribe video"),this.addEventInternal(this.subscribeState_.smallVideo?yV:bV,this.subscribeState_.smallVideo?"subscribe smallVideo":"unsubscribe smallVideo")):ge(S.video)||(this.subscribeState_.auxiliary=S.video),this.log_.info("subscribe ".concat(T," stream with options ").concat(JSON.stringify(S)," current state: ").concat(JSON.stringify(this.subscribeState_))),!this.peerConnection_&&!this.isSDPExchanging_){w.next=23;break}return v=zf,this.isMainStreamSubscribed||this.isAuxStreamSubscribed||(v=Gf),w.next=20,this.sendSubscription(v);case 20:T===Qe?(f.updateAudioPlayingState(this.subscribeState_.audio),f.updateVideoPlayingState(this.subscribeState_.video||this.subscribeState_.smallVideo)):f.updateVideoPlayingState(this.subscribeState_.auxiliary),w.next=26;break;case 23:return this.initialize(),w.next=26,this.connect();case 26:return m&&this.emitter_.emit(et.STREAM_SUBSCRIBED,{stream:f,result:!0}),w.abrupt("return",f);case 30:if(w.prev=30,w.t0=w.catch(0),!this.client_.getIsJoined()||!this.isStreamUnpublished(f)){w.next=35;break}throw this.log_.warn("".concat(w.t0.message," ").concat(JSON.stringify(this.trackState_))),new te({code:Z.REMOTE_STREAM_NOT_EXIST,message:"remote user ".concat(this.userId_," unpublished stream")});case 35:throw w.t0;case 36:case"end":return w.stop()}},u,this,[[0,30]])})),function(u,f){return a.apply(this,arguments)})},{key:"checkTrackEnded",value:function(){try{var u=this.peerConnection_.getReceivers().map(function(f){return f.track}).find(function(f){return f.readyState==="ended"});u&&this.currentState_===sn&&!this.isReconnecting_&&(this.log_.warn("".concat(u.kind," track ended, start reconnect")),this.startReconnection())}catch(f){}}},{key:"unsubscribe",value:(c=H(p().mark(function u(f){var S,x,E;return p().wrap(function(I){for(;;)switch(I.prev=I.next){case 0:if((S=f.getType())!==Qe){I.next=10;break}if(this.isMainStreamSubscribed){I.next=5;break}return this.log_.info("main stream already unsubscribed"),I.abrupt("return",f);case 5:this.subscribeState_.audio=!1,this.subscribeState_.video=!1,this.subscribeState_.smallVideo=!1,I.next=14;break;case 10:if(this.isAuxStreamSubscribed){I.next=13;break}return this.log_.info("auxiliary stream already unsubscribed"),I.abrupt("return",f);case 13:this.subscribeState_.auxiliary=!1;case 14:return x=Gf,(S===yt&&this.isAuxStreamSubscribed||S===Dt&&this.isMainStreamSubscribed)&&(x=zf),this.log_.info("unsubscribe ".concat(S," stream with ").concat(JSON.stringify(this.subscribeState_))),I.next=19,this.sendSubscription(x);case 19:return f.updateVideoPlayingState(!1),f.updateAudioPlayingState(!1),x===Gf&&((E=f.getMediaStream())&&E.getTracks().forEach(function(m){return E.removeTrack(m)}),this.closePeerConnection(),this.emitConnectionStateChangedEvent(on)),this.addEventInternal(om,"unsubscribe audio"),this.addEventInternal(XU,"unsubscribe video"),I.abrupt("return",f);case 25:case"end":return I.stop()}},u,this)})),function(u){return c.apply(this,arguments)})},{key:"sendSubscription",value:function(u){var f=this,S={srcTinyId:this.tinyId_,srcUserId:this.userId_},x=PU,E=st.UNSUBSCRIBE_RESULT;return u===zf&&(S={audio:this.subscribeState_.audio,bigVideo:this.subscribeState_.video,auxVideo:this.subscribeState_.auxiliary,smallVideo:this.subscribeState_.smallVideo,srcTinyId:this.tinyId_},x=DU,E=st.SUBSCRIBE_CHANGE_RESULT),this.signalChannel_.sendWaitForResponse({command:x,data:S,responseCommand:E,timeout:1e4}).then(function(I){var m=I.data;if(m.code!==0){var T=new te({code:m.code,message:ae({key:CN,data:{type:u,message:m.message}})});throw f.log_.error(T),T}})}},{key:"connect",value:(o=H(p().mark(function u(){return p().wrap(function(f){for(;;)switch(f.prev=f.next){case 0:return f.prev=0,f.next=3,this.exchangeSDP();case 3:return f.next=5,this.waitForPeerConnectionConnected();case 5:f.next=11;break;case 7:throw f.prev=7,f.t0=f.catch(0),this.closePeerConnection(!0),f.t0;case 11:case"end":return f.stop()}},u,this,[[0,7]])})),function(){return o.apply(this,arguments)})},{key:"exchangeSDP",value:(r=H(p().mark(function u(){var f,S,x,E,I,m;return p().wrap(function(T){for(;;)switch(T.prev=T.next){case 0:return T.prev=0,this.isSDPExchanging_=!0,T.next=4,this.createOffer();case 4:return this.log_.info("createOffer success, sending offer to remote server"),f=this.peerConnection_.localDescription,S=f.type,x=f.sdp,E={type:S,sdp:x,srcUserId:this.userId_,srcTinyId:this.tinyId_,audio:this.subscribeState_.audio,bigVideo:this.subscribeState_.video,auxVideo:this.subscribeState_.auxiliary,smallVideo:this.subscribeState_.smallVideo},Y.emit(Qp,{client:this.client_,connection:this,userId:this.userId_,tinyId:this.tinyId_,role:so,subscribeState:this.subscribeState_,trackState:this.trackState_}),T.next=10,this.signalChannel_.sendWaitForResponse({command:AU,commandDesc:"exchange sdp",data:E,responseCommand:st.SUBSCRIBE_RESULT,timeout:1e4});case 10:if(I=T.sent,this.peerConnection_){T.next=15;break}throw m=new te({code:Z.INVALID_OPERATION,message:ae({key:X3})}),this.log_.warn(m),m;case 15:return T.next=17,this.onSubscribeResult(I);case 17:this.isSDPExchanging_=!1,T.next=24;break;case 20:throw T.prev=20,T.t0=T.catch(0),this.isSDPExchanging_=!1,T.t0;case 24:case"end":return T.stop()}},u,this,[[0,20]])})),function(){return r.apply(this,arguments)})},{key:"createOffer",value:(i=H(p().mark(function u(){var f,S;return p().wrap(function(x){for(;;)switch(x.prev=x.next){case 0:return f={voiceActivityDetection:!1},vl()&&this.sdpSemantics_===Ys?(this.peerConnection_.addTransceiver(Ee,{direction:"recvonly"}),this.peerConnection_.addTransceiver(xe,{direction:"recvonly"}),this.peerConnection_.addTransceiver(xe,{direction:"recvonly"})):(f.offerToReceiveAudio=!0,f.offerToReceiveVideo=!0),x.next=4,this.peerConnection_.createOffer(f);case 4:return S=x.sent,x.next=7,Vk();case 7:return x.sent.isH264DecodeSupported||(this.log_.warn("remove h264 desc from sdp"),S.sdp=(E=S.sdp,I=void 0,(I=Fr(E)).media.forEach(function(m){if(m.type===xe){var T=new Set;m.rtp.forEach(function(w){var L=w.payload;return w.codec==="H264"&&T.add(L)}),m.fmtp.forEach(function(w){var L=w.payload,N=w.config.match(/apt=(\d+)/);N&&N[1]&&T.has(Number(N[1]))&&T.add(L)});var v=function(w){var L=w.payload;return!T.has(L)};m.rtp=m.rtp.filter(v),m.rtcpFb=m.rtcpFb.filter(v),m.fmtp=m.fmtp.filter(v),m.payloads=m.payloads.split(" ").filter(function(w){return!T.has(Number(w))}).join(" ")}}),yo(I))),S.sdp=this.addRRTRLine(S.sdp),S.sdp=this.addSPSDescription(S.sdp),S.sdp=WV(S.sdp),this.sdpSemantics_===Ys&&(S.sdp=this.removeSDESDescription(S.sdp)),x.next=16,this.peerConnection_.setLocalDescription(S);case 16:case"end":return x.stop()}var E,I},u,this)})),function(){return i.apply(this,arguments)})},{key:"onSubscribeResult",value:(n=H(p().mark(function u(f){var S,x,E,I,m,T,v,w=this;return p().wrap(function(L){for(;;)switch(L.prev=L.next){case 0:if(S=f&&f.data||{},x=S.code,E=S.message,I=E===void 0?"":E,m=f&&f.data&&f.data.data||{},T=m.type,v=m.sdp,x!==77393){L.next=5;break}throw this.log_.error(vi.NOT_SUPPORTED_H264DECODE),new te({code:Z.NOT_SUPPORTED_H264,message:ae({key:_S})});case 5:if(L.prev=5,x===0){L.next=8;break}throw new te({code:x,message:ae({key:AN,data:{errMsg:I}})});case 8:return this.log_.debug("accept remote answer: "+v),L.next=11,this.peerConnection_.setRemoteDescription({type:T,sdp:v});case 11:this.sei_&&(this.sei_.handleEncodedStreams(),this.sei_.onSEIMessage=function(N){w.emitter_.emit(et.SEI_MESSAGE,q(q({},N),{},{userId:w.userId_}))}),this.updateSSRC(v),L.next=19;break;case 15:throw L.prev=15,L.t0=L.catch(5),this.log_.error(L.t0),L.t0;case 19:case"end":return L.stop()}},u,this,[[5,15]])})),function(u){return n.apply(this,arguments)})},{key:"updateSSRC",value:function(u){var f=this;try{Fr(u).media.forEach(function(S){if(S.type===Ee){var x=S.ssrcs.find(function(m){return m.value.includes(xr)});x&&(f.ssrc_.audio=x.id)}else{var E=S.ssrcs.find(function(m){return m.value.includes(xr)}),I=S.ssrcs.find(function(m){return m.value.includes(Xs)});E&&(f.ssrc_.video=E.id),I&&(f.ssrc_.auxiliary=I.id)}})}catch(S){}}},{key:"setRemoteStream",value:function(u,f){this.remoteStreams_.set(u,f)}},{key:"getSubscribeState",value:function(){return this.subscribeState_}},{key:"getTrackState",value:function(){return this.trackState_}},{key:"getSSRC",value:function(){return this.ssrc_}},{key:"getMainStream",value:function(){return this.remoteStreams_.get(xr)}},{key:"getAuxStream",value:function(){return this.remoteStreams_.get(Xs)}},{key:"getMainStreamVideoTrackId",value:function(){var u=this.getMainStream();if(u){var f=u.getVideoTrack();if(f)return f.id}return""}},{key:"getAuxStreamVideoTrackId",value:function(){var u=this.getAuxStream();if(u){var f=u.getVideoTrack();if(f)return f.id}return""}},{key:"reconnect",value:(t=H(p().mark(function u(){var f,S,x=this;return p().wrap(function(E){for(;;)switch(E.prev=E.next){case 0:if(this.reconnectionTimer_===-1){E.next=3;break}return this.log_.warn("reconnect() downlink is reconnecting, ignore current reconnection"),E.abrupt("return");case 3:if(!(this.reconnectionCount_>=30)){E.next=12;break}return this.log_.warn("SDK has tried reconnect downlink [".concat(this.userId_,"] for ").concat(30," times, but all failed, please check your network")),this.stopReconnection(),f=new te({code:Z.DOWNLINK_RECONNECTION_FAILED,message:ae({key:RN})}),ke.logFailedEvent({userId:this.client_.getUserId(),eventType:Db,error:f}),this.addEventInternal(_V,"downlink-connection reconnect fail"),this.emitConnectionStateChangedEvent(on),this.emitter_.emit(et.ERROR,f),E.abrupt("return");case 12:if(this.signalChannel_.getCurrentState()===oc){E.next=16;break}return this.log_.warn("reconnect() signal channel is not connected, suspend reconnection until signal is connected"),this.signalChannel_.once(ac,this.reconnect,this),E.abrupt("return");case 16:if(this.reconnectionCount_++,this.log_.warn("reconnect() try to reconnect downlink [".concat(this.reconnectionCount_,"/").concat(30,"]")),S=xp(this.reconnectionCount_),this.reconnectionTimer_=setTimeout(function(){x.log_.warn("reconnect() downlink [".concat(x.userId_,"] reconnect timeout(").concat(S/1e3,"s), try again")),x.clearReconnectionTimer(),x.reconnect()},S),!(this.isSDPExchanging_||this.peerConnection_&&this.peerConnection_.connectionState===Ju)){E.next=22;break}return E.abrupt("return");case 22:return E.prev=22,this.closePeerConnection(),this.initialize(),E.next=27,this.connect();case 27:this.stopReconnection(),this.log_.warn("reconnect() downlink reconnect successfully"),ke.logSuccessEvent({userId:this.client_.getUserId(),eventType:Db}),this.addEventInternal(gV,"downlink-connection reconnect success"),this.recoverSubscription(),E.next=36;break;case 34:E.prev=34,E.t0=E.catch(22);case 36:case"end":return E.stop()}},u,this,[[22,34]])})),function(){return t.apply(this,arguments)})},{key:"recoverSubscription",value:function(){var u=this,f=this.client_.getSubscriptionManager();f&&Se(this.remoteStreams_.values()).forEach(function(S){f.hasAutoRecoveryFlag(u.userId_,S.getType())&&f.recover(S)})}},{key:"getIsReconnecting",value:function(){return this.isReconnecting_}},{key:"getSubscribedMainStream",value:function(){var u=null;return this.isMainStreamSubscribed&&(u=this.remoteStreams_.get(xr)),u}},{key:"clearReconnectionTimer",value:function(){this.reconnectionTimer_!==-1&&(clearTimeout(this.reconnectionTimer_),this.reconnectionTimer_=-1)}},{key:"startReconnection",value:function(){var u=this.client_.getSubscriptionManager();if(u){var f,S=oe(this.remoteStreams_.values());try{for(S.s();!(f=S.n()).done;){var x=f.value,E=x.getType();(E===yt&&(this.trackState_.audio||this.trackState_.video)||E===Dt&&this.trackState_.auxiliary)&&u.setAutoRecoveryFlag(this.userId_,x.getType())}}catch(I){S.e(I)}finally{S.f()}}le(Ye(l.prototype),"startReconnection",this).call(this)}},{key:"getCurrentState",value:function(){return this.currentState_}},{key:"hasMainStream",value:function(){return this.trackState_.video||this.trackState_.audio||this.trackState_.smallVideo}},{key:"hasAuxStream",value:function(){return this.trackState_.auxiliary}}]),l}(Bv),X(ur.prototype,"subscribe",[aI,oI],Object.getOwnPropertyDescriptor(ur.prototype,"subscribe"),ur.prototype),X(ur.prototype,"unsubscribe",[sI],Object.getOwnPropertyDescriptor(ur.prototype,"unsubscribe"),ur.prototype),X(ur.prototype,"exchangeSDP",[cI],Object.getOwnPropertyDescriptor(ur.prototype,"exchangeSDP"),ur.prototype),ur),sd=function(){function e(){Q(this,e),this.startTime=0,this.endTime=0,this.start()}return Ie(e,[{key:"start",value:function(){this.startTime===0&&(this.startTime=Ct())}},{key:"stop",value:function(){this.endTime===0&&(this.endTime=Ct())}},{key:"getDuration",value:function(){return this.endTime===0?Ct()-this.startTime:this.endTime-this.startTime}}]),e}(),r7=function(){function e(r){Q(this,e),this.client_=r.client,this.intervalId_=-1,this.statsCalculator_=r.stats,this.prevStats_=null,this.renderFreezeMap_=new Map,this.remoteStreamMap_=new Map,this.dataFreezeMap_=new Map,this.monitorFreezeData_=new Map}var t,n,i;return Ie(e,[{key:"installEvents",value:function(){Y.on(Jp,this.handlePlayVideoStart,this),Y.on(nc,this.onVideoTrackMuted,this),Y.on(Gp,this.onVideoTrackUnmuted,this),Y.on(ca,this.handleStreamStopped,this),Y.on(Vr,this.handleStreamStopped,this),Y.on(tc,this.handleVideoPlaying,this)}},{key:"uninstallEvents",value:function(){Y.off(Jp,this.handlePlayVideoStart,this),Y.off(nc,this.onVideoTrackMuted,this),Y.off(Gp,this.onVideoTrackUnmuted,this),Y.off(ca,this.handleStreamStopped,this),Y.off(Vr,this.handleStreamStopped,this),Y.off(tc,this.handleVideoPlaying,this)}},{key:"start",value:function(){var r=this;this.intervalId_===-1&&(this.installEvents(),this.intervalId_=mt.run(H(p().mark(function o(){return p().wrap(function(c){for(;;)switch(c.prev=c.next){case 0:return c.prev=0,c.next=3,r.detectFPS();case 3:c.next=7;break;case 5:c.prev=5,c.t0=c.catch(0);case 7:case"end":return c.stop()}},o,null,[[0,5]])})),{delay:1e3}))}},{key:"stop",value:function(){this.intervalId_!==-1&&(this.uninstallEvents(),mt.clearTask(this.intervalId_),this.intervalId_=-1,this.renderFreezeMap_.clear(),this.dataFreezeMap_.clear(),this.remoteStreamMap_.clear())}},{key:"onVideoTrackMuted",value:function(r){var o=r.stream;if(o.getClient()===this.client_&&o.isRemote()){var c=o.userId_,a=o.type_,s="".concat(c,"_").concat(a),l=this.dataFreezeMap_.get(s),u=new sd;l?l.durationItemList.push(u):this.dataFreezeMap_.set(s,{userId:c,type:a,durationItemList:[u],isFreezing:function(){var f=this.durationItemList[this.durationItemList.length-1];return f&&f.endTime===0}})}}},{key:"onVideoTrackUnmuted",value:function(r){var o=r.stream;if(o.getClient()===this.client_&&o.isRemote()){var c=o.userId_,a=o.type_,s="".concat(c,"_").concat(a);this.stopDataFreeze({key:s,userId:c,type:a})}}},{key:"handleStreamStopped",value:function(r){var o=r.client,c=r.stream;if(o===this.client_){var a=c.getUserId(),s=c.getType(),l="".concat(a,"_").concat(s);this.stopDataFreeze({key:l,userId:a,type:s})}}},{key:"stopDataFreeze",value:function(r){var o=r.key,c=r.userId,a=r.type,s=this.dataFreezeMap_.get(o);if(s&&s.isFreezing()){var l=s.durationItemList[s.durationItemList.length-1];l.stop();var u=l.getDuration();u>500?(ke.logEvent({eventType:"videoFrozenCount",delta:u}),this.monitorFreezeData_.set(o,{userId:c,type:a,duration:u})):s.durationItemList.pop()}}},{key:"getTotalDuration",value:function(r){return r.reduce(function(o,c){var a=c.getDuration();return o+Math.min(a,5e3)},0)}},{key:"getStats",value:(i=H(p().mark(function r(){var o,c,a,s,l,u,f,S,x,E,I;return p().wrap(function(m){for(;;)switch(m.prev=m.next){case 0:o=this.client_.getConnections(),c={},a=oe(o),m.prev=3,a.s();case 5:if((s=a.n()).done){m.next=20;break}if(l=Te(s.value,2),u=l[0],(f=l[1]).getPeerConnection()){m.next=9;break}return m.abrupt("continue",18);case 9:return S=f.getSubscribeState(),x=f.getTrackState(),m.next=13,this.statsCalculator_.getReceiverStats(f);case 13:E=m.sent,(I={userId:E.userId,tinyId:u,hasVideo:x.video&&S.video,hasAuxiliary:x.auxiliary&&S.auxiliary,video:{framesDecoded:0},auxiliary:{framesDecoded:0}}).hasVideo&&(I.video.framesDecoded=E.video.framesDecoded),I.hasAuxiliary&&(I.auxiliary.framesDecoded=E.auxiliary.framesDecoded),c[E.userId]=I;case 18:m.next=5;break;case 20:m.next=25;break;case 22:m.prev=22,m.t0=m.catch(3),a.e(m.t0);case 25:return m.prev=25,a.f(),m.finish(25);case 28:return m.abrupt("return",c);case 29:case"end":return m.stop()}},r,this,[[3,22,25,28]])})),function(){return i.apply(this,arguments)})},{key:"detectFPS",value:(n=H(p().mark(function r(){var o,c,a,s,l,u;return p().wrap(function(f){for(;;)switch(f.prev=f.next){case 0:return f.next=2,this.getStats();case 2:if(o=f.sent,this.prevStats_){f.next=6;break}return this.prevStats_=o,f.abrupt("return");case 6:f.t0=p().keys(o);case 7:if((f.t1=f.t0()).done){f.next=17;break}if(c=f.t1.value,this.prevStats_[c]){f.next=11;break}return f.abrupt("continue",7);case 11:a=o[c].tinyId,s=this.client_.getMutedStates(),o[c].hasVideo&&this.prevStats_[c].hasVideo&&s.has(a)&&!s.get(a).videoMuted&&(l=o[c].video.framesDecoded-this.prevStats_[c].video.framesDecoded,this.handleRenderFreeze({userId:c,type:yt,fps:l})),o[c].hasAuxiliary&&this.prevStats_[c].hasAuxiliary&&(u=o[c].auxiliary.framesDecoded-this.prevStats_[c].auxiliary.framesDecoded,this.handleRenderFreeze({userId:c,type:Dt,fps:u})),f.next=7;break;case 17:this.prevStats_=o;case 18:case"end":return f.stop()}},r,this)})),function(){return n.apply(this,arguments)})},{key:"handleRenderFreeze",value:(t=H(p().mark(function r(o){var c,a,s,l,u,f,S,x;return p().wrap(function(E){for(;;)switch(E.prev=E.next){case 0:c=o.userId,a=o.fps,s=o.type,l="".concat(c,"_").concat(s),u=this.renderFreezeMap_.get(l),a<=2?(f=Ct(),u&&!u.isFreeze&&(u.freezeTimeline.push({startTime:f,endTime:void 0}),u.isFreeze=!0),u||this.renderFreezeMap_.set(l,{userId:c,type:s,isFreeze:!0,freezeTimeline:[{startTime:f,endTime:void 0}],renderFreezeTotal:0})):u&&u.isFreeze&&(u.isFreeze=!1,(S=u.freezeTimeline.pop()).endTime=Ct(),x=S.endTime-S.startTime,u.freezeTimeline.push(S),u.renderFreezeTotal+=Math.min(5e3,x));case 4:case"end":return E.stop()}},r,this)})),function(r){return t.apply(this,arguments)})},{key:"handlePlayVideoStart",value:function(r){var o=r.stream;if(o.getClient()===this.client_&&o.isRemote()&&o.hasVideo()){var c="".concat(o.getUserId(),"_").concat(o.getType());this.remoteStreamMap_.has(c)||this.remoteStreamMap_.set(c,{isPlayingFired:!1})}}},{key:"handleVideoPlaying",value:function(r){var o=r.stream;if(o.isRemote()&&o.getClient()===this.client_){var c="".concat(o.getUserId(),"_").concat(o.getType());this.remoteStreamMap_.has(c)&&(this.remoteStreamMap_.get(c).isPlayingFired=!0)}}},{key:"getDataFreezeDuration",value:function(r){var o={dataFreeze:0,count:0},c=this.dataFreezeMap_.get(r);if(c){if(c.isFreezing()){var a=c.durationItemList[c.durationItemList.length-1];a.stop(),a.getDuration()<500&&c.durationItemList.pop()}o.dataFreeze=this.getTotalDuration(c.durationItemList),o.count=c.durationItemList.length}return o}},{key:"getRenderFreezeDuration",value:function(r){var o=this.renderFreezeMap_.get(r),c=0,a=0;if(o)if(o.isFreeze){var s=Ct()-o.freezeTimeline[o.freezeTimeline.length-1].startTime;c=o.renderFreezeTotal+Math.min(s,5e3),a=o.freezeTimeline.length}else c=o.renderFreezeTotal;return{renderFreeze:c,count:a}}},{key:"getMonitorFreeze",value:function(){return this.monitorFreezeData_}},{key:"isBlackStream",value:function(r){return!!this.remoteStreamMap_.has(r)&&!this.remoteStreamMap_.get(r).isPlayingFired}},{key:"resetMonitor",value:function(){this.monitorFreezeData_.clear()}}]),e}(),Yv=Ie(function e(t){Q(this,e),this.userId=t.userId,this.tinyId=t.tinyId,this.role=t.role===so?Tr:Zi}),lI={exports:{}};(function(e){(function(t){function n(m,T){var v=(65535&m)+(65535&T);return(m>>16)+(T>>16)+(v>>16)<<16|65535&v}function i(m,T,v,w,L,N){return n((V=n(n(T,m),n(w,N)))<<(_=L)|V>>>32-_,v);var V,_}function r(m,T,v,w,L,N,V){return i(T&v|~T&w,m,T,L,N,V)}function o(m,T,v,w,L,N,V){return i(T&w|v&~w,m,T,L,N,V)}function c(m,T,v,w,L,N,V){return i(T^v^w,m,T,L,N,V)}function a(m,T,v,w,L,N,V){return i(v^(T|~w),m,T,L,N,V)}function s(m,T){var v,w,L,N,V;m[T>>5]|=128<<T%32,m[14+(T+64>>>9<<4)]=T;var _=1732584193,b=-271733879,R=-1732584194,P=271733878;for(v=0;v<m.length;v+=16)w=_,L=b,N=R,V=P,_=r(_,b,R,P,m[v],7,-680876936),P=r(P,_,b,R,m[v+1],12,-389564586),R=r(R,P,_,b,m[v+2],17,606105819),b=r(b,R,P,_,m[v+3],22,-1044525330),_=r(_,b,R,P,m[v+4],7,-176418897),P=r(P,_,b,R,m[v+5],12,1200080426),R=r(R,P,_,b,m[v+6],17,-1473231341),b=r(b,R,P,_,m[v+7],22,-45705983),_=r(_,b,R,P,m[v+8],7,1770035416),P=r(P,_,b,R,m[v+9],12,-1958414417),R=r(R,P,_,b,m[v+10],17,-42063),b=r(b,R,P,_,m[v+11],22,-1990404162),_=r(_,b,R,P,m[v+12],7,1804603682),P=r(P,_,b,R,m[v+13],12,-40341101),R=r(R,P,_,b,m[v+14],17,-1502002290),_=o(_,b=r(b,R,P,_,m[v+15],22,1236535329),R,P,m[v+1],5,-165796510),P=o(P,_,b,R,m[v+6],9,-1069501632),R=o(R,P,_,b,m[v+11],14,643717713),b=o(b,R,P,_,m[v],20,-373897302),_=o(_,b,R,P,m[v+5],5,-701558691),P=o(P,_,b,R,m[v+10],9,38016083),R=o(R,P,_,b,m[v+15],14,-660478335),b=o(b,R,P,_,m[v+4],20,-405537848),_=o(_,b,R,P,m[v+9],5,568446438),P=o(P,_,b,R,m[v+14],9,-1019803690),R=o(R,P,_,b,m[v+3],14,-187363961),b=o(b,R,P,_,m[v+8],20,1163531501),_=o(_,b,R,P,m[v+13],5,-1444681467),P=o(P,_,b,R,m[v+2],9,-51403784),R=o(R,P,_,b,m[v+7],14,1735328473),_=c(_,b=o(b,R,P,_,m[v+12],20,-1926607734),R,P,m[v+5],4,-378558),P=c(P,_,b,R,m[v+8],11,-2022574463),R=c(R,P,_,b,m[v+11],16,1839030562),b=c(b,R,P,_,m[v+14],23,-35309556),_=c(_,b,R,P,m[v+1],4,-1530992060),P=c(P,_,b,R,m[v+4],11,1272893353),R=c(R,P,_,b,m[v+7],16,-155497632),b=c(b,R,P,_,m[v+10],23,-1094730640),_=c(_,b,R,P,m[v+13],4,681279174),P=c(P,_,b,R,m[v],11,-358537222),R=c(R,P,_,b,m[v+3],16,-722521979),b=c(b,R,P,_,m[v+6],23,76029189),_=c(_,b,R,P,m[v+9],4,-640364487),P=c(P,_,b,R,m[v+12],11,-421815835),R=c(R,P,_,b,m[v+15],16,530742520),_=a(_,b=c(b,R,P,_,m[v+2],23,-995338651),R,P,m[v],6,-198630844),P=a(P,_,b,R,m[v+7],10,1126891415),R=a(R,P,_,b,m[v+14],15,-1416354905),b=a(b,R,P,_,m[v+5],21,-57434055),_=a(_,b,R,P,m[v+12],6,1700485571),P=a(P,_,b,R,m[v+3],10,-1894986606),R=a(R,P,_,b,m[v+10],15,-1051523),b=a(b,R,P,_,m[v+1],21,-2054922799),_=a(_,b,R,P,m[v+8],6,1873313359),P=a(P,_,b,R,m[v+15],10,-30611744),R=a(R,P,_,b,m[v+6],15,-1560198380),b=a(b,R,P,_,m[v+13],21,1309151649),_=a(_,b,R,P,m[v+4],6,-145523070),P=a(P,_,b,R,m[v+11],10,-1120210379),R=a(R,P,_,b,m[v+2],15,718787259),b=a(b,R,P,_,m[v+9],21,-343485551),_=n(_,w),b=n(b,L),R=n(R,N),P=n(P,V);return[_,b,R,P]}function l(m){var T,v="",w=32*m.length;for(T=0;T<w;T+=8)v+=String.fromCharCode(m[T>>5]>>>T%32&255);return v}function u(m){var T,v=[];for(v[(m.length>>2)-1]=void 0,T=0;T<v.length;T+=1)v[T]=0;var w=8*m.length;for(T=0;T<w;T+=8)v[T>>5]|=(255&m.charCodeAt(T/8))<<T%32;return v}function f(m){var T,v,w="0123456789abcdef",L="";for(v=0;v<m.length;v+=1)T=m.charCodeAt(v),L+=w.charAt(T>>>4&15)+w.charAt(15&T);return L}function S(m){return unescape(encodeURIComponent(m))}function x(m){return function(T){return l(s(u(T),8*T.length))}(S(m))}function E(m,T){return function(v,w){var L,N,V=u(v),_=[],b=[];for(_[15]=b[15]=void 0,V.length>16&&(V=s(V,8*v.length)),L=0;L<16;L+=1)_[L]=909522486^V[L],b[L]=1549556828^V[L];return N=s(_.concat(u(w)),512+8*w.length),l(s(b.concat(N),640))}(S(m),S(T))}function I(m,T,v){return T?v?E(T,m):f(E(T,m)):v?x(m):f(x(m))}e.exports?e.exports=I:t.md5=I})(ce)})(lI);var dI,hI,Ai,cd=lI.exports,i7=function(){function e(o){Q(this,e),this.client_=o.client,this.signalChannel_=o.signalChannel,this.log_=_e.createLogger({id:"mix|"+this.client_.getUserId(),userId:o.client.getUserId(),sdkAppId:o.client.getSDKAppId()}),this.isMixing_=!1,this.config_=null,this.data_=null,this.remoteStreamMap_=new Map,this.installEvents()}var t,n,i,r;return Ie(e,[{key:"isPresetLayoutMode",get:function(){return this.config_&&this.config_.mode===Jf.PRESET_LAYOUT}},{key:"installEvents",value:function(){Y.on(Ur,this.onStreamSubscribed,this),Y.on(Vr,this.onStreamUnsubscribed,this),this.client_.on("stream-removed",this.onStreamRemoved,this)}},{key:"uninstallEvents",value:function(){Y.off(Ur,this.onStreamSubscribed,this),Y.off(Vr,this.onStreamUnsubscribed,this),this.client_.off("stream-removed",this.onStreamRemoved,this)}},{key:"reset",value:function(){this.uninstallEvents(),this.isMixing_=!1,this.config_=null}},{key:"onStreamSubscribed",value:function(o){var c=o.client,a=o.stream;c===this.client_&&(this.remoteStreamMap_.set(a.getId(),{remoteStream:a,isUsed:!1}),this.isMixing_&&this.hasAvailablePlaceHolder()&&this.startMixTranscode(this.config_))}},{key:"onStreamUnsubscribed",value:function(o){var c=o.client,a=o.stream;c===this.client_&&this.onStreamRemoved({stream:a})}},{key:"onStreamRemoved",value:function(o){var c=o.stream;if(this.remoteStreamMap_.has(c.getId())){var a=this.remoteStreamMap_.get(c.getId()).isUsed;this.remoteStreamMap_.delete(c.getId()),this.isMixing_&&this.isPresetLayoutMode&&a&&this.startMixTranscode(this.config_)}}},{key:"startMixTranscode",value:(r=H(p().mark(function o(c){var a,s,l;return p().wrap(function(u){for(;;)switch(u.prev=u.next){case 0:if(u.prev=0,this.resetIsUsedFlag(),this.config_=c,a=this.getInputParam(c,this.remoteStreamMap_),s=this.getOutputParam(c),l=this.getOutputSessionId({config:c,roomId:this.client_.getRoomId(),userId:this.client_.getUserId()}),!this.isMixing_||!this.data_||l===this.data_.outputSessionId){u.next=10;break}return this.log_.info("startMixTranscode() streamId changed, stop mixing before start"),u.next=10,this.doStopMixTranscode();case 10:return u.next=12,this.doStartMixTranscode({outputSessionId:l,inputParam:a,outputParam:s});case 12:u.next=18;break;case 14:throw u.prev=14,u.t0=u.catch(0),this.resetIsUsedFlag(),u.t0;case 18:case"end":return u.stop()}},o,this,[[0,14]])})),function(o){return r.apply(this,arguments)})},{key:"doStartMixTranscode",value:(i=H(p().mark(function o(c){var a,s,l,u,f,S,x,E;return p().wrap(function(I){for(;;)switch(I.prev=I.next){case 0:return a=c.outputSessionId,s=c.inputParam,l=c.outputParam,u={roomId:String(this.client_.getRoomId()),mcuRequestTime:Date.now(),outputSessionId:a,inputParam:s,outputParam:l},this.data_=u,this.log_.info("startMixTranscode: ".concat(JSON.stringify(u))),this.isMixing_=!0,I.prev=5,I.next=8,this.signalChannel_.sendWaitForResponse({command:UU,data:u,timeout:5e3,responseCommand:st.START_MIX_TRANSCODE_RES,commandDesc:"startMixTranscode"});case 8:if(f=I.sent,S=f.data,x=S.code,E=S.message,x===0){I.next=15;break}throw x===-102083&&(E="Please enable relayed-push in ".concat($b," and try later, refer to ").concat(Yf,"tutorial-26-advanced-publish-cdn-stream.html")),this.log_.error("startMixTranscode failed, errCode: ".concat(x," errMsg: ").concat(E)),this.isMixing_=!1,new te({code:Z.START_MIX_TRANSCODE_FAILED,message:ae({key:I3,data:{message:E},link:{className:"Client",fnName:"startMixTranscode"}})});case 15:I.next=21;break;case 17:throw I.prev=17,I.t0=I.catch(5),this.isMixing_=!1,I.t0;case 21:case"end":return I.stop()}},o,this,[[5,17]])})),function(o){return i.apply(this,arguments)})},{key:"reStartMixTranscode",value:function(){this.isMixing_&&this.startMixTranscode(this.config_)}},{key:"stopMixTranscode",value:(n=H(p().mark(function o(){return p().wrap(function(c){for(;;)switch(c.prev=c.next){case 0:if(this.isMixing_){c.next=2;break}throw new te({code:Z.INVALID_OPERATION,message:ae({key:C3})});case 2:return c.next=4,this.doStopMixTranscode();case 4:this.resetIsUsedFlag();case 5:case"end":return c.stop()}},o,this)})),function(){return n.apply(this,arguments)})},{key:"doStopMixTranscode",value:(t=H(p().mark(function o(){var c,a,s,l,u;return p().wrap(function(f){for(;;)switch(f.prev=f.next){case 0:return c={mcuRequestTime:Date.now(),outputSessionId:this.data_.outputSessionId,streamType:this.data_.outputParam.streamType},this.log_.info("stopMixTranscode: ".concat(JSON.stringify(c))),f.next=4,this.signalChannel_.sendWaitForResponse({command:VU,data:c,timeout:5e3,responseCommand:st.STOP_MIX_TRANSCODE_RES,commandDesc:"stopMixTranscode"});case 4:if(a=f.sent,s=a.data,l=s.code,u=s.message,l!==0){f.next=10;break}this.isMixing_=!1,f.next=12;break;case 10:throw this.log_.error("stopMixTranscode failed, errCode: ".concat(l," errMsg: ").concat(u)),new te({code:Z.STOP_MIX_TRANSCODE_FAILED,message:ae({key:w3,data:{message:u},link:{className:"Client",fnName:"stopMixTranscode"}})});case 12:case"end":return f.stop()}},o,this)})),function(){return t.apply(this,arguments)})},{key:"getOutputSessionId",value:function(o){var c=o.config,a=o.userId,s=o.roomId;return Bt(c.streamId)&&c.streamId.length>0?c.streamId:cd("".concat(s,"_").concat(a,"_main"))}},{key:"getInputParam",value:function(o,c){var a=this,s=o.mixUsers.map(function(l){return{userId:l.userId,roomId:String(l.roomId||a.client_.getRoomId()),width:l.width||0,height:l.height||0,locationX:l.locationX||0,locationY:l.locationY||0,zOrder:l.zOrder,streamType:ge(l.streamType)||l.streamType!==Dt?0:1,inputType:l.pureAudio?Gb.IT_PURE_AUDIO:Gb.IT_AUDIO_VIDEO,renderMode:l.renderMode||0}});return o.mode===Jf.PRESET_LAYOUT&&(s.forEach(function(l){if(l.userId===Hb.REMOTE){var u=Se(c.values()).find(function(f){return!f.isUsed});u&&(l.userId=u.remoteStream.getUserId(),l.streamType=u.remoteStream.getType()===Dt?1:0,u.isUsed=!0)}}),s=s.filter(function(l){return l.userId!==Hb.REMOTE})),s}},{key:"getOutputParam",value:function(o){var c=o.streamId||"";return{streamId:c,streamType:c.length>0?1:0,width:ge(o.videoWidth)?640:o.videoWidth,height:ge(o.videoHeight)?480:o.videoHeight,videoBps:o.videoBitrate||0,fps:o.videoFramerate||15,gop:o.videoGOP||2,audioSampleRate:o.audioSampleRate||48e3,audioBps:o.audioBitrate||64,audioChannels:o.audioChannels||1,backgroundColor:o.backgroundColor||0,backgroundImg:o.backgroundImage||"",extraInfo:"",videoCodec:2,audioCodec:0}}},{key:"hasAvailablePlaceHolder",value:function(){return!!this.isPresetLayoutMode&&this.data_.inputParam.length!==this.config_.mixUsers.length}},{key:"resetIsUsedFlag",value:function(){this.remoteStreamMap_.forEach(function(o){return o.isUsed=!1})}}]),e}(),a7=function(){function e(a){Q(this,e),this.client_=a.client,this.signalChannel_=a.signalChannel,this.publishTencentMainStreamObj_={params_:null,streamId_:void 0,isPublishing_:!1},this.publishTencentAuxStreamObj_={params_:null,streamId_:void 0,isPublishing_:!1},this.publishGivenCDNData_=null,this.isPublishingGivenCDN_=!1}var t,n,i,r,o,c;return Ie(e,[{key:"setSignalChannel",value:function(a){this.signalChannel_=a.signalChannel}},{key:"getIsPublishingTencentCDN",value:function(){return this.publishTencentMainStreamObj_.isPublishing_||this.publishTencentAuxStreamObj_.isPublishing_}},{key:"getIsPublishingGivenCDN",value:function(){return this.isPublishingGivenCDN_}},{key:"generatePublishCDNStreamId",value:function(a,s){if(!a){var l="".concat(this.client_.getRoomId(),"_").concat(this.client_.getUserId(),"_").concat(s);return/^[A-Za-z\d_-]*$/.test(l)||(l=cd(l)),"".concat(this.client_.getSDKAppId(),"_").concat(l)}return a}},{key:"generatePublishCDNSessionId",value:function(a){return cd("".concat(this.client_.getRoomId(),"_").concat(this.client_.getUserId(),"_").concat(a))}},{key:"startPublishTencentCDN",value:(c=H(p().mark(function a(s){var l,u,f,S;return p().wrap(function(x){for(;;)switch(x.prev=x.next){case 0:if(s.streamType===Nn?(this.publishTencentAuxStreamObj_.params_=s,this.publishTencentAuxStreamObj_.isPublishing_=!0):(this.publishTencentMainStreamObj_.params_=s,this.publishTencentMainStreamObj_.isPublishing_=!0),this.client_.isJoined_){x.next=3;break}return x.abrupt("return");case 3:return l=this.generatePublishCDNStreamId(s.streamId,s.streamType),u=this.generatePublishCDNSessionId(s.streamType),f=s.streamType===Nn?1:0,S={requestTime:Date.now(),sessionId:u,streamId:l,streamType:f},x.next=9,this.doStartPublishTencentCDN(S,s.streamType);case 9:case"end":return x.stop()}},a,this)})),function(a){return c.apply(this,arguments)})},{key:"doStartPublishTencentCDN",value:(o=H(p().mark(function a(s,l){var u,f,S,x;return p().wrap(function(E){for(;;)switch(E.prev=E.next){case 0:return E.prev=0,_e.info("startPublishTencentCDN: "+JSON.stringify(s)),E.next=4,this.signalChannel_.sendWaitForResponseWithRetry({command:OU,data:s,timeout:2e3,responseCommand:st.START_PUBLISH_TENCENT_CDN_RES,commandDesc:"startPublishCDNStream",retries:2});case 4:if(u=E.sent,f=u.data,S=f.code,x=f.message,S!==0){E.next=10;break}l===Nn?this.publishTencentAuxStreamObj_.streamId_=s.streamId:this.publishTencentMainStreamObj_.streamId_=s.streamId,E.next=14;break;case 10:throw l===Nn?this.publishTencentAuxStreamObj_.isPublishing_=!1:this.publishTencentMainStreamObj_.isPublishing_=!1,S===-102083&&(x="Please enable relayed-push in ".concat($b," and try later, refer to ").concat(Yf,"tutorial-26-advanced-publish-cdn-stream.html")),_e.error("startPublishTencentCDN failed, errCode: ".concat(S,", errMsg: ").concat(x)),new te({code:Z.START_PUBLISH_CDN_FAILED,message:ae({key:dS,data:{message:x},link:{className:"Client",fnName:"startPublishCDNStream"}})});case 14:E.next=20;break;case 16:throw E.prev=16,E.t0=E.catch(0),l===Nn?this.publishTencentAuxStreamObj_.isPublishing_=!1:this.publishTencentMainStreamObj_.isPublishing_=!1,E.t0;case 20:case"end":return E.stop()}},a,this,[[0,16]])})),function(a,s){return o.apply(this,arguments)})},{key:"resetPublishTencentParam",value:function(a){a===Qe&&(this.publishTencentMainStreamObj_={params_:null,streamId_:void 0,isPublishing_:!1}),a===Nn&&(this.publishTencentAuxStreamObj_={params_:null,streamId_:void 0,isPublishing_:!1})}},{key:"stopPublishTencentCDN",value:(r=H(p().mark(function a(){return p().wrap(function(s){for(;;)switch(s.prev=s.next){case 0:if(this.client_.isJoined_){s.next=4;break}return this.resetPublishTencentParam(Qe),this.resetPublishTencentParam(Nn),s.abrupt("return");case 4:if(!this.publishTencentMainStreamObj_.isPublishing_){s.next=7;break}return s.next=7,this.doStopPublishTencentCDN(Qe);case 7:if(!this.publishTencentAuxStreamObj_.isPublishing_){s.next=10;break}return s.next=10,this.doStopPublishTencentCDN(Nn);case 10:case"end":return s.stop()}},a,this)})),function(){return r.apply(this,arguments)})},{key:"doStopPublishTencentCDN",value:(i=H(p().mark(function a(s){var l,u,f,S,x;return p().wrap(function(E){for(;;)switch(E.prev=E.next){case 0:return l={requestTime:Date.now(),sessionId:cd("".concat(this.client_.getRoomId(),"_").concat(this.client_.getUserId(),"_").concat(s))},_e.info("stopPublishTencentCDN: "+JSON.stringify(l)),E.next=4,this.signalChannel_.sendWaitForResponse({command:LU,data:l,timeout:5e3,responseCommand:st.STOP_PUBLISH_TENCENT_CDN_RES,commandDesc:"stopPublishCDNStream"});case 4:if(u=E.sent,f=u.data,S=f.code,x=f.message,S!==0){E.next=10;break}this.resetPublishTencentParam(s),E.next=17;break;case 10:if(S!==-102069){E.next=15;break}_e.warn("stopPublishTencentCDN failed, can not stopPublishTencentCDN in auto relayed-push mode"),this.resetPublishTencentParam(s),E.next=17;break;case 15:throw _e.error("stopPublishTencentCDN failed, errCode: ".concat(S," errMsg: ").concat(x)),new te({code:Z.STOP_PUBLISH_CDN_FAILED,message:ae({key:hS,data:{message:x},link:{className:"Client",fnName:"stopPublishCDNStream"}})});case 17:case"end":return E.stop()}},a,this)})),function(a){return i.apply(this,arguments)})},{key:"startPublishGivenCDN",value:(n=H(p().mark(function a(s){var l,u,f,S,x,E;return p().wrap(function(I){for(;;)switch(I.prev=I.next){case 0:if(l=s.streamType===Qe?this.publishTencentMainStreamObj_.streamId_:this.publishTencentAuxStreamObj_.streamId_,u={pushRequestTime:Date.now(),pushAppId:s.appId,pushBizId:s.bizId,pushCdnUrl:s.url,pushStreamType:s.streamType,pushStreamId:l},_e.info("startPublishGivenCDN: "+JSON.stringify(u)),this.publishGivenCDNData_=u,this.isPublishingGivenCDN_=!0,this.client_.isJoined_){I.next=7;break}return I.abrupt("return");case 7:return I.prev=7,I.next=10,this.signalChannel_.sendWaitForResponse({command:MU,data:u,timeout:5e3,responseCommand:st.START_PUBLISH_GIVEN_CDN_RES,commandDesc:"startPublishCDNStream"});case 10:if(f=I.sent,S=f.data,x=S.code,E=S.message,x===0){I.next=17;break}throw _e.error("startPublishGivenCDN failed, errCode: ".concat(x,", errMsg: ").concat(E)),this.publishGivenCDNData_=null,this.isPublishingGivenCDN_=!1,new te({code:Z.START_PUBLISH_CDN_FAILED,message:ae({key:dS,data:{message:E},link:{className:"Client",fnName:"startPublishCDNStream"}})});case 17:I.next=24;break;case 19:throw I.prev=19,I.t0=I.catch(7),this.publishGivenCDNData_=null,this.isPublishingGivenCDN_=!1,I.t0;case 24:case"end":return I.stop()}},a,this,[[7,19]])})),function(a){return n.apply(this,arguments)})},{key:"stopPublishGivenCDN",value:(t=H(p().mark(function a(){var s,l,u,f,S,x,E,I,m,T;return p().wrap(function(v){for(;;)switch(v.prev=v.next){case 0:if(this.client_.isJoined_){v.next=4;break}return this.publishGivenCDNData_=null,this.isPublishingGivenCDN_=!1,v.abrupt("return");case 4:return s=this.publishGivenCDNData_,l=s.pushAppId,u=s.pushBizId,f=s.pushCdnUrl,S=s.pushStreamType,x={pushRequestTime:Date.now(),pushAppId:l,pushBizId:u,pushCdnUrl:f,pushStreamType:S},_e.info("stopPublishGivenCDN: "+JSON.stringify(x)),v.next=9,this.signalChannel_.sendWaitForResponse({command:NU,data:x,timeout:5e3,responseCommand:st.STOP_PUBLISH_GIVEN_CDN_RES,commandDesc:"stopPublishCDNStream"});case 9:if(E=v.sent,I=E.data,m=I.code,T=I.message,m!==0){v.next=16;break}this.publishGivenCDNData_=null,this.isPublishingGivenCDN_=!1,v.next=18;break;case 16:throw _e.error("stopPublishGivenCDN failed, errCode: ".concat(m," errMsg: ").concat(T)),new te({code:Z.STOP_PUBLISH_CDN_FAILED,message:ae({key:hS,data:{message:T},link:{className:"Client",fnName:"stopPublishCDNStream"}})});case 18:case"end":return v.stop()}},a,this)})),function(){return t.apply(this,arguments)})},{key:"handleCDNConfigForJoinData",value:function(a){var s,l=a;if(this.publishTencentMainStreamObj_.isPublishing_||this.publishTencentAuxStreamObj_.isPublishing_){var u={};Bt(l)&&(u=JSON.parse(l)),u.Str_uc_params||(u.Str_uc_params={}),this.publishTencentMainStreamObj_.isPublishing_&&(this.publishTencentMainStreamObj_.streamId_?u.Str_uc_params.userdefine_streamid_main=this.publishTencentMainStreamObj_.streamId_:this.publishTencentMainStreamObj_.params_&&(u.Str_uc_params.userdefine_streamid_main=this.generatePublishCDNStreamId(this.publishTencentMainStreamObj_.params_.streamId,Qe))),this.publishTencentAuxStreamObj_.isPublishing_&&(this.publishTencentAuxStreamObj_.streamId_?u.Str_uc_params.userdefine_streamid_aux=this.publishTencentAuxStreamObj_.streamId_:this.publishTencentAuxStreamObj_.params_&&(u.Str_uc_params.userdefine_streamid_aux=this.generatePublishCDNStreamId(this.publishTencentAuxStreamObj_.params_.streamId,Nn))),l=JSON.stringify(u)}if(this.isPublishingGivenCDN_){var f=this.publishGivenCDNData_,S=f.pushAppId,x=f.pushBizId,E=f.pushCdnUrl,I=f.pushStreamType,m=f.pushStreamId;s={pushRequestTime:Date.now(),pushAppId:S,pushBizId:x,pushCdnUrl:E,pushStreamType:I,pushStreamId:m}}return{bussinessInfo:l,pushUserCdnInfo:s}}},{key:"reset",value:function(){this.resetPublishTencentParam(Qe),this.resetPublishTencentParam(Nn),this.publishGivenCDNData_=null,this.isPublishingGivenCDN_=!1}}]),e}(),o7=function(){function e(t){Q(this,e),this.client_=t.client,this.durationMap_=new Map,this.installEvents()}return Ie(e,[{key:"installEvents",value:function(){Y.on(Ur,this.handleSubscribed,this),Y.on(jn,this.handleStreamTrackUpdated,this),Y.on(Vr,this.handleStreamStopped,this),Y.on(ca,this.handleStreamStopped,this)}},{key:"uninstallEvents",value:function(){Y.off(Ur,this.handleSubscribed,this),Y.off(jn,this.handleStreamTrackUpdated,this),Y.off(Vr,this.handleStreamStopped,this),Y.off(ca,this.handleStreamStopped,this)}},{key:"handleSubscribed",value:function(t){var n=t.client,i=t.stream;if(n===this.client_){var r=i.getUserId(),o=i.getType(),c="".concat(r,"_").concat(o);if(i.hasAudio())if(i.isMainAudioSubscribed){var a=new sd,s=this.durationMap_.get(c);s?this.isRecording(s.audio)||s.audio.push(a):this.durationMap_.set(c,{userId:r,type:o,audio:[a],video:[]})}else this.stopDurationItem(c,Ee);if(i.hasVideo())if(o===yt&&i.isMainVideoSubscribed||o===Dt&&i.isAuxVideoSubscribed){var l=new sd,u=this.durationMap_.get(c);u?this.isRecording(u.video)||u.video.push(l):this.durationMap_.set(c,{userId:r,type:o,audio:[],video:[l]})}else this.stopDurationItem(c,xe)}}},{key:"handleStreamStopped",value:function(t){var n=t.client,i=t.stream;if(this.clientHitTest(n)){var r=i.getUserId(),o=i.getType(),c="".concat(r,"_").concat(o);this.stopDurationItem(c,Ee),this.stopDurationItem(c,xe)}}},{key:"handleStreamTrackUpdated",value:function(t){var n=t.client,i=t.userId,r=t.tinyId,o=t.kind,c=t.action;if(this.clientHitTest(n)&&this.client_.getConnections().has(r)){var a=o===gt?o:yt,s="".concat(i,"_").concat(a);if(c===cn.ADD){var l=this.client_.getConnections().get(r).getSubscribeState();if(o===Ee&&!l.audio||o===xe&&!l.video||o===gt&&!l.auxiliary)return;var u=new sd,f=this.durationMap_.get(s);f?(o!==Ee||this.isRecording(f.audio)||f.audio.push(u),o===Ee||this.isRecording(f.video)||f.video.push(u)):this.durationMap_.set(s,{userId:i,type:a,audio:o===Ee?[u]:[],video:o===Ee?[]:[u]})}else this.stopDurationItem(s,o===Ee?Ee:xe)}}},{key:"isRecording",value:function(t){return t.findIndex(function(n){return n.endTime===0})>=0}},{key:"stopDurationItem",value:function(t,n){if(this.durationMap_.has(t)){var i=this.durationMap_.get(t)[n].find(function(r){return r.endTime===0});i&&i.stop()}}},{key:"clientHitTest",value:function(t){return this.client_===t}},{key:"getDuration",value:function(t,n){return this.durationMap_.has(t)?this.durationMap_.get(t)[n].reduce(function(i,r){return i+r.getDuration()},0):0}},{key:"getDurationMap",value:function(){return this.durationMap_}},{key:"reset",value:function(){this.durationMap_.clear()}},{key:"destroy",value:function(){this.client_=null,this.uninstallEvents()}}]),e}();function wc(){return function(e,t,n){var i=n.value,r=new Set;return n.value=H(p().mark(function o(){var c,a,s,l,u=arguments;return p().wrap(function(f){for(;;)switch(f.prev=f.next){case 0:if(!r.has(this)){f.next=2;break}throw new te({code:Z.INVALID_OPERATION,message:ae({key:bN,data:{name:t}})});case 2:for(f.prev=2,r.add(this),c=u.length,a=new Array(c),s=0;s<c;s++)a[s]=u[s];return f.next=7,i.apply(this,a);case 7:return l=f.sent,r.delete(this),f.abrupt("return",l);case 12:throw f.prev=12,f.t0=f.catch(2),r.delete(this),f.t0;case 16:case"end":return f.stop()}},o,this,[[2,12]])})),n}}var fI,pI,mI,vI,gI,_I,yI,bI,SI,kI,TI,xI,II,wI,CI,EI,RI,AI,PI,DI,OI,LI,MI,NI,UI,VI,jI,BI,FI,HI,GI,Pe,s7=(dI=fn({name:"options",type:In,required:!0,properties:{roomId:{type:dt,required:!0},userId:{type:dt,required:!1}}}),hI=fn({name:"options",type:In,required:!0,properties:{updateList:{type:zb,required:!0,arrayItem:{require:!0,type:In,properties:{roomId:{required:!0,type:dt},userId:{required:!1,type:dt},muteAudio:{type:Wt},muteVideo:{type:Wt},muteAuxiliary:{type:Wt}}},validate:function(e){if(e.find(function(t){return t.userId})&&e.find(function(t){return!t.userId}))throw new te({code:Z.INVALID_PARAMETER,message:"you can not update both userId and all"})}}}}),Ai=function(){function e(){Q(this,e),this.crossRoomSeq=0}var t,n,i;return Ie(e,[{key:"call",value:function(r,o){return ln(this[r])?this[r](o):Promise.reject(new te({code:Z.INVALID_PARAMETER,message:ae({key:K3,data:{name:r}})}))}},{key:"updatePrivateMapKey",value:function(r){var o=r.privateMapKey;return r.client.setProperty("privateMapKey",o),Promise.resolve()}},{key:"connectOtherRoom",value:(i=H(p().mark(function r(o){var c,a,s,l;return p().wrap(function(u){for(;;)switch(u.prev=u.next){case 0:if(c=o.client,a=o.roomId,s=o.userId,c.signalChannel_){u.next=3;break}return u.abrupt("return",Promise.reject(new te({code:Z.INVALID_OPERATION,message:"you did not joined room"})));case 3:return u.next=5,c.signalChannel_.sendWaitForResponseWithRetry({command:HU,responseCommand:st.CONNECT_OTHER_ROOM_RES,data:{roomId:a,userId:s,localRoomId:s?void 0:c.getRoomId()},retries:3});case 5:if((l=u.sent).data.code===0){u.next=8;break}throw new te({code:l.data.code,message:l.data.message});case 8:case"end":return u.stop()}},r)})),function(r){return i.apply(this,arguments)})},{key:"updateOtherRoomForwardMode",value:(n=H(p().mark(function r(o){var c,a,s,l,u;return p().wrap(function(f){for(;;)switch(f.prev=f.next){case 0:if(a=o.client,s=o.updateList,a.signalChannel_){f.next=3;break}return f.abrupt("return",Promise.reject(new te({code:Z.INVALID_OPERATION,message:"you did not joined room"})));case 3:return l=s.find(function(S){return S.userId})?0:1,f.next=6,a.signalChannel_.sendWaitForResponseWithRetry({command:GU,responseCommand:st.UPDATE_OTHER_ROOM_FORWARD_MODE_RES,data:{seq:++this.crossRoomSeq,operationType:l,updateList:s.map(function(S){return{roomId:S.roomId,userId:S.userId,muteAudio:S.muteAudio,muteVideo:S.muteVideo,muteSubStream:S.muteAuxiliary}})},retries:3});case 6:if(!(u=f.sent).data.data.expectSeq){f.next=10;break}return this.crossRoomSeq=u.data.data.expectSeq,f.abrupt("return",this.updateOtherRoomForwardMode({client:a,updateList:s}));case 10:if(u.data.code===0){f.next=14;break}throw new te({code:u.data.code,message:u.data.message});case 14:if(!(((c=u.data.errorList)===null||c===void 0?void 0:c.length)>0)){f.next=16;break}throw new te({code:Z.UNKNOWN,message:u.data.errorList[0].message});case 16:case"end":return f.stop()}},r,this)})),function(r){return n.apply(this,arguments)})},{key:"disconnectOtherRoom",value:(t=H(p().mark(function r(o){var c,a,s;return p().wrap(function(l){for(;;)switch(l.prev=l.next){case 0:if(c=o.client,a=o.roomId,c.signalChannel_){l.next=3;break}return l.abrupt("return",Promise.resolve());case 3:return l.next=5,c.signalChannel_.sendWaitForResponseWithRetry({command:zU,responseCommand:st.DISCONNECT_OTHER_ROOM_RES,data:{roomId:a,localRoomId:a?c.getRoomId():void 0},retries:3});case 5:if((s=l.sent).data.code===0){l.next=8;break}throw new te({code:s.data.code,message:s.data.message});case 8:case"end":return l.stop()}},r)})),function(r){return t.apply(this,arguments)})}]),e}(),X(Ai.prototype,"connectOtherRoom",[dI],Object.getOwnPropertyDescriptor(Ai.prototype,"connectOtherRoom"),Ai.prototype),X(Ai.prototype,"updateOtherRoomForwardMode",[hI],Object.getOwnPropertyDescriptor(Ai.prototype,"updateOtherRoomForwardMode"),Ai.prototype),Ai),c7=new s7,ud,ld,dd,$v,zI,WI,JI,qI,KI,XI,$t,u7=(fI=wc(),pI=fn(Yt.CLIENT.join),mI=Lo({retries:1,timeout:0,onError:function(e,t,n){this.isUsingCachedSchedule_?(this.log_.warn("is using cached schedule, retry join"),ki(!0),this.reset(),t()):(Y.emit(sa,{client:this,error:e}),ke.logFailedEvent({userId:this.userId_,eventType:Tb,error:e}),this.reset(),this.log_.error(e),n(e))}}),vI=wc(),gI=Lo({retries:3}),_I=wc(),yI=fn.apply(void 0,Se(Yt.CLIENT.publish)),bI=St(un),SI=wc(),kI=fn(Yt.CLIENT.unpublish),TI=fn.apply(void 0,Se(Yt.CLIENT.subscribe)),xI=fn(Yt.CLIENT.unsubscribe),II=wc(),wI=fn(Yt.CLIENT.switchRole),CI=St(un),EI=fn(Yt.CLIENT.startPublishCDNStream),RI=St(un),AI=St(un),PI=fn(Yt.CLIENT.startMixTranscode),DI=St(un),OI=St(un),LI=St(un),MI=St(un),NI=St(un),UI=St(un),VI=St(un),jI=Ql.apply(void 0,Se(Yt.CLIENT.sendSEIMessage)),BI=St(un),ud={timesInSecond:30,maxSizeInSecond:8e3,getSize:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return t[0].byteLength}},ld=ud.timesInSecond,dd=ud.maxSizeInSecond,$v=ud.getSize,FI=function(e,t,n){var i=n.value,r=new Map;return Y.on(Up,function(o){var c=o.client;return r.delete(c)}),n.value=function(){var o=r.get(this);o||(o={callCountInSecond:0,timestamp:0,totalSizeInSecond:0},r.set(this,o)),o.timestamp===0?o.timestamp=Date.now():Date.now()-o.timestamp>1e3&&(o.timestamp=Date.now(),o.callCountInSecond=0,o.totalSizeInSecond=0);for(var c=arguments.length,a=new Array(c),s=0;s<c;s++)a[s]=arguments[s];if($v&&(o.totalSizeInSecond+=$v.apply(void 0,a)),o.timestamp!==0&&Date.now()-o.timestamp<1e3&&(o.callCountInSecond>=ld||o.totalSizeInSecond>dd))throw new te({code:Z.INVALID_OPERATION,message:ae({key:n4,data:{isTimes:o.callCountInSecond>=ld,isSize:o.totalSizeInSecond>dd,name:t,timesInSecond:ld,maxSizeInSecond:dd}})});return o.callCountInSecond++,i.apply(this,a)},n},HI=St(un),GI=St(un),Pe=function(){function e(k){var h,y;Q(this,e),this.name_=un,this.mode_=k.mode,this.sdpSemantics_=Wf,ge(k.sdpSemantics)?function(){var A;if(ge(window.RTCRtpTransceiver)||!("currentDirection"in RTCRtpTransceiver.prototype))return!1;var D=null,j=!1;try{(D=new RTCPeerConnection({sdpSemantics:Ys})).addTransceiver(Ee),j=!0}catch(K){}return(A=D)===null||A===void 0||A.close(),j}()&&(this.sdpSemantics_=Ys):this.sdpSemantics_=k.sdpSemantics,this.sdkAppId_=k.sdkAppId,this.userId_=k.userId,this.log_=_e.createLogger({id:"c".concat(k.seq,"|").concat(this.userId_),userId:this.userId_,sdkAppId:this.sdkAppId_}),this.userSig_=k.userSig,this.roomId_=0,this.useStringRoomId_=k.useStringRoomId||!1,this.pureAudioPushMode_=null,this.version_=k.version,this.log_.info("using sdpSemantics: "+this.sdpSemantics_),this.signalChannel_=null,this.role_=Tr,this.privateMapKey_="",this.tinyId_=0,this.env_="",this.proxy_=null,this.unifiedProxy_=null,this.connections_=new Map,this.mutedStates_=new Map,this.userMap_=new Map,this.syncUserListInterval_=-1,this.localStream_=null,this.localAuxStream_=null,this.uplinkConnection_=null,this.emitter_=GS(new Si,this.name_),this.isJoined_=!1,this.heartbeat_=-1,this.lastHeartBeatTime_=-1,this.stats_=new c6(this),this.joinTimeout_=-1,this.changeBigSmallRecords_=new Map,this.networkQuality_=null,this.badCaseDetector_=null,this.networkType_=Tp(),this.autoSubscribe_=!!ge(k.autoSubscribe)||k.autoSubscribe,this.joinedTimestamp_=0,this.joinOptions_={},this.basis_=(y={browser:aa().name+"/"+aa().version,os:Im(),displayResolution:ZV(),isScreenShareSupported:Bk(),isWebRTCSupported:ym(),isGetUserMediaSupported:e6(),isWebAudioSupported:t6(),isWebSocketsSupported:"WebSocket"in window&&window.WebSocket.CLOSING===2,isWebCodecSupported:(h={AudioDecoder:!1,AudioEncoder:!1,VideoDecoder:!1,VideoEncoder:!1,ImageDecoder:!1},ge(window.AudioDecoder)||(h.AudioDecoder=!0),ge(window.AudioEncoder)||(h.AudioEncoder=!0),ge(window.VideoDecoder)||(h.VideoDecoder=!0),ge(window.VideoEncoder)||(h.VideoEncoder=!0),ge(window.ImageDecoder)||(h.ImageDecoder=!0),h),isMediaSessionSupported:"mediaSession"in navigator&&!ge(navigator.mediaSession.setActionHandler),isWebTransportSupported:!ge(window.WebTransport)},navigator.userAgent.includes("miniProgram")&&(y.browser="mini/".concat(y.browser)),y),this.initBussinessInfo_(k),this.publishedCDN_=!1,this.publishCDNData_=null,this.mixedMCU_=!1,this.mixTranscodeData_=null,this.checkSystemResult_=null,this.enableAudioVolumeEvaluation_=!1,this.audioVolumeIntervalId_=null,this.mixTranscodeManager_=null,this.publishCDNManager_=new a7({client:this}),this.keyPointManager_=new kF({client:this,frameWorkType:k.frameWorkType,component:k.component}),this.isPublishing_=!1,this.isEnableSmallStream_=!1,this.smallStreamConfig_={bitrate:100,frameRate:15,height:120,width:160},this.turnServers_=[],this.iceTransportPolicy_=k.iceTransportPolicy,this.schedule_={domains:null,iceServers:null,iceTransportPolicy:null,trtcCapability:null},this.isUsingCachedSchedule_=!1,this.enableAutoPlayDialog_=!!ge(k.enableAutoPlayDialog)||k.enableAutoPlayDialog,this.enableMultiAuxStream_=!ge(k.enableMultiAuxStream)&&k.enableMultiAuxStream,this.signalInfo_={},this.enableSEI_=!ge(k.enableSEI)&&k.enableSEI,this.isDestroyed_=!1}var t,n,i,r,o,c,a,s,l,u,f,S,x,E,I,m,T,v,w,L,N,V,_,b,R,P,U;return Ie(e,[{key:"initBussinessInfo_",value:function(k){this.bussinessInfo_=k.bussinessInfo;var h={};if(Bt(k.bussinessInfo)&&(h=JSON.parse(k.bussinessInfo)),!ge(k.pureAudioPushMode)){if(!Number.isInteger(Number(k.pureAudioPushMode)))throw new te({code:Z.INVALID_PARAMETER,message:ae({key:DN})});this.pureAudioPushMode_=k.pureAudioPushMode,h.Str_uc_params||(h.Str_uc_params={}),h.Str_uc_params.pure_audio_push_mod=this.pureAudioPushMode_}if(!ge(k.streamId)){if(!(Bt(k.streamId)&&String(k.streamId)&&String(k.streamId).length<=64))throw new te({code:Z.INVALID_PARAMETER,message:ae({key:ON})});h.Str_uc_params||(h.Str_uc_params={}),h.Str_uc_params.userdefine_streamid_main=k.streamId}if(!ge(k.userDefineRecordId)){if(k.userDefineRecordId.match(/^[A-Za-z0-9_-]{1,64}$/gi)===null)throw new te({code:Z.INVALID_PARAMETER,message:ae({key:LN})});h.Str_uc_params||(h.Str_uc_params={}),h.Str_uc_params.userdefine_record_id=k.userDefineRecordId}if(!ge(k.userDefinePushArgs)){if(!(Bt(k.userDefinePushArgs)&&String(k.userDefinePushArgs)&&String(k.userDefinePushArgs).length<=256))throw new te({code:Z.INVALID_PARAMETER,message:ae({key:MN})});h.Str_uc_params||(h.Str_uc_params={}),h.Str_uc_params.userdefine_push_args=k.userDefinePushArgs}k.enableServerAudioMix&&(h.Str_uc_params||(h.Str_uc_params={}),h.Str_uc_params.enable_server_audio_mix=1,h.Str_uc_params.uc_biz_type=1e3),Br(h)||(this.bussinessInfo_=JSON.stringify(h))}},{key:"schedule",value:(U=H(p().mark(function k(h){var y,A,D;return p().wrap(function(j){for(;;)switch(j.prev=j.next){case 0:return j.next=2,OV({userId:this.userId_,sdkAppId:this.sdkAppId_,roomId:h,useStringRoomId:this.useStringRoomId_,version:this.version_,userSig:this.userSig_});case 2:y=j.sent,A=y.result,D=y.isCached,this.isUsingCachedSchedule_=D,A&&(this.log_.info("schedule with cache:".concat(D," : ").concat(JSON.stringify(A))),A.trtcCapability=A==null?void 0:A.trtcAutoConf,this.schedule_=q(q({},this.schedule_),A),Y.emit(qS,this.schedule_));case 7:case"end":return j.stop()}},k,this)})),function(k){return U.apply(this,arguments)})},{key:"getSignalChannelUrl",value:function(){var k={mainUrl:"",backupUrl:""},h=MS();return h?k.mainUrl=k.backupUrl="wss://".concat(h,".rtc.qq.com"):this.proxy_?k.mainUrl=k.backupUrl=this.proxy_:this.unifiedProxy_?k.mainUrl=k.backupUrl="wss://".concat(this.unifiedProxy_):Array.isArray(this.schedule_.domains)&&this.schedule_.domains.length>0&&(k.mainUrl=k.backupUrl="wss://".concat(this.schedule_.domains[0]),this.schedule_.domains[1]&&(k.backupUrl="wss://".concat(this.schedule_.domains[1]))),k}},{key:"getUserId",value:function(){return this.userId_}},{key:"getUserSig",value:function(){return this.userSig_}},{key:"getRole",value:function(){return this.role_}},{key:"getSignalInfo",value:function(){return this.signalInfo_}},{key:"getRoomId",value:function(){return this.roomId_}},{key:"getSDKAppId",value:function(){return this.sdkAppId_}},{key:"getTinyId",value:function(){return this.tinyId_}},{key:"getIceTransportPolicy",value:function(){return this.iceTransportPolicy_||this.schedule_.iceTransportPolicy||"all"}},{key:"initialize",value:function(k){var h=this;this.log_.info("setup signal channel");var y=this.getSignalChannelUrl(),A=y.mainUrl,D=y.backupUrl;return this.signalChannel_=new NV({sdkAppId:this.sdkAppId_,userId:this.userId_,userSig:this.userSig_,roomId:k.roomId,url:A,backupUrl:D,signalDomainWhenUnifiedProxy:this.unifiedProxy_?this.schedule_.domains[0]:void 0,client:this}),this.networkQuality_||(this.networkQuality_=new u6({connections:this.connections_,signalChannel:this.signalChannel_,userId:this.userId_,client:this}),this.networkQuality_.on(ct.NETWORK_QUALITY,function(j){h.emitter_.emit(ct.NETWORK_QUALITY,j)})),this.deviceDetector_||(this.deviceDetector_=new l6({client:this})),this.subscriptionManager_||(this.subscriptionManager_=new TF({client:this})),this.badCaseDetector_||(this.badCaseDetector_=new r7({client:this,stats:this.stats_})),this.callDurationCalculator_||(this.callDurationCalculator_=new o7({client:this})),this.mixTranscodeManager_||(this.mixTranscodeManager_=new i7({client:this,signalChannel:this.signalChannel_})),this.publishCDNManager_&&this.publishCDNManager_.setSignalChannel({signalChannel:this.signalChannel_}),this.signalChannel_.on(rm,function(j){h.log_.info("SignalChannel state changed from ".concat(j.prevState," to ").concat(j.state)),h.emitter_.emit(ct.CONNECTION_STATE_CHANGED,j)}),this.signalChannel_.on(im,function(j){h.reset(),h.emitter_.emit(ct.ERROR,j)}),this.signalChannel_.once(pk,function(j){h.tinyId_=j.signalInfo.tinyId,Y.emit(ll,{client:h})}),this.signalChannel_.on(st.PEER_JOIN,this.onPeerJoin,this),this.signalChannel_.on(st.PEER_LEAVE,this.onPeerLeave,this),this.signalChannel_.on(st.UPDATE_REMOTE_MUTE_STAT,function(j){Date.now()-h.lastHeartBeatTime_>=1e4&&h.doHeartbeat(),Y.emit(Op,{client:h,data:j.data}),h.onPublishedUserList(j.data),h.onUpdateRemoteMuteStat(j.data)}),this.signalChannel_.on(st.CLIENT_BANNED,function(j){var K,J=j.data.data.reason;if(ke.uploadEvent({log:"stat-banned:".concat(J),userId:h.userId_}),J===UM)K="you got banned by the admin";else if(J===VM)K="duplicated userId joining the room";else if(J===BM)K="the room has been disbanded by the admin",J=J.replace("_","-");else if(J===jM)return h.log_.warn("".concat(J," last heart beat time: ").concat(h.lastHeartBeatTime_," interval: ").concat(Date.now()-h.lastHeartBeatTime_,", visibility: ").concat(document.visibilityState)),void h.reJoin();h.log_[J==="kick"?"error":"info"]("user was banned because of [".concat(J,"]")),h.reset(),h.emitter_.emit(ct.CLIENT_BANNED,{reason:J,message:ae({key:ZN,data:{message:K,reason:J}})||J})}),Y.emit(Mp,{client:this}),this.signalChannel_.connect()}},{key:"preJoin",value:(P=H(p().mark(function k(h){var y,A,D,j;return p().wrap(function(K){for(;;)switch(K.prev=K.next){case 0:return this.joinOptions_=h,K.next=3,Sm();case 3:if(this.checkSystemResult_=K.sent,this.checkDestroy(),(y=MS())||(y=Gu,this.proxy_&&(this.proxy_.startsWith(HM)?y=zM:this.proxy_.startsWith(GM)&&(y=WM))),this.env_=y,ke.setConfig({env:y,sdkAppId:this.sdkAppId_,userId:this.userId_,roomId:h.roomId}),this.uploadTrtcStats(),A=this.checkSystemResult_.detail,D=A.isH264EncodeSupported,j=A.isVp8EncodeSupported,ym()&&(D||j)){K.next=13;break}throw new te({code:Z.NOT_SUPPORTED,message:ae({key:vS})});case 13:case"end":return K.stop()}},k,this)})),function(k){return P.apply(this,arguments)})},{key:"join",value:(R=H(p().mark(function k(h){var y,A=this;return p().wrap(function(D){for(;;)switch(D.prev=D.next){case 0:return this.roomId_=h.roomId,ge(h.role)||(this.role_=h.role),ge(h.privateMapKey)||(this.privateMapKey_=h.privateMapKey),y=Ct(),Y.emit(ul,{client:this}),vn(this.userId_,{eventId:iV,eventDesc:"joining room",timestamp:an(),userId:this.userId_,tinyId:this.tinyId_}),D.next=8,this.preJoin(h);case 8:return D.abrupt("return",new Promise(function(){var j=H(p().mark(function K(J,se){return p().wrap(function(ie){for(;;)switch(ie.prev=ie.next){case 0:if(A.joinReject_=se,ie.prev=1,A.proxy_||A.schedule_.domains){ie.next=5;break}return ie.next=5,A.schedule(h.roomId);case 5:return A.checkDestroy(),ie.next=8,A.initialize(h);case 8:return ie.next=10,A.doJoin(h);case 10:A.signalInfo_=A.signalChannel_.getSignalInfo(),Y.emit(po,{client:A}),A.joinedTimestamp_=Ct(),ke.logSuccessEvent({userId:A.userId_,eventType:eN,delta:A.joinedTimestamp_-y}),ke.logSuccessEvent({userId:A.userId_,eventType:Tb}),ke.uploadEvent({log:"stat-autoplay-dialog:".concat(A.enableAutoPlayDialog_),userId:A.userId_}),ke.uploadEvent({log:"stat-conv-".concat(ra,"-").concat(location.hostname),userId:A.userId_}),J(),ie.next=23;break;case 20:ie.prev=20,ie.t0=ie.catch(1),se(ie.t0);case 23:A.joinReject_=null;case 24:case"end":return ie.stop()}},K,null,[[1,20]])}));return function(K,J){return j.apply(this,arguments)}}()));case 9:case"end":return D.stop()}},k,this)})),function(k){return R.apply(this,arguments)})},{key:"checkDestroy",value:function(){if(this.isDestroyed_)throw new te({code:Z.INVALID_OPERATION,message:ae({key:tp,data:{funName:"join"}})})}},{key:"uploadTrtcStats",value:(b=H(p().mark(function k(){var h,y,A,D,j,K,J,se,ie,Je,Ue,Fe,ht;return p().wrap(function(ze){for(;;)switch(ze.prev=ze.next){case 0:return ze.prev=0,ze.next=3,xt.getMicrophones();case 3:A=ze.sent,h=A&&A.length,ze.next=9;break;case 7:ze.prev=7,ze.t0=ze.catch(0);case 9:return ze.prev=9,ze.next=12,xt.getCameras();case 12:D=ze.sent,y=D&&D.length,ze.next=18;break;case 16:ze.prev=16,ze.t1=ze.catch(9);case 18:j={microphone:h,camera:y},K=this.checkSystemResult_.detail,J=K.isH264EncodeSupported,se=K.isVp8EncodeSupported,ie=K.isH264DecodeSupported,Je=K.isVp8DecodeSupported,Ue={webRTC:this.basis_.isWebRTCSupported,getUserMedia:this.basis_.isGetUserMediaSupported,webSocket:this.basis_.isWebSocketsSupported,screenShare:this.basis_.isScreenShareSupported,webAudio:this.basis_.isWebAudioSupported,h264Encode:J,h264Decode:ie,vp8Encode:se,vp8Decode:Je},Fe={browser:this.basis_.browser,os:this.basis_.os,trtc:Ue,devices:j},ht={isWebCodecSupported:this.basis_.isWebCodecSupported,isMediaSessionSupported:this.basis_.isMediaSessionSupported,isWebTransportSupported:this.basis_.isWebTransportSupported},ke.uploadEvent({log:"trtcstats-"+JSON.stringify(Fe),userId:this.userId_}),this.log_.info("TrtcStats-"+JSON.stringify(Fe)),ke.uploadEvent({log:"trtcadvancedstats-"+JSON.stringify(ht),userId:this.userId_});case 26:case"end":return ze.stop()}},k,this,[[0,7],[9,16]])})),function(){return b.apply(this,arguments)})},{key:"doJoin",value:function(k){var h=this;return new Promise(function(y,A){h.log_.info("Join() => joining room: ".concat(h.roomId_," useStringRoomId: ").concat(h.useStringRoomId_," mode: ").concat(h.mode_," role: ").concat(h.role_));var D={roomId:String(h.roomId_),useStringRoomId:h.useStringRoomId_,privateMapKey:h.privateMapKey_,trtcRole:h.role_===Tr?so:Vf,trtcScene:h.mode_===zu?XM:KM,sdpSemantics:h.sdpSemantics_,version:P4(h.version_),ua:navigator&&navigator.userAgent||"",autoSubscribe:h.autoSubscribe_,terminalType:ta?4:op?2:ap?3:ec?12:AS?5:PS?13:1,netType:qf[Tp()],bussinessInfo:h.bussinessInfo_,receiveMix:!0};if(h.publishCDNManager_){var j=h.publishCDNManager_.handleCDNConfigForJoinData(h.bussinessInfo_),K=j.bussinessInfo,J=j.pushUserCdnInfo;Object.assign(D,{bussinessInfo:K,pushUserCdnInfo:J})}h.log_.debug("join room signal data: ".concat(JSON.stringify(D))),h.joinTimeout_=setTimeout(function(){A(new te({code:Z.JOIN_ROOM_FAILED,message:ae({key:BN})}))},5e3),Y.emit(Ep,{client:h}),h.signalChannel_.once(mk,function(se){h.clearJoinTimeout(),Y.emit(ll,{client:h,error:se}),A(se)}),h.signalChannel_.send(IU,D),h.signalChannel_.once(st.JOIN_ROOM_RESULT,function(se){h.clearJoinTimeout();var ie=se.data,Je=ie.code,Ue=ie.message,Fe=ie.data;h.onPublishedUserList({data:{userList:Fe.publishers}}),Y.emit(Rp,{client:h,code:Je}),Je===0?(h.isJoined_=!0,h.log_.info("Join room success, start heartbeat"),h.startHeartbeat(),h.badCaseDetector_&&h.badCaseDetector_.start(),h.syncUserList(),h.startSyncUserListInterval(),y()):(h.log_.error("Join room failed result: "+Je+" error: "+Ue),A(new te({code:Z.JOIN_ROOM_FAILED,extraCode:Je,message:ae({key:uS,data:{error:Ue,code:Je}})})))})})}},{key:"reJoin",value:(_=H(p().mark(function k(){return p().wrap(function(h){for(;;)switch(h.prev=h.next){case 0:if(this.isJoined_){h.next=3;break}return this.log_.warn("reJoin abort"),h.abrupt("return");case 3:return this.isJoined_=!1,h.prev=4,this.log_.warn("reJoin pending: ".concat(this.joinOptions_.roomId)),this.subscriptionManager_&&this.subscriptionManager_.markAllStream(),this.signalChannel_.close(),h.next=10,this.signalChannel_.connect();case 10:return h.next=12,this.doJoin(q(q({},this.joinOptions_),{},{role:this.role_,privateMapKey:this.privateMapKey_}));case 12:this.log_.warn("reJoin success"),ke.logSuccessEvent({userId:this.userId_,eventType:xb}),this.checkConnectionsToReconnect(),this.uplinkConnection_&&!this.uplinkConnection_.getIsReconnecting()&&this.uplinkConnection_.startReconnection(),this.mixTranscodeManager_&&this.mixTranscodeManager_.reStartMixTranscode(),h.next=25;break;case 19:h.prev=19,h.t0=h.catch(4),this.log_.warn("reJoin fail "+h.t0),this.reset(),ke.logFailedEvent({userId:this.userId_,eventType:xb,error:h.t0}),this.emitter_.emit(ct.ERROR,new te({code:Z.JOIN_ROOM_FAILED,message:ae({key:FN,data:{roomId:this.joinOptions_.roomId}})}));case 25:case"end":return h.stop()}},k,this,[[4,19]])})),function(){return _.apply(this,arguments)})},{key:"leave",value:(V=H(p().mark(function k(){var h;return p().wrap(function(y){for(;;)switch(y.prev=y.next){case 0:return Y.emit(Ap,{client:this}),vn(this.userId_,{eventId:aV,eventDesc:"leaving room",timestamp:an(),userId:this.userId_,tinyId:this.tinyId_}),y.prev=2,y.next=5,this.doHeartbeat();case 5:y.next=9;break;case 7:y.prev=7,y.t0=y.catch(2);case 9:this.doLeave(),Y.emit(mo,{client:this}),ke.logSuccessEvent({userId:this.userId_,eventType:tN}),h=Math.floor((Ct()-this.joinedTimestamp_)/1e3),ke.logSuccessEvent({userId:this.userId_,eventType:nN,delta:h});case 14:case"end":return y.stop()}},k,this,[[2,7]])})),function(){return V.apply(this,arguments)})},{key:"doLeave",value:function(){this.isJoined_&&(Y.emit(Pp,{client:this}),this.log_.info("leave() => leaving room"),this.signalChannel_.send(wU),this.reset())}},{key:"clearNetworkQuality",value:function(){this.networkQuality_&&(this.networkQuality_.stop(),this.networkQuality_=null)}},{key:"closeConnections",value:function(){var k=this;this.connections_.forEach(function(h){k.closeDownLink(h.getTinyId())})}},{key:"clearJoinTimeout",value:function(){clearTimeout(this.joinTimeout_),this.joinTimeout_=-1}},{key:"destroy",value:function(){var k,h,y;if(this.isJoined_)throw this.log_.warn(vi.INVALID_DESTROY),new te({code:Z.INVALID_OPERATION,message:ae({key:HN})});this.isDestroyed_||(this.log_.info("destroy client"),this.joinReject_&&(this.joinReject_(new te({code:Z.INVALID_OPERATION,message:ae({key:tp,data:{funName:"join"}})})),this.clearJoinTimeout(),this.reset()),this.off("*"),(k=this.callDurationCalculator_)===null||k===void 0||k.destroy(),(h=this.keyPointManager_)===null||h===void 0||h.destroy(),(y=this.deviceDetector_)===null||y===void 0||y.destroy(),this.callDurationCalculator_=null,this.keyPointManager_=null,this.deviceDetector_=null,this.badCaseDetector_=null,this.publishCDNManager_=null,this.isDestroyed_=!0,Y.emit(Up,{client:this}))}},{key:"reset",value:function(){this.isJoined_=!1,this.schedule_={domains:null,iceServers:null,iceTransportPolicy:null,trtcCapability:null},this.keyPointManager_&&this.keyPointManager_.prepareReport(),this.mixTranscodeManager_&&(this.mixTranscodeManager_.reset(),this.mixTranscodeManager_=null),this.publishCDNManager_&&this.publishCDNManager_.reset(),this.userMap_.clear(),this.stopSyncUserListInterval(),this.stopHeartbeat(),this.closeConnections(),this.mutedStates_.clear(),this.clearNetworkQuality(),this.badCaseDetector_&&this.callDurationCalculator_&&this.uploadAllCallStats(),this.closeUplink(),this.signalChannel_&&(this.log_.info("destroying SignalChannel"),this.signalChannel_.close(),this.signalChannel_=null),this.stats_.reset()}},{key:"startSyncUserListInterval",value:function(){this.syncUserListInterval_===-1&&(this.syncUserListInterval_=mt.run(uo,this.syncUserList.bind(this)))}},{key:"stopSyncUserListInterval",value:function(){mt.clearTask(this.syncUserListInterval_),this.syncUserListInterval_=-1}},{key:"syncUserList",value:(N=H(p().mark(function k(){var h,y=this;return p().wrap(function(A){for(;;)switch(A.prev=A.next){case 0:return A.prev=0,A.next=3,this.getUserList();case 3:h=A.sent,this.userMap_.size!==0&&this.userMap_.forEach(function(D){h.findIndex(function(j){return j.userId===D.userId})<0&&(y.log_.info("peer leave detected: ".concat(D.userId)),y.cleanUser({userId:D.userId,tinyId:D.tinyId}))}),h.forEach(function(D){var j=D.userId;y.userMap_.has(j)||j===y.userId_||(y.userMap_.set(j,D),y.emitter_.emit(ct.PEER_JOIN,{userId:j}))}),A.next=11;break;case 8:A.prev=8,A.t0=A.catch(0),this.log_.warn("sync user list failed: "+A.t0);case 11:case"end":return A.stop()}},k,this,[[0,8]])})),function(){return N.apply(this,arguments)})},{key:"getUserList",value:function(){return this.signalChannel_?this.signalChannel_.sendWaitForResponse({command:jU,responseCommand:st.USER_LIST_RES,enableLog:!1,timeout:2e3}).then(function(k){var h=k.data,y=h.code,A=h.message;if(y===0)return(h.data&&h.data.userList||[]).map(function(D){var j=D.userId,K=D.srcTinyId,J=D.role;return new Yv({userId:j,tinyId:K,role:J})});throw ae({key:yS,data:{signalResponse:st.USER_LIST_RES,code:y,message:A}})}):[]}},{key:"publish",value:(L=H(p().mark(function k(h){var y,A,D,j,K,J,se,ie,Je=this,Ue=arguments;return p().wrap(function(Fe){for(;;)switch(Fe.prev=Fe.next){case 0:return y=Ue.length>1&&Ue[1]!==void 0?Ue[1]:{isAuxiliary:!1},h.setPublishState($s),this.isPublishing_=!0,A=Ct(),Y.emit(Lp,{client:this,stream:h}),D=y.isAuxiliary,j=D?gt:Qe,K=h.getScreen(),this.log_.info("publish() => publishing ".concat(K?Of+" ":"").concat(j," stream ").concat(h.getId())),J=this.uplinkConnection_,Fe.prev=10,J||((J=new OF({userId:this.userId_,tinyId:this.tinyId_,client:this,isUplink:!0,signalChannel:this.signalChannel_,enableSEI:this.enableSEI_})).initialize(),J.on(et.ERROR,function(ht){var ze=ht.getCode();ze!==Z.ICE_TRANSPORT_ERROR&&(ze===Z.UPLINK_RECONNECTION_FAILED&&Je.closeUplink(),Je.emitter_.emit(ct.ERROR,ht))})),h.setConnection(J),Fe.next=15,J.publish(h,D);case 15:this.log_.info("local ".concat(K?Of+" ":"").concat(j," stream is published")),this.isPublishing_=!1,D?this.localAuxStream_=h:(this.localStream_=h,this.deviceDetector_&&this.deviceDetector_.setLocalStream(this.localStream_),this.localStream_.getBeautyStatus()&&this.log_.info("beauty stream is published successfully")),h.setPublishState(iN),h.setClient(this,D),this.uplinkConnection_=J,se=Ct(),ie=se-A,ke.logSuccessEvent({userId:this.userId_,eventType:Ib}),ke.logSuccessEvent({userId:this.userId_,eventType:rN,delta:ie}),h.hasAudio()&&vn(this.userId_,{eventId:yk,eventDesc:"publish audio track",timestamp:an(),userId:this.userId_,tinyId:this.tinyId_}),h.hasVideo()&&vn(this.userId_,{eventId:_k,eventDesc:"publish video track",timestamp:an(),userId:this.userId_,tinyId:this.tinyId_}),this.networkQuality_&&this.networkQuality_.setUplinkConnection(this.uplinkConnection_),Y.emit(N4,{localStream:h,isAuxiliary:D,client:this}),this.notPublishWithoutH264Supported_=!1,h.isAIDenoiser&&Ri.handleFunctionState({fnName:"AI_DENOISER"}),Fe.next=42;break;case 33:throw Fe.prev=33,Fe.t0=Fe.catch(10),Fe.t0 instanceof te&&Fe.t0.getCode()===Z.NOT_SUPPORTED_H264&&(this.notPublishWithoutH264Supported_=!0),h.setPublishState(Wb),J.close(),this.log_.error("failed to publish stream "+Fe.t0),this.isPublishing_=!1,ke.logFailedEvent({userId:this.userId_,eventType:Ib,error:Fe.t0}),Fe.t0;case 42:case"end":return Fe.stop()}},k,this,[[10,33]])})),function(k){return L.apply(this,arguments)})},{key:"unpublish",value:(w=H(p().mark(function k(h){var y,A;return p().wrap(function(D){for(;;)switch(D.prev=D.next){case 0:if(this.uplinkConnection_){D.next=2;break}return D.abrupt("return");case 2:return y=h===this.localAuxStream_,A=h.getScreen(),this.log_.info("unpublish() => unpublishing local ".concat(A?Of+" ":"").concat(y?gt:Qe," stream")),D.prev=5,D.next=8,this.uplinkConnection_.unpublish(h);case 8:ke.logSuccessEvent({userId:this.userId_,eventType:wb}),D.next=15;break;case 11:D.prev=11,D.t0=D.catch(5),this.log_.warn("unpublish error ".concat(D.t0)),ke.logFailedEvent({userId:this.userId_,eventType:wb,error:D.t0});case 15:h.setClient(null),h.setConnection(null),y?this.localAuxStream_=null:(this.localStream_=null,h.hasAudio()&&vn(this.userId_,{eventId:Sk,eventDesc:"unpublish audio track",timestamp:an(),userId:this.userId_,tinyId:this.tinyId_}),h.hasVideo()&&vn(this.userId_,{eventId:bk,eventDesc:"unpublish video track",timestamp:an(),userId:this.userId_,tinyId:this.tinyId_})),this.localStream_||this.localAuxStream_||this.closeUplink();case 19:case"end":return D.stop()}},k,this,[[5,11]])})),function(k){return w.apply(this,arguments)})},{key:"closeUplink",value:function(){this.uplinkConnection_&&(this.uplinkConnection_.close(),this.uplinkConnection_=null,this.networkQuality_&&this.networkQuality_.setUplinkConnection(null),this.localStream_&&(this.localStream_.setClient(null),this.localStream_.setConnection(null),this.localStream_=null),this.localAuxStream_&&(this.localAuxStream_.setClient(null),this.localAuxStream_.setConnection(null),this.localAuxStream_=null),this.deviceDetector_&&this.deviceDetector_.setLocalStream(null))}},{key:"closeDownLink",value:function(k){var h=this.connections_.get(k);h&&(h.getIsReconnecting()&&h.stopReconnection(),this.subscriptionManager_&&this.subscriptionManager_.delete(h.getUserId()),h.close(),this.connections_.delete(k),this.mutedStates_.delete(k))}},{key:"subscribe",value:(v=H(p().mark(function k(h,y){var A,D,j;return p().wrap(function(K){for(;;)switch(K.prev=K.next){case 0:return this.log_.info("subscribe() => subscribe to [".concat(h.getUserId(),"] ").concat(h.getType()," stream with options: ").concat(JSON.stringify(y))),ge(y)&&(y={audio:!0,video:!0}),ge(y.audio)&&(y.audio=!0),ge(y.smallVideo)?ge(y.video)&&(y.video=!0):y.smallVideo?ge(y.video)?(y.video=!1,y.smallVideo=!0):y.video&&(y.video=!0,delete y.smallVideo,this.log_.warn("options.video and options.smallVideo can't be both true")):ge(y.video)&&(y.video=!0,delete y.smallVideo),y.video&&this.changeBigSmallRecords_.delete(h.getUserId()),A=h.getConnection(),y.smallVideo&&(A.getTrackState().smallVideo||(this.setRemoteVideoStreamType(h,"small"),y.video=!0,delete y.smallVideo)),K.prev=7,Y.emit(jp,{client:this,stream:h}),K.next=11,A.subscribe(h,y);case 11:this.subscriptionManager_&&this.subscriptionManager_.addSubscriptionRecord(h.getUserId(),h,y),this.notSubscribeWithoutH264Supported_=!1,ke.logSuccessEvent({userId:this.userId_,eventType:Cb}),A.checkTrackEnded(),K.next=25;break;case 17:throw K.prev=17,K.t0=K.catch(7),(D=K.t0 instanceof te?K.t0.getCode():Z.UNKNOWN)===Z.NOT_SUPPORTED_H264&&(this.notSubscribeWithoutH264Supported_=!0),(j=new te(D===Z.REMOTE_STREAM_NOT_EXIST?{code:Z.API_CALL_ABORTED,message:ae({key:ip,data:{message:K.t0.message,stream:h}})}:{code:D,message:ae({key:KN,data:{message:K.t0.message,stream:h}})})).getCode()===Z.API_CALL_ABORTED?this.log_.warn(j):this.log_.error(j),ke.logFailedEvent({userId:this.userId_,eventType:Cb,error:j}),j;case 25:case"end":return K.stop()}},k,this,[[7,17]])})),function(k,h){return v.apply(this,arguments)})},{key:"unsubscribe",value:(T=H(p().mark(function k(h){var y;return p().wrap(function(A){for(;;)switch(A.prev=A.next){case 0:return this.log_.info("unsubscribe() => unsubscribe to [".concat(h.getUserId(),"] ").concat(h.getType()," stream")),A.prev=1,y=h.getConnection(),A.next=5,y.unsubscribe(h);case 5:this.subscriptionManager_&&this.subscriptionManager_.addUnsubscriptionRecord(h.getUserId(),h),Y.emit(Vr,{client:this,stream:h}),ke.logSuccessEvent({userId:this.userId_,eventType:Eb}),A.next=14;break;case 10:throw A.prev=10,A.t0=A.catch(1),ke.logFailedEvent({userId:this.userId_,eventType:Eb,error:A.t0}),A.t0;case 14:case"end":return A.stop()}},k,this,[[1,10]])})),function(k){return T.apply(this,arguments)})},{key:"switchRole",value:(m=H(p().mark(function k(h){return p().wrap(function(y){for(;;)switch(y.prev=y.next){case 0:if(this.role_!==h){y.next=2;break}return y.abrupt("return");case 2:return h===Zi&&this.uplinkConnection_&&this.closeUplink(),this.log_.info("switchRole() => switch role to: "+h),y.next=6,this.doSwitchRole(h);case 6:case"end":return y.stop()}},k,this)})),function(k){return m.apply(this,arguments)})},{key:"doSwitchRole",value:function(k){var h,y,A=this,D={command:BU,data:{role:k===Tr?so:Vf,privateMapKey:this.privateMapKey_},responseCommand:st.SWITCH_ROLE_RES,retries:((h=this.schedule_.config)===null||h===void 0||(y=h.retries)===null||y===void 0?void 0:y.switchRole)||1};return this.log_.info("switchRole signal data: "+JSON.stringify(D.data)),this.signalChannel_.sendWaitForResponseWithRetry(D).then(function(j){var K=j.data,J=K.code,se=K.message;if(J!==0)throw new te({code:Z.SWITCH_ROLE_FAILED,message:ae({key:$N,data:{errMsg:se,errCode:J}})});A.role_=k}).catch(function(j){throw j instanceof te&&j.getCode()===Z.API_CALL_TIMEOUT&&(j=new te({code:Z.SWITCH_ROLE_FAILED,message:ae({key:YN})})),A.log_.error(j),j})}},{key:"on",value:function(k,h,y){this.emitter_.on(k,h,y)}},{key:"off",value:function(k,h,y){k==="*"?this.emitter_.removeAllListeners():this.emitter_.off(k,h,y)}},{key:"getRemoteMutedState",value:function(){var k=this,h=[];return this.mutedStates_.forEach(function(y,A,D){var j=k.connections_.get(A);j&&h.push(q({userId:j.getUserId()},y))}),h}},{key:"getTransportStats",value:(I=H(p().mark(function k(){var h,y,A,D,j,K,J;return p().wrap(function(se){for(;;)switch(se.prev=se.next){case 0:if(h={rtt:0,downlinksRTT:{}},!this.uplinkConnection_){se.next=6;break}return se.next=4,this.stats_.getSenderStats(this.uplinkConnection_);case 4:y=se.sent,h.rtt=y.rtt;case 6:A=oe(this.connections_),se.prev=7,A.s();case 9:if((D=A.n()).done){se.next=17;break}return(j=Te(D.value,2))[0],K=j[1],se.next=13,this.stats_.getReceiverStats(K);case 13:J=se.sent,h.downlinksRTT[J.userId]=J.rtt;case 15:se.next=9;break;case 17:se.next=22;break;case 19:se.prev=19,se.t0=se.catch(7),A.e(se.t0);case 22:return se.prev=22,A.f(),se.finish(22);case 25:return se.abrupt("return",h);case 26:case"end":return se.stop()}},k,this,[[7,19,22,25]])})),function(){return I.apply(this,arguments)})},{key:"getLocalAudioStats",value:(E=H(p().mark(function k(){var h,y;return p().wrap(function(A){for(;;)switch(A.prev=A.next){case 0:if((h={})[this.userId_]={bytesSent:0,packetsSent:0},!this.uplinkConnection_){A.next=7;break}return A.next=5,this.stats_.getSenderStats(this.uplinkConnection_);case 5:y=A.sent,h[this.userId_]={bytesSent:y.audio.bytesSent,packetsSent:y.audio.packetsSent};case 7:return A.abrupt("return",h);case 8:case"end":return A.stop()}},k,this)})),function(){return E.apply(this,arguments)})},{key:"getLocalVideoStats",value:(x=H(p().mark(function k(){var h,y;return p().wrap(function(A){for(;;)switch(A.prev=A.next){case 0:if((h={})[this.userId_]={bytesSent:0,packetsSent:0,framesEncoded:0,framesSent:0,frameWidth:0,frameHeight:0},!this.uplinkConnection_){A.next=7;break}return A.next=5,this.stats_.getSenderStats(this.uplinkConnection_);case 5:y=A.sent,h[this.userId_]={bytesSent:y.video.bytesSent,packetsSent:y.video.packetsSent,framesEncoded:y.video.framesEncoded,framesSent:y.video.framesSent,frameWidth:y.video.frameWidth,frameHeight:y.video.frameHeight};case 7:return A.abrupt("return",h);case 8:case"end":return A.stop()}},k,this)})),function(){return x.apply(this,arguments)})},{key:"getRemoteAudioStats",value:(S=H(p().mark(function k(){var h,y,A,D,j,K,J,se;return p().wrap(function(ie){for(;;)switch(ie.prev=ie.next){case 0:h={},y=oe(this.connections_),ie.prev=2,y.s();case 4:if((A=y.n()).done){ie.next=13;break}return(D=Te(A.value,2))[0],j=D[1],K=j.getDelay(),J=K.audioDelay,ie.next=9,this.stats_.getReceiverStats(j);case 9:(se=ie.sent).hasAudio&&(h[se.userId]={bytesReceived:se.audio.bytesReceived,packetsReceived:se.audio.packetsReceived,packetsLost:se.audio.packetsLost,end2EndDelay:J});case 11:ie.next=4;break;case 13:ie.next=18;break;case 15:ie.prev=15,ie.t0=ie.catch(2),y.e(ie.t0);case 18:return ie.prev=18,y.f(),ie.finish(18);case 21:return ie.abrupt("return",h);case 22:case"end":return ie.stop()}},k,this,[[2,15,18,21]])})),function(){return S.apply(this,arguments)})},{key:"getRemoteVideoStats",value:(f=H(p().mark(function k(){var h,y,A,D,j,K,J,se,ie,Je=arguments;return p().wrap(function(Ue){for(;;)switch(Ue.prev=Ue.next){case 0:h=Je.length>0&&Je[0]!==void 0?Je[0]:yt,y={},A=oe(this.connections_),Ue.prev=3,A.s();case 5:if((D=A.n()).done){Ue.next=15;break}return(j=Te(D.value,2))[0],K=j[1],Ue.next=9,this.stats_.getReceiverStats(K);case 9:J=Ue.sent,se=K.getDelay(),ie=se.videoDelay,h===yt&&J.hasVideo&&(y[J.userId]={bytesReceived:J.video.bytesReceived,packetsReceived:J.video.packetsReceived,packetsLost:J.video.packetsLost,framesDecoded:J.video.framesDecoded,frameWidth:J.video.frameWidth,frameHeight:J.video.frameHeight,end2EndDelay:ie}),h===Dt&&J.hasAuxiliary&&(y[J.userId]={bytesReceived:J.auxiliary.bytesReceived,packetsReceived:J.auxiliary.packetsReceived,packetsLost:J.auxiliary.packetsLost,framesDecoded:J.auxiliary.framesDecoded,frameWidth:J.auxiliary.frameWidth,frameHeight:J.auxiliary.frameHeight,end2EndDelay:ie});case 13:Ue.next=5;break;case 15:Ue.next=20;break;case 17:Ue.prev=17,Ue.t0=Ue.catch(3),A.e(Ue.t0);case 20:return Ue.prev=20,A.f(),Ue.finish(20);case 23:return Ue.abrupt("return",y);case 24:case"end":return Ue.stop()}},k,this,[[3,17,20,23]])})),function(){return f.apply(this,arguments)})},{key:"getSdpSemantics",value:function(){return this.sdpSemantics_}},{key:"getIceServers",value:function(){return this.turnServers_.length===0&&this.schedule_.iceServers?this.schedule_.iceServers:this.turnServers_}},{key:"getConnections",value:function(){return this.connections_}},{key:"getMutedStates",value:function(){return this.mutedStates_}},{key:"startHeartbeat",value:function(){this.heartbeat_===-1&&(this.log_.info("startHeartbeat..."),this.heartbeat_=mt.run(uo,this.doHeartbeat.bind(this),{delay:2e3}))}},{key:"stopHeartbeat",value:function(){this.heartbeat_!==-1&&(this.log_.info("stopHeartbeat"),mt.clearTask(this.heartbeat_),this.heartbeat_=-1,this.lastHeartBeatTime_=-1)}},{key:"doHeartbeat",value:(u=H(p().mark(function k(){var h,y,A,D,j,K;return p().wrap(function(J){for(;;)switch(J.prev=J.next){case 0:return y=this.badCaseDetector_.getMonitorFreeze(),J.next=3,this.stats_.getStatsReport({uplinkConnection:this.uplinkConnection_,downlinkConnections:this.connections_,freezeMap:y});case 3:if(A=J.sent,Y.emit(Dp,{client:this,stats:A}),(h=this.badCaseDetector_)===null||h===void 0||h.resetMonitor(),this.signalChannel_){J.next=8;break}return J.abrupt("return");case 8:D=this.signalChannel_.isConnected()?SV(this.userId_):[],j=q(q({str_sdk_version:this.version_,uint64_datetime:new Date().getTime(),msg_user_info:{str_identifier:this.userId_,uint64_tinyid:this.tinyId_},msg_device_info:{uint32_terminal_type:15,str_device_name:navigator.platform,str_os_version:"",uint32_net_type:qf[this.networkType_]}},A),{},{msg_event_msg:D}),this.signalChannel_.send(CU,j),K=Date.now(),this.lastHeartBeatTime_>0&&K-this.lastHeartBeatTime_>1e4&&this.log_.warn("heartbeat took ".concat(K-this.lastHeartBeatTime_)),this.lastHeartBeatTime_=K,!this.isRelayChanged_&&this.isRelayMaybeFailed()&&(this.reJoin(),this.isRelayChanged_=!0);case 15:case"end":return J.stop()}},k,this)})),function(){return u.apply(this,arguments)})},{key:"onRemoteStreamAdded",value:function(k){var h=k.content,y=h.userId,A=h.tinyId,D=h.audio,j=h.bigVideo,K=h.auxVideo,J=h.smallVideo;if(y!==null){this.userMap_.has(y)||(this.userMap_.set(y,new Yv({userId:y,tinyId:A,role:Tr})),this.emitter_.emit(ct.PEER_JOIN,{userId:y}));var se=this.connections_.get(A);if(se){if(se.getIsReconnecting())return;this.log_.warn("duplicated stream-added observed, rebuild the connection"),se.close(),this.connections_.delete(A)}var ie={audio:D,video:j,auxiliary:K,smallVideo:J};this.log_.info("remote peer [".concat(y,"] published stream. trackState: ").concat(JSON.stringify(ie))),this.createDownlinkConnection({userId:y,tinyId:A,trackState:ie})}else this.log_.warn("received null userId on stream added")}},{key:"createDownlinkConnection",value:function(k){var h=this,y=k.userId,A=k.tinyId,D=k.trackState,j=new n7({userId:y,tinyId:A,client:this,isUplink:!1,signalChannel:this.signalChannel_,autoSubscribe:this.autoSubscribe_,trackState:D,enableSEI:this.enableSEI_});this.connections_.set(A,j),this.installDownlinkEvents(j,y,A),this.autoSubscribe_?(j.initialize(),j.connect().catch(function(){!j.getMainStream()&&j.hasMainStream()&&h.initRemoteStream({type:yt,userId:y,downlinkConnection:j}),!j.getAuxStream()&&j.hasAuxStream()&&h.initRemoteStream({type:Dt,userId:y,downlinkConnection:j})})):(j.hasMainStream()&&this.initRemoteStream({type:yt,userId:y,downlinkConnection:j}),j.hasAuxStream()&&this.initRemoteStream({type:Dt,userId:y,downlinkConnection:j}))}},{key:"initRemoteStream",value:function(k){var h=k.type,y=k.userId,A=k.downlinkConnection,D=new Gv({type:h,userId:y,client:this});D.setConnection(A),A.setRemoteStream(h===yt?xr:Xs,D),D.setIsStreamAddedEventEmitted(!0),Y.emit(dl,{client:this,stream:D}),this.emitter_.emit(ct.STREAM_ADDED,{stream:D})}},{key:"installDownlinkEvents",value:function(k,h,y){var A=this;k.on(et.SEI_MESSAGE,function(D){A.emitter_.emit(ct.SEI_MESSAGE,D)}),k.on(et.STREAM_ADDED,function(D){D.stream.setIsStreamAddedEventEmitted(!0),Y.emit(dl,{client:A,stream:D.stream}),A.emitter_.emit(ct.STREAM_ADDED,{stream:D.stream})}),k.on(et.STREAM_REMOVED,function(D){A.changeBigSmallRecords_.delete(D.stream.getUserId()),D.stream.stop(),D.stream.setIsStreamAddedEventEmitted(!1),A.subscriptionManager_&&A.subscriptionManager_.deleteAutoRecoveryFlag(D.stream.getUserId(),D.stream.getType()),Y.emit(ca,{client:A,stream:D.stream}),A.emitter_.emit(ct.STREAM_REMOVED,{stream:D.stream})}),k.on(et.STREAM_UPDATED,function(D){Y.emit(M4,{client:A,stream:D.stream});var j=k.getMixUserList();j&&(D.mixUserList=j),A.emitter_.emit(ct.STREAM_UPDATED,D)}),k.on(et.STREAM_SUBSCRIBED,function(D){Y.emit(Ur,{client:A,stream:D.stream}),A.emitter_.emit(ct.STREAM_SUBSCRIBED,{stream:D.stream})}),k.on(et.ERROR,function(D){var j=D.getCode();j!==Z.ICE_TRANSPORT_ERROR&&(j===Z.DOWNLINK_RECONNECTION_FAILED&&A.closeDownLink(y),A.emitter_.emit(ct.ERROR,D))})}},{key:"onPeerJoin",value:function(k){var h=k.data.data,y=h.srcTinyId,A=h.userId,D=h.role;this.userMap_.has(A)||(this.userMap_.set(A,new Yv({userId:A,tinyId:y,role:D})),this.emitter_.emit(ct.PEER_JOIN,{userId:A}))}},{key:"onPeerLeave",value:function(k){var h=k.data.data,y=h.srcTinyId,A=h.userId,D=h.reason,j=D===void 0?0:D;this.log_.info("peer leave [".concat(A,"]: ").concat(hN[j])),this.cleanUser({userId:A,tinyId:y})}},{key:"cleanUser",value:function(k){var h=k.userId,y=k.tinyId;this.userMap_.delete(h),this.closeDownLink(y),this.emitter_.emit(ct.PEER_LEAVE,{userId:h})}},{key:"onPublishedUserList",value:function(k){var h=this;try{var y=Se(k.data.userList);k.data.mixRobotList&&y.push.apply(y,Se(k.data.mixRobotList)),k.data.fakeMixUser&&y.push(k.data.fakeMixUser);var A=y.map(function(D){return D.userId});this.connections_.forEach(function(D){var j=D.getUserId(),K=D.getTinyId();A.findIndex(function(J){return J===j})<0&&(h.log_.info("peer unpublished detected [".concat(j,"]")),h.closeDownLink(K))}),y.forEach(function(D){var j=D.userId,K=D.srcTinyId,J=D.flag,se=D.mixUserList;if(j!==h.userId_){var ie=!!(1&J),Je=!!(8&J),Ue=!!(4&J),Fe=!!(2&J),ht=h.connections_.get(K);if((Fe||ie)&&h.checkSubscribeBigSmallVideo(ht,Fe),ht){var ze=ht.getTrackState(),Cc=ze.audio,hd=ze.video,Ec=ze.auxiliary,QI=ze.smallVideo;ho(se)&&ht.setMixUserList(se),!hd&&ie&&Y.emit(jn,{client:h,tinyId:K,userId:j,action:cn.ADD,kind:xe}),!Cc&&Je&&Y.emit(jn,{client:h,tinyId:K,userId:j,action:cn.ADD,kind:Ee}),!Ec&&Ue&&Y.emit(jn,{client:h,tinyId:K,userId:j,action:cn.ADD,kind:gt}),!QI&&Fe&&Y.emit(jn,{client:h,tinyId:K,userId:j,action:cn.ADD,kind:Fu}),hd&&!ie&&Y.emit(jn,{client:h,tinyId:K,userId:j,action:cn.REMOVE,kind:xe}),Cc&&!Je&&Y.emit(jn,{client:h,tinyId:K,userId:j,action:cn.REMOVE,kind:Ee}),Ec&&!Ue&&Y.emit(jn,{client:h,tinyId:K,userId:j,action:cn.REMOVE,kind:gt}),QI&&!Fe&&Y.emit(jn,{client:h,tinyId:K,userId:j,action:cn.REMOVE,kind:Fu})}else h.log_.info("peer published detected [".concat(j,"]")),h.onRemoteStreamAdded({content:{audio:Je,bigVideo:ie,auxVideo:Ue,smallVideo:Fe,userId:j,tinyId:K}})}})}catch(D){}}},{key:"onUpdateRemoteMuteStat",value:function(k){var h=this,y=k.data;(y&&y.userList||[]).forEach(function(A){var D=A.srcTinyId,j=A.userId;if(D!==0&&D!==h.tinyId_){var K=h.connections_.get(D);if(K){var J=K.getMainStream();if(J&&J.getIsStreamAddedEventEmitted()){var se=!!(1&A.flag),ie=!!(8&A.flag),Je=!!(2&A.flag),Ue=!!(64&A.flag),Fe=!!(16&A.flag),ht=h.mutedStates_.get(D);if(ht===void 0)return h.mutedStates_.set(D,{hasAudio:ie,hasVideo:se,hasSmall:Je,audioMuted:Ue,videoMuted:Fe}),se?Fe?h.emitter_.emit(ct.MUTE_VIDEO,{userId:j}):h.emitter_.emit(ct.UNMUTE_VIDEO,{userId:j}):h.emitter_.emit(ct.MUTE_VIDEO,{userId:j}),void(ie?Ue?h.emitter_.emit(ct.MUTE_AUDIO,{userId:j}):h.emitter_.emit(ct.UNMUTE_AUDIO,{userId:j}):h.emitter_.emit(ct.MUTE_AUDIO,{userId:j}));var ze=!ht.audioMuted&&ht.hasAudio,Cc=!Ue&&ie,hd=!ht.videoMuted&&ht.hasVideo,Ec=!Fe&&se;h.mutedStates_.set(D,{hasAudio:ie,hasVideo:se,hasSmall:Je,audioMuted:Ue,videoMuted:Fe}),ze!==Cc&&(Cc?h.emitter_.emit(ct.UNMUTE_AUDIO,{userId:j}):h.emitter_.emit(ct.MUTE_AUDIO,{userId:j})),hd!==Ec&&(Ec?h.emitter_.emit(ct.UNMUTE_VIDEO,{userId:j}):h.emitter_.emit(ct.MUTE_VIDEO,{userId:j}))}}else h.mutedStates_.delete(D)}})}},{key:"getEnv",value:function(){return this.env_}},{key:"getSubscriptionManager",value:function(){return this.subscriptionManager_}},{key:"startPublishCDNStream",value:(l=H(p().mark(function k(){var h,y=arguments;return p().wrap(function(A){for(;;)switch(A.prev=A.next){case 0:if(h=y.length>0&&y[0]!==void 0?y[0]:{},this.log_.info("startPublishCDNStream with params: ".concat(JSON.stringify(h),"; isJoined: ").concat(this.isJoined_,"; hasMainStream: ").concat(!!this.localStream_,"; hasAuxStream: ").concat(!!this.localAuxStream_,";")),h.streamType=h.streamType||Qe,h.streamType===gt&&(h.streamType=Nn),h.streamId=h.streamId||"",!this.isJoined_){A.next=10;break}if(h.streamType!==Qe||this.localStream_){A.next=8;break}throw new te({code:Z.INVALID_OPERATION,message:ae({key:lS})});case 8:if(h.streamType!==Nn||this.localAuxStream_){A.next=10;break}throw new te({code:Z.INVALID_OPERATION,message:ae({key:lS})});case 10:return A.next=12,this.publishCDNManager_.startPublishTencentCDN(h);case 12:if(!(h.appId&&h.bizId&&h.url)){A.next=15;break}return A.next=15,this.publishCDNManager_.startPublishGivenCDN(h);case 15:case"end":return A.stop()}},k,this)})),function(){return l.apply(this,arguments)})},{key:"stopPublishCDNStream",value:(s=H(p().mark(function k(){return p().wrap(function(h){for(;;)switch(h.prev=h.next){case 0:if(this.publishCDNManager_.getIsPublishingTencentCDN()){h.next=2;break}throw new te({code:Z.INVALID_OPERATION,message:ae({key:e3})});case 2:return this.log_.info("stopPublishCDNStream"),h.next=5,this.publishCDNManager_.stopPublishTencentCDN();case 5:if(!this.publishCDNManager_.getIsPublishingGivenCDN()){h.next=8;break}return h.next=8,this.publishCDNManager_.stopPublishGivenCDN();case 8:case"end":return h.stop()}},k,this)})),function(){return s.apply(this,arguments)})},{key:"startMixTranscode",value:(a=H(p().mark(function k(h){return p().wrap(function(y){for(;;)switch(y.prev=y.next){case 0:if(this.isJoined_&&this.mixTranscodeManager_){y.next=2;break}throw new te({code:Z.INVALID_OPERATION,message:ae({key:n3})});case 2:return ge(h.mode)&&(h.mode=Jf.MANUAL),y.prev=3,this.log_.info("startMixTranscode with config ".concat(JSON.stringify(h))),ke.uploadEvent({log:"mix-transcode-mode:".concat(h.mode),userId:this.userId_}),y.next=8,this.mixTranscodeManager_.startMixTranscode(h);case 8:ke.logSuccessEvent({userId:this.userId_,eventType:Vb}),y.next=15;break;case 11:throw y.prev=11,y.t0=y.catch(3),ke.logFailedEvent({userId:this.userId_,eventType:Vb,error:y.t0}),y.t0;case 15:case"end":return y.stop()}},k,this,[[3,11]])})),function(k){return a.apply(this,arguments)})},{key:"stopMixTranscode",value:(c=H(p().mark(function k(){return p().wrap(function(h){for(;;)switch(h.prev=h.next){case 0:if(this.isJoined_&&this.mixTranscodeManager_){h.next=2;break}throw new te({code:Z.INVALID_OPERATION,message:ae({key:r3})});case 2:return h.prev=2,h.next=5,this.mixTranscodeManager_.stopMixTranscode();case 5:ke.logSuccessEvent({userId:this.userId_,eventType:jb}),h.next=12;break;case 8:throw h.prev=8,h.t0=h.catch(2),ke.logFailedEvent({userId:this.userId_,eventType:jb,error:h.t0}),h.t0;case 12:case"end":return h.stop()}},k,this,[[2,8]])})),function(){return c.apply(this,arguments)})},{key:"getSystemResult",value:function(){return this.checkSystemResult_}},{key:"enableAudioVolumeEvaluation",value:function(){var k=this,h=arguments.length>0&&arguments[0]!==void 0?arguments[0]:2e3,y=arguments.length>1&&arguments[1]!==void 0&&arguments[1];if(!tr(h))throw new te({code:Z.INVALID_PARAMETER,message:ae({key:i3})});if(this.log_.info("enableAudioVolumeEvaluation with interval: "+h),h<=0)return this.enableAudioVolumeEvaluation_=!1,mt.clearTask(this.audioVolumeIntervalId_),void(this.audioVolumeIntervalId_=null);h=Math.floor(Math.max(h,16)),Y.emit(Np,{interval:h}),this.audioVolumeIntervalId_&&(mt.clearTask(this.audioVolumeIntervalId_),this.audioVolumeIntervalId_=null),this.enableAudioVolumeEvaluation_=!0,this.audioVolumeIntervalId_=mt.run(Qu,function(){var A=[];if(k.localStream_){var D=Math.floor(100*k.localStream_.getAudioLevel());A.push({userId:k.userId_,audioVolume:D,stream:k.localStream_})}k.connections_.forEach(function(j){var K=j.getSubscribedMainStream();if(K){var J=Math.floor(100*K.getAudioLevel());A.push({userId:j.getUserId(),audioVolume:J,stream:K})}}),k.emitter_.emit(ct.AUDIO_VOLUME,{result:A})},{fps:1e3/h,backgroundTask:y})}},{key:"callExperimentalAPI",value:function(k,h){return this.log_.info("callExperimentalAPI(".concat(k,", ").concat(JSON.stringify(h),")")),c7.call(k,q({client:this},h))}},{key:"setProperty",value:function(k,h){var y="".concat(k,"_");ge(this[y])||(this[y]=h)}},{key:"uploadAllCallStats",value:function(){var k=this;this.callDurationCalculator_.getDurationMap().forEach(function(h,y){var A={userId:h.userId,type:h.type,duration:k.callDurationCalculator_.getDuration(y,xe),dataFreeze:k.badCaseDetector_.getDataFreezeDuration(y).dataFreeze,renderFreeze:k.badCaseDetector_.getRenderFreezeDuration(y).renderFreeze};ke.uploadEvent({log:"callStats-"+JSON.stringify(A),userId:k.userId_})}),this.badCaseDetector_.stop(),this.callDurationCalculator_.reset()}},{key:"enableSmallStream",value:(o=H(p().mark(function k(){return p().wrap(function(h){for(;;)switch(h.prev=h.next){case 0:if(!this.isPublished()&&!this.isPublishing_){h.next=2;break}throw new te({code:Z.INVALID_OPERATION,message:ae({key:a3})});case 2:if(!zk()){h.next=7;break}this.setIsEnableSmallStream(!0),this.log_.info("SmallStream successfully enabled"),h.next=8;break;case 7:throw new te({code:Z.INVALID_OPERATION,message:ae({key:s3})});case 8:case"end":return h.stop()}},k,this)})),function(){return o.apply(this,arguments)})},{key:"disableSmallStream",value:(r=H(p().mark(function k(){return p().wrap(function(h){for(;;)switch(h.prev=h.next){case 0:if(!this.isPublished()&&!this.isPublishing_){h.next=2;break}throw new te({code:Z.INVALID_OPERATION,message:ae({key:o3})});case 2:this.setIsEnableSmallStream(!1),this.log_.info("SmallStream successfully disabled");case 4:case"end":return h.stop()}},k,this)})),function(){return r.apply(this,arguments)})},{key:"setSmallStreamProfile",value:function(k){var h=this;k&&k.framerate&&(k.frameRate=k.framerate),k.width*k.height>307200&&(k.width=320,k.height=240,this.log_.info("Small stream resolution is beyond limitation, which is invalid. Reset to 320 * 240")),Object.keys(this.smallStreamConfig_).forEach(function(J){k[J]&&(h.smallStreamConfig_[J]=k[J])});var y=this.smallStreamConfig_,A=y.width,D=y.height,j=y.bitrate,K=y.frameRate;if(this.log_.info("setSmallStreamProfile: bitrate=".concat(j,", frameRate=").concat(K,", height=").concat(D,", width=").concat(A)),A<0||D<0||j<0||K<0)throw new te({code:Z.INVALID_PARAMETER,message:ae({key:c3})})}},{key:"setRemoteVideoStreamType",value:(i=H(p().mark(function k(h,y){return p().wrap(function(A){for(;;)switch(A.prev=A.next){case 0:if(h instanceof Gv){A.next=2;break}throw new te({code:Z.INVALID_PARAMETER,message:ae({key:u3})});case 2:if(h.getConnection()){A.next=4;break}throw new te({code:Z.INVALID_OPERATION,message:ae({key:ep})});case 4:if(h.getType()!==Dt){A.next=6;break}return A.abrupt("return");case 6:A.t0=y,A.next=A.t0===Jb||A.t0===qb?9:12;break;case 9:return A.next=11,this.changeVideoType(h,y);case 11:case 12:return A.abrupt("break",13);case 13:case"end":return A.stop()}},k,this)})),function(k,h){return i.apply(this,arguments)})},{key:"changeVideoType",value:(n=H(p().mark(function k(h,y){var A,D;return p().wrap(function(j){for(;;)switch(j.prev=j.next){case 0:A=h.getUserId(),D={stream:h,options:{video:y===Jb,smallVideo:y===qb},isSubscribing:!1,reSubscribeCount:10},this.changeBigSmallRecords_.set(A,D),this.log_.info("set [".concat(A,"] ").concat(h.getType()," stream video prefer type: ").concat(y));case 5:case"end":return j.stop()}},k,this)})),function(k,h){return n.apply(this,arguments)})},{key:"checkSubscribeBigSmallVideo",value:(t=H(p().mark(function k(h,y){var A,D,j,K,J,se,ie,Je,Ue,Fe,ht;return p().wrap(function(ze){for(;;)switch(ze.prev=ze.next){case 0:if(h!=null&&h.isBigStreamSubscribed||h!=null&&h.isSmallStreamSubscribed){ze.next=2;break}return ze.abrupt("return");case 2:if(A=h.getUserId(),this.changeBigSmallRecords_.has(A)){ze.next=5;break}return ze.abrupt("return");case 5:if(D=this.changeBigSmallRecords_.get(A),j=h.getSubscribeState(),K=j.video,J=j.smallVideo,se=D.stream,ie=D.options,Je=D.isSubscribing,Ue=D.reSubscribeCount,!(ie.video&&K||ie.smallVideo&&J&&y)){ze.next=10;break}return ze.abrupt("return");case 10:if(Fe={video:ie.video,smallVideo:ie.smallVideo},!(y&&h.isBigStreamSubscribed||h.isSmallStreamSubscribed)){ze.next=31;break}if(ze.prev=12,!(ie&&se&&!Je&&Ue>=1)){ze.next=24;break}return D.isSubscribing=!0,D.reSubscribeCount=Ue-1,ht=se.getConnection(),!y&&ht.isSmallStreamSubscribed&&(Fe={video:!0,smallVideo:!1}),Fe.emitEvent=!1,ze.next=21,ht==null?void 0:ht.subscribe(se,Fe);case 21:this.log_.info("change [".concat(A,"] to ").concat(Fe.smallVideo?"small":"big"," video successfully. count ").concat(10-D.reSubscribeCount,".")),D.isSubscribing=!1,D.reSubscribeCount=10;case 24:ze.next=31;break;case 26:ze.prev=26,ze.t0=ze.catch(12),this.log_.info("change [".concat(A,"] to ").concat(Fe.smallVideo?"small":"big"," video failed. count ").concat(10-D.reSubscribeCount,".")),D.isSubscribing=!1,Ue===0&&this.changeBigSmallRecords_.delete(A);case 31:case"end":return ze.stop()}},k,this,[[12,26]])})),function(k,h){return t.apply(this,arguments)})},{key:"setIsEnableSmallStream",value:function(k){this.isEnableSmallStream_=k}},{key:"getIsEnableSmallStream",value:function(){return this.isEnableSmallStream_}},{key:"smallStreamConfig",get:function(){return this.smallStreamConfig_}},{key:"isPublished",value:function(){return!!this.localStream_}},{key:"getUplinkConnection",value:function(){return this.uplinkConnection_}},{key:"getLocalStream",value:function(){return this.localStream_}},{key:"getMode",value:function(){return this.mode_}},{key:"getBadCaseDetector",value:function(){return this.badCaseDetector_}},{key:"getCallDurationCalculator",value:function(){return this.callDurationCalculator_}},{key:"getIsJoined",value:function(){return this.isJoined_}},{key:"getAllConnections",value:function(){var k=Se(this.connections_.values());return this.uplinkConnection_&&k.push(this.uplinkConnection_),k}},{key:"isRelayMaybeFailed",value:function(){if(!this.signalChannel_.isOnline)return!1;var k=this.getAllConnections();if(k.length===0)return!1;for(var h=0;h<k.length;h++)if(k[h].getReconnectionCount()<6)return!1;return!0}},{key:"getUseStringRoomId",value:function(){return this.useStringRoomId_}},{key:"checkConnectionsToReconnect",value:function(){var k=this;this.getAllConnections().forEach(function(h){if(!h.getIsReconnecting()){var y=h.getPeerConnection();y&&y.connectionState===Bf&&(k.log_.warn("[".concat(h.getUserId(),"] pc is closed but not reconnect")),h.startReconnection())}})}},{key:"getEnableAutoPlayDialog",value:function(){return this.enableAutoPlayDialog_}},{key:"sendSEIMessage",value:function(k,h){this.uplinkConnection_.sendSEI(k,h)}},{key:"setProxyServer",value:function(k){if(this.log_.info("set proxy server: ".concat(JSON.stringify(k))),Bt(k)){if(!k.startsWith("wss://"))throw new te({code:Z.INVALID_PARAMETER,message:ae({key:NN})});this.proxy_=k}else if(yi(k)){var h=k.websocketProxy,y=k.loggerProxy,A=k.scheduleProxy,D=k.unifiedProxy;h&&(this.proxy_=h),y&&Uf(y),A&&Xb(A),D&&(this.unifiedProxy_=D,Uf("https://".concat(D)),Xb(D))}}},{key:"setTurnServer",value:function(k){this.log_.info("set turn server: "+JSON.stringify(k));var h=[];Array.isArray(k)?k.forEach(function(y){return h.push(jS(y))}):yi(k)&&h.push(jS(k)),this.turnServers_=h}},{key:"get2k4kFlag",value:function(){var k,h;return((k=this.schedule_)===null||k===void 0||(h=k.trtcCapability)===null||h===void 0?void 0:h["2k4k"])||2}},{key:"getWSProxy",value:function(){return this.proxy_}},{key:"getUnifiedProxy",value:function(){return this.unifiedProxy_}}]),e}(),X(Pe.prototype,"join",[fI,pI,mI],Object.getOwnPropertyDescriptor(Pe.prototype,"join"),Pe.prototype),X(Pe.prototype,"leave",[vI],Object.getOwnPropertyDescriptor(Pe.prototype,"leave"),Pe.prototype),X(Pe.prototype,"getUserList",[gI],Object.getOwnPropertyDescriptor(Pe.prototype,"getUserList"),Pe.prototype),X(Pe.prototype,"publish",[_I,yI,bI],Object.getOwnPropertyDescriptor(Pe.prototype,"publish"),Pe.prototype),X(Pe.prototype,"unpublish",[SI,kI],Object.getOwnPropertyDescriptor(Pe.prototype,"unpublish"),Pe.prototype),X(Pe.prototype,"subscribe",[TI],Object.getOwnPropertyDescriptor(Pe.prototype,"subscribe"),Pe.prototype),X(Pe.prototype,"unsubscribe",[xI],Object.getOwnPropertyDescriptor(Pe.prototype,"unsubscribe"),Pe.prototype),X(Pe.prototype,"switchRole",[II,wI,CI],Object.getOwnPropertyDescriptor(Pe.prototype,"switchRole"),Pe.prototype),X(Pe.prototype,"startPublishCDNStream",[EI,RI],Object.getOwnPropertyDescriptor(Pe.prototype,"startPublishCDNStream"),Pe.prototype),X(Pe.prototype,"stopPublishCDNStream",[AI],Object.getOwnPropertyDescriptor(Pe.prototype,"stopPublishCDNStream"),Pe.prototype),X(Pe.prototype,"startMixTranscode",[PI,DI],Object.getOwnPropertyDescriptor(Pe.prototype,"startMixTranscode"),Pe.prototype),X(Pe.prototype,"stopMixTranscode",[OI],Object.getOwnPropertyDescriptor(Pe.prototype,"stopMixTranscode"),Pe.prototype),X(Pe.prototype,"enableAudioVolumeEvaluation",[LI],Object.getOwnPropertyDescriptor(Pe.prototype,"enableAudioVolumeEvaluation"),Pe.prototype),X(Pe.prototype,"enableSmallStream",[MI],Object.getOwnPropertyDescriptor(Pe.prototype,"enableSmallStream"),Pe.prototype),X(Pe.prototype,"disableSmallStream",[NI],Object.getOwnPropertyDescriptor(Pe.prototype,"disableSmallStream"),Pe.prototype),X(Pe.prototype,"setSmallStreamProfile",[UI],Object.getOwnPropertyDescriptor(Pe.prototype,"setSmallStreamProfile"),Pe.prototype),X(Pe.prototype,"setRemoteVideoStreamType",[VI],Object.getOwnPropertyDescriptor(Pe.prototype,"setRemoteVideoStreamType"),Pe.prototype),X(Pe.prototype,"sendSEIMessage",[jI,BI,FI],Object.getOwnPropertyDescriptor(Pe.prototype,"sendSEIMessage"),Pe.prototype),X(Pe.prototype,"setProxyServer",[HI],Object.getOwnPropertyDescriptor(Pe.prototype,"setProxyServer"),Pe.prototype),X(Pe.prototype,"setTurnServer",[GI],Object.getOwnPropertyDescriptor(Pe.prototype,"setTurnServer"),Pe.prototype),Pe),l7=0,d7=0,h7=(zI=St(Zs),WI=St(Zs),JI=St(Zs),qI=Ql(Yt.TRTC.createClient),KI=St(Zs),XI=Ql(Yt.TRTC.createStream),$t=function(){function e(){Q(this,e),this.name_=Zs,this.VERSION=Gi,this.Logger={loggerManager:_e,LogLevel:Un,setLogLevel:function(n){_e.setLogLevel(n),n<=1&&R4()},enableUploadLog:function(){Ri.handleFunctionState({fnName:"TRTC.enableUploadLog"}),_e.enableUploadLog()},disableUploadLog:function(){_e.warn("disableUploadLog"),Ri.handleFunctionState({fnName:"TRTC.disableUploadLog"}),_e.disableUploadLog()}}}var t;return Ie(e,[{key:"checkSystemRequirements",value:(t=H(p().mark(function n(){return p().wrap(function(i){for(;;)switch(i.prev=i.next){case 0:return i.next=2,Sm();case 2:return i.abrupt("return",i.sent);case 3:case"end":return i.stop()}},n)})),function(){return t.apply(this,arguments)})},{key:"isScreenShareSupported",value:function(){return Bk()}},{key:"isSmallStreamSupported",value:function(){return zk()}},{key:"getDevices",value:function(){return Em()}},{key:"getCameras",value:function(){return function(){return Cm.apply(this,arguments)}()}},{key:"getMicrophones",value:function(){return Xk()}},{key:"getSpeakers",value:function(){return Qk()}},{key:"createClient",value:function(n){(function(){if(QS&&(QS=!1,_e.getLogLevel()!=xt.Logger.LogLevel.NONE&&(console.info("******************************************************************************"),console.info("* TRTC Web SDK"),console.info("* API Document: "+"".concat(Yf,"index.html")),console.info("* Changelog: https://cloud.tencent.com/document/product/647/38958"),console.info("* Report issues: https://github.com/LiteAVSDK/TRTC_Web/issues"),console.info("******************************************************************************")),_e.info("TRTC Web SDK Version: 4.15.21"),_e.info("UserAgent: "+navigator.userAgent),_e.info("URL of current page: "+location.href),navigator.userAgentData&&ln(navigator.userAgentData.getHighEntropyValues)))try{navigator.userAgentData.getHighEntropyValues(["architecture","bitness","model","platformVersion","fullVersionList"]).then(function(o){var c="UAData: ".concat(o.platform,"/").concat(o.platformVersion);o.architecture&&o.bitness&&(c+=" ".concat(o.architecture,"/").concat(o.bitness)),o.mobile&&(c+=" mobile"),o.model&&(c+=" model: ".concat(o.model)),o.fullVersionList&&(c+=" ".concat(o.fullVersionList.filter(function(a){return a.brand!=="Not/A)Brand"}).map(function(a){return"".concat(a.brand,"/").concat(a.version)}).join(","))),_e.info(c)}).catch(function(){})}catch(o){}})();var i={version:this.VERSION},r=new u7(q(q(q({},i),n),{},{seq:++l7}));return Y.emit(JS,{client:r}),r}},{key:"createStream",value:function(n){return new DF(q(q({},n),{},{seq:++d7}))}}]),e}(),X($t.prototype,"checkSystemRequirements",[zI],Object.getOwnPropertyDescriptor($t.prototype,"checkSystemRequirements"),$t.prototype),X($t.prototype,"isScreenShareSupported",[WI],Object.getOwnPropertyDescriptor($t.prototype,"isScreenShareSupported"),$t.prototype),X($t.prototype,"isSmallStreamSupported",[JI],Object.getOwnPropertyDescriptor($t.prototype,"isSmallStreamSupported"),$t.prototype),X($t.prototype,"createClient",[qI,KI],Object.getOwnPropertyDescriptor($t.prototype,"createClient"),$t.prototype),X($t.prototype,"createStream",[XI],Object.getOwnPropertyDescriptor($t.prototype,"createStream"),$t.prototype),$t),xt=new h7;return xt})});var ig=eg((L7,rg)=>{"use strict";var No=typeof Reflect=="object"?Reflect:null,tw=No&&typeof No.apply=="function"?No.apply:function(q,p,G){return Function.prototype.apply.call(q,p,G)},md;No&&typeof No.ownKeys=="function"?md=No.ownKeys:Object.getOwnPropertySymbols?md=function(q){return Object.getOwnPropertyNames(q).concat(Object.getOwnPropertySymbols(q))}:md=function(q){return Object.getOwnPropertyNames(q)};function S7(ne){console&&console.warn&&console.warn(ne)}var rw=Number.isNaN||function(q){return q!==q};function vt(){vt.init.call(this)}rg.exports=vt;rg.exports.once=I7;vt.EventEmitter=vt;vt.prototype._events=void 0;vt.prototype._eventsCount=0;vt.prototype._maxListeners=void 0;var nw=10;function vd(ne){if(typeof ne!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof ne)}Object.defineProperty(vt,"defaultMaxListeners",{enumerable:!0,get:function(){return nw},set:function(ne){if(typeof ne!="number"||ne<0||rw(ne))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+ne+".");nw=ne}});vt.init=function(){(this._events===void 0||this._events===Object.getPrototypeOf(this)._events)&&(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0};vt.prototype.setMaxListeners=function(q){if(typeof q!="number"||q<0||rw(q))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+q+".");return this._maxListeners=q,this};function iw(ne){return ne._maxListeners===void 0?vt.defaultMaxListeners:ne._maxListeners}vt.prototype.getMaxListeners=function(){return iw(this)};vt.prototype.emit=function(q){for(var p=[],G=1;G<arguments.length;G++)p.push(arguments[G]);var $=q==="error",H=this._events;if(H!==void 0)$=$&&H.error===void 0;else if(!$)return!1;if($){var Q;if(p.length>0&&(Q=p[0]),Q instanceof Error)throw Q;var Re=new Error("Unhandled error."+(Q?" ("+Q.message+")":""));throw Re.context=Q,Re}var Ie=H[q];if(Ie===void 0)return!1;if(typeof Ie=="function")tw(Ie,this,p);else for(var $e=Ie.length,Et=uw(Ie,$e),G=0;G<$e;++G)tw(Et[G],this,p);return!0};function aw(ne,q,p,G){var $,H,Q;if(vd(p),H=ne._events,H===void 0?(H=ne._events=Object.create(null),ne._eventsCount=0):(H.newListener!==void 0&&(ne.emit("newListener",q,p.listener?p.listener:p),H=ne._events),Q=H[q]),Q===void 0)Q=H[q]=p,++ne._eventsCount;else if(typeof Q=="function"?Q=H[q]=G?[p,Q]:[Q,p]:G?Q.unshift(p):Q.push(p),$=iw(ne),$>0&&Q.length>$&&!Q.warned){Q.warned=!0;var Re=new Error("Possible EventEmitter memory leak detected. "+Q.length+" "+String(q)+" listeners added. Use emitter.setMaxListeners() to increase limit");Re.name="MaxListenersExceededWarning",Re.emitter=ne,Re.type=q,Re.count=Q.length,S7(Re)}return ne}vt.prototype.addListener=function(q,p){return aw(this,q,p,!1)};vt.prototype.on=vt.prototype.addListener;vt.prototype.prependListener=function(q,p){return aw(this,q,p,!0)};function k7(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function ow(ne,q,p){var G={fired:!1,wrapFn:void 0,target:ne,type:q,listener:p},$=k7.bind(G);return $.listener=p,G.wrapFn=$,$}vt.prototype.once=function(q,p){return vd(p),this.on(q,ow(this,q,p)),this};vt.prototype.prependOnceListener=function(q,p){return vd(p),this.prependListener(q,ow(this,q,p)),this};vt.prototype.removeListener=function(q,p){var G,$,H,Q,Re;if(vd(p),$=this._events,$===void 0)return this;if(G=$[q],G===void 0)return this;if(G===p||G.listener===p)--this._eventsCount===0?this._events=Object.create(null):(delete $[q],$.removeListener&&this.emit("removeListener",q,G.listener||p));else if(typeof G!="function"){for(H=-1,Q=G.length-1;Q>=0;Q--)if(G[Q]===p||G[Q].listener===p){Re=G[Q].listener,H=Q;break}if(H<0)return this;H===0?G.shift():T7(G,H),G.length===1&&($[q]=G[0]),$.removeListener!==void 0&&this.emit("removeListener",q,Re||p)}return this};vt.prototype.off=vt.prototype.removeListener;vt.prototype.removeAllListeners=function(q){var p,G,$;if(G=this._events,G===void 0)return this;if(G.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):G[q]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete G[q]),this;if(arguments.length===0){var H=Object.keys(G),Q;for($=0;$<H.length;++$)Q=H[$],Q!=="removeListener"&&this.removeAllListeners(Q);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(p=G[q],typeof p=="function")this.removeListener(q,p);else if(p!==void 0)for($=p.length-1;$>=0;$--)this.removeListener(q,p[$]);return this};function sw(ne,q,p){var G=ne._events;if(G===void 0)return[];var $=G[q];return $===void 0?[]:typeof $=="function"?p?[$.listener||$]:[$]:p?x7($):uw($,$.length)}vt.prototype.listeners=function(q){return sw(this,q,!0)};vt.prototype.rawListeners=function(q){return sw(this,q,!1)};vt.listenerCount=function(ne,q){return typeof ne.listenerCount=="function"?ne.listenerCount(q):cw.call(ne,q)};vt.prototype.listenerCount=cw;function cw(ne){var q=this._events;if(q!==void 0){var p=q[ne];if(typeof p=="function")return 1;if(p!==void 0)return p.length}return 0}vt.prototype.eventNames=function(){return this._eventsCount>0?md(this._events):[]};function uw(ne,q){for(var p=new Array(q),G=0;G<q;++G)p[G]=ne[G];return p}function T7(ne,q){for(;q+1<ne.length;q++)ne[q]=ne[q+1];ne.pop()}function x7(ne){for(var q=new Array(ne.length),p=0;p<q.length;++p)q[p]=ne[p].listener||ne[p];return q}function I7(ne,q){return new Promise(function(p,G){function $(Q){ne.removeListener(q,H),G(Q)}function H(){typeof ne.removeListener=="function"&&ne.removeListener("error",$),p([].slice.call(arguments))}lw(ne,q,H,{once:!0}),q!=="error"&&w7(ne,$,{once:!0})})}function w7(ne,q,p){typeof ne.on=="function"&&lw(ne,"error",q,p)}function lw(ne,q,p,G){if(typeof ne.on=="function")G.once?ne.once(q,p):ne.on(q,p);else if(typeof ne.addEventListener=="function")ne.addEventListener(q,function $(H){G.once&&ne.removeEventListener(q,$),p(H)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof ne)}});var hw=eg((ag,og)=>{(function(ne,q){typeof ag=="object"&&typeof og!="undefined"?og.exports=q(Er()):typeof define=="function"&&define.amd?define(["trtc-js-sdk"],q):(ne=typeof globalThis!="undefined"?globalThis:ne||self).RTCBeautyPlugin=q(ne.TRTC)})(ag,function(ne){function q(le){return le&&typeof le=="object"&&"default"in le?le:{default:le}}var p=q(ne);function G(){G=function(){return le};var le={},Te=Object.prototype,Se=Te.hasOwnProperty,je=typeof Symbol=="function"?Symbol:{},He=je.iterator||"@@iterator",oe=je.asyncIterator||"@@asyncIterator",X=je.toStringTag||"@@toStringTag";function ce(he,de,Ne){return Object.defineProperty(he,de,{value:Ne,enumerable:!0,configurable:!0,writable:!0}),he[de]}try{ce({},"")}catch(he){ce=function(de,Ne,We){return de[Ne]=We}}function z(he,de,Ne,We){var De=de&&de.prototype instanceof ue?de:ue,ut=Object.create(De.prototype),rt=new Ze(We||[]);return ut._invoke=function(Ut,en,pe){var Ot="suspendedStart";return function(Kt,fr){if(Ot==="executing")throw new Error("Generator is already running");if(Ot==="completed"){if(Kt==="throw")throw fr;return qn()}for(pe.method=Kt,pe.arg=fr;;){var Pi=pe.delegate;if(Pi){var yn=hr(Pi,pe);if(yn){if(yn===be)continue;return yn}}if(pe.method==="next")pe.sent=pe._sent=pe.arg;else if(pe.method==="throw"){if(Ot==="suspendedStart")throw Ot="completed",pe.arg;pe.dispatchException(pe.arg)}else pe.method==="return"&&pe.abrupt("return",pe.arg);Ot="executing";var Rt=re(Ut,en,pe);if(Rt.type==="normal"){if(Ot=pe.done?"completed":"suspendedYield",Rt.arg===be)continue;return{value:Rt.arg,done:pe.done}}Rt.type==="throw"&&(Ot="completed",pe.method="throw",pe.arg=Rt.arg)}}}(he,Ne,rt),ut}function re(he,de,Ne){try{return{type:"normal",arg:he.call(de,Ne)}}catch(We){return{type:"throw",arg:We}}}le.wrap=z;var be={};function ue(){}function ye(){}function Me(){}var Jt={};ce(Jt,He,function(){return this});var Zt=Object.getPrototypeOf,Ke=Zt&&Zt(Zt(Gt([])));Ke&&Ke!==Te&&Se.call(Ke,He)&&(Jt=Ke);var qt=Me.prototype=ue.prototype=Object.create(Jt);function ft(he){["next","throw","return"].forEach(function(de){ce(he,de,function(Ne){return this._invoke(de,Ne)})})}function Jn(he,de){function Ne(De,ut,rt,Ut){var en=re(he[De],he,ut);if(en.type!=="throw"){var pe=en.arg,Ot=pe.value;return Ot&&typeof Ot=="object"&&Se.call(Ot,"__await")?de.resolve(Ot.__await).then(function(Kt){Ne("next",Kt,rt,Ut)},function(Kt){Ne("throw",Kt,rt,Ut)}):de.resolve(Ot).then(function(Kt){pe.value=Kt,rt(pe)},function(Kt){return Ne("throw",Kt,rt,Ut)})}Ut(en.arg)}var We;this._invoke=function(De,ut){function rt(){return new de(function(Ut,en){Ne(De,ut,Ut,en)})}return We=We?We.then(rt,rt):rt()}}function hr(he,de){var Ne=he.iterator[de.method];if(Ne===void 0){if(de.delegate=null,de.method==="throw"){if(he.iterator.return&&(de.method="return",de.arg=void 0,hr(he,de),de.method==="throw"))return be;de.method="throw",de.arg=new TypeError("The iterator does not provide a 'throw' method")}return be}var We=re(Ne,he.iterator,de.arg);if(We.type==="throw")return de.method="throw",de.arg=We.arg,de.delegate=null,be;var De=We.arg;return De?De.done?(de[he.resultName]=De.value,de.next=he.nextLoc,de.method!=="return"&&(de.method="next",de.arg=void 0),de.delegate=null,be):De:(de.method="throw",de.arg=new TypeError("iterator result is not an object"),de.delegate=null,be)}function Ht(he){var de={tryLoc:he[0]};1 in he&&(de.catchLoc=he[1]),2 in he&&(de.finallyLoc=he[2],de.afterLoc=he[3]),this.tryEntries.push(de)}function Rn(he){var de=he.completion||{};de.type="normal",delete de.arg,he.completion=de}function Ze(he){this.tryEntries=[{tryLoc:"root"}],he.forEach(Ht,this),this.reset(!0)}function Gt(he){if(he){var de=he[He];if(de)return de.call(he);if(typeof he.next=="function")return he;if(!isNaN(he.length)){var Ne=-1,We=function De(){for(;++Ne<he.length;)if(Se.call(he,Ne))return De.value=he[Ne],De.done=!1,De;return De.value=void 0,De.done=!0,De};return We.next=We}}return{next:qn}}function qn(){return{value:void 0,done:!0}}return ye.prototype=Me,ce(qt,"constructor",Me),ce(Me,"constructor",ye),ye.displayName=ce(Me,X,"GeneratorFunction"),le.isGeneratorFunction=function(he){var de=typeof he=="function"&&he.constructor;return!!de&&(de===ye||(de.displayName||de.name)==="GeneratorFunction")},le.mark=function(he){return Object.setPrototypeOf?Object.setPrototypeOf(he,Me):(he.__proto__=Me,ce(he,X,"GeneratorFunction")),he.prototype=Object.create(qt),he},le.awrap=function(he){return{__await:he}},ft(Jn.prototype),ce(Jn.prototype,oe,function(){return this}),le.AsyncIterator=Jn,le.async=function(he,de,Ne,We,De){De===void 0&&(De=Promise);var ut=new Jn(z(he,de,Ne,We),De);return le.isGeneratorFunction(de)?ut:ut.next().then(function(rt){return rt.done?rt.value:ut.next()})},ft(qt),ce(qt,X,"Generator"),ce(qt,He,function(){return this}),ce(qt,"toString",function(){return"[object Generator]"}),le.keys=function(he){var de=[];for(var Ne in he)de.push(Ne);return de.reverse(),function We(){for(;de.length;){var De=de.pop();if(De in he)return We.value=De,We.done=!1,We}return We.done=!0,We}},le.values=Gt,Ze.prototype={constructor:Ze,reset:function(he){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(Rn),!he)for(var de in this)de.charAt(0)==="t"&&Se.call(this,de)&&!isNaN(+de.slice(1))&&(this[de]=void 0)},stop:function(){this.done=!0;var he=this.tryEntries[0].completion;if(he.type==="throw")throw he.arg;return this.rval},dispatchException:function(he){if(this.done)throw he;var de=this;function Ne(en,pe){return ut.type="throw",ut.arg=he,de.next=en,pe&&(de.method="next",de.arg=void 0),!!pe}for(var We=this.tryEntries.length-1;We>=0;--We){var De=this.tryEntries[We],ut=De.completion;if(De.tryLoc==="root")return Ne("end");if(De.tryLoc<=this.prev){var rt=Se.call(De,"catchLoc"),Ut=Se.call(De,"finallyLoc");if(rt&&Ut){if(this.prev<De.catchLoc)return Ne(De.catchLoc,!0);if(this.prev<De.finallyLoc)return Ne(De.finallyLoc)}else if(rt){if(this.prev<De.catchLoc)return Ne(De.catchLoc,!0)}else{if(!Ut)throw new Error("try statement without catch or finally");if(this.prev<De.finallyLoc)return Ne(De.finallyLoc)}}}},abrupt:function(he,de){for(var Ne=this.tryEntries.length-1;Ne>=0;--Ne){var We=this.tryEntries[Ne];if(We.tryLoc<=this.prev&&Se.call(We,"finallyLoc")&&this.prev<We.finallyLoc){var De=We;break}}De&&(he==="break"||he==="continue")&&De.tryLoc<=de&&de<=De.finallyLoc&&(De=null);var ut=De?De.completion:{};return ut.type=he,ut.arg=de,De?(this.method="next",this.next=De.finallyLoc,be):this.complete(ut)},complete:function(he,de){if(he.type==="throw")throw he.arg;return he.type==="break"||he.type==="continue"?this.next=he.arg:he.type==="return"?(this.rval=this.arg=he.arg,this.method="return",this.next="end"):he.type==="normal"&&de&&(this.next=de),be},finish:function(he){for(var de=this.tryEntries.length-1;de>=0;--de){var Ne=this.tryEntries[de];if(Ne.finallyLoc===he)return this.complete(Ne.completion,Ne.afterLoc),Rn(Ne),be}},catch:function(he){for(var de=this.tryEntries.length-1;de>=0;--de){var Ne=this.tryEntries[de];if(Ne.tryLoc===he){var We=Ne.completion;if(We.type==="throw"){var De=We.arg;Rn(Ne)}return De}}throw new Error("illegal catch attempt")},delegateYield:function(he,de,Ne){return this.delegate={iterator:Gt(he),resultName:de,nextLoc:Ne},this.method==="next"&&(this.arg=void 0),be}},le}function $(le){return $=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(Te){return typeof Te}:function(Te){return Te&&typeof Symbol=="function"&&Te.constructor===Symbol&&Te!==Symbol.prototype?"symbol":typeof Te},$(le)}function H(le,Te,Se,je,He,oe,X){try{var ce=le[oe](X),z=ce.value}catch(re){return void Se(re)}ce.done?Te(z):Promise.resolve(z).then(je,He)}function Q(le){return function(){var Te=this,Se=arguments;return new Promise(function(je,He){var oe=le.apply(Te,Se);function X(z){H(oe,je,He,X,ce,"next",z)}function ce(z){H(oe,je,He,X,ce,"throw",z)}X(void 0)})}}function Re(le,Te){if(!(le instanceof Te))throw new TypeError("Cannot call a class as a function")}function Ie(le,Te){for(var Se=0;Se<Te.length;Se++){var je=Te[Se];je.enumerable=je.enumerable||!1,je.configurable=!0,"value"in je&&(je.writable=!0),Object.defineProperty(le,je.key,je)}}function $e(le,Te,Se){return Te&&Ie(le.prototype,Te),Se&&Ie(le,Se),Object.defineProperty(le,"prototype",{writable:!1}),le}function Et(le,Te,Se){var je=function(re,be,ue){var ye=new RegExp("\\b".concat(be," \\w+ (\\w+)"),"ig");re.replace(ye,function(Me,Jt){return ue[Jt]=0,Me})},He=function(re,be,ue){var ye=re.createShader(ue);return re.shaderSource(ye,be),re.compileShader(ye),re.getShaderParameter(ye,re.COMPILE_STATUS)?ye:(console.log(re.getShaderInfoLog(ye)),null)};this.uniform={},this.attribute={};var oe=He(le,Te,le.VERTEX_SHADER),X=He(le,Se,le.FRAGMENT_SHADER);for(var ce in this.id=le.createProgram(),le.attachShader(this.id,oe),le.attachShader(this.id,X),le.linkProgram(this.id),le.getProgramParameter(this.id,le.LINK_STATUS)||console.log(le.getProgramInfoLog(this.id)),le.useProgram(this.id),je(Te,"attribute",this.attribute),this.attribute)this.attribute[ce]=le.getAttribLocation(this.id,ce);for(var z in je(Te,"uniform",this.uniform),je(Se,"uniform",this.uniform),this.uniform)this.uniform[z]=le.getUniformLocation(this.id,z)}function Ye(le,Te,Se,je){for(var He=[],oe=0;oe<Te.length;++oe)He.push(Ac(le,Te[oe],le[dr[oe]]));return function(X,ce,z,re){var be=X.createProgram();return ce.forEach(function(ue){X.attachShader(be,ue)}),z&&z.forEach(function(ue,ye){X.bindAttribLocation(be,re?re[ye]:ye,ue)}),X.linkProgram(be),X.getProgramParameter(be,X.LINK_STATUS)?be:(X.deleteProgram(be),null)}(le,He,Se,je)}var dr=["VERTEX_SHADER","FRAGMENT_SHADER"];function Ac(le,Te,Se){var je=le.createShader(Se);return le.shaderSource(je,Te),le.compileShader(je),le.getShaderParameter(je,le.COMPILE_STATUS)?je:(le.deleteShader(je),null)}var zo=function(){function le(Te){Re(this,le),this.canvas=Te.canvas,this.video=Te.video,this.width=Te.width||640,this.height=Te.height||480,this.vertexBuffer=null,this.currentProgram=null,this.applied=!1,this.beautyParams={beauty:.5,brightness:.5,ruddy:.5},this.gl=this.createGL(Te.canvas),this.sourceTexture=this.gl.createTexture()}return $e(le,[{key:"setRect",value:function(Te,Se){this.width=Te,this.height=Se}},{key:"apply",value:function(Te){if(!this.vertexBuffer){var Se=new Float32Array([-1,-1,0,1,1,-1,1,1,-1,1,0,0,-1,1,0,0,1,-1,1,1,1,1,1,0]);this.vertexBuffer=this.gl.createBuffer(),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this.vertexBuffer),this.gl.bufferData(this.gl.ARRAY_BUFFER,Se,this.gl.STATIC_DRAW),this.gl.pixelStorei(this.gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!0)}this.gl.viewport(0,0,this.width,this.height),this.gl.bindTexture(this.gl.TEXTURE_2D,this.sourceTexture),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_WRAP_S,this.gl.CLAMP_TO_EDGE),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_WRAP_T,this.gl.CLAMP_TO_EDGE),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_MIN_FILTER,this.gl.NEAREST),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_MAG_FILTER,this.gl.NEAREST),this.applied?this.gl.texSubImage2D(this.gl.TEXTURE_2D,0,0,0,this.gl.RGB,this.gl.UNSIGNED_BYTE,Te):(this.gl.texImage2D(this.gl.TEXTURE_2D,0,this.gl.RGB,this.gl.RGB,this.gl.UNSIGNED_BYTE,Te),this.applied=!0);var je=this.beautyParams,He=je.beauty,oe=je.brightness,X=je.ruddy,ce=2/this.width,z=2/this.height,re=this.compileBeautyShader();this.gl.uniform2f(re.uniform.singleStepOffset,ce,z);var be=new Float32Array([1-.8*He,1-.6*He,.1+.45*X,.1+.45*X]);this.gl.uniform4fv(re.uniform.params,be),this.gl.uniform1f(re.uniform.brightness,.12*oe),this.gl.bindTexture(this.gl.TEXTURE_2D,this.sourceTexture),this.gl.bindFramebuffer(this.gl.FRAMEBUFFER,null),this.gl.uniform1f(this.currentProgram.uniform.flipY,1),this.gl.drawArrays(this.gl.TRIANGLES,0,6)}},{key:"compileBeautyShader",value:function(){if(this.currentProgram)return this.currentProgram;this.currentProgram=new Et(this.gl,["precision highp float;","attribute vec2 pos;","attribute vec2 uv;","varying vec2 vUv;","uniform float flipY;","void main(void) {","vUv = uv;","gl_Position = vec4(pos.x, pos.y*flipY, 0.0, 1.);","}"].join(`
|
|
107
71
|
`),["precision highp float;","uniform vec2 singleStepOffset;","uniform sampler2D texture;","uniform vec4 params;","uniform float brightness;","varying vec2 vUv;","const highp vec3 W = vec3(0.299,0.587,0.114);","const mat3 saturateMatrix = mat3(1.1102,-0.0598,-0.061,-0.0774,1.0826,-0.1186,-0.0228,-0.0228,1.1772);","vec2 blurCoordinates[24];","float hardLight(float color){","if(color <= 0.5){","color = color * color * 2.0;","} else {","color = 1.0 - ((1.0 - color)*(1.0 - color) * 2.0);","}","return color;","}","void main(){","vec3 centralColor = texture2D(texture, vUv).rgb;","blurCoordinates[0] = vUv.xy + singleStepOffset * vec2(0.0, -10.0);","blurCoordinates[1] = vUv.xy + singleStepOffset * vec2(0.0, 10.0);","blurCoordinates[2] = vUv.xy + singleStepOffset * vec2(-10.0, 0.0);","blurCoordinates[3] = vUv.xy + singleStepOffset * vec2(10.0, 0.0);","blurCoordinates[4] = vUv.xy + singleStepOffset * vec2(5.0, -8.0);","blurCoordinates[5] = vUv.xy + singleStepOffset * vec2(5.0, 8.0);","blurCoordinates[6] = vUv.xy + singleStepOffset * vec2(-5.0, 8.0);","blurCoordinates[7] = vUv.xy + singleStepOffset * vec2(-5.0, -8.0);","blurCoordinates[8] = vUv.xy + singleStepOffset * vec2(8.0, -5.0);","blurCoordinates[9] = vUv.xy + singleStepOffset * vec2(8.0, 5.0);","blurCoordinates[10] = vUv.xy + singleStepOffset * vec2(-8.0, 5.0);","blurCoordinates[11] = vUv.xy + singleStepOffset * vec2(-8.0, -5.0);","blurCoordinates[12] = vUv.xy + singleStepOffset * vec2(0.0, -6.0);","blurCoordinates[13] = vUv.xy + singleStepOffset * vec2(0.0, 6.0);","blurCoordinates[14] = vUv.xy + singleStepOffset * vec2(6.0, 0.0);","blurCoordinates[15] = vUv.xy + singleStepOffset * vec2(-6.0, 0.0);","blurCoordinates[16] = vUv.xy + singleStepOffset * vec2(-4.0, -4.0);","blurCoordinates[17] = vUv.xy + singleStepOffset * vec2(-4.0, 4.0);","blurCoordinates[18] = vUv.xy + singleStepOffset * vec2(4.0, -4.0);","blurCoordinates[19] = vUv.xy + singleStepOffset * vec2(4.0, 4.0);","blurCoordinates[20] = vUv.xy + singleStepOffset * vec2(-2.0, -2.0);","blurCoordinates[21] = vUv.xy + singleStepOffset * vec2(-2.0, 2.0);","blurCoordinates[22] = vUv.xy + singleStepOffset * vec2(2.0, -2.0);","blurCoordinates[23] = vUv.xy + singleStepOffset * vec2(2.0, 2.0);","float sampleColor = centralColor.g * 22.0;","sampleColor += texture2D(texture, blurCoordinates[0]).g;","sampleColor += texture2D(texture, blurCoordinates[1]).g;","sampleColor += texture2D(texture, blurCoordinates[2]).g;","sampleColor += texture2D(texture, blurCoordinates[3]).g;","sampleColor += texture2D(texture, blurCoordinates[4]).g;","sampleColor += texture2D(texture, blurCoordinates[5]).g;","sampleColor += texture2D(texture, blurCoordinates[6]).g;","sampleColor += texture2D(texture, blurCoordinates[7]).g;","sampleColor += texture2D(texture, blurCoordinates[8]).g;","sampleColor += texture2D(texture, blurCoordinates[9]).g;","sampleColor += texture2D(texture, blurCoordinates[10]).g;","sampleColor += texture2D(texture, blurCoordinates[11]).g;","sampleColor += texture2D(texture, blurCoordinates[12]).g * 2.0;","sampleColor += texture2D(texture, blurCoordinates[13]).g * 2.0;","sampleColor += texture2D(texture, blurCoordinates[14]).g * 2.0;","sampleColor += texture2D(texture, blurCoordinates[15]).g * 2.0;","sampleColor += texture2D(texture, blurCoordinates[16]).g * 2.0;","sampleColor += texture2D(texture, blurCoordinates[17]).g * 2.0;","sampleColor += texture2D(texture, blurCoordinates[18]).g * 2.0;","sampleColor += texture2D(texture, blurCoordinates[19]).g * 2.0;","sampleColor += texture2D(texture, blurCoordinates[20]).g * 3.0;","sampleColor += texture2D(texture, blurCoordinates[21]).g * 3.0;","sampleColor += texture2D(texture, blurCoordinates[22]).g * 3.0;","sampleColor += texture2D(texture, blurCoordinates[23]).g * 3.0;","sampleColor = sampleColor / 62.0;","float highPass = centralColor.g - sampleColor + 0.5;","for(int i = 0; i < 5;i++){","highPass = hardLight(highPass);","}","float luminance = dot(centralColor, W);","float alpha = pow(luminance, params.r);","vec3 smoothColor = centralColor + (centralColor-vec3(highPass))*alpha*0.1;","smoothColor.r = clamp(pow(smoothColor.r, params.g),0.0,1.0);","smoothColor.g = clamp(pow(smoothColor.g, params.g),0.0,1.0);","smoothColor.b = clamp(pow(smoothColor.b, params.g),0.0,1.0);","vec3 screen = vec3(1.0) - (vec3(1.0)-smoothColor) * (vec3(1.0)-centralColor);","vec3 lighten = max(smoothColor, centralColor);","vec3 softLight = 2.0 * centralColor*smoothColor + centralColor*centralColor - 2.0 * centralColor*centralColor * smoothColor;","gl_FragColor = vec4(mix(centralColor, screen, alpha), 1.0);","gl_FragColor.rgb = mix(gl_FragColor.rgb, lighten, alpha);","gl_FragColor.rgb = mix(gl_FragColor.rgb, softLight, params.b);","vec3 satColor = gl_FragColor.rgb * saturateMatrix;","gl_FragColor.rgb = mix(gl_FragColor.rgb, satColor, params.a);","gl_FragColor.rgb = vec3(gl_FragColor.rgb + vec3(brightness));","}"].join(`
|
|
108
|
-
`));var Te=Float32Array.BYTES_PER_ELEMENT,
|
|
72
|
+
`));var Te=Float32Array.BYTES_PER_ELEMENT,Se=4*Te;return this.gl.enableVertexAttribArray(this.currentProgram.attribute.pos),this.gl.vertexAttribPointer(this.currentProgram.attribute.pos,2,this.gl.FLOAT,!1,Se,0),this.gl.enableVertexAttribArray(this.currentProgram.attribute.uv),this.gl.vertexAttribPointer(this.currentProgram.attribute.uv,2,this.gl.FLOAT,!1,Se,2*Te),this.currentProgram}},{key:"createGL",value:function(Te){var Se=Te.getContext("webgl2");if(Se||Te.getContext("experimental-webgl",{preserveDrawingBuffer:!0}),!Se)throw"Couldn't get WebGL context";return Se}},{key:"setBeautyParams",value:function(Te){this.beautyParams=Te}},{key:"reset",value:function(){this.applied=!1}}]),le}(),Wo=function(){function le(oe){Re(this,le),this.canvas=oe.canvas,this.video=oe.video,this.width=oe.width||640,this.height=oe.height||480,this.onoverload=oe.onoverload,this.gl=this.createGL(oe.canvas),this.vao=this.gl.createVertexArray(),this.positionBuffer=this.gl.createBuffer(),this.sourceTexture=this.gl.createTexture(),this.program=null,this.blurParams={resolutionLocation:null,imageLocation0:null,imageLocation1:null},this.virtualParams={resolutionLocation:null,imageLocation0:null,imageLocation1:null,imageLocation2:null,imageOldLocation0:null,imageOldLocation1:null,imageOldLocation2:null,imageOldLocation3:null,imageOldLocation4:null,imageOldLocation5:null},this.virtualLocation={postProcessTypeLocation:null,sigmaLocation:null,bSigmaLocation:null,mSizeLocation:null,overlayTypeLocation:null,hardThresholdLocation:null,sigmoidClipLocation:null},this.maskBuffer=[],this.frameBuffer=[],this.virtualOption={postProcess:2,sigma:100,bSigma:10,kSize:19,overlayType:0,hardThreshold:.5,sigmoidClip:1},this.type=0,this.frameRate=0,this.rafId=null,this.timeoutId=null,this.img=new Image,this.imgCropCanvas=document.createElement("canvas"),this.imgCropCanvasCtx=this.imgCropCanvas.getContext("2d"),this.imgMap=new Map,this.tempImg=new Image,this.tempImg.crossOrigin="anonymous",this.isRender=!1,this.enable=!1,this.processingTimes=[],this.frameCount=0}var Te,Se,je,He;return $e(le,[{key:"loadResources",value:(He=Q(G().mark(function oe(){return G().wrap(function(X){for(;;)switch(X.prev=X.next){case 0:return X.next=2,new window.SelfieSegmentation({locateFile:function(ce){return"https://web.sdk.qcloud.com/trtc/webrtc/download/segmentation/".concat(ce)}});case 2:return this.selfieSegmentation=X.sent,X.next=5,this.selfieSegmentation.initialize();case 5:case"end":return X.stop()}},oe,this)})),function(){return He.apply(this,arguments)})},{key:"setEnable",value:function(oe){this.enable=oe}},{key:"initVirtualParams",value:(je=Q(G().mark(function oe(X){var ce,z;return G().wrap(function(re){for(;;)switch(re.prev=re.next){case 0:if(ce=X.img,z=X.type,this.type=z==="blur"?0:1,!ce){re.next=5;break}return re.next=5,this.setBackground(ce);case 5:this.type===0?this.initBackgroundBlurProgram():this.type===1&&this.initVirtualBackgroundProgram();case 6:case"end":return re.stop()}},oe,this)})),function(oe){return je.apply(this,arguments)})},{key:"setBackground",value:(Se=Q(G().mark(function oe(X){var ce=this;return G().wrap(function(z){for(;;)switch(z.prev=z.next){case 0:return z.abrupt("return",new Promise(function(re,be){try{X instanceof HTMLImageElement?(ce.img=X,re()):(ce.tempImg.onload=function(){ce.imgCropCanvasCtx.drawImage(ce.tempImg,0,0,ce.width,ce.height);var ue=ce.imgCropCanvas.toDataURL("image/jpeg",.5);ce.img.src=ue,ce.imgMap.set(X,ue),re()},ce.imgMap.has(X)?(ce.img.src=ce.imgMap.get(X),re()):ce.tempImg.src=X)}catch(ue){be("please check the img parameter!")}}));case 1:case"end":return z.stop()}},oe)})),function(oe){return Se.apply(this,arguments)})},{key:"setRect",value:function(oe,X){this.width=oe,this.height=X,this.imgCropCanvas.width=this.width,this.imgCropCanvas.height=this.height,this.imgCropCanvasCtx.fillStyle="#000",this.imgCropCanvasCtx.fillRect(0,0,this.width,this.height),this.img.width=oe,this.img.height=X,this.img.src=this.imgCropCanvas.toDataURL("image/jpeg",.5),this.tempImg.width=oe,this.tempImg.height=X}},{key:"createGL",value:function(oe){var X=oe.getContext("webgl2");if(X||oe.getContext("experimental-webgl",{preserveDrawingBuffer:!0}),!X)throw"Couldn't get WebGL context";return X}},{key:"setRectangle",value:function(oe,X,ce,z,re){var be=X,ue=X+z,ye=ce,Me=ce+re;oe.bufferData(oe.ARRAY_BUFFER,new Float32Array([be,ye,ue,ye,be,Me,be,Me,ue,ye,ue,Me]),oe.STATIC_DRAW)}},{key:"startVirtual",value:function(oe){this.frameRate=oe,this.selfieSegmentation.setOptions({selfieMode:!1,modelSelection:0,effect:"background"}),this.type===0?this.selfieSegmentation.onResults(this.onBlurResult.bind(this)):this.selfieSegmentation.onResults(this.onVirtualResults.bind(this)),this.startTime=new Date().getTime(),this.isRender=!0,this.enable=!0,this.installEvents()}},{key:"render",value:(Te=Q(G().mark(function oe(){var X,ce,z=this;return G().wrap(function(re){for(;;)switch(re.prev=re.next){case 0:if(this.isRender){re.next=2;break}return re.abrupt("return");case 2:if(!((X=new Date().getTime())-this.startTime>1e3/this.frameRate)){re.next=12;break}if(!this.enable||this.video.readyState!==this.video.HAVE_ENOUGH_DATA){re.next=7;break}return re.next=7,this.selfieSegmentation.send({image:this.video});case 7:ce=X-this.startTime,this.processingTimes.push(ce),this.processingTimes.length>100&&this.processingTimes.shift(),this.frameCount>=100?this.processingTimes.reduce(function(be,ue){return be+ue},0)/this.processingTimes.length>100&&(console.log("frameRate is too low, trigger overload."),this.onoverload&&typeof this.onoverload=="function"&&this.onoverload(),this.frameCount=0,this.processingTimes=[]):this.frameCount+=1,this.startTime=X;case 12:document.hidden?(this.timeoutId&&clearTimeout(this.timeoutId),this.rafId&&cancelAnimationFrame(this.rafId),this.timeoutId=setTimeout(function(){z.render()},1e3/this.frameRate)):(this.timeoutId&&clearTimeout(this.timeoutId),this.rafId&&cancelAnimationFrame(this.rafId),this.rafId=requestAnimationFrame(this.render.bind(this)));case 13:case"end":return re.stop()}},oe,this)})),function(){return Te.apply(this,arguments)})},{key:"installEvents",value:function(){window.addEventListener("visibilitychange",this.render.bind(this))}},{key:"uninstallEvents",value:function(){window.addEventListener("visibilitychange",this.render.bind(this))}},{key:"reset",value:function(){this.isRender=!1,cancelAnimationFrame(this.rafId),clearTimeout(this.timeoutId),this.gl.clear(this.gl.COLOR_BUFFER_BIT|this.gl.DEPTH_BUFFER_BIT),this.gl.deleteProgram(this.program),this.gl.deleteTexture(this.sourceTexture),this.uninstallEvents()}},{key:"destroy",value:function(){this.reset(),this.gl.deleteBuffer(this.positionBuffer)}},{key:"initBackgroundBlurProgram",value:function(){var oe=this.gl,X={vertexShaderSource:`#version 300 es
|
|
109
73
|
|
|
110
74
|
// an attribute is an input (in) to a vertex shader.
|
|
111
75
|
// It will receive data from a buffer
|
|
@@ -284,7 +248,7 @@ b=`+C+":"+T+`\r
|
|
|
284
248
|
|
|
285
249
|
outColor = (1.0 - color0.r) * gaussianBlur + color0.r * color1;
|
|
286
250
|
}
|
|
287
|
-
`},
|
|
251
|
+
`},ce=X.vertexShaderSource,z=X.fragmentShaderSource;this.program=Ye(oe,[ce,z]);var re=oe.getAttribLocation(this.program,"position"),be=oe.getAttribLocation(this.program,"texCoord");this.blurParams.resolutionLocation=oe.getUniformLocation(this.program,"resolution"),this.blurParams.imageLocation0=oe.getUniformLocation(this.program,"u_image0"),this.blurParams.imageLocation1=oe.getUniformLocation(this.program,"u_image1"),oe.bindVertexArray(this.vao),oe.bindBuffer(oe.ARRAY_BUFFER,this.positionBuffer),oe.enableVertexAttribArray(re),oe.vertexAttribPointer(re,2,oe.FLOAT,!1,0,0),oe.bindBuffer(oe.ARRAY_BUFFER,oe.createBuffer()),oe.bufferData(oe.ARRAY_BUFFER,new Float32Array([0,0,1,0,0,1,0,1,1,0,1,1]),oe.STATIC_DRAW),oe.enableVertexAttribArray(be),oe.vertexAttribPointer(be,2,oe.FLOAT,!1,0,0)}},{key:"onBlurResult",value:function(oe){for(var X=oe.segmentationMask,ce=oe.image,z=this.gl,re=[],be=[X,ce],ue=0;ue<2;++ue){var ye=z.createTexture();z.bindTexture(z.TEXTURE_2D,ye),z.texParameteri(z.TEXTURE_2D,z.TEXTURE_WRAP_S,z.CLAMP_TO_EDGE),z.texParameteri(z.TEXTURE_2D,z.TEXTURE_WRAP_T,z.CLAMP_TO_EDGE),z.texParameteri(z.TEXTURE_2D,z.TEXTURE_MIN_FILTER,z.NEAREST),z.texParameteri(z.TEXTURE_2D,z.TEXTURE_MAG_FILTER,z.NEAREST),z.texImage2D(z.TEXTURE_2D,0,z.RGBA,z.RGBA,z.UNSIGNED_BYTE,be[ue]),re.push(ye)}z.bindBuffer(z.ARRAY_BUFFER,this.positionBuffer),this.setRectangle(z,0,0,this.width,this.height),z.viewport(0,0,this.width,this.height),z.clearColor(0,0,0,0),z.clear(z.COLOR_BUFFER_BIT|z.DEPTH_BUFFER_BIT),z.useProgram(this.program),z.bindVertexArray(this.vao);var Me=this.blurParams,Jt=Me.resolutionLocation,Zt=Me.imageLocation0,Ke=Me.imageLocation1;z.uniform2f(Jt,this.width,this.height),z.uniform1i(Zt,0),z.uniform1i(Ke,1),z.activeTexture(z.TEXTURE0),z.bindTexture(z.TEXTURE_2D,re[0]),z.activeTexture(z.TEXTURE1),z.bindTexture(z.TEXTURE_2D,re[1]),z.drawArrays(z.TRIANGLES,0,6)}},{key:"initVirtualBackgroundProgram",value:function(){var oe=this.gl,X={vertexShaderSource:`#version 300 es
|
|
288
252
|
|
|
289
253
|
// an attribute is an input (in) to a vertex shader.
|
|
290
254
|
// It will receive data from a buffer
|
|
@@ -564,22 +528,23 @@ b=`+C+":"+T+`\r
|
|
|
564
528
|
outColor.rgb = (maskValue * color1 + (1.0 - maskValue) * color2).rgb;
|
|
565
529
|
outColor.a = 1.0;
|
|
566
530
|
}
|
|
567
|
-
`},Y=te.vertexShaderSource,z=te.fragmentShaderSource;this.program=Xe(ae,[Y,z]);var le=ae.getAttribLocation(this.program,"position"),se=ae.getAttribLocation(this.program,"texCoord"),ye=this.program;this.virtualParams={resolutionLocation:ae.getUniformLocation(ye,"resolution"),imageLocation0:ae.getUniformLocation(ye,"u_image0"),imageLocation1:ae.getUniformLocation(ye,"u_image1"),imageLocation2:ae.getUniformLocation(ye,"u_image2"),imageOldLocation0:ae.getUniformLocation(ye,"u_image_old0"),imageOldLocation1:ae.getUniformLocation(ye,"u_image_old1"),imageOldLocation2:ae.getUniformLocation(ye,"u_image_old2"),imageOldLocation3:ae.getUniformLocation(ye,"u_image_old3"),imageOldLocation4:ae.getUniformLocation(ye,"u_image_old4"),imageOldLocation5:ae.getUniformLocation(ye,"u_image_old5")},this.virtualLocation={postProcessTypeLocation:ae.getUniformLocation(ye,"PostProcessType"),sigmaLocation:ae.getUniformLocation(ye,"SIGMA"),bSigmaLocation:ae.getUniformLocation(ye,"BSIGMA"),mSizeLocation:ae.getUniformLocation(ye,"MSIZE"),overlayTypeLocation:ae.getUniformLocation(ye,"overlayType"),hardThresholdLocation:ae.getUniformLocation(ye,"hardThreshold"),sigmoidClipLocation:ae.getUniformLocation(ye,"sigmoidClip")},ae.bindVertexArray(this.vao),ae.bindBuffer(ae.ARRAY_BUFFER,this.positionBuffer),ae.enableVertexAttribArray(le),ae.vertexAttribPointer(le,2,ae.FLOAT,!1,0,0),ae.bindBuffer(ae.ARRAY_BUFFER,ae.createBuffer()),ae.bufferData(ae.ARRAY_BUFFER,new Float32Array([0,0,1,0,0,1,0,1,1,0,1,1]),ae.STATIC_DRAW),ae.enableVertexAttribArray(se),ae.vertexAttribPointer(se,2,ae.FLOAT,!1,0,0)}},{key:"onVirtualResults",value:function(ae){var te=ae.segmentationMask,Y=ae.image,z=this.gl;this.maskBuffer.length<3&&this.maskBuffer.push(te,te,te),this.frameBuffer.length<3&&this.frameBuffer.push(Y,Y,Y);for(var le=[],se=[te,Y,this.img,this.maskBuffer[0],this.maskBuffer[1],this.maskBuffer[2],this.frameBuffer[0],this.frameBuffer[1],this.frameBuffer[2]],ye=0;ye<se.length;++ye)this.sourceTexture=z.createTexture(),z.bindTexture(z.TEXTURE_2D,this.sourceTexture),z.texParameteri(z.TEXTURE_2D,z.TEXTURE_WRAP_S,z.CLAMP_TO_EDGE),z.texParameteri(z.TEXTURE_2D,z.TEXTURE_WRAP_T,z.CLAMP_TO_EDGE),z.texParameteri(z.TEXTURE_2D,z.TEXTURE_MIN_FILTER,z.NEAREST),z.texParameteri(z.TEXTURE_2D,z.TEXTURE_MAG_FILTER,z.NEAREST),z.texImage2D(z.TEXTURE_2D,0,z.RGBA,z.RGBA,z.UNSIGNED_BYTE,se[ye]),le.push(this.sourceTexture);z.bindBuffer(z.ARRAY_BUFFER,this.positionBuffer),this.setRectangle(z,0,0,this.width,this.height),z.viewport(0,0,this.width,this.height),z.clearColor(0,0,0,0),z.clear(z.COLOR_BUFFER_BIT|z.DEPTH_BUFFER_BIT),z.useProgram(this.program),z.bindVertexArray(this.vao);var ce=this.virtualParams,Se=ce.resolutionLocation,Dt=ce.imageLocation0,Tn=ce.imageLocation1,Gt=ce.imageLocation2,Ke=ce.imageOldLocation0,it=ce.imageOldLocation1,Wn=ce.imageOldLocation2,qn=ce.imageOldLocation3,Jn=ce.imageOldLocation4,Xt=ce.imageOldLocation5;z.uniform2f(Se,this.width,this.height);var et=this.virtualOption,Rt=et.postProcess,Kn=et.kSize,fe=et.sigma,de=et.bSigma,je=et.overlayType,qe=et.hardThreshold,Oe=et.sigmoidClip,ut=this.virtualLocation,xt=ut.postProcessTypeLocation,ht=ut.mSizeLocation,Qt=ut.sigmaLocation,$e=ut.bSigmaLocation,ke=ut.overlayTypeLocation,Ht=ut.hardThresholdLocation,ri=ut.sigmoidClipLocation;z.uniform1i(xt,Rt),z.uniform1i(ht,Kn),z.uniform1f(Qt,fe),z.uniform1f($e,de),z.uniform1i(ke,je),z.uniform1f(Ht,qe),z.uniform1i(ri,Oe),z.uniform1i(Dt,0),z.uniform1i(Tn,1),z.uniform1i(Gt,2),z.uniform1i(Ke,3),z.uniform1i(it,4),z.uniform1i(Wn,5),z.uniform1i(qn,6),z.uniform1i(Jn,7),z.uniform1i(Xt,8),z.activeTexture(z.TEXTURE0),z.bindTexture(z.TEXTURE_2D,le[0]),z.activeTexture(z.TEXTURE1),z.bindTexture(z.TEXTURE_2D,le[1]),z.activeTexture(z.TEXTURE2),z.bindTexture(z.TEXTURE_2D,le[2]),z.activeTexture(z.TEXTURE3),z.bindTexture(z.TEXTURE_2D,le[3]),z.activeTexture(z.TEXTURE4),z.bindTexture(z.TEXTURE_2D,le[4]),z.activeTexture(z.TEXTURE5),z.bindTexture(z.TEXTURE_2D,le[5]),z.activeTexture(z.TEXTURE6),z.bindTexture(z.TEXTURE_2D,le[6]),z.activeTexture(z.TEXTURE7),z.bindTexture(z.TEXTURE_2D,le[7]),z.activeTexture(z.TEXTURE8),z.bindTexture(z.TEXTURE_2D,le[8]),z.drawArrays(z.TRIANGLES,0,6),this.maskBuffer[0]=this.maskBuffer[1],this.maskBuffer[1]=this.maskBuffer[2],this.maskBuffer[2]=te,this.frameBuffer[0]=this.frameBuffer[1],this.frameBuffer[1]=this.frameBuffer[2],this.frameBuffer[2]=Y}}]),oe}(),ts=typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:{};(function(){var oe;function Te(l){var _=0;return function(){return _<l.length?{done:!1,value:l[_++]}:{done:!0}}}var be=typeof Object.defineProperties=="function"?Object.defineProperty:function(l,_,R){return l==Array.prototype||l==Object.prototype||(l[_]=R.value),l},Fe=function(l){l=[(typeof globalThis=="undefined"?"undefined":Q(globalThis))=="object"&&globalThis,l,(typeof window=="undefined"?"undefined":Q(window))=="object"&&window,(typeof self=="undefined"?"undefined":Q(self))=="object"&&self,Q(ts)=="object"&&ts];for(var _=0;_<l.length;++_){var R=l[_];if(R&&R.Math==Math)return R}throw Error("Cannot find global object")}(this);function He(l,_){if(_)e:{var R=Fe;l=l.split(".");for(var M=0;M<l.length-1;M++){var V=l[M];if(!(V in R))break e;R=R[V]}(_=_(M=R[l=l[l.length-1]]))!=M&&_!=null&&be(R,l,{configurable:!0,writable:!0,value:_})}}function ae(l){return(l={next:l})[Symbol.iterator]=function(){return this},l}function te(l){var _=typeof Symbol!="undefined"&&Symbol.iterator&&l[Symbol.iterator];return _?_.call(l):{next:Te(l)}}function Y(l){if(!(l instanceof Array)){l=te(l);for(var _,R=[];!(_=l.next()).done;)R.push(_.value);l=R}return l}He("Symbol",function(l){function _(V,U){this.h=V,be(this,"description",{configurable:!0,writable:!0,value:U})}if(l)return l;_.prototype.toString=function(){return this.h};var R="jscomp_symbol_"+(1e9*Math.random()>>>0)+"_",M=0;return function V(U){if(this instanceof V)throw new TypeError("Symbol is not a constructor");return new _(R+(U||"")+"_"+M++,U)}}),He("Symbol.iterator",function(l){if(l)return l;l=Symbol("Symbol.iterator");for(var _="Array Int8Array Uint8Array Uint8ClampedArray Int16Array Uint16Array Int32Array Uint32Array Float32Array Float64Array".split(" "),R=0;R<_.length;R++){var M=Fe[_[R]];typeof M=="function"&&typeof M.prototype[l]!="function"&&be(M.prototype,l,{configurable:!0,writable:!0,value:function(){return ae(Te(this))}})}return l});var z=typeof Object.assign=="function"?Object.assign:function(l,_){for(var R=1;R<arguments.length;R++){var M=arguments[R];if(M)for(var V in M)Object.prototype.hasOwnProperty.call(M,V)&&(l[V]=M[V])}return l};He("Object.assign",function(l){return l||z});var le,se=typeof Object.create=="function"?Object.create:function(l){function _(){}return _.prototype=l,new _};if(typeof Object.setPrototypeOf=="function")le=Object.setPrototypeOf;else{var ye;e:{var ce={};try{ce.__proto__={a:!0},ye=ce.a;break e}catch(l){}ye=!1}le=ye?function(l,_){if(l.__proto__=_,l.__proto__!==_)throw new TypeError(l+" is not extensible");return l}:null}var Se=le;function Dt(l,_){if(l.prototype=se(_.prototype),l.prototype.constructor=l,Se)Se(l,_);else for(var R in _)if(R!="prototype")if(Object.defineProperties){var M=Object.getOwnPropertyDescriptor(_,R);M&&Object.defineProperty(l,R,M)}else l[R]=_[R];l.za=_.prototype}function Tn(){this.m=!1,this.j=null,this.i=void 0,this.h=1,this.v=this.s=0,this.l=null}function Gt(l){if(l.m)throw new TypeError("Generator is already running");l.m=!0}function Ke(l,_){l.l={ma:_,na:!0},l.h=l.s||l.v}function it(l,_,R){return l.h=R,{value:_}}function Wn(l){this.h=new Tn,this.i=l}function qn(l,_,R,M){try{var V=_.call(l.h.j,R);if(!(V instanceof Object))throw new TypeError("Iterator result "+V+" is not an object");if(!V.done)return l.h.m=!1,V;var U=V.value}catch(F){return l.h.j=null,Ke(l.h,F),Jn(l)}return l.h.j=null,M.call(l.h,U),Jn(l)}function Jn(l){for(;l.h.h;)try{var _=l.i(l.h);if(_)return l.h.m=!1,{value:_.value,done:!1}}catch(R){l.h.i=void 0,Ke(l.h,R)}if(l.h.m=!1,l.h.l){if(_=l.h.l,l.h.l=null,_.na)throw _.ma;return{value:_.return,done:!0}}return{value:void 0,done:!0}}function Xt(l){this.next=function(_){return Gt(l.h),l.h.j?_=qn(l,l.h.j.next,_,l.h.u):(l.h.u(_),_=Jn(l)),_},this.throw=function(_){return Gt(l.h),l.h.j?_=qn(l,l.h.j.throw,_,l.h.u):(Ke(l.h,_),_=Jn(l)),_},this.return=function(_){return function(R,M){Gt(R.h);var V=R.h.j;return V?qn(R,"return"in V?V.return:function(U){return{value:U,done:!0}},M,R.h.return):(R.h.return(M),Jn(R))}(l,_)},this[Symbol.iterator]=function(){return this}}function et(l){return function(_){function R(V){return _.next(V)}function M(V){return _.throw(V)}return new Promise(function(V,U){(function F(W){W.done?V(W.value):Promise.resolve(W.value).then(R,M).then(F,U)})(_.next())})}(new Xt(new Wn(l)))}function Rt(l){return l||Array.prototype.fill}Tn.prototype.u=function(l){this.i=l},Tn.prototype.return=function(l){this.l={return:l},this.h=this.v},He("Promise",function(l){function _(F){this.i=0,this.j=void 0,this.h=[],this.u=!1;var W=this.l();try{F(W.resolve,W.reject)}catch(Z){W.reject(Z)}}function R(){this.h=null}function M(F){return F instanceof _?F:new _(function(W){W(F)})}if(l)return l;R.prototype.i=function(F){if(this.h==null){this.h=[];var W=this;this.j(function(){W.m()})}this.h.push(F)};var V=Fe.setTimeout;R.prototype.j=function(F){V(F,0)},R.prototype.m=function(){for(;this.h&&this.h.length;){var F=this.h;this.h=[];for(var W=0;W<F.length;++W){var Z=F[W];F[W]=null;try{Z()}catch(pe){this.l(pe)}}}this.h=null},R.prototype.l=function(F){this.j(function(){throw F})},_.prototype.l=function(){function F(pe){return function(me){Z||(Z=!0,pe.call(W,me))}}var W=this,Z=!1;return{resolve:F(this.I),reject:F(this.m)}},_.prototype.I=function(F){if(F===this)this.m(new TypeError("A Promise cannot resolve to itself"));else if(F instanceof _)this.L(F);else{e:switch(Q(F)){case"object":var W=F!=null;break e;case"function":W=!0;break e;default:W=!1}W?this.F(F):this.s(F)}},_.prototype.F=function(F){var W=void 0;try{W=F.then}catch(Z){return void this.m(Z)}typeof W=="function"?this.M(W,F):this.s(F)},_.prototype.m=function(F){this.v(2,F)},_.prototype.s=function(F){this.v(1,F)},_.prototype.v=function(F,W){if(this.i!=0)throw Error("Cannot settle("+F+", "+W+"): Promise already settled in state"+this.i);this.i=F,this.j=W,this.i===2&&this.K(),this.H()},_.prototype.K=function(){var F=this;V(function(){if(F.D()){var W=Fe.console;W!==void 0&&W.error(F.j)}},1)},_.prototype.D=function(){if(this.u)return!1;var F=Fe.CustomEvent,W=Fe.Event,Z=Fe.dispatchEvent;return Z===void 0||(typeof F=="function"?F=new F("unhandledrejection",{cancelable:!0}):typeof W=="function"?F=new W("unhandledrejection",{cancelable:!0}):(F=Fe.document.createEvent("CustomEvent")).initCustomEvent("unhandledrejection",!1,!0,F),F.promise=this,F.reason=this.j,Z(F))},_.prototype.H=function(){if(this.h!=null){for(var F=0;F<this.h.length;++F)U.i(this.h[F]);this.h=null}};var U=new R;return _.prototype.L=function(F){var W=this.l();F.T(W.resolve,W.reject)},_.prototype.M=function(F,W){var Z=this.l();try{F.call(W,Z.resolve,Z.reject)}catch(pe){Z.reject(pe)}},_.prototype.then=function(F,W){function Z(De,ve){return typeof De=="function"?function(Me){try{pe(De(Me))}catch(Ge){me(Ge)}}:ve}var pe,me,Ce=new _(function(De,ve){pe=De,me=ve});return this.T(Z(F,pe),Z(W,me)),Ce},_.prototype.catch=function(F){return this.then(void 0,F)},_.prototype.T=function(F,W){function Z(){switch(pe.i){case 1:F(pe.j);break;case 2:W(pe.j);break;default:throw Error("Unexpected state: "+pe.i)}}var pe=this;this.h==null?U.i(Z):this.h.push(Z),this.u=!0},_.resolve=M,_.reject=function(F){return new _(function(W,Z){Z(F)})},_.race=function(F){return new _(function(W,Z){for(var pe=te(F),me=pe.next();!me.done;me=pe.next())M(me.value).T(W,Z)})},_.all=function(F){var W=te(F),Z=W.next();return Z.done?M([]):new _(function(pe,me){function Ce(Me){return function(Ge){De[Me]=Ge,--ve==0&&pe(De)}}var De=[],ve=0;do De.push(void 0),ve++,M(Z.value).T(Ce(De.length-1),me),Z=W.next();while(!Z.done)})},_}),He("Array.prototype.keys",function(l){return l||function(){return function(_,R){_ instanceof String&&(_+="");var M=0,V=!1,U={next:function(){if(!V&&M<_.length){var F=M++;return{value:R(F,_[F]),done:!1}}return V=!0,{done:!0,value:void 0}}};return U[Symbol.iterator]=function(){return U},U}(this,function(_){return _})}}),He("Array.prototype.fill",function(l){return l||function(_,R,M){var V=this.length||0;for(0>R&&(R=Math.max(0,V+R)),(M==null||M>V)&&(M=V),0>(M=Number(M))&&(M=Math.max(0,V+M)),R=Number(R||0);R<M;R++)this[R]=_;return this}}),He("Int8Array.prototype.fill",Rt),He("Uint8Array.prototype.fill",Rt),He("Uint8ClampedArray.prototype.fill",Rt),He("Int16Array.prototype.fill",Rt),He("Uint16Array.prototype.fill",Rt),He("Int32Array.prototype.fill",Rt),He("Uint32Array.prototype.fill",Rt),He("Float32Array.prototype.fill",Rt),He("Float64Array.prototype.fill",Rt),He("Object.is",function(l){return l||function(_,R){return _===R?_!==0||1/_==1/R:_!=_&&R!=R}}),He("Array.prototype.includes",function(l){return l||function(_,R){var M=this;M instanceof String&&(M=String(M));var V=M.length;for(0>(R=R||0)&&(R=Math.max(R+V,0));R<V;R++){var U=M[R];if(U===_||Object.is(U,_))return!0}return!1}}),He("String.prototype.includes",function(l){return l||function(_,R){if(this==null)throw new TypeError("The 'this' value for String.prototype.includes must not be null or undefined");if(_ instanceof RegExp)throw new TypeError("First argument to String.prototype.includes must not be a regular expression");return this.indexOf(_,R||0)!==-1}});var Kn=this||self;function fe(l,_){l=l.split(".");var R,M=Kn;for((l[0]in M)||M.execScript===void 0||M.execScript("var "+l[0]);l.length&&(R=l.shift());)l.length||_===void 0?M=M[R]&&M[R]!==Object.prototype[R]?M[R]:M[R]={}:M[R]=_}function de(l){var _;return(_=Kn.navigator)&&(_=_.userAgent)||(_=""),_.indexOf(l)!=-1}var je=Array.prototype.map?function(l,_){return Array.prototype.map.call(l,_,void 0)}:function(l,_){for(var R=l.length,M=Array(R),V=typeof l=="string"?l.split(""):l,U=0;U<R;U++)U in V&&(M[U]=_.call(void 0,V[U],U,l));return M},qe={},Oe=null;function ut(l){var _=l.length,R=3*_/4;R%3?R=Math.floor(R):"=.".indexOf(l[_-1])!=-1&&(R="=.".indexOf(l[_-2])!=-1?R-2:R-1);var M=new Uint8Array(R),V=0;return function(U,F){function W(ve){for(;Z<U.length;){var Me=U.charAt(Z++),Ge=Oe[Me];if(Ge!=null)return Ge;if(!/^[\s\xa0]*$/.test(Me))throw Error("Unknown base64 encoding at char: "+Me)}return ve}xt();for(var Z=0;;){var pe=W(-1),me=W(0),Ce=W(64),De=W(64);if(De===64&&pe===-1)break;F(pe<<2|me>>4),Ce!=64&&(F(me<<4&240|Ce>>2),De!=64&&F(Ce<<6&192|De))}}(l,function(U){M[V++]=U}),V!==R?M.subarray(0,V):M}function xt(){if(!Oe){Oe={};for(var l="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789".split(""),_=["+/=","+/","-_=","-_.","-_"],R=0;5>R;R++){var M=l.concat(_[R].split(""));qe[R]=M;for(var V=0;V<M.length;V++){var U=M[V];Oe[U]===void 0&&(Oe[U]=V)}}}}var ht=typeof Uint8Array!="undefined",Qt=!(de("Trident")||de("MSIE"))&&typeof Kn.btoa=="function";function $e(l){if(!Qt){var _;_===void 0&&(_=0),xt(),_=qe[_];for(var R=Array(Math.floor(l.length/3)),M=_[64]||"",V=0,U=0;V<l.length-2;V+=3){var F=l[V],W=l[V+1],Z=l[V+2],pe=_[F>>2];F=_[(3&F)<<4|W>>4],W=_[(15&W)<<2|Z>>6],Z=_[63&Z],R[U++]=pe+F+W+Z}switch(pe=0,Z=M,l.length-V){case 2:Z=_[(15&(pe=l[V+1]))<<2]||M;case 1:l=l[V],R[U]=_[l>>2]+_[(3&l)<<4|pe>>4]+Z+M}return R.join("")}for(_="";10240<l.length;)_+=String.fromCharCode.apply(null,l.subarray(0,10240)),l=l.subarray(10240);return _+=String.fromCharCode.apply(null,l),btoa(_)}var ke,Ht=RegExp("[-_.]","g");function ri(l){switch(l){case"-":return"+";case"_":return"/";case".":return"=";default:return""}}function Rr(l){if(!Qt)return ut(l);Ht.test(l)&&(l=l.replace(Ht,ri)),l=atob(l);for(var _=new Uint8Array(l.length),R=0;R<l.length;R++)_[R]=l.charCodeAt(R);return _}function Ar(){return ke||(ke=new Uint8Array(0))}var zt={},Dn=typeof Uint8Array.prototype.slice=="function",Ot=0,Wt=0;function en(l){var _=0>l,R=(l=Math.abs(l))>>>0;l=Math.floor((l-R)/4294967296),_&&(_=(R=te(pn(R,l))).next().value,l=R.next().value,R=_),Ot=R>>>0,Wt=l>>>0}var Uc,Cd=typeof BigInt=="function";function pn(l,_){return _=~_,l?l=1+~l:_+=1,[l,_]}function Ra(l,_){this.i=l>>>0,this.h=_>>>0}function ji(l){if(!l)return Uc||(Uc=new Ra(0,0));if(!/^-?\d+$/.test(l))return null;if(16>l.length)en(Number(l));else if(Cd)l=BigInt(l),Ot=Number(l&BigInt(4294967295))>>>0,Wt=Number(l>>BigInt(32)&BigInt(4294967295));else{var _=+(l[0]==="-");Wt=Ot=0;for(var R=l.length,M=_,V=(R-_)%6+_;V<=R;M=V,V+=6)M=Number(l.slice(M,V)),Wt*=1e6,4294967296<=(Ot=1e6*Ot+M)&&(Wt+=Ot/4294967296|0,Ot%=4294967296);_&&(l=(_=te(pn(Ot,Wt))).next().value,_=_.next().value,Ot=l,Wt=_)}return new Ra(Ot,Wt)}function Vc(l,_){return Error("Invalid wire type: "+l+" (at position "+_+")")}function tt(){return Error("Failed to read varint, encoding is invalid.")}function ns(l,_){return Error("Tried to read past the end of the data "+_+" > "+l)}function Pr(){throw Error("Invalid UTF8")}function vt(l,_){return _=String.fromCharCode.apply(null,_),l==null?_:l+_}var Bi,jc,Bc,fn=void 0,dr=typeof TextDecoder!="undefined",Xn=typeof TextEncoder!="undefined";function rs(l){if(l!==zt)throw Error("illegal external caller")}function Dr(l,_){if(rs(_),this.V=l,l!=null&&l.length===0)throw Error("ByteString should be constructed with non-empty values")}function Aa(){return Bc||(Bc=new Dr(null,zt))}function is(l){rs(zt);var _=l.V;return(_=_==null||ht&&_!=null&&_ instanceof Uint8Array?_:typeof _=="string"?Rr(_):null)==null?_:l.V=_}function as(l,_){this.i=null,this.m=!1,this.h=this.j=this.l=0,Pa(this,l,_)}function Pa(l,_,R){R=R===void 0?{}:R,l.S=R.S!==void 0&&R.S,_&&(_=function(M){if(typeof M=="string")return{buffer:Rr(M),C:!1};if(Array.isArray(M))return{buffer:new Uint8Array(M),C:!1};if(M.constructor===Uint8Array)return{buffer:M,C:!1};if(M.constructor===ArrayBuffer)return{buffer:new Uint8Array(M),C:!1};if(M.constructor===Dr)return{buffer:is(M)||Ar(),C:!0};if(M instanceof Uint8Array)return{buffer:new Uint8Array(M.buffer,M.byteOffset,M.byteLength),C:!1};throw Error("Type not convertible to a Uint8Array, expected a Uint8Array, an ArrayBuffer, a base64 encoded string, a ByteString or an Array of numbers")}(_),l.i=_.buffer,l.m=_.C,l.l=0,l.j=l.i.length,l.h=l.l)}function mn(l,_){if(l.h=_,_>l.j)throw ns(l.j,_)}function ii(l){var _=l.i,R=l.h,M=_[R++],V=127&M;if(128&M&&(V|=(127&(M=_[R++]))<<7,128&M&&(V|=(127&(M=_[R++]))<<14,128&M&&(V|=(127&(M=_[R++]))<<21,128&M&&(V|=(M=_[R++])<<28,128&M&&128&_[R++]&&128&_[R++]&&128&_[R++]&&128&_[R++]&&128&_[R++])))))throw tt();return mn(l,R),V}function Fc(l,_){if(0>_)throw Error("Tried to read a negative byte length: "+_);var R=l.h,M=R+_;if(M>l.j)throw ns(_,l.j-R);return l.h=M,R}as.prototype.reset=function(){this.h=this.l};var os=[];function Da(){this.h=[]}function Gc(l,_,R){for(;0<R||127<_;)l.h.push(127&_|128),_=(_>>>7|R<<25)>>>0,R>>>=7;l.h.push(_)}function Lr(l,_){for(;127<_;)l.h.push(127&_|128),_>>>=7;l.h.push(_)}function ss(l,_){if(os.length){var R=os.pop();Pa(R,l,_),l=R}else l=new as(l,_);this.h=l,this.j=this.h.h,this.i=this.l=-1,this.setOptions(_)}function Hc(l){var _=l.h;if(_.h==_.j)return!1;l.j=l.h.h;var R=ii(l.h)>>>0;if(_=R>>>3,!(0<=(R&=7)&&5>=R))throw Vc(R,l.j);if(1>_)throw Error("Invalid field number: "+_+" (at position "+l.j+")");return l.l=_,l.i=R,!0}function Or(l){switch(l.i){case 0:if(l.i!=0)Or(l);else e:{for(var _=(l=l.h).h,R=_+10,M=l.i;_<R;)if((128&M[_++])==0){mn(l,_);break e}throw tt()}break;case 1:mn(l=l.h,l.h+8);break;case 2:l.i!=2?Or(l):(_=ii(l.h)>>>0,mn(l=l.h,l.h+_));break;case 5:mn(l=l.h,l.h+4);break;case 3:for(_=l.l;;){if(!Hc(l))throw Error("Unmatched start-group tag: stream EOF");if(l.i==4){if(l.l!=_)throw Error("Unmatched end-group tag");break}Or(l)}break;default:throw Vc(l.i,l.j)}}Da.prototype.length=function(){return this.h.length},Da.prototype.end=function(){var l=this.h;return this.h=[],l},ss.prototype.setOptions=function(l){l=l===void 0?{}:l,this.ca=l.ca!==void 0&&l.ca},ss.prototype.reset=function(){this.h.reset(),this.j=this.h.h,this.i=this.l=-1};var La=[];function ai(){this.j=[],this.i=0,this.h=new Da}function oi(l,_){_.length!==0&&(l.j.push(_),l.i+=_.length)}var Qn=typeof Symbol=="function"&&Q(Symbol())==="symbol"?Symbol():void 0;function Mr(l,_){return Qn?l[Qn]|=_:l.A!==void 0?l.A|=_:(Object.defineProperties(l,{A:{value:_,configurable:!0,writable:!0,enumerable:!1}}),_)}function vn(l,_){Qn?l[Qn]&&(l[Qn]&=~_):l.A!==void 0&&(l.A&=~_)}function It(l){var _;return(_=Qn?l[Qn]:l.A)==null?0:_}function Ln(l,_){Qn?l[Qn]=_:l.A!==void 0?l.A=_:Object.defineProperties(l,{A:{value:_,configurable:!0,writable:!0,enumerable:!1}})}function hr(l){return Mr(l,1),l}function cs(l,_){Ln(_,-51&(0|l))}function si(l,_){Ln(_,-41&(18|l))}var Fi={};function Oa(l){return l!==null&&Q(l)==="object"&&!Array.isArray(l)&&l.constructor===Object}var pr,Gi,zc=[];function Hi(l){if(2&It(l.o))throw Error("Cannot mutate an immutable Message")}function us(l){var _=l.length;(_=_?l[_-1]:void 0)&&Oa(_)?_.g=1:(_={},l.push((_.g=1,_)))}function ls(l){var _=l.i+l.G;return l.B||(l.B=l.o[_]={})}function tn(l,_){return _===-1?null:_>=l.i?l.B?l.B[_]:void 0:l.o[_+l.G]}function xn(l,_,R,M){Hi(l),zi(l,_,R,M)}function zi(l,_,R,M){l.j&&(l.j=void 0),_>=l.i||M?ls(l)[_]=R:(l.o[_+l.G]=R,(l=l.B)&&_ in l&&delete l[_])}function ds(l,_,R,M){var V=tn(l,_);Array.isArray(V)||(V=pr);var U=It(V);if(1&U||hr(V),M)2&U||Mr(V,2),1&R||Object.freeze(V);else{M=!(2&R);var F=2&U;1&R||!F?M&&16&U&&!F&&vn(V,16):zi(l,_,V=hr(Array.prototype.slice.call(V)))}return V}function Ut(l,_){var R=tn(l,_),M=R==null?R:typeof R=="number"||R==="NaN"||R==="Infinity"||R==="-Infinity"?Number(R):void 0;return M!=null&&M!==R&&zi(l,_,M),M}function Wc(l,_,R,M,V){l.h||(l.h={});var U=l.h[R],F=ds(l,R,3,V);if(!U){var W=F;U=[];var Z=!!(16&It(l.o));F=!!(2&It(W));var pe=W;!V&&F&&(W=Array.prototype.slice.call(W));for(var me=F,Ce=0;Ce<W.length;Ce++){var De=W[Ce],ve=_,Me=!1;if(Me=Me!==void 0&&Me,(De=Array.isArray(De)?new ve(De):Me?new ve:void 0)!==void 0){var Ge=Me=It(ve=De.o);F&&(Ge|=2),Z&&(Ge|=16),Ge!=Me&&Ln(ve,Ge),ve=Ge,me=me||!!(2&ve),U.push(De)}}return l.h[R]=U,_=33|(Z=It(W)),Z!=(_=me?-9&_:8|_)&&(me=W,Object.isFrozen(me)&&(me=Array.prototype.slice.call(me)),Ln(me,_),W=me),pe!==W&&zi(l,R,W),(V||M&&F)&&Mr(U,2),M&&Object.freeze(U),U}return V||(V=Object.isFrozen(U),M&&!V?Object.freeze(U):!M&&V&&(U=Array.prototype.slice.call(U),l.h[R]=U)),U}function hs(l,_,R){var M=!!(2&It(l.o));if(_=Wc(l,_,R,M,M),l=ds(l,R,3,M),!(M||8&It(l))){for(M=0;M<_.length;M++){if(2&It((R=_[M]).o)){var V=ms(R,!1);V.j=R}else V=R;R!==V&&(_[M]=V,l[M]=V.o)}Mr(l,8)}return _}function rt(l,_,R){if(R!=null&&typeof R!="number")throw Error("Value of float/double field must be a number|null|undefined, found "+Q(R)+": "+R);xn(l,_,R)}function qc(l,_,R,M,V){Hi(l);var U=Wc(l,R,_,!1,!1);return R=M!=null?M:new R,l=ds(l,_,2,!1),V!=null?(U.splice(V,0,R),l.splice(V,0,R.o)):(U.push(R),l.push(R.o)),R.C()&&vn(l,8),R}function Ma(l,_){return l==null?_:l}function On(l,_,R){return R=R===void 0?0:R,Ma(Ut(l,_),R)}function Jc(l,_,R,M){if(l!=null){if(Array.isArray(l))l=ci(l,_,R,M!==void 0);else if(Oa(l)){var V,U={};for(V in l)U[V]=Jc(l[V],_,R,M);l=U}else l=_(l,M);return l}}function ci(l,_,R,M){var V=It(l);M=M?!!(16&V):void 0,l=Array.prototype.slice.call(l);for(var U=0;U<l.length;U++)l[U]=Jc(l[U],_,R,M);return R(V,l),l}function Rd(l){return l.ja===Fi?l.toJSON():function(_){switch(Q(_)){case"number":return isFinite(_)?_:String(_);case"object":if(_)if(Array.isArray(_)){if((128&It(_))!=0)return us(_=Array.prototype.slice.call(_)),_}else{if(ht&&_!=null&&_ instanceof Uint8Array)return $e(_);if(_ instanceof Dr){var R=_.V;return R==null?"":typeof R=="string"?R:_.V=$e(R)}}}return _}(l)}function Ad(l,_){128&l&&us(_)}function ps(l,_,R){if(R=R===void 0?si:R,l!=null){if(ht&&l instanceof Uint8Array)return l.length?new Dr(new Uint8Array(l),zt):Aa();if(Array.isArray(l)){var M=It(l);return 2&M?l:!_||32&M||!(16&M||M===0)?(4&(_=It(l=ci(l,ps,4&M?si:R,!0)))&&2&_&&Object.freeze(l),l):(Ln(l,2|M),l)}return l.ja===Fi?fs(l):l}}function Kc(l,_,R,M,V,U,F){if(l=l.h&&l.h[R]){if(2&(M=It(l))?M=l:(si(M,U=je(l,fs)),Object.freeze(U),M=U),Hi(_),F=M==null?pr:hr([]),M!=null){for(U=!!M.length,l=0;l<M.length;l++){var W=M[l];U=U&&!(2&It(W.o)),F[l]=W.o}U=1|(U?8:0),((l=It(F))&U)!==U&&(Object.isFrozen(F)&&(F=Array.prototype.slice.call(F)),Ln(F,l|U)),_.h||(_.h={}),_.h[R]=M}else _.h&&(_.h[R]=void 0);zi(_,R,F,V)}else xn(_,R,ps(M,U,F),V)}function fs(l){return 2&It(l.o)||Mr((l=ms(l,!0)).o,2),l}function ms(l,_){var R=l.o,M=[];Mr(M,16);var V=l.constructor.h;if(V&&M.push(V),V=l.B){M.length=R.length,M.fill(void 0,M.length,R.length);var U={};M[M.length-1]=U}(128&It(R))!=0&&us(M),_=_||l.C()?si:cs,U=l.constructor,Gi=M,M=new U(M),Gi=void 0,l.R&&(M.R=l.R.slice()),U=!!(16&It(R));for(var F=V?R.length-1:R.length,W=0;W<F;W++)Kc(l,M,W-l.G,R[W],!1,U,_);if(V)for(var Z in V)Kc(l,M,+Z,V[Z],!0,U,_);return M}function Mt(l,_,R){l==null&&(l=Gi),Gi=void 0;var M,V=this.constructor.i||0,U=0<V,F=this.constructor.h,W=!1;if(l==null){var Z=48,pe=!0;U&&(V=0,Z|=128),Ln(l=F?[F]:[],Z)}else{if(!Array.isArray(l)||F&&F!==l[0])throw Error();var me=Z=Mr(l,0);if((pe=(16&me)!=0)&&((W=(32&me)!=0)||(me|=32)),U){if(128&me)V=0;else if(0<l.length){var Ce=l[l.length-1];if(Oa(Ce)&&"g"in Ce){V=0,me|=128,delete Ce.g;var De,ve=!0;for(De in Ce){ve=!1;break}ve&&l.pop()}}}else if(128&me)throw Error();Z!==me&&Ln(l,me)}if(this.G=(F?0:-1)-V,this.h=void 0,this.o=l,V=(F=this.o.length)-1,F&&Oa(F=this.o[V])?(this.B=F,this.i=V-this.G):_!==void 0&&-1<_?(this.i=Math.max(_,V+1-this.G),this.B=void 0):this.i=Number.MAX_VALUE,!U&&this.B&&"g"in this.B)throw Error('Unexpected "g" flag in sparse object of message that is not a group type.');if(R)for(_=pe&&!W&&!0,U=this.i,pe=0;pe<R.length;pe++)(W=R[pe])<U?(V=l[W+=this.G])?fr(V,_):l[W]=pr:(M||(M=ls(this)),(V=M[W])?fr(V,_):M[W]=pr)}function fr(l,_){if(Array.isArray(l)){var R=It(l),M=1;!_||2&R||(M|=16),(R&M)!==M&&Ln(l,R|M)}}function vs(l,_,R){if(R){var M,V={};for(M in R){var U=R[M],F=U.ra;F||(V.J=U.xa||U.oa.W,U.ia?(V.aa=$c(U.ia),F=function(W){return function(Z,pe,me){return W.J(Z,pe,me,W.aa)}}(V)):U.ka?(V.Z=Zc(U.da.P,U.ka),F=function(W){return function(Z,pe,me){return W.J(Z,pe,me,W.Z)}}(V)):F=V.J,U.ra=F),F(_,l,U.da),V={J:V.J,aa:V.aa,Z:V.Z}}}(function(W,Z){if(Z=Z.R){oi(W,W.h.end());for(var pe=0;pe<Z.length;pe++)oi(W,is(Z[pe])||Ar())}})(_,l)}Ln(zc,23),pr=Object.freeze(zc),Mt.prototype.toJSON=function(){return ci(this.o,Rd,Ad)},Mt.prototype.C=function(){return!!(2&It(this.o))},Mt.prototype.ja=Fi,Mt.prototype.toString=function(){return this.o.toString()};var Na=Symbol();function at(l,_,R){return l[Na]||(l[Na]=function(M,V){return _(M,V,R)})}function Xc(l){var _=l[Na];if(!_){var R=_s(l);_=function(M,V){return nu(M,V,R)},l[Na]=_}return _}function Qc(l){var _=function(V){var U=V.ia;return U?Xc(U):(U=V.wa)?at(V.da.P,U,V.ka):void 0}(l),R=l.da,M=l.oa.U;return _?function(V,U){return M(V,U,R,_)}:function(V,U){return M(V,U,R)}}function gs(l,_){var R=l[_];return typeof R=="function"&&R.length===0&&(R=R(),l[_]=R),Array.isArray(R)&&(qi in R||Nr in R||0<R.length&&typeof R[0]=="function")?R:void 0}function Yc(l,_,R,M,V,U){_.P=l[0];var F=1;if(l.length>F&&typeof l[F]!="number"){var W=l[F++];R(_,W)}for(;F<l.length;){R=l[F++];for(var Z=F+1;Z<l.length&&typeof l[Z]!="number";)Z++;switch(W=l[F++],Z-=F){case 0:M(_,R,W);break;case 1:(Z=gs(l,F))?(F++,V(_,R,W,Z)):M(_,R,W,l[F++]);break;case 2:V(_,R,W,Z=gs(l,Z=F++),l[F++]);break;case 3:U(_,R,W,l[F++],l[F++],l[F++]);break;case 4:U(_,R,W,l[F++],l[F++],l[F++],l[F++]);break;default:throw Error("unexpected number of binary field arguments: "+Z)}}return _}var Ua=Symbol();function $c(l){var _=l[Ua];if(!_){var R=Wi(l);_=function(M,V){return ru(M,V,R)},l[Ua]=_}return _}function Zc(l,_){var R=l[Ua];return R||(R=function(M,V){return vs(M,V,_)},l[Ua]=R),R}var Nr=Symbol();function Pd(l,_){l.push(_)}function Dd(l,_,R){l.push(_,R.W)}function Va(l,_,R,M){var V=$c(M),U=Wi(M).P,F=R.W;l.push(_,function(W,Z,pe){return F(W,Z,pe,U,V)})}function eu(l,_,R,M,V,U){var F=Zc(M,U),W=R.W;l.push(_,function(Z,pe,me){return W(Z,pe,me,M,F)})}function Wi(l){var _=l[Nr];return _||(_=Yc(l,l[Nr]=[],Pd,Dd,Va,eu),qi in l&&Nr in l&&(l.length=0),_)}var qi=Symbol();function ja(l,_){l[0]=_}function Ld(l,_,R,M){var V=R.U;l[_]=M?function(U,F,W){return V(U,F,W,M)}:V}function tu(l,_,R,M,V){var U=R.U,F=Xc(M),W=_s(M).P;l[_]=function(Z,pe,me){return U(Z,pe,me,W,F,V)}}function Od(l,_,R,M,V,U,F){var W=R.U,Z=at(M,V,U);l[_]=function(pe,me,Ce){return W(pe,me,Ce,M,Z,F)}}function _s(l){var _=l[qi];return _||(_=Yc(l,l[qi]={},ja,Ld,tu,Od),qi in l&&Nr in l&&(l.length=0),_)}function nu(l,_,R){for(;Hc(_)&&_.i!=4;){var M=_.l,V=R[M];if(!V){var U=R[0];U&&(U=U[M])&&(V=R[M]=Qc(U))}if(!V||!V(_,l,M)){M=l,U=(V=_).j,Or(V);var F=V;if(!F.ca){if(V=F.h.h-U,F.h.h=U,F=F.h,V==0)V=Aa();else{if(U=Fc(F,V),F.S&&F.m)V=F.i.subarray(U,U+V);else{F=F.i;var W=U;V=W===(V=U+V)?Ar():Dn?F.slice(W,V):new Uint8Array(F.subarray(W,V))}V=V.length==0?Aa():new Dr(V,zt)}(U=M.R)?U.push(V):M.R=[V]}}}return l}function ru(l,_,R){for(var M=R.length,V=M%2==1,U=V?1:0;U<M;U+=2)(0,R[U+1])(_,l,R[U]);vs(l,_,V?R[0]:void 0)}function Ji(l,_){return{U:l,W:_}}var In=Ji(function(l,_,R){if(l.i!==5)return!1;var M=(l=l.h).i,V=l.h,U=M[V],F=M[V+1],W=M[V+2];return M=M[V+3],mn(l,l.h+4),l=2*((F=(U<<0|F<<8|W<<16|M<<24)>>>0)>>31)+1,U=F>>>23&255,F&=8388607,xn(_,R,U==255?F?NaN:1/0*l:U==0?l*Math.pow(2,-149)*F:l*Math.pow(2,U-150)*(F+Math.pow(2,23))),!0},function(l,_,R){if((_=Ut(_,R))!=null){Lr(l.h,8*R+5),l=l.h;var M=+_;M===0?0<1/M?Ot=Wt=0:(Wt=0,Ot=2147483648):isNaN(M)?(Wt=0,Ot=2147483647):34028234663852886e22<(M=(R=0>M?-2147483648:0)?-M:M)?(Wt=0,Ot=(2139095040|R)>>>0):11754943508222875e-54>M?(M=Math.round(M/Math.pow(2,-149)),Wt=0,Ot=(R|M)>>>0):(_=Math.floor(Math.log(M)/Math.LN2),M*=Math.pow(2,-_),16777216<=(M=Math.round(8388608*M))&&++_,Wt=0,Ot=(R|_+127<<23|8388607&M)>>>0),R=Ot,l.h.push(R>>>0&255),l.h.push(R>>>8&255),l.h.push(R>>>16&255),l.h.push(R>>>24&255)}}),Md=Ji(function(l,_,R){if(l.i!==0)return!1;var M=l.h,V=0,U=l=0,F=M.i,W=M.h;do{var Z=F[W++];V|=(127&Z)<<U,U+=7}while(32>U&&128&Z);for(32<U&&(l|=(127&Z)>>4),U=3;32>U&&128&Z;U+=7)l|=(127&(Z=F[W++]))<<U;if(mn(M,W),!(128>Z))throw tt();return M=V>>>0,(l=2147483648&(Z=l>>>0))&&(Z=~Z>>>0,(M=1+~M>>>0)==0&&(Z=Z+1>>>0)),M=4294967296*Z+(M>>>0),xn(_,R,l?-M:M),!0},function(l,_,R){(_=tn(_,R))!=null&&(typeof _=="string"&&ji(_),_!=null&&(Lr(l.h,8*R),typeof _=="number"?(l=l.h,en(_),Gc(l,Ot,Wt)):(R=ji(_),Gc(l.h,R.i,R.h))))}),Nd=Ji(function(l,_,R){return l.i===0&&(xn(_,R,ii(l.h)),!0)},function(l,_,R){if((_=tn(_,R))!=null&&_!=null)if(Lr(l.h,8*R),l=l.h,0<=(R=_))Lr(l,R);else{for(_=0;9>_;_++)l.h.push(127&R|128),R>>=7;l.h.push(1)}}),ys=Ji(function(l,_,R){if(l.i!==2)return!1;var M=ii(l.h)>>>0,V=Fc(l=l.h,M);if(l=l.i,dr){var U,F=l;(U=Bi)||(U=Bi=new TextDecoder("utf-8",{fatal:!0})),l=V+M,F=V===0&&l===F.length?F:F.subarray(V,l);try{var W=U.decode(F)}catch(Ce){if(fn===void 0){try{U.decode(new Uint8Array([128]))}catch(De){}try{U.decode(new Uint8Array([97])),fn=!0}catch(De){fn=!1}}throw!fn&&(Bi=void 0),Ce}}else{M=(W=V)+M,V=[];for(var Z,pe,me=null;W<M;)128>(Z=l[W++])?V.push(Z):224>Z?W>=M?Pr():(pe=l[W++],194>Z||(192&pe)!=128?(W--,Pr()):V.push((31&Z)<<6|63&pe)):240>Z?W>=M-1?Pr():(192&(pe=l[W++]))!=128||Z===224&&160>pe||Z===237&&160<=pe||(192&(F=l[W++]))!=128?(W--,Pr()):V.push((15&Z)<<12|(63&pe)<<6|63&F):244>=Z?W>=M-2?Pr():(192&(pe=l[W++]))!=128||pe-144+(Z<<28)>>30!=0||(192&(F=l[W++]))!=128||(192&(U=l[W++]))!=128?(W--,Pr()):(Z=(7&Z)<<18|(63&pe)<<12|(63&F)<<6|63&U,Z-=65536,V.push(55296+(Z>>10&1023),56320+(1023&Z))):Pr(),8192<=V.length&&(me=vt(me,V),V.length=0);W=vt(me,V)}return xn(_,R,W),!0},function(l,_,R){if((_=tn(_,R))!=null){var M=!1;if(M=M!==void 0&&M,Xn){if(M&&/(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])/.test(_))throw Error("Found an unpaired surrogate");_=(jc||(jc=new TextEncoder)).encode(_)}else{for(var V=0,U=new Uint8Array(3*_.length),F=0;F<_.length;F++){var W=_.charCodeAt(F);if(128>W)U[V++]=W;else{if(2048>W)U[V++]=W>>6|192;else{if(55296<=W&&57343>=W){if(56319>=W&&F<_.length){var Z=_.charCodeAt(++F);if(56320<=Z&&57343>=Z){W=1024*(W-55296)+Z-56320+65536,U[V++]=W>>18|240,U[V++]=W>>12&63|128,U[V++]=W>>6&63|128,U[V++]=63&W|128;continue}F--}if(M)throw Error("Found an unpaired surrogate");W=65533}U[V++]=W>>12|224,U[V++]=W>>6&63|128}U[V++]=63&W|128}}_=V===U.length?U:U.subarray(0,V)}Lr(l.h,8*R+2),Lr(l.h,_.length),oi(l,l.h.end()),oi(l,_)}}),At=Ji(function(l,_,R,M,V){if(l.i!==2)return!1;_=qc(_,R,M),R=l.h.j,M=ii(l.h)>>>0;var U=l.h.h+M,F=U-R;if(0>=F&&(l.h.j=U,V(_,l,void 0,void 0,void 0),F=U-l.h.h),F)throw Error("Message parsing ended unexpectedly. Expected to read "+M+" bytes, instead read "+(M-F)+" bytes, either the data ended unexpectedly or the message misreported its own length");return l.h.h=U,l.h.j=R,!0},function(l,_,R,M,V){if((_=hs(_,M,R))!=null)for(M=0;M<_.length;M++){var U=l;Lr(U.h,8*R+2);var F=U.h.end();oi(U,F),F.push(U.i),U=F,V(_[M],l),F=l;var W=U.pop();for(W=F.i+F.h.length()-W;127<W;)U.push(127&W|128),W>>>=7,F.i++;U.push(W),F.i++}});function Ba(l){return function(_,R){e:{if(La.length){var M=La.pop();M.setOptions(R),Pa(M.h,_,R),_=M}else _=new ss(_,R);try{var V=_s(l),U=nu(new V.P,_,V);break e}finally{(V=_.h).i=null,V.m=!1,V.l=0,V.j=0,V.h=0,V.S=!1,_.l=-1,_.i=-1,100>La.length&&La.push(_)}U=void 0}return U}}function bs(l){return function(){var _=new ai;ru(this,_,Wi(l)),oi(_,_.h.end());for(var R=new Uint8Array(_.i),M=_.j,V=M.length,U=0,F=0;F<V;F++){var W=M[F];R.set(W,U),U+=W.length}return _.j=[R],R}}function ui(l){Mt.call(this,l)}Dt(ui,Mt);var iu=[ui,1,Nd,2,In,3,ys,4,ys];function yt(l){Mt.call(this,l,-1,Ud)}ui.prototype.l=bs(iu),Dt(yt,Mt),yt.prototype.addClassification=function(l,_){return qc(this,1,ui,l,_),this};var Ud=[1],Vd=Ba([yt,1,At,iu]);function Ki(l){Mt.call(this,l)}Dt(Ki,Mt);var Xi=[Ki,1,In,2,In,3,In,4,In,5,In];function Ss(l){Mt.call(this,l,-1,jd)}Ki.prototype.l=bs(Xi),Dt(Ss,Mt);var jd=[1],ks=Ba([Ss,1,At,Xi]);function Fa(l){Mt.call(this,l)}Dt(Fa,Mt);var au=[Fa,1,In,2,In,3,In,4,In,5,In,6,Md],Bd=Ba(au);function ou(l,_,R){if(R=l.createShader(R===0?l.VERTEX_SHADER:l.FRAGMENT_SHADER),l.shaderSource(R,_),l.compileShader(R),!l.getShaderParameter(R,l.COMPILE_STATUS))throw Error(`Could not compile WebGL shader.
|
|
531
|
+
`},ce=X.vertexShaderSource,z=X.fragmentShaderSource;this.program=Ye(oe,[ce,z]);var re=oe.getAttribLocation(this.program,"position"),be=oe.getAttribLocation(this.program,"texCoord"),ue=this.program;this.virtualParams={resolutionLocation:oe.getUniformLocation(ue,"resolution"),imageLocation0:oe.getUniformLocation(ue,"u_image0"),imageLocation1:oe.getUniformLocation(ue,"u_image1"),imageLocation2:oe.getUniformLocation(ue,"u_image2"),imageOldLocation0:oe.getUniformLocation(ue,"u_image_old0"),imageOldLocation1:oe.getUniformLocation(ue,"u_image_old1"),imageOldLocation2:oe.getUniformLocation(ue,"u_image_old2"),imageOldLocation3:oe.getUniformLocation(ue,"u_image_old3"),imageOldLocation4:oe.getUniformLocation(ue,"u_image_old4"),imageOldLocation5:oe.getUniformLocation(ue,"u_image_old5")},this.virtualLocation={postProcessTypeLocation:oe.getUniformLocation(ue,"PostProcessType"),sigmaLocation:oe.getUniformLocation(ue,"SIGMA"),bSigmaLocation:oe.getUniformLocation(ue,"BSIGMA"),mSizeLocation:oe.getUniformLocation(ue,"MSIZE"),overlayTypeLocation:oe.getUniformLocation(ue,"overlayType"),hardThresholdLocation:oe.getUniformLocation(ue,"hardThreshold"),sigmoidClipLocation:oe.getUniformLocation(ue,"sigmoidClip")},oe.bindVertexArray(this.vao),oe.bindBuffer(oe.ARRAY_BUFFER,this.positionBuffer),oe.enableVertexAttribArray(re),oe.vertexAttribPointer(re,2,oe.FLOAT,!1,0,0),oe.bindBuffer(oe.ARRAY_BUFFER,oe.createBuffer()),oe.bufferData(oe.ARRAY_BUFFER,new Float32Array([0,0,1,0,0,1,0,1,1,0,1,1]),oe.STATIC_DRAW),oe.enableVertexAttribArray(be),oe.vertexAttribPointer(be,2,oe.FLOAT,!1,0,0)}},{key:"onVirtualResults",value:function(oe){var X=oe.segmentationMask,ce=oe.image,z=this.gl;this.maskBuffer.length<3&&this.maskBuffer.push(X,X,X),this.frameBuffer.length<3&&this.frameBuffer.push(ce,ce,ce);for(var re=[],be=[X,ce,this.img,this.maskBuffer[0],this.maskBuffer[1],this.maskBuffer[2],this.frameBuffer[0],this.frameBuffer[1],this.frameBuffer[2]],ue=0;ue<be.length;++ue)this.sourceTexture=z.createTexture(),z.bindTexture(z.TEXTURE_2D,this.sourceTexture),z.texParameteri(z.TEXTURE_2D,z.TEXTURE_WRAP_S,z.CLAMP_TO_EDGE),z.texParameteri(z.TEXTURE_2D,z.TEXTURE_WRAP_T,z.CLAMP_TO_EDGE),z.texParameteri(z.TEXTURE_2D,z.TEXTURE_MIN_FILTER,z.NEAREST),z.texParameteri(z.TEXTURE_2D,z.TEXTURE_MAG_FILTER,z.NEAREST),z.texImage2D(z.TEXTURE_2D,0,z.RGBA,z.RGBA,z.UNSIGNED_BYTE,be[ue]),re.push(this.sourceTexture);z.bindBuffer(z.ARRAY_BUFFER,this.positionBuffer),this.setRectangle(z,0,0,this.width,this.height),z.viewport(0,0,this.width,this.height),z.clearColor(0,0,0,0),z.clear(z.COLOR_BUFFER_BIT|z.DEPTH_BUFFER_BIT),z.useProgram(this.program),z.bindVertexArray(this.vao);var ye=this.virtualParams,Me=ye.resolutionLocation,Jt=ye.imageLocation0,Zt=ye.imageLocation1,Ke=ye.imageLocation2,qt=ye.imageOldLocation0,ft=ye.imageOldLocation1,Jn=ye.imageOldLocation2,hr=ye.imageOldLocation3,Ht=ye.imageOldLocation4,Rn=ye.imageOldLocation5;z.uniform2f(Me,this.width,this.height);var Ze=this.virtualOption,Gt=Ze.postProcess,qn=Ze.kSize,he=Ze.sigma,de=Ze.bSigma,Ne=Ze.overlayType,We=Ze.hardThreshold,De=Ze.sigmoidClip,ut=this.virtualLocation,rt=ut.postProcessTypeLocation,Ut=ut.mSizeLocation,en=ut.sigmaLocation,pe=ut.bSigmaLocation,Ot=ut.overlayTypeLocation,Kt=ut.hardThresholdLocation,fr=ut.sigmoidClipLocation;z.uniform1i(rt,Gt),z.uniform1i(Ut,qn),z.uniform1f(en,he),z.uniform1f(pe,de),z.uniform1i(Ot,Ne),z.uniform1f(Kt,We),z.uniform1i(fr,De),z.uniform1i(Jt,0),z.uniform1i(Zt,1),z.uniform1i(Ke,2),z.uniform1i(qt,3),z.uniform1i(ft,4),z.uniform1i(Jn,5),z.uniform1i(hr,6),z.uniform1i(Ht,7),z.uniform1i(Rn,8),z.activeTexture(z.TEXTURE0),z.bindTexture(z.TEXTURE_2D,re[0]),z.activeTexture(z.TEXTURE1),z.bindTexture(z.TEXTURE_2D,re[1]),z.activeTexture(z.TEXTURE2),z.bindTexture(z.TEXTURE_2D,re[2]),z.activeTexture(z.TEXTURE3),z.bindTexture(z.TEXTURE_2D,re[3]),z.activeTexture(z.TEXTURE4),z.bindTexture(z.TEXTURE_2D,re[4]),z.activeTexture(z.TEXTURE5),z.bindTexture(z.TEXTURE_2D,re[5]),z.activeTexture(z.TEXTURE6),z.bindTexture(z.TEXTURE_2D,re[6]),z.activeTexture(z.TEXTURE7),z.bindTexture(z.TEXTURE_2D,re[7]),z.activeTexture(z.TEXTURE8),z.bindTexture(z.TEXTURE_2D,re[8]),z.drawArrays(z.TRIANGLES,0,6),this.maskBuffer[0]=this.maskBuffer[1],this.maskBuffer[1]=this.maskBuffer[2],this.maskBuffer[2]=X,this.frameBuffer[0]=this.frameBuffer[1],this.frameBuffer[1]=this.frameBuffer[2],this.frameBuffer[2]=ce}}]),le}(),Jo=typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:{};(function(){var le;function Te(d){var g=0;return function(){return g<d.length?{done:!1,value:d[g++]}:{done:!0}}}var Se=typeof Object.defineProperties=="function"?Object.defineProperty:function(d,g,C){return d==Array.prototype||d==Object.prototype||(d[g]=C.value),d},je=function(d){d=[(typeof globalThis=="undefined"?"undefined":$(globalThis))=="object"&&globalThis,d,(typeof window=="undefined"?"undefined":$(window))=="object"&&window,(typeof self=="undefined"?"undefined":$(self))=="object"&&self,$(Jo)=="object"&&Jo];for(var g=0;g<d.length;++g){var C=d[g];if(C&&C.Math==Math)return C}throw Error("Cannot find global object")}(this);function He(d,g){if(g)e:{var C=je;d=d.split(".");for(var O=0;O<d.length-1;O++){var B=d[O];if(!(B in C))break e;C=C[B]}(g=g(O=C[d=d[d.length-1]]))!=O&&g!=null&&Se(C,d,{configurable:!0,writable:!0,value:g})}}function oe(d){return(d={next:d})[Symbol.iterator]=function(){return this},d}function X(d){var g=typeof Symbol!="undefined"&&Symbol.iterator&&d[Symbol.iterator];return g?g.call(d):{next:Te(d)}}function ce(d){if(!(d instanceof Array)){d=X(d);for(var g,C=[];!(g=d.next()).done;)C.push(g.value);d=C}return d}He("Symbol",function(d){function g(B,M){this.h=B,Se(this,"description",{configurable:!0,writable:!0,value:M})}if(d)return d;g.prototype.toString=function(){return this.h};var C="jscomp_symbol_"+(1e9*Math.random()>>>0)+"_",O=0;return function B(M){if(this instanceof B)throw new TypeError("Symbol is not a constructor");return new g(C+(M||"")+"_"+O++,M)}}),He("Symbol.iterator",function(d){if(d)return d;d=Symbol("Symbol.iterator");for(var g="Array Int8Array Uint8Array Uint8ClampedArray Int16Array Uint16Array Int32Array Uint32Array Float32Array Float64Array".split(" "),C=0;C<g.length;C++){var O=je[g[C]];typeof O=="function"&&typeof O.prototype[d]!="function"&&Se(O.prototype,d,{configurable:!0,writable:!0,value:function(){return oe(Te(this))}})}return d});var z=typeof Object.assign=="function"?Object.assign:function(d,g){for(var C=1;C<arguments.length;C++){var O=arguments[C];if(O)for(var B in O)Object.prototype.hasOwnProperty.call(O,B)&&(d[B]=O[B])}return d};He("Object.assign",function(d){return d||z});var re,be=typeof Object.create=="function"?Object.create:function(d){function g(){}return g.prototype=d,new g};if(typeof Object.setPrototypeOf=="function")re=Object.setPrototypeOf;else{var ue;e:{var ye={};try{ye.__proto__={a:!0},ue=ye.a;break e}catch(d){}ue=!1}re=ue?function(d,g){if(d.__proto__=g,d.__proto__!==g)throw new TypeError(d+" is not extensible");return d}:null}var Me=re;function Jt(d,g){if(d.prototype=be(g.prototype),d.prototype.constructor=d,Me)Me(d,g);else for(var C in g)if(C!="prototype")if(Object.defineProperties){var O=Object.getOwnPropertyDescriptor(g,C);O&&Object.defineProperty(d,C,O)}else d[C]=g[C];d.za=g.prototype}function Zt(){this.m=!1,this.j=null,this.i=void 0,this.h=1,this.v=this.s=0,this.l=null}function Ke(d){if(d.m)throw new TypeError("Generator is already running");d.m=!0}function qt(d,g){d.l={ma:g,na:!0},d.h=d.s||d.v}function ft(d,g,C){return d.h=C,{value:g}}function Jn(d){this.h=new Zt,this.i=d}function hr(d,g,C,O){try{var B=g.call(d.h.j,C);if(!(B instanceof Object))throw new TypeError("Iterator result "+B+" is not an object");if(!B.done)return d.h.m=!1,B;var M=B.value}catch(F){return d.h.j=null,qt(d.h,F),Ht(d)}return d.h.j=null,O.call(d.h,M),Ht(d)}function Ht(d){for(;d.h.h;)try{var g=d.i(d.h);if(g)return d.h.m=!1,{value:g.value,done:!1}}catch(C){d.h.i=void 0,qt(d.h,C)}if(d.h.m=!1,d.h.l){if(g=d.h.l,d.h.l=null,g.na)throw g.ma;return{value:g.return,done:!0}}return{value:void 0,done:!0}}function Rn(d){this.next=function(g){return Ke(d.h),d.h.j?g=hr(d,d.h.j.next,g,d.h.u):(d.h.u(g),g=Ht(d)),g},this.throw=function(g){return Ke(d.h),d.h.j?g=hr(d,d.h.j.throw,g,d.h.u):(qt(d.h,g),g=Ht(d)),g},this.return=function(g){return function(C,O){Ke(C.h);var B=C.h.j;return B?hr(C,"return"in B?B.return:function(M){return{value:M,done:!0}},O,C.h.return):(C.h.return(O),Ht(C))}(d,g)},this[Symbol.iterator]=function(){return this}}function Ze(d){return function(g){function C(B){return g.next(B)}function O(B){return g.throw(B)}return new Promise(function(B,M){(function F(W){W.done?B(W.value):Promise.resolve(W.value).then(C,O).then(F,M)})(g.next())})}(new Rn(new Jn(d)))}function Gt(d){return d||Array.prototype.fill}Zt.prototype.u=function(d){this.i=d},Zt.prototype.return=function(d){this.l={return:d},this.h=this.v},He("Promise",function(d){function g(F){this.i=0,this.j=void 0,this.h=[],this.u=!1;var W=this.l();try{F(W.resolve,W.reject)}catch(ee){W.reject(ee)}}function C(){this.h=null}function O(F){return F instanceof g?F:new g(function(W){W(F)})}if(d)return d;C.prototype.i=function(F){if(this.h==null){this.h=[];var W=this;this.j(function(){W.m()})}this.h.push(F)};var B=je.setTimeout;C.prototype.j=function(F){B(F,0)},C.prototype.m=function(){for(;this.h&&this.h.length;){var F=this.h;this.h=[];for(var W=0;W<F.length;++W){var ee=F[W];F[W]=null;try{ee()}catch(fe){this.l(fe)}}}this.h=null},C.prototype.l=function(F){this.j(function(){throw F})},g.prototype.l=function(){function F(fe){return function(me){ee||(ee=!0,fe.call(W,me))}}var W=this,ee=!1;return{resolve:F(this.I),reject:F(this.m)}},g.prototype.I=function(F){if(F===this)this.m(new TypeError("A Promise cannot resolve to itself"));else if(F instanceof g)this.L(F);else{e:switch($(F)){case"object":var W=F!=null;break e;case"function":W=!0;break e;default:W=!1}W?this.F(F):this.s(F)}},g.prototype.F=function(F){var W=void 0;try{W=F.then}catch(ee){return void this.m(ee)}typeof W=="function"?this.M(W,F):this.s(F)},g.prototype.m=function(F){this.v(2,F)},g.prototype.s=function(F){this.v(1,F)},g.prototype.v=function(F,W){if(this.i!=0)throw Error("Cannot settle("+F+", "+W+"): Promise already settled in state"+this.i);this.i=F,this.j=W,this.i===2&&this.K(),this.H()},g.prototype.K=function(){var F=this;B(function(){if(F.D()){var W=je.console;W!==void 0&&W.error(F.j)}},1)},g.prototype.D=function(){if(this.u)return!1;var F=je.CustomEvent,W=je.Event,ee=je.dispatchEvent;return ee===void 0||(typeof F=="function"?F=new F("unhandledrejection",{cancelable:!0}):typeof W=="function"?F=new W("unhandledrejection",{cancelable:!0}):(F=je.document.createEvent("CustomEvent")).initCustomEvent("unhandledrejection",!1,!0,F),F.promise=this,F.reason=this.j,ee(F))},g.prototype.H=function(){if(this.h!=null){for(var F=0;F<this.h.length;++F)M.i(this.h[F]);this.h=null}};var M=new C;return g.prototype.L=function(F){var W=this.l();F.T(W.resolve,W.reject)},g.prototype.M=function(F,W){var ee=this.l();try{F.call(W,ee.resolve,ee.reject)}catch(fe){ee.reject(fe)}},g.prototype.then=function(F,W){function ee(Ae,ve){return typeof Ae=="function"?function(Oe){try{fe(Ae(Oe))}catch(Be){me(Be)}}:ve}var fe,me,we=new g(function(Ae,ve){fe=Ae,me=ve});return this.T(ee(F,fe),ee(W,me)),we},g.prototype.catch=function(F){return this.then(void 0,F)},g.prototype.T=function(F,W){function ee(){switch(fe.i){case 1:F(fe.j);break;case 2:W(fe.j);break;default:throw Error("Unexpected state: "+fe.i)}}var fe=this;this.h==null?M.i(ee):this.h.push(ee),this.u=!0},g.resolve=O,g.reject=function(F){return new g(function(W,ee){ee(F)})},g.race=function(F){return new g(function(W,ee){for(var fe=X(F),me=fe.next();!me.done;me=fe.next())O(me.value).T(W,ee)})},g.all=function(F){var W=X(F),ee=W.next();return ee.done?O([]):new g(function(fe,me){function we(Oe){return function(Be){Ae[Oe]=Be,--ve==0&&fe(Ae)}}var Ae=[],ve=0;do Ae.push(void 0),ve++,O(ee.value).T(we(Ae.length-1),me),ee=W.next();while(!ee.done)})},g}),He("Array.prototype.keys",function(d){return d||function(){return function(g,C){g instanceof String&&(g+="");var O=0,B=!1,M={next:function(){if(!B&&O<g.length){var F=O++;return{value:C(F,g[F]),done:!1}}return B=!0,{done:!0,value:void 0}}};return M[Symbol.iterator]=function(){return M},M}(this,function(g){return g})}}),He("Array.prototype.fill",function(d){return d||function(g,C,O){var B=this.length||0;for(0>C&&(C=Math.max(0,B+C)),(O==null||O>B)&&(O=B),0>(O=Number(O))&&(O=Math.max(0,B+O)),C=Number(C||0);C<O;C++)this[C]=g;return this}}),He("Int8Array.prototype.fill",Gt),He("Uint8Array.prototype.fill",Gt),He("Uint8ClampedArray.prototype.fill",Gt),He("Int16Array.prototype.fill",Gt),He("Uint16Array.prototype.fill",Gt),He("Int32Array.prototype.fill",Gt),He("Uint32Array.prototype.fill",Gt),He("Float32Array.prototype.fill",Gt),He("Float64Array.prototype.fill",Gt),He("Object.is",function(d){return d||function(g,C){return g===C?g!==0||1/g==1/C:g!=g&&C!=C}}),He("Array.prototype.includes",function(d){return d||function(g,C){var O=this;O instanceof String&&(O=String(O));var B=O.length;for(0>(C=C||0)&&(C=Math.max(C+B,0));C<B;C++){var M=O[C];if(M===g||Object.is(M,g))return!0}return!1}}),He("String.prototype.includes",function(d){return d||function(g,C){if(this==null)throw new TypeError("The 'this' value for String.prototype.includes must not be null or undefined");if(g instanceof RegExp)throw new TypeError("First argument to String.prototype.includes must not be a regular expression");return this.indexOf(g,C||0)!==-1}});var qn=this||self;function he(d,g){d=d.split(".");var C,O=qn;for((d[0]in O)||O.execScript===void 0||O.execScript("var "+d[0]);d.length&&(C=d.shift());)d.length||g===void 0?O=O[C]&&O[C]!==Object.prototype[C]?O[C]:O[C]={}:O[C]=g}function de(d){var g;return(g=qn.navigator)&&(g=g.userAgent)||(g=""),g.indexOf(d)!=-1}var Ne=Array.prototype.map?function(d,g){return Array.prototype.map.call(d,g,void 0)}:function(d,g){for(var C=d.length,O=Array(C),B=typeof d=="string"?d.split(""):d,M=0;M<C;M++)M in B&&(O[M]=g.call(void 0,B[M],M,d));return O},We={},De=null;function ut(d){var g=d.length,C=3*g/4;C%3?C=Math.floor(C):"=.".indexOf(d[g-1])!=-1&&(C="=.".indexOf(d[g-2])!=-1?C-2:C-1);var O=new Uint8Array(C),B=0;return function(M,F){function W(ve){for(;ee<M.length;){var Oe=M.charAt(ee++),Be=De[Oe];if(Be!=null)return Be;if(!/^[\s\xa0]*$/.test(Oe))throw Error("Unknown base64 encoding at char: "+Oe)}return ve}rt();for(var ee=0;;){var fe=W(-1),me=W(0),we=W(64),Ae=W(64);if(Ae===64&&fe===-1)break;F(fe<<2|me>>4),we!=64&&(F(me<<4&240|we>>2),Ae!=64&&F(we<<6&192|Ae))}}(d,function(M){O[B++]=M}),B!==C?O.subarray(0,B):O}function rt(){if(!De){De={};for(var d="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789".split(""),g=["+/=","+/","-_=","-_.","-_"],C=0;5>C;C++){var O=d.concat(g[C].split(""));We[C]=O;for(var B=0;B<O.length;B++){var M=O[B];De[M]===void 0&&(De[M]=B)}}}}var Ut=typeof Uint8Array!="undefined",en=!(de("Trident")||de("MSIE"))&&typeof qn.btoa=="function";function pe(d){if(!en){var g;g===void 0&&(g=0),rt(),g=We[g];for(var C=Array(Math.floor(d.length/3)),O=g[64]||"",B=0,M=0;B<d.length-2;B+=3){var F=d[B],W=d[B+1],ee=d[B+2],fe=g[F>>2];F=g[(3&F)<<4|W>>4],W=g[(15&W)<<2|ee>>6],ee=g[63&ee],C[M++]=fe+F+W+ee}switch(fe=0,ee=O,d.length-B){case 2:ee=g[(15&(fe=d[B+1]))<<2]||O;case 1:d=d[B],C[M]=g[d>>2]+g[(3&d)<<4|fe>>4]+ee+O}return C.join("")}for(g="";10240<d.length;)g+=String.fromCharCode.apply(null,d.subarray(0,10240)),d=d.subarray(10240);return g+=String.fromCharCode.apply(null,d),btoa(g)}var Ot,Kt=RegExp("[-_.]","g");function fr(d){switch(d){case"-":return"+";case"_":return"/";case".":return"=";default:return""}}function Pi(d){if(!en)return ut(d);Kt.test(d)&&(d=d.replace(Kt,fr)),d=atob(d);for(var g=new Uint8Array(d.length),C=0;C<d.length;C++)g[C]=d.charCodeAt(C);return g}function yn(){return Ot||(Ot=new Uint8Array(0))}var Rt={},Cd=typeof Uint8Array.prototype.slice=="function",Lt=0,pt=0;function Dc(d){var g=0>d,C=(d=Math.abs(d))>>>0;d=Math.floor((d-C)/4294967296),g&&(g=(C=X(ba(C,d))).next().value,d=C.next().value,C=g),Lt=C>>>0,pt=d>>>0}var Oc,bn=typeof BigInt=="function";function ba(d,g){return g=~g,d?d=1+~d:g+=1,[d,g]}function Di(d,g){this.i=d>>>0,this.h=g>>>0}function Lc(d){if(!d)return Oc||(Oc=new Di(0,0));if(!/^-?\d+$/.test(d))return null;if(16>d.length)Dc(Number(d));else if(bn)d=BigInt(d),Lt=Number(d&BigInt(4294967295))>>>0,pt=Number(d>>BigInt(32)&BigInt(4294967295));else{var g=+(d[0]==="-");pt=Lt=0;for(var C=d.length,O=g,B=(C-g)%6+g;B<=C;O=B,B+=6)O=Number(d.slice(O,B)),pt*=1e6,4294967296<=(Lt=1e6*Lt+O)&&(pt+=Lt/4294967296|0,Lt%=4294967296);g&&(d=(g=X(ba(Lt,pt))).next().value,g=g.next().value,Lt=d,pt=g)}return new Di(Lt,pt)}function it(d,g){return Error("Invalid wire type: "+d+" (at position "+g+")")}function Sa(){return Error("Failed to read varint, encoding is invalid.")}function Mc(d,g){return Error("Tried to read past the end of the data "+g+" > "+d)}function at(){throw Error("Invalid UTF8")}function ka(d,g){return g=String.fromCharCode.apply(null,g),d==null?g:d+g}var qo,Nc,An,Sn=void 0,Kn=typeof TextDecoder!="undefined",Uc=typeof TextEncoder!="undefined";function Ta(d){if(d!==Rt)throw Error("illegal external caller")}function Xr(d,g){if(Ta(g),this.V=d,d!=null&&d.length===0)throw Error("ByteString should be constructed with non-empty values")}function xa(){return An||(An=new Xr(null,Rt))}function Ko(d){Ta(Rt);var g=d.V;return(g=g==null||Ut&&g!=null&&g instanceof Uint8Array?g:typeof g=="string"?Pi(g):null)==null?g:d.V=g}function Xo(d,g){this.i=null,this.m=!1,this.h=this.j=this.l=0,pr(this,d,g)}function pr(d,g,C){C=C===void 0?{}:C,d.S=C.S!==void 0&&C.S,g&&(g=function(O){if(typeof O=="string")return{buffer:Pi(O),C:!1};if(Array.isArray(O))return{buffer:new Uint8Array(O),C:!1};if(O.constructor===Uint8Array)return{buffer:O,C:!1};if(O.constructor===ArrayBuffer)return{buffer:new Uint8Array(O),C:!1};if(O.constructor===Xr)return{buffer:Ko(O)||yn(),C:!0};if(O instanceof Uint8Array)return{buffer:new Uint8Array(O.buffer,O.byteOffset,O.byteLength),C:!1};throw Error("Type not convertible to a Uint8Array, expected a Uint8Array, an ArrayBuffer, a base64 encoded string, a ByteString or an Array of numbers")}(g),d.i=g.buffer,d.m=g.C,d.l=0,d.j=d.i.length,d.h=d.l)}function mr(d,g){if(d.h=g,g>d.j)throw Mc(d.j,g)}function Oi(d){var g=d.i,C=d.h,O=g[C++],B=127&O;if(128&O&&(B|=(127&(O=g[C++]))<<7,128&O&&(B|=(127&(O=g[C++]))<<14,128&O&&(B|=(127&(O=g[C++]))<<21,128&O&&(B|=(O=g[C++])<<28,128&O&&128&g[C++]&&128&g[C++]&&128&g[C++]&&128&g[C++]&&128&g[C++])))))throw Sa();return mr(d,C),B}function Qo(d,g){if(0>g)throw Error("Tried to read a negative byte length: "+g);var C=d.h,O=C+g;if(O>d.j)throw Mc(g,d.j-C);return d.h=O,C}Xo.prototype.reset=function(){this.h=this.l};var Yo=[];function $o(){this.h=[]}function Vc(d,g,C){for(;0<C||127<g;)d.h.push(127&g|128),g=(g>>>7|C<<25)>>>0,C>>>=7;d.h.push(g)}function Ar(d,g){for(;127<g;)d.h.push(127&g|128),g>>>=7;d.h.push(g)}function Zo(d,g){if(Yo.length){var C=Yo.pop();pr(C,d,g),d=C}else d=new Xo(d,g);this.h=d,this.j=this.h.h,this.i=this.l=-1,this.setOptions(g)}function Li(d){var g=d.h;if(g.h==g.j)return!1;d.j=d.h.h;var C=Oi(d.h)>>>0;if(g=C>>>3,!(0<=(C&=7)&&5>=C))throw it(C,d.j);if(1>g)throw Error("Invalid field number: "+g+" (at position "+d.j+")");return d.l=g,d.i=C,!0}function Ia(d){switch(d.i){case 0:if(d.i!=0)Ia(d);else e:{for(var g=(d=d.h).h,C=g+10,O=d.i;g<C;)if((128&O[g++])==0){mr(d,g);break e}throw Sa()}break;case 1:mr(d=d.h,d.h+8);break;case 2:d.i!=2?Ia(d):(g=Oi(d.h)>>>0,mr(d=d.h,d.h+g));break;case 5:mr(d=d.h,d.h+4);break;case 3:for(g=d.l;;){if(!Li(d))throw Error("Unmatched start-group tag: stream EOF");if(d.i==4){if(d.l!=g)throw Error("Unmatched end-group tag");break}Ia(d)}break;default:throw it(d.i,d.j)}}$o.prototype.length=function(){return this.h.length},$o.prototype.end=function(){var d=this.h;return this.h=[],d},Zo.prototype.setOptions=function(d){d=d===void 0?{}:d,this.ca=d.ca!==void 0&&d.ca},Zo.prototype.reset=function(){this.h.reset(),this.j=this.h.h,this.i=this.l=-1};var Xn=[];function Ed(){this.j=[],this.i=0,this.h=new $o}function Qr(d,g){g.length!==0&&(d.j.push(g),d.i+=g.length)}var Qn=typeof Symbol=="function"&&$(Symbol())==="symbol"?Symbol():void 0;function Vt(d,g){return Qn?d[Qn]|=g:d.A!==void 0?d.A|=g:(Object.defineProperties(d,{A:{value:g,configurable:!0,writable:!0,enumerable:!1}}),g)}function jc(d,g){Qn?d[Qn]&&(d[Qn]&=~g):d.A!==void 0&&(d.A&=~g)}function It(d){var g;return(g=Qn?d[Qn]:d.A)==null?0:g}function Xt(d,g){Qn?d[Qn]=g:d.A!==void 0?d.A=g:Object.defineProperties(d,{A:{value:g,configurable:!0,writable:!0,enumerable:!1}})}function Mi(d){return Vt(d,1),d}function es(d,g){Xt(g,-51&(0|d))}function Yr(d,g){Xt(g,-41&(18|d))}var ts={};function Pr(d){return d!==null&&$(d)==="object"&&!Array.isArray(d)&&d.constructor===Object}var $r,wa,Ca=[];function ns(d){if(2&It(d.o))throw Error("Cannot mutate an immutable Message")}function Ea(d){var g=d.length;(g=g?d[g-1]:void 0)&&Pr(g)?g.g=1:(g={},d.push((g.g=1,g)))}function Ra(d){var g=d.i+d.G;return d.B||(d.B=d.o[g]={})}function pn(d,g){return g===-1?null:g>=d.i?d.B?d.B[g]:void 0:d.o[g+d.G]}function Pn(d,g,C,O){ns(d),Ni(d,g,C,O)}function Ni(d,g,C,O){d.j&&(d.j=void 0),g>=d.i||O?Ra(d)[g]=C:(d.o[g+d.G]=C,(d=d.B)&&g in d&&delete d[g])}function Mt(d,g,C,O){var B=pn(d,g);Array.isArray(B)||(B=$r);var M=It(B);if(1&M||Mi(B),O)2&M||Vt(B,2),1&C||Object.freeze(B);else{O=!(2&C);var F=2&M;1&C||!F?O&&16&M&&!F&&jc(B,16):Ni(d,g,B=Mi(Array.prototype.slice.call(B)))}return B}function rs(d,g){var C=pn(d,g),O=C==null?C:typeof C=="number"||C==="NaN"||C==="Infinity"||C==="-Infinity"?Number(C):void 0;return O!=null&&O!==C&&Ni(d,g,O),O}function Bc(d,g,C,O,B){d.h||(d.h={});var M=d.h[C],F=Mt(d,C,3,B);if(!M){var W=F;M=[];var ee=!!(16&It(d.o));F=!!(2&It(W));var fe=W;!B&&F&&(W=Array.prototype.slice.call(W));for(var me=F,we=0;we<W.length;we++){var Ae=W[we],ve=g,Oe=!1;if(Oe=Oe!==void 0&&Oe,(Ae=Array.isArray(Ae)?new ve(Ae):Oe?new ve:void 0)!==void 0){var Be=Oe=It(ve=Ae.o);F&&(Be|=2),ee&&(Be|=16),Be!=Oe&&Xt(ve,Be),ve=Be,me=me||!!(2&ve),M.push(Ae)}}return d.h[C]=M,g=33|(ee=It(W)),ee!=(g=me?-9&g:8|g)&&(me=W,Object.isFrozen(me)&&(me=Array.prototype.slice.call(me)),Xt(me,g),W=me),fe!==W&&Ni(d,C,W),(B||O&&F)&&Vt(M,2),O&&Object.freeze(M),M}return B||(B=Object.isFrozen(M),O&&!B?Object.freeze(M):!O&&B&&(M=Array.prototype.slice.call(M),d.h[C]=M)),M}function kt(d,g,C){var O=!!(2&It(d.o));if(g=Bc(d,g,C,O,O),d=Mt(d,C,3,O),!(O||8&It(d))){for(O=0;O<g.length;O++){if(2&It((C=g[O]).o)){var B=Zr(C,!1);B.j=C}else B=C;C!==B&&(g[O]=B,d[O]=B.o)}Vt(d,8)}return g}function Dn(d,g,C){if(C!=null&&typeof C!="number")throw Error("Value of float/double field must be a number|null|undefined, found "+$(C)+": "+C);Pn(d,g,C)}function Fc(d,g,C,O,B){ns(d);var M=Bc(d,C,g,!1,!1);return C=O!=null?O:new C,d=Mt(d,g,2,!1),B!=null?(M.splice(B,0,C),d.splice(B,0,C.o)):(M.push(C),d.push(C.o)),C.C()&&jc(d,8),C}function Aa(d,g){return d==null?g:d}function On(d,g,C){return C=C===void 0?0:C,Aa(rs(d,g),C)}function Ui(d,g,C,O){if(d!=null){if(Array.isArray(d))d=is(d,g,C,O!==void 0);else if(Pr(d)){var B,M={};for(B in d)M[B]=Ui(d[B],g,C,O);d=M}else d=g(d,O);return d}}function is(d,g,C,O){var B=It(d);O=O?!!(16&B):void 0,d=Array.prototype.slice.call(d);for(var M=0;M<d.length;M++)d[M]=Ui(d[M],g,C,O);return C(B,d),d}function Rd(d){return d.ja===ts?d.toJSON():function(g){switch($(g)){case"number":return isFinite(g)?g:String(g);case"object":if(g)if(Array.isArray(g)){if((128&It(g))!=0)return Ea(g=Array.prototype.slice.call(g)),g}else{if(Ut&&g!=null&&g instanceof Uint8Array)return pe(g);if(g instanceof Xr){var C=g.V;return C==null?"":typeof C=="string"?C:g.V=pe(C)}}}return g}(d)}function Hc(d,g){128&d&&Ea(g)}function Gc(d,g,C){if(C=C===void 0?Yr:C,d!=null){if(Ut&&d instanceof Uint8Array)return d.length?new Xr(new Uint8Array(d),Rt):xa();if(Array.isArray(d)){var O=It(d);return 2&O?d:!g||32&O||!(16&O||O===0)?(4&(g=It(d=is(d,Gc,4&O?Yr:C,!0)))&&2&g&&Object.freeze(d),d):(Xt(d,2|O),d)}return d.ja===ts?os(d):d}}function as(d,g,C,O,B,M,F){if(d=d.h&&d.h[C]){if(2&(O=It(d))?O=d:(Yr(O,M=Ne(d,os)),Object.freeze(M),O=M),ns(g),F=O==null?$r:Mi([]),O!=null){for(M=!!O.length,d=0;d<O.length;d++){var W=O[d];M=M&&!(2&It(W.o)),F[d]=W.o}M=1|(M?8:0),((d=It(F))&M)!==M&&(Object.isFrozen(F)&&(F=Array.prototype.slice.call(F)),Xt(F,d|M)),g.h||(g.h={}),g.h[C]=O}else g.h&&(g.h[C]=void 0);Ni(g,C,F,B)}else Pn(g,C,Gc(O,M,F),B)}function os(d){return 2&It(d.o)||Vt((d=Zr(d,!0)).o,2),d}function Zr(d,g){var C=d.o,O=[];Vt(O,16);var B=d.constructor.h;if(B&&O.push(B),B=d.B){O.length=C.length,O.fill(void 0,O.length,C.length);var M={};O[O.length-1]=M}(128&It(C))!=0&&Ea(O),g=g||d.C()?Yr:es,M=d.constructor,wa=O,O=new M(O),wa=void 0,d.R&&(O.R=d.R.slice()),M=!!(16&It(C));for(var F=B?C.length-1:C.length,W=0;W<F;W++)as(d,O,W-d.G,C[W],!1,M,g);if(B)for(var ee in B)as(d,O,+ee,B[ee],!0,M,g);return O}function At(d,g,C){d==null&&(d=wa),wa=void 0;var O,B=this.constructor.i||0,M=0<B,F=this.constructor.h,W=!1;if(d==null){var ee=48,fe=!0;M&&(B=0,ee|=128),Xt(d=F?[F]:[],ee)}else{if(!Array.isArray(d)||F&&F!==d[0])throw Error();var me=ee=Vt(d,0);if((fe=(16&me)!=0)&&((W=(32&me)!=0)||(me|=32)),M){if(128&me)B=0;else if(0<d.length){var we=d[d.length-1];if(Pr(we)&&"g"in we){B=0,me|=128,delete we.g;var Ae,ve=!0;for(Ae in we){ve=!1;break}ve&&d.pop()}}}else if(128&me)throw Error();ee!==me&&Xt(d,me)}if(this.G=(F?0:-1)-B,this.h=void 0,this.o=d,B=(F=this.o.length)-1,F&&Pr(F=this.o[B])?(this.B=F,this.i=B-this.G):g!==void 0&&-1<g?(this.i=Math.max(g,B+1-this.G),this.B=void 0):this.i=Number.MAX_VALUE,!M&&this.B&&"g"in this.B)throw Error('Unexpected "g" flag in sparse object of message that is not a group type.');if(C)for(g=fe&&!W&&!0,M=this.i,fe=0;fe<C.length;fe++)(W=C[fe])<M?(B=d[W+=this.G])?ss(B,g):d[W]=$r:(O||(O=Ra(this)),(B=O[W])?ss(B,g):O[W]=$r)}function ss(d,g){if(Array.isArray(d)){var C=It(d),O=1;!g||2&C||(O|=16),(C&O)!==O&&Xt(d,C|O)}}function zc(d,g,C){if(C){var O,B={};for(O in C){var M=C[O],F=M.ra;F||(B.J=M.xa||M.oa.W,M.ia?(B.aa=Xc(M.ia),F=function(W){return function(ee,fe,me){return W.J(ee,fe,me,W.aa)}}(B)):M.ka?(B.Z=Vi(M.da.P,M.ka),F=function(W){return function(ee,fe,me){return W.J(ee,fe,me,W.Z)}}(B)):F=B.J,M.ra=F),F(g,d,M.da),B={J:B.J,aa:B.aa,Z:B.Z}}}(function(W,ee){if(ee=ee.R){Qr(W,W.h.end());for(var fe=0;fe<ee.length;fe++)Qr(W,Ko(ee[fe])||yn())}})(g,d)}Xt(Ca,23),$r=Object.freeze(Ca),At.prototype.toJSON=function(){return is(this.o,Rd,Hc)},At.prototype.C=function(){return!!(2&It(this.o))},At.prototype.ja=ts,At.prototype.toString=function(){return this.o.toString()};var tt=Symbol();function Wc(d,g,C){return d[tt]||(d[tt]=function(O,B){return g(O,B,C)})}function cs(d){var g=d[tt];if(!g){var C=ds(d);g=function(O,B){return $c(O,B,C)},d[tt]=g}return g}function Jc(d){var g=function(B){var M=B.ia;return M?cs(M):(M=B.wa)?Wc(B.da.P,M,B.ka):void 0}(d),C=d.da,O=d.oa.U;return g?function(B,M){return O(B,M,C,g)}:function(B,M){return O(B,M,C)}}function qc(d,g){var C=d[g];return typeof C=="function"&&C.length===0&&(C=C(),d[g]=C),Array.isArray(C)&&(vr in C||ji in C||0<C.length&&typeof C[0]=="function")?C:void 0}function Kc(d,g,C,O,B,M){g.P=d[0];var F=1;if(d.length>F&&typeof d[F]!="number"){var W=d[F++];C(g,W)}for(;F<d.length;){C=d[F++];for(var ee=F+1;ee<d.length&&typeof d[ee]!="number";)ee++;switch(W=d[F++],ee-=F){case 0:O(g,C,W);break;case 1:(ee=qc(d,F))?(F++,B(g,C,W,ee)):O(g,C,W,d[F++]);break;case 2:B(g,C,W,ee=qc(d,ee=F++),d[F++]);break;case 3:M(g,C,W,d[F++],d[F++],d[F++]);break;case 4:M(g,C,W,d[F++],d[F++],d[F++],d[F++]);break;default:throw Error("unexpected number of binary field arguments: "+ee)}}return g}var Pa=Symbol();function Xc(d){var g=d[Pa];if(!g){var C=ls(d);g=function(O,B){return Zc(O,B,C)},d[Pa]=g}return g}function Vi(d,g){var C=d[Pa];return C||(C=function(O,B){return zc(O,B,g)},d[Pa]=C),C}var ji=Symbol();function Ad(d,g){d.push(g)}function Da(d,g,C){d.push(g,C.W)}function Qc(d,g,C,O){var B=Xc(O),M=ls(O).P,F=C.W;d.push(g,function(W,ee,fe){return F(W,ee,fe,M,B)})}function us(d,g,C,O,B,M){var F=Vi(O,M),W=C.W;d.push(g,function(ee,fe,me){return W(ee,fe,me,O,F)})}function ls(d){var g=d[ji];return g||(g=Kc(d,d[ji]=[],Ad,Da,Qc,us),vr in d&&ji in d&&(d.length=0),g)}var vr=Symbol();function Pd(d,g){d[0]=g}function Yc(d,g,C,O){var B=C.U;d[g]=O?function(M,F,W){return B(M,F,W,O)}:B}function Dd(d,g,C,O,B){var M=C.U,F=cs(O),W=ds(O).P;d[g]=function(ee,fe,me){return M(ee,fe,me,W,F,B)}}function Od(d,g,C,O,B,M,F){var W=C.U,ee=Wc(O,B,M);d[g]=function(fe,me,we){return W(fe,me,we,O,ee,F)}}function ds(d){var g=d[vr];return g||(g=Kc(d,d[vr]={},Pd,Yc,Dd,Od),vr in d&&ji in d&&(d.length=0),g)}function $c(d,g,C){for(;Li(g)&&g.i!=4;){var O=g.l,B=C[O];if(!B){var M=C[0];M&&(M=M[O])&&(B=C[O]=Jc(M))}if(!B||!B(g,d,O)){O=d,M=(B=g).j,Ia(B);var F=B;if(!F.ca){if(B=F.h.h-M,F.h.h=M,F=F.h,B==0)B=xa();else{if(M=Qo(F,B),F.S&&F.m)B=F.i.subarray(M,M+B);else{F=F.i;var W=M;B=W===(B=M+B)?yn():Cd?F.slice(W,B):new Uint8Array(F.subarray(W,B))}B=B.length==0?xa():new Xr(B,Rt)}(M=O.R)?M.push(B):O.R=[B]}}}return d}function Zc(d,g,C){for(var O=C.length,B=O%2==1,M=B?1:0;M<O;M+=2)(0,C[M+1])(g,d,C[M]);zc(d,g,B?C[0]:void 0)}function Bi(d,g){return{U:d,W:g}}var kn=Bi(function(d,g,C){if(d.i!==5)return!1;var O=(d=d.h).i,B=d.h,M=O[B],F=O[B+1],W=O[B+2];return O=O[B+3],mr(d,d.h+4),d=2*((F=(M<<0|F<<8|W<<16|O<<24)>>>0)>>31)+1,M=F>>>23&255,F&=8388607,Pn(g,C,M==255?F?NaN:1/0*d:M==0?d*Math.pow(2,-149)*F:d*Math.pow(2,M-150)*(F+Math.pow(2,23))),!0},function(d,g,C){if((g=rs(g,C))!=null){Ar(d.h,8*C+5),d=d.h;var O=+g;O===0?0<1/O?Lt=pt=0:(pt=0,Lt=2147483648):isNaN(O)?(pt=0,Lt=2147483647):34028234663852886e22<(O=(C=0>O?-2147483648:0)?-O:O)?(pt=0,Lt=(2139095040|C)>>>0):11754943508222875e-54>O?(O=Math.round(O/Math.pow(2,-149)),pt=0,Lt=(C|O)>>>0):(g=Math.floor(Math.log(O)/Math.LN2),O*=Math.pow(2,-g),16777216<=(O=Math.round(8388608*O))&&++g,pt=0,Lt=(C|g+127<<23|8388607&O)>>>0),C=Lt,d.h.push(C>>>0&255),d.h.push(C>>>8&255),d.h.push(C>>>16&255),d.h.push(C>>>24&255)}}),Ld=Bi(function(d,g,C){if(d.i!==0)return!1;var O=d.h,B=0,M=d=0,F=O.i,W=O.h;do{var ee=F[W++];B|=(127&ee)<<M,M+=7}while(32>M&&128&ee);for(32<M&&(d|=(127&ee)>>4),M=3;32>M&&128ⅇM+=7)d|=(127&(ee=F[W++]))<<M;if(mr(O,W),!(128>ee))throw Sa();return O=B>>>0,(d=2147483648&(ee=d>>>0))&&(ee=~ee>>>0,(O=1+~O>>>0)==0&&(ee=ee+1>>>0)),O=4294967296*ee+(O>>>0),Pn(g,C,d?-O:O),!0},function(d,g,C){(g=pn(g,C))!=null&&(typeof g=="string"&&Lc(g),g!=null&&(Ar(d.h,8*C),typeof g=="number"?(d=d.h,Dc(g),Vc(d,Lt,pt)):(C=Lc(g),Vc(d.h,C.i,C.h))))}),eu=Bi(function(d,g,C){return d.i===0&&(Pn(g,C,Oi(d.h)),!0)},function(d,g,C){if((g=pn(g,C))!=null&&g!=null)if(Ar(d.h,8*C),d=d.h,0<=(C=g))Ar(d,C);else{for(g=0;9>g;g++)d.h.push(127&C|128),C>>=7;d.h.push(1)}}),Pt=Bi(function(d,g,C){if(d.i!==2)return!1;var O=Oi(d.h)>>>0,B=Qo(d=d.h,O);if(d=d.i,Kn){var M,F=d;(M=qo)||(M=qo=new TextDecoder("utf-8",{fatal:!0})),d=B+O,F=B===0&&d===F.length?F:F.subarray(B,d);try{var W=M.decode(F)}catch(we){if(Sn===void 0){try{M.decode(new Uint8Array([128]))}catch(Ae){}try{M.decode(new Uint8Array([97])),Sn=!0}catch(Ae){Sn=!1}}throw!Sn&&(qo=void 0),we}}else{O=(W=B)+O,B=[];for(var ee,fe,me=null;W<O;)128>(ee=d[W++])?B.push(ee):224>ee?W>=O?at():(fe=d[W++],194>ee||(192&fe)!=128?(W--,at()):B.push((31&ee)<<6|63&fe)):240>ee?W>=O-1?at():(192&(fe=d[W++]))!=128||ee===224&&160>fe||ee===237&&160<=fe||(192&(F=d[W++]))!=128?(W--,at()):B.push((15&ee)<<12|(63&fe)<<6|63&F):244>=ee?W>=O-2?at():(192&(fe=d[W++]))!=128||fe-144+(ee<<28)>>30!=0||(192&(F=d[W++]))!=128||(192&(M=d[W++]))!=128?(W--,at()):(ee=(7&ee)<<18|(63&fe)<<12|(63&F)<<6|63&M,ee-=65536,B.push(55296+(ee>>10&1023),56320+(1023&ee))):at(),8192<=B.length&&(me=ka(me,B),B.length=0);W=ka(me,B)}return Pn(g,C,W),!0},function(d,g,C){if((g=pn(g,C))!=null){var O=!1;if(O=O!==void 0&&O,Uc){if(O&&/(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])/.test(g))throw Error("Found an unpaired surrogate");g=(Nc||(Nc=new TextEncoder)).encode(g)}else{for(var B=0,M=new Uint8Array(3*g.length),F=0;F<g.length;F++){var W=g.charCodeAt(F);if(128>W)M[B++]=W;else{if(2048>W)M[B++]=W>>6|192;else{if(55296<=W&&57343>=W){if(56319>=W&&F<g.length){var ee=g.charCodeAt(++F);if(56320<=ee&&57343>=ee){W=1024*(W-55296)+ee-56320+65536,M[B++]=W>>18|240,M[B++]=W>>12&63|128,M[B++]=W>>6&63|128,M[B++]=63&W|128;continue}F--}if(O)throw Error("Found an unpaired surrogate");W=65533}M[B++]=W>>12|224,M[B++]=W>>6&63|128}M[B++]=63&W|128}}g=B===M.length?M:M.subarray(0,B)}Ar(d.h,8*C+2),Ar(d.h,g.length),Qr(d,d.h.end()),Qr(d,g)}}),hs=Bi(function(d,g,C,O,B){if(d.i!==2)return!1;g=Fc(g,C,O),C=d.h.j,O=Oi(d.h)>>>0;var M=d.h.h+O,F=M-C;if(0>=F&&(d.h.j=M,B(g,d,void 0,void 0,void 0),F=M-d.h.h),F)throw Error("Message parsing ended unexpectedly. Expected to read "+O+" bytes, instead read "+(O-F)+" bytes, either the data ended unexpectedly or the message misreported its own length");return d.h.h=M,d.h.j=C,!0},function(d,g,C,O,B){if((g=kt(g,O,C))!=null)for(O=0;O<g.length;O++){var M=d;Ar(M.h,8*C+2);var F=M.h.end();Qr(M,F),F.push(M.i),M=F,B(g[O],d),F=d;var W=M.pop();for(W=F.i+F.h.length()-W;127<W;)M.push(127&W|128),W>>>=7,F.i++;M.push(W),F.i++}});function fs(d){return function(g,C){e:{if(Xn.length){var O=Xn.pop();O.setOptions(C),pr(O.h,g,C),g=O}else g=new Zo(g,C);try{var B=ds(d),M=$c(new B.P,g,B);break e}finally{(B=g.h).i=null,B.m=!1,B.l=0,B.j=0,B.h=0,B.S=!1,g.l=-1,g.i=-1,100>Xn.length&&Xn.push(g)}M=void 0}return M}}function ps(d){return function(){var g=new Ed;Zc(this,g,ls(d)),Qr(g,g.h.end());for(var C=new Uint8Array(g.i),O=g.j,B=O.length,M=0,F=0;F<B;F++){var W=O[F];C.set(W,M),M+=W.length}return g.j=[C],C}}function ei(d){At.call(this,d)}Jt(ei,At);var Tt=[ei,1,eu,2,kn,3,Pt,4,Pt];function ms(d){At.call(this,d,-1,Md)}ei.prototype.l=ps(Tt),Jt(ms,At),ms.prototype.addClassification=function(d,g){return Fc(this,1,ei,d,g),this};var Md=[1],Nd=fs([ms,1,hs,Tt]);function gr(d){At.call(this,d)}Jt(gr,At);var vs=[gr,1,kn,2,kn,3,kn,4,kn,5,kn];function tu(d){At.call(this,d,-1,gs)}gr.prototype.l=ps(vs),Jt(tu,At);var gs=[1],Ud=fs([tu,1,hs,vs]);function Oa(d){At.call(this,d)}Jt(Oa,At);var nu=[Oa,1,kn,2,kn,3,kn,4,kn,5,kn,6,Ld],Vd=fs(nu);function ru(d,g,C){if(C=d.createShader(C===0?d.VERTEX_SHADER:d.FRAGMENT_SHADER),d.shaderSource(C,g),d.compileShader(C),!d.getShaderParameter(C,d.COMPILE_STATUS))throw Error(`Could not compile WebGL shader.
|
|
568
532
|
|
|
569
|
-
`+
|
|
533
|
+
`+d.getShaderInfoLog(C));return C}function jd(d){return kt(d,ei,1).map(function(g){var C=pn(g,1);return{index:C==null?0:C,qa:On(g,2),label:pn(g,3)!=null?Aa(pn(g,3),""):void 0,displayName:pn(g,4)!=null?Aa(pn(g,4),""):void 0}})}function Ln(d){return{x:On(d,1),y:On(d,2),z:On(d,3),visibility:rs(d,4)!=null?On(d,4):void 0}}function Fi(d,g){this.i=d,this.h=g,this.m=0}function La(d,g,C){return function(O,B){var M=O.h;if(O.s===void 0){var F=ru(M,`
|
|
570
534
|
attribute vec2 aVertex;
|
|
571
535
|
attribute vec2 aTex;
|
|
572
536
|
varying vec2 vTex;
|
|
573
537
|
void main(void) {
|
|
574
538
|
gl_Position = vec4(aVertex, 0.0, 1.0);
|
|
575
539
|
vTex = aTex;
|
|
576
|
-
}`,0),W=
|
|
540
|
+
}`,0),W=ru(M,`
|
|
577
541
|
precision mediump float;
|
|
578
542
|
varying vec2 vTex;
|
|
579
543
|
uniform sampler2D sampler0;
|
|
580
544
|
void main(){
|
|
581
545
|
gl_FragColor = texture2D(sampler0, vTex);
|
|
582
|
-
}`,1),
|
|
546
|
+
}`,1),ee=M.createProgram();if(M.attachShader(ee,F),M.attachShader(ee,W),M.linkProgram(ee),!M.getProgramParameter(ee,M.LINK_STATUS))throw Error(`Could not compile WebGL program.
|
|
583
547
|
|
|
584
|
-
`+U.getProgramInfoLog(Z));F=M.s=Z,U.useProgram(F),W=U.getUniformLocation(F,"sampler0"),M.l={O:U.getAttribLocation(F,"aVertex"),N:U.getAttribLocation(F,"aTex"),ya:W},M.v=U.createBuffer(),U.bindBuffer(U.ARRAY_BUFFER,M.v),U.enableVertexAttribArray(M.l.O),U.vertexAttribPointer(M.l.O,2,U.FLOAT,!1,0,0),U.bufferData(U.ARRAY_BUFFER,new Float32Array([-1,-1,-1,1,1,1,1,-1]),U.STATIC_DRAW),U.bindBuffer(U.ARRAY_BUFFER,null),M.u=U.createBuffer(),U.bindBuffer(U.ARRAY_BUFFER,M.u),U.enableVertexAttribArray(M.l.N),U.vertexAttribPointer(M.l.N,2,U.FLOAT,!1,0,0),U.bufferData(U.ARRAY_BUFFER,new Float32Array([0,1,0,0,1,0,1,1]),U.STATIC_DRAW),U.bindBuffer(U.ARRAY_BUFFER,null),U.uniform1i(W,0)}F=M.l,U.useProgram(M.s),U.canvas.width=V.width,U.canvas.height=V.height,U.viewport(0,0,V.width,V.height),U.activeTexture(U.TEXTURE0),M.i.bindTexture2d(V.glName),U.enableVertexAttribArray(F.O),U.bindBuffer(U.ARRAY_BUFFER,M.v),U.vertexAttribPointer(F.O,2,U.FLOAT,!1,0,0),U.enableVertexAttribArray(F.N),U.bindBuffer(U.ARRAY_BUFFER,M.u),U.vertexAttribPointer(F.N,2,U.FLOAT,!1,0,0),U.bindFramebuffer(U.DRAW_FRAMEBUFFER?U.DRAW_FRAMEBUFFER:U.FRAMEBUFFER,null),U.clearColor(0,0,0,0),U.clear(U.COLOR_BUFFER_BIT),U.colorMask(!0,!0,!0,!0),U.drawArrays(U.TRIANGLE_FAN,0,4),U.disableVertexAttribArray(F.O),U.disableVertexAttribArray(F.N),U.bindBuffer(U.ARRAY_BUFFER,null),M.i.bindTexture2d(0)}(l,_),typeof l.h.canvas.transferToImageBitmap=="function"?Promise.resolve(l.h.canvas.transferToImageBitmap()):R?Promise.resolve(l.h.canvas):typeof createImageBitmap=="function"?createImageBitmap(l.h.canvas):(l.j===void 0&&(l.j=document.createElement("canvas")),new Promise(function(M){l.j.height=l.h.canvas.height,l.j.width=l.h.canvas.width,l.j.getContext("2d",{}).drawImage(l.h.canvas,0,0,l.h.canvas.width,l.h.canvas.height),M(l.j)}))}function Ts(l){this.h=l}Fa.prototype.l=bs(au);var Hd=new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,2,1,0,10,9,1,7,0,65,0,253,15,26,11]);function su(l,_){return _+l}function cu(l,_){window[l]=_}function Qi(l){if(this.h=l,this.listeners={},this.l={},this.L={},this.s={},this.v={},this.M=this.u=this.ga=!0,this.I=Promise.resolve(),this.fa="",this.D={},this.locateFile=l&&l.locateFile||su,(typeof window=="undefined"?"undefined":Q(window))==="object")var _=window.location.pathname.toString().substring(0,window.location.pathname.toString().lastIndexOf("/"))+"/";else{if(typeof location=="undefined")throw Error("solutions can only be loaded on a web page or in a web worker");_=location.pathname.toString().substring(0,location.pathname.toString().lastIndexOf("/"))+"/"}if(this.ha=_,l.options)for(var R=(_=te(Object.keys(l.options))).next();!R.done;R=_.next()){R=R.value;var M=l.options[R].default;M!==void 0&&(this.l[R]=typeof M=="function"?M():M)}}function Ur(l){var _,R,M,V,U,F,W,Z,pe,me,Ce;return et(function(De){switch(De.h){case 1:return l.ga?(_=l.h.files===void 0?[]:typeof l.h.files=="function"?l.h.files(l.l):l.h.files,it(De,et(function(ve){switch(ve.h){case 1:return ve.s=2,it(ve,WebAssembly.instantiate(Hd),4);case 4:ve.h=3,ve.s=0;break;case 2:return ve.s=0,ve.l=null,ve.return(!1);case 3:return ve.return(!0)}}),2)):De.return();case 2:if(R=De.i,(typeof window=="undefined"?"undefined":Q(window))==="object")return cu("createMediapipeSolutionsWasm",{locateFile:l.locateFile}),cu("createMediapipeSolutionsPackedAssets",{locateFile:l.locateFile}),F=_.filter(function(ve){return ve.data!==void 0}),W=_.filter(function(ve){return ve.data===void 0}),Z=Promise.all(F.map(function(ve){var Me=Ha(l,ve.url);if(ve.path!==void 0){var Ge=ve.path;Me=Me.then(function(ot){return l.overrideFile(Ge,ot),Promise.resolve(ot)})}return Me})),pe=Promise.all(W.map(function(ve){return ve.simd===void 0||ve.simd&&R||!ve.simd&&!R?function(Me){var Ge=document.createElement("script");return Ge.setAttribute("src",Me),Ge.setAttribute("crossorigin","anonymous"),new Promise(function(ot){Ge.addEventListener("load",function(){ot()},!1),Ge.addEventListener("error",function(){ot()},!1),document.body.appendChild(Ge)})}(l.locateFile(ve.url,l.ha)):Promise.resolve()})).then(function(){var ve,Me,Ge;return et(function(ot){if(ot.h==1)return ve=window.createMediapipeSolutionsWasm,Me=window.createMediapipeSolutionsPackedAssets,Ge=l,it(ot,ve(Me),2);Ge.i=ot.i,ot.h=0})}),me=et(function(ve){return l.h.graph&&l.h.graph.url?ve=it(ve,Ha(l,l.h.graph.url),0):(ve.h=0,ve=void 0),ve}),it(De,Promise.all([pe,Z,me]),7);if(typeof importScripts!="function")throw Error("solutions can only be loaded on a web page or in a web worker");return M=_.filter(function(ve){return ve.simd===void 0||ve.simd&&R||!ve.simd&&!R}).map(function(ve){return l.locateFile(ve.url,l.ha)}),importScripts.apply(null,Y(M)),V=l,it(De,createMediapipeSolutionsWasm(Module),6);case 6:V.i=De.i,l.m=new OffscreenCanvas(1,1),l.i.canvas=l.m,U=l.i.GL.createContext(l.m,{antialias:!1,alpha:!1,va:typeof WebGL2RenderingContext!="undefined"?2:1}),l.i.GL.makeContextCurrent(U),De.h=4;break;case 7:if(l.m=document.createElement("canvas"),!(Ce=l.m.getContext("webgl2",{}))&&!(Ce=l.m.getContext("webgl",{})))return alert("Failed to create WebGL canvas context when passing video frame."),De.return();l.K=Ce,l.i.canvas=l.m,l.i.createContext(l.m,!0,!0,{});case 4:l.j=new l.i.SolutionWasm,l.ga=!1,De.h=0}})}function Ha(l,_){var R,M;return et(function(V){return _ in l.L?V.return(l.L[_]):(R=l.locateFile(_,""),M=fetch(R).then(function(U){return U.arrayBuffer()}),l.L[_]=M,V.return(M))})}function xs(l,_,R){var M,V,U,F,W,Z,pe,me,Ce,De,ve,Me,Ge,ot;return et(function(lt){switch(lt.h){case 1:if(!R)return lt.return(_);for(M={},V=0,U=te(Object.keys(R)),F=U.next();!F.done;F=U.next())W=F.value,typeof(Z=R[W])!="string"&&Z.type==="texture"&&_[Z.stream]!==void 0&&++V;1<V&&(l.M=!1),pe=te(Object.keys(R)),F=pe.next();case 2:if(F.done){lt.h=4;break}if(me=F.value,typeof(Ce=R[me])=="string")return Ge=M,ot=me,it(lt,function(Vr,$i,mr){var Wa;return et(function(Is){return typeof mr=="number"||mr instanceof Uint8Array||mr instanceof Vr.i.Uint8BlobList?Is.return(mr):mr instanceof Vr.i.Texture2dDataOut?((Wa=Vr.v[$i])||(Wa=new gn(Vr.i,Vr.K),Vr.v[$i]=Wa),Is.return(Ga(Wa,mr,Vr.M))):Is.return(void 0)})}(l,me,_[Ce]),14);if(De=_[Ce.stream],Ce.type==="detection_list"){if(De){for(var Bt=De.getRectList(),Yt=De.getLandmarksList(),$t=De.getClassificationsList(),Je=[],wt=0;wt<Bt.size();++wt){var st=Bd(Bt.get(wt)),za=void 0;za=za===void 0?0:za,st={la:{sa:On(st,1),ta:On(st,2),height:On(st,3),width:On(st,4),rotation:On(st,5,0),pa:Ma(tn(st,6),za)},ea:hs(ks(Yt.get(wt)),Ki,1).map(Gd),ba:Fd(Vd($t.get(wt)))},Je.push(st)}Bt=Je}else Bt=[];M[me]=Bt,lt.h=7;break}if(Ce.type==="proto_list"){if(De){for(Bt=Array(De.size()),Yt=0;Yt<De.size();Yt++)Bt[Yt]=De.get(Yt);De.delete()}else Bt=[];M[me]=Bt,lt.h=7;break}if(De===void 0){lt.h=3;break}if(Ce.type==="float_list"){M[me]=De,lt.h=7;break}if(Ce.type==="proto"){M[me]=De,lt.h=7;break}if(Ce.type!=="texture")throw Error("Unknown output config type: '"+Ce.type+"'");return(ve=l.v[me])||(ve=new gn(l.i,l.K),l.v[me]=ve),it(lt,Ga(ve,De,l.M),13);case 13:Me=lt.i,M[me]=Me;case 7:Ce.transform&&M[me]&&(M[me]=Ce.transform(M[me])),lt.h=3;break;case 14:Ge[ot]=lt.i;case 3:F=pe.next(),lt.h=2;break;case 4:return lt.return(M)}})}function zd(l,_){for(var R=_.name||"$",M=[].concat(Y(_.wants)),V=new l.i.StringList,U=te(_.wants),F=U.next();!F.done;F=U.next())V.push_back(F.value);U=l.i.PacketListener.implement({onResults:function(W){for(var Z={},pe=0;pe<_.wants.length;++pe)Z[M[pe]]=W.get(pe);var me=l.listeners[R];me&&(l.I=xs(l,Z,_.outs).then(function(Ce){Ce=me(Ce);for(var De=0;De<_.wants.length;++De){var ve=Z[M[De]];Q(ve)==="object"&&ve.hasOwnProperty&&ve.hasOwnProperty("delete")&&ve.delete()}Ce&&(l.I=Ce)}))}}),l.j.attachMultiListener(V,U),V.delete()}function Yi(l){return l===void 0&&(l=0),l===1?"selfie_segmentation_landscape.tflite":"selfie_segmentation.tflite"}function li(l){var _=this;l=l||{},this.h=new Qi({locateFile:l.locateFile,files:function(R){return[{simd:!0,url:"selfie_segmentation_solution_simd_wasm_bin.js"},{simd:!1,url:"selfie_segmentation_solution_wasm_bin.js"},{data:!0,url:Yi(R.modelSelection)}]},graph:{url:"selfie_segmentation.binarypb"},listeners:[{wants:["segmentation_mask","image_transformed"],outs:{image:{type:"texture",stream:"image_transformed"},segmentationMask:{type:"texture",stream:"segmentation_mask"}}}],inputs:{image:{type:"video",stream:"input_frames_gpu"}},options:{useCpuInference:{type:0,graphOptionXref:{calculatorType:"InferenceCalculator",fieldName:"use_cpu_inference"},default:(typeof window=="undefined"?"undefined":Q(window))==="object"&&window.navigator!==void 0&&("iPad Simulator;iPhone Simulator;iPod Simulator;iPad;iPhone;iPod".split(";").includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document)},selfieMode:{type:0,graphOptionXref:{calculatorType:"GlScalerCalculator",calculatorIndex:1,fieldName:"flip_horizontal"}},modelSelection:{type:1,graphOptionXref:{calculatorType:"ConstantSidePacketCalculator",calculatorName:"ConstantSidePacketCalculatorModelSelection",fieldName:"int_value"},onChange:function(R){var M,V,U;return et(function(F){return F.h==1?(M=Yi(R),V="third_party/mediapipe/modules/selfie_segmentation/"+M,it(F,Ha(_.h,M),2)):(U=F.i,_.h.overrideFile(V,U),F.return(!0))})}}}})}(oe=Qi.prototype).close=function(){return this.j&&this.j.delete(),Promise.resolve()},oe.reset=function(){var l=this;return et(function(_){l.j&&(l.j.reset(),l.s={},l.v={}),_.h=0})},oe.setOptions=function(l,_){var R=this;if(_=_||this.h.options){for(var M=[],V=[],U={},F=te(Object.keys(l)),W=F.next();!W.done;U={X:U.X,Y:U.Y},W=F.next())if(!((W=W.value)in this.l)||this.l[W]!==l[W]){this.l[W]=l[W];var Z=_[W];Z!==void 0&&(Z.onChange&&(U.X=Z.onChange,U.Y=l[W],M.push(function(pe){return function(){return et(function(me){if(me.h==1)return it(me,pe.X(pe.Y),2);me.i===!0&&(R.u=!0),me.h=0})}}(U))),Z.graphOptionXref&&(W=Object.assign({},{calculatorName:"",calculatorIndex:0},Z.graphOptionXref,{valueNumber:Z.type===1?l[W]:0,valueBoolean:Z.type===0&&l[W],valueString:Z.type===2?l[W]:""}),V.push(W)))}M.length===0&&V.length===0||(this.u=!0,this.H=(this.H===void 0?[]:this.H).concat(V),this.F=(this.F===void 0?[]:this.F).concat(M))}},oe.initialize=function(){var l=this;return et(function(_){return _.h==1?it(_,Ur(l),2):_.h!=3?it(_,function(R){var M,V,U,F,W,Z,pe,me;return et(function(Ce){if(Ce.h==1)return R.h.graph&&R.h.graph.url&&R.fa===R.h.graph.url?Ce.return():(R.u=!0,R.h.graph&&R.h.graph.url?(R.fa=R.h.graph.url,it(Ce,Ha(R,R.h.graph.url),3)):void(Ce.h=2));for(Ce.h!=2&&(M=Ce.i,R.j.loadGraph(M)),V=te(Object.keys(R.D)),U=V.next();!U.done;U=V.next())F=U.value,R.j.overrideFile(F,R.D[F]);if(R.D={},R.h.listeners)for(W=te(R.h.listeners),Z=W.next();!Z.done;Z=W.next())pe=Z.value,zd(R,pe);me=R.l,R.l={},R.setOptions(me),Ce.h=0})}(l),3):it(_,function(R){var M,V,U,F,W,Z;return et(function(pe){switch(pe.h){case 1:if(!R.u)return pe.return();if(!R.F){pe.h=2;break}M=te(R.F),V=M.next();case 3:if(V.done){pe.h=5;break}return it(pe,(0,V.value)(),4);case 4:V=M.next(),pe.h=3;break;case 5:R.F=void 0;case 2:if(R.H){for(U=new R.i.GraphOptionChangeRequestList,F=te(R.H),W=F.next();!W.done;W=F.next())Z=W.value,U.push_back(Z);R.j.changeOptions(U),U.delete(),R.H=void 0}R.u=!1,pe.h=0}})}(l),0)})},oe.overrideFile=function(l,_){this.j?this.j.overrideFile(l,_):this.D[l]=_},oe.clearOverriddenFiles=function(){this.D={},this.j&&this.j.clearOverriddenFiles()},oe.send=function(l,_){var R,M,V,U,F,W,Z,pe,me,Ce=this;return et(function(De){switch(De.h){case 1:return Ce.h.inputs?(R=1e3*(_==null?performance.now():_),it(De,Ce.I,2)):De.return();case 2:return it(De,Ce.initialize(),3);case 3:for(M=new Ce.i.PacketDataList,V=te(Object.keys(l)),U=V.next();!U.done;U=V.next())if(F=U.value,W=Ce.h.inputs[F]){e:{var ve=l[F];switch(W.type){case"video":var Me=Ce.s[W.stream];if(Me||(Me=new gn(Ce.i,Ce.K),Ce.s[W.stream]=Me),Me.m===0&&(Me.m=Me.i.createTexture()),typeof HTMLVideoElement!="undefined"&&ve instanceof HTMLVideoElement)var Ge=ve.videoWidth,ot=ve.videoHeight;else typeof HTMLImageElement!="undefined"&&ve instanceof HTMLImageElement?(Ge=ve.naturalWidth,ot=ve.naturalHeight):(Ge=ve.width,ot=ve.height);ot={glName:Me.m,width:Ge,height:ot},(Ge=Me.h).canvas.width=ot.width,Ge.canvas.height=ot.height,Ge.activeTexture(Ge.TEXTURE0),Me.i.bindTexture2d(Me.m),Ge.texImage2D(Ge.TEXTURE_2D,0,Ge.RGBA,Ge.RGBA,Ge.UNSIGNED_BYTE,ve),Me.i.bindTexture2d(0),Me=ot;break e;case"detections":for((Me=Ce.s[W.stream])||(Me=new Ts(Ce.i),Ce.s[W.stream]=Me),Me.data||(Me.data=new Me.h.DetectionListData),Me.data.reset(ve.length),ot=0;ot<ve.length;++ot){Ge=ve[ot];var lt=Me.data,Bt=lt.setBoundingBox,Yt=ot,$t=Ge.la,Je=new Fa;if(rt(Je,1,$t.sa),rt(Je,2,$t.ta),rt(Je,3,$t.height),rt(Je,4,$t.width),rt(Je,5,$t.rotation),xn(Je,6,$t.pa),$t=Je.l(),Bt.call(lt,Yt,$t),Ge.ea)for(lt=0;lt<Ge.ea.length;++lt){Je=Ge.ea[lt],Yt=(Bt=Me.data).addNormalizedLandmark,$t=ot,Je=Object.assign({},Je,{visibility:Je.visibility?Je.visibility:0});var wt=new Ki;rt(wt,1,Je.x),rt(wt,2,Je.y),rt(wt,3,Je.z),Je.visibility&&rt(wt,4,Je.visibility),Je=wt.l(),Yt.call(Bt,$t,Je)}if(Ge.ba)for(lt=0;lt<Ge.ba.length;++lt)Yt=(Bt=Me.data).addClassification,$t=ot,Je=Ge.ba[lt],rt(wt=new ui,2,Je.qa),Je.index&&xn(wt,1,Je.index),Je.label&&xn(wt,3,Je.label),Je.displayName&&xn(wt,4,Je.displayName),Je=wt.l(),Yt.call(Bt,$t,Je)}Me=Me.data;break e;default:Me={}}}switch(Z=Me,pe=W.stream,W.type){case"video":M.pushTexture2d(Object.assign({},Z,{stream:pe,timestamp:R}));break;case"detections":(me=Z).stream=pe,me.timestamp=R,M.pushDetectionList(me);break;default:throw Error("Unknown input config type: '"+W.type+"'")}}return Ce.j.send(M),it(De,Ce.I,4);case 4:M.delete(),De.h=0}})},oe.onResults=function(l,_){this.listeners[_||"$"]=l},fe("Solution",Qi),fe("OptionType",{BOOL:0,NUMBER:1,ua:2,0:"BOOL",1:"NUMBER",2:"STRING"}),(oe=li.prototype).close=function(){return this.h.close(),Promise.resolve()},oe.onResults=function(l){this.h.onResults(l)},oe.initialize=function(){var l=this;return et(function(_){return it(_,l.h.initialize(),0)})},oe.reset=function(){this.h.reset()},oe.send=function(l){var _=this;return et(function(R){return it(R,_.h.send(l),0)})},oe.setOptions=function(l){this.h.setOptions(l)},fe("SelfieSegmentation",li),fe("VERSION","0.1.1675465747")}).call(ts);var Cr=function(oe){return typeof oe=="number"},Nc=function(){function oe(){Pe(this,oe),this.userId="",this.videoBeauty=document.createElement("video"),this.videoBeauty.loop=!0,this.videoBeauty.autoplay=!0,this.videoVirtual=document.createElement("video"),this.videoVirtual.loop=!0,this.videoVirtual.autoplay=!0,this.onoverload=null,this.canvasBeauty=document.createElement("canvas"),this.filter=new Zo({canvas:this.canvasBeauty,video:this.videoBeauty}),this.canvasVirtual=document.createElement("canvas"),this.virtual=new es({canvas:this.canvasVirtual,video:this.videoVirtual,onoverload:this.onoverload}),this.beautyParams={beauty:.5,brightness:.5,ruddy:.5},this.timeoutId=null,this.rafId=null,this.startTime=null,this.originTrack=null,this.beautyTrack=null,this.resultTrack=null,this.localStream=null,this.frameRate=null,this.disableStatus=!1,this.isVirualEnable=!1}var Te,be,Fe,He,ae;return Ye(oe,[{key:"generateBeautyStream",value:function(te){this.userId=te==null?void 0:te.getUserId();var Y=te.getVideoTrack();if(!Y)throw new Error("Your localStream does not contain video track.");var z=this.generateBeautyTrack(Y);return te.replaceTrack(z),this.localStream=te,te.setBeautyStatus&&te.setBeautyStatus(!0),console.log("RTCBeautyPlugin: generateBeautyStream ".concat(this.userId?"userId: ".concat(this.userId):"")),te}},{key:"generateBeautyTrack",value:function(te){var Y=this;this.reset();var z=te.getSettings();this.frameRate=z.frameRate,this.filter.setRect(z.width,z.height),this.setRect(z.width,z.height);var le=new MediaStream;le.addTrack(te),this.videoBeauty.srcObject=le,this.videoBeauty.play();var se=this.canvasBeauty.captureStream(this.frameRate||15).getVideoTracks()[0];return this.rafId&&cancelAnimationFrame(this.rafId),this.rafId=requestAnimationFrame(function(){Y.startTime=new Date().getTime(),Y.render()}),this.installEvents(),this.originTrack=te,this.beautyTrack=se,this.setTrackParam({type:"beauty",originTrack:te,resultTrack:se,param:this.beautyParams}),se}},{key:"setBackground",value:(ae=K(H().mark(function te(Y){return H().wrap(function(z){for(;;)switch(z.prev=z.next){case 0:return z.next=2,this.virtual.setBackground(Y);case 2:console.log("RTCBeautyPlugin: setBackground img:".concat(Y));case 3:case"end":return z.stop()}},te,this)})),function(te){return ae.apply(this,arguments)})},{key:"generateStream",value:(He=K(H().mark(function te(Y){var z,le,se,ye,ce;return H().wrap(function(Se){for(;;)switch(Se.prev=Se.next){case 0:if(z=Y.localStream,le=Y.type,se=Y.img,ye=z.getVideoTrack()){Se.next=4;break}throw new Error("Your localStream does not contain video track.");case 4:return this.localStream=z,Se.next=7,this.generateMixedTrack({videoTrack:ye,type:le,img:se});case 7:return ce=Se.sent,z.replaceTrack(ce),z.setBeautyStatus&&z.setBeautyStatus(!0),Se.abrupt("return",z);case 11:case"end":return Se.stop()}},te,this)})),function(te){return He.apply(this,arguments)})},{key:"generateMixedTrack",value:(Fe=K(H().mark(function te(Y){var z,le,se,ye,ce;return H().wrap(function(Se){for(;;)switch(Se.prev=Se.next){case 0:if(z=Y.videoTrack,le=Y.type,se=Y.img,this.virtual.selfieSegmentation){Se.next=3;break}throw new Error("you should call loadResources() first");case 3:return this.virtual.initVirtualParams({type:le,img:se}),Se.next=6,this.generateBeautyTrack(z);case 6:return ye=Se.sent,Se.next=9,this.generateVirtualTrack({videoTrack:ye,type:le,img:se});case 9:return ce=Se.sent,this.beautyTrack=ye,this.resultTrack=ce,this.setTrackParam({type:"mixed",originTrack:this.originTrack,resultTrack:this.resultTrack,param:{type:le,img:se}}),Se.abrupt("return",this.resultTrack);case 14:case"end":return Se.stop()}},te,this)})),function(te){return Fe.apply(this,arguments)})},{key:"generateVirtualStream",value:(be=K(H().mark(function te(Y){var z,le,se,ye,ce;return H().wrap(function(Se){for(;;)switch(Se.prev=Se.next){case 0:if(z=Y.localStream,le=Y.type,se=Y.img,ye=z.getVideoTrack()){Se.next=4;break}throw new Error("Your localStream does not contain video track.");case 4:return this.localStream=z,Se.next=7,this.generateVirtualTrack({videoTrack:ye,type:le,img:se});case 7:return ce=Se.sent,Se.next=10,z.replaceTrack(ce);case 10:return z.setBeautyStatus&&z.setBeautyStatus(!0),console.log("".concat(this.userId?"[userId: ".concat(this.userId,"]"):""," RTCBeautyPlugin generate ").concat(le," Stream.")),Se.abrupt("return",z);case 13:case"end":return Se.stop()}},te,this)})),function(te){return be.apply(this,arguments)})},{key:"generateVirtualTrack",value:(Te=K(H().mark(function te(Y){var z,le,se,ye;return H().wrap(function(ce){for(;;)switch(ce.prev=ce.next){case 0:if(z=Y.videoTrack,le=Y.type,se=Y.img,this.virtual.selfieSegmentation){ce.next=3;break}throw new Error("you should call loadResources() first");case 3:return ye=z.getSettings(),this.frameRate=ye.frameRate,this.virtual.setRect(ye.width,ye.height),ce.next=8,this.virtual.initVirtualParams({type:le,img:se});case 8:return this.setRect(ye.width,ye.height),this.mediaStream=new MediaStream,this.mediaStream.addTrack(z),this.videoVirtual.srcObject=this.mediaStream,ce.next=14,this.videoVirtual.play();case 14:return this.virtual.startVirtual(this.frameRate),ce.next=17,this.virtual.render();case 17:return this.originTrack=z,this.resultTrack=this.canvasVirtual.captureStream(this.frameRate||15).getVideoTracks()[0],this.setTrackParam({type:"virtual",originTrack:this.originTrack,resultTrack:this.resultTrack,param:{type:le,img:se}}),this.isVirualEnable=!0,ce.abrupt("return",this.resultTrack);case 22:case"end":return ce.stop()}},te,this)})),function(te){return Te.apply(this,arguments)})},{key:"replaceVirtualTrack",value:function(te){this.isVirualEnable&&(this.mediaStream.removeTrack(this.mediaStream.getVideoTracks()[0]),this.mediaStream.addTrack(te),this.originTrack=te)}},{key:"deleteSource",value:function(te){if(m.default){var Y=m.default.beautyTrackMap.get(te);Y&&(Y.type==="mixed"&&this.deleteSource(Y.originTrack.id),Y.originTrack&&(Y.originTrack.stop(),Y.originTrack=null),Y.beautyTrack&&(Y.beautyTrack.stop(),Y.beautyTrack=null),Y.resultTrack&&(Y.resultTrack.stop(),Y.resultTrack=null),m.default.beautyTrackMap.delete(te))}}},{key:"draw",value:function(){this.videoBeauty&&this.videoBeauty.readyState===this.videoBeauty.HAVE_ENOUGH_DATA&&this.filter.apply(this.videoBeauty)}},{key:"enableVirtualBg",value:function(){var te;if(this.virtual&&!this.isVirualEnable)return this.virtual.setEnable(!0),this.virtual.render(),this.isVirualEnable=!0,(te=this.localStream)===null||te===void 0||te.replaceTrack(this.resultTrack),console.log("".concat(this.userId?"[userId: ".concat(this.userId,"]"):""," RTCBeautyPlugin enable.")),this.resultTrack}},{key:"disableVirtualBg",value:function(){var te;if(this.virtual&&this.isVirualEnable)return this.virtual.setEnable(!1),this.isVirualEnable=!1,(te=this.localStream)===null||te===void 0||te.replaceTrack(this.originTrack),console.log("".concat(this.userId?"[userId: ".concat(this.userId,"]"):""," RTCBeautyPlugin disable.")),this.originTrack}},{key:"changeType",value:function(te){var Y=te.type,z=te.img;console.log("".concat(this.userId?"[userId: ".concat(this.userId,"]"):""," RTCBeautyPlugin changeType\uFF1A").concat(Y,". img: ").concat(z,".")),Y==="blur"&&(this.virtual.reset(),this.virtual.initVirtualParams({type:"blur"}),this.virtual.startVirtual(this.frameRate),this.virtual.render()),Y==="virtual"&&(this.virtual.reset(),this.virtual.initVirtualParams({type:"virtual",img:z}),this.virtual.startVirtual(this.frameRate),this.virtual.render()),this.setTrackParam({type:Y,originTrack:this.originTrack,resultTrack:this.resultTrack,param:{type:Y,img:z}})}},{key:"render",value:function(){var te=this,Y=new Date().getTime();Y-this.startTime>1e3/this.frameRate&&(this.draw(),this.startTime=Y),document.hidden?(clearTimeout(this.timeoutId),this.timeoutId=setTimeout(function(){te.render()},1e3/this.frameRate)):(this.timeoutId&&clearTimeout(this.timeoutId),this.rafId&&cancelAnimationFrame(this.rafId),this.rafId=requestAnimationFrame(this.render.bind(this)))}},{key:"setBeautyParam",value:function(te){var Y=te.beauty,z=te.brightness,le=te.ruddy;Cr(Y)&&(this.beautyParams.beauty=Y),Cr(z)&&(this.beautyParams.brightness=z),Cr(le)&&(this.beautyParams.ruddy=le),this.filter.setBeautyParams(this.beautyParams),this.getClose()&&!this.disableStatus&&this.disable(),!this.getClose()&&this.disableStatus&&this.enable()}},{key:"setRect",value:function(te,Y){var z=te||640,le=Y||480;this.videoBeauty.height=le,this.videoBeauty.width=z,this.canvasBeauty.height=le,this.canvasBeauty.width=z,this.videoVirtual.height=le,this.videoVirtual.width=z,this.canvasVirtual.height=le,this.canvasVirtual.width=z}},{key:"reset",value:function(){cancelAnimationFrame(this.rafId),clearTimeout(this.timeoutId),this.videoBeauty.pause(),this.filter.reset(),this.beautyTrack&&this.beautyTrack.stop(),this.videoVirtual.pause(),this.resultTrack&&this.resultTrack.stop(),this.originTrack&&this.originTrack.stop()}},{key:"destroy",value:function(){cancelAnimationFrame(this.rafId),clearTimeout(this.timeoutId),this.canvasBeauty&&(this.canvasBeauty.width=0,this.canvasBeauty.height=0,this.canvasBeauty.remove(),this.canvasBeauty=null),this.videoBeauty&&(this.videoBeauty.pause(),this.videoBeauty.removeAttribute("srcObject"),this.videoBeauty.removeAttribute("src"),this.videoBeauty.load(),this.videoBeauty.width=0,this.videoBeauty.height=0,this.videoBeauty.remove(),this.videoBeauty=null),this.beautyTrack&&(this.deleteSource(this.beautyTrack.id),this.beautyTrack.stop(),this.beautyTrack=null),this.originTrack&&(this.originTrack.stop(),this.originTrack=null),this.resultTrack&&(this.deleteSource(this.resultTrack.id),this.resultTrack.stop(),this.resultTrack=null),this.canvasVirtual&&(this.canvasVirtual.width=0,this.canvasVirtual.height=0,this.canvasVirtual.remove(),this.canvasVirtual=null),this.videoVirtual&&(this.videoVirtual.pause(),this.videoVirtual.removeAttribute("srcObject"),this.videoVirtual.removeAttribute("src"),this.videoVirtual.load(),this.videoVirtual.width=0,this.videoVirtual.height=0,this.videoVirtual.remove(),this.videoVirtual=null),this.virtual.destroy(),this.uninstallEvents()}},{key:"generateVideoTrackFromCanvasCapture",value:function(te){return this.canvasVirtual.captureStream(te).getVideoTracks()[0]}},{key:"setTrackParam",value:function(te){var Y=te.type,z=te.originTrack,le=te.resultTrack,se=te.param;m.default&&(m.default.beautyTrackMap||(m.default.beautyTrackMap=new Map),m.default.beautyTrackMap.set(le.id,{type:Y,originTrack:z,resultTrack:le,param:se,pluginInstance:this}))}},{key:"disable",value:function(){this.localStream&&this.originTrack&&(this.localStream.replaceTrack(this.originTrack),cancelAnimationFrame(this.rafId),clearTimeout(this.timeoutId),this.disableStatus=!0)}},{key:"enable",value:function(){this.localStream&&this.beautyTrack&&(this.localStream.replaceTrack(this.beautyTrack),this.render(),this.disableStatus=!1)}},{key:"installEvents",value:function(){document.addEventListener("visibilitychange",this.render.bind(this))}},{key:"uninstallEvents",value:function(){document.removeEventListener("visibilitychange",this.render.bind(this))}},{key:"overload",value:function(){this.onoverload&&this.onoverload()}},{key:"getClose",value:function(){return this.beautyParams.beauty===0&&this.beautyParams.brightness===0&&this.beautyParams.ruddy===0}}]),oe}();return m.default&&(m.default.getRTCBeautyPlugin=function(){return new Nc}),Nc})});var iw="0.0.15";var yd=ur(Er());var _d=ur(Er());var mw=ur(sg());var qo=class extends mw.default{constructor({mediaType:m}){super();Be(this,"trackMediaType");Be(this,"_stream");Be(this,"_playerState");this.trackMediaType=m}get isPlaying(){return this._playerState==="PLAYING"}async stop(){this._playerState="STOPPED",await this._stream.stop()}};var C7=1,Jo=class extends qo{constructor(m){super(m);Be(this,"TRTC",_d.default);Be(this,"muted");Be(this,"_publishedStream",null);Be(this,"_log");this._log=jt.createLogger({id:m.id+C7++})}get closed(){let m=this.getMediaStreamTrack();return m?m.readyState==="ended":!0}async init(){this._stream.on("device-auto-recovered",async({isMicrophone:m,isCamera:H,microphoneId:Q,cameraId:G})=>{if(this._publishedStream&&this._stream!==this._publishedStream){let K=this.getMediaStreamTrack(),Pe=this.trackMediaType==="audio"?this._publishedStream.getAudioTrack():this._publishedStream.getVideoTrack();K&&Pe&&K!==Pe&&this._publishedStream.replaceTrack(K)}if(m){let K=(await _d.default.getMicrophones()).find(Pe=>Pe.deviceId===Q);K&&this.emit("device-switched",K)}if(H){let K=(await _d.default.getCameras()).find(Pe=>Pe.deviceId===G);K&&this.emit("device-switched",K)}}),this._stream.on("player-state-changed",({state:m})=>{this._playerState=m}),this._stream.on("error",m=>{m.getCode()===16452&&this.emit("track-ended",this.trackMediaType)}),await this._stream.initialize()}setPublishedStream(m){this._publishedStream=m}on(m,H){return super.on(m,H),this}async setMuted(m){let H=this._publishedStream||this._stream;this.trackMediaType==="audio"?m?H.muteAudio():H.unmuteAudio():m?H.muteVideo():H.unmuteVideo()}getMediaStreamTrack(){return this.trackMediaType==="audio"?this._stream.getAudioTrack():this._stream.getVideoTrack()}close(){this._stream.close()}getTrackLabel(){var m;return((m=this.getMediaStreamTrack())==null?void 0:m.label)||""}getDeviceId(){var m,H;return((H=(m=this.getMediaStreamTrack())==null?void 0:m.getSettings())==null?void 0:H.deviceId)||""}};var gw=ur(vw()),_w=ur(Er());var Ko=class extends Jo{constructor(m){super(m);Be(this,"mirrored",!1);Be(this,"lastPlayContainer");Be(this,"_beautyPlugin");Be(this,"_virtualTrack");Be(this,"_isVirtualEnable",!1);Be(this,"_imageUrl",null);this.onOriginTrackEnded=this.onOriginTrackEnded.bind(this)}get _originTrack(){var m;return((m=this._beautyPlugin)==null?void 0:m.originTrack)||null}get videoElement(){var m;return((m=this.lastPlayContainer)==null?void 0:m.querySelector(`#video_${this._stream.getId()}`))||null}mirrorVideo(m){this.lastPlayContainer&&this._stream.play(this.lastPlayContainer,{mirror:m}),this.mirrored=m}async applyVirtualBackground(m){var H;if(this._log.info(`applyVirtualBackground ${m} ${this._imageUrl}`),!m)return this.stopVirtualBackground(),!0;if(m===this._imageUrl)return!0;if(this._beautyPlugin||(this._beautyPlugin=new gw.default,await this._beautyPlugin.virtual.loadResources(),this._beautyPlugin.virtual.onoverload=()=>{this._log.info("virtualBackground is onoverload"),this.emit("VirtualBackgroundOverload")}),this._imageUrl)m==="blur"&&this._imageUrl!=="blur"&&this._beautyPlugin.changeType({type:"blur"}),m!=="blur"&&this._imageUrl==="blur"&&this._beautyPlugin.changeType({type:"virtual",img:m}),m!=="blur"&&this._imageUrl!=="blur"&&this._imageUrl!==m&&await this._beautyPlugin.setBackground(m);else{let Q=await this._beautyPlugin.generateVirtualStream({localStream:this._stream,type:m==="blur"?"blur":"virtual",img:m==="blur"?void 0:m});this._virtualTrack=Q.getVideoTrack(),this._publishedStream&&this._publishedStream.replaceTrack(this._virtualTrack),this._isVirtualEnable=!0}return(H=this._originTrack)==null||H.addEventListener("ended",this.onOriginTrackEnded),this._imageUrl=m,!this._isVirtualEnable&&this._beautyPlugin&&(this._isVirtualEnable=!0,this._beautyPlugin.enableVirtualBg()),!0}async onOriginTrackEnded(){let m=(await _w.default.getCameras())[0];m?this.setDevice(m.deviceId):this.emit("track-ended",this.trackMediaType)}async stopVirtualBackground(){var m;return this._log.info("stopVirtualBackground is called"),this._beautyPlugin&&this._isVirtualEnable&&(this._log.info("RTCBeautyPlugin: call disableVirtualBackground"),this._beautyPlugin.disableVirtualBg(),this._isVirtualEnable=!1,(m=this._originTrack)==null||m.removeEventListener("ended",this.onOriginTrackEnded)),!0}getDeviceId(){var m,H;return this._isVirtualEnable||this._beautyPlugin?((H=(m=this._beautyPlugin.originTrack)==null?void 0:m.getSettings())==null?void 0:H.deviceId)||"":super.getDeviceId()}getMediaStreamTrack(){return this._originTrack&&(this._isVirtualEnable||this._beautyPlugin)?this._originTrack:super.getMediaStreamTrack()}close(){var m;(m=this._beautyPlugin)==null||m.destroy()}};var Ca=class extends Ko{constructor(m){var Pe;super(md(ni({},m),{mediaType:"video"}));Be(this,"_videoProfile",{width:320,height:240,frameRate:15,bitrate:300});let{width:H,height:Q,frameRate:G,bitrate:K}=m;jt.info("new LingoCameraVideoTrack"),this._stream=yd.default.createStream({audio:!1,video:!0,cameraId:m.cameraId}),H&&(this._videoProfile.width=H),Q&&(this._videoProfile.height=Q),G&&(this._videoProfile.frameRate=G),K&&(this._videoProfile.bitrate=K),this._stream.setVideoProfile(this._videoProfile),(Pe=this._publishedStream)==null||Pe.setVideoProfile(this._videoProfile)}getVideoProfile(){return this._videoProfile}async play(m){await this._stream.play(m.container,{mirror:this.mirrored}),this.lastPlayContainer=m.container}async stop(){await super.stop(),this.lastPlayContainer=null}async setDevice(m){var G,K,Pe,we;let H=this._beautyPlugin&&this._isVirtualEnable;if(this._log.info(`setDevice ${m} visual: ${H}`),H){let Ye=yd.default.createStream({audio:!1,video:!0,cameraId:m});Ye.setVideoProfile(this._videoProfile),(G=this._publishedStream)==null||G.setVideoProfile(this._videoProfile),await Ye.initialize();let Ct=Ye.getVideoTrack();Ct&&((K=this._originTrack)==null||K.removeEventListener("ended",this.onOriginTrackEnded),await((Pe=this._beautyPlugin)==null?void 0:Pe.replaceVirtualTrack(Ct)),(we=this._originTrack)==null||we.addEventListener("ended",this.onOriginTrackEnded))}else if(await this._stream.switchDevice(this.trackMediaType,m),this._publishedStream&&this._publishedStream!==this._stream){let Ye=this.getMediaStreamTrack();Ye&&await this._publishedStream.replaceTrack(Ye)}let Q=(await yd.default.getCameras()).find(Ye=>Ye.deviceId===m);Q&&this.emit("device-switched",Q),!this._isVirtualEnable&&this._beautyPlugin&&(this._beautyPlugin.destroy(),this._beautyPlugin=null,this._isVirtualEnable=!1,this._imageUrl=null)}close(){var m;(m=this.getMediaStreamTrack())==null||m.stop(),this._stream.hasAudio()||this._stream.close(),super.close()}};var yw=ur(Er());var R7=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(ne){let q=Math.random()*16|0;return(ne=="x"?q:q&3|8).toString(16)})};function bd(){return!performance||!performance.now?Date.now():Math.floor(performance.now())}var lg=class{constructor(){this.intervalMap_=new Map}setInterval(q,m,H=!0){if(!window||!window.requestAnimationFrame)return setInterval(q,m);let Q=R7(),G=bd(),K=G;this.intervalMap_.set(Q,{rafId:null,timeoutId:null,onVisibilityChange:null});let Pe=()=>{if(H&&document.hidden){if(q(),!this.intervalMap_.has(Q))return;let Ye=setTimeout(Pe,m);this.setTimeoutId(Q,Ye),G=bd(),K=G}else{if(K=bd(),K-G>=m&&(G=K,q(),!this.intervalMap_.has(Q)))return;let Ye=requestAnimationFrame(Pe);this.setRafId(Q,Ye)}},we=requestAnimationFrame(Pe);if(this.setRafId(Q,we),H){let Ye=()=>{if(document.hidden){let Ct=bd()-G;if(Ct>=m)Pe();else{let Xe=setTimeout(Pe,m-Ct);this.setTimeoutId(Q,Xe)}}};document.addEventListener("visibilitychange",Ye),this.setOnVisibilityChange(Q,Ye),document.hidden&&Ye()}return Q}clearInterval(q){if(this.intervalMap_.has(q)){let{rafId:m,timeoutId:H,onVisibilityChange:Q}=this.intervalMap_.get(q);cancelAnimationFrame(m),clearTimeout(H),document.removeEventListener("visibilitychange",Q),this.intervalMap_.delete(q)}}setTimeoutId(q,m){if(this.intervalMap_.has(q)){let H=this.intervalMap_.get(q);H.timeoutId&&clearTimeout(H.timeoutId),H.timeoutId=m}}setRafId(q,m){if(this.intervalMap_.has(q)){let H=this.intervalMap_.get(q);H.rafId&&cancelAnimationFrame(H.rafId),H.rafId=m}}setOnVisibilityChange(q,m){if(this.intervalMap_.has(q)){let H=this.intervalMap_.get(q);H.onVisibilityChange=m}}},A7=new lg,dg=A7;var Sd=class extends Ko{constructor(m){super({mediaType:"video",id:"cus"});Be(this,"frameRate",0);Be(this,"canvas",document.createElement("canvas"));Be(this,"canvasCtx");Be(this,"onDraw",null);Be(this,"_cameraVideoTrack",null);Be(this,"_timerId");this._cameraVideoTrack=m}timerStop(){dg.clearInterval(this._timerId)}async init(){var Q;if(this.canvasCtx)return;this.canvasCtx=this.canvas.getContext("2d");let m=(Q=this._cameraVideoTrack)==null?void 0:Q.getMediaStreamTrack();if(m){let{width:G,height:K,frameRate:Pe}=m.getSettings();G&&(this.canvas.width=G),K&&(this.canvas.height=K),Pe&&(this.frameRate=Pe)}this._timerId=dg.setInterval(()=>{var Pe,we,Ye;let G=(Pe=this._cameraVideoTrack)==null?void 0:Pe.getMediaStreamTrack();if(G){let{width:Ct,height:Xe,frameRate:lr}=G.getSettings();Ct&&(this.canvas.width=Ct),Xe&&(this.canvas.height=Xe),lr&&(this.frameRate=lr)}let K=(we=this._cameraVideoTrack)==null?void 0:we.videoElement;K&&((Ye=this.canvasCtx)==null||Ye.drawImage(K,0,0,this.canvas.width,this.canvas.height),this.onDraw&&this.onDraw(this.canvas,this.mirrored))},1e3/this.frameRate,!0);let H=this.canvas.captureStream(this.frameRate).getVideoTracks()[0];this._stream=yw.default.createStream({videoSource:H}),await super.init()}async play(m){var H,Q,G,K;if(m.container){this.lastPlayContainer=m.container,(H=this._cameraVideoTrack)!=null&&H.isPlaying||await((Q=this._cameraVideoTrack)==null?void 0:Q.play({container:m.container}));let Pe=(G=this._cameraVideoTrack)==null?void 0:G.videoElement;Pe&&Pe.parentElement&&(Pe.parentElement.style.display="none"),await this._stream.play(m.container),this.mirrorVideo(this.mirrored)}(K=m.custom)!=null&&K.onDraw&&(this.onDraw=m.custom.onDraw)}async stop(){var H;this.onDraw=null;let m=(H=this._cameraVideoTrack)==null?void 0:H.videoElement;m&&m.parentElement&&(m.parentElement.style.display="block"),await this._stream.stop(),this.lastPlayContainer=null}setDevice(m){return Promise.resolve()}};var hg=ur(Er());function kd(ne){return ne*1.5>100?100:ne*1.5}var Td=class extends Jo{constructor({microphoneId:m}){super({mediaType:"audio"});Be(this,"_captureVolume",100);Be(this,"_div",document.createElement("div"));Be(this,"_isPlayCalled",!1);jt.info("new LingoMicrophoneAudioTrack"),this._stream=hg.default.createStream({audio:!0,video:!1,microphoneId:m})}async play(){return this._isPlayCalled=!0,await this._stream.play(this._div,{muted:!1})}stop(){return this._isPlayCalled=!1,super.stop()}setPublishedStream(m){var H;m===null?(H=this._publishedStream)==null||H.setAudioCaptureVolume(100):m.setAudioCaptureVolume(this._captureVolume),super.setPublishedStream(m)}async setDevice(m){if(jt.warn(`switch mic ${m}`),m==="default"&&this._stream.isAudioRecovering_)return;if(await this._stream.switchDevice(this.trackMediaType,m),this._publishedStream&&this._publishedStream!==this._stream){let Q=this.getMediaStreamTrack();Q&&await this._publishedStream.replaceTrack(Q)}let H=(await hg.default.getMicrophones()).find(Q=>Q.deviceId===m);H&&this.emit("device-switched",H)}setVolume(m){var H;(H=this._publishedStream)==null||H.setAudioCaptureVolume(m),this._captureVolume=m}getVolume(){return this._isPlayCalled||(this._isPlayCalled=!0,this._stream.play(this._div)),kd(this._stream.getAudioLevel()*100)}setSpeakerDevice(m){return this._stream.setAudioOutput(m)}close(){var m;(m=this.getMediaStreamTrack())==null||m.stop(),this._stream.hasAudio()||this._stream.close()}};var Xo=class extends qo{constructor({uid:m,mediaType:H,stream:Q}){super({mediaType:H});Be(this,"uid");Be(this,"isSubscribed",!1);this.uid=m,this._stream=Q,this._stream.on("player-state-changed",({state:G})=>{this._playerState=G})}subscribe(){this.isSubscribed=!0}unsubscribe(){this.isSubscribed=!1}};var xd=class extends Xo{constructor({uid:q,stream:m}){super({uid:q,mediaType:"audio",stream:m})}setVolume(q){this._stream.setAudioVolume(q/100)}getVolume(){return kd(this._stream.getAudioLevel()*100)}setSpeakerDevice(q){return this._stream.setAudioOutput(q)}async play(){return this._stream.isPlaying()?Promise.resolve():this._stream.play(document.createElement("div"))}};var Id=class extends Xo{constructor({uid:m,stream:H}){super({uid:m,mediaType:"video",stream:H});Be(this,"mirrored",!1);Be(this,"lastPlayContainer")}async play(m){await this._stream.play(m.container),this.lastPlayContainer=m.container}async stop(){await super.stop(),this.lastPlayContainer=null}mirrorVideo(m){this.lastPlayContainer&&(this._stream.play(this.lastPlayContainer,{mirror:m}),this.mirrored=m)}};import{LingoBaseRTC as D7,LingoRTCError as vg}from"@lingoace/lingo-base-rtc";var pg=ur(Er());import{LingoBaseRTCClient as P7,LingoRTCError as Qo,config as Oc}from"@lingoace/lingo-base-rtc";var wd=new WeakMap;function Ed(){return function(ne,q,m){let H=m.value,Q=({fn:G,args:K,context:Pe,resolve:we,reject:Ye})=>{G.apply(Pe,K).then(we,Ye).finally(()=>{let Ct=wd.get(Pe);Ct.shift(),Ct[0]&&Q(ni({},Ct[0]))})};return m.value=function(...G){return new Promise((K,Pe)=>{if(wd.has(this)){let we=wd.get(this),{length:Ye}=we;we.push({fn:H,args:G,context:this,resolve:K,reject:Pe}),Ye===0&&Q({fn:H,args:G,context:this,resolve:K,reject:Pe})}else wd.set(this,[{fn:H,args:G,context:this,resolve:K,reject:Pe}]),Q({fn:H,args:G,context:this,resolve:K,reject:Pe})})},m}}import{LingoRTCError as bw}from"@lingoace/lingo-base-rtc";function An(ne){return function(q,m,H){let Q=H.value;return H.value=async function(...G){try{return await Q.apply(this,G)}catch(K){throw ne?ne(K):K instanceof bw?K:bw.createOtherError(K.message)}},H}}var Pn=class extends P7{constructor(){super(...arguments);Be(this,"_client",null);Be(this,"_localStream",null);Be(this,"_screenStream",null);Be(this,"_remoteAuxiliaryStream",null);Be(this,"_remoteMainStreamMap",new Map);Be(this,"_remoteUserIdSet",new Set);Be(this,"_quality",{res:"0x0",vfps:0,vra:0,ara:0,rtt:0,pktLostRate:0,upQuality:0,downQuality:0});Be(this,"_prevLocalVideoStat",null);Be(this,"_prevLocalAudioStat",null)}getRemoteUsers(){let m=new Map;return this._remoteUserIdSet.forEach(H=>{m.set(H,{uid:H,hasAudio:!1,hasVideo:!1})}),this.remoteAudioTrackMap.forEach(H=>{if(m.has(H.uid)){let Q=m.get(H.uid);Q.hasAudio=!0,Q.audioTrack=H.isSubscribed?H:void 0}else m.set(H.uid,{uid:H.uid,hasAudio:!0,hasVideo:!1,audioTrack:H.isSubscribed?H:void 0,videoTrack:void 0})}),this.remoteVideoTrackMap.forEach(H=>{let{uid:Q}=H;if(m.has(H.uid)){let G=m.get(H.uid);G.hasVideo=!0,G.videoTrack=H.isSubscribed?H:void 0}else m.set(Q,{uid:Q,hasAudio:!1,hasVideo:!0,audioTrack:void 0,videoTrack:H.isSubscribed?H:void 0})}),[...m.values()]}async join(m){return this._client=pg.default.createClient({sdkAppId:Number(m.appId),userId:m.uid,userSig:m.token,mode:"rtc",useStringRoomId:!0,autoSubscribe:!1,enableAutoPlayDialog:!1}),this.handleEvents(),await this._client.join({roomId:m.roomId}),this.joinParam=m,this.uid=m.uid,m.uid}async leave(){!this._client||(await this._client.leave(),this.joinParam=void 0,this._client=null)}start(){return Promise.resolve()}async publish(m){return this._localStream?(m instanceof Ca&&await this._localStream.setVideoProfile(m.getVideoProfile()),await this._localStream.addTrack(m.getMediaStreamTrack())):(await this._client.publish(m._stream),this._localStream=m._stream),m.setPublishedStream(this._localStream),this.localTracks.push(m),!0}async unpublish(m){var Q;let H=m.getMediaStreamTrack();return!H||!this._localStream||this.localTracks.length===0||(this.localTracks.length===1?(await((Q=this._client)==null?void 0:Q.unpublish(this._localStream)),m.setPublishedStream(null),this._localStream=null,this.localTracks=[]):this.localTracks.find(G=>G===m)&&(await this._localStream.removeTrack(H),m.setPublishedStream(null),this.localTracks=this.localTracks.filter(G=>G!==m))),!0}async subscribe(m,H){var Q,G;if(!this._client)throw Qo.createOtherError("\u7528\u6237\u672A\u8FDB\u623F\uFF0C\u65E0\u6CD5\u8BA2\u9605");if(H==="audio"&&!this.remoteAudioTrackMap.has(m))throw Qo.createOtherError(`\u8FDC\u7AEF\u7528\u6237: ${m} \u672A\u63A8\u97F3\u9891\uFF0C\u65E0\u6CD5\u8BA2\u9605`);if(H==="video"&&m!==Oc.screenSharingUid&&!this.remoteVideoTrackMap.has(m))throw Qo.createOtherError(`\u8FDC\u7AEF\u7528\u6237: ${m} \u672A\u63A8\u89C6\u9891\uFF0C\u65E0\u6CD5\u8BA2\u9605`);if(jt.info(`subscribe ${m} ${H}`),m===Oc.screenSharingUid&&this._remoteAuxiliaryStream&&this._client)return await this._client.subscribe(this._remoteAuxiliaryStream),!0;if(H==="audio"){let K=this.remoteAudioTrackMap.get(m);K.subscribe();try{await this._client.subscribe(K._stream,{audio:!0,video:!!((Q=this.remoteVideoTrackMap.get(m))!=null&&Q.isSubscribed)})}catch(Pe){throw K.unsubscribe(),Pe}}else{let K=this.remoteVideoTrackMap.get(m);K.subscribe();try{await this._client.subscribe(K._stream,{video:!0,audio:!!((G=this.remoteAudioTrackMap.get(m))!=null&&G.isSubscribed)})}catch(Pe){throw K.unsubscribe(),Pe}}return!0}async unsubscribe(m,H){var G,K;if(!this._client)throw Qo.createOtherError("\u7528\u6237\u672A\u8FDB\u623F\uFF0C\u65E0\u6CD5\u8BA2\u9605");jt.info(`unsubscribe ${m} ${H}`);let Q=null;if(H==="audio"&&this.remoteAudioTrackMap.has(m)?Q=this.remoteAudioTrackMap.get(m):H==="video"&&this.remoteVideoTrackMap.has(m)&&(Q=this.remoteVideoTrackMap.get(m)),!Q)throw Qo.createOtherError(`\u8FDC\u7AEF\u7528\u6237: ${m} \u672A\u63A8 ${H}\uFF0C\u65E0\u6CD5\u8BA2\u9605`);return m===Oc.screenSharingUid&&this._remoteAuxiliaryStream?(await this._client.unsubscribe(this._remoteAuxiliaryStream),!0):(H==="audio"?(G=this.remoteVideoTrackMap.get(m))!=null&&G.isSubscribed?await this._client.subscribe(Q._stream,{video:!0,audio:!1}):await this._client.unsubscribe(Q._stream):(K=this.remoteAudioTrackMap.get(m))!=null&&K.isSubscribed?await this._client.subscribe(Q._stream,{video:!1,audio:!0}):await this._client.unsubscribe(Q._stream),Q.unsubscribe(),!0)}getQOEStats(){return this._quality}async startScreenShare(m){if(!this.joinParam||!this._client)throw Qo.createOtherError("\u7528\u6237\u672A\u8FDB\u623F\uFF0C\u65E0\u6CD5\u5F00\u542F\u5C4F\u5E55\u5206\u4EAB");this._screenStream=pg.default.createStream({screen:!0,screenAudio:!0});let H={width:1280,height:720,frameRate:15,bitrate:2e3};this._screenStream.setScreenProfile(ni(ni({},H),m)),this._screenStream.on("screen-sharing-stopped",async()=>{await this.stopScreenShare(),this.emit("ScreenSharingEnded")}),await this._screenStream.initialize(),await this._client.publish(this._screenStream,{isAuxiliary:!0})}async stopScreenShare(){!this._client||!this._screenStream||(await this._client.unpublish(this._screenStream),this._screenStream.stop(),this._screenStream.close(),this._screenStream=null)}async playScreenShareView(m){var H;this._remoteAuxiliaryStream&&this._client?(await this._client.subscribe(this._remoteAuxiliaryStream),await this._remoteAuxiliaryStream.play(m)):await((H=this._screenStream)==null?void 0:H.play(m))}async stopScreenShareView(){var m;this._remoteAuxiliaryStream&&this._client?(await this._client.unsubscribe(this._remoteAuxiliaryStream),await this._remoteAuxiliaryStream.stop()):await((m=this._screenStream)==null?void 0:m.stop())}handleEvents(){!this._client||(this._client.on("connection-state-changed",({prevState:m,state:H})=>{this.connectionState=H,this.emit("ConnectionStateChange",H,m,"")}),this._client.on("peer-join",m=>{this._remoteUserIdSet.add(m.userId),this.emit("UserJoined",m.userId)}),this._client.on("peer-leave",m=>{this._remoteUserIdSet.delete(m.userId),this.emit("UserLeft",m.userId)}),this._client.on("stream-added",m=>{let H=m.stream,Q=H.getUserId();if(H.getType()==="auxiliary"){this._remoteAuxiliaryStream=H,this.emit("RemoteScreenSharing",Oc.screenSharingUid,!0,"video");return}this._remoteMainStreamMap.set(Q,H),H.on("error",G=>{if(G.getCode()===16451){let K=()=>{H.resume().then(()=>{document.body.removeEventListener("click",K),document.body.removeEventListener("touchstart",K)})};document.body.addEventListener("click",K,!0),document.body.addEventListener("touchstart",K,!0),this.emit("AutoplayFailed")}}),H.hasAudio()&&this.handleUserPublished(Q,"audio"),H.hasVideo()&&this.handleUserPublished(Q,"video")}),this._client.on("stream-updated",m=>{let H=m.stream,Q=H.getUserId();!this.remoteAudioTrackMap.has(Q)&&H.hasAudio()&&this.handleUserPublished(Q,"audio"),this.remoteAudioTrackMap.has(Q)&&!H.hasAudio()&&this.handleUserUnpublished(Q,"audio"),!this.remoteVideoTrackMap.has(Q)&&H.hasVideo()&&this.handleUserPublished(Q,"video"),this.remoteVideoTrackMap.has(Q)&&!H.hasVideo()&&this.handleUserUnpublished(Q,"video")}),this._client.on("stream-removed",m=>{let H=m.stream.getUserId();if(m.stream.getType()==="auxiliary"){this._remoteAuxiliaryStream=null,this.emit("RemoteScreenSharing",Oc.screenSharingUid,!1,"video");return}this._remoteMainStreamMap.delete(H),this.handleUserUnpublished(H,"audio"),this.handleUserUnpublished(H,"video")}),this._client.on("network-quality",m=>{var H,Q;this._quality.upQuality=m.uplinkNetworkQuality,this._quality.downQuality=m.downlinkNetworkQuality,this._quality.rtt=m.uplinkRTT,this._quality.pktLostRate=m.uplinkLoss,(H=this._client)==null||H.getLocalVideoStats().then(G=>{let K=G[this.uid];K&&(this._quality.res=`${K.frameWidth}x${K.frameHeight}`,this._prevLocalVideoStat&&(this._quality.vfps=Math.floor((K.framesSent-this._prevLocalVideoStat.framesSent)/2)||0,this._quality.vra=Math.floor((K.bytesSent-this._prevLocalVideoStat.bytesSent)*8/2)||0),this._prevLocalVideoStat=K)}),(Q=this._client)==null||Q.getLocalAudioStats().then(G=>{let K=G[this.uid];K&&(this._prevLocalAudioStat&&(this._quality.ara=Math.floor((K.bytesSent-this._prevLocalAudioStat.bytesSent)*8/2)||0),this._prevLocalAudioStat=K)}),this.emit("NetworkQuality",m)}),this._client.on("mute-audio",m=>{this.handleUserUnpublished(m.userId,"audio")}),this._client.on("unmute-audio",m=>{this.handleUserPublished(m.userId,"audio",!0)}))}handleUserUnpublished(m,H){jt.info(`UserUnpublished ${m} ${H}`),H==="audio"?this.remoteAudioTrackMap.has(m)&&(this.remoteAudioTrackMap.delete(m),this.emit("UserUnpublished",m,H)):this.remoteVideoTrackMap.has(m)&&(this.remoteVideoTrackMap.delete(m),this.emit("UserUnpublished",m,H))}handleUserPublished(m,H,Q=!1){var Pe;jt.info(`UserPublished ${m} ${H} firedByUnmute: ${Q}`);let G=this._remoteMainStreamMap.get(m),K=(Pe=this._client)==null?void 0:Pe.getRemoteMutedState().find(we=>we.userId===m);if(G){if(H==="audio"&&!this.remoteAudioTrackMap.has(m)&&G.hasAudio()){if(!Q&&K&&K.audioMuted)return;let we=new xd({uid:m,stream:G});this.remoteAudioTrackMap.set(m,we)}else if(H==="video"&&!this.remoteVideoTrackMap.has(m)&&G.hasVideo()){let we=new Id({uid:m,stream:G});this.remoteVideoTrackMap.set(m,we)}this.emit("UserPublished",m,H)}}};Rn([An(),Ed()],Pn.prototype,"publish",1),Rn([An()],Pn.prototype,"unpublish",1),Rn([An()],Pn.prototype,"subscribe",1),Rn([An()],Pn.prototype,"unsubscribe",1),Rn([An()],Pn.prototype,"startScreenShare",1),Rn([An()],Pn.prototype,"stopScreenShare",1),Rn([An()],Pn.prototype,"playScreenShareView",1),Rn([An()],Pn.prototype,"stopScreenShareView",1);var $o=ur(Er());var Sw=ur(sg()),fg=ur(Er());var mg=class extends Sw.default{constructor(){super();Be(this,"prevDevices_",[]);navigator.mediaDevices&&(this.onDeviceChange=this.onDeviceChange.bind(this),navigator.mediaDevices.addEventListener("devicechange",this.onDeviceChange))}async init(){this.prevDevices_=await fg.default.getDevices()}async onDeviceChange(){let m=await fg.default.getDevices(),H=m.filter(G=>this.prevDevices_.findIndex(({deviceId:K})=>G.deviceId===K)<0),Q=this.prevDevices_.filter(G=>m.findIndex(({deviceId:K})=>G.deviceId===K)<0);H.length>0&&H.forEach(G=>{this.emit("device-added",G)}),Q.length>0&&Q.forEach(G=>{this.emit("device-removed",G)}),this.prevDevices_=m}destroy(){navigator.mediaDevices.removeEventListener("devicechange",this.onDeviceChange)}},kw=mg;var jt=$o.default.Logger.loggerManager,Yo=class extends D7{constructor(){super(...arguments);Be(this,"version",iw);Be(this,"_deviceDetector",new kw);Be(this,"_virtualOverloadCount",0);Be(this,"_isVirtualOverloadStart",0)}init(m){return jt.info(`lingo-trtc version: ${this.version}`),Promise.resolve()}release(){this._deviceDetector.destroy(),super.release()}async checkSystemRequirements(){let{result:m}=await $o.default.checkSystemRequirements();return m&&$o.default.isScreenShareSupported()}async createClient(){return this.client=new Pn,await this._deviceDetector.init(),this._deviceDetector.on("device-added",m=>{m.kind==="videoinput"?this.client.emit("CameraChanged",!0,m):m.kind==="audioinput"?this.client.emit("MicrophoneChanged",!0,m):m.kind==="audiooutput"&&this.client.emit("SpeakerDeviceChanged",!0,m)}),this._deviceDetector.on("device-removed",async m=>{var H,Q;if(m.kind==="videoinput"){let G=this.cameraVideoTrack||this.previewVideoTrack;if(m.deviceId===(G==null?void 0:G.getDeviceId())){if((await $o.default.getCameras()).length===0){this.client.emit("CameraChanged",!1,m);return}G.once("device-switched",()=>{this.client.emit("CameraChanged",!1,m)}),G.once("track-ended",()=>{this.client.emit("CameraChanged",!1,m)})}else this.client.emit("CameraChanged",!1,m)}else if(m.kind==="audioinput")if(m.deviceId===((H=this.microphoneAudioTrack)==null?void 0:H.getDeviceId())){if((await $o.default.getMicrophones()).length===0){this.client.emit("CameraChanged",!1,m);return}this.microphoneAudioTrack.once("device-switched",()=>{this.client.emit("CameraChanged",!1,m)}),(Q=this.microphoneAudioTrack)==null||Q.once("track-ended",()=>{this.client.emit("CameraChanged",!1,m)})}else this.client.emit("MicrophoneChanged",!1,m);else m.kind==="audiooutput"&&this.client.emit("SpeakerDeviceChanged",!1,m)}),this.client}async createCustomVideoTrack(m){if(this.customVideoTrack&&!this.customVideoTrack.closed)return this.customVideoTrack;jt.info("createCustomVideoTrack");let H=new Sd(m);return await H.init(),this.customVideoTrack=H,H}async detectCamera(m){var H,Q;if(this.previewVideoTrack&&!this.previewVideoTrack.closed)return{checkIsActive:()=>{var G,K;return Promise.resolve(((K=(G=this.previewVideoTrack)==null?void 0:G.getMediaStreamTrack())==null?void 0:K.readyState)==="live")},cleanup:()=>{var G,K;(G=this.previewVideoTrack)==null||G.stop(),(K=this.previewVideoTrack)==null||K.close(),this.previewVideoTrack=void 0}};jt.info("detectCamera");try{let G=new Ca({cameraId:m.cameraId,id:"pv"});return G.on("device-switched",K=>this.client.emit("DeviceSwitched",K)),this.previewVideoTrack=G,await G.init(),m.mirror&&G.mirrorVideo(m.mirror),m.container&&await G.play({container:m.container}),{checkIsActive:()=>{var K;return Promise.resolve(((K=G.getMediaStreamTrack())==null?void 0:K.readyState)==="live")},cleanup:()=>{G.stop(),G.close(),this.previewVideoTrack=void 0}}}catch(G){throw(H=this.previewVideoTrack)==null||H.stop(),(Q=this.previewVideoTrack)==null||Q.close(),this.previewVideoTrack=void 0,G}}processExternalMediaAEC(m){}async createMicrophoneAudioTrack(m){if(this.microphoneAudioTrack&&!this.microphoneAudioTrack.closed)return this.microphoneAudioTrack;jt.info("createMicrophoneAudioTrack");let H=new Td({microphoneId:m});return H.on("device-switched",Q=>this.client.emit("DeviceSwitched",Q)),await H.init(),this.microphoneAudioTrack=H,this.client.emit("LocalTrackCreated",H),H}async createCameraVideoTrack(m){if(this.cameraVideoTrack&&!this.cameraVideoTrack.closed)return this.cameraVideoTrack;jt.info(`createCameraVideoTrack ${JSON.stringify(m)}`);let H=new Ca(md(ni({},m),{id:"ct"}));return H.on("device-switched",Q=>this.client.emit("DeviceSwitched",Q)),await H.init(),this.cameraVideoTrack=H,this.client.emit("LocalTrackCreated",H),this.cameraVideoTrack.on("VirtualBackgroundOverload",()=>{this._virtualOverloadCount++,jt.warn(`VirtualBackground overload count is: ${this._virtualOverloadCount}`),new Date().getTime()-this._isVirtualOverloadStart>5e3&&(this._virtualOverloadCount>10&&(jt.warn("VirtualBackgroundOverload"),this.client.emit("VirtualBackgroundOverload")),this._virtualOverloadCount=0,this._isVirtualOverloadStart=new Date().getTime())}),H}};Rn([Ed(),An(ne=>vg.createRTCError(ne))],Yo.prototype,"detectCamera",1),Rn([An(ne=>vg.createRTCError(ne))],Yo.prototype,"createMicrophoneAudioTrack",1),Rn([An(ne=>vg.createRTCError(ne))],Yo.prototype,"createCameraVideoTrack",1);var tG=Yo;export{tG as default,jt as loggerManager};
|
|
548
|
+
`+M.getProgramInfoLog(ee));F=O.s=ee,M.useProgram(F),W=M.getUniformLocation(F,"sampler0"),O.l={O:M.getAttribLocation(F,"aVertex"),N:M.getAttribLocation(F,"aTex"),ya:W},O.v=M.createBuffer(),M.bindBuffer(M.ARRAY_BUFFER,O.v),M.enableVertexAttribArray(O.l.O),M.vertexAttribPointer(O.l.O,2,M.FLOAT,!1,0,0),M.bufferData(M.ARRAY_BUFFER,new Float32Array([-1,-1,-1,1,1,1,1,-1]),M.STATIC_DRAW),M.bindBuffer(M.ARRAY_BUFFER,null),O.u=M.createBuffer(),M.bindBuffer(M.ARRAY_BUFFER,O.u),M.enableVertexAttribArray(O.l.N),M.vertexAttribPointer(O.l.N,2,M.FLOAT,!1,0,0),M.bufferData(M.ARRAY_BUFFER,new Float32Array([0,1,0,0,1,0,1,1]),M.STATIC_DRAW),M.bindBuffer(M.ARRAY_BUFFER,null),M.uniform1i(W,0)}F=O.l,M.useProgram(O.s),M.canvas.width=B.width,M.canvas.height=B.height,M.viewport(0,0,B.width,B.height),M.activeTexture(M.TEXTURE0),O.i.bindTexture2d(B.glName),M.enableVertexAttribArray(F.O),M.bindBuffer(M.ARRAY_BUFFER,O.v),M.vertexAttribPointer(F.O,2,M.FLOAT,!1,0,0),M.enableVertexAttribArray(F.N),M.bindBuffer(M.ARRAY_BUFFER,O.u),M.vertexAttribPointer(F.N,2,M.FLOAT,!1,0,0),M.bindFramebuffer(M.DRAW_FRAMEBUFFER?M.DRAW_FRAMEBUFFER:M.FRAMEBUFFER,null),M.clearColor(0,0,0,0),M.clear(M.COLOR_BUFFER_BIT),M.colorMask(!0,!0,!0,!0),M.drawArrays(M.TRIANGLE_FAN,0,4),M.disableVertexAttribArray(F.O),M.disableVertexAttribArray(F.N),M.bindBuffer(M.ARRAY_BUFFER,null),O.i.bindTexture2d(0)}(d,g),typeof d.h.canvas.transferToImageBitmap=="function"?Promise.resolve(d.h.canvas.transferToImageBitmap()):C?Promise.resolve(d.h.canvas):typeof createImageBitmap=="function"?createImageBitmap(d.h.canvas):(d.j===void 0&&(d.j=document.createElement("canvas")),new Promise(function(O){d.j.height=d.h.canvas.height,d.j.width=d.h.canvas.width,d.j.getContext("2d",{}).drawImage(d.h.canvas,0,0,d.h.canvas.width,d.h.canvas.height),O(d.j)}))}function Bd(d){this.h=d}Oa.prototype.l=ps(nu);var iu=new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,2,1,0,10,9,1,7,0,65,0,253,15,26,11]);function Fd(d,g){return g+d}function Ma(d,g){window[d]=g}function Yn(d){if(this.h=d,this.listeners={},this.l={},this.L={},this.s={},this.v={},this.M=this.u=this.ga=!0,this.I=Promise.resolve(),this.fa="",this.D={},this.locateFile=d&&d.locateFile||Fd,(typeof window=="undefined"?"undefined":$(window))==="object")var g=window.location.pathname.toString().substring(0,window.location.pathname.toString().lastIndexOf("/"))+"/";else{if(typeof location=="undefined")throw Error("solutions can only be loaded on a web page or in a web worker");g=location.pathname.toString().substring(0,location.pathname.toString().lastIndexOf("/"))+"/"}if(this.ha=g,d.options)for(var C=(g=X(Object.keys(d.options))).next();!C.done;C=g.next()){C=C.value;var O=d.options[C].default;O!==void 0&&(this.l[C]=typeof O=="function"?O():O)}}function Hd(d){var g,C,O,B,M,F,W,ee,fe,me,we;return Ze(function(Ae){switch(Ae.h){case 1:return d.ga?(g=d.h.files===void 0?[]:typeof d.h.files=="function"?d.h.files(d.l):d.h.files,ft(Ae,Ze(function(ve){switch(ve.h){case 1:return ve.s=2,ft(ve,WebAssembly.instantiate(iu),4);case 4:ve.h=3,ve.s=0;break;case 2:return ve.s=0,ve.l=null,ve.return(!1);case 3:return ve.return(!0)}}),2)):Ae.return();case 2:if(C=Ae.i,(typeof window=="undefined"?"undefined":$(window))==="object")return Ma("createMediapipeSolutionsWasm",{locateFile:d.locateFile}),Ma("createMediapipeSolutionsPackedAssets",{locateFile:d.locateFile}),F=g.filter(function(ve){return ve.data!==void 0}),W=g.filter(function(ve){return ve.data===void 0}),ee=Promise.all(F.map(function(ve){var Oe=ti(d,ve.url);if(ve.path!==void 0){var Be=ve.path;Oe=Oe.then(function(ot){return d.overrideFile(Be,ot),Promise.resolve(ot)})}return Oe})),fe=Promise.all(W.map(function(ve){return ve.simd===void 0||ve.simd&&C||!ve.simd&&!C?function(Oe){var Be=document.createElement("script");return Be.setAttribute("src",Oe),Be.setAttribute("crossorigin","anonymous"),new Promise(function(ot){Be.addEventListener("load",function(){ot()},!1),Be.addEventListener("error",function(){ot()},!1),document.body.appendChild(Be)})}(d.locateFile(ve.url,d.ha)):Promise.resolve()})).then(function(){var ve,Oe,Be;return Ze(function(ot){if(ot.h==1)return ve=window.createMediapipeSolutionsWasm,Oe=window.createMediapipeSolutionsPackedAssets,Be=d,ft(ot,ve(Oe),2);Be.i=ot.i,ot.h=0})}),me=Ze(function(ve){return d.h.graph&&d.h.graph.url?ve=ft(ve,ti(d,d.h.graph.url),0):(ve.h=0,ve=void 0),ve}),ft(Ae,Promise.all([fe,ee,me]),7);if(typeof importScripts!="function")throw Error("solutions can only be loaded on a web page or in a web worker");return O=g.filter(function(ve){return ve.simd===void 0||ve.simd&&C||!ve.simd&&!C}).map(function(ve){return d.locateFile(ve.url,d.ha)}),importScripts.apply(null,ce(O)),B=d,ft(Ae,createMediapipeSolutionsWasm(Module),6);case 6:B.i=Ae.i,d.m=new OffscreenCanvas(1,1),d.i.canvas=d.m,M=d.i.GL.createContext(d.m,{antialias:!1,alpha:!1,va:typeof WebGL2RenderingContext!="undefined"?2:1}),d.i.GL.makeContextCurrent(M),Ae.h=4;break;case 7:if(d.m=document.createElement("canvas"),!(we=d.m.getContext("webgl2",{}))&&!(we=d.m.getContext("webgl",{})))return alert("Failed to create WebGL canvas context when passing video frame."),Ae.return();d.K=we,d.i.canvas=d.m,d.i.createContext(d.m,!0,!0,{});case 4:d.j=new d.i.SolutionWasm,d.ga=!1,Ae.h=0}})}function ti(d,g){var C,O;return Ze(function(B){return g in d.L?B.return(d.L[g]):(C=d.locateFile(g,""),O=fetch(C).then(function(M){return M.arrayBuffer()}),d.L[g]=O,B.return(O))})}function Gd(d,g,C){var O,B,M,F,W,ee,fe,me,we,Ae,ve,Oe,Be,ot;return Ze(function(lt){switch(lt.h){case 1:if(!C)return lt.return(g);for(O={},B=0,M=X(Object.keys(C)),F=M.next();!F.done;F=M.next())W=F.value,typeof(ee=C[W])!="string"&&ee.type==="texture"&&g[ee.stream]!==void 0&&++B;1<B&&(d.M=!1),fe=X(Object.keys(C)),F=fe.next();case 2:if(F.done){lt.h=4;break}if(me=F.value,typeof(we=C[me])=="string")return Be=O,ot=me,ft(lt,function(Mn,Va,ri){var ja;return Ze(function(_s){return typeof ri=="number"||ri instanceof Uint8Array||ri instanceof Mn.i.Uint8BlobList?_s.return(ri):ri instanceof Mn.i.Texture2dDataOut?((ja=Mn.v[Va])||(ja=new Fi(Mn.i,Mn.K),Mn.v[Va]=ja),_s.return(La(ja,ri,Mn.M))):_s.return(void 0)})}(d,me,g[we]),14);if(Ae=g[we.stream],we.type==="detection_list"){if(Ae){for(var jt=Ae.getRectList(),mn=Ae.getLandmarksList(),bt=Ae.getClassificationsList(),qe=[],Xe=0;Xe<jt.size();++Xe){var _r=Vd(jt.get(Xe)),Ua=void 0;Ua=Ua===void 0?0:Ua,_r={la:{sa:On(_r,1),ta:On(_r,2),height:On(_r,3),width:On(_r,4),rotation:On(_r,5,0),pa:Aa(pn(_r,6),Ua)},ea:kt(Ud(mn.get(Xe)),gr,1).map(Ln),ba:jd(Nd(bt.get(Xe)))},qe.push(_r)}jt=qe}else jt=[];O[me]=jt,lt.h=7;break}if(we.type==="proto_list"){if(Ae){for(jt=Array(Ae.size()),mn=0;mn<Ae.size();mn++)jt[mn]=Ae.get(mn);Ae.delete()}else jt=[];O[me]=jt,lt.h=7;break}if(Ae===void 0){lt.h=3;break}if(we.type==="float_list"){O[me]=Ae,lt.h=7;break}if(we.type==="proto"){O[me]=Ae,lt.h=7;break}if(we.type!=="texture")throw Error("Unknown output config type: '"+we.type+"'");return(ve=d.v[me])||(ve=new Fi(d.i,d.K),d.v[me]=ve),ft(lt,La(ve,Ae,d.M),13);case 13:Oe=lt.i,O[me]=Oe;case 7:we.transform&&O[me]&&(O[me]=we.transform(O[me])),lt.h=3;break;case 14:Be[ot]=lt.i;case 3:F=fe.next(),lt.h=2;break;case 4:return lt.return(O)}})}function Na(d,g){for(var C=g.name||"$",O=[].concat(ce(g.wants)),B=new d.i.StringList,M=X(g.wants),F=M.next();!F.done;F=M.next())B.push_back(F.value);M=d.i.PacketListener.implement({onResults:function(W){for(var ee={},fe=0;fe<g.wants.length;++fe)ee[O[fe]]=W.get(fe);var me=d.listeners[C];me&&(d.I=Gd(d,ee,g.outs).then(function(we){we=me(we);for(var Ae=0;Ae<g.wants.length;++Ae){var ve=ee[O[Ae]];$(ve)==="object"&&ve.hasOwnProperty&&ve.hasOwnProperty("delete")&&ve.delete()}we&&(d.I=we)}))}}),d.j.attachMultiListener(B,M),B.delete()}function ni(d){return d===void 0&&(d=0),d===1?"selfie_segmentation_landscape.tflite":"selfie_segmentation.tflite"}function Hi(d){var g=this;d=d||{},this.h=new Yn({locateFile:d.locateFile,files:function(C){return[{simd:!0,url:"selfie_segmentation_solution_simd_wasm_bin.js"},{simd:!1,url:"selfie_segmentation_solution_wasm_bin.js"},{data:!0,url:ni(C.modelSelection)}]},graph:{url:"selfie_segmentation.binarypb"},listeners:[{wants:["segmentation_mask","image_transformed"],outs:{image:{type:"texture",stream:"image_transformed"},segmentationMask:{type:"texture",stream:"segmentation_mask"}}}],inputs:{image:{type:"video",stream:"input_frames_gpu"}},options:{useCpuInference:{type:0,graphOptionXref:{calculatorType:"InferenceCalculator",fieldName:"use_cpu_inference"},default:(typeof window=="undefined"?"undefined":$(window))==="object"&&window.navigator!==void 0&&("iPad Simulator;iPhone Simulator;iPod Simulator;iPad;iPhone;iPod".split(";").includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document)},selfieMode:{type:0,graphOptionXref:{calculatorType:"GlScalerCalculator",calculatorIndex:1,fieldName:"flip_horizontal"}},modelSelection:{type:1,graphOptionXref:{calculatorType:"ConstantSidePacketCalculator",calculatorName:"ConstantSidePacketCalculatorModelSelection",fieldName:"int_value"},onChange:function(C){var O,B,M;return Ze(function(F){return F.h==1?(O=ni(C),B="third_party/mediapipe/modules/selfie_segmentation/"+O,ft(F,ti(g.h,O),2)):(M=F.i,g.h.overrideFile(B,M),F.return(!0))})}}}})}(le=Yn.prototype).close=function(){return this.j&&this.j.delete(),Promise.resolve()},le.reset=function(){var d=this;return Ze(function(g){d.j&&(d.j.reset(),d.s={},d.v={}),g.h=0})},le.setOptions=function(d,g){var C=this;if(g=g||this.h.options){for(var O=[],B=[],M={},F=X(Object.keys(d)),W=F.next();!W.done;M={X:M.X,Y:M.Y},W=F.next())if(!((W=W.value)in this.l)||this.l[W]!==d[W]){this.l[W]=d[W];var ee=g[W];ee!==void 0&&(ee.onChange&&(M.X=ee.onChange,M.Y=d[W],O.push(function(fe){return function(){return Ze(function(me){if(me.h==1)return ft(me,fe.X(fe.Y),2);me.i===!0&&(C.u=!0),me.h=0})}}(M))),ee.graphOptionXref&&(W=Object.assign({},{calculatorName:"",calculatorIndex:0},ee.graphOptionXref,{valueNumber:ee.type===1?d[W]:0,valueBoolean:ee.type===0&&d[W],valueString:ee.type===2?d[W]:""}),B.push(W)))}O.length===0&&B.length===0||(this.u=!0,this.H=(this.H===void 0?[]:this.H).concat(B),this.F=(this.F===void 0?[]:this.F).concat(O))}},le.initialize=function(){var d=this;return Ze(function(g){return g.h==1?ft(g,Hd(d),2):g.h!=3?ft(g,function(C){var O,B,M,F,W,ee,fe,me;return Ze(function(we){if(we.h==1)return C.h.graph&&C.h.graph.url&&C.fa===C.h.graph.url?we.return():(C.u=!0,C.h.graph&&C.h.graph.url?(C.fa=C.h.graph.url,ft(we,ti(C,C.h.graph.url),3)):void(we.h=2));for(we.h!=2&&(O=we.i,C.j.loadGraph(O)),B=X(Object.keys(C.D)),M=B.next();!M.done;M=B.next())F=M.value,C.j.overrideFile(F,C.D[F]);if(C.D={},C.h.listeners)for(W=X(C.h.listeners),ee=W.next();!ee.done;ee=W.next())fe=ee.value,Na(C,fe);me=C.l,C.l={},C.setOptions(me),we.h=0})}(d),3):ft(g,function(C){var O,B,M,F,W,ee;return Ze(function(fe){switch(fe.h){case 1:if(!C.u)return fe.return();if(!C.F){fe.h=2;break}O=X(C.F),B=O.next();case 3:if(B.done){fe.h=5;break}return ft(fe,(0,B.value)(),4);case 4:B=O.next(),fe.h=3;break;case 5:C.F=void 0;case 2:if(C.H){for(M=new C.i.GraphOptionChangeRequestList,F=X(C.H),W=F.next();!W.done;W=F.next())ee=W.value,M.push_back(ee);C.j.changeOptions(M),M.delete(),C.H=void 0}C.u=!1,fe.h=0}})}(d),0)})},le.overrideFile=function(d,g){this.j?this.j.overrideFile(d,g):this.D[d]=g},le.clearOverriddenFiles=function(){this.D={},this.j&&this.j.clearOverriddenFiles()},le.send=function(d,g){var C,O,B,M,F,W,ee,fe,me,we=this;return Ze(function(Ae){switch(Ae.h){case 1:return we.h.inputs?(C=1e3*(g==null?performance.now():g),ft(Ae,we.I,2)):Ae.return();case 2:return ft(Ae,we.initialize(),3);case 3:for(O=new we.i.PacketDataList,B=X(Object.keys(d)),M=B.next();!M.done;M=B.next())if(F=M.value,W=we.h.inputs[F]){e:{var ve=d[F];switch(W.type){case"video":var Oe=we.s[W.stream];if(Oe||(Oe=new Fi(we.i,we.K),we.s[W.stream]=Oe),Oe.m===0&&(Oe.m=Oe.i.createTexture()),typeof HTMLVideoElement!="undefined"&&ve instanceof HTMLVideoElement)var Be=ve.videoWidth,ot=ve.videoHeight;else typeof HTMLImageElement!="undefined"&&ve instanceof HTMLImageElement?(Be=ve.naturalWidth,ot=ve.naturalHeight):(Be=ve.width,ot=ve.height);ot={glName:Oe.m,width:Be,height:ot},(Be=Oe.h).canvas.width=ot.width,Be.canvas.height=ot.height,Be.activeTexture(Be.TEXTURE0),Oe.i.bindTexture2d(Oe.m),Be.texImage2D(Be.TEXTURE_2D,0,Be.RGBA,Be.RGBA,Be.UNSIGNED_BYTE,ve),Oe.i.bindTexture2d(0),Oe=ot;break e;case"detections":for((Oe=we.s[W.stream])||(Oe=new Bd(we.i),we.s[W.stream]=Oe),Oe.data||(Oe.data=new Oe.h.DetectionListData),Oe.data.reset(ve.length),ot=0;ot<ve.length;++ot){Be=ve[ot];var lt=Oe.data,jt=lt.setBoundingBox,mn=ot,bt=Be.la,qe=new Oa;if(Dn(qe,1,bt.sa),Dn(qe,2,bt.ta),Dn(qe,3,bt.height),Dn(qe,4,bt.width),Dn(qe,5,bt.rotation),Pn(qe,6,bt.pa),bt=qe.l(),jt.call(lt,mn,bt),Be.ea)for(lt=0;lt<Be.ea.length;++lt){qe=Be.ea[lt],mn=(jt=Oe.data).addNormalizedLandmark,bt=ot,qe=Object.assign({},qe,{visibility:qe.visibility?qe.visibility:0});var Xe=new gr;Dn(Xe,1,qe.x),Dn(Xe,2,qe.y),Dn(Xe,3,qe.z),qe.visibility&&Dn(Xe,4,qe.visibility),qe=Xe.l(),mn.call(jt,bt,qe)}if(Be.ba)for(lt=0;lt<Be.ba.length;++lt)mn=(jt=Oe.data).addClassification,bt=ot,qe=Be.ba[lt],Dn(Xe=new ei,2,qe.qa),qe.index&&Pn(Xe,1,qe.index),qe.label&&Pn(Xe,3,qe.label),qe.displayName&&Pn(Xe,4,qe.displayName),qe=Xe.l(),mn.call(jt,bt,qe)}Oe=Oe.data;break e;default:Oe={}}}switch(ee=Oe,fe=W.stream,W.type){case"video":O.pushTexture2d(Object.assign({},ee,{stream:fe,timestamp:C}));break;case"detections":(me=ee).stream=fe,me.timestamp=C,O.pushDetectionList(me);break;default:throw Error("Unknown input config type: '"+W.type+"'")}}return we.j.send(O),ft(Ae,we.I,4);case 4:O.delete(),Ae.h=0}})},le.onResults=function(d,g){this.listeners[g||"$"]=d},he("Solution",Yn),he("OptionType",{BOOL:0,NUMBER:1,ua:2,0:"BOOL",1:"NUMBER",2:"STRING"}),(le=Hi.prototype).close=function(){return this.h.close(),Promise.resolve()},le.onResults=function(d){this.h.onResults(d)},le.initialize=function(){var d=this;return Ze(function(g){return ft(g,d.h.initialize(),0)})},le.reset=function(){this.h.reset()},le.send=function(d){var g=this;return Ze(function(C){return ft(C,g.h.send(d),0)})},le.setOptions=function(d){this.h.setOptions(d)},he("SelfieSegmentation",Hi),he("VERSION","0.1.1675465747")}).call(Jo);var Rr=function(le){return typeof le=="number"},Pc=function(){function le(){Re(this,le),this.userId="",this.videoBeauty=document.createElement("video"),this.videoBeauty.loop=!0,this.videoBeauty.autoplay=!0,this.videoVirtual=document.createElement("video"),this.videoVirtual.loop=!0,this.videoVirtual.autoplay=!0,this.onoverload=null,this.canvasBeauty=document.createElement("canvas"),this.filter=new zo({canvas:this.canvasBeauty,video:this.videoBeauty}),this.canvasVirtual=document.createElement("canvas"),this.virtual=new Wo({canvas:this.canvasVirtual,video:this.videoVirtual,onoverload:this.onoverload}),this.beautyParams={beauty:.5,brightness:.5,ruddy:.5},this.timeoutId=null,this.rafId=null,this.startTime=null,this.originTrack=null,this.beautyTrack=null,this.resultTrack=null,this.localStream=null,this.frameRate=null,this.disableStatus=!1,this.isVirualEnable=!1}var Te,Se,je,He,oe;return $e(le,[{key:"generateBeautyStream",value:function(X){this.userId=X==null?void 0:X.getUserId();var ce=X.getVideoTrack();if(!ce)throw new Error("Your localStream does not contain video track.");var z=this.generateBeautyTrack(ce);return X.replaceTrack(z),this.localStream=X,X.setBeautyStatus&&X.setBeautyStatus(!0),console.log("RTCBeautyPlugin: generateBeautyStream ".concat(this.userId?"userId: ".concat(this.userId):"")),X}},{key:"generateBeautyTrack",value:function(X){var ce=this;this.reset();var z=X.getSettings();this.frameRate=z.frameRate,this.filter.setRect(z.width,z.height),this.setRect(z.width,z.height);var re=new MediaStream;re.addTrack(X),this.videoBeauty.srcObject=re,this.videoBeauty.play();var be=this.canvasBeauty.captureStream(this.frameRate||15).getVideoTracks()[0];return this.rafId&&cancelAnimationFrame(this.rafId),this.rafId=requestAnimationFrame(function(){ce.startTime=new Date().getTime(),ce.render()}),this.installEvents(),this.originTrack=X,this.beautyTrack=be,this.setTrackParam({type:"beauty",originTrack:X,resultTrack:be,param:this.beautyParams}),be}},{key:"setBackground",value:(oe=Q(G().mark(function X(ce){return G().wrap(function(z){for(;;)switch(z.prev=z.next){case 0:return z.next=2,this.virtual.setBackground(ce);case 2:console.log("RTCBeautyPlugin: setBackground img:".concat(ce));case 3:case"end":return z.stop()}},X,this)})),function(X){return oe.apply(this,arguments)})},{key:"generateStream",value:(He=Q(G().mark(function X(ce){var z,re,be,ue,ye;return G().wrap(function(Me){for(;;)switch(Me.prev=Me.next){case 0:if(z=ce.localStream,re=ce.type,be=ce.img,ue=z.getVideoTrack()){Me.next=4;break}throw new Error("Your localStream does not contain video track.");case 4:return this.localStream=z,Me.next=7,this.generateMixedTrack({videoTrack:ue,type:re,img:be});case 7:return ye=Me.sent,z.replaceTrack(ye),z.setBeautyStatus&&z.setBeautyStatus(!0),Me.abrupt("return",z);case 11:case"end":return Me.stop()}},X,this)})),function(X){return He.apply(this,arguments)})},{key:"generateMixedTrack",value:(je=Q(G().mark(function X(ce){var z,re,be,ue,ye;return G().wrap(function(Me){for(;;)switch(Me.prev=Me.next){case 0:if(z=ce.videoTrack,re=ce.type,be=ce.img,this.virtual.selfieSegmentation){Me.next=3;break}throw new Error("you should call loadResources() first");case 3:return this.virtual.initVirtualParams({type:re,img:be}),Me.next=6,this.generateBeautyTrack(z);case 6:return ue=Me.sent,Me.next=9,this.generateVirtualTrack({videoTrack:ue,type:re,img:be});case 9:return ye=Me.sent,this.beautyTrack=ue,this.resultTrack=ye,this.setTrackParam({type:"mixed",originTrack:this.originTrack,resultTrack:this.resultTrack,param:{type:re,img:be}}),Me.abrupt("return",this.resultTrack);case 14:case"end":return Me.stop()}},X,this)})),function(X){return je.apply(this,arguments)})},{key:"generateVirtualStream",value:(Se=Q(G().mark(function X(ce){var z,re,be,ue,ye;return G().wrap(function(Me){for(;;)switch(Me.prev=Me.next){case 0:if(z=ce.localStream,re=ce.type,be=ce.img,ue=z.getVideoTrack()){Me.next=4;break}throw new Error("Your localStream does not contain video track.");case 4:return this.localStream=z,Me.next=7,this.generateVirtualTrack({videoTrack:ue,type:re,img:be});case 7:return ye=Me.sent,Me.next=10,z.replaceTrack(ye);case 10:return z.setBeautyStatus&&z.setBeautyStatus(!0),console.log("".concat(this.userId?"[userId: ".concat(this.userId,"]"):""," RTCBeautyPlugin generate ").concat(re," Stream.")),Me.abrupt("return",z);case 13:case"end":return Me.stop()}},X,this)})),function(X){return Se.apply(this,arguments)})},{key:"generateVirtualTrack",value:(Te=Q(G().mark(function X(ce){var z,re,be,ue;return G().wrap(function(ye){for(;;)switch(ye.prev=ye.next){case 0:if(z=ce.videoTrack,re=ce.type,be=ce.img,this.virtual.selfieSegmentation){ye.next=3;break}throw new Error("you should call loadResources() first");case 3:return ue=z.getSettings(),this.frameRate=ue.frameRate,this.virtual.setRect(ue.width,ue.height),ye.next=8,this.virtual.initVirtualParams({type:re,img:be});case 8:return this.setRect(ue.width,ue.height),this.mediaStream=new MediaStream,this.mediaStream.addTrack(z),this.videoVirtual.srcObject=this.mediaStream,ye.next=14,this.videoVirtual.play();case 14:return this.virtual.startVirtual(this.frameRate),ye.next=17,this.virtual.render();case 17:return this.originTrack=z,this.resultTrack=this.canvasVirtual.captureStream(this.frameRate||15).getVideoTracks()[0],this.setTrackParam({type:"virtual",originTrack:this.originTrack,resultTrack:this.resultTrack,param:{type:re,img:be}}),this.isVirualEnable=!0,ye.abrupt("return",this.resultTrack);case 22:case"end":return ye.stop()}},X,this)})),function(X){return Te.apply(this,arguments)})},{key:"replaceVirtualTrack",value:function(X){this.isVirualEnable&&(this.mediaStream.removeTrack(this.mediaStream.getVideoTracks()[0]),this.mediaStream.addTrack(X),this.originTrack=X)}},{key:"deleteSource",value:function(X){if(p.default){var ce=p.default.beautyTrackMap.get(X);ce&&(ce.type==="mixed"&&this.deleteSource(ce.originTrack.id),ce.originTrack&&(ce.originTrack.stop(),ce.originTrack=null),ce.beautyTrack&&(ce.beautyTrack.stop(),ce.beautyTrack=null),ce.resultTrack&&(ce.resultTrack.stop(),ce.resultTrack=null),p.default.beautyTrackMap.delete(X))}}},{key:"draw",value:function(){this.videoBeauty&&this.videoBeauty.readyState===this.videoBeauty.HAVE_ENOUGH_DATA&&this.filter.apply(this.videoBeauty)}},{key:"enableVirtualBg",value:function(){var X;if(this.virtual&&!this.isVirualEnable)return this.virtual.setEnable(!0),this.virtual.render(),this.isVirualEnable=!0,(X=this.localStream)===null||X===void 0||X.replaceTrack(this.resultTrack),console.log("".concat(this.userId?"[userId: ".concat(this.userId,"]"):""," RTCBeautyPlugin enable.")),this.resultTrack}},{key:"disableVirtualBg",value:function(){var X;if(this.virtual&&this.isVirualEnable)return this.virtual.setEnable(!1),this.isVirualEnable=!1,(X=this.localStream)===null||X===void 0||X.replaceTrack(this.originTrack),console.log("".concat(this.userId?"[userId: ".concat(this.userId,"]"):""," RTCBeautyPlugin disable.")),this.originTrack}},{key:"changeType",value:function(X){var ce=X.type,z=X.img;console.log("".concat(this.userId?"[userId: ".concat(this.userId,"]"):""," RTCBeautyPlugin changeType\uFF1A").concat(ce,". img: ").concat(z,".")),ce==="blur"&&(this.virtual.reset(),this.virtual.initVirtualParams({type:"blur"}),this.virtual.startVirtual(this.frameRate),this.virtual.render()),ce==="virtual"&&(this.virtual.reset(),this.virtual.initVirtualParams({type:"virtual",img:z}),this.virtual.startVirtual(this.frameRate),this.virtual.render()),this.setTrackParam({type:ce,originTrack:this.originTrack,resultTrack:this.resultTrack,param:{type:ce,img:z}})}},{key:"render",value:function(){var X=this,ce=new Date().getTime();ce-this.startTime>1e3/this.frameRate&&(this.draw(),this.startTime=ce),document.hidden?(clearTimeout(this.timeoutId),this.timeoutId=setTimeout(function(){X.render()},1e3/this.frameRate)):(this.timeoutId&&clearTimeout(this.timeoutId),this.rafId&&cancelAnimationFrame(this.rafId),this.rafId=requestAnimationFrame(this.render.bind(this)))}},{key:"setBeautyParam",value:function(X){var ce=X.beauty,z=X.brightness,re=X.ruddy;Rr(ce)&&(this.beautyParams.beauty=ce),Rr(z)&&(this.beautyParams.brightness=z),Rr(re)&&(this.beautyParams.ruddy=re),this.filter.setBeautyParams(this.beautyParams),this.getClose()&&!this.disableStatus&&this.disable(),!this.getClose()&&this.disableStatus&&this.enable()}},{key:"setRect",value:function(X,ce){var z=X||640,re=ce||480;this.videoBeauty.height=re,this.videoBeauty.width=z,this.canvasBeauty.height=re,this.canvasBeauty.width=z,this.videoVirtual.height=re,this.videoVirtual.width=z,this.canvasVirtual.height=re,this.canvasVirtual.width=z}},{key:"reset",value:function(){cancelAnimationFrame(this.rafId),clearTimeout(this.timeoutId),this.videoBeauty.pause(),this.filter.reset(),this.beautyTrack&&this.beautyTrack.stop(),this.videoVirtual.pause(),this.resultTrack&&this.resultTrack.stop(),this.originTrack&&this.originTrack.stop()}},{key:"destroy",value:function(){cancelAnimationFrame(this.rafId),clearTimeout(this.timeoutId),this.canvasBeauty&&(this.canvasBeauty.width=0,this.canvasBeauty.height=0,this.canvasBeauty.remove(),this.canvasBeauty=null),this.videoBeauty&&(this.videoBeauty.pause(),this.videoBeauty.removeAttribute("srcObject"),this.videoBeauty.removeAttribute("src"),this.videoBeauty.load(),this.videoBeauty.width=0,this.videoBeauty.height=0,this.videoBeauty.remove(),this.videoBeauty=null),this.beautyTrack&&(this.deleteSource(this.beautyTrack.id),this.beautyTrack.stop(),this.beautyTrack=null),this.originTrack&&(this.originTrack.stop(),this.originTrack=null),this.resultTrack&&(this.deleteSource(this.resultTrack.id),this.resultTrack.stop(),this.resultTrack=null),this.canvasVirtual&&(this.canvasVirtual.width=0,this.canvasVirtual.height=0,this.canvasVirtual.remove(),this.canvasVirtual=null),this.videoVirtual&&(this.videoVirtual.pause(),this.videoVirtual.removeAttribute("srcObject"),this.videoVirtual.removeAttribute("src"),this.videoVirtual.load(),this.videoVirtual.width=0,this.videoVirtual.height=0,this.videoVirtual.remove(),this.videoVirtual=null),this.virtual.destroy(),this.uninstallEvents()}},{key:"generateVideoTrackFromCanvasCapture",value:function(X){return this.canvasVirtual.captureStream(X).getVideoTracks()[0]}},{key:"setTrackParam",value:function(X){var ce=X.type,z=X.originTrack,re=X.resultTrack,be=X.param;p.default&&(p.default.beautyTrackMap||(p.default.beautyTrackMap=new Map),p.default.beautyTrackMap.set(re.id,{type:ce,originTrack:z,resultTrack:re,param:be,pluginInstance:this}))}},{key:"disable",value:function(){this.localStream&&this.originTrack&&(this.localStream.replaceTrack(this.originTrack),cancelAnimationFrame(this.rafId),clearTimeout(this.timeoutId),this.disableStatus=!0)}},{key:"enable",value:function(){this.localStream&&this.beautyTrack&&(this.localStream.replaceTrack(this.beautyTrack),this.render(),this.disableStatus=!1)}},{key:"installEvents",value:function(){document.addEventListener("visibilitychange",this.render.bind(this))}},{key:"uninstallEvents",value:function(){document.removeEventListener("visibilitychange",this.render.bind(this))}},{key:"overload",value:function(){this.onoverload&&this.onoverload()}},{key:"getClose",value:function(){return this.beautyParams.beauty===0&&this.beautyParams.brightness===0&&this.beautyParams.ruddy===0}}]),le}();return p.default&&(p.default.getRTCBeautyPlugin=function(){return new Pc}),Pc})});var ew="0.0.17";var _d=lr(Er());var gd=lr(Er());var dw=lr(ig());var Uo=class extends dw.default{constructor({mediaType:p}){super();Ve(this,"trackMediaType");Ve(this,"_stream");Ve(this,"_playerState");this.trackMediaType=p}get isPlaying(){return this._playerState==="PLAYING"}async stop(){this._playerState="STOPPED",await this._stream.stop()}};var C7=1,Vo=class extends Uo{constructor(p){super(p);Ve(this,"TRTC",gd.default);Ve(this,"muted");Ve(this,"_publishedStream",null);Ve(this,"_log");this._log=Ft.createLogger({id:p.id+C7++})}get closed(){let p=this.getMediaStreamTrack();return p?p.readyState==="ended":!0}async init(){this._stream.on("device-auto-recovered",async({isMicrophone:p,isCamera:G,microphoneId:$,cameraId:H})=>{if(this._publishedStream&&this._stream!==this._publishedStream){let Q=this.getMediaStreamTrack(),Re=this.trackMediaType==="audio"?this._publishedStream.getAudioTrack():this._publishedStream.getVideoTrack();Q&&Re&&Q!==Re&&this._publishedStream.replaceTrack(Q)}if(p){let Q=(await gd.default.getMicrophones()).find(Re=>Re.deviceId===$);Q&&this.emit("device-switched",Q)}if(G){let Q=(await gd.default.getCameras()).find(Re=>Re.deviceId===H);Q&&this.emit("device-switched",Q)}}),this._stream.on("player-state-changed",({state:p})=>{this._playerState=p}),this._stream.on("error",p=>{p.getCode()===16452&&this.emit("track-ended",this.trackMediaType)}),await this._stream.initialize()}setPublishedStream(p){this._publishedStream=p}on(p,G){return super.on(p,G),this}async setMuted(p){let G=this._publishedStream||this._stream;this.trackMediaType==="audio"?p?G.muteAudio():G.unmuteAudio():p?G.muteVideo():G.unmuteVideo()}getMediaStreamTrack(){return this.trackMediaType==="audio"?this._stream.getAudioTrack():this._stream.getVideoTrack()}close(){this._stream.close()}getTrackLabel(){var p;return((p=this.getMediaStreamTrack())==null?void 0:p.label)||""}getDeviceId(){var p,G;return((G=(p=this.getMediaStreamTrack())==null?void 0:p.getSettings())==null?void 0:G.deviceId)||""}};var fw=lr(hw()),pw=lr(Er());var jo=class extends Vo{constructor(p){super(p);Ve(this,"mirrored",!1);Ve(this,"lastPlayContainer");Ve(this,"_beautyPlugin");Ve(this,"_virtualTrack");Ve(this,"_isVirtualEnable",!1);Ve(this,"_imageUrl",null);this.onOriginTrackEnded=this.onOriginTrackEnded.bind(this)}get _originTrack(){var p;return((p=this._beautyPlugin)==null?void 0:p.originTrack)||null}get videoElement(){var p;return((p=this.lastPlayContainer)==null?void 0:p.querySelector(`#video_${this._stream.getId()}`))||null}mirrorVideo(p){this.lastPlayContainer&&this._stream.play(this.lastPlayContainer,{mirror:p}),this.mirrored=p}async applyVirtualBackground(p){var G;if(this._log.info(`applyVirtualBackground ${p} ${this._imageUrl}`),!p)return this.stopVirtualBackground(),!0;if(p===this._imageUrl)return!0;if(this._beautyPlugin||(this._beautyPlugin=new fw.default,await this._beautyPlugin.virtual.loadResources(),this._beautyPlugin.virtual.onoverload=()=>{this._log.info("virtualBackground is onoverload"),this.emit("VirtualBackgroundOverload")}),this._imageUrl)p==="blur"&&this._imageUrl!=="blur"&&this._beautyPlugin.changeType({type:"blur"}),p!=="blur"&&this._imageUrl==="blur"&&this._beautyPlugin.changeType({type:"virtual",img:p}),p!=="blur"&&this._imageUrl!=="blur"&&this._imageUrl!==p&&await this._beautyPlugin.setBackground(p);else{let $=await this._beautyPlugin.generateVirtualStream({localStream:this._stream,type:p==="blur"?"blur":"virtual",img:p==="blur"?void 0:p});this._virtualTrack=$.getVideoTrack(),this._publishedStream&&this._publishedStream.replaceTrack(this._virtualTrack),this._isVirtualEnable=!0}return(G=this._originTrack)==null||G.addEventListener("ended",this.onOriginTrackEnded),this._imageUrl=p,!this._isVirtualEnable&&this._beautyPlugin&&(this._isVirtualEnable=!0,this._beautyPlugin.enableVirtualBg()),!0}async onOriginTrackEnded(){let p=(await pw.default.getCameras())[0];p?this.setDevice(p.deviceId):this.emit("track-ended",this.trackMediaType)}async stopVirtualBackground(){var p;return this._log.info("stopVirtualBackground is called"),this._beautyPlugin&&this._isVirtualEnable&&(this._log.info("RTCBeautyPlugin: call disableVirtualBackground"),this._beautyPlugin.disableVirtualBg(),this._isVirtualEnable=!1,(p=this._originTrack)==null||p.removeEventListener("ended",this.onOriginTrackEnded)),!0}getDeviceId(){var p,G;return this._isVirtualEnable||this._beautyPlugin?((G=(p=this._beautyPlugin.originTrack)==null?void 0:p.getSettings())==null?void 0:G.deviceId)||"":super.getDeviceId()}getMediaStreamTrack(){return this._originTrack&&(this._isVirtualEnable||this._beautyPlugin)?this._originTrack:super.getMediaStreamTrack()}close(){var p;(p=this._beautyPlugin)==null||p.destroy()}};var ya=class extends jo{constructor(p){var Re;super(pd(Kr({},p),{mediaType:"video"}));Ve(this,"_videoProfile",{width:320,height:240,frameRate:15,bitrate:300});let{width:G,height:$,frameRate:H,bitrate:Q}=p;Ft.info("new LingoCameraVideoTrack"),this._stream=_d.default.createStream({audio:!1,video:!0,cameraId:p.cameraId}),G&&(this._videoProfile.width=G),$&&(this._videoProfile.height=$),H&&(this._videoProfile.frameRate=H),Q&&(this._videoProfile.bitrate=Q),this._stream.setVideoProfile(this._videoProfile),(Re=this._publishedStream)==null||Re.setVideoProfile(this._videoProfile)}getVideoProfile(){return this._videoProfile}async play(p){await this._stream.play(p.container,{mirror:this.mirrored}),this.lastPlayContainer=p.container}async stop(){await super.stop(),this.lastPlayContainer=null}async setDevice(p){var H,Q,Re,Ie;let G=this._beautyPlugin&&this._isVirtualEnable;if(this._log.info(`setDevice ${p} visual: ${G}`),G){let $e=_d.default.createStream({audio:!1,video:!0,cameraId:p});$e.setVideoProfile(this._videoProfile),(H=this._publishedStream)==null||H.setVideoProfile(this._videoProfile),await $e.initialize();let Et=$e.getVideoTrack();Et&&((Q=this._originTrack)==null||Q.removeEventListener("ended",this.onOriginTrackEnded),await((Re=this._beautyPlugin)==null?void 0:Re.replaceVirtualTrack(Et)),(Ie=this._originTrack)==null||Ie.addEventListener("ended",this.onOriginTrackEnded))}else if(await this._stream.switchDevice(this.trackMediaType,p),this._publishedStream&&this._publishedStream!==this._stream){let $e=this.getMediaStreamTrack();$e&&await this._publishedStream.replaceTrack($e)}let $=(await _d.default.getCameras()).find($e=>$e.deviceId===p);$&&this.emit("device-switched",$),!this._isVirtualEnable&&this._beautyPlugin&&(this._beautyPlugin.destroy(),this._beautyPlugin=null,this._isVirtualEnable=!1,this._imageUrl=null)}close(){var p;(p=this.getMediaStreamTrack())==null||p.stop(),this._stream.hasAudio()||this._stream.close(),super.close()}};var mw=lr(Er());var E7=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(ne){let q=Math.random()*16|0;return(ne=="x"?q:q&3|8).toString(16)})};function yd(){return!performance||!performance.now?Date.now():Math.floor(performance.now())}var sg=class{constructor(){this.intervalMap_=new Map}setInterval(q,p,G=!0){if(!window||!window.requestAnimationFrame)return setInterval(q,p);let $=E7(),H=yd(),Q=H;this.intervalMap_.set($,{rafId:null,timeoutId:null,onVisibilityChange:null});let Re=()=>{if(G&&document.hidden){if(q(),!this.intervalMap_.has($))return;let $e=setTimeout(Re,p);this.setTimeoutId($,$e),H=yd(),Q=H}else{if(Q=yd(),Q-H>=p&&(H=Q,q(),!this.intervalMap_.has($)))return;let $e=requestAnimationFrame(Re);this.setRafId($,$e)}},Ie=requestAnimationFrame(Re);if(this.setRafId($,Ie),G){let $e=()=>{if(document.hidden){let Et=yd()-H;if(Et>=p)Re();else{let Ye=setTimeout(Re,p-Et);this.setTimeoutId($,Ye)}}};document.addEventListener("visibilitychange",$e),this.setOnVisibilityChange($,$e),document.hidden&&$e()}return $}clearInterval(q){if(this.intervalMap_.has(q)){let{rafId:p,timeoutId:G,onVisibilityChange:$}=this.intervalMap_.get(q);cancelAnimationFrame(p),clearTimeout(G),document.removeEventListener("visibilitychange",$),this.intervalMap_.delete(q)}}setTimeoutId(q,p){if(this.intervalMap_.has(q)){let G=this.intervalMap_.get(q);G.timeoutId&&clearTimeout(G.timeoutId),G.timeoutId=p}}setRafId(q,p){if(this.intervalMap_.has(q)){let G=this.intervalMap_.get(q);G.rafId&&cancelAnimationFrame(G.rafId),G.rafId=p}}setOnVisibilityChange(q,p){if(this.intervalMap_.has(q)){let G=this.intervalMap_.get(q);G.onVisibilityChange=p}}},R7=new sg,cg=R7;var bd=class extends jo{constructor(p){super({mediaType:"video",id:"cus"});Ve(this,"frameRate",0);Ve(this,"canvas",document.createElement("canvas"));Ve(this,"canvasCtx");Ve(this,"onDraw",null);Ve(this,"_cameraVideoTrack",null);Ve(this,"_timerId");this._cameraVideoTrack=p}timerStop(){cg.clearInterval(this._timerId)}async init(){var $;if(this.canvasCtx)return;this.canvasCtx=this.canvas.getContext("2d");let p=($=this._cameraVideoTrack)==null?void 0:$.getMediaStreamTrack();if(p){let{width:H,height:Q,frameRate:Re}=p.getSettings();H&&(this.canvas.width=H),Q&&(this.canvas.height=Q),Re&&(this.frameRate=Re)}this._timerId=cg.setInterval(()=>{var Re,Ie,$e;let H=(Re=this._cameraVideoTrack)==null?void 0:Re.getMediaStreamTrack();if(H){let{width:Et,height:Ye,frameRate:dr}=H.getSettings();Et&&(this.canvas.width=Et),Ye&&(this.canvas.height=Ye),dr&&(this.frameRate=dr)}let Q=(Ie=this._cameraVideoTrack)==null?void 0:Ie.videoElement;Q&&(($e=this.canvasCtx)==null||$e.drawImage(Q,0,0,this.canvas.width,this.canvas.height),this.onDraw&&this.onDraw(this.canvas,this.mirrored))},1e3/this.frameRate,!0);let G=this.canvas.captureStream(this.frameRate).getVideoTracks()[0];this._stream=mw.default.createStream({videoSource:G}),await super.init()}async play(p){var G,$,H,Q;if(p.container){this.lastPlayContainer=p.container,(G=this._cameraVideoTrack)!=null&&G.isPlaying||await(($=this._cameraVideoTrack)==null?void 0:$.play({container:p.container}));let Re=(H=this._cameraVideoTrack)==null?void 0:H.videoElement;Re&&Re.parentElement&&(Re.parentElement.style.display="none"),await this._stream.play(p.container),this.mirrorVideo(this.mirrored)}(Q=p.custom)!=null&&Q.onDraw&&(this.onDraw=p.custom.onDraw)}async stop(){var G;this.onDraw=null;let p=(G=this._cameraVideoTrack)==null?void 0:G.videoElement;p&&p.parentElement&&(p.parentElement.style.display="block"),await this._stream.stop(),this.lastPlayContainer=null}setDevice(p){return Promise.resolve()}};var ug=lr(Er());function Sd(ne){return ne*1.5>100?100:ne*1.5}var kd=class extends Vo{constructor({microphoneId:p}){super({mediaType:"audio"});Ve(this,"_captureVolume",100);Ve(this,"_div",document.createElement("div"));Ve(this,"_isPlayCalled",!1);Ft.info("new LingoMicrophoneAudioTrack"),this._stream=ug.default.createStream({audio:!0,video:!1,microphoneId:p})}async play(){return this._isPlayCalled=!0,await this._stream.play(this._div,{muted:!1})}stop(){return this._isPlayCalled=!1,super.stop()}setPublishedStream(p){var G;p===null?(G=this._publishedStream)==null||G.setAudioCaptureVolume(100):p.setAudioCaptureVolume(this._captureVolume),super.setPublishedStream(p)}async setDevice(p){if(Ft.warn(`switch mic ${p}`),p==="default"&&this._stream.isAudioRecovering_)return;if(await this._stream.switchDevice(this.trackMediaType,p),this._publishedStream&&this._publishedStream!==this._stream){let $=this.getMediaStreamTrack();$&&await this._publishedStream.replaceTrack($)}let G=(await ug.default.getMicrophones()).find($=>$.deviceId===p);G&&this.emit("device-switched",G)}setVolume(p){var G;(G=this._publishedStream)==null||G.setAudioCaptureVolume(p),this._captureVolume=p}getVolume(){return this._isPlayCalled||(this._isPlayCalled=!0,this._stream.play(this._div)),Sd(this._stream.getAudioLevel()*100)}setSpeakerDevice(p){return this._stream.setAudioOutput(p)}close(){var p;(p=this.getMediaStreamTrack())==null||p.stop(),this._stream.hasAudio()||this._stream.close()}};var Bo=class extends Uo{constructor({uid:p,mediaType:G,stream:$}){super({mediaType:G});Ve(this,"uid");Ve(this,"isSubscribed",!1);this.uid=p,this._stream=$,this._stream.on("player-state-changed",({state:H})=>{this._playerState=H})}subscribe(){this.isSubscribed=!0}unsubscribe(){this.isSubscribed=!1}};var Td=class extends Bo{constructor({uid:q,stream:p}){super({uid:q,mediaType:"audio",stream:p})}setVolume(q){this._stream.setAudioVolume(q/100)}getVolume(){return Sd(this._stream.getAudioLevel()*100)}setSpeakerDevice(q){return this._stream.setAudioOutput(q)}async play(){return this._stream.isPlaying()?Promise.resolve():this._stream.play(document.createElement("div"))}};var xd=class extends Bo{constructor({uid:p,stream:G}){super({uid:p,mediaType:"video",stream:G});Ve(this,"mirrored",!1);Ve(this,"lastPlayContainer")}async play(p){await this._stream.play(p.container),this.lastPlayContainer=p.container}async stop(){await super.stop(),this.lastPlayContainer=null}mirrorVideo(p){this.lastPlayContainer&&(this._stream.play(this.lastPlayContainer,{mirror:p}),this.mirrored=p)}};import{LingoBaseRTC as P7,LingoRTCError as fg}from"@lingoace/lingo-base-rtc";var lg=lr(Er());import{LingoBaseRTCClient as A7,LingoRTCError as Fo,config as Rc}from"@lingoace/lingo-base-rtc";var Id=new WeakMap;function wd(){return function(ne,q,p){let G=p.value,$=({fn:H,args:Q,context:Re,resolve:Ie,reject:$e})=>{H.apply(Re,Q).then(Ie,$e).finally(()=>{let Et=Id.get(Re);Et.shift(),Et[0]&&$(Kr({},Et[0]))})};return p.value=function(...H){return new Promise((Q,Re)=>{if(Id.has(this)){let Ie=Id.get(this),{length:$e}=Ie;Ie.push({fn:G,args:H,context:this,resolve:Q,reject:Re}),$e===0&&$({fn:G,args:H,context:this,resolve:Q,reject:Re})}else Id.set(this,[{fn:G,args:H,context:this,resolve:Q,reject:Re}]),$({fn:G,args:H,context:this,resolve:Q,reject:Re})})},p}}import{LingoRTCError as vw}from"@lingoace/lingo-base-rtc";function Cn(ne){return function(q,p,G){let $=G.value;return G.value=async function(...H){try{return await $.apply(this,H)}catch(Q){throw ne?ne(Q):Q instanceof vw?Q:vw.createOtherError(Q.message)}},G}}var En=class extends A7{constructor(){super(...arguments);Ve(this,"_client",null);Ve(this,"_localStream",null);Ve(this,"_screenStream",null);Ve(this,"_remoteAuxiliaryStream",null);Ve(this,"_remoteMainStreamMap",new Map);Ve(this,"_remoteUserIdSet",new Set);Ve(this,"_quality",{res:"0x0",vfps:0,vra:0,ara:0,rtt:0,pktLostRate:0,upQuality:0,downQuality:0});Ve(this,"_prevLocalVideoStat",null);Ve(this,"_prevLocalAudioStat",null)}getRemoteUsers(){let p=new Map;return this._remoteUserIdSet.forEach(G=>{p.set(G,{uid:G,hasAudio:!1,hasVideo:!1})}),this.remoteAudioTrackMap.forEach(G=>{if(p.has(G.uid)){let $=p.get(G.uid);$.hasAudio=!0,$.audioTrack=G.isSubscribed?G:void 0}else p.set(G.uid,{uid:G.uid,hasAudio:!0,hasVideo:!1,audioTrack:G.isSubscribed?G:void 0,videoTrack:void 0})}),this.remoteVideoTrackMap.forEach(G=>{let{uid:$}=G;if(p.has(G.uid)){let H=p.get(G.uid);H.hasVideo=!0,H.videoTrack=G.isSubscribed?G:void 0}else p.set($,{uid:$,hasAudio:!1,hasVideo:!0,audioTrack:void 0,videoTrack:G.isSubscribed?G:void 0})}),[...p.values()]}async join(p){return this._client=lg.default.createClient({sdkAppId:Number(p.appId),userId:p.uid,userSig:p.token,mode:"rtc",useStringRoomId:!0,autoSubscribe:!1,enableAutoPlayDialog:!1}),this.handleEvents(),await this._client.join({roomId:p.roomId}),this.joinParam=p,this.uid=p.uid,p.uid}async leave(){!this._client||(await this._client.leave(),this.joinParam=void 0,this._client=null)}start(){return Promise.resolve()}async publish(p){return this._localStream?(p instanceof ya&&await this._localStream.setVideoProfile(p.getVideoProfile()),await this._localStream.addTrack(p.getMediaStreamTrack())):(await this._client.publish(p._stream),this._localStream=p._stream),p.setPublishedStream(this._localStream),this.localTracks.push(p),!0}async unpublish(p){var $;let G=p.getMediaStreamTrack();return!G||!this._localStream||this.localTracks.length===0||(this.localTracks.length===1?(await(($=this._client)==null?void 0:$.unpublish(this._localStream)),p.setPublishedStream(null),this._localStream=null,this.localTracks=[]):this.localTracks.find(H=>H===p)&&(await this._localStream.removeTrack(G),p.setPublishedStream(null),this.localTracks=this.localTracks.filter(H=>H!==p))),!0}async subscribe(p,G){var $,H;if(!this._client)throw Fo.createOtherError("\u7528\u6237\u672A\u8FDB\u623F\uFF0C\u65E0\u6CD5\u8BA2\u9605");if(G==="audio"&&!this.remoteAudioTrackMap.has(p))throw Fo.createOtherError(`\u8FDC\u7AEF\u7528\u6237: ${p} \u672A\u63A8\u97F3\u9891\uFF0C\u65E0\u6CD5\u8BA2\u9605`);if(G==="video"&&p!==Rc.screenSharingUid&&!this.remoteVideoTrackMap.has(p))throw Fo.createOtherError(`\u8FDC\u7AEF\u7528\u6237: ${p} \u672A\u63A8\u89C6\u9891\uFF0C\u65E0\u6CD5\u8BA2\u9605`);if(Ft.info(`subscribe ${p} ${G}`),p===Rc.screenSharingUid&&this._remoteAuxiliaryStream&&this._client)return await this._client.subscribe(this._remoteAuxiliaryStream),!0;if(G==="audio"){let Q=this.remoteAudioTrackMap.get(p);Q.subscribe();try{await this._client.subscribe(Q._stream,{audio:!0,video:!!(($=this.remoteVideoTrackMap.get(p))!=null&&$.isSubscribed)})}catch(Re){throw Q.unsubscribe(),Re}}else{let Q=this.remoteVideoTrackMap.get(p);Q.subscribe();try{await this._client.subscribe(Q._stream,{video:!0,audio:!!((H=this.remoteAudioTrackMap.get(p))!=null&&H.isSubscribed)})}catch(Re){throw Q.unsubscribe(),Re}}return!0}async unsubscribe(p,G){var H,Q;if(!this._client)throw Fo.createOtherError("\u7528\u6237\u672A\u8FDB\u623F\uFF0C\u65E0\u6CD5\u8BA2\u9605");Ft.info(`unsubscribe ${p} ${G}`);let $=null;if(G==="audio"&&this.remoteAudioTrackMap.has(p)?$=this.remoteAudioTrackMap.get(p):G==="video"&&this.remoteVideoTrackMap.has(p)&&($=this.remoteVideoTrackMap.get(p)),!$)throw Fo.createOtherError(`\u8FDC\u7AEF\u7528\u6237: ${p} \u672A\u63A8 ${G}\uFF0C\u65E0\u6CD5\u8BA2\u9605`);return p===Rc.screenSharingUid&&this._remoteAuxiliaryStream?(await this._client.unsubscribe(this._remoteAuxiliaryStream),!0):(G==="audio"?(H=this.remoteVideoTrackMap.get(p))!=null&&H.isSubscribed?await this._client.subscribe($._stream,{video:!0,audio:!1}):await this._client.unsubscribe($._stream):(Q=this.remoteAudioTrackMap.get(p))!=null&&Q.isSubscribed?await this._client.subscribe($._stream,{video:!1,audio:!0}):await this._client.unsubscribe($._stream),$.unsubscribe(),!0)}getQOEStats(){return this._quality}async startScreenShare(p){if(!this.joinParam||!this._client)throw Fo.createOtherError("\u7528\u6237\u672A\u8FDB\u623F\uFF0C\u65E0\u6CD5\u5F00\u542F\u5C4F\u5E55\u5206\u4EAB");this._screenStream=lg.default.createStream({screen:!0,screenAudio:!0});let G={width:1280,height:720,frameRate:15,bitrate:2e3};this._screenStream.setScreenProfile(Kr(Kr({},G),p)),this._screenStream.on("screen-sharing-stopped",async()=>{await this.stopScreenShare(),this.emit("ScreenSharingEnded")}),await this._screenStream.initialize(),await this._client.publish(this._screenStream,{isAuxiliary:!0})}async stopScreenShare(){!this._client||!this._screenStream||(await this._client.unpublish(this._screenStream),this._screenStream.stop(),this._screenStream.close(),this._screenStream=null)}async playScreenShareView(p){var G;this._remoteAuxiliaryStream&&this._client?(await this._client.subscribe(this._remoteAuxiliaryStream),await this._remoteAuxiliaryStream.play(p)):await((G=this._screenStream)==null?void 0:G.play(p))}async stopScreenShareView(){var p;this._remoteAuxiliaryStream&&this._client?(await this._client.unsubscribe(this._remoteAuxiliaryStream),await this._remoteAuxiliaryStream.stop()):await((p=this._screenStream)==null?void 0:p.stop())}handleEvents(){!this._client||(this._client.on("connection-state-changed",({prevState:p,state:G})=>{this.connectionState=G,this.emit("ConnectionStateChange",G,p,"")}),this._client.on("peer-join",p=>{this._remoteUserIdSet.add(p.userId),this.emit("UserJoined",p.userId)}),this._client.on("peer-leave",p=>{this._remoteUserIdSet.delete(p.userId),this.emit("UserLeft",p.userId)}),this._client.on("stream-added",p=>{let G=p.stream,$=G.getUserId();if(G.getType()==="auxiliary"){this._remoteAuxiliaryStream=G,this.emit("RemoteScreenSharing",Rc.screenSharingUid,!0,"video");return}this._remoteMainStreamMap.set($,G),G.on("error",H=>{if(H.getCode()===16451){let Q=()=>{G.resume().then(()=>{document.body.removeEventListener("click",Q),document.body.removeEventListener("touchstart",Q)})};document.body.addEventListener("click",Q,!0),document.body.addEventListener("touchstart",Q,!0),this.emit("AutoplayFailed")}}),G.hasAudio()&&this.handleUserPublished($,"audio"),G.hasVideo()&&this.handleUserPublished($,"video")}),this._client.on("stream-updated",p=>{let G=p.stream,$=G.getUserId();!this.remoteAudioTrackMap.has($)&&G.hasAudio()&&this.handleUserPublished($,"audio"),this.remoteAudioTrackMap.has($)&&!G.hasAudio()&&this.handleUserUnpublished($,"audio"),!this.remoteVideoTrackMap.has($)&&G.hasVideo()&&this.handleUserPublished($,"video"),this.remoteVideoTrackMap.has($)&&!G.hasVideo()&&this.handleUserUnpublished($,"video")}),this._client.on("stream-removed",p=>{let G=p.stream.getUserId();if(p.stream.getType()==="auxiliary"){this._remoteAuxiliaryStream=null,this.emit("RemoteScreenSharing",Rc.screenSharingUid,!1,"video");return}this._remoteMainStreamMap.delete(G),this.handleUserUnpublished(G,"audio"),this.handleUserUnpublished(G,"video")}),this._client.on("network-quality",p=>{var G,$;this._quality.upQuality=p.uplinkNetworkQuality,this._quality.downQuality=p.downlinkNetworkQuality,this._quality.rtt=p.uplinkRTT,this._quality.pktLostRate=p.uplinkLoss,(G=this._client)==null||G.getLocalVideoStats().then(H=>{let Q=H[this.uid];Q&&(this._quality.res=`${Q.frameWidth}x${Q.frameHeight}`,this._prevLocalVideoStat&&(this._quality.vfps=Math.floor((Q.framesSent-this._prevLocalVideoStat.framesSent)/2)||0,this._quality.vra=Math.floor((Q.bytesSent-this._prevLocalVideoStat.bytesSent)*8/2)||0),this._prevLocalVideoStat=Q)}),($=this._client)==null||$.getLocalAudioStats().then(H=>{let Q=H[this.uid];Q&&(this._prevLocalAudioStat&&(this._quality.ara=Math.floor((Q.bytesSent-this._prevLocalAudioStat.bytesSent)*8/2)||0),this._prevLocalAudioStat=Q)}),this.emit("NetworkQuality",p)}),this._client.on("mute-audio",p=>{this.handleUserUnpublished(p.userId,"audio")}),this._client.on("unmute-audio",p=>{this.handleUserPublished(p.userId,"audio",!0)}))}handleUserUnpublished(p,G){Ft.info(`UserUnpublished ${p} ${G}`),G==="audio"?this.remoteAudioTrackMap.has(p)&&(this.remoteAudioTrackMap.delete(p),this.emit("UserUnpublished",p,G)):this.remoteVideoTrackMap.has(p)&&(this.remoteVideoTrackMap.delete(p),this.emit("UserUnpublished",p,G))}handleUserPublished(p,G,$=!1){var Re;Ft.info(`UserPublished ${p} ${G} firedByUnmute: ${$}`);let H=this._remoteMainStreamMap.get(p),Q=(Re=this._client)==null?void 0:Re.getRemoteMutedState().find(Ie=>Ie.userId===p);if(H){if(G==="audio"&&!this.remoteAudioTrackMap.has(p)&&H.hasAudio()){if(!$&&Q&&Q.audioMuted)return;let Ie=new Td({uid:p,stream:H});this.remoteAudioTrackMap.set(p,Ie)}else if(G==="video"&&!this.remoteVideoTrackMap.has(p)&&H.hasVideo()){let Ie=new xd({uid:p,stream:H});this.remoteVideoTrackMap.set(p,Ie)}this.emit("UserPublished",p,G)}}};wn([Cn(),wd()],En.prototype,"publish",1),wn([Cn()],En.prototype,"unpublish",1),wn([Cn()],En.prototype,"subscribe",1),wn([Cn()],En.prototype,"unsubscribe",1),wn([Cn()],En.prototype,"startScreenShare",1),wn([Cn()],En.prototype,"stopScreenShare",1),wn([Cn()],En.prototype,"playScreenShareView",1),wn([Cn()],En.prototype,"stopScreenShareView",1);var Go=lr(Er());var gw=lr(ig()),dg=lr(Er());var hg=class extends gw.default{constructor(){super();Ve(this,"prevDevices_",[]);navigator.mediaDevices&&(this.onDeviceChange=this.onDeviceChange.bind(this),navigator.mediaDevices.addEventListener("devicechange",this.onDeviceChange))}async init(){this.prevDevices_=await dg.default.getDevices()}async onDeviceChange(){let p=await dg.default.getDevices(),G=p.filter(H=>this.prevDevices_.findIndex(({deviceId:Q})=>H.deviceId===Q)<0),$=this.prevDevices_.filter(H=>p.findIndex(({deviceId:Q})=>H.deviceId===Q)<0);G.length>0&&G.forEach(H=>{this.emit("device-added",H)}),$.length>0&&$.forEach(H=>{this.emit("device-removed",H)}),this.prevDevices_=p}destroy(){navigator.mediaDevices.removeEventListener("devicechange",this.onDeviceChange)}},_w=hg;var Ft=Go.default.Logger.loggerManager,Ho=class extends P7{constructor(){super(...arguments);Ve(this,"version",ew);Ve(this,"_deviceDetector",new _w);Ve(this,"_virtualOverloadCount",0);Ve(this,"_isVirtualOverloadStart",0)}init(p){return Ft.info(`lingo-trtc version: ${this.version}`),Promise.resolve()}release(){this._deviceDetector.destroy(),super.release()}async checkSystemRequirements(){let{result:p}=await Go.default.checkSystemRequirements();return p&&Go.default.isScreenShareSupported()}async createClient(){return this.client=new En,await this._deviceDetector.init(),this._deviceDetector.on("device-added",p=>{p.kind==="videoinput"?this.client.emit("CameraChanged",!0,p):p.kind==="audioinput"?this.client.emit("MicrophoneChanged",!0,p):p.kind==="audiooutput"&&this.client.emit("SpeakerDeviceChanged",!0,p)}),this._deviceDetector.on("device-removed",async p=>{var G,$;if(p.kind==="videoinput"){let H=this.cameraVideoTrack||this.previewVideoTrack;if(p.deviceId===(H==null?void 0:H.getDeviceId())){if((await Go.default.getCameras()).length===0){this.client.emit("CameraChanged",!1,p);return}H.once("device-switched",()=>{this.client.emit("CameraChanged",!1,p)}),H.once("track-ended",()=>{this.client.emit("CameraChanged",!1,p)})}else this.client.emit("CameraChanged",!1,p)}else if(p.kind==="audioinput")if(p.deviceId===((G=this.microphoneAudioTrack)==null?void 0:G.getDeviceId())){if((await Go.default.getMicrophones()).length===0){this.client.emit("CameraChanged",!1,p);return}this.microphoneAudioTrack.once("device-switched",()=>{this.client.emit("CameraChanged",!1,p)}),($=this.microphoneAudioTrack)==null||$.once("track-ended",()=>{this.client.emit("CameraChanged",!1,p)})}else this.client.emit("MicrophoneChanged",!1,p);else p.kind==="audiooutput"&&this.client.emit("SpeakerDeviceChanged",!1,p)}),this.client}async createCustomVideoTrack(p){if(this.customVideoTrack&&!this.customVideoTrack.closed)return this.customVideoTrack;Ft.info("createCustomVideoTrack");let G=new bd(p);return await G.init(),this.customVideoTrack=G,G}async detectCamera(p){var G,$;if(this.previewVideoTrack&&!this.previewVideoTrack.closed)return{checkIsActive:()=>{var H,Q;return Promise.resolve(((Q=(H=this.previewVideoTrack)==null?void 0:H.getMediaStreamTrack())==null?void 0:Q.readyState)==="live")},cleanup:()=>{var H,Q;(H=this.previewVideoTrack)==null||H.stop(),(Q=this.previewVideoTrack)==null||Q.close(),this.previewVideoTrack=void 0}};Ft.info("detectCamera");try{let H=new ya({cameraId:p.cameraId,id:"pv"});return H.on("device-switched",Q=>this.client.emit("DeviceSwitched",Q)),this.previewVideoTrack=H,await H.init(),p.mirror&&H.mirrorVideo(p.mirror),p.container&&await H.play({container:p.container}),{checkIsActive:()=>{var Q;return Promise.resolve(((Q=H.getMediaStreamTrack())==null?void 0:Q.readyState)==="live")},cleanup:()=>{H.stop(),H.close(),this.previewVideoTrack=void 0}}}catch(H){throw(G=this.previewVideoTrack)==null||G.stop(),($=this.previewVideoTrack)==null||$.close(),this.previewVideoTrack=void 0,H}}processExternalMediaAEC(p){}async createMicrophoneAudioTrack(p){if(this.microphoneAudioTrack&&!this.microphoneAudioTrack.closed)return this.microphoneAudioTrack;Ft.info("createMicrophoneAudioTrack");let G=new kd({microphoneId:p});return G.on("device-switched",$=>this.client.emit("DeviceSwitched",$)),await G.init(),this.microphoneAudioTrack=G,this.client.emit("LocalTrackCreated",G),G}async createCameraVideoTrack(p){if(this.cameraVideoTrack&&!this.cameraVideoTrack.closed)return this.cameraVideoTrack;Ft.info(`createCameraVideoTrack ${JSON.stringify(p)}`);let G=new ya(pd(Kr({},p),{id:"ct"}));return G.on("device-switched",$=>this.client.emit("DeviceSwitched",$)),await G.init(),this.cameraVideoTrack=G,this.client.emit("LocalTrackCreated",G),this.cameraVideoTrack.on("VirtualBackgroundOverload",()=>{this._virtualOverloadCount++,Ft.warn(`VirtualBackground overload count is: ${this._virtualOverloadCount}`),new Date().getTime()-this._isVirtualOverloadStart>5e3&&(this._virtualOverloadCount>10&&(Ft.warn("VirtualBackgroundOverload"),this.client.emit("VirtualBackgroundOverload")),this._virtualOverloadCount=0,this._isVirtualOverloadStart=new Date().getTime())}),G}};wn([wd(),Cn(ne=>fg.createRTCError(ne))],Ho.prototype,"detectCamera",1),wn([Cn(ne=>fg.createRTCError(ne))],Ho.prototype,"createMicrophoneAudioTrack",1),wn([Cn(ne=>fg.createRTCError(ne))],Ho.prototype,"createCameraVideoTrack",1);if(document){let ne={MAIN:"schedule.rtc.qq.com",BACKUP:"schedule.rtc.qcloud.com",MAIN_OVERSEA:"schedule.rtc.tencentcloud.com",BACKUP_OVERSEA:"schedule-ecdn.rtc.tencentcloud.com"};document.head.innerHTML+=Object.values(ne).map(q=>`<link rel="dns-prefetch" href="https://${q}">`).join(`\r
|
|
549
|
+
`)}var eH=Ho;export{eH as default,Ft as loggerManager};
|
|
585
550
|
/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */
|