@lingoace/lingo-trtc-rtc 0.0.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/index.d.ts +19 -0
  2. package/package.json +9 -0
  3. package/trtc-lingo.js +585 -0
package/trtc-lingo.js ADDED
@@ -0,0 +1,585 @@
1
+ var f7=Object.create;var fd=Object.defineProperty,m7=Object.defineProperties,fw=Object.getOwnPropertyDescriptor,v7=Object.getOwnPropertyDescriptors,g7=Object.getOwnPropertyNames,pw=Object.getOwnPropertySymbols,_7=Object.getPrototypeOf,mw=Object.prototype.hasOwnProperty,y7=Object.prototype.propertyIsEnumerable;var og=(X,G,m)=>G in X?fd(X,G,{enumerable:!0,configurable:!0,writable:!0,value:m}):X[G]=m,Jr=(X,G)=>{for(var m in G||(G={}))mw.call(G,m)&&og(X,m,G[m]);if(pw)for(var m of pw(G))y7.call(G,m)&&og(X,m,G[m]);return X},md=(X,G)=>m7(X,v7(G));var sg=(X,G)=>()=>(G||X((G={exports:{}}).exports,G),G.exports);var b7=(X,G,m,V)=>{if(G&&typeof G=="object"||typeof G=="function")for(let J of g7(G))!mw.call(X,J)&&J!==m&&fd(X,J,{get:()=>G[J],enumerable:!(V=fw(G,J))||V.enumerable});return X};var ir=(X,G,m)=>(m=X!=null?f7(_7(X)):{},b7(G||!X||!X.__esModule?fd(m,"default",{value:X,enumerable:!0}):m,X));var xn=(X,G,m,V)=>{for(var J=V>1?void 0:V?fw(G,m):G,N=X.length-1,z;N>=0;N--)(z=X[N])&&(J=(V?z(G,m,J):z(J))||J);return V&&J&&fd(G,m,J),J};var Ue=(X,G,m)=>(og(X,typeof G!="symbol"?G+"":G,m),m);var Ir=sg((cg,ug)=>{(function(X,G){typeof cg=="object"&&typeof ug!="undefined"?ug.exports=G():typeof define=="function"&&define.amd?define(G):(X=typeof globalThis!="undefined"?globalThis:X||self).TRTC=G()})(cg,function(){function X(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),n.push.apply(n,r)}return n}function G(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?X(Object(n),!0).forEach(function(r){ut(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):X(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}function m(){m=function(){return e};var e={},t=Object.prototype,n=t.hasOwnProperty,r=typeof Symbol=="function"?Symbol:{},i=r.iterator||"@@iterator",o=r.asyncIterator||"@@asyncIterator",a=r.toStringTag||"@@toStringTag";function s(A,U,T){return Object.defineProperty(A,U,{value:T,enumerable:!0,configurable:!0,writable:!0}),A[U]}try{s({},"")}catch(A){s=function(U,T,g){return U[T]=g}}function c(A,U,T,g){var I=U&&U.prototype instanceof p?U:p,w=Object.create(I.prototype),L=new O(g||[]);return w._invoke=function(B,ee,oe){var ve="suspendedStart";return function(ge,qe){if(ve==="executing")throw new Error("Generator is already running");if(ve==="completed"){if(ge==="throw")throw qe;return P()}for(oe.method=ge,oe.arg=qe;;){var Ne=oe.delegate;if(Ne){var Ge=Y(Ne,oe);if(Ge){if(Ge===d)continue;return Ge}}if(oe.method==="next")oe.sent=oe._sent=oe.arg;else if(oe.method==="throw"){if(ve==="suspendedStart")throw ve="completed",oe.arg;oe.dispatchException(oe.arg)}else oe.method==="return"&&oe.abrupt("return",oe.arg);ve="executing";var Je=u(B,ee,oe);if(Je.type==="normal"){if(ve=oe.done?"completed":"suspendedYield",Je.arg===d)continue;return{value:Je.arg,done:oe.done}}Je.type==="throw"&&(ve="completed",oe.method="throw",oe.arg=Je.arg)}}}(A,T,L),w}function u(A,U,T){try{return{type:"normal",arg:A.call(U,T)}}catch(g){return{type:"throw",arg:g}}}e.wrap=c;var d={};function p(){}function h(){}function f(){}var _={};s(_,i,function(){return this});var y=Object.getPrototypeOf,S=y&&y(y(k([])));S&&S!==t&&n.call(S,i)&&(_=S);var E=f.prototype=p.prototype=Object.create(_);function R(A){["next","throw","return"].forEach(function(U){s(A,U,function(T){return this._invoke(U,T)})})}function H(A,U){function T(I,w,L,B){var ee=u(A[I],A,w);if(ee.type!=="throw"){var oe=ee.arg,ve=oe.value;return ve&&typeof ve=="object"&&n.call(ve,"__await")?U.resolve(ve.__await).then(function(ge){T("next",ge,L,B)},function(ge){T("throw",ge,L,B)}):U.resolve(ve).then(function(ge){oe.value=ge,L(oe)},function(ge){return T("throw",ge,L,B)})}B(ee.arg)}var g;this._invoke=function(I,w){function L(){return new U(function(B,ee){T(I,w,B,ee)})}return g=g?g.then(L,L):L()}}function Y(A,U){var T=A.iterator[U.method];if(T===void 0){if(U.delegate=null,U.method==="throw"){if(A.iterator.return&&(U.method="return",U.arg=void 0,Y(A,U),U.method==="throw"))return d;U.method="throw",U.arg=new TypeError("The iterator does not provide a 'throw' method")}return d}var g=u(T,A.iterator,U.arg);if(g.type==="throw")return U.method="throw",U.arg=g.arg,U.delegate=null,d;var I=g.arg;return I?I.done?(U[A.resultName]=I.value,U.next=A.nextLoc,U.method!=="return"&&(U.method="next",U.arg=void 0),U.delegate=null,d):I:(U.method="throw",U.arg=new TypeError("iterator result is not an object"),U.delegate=null,d)}function ue(A){var U={tryLoc:A[0]};1 in A&&(U.catchLoc=A[1]),2 in A&&(U.finallyLoc=A[2],U.afterLoc=A[3]),this.tryEntries.push(U)}function le(A){var U=A.completion||{};U.type="normal",delete U.arg,A.completion=U}function O(A){this.tryEntries=[{tryLoc:"root"}],A.forEach(ue,this),this.reset(!0)}function k(A){if(A){var U=A[i];if(U)return U.call(A);if(typeof A.next=="function")return A;if(!isNaN(A.length)){var T=-1,g=function I(){for(;++T<A.length;)if(n.call(A,T))return I.value=A[T],I.done=!1,I;return I.value=void 0,I.done=!0,I};return g.next=g}}return{next:P}}function P(){return{value:void 0,done:!0}}return h.prototype=f,s(E,"constructor",f),s(f,"constructor",h),h.displayName=s(f,a,"GeneratorFunction"),e.isGeneratorFunction=function(A){var U=typeof A=="function"&&A.constructor;return!!U&&(U===h||(U.displayName||U.name)==="GeneratorFunction")},e.mark=function(A){return Object.setPrototypeOf?Object.setPrototypeOf(A,f):(A.__proto__=f,s(A,a,"GeneratorFunction")),A.prototype=Object.create(E),A},e.awrap=function(A){return{__await:A}},R(H.prototype),s(H.prototype,o,function(){return this}),e.AsyncIterator=H,e.async=function(A,U,T,g,I){I===void 0&&(I=Promise);var w=new H(c(A,U,T,g),I);return e.isGeneratorFunction(U)?w:w.next().then(function(L){return L.done?L.value:w.next()})},R(E),s(E,a,"Generator"),s(E,i,function(){return this}),s(E,"toString",function(){return"[object Generator]"}),e.keys=function(A){var U=[];for(var T in A)U.push(T);return U.reverse(),function g(){for(;U.length;){var I=U.pop();if(I in A)return g.value=I,g.done=!1,g}return g.done=!0,g}},e.values=k,O.prototype={constructor:O,reset:function(A){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(le),!A)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 A=this.tryEntries[0].completion;if(A.type==="throw")throw A.arg;return this.rval},dispatchException:function(A){if(this.done)throw A;var U=this;function T(ee,oe){return w.type="throw",w.arg=A,U.next=ee,oe&&(U.method="next",U.arg=void 0),!!oe}for(var g=this.tryEntries.length-1;g>=0;--g){var I=this.tryEntries[g],w=I.completion;if(I.tryLoc==="root")return T("end");if(I.tryLoc<=this.prev){var L=n.call(I,"catchLoc"),B=n.call(I,"finallyLoc");if(L&&B){if(this.prev<I.catchLoc)return T(I.catchLoc,!0);if(this.prev<I.finallyLoc)return T(I.finallyLoc)}else if(L){if(this.prev<I.catchLoc)return T(I.catchLoc,!0)}else{if(!B)throw new Error("try statement without catch or finally");if(this.prev<I.finallyLoc)return T(I.finallyLoc)}}}},abrupt:function(A,U){for(var T=this.tryEntries.length-1;T>=0;--T){var g=this.tryEntries[T];if(g.tryLoc<=this.prev&&n.call(g,"finallyLoc")&&this.prev<g.finallyLoc){var I=g;break}}I&&(A==="break"||A==="continue")&&I.tryLoc<=U&&U<=I.finallyLoc&&(I=null);var w=I?I.completion:{};return w.type=A,w.arg=U,I?(this.method="next",this.next=I.finallyLoc,d):this.complete(w)},complete:function(A,U){if(A.type==="throw")throw A.arg;return A.type==="break"||A.type==="continue"?this.next=A.arg:A.type==="return"?(this.rval=this.arg=A.arg,this.method="return",this.next="end"):A.type==="normal"&&U&&(this.next=U),d},finish:function(A){for(var U=this.tryEntries.length-1;U>=0;--U){var T=this.tryEntries[U];if(T.finallyLoc===A)return this.complete(T.completion,T.afterLoc),le(T),d}},catch:function(A){for(var U=this.tryEntries.length-1;U>=0;--U){var T=this.tryEntries[U];if(T.tryLoc===A){var g=T.completion;if(g.type==="throw"){var I=g.arg;le(T)}return I}}throw new Error("illegal catch attempt")},delegateYield:function(A,U,T){return this.delegate={iterator:k(A),resultName:U,nextLoc:T},this.method==="next"&&(this.arg=void 0),d}},e}function V(e){return V=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},V(e)}function J(e,t,n,r,i,o,a){try{var s=e[o](a),c=s.value}catch(u){return void n(u)}s.done?t(c):Promise.resolve(c).then(r,i)}function N(e){return function(){var t=this,n=arguments;return new Promise(function(r,i){var o=e.apply(t,n);function a(c){J(o,r,i,a,s,"next",c)}function s(c){J(o,r,i,a,s,"throw",c)}a(void 0)})}}function z(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 r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function ke(e,t,n){return t&&Pe(e.prototype,t),n&&Pe(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function ut(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Mt(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&&ar(e,t)}function $e(e){return $e=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},$e(e)}function ar(e,t){return ar=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(n,r){return n.__proto__=r,n},ar(e,t)}function Pc(){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 Eo(e,t,n){return Eo=Pc()?Reflect.construct.bind():function(r,i,o){var a=[null];a.push.apply(a,i);var s=new(Function.bind.apply(r,a));return o&&ar(s,o.prototype),s},Eo.apply(null,arguments)}function Co(e){var t=typeof Map=="function"?new Map:void 0;return Co=function(n){if(n===null||(r=n,Function.toString.call(r).indexOf("[native code]")===-1))return n;var r;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 Eo(n,arguments,$e(this).constructor)}return i.prototype=Object.create(n.prototype,{constructor:{value:i,enumerable:!1,writable:!0,configurable:!0}}),ar(i,n)},Co(e)}function Ro(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 wr(e){var t=Pc();return function(){var n,r=$e(e);if(t){var i=$e(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return Ro(this,n)}}function Dc(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&(e=$e(e))!==null;);return e}function ae(){return ae=typeof Reflect!="undefined"&&Reflect.get?Reflect.get.bind():function(e,t,n){var r=Dc(e,t);if(r){var i=Object.getOwnPropertyDescriptor(r,t);return i.get?i.get.call(arguments.length<3?e:n):i.value}},ae.apply(this,arguments)}function Te(e,t){return function(n){if(Array.isArray(n))return n}(e)||function(n,r){var i=n==null?null:typeof Symbol!="undefined"&&n[Symbol.iterator]||n["@@iterator"];if(i!=null){var o,a,s=[],c=!0,u=!1;try{for(i=i.call(n);!(c=(o=i.next()).done)&&(s.push(o.value),!r||s.length!==r);c=!0);}catch(d){u=!0,a=d}finally{try{c||i.return==null||i.return()}finally{if(u)throw a}}return s}}(e,t)||Ve(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 Fe(t)}(e)||function(t){if(typeof Symbol!="undefined"&&t[Symbol.iterator]!=null||t["@@iterator"]!=null)return Array.from(t)}(e)||Ve(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 Ve(e,t){if(e){if(typeof e=="string")return Fe(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)?Fe(e,t):void 0}}function Fe(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function ne(e,t){var n=typeof Symbol!="undefined"&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=Ve(e))||t&&e&&typeof e.length=="number"){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(c){throw c},f:i}}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,a=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var c=n.next();return a=c.done,c},e:function(c){s=!0,o=c},f:function(){try{a||n.return==null||n.return()}finally{if(s)throw o}}}}function q(e,t,n,r,i){var o={};return Object.keys(r).forEach(function(a){o[a]=r[a]}),o.enumerable=!!o.enumerable,o.configurable=!!o.configurable,("value"in o||o.initializer)&&(o.writable=!0),o=n.slice().reverse().reduce(function(a,s){return s(e,t,a)||a},o),i&&o.initializer!==void 0&&(o.value=o.initializer?o.initializer.call(i):void 0,o.initializer=void 0),o.initializer===void 0&&(Object.defineProperty(e,t,o),o=null),o}var re=typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:{},j=function(e){return e&&e.Math==Math&&e},Z=j(typeof globalThis=="object"&&globalThis)||j(typeof window=="object"&&window)||j(typeof self=="object"&&self)||j(typeof re=="object"&&re)||function(){return this}()||Function("return this")(),ye={},ie=function(e){try{return!!e()}catch(t){return!0}},_e=!ie(function(){return Object.defineProperty({},1,{get:function(){return 7}})[1]!=7}),De=!ie(function(){var e=function(){}.bind();return typeof e!="function"||e.hasOwnProperty("prototype")}),Gt=De,qt=Function.prototype.call,Ke=Gt?qt.bind(qt):function(){return qt.apply(qt,arguments)},Ht={},lt={}.propertyIsEnumerable,Gn=Object.getOwnPropertyDescriptor,or=Gn&&!lt.call({1:2},1);Ht.f=or?function(e){var t=Gn(this,e);return!!t&&t.enumerable}:lt;var Ut,En,Ze=function(e,t){return{enumerable:!(1&e),configurable:!(2&e),writable:!(4&e),value:t}},Bt=De,Hn=Function.prototype,he=Hn.bind,se=Hn.call,Me=Bt&&he.bind(se,se),ce=Bt?function(e){return e&&Me(e)}:function(e){return e&&function(){return se.apply(e,arguments)}},Ae=ce,st=Ae({}.toString),Tt=Ae("".slice),vt=function(e){return Tt(st(e),8,-1)},Kt=ie,tt=vt,wt=Object,zt=ce("".split),Cn=Kt(function(){return!wt("z").propertyIsEnumerable(0)})?function(e){return tt(e)=="String"?zt(e,""):wt(e)}:wt,Si=TypeError,Ct=function(e){if(e==null)throw Si("Can't call method on "+e);return e},fn=Cn,Cd=Ct,it=function(e){return fn(Cd(e))},We=function(e){return typeof e=="function"},Lc=We,yt=function(e){return typeof e=="object"?e!==null:Lc(e)},Ao=Z,Oc=We,Mc=function(e){return Oc(e)?e:void 0},Rn=function(e,t){return arguments.length<2?Mc(Ao[e]):Ao[e]&&Ao[e][t]},zn=ce({}.isPrototypeOf),mn=Rn("navigator","userAgent")||"",Po=Z,Wn=mn,Do=Po.process,ca=Po.Deno,Lo=Do&&Do.versions||ca&&ca.version,Oo=Lo&&Lo.v8;Oo&&(En=(Ut=Oo.split("."))[0]>0&&Ut[0]<4?1:+(Ut[0]+Ut[1])),!En&&Wn&&(!(Ut=Wn.match(/Edge\/(\d+)/))||Ut[1]>=74)&&(Ut=Wn.match(/Chrome\/(\d+)/))&&(En=+Ut[1]);var Jn=En,Nc=Jn,Rd=ie,Mo=!!Object.getOwnPropertySymbols&&!Rd(function(){var e=Symbol();return!String(e)||!(Object(e)instanceof Symbol)||!Symbol.sham&&Nc&&Nc<41}),qr=Mo&&!Symbol.sham&&typeof Symbol.iterator=="symbol",No=Rn,Vc=We,Uc=zn,Vo=Object,An=qr?function(e){return typeof e=="symbol"}:function(e){var t=No("Symbol");return Vc(t)&&Uc(t.prototype,Vo(e))},ki=String,Er=function(e){try{return ki(e)}catch(t){return"Object"}},Bc=We,Uo=Er,jc=TypeError,Nt=function(e){if(Bc(e))return e;throw jc(Uo(e)+" is not a function")},Bo=Nt,sr=function(e,t){var n=e[t];return n==null?void 0:Bo(n)},Kr=Ke,Qr=We,jo=yt,Xr=TypeError,cn={exports:{}},cr=Z,Fc=Object.defineProperty,bt=function(e,t){try{Fc(cr,e,{value:t,configurable:!0,writable:!0})}catch(n){cr[e]=t}return t},Pn=bt,ua="__core-js_shared__",Fo=Z[ua]||Pn(ua,{}),Ti=Fo;(cn.exports=function(e,t){return Ti[e]||(Ti[e]=t!==void 0?t:{})})("versions",[]).push({version:"3.24.1",mode:"global",copyright:"\xA9 2014-2022 Denis Pushkarev (zloirock.ru)",license:"https://github.com/zloirock/core-js/blob/v3.24.1/LICENSE",source:"https://github.com/zloirock/core-js"});var Go=Ct,la=Object,Rt=function(e){return la(Go(e))},da=Rt,Gc=ce({}.hasOwnProperty),kt=Object.hasOwn||function(e,t){return Gc(da(e),t)},Ho=ce,Hc=0,vn=Math.random(),Dn=Ho(1 .toString),ur=function(e){return"Symbol("+(e===void 0?"":e)+")_"+Dn(++Hc+vn,36)},zo=Z,Wo=cn.exports,Jo=kt,qo=ur,gn=Mo,Ko=qr,lr=Wo("wks"),jt=zo.Symbol,Qo=jt&&jt.for,Xo=Ko?jt:jt&&jt.withoutSetter||qo,ct=function(e){if(!Jo(lr,e)||!gn&&typeof lr[e]!="string"){var t="Symbol."+e;gn&&Jo(jt,e)?lr[e]=jt[e]:lr[e]=Ko&&Qo?Qo(t):Xo(t)}return lr[e]},Ad=Ke,Yo=yt,$o=An,zc=sr,Wc=function(e,t){var n,r;if(t==="string"&&Qr(n=e.toString)&&!jo(r=Kr(n,e))||Qr(n=e.valueOf)&&!jo(r=Kr(n,e))||t!=="string"&&Qr(n=e.toString)&&!jo(r=Kr(n,e)))return r;throw Xr("Can't convert object to primitive value")},Qt=TypeError,Jc=ct("toPrimitive"),ha=function(e,t){if(!Yo(e)||$o(e))return e;var n,r=zc(e,Jc);if(r){if(t===void 0&&(t="default"),n=Ad(r,e,t),!Yo(n)||$o(n))return n;throw Qt("Can't convert object to primitive value")}return t===void 0&&(t="number"),Wc(e,t)},pa=ha,qc=An,xi=function(e){var t=pa(e,"string");return qc(t)?t:t+""},Kc=yt,fa=Z.document,Qc=Kc(fa)&&Kc(fa.createElement),Cr=function(e){return Qc?fa.createElement(e):{}},Xc=Cr,Zo=!_e&&!ie(function(){return Object.defineProperty(Xc("div"),"a",{get:function(){return 7}}).a!=7}),Ii=_e,Pd=Ke,Dd=Ht,Ld=Ze,Od=it,es=xi,wi=kt,Md=Zo,Yc=Object.getOwnPropertyDescriptor;ye.f=Ii?Yc:function(e,t){if(e=Od(e),t=es(t),Md)try{return Yc(e,t)}catch(n){}if(wi(e,t))return Ld(!Pd(Dd.f,e,t),e[t])};var At={},$c=_e&&ie(function(){return Object.defineProperty(function(){},"prototype",{value:42,writable:!1}).prototype!=42}),ts=yt,Zc=String,eu=TypeError,dt=function(e){if(ts(e))return e;throw eu(Zc(e)+" is not an object")},_n=_e,Nd=Zo,Vd=$c,Ei=dt,ns=xi,rs=TypeError,Ci=Object.defineProperty,Yr=Object.getOwnPropertyDescriptor,tu="enumerable",is="configurable",Ud="writable";At.f=_n?Vd?function(e,t,n){if(Ei(e),t=ns(t),Ei(n),typeof e=="function"&&t==="prototype"&&"value"in n&&Ud in n&&!n.writable){var r=Yr(e,t);r&&r.writable&&(e[t]=n.value,n={configurable:is in n?n.configurable:r.configurable,enumerable:tu in n?n.enumerable:r.enumerable,writable:!1})}return Ci(e,t,n)}:Ci:function(e,t,n){if(Ei(e),t=ns(t),Ei(n),Nd)try{return Ci(e,t,n)}catch(r){}if("get"in n||"set"in n)throw rs("Accessors not supported");return"value"in n&&(e[t]=n.value),e};var Bd=At,Ri=Ze,yn=_e?function(e,t,n){return Bd.f(e,t,Ri(1,n))}:function(e,t,n){return e[t]=n,e},ma={exports:{}},as=_e,jd=kt,Ai=Function.prototype,nu=as&&Object.getOwnPropertyDescriptor,os=jd(Ai,"name"),dr={EXISTS:os,PROPER:os&&function(){}.name==="something",CONFIGURABLE:os&&(!as||as&&nu(Ai,"name").configurable)},Fd=We,ss=Fo,cs=ce(Function.toString);Fd(ss.inspectSource)||(ss.inspectSource=function(e){return cs(e)});var Pi,Di,va,ga=ss.inspectSource,ru=We,us=ga,iu=Z.WeakMap,Li=ru(iu)&&/native code/.test(us(iu)),Gd=cn.exports,Hd=ur,ls=Gd("keys"),_a=function(e){return ls[e]||(ls[e]=Hd(e))},l={},v=Li,b=Z,x=ce,D=yt,C=yn,M=kt,F=Fo,K=_a,de=l,me="Object already initialized",we=b.TypeError,Re=b.WeakMap;if(v||F.state){var pe=F.state||(F.state=new Re),Le=x(pe.get),Be=x(pe.has),at=x(pe.set);Pi=function(e,t){if(Be(pe,e))throw new we(me);return t.facade=e,at(pe,e,t),t},Di=function(e){return Le(pe,e)||{}},va=function(e){return Be(pe,e)}}else{var nt=K("state");de[nt]=!0,Pi=function(e,t){if(M(e,nt))throw new we(me);return t.facade=e,C(e,nt,t),t},Di=function(e){return M(e,nt)?e[nt]:{}},va=function(e){return M(e,nt)}}var Qe={set:Pi,get:Di,has:va,enforce:function(e){return va(e)?Di(e):Pi(e,{})},getterFor:function(e){return function(t){var n;if(!D(t)||(n=Di(t)).type!==e)throw we("Incompatible receiver, "+e+" required");return n}}},un=ie,Xt=We,Xe=kt,Dt=_e,hr=dr.CONFIGURABLE,ya=ga,Rr=Qe.enforce,au=Qe.get,qn=Object.defineProperty,ba=Dt&&!un(function(){return qn(function(){},"length",{value:8}).length!==8}),ds=String(String).split("String"),Mw=ma.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),(!Xe(e,"name")||hr&&e.name!==t)&&(Dt?qn(e,"name",{value:t,configurable:!0}):e.name=t),ba&&n&&Xe(n,"arity")&&e.length!==n.arity&&qn(e,"length",{value:n.arity});try{n&&Xe(n,"constructor")&&n.constructor?Dt&&qn(e,"prototype",{writable:!1}):e.prototype&&(e.prototype=void 0)}catch(i){}var r=Rr(e);return Xe(r,"source")||(r.source=ds.join(typeof t=="string"?t:"")),e};Function.prototype.toString=Mw(function(){return Xt(this)&&au(this).source||ya(this)},"toString");var Nw=We,Vw=At,Uw=ma.exports,Bw=bt,Wt=function(e,t,n,r){r||(r={});var i=r.enumerable,o=r.name!==void 0?r.name:t;if(Nw(n)&&Uw(n,o,r),r.global)i?e[t]=n:Bw(t,n);else{try{r.unsafe?e[t]&&(i=!0):delete e[t]}catch(a){}i?e[t]=n:Vw.f(e,t,{value:n,enumerable:!1,configurable:!r.nonConfigurable,writable:!r.nonWritable})}return e},$r={},jw=Math.ceil,Fw=Math.floor,Gw=Math.trunc||function(e){var t=+e;return(t>0?Fw:jw)(t)},Kn=function(e){var t=+e;return t!=t||t===0?0:Gw(t)},Hw=Kn,zw=Math.max,Ww=Math.min,Zr=function(e,t){var n=Hw(e);return n<0?zw(n+t,0):Ww(n,t)},Jw=Kn,qw=Math.min,Qn=function(e){return e>0?qw(Jw(e),9007199254740991):0},Kw=Qn,Zt=function(e){return Kw(e.length)},Qw=it,Xw=Zr,Yw=Zt,Sg=function(e){return function(t,n,r){var i,o=Qw(t),a=Yw(o),s=Xw(r,a);if(e&&n!=n){for(;a>s;)if((i=o[s++])!=i)return!0}else for(;a>s;s++)if((e||s in o)&&o[s]===n)return e||s||0;return!e&&-1}},hs={includes:Sg(!0),indexOf:Sg(!1)},zd=kt,$w=it,Zw=hs.indexOf,eE=l,kg=ce([].push),Tg=function(e,t){var n,r=$w(e),i=0,o=[];for(n in r)!zd(eE,n)&&zd(r,n)&&kg(o,n);for(;t.length>i;)zd(r,n=t[i++])&&(~Zw(o,n)||kg(o,n));return o},Wd=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"],tE=Tg,nE=Wd.concat("length","prototype");$r.f=Object.getOwnPropertyNames||function(e){return tE(e,nE)};var Jd={};Jd.f=Object.getOwnPropertySymbols;var rE=Rn,iE=$r,aE=Jd,oE=dt,sE=ce([].concat),cE=rE("Reflect","ownKeys")||function(e){var t=iE.f(oE(e)),n=aE.f;return n?sE(t,n(e)):t},xg=kt,uE=cE,lE=ye,dE=At,hE=ie,pE=We,fE=/#|\.prototype\./,ps=function(e,t){var n=vE[mE(e)];return n==_E||n!=gE&&(pE(t)?hE(t):!!t)},mE=ps.normalize=function(e){return String(e).replace(fE,".").toLowerCase()},vE=ps.data={},gE=ps.NATIVE="N",_E=ps.POLYFILL="P",fs=ps,qd=Z,yE=ye.f,bE=yn,SE=Wt,kE=bt,TE=function(e,t,n){for(var r=uE(t),i=dE.f,o=lE.f,a=0;a<r.length;a++){var s=r[a];xg(e,s)||n&&xg(n,s)||i(e,s,o(t,s))}},xE=fs,Oe=function(e,t){var n,r,i,o,a,s=e.target,c=e.global,u=e.stat;if(n=c?qd:u?qd[s]||kE(s,{}):(qd[s]||{}).prototype)for(r in t){if(o=t[r],i=e.dontCallGetSet?(a=yE(n,r))&&a.value:n[r],!xE(c?r:s+(u?".":"#")+r,e.forced)&&i!==void 0){if(typeof o==typeof i)continue;TE(o,i)}(e.sham||i&&i.sham)&&bE(o,"sham",!0),SE(n,r,o,e)}},IE=Oe,wE=ie,EE=it,Ig=ye.f,wg=_e,CE=wE(function(){Ig(1)});IE({target:"Object",stat:!0,forced:!wg||CE,sham:!wg},{getOwnPropertyDescriptor:function(e,t){return Ig(EE(e),t)}});let Eg=!0,Cg=!0;function ms(e,t,n){let r=e.match(t);return r&&r.length>=n&&parseInt(r[n],10)}function Sa(e,t,n){if(!e.RTCPeerConnection)return;let r=e.RTCPeerConnection.prototype,i=r.addEventListener;r.addEventListener=function(a,s){if(a!==t)return i.apply(this,arguments);let c=u=>{let d=n(u);d&&(s.handleEvent?s.handleEvent(d):s(d))};return this._eventMap=this._eventMap||{},this._eventMap[t]||(this._eventMap[t]=new Map),this._eventMap[t].set(s,c),i.apply(this,[a,c])};let o=r.removeEventListener;r.removeEventListener=function(a,s){if(a!==t||!this._eventMap||!this._eventMap[t])return o.apply(this,arguments);if(!this._eventMap[t].has(s))return o.apply(this,arguments);let c=this._eventMap[t].get(s);return this._eventMap[t].delete(s),this._eventMap[t].size===0&&delete this._eventMap[t],Object.keys(this._eventMap).length===0&&delete this._eventMap,o.apply(this,[a,c])},Object.defineProperty(r,"on"+t,{get(){return this["_on"+t]},set(a){this["_on"+t]&&(this.removeEventListener(t,this["_on"+t]),delete this["_on"+t]),a&&this.addEventListener(t,this["_on"+t]=a)},enumerable:!0,configurable:!0})}function RE(e){return typeof e!="boolean"?new Error("Argument type: "+typeof e+". Please use a boolean."):(Eg=e,e?"adapter.js logging disabled":"adapter.js logging enabled")}function AE(e){return typeof e!="boolean"?new Error("Argument type: "+typeof e+". Please use a boolean."):(Cg=!e,"adapter.js deprecation warnings "+(e?"disabled":"enabled"))}function Kd(){if(typeof window=="object"){if(Eg)return;typeof console!="undefined"&&typeof console.log=="function"&&console.log.apply(console,arguments)}}function ou(e,t){Cg&&console.warn(e+" is deprecated, please use "+t+" instead.")}function Rg(e){return Object.prototype.toString.call(e)==="[object Object]"}function Ag(e){return Rg(e)?Object.keys(e).reduce(function(t,n){let r=Rg(e[n]),i=r?Ag(e[n]):e[n],o=r&&!Object.keys(i).length;return i===void 0||o?t:Object.assign(t,{[n]:i})},{}):e}function Qd(e,t,n){t&&!n.has(t.id)&&(n.set(t.id,t),Object.keys(t).forEach(r=>{r.endsWith("Id")?Qd(e,e.get(t[r]),n):r.endsWith("Ids")&&t[r].forEach(i=>{Qd(e,e.get(i),n)})}))}function Pg(e,t,n){let r=n?"outbound-rtp":"inbound-rtp",i=new Map;if(t===null)return i;let o=[];return e.forEach(a=>{a.type==="track"&&a.trackIdentifier===t.id&&o.push(a)}),o.forEach(a=>{e.forEach(s=>{s.type===r&&s.trackId===a.id&&Qd(e,s,i)})}),i}let Dg=Kd;function Lg(e,t){let n=e&&e.navigator;if(!n.mediaDevices)return;let r=function(a){if(typeof a!="object"||a.mandatory||a.optional)return a;let s={};return Object.keys(a).forEach(c=>{if(c==="require"||c==="advanced"||c==="mediaSource")return;let u=typeof a[c]=="object"?a[c]:{ideal:a[c]};u.exact!==void 0&&typeof u.exact=="number"&&(u.min=u.max=u.exact);let d=function(p,h){return p?p+h.charAt(0).toUpperCase()+h.slice(1):h==="deviceId"?"sourceId":h};if(u.ideal!==void 0){s.optional=s.optional||[];let p={};typeof u.ideal=="number"?(p[d("min",c)]=u.ideal,s.optional.push(p),p={},p[d("max",c)]=u.ideal,s.optional.push(p)):(p[d("",c)]=u.ideal,s.optional.push(p))}u.exact!==void 0&&typeof u.exact!="number"?(s.mandatory=s.mandatory||{},s.mandatory[d("",c)]=u.exact):["min","max"].forEach(p=>{u[p]!==void 0&&(s.mandatory=s.mandatory||{},s.mandatory[d(p,c)]=u[p])})}),a.advanced&&(s.optional=(s.optional||[]).concat(a.advanced)),s},i=function(a,s){if(t.version>=61)return s(a);if((a=JSON.parse(JSON.stringify(a)))&&typeof a.audio=="object"){let c=function(u,d,p){d in u&&!(p in u)&&(u[p]=u[d],delete u[d])};c((a=JSON.parse(JSON.stringify(a))).audio,"autoGainControl","googAutoGainControl"),c(a.audio,"noiseSuppression","googNoiseSuppression"),a.audio=r(a.audio)}if(a&&typeof a.video=="object"){let c=a.video.facingMode;c=c&&(typeof c=="object"?c:{ideal:c});let u=t.version<66;if(c&&(c.exact==="user"||c.exact==="environment"||c.ideal==="user"||c.ideal==="environment")&&(!n.mediaDevices.getSupportedConstraints||!n.mediaDevices.getSupportedConstraints().facingMode||u)){let d;if(delete a.video.facingMode,c.exact==="environment"||c.ideal==="environment"?d=["back","rear"]:c.exact!=="user"&&c.ideal!=="user"||(d=["front"]),d)return n.mediaDevices.enumerateDevices().then(p=>{let h=(p=p.filter(f=>f.kind==="videoinput")).find(f=>d.some(_=>f.label.toLowerCase().includes(_)));return!h&&p.length&&d.includes("back")&&(h=p[p.length-1]),h&&(a.video.deviceId=c.exact?{exact:h.deviceId}:{ideal:h.deviceId}),a.video=r(a.video),Dg("chrome: "+JSON.stringify(a)),s(a)})}a.video=r(a.video)}return Dg("chrome: "+JSON.stringify(a)),s(a)},o=function(a){return t.version>=64?a:{name:{PermissionDeniedError:"NotAllowedError",PermissionDismissedError:"NotAllowedError",InvalidStateError:"NotAllowedError",DevicesNotFoundError:"NotFoundError",ConstraintNotSatisfiedError:"OverconstrainedError",TrackStartError:"NotReadableError",MediaDeviceFailedDueToShutdown:"NotAllowedError",MediaDeviceKillSwitchOn:"NotAllowedError",TabCaptureError:"AbortError",ScreenCaptureError:"AbortError",DeviceCaptureError:"AbortError"}[a.name]||a.name,message:a.message,constraint:a.constraint||a.constraintName,toString(){return this.name+(this.message&&": ")+this.message}}};if(n.getUserMedia=function(a,s,c){i(a,u=>{n.webkitGetUserMedia(u,s,d=>{c&&c(o(d))})})}.bind(n),n.mediaDevices.getUserMedia){let a=n.mediaDevices.getUserMedia.bind(n.mediaDevices);n.mediaDevices.getUserMedia=function(s){return i(s,c=>a(c).then(u=>{if(c.audio&&!u.getAudioTracks().length||c.video&&!u.getVideoTracks().length)throw u.getTracks().forEach(d=>{d.stop()}),new DOMException("","NotFoundError");return u},u=>Promise.reject(o(u))))}}}function Og(e){e.MediaStream=e.MediaStream||e.webkitMediaStream}function Mg(e){if(typeof e=="object"&&e.RTCPeerConnection&&!("ontrack"in e.RTCPeerConnection.prototype)){Object.defineProperty(e.RTCPeerConnection.prototype,"ontrack",{get(){return this._ontrack},set(n){this._ontrack&&this.removeEventListener("track",this._ontrack),this.addEventListener("track",this._ontrack=n)},enumerable:!0,configurable:!0});let t=e.RTCPeerConnection.prototype.setRemoteDescription;e.RTCPeerConnection.prototype.setRemoteDescription=function(){return this._ontrackpoly||(this._ontrackpoly=n=>{n.stream.addEventListener("addtrack",r=>{let i;i=e.RTCPeerConnection.prototype.getReceivers?this.getReceivers().find(a=>a.track&&a.track.id===r.track.id):{track:r.track};let o=new Event("track");o.track=r.track,o.receiver=i,o.transceiver={receiver:i},o.streams=[n.stream],this.dispatchEvent(o)}),n.stream.getTracks().forEach(r=>{let i;i=e.RTCPeerConnection.prototype.getReceivers?this.getReceivers().find(a=>a.track&&a.track.id===r.id):{track:r};let o=new Event("track");o.track=r,o.receiver=i,o.transceiver={receiver:i},o.streams=[n.stream],this.dispatchEvent(o)})},this.addEventListener("addstream",this._ontrackpoly)),t.apply(this,arguments)}}else Sa(e,"track",t=>(t.transceiver||Object.defineProperty(t,"transceiver",{value:{receiver:t.receiver}}),t))}function Ng(e){if(typeof e=="object"&&e.RTCPeerConnection&&!("getSenders"in e.RTCPeerConnection.prototype)&&"createDTMFSender"in e.RTCPeerConnection.prototype){let t=function(i,o){return{track:o,get dtmf(){return this._dtmf===void 0&&(o.kind==="audio"?this._dtmf=i.createDTMFSender(o):this._dtmf=null),this._dtmf},_pc:i}};if(!e.RTCPeerConnection.prototype.getSenders){e.RTCPeerConnection.prototype.getSenders=function(){return this._senders=this._senders||[],this._senders.slice()};let i=e.RTCPeerConnection.prototype.addTrack;e.RTCPeerConnection.prototype.addTrack=function(a,s){let c=i.apply(this,arguments);return c||(c=t(this,a),this._senders.push(c)),c};let o=e.RTCPeerConnection.prototype.removeTrack;e.RTCPeerConnection.prototype.removeTrack=function(a){o.apply(this,arguments);let s=this._senders.indexOf(a);s!==-1&&this._senders.splice(s,1)}}let n=e.RTCPeerConnection.prototype.addStream;e.RTCPeerConnection.prototype.addStream=function(i){this._senders=this._senders||[],n.apply(this,[i]),i.getTracks().forEach(o=>{this._senders.push(t(this,o))})};let r=e.RTCPeerConnection.prototype.removeStream;e.RTCPeerConnection.prototype.removeStream=function(i){this._senders=this._senders||[],r.apply(this,[i]),i.getTracks().forEach(o=>{let a=this._senders.find(s=>s.track===o);a&&this._senders.splice(this._senders.indexOf(a),1)})}}else if(typeof e=="object"&&e.RTCPeerConnection&&"getSenders"in e.RTCPeerConnection.prototype&&"createDTMFSender"in e.RTCPeerConnection.prototype&&e.RTCRtpSender&&!("dtmf"in e.RTCRtpSender.prototype)){let t=e.RTCPeerConnection.prototype.getSenders;e.RTCPeerConnection.prototype.getSenders=function(){let n=t.apply(this,[]);return n.forEach(r=>r._pc=this),n},Object.defineProperty(e.RTCRtpSender.prototype,"dtmf",{get(){return this._dtmf===void 0&&(this.track.kind==="audio"?this._dtmf=this._pc.createDTMFSender(this.track):this._dtmf=null),this._dtmf}})}}function Vg(e){if(!e.RTCPeerConnection)return;let t=e.RTCPeerConnection.prototype.getStats;e.RTCPeerConnection.prototype.getStats=function(){let[n,r,i]=arguments;if(arguments.length>0&&typeof n=="function")return t.apply(this,arguments);if(t.length===0&&(arguments.length===0||typeof n!="function"))return t.apply(this,[]);let o=function(s){let c={};return s.result().forEach(u=>{let d={id:u.id,timestamp:u.timestamp,type:{localcandidate:"local-candidate",remotecandidate:"remote-candidate"}[u.type]||u.type};u.names().forEach(p=>{d[p]=u.stat(p)}),c[d.id]=d}),c},a=function(s){return new Map(Object.keys(s).map(c=>[c,s[c]]))};if(arguments.length>=2){let s=function(c){r(a(o(c)))};return t.apply(this,[s,n])}return new Promise((s,c)=>{t.apply(this,[function(u){s(a(o(u)))},c])}).then(r,i)}}function Ug(e){if(!(typeof e=="object"&&e.RTCPeerConnection&&e.RTCRtpSender&&e.RTCRtpReceiver))return;if(!("getStats"in e.RTCRtpSender.prototype)){let n=e.RTCPeerConnection.prototype.getSenders;n&&(e.RTCPeerConnection.prototype.getSenders=function(){let i=n.apply(this,[]);return i.forEach(o=>o._pc=this),i});let r=e.RTCPeerConnection.prototype.addTrack;r&&(e.RTCPeerConnection.prototype.addTrack=function(){let i=r.apply(this,arguments);return i._pc=this,i}),e.RTCRtpSender.prototype.getStats=function(){let i=this;return this._pc.getStats().then(o=>Pg(o,i.track,!0))}}if(!("getStats"in e.RTCRtpReceiver.prototype)){let n=e.RTCPeerConnection.prototype.getReceivers;n&&(e.RTCPeerConnection.prototype.getReceivers=function(){let r=n.apply(this,[]);return r.forEach(i=>i._pc=this),r}),Sa(e,"track",r=>(r.receiver._pc=r.srcElement,r)),e.RTCRtpReceiver.prototype.getStats=function(){let r=this;return this._pc.getStats().then(i=>Pg(i,r.track,!1))}}if(!("getStats"in e.RTCRtpSender.prototype)||!("getStats"in e.RTCRtpReceiver.prototype))return;let t=e.RTCPeerConnection.prototype.getStats;e.RTCPeerConnection.prototype.getStats=function(){if(arguments.length>0&&arguments[0]instanceof e.MediaStreamTrack){let n=arguments[0],r,i,o;return this.getSenders().forEach(a=>{a.track===n&&(r?o=!0:r=a)}),this.getReceivers().forEach(a=>(a.track===n&&(i?o=!0:i=a),a.track===n)),o||r&&i?Promise.reject(new DOMException("There are more than one sender or receiver for the track.","InvalidAccessError")):r?r.getStats():i?i.getStats():Promise.reject(new DOMException("There is no sender or receiver for the track.","InvalidAccessError"))}return t.apply(this,arguments)}}function Bg(e){e.RTCPeerConnection.prototype.getLocalStreams=function(){return this._shimmedLocalStreams=this._shimmedLocalStreams||{},Object.keys(this._shimmedLocalStreams).map(o=>this._shimmedLocalStreams[o][0])};let t=e.RTCPeerConnection.prototype.addTrack;e.RTCPeerConnection.prototype.addTrack=function(o,a){if(!a)return t.apply(this,arguments);this._shimmedLocalStreams=this._shimmedLocalStreams||{};let s=t.apply(this,arguments);return this._shimmedLocalStreams[a.id]?this._shimmedLocalStreams[a.id].indexOf(s)===-1&&this._shimmedLocalStreams[a.id].push(s):this._shimmedLocalStreams[a.id]=[a,s],s};let n=e.RTCPeerConnection.prototype.addStream;e.RTCPeerConnection.prototype.addStream=function(o){this._shimmedLocalStreams=this._shimmedLocalStreams||{},o.getTracks().forEach(c=>{if(this.getSenders().find(u=>u.track===c))throw new DOMException("Track already exists.","InvalidAccessError")});let a=this.getSenders();n.apply(this,arguments);let s=this.getSenders().filter(c=>a.indexOf(c)===-1);this._shimmedLocalStreams[o.id]=[o].concat(s)};let r=e.RTCPeerConnection.prototype.removeStream;e.RTCPeerConnection.prototype.removeStream=function(o){return this._shimmedLocalStreams=this._shimmedLocalStreams||{},delete this._shimmedLocalStreams[o.id],r.apply(this,arguments)};let i=e.RTCPeerConnection.prototype.removeTrack;e.RTCPeerConnection.prototype.removeTrack=function(o){return this._shimmedLocalStreams=this._shimmedLocalStreams||{},o&&Object.keys(this._shimmedLocalStreams).forEach(a=>{let s=this._shimmedLocalStreams[a].indexOf(o);s!==-1&&this._shimmedLocalStreams[a].splice(s,1),this._shimmedLocalStreams[a].length===1&&delete this._shimmedLocalStreams[a]}),i.apply(this,arguments)}}function jg(e,t){if(!e.RTCPeerConnection)return;if(e.RTCPeerConnection.prototype.addTrack&&t.version>=65)return Bg(e);let n=e.RTCPeerConnection.prototype.getLocalStreams;e.RTCPeerConnection.prototype.getLocalStreams=function(){let u=n.apply(this);return this._reverseStreams=this._reverseStreams||{},u.map(d=>this._reverseStreams[d.id])};let r=e.RTCPeerConnection.prototype.addStream;e.RTCPeerConnection.prototype.addStream=function(u){if(this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{},u.getTracks().forEach(d=>{if(this.getSenders().find(p=>p.track===d))throw new DOMException("Track already exists.","InvalidAccessError")}),!this._reverseStreams[u.id]){let d=new e.MediaStream(u.getTracks());this._streams[u.id]=d,this._reverseStreams[d.id]=u,u=d}r.apply(this,[u])};let i=e.RTCPeerConnection.prototype.removeStream;function o(u,d){let p=d.sdp;return Object.keys(u._reverseStreams||[]).forEach(h=>{let f=u._reverseStreams[h],_=u._streams[f.id];p=p.replace(new RegExp(_.id,"g"),f.id)}),new RTCSessionDescription({type:d.type,sdp:p})}function a(u,d){let p=d.sdp;return Object.keys(u._reverseStreams||[]).forEach(h=>{let f=u._reverseStreams[h],_=u._streams[f.id];p=p.replace(new RegExp(f.id,"g"),_.id)}),new RTCSessionDescription({type:d.type,sdp:p})}e.RTCPeerConnection.prototype.removeStream=function(u){this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{},i.apply(this,[this._streams[u.id]||u]),delete this._reverseStreams[this._streams[u.id]?this._streams[u.id].id:u.id],delete this._streams[u.id]},e.RTCPeerConnection.prototype.addTrack=function(u,d){if(this.signalingState==="closed")throw new DOMException("The RTCPeerConnection's signalingState is 'closed'.","InvalidStateError");let p=[].slice.call(arguments,1);if(p.length!==1||!p[0].getTracks().find(_=>_===u))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(_=>_.track===u))throw new DOMException("Track already exists.","InvalidAccessError");this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{};let f=this._streams[d.id];if(f)f.addTrack(u),Promise.resolve().then(()=>{this.dispatchEvent(new Event("negotiationneeded"))});else{let _=new e.MediaStream([u]);this._streams[d.id]=_,this._reverseStreams[_.id]=d,this.addStream(_)}return this.getSenders().find(_=>_.track===u)},["createOffer","createAnswer"].forEach(function(u){let d=e.RTCPeerConnection.prototype[u],p={[u](){let h=arguments;return arguments.length&&typeof arguments[0]=="function"?d.apply(this,[f=>{let _=o(this,f);h[0].apply(null,[_])},f=>{h[1]&&h[1].apply(null,f)},arguments[2]]):d.apply(this,arguments).then(f=>o(this,f))}};e.RTCPeerConnection.prototype[u]=p[u]});let s=e.RTCPeerConnection.prototype.setLocalDescription;e.RTCPeerConnection.prototype.setLocalDescription=function(){return arguments.length&&arguments[0].type?(arguments[0]=a(this,arguments[0]),s.apply(this,arguments)):s.apply(this,arguments)};let c=Object.getOwnPropertyDescriptor(e.RTCPeerConnection.prototype,"localDescription");Object.defineProperty(e.RTCPeerConnection.prototype,"localDescription",{get(){let u=c.get.apply(this);return u.type===""?u:o(this,u)}}),e.RTCPeerConnection.prototype.removeTrack=function(u){if(this.signalingState==="closed")throw new DOMException("The RTCPeerConnection's signalingState is 'closed'.","InvalidStateError");if(!u._pc)throw new DOMException("Argument 1 of RTCPeerConnection.removeTrack does not implement interface RTCRtpSender.","TypeError");if(u._pc!==this)throw new DOMException("Sender was not created by this connection.","InvalidAccessError");let d;this._streams=this._streams||{},Object.keys(this._streams).forEach(p=>{this._streams[p].getTracks().find(h=>u.track===h)&&(d=this._streams[p])}),d&&(d.getTracks().length===1?this.removeStream(this._reverseStreams[d.id]):d.removeTrack(u.track),this.dispatchEvent(new Event("negotiationneeded")))}}function Xd(e,t){!e.RTCPeerConnection&&e.webkitRTCPeerConnection&&(e.RTCPeerConnection=e.webkitRTCPeerConnection),e.RTCPeerConnection&&t.version<53&&["setLocalDescription","setRemoteDescription","addIceCandidate"].forEach(function(n){let r=e.RTCPeerConnection.prototype[n],i={[n](){return arguments[0]=new(n==="addIceCandidate"?e.RTCIceCandidate:e.RTCSessionDescription)(arguments[0]),r.apply(this,arguments)}};e.RTCPeerConnection.prototype[n]=i[n]})}function Fg(e,t){Sa(e,"negotiationneeded",n=>{let r=n.target;if(!(t.version<72||r.getConfiguration&&r.getConfiguration().sdpSemantics==="plan-b")||r.signalingState==="stable")return n})}var Gg=Object.freeze({__proto__:null,shimMediaStream:Og,shimOnTrack:Mg,shimGetSendersWithDtmf:Ng,shimGetStats:Vg,shimSenderReceiverGetStats:Ug,shimAddTrackRemoveTrackWithNative:Bg,shimAddTrackRemoveTrack:jg,shimPeerConnection:Xd,fixNegotiationNeeded:Fg,shimGetUserMedia:Lg,shimGetDisplayMedia:function(e,t){e.navigator.mediaDevices&&"getDisplayMedia"in e.navigator.mediaDevices||e.navigator.mediaDevices&&(typeof t=="function"?e.navigator.mediaDevices.getDisplayMedia=function(n){return t(n).then(r=>{let i=n.video&&n.video.width,o=n.video&&n.video.height,a=n.video&&n.video.frameRate;return n.video={mandatory:{chromeMediaSource:"desktop",chromeMediaSourceId:r,maxFrameRate:a||3}},i&&(n.video.mandatory.maxWidth=i),o&&(n.video.mandatory.maxHeight=o),e.navigator.mediaDevices.getUserMedia(n)})}:console.error("shimGetDisplayMedia: getSourceId argument is not a function"))}}),Yd={exports:{}};(function(e){var t={generateIdentifier:function(){return Math.random().toString(36).substr(2,10)}};t.localCName=t.generateIdentifier(),t.splitLines=function(n){return n.trim().split(`
5
+ `).map(function(r){return r.trim()})},t.splitSections=function(n){return n.split(`
6
+ m=`).map(function(r,i){return(i>0?"m="+r:r).trim()+`\r
7
+ `})},t.getDescription=function(n){var r=t.splitSections(n);return r&&r[0]},t.getMediaSections=function(n){var r=t.splitSections(n);return r.shift(),r},t.matchPrefix=function(n,r){return t.splitLines(n).filter(function(i){return i.indexOf(r)===0})},t.parseCandidate=function(n){for(var r,i={foundation:(r=n.indexOf("a=candidate:")===0?n.substring(12).split(" "):n.substring(10).split(" "))[0],component:parseInt(r[1],10),protocol:r[2].toLowerCase(),priority:parseInt(r[3],10),ip:r[4],address:r[4],port:parseInt(r[5],10),type:r[7]},o=8;o<r.length;o+=2)switch(r[o]){case"raddr":i.relatedAddress=r[o+1];break;case"rport":i.relatedPort=parseInt(r[o+1],10);break;case"tcptype":i.tcpType=r[o+1];break;case"ufrag":i.ufrag=r[o+1],i.usernameFragment=r[o+1];break;default:i[r[o]]=r[o+1]}return i},t.writeCandidate=function(n){var r=[];r.push(n.foundation),r.push(n.component),r.push(n.protocol.toUpperCase()),r.push(n.priority),r.push(n.address||n.ip),r.push(n.port);var i=n.type;return r.push("typ"),r.push(i),i!=="host"&&n.relatedAddress&&n.relatedPort&&(r.push("raddr"),r.push(n.relatedAddress),r.push("rport"),r.push(n.relatedPort)),n.tcpType&&n.protocol.toLowerCase()==="tcp"&&(r.push("tcptype"),r.push(n.tcpType)),(n.usernameFragment||n.ufrag)&&(r.push("ufrag"),r.push(n.usernameFragment||n.ufrag)),"candidate:"+r.join(" ")},t.parseIceOptions=function(n){return n.substr(14).split(" ")},t.parseRtpMap=function(n){var r=n.substr(9).split(" "),i={payloadType:parseInt(r.shift(),10)};return r=r[0].split("/"),i.name=r[0],i.clockRate=parseInt(r[1],10),i.channels=r.length===3?parseInt(r[2],10):1,i.numChannels=i.channels,i},t.writeRtpMap=function(n){var r=n.payloadType;n.preferredPayloadType!==void 0&&(r=n.preferredPayloadType);var i=n.channels||n.numChannels||1;return"a=rtpmap:"+r+" "+n.name+"/"+n.clockRate+(i!==1?"/"+i:"")+`\r
8
+ `},t.parseExtmap=function(n){var r=n.substr(9).split(" ");return{id:parseInt(r[0],10),direction:r[0].indexOf("/")>0?r[0].split("/")[1]:"sendrecv",uri:r[1]}},t.writeExtmap=function(n){return"a=extmap:"+(n.id||n.preferredId)+(n.direction&&n.direction!=="sendrecv"?"/"+n.direction:"")+" "+n.uri+`\r
9
+ `},t.parseFmtp=function(n){for(var r,i={},o=n.substr(n.indexOf(" ")+1).split(";"),a=0;a<o.length;a++)i[(r=o[a].trim().split("="))[0].trim()]=r[1];return i},t.writeFmtp=function(n){var r="",i=n.payloadType;if(n.preferredPayloadType!==void 0&&(i=n.preferredPayloadType),n.parameters&&Object.keys(n.parameters).length){var o=[];Object.keys(n.parameters).forEach(function(a){n.parameters[a]?o.push(a+"="+n.parameters[a]):o.push(a)}),r+="a=fmtp:"+i+" "+o.join(";")+`\r
10
+ `}return r},t.parseRtcpFb=function(n){var r=n.substr(n.indexOf(" ")+1).split(" ");return{type:r.shift(),parameter:r.join(" ")}},t.writeRtcpFb=function(n){var r="",i=n.payloadType;return n.preferredPayloadType!==void 0&&(i=n.preferredPayloadType),n.rtcpFeedback&&n.rtcpFeedback.length&&n.rtcpFeedback.forEach(function(o){r+="a=rtcp-fb:"+i+" "+o.type+(o.parameter&&o.parameter.length?" "+o.parameter:"")+`\r
11
+ `}),r},t.parseSsrcMedia=function(n){var r=n.indexOf(" "),i={ssrc:parseInt(n.substr(7,r-7),10)},o=n.indexOf(":",r);return o>-1?(i.attribute=n.substr(r+1,o-r-1),i.value=n.substr(o+1)):i.attribute=n.substr(r+1),i},t.parseSsrcGroup=function(n){var r=n.substr(13).split(" ");return{semantics:r.shift(),ssrcs:r.map(function(i){return parseInt(i,10)})}},t.getMid=function(n){var r=t.matchPrefix(n,"a=mid:")[0];if(r)return r.substr(6)},t.parseFingerprint=function(n){var r=n.substr(14).split(" ");return{algorithm:r[0].toLowerCase(),value:r[1]}},t.getDtlsParameters=function(n,r){return{role:"auto",fingerprints:t.matchPrefix(n+r,"a=fingerprint:").map(t.parseFingerprint)}},t.writeDtlsParameters=function(n,r){var i="a=setup:"+r+`\r
12
+ `;return n.fingerprints.forEach(function(o){i+="a=fingerprint:"+o.algorithm+" "+o.value+`\r
13
+ `}),i},t.parseCryptoLine=function(n){var r=n.substr(9).split(" ");return{tag:parseInt(r[0],10),cryptoSuite:r[1],keyParams:r[2],sessionParams:r.slice(3)}},t.writeCryptoLine=function(n){return"a=crypto:"+n.tag+" "+n.cryptoSuite+" "+(typeof n.keyParams=="object"?t.writeCryptoKeyParams(n.keyParams):n.keyParams)+(n.sessionParams?" "+n.sessionParams.join(" "):"")+`\r
14
+ `},t.parseCryptoKeyParams=function(n){if(n.indexOf("inline:")!==0)return null;var r=n.substr(7).split("|");return{keyMethod:"inline",keySalt:r[0],lifeTime:r[1],mkiValue:r[2]?r[2].split(":")[0]:void 0,mkiLength:r[2]?r[2].split(":")[1]:void 0}},t.writeCryptoKeyParams=function(n){return n.keyMethod+":"+n.keySalt+(n.lifeTime?"|"+n.lifeTime:"")+(n.mkiValue&&n.mkiLength?"|"+n.mkiValue+":"+n.mkiLength:"")},t.getCryptoParameters=function(n,r){return t.matchPrefix(n+r,"a=crypto:").map(t.parseCryptoLine)},t.getIceParameters=function(n,r){var i=t.matchPrefix(n+r,"a=ice-ufrag:")[0],o=t.matchPrefix(n+r,"a=ice-pwd:")[0];return i&&o?{usernameFragment:i.substr(12),password:o.substr(10)}:null},t.writeIceParameters=function(n){return"a=ice-ufrag:"+n.usernameFragment+`\r
15
+ a=ice-pwd:`+n.password+`\r
16
+ `},t.parseRtpParameters=function(n){for(var r={codecs:[],headerExtensions:[],fecMechanisms:[],rtcp:[]},i=t.splitLines(n)[0].split(" "),o=3;o<i.length;o++){var a=i[o],s=t.matchPrefix(n,"a=rtpmap:"+a+" ")[0];if(s){var c=t.parseRtpMap(s),u=t.matchPrefix(n,"a=fmtp:"+a+" ");switch(c.parameters=u.length?t.parseFmtp(u[0]):{},c.rtcpFeedback=t.matchPrefix(n,"a=rtcp-fb:"+a+" ").map(t.parseRtcpFb),r.codecs.push(c),c.name.toUpperCase()){case"RED":case"ULPFEC":r.fecMechanisms.push(c.name.toUpperCase())}}}return t.matchPrefix(n,"a=extmap:").forEach(function(d){r.headerExtensions.push(t.parseExtmap(d))}),r},t.writeRtpDescription=function(n,r){var i="";i+="m="+n+" ",i+=r.codecs.length>0?"9":"0",i+=" UDP/TLS/RTP/SAVPF ",i+=r.codecs.map(function(a){return a.preferredPayloadType!==void 0?a.preferredPayloadType:a.payloadType}).join(" ")+`\r
17
+ `,i+=`c=IN IP4 0.0.0.0\r
18
+ `,i+=`a=rtcp:9 IN IP4 0.0.0.0\r
19
+ `,r.codecs.forEach(function(a){i+=t.writeRtpMap(a),i+=t.writeFmtp(a),i+=t.writeRtcpFb(a)});var o=0;return r.codecs.forEach(function(a){a.maxptime>o&&(o=a.maxptime)}),o>0&&(i+="a=maxptime:"+o+`\r
20
+ `),i+=`a=rtcp-mux\r
21
+ `,r.headerExtensions&&r.headerExtensions.forEach(function(a){i+=t.writeExtmap(a)}),i},t.parseRtpEncodingParameters=function(n){var r,i=[],o=t.parseRtpParameters(n),a=o.fecMechanisms.indexOf("RED")!==-1,s=o.fecMechanisms.indexOf("ULPFEC")!==-1,c=t.matchPrefix(n,"a=ssrc:").map(function(h){return t.parseSsrcMedia(h)}).filter(function(h){return h.attribute==="cname"}),u=c.length>0&&c[0].ssrc,d=t.matchPrefix(n,"a=ssrc-group:FID").map(function(h){return h.substr(17).split(" ").map(function(f){return parseInt(f,10)})});d.length>0&&d[0].length>1&&d[0][0]===u&&(r=d[0][1]),o.codecs.forEach(function(h){if(h.name.toUpperCase()==="RTX"&&h.parameters.apt){var f={ssrc:u,codecPayloadType:parseInt(h.parameters.apt,10)};u&&r&&(f.rtx={ssrc:r}),i.push(f),a&&((f=JSON.parse(JSON.stringify(f))).fec={ssrc:u,mechanism:s?"red+ulpfec":"red"},i.push(f))}}),i.length===0&&u&&i.push({ssrc:u});var p=t.matchPrefix(n,"b=");return p.length&&(p=p[0].indexOf("b=TIAS:")===0?parseInt(p[0].substr(7),10):p[0].indexOf("b=AS:")===0?1e3*parseInt(p[0].substr(5),10)*.95-16e3:void 0,i.forEach(function(h){h.maxBitrate=p})),i},t.parseRtcpParameters=function(n){var r={},i=t.matchPrefix(n,"a=ssrc:").map(function(s){return t.parseSsrcMedia(s)}).filter(function(s){return s.attribute==="cname"})[0];i&&(r.cname=i.value,r.ssrc=i.ssrc);var o=t.matchPrefix(n,"a=rtcp-rsize");r.reducedSize=o.length>0,r.compound=o.length===0;var a=t.matchPrefix(n,"a=rtcp-mux");return r.mux=a.length>0,r},t.parseMsid=function(n){var r,i=t.matchPrefix(n,"a=msid:");if(i.length===1)return{stream:(r=i[0].substr(7).split(" "))[0],track:r[1]};var o=t.matchPrefix(n,"a=ssrc:").map(function(a){return t.parseSsrcMedia(a)}).filter(function(a){return a.attribute==="msid"});return o.length>0?{stream:(r=o[0].value.split(" "))[0],track:r[1]}:void 0},t.parseSctpDescription=function(n){var r,i=t.parseMLine(n),o=t.matchPrefix(n,"a=max-message-size:");o.length>0&&(r=parseInt(o[0].substr(19),10)),isNaN(r)&&(r=65536);var a=t.matchPrefix(n,"a=sctp-port:");if(a.length>0)return{port:parseInt(a[0].substr(12),10),protocol:i.fmt,maxMessageSize:r};if(t.matchPrefix(n,"a=sctpmap:").length>0){var s=t.matchPrefix(n,"a=sctpmap:")[0].substr(10).split(" ");return{port:parseInt(s[0],10),protocol:s[1],maxMessageSize:r}}},t.writeSctpDescription=function(n,r){var i=[];return i=n.protocol!=="DTLS/SCTP"?["m="+n.kind+" 9 "+n.protocol+" "+r.protocol+`\r
22
+ `,`c=IN IP4 0.0.0.0\r
23
+ `,"a=sctp-port:"+r.port+`\r
24
+ `]:["m="+n.kind+" 9 "+n.protocol+" "+r.port+`\r
25
+ `,`c=IN IP4 0.0.0.0\r
26
+ `,"a=sctpmap:"+r.port+" "+r.protocol+` 65535\r
27
+ `],r.maxMessageSize!==void 0&&i.push("a=max-message-size:"+r.maxMessageSize+`\r
28
+ `),i.join("")},t.generateSessionId=function(){return Math.random().toString().substr(2,21)},t.writeSessionBoilerplate=function(n,r,i){var o=r!==void 0?r:2;return`v=0\r
29
+ o=`+(i||"thisisadapterortc")+" "+(n||t.generateSessionId())+" "+o+` IN IP4 127.0.0.1\r
30
+ s=-\r
31
+ t=0 0\r
32
+ `},t.writeMediaSection=function(n,r,i,o){var a=t.writeRtpDescription(n.kind,r);if(a+=t.writeIceParameters(n.iceGatherer.getLocalParameters()),a+=t.writeDtlsParameters(n.dtlsTransport.getLocalParameters(),i==="offer"?"actpass":"active"),a+="a=mid:"+n.mid+`\r
33
+ `,n.direction?a+="a="+n.direction+`\r
34
+ `:n.rtpSender&&n.rtpReceiver?a+=`a=sendrecv\r
35
+ `:n.rtpSender?a+=`a=sendonly\r
36
+ `:n.rtpReceiver?a+=`a=recvonly\r
37
+ `:a+=`a=inactive\r
38
+ `,n.rtpSender){var s="msid:"+o.id+" "+n.rtpSender.track.id+`\r
39
+ `;a+="a="+s,a+="a=ssrc:"+n.sendEncodingParameters[0].ssrc+" "+s,n.sendEncodingParameters[0].rtx&&(a+="a=ssrc:"+n.sendEncodingParameters[0].rtx.ssrc+" "+s,a+="a=ssrc-group:FID "+n.sendEncodingParameters[0].ssrc+" "+n.sendEncodingParameters[0].rtx.ssrc+`\r
40
+ `)}return a+="a=ssrc:"+n.sendEncodingParameters[0].ssrc+" cname:"+t.localCName+`\r
41
+ `,n.rtpSender&&n.sendEncodingParameters[0].rtx&&(a+="a=ssrc:"+n.sendEncodingParameters[0].rtx.ssrc+" cname:"+t.localCName+`\r
42
+ `),a},t.getDirection=function(n,r){for(var i=t.splitLines(n),o=0;o<i.length;o++)switch(i[o]){case"a=sendrecv":case"a=sendonly":case"a=recvonly":case"a=inactive":return i[o].substr(2)}return r?t.getDirection(r):"sendrecv"},t.getKind=function(n){return t.splitLines(n)[0].split(" ")[0].substr(2)},t.isRejected=function(n){return n.split(" ",2)[1]==="0"},t.parseMLine=function(n){var r=t.splitLines(n)[0].substr(2).split(" ");return{kind:r[0],port:parseInt(r[1],10),protocol:r[2],fmt:r.slice(3).join(" ")}},t.parseOLine=function(n){var r=t.matchPrefix(n,"o=")[0].substr(2).split(" ");return{username:r[0],sessionId:r[1],sessionVersion:parseInt(r[2],10),netType:r[3],addressType:r[4],address:r[5]}},t.isValidSDP=function(n){if(typeof n!="string"||n.length===0)return!1;for(var r=t.splitLines(n),i=0;i<r.length;i++)if(r[i].length<2||r[i].charAt(1)!=="=")return!1;return!0},e.exports=t})(Yd);var su=Yd.exports,je=Yd.exports;function Hg(e,t,n,r,i){var o=je.writeRtpDescription(e.kind,t);if(o+=je.writeIceParameters(e.iceGatherer.getLocalParameters()),o+=je.writeDtlsParameters(e.dtlsTransport.getLocalParameters(),n==="offer"?"actpass":i||"active"),o+="a=mid:"+e.mid+`\r
43
+ `,e.rtpSender&&e.rtpReceiver?o+=`a=sendrecv\r
44
+ `:e.rtpSender?o+=`a=sendonly\r
45
+ `:e.rtpReceiver?o+=`a=recvonly\r
46
+ `:o+=`a=inactive\r
47
+ `,e.rtpSender){var a=e.rtpSender._initialTrackId||e.rtpSender.track.id;e.rtpSender._initialTrackId=a;var s="msid:"+(r?r.id:"-")+" "+a+`\r
48
+ `;o+="a="+s,o+="a=ssrc:"+e.sendEncodingParameters[0].ssrc+" "+s,e.sendEncodingParameters[0].rtx&&(o+="a=ssrc:"+e.sendEncodingParameters[0].rtx.ssrc+" "+s,o+="a=ssrc-group:FID "+e.sendEncodingParameters[0].ssrc+" "+e.sendEncodingParameters[0].rtx.ssrc+`\r
49
+ `)}return o+="a=ssrc:"+e.sendEncodingParameters[0].ssrc+" cname:"+je.localCName+`\r
50
+ `,e.rtpSender&&e.sendEncodingParameters[0].rtx&&(o+="a=ssrc:"+e.sendEncodingParameters[0].rtx.ssrc+" cname:"+je.localCName+`\r
51
+ `),o}function cu(e,t){var n={codecs:[],headerExtensions:[],fecMechanisms:[]},r=function(o,a){o=parseInt(o,10);for(var s=0;s<a.length;s++)if(a[s].payloadType===o||a[s].preferredPayloadType===o)return a[s]},i=function(o,a,s,c){var u=r(o.parameters.apt,s),d=r(a.parameters.apt,c);return u&&d&&u.name.toLowerCase()===d.name.toLowerCase()};return e.codecs.forEach(function(o){for(var a=0;a<t.codecs.length;a++){var s=t.codecs[a];if(o.name.toLowerCase()===s.name.toLowerCase()&&o.clockRate===s.clockRate){if(o.name.toLowerCase()==="rtx"&&o.parameters&&s.parameters.apt&&!i(o,s,e.codecs,t.codecs))continue;(s=JSON.parse(JSON.stringify(s))).numChannels=Math.min(o.numChannels,s.numChannels),n.codecs.push(s),s.rtcpFeedback=s.rtcpFeedback.filter(function(c){for(var u=0;u<o.rtcpFeedback.length;u++)if(o.rtcpFeedback[u].type===c.type&&o.rtcpFeedback[u].parameter===c.parameter)return!0;return!1});break}}}),e.headerExtensions.forEach(function(o){for(var a=0;a<t.headerExtensions.length;a++){var s=t.headerExtensions[a];if(o.uri===s.uri){n.headerExtensions.push(s);break}}}),n}function zg(e,t,n){return{offer:{setLocalDescription:["stable","have-local-offer"],setRemoteDescription:["stable","have-remote-offer"]},answer:{setLocalDescription:["have-remote-offer","have-local-pranswer"],setRemoteDescription:["have-local-offer","have-remote-pranswer"]}}[t][e].indexOf(n)!==-1}function $d(e,t){var n=e.getRemoteCandidates().find(function(r){return t.foundation===r.foundation&&t.ip===r.ip&&t.port===r.port&&t.priority===r.priority&&t.protocol===r.protocol&&t.type===r.type});return n||e.addRemoteCandidate(t),!n}function Yt(e,t){var n=new Error(t);return n.name=e,n.code={NotSupportedError:9,InvalidStateError:11,InvalidAccessError:15,TypeError:void 0,OperationError:void 0}[e],n}var PE=function(e,t){function n(a,s){s.addTrack(a),s.dispatchEvent(new e.MediaStreamTrackEvent("addtrack",{track:a}))}function r(a,s,c,u){var d=new Event("track");d.track=s,d.receiver=c,d.transceiver={receiver:c},d.streams=u,e.setTimeout(function(){a._dispatchEvent("track",d)})}var i=function(a){var s=this,c=document.createDocumentFragment();if(["addEventListener","removeEventListener","dispatchEvent"].forEach(function(d){s[d]=c[d].bind(c)}),this.canTrickleIceCandidates=null,this.needNegotiation=!1,this.localStreams=[],this.remoteStreams=[],this._localDescription=null,this._remoteDescription=null,this.signalingState="stable",this.iceConnectionState="new",this.connectionState="new",this.iceGatheringState="new",a=JSON.parse(JSON.stringify(a||{})),this.usingBundle=a.bundlePolicy==="max-bundle",a.rtcpMuxPolicy==="negotiate")throw Yt("NotSupportedError","rtcpMuxPolicy 'negotiate' is not supported");switch(a.rtcpMuxPolicy||(a.rtcpMuxPolicy="require"),a.iceTransportPolicy){case"all":case"relay":break;default:a.iceTransportPolicy="all"}switch(a.bundlePolicy){case"balanced":case"max-compat":case"max-bundle":break;default:a.bundlePolicy="balanced"}if(a.iceServers=function(d,p){var h=!1;return(d=JSON.parse(JSON.stringify(d))).filter(function(f){if(f&&(f.urls||f.url)){var _=f.urls||f.url;f.url&&!f.urls&&console.warn("RTCIceServer.url is deprecated! Use urls instead.");var y=typeof _=="string";return y&&(_=[_]),_=_.filter(function(S){return S.indexOf("turn:")!==0||S.indexOf("transport=udp")===-1||S.indexOf("turn:[")!==-1||h?S.indexOf("stun:")===0&&p>=14393&&S.indexOf("?transport=udp")===-1:(h=!0,!0)}),delete f.url,f.urls=y?_[0]:_,!!_.length}})}(a.iceServers||[],t),this._iceGatherers=[],a.iceCandidatePoolSize)for(var u=a.iceCandidatePoolSize;u>0;u--)this._iceGatherers.push(new e.RTCIceGatherer({iceServers:a.iceServers,gatherPolicy:a.iceTransportPolicy}));else a.iceCandidatePoolSize=0;this._config=a,this.transceivers=[],this._sdpSessionId=je.generateSessionId(),this._sdpSessionVersion=0,this._dtlsRole=void 0,this._isClosed=!1};Object.defineProperty(i.prototype,"localDescription",{configurable:!0,get:function(){return this._localDescription}}),Object.defineProperty(i.prototype,"remoteDescription",{configurable:!0,get:function(){return this._remoteDescription}}),i.prototype.onicecandidate=null,i.prototype.onaddstream=null,i.prototype.ontrack=null,i.prototype.onremovestream=null,i.prototype.onsignalingstatechange=null,i.prototype.oniceconnectionstatechange=null,i.prototype.onconnectionstatechange=null,i.prototype.onicegatheringstatechange=null,i.prototype.onnegotiationneeded=null,i.prototype.ondatachannel=null,i.prototype._dispatchEvent=function(a,s){this._isClosed||(this.dispatchEvent(s),typeof this["on"+a]=="function"&&this["on"+a](s))},i.prototype._emitGatheringStateChange=function(){var a=new Event("icegatheringstatechange");this._dispatchEvent("icegatheringstatechange",a)},i.prototype.getConfiguration=function(){return this._config},i.prototype.getLocalStreams=function(){return this.localStreams},i.prototype.getRemoteStreams=function(){return this.remoteStreams},i.prototype._createTransceiver=function(a,s){var c=this.transceivers.length>0,u={track:null,iceGatherer:null,iceTransport:null,dtlsTransport:null,localCapabilities:null,remoteCapabilities:null,rtpSender:null,rtpReceiver:null,kind:a,mid:null,sendEncodingParameters:null,recvEncodingParameters:null,stream:null,associatedRemoteMediaStreams:[],wantReceive:!0};if(this.usingBundle&&c)u.iceTransport=this.transceivers[0].iceTransport,u.dtlsTransport=this.transceivers[0].dtlsTransport;else{var d=this._createIceAndDtlsTransports();u.iceTransport=d.iceTransport,u.dtlsTransport=d.dtlsTransport}return s||this.transceivers.push(u),u},i.prototype.addTrack=function(a,s){if(this._isClosed)throw Yt("InvalidStateError","Attempted to call addTrack on a closed peerconnection.");var c;if(this.transceivers.find(function(d){return d.track===a}))throw Yt("InvalidAccessError","Track already exists.");for(var u=0;u<this.transceivers.length;u++)this.transceivers[u].track||this.transceivers[u].kind!==a.kind||(c=this.transceivers[u]);return c||(c=this._createTransceiver(a.kind)),this._maybeFireNegotiationNeeded(),this.localStreams.indexOf(s)===-1&&this.localStreams.push(s),c.track=a,c.stream=s,c.rtpSender=new e.RTCRtpSender(a,c.dtlsTransport),c.rtpSender},i.prototype.addStream=function(a){var s=this;if(t>=15025)a.getTracks().forEach(function(u){s.addTrack(u,a)});else{var c=a.clone();a.getTracks().forEach(function(u,d){var p=c.getTracks()[d];u.addEventListener("enabled",function(h){p.enabled=h.enabled})}),c.getTracks().forEach(function(u){s.addTrack(u,c)})}},i.prototype.removeTrack=function(a){if(this._isClosed)throw Yt("InvalidStateError","Attempted to call removeTrack on a closed peerconnection.");if(!(a instanceof e.RTCRtpSender))throw new TypeError("Argument 1 of RTCPeerConnection.removeTrack does not implement interface RTCRtpSender.");var s=this.transceivers.find(function(u){return u.rtpSender===a});if(!s)throw Yt("InvalidAccessError","Sender was not created by this connection.");var c=s.stream;s.rtpSender.stop(),s.rtpSender=null,s.track=null,s.stream=null,this.transceivers.map(function(u){return u.stream}).indexOf(c)===-1&&this.localStreams.indexOf(c)>-1&&this.localStreams.splice(this.localStreams.indexOf(c),1),this._maybeFireNegotiationNeeded()},i.prototype.removeStream=function(a){var s=this;a.getTracks().forEach(function(c){var u=s.getSenders().find(function(d){return d.track===c});u&&s.removeTrack(u)})},i.prototype.getSenders=function(){return this.transceivers.filter(function(a){return!!a.rtpSender}).map(function(a){return a.rtpSender})},i.prototype.getReceivers=function(){return this.transceivers.filter(function(a){return!!a.rtpReceiver}).map(function(a){return a.rtpReceiver})},i.prototype._createIceGatherer=function(a,s){var c=this;if(s&&a>0)return this.transceivers[0].iceGatherer;if(this._iceGatherers.length)return this._iceGatherers.shift();var u=new e.RTCIceGatherer({iceServers:this._config.iceServers,gatherPolicy:this._config.iceTransportPolicy});return Object.defineProperty(u,"state",{value:"new",writable:!0}),this.transceivers[a].bufferedCandidateEvents=[],this.transceivers[a].bufferCandidates=function(d){var p=!d.candidate||Object.keys(d.candidate).length===0;u.state=p?"completed":"gathering",c.transceivers[a].bufferedCandidateEvents!==null&&c.transceivers[a].bufferedCandidateEvents.push(d)},u.addEventListener("localcandidate",this.transceivers[a].bufferCandidates),u},i.prototype._gather=function(a,s){var c=this,u=this.transceivers[s].iceGatherer;if(!u.onlocalcandidate){var d=this.transceivers[s].bufferedCandidateEvents;this.transceivers[s].bufferedCandidateEvents=null,u.removeEventListener("localcandidate",this.transceivers[s].bufferCandidates),u.onlocalcandidate=function(p){if(!(c.usingBundle&&s>0)){var h=new Event("icecandidate");h.candidate={sdpMid:a,sdpMLineIndex:s};var f=p.candidate,_=!f||Object.keys(f).length===0;if(_)u.state!=="new"&&u.state!=="gathering"||(u.state="completed");else{u.state==="new"&&(u.state="gathering"),f.component=1,f.ufrag=u.getLocalParameters().usernameFragment;var y=je.writeCandidate(f);h.candidate=Object.assign(h.candidate,je.parseCandidate(y)),h.candidate.candidate=y,h.candidate.toJSON=function(){return{candidate:h.candidate.candidate,sdpMid:h.candidate.sdpMid,sdpMLineIndex:h.candidate.sdpMLineIndex,usernameFragment:h.candidate.usernameFragment}}}var S=je.getMediaSections(c._localDescription.sdp);S[h.candidate.sdpMLineIndex]+=_?`a=end-of-candidates\r
52
+ `:"a="+h.candidate.candidate+`\r
53
+ `,c._localDescription.sdp=je.getDescription(c._localDescription.sdp)+S.join("");var E=c.transceivers.every(function(R){return R.iceGatherer&&R.iceGatherer.state==="completed"});c.iceGatheringState!=="gathering"&&(c.iceGatheringState="gathering",c._emitGatheringStateChange()),_||c._dispatchEvent("icecandidate",h),E&&(c._dispatchEvent("icecandidate",new Event("icecandidate")),c.iceGatheringState="complete",c._emitGatheringStateChange())}},e.setTimeout(function(){d.forEach(function(p){u.onlocalcandidate(p)})},0)}},i.prototype._createIceAndDtlsTransports=function(){var a=this,s=new e.RTCIceTransport(null);s.onicestatechange=function(){a._updateIceConnectionState(),a._updateConnectionState()};var c=new e.RTCDtlsTransport(s);return c.ondtlsstatechange=function(){a._updateConnectionState()},c.onerror=function(){Object.defineProperty(c,"state",{value:"failed",writable:!0}),a._updateConnectionState()},{iceTransport:s,dtlsTransport:c}},i.prototype._disposeIceAndDtlsTransports=function(a){var s=this.transceivers[a].iceGatherer;s&&(delete s.onlocalcandidate,delete this.transceivers[a].iceGatherer);var c=this.transceivers[a].iceTransport;c&&(delete c.onicestatechange,delete this.transceivers[a].iceTransport);var u=this.transceivers[a].dtlsTransport;u&&(delete u.ondtlsstatechange,delete u.onerror,delete this.transceivers[a].dtlsTransport)},i.prototype._transceive=function(a,s,c){var u=cu(a.localCapabilities,a.remoteCapabilities);s&&a.rtpSender&&(u.encodings=a.sendEncodingParameters,u.rtcp={cname:je.localCName,compound:a.rtcpParameters.compound},a.recvEncodingParameters.length&&(u.rtcp.ssrc=a.recvEncodingParameters[0].ssrc),a.rtpSender.send(u)),c&&a.rtpReceiver&&u.codecs.length>0&&(a.kind==="video"&&a.recvEncodingParameters&&t<15019&&a.recvEncodingParameters.forEach(function(d){delete d.rtx}),a.recvEncodingParameters.length?u.encodings=a.recvEncodingParameters:u.encodings=[{}],u.rtcp={compound:a.rtcpParameters.compound},a.rtcpParameters.cname&&(u.rtcp.cname=a.rtcpParameters.cname),a.sendEncodingParameters.length&&(u.rtcp.ssrc=a.sendEncodingParameters[0].ssrc),a.rtpReceiver.receive(u))},i.prototype.setLocalDescription=function(a){var s,c,u=this;if(["offer","answer"].indexOf(a.type)===-1)return Promise.reject(Yt("TypeError",'Unsupported type "'+a.type+'"'));if(!zg("setLocalDescription",a.type,u.signalingState)||u._isClosed)return Promise.reject(Yt("InvalidStateError","Can not set local "+a.type+" in state "+u.signalingState));if(a.type==="offer")s=je.splitSections(a.sdp),c=s.shift(),s.forEach(function(p,h){var f=je.parseRtpParameters(p);u.transceivers[h].localCapabilities=f}),u.transceivers.forEach(function(p,h){u._gather(p.mid,h)});else if(a.type==="answer"){s=je.splitSections(u._remoteDescription.sdp),c=s.shift();var d=je.matchPrefix(c,"a=ice-lite").length>0;s.forEach(function(p,h){var f=u.transceivers[h],_=f.iceGatherer,y=f.iceTransport,S=f.dtlsTransport,E=f.localCapabilities,R=f.remoteCapabilities;if(!(je.isRejected(p)&&je.matchPrefix(p,"a=bundle-only").length===0)&&!f.rejected){var H=je.getIceParameters(p,c),Y=je.getDtlsParameters(p,c);d&&(Y.role="server"),u.usingBundle&&h!==0||(u._gather(f.mid,h),y.state==="new"&&y.start(_,H,d?"controlling":"controlled"),S.state==="new"&&S.start(Y));var ue=cu(E,R);u._transceive(f,ue.codecs.length>0,!1)}})}return u._localDescription={type:a.type,sdp:a.sdp},a.type==="offer"?u._updateSignalingState("have-local-offer"):u._updateSignalingState("stable"),Promise.resolve()},i.prototype.setRemoteDescription=function(a){var s=this;if(["offer","answer"].indexOf(a.type)===-1)return Promise.reject(Yt("TypeError",'Unsupported type "'+a.type+'"'));if(!zg("setRemoteDescription",a.type,s.signalingState)||s._isClosed)return Promise.reject(Yt("InvalidStateError","Can not set remote "+a.type+" in state "+s.signalingState));var c={};s.remoteStreams.forEach(function(y){c[y.id]=y});var u=[],d=je.splitSections(a.sdp),p=d.shift(),h=je.matchPrefix(p,"a=ice-lite").length>0,f=je.matchPrefix(p,"a=group:BUNDLE ").length>0;s.usingBundle=f;var _=je.matchPrefix(p,"a=ice-options:")[0];return s.canTrickleIceCandidates=!!_&&_.substr(14).split(" ").indexOf("trickle")>=0,d.forEach(function(y,S){var E=je.splitLines(y),R=je.getKind(y),H=je.isRejected(y)&&je.matchPrefix(y,"a=bundle-only").length===0,Y=E[0].substr(2).split(" ")[2],ue=je.getDirection(y,p),le=je.parseMsid(y),O=je.getMid(y)||je.generateIdentifier();if(H||R==="application"&&(Y==="DTLS/SCTP"||Y==="UDP/DTLS/SCTP"))s.transceivers[S]={mid:O,kind:R,protocol:Y,rejected:!0};else{var k,P,A,U,T,g,I,w,L;!H&&s.transceivers[S]&&s.transceivers[S].rejected&&(s.transceivers[S]=s._createTransceiver(R,!0));var B,ee,oe=je.parseRtpParameters(y);H||(B=je.getIceParameters(y,p),(ee=je.getDtlsParameters(y,p)).role="client"),I=je.parseRtpEncodingParameters(y);var ve=je.parseRtcpParameters(y),ge=je.matchPrefix(y,"a=end-of-candidates",p).length>0,qe=je.matchPrefix(y,"a=candidate:").map(function(Je){return je.parseCandidate(Je)}).filter(function(Je){return Je.component===1});if((a.type==="offer"||a.type==="answer")&&!H&&f&&S>0&&s.transceivers[S]&&(s._disposeIceAndDtlsTransports(S),s.transceivers[S].iceGatherer=s.transceivers[0].iceGatherer,s.transceivers[S].iceTransport=s.transceivers[0].iceTransport,s.transceivers[S].dtlsTransport=s.transceivers[0].dtlsTransport,s.transceivers[S].rtpSender&&s.transceivers[S].rtpSender.setTransport(s.transceivers[0].dtlsTransport),s.transceivers[S].rtpReceiver&&s.transceivers[S].rtpReceiver.setTransport(s.transceivers[0].dtlsTransport)),a.type!=="offer"||H)a.type==="answer"&&!H&&(P=(k=s.transceivers[S]).iceGatherer,A=k.iceTransport,U=k.dtlsTransport,T=k.rtpReceiver,g=k.sendEncodingParameters,w=k.localCapabilities,s.transceivers[S].recvEncodingParameters=I,s.transceivers[S].remoteCapabilities=oe,s.transceivers[S].rtcpParameters=ve,qe.length&&A.state==="new"&&(!h&&!ge||f&&S!==0?qe.forEach(function(Je){$d(k.iceTransport,Je)}):A.setRemoteCandidates(qe)),f&&S!==0||(A.state==="new"&&A.start(P,B,"controlling"),U.state==="new"&&U.start(ee)),!cu(k.localCapabilities,k.remoteCapabilities).codecs.filter(function(Je){return Je.name.toLowerCase()==="rtx"}).length&&k.sendEncodingParameters[0].rtx&&delete k.sendEncodingParameters[0].rtx,s._transceive(k,ue==="sendrecv"||ue==="recvonly",ue==="sendrecv"||ue==="sendonly"),!T||ue!=="sendrecv"&&ue!=="sendonly"?delete k.rtpReceiver:(L=T.track,le?(c[le.stream]||(c[le.stream]=new e.MediaStream),n(L,c[le.stream]),u.push([L,T,c[le.stream]])):(c.default||(c.default=new e.MediaStream),n(L,c.default),u.push([L,T,c.default]))));else{(k=s.transceivers[S]||s._createTransceiver(R)).mid=O,k.iceGatherer||(k.iceGatherer=s._createIceGatherer(S,f)),qe.length&&k.iceTransport.state==="new"&&(!ge||f&&S!==0?qe.forEach(function(Je){$d(k.iceTransport,Je)}):k.iceTransport.setRemoteCandidates(qe)),w=e.RTCRtpReceiver.getCapabilities(R),t<15019&&(w.codecs=w.codecs.filter(function(Je){return Je.name!=="rtx"})),g=k.sendEncodingParameters||[{ssrc:1001*(2*S+2)}];var Ne,Ge=!1;ue==="sendrecv"||ue==="sendonly"?(Ge=!k.rtpReceiver,T=k.rtpReceiver||new e.RTCRtpReceiver(k.dtlsTransport,R),Ge&&(L=T.track,le&&le.stream==="-"||(le?(c[le.stream]||(c[le.stream]=new e.MediaStream,Object.defineProperty(c[le.stream],"id",{get:function(){return le.stream}})),Object.defineProperty(L,"id",{get:function(){return le.track}}),Ne=c[le.stream]):(c.default||(c.default=new e.MediaStream),Ne=c.default)),Ne&&(n(L,Ne),k.associatedRemoteMediaStreams.push(Ne)),u.push([L,T,Ne]))):k.rtpReceiver&&k.rtpReceiver.track&&(k.associatedRemoteMediaStreams.forEach(function(Je){var ze=Je.getTracks().find(function(xr){return xr.id===k.rtpReceiver.track.id});ze&&function(xr,sa){sa.removeTrack(xr),sa.dispatchEvent(new e.MediaStreamTrackEvent("removetrack",{track:xr}))}(ze,Je)}),k.associatedRemoteMediaStreams=[]),k.localCapabilities=w,k.remoteCapabilities=oe,k.rtpReceiver=T,k.rtcpParameters=ve,k.sendEncodingParameters=g,k.recvEncodingParameters=I,s._transceive(s.transceivers[S],!1,Ge)}}}),s._dtlsRole===void 0&&(s._dtlsRole=a.type==="offer"?"active":"passive"),s._remoteDescription={type:a.type,sdp:a.sdp},a.type==="offer"?s._updateSignalingState("have-remote-offer"):s._updateSignalingState("stable"),Object.keys(c).forEach(function(y){var S=c[y];if(S.getTracks().length){if(s.remoteStreams.indexOf(S)===-1){s.remoteStreams.push(S);var E=new Event("addstream");E.stream=S,e.setTimeout(function(){s._dispatchEvent("addstream",E)})}u.forEach(function(R){var H=R[0],Y=R[1];S.id===R[2].id&&r(s,H,Y,[S])})}}),u.forEach(function(y){y[2]||r(s,y[0],y[1],[])}),e.setTimeout(function(){s&&s.transceivers&&s.transceivers.forEach(function(y){y.iceTransport&&y.iceTransport.state==="new"&&y.iceTransport.getRemoteCandidates().length>0&&(console.warn("Timeout for addRemoteCandidate. Consider sending an end-of-candidates notification"),y.iceTransport.addRemoteCandidate({}))})},4e3),Promise.resolve()},i.prototype.close=function(){this.transceivers.forEach(function(a){a.iceTransport&&a.iceTransport.stop(),a.dtlsTransport&&a.dtlsTransport.stop(),a.rtpSender&&a.rtpSender.stop(),a.rtpReceiver&&a.rtpReceiver.stop()}),this._isClosed=!0,this._updateSignalingState("closed")},i.prototype._updateSignalingState=function(a){this.signalingState=a;var s=new Event("signalingstatechange");this._dispatchEvent("signalingstatechange",s)},i.prototype._maybeFireNegotiationNeeded=function(){var a=this;this.signalingState==="stable"&&this.needNegotiation!==!0&&(this.needNegotiation=!0,e.setTimeout(function(){if(a.needNegotiation){a.needNegotiation=!1;var s=new Event("negotiationneeded");a._dispatchEvent("negotiationneeded",s)}},0))},i.prototype._updateIceConnectionState=function(){var a,s={new:0,closed:0,checking:0,connected:0,completed:0,disconnected:0,failed:0};if(this.transceivers.forEach(function(u){u.iceTransport&&!u.rejected&&s[u.iceTransport.state]++}),a="new",s.failed>0?a="failed":s.checking>0?a="checking":s.disconnected>0?a="disconnected":s.new>0?a="new":s.connected>0?a="connected":s.completed>0&&(a="completed"),a!==this.iceConnectionState){this.iceConnectionState=a;var c=new Event("iceconnectionstatechange");this._dispatchEvent("iceconnectionstatechange",c)}},i.prototype._updateConnectionState=function(){var a,s={new:0,closed:0,connecting:0,connected:0,completed:0,disconnected:0,failed:0};if(this.transceivers.forEach(function(u){u.iceTransport&&u.dtlsTransport&&!u.rejected&&(s[u.iceTransport.state]++,s[u.dtlsTransport.state]++)}),s.connected+=s.completed,a="new",s.failed>0?a="failed":s.connecting>0?a="connecting":s.disconnected>0?a="disconnected":s.new>0?a="new":s.connected>0&&(a="connected"),a!==this.connectionState){this.connectionState=a;var c=new Event("connectionstatechange");this._dispatchEvent("connectionstatechange",c)}},i.prototype.createOffer=function(){var a=this;if(a._isClosed)return Promise.reject(Yt("InvalidStateError","Can not call createOffer after close"));var s=a.transceivers.filter(function(h){return h.kind==="audio"}).length,c=a.transceivers.filter(function(h){return h.kind==="video"}).length,u=arguments[0];if(u){if(u.mandatory||u.optional)throw new TypeError("Legacy mandatory/optional constraints not supported.");u.offerToReceiveAudio!==void 0&&(s=u.offerToReceiveAudio===!0?1:u.offerToReceiveAudio===!1?0:u.offerToReceiveAudio),u.offerToReceiveVideo!==void 0&&(c=u.offerToReceiveVideo===!0?1:u.offerToReceiveVideo===!1?0:u.offerToReceiveVideo)}for(a.transceivers.forEach(function(h){h.kind==="audio"?--s<0&&(h.wantReceive=!1):h.kind==="video"&&--c<0&&(h.wantReceive=!1)});s>0||c>0;)s>0&&(a._createTransceiver("audio"),s--),c>0&&(a._createTransceiver("video"),c--);var d=je.writeSessionBoilerplate(a._sdpSessionId,a._sdpSessionVersion++);a.transceivers.forEach(function(h,f){var _=h.track,y=h.kind,S=h.mid||je.generateIdentifier();h.mid=S,h.iceGatherer||(h.iceGatherer=a._createIceGatherer(f,a.usingBundle));var E=e.RTCRtpSender.getCapabilities(y);t<15019&&(E.codecs=E.codecs.filter(function(H){return H.name!=="rtx"})),E.codecs.forEach(function(H){H.name==="H264"&&H.parameters["level-asymmetry-allowed"]===void 0&&(H.parameters["level-asymmetry-allowed"]="1"),h.remoteCapabilities&&h.remoteCapabilities.codecs&&h.remoteCapabilities.codecs.forEach(function(Y){H.name.toLowerCase()===Y.name.toLowerCase()&&H.clockRate===Y.clockRate&&(H.preferredPayloadType=Y.payloadType)})}),E.headerExtensions.forEach(function(H){(h.remoteCapabilities&&h.remoteCapabilities.headerExtensions||[]).forEach(function(Y){H.uri===Y.uri&&(H.id=Y.id)})});var R=h.sendEncodingParameters||[{ssrc:1001*(2*f+1)}];_&&t>=15019&&y==="video"&&!R[0].rtx&&(R[0].rtx={ssrc:R[0].ssrc+1}),h.wantReceive&&(h.rtpReceiver=new e.RTCRtpReceiver(h.dtlsTransport,y)),h.localCapabilities=E,h.sendEncodingParameters=R}),a._config.bundlePolicy!=="max-compat"&&(d+="a=group:BUNDLE "+a.transceivers.map(function(h){return h.mid}).join(" ")+`\r
54
+ `),d+=`a=ice-options:trickle\r
55
+ `,a.transceivers.forEach(function(h,f){d+=Hg(h,h.localCapabilities,"offer",h.stream,a._dtlsRole),d+=`a=rtcp-rsize\r
56
+ `,!h.iceGatherer||a.iceGatheringState==="new"||f!==0&&a.usingBundle||(h.iceGatherer.getLocalCandidates().forEach(function(_){_.component=1,d+="a="+je.writeCandidate(_)+`\r
57
+ `}),h.iceGatherer.state==="completed"&&(d+=`a=end-of-candidates\r
58
+ `))});var p=new e.RTCSessionDescription({type:"offer",sdp:d});return Promise.resolve(p)},i.prototype.createAnswer=function(){var a=this;if(a._isClosed)return Promise.reject(Yt("InvalidStateError","Can not call createAnswer after close"));if(a.signalingState!=="have-remote-offer"&&a.signalingState!=="have-local-pranswer")return Promise.reject(Yt("InvalidStateError","Can not call createAnswer in signalingState "+a.signalingState));var s=je.writeSessionBoilerplate(a._sdpSessionId,a._sdpSessionVersion++);a.usingBundle&&(s+="a=group:BUNDLE "+a.transceivers.map(function(d){return d.mid}).join(" ")+`\r
59
+ `),s+=`a=ice-options:trickle\r
60
+ `;var c=je.getMediaSections(a._remoteDescription.sdp).length;a.transceivers.forEach(function(d,p){if(!(p+1>c)){if(d.rejected)return d.kind==="application"?d.protocol==="DTLS/SCTP"?s+=`m=application 0 DTLS/SCTP 5000\r
61
+ `:s+="m=application 0 "+d.protocol+` webrtc-datachannel\r
62
+ `:d.kind==="audio"?s+=`m=audio 0 UDP/TLS/RTP/SAVPF 0\r
63
+ a=rtpmap:0 PCMU/8000\r
64
+ `:d.kind==="video"&&(s+=`m=video 0 UDP/TLS/RTP/SAVPF 120\r
65
+ a=rtpmap:120 VP8/90000\r
66
+ `),void(s+=`c=IN IP4 0.0.0.0\r
67
+ a=inactive\r
68
+ a=mid:`+d.mid+`\r
69
+ `);var h;d.stream&&(d.kind==="audio"?h=d.stream.getAudioTracks()[0]:d.kind==="video"&&(h=d.stream.getVideoTracks()[0]),h&&t>=15019&&d.kind==="video"&&!d.sendEncodingParameters[0].rtx&&(d.sendEncodingParameters[0].rtx={ssrc:d.sendEncodingParameters[0].ssrc+1}));var f=cu(d.localCapabilities,d.remoteCapabilities);!f.codecs.filter(function(_){return _.name.toLowerCase()==="rtx"}).length&&d.sendEncodingParameters[0].rtx&&delete d.sendEncodingParameters[0].rtx,s+=Hg(d,f,"answer",d.stream,a._dtlsRole),d.rtcpParameters&&d.rtcpParameters.reducedSize&&(s+=`a=rtcp-rsize\r
70
+ `)}});var u=new e.RTCSessionDescription({type:"answer",sdp:s});return Promise.resolve(u)},i.prototype.addIceCandidate=function(a){var s,c=this;return a&&a.sdpMLineIndex===void 0&&!a.sdpMid?Promise.reject(new TypeError("sdpMLineIndex or sdpMid required")):new Promise(function(u,d){if(!c._remoteDescription)return d(Yt("InvalidStateError","Can not add ICE candidate without a remote description"));if(a&&a.candidate!==""){var p=a.sdpMLineIndex;if(a.sdpMid){for(var h=0;h<c.transceivers.length;h++)if(c.transceivers[h].mid===a.sdpMid){p=h;break}}var f=c.transceivers[p];if(!f)return d(Yt("OperationError","Can not add ICE candidate"));if(f.rejected)return u();var _=Object.keys(a.candidate).length>0?je.parseCandidate(a.candidate):{};if(_.protocol==="tcp"&&(_.port===0||_.port===9)||_.component&&_.component!==1)return u();if((p===0||p>0&&f.iceTransport!==c.transceivers[0].iceTransport)&&!$d(f.iceTransport,_))return d(Yt("OperationError","Can not add ICE candidate"));var y=a.candidate.trim();y.indexOf("a=")===0&&(y=y.substr(2)),(s=je.getMediaSections(c._remoteDescription.sdp))[p]+="a="+(_.type?y:"end-of-candidates")+`\r
71
+ `,c._remoteDescription.sdp=je.getDescription(c._remoteDescription.sdp)+s.join("")}else for(var S=0;S<c.transceivers.length&&(c.transceivers[S].rejected||(c.transceivers[S].iceTransport.addRemoteCandidate({}),(s=je.getMediaSections(c._remoteDescription.sdp))[S]+=`a=end-of-candidates\r
72
+ `,c._remoteDescription.sdp=je.getDescription(c._remoteDescription.sdp)+s.join(""),!c.usingBundle));S++);u()})},i.prototype.getStats=function(a){if(a&&a instanceof e.MediaStreamTrack){var s=null;if(this.transceivers.forEach(function(u){u.rtpSender&&u.rtpSender.track===a?s=u.rtpSender:u.rtpReceiver&&u.rtpReceiver.track===a&&(s=u.rtpReceiver)}),!s)throw Yt("InvalidAccessError","Invalid selector.");return s.getStats()}var c=[];return this.transceivers.forEach(function(u){["rtpSender","rtpReceiver","iceGatherer","iceTransport","dtlsTransport"].forEach(function(d){u[d]&&c.push(u[d].getStats())})}),Promise.all(c).then(function(u){var d=new Map;return u.forEach(function(p){p.forEach(function(h){d.set(h.id,h)})}),d})},["RTCRtpSender","RTCRtpReceiver","RTCIceGatherer","RTCIceTransport","RTCDtlsTransport"].forEach(function(a){var s=e[a];if(s&&s.prototype&&s.prototype.getStats){var c=s.prototype.getStats;s.prototype.getStats=function(){return c.apply(this).then(function(u){var d=new Map;return Object.keys(u).forEach(function(p){var h;u[p].type={inboundrtp:"inbound-rtp",outboundrtp:"outbound-rtp",candidatepair:"candidate-pair",localcandidate:"local-candidate",remotecandidate:"remote-candidate"}[(h=u[p]).type]||h.type,d.set(p,u[p])}),d})}}});var o=["createOffer","createAnswer"];return o.forEach(function(a){var s=i.prototype[a];i.prototype[a]=function(){var c=arguments;return typeof c[0]=="function"||typeof c[1]=="function"?s.apply(this,[arguments[2]]).then(function(u){typeof c[0]=="function"&&c[0].apply(null,[u])},function(u){typeof c[1]=="function"&&c[1].apply(null,[u])}):s.apply(this,arguments)}}),(o=["setLocalDescription","setRemoteDescription","addIceCandidate"]).forEach(function(a){var s=i.prototype[a];i.prototype[a]=function(){var c=arguments;return typeof c[1]=="function"||typeof c[2]=="function"?s.apply(this,arguments).then(function(){typeof c[1]=="function"&&c[1].apply(null)},function(u){typeof c[2]=="function"&&c[2].apply(null,[u])}):s.apply(this,arguments)}}),["getStats"].forEach(function(a){var s=i.prototype[a];i.prototype[a]=function(){var c=arguments;return typeof c[1]=="function"?s.apply(this,arguments).then(function(){typeof c[1]=="function"&&c[1].apply(null)}):s.apply(this,arguments)}}),i};function Wg(e){let t=e&&e.navigator,n=t.mediaDevices.getUserMedia.bind(t.mediaDevices);t.mediaDevices.getUserMedia=function(r){return n(r).catch(i=>Promise.reject(function(o){return{name:{PermissionDeniedError:"NotAllowedError"}[o.name]||o.name,message:o.message,constraint:o.constraint,toString(){return this.name}}}(i)))}}function Jg(e){"getDisplayMedia"in e.navigator&&e.navigator.mediaDevices&&(e.navigator.mediaDevices&&"getDisplayMedia"in e.navigator.mediaDevices||(e.navigator.mediaDevices.getDisplayMedia=e.navigator.getDisplayMedia.bind(e.navigator)))}function Zd(e,t){if(e.RTCIceGatherer&&(e.RTCIceCandidate||(e.RTCIceCandidate=function(r){return r}),e.RTCSessionDescription||(e.RTCSessionDescription=function(r){return r}),t.version<15025)){let r=Object.getOwnPropertyDescriptor(e.MediaStreamTrack.prototype,"enabled");Object.defineProperty(e.MediaStreamTrack.prototype,"enabled",{set(i){r.set.call(this,i);let o=new Event("enabled");o.enabled=i,this.dispatchEvent(o)}})}e.RTCRtpSender&&!("dtmf"in e.RTCRtpSender.prototype)&&Object.defineProperty(e.RTCRtpSender.prototype,"dtmf",{get(){return this._dtmf===void 0&&(this.track.kind==="audio"?this._dtmf=new e.RTCDtmfSender(this):this.track.kind==="video"&&(this._dtmf=null)),this._dtmf}}),e.RTCDtmfSender&&!e.RTCDTMFSender&&(e.RTCDTMFSender=e.RTCDtmfSender);let n=PE(e,t.version);e.RTCPeerConnection=function(r){return r&&r.iceServers&&(r.iceServers=function(i,o){let a=!1;return(i=JSON.parse(JSON.stringify(i))).filter(s=>{if(s&&(s.urls||s.url)){let c=s.urls||s.url;s.url&&!s.urls&&ou("RTCIceServer.url","RTCIceServer.urls");let u=typeof c=="string";return u&&(c=[c]),c=c.filter(d=>{if(d.indexOf("stun:")===0)return!1;let p=d.startsWith("turn")&&!d.startsWith("turn:[")&&d.includes("transport=udp");return p&&!a?(a=!0,!0):p&&!a}),delete s.url,s.urls=u?c[0]:c,!!c.length}})}(r.iceServers,t.version),Kd("ICE servers after filtering:",r.iceServers)),new n(r)},e.RTCPeerConnection.prototype=n.prototype}function qg(e){e.RTCRtpSender&&!("replaceTrack"in e.RTCRtpSender.prototype)&&(e.RTCRtpSender.prototype.replaceTrack=e.RTCRtpSender.prototype.setTrack)}var Kg=Object.freeze({__proto__:null,shimPeerConnection:Zd,shimReplaceTrack:qg,shimGetUserMedia:Wg,shimGetDisplayMedia:Jg});function Qg(e,t){let n=e&&e.navigator,r=e&&e.MediaStreamTrack;if(n.getUserMedia=function(i,o,a){ou("navigator.getUserMedia","navigator.mediaDevices.getUserMedia"),n.mediaDevices.getUserMedia(i).then(o,a)},!(t.version>55&&"autoGainControl"in n.mediaDevices.getSupportedConstraints())){let i=function(a,s,c){s in a&&!(c in a)&&(a[c]=a[s],delete a[s])},o=n.mediaDevices.getUserMedia.bind(n.mediaDevices);if(n.mediaDevices.getUserMedia=function(a){return typeof a=="object"&&typeof a.audio=="object"&&(a=JSON.parse(JSON.stringify(a)),i(a.audio,"autoGainControl","mozAutoGainControl"),i(a.audio,"noiseSuppression","mozNoiseSuppression")),o(a)},r&&r.prototype.getSettings){let a=r.prototype.getSettings;r.prototype.getSettings=function(){let s=a.apply(this,arguments);return i(s,"mozAutoGainControl","autoGainControl"),i(s,"mozNoiseSuppression","noiseSuppression"),s}}if(r&&r.prototype.applyConstraints){let a=r.prototype.applyConstraints;r.prototype.applyConstraints=function(s){return this.kind==="audio"&&typeof s=="object"&&(s=JSON.parse(JSON.stringify(s)),i(s,"autoGainControl","mozAutoGainControl"),i(s,"noiseSuppression","mozNoiseSuppression")),a.apply(this,[s])}}}}function Xg(e){typeof e=="object"&&e.RTCTrackEvent&&"receiver"in e.RTCTrackEvent.prototype&&!("transceiver"in e.RTCTrackEvent.prototype)&&Object.defineProperty(e.RTCTrackEvent.prototype,"transceiver",{get(){return{receiver:this.receiver}}})}function eh(e,t){if(typeof e!="object"||!e.RTCPeerConnection&&!e.mozRTCPeerConnection)return;!e.RTCPeerConnection&&e.mozRTCPeerConnection&&(e.RTCPeerConnection=e.mozRTCPeerConnection),t.version<53&&["setLocalDescription","setRemoteDescription","addIceCandidate"].forEach(function(i){let o=e.RTCPeerConnection.prototype[i],a={[i](){return arguments[0]=new(i==="addIceCandidate"?e.RTCIceCandidate:e.RTCSessionDescription)(arguments[0]),o.apply(this,arguments)}};e.RTCPeerConnection.prototype[i]=a[i]});let n={inboundrtp:"inbound-rtp",outboundrtp:"outbound-rtp",candidatepair:"candidate-pair",localcandidate:"local-candidate",remotecandidate:"remote-candidate"},r=e.RTCPeerConnection.prototype.getStats;e.RTCPeerConnection.prototype.getStats=function(){let[i,o,a]=arguments;return r.apply(this,[i||null]).then(s=>{if(t.version<53&&!o)try{s.forEach(c=>{c.type=n[c.type]||c.type})}catch(c){if(c.name!=="TypeError")throw c;s.forEach((u,d)=>{s.set(d,Object.assign({},u,{type:n[u.type]||u.type}))})}return s}).then(o,a)}}function Yg(e){if(typeof e!="object"||!e.RTCPeerConnection||!e.RTCRtpSender||e.RTCRtpSender&&"getStats"in e.RTCRtpSender.prototype)return;let t=e.RTCPeerConnection.prototype.getSenders;t&&(e.RTCPeerConnection.prototype.getSenders=function(){let r=t.apply(this,[]);return r.forEach(i=>i._pc=this),r});let n=e.RTCPeerConnection.prototype.addTrack;n&&(e.RTCPeerConnection.prototype.addTrack=function(){let r=n.apply(this,arguments);return r._pc=this,r}),e.RTCRtpSender.prototype.getStats=function(){return this.track?this._pc.getStats(this.track):Promise.resolve(new Map)}}function $g(e){if(typeof e!="object"||!e.RTCPeerConnection||!e.RTCRtpSender||e.RTCRtpSender&&"getStats"in e.RTCRtpReceiver.prototype)return;let t=e.RTCPeerConnection.prototype.getReceivers;t&&(e.RTCPeerConnection.prototype.getReceivers=function(){let n=t.apply(this,[]);return n.forEach(r=>r._pc=this),n}),Sa(e,"track",n=>(n.receiver._pc=n.srcElement,n)),e.RTCRtpReceiver.prototype.getStats=function(){return this._pc.getStats(this.track)}}function Zg(e){e.RTCPeerConnection&&!("removeStream"in e.RTCPeerConnection.prototype)&&(e.RTCPeerConnection.prototype.removeStream=function(t){ou("removeStream","removeTrack"),this.getSenders().forEach(n=>{n.track&&t.getTracks().includes(n.track)&&this.removeTrack(n)})})}function e_(e){e.DataChannel&&!e.RTCDataChannel&&(e.RTCDataChannel=e.DataChannel)}function t_(e){if(typeof e!="object"||!e.RTCPeerConnection)return;let t=e.RTCPeerConnection.prototype.addTransceiver;t&&(e.RTCPeerConnection.prototype.addTransceiver=function(){this.setParametersPromises=[];let n=arguments[1],r=n&&"sendEncodings"in n;r&&n.sendEncodings.forEach(o=>{if("rid"in o&&!/^[a-z0-9]{0,16}$/i.test(o.rid))throw new TypeError("Invalid RID value provided.");if("scaleResolutionDownBy"in o&&!(parseFloat(o.scaleResolutionDownBy)>=1))throw new RangeError("scale_resolution_down_by must be >= 1.0");if("maxFramerate"in o&&!(parseFloat(o.maxFramerate)>=0))throw new RangeError("max_framerate must be >= 0.0")});let i=t.apply(this,arguments);if(r){let{sender:o}=i,a=o.getParameters();(!("encodings"in a)||a.encodings.length===1&&Object.keys(a.encodings[0]).length===0)&&(a.encodings=n.sendEncodings,o.sendEncodings=n.sendEncodings,this.setParametersPromises.push(o.setParameters(a).then(()=>{delete o.sendEncodings}).catch(()=>{delete o.sendEncodings})))}return i})}function n_(e){if(typeof e!="object"||!e.RTCRtpSender)return;let t=e.RTCRtpSender.prototype.getParameters;t&&(e.RTCRtpSender.prototype.getParameters=function(){let n=t.apply(this,arguments);return"encodings"in n||(n.encodings=[].concat(this.sendEncodings||[{}])),n})}function r_(e){if(typeof e!="object"||!e.RTCPeerConnection)return;let t=e.RTCPeerConnection.prototype.createOffer;e.RTCPeerConnection.prototype.createOffer=function(){return this.setParametersPromises&&this.setParametersPromises.length?Promise.all(this.setParametersPromises).then(()=>t.apply(this,arguments)).finally(()=>{this.setParametersPromises=[]}):t.apply(this,arguments)}}function i_(e){if(typeof e!="object"||!e.RTCPeerConnection)return;let t=e.RTCPeerConnection.prototype.createAnswer;e.RTCPeerConnection.prototype.createAnswer=function(){return this.setParametersPromises&&this.setParametersPromises.length?Promise.all(this.setParametersPromises).then(()=>t.apply(this,arguments)).finally(()=>{this.setParametersPromises=[]}):t.apply(this,arguments)}}var a_=Object.freeze({__proto__:null,shimOnTrack:Xg,shimPeerConnection:eh,shimSenderGetStats:Yg,shimReceiverGetStats:$g,shimRemoveStream:Zg,shimRTCDataChannel:e_,shimAddTransceiver:t_,shimGetParameters:n_,shimCreateOffer:r_,shimCreateAnswer:i_,shimGetUserMedia:Qg,shimGetDisplayMedia:function(e,t){e.navigator.mediaDevices&&"getDisplayMedia"in e.navigator.mediaDevices||e.navigator.mediaDevices&&(e.navigator.mediaDevices.getDisplayMedia=function(n){if(!n||!n.video){let r=new DOMException("getDisplayMedia without video constraints is undefined");return r.name="NotFoundError",r.code=8,Promise.reject(r)}return n.video===!0?n.video={mediaSource:t}:n.video.mediaSource=t,e.navigator.mediaDevices.getUserMedia(n)})}});function o_(e){if(typeof e=="object"&&e.RTCPeerConnection){if("getLocalStreams"in e.RTCPeerConnection.prototype||(e.RTCPeerConnection.prototype.getLocalStreams=function(){return this._localStreams||(this._localStreams=[]),this._localStreams}),!("addStream"in e.RTCPeerConnection.prototype)){let t=e.RTCPeerConnection.prototype.addTrack;e.RTCPeerConnection.prototype.addStream=function(n){this._localStreams||(this._localStreams=[]),this._localStreams.includes(n)||this._localStreams.push(n),n.getAudioTracks().forEach(r=>t.call(this,r,n)),n.getVideoTracks().forEach(r=>t.call(this,r,n))},e.RTCPeerConnection.prototype.addTrack=function(n,...r){return r&&r.forEach(i=>{this._localStreams?this._localStreams.includes(i)||this._localStreams.push(i):this._localStreams=[i]}),t.apply(this,arguments)}}"removeStream"in e.RTCPeerConnection.prototype||(e.RTCPeerConnection.prototype.removeStream=function(t){this._localStreams||(this._localStreams=[]);let n=this._localStreams.indexOf(t);if(n===-1)return;this._localStreams.splice(n,1);let r=t.getTracks();this.getSenders().forEach(i=>{r.includes(i.track)&&this.removeTrack(i)})})}}function s_(e){if(typeof e=="object"&&e.RTCPeerConnection&&("getRemoteStreams"in e.RTCPeerConnection.prototype||(e.RTCPeerConnection.prototype.getRemoteStreams=function(){return this._remoteStreams?this._remoteStreams:[]}),!("onaddstream"in e.RTCPeerConnection.prototype))){Object.defineProperty(e.RTCPeerConnection.prototype,"onaddstream",{get(){return this._onaddstream},set(n){this._onaddstream&&(this.removeEventListener("addstream",this._onaddstream),this.removeEventListener("track",this._onaddstreampoly)),this.addEventListener("addstream",this._onaddstream=n),this.addEventListener("track",this._onaddstreampoly=r=>{r.streams.forEach(i=>{if(this._remoteStreams||(this._remoteStreams=[]),this._remoteStreams.includes(i))return;this._remoteStreams.push(i);let o=new Event("addstream");o.stream=i,this.dispatchEvent(o)})})}});let t=e.RTCPeerConnection.prototype.setRemoteDescription;e.RTCPeerConnection.prototype.setRemoteDescription=function(){let n=this;return this._onaddstreampoly||this.addEventListener("track",this._onaddstreampoly=function(r){r.streams.forEach(i=>{if(n._remoteStreams||(n._remoteStreams=[]),n._remoteStreams.indexOf(i)>=0)return;n._remoteStreams.push(i);let o=new Event("addstream");o.stream=i,n.dispatchEvent(o)})}),t.apply(n,arguments)}}}function c_(e){if(typeof e!="object"||!e.RTCPeerConnection)return;let t=e.RTCPeerConnection.prototype,n=t.createOffer,r=t.createAnswer,i=t.setLocalDescription,o=t.setRemoteDescription,a=t.addIceCandidate;t.createOffer=function(c,u){let d=arguments.length>=2?arguments[2]:arguments[0],p=n.apply(this,[d]);return u?(p.then(c,u),Promise.resolve()):p},t.createAnswer=function(c,u){let d=arguments.length>=2?arguments[2]:arguments[0],p=r.apply(this,[d]);return u?(p.then(c,u),Promise.resolve()):p};let s=function(c,u,d){let p=i.apply(this,[c]);return d?(p.then(u,d),Promise.resolve()):p};t.setLocalDescription=s,s=function(c,u,d){let p=o.apply(this,[c]);return d?(p.then(u,d),Promise.resolve()):p},t.setRemoteDescription=s,s=function(c,u,d){let p=a.apply(this,[c]);return d?(p.then(u,d),Promise.resolve()):p},t.addIceCandidate=s}function u_(e){let t=e&&e.navigator;if(t.mediaDevices&&t.mediaDevices.getUserMedia){let n=t.mediaDevices,r=n.getUserMedia.bind(n);t.mediaDevices.getUserMedia=i=>r(l_(i))}!t.getUserMedia&&t.mediaDevices&&t.mediaDevices.getUserMedia&&(t.getUserMedia=function(n,r,i){t.mediaDevices.getUserMedia(n).then(r,i)}.bind(t))}function l_(e){return e&&e.video!==void 0?Object.assign({},e,{video:Ag(e.video)}):e}function d_(e){if(!e.RTCPeerConnection)return;let t=e.RTCPeerConnection;e.RTCPeerConnection=function(n,r){if(n&&n.iceServers){let i=[];for(let o=0;o<n.iceServers.length;o++){let a=n.iceServers[o];!a.hasOwnProperty("urls")&&a.hasOwnProperty("url")?(ou("RTCIceServer.url","RTCIceServer.urls"),a=JSON.parse(JSON.stringify(a)),a.urls=a.url,delete a.url,i.push(a)):i.push(n.iceServers[o])}n.iceServers=i}return new t(n,r)},e.RTCPeerConnection.prototype=t.prototype,"generateCertificate"in t&&Object.defineProperty(e.RTCPeerConnection,"generateCertificate",{get:()=>t.generateCertificate})}function h_(e){typeof e=="object"&&e.RTCTrackEvent&&"receiver"in e.RTCTrackEvent.prototype&&!("transceiver"in e.RTCTrackEvent.prototype)&&Object.defineProperty(e.RTCTrackEvent.prototype,"transceiver",{get(){return{receiver:this.receiver}}})}function p_(e){let t=e.RTCPeerConnection.prototype.createOffer;e.RTCPeerConnection.prototype.createOffer=function(n){if(n){n.offerToReceiveAudio!==void 0&&(n.offerToReceiveAudio=!!n.offerToReceiveAudio);let r=this.getTransceivers().find(o=>o.receiver.track.kind==="audio");n.offerToReceiveAudio===!1&&r?r.direction==="sendrecv"?r.setDirection?r.setDirection("sendonly"):r.direction="sendonly":r.direction==="recvonly"&&(r.setDirection?r.setDirection("inactive"):r.direction="inactive"):n.offerToReceiveAudio!==!0||r||this.addTransceiver("audio"),n.offerToReceiveVideo!==void 0&&(n.offerToReceiveVideo=!!n.offerToReceiveVideo);let i=this.getTransceivers().find(o=>o.receiver.track.kind==="video");n.offerToReceiveVideo===!1&&i?i.direction==="sendrecv"?i.setDirection?i.setDirection("sendonly"):i.direction="sendonly":i.direction==="recvonly"&&(i.setDirection?i.setDirection("inactive"):i.direction="inactive"):n.offerToReceiveVideo!==!0||i||this.addTransceiver("video")}return t.apply(this,arguments)}}function f_(e){typeof e!="object"||e.AudioContext||(e.AudioContext=e.webkitAudioContext)}var m_=Object.freeze({__proto__:null,shimLocalStreamsAPI:o_,shimRemoteStreamsAPI:s_,shimCallbacksAPI:c_,shimGetUserMedia:u_,shimConstraints:l_,shimRTCIceServerUrls:d_,shimTrackEventTransceiver:h_,shimCreateOfferLegacy:p_,shimAudioContext:f_});function uu(e){if(!e.RTCIceCandidate||e.RTCIceCandidate&&"foundation"in e.RTCIceCandidate.prototype)return;let t=e.RTCIceCandidate;e.RTCIceCandidate=function(n){if(typeof n=="object"&&n.candidate&&n.candidate.indexOf("a=")===0&&((n=JSON.parse(JSON.stringify(n))).candidate=n.candidate.substr(2)),n.candidate&&n.candidate.length){let r=new t(n),i=su.parseCandidate(n.candidate),o=Object.assign(r,i);return o.toJSON=function(){return{candidate:o.candidate,sdpMid:o.sdpMid,sdpMLineIndex:o.sdpMLineIndex,usernameFragment:o.usernameFragment}},o}return new t(n)},e.RTCIceCandidate.prototype=t.prototype,Sa(e,"icecandidate",n=>(n.candidate&&Object.defineProperty(n,"candidate",{value:new e.RTCIceCandidate(n.candidate),writable:"false"}),n))}function vs(e,t){if(!e.RTCPeerConnection)return;"sctp"in e.RTCPeerConnection.prototype||Object.defineProperty(e.RTCPeerConnection.prototype,"sctp",{get(){return this._sctp===void 0?null:this._sctp}});let n=function(s){if(!s||!s.sdp)return!1;let c=su.splitSections(s.sdp);return c.shift(),c.some(u=>{let d=su.parseMLine(u);return d&&d.kind==="application"&&d.protocol.indexOf("SCTP")!==-1})},r=function(s){let c=s.sdp.match(/mozilla...THIS_IS_SDPARTA-(\d+)/);if(c===null||c.length<2)return-1;let u=parseInt(c[1],10);return u!=u?-1:u},i=function(s){let c=65536;return t.browser==="firefox"&&(c=t.version<57?s===-1?16384:2147483637:t.version<60?t.version===57?65535:65536:2147483637),c},o=function(s,c){let u=65536;t.browser==="firefox"&&t.version===57&&(u=65535);let d=su.matchPrefix(s.sdp,"a=max-message-size:");return d.length>0?u=parseInt(d[0].substr(19),10):t.browser==="firefox"&&c!==-1&&(u=2147483637),u},a=e.RTCPeerConnection.prototype.setRemoteDescription;e.RTCPeerConnection.prototype.setRemoteDescription=function(){if(this._sctp=null,t.browser==="chrome"&&t.version>=76){let{sdpSemantics:s}=this.getConfiguration();s==="plan-b"&&Object.defineProperty(this,"sctp",{get(){return this._sctp===void 0?null:this._sctp},enumerable:!0,configurable:!0})}if(n(arguments[0])){let s=r(arguments[0]),c=i(s),u=o(arguments[0],s),d;d=c===0&&u===0?Number.POSITIVE_INFINITY:c===0||u===0?Math.max(c,u):Math.min(c,u);let p={};Object.defineProperty(p,"maxMessageSize",{get:()=>d}),this._sctp=p}return a.apply(this,arguments)}}function gs(e){if(!e.RTCPeerConnection||!("createDataChannel"in e.RTCPeerConnection.prototype))return;function t(r,i){let o=r.send;r.send=function(){let a=arguments[0],s=a.length||a.size||a.byteLength;if(r.readyState==="open"&&i.sctp&&s>i.sctp.maxMessageSize)throw new TypeError("Message too large (can send a maximum of "+i.sctp.maxMessageSize+" bytes)");return o.apply(r,arguments)}}let n=e.RTCPeerConnection.prototype.createDataChannel;e.RTCPeerConnection.prototype.createDataChannel=function(){let r=n.apply(this,arguments);return t(r,this),r},Sa(e,"datachannel",r=>(t(r.channel,r.target),r))}function th(e){if(!e.RTCPeerConnection||"connectionState"in e.RTCPeerConnection.prototype)return;let t=e.RTCPeerConnection.prototype;Object.defineProperty(t,"connectionState",{get(){return{completed:"connected",checking:"connecting"}[this.iceConnectionState]||this.iceConnectionState},enumerable:!0,configurable:!0}),Object.defineProperty(t,"onconnectionstatechange",{get(){return this._onconnectionstatechange||null},set(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(n=>{let r=t[n];t[n]=function(){return this._connectionstatechangepoly||(this._connectionstatechangepoly=i=>{let o=i.target;if(o._lastConnectionState!==o.connectionState){o._lastConnectionState=o.connectionState;let a=new Event("connectionstatechange",i);o.dispatchEvent(a)}return i},this.addEventListener("iceconnectionstatechange",this._connectionstatechangepoly)),r.apply(this,arguments)}})}function nh(e,t){if(!e.RTCPeerConnection||t.browser==="chrome"&&t.version>=71||t.browser==="safari"&&t.version>=605)return;let n=e.RTCPeerConnection.prototype.setRemoteDescription;e.RTCPeerConnection.prototype.setRemoteDescription=function(r){if(r&&r.sdp&&r.sdp.indexOf(`
73
+ a=extmap-allow-mixed`)!==-1){let i=r.sdp.split(`
74
+ `).filter(o=>o.trim()!=="a=extmap-allow-mixed").join(`
75
+ `);e.RTCSessionDescription&&r instanceof e.RTCSessionDescription?arguments[0]=new e.RTCSessionDescription({type:r.type,sdp:i}):r.sdp=i}return n.apply(this,arguments)}}function lu(e,t){if(!e.RTCPeerConnection||!e.RTCPeerConnection.prototype)return;let n=e.RTCPeerConnection.prototype.addIceCandidate;n&&n.length!==0&&(e.RTCPeerConnection.prototype.addIceCandidate=function(){return arguments[0]?(t.browser==="chrome"&&t.version<78||t.browser==="firefox"&&t.version<68||t.browser==="safari")&&arguments[0]&&arguments[0].candidate===""?Promise.resolve():n.apply(this,arguments):(arguments[1]&&arguments[1].apply(null),Promise.resolve())})}var DE=Object.freeze({__proto__:null,shimRTCIceCandidate:uu,shimMaxMessageSize:vs,shimSendThrowTypeError:gs,shimConnectionState:th,removeExtmapAllowMixed:nh,shimAddIceCandidateNullOrEmpty:lu});(function({window:e}={},t={shimChrome:!0,shimFirefox:!0,shimEdge:!0,shimSafari:!0}){let n=Kd,r=function(o){let a={browser:null,version:null};if(o===void 0||!o.navigator)return a.browser="Not a browser.",a;let{navigator:s}=o;if(s.mozGetUserMedia)a.browser="firefox",a.version=ms(s.userAgent,/Firefox\/(\d+)\./,1);else if(s.webkitGetUserMedia||o.isSecureContext===!1&&o.webkitRTCPeerConnection&&!o.RTCIceGatherer)a.browser="chrome",a.version=ms(s.userAgent,/Chrom(e|ium)\/(\d+)\./,2);else if(s.mediaDevices&&s.userAgent.match(/Edge\/(\d+).(\d+)$/))a.browser="edge",a.version=ms(s.userAgent,/Edge\/(\d+).(\d+)$/,2);else{if(!o.RTCPeerConnection||!s.userAgent.match(/AppleWebKit\/(\d+)\./))return a.browser="Not a supported browser.",a;a.browser="safari",a.version=ms(s.userAgent,/AppleWebKit\/(\d+)\./,1),a.supportsUnifiedPlan=o.RTCRtpTransceiver&&"currentDirection"in o.RTCRtpTransceiver.prototype}return a}(e),i={browserDetails:r,commonShim:DE,extractVersion:ms,disableLog:RE,disableWarnings:AE};switch(r.browser){case"chrome":if(!Gg||!Xd||!t.shimChrome)return n("Chrome shim is not included in this adapter release."),i;if(r.version===null)return n("Chrome shim can not determine version, not shimming."),i;n("adapter.js shimming chrome."),i.browserShim=Gg,lu(e,r),Lg(e,r),Og(e),Xd(e,r),Mg(e),jg(e,r),Ng(e),Vg(e),Ug(e),Fg(e,r),uu(e),th(e),vs(e,r),gs(e),nh(e,r);break;case"firefox":if(!a_||!eh||!t.shimFirefox)return n("Firefox shim is not included in this adapter release."),i;n("adapter.js shimming firefox."),i.browserShim=a_,lu(e,r),Qg(e,r),eh(e,r),Xg(e),Zg(e),Yg(e),$g(e),e_(e),t_(e),n_(e),r_(e),i_(e),uu(e),th(e),vs(e,r),gs(e);break;case"edge":if(!Kg||!Zd||!t.shimEdge)return n("MS edge shim is not included in this adapter release."),i;n("adapter.js shimming edge."),i.browserShim=Kg,Wg(e),Jg(e),Zd(e,r),qg(e),vs(e,r),gs(e);break;case"safari":if(!m_||!t.shimSafari)return n("Safari shim is not included in this adapter release."),i;n("adapter.js shimming safari."),i.browserShim=m_,lu(e,r),d_(e),p_(e),c_(e),o_(e),s_(e),h_(e),u_(e),f_(e),uu(e),vs(e,r),gs(e),nh(e,r);break;default:n("Unsupported browser!")}})({window:typeof window=="undefined"?void 0:window});var Oi="4.15.6",v_={},LE=Tg,OE=Wd,du=Object.keys||function(e){return LE(e,OE)},ME=_e,NE=$c,VE=At,UE=dt,BE=it,jE=du;v_.f=ME&&!NE?Object.defineProperties:function(e,t){UE(e);for(var n,r=BE(t),i=jE(t),o=i.length,a=0;o>a;)VE.f(e,n=i[a++],r[n]);return e};var hu,g_=Rn("document","documentElement"),FE=dt,GE=v_,__=Wd,HE=l,zE=g_,WE=Cr,y_=_a("IE_PROTO"),rh=function(){},b_=function(e){return"<script>"+e+"<\/script>"},S_=function(e){e.write(b_("")),e.close();var t=e.parentWindow.Object;return e=null,t},pu=function(){try{hu=new ActiveXObject("htmlfile")}catch(r){}var e,t;pu=typeof document!="undefined"?document.domain&&hu?S_(hu):((t=WE("iframe")).style.display="none",zE.appendChild(t),t.src=String("javascript:"),(e=t.contentWindow.document).open(),e.write(b_("document.F=Object")),e.close(),e.F):S_(hu);for(var n=__.length;n--;)delete pu.prototype[__[n]];return pu()};HE[y_]=!0;var ka=Object.create||function(e,t){var n;return e!==null?(rh.prototype=FE(e),n=new rh,rh.prototype=null,n[y_]=e):n=pu(),t===void 0?n:GE.f(n,t)},JE=ct,qE=ka,KE=At.f,ih=JE("unscopables"),ah=Array.prototype;ah[ih]==null&&KE(ah,ih,{configurable:!0,value:qE(null)});var Mi,k_,T_,fu=function(e){ah[ih][e]=!0},_s={},x_=!ie(function(){function e(){}return e.prototype.constructor=null,Object.getPrototypeOf(new e)!==e.prototype}),QE=kt,XE=We,YE=Rt,$E=x_,I_=_a("IE_PROTO"),oh=Object,ZE=oh.prototype,ys=$E?oh.getPrototypeOf:function(e){var t=YE(e);if(QE(t,I_))return t[I_];var n=t.constructor;return XE(n)&&t instanceof n?n.prototype:t instanceof oh?ZE:null},eC=ie,tC=We,w_=ys,nC=Wt,sh=ct("iterator"),E_=!1;[].keys&&("next"in(T_=[].keys())?(k_=w_(w_(T_)))!==Object.prototype&&(Mi=k_):E_=!0);var rC=Mi==null||eC(function(){var e={};return Mi[sh].call(e)!==e});rC&&(Mi={}),tC(Mi[sh])||nC(Mi,sh,function(){return this});var ch={IteratorPrototype:Mi,BUGGY_SAFARI_ITERATORS:E_},iC=At.f,aC=kt,C_=ct("toStringTag"),Ni=function(e,t,n){e&&!n&&(e=e.prototype),e&&!aC(e,C_)&&iC(e,C_,{configurable:!0,value:t})},oC=ch.IteratorPrototype,sC=ka,cC=Ze,uC=Ni,lC=_s,dC=function(){return this},R_=function(e,t,n,r){var i=t+" Iterator";return e.prototype=sC(oC,{next:cC(+!r,n)}),uC(e,i,!1),lC[i]=dC,e},hC=We,pC=String,fC=TypeError,mC=ce,vC=dt,gC=function(e){if(typeof e=="object"||hC(e))return e;throw fC("Can't set "+pC(e)+" as a prototype")},Ta=Object.setPrototypeOf||("__proto__"in{}?function(){var e,t=!1,n={};try{(e=mC(Object.getOwnPropertyDescriptor(Object.prototype,"__proto__").set))(n,[]),t=n instanceof Array}catch(r){}return function(r,i){return vC(r),gC(i),t?e(r,i):r.__proto__=i,r}}():void 0),_C=Oe,yC=Ke,bC=We,SC=R_,A_=ys,P_=Ta,kC=Ni,TC=yn,uh=Wt,xC=_s,IC=dr.PROPER,wC=dr.CONFIGURABLE,D_=ch.IteratorPrototype,mu=ch.BUGGY_SAFARI_ITERATORS,bs=ct("iterator"),L_="keys",Ss="values",O_="entries",EC=function(){return this},lh=function(e,t,n,r,i,o,a){SC(n,t,r);var s,c,u,d=function(E){if(E===i&&y)return y;if(!mu&&E in f)return f[E];switch(E){case L_:case Ss:case O_:return function(){return new n(this,E)}}return function(){return new n(this)}},p=t+" Iterator",h=!1,f=e.prototype,_=f[bs]||f["@@iterator"]||i&&f[i],y=!mu&&_||d(i),S=t=="Array"&&f.entries||_;if(S&&(s=A_(S.call(new e)))!==Object.prototype&&s.next&&(A_(s)!==D_&&(P_?P_(s,D_):bC(s[bs])||uh(s,bs,EC)),kC(s,p,!0)),IC&&i==Ss&&_&&_.name!==Ss&&(wC?TC(f,"name",Ss):(h=!0,y=function(){return yC(_,this)})),i)if(c={values:d(Ss),keys:o?y:d(L_),entries:d(O_)},a)for(u in c)(mu||h||!(u in f))&&uh(f,u,c[u]);else _C({target:t,proto:!0,forced:mu||h},c);return f[bs]!==y&&uh(f,bs,y,{name:i}),xC[t]=y,c},CC=it,dh=fu,M_=_s,N_=Qe,RC=At.f,AC=lh,PC=_e,V_="Array Iterator",DC=N_.set,LC=N_.getterFor(V_),U_=AC(Array,"Array",function(e,t){DC(this,{type:V_,target:CC(e),index:0,kind:t})},function(){var e=LC(this),t=e.target,n=e.kind,r=e.index++;return!t||r>=t.length?(e.target=void 0,{value:void 0,done:!0}):n=="keys"?{value:r,done:!1}:n=="values"?{value:t[r],done:!1}:{value:[r,t[r]],done:!1}},"values"),B_=M_.Arguments=M_.Array;if(dh("keys"),dh("values"),dh("entries"),PC&&B_.name!=="values")try{RC(B_,"name",{value:"values"})}catch(e){}var j_={};j_[ct("toStringTag")]="z";var hh=String(j_)==="[object z]",OC=hh,MC=We,vu=vt,NC=ct("toStringTag"),VC=Object,UC=vu(function(){return arguments}())=="Arguments",ei=OC?vu:function(e){var t,n,r;return e===void 0?"Undefined":e===null?"Null":typeof(n=function(i,o){try{return i[o]}catch(a){}}(t=VC(e),NC))=="string"?n:UC?vu(t):(r=vu(t))=="Object"&&MC(t.callee)?"Arguments":r},BC=ei,jC=hh?{}.toString:function(){return"[object "+BC(this)+"]"};hh||Wt(Object.prototype,"toString",jC,{unsafe:!0});var ks={exports:{}},ph={},FC=xi,GC=At,HC=Ze,Ts=function(e,t,n){var r=FC(t);r in e?GC.f(e,r,HC(0,n)):e[r]=n},F_=Zr,zC=Zt,WC=Ts,JC=Array,qC=Math.max,xs=function(e,t,n){for(var r=zC(e),i=F_(t,r),o=F_(n===void 0?r:n,r),a=JC(qC(o-i,0)),s=0;i<o;i++,s++)WC(a,s,e[i]);return a.length=s,a},KC=vt,QC=it,G_=$r.f,XC=xs,H_=typeof window=="object"&&window&&Object.getOwnPropertyNames?Object.getOwnPropertyNames(window):[];ph.f=function(e){return H_&&KC(e)=="Window"?function(t){try{return G_(t)}catch(n){return XC(H_)}}(e):G_(QC(e))};var YC=ie(function(){if(typeof ArrayBuffer=="function"){var e=new ArrayBuffer(8);Object.isExtensible(e)&&Object.defineProperty(e,"a",{value:8})}}),$C=ie,ZC=yt,eR=vt,z_=YC,gu=Object.isExtensible,W_=$C(function(){gu(1)})||z_?function(e){return!!ZC(e)&&(!z_||eR(e)!="ArrayBuffer")&&(!gu||gu(e))}:gu,tR=!ie(function(){return Object.isExtensible(Object.preventExtensions({}))}),nR=Oe,rR=ce,iR=l,aR=yt,fh=kt,oR=At.f,J_=$r,sR=ph,mh=W_,cR=tR,q_=!1,Ar=ur("meta"),uR=0,vh=function(e){oR(e,Ar,{value:{objectID:"O"+uR++,weakData:{}}})},lR=ks.exports={enable:function(){lR.enable=function(){},q_=!0;var e=J_.f,t=rR([].splice),n={};n[Ar]=1,e(n).length&&(J_.f=function(r){for(var i=e(r),o=0,a=i.length;o<a;o++)if(i[o]===Ar){t(i,o,1);break}return i},nR({target:"Object",stat:!0,forced:!0},{getOwnPropertyNames:sR.f}))},fastKey:function(e,t){if(!aR(e))return typeof e=="symbol"?e:(typeof e=="string"?"S":"P")+e;if(!fh(e,Ar)){if(!mh(e))return"F";if(!t)return"E";vh(e)}return e[Ar].objectID},getWeakData:function(e,t){if(!fh(e,Ar)){if(!mh(e))return!0;if(!t)return!1;vh(e)}return e[Ar].weakData},onFreeze:function(e){return cR&&q_&&mh(e)&&!fh(e,Ar)&&vh(e),e}};iR[Ar]=!0;var dR=Nt,hR=De,pR=ce(ce.bind),Pr=function(e,t){return dR(e),t===void 0?e:hR?pR(e,t):function(){return e.apply(t,arguments)}},fR=_s,mR=ct("iterator"),vR=Array.prototype,gh=function(e){return e!==void 0&&(fR.Array===e||vR[mR]===e)},gR=ei,K_=sr,_R=_s,yR=ct("iterator"),Is=function(e){if(e!=null)return K_(e,yR)||K_(e,"@@iterator")||_R[gR(e)]},bR=Ke,SR=Nt,kR=dt,TR=Er,xR=Is,IR=TypeError,_u=function(e,t){var n=arguments.length<2?xR(e):t;if(SR(n))return kR(bR(n,e));throw IR(TR(e)+" is not iterable")},wR=Ke,Q_=dt,ER=sr,X_=function(e,t,n){var r,i;Q_(e);try{if(!(r=ER(e,"return"))){if(t==="throw")throw n;return n}r=wR(r,e)}catch(o){i=!0,r=o}if(t==="throw")throw n;if(i)throw r;return Q_(r),n},CR=Pr,RR=Ke,AR=dt,PR=Er,DR=gh,LR=Zt,Y_=zn,OR=_u,MR=Is,$_=X_,NR=TypeError,yu=function(e,t){this.stopped=e,this.result=t},Z_=yu.prototype,ws=function(e,t,n){var r,i,o,a,s,c,u,d=n&&n.that,p=!(!n||!n.AS_ENTRIES),h=!(!n||!n.IS_RECORD),f=!(!n||!n.IS_ITERATOR),_=!(!n||!n.INTERRUPTED),y=CR(t,d),S=function(R){return r&&$_(r,"normal",R),new yu(!0,R)},E=function(R){return p?(AR(R),_?y(R[0],R[1],S):y(R[0],R[1])):_?y(R,S):y(R)};if(h)r=e.iterator;else if(f)r=e;else{if(!(i=MR(e)))throw NR(PR(e)+" is not iterable");if(DR(i)){for(o=0,a=LR(e);a>o;o++)if((s=E(e[o]))&&Y_(Z_,s))return s;return new yu(!1)}r=OR(e,i)}for(c=h?e.next:r.next;!(u=RR(c,r)).done;){try{s=E(u.value)}catch(R){$_(r,"throw",R)}if(typeof s=="object"&&s&&Y_(Z_,s))return s}return new yu(!1)},VR=zn,UR=TypeError,ti=function(e,t){if(VR(t,e))return e;throw UR("Incorrect invocation")},ey=ct("iterator"),ty=!1;try{var BR=0,ny={next:function(){return{done:!!BR++}},return:function(){ty=!0}};ny[ey]=function(){return this},Array.from(ny,function(){throw 2})}catch(e){}var _h=function(e,t){if(!t&&!ty)return!1;var n=!1;try{var r={};r[ey]=function(){return{next:function(){return{done:n=!0}}}},e(r)}catch(i){}return n},jR=We,FR=yt,ry=Ta,bu=function(e,t,n){var r,i;return ry&&jR(r=t.constructor)&&r!==n&&FR(i=r.prototype)&&i!==n.prototype&&ry(e,i),e},GR=Oe,HR=Z,zR=ce,iy=fs,WR=Wt,JR=ks.exports,qR=ws,KR=ti,QR=We,yh=yt,bh=ie,XR=_h,YR=Ni,$R=bu,Sh=function(e,t,n){var r=e.indexOf("Map")!==-1,i=e.indexOf("Weak")!==-1,o=r?"set":"add",a=HR[e],s=a&&a.prototype,c=a,u={},d=function(S){var E=zR(s[S]);WR(s,S,S=="add"?function(R){return E(this,R===0?0:R),this}:S=="delete"?function(R){return!(i&&!yh(R))&&E(this,R===0?0:R)}:S=="get"?function(R){return i&&!yh(R)?void 0:E(this,R===0?0:R)}:S=="has"?function(R){return!(i&&!yh(R))&&E(this,R===0?0:R)}:function(R,H){return E(this,R===0?0:R,H),this})};if(iy(e,!QR(a)||!(i||s.forEach&&!bh(function(){new a().entries().next()}))))c=n.getConstructor(t,e,r,o),JR.enable();else if(iy(e,!0)){var p=new c,h=p[o](i?{}:-0,1)!=p,f=bh(function(){p.has(1)}),_=XR(function(S){new a(S)}),y=!i&&bh(function(){for(var S=new a,E=5;E--;)S[o](E,E);return!S.has(-0)});_||((c=t(function(S,E){KR(S,s);var R=$R(new a,S,c);return E!=null&&qR(E,R[o],{that:R,AS_ENTRIES:r}),R})).prototype=s,s.constructor=c),(f||y)&&(d("delete"),d("has"),r&&d("get")),(y||h)&&d(o),i&&s.clear&&delete s.clear}return u[e]=c,GR({global:!0,constructor:!0,forced:c!=a},u),YR(c,e),i||n.setStrong(c,e,r),c},ZR=Wt,Es=function(e,t,n){for(var r in t)ZR(e,r,t[r],n);return e},eA=Rn,tA=At,nA=_e,ay=ct("species"),Cs=function(e){var t=eA(e),n=tA.f;nA&&t&&!t[ay]&&n(t,ay,{configurable:!0,get:function(){return this}})},rA=At.f,iA=ka,oy=Es,aA=Pr,oA=ti,sA=ws,cA=lh,uA=Cs,Rs=_e,sy=ks.exports.fastKey,cy=Qe.set,kh=Qe.getterFor,uy={getConstructor:function(e,t,n,r){var i=e(function(u,d){oA(u,o),cy(u,{type:t,index:iA(null),first:void 0,last:void 0,size:0}),Rs||(u.size=0),d!=null&&sA(d,u[r],{that:u,AS_ENTRIES:n})}),o=i.prototype,a=kh(t),s=function(u,d,p){var h,f,_=a(u),y=c(u,d);return y?y.value=p:(_.last=y={index:f=sy(d,!0),key:d,value:p,previous:h=_.last,next:void 0,removed:!1},_.first||(_.first=y),h&&(h.next=y),Rs?_.size++:u.size++,f!=="F"&&(_.index[f]=y)),u},c=function(u,d){var p,h=a(u),f=sy(d);if(f!=="F")return h.index[f];for(p=h.first;p;p=p.next)if(p.key==d)return p};return oy(o,{clear:function(){for(var u=a(this),d=u.index,p=u.first;p;)p.removed=!0,p.previous&&(p.previous=p.previous.next=void 0),delete d[p.index],p=p.next;u.first=u.last=void 0,Rs?u.size=0:this.size=0},delete:function(u){var d=this,p=a(d),h=c(d,u);if(h){var f=h.next,_=h.previous;delete p.index[h.index],h.removed=!0,_&&(_.next=f),f&&(f.previous=_),p.first==h&&(p.first=f),p.last==h&&(p.last=_),Rs?p.size--:d.size--}return!!h},forEach:function(u){for(var d,p=a(this),h=aA(u,arguments.length>1?arguments[1]:void 0);d=d?d.next:p.first;)for(h(d.value,d.key,this);d&&d.removed;)d=d.previous},has:function(u){return!!c(this,u)}}),oy(o,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)}}),Rs&&rA(o,"size",{get:function(){return a(this).size}}),i},setStrong:function(e,t,n){var r=t+" Iterator",i=kh(t),o=kh(r);cA(e,t,function(a,s){cy(this,{type:r,target:a,state:i(a),kind:s,last:void 0})},function(){for(var a=o(this),s=a.kind,c=a.last;c&&c.removed;)c=c.previous;return a.target&&(a.last=c=c?c.next:a.state.first)?s=="keys"?{value:c.key,done:!1}:s=="values"?{value:c.value,done:!1}:{value:[c.key,c.value],done:!1}:(a.target=void 0,{value:void 0,done:!0})},n?"entries":"values",!n,!0),uA(t)}};Sh("Set",function(e){return function(){return e(this,arguments.length?arguments[0]:void 0)}},uy);var lA=ei,dA=String,Vt=function(e){if(lA(e)==="Symbol")throw TypeError("Cannot convert a Symbol value to a string");return dA(e)},Th=ce,hA=Kn,pA=Vt,fA=Ct,mA=Th("".charAt),ly=Th("".charCodeAt),vA=Th("".slice),dy=function(e){return function(t,n){var r,i,o=pA(fA(t)),a=hA(n),s=o.length;return a<0||a>=s?e?"":void 0:(r=ly(o,a))<55296||r>56319||a+1===s||(i=ly(o,a+1))<56320||i>57343?e?mA(o,a):r:e?vA(o,a,a+2):i-56320+(r-55296<<10)+65536}},xh={codeAt:dy(!1),charAt:dy(!0)},gA=xh.charAt,_A=Vt,hy=Qe,yA=lh,py="String Iterator",bA=hy.set,SA=hy.getterFor(py);yA(String,"String",function(e){bA(this,{type:py,string:_A(e),index:0})},function(){var e,t=SA(this),n=t.string,r=t.index;return r>=n.length?{value:void 0,done:!0}:(e=gA(n,r),t.index+=e.length,{value:e,done:!1})});var fy={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},Ih=Cr("span").classList,my=Ih&&Ih.constructor&&Ih.constructor.prototype,vy=my===Object.prototype?void 0:my,gy=Z,_y=fy,kA=vy,As=U_,wh=yn,yy=ct,Eh=yy("iterator"),by=yy("toStringTag"),Ch=As.values,Sy=function(e,t){if(e){if(e[Eh]!==Ch)try{wh(e,Eh,Ch)}catch(r){e[Eh]=Ch}if(e[by]||wh(e,by,t),_y[t]){for(var n in As)if(e[n]!==As[n])try{wh(e,n,As[n])}catch(r){e[n]=As[n]}}}};for(var Rh in _y)Sy(gy[Rh]&&gy[Rh].prototype,Rh);Sy(kA,"DOMTokenList");var TA=De,ky=Function.prototype,Ty=ky.apply,xy=ky.call,ni=typeof Reflect=="object"&&Reflect.apply||(TA?xy.bind(Ty):function(){return xy.apply(Ty,arguments)}),xa=ce([].slice),xA=TypeError,Su=function(e,t){if(e<t)throw xA("Not enough arguments");return e},Ah=Z,IA=ni,wA=We,EA=xa,CA=Su,RA=/MSIE .\./.test(mn),AA=Ah.Function,Iy=function(e){return RA?function(t,n){var r=CA(arguments.length,1)>2,i=wA(t)?t:AA(t),o=r?EA(arguments,2):void 0;return e(r?function(){IA(i,this,o)}:i,n)}:e},wy={setTimeout:Iy(Ah.setTimeout),setInterval:Iy(Ah.setInterval)},Ey=wy.setInterval;Oe({global:!0,bind:!0,forced:Z.setInterval!==Ey},{setInterval:Ey});var Cy=wy.setTimeout;Oe({global:!0,bind:!0,forced:Z.setTimeout!==Cy},{setTimeout:Cy}),Sh("Map",function(e){return function(){return e(this,arguments.length?arguments[0]:void 0)}},uy);var PA=vt,Ps=Array.isArray||function(e){return PA(e)=="Array"},DA=ce,LA=ie,Ry=We,OA=ei,MA=ga,Ay=function(){},NA=[],Py=Rn("Reflect","construct"),Ph=/^\s*(?:class|function)\b/,VA=DA(Ph.exec),UA=!Ph.exec(Ay),Ds=function(e){if(!Ry(e))return!1;try{return Py(Ay,NA,e),!0}catch(t){return!1}},Dy=function(e){if(!Ry(e))return!1;switch(OA(e)){case"AsyncFunction":case"GeneratorFunction":case"AsyncGeneratorFunction":return!1}try{return UA||!!VA(Ph,MA(e))}catch(t){return!0}};Dy.sham=!0;var ku=!Py||LA(function(){var e;return Ds(Ds.call)||!Ds(Object)||!Ds(function(){e=!0})||e})?Dy:Ds,Ly=Ps,BA=ku,jA=yt,FA=ct("species"),Oy=Array,GA=function(e){var t;return Ly(e)&&(t=e.constructor,(BA(t)&&(t===Oy||Ly(t.prototype))||jA(t)&&(t=t[FA])===null)&&(t=void 0)),t===void 0?Oy:t},Dh=function(e,t){return new(GA(e))(t===0?0:t)},HA=Pr,zA=Cn,WA=Rt,JA=Zt,qA=Dh,My=ce([].push),ri=function(e){var t=e==1,n=e==2,r=e==3,i=e==4,o=e==6,a=e==7,s=e==5||o;return function(c,u,d,p){for(var h,f,_=WA(c),y=zA(_),S=HA(u,d),E=JA(y),R=0,H=p||qA,Y=t?H(c,E):n||a?H(c,0):void 0;E>R;R++)if((s||R in y)&&(f=S(h=y[R],R,_),e))if(t)Y[R]=f;else if(f)switch(e){case 3:return!0;case 5:return h;case 6:return R;case 2:My(Y,h)}else switch(e){case 4:return!1;case 7:My(Y,h)}return o?-1:r||i?i:Y}},en={forEach:ri(0),map:ri(1),filter:ri(2),some:ri(3),every:ri(4),find:ri(5),findIndex:ri(6),filterReject:ri(7)},KA=ie,QA=Jn,XA=ct("species"),Ls=function(e){return QA>=51||!KA(function(){var t=[];return(t.constructor={})[XA]=function(){return{foo:1}},t[e](Boolean).foo!==1})},YA=en.map;Oe({target:"Array",proto:!0,forced:!Ls("map")},{map:function(e){return YA(this,e,arguments.length>1?arguments[1]:void 0)}});var $A=TypeError,Ny=function(e){if(e>9007199254740991)throw $A("Maximum allowed index exceeded");return e},Vy=Er,ZA=TypeError,Uy=function(e,t){if(!delete e[t])throw ZA("Cannot delete property "+Vy(t)+" of "+Vy(e))},e2=Oe,t2=Rt,n2=Zr,r2=Kn,i2=Zt,a2=Ny,o2=Dh,s2=Ts,Lh=Uy,c2=Ls("splice"),u2=Math.max,l2=Math.min;e2({target:"Array",proto:!0,forced:!c2},{splice:function(e,t){var n,r,i,o,a,s,c=t2(this),u=i2(c),d=n2(e,u),p=arguments.length;for(p===0?n=r=0:p===1?(n=0,r=u-d):(n=p-2,r=l2(u2(r2(t),0),u-d)),a2(u+n-r),i=o2(c,r),o=0;o<r;o++)(a=d+o)in c&&s2(i,o,c[a]);if(i.length=r,n<r){for(o=d;o<u-r;o++)s=o+n,(a=o+r)in c?c[s]=c[a]:Lh(c,s);for(o=u;o>u-r+n;o--)Lh(c,o-1)}else if(n>r)for(o=u-r;o>d;o--)s=o+n-1,(a=o+r-1)in c?c[s]=c[a]:Lh(c,s);for(o=0;o<n;o++)c[o+d]=arguments[o+2];return c.length=u-r+n,i}});var d2=ie,Os=function(e,t){var n=[][e];return!!n&&d2(function(){n.call(null,t||function(){return 1},1)})},h2=en.forEach,Oh=Os("forEach")?[].forEach:function(e){return h2(this,e,arguments.length>1?arguments[1]:void 0)};Oe({target:"Array",proto:!0,forced:[].forEach!=Oh},{forEach:Oh});var By=Z,jy=fy,p2=vy,Mh=Oh,f2=yn,Fy=function(e){if(e&&e.forEach!==Mh)try{f2(e,"forEach",Mh)}catch(t){e.forEach=Mh}};for(var Nh in jy)jy[Nh]&&Fy(By[Nh]&&By[Nh].prototype);Fy(p2);var m2=Oe,v2=Cn,g2=it,_2=Os,y2=ce([].join),b2=v2!=Object,S2=_2("join",",");m2({target:"Array",proto:!0,forced:b2||!S2},{join:function(e){return y2(g2(this),e===void 0?",":e)}});var k2=en.filter;Oe({target:"Array",proto:!0,forced:!Ls("filter")},{filter:function(e){return k2(this,e,arguments.length>1?arguments[1]:void 0)}});var T2=Oe,x2=ie,I2=Ps,w2=yt,E2=Rt,C2=Zt,Gy=Ny,Hy=Ts,R2=Dh,A2=Ls,P2=Jn,zy=ct("isConcatSpreadable"),D2=P2>=51||!x2(function(){var e=[];return e[zy]=!1,e.concat()[0]!==e}),L2=A2("concat"),O2=function(e){if(!w2(e))return!1;var t=e[zy];return t!==void 0?!!t:I2(e)};T2({target:"Array",proto:!0,arity:1,forced:!D2||!L2},{concat:function(e){var t,n,r,i,o,a=E2(this),s=R2(a,0),c=0;for(t=-1,r=arguments.length;t<r;t++)if(O2(o=t===-1?a:arguments[t]))for(i=C2(o),Gy(c+i),n=0;n<i;n++,c++)n in o&&Hy(s,c,o[n]);else Gy(c+1),Hy(s,c++,o);return s.length=c,s}});var Wy=ce,M2=Wt,Vh=Date.prototype,Jy="Invalid Date",N2="toString",V2=Wy(Vh.toString),U2=Wy(Vh.getTime);String(new Date(NaN))!=Jy&&M2(Vh,N2,function(){var e=U2(this);return e==e?V2(this):Jy});var B2=Kn,j2=Vt,F2=Ct,G2=RangeError,qy=function(e){var t=j2(F2(this)),n="",r=B2(e);if(r<0||r==1/0)throw G2("Wrong number of repetitions");for(;r>0;(r>>>=1)&&(t+=t))1&r&&(n+=t);return n},Ky=ce,H2=Qn,Qy=Vt,z2=Ct,W2=Ky(qy),J2=Ky("".slice),q2=Math.ceil,Xy=function(e){return function(t,n,r){var i,o,a=Qy(z2(t)),s=H2(n),c=a.length,u=r===void 0?" ":Qy(r);return s<=c||u==""?a:((o=W2(u,q2((i=s-c)/u.length))).length>i&&(o=J2(o,0,i)),e?a+o:o+a)}},K2={start:Xy(!1),end:Xy(!0)},Q2=/Version\/10(?:\.\d+){1,2}(?: [\w./]+)?(?: Mobile\/\w+)? Safari\//.test(mn),X2=K2.start;Oe({target:"String",proto:!0,forced:Q2},{padStart:function(e){return X2(this,e,arguments.length>1?arguments[1]:void 0)}});var Y2=dt,Yy=function(){var e=Y2(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},Uh=ie,Bh=Z.RegExp,jh=Uh(function(){var e=Bh("a","y");return e.lastIndex=2,e.exec("abcd")!=null}),$2=jh||Uh(function(){return!Bh("a","y").sticky}),Fh={BROKEN_CARET:jh||Uh(function(){var e=Bh("^r","gy");return e.lastIndex=2,e.exec("str")!=null}),MISSED_STICKY:$2,UNSUPPORTED_Y:jh},Z2=ie,eP=Z.RegExp,$y=Z2(function(){var e=eP(".","s");return!(e.dotAll&&e.exec(`
76
+ `)&&e.flags==="s")}),tP=ie,nP=Z.RegExp,Zy=tP(function(){var e=nP("(?<a>b)","g");return e.exec("b").groups.a!=="b"||"b".replace(e,"$<a>c")!=="bc"}),Ia=Ke,Tu=ce,rP=Vt,iP=Yy,aP=Fh,oP=cn.exports,sP=ka,cP=Qe.get,uP=$y,lP=Zy,dP=oP("native-string-replace",String.prototype.replace),xu=RegExp.prototype.exec,Gh=xu,hP=Tu("".charAt),pP=Tu("".indexOf),fP=Tu("".replace),Hh=Tu("".slice),zh=function(){var e=/a/,t=/b*/g;return Ia(xu,e,"a"),Ia(xu,t,"a"),e.lastIndex!==0||t.lastIndex!==0}(),e0=aP.BROKEN_CARET,Wh=/()??/.exec("")[1]!==void 0;(zh||Wh||e0||uP||lP)&&(Gh=function(e){var t,n,r,i,o,a,s,c=this,u=cP(c),d=rP(e),p=u.raw;if(p)return p.lastIndex=c.lastIndex,t=Ia(Gh,p,d),c.lastIndex=p.lastIndex,t;var h=u.groups,f=e0&&c.sticky,_=Ia(iP,c),y=c.source,S=0,E=d;if(f&&(_=fP(_,"y",""),pP(_,"g")===-1&&(_+="g"),E=Hh(d,c.lastIndex),c.lastIndex>0&&(!c.multiline||c.multiline&&hP(d,c.lastIndex-1)!==`
77
+ `)&&(y="(?: "+y+")",E=" "+E,S++),n=new RegExp("^(?:"+y+")",_)),Wh&&(n=new RegExp("^"+y+"$(?!\\s)",_)),zh&&(r=c.lastIndex),i=Ia(xu,f?n:c,E),f?i?(i.input=Hh(i.input,S),i[0]=Hh(i[0],S),i.index=c.lastIndex,c.lastIndex+=i[0].length):c.lastIndex=0:zh&&i&&(c.lastIndex=c.global?i.index+i[0].length:r),Wh&&i&&i.length>1&&Ia(dP,i[0],n,function(){for(o=1;o<arguments.length-2;o++)arguments[o]===void 0&&(i[o]=void 0)}),i&&h)for(i.groups=a=sP(null),o=0;o<h.length;o++)a[(s=h[o])[0]]=i[s[1]];return i});var Ms=Gh;Oe({target:"RegExp",proto:!0,forced:/./.exec!==Ms},{exec:Ms});var t0=ce,n0=Wt,mP=Ms,r0=ie,i0=ct,vP=yn,gP=i0("species"),Jh=RegExp.prototype,Iu=function(e,t,n,r){var i=i0(e),o=!r0(function(){var u={};return u[i]=function(){return 7},""[e](u)!=7}),a=o&&!r0(function(){var u=!1,d=/a/;return e==="split"&&((d={}).constructor={},d.constructor[gP]=function(){return d},d.flags="",d[i]=/./[i]),d.exec=function(){return u=!0,null},d[i](""),!u});if(!o||!a||n){var s=t0(/./[i]),c=t(i,""[e],function(u,d,p,h,f){var _=t0(u),y=d.exec;return y===mP||y===Jh.exec?o&&!f?{done:!0,value:s(d,p,h)}:{done:!0,value:_(p,d,h)}:{done:!1}});n0(String.prototype,e,c[0]),n0(Jh,i,c[1])}r&&vP(Jh[i],"sham",!0)},_P=xh.charAt,qh=function(e,t,n){return t+(n?_P(e,t).length:1)},Kh=ce,yP=Rt,bP=Math.floor,Qh=Kh("".charAt),SP=Kh("".replace),Xh=Kh("".slice),kP=/\$([$&'`]|\d{1,2}|<[^>]*>)/g,TP=/\$([$&'`]|\d{1,2})/g,a0=Ke,xP=dt,IP=We,wP=vt,EP=Ms,CP=TypeError,wu=function(e,t){var n=e.exec;if(IP(n)){var r=a0(n,e,t);return r!==null&&xP(r),r}if(wP(e)==="RegExp")return a0(EP,e,t);throw CP("RegExp#exec called on incompatible receiver")},RP=ni,o0=Ke,Eu=ce,AP=Iu,PP=ie,DP=dt,LP=We,OP=Kn,MP=Qn,wa=Vt,NP=Ct,VP=qh,UP=sr,BP=function(e,t,n,r,i,o){var a=n+e.length,s=r.length,c=TP;return i!==void 0&&(i=yP(i),c=kP),SP(o,c,function(u,d){var p;switch(Qh(d,0)){case"$":return"$";case"&":return e;case"`":return Xh(t,0,n);case"'":return Xh(t,a);case"<":p=i[Xh(d,1,-1)];break;default:var h=+d;if(h===0)return u;if(h>s){var f=bP(h/10);return f===0?u:f<=s?r[f-1]===void 0?Qh(d,1):r[f-1]+Qh(d,1):u}p=r[h-1]}return p===void 0?"":p})},jP=wu,Yh=ct("replace"),FP=Math.max,GP=Math.min,HP=Eu([].concat),$h=Eu([].push),s0=Eu("".indexOf),c0=Eu("".slice),zP="a".replace(/./,"$0")==="$0",u0=!!/./[Yh]&&/./[Yh]("a","$0")==="",WP=!PP(function(){var e=/./;return e.exec=function(){var t=[];return t.groups={a:"7"},t},"".replace(e,"$<a>")!=="7"});AP("replace",function(e,t,n){var r=u0?"$":"$0";return[function(i,o){var a=NP(this),s=i==null?void 0:UP(i,Yh);return s?o0(s,i,a,o):o0(t,wa(a),i,o)},function(i,o){var a=DP(this),s=wa(i);if(typeof o=="string"&&s0(o,r)===-1&&s0(o,"$<")===-1){var c=n(t,a,s,o);if(c.done)return c.value}var u=LP(o);u||(o=wa(o));var d=a.global;if(d){var p=a.unicode;a.lastIndex=0}for(var h=[];;){var f=jP(a,s);if(f===null||($h(h,f),!d))break;wa(f[0])===""&&(a.lastIndex=VP(s,MP(a.lastIndex),p))}for(var _,y="",S=0,E=0;E<h.length;E++){for(var R=wa((f=h[E])[0]),H=FP(GP(OP(f.index),s.length),0),Y=[],ue=1;ue<f.length;ue++)$h(Y,(_=f[ue])===void 0?_:String(_));var le=f.groups;if(u){var O=HP([R],Y,H,s);le!==void 0&&$h(O,le);var k=wa(RP(o,void 0,O))}else k=BP(R,s,H,Y,le,o);H>=S&&(y+=c0(s,S,H)+k,S=H+R.length)}return y+c0(s,S)}]},!WP||!zP||u0);var JP=Ke,qP=kt,KP=zn,QP=Yy,l0=RegExp.prototype,d0=function(e){var t=e.flags;return t!==void 0||"flags"in l0||qP(e,"flags")||!KP(l0,e)?t:JP(QP,e)},XP=dr.PROPER,YP=Wt,$P=dt,h0=Vt,ZP=ie,eD=d0,p0="toString",f0=RegExp.prototype.toString,tD=ZP(function(){return f0.call({source:"a",flags:"b"})!="/a/b"}),nD=XP&&f0.name!=p0;(tD||nD)&&YP(RegExp.prototype,p0,function(){var e=$P(this);return"/"+h0(e.source)+"/"+h0(eD(e))},{unsafe:!0});var rD=ie,iD=ct("iterator"),m0=!rD(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(r,i){t.delete("b"),n+=i+r}),!t.sort||e.href!=="http://a/c%20d?a=1&c=3"||t.get("c")!=="3"||String(new URLSearchParams("?a=1"))!=="a=1"||!t[iD]||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"}),v0=xs,aD=Math.floor,Zh=function(e,t){var n=e.length,r=aD(n/2);return n<8?oD(e,t):sD(e,Zh(v0(e,0,r),t),Zh(v0(e,r),t),t)},oD=function(e,t){for(var n,r,i=e.length,o=1;o<i;){for(r=o,n=e[o];r&&t(e[r-1],n)>0;)e[r]=e[--r];r!==o++&&(e[r]=n)}return e},sD=function(e,t,n,r){for(var i=t.length,o=n.length,a=0,s=0;a<i||s<o;)e[a+s]=a<i&&s<o?r(t[a],n[s])<=0?t[a++]:n[s++]:a<i?t[a++]:n[s++];return e},g0=Zh,ep=Oe,Ea=Z,Cu=Ke,pr=ce,cD=_e,_0=m0,y0=Wt,uD=Es,lD=Ni,dD=R_,tp=Qe,b0=ti,np=We,hD=kt,pD=Pr,fD=ei,mD=dt,S0=yt,bn=Vt,vD=ka,k0=Ze,rp=_u,gD=Is,Ca=Su,_D=g0,yD=ct("iterator"),Ru="URLSearchParams",T0="URLSearchParamsIterator",x0=tp.set,Xn=tp.getterFor(Ru),bD=tp.getterFor(T0),SD=Object.getOwnPropertyDescriptor,ip=function(e){if(!cD)return Ea[e];var t=SD(Ea,e);return t&&t.value},I0=ip("fetch"),Au=ip("Request"),Ns=ip("Headers"),ap=Au&&Au.prototype,w0=Ns&&Ns.prototype,kD=Ea.RegExp,TD=Ea.TypeError,E0=Ea.decodeURIComponent,xD=Ea.encodeURIComponent,ID=pr("".charAt),C0=pr([].join),Vi=pr([].push),op=pr("".replace),wD=pr([].shift),R0=pr([].splice),A0=pr("".split),ED=pr("".slice),CD=/\+/g,P0=Array(4),RD=function(e){return P0[e-1]||(P0[e-1]=kD("((?:%[\\da-f]{2}){"+e+"})","gi"))},AD=function(e){try{return E0(e)}catch(t){return e}},D0=function(e){var t=op(e,CD," "),n=4;try{return E0(t)}catch(r){for(;n;)t=op(t,RD(n--),AD);return t}},PD=/[!'()~]|%20/g,DD={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+"},LD=function(e){return DD[e]},L0=function(e){return op(xD(e),PD,LD)},sp=dD(function(e,t){x0(this,{type:T0,iterator:rp(Xn(e).entries),kind:t})},"Iterator",function(){var e=bD(this),t=e.kind,n=e.iterator.next(),r=n.value;return n.done||(n.value=t==="keys"?r.key:t==="values"?r.value:[r.key,r.value]),n},!0),O0=function(e){this.entries=[],this.url=null,e!==void 0&&(S0(e)?this.parseObject(e):this.parseQuery(typeof e=="string"?ID(e,0)==="?"?ED(e,1):e:bn(e)))};O0.prototype={type:Ru,bindURL:function(e){this.url=e,this.update()},parseObject:function(e){var t,n,r,i,o,a,s,c=gD(e);if(c)for(n=(t=rp(e,c)).next;!(r=Cu(n,t)).done;){if(o=(i=rp(mD(r.value))).next,(a=Cu(o,i)).done||(s=Cu(o,i)).done||!Cu(o,i).done)throw TD("Expected sequence with length 2");Vi(this.entries,{key:bn(a.value),value:bn(s.value)})}else for(var u in e)hD(e,u)&&Vi(this.entries,{key:u,value:bn(e[u])})},parseQuery:function(e){if(e)for(var t,n,r=A0(e,"&"),i=0;i<r.length;)(t=r[i++]).length&&(n=A0(t,"="),Vi(this.entries,{key:D0(wD(n)),value:D0(C0(n,"="))}))},serialize:function(){for(var e,t=this.entries,n=[],r=0;r<t.length;)e=t[r++],Vi(n,L0(e.key)+"="+L0(e.value));return C0(n,"&")},update:function(){this.entries.length=0,this.parseQuery(this.url.query)},updateURL:function(){this.url&&this.url.update()}};var Pu=function(){b0(this,Vs);var e=arguments.length>0?arguments[0]:void 0;x0(this,new O0(e))},Vs=Pu.prototype;if(uD(Vs,{append:function(e,t){Ca(arguments.length,2);var n=Xn(this);Vi(n.entries,{key:bn(e),value:bn(t)}),n.updateURL()},delete:function(e){Ca(arguments.length,1);for(var t=Xn(this),n=t.entries,r=bn(e),i=0;i<n.length;)n[i].key===r?R0(n,i,1):i++;t.updateURL()},get:function(e){Ca(arguments.length,1);for(var t=Xn(this).entries,n=bn(e),r=0;r<t.length;r++)if(t[r].key===n)return t[r].value;return null},getAll:function(e){Ca(arguments.length,1);for(var t=Xn(this).entries,n=bn(e),r=[],i=0;i<t.length;i++)t[i].key===n&&Vi(r,t[i].value);return r},has:function(e){Ca(arguments.length,1);for(var t=Xn(this).entries,n=bn(e),r=0;r<t.length;)if(t[r++].key===n)return!0;return!1},set:function(e,t){Ca(arguments.length,1);for(var n,r=Xn(this),i=r.entries,o=!1,a=bn(e),s=bn(t),c=0;c<i.length;c++)(n=i[c]).key===a&&(o?R0(i,c--,1):(o=!0,n.value=s));o||Vi(i,{key:a,value:s}),r.updateURL()},sort:function(){var e=Xn(this);_D(e.entries,function(t,n){return t.key>n.key?1:-1}),e.updateURL()},forEach:function(e){for(var t,n=Xn(this).entries,r=pD(e,arguments.length>1?arguments[1]:void 0),i=0;i<n.length;)r((t=n[i++]).value,t.key,this)},keys:function(){return new sp(this,"keys")},values:function(){return new sp(this,"values")},entries:function(){return new sp(this,"entries")}},{enumerable:!0}),y0(Vs,yD,Vs.entries,{name:"entries"}),y0(Vs,"toString",function(){return Xn(this).serialize()},{enumerable:!0}),lD(Pu,Ru),ep({global:!0,constructor:!0,forced:!_0},{URLSearchParams:Pu}),!_0&&np(Ns)){var OD=pr(w0.has),MD=pr(w0.set),M0=function(e){if(S0(e)){var t,n=e.body;if(fD(n)===Ru)return t=e.headers?new Ns(e.headers):new Ns,OD(t,"content-type")||MD(t,"content-type","application/x-www-form-urlencoded;charset=UTF-8"),vD(e,{body:k0(0,bn(n)),headers:k0(0,t)})}return e};if(np(I0)&&ep({global:!0,enumerable:!0,dontCallGetSet:!0,forced:!0},{fetch:function(e){return I0(e,arguments.length>1?M0(arguments[1]):{})}}),np(Au)){var cp=function(e){return b0(this,ap),new Au(e,arguments.length>1?M0(arguments[1]):{})};ap.constructor=cp,cp.prototype=ap,ep({global:!0,constructor:!0,dontCallGetSet:!0,forced:!0},{Request:cp})}}var ND={URLSearchParams:Pu,getState:Xn},VD=Object.is||function(e,t){return e===t?e!==0||1/e==1/t:e!=e&&t!=t},UD=Ke,BD=dt,jD=Ct,N0=VD,V0=Vt,FD=sr,GD=wu;Iu("search",function(e,t,n){return[function(r){var i=jD(this),o=r==null?void 0:FD(r,e);return o?UD(o,r,i):new RegExp(r)[e](V0(i))},function(r){var i=BD(this),o=V0(r),a=n(t,i,o);if(a.done)return a.value;var s=i.lastIndex;N0(s,0)||(i.lastIndex=0);var c=GD(i,o);return N0(i.lastIndex,s)||(i.lastIndex=s),c===null?-1:c.index}]}),new Date().getTime();var up=0,tn=function(){return new Date().getTime()+up},U0=function(){var e=new Date;return e.setTime(tn()),e.toLocaleString()},HD=Ke,zD=dt,WD=Qn,lp=Vt,JD=Ct,qD=sr,KD=qh,B0=wu;Iu("match",function(e,t,n){return[function(r){var i=JD(this),o=r==null?void 0:qD(r,e);return o?HD(o,r,i):new RegExp(r)[e](lp(i))},function(r){var i=zD(this),o=lp(r),a=n(t,i,o);if(a.done)return a.value;if(!i.global)return B0(i,o);var s=i.unicode;i.lastIndex=0;for(var c,u=[],d=0;(c=B0(i,o))!==null;){var p=lp(c[0]);u[d]=p,p===""&&(i.lastIndex=KD(o,WD(i.lastIndex),s)),d++}return d===0?null:u}]});var QD=yt,XD=vt,YD=ct("match"),dp=function(e){var t;return QD(e)&&((t=e[YD])!==void 0?!!t:XD(e)=="RegExp")},$D=At.f,ZD=_e,hp=Z,Us=ce,eL=fs,tL=bu,nL=yn,rL=$r.f,j0=zn,iL=dp,F0=Vt,aL=d0,G0=Fh,oL=function(e,t,n){n in e||$D(e,n,{configurable:!0,get:function(){return t[n]},set:function(r){t[n]=r}})},sL=Wt,cL=ie,uL=kt,lL=Qe.enforce,dL=Cs,H0=$y,z0=Zy,hL=ct("match"),ii=hp.RegExp,Ra=ii.prototype,pL=hp.SyntaxError,fL=Us(Ra.exec),Du=Us("".charAt),W0=Us("".replace),J0=Us("".indexOf),mL=Us("".slice),vL=/^\?<[^\s\d!#%&*+<=>@^][^\s!#%&*+<=>@^]*>/,Ui=/a/g,pp=/a/g,gL=new ii(Ui)!==Ui,q0=G0.MISSED_STICKY,_L=G0.UNSUPPORTED_Y,yL=ZD&&(!gL||q0||H0||z0||cL(function(){return pp[hL]=!1,ii(Ui)!=Ui||ii(pp)==pp||ii(Ui,"i")!="/a/i"}));if(eL("RegExp",yL)){for(var Bi=function(e,t){var n,r,i,o,a,s,c=j0(Ra,this),u=iL(e),d=t===void 0,p=[],h=e;if(!c&&u&&d&&e.constructor===Bi)return e;if((u||j0(Ra,e))&&(e=e.source,d&&(t=aL(h))),e=e===void 0?"":F0(e),t=t===void 0?"":F0(t),h=e,H0&&"dotAll"in Ui&&(r=!!t&&J0(t,"s")>-1)&&(t=W0(t,/s/g,"")),n=t,q0&&"sticky"in Ui&&(i=!!t&&J0(t,"y")>-1)&&_L&&(t=W0(t,/y/g,"")),z0&&(o=function(f){for(var _,y=f.length,S=0,E="",R=[],H={},Y=!1,ue=!1,le=0,O="";S<=y;S++){if((_=Du(f,S))==="\\")_+=Du(f,++S);else if(_==="]")Y=!1;else if(!Y)switch(!0){case _==="[":Y=!0;break;case _==="(":fL(vL,mL(f,S+1))&&(S+=2,ue=!0),E+=_,le++;continue;case(_===">"&&ue):if(O===""||uL(H,O))throw new pL("Invalid capture group name");H[O]=!0,R[R.length]=[O,le],ue=!1,O="";continue}ue?O+=_:E+=_}return[E,R]}(e),e=o[0],p=o[1]),a=tL(ii(e,t),c?this:Ra,Bi),(r||i||p.length)&&(s=lL(a),r&&(s.dotAll=!0,s.raw=Bi(function(f){for(var _,y=f.length,S=0,E="",R=!1;S<=y;S++)(_=Du(f,S))!=="\\"?R||_!=="."?(_==="["?R=!0:_==="]"&&(R=!1),E+=_):E+="[\\s\\S]":E+=_+Du(f,++S);return E}(e),n)),i&&(s.sticky=!0),p.length&&(s.groups=p)),e!==h)try{nL(a,"source",h===""?"(?:)":h)}catch(f){}return a},K0=rL(ii),Q0=0;K0.length>Q0;)oL(Bi,ii,K0[Q0++]);Ra.constructor=Bi,Bi.prototype=Ra,sL(hp,"RegExp",Bi,{constructor:!0})}dL("RegExp");var X0=ce(1 .valueOf),Y0=`
78
+ \v\f\r \xA0\u1680\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028\u2029\uFEFF`,bL=Ct,SL=Vt,$0=ce("".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]`,kL=RegExp("^"+Lu+Lu+"*"),TL=RegExp(Lu+Lu+"*$"),fp=function(e){return function(t){var n=SL(bL(t));return 1&e&&(n=$0(n,kL,"")),2&e&&(n=$0(n,TL,"")),n}},Ou={start:fp(1),end:fp(2),trim:fp(3)},xL=_e,mp=Z,Z0=ce,IL=fs,wL=Wt,eb=kt,EL=bu,CL=zn,RL=An,tb=ha,AL=ie,PL=$r.f,DL=ye.f,LL=At.f,OL=X0,ML=Ou.trim,nb="Number",ai=mp.Number,vp=ai.prototype,NL=mp.TypeError,VL=Z0("".slice),Mu=Z0("".charCodeAt),UL=function(e){var t=tb(e,"number");return typeof t=="bigint"?t:BL(t)},BL=function(e){var t,n,r,i,o,a,s,c,u=tb(e,"number");if(RL(u))throw NL("Cannot convert a Symbol value to a number");if(typeof u=="string"&&u.length>2){if(u=ML(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:r=2,i=49;break;case 79:case 111:r=8,i=55;break;default:return+u}for(a=(o=VL(u,2)).length,s=0;s<a;s++)if((c=Mu(o,s))<48||c>i)return NaN;return parseInt(o,r)}}return+u};if(IL(nb,!ai(" 0o1")||!ai("0b1")||ai("+0x1"))){for(var Nu,Aa=function(e){var t=arguments.length<1?0:ai(UL(e)),n=this;return CL(vp,n)&&AL(function(){OL(n)})?EL(Object(t),n,Aa):t},rb=xL?PL(ai):"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(","),gp=0;rb.length>gp;gp++)eb(ai,Nu=rb[gp])&&!eb(Aa,Nu)&&LL(Aa,Nu,DL(ai,Nu));Aa.prototype=vp,vp.constructor=Aa,wL(mp,nb,Aa,{constructor:!0})}var jL=hs.includes,FL=fu;Oe({target:"Array",proto:!0,forced:ie(function(){return!Array(1).includes()})},{includes:function(e){return jL(this,e,arguments.length>1?arguments[1]:void 0)}}),FL("includes");var GL=dp,HL=TypeError,ib=function(e){if(GL(e))throw HL("The method doesn't accept regular expressions");return e},zL=ct("match"),ab=function(e){var t=/./;try{"/./"[e](t)}catch(n){try{return t[zL]=!1,"/./"[e](t)}catch(r){}}return!1},WL=Oe,JL=ib,qL=Ct,ob=Vt,KL=ab,QL=ce("".indexOf);WL({target:"String",proto:!0,forced:!KL("includes")},{includes:function(e){return!!~QL(ob(qL(this)),ob(JL(e)),arguments.length>1?arguments[1]:void 0)}});var XL=Oe,YL=hs.indexOf,$L=Os,_p=ce([].indexOf),sb=!!_p&&1/_p([1],1,-0)<0,ZL=$L("indexOf");XL({target:"Array",proto:!0,forced:sb||!ZL},{indexOf:function(e){var t=arguments.length>1?arguments[1]:void 0;return sb?_p(this,e,t)||0:YL(this,e,t)}});var eO=Rt,cb=ys,tO=x_;Oe({target:"Object",stat:!0,forced:ie(function(){cb(1)}),sham:!tO},{getPrototypeOf:function(e){return cb(eO(e))}});var nO=ni,rO=Nt,iO=dt;Oe({target:"Reflect",stat:!0,forced:!ie(function(){Reflect.apply(function(){})})},{apply:function(e,t,n){return nO(rO(e),t,iO(n))}});var aO=_e,oO=dr.EXISTS,ub=ce,sO=At.f,lb=Function.prototype,cO=ub(lb.toString),db=/function\b(?:\s|\/\*[\S\s]*?\*\/|\/\/[^\n\r]*[\n\r]+)*([^\s(/]*)/,uO=ub(db.exec);aO&&!oO&&sO(lb,"name",{configurable:!0,get:function(){try{return uO(db,cO(this))[1]}catch(e){return""}}});var lO=Oe,hb=Date,dO=ce(hb.prototype.getTime);lO({target:"Date",stat:!0},{now:function(){return dO(new hb)}});var hO=ku,pO=Er,fO=TypeError,pb=function(e){if(hO(e))return e;throw fO(pO(e)+" is not a constructor")},fb=dt,mO=pb,vO=ct("species"),Bs=function(e,t){var n,r=fb(e).constructor;return r===void 0||(n=fb(r)[vO])==null?t:mO(n)},gO=ni,js=Ke,yp=ce,_O=Iu,yO=dp,bO=dt,mb=Ct,SO=Bs,kO=qh,TO=Qn,bp=Vt,xO=sr,vb=xs,gb=wu,IO=Ms,wO=ie,Pa=Fh.UNSUPPORTED_Y,_b=4294967295,EO=Math.min,yb=[].push,CO=yp(/./.exec),Da=yp(yb),Fs=yp("".slice),RO=!wO(function(){var e=/(?:)/,t=e.exec;e.exec=function(){return t.apply(this,arguments)};var n="ab".split(e);return n.length!==2||n[0]!=="a"||n[1]!=="b"});_O("split",function(e,t,n){var r;return r="abbc".split(/(b)*/)[1]=="c"||"test".split(/(?:)/,-1).length!=4||"ab".split(/(?:ab)*/).length!=2||".".split(/(.?)(.?)/).length!=4||".".split(/()()/).length>1||"".split(/.?/).length?function(i,o){var a=bp(mb(this)),s=o===void 0?_b:o>>>0;if(s===0)return[];if(i===void 0)return[a];if(!yO(i))return js(t,a,i,s);for(var c,u,d,p=[],h=(i.ignoreCase?"i":"")+(i.multiline?"m":"")+(i.unicode?"u":"")+(i.sticky?"y":""),f=0,_=new RegExp(i.source,h+"g");(c=js(IO,_,a))&&!((u=_.lastIndex)>f&&(Da(p,Fs(a,f,c.index)),c.length>1&&c.index<a.length&&gO(yb,p,vb(c,1)),d=c[0].length,f=u,p.length>=s));)_.lastIndex===c.index&&_.lastIndex++;return f===a.length?!d&&CO(_,"")||Da(p,""):Da(p,Fs(a,f)),p.length>s?vb(p,0,s):p}:"0".split(void 0,0).length?function(i,o){return i===void 0&&o===0?[]:js(t,this,i,o)}:t,[function(i,o){var a=mb(this),s=i==null?void 0:xO(i,e);return s?js(s,i,a,o):js(r,bp(a),i,o)},function(i,o){var a=bO(this),s=bp(i),c=n(r,a,s,o,r!==t);if(c.done)return c.value;var u=SO(a,RegExp),d=a.unicode,p=(a.ignoreCase?"i":"")+(a.multiline?"m":"")+(a.unicode?"u":"")+(Pa?"g":"y"),h=new u(Pa?"^(?:"+a.source+")":a,p),f=o===void 0?_b:o>>>0;if(f===0)return[];if(s.length===0)return gb(h,s)===null?[s]:[];for(var _=0,y=0,S=[];y<s.length;){h.lastIndex=Pa?0:y;var E,R=gb(h,Pa?Fs(s,y):s);if(R===null||(E=EO(TO(h.lastIndex+(Pa?y:0)),s.length))===_)y=kO(s,y,d);else{if(Da(S,Fs(s,_,y)),S.length===f)return S;for(var H=1;H<=R.length-1;H++)if(Da(S,R[H]),S.length===f)return S;y=_=E}}return Da(S,Fs(s,_)),S}]},!RO,Pa);var Gs,La,bb,Sp,Hs=vt(Z.process)=="process",Sb=/(?:ipad|iphone|ipod).*applewebkit/i.test(mn),Sn=Z,AO=ni,PO=Pr,kb=We,DO=kt,LO=ie,Tb=g_,OO=xa,xb=Cr,MO=Su,NO=Sb,VO=Hs,kp=Sn.setImmediate,Tp=Sn.clearImmediate,UO=Sn.process,xp=Sn.Dispatch,BO=Sn.Function,Ib=Sn.MessageChannel,jO=Sn.String,Ip=0,zs={},FO="onreadystatechange";try{Gs=Sn.location}catch(e){}var wp=function(e){if(DO(zs,e)){var t=zs[e];delete zs[e],t()}},Ep=function(e){return function(){wp(e)}},wb=function(e){wp(e.data)},Eb=function(e){Sn.postMessage(jO(e),Gs.protocol+"//"+Gs.host)};kp&&Tp||(kp=function(e){MO(arguments.length,1);var t=kb(e)?e:BO(e),n=OO(arguments,1);return zs[++Ip]=function(){AO(t,void 0,n)},La(Ip),Ip},Tp=function(e){delete zs[e]},VO?La=function(e){UO.nextTick(Ep(e))}:xp&&xp.now?La=function(e){xp.now(Ep(e))}:Ib&&!NO?(Sp=(bb=new Ib).port2,bb.port1.onmessage=wb,La=PO(Sp.postMessage,Sp)):Sn.addEventListener&&kb(Sn.postMessage)&&!Sn.importScripts&&Gs&&Gs.protocol!=="file:"&&!LO(Eb)?(La=Eb,Sn.addEventListener("message",wb,!1)):La=FO in xb("script")?function(e){Tb.appendChild(xb("script")).onreadystatechange=function(){Tb.removeChild(this),wp(e)}}:function(e){setTimeout(Ep(e),0)});var Ws,ji,Js,Oa,Cp,Rp,Ap,Cb,Rb={set:kp,clear:Tp},GO=Z,HO=/ipad|iphone|ipod/i.test(mn)&&GO.Pebble!==void 0,zO=/web0s(?!.*chrome)/i.test(mn),Fi=Z,Ab=Pr,WO=ye.f,Pp=Rb.set,JO=Sb,qO=HO,KO=zO,Dp=Hs,Pb=Fi.MutationObserver||Fi.WebKitMutationObserver,Db=Fi.document,Lb=Fi.process,Vu=Fi.Promise,Ob=WO(Fi,"queueMicrotask"),Mb=Ob&&Ob.value;Mb||(Ws=function(){var e,t;for(Dp&&(e=Lb.domain)&&e.exit();ji;){t=ji.fn,ji=ji.next;try{t()}catch(n){throw ji?Oa():Js=void 0,n}}Js=void 0,e&&e.enter()},JO||Dp||KO||!Pb||!Db?!qO&&Vu&&Vu.resolve?((Ap=Vu.resolve(void 0)).constructor=Vu,Cb=Ab(Ap.then,Ap),Oa=function(){Cb(Ws)}):Dp?Oa=function(){Lb.nextTick(Ws)}:(Pp=Ab(Pp,Fi),Oa=function(){Pp(Ws)}):(Cp=!0,Rp=Db.createTextNode(""),new Pb(Ws).observe(Rp,{characterData:!0}),Oa=function(){Rp.data=Cp=!Cp}));var QO=Mb||function(e){var t={fn:e,next:void 0};Js&&(Js.next=t),ji||(ji=t,Oa()),Js=t},XO=Z,Lp=function(e){try{return{error:!1,value:e()}}catch(t){return{error:!0,value:t}}},Nb=function(){this.head=null,this.tail=null};Nb.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 YO=Nb,qs=Z.Promise,Vb=typeof Deno=="object"&&Deno&&typeof Deno.version=="object",$O=!Vb&&!Hs&&typeof window=="object"&&typeof document=="object",ZO=Z,Ks=qs,eM=We,tM=fs,nM=ga,rM=ct,iM=$O,aM=Vb,Op=Jn;Ks&&Ks.prototype;var oM=rM("species"),Ub=!1,Bb=eM(ZO.PromiseRejectionEvent),sM=tM("Promise",function(){var e=nM(Ks),t=e!==String(Ks);if(!t&&Op===66)return!0;if(!Op||Op<51||!/native code/.test(e)){var n=new Ks(function(i){i(1)}),r=function(i){i(function(){},function(){})};if((n.constructor={})[oM]=r,!(Ub=n.then(function(){})instanceof r))return!0}return!t&&(iM||aM)&&!Bb}),Gi={CONSTRUCTOR:sM,REJECTION_EVENT:Bb,SUBCLASSING:Ub},Ma={},jb=Nt,cM=function(e){var t,n;this.promise=new e(function(r,i){if(t!==void 0||n!==void 0)throw TypeError("Bad Promise constructor");t=r,n=i}),this.resolve=jb(t),this.reject=jb(n)};Ma.f=function(e){return new cM(e)};var Mp,Fb,Gb,uM=Oe,Uu=Hs,oi=Z,Na=Ke,Hb=Wt,zb=Ta,lM=Ni,dM=Cs,hM=Nt,Bu=We,pM=yt,fM=ti,mM=Bs,Wb=Rb.set,Np=QO,vM=function(e,t){var n=XO.console;n&&n.error&&(arguments.length==1?n.error(e):n.error(e,t))},gM=Lp,_M=YO,Jb=Qe,ju=qs,qb=Ma,Fu="Promise",Kb=Gi.CONSTRUCTOR,yM=Gi.REJECTION_EVENT,bM=Gi.SUBCLASSING,Vp=Jb.getterFor(Fu),SM=Jb.set,Va=ju&&ju.prototype,Ua=ju,Gu=Va,Qb=oi.TypeError,Up=oi.document,Bp=oi.process,jp=qb.f,kM=jp,TM=!!(Up&&Up.createEvent&&oi.dispatchEvent),Xb="unhandledrejection",Yb=function(e){var t;return!(!pM(e)||!Bu(t=e.then))&&t},$b=function(e,t){var n,r,i,o=t.value,a=t.state==1,s=a?e.ok:e.fail,c=e.resolve,u=e.reject,d=e.domain;try{s?(a||(t.rejection===2&&IM(t),t.rejection=1),s===!0?n=o:(d&&d.enter(),n=s(o),d&&(d.exit(),i=!0)),n===e.promise?u(Qb("Promise-chain cycle")):(r=Yb(n))?Na(r,n,c,u):c(n)):u(o)}catch(p){d&&!i&&d.exit(),u(p)}},Zb=function(e,t){e.notified||(e.notified=!0,Np(function(){for(var n,r=e.reactions;n=r.get();)$b(n,e);e.notified=!1,t&&!e.rejection&&xM(e)}))},eS=function(e,t,n){var r,i;TM?((r=Up.createEvent("Event")).promise=t,r.reason=n,r.initEvent(e,!1,!0),oi.dispatchEvent(r)):r={promise:t,reason:n},!yM&&(i=oi["on"+e])?i(r):e===Xb&&vM("Unhandled promise rejection",n)},xM=function(e){Na(Wb,oi,function(){var t,n=e.facade,r=e.value;if(tS(e)&&(t=gM(function(){Uu?Bp.emit("unhandledRejection",r,n):eS(Xb,n,r)}),e.rejection=Uu||tS(e)?2:1,t.error))throw t.value})},tS=function(e){return e.rejection!==1&&!e.parent},IM=function(e){Na(Wb,oi,function(){var t=e.facade;Uu?Bp.emit("rejectionHandled",t):eS("rejectionhandled",t,e.value)})},Ba=function(e,t,n){return function(r){e(t,r,n)}},ja=function(e,t,n){e.done||(e.done=!0,n&&(e=n),e.value=t,e.state=2,Zb(e,!0))},Fp=function(e,t,n){if(!e.done){e.done=!0,n&&(e=n);try{if(e.facade===t)throw Qb("Promise can't be resolved itself");var r=Yb(t);r?Np(function(){var i={done:!1};try{Na(r,t,Ba(Fp,i,e),Ba(ja,i,e))}catch(o){ja(i,o,e)}}):(e.value=t,e.state=1,Zb(e,!1))}catch(i){ja({done:!1},i,e)}}};if(Kb&&(Gu=(Ua=function(e){fM(this,Gu),hM(e),Na(Mp,this);var t=Vp(this);try{e(Ba(Fp,t),Ba(ja,t))}catch(n){ja(t,n)}}).prototype,(Mp=function(e){SM(this,{type:Fu,done:!1,notified:!1,parent:!1,reactions:new _M,rejection:!1,state:0,value:void 0})}).prototype=Hb(Gu,"then",function(e,t){var n=Vp(this),r=jp(mM(this,Ua));return n.parent=!0,r.ok=!Bu(e)||e,r.fail=Bu(t)&&t,r.domain=Uu?Bp.domain:void 0,n.state==0?n.reactions.add(r):Np(function(){$b(r,n)}),r.promise}),Fb=function(){var e=new Mp,t=Vp(e);this.promise=e,this.resolve=Ba(Fp,t),this.reject=Ba(ja,t)},qb.f=jp=function(e){return e===Ua||e===void 0?new Fb(e):kM(e)},Bu(ju)&&Va!==Object.prototype)){Gb=Va.then,bM||Hb(Va,"then",function(e,t){var n=this;return new Ua(function(r,i){Na(Gb,n,r,i)}).then(e,t)},{unsafe:!0});try{delete Va.constructor}catch(e){}zb&&zb(Va,Gu)}uM({global:!0,constructor:!0,wrap:!0,forced:Kb},{Promise:Ua}),lM(Ua,Fu,!1),dM(Fu);var wM=qs,nS=Gi.CONSTRUCTOR||!_h(function(e){wM.all(e).then(void 0,function(){})}),EM=Ke,CM=Nt,RM=Ma,AM=Lp,PM=ws;Oe({target:"Promise",stat:!0,forced:nS},{all:function(e){var t=this,n=RM.f(t),r=n.resolve,i=n.reject,o=AM(function(){var a=CM(t.resolve),s=[],c=0,u=1;PM(e,function(d){var p=c++,h=!1;u++,EM(a,t,d).then(function(f){h||(h=!0,s[p]=f,--u||r(s))},i)}),--u||r(s)});return o.error&&i(o.value),n.promise}});var DM=Oe,LM=Gi.CONSTRUCTOR,Gp=qs,OM=Rn,MM=We,NM=Wt,rS=Gp&&Gp.prototype;if(DM({target:"Promise",proto:!0,forced:LM,real:!0},{catch:function(e){return this.then(void 0,e)}}),MM(Gp)){var iS=OM("Promise").prototype.catch;rS.catch!==iS&&NM(rS,"catch",iS,{unsafe:!0})}var VM=Ke,UM=Nt,BM=Ma,jM=Lp,FM=ws;Oe({target:"Promise",stat:!0,forced:nS},{race:function(e){var t=this,n=BM.f(t),r=n.reject,i=jM(function(){var o=UM(t.resolve);FM(e,function(a){VM(o,t,a).then(n.resolve,r)})});return i.error&&r(i.value),n.promise}});var GM=Ke,HM=Ma;Oe({target:"Promise",stat:!0,forced:Gi.CONSTRUCTOR},{reject:function(e){var t=HM.f(this);return GM(t.reject,void 0,e),t.promise}});var zM=dt,WM=yt,JM=Ma,aS=function(e,t){if(zM(e),WM(t)&&t.constructor===e)return t;var n=JM.f(e);return(0,n.resolve)(t),n.promise},qM=Oe,KM=Gi.CONSTRUCTOR,QM=aS;Rn("Promise"),qM({target:"Promise",stat:!0,forced:KM},{resolve:function(e){return QM(this,e)}});var XM=Rt,oS=du;Oe({target:"Object",stat:!0,forced:ie(function(){oS(1)})},{keys:function(e){return oS(XM(e))}});var sS="canvas",Ce="audio",xe="video",Hp="screen",Dr="small",Hu="big",pt="auxiliary",Ln="aux",zu="smallVideo",cS="user",uS="environment",$t="mute",fr="unmute",Lt="ended",si="playing",ci="pause",Fa="error",zp="loadeddata",Qs="audioinput",Wu="videoinput",lS="detail",YM="text",Ye="main",Hi="backup",$M="banned",ZM="kick",eN="user_time_out",tN="room_disband",dS="sei-message",Ga="PLAYING",mr="PAUSED",ui="STOPPED",Ha="inactive",li="sendonly",Wp="recvonly",hS="add",pS="remove",nN="replace",Jp="track",rN="wss://trtc.rtc.qq.com",iN="wss://webrtc.qq.com",Ju="qcloud",aN="trtc",oN="webrtc",Xs="",fS="jssdk_log",sN="jssdk_event",cN="jssdk_new_endreport",uN=function(e){return Xs=e},lN=1,dN=2,qu="live",za=20,qp=21,vr="anchor",zi="audience",gr="5Y2wZK8nANNAoVw6dSAHVjNxrD1ObBM2kBPV",Ys="224d130c-7b5c-415b-aaa2-79c2eb5a6df2",hN=2,gt=Ye,Pt=pt,Ku="unknown",nn="DISCONNECTED",mS="CONNECTING",vS="RECONNECTING",ln="CONNECTED",pN="new",Qu="connecting",gS="failed",Kp="closed",fN="disconnected",_S="connected",mN="completed",Qp=30,yS="join",vN="delta-join",bS="rejoin",gN="leave",_N="delta-leave",SS="publish",yN="delta-publish",kS="unpublish",TS="subscribe",xS="unsubscribe",IS="uplink-connection",wS="uplink-reconnection",ES="downlink-connection",CS="downlink-reconnection",Xu="setLocalDescription",RS="setRemoteDescription",AS="iceConnectionState",$s="stream-initialize",Xp="websocketConnectionState",PS="websocketReconnectionState",DS="update-stream",LS="recover-subscription",OS="start-mix-transcode",MS="stop-mix-transcode",NS="player-error",VS="schedule",Yp="unsubscribe",$p="subscribe_change",Zs="unified-plan",Zp="plan-b",ef={MANUAL:"manual",PRESET_LAYOUT:"preset-layout"},US={REMOTE:"$PLACE_HOLDER_REMOTE$"},BS={IT_AUDIO_VIDEO:0,IT_PICTURE:2,IT_CANVAS:3,IT_PURE_AUDIO:4,IT_PURE_VIDEO:5},St="string",xt="number",rn="boolean",bN="array",_r="object",an={ADD:hS,REMOVE:pS},tf={unknown:0,wifi:1,"4g":2,"3g":3,"2g":4,wired:5},jS=-1,ec=0,SN=1,FS=Hu,GS=Dr,HS=6048e5,kN="schedule.rtc.qq.com",zS="schedule.rtc.qcloud.com",TN="schedule.rtc.tencentcloud.com",xN="schedule-ecdn.rtc.tencentcloud.com",Yu="",IN=function(e){return Yu=e},wN="TRTC",EN="Client",nf="LocalStream",rf="RemoteStream",CN="Stream",WS="web.sdk.qcloud.com",RN="web.sdk.tencent.cn",AN="web.sdk.cloud.tencent.cn",JS="https://console.cloud.tencent.com/trtc",Wa="https://".concat(WS,"/trtc/webrtc/doc"),af="".concat(Wa,"/zh-cn/"),of="trtc_error_assistance",$u="default",qS="communications",On={TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,NONE:5},Wi=Object.keys(On),PN=["normal leave","timeout leave","kick","role change"],Zu=2e3,Ja="ric",el="raf",DN="interval",KS="timeout",QS="Resolution reset to 1080p, need to upgrade ability here https://cloud.tencent.com/document/product/647/85386",LN=Ct,XS=Vt,ON=/"/g,MN=ce("".replace),YS=function(e,t,n,r){var i=XS(LN(e)),o="<"+t;return n!==""&&(o+=" "+n+'="'+MN(XS(r),ON,"&quot;")+'"'),o+">"+i+"</"+t+">"},NN=ie,$S=function(e){return NN(function(){var t=""[e]('"');return t!==t.toLowerCase()||t.split('"').length>3})},VN=YS;Oe({target:"String",proto:!0,forced:$S("link")},{link:function(e){return VN(this,"a","href",e)}}),Oe({target:"Array",stat:!0},{isArray:Ps});var UN="AVOID_REPEATED_CALL",BN="INVALID_PARAMETER_REQUIRED",ZS="INVALID_PARAMETER_TYPE",jN="INVALID_PARAMETER_EMPTY",ek="INVALID_PARAMETER_INSTANCE",FN="INVALID_PARAMETER_RANGE",GN="API_CALL_TIMEOUT",HN="SIGNAL_CHANNEL_RECONNECTION_FAILED",zN="SIGNAL_CHANNEL_SETUP_FAILED",WN="ERROR_MESSAGE",JN="EXCHANGE_SDP_TIMEOUT",qN="DOWNLINK_RECONNECTION_FAILED",KN="EXCHANGE_SDP_FAILED",QN="UPLINK_RECONNECTION_FAILED",XN="INVALID_PURE_AUDIO",YN="INVALID_STREAMID",$N="INVALID_USER_DEFINE_RECORDID",ZN="INVALID_USER_DEFINE_PUSH_ARGS",e3="INVALID_PROXY",t3="INVALID_JOIN",n3="INVALID_ROOMID_STRING",r3="INVALID_ROOMID_INTEGER",i3="JOIN_ROOM_TIMEOUT",tk="JOIN_ROOM_FAILED",a3="REJOIN_ROOM_FAILED",o3="INVALID_DESTROY",s3="INVALID_PUBLISH",c3="INVALID_UNPUBLISH",u3="INVALID_AUDIENCE",l3="INVALID_INITIALIZE",d3="INVALID_DUPLICATE_PUBLISHING",sf="INVALID_REMOTE_STREAM",h3="SUBSCRIBE_FAILED",p3="INVALID_ROLE",f3="INVALID_OPERATION_SWITCH_ROLE",m3="SWITCH_ROLE_TIMEOUT",v3="SWITCH_ROLE_FAILED",g3="CLIENT_BANNED",nk="INVALID_OPERATION_START_PUBLISH_CDN",_3="INVALID_OPERATION_STOP_PUBLISH_CDN",y3="INVALID_STREAM_ID",rk="START_PUBLISH_CDN_FAILED",ik="STOP_PUBLISH_CDN_FAILED",b3="START_MIX_TRANSCODE",S3="STOP_MIX_TRANSCODE",k3="INVALID_AUDIO_VOLUME",T3="ENABLE_SMALL_STREAM_PUBLISHED",x3="DISABLE_SMALL_STREAM_PUBLISHED",I3="NOT_SUPPORTED_SMALL_STREAM",w3="INVALID_SMALL_STREAM_PROFILE",E3="INVALID_PARAMETER_REMOTE_STREAM",C3="INVALID_SWITCH_DEVICE",R3="INVALID_SWITCH_DEVICE_PUBLISHING",ak="INVALID_REPLACE_TRACK",A3="INVALID_INITIALIZE_LOCAL_STREAM",P3="INVALID_ADD_TRACK_REPETITIVE",D3="INVALID_ADD_TRACK_REMOVING",L3="INVALID_ADD_TRACK_PUBLISHING",ok="INVALID_STREAM_INITIALIZED",O3="INVALID_ADD_TRACK_NUMBER",M3="INVALID_REMOVE_AUDIO_TRACK",N3="INVALID_REMOVE_AUDIO_ADDING",V3="INVALID_REMOVE_AUDIO_ON",U3="INVALID_REMOVE_TRACK_PUBLISHING",B3="INVALID_REMOVE_TRACK_NOT_PUBLISHING",j3="INVALID_REMOVE_TRACK_NUMBER",F3="INVALID_REPLACE_TRACK_NO_TRACK",G3="REPEAT_JOIN",cf="CLIENT_DESTROYED",H3="START_MIX_TRANSCODE_FAILED",z3="STOP_MIX_TRANSCODE_FAILED",W3="MIX_TRANSCODE_NOT_STARTED",J3="CANNOT_LESS_THAN_ZERO",q3="MIX_PARAMS_VIDEO_FRAMERATE",K3="MIX_PARAMS_VIDEO_GOP",Q3="MIX_PARAMS_AUDIO_BITRATE",X3="MIX_PARAMS_USER_Z_ORDER",Y3="MIX_PARAMS_NOT_SELF",$3="MIX_PARAMS_USER_STREAM",Z3="INVALID_ELEMENT_ID",e4="INVALID_ELEMENT_ID_TYPE",uf="PLAY_FAILED",t4="INVALID_CREATE_STREAM_SOURCE",n4="INVALID_CREATE_STREAM_SCREEN",r4="INVALID_CREATE_STREAM_AUDIO",i4="INVALID_CREATE_STREAM_SCREEN_AUDIO",sk="NOT_SUPPORTED_HTTP",ck="NOT_SUPPORTED_WEBRTC",a4="NOT_SUPPORTED_PROFILE",uk="NOT_SUPPORTED_H264ENCODE",lk="NOT_SUPPORTED_H264DECODE",lf="NOT_SUPPORTED_TRACK",o4="NOT_SUPPORTED_SWITCH_DEVICE",s4="NOT_SUPPORTED_CAPTURE",c4="NOT_SUPPORTED_AUX",u4="MICROPHONE_NOT_FOUND",l4="CAMERA_NOT_FOUND",dk="SIGNAL_RESPONSE_FAILED",d4="CATCH_HANDLER_ERROR",h4="API_NOT_EXIST",p4="CONNECTION_CLOSED",f4="SUBSCRIBE_ALL_FALSE",hk="SEI_NOT_SUPPORT",m4="SEI_DISABLED",v4="SEI_EMPTY",g4="SEI_OVERSIZE",_4="SEI_BEFORE_PUBLISH",y4="SEI_NOT_VIDEO",b4="CALL_FREQUENCY_LIMIT",S4="CONNECTION_ABORTED",df="API_CALL_ABORTED",k4="DUPLICATE_AUX",di={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,r=e.fnName,i=e.value;return"'".concat(t||n.name,"' is a required param when calling ").concat(r,"(), received: ").concat(i,".")},INVALID_PARAMETER_TYPE:function(e){var t=e.key,n=e.rule,r=e.fnName,i=e.value,o="".concat(t||n.name),a="";return a=Array.isArray(n.type)?n.type.join("|"):n.type,"'".concat(o,"' must be type of ").concat(a," when calling ").concat(r,"(), received type: ").concat(hi(i),".")},INVALID_PARAMETER_EMPTY:function(e){var t=e.key,n=e.rule,r=e.fnName,i=e.value;return"'".concat(t||n.name,"' cannot be '").concat(i,"' when calling ").concat(r,"().")},INVALID_PARAMETER_INSTANCE:function(e){var t=e.key,n=e.rule,r=e.fnName,i=e.value,o="".concat(t||n.name),a="".concat(n.instanceOf.name||n.instanceOf);return"'".concat(o,"' must be instanceof ").concat(a," when calling ").concat(r,"(), received type: ").concat(hi(i),".")},INVALID_PARAMETER_RANGE:function(e){var t=e.key,n=e.rule,r=e.fnName,i=e.value;return"'".concat(t||n.name,"' must be one of ").concat(n.values.join("|")," when calling ").concat(r,"(), 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(zi,', please call switchRole("').concat(vr,'") 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(vr," 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,r=e.fnName;return e.value,"'".concat(t||n.name,"' cannot be less than 0 when calling ").concat(r,"().")},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,r=e.type;return"the element corresponding to '".concat(t,"' must be instanceof HTMLDivElement when calling ").concat(n,"(), received: ").concat(r,".")},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,r=e.timesInSecond,i=e.maxSizeInSecond;return"api ".concat(n," call ").concat(t?"size":"times"," is over ").concat(t?i+" bytes":r," 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."},pk=Z,T4=ie,x4=Vt,I4=Ou.trim,w4=ce("".charAt),tl=pk.parseFloat,fk=pk.Symbol,mk=fk&&fk.iterator,vk=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||mk&&!T4(function(){tl(Object(mk))})?function(e){var t=I4(x4(e)),n=tl(t);return n===0&&w4(t,0)=="-"?-0:n}:tl;Oe({global:!0,forced:parseFloat!=vk},{parseFloat:vk});var Ee=window.navigator&&window.navigator.userAgent||"",gk=/AppleWebKit\/([\d.]+)/i.exec(Ee);gk&&parseFloat(gk.pop());var hf=/iPad/i.test(Ee),_k=navigator.maxTouchPoints&&navigator.maxTouchPoints>2&&/Macintosh/.test(Ee),pf=/iPhone/i.test(Ee)&&!hf,E4=/iPod/i.test(Ee),Lr=pf||hf||E4||_k,qa=/Android/i.test(Ee);qa&&function(){var e=Ee.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])}(),qa&&/webkit/i.test(Ee);var yr=/Firefox/i.test(Ee),yk=yr&&function(){var e=Ee.match(/Firefox\/(\d+)/);return e&&e[1]?parseFloat(e[1]):null}(),nl=/Edge\//i.test(Ee),C4=nl&&function(){var e=Ee.match(/Edge\/(\d+)/i);if(e&&e[1])return e[1]}(),rl=/Edg\//i.test(Ee),bk=rl&&function(){var e=Ee.match(/Edg\/(\d+)/);return e&&e[1]?parseFloat(e[1]):null}(),ff=/SogouMobileBrowser\//i.test(Ee),R4=ff&&function(){var e=Ee.match(/SogouMobileBrowser\/(\d+)/);return e&&e[1]?parseFloat(e[1]):null}(),mf=/MetaSr\s/i.test(Ee),A4=mf&&function(){var e=Ee.match(/MetaSr(\s\d+(\.\d+)+)/);return e&&e[1]?parseFloat(e[1]):null}(),Or=/TBS\/\d+/i.test(Ee),P4=Or&&function(){var e=Ee.match(/TBS\/(\d+)/i);if(e&&e[1])return e[1]}(),vf=/XWEB\/\d+/i.test(Ee),D4=vf&&function(){var e=Ee.match(/XWEB\/(\d+)/i);if(e&&e[1])return e[1]}();/MSIE\s8\.0/.test(Ee),/MSIE\/\d+/i.test(Ee)&&function(){var e=/MSIE\s(\d+)\.\d/.exec(Ee),t=e&&parseFloat(e[1]);!t&&/Trident\/7.0/i.test(Ee)&&/rv:11.0/.test(Ee)&&(t=11)}();var gf=/(micromessenger|webbrowser)/i.test(Ee),L4=gf&&function(){var e=Ee.match(/MicroMessenger\/(\d+)/i);if(e&&e[1])return e[1]}(),_f=!Or&&/MQQBrowser\/\d+/i.test(Ee)&&/COVC\/\d+/i.test(Ee),yf=!Or&&/MQQBrowser\/\d+/i.test(Ee)&&!/COVC\/\d+/i.test(Ee),Sk=(yf||_f)&&function(){var e=Ee.match(/ MQQBrowser\/([\d.]+)/);return e&&e[1]?e[1]:null}(),bf=!Or&&/ QQBrowser\/\d+/i.test(Ee),O4=bf&&function(){var e=Ee.match(/ QQBrowser\/([\d.]+)/);return e&&e[1]?e[1]:null}(),Sf=!Or&&/QQBrowserLite\/\d+/i.test(Ee),M4=Sf&&function(){var e=Ee.match(/QQBrowserLite\/([\d.]+)/);return e&&e[1]?e[1]:null}(),kf=!Or&&/MQBHD\/\d+/i.test(Ee),N4=kf&&function(){var e=Ee.match(/MQBHD\/([\d.]+)/);return e&&e[1]?e[1]:null}(),kk=/Windows/i.test(Ee),tc=!Lr&&/MAC OS X/i.test(Ee),Tk=!qa&&/Linux/i.test(Ee);/MicroMessenger/i.test(Ee);var V4=/UCBrowser/i.test(Ee);/Electron/i.test(Ee);var xk,il,Tf=/MiuiBrowser/i.test(Ee),U4=Tf&&function(){var e=Ee.match(/MiuiBrowser\/([\d.]+)/);return e&&e[1]?e[1]:null}(),xf=/HuaweiBrowser/i.test(Ee),If=/Huawei/i.test(Ee),B4=xf&&function(){var e=Ee.match(/HuaweiBrowser\/([\d.]+)/);return e&&e[1]?e[1]:null}(),wf=/SamsungBrowser/i.test(Ee),j4=wf&&function(){var e=Ee.match(/SamsungBrowser\/([\d.]+)/);return e&&e[1]?e[1]:null}(),al=/HeyTapBrowser/i.test(Ee),F4=al&&function(){var e=Ee.match(/HeyTapBrowser\/([\d.]+)/);return e&&e[1]?e[1]:null}(),ol=/VivoBrowser/i.test(Ee),G4=ol&&function(){var e=Ee.match(/VivoBrowser\/([\d.]+)/);return e&&e[1]?e[1]:null}(),nc=function(){var e=Ee.match(/Chrome\/(\d+)/);return e&&e[1]?Number(e[1]):null},H4=/Chrome/i.test(Ee),sl=!nl&&!mf&&!ff&&!Or&&!vf&&!rl&&!bf&&!Tf&&!xf&&!wf&&!al&&!ol&&/Chrome/i.test(Ee),Ef=sl&&nc(),z4=sl&&function(){var e=Ee.match(/Chrome\/([\d.]+)/);return e&&e[1]?e[1]:null}(),Ji=!H4&&!yf&&!_f&&!Sf&&!kf&&/Safari/i.test(Ee),Cf=function(){if(Ji){var e=Ee.match(/Version\/([\d.]+)/);if(e&&e[1])return e[1]}return""}(),W4=/Android.*(wv|.0.0.0)/.test(Ee),Mr=function(){if(_k)return Cf;if(Lr){var e=Ee.match(/OS (\d+)_(\d+)/i);if(e&&e[1]){var t=e[1];return e[2]&&(t+=".".concat(e[2])),t}}return""}(),cl=Cf==="15.1",ul=Mr==="15.1",J4=(xk=Number(Mr.split(".")[0]))===14||xk===13,Ka=location.protocol==="file:"||location.hostname==="localhost"||location.hostname==="127.0.0.1",qi=function(){if(fe(il))try{il=window.localStorage}catch(e){be.warn(e),il=!1}return il},Rf=new Map([[yr,["Firefox",yk]],[rl,["Edg",bk]],[sl,["Chrome",z4]],[Ji,["Safari",Cf]],[Or,["TBS",P4]],[vf,["XWEB",D4]],[gf&&pf,["WeChat",L4]],[bf,["QQ(Win)",O4]],[yf,["QQ(Mobile)",Sk]],[_f,["QQ(Mobile X5)",Sk]],[Sf,["QQ(Mac)",M4]],[kf,["QQ(iPad)",N4]],[Tf,["MI",U4]],[xf,["HW",B4]],[wf,["Samsung",j4]],[al,["OPPO",F4]],[ol,["VIVO",G4]],[nl,["EDGE",C4]],[ff,["SogouMobile",R4]],[mf,["Sogou",A4]]]);function Ki(){var e="unknown",t="unknown";return Rf.get(!0)&&(e=Rf.get(!0)[0],t=Rf.get(!0)[1]),{name:e,version:t}}var Ik=function(e,t){return t?Wa+"/"+e+"/"+t:Wa+"/"+e+"/index.html"},q4=function(){if(!qi())return!1;var e=localStorage.getItem(of);e&&!function(t){var n=t.saveTime&&new Date().getTime()-t.saveTime>=HS,r=!t.saveVersion||t.saveVersion!==Oi;return n||r}(JSON.parse(e))||(be.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(of,JSON.stringify({message:t.responseText,saveTime:new Date().getTime(),saveVersion:Oi})),document.body.removeChild(n)}}())};function te(e){var t=e.key,n=e.data,r=e.link,i=e.addDocLink,o=i===void 0||i,a="",s="",c="";kn(di[t])?a=di[t](n):Ft(di[t])&&(a=di[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 f=localStorage.getItem(of);if(f){f=JSON.parse(f);var _=document.createElement("script");_.type="text/javascript",_.text=f.message,document.body.appendChild(_);var y=window.TRTC_ERROR_INFO,S=window.TRTC_ERROR_LINK;return document.body.removeChild(_),{TRTC_ERROR_INFO:y,TRTC_ERROR_LINK:S}}return{}}(),d=u.TRTC_ERROR_INFO,p=u.TRTC_ERROR_LINK;r?c="".concat(r.className,".html#").concat(r.fnName):p&&p[t]&&(kn(p[t])?c=p[t](n):Ft(p[t])&&(c=p[t]));var h=a;return Xi()&&(d&&d[t]&&(kn(d[t])?s=d[t](n):Ft(d[t])&&(s=d[t])),s&&(h=o?s+`
81
+ \u8BF7\u67E5\u770B\u6587\u6863: `+Ik("zh-cn",c)+`
82
+
83
+ `:s+`
84
+
85
+ `,h+=a)),o&&(h+=`
86
+ Refer to: `+Ik("en",c)+`
87
+ `),h}var wk=function(){return function(e){var t=window.location.search.match(new RegExp("(\\?|&)"+e+"=([^&]*)(&|$)"));return t?decodeURIComponent(t[2]):""}("trtc_env")},Ek=function(e){return(e=Number(e))>0&&e<14e8},ll=function(e,t){var n;n=Xs?Xs.includes("http")?Xs:"https://"+Xs:Ek(e)?"https://apisgp.my-imcloud.com":"https://yun.tim.qq.com";var r=Math.floor(Math.random()*Math.pow(2,31));return"".concat(n,"/v5/AVQualityReportSvc/C2S?random=").concat(r,"&sdkappid=").concat(e,"&cmdtype=").concat(t)};function Af(){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 r=t&&t.type&&t.type.toLowerCase(),i=t&&t.effectiveType&&t.effectiveType.toLowerCase();i==="slow-2"&&(i="2g");var o=n||"unknown";if(r)switch(r){case"cellular":case"wimax":o=i||"unknown";break;case"wifi":o="wifi";break;case"ethernet":o="wired";break;case"none":case"other":case"unknown":o="unknown"}return o}var Qi=function(e){if(!e||V(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 dl(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:dl(e-1,n,t+n)}function Pf(e){var t=Math.round(e/2)+1;return t>6?13e3:1e3*dl(t)}var kn=function(e){return typeof e=="function"},fe=function(e){return e===void 0},Ft=function(e){return typeof e=="string"},br=function(e){return typeof e=="number"},Ck=function(e){return typeof e=="boolean"},Rk=function(e){return hi(e)==="object"},Ak=function(e){return hi(e)==="array"},Pk=function(e){return hi(e)==="MediaStreamTrack".toLowerCase()};function hi(e){return Reflect.apply(Object.prototype.toString,e,[]).replace(/^\[object\s(\w+)\]$/,"$1").toLowerCase()}function Dk(e){var t={};return t.urls="turn:".concat(e.url),fe(e.username)||fe(e.credential)||(t.username=e.username,t.credential=e.credential,t.credentialType="password",fe(e.credentialType)||(t.credentialType=e.credentialType)),t}function Et(){return performance&&performance.now?Math.floor(performance.now()):Date.now()}function Df(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"big";if(!Ft(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 Lf,Of,Xi=function(){var e=navigator.language||navigator.userLanguage;return(e=e.substr(0,2))==="zh"},Lk=(Lf=!1,Of=document.visibilityState,function(){document.visibilityState!==Of&&be.info("visibility change: ".concat(document.visibilityState)),Lf||(document.addEventListener("visibilitychange",function(){be.info("visibility change: "+document.visibilityState),Of=document.visibilityState}),Lf=!0)});window.AudioContext=window.AudioContext||window.webkitAudioContext||window.mozAudioContext;var Ok=function(){return new window.AudioContext},Mk=function(){var e;return function(){return e||(e=new window.AudioContext,e.onstatechange=function(){be.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)}}(),K4=!!window.AudioWorkletNode,Nk=function(e,t){var n=e.emit;return e.emit=function(){for(var r=arguments.length,i=new Array(r),o=0;o<r;o++)i[o]=arguments[o];try{n.apply(e,i)}catch(s){var a=te({key:d4,data:{name:t,event:i[0]},addDocLink:!1});be.warn(a+`
88
+
89
+ `+s.stack)}},e},Vk=function(e){return+e<10?"0".concat(e):e},Q4=function(e){var t=e.match(/^\d+\.\d+\.\d+/)[0];if(!t)return e;var n=t.split("."),r=Vk(n[1])+Vk(n[2]);return n[1]-15>0&&(n[1]="15"),n[2]-15>0&&(n[2]="15"),n.join(".")+"."+r};function hl(e){var t=e.url,n=e.body,r=e.method,i=e.timeout,o=new XMLHttpRequest;return new Promise(function(a,s){o.onload=function(u){if(o.status>=200&&o.status<300&&o.responseText.length>0)try{var d=JSON.parse(o.response);a({data:d})}catch(p){a({data:o.response})}else o.status>0&&s({code:o.status,message:"request failed, readyState:".concat(o.readyState," status:").concat(o.status," loaded size:").concat(u.loaded)})};var c=function(u){s({code:o.readyState,message:"request ".concat(u.type,", readyState:").concat(o.readyState," status:").concat(o.status," loaded size:").concat(u.loaded)})};o.onerror=c,o.onabort=c,o.ontimeout=c,o.timeout=i||5e3,o.open(r||"POST",t,!0),o.send(n)})}var Uk={exports:{}};(function(e){var t=Object.prototype.hasOwnProperty,n="~";function r(){}function i(c,u,d){this.fn=c,this.context=u,this.once=d||!1}function o(c,u,d,p,h){if(typeof d!="function")throw new TypeError("The listener must be a function");var f=new i(d,p||c,h),_=n?n+u:u;return c._events[_]?c._events[_].fn?c._events[_]=[c._events[_],f]:c._events[_].push(f):(c._events[_]=f,c._eventsCount++),c}function a(c,u){--c._eventsCount==0?c._events=new r:delete c._events[u]}function s(){this._events=new r,this._eventsCount=0}Object.create&&(r.prototype=Object.create(null),new r().__proto__||(n=!1)),s.prototype.eventNames=function(){var c,u,d=[];if(this._eventsCount===0)return d;for(u in c=this._events)t.call(c,u)&&d.push(n?u.slice(1):u);return Object.getOwnPropertySymbols?d.concat(Object.getOwnPropertySymbols(c)):d},s.prototype.listeners=function(c){var u=n?n+c:c,d=this._events[u];if(!d)return[];if(d.fn)return[d.fn];for(var p=0,h=d.length,f=new Array(h);p<h;p++)f[p]=d[p].fn;return f},s.prototype.listenerCount=function(c){var u=n?n+c:c,d=this._events[u];return d?d.fn?1:d.length:0},s.prototype.emit=function(c,u,d,p,h,f){var _=n?n+c:c;if(!this._events[_])return!1;var y,S,E=this._events[_],R=arguments.length;if(E.fn){switch(E.once&&this.removeListener(c,E.fn,void 0,!0),R){case 1:return E.fn.call(E.context),!0;case 2:return E.fn.call(E.context,u),!0;case 3:return E.fn.call(E.context,u,d),!0;case 4:return E.fn.call(E.context,u,d,p),!0;case 5:return E.fn.call(E.context,u,d,p,h),!0;case 6:return E.fn.call(E.context,u,d,p,h,f),!0}for(S=1,y=new Array(R-1);S<R;S++)y[S-1]=arguments[S];E.fn.apply(E.context,y)}else{var H,Y=E.length;for(S=0;S<Y;S++)switch(E[S].once&&this.removeListener(c,E[S].fn,void 0,!0),R){case 1:E[S].fn.call(E[S].context);break;case 2:E[S].fn.call(E[S].context,u);break;case 3:E[S].fn.call(E[S].context,u,d);break;case 4:E[S].fn.call(E[S].context,u,d,p);break;default:if(!y)for(H=1,y=new Array(R-1);H<R;H++)y[H-1]=arguments[H];E[S].fn.apply(E[S].context,y)}}return!0},s.prototype.on=function(c,u,d){return o(this,c,u,d,!1)},s.prototype.once=function(c,u,d){return o(this,c,u,d,!0)},s.prototype.removeListener=function(c,u,d,p){var h=n?n+c:c;if(!this._events[h])return this;if(!u)return a(this,h),this;var f=this._events[h];if(f.fn)f.fn!==u||p&&!f.once||d&&f.context!==d||a(this,h);else{for(var _=0,y=[],S=f.length;_<S;_++)(f[_].fn!==u||p&&!f[_].once||d&&f[_].context!==d)&&y.push(f[_]);y.length?this._events[h]=y.length===1?y[0]:y:a(this,h)}return this},s.prototype.removeAllListeners=function(c){var u;return c?(u=n?n+c:c,this._events[u]&&a(this,u)):(this._events=new r,this._eventsCount=0),this},s.prototype.off=s.prototype.removeListener,s.prototype.addListener=s.prototype.on,s.prefixed=n,s.EventEmitter=s,e.exports=s})(Uk);var pi=Uk.exports,W=new pi,pl=1,Mf=2,Nf=3,Qa=4,Xa=5,Vf=20,Uf=21,Ya=22,Bf=23,jf=24,Ff=27,Gf=28,fl=29,Bk=30,Hf=33,jk=31,zf=32,X4=100,Fk=101,rc=102,Wf=103,Mn=110,ml=111,Jf=112,Nr=113,Vr=114,Y4=115,Yi=116,$4=120,qf=121,Kf=122,Qf=123,ic=130,Xf=131,Yf=132,$f=133,Zf=134,em=135,tm=136,nm=137,rm=200,im=201,am=300,ac=301,om=302,sm=303;function oc(e){var t=e.retryFunction,n=e.settings,r=e.onError,i=e.onRetrying,o=e.onRetryFailed,a=e.context;return function(){for(var s=this,c=arguments.length,u=new Array(c),d=0;d<c;d++)u[d]=arguments[d];var p=n.retries||5,h=0,f=-1,_=0,y=function(){var S=N(m().mark(function E(R,H){var Y,ue,le,O;return m().wrap(function(k){for(;;)switch(k.prev=k.next){case 0:return Y=a||s,k.prev=1,k.next=4,t.apply(Y,u);case 4:ue=k.sent,h=0,R(ue),k.next=14;break;case 9:k.prev=9,k.t0=k.catch(1),le=function(){clearTimeout(f),h=0,_=2,H(k.t0)},O=function(){_!==2&&h<p?(h++,_=1,kn(i)&&i.call(Y,h,le),f=setTimeout(function(){f=-1,y(R,H)},fe(n.timeout)?1e3:n.timeout)):(le(),kn(o)&&o.call(Y,k.t0))},kn(r)?r.call(Y,k.t0,O,H,u):O();case 14:case"end":return k.stop()}},E,null,[[1,9]])}));return function(E,R){return S.apply(this,arguments)}}();return new Promise(y)}}var Z4=ke(function e(t){z(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}),eV=function(){function e(t){z(this,e),this.id_=t.id,this.userId_=t.userId,this.sdkAppId_=t.sdkAppId,this.type_=t.type,this.isLocal_=!Ck(t.isLocal)||t.isLocal}return ke(e,[{key:"setUserId",value:function(t){this.userId_=t}},{key:"setSdkAppId",value:function(t){this.sdkAppId_=t}},{key:"log",value:function(t,n){be.log({log:"[".concat(this.isLocal_?"\u2191":"\u2193").concat(this.id_,"] ").concat(this.type_?this.type_+" ":"").concat(n),level:t,forAllJoinedClients:fe(this.userId_),userId:this.userId_,sdkAppId:this.sdkAppId_})}},{key:"info",value:function(t){this.log(On.INFO,t)}},{key:"debug",value:function(t){this.log(On.DEBUG,t)}},{key:"warn",value:function(t){this.log(On.WARN,t)}},{key:"error",value:function(t){this.log(On.ERROR,t)}}]),e}(),tV=!(Lr||qa),nV=function(){function e(){var r=this;z(this,e),this.clients_=new Set,this.queue_=[],this.timeoutId_=-1,this.logLevel_=On.DEBUG,this.logLevelToUpload_=On.INFO,this.enableUploadLog_=!0,this.isAbleToUpload_=!1,this.checkURLParam(),W.on(Bk,function(i){var o=i.client;r.timeoutId_===-1&&r.startUpload(),r.clients_.add(o)}),W.on(Hf,function(i){var o=i.client;return r.clients_.delete(o)}),W.on(jk,function(i){i&&Qi(i.config)&&Wi[i.config.logLevelToUpload]&&(r.logLevelToUpload_=i.config.logLevelToUpload)}),W.on(Qa,this.setIsAbleToUpload,this),W.on(Xa,this.setIsAbleToUpload,this)}var t,n;return ke(e,[{key:"getIsAbleToUpload",value:function(){return this.isAbleToUpload_}},{key:"setIsAbleToUpload",value:function(){this.isAbleToUpload_=!0,W.off(Qa,this.setIsAbleToUpload,this),W.off(Xa,this.setIsAbleToUpload,this)}},{key:"startUpload",value:(n=N(m().mark(function r(){var i=this;return m().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 i.startUpload()},2e3);case 8:case"end":return o.stop()}},r,this,[[0,5]])})),function(){return n.apply(this,arguments)})},{key:"getLogsToUpload",value:function(){var r=this,i={map:new Map,splicedQueue:[]};if(this.queue_[0].forAllJoinedClients&&this.clients_.size===0)return i;for(var o=0,a=function(){if(o===50)return"break";var s=r.queue_[o];s.forAllJoinedClients?r.clients_.forEach(function(c){if(c.getIsJoined()){var u=c.getUserId(),d=c.getSDKAppId();i.map.has(u)?i.map.get(u).logs.push(s):i.map.set(u,{userId:u,sdkAppId:d,logs:[s]})}}):i.map.has(s.userId)?i.map.get(s.userId).logs.push(s):i.map.set(s.userId,{userId:s.userId,sdkAppId:s.sdkAppId,logs:[s]})};o<this.queue_.length&&a()!=="break";o++);return i.map.size>0&&(i.splicedQueue=this.queue_.splice(0,o)),i}},{key:"upload",value:(t=N(m().mark(function r(){var i,o,a,s,c,u,d,p,h,f;return m().wrap(function(_){for(;;)switch(_.prev=_.next){case 0:if(this.queue_.length!==0&&this.isAbleToUpload_){_.next=2;break}return _.abrupt("return");case 2:if(i=this.getLogsToUpload(),o=i.map,a=i.splicedQueue,o.size!==0){_.next=5;break}return _.abrupt("return");case 5:_.prev=5,s=Se(o.values()),c=0;case 8:if(!(c<s.length)){_.next=16;break}return u=s[c],d=u.userId,p=u.sdkAppId,h=u.logs,_.next=12,this.uploadLogWithRetry(JSON.stringify({timestamp:U0(),sdkAppId:String(p),userId:d,version:Oi,log:h.map(function(y){return y.log}).join(`
90
+ `)}),p);case 12:h.forEach(function(y){return y.uploaded=!0});case 13:c++,_.next=8;break;case 16:_.next=20;break;case 18:_.prev=18,_.t0=_.catch(5);case 20:f=a.filter(function(y){return!y.uploaded}),f.length>0&&(this.queue_=f.concat(this.queue_));case 22:case"end":return _.stop()}},r,this,[[5,18]])})),function(){return t.apply(this,arguments)})},{key:"uploadLogWithRetry",value:function(r,i){return oc({retryFunction:function(){return hl({url:ll(i,fS),body:r,timeout:5e3})},settings:{retries:3,timeout:1e3},onError:function(o,a){a()}})()}},{key:"getPrefix",value:function(r){var i=new Date;return i.setTime(tn()),String.prototype.padStart?"[".concat(i.toTimeString().replace(/.*(\d{2}:\d{2}:\d{2}).*/,"$1"),":").concat(i.getMilliseconds().toString().padStart(3,"0"),"] <").concat(Wi[r],">"):"[".concat(i.toTimeString().replace(/.*(\d{2}:\d{2}:\d{2}).*/,"$1"),":").concat(i.getMilliseconds(),"] <").concat(Wi[r],">")}},{key:"getLogLevel",value:function(){return this.logLevel_}},{key:"setLogLevel",value:function(r){fe(Wi[r])||(this.logLevel_!==r&&this.info("setLogLevel ".concat(r)),this.logLevel_=r)}},{key:"enableUploadLog",value:function(){this.enableUploadLog_=!0}},{key:"disableUploadLog",value:function(){this.enableUploadLog_=!1}},{key:"log",value:function(r){var i=r.log,o=r.level,a=r.forAllJoinedClients,s=a===void 0||a,c=r.userId,u=r.sdkAppId;if(i="".concat(this.getPrefix(o)," ").concat(i),this.enableUploadLog_&&o>=this.logLevelToUpload_&&this.queue_.push(new Z4({log:i,level:o,userId:c,sdkAppId:u,forAllJoinedClients:s})),!(o<this.logLevel_)){var d=Wi[o]?Wi[o].toLowerCase():"info";tV?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(r){this.log({log:r,level:On.DEBUG})}},{key:"info",value:function(r){this.log({log:r,level:On.INFO})}},{key:"warn",value:function(r){this.log({log:r,level:On.WARN})}},{key:"error",value:function(r){this.log({log:r,level:On.ERROR})}},{key:"createLogger",value:function(r){return new eV(r)}},{key:"checkURLParam",value:function(){var r=new URLSearchParams(location.search).get("logLevelToUpload");Wi[r]&&(this.logLevelToUpload_=r)}}]),e}(),be=new nV,Gk=!0,rV=yt,iV=Math.floor,Hk=Number.isInteger||function(e){return!rV(e)&&isFinite(e)&&iV(e)===e};Oe({target:"Number",stat:!0},{isInteger:Hk});var cm,aV=Oe,zk=ce,oV=ye.f,sV=Qn,Wk=Vt,cV=ib,uV=Ct,lV=ab,Jk=zk("".startsWith),dV=zk("".slice),hV=Math.min,qk=lV("startsWith");aV({target:"String",proto:!0,forced:!!(qk||(cm=oV(String.prototype,"startsWith"),!cm||cm.writable))&&!qk},{startsWith:function(e){var t=Wk(uV(this));cV(e);var n=sV(hV(arguments.length>1?arguments[1]:void 0,t.length)),r=Wk(e);return Jk?Jk(t,r,n):dV(t,n,n+r.length)===r}});var Kk=_e,pV=ce,fV=Ke,mV=ie,um=du,vV=Jd,gV=Ht,_V=Rt,yV=Cn,$a=Object.assign,Qk=Object.defineProperty,bV=pV([].concat),Xk=!$a||mV(function(){if(Kk&&$a({b:1},$a(Qk({},"a",{enumerable:!0,get:function(){Qk(this,"b",{value:3,enumerable:!1})}}),{b:2})).b!==1)return!0;var e={},t={},n=Symbol(),r="abcdefghijklmnopqrst";return e[n]=7,r.split("").forEach(function(i){t[i]=i}),$a({},e)[n]!=7||um($a({},t)).join("")!=r})?function(e,t){for(var n=_V(e),r=arguments.length,i=1,o=vV.f,a=gV.f;r>i;)for(var s,c=yV(arguments[i++]),u=o?bV(um(c),o(c)):um(c),d=u.length,p=0;d>p;)s=u[p++],Kk&&!fV(a,c,s)||(n[s]=c[s]);return n}:$a,Yk=Xk;Oe({target:"Object",stat:!0,arity:2,forced:Object.assign!==Yk},{assign:Yk});var $k=ce,SV=Nt,kV=yt,TV=kt,Zk=xa,xV=De,eT=Function,IV=$k([].concat),wV=$k([].join),lm={},EV=function(e,t,n){if(!TV(lm,t)){for(var r=[],i=0;i<t;i++)r[i]="a["+i+"]";lm[t]=eT("C,a","return new C("+wV(r,",")+")")}return lm[t](e,n)},CV=xV?eT.bind:function(e){var t=SV(this),n=t.prototype,r=Zk(arguments,1),i=function(){var o=IV(r,Zk(arguments));return this instanceof i?EV(t,o.length,o):t.apply(e,o)};return kV(n)&&(i.prototype=n),i},tT=CV;Oe({target:"Function",proto:!0,forced:Function.bind!==tT},{bind:tT});var RV=Oe,AV=en.findIndex,PV=fu,nT="findIndex",rT=!0;nT in[]&&Array(1).findIndex(function(){rT=!1}),RV({target:"Array",proto:!0,forced:rT},{findIndex:function(e){return AV(this,e,arguments.length>1?arguments[1]:void 0)}}),PV(nT);var DV=_e,iT=ce,LV=du,OV=it,MV=iT(Ht.f),NV=iT([].push),aT=function(e){return function(t){for(var n,r=OV(t),i=LV(r),o=i.length,a=0,s=[];o>a;)n=i[a++],DV&&!MV(r,n)||NV(s,e?[n,r[n]]:r[n]);return s}},VV={entries:aT(!0),values:aT(!1)}.values;Oe({target:"Object",stat:!0},{values:function(e){return VV(e)}});var oT=1,sT=5,dm=2,sc=3,hm=4,vl="DISCONNECTED",cT="CONNECTING",pm="RECONNECTING",cc="CONNECTED",Ur={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},UV=[Ur.UPDATE_REMOTE_MUTE_STAT,Ur.UPLINK_NETWORK_STATS,Ur.USER_LIST_RES,Ur.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"},BV="publish_change",jV="publish_state_change",FV="join",GV="leave",HV="quality_report",zV="mute_uplink",WV="publish",uT="unpublish",JV="subscribe",qV="unsubscribe",KV="subscribe_change",QV="start_publishing",XV="stop_publishing",YV="start_push_user_cdn",$V="stop_push_user_cdn",ZV="start_mcu_mix",eU="stop_mcu_mix",tU="get_user_list",nU="change_role",rU="update_constraint_config",Q={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},$=function(e){Mt(n,e);var t=wr(n);function n(r){var i,o=r.name,a=o===void 0?"RtcError":o,s=r.message,c=r.code,u=c===void 0?Q.UNKNOWN:c,d=r.extraCode,p=d===void 0?0:d,h=r.constraint;z(this,n);var f="<".concat(function(_){for(var y in Q)if(Q[y]===_)return y;return"UNKNOWN"}(u)," 0x").concat(u.toString(16),">");return(i=t.call(this,s+"".concat(h?" constraint: ".concat(h):"")+"".concat(s!=null&&s.includes(f)?"":" "+f))).code_=u,i.extraCode_=p,i.name=a,i.message_=s,h&&(i.constraint=h),i}return ke(n,[{key:"getCode",value:function(){return this.code_}},{key:"getExtraCode",value:function(){return this.extraCode_}}]),n}(Co(Error)),lT=32768,dT=32769,hT=32770,pT=32771,iU=32772,aU=32773,oU=32774,sU=32775,fT=32777,cU=32778,fm=32779,uU=32780,lU=32781,dU=32782,hU=32783,pU=32784,fU=32785,mU=32786,vU=32787,gU=32788,_U=32789,yU=32790,bU=32791,SU=32792,kU=32793,TU=32794,xU=32795,IU=32796,wU=32797,EU=32798,CU=32799,RU=32800,AU=32801,PU=32802,DU=32803,LU=32804,uc=new Map,dn=function(e,t){var n=uc.get(e);n||(uc.set(e,[]),n=uc.get(e)),n.push(t)},OU=function(e){var t=uc.get(e),n=[];return t?(uc.delete(e),n=t.map(function(r){return{uint32_event_id:r.eventId,uint64_date:r.timestamp,str_userid:r.remoteUserId,str_event_json:r.eventDesc}})):n=[],n},MU=Object.prototype.hasOwnProperty;function $i(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(Qi(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(MU.call(e,t))return!1;return!0}return!1}var NU=function(){function e(){z(this,e);var t=Ki(),n=t.name,r=t.version;this.roomIdMap_=new Map,this.configs_={sdkAppId:"",userId:"",version:Oi,env:Ju,browserVersion:n+r,ua:navigator.userAgent}}return ke(e,[{key:"setConfig",value:function(t){var n=t.sdkAppId,r=t.env,i=t.userId,o=t.roomId;n!==this.configs_.sdkAppId&&(this.configs_.sdkAppId=String(n)),this.configs_.env=r,this.configs_.userId=i,this.roomIdMap_.set(i,String(o))}},{key:"logEvent",value:function(t){if(!Ka){var n=G(G(G({},t),this.configs_),{},{userId:t.userId||this.configs_.userId});fe(n.code)&&(n.code=n.result==="failed"?Q.UNKNOWN:0),this.sendRequest(ll(this.configs_.sdkAppId,sN),n)}}},{key:"logSuccessEvent",value:function(t){Ka||(this.logEvent(G(G({},t),{},{result:"success",roomId:this.roomIdMap_.get(t.userId)})),this.configs_.env===Ju&&this.uploadEventToKibana(G(G({},t),{},{result:"success"})))}},{key:"logFailedEvent",value:function(t){if(!Ka){var n=t.eventType,r=t.code,i=t.error,o=t.userId,a={roomId:this.roomIdMap_.get(o),userId:o,eventType:n,result:"failed",code:r||(i instanceof $?i.getExtraCode()||i.getCode():Q.UNKNOWN)};this.logEvent(a),this.configs_.env===Ju&&this.uploadEventToKibana(G(G({},a),{},{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,r=t.userId,i=t.error,o={timestamp:U0(),sdkAppId:this.configs_.sdkAppId,userId:r||this.configs_.userId,version:this.configs_.version,log:n};i&&(o.errorInfo=i.message),this.sendRequest(ll(this.configs_.sdkAppId,fS),o)}},{key:"sendRequest",value:function(t,n){var r=this;be.getIsAbleToUpload()?hl({url:t,body:JSON.stringify(n)}).catch(function(){}):setTimeout(function(){r.sendRequest(t,n)},1e3)}}]),e}(),Ie=new NU,VU=function(){function e(t){z(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_));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_=vl,this.reconnectionCount_=0,this.reconnectionTimer_=-1,this.lastMessageTime_=-1,this.seq_=0,this.log_=be.createLogger({id:"ws|"+this.userId_,userId:this.userId_,sdkAppId:this.sdkAppId_}),this.emitter_=new pi}return ke(e,[{key:"isOnline",get:function(){return this.currentState_===cc&&Date.now()-this.lastMessageTime_<12e3}},{key:"connect",value:function(){var t=this;return new Promise(function(n,r){t.log_.info("connect to url: ".concat(t.urlWithParam_)),t.emitConnectionStateChanged(cT),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),t.once(sc,n),t.once(hm,r)})}},{key:"tryConnectBackup",value:function(){this.backupSocket_||(this.unbindAndCloseSocket(Ye),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===Ye){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_&&$i(this.signalInfo_)&&this.stopReconnection(),this.clearBackupTimer(),t.target===this.socket_?(this.unbindAndCloseSocket(Hi),this.socketInUse_=this.socket_):(this.unbindAndCloseSocket(Ye),this.socketInUse_=this.backupSocket_);var n=t.target.url;this.log_.info("websocket[".concat(n,"] is connected")),this.currentState_===cT?this.addSignalEvent(bU,"signal channel is connected"):this.currentState_===pm&&this.addSignalEvent(xU,"signal channel reconnect success"),this.emitConnectionStateChanged(cc),this.emitter_.emit(sc)}}},{key:"onclose",value:function(t){var n=t.target.url,r=t.target===this.socketInUse_;this.log_.info("websocket[".concat(n," InUse: ").concat(r,"] is closed with code: ").concat(t.code)),t.target===this.socketInUse_&&(this.isConnected_=!1,this.emitConnectionStateChanged(vl),this.addSignalEvent(yU,"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),this.socket_=this.backupSocket_=this.socketInUse_=null,this.reconnect(Ye)))}},{key:"onerror",value:function(t){var n=t.target.url;this.log_.error("websocket[".concat(n,"] error observed")),this.isConnected_?t.target===this.socketInUse_&&(this.isConnected_=!1,this.unbindAndCloseSocket(Ye),this.unbindAndCloseSocket(Hi),this.socketInUse_=null,this.reconnect(Ye)):(this.isReconnecting_||Ie.logFailedEvent({userId:this.client_.getUserId(),eventType:Xp,code:Q.UNKNOWN}),t.target==this.socket_?(this.unbindAndCloseSocket(Ye),this.reconnect(Hi)):(this.unbindAndCloseSocket(Hi),this.reconnect(Ye))),this.isConnecting_=!1,this.isConnected_=!1}},{key:"onmessage",value:function(t){if(this.isConnected_){this.lastMessageTime_=Date.now();var n=JSON.parse(t.data),r=n.cmd,i=n.data,o=Object.values(Ur),a=Object.keys(Ur)[o.indexOf(r)],s=ft[a];switch(UV.includes(r)||(this.log_.debug("received msg: ".concat(t.data)),this.log_.info("Received event: [ ".concat(s||"unknown cmd: "+r," ]"))),r){case Ur.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){up=u-new Date().getTime();var d=new Date;d.setTime(u),be.info("baseTime from server: "+d+" offset: "+up)}(i.svrTime),this.log_.info("ChannelSetup Success"),Ie.logSuccessEvent({userId:this.userId_,eventType:Xp}),this.emitter_.emit(oT,{signalInfo:this.signalInfo_});else{var c=new $({code:Q.SIGNAL_CHANNEL_SETUP_FAILED,extraCode:n.code,message:te({key:zN,data:{errorCode:n.code,errorMsg:n.message}})});this.log_.error("".concat(n.code,", ").concat(n.message)),this.close(),Ie.logFailedEvent({userId:this.userId_,eventType:Xp,error:c}),this.emitter_.emit(sT,c)}break;case Ur.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 Ur.CHANNEL_RECONNECT_RESULT:n.code===0?(this.log_.warn("reconnect success"),this.stopReconnection(),Ie.logSuccessEvent({userId:this.userId_,eventType:PS}),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){dn(this.userId_,{eventId:t,eventDesc:n,timestamp:tn(),userId:this.userId_,tinyId:this.signalInfo_.tinyId})}},{key:"reconnect",value:function(){var t=this,n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:Ye;if(this.isConnecting_||this.reconnectionTimer_!==-1)this.log_.info("signal channel is reconnecting, ignoring current reconnection");else{if(this.reconnectionCount_>=Qp){this.log_.warn("SDK has tried reconnect signal channel for ".concat(Qp," times, but all failed. please check your network"));var r=new $({code:Q.SIGNAL_CHANNEL_RECONNECTION_FAILED,message:te({key:HN})});return Ie.logFailedEvent({userId:this.client_.getUserId(),eventType:PS,error:r}),this.addSignalEvent(IU,"signal channel reconnect fail"),void this.emitter_.emit(hm,r)}this.isConnecting_=!0,this.reconnectionCount_++,this.currentState_!==pm&&(this.emitConnectionStateChanged(pm),this.addSignalEvent(TU,"signal channel is reconnecting")),this.log_.warn("reconnecting to ".concat(n," signal channel [").concat(this.reconnectionCount_,"/").concat(Qp,"]"));var i=this.getReconnectionUrl(n);n===Ye?(this.socket_=new WebSocket(i),this.bindSocket(this.socket_)):(this.backupSocket_=new WebSocket(i),this.bindSocket(this.backupSocket_));var o=Pf(this.reconnectionCount_);this.reconnectionTimer_=setTimeout(function(){t.log_.warn("reconnect ".concat(n," signal channel timeout(").concat(o/1e3,"s), close and try again")),t.isConnecting_=!1,t.clearReconnectionTimer(),t.unbindAndCloseSocket(n),t.reconnect(n===Ye?Hi:Ye)},o)}}},{key:"isConnected",value:function(){return this.isConnected_}},{key:"isReconnecting_",get:function(){return this.reconnectionTimer_!==-1}},{key:"getReconnectionUrl",value:function(t){var n=t===Ye?this.urlWithParam_:this.backupUrlWithParam_;if(!$i(this.signalInfo_)&&n.indexOf("&rc=1")===-1){var r=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(r,"&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 r={cmd:t,data:n,userId:this.userId_,tinyId:this.signalInfo_.tinyId,seq:++this.seq_};return this.socketInUse_.send(JSON.stringify(r)),r.seq}}},{key:"sendWaitForResponse",value:function(t){var n=this,r=t.command,i=t.data,o=t.timeout,a=o===void 0?5e3:o,s=t.responseCommand,c=t.commandDesc,u=t.enableLog,d=u===void 0||u;return new Promise(function(p,h){var f=setTimeout(function(){n.off(s,_);var S=new $({code:Q.API_CALL_TIMEOUT,message:te({key:GN,data:{commandDesc:c,command:r}})});d&&n.log_.warn(S),h(S)},a),_=function S(E){E.data.seq===y&&(clearTimeout(f),n.off(s,S),p(E))};n.on(s,_);var y=n.send(r,i)})}},{key:"sendWaitForResponseWithRetry",value:function(){var t=this,n=arguments.length<=0?void 0:arguments[0],r=n.commandDesc,i=n.command,o=n.retries,a=o===void 0?0:o,s=n.retryTimeout,c=s===void 0?0:s;return oc({retryFunction:this.sendWaitForResponse,onRetrying:function(u){t.log_.warn("".concat(r||i," timeout observed, retrying [").concat(u,"/").concat(a,"]"))},settings:{retries:a,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(Ye),this.unbindAndCloseSocket(Hi),this.emitConnectionStateChanged(vl)}},{key:"on",value:function(t,n,r){this.emitter_.on(t,n,r)}},{key:"removeListener",value:function(t,n,r){this.emitter_.removeListener(t,n,r)}},{key:"once",value:function(t,n,r){this.emitter_.once(t,n,r)}},{key:"off",value:function(t,n,r){this.emitter_.off(t,n,r)}},{key:"emitConnectionStateChanged",value:function(t){t!==this.currentState_&&(this.emitter_.emit(dm,{prevState:this.currentState_,state:t}),this.currentState_=t)}}]),e}(),UU=Oe,BU=en.find,jU=fu,mT="find",vT=!0;mT in[]&&Array(1).find(function(){vT=!1}),UU({target:"Array",proto:!0,forced:vT},{find:function(e){return BU(this,e,arguments.length>1?arguments[1]:void 0)}}),jU(mT);var Yn={},gT={},mm={exports:{}},_T=mm.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(_T).forEach(function(e){_T[e].forEach(function(t){t.reg||(t.reg=/(.*)/),t.format||(t.format="%s")})}),function(e){var t=function(a){return String(Number(a))===a?Number(a):a},n=function(a,s,c){var u=a.name&&a.names;a.push&&!s[a.push]?s[a.push]=[]:u&&!s[a.name]&&(s[a.name]={});var d=a.push?{}:u?s[a.name]:s;(function(p,h,f,_){if(_&&!f)h[_]=t(p[1]);else for(var y=0;y<f.length;y+=1)p[y+1]!=null&&(h[f[y]]=t(p[y+1]))})(c.match(a.reg),d,a.names,a.name),a.push&&s[a.push].push(d)},r=mm.exports,i=RegExp.prototype.test.bind(/^([a-z])=(.*)/);e.parse=function(a){var s={},c=[],u=s;return a.split(/(\r\n|\r|\n)/).filter(i).forEach(function(d){var p=d[0],h=d.slice(2);p==="m"&&(c.push({rtp:[],fmtp:[]}),u=c[c.length-1]);for(var f=0;f<(r[p]||[]).length;f+=1){var _=r[p][f];if(_.reg.test(h))return n(_,u,h)}}),s.media=c,s};var o=function(a,s){var c=s.split(/=(.+)/,2);return c.length===2?a[c[0]]=t(c[1]):c.length===1&&s.length>1&&(a[c[0]]=void 0),a};e.parseParams=function(a){return a.split(/;\s?/).reduce(o,{})},e.parseFmtpConfig=e.parseParams,e.parsePayloads=function(a){return a.toString().split(" ").map(Number)},e.parseRemoteCandidates=function(a){for(var s=[],c=a.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(a){return a.split(" ").map(function(s){return s.substring(1,s.length-1).split(",").reduce(o,{})})},e.parseSimulcastStreamList=function(a){return a.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}})})}}(gT);var vm=mm.exports,FU=/%[sdv%]/g,GU=function(e){var t=1,n=arguments,r=n.length;return e.replace(FU,function(i){if(t>=r)return i;var o=n[t];switch(t+=1,i){case"%%":return"%";case"%s":return String(o);case"%d":return Number(o);case"%v":return""}})},lc=function(e,t,n){var r=[e+"="+(t.format instanceof Function?t.format(t.push?n:n[t.name]):t.format)];if(t.names)for(var i=0;i<t.names.length;i+=1){var o=t.names[i];t.name?r.push(n[t.name][o]):r.push(n[t.names[i]])}else r.push(n[t.name]);return GU.apply(null,r)},HU=["v","o","s","i","u","e","p","c","b","t","r","z","a"],zU=["i","c","b","a"],Zi=gT,WU=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||HU,r=t.innerOrder||zU,i=[];return n.forEach(function(o){vm[o].forEach(function(a){a.name in e&&e[a.name]!=null?i.push(lc(o,a,e)):a.push in e&&e[a.push]!=null&&e[a.push].forEach(function(s){i.push(lc(o,a,s))})})}),e.media.forEach(function(o){i.push(lc("m",vm.m[0],o)),r.forEach(function(a){vm[a].forEach(function(s){s.name in o&&o[s.name]!=null?i.push(lc(a,s,o)):s.push in o&&o[s.push]!=null&&o[s.push].forEach(function(c){i.push(lc(a,s,c))})})})}),i.join(`\r
91
+ `)+`\r
92
+ `};Yn.write=WU,Yn.parse=Zi.parse,Yn.parseParams=Zi.parseParams,Yn.parseFmtpConfig=Zi.parseFmtpConfig,Yn.parsePayloads=Zi.parsePayloads,Yn.parseRemoteCandidates=Zi.parseRemoteCandidates,Yn.parseImageAttributes=Zi.parseImageAttributes,Yn.parseSimulcastStreamList=Zi.parseSimulcastStreamList;var Br=function(e){return Yn.parse(e)},Za=function(e){return Yn.write(e)},JU=function(e){var t=Br(e);return t.media.forEach(function(n){n.type===Ce&&n.fmtp.forEach(function(r){r.config+=";sprop-stereo=1;stereo=1"})}),Za(t)};function qU(e){var t=Br(e);return t.media.forEach(function(n){if(n.type===xe){var r=new Set;n.rtp.forEach(function(o){var a=o.payload;return o.codec==="H264"&&r.add(a)}),n.fmtp.forEach(function(o){var a=o.payload,s=o.config.match(/apt=(\d+)/);s&&s[1]&&r.has(Number(s[1]))&&r.add(a)});var i=function(o){var a=o.payload;return!r.has(a)};n.rtp=n.rtp.filter(i),n.rtcpFb=n.rtcpFb.filter(i),n.fmtp=n.fmtp.filter(i),n.payloads=n.payloads.split(" ").filter(function(o){return!r.has(Number(o))}).join(" ")}}),Za(t)}var gm,_m,ym,bm,KU=Oe,Sm=ce,QU=Kn,XU=X0,YU=qy,yT=ie,$U=RangeError,bT=String,ST=Math.floor,km=Sm(YU),kT=Sm("".slice),dc=Sm(1 .toFixed),eo=function(e,t,n){return t===0?n:t%2==1?eo(e,t-1,n*e):eo(e*e,t/2,n)},to=function(e,t,n){for(var r=-1,i=n;++r<6;)i+=t*e[r],e[r]=i%1e7,i=ST(i/1e7)},Tm=function(e,t){for(var n=6,r=0;--n>=0;)r+=e[n],e[n]=ST(r/t),r=r%t*1e7},TT=function(e){for(var t=6,n="";--t>=0;)if(n!==""||t===0||e[t]!==0){var r=bT(e[t]);n=n===""?r:n+km("0",7-r.length)+r}return n};KU({target:"Number",proto:!0,forced:yT(function(){return dc(8e-5,3)!=="0.000"||dc(.9,0)!=="1"||dc(1.255,2)!=="1.25"||dc(0xde0b6b3a7640080,0)!=="1000000000000000128"})||!yT(function(){dc({})})},{toFixed:function(e){var t,n,r,i,o=XU(this),a=QU(e),s=[0,0,0,0,0,0],c="",u="0";if(a<0||a>20)throw $U("Incorrect fraction digits");if(o!=o)return"NaN";if(o<=-1e21||o>=1e21)return bT(o);if(o<0&&(c="-",o=-o),o>1e-21)if(n=(t=function(d){for(var p=0,h=d;h>=4096;)p+=12,h/=4096;for(;h>=2;)p+=1,h/=2;return p}(o*eo(2,69,1))-69)<0?o*eo(2,-t,1):o/eo(2,t,1),n*=4503599627370496,(t=52-t)>0){for(to(s,0,n),r=a;r>=7;)to(s,1e7,0),r-=7;for(to(s,eo(10,r,1),0),r=t-1;r>=23;)Tm(s,1<<23),r-=23;Tm(s,1<<r),to(s,1,1),Tm(s,2),u=TT(s)}else to(s,0,n),to(s,1<<-t,0),u=TT(s)+km("0",a);return u=a>0?c+((i=u.length)<=a?"0."+km("0",a-i)+u:kT(u,0,i-a)+"."+kT(u,i-a)):c+u}});var xT=((gm=window)===null||gm===void 0?void 0:gm.requestIdleCallback)||function(e){var t=Date.now();return setTimeout(function(){e({didTimeout:!1,timeRemaining:function(){return Math.max(0,50-(Date.now()-t))}})},1e3)},ZU=((_m=window)===null||_m===void 0?void 0:_m.cancelIdleCallback)||function(e){clearTimeout(e)},e6=((ym=window)===null||ym===void 0?void 0:ym.cancelAnimationFrame)||((bm=window)===null||bm===void 0?void 0:bm.mozCancelAnimationFrame),_t=function(){function e(){z(this,e)}return ke(e,null,[{key:"generateTaskID",value:function(){return this.currentTaskID++}},{key:"run",value:function(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:KS,n=arguments.length>1?arguments[1]:void 0,r=arguments.length>2?arguments[2]:void 0;r=G(G({},t===DN?{delay:2e3,count:0,backgroundTask:!0}:t===Ja?{delay:1e4,count:0}:t===el?{fps:60,delay:16.6,count:0,backgroundTask:!0}:{delay:2e3,count:0,backgroundTask:!0}),r),Rk(n)&&(r=G(G({},r),n)),kn(t)&&(n=t,t=KS);var i=G({taskID:this.generateTaskID(),loopCount:0,intervalID:null,timeoutID:null,rafID:null,ricID:null,taskName:t,callback:n},r);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 r(){if(t.callback(),t.loopCount+=1,!n.isBreakLoop(t))return t.timeoutID=setTimeout(r,t.delay)},t.delay)}},{key:"ric",value:function(t){var n,r=this,i=Et();return t.ricID=xT(function o(){if((n=Et()-i)>=t.delay&&(i=Et()-Math.floor(n%t.delay),t.callback(),t.loopCount+=1),!r.isBreakLoop(t))return t.ricID=xT(o,{timeout:t.delay})},{timeout:t.delay})}},{key:"raf",value:function(t){var n=this;t.delay=(1e3/t.fps).toFixed(2);var r,i=Et(),o=function s(){if(document.hidden&&t.backgroundTask)return r=Et()-i,i=Et(),t.callback(),t.loopCount+=1,n.isBreakLoop(t)?void 0:t.timeoutID=setTimeout(s,t.delay-Math.floor(r%t.delay));if((r=Et()-i)>=t.delay&&(i=Et()-Math.floor(r%t.delay),t.callback(),t.loopCount+=1),!n.isBreakLoop(t))return t.rafID=requestAnimationFrame(s)};if(t.rafID=requestAnimationFrame(o),t.backgroundTask){var a=function(){if(document.hidden){var s=Et()-i;s>=t.delay?o():t.timeoutID=setTimeout(o,t.delay-s)}};document.addEventListener("visibilitychange",a),t.onVisibilitychange=a,document.hidden&&a()}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),r=n.intervalID,i=n.timeoutID,o=n.rafID,a=n.ricID,s=n.onVisibilitychange;return r&&clearInterval(r),i&&clearTimeout(i),o&&e6(o),a&&ZU(a),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}();ut(_t,"taskMap",new Map),ut(_t,"currentTaskID",1);var t6=function(){function e(){z(this,e),this.prefix_="TRTC",this.queue_=new Map,this.checkStorage()}return ke(e,[{key:"getRealKey",value:function(t){return"".concat(this.prefix_,"_").concat(t)}},{key:"checkStorage",value:function(){var t=this;if(qi()){var n=Object.keys(localStorage).filter(function(r){if(r.startsWith(t.prefix_)){var i=JSON.parse(localStorage.getItem(r));if(i&&i.expiresIn<Date.now())return!0}return!1});n.forEach(function(r){return localStorage.removeItem(r)})}}},{key:"doFlush",value:function(){if(qi())try{var t,n=ne(this.queue_);try{for(n.s();!(t=n.n()).done;){var r=Te(t.value,2),i=r[0],o=r[1];localStorage.setItem(i,JSON.stringify(o))}}catch(a){n.e(a)}finally{n.f()}}catch(a){be.warn(a)}}},{key:"getItem",value:function(t){if(!qi())return null;try{var n=JSON.parse(localStorage.getItem(this.getRealKey(t)));return n&&n.expiresIn>=Date.now()?n.value:null}catch(r){be.warn(r)}}},{key:"setItem",value:function(t,n){var r=arguments.length>2&&arguments[2]!==void 0&&arguments[2];if(qi())try{var i={expiresIn:Date.now()+HS,value:n};r?localStorage.setItem(this.getRealKey(t),JSON.stringify(i)):(this.queue_.set(this.getRealKey(t),i),_t.hasTask(this.intervalId_)||(this.intervalId_=_t.run(Ja,this.doFlush.bind(this),{count:1})))}catch(o){be.warn(o)}}},{key:"deleteItem",value:function(t){if(!qi())return!1;try{return t=this.getRealKey(t),this.queue_.delete(t),localStorage.removeItem(t),!0}catch(n){return be.warn(n),!1}}},{key:"clear",value:function(){if(qi())try{localStorage.clear()}catch(t){be.warn(t)}}}]),e}(),no=new t6,mt={result:!1,detail:{isBrowserSupported:!1,isWebRTCSupported:!1,isMediaDevicesSupported:!1,isH264EncodeSupported:!1,isVp8EncodeSupported:!1,isH264DecodeSupported:!1,isVp8DecodeSupported:!1}},IT="checkResult",wT=function(){return!V4&&!nl&&!(rl&&bk<80)&&!(yr&&yk<56)},xm=function(){return["RTCPeerConnection","webkitRTCPeerConnection","RTCIceGatherer"].filter(function(e){return e in window}).length>0},n6=function(){if(!navigator.mediaDevices)return!1;var e=["getUserMedia","enumerateDevices"];return e.filter(function(t){return t in navigator.mediaDevices}).length===e.length},ET=function(){var e=N(m().mark(function t(){var n,r,i,o,a,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="",r=!1,i=!1,c.prev=5,o=new RTCPeerConnection,(a=document.createElement(sS)).getContext("2d"),s=a.captureStream(0),o.addTrack(s.getVideoTracks()[0],s),c.next=13,o.createOffer();case 13:return(n=c.sent).sdp.toLowerCase().indexOf("h264")!==-1&&(r=!0),n.sdp.toLowerCase().indexOf("vp8")!==-1&&(i=!0),o.close(),mt.detail.isH264EncodeSupported=r,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 r6(){return Im.apply(this,arguments)}function Im(){return Im=N(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=N(m().mark(function r(i){var o,a,s,c,u,d,p,h,f,_,y,S,E,R;return m().wrap(function(H){for(;;)switch(H.prev=H.next){case 0:return o={encode:!1,decode:!1},a=null,H.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,p=-1,a=function(){clearInterval(d),clearInterval(u),clearTimeout(p),f.close(),_.close(),h.getTracks().forEach(function(Y){return Y.stop()})},p=setTimeout(function(){a(),i(o)},3e3),h=s.captureStream(),f=new RTCPeerConnection({}),_=new RTCPeerConnection({offerToReceiveAudio:!0,offerToReceiveVideo:!0}),f.addEventListener("icecandidate",function(Y){return _.addIceCandidate(Y.candidate)}),_.addEventListener("icecandidate",function(Y){return f.addIceCandidate(Y.candidate)}),f.addTrack(h.getVideoTracks()[0],h),H.next=20,f.createOffer();case 20:return y=H.sent,H.next=23,f.setLocalDescription(y);case 23:return H.next=25,_.setRemoteDescription(y);case 25:return H.next=27,_.createAnswer();case 27:return S=H.sent,E=Br(S.sdp),R=E.media[0].rtp.findIndex(function(Y){return Y.codec==="H264"}),E.media[0].rtp=[E.media[0].rtp[R]],E.media[0].fmtp=E.media[0].fmtp.filter(function(Y){return Y.payload===E.media[0].rtp[0].payload}),E.media[0].rtcpFb=E.media[0].rtcpFb.filter(function(Y){return Y.payload===E.media[0].rtp[0].payload}),S.sdp=Za(E),H.next=36,_.setLocalDescription(S);case 36:return H.next=38,f.setRemoteDescription(S);case 38:d=setInterval(N(m().mark(function Y(){var ue,le;return m().wrap(function(O){for(;;)switch(O.prev=O.next){case 0:return o.encode&&o.decode&&(a(),i(o)),O.next=3,f.getStats();case 3:return ue=O.sent,O.next=6,_.getStats();case 6:le=O.sent,o.encode||ue.forEach(function(k){k.type==="outbound-rtp"&&k.mediaType===xe&&k.framesEncoded>0&&(o.encode=!0)}),o.decode||le.forEach(function(k){k.type==="inbound-rtp"&&k.mediaType===xe&&k.framesDecoded>0&&(o.decode=!0)});case 9:case"end":return O.stop()}},Y)})),500),H.next=46;break;case 41:H.prev=41,H.t0=H.catch(2),a(),be.warn(H.t0),i(o);case 46:case"end":return H.stop()}},r,null,[[2,41]])}));return function(r){return n.apply(this,arguments)}}()));case 1:case"end":return t.stop()}},e)})),Im.apply(this,arguments)}var CT=function(){var e=N(m().mark(function t(){var n,r,i,o;return m().wrap(function(a){for(;;)switch(a.prev=a.next){case 0:if(!mt.detail.isH264DecodeSupported||!mt.detail.isVp8DecodeSupported){a.next=2;break}return a.abrupt("return",{isH264DecodeSupported:mt.detail.isH264DecodeSupported,isVp8DecodeSupported:mt.detail.isVp8DecodeSupported});case 2:return n="",r=!1,i=!1,a.prev=5,o=new RTCPeerConnection,a.next=9,o.createOffer({offerToReceiveAudio:1,offerToReceiveVideo:1});case 9:return(n=a.sent).sdp.toLowerCase().indexOf("h264")!==-1&&(r=!0),n.sdp.toLowerCase().indexOf("vp8")!==-1&&(i=!0),o.close(),a.abrupt("return",{isH264DecodeSupported:r,isVp8DecodeSupported:i});case 16:return a.prev=16,a.t0=a.catch(5),a.abrupt("return",{isH264DecodeSupported:!1,isVp8DecodeSupported:!1});case 19:case"end":return a.stop()}},t,null,[[5,16]])}));return function(){return e.apply(this,arguments)}}(),i6=function(){var e=N(m().mark(function t(){var n,r,i,o,a,s,c,u,d,p,h,f,_;return m().wrap(function(y){for(;;)switch(y.prev=y.next){case 0:if(RT()){y.next=2;break}return y.abrupt("return",mt);case 2:return n=wT(),r=xm(),i=n6(),y.next=7,ET();case 7:return o=y.sent,a=o.isH264EncodeSupported,s=o.isVp8EncodeSupported,y.next=12,CT();case 12:if(c=y.sent,u=c.isH264DecodeSupported,d=c.isVp8DecodeSupported,a&&s){y.next=21;break}return y.next=18,ET();case 18:p=y.sent,a=p.isH264EncodeSupported,s=p.isVp8EncodeSupported;case 21:if(!(a&&u&&(al||ol||W4)&&!Or&&nc()<79)){y.next=29;break}return y.next=24,r6();case 24:h=y.sent,f=h.encode,_=h.decode,a=f,u=_;case 29:return mt.result=n&&r&&i&&(a||s)&&(u||d),mt.detail.isBrowserSupported=n,mt.detail.isWebRTCSupported=r,mt.detail.isMediaDevicesSupported=i,mt.detail.isH264EncodeSupported=a,mt.detail.isVp8EncodeSupported=s,mt.detail.isH264DecodeSupported=u,mt.detail.isVp8DecodeSupported=d,a6(),no.setItem(IT,{ua:navigator.userAgent,checkResult:mt},!0),y.abrupt("return",mt);case 40:case"end":return y.stop()}},t)}));return function(){return e.apply(this,arguments)}}(),wm=function(e,t){var n=null;return function(){if(n)return n;for(var r=arguments.length,i=new Array(r),o=0;o<r;o++)i[o]=arguments[o];return(n=e.apply(t||this,i)).then(function(a){return n=null,a}).catch(function(a){throw n=null,a}),n}}(i6);function RT(){return Object.keys(mt.detail).findIndex(function(e){return!mt.detail[e]})>=0}function a6(){RT()&&(be.warn(te({key:ck})),be.info("".concat(navigator.userAgent," ").concat(JSON.stringify(mt.detail))))}function AT(){return!(!navigator.mediaDevices||!navigator.mediaDevices.getDisplayMedia)}function PT(){return"RTCPeerConnection"in window&&"getReceivers"in window.RTCPeerConnection.prototype}function gl(){return"RTCPeerConnection"in window&&"getSenders"in window.RTCPeerConnection.prototype}function fi(){return"RTCPeerConnection"in window&&"getTransceivers"in window.RTCPeerConnection.prototype}function Em(){return"RTCPeerConnection"in window&&"addTransceiver"in window.RTCPeerConnection.prototype}function Cm(){return"RTCRtpSender"in window&&"replaceTrack"in window.RTCRtpSender.prototype}function DT(){return"RTCRtpSender"in window&&"setParameters"in window.RTCRtpSender.prototype&&gl()}function _l(){return!!fe(navigator.mediaDevices)&&(be.error(di.NOT_SUPPORTED_MEDIA),!0)}function yl(){return location.protocol==="http:"&&!Ka&&(be.warn(te({key:sk})),!0)}var Rm="RTCRtpSender"in window&&"createEncodedStreams"in window.RTCRtpSender.prototype&&nc()>=86;function Am(e){return!(e.type!=="candidate-pair"||!e.nominated||e.state!=="in-progress"&&e.state!=="succeeded")&&!(Ck(e.selected)&&!e.selected)}var LT=new Map([[qa,"Android"],[Lr,"iOS"],[kk,"Windows"],[tc,"MacOS"],[Tk,"Linux"]]);function Pm(){var e="unknown";return LT.get(!0)&&(e=LT.get(!0)),e}function o6(){var e="";return screen.width&&(e+=(screen.width?screen.width*window.devicePixelRatio:"")+" * "+(screen.height?screen.height*window.devicePixelRatio:"")),e}function s6(){var e=!1;return(navigator.getUserMedia||navigator.mediaDevices&&navigator.mediaDevices.getUserMedia)&&(e=!0),e}function c6(){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 OT(){return!(gf&&nc()<86)&&!(Lr&&br(Mr)&&Mr<15)&&!(Ef&&Ef<63)&&!(!wT()||!("captureStream"in HTMLCanvasElement.prototype))}var ro=window.MediaStreamTrack&&"getSettings"in MediaStreamTrack.prototype,u6=window.MediaStreamTrack&&"getCapabilities"in MediaStreamTrack.prototype,l6=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(){yl();var e=no.getItem(IT);e&&e.ua===navigator.userAgent&&(mt=e.checkResult),wm()})();var rt={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:dS},ot={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:dS,ERROR:"error"},MT="player-state-changed",d6="screen-sharing-stopped",h6="connection-state-changed",p6="device-auto-recovered",Dm="error",hn="player-state-changed",f6=YS;Oe({target:"String",proto:!0,forced:$S("small")},{small:function(){return f6(this,"small","","")}});var m6=function(){function e(o){z(this,e);var a=o.getUserId();this.log_=be.createLogger({id:a,userId:a,sdkAppId:o.getSDKAppId()}),this.prevReportTime_=0,this.prevReport_={},this.prevEncoderImplementation_="",this.prevQualityLimitationReason_="",this.prevDecoderImplementationMap_=new Map}var t,n,r,i;return ke(e,[{key:"statInterval",get:function(){return this.prevReportTime_===0?2:(Date.now()-this.prevReportTime_)/1e3}},{key:"getSenderStats",value:(i=N(m().mark(function o(a){var s,c,u,d,p=this;return m().wrap(function(h){for(;;)switch(h.prev=h.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=a.getPeerConnection(),u=a.getSSRC(),!c){h.next=15;break}return h.prev=4,h.next=7,c.getStats();case 7:h.sent.forEach(function(f){if(f.type==="outbound-rtp")if(f.mediaType===xe){if(!yr&&f.bytesSent===0)return;f.ssrc!==u.video||fe(f.encoderImplementation)||p.prevEncoderImplementation_===f.encoderImplementation||(p.log_.info("encoderImplementation change to ".concat(f.encoderImplementation)),p.prevEncoderImplementation_=f.encoderImplementation),f.ssrc!==u.video||fe(f.qualityLimitationReason)||p.prevQualityLimitationReason_===f.qualityLimitationReason||(p.log_.info("qualityLimitationReason change to ".concat(f.qualityLimitationReason)),p.prevQualityLimitationReason_=f.qualityLimitationReason);var _=xe;f.ssrc===u.small?_=Dr:f.ssrc===u.auxiliary&&(_=pt),s[_].bytesSent=f.bytesSent,s[_].packetsSent=f.packetsSent,s[_].framesEncoded=f.framesEncoded}else f.mediaType===Ce&&(s.audio.bytesSent=f.bytesSent,s.audio.packetsSent=f.packetsSent);else f.type==="candidate-pair"?Am(f)&&br(f.currentRoundTripTime)&&(s.rtt=Math.floor(1e3*f.currentRoundTripTime)):f.type==="media-source"&&(f.kind===Ce?(s.audio.audioLevel=f.audioLevel||0,s.audio.totalAudioEnergy=f.totalAudioEnergy||0):f.kind===xe&&(f.trackIdentifier===a.getVideoTrackId(xe)?s.video.fpsCapture=f.framesPerSecond:f.trackIdentifier===a.getVideoTrackId(pt)?s.auxiliary.fpsCapture=f.framesPerSecond:s.small.fpsCapture=f.framesPerSecond));var y;fe(f.audioLevel)||(s.audio.audioLevel=f.audioLevel||0,s.audio.totalAudioEnergy=f.totalAudioEnergy||0),fe(f.frameWidth)||(f.trackIdentifier===a.getVideoTrackId(xe)||f.ssrc===u.video?y=xe:f.trackIdentifier===a.getVideoTrackId(pt)||f.ssrc===u.auxiliary?y=pt:f.trackIdentifier!==a.getVideoTrackId(Dr)&&f.ssrc!==u.small||(y=Dr),y&&(s[y].frameWidth=f.frameWidth,s[y].frameHeight=f.frameHeight,s[y].framesSent=f.framesSent))}),s.audio.audioLevel===0&&(s.audio.audioLevel=((d=a.getLocalStream())===null||d===void 0?void 0:d.getInternalAudioLevel())||0),h.next=15;break;case 12:h.prev=12,h.t0=h.catch(4),this.log_.warn("failed to getStats on sender connection "+h.t0);case 15:return h.abrupt("return",s);case 16:case"end":return h.stop()}},o,this,[[4,12]])})),function(o){return i.apply(this,arguments)})},{key:"getReceiverStats",value:(r=N(m().mark(function o(a){var s,c,u,d,p,h=this;return m().wrap(function(f){for(;;)switch(f.prev=f.next){case 0:if(s={tinyId:a.getTinyId(),userId:a.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=a.getPeerConnection())){f.next=16;break}return f.prev=3,u=a.getSSRC(),d=a.getTrackState(),f.next=8,c.getStats();case 8:f.sent.forEach(function(_){if(_.type==="inbound-rtp"){if(_.mediaType===Ce&&_.ssrc===u.audio&&d.audio)s.audio.packetsReceived=_.packetsReceived,s.audio.bytesReceived=_.bytesReceived,s.audio.packetsLost=_.packetsLost,s.audio.jitter=_.jitter,s.hasAudio=!0;else if(_.mediaType===xe){if(yr&&_.bytesReceived===0)return;_.ssrc===u.video&&d.video&&(s.video.packetsReceived=_.packetsReceived,s.video.bytesReceived=_.bytesReceived,s.video.packetsLost=_.packetsLost,s.video.framesReceived=_.framesReceived,s.video.framesDecoded=_.framesDecoded,s.video.fpsDecoded=_.framesPerSecond,s.hasVideo=!0,!_.decoderImplementation||h.prevDecoderImplementationMap_.has(s.userId)&&h.prevDecoderImplementationMap_.get(s.userId)===_.decoderImplementation||(h.log_.info("".concat(s.userId," decoderImplementation change to ").concat(_.decoderImplementation)),h.prevDecoderImplementationMap_.set(s.userId,_.decoderImplementation))),_.ssrc===u.auxiliary&&d.auxiliary&&(s.auxiliary.packetsReceived=_.packetsReceived,s.auxiliary.bytesReceived=_.bytesReceived,s.auxiliary.packetsLost=_.packetsLost,s.auxiliary.framesReceived=_.framesReceived,s.auxiliary.framesDecoded=_.framesDecoded,s.auxiliary.fpsDecoded=_.framesPerSecond,s.hasAuxiliary=!0)}}else _.type==="candidate-pair"&&Am(_)&&br(_.currentRoundTripTime)&&(s.rtt=Math.floor(1e3*_.currentRoundTripTime));fe(_.frameWidth)||(_.trackIdentifier!==a.getMainStreamVideoTrackId()&&_.ssrc!==u.video||(s.video.frameWidth=_.frameWidth,s.video.frameHeight=_.frameHeight),_.trackIdentifier!==a.getAuxStreamVideoTrackId()&&_.ssrc!==u.auxiliary||(s.auxiliary.frameWidth=_.frameWidth,s.auxiliary.frameHeight=_.frameHeight)),fe(_.audioLevel)||(s.audio.audioLevel=_.audioLevel||0,s.audio.totalAudioEnergy=_.totalAudioEnergy||0)}),s.audio.audioLevel===0&&(s.audio.audioLevel=((p=a.getMainStream())===null||p===void 0?void 0:p.getInternalAudioLevel())||0),f.next=16;break;case 13:f.prev=13,f.t0=f.catch(3),this.log_.warn("failed to getStats on receiver connection "+f.t0);case 16:return f.abrupt("return",s);case 17:case"end":return f.stop()}},o,this,[[3,13]])})),function(o){return r.apply(this,arguments)})},{key:"getStats",value:(n=N(m().mark(function o(a,s){var c,u,d,p,h,f,_;return m().wrap(function(y){for(;;)switch(y.prev=y.next){case 0:if(c={},!a){y.next=5;break}return y.next=4,this.getSenderStats(a);case 4:c=y.sent;case 5:u=[],d=ne(s),y.prev=7,d.s();case 9:if((p=d.n()).done){y.next=17;break}return(h=Te(p.value,2))[0],f=h[1],y.next=13,this.getReceiverStats(f);case 13:_=y.sent,u.push(_);case 15:y.next=9;break;case 17:y.next=22;break;case 19:y.prev=19,y.t0=y.catch(7),d.e(y.t0);case 22:return y.prev=22,d.f(),y.finish(22);case 25:return y.abrupt("return",{senderStats:c,receiverStats:u});case 26:case"end":return y.stop()}},o,this,[[7,19,22,25]])})),function(o,a){return n.apply(this,arguments)})},{key:"getDifferenceValue",value:function(o,a){if($i(o))return a;var s=a-o;return s<0?0:s}},{key:"prepareReport",value:function(o){var a=this,s=o.stats,c=o.report,u=o.freezeMap;if(!$i(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 p=[],h={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(p.push(h),s.senderStats.small.bytesSent){var f={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};p.push(f)}if(s.senderStats.auxiliary.bytesSent){var _={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};p.push(_)}var y={uint32_bitrate:0,uint32_rtt:s.senderStats.rtt};c.msg_up_stream_info={msg_audio_status:d,msg_video_status:p,msg_network_status:y}}var S=this.statInterval;c.msg_down_stream_info=[],s.receiverStats.forEach(function(k){var P={};if(P.msg_user_info={str_identifier:k.userId,uint64_tinyid:k.tinyId},P.msg_network_status={uint32_rtt:k.rtt},P.msg_video_status={},k.hasAudio){var A={uint32_audio_codec_bitrate:k.audio.bytesReceived,uint32_audio_total_bitrate:k.audio.bytesReceived,uint32_audio_level:1e8*k.audio.audioLevel,uint32_audio_energy:1e6*k.audio.totalAudioEnergy,uint32_audio_receive:k.audio.packetsReceived,uint32_audio_origin_lost:k.audio.packetsLost,audioLevel:k.audio.audioLevel};P.msg_audio_status=A}if(P.msg_video_status=[],k.hasVideo){var U=u.get(k.userId+"_"+gt),T=U?U.duration:0,g={uint32_video_stream_type:2,uint32_video_receive_fps:k.video.framesReceived,uint32_video_width:k.video.frameWidth,uint32_video_height:k.video.frameHeight,uint32_video_codec_bitrate:k.video.bytesReceived,uint32_video_receive:k.video.packetsReceived,uint32_video_origin_lost:k.video.packetsLost,uint32_video_block_time:T,uint32_video_dec_fps:k.video.framesDecoded};P.msg_video_status.push(g)}if(k.hasAuxiliary){var I=u.get(k.userId+"_"+Pt),w=I?I.duration:0,L={uint32_video_stream_type:7,uint32_video_receive_fps:k.auxiliary.framesReceived,uint32_video_width:k.auxiliary.frameWidth,uint32_video_height:k.auxiliary.frameHeight,uint32_video_codec_bitrate:k.auxiliary.bytesReceived,uint32_video_receive:k.auxiliary.packetsReceived+k.auxiliary.packetsLost,uint32_video_origin_lost:k.auxiliary.packetsLost,uint32_video_block_time:w,uint32_video_dec_fps:k.auxiliary.framesDecoded};P.msg_video_status.push(L)}c.msg_down_stream_info.push(P)});var E=this.prevReport_;if(this.prevReport_=JSON.parse(JSON.stringify(c)),c.msg_up_stream_info.msg_audio_status&&E.msg_up_stream_info.msg_audio_status){var R=E.msg_up_stream_info.msg_audio_status,H=c.msg_up_stream_info.msg_audio_status,Y=this.getDifferenceValue(R.uint32_audio_codec_bitrate,H.uint32_audio_codec_bitrate);H.uint32_audio_codec_bitrate=Math.round(8*Y/S),c.msg_up_stream_info.msg_network_status.uint32_bitrate+=H.uint32_audio_codec_bitrate}var ue=E.msg_up_stream_info.msg_video_status;c.msg_up_stream_info.msg_video_status.forEach(function(k){var P=ue.find(function(I){return I.uint32_video_stream_type===k.uint32_video_stream_type});if(!P||P.uint32_video_codec_bitrate===0)return k.uint32_video_codec_bitrate=0,k.uint32_video_enc_fps=0,void(k.uint32_video_codec_fps=0);var A=P.uint32_video_codec_bitrate,U=P.uint32_video_enc_fps,T=P.uint32_video_codec_fps,g=a.getDifferenceValue(A,k.uint32_video_codec_bitrate);k.uint32_video_codec_bitrate=Math.round(8*g/S),c.msg_up_stream_info.msg_network_status.uint32_bitrate+=k.uint32_video_codec_bitrate,k.uint32_video_enc_fps=Math.round(a.getDifferenceValue(U,k.uint32_video_enc_fps)/S),k.uint32_video_codec_fps=Math.round(a.getDifferenceValue(T,k.uint32_video_codec_fps)/S)});var le=c.msg_down_stream_info,O=E.msg_down_stream_info;return le.forEach(function(k){var P=O.find(function(w){return w.msg_user_info.uint64_tinyid===k.msg_user_info.uint64_tinyid});if(P){if(k.msg_audio_status&&P.msg_audio_status){var A=k.msg_audio_status,U=P.msg_audio_status;A.uint32_audio_origin_lost=a.getDifferenceValue(U.uint32_audio_origin_lost,A.uint32_audio_origin_lost),A.uint32_audio_receive=a.getDifferenceValue(U.uint32_audio_receive,A.uint32_audio_receive),A.uint32_audio_receive+=A.uint32_audio_origin_lost;var T=a.getDifferenceValue(U.uint32_audio_codec_bitrate,A.uint32_audio_codec_bitrate);A.uint32_audio_codec_bitrate=Math.round(8*T/S),A.uint32_audio_total_bitrate=Math.round(8*T/S)}if(k.msg_video_status&&P.msg_video_status){var g=k.msg_video_status,I=P.msg_video_status;g.forEach(function(w){var L=I.find(function(Ge){return Ge.uint32_video_stream_type===w.uint32_video_stream_type});if(!L)return w.uint32_video_receive=0,w.uint32_video_origin_lost=0,w.uint32_video_codec_bitrate=0,w.uint32_video_receive_fps=0,void(w.uint32_video_dec_fps=0);var B=L.uint32_video_receive,ee=L.uint32_video_origin_lost,oe=L.uint32_video_codec_bitrate,ve=L.uint32_video_receive_fps,ge=L.uint32_video_dec_fps;w.uint32_video_origin_lost=a.getDifferenceValue(ee,w.uint32_video_origin_lost),w.uint32_video_receive=a.getDifferenceValue(B,w.uint32_video_receive)+w.uint32_video_origin_lost;var qe=a.getDifferenceValue(oe,w.uint32_video_codec_bitrate);w.uint32_video_codec_bitrate=Math.round(8*qe/S);var Ne=a.getDifferenceValue(ve,w.uint32_video_receive_fps);w.uint32_video_receive_fps=Math.round(Ne/S),w.uint32_video_dec_fps=Math.round(a.getDifferenceValue(ge,w.uint32_video_dec_fps)/S)})}}}),c}},{key:"getStatsReport",value:(t=N(m().mark(function o(a){var s,c,u,d,p;return m().wrap(function(h){for(;;)switch(h.prev=h.next){case 0:return s=a.uplinkConnection,c=a.downlinkConnections,u=a.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}}]},h.next=4,this.getStats(s,c);case 4:return p=h.sent,JSON.stringify(this.prevReport_)==="{}"&&(this.prevReport_=JSON.parse(JSON.stringify(d))),this.prepareReport({stats:p,report:d,freezeMap:u,uplinkConnection:s,downlinkConnections:c}),this.prevReportTime_=Date.now(),h.abrupt("return",d);case 9:case"end":return h.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}(),v6=function(){function e(r){var i=r.signalChannel,o=r.connections,a=r.client;z(this,e),this.client_=a,this.signalChannel_=i,this.connections_=o,this.client_=a,this.log_=be.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 pi,this.initialize()}var t,n;return ke(e,[{key:"uplinkNetworkQuality",get:function(){return this.uplinkNetworkQuality_},set:function(r){r!==this.uplinkNetworkQuality_&&this.log_.info("uplink network quality change ".concat(this.uplinkNetworkQuality," -> ").concat(r,", rtt: ").concat(this.uplinkRTT_,", loss: ").concat(this.uplinkLoss_)),this.uplinkNetworkQuality_=r}},{key:"downlinkNetworkQuality",get:function(){return this.downlinkNetworkQuality_},set:function(r){if(r!==this.downlinkNetworkQuality_){var i=this.getAverageLossAndRTT(Se(this.downlinkLossAndRTTMap_.values())),o=i.rtt,a=i.loss;this.log_.info("downlink network quality change ".concat(this.downlinkNetworkQuality," -> ").concat(r,", rtt: ").concat(o,", loss: ").concat(a))}this.downlinkNetworkQuality_=r}},{key:"initialize",value:function(){var r=this;this.signalChannel_.on(ft.UPLINK_NETWORK_STATS,function(i){r.handleUplinkNetworkQuality(i)}),this.signalChannel_.on(dm,this.handleSignalConnectionStateChange.bind(this)),this.start()}},{key:"handleUplinkNetworkQuality",value:function(r){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(r.data.code===0){var o=r.data.data,a=o.expectAudPkg+o.expectVidPkg,s=o.recvAudPkg+o.recvVidPkg,c=a-s,u=o.delay;if(u&&this.updateDelay(u),a===0&&s===0)return;this.uplinkLoss_=c<=0?0:Math.round(c/a*100),this.uplinkRTT_=o.rtt,this.uplinkNetworkQuality=this.getNetworkQuality(this.uplinkLoss_,this.uplinkRTT_)}}},{key:"handleDownlinkNetworkQuality",value:(n=N(m().mark(function r(){var i,o,a,s,c,u,d,p,h,f,_,y,S,E,R,H=this;return m().wrap(function(Y){for(;;)switch(Y.prev=Y.next){case 0:if(this.connections_&&this.connections_.size!==0){Y.next=3;break}return this.downlinkNetworkQuality=0,Y.abrupt("return");case 3:if(i=Se(this.connections_.values()),o=i.filter(function(ue){return ue.getPeerConnection()&&ue.getPeerConnection().connectionState===_S}),i.filter(function(ue){return ue.getPeerConnection()&&H.isPeerConnectionDisconnected(ue.getPeerConnection())}).length!==i.length){Y.next=9;break}return this.downlinkNetworkQuality=6,Y.abrupt("return");case 9:a=0;case 10:if(!(a<o.length)){Y.next=31;break}return s=o[a].getPeerConnection(),Y.next=14,this.getStat(s);case 14:if(c=Y.sent,u=c.rtt,d=c.totalPacketsLost,p=c.totalPacketsReceived,this.downlinkPrevStatMap_.has(s)){Y.next=21;break}return this.downlinkPrevStatMap_.set(s,{totalPacketsLost:d,totalPacketsReceived:p}),Y.abrupt("continue",28);case 21:h=0,f=this.downlinkPrevStatMap_.get(s),_=d-f.totalPacketsLost,y=p-f.totalPacketsReceived,h=_<=0||y<0?0:Math.round(_/(_+y)*100),this.downlinkPrevStatMap_.set(s,{totalPacketsLost:d,totalPacketsReceived:p}),this.downlinkLossAndRTTMap_.set(s,{rtt:u,loss:h,userId:o[a].getUserId()});case 28:a++,Y.next=10;break;case 31:if(Se(this.downlinkPrevStatMap_.keys()).forEach(function(ue){H.isPeerConnectionDisconnected(ue)&&(H.downlinkPrevStatMap_.delete(ue),H.downlinkLossAndRTTMap_.delete(ue))}),this.downlinkLossAndRTTMap_.size!==0){Y.next=34;break}return Y.abrupt("return");case 34:S=this.getAverageLossAndRTT(Se(this.downlinkLossAndRTTMap_.values())),E=S.rtt,R=S.loss,this.downlinkRTT_=E,this.downlinkLoss_=R,this.downlinkNetworkQuality=this.getNetworkQuality(R,E);case 38:case"end":return Y.stop()}},r,this)})),function(){return n.apply(this,arguments)})},{key:"getStat",value:(t=N(m().mark(function r(i){var o,a,s,c;return m().wrap(function(u){for(;;)switch(u.prev=u.next){case 0:if(o={rtt:0,totalPacketsLost:0,totalPacketsReceived:0},i&&PT()){u.next=3;break}return u.abrupt("return",o);case 3:a=i.getReceivers(),u.prev=4,s=0;case 6:if(!(s<a.length)){u.next=15;break}return c=a[s],u.next=10,c.getStats();case 10:u.sent.forEach(function(d){d.type==="candidate-pair"&&br(d.currentRoundTripTime)&&(o.rtt=Math.round(1e3*d.currentRoundTripTime)),d.type!=="inbound-rtp"||d.mediaType!==Ce&&d.mediaType!==xe||(o.totalPacketsLost+=d.packetsLost,o.totalPacketsReceived+=d.packetsReceived)});case 12:s++,u.next=6;break;case 15:return u.abrupt("return",o);case 18:return u.prev=18,u.t0=u.catch(4),u.abrupt("return",o);case 21:case"end":return u.stop()}},r,null,[[4,18]])})),function(r){return t.apply(this,arguments)})},{key:"getAverageLossAndRTT",value:function(r){var i={rtt:0,loss:0};return Array.isArray(r)&&r.length>0&&(r.forEach(function(o){i.rtt+=o.rtt,i.loss+=o.loss}),Object.keys(i).forEach(function(o){i[o]=Math.round(i[o]/r.length)})),i}},{key:"getNetworkQuality",value:function(r,i){return r>50||i>500?5:r>30||i>350?4:r>20||i>200?3:r>10||i>100?2:r>=0||i>=0?1:0}},{key:"handleSignalConnectionStateChange",value:function(r){r.state===vl?(this.uplinkRTT_=0,this.uplinkLoss_=0,this.uplinkNetworkQuality=6):r.state===cc&&this.uplinkNetworkQuality===6&&(this.uplinkNetworkQuality=5)}},{key:"handleUplinkConnectionStateChange",value:function(r){var i=r.state;i===nn?(this.uplinkLoss_=0,this.uplinkRTT_=0,this.uplinkNetworkQuality=6):i===ln&&this.uplinkNetworkQuality===6&&(this.uplinkNetworkQuality=5)}},{key:"isPeerConnectionDisconnected",value:function(r){return!(!r||r.connectionState!==fN&&r.connectionState!==gS&&r.connectionState!==Kp)}},{key:"setUplinkConnection",value:function(r){this.uplinkConnection_=r,this.uplinkConnection_?this.uplinkConnection_.on(rt.CONNECTION_STATE_CHANGED,this.handleUplinkConnectionStateChange.bind(this)):(this.uplinkNetworkQuality=0,this.uplinkRTT_=0,this.uplinkLoss_=0)}},{key:"start",value:function(){var r=this;this.interval_===-1?(this.log_.info("start network quality calculating"),this.interval_=_t.run(Ja,function(){r.handleDownlinkNetworkQuality(),W.emit(am,{client:r.client_,uplinkNetworkQuality:r.uplinkNetworkQuality,downlinkNetworkQuality:r.downlinkNetworkQuality,uplinkRTT:r.uplinkRTT_,uplinkLoss:r.uplinkLoss_,downlinkRTT:r.downlinkRTT_,downlinkLoss:r.downlinkLoss_,downlinkLossAndRTTMap:r.downlinkLossAndRTTMap_}),r.emitter_.emit(ot.NETWORK_QUALITY,{uplinkNetworkQuality:r.uplinkNetworkQuality,downlinkNetworkQuality:r.downlinkNetworkQuality,uplinkRTT:r.uplinkRTT_,uplinkLoss:r.uplinkLoss_,downlinkRTT:r.downlinkRTT_,downlinkLoss:r.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(r,i){this.emitter_.on(r,i)}},{key:"updateDelay",value:function(r){var i=this;r.forEach(function(o){var a=o.srcTinyId,s=o.videoDelay,c=o.audioDelay,u=i.connections_.get(a);u&&u.setDelay({videoDelay:s,audioDelay:c})})}}]),e}(),g6=function(){function e(r){z(this,e),this.log_=be.createLogger({id:r.client.getUserId(),userId:r.client.getUserId(),sdkAppId:r.client.getSDKAppId()}),this.localStream_=null,this.prevDevices_=[],this.initialize()}var t,n;return ke(e,[{key:"initialize",value:function(){navigator.mediaDevices&&(this.onDeviceChange=this.onDeviceChange.bind(this),navigator.mediaDevices.addEventListener("devicechange",this.onDeviceChange))}},{key:"destroy",value:function(){navigator.mediaDevices&&navigator.mediaDevices.removeEventListener("devicechange",this.onDeviceChange)}},{key:"onDeviceChange",value:(n=N(m().mark(function r(){var i,o,a,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,Om();case 4:i=c.sent,o=i.filter(function(u){return s.prevDevices_.findIndex(function(d){var p=d.deviceId;return u.deviceId===p})<0}),a=this.prevDevices_.filter(function(u){return i.findIndex(function(d){var p=d.deviceId;return u.deviceId===p})<0}),o.length>0&&this.handleDeviceAdded(this.prevDevices_,o),a.length>0&&this.handleDeviceRemoved(i,a),this.prevDevices_=i;case 10:case"end":return c.stop()}},r,this)})),function(){return n.apply(this,arguments)})},{key:"setLocalStream",value:(t=N(m().mark(function r(i){return m().wrap(function(o){for(;;)switch(o.prev=o.next){case 0:if(!i){o.next=4;break}return o.next=3,Om();case 3:this.prevDevices_=o.sent;case 4:this.localStream_=i;case 5:case"end":return o.stop()}},r,this)})),function(r){return t.apply(this,arguments)})},{key:"handleDeviceAdded",value:function(r,i){var o,a;if(this.localStream_){this.log_.warn("devicesAdded: ".concat(JSON.stringify(i))),this.localStream_.updateDeviceIdInUse();var s=i.filter(function(f){return f.kind===Wu}),c=i.filter(function(f){return f.kind===Qs}),u=r.filter(function(f){return f.kind===Wu}),d=r.filter(function(f){return f.kind===Qs}),p=s.length>0&&u.length===0&&((o=this.localStream_.getVideoTrack())===null||o===void 0?void 0:o.readyState)!=="live",h=c.length>0&&d.length===0&&((a=this.localStream_.getAudioTrack())===null||a===void 0?void 0:a.readyState)!=="live";if(h&&p)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});p&&(this.log_.info("new camera detected, but there was no camera before."),this.localStream_.recoverCapture({audio:!1,video:!0,cameraId:s[0].deviceId})),h&&(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(r,i){if(this.localStream_){this.log_.warn("devicesRemoved: ".concat(JSON.stringify(i))),this.localStream_.updateDeviceIdInUse();var o=!1,a=!1,s=this.localStream_.getCameraId(),c=this.localStream_.getMicrophoneId();if(c===$u){var u=this.localStream_.getMicrophoneGroupId(),d=r.filter(function(p){return p.deviceId===$u&&p.kind===Qs})[0];d&&d.groupId!==u&&(a=!0)}if(i.forEach(function(p){var h=p.deviceId;s.length>0&&h===s?o=!0:c.length>0&&h===c&&(a=!0)}),o&&a)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}));o&&(this.log_.warn("current camera in use is lost, deviceId: ".concat(s)),this.localStream_.getVideo()&&this.localStream_.recoverCapture({video:!0,audio:!1})),a&&(this.log_.warn("current microphone in use is lost, deviceId: ".concat(c)),this.localStream_.getAudio()&&this.localStream_.recoverCapture({video:!1,audio:!0}))}}}]),e}();function Lm(){return Lm=N(m().mark(function e(){var t;return m().wrap(function(n){for(;;)switch(n.prev=n.next){case 0:if(!yl()&&!_l()){n.next=2;break}return n.abrupt("return",[]);case 2:return n.next=4,bl();case 4:return t=n.sent,n.abrupt("return",t.filter(function(r){return r.kind===Wu}).map(function(r,i){var o=r.label;r.label||(o="camera_"+i);var a={label:o,deviceId:r.deviceId,kind:r.kind};return r.groupId&&(a.groupId=r.groupId),r.getCapabilities&&(a.getCapabilities=function(){return r.getCapabilities()}),a}));case 6:case"end":return n.stop()}},e)})),Lm.apply(this,arguments)}var NT=new Set;function bl(){return VT.apply(this,arguments)}function VT(){return(VT=N(m().mark(function e(){var t;return m().wrap(function(n){for(;;)switch(n.prev=n.next){case 0:if(!yl()&&!_l()){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(r){NT.add("".concat(r.deviceId,"_").concat(r.kind))}),n.abrupt("return",t);case 7:case"end":return n.stop()}},e)}))).apply(this,arguments)}function Om(){return Mm.apply(this,arguments)}function Mm(){return Mm=N(m().mark(function e(){var t;return m().wrap(function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,bl();case 2:return t=n.sent,n.abrupt("return",t.filter(function(r){return r.kind!==Qs||r.deviceId!=qS}).map(function(r,i){var o=r.label;r.label||(o=r.kind+"_"+i);var a={label:o,deviceId:r.deviceId,kind:r.kind};return r.groupId&&(a.groupId=r.groupId),r.getCapabilities&&(a.getCapabilities=function(){return r.getCapabilities()}),a}));case 4:case"end":return n.stop()}},e)})),Mm.apply(this,arguments)}function UT(){return Nm.apply(this,arguments)}function Nm(){return Nm=N(m().mark(function e(){var t;return m().wrap(function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,bl();case 2:return t=n.sent,n.abrupt("return",t.filter(function(r){return r.kind===Qs&&r.deviceId!==qS}).map(function(r,i){var o=r.label;r.label||(o="microphone_"+i);var a={label:o,deviceId:r.deviceId,kind:r.kind};return r.groupId&&(a.groupId=r.groupId),r.getCapabilities&&(a.getCapabilities=function(){return r.getCapabilities()}),a}));case 4:case"end":return n.stop()}},e)})),Nm.apply(this,arguments)}function Vm(){return Vm=N(m().mark(function e(){var t;return m().wrap(function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,bl();case 2:return t=n.sent,n.abrupt("return",t.filter(function(r){return r.kind==="audiooutput"}).map(function(r,i){var o=r.label;r.label||(o="speaker_"+i);var a={label:o,deviceId:r.deviceId,kind:r.kind};return r.groupId&&(a.groupId=r.groupId),a}));case 4:case"end":return n.stop()}},e)})),Vm.apply(this,arguments)}function _6(e){var t;if(e instanceof CanvasCaptureMediaStreamTrack||!(e instanceof MediaStreamTrack))return!1;var n=e.label.toLocaleLowerCase();if(n.includes("camera")||n.includes("webcam"))return!0;var r="".concat((t=e.getSettings())===null||t===void 0?void 0:t.deviceId,"_").concat(Wu);return!!NT.has(r)}function y6(e,t){return BT.apply(this,arguments)}function BT(){return(BT=N(m().mark(function e(t,n){var r,i;return m().wrap(function(o){for(;;)switch(o.prev=o.next){case 0:return o.next=2,UT();case 2:if(r=o.sent,((i=r.find(function(a){return a.deviceId===$u}))==null?void 0:i.groupId)!==t||i.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 Nn,jT=ma.exports,b6=At,S6=dt,k6=X_,T6=Pr,x6=Ke,I6=Rt,w6=function(e,t,n,r){try{return r?t(S6(n)[0],n[1]):t(n)}catch(i){k6(e,"throw",i)}},E6=gh,C6=ku,R6=Zt,FT=Ts,A6=_u,P6=Is,GT=Array,ea=ce,Um=2147483647,D6=/[^\0-\u007E]/,HT=/[.\u3002\uFF0E\uFF61]/g,zT="Overflow: input needs wider integers to process",WT=RangeError,L6=ea(HT.exec),io=Math.floor,Bm=String.fromCharCode,JT=ea("".charCodeAt),qT=ea([].join),mi=ea([].push),O6=ea("".replace),M6=ea("".split),N6=ea("".toLowerCase),KT=function(e){return e+22+75*(e<26)},V6=function(e,t,n){var r=0;for(e=n?io(e/700):e>>1,e+=io(e/t);e>455;)e=io(e/35),r+=36;return io(r+36*e/(e+38))},U6=function(e){var t=[];e=function(E){for(var R=[],H=0,Y=E.length;H<Y;){var ue=JT(E,H++);if(ue>=55296&&ue<=56319&&H<Y){var le=JT(E,H++);(64512&le)==56320?mi(R,((1023&ue)<<10)+(1023&le)+65536):(mi(R,ue),H--)}else mi(R,ue)}return R}(e);var n,r,i=e.length,o=128,a=0,s=72;for(n=0;n<e.length;n++)(r=e[n])<128&&mi(t,Bm(r));var c=t.length,u=c;for(c&&mi(t,"-");u<i;){var d=Um;for(n=0;n<e.length;n++)(r=e[n])>=o&&r<d&&(d=r);var p=u+1;if(d-o>io((Um-a)/p))throw WT(zT);for(a+=(d-o)*p,o=d,n=0;n<e.length;n++){if((r=e[n])<o&&++a>Um)throw WT(zT);if(r==o){for(var h=a,f=36;;){var _=f<=s?1:f>=s+26?26:f-s;if(h<_)break;var y=h-_,S=36-_;mi(t,Bm(KT(_+y%S))),h=io(y/S),f+=36}mi(t,Bm(KT(h))),s=V6(a,p,u==c),a=0,u++}}a++,o++}return qT(t,"")},B6=Oe,jm=_e,j6=m0,Fm=Z,QT=Pr,Vn=ce,Sl=Wt,Un=function(e,t,n){return n.get&&jT(n.get,t,{getter:!0}),n.set&&jT(n.set,t,{setter:!0}),b6.f(e,t,n)},F6=ti,Gm=kt,Hm=Xk,ao=function(e){var t=I6(e),n=C6(this),r=arguments.length,i=r>1?arguments[1]:void 0,o=i!==void 0;o&&(i=T6(i,r>2?arguments[2]:void 0));var a,s,c,u,d,p,h=P6(t),f=0;if(!h||this===GT&&E6(h))for(a=R6(t),s=n?new this(a):GT(a);a>f;f++)p=o?i(t[f],f):t[f],FT(s,f,p);else for(d=(u=A6(t,h)).next,s=n?new this:[];!(c=x6(d,u)).done;f++)p=o?w6(u,i,[c.value,f],!0):c.value,FT(s,f,p);return s.length=f,s},$n=xs,G6=xh.codeAt,H6=function(e){var t,n,r=[],i=M6(O6(N6(e),HT,"."),".");for(t=0;t<i.length;t++)n=i[t],mi(r,L6(D6,n)?"xn--"+U6(n):n);return qT(r,".")},jr=Vt,z6=Ni,W6=Su,XT=ND,YT=Qe,J6=YT.set,kl=YT.getterFor("URL"),q6=XT.URLSearchParams,K6=XT.getState,hc=Fm.URL,zm=Fm.TypeError,Tl=Fm.parseInt,Q6=Math.floor,$T=Math.pow,Bn=Vn("".charAt),Zn=Vn(/./.exec),pc=Vn([].join),X6=Vn(1 .toString),Y6=Vn([].pop),oo=Vn([].push),ZT=Vn("".replace),$6=Vn([].shift),Z6=Vn("".split),fc=Vn("".slice),xl=Vn("".toLowerCase),e5=Vn([].unshift),Wm="Invalid scheme",ta="Invalid host",e1="Invalid port",t1=/[a-z]/i,t5=/[\d+-.a-z]/i,Jm=/\d/,n5=/^0x/i,r5=/^[0-7]+$/,i5=/^\d+$/,n1=/^[\da-f]+$/i,a5=/[\0\t\n\r #%/:<>?@[\\\]^|]/,o5=/[\0\t\n\r #/:<>?@[\\\]^|]/,s5=/^[\u0000-\u0020]+|[\u0000-\u0020]+$/g,c5=/[\t\n\r]/g,mc=function(e){var t,n,r,i;if(typeof e=="number"){for(t=[],n=0;n<4;n++)e5(t,e%256),e=Q6(e/256);return pc(t,".")}if(typeof e=="object"){for(t="",r=function(o){for(var a=null,s=1,c=null,u=0,d=0;d<8;d++)o[d]!==0?(u>s&&(a=c,s=u),c=null,u=0):(c===null&&(c=d),++u);return u>s&&(a=c,s=u),a}(e),n=0;n<8;n++)i&&e[n]===0||(i&&(i=!1),r===n?(t+=n?":":"::",i=!0):(t+=X6(e[n],16),n<7&&(t+=":")));return"["+t+"]"}return e},Il={},r1=Hm({},Il,{" ":1,'"':1,"<":1,">":1,"`":1}),i1=Hm({},r1,{"#":1,"?":1,"{":1,"}":1}),qm=Hm({},i1,{"/":1,":":1,";":1,"=":1,"@":1,"[":1,"\\":1,"]":1,"^":1,"|":1}),vi=function(e,t){var n=G6(e,0);return n>32&&n<127&&!Gm(t,e)?e:encodeURIComponent(e)},wl={ftp:21,file:null,http:80,https:443,ws:80,wss:443},vc=function(e,t){var n;return e.length==2&&Zn(t1,Bn(e,0))&&((n=Bn(e,1))==":"||!t&&n=="|")},a1=function(e){var t;return e.length>1&&vc(fc(e,0,2))&&(e.length==2||(t=Bn(e,2))==="/"||t==="\\"||t==="?"||t==="#")},u5=function(e){return e==="."||xl(e)==="%2e"},Km={},o1={},Qm={},s1={},c1={},Xm={},u1={},l1={},El={},Cl={},Ym={},$m={},Zm={},ev={},d1={},tv={},so={},Sr={},h1={},na={},Fr={},nv=function(e,t,n){var r,i,o,a=jr(e);if(t){if(i=this.parse(a))throw zm(i);this.searchParams=null}else{if(n!==void 0&&(r=new nv(n,!0)),i=this.parse(a,null,r))throw zm(i);(o=K6(new q6)).bindURL(this),this.searchParams=o}};nv.prototype={type:"URL",parse:function(e,t,n){var r,i,o,a,s,c=this,u=t||Km,d=0,p="",h=!1,f=!1,_=!1;for(e=jr(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=ZT(e,s5,"")),e=ZT(e,c5,""),r=ao(e);d<=r.length;){switch(i=r[d],u){case Km:if(!i||!Zn(t1,i)){if(t)return Wm;u=Qm;continue}p+=xl(i),u=o1;break;case o1:if(i&&(Zn(t5,i)||i=="+"||i=="-"||i=="."))p+=xl(i);else{if(i!=":"){if(t)return Wm;p="",u=Qm,d=0;continue}if(t&&(c.isSpecial()!=Gm(wl,p)||p=="file"&&(c.includesCredentials()||c.port!==null)||c.scheme=="file"&&!c.host))return;if(c.scheme=p,t)return void(c.isSpecial()&&wl[c.scheme]==c.port&&(c.port=null));p="",c.scheme=="file"?u=ev:c.isSpecial()&&n&&n.scheme==c.scheme?u=s1:c.isSpecial()?u=l1:r[d+1]=="/"?(u=c1,d++):(c.cannotBeABaseURL=!0,oo(c.path,""),u=h1)}break;case Qm:if(!n||n.cannotBeABaseURL&&i!="#")return Wm;if(n.cannotBeABaseURL&&i=="#"){c.scheme=n.scheme,c.path=$n(n.path),c.query=n.query,c.fragment="",c.cannotBeABaseURL=!0,u=Fr;break}u=n.scheme=="file"?ev:Xm;continue;case s1:if(i!="/"||r[d+1]!="/"){u=Xm;continue}u=El,d++;break;case c1:if(i=="/"){u=Cl;break}u=Sr;continue;case Xm:if(c.scheme=n.scheme,i==Nn)c.username=n.username,c.password=n.password,c.host=n.host,c.port=n.port,c.path=$n(n.path),c.query=n.query;else if(i=="/"||i=="\\"&&c.isSpecial())u=u1;else if(i=="?")c.username=n.username,c.password=n.password,c.host=n.host,c.port=n.port,c.path=$n(n.path),c.query="",u=na;else{if(i!="#"){c.username=n.username,c.password=n.password,c.host=n.host,c.port=n.port,c.path=$n(n.path),c.path.length--,u=Sr;continue}c.username=n.username,c.password=n.password,c.host=n.host,c.port=n.port,c.path=$n(n.path),c.query=n.query,c.fragment="",u=Fr}break;case u1:if(!c.isSpecial()||i!="/"&&i!="\\"){if(i!="/"){c.username=n.username,c.password=n.password,c.host=n.host,c.port=n.port,u=Sr;continue}u=Cl}else u=El;break;case l1:if(u=El,i!="/"||Bn(p,d+1)!="/")continue;d++;break;case El:if(i!="/"&&i!="\\"){u=Cl;continue}break;case Cl:if(i=="@"){h&&(p="%40"+p),h=!0,o=ao(p);for(var y=0;y<o.length;y++){var S=o[y];if(S!=":"||_){var E=vi(S,qm);_?c.password+=E:c.username+=E}else _=!0}p=""}else if(i==Nn||i=="/"||i=="?"||i=="#"||i=="\\"&&c.isSpecial()){if(h&&p=="")return"Invalid authority";d-=ao(p).length+1,p="",u=Ym}else p+=i;break;case Ym:case $m:if(t&&c.scheme=="file"){u=tv;continue}if(i!=":"||f){if(i==Nn||i=="/"||i=="?"||i=="#"||i=="\\"&&c.isSpecial()){if(c.isSpecial()&&p=="")return ta;if(t&&p==""&&(c.includesCredentials()||c.port!==null))return;if(a=c.parseHost(p))return a;if(p="",u=so,t)return;continue}i=="["?f=!0:i=="]"&&(f=!1),p+=i}else{if(p=="")return ta;if(a=c.parseHost(p))return a;if(p="",u=Zm,t==$m)return}break;case Zm:if(!Zn(Jm,i)){if(i==Nn||i=="/"||i=="?"||i=="#"||i=="\\"&&c.isSpecial()||t){if(p!=""){var R=Tl(p,10);if(R>65535)return e1;c.port=c.isSpecial()&&R===wl[c.scheme]?null:R,p=""}if(t)return;u=so;continue}return e1}p+=i;break;case ev:if(c.scheme="file",i=="/"||i=="\\")u=d1;else{if(!n||n.scheme!="file"){u=Sr;continue}if(i==Nn)c.host=n.host,c.path=$n(n.path),c.query=n.query;else if(i=="?")c.host=n.host,c.path=$n(n.path),c.query="",u=na;else{if(i!="#"){a1(pc($n(r,d),""))||(c.host=n.host,c.path=$n(n.path),c.shortenPath()),u=Sr;continue}c.host=n.host,c.path=$n(n.path),c.query=n.query,c.fragment="",u=Fr}}break;case d1:if(i=="/"||i=="\\"){u=tv;break}n&&n.scheme=="file"&&!a1(pc($n(r,d),""))&&(vc(n.path[0],!0)?oo(c.path,n.path[0]):c.host=n.host),u=Sr;continue;case tv:if(i==Nn||i=="/"||i=="\\"||i=="?"||i=="#"){if(!t&&vc(p))u=Sr;else if(p==""){if(c.host="",t)return;u=so}else{if(a=c.parseHost(p))return a;if(c.host=="localhost"&&(c.host=""),t)return;p="",u=so}continue}p+=i;break;case so:if(c.isSpecial()){if(u=Sr,i!="/"&&i!="\\")continue}else if(t||i!="?")if(t||i!="#"){if(i!=Nn&&(u=Sr,i!="/"))continue}else c.fragment="",u=Fr;else c.query="",u=na;break;case Sr:if(i==Nn||i=="/"||i=="\\"&&c.isSpecial()||!t&&(i=="?"||i=="#")){if((s=xl(s=p))===".."||s==="%2e."||s===".%2e"||s==="%2e%2e"?(c.shortenPath(),i=="/"||i=="\\"&&c.isSpecial()||oo(c.path,"")):u5(p)?i=="/"||i=="\\"&&c.isSpecial()||oo(c.path,""):(c.scheme=="file"&&!c.path.length&&vc(p)&&(c.host&&(c.host=""),p=Bn(p,0)+":"),oo(c.path,p)),p="",c.scheme=="file"&&(i==Nn||i=="?"||i=="#"))for(;c.path.length>1&&c.path[0]==="";)$6(c.path);i=="?"?(c.query="",u=na):i=="#"&&(c.fragment="",u=Fr)}else p+=vi(i,i1);break;case h1:i=="?"?(c.query="",u=na):i=="#"?(c.fragment="",u=Fr):i!=Nn&&(c.path[0]+=vi(i,Il));break;case na:t||i!="#"?i!=Nn&&(i=="'"&&c.isSpecial()?c.query+="%27":c.query+=i=="#"?"%23":vi(i,Il)):(c.fragment="",u=Fr);break;case Fr:i!=Nn&&(c.fragment+=vi(i,r1))}d++}},parseHost:function(e){var t,n,r;if(Bn(e,0)=="["){if(Bn(e,e.length-1)!="]"||(t=function(i){var o,a,s,c,u,d,p,h=[0,0,0,0,0,0,0,0],f=0,_=null,y=0,S=function(){return Bn(i,y)};if(S()==":"){if(Bn(i,1)!=":")return;y+=2,_=++f}for(;S();){if(f==8)return;if(S()!=":"){for(o=a=0;a<4&&Zn(n1,S());)o=16*o+Tl(S(),16),y++,a++;if(S()=="."){if(a==0||(y-=a,f>6))return;for(s=0;S();){if(c=null,s>0){if(!(S()=="."&&s<4))return;y++}if(!Zn(Jm,S()))return;for(;Zn(Jm,S());){if(u=Tl(S(),10),c===null)c=u;else{if(c==0)return;c=10*c+u}if(c>255)return;y++}h[f]=256*h[f]+c,++s!=2&&s!=4||f++}if(s!=4)return;break}if(S()==":"){if(y++,!S())return}else if(S())return;h[f++]=o}else{if(_!==null)return;y++,_=++f}}if(_!==null)for(d=f-_,f=7;f!=0&&d>0;)p=h[f],h[f--]=h[_+d-1],h[_+--d]=p;else if(f!=8)return;return h}(fc(e,1,-1)),!t))return ta;this.host=t}else if(this.isSpecial()){if(e=H6(e),Zn(a5,e)||(t=function(i){var o,a,s,c,u,d,p,h=Z6(i,".");if(h.length&&h[h.length-1]==""&&h.length--,(o=h.length)>4)return i;for(a=[],s=0;s<o;s++){if((c=h[s])=="")return i;if(u=10,c.length>1&&Bn(c,0)=="0"&&(u=Zn(n5,c)?16:8,c=fc(c,u==8?1:2)),c==="")d=0;else{if(!Zn(u==10?i5:u==8?r5:n1,c))return i;d=Tl(c,u)}oo(a,d)}for(s=0;s<o;s++)if(d=a[s],s==o-1){if(d>=$T(256,5-o))return null}else if(d>255)return null;for(p=Y6(a),s=0;s<a.length;s++)p+=a[s]*$T(256,3-s);return p}(e),t===null))return ta;this.host=t}else{if(Zn(o5,e))return ta;for(t="",n=ao(e),r=0;r<n.length;r++)t+=vi(n[r],Il);this.host=t}},cannotHaveUsernamePasswordPort:function(){return!this.host||this.cannotBeABaseURL||this.scheme=="file"},includesCredentials:function(){return this.username!=""||this.password!=""},isSpecial:function(){return Gm(wl,this.scheme)},shortenPath:function(){var e=this.path,t=e.length;!t||this.scheme=="file"&&t==1&&vc(e[0],!0)||e.length--},serialize:function(){var e=this,t=e.scheme,n=e.username,r=e.password,i=e.host,o=e.port,a=e.path,s=e.query,c=e.fragment,u=t+":";return i!==null?(u+="//",e.includesCredentials()&&(u+=n+(r?":"+r:"")+"@"),u+=mc(i),o!==null&&(u+=":"+o)):t=="file"&&(u+="//"),u+=e.cannotBeABaseURL?a[0]:a.length?"/"+pc(a,"/"):"",s!==null&&(u+="?"+s),c!==null&&(u+="#"+c),u},setHref:function(e){var t=this.parse(e);if(t)throw zm(t);this.searchParams.update()},getOrigin:function(){var e=this.scheme,t=this.port;if(e=="blob")try{return new co(e.path[0]).origin}catch(n){return"null"}return e!="file"&&this.isSpecial()?e+"://"+mc(this.host)+(t!==null?":"+t:""):"null"},getProtocol:function(){return this.scheme+":"},setProtocol:function(e){this.parse(jr(e)+":",Km)},getUsername:function(){return this.username},setUsername:function(e){var t=ao(jr(e));if(!this.cannotHaveUsernamePasswordPort()){this.username="";for(var n=0;n<t.length;n++)this.username+=vi(t[n],qm)}},getPassword:function(){return this.password},setPassword:function(e){var t=ao(jr(e));if(!this.cannotHaveUsernamePasswordPort()){this.password="";for(var n=0;n<t.length;n++)this.password+=vi(t[n],qm)}},getHost:function(){var e=this.host,t=this.port;return e===null?"":t===null?mc(e):mc(e)+":"+t},setHost:function(e){this.cannotBeABaseURL||this.parse(e,Ym)},getHostname:function(){var e=this.host;return e===null?"":mc(e)},setHostname:function(e){this.cannotBeABaseURL||this.parse(e,$m)},getPort:function(){var e=this.port;return e===null?"":jr(e)},setPort:function(e){this.cannotHaveUsernamePasswordPort()||((e=jr(e))==""?this.port=null:this.parse(e,Zm))},getPathname:function(){var e=this.path;return this.cannotBeABaseURL?e[0]:e.length?"/"+pc(e,"/"):""},setPathname:function(e){this.cannotBeABaseURL||(this.path=[],this.parse(e,so))},getSearch:function(){var e=this.query;return e?"?"+e:""},setSearch:function(e){(e=jr(e))==""?this.query=null:(Bn(e,0)=="?"&&(e=fc(e,1)),this.query="",this.parse(e,na)),this.searchParams.update()},getSearchParams:function(){return this.searchParams.facade},getHash:function(){var e=this.fragment;return e?"#"+e:""},setHash:function(e){(e=jr(e))!=""?(Bn(e,0)=="#"&&(e=fc(e,1)),this.fragment="",this.parse(e,Fr)):this.fragment=null},update:function(){this.query=this.searchParams.serialize()||null}};var co=function(e){var t=F6(this,on),n=W6(arguments.length,1)>1?arguments[1]:void 0,r=J6(t,new nv(e,!1,n));jm||(t.href=r.serialize(),t.origin=r.getOrigin(),t.protocol=r.getProtocol(),t.username=r.getUsername(),t.password=r.getPassword(),t.host=r.getHost(),t.hostname=r.getHostname(),t.port=r.getPort(),t.pathname=r.getPathname(),t.search=r.getSearch(),t.searchParams=r.getSearchParams(),t.hash=r.getHash())},on=co.prototype,jn=function(e,t){return{get:function(){return kl(this)[e]()},set:t&&function(n){return kl(this)[t](n)},configurable:!0,enumerable:!0}};if(jm&&(Un(on,"href",jn("serialize","setHref")),Un(on,"origin",jn("getOrigin")),Un(on,"protocol",jn("getProtocol","setProtocol")),Un(on,"username",jn("getUsername","setUsername")),Un(on,"password",jn("getPassword","setPassword")),Un(on,"host",jn("getHost","setHost")),Un(on,"hostname",jn("getHostname","setHostname")),Un(on,"port",jn("getPort","setPort")),Un(on,"pathname",jn("getPathname","setPathname")),Un(on,"search",jn("getSearch","setSearch")),Un(on,"searchParams",jn("getSearchParams")),Un(on,"hash",jn("getHash","setHash"))),Sl(on,"toJSON",function(){return kl(this).serialize()},{enumerable:!0}),Sl(on,"toString",function(){return kl(this).serialize()},{enumerable:!0}),hc){var p1=hc.createObjectURL,f1=hc.revokeObjectURL;p1&&Sl(co,"createObjectURL",QT(p1,hc)),f1&&Sl(co,"revokeObjectURL",QT(f1,hc))}z6(co,"URL"),B6({global:!0,constructor:!0,forced:!j6,sham:!jm},{URL:co});var ra,Rl,l5=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"}),m1=!1,d5=function(){function e(n){z(this,e),this.context_=n.context,this.addModuleToContext()}var t;return ke(e,[{key:"addModuleToContext",value:(t=N(m().mark(function n(){return m().wrap(function(r){for(;;)switch(r.prev=r.next){case 0:return r.prev=0,r.next=3,this.context_.audioWorklet.addModule(URL.createObjectURL(l5));case 3:be.info("worklet addModule success"),W.emit(om),m1=!0,r.next=12;break;case 8:r.prev=8,r.t0=r.catch(0),be.info("worklet addModule catch error. ".concat(r.t0.message)),W.emit(sm);case 12:case"end":return r.stop()}},n,this,[[0,8]])})),function(){return t.apply(this,arguments)})},{key:"initWorkletSuccess",get:function(){return m1}}]),e}(),Al=0,h5=function(){function e(t){z(this,e);var n=t.track,r=t.log,i=t.stream;this.volume_=0,this.log_=r,this.track_=n,this.stream_=i,ra||(ra=Ok()),this.audioCtx_=ra,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,W.on(ac,this.resume,this),W.on(zf,this.handleAudioLevelInterval,this),K4?(W.on(om,this.initAudioWorklet,this),W.on(sm,this.initScriptProcessor,this),this.preload()):this.initScriptProcessor(),Al+=1}return ke(e,[{key:"preload",value:function(){Rl?Rl.initWorkletSuccess&&this.initAudioWorklet():Rl=new d5({context:ra})}},{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."),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 r=n.inputBuffer.getChannelData(0),i=0,o=0;o<r.length;++o)i+=r[o]*r[o];t.volume_=Math.sqrt(i/r.length)||0},this.streamSource_.connect(this.scriptProcessorNode_),this.scriptProcessorNode_.connect(this.destination_)}catch(n){this.log_.error("volumeMeter init script processor error: "+n)}}},{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,W.off(ac,this.resume,this),W.off(zf,this.handleAudioLevelInterval,this),W.off(om,this.initAudioWorklet,this),W.off(sm,this.initScriptProcessor,this),Al>0&&(Al-=1),Al===0&&((t=ra)===null||t===void 0||t.close(),ra=null,Rl=null)}},{key:"resume",value:function(){var t;(t=ra)===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,r=t.interval;this.interval_=r,(n=this.audioWorkletNode_)===null||n===void 0||n.port.postMessage({name:"setIntervalTime",intervalTime:r})}}]),e}(),p5=function(){function e(o){z(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 pi,this.initializeElement(),this.state_="NONE",this.volumeMeter_=new h5({stream:this.stream_,track:this.gainedTrack_||this.track_,log:this.log_})}var t,n,r,i;return ke(e,[{key:"isPlaying",get:function(){return this.state_===Ga}},{key:"initializeElement",value:function(){if(this.isAudioElementInit()){var o=new MediaStream;o.addTrack(this.gainedTrack_||this.track_);var a=document.createElement(Ce);a.srcObject=o,a.muted=this.muted_,a.setAttribute("id","audio_".concat(this.stream_.getId())),a.setAttribute("autoplay","autoplay"),a.setAttribute("playsinline","playsinline"),this.div_.appendChild(a),this.element_=a}this.handleEvents()}},{key:"setMuted",value:function(o){this.element_&&(this.element_.muted=o,this.muted_=o)}},{key:"play",value:(i=N(m().mark(function o(){var a;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),a=te({key:uf,data:{media:"Audio",error:s.t0}}),this.log_.warn(a),!a.includes("NotAllowedError")){s.next=16;break}throw new $({code:Q.PLAY_NOT_ALLOWED,message:a});case 16:case"end":return s.stop()}},o,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(si,this.handleElementEvent),this.element_.addEventListener(Lt,this.handleElementEvent),this.element_.addEventListener(ci,this.handleElementEvent),this.element_.addEventListener(Fa,this.handleElementEvent)),this.track_.addEventListener(Lt,this.handleTrackEvent),this.track_.addEventListener($t,this.handleTrackEvent),this.track_.addEventListener(fr,this.handleTrackEvent),this.track_.readyState===Lt&&this.handleTrackEvent({type:Lt}),this.track_.muted&&this.handleTrackEvent({type:$t})}},{key:"handleElementEvent",value:(r=N(m().mark(function o(a){var s,c,u,d,p,h,f,_=this;return m().wrap(function(y){for(;;)switch(y.prev=y.next){case 0:s=a.type,y.t0=s,y.next=y.t0===si?4:y.t0===Lt?9:y.t0===ci?12:y.t0===Fa?21:32;break;case 4:return this.log_.info("audio player is playing"),this.state_=Ga,W.emit(Wf,{stream:this.stream_}),this.emitter_.emit(hn,{state:this.state_,reason:si}),y.abrupt("break",32);case 9:return this.log_.info("audio player is ended"),this.state_!==ui&&(this.state_=ui,this.emitter_.emit(hn,{state:this.state_,reason:Lt})),y.abrupt("break",32);case 12:return this.log_.info("audio player is paused"),this.state_=mr,this.emitter_.emit(hn,{state:this.state_,reason:ci}),(c=this.div_&&document.getElementById(this.div_.id))||this.log_.warn("audio player has been remove, element ID: ".concat(this.div_.id)),u=nc(),this.pausedRetryCount_>0&&(br(u)&&u<=70||!c)&&(this.resume(),this.pausedRetryCount_--),Lr&&(this.interval_=_t.run(function(){_.element_&&_.state_===mr&&_.resume()},{delay:3e3})),y.abrupt("break",32);case 21:if(!this.element_||!this.element_.error){y.next=31;break}return d="".concat(Pm(),"/").concat(Ki().name,"/").concat(Ki().version),y.next=25,It.getSpeakers();case 25:p=y.sent,h=p[0].label,(f=p.find(function(S){return S.deviceId===_.outputDeviceId_}))&&(h=f.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(h)),Ie.uploadEvent("stat-".concat(this.stream_.getType(),"-audio-").concat(NS,"-").concat(this.element_.error.code,"-").concat(d,"-").concat(h),this.element_.error);case 31:return y.abrupt("break",32);case 32:case"end":return y.stop()}},o,this)})),function(o){return r.apply(this,arguments)})},{key:"handleTrackEvent",value:function(o){var a=o.type;switch(a){case Lt:this.log_.info("audio track is ended"),this.state_!==ui&&(this.state_=ui,this.emitter_.emit(hn,{state:this.state_,reason:Lt})),W.emit(nm,{stream:this.stream_,type:a});break;case $t:this.log_.info("audio track is unable to provide media output"),this.stream_.isRemote()||Lk(),this.state_!==mr&&(this.state_=mr,this.emitter_.emit(hn,{state:this.state_,reason:$t})),W.emit(tm,{stream:this.stream_,type:a});break;case fr:this.log_.info("audio track is able to provide media output"),this.state_===mr&&(this.state_=Ga,this.emitter_.emit(hn,{state:this.state_,reason:fr}))}}},{key:"unbindEvents",value:function(){this.element_&&(this.element_.removeEventListener(si,this.handleElementEvent),this.element_.removeEventListener(Lt,this.handleElementEvent),this.element_.removeEventListener(ci,this.handleElementEvent),this.element_.removeEventListener(Fa,this.handleElementEvent)),this.track_&&(this.track_.removeEventListener(Lt,this.handleTrackEvent),this.track_.removeEventListener($t,this.handleTrackEvent),this.track_.removeEventListener(fr,this.handleTrackEvent))}},{key:"setSinkId",value:(n=N(m().mark(function o(a){return m().wrap(function(s){for(;;)switch(s.prev=s.next){case 0:if(this.outputDeviceId_===a){s.next=5;break}if(!this.element_){s.next=4;break}return s.next=4,this.element_.setSinkId(a);case 4:this.outputDeviceId_=a;case 5:case"end":return s.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&&_t.clearTask(this.interval_)}},{key:"resume",value:(t=N(m().mark(function o(){var a;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),a=te({key:uf,data:{media:"Audio",error:s.t0}}),this.log_.warn(a),!a.includes("NotAllowedError")){s.next=13;break}throw new $({code:Q.PLAY_NOT_ALLOWED,message:a});case 13:case"end":return s.stop()}},o,this,[[0,7]])})),function(){return t.apply(this,arguments)})},{key:"on",value:function(o,a){this.emitter_.on(o,a)}},{key:"isAudioElementInit",value:function(){return!(Mr==="15.2"||Mr==="15.3"||Mr==="15.4")||this.stream_.getType()!=="local"||!this.muted_||(this.log_.info("audioElement is muted."),!1)}}]),e}(),f5=dr.PROPER,m5=ie,v1=Y0,v5=Ou.trim;Oe({target:"String",proto:!0,forced:function(e){return m5(function(){return!!v1[e]()||"\u200B\x85\u180E"[e]()!=="\u200B\x85\u180E"||f5&&v1[e].name!==e})}("trim")},{trim:function(){return v5(this)}});var Gr="trtc_autoplay",rv="".concat(Gr,"_mask"),uo="".concat(Gr,"_wrapper"),g1="".concat(Gr,"_header"),iv="".concat(Gr,"_content"),Pl="".concat(Gr,"_action_wrapper"),av="".concat(Gr,"_question"),ov="".concat(Gr,"_collapse"),Dl="".concat(Gr,"_action_confirm"),_1="".concat(Gr,"_detail"),y1="#2473E8",sv="dialog",g5="".concat(sv,"-show"),_5="".concat(sv,"-1"),y5="".concat(sv,"-2"),b1=!1,S1=function(){return!!document.querySelector(".".concat(uo))},k1="".concat(Wa,"/").concat(Xi()?"zh-cn":"en","/tutorial-21-advanced-auto-play-policy.html"),T1="<br><a href='".concat(k1,"' target='_blank'>").concat(Xi()?"\u5176\u4ED6\u65B9\u6848\uFF1F":"Any other solution?","</a>"),b5="".concat(Xi()?"\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(T1):"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(T1)),x1=function(){function e(){if(z(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",Xi()||(this.content='Media playback failed. Click the "Resume" to resume playback.'),!b1){var t=document.createElement("style");t.innerHTML=".".concat(rv,"{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(rv," div:not(.").concat(Pl,"){display:block !important;}.").concat(uo,"{padding:14px;background:#fff;border-radius:3px;box-shadow:0px 3px 15px #434343;border:1px solid #d1cfcf;max-width:500px;}.").concat(uo," a{color:").concat(y1,";}.").concat(g1,"{overflow:hidden;text-overflow:ellipsis;font-size:16px;font-weight:600;}.").concat(iv,"{margin:8px 0;}.").concat(Pl,"{width:100%;display:flex !important;align-items:center;justify-content:right;float:right;}.").concat(ov,"{margin-right:auto;cursor:pointer}.").concat(av,"{height:100%;line-height:16px;cursor:pointer;}.").concat(Dl,"{margin-left:8px;color:#fff;background:").concat(y1,";padding:4px 12px;outline:none;border:1px solid;border-radius:3px;font-weight:bold;}.").concat(Dl,":hover{opacity:0.9;}.").concat(ov,",.").concat(Dl,",.").concat(iv,",.").concat(av,"{font-size:14px;}@media screen and (max-width:750px){.").concat(uo,"{width:80vw;}}"),document.head.appendChild(t),b1=!0}this.showDetail_=!1,this.isCollapseClicked_=!1,this.isQuestionClicked_=!1,this.addDiaLog()}return ke(e,[{key:"createDiaLog",value:function(){var t=document.createElement("template");t.innerHTML='<div class="'.concat(rv,`"><div class='`).concat(uo,"'><div class='").concat(g1,"'>").concat(location.host,"</div><div class='").concat(iv,"'>").concat(this.content,"</div><div class='").concat(_1,`' style="visibility:hidden;width:100%;height:0;font-size:12px;color:gray;">`).concat(b5,"</div><div class='").concat(Pl,"'></div></div></div>").trim();var n=document.createElement("button");n.className=Dl,n.innerText=Xi()?"\u6062\u590D\u64AD\u653E":"Resume",n.onclick=this.onConfirm.bind(this);var r=document.createElement("div");r.className=av,r.innerHTML=`<?xml version="1.0" encoding="UTF-8"?>
93
+ <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
+ <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
+ <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
+ <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
+ </svg>
98
+ `,r.onclick=this.onQuestionClick.bind(this);var i=document.createElement("div");i.className=ov,i.innerText="".concat(Xi()?"\u8BE6\u60C5 >":"Detail >"),i.onclick=this.onCollapseClick.bind(this);var o=t.content.firstChild,a=o.querySelector(".".concat(Pl));return a.appendChild(i),a.appendChild(r),a.appendChild(n),o}},{key:"addDiaLog",value:function(){S1()||(this.dialogNode_=this.createDiaLog(),document.body.appendChild(this.dialogNode_),this.dialogNode_.onclick=this.onConfirm.bind(this),this.dialogNode_.querySelector(".".concat(uo)).onclick=function(t){return t.stopPropagation()},this.bodyPosition_=document.body.style.position,document.body.style.position="fixed",be.info("show autoplay dialog"),Ie.uploadEvent({log:g5}))}},{key:"deleteDiaLog",value:function(){this.dialogNode_&&(document.body.removeChild(this.dialogNode_),document.body.style.position=this.bodyPosition_,this.dialogNode_=null)}},{key:"onConfirm",value:function(){be.warn("confirm clicked, try resume stream"),W.emit(ac),this.deleteDiaLog()}},{key:"onCollapseClick",value:function(){var t=this.dialogNode_.querySelector(".".concat(_1));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:_5}),this.isCollapseClicked_=!0}},{key:"onQuestionClick",value:function(){window.open(k1,"_blank"),this.isQuestionClicked_||Ie.uploadEvent({log:y5}),this.isQuestionClicked_=!0}}]),e}(),I1=function(){function e(n){z(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 pi,this.initializeElement(),this.state_="NONE",this.pausedRetryCount_=5}var t;return ke(e,[{key:"isPlaying",get:function(){return this.state_===Ga}},{key:"initializeElement",value:function(){var n=new MediaStream;n.addTrack(this.track_);var r=document.createElement(xe);r.srcObject=n,r.muted=!0;var i="width: 100%; height: 100%; object-fit: ".concat(this.objectFit_,";");this.mirror_&&(i+="transform: scaleX(-1);"),r.setAttribute("id","video_".concat(this.stream_.getId())),r.setAttribute("style",i),r.setAttribute("autoplay","autoplay"),r.setAttribute("playsinline","playsinline"),this.div_&&this.div_.appendChild(r),this.element_=r,this.handleEvents()}},{key:"setRect",value:function(n){var r=n.width,i=n.height;this.element_&&(this.element_.style.width=r+"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=N(m().mark(function n(){var r;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),r=te({key:uf,data:{media:"Video",error:i.t0}}),this.log_.warn(r),!r.includes("NotAllowedError")){i.next=11;break}throw new $({code:Q.PLAY_NOT_ALLOWED,message:r});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(si,this.handleElementEvent),this.element_.addEventListener(Lt,this.handleElementEvent),this.element_.addEventListener(ci,this.handleElementEvent),this.element_.addEventListener(Fa,this.handleElementEvent),this.element_.addEventListener(zp,this.handleElementEvent),this.track_.addEventListener(Lt,this.handleTrackEvent),this.track_.addEventListener($t,this.handleTrackEvent),this.track_.addEventListener(fr,this.handleTrackEvent),this.track_.readyState===Lt&&this.handleTrackEvent({type:Lt}),this.track_.muted&&this.handleTrackEvent({type:$t})}},{key:"handleElementEvent",value:function(n){var r=this;switch(n.type){case si:this.log_.info("video player is playing"),this.state_=Ga,W.emit(rc,{stream:this.stream_}),this.emitter_.emit(hn,{state:this.state_,reason:si}),this.interval_&&(_t.clearTask(this.interval_),this.interval_=null);break;case Lt:this.log_.info("video player is ended"),this.state_!==ui&&(this.state_=ui,this.emitter_.emit(hn,{state:this.state_,reason:Lt}));break;case ci: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_=mr,this.emitter_.emit(hn,{state:this.state_,reason:ci}),this.pausedRetryCount_>0&&!S1()&&(this.log_.info("video player auto resume when video paused"),this.resume(),this.pausedRetryCount_--),Lr&&(this.interval_=_t.run(function(){r.element_&&r.state_===mr&&r.resume()},{delay:3e3}));break;case Fa:if(this.element_&&this.element_.error){var i="".concat(Pm(),"/").concat(Ki().name,"/").concat(Ki().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("stat-".concat(this.stream_.getType(),"-video-").concat(NS,"-").concat(this.element_.error.code,"-").concat(i),this.element_.error)}break;case zp:W.emit($f,{stream:this.stream_})}}},{key:"handleTrackEvent",value:function(n){var r=n.type;switch(r){case Lt:this.log_.info("video track is ended"),W.emit(em,{stream:this.stream_,type:r}),this.state_!==ui&&(this.state_=ui,this.emitter_.emit(hn,{state:this.state_,reason:Lt}));break;case $t:this.log_.info("video track is unable to provide media output"),this.stream_.isRemote()||Lk(),W.emit(ic,{stream:this.stream_,type:r}),this.state_!==mr&&(this.state_=mr,this.emitter_.emit(hn,{state:this.state_,reason:$t}));break;case fr:this.log_.info("video track is able to provide media output"),W.emit(Xf,{stream:this.stream_}),this.state_===mr&&(this.state_=Ga,this.emitter_.emit(hn,{state:this.state_,reason:fr}))}}},{key:"unbindEvents",value:function(){this.element_&&(this.element_.removeEventListener(si,this.handleElementEvent),this.element_.removeEventListener(Lt,this.handleElementEvent),this.element_.removeEventListener(ci,this.handleElementEvent),this.element_.removeEventListener(Fa,this.handleElementEvent),this.element_.removeEventListener(zp,this.handleElementEvent)),this.track_&&(this.track_.removeEventListener(Lt,this.handleTrackEvent),this.track_.removeEventListener($t,this.handleTrackEvent),this.track_.removeEventListener(fr,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,r){this.emitter_.on(n,r)}},{key:"getElement",value:function(){return this.element_?this.element_:null}}]),e}(),cv=typeof ArrayBuffer!="undefined"&&typeof DataView!="undefined",S5=Kn,k5=Qn,T5=RangeError,w1=function(e){if(e===void 0)return 0;var t=S5(e),n=k5(t);if(t!==n)throw T5("Wrong length or index");return n},x5=Array,I5=Math.abs,Hr=Math.pow,w5=Math.floor,E5=Math.log,C5=Math.LN2,R5={pack:function(e,t,n){var r,i,o,a=x5(n),s=8*n-t-1,c=(1<<s)-1,u=c>>1,d=t===23?Hr(2,-24)-Hr(2,-77):0,p=e<0||e===0&&1/e<0?1:0,h=0;for((e=I5(e))!=e||e===1/0?(i=e!=e?1:0,r=c):(r=w5(E5(e)/C5),e*(o=Hr(2,-r))<1&&(r--,o*=2),(e+=r+u>=1?d/o:d*Hr(2,1-u))*o>=2&&(r++,o/=2),r+u>=c?(i=0,r=c):r+u>=1?(i=(e*o-1)*Hr(2,t),r+=u):(i=e*Hr(2,u-1)*Hr(2,t),r=0));t>=8;)a[h++]=255&i,i/=256,t-=8;for(r=r<<t|i,s+=t;s>0;)a[h++]=255&r,r/=256,s-=8;return a[--h]|=128*p,a},unpack:function(e,t){var n,r=e.length,i=8*r-t-1,o=(1<<i)-1,a=o>>1,s=i-7,c=r-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-a;else{if(d===o)return n?NaN:u?-1/0:1/0;n+=Hr(2,t),d-=a}return(u?-1:1)*n*Hr(2,d-t)}},A5=Rt,E1=Zr,P5=Zt,C1=function(e){for(var t=A5(this),n=P5(t),r=arguments.length,i=E1(r>1?arguments[1]:void 0,n),o=r>2?arguments[2]:void 0,a=o===void 0?n:E1(o,n);a>i;)t[i++]=e;return t},Ll=Z,uv=ce,lv=_e,D5=cv,R1=dr,A1=yn,P1=Es,dv=ie,Ol=ti,L5=Kn,O5=Qn,Ml=w1,D1=R5,M5=ys,L1=Ta,N5=$r.f,V5=At.f,U5=C1,B5=xs,O1=Ni,j5=R1.PROPER,M1=R1.CONFIGURABLE,lo=Qe.get,N1=Qe.set,hv="ArrayBuffer",F5="DataView",V1="Wrong index",er=Ll.ArrayBuffer,tr=er,ho=tr&&tr.prototype,kr=Ll.DataView,ia=kr&&kr.prototype,U1=Object.prototype,G5=Ll.Array,Nl=Ll.RangeError,H5=uv(U5),z5=uv([].reverse),B1=D1.pack,j1=D1.unpack,F1=function(e){return[255&e]},G1=function(e){return[255&e,e>>8&255]},H1=function(e){return[255&e,e>>8&255,e>>16&255,e>>24&255]},z1=function(e){return e[3]<<24|e[2]<<16|e[1]<<8|e[0]},W5=function(e){return B1(e,23,4)},J5=function(e){return B1(e,52,8)},Vl=function(e,t){V5(e.prototype,t,{get:function(){return lo(this)[t]}})},gi=function(e,t,n,r){var i=Ml(n),o=lo(e);if(i+t>o.byteLength)throw Nl(V1);var a=lo(o.buffer).bytes,s=i+o.byteOffset,c=B5(a,s,s+t);return r?c:z5(c)},_i=function(e,t,n,r,i,o){var a=Ml(n),s=lo(e);if(a+t>s.byteLength)throw Nl(V1);for(var c=lo(s.buffer).bytes,u=a+s.byteOffset,d=r(+i),p=0;p<t;p++)c[u+p]=d[o?p:t-p-1]};if(D5){var W1=j5&&er.name!==hv;if(dv(function(){er(1)})&&dv(function(){new er(-1)})&&!dv(function(){return new er,new er(1.5),new er(NaN),W1&&!M1}))W1&&M1&&A1(er,"name",hv);else{(tr=function(e){return Ol(this,ho),new er(Ml(e))}).prototype=ho;for(var pv,J1=N5(er),q1=0;J1.length>q1;)(pv=J1[q1++])in tr||A1(tr,pv,er[pv]);ho.constructor=tr}L1&&M5(ia)!==U1&&L1(ia,U1);var Ul=new kr(new tr(2)),K1=uv(ia.setInt8);Ul.setInt8(0,2147483648),Ul.setInt8(1,2147483649),!Ul.getInt8(0)&&Ul.getInt8(1)||P1(ia,{setInt8:function(e,t){K1(this,e,t<<24>>24)},setUint8:function(e,t){K1(this,e,t<<24>>24)}},{unsafe:!0})}else ho=(tr=function(e){Ol(this,ho);var t=Ml(e);N1(this,{bytes:H5(G5(t),0),byteLength:t}),lv||(this.byteLength=t)}).prototype,kr=function(e,t,n){Ol(this,ia),Ol(e,ho);var r=lo(e).byteLength,i=L5(t);if(i<0||i>r)throw Nl("Wrong offset");if(i+(n=n===void 0?r-i:O5(n))>r)throw Nl("Wrong length");N1(this,{buffer:e,byteLength:n,byteOffset:i}),lv||(this.buffer=e,this.byteLength=n,this.byteOffset=i)},ia=kr.prototype,lv&&(Vl(tr,"byteLength"),Vl(kr,"buffer"),Vl(kr,"byteLength"),Vl(kr,"byteOffset")),P1(ia,{getInt8:function(e){return gi(this,1,e)[0]<<24>>24},getUint8:function(e){return gi(this,1,e)[0]},getInt16:function(e){var t=gi(this,2,e,arguments.length>1?arguments[1]:void 0);return(t[1]<<8|t[0])<<16>>16},getUint16:function(e){var t=gi(this,2,e,arguments.length>1?arguments[1]:void 0);return t[1]<<8|t[0]},getInt32:function(e){return z1(gi(this,4,e,arguments.length>1?arguments[1]:void 0))},getUint32:function(e){return z1(gi(this,4,e,arguments.length>1?arguments[1]:void 0))>>>0},getFloat32:function(e){return j1(gi(this,4,e,arguments.length>1?arguments[1]:void 0),23)},getFloat64:function(e){return j1(gi(this,8,e,arguments.length>1?arguments[1]:void 0),52)},setInt8:function(e,t){_i(this,1,e,F1,t)},setUint8:function(e,t){_i(this,1,e,F1,t)},setInt16:function(e,t){_i(this,2,e,G1,t,arguments.length>2?arguments[2]:void 0)},setUint16:function(e,t){_i(this,2,e,G1,t,arguments.length>2?arguments[2]:void 0)},setInt32:function(e,t){_i(this,4,e,H1,t,arguments.length>2?arguments[2]:void 0)},setUint32:function(e,t){_i(this,4,e,H1,t,arguments.length>2?arguments[2]:void 0)},setFloat32:function(e,t){_i(this,4,e,W5,t,arguments.length>2?arguments[2]:void 0)},setFloat64:function(e,t){_i(this,8,e,J5,t,arguments.length>2?arguments[2]:void 0)}});O1(tr,hv),O1(kr,F5);var gc={ArrayBuffer:tr,DataView:kr},q5=Oe,fv=ce,K5=ie,Q1=dt,X1=Zr,Q5=Qn,X5=Bs,mv=gc.ArrayBuffer,vv=gc.DataView,Y1=vv.prototype,$1=fv(mv.prototype.slice),Y5=fv(Y1.getUint8),$5=fv(Y1.setUint8);q5({target:"ArrayBuffer",proto:!0,unsafe:!0,forced:K5(function(){return!new mv(2).slice(1,void 0).byteLength})},{slice:function(e,t){if($1&&t===void 0)return $1(Q1(this),e);for(var n=Q1(this).byteLength,r=X1(e,n),i=X1(t===void 0?n:t,n),o=new(X5(this,mv))(Q5(i-r)),a=new vv(this),s=new vv(o),c=0;r<i;)$5(s,c++,Y5(a,r++));return o}}),Oe({global:!0,constructor:!0,forced:!cv},{DataView:gc.DataView});var Z5=Oe,eB=Ps,tB=ce([].reverse),Z1=[1,2];Z5({target:"Array",proto:!0,forced:String(Z1)===String(Z1.reverse())},{reverse:function(){return eB(this)&&(this.length=this.length),tB(this)}});var nB=Nt,rB=Rt,iB=Cn,aB=Zt,oB=TypeError,ex=function(e){return function(t,n,r,i){nB(n);var o=rB(t),a=iB(o),s=aB(o),c=e?s-1:0,u=e?-1:1;if(r<2)for(;;){if(c in a){i=a[c],c+=u;break}if(c+=u,e?c<0:s<=c)throw oB("Reduce of empty array with no initial value")}for(;e?c>=0:s>c;c+=u)c in a&&(i=n(i,a[c],c,o));return i}},gv={left:ex(!1),right:ex(!0)},sB=gv.left,tx=Jn,cB=Hs;Oe({target:"Array",proto:!0,forced:!Os("reduce")||!cB&&tx>79&&tx<83},{reduce:function(e){var t=arguments.length;return sB(this,e,t,t>1?arguments[1]:void 0)}});var uB=Cs,lB="ArrayBuffer",nx=gc.ArrayBuffer;Oe({global:!0,constructor:!0,forced:Z.ArrayBuffer!==nx},{ArrayBuffer:nx}),uB(lB);var dB=Oe,rx=Ps,hB=ku,pB=yt,ix=Zr,fB=Zt,mB=it,vB=Ts,gB=ct,_B=xa,yB=Ls("slice"),bB=gB("species"),_v=Array,SB=Math.max;dB({target:"Array",proto:!0,forced:!yB},{slice:function(e,t){var n,r,i,o=mB(this),a=fB(o),s=ix(e,a),c=ix(t===void 0?a:t,a);if(rx(o)&&(n=o.constructor,(hB(n)&&(n===_v||rx(n.prototype))||pB(n)&&(n=n[bB])===null)&&(n=void 0),n===_v||n===void 0))return _B(o,s,c);for(r=new(n===void 0?_v:n)(SB(c-s,0)),i=0;s<c;s++,i++)s in o&&vB(r,i,o[s]);return r.length=i,r}});var ax=Z,kB=ie,TB=ce,xB=Vt,IB=Ou.trim,ox=Y0,_c=ax.parseInt,sx=ax.Symbol,cx=sx&&sx.iterator,ux=/^[+-]?0x/i,wB=TB(ux.exec),lx=_c(ox+"08")!==8||_c(ox+"0x16")!==22||cx&&!kB(function(){_c(Object(cx))})?function(e,t){var n=IB(xB(e));return _c(n,t>>>0||(wB(ux,n)?16:10))}:_c;Oe({global:!0,forced:parseInt!=lx},{parseInt:lx});var pn,po,Bl,yv={exports:{}},EB=cv,bv=_e,sn=Z,dx=We,jl=yt,yi=kt,Sv=ei,CB=Er,RB=yn,kv=Wt,AB=At.f,PB=zn,Fl=ys,fo=Ta,DB=ct,LB=ur,hx=Qe.enforce,OB=Qe.get,Gl=sn.Int8Array,Tv=Gl&&Gl.prototype,px=sn.Uint8ClampedArray,fx=px&&px.prototype,Tr=Gl&&Fl(Gl),nr=Tv&&Fl(Tv),MB=Object.prototype,xv=sn.TypeError,mx=DB("toStringTag"),Iv=LB("TYPED_ARRAY_TAG"),NB="TypedArrayConstructor",zr=EB&&!!fo&&Sv(sn.opera)!=="Opera",vx=!1,Wr={Int8Array:1,Uint8Array:1,Uint8ClampedArray:1,Int16Array:2,Uint16Array:2,Int32Array:4,Uint32Array:4,Float32Array:4,Float64Array:8},wv={BigInt64Array:8,BigUint64Array:8},gx=function(e){var t=Fl(e);if(jl(t)){var n=OB(t);return n&&yi(n,NB)?n.TypedArrayConstructor:gx(t)}},_x=function(e){if(!jl(e))return!1;var t=Sv(e);return yi(Wr,t)||yi(wv,t)};for(pn in Wr)(Bl=(po=sn[pn])&&po.prototype)?hx(Bl).TypedArrayConstructor=po:zr=!1;for(pn in wv)(Bl=(po=sn[pn])&&po.prototype)&&(hx(Bl).TypedArrayConstructor=po);if((!zr||!dx(Tr)||Tr===Function.prototype)&&(Tr=function(){throw xv("Incorrect invocation")},zr))for(pn in Wr)sn[pn]&&fo(sn[pn],Tr);if((!zr||!nr||nr===MB)&&(nr=Tr.prototype,zr))for(pn in Wr)sn[pn]&&fo(sn[pn].prototype,nr);if(zr&&Fl(fx)!==nr&&fo(fx,nr),bv&&!yi(nr,mx))for(pn in vx=!0,AB(nr,mx,{get:function(){return jl(this)?this[Iv]:void 0}}),Wr)sn[pn]&&RB(sn[pn],Iv,pn);var He={NATIVE_ARRAY_BUFFER_VIEWS:zr,TYPED_ARRAY_TAG:vx&&Iv,aTypedArray:function(e){if(_x(e))return e;throw xv("Target is not a typed array")},aTypedArrayConstructor:function(e){if(dx(e)&&(!fo||PB(Tr,e)))return e;throw xv(CB(e)+" is not a typed array constructor")},exportTypedArrayMethod:function(e,t,n,r){if(bv){if(n)for(var i in Wr){var o=sn[i];if(o&&yi(o.prototype,e))try{delete o.prototype[e]}catch(a){try{o.prototype[e]=t}catch(s){}}}nr[e]&&!n||kv(nr,e,n?t:zr&&Tv[e]||t,r)}},exportTypedArrayStaticMethod:function(e,t,n){var r,i;if(bv){if(fo){if(n){for(r in Wr)if((i=sn[r])&&yi(i,e))try{delete i[e]}catch(o){}}if(Tr[e]&&!n)return;try{return kv(Tr,e,n?t:zr&&Tr[e]||t)}catch(o){}}for(r in Wr)!(i=sn[r])||i[e]&&!n||kv(i,e,t)}},getTypedArrayConstructor:gx,isView:function(e){if(!jl(e))return!1;var t=Sv(e);return t==="DataView"||yi(Wr,t)||yi(wv,t)},isTypedArray:_x,TypedArray:Tr,TypedArrayPrototype:nr},yx=Z,Ev=ie,VB=_h,UB=He.NATIVE_ARRAY_BUFFER_VIEWS,BB=yx.ArrayBuffer,aa=yx.Int8Array,jB=!UB||!Ev(function(){aa(1)})||!Ev(function(){new aa(-1)})||!VB(function(e){new aa,new aa(null),new aa(1.5),new aa(e)},!0)||Ev(function(){return new aa(new BB(2),1,void 0).length!==1}),FB=Kn,GB=RangeError,HB=function(e){var t=FB(e);if(t<0)throw GB("The argument can't be less than 0");return t},zB=RangeError,bx=function(e,t){var n=HB(e);if(n%t)throw zB("Wrong offset");return n},WB=Pr,JB=Ke,qB=pb,KB=Rt,QB=Zt,XB=_u,YB=Is,$B=gh,ZB=He.aTypedArrayConstructor,Sx=Oe,kx=Z,Tx=Ke,ej=_e,tj=jB,mo=He,xx=gc,Ix=ti,nj=Ze,yc=yn,rj=Hk,ij=Qn,wx=w1,Cv=bx,Ex=xi,bc=kt,aj=ei,Rv=yt,oj=An,sj=ka,cj=zn,Hl=Ta,uj=$r.f,Cx=function(e){var t,n,r,i,o,a,s=qB(this),c=KB(e),u=arguments.length,d=u>1?arguments[1]:void 0,p=d!==void 0,h=YB(c);if(h&&!$B(h))for(a=(o=XB(c,h)).next,c=[];!(i=JB(a,o)).done;)c.push(i.value);for(p&&u>2&&(d=WB(d,arguments[2])),n=QB(c),r=new(ZB(s))(n),t=0;n>t;t++)r[t]=p?d(c[t],t):c[t];return r},lj=en.forEach,dj=Cs,Rx=At,Ax=ye,hj=bu,Av=Qe.get,pj=Qe.set,fj=Qe.enforce,Pv=Rx.f,mj=Ax.f,vj=Math.round,Dv=kx.RangeError,Px=xx.ArrayBuffer,gj=Px.prototype,_j=xx.DataView,zl=mo.NATIVE_ARRAY_BUFFER_VIEWS,Dx=mo.TYPED_ARRAY_TAG,Lx=mo.TypedArray,Sc=mo.TypedArrayPrototype,yj=mo.aTypedArrayConstructor,Lv=mo.isTypedArray,Wl="BYTES_PER_ELEMENT",Ov="Wrong length",Ox=function(e,t){yj(e);for(var n=0,r=t.length,i=new e(r);r>n;)i[n]=t[n++];return i},Jl=function(e,t){Pv(e,t,{get:function(){return Av(this)[t]}})},Mx=function(e){var t;return cj(gj,e)||(t=aj(e))=="ArrayBuffer"||t=="SharedArrayBuffer"},Nx=function(e,t){return Lv(e)&&!oj(t)&&t in e&&rj(+t)&&t>=0},Vx=function(e,t){return t=Ex(t),Nx(e,t)?nj(2,e[t]):mj(e,t)},Ux=function(e,t,n){return t=Ex(t),!(Nx(e,t)&&Rv(n)&&bc(n,"value"))||bc(n,"get")||bc(n,"set")||n.configurable||bc(n,"writable")&&!n.writable||bc(n,"enumerable")&&!n.enumerable?Pv(e,t,n):(e[t]=n.value,e)};ej?(zl||(Ax.f=Vx,Rx.f=Ux,Jl(Sc,"buffer"),Jl(Sc,"byteOffset"),Jl(Sc,"byteLength"),Jl(Sc,"length")),Sx({target:"Object",stat:!0,forced:!zl},{getOwnPropertyDescriptor:Vx,defineProperty:Ux}),yv.exports=function(e,t,n){var r=e.match(/\d+$/)[0]/8,i=e+(n?"Clamped":"")+"Array",o="get"+e,a="set"+e,s=kx[i],c=s,u=c&&c.prototype,d={},p=function(f,_){Pv(f,_,{get:function(){return function(y,S){var E=Av(y);return E.view[o](S*r+E.byteOffset,!0)}(this,_)},set:function(y){return function(S,E,R){var H=Av(S);n&&(R=(R=vj(R))<0?0:R>255?255:255&R),H.view[a](E*r+H.byteOffset,R,!0)}(this,_,y)},enumerable:!0})};zl?tj&&(c=t(function(f,_,y,S){return Ix(f,u),hj(Rv(_)?Mx(_)?S!==void 0?new s(_,Cv(y,r),S):y!==void 0?new s(_,Cv(y,r)):new s(_):Lv(_)?Ox(c,_):Tx(Cx,c,_):new s(wx(_)),f,c)}),Hl&&Hl(c,Lx),lj(uj(s),function(f){f in c||yc(c,f,s[f])}),c.prototype=u):(c=t(function(f,_,y,S){Ix(f,u);var E,R,H,Y=0,ue=0;if(Rv(_)){if(!Mx(_))return Lv(_)?Ox(c,_):Tx(Cx,c,_);E=_,ue=Cv(y,r);var le=_.byteLength;if(S===void 0){if(le%r||(R=le-ue)<0)throw Dv(Ov)}else if((R=ij(S)*r)+ue>le)throw Dv(Ov);H=R/r}else H=wx(_),E=new Px(R=H*r);for(pj(f,{buffer:E,byteOffset:ue,byteLength:R,length:H,view:new _j(E)});Y<H;)p(f,Y++)}),Hl&&Hl(c,Lx),u=c.prototype=sj(Sc)),u.constructor!==c&&yc(u,"constructor",c),fj(u).TypedArrayConstructor=c,Dx&&yc(u,Dx,i);var h=c!=s;d[i]=c,Sx({global:!0,constructor:!0,forced:h,sham:!zl},d),Wl in c||yc(c,Wl,r),Wl in u||yc(u,Wl,r),dj(i)}):yv.exports=function(){},(0,yv.exports)("Uint8",function(e){return function(t,n,r){return e(this,t,n,r)}});var bj=Rt,Mv=Zr,Sj=Zt,kj=Uy,Tj=Math.min,xj=[].copyWithin||function(e,t){var n=bj(this),r=Sj(n),i=Mv(e,r),o=Mv(t,r),a=arguments.length>2?arguments[2]:void 0,s=Tj((a===void 0?r:Mv(a,r))-o,r-i),c=1;for(o<i&&i<o+s&&(c=-1,o+=s-1,i+=s-1);s-- >0;)o in n?n[i]=n[o]:kj(n,i),i+=c,o+=c;return n},Bx=He,Ij=ce(xj),wj=Bx.aTypedArray;(0,Bx.exportTypedArrayMethod)("copyWithin",function(e,t){return Ij(wj(this),e,t,arguments.length>2?arguments[2]:void 0)});var Ej=en.every,Cj=He.aTypedArray;(0,He.exportTypedArrayMethod)("every",function(e){return Ej(Cj(this),e,arguments.length>1?arguments[1]:void 0)});var Rj=ha,Aj=TypeError,Pj=C1,Dj=function(e){var t=Rj(e,"number");if(typeof t=="number")throw Aj("Can't convert number to bigint");return BigInt(t)},Lj=ei,Oj=Ke,Mj=ie,Nj=He.aTypedArray,Vj=He.exportTypedArrayMethod,Uj=ce("".slice);Vj("fill",function(e){var t=arguments.length;Nj(this);var n=Uj(Lj(this),0,3)==="Big"?Dj(e):+e;return Oj(Pj,this,n,t>1?arguments[1]:void 0,t>2?arguments[2]:void 0)},Mj(function(){var e=0;return new Int8Array(2).fill({valueOf:function(){return e++}}),e!==1}));var Bj=Zt,jj=Bs,Fj=He.aTypedArrayConstructor,Gj=He.getTypedArrayConstructor,ql=function(e){return Fj(jj(e,Gj(e)))},Hj=function(e,t){for(var n=0,r=Bj(t),i=new e(r);r>n;)i[n]=t[n++];return i},zj=ql,Wj=en.filter,Jj=function(e,t){return Hj(zj(e),t)},qj=He.aTypedArray;(0,He.exportTypedArrayMethod)("filter",function(e){var t=Wj(qj(this),e,arguments.length>1?arguments[1]:void 0);return Jj(this,t)});var Kj=en.find,Qj=He.aTypedArray;(0,He.exportTypedArrayMethod)("find",function(e){return Kj(Qj(this),e,arguments.length>1?arguments[1]:void 0)});var Xj=en.findIndex,Yj=He.aTypedArray;(0,He.exportTypedArrayMethod)("findIndex",function(e){return Xj(Yj(this),e,arguments.length>1?arguments[1]:void 0)});var $j=en.forEach,Zj=He.aTypedArray;(0,He.exportTypedArrayMethod)("forEach",function(e){$j(Zj(this),e,arguments.length>1?arguments[1]:void 0)});var e8=hs.includes,t8=He.aTypedArray;(0,He.exportTypedArrayMethod)("includes",function(e){return e8(t8(this),e,arguments.length>1?arguments[1]:void 0)});var n8=hs.indexOf,r8=He.aTypedArray;(0,He.exportTypedArrayMethod)("indexOf",function(e){return n8(r8(this),e,arguments.length>1?arguments[1]:void 0)});var i8=Z,a8=ie,Nv=ce,jx=He,Vv=U_,Uv=ct("iterator"),Fx=i8.Uint8Array,o8=Nv(Vv.values),s8=Nv(Vv.keys),c8=Nv(Vv.entries),Bv=jx.aTypedArray,Kl=jx.exportTypedArrayMethod,vo=Fx&&Fx.prototype,Ql=!a8(function(){vo[Uv].call([1])}),Gx=!!vo&&vo.values&&vo[Uv]===vo.values&&vo.values.name==="values",Hx=function(){return o8(Bv(this))};Kl("entries",function(){return c8(Bv(this))},Ql),Kl("keys",function(){return s8(Bv(this))},Ql),Kl("values",Hx,Ql||!Gx,{name:"values"}),Kl(Uv,Hx,Ql||!Gx,{name:"values"});var u8=He.aTypedArray,l8=He.exportTypedArrayMethod,d8=ce([].join);l8("join",function(e){return d8(u8(this),e)});var h8=ni,p8=it,f8=Kn,m8=Zt,v8=Os,g8=Math.min,jv=[].lastIndexOf,zx=!!jv&&1/[1].lastIndexOf(1,-0)<0,_8=v8("lastIndexOf"),y8=zx||!_8?function(e){if(zx)return h8(jv,this,arguments)||0;var t=p8(this),n=m8(t),r=n-1;for(arguments.length>1&&(r=g8(r,f8(arguments[1]))),r<0&&(r=n+r);r>=0;r--)if(r in t&&t[r]===e)return r||0;return-1}:jv,b8=ni,S8=y8,k8=He.aTypedArray;(0,He.exportTypedArrayMethod)("lastIndexOf",function(e){var t=arguments.length;return b8(S8,k8(this),t>1?[e,arguments[1]]:[e])});var T8=en.map,x8=ql,I8=He.aTypedArray;(0,He.exportTypedArrayMethod)("map",function(e){return T8(I8(this),e,arguments.length>1?arguments[1]:void 0,function(t,n){return new(x8(t))(n)})});var w8=gv.left,E8=He.aTypedArray;(0,He.exportTypedArrayMethod)("reduce",function(e){var t=arguments.length;return w8(E8(this),e,t,t>1?arguments[1]:void 0)});var C8=gv.right,R8=He.aTypedArray;(0,He.exportTypedArrayMethod)("reduceRight",function(e){var t=arguments.length;return C8(R8(this),e,t,t>1?arguments[1]:void 0)});var A8=He.aTypedArray,P8=He.exportTypedArrayMethod,D8=Math.floor;P8("reverse",function(){for(var e,t=this,n=A8(t).length,r=D8(n/2),i=0;i<r;)e=t[i],t[i++]=t[--n],t[n]=e;return t});var Wx=Z,Jx=Ke,Fv=He,L8=Zt,O8=bx,M8=Rt,qx=ie,N8=Wx.RangeError,Gv=Wx.Int8Array,Kx=Gv&&Gv.prototype,Qx=Kx&&Kx.set,V8=Fv.aTypedArray,U8=Fv.exportTypedArrayMethod,Hv=!qx(function(){var e=new Uint8ClampedArray(2);return Jx(Qx,e,{length:1,0:3},1),e[1]!==3}),B8=Hv&&Fv.NATIVE_ARRAY_BUFFER_VIEWS&&qx(function(){var e=new Gv(2);return e.set(1),e.set("2",1),e[0]!==0||e[1]!==2});U8("set",function(e){V8(this);var t=O8(arguments.length>1?arguments[1]:void 0,1),n=M8(e);if(Hv)return Jx(Qx,this,n,t);var r=this.length,i=L8(n),o=0;if(i+t>r)throw N8("Wrong length");for(;o<i;)this[t+o]=n[o++]},!Hv||B8);var j8=ql,F8=xa,G8=He.aTypedArray;(0,He.exportTypedArrayMethod)("slice",function(e,t){for(var n=F8(G8(this),e,t),r=j8(this),i=0,o=n.length,a=new r(o);o>i;)a[i]=n[i++];return a},ie(function(){new Int8Array(1).slice()}));var H8=en.some,z8=He.aTypedArray;(0,He.exportTypedArrayMethod)("some",function(e){return H8(z8(this),e,arguments.length>1?arguments[1]:void 0)});var Xx=mn.match(/firefox\/(\d+)/i),W8=!!Xx&&+Xx[1],J8=/MSIE|Trident/.test(mn),Yx=mn.match(/AppleWebKit\/(\d+)\./),q8=!!Yx&&+Yx[1],K8=ce,zv=ie,Q8=Nt,X8=g0,$x=W8,Y8=J8,Zx=Jn,eI=q8,$8=He.aTypedArray,Z8=He.exportTypedArrayMethod,kc=Z.Uint16Array,go=kc&&K8(kc.prototype.sort),eF=!(!go||zv(function(){go(new kc(2),null)})&&zv(function(){go(new kc(2),{})})),tI=!!go&&!zv(function(){if(Zx)return Zx<74;if($x)return $x<67;if(Y8)return!0;if(eI)return eI<602;var e,t,n=new kc(516),r=Array(516);for(e=0;e<516;e++)t=e%4,n[e]=515-e,r[e]=e-2*t+3;for(go(n,function(i,o){return(i/4|0)-(o/4|0)}),e=0;e<516;e++)if(n[e]!==r[e])return!0});Z8("sort",function(e){return e!==void 0&&Q8(e),tI?go(this,e):X8($8(this),function(t){return function(n,r){return t!==void 0?+t(n,r)||0:r!=r?-1:n!=n?1:n===0&&r===0?1/n>0&&1/r<0?1:-1:n>r}}(e))},!tI||eF);var tF=Qn,nI=Zr,nF=ql,rF=He.aTypedArray;(0,He.exportTypedArrayMethod)("subarray",function(e,t){var n=rF(this),r=n.length,i=nI(e,r);return new(nF(n))(n.buffer,n.byteOffset+i*n.BYTES_PER_ELEMENT,tF((t===void 0?r:nI(t,r))-i))});var iF=ni,rI=He,Wv=ie,iI=xa,Xl=Z.Int8Array,aI=rI.aTypedArray,aF=rI.exportTypedArrayMethod,oI=[].toLocaleString,oF=!!Xl&&Wv(function(){oI.call(new Xl(1))});aF("toLocaleString",function(){return iF(oI,oF?iI(aI(this)):aI(this),iI(arguments))},Wv(function(){return[1,2].toLocaleString()!=new Xl([1,2]).toLocaleString()})||!Wv(function(){Xl.prototype.toLocaleString.call([1,2])}));var sF=He.exportTypedArrayMethod,cF=ie,uF=ce,sI=Z.Uint8Array,lF=sI&&sI.prototype||{},Yl=[].toString,dF=uF([].join);cF(function(){Yl.call({})})&&(Yl=function(){return dF(this)});var hF=lF.toString!=Yl;sF("toString",Yl,hF);var pF=function(){function e(t,n,r){z(this,e),this.isUplink_=r,this.connection_=t,this.log_=n,this.seiMessageList_=[],this.seiPayloadType_=243,this.mainVideoSenderOrReceiver_=null,this.mainVideoAbortController_=null,this.abortMap_=new Map,this.onSEIMessage=null}return ke(e,[{key:"isRunning",get:function(){return!!this.mainVideoAbortController_}},{key:"start",value:function(t){this.mainVideoSenderOrReceiver_=t;var n=t.createEncodedStreams(),r=n.readable,i=n.writable,o=new TransformStream({transform:this.isUplink_?this.encodeVideoFrame.bind(this):this.decodeVideoFrame.bind(this)});this.mainVideoAbortController_=new AbortController,r.pipeThrough(o).pipeTo(i,{signal:this.mainVideoAbortController_.signal}).catch(function(){})}},{key:"restart",value:function(t){this.stop(),this.start(t)}},{key:"stop",value:function(){var t;(t=this.mainVideoAbortController_)===null||t===void 0||t.abort(),this.mainVideoAbortController_=null}},{key:"destroy",value:function(){this.stop(),this.abortMap_.forEach(function(t){return t.abort()}),this.abortMap_.clear(),this.log_=null,this.onSEIMessage=null,this.mainVideoSenderOrReceiver_=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(r,i){if(i===1){if(r===t.mainVideoSenderOrReceiver_)return;t.isRunning?t.restart(r):t.start(r)}else{if(t.abortMap_.has(r))return;t.pipeSenderOrReceiver(r)}}):n.getReceivers().forEach(function(r,i){var o;t.abortMap_.has(r)||r===t.mainVideoSenderOrReceiver_||(i===1&&((o=r.track)===null||o===void 0?void 0:o.kind)===xe?t.isRunning?t.restart(r):t.start(r):t.pipeSenderOrReceiver(r))})}catch(r){this.log_.warn(r)}}},{key:"pipeSenderOrReceiver",value:function(t){var n=t.createEncodedStreams(),r=n.readable,i=n.writable,o=new AbortController;this.abortMap_.set(t,o),r.pipeTo(i,{signal:o.signal}).catch(function(){})}},{key:"clearUnusedSenderOrReceiver",value:function(t){var n=this;this.abortMap_.forEach(function(r,i){(n.isUplink_?t.getSenders():t.getReceivers()).find(function(o){return o===i})||(r.abort(),n.abortMap_.delete(i))})}},{key:"push",value:function(t,n){n&&n.seiPayloadType&&(this.seiPayloadType_=n.seiPayloadType),this.seiMessageList_.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,r=0,i=new DataView(t),o=0;o<t.byteLength;o++)switch(i.getUint8(o)){case 0:n++;break;case 1:n!==2&&n!==3||r++,n=0;break;default:n=0}return r}},{key:"encodeVideoFrame",value:function(t,n){try{if(this.connection_.isH264&&this.seiMessageList_.length>0&&!this.isEmptyFrame(t)){var r=9-this.getNaluCount(t.data);if(r<=0)return;for(var i=this.seiMessageList_.splice(0,r).reverse().map(this.encodeSEINalu.bind(this)),o=i.reduce(function(f,_){return f+_.dataView.byteLength},0),a=new ArrayBuffer(o+t.data.byteLength),s=new DataView(a),c=new DataView(t.data),u=0,d=0;d<i.length;d++)for(var p=0;p<i[d].dataView.byteLength;p++)s.setInt8(u++,i[d].dataView.getInt8(p));for(var h=0;h<t.data.byteLength;h++)s.setInt8(u++,c.getInt8(h));t.data=a,this.log_.debug("".concat(i.length," sei sent"))}}catch(f){this.log_.warn(f)}n.enqueue(t)}},{key:"decodeVideoFrame",value:function(t,n){var r=this;try{if(this.connection_.isH264&&!this.isEmptyFrame(t)&&this.hasSEI(t.data)){for(var i=[],o=new DataView(t.data),a=0,s=-1,c=-1,u=0;u<t.data.byteLength;u++){var d=o.getUint8(u);if(d===0)a++;else if(d===1){if(a===2||a===3){var p=u-a;if(s===-1?s=p:c===-1&&(c=p,i.push(new cI(new DataView(o.buffer.slice(s,c)))),s=p,c=-1),o.getUint8(u+1)!==6){t.data=new DataView(o.buffer.slice(p)).buffer;break}}a=0}else a=0}this.log_.debug("".concat(i.length," sei received")),kn(this.onSEIMessage)&&i.reverse().forEach(function(h){r.onSEIMessage({seiPayloadType:h.seiPayloadType,data:h.seiPayload.buffer})})}}catch(h){this.log_.warn(h)}n.enqueue(t)}},{key:"encodeSEINalu",value:function(t){var n=t.byteLength,r=parseInt(n/255),i=n%255,o=[];o.push(0,0,0,1,6,this.seiPayloadType_);for(var a=0;a<r;a++)o.push(255);o.push(i);var s=new DataView(t);return o.push.apply(o,Se(new Uint8Array(s.buffer))),o.push(128),new cI(new DataView(new Uint8Array(o).buffer),!0)}}]),e}(),cI=function(){function e(t){var n=arguments.length>1&&arguments[1]!==void 0&&arguments[1];z(this,e),this.dataView=t,this.isSEI&&(n?this.addPreventionByte():this.removePreventionByte())}return ke(e,[{key:"addPreventionByte",value:function(){for(var t=this.seiPayloadStartIndex,n=this.dataView.byteLength-2,r=[],i=0,o=t;o<=n;o++){var a=this.dataView.getInt8(o);switch(a){case 0:case 1:case 2:case 3:i===2&&(r.push(3),i=0),a==0?i++:i=0,r.push(a);break;default:i=0,r.push(a)}}r.push(this.dataView.getInt8(this.dataView.byteLength-1));var s=new DataView(new Uint8Array([].concat(Se(new Uint8Array(this.dataView.buffer).slice(0,t)),r)).buffer);this.dataView=s}},{key:"removePreventionByte",value:function(){for(var t=this.seiPayloadStartIndex,n=this.dataView.byteLength-1,r=[],i=0,o=t;o<=n;o++)switch(this.dataView.getInt8(o)){case 0:i++,r.push(this.dataView.getInt8(o));break;case 3:i!==2&&r.push(this.dataView.getInt8(o)),i=0;break;default:r.push(this.dataView.getInt8(o)),i=0}var a=new DataView(new Uint8Array([].concat(Se(new Uint8Array(this.dataView.buffer).slice(0,t)),r)).buffer);this.dataView=a}},{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,r=6;r<this.dataView.buffer.byteLength;r++){var i=this.dataView.getUint8(r);if(n++,i!==255){t+=i;break}t+=255}for(var o=new ArrayBuffer(t),a=new DataView(o),s=0;s<o.byteLength;s++,n++)a.setInt8(s,this.dataView.getInt8(n));return a}}]),e}(),Jv=function(){function e(n){z(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_=be.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 pi,this.currentState_=nn,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_&&Rm&&(this.sei_=new pF(this,this.log_,this.isUplink_))}var t;return ke(e,[{key:"initialize",value:function(){var n={encodedInsertableStreams:this.enableSEI_&&Rm,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(nn))}},{key:"getDTLSTransportState",value:function(){if(!this.peerConnection_)return Ku;var n=null;if(this.isUplink_){if(!gl()||this.peerConnection_.getSenders().length===0)return Ku;n=this.peerConnection_.getSenders()[0].transport}else{if(!PT()||this.peerConnection_.getReceivers().length===0)return Ku;n=this.peerConnection_.getReceivers()[0].transport}return n?n.state:Ku}},{key:"onConnectionStateChange",value:function(n){var r=this.peerConnection_.iceConnectionState,i=this.getDTLSTransportState();if(this.log_.info("onConnectionStateChange() connectionState: "+n.target.connectionState),this.log_.info("ICE Transport state: ".concat(r,", DTLS Transport state: ").concat(i)),n.target.connectionState===Qu&&this.emitConnectionStateChangedEvent(mS),n.target.connectionState===gS||n.target.connectionState===Kp){var o="".concat(this.isUplink_?"uplink":"downlink"," ICE/DTLS Transport connection ").concat(n.target.connectionState,". ICE Transport state: ").concat(r,", DTLS Transport state: ").concat(i),a=new $({message:o,code:Q.ICE_TRANSPORT_ERROR});Ie.logFailedEvent({userId:this.client_.getUserId(),eventType:AS,error:a}),this.emitConnectionStateChangedEvent(nn),this.isErrorObserved_||this.emitter_.emit(rt.ERROR,a)}n.target.connectionState!==_S&&n.target.connectionState!==mN||(this.logSelectedCandidate(),Ie.logSuccessEvent({userId:this.client_.getUserId(),eventType:AS}),this.emitConnectionStateChangedEvent(ln))}},{key:"emitConnectionStateChangedEvent",value:function(n){n!==this.currentState_&&(this.currentState_===vS&&n===mS||(W.emit(rm,{client:this.client_,connection:this,prevState:this.currentState_,state:n}),this.emitter_.emit(rt.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,r){var i=this.client_.getUserId(),o={eventId:n,eventDesc:r,timestamp:tn(),userId:i,tinyId:this.client_.getTinyId()};this.isUplink_||(o.remoteUserId=this.userId_,o.remoteTinyId=this.tinyId_),dn(i,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=N(m().mark(function n(){var r,i,o,a,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:r=d.sent,i=ne(r),d.prev=6,i.s();case 8:if((o=i.n()).done){d.next=18;break}if((a=Te(o.value,2))[0],!Am(s=a[1])){d.next=16;break}return c=r.get(s.localCandidateId),u=r.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(r,i){if(n.currentState_===ln)return r();var o=-1,a=function(u){u.state===ln&&(clearTimeout(o),c(),r())},s=function(u){u.client===n.client_&&(clearTimeout(o),c(),i(new $({code:Q.API_CALL_ABORTED,message:te({key:S4,data:"leave room"})})))},c=function(){W.off(Ya,s,n),n.emitter_.off(rt.CONNECTION_STATE_CHANGED,a,n)};o=setTimeout(function(){c();var u=new $({code:Q.API_CALL_TIMEOUT,message:"connection timeout"});i(u)},1e4),W.on(Ya,s,n),n.emitter_.on(rt.CONNECTION_STATE_CHANGED,a,n)}),this.waitForPeerConnectionConnectedPromise_=this.waitForPeerConnectionConnectedPromise_.then(function(r){return n.waitForPeerConnectionConnectedPromise_=null,r}).catch(function(r){throw n.waitForPeerConnectionConnectedPromise_=null,r})),this.waitForPeerConnectionConnectedPromise_}},{key:"getReconnectionCount",value:function(){return this.reconnectionCount_}},{key:"startReconnection",value:function(){this.isReconnecting_=!0,this.emitConnectionStateChangedEvent(vS),this.reconnect(),this.addEventInternal(this.isUplink_?wU:RU,"".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(sc,this.reconnect,this)}},{key:"on",value:function(n,r,i){this.emitter_.on(n,r,i)}},{key:"off",value:function(n,r,i){this.emitter_.off(n,r,i)}},{key:"setDelay",value:function(n){var r=n.audioDelay,i=n.videoDelay;this.delay_={audioDelay:r,videoDelay:i}}},{key:"getDelay",value:function(){return this.delay_}},{key:"isH264",get:function(){var n,r;return!((n=this.peerConnection_)===null||n===void 0||(r=n.remoteDescription)===null||r===void 0||!r.sdp.includes("H264"))}}]),e}(),fF=function(){function e(){z(this,e),this.set_=new Set,W.on(pl,this.add,this),W.on(Qa,this.add,this),W.on(Xa,this.delete,this),W.on(Ya,this.delete,this)}return ke(e,[{key:"add",value:function(t){var n=t.client,r=t.roomId;if(n.getMode()!=="rtc"){var i=this.getKey(n.getUserId(),r||n.getRoomId(),n.getSDKAppId(),n.getUseStringRoomId());this.set_.add(i)}}},{key:"delete",value:function(t){var n=t.client;if(n.getMode()!=="rtc"){var r=this.getKey(n.getUserId(),n.getRoomId(),n.getSDKAppId(),n.getUseStringRoomId());this.set_.delete(r)}}},{key:"getKey",value:function(t,n,r,i){return"".concat(r,"_").concat(n,"_").concat(t,"_").concat(i)}},{key:"isJoined",value:function(t){var n=t.userId,r=t.roomId,i=t.sdkAppId,o=t.client;return o.getMode()!=="rtc"&&this.set_.has(this.getKey(n,r,i,o.getUseStringRoomId()))}}]),e}(),mF=new fF;function uI(e,t,n,r){if(this.useStringRoomId_){if(!(Ft(e)&&/^[A-Za-z\d\s!#$%&()+\-:;<=.>?@[\]^_{}|~,]{1,64}$/.test(e)))throw new $({code:Q.INVALID_PARAMETER,message:te({key:n3,data:t,link:{className:r,fnName:n}})})}else if(!(br(e)&&/^[1-9]\d*$/.test(String(e))&&e<4294967295))throw new $({code:Q.INVALID_PARAMETER,message:te({key:r3,data:t,link:{className:r,fnName:n}})})}function lI(e,t,n,r){if(!/^[A-Za-z\d_-]*$/.test(e))throw new $({code:Q.INVALID_PARAMETER,message:te({key:y3,data:t,link:{className:r,fnName:n}})})}var dI,Tc,vF={createClient:{name:"clientConfig",required:!0,type:_r,properties:{sdkAppId:{required:!0,type:xt,allowEmpty:!1},userId:{required:!0,type:St,allowEmpty:!1},userSig:{required:!0,type:St,allowEmpty:!1},mode:{required:!0,type:St,values:["rtc",qu]},useStringRoomId:{type:rn},autoSubscribe:{type:rn},enableAutoPlayDialog:{type:rn},streamId:{type:St},userDefineRecordId:{type:St},pureAudioPushMode:{type:xt,values:[1,2]},enableSEI:{type:rn}}},createStream:{name:"streamConfig",required:!0,type:_r,properties:{userId:{type:St},audio:{type:rn},video:{type:rn},screen:{type:rn},screenAudio:{type:rn},microphoneId:{type:St},cameraId:{type:St},facingMode:{type:[St,_r]},audioSource:{instanceOf:window.MediaStreamTrack},videoSource:{instanceOf:window.MediaStreamTrack}},validate:function(e){if(!fe(e.screen)&&e.screen&&fe(e.audio)&&(e.audio=!1),!(fe(e.audio)&&fe(e.video)||fe(e.audioSource)&&fe(e.videoSource)))throw new $({code:Q.INVALID_PARAMETER,message:te({key:t4})});if(!fe(e.screen)&&e.screen===!0&&e.video===!0)throw new $({code:Q.INVALID_PARAMETER,message:te({key:n4})});if(e.audio&&e.screenAudio)throw new $({code:Q.INVALID_PARAMETER,message:te({key:r4})});if(e.screen!==!0&&e.screenAudio===!0)throw new $({code:Q.INVALID_PARAMETER,message:te({key:i4})});if(!fe(e.screen)&&e.screen===!0&&!this.isScreenShareSupported())throw new $({code:Q.INVALID_OPERATION,message:te({key:s4})})}}},gF={join:{name:"options",required:!0,type:_r,properties:{roomId:{required:!0,type:[xt,St],allowEmpty:!1,validate:uI},role:{type:[St],values:[vr,zi]},privateMapKey:{type:[St]}},validate:function(e){if(this.isJoined_)throw new $({code:Q.INVALID_OPERATION,message:te({key:t3})});if(this.checkDestroy(),mF.isJoined({userId:this.userId_,roomId:e.roomId,sdkAppId:this.sdkAppId_,client:this}))throw new $({code:Q.INVALID_OPERATION,message:te({key:G3,data:this.userId_})})}},publish:[{name:"stream",required:!0,instanceOf:nf,validate:function(e){if(!this.isJoined_)throw new $({code:Q.INVALID_OPERATION,message:te({key:s3})});if(this.mode_===qu&&this.role_===zi)throw new $({code:Q.INVALID_OPERATION,message:te({key:u3})});if(!e.getIsReadyToPublish())throw new $({code:Q.INVALID_OPERATION,message:te({key:l3})});if(this.notPublishWithoutH264Supported_)throw new $({code:Q.NOT_SUPPORTED_H264,message:te({key:uk})})}},{name:"options",type:_r,defaultValue:{isAuxiliary:!1},properties:{isAuxiliary:{type:rn,defaultValue:!1,validate:function(){var e=arguments.length>0&&arguments[0]!==void 0&&arguments[0];if(e&&!Em())throw new $({code:Q.NOT_SUPPORTED,message:te({key:c4})});if(this.uplinkConnection_&&(e&&this.uplinkConnection_.isAuxStreamPublished||!e&&this.uplinkConnection_.isMainStreamPublished))throw new $({code:Q.INVALID_OPERATION,message:te({key:d3,data:e?pt:"local"})});var t=this.localScreenStream_||Se(this.connections_.values()).findIndex(function(n){return n.getTrackState().auxiliary})>=0;if(!this.enableMultiAuxStream_&&e&&t)throw new $({code:Q.INVALID_OPERATION,message:te({key:k4})})}}}}],unpublish:{name:"stream",required:!0,instanceOf:nf,validate:function(e){if(e!==this.localStream_&&e!==this.localAuxStream_){if(this.localStream_||this.localAuxStream_)throw new $({code:Q.INVALID_PARAMETER,message:te({key:c3})});this.log_.warn("Client currently has no published stream, please call publish() first.")}}},subscribe:[{name:"stream",required:!0,instanceOf:rf,validate:function(e){if(!e.getConnection())throw new $({code:Q.INVALID_OPERATION,message:te({key:sf})});if(this.notSubscribeWithoutH264Supported_)throw new $({code:Q.NOT_SUPPORTED_H264,message:te({key:lk})})}},{name:"options",type:_r,properties:{audio:{type:rn},video:{type:rn},smallVideo:{type:rn}},validate:function(e){var t=e.audio,n=e.video,r=e.smallVideo;if(t===!1&&n===!1&&(fe(r)||r===!1))throw new $({code:Q.INVALID_OPERATION,message:te({key:f4})})}}],unsubscribe:{name:"stream",required:!0,instanceOf:rf,validate:function(e){if(!e.getConnection())throw new $({code:Q.INVALID_OPERATION,message:te({key:sf})})}},switchRole:{name:"role",required:!0,values:[vr,zi],validate:function(){if(this.mode_!==qu)throw new $({code:Q.INVALID_PARAMETER,message:te({key:p3})});if(!this.isJoined_)throw new $({code:Q.INVALID_OPERATION,message:te({key:f3})})}},startPublishCDNStream:{name:"options",required:!1,properties:{streamId:{type:St,validate:lI},streamType:{type:St,values:["main","auxiliary"]},appId:{type:xt,allowEmpty:!1},bizId:{type:xt,allowEmpty:!1},url:{type:St,allowEmpty:!1}},validate:function(){if(this.isDestroyed_)throw new $({code:Q.INVALID_OPERATION,message:te({key:cf,data:{funName:"startPublishCDNStream"}})})}},startMixTranscode:{name:"config",required:!0,type:_r,properties:{mode:{type:St,values:["preset-layout","manual"]},streamId:{type:St,validate:lI},videoWidth:{type:xt,notLessThanZero:!0},videoHeight:{type:xt,notLessThanZero:!0},videoBitrate:{type:xt,notLessThanZero:!0,allowEmpty:!1},videoFramerate:{type:xt,validate:function(e,t,n,r){if(e<=0||e>30)throw new $({code:Q.INVALID_PARAMETER,message:te({key:q3,link:{className:r,fnName:n}})})}},videoGop:{type:xt,validate:function(e,t,n,r){if(e<1||e>8)throw new $({code:Q.INVALID_PARAMETER,message:te({key:K3,link:{className:r,fnName:n}})})}},audioSampleRate:{type:xt,notLessThanZero:!0},audioBitrate:{type:xt,validate:function(e,t,n,r){if(e<32||e>192)throw new $({code:Q.INVALID_PARAMETER,message:te({key:Q3,link:{className:r,fnName:n}})})}},audioChannels:{type:xt,values:[1,2]},backgroundColor:{type:xt},backgroundImage:{type:St},mixUsers:{required:!0,type:bN,arrayItem:{require:!0,type:_r,properties:{userId:{required:!0,type:St},roomId:{type:[St,xt],validate:uI},pureAudio:{type:rn},width:{type:xt,notLessThanZero:!0},height:{type:xt,notLessThanZero:!0},locationX:{type:xt,notLessThanZero:!0},locationY:{type:xt,notLessThanZero:!0},zOrder:{type:xt},streamType:{type:St,values:["main","auxiliary"]},renderMode:{type:xt,values:[0,1,2,4]}}}}},validate:function(e,t,n,r,i){var o=0,a=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>15)throw new $({code:Q.INVALID_PARAMETER,message:te({key:X3,data:"config.mixUsers[".concat(d,"].zOrder"),link:{className:r,fnName:n}})});u.width+u.locationX>o&&(o=u.width+u.locationX),u.height+u.locationY>a&&(a=u.height+u.locationY)}}),c.indexOf(this.getUserId())<0)throw new $({code:Q.INVALID_PARAMETER,message:te({key:Y3,link:{className:r,fnName:n}})});if(e.videoWidth<o||e.videoHeight<a)throw new $({code:Q.INVALID_PARAMETER,message:te({key:$3,link:{className:r,fnName:n}})})}},sendSEIMessage:[{name:"buffer",required:!0,instanceOf:ArrayBuffer,validate:function(e){if(!Rm)throw new $({code:Q.NOT_SUPPORTED,message:te({key:hk})});if(!this.enableSEI_)throw new $({code:Q.INVALID_OPERATION,message:te({key:m4})});if(e.byteLength>1e3)throw new $({code:Q.INVALID_PARAMETER,message:te({key:g4,data:e.byteLength})});if(e.byteLength===0)throw new $({code:Q.INVALID_PARAMETER,message:te({key:v4})});if(!this.uplinkConnection_||!this.localStream_)throw new $({code:Q.INVALID_PARAMETER,message:te({key:_4})});if(!this.localStream_.hasVideo())throw new $({code:Q.INVALID_OPERATION,message:te({key:y4})});var t=this.uplinkConnection_.isH264;if(!t)throw new $({code:Q.NOT_SUPPORTED,message:te({key:hk,data:t})})}},{name:"options",type:_r,properties:{seiPayloadType:{type:xt,values:[5,243]}}}]},_F={play:[{name:"elementId",required:!0,type:[St,"HTMLDivElement"],validate:function(e,t,n){if(Ft(e)){var r=document.getElementById(e);if(!r)throw new $({code:Q.INVALID_PARAMETER,message:te({key:Z3,data:{key:t,fnName:n}})});if(!(r instanceof HTMLDivElement))throw new $({code:Q.INVALID_PARAMETER,message:te({key:e4,data:{key:t,fnName:n,type:hi(r)}})})}}},{name:"options",type:_r,properties:{objectFit:{type:St,values:["contain","cover","fill"]},muted:{type:rn},mirror:{type:rn}}}],addTrack:{name:Jp,instanceOf:MediaStreamTrack,validate:function(e){if(this.isAddingTrack_)throw new $({code:Q.INVALID_OPERATION,message:te({key:P3})});if(this.isRemovingTrack_)throw new $({code:Q.INVALID_OPERATION,message:te({key:D3})});if(this.publishState_===ec)throw new $({code:Q.INVALID_OPERATION,message:te({key:L3})});var t=this.getMediaStream();if(!t)throw new $({code:Q.INVALID_OPERATION,message:te({key:ok})});if(e.kind===Ce&&t.getAudioTracks().length>0||e.kind===xe&&t.getVideoTracks().length>0)throw new $({code:Q.INVALID_OPERATION,message:te({key:O3})});if(!fi()&&!gl())throw new $({code:Q.NOT_SUPPORTED,message:te({key:lf,data:hS})})}},removeTrack:{name:Jp,instanceOf:MediaStreamTrack,validate:function(e){if(this.isAddingTrack_)throw new $({code:Q.INVALID_OPERATION,message:te({key:N3})});if(this.isRemovingTrack_)throw new $({code:Q.INVALID_OPERATION,message:te({key:V3})});if(this.publishState_===ec)throw new $({code:Q.INVALID_OPERATION,message:te({key:U3})});var t=this.getMediaStream();if(!t)throw new $({code:Q.INVALID_OPERATION,message:te({key:ok})});if(t.getTracks().indexOf(e)===-1)throw new $({code:Q.INVALID_PARAMETER,message:te({key:B3})});if(!fi()){if(t.getTracks().length===1)throw new $({code:Q.INVALID_OPERATION,message:te({key:j3})});if(e.kind===Ce)throw new $({code:Q.INVALID_PARAMETER,message:te({key:M3})});if(!gl())throw new $({code:Q.NOT_SUPPORTED,message:te({key:lf,data:pS})})}}},replaceTrack:{name:Jp,instanceOf:MediaStreamTrack,validate:function(e){var t=this.getMediaStream();if(!t)throw new $({code:Q.INVALID_OPERATION,message:te({key:A3})});if(this.publishState_===ec)throw new $({code:Q.INVALID_OPERATION,message:te({key:ak})});if(e.kind===Ce&&t.getAudioTracks().length<=0||e.kind===xe&&t.getVideoTracks().length<=0)throw new $({code:Q.INVALID_PARAMETER,message:te({key:F3,data:e})});if(!Cm())throw new $({code:Q.NOT_SUPPORTED,message:te({key:lf,data:nN})})}}},Jt={TRTC:vF,CLIENT:gF,LOCAL_STREAM:{switchDevice:[{name:"type",required:!0,type:St,values:[Ce,xe]},{name:"deviceId",required:!0,type:St,validate:function(){if(this.screen_&&!this.audio_||this.audioSource_||this.videoSource_)throw new $({code:Q.INVALID_OPERATION,message:te({key:C3})});if(this.publishState_===ec)throw new $({code:Q.INVALID_OPERATION,message:te({key:R3})});if(!Cm())throw new $({code:Q.NOT_SUPPORTED,message:te({key:o4})})}}],setAudioCaptureVolume:{name:"volume",type:xt}},STREAM:_F};function $l(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return function(r,i,o){var a=o.value;return o.value=function(){for(var s=arguments.length,c=new Array(s),u=0;u<s;u++)c[u]=arguments[u];return hI.call(this,t,c,i,this.name_),a.apply(this,c)},o}}function Tn(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return function(r,i,o){var a=o.value;return o.value=N(m().mark(function s(){var c,u,d,p=arguments;return m().wrap(function(h){for(;;)switch(h.prev=h.next){case 0:for(c=p.length,u=new Array(c),d=0;d<c;d++)u[d]=p[d];return hI.call(this,t,u,i,this.name_),h.abrupt("return",a.apply(this,u));case 3:case"end":return h.stop()}},s,this)})),o}}function hI(e,t,n,r){try{for(var i=0;i<e.length;i++)qv.call(this,{rule:e[i],value:t[i],key:e[i].name,fnName:n,className:r})}catch(o){throw be.error(o),o}}function qv(e){var t=this,n=e.rule,r=e.value,i=e.key,o=e.fnName,a=e.className;if(fe(r)){if(n.required)throw new $({code:Q.INVALID_PARAMETER,message:te({key:BN,data:{key:i,rule:n,fnName:o,value:r},link:{className:a,fnName:o}})});if(fe(n.defaultValue))return;r=n.defaultValue}if(Array.isArray(n.type)){if(!n.type.map(function(p){return p.toLowerCase()}).includes(hi(r)))throw new $({code:Q.INVALID_PARAMETER,message:te({key:ZS,data:{key:i,rule:n,fnName:o,value:r},link:{className:a,fnName:o}})})}else if(!fe(n.type)&&hi(r)!==n.type)throw new $({code:Q.INVALID_PARAMETER,message:te({key:ZS,data:{key:i,rule:n,fnName:o,value:r},link:{className:a,fnName:o}})});if(n.allowEmpty===!1){var s=br(r)&&(r===0||Number.isNaN(r)),c=Ft(r)&&r.trim()==="";if(s||c)throw new $({code:Q.INVALID_PARAMETER,message:te({key:jN,data:{key:i,rule:n,fnName:o,value:r},link:{className:a,fnName:o}})})}if(n.notLessThanZero&&br(r)&&r<0)throw new $({code:Q.INVALID_PARAMETER,message:te({key:J3,data:{key:i,rule:n,fnName:o,value:r},link:{className:a,fnName:o}})});if(Ft(n.instanceOf)){if(!r||r.name_!==n.instanceOf)throw new $({code:Q.INVALID_PARAMETER,message:te({key:ek,data:{key:i,rule:n,fnName:o,value:r},link:{className:a,fnName:o}})})}else if(kn(n.instanceOf)&&!(r instanceof n.instanceOf))throw new $({code:Q.INVALID_PARAMETER,message:te({key:ek,data:{key:i,rule:n,fnName:o,value:r},link:{className:a,fnName:o}})});if(n.values&&!n.values.includes(r))throw new $({code:Q.INVALID_PARAMETER,message:te({key:FN,data:{key:i,rule:n,fnName:o,value:r},link:{className:a,fnName:o}})});var u=n.properties;Qi(u)&&Rk(r)&&Object.keys(u).forEach(function(p){qv.call(t,{rule:u[p],value:r&&r[p],key:"".concat(i,".").concat(p),fnName:o,className:a})});var d=n.arrayItem;Qi(d)&&Ak(r)&&r.forEach(function(p,h){qv.call(t,{rule:d,value:p,key:"".concat(i,"[").concat(h,"]"),fnName:o,className:a})}),kn(n.validate)&&n.validate.call(this,r,i,o,a,this)}Oe({target:"Number",stat:!0},{isNaN:function(e){return e!=e}});var pI=(dI=Tn.apply(void 0,Se(Jt.STREAM.play)),Tc=function(){function e(a){z(this,e),this.name_=CN,this.userId_=a.userId,this.isRemote_=a.isRemote,this.type_=a.type,this.log_=be.createLogger({id:"s".concat(a.seq?a.seq:"","|").concat(this.userId_),userId:fe(a.client)?void 0:a.client.getUserId(),sdkAppId:fe(a.client)?void 0:a.client.getSDKAppId(),isLocal:!this.isRemote_,type:this.isRemote_?this.type_:""}),this.client_=null,fe(a.client)||(this.client_=a.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_=Nk(new pi,this.name_),this.connectionState_=nn,this.installEvents(),fe(a.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(Wa,"/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(Wa,"/zh-cn/LocalStream.html#play\u3002"))}var t,n,r,i,o;return ke(e,[{key:"installEvents",value:function(){W.on(ac,this.restartPlayback,this)}},{key:"uninstallEvents",value:function(){W.off(ac,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_===Pt&&this.connection_.isAuxStreamSubscribed}},{key:"isMainVideoSubscribed",get:function(){var a=this.getSubscribedState();return this.type_===gt&&a&&a.video}},{key:"isMainAudioSubscribed",get:function(){var a=this.getSubscribedState();return this.type_===gt&&a&&a.audio}},{key:"isAuxVideoSubscribed",get:function(){var a=this.getSubscribedState();return this.type_===Pt&&a&&a.auxiliary}},{key:"isSmallVideoSubscribed",get:function(){var a=this.getSubscribedState();return this.type_===gt&&a&&a.smallVideo}},{key:"emitConnectionStateChanged",value:function(a){a.state!==this.connectionState_&&(a.state!==nn&&this.isRemote_&&!this.isSubscribed||(this.emitter_.emit(h6,a),this.connectionState_=a.state))}},{key:"setConnection",value:function(a){this.connection_!==a&&(a instanceof Jv?(this.connection_!==null&&this.connection_.off(rt.CONNECTION_STATE_CHANGED,this.emitConnectionStateChanged,this),a.on(rt.CONNECTION_STATE_CHANGED,this.emitConnectionStateChanged,this)):a===null&&this.connection_.off(rt.CONNECTION_STATE_CHANGED,this.emitConnectionStateChanged,this),this.connection_=a)}},{key:"getConnection",value:function(){return this.connection_}},{key:"play",value:(o=N(m().mark(function a(s,c){var u,d,p;return m().wrap(function(h){for(;;)switch(h.prev=h.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_){h.next=9;break}return c&&!fe(c.muted)&&(this.muted_=c.muted),c&&!fe(c.objectFit)&&(this.objectFit_=c.objectFit),this.isScreenShare()?this.mirror_=!1:c&&!fe(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,Ft(s)&&(u=document.getElementById(s)),u.appendChild(this.div_),this.elementId_=s),h.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;"),p=s,Ft(s)&&(p=document.getElementById(s)),p.appendChild(d),this.elementId_=s,this.div_=d,this.isRemote_||(this.muted_=!0),c&&!fe(c.muted)&&(this.muted_=c.muted),this.isScreenShare()&&(this.objectFit_="contain"),c&&!fe(c.objectFit)&&(this.objectFit_=c.objectFit),this.isScreenShare()?this.mirror_=!1:(this.isRemote_||(this.mirror_=!0),c&&!fe(c.mirror)&&(this.mirror_=c.mirror)),W.emit(Yf,{stream:this}),h.next=26,Promise.all([this.playAudio(),this.playVideo()]);case 26:W.emit(X4,{stream:this});case 27:case"end":return h.stop()}},a,this)})),function(a,s){return o.apply(this,arguments)})},{key:"playAudio",value:(i=N(m().mark(function a(){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 p5({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(hn,function(p){var h={type:Ce,state:p.state,reason:p.reason};W.emit(Fk,G({stream:u},h)),u.emitter_.emit(MT,h)}),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 x1,this.emitter_.emit(Dm,d.t0),d.t0;case 17:case"end":return d.stop()}},a,this,[[7,12]])})),function(){return i.apply(this,arguments)})},{key:"playVideo",value:(r=N(m().mark(function a(){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 W.emit(Zf,{stream:this}),this.log_.info("create VideoPlayer and play"),this.videoPlayer_=new I1({stream:this,track:s,div:this.div_,muted:this.muted_,objectFit:this.objectFit_,mirror:this.mirror_}),this.videoPlayer_.on(hn,function(d){var p={type:xe,state:d.state,reason:d.reason};W.emit(Fk,G({stream:c},p)),c.emitter_.emit(MT,p)}),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 x1,this.emitter_.emit(Dm,u.t0),u.t0;case 18:case"end":return u.stop()}},a,this,[[8,13]])})),function(){return r.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(a){}))}},{key:"restartVideo",value:function(){this.isPlaying_&&(this.stopVideo(),this.playVideo().catch(function(a){}))}},{key:"stop",value:function(){this.isPlaying_&&(this.isPlaying_=!1,this.stopAudio(),this.stopVideo(),this.div_.parentNode.removeChild(this.div_))}},{key:"resume",value:(n=N(m().mark(function a(){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()}},a,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(a){a.stop()}),this.mediaStream_=null),this.uninstallEvents())}},{key:"muteAudio",value:function(){return this.addRemoteEvent(!0,Ce),this.doEnableTrack(Ce,!1)}},{key:"muteVideo",value:function(){return this.addRemoteEvent(!0,xe),this.doEnableTrack(xe,!1)}},{key:"unmuteAudio",value:function(){return this.addRemoteEvent(!1,Ce),this.doEnableTrack(Ce,!0)}},{key:"unmuteVideo",value:function(){return this.addRemoteEvent(!1,xe),this.doEnableTrack(xe,!0)}},{key:"addRemoteEvent",value:function(a,s){if(this.isRemote_&&this.client_){var c=this.client_.getUserId(),u="".concat(a?$t:fr," remote ").concat(s);dn(c,{eventId:s===Ce?a?fU:vU:a?pU:mU,eventDesc:u,timestamp:new Date().getTime(),userId:c,tinyId:this.client_.getTinyId(),remoteUserId:this.userId_,remoteTinyId:this.connection_.getTinyId()})}}},{key:"doEnableTrack",value:function(a,s){var c=!1;return a===Ce?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=N(m().mark(function a(s){return m().wrap(function(c){for(;;)switch(c.prev=c.next){case 0:if(this.audioOutputDeviceId_=s,!this.audioPlayer_){c.next=4;break}return c.next=4,this.audioPlayer_.setSinkId(s);case 4:case"end":return c.stop()}},a,this)})),function(a){return t.apply(this,arguments)})},{key:"setAudioVolume",value:function(a){this.audioVolume_=a,this.log_.info("setAudioVolume to ".concat(a)),this.audioPlayer_&&this.audioPlayer_.setVolume(a)}},{key:"getAudioLevel",value:function(){var a=0;return this.audioPlayer_&&(a=this.audioPlayer_.getAudioLevel()),a}},{key:"getInternalAudioLevel",value:function(){var a=0;return this.audioPlayer_&&(a=this.audioPlayer_.getInternalAudioLevel()),a}},{key:"hasAudio",value:function(){if(this.isRemote_){if(!this.connection_)return!1;var a=this.connection_.getTrackState();return this.type_===gt&&a.audio}return!!this.getAudioTrack()}},{key:"hasVideo",value:function(){if(this.isRemote_){if(!this.connection_)return!1;var a=this.connection_.getTrackState();return this.type_===Pt?a.auxiliary:a.video}return!!this.getVideoTrack()}},{key:"getSubscribedState",value:function(){return this.isRemote_&&this.connection_?this.connection_.getSubscribeState():null}},{key:"getAudioTrack",value:function(){var a=null;if(this.mediaStream_){var s=this.mediaStream_.getAudioTracks();s.length>0&&(a=s[0])}return a}},{key:"getVideoTrack",value:function(){var a=null;if(this.mediaStream_){var s=this.mediaStream_.getVideoTracks();s.length>0&&(a=s[0])}return a}},{key:"getVideoFrame",value:function(){return this.videoPlayer_?this.videoPlayer_.getVideoFrame():null}},{key:"getMediaStream",value:function(){return this.mediaStream_}},{key:"setMediaStream",value:function(a){a!==this.mediaStream_&&(this.mediaStream_&&this.mediaStream_.getTracks().forEach(function(s){return s.stop()}),this.mediaStream_=a)}},{key:"updateVideoPlayingState",value:function(a){this.isPlaying_&&(a?(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(a){this.isPlaying_&&(a?(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(a,s,c){this.emitter_.on(a,s,c)}},{key:"off",value:function(a,s,c){a==="*"?this.emitter_.removeAllListeners():this.emitter_.off(a,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}(),q(Tc.prototype,"play",[dI],Object.getOwnPropertyDescriptor(Tc.prototype,"play"),Tc.prototype),Tc),Kv=function(e){Mt(n,e);var t=wr(n);function n(r){var i;z(this,n);var o={isRemote:!0,type:r.type},a=G(G({},r),o);return(i=t.call(this,a)).name_=rf,i.isStreamAddedEventEmitted_=!1,i.isAbleToCallSubscription_=!0,i}return ke(n,[{key:"installEvents",value:function(){ae($e(n.prototype),"installEvents",this).call(this),W.on(Nr,this.handleStreamSubscribed,this),W.on(Vr,this.handleStreamUnsubscribed,this)}},{key:"uninstallEvents",value:function(){ae($e(n.prototype),"uninstallEvents",this).call(this),W.off(Nr,this.handleStreamSubscribed,this),W.off(Vr,this.handleStreamUnsubscribed,this)}},{key:"handleStreamSubscribed",value:function(r){r.client===this.client_&&r.stream===this&&this.connection_.getCurrentState()===ln&&this.emitConnectionStateChanged({prevState:nn,state:ln})}},{key:"handleStreamUnsubscribed",value:function(r){r.client===this.client_&&r.stream===this&&this.emitConnectionStateChanged({prevState:ln,state:nn})}},{key:"getType",value:function(){return ae($e(n.prototype),"getType",this).call(this)}},{key:"getIsAbleToCallSubscription",value:function(){return this.isAbleToCallSubscription_}},{key:"setIsAbleToCallSubscription",value:function(r){this.isAbleToCallSubscription_=r}},{key:"setIsStreamAddedEventEmitted",value:function(r){this.isStreamAddedEventEmitted_=r}},{key:"getIsStreamAddedEventEmitted",value:function(){return this.isStreamAddedEventEmitted_}},{key:"getAudioTrack",value:function(){return this.connection_&&this.connection_.getTrackState().audio?ae($e(n.prototype),"getAudioTrack",this).call(this):null}},{key:"getVideoTrack",value:function(){if(!this.connection_)return null;var r=this.connection_.getTrackState();return(this.type_!==gt||r.video)&&(this.type_!==Pt||r.auxiliary)?ae($e(n.prototype),"getVideoTrack",this).call(this):null}},{key:"close",value:function(){ae($e(n.prototype),"close",this).call(this)}}]),n}(pI),yF=function(){function e(i){z(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,r;return ke(e,[{key:"isEnabled",get:function(){return this.client_.getEnv()!=="webrtc"}},{key:"recover",value:(r=N(m().mark(function i(o){var a,s,c;return m().wrap(function(u){for(;;)switch(u.prev=u.next){case 0:if(a=o.getUserId(),s=o.getType(),this.hasAutoRecoveryFlag(a,s)){u.next=5;break}return u.abrupt("return");case 5:if(c=this.getUnsubscribedStream(a,s)?"unsubscribe":"subscribe",u.prev=6,be.warn("recover() try to recover subscription [".concat(c,"][").concat(a,"][").concat(s,"]")),c!=="subscribe"){u.next=13;break}return u.next=11,this.recoverSubscription(a,o);case 11:u.next=15;break;case 13:return u.next=15,this.recoverUnsubscription(a,o);case 15:Ie.logSuccessEvent({userId:this.client_.getUserId(),eventType:LS}),be.warn("recover() recover successfully [".concat(c,"][").concat(a,"][").concat(s,"]")),u.next=23;break;case 19:u.prev=19,u.t0=u.catch(6),be.error("recover() recover failed [".concat(c,"][").concat(a,"][").concat(s,"]"),u.t0),Ie.logFailedEvent({userId:this.client_.getUserId(),eventType:LS,error:u.t0});case 23:this.deleteAutoRecoveryFlag(a,s);case 24:case"end":return u.stop()}},i,this,[[6,19]])})),function(i){return r.apply(this,arguments)})},{key:"recoverSubscription",value:(n=N(m().mark(function i(o,a){var s,c,u,d,p;return m().wrap(function(h){for(;;)switch(h.prev=h.next){case 0:if(s=this.getOptions(o,a.getType()),c=this.getSubscribedStream(o,a.getType()),s&&c){h.next=4;break}return h.abrupt("return");case 4:u=this.getStreamMuteState(c),d=u.isAudioMuted,p=u.isVideoMuted,this.mergeStream(c,a),this.recoverPlayingState(c),d&&c.doEnableTrack(Ce,!1),p&&c.doEnableTrack(xe,!1);case 9:case"end":return h.stop()}},i,this)})),function(i,o){return n.apply(this,arguments)})},{key:"recoverUnsubscription",value:(t=N(m().mark(function i(o,a){var s;return m().wrap(function(c){for(;;)switch(c.prev=c.next){case 0:if(s=this.getUnsubscribedStream(o,a.getType())){c.next=3;break}return c.abrupt("return");case 3:this.mergeStream(s,a);case 4:case"end":return c.stop()}},i,this)})),function(i,o){return t.apply(this,arguments)})},{key:"getStreamMuteState",value:function(i){var o={isAudioMuted:!1,isVideoMuted:!1},a=i.getMediaStream();return a&&(o.isAudioMuted=a.getAudioTracks().map(function(s){return s.enabled}).includes(!1),o.isVideoMuted=a.getVideoTracks().map(function(s){return s.enabled}).includes(!1)),o}},{key:"recoverPlayingState",value:function(i){var o=i.isPlaying(),a=i.getDiv();if(o&&a){var s=a.parentNode;i.stop(),i.play(s,{objectFit:i.getObjectFit(),muted:i.getMuted()})}}},{key:"mergeStream",value:function(i,o){var a=o.getConnection(),s=o.getMediaStream();i.setConnection(a),a.setRemoteStream(s.id,i),i.setMediaStream(s),i.updateAudioPlayingState(o.hasAudio()),i.updateVideoPlayingState(o.hasVideo())}},{key:"addSubscriptionRecord",value:function(i,o,a){var s=o.getType();if(this.subscribedStreams_.has(i))this.subscribedStreams_.get(i).set(s,o);else{var c=new Map;c.set(o.getType(),o),this.subscribedStreams_.set(i,c)}if(this.subscriptedOptions_.has(i))this.subscriptedOptions_.get(i).set(s,a);else{var u=new Map;u.set(o.getType(),a),this.subscriptedOptions_.set(i,u)}this.deleteUnsubscriptionRecord(i,s)}},{key:"addUnsubscriptionRecord",value:function(i,o){if(this.unsubscribedStreams_.has(i))this.unsubscribedStreams_.get(i).set(o.getType(),o);else{var a=new Map;a.set(o.getType(),o),this.unsubscribedStreams_.set(i,a)}this.deleteSubscriptionRecord(i,o.getType())}},{key:"getSubscribedStream",value:function(i,o){return this.subscribedStreams_.has(i)&&this.subscribedStreams_.get(i).has(o)?this.subscribedStreams_.get(i).get(o):null}},{key:"getOptions",value:function(i,o){return this.subscriptedOptions_.has(i)&&this.subscriptedOptions_.get(i).has(o)?this.subscriptedOptions_.get(i).get(o):null}},{key:"getUnsubscribedStream",value:function(i,o){return this.unsubscribedStreams_.has(i)&&this.unsubscribedStreams_.get(i).has(o)?this.unsubscribedStreams_.get(i).get(o):null}},{key:"deleteSubscriptionRecord",value:function(i,o){this.subscribedStreams_.has(i)&&this.subscribedStreams_.get(i).delete(o),this.subscriptedOptions_.has(i)&&this.subscriptedOptions_.get(i).delete(o)}},{key:"deleteUnsubscriptionRecord",value:function(i,o){this.unsubscribedStreams_.has(i)&&this.unsubscribedStreams_.get(i).delete(o)}},{key:"markAllStream",value:function(){for(var i=0,o=Se(this.subscribedStreams_.entries());i<o.length;i++)for(var a=Te(o[i],2),s=a[0],c=0,u=Se(a[1].entries());c<u.length;c++){var d=Te(u[c],1)[0];this.setAutoRecoveryFlag(s,d)}for(var p=0,h=Se(this.unsubscribedStreams_.entries());p<h.length;p++)for(var f=Te(h[p],2),_=f[0],y=0,S=Se(f[1].entries());y<S.length;y++){var E=Te(S[y],1)[0];this.setAutoRecoveryFlag(_,E)}}},{key:"setAutoRecoveryFlag",value:function(i,o){if(be.info("setAutoRecoveryFlag() mark [".concat(i,"][").concat(o,"]")),this.autoRecoveryFlags_.has(i))this.autoRecoveryFlags_.get(i).set(o);else{var a=new Map;a.set(o),this.autoRecoveryFlags_.set(i,a)}}},{key:"hasAutoRecoveryFlag",value:function(i,o){return!!this.isEnabled&&this.autoRecoveryFlags_.has(i)&&this.autoRecoveryFlags_.get(i).has(o)}},{key:"deleteAutoRecoveryFlag",value:function(i,o){this.autoRecoveryFlags_.has(i)&&this.autoRecoveryFlags_.get(i).delete(o)}},{key:"delete",value:function(i){this.unsubscribedStreams_.delete(i),this.subscribedStreams_.delete(i),this.subscriptedOptions_.delete(i),this.autoRecoveryFlags_.delete(i)}}]),e}(),bF=function(){function e(t){z(this,e),this.player_=t,this.canvas_=document.createElement(sS),this.canvasCtx_=this.canvas_.getContext("2d")}return ke(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,r=t.videoWidth,i=r*this.canvas_.height/(n*this.canvas_.width);if(i>1.05||i<.95){var o=r*n/(this.canvas_.width*this.canvas_.height);this.setCanvasRect(r/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}(),SF=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"}),kF=function(){function e(t){z(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 ke(e,[{key:"initWorker",value:function(){try{this.worker=new Worker(URL.createObjectURL(SF)),be.info("init worker processor success")}catch(t){be.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){z(this,e),this.localStream_=n,this.player_=null,this.processor_=null,this.initOffscreenSuccess_=!1}var t;return ke(e,[{key:"initialize",value:(t=N(m().mark(function n(){var r;return m().wrap(function(i){for(;;)switch(i.prev=i.next){case 0:if(!(l6()&&((r=navigator)===null||r===void 0?void 0:r.hardwareConcurrency)>=6)){i.next=13;break}return i.prev=1,i.next=4,this.initOffscreen();case 4:this.initOffscreenSuccess_=!0,be.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 r,i=n.height,o=n.width,a=n.frameRate,s=this.getSmallVideoProfile(o,i);return this.initOffscreenSuccess_?(this.processor_.setCanvasRect(s.width,s.height),r=this.processor_.generatorVideoTrack()):(this.processor_.setCanvasRect(s.width,s.height),this.player_.setRect({width:s.width,height:s.height}),r=this.processor_.generateVideoTrackFromCanvasCapture(a),this.interval_=_t.run(el,this.render.bind(this),{fps:a})),r}},{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 kF({videoTrack:this.localStream_.getVideoTrack()})}},{key:"initCanvas",value:function(){this.player_=new I1({stream:this.localStream_,track:this.localStream_.getVideoTrack(),muted:!0,objectFit:"cover",mirror:!1}),this.player_.play().then(function(){be.info("VideoGenerator: play local video success")}).catch(function(){be.error("VideoGenerator: Failed to play local video")}),this.processor_=new bF(this.player_)}},{key:"getSmallVideoProfile",value:function(n,r){var i,o=this.localStream_.getVideoTrack(),a=this.localStream_.getVideoProfile();if(ro){var s=o.getSettings();s&&s.width&&s.height&&(a.width=s.width,a.height=s.height)}var c=a.width*a.height,u=n*r;return be.info("big stream resolution: ".concat(a.width,"*").concat(a.height," small stream resolution: ").concat(n,"*").concat(r," ")),i=c>u?c/u:c/19200,{width:parseInt(a.width/Math.sqrt(i)),height:parseInt(a.height/Math.sqrt(i))}}}]),e}();function xc(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{retries:5,timeout:2e3};return function(t,n,r){var i=oc({retryFunction:r.value,settings:e,onError:e.onError,onRetrying:e.onRetrying,onRetryFailed:e.onRetryFailed});return r.value=function(){for(var o=arguments.length,a=new Array(o),s=0;s<o;s++)a[s]=arguments[s];return i.apply(this,a)},r}}var ed=new Map,TF=function(){var e=N(m().mark(function t(n){var r,i,o;return m().wrap(function(a){for(;;)switch(a.prev=a.next){case 0:if(!_l()){a.next=2;break}return a.abrupt("return");case 2:return a.next=4,xF(n);case 4:if(r=a.sent,be.info("getUserMedia with constraints: "+JSON.stringify(r)),!r.audio){a.next=11;break}return a.next=9,It.getMicrophones();case 9:i=a.sent,be.info("microphones: ".concat(JSON.stringify(i)));case 11:if(!r.video){a.next=16;break}return a.next=14,It.getCameras();case 14:o=a.sent,be.info("cameras: ".concat(JSON.stringify(o)));case 16:return a.prev=16,a.next=19,navigator.mediaDevices.getUserMedia(r);case 19:return a.abrupt("return",a.sent);case 22:if(a.prev=22,a.t0=a.catch(16),a.t0.name!=="NotFoundError"){a.next=29;break}if(!o||o.length!==0){a.next=27;break}throw new $({code:Q.DEVICE_NOT_FOUND,message:te({key:l4})});case 27:if(!i||i.length!==0){a.next=29;break}throw new $({code:Q.DEVICE_NOT_FOUND,message:te({key:u4})});case 29:throw new $({code:Q.INITIALIZE_FAILED,name:a.t0.name,message:a.t0.message,constraint:a.t0.constraint});case 30:case"end":return a.stop()}},t,null,[[16,22]])}));return function(t){return e.apply(this,arguments)}}(),Qv=oc({retryFunction:TF,settings:{retries:3,timeout:500},onError:function(e,t,n,r){be.warn("getUserMedia error: ".concat(e)),e.name==="NotReadableError"?t():e.message.includes("deviceId")&&r[0].retryWhenExactFailed?(r[0].useExact=!1,t()):n(e)},onRetrying:function(e){be.warn("getUserMedia retrying [".concat(e,"/3]"))}});function xF(e){return fI.apply(this,arguments)}function fI(){return(fI=N(m().mark(function e(t){var n,r,i,o,a,s;return m().wrap(function(c){for(;;)switch(c.prev=c.next){case 0:if(n={echoCancellation:t.echoCancellation,autoGainControl:t.autoGainControl,noiseSuppression:t.noiseSuppression},t.audio){c.next=5;break}n=!1,c.next=15;break;case 5:if($i(t.microphoneId)){c.next=9;break}n=G({deviceId:t.useExact?{exact:t.microphoneId}:t.microphoneId,sampleRate:t.sampleRate,channelCount:t.channelCount},n),c.next=15;break;case 9:return n=G({sampleRate:t.sampleRate,channelCount:t.channelCount},n),c.next=12,It.getMicrophones();case 12:r=c.sent,(i=r.filter(function(u){return u.deviceId.length>0})).length>0&&(n.deviceId={exact:i[0].deviceId});case 15:return o={},a={ideal:t.width,max:t.width},s={ideal:t.height,max:t.height},yr&&tc&&t.width*t.height<101376&&(a=t.width,s=t.height),o=!fe(t.facingMode)&&t.video?{facingMode:t.facingMode,width:a,height:s,frameRate:t.frameRate}:!$i(t.cameraId)&&t.video?{deviceId:t.useExact?{exact:t.cameraId}:t.cameraId,width:a,height:s,frameRate:t.frameRate}:!!t.video&&(!!fe(t.width)||{width:a,height:s,frameRate:t.frameRate}),c.abrupt("return",{audio:n,video:o});case 21:case"end":return c.stop()}},e)}))).apply(this,arguments)}var IF=function(){var e=N(m().mark(function t(n){var r,i,o,a,s,c,u,d,p;return m().wrap(function(h){for(;;)switch(h.prev=h.next){case 0:if(!_l()){h.next=2;break}return h.abrupt("return");case 2:if(r=null,!(sl&&Ef<74||Ji)){h.next=27;break}return i=Xv(n),be.info("getDisplayMedia with constraints: "+JSON.stringify(i)),h.next=8,navigator.mediaDevices.getDisplayMedia(i);case 8:if(o=h.sent,!n.screenAudio){h.next=14;break}return be.warn("Your browser not support capture system audio"),h.abrupt("return",o);case 14:if(!n.audio){h.next=24;break}return a=mI(n),be.info("getUserMedia with constraints: "+JSON.stringify(a)),h.next=19,navigator.mediaDevices.getUserMedia(a);case 19:return r=h.sent,o.addTrack(r.getAudioTracks()[0]),h.abrupt("return",o);case 24:return h.abrupt("return",o);case 25:h.next=53;break;case 27:if(!n.screenAudio){h.next=37;break}return n.audioConstraints={echoCancellation:!0,noiseSuppression:!0,sampleRate:44100},s=Xv(n),be.info("getDisplayMedia with constraints: "+JSON.stringify(s)),h.next=33,navigator.mediaDevices.getDisplayMedia(s);case 33:return c=h.sent,h.abrupt("return",c);case 37:return u=Xv(n),be.info("getDisplayMedia with constraints: "+JSON.stringify(u)),h.next=41,navigator.mediaDevices.getDisplayMedia(u);case 41:if(d=h.sent,!n.audio){h.next=52;break}return p=mI(n),be.info("getUserMedia with constraints: "+JSON.stringify(p)),h.next=47,navigator.mediaDevices.getUserMedia(p);case 47:return r=h.sent,d.addTrack(r.getAudioTracks()[0]),h.abrupt("return",d);case 52:return h.abrupt("return",d);case 53:case"end":return h.stop()}},t)}));return function(t){return e.apply(this,arguments)}}();function mI(e){var t={echoCancellation:e.echoCancellation,autoGainControl:e.autoGainControl,noiseSuppression:e.noiseSuppression,sampleRate:e.sampleRate,channelCount:e.channelCount};return fe(e.microphoneId)||(t.deviceId=e.microphoneId),{audio:t,video:!1}}function Xv(e){var t={systemAudio:"include",selfBrowserSurface:"include",surfaceSwitching:"include"},n={width:Ji?{max:e.width}:{ideal:e.width,max:e.width},height:Ji?{max:e.height}:{ideal:e.height,max:e.height},frameRate:e.frameRate,displaySurface:"monitor"};return t.video=n,fe(e.audioConstraints)||(t.audio=e.audioConstraints),t}var vI,gI,_I,yI,bI,SI,Ot,kI,Ic,Yv=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}]]),$v=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}]]),TI=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}]]),wF=(vI=Tn.apply(void 0,Se(Jt.LOCAL_STREAM.switchDevice)),gI=Tn(Jt.STREAM.addTrack),_I=Tn(Jt.STREAM.removeTrack),yI=Tn(Jt.STREAM.replaceTrack),bI=xc({retries:10,timeout:3e3,onRetryFailed:function(e){Ie.logFailedEvent({userId:this.client_?this.client_.getUserId():this.userId_,eventType:DS,error:e}),this.emitter_.emit(Dm,new $({code:Q.DEVICE_AUTO_RECOVER_FAILED,message:e.message}))}}),SI=$l(Jt.LOCAL_STREAM.setAudioCaptureVolume),Ot=function(e){Mt(p,e);var t,n,r,i,o,a,s,c,u,d=wr(p);function p(h){var f;z(this,p);var _=G(G({},h),{isRemote:!1,type:"local"});return(f=d.call(this,_)).name_=nf,f.client_=null,f.video_=h.video,f.audio_=h.audio,f.cameraId_=h.cameraId,f.cameraGroupId_="",f.facingMode_=h.facingMode,f.microphoneId_=h.microphoneId,f.microphoneGroupId_="",f.microphoneLabel_="",f.videoSource_=h.videoSource,f.audioSource_=h.audioSource,f.screen_=h.screen,f.screenAudio_=h.screenAudio,f.audioProfile_={echoCancellation:!!fe(h.echoCancellation)||h.echoCancellation,autoGainControl:!!fe(h.autoGainControl)||h.autoGainControl,noiseSuppression:!!fe(h.noiseSuppression)||h.noiseSuppression,sampleRate:48e3,channelCount:1,bitrate:40},f.videoProfile_=Yv.get("480p_2"),f.screenProfile_=$v.get("1080p"),f.videoSetting_=null,f.muteState_={video:!1,audio:!1,auxVideo:!1},f.beautyStatus_=!1,f.prevAudioRecoverTime_=0,f.prevVideoRecoverTime_=0,f.isAudioRecovering_=!1,f.isVideoRecovering_=!1,f.initState(),f.canvas_=null,f.canvasInterval_=null,f.canvasTrack_=null,f.gain_={audioTrack:null,source:null,gainNode:null},f.captureVolume_=100,f.enableAudoRecoverCapture_=!!fe(h.enableAudoRecoverCapture)||h.enableAudoRecoverCapture,f.log_.info("stream created: ".concat(f.id_," autoRecover: ").concat(f.enableAudoRecoverCapture_)),f}return ke(p,[{key:"initState",value:function(){this.isAddingTrack_=!1,this.isRemovingTrack_=!1,this.setIsReadyToPublish(!1),this.setPublishState(jS)}},{key:"installEvents",value:function(){ae($e(p.prototype),"installEvents",this).call(this),W.on(em,this.onVideoTrackStopped,this),W.on(ic,this.onVideoTrackStopped,this),W.on(nm,this.onAudioTrackStopped,this),W.on(tm,this.onAudioTrackStopped,this)}},{key:"uninstallEvents",value:function(){ae($e(p.prototype),"uninstallEvents",this).call(this),W.off(em,this.onVideoTrackStopped,this),W.off(ic,this.onVideoTrackStopped,this),W.off(nm,this.onAudioTrackStopped,this),W.off(tm,this.onAudioTrackStopped,this)}},{key:"initialize",value:function(){var h=this;return new Promise(function(f,_){if(yl())_(new $({code:Q.INVALID_OPERATION,message:te({key:sk})}));else{if(fe(h.audio_)){var y=new MediaStream;return fe(h.audioSource_)||(y.addTrack(h.audioSource_),h.updateAudioPlayingState(!0)),fe(h.videoSource_)||(y.addTrack(h.videoSource_),h.updateVideoPlayingState(!0)),h.setMediaStream(y),Ie.logSuccessEvent({userId:h.client_?h.client_.getUserId():h.userId_,eventType:$s,kind:"custom"}),h.setIsReadyToPublish(!0),f()}h.screen_?(h.log_.info("initialize stream audio: "+h.audio_+" screenAudio: "+h.screenAudio_+" screen: "+h.screen_),IF({audio:h.audio_,screenAudio:h.screenAudio_,microphoneId:h.microphoneId_,width:h.screenProfile_.width,height:h.screenProfile_.height,frameRate:h.screenProfile_.frameRate,sampleRate:h.audioProfile_.sampleRate,channelCount:h.audioProfile_.channelCount,autoGainControl:h.audioProfile_.autoGainControl,noiseSuppression:h.audioProfile_.noiseSuppression,echoCancellation:h.audioProfile_.echoCancellation}).then(function(S){h.setMediaStream(S),h.updateAudioPlayingState(h.audio_||h.screenAudio_),h.updateVideoPlayingState(!0);var E=h.getVideoTrack();return h.listenForScreenSharingStopped(E),h.setVideoContentHint(lS),h.updateDeviceIdInUse(),h.setIsReadyToPublish(!0),h.log_.info(JSON.stringify(E.getSettings())),Ie.logSuccessEvent({userId:h.client_?h.client_.getUserId():h.userId_,eventType:$s,kind:"getDisplayMedia"}),f()}).catch(function(S){Ie.logFailedEvent({userId:h.client_?h.client_.getUserId():h.userId_,eventType:$s,kind:"getDisplayMedia",error:S}),h.log_.error("getDisplayMedia error observed "+S),_(S instanceof $?S:new $({code:Q.INITIALIZE_FAILED,name:S.name,message:S.message}))})):(W.emit(qf,{stream:h,audio:h.audio_,video:h.video_}),h.log_.info("initialize stream audio: "+h.audio_+" video: "+h.video_),Qv({audio:h.audio_,video:h.video_,facingMode:h.facingMode_,cameraId:h.cameraId_,microphoneId:h.microphoneId_,width:h.videoProfile_.width,height:h.videoProfile_.height,frameRate:h.videoProfile_.frameRate,sampleRate:h.audioProfile_.sampleRate,channelCount:h.audioProfile_.channelCount,autoGainControl:h.audioProfile_.autoGainControl,noiseSuppression:h.audioProfile_.noiseSuppression,echoCancellation:h.audioProfile_.echoCancellation,useExact:!0,retryWhenExactFailed:!0}).then(function(S){return W.emit(Kf,{stream:h,audio:h.audio_,video:h.video_}),h.setMediaStream(S),S.getTracks().forEach(function(E){E.kind===xe&&ro&&(h.videoSetting_=E.getSettings()),u6&&h.log_.info("".concat(E.kind," capabilities: ").concat(JSON.stringify(E.getCapabilities())))}),h.updateAudioPlayingState(h.audio_),h.updateVideoPlayingState(h.video_),h.updateDeviceIdInUse(),h.log_.info("gotStream hasAudio: "+h.hasAudio()+" hasVideo: "+h.hasVideo()),h.setIsReadyToPublish(!0),Ie.logSuccessEvent({userId:h.client_?h.client_.getUserId():h.userId_,eventType:$s,kind:"getUserMedia"}),f()}).catch(function(S){W.emit(Qf,{stream:h,audio:h.audio_,video:h.video_,error:S}),Ie.logFailedEvent({userId:h.client_?h.client_.getUserId():h.userId_,eventType:$s,kind:"getUserMedia",error:S}),h.log_.error("getUserMedia error observed "+S),_(S)}))}})}},{key:"listenForScreenSharingStopped",value:function(h){var f=this;h.addEventListener("ended",function(_){f.log_.info("screen sharing was stopped because the video track is ended"),f.emitter_.emit(d6)})}},{key:"muteAudio",value:function(){var h=ae($e(p.prototype),"muteAudio",this).call(this);return h&&(this.log_.info("localStream mute audio"),this.sendMutedFlag(Ce,!0)),h}},{key:"muteVideo",value:function(){var h=ae($e(p.prototype),"muteVideo",this).call(this);return h&&(this.log_.info("localStream mute video"),this.sendMutedFlag(xe,!0)),h}},{key:"unmuteAudio",value:function(){var h=ae($e(p.prototype),"unmuteAudio",this).call(this);return h&&(this.log_.info("localStream unmute audio"),this.sendMutedFlag(Ce,!1)),h}},{key:"unmuteVideo",value:function(){var h=ae($e(p.prototype),"unmuteVideo",this).call(this);return h&&(this.log_.info("localStream unmute video"),this.sendMutedFlag(xe,!1)),h}},{key:"sendMutedFlag",value:function(h,f){this.setMuteState(h,f);var _=this.getConnection();if(_){_.sendMutedFlag(this.muteState_,this);var y=_.getUserId(),S=_.getTinyId(),E="".concat(f?$t:fr," local ").concat(h," track");dn(y,{eventId:h===Ce?f?iU:oU:f?aU:sU,eventDesc:E,timestamp:tn(),userId:y,tinyId:S})}}},{key:"setMuteState",value:function(h,f){this.muteState_[h]=f,this.log_.info("set ".concat(h," muted state: [").concat(f?"mute":"unmute","]"))}},{key:"setAudioProfile",value:function(h){var f;V(h)==="object"?f=h:(f=TI.get(h))===void 0&&(f=TI.get("standard")),this.log_.info("setAudioProfile: "+JSON.stringify(f)),this.audioProfile_=G(G({},this.audioProfile_),f)}},{key:"setVideoProfile",value:(u=N(m().mark(function h(f){var _,y,S,E;return m().wrap(function(R){for(;;)switch(R.prev=R.next){case 0:if(!this.connection_||DT()){R.next=2;break}throw new $({code:Q.NOT_SUPPORTED,message:te({key:a4})});case 2:if(Qi(f)?y=G(G({},this.videoProfile_),f):Ft(f)&&(y=Yv.get(f),fe(y)&&(y=Yv.get("480p_2"))),(_=this.client_)!==null&&_!==void 0&&_.get2k4kFlag()&&this.client_.get2k4kFlag()!==1&&!this.screen_&&y.height*y.width>=3686400&&(y.width=1920,y.height=1080,this.log_.warn(QS)),y&&y.width*y.height>921600&&J4&&(y.width=1280,y.height=720,this.log_.warn("reset to 1280 * 720 on iOS 13~14")),this.log_.info("setVideoProfile "+JSON.stringify(y)),!(S=this.getVideoTrack())){R.next=10;break}return R.next=10,S.applyConstraints(y);case 10:if(E=this.videoProfile_.bitrate!==y.bitrate,this.videoProfile_=y,!E||!this.connection_){R.next=16;break}return R.next=15,this.connection_.setBandwidth({bandwidth:y.bitrate,type:xe,videoType:Hu});case 15:this.connection_.sendMediaSettings(this);case 16:case"end":return R.stop()}},h,this)})),function(h){return u.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(h){var f=h;Ft(h)&&(f=$v.get(h)||$v.get("1080p")),this.log_.info("setScreenProfile "+JSON.stringify(h)),this.screenProfile_=f}},{key:"getVideoProfile",value:function(){return this.screen_?this.screenProfile_:this.videoProfile_}},{key:"getAudioProfile",value:function(){return this.audioProfile_}},{key:"setVideoContentHint",value:function(h){var f=this.getVideoTrack();f&&"contentHint"in f&&(this.log_.info("set video track contentHint to: "+h),f.contentHint=h,f.contentHint!==h&&this.log_.warn("Invalid video track contentHint: "+h))}},{key:"switchDevice",value:(c=N(m().mark(function h(f,_){var y,S,E,R,H,Y,ue,le,O,k,P,A,U,T,g,I,w,L;return m().wrap(function(B){for(;;)switch(B.prev=B.next){case 0:if(this.mediaStream_&&this.cameraId_!==_&&this.facingMode_!==_){B.next=2;break}return B.abrupt("return");case 2:if(S=f===xe,!(y=f===Ce)||_!==this.microphoneId_){B.next=11;break}if(_===$u){B.next=7;break}return B.abrupt("return");case 7:return B.next=9,y6(this.microphoneGroupId_,this.microphoneLabel_);case 9:if(!B.sent){B.next=11;break}return B.abrupt("return");case 11:return this.setIsReadyToPublish(!1),this.log_.info("switchDevice "+f+" to: "+_),y&&(E=this.getAudioTrack(),R=this.getMicrophoneTrackMixed(),E&&E.stop(),R&&R.stop()),S&&((H=this.getVideoTrack())&&H.stop(),If&&(Y=this.getAudioTrack())&&(this.log_.info("stop audio track first in huawei env"),Y.stop())),B.prev=15,B.next=18,Qv({audio:y||If,video:S,facingMode:_===cS||_===uS?_:void 0,cameraId:S?_:this.cameraId_,microphoneId: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(ue=B.sent,le=null,!y){B.next=25;break}(O=ue.getAudioTracks()[0])&&this.isAudioTrackMixed()?(k=this.getAudioTrack(),P=It.AudioMixerPlugin.getAudioTrackMap(),A=It.AudioMixerPlugin.mix({targetTrack:O,sourceList:P.get(k.id).sourceList,trackList:P.get(k.id).trackList}),le=A):le=O,B.next=34;break;case 25:if(!(le=ue.getVideoTracks()[0])||!this.isVideoTrackBeautified()){B.next=30;break}return B.next=29,this.generateBeautyTrack(le);case 29:le=B.sent;case 30:if(!(U=ue.getAudioTracks()[0])||!If){B.next=34;break}return B.next=34,this.replaceTrack(U);case 34:return B.next=36,this.replaceTrack(le);case 36:this.updateDeviceIdInUse(),(T=this.getConnection())&&(g=T.getUserId(),I=T.getTinyId(),w=uU,L="switch camera",y&&(w=lU,L="switch microphone"),dn(g,{eventId:w,eventDesc:L,timestamp:tn(),userId:g,tinyId:I})),this.log_.info("switch ".concat(y?"microphone":"camera"," success ")),y&&(this.audio_=!0),S&&(this.video_=!0,_!==uS&&_!==cS||(this.facingMode_=_)),this.setIsReadyToPublish(!0),B.next=50;break;case 45:throw B.prev=45,B.t0=B.catch(15),this.log_.error(B.t0),y?this.recoverCapture({audio:!0,video:!1,microphoneId:this.microphoneId_}):this.recoverCapture({audio:!1,video:!0,cameraId:this.cameraId_,facingMode:this.facingMode_}),B.t0;case 50:case"end":return B.stop()}},h,this,[[15,45]])})),function(h,f){return c.apply(this,arguments)})},{key:"addTrack",value:(s=N(m().mark(function h(f){var _,y,S;return m().wrap(function(E){for(;;)switch(E.prev=E.next){case 0:if(E.prev=0,f.kind===xe&&ro&&(_=f.getSettings(),!this.videoSetting_||_.width===this.videoSetting_.width&&_.height===this.videoSetting_.height||this.log_.warn("video resolution of the track (".concat(_.width," x ").concat(_.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(f),this.mediaStream_.addTrack(f),!(y=this.getConnection())){E.next=11;break}return S=null,f.kind===xe&&(ul||cl)&&Pk(f)&&(S=this.getCanvasTrack()),E.next=11,y.addTrack(S||f,this);case 11:f.kind===Ce?(this.audio_=!0,this.updateAudioPlayingState(!0),this.captureVolume_!==100&&this.setAudioCaptureVolume(this.captureVolume_)):(this.video_=!0,this.updateVideoPlayingState(!0)),this.isAddingTrack_=!1,E.next=20;break;case 15:throw E.prev=15,E.t0=E.catch(0),this.mediaStream_.removeTrack(f),this.isAddingTrack_=!1,E.t0;case 20:case"end":return E.stop()}},h,this,[[0,15]])})),function(h){return s.apply(this,arguments)})},{key:"removeTrack",value:(a=N(m().mark(function h(f){var _;return m().wrap(function(y){for(;;)switch(y.prev=y.next){case 0:if(y.prev=0,this.isRemovingTrack_=!0,!(_=this.getConnection())){y.next=17;break}if(f.kind!==xe||!ul&&!cl||!this.canvasTrack_){y.next=10;break}return y.next=7,_.removeTrack(this.canvasTrack_,this);case 7:this.clearCanvas(),y.next=17;break;case 10:if(f.kind!==Ce||!this.gain_.audioTrack){y.next=15;break}return y.next=13,_.removeTrack(this.gain_.audioTrack,this);case 13:y.next=17;break;case 15:return y.next=17,_.removeTrack(f,this);case 17:this.mediaStream_.removeTrack(f),f.kind===Ce?(this.audio_=!1,this.updateAudioPlayingState(!1),this.stopGainNode()):(this.video_=!1,this.updateVideoPlayingState(!1)),this.isRemovingTrack_=!1,y.next=26;break;case 22:throw y.prev=22,y.t0=y.catch(0),this.isRemovingTrack_=!1,y.t0;case 26:case"end":return y.stop()}},h,this,[[0,22]])})),function(h){return a.apply(this,arguments)})},{key:"replaceTrack",value:(o=N(m().mark(function h(f){var _,y,S;return m().wrap(function(E){for(;;)switch(E.prev=E.next){case 0:if(f.kind===xe&&ro&&(_=f.getSettings(),!this.videoSetting_||_.width===this.videoSetting_.width&&_.height===this.videoSetting_.height||this.log_.warn("video resolution of the track (".concat(_.width," x ").concat(_.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(f),y=this.mediaStream_,f.kind!==Ce){E.next=12;break}if(y.removeTrack(y.getAudioTracks()[0]),y.addTrack(f),ae($e(p.prototype),"restartAudio",this).call(this),!this.gain_.gainNode){E.next=10;break}return this.reconnectGainNode(f),E.abrupt("return");case 10:E.next=15;break;case 12:y.removeTrack(y.getVideoTracks()[0]),y.addTrack(f),ae($e(p.prototype),"restartVideo",this).call(this);case 15:if(!(S=this.getConnection())){E.next=21;break}if(f.kind!==xe||!ul&&!cl||!this.canvasTrack_){E.next=19;break}return E.abrupt("return");case 19:return E.next=21,S.replaceTrack(f,this);case 21:case"end":return E.stop()}},h,this)})),function(h){return o.apply(this,arguments)})},{key:"recoverCapture",value:(i=N(m().mark(function h(f){var _,y,S,E,R,H,Y,ue,le,O,k,P,A,U,T,g,I;return m().wrap(function(w){for(;;)switch(w.prev=w.next){case 0:if(!(!this.mediaStream_||!this.enableAudoRecoverCapture_||f.audio&&!f.video&&this.isAudioRecovering_||f.video&&!f.audio&&this.isVideoRecovering_)){w.next=2;break}return w.abrupt("return");case 2:return f.audio&&(this.isAudioRecovering_=!0),f.video&&(this.isVideoRecovering_=!0),this.log_.warn("recoverCapture() trying "+JSON.stringify(f)),_=this.audio_&&f.audio,y=this.video_&&f.video,w.prev=7,w.next=10,It.getCameras();case 10:return S=w.sent,w.next=13,It.getMicrophones();case 13:if(E=w.sent,y&&S.length===0&&(y=!1,this.log_.warn("recoverCapture() video flag is true, but no camera detected, set video to false")),_&&E.length===0&&(_=!1,this.log_.warn("recoverCapture() audio flag is true, but no microphone detected, set audio to false")),_||y){w.next=19;break}return this.log_.warn("recoverCapture() both audio and video are false, aborted"),w.abrupt("return");case 19:return R=f&&S.findIndex(function(L){return L.deviceId===f.cameraId})>=0,H=f&&E.findIndex(function(L){return L.deviceId===f.microphoneId})>=0,_&&((Y=this.getAudioTrack())===null||Y===void 0||Y.stop()),y&&((ue=this.getVideoTrack())===null||ue===void 0||ue.stop()),w.next=25,Qv({audio:_,video:y,cameraId:R?f.cameraId:void 0,microphoneId:H?f.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 25:le=w.sent,O=le.getTracks(),k=0;case 28:if(!(k<O.length)){w.next=55;break}if((P=O[k]).kind!==Ce||!this.isAudioTrackMixed()){w.next=41;break}if(A=this.getAudioTrack(),U=It.AudioMixerPlugin.getAudioTrackMap(),(T=U.get(A.id)).hasMicrophone){w.next=37;break}return P.stop(),w.abrupt("continue",52);case 37:return g=It.AudioMixerPlugin.mix({targetTrack:P,sourceList:T.sourceList,trackList:T.trackList}),w.next=40,this.replaceTrack(g);case 40:return w.abrupt("continue",52);case 41:if(P.kind!==xe||!this.isVideoTrackBeautified()){w.next=48;break}return w.next=44,this.generateBeautyTrack(P);case 44:return I=w.sent,w.next=47,this.replaceTrack(I);case 47:return w.abrupt("continue",52);case 48:return w.next=50,this.replaceTrack(P);case 50:if(P.readyState!=="ended"){w.next=52;break}throw new Error("new track is failed, muted ".concat(P.muted," readyState ").concat(P.readyState));case 52:k++,w.next=28;break;case 55:this.updateDeviceIdInUse(),Ie.logSuccessEvent({userId:this.client_?this.client_.getUserId():this.userId_,eventType:DS}),f.audio&&(this.isAudioRecovering_=!1),f.video&&(this.isVideoRecovering_=!1),this.log_.warn("recoverCapture() successfully"),this.emitter_.emit(p6,{isCamera:f.video,isMicrophone:f.audio,cameraId:this.cameraId_,microphoneId:this.microphoneId_}),w.next=69;break;case 63:throw w.prev=63,w.t0=w.catch(7),f.audio&&(this.isAudioRecovering_=!1),f.video&&(this.isVideoRecovering_=!1),this.log_.warn("recoverCapture() failed, "+w.t0),w.t0;case 69:case"end":return w.stop()}},h,this,[[7,63]])})),function(h){return i.apply(this,arguments)})},{key:"updateDeviceIdInUse",value:function(){var h=this;if(!this.mediaStream_)return this.cameraId_="",this.cameraGroupId_="",this.microphoneId_="",void(this.microphoneGroupId_="");ro&&this.mediaStream_.getTracks().forEach(function(y){if(y.kind===Ce&&h.isAudioTrackMixed()){var S=h.getMicrophoneTrackMixed();if(S){var E=S.getSettings(),R=E.deviceId,H=E.groupId;R&&(h.microphoneId_=R,h.microphoneGroupId_=H,h.microphoneLabel_=S.label)}}else if(y.kind===xe&&h.isVideoTrackBeautified()){var Y=h.getBeautyOriginTrack();if(Y){var ue=Y.getSettings(),le=ue.deviceId,O=ue.groupId;le&&(h.cameraId_=le,h.cameraGroupId_=O)}}else{var k=y.getSettings(),P=k.deviceId,A=k.groupId;P&&(y.kind===Ce?(h.microphoneId_=P,h.microphoneGroupId_=A,h.microphoneLabel_=y.label):y.kind!==xe||h.screen_||(h.cameraId_=P,h.cameraGroupId_=A))}});var f=this.mediaStream_.getAudioTracks(),_=this.mediaStream_.getVideoTracks();f&&f.length===0&&(this.microphoneId_="",this.microphoneGroupId_=""),_&&_.length===0&&(this.cameraId_="",this.cameraGroupId_="")}},{key:"isAudioTrackMixed",value:function(){if(It.AudioMixerPlugin){var h=It.AudioMixerPlugin.getAudioTrackMap(),f=this.getAudioTrack();if(h&&f&&h.has(f.id))return!0}return!1}},{key:"getMicrophoneTrackMixed",value:function(){if(It.AudioMixerPlugin){var h=It.AudioMixerPlugin.getAudioTrackMap(),f=this.getAudioTrack();if(h&&f&&h.has(f.id)){var _=h.get(f.id);return _.hasMicrophone?_.microphoneTrack:null}}return null}},{key:"isVideoTrackBeautified",value:function(){if(It.beautyTrackMap){var h=It.beautyTrackMap,f=this.getVideoTrack();if(f&&h.has(f.id))return!0}return!1}},{key:"getBeautyOriginTrack",value:function(){if(It.beautyTrackMap){var h=It.beautyTrackMap,f=this.getVideoTrack();if(f&&h.has(f.id)){var _=h.get(f.id);if(_.originTrack)return _.originTrack}}return null}},{key:"generateBeautyTrack",value:(r=N(m().mark(function h(f){var _,y,S,E;return m().wrap(function(R){for(;;)switch(R.prev=R.next){case 0:if(_=null,y=this.getVideoTrack(),S=It.beautyTrackMap.get(y.id),E=S.param,S.type){R.next=8;break}_=S.pluginInstance.generateBeautyTrack(f),R.next=22;break;case 8:R.t0=S.type,R.next=R.t0==="beauty"?11:R.t0==="virtual"?13:R.t0==="mixed"?17:21;break;case 11:return _=S.pluginInstance.generateBeautyTrack(f),R.abrupt("break",22);case 13:return R.next=15,S.pluginInstance.generateVirtualTrack({videoTrack:f,type:E.type,img:E.img});case 15:case 19:return _=R.sent,R.abrupt("break",22);case 17:return R.next=19,S.pluginInstance.generateMixedTrack({videoTrack:f,type:E.type,img:E.img});case 21:return R.abrupt("break",22);case 22:return S.pluginInstance.deleteSource(y.id),this.log_.info("regenerate beauty track, track id = ".concat(f.id)),R.abrupt("return",_);case 25:case"end":return R.stop()}},h,this)})),function(h){return r.apply(this,arguments)})},{key:"getScreen",value:function(){return this.screen_}},{key:"hasScreenTrack",value:function(){if(this.screen_)return!0;var h=this.getVideoTrack();return!!h&&(h.contentHint===lS||h.contentHint===YM)}},{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(h){this.isReadyToPublish_=h}},{key:"setPublishState",value:function(h){this.publishState_=h}},{key:"setBeautyStatus",value:function(h){this.beautyStatus_=!!h}},{key:"getBeautyStatus",value:function(){return this.beautyStatus_}},{key:"syncMuteState",value:function(){var h=this.getAudioTrack(),f=this.getVideoTrack();if(h){var _=!h.enabled;this.setMuteState(Ce,_)}if(f){var y=!f.enabled;this.setMuteState(xe,y)}this.connection_&&this.connection_.sendMutedFlag(this.muteState_,this)}},{key:"keepMuteState",value:function(h){h instanceof MediaStreamTrack&&this.muteState_[h.kind]&&(h.enabled=!1,this.log_.warn("prev ".concat(h.kind," track is muted, keep mute state")))}},{key:"onVideoTrackStopped",value:(n=N(m().mark(function h(f){var _,y,S=this;return m().wrap(function(E){for(;;)switch(E.prev=E.next){case 0:if(_=f.stream,y=f.type,_===this&&this.video_&&this.cameraId_&&_6(this.getVideoTrack())&&!this.isVideoRecovering_&&(!(tc&&Ji||Lr&&Number(Mr)>=15.1)||y!==$t)){E.next=3;break}return E.abrupt("return");case 3:if(!(Date.now()-this.prevVideoRecoverTime_<Zu)){E.next=6;break}return setTimeout(function(){return S.onVideoTrackStopped({stream:_,type:y})},Zu),E.abrupt("return");case 6:y===$t?setTimeout(function(){var R=S.getVideoTrack();R!=null&&R.muted&&document.visibilityState==="visible"&&S.recoverVideoCapture(y)},5e3):this.recoverVideoCapture(y);case 7:case"end":return E.stop()}},h,this)})),function(h){return n.apply(this,arguments)})},{key:"onAudioTrackStopped",value:(t=N(m().mark(function h(f){var _,y,S=this;return m().wrap(function(E){for(;;)switch(E.prev=E.next){case 0:if(_=f.stream,y=f.type,_===this&&this.audio_&&this.microphoneId_&&!this.isAudioRecovering_&&(!(tc&&Ji||Lr&&Number(Mr)>=15.1)||y!==$t)){E.next=3;break}return E.abrupt("return");case 3:if(!(Date.now()-this.prevAudioRecoverTime_<Zu)){E.next=6;break}return setTimeout(function(){return S.onAudioTrackStopped({stream:_,type:y})},Zu),E.abrupt("return");case 6:y===$t?setTimeout(function(){var R=S.getAudioTrack();R!=null&&R.muted&&document.visibilityState==="visible"&&S.recoverAudioCapture(y)},5e3):this.recoverAudioCapture(y);case 7:case"end":return E.stop()}},h,this)})),function(h){return t.apply(this,arguments)})},{key:"recoverAudioCapture",value:function(h){this.prevAudioRecoverTime_=Date.now(),Ie.uploadEvent({log:"stat-local-audio-".concat(h),userId:this.userId_}),this.recoverCapture({audio:!0,video:!1,microphoneId:this.microphoneId_})}},{key:"recoverVideoCapture",value:function(h){this.prevVideoRecoverTime_=Date.now(),Ie.uploadEvent({log:"stat-local-video-".concat(h),userId:this.userId_}),this.recoverCapture({audio:!1,video:!0,cameraId:this.cameraId_})}},{key:"setAudioVolume",value:function(h){ae($e(p.prototype),"setAudioVolume",this).call(this,h)}},{key:"clearCanvas",value:function(){this.canvasInterval_&&(_t.clearTask(this.canvasInterval_),this.canvasInterval_=null,this.canvas_=null,this.canvasTrack_=null)}},{key:"getCanvasTrack",value:function(){var h=this;if(this.canvasTrack_)return this.canvasTrack_;this.log_.info("gen canvas track");var f=this.getVideoTrack().getSettings(),_=f.width,y=f.height,S=f.frameRate;this.canvas_=document.createElement("canvas");var E=this.canvas_.getContext("2d");this.canvas_.width=_,this.canvas_.height=y,this.canvasInterval_=_t.run(el,function(){if(h.hasVideo()){var H=h.getVideoTrack().getSettings();H.width===h.canvas_.width&&H.height===h.canvas_.height||(h.canvas_.width=H.width,h.canvas_.height=H.height)}h.videoPlayer_&&h.videoPlayer_.element_&&E.drawImage(h.videoPlayer_.element_,0,0,h.canvas_.width,h.canvas_.height)},{fps:Math.max(15,S)});var R=this.canvas_.captureStream();return this.canvasTrack_=R.getVideoTracks()[0],this.canvasTrack_}},{key:"setClient",value:function(h,f){h&&(this.log_.setUserId(h.getUserId()),this.log_.setSdkAppId(h.getSDKAppId()),f||this.syncMuteState()),this.client_=h}},{key:"setAudioCaptureVolume",value:function(){var h=this,f=arguments.length>0&&arguments[0]!==void 0?arguments[0]:100;if(!this.hasAudio()||f<0||!Cm())return!1;if(this.captureVolume_===f)return!0;this.captureVolume_=f,this.log_.info("setCaptureVolume "+f),f/=100;var _=Mk();if(this.gain_.gainNode)this.gain_.gainNode.gain.value=f;else{var y,S=new MediaStream;S.addTrack(this.getAudioTrack());var E=_.createMediaStreamDestination(),R=_.createMediaStreamSource(S),H=_.createGain();H.gain.value=f,R.connect(H),H.connect(E);var Y=E.stream.getAudioTracks()[0],ue=function(le){return h.log_.info("gained audio track ".concat(le))};Y.onmute=function(){return ue("muted")},Y.onunmute=function(){return ue("unmuted")},Y.onended=function(){return ue("ended")},this.gain_={source:R,audioTrack:Y,gainNode:H},(y=this.connection_)===null||y===void 0||y.replaceTrack(Y),ae($e(p.prototype),"restartAudio",this).call(this)}return!0}},{key:"getGainedTrack",value:function(){return this.gain_.audioTrack}},{key:"reconnectGainNode",value:function(h){this.log_.warn("reconnect gain node");var f=new MediaStream;f.addTrack(h);var _=Mk().createMediaStreamSource(f);_.connect(this.gain_.gainNode),this.gain_.source.disconnect(),this.gain_.source=_}},{key:"stopGainNode",value:function(){var h=this.gain_,f=h.audioTrack,_=h.source,y=h.gainNode;y&&(_.disconnect(),y.disconnect(),f.onmute=null,f.onunmute=null,f.onended=null,f.stop(),this.gain_={source:null,gainNode:null,audioTrack:null}),this.captureVolume_=100}},{key:"close",value:function(){this.setIsReadyToPublish(!1),this.stopGainNode(),ae($e(p.prototype),"close",this).call(this)}}]),p}(pI),q(Ot.prototype,"switchDevice",[vI],Object.getOwnPropertyDescriptor(Ot.prototype,"switchDevice"),Ot.prototype),q(Ot.prototype,"addTrack",[gI],Object.getOwnPropertyDescriptor(Ot.prototype,"addTrack"),Ot.prototype),q(Ot.prototype,"removeTrack",[_I],Object.getOwnPropertyDescriptor(Ot.prototype,"removeTrack"),Ot.prototype),q(Ot.prototype,"replaceTrack",[yI],Object.getOwnPropertyDescriptor(Ot.prototype,"replaceTrack"),Ot.prototype),q(Ot.prototype,"recoverCapture",[bI],Object.getOwnPropertyDescriptor(Ot.prototype,"recoverCapture"),Ot.prototype),q(Ot.prototype,"setAudioCaptureVolume",[SI],Object.getOwnPropertyDescriptor(Ot.prototype,"setAudioCaptureVolume"),Ot.prototype),Ot),xI={voiceActivityDetection:!1},EF=(kI=xc({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)}}),Ic=function(e){Mt(le,e);var t,n,r,i,o,a,s,c,u,d,p,h,f,_,y,S,E,R,H,Y,ue=wr(le);function le(O){var k;return z(this,le),(k=ue.call(this,O)).localStream_=null,k.exchangeSDPTimeout_=-1,k.localAuxStream_=null,k.publishingStream_=null,k.isPublishingAuxStream_=!1,k.smallGenerator_=null,k.isSDPExchanging_=!1,k.ssrc_={audio:0,video:0,small:0,auxiliary:0},k.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},k.mixedAudioTrack_=null,k}return ke(le,[{key:"isMainStreamPublished",get:function(){return!!this.localStream_}},{key:"isAuxStreamPublished",get:function(){return!!this.localAuxStream_}},{key:"publishState",get:function(){var O=this,k={audio:!1,bigVideo:!1,smallVideo:!1,auxVideo:!1};if(this.peerConnection_){var P,A,U,T,g=this.peerConnection_.getSenders();g&&(fi()?(k.audio=!((P=g[0])===null||P===void 0||!P.track),k.bigVideo=!((A=g[1])===null||A===void 0||!A.track),k.smallVideo=!((U=g[2])===null||U===void 0||!U.track),k.auxVideo=!((T=g[3])===null||T===void 0||!T.track)):g.forEach(function(I){I.track&&(I.track.kind===Ce?k.audio=!0:(k.bigVideo=!0,O.smallGenerator_&&(k.smallVideo=!0)))}))}return k}},{key:"initialize",value:function(){ae($e(le.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(){ae($e(le.prototype),"close",this).call(this),this.reset(),this.emitConnectionStateChangedEvent(nn),this.smallGenerator_&&(this.smallGenerator_.destroy(),this.smallGenerator_=null)}},{key:"installEvents",value:function(){this.emitter_.on(rt.ERROR,this.handleError,this),this.emitter_.on(rt.CONNECTION_STATE_CHANGED,this.handleConnectionStateChange,this)}},{key:"uninstallEvents",value:function(){this.emitter_.off(rt.ERROR,this.handleError,this),this.emitter_.off(rt.CONNECTION_STATE_CHANGED,this.handleConnectionStateChange,this)}},{key:"publish",value:(Y=N(m().mark(function O(k,P){var A,U,T,g,I,w;return m().wrap(function(L){for(;;)switch(L.prev=L.next){case 0:if(this.publishingStream_=k,this.isPublishingAuxStream_=P,T=k.getVideoTrack(),g=null,!T||P||!this.client_.getIsEnableSmallStream()){L.next=9;break}return this.smallGenerator_=new Zl(k),L.next=8,this.smallGenerator_.initialize();case 8:g=this.smallGenerator_.generateSmallVideoTrack(this.client_.smallStreamConfig_);case 9:if((A=this.client_)===null||A===void 0||!A.get2k4kFlag()){L.next=18;break}if(I=this.client_.get2k4kFlag()===1,w=k.getVideoProfile(),I||k.getScreen()||!(w.height*w.width>=3686400)){L.next=18;break}return w.width=1920,w.height=1080,this.log_.warn(QS),L.next=18,k.setVideoProfile(w);case 18:if(this.updateMediaSettings(k,P),!Em()){L.next=24;break}return L.next=22,this.publishByTransceiver(k,g,P);case 22:L.next=26;break;case 24:return L.next=26,this.publishByAddTrack(k,g);case 26:return this.publishingStream_=null,this.isPublishingAuxStream_=!1,P?this.localAuxStream_=k:this.localStream_=k,(U=this.sei_)===null||U===void 0||U.handleEncodedStreams(),L.abrupt("return",k);case 31:case"end":return L.stop()}},O,this)})),function(O,k){return Y.apply(this,arguments)})},{key:"publishByTransceiver",value:(H=N(m().mark(function O(k,P,A){var U,T,g,I,w,L,B;return m().wrap(function(ee){for(;;)switch(ee.prev=ee.next){case 0:if(this.log_.info("publish by transceiver"),U=k.getMediaStream(),T=k.getAudioTrack(),g=k.getVideoTrack(),I=null,(ul||cl)&&Pk(g)&&(I=k.getCanvasTrack()),(w=this.peerConnection_.getTransceivers()).length!==0){ee.next=16;break}return this.peerConnection_.addTransceiver(T||Ce,{direction:li,streams:[U]}),this.peerConnection_.addTransceiver(A?xe:I||g||xe,{direction:li,streams:[U]}),this.peerConnection_.addTransceiver(P||xe,{direction:li,streams:[U]}),this.peerConnection_.addTransceiver(A?I||g:xe,{direction:li,streams:[U]}),ee.next=14,this.connect();case 14:ee.next=46;break;case 16:if(L=[],!T){ee.next=29;break}if(!w[0].sender.track){ee.next=24;break}return this.mixAudioTrack(w[0].sender.track,T),ee.next=22,w[0].sender.replaceTrack(this.mixedAudioTrack_);case 22:ee.next=27;break;case 24:return ee.next=26,w[0].sender.replaceTrack(T);case 26:L.push(0);case 27:return ee.next=29,this.setBandwidth({bandwidth:k.getAudioBitrate(),type:Ce});case 29:if(!g){ee.next=42;break}return B=A?3:1,ee.next=33,w[B].sender.replaceTrack(I||g);case 33:return ee.next=35,this.setBandwidth({bandwidth:k.getVideoBitrate(),type:xe,videoType:A?pt:Hu});case 35:if(L.push(B),!P){ee.next=42;break}return ee.next=39,w[2].sender.replaceTrack(P);case 39:return ee.next=41,this.setBandwidth({bandwidth:this.client_.smallStreamConfig.bitrate,type:xe,videoType:Dr});case 41:L.push(2);case 42:return ee.next=44,this.setTransceiverDirection(li,L);case 44:return ee.next=46,this.doPublishChange();case 46:case"end":return ee.stop()}},O,this)})),function(O,k,P){return H.apply(this,arguments)})},{key:"publishByAddTrack",value:(R=N(m().mark(function O(k,P){var A,U,T,g;return m().wrap(function(I){for(;;)switch(I.prev=I.next){case 0:return this.log_.info("publish by addtrack"),A=k.getMediaStream(),U=k.getAudioTrack(),T=k.getVideoTrack(),U&&this.peerConnection_.addTrack(U,A),T&&(this.peerConnection_.addTrack(T,A),P&&((g=new MediaStream).addTrack(P),this.peerConnection_.addTrack(P,g))),I.next=8,this.connect();case 8:case"end":return I.stop()}},O,this)})),function(O,k){return R.apply(this,arguments)})},{key:"unpublish",value:(E=N(m().mark(function O(k){var P,A,U,T;return m().wrap(function(g){for(;;)switch(g.prev=g.next){case 0:if(fi()){g.next=2;break}return g.abrupt("return",this.doUnpublish());case 2:if(P=k.getAudioTrack(),A=k===this.localAuxStream_,U=this.peerConnection_.getSenders(),T=[],!P){g.next=17;break}if(!this.mixedAudioTrack_){g.next=14;break}return this.log_.info("has mixed audioTrack, use another audioTrack"),g.next=11,U[0].replaceTrack(A?this.localStream_.getAudioTrack():this.localAuxStream_.getAudioTrack());case 11:this.destroyMixedAudioTrack(),g.next=17;break;case 14:return g.next=16,U[0].replaceTrack(null);case 16:T.push(0);case 17:if(!A){g.next=25;break}return g.next=20,U[3].replaceTrack(null);case 20:this.localAuxStream_=null,this.mediaSettings_=G(G({},this.mediaSettings_),{},{auxVideoBps:0,auxVideoFps:0,auxVideoWidth:0,auxVideoHeight:0}),T.push(3),g.next=32;break;case 25:return g.next=27,U[1].replaceTrack(null);case 27:return g.next=29,U[2].replaceTrack(null);case 29:this.localStream_=null,this.mediaSettings_=G(G({},this.mediaSettings_),{},{videoWidth:0,videoHeight:0,videoBps:0,videoFps:0,audioFs:0,audioChannel:0,audioBps:0,smallVideoWidth:0,smallVideoHeight:0,smallVideoFps:0,smallVideoBps:0}),T.push(1,2);case 32:if(!this.localStream_&&!this.localAuxStream_){g.next=39;break}return g.next=35,this.setTransceiverDirection(Ha,T);case 35:return g.next=37,this.doPublishChange();case 37:g.next=41;break;case 39:return g.next=41,this.doUnpublish();case 41:case"end":return g.stop()}},O,this)})),function(O){return E.apply(this,arguments)})},{key:"doPublishChange",value:(S=N(m().mark(function O(){var k;return m().wrap(function(P){for(;;)switch(P.prev=P.next){case 0:return k={state:this.publishState,constraintConfig:this.mediaSettings_},P.next=3,this.signalChannel_.sendWaitForResponse({command:jV,data:k,responseCommand:ft.PUBLISH_STATE_CHANGE_RESULT});case 3:case"end":return P.stop()}},O,this)})),function(){return S.apply(this,arguments)})},{key:"doUnpublish",value:function(){var O=this;return this.signalChannel_.sendWaitForResponse({command:uT,commandDesc:"unpublish",responseCommand:ft.UNPUBLISH_RESULT}).then(function(){O.close()}).catch(function(){O.close()})}},{key:"updateMediaSettings",value:function(O,k){var P=this;this.localAuxStream_&&O===this.localAuxStream_&&(k=!0);var A=this.client_.getSystemResult().detail,U=A.isH264EncodeSupported,T=A.isVp8EncodeSupported;U?this.mediaSettings_.videoCodec="H264":T&&(this.mediaSettings_.videoCodec="VP8"),ro?O.getMediaStream().getTracks().forEach(function(g){var I=g.getSettings();if(g.kind===Ce){var w=1;I.channelCount&&(w=I.channelCount),P.mediaSettings_.audioChannel=w,P.mediaSettings_.audioBps=1e3*O.getAudioBitrate(),P.mediaSettings_.audioFs=I.sampleRate}else if(g.kind===xe){if(k)return P.mediaSettings_.auxVideoWidth=I.width,P.mediaSettings_.auxVideoHeight=I.height,P.mediaSettings_.auxVideoFps=I.frameRate,void(P.mediaSettings_.auxVideoBps=1e3*O.getVideoBitrate());P.client_.getIsEnableSmallStream()&&(P.mediaSettings_.smallVideoWidth=P.client_.smallStreamConfig.width,P.mediaSettings_.smallVideoHeight=P.client_.smallStreamConfig.height,P.mediaSettings_.smallVideoFps=P.client_.smallStreamConfig.frameRate,P.mediaSettings_.smallVideoBps=1e3*P.client_.smallStreamConfig.bitrate),P.mediaSettings_.videoWidth=I.width,P.mediaSettings_.videoHeight=I.height,P.mediaSettings_.videoFps=I.frameRate,P.mediaSettings_.videoBps=1e3*O.getVideoBitrate()}}):this.updateMediaSettingsFromProfile(O),this.log_.info("updateMediaSettings: "+JSON.stringify(this.mediaSettings_))}},{key:"updateMediaSettingsFromProfile",value:function(O){if(O){if(O.hasAudio()){var k=O.getAudioProfile();this.mediaSettings_.audioChannel=k.channelCount,this.mediaSettings_.audioBps=1e3*k.bitrate,this.mediaSettings_.audioFs=k.sampleRate}if(O.hasVideo()){var P=O.getVideoProfile();this.mediaSettings_.videoWidth=P.width,this.mediaSettings_.videoHeight=P.height,this.mediaSettings_.videoFps=P.frameRate,this.mediaSettings_.videoBps=1e3*P.bitrate}}}},{key:"sendMediaSettings",value:function(O){var k=this;this.updateMediaSettings(O),this.signalChannel_.sendWaitForResponse({command:rU,data:this.mediaSettings_,responseCommand:ft.UPDATE_CONSTRAINT_CONFIG_RES}).then(function(P){P.data.code!==0&&k.log_.warn(P.data.message)}).catch(this.log_.warn)}},{key:"addTrack",value:(y=N(m().mark(function O(k,P){var A,U;return m().wrap(function(T){for(;;)switch(T.prev=T.next){case 0:if(this.peerConnection_){T.next=2;break}return T.abrupt("return");case 2:if(U=P===this.localAuxStream_,this.log_.info("is adding ".concat(k.kind," track to current published local ").concat(U?pt:Ye," stream")),(A=this.sei_)===null||A===void 0||A.handleEncodedStreams(),!fi()){T.next=10;break}return T.next=8,this.addTrackByTransceiver(k,P);case 8:T.next=12;break;case 10:return T.next=12,this.addTrackBySender(k);case 12:dn(this.userId_,{eventId:k.kind===Ce?dT:lT,eventDesc:"add ".concat(k.kind," track to current published stream"),timestamp:tn(),userId:this.userId_,tinyId:this.tinyId_});case 13:case"end":return T.stop()}},O,this)})),function(O,k){return y.apply(this,arguments)})},{key:"addTrackByTransceiver",value:(_=N(m().mark(function O(k,P){var A,U,T,g;return m().wrap(function(I){for(;;)switch(I.prev=I.next){case 0:if(A=P===this.localAuxStream_,U=this.peerConnection_.getTransceivers(),k.kind!==Ce){I.next=13;break}if(!U[0].sender.track){I.next=9;break}return this.mixAudioTrack(U[0].sender.track,k),I.next=7,U[0].sender.replaceTrack(this.mixedAudioTrack_);case 7:I.next=11;break;case 9:return I.next=11,U[0].sender.replaceTrack(k);case 11:I.next=26;break;case 13:return T=A?3:1,I.next=16,U[T].sender.replaceTrack(k);case 16:if(T!==1||!this.client_.getIsEnableSmallStream()){I.next=23;break}return this.smallGenerator_=new Zl(this.localStream_),I.next=20,this.smallGenerator_.initialize();case 20:return g=this.smallGenerator_.generateSmallVideoTrack(this.client_.smallStreamConfig_),I.next=23,U[2].sender.replaceTrack(g);case 23:if(U[T].direction!==Ha){I.next=26;break}return I.next=26,this.setTransceiverDirection(li,[T]);case 26:return this.updateMediaSettings(P,A),I.next=29,this.doPublishChange();case 29:case"end":return I.stop()}},O,this)})),function(O,k){return _.apply(this,arguments)})},{key:"addTrackBySender",value:(f=N(m().mark(function O(k){var P,A,U,T,g;return m().wrap(function(I){for(;;)switch(I.prev=I.next){case 0:if(!(fi()&&this.peerConnection_.getTransceivers().findIndex(function(w){return w.direction==="stopped"})>=0)){I.next=4;break}return this.log_.warn("transceiver is stopping, negotiate sdp first"),I.next=4,this.updateOffer(an.REMOVE,k);case 4:if(!(P=this.peerConnection_.getSenders().find(function(w){return w.track&&w.track.kind===k.kind}))){I.next=11;break}return this.log_.warn("sender already exists, remove sender first"),A=P.track,this.removeSender(P),I.next=11,this.updateOffer(an.REMOVE,A);case 11:if(U=this.localStream_.getMediaStream(),this.peerConnection_.addTrack(k,U),k.kind!==xe||!this.client_.getIsEnableSmallStream()){I.next=21;break}return this.smallGenerator_=new Zl(this.localStream_),I.next=17,this.smallGenerator_.initialize();case 17:T=this.smallGenerator_.generateSmallVideoTrack(this.client_.smallStreamConfig_),(g=new MediaStream).addTrack(T),this.peerConnection_.addTrack(T,g);case 21:return I.next=23,this.updateOffer(an.ADD,k);case 23:case"end":return I.stop()}},O,this)})),function(O){return f.apply(this,arguments)})},{key:"isNeedToResetOfferOrder",value:function(){if(this.sdpSemantics_===Zp||!this.peerConnection_||!this.peerConnection_.localDescription)return!1;for(var O=this.peerConnection_.localDescription.sdp,k=Br(O),P=0;P<k.media.length;P++)if(k.media[P].mid===0&&k.media[P].type===xe)return!0;return!1}},{key:"removeSender",value:function(O){var k=null;fi()&&(k=this.peerConnection_.getTransceivers().find(function(P){return P.sender&&P.sender.track===O.track})),this.peerConnection_.removeTrack(O),k&&kn(k.stop)&&(this.log_.info("stop transceiver"),k.stop())}},{key:"removeTrack",value:(h=N(m().mark(function O(k,P){return m().wrap(function(A){for(;;)switch(A.prev=A.next){case 0:if(this.peerConnection_){A.next=2;break}return A.abrupt("return");case 2:if(this.log_.info("is removing ".concat(k.kind," track from current published local ").concat(P===this.localAuxStream_?pt:Ye," stream")),!fi()){A.next=8;break}return A.next=6,this.removeTrackByTransceiver(k,P);case 6:A.next=10;break;case 8:return A.next=10,this.removeTrackBySender(k);case 10:dn(this.userId_,{eventId:k.kind===Ce?pT:hT,eventDesc:"remove ".concat(k.kind," track from current published stream"),timestamp:tn(),userId:this.userId_,tinyId:this.tinyId_});case 11:case"end":return A.stop()}},O,this)})),function(O,k){return h.apply(this,arguments)})},{key:"removeTrackByTransceiver",value:(p=N(m().mark(function O(k,P){var A,U,T;return m().wrap(function(g){for(;;)switch(g.prev=g.next){case 0:if(A=P===this.localAuxStream_,U=this.peerConnection_.getTransceivers(),k.kind!==Ce){g.next=13;break}if(!this.mixedAudioTrack_){g.next=9;break}return g.next=6,U[0].sender.replaceTrack(A?this.localStream_.getAudioTrack():this.localAuxStream_.getAudioTrack());case 6:this.destroyMixedAudioTrack(),g.next=11;break;case 9:return g.next=11,U[0].sender.replaceTrack(null);case 11:g.next=23;break;case 13:return T=A?3:1,g.next=16,U[T].sender.replaceTrack(null);case 16:if(T!==1||!this.smallGenerator_){g.next=21;break}return this.smallGenerator_.destroy(),this.smallGenerator_=null,g.next=21,U[2].sender.replaceTrack(null);case 21:return g.next=23,this.setTransceiverDirection(Ha,[T]);case 23:return this.updateMediaSettings(P,A),g.next=26,this.doPublishChange();case 26:case"end":return g.stop()}},O,this)})),function(O,k){return p.apply(this,arguments)})},{key:"setTransceiverDirection",value:(d=N(m().mark(function O(k,P){var A,U,T,g,I,w;return m().wrap(function(L){for(;;)switch(L.prev=L.next){case 0:if(yr){L.next=2;break}return L.abrupt("return");case 2:if(A=!1,U=!1,this.log_.info("setting transceiver ".concat(P.join(",")," direction to ").concat(k)),T=this.peerConnection_.getTransceivers(),P.forEach(function(B){T[B].direction!==k&&(T[B].direction=k,A=!0)}),!A){L.next=14;break}return this.log_.info("updating offer"),L.next=11,this.peerConnection_.createOffer();case 11:return g=L.sent,L.next=14,this.peerConnection_.setLocalDescription(g);case 14:if(I=-1,w=this.peerConnection_.remoteDescription.sdp.split(`\r
99
+ `).map(function(B){if(B.match(new RegExp("a=(".concat(Ha,"|").concat(Wp,"|").concat(li,")")))&&I++,P.includes(I)){if(k===Ha&&B.includes("a=".concat(Wp)))return U=!0,"a=".concat(k);if(k===li&&B.includes("a=".concat(Ha)))return U=!0,"a=".concat(Wp)}return B}).join(`\r
100
+ `),!U){L.next=20;break}return this.log_.info("updating answer"),L.next=20,this.peerConnection_.setRemoteDescription({type:"answer",sdp:w});case 20:case"end":return L.stop()}},O,this)})),function(O,k){return d.apply(this,arguments)})},{key:"removeTrackBySender",value:(u=N(m().mark(function O(k){var P,A,U=this;return m().wrap(function(T){for(;;)switch(T.prev=T.next){case 0:if(k.kind!==xe||!this.isNeedToResetOfferOrder()){T.next=7;break}return this.reset(),this.initialize(),(P=this.localStream_.getMediaStream())===null||P===void 0||P.removeTrack(k),T.next=6,this.publish(this.localStream_);case 6:return T.abrupt("return");case 7:return(A=this.peerConnection_.getSenders().find(function(g){return g.track===k}))&&(this.removeSender(A),k.kind===xe&&this.smallGenerator_&&(this.smallGenerator_.destroy(),this.smallGenerator_=null,this.peerConnection_.getSenders().forEach(function(g){g.track&&g.track.kind===xe&&U.removeSender(g)}))),T.next=11,this.updateOffer(an.REMOVE,k);case 11:case"end":return T.stop()}},O,this)})),function(O){return u.apply(this,arguments)})},{key:"replaceTrack",value:(c=N(m().mark(function O(k,P){var A,U,T,g,I,w,L;return m().wrap(function(B){for(;;)switch(B.prev=B.next){case 0:if((U=(A=this.peerConnection_)===null||A===void 0?void 0:A.getSenders())&&U.length!==0){B.next=3;break}throw new $({code:Q.INVALID_OPERATION,message:te({key:ak})});case 3:if(T=P===this.localAuxStream_,this.log_.info("is replacing ".concat(k.kind," track to current published local ").concat(T?pt:Ye," stream")),k.kind!==Ce||!U[0]){B.next=16;break}if(!(this.mixedAudioTrack_&&(g=this.localStream_)!==null&&g!==void 0&&g.hasAudio()&&(I=this.localAuxStream_)!==null&&I!==void 0&&I.hasAudio())){B.next=14;break}return this.destroyMixedAudioTrack(),w=T?this.localStream_.getAudioTrack():this.localAuxStream_.getAudioTrack(),this.mixAudioTrack(k,w),B.next=12,U[0].replaceTrack(this.mixedAudioTrack_);case 12:B.next=16;break;case 14:return B.next=16,U[0].replaceTrack(k);case 16:if(k.kind!==xe){B.next=32;break}if(P!==this.localStream_||!U[1]){B.next=29;break}return B.next=20,U[1].replaceTrack(k);case 20:if(!this.smallGenerator_||!U[2]){B.next=29;break}return this.log_.info("replacing smallVideo"),this.smallGenerator_.destroy(),this.smallGenerator_=new Zl(this.localStream_),B.next=26,this.smallGenerator_.initialize();case 26:return L=this.smallGenerator_.generateSmallVideoTrack(this.client_.smallStreamConfig_),B.next=29,U[2].replaceTrack(L);case 29:if(P!==this.localAuxStream_||!U[3]){B.next=32;break}return B.next=32,U[3].replaceTrack(k);case 32:dn(this.userId_,{eventId:k.kind===Ce?hU:dU,eventDesc:"replace ".concat(k.kind," track from current published stream"),timestamp:tn(),userId:this.userId_,tinyId:this.tinyId_});case 33:case"end":return B.stop()}},O,this)})),function(O,k){return c.apply(this,arguments)})},{key:"updateOffer",value:(s=N(m().mark(function O(k,P){var A,U,T,g,I,w,L;return m().wrap(function(B){for(;;)switch(B.prev=B.next){case 0:return B.prev=0,B.next=3,this.peerConnection_.createOffer(xI);case 3:return A=B.sent,yr&&(A.sdp=this.setSDPDirection(A.sdp,"sendrecv")),B.next=7,this.peerConnection_.setLocalDescription(A);case 7:return U=this.updateMediaSettings(this.localStream_||this.localAuxStream_),T={action:k,trackId:P.id,kind:P.kind===xe?"bigVideo":P.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: "+T.sdp),B.next=13,this.signalChannel_.sendWaitForResponse({command:BV,data:T,responseCommand:ft.UPDATE_OFFER_RESULT,timeout:1e4,commandDesc:"update offer"});case 13:return g=B.sent,I=g.data,w=I.code,L=I.message,w!==0&&this.checkPublishResultCode(w,L),B.next=18,this.acceptAnswer(g.data.data);case 18:this.updateSSRC(A.sdp),Ie.logSuccessEvent({userId:this.client_.getUserId(),eventType:Xu,kind:"offer"}),B.next=27;break;case 22:throw B.prev=22,B.t0=B.catch(0),this.log_.error(B.t0),Ie.logFailedEvent({userId:this.client_.getUserId(),eventType:Xu,kind:"offer",error:B.t0}),B.t0;case 27:case"end":return B.stop()}},O,this,[[0,22]])})),function(O,k){return s.apply(this,arguments)})},{key:"setBandwidth",value:(a=N(m().mark(function O(k){var P,A,U,T,g,I,w,L;return m().wrap(function(B){for(;;)switch(B.prev=B.next){case 0:if(P=k.bandwidth,A=k.type,U=k.videoType,T=U===void 0?"":U,g=k.sdp,DT()||!g){B.next=3;break}return B.abrupt("return",A===xe?this.updateVideoBandwidthRestriction(g,P,T):this.updateAudioBandwidthRestriction(g,P));case 3:if(I=0,A===xe&&(I=T===Dr?2:T===pt?3:1),!(w=this.peerConnection_.getSenders()[I])){B.next=22;break}return(L=w.getParameters()).encodings&&L.encodings.length!==0||(L.encodings=[{}]),P==="unlimited"?delete L.encodings[0].maxBitrate:L.encodings[0].maxBitrate=1e3*P,B.prev=10,B.next=13,w.setParameters(L);case 13:return this.log_.info(T+A+" bandwidth was set to "+P+" kbps"),B.abrupt("return",g);case 17:if(B.prev=17,B.t0=B.catch(10),this.log_.info("failed to set bandwidth by setting maxBitrate: "+B.t0),!g){B.next=22;break}return B.abrupt("return",A===xe?this.updateVideoBandwidthRestriction(g,P,T):this.updateAudioBandwidthRestriction(g,P));case 22:return B.abrupt("return",g);case 23:case"end":return B.stop()}},O,this,[[10,17]])})),function(O){return a.apply(this,arguments)})},{key:"updateVideoBandwidthRestriction",value:function(O,k,P){var A="AS";yr&&(A="TIAS",k*=1e3);var U=0,T=-1;return P===Dr?U=1:P===pt&&(U=2),O=O.replace(/m=video (.*)\r\nc=IN (.*)\r\n/g,function(g){return++T===U?"".concat(g,"b=").concat(A,":").concat(k,`\r
101
+ `):g}),O}},{key:"updateAudioBandwidthRestriction",value:function(O,k){var P="AS";return yr&&(P="TIAS",k*=1e3),O=O.replace(/m=audio (.*)\r\nc=IN (.*)\r\n/,`m=audio $1\r
102
+ c=IN $2\r
103
+ b=`+P+":"+k+`\r
104
+ `)}},{key:"removeBandwidthRestriction",value:function(O){return O.replace(/b=AS:.*\r\n/,"").replace(/b=TIAS:.*\r\n/,"")}},{key:"removeVideoOrientation",value:function(O){return O.replace(/urn:3gpp:video-orientation/,"")}},{key:"connect",value:(o=N(m().mark(function O(){return m().wrap(function(k){for(;;)switch(k.prev=k.next){case 0:return k.prev=0,k.next=3,this.exchangeSDP();case 3:return k.next=5,this.waitForPeerConnectionConnected();case 5:k.next=11;break;case 7:throw k.prev=7,k.t0=k.catch(0),this.closePeerConnection(!0),k.t0;case 11:case"end":return k.stop()}},O,this,[[0,7]])})),function(){return o.apply(this,arguments)})},{key:"exchangeSDP",value:(i=N(m().mark(function O(){return m().wrap(function(k){for(;;)switch(k.prev=k.next){case 0:return k.prev=0,this.isSDPExchanging_=!0,k.next=4,this.createOffer();case 4:return this.log_.info("createOffer success, sending offer to remote server"),k.next=7,this.doExchangeSDP();case 7:this.isSDPExchanging_=!1,k.next=14;break;case 10:throw k.prev=10,k.t0=k.catch(0),this.isSDPExchanging_=!1,k.t0;case 14:case"end":return k.stop()}},O,this,[[0,10]])})),function(){return i.apply(this,arguments)})},{key:"createOffer",value:(r=N(m().mark(function O(){var k;return m().wrap(function(P){for(;;)switch(P.prev=P.next){case 0:return P.prev=0,P.next=3,this.peerConnection_.createOffer(xI);case 3:return k=P.sent,P.next=6,this.peerConnection_.setLocalDescription(k);case 6:this.updateSSRC(k.sdp),Ie.logSuccessEvent({userId:this.client_.getUserId(),eventType:Xu,kind:"offer"}),P.next=14;break;case 10:throw P.prev=10,P.t0=P.catch(0),Ie.logFailedEvent({userId:this.client_.getUserId(),eventType:Xu,kind:"offer",error:P.t0}),P.t0;case 14:case"end":return P.stop()}},O,this,[[0,10]])})),function(){return r.apply(this,arguments)})},{key:"doExchangeSDP",value:function(){var O=this;return new Promise(function(k,P){O.exchangeSDPTimeout_=setTimeout(function(){O.signalChannel_.off(ft.PUBLISH_RESULT,A),O.clearExchangeSDPTimeout();var T=new $({code:Q.API_CALL_TIMEOUT,message:te({key:JN})});P(T)},1e4);var A=function(){var T=N(m().mark(function g(I){var w,L,B;return m().wrap(function(ee){for(;;)switch(ee.prev=ee.next){case 0:if(ee.prev=0,O.clearExchangeSDPTimeout(),w=I.data,L=w.code,B=w.message,L!==0){ee.next=9;break}return ee.next=6,O.acceptAnswer(I.data.data);case 6:k(),ee.next=10;break;case 9:O.checkPublishResultCode(L,B);case 10:ee.next=15;break;case 12:ee.prev=12,ee.t0=ee.catch(0),P(ee.t0);case 15:case"end":return ee.stop()}},g,null,[[0,12]])}));return function(g){return T.apply(this,arguments)}}(),U={type:O.peerConnection_.localDescription.type,sdp:O.removeVideoOrientation(O.peerConnection_.localDescription.sdp),screen:(O.publishingStream_||O.localStream_).hasScreenTrack(),state:O.publishState,constraintConfig:O.mediaSettings_};O.signalChannel_.once(ft.PUBLISH_RESULT,A),O.log_.debug("sending sdp offer: "+U.sdp),O.signalChannel_.send(WV,U)})}},{key:"setSDPDirection",value:function(O,k){var P=arguments.length>2&&arguments[2]!==void 0?arguments[2]:"all",A=Br(O);return A.media.forEach(function(U){P!=="all"&&U.type!==P||(U.direction=k)}),Za(A)}},{key:"acceptAnswer",value:(n=N(m().mark(function O(k){var P,A,U,T,g,I,w;return m().wrap(function(L){for(;;)switch(L.prev=L.next){case 0:if(L.prev=0,P=this.removeVideoOrientation(k.sdp),!(A=this.publishingStream_||this.localStream_)){L.next=15;break}if(U=A.getVideoBitrate(),T=A.getAudioBitrate(),!U){L.next=11;break}return g=this.isPublishingAuxStream_?pt:Hu,L.next=10,this.setBandwidth({bandwidth:U,type:xe,sdp:P,videoType:g});case 10:P=L.sent;case 11:if(!T){L.next=15;break}return L.next=14,this.setBandwidth({bandwidth:T,type:Ce,sdp:P});case 14:P=L.sent;case 15:if(!this.client_.getIsEnableSmallStream()){L.next=20;break}return I=this.client_.smallStreamConfig,L.next=19,this.setBandwidth({bandwidth:I.bitrate,type:xe,videoType:Dr,sdp:P});case 19:P=L.sent;case 20:return w={type:k.type,sdp:P},L.next=23,this.peerConnection_.setRemoteDescription(w);case 23:this.log_.debug("accepted answer: "+P),Ie.logSuccessEvent({userId:this.client_.getUserId(),eventType:RS,kind:"answer"}),L.next=32;break;case 27:throw L.prev=27,L.t0=L.catch(0),Ie.logFailedEvent({userId:this.client_.getUserId(),eventType:RS,kind:"answer",error:L.t0}),this.log_.error("failed to accept remote answer "+L.t0),L.t0;case 32:case"end":return L.stop()}},O,this,[[0,27]])})),function(O){return n.apply(this,arguments)})},{key:"sendMutedFlag",value:function(O,k){if(k!==this.localAuxStream_){var P={audio:O.audio,bigVideo:O.video,auxVideo:O.auxVideo};this.log_.info("send muted state: ".concat(JSON.stringify(P))),this.signalChannel_.send(zV,P)}}},{key:"getIsReconnecting",value:function(){return this.isReconnecting_}},{key:"reconnect",value:(t=N(m().mark(function O(){var k,P,A=this;return m().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(),k=new $({code:Q.UPLINK_RECONNECTION_FAILED,message:te({key:QN})}),Ie.logFailedEvent({userId:this.client_.getUserId(),eventType:wS,error:k}),this.addEventInternal(CU,"uplink-connection reconnect fail"),this.emitConnectionStateChangedEvent(nn),this.emitter_.emit(rt.ERROR,k),U.abrupt("return");case 12:if(this.signalChannel_.getCurrentState()===cc){U.next=16;break}return this.log_.warn("reconnect() signal channel is not connected, suspend reconnection until signal is connected"),this.signalChannel_.once(sc,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,"]")),P=Pf(this.reconnectionCount_),this.reconnectionTimer_=setTimeout(function(){A.log_.warn("reconnect() uplink reconnect timeout(".concat(P/1e3,"s), try again")),A.clearReconnectionTimer(),A.reconnect()},P),!(this.isSDPExchanging_||this.peerConnection_&&this.peerConnection_.connectionState===Qu)){U.next=23;break}return U.abrupt("return");case 23:return U.next=25,this.signalChannel_.sendWaitForResponse({command:uT,responseCommand:ft.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:Ie.logSuccessEvent({userId:this.client_.getUserId(),eventType:wS}),this.log_.warn("reconnect() uplink reconnect successfully"),this.addEventInternal(EU,"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()}},O,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(O){O.getCode()===Q.ICE_TRANSPORT_ERROR&&(this.isFirstConnection_&&(this.isFirstConnection_=!1,Ie.logFailedEvent({userId:this.client_.getUserId(),eventType:IS,error:O})),this.isReconnecting_||this.startReconnection())}},{key:"handleConnectionStateChange",value:function(O){O.state===ln&&this.isFirstConnection_&&(this.isFirstConnection_=!1,Ie.logSuccessEvent({userId:this.client_.getUserId(),eventType:IS}),this.addEventInternal(SU,"uplink-connection is connected"))}},{key:"updateSSRC",value:function(O){var k=this;try{Br(O).media.forEach(function(P,A){if(P.type===Ce){var U=P.ssrcs[0];U&&(k.ssrc_.audio=U.id)}else{if(k.sdpSemantics_===Zp)return void P.ssrcGroups.forEach(function(g,I){var w=Number(g.ssrcs.split(" ")[0]);I===0?k.ssrc_.video=w:I===1&&(k.ssrc_.small=w)});var T=P.ssrcs[0];if(!T)return;switch(A){case 1:k.ssrc_.video=T.id;break;case 2:k.ssrc_.small=T.id;break;case 3:k.ssrc_.auxiliary=T.id}}})}catch(P){}}},{key:"getVideoTrackId",value:function(){var O=arguments.length>0&&arguments[0]!==void 0?arguments[0]:xe;if(this.peerConnection_){var k=this.peerConnection_.getSenders();if(O===xe&&k[1]&&k[1].track)return k[1].track.id;if(O===Dr&&k[2]&&k[2].track)return k[2].track.id;if(O===pt&&k[3]&&k[3].track)return k[3].track.id}if(this.localStream_&&O===xe){var P=this.localStream_.getVideoTrack();if(P)return P.id}if(this.localAuxStream_&&O===pt){var A=this.localAuxStream_.getVideoTrack();if(A)return A.id}return""}},{key:"getSSRC",value:function(){return this.ssrc_}},{key:"checkPublishResultCode",value:function(O,k){if(O!==0)throw O===1028?(this.log_.error(di.NOT_SUPPORTED_H264ENCODE),new $({code:Q.NOT_SUPPORTED_H264,message:te({key:uk})})):new $({code:Q.UNKNOWN,message:te({key:dk,data:{signalResponse:ft.PUBLISH_RESULT,code:O,message:k}})})}},{key:"getLocalStream",value:function(){return this.localStream_}},{key:"sendSEI",value:function(O,k){this.sei_.push(O,k)}},{key:"mixAudioTrack",value:function(O,k){this.log_.info("mix audio track"),this.mixedAudioTrack_=function(P){var A=Ok(),U=A.createMediaStreamDestination(),T=[];P.forEach(function(I){var w=new MediaStream;w.addTrack(I);var L=A.createMediaStreamSource(w);L.connect(U),T.push(L)});var g=U.stream.getAudioTracks()[0];return ed.set(g,{destination:U,track:g,mediaStreamSourceList:T}),g}([O,k])}},{key:"destroyMixedAudioTrack",value:function(){this.mixedAudioTrack_&&(this.log_.info("destroy audio track"),function(O){if(ed.has(O)){var k=ed.get(O),P=k.destination,A=k.track,U=k.mediaStreamSourceList;A.stop(),P.disconnect(),U.forEach(function(T){T.disconnect()}),ed.delete(O)}}(this.mixedAudioTrack_),this.mixedAudioTrack_=null)}}]),le}(Jv),q(Ic.prototype,"publish",[kI],Object.getOwnPropertyDescriptor(Ic.prototype,"publish"),Ic.prototype),Ic),CF=ce,II=Es,td=ks.exports.getWeakData,RF=dt,Zv=yt,AF=ti,PF=ws,wI=kt,DF=Qe.set,LF=Qe.getterFor,OF=en.find,MF=en.findIndex,NF=CF([].splice),VF=0,nd=function(e){return e.frozen||(e.frozen=new EI)},EI=function(){this.entries=[]},eg=function(e,t){return OF(e.entries,function(n){return n[0]===t})};EI.prototype={get:function(e){var t=eg(this,e);if(t)return t[1]},has:function(e){return!!eg(this,e)},set:function(e,t){var n=eg(this,e);n?n[1]=t:this.entries.push([e,t])},delete:function(e){var t=MF(this.entries,function(n){return n[0]===e});return~t&&NF(this.entries,t,1),!!~t}};var wc,UF={getConstructor:function(e,t,n,r){var i=e(function(c,u){AF(c,o),DF(c,{type:t,id:VF++,frozen:void 0}),u!=null&&PF(u,c[r],{that:c,AS_ENTRIES:n})}),o=i.prototype,a=LF(t),s=function(c,u,d){var p=a(c),h=td(RF(u),!0);return h===!0?nd(p).set(u,d):h[p.id]=d,c};return II(o,{delete:function(c){var u=a(this);if(!Zv(c))return!1;var d=td(c);return d===!0?nd(u).delete(c):d&&wI(d,u.id)&&delete d[u.id]},has:function(c){var u=a(this);if(!Zv(c))return!1;var d=td(c);return d===!0?nd(u).has(c):d&&wI(d,u.id)}}),II(o,n?{get:function(c){var u=a(this);if(Zv(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}},CI=Z,rd=ce,BF=Es,jF=ks.exports,FF=Sh,RI=UF,id=yt,ad=W_,od=Qe.enforce,GF=Li,HF=!CI.ActiveXObject&&"ActiveXObject"in CI,AI=function(e){return function(){return e(this,arguments.length?arguments[0]:void 0)}},zF=FF("WeakMap",AI,RI);if(GF&&HF){wc=RI.getConstructor(AI,"WeakMap",!0),jF.enable();var Ec=zF.prototype,PI=rd(Ec.delete),sd=rd(Ec.has),DI=rd(Ec.get),LI=rd(Ec.set);BF(Ec,{delete:function(e){if(id(e)&&!ad(e)){var t=od(this);return t.frozen||(t.frozen=new wc),PI(this,e)||t.frozen.delete(e)}return PI(this,e)},has:function(e){if(id(e)&&!ad(e)){var t=od(this);return t.frozen||(t.frozen=new wc),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 wc),sd(this,e)?DI(this,e):t.frozen.get(e)}return DI(this,e)},set:function(e,t){if(id(e)&&!ad(e)){var n=od(this);n.frozen||(n.frozen=new wc),sd(this,e)?LI(this,e,t):n.frozen.set(e,t)}else LI(this,e,t);return this}})}var WF=Oe,cd=qs,JF=ie,OI=Rn,MI=We,qF=Bs,NI=aS,KF=Wt,tg=cd&&cd.prototype;if(WF({target:"Promise",proto:!0,real:!0,forced:!!cd&&JF(function(){tg.finally.call({then:function(){}},function(){})})},{finally:function(e){var t=qF(this,OI("Promise")),n=MI(e);return this.then(n?function(r){return NI(t,e()).then(function(){return r})}:e,n?function(r){return NI(t,e()).then(function(){throw r})}:e)}}),MI(cd)){var VI=OI("Promise").prototype.finally;tg.finally!==VI&&KF(tg,"finally",VI,{unsafe:!0})}var UI,BI,jI,FI,rr,_o=new WeakMap;function GI(){return function(e,t,n){var r=n.value,i=function o(a){var s=a.fn,c=a.args,u=a.context,d=a.resolve,p=a.reject;s.apply(u,c).then(d,p).finally(function(){var h=_o.get(u);h&&(h.shift(),h[0]&&o(G({},h[0])))})};return n.value=function(){for(var o=this,a=arguments.length,s=new Array(a),c=0;c<a;c++)s[c]=arguments[c];return new Promise(function(u,d){if(_o.has(o)){var p=_o.get(o),h=p.length;p.push({fn:r,args:s,context:o,resolve:u,reject:d,name:t}),h===0&&i({fn:r,args:s,context:o,resolve:u,reject:d})}else _o.set(o,[{fn:r,args:s,context:o,resolve:u,reject:d,name:t}]),i({fn:r,args:s,context:o,resolve:u,reject:d})})},n}}var QF=(UI=GI(),BI=xc({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)}}),jI=GI(),FI=function(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:1e4;return function(t,n,r){var i=r.value;return r.value=function(){for(var o=this,a=arguments.length,s=new Array(a),c=0;c<a;c++)s[c]=arguments[c];return new Promise(function(u,d){var p=setTimeout(function(){return d(new Error("".concat(n," timeout")))},e);i.apply(o,s).then(u,d).finally(function(){clearTimeout(p)})})},r}}(),rr=function(e){Mt(u,e);var t,n,r,i,o,a,s,c=wr(u);function u(d){var p;return z(this,u),(p=c.call(this,d)).remoteStreams_=new Map,p.autoSubscribe=d.autoSubscribe,p.trackState_={audio:d.trackState.audio,video:d.trackState.video,auxiliary:d.trackState.auxiliary,smallVideo:d.trackState.smallVideo},p.ssrc_={audio:0,video:0,auxiliary:0},p.subscribeState_={audio:d.autoSubscribe,video:d.autoSubscribe,auxiliary:d.autoSubscribe,smallVideo:!1},p.isSDPExchanging_=!1,p.installEvents(),p}return ke(u,[{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()===Ye?!this.trackState_.audio&&!this.trackState_.video:!this.trackState_.auxiliary}},{key:"initialize",value:function(){ae($e(u.prototype),"initialize",this).call(this),this.peerConnection_.ontrack=this.onTrack.bind(this)}},{key:"close",value:function(){var d,p,h,f=this;ae($e(u.prototype),"close",this).call(this),this.trackState_.audio=!1,this.trackState_.video=!1,this.trackState_.smallVideo=!1,this.trackState_.auxiliary=!1,this.emitConnectionStateChangedEvent(nn),d=this,p=function(_){_.fn;var y=_.args,S=_.resolve,E=_.reject,R=_.name;if(R==="subscribe"){if(!f.client_.getIsJoined())return E(new $({code:Q.API_CALL_ABORTED,message:te({key:df,data:{message:"leave room",stream:y[0]}})}));if(f.isStreamUnpublished(y[0]))return E(new $({code:Q.API_CALL_ABORTED,message:te({key:df,data:{message:"remote user ".concat(f.userId_," unpublished stream"),stream:y[0]}})}))}else if(R==="unsubscribe")return S();S()},(h=_o.get(d))===null||h===void 0||h.forEach(p),_o.delete(d),this.remoteStreams_.forEach(function(_){var y=_;y.setConnection(null),y.uninstallEvents(),y.getIsStreamAddedEventEmitted()&&f.emitter_.emit(rt.STREAM_REMOVED,{stream:y})}),this.remoteStreams_.clear(),this.uninstallEvents()}},{key:"installEvents",value:function(){var d=this;W.on(Mn,this.onRemoteStreamUpdate,this),this.emitter_.on(rt.ERROR,function(p){p.getCode()===Q.ICE_TRANSPORT_ERROR&&(d.isFirstConnection_&&(d.isFirstConnection_=!1,Ie.logFailedEvent({userId:d.client_.getUserId(),eventType:ES,error:p})),d.isReconnecting_||d.startReconnection())}),this.emitter_.on(rt.CONNECTION_STATE_CHANGED,function(p){p.state===ln&&d.isFirstConnection_&&(d.isFirstConnection_=!1,Ie.logSuccessEvent({userId:d.client_.getUserId(),eventType:ES}),d.addEventInternal(kU,"downlink-connection is connected"))})}},{key:"uninstallEvents",value:function(){W.removeListener(Mn,this.onRemoteStreamUpdate,this)}},{key:"onRemoteStreamUpdate",value:function(d){if(this.hitTest(d.tinyId)&&d.client===this.client_){this.updateTrackState(d.action,d.kind);var p=d.kind===pt?Ys:gr,h=this.remoteStreams_.get(p);if(!h)return;d.action===an.ADD?this.handleRemoteAddTrack(d.kind,h):this.handleRemoteRemoveTrack(d.kind,h)}}},{key:"handleRemoteAddTrack",value:function(d,p){this.log_.info("remote add ".concat(d," track")),d===Ce?p.updateAudioPlayingState(this.subscribeState_.audio):p.updateVideoPlayingState(d===pt?this.subscribeState_.auxiliary:this.subscribeState_.video||this.subscribeState_.smallVideo),p.getIsStreamAddedEventEmitted()?this.emitter_.emit(rt.STREAM_UPDATED,{stream:p}):(this.emitter_.emit(rt.STREAM_ADDED,{stream:p}),this.currentState_===ln&&p.emitConnectionStateChanged({prevState:nn,state:ln}))}},{key:"handleRemoteRemoveTrack",value:function(d,p){p.getIsStreamAddedEventEmitted()&&(this.log_.info("remote remove ".concat(d," track")),d===pt||!this.trackState_.audio&&!this.trackState_.video?(this.log_.info("remote stream ".concat(p.getType()," removed")),this.currentState_===ln&&p.emitConnectionStateChanged({prevState:ln,state:nn}),this.emitter_.emit(rt.STREAM_REMOVED,{stream:p})):(d===Ce?p.updateAudioPlayingState(!1):(d!==zu||this.isSmallStreamSubscribed)&&p.updateVideoPlayingState(!1),this.emitter_.emit(rt.STREAM_UPDATED,{stream:p})))}},{key:"updateTrackState",value:function(d,p){var h=d===an.ADD;switch(p){case Ce:this.trackState_.audio=h;break;case xe:this.trackState_.video=h;break;case pt:this.trackState_.auxiliary=h;break;case zu:this.trackState_.smallVideo=h}this.log_.info("trackState updated: ".concat(JSON.stringify(this.trackState_)))}},{key:"onTrack",value:function(d){var p=d.streams[0],h=d.track;if(this.log_.info("ontrack() kind: ".concat(h.kind," id: ").concat(h.id," streamId: ").concat(p.id)),this.sdpSemantics_===Zs){var f=function(R){var H=Yn.parse(R),Y={audio:[],video:[]};return H.media.forEach(function(ue){if(ue.ssrcs){var le=ue.ssrcs[0].id>>16&255;if(ue.type===Ce)Y.audio.push(gr);else if(ue.type==xe){var O=le===hN?gr:Ys;Y.video.push(O)}}}),Y}(this.peerConnection_.remoteDescription.sdp);if(h.kind===Ce){if(f.audio.length===0||p.id!==gr)return void this.log_.debug("skip this invalid audio track")}else if(f.video.indexOf(p.id)===-1)return void this.log_.debug("skip this invalid video track: ".concat(h.id," msid: ").concat(p.id))}Ie.logEvent({eventType:"ontrack",kind:h.kind});var _=!1,y=this.remoteStreams_.get(p.id),S=p.id===gr?gt:Pt;if(fe(y)&&((y=new Kv({type:S,userId:this.userId_,client:this.client_})).setConnection(this),this.remoteStreams_.set(p.id,y),_=!0),y.setMediaStream(p),h.kind===Ce?y.updateAudioPlayingState(this.subscribeState_.audio):S===gt?y.updateVideoPlayingState(this.subscribeState_.video||this.subscribeState_.smallVideo):y.updateVideoPlayingState(this.subscribeState_.auxiliary),(S!==Pt||this.trackState_.auxiliary)&&(S!==gt||this.trackState_.audio||this.trackState_.video)){var E=this.client_.getSubscriptionManager();E&&E.hasAutoRecoveryFlag(this.userId_,S)||(_?this.emitter_.emit(rt.STREAM_ADDED,{stream:y}):this.emitter_.emit(rt.STREAM_UPDATED,{stream:y}))}}},{key:"addRRTRLine",value:function(d){var p=d.split(`\r
105
+ `),h=new Map;p.forEach(function(R,H){/^a=rtcp-fb:/.test(R)&&p[H+1]&&!/^a=rtcp-fb:/.test(p[H+1])&&h.set(H+1,R.match(/^a=rtcp-fb:\d+/)[0]+" rrtr")});for(var f=Se(h),_=0;_<f.length;_++){var y=Te(f[_],2),S=y[0],E=y[1];p.splice(S+_,0,E)}return p.join(`\r
106
+ `)}},{key:"addSPSDescription",value:function(d){var p=Br(d);return p.media.forEach(function(h){h.type===xe&&h.fmtp.forEach(function(f){f.config+=";sps-pps-idr-in-keyframe=1"})}),Za(p)}},{key:"removeSDESDescription",value:function(d){var p=["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"],h=Br(d);return h.media.forEach(function(f){f.ext=f.ext.filter(function(_){return!p.includes(_.uri)})}),Za(h)}},{key:"isSubscriptionStateNotChanged",value:function(d,p){return d.getType()===gt?(p==null?void 0:p.audio)===this.subscribeState_.audio&&(p==null?void 0:p.video)===this.subscribeState_.video&&this.isSubscribeSmall(p):d.getType()===Pt?!fe(p.video)&&this.subscribeState_.auxiliary===p.video:void 0}},{key:"isSubscribeSmall",value:function(d){return fe(d.smallVideo)&&!this.subscribeState_.smallVideo}},{key:"subscribe",value:(s=N(m().mark(function d(p,h){var f,_,y,S,E,R;return m().wrap(function(H){for(;;)switch(H.prev=H.next){case 0:if(H.prev=0,y=h.emitEvent,S=y===void 0||y,E=p.getType(),((f=this.peerConnection_)===null||f===void 0?void 0:f.connectionState)!==pN&&((_=this.peerConnection_)===null||_===void 0?void 0:_.connectionState)!==Qu){H.next=6;break}return H.next=6,this.waitForPeerConnectionConnected();case 6:if(!this.isSubscriptionStateNotChanged(p,h)){H.next=13;break}if(this.peerConnection_){H.next=11;break}return this.initialize(),H.next=11,this.connect();case 11:return S&&fe(h.smallVideo)&&this.emitter_.emit(rt.STREAM_SUBSCRIBED,{stream:p,result:!0}),H.abrupt("return",p);case 13:if(E===Ye?(fe(h.audio)||(this.subscribeState_.audio=h.audio),fe(h.video)||(this.subscribeState_.video=h.video),this.subscribeState_.smallVideo=(h==null?void 0:h.smallVideo)||!1,this.addEventInternal(this.subscribeState_.audio?fT:fm,this.subscribeState_.audio?"subscribe audio":"unsubscribe audio"),this.addEventInternal(this.subscribeState_.video?fT:fm,this.subscribeState_.video?"subscribe video":"unsubscribe video"),this.addEventInternal(this.subscribeState_.smallVideo?DU:LU,this.subscribeState_.smallVideo?"subscribe smallVideo":"unsubscribe smallVideo")):fe(h.video)||(this.subscribeState_.auxiliary=h.video),this.log_.info("subscribe ".concat(E," stream with options ").concat(JSON.stringify(h)," current state: ").concat(JSON.stringify(this.subscribeState_))),!this.peerConnection_&&!this.isSDPExchanging_){H.next=23;break}return R=$p,this.isMainStreamSubscribed||this.isAuxStreamSubscribed||(R=Yp),H.next=20,this.sendSubscription(R);case 20:E===Ye?(p.updateAudioPlayingState(this.subscribeState_.audio),p.updateVideoPlayingState(this.subscribeState_.video||this.subscribeState_.smallVideo)):p.updateVideoPlayingState(this.subscribeState_.auxiliary),H.next=26;break;case 23:return this.initialize(),H.next=26,this.connect();case 26:return S&&this.emitter_.emit(rt.STREAM_SUBSCRIBED,{stream:p,result:!0}),H.abrupt("return",p);case 30:if(H.prev=30,H.t0=H.catch(0),!this.client_.getIsJoined()||!this.isStreamUnpublished(p)){H.next=35;break}throw this.log_.warn("".concat(H.t0.message," ").concat(JSON.stringify(this.trackState_))),new $({code:Q.REMOTE_STREAM_NOT_EXIST,message:"remote user ".concat(this.userId_," unpublished stream")});case 35:throw H.t0;case 36:case"end":return H.stop()}},d,this,[[0,30]])})),function(d,p){return s.apply(this,arguments)})},{key:"unsubscribe",value:(a=N(m().mark(function d(p){var h,f,_;return m().wrap(function(y){for(;;)switch(y.prev=y.next){case 0:if((h=p.getType())!==Ye){y.next=10;break}if(this.isMainStreamSubscribed){y.next=5;break}return this.log_.info("main stream already unsubscribed"),y.abrupt("return",p);case 5:this.subscribeState_.audio=!1,this.subscribeState_.video=!1,this.subscribeState_.smallVideo=!1,y.next=14;break;case 10:if(this.isAuxStreamSubscribed){y.next=13;break}return this.log_.info("auxiliary stream already unsubscribed"),y.abrupt("return",p);case 13:this.subscribeState_.auxiliary=!1;case 14:return f=Yp,(h===gt&&this.isAuxStreamSubscribed||h===Pt&&this.isMainStreamSubscribed)&&(f=$p),this.log_.info("unsubscribe ".concat(h," stream with ").concat(JSON.stringify(this.subscribeState_))),y.next=19,this.sendSubscription(f);case 19:return p.updateVideoPlayingState(!1),p.updateAudioPlayingState(!1),f===Yp&&((_=p.getMediaStream())&&_.getTracks().forEach(function(S){return _.removeTrack(S)}),this.closePeerConnection(),this.emitConnectionStateChangedEvent(nn)),this.addEventInternal(fm,"unsubscribe audio"),this.addEventInternal(cU,"unsubscribe video"),y.abrupt("return",p);case 25:case"end":return y.stop()}},d,this)})),function(d){return a.apply(this,arguments)})},{key:"sendSubscription",value:function(d){var p=this,h={srcTinyId:this.tinyId_,srcUserId:this.userId_},f=qV,_=ft.UNSUBSCRIBE_RESULT;return d===$p&&(h={audio:this.subscribeState_.audio,bigVideo:this.subscribeState_.video,auxVideo:this.subscribeState_.auxiliary,smallVideo:this.subscribeState_.smallVideo,srcTinyId:this.tinyId_},f=KV,_=ft.SUBSCRIBE_CHANGE_RESULT),this.signalChannel_.sendWaitForResponse({command:f,data:h,responseCommand:_,timeout:1e4}).then(function(y){var S=y.data;if(S.code!==0){var E=new $({code:S.code,message:te({key:WN,data:{type:d,message:S.message}})});throw p.log_.error(E),E}})}},{key:"connect",value:(o=N(m().mark(function d(){return m().wrap(function(p){for(;;)switch(p.prev=p.next){case 0:return p.prev=0,p.next=3,this.exchangeSDP();case 3:return p.next=5,this.waitForPeerConnectionConnected();case 5:p.next=11;break;case 7:throw p.prev=7,p.t0=p.catch(0),this.closePeerConnection(!0),p.t0;case 11:case"end":return p.stop()}},d,this,[[0,7]])})),function(){return o.apply(this,arguments)})},{key:"exchangeSDP",value:(i=N(m().mark(function d(){var p,h,f,_,y,S;return m().wrap(function(E){for(;;)switch(E.prev=E.next){case 0:return E.prev=0,this.isSDPExchanging_=!0,E.next=4,this.createOffer();case 4:return this.log_.info("createOffer success, sending offer to remote server"),p=this.peerConnection_.localDescription,h=p.type,f=p.sdp,_={type:h,sdp:f,srcUserId:this.userId_,srcTinyId:this.tinyId_,audio:this.subscribeState_.audio,bigVideo:this.subscribeState_.video,auxVideo:this.subscribeState_.auxiliary,smallVideo:this.subscribeState_.smallVideo},W.emit(im,{client:this.client_,connection:this,userId:this.userId_,tinyId:this.tinyId_,role:za,subscribeState:this.subscribeState_,trackState:this.trackState_}),E.next=10,this.signalChannel_.sendWaitForResponse({command:JV,commandDesc:"exchange sdp",data:_,responseCommand:ft.SUBSCRIBE_RESULT,timeout:1e4});case 10:if(y=E.sent,this.peerConnection_){E.next=15;break}throw S=new $({code:Q.INVALID_OPERATION,message:te({key:p4})}),this.log_.warn(S),S;case 15:return E.next=17,this.onSubscribeResult(y);case 17:this.isSDPExchanging_=!1,E.next=24;break;case 20:throw E.prev=20,E.t0=E.catch(0),this.isSDPExchanging_=!1,E.t0;case 24:case"end":return E.stop()}},d,this,[[0,20]])})),function(){return i.apply(this,arguments)})},{key:"createOffer",value:(r=N(m().mark(function d(){var p,h;return m().wrap(function(f){for(;;)switch(f.prev=f.next){case 0:return p={voiceActivityDetection:!1},Em()&&this.sdpSemantics_===Zs?(this.peerConnection_.addTransceiver(Ce,{direction:"recvonly"}),this.peerConnection_.addTransceiver(xe,{direction:"recvonly"}),this.peerConnection_.addTransceiver(xe,{direction:"recvonly"})):(p.offerToReceiveAudio=!0,p.offerToReceiveVideo=!0),f.next=4,this.peerConnection_.createOffer(p);case 4:return h=f.sent,f.next=7,CT();case 7:return f.sent.isH264DecodeSupported||(this.log_.warn("remove h264 desc from sdp"),h.sdp=qU(h.sdp)),h.sdp=this.addRRTRLine(h.sdp),h.sdp=this.addSPSDescription(h.sdp),h.sdp=JU(h.sdp),this.sdpSemantics_===Zs&&(h.sdp=this.removeSDESDescription(h.sdp)),f.next=16,this.peerConnection_.setLocalDescription(h);case 16:case"end":return f.stop()}},d,this)})),function(){return r.apply(this,arguments)})},{key:"onSubscribeResult",value:(n=N(m().mark(function d(p){var h,f,_,y,S,E,R,H=this;return m().wrap(function(Y){for(;;)switch(Y.prev=Y.next){case 0:if(h=p&&p.data||{},f=h.code,_=h.message,y=_===void 0?"":_,S=p&&p.data&&p.data.data||{},E=S.type,R=S.sdp,f!==77393){Y.next=5;break}throw this.log_.error(di.NOT_SUPPORTED_H264DECODE),new $({code:Q.NOT_SUPPORTED_H264,message:te({key:lk})});case 5:if(Y.prev=5,f===0){Y.next=8;break}throw new $({code:f,message:te({key:KN,data:{errMsg:y}})});case 8:return this.log_.debug("accept remote answer: "+R),Y.next=11,this.peerConnection_.setRemoteDescription({type:E,sdp:R});case 11:this.sei_&&(this.sei_.handleEncodedStreams(),this.sei_.onSEIMessage=function(ue){H.emitter_.emit(rt.SEI_MESSAGE,G(G({},ue),{},{userId:H.userId_}))}),this.updateSSRC(R),Y.next=19;break;case 15:throw Y.prev=15,Y.t0=Y.catch(5),this.log_.error(Y.t0),Y.t0;case 19:case"end":return Y.stop()}},d,this,[[5,15]])})),function(d){return n.apply(this,arguments)})},{key:"updateSSRC",value:function(d){var p=this;try{Br(d).media.forEach(function(h){if(h.type===Ce){var f=h.ssrcs.find(function(S){return S.value.includes(gr)});f&&(p.ssrc_.audio=f.id)}else{var _=h.ssrcs.find(function(S){return S.value.includes(gr)}),y=h.ssrcs.find(function(S){return S.value.includes(Ys)});_&&(p.ssrc_.video=_.id),y&&(p.ssrc_.auxiliary=y.id)}})}catch(h){}}},{key:"setRemoteStream",value:function(d,p){this.remoteStreams_.set(d,p)}},{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(gr)}},{key:"getAuxStream",value:function(){return this.remoteStreams_.get(Ys)}},{key:"getMainStreamVideoTrackId",value:function(){var d=this.getMainStream();if(d){var p=d.getVideoTrack();if(p)return p.id}return""}},{key:"getAuxStreamVideoTrackId",value:function(){var d=this.getAuxStream();if(d){var p=d.getVideoTrack();if(p)return p.id}return""}},{key:"reconnect",value:(t=N(m().mark(function d(){var p,h,f=this;return m().wrap(function(_){for(;;)switch(_.prev=_.next){case 0:if(this.reconnectionTimer_===-1){_.next=3;break}return this.log_.warn("reconnect() downlink is reconnecting, ignore current reconnection"),_.abrupt("return");case 3:if(!(this.reconnectionCount_>=30)){_.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(),p=new $({code:Q.DOWNLINK_RECONNECTION_FAILED,message:te({key:qN})}),Ie.logFailedEvent({userId:this.client_.getUserId(),eventType:CS,error:p}),this.addEventInternal(PU,"downlink-connection reconnect fail"),this.emitConnectionStateChangedEvent(nn),this.emitter_.emit(rt.ERROR,p),_.abrupt("return");case 12:if(this.signalChannel_.getCurrentState()===cc){_.next=16;break}return this.log_.warn("reconnect() signal channel is not connected, suspend reconnection until signal is connected"),this.signalChannel_.once(sc,this.reconnect,this),_.abrupt("return");case 16:if(this.reconnectionCount_++,this.log_.warn("reconnect() try to reconnect downlink [".concat(this.reconnectionCount_,"/").concat(30,"]")),h=Pf(this.reconnectionCount_),this.reconnectionTimer_=setTimeout(function(){f.log_.warn("reconnect() downlink [".concat(f.userId_,"] reconnect timeout(").concat(h/1e3,"s), try again")),f.clearReconnectionTimer(),f.reconnect()},h),!(this.isSDPExchanging_||this.peerConnection_&&this.peerConnection_.connectionState===Qu)){_.next=22;break}return _.abrupt("return");case 22:return _.prev=22,this.closePeerConnection(),this.initialize(),_.next=27,this.connect();case 27:this.stopReconnection(),this.log_.warn("reconnect() downlink reconnect successfully"),Ie.logSuccessEvent({userId:this.client_.getUserId(),eventType:CS}),this.addEventInternal(AU,"downlink-connection reconnect success"),this.recoverSubscription(),_.next=36;break;case 34:_.prev=34,_.t0=_.catch(22);case 36:case"end":return _.stop()}},d,this,[[22,34]])})),function(){return t.apply(this,arguments)})},{key:"recoverSubscription",value:function(){var d=this,p=this.client_.getSubscriptionManager();p&&Se(this.remoteStreams_.values()).forEach(function(h){p.hasAutoRecoveryFlag(d.userId_,h.getType())&&p.recover(h)})}},{key:"getIsReconnecting",value:function(){return this.isReconnecting_}},{key:"getSubscribedMainStream",value:function(){var d=null;return this.isMainStreamSubscribed&&(d=this.remoteStreams_.get(gr)),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 p,h=ne(this.remoteStreams_.values());try{for(h.s();!(p=h.n()).done;){var f=p.value,_=f.getType();(_===gt&&(this.trackState_.audio||this.trackState_.video)||_===Pt&&this.trackState_.auxiliary)&&d.setAutoRecoveryFlag(this.userId_,f.getType())}}catch(y){h.e(y)}finally{h.f()}}ae($e(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),q(rr.prototype,"subscribe",[UI,BI],Object.getOwnPropertyDescriptor(rr.prototype,"subscribe"),rr.prototype),q(rr.prototype,"unsubscribe",[jI],Object.getOwnPropertyDescriptor(rr.prototype,"unsubscribe"),rr.prototype),q(rr.prototype,"exchangeSDP",[FI],Object.getOwnPropertyDescriptor(rr.prototype,"exchangeSDP"),rr.prototype),rr),ud=function(){function e(){z(this,e),this.startTime=0,this.endTime=0,this.start()}return ke(e,[{key:"start",value:function(){this.startTime===0&&(this.startTime=Et())}},{key:"stop",value:function(){this.endTime===0&&(this.endTime=Et())}},{key:"getDuration",value:function(){return this.endTime===0?Et()-this.startTime:this.endTime-this.startTime}}]),e}(),XF=function(){function e(i){z(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,r;return ke(e,[{key:"installEvents",value:function(){W.on(Zf,this.handlePlayVideoStart,this),W.on(ic,this.onVideoTrackMuted,this),W.on(Xf,this.onVideoTrackUnmuted,this),W.on(Yi,this.handleStreamStopped,this),W.on(Vr,this.handleStreamStopped,this),W.on(rc,this.handleVideoPlaying,this)}},{key:"uninstallEvents",value:function(){W.off(Zf,this.handlePlayVideoStart,this),W.off(ic,this.onVideoTrackMuted,this),W.off(Xf,this.onVideoTrackUnmuted,this),W.off(Yi,this.handleStreamStopped,this),W.off(Vr,this.handleStreamStopped,this),W.off(rc,this.handleVideoPlaying,this)}},{key:"start",value:function(){var i=this;this.intervalId_===-1&&(this.installEvents(),this.intervalId_=_t.run(N(m().mark(function o(){return m().wrap(function(a){for(;;)switch(a.prev=a.next){case 0:return a.prev=0,a.next=3,i.detectFPS();case 3:a.next=7;break;case 5:a.prev=5,a.t0=a.catch(0);case 7:case"end":return a.stop()}},o,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 o=i.stream;if(o.getClient()===this.client_&&o.isRemote()){var a=o.userId_,s=o.type_,c="".concat(a,"_").concat(s),u=this.dataFreezeMap_.get(c),d=new ud;u?u.durationItemList.push(d):this.dataFreezeMap_.set(c,{userId:a,type:s,durationItemList:[d],isFreezing:function(){var p=this.durationItemList[this.durationItemList.length-1];return p&&p.endTime===0}})}}},{key:"onVideoTrackUnmuted",value:function(i){var o=i.stream;if(o.getClient()===this.client_&&o.isRemote()){var a=o.userId_,s=o.type_,c="".concat(a,"_").concat(s);this.stopDataFreeze({key:c,userId:a,type:s})}}},{key:"handleStreamStopped",value:function(i){var o=i.client,a=i.stream;if(o===this.client_){var s=a.getUserId(),c=a.getType(),u="".concat(s,"_").concat(c);this.stopDataFreeze({key:u,userId:s,type:c})}}},{key:"stopDataFreeze",value:function(i){var o=i.key,a=i.userId,s=i.type,c=this.dataFreezeMap_.get(o);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(o,{userId:a,type:s,duration:d})):c.durationItemList.pop()}}},{key:"getTotalDuration",value:function(i){return i.reduce(function(o,a){var s=a.getDuration();return o+Math.min(s,5e3)},0)}},{key:"getStats",value:(r=N(m().mark(function i(){var o,a,s,c,u,d,p,h,f,_,y;return m().wrap(function(S){for(;;)switch(S.prev=S.next){case 0:o=this.client_.getConnections(),a={},s=ne(o),S.prev=3,s.s();case 5:if((c=s.n()).done){S.next=20;break}if(u=Te(c.value,2),d=u[0],(p=u[1]).getPeerConnection()){S.next=9;break}return S.abrupt("continue",18);case 9:return h=p.getSubscribeState(),f=p.getTrackState(),S.next=13,this.statsCalculator_.getReceiverStats(p);case 13:_=S.sent,(y={userId:_.userId,tinyId:d,hasVideo:f.video&&h.video,hasAuxiliary:f.auxiliary&&h.auxiliary,video:{framesDecoded:0},auxiliary:{framesDecoded:0}}).hasVideo&&(y.video.framesDecoded=_.video.framesDecoded),y.hasAuxiliary&&(y.auxiliary.framesDecoded=_.auxiliary.framesDecoded),a[_.userId]=y;case 18:S.next=5;break;case 20:S.next=25;break;case 22:S.prev=22,S.t0=S.catch(3),s.e(S.t0);case 25:return S.prev=25,s.f(),S.finish(25);case 28:return S.abrupt("return",a);case 29:case"end":return S.stop()}},i,this,[[3,22,25,28]])})),function(){return r.apply(this,arguments)})},{key:"detectFPS",value:(n=N(m().mark(function i(){var o,a,s,c,u,d;return m().wrap(function(p){for(;;)switch(p.prev=p.next){case 0:return p.next=2,this.getStats();case 2:if(o=p.sent,this.prevStats_){p.next=6;break}return this.prevStats_=o,p.abrupt("return");case 6:p.t0=m().keys(o);case 7:if((p.t1=p.t0()).done){p.next=17;break}if(a=p.t1.value,this.prevStats_[a]){p.next=11;break}return p.abrupt("continue",7);case 11:s=o[a].tinyId,c=this.client_.getMutedStates(),o[a].hasVideo&&this.prevStats_[a].hasVideo&&c.has(s)&&!c.get(s).videoMuted&&(u=o[a].video.framesDecoded-this.prevStats_[a].video.framesDecoded,this.handleRenderFreeze({userId:a,type:gt,fps:u})),o[a].hasAuxiliary&&this.prevStats_[a].hasAuxiliary&&(d=o[a].auxiliary.framesDecoded-this.prevStats_[a].auxiliary.framesDecoded,this.handleRenderFreeze({userId:a,type:Pt,fps:d})),p.next=7;break;case 17:this.prevStats_=o;case 18:case"end":return p.stop()}},i,this)})),function(){return n.apply(this,arguments)})},{key:"handleRenderFreeze",value:(t=N(m().mark(function i(o){var a,s,c,u,d,p,h,f;return m().wrap(function(_){for(;;)switch(_.prev=_.next){case 0:a=o.userId,s=o.fps,c=o.type,u="".concat(a,"_").concat(c),d=this.renderFreezeMap_.get(u),s<=2?(p=Et(),d&&!d.isFreeze&&(d.freezeTimeline.push({startTime:p,endTime:void 0}),d.isFreeze=!0),d||this.renderFreezeMap_.set(u,{userId:a,type:c,isFreeze:!0,freezeTimeline:[{startTime:p,endTime:void 0}],renderFreezeTotal:0})):d&&d.isFreeze&&(d.isFreeze=!1,(h=d.freezeTimeline.pop()).endTime=Et(),f=h.endTime-h.startTime,d.freezeTimeline.push(h),d.renderFreezeTotal+=Math.min(5e3,f));case 4:case"end":return _.stop()}},i,this)})),function(i){return t.apply(this,arguments)})},{key:"handlePlayVideoStart",value:function(i){var o=i.stream;if(o.getClient()===this.client_&&o.isRemote()&&o.hasVideo()){var a="".concat(o.getUserId(),"_").concat(o.getType());this.remoteStreamMap_.has(a)||this.remoteStreamMap_.set(a,{isPlayingFired:!1})}}},{key:"handleVideoPlaying",value:function(i){var o=i.stream;if(o.isRemote()&&o.getClient()===this.client_){var a="".concat(o.getUserId(),"_").concat(o.getType());this.remoteStreamMap_.has(a)&&(this.remoteStreamMap_.get(a).isPlayingFired=!0)}}},{key:"getDataFreezeDuration",value:function(i){var o={dataFreeze:0,count:0},a=this.dataFreezeMap_.get(i);if(a){if(a.isFreezing()){var s=a.durationItemList[a.durationItemList.length-1];s.stop(),s.getDuration()<500&&a.durationItemList.pop()}o.dataFreeze=this.getTotalDuration(a.durationItemList),o.count=a.durationItemList.length}return o}},{key:"getRenderFreezeDuration",value:function(i){var o=this.renderFreezeMap_.get(i),a=0,s=0;if(o)if(o.isFreeze){var c=Et()-o.freezeTimeline[o.freezeTimeline.length-1].startTime;a=o.renderFreezeTotal+Math.min(c,5e3),s=o.freezeTimeline.length}else a=o.renderFreezeTotal;return{renderFreeze:a,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}(),ng=ke(function e(t){z(this,e),this.userId=t.userId,this.tinyId=t.tinyId,this.role=t.role===za?vr:zi}),HI={exports:{}};(function(e){(function(t){function n(S,E){var R=(65535&S)+(65535&E);return(S>>16)+(E>>16)+(R>>16)<<16|65535&R}function r(S,E,R,H,Y,ue){return n((le=n(n(E,S),n(H,ue)))<<(O=Y)|le>>>32-O,R);var le,O}function i(S,E,R,H,Y,ue,le){return r(E&R|~E&H,S,E,Y,ue,le)}function o(S,E,R,H,Y,ue,le){return r(E&H|R&~H,S,E,Y,ue,le)}function a(S,E,R,H,Y,ue,le){return r(E^R^H,S,E,Y,ue,le)}function s(S,E,R,H,Y,ue,le){return r(R^(E|~H),S,E,Y,ue,le)}function c(S,E){var R,H,Y,ue,le;S[E>>5]|=128<<E%32,S[14+(E+64>>>9<<4)]=E;var O=1732584193,k=-271733879,P=-1732584194,A=271733878;for(R=0;R<S.length;R+=16)H=O,Y=k,ue=P,le=A,O=i(O,k,P,A,S[R],7,-680876936),A=i(A,O,k,P,S[R+1],12,-389564586),P=i(P,A,O,k,S[R+2],17,606105819),k=i(k,P,A,O,S[R+3],22,-1044525330),O=i(O,k,P,A,S[R+4],7,-176418897),A=i(A,O,k,P,S[R+5],12,1200080426),P=i(P,A,O,k,S[R+6],17,-1473231341),k=i(k,P,A,O,S[R+7],22,-45705983),O=i(O,k,P,A,S[R+8],7,1770035416),A=i(A,O,k,P,S[R+9],12,-1958414417),P=i(P,A,O,k,S[R+10],17,-42063),k=i(k,P,A,O,S[R+11],22,-1990404162),O=i(O,k,P,A,S[R+12],7,1804603682),A=i(A,O,k,P,S[R+13],12,-40341101),P=i(P,A,O,k,S[R+14],17,-1502002290),O=o(O,k=i(k,P,A,O,S[R+15],22,1236535329),P,A,S[R+1],5,-165796510),A=o(A,O,k,P,S[R+6],9,-1069501632),P=o(P,A,O,k,S[R+11],14,643717713),k=o(k,P,A,O,S[R],20,-373897302),O=o(O,k,P,A,S[R+5],5,-701558691),A=o(A,O,k,P,S[R+10],9,38016083),P=o(P,A,O,k,S[R+15],14,-660478335),k=o(k,P,A,O,S[R+4],20,-405537848),O=o(O,k,P,A,S[R+9],5,568446438),A=o(A,O,k,P,S[R+14],9,-1019803690),P=o(P,A,O,k,S[R+3],14,-187363961),k=o(k,P,A,O,S[R+8],20,1163531501),O=o(O,k,P,A,S[R+13],5,-1444681467),A=o(A,O,k,P,S[R+2],9,-51403784),P=o(P,A,O,k,S[R+7],14,1735328473),O=a(O,k=o(k,P,A,O,S[R+12],20,-1926607734),P,A,S[R+5],4,-378558),A=a(A,O,k,P,S[R+8],11,-2022574463),P=a(P,A,O,k,S[R+11],16,1839030562),k=a(k,P,A,O,S[R+14],23,-35309556),O=a(O,k,P,A,S[R+1],4,-1530992060),A=a(A,O,k,P,S[R+4],11,1272893353),P=a(P,A,O,k,S[R+7],16,-155497632),k=a(k,P,A,O,S[R+10],23,-1094730640),O=a(O,k,P,A,S[R+13],4,681279174),A=a(A,O,k,P,S[R],11,-358537222),P=a(P,A,O,k,S[R+3],16,-722521979),k=a(k,P,A,O,S[R+6],23,76029189),O=a(O,k,P,A,S[R+9],4,-640364487),A=a(A,O,k,P,S[R+12],11,-421815835),P=a(P,A,O,k,S[R+15],16,530742520),O=s(O,k=a(k,P,A,O,S[R+2],23,-995338651),P,A,S[R],6,-198630844),A=s(A,O,k,P,S[R+7],10,1126891415),P=s(P,A,O,k,S[R+14],15,-1416354905),k=s(k,P,A,O,S[R+5],21,-57434055),O=s(O,k,P,A,S[R+12],6,1700485571),A=s(A,O,k,P,S[R+3],10,-1894986606),P=s(P,A,O,k,S[R+10],15,-1051523),k=s(k,P,A,O,S[R+1],21,-2054922799),O=s(O,k,P,A,S[R+8],6,1873313359),A=s(A,O,k,P,S[R+15],10,-30611744),P=s(P,A,O,k,S[R+6],15,-1560198380),k=s(k,P,A,O,S[R+13],21,1309151649),O=s(O,k,P,A,S[R+4],6,-145523070),A=s(A,O,k,P,S[R+11],10,-1120210379),P=s(P,A,O,k,S[R+2],15,718787259),k=s(k,P,A,O,S[R+9],21,-343485551),O=n(O,H),k=n(k,Y),P=n(P,ue),A=n(A,le);return[O,k,P,A]}function u(S){var E,R="",H=32*S.length;for(E=0;E<H;E+=8)R+=String.fromCharCode(S[E>>5]>>>E%32&255);return R}function d(S){var E,R=[];for(R[(S.length>>2)-1]=void 0,E=0;E<R.length;E+=1)R[E]=0;var H=8*S.length;for(E=0;E<H;E+=8)R[E>>5]|=(255&S.charCodeAt(E/8))<<E%32;return R}function p(S){var E,R,H="0123456789abcdef",Y="";for(R=0;R<S.length;R+=1)E=S.charCodeAt(R),Y+=H.charAt(E>>>4&15)+H.charAt(15&E);return Y}function h(S){return unescape(encodeURIComponent(S))}function f(S){return function(E){return u(c(d(E),8*E.length))}(h(S))}function _(S,E){return function(R,H){var Y,ue,le=d(R),O=[],k=[];for(O[15]=k[15]=void 0,le.length>16&&(le=c(le,8*R.length)),Y=0;Y<16;Y+=1)O[Y]=909522486^le[Y],k[Y]=1549556828^le[Y];return ue=c(O.concat(d(H)),512+8*H.length),u(c(k.concat(ue),640))}(h(S),h(E))}function y(S,E,R){return E?R?_(E,S):p(_(E,S)):R?f(S):p(f(S))}e.exports?e.exports=y:t.md5=y})(re)})(HI);var zI,Cc,ld=HI.exports,YF=function(){function e(o){z(this,e),this.client_=o.client,this.signalChannel_=o.signalChannel,this.log_=be.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,r,i;return ke(e,[{key:"isPresetLayoutMode",get:function(){return this.config_&&this.config_.mode===ef.PRESET_LAYOUT}},{key:"installEvents",value:function(){W.on(Nr,this.onStreamSubscribed,this),W.on(Vr,this.onStreamUnsubscribed,this),this.client_.on("stream-removed",this.onStreamRemoved,this)}},{key:"uninstallEvents",value:function(){W.off(Nr,this.onStreamSubscribed,this),W.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 a=o.client,s=o.stream;a===this.client_&&(this.remoteStreamMap_.set(s.getId(),{remoteStream:s,isUsed:!1}),this.isMixing_&&this.hasAvailablePlaceHolder()&&this.startMixTranscode(this.config_))}},{key:"onStreamUnsubscribed",value:function(o){var a=o.client,s=o.stream;a===this.client_&&this.onStreamRemoved({stream:s})}},{key:"onStreamRemoved",value:function(o){var a=o.stream;if(this.remoteStreamMap_.has(a.getId())){var s=this.remoteStreamMap_.get(a.getId()).isUsed;this.remoteStreamMap_.delete(a.getId()),this.isMixing_&&this.isPresetLayoutMode&&s&&this.startMixTranscode(this.config_)}}},{key:"startMixTranscode",value:(i=N(m().mark(function o(a){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_=a,s=this.getInputParam(a,this.remoteStreamMap_),c=this.getOutputParam(a),u=this.getOutputSessionId({config:a,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()}},o,this,[[0,14]])})),function(o){return i.apply(this,arguments)})},{key:"doStartMixTranscode",value:(r=N(m().mark(function o(a){var s,c,u,d,p,h,f,_;return m().wrap(function(y){for(;;)switch(y.prev=y.next){case 0:return s=a.outputSessionId,c=a.inputParam,u=a.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,y.prev=5,y.next=8,this.signalChannel_.sendWaitForResponse({command:ZV,data:d,timeout:5e3,responseCommand:ft.START_MIX_TRANSCODE_RES,commandDesc:"startMixTranscode"});case 8:if(p=y.sent,h=p.data,f=h.code,_=h.message,f===0){y.next=15;break}throw f===-102083&&(_="Please enable relayed-push in ".concat(JS," and try later, refer to ").concat(af,"tutorial-26-advanced-publish-cdn-stream.html")),this.log_.error("startMixTranscode failed, errCode: ".concat(f," errMsg: ").concat(_)),this.isMixing_=!1,new $({code:Q.START_MIX_TRANSCODE_FAILED,message:te({key:H3,data:{message:_},link:{className:"Client",fnName:"startMixTranscode"}})});case 15:y.next=21;break;case 17:throw y.prev=17,y.t0=y.catch(5),this.isMixing_=!1,y.t0;case 21:case"end":return y.stop()}},o,this,[[5,17]])})),function(o){return r.apply(this,arguments)})},{key:"reStartMixTranscode",value:function(){this.isMixing_&&this.startMixTranscode(this.config_)}},{key:"stopMixTranscode",value:(n=N(m().mark(function o(){return m().wrap(function(a){for(;;)switch(a.prev=a.next){case 0:if(this.isMixing_){a.next=2;break}throw new $({code:Q.INVALID_OPERATION,message:te({key:W3})});case 2:return a.next=4,this.doStopMixTranscode();case 4:this.resetIsUsedFlag();case 5:case"end":return a.stop()}},o,this)})),function(){return n.apply(this,arguments)})},{key:"doStopMixTranscode",value:(t=N(m().mark(function o(){var a,s,c,u,d;return m().wrap(function(p){for(;;)switch(p.prev=p.next){case 0:return a={mcuRequestTime:Date.now(),outputSessionId:this.data_.outputSessionId,streamType:this.data_.outputParam.streamType},this.log_.info("stopMixTranscode: ".concat(JSON.stringify(a))),p.next=4,this.signalChannel_.sendWaitForResponse({command:eU,data:a,timeout:5e3,responseCommand:ft.STOP_MIX_TRANSCODE_RES,commandDesc:"stopMixTranscode"});case 4:if(s=p.sent,c=s.data,u=c.code,d=c.message,u!==0){p.next=10;break}this.isMixing_=!1,p.next=12;break;case 10:throw this.log_.error("stopMixTranscode failed, errCode: ".concat(u," errMsg: ").concat(d)),new $({code:Q.STOP_MIX_TRANSCODE_FAILED,message:te({key:z3,data:{message:d},link:{className:"Client",fnName:"stopMixTranscode"}})});case 12:case"end":return p.stop()}},o,this)})),function(){return t.apply(this,arguments)})},{key:"getOutputSessionId",value:function(o){var a=o.config,s=o.userId,c=o.roomId;return Ft(a.streamId)&&a.streamId.length>0?a.streamId:ld("".concat(c,"_").concat(s,"_main"))}},{key:"getInputParam",value:function(o,a){var s=this,c=o.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:fe(u.streamType)||u.streamType!==Pt?0:1,inputType:u.pureAudio?BS.IT_PURE_AUDIO:BS.IT_AUDIO_VIDEO,renderMode:u.renderMode||0}});return o.mode===ef.PRESET_LAYOUT&&(c.forEach(function(u){if(u.userId===US.REMOTE){var d=Se(a.values()).find(function(p){return!p.isUsed});d&&(u.userId=d.remoteStream.getUserId(),u.streamType=d.remoteStream.getType()===Pt?1:0,d.isUsed=!0)}}),c=c.filter(function(u){return u.userId!==US.REMOTE})),c}},{key:"getOutputParam",value:function(o){var a=o.streamId||"";return{streamId:a,streamType:a.length>0?1:0,width:fe(o.videoWidth)?640:o.videoWidth,height:fe(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}(),$F=function(){function e(s){z(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,r,i,o,a;return ke(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:(a=N(m().mark(function s(c){var u,d,p,h;return m().wrap(function(f){for(;;)switch(f.prev=f.next){case 0:if(c.streamType===Ln?(this.publishTencentAuxStreamObj_.params_=c,this.publishTencentAuxStreamObj_.isPublishing_=!0):(this.publishTencentMainStreamObj_.params_=c,this.publishTencentMainStreamObj_.isPublishing_=!0),this.client_.isJoined_){f.next=3;break}return f.abrupt("return");case 3:return u=this.generatePublishCDNStreamId(c.streamId,c.streamType),d=this.generatePublishCDNSessionId(c.streamType),p=c.streamType===Ln?1:0,h={requestTime:Date.now(),sessionId:d,streamId:u,streamType:p},f.next=9,this.doStartPublishTencentCDN(h,c.streamType);case 9:case"end":return f.stop()}},s,this)})),function(s){return a.apply(this,arguments)})},{key:"doStartPublishTencentCDN",value:(o=N(m().mark(function s(c,u){var d,p,h,f;return m().wrap(function(_){for(;;)switch(_.prev=_.next){case 0:return _.prev=0,be.info("startPublishTencentCDN: "+JSON.stringify(c)),_.next=4,this.signalChannel_.sendWaitForResponseWithRetry({command:QV,data:c,timeout:2e3,responseCommand:ft.START_PUBLISH_TENCENT_CDN_RES,commandDesc:"startPublishCDNStream",retries:2});case 4:if(d=_.sent,p=d.data,h=p.code,f=p.message,h!==0){_.next=10;break}u===Ln?this.publishTencentAuxStreamObj_.streamId_=c.streamId:this.publishTencentMainStreamObj_.streamId_=c.streamId,_.next=14;break;case 10:throw u===Ln?this.publishTencentAuxStreamObj_.isPublishing_=!1:this.publishTencentMainStreamObj_.isPublishing_=!1,h===-102083&&(f="Please enable relayed-push in ".concat(JS," and try later, refer to ").concat(af,"tutorial-26-advanced-publish-cdn-stream.html")),be.error("startPublishTencentCDN failed, errCode: ".concat(h,", errMsg: ").concat(f)),new $({code:Q.START_PUBLISH_CDN_FAILED,message:te({key:rk,data:{message:f},link:{className:"Client",fnName:"startPublishCDNStream"}})});case 14:_.next=20;break;case 16:throw _.prev=16,_.t0=_.catch(0),u===Ln?this.publishTencentAuxStreamObj_.isPublishing_=!1:this.publishTencentMainStreamObj_.isPublishing_=!1,_.t0;case 20:case"end":return _.stop()}},s,this,[[0,16]])})),function(s,c){return o.apply(this,arguments)})},{key:"resetPublishTencentParam",value:function(s){s===Ye&&(this.publishTencentMainStreamObj_={params_:null,streamId_:void 0,isPublishing_:!1}),s===Ln&&(this.publishTencentAuxStreamObj_={params_:null,streamId_:void 0,isPublishing_:!1})}},{key:"stopPublishTencentCDN",value:(i=N(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(Ye),this.resetPublishTencentParam(Ln),c.abrupt("return");case 4:if(!this.publishTencentMainStreamObj_.isPublishing_){c.next=7;break}return c.next=7,this.doStopPublishTencentCDN(Ye);case 7:if(!this.publishTencentAuxStreamObj_.isPublishing_){c.next=10;break}return c.next=10,this.doStopPublishTencentCDN(Ln);case 10:case"end":return c.stop()}},s,this)})),function(){return i.apply(this,arguments)})},{key:"doStopPublishTencentCDN",value:(r=N(m().mark(function s(c){var u,d,p,h,f;return m().wrap(function(_){for(;;)switch(_.prev=_.next){case 0:return u={requestTime:Date.now(),sessionId:ld("".concat(this.client_.getRoomId(),"_").concat(this.client_.getUserId(),"_").concat(c))},be.info("stopPublishTencentCDN: "+JSON.stringify(u)),_.next=4,this.signalChannel_.sendWaitForResponse({command:XV,data:u,timeout:5e3,responseCommand:ft.STOP_PUBLISH_TENCENT_CDN_RES,commandDesc:"stopPublishCDNStream"});case 4:if(d=_.sent,p=d.data,h=p.code,f=p.message,h!==0){_.next=10;break}this.resetPublishTencentParam(c),_.next=17;break;case 10:if(h!==-102069){_.next=15;break}be.warn("stopPublishTencentCDN failed, can not stopPublishTencentCDN in auto relayed-push mode"),this.resetPublishTencentParam(c),_.next=17;break;case 15:throw be.error("stopPublishTencentCDN failed, errCode: ".concat(h," errMsg: ").concat(f)),new $({code:Q.STOP_PUBLISH_CDN_FAILED,message:te({key:ik,data:{message:f},link:{className:"Client",fnName:"stopPublishCDNStream"}})});case 17:case"end":return _.stop()}},s,this)})),function(s){return r.apply(this,arguments)})},{key:"startPublishGivenCDN",value:(n=N(m().mark(function s(c){var u,d,p,h,f,_;return m().wrap(function(y){for(;;)switch(y.prev=y.next){case 0:if(u=c.streamType===Ye?this.publishTencentMainStreamObj_.streamId_:this.publishTencentAuxStreamObj_.streamId_,d={pushRequestTime:Date.now(),pushAppId:c.appId,pushBizId:c.bizId,pushCdnUrl:c.url,pushStreamType:c.streamType,pushStreamId:u},be.info("startPublishGivenCDN: "+JSON.stringify(d)),this.publishGivenCDNData_=d,this.isPublishingGivenCDN_=!0,this.client_.isJoined_){y.next=7;break}return y.abrupt("return");case 7:return y.prev=7,y.next=10,this.signalChannel_.sendWaitForResponse({command:YV,data:d,timeout:5e3,responseCommand:ft.START_PUBLISH_GIVEN_CDN_RES,commandDesc:"startPublishCDNStream"});case 10:if(p=y.sent,h=p.data,f=h.code,_=h.message,f===0){y.next=17;break}throw be.error("startPublishGivenCDN failed, errCode: ".concat(f,", errMsg: ").concat(_)),this.publishGivenCDNData_=null,this.isPublishingGivenCDN_=!1,new $({code:Q.START_PUBLISH_CDN_FAILED,message:te({key:rk,data:{message:_},link:{className:"Client",fnName:"startPublishCDNStream"}})});case 17:y.next=24;break;case 19:throw y.prev=19,y.t0=y.catch(7),this.publishGivenCDNData_=null,this.isPublishingGivenCDN_=!1,y.t0;case 24:case"end":return y.stop()}},s,this,[[7,19]])})),function(s){return n.apply(this,arguments)})},{key:"stopPublishGivenCDN",value:(t=N(m().mark(function s(){var c,u,d,p,h,f,_,y,S,E;return m().wrap(function(R){for(;;)switch(R.prev=R.next){case 0:if(this.client_.isJoined_){R.next=4;break}return this.publishGivenCDNData_=null,this.isPublishingGivenCDN_=!1,R.abrupt("return");case 4:return c=this.publishGivenCDNData_,u=c.pushAppId,d=c.pushBizId,p=c.pushCdnUrl,h=c.pushStreamType,f={pushRequestTime:Date.now(),pushAppId:u,pushBizId:d,pushCdnUrl:p,pushStreamType:h},be.info("stopPublishGivenCDN: "+JSON.stringify(f)),R.next=9,this.signalChannel_.sendWaitForResponse({command:$V,data:f,timeout:5e3,responseCommand:ft.STOP_PUBLISH_GIVEN_CDN_RES,commandDesc:"stopPublishCDNStream"});case 9:if(_=R.sent,y=_.data,S=y.code,E=y.message,S!==0){R.next=16;break}this.publishGivenCDNData_=null,this.isPublishingGivenCDN_=!1,R.next=18;break;case 16:throw be.error("stopPublishGivenCDN failed, errCode: ".concat(S," errMsg: ").concat(E)),new $({code:Q.STOP_PUBLISH_CDN_FAILED,message:te({key:ik,data:{message:E},link:{className:"Client",fnName:"stopPublishCDNStream"}})});case 18:case"end":return R.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={};Ft(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,Ye))),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,Ln))),u=JSON.stringify(d)}if(this.isPublishingGivenCDN_){var p=this.publishGivenCDNData_,h=p.pushAppId,f=p.pushBizId,_=p.pushCdnUrl,y=p.pushStreamType,S=p.pushStreamId;c={pushRequestTime:Date.now(),pushAppId:h,pushBizId:f,pushCdnUrl:_,pushStreamType:y,pushStreamId:S}}return{bussinessInfo:u,pushUserCdnInfo:c}}},{key:"reset",value:function(){this.resetPublishTencentParam(Ye),this.resetPublishTencentParam(Ln),this.publishGivenCDNData_=null,this.isPublishingGivenCDN_=!1}}]),e}(),ZF=function(){function e(t){z(this,e),this.client_=t.client,this.durationMap_=new Map,this.installEvents()}return ke(e,[{key:"installEvents",value:function(){W.on(Nr,this.handleSubscribed,this),W.on(Mn,this.handleStreamTrackUpdated,this),W.on(Vr,this.handleStreamStopped,this),W.on(Yi,this.handleStreamStopped,this)}},{key:"uninstallEvents",value:function(){W.off(Nr,this.handleSubscribed,this),W.off(Mn,this.handleStreamTrackUpdated,this),W.off(Vr,this.handleStreamStopped,this),W.off(Yi,this.handleStreamStopped,this)}},{key:"handleSubscribed",value:function(t){var n=t.client,r=t.stream;if(n===this.client_){var i=r.getUserId(),o=r.getType(),a="".concat(i,"_").concat(o);if(r.hasAudio())if(r.isMainAudioSubscribed){var s=new ud,c=this.durationMap_.get(a);c?this.isRecording(c.audio)||c.audio.push(s):this.durationMap_.set(a,{userId:i,type:o,audio:[s],video:[]})}else this.stopDurationItem(a,Ce);if(r.hasVideo())if(o===gt&&r.isMainVideoSubscribed||o===Pt&&r.isAuxVideoSubscribed){var u=new ud,d=this.durationMap_.get(a);d?this.isRecording(d.video)||d.video.push(u):this.durationMap_.set(a,{userId:i,type:o,audio:[],video:[u]})}else this.stopDurationItem(a,xe)}}},{key:"handleStreamStopped",value:function(t){var n=t.client,r=t.stream;if(this.clientHitTest(n)){var i=r.getUserId(),o=r.getType(),a="".concat(i,"_").concat(o);this.stopDurationItem(a,Ce),this.stopDurationItem(a,xe)}}},{key:"handleStreamTrackUpdated",value:function(t){var n=t.client,r=t.userId,i=t.tinyId,o=t.kind,a=t.action;if(this.clientHitTest(n)&&this.client_.getConnections().has(i)){var s=o===pt?o:gt,c="".concat(r,"_").concat(s);if(a===an.ADD){var u=this.client_.getConnections().get(i).getSubscribeState();if(o===Ce&&!u.audio||o===xe&&!u.video||o===pt&&!u.auxiliary)return;var d=new ud,p=this.durationMap_.get(c);p?(o!==Ce||this.isRecording(p.audio)||p.audio.push(d),o===Ce||this.isRecording(p.video)||p.video.push(d)):this.durationMap_.set(c,{userId:r,type:s,audio:o===Ce?[d]:[],video:o===Ce?[]:[d]})}else this.stopDurationItem(c,o===Ce?Ce: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 r=this.durationMap_.get(t)[n].find(function(i){return i.endTime===0});r&&r.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(r,i){return r+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}(),e7=Oe,t7=ie,n7=ph.f;e7({target:"Object",stat:!0,forced:t7(function(){return!Object.getOwnPropertyNames(1)})},{getOwnPropertyNames:n7});var oa=5e3,r7={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},rg=ke(function e(t){z(this,e),this.str_identifier=String(t.userId),this.uint64_tinyid=Number(t.tinyId),this.uint32_role=t.role}),i7=(zI=xc({timeout:500,retries:3}),Cc=function(){function e(i){var o=this;z(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_=be.createLogger({id:"kpm|"+this.client_.getUserId(),userId:this.client_.getUserId(),sdkAppId:this.client_.getSDKAppId()}),Object.getOwnPropertyNames(this.__proto__).forEach(function(a){a.startsWith("handle")&&kn(o[a])&&(o[a]=function(s){var c=s.fn,u=s.context;return N(m().mark(function d(){var p,h,f,_=arguments;return m().wrap(function(y){for(;;)switch(y.prev=y.next){case 0:for(y.prev=0,p=_.length,h=new Array(p),f=0;f<p;f++)h[f]=_[f];return y.next=4,c.apply(u||this,h);case 4:return y.abrupt("return",y.sent);case 7:y.prev=7,y.t0=y.catch(0),be.error("".concat(c.name,"() error observed ")+y.t0);case 10:case"end":return y.stop()}},d,this,[[0,7]])}))}({fn:o[a],context:o}))}),this.initData(),this.installEvents(),this.intervalId_=_t.run(Ja,this.setStorage.bind(this),{delay:2e4})}var t,n,r;return ke(e,[{key:"initData",value:function(){this.firstPublishedUserList_=[],this.networkQuality_={totalUplinkRTT:0,totalUplinkLoss:0,count:0,totalDownlinkRTTAndLossMap:new Map},this.basicInfo={string_sdk_version:Oi,uint32_os_type:15,string_device_name:"",string_http_user_agent:navigator.userAgent,string_os_version:"",uint32_avg_rtt:0,uint32_avg_up_loss:0,uint32_scene:this.client_.getMode()==="live"?1:0,uint32_joining_duration:0,uint32_networkType:tf[Af()],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(){W.on(pl,this.handleJoinStart,this),W.on(Gf,this.handleWSStart,this),W.on(fl,this.handleWSEnd,this),W.on(Mf,this.handleJoinSendCMD,this),W.on(Nf,this.handleJoinReceivedCMDResponce,this),W.on(Qa,this.handleJoinSuccess,this),W.on(Xa,this.handleJoinFailed,this),W.on(jf,this.handleReceivedPublishUserList,this),W.on(rm,this.handleConnectionStateChanged,this),W.on(Vf,this.handleLeaveStart,this),W.on(Ya,this.handleLeaveSuccess,this),W.on(Uf,this.handleLeaveSendCMD,this),W.on(im,this.handleSendSubscribeCMD,this),W.on(rc,this.handleVideoPlaying,this),W.on(Wf,this.handleAudioPlaying,this),W.on(am,this.handleNetworkQuality,this),W.on(Bf,this.handleHeartbeatStats,this),W.on(ml,this.handleRemoteStreamAdded,this),W.on(Jf,this.handleRemoteStreamSubscribeStart,this),W.on(Nr,this.handleRemoteStreamSubscribed,this),W.on(Yi,this.handleRemoteStreamRemoved,this),W.on($f,this.handleVideoLoadedData,this),W.on(Yf,this.handlePlayStream,this),W.on(Ff,this.handlePublishStart,this),W.on(qf,this.handleLocalStreamInitStart,this),W.on(Kf,this.handleLocalStreamInitEnd,this),W.on(Qf,this.handleLocalStreamInitFailed,this)}},{key:"uninstallEvents",value:function(){W.off(pl,this.handleJoinStart,this),W.off(Gf,this.handleWSStart,this),W.off(fl,this.handleWSEnd,this),W.off(Mf,this.handleJoinSendCMD,this),W.off(Nf,this.handleJoinReceivedCMDResponce,this),W.off(jf,this.handleReceivedPublishUserList,this),W.off(rm,this.handleConnectionStateChanged,this),W.off(Vf,this.handleLeaveStart,this),W.off(Ya,this.handleLeaveSuccess,this),W.off(Qa,this.handleJoinSuccess,this),W.off(Xa,this.handleJoinFailed,this),W.off(Uf,this.handleLeaveSendCMD,this),W.off(im,this.handleSendSubscribeCMD,this),W.off(rc,this.handleVideoPlaying,this),W.off(Wf,this.handleAudioPlaying,this),W.off(am,this.handleNetworkQuality,this),W.off(Bf,this.handleHeartbeatStats,this),W.off(ml,this.handleRemoteStreamAdded,this),W.off(Jf,this.handleRemoteStreamSubscribeStart,this),W.off(Nr,this.handleRemoteStreamSubscribed,this),W.off(Yi,this.handleRemoteStreamRemoved,this),W.off($f,this.handleVideoLoadedData,this),W.off(Yf,this.handlePlayStream,this),W.off(Ff,this.handlePublishStart,this),W.off(qf,this.handleLocalStreamInitStart,this),W.off(Kf,this.handleLocalStreamInitEnd,this),W.off(Qf,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 o=i.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(i){var o=i.client,a=i.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(),a&&(this.pathJoinRoom_.int32_send_request_acc_ip_cmd_ret=a instanceof $?Number(a.getExtraCode()||a.getCode()):Q.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 o=i.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(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 o=i.client,a=i.state,s=i.connection;if(this.hitTest(o)&&a===ln){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 o=i.client,a=i.stream;if(this.hitTest(o)){var s=a.getUserId(),c=a.getType(),u="".concat(s,"_").concat(c),d=this.remoteStreamStatsMap_.get(u);if(d)d.stream=a;else{var p={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:G({},r7),stream:a};p.statsToReport.msg_user_info=new rg({userId:s,tinyId:a.getTinyId(),role:za}),p.statsToReport.uint32_stream_type=c===gt?2:7,this.remoteStreamStatsMap_.set(u,p)}}}},{key:"handleRemoteStreamSubscribeStart",value:function(i){var o=i.client,a=i.stream;if(this.hitTest(o)){var s=a.getUserId(),c=a.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 o=new rg(i),a=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: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:i.userId,sendSubscribeCMDTime:a}),i.trackState.audio&&i.subscribeState.audio&&!this.pathMainAudioMap_.has(s)&&this.pathMainAudioMap_.set(s,{statsToReport:{msg_user_info:o,uint64_start_enter_time:this.pathJoinRoom_.uint64_start_time,uint64_play_first_frame_time:0},userId:i.userId,sendSubscribeCMDTime:a});var c="".concat(i.userId,"_").concat(Pt);i.trackState.auxiliary&&i.subscribeState.auxiliary&&!this.pathAuxiliaryMap_.has(c)&&this.pathAuxiliaryMap_.set(c,{sendSubscribeCMDTime:a})}}},{key:"handleRemoteStreamSubscribed",value:function(i){var o=i.client,a=i.stream;if(this.hitTest(o)){var s=a.getUserId(),c=a.getType(),u="".concat(s,"_").concat(c),d=this.remoteStreamStatsMap_.get(u);d&&d.subscribedTime===0&&(d.subscribedTime=Date.now(),d.stream=a)}}},{key:"handleRemoteStreamRemoved",value:function(i){var o=i.client,a=i.stream;if(this.hitTest(o)){var s=a.getUserId(),c=a.getType(),u=this.remoteStreamStatsMap_.get("".concat(s,"_").concat(c));u&&(u.stream=null)}}},{key:"handlePlayStream",value:function(i){var o=i.stream;if(o.isRemote()&&o.getConnection()&&this.hitTest(o.getConnection().getClient())){var a=o.getConnection().getUserId(),s="".concat(a,"_").concat(o.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 o=i.stream;if(o.isRemote()&&o.getConnection()&&this.hitTest(o.getConnection().getClient())){var a=o.getConnection().getUserId(),s="".concat(a,"_").concat(o.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 o=i.stream;if(o.isRemote()&&o.getConnection()&&this.hitTest(o.getConnection().getClient())){var a=o.getConnection().getUserId(),s="".concat(a,"_").concat(o.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),p=d.statsToReport,h=d.playStreamTime,f=d.subscribedTime;p.uint32_video_render_first===0&&h-f<=100&&(p.uint32_video_render_first=c-u.sendSubscribeCMDTime)}}if(o.getType()===Pt&&this.pathAuxiliaryMap_.has(s)&&this.remoteStreamStatsMap_.has(s)){var _=this.remoteStreamStatsMap_.get(s),y=_.statsToReport,S=_.playStreamTime,E=_.subscribedTime;y.uint32_video_render_first===0&&S-E<=100&&(y.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 o=i.stream.getConnection().getUserId(),a="".concat(o,"_").concat(i.stream.getType());if(this.pathMainAudioMap_.has(a)){var s=this.pathMainAudioMap_.get(a);s.statsToReport.uint64_play_first_frame_time===0&&(s.statsToReport.uint64_play_first_frame_time=Date.now())}}}},{key:"handleNetworkQuality",value:function(i){var o=this;this.hitTest(i.client)&&(this.networkQuality_.totalUplinkLoss+=i.uplinkLoss,this.networkQuality_.totalUplinkRTT+=i.uplinkRTT,this.networkQuality_.count++,i.downlinkLossAndRTTMap.forEach(function(a){var s=a.rtt,c=a.loss,u=a.userId,d=o.networkQuality_.totalDownlinkRTTAndLossMap.get(u);d?(d.totalRTT+=s,d.totalLoss+=c,d.count++):o.networkQuality_.totalDownlinkRTTAndLossMap.set(u,{totalRTT:s,totalLoss:c,count:1})}))}},{key:"handleHeartbeatStats",value:function(i){var o=this;if(this.hitTest(i.client)){var a=i.stats,s=a.msg_up_stream_info,c=a.msg_down_stream_info;if(s.msg_video_status[0]){var u=s.msg_video_status[0],d=u.uint32_video_codec_bitrate,p=u.uint32_video_enc_fps,h=u.uint32_video_width,f=u.uint32_video_height;this.localStreamStats_.totalVideoBitrate+=d,this.localStreamStats_.totalVideoFPS+=p,this.localStreamStats_.totalVideoWidth+=h,this.localStreamStats_.totalVideoHeight+=f,this.localStreamStats_.videoCount++}if(s.msg_audio_status){var _=s.msg_audio_status.audioLevel;Math.floor(100*_)>0&&(this.localStreamStats_.totalAudioLevel+=_,this.localStreamStats_.audioLevelCount++)}c.forEach(function(y){var S=y.msg_user_info,E=y.msg_audio_status,R=y.msg_video_status,H=S.str_identifier;if(R.forEach(function(O){var k=O.uint32_video_stream_type===2,P=O.uint32_video_stream_type===7,A="".concat(H,"_").concat(k?gt:Pt);if(o.remoteStreamStatsMap_.has(A)){var U,T,g=o.remoteStreamStatsMap_.get(A);(k&&(U=g.stream)!==null&&U!==void 0&&U.isMainVideoSubscribed||P&&(T=g.stream)!==null&&T!==void 0&&T.isAuxVideoSubscribed)&&(g.totalVideoFPS+=O.uint32_video_receive_fps,g.totalVideoBitrate+=O.uint32_video_codec_bitrate,g.videoCount++,g.statsToReport.uint32_video_width===0&&(g.statsToReport.uint32_video_width=O.uint32_video_width),g.statsToReport.uint32_video_height===0&&(g.statsToReport.uint32_video_height=O.uint32_video_height))}}),E){var Y="".concat(H,"_").concat(gt);if(o.remoteStreamStatsMap_.has(Y)){var ue,le=o.remoteStreamStatsMap_.get(Y);(ue=le.stream)!==null&&ue!==void 0&&ue.isMainAudioSubscribed&&(le.totalAudioBitrate+=E.uint32_audio_codec_bitrate,le.audioCount++,Math.floor(100*E.audioLevel)>0&&(le.totalAudioLevel+=E.audioLevel,le.audioLevelCount++))}}})}}},{key:"handlePublishStart",value:function(i){var o=i.client;this.hitTest(o)&&this.localStreamStats_.publishStartTime===0&&(this.localStreamStats_.publishStartTime=Date.now())}},{key:"handleLocalStreamInitStart",value:function(i){var o=i.audio,a=i.video;o&&this.pathJoinRoom_.uint64_init_audio_start_time===0&&(this.pathJoinRoom_.uint64_init_audio_start_time=Date.now()),a&&this.pathJoinRoom_.uint64_init_camera_start_time===0&&(this.pathJoinRoom_.uint64_init_camera_start_time=Date.now())}},{key:"handleLocalStreamInitEnd",value:function(i){var o=i.audio,a=i.video;o&&this.pathJoinRoom_.uint64_init_audio_end_time===0&&(this.pathJoinRoom_.uint64_init_audio_end_time=Date.now()),a&&this.pathJoinRoom_.uint64_init_camera_end_time===0&&(this.pathJoinRoom_.uint64_init_camera_end_time=Date.now())}},{key:"handleLocalStreamInitFailed",value:function(i){var o=i.audio,a=i.video,s=i.error,c=s instanceof $?s.getExtraCode()||s.getCode():{NotFoundError:1,NotAllowedError:2,NotReadableError:3,OverConstrainedError:4,AbortError:5}[s.name]||Q.UNKNOWN;o&&this.pathJoinRoom_.uint64_init_audio_end_time===0&&(this.pathJoinRoom_.int32_init_audio_ret=c,this.pathJoinRoom_.uint64_init_audio_end_time=Date.now()),a&&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(o){return o.userId===i&&1&o.flag})>=0}},{key:"hasAudioFlag",value:function(i){return this.firstPublishedUserList_.findIndex(function(o){return o.userId===i&&8&o.flag})>=0}},{key:"hasAuxFlag",value:function(i){return this.firstPublishedUserList_.findIndex(function(o){return o.userId===i&&4&o.flag})>=0}},{key:"hitTest",value:function(i){return i===this.client_}},{key:"checkStorage",value:(r=N(m().mark(function i(){var o;return m().wrap(function(a){for(;;)switch(a.prev=a.next){case 0:if(a.prev=0,!(o=no.getItem(this.storageKey_))){a.next=6;break}return a.next=5,this.upload(o);case 5:no.deleteItem(this.storageKey_);case 6:a.next=11;break;case 8:a.prev=8,a.t0=a.catch(0),this.log_.warn(a.t0);case 11:case"end":return a.stop()}},i,this,[[0,8]])})),function(){return r.apply(this,arguments)})},{key:"setStorage",value:function(){this.prepareReport();var i=this.getReportData();i.msg_path_enter_room.uint64_start_time!==0&&no.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 o=Math.floor(this.localStreamStats_.totalVideoWidth/this.localStreamStats_.videoCount),a=Math.floor(this.localStreamStats_.totalVideoHeight/this.localStreamStats_.videoCount);this.localStreamStats_.statsToReport.uint32_video_big_resolution=o<<16|a}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),p=d.totalLoss,h=d.count;s.statsToReport.uint32_avg_down_loss=Math.floor(p/h)}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 f=i.client_.getCallDurationCalculator();f&&(s.statsToReport.uint32_audio_play_time=f.getDuration(c,Ce),s.statsToReport.uint32_video_play_time=f.getDuration(c,xe)),s.statsToReport.uint32_video_render_first=Math.min(s.statsToReport.uint32_video_render_first,oa);var _=i.client_.getBadCaseDetector();if(_){var y=_.getDataFreezeDuration(c),S=y.dataFreeze,E=y.count,R=_.getRenderFreezeDuration(c).renderFreeze;s.statsToReport.uint32_video_block_count=E,s.statsToReport.uint32_video_block_time=Math.min(S,s.statsToReport.uint32_video_play_time),s.statsToReport.uint32_video_external_block_time=Math.min(R,s.statsToReport.uint32_video_play_time),_.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>oa&&(s.statsToReport.uint64_play_first_frame_time=s.statsToReport.uint64_start_enter_time+oa):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>oa&&(s.statsToReport.uint64_render_first_frame_time=s.statsToReport.uint64_start_enter_time+oa):i.pathMainVideoMap_.delete(c)}),this.pathJoinRoom_.uint64_end_time-this.pathJoinRoom_.uint64_start_time>oa&&(this.pathJoinRoom_.uint64_end_time=this.pathJoinRoom_.uint64_start_time+oa)}},{key:"getReportData",value:function(){var i=this.client_.getSignalInfo();return{uint32_sdk_app_id:Number(this.client_.getSDKAppId()),msg_user_info:new rg({userId:this.client_.getUserId(),tinyId:this.client_.getTinyId(),role:this.client_.getRole()===vr?za:qp}),msg_basic_info:this.basicInfo,uint32_acc_ip:Df(i.relayIp),uint32_client_ip:Df(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: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:Df(i.clientIp,"small"),error_code:[],msg_local_statistics:this.localStreamStats_.statsToReport}}},{key:"report",value:(n=N(m().mark(function i(){var o;return m().wrap(function(a){for(;;)switch(a.prev=a.next){case 0:return a.prev=0,o=this.getReportData(),a.next=4,this.upload(o);case 4:no.deleteItem(this.storageKey_),this.initData(),a.next=11;break;case 8:a.prev=8,a.t0=a.catch(0),this.log_.warn(a.t0);case 11:case"end":return a.stop()}},i,this,[[0,8]])})),function(){return n.apply(this,arguments)})},{key:"upload",value:(t=N(m().mark(function i(o){var a,s,c;return m().wrap(function(u){for(;;)switch(u.prev=u.next){case 0:if(!(Ka||o.msg_path_enter_room.uint64_start_time===0||[WS,RN,AN].findIndex(function(d){return d===location.host})>=0)){u.next=2;break}return u.abrupt("return");case 2:return a=Number(this.client_.getSDKAppId()),s=ll(a,cN),u.next=6,hl({url:s,body:JSON.stringify(o)});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}(),q(Cc.prototype,"upload",[zI],Object.getOwnPropertyDescriptor(Cc.prototype,"upload"),Cc.prototype),Cc);function Rc(){return function(e,t,n){var r=n.value,i=new Set;return n.value=N(m().mark(function o(){var a,s,c,u,d=arguments;return m().wrap(function(p){for(;;)switch(p.prev=p.next){case 0:if(!i.has(this)){p.next=2;break}throw new $({code:Q.INVALID_OPERATION,message:te({key:UN,data:{name:t}})});case 2:for(p.prev=2,i.add(this),a=d.length,s=new Array(a),c=0;c<a;c++)s[c]=d[c];return p.next=7,r.apply(this,s);case 7:return u=p.sent,i.delete(this),p.abrupt("return",u);case 12:throw p.prev=12,p.t0=p.catch(2),i.delete(this),p.t0;case 16:case"end":return p.stop()}},o,this,[[2,12]])})),n}}function a7(e){return ig.apply(this,arguments)}function ig(){return ig=N(m().mark(function e(t){var n,r,i,o,a,s,c,u,d,p,h,f,_;return m().wrap(function(y){for(;;)switch(y.prev=y.next){case 0:return n=t.userId,r=t.sdkAppId,i=t.useStringRoomId,o=t.roomId,a=t.userSig,s={delta:0,count:[1,1],msg:[]},y.prev=2,(c=new FormData).append("userId",String(n)),c.append("sdkAppId",String(r)),c.append("isStrGroupId",i),c.append("groupId",String(o)),c.append("sdkVersion",Oi),c.append("userSig",String(a)),Yu&&c.append("oversea",!0),u=Et(),y.next=14,s7(c,s,r);case 14:return d=y.sent,s.delta=Et()-u,WI({stat:s,userId:n}),y.abrupt("return",d);case 20:throw y.prev=20,y.t0=y.catch(2),p=Ak(y.t0)?y.t0[0]:y.t0,h=br(p.code)?p.code:0,f="get websocket url failed: ".concat(p.message.includes("timeout")?"timeout":p.message),_=new $({code:Q.SCHEDULE_FAILED,extraCode:h,message:te({key:tk,data:{error:f,code:h}})}),be.error(_),WI({stat:s,userId:n,roomId:o,error:_}),_;case 29:case"end":return y.stop()}},e,null,[[2,20]])})),ig.apply(this,arguments)}function WI(e){var t=e.stat,n=e.userId,r=e.error;r?Ie.logFailedEvent({eventType:VS,error:r,userId:n}):Ie.logSuccessEvent({eventType:VS,delta:t.delta,userId:n}),Ie.uploadEvent({log:"stat-schedule:"+JSON.stringify(t),userId:n})}function JI(e){var t,n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:Ye;return t=Yu?n===Ye?Yu:zS:Ek(e)?n===Ye?TN:xN:n===Ye?kN:zS,"https://".concat(t,"/api/v1/config")}function o7(e,t,n){return new Promise(function(r,i){hl({url:e,body:t,timeout:n.timeout}).then(function(o){o.data.code===0?r(o.data.data):i({code:o.data.code,message:o.data.msg})}).catch(i)})}var qI=function(e,t){return oc({retryFunction:o7,settings:{retries:3,timeout:0},onError:t,onRetrying:e})};function s7(e,t,n){return new Promise(function(r,i){var o,a=null;(o=[qI(function(s){return t.count[0]=s+1},function(s,c){t.msg[0]=s.message,a||c()})(JI(n,Ye),e,{get timeout(){return 1e3*dl(2+t.count[0])}}),qI(function(s){return t.count[1]=s+1},function(s,c){t.msg[1]=s.message,a||c()})(JI(n,Hi),e,{get timeout(){return 1e3*dl(2+t.count[1])}})],new Promise(function(s,c){var u=[];o.forEach(function(d){d.then(s).catch(function(p){u.push(p),u.length===o.length&&c(u)})})})).then(function(s){r(a=s)}).catch(i)})}var KI,QI,XI,YI,$I,ZI,ew,tw,nw,rw,iw,aw,ow,sw,cw,uw,et,c7=function(){function e(){z(this,e)}return ke(e,[{key:"call",value:function(t,n){return kn(this[t])?this[t](n):Promise.reject(new $({code:Q.INVALID_PARAMETER,message:te({key:h4,data:{name:t}})}))}},{key:"updatePrivateMapKey",value:function(t){var n=t.privateMapKey;return t.client.setProperty("privateMapKey",n),Promise.resolve()}}]),e}(),u7=new c7,dd,hd,pd,ag,lw,dw,bi,l7=(KI=Rc(),QI=Tn(Jt.CLIENT.join),XI=Rc(),YI=xc({retries:3}),$I=Rc(),ZI=Tn.apply(void 0,Se(Jt.CLIENT.publish)),ew=Rc(),tw=Tn(Jt.CLIENT.unpublish),nw=Tn.apply(void 0,Se(Jt.CLIENT.subscribe)),rw=Tn(Jt.CLIENT.unsubscribe),iw=Rc(),aw=Tn(Jt.CLIENT.switchRole),ow=Tn(Jt.CLIENT.startPublishCDNStream),sw=Tn(Jt.CLIENT.startMixTranscode),cw=$l.apply(void 0,Se(Jt.CLIENT.sendSEIMessage)),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,ag=dd.getSize,uw=function(e,t,n){var r=n.value,i=new Map;return W.on(Hf,function(o){var a=o.client;return i.delete(a)}),n.value=function(){var o=i.get(this);o||(o={callCountInSecond:0,timestamp:0,totalSizeInSecond:0},i.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 a=arguments.length,s=new Array(a),c=0;c<a;c++)s[c]=arguments[c];if(ag&&(o.totalSizeInSecond+=ag.apply(void 0,s)),o.timestamp!==0&&Date.now()-o.timestamp<1e3&&(o.callCountInSecond>=hd||o.totalSizeInSecond>pd))throw new $({code:Q.INVALID_OPERATION,message:te({key:b4,data:{isTimes:o.callCountInSecond>=hd,isSize:o.totalSizeInSecond>pd,name:t,timesInSecond:hd,maxSizeInSecond:pd}})});return o.callCountInSecond++,r.apply(this,s)},n},et=function(){function e(T){var g,I;z(this,e),this.name_=EN,this.mode_=T.mode,this.sdpSemantics_=Zp,fe(T.sdpSemantics)?function(){var w;if(fe(window.RTCRtpTransceiver)||!("currentDirection"in RTCRtpTransceiver.prototype))return!1;var L=null,B=!1;try{(L=new RTCPeerConnection({sdpSemantics:Zs})).addTransceiver(Ce),B=!0}catch(ee){}return(w=L)===null||w===void 0||w.close(),B}()&&(this.sdpSemantics_=Zs):this.sdpSemantics_=T.sdpSemantics,this.sdkAppId_=T.sdkAppId,this.userId_=T.userId,this.log_=be.createLogger({id:"c".concat(T.seq,"|").concat(this.userId_),userId:this.userId_,sdkAppId:this.sdkAppId_}),this.userSig_=T.userSig,this.roomId_=0,this.useStringRoomId_=T.useStringRoomId||!1,this.pureAudioPushMode_=null,this.version_=T.version,this.log_.info("using sdpSemantics: "+this.sdpSemantics_),this.signalChannel_=null,this.role_=vr,this.privateMapKey_="",this.tinyId_=0,this.env_="",this.proxy_=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_=Nk(new pi,this.name_),this.isJoined_=!1,this.heartbeat_=-1,this.lastHeartBeatTime_=-1,this.stats_=new m6(this),this.joinTimeout_=-1,this.changeBigSmallRecords_=new Map,this.networkQuality_=null,this.badCaseDetector_=null,this.networkType_=Af(),this.autoSubscribe_=!!fe(T.autoSubscribe)||T.autoSubscribe,this.joinedTimestamp_=0,this.joinOptions_={},this.basis_=(I={browser:Ki().name+"/"+Ki().version,os:Pm(),displayResolution:o6(),isScreenShareSupported:AT(),isWebRTCSupported:xm(),isGetUserMediaSupported:s6(),isWebAudioSupported:c6(),isWebSocketsSupported:"WebSocket"in window&&window.WebSocket.CLOSING===2,isWebCodecSupported:(g={AudioDecoder:!1,AudioEncoder:!1,VideoDecoder:!1,VideoEncoder:!1,ImageDecoder:!1},fe(window.AudioDecoder)||(g.AudioDecoder=!0),fe(window.AudioEncoder)||(g.AudioEncoder=!0),fe(window.VideoDecoder)||(g.VideoDecoder=!0),fe(window.VideoEncoder)||(g.VideoEncoder=!0),fe(window.ImageDecoder)||(g.ImageDecoder=!0),g),isMediaSessionSupported:"mediaSession"in navigator&&!fe(navigator.mediaSession.setActionHandler),isWebTransportSupported:!fe(window.WebTransport)},navigator.userAgent.includes("miniProgram")&&(I.browser="mini/".concat(I.browser)),I),this.initBussinessInfo_(T),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 $F({client:this}),this.keyPointManager_=new i7({client:this,frameWorkType:T.frameWorkType,component:T.component}),this.isPublishing_=!1,this.isEnableSmallStream_=!1,this.smallStreamConfig_={bitrate:100,frameRate:15,height:120,width:160},this.turnServers_=[],this.iceTransportPolicy_=T.iceTransportPolicy,this.schedule_={domains:null,iceServers:null,iceTransportPolicy:null,trtcCapability:null},this.enableAutoPlayDialog_=!!fe(T.enableAutoPlayDialog)||T.enableAutoPlayDialog,this.enableMultiAuxStream_=!fe(T.enableMultiAuxStream)&&T.enableMultiAuxStream,this.signalInfo_={},this.enableSEI_=!fe(T.enableSEI)&&T.enableSEI,this.isDestroyed_=!1}var t,n,r,i,o,a,s,c,u,d,p,h,f,_,y,S,E,R,H,Y,ue,le,O,k,P,A,U;return ke(e,[{key:"initBussinessInfo_",value:function(T){this.bussinessInfo_=T.bussinessInfo;var g={};if(Ft(T.bussinessInfo)&&(g=JSON.parse(T.bussinessInfo)),!fe(T.pureAudioPushMode)){if(!Number.isInteger(Number(T.pureAudioPushMode)))throw new $({code:Q.INVALID_PARAMETER,message:te({key:XN})});this.pureAudioPushMode_=T.pureAudioPushMode,g.Str_uc_params||(g.Str_uc_params={}),g.Str_uc_params.pure_audio_push_mod=this.pureAudioPushMode_}if(!fe(T.streamId)){if(!(Ft(T.streamId)&&String(T.streamId)&&String(T.streamId).length<=64))throw new $({code:Q.INVALID_PARAMETER,message:te({key:YN})});g.Str_uc_params||(g.Str_uc_params={}),g.Str_uc_params.userdefine_streamid_main=T.streamId}if(!fe(T.userDefineRecordId)){if(T.userDefineRecordId.match(/^[A-Za-z0-9_-]{1,64}$/gi)===null)throw new $({code:Q.INVALID_PARAMETER,message:te({key:$N})});g.Str_uc_params||(g.Str_uc_params={}),g.Str_uc_params.userdefine_record_id=T.userDefineRecordId}if(!fe(T.userDefinePushArgs)){if(!(Ft(T.userDefinePushArgs)&&String(T.userDefinePushArgs)&&String(T.userDefinePushArgs).length<=256))throw new $({code:Q.INVALID_PARAMETER,message:te({key:ZN})});g.Str_uc_params||(g.Str_uc_params={}),g.Str_uc_params.userdefine_push_args=T.userDefinePushArgs}$i(g)||(this.bussinessInfo_=JSON.stringify(g))}},{key:"schedule",value:(U=N(m().mark(function T(g){var I;return m().wrap(function(w){for(;;)switch(w.prev=w.next){case 0:return w.next=2,a7({userId:this.userId_,sdkAppId:this.sdkAppId_,roomId:g,useStringRoomId:this.useStringRoomId_,version:this.version_,userSig:this.userSig_});case 2:(I=w.sent)&&(this.log_.info("schedule: ".concat(JSON.stringify(I))),I.trtcCapability=I==null?void 0:I.trtcAutoConf,this.schedule_=G(G({},this.schedule_),I),W.emit(jk,this.schedule_));case 4:case"end":return w.stop()}},T,this)})),function(T){return U.apply(this,arguments)})},{key:"getSignalChannelUrl",value:function(){var T={mainUrl:"",backupUrl:""},g=wk();return g?T.mainUrl=T.backupUrl="wss://".concat(g,".rtc.qq.com"):this.proxy_?T.mainUrl=T.backupUrl=this.proxy_:Array.isArray(this.schedule_.domains)&&this.schedule_.domains.length>0&&(T.mainUrl=T.backupUrl="wss://".concat(this.schedule_.domains[0]),this.schedule_.domains[1]&&(T.backupUrl="wss://".concat(this.schedule_.domains[1]))),T}},{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(){var T=this;this.log_.info("setup signal channel");var g=this.getSignalChannelUrl(),I=g.mainUrl,w=g.backupUrl;return this.signalChannel_=new VU({sdkAppId:this.sdkAppId_,userId:this.userId_,userSig:this.userSig_,url:I,backupUrl:w,client:this}),this.networkQuality_||(this.networkQuality_=new v6({connections:this.connections_,signalChannel:this.signalChannel_,userId:this.userId_,client:this}),this.networkQuality_.on(ot.NETWORK_QUALITY,function(L){T.emitter_.emit(ot.NETWORK_QUALITY,L)})),this.deviceDetector_||(this.deviceDetector_=new g6({client:this})),this.subscriptionManager_||(this.subscriptionManager_=new yF({client:this})),this.badCaseDetector_||(this.badCaseDetector_=new XF({client:this,stats:this.stats_})),this.callDurationCalculator_||(this.callDurationCalculator_=new ZF({client:this})),this.mixTranscodeManager_||(this.mixTranscodeManager_=new YF({client:this,signalChannel:this.signalChannel_})),this.publishCDNManager_&&this.publishCDNManager_.setSignalChannel({signalChannel:this.signalChannel_}),this.signalChannel_.on(dm,function(L){T.log_.info("SignalChannel state changed from ".concat(L.prevState," to ").concat(L.state)),T.emitter_.emit(ot.CONNECTION_STATE_CHANGED,L)}),this.signalChannel_.on(hm,function(L){T.reset(),T.emitter_.emit(ot.ERROR,L)}),this.signalChannel_.once(oT,function(L){T.tinyId_=L.signalInfo.tinyId,W.emit(fl,{client:T})}),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(L){Date.now()-T.lastHeartBeatTime_>=1e4&&T.doHeartbeat(),W.emit(jf,{client:T,data:L.data}),T.onPublishedUserList(L.data),T.onUpdateRemoteMuteStat(L.data)}),this.signalChannel_.on(ft.CLIENT_BANNED,function(L){var B,ee=L.data.data.reason;if(Ie.uploadEvent({log:"stat-banned:".concat(ee),userId:T.userId_}),ee===$M)B="you got banned by the admin";else if(ee===ZM)B="duplicated userId joining the room";else if(ee===tN)B="the room has been disbanded by the admin",ee=ee.replace("_","-");else if(ee===eN)return T.log_.warn("".concat(ee," last heart beat time: ").concat(T.lastHeartBeatTime_," interval: ").concat(Date.now()-T.lastHeartBeatTime_,", visibility: ").concat(document.visibilityState)),void T.reJoin();T.log_[ee==="kick"?"error":"info"]("user was banned because of [".concat(ee,"]")),T.reset(),T.emitter_.emit(ot.CLIENT_BANNED,{reason:ee,message:te({key:g3,data:{message:B,reason:ee}})||ee})}),W.emit(Gf,{client:this}),this.signalChannel_.connect()}},{key:"preJoin",value:(A=N(m().mark(function T(g){var I,w,L,B;return m().wrap(function(ee){for(;;)switch(ee.prev=ee.next){case 0:return this.joinOptions_=g,ee.next=3,wm();case 3:if(this.checkSystemResult_=ee.sent,this.checkDestroy(),(I=wk())||(I=Ju,this.proxy_&&(this.proxy_.startsWith(rN)?I=aN:this.proxy_.startsWith(iN)&&(I=oN))),this.env_=I,Ie.setConfig({env:I,sdkAppId:this.sdkAppId_,userId:this.userId_,roomId:g.roomId}),this.uploadTrtcStats(),w=this.checkSystemResult_.detail,L=w.isH264EncodeSupported,B=w.isVp8EncodeSupported,xm()&&(L||B)){ee.next=13;break}throw new $({code:Q.NOT_SUPPORTED,message:te({key:ck})});case 13:case"end":return ee.stop()}},T,this)})),function(T){return A.apply(this,arguments)})},{key:"join",value:(P=N(m().mark(function T(g){var I,w=this;return m().wrap(function(L){for(;;)switch(L.prev=L.next){case 0:return this.roomId_=g.roomId,fe(g.role)||(this.role_=g.role),fe(g.privateMapKey)||(this.privateMapKey_=g.privateMapKey),I=Et(),W.emit(pl,{client:this}),dn(this.userId_,{eventId:gU,eventDesc:"joining room",timestamp:tn(),userId:this.userId_,tinyId:this.tinyId_}),L.next=8,this.preJoin(g);case 8:return L.abrupt("return",new Promise(function(){var B=N(m().mark(function ee(oe,ve){return m().wrap(function(ge){for(;;)switch(ge.prev=ge.next){case 0:if(w.joinReject_=ve,ge.prev=1,w.proxy_||w.schedule_.domains){ge.next=5;break}return ge.next=5,w.schedule(g.roomId);case 5:return w.checkDestroy(),ge.next=8,w.initialize(g);case 8:return ge.next=10,w.doJoin(g);case 10:w.signalInfo_=w.signalChannel_.getSignalInfo(),W.emit(Qa,{client:w}),w.joinedTimestamp_=Et(),Ie.logSuccessEvent({userId:w.userId_,eventType:vN,delta:w.joinedTimestamp_-I}),Ie.logSuccessEvent({userId:w.userId_,eventType:yS}),Ie.uploadEvent({log:"stat-autoplay-dialog:".concat(w.enableAutoPlayDialog_),userId:w.userId_}),Ie.uploadEvent({log:"stat-conv-".concat(Ka,"-").concat(location.hostname),userId:w.userId_}),oe(),ge.next=26;break;case 20:ge.prev=20,ge.t0=ge.catch(1),W.emit(Xa,{client:w,error:ge.t0}),Ie.logFailedEvent({userId:w.userId_,eventType:yS,error:ge.t0}),w.reset(),ve(ge.t0);case 26:w.joinReject_=null;case 27:case"end":return ge.stop()}},ee,null,[[1,20]])}));return function(ee,oe){return B.apply(this,arguments)}}()));case 9:case"end":return L.stop()}},T,this)})),function(T){return P.apply(this,arguments)})},{key:"checkDestroy",value:function(){if(this.isDestroyed_)throw new $({code:Q.INVALID_OPERATION,message:te({key:cf,data:{funName:"join"}})})}},{key:"uploadTrtcStats",value:(k=N(m().mark(function T(){var g,I,w,L,B,ee,oe,ve,ge,qe,Ne,Ge,Je;return m().wrap(function(ze){for(;;)switch(ze.prev=ze.next){case 0:return ze.prev=0,ze.next=3,It.getMicrophones();case 3:w=ze.sent,g=w&&w.length,ze.next=9;break;case 7:ze.prev=7,ze.t0=ze.catch(0);case 9:return ze.prev=9,ze.next=12,It.getCameras();case 12:L=ze.sent,I=L&&L.length,ze.next=18;break;case 16:ze.prev=16,ze.t1=ze.catch(9);case 18:B={microphone:g,camera:I},ee=this.checkSystemResult_.detail,oe=ee.isH264EncodeSupported,ve=ee.isVp8EncodeSupported,ge=ee.isH264DecodeSupported,qe=ee.isVp8DecodeSupported,Ne={webRTC:this.basis_.isWebRTCSupported,getUserMedia:this.basis_.isGetUserMediaSupported,webSocket:this.basis_.isWebSocketsSupported,screenShare:this.basis_.isScreenShareSupported,webAudio:this.basis_.isWebAudioSupported,h264Encode:oe,h264Decode:ge,vp8Encode:ve,vp8Decode:qe},Ge={browser:this.basis_.browser,os:this.basis_.os,trtc:Ne,devices:B},Je={isWebCodecSupported:this.basis_.isWebCodecSupported,isMediaSessionSupported:this.basis_.isMediaSessionSupported,isWebTransportSupported:this.basis_.isWebTransportSupported},Ie.uploadEvent({log:"trtcstats-"+JSON.stringify(Ge),userId:this.userId_}),this.log_.info("TrtcStats-"+JSON.stringify(Ge)),Ie.uploadEvent({log:"trtcadvancedstats-"+JSON.stringify(Je),userId:this.userId_});case 26:case"end":return ze.stop()}},T,this,[[0,7],[9,16]])})),function(){return k.apply(this,arguments)})},{key:"doJoin",value:function(T){var g=this;return new Promise(function(I,w){g.log_.info("Join() => joining room: ".concat(g.roomId_," useStringRoomId: ").concat(g.useStringRoomId_," mode: ").concat(g.mode_," role: ").concat(g.role_));var L={roomId:String(g.roomId_),useStringRoomId:g.useStringRoomId_,privateMapKey:g.privateMapKey_,trtcRole:g.role_===vr?za:qp,trtcScene:g.mode_===qu?dN:lN,sdpSemantics:g.sdpSemantics_,version:Q4(g.version_),ua:navigator&&navigator.userAgent||"",autoSubscribe:g.autoSubscribe_,terminalType:qa?4:pf?2:hf?3:tc?12:kk?5:Tk?13:1,netType:tf[Af()],bussinessInfo:g.bussinessInfo_};if(g.publishCDNManager_){var B=g.publishCDNManager_.handleCDNConfigForJoinData(g.bussinessInfo_),ee=B.bussinessInfo,oe=B.pushUserCdnInfo;Object.assign(L,{bussinessInfo:ee,pushUserCdnInfo:oe})}g.log_.debug("join room signal data: ".concat(JSON.stringify(L))),g.joinTimeout_=setTimeout(function(){g.log_.error("join room timeout observed"),w(new $({code:Q.JOIN_ROOM_FAILED,message:te({key:i3})}))},5e3),W.emit(Mf,{client:g}),g.signalChannel_.once(sT,function(ve){g.clearJoinTimeout(),W.emit(fl,{client:g,error:ve}),w(ve)}),g.signalChannel_.send(FV,L),g.signalChannel_.once(ft.JOIN_ROOM_RESULT,function(ve){g.clearJoinTimeout();var ge=ve.data,qe=ge.code,Ne=ge.message,Ge=ge.data;g.onPublishedUserList({data:{userList:Ge.publishers}}),W.emit(Nf,{client:g,code:qe}),qe===0?(g.isJoined_=!0,g.log_.info("Join room success, start heartbeat"),g.startHeartbeat(),g.badCaseDetector_&&g.badCaseDetector_.start(),g.syncUserList(),g.startSyncUserListInterval(),I()):(g.log_.error("Join room failed result: "+qe+" error: "+Ne),w(new $({code:Q.JOIN_ROOM_FAILED,extraCode:qe,message:te({key:tk,data:{error:Ne,code:qe}})})))})})}},{key:"reJoin",value:(O=N(m().mark(function T(){return m().wrap(function(g){for(;;)switch(g.prev=g.next){case 0:if(this.isJoined_){g.next=3;break}return this.log_.warn("reJoin abort"),g.abrupt("return");case 3:return this.isJoined_=!1,g.prev=4,this.log_.warn("reJoin pending: ".concat(this.joinOptions_.roomId)),this.subscriptionManager_&&this.subscriptionManager_.markAllStream(),this.signalChannel_.close(),g.next=10,this.signalChannel_.connect();case 10:return g.next=12,this.doJoin(G(G({},this.joinOptions_),{},{role:this.role_,privateMapKey:this.privateMapKey_}));case 12:this.log_.warn("reJoin success"),Ie.logSuccessEvent({userId:this.userId_,eventType:bS}),this.checkConnectionsToReconnect(),this.uplinkConnection_&&!this.uplinkConnection_.getIsReconnecting()&&this.uplinkConnection_.startReconnection(),this.mixTranscodeManager_&&this.mixTranscodeManager_.reStartMixTranscode(),g.next=25;break;case 19:g.prev=19,g.t0=g.catch(4),this.log_.warn("reJoin fail "+g.t0),this.reset(),Ie.logFailedEvent({userId:this.userId_,eventType:bS,error:g.t0}),this.emitter_.emit(ot.ERROR,new $({code:Q.JOIN_ROOM_FAILED,message:te({key:a3,data:{roomId:this.joinOptions_.roomId}})}));case 25:case"end":return g.stop()}},T,this,[[4,19]])})),function(){return O.apply(this,arguments)})},{key:"leave",value:(le=N(m().mark(function T(){var g;return m().wrap(function(I){for(;;)switch(I.prev=I.next){case 0:return W.emit(Vf,{client:this}),dn(this.userId_,{eventId:_U,eventDesc:"leaving room",timestamp:tn(),userId:this.userId_,tinyId:this.tinyId_}),I.prev=2,I.next=5,this.doHeartbeat();case 5:I.next=9;break;case 7:I.prev=7,I.t0=I.catch(2);case 9:this.doLeave(),W.emit(Ya,{client:this}),Ie.logSuccessEvent({userId:this.userId_,eventType:gN}),g=Math.floor((Et()-this.joinedTimestamp_)/1e3),Ie.logSuccessEvent({userId:this.userId_,eventType:_N,delta:g});case 14:case"end":return I.stop()}},T,this,[[2,7]])})),function(){return le.apply(this,arguments)})},{key:"doLeave",value:function(){this.isJoined_&&(W.emit(Uf,{client:this}),this.log_.info("leave() => leaving room"),this.signalChannel_.send(GV),this.reset())}},{key:"clearNetworkQuality",value:function(){this.networkQuality_&&(this.networkQuality_.stop(),this.networkQuality_=null)}},{key:"closeConnections",value:function(){var T=this;this.connections_.forEach(function(g){T.closeDownLink(g.getTinyId())})}},{key:"clearJoinTimeout",value:function(){clearTimeout(this.joinTimeout_),this.joinTimeout_=-1}},{key:"destroy",value:function(){var T,g,I;if(this.isJoined_)throw this.log_.warn(di.INVALID_DESTROY),new $({code:Q.INVALID_OPERATION,message:te({key:o3})});this.isDestroyed_||(this.log_.info("destroy client"),this.joinReject_&&(this.joinReject_(new $({code:Q.INVALID_OPERATION,message:te({key:cf,data:{funName:"join"}})})),this.clearJoinTimeout(),this.reset()),this.off("*"),(T=this.callDurationCalculator_)===null||T===void 0||T.destroy(),(g=this.keyPointManager_)===null||g===void 0||g.destroy(),(I=this.deviceDetector_)===null||I===void 0||I.destroy(),this.callDurationCalculator_=null,this.keyPointManager_=null,this.deviceDetector_=null,this.badCaseDetector_=null,this.publishCDNManager_=null,this.isDestroyed_=!0,W.emit(Hf,{client:this}))}},{key:"reset",value:function(){this.isJoined_=!1,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(Ja,this.syncUserList.bind(this)))}},{key:"stopSyncUserListInterval",value:function(){_t.clearTask(this.syncUserListInterval_),this.syncUserListInterval_=-1}},{key:"syncUserList",value:(ue=N(m().mark(function T(){var g,I=this;return m().wrap(function(w){for(;;)switch(w.prev=w.next){case 0:return w.prev=0,w.next=3,this.getUserList();case 3:g=w.sent,this.userMap_.size!==0&&this.userMap_.forEach(function(L){g.findIndex(function(B){return B.userId===L.userId})<0&&(I.log_.info("peer leave detected: ".concat(L.userId)),I.cleanUser({userId:L.userId,tinyId:L.tinyId}))}),g.forEach(function(L){var B=L.userId;I.userMap_.has(B)||B===I.userId_||(I.userMap_.set(B,L),I.emitter_.emit(ot.PEER_JOIN,{userId:B}))}),w.next=11;break;case 8:w.prev=8,w.t0=w.catch(0),this.log_.warn("sync user list failed: "+w.t0);case 11:case"end":return w.stop()}},T,this,[[0,8]])})),function(){return ue.apply(this,arguments)})},{key:"getUserList",value:function(){return this.signalChannel_?this.signalChannel_.sendWaitForResponse({command:tU,responseCommand:ft.USER_LIST_RES,enableLog:!1,timeout:2e3}).then(function(T){var g=T.data,I=g.code,w=g.message;if(I===0)return(g.data&&g.data.userList||[]).map(function(L){var B=L.userId,ee=L.srcTinyId,oe=L.role;return new ng({userId:B,tinyId:ee,role:oe})});throw te({key:dk,data:{signalResponse:ft.USER_LIST_RES,code:I,message:w}})}):[]}},{key:"publish",value:(Y=N(m().mark(function T(g){var I,w,L,B,ee,oe,ve,ge,qe=this,Ne=arguments;return m().wrap(function(Ge){for(;;)switch(Ge.prev=Ge.next){case 0:return I=Ne.length>1&&Ne[1]!==void 0?Ne[1]:{isAuxiliary:!1},g.setPublishState(ec),this.isPublishing_=!0,w=Et(),W.emit(Ff,{client:this,stream:g}),L=I.isAuxiliary,B=L?pt:Ye,ee=g.getScreen(),this.log_.info("publish() => publishing ".concat(ee?Hp+" ":"").concat(B," stream ").concat(g.getId())),oe=this.uplinkConnection_,Ge.prev=10,oe||((oe=new EF({userId:this.userId_,tinyId:this.tinyId_,client:this,isUplink:!0,signalChannel:this.signalChannel_,enableSEI:this.enableSEI_})).initialize(),oe.on(rt.ERROR,function(Je){var ze=Je.getCode();ze!==Q.ICE_TRANSPORT_ERROR&&(ze===Q.UPLINK_RECONNECTION_FAILED&&qe.closeUplink(),qe.emitter_.emit(ot.ERROR,Je))})),g.setConnection(oe),Ge.next=15,oe.publish(g,L);case 15:this.log_.info("local ".concat(ee?Hp+" ":"").concat(B," stream is published")),this.isPublishing_=!1,L?this.localAuxStream_=g:(this.localStream_=g,this.deviceDetector_&&this.deviceDetector_.setLocalStream(this.localStream_),this.localStream_.getBeautyStatus()&&this.log_.info("beauty stream is published successfully")),g.setPublishState(SN),g.setClient(this,L),this.uplinkConnection_=oe,ve=Et(),ge=ve-w,Ie.logSuccessEvent({userId:this.userId_,eventType:SS}),Ie.logSuccessEvent({userId:this.userId_,eventType:yN,delta:ge}),g.hasAudio()&&dn(this.userId_,{eventId:dT,eventDesc:"publish audio track",timestamp:tn(),userId:this.userId_,tinyId:this.tinyId_}),g.hasVideo()&&dn(this.userId_,{eventId:lT,eventDesc:"publish video track",timestamp:tn(),userId:this.userId_,tinyId:this.tinyId_}),this.networkQuality_&&this.networkQuality_.setUplinkConnection(this.uplinkConnection_),W.emit($4,{localStream:g,isAuxiliary:L,client:this}),this.notPublishWithoutH264Supported_=!1,Ge.next=41;break;case 32:throw Ge.prev=32,Ge.t0=Ge.catch(10),Ge.t0 instanceof $&&Ge.t0.getCode()===Q.NOT_SUPPORTED_H264&&(this.notPublishWithoutH264Supported_=!0),g.setPublishState(jS),oe.close(),this.log_.error("failed to publish stream "+Ge.t0),this.isPublishing_=!1,Ie.logFailedEvent({userId:this.userId_,eventType:SS,error:Ge.t0}),Ge.t0;case 41:case"end":return Ge.stop()}},T,this,[[10,32]])})),function(T){return Y.apply(this,arguments)})},{key:"unpublish",value:(H=N(m().mark(function T(g){var I,w;return m().wrap(function(L){for(;;)switch(L.prev=L.next){case 0:if(this.uplinkConnection_){L.next=2;break}return L.abrupt("return");case 2:return I=g===this.localAuxStream_,w=g.getScreen(),this.log_.info("unpublish() => unpublishing local ".concat(w?Hp+" ":"").concat(I?pt:Ye," stream")),L.prev=5,L.next=8,this.uplinkConnection_.unpublish(g);case 8:g.setClient(null),g.setConnection(null),I?this.localAuxStream_=null:(this.localStream_=null,g.hasAudio()&&dn(this.userId_,{eventId:pT,eventDesc:"unpublish audio track",timestamp:tn(),userId:this.userId_,tinyId:this.tinyId_}),g.hasVideo()&&dn(this.userId_,{eventId:hT,eventDesc:"unpublish video track",timestamp:tn(),userId:this.userId_,tinyId:this.tinyId_})),this.localStream_||this.localAuxStream_||this.closeUplink(),Ie.logSuccessEvent({userId:this.userId_,eventType:kS}),L.next=19;break;case 15:throw L.prev=15,L.t0=L.catch(5),Ie.logFailedEvent({userId:this.userId_,eventType:kS,error:L.t0}),L.t0;case 19:case"end":return L.stop()}},T,this,[[5,15]])})),function(T){return H.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(T){var g=this.connections_.get(T);g&&(g.getIsReconnecting()&&g.stopReconnection(),this.subscriptionManager_&&this.subscriptionManager_.delete(g.getUserId()),g.close(),this.connections_.delete(T),this.mutedStates_.delete(T))}},{key:"subscribe",value:(R=N(m().mark(function T(g,I){var w,L,B;return m().wrap(function(ee){for(;;)switch(ee.prev=ee.next){case 0:return this.log_.info("subscribe() => subscribe to [".concat(g.getUserId(),"] ").concat(g.getType()," stream with options: ").concat(JSON.stringify(I))),fe(I)&&(I={audio:!0,video:!0}),fe(I.audio)&&(I.audio=!0),fe(I.smallVideo)?fe(I.video)&&(I.video=!0):I.smallVideo?fe(I.video)?(I.video=!1,I.smallVideo=!0):I.video&&(I.video=!0,delete I.smallVideo,this.log_.warn("options.video and options.smallVideo can't be both true")):fe(I.video)&&(I.video=!0,delete I.smallVideo),I.video&&this.changeBigSmallRecords_.delete(g.getUserId()),w=g.getConnection(),I.smallVideo&&(w.getTrackState().smallVideo||(this.setRemoteVideoStreamType(g,"small"),I.video=!0,delete I.smallVideo)),ee.prev=7,W.emit(Jf,{client:this,stream:g}),ee.next=11,w.subscribe(g,I);case 11:this.subscriptionManager_&&this.subscriptionManager_.addSubscriptionRecord(g.getUserId(),g,I),this.notSubscribeWithoutH264Supported_=!1,Ie.logSuccessEvent({userId:this.userId_,eventType:TS}),ee.next=24;break;case 16:throw ee.prev=16,ee.t0=ee.catch(7),(L=ee.t0 instanceof $?ee.t0.getCode():Q.UNKNOWN)===Q.NOT_SUPPORTED_H264&&(this.notSubscribeWithoutH264Supported_=!0),(B=new $(L===Q.REMOTE_STREAM_NOT_EXIST?{code:Q.API_CALL_ABORTED,message:te({key:df,data:{message:ee.t0.message,stream:g}})}:{code:L,message:te({key:h3,data:{message:ee.t0.message,stream:g}})})).getCode()===Q.API_CALL_ABORTED?this.log_.warn(B):this.log_.error(B),Ie.logFailedEvent({userId:this.userId_,eventType:TS,error:B}),B;case 24:case"end":return ee.stop()}},T,this,[[7,16]])})),function(T,g){return R.apply(this,arguments)})},{key:"unsubscribe",value:(E=N(m().mark(function T(g){var I;return m().wrap(function(w){for(;;)switch(w.prev=w.next){case 0:return this.log_.info("unsubscribe() => unsubscribe to [".concat(g.getUserId(),"] ").concat(g.getType()," stream")),w.prev=1,I=g.getConnection(),w.next=5,I.unsubscribe(g);case 5:this.subscriptionManager_&&this.subscriptionManager_.addUnsubscriptionRecord(g.getUserId(),g),W.emit(Vr,{client:this,stream:g}),Ie.logSuccessEvent({userId:this.userId_,eventType:xS}),w.next=14;break;case 10:throw w.prev=10,w.t0=w.catch(1),Ie.logFailedEvent({userId:this.userId_,eventType:xS,error:w.t0}),w.t0;case 14:case"end":return w.stop()}},T,this,[[1,10]])})),function(T){return E.apply(this,arguments)})},{key:"switchRole",value:(S=N(m().mark(function T(g){return m().wrap(function(I){for(;;)switch(I.prev=I.next){case 0:if(this.role_!==g){I.next=2;break}return I.abrupt("return");case 2:return g===zi&&this.uplinkConnection_&&this.closeUplink(),this.log_.info("switchRole() => switch role to: "+g),I.next=6,this.doSwitchRole(g);case 6:case"end":return I.stop()}},T,this)})),function(T){return S.apply(this,arguments)})},{key:"doSwitchRole",value:function(T){var g,I,w=this,L={command:nU,data:{role:T===vr?za:qp,privateMapKey:this.privateMapKey_},responseCommand:ft.SWITCH_ROLE_RES,retries:((g=this.schedule_.config)===null||g===void 0||(I=g.retries)===null||I===void 0?void 0:I.switchRole)||1};return this.log_.info("switchRole signal data: "+JSON.stringify(L.data)),this.signalChannel_.sendWaitForResponseWithRetry(L).then(function(B){var ee=B.data,oe=ee.code,ve=ee.message;if(oe!==0)throw new $({code:Q.SWITCH_ROLE_FAILED,message:te({key:v3,data:{errMsg:ve,errCode:oe}})});w.role_=T}).catch(function(B){throw B instanceof $&&B.getCode()===Q.API_CALL_TIMEOUT&&(B=new $({code:Q.SWITCH_ROLE_FAILED,message:te({key:m3})})),w.log_.error(B),B})}},{key:"on",value:function(T,g,I){this.emitter_.on(T,g,I)}},{key:"off",value:function(T,g,I){T==="*"?this.emitter_.removeAllListeners():this.emitter_.off(T,g,I)}},{key:"getRemoteMutedState",value:function(){var T=this,g=[];return this.mutedStates_.forEach(function(I,w,L){var B=T.connections_.get(w);B&&g.push(G({userId:B.getUserId()},I))}),g}},{key:"getTransportStats",value:(y=N(m().mark(function T(){var g,I,w,L,B,ee,oe;return m().wrap(function(ve){for(;;)switch(ve.prev=ve.next){case 0:if(g={rtt:0,downlinksRTT:{}},!this.uplinkConnection_){ve.next=6;break}return ve.next=4,this.stats_.getSenderStats(this.uplinkConnection_);case 4:I=ve.sent,g.rtt=I.rtt;case 6:w=ne(this.connections_),ve.prev=7,w.s();case 9:if((L=w.n()).done){ve.next=17;break}return(B=Te(L.value,2))[0],ee=B[1],ve.next=13,this.stats_.getReceiverStats(ee);case 13:oe=ve.sent,g.downlinksRTT[oe.userId]=oe.rtt;case 15:ve.next=9;break;case 17:ve.next=22;break;case 19:ve.prev=19,ve.t0=ve.catch(7),w.e(ve.t0);case 22:return ve.prev=22,w.f(),ve.finish(22);case 25:return ve.abrupt("return",g);case 26:case"end":return ve.stop()}},T,this,[[7,19,22,25]])})),function(){return y.apply(this,arguments)})},{key:"getLocalAudioStats",value:(_=N(m().mark(function T(){var g,I;return m().wrap(function(w){for(;;)switch(w.prev=w.next){case 0:if((g={})[this.userId_]={bytesSent:0,packetsSent:0},!this.uplinkConnection_){w.next=7;break}return w.next=5,this.stats_.getSenderStats(this.uplinkConnection_);case 5:I=w.sent,g[this.userId_]={bytesSent:I.audio.bytesSent,packetsSent:I.audio.packetsSent};case 7:return w.abrupt("return",g);case 8:case"end":return w.stop()}},T,this)})),function(){return _.apply(this,arguments)})},{key:"getLocalVideoStats",value:(f=N(m().mark(function T(){var g,I;return m().wrap(function(w){for(;;)switch(w.prev=w.next){case 0:if((g={})[this.userId_]={bytesSent:0,packetsSent:0,framesEncoded:0,framesSent:0,frameWidth:0,frameHeight:0},!this.uplinkConnection_){w.next=7;break}return w.next=5,this.stats_.getSenderStats(this.uplinkConnection_);case 5:I=w.sent,g[this.userId_]={bytesSent:I.video.bytesSent,packetsSent:I.video.packetsSent,framesEncoded:I.video.framesEncoded,framesSent:I.video.framesSent,frameWidth:I.video.frameWidth,frameHeight:I.video.frameHeight};case 7:return w.abrupt("return",g);case 8:case"end":return w.stop()}},T,this)})),function(){return f.apply(this,arguments)})},{key:"getRemoteAudioStats",value:(h=N(m().mark(function T(){var g,I,w,L,B,ee,oe,ve;return m().wrap(function(ge){for(;;)switch(ge.prev=ge.next){case 0:g={},I=ne(this.connections_),ge.prev=2,I.s();case 4:if((w=I.n()).done){ge.next=13;break}return(L=Te(w.value,2))[0],B=L[1],ee=B.getDelay(),oe=ee.audioDelay,ge.next=9,this.stats_.getReceiverStats(B);case 9:(ve=ge.sent).hasAudio&&(g[ve.userId]={bytesReceived:ve.audio.bytesReceived,packetsReceived:ve.audio.packetsReceived,packetsLost:ve.audio.packetsLost,end2EndDelay:oe});case 11:ge.next=4;break;case 13:ge.next=18;break;case 15:ge.prev=15,ge.t0=ge.catch(2),I.e(ge.t0);case 18:return ge.prev=18,I.f(),ge.finish(18);case 21:return ge.abrupt("return",g);case 22:case"end":return ge.stop()}},T,this,[[2,15,18,21]])})),function(){return h.apply(this,arguments)})},{key:"getRemoteVideoStats",value:(p=N(m().mark(function T(){var g,I,w,L,B,ee,oe,ve,ge,qe=arguments;return m().wrap(function(Ne){for(;;)switch(Ne.prev=Ne.next){case 0:g=qe.length>0&&qe[0]!==void 0?qe[0]:gt,I={},w=ne(this.connections_),Ne.prev=3,w.s();case 5:if((L=w.n()).done){Ne.next=15;break}return(B=Te(L.value,2))[0],ee=B[1],Ne.next=9,this.stats_.getReceiverStats(ee);case 9:oe=Ne.sent,ve=ee.getDelay(),ge=ve.videoDelay,g===gt&&oe.hasVideo&&(I[oe.userId]={bytesReceived:oe.video.bytesReceived,packetsReceived:oe.video.packetsReceived,packetsLost:oe.video.packetsLost,framesDecoded:oe.video.framesDecoded,frameWidth:oe.video.frameWidth,frameHeight:oe.video.frameHeight,end2EndDelay:ge}),g===Pt&&oe.hasAuxiliary&&(I[oe.userId]={bytesReceived:oe.auxiliary.bytesReceived,packetsReceived:oe.auxiliary.packetsReceived,packetsLost:oe.auxiliary.packetsLost,framesDecoded:oe.auxiliary.framesDecoded,frameWidth:oe.auxiliary.frameWidth,frameHeight:oe.auxiliary.frameHeight,end2EndDelay:ge});case 13:Ne.next=5;break;case 15:Ne.next=20;break;case 17:Ne.prev=17,Ne.t0=Ne.catch(3),w.e(Ne.t0);case 20:return Ne.prev=20,w.f(),Ne.finish(20);case 23:return Ne.abrupt("return",I);case 24:case"end":return Ne.stop()}},T,this,[[3,17,20,23]])})),function(){return p.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(Ja,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=N(m().mark(function T(){var g,I,w,L,B,ee;return m().wrap(function(oe){for(;;)switch(oe.prev=oe.next){case 0:return I=this.badCaseDetector_.getMonitorFreeze(),oe.next=3,this.stats_.getStatsReport({uplinkConnection:this.uplinkConnection_,downlinkConnections:this.connections_,freezeMap:I});case 3:if(w=oe.sent,W.emit(Bf,{client:this,stats:w}),(g=this.badCaseDetector_)===null||g===void 0||g.resetMonitor(),this.signalChannel_){oe.next=8;break}return oe.abrupt("return");case 8:L=this.signalChannel_.isConnected()?OU(this.userId_):[],B=G(G({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:tf[this.networkType_]}},w),{},{msg_event_msg:L}),this.signalChannel_.send(HV,B),ee=Date.now(),this.lastHeartBeatTime_>0&&ee-this.lastHeartBeatTime_>1e4&&this.log_.warn("heartbeat took ".concat(ee-this.lastHeartBeatTime_)),this.lastHeartBeatTime_=ee,!this.isRelayChanged_&&this.isRelayMaybeFailed()&&(this.reJoin(),this.isRelayChanged_=!0);case 15:case"end":return oe.stop()}},T,this)})),function(){return d.apply(this,arguments)})},{key:"onRemoteStreamAdded",value:function(T){var g=T.content,I=g.userId,w=g.tinyId,L=g.audio,B=g.bigVideo,ee=g.auxVideo,oe=g.smallVideo;if(I!==null){this.userMap_.has(I)||(this.userMap_.set(I,new ng({userId:I,tinyId:w,role:vr})),this.emitter_.emit(ot.PEER_JOIN,{userId:I}));var ve=this.connections_.get(w);if(ve){if(ve.getIsReconnecting())return;this.log_.warn("duplicated stream-added observed, rebuild the connection"),ve.close(),this.connections_.delete(w)}var ge={audio:L,video:B,auxiliary:ee,smallVideo:oe};this.log_.info("remote peer [".concat(I,"] published stream. trackState: ").concat(JSON.stringify(ge))),this.createDownlinkConnection({userId:I,tinyId:w,trackState:ge})}else this.log_.warn("received null userId on stream added")}},{key:"createDownlinkConnection",value:function(T){var g=this,I=T.userId,w=T.tinyId,L=T.trackState,B=new QF({userId:I,tinyId:w,client:this,isUplink:!1,signalChannel:this.signalChannel_,autoSubscribe:this.autoSubscribe_,trackState:L,enableSEI:this.enableSEI_});this.connections_.set(w,B),this.installDownlinkEvents(B,I,w),this.autoSubscribe_?(B.initialize(),B.connect().catch(function(){!B.getMainStream()&&B.hasMainStream()&&g.initRemoteStream({type:gt,userId:I,downlinkConnection:B}),!B.getAuxStream()&&B.hasAuxStream()&&g.initRemoteStream({type:Pt,userId:I,downlinkConnection:B})})):(B.hasMainStream()&&this.initRemoteStream({type:gt,userId:I,downlinkConnection:B}),B.hasAuxStream()&&this.initRemoteStream({type:Pt,userId:I,downlinkConnection:B}))}},{key:"initRemoteStream",value:function(T){var g=T.type,I=T.userId,w=T.downlinkConnection,L=new Kv({type:g,userId:I,client:this});L.setConnection(w),w.setRemoteStream(g===gt?gr:Ys,L),L.setIsStreamAddedEventEmitted(!0),W.emit(ml,{client:this,stream:L}),this.emitter_.emit(ot.STREAM_ADDED,{stream:L})}},{key:"installDownlinkEvents",value:function(T,g,I){var w=this;T.on(rt.SEI_MESSAGE,function(L){w.emitter_.emit(ot.SEI_MESSAGE,L)}),T.on(rt.STREAM_ADDED,function(L){L.stream.setIsStreamAddedEventEmitted(!0),W.emit(ml,{client:w,stream:L.stream}),w.emitter_.emit(ot.STREAM_ADDED,{stream:L.stream})}),T.on(rt.STREAM_REMOVED,function(L){w.changeBigSmallRecords_.delete(L.stream.getUserId()),L.stream.stop(),L.stream.setIsStreamAddedEventEmitted(!1),w.subscriptionManager_&&w.subscriptionManager_.deleteAutoRecoveryFlag(L.stream.getUserId(),L.stream.getType()),W.emit(Yi,{client:w,stream:L.stream}),w.emitter_.emit(ot.STREAM_REMOVED,{stream:L.stream})}),T.on(rt.STREAM_UPDATED,function(L){W.emit(Y4,{client:w,stream:L.stream}),w.emitter_.emit(ot.STREAM_UPDATED,{stream:L.stream})}),T.on(rt.STREAM_SUBSCRIBED,function(L){W.emit(Nr,{client:w,stream:L.stream}),w.emitter_.emit(ot.STREAM_SUBSCRIBED,{stream:L.stream})}),T.on(rt.ERROR,function(L){var B=L.getCode();B!==Q.ICE_TRANSPORT_ERROR&&(B===Q.DOWNLINK_RECONNECTION_FAILED&&w.closeDownLink(I),w.emitter_.emit(ot.ERROR,L))})}},{key:"onPeerJoin",value:function(T){var g=T.data.data,I=g.srcTinyId,w=g.userId,L=g.role;this.userMap_.has(w)||(this.userMap_.set(w,new ng({userId:w,tinyId:I,role:L})),this.emitter_.emit(ot.PEER_JOIN,{userId:w}))}},{key:"onPeerLeave",value:function(T){var g=T.data.data,I=g.srcTinyId,w=g.userId,L=g.reason,B=L===void 0?0:L;this.log_.info("peer leave [".concat(w,"]: ").concat(PN[B])),this.cleanUser({userId:w,tinyId:I})}},{key:"cleanUser",value:function(T){var g=T.userId,I=T.tinyId;this.userMap_.delete(g),this.closeDownLink(I),this.emitter_.emit(ot.PEER_LEAVE,{userId:g})}},{key:"onPublishedUserList",value:function(T){var g=this;try{var I=T.data.userList.map(function(w){return w.userId});this.connections_.forEach(function(w){var L=w.getUserId(),B=w.getTinyId();I.findIndex(function(ee){return ee===L})<0&&(g.log_.info("peer unpublished detected [".concat(L,"]")),g.closeDownLink(B))}),T.data.userList.forEach(function(w){var L=w.userId,B=w.srcTinyId,ee=w.flag;if(L!==g.userId_){var oe=!!(1&ee),ve=!!(8&ee),ge=!!(4&ee),qe=!!(2&ee),Ne=g.connections_.get(B);if((qe||oe)&&g.checkSubscribeBigSmallVideo(Ne,qe),Ne){var Ge=Ne.getTrackState(),Je=Ge.audio,ze=Ge.video,xr=Ge.auxiliary,sa=Ge.smallVideo;!ze&&oe&&W.emit(Mn,{client:g,tinyId:B,userId:L,action:an.ADD,kind:xe}),!Je&&ve&&W.emit(Mn,{client:g,tinyId:B,userId:L,action:an.ADD,kind:Ce}),!xr&&ge&&W.emit(Mn,{client:g,tinyId:B,userId:L,action:an.ADD,kind:pt}),!sa&&qe&&W.emit(Mn,{client:g,tinyId:B,userId:L,action:an.ADD,kind:zu}),ze&&!oe&&W.emit(Mn,{client:g,tinyId:B,userId:L,action:an.REMOVE,kind:xe}),Je&&!ve&&W.emit(Mn,{client:g,tinyId:B,userId:L,action:an.REMOVE,kind:Ce}),xr&&!ge&&W.emit(Mn,{client:g,tinyId:B,userId:L,action:an.REMOVE,kind:pt}),sa&&!qe&&W.emit(Mn,{client:g,tinyId:B,userId:L,action:an.REMOVE,kind:zu})}else g.log_.info("peer published detected [".concat(L,"]")),g.onRemoteStreamAdded({content:{audio:ve,bigVideo:oe,auxVideo:ge,smallVideo:qe,userId:L,tinyId:B}})}})}catch(w){}}},{key:"onUpdateRemoteMuteStat",value:function(T){var g=this,I=T.data;(I&&I.userList||[]).forEach(function(w){var L=w.srcTinyId,B=w.userId;if(L!==0&&L!==g.tinyId_){var ee=g.connections_.get(L);if(ee){var oe=ee.getMainStream();if(oe&&oe.getIsStreamAddedEventEmitted()){var ve=!!(1&w.flag),ge=!!(8&w.flag),qe=!!(2&w.flag),Ne=!!(64&w.flag),Ge=!!(16&w.flag),Je=g.mutedStates_.get(L);if(Je===void 0)return g.mutedStates_.set(L,{hasAudio:ge,hasVideo:ve,hasSmall:qe,audioMuted:Ne,videoMuted:Ge}),ve?Ge?g.emitter_.emit(ot.MUTE_VIDEO,{userId:B}):g.emitter_.emit(ot.UNMUTE_VIDEO,{userId:B}):g.emitter_.emit(ot.MUTE_VIDEO,{userId:B}),void(ge?Ne?g.emitter_.emit(ot.MUTE_AUDIO,{userId:B}):g.emitter_.emit(ot.UNMUTE_AUDIO,{userId:B}):g.emitter_.emit(ot.MUTE_AUDIO,{userId:B}));var ze=!Je.audioMuted&&Je.hasAudio,xr=!Ne&&ge,sa=!Je.videoMuted&&Je.hasVideo,hw=!Ge&&ve;g.mutedStates_.set(L,{hasAudio:ge,hasVideo:ve,hasSmall:qe,audioMuted:Ne,videoMuted:Ge}),ze!==xr&&(xr?g.emitter_.emit(ot.UNMUTE_AUDIO,{userId:B}):g.emitter_.emit(ot.MUTE_AUDIO,{userId:B})),sa!==hw&&(hw?g.emitter_.emit(ot.UNMUTE_VIDEO,{userId:B}):g.emitter_.emit(ot.MUTE_VIDEO,{userId:B}))}}else g.mutedStates_.delete(L)}})}},{key:"getEnv",value:function(){return this.env_}},{key:"getSubscriptionManager",value:function(){return this.subscriptionManager_}},{key:"startPublishCDNStream",value:(u=N(m().mark(function T(){var g,I=arguments;return m().wrap(function(w){for(;;)switch(w.prev=w.next){case 0:if(g=I.length>0&&I[0]!==void 0?I[0]:{},this.log_.info("startPublishCDNStream with params: ".concat(JSON.stringify(g),"; isJoined: ").concat(this.isJoined_,"; hasMainStream: ").concat(!!this.localStream_,"; hasAuxStream: ").concat(!!this.localAuxStream_,";")),g.streamType=g.streamType||Ye,g.streamType===pt&&(g.streamType=Ln),g.streamId=g.streamId||"",!this.isJoined_){w.next=10;break}if(g.streamType!==Ye||this.localStream_){w.next=8;break}throw new $({code:Q.INVALID_OPERATION,message:te({key:nk})});case 8:if(g.streamType!==Ln||this.localAuxStream_){w.next=10;break}throw new $({code:Q.INVALID_OPERATION,message:te({key:nk})});case 10:return w.next=12,this.publishCDNManager_.startPublishTencentCDN(g);case 12:if(!(g.appId&&g.bizId&&g.url)){w.next=15;break}return w.next=15,this.publishCDNManager_.startPublishGivenCDN(g);case 15:case"end":return w.stop()}},T,this)})),function(){return u.apply(this,arguments)})},{key:"stopPublishCDNStream",value:(c=N(m().mark(function T(){return m().wrap(function(g){for(;;)switch(g.prev=g.next){case 0:if(this.publishCDNManager_.getIsPublishingTencentCDN()){g.next=2;break}throw new $({code:Q.INVALID_OPERATION,message:te({key:_3})});case 2:return this.log_.info("stopPublishCDNStream"),g.next=5,this.publishCDNManager_.stopPublishTencentCDN();case 5:if(!this.publishCDNManager_.getIsPublishingGivenCDN()){g.next=8;break}return g.next=8,this.publishCDNManager_.stopPublishGivenCDN();case 8:case"end":return g.stop()}},T,this)})),function(){return c.apply(this,arguments)})},{key:"startMixTranscode",value:(s=N(m().mark(function T(g){return m().wrap(function(I){for(;;)switch(I.prev=I.next){case 0:if(this.isJoined_&&this.mixTranscodeManager_){I.next=2;break}throw new $({code:Q.INVALID_OPERATION,message:te({key:b3})});case 2:return fe(g.mode)&&(g.mode=ef.MANUAL),I.prev=3,this.log_.info("startMixTranscode with config ".concat(JSON.stringify(g))),Ie.uploadEvent({log:"mix-transcode-mode:".concat(g.mode),userId:this.userId_}),I.next=8,this.mixTranscodeManager_.startMixTranscode(g);case 8:Ie.logSuccessEvent({userId:this.userId_,eventType:OS}),I.next=15;break;case 11:throw I.prev=11,I.t0=I.catch(3),Ie.logFailedEvent({userId:this.userId_,eventType:OS,error:I.t0}),I.t0;case 15:case"end":return I.stop()}},T,this,[[3,11]])})),function(T){return s.apply(this,arguments)})},{key:"stopMixTranscode",value:(a=N(m().mark(function T(){return m().wrap(function(g){for(;;)switch(g.prev=g.next){case 0:if(this.isJoined_&&this.mixTranscodeManager_){g.next=2;break}throw new $({code:Q.INVALID_OPERATION,message:te({key:S3})});case 2:return g.prev=2,g.next=5,this.mixTranscodeManager_.stopMixTranscode();case 5:Ie.logSuccessEvent({userId:this.userId_,eventType:MS}),g.next=12;break;case 8:throw g.prev=8,g.t0=g.catch(2),Ie.logFailedEvent({userId:this.userId_,eventType:MS,error:g.t0}),g.t0;case 12:case"end":return g.stop()}},T,this,[[2,8]])})),function(){return a.apply(this,arguments)})},{key:"getSystemResult",value:function(){return this.checkSystemResult_}},{key:"enableAudioVolumeEvaluation",value:function(){var T=this,g=arguments.length>0&&arguments[0]!==void 0?arguments[0]:2e3,I=arguments.length>1&&arguments[1]!==void 0&&arguments[1];if(!br(g))throw new $({code:Q.INVALID_PARAMETER,message:te({key:k3})});if(this.log_.info("enableAudioVolumeEvaluation with interval: "+g),g<=0)return this.enableAudioVolumeEvaluation_=!1,_t.clearTask(this.audioVolumeIntervalId_),void(this.audioVolumeIntervalId_=null);g=Math.floor(Math.max(g,16)),W.emit(zf,{interval:g}),this.audioVolumeIntervalId_&&(_t.clearTask(this.audioVolumeIntervalId_),this.audioVolumeIntervalId_=null),this.enableAudioVolumeEvaluation_=!0,this.audioVolumeIntervalId_=_t.run(el,function(){var w=[];if(T.localStream_){var L=Math.floor(100*T.localStream_.getAudioLevel());w.push({userId:T.userId_,audioVolume:L,stream:T.localStream_})}T.connections_.forEach(function(B){var ee=B.getSubscribedMainStream();if(ee){var oe=Math.floor(100*ee.getAudioLevel());w.push({userId:B.getUserId(),audioVolume:oe,stream:ee})}}),T.emitter_.emit(ot.AUDIO_VOLUME,{result:w})},{fps:1e3/g,backgroundTask:I})}},{key:"callExperimentalAPI",value:function(T,g){return u7.call(T,G({client:this},g))}},{key:"setProperty",value:function(T,g){var I="".concat(T,"_");fe(this[I])||(this[I]=g)}},{key:"uploadAllCallStats",value:function(){var T=this;this.callDurationCalculator_.getDurationMap().forEach(function(g,I){var w={userId:g.userId,type:g.type,duration:T.callDurationCalculator_.getDuration(I,xe),dataFreeze:T.badCaseDetector_.getDataFreezeDuration(I).dataFreeze,renderFreeze:T.badCaseDetector_.getRenderFreezeDuration(I).renderFreeze};Ie.uploadEvent({log:"callStats-"+JSON.stringify(w),userId:T.userId_})}),this.badCaseDetector_.stop(),this.callDurationCalculator_.reset()}},{key:"enableSmallStream",value:(o=N(m().mark(function T(){return m().wrap(function(g){for(;;)switch(g.prev=g.next){case 0:if(!this.isPublished()&&!this.isPublishing_){g.next=2;break}throw new $({code:Q.INVALID_OPERATION,message:te({key:T3})});case 2:if(!OT()){g.next=7;break}this.setIsEnableSmallStream(!0),this.log_.info("SmallStream successfully enabled"),g.next=8;break;case 7:throw new $({code:Q.INVALID_OPERATION,message:te({key:I3})});case 8:case"end":return g.stop()}},T,this)})),function(){return o.apply(this,arguments)})},{key:"disableSmallStream",value:(i=N(m().mark(function T(){return m().wrap(function(g){for(;;)switch(g.prev=g.next){case 0:if(!this.isPublished()&&!this.isPublishing_){g.next=2;break}throw new $({code:Q.INVALID_OPERATION,message:te({key:x3})});case 2:this.setIsEnableSmallStream(!1),this.log_.info("SmallStream successfully disabled");case 4:case"end":return g.stop()}},T,this)})),function(){return i.apply(this,arguments)})},{key:"setSmallStreamProfile",value:function(T){var g=this;T&&T.framerate&&(T.frameRate=T.framerate),T.width*T.height>307200&&(T.width=320,T.height=240,this.log_.info("Small stream resolution is beyond limitation, which is invalid. Reset to 320 * 240")),Object.keys(this.smallStreamConfig_).forEach(function(oe){T[oe]&&(g.smallStreamConfig_[oe]=T[oe])});var I=this.smallStreamConfig_,w=I.width,L=I.height,B=I.bitrate,ee=I.frameRate;if(this.log_.info("setSmallStreamProfile: bitrate=".concat(B,", frameRate=").concat(ee,", height=").concat(L,", width=").concat(w)),w<0||L<0||B<0||ee<0)throw new $({code:Q.INVALID_PARAMETER,message:te({key:w3})})}},{key:"setRemoteVideoStreamType",value:(r=N(m().mark(function T(g,I){return m().wrap(function(w){for(;;)switch(w.prev=w.next){case 0:if(g instanceof Kv){w.next=2;break}throw new $({code:Q.INVALID_PARAMETER,message:te({key:E3})});case 2:if(g.getConnection()){w.next=4;break}throw new $({code:Q.INVALID_OPERATION,message:te({key:sf})});case 4:if(g.getType()!==Pt){w.next=6;break}return w.abrupt("return");case 6:w.t0=I,w.next=w.t0===FS||w.t0===GS?9:12;break;case 9:return w.next=11,this.changeVideoType(g,I);case 11:case 12:return w.abrupt("break",13);case 13:case"end":return w.stop()}},T,this)})),function(T,g){return r.apply(this,arguments)})},{key:"changeVideoType",value:(n=N(m().mark(function T(g,I){var w,L;return m().wrap(function(B){for(;;)switch(B.prev=B.next){case 0:w=g.getUserId(),L={stream:g,options:{video:I===FS,smallVideo:I===GS},isSubscribing:!1,reSubscribeCount:10},this.changeBigSmallRecords_.set(w,L),this.log_.info("set [".concat(w,"] ").concat(g.getType()," stream video prefer type: ").concat(I));case 5:case"end":return B.stop()}},T,this)})),function(T,g){return n.apply(this,arguments)})},{key:"checkSubscribeBigSmallVideo",value:(t=N(m().mark(function T(g,I){var w,L,B,ee,oe,ve,ge,qe,Ne,Ge,Je;return m().wrap(function(ze){for(;;)switch(ze.prev=ze.next){case 0:if(g!=null&&g.isBigStreamSubscribed||g!=null&&g.isSmallStreamSubscribed){ze.next=2;break}return ze.abrupt("return");case 2:if(w=g.getUserId(),this.changeBigSmallRecords_.has(w)){ze.next=5;break}return ze.abrupt("return");case 5:if(L=this.changeBigSmallRecords_.get(w),B=g.getSubscribeState(),ee=B.video,oe=B.smallVideo,ve=L.stream,ge=L.options,qe=L.isSubscribing,Ne=L.reSubscribeCount,!(ge.video&&ee||ge.smallVideo&&oe&&I)){ze.next=10;break}return ze.abrupt("return");case 10:if(Ge={video:ge.video,smallVideo:ge.smallVideo},!(I&&g.isBigStreamSubscribed||g.isSmallStreamSubscribed)){ze.next=31;break}if(ze.prev=12,!(ge&&ve&&!qe&&Ne>=1)){ze.next=24;break}return L.isSubscribing=!0,L.reSubscribeCount=Ne-1,Je=ve.getConnection(),!I&&Je.isSmallStreamSubscribed&&(Ge={video:!0,smallVideo:!1}),Ge.emitEvent=!1,ze.next=21,Je==null?void 0:Je.subscribe(ve,Ge);case 21:this.log_.info("change [".concat(w,"] to ").concat(Ge.smallVideo?"small":"big"," video successfully. count ").concat(10-L.reSubscribeCount,".")),L.isSubscribing=!1,L.reSubscribeCount=10;case 24:ze.next=31;break;case 26:ze.prev=26,ze.t0=ze.catch(12),this.log_.info("change [".concat(w,"] to ").concat(Ge.smallVideo?"small":"big"," video failed. count ").concat(10-L.reSubscribeCount,".")),L.isSubscribing=!1,Ne===0&&this.changeBigSmallRecords_.delete(w);case 31:case"end":return ze.stop()}},T,this,[[12,26]])})),function(T,g){return t.apply(this,arguments)})},{key:"setIsEnableSmallStream",value:function(T){this.isEnableSmallStream_=T}},{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 T=Se(this.connections_.values());return this.uplinkConnection_&&T.push(this.uplinkConnection_),T}},{key:"isRelayMaybeFailed",value:function(){if(!this.signalChannel_.isOnline)return!1;var T=this.getAllConnections();if(T.length===0)return!1;for(var g=0;g<T.length;g++)if(T[g].getReconnectionCount()<6)return!1;return!0}},{key:"getUseStringRoomId",value:function(){return this.useStringRoomId_}},{key:"checkConnectionsToReconnect",value:function(){var T=this;this.getAllConnections().forEach(function(g){if(!g.getIsReconnecting()){var I=g.getPeerConnection();I&&I.connectionState===Kp&&(T.log_.warn("[".concat(g.getUserId(),"] pc is closed but not reconnect")),g.startReconnection())}})}},{key:"getEnableAutoPlayDialog",value:function(){return this.enableAutoPlayDialog_}},{key:"sendSEIMessage",value:function(T,g){this.uplinkConnection_.sendSEI(T,g)}},{key:"setProxyServer",value:function(T){if(this.log_.info("set proxy server: ".concat(JSON.stringify(T))),Ft(T)){if(!T.startsWith("wss://"))throw new $({code:Q.INVALID_PARAMETER,message:te({key:e3})});this.proxy_=T}else if(Qi(T)){var g=T.websocketProxy,I=T.loggerProxy,w=T.scheduleProxy;g&&(this.proxy_=g),I&&uN(I),w&&IN(w)}}},{key:"setTurnServer",value:function(T){this.log_.info("set turn server: "+JSON.stringify(T));var g=[];Array.isArray(T)?T.forEach(function(I){return g.push(Dk(I))}):Qi(T)&&g.push(Dk(T)),this.turnServers_=g}},{key:"get2k4kFlag",value:function(){var T,g;return(T=this.schedule_)===null||T===void 0||(g=T.trtcCapability)===null||g===void 0?void 0:g["2k4k"]}}]),e}(),q(et.prototype,"join",[KI,QI],Object.getOwnPropertyDescriptor(et.prototype,"join"),et.prototype),q(et.prototype,"leave",[XI],Object.getOwnPropertyDescriptor(et.prototype,"leave"),et.prototype),q(et.prototype,"getUserList",[YI],Object.getOwnPropertyDescriptor(et.prototype,"getUserList"),et.prototype),q(et.prototype,"publish",[$I,ZI],Object.getOwnPropertyDescriptor(et.prototype,"publish"),et.prototype),q(et.prototype,"unpublish",[ew,tw],Object.getOwnPropertyDescriptor(et.prototype,"unpublish"),et.prototype),q(et.prototype,"subscribe",[nw],Object.getOwnPropertyDescriptor(et.prototype,"subscribe"),et.prototype),q(et.prototype,"unsubscribe",[rw],Object.getOwnPropertyDescriptor(et.prototype,"unsubscribe"),et.prototype),q(et.prototype,"switchRole",[iw,aw],Object.getOwnPropertyDescriptor(et.prototype,"switchRole"),et.prototype),q(et.prototype,"startPublishCDNStream",[ow],Object.getOwnPropertyDescriptor(et.prototype,"startPublishCDNStream"),et.prototype),q(et.prototype,"startMixTranscode",[sw],Object.getOwnPropertyDescriptor(et.prototype,"startMixTranscode"),et.prototype),q(et.prototype,"sendSEIMessage",[cw,uw],Object.getOwnPropertyDescriptor(et.prototype,"sendSEIMessage"),et.prototype),et),d7=0,h7=0,p7=(lw=$l(Jt.TRTC.createClient),dw=$l(Jt.TRTC.createStream),bi=function(){function e(){z(this,e),this.name_=wN,this.VERSION=Oi,this.Logger={loggerManager:be,LogLevel:On,setLogLevel:function(n){be.setLogLevel(n),n<=1&&q4()},enableUploadLog:function(){be.enableUploadLog()},disableUploadLog:function(){be.warn("disableUploadLog"),be.disableUploadLog()}}}var t;return ke(e,[{key:"checkSystemRequirements",value:(t=N(m().mark(function n(){return m().wrap(function(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,wm();case 2:return r.abrupt("return",r.sent);case 3:case"end":return r.stop()}},n)})),function(){return t.apply(this,arguments)})},{key:"isScreenShareSupported",value:function(){return AT()}},{key:"isSmallStreamSupported",value:function(){return OT()}},{key:"getDevices",value:function(){return Om()}},{key:"getCameras",value:function(){return function(){return Lm.apply(this,arguments)}()}},{key:"getMicrophones",value:function(){return UT()}},{key:"getSpeakers",value:function(){return function(){return Vm.apply(this,arguments)}()}},{key:"createClient",value:function(n){Gk&&(Gk=!1,be.getLogLevel()!=It.Logger.LogLevel.NONE&&(console.info("******************************************************************************"),console.info("* TRTC Web SDK"),console.info("* API Document: "+"".concat(af,"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("******************************************************************************")),be.info("TRTC Web SDK Version: 4.15.6"),be.info("UserAgent: "+navigator.userAgent),be.info("URL of current page: "+location.href));var r={version:this.VERSION},i=new l7(G(G(G({},r),n),{},{seq:++d7}));return W.emit(Bk,{client:i}),i}},{key:"createStream",value:function(n){return new wF(G(G({},n),{},{seq:++h7}))}}]),e}(),q(bi.prototype,"createClient",[lw],Object.getOwnPropertyDescriptor(bi.prototype,"createClient"),bi.prototype),q(bi.prototype,"createStream",[dw],Object.getOwnPropertyDescriptor(bi.prototype,"createStream"),bi.prototype),bi),It=new p7;return It})});var dg=sg((M7,lg)=>{"use strict";var yo=typeof Reflect=="object"?Reflect:null,gw=yo&&typeof yo.apply=="function"?yo.apply:function(G,m,V){return Function.prototype.apply.call(G,m,V)},vd;yo&&typeof yo.ownKeys=="function"?vd=yo.ownKeys:Object.getOwnPropertySymbols?vd=function(G){return Object.getOwnPropertyNames(G).concat(Object.getOwnPropertySymbols(G))}:vd=function(G){return Object.getOwnPropertyNames(G)};function k7(X){console&&console.warn&&console.warn(X)}var yw=Number.isNaN||function(G){return G!==G};function ht(){ht.init.call(this)}lg.exports=ht;lg.exports.once=w7;ht.EventEmitter=ht;ht.prototype._events=void 0;ht.prototype._eventsCount=0;ht.prototype._maxListeners=void 0;var _w=10;function gd(X){if(typeof X!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof X)}Object.defineProperty(ht,"defaultMaxListeners",{enumerable:!0,get:function(){return _w},set:function(X){if(typeof X!="number"||X<0||yw(X))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+X+".");_w=X}});ht.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};ht.prototype.setMaxListeners=function(G){if(typeof G!="number"||G<0||yw(G))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+G+".");return this._maxListeners=G,this};function bw(X){return X._maxListeners===void 0?ht.defaultMaxListeners:X._maxListeners}ht.prototype.getMaxListeners=function(){return bw(this)};ht.prototype.emit=function(G){for(var m=[],V=1;V<arguments.length;V++)m.push(arguments[V]);var J=G==="error",N=this._events;if(N!==void 0)J=J&&N.error===void 0;else if(!J)return!1;if(J){var z;if(m.length>0&&(z=m[0]),z instanceof Error)throw z;var Pe=new Error("Unhandled error."+(z?" ("+z.message+")":""));throw Pe.context=z,Pe}var ke=N[G];if(ke===void 0)return!1;if(typeof ke=="function")gw(ke,this,m);else for(var ut=ke.length,Mt=Iw(ke,ut),V=0;V<ut;++V)gw(Mt[V],this,m);return!0};function Sw(X,G,m,V){var J,N,z;if(gd(m),N=X._events,N===void 0?(N=X._events=Object.create(null),X._eventsCount=0):(N.newListener!==void 0&&(X.emit("newListener",G,m.listener?m.listener:m),N=X._events),z=N[G]),z===void 0)z=N[G]=m,++X._eventsCount;else if(typeof z=="function"?z=N[G]=V?[m,z]:[z,m]:V?z.unshift(m):z.push(m),J=bw(X),J>0&&z.length>J&&!z.warned){z.warned=!0;var Pe=new Error("Possible EventEmitter memory leak detected. "+z.length+" "+String(G)+" listeners added. Use emitter.setMaxListeners() to increase limit");Pe.name="MaxListenersExceededWarning",Pe.emitter=X,Pe.type=G,Pe.count=z.length,k7(Pe)}return X}ht.prototype.addListener=function(G,m){return Sw(this,G,m,!1)};ht.prototype.on=ht.prototype.addListener;ht.prototype.prependListener=function(G,m){return Sw(this,G,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 kw(X,G,m){var V={fired:!1,wrapFn:void 0,target:X,type:G,listener:m},J=T7.bind(V);return J.listener=m,V.wrapFn=J,J}ht.prototype.once=function(G,m){return gd(m),this.on(G,kw(this,G,m)),this};ht.prototype.prependOnceListener=function(G,m){return gd(m),this.prependListener(G,kw(this,G,m)),this};ht.prototype.removeListener=function(G,m){var V,J,N,z,Pe;if(gd(m),J=this._events,J===void 0)return this;if(V=J[G],V===void 0)return this;if(V===m||V.listener===m)--this._eventsCount===0?this._events=Object.create(null):(delete J[G],J.removeListener&&this.emit("removeListener",G,V.listener||m));else if(typeof V!="function"){for(N=-1,z=V.length-1;z>=0;z--)if(V[z]===m||V[z].listener===m){Pe=V[z].listener,N=z;break}if(N<0)return this;N===0?V.shift():x7(V,N),V.length===1&&(J[G]=V[0]),J.removeListener!==void 0&&this.emit("removeListener",G,Pe||m)}return this};ht.prototype.off=ht.prototype.removeListener;ht.prototype.removeAllListeners=function(G){var m,V,J;if(V=this._events,V===void 0)return this;if(V.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):V[G]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete V[G]),this;if(arguments.length===0){var N=Object.keys(V),z;for(J=0;J<N.length;++J)z=N[J],z!=="removeListener"&&this.removeAllListeners(z);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(m=V[G],typeof m=="function")this.removeListener(G,m);else if(m!==void 0)for(J=m.length-1;J>=0;J--)this.removeListener(G,m[J]);return this};function Tw(X,G,m){var V=X._events;if(V===void 0)return[];var J=V[G];return J===void 0?[]:typeof J=="function"?m?[J.listener||J]:[J]:m?I7(J):Iw(J,J.length)}ht.prototype.listeners=function(G){return Tw(this,G,!0)};ht.prototype.rawListeners=function(G){return Tw(this,G,!1)};ht.listenerCount=function(X,G){return typeof X.listenerCount=="function"?X.listenerCount(G):xw.call(X,G)};ht.prototype.listenerCount=xw;function xw(X){var G=this._events;if(G!==void 0){var m=G[X];if(typeof m=="function")return 1;if(m!==void 0)return m.length}return 0}ht.prototype.eventNames=function(){return this._eventsCount>0?vd(this._events):[]};function Iw(X,G){for(var m=new Array(G),V=0;V<G;++V)m[V]=X[V];return m}function x7(X,G){for(;G+1<X.length;G++)X[G]=X[G+1];X.pop()}function I7(X){for(var G=new Array(X.length),m=0;m<G.length;++m)G[m]=X[m].listener||X[m];return G}function w7(X,G){return new Promise(function(m,V){function J(z){X.removeListener(G,N),V(z)}function N(){typeof X.removeListener=="function"&&X.removeListener("error",J),m([].slice.call(arguments))}ww(X,G,N,{once:!0}),G!=="error"&&E7(X,J,{once:!0})})}function E7(X,G,m){typeof X.on=="function"&&ww(X,"error",G,m)}function ww(X,G,m,V){if(typeof X.on=="function")V.once?X.once(G,m):X.on(G,m);else if(typeof X.addEventListener=="function")X.addEventListener(G,function J(N){V.once&&X.removeEventListener(G,J),m(N)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof X)}});var Cw=sg((hg,pg)=>{(function(X,G){typeof hg=="object"&&typeof pg!="undefined"?pg.exports=G(Ir()):typeof define=="function"&&define.amd?define(["trtc-js-sdk"],G):(X=typeof globalThis!="undefined"?globalThis:X||self).RTCBeautyPlugin=G(X.TRTC)})(hg,function(X){function G(ae){return ae&&typeof ae=="object"&&"default"in ae?ae:{default:ae}}var m=G(X);function V(){V=function(){return ae};var ae={},Te=Object.prototype,Se=Te.hasOwnProperty,Ve=typeof Symbol=="function"?Symbol:{},Fe=Ve.iterator||"@@iterator",ne=Ve.asyncIterator||"@@asyncIterator",q=Ve.toStringTag||"@@toStringTag";function re(he,se,Me){return Object.defineProperty(he,se,{value:Me,enumerable:!0,configurable:!0,writable:!0}),he[se]}try{re({},"")}catch(he){re=function(se,Me,ce){return se[Me]=ce}}function j(he,se,Me,ce){var Ae=se&&se.prototype instanceof ie?se:ie,st=Object.create(Ae.prototype),Tt=new Ze(ce||[]);return st._invoke=function(vt,Kt,tt){var wt="suspendedStart";return function(zt,Cn){if(wt==="executing")throw new Error("Generator is already running");if(wt==="completed"){if(zt==="throw")throw Cn;return Hn()}for(tt.method=zt,tt.arg=Cn;;){var Si=tt.delegate;if(Si){var Ct=or(Si,tt);if(Ct){if(Ct===ye)continue;return Ct}}if(tt.method==="next")tt.sent=tt._sent=tt.arg;else if(tt.method==="throw"){if(wt==="suspendedStart")throw wt="completed",tt.arg;tt.dispatchException(tt.arg)}else tt.method==="return"&&tt.abrupt("return",tt.arg);wt="executing";var fn=Z(vt,Kt,tt);if(fn.type==="normal"){if(wt=tt.done?"completed":"suspendedYield",fn.arg===ye)continue;return{value:fn.arg,done:tt.done}}fn.type==="throw"&&(wt="completed",tt.method="throw",tt.arg=fn.arg)}}}(he,Me,Tt),st}function Z(he,se,Me){try{return{type:"normal",arg:he.call(se,Me)}}catch(ce){return{type:"throw",arg:ce}}}ae.wrap=j;var ye={};function ie(){}function _e(){}function De(){}var Gt={};re(Gt,Fe,function(){return this});var qt=Object.getPrototypeOf,Ke=qt&&qt(qt(Bt([])));Ke&&Ke!==Te&&Se.call(Ke,Fe)&&(Gt=Ke);var Ht=De.prototype=ie.prototype=Object.create(Gt);function lt(he){["next","throw","return"].forEach(function(se){re(he,se,function(Me){return this._invoke(se,Me)})})}function Gn(he,se){function Me(Ae,st,Tt,vt){var Kt=Z(he[Ae],he,st);if(Kt.type!=="throw"){var tt=Kt.arg,wt=tt.value;return wt&&typeof wt=="object"&&Se.call(wt,"__await")?se.resolve(wt.__await).then(function(zt){Me("next",zt,Tt,vt)},function(zt){Me("throw",zt,Tt,vt)}):se.resolve(wt).then(function(zt){tt.value=zt,Tt(tt)},function(zt){return Me("throw",zt,Tt,vt)})}vt(Kt.arg)}var ce;this._invoke=function(Ae,st){function Tt(){return new se(function(vt,Kt){Me(Ae,st,vt,Kt)})}return ce=ce?ce.then(Tt,Tt):Tt()}}function or(he,se){var Me=he.iterator[se.method];if(Me===void 0){if(se.delegate=null,se.method==="throw"){if(he.iterator.return&&(se.method="return",se.arg=void 0,or(he,se),se.method==="throw"))return ye;se.method="throw",se.arg=new TypeError("The iterator does not provide a 'throw' method")}return ye}var ce=Z(Me,he.iterator,se.arg);if(ce.type==="throw")return se.method="throw",se.arg=ce.arg,se.delegate=null,ye;var Ae=ce.arg;return Ae?Ae.done?(se[he.resultName]=Ae.value,se.next=he.nextLoc,se.method!=="return"&&(se.method="next",se.arg=void 0),se.delegate=null,ye):Ae:(se.method="throw",se.arg=new TypeError("iterator result is not an object"),se.delegate=null,ye)}function Ut(he){var se={tryLoc:he[0]};1 in he&&(se.catchLoc=he[1]),2 in he&&(se.finallyLoc=he[2],se.afterLoc=he[3]),this.tryEntries.push(se)}function En(he){var se=he.completion||{};se.type="normal",delete se.arg,he.completion=se}function Ze(he){this.tryEntries=[{tryLoc:"root"}],he.forEach(Ut,this),this.reset(!0)}function Bt(he){if(he){var se=he[Fe];if(se)return se.call(he);if(typeof he.next=="function")return he;if(!isNaN(he.length)){var Me=-1,ce=function Ae(){for(;++Me<he.length;)if(Se.call(he,Me))return Ae.value=he[Me],Ae.done=!1,Ae;return Ae.value=void 0,Ae.done=!0,Ae};return ce.next=ce}}return{next:Hn}}function Hn(){return{value:void 0,done:!0}}return _e.prototype=De,re(Ht,"constructor",De),re(De,"constructor",_e),_e.displayName=re(De,q,"GeneratorFunction"),ae.isGeneratorFunction=function(he){var se=typeof he=="function"&&he.constructor;return!!se&&(se===_e||(se.displayName||se.name)==="GeneratorFunction")},ae.mark=function(he){return Object.setPrototypeOf?Object.setPrototypeOf(he,De):(he.__proto__=De,re(he,q,"GeneratorFunction")),he.prototype=Object.create(Ht),he},ae.awrap=function(he){return{__await:he}},lt(Gn.prototype),re(Gn.prototype,ne,function(){return this}),ae.AsyncIterator=Gn,ae.async=function(he,se,Me,ce,Ae){Ae===void 0&&(Ae=Promise);var st=new Gn(j(he,se,Me,ce),Ae);return ae.isGeneratorFunction(se)?st:st.next().then(function(Tt){return Tt.done?Tt.value:st.next()})},lt(Ht),re(Ht,q,"Generator"),re(Ht,Fe,function(){return this}),re(Ht,"toString",function(){return"[object Generator]"}),ae.keys=function(he){var se=[];for(var Me in he)se.push(Me);return se.reverse(),function ce(){for(;se.length;){var Ae=se.pop();if(Ae in he)return ce.value=Ae,ce.done=!1,ce}return ce.done=!0,ce}},ae.values=Bt,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(En),!he)for(var se in this)se.charAt(0)==="t"&&Se.call(this,se)&&!isNaN(+se.slice(1))&&(this[se]=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 se=this;function Me(Kt,tt){return st.type="throw",st.arg=he,se.next=Kt,tt&&(se.method="next",se.arg=void 0),!!tt}for(var ce=this.tryEntries.length-1;ce>=0;--ce){var Ae=this.tryEntries[ce],st=Ae.completion;if(Ae.tryLoc==="root")return Me("end");if(Ae.tryLoc<=this.prev){var Tt=Se.call(Ae,"catchLoc"),vt=Se.call(Ae,"finallyLoc");if(Tt&&vt){if(this.prev<Ae.catchLoc)return Me(Ae.catchLoc,!0);if(this.prev<Ae.finallyLoc)return Me(Ae.finallyLoc)}else if(Tt){if(this.prev<Ae.catchLoc)return Me(Ae.catchLoc,!0)}else{if(!vt)throw new Error("try statement without catch or finally");if(this.prev<Ae.finallyLoc)return Me(Ae.finallyLoc)}}}},abrupt:function(he,se){for(var Me=this.tryEntries.length-1;Me>=0;--Me){var ce=this.tryEntries[Me];if(ce.tryLoc<=this.prev&&Se.call(ce,"finallyLoc")&&this.prev<ce.finallyLoc){var Ae=ce;break}}Ae&&(he==="break"||he==="continue")&&Ae.tryLoc<=se&&se<=Ae.finallyLoc&&(Ae=null);var st=Ae?Ae.completion:{};return st.type=he,st.arg=se,Ae?(this.method="next",this.next=Ae.finallyLoc,ye):this.complete(st)},complete:function(he,se){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"&&se&&(this.next=se),ye},finish:function(he){for(var se=this.tryEntries.length-1;se>=0;--se){var Me=this.tryEntries[se];if(Me.finallyLoc===he)return this.complete(Me.completion,Me.afterLoc),En(Me),ye}},catch:function(he){for(var se=this.tryEntries.length-1;se>=0;--se){var Me=this.tryEntries[se];if(Me.tryLoc===he){var ce=Me.completion;if(ce.type==="throw"){var Ae=ce.arg;En(Me)}return Ae}}throw new Error("illegal catch attempt")},delegateYield:function(he,se,Me){return this.delegate={iterator:Bt(he),resultName:se,nextLoc:Me},this.method==="next"&&(this.arg=void 0),ye}},ae}function J(ae){return J=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},J(ae)}function N(ae,Te,Se,Ve,Fe,ne,q){try{var re=ae[ne](q),j=re.value}catch(Z){return void Se(Z)}re.done?Te(j):Promise.resolve(j).then(Ve,Fe)}function z(ae){return function(){var Te=this,Se=arguments;return new Promise(function(Ve,Fe){var ne=ae.apply(Te,Se);function q(j){N(ne,Ve,Fe,q,re,"next",j)}function re(j){N(ne,Ve,Fe,q,re,"throw",j)}q(void 0)})}}function Pe(ae,Te){if(!(ae instanceof Te))throw new TypeError("Cannot call a class as a function")}function ke(ae,Te){for(var Se=0;Se<Te.length;Se++){var Ve=Te[Se];Ve.enumerable=Ve.enumerable||!1,Ve.configurable=!0,"value"in Ve&&(Ve.writable=!0),Object.defineProperty(ae,Ve.key,Ve)}}function ut(ae,Te,Se){return Te&&ke(ae.prototype,Te),Se&&ke(ae,Se),Object.defineProperty(ae,"prototype",{writable:!1}),ae}function Mt(ae,Te,Se){var Ve=function(Z,ye,ie){var _e=new RegExp("\\b".concat(ye," \\w+ (\\w+)"),"ig");Z.replace(_e,function(De,Gt){return ie[Gt]=0,De})},Fe=function(Z,ye,ie){var _e=Z.createShader(ie);return Z.shaderSource(_e,ye),Z.compileShader(_e),Z.getShaderParameter(_e,Z.COMPILE_STATUS)?_e:(console.log(Z.getShaderInfoLog(_e)),null)};this.uniform={},this.attribute={};var ne=Fe(ae,Te,ae.VERTEX_SHADER),q=Fe(ae,Se,ae.FRAGMENT_SHADER);for(var re in this.id=ae.createProgram(),ae.attachShader(this.id,ne),ae.attachShader(this.id,q),ae.linkProgram(this.id),ae.getProgramParameter(this.id,ae.LINK_STATUS)||console.log(ae.getProgramInfoLog(this.id)),ae.useProgram(this.id),Ve(Te,"attribute",this.attribute),this.attribute)this.attribute[re]=ae.getAttribLocation(this.id,re);for(var j in Ve(Te,"uniform",this.uniform),Ve(Se,"uniform",this.uniform),this.uniform)this.uniform[j]=ae.getUniformLocation(this.id,j)}function $e(ae,Te,Se,Ve){for(var Fe=[],ne=0;ne<Te.length;++ne)Fe.push(Pc(ae,Te[ne],ae[ar[ne]]));return function(q,re,j,Z){var ye=q.createProgram();return re.forEach(function(ie){q.attachShader(ye,ie)}),j&&j.forEach(function(ie,_e){q.bindAttribLocation(ye,Z?Z[_e]:_e,ie)}),q.linkProgram(ye),q.getProgramParameter(ye,q.LINK_STATUS)?ye:(q.deleteProgram(ye),null)}(ae,Fe,Se,Ve)}var ar=["VERTEX_SHADER","FRAGMENT_SHADER"];function Pc(ae,Te,Se){var Ve=ae.createShader(Se);return ae.shaderSource(Ve,Te),ae.compileShader(Ve),ae.getShaderParameter(Ve,ae.COMPILE_STATUS)?Ve:(ae.deleteShader(Ve),null)}var Eo=function(){function ae(Te){Pe(this,ae),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 ut(ae,[{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 Ve=this.beautyParams,Fe=Ve.beauty,ne=Ve.brightness,q=Ve.ruddy,re=2/this.width,j=2/this.height,Z=this.compileBeautyShader();this.gl.uniform2f(Z.uniform.singleStepOffset,re,j);var ye=new Float32Array([1-.8*Fe,1-.6*Fe,.1+.45*q,.1+.45*q]);this.gl.uniform4fv(Z.uniform.params,ye),this.gl.uniform1f(Z.uniform.brightness,.12*ne),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 Mt(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
+ `),["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,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}}]),ae}(),Co=function(){function ae(ne){Pe(this,ae),this.canvas=ne.canvas,this.video=ne.video,this.width=ne.width||640,this.height=ne.height||480,this.onoverload=ne.onoverload,this.gl=this.createGL(ne.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,Ve,Fe;return ut(ae,[{key:"loadResources",value:(Fe=z(V().mark(function ne(){return V().wrap(function(q){for(;;)switch(q.prev=q.next){case 0:return q.next=2,new window.SelfieSegmentation({locateFile:function(re){return"https://web.sdk.qcloud.com/trtc/webrtc/download/segmentation/".concat(re)}});case 2:return this.selfieSegmentation=q.sent,q.next=5,this.selfieSegmentation.initialize();case 5:case"end":return q.stop()}},ne,this)})),function(){return Fe.apply(this,arguments)})},{key:"setEnable",value:function(ne){this.enable=ne}},{key:"initVirtualParams",value:(Ve=z(V().mark(function ne(q){var re,j;return V().wrap(function(Z){for(;;)switch(Z.prev=Z.next){case 0:if(re=q.img,j=q.type,this.type=j==="blur"?0:1,!re){Z.next=5;break}return Z.next=5,this.setBackground(re);case 5:this.type===0?this.initBackgroundBlurProgram():this.type===1&&this.initVirtualBackgroundProgram();case 6:case"end":return Z.stop()}},ne,this)})),function(ne){return Ve.apply(this,arguments)})},{key:"setBackground",value:(Se=z(V().mark(function ne(q){var re=this;return V().wrap(function(j){for(;;)switch(j.prev=j.next){case 0:return j.abrupt("return",new Promise(function(Z,ye){try{q instanceof HTMLImageElement?(re.img=q,Z()):(re.tempImg.onload=function(){re.imgCropCanvasCtx.drawImage(re.tempImg,0,0,re.width,re.height);var ie=re.imgCropCanvas.toDataURL("image/jpeg",.5);re.img.src=ie,re.imgMap.set(q,ie),Z()},re.imgMap.has(q)?(re.img.src=re.imgMap.get(q),Z()):re.tempImg.src=q)}catch(ie){ye("please check the img parameter!")}}));case 1:case"end":return j.stop()}},ne)})),function(ne){return Se.apply(this,arguments)})},{key:"setRect",value:function(ne,q){this.width=ne,this.height=q,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=ne,this.img.height=q,this.img.src=this.imgCropCanvas.toDataURL("image/jpeg",.5),this.tempImg.width=ne,this.tempImg.height=q}},{key:"createGL",value:function(ne){var q=ne.getContext("webgl2");if(q||ne.getContext("experimental-webgl",{preserveDrawingBuffer:!0}),!q)throw"Couldn't get WebGL context";return q}},{key:"setRectangle",value:function(ne,q,re,j,Z){var ye=q,ie=q+j,_e=re,De=re+Z;ne.bufferData(ne.ARRAY_BUFFER,new Float32Array([ye,_e,ie,_e,ye,De,ye,De,ie,_e,ie,De]),ne.STATIC_DRAW)}},{key:"startVirtual",value:function(ne){this.frameRate=ne,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=z(V().mark(function ne(){var q,re,j=this;return V().wrap(function(Z){for(;;)switch(Z.prev=Z.next){case 0:if(this.isRender){Z.next=2;break}return Z.abrupt("return");case 2:if(!((q=new Date().getTime())-this.startTime>1e3/this.frameRate)){Z.next=12;break}if(!this.enable||this.video.readyState!==this.video.HAVE_ENOUGH_DATA){Z.next=7;break}return Z.next=7,this.selfieSegmentation.send({image:this.video});case 7:re=q-this.startTime,this.processingTimes.push(re),this.processingTimes.length>100&&this.processingTimes.shift(),this.frameCount>=100?this.processingTimes.reduce(function(ye,ie){return ye+ie},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=q;case 12:document.hidden?(this.timeoutId&&clearTimeout(this.timeoutId),this.rafId&&cancelAnimationFrame(this.rafId),this.timeoutId=setTimeout(function(){j.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 Z.stop()}},ne,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 ne=this.gl,q={vertexShaderSource:`#version 300 es
109
+
110
+ // an attribute is an input (in) to a vertex shader.
111
+ // It will receive data from a buffer
112
+ in vec2 position;
113
+ in vec2 texCoord;
114
+
115
+ // Used to pass in the resolution of the canvas
116
+ uniform vec2 resolution;
117
+
118
+ // Used to pass the texture coordinates to the fragment shader
119
+ out vec2 v_texCoord;
120
+
121
+ // all shaders have a main function
122
+ void main() {
123
+
124
+ // convert the position from pixels to 0.0 to 1.0
125
+ vec2 zeroToOne = position / resolution;
126
+
127
+ // convert from 0->1 to 0->2
128
+ vec2 zeroToTwo = zeroToOne * 2.0;
129
+
130
+ // convert from 0->2 to -1->+1 (clipspace)
131
+ vec2 clipSpace = zeroToTwo - 1.0;
132
+
133
+ gl_Position = vec4(clipSpace * vec2(1, -1), 0, 1);
134
+
135
+ // pass the texCoord to the fragment shader
136
+ // The GPU will interpolate this value between points.
137
+ v_texCoord = texCoord;
138
+ }
139
+ `,fragmentShaderSource:`#version 300 es
140
+
141
+ // fragment shaders don't have a default precision so we need
142
+ // to pick one. highp is a good default. It means "high precision"
143
+ precision highp float;
144
+
145
+ // our texture
146
+ uniform sampler2D u_image0;
147
+ uniform sampler2D u_image1;
148
+
149
+ // the texCoords passed in from the vertex shader.
150
+ in vec2 v_texCoord;
151
+
152
+ // we need to declare an output for the fragment shader
153
+ out vec4 outColor;
154
+
155
+ void main() {
156
+ vec2 onePixel = vec2(1) / vec2(textureSize(u_image0, 0));
157
+
158
+ vec4 color0 = texture(u_image0, v_texCoord);
159
+ vec4 color1 = texture(u_image1, v_texCoord);
160
+
161
+ vec4 gaussianBlur = vec4(0.0);
162
+
163
+ gaussianBlur += texture(u_image1, v_texCoord+ vec2(-12.0 * onePixel.x, -12.0 * onePixel.y)) * 0.004937634762006754;
164
+ gaussianBlur += texture(u_image1, v_texCoord+ vec2(-12.0 * onePixel.x, -10.0 * onePixel.y)) * 0.00572726182364418;
165
+ gaussianBlur += texture(u_image1, v_texCoord+ vec2(-12.0 * onePixel.x, -8.0 * onePixel.y)) * 0.006427731733273422;
166
+ gaussianBlur += texture(u_image1, v_texCoord+ vec2(-12.0 * onePixel.x, -6.0 * onePixel.y)) * 0.006979930414848231;
167
+ gaussianBlur += texture(u_image1, v_texCoord+ vec2(-12.0 * onePixel.x, -4.0 * onePixel.y)) * 0.007333766846250579;
168
+ gaussianBlur += texture(u_image1, v_texCoord+ vec2(-12.0 * onePixel.x, -2.0 * onePixel.y)) * 0.0074556543695930904;
169
+ gaussianBlur += texture(u_image1, v_texCoord+ vec2(-12.0 * onePixel.x, 0.0 * onePixel.y)) * 0.007333766846250585;
170
+ gaussianBlur += texture(u_image1, v_texCoord+ vec2(-12.0 * onePixel.x, 2.0 * onePixel.y)) * 0.0069799304148482205;
171
+ gaussianBlur += texture(u_image1, v_texCoord+ vec2(-12.0 * onePixel.x, 4.0 * onePixel.y)) * 0.006427731733273439;
172
+ gaussianBlur += texture(u_image1, v_texCoord+ vec2(-12.0 * onePixel.x, 6.0 * onePixel.y)) * 0.0057272618236441745;
173
+ gaussianBlur += texture(u_image1, v_texCoord+ vec2(-12.0 * onePixel.x, 8.0 * onePixel.y)) * 0.004937634762006749;
174
+ gaussianBlur += texture(u_image1, v_texCoord+ vec2(-10.0 * onePixel.x, -12.0 * onePixel.y)) * 0.00572726182364418;
175
+ gaussianBlur += texture(u_image1, v_texCoord+ vec2(-10.0 * onePixel.x, -10.0 * onePixel.y)) * 0.006643166126617444;
176
+ gaussianBlur += texture(u_image1, v_texCoord+ vec2(-10.0 * onePixel.x, -8.0 * onePixel.y)) * 0.007455655256615504;
177
+ gaussianBlur += texture(u_image1, v_texCoord+ vec2(-10.0 * onePixel.x, -6.0 * onePixel.y)) * 0.008096161608439047;
178
+ gaussianBlur += texture(u_image1, v_texCoord+ vec2(-10.0 * onePixel.x, -4.0 * onePixel.y)) * 0.008506583598534066;
179
+ gaussianBlur += texture(u_image1, v_texCoord+ vec2(-10.0 * onePixel.x, -2.0 * onePixel.y)) * 0.008647963387211346;
180
+ gaussianBlur += texture(u_image1, v_texCoord+ vec2(-10.0 * onePixel.x, 0.0 * onePixel.y)) * 0.008506583598534071;
181
+ gaussianBlur += texture(u_image1, v_texCoord+ vec2(-10.0 * onePixel.x, 2.0 * onePixel.y)) * 0.008096161608439035;
182
+ gaussianBlur += texture(u_image1, v_texCoord+ vec2(-10.0 * onePixel.x, 4.0 * onePixel.y)) * 0.007455655256615524;
183
+ gaussianBlur += texture(u_image1, v_texCoord+ vec2(-10.0 * onePixel.x, 6.0 * onePixel.y)) * 0.006643166126617437;
184
+ gaussianBlur += texture(u_image1, v_texCoord+ vec2(-10.0 * onePixel.x, 8.0 * onePixel.y)) * 0.005727261823644173;
185
+ gaussianBlur += texture(u_image1, v_texCoord+ vec2(-8.0 * onePixel.x, -12.0 * onePixel.y)) * 0.006427731733273422;
186
+ gaussianBlur += texture(u_image1, v_texCoord+ vec2(-8.0 * onePixel.x, -10.0 * onePixel.y)) * 0.007455655256615504;
187
+ gaussianBlur += texture(u_image1, v_texCoord+ vec2(-8.0 * onePixel.x, -8.0 * onePixel.y)) * 0.008367515465671788;
188
+ gaussianBlur += texture(u_image1, v_texCoord+ vec2(-8.0 * onePixel.x, -6.0 * onePixel.y)) * 0.009086358628382269;
189
+ gaussianBlur += texture(u_image1, v_texCoord+ vec2(-8.0 * onePixel.x, -4.0 * onePixel.y)) * 0.009546977075905662;
190
+ gaussianBlur += texture(u_image1, v_texCoord+ vec2(-8.0 * onePixel.x, -2.0 * onePixel.y)) * 0.009705648249340199;
191
+ gaussianBlur += texture(u_image1, v_texCoord+ vec2(-8.0 * onePixel.x, 0.0 * onePixel.y)) * 0.00954697707590567;
192
+ gaussianBlur += texture(u_image1, v_texCoord+ vec2(-8.0 * onePixel.x, 2.0 * onePixel.y)) * 0.009086358628382255;
193
+ gaussianBlur += texture(u_image1, v_texCoord+ vec2(-8.0 * onePixel.x, 4.0 * onePixel.y)) * 0.00836751546567181;
194
+ gaussianBlur += texture(u_image1, v_texCoord+ vec2(-8.0 * onePixel.x, 6.0 * onePixel.y)) * 0.007455655256615497;
195
+ gaussianBlur += texture(u_image1, v_texCoord+ vec2(-8.0 * onePixel.x, 8.0 * onePixel.y)) * 0.006427731733273414;
196
+ gaussianBlur += texture(u_image1, v_texCoord+ vec2(-6.0 * onePixel.x, -12.0 * onePixel.y)) * 0.006979930414848231;
197
+ gaussianBlur += texture(u_image1, v_texCoord+ vec2(-6.0 * onePixel.x, -10.0 * onePixel.y)) * 0.008096161608439047;
198
+ gaussianBlur += texture(u_image1, v_texCoord+ vec2(-6.0 * onePixel.x, -8.0 * onePixel.y)) * 0.009086358628382269;
199
+ gaussianBlur += texture(u_image1, v_texCoord+ vec2(-6.0 * onePixel.x, -6.0 * onePixel.y)) * 0.009866956740300258;
200
+ gaussianBlur += texture(u_image1, v_texCoord+ vec2(-6.0 * onePixel.x, -4.0 * onePixel.y)) * 0.010367146363159857;
201
+ gaussianBlur += texture(u_image1, v_texCoord+ vec2(-6.0 * onePixel.x, -2.0 * onePixel.y)) * 0.010539448785751998;
202
+ gaussianBlur += texture(u_image1, v_texCoord+ vec2(-6.0 * onePixel.x, 0.0 * onePixel.y)) * 0.010367146363159866;
203
+ gaussianBlur += texture(u_image1, v_texCoord+ vec2(-6.0 * onePixel.x, 2.0 * onePixel.y)) * 0.009866956740300243;
204
+ gaussianBlur += texture(u_image1, v_texCoord+ vec2(-6.0 * onePixel.x, 4.0 * onePixel.y)) * 0.009086358628382293;
205
+ gaussianBlur += texture(u_image1, v_texCoord+ vec2(-6.0 * onePixel.x, 6.0 * onePixel.y)) * 0.00809616160843904;
206
+ gaussianBlur += texture(u_image1, v_texCoord+ vec2(-6.0 * onePixel.x, 8.0 * onePixel.y)) * 0.006979930414848224;
207
+ gaussianBlur += texture(u_image1, v_texCoord+ vec2(-4.0 * onePixel.x, -12.0 * onePixel.y)) * 0.007333766846250579;
208
+ gaussianBlur += texture(u_image1, v_texCoord+ vec2(-4.0 * onePixel.x, -10.0 * onePixel.y)) * 0.008506583598534066;
209
+ gaussianBlur += texture(u_image1, v_texCoord+ vec2(-4.0 * onePixel.x, -8.0 * onePixel.y)) * 0.009546977075905662;
210
+ gaussianBlur += texture(u_image1, v_texCoord+ vec2(-4.0 * onePixel.x, -6.0 * onePixel.y)) * 0.010367146363159857;
211
+ gaussianBlur += texture(u_image1, v_texCoord+ vec2(-4.0 * onePixel.x, -4.0 * onePixel.y)) * 0.010892692300575347;
212
+ gaussianBlur += texture(u_image1, v_texCoord+ vec2(-4.0 * onePixel.x, -2.0 * onePixel.y)) * 0.01107372931946121;
213
+ gaussianBlur += texture(u_image1, v_texCoord+ vec2(-4.0 * onePixel.x, 0.0 * onePixel.y)) * 0.010892692300575355;
214
+ gaussianBlur += texture(u_image1, v_texCoord+ vec2(-4.0 * onePixel.x, 2.0 * onePixel.y)) * 0.01036714636315984;
215
+ gaussianBlur += texture(u_image1, v_texCoord+ vec2(-4.0 * onePixel.x, 4.0 * onePixel.y)) * 0.009546977075905686;
216
+ gaussianBlur += texture(u_image1, v_texCoord+ vec2(-4.0 * onePixel.x, 6.0 * onePixel.y)) * 0.008506583598534057;
217
+ gaussianBlur += texture(u_image1, v_texCoord+ vec2(-4.0 * onePixel.x, 8.0 * onePixel.y)) * 0.007333766846250571;
218
+ gaussianBlur += texture(u_image1, v_texCoord+ vec2(-2.0 * onePixel.x, -12.0 * onePixel.y)) * 0.0074556543695930904;
219
+ gaussianBlur += texture(u_image1, v_texCoord+ vec2(-2.0 * onePixel.x, -10.0 * onePixel.y)) * 0.008647963387211346;
220
+ gaussianBlur += texture(u_image1, v_texCoord+ vec2(-2.0 * onePixel.x, -8.0 * onePixel.y)) * 0.009705648249340199;
221
+ gaussianBlur += texture(u_image1, v_texCoord+ vec2(-2.0 * onePixel.x, -6.0 * onePixel.y)) * 0.010539448785751998;
222
+ gaussianBlur += texture(u_image1, v_texCoord+ vec2(-2.0 * onePixel.x, -4.0 * onePixel.y)) * 0.01107372931946121;
223
+ gaussianBlur += texture(u_image1, v_texCoord+ vec2(-2.0 * onePixel.x, -2.0 * onePixel.y)) * 0.011257775181459748;
224
+ gaussianBlur += texture(u_image1, v_texCoord+ vec2(-2.0 * onePixel.x, 0.0 * onePixel.y)) * 0.011073729319461219;
225
+ gaussianBlur += texture(u_image1, v_texCoord+ vec2(-2.0 * onePixel.x, 2.0 * onePixel.y)) * 0.010539448785751979;
226
+ gaussianBlur += texture(u_image1, v_texCoord+ vec2(-2.0 * onePixel.x, 4.0 * onePixel.y)) * 0.009705648249340225;
227
+ gaussianBlur += texture(u_image1, v_texCoord+ vec2(-2.0 * onePixel.x, 6.0 * onePixel.y)) * 0.008647963387211337;
228
+ gaussianBlur += texture(u_image1, v_texCoord+ vec2(-2.0 * onePixel.x, 8.0 * onePixel.y)) * 0.007455654369593082;
229
+ gaussianBlur += texture(u_image1, v_texCoord+ vec2(0.0 * onePixel.x, -12.0 * onePixel.y)) * 0.007333766846250585;
230
+ gaussianBlur += texture(u_image1, v_texCoord+ vec2(0.0 * onePixel.x, -10.0 * onePixel.y)) * 0.008506583598534071;
231
+ gaussianBlur += texture(u_image1, v_texCoord+ vec2(0.0 * onePixel.x, -8.0 * onePixel.y)) * 0.00954697707590567;
232
+ gaussianBlur += texture(u_image1, v_texCoord+ vec2(0.0 * onePixel.x, -6.0 * onePixel.y)) * 0.010367146363159866;
233
+ gaussianBlur += texture(u_image1, v_texCoord+ vec2(0.0 * onePixel.x, -4.0 * onePixel.y)) * 0.010892692300575355;
234
+ gaussianBlur += texture(u_image1, v_texCoord+ vec2(0.0 * onePixel.x, -2.0 * onePixel.y)) * 0.011073729319461219;
235
+ gaussianBlur += texture(u_image1, v_texCoord+ vec2(0.0 * onePixel.x, 0.0 * onePixel.y)) * 0.010892692300575364;
236
+ gaussianBlur += texture(u_image1, v_texCoord+ vec2(0.0 * onePixel.x, 2.0 * onePixel.y)) * 0.01036714636315985;
237
+ gaussianBlur += texture(u_image1, v_texCoord+ vec2(0.0 * onePixel.x, 4.0 * onePixel.y)) * 0.009546977075905695;
238
+ gaussianBlur += texture(u_image1, v_texCoord+ vec2(0.0 * onePixel.x, 6.0 * onePixel.y)) * 0.008506583598534064;
239
+ gaussianBlur += texture(u_image1, v_texCoord+ vec2(0.0 * onePixel.x, 8.0 * onePixel.y)) * 0.007333766846250576;
240
+ gaussianBlur += texture(u_image1, v_texCoord+ vec2(2.0 * onePixel.x, -12.0 * onePixel.y)) * 0.0069799304148482205;
241
+ gaussianBlur += texture(u_image1, v_texCoord+ vec2(2.0 * onePixel.x, -10.0 * onePixel.y)) * 0.008096161608439035;
242
+ gaussianBlur += texture(u_image1, v_texCoord+ vec2(2.0 * onePixel.x, -8.0 * onePixel.y)) * 0.009086358628382255;
243
+ gaussianBlur += texture(u_image1, v_texCoord+ vec2(2.0 * onePixel.x, -6.0 * onePixel.y)) * 0.009866956740300243;
244
+ gaussianBlur += texture(u_image1, v_texCoord+ vec2(2.0 * onePixel.x, -4.0 * onePixel.y)) * 0.01036714636315984;
245
+ gaussianBlur += texture(u_image1, v_texCoord+ vec2(2.0 * onePixel.x, -2.0 * onePixel.y)) * 0.010539448785751979;
246
+ gaussianBlur += texture(u_image1, v_texCoord+ vec2(2.0 * onePixel.x, 0.0 * onePixel.y)) * 0.01036714636315985;
247
+ gaussianBlur += texture(u_image1, v_texCoord+ vec2(2.0 * onePixel.x, 2.0 * onePixel.y)) * 0.009866956740300227;
248
+ gaussianBlur += texture(u_image1, v_texCoord+ vec2(2.0 * onePixel.x, 4.0 * onePixel.y)) * 0.00908635862838228;
249
+ gaussianBlur += texture(u_image1, v_texCoord+ vec2(2.0 * onePixel.x, 6.0 * onePixel.y)) * 0.008096161608439026;
250
+ gaussianBlur += texture(u_image1, v_texCoord+ vec2(2.0 * onePixel.x, 8.0 * onePixel.y)) * 0.006979930414848213;
251
+ gaussianBlur += texture(u_image1, v_texCoord+ vec2(4.0 * onePixel.x, -12.0 * onePixel.y)) * 0.006427731733273439;
252
+ gaussianBlur += texture(u_image1, v_texCoord+ vec2(4.0 * onePixel.x, -10.0 * onePixel.y)) * 0.007455655256615524;
253
+ gaussianBlur += texture(u_image1, v_texCoord+ vec2(4.0 * onePixel.x, -8.0 * onePixel.y)) * 0.00836751546567181;
254
+ gaussianBlur += texture(u_image1, v_texCoord+ vec2(4.0 * onePixel.x, -6.0 * onePixel.y)) * 0.009086358628382293;
255
+ gaussianBlur += texture(u_image1, v_texCoord+ vec2(4.0 * onePixel.x, -4.0 * onePixel.y)) * 0.009546977075905686;
256
+ gaussianBlur += texture(u_image1, v_texCoord+ vec2(4.0 * onePixel.x, -2.0 * onePixel.y)) * 0.009705648249340225;
257
+ gaussianBlur += texture(u_image1, v_texCoord+ vec2(4.0 * onePixel.x, 0.0 * onePixel.y)) * 0.009546977075905695;
258
+ gaussianBlur += texture(u_image1, v_texCoord+ vec2(4.0 * onePixel.x, 2.0 * onePixel.y)) * 0.00908635862838228;
259
+ gaussianBlur += texture(u_image1, v_texCoord+ vec2(4.0 * onePixel.x, 4.0 * onePixel.y)) * 0.008367515465671832;
260
+ gaussianBlur += texture(u_image1, v_texCoord+ vec2(4.0 * onePixel.x, 6.0 * onePixel.y)) * 0.007455655256615516;
261
+ gaussianBlur += texture(u_image1, v_texCoord+ vec2(4.0 * onePixel.x, 8.0 * onePixel.y)) * 0.006427731733273432;
262
+ gaussianBlur += texture(u_image1, v_texCoord+ vec2(6.0 * onePixel.x, -12.0 * onePixel.y)) * 0.0057272618236441745;
263
+ gaussianBlur += texture(u_image1, v_texCoord+ vec2(6.0 * onePixel.x, -10.0 * onePixel.y)) * 0.006643166126617437;
264
+ gaussianBlur += texture(u_image1, v_texCoord+ vec2(6.0 * onePixel.x, -8.0 * onePixel.y)) * 0.007455655256615497;
265
+ gaussianBlur += texture(u_image1, v_texCoord+ vec2(6.0 * onePixel.x, -6.0 * onePixel.y)) * 0.00809616160843904;
266
+ gaussianBlur += texture(u_image1, v_texCoord+ vec2(6.0 * onePixel.x, -4.0 * onePixel.y)) * 0.008506583598534057;
267
+ gaussianBlur += texture(u_image1, v_texCoord+ vec2(6.0 * onePixel.x, -2.0 * onePixel.y)) * 0.008647963387211337;
268
+ gaussianBlur += texture(u_image1, v_texCoord+ vec2(6.0 * onePixel.x, 0.0 * onePixel.y)) * 0.008506583598534064;
269
+ gaussianBlur += texture(u_image1, v_texCoord+ vec2(6.0 * onePixel.x, 2.0 * onePixel.y)) * 0.008096161608439026;
270
+ gaussianBlur += texture(u_image1, v_texCoord+ vec2(6.0 * onePixel.x, 4.0 * onePixel.y)) * 0.007455655256615516;
271
+ gaussianBlur += texture(u_image1, v_texCoord+ vec2(6.0 * onePixel.x, 6.0 * onePixel.y)) * 0.00664316612661743;
272
+ gaussianBlur += texture(u_image1, v_texCoord+ vec2(6.0 * onePixel.x, 8.0 * onePixel.y)) * 0.005727261823644167;
273
+ gaussianBlur += texture(u_image1, v_texCoord+ vec2(8.0 * onePixel.x, -12.0 * onePixel.y)) * 0.004937634762006749;
274
+ gaussianBlur += texture(u_image1, v_texCoord+ vec2(8.0 * onePixel.x, -10.0 * onePixel.y)) * 0.005727261823644173;
275
+ gaussianBlur += texture(u_image1, v_texCoord+ vec2(8.0 * onePixel.x, -8.0 * onePixel.y)) * 0.006427731733273414;
276
+ gaussianBlur += texture(u_image1, v_texCoord+ vec2(8.0 * onePixel.x, -6.0 * onePixel.y)) * 0.006979930414848224;
277
+ gaussianBlur += texture(u_image1, v_texCoord+ vec2(8.0 * onePixel.x, -4.0 * onePixel.y)) * 0.007333766846250571;
278
+ gaussianBlur += texture(u_image1, v_texCoord+ vec2(8.0 * onePixel.x, -2.0 * onePixel.y)) * 0.007455654369593082;
279
+ gaussianBlur += texture(u_image1, v_texCoord+ vec2(8.0 * onePixel.x, 0.0 * onePixel.y)) * 0.007333766846250576;
280
+ gaussianBlur += texture(u_image1, v_texCoord+ vec2(8.0 * onePixel.x, 2.0 * onePixel.y)) * 0.006979930414848213;
281
+ gaussianBlur += texture(u_image1, v_texCoord+ vec2(8.0 * onePixel.x, 4.0 * onePixel.y)) * 0.006427731733273432;
282
+ gaussianBlur += texture(u_image1, v_texCoord+ vec2(8.0 * onePixel.x, 6.0 * onePixel.y)) * 0.005727261823644167;
283
+ gaussianBlur += texture(u_image1, v_texCoord+ vec2(8.0 * onePixel.x, 8.0 * onePixel.y)) * 0.004937634762006742;
284
+
285
+ outColor = (1.0 - color0.r) * gaussianBlur + color0.r * color1;
286
+ }
287
+ `},re=q.vertexShaderSource,j=q.fragmentShaderSource;this.program=$e(ne,[re,j]);var Z=ne.getAttribLocation(this.program,"position"),ye=ne.getAttribLocation(this.program,"texCoord");this.blurParams.resolutionLocation=ne.getUniformLocation(this.program,"resolution"),this.blurParams.imageLocation0=ne.getUniformLocation(this.program,"u_image0"),this.blurParams.imageLocation1=ne.getUniformLocation(this.program,"u_image1"),ne.bindVertexArray(this.vao),ne.bindBuffer(ne.ARRAY_BUFFER,this.positionBuffer),ne.enableVertexAttribArray(Z),ne.vertexAttribPointer(Z,2,ne.FLOAT,!1,0,0),ne.bindBuffer(ne.ARRAY_BUFFER,ne.createBuffer()),ne.bufferData(ne.ARRAY_BUFFER,new Float32Array([0,0,1,0,0,1,0,1,1,0,1,1]),ne.STATIC_DRAW),ne.enableVertexAttribArray(ye),ne.vertexAttribPointer(ye,2,ne.FLOAT,!1,0,0)}},{key:"onBlurResult",value:function(ne){for(var q=ne.segmentationMask,re=ne.image,j=this.gl,Z=[],ye=[q,re],ie=0;ie<2;++ie){var _e=j.createTexture();j.bindTexture(j.TEXTURE_2D,_e),j.texParameteri(j.TEXTURE_2D,j.TEXTURE_WRAP_S,j.CLAMP_TO_EDGE),j.texParameteri(j.TEXTURE_2D,j.TEXTURE_WRAP_T,j.CLAMP_TO_EDGE),j.texParameteri(j.TEXTURE_2D,j.TEXTURE_MIN_FILTER,j.NEAREST),j.texParameteri(j.TEXTURE_2D,j.TEXTURE_MAG_FILTER,j.NEAREST),j.texImage2D(j.TEXTURE_2D,0,j.RGBA,j.RGBA,j.UNSIGNED_BYTE,ye[ie]),Z.push(_e)}j.bindBuffer(j.ARRAY_BUFFER,this.positionBuffer),this.setRectangle(j,0,0,this.width,this.height),j.viewport(0,0,this.width,this.height),j.clearColor(0,0,0,0),j.clear(j.COLOR_BUFFER_BIT|j.DEPTH_BUFFER_BIT),j.useProgram(this.program),j.bindVertexArray(this.vao);var De=this.blurParams,Gt=De.resolutionLocation,qt=De.imageLocation0,Ke=De.imageLocation1;j.uniform2f(Gt,this.width,this.height),j.uniform1i(qt,0),j.uniform1i(Ke,1),j.activeTexture(j.TEXTURE0),j.bindTexture(j.TEXTURE_2D,Z[0]),j.activeTexture(j.TEXTURE1),j.bindTexture(j.TEXTURE_2D,Z[1]),j.drawArrays(j.TRIANGLES,0,6)}},{key:"initVirtualBackgroundProgram",value:function(){var ne=this.gl,q={vertexShaderSource:`#version 300 es
288
+
289
+ // an attribute is an input (in) to a vertex shader.
290
+ // It will receive data from a buffer
291
+ in vec2 position;
292
+ in vec2 texCoord;
293
+
294
+ // Used to pass in the resolution of the canvas
295
+ uniform vec2 resolution;
296
+
297
+ // Used to pass the texture coordinates to the fragment shader
298
+ out vec2 v_texCoord;
299
+
300
+ // all shaders have a main function
301
+ void main() {
302
+
303
+ // convert the position from pixels to 0.0 to 1.0
304
+ vec2 zeroToOne = position / resolution;
305
+
306
+ // convert from 0->1 to 0->2
307
+ vec2 zeroToTwo = zeroToOne * 2.0;
308
+
309
+ // convert from 0->2 to -1->+1 (clipspace)
310
+ vec2 clipSpace = zeroToTwo - 1.0;
311
+
312
+ gl_Position = vec4(clipSpace * vec2(1, -1), 0, 1);
313
+
314
+ // pass the texCoord to the fragment shader
315
+ // The GPU will interpolate this value between points.
316
+ v_texCoord = texCoord;
317
+ }
318
+ `,fragmentShaderSource:`#version 300 es
319
+
320
+ // fragment shaders don't have a default precision so we need
321
+ // to pick one. highp is a good default. It means "high precision"
322
+ precision highp float;
323
+
324
+ // Some hyperParameter:
325
+ uniform int PostProcessType;
326
+ uniform int MSIZE;
327
+ uniform float SIGMA;
328
+ uniform float BSIGMA;
329
+ uniform int overlayType;
330
+ uniform float hardThreshold;
331
+ uniform int sigmoidClip;
332
+
333
+ // our texture
334
+ uniform sampler2D u_image0;
335
+ uniform sampler2D u_image1;
336
+ uniform sampler2D u_image2;
337
+
338
+ // time-wise texture
339
+ uniform sampler2D u_image_old0;
340
+ uniform sampler2D u_image_old1;
341
+ uniform sampler2D u_image_old2;
342
+ uniform sampler2D u_image_old3;
343
+ uniform sampler2D u_image_old4;
344
+ uniform sampler2D u_image_old5;
345
+
346
+ // the texCoords passed in from the vertex shader.
347
+ in vec2 v_texCoord;
348
+
349
+ // we need to declare an output for the fragment shader
350
+ out vec4 outColor;
351
+
352
+ float normpdf(in float x, in float sigma)
353
+ {
354
+ return 0.39894*exp(-0.5*x*x/(sigma*sigma))/sigma;
355
+ }
356
+
357
+ float normpdf3(in vec3 v, in float sigma)
358
+ {
359
+ return 0.39894*exp(-0.5*dot(v,v)/(sigma*sigma))/sigma;
360
+ }
361
+
362
+ void main() {
363
+ vec2 onePixel = vec2(1) / vec2(textureSize(u_image0, 0));
364
+
365
+ vec4 color0 = texture(u_image0, v_texCoord); // mask. r & a are same.
366
+ vec4 color1 = texture(u_image1, v_texCoord); // video image.
367
+ vec4 color2 = texture(u_image2, v_texCoord); // background image.
368
+ vec4 color_old0 = texture(u_image_old0, v_texCoord); // old mask(3 frames old)
369
+ vec4 color_old1 = texture(u_image_old1, v_texCoord); // old mask(2 frames old)
370
+ vec4 color_old2 = texture(u_image_old2, v_texCoord); // old mask(1 frames old)
371
+ vec4 color_old3 = texture(u_image_old3, v_texCoord); // old video image(3 frames old)
372
+ vec4 color_old4 = texture(u_image_old4, v_texCoord); // old video image(2 frames old)
373
+ vec4 color_old5 = texture(u_image_old5, v_texCoord); // old video image(1 frames old)
374
+
375
+ float maskValue = color0.a;
376
+ if (PostProcessType == 0) {
377
+ // Do nothing to the mask. Passthrough.
378
+ }
379
+ else if (PostProcessType == 1) {
380
+ // JBF
381
+ vec4 c = texture(u_image1, v_texCoord);
382
+ int kSize = (MSIZE-1)/2;
383
+ float kernel[40];
384
+ float bfinal_colour = 0.0;
385
+ float bZ = 0.0;
386
+ //create the 1-D kernel
387
+ for (int j = 0; j <= kSize; ++j) {
388
+ kernel[kSize+j] = kernel[kSize-j] = normpdf(float(j), SIGMA);
389
+ }
390
+
391
+ vec3 cc;
392
+ float gfactor;
393
+ float bfactor;
394
+ float bZnorm = 1.0/normpdf(0.0, BSIGMA);
395
+
396
+ for (int i=-kSize; i <= kSize; ++i)
397
+ {
398
+ for (int j=-kSize; j <= kSize; ++j)
399
+ {
400
+ cc = texture(u_image1, v_texCoord+ vec2(float(i) * onePixel.x, float(j) * onePixel.y)).rgb;
401
+
402
+ // compute both the gaussian smoothed and bilateral
403
+ gfactor = kernel[kSize+j]*kernel[kSize+i];
404
+ bfactor = normpdf3(cc-c.rgb, BSIGMA)*bZnorm*gfactor;
405
+ bZ += bfactor;
406
+
407
+ bfinal_colour += bfactor * texture(u_image0, v_texCoord+ vec2(float(i) * onePixel.x, float(j) * onePixel.y)).a;
408
+ }
409
+ }
410
+
411
+ maskValue = bfinal_colour / bZ;
412
+ }
413
+ else if (PostProcessType == 2) {
414
+ // Joint Bilateral filter. + avg time domain filter. Pixel image is time-domain filtered, ref image is not.
415
+ // vec4 c = texture(u_image1, v_texCoord);
416
+ // vec4 c = texture(u_image1, v_texCoord) * 0.25 + texture(u_image_old3, v_texCoord) * 0.25 +
417
+ // texture(u_image_old4, v_texCoord) * 0.25 + texture(u_image_old5, v_texCoord) * 0.25;
418
+ // vec4 c = sqrt(
419
+ // texture(u_image1, v_texCoord) * texture(u_image1, v_texCoord) * 0.25 +
420
+ // texture(u_image1, v_texCoord) * texture(u_image_old3, v_texCoord) * 0.25 +
421
+ // texture(u_image1, v_texCoord) * texture(u_image_old4, v_texCoord) * 0.25 +
422
+ // texture(u_image1, v_texCoord) * texture(u_image_old5, v_texCoord) * 0.25
423
+ // );
424
+ vec4 c = texture(u_image1, v_texCoord) * 0.5 + texture(u_image_old4, v_texCoord) * 0.5;
425
+
426
+ int kSize = (MSIZE-1)/2;
427
+ float kernel[40];
428
+ float bfinal_colour = 0.0;
429
+ float bZ = 0.0;
430
+ //create the 1-D kernel
431
+ for (int j = 0; j <= kSize; ++j) {
432
+ kernel[kSize+j] = kernel[kSize-j] = normpdf(float(j), SIGMA);
433
+ }
434
+
435
+ vec3 cc;
436
+ float gfactor;
437
+ float bfactor;
438
+ float bZnorm = 1.0/normpdf(0.0, BSIGMA);
439
+
440
+ for (int i=-kSize; i <= kSize; ++i)
441
+ {
442
+ for (int j=-kSize; j <= kSize; ++j)
443
+ {
444
+ vec3 p0 = texture(u_image1, v_texCoord+ vec2(float(i) * onePixel.x, float(j) * onePixel.y)).rgb;
445
+ // vec3 p1 = texture(u_image_old3, v_texCoord+ vec2(float(i) * onePixel.x, float(j) * onePixel.y)).rgb;
446
+ // vec3 p2 = texture(u_image_old4, v_texCoord+ vec2(float(i) * onePixel.x, float(j) * onePixel.y)).rgb;
447
+ vec3 p3 = texture(u_image_old5, v_texCoord+ vec2(float(i) * onePixel.x, float(j) * onePixel.y)).rgb;
448
+ cc = p0 * 0.5 + p3 * 0.5;
449
+
450
+ // compute both the gaussian smoothed and bilateral
451
+ gfactor = kernel[kSize+j]*kernel[kSize+i];
452
+ bfactor = normpdf3(cc-c.rgb, BSIGMA)*bZnorm*gfactor;
453
+ bZ += bfactor;
454
+
455
+ // bfinal_colour += bfactor * texture(u_image0, v_texCoord+ vec2(float(i) * onePixel.x, float(j) * onePixel.y)).a;
456
+ float tmp0 = texture(u_image0, v_texCoord+ vec2(float(i) * onePixel.x, float(j) * onePixel.y)).a;
457
+ float tmp1 = texture(u_image_old0, v_texCoord+ vec2(float(i) * onePixel.x, float(j) * onePixel.y)).a;
458
+ float tmp2 = texture(u_image_old1, v_texCoord+ vec2(float(i) * onePixel.x, float(j) * onePixel.y)).a;
459
+ float tmp3 = texture(u_image_old2, v_texCoord+ vec2(float(i) * onePixel.x, float(j) * onePixel.y)).a;
460
+
461
+ bfinal_colour += bfactor * ( tmp0 * 0.5 + tmp3 * 0.5 ); // smooth filter on latest 2 frames.
462
+ }
463
+ }
464
+
465
+ maskValue = bfinal_colour / bZ;
466
+ }
467
+ else if (PostProcessType == 3) {
468
+ // Joint Bilateral filter. + avg time domain filter. Pixel image is time-domain filtered, ref image is not.
469
+ vec4 c = texture(u_image1, v_texCoord) * 0.33 + texture(u_image_old5, v_texCoord) * 0.33 + texture(u_image_old4, v_texCoord) * 0.33;
470
+
471
+ int kSize = (MSIZE-1)/2;
472
+ float kernel[40];
473
+ float bfinal_colour = 0.0;
474
+ float bZ = 0.0;
475
+ //create the 1-D kernel
476
+ for (int j = 0; j <= kSize; ++j) {
477
+ kernel[kSize+j] = kernel[kSize-j] = normpdf(float(j), SIGMA);
478
+ }
479
+
480
+ vec3 cc;
481
+ float gfactor;
482
+ float bfactor;
483
+ float bZnorm = 1.0/normpdf(0.0, BSIGMA);
484
+
485
+ for (int i=-kSize; i <= kSize; ++i)
486
+ {
487
+ for (int j=-kSize; j <= kSize; ++j)
488
+ {
489
+ vec3 p0 = texture(u_image1, v_texCoord+ vec2(float(i) * onePixel.x, float(j) * onePixel.y)).rgb;
490
+ vec3 p2 = texture(u_image_old4, v_texCoord+ vec2(float(i) * onePixel.x, float(j) * onePixel.y)).rgb;
491
+ vec3 p3 = texture(u_image_old5, v_texCoord+ vec2(float(i) * onePixel.x, float(j) * onePixel.y)).rgb;
492
+ cc = p0 * 0.33 + p3 * 0.33 + p2 * 0.33;
493
+
494
+ // compute both the gaussian smoothed and bilateral
495
+ gfactor = kernel[kSize+j]*kernel[kSize+i];
496
+ bfactor = normpdf3(cc-c.rgb, BSIGMA)*bZnorm*gfactor;
497
+ bZ += bfactor;
498
+
499
+ // bfinal_colour += bfactor * texture(u_image0, v_texCoord+ vec2(float(i) * onePixel.x, float(j) * onePixel.y)).a;
500
+ float tmp0 = texture(u_image0, v_texCoord+ vec2(float(i) * onePixel.x, float(j) * onePixel.y)).a;
501
+ float tmp1 = texture(u_image_old0, v_texCoord+ vec2(float(i) * onePixel.x, float(j) * onePixel.y)).a;
502
+ float tmp2 = texture(u_image_old1, v_texCoord+ vec2(float(i) * onePixel.x, float(j) * onePixel.y)).a;
503
+ float tmp3 = texture(u_image_old2, v_texCoord+ vec2(float(i) * onePixel.x, float(j) * onePixel.y)).a;
504
+
505
+ bfinal_colour += bfactor * ( tmp0 * 0.33 + tmp3 * 0.33 + tmp2 * 0.33 ); // smooth filter on latest 3 frames.
506
+ }
507
+ }
508
+
509
+ maskValue = bfinal_colour / bZ;
510
+ }
511
+ else if (PostProcessType == 4) {
512
+ vec4 c = texture(u_image1, v_texCoord) * 0.25 + texture(u_image_old5, v_texCoord) * 0.25 +
513
+ texture(u_image_old4, v_texCoord) * 0.25 + texture(u_image_old3, v_texCoord) * 0.25;
514
+
515
+ int kSize = (MSIZE-1)/2;
516
+ float kernel[40];
517
+ float bfinal_colour = 0.0;
518
+ float bZ = 0.0;
519
+ //create the 1-D kernel
520
+ for (int j = 0; j <= kSize; ++j) {
521
+ kernel[kSize+j] = kernel[kSize-j] = normpdf(float(j), SIGMA);
522
+ }
523
+
524
+ vec3 cc;
525
+ float gfactor;
526
+ float bfactor;
527
+ float bZnorm = 1.0/normpdf(0.0, BSIGMA);
528
+
529
+ for (int i=-kSize; i <= kSize; ++i)
530
+ {
531
+ for (int j=-kSize; j <= kSize; ++j)
532
+ {
533
+ vec3 p0 = texture(u_image1, v_texCoord+ vec2(float(i) * onePixel.x, float(j) * onePixel.y)).rgb;
534
+ vec3 p1 = texture(u_image_old3, v_texCoord+ vec2(float(i) * onePixel.x, float(j) * onePixel.y)).rgb;
535
+ vec3 p2 = texture(u_image_old4, v_texCoord+ vec2(float(i) * onePixel.x, float(j) * onePixel.y)).rgb;
536
+ vec3 p3 = texture(u_image_old5, v_texCoord+ vec2(float(i) * onePixel.x, float(j) * onePixel.y)).rgb;
537
+ cc = p0 * 0.25 + p1 * 0.25 + p2 * 0.25 + p3 * 0.25;
538
+
539
+ // compute both the gaussian smoothed and bilateral
540
+ gfactor = kernel[kSize+j]*kernel[kSize+i];
541
+ bfactor = normpdf3(cc-c.rgb, BSIGMA)*bZnorm*gfactor;
542
+ bZ += bfactor;
543
+
544
+ float tmp0 = texture(u_image0, v_texCoord+ vec2(float(i) * onePixel.x, float(j) * onePixel.y)).a;
545
+ float tmp1 = texture(u_image_old0, v_texCoord+ vec2(float(i) * onePixel.x, float(j) * onePixel.y)).a;
546
+ float tmp2 = texture(u_image_old1, v_texCoord+ vec2(float(i) * onePixel.x, float(j) * onePixel.y)).a;
547
+ float tmp3 = texture(u_image_old2, v_texCoord+ vec2(float(i) * onePixel.x, float(j) * onePixel.y)).a;
548
+
549
+ bfinal_colour += bfactor * ( tmp0 * 0.25 + tmp3 * 0.25 + tmp1 * 0.25 + tmp2 * 0.25 ); // smooth filter on latest 4 frames.
550
+ }
551
+ }
552
+
553
+ maskValue = bfinal_colour / bZ;
554
+ }
555
+
556
+ if (sigmoidClip == 1) {
557
+ maskValue = 1.0 / (1.0 + exp(-10.0 * (maskValue - 0.5)));
558
+ }
559
+
560
+ if (overlayType != 0) {
561
+ maskValue = maskValue > hardThreshold ? 1.0 : 0.0;
562
+ }
563
+
564
+ outColor.rgb = (maskValue * color1 + (1.0 - maskValue) * color2).rgb;
565
+ outColor.a = 1.0;
566
+ }
567
+ `},re=q.vertexShaderSource,j=q.fragmentShaderSource;this.program=$e(ne,[re,j]);var Z=ne.getAttribLocation(this.program,"position"),ye=ne.getAttribLocation(this.program,"texCoord"),ie=this.program;this.virtualParams={resolutionLocation:ne.getUniformLocation(ie,"resolution"),imageLocation0:ne.getUniformLocation(ie,"u_image0"),imageLocation1:ne.getUniformLocation(ie,"u_image1"),imageLocation2:ne.getUniformLocation(ie,"u_image2"),imageOldLocation0:ne.getUniformLocation(ie,"u_image_old0"),imageOldLocation1:ne.getUniformLocation(ie,"u_image_old1"),imageOldLocation2:ne.getUniformLocation(ie,"u_image_old2"),imageOldLocation3:ne.getUniformLocation(ie,"u_image_old3"),imageOldLocation4:ne.getUniformLocation(ie,"u_image_old4"),imageOldLocation5:ne.getUniformLocation(ie,"u_image_old5")},this.virtualLocation={postProcessTypeLocation:ne.getUniformLocation(ie,"PostProcessType"),sigmaLocation:ne.getUniformLocation(ie,"SIGMA"),bSigmaLocation:ne.getUniformLocation(ie,"BSIGMA"),mSizeLocation:ne.getUniformLocation(ie,"MSIZE"),overlayTypeLocation:ne.getUniformLocation(ie,"overlayType"),hardThresholdLocation:ne.getUniformLocation(ie,"hardThreshold"),sigmoidClipLocation:ne.getUniformLocation(ie,"sigmoidClip")},ne.bindVertexArray(this.vao),ne.bindBuffer(ne.ARRAY_BUFFER,this.positionBuffer),ne.enableVertexAttribArray(Z),ne.vertexAttribPointer(Z,2,ne.FLOAT,!1,0,0),ne.bindBuffer(ne.ARRAY_BUFFER,ne.createBuffer()),ne.bufferData(ne.ARRAY_BUFFER,new Float32Array([0,0,1,0,0,1,0,1,1,0,1,1]),ne.STATIC_DRAW),ne.enableVertexAttribArray(ye),ne.vertexAttribPointer(ye,2,ne.FLOAT,!1,0,0)}},{key:"onVirtualResults",value:function(ne){var q=ne.segmentationMask,re=ne.image,j=this.gl;this.maskBuffer.length<3&&this.maskBuffer.push(q,q,q),this.frameBuffer.length<3&&this.frameBuffer.push(re,re,re);for(var Z=[],ye=[q,re,this.img,this.maskBuffer[0],this.maskBuffer[1],this.maskBuffer[2],this.frameBuffer[0],this.frameBuffer[1],this.frameBuffer[2]],ie=0;ie<ye.length;++ie)this.sourceTexture=j.createTexture(),j.bindTexture(j.TEXTURE_2D,this.sourceTexture),j.texParameteri(j.TEXTURE_2D,j.TEXTURE_WRAP_S,j.CLAMP_TO_EDGE),j.texParameteri(j.TEXTURE_2D,j.TEXTURE_WRAP_T,j.CLAMP_TO_EDGE),j.texParameteri(j.TEXTURE_2D,j.TEXTURE_MIN_FILTER,j.NEAREST),j.texParameteri(j.TEXTURE_2D,j.TEXTURE_MAG_FILTER,j.NEAREST),j.texImage2D(j.TEXTURE_2D,0,j.RGBA,j.RGBA,j.UNSIGNED_BYTE,ye[ie]),Z.push(this.sourceTexture);j.bindBuffer(j.ARRAY_BUFFER,this.positionBuffer),this.setRectangle(j,0,0,this.width,this.height),j.viewport(0,0,this.width,this.height),j.clearColor(0,0,0,0),j.clear(j.COLOR_BUFFER_BIT|j.DEPTH_BUFFER_BIT),j.useProgram(this.program),j.bindVertexArray(this.vao);var _e=this.virtualParams,De=_e.resolutionLocation,Gt=_e.imageLocation0,qt=_e.imageLocation1,Ke=_e.imageLocation2,Ht=_e.imageOldLocation0,lt=_e.imageOldLocation1,Gn=_e.imageOldLocation2,or=_e.imageOldLocation3,Ut=_e.imageOldLocation4,En=_e.imageOldLocation5;j.uniform2f(De,this.width,this.height);var Ze=this.virtualOption,Bt=Ze.postProcess,Hn=Ze.kSize,he=Ze.sigma,se=Ze.bSigma,Me=Ze.overlayType,ce=Ze.hardThreshold,Ae=Ze.sigmoidClip,st=this.virtualLocation,Tt=st.postProcessTypeLocation,vt=st.mSizeLocation,Kt=st.sigmaLocation,tt=st.bSigmaLocation,wt=st.overlayTypeLocation,zt=st.hardThresholdLocation,Cn=st.sigmoidClipLocation;j.uniform1i(Tt,Bt),j.uniform1i(vt,Hn),j.uniform1f(Kt,he),j.uniform1f(tt,se),j.uniform1i(wt,Me),j.uniform1f(zt,ce),j.uniform1i(Cn,Ae),j.uniform1i(Gt,0),j.uniform1i(qt,1),j.uniform1i(Ke,2),j.uniform1i(Ht,3),j.uniform1i(lt,4),j.uniform1i(Gn,5),j.uniform1i(or,6),j.uniform1i(Ut,7),j.uniform1i(En,8),j.activeTexture(j.TEXTURE0),j.bindTexture(j.TEXTURE_2D,Z[0]),j.activeTexture(j.TEXTURE1),j.bindTexture(j.TEXTURE_2D,Z[1]),j.activeTexture(j.TEXTURE2),j.bindTexture(j.TEXTURE_2D,Z[2]),j.activeTexture(j.TEXTURE3),j.bindTexture(j.TEXTURE_2D,Z[3]),j.activeTexture(j.TEXTURE4),j.bindTexture(j.TEXTURE_2D,Z[4]),j.activeTexture(j.TEXTURE5),j.bindTexture(j.TEXTURE_2D,Z[5]),j.activeTexture(j.TEXTURE6),j.bindTexture(j.TEXTURE_2D,Z[6]),j.activeTexture(j.TEXTURE7),j.bindTexture(j.TEXTURE_2D,Z[7]),j.activeTexture(j.TEXTURE8),j.bindTexture(j.TEXTURE_2D,Z[8]),j.drawArrays(j.TRIANGLES,0,6),this.maskBuffer[0]=this.maskBuffer[1],this.maskBuffer[1]=this.maskBuffer[2],this.maskBuffer[2]=q,this.frameBuffer[0]=this.frameBuffer[1],this.frameBuffer[1]=this.frameBuffer[2],this.frameBuffer[2]=re}}]),ae}(),Ro=typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:{};(function(){var ae;function Te(l){var v=0;return function(){return v<l.length?{done:!1,value:l[v++]}:{done:!0}}}var Se=typeof Object.defineProperties=="function"?Object.defineProperty:function(l,v,b){return l==Array.prototype||l==Object.prototype||(l[v]=b.value),l},Ve=function(l){l=[(typeof globalThis=="undefined"?"undefined":J(globalThis))=="object"&&globalThis,l,(typeof window=="undefined"?"undefined":J(window))=="object"&&window,(typeof self=="undefined"?"undefined":J(self))=="object"&&self,J(Ro)=="object"&&Ro];for(var v=0;v<l.length;++v){var b=l[v];if(b&&b.Math==Math)return b}throw Error("Cannot find global object")}(this);function Fe(l,v){if(v)e:{var b=Ve;l=l.split(".");for(var x=0;x<l.length-1;x++){var D=l[x];if(!(D in b))break e;b=b[D]}(v=v(x=b[l=l[l.length-1]]))!=x&&v!=null&&Se(b,l,{configurable:!0,writable:!0,value:v})}}function ne(l){return(l={next:l})[Symbol.iterator]=function(){return this},l}function q(l){var v=typeof Symbol!="undefined"&&Symbol.iterator&&l[Symbol.iterator];return v?v.call(l):{next:Te(l)}}function re(l){if(!(l instanceof Array)){l=q(l);for(var v,b=[];!(v=l.next()).done;)b.push(v.value);l=b}return l}Fe("Symbol",function(l){function v(D,C){this.h=D,Se(this,"description",{configurable:!0,writable:!0,value:C})}if(l)return l;v.prototype.toString=function(){return this.h};var b="jscomp_symbol_"+(1e9*Math.random()>>>0)+"_",x=0;return function D(C){if(this instanceof D)throw new TypeError("Symbol is not a constructor");return new v(b+(C||"")+"_"+x++,C)}}),Fe("Symbol.iterator",function(l){if(l)return l;l=Symbol("Symbol.iterator");for(var v="Array Int8Array Uint8Array Uint8ClampedArray Int16Array Uint16Array Int32Array Uint32Array Float32Array Float64Array".split(" "),b=0;b<v.length;b++){var x=Ve[v[b]];typeof x=="function"&&typeof x.prototype[l]!="function"&&Se(x.prototype,l,{configurable:!0,writable:!0,value:function(){return ne(Te(this))}})}return l});var j=typeof Object.assign=="function"?Object.assign:function(l,v){for(var b=1;b<arguments.length;b++){var x=arguments[b];if(x)for(var D in x)Object.prototype.hasOwnProperty.call(x,D)&&(l[D]=x[D])}return l};Fe("Object.assign",function(l){return l||j});var Z,ye=typeof Object.create=="function"?Object.create:function(l){function v(){}return v.prototype=l,new v};if(typeof Object.setPrototypeOf=="function")Z=Object.setPrototypeOf;else{var ie;e:{var _e={};try{_e.__proto__={a:!0},ie=_e.a;break e}catch(l){}ie=!1}Z=ie?function(l,v){if(l.__proto__=v,l.__proto__!==v)throw new TypeError(l+" is not extensible");return l}:null}var De=Z;function Gt(l,v){if(l.prototype=ye(v.prototype),l.prototype.constructor=l,De)De(l,v);else for(var b in v)if(b!="prototype")if(Object.defineProperties){var x=Object.getOwnPropertyDescriptor(v,b);x&&Object.defineProperty(l,b,x)}else l[b]=v[b];l.za=v.prototype}function qt(){this.m=!1,this.j=null,this.i=void 0,this.h=1,this.v=this.s=0,this.l=null}function Ke(l){if(l.m)throw new TypeError("Generator is already running");l.m=!0}function Ht(l,v){l.l={ma:v,na:!0},l.h=l.s||l.v}function lt(l,v,b){return l.h=b,{value:v}}function Gn(l){this.h=new qt,this.i=l}function or(l,v,b,x){try{var D=v.call(l.h.j,b);if(!(D instanceof Object))throw new TypeError("Iterator result "+D+" is not an object");if(!D.done)return l.h.m=!1,D;var C=D.value}catch(M){return l.h.j=null,Ht(l.h,M),Ut(l)}return l.h.j=null,x.call(l.h,C),Ut(l)}function Ut(l){for(;l.h.h;)try{var v=l.i(l.h);if(v)return l.h.m=!1,{value:v.value,done:!1}}catch(b){l.h.i=void 0,Ht(l.h,b)}if(l.h.m=!1,l.h.l){if(v=l.h.l,l.h.l=null,v.na)throw v.ma;return{value:v.return,done:!0}}return{value:void 0,done:!0}}function En(l){this.next=function(v){return Ke(l.h),l.h.j?v=or(l,l.h.j.next,v,l.h.u):(l.h.u(v),v=Ut(l)),v},this.throw=function(v){return Ke(l.h),l.h.j?v=or(l,l.h.j.throw,v,l.h.u):(Ht(l.h,v),v=Ut(l)),v},this.return=function(v){return function(b,x){Ke(b.h);var D=b.h.j;return D?or(b,"return"in D?D.return:function(C){return{value:C,done:!0}},x,b.h.return):(b.h.return(x),Ut(b))}(l,v)},this[Symbol.iterator]=function(){return this}}function Ze(l){return function(v){function b(D){return v.next(D)}function x(D){return v.throw(D)}return new Promise(function(D,C){(function M(F){F.done?D(F.value):Promise.resolve(F.value).then(b,x).then(M,C)})(v.next())})}(new En(new Gn(l)))}function Bt(l){return l||Array.prototype.fill}qt.prototype.u=function(l){this.i=l},qt.prototype.return=function(l){this.l={return:l},this.h=this.v},Fe("Promise",function(l){function v(M){this.i=0,this.j=void 0,this.h=[],this.u=!1;var F=this.l();try{M(F.resolve,F.reject)}catch(K){F.reject(K)}}function b(){this.h=null}function x(M){return M instanceof v?M:new v(function(F){F(M)})}if(l)return l;b.prototype.i=function(M){if(this.h==null){this.h=[];var F=this;this.j(function(){F.m()})}this.h.push(M)};var D=Ve.setTimeout;b.prototype.j=function(M){D(M,0)},b.prototype.m=function(){for(;this.h&&this.h.length;){var M=this.h;this.h=[];for(var F=0;F<M.length;++F){var K=M[F];M[F]=null;try{K()}catch(de){this.l(de)}}}this.h=null},b.prototype.l=function(M){this.j(function(){throw M})},v.prototype.l=function(){function M(de){return function(me){K||(K=!0,de.call(F,me))}}var F=this,K=!1;return{resolve:M(this.I),reject:M(this.m)}},v.prototype.I=function(M){if(M===this)this.m(new TypeError("A Promise cannot resolve to itself"));else if(M instanceof v)this.L(M);else{e:switch(J(M)){case"object":var F=M!=null;break e;case"function":F=!0;break e;default:F=!1}F?this.F(M):this.s(M)}},v.prototype.F=function(M){var F=void 0;try{F=M.then}catch(K){return void this.m(K)}typeof F=="function"?this.M(F,M):this.s(M)},v.prototype.m=function(M){this.v(2,M)},v.prototype.s=function(M){this.v(1,M)},v.prototype.v=function(M,F){if(this.i!=0)throw Error("Cannot settle("+M+", "+F+"): Promise already settled in state"+this.i);this.i=M,this.j=F,this.i===2&&this.K(),this.H()},v.prototype.K=function(){var M=this;D(function(){if(M.D()){var F=Ve.console;F!==void 0&&F.error(M.j)}},1)},v.prototype.D=function(){if(this.u)return!1;var M=Ve.CustomEvent,F=Ve.Event,K=Ve.dispatchEvent;return K===void 0||(typeof M=="function"?M=new M("unhandledrejection",{cancelable:!0}):typeof F=="function"?M=new F("unhandledrejection",{cancelable:!0}):(M=Ve.document.createEvent("CustomEvent")).initCustomEvent("unhandledrejection",!1,!0,M),M.promise=this,M.reason=this.j,K(M))},v.prototype.H=function(){if(this.h!=null){for(var M=0;M<this.h.length;++M)C.i(this.h[M]);this.h=null}};var C=new b;return v.prototype.L=function(M){var F=this.l();M.T(F.resolve,F.reject)},v.prototype.M=function(M,F){var K=this.l();try{M.call(F,K.resolve,K.reject)}catch(de){K.reject(de)}},v.prototype.then=function(M,F){function K(Re,pe){return typeof Re=="function"?function(Le){try{de(Re(Le))}catch(Be){me(Be)}}:pe}var de,me,we=new v(function(Re,pe){de=Re,me=pe});return this.T(K(M,de),K(F,me)),we},v.prototype.catch=function(M){return this.then(void 0,M)},v.prototype.T=function(M,F){function K(){switch(de.i){case 1:M(de.j);break;case 2:F(de.j);break;default:throw Error("Unexpected state: "+de.i)}}var de=this;this.h==null?C.i(K):this.h.push(K),this.u=!0},v.resolve=x,v.reject=function(M){return new v(function(F,K){K(M)})},v.race=function(M){return new v(function(F,K){for(var de=q(M),me=de.next();!me.done;me=de.next())x(me.value).T(F,K)})},v.all=function(M){var F=q(M),K=F.next();return K.done?x([]):new v(function(de,me){function we(Le){return function(Be){Re[Le]=Be,--pe==0&&de(Re)}}var Re=[],pe=0;do Re.push(void 0),pe++,x(K.value).T(we(Re.length-1),me),K=F.next();while(!K.done)})},v}),Fe("Array.prototype.keys",function(l){return l||function(){return function(v,b){v instanceof String&&(v+="");var x=0,D=!1,C={next:function(){if(!D&&x<v.length){var M=x++;return{value:b(M,v[M]),done:!1}}return D=!0,{done:!0,value:void 0}}};return C[Symbol.iterator]=function(){return C},C}(this,function(v){return v})}}),Fe("Array.prototype.fill",function(l){return l||function(v,b,x){var D=this.length||0;for(0>b&&(b=Math.max(0,D+b)),(x==null||x>D)&&(x=D),0>(x=Number(x))&&(x=Math.max(0,D+x)),b=Number(b||0);b<x;b++)this[b]=v;return this}}),Fe("Int8Array.prototype.fill",Bt),Fe("Uint8Array.prototype.fill",Bt),Fe("Uint8ClampedArray.prototype.fill",Bt),Fe("Int16Array.prototype.fill",Bt),Fe("Uint16Array.prototype.fill",Bt),Fe("Int32Array.prototype.fill",Bt),Fe("Uint32Array.prototype.fill",Bt),Fe("Float32Array.prototype.fill",Bt),Fe("Float64Array.prototype.fill",Bt),Fe("Object.is",function(l){return l||function(v,b){return v===b?v!==0||1/v==1/b:v!=v&&b!=b}}),Fe("Array.prototype.includes",function(l){return l||function(v,b){var x=this;x instanceof String&&(x=String(x));var D=x.length;for(0>(b=b||0)&&(b=Math.max(b+D,0));b<D;b++){var C=x[b];if(C===v||Object.is(C,v))return!0}return!1}}),Fe("String.prototype.includes",function(l){return l||function(v,b){if(this==null)throw new TypeError("The 'this' value for String.prototype.includes must not be null or undefined");if(v instanceof RegExp)throw new TypeError("First argument to String.prototype.includes must not be a regular expression");return this.indexOf(v,b||0)!==-1}});var Hn=this||self;function he(l,v){l=l.split(".");var b,x=Hn;for((l[0]in x)||x.execScript===void 0||x.execScript("var "+l[0]);l.length&&(b=l.shift());)l.length||v===void 0?x=x[b]&&x[b]!==Object.prototype[b]?x[b]:x[b]={}:x[b]=v}function se(l){var v;return(v=Hn.navigator)&&(v=v.userAgent)||(v=""),v.indexOf(l)!=-1}var Me=Array.prototype.map?function(l,v){return Array.prototype.map.call(l,v,void 0)}:function(l,v){for(var b=l.length,x=Array(b),D=typeof l=="string"?l.split(""):l,C=0;C<b;C++)C in D&&(x[C]=v.call(void 0,D[C],C,l));return x},ce={},Ae=null;function st(l){var v=l.length,b=3*v/4;b%3?b=Math.floor(b):"=.".indexOf(l[v-1])!=-1&&(b="=.".indexOf(l[v-2])!=-1?b-2:b-1);var x=new Uint8Array(b),D=0;return function(C,M){function F(pe){for(;K<C.length;){var Le=C.charAt(K++),Be=Ae[Le];if(Be!=null)return Be;if(!/^[\s\xa0]*$/.test(Le))throw Error("Unknown base64 encoding at char: "+Le)}return pe}Tt();for(var K=0;;){var de=F(-1),me=F(0),we=F(64),Re=F(64);if(Re===64&&de===-1)break;M(de<<2|me>>4),we!=64&&(M(me<<4&240|we>>2),Re!=64&&M(we<<6&192|Re))}}(l,function(C){x[D++]=C}),D!==b?x.subarray(0,D):x}function Tt(){if(!Ae){Ae={};for(var l="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789".split(""),v=["+/=","+/","-_=","-_.","-_"],b=0;5>b;b++){var x=l.concat(v[b].split(""));ce[b]=x;for(var D=0;D<x.length;D++){var C=x[D];Ae[C]===void 0&&(Ae[C]=D)}}}}var vt=typeof Uint8Array!="undefined",Kt=!(se("Trident")||se("MSIE"))&&typeof Hn.btoa=="function";function tt(l){if(!Kt){var v;v===void 0&&(v=0),Tt(),v=ce[v];for(var b=Array(Math.floor(l.length/3)),x=v[64]||"",D=0,C=0;D<l.length-2;D+=3){var M=l[D],F=l[D+1],K=l[D+2],de=v[M>>2];M=v[(3&M)<<4|F>>4],F=v[(15&F)<<2|K>>6],K=v[63&K],b[C++]=de+M+F+K}switch(de=0,K=x,l.length-D){case 2:K=v[(15&(de=l[D+1]))<<2]||x;case 1:l=l[D],b[C]=v[l>>2]+v[(3&l)<<4|de>>4]+K+x}return b.join("")}for(v="";10240<l.length;)v+=String.fromCharCode.apply(null,l.subarray(0,10240)),l=l.subarray(10240);return v+=String.fromCharCode.apply(null,l),btoa(v)}var wt,zt=RegExp("[-_.]","g");function Cn(l){switch(l){case"-":return"+";case"_":return"/";case".":return"=";default:return""}}function Si(l){if(!Kt)return st(l);zt.test(l)&&(l=l.replace(zt,Cn)),l=atob(l);for(var v=new Uint8Array(l.length),b=0;b<l.length;b++)v[b]=l.charCodeAt(b);return v}function Ct(){return wt||(wt=new Uint8Array(0))}var fn={},Cd=typeof Uint8Array.prototype.slice=="function",it=0,We=0;function Lc(l){var v=0>l,b=(l=Math.abs(l))>>>0;l=Math.floor((l-b)/4294967296),v&&(v=(b=q(Oc(b,l))).next().value,l=b.next().value,b=v),it=b>>>0,We=l>>>0}var yt,Ao=typeof BigInt=="function";function Oc(l,v){return v=~v,l?l=1+~l:v+=1,[l,v]}function Mc(l,v){this.i=l>>>0,this.h=v>>>0}function Rn(l){if(!l)return yt||(yt=new Mc(0,0));if(!/^-?\d+$/.test(l))return null;if(16>l.length)Lc(Number(l));else if(Ao)l=BigInt(l),it=Number(l&BigInt(4294967295))>>>0,We=Number(l>>BigInt(32)&BigInt(4294967295));else{var v=+(l[0]==="-");We=it=0;for(var b=l.length,x=v,D=(b-v)%6+v;D<=b;x=D,D+=6)x=Number(l.slice(x,D)),We*=1e6,4294967296<=(it=1e6*it+x)&&(We+=it/4294967296|0,it%=4294967296);v&&(l=(v=q(Oc(it,We))).next().value,v=v.next().value,it=l,We=v)}return new Mc(it,We)}function zn(l,v){return Error("Invalid wire type: "+l+" (at position "+v+")")}function mn(){return Error("Failed to read varint, encoding is invalid.")}function Po(l,v){return Error("Tried to read past the end of the data "+v+" > "+l)}function Wn(){throw Error("Invalid UTF8")}function Do(l,v){return v=String.fromCharCode.apply(null,v),l==null?v:l+v}var ca,Lo,Oo,Jn=void 0,Nc=typeof TextDecoder!="undefined",Rd=typeof TextEncoder!="undefined";function Mo(l){if(l!==fn)throw Error("illegal external caller")}function qr(l,v){if(Mo(v),this.V=l,l!=null&&l.length===0)throw Error("ByteString should be constructed with non-empty values")}function No(){return Oo||(Oo=new qr(null,fn))}function Vc(l){Mo(fn);var v=l.V;return(v=v==null||vt&&v!=null&&v instanceof Uint8Array?v:typeof v=="string"?Si(v):null)==null?v:l.V=v}function Uc(l,v){this.i=null,this.m=!1,this.h=this.j=this.l=0,Vo(this,l,v)}function Vo(l,v,b){b=b===void 0?{}:b,l.S=b.S!==void 0&&b.S,v&&(v=function(x){if(typeof x=="string")return{buffer:Si(x),C:!1};if(Array.isArray(x))return{buffer:new Uint8Array(x),C:!1};if(x.constructor===Uint8Array)return{buffer:x,C:!1};if(x.constructor===ArrayBuffer)return{buffer:new Uint8Array(x),C:!1};if(x.constructor===qr)return{buffer:Vc(x)||Ct(),C:!0};if(x instanceof Uint8Array)return{buffer:new Uint8Array(x.buffer,x.byteOffset,x.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")}(v),l.i=v.buffer,l.m=v.C,l.l=0,l.j=l.i.length,l.h=l.l)}function An(l,v){if(l.h=v,v>l.j)throw Po(l.j,v)}function ki(l){var v=l.i,b=l.h,x=v[b++],D=127&x;if(128&x&&(D|=(127&(x=v[b++]))<<7,128&x&&(D|=(127&(x=v[b++]))<<14,128&x&&(D|=(127&(x=v[b++]))<<21,128&x&&(D|=(x=v[b++])<<28,128&x&&128&v[b++]&&128&v[b++]&&128&v[b++]&&128&v[b++]&&128&v[b++])))))throw mn();return An(l,b),D}function Er(l,v){if(0>v)throw Error("Tried to read a negative byte length: "+v);var b=l.h,x=b+v;if(x>l.j)throw Po(v,l.j-b);return l.h=x,b}Uc.prototype.reset=function(){this.h=this.l};var Bc=[];function Uo(){this.h=[]}function jc(l,v,b){for(;0<b||127<v;)l.h.push(127&v|128),v=(v>>>7|b<<25)>>>0,b>>>=7;l.h.push(v)}function Nt(l,v){for(;127<v;)l.h.push(127&v|128),v>>>=7;l.h.push(v)}function Bo(l,v){if(Bc.length){var b=Bc.pop();Vo(b,l,v),l=b}else l=new Uc(l,v);this.h=l,this.j=this.h.h,this.i=this.l=-1,this.setOptions(v)}function sr(l){var v=l.h;if(v.h==v.j)return!1;l.j=l.h.h;var b=ki(l.h)>>>0;if(v=b>>>3,!(0<=(b&=7)&&5>=b))throw zn(b,l.j);if(1>v)throw Error("Invalid field number: "+v+" (at position "+l.j+")");return l.l=v,l.i=b,!0}function Kr(l){switch(l.i){case 0:if(l.i!=0)Kr(l);else e:{for(var v=(l=l.h).h,b=v+10,x=l.i;v<b;)if((128&x[v++])==0){An(l,v);break e}throw mn()}break;case 1:An(l=l.h,l.h+8);break;case 2:l.i!=2?Kr(l):(v=ki(l.h)>>>0,An(l=l.h,l.h+v));break;case 5:An(l=l.h,l.h+4);break;case 3:for(v=l.l;;){if(!sr(l))throw Error("Unmatched start-group tag: stream EOF");if(l.i==4){if(l.l!=v)throw Error("Unmatched end-group tag");break}Kr(l)}break;default:throw zn(l.i,l.j)}}Uo.prototype.length=function(){return this.h.length},Uo.prototype.end=function(){var l=this.h;return this.h=[],l},Bo.prototype.setOptions=function(l){l=l===void 0?{}:l,this.ca=l.ca!==void 0&&l.ca},Bo.prototype.reset=function(){this.h.reset(),this.j=this.h.h,this.i=this.l=-1};var Qr=[];function jo(){this.j=[],this.i=0,this.h=new Uo}function Xr(l,v){v.length!==0&&(l.j.push(v),l.i+=v.length)}var cn=typeof Symbol=="function"&&J(Symbol())==="symbol"?Symbol():void 0;function cr(l,v){return cn?l[cn]|=v:l.A!==void 0?l.A|=v:(Object.defineProperties(l,{A:{value:v,configurable:!0,writable:!0,enumerable:!1}}),v)}function Fc(l,v){cn?l[cn]&&(l[cn]&=~v):l.A!==void 0&&(l.A&=~v)}function bt(l){var v;return(v=cn?l[cn]:l.A)==null?0:v}function Pn(l,v){cn?l[cn]=v:l.A!==void 0?l.A=v:Object.defineProperties(l,{A:{value:v,configurable:!0,writable:!0,enumerable:!1}})}function ua(l){return cr(l,1),l}function Fo(l,v){Pn(v,-51&(0|l))}function Ti(l,v){Pn(v,-41&(18|l))}var Go={};function la(l){return l!==null&&J(l)==="object"&&!Array.isArray(l)&&l.constructor===Object}var Rt,da,Gc=[];function kt(l){if(2&bt(l.o))throw Error("Cannot mutate an immutable Message")}function Ho(l){var v=l.length;(v=v?l[v-1]:void 0)&&la(v)?v.g=1:(v={},l.push((v.g=1,v)))}function Hc(l){var v=l.i+l.G;return l.B||(l.B=l.o[v]={})}function vn(l,v){return v===-1?null:v>=l.i?l.B?l.B[v]:void 0:l.o[v+l.G]}function Dn(l,v,b,x){kt(l),ur(l,v,b,x)}function ur(l,v,b,x){l.j&&(l.j=void 0),v>=l.i||x?Hc(l)[v]=b:(l.o[v+l.G]=b,(l=l.B)&&v in l&&delete l[v])}function zo(l,v,b,x){var D=vn(l,v);Array.isArray(D)||(D=Rt);var C=bt(D);if(1&C||ua(D),x)2&C||cr(D,2),1&b||Object.freeze(D);else{x=!(2&b);var M=2&C;1&b||!M?x&&16&C&&!M&&Fc(D,16):ur(l,v,D=ua(Array.prototype.slice.call(D)))}return D}function Wo(l,v){var b=vn(l,v),x=b==null?b:typeof b=="number"||b==="NaN"||b==="Infinity"||b==="-Infinity"?Number(b):void 0;return x!=null&&x!==b&&ur(l,v,x),x}function Jo(l,v,b,x,D){l.h||(l.h={});var C=l.h[b],M=zo(l,b,3,D);if(!C){var F=M;C=[];var K=!!(16&bt(l.o));M=!!(2&bt(F));var de=F;!D&&M&&(F=Array.prototype.slice.call(F));for(var me=M,we=0;we<F.length;we++){var Re=F[we],pe=v,Le=!1;if(Le=Le!==void 0&&Le,(Re=Array.isArray(Re)?new pe(Re):Le?new pe:void 0)!==void 0){var Be=Le=bt(pe=Re.o);M&&(Be|=2),K&&(Be|=16),Be!=Le&&Pn(pe,Be),pe=Be,me=me||!!(2&pe),C.push(Re)}}return l.h[b]=C,v=33|(K=bt(F)),K!=(v=me?-9&v:8|v)&&(me=F,Object.isFrozen(me)&&(me=Array.prototype.slice.call(me)),Pn(me,v),F=me),de!==F&&ur(l,b,F),(D||x&&M)&&cr(C,2),x&&Object.freeze(C),C}return D||(D=Object.isFrozen(C),x&&!D?Object.freeze(C):!x&&D&&(C=Array.prototype.slice.call(C),l.h[b]=C)),C}function qo(l,v,b){var x=!!(2&bt(l.o));if(v=Jo(l,v,b,x,x),l=zo(l,b,3,x),!(x||8&bt(l))){for(x=0;x<v.length;x++){if(2&bt((b=v[x]).o)){var D=Wc(b,!1);D.j=b}else D=b;b!==D&&(v[x]=D,l[x]=D.o)}cr(l,8)}return v}function gn(l,v,b){if(b!=null&&typeof b!="number")throw Error("Value of float/double field must be a number|null|undefined, found "+J(b)+": "+b);Dn(l,v,b)}function Ko(l,v,b,x,D){kt(l);var C=Jo(l,b,v,!1,!1);return b=x!=null?x:new b,l=zo(l,v,2,!1),D!=null?(C.splice(D,0,b),l.splice(D,0,b.o)):(C.push(b),l.push(b.o)),b.C()&&Fc(l,8),b}function lr(l,v){return l==null?v:l}function jt(l,v,b){return b=b===void 0?0:b,lr(Wo(l,v),b)}function Qo(l,v,b,x){if(l!=null){if(Array.isArray(l))l=Xo(l,v,b,x!==void 0);else if(la(l)){var D,C={};for(D in l)C[D]=Qo(l[D],v,b,x);l=C}else l=v(l,x);return l}}function Xo(l,v,b,x){var D=bt(l);x=x?!!(16&D):void 0,l=Array.prototype.slice.call(l);for(var C=0;C<l.length;C++)l[C]=Qo(l[C],v,b,x);return b(D,l),l}function ct(l){return l.ja===Go?l.toJSON():function(v){switch(J(v)){case"number":return isFinite(v)?v:String(v);case"object":if(v)if(Array.isArray(v)){if((128&bt(v))!=0)return Ho(v=Array.prototype.slice.call(v)),v}else{if(vt&&v!=null&&v instanceof Uint8Array)return tt(v);if(v instanceof qr){var b=v.V;return b==null?"":typeof b=="string"?b:v.V=tt(b)}}}return v}(l)}function Ad(l,v){128&l&&Ho(v)}function Yo(l,v,b){if(b=b===void 0?Ti:b,l!=null){if(vt&&l instanceof Uint8Array)return l.length?new qr(new Uint8Array(l),fn):No();if(Array.isArray(l)){var x=bt(l);return 2&x?l:!v||32&x||!(16&x||x===0)?(4&(v=bt(l=Xo(l,Yo,4&x?Ti:b,!0)))&&2&v&&Object.freeze(l),l):(Pn(l,2|x),l)}return l.ja===Go?zc(l):l}}function $o(l,v,b,x,D,C,M){if(l=l.h&&l.h[b]){if(2&(x=bt(l))?x=l:(Ti(x,C=Me(l,zc)),Object.freeze(C),x=C),kt(v),M=x==null?Rt:ua([]),x!=null){for(C=!!x.length,l=0;l<x.length;l++){var F=x[l];C=C&&!(2&bt(F.o)),M[l]=F.o}C=1|(C?8:0),((l=bt(M))&C)!==C&&(Object.isFrozen(M)&&(M=Array.prototype.slice.call(M)),Pn(M,l|C)),v.h||(v.h={}),v.h[b]=x}else v.h&&(v.h[b]=void 0);ur(v,b,M,D)}else Dn(v,b,Yo(x,C,M),D)}function zc(l){return 2&bt(l.o)||cr((l=Wc(l,!0)).o,2),l}function Wc(l,v){var b=l.o,x=[];cr(x,16);var D=l.constructor.h;if(D&&x.push(D),D=l.B){x.length=b.length,x.fill(void 0,x.length,b.length);var C={};x[x.length-1]=C}(128&bt(b))!=0&&Ho(x),v=v||l.C()?Ti:Fo,C=l.constructor,da=x,x=new C(x),da=void 0,l.R&&(x.R=l.R.slice()),C=!!(16&bt(b));for(var M=D?b.length-1:b.length,F=0;F<M;F++)$o(l,x,F-l.G,b[F],!1,C,v);if(D)for(var K in D)$o(l,x,+K,D[K],!0,C,v);return x}function Qt(l,v,b){l==null&&(l=da),da=void 0;var x,D=this.constructor.i||0,C=0<D,M=this.constructor.h,F=!1;if(l==null){var K=48,de=!0;C&&(D=0,K|=128),Pn(l=M?[M]:[],K)}else{if(!Array.isArray(l)||M&&M!==l[0])throw Error();var me=K=cr(l,0);if((de=(16&me)!=0)&&((F=(32&me)!=0)||(me|=32)),C){if(128&me)D=0;else if(0<l.length){var we=l[l.length-1];if(la(we)&&"g"in we){D=0,me|=128,delete we.g;var Re,pe=!0;for(Re in we){pe=!1;break}pe&&l.pop()}}}else if(128&me)throw Error();K!==me&&Pn(l,me)}if(this.G=(M?0:-1)-D,this.h=void 0,this.o=l,D=(M=this.o.length)-1,M&&la(M=this.o[D])?(this.B=M,this.i=D-this.G):v!==void 0&&-1<v?(this.i=Math.max(v,D+1-this.G),this.B=void 0):this.i=Number.MAX_VALUE,!C&&this.B&&"g"in this.B)throw Error('Unexpected "g" flag in sparse object of message that is not a group type.');if(b)for(v=de&&!F&&!0,C=this.i,de=0;de<b.length;de++)(F=b[de])<C?(D=l[F+=this.G])?Jc(D,v):l[F]=Rt:(x||(x=Hc(this)),(D=x[F])?Jc(D,v):x[F]=Rt)}function Jc(l,v){if(Array.isArray(l)){var b=bt(l),x=1;!v||2&b||(x|=16),(b&x)!==x&&Pn(l,b|x)}}function ha(l,v,b){if(b){var x,D={};for(x in b){var C=b[x],M=C.ra;M||(D.J=C.xa||C.oa.W,C.ia?(D.aa=Xc(C.ia),M=function(F){return function(K,de,me){return F.J(K,de,me,F.aa)}}(D)):C.ka?(D.Z=Zo(C.da.P,C.ka),M=function(F){return function(K,de,me){return F.J(K,de,me,F.Z)}}(D)):M=D.J,C.ra=M),M(v,l,C.da),D={J:D.J,aa:D.aa,Z:D.Z}}}(function(F,K){if(K=K.R){Xr(F,F.h.end());for(var de=0;de<K.length;de++)Xr(F,Vc(K[de])||Ct())}})(v,l)}Pn(Gc,23),Rt=Object.freeze(Gc),Qt.prototype.toJSON=function(){return Xo(this.o,ct,Ad)},Qt.prototype.C=function(){return!!(2&bt(this.o))},Qt.prototype.ja=Go,Qt.prototype.toString=function(){return this.o.toString()};var pa=Symbol();function qc(l,v,b){return l[pa]||(l[pa]=function(x,D){return v(x,D,b)})}function xi(l){var v=l[pa];if(!v){var b=ts(l);v=function(x,D){return Zc(x,D,b)},l[pa]=v}return v}function Kc(l){var v=function(D){var C=D.ia;return C?xi(C):(C=D.wa)?qc(D.da.P,C,D.ka):void 0}(l),b=l.da,x=l.oa.U;return v?function(D,C){return x(D,C,b,v)}:function(D,C){return x(D,C,b)}}function fa(l,v){var b=l[v];return typeof b=="function"&&b.length===0&&(b=b(),l[v]=b),Array.isArray(b)&&(wi in b||Ii in b||0<b.length&&typeof b[0]=="function")?b:void 0}function Qc(l,v,b,x,D,C){v.P=l[0];var M=1;if(l.length>M&&typeof l[M]!="number"){var F=l[M++];b(v,F)}for(;M<l.length;){b=l[M++];for(var K=M+1;K<l.length&&typeof l[K]!="number";)K++;switch(F=l[M++],K-=M){case 0:x(v,b,F);break;case 1:(K=fa(l,M))?(M++,D(v,b,F,K)):x(v,b,F,l[M++]);break;case 2:D(v,b,F,K=fa(l,K=M++),l[M++]);break;case 3:C(v,b,F,l[M++],l[M++],l[M++]);break;case 4:C(v,b,F,l[M++],l[M++],l[M++],l[M++]);break;default:throw Error("unexpected number of binary field arguments: "+K)}}return v}var Cr=Symbol();function Xc(l){var v=l[Cr];if(!v){var b=es(l);v=function(x,D){return eu(x,D,b)},l[Cr]=v}return v}function Zo(l,v){var b=l[Cr];return b||(b=function(x,D){return ha(x,D,v)},l[Cr]=b),b}var Ii=Symbol();function Pd(l,v){l.push(v)}function Dd(l,v,b){l.push(v,b.W)}function Ld(l,v,b,x){var D=Xc(x),C=es(x).P,M=b.W;l.push(v,function(F,K,de){return M(F,K,de,C,D)})}function Od(l,v,b,x,D,C){var M=Zo(x,C),F=b.W;l.push(v,function(K,de,me){return F(K,de,me,x,M)})}function es(l){var v=l[Ii];return v||(v=Qc(l,l[Ii]=[],Pd,Dd,Ld,Od),wi in l&&Ii in l&&(l.length=0),v)}var wi=Symbol();function Md(l,v){l[0]=v}function Yc(l,v,b,x){var D=b.U;l[v]=x?function(C,M,F){return D(C,M,F,x)}:D}function At(l,v,b,x,D){var C=b.U,M=xi(x),F=ts(x).P;l[v]=function(K,de,me){return C(K,de,me,F,M,D)}}function $c(l,v,b,x,D,C,M){var F=b.U,K=qc(x,D,C);l[v]=function(de,me,we){return F(de,me,we,x,K,M)}}function ts(l){var v=l[wi];return v||(v=Qc(l,l[wi]={},Md,Yc,At,$c),wi in l&&Ii in l&&(l.length=0),v)}function Zc(l,v,b){for(;sr(v)&&v.i!=4;){var x=v.l,D=b[x];if(!D){var C=b[0];C&&(C=C[x])&&(D=b[x]=Kc(C))}if(!D||!D(v,l,x)){x=l,C=(D=v).j,Kr(D);var M=D;if(!M.ca){if(D=M.h.h-C,M.h.h=C,M=M.h,D==0)D=No();else{if(C=Er(M,D),M.S&&M.m)D=M.i.subarray(C,C+D);else{M=M.i;var F=C;D=F===(D=C+D)?Ct():Cd?M.slice(F,D):new Uint8Array(M.subarray(F,D))}D=D.length==0?No():new qr(D,fn)}(C=x.R)?C.push(D):x.R=[D]}}}return l}function eu(l,v,b){for(var x=b.length,D=x%2==1,C=D?1:0;C<x;C+=2)(0,b[C+1])(v,l,b[C]);ha(l,v,D?b[0]:void 0)}function dt(l,v){return{U:l,W:v}}var _n=dt(function(l,v,b){if(l.i!==5)return!1;var x=(l=l.h).i,D=l.h,C=x[D],M=x[D+1],F=x[D+2];return x=x[D+3],An(l,l.h+4),l=2*((M=(C<<0|M<<8|F<<16|x<<24)>>>0)>>31)+1,C=M>>>23&255,M&=8388607,Dn(v,b,C==255?M?NaN:1/0*l:C==0?l*Math.pow(2,-149)*M:l*Math.pow(2,C-150)*(M+Math.pow(2,23))),!0},function(l,v,b){if((v=Wo(v,b))!=null){Nt(l.h,8*b+5),l=l.h;var x=+v;x===0?0<1/x?it=We=0:(We=0,it=2147483648):isNaN(x)?(We=0,it=2147483647):34028234663852886e22<(x=(b=0>x?-2147483648:0)?-x:x)?(We=0,it=(2139095040|b)>>>0):11754943508222875e-54>x?(x=Math.round(x/Math.pow(2,-149)),We=0,it=(b|x)>>>0):(v=Math.floor(Math.log(x)/Math.LN2),x*=Math.pow(2,-v),16777216<=(x=Math.round(8388608*x))&&++v,We=0,it=(b|v+127<<23|8388607&x)>>>0),b=it,l.h.push(b>>>0&255),l.h.push(b>>>8&255),l.h.push(b>>>16&255),l.h.push(b>>>24&255)}}),Nd=dt(function(l,v,b){if(l.i!==0)return!1;var x=l.h,D=0,C=l=0,M=x.i,F=x.h;do{var K=M[F++];D|=(127&K)<<C,C+=7}while(32>C&&128&K);for(32<C&&(l|=(127&K)>>4),C=3;32>C&&128&K;C+=7)l|=(127&(K=M[F++]))<<C;if(An(x,F),!(128>K))throw mn();return x=D>>>0,(l=2147483648&(K=l>>>0))&&(K=~K>>>0,(x=1+~x>>>0)==0&&(K=K+1>>>0)),x=4294967296*K+(x>>>0),Dn(v,b,l?-x:x),!0},function(l,v,b){(v=vn(v,b))!=null&&(typeof v=="string"&&Rn(v),v!=null&&(Nt(l.h,8*b),typeof v=="number"?(l=l.h,Lc(v),jc(l,it,We)):(b=Rn(v),jc(l.h,b.i,b.h))))}),Vd=dt(function(l,v,b){return l.i===0&&(Dn(v,b,ki(l.h)),!0)},function(l,v,b){if((v=vn(v,b))!=null&&v!=null)if(Nt(l.h,8*b),l=l.h,0<=(b=v))Nt(l,b);else{for(v=0;9>v;v++)l.h.push(127&b|128),b>>=7;l.h.push(1)}}),Ei=dt(function(l,v,b){if(l.i!==2)return!1;var x=ki(l.h)>>>0,D=Er(l=l.h,x);if(l=l.i,Nc){var C,M=l;(C=ca)||(C=ca=new TextDecoder("utf-8",{fatal:!0})),l=D+x,M=D===0&&l===M.length?M:M.subarray(D,l);try{var F=C.decode(M)}catch(we){if(Jn===void 0){try{C.decode(new Uint8Array([128]))}catch(Re){}try{C.decode(new Uint8Array([97])),Jn=!0}catch(Re){Jn=!1}}throw!Jn&&(ca=void 0),we}}else{x=(F=D)+x,D=[];for(var K,de,me=null;F<x;)128>(K=l[F++])?D.push(K):224>K?F>=x?Wn():(de=l[F++],194>K||(192&de)!=128?(F--,Wn()):D.push((31&K)<<6|63&de)):240>K?F>=x-1?Wn():(192&(de=l[F++]))!=128||K===224&&160>de||K===237&&160<=de||(192&(M=l[F++]))!=128?(F--,Wn()):D.push((15&K)<<12|(63&de)<<6|63&M):244>=K?F>=x-2?Wn():(192&(de=l[F++]))!=128||de-144+(K<<28)>>30!=0||(192&(M=l[F++]))!=128||(192&(C=l[F++]))!=128?(F--,Wn()):(K=(7&K)<<18|(63&de)<<12|(63&M)<<6|63&C,K-=65536,D.push(55296+(K>>10&1023),56320+(1023&K))):Wn(),8192<=D.length&&(me=Do(me,D),D.length=0);F=Do(me,D)}return Dn(v,b,F),!0},function(l,v,b){if((v=vn(v,b))!=null){var x=!1;if(x=x!==void 0&&x,Rd){if(x&&/(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])/.test(v))throw Error("Found an unpaired surrogate");v=(Lo||(Lo=new TextEncoder)).encode(v)}else{for(var D=0,C=new Uint8Array(3*v.length),M=0;M<v.length;M++){var F=v.charCodeAt(M);if(128>F)C[D++]=F;else{if(2048>F)C[D++]=F>>6|192;else{if(55296<=F&&57343>=F){if(56319>=F&&M<v.length){var K=v.charCodeAt(++M);if(56320<=K&&57343>=K){F=1024*(F-55296)+K-56320+65536,C[D++]=F>>18|240,C[D++]=F>>12&63|128,C[D++]=F>>6&63|128,C[D++]=63&F|128;continue}M--}if(x)throw Error("Found an unpaired surrogate");F=65533}C[D++]=F>>12|224,C[D++]=F>>6&63|128}C[D++]=63&F|128}}v=D===C.length?C:C.subarray(0,D)}Nt(l.h,8*b+2),Nt(l.h,v.length),Xr(l,l.h.end()),Xr(l,v)}}),ns=dt(function(l,v,b,x,D){if(l.i!==2)return!1;v=Ko(v,b,x),b=l.h.j,x=ki(l.h)>>>0;var C=l.h.h+x,M=C-b;if(0>=M&&(l.h.j=C,D(v,l,void 0,void 0,void 0),M=C-l.h.h),M)throw Error("Message parsing ended unexpectedly. Expected to read "+x+" bytes, instead read "+(x-M)+" bytes, either the data ended unexpectedly or the message misreported its own length");return l.h.h=C,l.h.j=b,!0},function(l,v,b,x,D){if((v=qo(v,x,b))!=null)for(x=0;x<v.length;x++){var C=l;Nt(C.h,8*b+2);var M=C.h.end();Xr(C,M),M.push(C.i),C=M,D(v[x],l),M=l;var F=C.pop();for(F=M.i+M.h.length()-F;127<F;)C.push(127&F|128),F>>>=7,M.i++;C.push(F),M.i++}});function rs(l){return function(v,b){e:{if(Qr.length){var x=Qr.pop();x.setOptions(b),Vo(x.h,v,b),v=x}else v=new Bo(v,b);try{var D=ts(l),C=Zc(new D.P,v,D);break e}finally{(D=v.h).i=null,D.m=!1,D.l=0,D.j=0,D.h=0,D.S=!1,v.l=-1,v.i=-1,100>Qr.length&&Qr.push(v)}C=void 0}return C}}function Ci(l){return function(){var v=new jo;eu(this,v,es(l)),Xr(v,v.h.end());for(var b=new Uint8Array(v.i),x=v.j,D=x.length,C=0,M=0;M<D;M++){var F=x[M];b.set(F,C),C+=F.length}return v.j=[b],b}}function Yr(l){Qt.call(this,l)}Gt(Yr,Qt);var tu=[Yr,1,Vd,2,_n,3,Ei,4,Ei];function is(l){Qt.call(this,l,-1,Ud)}Yr.prototype.l=Ci(tu),Gt(is,Qt),is.prototype.addClassification=function(l,v){return Ko(this,1,Yr,l,v),this};var Ud=[1],Bd=rs([is,1,ns,tu]);function Ri(l){Qt.call(this,l)}Gt(Ri,Qt);var yn=[Ri,1,_n,2,_n,3,_n,4,_n,5,_n];function ma(l){Qt.call(this,l,-1,as)}Ri.prototype.l=Ci(yn),Gt(ma,Qt);var as=[1],jd=rs([ma,1,ns,yn]);function Ai(l){Qt.call(this,l)}Gt(Ai,Qt);var nu=[Ai,1,_n,2,_n,3,_n,4,_n,5,_n,6,Nd],os=rs(nu);function dr(l,v,b){if(b=l.createShader(b===0?l.VERTEX_SHADER:l.FRAGMENT_SHADER),l.shaderSource(b,v),l.compileShader(b),!l.getShaderParameter(b,l.COMPILE_STATUS))throw Error(`Could not compile WebGL shader.
568
+
569
+ `+l.getShaderInfoLog(b));return b}function Fd(l){return qo(l,Yr,1).map(function(v){var b=vn(v,1);return{index:b==null?0:b,qa:jt(v,2),label:vn(v,3)!=null?lr(vn(v,3),""):void 0,displayName:vn(v,4)!=null?lr(vn(v,4),""):void 0}})}function ss(l){return{x:jt(l,1),y:jt(l,2),z:jt(l,3),visibility:Wo(l,4)!=null?jt(l,4):void 0}}function cs(l,v){this.i=l,this.h=v,this.m=0}function Pi(l,v,b){return function(x,D){var C=x.h;if(x.s===void 0){var M=dr(C,`
570
+ attribute vec2 aVertex;
571
+ attribute vec2 aTex;
572
+ varying vec2 vTex;
573
+ void main(void) {
574
+ gl_Position = vec4(aVertex, 0.0, 1.0);
575
+ vTex = aTex;
576
+ }`,0),F=dr(C,`
577
+ precision mediump float;
578
+ varying vec2 vTex;
579
+ uniform sampler2D sampler0;
580
+ void main(){
581
+ gl_FragColor = texture2D(sampler0, vTex);
582
+ }`,1),K=C.createProgram();if(C.attachShader(K,M),C.attachShader(K,F),C.linkProgram(K),!C.getProgramParameter(K,C.LINK_STATUS))throw Error(`Could not compile WebGL program.
583
+
584
+ `+C.getProgramInfoLog(K));M=x.s=K,C.useProgram(M),F=C.getUniformLocation(M,"sampler0"),x.l={O:C.getAttribLocation(M,"aVertex"),N:C.getAttribLocation(M,"aTex"),ya:F},x.v=C.createBuffer(),C.bindBuffer(C.ARRAY_BUFFER,x.v),C.enableVertexAttribArray(x.l.O),C.vertexAttribPointer(x.l.O,2,C.FLOAT,!1,0,0),C.bufferData(C.ARRAY_BUFFER,new Float32Array([-1,-1,-1,1,1,1,1,-1]),C.STATIC_DRAW),C.bindBuffer(C.ARRAY_BUFFER,null),x.u=C.createBuffer(),C.bindBuffer(C.ARRAY_BUFFER,x.u),C.enableVertexAttribArray(x.l.N),C.vertexAttribPointer(x.l.N,2,C.FLOAT,!1,0,0),C.bufferData(C.ARRAY_BUFFER,new Float32Array([0,1,0,0,1,0,1,1]),C.STATIC_DRAW),C.bindBuffer(C.ARRAY_BUFFER,null),C.uniform1i(F,0)}M=x.l,C.useProgram(x.s),C.canvas.width=D.width,C.canvas.height=D.height,C.viewport(0,0,D.width,D.height),C.activeTexture(C.TEXTURE0),x.i.bindTexture2d(D.glName),C.enableVertexAttribArray(M.O),C.bindBuffer(C.ARRAY_BUFFER,x.v),C.vertexAttribPointer(M.O,2,C.FLOAT,!1,0,0),C.enableVertexAttribArray(M.N),C.bindBuffer(C.ARRAY_BUFFER,x.u),C.vertexAttribPointer(M.N,2,C.FLOAT,!1,0,0),C.bindFramebuffer(C.DRAW_FRAMEBUFFER?C.DRAW_FRAMEBUFFER:C.FRAMEBUFFER,null),C.clearColor(0,0,0,0),C.clear(C.COLOR_BUFFER_BIT),C.colorMask(!0,!0,!0,!0),C.drawArrays(C.TRIANGLE_FAN,0,4),C.disableVertexAttribArray(M.O),C.disableVertexAttribArray(M.N),C.bindBuffer(C.ARRAY_BUFFER,null),x.i.bindTexture2d(0)}(l,v),typeof l.h.canvas.transferToImageBitmap=="function"?Promise.resolve(l.h.canvas.transferToImageBitmap()):b?Promise.resolve(l.h.canvas):typeof createImageBitmap=="function"?createImageBitmap(l.h.canvas):(l.j===void 0&&(l.j=document.createElement("canvas")),new Promise(function(x){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),x(l.j)}))}function Di(l){this.h=l}Ai.prototype.l=Ci(nu);var va=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 ga(l,v){return v+l}function ru(l,v){window[l]=v}function us(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||ga,(typeof window=="undefined"?"undefined":J(window))==="object")var v=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");v=location.pathname.toString().substring(0,location.pathname.toString().lastIndexOf("/"))+"/"}if(this.ha=v,l.options)for(var b=(v=q(Object.keys(l.options))).next();!b.done;b=v.next()){b=b.value;var x=l.options[b].default;x!==void 0&&(this.l[b]=typeof x=="function"?x():x)}}function iu(l){var v,b,x,D,C,M,F,K,de,me,we;return Ze(function(Re){switch(Re.h){case 1:return l.ga?(v=l.h.files===void 0?[]:typeof l.h.files=="function"?l.h.files(l.l):l.h.files,lt(Re,Ze(function(pe){switch(pe.h){case 1:return pe.s=2,lt(pe,WebAssembly.instantiate(va),4);case 4:pe.h=3,pe.s=0;break;case 2:return pe.s=0,pe.l=null,pe.return(!1);case 3:return pe.return(!0)}}),2)):Re.return();case 2:if(b=Re.i,(typeof window=="undefined"?"undefined":J(window))==="object")return ru("createMediapipeSolutionsWasm",{locateFile:l.locateFile}),ru("createMediapipeSolutionsPackedAssets",{locateFile:l.locateFile}),M=v.filter(function(pe){return pe.data!==void 0}),F=v.filter(function(pe){return pe.data===void 0}),K=Promise.all(M.map(function(pe){var Le=Li(l,pe.url);if(pe.path!==void 0){var Be=pe.path;Le=Le.then(function(at){return l.overrideFile(Be,at),Promise.resolve(at)})}return Le})),de=Promise.all(F.map(function(pe){return pe.simd===void 0||pe.simd&&b||!pe.simd&&!b?function(Le){var Be=document.createElement("script");return Be.setAttribute("src",Le),Be.setAttribute("crossorigin","anonymous"),new Promise(function(at){Be.addEventListener("load",function(){at()},!1),Be.addEventListener("error",function(){at()},!1),document.body.appendChild(Be)})}(l.locateFile(pe.url,l.ha)):Promise.resolve()})).then(function(){var pe,Le,Be;return Ze(function(at){if(at.h==1)return pe=window.createMediapipeSolutionsWasm,Le=window.createMediapipeSolutionsPackedAssets,Be=l,lt(at,pe(Le),2);Be.i=at.i,at.h=0})}),me=Ze(function(pe){return l.h.graph&&l.h.graph.url?pe=lt(pe,Li(l,l.h.graph.url),0):(pe.h=0,pe=void 0),pe}),lt(Re,Promise.all([de,K,me]),7);if(typeof importScripts!="function")throw Error("solutions can only be loaded on a web page or in a web worker");return x=v.filter(function(pe){return pe.simd===void 0||pe.simd&&b||!pe.simd&&!b}).map(function(pe){return l.locateFile(pe.url,l.ha)}),importScripts.apply(null,re(x)),D=l,lt(Re,createMediapipeSolutionsWasm(Module),6);case 6:D.i=Re.i,l.m=new OffscreenCanvas(1,1),l.i.canvas=l.m,C=l.i.GL.createContext(l.m,{antialias:!1,alpha:!1,va:typeof WebGL2RenderingContext!="undefined"?2:1}),l.i.GL.makeContextCurrent(C),Re.h=4;break;case 7:if(l.m=document.createElement("canvas"),!(we=l.m.getContext("webgl2",{}))&&!(we=l.m.getContext("webgl",{})))return alert("Failed to create WebGL canvas context when passing video frame."),Re.return();l.K=we,l.i.canvas=l.m,l.i.createContext(l.m,!0,!0,{});case 4:l.j=new l.i.SolutionWasm,l.ga=!1,Re.h=0}})}function Li(l,v){var b,x;return Ze(function(D){return v in l.L?D.return(l.L[v]):(b=l.locateFile(v,""),x=fetch(b).then(function(C){return C.arrayBuffer()}),l.L[v]=x,D.return(x))})}function Gd(l,v,b){var x,D,C,M,F,K,de,me,we,Re,pe,Le,Be,at;return Ze(function(nt){switch(nt.h){case 1:if(!b)return nt.return(v);for(x={},D=0,C=q(Object.keys(b)),M=C.next();!M.done;M=C.next())F=M.value,typeof(K=b[F])!="string"&&K.type==="texture"&&v[K.stream]!==void 0&&++D;1<D&&(l.M=!1),de=q(Object.keys(b)),M=de.next();case 2:if(M.done){nt.h=4;break}if(me=M.value,typeof(we=b[me])=="string")return Be=x,at=me,lt(nt,function(Rr,au,qn){var ba;return Ze(function(ds){return typeof qn=="number"||qn instanceof Uint8Array||qn instanceof Rr.i.Uint8BlobList?ds.return(qn):qn instanceof Rr.i.Texture2dDataOut?((ba=Rr.v[au])||(ba=new cs(Rr.i,Rr.K),Rr.v[au]=ba),ds.return(Pi(ba,qn,Rr.M))):ds.return(void 0)})}(l,me,v[we]),14);if(Re=v[we.stream],we.type==="detection_list"){if(Re){for(var Qe=Re.getRectList(),un=Re.getLandmarksList(),Xt=Re.getClassificationsList(),Xe=[],Dt=0;Dt<Qe.size();++Dt){var hr=os(Qe.get(Dt)),ya=void 0;ya=ya===void 0?0:ya,hr={la:{sa:jt(hr,1),ta:jt(hr,2),height:jt(hr,3),width:jt(hr,4),rotation:jt(hr,5,0),pa:lr(vn(hr,6),ya)},ea:qo(jd(un.get(Dt)),Ri,1).map(ss),ba:Fd(Bd(Xt.get(Dt)))},Xe.push(hr)}Qe=Xe}else Qe=[];x[me]=Qe,nt.h=7;break}if(we.type==="proto_list"){if(Re){for(Qe=Array(Re.size()),un=0;un<Re.size();un++)Qe[un]=Re.get(un);Re.delete()}else Qe=[];x[me]=Qe,nt.h=7;break}if(Re===void 0){nt.h=3;break}if(we.type==="float_list"){x[me]=Re,nt.h=7;break}if(we.type==="proto"){x[me]=Re,nt.h=7;break}if(we.type!=="texture")throw Error("Unknown output config type: '"+we.type+"'");return(pe=l.v[me])||(pe=new cs(l.i,l.K),l.v[me]=pe),lt(nt,Pi(pe,Re,l.M),13);case 13:Le=nt.i,x[me]=Le;case 7:we.transform&&x[me]&&(x[me]=we.transform(x[me])),nt.h=3;break;case 14:Be[at]=nt.i;case 3:M=de.next(),nt.h=2;break;case 4:return nt.return(x)}})}function Hd(l,v){for(var b=v.name||"$",x=[].concat(re(v.wants)),D=new l.i.StringList,C=q(v.wants),M=C.next();!M.done;M=C.next())D.push_back(M.value);C=l.i.PacketListener.implement({onResults:function(F){for(var K={},de=0;de<v.wants.length;++de)K[x[de]]=F.get(de);var me=l.listeners[b];me&&(l.I=Gd(l,K,v.outs).then(function(we){we=me(we);for(var Re=0;Re<v.wants.length;++Re){var pe=K[x[Re]];J(pe)==="object"&&pe.hasOwnProperty&&pe.hasOwnProperty("delete")&&pe.delete()}we&&(l.I=we)}))}}),l.j.attachMultiListener(D,C),D.delete()}function ls(l){return l===void 0&&(l=0),l===1?"selfie_segmentation_landscape.tflite":"selfie_segmentation.tflite"}function _a(l){var v=this;l=l||{},this.h=new us({locateFile:l.locateFile,files:function(b){return[{simd:!0,url:"selfie_segmentation_solution_simd_wasm_bin.js"},{simd:!1,url:"selfie_segmentation_solution_wasm_bin.js"},{data:!0,url:ls(b.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":J(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(b){var x,D,C;return Ze(function(M){return M.h==1?(x=ls(b),D="third_party/mediapipe/modules/selfie_segmentation/"+x,lt(M,Li(v.h,x),2)):(C=M.i,v.h.overrideFile(D,C),M.return(!0))})}}}})}(ae=us.prototype).close=function(){return this.j&&this.j.delete(),Promise.resolve()},ae.reset=function(){var l=this;return Ze(function(v){l.j&&(l.j.reset(),l.s={},l.v={}),v.h=0})},ae.setOptions=function(l,v){var b=this;if(v=v||this.h.options){for(var x=[],D=[],C={},M=q(Object.keys(l)),F=M.next();!F.done;C={X:C.X,Y:C.Y},F=M.next())if(!((F=F.value)in this.l)||this.l[F]!==l[F]){this.l[F]=l[F];var K=v[F];K!==void 0&&(K.onChange&&(C.X=K.onChange,C.Y=l[F],x.push(function(de){return function(){return Ze(function(me){if(me.h==1)return lt(me,de.X(de.Y),2);me.i===!0&&(b.u=!0),me.h=0})}}(C))),K.graphOptionXref&&(F=Object.assign({},{calculatorName:"",calculatorIndex:0},K.graphOptionXref,{valueNumber:K.type===1?l[F]:0,valueBoolean:K.type===0&&l[F],valueString:K.type===2?l[F]:""}),D.push(F)))}x.length===0&&D.length===0||(this.u=!0,this.H=(this.H===void 0?[]:this.H).concat(D),this.F=(this.F===void 0?[]:this.F).concat(x))}},ae.initialize=function(){var l=this;return Ze(function(v){return v.h==1?lt(v,iu(l),2):v.h!=3?lt(v,function(b){var x,D,C,M,F,K,de,me;return Ze(function(we){if(we.h==1)return b.h.graph&&b.h.graph.url&&b.fa===b.h.graph.url?we.return():(b.u=!0,b.h.graph&&b.h.graph.url?(b.fa=b.h.graph.url,lt(we,Li(b,b.h.graph.url),3)):void(we.h=2));for(we.h!=2&&(x=we.i,b.j.loadGraph(x)),D=q(Object.keys(b.D)),C=D.next();!C.done;C=D.next())M=C.value,b.j.overrideFile(M,b.D[M]);if(b.D={},b.h.listeners)for(F=q(b.h.listeners),K=F.next();!K.done;K=F.next())de=K.value,Hd(b,de);me=b.l,b.l={},b.setOptions(me),we.h=0})}(l),3):lt(v,function(b){var x,D,C,M,F,K;return Ze(function(de){switch(de.h){case 1:if(!b.u)return de.return();if(!b.F){de.h=2;break}x=q(b.F),D=x.next();case 3:if(D.done){de.h=5;break}return lt(de,(0,D.value)(),4);case 4:D=x.next(),de.h=3;break;case 5:b.F=void 0;case 2:if(b.H){for(C=new b.i.GraphOptionChangeRequestList,M=q(b.H),F=M.next();!F.done;F=M.next())K=F.value,C.push_back(K);b.j.changeOptions(C),C.delete(),b.H=void 0}b.u=!1,de.h=0}})}(l),0)})},ae.overrideFile=function(l,v){this.j?this.j.overrideFile(l,v):this.D[l]=v},ae.clearOverriddenFiles=function(){this.D={},this.j&&this.j.clearOverriddenFiles()},ae.send=function(l,v){var b,x,D,C,M,F,K,de,me,we=this;return Ze(function(Re){switch(Re.h){case 1:return we.h.inputs?(b=1e3*(v==null?performance.now():v),lt(Re,we.I,2)):Re.return();case 2:return lt(Re,we.initialize(),3);case 3:for(x=new we.i.PacketDataList,D=q(Object.keys(l)),C=D.next();!C.done;C=D.next())if(M=C.value,F=we.h.inputs[M]){e:{var pe=l[M];switch(F.type){case"video":var Le=we.s[F.stream];if(Le||(Le=new cs(we.i,we.K),we.s[F.stream]=Le),Le.m===0&&(Le.m=Le.i.createTexture()),typeof HTMLVideoElement!="undefined"&&pe instanceof HTMLVideoElement)var Be=pe.videoWidth,at=pe.videoHeight;else typeof HTMLImageElement!="undefined"&&pe instanceof HTMLImageElement?(Be=pe.naturalWidth,at=pe.naturalHeight):(Be=pe.width,at=pe.height);at={glName:Le.m,width:Be,height:at},(Be=Le.h).canvas.width=at.width,Be.canvas.height=at.height,Be.activeTexture(Be.TEXTURE0),Le.i.bindTexture2d(Le.m),Be.texImage2D(Be.TEXTURE_2D,0,Be.RGBA,Be.RGBA,Be.UNSIGNED_BYTE,pe),Le.i.bindTexture2d(0),Le=at;break e;case"detections":for((Le=we.s[F.stream])||(Le=new Di(we.i),we.s[F.stream]=Le),Le.data||(Le.data=new Le.h.DetectionListData),Le.data.reset(pe.length),at=0;at<pe.length;++at){Be=pe[at];var nt=Le.data,Qe=nt.setBoundingBox,un=at,Xt=Be.la,Xe=new Ai;if(gn(Xe,1,Xt.sa),gn(Xe,2,Xt.ta),gn(Xe,3,Xt.height),gn(Xe,4,Xt.width),gn(Xe,5,Xt.rotation),Dn(Xe,6,Xt.pa),Xt=Xe.l(),Qe.call(nt,un,Xt),Be.ea)for(nt=0;nt<Be.ea.length;++nt){Xe=Be.ea[nt],un=(Qe=Le.data).addNormalizedLandmark,Xt=at,Xe=Object.assign({},Xe,{visibility:Xe.visibility?Xe.visibility:0});var Dt=new Ri;gn(Dt,1,Xe.x),gn(Dt,2,Xe.y),gn(Dt,3,Xe.z),Xe.visibility&&gn(Dt,4,Xe.visibility),Xe=Dt.l(),un.call(Qe,Xt,Xe)}if(Be.ba)for(nt=0;nt<Be.ba.length;++nt)un=(Qe=Le.data).addClassification,Xt=at,Xe=Be.ba[nt],gn(Dt=new Yr,2,Xe.qa),Xe.index&&Dn(Dt,1,Xe.index),Xe.label&&Dn(Dt,3,Xe.label),Xe.displayName&&Dn(Dt,4,Xe.displayName),Xe=Dt.l(),un.call(Qe,Xt,Xe)}Le=Le.data;break e;default:Le={}}}switch(K=Le,de=F.stream,F.type){case"video":x.pushTexture2d(Object.assign({},K,{stream:de,timestamp:b}));break;case"detections":(me=K).stream=de,me.timestamp=b,x.pushDetectionList(me);break;default:throw Error("Unknown input config type: '"+F.type+"'")}}return we.j.send(x),lt(Re,we.I,4);case 4:x.delete(),Re.h=0}})},ae.onResults=function(l,v){this.listeners[v||"$"]=l},he("Solution",us),he("OptionType",{BOOL:0,NUMBER:1,ua:2,0:"BOOL",1:"NUMBER",2:"STRING"}),(ae=_a.prototype).close=function(){return this.h.close(),Promise.resolve()},ae.onResults=function(l){this.h.onResults(l)},ae.initialize=function(){var l=this;return Ze(function(v){return lt(v,l.h.initialize(),0)})},ae.reset=function(){this.h.reset()},ae.send=function(l){var v=this;return Ze(function(b){return lt(b,v.h.send(l),0)})},ae.setOptions=function(l){this.h.setOptions(l)},he("SelfieSegmentation",_a),he("VERSION","0.1.1675465747")}).call(Ro);var wr=function(ae){return typeof ae=="number"},Dc=function(){function ae(){Pe(this,ae),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 Eo({canvas:this.canvasBeauty,video:this.videoBeauty}),this.canvasVirtual=document.createElement("canvas"),this.virtual=new Co({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,Ve,Fe,ne;return ut(ae,[{key:"generateBeautyStream",value:function(q){this.userId=q==null?void 0:q.getUserId();var re=q.getVideoTrack();if(!re)throw new Error("Your localStream does not contain video track.");var j=this.generateBeautyTrack(re);return q.replaceTrack(j),this.localStream=q,q.setBeautyStatus&&q.setBeautyStatus(!0),console.log("RTCBeautyPlugin: generateBeautyStream ".concat(this.userId?"userId: ".concat(this.userId):"")),q}},{key:"generateBeautyTrack",value:function(q){var re=this;this.reset();var j=q.getSettings();this.frameRate=j.frameRate,this.filter.setRect(j.width,j.height),this.setRect(j.width,j.height);var Z=new MediaStream;Z.addTrack(q),this.videoBeauty.srcObject=Z,this.videoBeauty.play();var ye=this.canvasBeauty.captureStream(this.frameRate||15).getVideoTracks()[0];return this.rafId&&cancelAnimationFrame(this.rafId),this.rafId=requestAnimationFrame(function(){re.startTime=new Date().getTime(),re.render()}),this.installEvents(),this.originTrack=q,this.beautyTrack=ye,this.setTrackParam({type:"beauty",originTrack:q,resultTrack:ye,param:this.beautyParams}),ye}},{key:"setBackground",value:(ne=z(V().mark(function q(re){return V().wrap(function(j){for(;;)switch(j.prev=j.next){case 0:return j.next=2,this.virtual.setBackground(re);case 2:console.log("RTCBeautyPlugin: setBackground img:".concat(re));case 3:case"end":return j.stop()}},q,this)})),function(q){return ne.apply(this,arguments)})},{key:"generateStream",value:(Fe=z(V().mark(function q(re){var j,Z,ye,ie,_e;return V().wrap(function(De){for(;;)switch(De.prev=De.next){case 0:if(j=re.localStream,Z=re.type,ye=re.img,ie=j.getVideoTrack()){De.next=4;break}throw new Error("Your localStream does not contain video track.");case 4:return this.localStream=j,De.next=7,this.generateMixedTrack({videoTrack:ie,type:Z,img:ye});case 7:return _e=De.sent,j.replaceTrack(_e),j.setBeautyStatus&&j.setBeautyStatus(!0),De.abrupt("return",j);case 11:case"end":return De.stop()}},q,this)})),function(q){return Fe.apply(this,arguments)})},{key:"generateMixedTrack",value:(Ve=z(V().mark(function q(re){var j,Z,ye,ie,_e;return V().wrap(function(De){for(;;)switch(De.prev=De.next){case 0:if(j=re.videoTrack,Z=re.type,ye=re.img,this.virtual.selfieSegmentation){De.next=3;break}throw new Error("you should call loadResources() first");case 3:return this.virtual.initVirtualParams({type:Z,img:ye}),De.next=6,this.generateBeautyTrack(j);case 6:return ie=De.sent,De.next=9,this.generateVirtualTrack({videoTrack:ie,type:Z,img:ye});case 9:return _e=De.sent,this.beautyTrack=ie,this.resultTrack=_e,this.setTrackParam({type:"mixed",originTrack:this.originTrack,resultTrack:this.resultTrack,param:{type:Z,img:ye}}),De.abrupt("return",this.resultTrack);case 14:case"end":return De.stop()}},q,this)})),function(q){return Ve.apply(this,arguments)})},{key:"generateVirtualStream",value:(Se=z(V().mark(function q(re){var j,Z,ye,ie,_e;return V().wrap(function(De){for(;;)switch(De.prev=De.next){case 0:if(j=re.localStream,Z=re.type,ye=re.img,ie=j.getVideoTrack()){De.next=4;break}throw new Error("Your localStream does not contain video track.");case 4:return this.localStream=j,De.next=7,this.generateVirtualTrack({videoTrack:ie,type:Z,img:ye});case 7:return _e=De.sent,De.next=10,j.replaceTrack(_e);case 10:return j.setBeautyStatus&&j.setBeautyStatus(!0),console.log("".concat(this.userId?"[userId: ".concat(this.userId,"]"):""," RTCBeautyPlugin generate ").concat(Z," Stream.")),De.abrupt("return",j);case 13:case"end":return De.stop()}},q,this)})),function(q){return Se.apply(this,arguments)})},{key:"generateVirtualTrack",value:(Te=z(V().mark(function q(re){var j,Z,ye,ie;return V().wrap(function(_e){for(;;)switch(_e.prev=_e.next){case 0:if(j=re.videoTrack,Z=re.type,ye=re.img,this.virtual.selfieSegmentation){_e.next=3;break}throw new Error("you should call loadResources() first");case 3:return ie=j.getSettings(),this.frameRate=ie.frameRate,this.virtual.setRect(ie.width,ie.height),_e.next=8,this.virtual.initVirtualParams({type:Z,img:ye});case 8:return this.setRect(ie.width,ie.height),this.mediaStream=new MediaStream,this.mediaStream.addTrack(j),this.videoVirtual.srcObject=this.mediaStream,_e.next=14,this.videoVirtual.play();case 14:return this.virtual.startVirtual(this.frameRate),_e.next=17,this.virtual.render();case 17:return this.originTrack=j,this.resultTrack=this.canvasVirtual.captureStream(this.frameRate||15).getVideoTracks()[0],this.setTrackParam({type:"virtual",originTrack:this.originTrack,resultTrack:this.resultTrack,param:{type:Z,img:ye}}),this.isVirualEnable=!0,_e.abrupt("return",this.resultTrack);case 22:case"end":return _e.stop()}},q,this)})),function(q){return Te.apply(this,arguments)})},{key:"replaceVirtualTrack",value:function(q){this.isVirualEnable&&(this.mediaStream.removeTrack(this.mediaStream.getVideoTracks()[0]),this.mediaStream.addTrack(q),this.originTrack=q)}},{key:"deleteSource",value:function(q){if(m.default){var re=m.default.beautyTrackMap.get(q);re&&(re.type==="mixed"&&this.deleteSource(re.originTrack.id),re.originTrack&&(re.originTrack.stop(),re.originTrack=null),re.beautyTrack&&(re.beautyTrack.stop(),re.beautyTrack=null),re.resultTrack&&(re.resultTrack.stop(),re.resultTrack=null),m.default.beautyTrackMap.delete(q))}}},{key:"draw",value:function(){this.videoBeauty&&this.videoBeauty.readyState===this.videoBeauty.HAVE_ENOUGH_DATA&&this.filter.apply(this.videoBeauty)}},{key:"enableVirtualBg",value:function(){var q;if(this.virtual&&!this.isVirualEnable)return this.virtual.setEnable(!0),this.virtual.render(),this.isVirualEnable=!0,(q=this.localStream)===null||q===void 0||q.replaceTrack(this.resultTrack),console.log("".concat(this.userId?"[userId: ".concat(this.userId,"]"):""," RTCBeautyPlugin enable.")),this.resultTrack}},{key:"disableVirtualBg",value:function(){var q;if(this.virtual&&this.isVirualEnable)return this.virtual.setEnable(!1),this.isVirualEnable=!1,(q=this.localStream)===null||q===void 0||q.replaceTrack(this.originTrack),console.log("".concat(this.userId?"[userId: ".concat(this.userId,"]"):""," RTCBeautyPlugin disable.")),this.originTrack}},{key:"changeType",value:function(q){var re=q.type,j=q.img;console.log("".concat(this.userId?"[userId: ".concat(this.userId,"]"):""," RTCBeautyPlugin changeType\uFF1A").concat(re,". img: ").concat(j,".")),re==="blur"&&(this.virtual.reset(),this.virtual.initVirtualParams({type:"blur"}),this.virtual.startVirtual(this.frameRate),this.virtual.render()),re==="virtual"&&(this.virtual.reset(),this.virtual.initVirtualParams({type:"virtual",img:j}),this.virtual.startVirtual(this.frameRate),this.virtual.render()),this.setTrackParam({type:re,originTrack:this.originTrack,resultTrack:this.resultTrack,param:{type:re,img:j}})}},{key:"render",value:function(){var q=this,re=new Date().getTime();re-this.startTime>1e3/this.frameRate&&(this.draw(),this.startTime=re),document.hidden?(clearTimeout(this.timeoutId),this.timeoutId=setTimeout(function(){q.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(q){var re=q.beauty,j=q.brightness,Z=q.ruddy;wr(re)&&(this.beautyParams.beauty=re),wr(j)&&(this.beautyParams.brightness=j),wr(Z)&&(this.beautyParams.ruddy=Z),this.filter.setBeautyParams(this.beautyParams),this.getClose()&&!this.disableStatus&&this.disable(),!this.getClose()&&this.disableStatus&&this.enable()}},{key:"setRect",value:function(q,re){var j=q||640,Z=re||480;this.videoBeauty.height=Z,this.videoBeauty.width=j,this.canvasBeauty.height=Z,this.canvasBeauty.width=j,this.videoVirtual.height=Z,this.videoVirtual.width=j,this.canvasVirtual.height=Z,this.canvasVirtual.width=j}},{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(q){return this.canvasVirtual.captureStream(q).getVideoTracks()[0]}},{key:"setTrackParam",value:function(q){var re=q.type,j=q.originTrack,Z=q.resultTrack,ye=q.param;m.default&&(m.default.beautyTrackMap||(m.default.beautyTrackMap=new Map),m.default.beautyTrackMap.set(Z.id,{type:re,originTrack:j,resultTrack:Z,param:ye,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}}]),ae}();return m.default&&(m.default.getRTCBeautyPlugin=function(){return new Dc}),Dc})});var vw="0.0.10";var yd=ir(Ir());var _d=ir(Ir());var Ew=ir(dg());var bo=class extends Ew.default{constructor({mediaType:m}){super();Ue(this,"trackMediaType");Ue(this,"_stream");Ue(this,"_playerState");this.trackMediaType=m}get isPlaying(){return this._playerState==="PLAYING"}async stop(){this._playerState="STOPPED",await this._stream.stop()}};var C7=1,So=class extends bo{constructor(m){super(m);Ue(this,"TRTC",_d.default);Ue(this,"muted");Ue(this,"_publishedStream",null);Ue(this,"_log");this._log=Fn.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:V,microphoneId:J,cameraId:N})=>{if(this._publishedStream&&this._stream!==this._publishedStream){let z=this.getMediaStreamTrack(),Pe=this.trackMediaType==="audio"?this._publishedStream.getAudioTrack():this._publishedStream.getVideoTrack();z&&Pe&&z!==Pe&&this._publishedStream.replaceTrack(z)}if(m){let z=(await _d.default.getMicrophones()).find(Pe=>Pe.deviceId===J);z&&this.emit("device-switched",z)}if(V){let z=(await _d.default.getCameras()).find(Pe=>Pe.deviceId===N);z&&this.emit("device-switched",z)}}),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,V){return super.on(m,V),this}async setMuted(m){let V=this._publishedStream||this._stream;this.trackMediaType==="audio"?m?V.muteAudio():V.unmuteAudio():m?V.muteVideo():V.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,V;return((V=(m=this.getMediaStreamTrack())==null?void 0:m.getSettings())==null?void 0:V.deviceId)||""}};var Rw=ir(Cw()),Aw=ir(Ir());var ko=class extends So{constructor(m){super(m);Ue(this,"mirrored",!1);Ue(this,"lastPlayContainer");Ue(this,"_beautyPlugin");Ue(this,"_virtualTrack");Ue(this,"_isVirtualEnable",!1);Ue(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 V;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 Rw.default,await this._beautyPlugin.virtual.loadResources(),this._beautyPlugin.virtual.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 J=await this._beautyPlugin.generateVirtualStream({localStream:this._stream,type:m==="blur"?"blur":"virtual",img:m==="blur"?void 0:m});this._virtualTrack=J.getVideoTrack(),this._publishedStream&&this._publishedStream.replaceTrack(this._virtualTrack),this._isVirtualEnable=!0}return(V=this._originTrack)==null||V.addEventListener("ended",this.onOriginTrackEnded),this._imageUrl=m,!this._isVirtualEnable&&this._beautyPlugin&&(this._beautyPlugin.enableVirtualBg(),this._isVirtualEnable=!0),!0}async onOriginTrackEnded(){let m=(await Aw.default.getCameras())[0];m?this.setDevice(m.deviceId):this.emit("track-ended",this.trackMediaType)}async stopVirtualBackground(){var m;return this._log.info("stopVirtualBackground"),this._beautyPlugin&&this._isVirtualEnable&&(this._beautyPlugin.disableVirtualBg(),this._isVirtualEnable=!1,(m=this._originTrack)==null||m.removeEventListener("ended",this.onOriginTrackEnded)),!0}getDeviceId(){var m,V;return this._isVirtualEnable||this._beautyPlugin?((V=(m=this._beautyPlugin.originTrack)==null?void 0:m.getSettings())==null?void 0:V.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 Ac=class extends ko{constructor(m){super(md(Jr({},m),{mediaType:"video"}));Ue(this,"_videoProfile",{width:320,height:240,frameRate:15,bitrate:300});let{width:V,height:J,frameRate:N,bitrate:z}=m;Fn.info("new LingoCameraVideoTrack"),this._stream=yd.default.createStream({audio:!1,video:!0,cameraId:m.cameraId}),V&&(this._videoProfile.width=V),J&&(this._videoProfile.height=J),N&&(this._videoProfile.frameRate=N),z&&(this._videoProfile.bitrate=z),this._stream.setVideoProfile(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 N,z,Pe;let V=this._beautyPlugin&&this._isVirtualEnable;if(this._log.info(`setDevice ${m} visual: ${V}`),V){let ke=yd.default.createStream({audio:!1,video:!0,cameraId:m});ke.setVideoProfile(this._videoProfile),await ke.initialize();let ut=ke.getVideoTrack();ut&&((N=this._originTrack)==null||N.removeEventListener("ended",this.onOriginTrackEnded),await((z=this._beautyPlugin)==null?void 0:z.replaceVirtualTrack(ut)),(Pe=this._originTrack)==null||Pe.addEventListener("ended",this.onOriginTrackEnded))}else await this._stream.switchDevice(this.trackMediaType,m);let J=(await yd.default.getCameras()).find(ke=>ke.deviceId===m);J&&this.emit("device-switched",J),!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 Pw=ir(Ir());var R7=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(X){let G=Math.random()*16|0;return(X=="x"?G:G&3|8).toString(16)})};function bd(){return!performance||!performance.now?Date.now():Math.floor(performance.now())}var fg=class{constructor(){this.intervalMap_=new Map}setInterval(G,m,V=!0){if(!window||!window.requestAnimationFrame)return setInterval(G,m);let J=R7(),N=bd(),z=N;this.intervalMap_.set(J,{rafId:null,timeoutId:null,onVisibilityChange:null});let Pe=()=>{if(V&&document.hidden){if(G(),!this.intervalMap_.has(J))return;let ut=setTimeout(Pe,m);this.setTimeoutId(J,ut),N=bd(),z=N}else{if(z=bd(),z-N>=m&&(N=z,G(),!this.intervalMap_.has(J)))return;let ut=requestAnimationFrame(Pe);this.setRafId(J,ut)}},ke=requestAnimationFrame(Pe);if(this.setRafId(J,ke),V){let ut=()=>{if(document.hidden){let Mt=bd()-N;if(Mt>=m)Pe();else{let $e=setTimeout(Pe,m-Mt);this.setTimeoutId(J,$e)}}};document.addEventListener("visibilitychange",ut),this.setOnVisibilityChange(J,ut),document.hidden&&ut()}return J}clearInterval(G){if(this.intervalMap_.has(G)){let{rafId:m,timeoutId:V,onVisibilityChange:J}=this.intervalMap_.get(G);cancelAnimationFrame(m),clearTimeout(V),document.removeEventListener("visibilitychange",J),this.intervalMap_.delete(G)}}setTimeoutId(G,m){if(this.intervalMap_.has(G)){let V=this.intervalMap_.get(G);V.timeoutId&&clearTimeout(V.timeoutId),V.timeoutId=m}}setRafId(G,m){if(this.intervalMap_.has(G)){let V=this.intervalMap_.get(G);V.rafId&&cancelAnimationFrame(V.rafId),V.rafId=m}}setOnVisibilityChange(G,m){if(this.intervalMap_.has(G)){let V=this.intervalMap_.get(G);V.onVisibilityChange=m}}},A7=new fg,mg=A7;var Sd=class extends ko{constructor(m){super({mediaType:"video",id:"cus"});Ue(this,"frameRate",0);Ue(this,"canvas",document.createElement("canvas"));Ue(this,"canvasCtx");Ue(this,"onDraw",null);Ue(this,"_cameraVideoTrack",null);Ue(this,"_timerId");this._cameraVideoTrack=m}timerStop(){mg.clearInterval(this._timerId)}async init(){var J;if(this.canvasCtx)return;this.canvasCtx=this.canvas.getContext("2d");let m=(J=this._cameraVideoTrack)==null?void 0:J.getMediaStreamTrack();if(m){let{width:N,height:z,frameRate:Pe}=m.getSettings();N&&(this.canvas.width=N),z&&(this.canvas.height=z),Pe&&(this.frameRate=Pe)}this._timerId=mg.setInterval(()=>{var Pe,ke,ut;let N=(Pe=this._cameraVideoTrack)==null?void 0:Pe.getMediaStreamTrack();if(N){let{width:Mt,height:$e,frameRate:ar}=N.getSettings();Mt&&(this.canvas.width=Mt),$e&&(this.canvas.height=$e),ar&&(this.frameRate=ar)}let z=(ke=this._cameraVideoTrack)==null?void 0:ke.videoElement;z&&((ut=this.canvasCtx)==null||ut.drawImage(z,0,0,this.canvas.width,this.canvas.height),this.onDraw&&this.onDraw(this.canvas,this.mirrored))},1e3/this.frameRate,!0);let V=this.canvas.captureStream(this.frameRate).getVideoTracks()[0];this._stream=Pw.default.createStream({videoSource:V}),await super.init()}async play(m){var V,J,N,z;if(m.container){this.lastPlayContainer=m.container,(V=this._cameraVideoTrack)!=null&&V.isPlaying||await((J=this._cameraVideoTrack)==null?void 0:J.play({container:m.container}));let Pe=(N=this._cameraVideoTrack)==null?void 0:N.videoElement;Pe&&Pe.parentElement&&(Pe.parentElement.style.display="none"),await this._stream.play(m.container),this.mirrorVideo(this.mirrored)}(z=m.custom)!=null&&z.onDraw&&(this.onDraw=m.custom.onDraw)}async stop(){var V;this.onDraw=null;let m=(V=this._cameraVideoTrack)==null?void 0:V.videoElement;m&&m.parentElement&&(m.parentElement.style.display="block"),await this._stream.stop(),this.lastPlayContainer=null}};var vg=ir(Ir());function kd(X){return X*1.5>100?100:X*1.5}var Td=class extends So{constructor({microphoneId:m}){super({mediaType:"audio"});Ue(this,"_captureVolume",100);Ue(this,"_div",document.createElement("div"));Ue(this,"_isPlayCalled",!1);Fn.info("new LingoMicrophoneAudioTrack"),this._stream=vg.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 V;m===null?(V=this._publishedStream)==null||V.setAudioCaptureVolume(100):m.setAudioCaptureVolume(this._captureVolume),super.setPublishedStream(m)}async setDevice(m){if(Fn.warn(`switch mic ${m}`),await this._stream.switchDevice(this.trackMediaType,m),this._publishedStream&&this._publishedStream!==this._stream){let J=this.getMediaStreamTrack();J&&await this._publishedStream.replaceTrack(J)}let V=(await vg.default.getMicrophones()).find(J=>J.deviceId===m);V&&this.emit("device-switched",V)}setVolume(m){var V;(V=this._publishedStream)==null||V.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 To=class extends bo{constructor({uid:m,mediaType:V,stream:J}){super({mediaType:V});Ue(this,"uid");Ue(this,"isSubscribed",!1);this.uid=m,this._stream=J,this._stream.on("player-state-changed",({state:N})=>{this._playerState=N})}subscribe(){this.isSubscribed=!0}unsubscribe(){this.isSubscribed=!1}};var xd=class extends To{constructor({uid:G,stream:m}){super({uid:G,mediaType:"audio",stream:m})}setVolume(G){this._stream.setAudioVolume(G/100)}getVolume(){return kd(this._stream.getAudioLevel()*100)}setSpeakerDevice(G){return this._stream.setAudioOutput(G)}async play(){return this._stream.isPlaying()?Promise.resolve():this._stream.play(document.createElement("div"))}};var Id=class extends To{constructor({uid:m,stream:V}){super({uid:m,mediaType:"video",stream:V});Ue(this,"mirrored",!1);Ue(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 bg}from"@lingoace/lingo-base-rtc";var gg=ir(Ir());import{LingoBaseRTCClient as P7,LingoRTCError as xo}from"@lingoace/lingo-base-rtc";var wd=new WeakMap;function Ed(){return function(X,G,m){let V=m.value,J=({fn:N,args:z,context:Pe,resolve:ke,reject:ut})=>{N.apply(Pe,z).then(ke,ut).finally(()=>{let Mt=wd.get(Pe);Mt.shift(),Mt[0]&&J(Jr({},Mt[0]))})};return m.value=function(...N){return new Promise((z,Pe)=>{if(wd.has(this)){let ke=wd.get(this),{length:ut}=ke;ke.push({fn:V,args:N,context:this,resolve:z,reject:Pe}),ut===0&&J({fn:V,args:N,context:this,resolve:z,reject:Pe})}else wd.set(this,[{fn:V,args:N,context:this,resolve:z,reject:Pe}]),J({fn:V,args:N,context:this,resolve:z,reject:Pe})})},m}}import{LingoRTCError as Dw}from"@lingoace/lingo-base-rtc";function In(X){return function(G,m,V){let J=V.value;return V.value=async function(...N){try{return await J.apply(this,N)}catch(z){throw X?X(z):z instanceof Dw?z:Dw.createOtherError(z.message)}},V}}var wn=class extends P7{constructor(){super(...arguments);Ue(this,"_client",null);Ue(this,"_localStream",null);Ue(this,"_screenStream",null);Ue(this,"_remoteAuxiliaryStream",null);Ue(this,"_remoteMainStreamMap",new Map);Ue(this,"_quality",{res:"0x0",vfps:0,vra:0,ara:0,rtt:0,pktLostRate:0,upQuality:0,downQuality:0});Ue(this,"_prevLocalVideoStat",null);Ue(this,"_prevLocalAudioStat",null)}getRemoteUsers(){let m=new Map;return this.remoteAudioTrackMap.forEach(V=>{if(m.has(V.uid)){let J=m.get(V.uid);J.hasAudio=!0,J.audioTrack=V.isSubscribed?V:void 0}else m.set(V.uid,{uid:V.uid,hasAudio:!0,hasVideo:!1,audioTrack:V.isSubscribed?V:void 0,videoTrack:void 0})}),this.remoteVideoTrackMap.forEach(V=>{let{uid:J}=V;if(m.has(V.uid)){let N=m.get(V.uid);N.hasVideo=!0,N.videoTrack=V.isSubscribed?V:void 0}else m.set(J,{uid:J,hasAudio:!1,hasVideo:!0,audioTrack:void 0,videoTrack:V.isSubscribed?V:void 0})}),[...m.values()]}async join(m){return this._client=gg.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?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 J;let V=m.getMediaStreamTrack();return!V||!this._localStream||this.localTracks.length===0||(this.localTracks.length===1?(await((J=this._client)==null?void 0:J.unpublish(this._localStream)),m.setPublishedStream(null),this._localStream=null,this.localTracks=[]):this.localTracks.find(N=>N===m)&&(await this._localStream.removeTrack(V),m.setPublishedStream(null),this.localTracks=this.localTracks.filter(N=>N!==m))),!0}async subscribe(m,V){var J,N;if(!this._client)throw xo.createOtherError("\u7528\u6237\u672A\u8FDB\u623F\uFF0C\u65E0\u6CD5\u8BA2\u9605");if(V==="audio"&&!this.remoteAudioTrackMap.has(m))throw xo.createOtherError(`\u8FDC\u7AEF\u7528\u6237: ${m} \u672A\u63A8\u97F3\u9891\uFF0C\u65E0\u6CD5\u8BA2\u9605`);if(V==="video"&&!this.remoteVideoTrackMap.has(m))throw xo.createOtherError(`\u8FDC\u7AEF\u7528\u6237: ${m} \u672A\u63A8\u89C6\u9891\uFF0C\u65E0\u6CD5\u8BA2\u9605`);if(V==="audio"){let z=this.remoteAudioTrackMap.get(m);z.subscribe();try{await this._client.subscribe(z._stream,{audio:!0,video:!!((J=this.remoteVideoTrackMap.get(m))!=null&&J.isSubscribed)})}catch(Pe){throw z.unsubscribe(),Pe}}else{let z=this.remoteVideoTrackMap.get(m);z.subscribe();try{await this._client.subscribe(z._stream,{video:!0,audio:!!((N=this.remoteAudioTrackMap.get(m))!=null&&N.isSubscribed)})}catch(Pe){throw z.unsubscribe(),Pe}}return!0}async unsubscribe(m,V){var N,z;if(!this._client)throw xo.createOtherError("\u7528\u6237\u672A\u8FDB\u623F\uFF0C\u65E0\u6CD5\u8BA2\u9605");let J=null;if(V==="audio"&&this.remoteAudioTrackMap.has(m)?J=this.remoteAudioTrackMap.get(m):V==="video"&&this.remoteVideoTrackMap.has(m)&&(J=this.remoteVideoTrackMap.get(m)),!J)throw xo.createOtherError(`\u8FDC\u7AEF\u7528\u6237: ${m} \u672A\u63A8 ${V}\uFF0C\u65E0\u6CD5\u8BA2\u9605`);return V==="audio"?(N=this.remoteVideoTrackMap.get(m))!=null&&N.isSubscribed?await this._client.subscribe(J._stream,{video:!0,audio:!1}):await this._client.unsubscribe(J._stream):(z=this.remoteAudioTrackMap.get(m))!=null&&z.isSubscribed?await this._client.subscribe(J._stream,{video:!1,audio:!0}):await this._client.unsubscribe(J._stream),J.unsubscribe(),!0}getQOEStats(){return this._quality}async startScreenShare(m){if(!this.joinParam||!this._client)throw xo.createOtherError("\u7528\u6237\u672A\u8FDB\u623F\uFF0C\u65E0\u6CD5\u5F00\u542F\u5C4F\u5E55\u5206\u4EAB");this._screenStream=gg.default.createStream({screen:!0,screenAudio:!0});let V={width:1280,height:720,frameRate:15,bitrate:2e3};this._screenStream.setScreenProfile(Jr(Jr({},V),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 V;this._remoteAuxiliaryStream&&this._client?(await this._client.subscribe(this._remoteAuxiliaryStream),await this._remoteAuxiliaryStream.play(m)):await((V=this._screenStream)==null?void 0:V.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:V})=>{this.connectionState=V,this.emit("ConnectionStateChange",V,m,"")}),this._client.on("peer-join",m=>this.emit("UserJoined",m.userId)),this._client.on("peer-leave",m=>this.emit("UserLeft",m.userId)),this._client.on("stream-added",m=>{let V=m.stream,J=V.getUserId();if(this._remoteMainStreamMap.set(J,V),V.on("error",N=>{if(N.getCode()===16451){let z=()=>{V.resume().then(()=>{document.body.removeEventListener("click",z),document.body.removeEventListener("touchstart",z)})};document.body.addEventListener("click",z,!0),document.body.addEventListener("touchstart",z,!0),this.emit("AutoplayFailed")}}),V.getType()==="auxiliary"){this._remoteAuxiliaryStream=V,this.emit("RemoteScreenSharing",J,!0,"video");return}V.hasAudio()&&this.handleUserPublished(J,"audio"),V.hasVideo()&&this.handleUserPublished(J,"video")}),this._client.on("stream-updated",m=>{let V=m.stream,J=V.getUserId();!this.remoteAudioTrackMap.has(J)&&V.hasAudio()&&this.handleUserPublished(J,"audio"),this.remoteAudioTrackMap.has(J)&&!V.hasAudio()&&this.handleUserUnpublished(J,"audio"),!this.remoteVideoTrackMap.has(J)&&V.hasVideo()&&this.handleUserPublished(J,"video"),this.remoteVideoTrackMap.has(J)&&!V.hasVideo()&&this.handleUserUnpublished(J,"video")}),this._client.on("stream-removed",m=>{let V=m.stream.getUserId();if(m.stream.getType()==="auxiliary"){this._remoteAuxiliaryStream=null,this.emit("RemoteScreenSharing",V,!1,"video");return}this._remoteMainStreamMap.delete(V),this.handleUserUnpublished(V,"audio"),this.handleUserUnpublished(V,"video")}),this._client.on("network-quality",m=>{var V,J;this._quality.upQuality=m.uplinkNetworkQuality,this._quality.downQuality=m.downlinkNetworkQuality,this._quality.rtt=m.uplinkRTT,this._quality.pktLostRate=m.uplinkLoss,(V=this._client)==null||V.getLocalVideoStats().then(N=>{let z=N[this.uid];z&&(this._quality.res=`${z.frameWidth}x${z.frameHeight}`,this._prevLocalVideoStat&&(this._quality.vfps=Math.floor((z.framesSent-this._prevLocalVideoStat.framesSent)/2)||0,this._quality.vra=Math.floor((z.bytesSent-this._prevLocalVideoStat.bytesSent)*8/2)||0),this._prevLocalVideoStat=z)}),(J=this._client)==null||J.getLocalAudioStats().then(N=>{let z=N[this.uid];z&&(this._prevLocalAudioStat&&(this._quality.ara=Math.floor((z.bytesSent-this._prevLocalAudioStat.bytesSent)*8/2)||0),this._prevLocalAudioStat=z)}),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,V){V==="audio"?this.remoteAudioTrackMap.has(m)&&(this.remoteAudioTrackMap.delete(m),this.emit("UserUnpublished",m,V)):this.remoteVideoTrackMap.has(m)&&(this.remoteVideoTrackMap.delete(m),this.emit("UserUnpublished",m,V))}handleUserPublished(m,V,J=!1){var Pe;let N=this._remoteMainStreamMap.get(m),z=(Pe=this._client)==null?void 0:Pe.getRemoteMutedState().find(ke=>ke.userId===m);if(N){if(V==="audio"&&!this.remoteAudioTrackMap.has(m)&&N.hasAudio()){if(!J&&z&&z.audioMuted)return;let ke=new xd({uid:m,stream:N});this.remoteAudioTrackMap.set(m,ke)}else if(V==="video"&&!this.remoteVideoTrackMap.has(m)&&N.hasVideo()){let ke=new Id({uid:m,stream:N});this.remoteVideoTrackMap.set(m,ke)}this.emit("UserPublished",m,V)}}};xn([In(),Ed()],wn.prototype,"publish",1),xn([In()],wn.prototype,"unpublish",1),xn([In()],wn.prototype,"subscribe",1),xn([In()],wn.prototype,"unsubscribe",1),xn([In()],wn.prototype,"startScreenShare",1),xn([In()],wn.prototype,"stopScreenShare",1),xn([In()],wn.prototype,"playScreenShareView",1),xn([In()],wn.prototype,"stopScreenShareView",1);var wo=ir(Ir());var Lw=ir(dg()),_g=ir(Ir());var yg=class extends Lw.default{constructor(){super();Ue(this,"prevDevices_",[]);navigator.mediaDevices&&(this.onDeviceChange=this.onDeviceChange.bind(this),navigator.mediaDevices.addEventListener("devicechange",this.onDeviceChange))}async init(){this.prevDevices_=await _g.default.getDevices()}async onDeviceChange(){let m=await _g.default.getDevices(),V=m.filter(N=>this.prevDevices_.findIndex(({deviceId:z})=>N.deviceId===z)<0),J=this.prevDevices_.filter(N=>m.findIndex(({deviceId:z})=>N.deviceId===z)<0);V.length>0&&V.forEach(N=>{this.emit("device-added",N)}),J.length>0&&J.forEach(N=>{this.emit("device-removed",N)}),this.prevDevices_=m}destroy(){navigator.mediaDevices.removeEventListener("devicechange",this.onDeviceChange)}},Ow=yg;var Fn=wo.default.Logger.loggerManager,Io=class extends D7{constructor(){super(...arguments);Ue(this,"version",vw);Ue(this,"_deviceDetector",new Ow);Ue(this,"_virtualOverloadCount",0);Ue(this,"_isVirtualOverloadStart",0)}init(m){return Fn.info(`lingo-trtc version: ${this.version}`),Promise.resolve()}release(){this._deviceDetector.destroy(),super.release()}async checkSystemRequirements(){let{result:m}=await wo.default.checkSystemRequirements();return m&&wo.default.isScreenShareSupported()}async createClient(){return this.client=new wn,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 V,J;if(m.kind==="videoinput"){let N=this.cameraVideoTrack||this.previewVideoTrack;if(m.deviceId===(N==null?void 0:N.getDeviceId())){if((await wo.default.getCameras()).length===0){this.client.emit("CameraChanged",!1,m);return}N.once("device-switched",()=>{this.client.emit("CameraChanged",!1,m)}),N.once("track-ended",()=>{this.client.emit("CameraChanged",!1,m)})}else this.client.emit("CameraChanged",!1,m)}else if(m.kind==="audioinput")if(m.deviceId===((V=this.microphoneAudioTrack)==null?void 0:V.getDeviceId())){if((await wo.default.getMicrophones()).length===0){this.client.emit("CameraChanged",!1,m);return}this.microphoneAudioTrack.once("device-switched",()=>{this.client.emit("CameraChanged",!1,m)}),(J=this.microphoneAudioTrack)==null||J.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;Fn.info("createCustomVideoTrack");let V=new Sd(m);return await V.init(),this.customVideoTrack=V,V}async detectCamera(m){var V,J;if(this.previewVideoTrack&&!this.previewVideoTrack.closed)return{checkIsActive:()=>{var N,z;return Promise.resolve(((z=(N=this.previewVideoTrack)==null?void 0:N.getMediaStreamTrack())==null?void 0:z.readyState)==="live")},cleanup:()=>{var N,z;(N=this.previewVideoTrack)==null||N.stop(),(z=this.previewVideoTrack)==null||z.close(),this.previewVideoTrack=void 0}};Fn.info("detectCamera");try{let N=new Ac({cameraId:m.cameraId,id:"pv"});return N.on("device-switched",z=>this.client.emit("DeviceSwitched",z)),this.previewVideoTrack=N,await N.init(),m.mirror&&N.mirrorVideo(m.mirror),m.container&&await N.play({container:m.container}),{checkIsActive:()=>{var z;return Promise.resolve(((z=N.getMediaStreamTrack())==null?void 0:z.readyState)==="live")},cleanup:()=>{N.stop(),N.close(),this.previewVideoTrack=void 0}}}catch(N){throw(V=this.previewVideoTrack)==null||V.stop(),(J=this.previewVideoTrack)==null||J.close(),this.previewVideoTrack=void 0,N}}processExternalMediaAEC(m){}async createMicrophoneAudioTrack(m){if(this.microphoneAudioTrack&&!this.microphoneAudioTrack.closed)return this.microphoneAudioTrack;Fn.info("createMicrophoneAudioTrack");let V=new Td({microphoneId:m});return V.on("device-switched",J=>this.client.emit("DeviceSwitched",J)),await V.init(),this.microphoneAudioTrack=V,this.client.emit("LocalTrackCreated",V),V}async createCameraVideoTrack(m){if(this.cameraVideoTrack&&!this.cameraVideoTrack.closed)return this.cameraVideoTrack;Fn.info(`createCameraVideoTrack ${JSON.stringify(m)}`);let V=new Ac(md(Jr({},m),{id:"ct"}));return V.on("device-switched",J=>this.client.emit("DeviceSwitched",J)),await V.init(),this.cameraVideoTrack=V,this.client.emit("LocalTrackCreated",V),this.cameraVideoTrack.on("VirtualBackgroundOverload",()=>{this._virtualOverloadCount++,new Date().getTime()-this._isVirtualOverloadStart>5e3&&(this._virtualOverloadCount>10&&this.client.emit("VirtualBackgroundOverload"),this._virtualOverloadCount=0,this._isVirtualOverloadStart=new Date().getTime())}),V}};xn([Ed(),In(X=>bg.createRTCError(X))],Io.prototype,"detectCamera",1),xn([In(X=>bg.createRTCError(X))],Io.prototype,"createMicrophoneAudioTrack",1),xn([In(X=>bg.createRTCError(X))],Io.prototype,"createCameraVideoTrack",1);var eG=Io;export{eG as default,Fn as loggerManager};
585
+ /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */